diff options
author | Mike Lockwood <lockwood@google.com> | 2012-05-11 09:01:08 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@google.com> | 2012-05-16 09:25:05 -0700 |
commit | 1f0627dea23276af0180ba57d0c84576c6357897 (patch) | |
tree | 1317fad5fb44c21c72814a52b47f5d41c0c10aa4 /drivers/usb/gadget/android.c | |
parent | 71c42632754e7a022d587b1c6175b63f34e93e90 (diff) | |
download | kernel_samsung_tuna-1f0627dea23276af0180ba57d0c84576c6357897.zip kernel_samsung_tuna-1f0627dea23276af0180ba57d0c84576c6357897.tar.gz kernel_samsung_tuna-1f0627dea23276af0180ba57d0c84576c6357897.tar.bz2 |
USB: gadget: f_audio_source: New gadget driver for audio output
This driver presents a standard USB audio class interface to the host
and an ALSA PCM device to userspace
Signed-off-by: Mike Lockwood <lockwood@google.com>
Diffstat (limited to 'drivers/usb/gadget/android.c')
-rw-r--r-- | drivers/usb/gadget/android.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index 74184a5..3abc53a 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -45,6 +45,7 @@ #include "epautoconf.c" #include "composite.c" +#include "f_audio_source.c" #include "f_mass_storage.c" #include "u_serial.c" #include "f_acm.c" @@ -740,6 +741,67 @@ static struct android_usb_function accessory_function = { .ctrlrequest = accessory_function_ctrlrequest, }; +static int audio_source_function_init(struct android_usb_function *f, + struct usb_composite_dev *cdev) +{ + struct audio_source_config *config; + + config = kzalloc(sizeof(struct audio_source_config), GFP_KERNEL); + if (!config) + return -ENOMEM; + config->card = -1; + config->device = -1; + f->config = config; + return 0; +} + +static void audio_source_function_cleanup(struct android_usb_function *f) +{ + kfree(f->config); +} + +static int audio_source_function_bind_config(struct android_usb_function *f, + struct usb_configuration *c) +{ + struct audio_source_config *config = f->config; + + return audio_source_bind_config(c, config); +} + +static void audio_source_function_unbind_config(struct android_usb_function *f, + struct usb_configuration *c) +{ + struct audio_source_config *config = f->config; + + config->card = -1; + config->device = -1; +} + +static ssize_t audio_source_pcm_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct android_usb_function *f = dev_get_drvdata(dev); + struct audio_source_config *config = f->config; + + /* print PCM card and device numbers */ + return sprintf(buf, "%d %d\n", config->card, config->device); +} + +static DEVICE_ATTR(pcm, S_IRUGO | S_IWUSR, audio_source_pcm_show, NULL); + +static struct device_attribute *audio_source_function_attributes[] = { + &dev_attr_pcm, + NULL +}; + +static struct android_usb_function audio_source_function = { + .name = "audio_source", + .init = audio_source_function_init, + .cleanup = audio_source_function_cleanup, + .bind_config = audio_source_function_bind_config, + .unbind_config = audio_source_function_unbind_config, + .attributes = audio_source_function_attributes, +}; static struct android_usb_function *supported_functions[] = { &adb_function, @@ -749,6 +811,7 @@ static struct android_usb_function *supported_functions[] = { &rndis_function, &mass_storage_function, &accessory_function, + &audio_source_function, NULL }; |