aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/usb/pcm.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 2bf0d77d1768..056587de7be4 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -120,10 +120,6 @@ static int init_pitch_v1(struct snd_usb_audio *chip, int iface,
120 120
121 ep = get_endpoint(alts, 0)->bEndpointAddress; 121 ep = get_endpoint(alts, 0)->bEndpointAddress;
122 122
123 /* if endpoint doesn't have pitch control, bail out */
124 if (!(fmt->attributes & UAC_EP_CS_ATTR_PITCH_CONTROL))
125 return 0;
126
127 data[0] = 1; 123 data[0] = 1;
128 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, 124 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
129 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 125 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
@@ -137,8 +133,32 @@ static int init_pitch_v1(struct snd_usb_audio *chip, int iface,
137 return 0; 133 return 0;
138} 134}
139 135
136static int init_pitch_v2(struct snd_usb_audio *chip, int iface,
137 struct usb_host_interface *alts,
138 struct audioformat *fmt)
139{
140 struct usb_device *dev = chip->dev;
141 unsigned char data[1];
142 unsigned int ep;
143 int err;
144
145 ep = get_endpoint(alts, 0)->bEndpointAddress;
146
147 data[0] = 1;
148 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
149 USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
150 UAC2_EP_CS_PITCH << 8, 0,
151 data, sizeof(data), 1000)) < 0) {
152 snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH (v2)\n",
153 dev->devnum, iface, fmt->altsetting);
154 return err;
155 }
156
157 return 0;
158}
159
140/* 160/*
141 * initialize the picth control and sample rate 161 * initialize the pitch control and sample rate
142 */ 162 */
143int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface, 163int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
144 struct usb_host_interface *alts, 164 struct usb_host_interface *alts,
@@ -146,13 +166,16 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface,
146{ 166{
147 struct usb_interface_descriptor *altsd = get_iface_desc(alts); 167 struct usb_interface_descriptor *altsd = get_iface_desc(alts);
148 168
169 /* if endpoint doesn't have pitch control, bail out */
170 if (!(fmt->attributes & UAC_EP_CS_ATTR_PITCH_CONTROL))
171 return 0;
172
149 switch (altsd->bInterfaceProtocol) { 173 switch (altsd->bInterfaceProtocol) {
150 case UAC_VERSION_1: 174 case UAC_VERSION_1:
151 return init_pitch_v1(chip, iface, alts, fmt); 175 return init_pitch_v1(chip, iface, alts, fmt);
152 176
153 case UAC_VERSION_2: 177 case UAC_VERSION_2:
154 /* not implemented yet */ 178 return init_pitch_v2(chip, iface, alts, fmt);
155 return 0;
156 } 179 }
157 180
158 return -EINVAL; 181 return -EINVAL;