2 * f_gadgetfs.h -- support file for f_gadgetfs.c
4 * Copyright (C) 2009 MCCI Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __F_GADGETFS_H__
22 #define __F_GADGETFS_H__
24 /* string id's are dynamically assigned */
26 #define GADGETFS_MANUFACTURER_IDX 2
27 #define GADGETFS_PRODUCT_IDX 1
28 #define GADGETFS_INTERFACE_IDX 0
30 #define GADGETFS_MANUFACTURER_IDX 0
31 #define GADGETFS_PRODUCT_IDX 1
32 #define GADGETFS_INTERFACE_IDX 2
35 #define GADGETFS_DRIVER_DESC "GadgetFS Function"
36 #define GADGETFS_DRIVER_VERSION "0.4"
39 #define GADGETFS_INTERFACE_ID 0
41 #define GADGETFS_INTERFACE_ID 2
44 /*-------------------------------------------------------------------------*/
48 /*-------------------------------------------------------------------------*/
50 struct gadgetfs_endpoint_descriptors {
51 struct usb_endpoint_descriptor *in;
52 struct usb_endpoint_descriptor *out;
53 struct usb_endpoint_descriptor *status;
56 /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */
57 static struct usb_string gadgetfs_string_defines[] = {
58 [GADGETFS_MANUFACTURER_IDX].s = "MCCI",
59 [GADGETFS_PRODUCT_IDX].s = "GadgetFS Composite Driver",
60 [GADGETFS_INTERFACE_IDX].s = "MTP Interface",
61 { }, /* end of list */
64 static struct usb_gadget_strings gadgetfs_string_table = {
65 .language = 0x0409, // en-us
66 .strings = gadgetfs_string_defines,
69 static struct usb_gadget_strings *gadgetfs_strings[] = {
70 &gadgetfs_string_table,
74 /* Control Interface Descriptor */
75 static struct usb_interface_descriptor gadgetfs_control_interface_descriptor __initdata = {
76 .bLength = sizeof(gadgetfs_control_interface_descriptor),
77 .bDescriptorType = USB_DT_INTERFACE,
79 .bInterfaceClass = USB_CLASS_STILL_IMAGE,
80 .bInterfaceSubClass = 1,
81 .bInterfaceProtocol = 1,
82 .iInterface = GADGETFS_INTERFACE_IDX,
85 /* High-Speed Support */
86 static struct usb_endpoint_descriptor gadgetfs_high_speed_ep_out_descriptor __initdata = {
87 .bLength = USB_DT_ENDPOINT_SIZE,
88 .bDescriptorType = USB_DT_ENDPOINT,
89 .bEndpointAddress = USB_DIR_OUT,
90 .bmAttributes = USB_ENDPOINT_XFER_BULK,
91 .wMaxPacketSize = cpu_to_le16(512),
94 static struct usb_endpoint_descriptor gadgetfs_high_speed_ep_in_descriptor __initdata = {
95 .bLength = USB_DT_ENDPOINT_SIZE,
96 .bDescriptorType = USB_DT_ENDPOINT,
97 .bEndpointAddress = USB_DIR_IN,
98 .bmAttributes = USB_ENDPOINT_XFER_BULK,
99 .wMaxPacketSize = cpu_to_le16(512),
103 static struct usb_endpoint_descriptor gadgetfs_high_speed_status_descriptor __initdata = {
104 .bLength = USB_DT_ENDPOINT_SIZE,
105 .bDescriptorType = USB_DT_ENDPOINT,
106 .bmAttributes = USB_ENDPOINT_XFER_INT,
107 .bEndpointAddress = USB_DIR_IN,
108 .wMaxPacketSize = __constant_cpu_to_le16 (8),//16+4),
112 static struct usb_descriptor_header *gadgetfs_high_speed_function[] __initdata = {
113 /* GadgetFS control descriptors */
114 (struct usb_descriptor_header *) &gadgetfs_control_interface_descriptor,
115 /* NOTE: status endpoint might need to be removed */
116 (struct usb_descriptor_header *) &gadgetfs_high_speed_status_descriptor,
117 (struct usb_descriptor_header *) &gadgetfs_high_speed_ep_in_descriptor,
118 (struct usb_descriptor_header *) &gadgetfs_high_speed_ep_out_descriptor,
122 /* Full-Speed Support */
123 static struct usb_endpoint_descriptor gadgetfs_full_speed_ep_in_descriptor __initdata = {
124 .bLength = USB_DT_ENDPOINT_SIZE,
125 .bDescriptorType = USB_DT_ENDPOINT,
126 .bEndpointAddress = USB_DIR_IN,
127 .bmAttributes = USB_ENDPOINT_XFER_BULK,
128 .wMaxPacketSize = __constant_cpu_to_le16 (64),
131 static struct usb_endpoint_descriptor gadgetfs_full_speed_ep_out_descriptor __initdata = {
132 .bLength = USB_DT_ENDPOINT_SIZE,
133 .bDescriptorType = USB_DT_ENDPOINT,
134 .bEndpointAddress = USB_DIR_OUT,
135 .bmAttributes = USB_ENDPOINT_XFER_BULK,
136 .wMaxPacketSize = __constant_cpu_to_le16 (64),
139 static struct usb_endpoint_descriptor gadgetfs_full_speed_status_descriptor __initdata = {
140 .bLength = USB_DT_ENDPOINT_SIZE,
141 .bDescriptorType = USB_DT_ENDPOINT,
142 .bEndpointAddress = USB_DIR_IN,
143 .bmAttributes = USB_ENDPOINT_XFER_INT,
144 .wMaxPacketSize = __constant_cpu_to_le16 (8),//16+4),
145 .bInterval = (1 << 5),
148 static struct usb_descriptor_header *gadgetfs_full_speed_function[] __initdata = {
149 /* GadgetFS control descriptors */
150 (struct usb_descriptor_header *) &gadgetfs_control_interface_descriptor,
151 /* NOTE: status endpoint might need to be removed */
152 (struct usb_descriptor_header *) &gadgetfs_full_speed_status_descriptor,
153 (struct usb_descriptor_header *) &gadgetfs_full_speed_ep_in_descriptor,
154 (struct usb_descriptor_header *) &gadgetfs_full_speed_ep_out_descriptor,
158 /* Internal data structure */
160 struct usb_function function;
161 struct usb_composite_dev *cdev; /* unused */
162 struct usb_gadget *gadget; /* unused */ /* copy of cdev->gadget */
163 struct usb_ep *ep_in;
164 struct usb_ep *ep_out;
165 struct usb_ep *ep_int;
167 struct gadgetfs_endpoint_descriptors full_speed_descriptor, high_speed_descriptor;
173 /*-------------------------------------------------------------------------*/
175 struct f_gadgetfs *the_gadget = NULL;
177 /*-------------------------------------------------------------------------*/
179 #endif /* __F_GADGETFS_H__ */