Re: usb/181987: USB isochronous transfer of the USB driver (Mentor Graphics OTG: musb_otg) is not working.

2013-10-15 Thread SAITOU Toshihide
The following reply was made to PR usb/181987; it has been noted by GNATS.

From: SAITOU Toshihide 
To: freebsd-gnats-sub...@freebsd.org
Cc:  
Subject: Re: usb/181987: USB isochronous transfer of the USB driver (Mentor
 Graphics OTG: musb_otg) is not working.
Date: Tue, 15 Oct 2013 22:17:17 +0900 (JST)

 In message: <525ce936.70...@bitfrost.no>
 Hans Petter Selasky  writes:
 > On 09/10/13 13:01, SAITOU Toshihide wrote:
 >>
 >>> Number: 181987
 >>> Category:   usb
 >>> Synopsis: USB isochronous transfer of the USB driver (Mentor
 >>> Graphics OTG: musb_otg) is not working.
 >>> Confidential:   no
 >>> Severity:   non-critical
 >>> Priority:   low
 >>> Responsible:freebsd-usb
 >>> State:  open
 >>> Quarter:
 >>> Keywords:
 >>> Date-Required:
 >>> Class:  sw-bug
 >>> Submitter-Id:   current-users
 >>> Arrival-Date:   Tue Sep 10 11:10:00 UTC 2013
 >>> Closed-Date:
 >>> Last-Modified:
 >>> Originator: SAITOU Toshihide
 >>> Release:FreeBSD 10.0-CURRENT
 >>> Organization:
 >>> Environment:
 >> FreeBSD bbb 10.0-CURRENT FreeBSD 10.0-CURRENT #1: Mon Sep 9
 >> 23:34:15 JST 2013
 >> toshi@fbsd:/usr/obj/arm.armv6/usr/src/sys/BEAGLEBONE arm
 >>
 >>> Description:
 >> The patch attached is somewhat fixed the problem for the
 >> LOGICOOL C920 but still most UVC devices are not working.
 >>
 >> My guess is that the not working device requires three
 >> transactions per *microframe* for the data transfer rate as
 >> the video streaming but the current driver performs one
 >> transaction per microframe. The following page imply the
 >> existence of the undocumented setting to perform so.
 >> http://e2e.ti.com/support/embedded/wince/f/353/t/68966.aspx
 >>
 >>> How-To-Repeat:
 >>
 >>> Fix:
 >>
 >>
 >>> Release-Note:
 >>> Audit-Trail:
 >>> Unformatted:
 >> ___
 >> freebsd-usb@freebsd.org mailing list
 >> http://lists.freebsd.org/mailman/listinfo/freebsd-usb
 >> To unsubscribe, send any mail to
 >> "freebsd-usb-unsubscr...@freebsd.org"
 >>
 > 
 > Hi,
 > 
 > Can you please test the attached patch and report back?
 > 
 > --HPS
 
 I tried to use a UVC device using libusb but couldn't get
 the data. The latter patch was the same result.
 
 FreeBSD revision is 255933.
 
 When libusb_submit_transfer's call back is called,
 actual_length of libusb_iso_packet_descriptor is 0 or 12.
 
 A snippet of ``sysctl hw.usb.debug=4'' is below:
 
 musbotg_device_isoc_enter: start next=537
 musbotg_ep_int_set: ep_no=1, on=1
 musbotg_host_data_rx: ep_no=1
 musbotg_host_data_rx: csr=0x01
 musbotg_host_data_rx: csrh=0x00
 musbotg_interrupt: real endpoint interrupt rx=0x0002, tx=0x
 musbotg_host_data_rx: ep_no=1
 musbotg_host_data_rx: csr=0x01
 musbotg_host_data_rx: count=0x0a80
 musbotg_channel_free: ep_no=1
 musbotg_ep_int_set: ep_no=1, on=0
 musbotg_device_done: xfer=0xc2c080c0, endpoint=0xc2ac3cb8, error=22
 
 It seems that more data are collected...
 
 
 Thanks,
 -- 
 SAITOU Toshihide
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/181987: USB isochronous transfer of the USB driver (Mentor Graphics OTG: musb_otg) is not working.

