Skip to content

Commit d355339

Browse files
rbilovolFelipe Balbi
authored and
Felipe Balbi
committed
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>
1 parent eb9fecb commit d355339

File tree

9 files changed

+59
-56
lines changed

9 files changed

+59
-56
lines changed

Diff for: Documentation/ABI/testing/configfs-usb-gadget-uac1 renamed to Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
What: /config/usb-gadget/gadget/functions/uac1.name
1+
What: /config/usb-gadget/gadget/functions/uac1_legacy.name
22
Date: Sep 2014
33
KernelVersion: 3.18
44
Description:

Diff for: Documentation/usb/gadget-testing.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ provided by gadgets.
1616
13. RNDIS function
1717
14. SERIAL function
1818
15. SOURCESINK function
19-
16. UAC1 function
19+
16. UAC1 function (legacy implementation)
2020
17. UAC2 function
2121
18. UVC function
2222
19. PRINTER function
@@ -589,15 +589,16 @@ device: run the gadget
589589
host: test-usb (tools/usb/testusb.c)
590590

591591

592-
16. UAC1 function
592+
16. UAC1 function (legacy implementation)
593593
=================
594594

595-
The function is provided by usb_f_uac1.ko module.
595+
The function is provided by usb_f_uac1_legacy.ko module.
596596

597597
Function-specific configfs interface
598598
------------------------------------
599599

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".
601602
The uac1 function provides these attributes in its function directory:
602603

603604
audio_buf_size - audio buffer size

Diff for: drivers/usb/gadget/Kconfig

+4-4
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ config USB_F_MASS_STORAGE
191191
config USB_F_FS
192192
tristate
193193

194-
config USB_F_UAC1
194+
config USB_F_UAC1_LEGACY
195195
tristate
196196

197197
config USB_F_UAC2
@@ -365,13 +365,13 @@ config USB_CONFIGFS_F_FS
365365
implemented in kernel space (for instance Ethernet, serial or
366366
mass storage) and other are implemented in user space.
367367

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)"
370370
depends on USB_CONFIGFS
371371
depends on SND
372372
select USB_LIBCOMPOSITE
373373
select SND_PCM
374-
select USB_F_UAC1
374+
select USB_F_UAC1_LEGACY
375375
help
376376
This Audio function implements 1 AudioControl interface,
377377
1 AudioStreaming Interface each for USB-OUT and USB-IN.

Diff for: drivers/usb/gadget/function/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
3333
usb_f_fs-y := f_fs.o
3434
obj-$(CONFIG_USB_F_FS) += usb_f_fs.o
3535
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
3838
usb_f_uac2-y := f_uac2.o
3939
obj-$(CONFIG_USB_F_UAC2) += usb_f_uac2.o
4040
usb_f_uvc-y := f_uvc.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_configfs.o

Diff for: drivers/usb/gadget/function/f_uac1.c renamed to drivers/usb/gadget/function/f_uac1_legacy.c

+23-22
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <linux/device.h>
1616
#include <linux/atomic.h>
1717

18-
#include "u_uac1.h"
18+
#include "u_uac1_legacy.h"
1919

2020
static int generic_set_cmd(struct usb_audio_control *con, u8 cmd, int value);
2121
static int generic_get_cmd(struct usb_audio_control *con, u8 cmd);
@@ -326,11 +326,11 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, struct usb_request *req)
326326
struct f_audio *audio = req->context;
327327
struct usb_composite_dev *cdev = audio->card.func.config->cdev;
328328
struct f_audio_buf *copy_buf = audio->copy_buf;
329-
struct f_uac1_opts *opts;
329+
struct f_uac1_legacy_opts *opts;
330330
int audio_buf_size;
331331
int err;
332332

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,
334334
func_inst);
335335
audio_buf_size = opts->audio_buf_size;
336336

@@ -578,13 +578,13 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
578578
struct usb_composite_dev *cdev = f->config->cdev;
579579
struct usb_ep *out_ep = audio->out_ep;
580580
struct usb_request *req;
581-
struct f_uac1_opts *opts;
581+
struct f_uac1_legacy_opts *opts;
582582
int req_buf_size, req_count, audio_buf_size;
583583
int i = 0, err = 0;
584584

