Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Jun 2014 15:39:43 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Yoshiro MIHIRA <sanpei.ml@gmail.com>, freebsd-arm@freebsd.org
Subject:   Re: only issue on FreeBSD/arm(beaglebone black) with multi channel USB audio device.
Message-ID:  <538F219F.4090708@selasky.org>
In-Reply-To: <538F1AAA.5000403@selasky.org>
References:  <CALwmBx1STSve8DmM46O7x1Kz-R8HmTcnTtAkyxUcKob8cb4EUQ@mail.gmail.com> <538F1AAA.5000403@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040301030404030009050306
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

On 06/04/14 15:10, Hans Petter Selasky wrote:
> On 06/04/14 15:03, Yoshiro MIHIRA wrote:
>> I have multi-channel USB audio device.
>>
>> *1 Kyo-On DIGI(sorry,this page was writtin in Japanese)
>> http://www.area-powers.jp/product/usb_product/product/kyo-on/u1soundt4.html
>>
>>
>> I can use this device without issue on **FreeBSD/i386-current**[OK].
>> (only I set below setting in /boot/loader.conf
>> hw.usb.uaudio.default_
>> channels=16
>>
>> [FYI] we discussed below thread.
>> http://comments.gmane.org/gmane.os.freebsd.devel.usb/6213
>>
>> I tried to use this USB audio on **FreeBSD/arm BeagleBone Black** same
>> source tree(r267049).
>> However I have noise sound **playback** sound[NG](mpg123 and wavplay).
>> If I **record** this device on BeagleBone Black, there is no issues.
>>
>> If I use 2ch USB audio device, there is no issues on BeagleBone Black.
>>
>> Does someone have any idea to use this device on BeagleBone Black?
>>
>
> Hi,
>
> Can you give some more information about your USB audio device:
>
> High Speed or Full Speed?
>
> What USB controllers are used?
>
> There are some limitations currently, that high-payload isochonous
> transfers are not fully supported by the non ehci/ohci/uhci/xhci
> controllers. That probably explains why only 2-channels are working.
>
> --HPS

Hi,

If the musb controller is used, can you try the attached patch?

--HPS


--------------040301030404030009050306
Content-Type: text/x-diff;
 name="musb_otg.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="musb_otg.diff"

=== musb_otg.c
==================================================================
--- musb_otg.c	(revision 266950)
+++ musb_otg.c	(local)
@@ -131,7 +131,7 @@
 static void	musbotg_standard_done(struct usb_xfer *);
 static void	musbotg_interrupt_poll(struct musbotg_softc *);
 static void	musbotg_root_intr(struct musbotg_softc *);
-static int	musbotg_channel_alloc(struct musbotg_softc *, struct musbotg_td *td);
+static int	musbotg_channel_alloc(struct musbotg_softc *, struct musbotg_td *td, uint8_t);
 static void	musbotg_channel_free(struct musbotg_softc *, struct musbotg_td *td);
 static void	musbotg_ep_int_set(struct musbotg_softc *sc, int channel, int on);
 
@@ -149,7 +149,7 @@
 };
 
 static int
-musbotg_channel_alloc(struct musbotg_softc *sc, struct musbotg_td *td)
+musbotg_channel_alloc(struct musbotg_softc *sc, struct musbotg_td *td, uint8_t is_tx)
 {
 	int ch;
 	int ep;
@@ -173,12 +173,23 @@
 		return (0);
 	}
 
-	for (ch = 1; ch < MUSB2_EP_MAX; ch++) {
-		if (!(sc->sc_channel_mask & (1 << ch))) {
-			sc->sc_channel_mask |= (1 << ch);
-			musbotg_ep_int_set(sc, ch, 1);
-			return (ch);
+	for (ch = sc->sc_ep_max; ch != 0; ch--) {
+		if (sc->sc_channel_mask & (1 << ch))
+			continue;
+
+		/* verify FIFO size */
+		if (is_tx) {
+			if (td->max_frame_size >
+			    sc->sc_hw_ep_profile[ch].max_in_frame_size)
+				continue;
+		} else {
+			if (td->max_frame_size >
+			    sc->sc_hw_ep_profile[ch].max_out_frame_size)
+				continue;
 		}
+		sc->sc_channel_mask |= (1 << ch);
+		musbotg_ep_int_set(sc, ch, 1);
+		return (ch);
 	}
 
 	DPRINTFN(-1, "No available channels. Mask: %04x\n",  sc->sc_channel_mask);
@@ -377,7 +388,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 0);
 
 	/* EP0 is busy, wait */
 	if (td->channel == -1)
@@ -498,7 +509,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 1);
 
 	/* EP0 is busy, wait */
 	if (td->channel == -1)
@@ -870,7 +881,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 0);
 
 	/* EP0 is busy, wait */
 	if (td->channel == -1)
@@ -1049,7 +1060,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 1);
 
 	/* No free EPs */
 	if (td->channel == -1)
@@ -1259,7 +1270,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 0);
 
 	/* EP0 is busy, wait */
 	if (td->channel == -1)
@@ -1346,7 +1357,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 1);
 
 	/* EP0 is busy, wait */
 	if (td->channel == -1)
@@ -1419,7 +1430,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 0);
 
 	/* EP0 is busy, wait */
 	if (td->channel == -1)
@@ -1567,7 +1578,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 1);
 
 	/* EP0 is busy, wait */
 	if (td->channel == -1)
@@ -1695,7 +1706,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 0);
 
 	/* No free EPs */
 	if (td->channel == -1)
@@ -1917,7 +1928,7 @@
 	sc = MUSBOTG_PC2SC(td->pc);
 
 	if (td->channel == -1)
-		td->channel = musbotg_channel_alloc(sc, td);
+		td->channel = musbotg_channel_alloc(sc, td, 1);
 
 	/* No free EPs */
 	if (td->channel == -1)
@@ -3226,6 +3237,7 @@
 			pf->support_out = 1;
 		} else if (frx && (temp <= nrx)) {
 			pf->max_out_frame_size = 1 << frx;
+			pf->max_in_frame_size = 0;
 			pf->is_simplex = 1;	/* simplex */
 			pf->support_multi_buffer = 1;
 			pf->support_bulk = 1;
@@ -3234,6 +3246,7 @@
 			pf->support_out = 1;
 		} else if (ftx && (temp <= ntx)) {
 			pf->max_in_frame_size = 1 << ftx;
+			pf->max_out_frame_size = 0;
 			pf->is_simplex = 1;	/* simplex */
 			pf->support_multi_buffer = 1;
 			pf->support_bulk = 1;
@@ -3287,18 +3300,6 @@
 }
 
 static void
-musbotg_suspend(struct musbotg_softc *sc)
-{
-	/* TODO */
-}
-
-static void
-musbotg_resume(struct musbotg_softc *sc)
-{
-	/* TODO */
-}
-
-static void
 musbotg_do_poll(struct usb_bus *bus)
 {
 	struct musbotg_softc *sc = MUSBOTG_BUS2SC(bus);
@@ -4214,13 +4215,13 @@
 
 	switch (state) {
 	case USB_HW_POWER_SUSPEND:
-		musbotg_suspend(sc);
+		musbotg_uninit(sc);
 		break;
 	case USB_HW_POWER_SHUTDOWN:
 		musbotg_uninit(sc);
 		break;
 	case USB_HW_POWER_RESUME:
-		musbotg_resume(sc);
+		musbotg_init(sc);
 		break;
 	default:
 		break;

--------------040301030404030009050306--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?538F219F.4090708>