All of lore.kernel.org
 help / color / mirror / Atom feed
* usbcore: Select UAC3 configuration for audio if present
@ 2018-09-13 11:06 Oliver Neukum
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Neukum @ 2018-09-13 11:06 UTC (permalink / raw)
  To: saranya.gopal, linux-usb
  Cc: abhilash.k.v, m.balaji, rajaram.regupathy, felipe.balbi

On Di, 2018-09-11 at 23:36 +0530, saranya.gopal@intel.com wrote:
> @@ -121,6 +132,23 @@ int usb_choose_configuration(struct usb_device *udev)
>  #endif
>                 }
>  
> +               /*
> +                * Select first configuration as default for audio so that
> +                * devices that don't comply with UAC3 protocol are supported.
> +                * But, still iterate through other configurations and
> +                * select UAC3 compliant config if present.
> +                */
> +               if (i == 0 && num_configs > 1 && desc && is_audio(desc)) {
> +                       best = c;
> +                       continue;
> +               }
> +
> +               if (i > 0 && desc && is_audio(desc)) {
> +                       if (is_uac3_config(desc))
> +                               best = c;
> +                               break;
> +               }

Hi,

that looks like a special case. Couldn't we do

for (all configuration) {

1. take first
2. if this configuration is generic and the current is specific change
current
3. if if this configuration is the same interface class as current and
protocol is higher, change current

}
	Regards
		Oliver

^ permalink raw reply	[flat|nested] 3+ messages in thread

* usbcore: Select UAC3 configuration for audio if present
@ 2018-09-14  9:22 saranya.gopal
  0 siblings, 0 replies; 3+ messages in thread
From: saranya.gopal @ 2018-09-14  9:22 UTC (permalink / raw)
  To: Oliver Neukum, linux-usb
  Cc: K V, Abhilash, Balaji, M, Regupathy, Rajaram, felipe.balbi

Hi Oliver,

> -----Original Message-----
> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-
> owner@vger.kernel.org] On Behalf Of Oliver Neukum
> Sent: Thursday, September 13, 2018 4:37 PM
> To: Gopal, Saranya <saranya.gopal@intel.com>; linux-usb@vger.kernel.org
> Cc: K V, Abhilash <abhilash.k.v@intel.com>; Balaji, M <m.balaji@intel.com>;
> Regupathy, Rajaram <rajaram.regupathy@intel.com>;
> felipe.balbi@linux.intel.com
> Subject: Re: [PATCH] usbcore: Select UAC3 configuration for audio if present
> 
> On Di, 2018-09-11 at 23:36 +0530, saranya.gopal@intel.com wrote:
> > @@ -121,6 +132,23 @@ int usb_choose_configuration(struct usb_device
> *udev)
> >  #endif
> >                 }
> >
> > +               /*
> > +                * Select first configuration as default for audio so that
> > +                * devices that don't comply with UAC3 protocol are supported.
> > +                * But, still iterate through other configurations and
> > +                * select UAC3 compliant config if present.
> > +                */
> > +               if (i == 0 && num_configs > 1 && desc && is_audio(desc)) {
> > +                       best = c;
> > +                       continue;
> > +               }
> > +
> > +               if (i > 0 && desc && is_audio(desc)) {
> > +                       if (is_uac3_config(desc))
> > +                               best = c;
> > +                               break;
> > +               }
> 
> Hi,
> 
> that looks like a special case. Couldn't we do
> 
> for (all configuration) {
> 
> 1. take first
> 2. if this configuration is generic and the current is specific change
> current
> 3. if if this configuration is the same interface class as current and
> protocol is higher, change current
> 

I have followed the same style used for Ethernet case in this function.
Do you foresee benefits with your approach over the existing one?

Thanks,
Saranya

> }
> 	Regards
> 		Oliver

^ permalink raw reply	[flat|nested] 3+ messages in thread

* usbcore: Select UAC3 configuration for audio if present
@ 2018-09-11 18:06 saranya.gopal
  0 siblings, 0 replies; 3+ messages in thread
From: saranya.gopal @ 2018-09-11 18:06 UTC (permalink / raw)
  To: linux-usb
  Cc: felipe.balbi, rajaram.regupathy, abhilash.k.v, m.balaji, Saranya Gopal

From: Saranya Gopal <saranya.gopal@intel.com>

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>
---
 drivers/usb/core/generic.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index bc8242b..dc6eb24 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -21,6 +21,7 @@
 
 #include <linux/usb.h>
 #include <linux/usb/hcd.h>
+#include <uapi/linux/usb/audio.h>
 #include "usb.h"
 
 static inline const char *plural(int n)
@@ -42,6 +43,16 @@ static int is_activesync(struct usb_interface_descriptor *desc)
 		&& desc->bInterfaceProtocol == 1;
 }
 
+static int is_audio(struct usb_interface_descriptor *desc)
+{
+	return desc->bInterfaceClass == USB_CLASS_AUDIO;
+}
+
+static int is_uac3_config(struct usb_interface_descriptor *desc)
+{
+	return desc->bInterfaceProtocol == UAC_VERSION_3;
+}
+
 int usb_choose_configuration(struct usb_device *udev)
 {
 	int i;
@@ -121,6 +132,23 @@ int usb_choose_configuration(struct usb_device *udev)
 #endif
 		}
 
+		/*
+		 * Select first configuration as default for audio so that
+		 * devices that don't comply with UAC3 protocol are supported.
+		 * But, still iterate through other configurations and
+		 * select UAC3 compliant config if present.
+		 */
+		if (i == 0 && num_configs > 1 && desc && is_audio(desc)) {
+			best = c;
+			continue;
+		}
+
+		if (i > 0 && desc && is_audio(desc)) {
+			if (is_uac3_config(desc))
+				best = c;
+				break;
+		}
+
 		/* From the remaining configs, choose the first one whose
 		 * first interface is for a non-vendor-specific class.
 		 * Reason: Linux is more likely to have a class driver

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-14  9:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-13 11:06 usbcore: Select UAC3 configuration for audio if present Oliver Neukum
  -- strict thread matches above, loose matches on Subject: below --
2018-09-14  9:22 saranya.gopal
2018-09-11 18:06 saranya.gopal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.