29 #include <linux/slab.h>
31 #include <linux/usb/audio.h>
53 static void usb_mixer_elem_free(
struct snd_kcontrol *kctl)
110 kctl->
tlv.
c = tlv_callback;
111 kctl->
vd[0].access |=
150 static const struct rc_config {
155 u8 min_packet_length;
159 {
USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 },
160 {
USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 },
161 {
USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 },
162 {
USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d },
163 {
USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d },
164 {
USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 },
167 static void snd_usb_soundblaster_remote_complete(
struct urb *
urb)
170 const struct rc_config *
rc = mixer->
rc_cfg;
173 if (urb->status < 0 || urb->actual_length < rc->min_packet_length)
178 code |= mixer->
rc_buffer[rc->offset + 1] << 8;
181 if (code == rc->mute_code)
188 static long snd_usb_sbrc_hwdep_read(
struct snd_hwdep *
hw,
char __user *
buf,
195 if (count != 1 && count != 4)
205 return err < 0 ? err :
count;
208 static unsigned int snd_usb_sbrc_hwdep_poll(
struct snd_hwdep *hw,
struct file *
file,
213 poll_wait(file, &mixer->
rc_waitq, wait);
223 if (rc_configs[i].usb_id == mixer->
chip->usb_id)
227 mixer->
rc_cfg = &rc_configs[
i];
229 len = mixer->
rc_cfg->packet_length;
236 "%s remote control", mixer->
chip->card->shortname);
239 hwdep->
ops.read = snd_usb_sbrc_hwdep_read;
240 hwdep->
ops.poll = snd_usb_sbrc_hwdep_poll;
258 usb_fill_control_urb(mixer->
rc_urb, mixer->
chip->dev,
259 usb_rcvctrlpipe(mixer->
chip->dev, 0),
261 snd_usb_soundblaster_remote_complete, mixer);
265 #define snd_audigy2nx_led_info snd_ctl_boolean_mono_info
287 if (mixer->
chip->shutdown) {
291 if (mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3042))
293 usb_sndctrlpipe(mixer->
chip->dev, 0), 0x24,
297 if (mixer->
chip->usb_id ==
USB_ID(0x041e, 0x30df))
299 usb_sndctrlpipe(mixer->
chip->dev, 0), 0x24,
304 usb_sndctrlpipe(mixer->
chip->dev, 0), 0x24,
306 value, index + 2,
NULL, 0);
318 .name =
"CMSS LED Switch",
320 .get = snd_audigy2nx_led_get,
321 .put = snd_audigy2nx_led_put,
326 .name =
"Power LED Switch",
328 .get = snd_audigy2nx_led_get,
329 .put = snd_audigy2nx_led_put,
334 .name =
"Dolby Digital LED Switch",
336 .get = snd_audigy2nx_led_get,
337 .put = snd_audigy2nx_led_put,
346 for (i = 0; i <
ARRAY_SIZE(snd_audigy2nx_controls); ++
i) {
348 if ((mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3042)) && i == 0)
351 if ((mixer->
chip->usb_id ==
USB_ID(0x041e, 0x30df)) && i == 0)
354 (mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3040) ||
355 mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3042) ||
356 mixer->
chip->usb_id ==
USB_ID(0x041e, 0x30df) ||
357 mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3048)))
371 static const struct sb_jack {
374 } jacks_audigy2nx[] = {
380 }, jacks_live24ext[] = {
386 const struct sb_jack *jacks;
391 snd_iprintf(buffer,
"%s jacks\n\n", mixer->
chip->card->shortname);
392 if (mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3020))
393 jacks = jacks_audigy2nx;
394 else if (mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3040) ||
395 mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3048))
396 jacks = jacks_live24ext;
400 for (i = 0; jacks[
i].name; ++
i) {
401 snd_iprintf(buffer,
"%s: ", jacks[i].name);
403 if (mixer->
chip->shutdown)
407 usb_rcvctrlpipe(mixer->
chip->dev, 0),
410 jacks[i].unitid << 8, buf, 3);
412 if (err == 3 && (buf[0] == 3 || buf[0] == 6))
413 snd_iprintf(buffer,
"%02x %02x\n", buf[1], buf[2]);
415 snd_iprintf(buffer,
"?\n");
419 static int snd_xonar_u1_switch_get(
struct snd_kcontrol *kcontrol,
428 static int snd_xonar_u1_switch_put(
struct snd_kcontrol *kcontrol,
432 u8 old_status, new_status;
436 if (ucontrol->
value.integer.value[0])
437 new_status = old_status | 0x02;
439 new_status = old_status & ~0x02;
440 changed = new_status != old_status;
442 if (mixer->
chip->shutdown)
446 usb_sndctrlpipe(mixer->
chip->dev, 0), 0x08,
448 50, 0, &new_status, 1);
458 .name =
"Digital Playback Switch",
460 .get = snd_xonar_u1_switch_get,
461 .put = snd_xonar_u1_switch_put,
478 #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
480 static int snd_nativeinstruments_control_get(
struct snd_kcontrol *kcontrol,
484 struct usb_device *
dev = mixer->
chip->dev;
491 if (mixer->
chip->shutdown)
497 &tmp,
sizeof(tmp), 1000);
502 "unable to issue vendor read request (ret = %d)", ret);
506 ucontrol->
value.integer.value[0] =
tmp;
511 static int snd_nativeinstruments_control_put(
struct snd_kcontrol *kcontrol,
515 struct usb_device *
dev = mixer->
chip->dev;
522 if (mixer->
chip->shutdown)
533 "unable to issue vendor write request (ret = %d)", ret);
542 .name =
"Direct Thru Channel A",
546 .name =
"Direct Thru Channel B",
550 .name =
"Phono Input Channel A",
554 .name =
"Phono Input Channel B",
561 .name =
"Direct Thru Channel A",
565 .name =
"Direct Thru Channel B",
569 .name =
"Direct Thru Channel C",
573 .name =
"Direct Thru Channel D",
577 .name =
"Phono Input Channel A",
581 .name =
"Phono Input Channel B",
585 .name =
"Phono Input Channel C",
589 .name =
"Phono Input Channel D",
602 .get = snd_nativeinstruments_control_get,
603 .put = snd_nativeinstruments_control_put,
607 for (i = 0; i <
count; i++) {
610 template.name = kc[
i].
name;
631 static int snd_ftu_eff_switch_info(
struct snd_kcontrol *kcontrol,
634 static const char *texts[8] = {
"Room 1",
655 static int snd_ftu_eff_switch_get(
struct snd_kcontrol *kctl,
662 unsigned char value[2];
666 const int val_len = 2;
689 if (mixer->
chip->shutdown)
695 validx << 8, snd_usb_ctrl_intf(chip) | (
id << 8),
701 ucontrol->
value.enumerated.item[0] = value[0];
708 static int snd_ftu_eff_switch_put(
struct snd_kcontrol *kctl,
716 unsigned char value[2];
720 const int validx = 1;
721 const int val_len = 2;
728 new_val = ucontrol->
value.enumerated.item[0];
741 if (mixer->
chip->shutdown)
747 validx << 8, snd_usb_ctrl_intf(chip) | (
id << 8),
758 if (cur_val != new_val) {
762 if (mixer->
chip->shutdown)
768 validx << 8, snd_usb_ctrl_intf(chip) | (
id << 8),
786 .name =
"Effect Program Switch",
789 .info = snd_ftu_eff_switch_info,
790 .get = snd_ftu_eff_switch_get,
791 .put = snd_ftu_eff_switch_put
806 template.private_value = (
unsigned long) pval;
827 const unsigned int id = 5;
830 for (out = 0; out < 8; out++) {
832 for (in = 0; in < 8; in++) {
835 "AIn%d - Out%d Capture Volume",
837 err = snd_create_std_mono_ctl(mixer,
id, control,
838 cmask, val_type, name,
843 for (in = 8; in < 16; in++) {
846 "DIn%d - Out%d Playback Volume",
848 err = snd_create_std_mono_ctl(mixer,
id, control,
849 cmask, val_type, name,
862 static const char name[] =
"Effect Volume";
863 const unsigned int id = 6;
865 const unsigned int control = 2;
866 const unsigned int cmask = 0;
868 return snd_create_std_mono_ctl(mixer,
id, control, cmask, val_type,
875 static const char name[] =
"Effect Duration";
876 const unsigned int id = 6;
878 const unsigned int control = 3;
879 const unsigned int cmask = 0;
881 return snd_create_std_mono_ctl(mixer,
id, control, cmask, val_type,
888 static const char name[] =
"Effect Feedback Volume";
889 const unsigned int id = 6;
891 const unsigned int control = 4;
892 const unsigned int cmask = 0;
894 return snd_create_std_mono_ctl(mixer,
id, control, cmask, val_type,
904 const unsigned int id = 7;
906 const unsigned int control = 7;
908 for (ch = 0; ch < 4; ++ch) {
911 "Effect Return %d Volume", ch + 1);
912 err = snd_create_std_mono_ctl(mixer,
id, control,
913 cmask, val_type, name,
928 const unsigned int id = 5;
930 const unsigned int control = 9;
932 for (ch = 0; ch < 8; ++ch) {
935 "Effect Send AIn%d Volume", ch + 1);
936 err = snd_create_std_mono_ctl(mixer,
id, control, cmask,
942 for (ch = 8; ch < 16; ++ch) {
945 "Effect Send DIn%d Volume", ch - 7);
946 err = snd_create_std_mono_ctl(mixer,
id, control, cmask,
959 err = snd_ftu_create_volume_ctls(mixer);
963 err = snd_ftu_create_effect_switch(mixer);
966 err = snd_ftu_create_effect_volume_ctl(mixer);
970 err = snd_ftu_create_effect_duration_ctl(mixer);
974 err = snd_ftu_create_effect_feedback_ctl(mixer);
978 err = snd_ftu_create_effect_return_ctls(mixer);
982 err = snd_ftu_create_effect_send_ctls(mixer);
990 unsigned char samplerate_id)
1019 .name =
"Headphone Playback Switch"
1026 .name =
"Headphone A Mix Playback Volume"
1033 .name =
"Headphone B Mix Playback Volume"
1041 .name =
"Output Playback Switch"
1048 .name =
"Output A Playback Volume"
1055 .name =
"Output B Playback Volume"
1063 .name =
"Input Capture Switch"
1070 .name =
"Input A Capture Volume"
1077 .name =
"Input B Capture Volume"
1088 if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
1091 switch (mixer->
chip->usb_id) {
1092 case USB_ID(0x041e, 0x3020):
1093 case USB_ID(0x041e, 0x3040):
1094 case USB_ID(0x041e, 0x3042):
1095 case USB_ID(0x041e, 0x30df):
1096 case USB_ID(0x041e, 0x3048):
1097 err = snd_audigy2nx_controls_create(mixer);
1100 if (!snd_card_proc_new(mixer->
chip->card,
"audigy2nx", &entry))
1101 snd_info_set_text_ops(entry, mixer,
1102 snd_audigy2nx_proc_read);
1105 case USB_ID(0x0763, 0x2080):
1106 case USB_ID(0x0763, 0x2081):
1107 err = snd_ftu_create_mixer(mixer);
1110 case USB_ID(0x0b05, 0x1739):
1111 case USB_ID(0x0b05, 0x1743):
1112 err = snd_xonar_u1_controls_create(mixer);
1115 case USB_ID(0x17cc, 0x1011):
1116 err = snd_nativeinstruments_create_mixer(mixer,
1117 snd_nativeinstruments_ta6_mixers,
1118 ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
1121 case USB_ID(0x17cc, 0x1021):
1122 err = snd_nativeinstruments_create_mixer(mixer,
1123 snd_nativeinstruments_ta10_mixers,
1124 ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
1127 case USB_ID(0x200c, 0x1018):
1129 err = snd_create_std_mono_table(mixer, ebox44_table);
1154 if (mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3040) ||
1155 mixer->
chip->usb_id ==
USB_ID(0x041e, 0x3048))