control.c (50d1e9302bab7d35dae7146f8c468e0943015616) control.c (bd4cbf6c7689d35d5d1248369d2c350f4711ca0a)
1/*
2 * Copyright (c) 2007 Daniel Mack
3 * friendly supported by NI.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 28 unchanged lines hidden (view full) ---

37 int is_intval = pos & CNT_INTVAL;
38 int maxval = 63;
39
40 uinfo->count = 1;
41 pos &= ~CNT_INTVAL;
42
43 switch (dev->chip.usb_id) {
44 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
1/*
2 * Copyright (c) 2007 Daniel Mack
3 * friendly supported by NI.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 28 unchanged lines hidden (view full) ---

37 int is_intval = pos & CNT_INTVAL;
38 int maxval = 63;
39
40 uinfo->count = 1;
41 pos &= ~CNT_INTVAL;
42
43 switch (dev->chip.usb_id) {
44 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
45 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
45 if (pos == 0) {
46 if (pos == 0) {
46 /* current input mode of A8DJ */
47 /* current input mode of A8DJ and A4DJ */
47 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
48 uinfo->value.integer.min = 0;
49 uinfo->value.integer.max = 2;
50 return 0;
51 }
52 break;
53
48 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
49 uinfo->value.integer.min = 0;
50 uinfo->value.integer.max = 2;
51 return 0;
52 }
53 break;
54
54 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
55 if (pos == 0) {
56 /* current input mode of A4DJ */
57 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
58 uinfo->value.integer.min = 0;
59 uinfo->value.integer.max = 1;
60 return 0;
61 }
62 break;
63
64 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
65 maxval = 127;
66 break;
67 }
68
69 if (is_intval) {
70 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
71 uinfo->value.integer.min = 0;

--- 9 unchanged lines hidden (view full) ---

81
82static int control_get(struct snd_kcontrol *kcontrol,
83 struct snd_ctl_elem_value *ucontrol)
84{
85 struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
86 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
87 int pos = kcontrol->private_value;
88
55 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
56 maxval = 127;
57 break;
58 }
59
60 if (is_intval) {
61 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
62 uinfo->value.integer.min = 0;

--- 9 unchanged lines hidden (view full) ---

72
73static int control_get(struct snd_kcontrol *kcontrol,
74 struct snd_ctl_elem_value *ucontrol)
75{
76 struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
77 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
78 int pos = kcontrol->private_value;
79
89 if (dev->chip.usb_id ==
90 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) {
91 /* A4DJ has only one control */
92 /* do not expose hardware input mode 0 */
93 ucontrol->value.integer.value[0] = dev->control_state[0] - 1;
94 return 0;
95 }
96
97 if (pos & CNT_INTVAL)
98 ucontrol->value.integer.value[0]
99 = dev->control_state[pos & ~CNT_INTVAL];
100 else
101 ucontrol->value.integer.value[0]
102 = !!(dev->control_state[pos / 8] & (1 << pos % 8));
103
104 return 0;
105}
106
107static int control_put(struct snd_kcontrol *kcontrol,
108 struct snd_ctl_elem_value *ucontrol)
109{
110 struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
111 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
112 int pos = kcontrol->private_value;
113 unsigned char cmd = EP1_CMD_WRITE_IO;
114
115 switch (dev->chip.usb_id) {
80 if (pos & CNT_INTVAL)
81 ucontrol->value.integer.value[0]
82 = dev->control_state[pos & ~CNT_INTVAL];
83 else
84 ucontrol->value.integer.value[0]
85 = !!(dev->control_state[pos / 8] & (1 << pos % 8));
86
87 return 0;
88}
89
90static int control_put(struct snd_kcontrol *kcontrol,
91 struct snd_ctl_elem_value *ucontrol)
92{
93 struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
94 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
95 int pos = kcontrol->private_value;
96 unsigned char cmd = EP1_CMD_WRITE_IO;
97
98 switch (dev->chip.usb_id) {
116 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): {
117 /* A4DJ has only one control */
118 /* do not expose hardware input mode 0 */
119 dev->control_state[0] = ucontrol->value.integer.value[0] + 1;
120 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
121 dev->control_state, sizeof(dev->control_state));
122 return 1;
123 }
124
125 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
126 cmd = EP1_CMD_DIMM_LEDS;
127 break;
128 }
129
130 if (pos & CNT_INTVAL) {
131 dev->control_state[pos & ~CNT_INTVAL]
132 = ucontrol->value.integer.value[0];

--- 257 unchanged lines hidden ---
99 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
100 cmd = EP1_CMD_DIMM_LEDS;
101 break;
102 }
103
104 if (pos & CNT_INTVAL) {
105 dev->control_state[pos & ~CNT_INTVAL]
106 = ucontrol->value.integer.value[0];

--- 257 unchanged lines hidden ---