Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: src/libopenusb1-glue.c

Issue 11358153: Update libmtp from pre 1.1.4 git to 1.1.5 release. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libmtp/
Patch Set: disable mptz Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * \file libusb1-glue.c 2 * \file libusb1-glue.c
3 * Low-level USB interface glue towards libusb. 3 * Low-level USB interface glue towards libusb.
4 * 4 *
5 * Copyright (C) 2005-2007 Richard A. Low <richard@wentnet.com> 5 * Copyright (C) 2005-2007 Richard A. Low <richard@wentnet.com>
6 * Copyright (C) 2005-2011 Linus Walleij <triad@df.lth.se> 6 * Copyright (C) 2005-2012 Linus Walleij <triad@df.lth.se>
7 * Copyright (C) 2006-2011 Marcus Meissner 7 * Copyright (C) 2006-2011 Marcus Meissner
8 * Copyright (C) 2007 Ted Bullock 8 * Copyright (C) 2007 Ted Bullock
9 * Copyright (C) 2008 Chris Bagwell <chris@cnpbagwell.com> 9 * Copyright (C) 2008 Chris Bagwell <chris@cnpbagwell.com>
10 * 10 *
11 * This library is free software; you can redistribute it and/or 11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public 12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This library is distributed in the hope that it will be useful, 16 * This library is distributed in the hope that it will be useful,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 static const LIBMTP_device_entry_t mtp_device_table[] = { 86 static const LIBMTP_device_entry_t mtp_device_table[] = {
87 /* We include an .h file which is shared between us and libgphoto2 */ 87 /* We include an .h file which is shared between us and libgphoto2 */
88 #include "music-players.h" 88 #include "music-players.h"
89 }; 89 };
90 static const int mtp_device_table_size = sizeof (mtp_device_table) / sizeof (LIB MTP_device_entry_t); 90 static const int mtp_device_table_size = sizeof (mtp_device_table) / sizeof (LIB MTP_device_entry_t);
91 91
92 // Local functions 92 // Local functions
93 static void init_usb(); 93 static void init_usb();
94 static void close_usb(PTP_USB* ptp_usb); 94 static void close_usb(PTP_USB* ptp_usb);
95 static int find_interface_and_endpoints(openusb_dev_handle_t *dev, 95 static int find_interface_and_endpoints(openusb_dev_handle_t *dev,
96 uint8_t *conf,
96 uint8_t *interface, 97 uint8_t *interface,
98 uint8_t *altsetting,
97 int* inep, 99 int* inep,
98 int* inep_maxpacket, 100 int* inep_maxpacket,
99 int* outep, 101 int* outep,
100 int* outep_maxpacket, 102 int* outep_maxpacket,
101 int* intep); 103 int* intep);
102 static void clear_stall(PTP_USB* ptp_usb); 104 static void clear_stall(PTP_USB* ptp_usb);
103 static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, openusb_dev_handle_ t * dev); 105 static int init_ptp_usb(PTPParams* params, PTP_USB* ptp_usb, openusb_dev_handle_ t * dev);
104 static short ptp_write_func(unsigned long, PTPDataHandler*, void *data, unsigned long*); 106 static short ptp_write_func(unsigned long, PTPDataHandler*, void *data, unsigned long*);
105 static short ptp_read_func(unsigned long, PTPDataHandler*, void *data, unsigned long*, int); 107 static short ptp_read_func(unsigned long, PTPDataHandler*, void *data, unsigned long*, int);
106 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status); 108 static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status);
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 */ 1943 */
1942 openusb_reset(*ptp_usb->handle); 1944 openusb_reset(*ptp_usb->handle);
1943 } 1945 }
1944 openusb_close_device(*ptp_usb->handle); 1946 openusb_close_device(*ptp_usb->handle);
1945 } 1947 }
1946 1948
1947 /** 1949 /**
1948 * Self-explanatory? 1950 * Self-explanatory?
1949 */ 1951 */
1950 static int find_interface_and_endpoints(openusb_dev_handle_t *dev, 1952 static int find_interface_and_endpoints(openusb_dev_handle_t *dev,
1953 uint8_t *conf,
1951 uint8_t *interface, 1954 uint8_t *interface,
1955 uint8_t *altsetting,
1952 int* inep, 1956 int* inep,
1953 int* inep_maxpacket, 1957 int* inep_maxpacket,
1954 int* outep, 1958 int* outep,
1955 int *outep_maxpacket, 1959 int *outep_maxpacket,
1956 int* intep) { 1960 int* intep) {
1957 int i, ret; 1961 uint8_t i;
1962 int ret;
1958 struct usb_device_desc desc; 1963 struct usb_device_desc desc;
1959 1964
1960 ret = openusb_parse_device_desc(libmtp_openusb_handle, *dev, NULL, 0, &desc) ; 1965 ret = openusb_parse_device_desc(libmtp_openusb_handle, *dev, NULL, 0, &desc) ;
1961 if (ret != OPENUSB_SUCCESS) return -1; 1966 if (ret != OPENUSB_SUCCESS) return -1;
1962 1967
1963 // Loop over the device configurations 1968 // Loop over the device configurations
1964 for (i = 0; i < desc.bNumConfigurations; i++) { 1969 for (i = 0; i < desc.bNumConfigurations; i++) {
1965 uint8_t j; 1970 uint8_t j;
1966 struct usb_config_desc config; 1971 struct usb_config_desc config;
1967 1972
1968 ret = openusb_parse_config_desc(libmtp_openusb_handle, *dev, NULL, 0, i, &config); 1973 ret = openusb_parse_config_desc(libmtp_openusb_handle, *dev, NULL, 0, i, &config);
1969 if (ret != OPENUSB_SUCCESS) continue; 1974 if (ret != OPENUSB_SUCCESS) continue;
1975 *conf = desc.bConfigurationValue;
1970 // Loop over each configurations interfaces 1976 // Loop over each configurations interfaces
1971 for (j = 0; j < config.bNumInterfaces; j++) { 1977 for (j = 0; j < config.bNumInterfaces; j++) {
1972 uint8_t k; 1978 uint8_t k;
1973 uint8_t no_ep; 1979 uint8_t no_ep;
1974 int found_inep = 0; 1980 int found_inep = 0;
1975 int found_outep = 0; 1981 int found_outep = 0;
1976 int found_intep = 0; 1982 int found_intep = 0;
1977 struct usb_endpoint_desc ep; 1983 struct usb_endpoint_desc ep;
1978 struct usb_interface_desc ifcdesc; 1984 struct usb_interface_desc ifcdesc;
1979 openusb_parse_interface_desc(libmtp_openusb_handle, *dev, NULL, 0, i , j, 0, &ifcdesc); 1985 openusb_parse_interface_desc(libmtp_openusb_handle, *dev, NULL, 0, i , j, 0, &ifcdesc);
1980 // MTP devices shall have 3 endpoints, ignore those interfaces 1986 // MTP devices shall have 3 endpoints, ignore those interfaces
1981 // that haven't. 1987 // that haven't.
1982 no_ep = ifcdesc.bNumEndpoints; 1988 no_ep = ifcdesc.bNumEndpoints;
1983 if (no_ep != 3) 1989 if (no_ep != 3)
1984 continue; 1990 continue;
1985 *interface = ifcdesc.bInterfaceNumber; 1991 *interface = ifcdesc.bInterfaceNumber;
1992 *altsetting = ifcdesc.bAlternateSetting;
1986 // Loop over the three endpoints to locate two bulk and 1993 // Loop over the three endpoints to locate two bulk and
1987 // one interrupt endpoint and FAIL if we cannot, and continue. 1994 // one interrupt endpoint and FAIL if we cannot, and continue.
1988 for (k = 0; k < no_ep; k++) { 1995 for (k = 0; k < no_ep; k++) {
1989 openusb_parse_endpoint_desc(libmtp_openusb_handle, *dev, NULL, 0 , i, j, 0, k, &ep); 1996 openusb_parse_endpoint_desc(libmtp_openusb_handle, *dev, NULL, 0 , i, j, 0, k, &ep);
1990 if (ep.bmAttributes == USB_ENDPOINT_TYPE_BULK) { 1997 if (ep.bmAttributes == USB_ENDPOINT_TYPE_BULK) {
1991 if ((ep.bEndpointAddress & USB_ENDPOINT_DIR_MASK) == 1998 if ((ep.bEndpointAddress & USB_ENDPOINT_DIR_MASK) ==
1992 USB_ENDPOINT_DIR_MASK) { 1999 USB_ENDPOINT_DIR_MASK) {
1993 *inep = ep.bEndpointAddress; 2000 *inep = ep.bEndpointAddress;
1994 *inep_maxpacket = ep.wMaxPacketSize; 2001 *inep_maxpacket = ep.wMaxPacketSize;
1995 found_inep = 1; 2002 found_inep = 1;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 * to work. 2087 * to work.
2081 */ 2088 */
2082 if (FLAG_ALWAYS_PROBE_DESCRIPTOR(ptp_usb)) { 2089 if (FLAG_ALWAYS_PROBE_DESCRIPTOR(ptp_usb)) {
2083 // Massage the device descriptor 2090 // Massage the device descriptor
2084 (void) probe_device_descriptor(ldevice, NULL); 2091 (void) probe_device_descriptor(ldevice, NULL);
2085 } 2092 }
2086 2093
2087 2094
2088 /* Assign interface and endpoints to usbinfo... */ 2095 /* Assign interface and endpoints to usbinfo... */
2089 err = find_interface_and_endpoints(ldevice, 2096 err = find_interface_and_endpoints(ldevice,
2097 &ptp_usb->conf,
2090 &ptp_usb->interface, 2098 &ptp_usb->interface,
2099 &ptp_usb->altsetting,
2091 &ptp_usb->inep, 2100 &ptp_usb->inep,
2092 &ptp_usb->inep_maxpacket, 2101 &ptp_usb->inep_maxpacket,
2093 &ptp_usb->outep, 2102 &ptp_usb->outep,
2094 &ptp_usb->outep_maxpacket, 2103 &ptp_usb->outep_maxpacket,
2095 &ptp_usb->intep); 2104 &ptp_usb->intep);
2096 2105
2097 if (err) { 2106 if (err) {
2098 openusb_free_devid_list(devs); 2107 openusb_free_devid_list(devs);
2099 LIBMTP_ERROR("LIBMTP PANIC: Unable to find interface & endpoints of devi ce\n"); 2108 LIBMTP_ERROR("LIBMTP PANIC: Unable to find interface & endpoints of devi ce\n");
2100 return LIBMTP_ERROR_CONNECTING; 2109 return LIBMTP_ERROR_CONNECTING;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 ctrl.timeout = ptp_usb->timeout; 2220 ctrl.timeout = ptp_usb->timeout;
2212 ctrl.next = NULL; 2221 ctrl.next = NULL;
2213 ctrl.setup.bRequest = USB_REQ_GET_STATUS; 2222 ctrl.setup.bRequest = USB_REQ_GET_STATUS;
2214 ctrl.setup.bmRequestType = USB_ENDPOINT_IN | USB_RECIP_ENDPOINT; 2223 ctrl.setup.bmRequestType = USB_ENDPOINT_IN | USB_RECIP_ENDPOINT;
2215 ctrl.setup.wIndex = ep; 2224 ctrl.setup.wIndex = ep;
2216 ctrl.setup.wValue = USB_FEATURE_HALT; 2225 ctrl.setup.wValue = USB_FEATURE_HALT;
2217 openusb_ctrl_xfer(*ptp_usb->handle, ptp_usb->interface, ep, &ctrl); 2226 openusb_ctrl_xfer(*ptp_usb->handle, ptp_usb->interface, ep, &ctrl);
2218 return ctrl.result.status; 2227 return ctrl.result.status;
2219 2228
2220 } 2229 }
OLDNEW
« config.h ('K') | « src/libmtp.h.in ('k') | src/libusb-glue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698