Home | History | Annotate | Download | only in usb
      1 /*
      2  * Gadget Function Driver for MTP
      3  *
      4  * Copyright (C) 2010 Google, Inc.
      5  * Author: Mike Lockwood <lockwood (at) 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 #ifdef __KERNEL__
     22 
     23 struct mtp_data_header {
     24 	/* length of packet, including this header */
     25 	uint32_t	length;
     26 	/* container type (2 for data packet) */
     27 	uint16_t	type;
     28 	/* MTP command code */
     29 	uint16_t    command;
     30 	/* MTP transaction ID */
     31 	uint32_t	transaction_id;
     32 };
     33 
     34 #endif /* __KERNEL__ */
     35 
     36 struct mtp_file_range {
     37 	/* file descriptor for file to transfer */
     38 	int			fd;
     39 	/* offset in file for start of transfer */
     40 	loff_t  	offset;
     41 	/* number of bytes to transfer */
     42 	int64_t		length;
     43 	/* MTP command ID for data header,
     44 	 * used only for MTP_SEND_FILE_WITH_HEADER
     45 	 */
     46 	uint16_t	command;
     47 	/* MTP transaction ID for data header,
     48 	 * used only for MTP_SEND_FILE_WITH_HEADER
     49 	 */
     50 	uint32_t	transaction_id;
     51 };
     52 
     53 struct mtp_event {
     54 	/* size of the event */
     55 	size_t		length;
     56 	/* event data to send */
     57 	void  		*data;
     58 };
     59 
     60 /* Sends the specified file range to the host */
     61 #define MTP_SEND_FILE              _IOW('M', 0, struct mtp_file_range)
     62 /* Receives data from the host and writes it to a file.
     63  * The file is created if it does not exist.
     64  */
     65 #define MTP_RECEIVE_FILE           _IOW('M', 1, struct mtp_file_range)
     66 /* Sends an event to the host via the interrupt endpoint */
     67 #define MTP_SEND_EVENT             _IOW('M', 3, struct mtp_event)
     68 /* Sends the specified file range to the host,
     69  * with a 12 byte MTP data packet header at the beginning.
     70  */
     71 #define MTP_SEND_FILE_WITH_HEADER  _IOW('M', 4, struct mtp_file_range)
     72 
     73 #endif /* __LINUX_USB_F_MTP_H */
     74