2013-10-15 Thread Hans Petter Selasky
The following reply was made to PR usb/181987; it has been noted by GNATS.

From: Hans Petter Selasky 
To: SAITOU Toshihide 
Cc: freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/181987: USB isochronous transfer of the USB driver (Mentor
 Graphics OTG: musb_otg) is not working.
Date: Tue, 15 Oct 2013 09:05:26 +0200

 This is a multi-part message in MIME format.
 --090607060603090803000207
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 On 09/10/13 13:01, SAITOU Toshihide wrote:
 >
 >> Number: 181987
 >> Category:   usb
 >> Synopsis:   USB isochronous transfer of the USB driver (Mentor Graphics 
 >> OTG: musb_otg) is not working.
 >> Confidential:   no
 >> Severity:   non-critical
 >> Priority:   low
 >> Responsible:freebsd-usb
 >> State:  open
 >> Quarter:
 >> Keywords:
 >> Date-Required:
 >> Class:  sw-bug
 >> Submitter-Id:   current-users
 >> Arrival-Date:   Tue Sep 10 11:10:00 UTC 2013
 >> Closed-Date:
 >> Last-Modified:
 >> Originator: SAITOU Toshihide
 >> Release:FreeBSD 10.0-CURRENT
 >> Organization:
 >> Environment:
 > FreeBSD bbb 10.0-CURRENT FreeBSD 10.0-CURRENT #1: Mon Sep  9 23:34:15 JST 
 > 2013 toshi@fbsd:/usr/obj/arm.armv6/usr/src/sys/BEAGLEBONE  arm
 >
 >> Description:
 > The patch attached is somewhat fixed the problem for the
 > LOGICOOL C920 but still most UVC devices are not working.
 >
 > My guess is that the not working device requires three
 > transactions per *microframe* for the data transfer rate as
 > the video streaming but the current driver performs one
 > transaction per microframe. The following page imply the
 > existence of the undocumented setting to perform so.
 > http://e2e.ti.com/support/embedded/wince/f/353/t/68966.aspx
 >
 >> How-To-Repeat:
 >
 >> Fix:
 >
 >
 >> Release-Note:
 >> Audit-Trail:
 >> Unformatted:
 > ___
 > freebsd-usb@freebsd.org mailing list
 > http://lists.freebsd.org/mailman/listinfo/freebsd-usb
 > To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"
 >
 
 Hi,
 
 Can you please test the attached patch and report back?
 
 --HPS
 
 --090607060603090803000207
 Content-Type: text/x-patch;
  name="musb.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="musb.diff"
 
 === sys/dev/usb/controller/musb_otg.c
 ==
 --- sys/dev/usb/controller/musb_otg.c  (revision 256504)
 +++ sys/dev/usb/controller/musb_otg.c  (local)
 @@ -646,8 +646,8 @@
count = MUSB2_READ_2(sc, MUSB2_REG_RXCOUNT);
  
