From a7bc1dd80c33400081bd113b8b8e1e989612ebe0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 17 Sep 2006 22:06:46 +0200 Subject: [PATCH] Check control API protocol version for TLV control Check control API protocol version to avoid unnecessary ioctl access for TLV stuff on the older drivers. --- src/control/control_hw.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/control/control_hw.c b/src/control/control_hw.c index 88770eeb..caa1dcab 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -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) { -- 2.47.1