]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Check control API protocol version for TLV control
authorTakashi Iwai <tiwai@suse.de>
Sun, 17 Sep 2006 20:06:46 +0000 (22:06 +0200)
committerTakashi Iwai <tiwai@suse.de>
Sun, 17 Sep 2006 20:06:46 +0000 (22:06 +0200)
Check control API protocol version to avoid unnecessary ioctl
access for TLV stuff on the older drivers.

src/control/control_hw.c

index 88770eebea593e5a9a1f3bca7b9aec9e8732277f..caa1dcab2be90dd4759b4637729e80945b040814 100644 (file)
@@ -40,11 +40,12 @@ const char *_snd_module_control_hw = "";
 
 #ifndef DOC_HIDDEN
 #define SNDRV_FILE_CONTROL     ALSA_DEVICE_DIRECTORY "controlC%i"
-#define SNDRV_CTL_VERSION_MAX  SNDRV_PROTOCOL_VERSION(2, 0, 3)
+#define SNDRV_CTL_VERSION_MAX  SNDRV_PROTOCOL_VERSION(2, 0, 4)
 
 typedef struct {
        int card;
        int fd;
+       unsigned int protocol;
 } snd_ctl_hw_t;
 #endif /* DOC_HIDDEN */
 
@@ -208,6 +209,10 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
        snd_ctl_hw_t *hw = handle->private_data;
        struct sndrv_ctl_tlv *xtlv;
        
+       /* we don't support TLV on protocol ver 2.0.3 or earlier */
+       if (hw->protocol < SNDRV_PROTOCOL_VERSION(2, 0, 4))
+               return -ENXIO;
+
        switch (op_flag) {
        case -1: inum = SNDRV_CTL_IOCTL_TLV_COMMAND; break;
        case 0: inum = SNDRV_CTL_IOCTL_TLV_READ; break;
@@ -407,6 +412,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
        }
        hw->card = card;
        hw->fd = fd;
+       hw->protocol = ver;
 
        err = snd_ctl_new(&ctl, SND_CTL_TYPE_HW, name);
        if (err < 0) {