clock.c (bc23416cd4579093acc1e7d819eee747def623da) | clock.c (11bcbc443a17653c65bc20029172fae76f4bcca4) |
---|---|
1/* 2 * Clock domain and sample rate management functions 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * --- 89 unchanged lines hidden (view full) --- 98static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_id) 99{ 100 unsigned char buf; 101 int ret; 102 103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), 104 UAC2_CS_CUR, 105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, | 1/* 2 * Clock domain and sample rate management functions 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * --- 89 unchanged lines hidden (view full) --- 98static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_id) 99{ 100 unsigned char buf; 101 int ret; 102 103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), 104 UAC2_CS_CUR, 105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, |
106 UAC2_CX_CLOCK_SELECTOR << 8, selector_id << 8, | 106 UAC2_CX_CLOCK_SELECTOR << 8, 107 snd_usb_ctrl_intf(chip) | (selector_id << 8), |
107 &buf, sizeof(buf), 1000); 108 109 if (ret < 0) 110 return ret; 111 112 return buf; 113} 114 115static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) 116{ 117 int err; 118 unsigned char data; 119 struct usb_device *dev = chip->dev; 120 121 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 122 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | 108 &buf, sizeof(buf), 1000); 109 110 if (ret < 0) 111 return ret; 112 113 return buf; 114} 115 116static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) 117{ 118 int err; 119 unsigned char data; 120 struct usb_device *dev = chip->dev; 121 122 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 123 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, |
123 UAC2_CS_CONTROL_CLOCK_VALID << 8, source_id << 8, | 124 UAC2_CS_CONTROL_CLOCK_VALID << 8, 125 snd_usb_ctrl_intf(chip) | (source_id << 8), |
124 &data, sizeof(data), 1000); 125 126 if (err < 0) { 127 snd_printk(KERN_WARNING "%s(): cannot get clock validity for id %d\n", 128 __func__, source_id); 129 return err; 130 } 131 --- 132 unchanged lines hidden (view full) --- 264 } 265 266 data[0] = rate; 267 data[1] = rate >> 8; 268 data[2] = rate >> 16; 269 data[3] = rate >> 24; 270 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 271 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | 126 &data, sizeof(data), 1000); 127 128 if (err < 0) { 129 snd_printk(KERN_WARNING "%s(): cannot get clock validity for id %d\n", 130 __func__, source_id); 131 return err; 132 } 133 --- 132 unchanged lines hidden (view full) --- 266 } 267 268 data[0] = rate; 269 data[1] = rate >> 8; 270 data[2] = rate >> 16; 271 data[3] = rate >> 24; 272 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 273 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, |
272 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, | 274 UAC2_CS_CONTROL_SAM_FREQ << 8, 275 snd_usb_ctrl_intf(chip) | (clock << 8), |
273 data, sizeof(data), 1000)) < 0) { 274 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", 275 dev->devnum, iface, fmt->altsetting, rate); 276 return err; 277 } 278 279 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 280 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | 276 data, sizeof(data), 1000)) < 0) { 277 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", 278 dev->devnum, iface, fmt->altsetting, rate); 279 return err; 280 } 281 282 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 283 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, |
281 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, | 284 UAC2_CS_CONTROL_SAM_FREQ << 8, 285 snd_usb_ctrl_intf(chip) | (clock << 8), |
282 data, sizeof(data), 1000)) < 0) { 283 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", 284 dev->devnum, iface, fmt->altsetting); 285 return err; 286 } 287 288 crate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); 289 if (crate != rate) --- 22 unchanged lines hidden --- | 286 data, sizeof(data), 1000)) < 0) { 287 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", 288 dev->devnum, iface, fmt->altsetting); 289 return err; 290 } 291 292 crate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); 293 if (crate != rate) --- 22 unchanged lines hidden --- |