/* verify the packet byte count */
 -  if (count != td->max_frame_size) {
 -  if (count < td->max_frame_size) {
 +  if (count != td->max_packet_size) {
 +  if (count < td->max_packet_size) {
/* we have a short packet */
td->short_pkt = 1;
got_short = 1;
 @@ -775,7 +775,7 @@
if (csr & MUSB2_MASK_CSR0L_TXPKTRDY) {
return (1); /* not complete */
}
 -  count = td->max_frame_size;
 +  count = td->max_packet_size;
if (td->remainder < count) {
/* we have a short packet */
td->short_pkt = 1;
 @@ -936,8 +936,8 @@
count = MUSB2_READ_2(sc, MUSB2_REG_RXCOUNT);
  
/* verify the packet byte count */
 -  if (count != td->max_frame_size) {
 -  if (count < td->max_frame_size) {
 +  if (count != td->max_packet_size) {
 +  if (count < td->max_packet_size) {
/* we have a short packet */
td->short_pkt = 1;
got_short = 1;
 @@ -1126,7 +1126,7 @@
}
  
/* check for short packet */
 -  count = td->max_frame_size;
 +  count = td->max_packet_size;
if (td->remainder < count) {
/* we have a short packet */
td->short_pkt = 1;
 @@ -1453,8 +1453,8 @@
/*
 * Check for short or invalid packet:
 */
 -  if (count != td->max_frame_size) {
 -  if (count < td->max_frame_size) {
 +  if (count != td->max_packet_size) {
 +  if (count < td->max_packet_size) {
/* we have a short packet */
td->short_pkt = 1;
got_short = 1;
 @@ -1592,7 +1592,7 @@
return (1); /* not complete */
}
/* check for short packet */
 -  count = td->ma

Re: usb/181987: USB isochronous transfer of the USB driver (Mentor Graphics OTG: musb_otg) is not working.

2013-09-11 Thread SAITOU Toshihide
In message: <522f517d.8040...@bitfrost.no>
Hans Petter Selasky  writes:
> 
> Is this feature urgent for 10.0, because 10 is now in a code
> slush state?

No, I'm not in a hurry, just intended to file a pr.
I'm sorry for sending pr in this period.

> BTW: You should not divide the max_frame_size by 3. You
> should check that the other options, for packet multiplier =
> 1 and 2 also work. See max_packet_size instead of
> max_frame_size!

I attach the patch using max_packet_size instead of
max_frame_size.  This is probably not good but I hope it
will trigger off the isochronous support for beaglebone
black.


--- musb_otg.h.orig 2013-09-11 21:25:45.0 +0900
+++ musb_otg.h  2013-09-11 21:25:45.0 +0900
@@ -318,7 +318,8 @@
uint16_t max_frame_size;/* packet_size * mult */
uint8_t ep_no;
uint8_t transfer_type;
-   uint8_t max_packet;
+   uint16_t max_packet_size;
+   int8_t data_seq;/* sequence of DATA packet */
uint8_t error:1;
uint8_t alt_next:1;
uint8_t short_pkt:1;
--- musb_otg.c.orig 2013-09-11 21:25:45.0 +0900
+++ musb_otg.c  2013-09-11 21:25:45.0 +0900
@@ -1661,7 +1661,7 @@
}
 
/* Max packet size */
-   MUSB2_WRITE_1(sc, MUSB2_REG_TXMAXP, td->max_packet);
+   MUSB2_WRITE_1(sc, MUSB2_REG_TXMAXP, td->max_packet_size);
 
/* write command */
MUSB2_WRITE_1(sc, MUSB2_REG_TXCSRL,
@@ -1689,7 +1689,6 @@
uint16_t count;
uint8_t csr, csrh;
uint8_t to;
-   uint8_t got_short;
 
/* get pointer to softc */
sc = MUSBOTG_PC2SC(td->pc);
@@ -1704,7 +1703,7 @@
DPRINTFN(1, "ep_no=%d\n", td->channel);
 
to = 8; /* don't loop forever! */
-   got_short = 0;
+   td->short_pkt = 0;
 
/* select endpoint */
MUSB2_WRITE_1(sc, MUSB2_REG_EPINDEX, td->channel);
@@ -1726,13 +1725,16 @@
td->hport);
 
/* RX NAK timeout */
-   MUSB2_WRITE_1(sc, MUSB2_REG_RXNAKLIMIT, MAX_NAK_TO);
+   if (td->transfer_type & MUSB2_MASK_TI_PROTO_ISOC)
+   MUSB2_WRITE_1(sc, MUSB2_REG_RXNAKLIMIT, 0);
+   else
+   MUSB2_WRITE_1(sc, MUSB2_REG_RXNAKLIMIT, MAX_NAK_TO);
 
/* Protocol, speed, device endpoint */
MUSB2_WRITE_1(sc, MUSB2_REG_RXTI, td->transfer_type);
 
/* Max packet size */
-   MUSB2_WRITE_1(sc, MUSB2_REG_RXMAXP, td->max_packet);
+   MUSB2_WRITE_1(sc, MUSB2_REG_RXMAXP, td->max_packet_size);
 
/* Data Toggle */
csrh = MUSB2_READ_1(sc, MUSB2_REG_RXCSRH);
@@ -1797,11 +1799,13 @@
/*
 * Check for short or invalid packet:
 */
-   if (count != td->max_frame_size) {
-   if (count < td->max_frame_size) {
+   if (count != td->max_packet_size) {
+   if (td->transfer_type & MUSB2_MASK_TI_PROTO_ISOC && 
td->data_seq < 2) {
+   /* allow short packet of DATA2 and DATA1 in isochronous 
transfer */
+   }
+   else if (count < td->max_packet_size) {
/* we have a short packet */
td->short_pkt = 1;
-   got_short = 1;
} else {
/* invalid USB packet */
td->error = 1;
@@ -1884,13 +1888,15 @@
MUSB2_WRITE_1(sc, MUSB2_REG_RXCSRL, 0);
 
/* check if we are complete */
-   if ((td->remainder == 0) || got_short) {
-   if (td->short_pkt) {
-   /* we are complete */
-   musbotg_channel_free(sc, td);
-   return (0);
-   }
-   /* else need to receive a zero length packet */
+if (td->remainder == 0 || td->short_pkt) {
+   /* we are complete */
+musbotg_channel_free(sc, td);
+return (0);
+}
+
+else if (td->transfer_type & MUSB2_MASK_TI_PROTO_ISOC && td->data_seq 
< 2) {
+   /* getting DATA2 or DATA1 */
+   td->data_seq++;
}
 
/* Reset transaction state and restart */
@@ -2075,7 +2081,7 @@
MUSB2_WRITE_1(sc, MUSB2_REG_TXTI, td->transfer_type);
 
/* Max packet size */
-   MUSB2_WRITE_1(sc, MUSB2_REG_TXMAXP, td->max_packet);
+   MUSB2_WRITE_1(sc, MUSB2_REG_TXMAXP, td->max_packet_size);
 
if (!td->transaction_started) {
csrh = MUSB2_READ_1(sc, MUSB2_REG_TXCSRH);
@@ -2444,7 +2450,7 @@
}
 
temp.transfer_type |= ep_no;
-   td->max_packet = xfer->max_packet_size;
+   td->max_packet_size = xfer->max_packet_size;
td->toggle = xfer->endpoint->toggle_next;
}
 
@@ -3159,9 +3165,9 @@
if (dynfifo) {
if (frx

Re: usb/181987: USB isochronous transfer of the USB driver (Mentor Graphics OTG: musb_otg) is not working.

2013-09-10 Thread Hans Petter Selasky

On 09/10/13 13:40, SAITOU Toshihide wrote:

The following reply was made to PR usb/181987; it has been noted by GNATS.

From: SAITOU Toshihide 
To: bug-follo...@freebsd.org
Cc:
Subject: Re: usb/181987: USB isochronous transfer of the USB driver (Mentor
  Graphics OTG: musb_otg) is not working.
Date: Tue, 10 Sep 2013 20:37:53 +0900 (JST)

  A missing patch.txt of the previous mail is here:


  --- musb_otg.c.orig   2013-09-10 19:57:53.0 +0900
  +++ musb_otg.c2013-09-10 19:57:53.0 +0900
  @@ -1689,7 +1689,6 @@
uint16_t count;
uint8_t csr, csrh;
uint8_t to;
  - uint8_t got_short;


Hi,

Is this feature urgent for 10.0, because 10 is now in a code slush state?

BTW: You should not divide the max_frame_size by 3. You should check 
that the other options, for packet multiplier = 1 and 2 also work. See 
max_packet_size instead of max_frame_size!


--HPS

___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/181987: USB isochronous transfer of the USB driver (Mentor Graphics OTG: musb_otg) is not working.

2013-09-10 Thread SAITOU Toshihide
The following reply was made to PR usb/181987; it has been noted by GNATS.

From: SAITOU Toshihide 
To: bug-follo...@freebsd.org
Cc:  
Subject: Re: usb/181987: USB isochronous transfer of the USB driver (Mentor
 Graphics OTG: musb_otg) is not working.
Date: Tue, 10 Sep 2013 20:37:53 +0900 (JST)

 A missing patch.txt of the previous mail is here:
 
 
 --- musb_otg.c.orig2013-09-10 19:57:53.0 +0900
 +++ musb_otg.c 2013-09-10 19:57:53.0 +0900
 @@ -1689,7 +1689,6 @@
uint16_t count;
uint8_t csr, csrh;
uint8_t to;
 -  uint8_t got_short;
  
/* get pointer to softc */
sc = MUSBOTG_PC2SC(td->pc);
 @@ -1704,7 +1703,7 @@
DPRINTFN(1, "ep_no=%d\n", td->channel);
  
to = 8; /* don't loop forever! */
 -  got_short = 0;
 +  td->short_pkt = 0;
  
/* select endpoint */
MUSB2_WRITE_1(sc, MUSB2_REG_EPINDEX, td->channel);
 @@ -1726,7 +1725,10 @@
td->hport);
  
/* RX NAK timeout */
 -  MUSB2_WRITE_1(sc, MUSB2_REG_RXNAKLIMIT, MAX_NAK_TO);
 +  if (td->transfer_type & MUSB2_MASK_TI_PROTO_ISOC)
 +  MUSB2_WRITE_1(sc, MUSB2_REG_RXNAKLIMIT, 0);
 +  else
 +  MUSB2_WRITE_1(sc, MUSB2_REG_RXNAKLIMIT, MAX_NAK_TO);
  
/* Protocol, speed, device endpoint */
MUSB2_WRITE_1(sc, MUSB2_REG_RXTI, td->transfer_type);
 @@ -1797,11 +1799,10 @@
/*
 * Check for short or invalid packet:
 */
 -  if (count != td->max_frame_size) {
 +  if (count < td->max_frame_size) {
if (count < td->max_frame_size) {
/* we have a short packet */
td->short_pkt = 1;
 -  got_short = 1;
} else {
/* invalid USB packet */
td->error = 1;
 @@ -1884,13 +1885,18 @@
MUSB2_WRITE_1(sc, MUSB2_REG_RXCSRL, 0);
  
/* check if we are complete */
 -  if ((td->remainder == 0) || got_short) {
 -  if (td->short_pkt) {
 -  /* we are complete */
 -  musbotg_channel_free(sc, td);
 -  return (0);
 -  }
 -  /* else need to receive a zero length packet */
 +if (td->remainder == 0 || td->short_pkt) {
 +  /* we are complete */
 +musbotg_channel_free(sc, td);
 +return (0);
 +}
 +
 +else if (td->transfer_type & MUSB2_MASK_TI_PROTO_ISOC) {
 +if (td->remainder != 0) {
 +  /* not short_pkt and now getting DATA2 or DATA1 */
 +td->transaction_started = 0;
 +return (1);
 +}
}
  
/* Reset transaction state and restart */
 @@ -3159,9 +3165,9 @@
if (dynfifo) {
if (frx && (temp <= nrx)) {
if (temp < 8) {
 -  frx = 10;   /* 1K */
 +  frx = 12;   /* 4K */
MUSB2_WRITE_1(sc, MUSB2_REG_RXFIFOSZ, 
 -  MUSB2_VAL_FIFOSZ_512 |
 +  MUSB2_VAL_FIFOSZ_4096 |
MUSB2_MASK_FIFODB);
} else {
frx = 7;/* 128 bytes */
 @@ -4042,7 +4048,7 @@
 * reasonable dummies:
 */
parm->hc_max_packet_size = 0x400;
 -  parm->hc_max_frame_size = 0x400;
 +  parm->hc_max_frame_size = 0xc00;
  
if ((parm->methods == &musbotg_device_isoc_methods) ||
(parm->methods == &musbotg_device_intr_methods))
 @@ -4116,7 +4122,10 @@
td = USB_ADD_BYTES(parm->buf, parm->size[0]);
  
/* init TD */
 -  td->max_frame_size = xfer->max_frame_size;
 +  if (parm->methods == &musbotg_device_isoc_methods)
 +  td->max_frame_size = xfer->max_frame_size/3;
 +  else
 +  td->max_frame_size = xfer->max_frame_size;
td->ep_no = ep_no;
td->obj_next = last_obj;
  
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"