Deleted Added
full compact
usb_template_mtp.c (246122) usb_template_mtp.c (246123)
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_mtp.c 246122 2013-01-30 15:26:04Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_mtp.c 246123 2013-01-30 15:46:26Z hselasky $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright

--- 45 unchanged lines hidden (view full) ---

55#include <sys/sx.h>
56#include <sys/unistd.h>
57#include <sys/callout.h>
58#include <sys/malloc.h>
59#include <sys/priv.h>
60
61#include <dev/usb/usb.h>
62#include <dev/usb/usbdi.h>
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright

--- 45 unchanged lines hidden (view full) ---

55#include <sys/sx.h>
56#include <sys/unistd.h>
57#include <sys/callout.h>
58#include <sys/malloc.h>
59#include <sys/priv.h>
60
61#include <dev/usb/usb.h>
62#include <dev/usb/usbdi.h>
63#include <dev/usb/usb_core.h>
64
63#include <dev/usb/template/usb_template.h>
64#endif /* USB_GLOBAL_INCLUDE_FILE */
65
66#define MTP_BREQUEST 0x08
67
68enum {
69 STRING_LANG_INDEX,
70 STRING_MTP_DATA_INDEX,
71 STRING_MTP_CONFIG_INDEX,
72 STRING_MTP_VENDOR_INDEX,
73 STRING_MTP_PRODUCT_INDEX,
74 STRING_MTP_SERIAL_INDEX,
75 STRING_MTP_MAX,
76};
77
65#include <dev/usb/template/usb_template.h>
66#endif /* USB_GLOBAL_INCLUDE_FILE */
67
68#define MTP_BREQUEST 0x08
69
70enum {
71 STRING_LANG_INDEX,
72 STRING_MTP_DATA_INDEX,
73 STRING_MTP_CONFIG_INDEX,
74 STRING_MTP_VENDOR_INDEX,
75 STRING_MTP_PRODUCT_INDEX,
76 STRING_MTP_SERIAL_INDEX,
77 STRING_MTP_MAX,
78};
79
78#define STRING_LANG \
79 0x09, 0x04, /* American English */
80
81#define STRING_MTP_DATA \
82 'U', 0, 'S', 0, 'B', 0, ' ', 0, \
83 'M', 0, 'T', 0, 'P', 0, \
84 ' ', 0, 'I', 0, 'n', 0, 't', 0, \
85 'e', 0, 'r', 0, 'f', 0, 'a', 0, \
86 'c', 0, 'e', 0,
87
88#define STRING_MTP_CONFIG \

--- 15 unchanged lines hidden (view full) ---

104
105#define STRING_MTP_SERIAL \
106 'J', 0, 'u', 0, 'n', 0, 'e', 0, \
107 ' ', 0, '2', 0, '0', 0, '0', 0, \
108 '8', 0,
109
110/* make the real string descriptors */
111
80#define STRING_MTP_DATA \
81 'U', 0, 'S', 0, 'B', 0, ' ', 0, \
82 'M', 0, 'T', 0, 'P', 0, \
83 ' ', 0, 'I', 0, 'n', 0, 't', 0, \
84 'e', 0, 'r', 0, 'f', 0, 'a', 0, \
85 'c', 0, 'e', 0,
86
87#define STRING_MTP_CONFIG \

--- 15 unchanged lines hidden (view full) ---

103
104#define STRING_MTP_SERIAL \
105 'J', 0, 'u', 0, 'n', 0, 'e', 0, \
106 ' ', 0, '2', 0, '0', 0, '0', 0, \
107 '8', 0,
108
109/* make the real string descriptors */
110
112USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
113USB_MAKE_STRING_DESC(STRING_MTP_DATA, string_mtp_data);
114USB_MAKE_STRING_DESC(STRING_MTP_CONFIG, string_mtp_config);
115USB_MAKE_STRING_DESC(STRING_MTP_VENDOR, string_mtp_vendor);
116USB_MAKE_STRING_DESC(STRING_MTP_PRODUCT, string_mtp_product);
117USB_MAKE_STRING_DESC(STRING_MTP_SERIAL, string_mtp_serial);
118
119/* prototypes */
120

--- 120 unchanged lines hidden (view full) ---

241 * Return values:
242 * NULL: Failure. No such string.
243 * Else: Success. Pointer to string descriptor is returned.
244 *------------------------------------------------------------------------*/
245static const void *
246mtp_get_string_desc(uint16_t lang_id, uint8_t string_index)
247{
248 static const void *ptr[STRING_MTP_MAX] = {
111USB_MAKE_STRING_DESC(STRING_MTP_DATA, string_mtp_data);
112USB_MAKE_STRING_DESC(STRING_MTP_CONFIG, string_mtp_config);
113USB_MAKE_STRING_DESC(STRING_MTP_VENDOR, string_mtp_vendor);
114USB_MAKE_STRING_DESC(STRING_MTP_PRODUCT, string_mtp_product);
115USB_MAKE_STRING_DESC(STRING_MTP_SERIAL, string_mtp_serial);
116
117/* prototypes */
118

--- 120 unchanged lines hidden (view full) ---

239 * Return values:
240 * NULL: Failure. No such string.
241 * Else: Success. Pointer to string descriptor is returned.
242 *------------------------------------------------------------------------*/
243static const void *
244mtp_get_string_desc(uint16_t lang_id, uint8_t string_index)
245{
246 static const void *ptr[STRING_MTP_MAX] = {
249 [STRING_LANG_INDEX] = &string_lang,
247 [STRING_LANG_INDEX] = &usb_string_lang_en,
250 [STRING_MTP_DATA_INDEX] = &string_mtp_data,
251 [STRING_MTP_CONFIG_INDEX] = &string_mtp_config,
252 [STRING_MTP_VENDOR_INDEX] = &string_mtp_vendor,
253 [STRING_MTP_PRODUCT_INDEX] = &string_mtp_product,
254 [STRING_MTP_SERIAL_INDEX] = &string_mtp_serial,
255 };
256
257 static const uint8_t dummy_desc[0x12] = {

--- 5 unchanged lines hidden (view full) ---

263 if (string_index == 0xEE) {
264 /*
265 * By returning this string LibMTP will automatically
266 * pickup our device.
267 */
268 return (dummy_desc);
269 }
270 if (string_index == 0) {
248 [STRING_MTP_DATA_INDEX] = &string_mtp_data,
249 [STRING_MTP_CONFIG_INDEX] = &string_mtp_config,
250 [STRING_MTP_VENDOR_INDEX] = &string_mtp_vendor,
251 [STRING_MTP_PRODUCT_INDEX] = &string_mtp_product,
252 [STRING_MTP_SERIAL_INDEX] = &string_mtp_serial,
253 };
254
255 static const uint8_t dummy_desc[0x12] = {

--- 5 unchanged lines hidden (view full) ---

261 if (string_index == 0xEE) {
262 /*
263 * By returning this string LibMTP will automatically
264 * pickup our device.
265 */
266 return (dummy_desc);
267 }
268 if (string_index == 0) {
271 return (&string_lang);
269 return (&usb_string_lang_en);
272 }
273 if (lang_id != 0x0409) {
274 return (NULL);
275 }
276 if (string_index < STRING_MTP_MAX) {
277 return (ptr[string_index]);
278 }
279 return (NULL);
280}
270 }
271 if (lang_id != 0x0409) {
272 return (NULL);
273 }
274 if (string_index < STRING_MTP_MAX) {
275 return (ptr[string_index]);
276 }
277 return (NULL);
278}