diff options
author | Mike Lockwood <lockwood@google.com> | 2012-05-11 09:00:40 -0700 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-08-16 13:46:18 -0700 |
commit | 23d5fe76cdc190682d1ca7cd1db0b4933631779c (patch) | |
tree | 028cfe8c5439f8d95e6e9f23fc6fb38a7afe2026 /drivers | |
parent | 03d9e752a0c3df2031fd57d41e59f71eb6209789 (diff) |
Add ACCESSORY_SET_AUDIO_MODE control request and ioctl
The control request will be used by the host to enable/disable USB audio
and the ioctl will be used by userspace to read the audio mode
Bug 1026047
Signed-off-by: Mike Lockwood <lockwood@google.com>
(cherry picked from commit 3e1ff6142761eef148c667e540381d1fbc437d4f)
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Change-Id: I5f449de230ca8f44e2dae30a0f87772310b68f20
Reviewed-on: http://git-master/r/123341
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/f_accessory.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/usb/gadget/f_accessory.c b/drivers/usb/gadget/f_accessory.c index 58c653fe50e4..bb6bee12fe27 100644 --- a/drivers/usb/gadget/f_accessory.c +++ b/drivers/usb/gadget/f_accessory.c @@ -40,7 +40,7 @@ #define BULK_BUFFER_SIZE 16384 #define ACC_STRING_SIZE 256 -#define PROTOCOL_VERSION 1 +#define PROTOCOL_VERSION 2 /* String IDs */ #define INTERFACE_STRING_INDEX 0 @@ -78,6 +78,8 @@ struct acc_dev { /* set to 1 if we have a pending start request */ int start_requested; + int audio_mode; + /* synchronize access to our device file */ atomic_t open_excl; @@ -510,6 +512,8 @@ static long acc_ioctl(struct file *fp, unsigned code, unsigned long value) break; case ACCESSORY_IS_START_REQUESTED: return dev->start_requested; + case ACCESSORY_GET_AUDIO_MODE: + return dev->audio_mode; } if (!src) return -EINVAL; @@ -586,6 +590,10 @@ static int acc_ctrlrequest(struct usb_composite_dev *cdev, cdev->gadget->ep0->driver_data = dev; cdev->req->complete = acc_complete_set_string; value = w_length; + } else if (b_request == ACCESSORY_SET_AUDIO_MODE && + w_index == 0 && w_length == 0) { + dev->audio_mode = w_value; + value = 0; } } else if (b_requestType == (USB_DIR_IN | USB_TYPE_VENDOR)) { if (b_request == ACCESSORY_GET_PROTOCOL) { @@ -600,6 +608,7 @@ static int acc_ctrlrequest(struct usb_composite_dev *cdev, memset(dev->uri, 0, sizeof(dev->uri)); memset(dev->serial, 0, sizeof(dev->serial)); dev->start_requested = 0; + dev->audio_mode = 0; } } |