2 * f_uac2.c -- USB Audio Class 2.0 Function
5 * Yadwinder Singh (yadi.brar01@gmail.com)
6 * Jaswinder Singh (jaswinder.singh@linaro.org)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/usb/audio.h>
15 #include <linux/usb/audio-v2.h>
16 #include <linux/platform_device.h>
17 #include <linux/module.h>
19 #include <sound/core.h>
20 #include <sound/pcm.h>
21 #include <sound/pcm_params.h>
23 /* Playback(USB-IN) Default Stereo - Fl/Fr */
24 static int p_chmask
= 0x3;
25 module_param(p_chmask
, uint
, S_IRUGO
);
26 MODULE_PARM_DESC(p_chmask
, "Playback Channel Mask");
28 /* Playback Default 48 KHz */
29 static int p_srate
= 48000;
30 module_param(p_srate
, uint
, S_IRUGO
);
31 MODULE_PARM_DESC(p_srate
, "Playback Sampling Rate");
33 /* Playback Default 16bits/sample */
34 static int p_ssize
= 2;
35 module_param(p_ssize
, uint
, S_IRUGO
);
36 MODULE_PARM_DESC(p_ssize
, "Playback Sample Size(bytes)");
38 /* Capture(USB-OUT) Default Stereo - Fl/Fr */
39 static int c_chmask
= 0x3;
40 module_param(c_chmask
, uint
, S_IRUGO
);
41 MODULE_PARM_DESC(c_chmask
, "Capture Channel Mask");
43 /* Capture Default 64 KHz */
44 static int c_srate
= 64000;
45 module_param(c_srate
, uint
, S_IRUGO
);
46 MODULE_PARM_DESC(c_srate
, "Capture Sampling Rate");
48 /* Capture Default 16bits/sample */
49 static int c_ssize
= 2;
50 module_param(c_ssize
, uint
, S_IRUGO
);
51 MODULE_PARM_DESC(c_ssize
, "Capture Sample Size(bytes)");
53 /* Keep everyone on toes */
57 * The driver implements a simple UAC_2 topology.
58 * USB-OUT -> IT_1 -> OT_3 -> ALSA_Capture
59 * ALSA_Playback -> IT_2 -> OT_4 -> USB-IN
60 * Capture and Playback sampling rates are independently
61 * controlled by two clock sources :
62 * CLK_5 := c_srate, and CLK_6 := p_srate
64 #define USB_OUT_IT_ID 1
66 #define IO_OUT_OT_ID 3
67 #define USB_IN_OT_ID 4
68 #define USB_OUT_CLK_ID 5
69 #define USB_IN_CLK_ID 6
71 #define CONTROL_ABSENT 0
72 #define CONTROL_RDONLY 1
73 #define CONTROL_RDWR 3
75 #define CLK_FREQ_CTRL 0
76 #define CLK_VLD_CTRL 2
85 const char *uac2_name
= "snd_uac2";
88 struct uac2_rtd_params
*pp
; /* parent param */
89 struct usb_request
*req
;
92 struct uac2_rtd_params
{
93 struct snd_uac2_chip
*uac2
; /* parent chip */
94 bool ep_enabled
; /* if the ep is enabled */
95 /* Size of the ring buffer */
97 unsigned char *dma_area
;
99 struct snd_pcm_substream
*ss
;
109 struct uac2_req ureq
[USB_XFERS
];
114 struct snd_uac2_chip
{
115 struct platform_device pdev
;
116 struct platform_driver pdrv
;
118 struct uac2_rtd_params p_prm
;
119 struct uac2_rtd_params c_prm
;
121 struct snd_card
*card
;
125 #define BUFF_SIZE_MAX (PAGE_SIZE * 16)
126 #define PRD_SIZE_MAX PAGE_SIZE
127 #define MIN_PERIODS 4
129 static struct snd_pcm_hardware uac2_pcm_hardware
= {
130 .info
= SNDRV_PCM_INFO_INTERLEAVED
| SNDRV_PCM_INFO_BLOCK_TRANSFER
131 | SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_MMAP_VALID
132 | SNDRV_PCM_INFO_PAUSE
| SNDRV_PCM_INFO_RESUME
,
133 .rates
= SNDRV_PCM_RATE_CONTINUOUS
,
134 .periods_max
= BUFF_SIZE_MAX
/ PRD_SIZE_MAX
,
135 .buffer_bytes_max
= BUFF_SIZE_MAX
,
136 .period_bytes_max
= PRD_SIZE_MAX
,
137 .periods_min
= MIN_PERIODS
,
142 u8 as_out_intf
, as_out_alt
;
143 u8 as_in_intf
, as_in_alt
;
145 struct usb_ep
*in_ep
, *out_ep
;
146 struct usb_function func
;
148 /* The ALSA Sound Card it represents on the USB-Client side */
149 struct snd_uac2_chip uac2
;
152 static struct audio_dev
*agdev_g
;
155 struct audio_dev
*func_to_agdev(struct usb_function
*f
)
157 return container_of(f
, struct audio_dev
, func
);
161 struct audio_dev
*uac2_to_agdev(struct snd_uac2_chip
*u
)
163 return container_of(u
, struct audio_dev
, uac2
);
167 struct snd_uac2_chip
*pdev_to_uac2(struct platform_device
*p
)
169 return container_of(p
, struct snd_uac2_chip
, pdev
);
173 uint
num_channels(uint chanmask
)
178 num
+= (chanmask
& 1);
186 agdev_iso_complete(struct usb_ep
*ep
, struct usb_request
*req
)
190 bool update_alsa
= false;
191 unsigned char *src
, *dst
;
192 int status
= req
->status
;
193 struct uac2_req
*ur
= req
->context
;
194 struct snd_pcm_substream
*substream
;
195 struct uac2_rtd_params
*prm
= ur
->pp
;
196 struct snd_uac2_chip
*uac2
= prm
->uac2
;
198 /* i/f shutting down */
199 if (!prm
->ep_enabled
)
203 * We can't really do much about bad xfers.
204 * Afterall, the ISOCH xfers could fail legitimately.
207 pr_debug("%s: iso_complete status(%d) %d/%d\n",
208 __func__
, status
, req
->actual
, req
->length
);
212 /* Do nothing if ALSA isn't active */
216 spin_lock_irqsave(&prm
->lock
, flags
);
218 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
219 src
= prm
->dma_area
+ prm
->hw_ptr
;
220 req
->actual
= req
->length
;
223 dst
= prm
->dma_area
+ prm
->hw_ptr
;
227 pending
= prm
->hw_ptr
% prm
->period_size
;
228 pending
+= req
->actual
;
229 if (pending
>= prm
->period_size
)
232 prm
->hw_ptr
= (prm
->hw_ptr
+ req
->actual
) % prm
->dma_bytes
;
234 spin_unlock_irqrestore(&prm
->lock
, flags
);
236 /* Pack USB load in ALSA ring buffer */
237 memcpy(dst
, src
, req
->actual
);
239 if (usb_ep_queue(ep
, req
, GFP_ATOMIC
))
240 dev_err(&uac2
->pdev
.dev
, "%d Error!\n", __LINE__
);
243 snd_pcm_period_elapsed(substream
);
249 uac2_pcm_trigger(struct snd_pcm_substream
*substream
, int cmd
)
251 struct snd_uac2_chip
*uac2
= snd_pcm_substream_chip(substream
);
252 struct uac2_rtd_params
*prm
;
256 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
261 spin_lock_irqsave(&prm
->lock
, flags
);
267 case SNDRV_PCM_TRIGGER_START
:
268 case SNDRV_PCM_TRIGGER_RESUME
:
271 case SNDRV_PCM_TRIGGER_STOP
:
272 case SNDRV_PCM_TRIGGER_SUSPEND
:
279 spin_unlock_irqrestore(&prm
->lock
, flags
);
281 /* Clear buffer after Play stops */
282 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
&& !prm
->ss
)
283 memset(prm
->rbuf
, 0, prm
->max_psize
* USB_XFERS
);
288 static snd_pcm_uframes_t
uac2_pcm_pointer(struct snd_pcm_substream
*substream
)
290 struct snd_uac2_chip
*uac2
= snd_pcm_substream_chip(substream
);
291 struct uac2_rtd_params
*prm
;
293 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
298 return bytes_to_frames(substream
->runtime
, prm
->hw_ptr
);
301 static int uac2_pcm_hw_params(struct snd_pcm_substream
*substream
,
302 struct snd_pcm_hw_params
*hw_params
)
304 struct snd_uac2_chip
*uac2
= snd_pcm_substream_chip(substream
);
305 struct uac2_rtd_params
*prm
;
308 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
313 err
= snd_pcm_lib_malloc_pages(substream
,
314 params_buffer_bytes(hw_params
));
316 prm
->dma_bytes
= substream
->runtime
->dma_bytes
;
317 prm
->dma_area
= substream
->runtime
->dma_area
;
318 prm
->period_size
= params_period_bytes(hw_params
);
324 static int uac2_pcm_hw_free(struct snd_pcm_substream
*substream
)
326 struct snd_uac2_chip
*uac2
= snd_pcm_substream_chip(substream
);
327 struct uac2_rtd_params
*prm
;
329 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
334 prm
->dma_area
= NULL
;
336 prm
->period_size
= 0;
338 return snd_pcm_lib_free_pages(substream
);
341 static int uac2_pcm_open(struct snd_pcm_substream
*substream
)
343 struct snd_uac2_chip
*uac2
= snd_pcm_substream_chip(substream
);
344 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
346 runtime
->hw
= uac2_pcm_hardware
;
348 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
349 spin_lock_init(&uac2
->p_prm
.lock
);
350 runtime
->hw
.rate_min
= p_srate
;
351 runtime
->hw
.formats
= SNDRV_PCM_FMTBIT_S16_LE
; /* ! p_ssize ! */
352 runtime
->hw
.channels_min
= num_channels(p_chmask
);
353 runtime
->hw
.period_bytes_min
= 2 * uac2
->p_prm
.max_psize
354 / runtime
->hw
.periods_min
;
356 spin_lock_init(&uac2
->c_prm
.lock
);
357 runtime
->hw
.rate_min
= c_srate
;
358 runtime
->hw
.formats
= SNDRV_PCM_FMTBIT_S16_LE
; /* ! c_ssize ! */
359 runtime
->hw
.channels_min
= num_channels(c_chmask
);
360 runtime
->hw
.period_bytes_min
= 2 * uac2
->c_prm
.max_psize
361 / runtime
->hw
.periods_min
;
364 runtime
->hw
.rate_max
= runtime
->hw
.rate_min
;
365 runtime
->hw
.channels_max
= runtime
->hw
.channels_min
;
367 snd_pcm_hw_constraint_integer(runtime
, SNDRV_PCM_HW_PARAM_PERIODS
);
372 /* ALSA cries without these function pointers */
373 static int uac2_pcm_null(struct snd_pcm_substream
*substream
)
378 static struct snd_pcm_ops uac2_pcm_ops
= {
379 .open
= uac2_pcm_open
,
380 .close
= uac2_pcm_null
,
381 .ioctl
= snd_pcm_lib_ioctl
,
382 .hw_params
= uac2_pcm_hw_params
,
383 .hw_free
= uac2_pcm_hw_free
,
384 .trigger
= uac2_pcm_trigger
,
385 .pointer
= uac2_pcm_pointer
,
386 .prepare
= uac2_pcm_null
,
389 static int snd_uac2_probe(struct platform_device
*pdev
)
391 struct snd_uac2_chip
*uac2
= pdev_to_uac2(pdev
);
392 struct snd_card
*card
;
396 /* Choose any slot, with no id */
397 err
= snd_card_create(-1, NULL
, THIS_MODULE
, 0, &card
);
404 * Create first PCM device
405 * Create a substream only for non-zero channel streams
407 err
= snd_pcm_new(uac2
->card
, "UAC2 PCM", 0,
408 p_chmask
? 1 : 0, c_chmask
? 1 : 0, &pcm
);
412 strcpy(pcm
->name
, "UAC2 PCM");
413 pcm
->private_data
= uac2
;
417 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &uac2_pcm_ops
);
418 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &uac2_pcm_ops
);
420 strcpy(card
->driver
, "UAC2_Gadget");
421 strcpy(card
->shortname
, "UAC2_Gadget");
422 sprintf(card
->longname
, "UAC2_Gadget %i", pdev
->id
);
424 snd_card_set_dev(card
, &pdev
->dev
);
426 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_CONTINUOUS
,
427 snd_dma_continuous_data(GFP_KERNEL
), 0, BUFF_SIZE_MAX
);
429 err
= snd_card_register(card
);
431 platform_set_drvdata(pdev
, card
);
444 static int snd_uac2_remove(struct platform_device
*pdev
)
446 struct snd_card
*card
= platform_get_drvdata(pdev
);
449 return snd_card_free(card
);
454 static int alsa_uac2_init(struct audio_dev
*agdev
)
456 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
459 uac2
->pdrv
.probe
= snd_uac2_probe
;
460 uac2
->pdrv
.remove
= snd_uac2_remove
;
461 uac2
->pdrv
.driver
.name
= uac2_name
;
464 uac2
->pdev
.name
= uac2_name
;
466 /* Register snd_uac2 driver */
467 err
= platform_driver_register(&uac2
->pdrv
);
471 /* Register snd_uac2 device */
472 err
= platform_device_register(&uac2
->pdev
);
474 platform_driver_unregister(&uac2
->pdrv
);
479 static void alsa_uac2_exit(struct audio_dev
*agdev
)
481 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
483 platform_driver_unregister(&uac2
->pdrv
);
484 platform_device_unregister(&uac2
->pdev
);
488 /* --------- USB Function Interface ------------- */
505 static char clksrc_in
[8];
506 static char clksrc_out
[8];
508 static struct usb_string strings_fn
[] = {
509 [STR_ASSOC
].s
= "Source/Sink",
510 [STR_IF_CTRL
].s
= "Topology Control",
511 [STR_CLKSRC_IN
].s
= clksrc_in
,
512 [STR_CLKSRC_OUT
].s
= clksrc_out
,
513 [STR_USB_IT
].s
= "USBH Out",
514 [STR_IO_IT
].s
= "USBD Out",
515 [STR_USB_OT
].s
= "USBH In",
516 [STR_IO_OT
].s
= "USBD In",
517 [STR_AS_OUT_ALT0
].s
= "Playback Inactive",
518 [STR_AS_OUT_ALT1
].s
= "Playback Active",
519 [STR_AS_IN_ALT0
].s
= "Capture Inactive",
520 [STR_AS_IN_ALT1
].s
= "Capture Active",
524 static struct usb_gadget_strings str_fn
= {
525 .language
= 0x0409, /* en-us */
526 .strings
= strings_fn
,
529 static struct usb_gadget_strings
*fn_strings
[] = {
534 static struct usb_qualifier_descriptor devqual_desc
= {
535 .bLength
= sizeof devqual_desc
,
536 .bDescriptorType
= USB_DT_DEVICE_QUALIFIER
,
538 .bcdUSB
= cpu_to_le16(0x200),
539 .bDeviceClass
= USB_CLASS_MISC
,
540 .bDeviceSubClass
= 0x02,
541 .bDeviceProtocol
= 0x01,
542 .bNumConfigurations
= 1,
546 static struct usb_interface_assoc_descriptor iad_desc
= {
547 .bLength
= sizeof iad_desc
,
548 .bDescriptorType
= USB_DT_INTERFACE_ASSOCIATION
,
550 .bFirstInterface
= 0,
551 .bInterfaceCount
= 3,
552 .bFunctionClass
= USB_CLASS_AUDIO
,
553 .bFunctionSubClass
= UAC2_FUNCTION_SUBCLASS_UNDEFINED
,
554 .bFunctionProtocol
= UAC_VERSION_2
,
557 /* Audio Control Interface */
558 static struct usb_interface_descriptor std_ac_if_desc
= {
559 .bLength
= sizeof std_ac_if_desc
,
560 .bDescriptorType
= USB_DT_INTERFACE
,
562 .bAlternateSetting
= 0,
564 .bInterfaceClass
= USB_CLASS_AUDIO
,
565 .bInterfaceSubClass
= USB_SUBCLASS_AUDIOCONTROL
,
566 .bInterfaceProtocol
= UAC_VERSION_2
,
569 /* Clock source for IN traffic */
570 struct uac_clock_source_descriptor in_clk_src_desc
= {
571 .bLength
= sizeof in_clk_src_desc
,
572 .bDescriptorType
= USB_DT_CS_INTERFACE
,
574 .bDescriptorSubtype
= UAC2_CLOCK_SOURCE
,
575 .bClockID
= USB_IN_CLK_ID
,
576 .bmAttributes
= UAC_CLOCK_SOURCE_TYPE_INT_FIXED
,
577 .bmControls
= (CONTROL_RDONLY
<< CLK_FREQ_CTRL
),
581 /* Clock source for OUT traffic */
582 struct uac_clock_source_descriptor out_clk_src_desc
= {
583 .bLength
= sizeof out_clk_src_desc
,
584 .bDescriptorType
= USB_DT_CS_INTERFACE
,
586 .bDescriptorSubtype
= UAC2_CLOCK_SOURCE
,
587 .bClockID
= USB_OUT_CLK_ID
,
588 .bmAttributes
= UAC_CLOCK_SOURCE_TYPE_INT_FIXED
,
589 .bmControls
= (CONTROL_RDONLY
<< CLK_FREQ_CTRL
),
593 /* Input Terminal for USB_OUT */
594 struct uac2_input_terminal_descriptor usb_out_it_desc
= {
595 .bLength
= sizeof usb_out_it_desc
,
596 .bDescriptorType
= USB_DT_CS_INTERFACE
,
598 .bDescriptorSubtype
= UAC_INPUT_TERMINAL
,
599 .bTerminalID
= USB_OUT_IT_ID
,
600 .wTerminalType
= cpu_to_le16(UAC_TERMINAL_STREAMING
),
602 .bCSourceID
= USB_OUT_CLK_ID
,
604 .bmControls
= (CONTROL_RDWR
<< COPY_CTRL
),
607 /* Input Terminal for I/O-In */
608 struct uac2_input_terminal_descriptor io_in_it_desc
= {
609 .bLength
= sizeof io_in_it_desc
,
610 .bDescriptorType
= USB_DT_CS_INTERFACE
,
612 .bDescriptorSubtype
= UAC_INPUT_TERMINAL
,
613 .bTerminalID
= IO_IN_IT_ID
,
614 .wTerminalType
= cpu_to_le16(UAC_INPUT_TERMINAL_UNDEFINED
),
616 .bCSourceID
= USB_IN_CLK_ID
,
618 .bmControls
= (CONTROL_RDWR
<< COPY_CTRL
),
621 /* Ouput Terminal for USB_IN */
622 struct uac2_output_terminal_descriptor usb_in_ot_desc
= {
623 .bLength
= sizeof usb_in_ot_desc
,
624 .bDescriptorType
= USB_DT_CS_INTERFACE
,
626 .bDescriptorSubtype
= UAC_OUTPUT_TERMINAL
,
627 .bTerminalID
= USB_IN_OT_ID
,
628 .wTerminalType
= cpu_to_le16(UAC_TERMINAL_STREAMING
),
630 .bSourceID
= IO_IN_IT_ID
,
631 .bCSourceID
= USB_IN_CLK_ID
,
632 .bmControls
= (CONTROL_RDWR
<< COPY_CTRL
),
635 /* Ouput Terminal for I/O-Out */
636 struct uac2_output_terminal_descriptor io_out_ot_desc
= {
637 .bLength
= sizeof io_out_ot_desc
,
638 .bDescriptorType
= USB_DT_CS_INTERFACE
,
640 .bDescriptorSubtype
= UAC_OUTPUT_TERMINAL
,
641 .bTerminalID
= IO_OUT_OT_ID
,
642 .wTerminalType
= cpu_to_le16(UAC_OUTPUT_TERMINAL_UNDEFINED
),
644 .bSourceID
= USB_OUT_IT_ID
,
645 .bCSourceID
= USB_OUT_CLK_ID
,
646 .bmControls
= (CONTROL_RDWR
<< COPY_CTRL
),
649 struct uac2_ac_header_descriptor ac_hdr_desc
= {
650 .bLength
= sizeof ac_hdr_desc
,
651 .bDescriptorType
= USB_DT_CS_INTERFACE
,
653 .bDescriptorSubtype
= UAC_MS_HEADER
,
654 .bcdADC
= cpu_to_le16(0x200),
655 .bCategory
= UAC2_FUNCTION_IO_BOX
,
656 .wTotalLength
= sizeof in_clk_src_desc
+ sizeof out_clk_src_desc
657 + sizeof usb_out_it_desc
+ sizeof io_in_it_desc
658 + sizeof usb_in_ot_desc
+ sizeof io_out_ot_desc
,
662 /* Audio Streaming OUT Interface - Alt0 */
663 static struct usb_interface_descriptor std_as_out_if0_desc
= {
664 .bLength
= sizeof std_as_out_if0_desc
,
665 .bDescriptorType
= USB_DT_INTERFACE
,
667 .bAlternateSetting
= 0,
669 .bInterfaceClass
= USB_CLASS_AUDIO
,
670 .bInterfaceSubClass
= USB_SUBCLASS_AUDIOSTREAMING
,
671 .bInterfaceProtocol
= UAC_VERSION_2
,
674 /* Audio Streaming OUT Interface - Alt1 */
675 static struct usb_interface_descriptor std_as_out_if1_desc
= {
676 .bLength
= sizeof std_as_out_if1_desc
,
677 .bDescriptorType
= USB_DT_INTERFACE
,
679 .bAlternateSetting
= 1,
681 .bInterfaceClass
= USB_CLASS_AUDIO
,
682 .bInterfaceSubClass
= USB_SUBCLASS_AUDIOSTREAMING
,
683 .bInterfaceProtocol
= UAC_VERSION_2
,
686 /* Audio Stream OUT Intface Desc */
687 struct uac2_as_header_descriptor as_out_hdr_desc
= {
688 .bLength
= sizeof as_out_hdr_desc
,
689 .bDescriptorType
= USB_DT_CS_INTERFACE
,
691 .bDescriptorSubtype
= UAC_AS_GENERAL
,
692 .bTerminalLink
= USB_OUT_IT_ID
,
694 .bFormatType
= UAC_FORMAT_TYPE_I
,
695 .bmFormats
= cpu_to_le32(UAC_FORMAT_TYPE_I_PCM
),
699 /* Audio USB_OUT Format */
700 struct uac2_format_type_i_descriptor as_out_fmt1_desc
= {
701 .bLength
= sizeof as_out_fmt1_desc
,
702 .bDescriptorType
= USB_DT_CS_INTERFACE
,
703 .bDescriptorSubtype
= UAC_FORMAT_TYPE
,
704 .bFormatType
= UAC_FORMAT_TYPE_I
,
707 /* STD AS ISO OUT Endpoint */
708 struct usb_endpoint_descriptor fs_epout_desc
= {
709 .bLength
= USB_DT_ENDPOINT_SIZE
,
710 .bDescriptorType
= USB_DT_ENDPOINT
,
712 .bEndpointAddress
= USB_DIR_OUT
,
713 .bmAttributes
= USB_ENDPOINT_XFER_ISOC
| USB_ENDPOINT_SYNC_ASYNC
,
717 struct usb_endpoint_descriptor hs_epout_desc
= {
718 .bLength
= USB_DT_ENDPOINT_SIZE
,
719 .bDescriptorType
= USB_DT_ENDPOINT
,
721 .bmAttributes
= USB_ENDPOINT_XFER_ISOC
| USB_ENDPOINT_SYNC_ASYNC
,
725 /* CS AS ISO OUT Endpoint */
726 static struct uac2_iso_endpoint_descriptor as_iso_out_desc
= {
727 .bLength
= sizeof as_iso_out_desc
,
728 .bDescriptorType
= USB_DT_CS_ENDPOINT
,
730 .bDescriptorSubtype
= UAC_EP_GENERAL
,
733 .bLockDelayUnits
= 0,
737 /* Audio Streaming IN Interface - Alt0 */
738 static struct usb_interface_descriptor std_as_in_if0_desc
= {
739 .bLength
= sizeof std_as_in_if0_desc
,
740 .bDescriptorType
= USB_DT_INTERFACE
,
742 .bAlternateSetting
= 0,
744 .bInterfaceClass
= USB_CLASS_AUDIO
,
745 .bInterfaceSubClass
= USB_SUBCLASS_AUDIOSTREAMING
,
746 .bInterfaceProtocol
= UAC_VERSION_2
,
749 /* Audio Streaming IN Interface - Alt1 */
750 static struct usb_interface_descriptor std_as_in_if1_desc
= {
751 .bLength
= sizeof std_as_in_if1_desc
,
752 .bDescriptorType
= USB_DT_INTERFACE
,
754 .bAlternateSetting
= 1,
756 .bInterfaceClass
= USB_CLASS_AUDIO
,
757 .bInterfaceSubClass
= USB_SUBCLASS_AUDIOSTREAMING
,
758 .bInterfaceProtocol
= UAC_VERSION_2
,
761 /* Audio Stream IN Intface Desc */
762 struct uac2_as_header_descriptor as_in_hdr_desc
= {
763 .bLength
= sizeof as_in_hdr_desc
,
764 .bDescriptorType
= USB_DT_CS_INTERFACE
,
766 .bDescriptorSubtype
= UAC_AS_GENERAL
,
767 .bTerminalLink
= USB_IN_OT_ID
,
769 .bFormatType
= UAC_FORMAT_TYPE_I
,
770 .bmFormats
= cpu_to_le32(UAC_FORMAT_TYPE_I_PCM
),
774 /* Audio USB_IN Format */
775 struct uac2_format_type_i_descriptor as_in_fmt1_desc
= {
776 .bLength
= sizeof as_in_fmt1_desc
,
777 .bDescriptorType
= USB_DT_CS_INTERFACE
,
778 .bDescriptorSubtype
= UAC_FORMAT_TYPE
,
779 .bFormatType
= UAC_FORMAT_TYPE_I
,
782 /* STD AS ISO IN Endpoint */
783 struct usb_endpoint_descriptor fs_epin_desc
= {
784 .bLength
= USB_DT_ENDPOINT_SIZE
,
785 .bDescriptorType
= USB_DT_ENDPOINT
,
787 .bEndpointAddress
= USB_DIR_IN
,
788 .bmAttributes
= USB_ENDPOINT_XFER_ISOC
| USB_ENDPOINT_SYNC_ASYNC
,
792 struct usb_endpoint_descriptor hs_epin_desc
= {
793 .bLength
= USB_DT_ENDPOINT_SIZE
,
794 .bDescriptorType
= USB_DT_ENDPOINT
,
796 .bmAttributes
= USB_ENDPOINT_XFER_ISOC
| USB_ENDPOINT_SYNC_ASYNC
,
800 /* CS AS ISO IN Endpoint */
801 static struct uac2_iso_endpoint_descriptor as_iso_in_desc
= {
802 .bLength
= sizeof as_iso_in_desc
,
803 .bDescriptorType
= USB_DT_CS_ENDPOINT
,
805 .bDescriptorSubtype
= UAC_EP_GENERAL
,
808 .bLockDelayUnits
= 0,
812 static struct usb_descriptor_header
*fs_audio_desc
[] = {
813 (struct usb_descriptor_header
*)&iad_desc
,
814 (struct usb_descriptor_header
*)&std_ac_if_desc
,
816 (struct usb_descriptor_header
*)&ac_hdr_desc
,
817 (struct usb_descriptor_header
*)&in_clk_src_desc
,
818 (struct usb_descriptor_header
*)&out_clk_src_desc
,
819 (struct usb_descriptor_header
*)&usb_out_it_desc
,
820 (struct usb_descriptor_header
*)&io_in_it_desc
,
821 (struct usb_descriptor_header
*)&usb_in_ot_desc
,
822 (struct usb_descriptor_header
*)&io_out_ot_desc
,
824 (struct usb_descriptor_header
*)&std_as_out_if0_desc
,
825 (struct usb_descriptor_header
*)&std_as_out_if1_desc
,
827 (struct usb_descriptor_header
*)&as_out_hdr_desc
,
828 (struct usb_descriptor_header
*)&as_out_fmt1_desc
,
829 (struct usb_descriptor_header
*)&fs_epout_desc
,
830 (struct usb_descriptor_header
*)&as_iso_out_desc
,
832 (struct usb_descriptor_header
*)&std_as_in_if0_desc
,
833 (struct usb_descriptor_header
*)&std_as_in_if1_desc
,
835 (struct usb_descriptor_header
*)&as_in_hdr_desc
,
836 (struct usb_descriptor_header
*)&as_in_fmt1_desc
,
837 (struct usb_descriptor_header
*)&fs_epin_desc
,
838 (struct usb_descriptor_header
*)&as_iso_in_desc
,
842 static struct usb_descriptor_header
*hs_audio_desc
[] = {
843 (struct usb_descriptor_header
*)&iad_desc
,
844 (struct usb_descriptor_header
*)&std_ac_if_desc
,
846 (struct usb_descriptor_header
*)&ac_hdr_desc
,
847 (struct usb_descriptor_header
*)&in_clk_src_desc
,
848 (struct usb_descriptor_header
*)&out_clk_src_desc
,
849 (struct usb_descriptor_header
*)&usb_out_it_desc
,
850 (struct usb_descriptor_header
*)&io_in_it_desc
,
851 (struct usb_descriptor_header
*)&usb_in_ot_desc
,
852 (struct usb_descriptor_header
*)&io_out_ot_desc
,
854 (struct usb_descriptor_header
*)&std_as_out_if0_desc
,
855 (struct usb_descriptor_header
*)&std_as_out_if1_desc
,
857 (struct usb_descriptor_header
*)&as_out_hdr_desc
,
858 (struct usb_descriptor_header
*)&as_out_fmt1_desc
,
859 (struct usb_descriptor_header
*)&hs_epout_desc
,
860 (struct usb_descriptor_header
*)&as_iso_out_desc
,
862 (struct usb_descriptor_header
*)&std_as_in_if0_desc
,
863 (struct usb_descriptor_header
*)&std_as_in_if1_desc
,
865 (struct usb_descriptor_header
*)&as_in_hdr_desc
,
866 (struct usb_descriptor_header
*)&as_in_fmt1_desc
,
867 (struct usb_descriptor_header
*)&hs_epin_desc
,
868 (struct usb_descriptor_header
*)&as_iso_in_desc
,
872 struct cntrl_cur_lay3
{
876 struct cntrl_range_lay3
{
884 free_ep(struct uac2_rtd_params
*prm
, struct usb_ep
*ep
)
886 struct snd_uac2_chip
*uac2
= prm
->uac2
;
889 prm
->ep_enabled
= false;
891 for (i
= 0; i
< USB_XFERS
; i
++) {
892 if (prm
->ureq
[i
].req
) {
893 usb_ep_dequeue(ep
, prm
->ureq
[i
].req
);
894 usb_ep_free_request(ep
, prm
->ureq
[i
].req
);
895 prm
->ureq
[i
].req
= NULL
;
899 if (usb_ep_disable(ep
))
900 dev_err(&uac2
->pdev
.dev
,
901 "%s:%d Error!\n", __func__
, __LINE__
);
905 afunc_bind(struct usb_configuration
*cfg
, struct usb_function
*fn
)
907 struct audio_dev
*agdev
= func_to_agdev(fn
);
908 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
909 struct usb_composite_dev
*cdev
= cfg
->cdev
;
910 struct usb_gadget
*gadget
= cdev
->gadget
;
911 struct uac2_rtd_params
*prm
;
914 ret
= usb_interface_id(cfg
, fn
);
916 dev_err(&uac2
->pdev
.dev
,
917 "%s:%d Error!\n", __func__
, __LINE__
);
920 std_ac_if_desc
.bInterfaceNumber
= ret
;
921 agdev
->ac_intf
= ret
;
924 ret
= usb_interface_id(cfg
, fn
);
926 dev_err(&uac2
->pdev
.dev
,
927 "%s:%d Error!\n", __func__
, __LINE__
);
930 std_as_out_if0_desc
.bInterfaceNumber
= ret
;
931 std_as_out_if1_desc
.bInterfaceNumber
= ret
;
932 agdev
->as_out_intf
= ret
;
933 agdev
->as_out_alt
= 0;
935 ret
= usb_interface_id(cfg
, fn
);
937 dev_err(&uac2
->pdev
.dev
,
938 "%s:%d Error!\n", __func__
, __LINE__
);
941 std_as_in_if0_desc
.bInterfaceNumber
= ret
;
942 std_as_in_if1_desc
.bInterfaceNumber
= ret
;
943 agdev
->as_in_intf
= ret
;
944 agdev
->as_in_alt
= 0;
946 agdev
->out_ep
= usb_ep_autoconfig(gadget
, &fs_epout_desc
);
947 if (!agdev
->out_ep
) {
948 dev_err(&uac2
->pdev
.dev
,
949 "%s:%d Error!\n", __func__
, __LINE__
);
952 agdev
->out_ep
->driver_data
= agdev
;
954 agdev
->in_ep
= usb_ep_autoconfig(gadget
, &fs_epin_desc
);
956 dev_err(&uac2
->pdev
.dev
,
957 "%s:%d Error!\n", __func__
, __LINE__
);
960 agdev
->in_ep
->driver_data
= agdev
;
962 uac2
->p_prm
.uac2
= uac2
;
963 uac2
->c_prm
.uac2
= uac2
;
965 hs_epout_desc
.bEndpointAddress
= fs_epout_desc
.bEndpointAddress
;
966 hs_epout_desc
.wMaxPacketSize
= fs_epout_desc
.wMaxPacketSize
;
967 hs_epin_desc
.bEndpointAddress
= fs_epin_desc
.bEndpointAddress
;
968 hs_epin_desc
.wMaxPacketSize
= fs_epin_desc
.wMaxPacketSize
;
970 ret
= usb_assign_descriptors(fn
, fs_audio_desc
, hs_audio_desc
, NULL
);
974 prm
= &agdev
->uac2
.c_prm
;
975 prm
->max_psize
= hs_epout_desc
.wMaxPacketSize
;
976 prm
->rbuf
= kzalloc(prm
->max_psize
* USB_XFERS
, GFP_KERNEL
);
979 dev_err(&uac2
->pdev
.dev
,
980 "%s:%d Error!\n", __func__
, __LINE__
);
984 prm
= &agdev
->uac2
.p_prm
;
985 prm
->max_psize
= hs_epin_desc
.wMaxPacketSize
;
986 prm
->rbuf
= kzalloc(prm
->max_psize
* USB_XFERS
, GFP_KERNEL
);
989 dev_err(&uac2
->pdev
.dev
,
990 "%s:%d Error!\n", __func__
, __LINE__
);
994 ret
= alsa_uac2_init(agdev
);
999 kfree(agdev
->uac2
.p_prm
.rbuf
);
1000 kfree(agdev
->uac2
.c_prm
.rbuf
);
1001 usb_free_all_descriptors(fn
);
1003 agdev
->in_ep
->driver_data
= NULL
;
1005 agdev
->out_ep
->driver_data
= NULL
;
1010 afunc_unbind(struct usb_configuration
*cfg
, struct usb_function
*fn
)
1012 struct audio_dev
*agdev
= func_to_agdev(fn
);
1013 struct uac2_rtd_params
*prm
;
1015 alsa_uac2_exit(agdev
);
1017 prm
= &agdev
->uac2
.p_prm
;
1020 prm
= &agdev
->uac2
.c_prm
;
1022 usb_free_all_descriptors(fn
);
1025 agdev
->in_ep
->driver_data
= NULL
;
1027 agdev
->out_ep
->driver_data
= NULL
;
1031 afunc_set_alt(struct usb_function
*fn
, unsigned intf
, unsigned alt
)
1033 struct usb_composite_dev
*cdev
= fn
->config
->cdev
;
1034 struct audio_dev
*agdev
= func_to_agdev(fn
);
1035 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
1036 struct usb_gadget
*gadget
= cdev
->gadget
;
1037 struct usb_request
*req
;
1039 struct uac2_rtd_params
*prm
;
1042 /* No i/f has more than 2 alt settings */
1044 dev_err(&uac2
->pdev
.dev
,
1045 "%s:%d Error!\n", __func__
, __LINE__
);
1049 if (intf
== agdev
->ac_intf
) {
1050 /* Control I/f has only 1 AltSetting - 0 */
1052 dev_err(&uac2
->pdev
.dev
,
1053 "%s:%d Error!\n", __func__
, __LINE__
);
1059 if (intf
== agdev
->as_out_intf
) {
1062 config_ep_by_speed(gadget
, fn
, ep
);
1063 agdev
->as_out_alt
= alt
;
1064 } else if (intf
== agdev
->as_in_intf
) {
1067 config_ep_by_speed(gadget
, fn
, ep
);
1068 agdev
->as_in_alt
= alt
;
1070 dev_err(&uac2
->pdev
.dev
,
1071 "%s:%d Error!\n", __func__
, __LINE__
);
1080 prm
->ep_enabled
= true;
1083 for (i
= 0; i
< USB_XFERS
; i
++) {
1084 if (prm
->ureq
[i
].req
) {
1085 if (usb_ep_queue(ep
, prm
->ureq
[i
].req
, GFP_ATOMIC
))
1086 dev_err(&uac2
->pdev
.dev
, "%d Error!\n",
1091 req
= usb_ep_alloc_request(ep
, GFP_ATOMIC
);
1093 dev_err(&uac2
->pdev
.dev
,
1094 "%s:%d Error!\n", __func__
, __LINE__
);
1098 prm
->ureq
[i
].req
= req
;
1099 prm
->ureq
[i
].pp
= prm
;
1102 req
->context
= &prm
->ureq
[i
];
1103 req
->length
= prm
->max_psize
;
1104 req
->complete
= agdev_iso_complete
;
1105 req
->buf
= prm
->rbuf
+ i
* req
->length
;
1107 if (usb_ep_queue(ep
, req
, GFP_ATOMIC
))
1108 dev_err(&uac2
->pdev
.dev
, "%d Error!\n", __LINE__
);
1115 afunc_get_alt(struct usb_function
*fn
, unsigned intf
)
1117 struct audio_dev
*agdev
= func_to_agdev(fn
);
1118 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
1120 if (intf
== agdev
->ac_intf
)
1121 return agdev
->ac_alt
;
1122 else if (intf
== agdev
->as_out_intf
)
1123 return agdev
->as_out_alt
;
1124 else if (intf
== agdev
->as_in_intf
)
1125 return agdev
->as_in_alt
;
1127 dev_err(&uac2
->pdev
.dev
,
1128 "%s:%d Invalid Interface %d!\n",
1129 __func__
, __LINE__
, intf
);
1135 afunc_disable(struct usb_function
*fn
)
1137 struct audio_dev
*agdev
= func_to_agdev(fn
);
1138 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
1140 free_ep(&uac2
->p_prm
, agdev
->in_ep
);
1141 agdev
->as_in_alt
= 0;
1143 free_ep(&uac2
->c_prm
, agdev
->out_ep
);
1144 agdev
->as_out_alt
= 0;
1148 in_rq_cur(struct usb_function
*fn
, const struct usb_ctrlrequest
*cr
)
1150 struct usb_request
*req
= fn
->config
->cdev
->req
;
1151 struct audio_dev
*agdev
= func_to_agdev(fn
);
1152 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
1153 u16 w_length
= le16_to_cpu(cr
->wLength
);
1154 u16 w_index
= le16_to_cpu(cr
->wIndex
);
1155 u16 w_value
= le16_to_cpu(cr
->wValue
);
1156 u8 entity_id
= (w_index
>> 8) & 0xff;
1157 u8 control_selector
= w_value
>> 8;
1158 int value
= -EOPNOTSUPP
;
1160 if (control_selector
== UAC2_CS_CONTROL_SAM_FREQ
) {
1161 struct cntrl_cur_lay3 c
;
1163 if (entity_id
== USB_IN_CLK_ID
)
1165 else if (entity_id
== USB_OUT_CLK_ID
)
1168 value
= min_t(unsigned, w_length
, sizeof c
);
1169 memcpy(req
->buf
, &c
, value
);
1170 } else if (control_selector
== UAC2_CS_CONTROL_CLOCK_VALID
) {
1171 *(u8
*)req
->buf
= 1;
1172 value
= min_t(unsigned, w_length
, 1);
1174 dev_err(&uac2
->pdev
.dev
,
1175 "%s:%d control_selector=%d TODO!\n",
1176 __func__
, __LINE__
, control_selector
);
1183 in_rq_range(struct usb_function
*fn
, const struct usb_ctrlrequest
*cr
)
1185 struct usb_request
*req
= fn
->config
->cdev
->req
;
1186 struct audio_dev
*agdev
= func_to_agdev(fn
);
1187 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
1188 u16 w_length
= le16_to_cpu(cr
->wLength
);
1189 u16 w_index
= le16_to_cpu(cr
->wIndex
);
1190 u16 w_value
= le16_to_cpu(cr
->wValue
);
1191 u8 entity_id
= (w_index
>> 8) & 0xff;
1192 u8 control_selector
= w_value
>> 8;
1193 struct cntrl_range_lay3 r
;
1194 int value
= -EOPNOTSUPP
;
1196 if (control_selector
== UAC2_CS_CONTROL_SAM_FREQ
) {
1197 if (entity_id
== USB_IN_CLK_ID
)
1199 else if (entity_id
== USB_OUT_CLK_ID
)
1206 r
.wNumSubRanges
= 1;
1208 value
= min_t(unsigned, w_length
, sizeof r
);
1209 memcpy(req
->buf
, &r
, value
);
1211 dev_err(&uac2
->pdev
.dev
,
1212 "%s:%d control_selector=%d TODO!\n",
1213 __func__
, __LINE__
, control_selector
);
1220 ac_rq_in(struct usb_function
*fn
, const struct usb_ctrlrequest
*cr
)
1222 if (cr
->bRequest
== UAC2_CS_CUR
)
1223 return in_rq_cur(fn
, cr
);
1224 else if (cr
->bRequest
== UAC2_CS_RANGE
)
1225 return in_rq_range(fn
, cr
);
1231 out_rq_cur(struct usb_function
*fn
, const struct usb_ctrlrequest
*cr
)
1233 u16 w_length
= le16_to_cpu(cr
->wLength
);
1234 u16 w_value
= le16_to_cpu(cr
->wValue
);
1235 u8 control_selector
= w_value
>> 8;
1237 if (control_selector
== UAC2_CS_CONTROL_SAM_FREQ
)
1244 setup_rq_inf(struct usb_function
*fn
, const struct usb_ctrlrequest
*cr
)
1246 struct audio_dev
*agdev
= func_to_agdev(fn
);
1247 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
1248 u16 w_index
= le16_to_cpu(cr
->wIndex
);
1249 u8 intf
= w_index
& 0xff;
1251 if (intf
!= agdev
->ac_intf
) {
1252 dev_err(&uac2
->pdev
.dev
,
1253 "%s:%d Error!\n", __func__
, __LINE__
);
1257 if (cr
->bRequestType
& USB_DIR_IN
)
1258 return ac_rq_in(fn
, cr
);
1259 else if (cr
->bRequest
== UAC2_CS_CUR
)
1260 return out_rq_cur(fn
, cr
);
1266 afunc_setup(struct usb_function
*fn
, const struct usb_ctrlrequest
*cr
)
1268 struct usb_composite_dev
*cdev
= fn
->config
->cdev
;
1269 struct audio_dev
*agdev
= func_to_agdev(fn
);
1270 struct snd_uac2_chip
*uac2
= &agdev
->uac2
;
1271 struct usb_request
*req
= cdev
->req
;
1272 u16 w_length
= le16_to_cpu(cr
->wLength
);
1273 int value
= -EOPNOTSUPP
;
1275 /* Only Class specific requests are supposed to reach here */
1276 if ((cr
->bRequestType
& USB_TYPE_MASK
) != USB_TYPE_CLASS
)
1279 if ((cr
->bRequestType
& USB_RECIP_MASK
) == USB_RECIP_INTERFACE
)
1280 value
= setup_rq_inf(fn
, cr
);
1282 dev_err(&uac2
->pdev
.dev
, "%s:%d Error!\n", __func__
, __LINE__
);
1285 req
->length
= value
;
1286 req
->zero
= value
< w_length
;
1287 value
= usb_ep_queue(cdev
->gadget
->ep0
, req
, GFP_ATOMIC
);
1289 dev_err(&uac2
->pdev
.dev
,
1290 "%s:%d Error!\n", __func__
, __LINE__
);
1298 static int audio_bind_config(struct usb_configuration
*cfg
)
1302 agdev_g
= kzalloc(sizeof *agdev_g
, GFP_KERNEL
);
1303 if (agdev_g
== NULL
) {
1304 printk(KERN_ERR
"Unable to allocate audio gadget\n");
1308 res
= usb_string_ids_tab(cfg
->cdev
, strings_fn
);
1311 iad_desc
.iFunction
= strings_fn
[STR_ASSOC
].id
;
1312 std_ac_if_desc
.iInterface
= strings_fn
[STR_IF_CTRL
].id
;
1313 in_clk_src_desc
.iClockSource
= strings_fn
[STR_CLKSRC_IN
].id
;
1314 out_clk_src_desc
.iClockSource
= strings_fn
[STR_CLKSRC_OUT
].id
;
1315 usb_out_it_desc
.iTerminal
= strings_fn
[STR_USB_IT
].id
;
1316 io_in_it_desc
.iTerminal
= strings_fn
[STR_IO_IT
].id
;
1317 usb_in_ot_desc
.iTerminal
= strings_fn
[STR_USB_OT
].id
;
1318 io_out_ot_desc
.iTerminal
= strings_fn
[STR_IO_OT
].id
;
1319 std_as_out_if0_desc
.iInterface
= strings_fn
[STR_AS_OUT_ALT0
].id
;
1320 std_as_out_if1_desc
.iInterface
= strings_fn
[STR_AS_OUT_ALT1
].id
;
1321 std_as_in_if0_desc
.iInterface
= strings_fn
[STR_AS_IN_ALT0
].id
;
1322 std_as_in_if1_desc
.iInterface
= strings_fn
[STR_AS_IN_ALT1
].id
;
1324 agdev_g
->func
.name
= "uac2_func";
1325 agdev_g
->func
.strings
= fn_strings
;
1326 agdev_g
->func
.bind
= afunc_bind
;
1327 agdev_g
->func
.unbind
= afunc_unbind
;
1328 agdev_g
->func
.set_alt
= afunc_set_alt
;
1329 agdev_g
->func
.get_alt
= afunc_get_alt
;
1330 agdev_g
->func
.disable
= afunc_disable
;
1331 agdev_g
->func
.setup
= afunc_setup
;
1333 /* Initialize the configurable parameters */
1334 usb_out_it_desc
.bNrChannels
= num_channels(c_chmask
);
1335 usb_out_it_desc
.bmChannelConfig
= cpu_to_le32(c_chmask
);
1336 io_in_it_desc
.bNrChannels
= num_channels(p_chmask
);
1337 io_in_it_desc
.bmChannelConfig
= cpu_to_le32(p_chmask
);
1338 as_out_hdr_desc
.bNrChannels
= num_channels(c_chmask
);
1339 as_out_hdr_desc
.bmChannelConfig
= cpu_to_le32(c_chmask
);
1340 as_in_hdr_desc
.bNrChannels
= num_channels(p_chmask
);
1341 as_in_hdr_desc
.bmChannelConfig
= cpu_to_le32(p_chmask
);
1342 as_out_fmt1_desc
.bSubslotSize
= c_ssize
;
1343 as_out_fmt1_desc
.bBitResolution
= c_ssize
* 8;
1344 as_in_fmt1_desc
.bSubslotSize
= p_ssize
;
1345 as_in_fmt1_desc
.bBitResolution
= p_ssize
* 8;
1347 snprintf(clksrc_in
, sizeof(clksrc_in
), "%uHz", p_srate
);
1348 snprintf(clksrc_out
, sizeof(clksrc_out
), "%uHz", c_srate
);
1350 res
= usb_add_function(cfg
, &agdev_g
->func
);
1358 uac2_unbind_config(struct usb_configuration
*cfg
)