585585
DBG(cdev, "intf %d, alt %d\n", intf, alt);
586586

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);
588588
req_buf_size = opts->req_buf_size;
589589
req_count = opts->req_count;
590590
audio_buf_size = opts->audio_buf_size;
@@ -705,9 +705,9 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f)
705705
struct usb_string *us;
706706
int status;
707707
struct usb_ep *ep = NULL;
708-
struct f_uac1_opts *audio_opts;
708+
struct f_uac1_legacy_opts *audio_opts;
709709

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);
711711
audio->card.gadget = c->cdev->gadget;
712712
/* set up ASLA audio devices */
713713
if (!audio_opts->bound) {
@@ -801,15 +801,16 @@ static int control_selector_init(struct f_audio *audio)
801801
return 0;
802802
}
803803

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)
805806
{
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,
807808
func_inst.group);
808809
}
809810

810811
static void f_uac1_attr_release(struct config_item *item)
811812
{
812-
struct f_uac1_opts *opts = to_f_uac1_opts(item);
813+
struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item);
813814

814815
usb_put_function_instance(&opts->func_inst);
815816
}
@@ -822,7 +823,7 @@ static struct configfs_item_operations f_uac1_item_ops = {
822823
static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
823824
char *page) \
824825
{ \
825-
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
826+
struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \
826827
int result; \
827828
\
828829
mutex_lock(&opts->lock); \
@@ -835,7 +836,7 @@ static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
835836
static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \
836837
const char *page, size_t len) \
837838
{ \
838-
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
839+
struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \
839840
int ret; \
840841
u32 num; \
841842
\
@@ -867,7 +868,7 @@ UAC1_INT_ATTRIBUTE(audio_buf_size);
867868
static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
868869
char *page) \
869870
{ \
870-
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
871+
struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \
871872
int result; \
872873
\
873874
mutex_lock(&opts->lock); \
@@ -880,7 +881,7 @@ static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
880881
static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \
881882
const char *page, size_t len) \
882883
{ \
883-
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
884+
struct f_uac1_legacy_opts *opts = to_f_uac1_opts(item); \
884885
int ret = -EBUSY; \
885886
char *tmp; \
886887
\
@@ -928,9 +929,9 @@ static struct config_item_type f_uac1_func_type = {
928929

929930
static void f_audio_free_inst(struct usb_function_instance *f)
930931
{
931-
struct f_uac1_opts *opts;
932+
struct f_uac1_legacy_opts *opts;
932933

933-
opts = container_of(f, struct f_uac1_opts, func_inst);
934+
opts = container_of(f, struct f_uac1_legacy_opts, func_inst);
934935
if (opts->fn_play_alloc)
935936
kfree(opts->fn_play);
936937
if (opts->fn_cap_alloc)
@@ -942,7 +943,7 @@ static void f_audio_free_inst(struct usb_function_instance *f)
942943

943944
static struct usb_function_instance *f_audio_alloc_inst(void)
944945
{
945-
struct f_uac1_opts *opts;
946+
struct f_uac1_legacy_opts *opts;
946947

947948
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
948949
if (!opts)
@@ -966,10 +967,10 @@ static struct usb_function_instance *f_audio_alloc_inst(void)
966967
static void f_audio_free(struct usb_function *f)
967968
{
968969
struct f_audio *audio = func_to_audio(f);
969-
struct f_uac1_opts *opts;
970+
struct f_uac1_legacy_opts *opts;
970971

971972
gaudio_cleanup(&audio->card);
972-
opts = container_of(f->fi, struct f_uac1_opts, func_inst);
973+
opts = container_of(f->fi, struct f_uac1_legacy_opts, func_inst);
973974
kfree(audio);
974975
mutex_lock(&opts->lock);
975976
--opts->refcnt;
@@ -984,7 +985,7 @@ static void f_audio_unbind(struct usb_configuration *c, struct usb_function *f)
984985
static struct usb_function *f_audio_alloc(struct usb_function_instance *fi)
985986
{
986987
struct f_audio *audio;
987-
struct f_uac1_opts *opts;
988+
struct f_uac1_legacy_opts *opts;
988989

989990
/* allocate and initialize one new instance */
990991
audio = kzalloc(sizeof(*audio), GFP_KERNEL);
@@ -993,7 +994,7 @@ static struct usb_function *f_audio_alloc(struct usb_function_instance *fi)
993994

994995
audio->card.func.name = "g_audio";
995996

996-
opts = container_of(fi, struct f_uac1_opts, func_inst);
997+
opts = container_of(fi, struct f_uac1_legacy_opts, func_inst);
997998
mutex_lock(&opts->lock);
998999
++opts->refcnt;
9991000
mutex_unlock(&opts->lock);
@@ -1015,6 +1016,6 @@ static struct usb_function *f_audio_alloc(struct usb_function_instance *fi)
10151016
return &audio->card.func;
10161017
}
10171018

1018-
DECLARE_USB_FUNCTION_INIT(uac1, f_audio_alloc_inst, f_audio_alloc);
1019+
DECLARE_USB_FUNCTION_INIT(uac1_legacy, f_audio_alloc_inst, f_audio_alloc);
10191020
MODULE_LICENSE("GPL");
10201021
MODULE_AUTHOR("Bryan Wu");

Diff for: drivers/usb/gadget/function/u_uac1.c renamed to drivers/usb/gadget/function/u_uac1_legacy.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <linux/random.h>
1919
#include <linux/syscalls.h>
2020

21-
#include "u_uac1.h"
21+
#include "u_uac1_legacy.h"
2222

2323
/*
2424
* This component encapsulates the ALSA devices for USB audio gadget
@@ -205,10 +205,11 @@ static int gaudio_open_snd_dev(struct gaudio *card)
205205
{
206206
struct snd_pcm_file *pcm_file;
207207
struct gaudio_snd_dev *snd;
208-
struct f_uac1_opts *opts;
208+
struct f_uac1_legacy_opts *opts;
209209
char *fn_play, *fn_cap, *fn_cntl;
210210

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);
212213
fn_play = opts->fn_play;
213214
fn_cap = opts->fn_cap;
214215
fn_cntl = opts->fn_cntl;

Diff for: drivers/usb/gadget/function/u_uac1.h renamed to drivers/usb/gadget/function/u_uac1_legacy.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* Licensed under the GPL-2 or later.
1010
*/
1111

12-
#ifndef __U_AUDIO_H
13-
#define __U_AUDIO_H
12+
#ifndef __U_UAC1_LEGACY_H
13+
#define __U_UAC1_LEGACY_H
1414

1515
#include <linux/device.h>
1616
#include <linux/err.h>
@@ -56,7 +56,7 @@ struct gaudio {
5656
/* TODO */
5757
};
5858

59-
struct f_uac1_opts {
59+
struct f_uac1_legacy_opts {
6060
struct usb_function_instance func_inst;
6161
int req_buf_size;
6262
int req_count;
@@ -79,4 +79,4 @@ size_t u_audio_playback(struct gaudio *card, void *buf, size_t count);
7979
int u_audio_get_playback_channels(struct gaudio *card);
8080
int u_audio_get_playback_rate(struct gaudio *card);
8181

82-
#endif /* __U_AUDIO_H */
82+
#endif /* __U_UAC1_LEGACY_H */

Diff for: drivers/usb/gadget/legacy/Kconfig

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ config USB_AUDIO
5454
depends on SND
5555
select USB_LIBCOMPOSITE
5656
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
5959
select USB_U_AUDIO if USB_F_UAC2
6060
help
6161
This Gadget Audio driver is compatible with USB Audio Class
@@ -73,7 +73,7 @@ config USB_AUDIO
7373
Say "y" to link the driver statically, or "m" to build a
7474
dynamically linked module called "g_audio".
7575

76-
config GADGET_UAC1
76+
config GADGET_UAC1_LEGACY
7777
bool "UAC 1.0 (Legacy)"
7878
depends on USB_AUDIO
7979
help

0 commit comments

Comments
 (0)