[alsa-devel] Hardware-specific IOCTLs
Message body Hello All, My question is about how to allocate a new hardware-specific IOCTL code. For example, the HDA driver consists of common HDA code and vendor-specific codes for various HDA codecs. As an HDA codec vendor, I want to be able to control some functionality in my codec, that is not present in codecs from other vendors. For this, I want to implement a special IOCTL in my vendor-specific code. I understand that I can register an IOCTL handler using snd_ctl_register_ioctl. My difficulty is how to define a code for my IOCTL and avoid a conflict with the common code in the future. Looking at header files, I see common "ALSA" audio IOCTLs starting with letter 'A', and "HWDEP" IOCTLs starting with letter 'H'. Some of H-IOCTLs are defined in asound.h, starting at offset 0, and some in hda_hwdep.h and sb16_csp.h starting at offset 0x10. My guess is that the latter start at 0x10 to give some expansion room for H-IOCTLs in asound.h...? I think I need some offset range in H-IOCTLs or a new IOCTL family with another letter, officially reserved for such codec-specific IOCTLs. Any suggestions? Best regards, Ivan
Ivan Bublikov wrote:
As an HDA codec vendor, I want to be able to control some functionality in my codec, that is not present in codecs from other vendors. [...] I can register an IOCTL handler using snd_ctl_register_ioctl.
This functions is for ioctl calls on the ctl device, which is global for one sound card and is not appropriate if one wants to address something like a PCM device or a codec.
For a HDA codec, use a hwdep device.
My difficulty is how to define a code for my IOCTL and avoid a conflict with the common code in the future.
Pick something not yet allocated in Documentation/ioctl/ioctl-number.txt.
Regards, Clemens
From: Clemens Ladisch clemens@ladisch.de
Ivan Bublikov wrote:
As an HDA codec vendor, I want to be able to control some functionality in my codec, that is not present in codecs from other vendors. [...] I can register an IOCTL handler using snd_ctl_register_ioctl.
This functions is for ioctl calls on the ctl device, which is global for one sound card and is not appropriate if one wants to address something like a PCM device or a codec.
For a HDA codec, use a hwdep device.
OK, I understand I simply need to add a new case in hda_hwdep_ioctl().
My difficulty is how to define a code for my IOCTL and avoid a conflict with the common code in the future.
Pick something not yet allocated in Documentation/ioctl/ioctl-number.txt.
Since half of the lines in it are marked "Conflict!" anyway, should I only pay attention to not conflict with "sound/*" lines? And then add a new line for my IOCTLs? And should I put my IOCTL definitions in hda_hwdep.h or create a new file?
Ivan Bublikov wrote:
Ivan Bublikov wrote:
My difficulty is how to define a code for my IOCTL and avoid a conflict with the common code in the future.
Pick something not yet allocated in Documentation/ioctl/ioctl-number.txt.
Since half of the lines in it are marked "Conflict!" anyway, should I only pay attention to not conflict with "sound/*" lines?
There are enough free codes so that you do not need to introduce new conflicts.
And then add a new line for my IOCTLs?
Yes.
And should I put my IOCTL definitions in hda_hwdep.h or create a new file?
If you go through the existing HDA hwdep device, your ioctls probably should go into the same header.
Regards, Clemens
participants (2)
-
Clemens Ladisch
-
Ivan Bublikov