Deleted Added
sdiff udiff text old ( 246122 ) new ( 246123 )
full compact
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_mtp.c 246122 2013-01-30 15:26:04Z 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>
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
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
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] = {
249 [STRING_LANG_INDEX] = &string_lang,
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) {
271 return (&string_lang);
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}