Skip to contentSkip to conversation

ALSA: Tascam US-16x08 DSP mixer quirk

PATCH Superseded OnkelDead 4 participants 5 messages Feb 15, 2017 – Feb 16, 2017 Sound

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

OnkelDead

author
#0 lore raw

PATCH v6 1/1 ALSA: Tascam US-16x08 DSP mixer quirk

Fixed codestyle, removed blank lines among the variable definitions / declarations. Changed log messages to usb_audio_dbg(), although they happens in therory only. Changed most control names to standard naming rule (where suitable, I'd miss naming rules for EQ or compressor features).

Add mixer quirk for Tascam US-16x08 usb interface. Even that this an usb compliant device,
the input channels and DSP functions (EQ/Compressor) arn't accessible by default.

---
 sound/usb/Makefile        |    1 +
 sound/usb/mixer_quirks.c  |    5 +
 sound/usb/mixer_us16x08.c | 1435 +++++++++++++++++++++++++++++++++++++++++++++
 sound/usb/mixer_us16x08.h |  122 ++++
 4 files changed, 1563 insertions(+)
 create mode 100644 sound/usb/mixer_us16x08.c
 create mode 100644 sound/usb/mixer_us16x08.h
sound/usb/Makefile +1 -0
index 2d2d122..42cb33b 100644
@@ -10,6 +10,7 @@ snd-usb-audio-objs := 	card.o \
 			mixer.o \
 			mixer_quirks.o \
 			mixer_scarlett.o \
+			mixer_us16x08.o \
 			pcm.o \
 			proc.o \
 			quirks.o \
sound/usb/mixer_quirks.c +5 -0
index 04991b0..4fa0053 100644
@@ -43,6 +43,7 @@
 #include "mixer.h"
 #include "mixer_quirks.h"
 #include "mixer_scarlett.h"
+#include "mixer_us16x08.h"
 #include "helper.h"
 
 extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl;
@@ -1729,6 +1730,10 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 		return err;
 
 	switch (mixer->chip->usb_id) {
+	/* Tascam US-16x08 */
+	case USB_ID(0x0644, 0x8047):
+		err = snd_us16x08_controls_create(mixer);
+		break;
 	case USB_ID(0x041e, 0x3020):
 	case USB_ID(0x041e, 0x3040):
 	case USB_ID(0x041e, 0x3042):
sound/usb/mixer_us16x08.c new file +1435 -0

1,435 lines not on this page · raw message

sound/usb/mixer_us16x08.h new file +122 -0

122 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi OnkelDead,

[auto build test WARNING on sound/for-next]
[also build test WARNING on v4.10-rc8 next-20170215]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/OnkelDead/ALSA-Tascam-US-16x08-DSP-mixer-quirk/20170215-222805
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: blackfin-allmodconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin

All warnings (new ones prefixed by >>):

sound/usb/mixer_us16x08.c: In function 'snd_us16x08_route_info':

>> sound/usb/mixer_us16x08.c:201:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     uinfo->value.enumerated.names_ptr = (__u64) route_names;
                                         ^

vim +201 sound/usb/mixer_us16x08.c

185 }
186
187 return err;
188 }
189
190 static int snd_us16x08_route_info(struct snd_kcontrol *kcontrol,
191 struct snd_ctl_elem_info *uinfo)
192 {
193 int i;
194
195 uinfo->count = 1;
196 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
197 uinfo->value.integer.max = SND_US16X08_KCMAX(kcontrol);
198 uinfo->value.integer.min = SND_US16X08_KCMIN(kcontrol);
199 uinfo->value.integer.step = SND_US16X08_KCSTEP(kcontrol);
200 uinfo->value.enumerated.items = 10;

 > 201		uinfo->value.enumerated.names_ptr = (__u64) route_names;

202 uinfo->value.enumerated.names_length = 0;
203 for (i = 0; i < 10; i++)
204 uinfo->value.enumerated.names_length +=
205 strlen(route_names[i]) + 1;
206 return 0;
207 }
208
209 static int snd_us16x08_route_get(struct snd_kcontrol *kcontrol,

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#2 lore raw

It seems that my approach to add names to snd_ctl_elem_info enumeration is wrong (see bleow). I couldn't find documentation or any example to lean on.
Any hints ?

-------- Weitergeleitete Nachricht --------
Betreff: Re: [alsa-devel] [PATCH v6 1/1] ALSA: Tascam US-16x08 DSP mixer quirk
Datum: Wed, 15 Feb 2017 23:46:04 +0800
Von: kbuild test robot <[email protected]>
An: OnkelDead <[email protected]>
Kopie (CC): OnkelDead <[email protected]>, [email protected], [email protected], [email protected]

Hi OnkelDead,

[auto build test WARNING on sound/for-next]
[also build test WARNING on v4.10-rc8 next-20170215]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/OnkelDead/ALSA-Tascam-US-16x08-DSP-mixer-quirk/20170215-222805
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: blackfin-allmodconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin

All warnings (new ones prefixed by >>):

sound/usb/mixer_us16x08.c: In function 'snd_us16x08_route_info':

Quoted 1 line
Quoted 1 line

sound/usb/mixer_us16x08.c:201:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

     uinfo->value.enumerated.names_ptr = (__u64) route_names;
                                         ^

vim +201 sound/usb/mixer_us16x08.c

185 }
186
187 return err;
188 }
189
190 static int snd_us16x08_route_info(struct snd_kcontrol *kcontrol,
191 struct snd_ctl_elem_info *uinfo)
192 {
193 int i;
194
195 uinfo->count = 1;
196 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
197 uinfo->value.integer.max = SND_US16X08_KCMAX(kcontrol);
198 uinfo->value.integer.min = SND_US16X08_KCMIN(kcontrol);
199 uinfo->value.integer.step = SND_US16X08_KCSTEP(kcontrol);
200 uinfo->value.enumerated.items = 10;

Quoted 1 line

201 uinfo->value.enumerated.names_ptr = (__u64) route_names;

202 uinfo->value.enumerated.names_length = 0;
203 for (i = 0; i < 10; i++)
204 uinfo->value.enumerated.names_length +=
205 strlen(route_names[i]) + 1;
206 return 0;
207 }
208
209 static int snd_us16x08_route_get(struct snd_kcontrol *kcontrol,

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw
Quoted 1 line · Detlef Urban

It seems that my approach to add names to snd_ctl_elem_info enumeration is wrong (see bleow).

You don't add names, you set a single name.
Anyway, just call snd_ctl_enum_info().

Regards,
Clemens

#4 lore raw
In reply to Detlef Urban
Quoted 60 lines · Detlef Urban

It seems that my approach to add names to snd_ctl_elem_info enumeration is wrong (see bleow).
I couldn't find documentation or any example to lean on. Any hints ?

-------- Weitergeleitete Nachricht --------
Betreff: Re: [alsa-devel] [PATCH v6 1/1] ALSA: Tascam US-16x08
DSP mixer quirk
Datum: Wed, 15 Feb 2017 23:46:04 +0800
Von: kbuild test robot <[email protected]>
An: OnkelDead <[email protected]>
Kopie (CC): OnkelDead <[email protected]>,
[email protected], [email protected], [email protected]

Hi OnkelDead,

[auto build test WARNING on sound/for-next]
[also build test WARNING on v4.10-rc8 next-20170215]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/OnkelDead/ALSA-Tascam-US-16x08-DSP-mixer-quirk/20170215-222805
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: blackfin-allmodconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin

All warnings (new ones prefixed by >>):

   sound/usb/mixer_us16x08.c: In function 'snd_us16x08_route_info':
Quoted 1 line
Quoted 1 line

sound/usb/mixer_us16x08.c:201:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

     uinfo->value.enumerated.names_ptr = (__u64) route_names;
                                         ^

vim +201 sound/usb/mixer_us16x08.c

   185		}
   186	
   187		return err;
   188	}
   189	
   190	static int snd_us16x08_route_info(struct snd_kcontrol *kcontrol,
   191		struct snd_ctl_elem_info *uinfo)
   192	{
   193		int i;
   194	
   195		uinfo->count = 1;
   196		uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
   197		uinfo->value.integer.max = SND_US16X08_KCMAX(kcontrol);
   198		uinfo->value.integer.min = SND_US16X08_KCMIN(kcontrol);
   199		uinfo->value.integer.step = SND_US16X08_KCSTEP(kcontrol);
   200		uinfo->value.enumerated.items = 10;
Quoted 7 lines
Quoted 1 line

201 uinfo->value.enumerated.names_ptr = (__u64) route_names;

   202		uinfo->value.enumerated.names_length = 0;
   203		for (i = 0; i < 10; i++)
   204			uinfo->value.enumerated.names_length +=
   205				strlen(route_names[i]) + 1;
   206		return 0;
   207	}

The code does wrong in multiple ways.

First off, if you use ENUMERATED type, you can't set uinfo->value.integer.*, but you can set only uinfo->value.enumerated.*. It's a union, so you know why.

Second, value.enumerated.names_ptr and value.enumerated.names_length are not used for the normal kctls, it's only for special kctls. Leave them.

Third, the concept of enum kctl info callback is to return only three
things: count, value.enumerated.items, and value.enumerated.name. The first one is the size of the array, the second is the size of the enum list, and the third one is the enum string corresponding to the value.enumearted.item given by the caller.

And, the solution is, like Clemens already mentioned, to use snd_ctl_enum_info() helper function:

static int snd_us16x08_route_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)

{
	return snd_ctl_enum_info(uinfo, 1, 10, route_names);
}

Takashi