Mike Lockwood | ba83b01 | 2010-04-16 10:39:22 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
Mike Lockwood | ce4022b | 2011-07-14 19:42:42 -0400 | [diff] [blame] | 21 | #include <linux/ioctl.h> |
| 22 | |
| 23 | #ifdef __KERNEL__ |
| 24 | |
| 25 | struct 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__ */ |
Mike Lockwood | ba83b01 | 2010-04-16 10:39:22 -0400 | [diff] [blame] | 37 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | /* Constants for MTP_SET_INTERFACE_MODE */ |
| 39 | #define MTP_INTERFACE_MODE_MTP 0 |
| 40 | #define MTP_INTERFACE_MODE_PTP 1 |
| 41 | |
| 42 | |
Mike Lockwood | ba83b01 | 2010-04-16 10:39:22 -0400 | [diff] [blame] | 43 | struct mtp_file_range { |
| 44 | /* file descriptor for file to transfer */ |
| 45 | int fd; |
| 46 | /* offset in file for start of transfer */ |
| 47 | loff_t offset; |
| 48 | /* number of bytes to transfer */ |
Mike Lockwood | 3e800b6 | 2010-11-16 17:14:32 -0500 | [diff] [blame] | 49 | int64_t length; |
Mike Lockwood | ce4022b | 2011-07-14 19:42:42 -0400 | [diff] [blame] | 50 | /* MTP command ID for data header, |
| 51 | * used only for MTP_SEND_FILE_WITH_HEADER |
| 52 | */ |
| 53 | uint16_t command; |
| 54 | /* MTP transaction ID for data header, |
| 55 | * used only for MTP_SEND_FILE_WITH_HEADER |
| 56 | */ |
| 57 | uint32_t transaction_id; |
Mike Lockwood | ba83b01 | 2010-04-16 10:39:22 -0400 | [diff] [blame] | 58 | }; |
| 59 | |
Mike Lockwood | 1de4d4d | 2010-07-06 19:27:52 -0400 | [diff] [blame] | 60 | struct mtp_event { |
| 61 | /* size of the event */ |
| 62 | size_t length; |
| 63 | /* event data to send */ |
| 64 | void *data; |
| 65 | }; |
| 66 | |
Mike Lockwood | ba83b01 | 2010-04-16 10:39:22 -0400 | [diff] [blame] | 67 | /* Sends the specified file range to the host */ |
| 68 | #define MTP_SEND_FILE _IOW('M', 0, struct mtp_file_range) |
| 69 | /* Receives data from the host and writes it to a file. |
| 70 | * The file is created if it does not exist. |
| 71 | */ |
| 72 | #define MTP_RECEIVE_FILE _IOW('M', 1, struct mtp_file_range) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | /* Sets the driver mode to either MTP or PTP */ |
| 74 | #define MTP_SET_INTERFACE_MODE _IOW('M', 2, int) |
Mike Lockwood | 1de4d4d | 2010-07-06 19:27:52 -0400 | [diff] [blame] | 75 | /* Sends an event to the host via the interrupt endpoint */ |
| 76 | #define MTP_SEND_EVENT _IOW('M', 3, struct mtp_event) |
Mike Lockwood | ce4022b | 2011-07-14 19:42:42 -0400 | [diff] [blame] | 77 | /* Sends the specified file range to the host, |
| 78 | * with a 12 byte MTP data packet header at the beginning. |
| 79 | */ |
| 80 | #define MTP_SEND_FILE_WITH_HEADER _IOW('M', 4, struct mtp_file_range) |
Mike Lockwood | ba83b01 | 2010-04-16 10:39:22 -0400 | [diff] [blame] | 81 | |
| 82 | #endif /* __LINUX_USB_F_MTP_H */ |