Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: function: make current f_uac1 implementation legacy

Before introducing new f_uac1 function (with virtual
ALSA card) make current implementation legacy.

This includes renaming of existing files, some
variables, config options and documentation

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Ruslan Bilovol and committed by
Felipe Balbi
d355339e eb9fecb9

+59 -56
+1 -1
Documentation/ABI/testing/configfs-usb-gadget-uac1 Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy
··· 1 - What: /config/usb-gadget/gadget/functions/uac1.name 1 + What: /config/usb-gadget/gadget/functions/uac1_legacy.name 2 2 Date: Sep 2014 3 3 KernelVersion: 3.18 4 4 Description:
+5 -4
Documentation/usb/gadget-testing.txt
··· 16 16 13. RNDIS function 17 17 14. SERIAL function 18 18 15. SOURCESINK function 19 - 16. UAC1 function 19 + 16. UAC1 function (legacy implementation) 20 20 17. UAC2 function 21 21 18. UVC function 22 22 19. PRINTER function ··· 589 589 host: test-usb (tools/usb/testusb.c) 590 590 591 591 592 - 16. UAC1 function 592 + 16. UAC1 function (legacy implementation) 593 593 ================= 594 594 595 - The function is provided by usb_f_uac1.ko module. 595 + The function is provided by usb_f_uac1_legacy.ko module. 596 596 597 597 Function-specific configfs interface 598 598 ------------------------------------ 599 599 600 - The function name to use when creating the function directory is "uac1". 600 + The function name to use when creating the function directory 601 + is "uac1_legacy". 601 602 The uac1 function provides these attributes in its function directory: 602 603 603 604 audio_buf_size - audio buffer size
+4 -4
drivers/usb/gadget/Kconfig
··· 191 191 config USB_F_FS 192 192 tristate 193 193 194 - config USB_F_UAC1 194 + config USB_F_UAC1_LEGACY 195 195 tristate 196 196 197 197 config USB_F_UAC2 ··· 365 365 implemented in kernel space (for instance Ethernet, serial or 366 366 mass storage) and other are implemented in user space. 367 367 368 - config USB_CONFIGFS_F_UAC1 369 - bool "Audio Class 1.0" 368 + config USB_CONFIGFS_F_UAC1_LEGACY 369 + bool "Audio Class 1.0 (legacy implementation)" 370 370 depends on USB_CONFIGFS 371 371 depends on SND 372 372 select USB_LIBCOMPOSITE 373 373 select SND_PCM 374 - select USB_F_UAC1 374 + select USB_F_UAC1_LEGACY 375 375 help 376 376 This Audio function implements 1 AudioControl interface, 377 377 1 AudioStreaming Interface each for USB-OUT and USB-IN.
+2 -2
drivers/usb/gadget/function/Makefile
··· 33 33 usb_f_fs-y := f_fs.o 34 34 obj-$(CONFIG_USB_F_FS) += usb_f_fs.o 35 35 obj-$(CONFIG_USB_U_AUDIO) += u_audio.o 36 - usb_f_uac1-y := f_uac1.o u_uac1.o 37 - obj-$(CONFIG_USB_F_UAC1) += usb_f_uac1.o 36 + usb_f_uac1_legacy-y := f_uac1_legacy.o u_uac1_legacy.o 37 + obj-$(CONFIG_USB_F_UAC1_LEGACY) += usb_f_uac1_legacy.o 38 38 usb_f_uac2-y := f_uac2.o 39 39 obj-$(CONFIG_USB_F_UAC2) += usb_f_uac2.o 40 40 usb_f_uvc-y := f_uvc.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_configfs.o
+23 -22
drivers/usb/gadget/function/f_uac1.c drivers/usb/gadget/function/f_uac1_legacy.c
··· 15 15 #include <linux/device.h> 16 16 #include <linux/atomic.h> 17 17 18 - #include "u_uac1.h" 18 + #include "u_uac1_legacy.h" 19 19 20 20 static int generic_set_cmd(struct usb_audio_control *con, u8 cmd, int value); 21 21 static int generic_get_cmd(struct usb_audio_control *con, u8 cmd); ··· 326 326 struct f_audio *audio = req->context; 327 327 struct usb_composite_dev *cdev = audio->card.func.config->cdev; 328 328 struct f_audio_buf *copy_buf = audio->copy_buf; 329 - struct f_uac1_opts *opts; 329 + struct f_uac1_legacy_opts *opts; 330 330 int audio_buf_size; 331 331 int err; 332 332 333 - opts = container_of(audio->card.func.fi, struct f_uac1_opts, 333 + opts = container_of(audio->card.func.fi, struct f_uac1_legacy_opts, 334 334 func_inst); 335 335 audio_buf_size = opts->audio_buf_size; 336 336 ··· 578 578 struct usb_composite_dev *cdev = f->config->cdev; 579 579 struct usb_ep *out_ep = audio->out_ep; 580 580 struct usb_request *req; 581 - struct f_uac1_opts *opts; 581 + struct f_uac1_legacy_opts *opts; 582 582 int req_buf_size, req_count, audio_buf_size; 583 583 int i = 0, err = 0; 584 584 585 585 DBG(cdev, "intf %d, alt %d\n", intf, alt); 586 586 587 - opts = container_of(f->fi, struct f_uac1_opts, func_inst); 587 + opts = container_of(f->fi, struct f_uac1_legacy_opts, func_inst); 588 588 req_buf_size = opts->req_buf_size; 589 589 req_count = opts->req_count; 590 590 audio_buf_size = opts->audio_buf_size; ··· 705 705 struct usb_string *us; 706 706 int status; 707 707 struct usb_ep *ep = NULL; 708 - struct f_uac1_opts *audio_opts; 708 + struct f_uac1_legacy_opts *audio_opts; 709 709 710 - audio_opts = container_of(f->fi, struct f_uac1_opts, func_inst); 710 + audio_opts = container_of(f->fi, struct f_uac1_legacy_opts, func_inst); 711 711 audio->card.gadget = c->cdev->gadget; 712 712 /* set up ASLA audio devices */ 713 713 if (!audio_opts->bound) { ··· 801 801 return 0; 802 802 } 803 803 804 - static inline struct f_uac1_opts *to_f_uac1_opts(struct config_item *item) 804 + static inline 805 + struct f_uac1_legacy_opts *to_f_uac1_opts(struct config_item *item) 805 806 { 806 - return container_of(to_config_group(item), struct f_uac1_opts, 807 + return container_of(to_config_group(item), struct f_uac1_legacy_opts, 807 808 func_inst.group); 808 809 } 809 810 810 811 static void f_uac1_attr_release(struct config_item *item) 811 812 { 812 - struct f_uac1_opts *opts = to_f_uac1_opts(item); 813 + struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); 813 814 814 815 usb_put_function_instance(&opts->func_inst); 815 816 } ··· 823 822 static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \ 824 823 char *page) \ 825 824 { \ 826 - struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 825 + struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \ 827 826 int result; \ 828 827 \ 829 828 mutex_lock(&opts->lock); \ ··· 836 835 static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \ 837 836 const char *page, size_t len) \ 838 837 { \ 839 - struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 838 + struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \ 840 839 int ret; \ 841 840 u32 num; \ 842 841 \ ··· 868 867 static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \ 869 868 char *page) \ 870 869 { \ 871 - struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 870 + struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \ 872 871 int result; \ 873 872 \ 874 873 mutex_lock(&opts->lock); \ ··· 881 880 static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \ 882 881 const char *page, size_t len) \ 883 882 { \ 884 - struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 883 + struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \ 885 884 int ret = -EBUSY; \ 886 885 char *tmp; \ 887 886 \ ··· 929 928 930 929 static void f_audio_free_inst(struct usb_function_instance *f) 931 930 { 932 - struct f_uac1_opts *opts; 931 + struct f_uac1_legacy_opts *opts; 933 932 934 - opts = container_of(f, struct f_uac1_opts, func_inst); 933 + opts = container_of(f, struct f_uac1_legacy_opts, func_inst); 935 934 if (opts->fn_play_alloc) 936 935 kfree(opts->fn_play); 937 936 if (opts->fn_cap_alloc) ··· 943 942 944 943 static struct usb_function_instance *f_audio_alloc_inst(void) 945 944 { 946 - struct f_uac1_opts *opts; 945 + struct f_uac1_legacy_opts *opts; 947 946 948 947 opts = kzalloc(sizeof(*opts), GFP_KERNEL); 949 948 if (!opts) ··· 967 966 static void f_audio_free(struct usb_function *f) 968 967 { 969 968 struct f_audio *audio = func_to_audio(f); 970 - struct f_uac1_opts *opts; 969 + struct f_uac1_legacy_opts *opts; 971 970 972 971 gaudio_cleanup(&audio->card); 973 - opts = container_of(f->fi, struct f_uac1_opts, func_inst); 972 + opts = container_of(f->fi, struct f_uac1_legacy_opts, func_inst); 974 973 kfree(audio); 975 974 mutex_lock(&opts->lock); 976 975 --opts->refcnt; ··· 985 984 static struct usb_function *f_audio_alloc(struct usb_function_instance *fi) 986 985 { 987 986 struct f_audio *audio; 988 - struct f_uac1_opts *opts; 987 + struct f_uac1_legacy_opts *opts; 989 988 990 989 /* allocate and initialize one new instance */ 991 990 audio = kzalloc(sizeof(*audio), GFP_KERNEL); ··· 994 993 995 994 audio->card.func.name = "g_audio"; 996 995 997 - opts = container_of(fi, struct f_uac1_opts, func_inst); 996 + opts = container_of(fi, struct f_uac1_legacy_opts, func_inst); 998 997 mutex_lock(&opts->lock); 999 998 ++opts->refcnt; 1000 999 mutex_unlock(&opts->lock); ··· 1016 1015 return &audio->card.func; 1017 1016 } 1018 1017 1019 - DECLARE_USB_FUNCTION_INIT(uac1, f_audio_alloc_inst, f_audio_alloc); 1018 + DECLARE_USB_FUNCTION_INIT(uac1_legacy, f_audio_alloc_inst, f_audio_alloc); 1020 1019 MODULE_LICENSE("GPL"); 1021 1020 MODULE_AUTHOR("Bryan Wu");
+4 -3
drivers/usb/gadget/function/u_uac1.c drivers/usb/gadget/function/u_uac1_legacy.c
··· 18 18 #include <linux/random.h> 19 19 #include <linux/syscalls.h> 20 20 21 - #include "u_uac1.h" 21 + #include "u_uac1_legacy.h" 22 22 23 23 /* 24 24 * This component encapsulates the ALSA devices for USB audio gadget ··· 205 205 { 206 206 struct snd_pcm_file *pcm_file; 207 207 struct gaudio_snd_dev *snd; 208 - struct f_uac1_opts *opts; 208 + struct f_uac1_legacy_opts *opts; 209 209 char *fn_play, *fn_cap, *fn_cntl; 210 210 211 - opts = container_of(card->func.fi, struct f_uac1_opts, func_inst); 211 + opts = container_of(card->func.fi, struct f_uac1_legacy_opts, 212 + func_inst); 212 213 fn_play = opts->fn_play; 213 214 fn_cap = opts->fn_cap; 214 215 fn_cntl = opts->fn_cntl;
+4 -4
drivers/usb/gadget/function/u_uac1.h drivers/usb/gadget/function/u_uac1_legacy.h
··· 9 9 * Licensed under the GPL-2 or later. 10 10 */ 11 11 12 - #ifndef __U_AUDIO_H 13 - #define __U_AUDIO_H 12 + #ifndef __U_UAC1_LEGACY_H 13 + #define __U_UAC1_LEGACY_H 14 14 15 15 #include <linux/device.h> 16 16 #include <linux/err.h> ··· 56 56 /* TODO */ 57 57 }; 58 58 59 - struct f_uac1_opts { 59 + struct f_uac1_legacy_opts { 60 60 struct usb_function_instance func_inst; 61 61 int req_buf_size; 62 62 int req_count; ··· 79 79 int u_audio_get_playback_channels(struct gaudio *card); 80 80 int u_audio_get_playback_rate(struct gaudio *card); 81 81 82 - #endif /* __U_AUDIO_H */ 82 + #endif /* __U_UAC1_LEGACY_H */
+3 -3
drivers/usb/gadget/legacy/Kconfig
··· 54 54 depends on SND 55 55 select USB_LIBCOMPOSITE 56 56 select SND_PCM 57 - select USB_F_UAC1 if GADGET_UAC1 58 - select USB_F_UAC2 if !GADGET_UAC1 57 + select USB_F_UAC1_LEGACY if GADGET_UAC1_LEGACY 58 + select USB_F_UAC2 if !GADGET_UAC1_LEGACY 59 59 select USB_U_AUDIO if USB_F_UAC2 60 60 help 61 61 This Gadget Audio driver is compatible with USB Audio Class ··· 73 73 Say "y" to link the driver statically, or "m" to build a 74 74 dynamically linked module called "g_audio". 75 75 76 - config GADGET_UAC1 76 + config GADGET_UAC1_LEGACY 77 77 bool "UAC 1.0 (Legacy)" 78 78 depends on USB_AUDIO 79 79 help
+13 -13
drivers/usb/gadget/legacy/audio.c
··· 20 20 21 21 USB_GADGET_COMPOSITE_OPTIONS(); 22 22 23 - #ifndef CONFIG_GADGET_UAC1 23 + #ifndef CONFIG_GADGET_UAC1_LEGACY 24 24 #include "u_uac2.h" 25 25 26 26 /* Playback(USB-IN) Default Stereo - Fl/Fr */ ··· 53 53 module_param(c_ssize, uint, S_IRUGO); 54 54 MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); 55 55 #else 56 - #include "u_uac1.h" 56 + #include "u_uac1_legacy.h" 57 57 58 58 static char *fn_play = FILE_PCM_PLAYBACK; 59 59 module_param(fn_play, charp, S_IRUGO); ··· 99 99 NULL, 100 100 }; 101 101 102 - #ifndef CONFIG_GADGET_UAC1 102 + #ifndef CONFIG_GADGET_UAC1_LEGACY 103 103 static struct usb_function_instance *fi_uac2; 104 104 static struct usb_function *f_uac2; 105 105 #else ··· 125 125 126 126 /* .bcdUSB = DYNAMIC */ 127 127 128 - #ifdef CONFIG_GADGET_UAC1 128 + #ifdef CONFIG_GADGET_UAC1_LEGACY 129 129 .bDeviceClass = USB_CLASS_PER_INTERFACE, 130 130 .bDeviceSubClass = 0, 131 131 .bDeviceProtocol = 0, ··· 164 164 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 165 165 } 166 166 167 - #ifdef CONFIG_GADGET_UAC1 167 + #ifdef CONFIG_GADGET_UAC1_LEGACY 168 168 f_uac1 = usb_get_function(fi_uac1); 169 169 if (IS_ERR(f_uac1)) { 170 170 status = PTR_ERR(f_uac1); ··· 204 204 205 205 static int audio_bind(struct usb_composite_dev *cdev) 206 206 { 207 - #ifndef CONFIG_GADGET_UAC1 207 + #ifndef CONFIG_GADGET_UAC1_LEGACY 208 208 struct f_uac2_opts *uac2_opts; 209 209 #else 210 - struct f_uac1_opts *uac1_opts; 210 + struct f_uac1_legacy_opts *uac1_opts; 211 211 #endif 212 212 int status; 213 213 214 - #ifndef CONFIG_GADGET_UAC1 214 + #ifndef CONFIG_GADGET_UAC1_LEGACY 215 215 fi_uac2 = usb_get_function_instance("uac2"); 216 216 if (IS_ERR(fi_uac2)) 217 217 return PTR_ERR(fi_uac2); 218 218 #else 219 - fi_uac1 = usb_get_function_instance("uac1"); 219 + fi_uac1 = usb_get_function_instance("uac1_legacy"); 220 220 if (IS_ERR(fi_uac1)) 221 221 return PTR_ERR(fi_uac1); 222 222 #endif 223 223 224 - #ifndef CONFIG_GADGET_UAC1 224 + #ifndef CONFIG_GADGET_UAC1_LEGACY 225 225 uac2_opts = container_of(fi_uac2, struct f_uac2_opts, func_inst); 226 226 uac2_opts->p_chmask = p_chmask; 227 227 uac2_opts->p_srate = p_srate; ··· 231 231 uac2_opts->c_ssize = c_ssize; 232 232 uac2_opts->req_number = UAC2_DEF_REQ_NUM; 233 233 #else 234 - uac1_opts = container_of(fi_uac1, struct f_uac1_opts, func_inst); 234 + uac1_opts = container_of(fi_uac1, struct f_uac1_legacy_opts, func_inst); 235 235 uac1_opts->fn_play = fn_play; 236 236 uac1_opts->fn_cap = fn_cap; 237 237 uac1_opts->fn_cntl = fn_cntl; ··· 269 269 kfree(otg_desc[0]); 270 270 otg_desc[0] = NULL; 271 271 fail: 272 - #ifndef CONFIG_GADGET_UAC1 272 + #ifndef CONFIG_GADGET_UAC1_LEGACY 273 273 usb_put_function_instance(fi_uac2); 274 274 #else 275 275 usb_put_function_instance(fi_uac1); ··· 279 279 280 280 static int audio_unbind(struct usb_composite_dev *cdev) 281 281 { 282 - #ifdef CONFIG_GADGET_UAC1 282 + #ifdef CONFIG_GADGET_UAC1_LEGACY 283 283 if (!IS_ERR_OR_NULL(f_uac1)) 284 284 usb_put_function(f_uac1); 285 285 if (!IS_ERR_OR_NULL(fi_uac1))