Subject: Re: sony cybershot umass problems
To: Quentin Garnier <cube@cubidou.net>
From: Mihai Chelaru <kefren@netbsd.ro>
List: current-users
Date: 01/07/2007 10:22:39
--Boundary-00=_P3KoFGiwHhHV6cs
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Wednesday 03 January 2007 20:04, Quentin Garnier wrote:
> On Tue, Jan 02, 2007 at 10:15:55AM +0100, Quentin Garnier wrote:
> > On Tue, Jan 02, 2007 at 11:03:26AM +0200, kefren@netbsd.ro wrote:
> > > Hi,
> > >
> > > My cybershot is reported as
> > >
> > > umass0 at uhub4 port 8 configuration 1 interface 0
> > > umass0: Sony Sony DSC, rev 2.00/6.00, addr 2
> > > umass0: using SCSI over CBI
> > > scsibus0 at umass0: 2 targets, 1 lun per target
> > > umass0: CBI reset failed, STALLED
> > >
> > > but never goes further to detect sdX device. My guess is that it needs
> > > somekind of quirk like here
> > > http://archive.netbsd.se/?ml=freebsd-mobile&a=2006-03&t=1811031 but I
> > > have no idea how to bring that in NetBSD. Anyone can help ?
> >
> > I have a DSC-T9.  I'll try adding a quirk by tonight.
>
> I'm not having much success so far;  I'll keep you updated.

Hello again,

Can you try the attached patch and see if it's OK for you ? Works fine here:

umass0 at uhub4 port 4 configuration 1 interface 0
umass0: Sony Sony DSC, rev 2.00/6.00, addr 2
umass0: using RBC over CBI
scsibus0 at umass0: 2 targets, 1 lun per target
sd0 at scsibus0 target 0 lun 0: <Sony, Sony DSC, 6.00> disk removable
sd0: fabricating a geometry
sd0: 951 MB, 951 cyl, 64 head, 32 sec, 512 bytes/sect x 1947648 sectors


-- 
Thanks,
Mihai

--Boundary-00=_P3KoFGiwHhHV6cs
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="sony.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="sony.diff"

Index: umass.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umass.c,v
retrieving revision 1.122
diff -u -r1.122 umass.c
--- umass.c	16 Nov 2006 01:33:27 -0000	1.122
+++ umass.c	7 Jan 2007 08:20:39 -0000
@@ -1311,17 +1311,26 @@
 umass_cbi_adsc(struct umass_softc *sc, char *buffer, int buflen,
 	       usbd_xfer_handle xfer)
 {
+	int blen2 = buflen;
 	KASSERT(sc->sc_wire & (UMASS_WPROTO_CBI|UMASS_WPROTO_CBI_I),
 		("sc->sc_wire == 0x%02x wrong for umass_cbi_adsc\n",
 		sc->sc_wire));
 
+/* XXX: Kefren: For Sony Cameras */
+	if ((sc->sc_cmd == UMASS_CPROTO_RBC) &&
+		(sc->sc_quirks & UMASS_QUIRK_RBC_PAD_TO_12) &&
+		(blen2 < 12)) {
+		blen2 = 12;
+		bzero(buffer + buflen, 12 - buflen);
+		}
+
 	sc->sc_req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
 	sc->sc_req.bRequest = UR_CBI_ADSC;
 	USETW(sc->sc_req.wValue, 0);
 	USETW(sc->sc_req.wIndex, sc->sc_ifaceno);
-	USETW(sc->sc_req.wLength, buflen);
+	USETW(sc->sc_req.wLength, blen2);
 	return umass_setup_ctrl_transfer(sc, &sc->sc_req, buffer,
-					 buflen, 0, xfer);
+					 blen2, 0, xfer);
 }
 
 
Index: umass_quirks.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umass_quirks.c,v
retrieving revision 1.70
diff -u -r1.70 umass_quirks.c
--- umass_quirks.c	11 Dec 2005 12:24:01 -0000	1.70
+++ umass_quirks.c	7 Jan 2007 08:20:39 -0000
@@ -149,7 +149,7 @@
 	 */
 	{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_DSC },
 	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
-	  0,
+	  UMASS_QUIRK_RBC_PAD_TO_12,
 	  0,
 	  UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
 	  NULL, umass_fixup_sony
@@ -242,5 +242,5 @@
 
 	id = usbd_get_interface_descriptor(sc->sc_iface);
 	if (id->bInterfaceSubClass == 0xff)
-		sc->sc_cmd = UMASS_CPROTO_SCSI;
+		sc->sc_cmd = UMASS_CPROTO_RBC;
 }
Index: umassvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/umassvar.h,v
retrieving revision 1.24
diff -u -r1.24 umassvar.h
--- umassvar.h	11 Dec 2005 12:24:01 -0000	1.24
+++ umassvar.h	7 Jan 2007 08:20:39 -0000
@@ -178,6 +178,7 @@
 	u_int32_t		sc_quirks;
 #define	UMASS_QUIRK_WRONG_CSWSIG         0x00000001
 #define	UMASS_QUIRK_WRONG_CSWTAG         0x00000002
+#define	UMASS_QUIRK_RBC_PAD_TO_12	 0x00000004
 
 	u_int32_t		sc_busquirks;
 

--Boundary-00=_P3KoFGiwHhHV6cs--