aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaranya Gopal <saranya.gopal@intel.com>2018-09-11 23:16:26 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-20 07:12:05 -0400
commitf13912d3f014a7f2fa5c35d25ee8c3f96bda6272 (patch)
treead1b5eea466358a6d08a865ae601462dc6f3ab7e
parent28da90f19cdec24d669d75942fec227f4de37abd (diff)
usbcore: Select UAC3 configuration for audio if present
USB audio class 3.0 specification introduced many significant changes like - new power domains, support for LPM/L1 - new cluster descriptor - new high capability and class-specific string descriptors - BADD profiles - ... and many other things (check spec from link below: http://www.usb.org/developers/docs/devclass_docs/USB_Audio_v3.0.zip) Now that UAC3 is supported in linux, choose UAC3 configuration for audio if the device supports it. Selecting this configuration will enable the system to save power by leveraging the new power domains and LPM L1 capability and also support new codec types and data formats for consumer audio applications. Signed-off-by: Saranya Gopal <saranya.gopal@intel.com> Reviewed-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/core/generic.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index bc8242bc4564..356b05c82dbc 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/usb.h> 22#include <linux/usb.h>
23#include <linux/usb/hcd.h> 23#include <linux/usb/hcd.h>
24#include <uapi/linux/usb/audio.h>
24#include "usb.h" 25#include "usb.h"
25 26
26static inline const char *plural(int n) 27static inline const char *plural(int n)
@@ -42,6 +43,16 @@ static int is_activesync(struct usb_interface_descriptor *desc)
42 && desc->bInterfaceProtocol == 1; 43 && desc->bInterfaceProtocol == 1;
43} 44}
44 45
46static bool is_audio(struct usb_interface_descriptor *desc)
47{
48 return desc->bInterfaceClass == USB_CLASS_AUDIO;
49}
50
51static bool is_uac3_config(struct usb_interface_descriptor *desc)
52{
53 return desc->bInterfaceProtocol == UAC_VERSION_3;
54}
55
45int usb_choose_configuration(struct usb_device *udev) 56int usb_choose_configuration(struct usb_device *udev)
46{ 57{
47 int i; 58 int i;
@@ -121,6 +132,22 @@ int usb_choose_configuration(struct usb_device *udev)
121#endif 132#endif
122 } 133 }
123 134
135 /*
136 * Select first configuration as default for audio so that
137 * devices that don't comply with UAC3 protocol are supported.
138 * But, still iterate through other configurations and
139 * select UAC3 compliant config if present.
140 */
141 if (i == 0 && num_configs > 1 && desc && is_audio(desc)) {
142 best = c;
143 continue;
144 }
145
146 if (i > 0 && desc && is_audio(desc) && is_uac3_config(desc)) {
147 best = c;
148 break;
149 }
150
124 /* From the remaining configs, choose the first one whose 151 /* From the remaining configs, choose the first one whose
125 * first interface is for a non-vendor-specific class. 152 * first interface is for a non-vendor-specific class.
126 * Reason: Linux is more likely to have a class driver 153 * Reason: Linux is more likely to have a class driver