From 0f688358b61f1f923553d3aee8d62ec46315525b4f992a6e52644556f47af246 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Thu, 2 Aug 2012 14:38:18 +0000 Subject: [PATCH] quilt refreshed with latest 2.4 libusb1 fixes OBS-URL: https://build.opensuse.org/package/show/graphics/libgphoto2?expand=0&rev=76 --- lg-24-branch.patch | 358 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 331 insertions(+), 27 deletions(-) diff --git a/lg-24-branch.patch b/lg-24-branch.patch index f7eec42..de3dc73 100644 --- a/lg-24-branch.patch +++ b/lg-24-branch.patch @@ -1,7 +1,8 @@ -diff -ru ./camlibs/canon/canon.c /home/marcus/projects/libgphoto2-2_4/libgphoto2/camlibs/canon/canon.c ---- camlibs/canon/canon.c 2012-03-30 23:23:47.000000000 +0200 -+++ camlibs/canon/canon.c 2012-07-19 20:19:15.693782425 +0200 -@@ -1333,8 +1333,7 @@ +Index: camlibs/canon/canon.c +=================================================================== +--- camlibs/canon/canon.c.orig ++++ camlibs/canon/canon.c +@@ -1333,8 +1333,7 @@ void canon_int_find_new_image ( Camera * if ( is_image ( new_name ) ) { /* Yup, we'll assume that this is the new image. */ GP_DEBUG ( " Found our new image file" ); @@ -11,10 +12,11 @@ diff -ru ./camlibs/canon/canon.c /home/marcus/projects/libgphoto2-2_4/libgphoto2 strcpy ( path->folder, canon2gphotopath ( camera, path->folder ) ); /* FIXME: Marcus: make it less large effort... */ -diff -ru ./camlibs/ptp2/library.c /home/marcus/projects/libgphoto2-2_4/libgphoto2/camlibs/ptp2/library.c ---- camlibs/ptp2/library.c 2012-04-15 17:11:15.000000000 +0200 -+++ camlibs/ptp2/library.c 2012-07-19 20:19:15.686782359 +0200 -@@ -715,7 +715,7 @@ +Index: camlibs/ptp2/library.c +=================================================================== +--- camlibs/ptp2/library.c.orig ++++ camlibs/ptp2/library.c +@@ -715,7 +715,7 @@ static struct { {"Nikon:Coolpix L110 (PTP mode)", 0x04b0, 0x017e, PTP_CAP}, /* miguel@rozsas.eng.br */ @@ -23,7 +25,7 @@ diff -ru ./camlibs/ptp2/library.c /home/marcus/projects/libgphoto2-2_4/libgphoto /* Graeme Wyatt */ {"Nikon:Coolpix L120 (PTP mode)", 0x04b0, 0x0185, PTP_CAP}, /* Kévin Ottens */ -@@ -740,6 +740,8 @@ +@@ -740,6 +740,8 @@ static struct { {"Nikon:Coolpix S8000 (PTP mode)",0x04b0, 0x021f, 0}, /* Aleksej Serdjukov */ {"Nikon:Coolpix S5100 (PTP mode)",0x04b0, 0x0220, 0}, @@ -32,7 +34,7 @@ diff -ru ./camlibs/ptp2/library.c /home/marcus/projects/libgphoto2-2_4/libgphoto /* Nikon Coolpix 2000 */ {"Nikon:Coolpix 2000 (PTP mode)", 0x04b0, 0x0302, 0}, /* From IRC reporter. */ -@@ -810,6 +812,11 @@ +@@ -810,6 +812,11 @@ static struct { /* IRC Reporter popolon */ {"Nikon:DSC D5100 (PTP mode)", 0x04b0, 0x0429, PTP_CAP|PTP_CAP_PREVIEW}, @@ -44,7 +46,7 @@ diff -ru ./camlibs/ptp2/library.c /home/marcus/projects/libgphoto2-2_4/libgphoto #if 0 /* Thomas Luzat */ /* this was reported as not working, mass storage only: -@@ -1058,6 +1065,8 @@ +@@ -1058,6 +1065,8 @@ static struct { /* Martin Lasarsch at SUSE. MTP_PROPLIST returns just 0 entries */ {"Canon:Digital IXUS 90 IS", 0x04a9, 0x3174, PTPBUG_DELETE_SENDS_EVENT}, @@ -53,7 +55,7 @@ diff -ru ./camlibs/ptp2/library.c /home/marcus/projects/libgphoto2-2_4/libgphoto /* https://sourceforge.net/tracker/?func=detail&aid=2722422&group_id=8874&atid=358874 */ {"Canon:Digital IXUS 85 IS", 0x04a9, 0x3174, PTPBUG_DELETE_SENDS_EVENT}, -@@ -1289,6 +1298,9 @@ +@@ -1289,6 +1298,9 @@ static struct { {"Apple:iPod Touch 3rd Gen (PTP mode)", 0x05ac, 0x1299, 0}, {"Apple:iPad (PTP mode)", 0x05ac, 0x129a, 0}, @@ -63,7 +65,7 @@ diff -ru ./camlibs/ptp2/library.c /home/marcus/projects/libgphoto2-2_4/libgphoto /* https://sourceforge.net/tracker/index.php?func=detail&aid=1869653&group_id=158745&atid=809061 */ {"Pioneer:DVR-LX60D", 0x08e4, 0x0142, 0}, -@@ -4555,12 +4567,14 @@ +@@ -4555,12 +4567,14 @@ get_file_func (CameraFilesystem *fs, con unsigned char *ximage = NULL; unsigned int xlen = 0; @@ -81,44 +83,346 @@ diff -ru ./camlibs/ptp2/library.c /home/marcus/projects/libgphoto2-2_4/libgphoto gp_log (GP_LOG_ERROR, "get_file_func/GP_FILE_TYPE_PREVIEW", "size mismatch %d vs %d", size, xlen); set_mimetype (camera, file, params->deviceinfo.VendorExtensionID, oi->ThumbFormat); CR (gp_file_set_data_and_size (file, (char*)ximage, xlen)); -diff -ru ./libgphoto2_port/libusb1/libusb1.c /home/marcus/projects/libgphoto2-2_4/libgphoto2/libgphoto2_port/libusb1/libusb1.c ---- libgphoto2_port/libusb1/libusb1.c 2012-03-26 21:34:10.000000000 +0200 -+++ libgphoto2_port/libusb1/libusb1.c 2012-07-19 20:05:50.066206830 +0200 -@@ -119,6 +119,7 @@ +Index: libgphoto2_port/libusb1/libusb1.c +=================================================================== +--- libgphoto2_port/libusb1/libusb1.c.orig ++++ libgphoto2_port/libusb1/libusb1.c +@@ -71,6 +71,10 @@ struct _GPPortPrivateLibrary { + + int detached; + ++ time_t devslastchecked; ++ int nrofdevs; ++ struct libusb_device_descriptor *descs; ++ libusb_device **devs; + }; + + GPPortType +@@ -79,38 +83,34 @@ gp_port_library_type (void) + return (GP_PORT_USB); + } + +-static time_t gp_devslastchecked = 0; +-static int gp_nrofdevs = 0; +-static struct libusb_device_descriptor *gp_descs; +-static libusb_device **gp_devs; + + static ssize_t +-load_devicelist (libusb_context *ctx) { ++load_devicelist (GPPortPrivateLibrary *pl) { + time_t xtime; + + time(&xtime); +- if (xtime != gp_devslastchecked) { +- if (gp_nrofdevs) +- libusb_free_device_list (gp_devs, 1); +- free (gp_descs); +- gp_nrofdevs = 0; +- gp_devs = NULL; +- gp_descs = NULL; ++ if (xtime != pl->devslastchecked) { ++ if (pl->nrofdevs) ++ libusb_free_device_list (pl->devs, 1); ++ free (pl->descs); ++ pl->nrofdevs = 0; ++ pl->devs = NULL; ++ pl->descs = NULL; + } +- if (!gp_nrofdevs) { ++ if (!pl->nrofdevs) { + int i; + +- gp_nrofdevs = libusb_get_device_list (ctx, &gp_devs); +- gp_descs = malloc (sizeof(gp_descs[0])*gp_nrofdevs); +- for (i=0;inrofdevs = libusb_get_device_list (pl->ctx, &pl->devs); ++ pl->descs = malloc (sizeof(pl->descs[0])*pl->nrofdevs); ++ for (i=0;inrofdevs;i++) { + int ret; +- ret = libusb_get_device_descriptor(gp_devs[i], &gp_descs[i]); ++ ret = libusb_get_device_descriptor(pl->devs[i], &pl->descs[i]); + if (ret) + gp_log (GP_LOG_ERROR, "libusb1", "libusb_get_device_descriptor(%d) returned %d", i, ret); + } + } +- time (&gp_devslastchecked); +- return gp_nrofdevs; ++ time (&pl->devslastchecked); ++ return pl->nrofdevs; + } + + int +@@ -119,6 +119,10 @@ gp_port_library_list (GPPortInfoList *li GPPortInfo info; int nrofdevices = 0; int d, i, i1, i2, unknownint; + libusb_context *ctx; ++ libusb_device **devs = NULL; ++ int nrofdevs = 0; ++ struct libusb_device_descriptor *descs; /* generic matcher. This will catch passed XXX,YYY entries for instance. */ info.type = GP_PORT_USB; -@@ -126,8 +127,8 @@ +@@ -126,26 +130,33 @@ gp_port_library_list (GPPortInfoList *li strcpy (info.path, "^usb:"); CHECK (gp_port_info_list_append (list, info)); - libusb_init (NULL); - gp_nrofdevs = load_devicelist (NULL); + libusb_init (&ctx); -+ gp_nrofdevs = load_devicelist (ctx); ++ nrofdevs = libusb_get_device_list (ctx, &devs); ++ descs = malloc (sizeof(descs[0])*nrofdevs); ++ for (i=0;ipl) { + libusb_exit (port->pl->ctx); ++ free (port->pl->descs); + free (port->pl); port->pl = NULL; } - if (gp_devs) libusb_free_device_list (gp_devs, 1); -+ gp_devs = NULL; gp_nrofdevs = 0; - free (gp_descs); +- free (gp_descs); return (GP_OK); } + +@@ -744,6 +754,7 @@ gp_port_usb_find_device_lib(GPPort *port + { + char *s; + int d, busnr = 0, devnr = 0; ++ GPPortPrivateLibrary *pl = port->pl; + + if (!port) + return (GP_ERROR_BAD_PARAMETERS); +@@ -767,23 +778,23 @@ gp_port_usb_find_device_lib(GPPort *port + return GP_ERROR_BAD_PARAMETERS; + } + +- gp_nrofdevs = load_devicelist (port->pl->ctx); ++ pl->nrofdevs = load_devicelist (port->pl); + +- for (d = 0; d < gp_nrofdevs; d++) { ++ for (d = 0; d < pl->nrofdevs; d++) { + struct libusb_config_descriptor *confdesc; + int ret; + int config = -1, interface = -1, altsetting = -1; + +- if ((gp_descs[d].idVendor != idvendor) || +- (gp_descs[d].idProduct != idproduct)) ++ if ((pl->descs[d].idVendor != idvendor) || ++ (pl->descs[d].idProduct != idproduct)) + continue; + +- if (busnr && (busnr != libusb_get_bus_number (gp_devs[d]))) ++ if (busnr && (busnr != libusb_get_bus_number (pl->devs[d]))) + continue; +- if (devnr && (devnr != libusb_get_device_address (gp_devs[d]))) ++ if (devnr && (devnr != libusb_get_device_address (pl->devs[d]))) + continue; + +- port->pl->d = gp_devs[d]; ++ port->pl->d = pl->devs[d]; + + gp_log (GP_LOG_VERBOSE, "libusb1", + "Looking for USB device " +@@ -791,9 +802,9 @@ gp_port_usb_find_device_lib(GPPort *port + idvendor, idproduct); + + /* Use the first config, interface and altsetting we find */ +- gp_port_usb_find_first_altsetting(gp_devs[d], &config, &interface, &altsetting); ++ gp_port_usb_find_first_altsetting(pl->devs[d], &config, &interface, &altsetting); + +- ret = libusb_get_config_descriptor (gp_devs[d], config, &confdesc); ++ ret = libusb_get_config_descriptor (pl->devs[d], config, &confdesc); + if (ret) + continue; + +@@ -810,11 +821,11 @@ gp_port_usb_find_device_lib(GPPort *port + port->settings.usb.interface = confdesc->interface[interface].altsetting[altsetting].bInterfaceNumber; + port->settings.usb.altsetting = confdesc->interface[interface].altsetting[altsetting].bAlternateSetting; + +- port->settings.usb.inep = gp_port_usb_find_ep(gp_devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_BULK); +- port->settings.usb.outep = gp_port_usb_find_ep(gp_devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_OUT, LIBUSB_TRANSFER_TYPE_BULK); +- port->settings.usb.intep = gp_port_usb_find_ep(gp_devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_INTERRUPT); ++ port->settings.usb.inep = gp_port_usb_find_ep(pl->devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_BULK); ++ port->settings.usb.outep = gp_port_usb_find_ep(pl->devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_OUT, LIBUSB_TRANSFER_TYPE_BULK); ++ port->settings.usb.intep = gp_port_usb_find_ep(pl->devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_INTERRUPT); + +- port->settings.usb.maxpacketsize = libusb_get_max_packet_size (gp_devs[d], port->settings.usb.inep); ++ port->settings.usb.maxpacketsize = libusb_get_max_packet_size (pl->devs[d], port->settings.usb.inep); + gp_log (GP_LOG_VERBOSE, "libusb1", + "Detected defaults: config %d, " + "interface %d, altsetting %d, " +@@ -998,6 +1009,8 @@ gp_port_usb_match_device_by_class(struct + if (class == 666) /* Special hack for MTP devices with MS OS descriptors. */ + return gp_port_usb_match_mtp_device (dev, configno, interfaceno, altsettingno); + ++ ret = libusb_get_device_descriptor(dev, &desc); ++ + if (desc.bDeviceClass == class && + (subclass == -1 || + desc.bDeviceSubClass == subclass) && +@@ -1005,7 +1018,6 @@ gp_port_usb_match_device_by_class(struct + desc.bDeviceProtocol == protocol)) + return 1; + +- ret = libusb_get_device_descriptor(dev, &desc); + + for (i = 0; i < desc.bNumConfigurations; i++) { + struct libusb_config_descriptor *config; +@@ -1045,6 +1057,7 @@ gp_port_usb_find_device_by_class_lib(GPP + { + char *s; + int d, busnr = 0, devnr = 0; ++ GPPortPrivateLibrary *pl = port->pl; + + if (!port) + return (GP_ERROR_BAD_PARAMETERS); +@@ -1065,14 +1078,14 @@ gp_port_usb_find_device_by_class_lib(GPP + if (!class) + return GP_ERROR_BAD_PARAMETERS; + +- gp_nrofdevs = load_devicelist (port->pl->ctx); +- for (d = 0; d < gp_nrofdevs; d++) { ++ pl->nrofdevs = load_devicelist (port->pl); ++ for (d = 0; d < pl->nrofdevs; d++) { + struct libusb_config_descriptor *confdesc; + int i, ret, config = -1, interface = -1, altsetting = -1; + +- if (busnr && (busnr != libusb_get_bus_number (gp_devs[d]))) ++ if (busnr && (busnr != libusb_get_bus_number (pl->devs[d]))) + continue; +- if (devnr && (devnr != libusb_get_device_address (gp_devs[d]))) ++ if (devnr && (devnr != libusb_get_device_address (pl->devs[d]))) + continue; + + gp_log (GP_LOG_VERBOSE, "gphoto2-port-usb", +@@ -1080,17 +1093,17 @@ gp_port_usb_find_device_by_class_lib(GPP + "(class 0x%x, subclass, 0x%x, protocol 0x%x)...", + class, subclass, protocol); + +- ret = gp_port_usb_match_device_by_class(gp_devs[d], class, subclass, protocol, &config, &interface, &altsetting); ++ ret = gp_port_usb_match_device_by_class(pl->devs[d], class, subclass, protocol, &config, &interface, &altsetting); + if (!ret) + continue; + +- port->pl->d = gp_devs[d]; ++ port->pl->d = pl->devs[d]; + gp_log (GP_LOG_VERBOSE, "libusb1", + "Found USB class device " + "(class 0x%x, subclass, 0x%x, protocol 0x%x)", + class, subclass, protocol); + +- ret = libusb_get_config_descriptor (gp_devs[d], config, &confdesc); ++ ret = libusb_get_config_descriptor (pl->devs[d], config, &confdesc); + if (ret) continue; + + /* Set the defaults */ +@@ -1098,9 +1111,9 @@ gp_port_usb_find_device_by_class_lib(GPP + port->settings.usb.interface = confdesc->interface[interface].altsetting[altsetting].bInterfaceNumber; + port->settings.usb.altsetting = confdesc->interface[interface].altsetting[altsetting].bAlternateSetting; + +- port->settings.usb.inep = gp_port_usb_find_ep(gp_devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_BULK); +- port->settings.usb.outep = gp_port_usb_find_ep(gp_devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_OUT, LIBUSB_TRANSFER_TYPE_BULK); +- port->settings.usb.intep = gp_port_usb_find_ep(gp_devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_INTERRUPT); ++ port->settings.usb.inep = gp_port_usb_find_ep(pl->devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_BULK); ++ port->settings.usb.outep = gp_port_usb_find_ep(pl->devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_OUT, LIBUSB_TRANSFER_TYPE_BULK); ++ port->settings.usb.intep = gp_port_usb_find_ep(pl->devs[d], config, interface, altsetting, LIBUSB_ENDPOINT_IN, LIBUSB_TRANSFER_TYPE_INTERRUPT); + port->settings.usb.maxpacketsize = 0; + gp_log (GP_LOG_DEBUG, "libusb1", "inep to look for is %02x", port->settings.usb.inep); + for (i=0;iinterface[interface].altsetting[altsetting].bNumEndpoints;i++) { +@@ -1117,8 +1130,8 @@ gp_port_usb_find_device_by_class_lib(GPP + port->settings.usb.config, + port->settings.usb.interface, + port->settings.usb.altsetting, +- gp_descs[d].idVendor, +- gp_descs[d].idProduct, ++ pl->descs[d].idVendor, ++ pl->descs[d].idProduct, + port->settings.usb.inep, + port->settings.usb.outep, + port->settings.usb.intep