blob: 72a432e2fcdd66ca0cd89b7fc84e174c4c38c3b4 [file] [log] [blame]
Benoit Gobyf0fbc482011-12-19 14:37:50 -08001/*
2 * Gadget Function Driver for MTP
3 *
4 * Copyright (C) 2010 Google, Inc.
5 * Author: Mike Lockwood <lockwood@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
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.
15 *
16 */
17
18#ifndef __LINUX_USB_F_MTP_H
19#define __LINUX_USB_F_MTP_H
20
21#include <linux/ioctl.h>
22
23#ifdef __KERNEL__
24
25struct mtp_data_header {
26 /* length of packet, including this header */
27 uint32_t length;
28 /* container type (2 for data packet) */
29 uint16_t type;
30 /* MTP command code */
31 uint16_t command;
32 /* MTP transaction ID */
33 uint32_t transaction_id;
34};
35
36#endif /* __KERNEL__ */
37
38struct mtp_file_range {
39 /* file descriptor for file to transfer */
40 int fd;
41 /* offset in file for start of transfer */
42 loff_t offset;
43 /* number of bytes to transfer */
44 int64_t length;
45 /* MTP command ID for data header,
46 * used only for MTP_SEND_FILE_WITH_HEADER
47 */
48 uint16_t command;
49 /* MTP transaction ID for data header,
50 * used only for MTP_SEND_FILE_WITH_HEADER
51 */
52 uint32_t transaction_id;
53};
54
55struct mtp_event {
56 /* size of the event */
57 size_t length;
58 /* event data to send */
59 void *data;
60};
61
62/* Sends the specified file range to the host */
63#define MTP_SEND_FILE _IOW('M', 0, struct mtp_file_range)
64/* Receives data from the host and writes it to a file.
65 * The file is created if it does not exist.
66 */
67#define MTP_RECEIVE_FILE _IOW('M', 1, struct mtp_file_range)
68/* Sends an event to the host via the interrupt endpoint */
69#define MTP_SEND_EVENT _IOW('M', 3, struct mtp_event)
70/* Sends the specified file range to the host,
71 * with a 12 byte MTP data packet header at the beginning.
72 */
73#define MTP_SEND_FILE_WITH_HEADER _IOW('M', 4, struct mtp_file_range)
74
75#endif /* __LINUX_USB_F_MTP_H */