Remove the execution flag from non-executables
[platform/core/connectivity/mtp-responder.git] / include / transport / mtp_usb_driver.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef _MTP_USB_DRIVER_H_
18 #define _MTP_USB_DRIVER_H_
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include "mtp_config.h"
25 #include "mtp_datatype.h"
26 #include "mtp_msgq.h"
27
28 /* Start of driver related defines */
29 #define MTP_DRIVER_PATH                 "/dev/usb_mtp_gadget"
30
31 /* FunctionFS endpoint paths  */
32 #ifndef MTP_FFS_PATH
33 #define MTP_FFS_PATH "/dev/usb-funcs/mtp/default"
34 #endif
35 #define MTP_EP0_PATH       MTP_FFS_PATH "/ep0"
36 #define MTP_EP_IN_PATH     MTP_FFS_PATH "/ep1"
37 #define MTP_EP_OUT_PATH    MTP_FFS_PATH "/ep2"
38 #define MTP_EP_STATUS_PATH MTP_FFS_PATH "/ep3"
39
40 /* These values come from f_mtp_slp.h of kernel source */
41 #define MTP_IOCTL_LETTER                'Z'
42 #define MTP_GET_HIGH_FULL_SPEED         _IOR(MTP_IOCTL_LETTER, 1, int)
43 #define MTP_DISABLE                     _IO(MTP_IOCTL_LETTER, 2)
44 #define MTP_CLEAR_HALT                  _IO(MTP_IOCTL_LETTER, 3)
45 #define MTP_WRITE_INT_DATA              _IOW(MTP_IOCTL_LETTER, 4, char *)
46 #define MTP_SET_USER_PID                _IOW(MTP_IOCTL_LETTER, 5, int)
47 #define MTP_GET_SETUP_DATA              _IOR(MTP_IOCTL_LETTER, 6, char *)
48 #define MTP_SET_SETUP_DATA              _IOW(MTP_IOCTL_LETTER, 7, char *)
49 #define MTP_SEND_RESET_ACK              _IO(MTP_IOCTL_LETTER, 8)
50 #define MTP_SET_ZLP_DATA                _IO(MTP_IOCTL_LETTER, 9)
51 #define MTP_GET_MAX_PKT_SIZE            _IOR(MTP_IOCTL_LETTER, 22, void *)
52
53 #define SIG_SETUP                       44
54 /* End of driver related defines */
55
56 typedef struct mtp_max_pkt_size {
57         mtp_uint32 tx;
58         mtp_uint32 rx;
59 } mtp_max_pkt_size_t;
60
61 /* Transport driver interface */
62 typedef struct mtp_usb_driver {
63         mtp_bool (*transport_init_usb_device)(void);
64         void *(*transport_thread_fake_usb_read)(void *arg);
65         void *(*transport_thread_fake_usb_write)(void *arg);
66         void (*transport_deinit_usb_device)(void);
67         void *(*transport_thread_usb_write)(void *arg);
68         void *(*transport_thread_usb_read)(void *arg);
69         void *(*transport_thread_usb_control)(void *arg);
70         mtp_int32 (*transport_mq_init)(msgq_id_t *rx_ipc, msgq_id_t *tx_ipc);
71         mtp_bool (*transport_mq_deinit)(msgq_id_t *rx_ipc, msgq_id_t *tx_ipc);
72         mtp_uint32 (*transport_get_usb_packet_len)(void);
73         mtp_uint32 (*get_tx_pkt_size)(void);
74         mtp_uint32 (*get_rx_pkt_size)(void);
75 } mtp_usb_driver_t;
76
77 extern const mtp_usb_driver_t mtp_usb_driver_slp;
78 extern const mtp_usb_driver_t mtp_usb_driver_ffs;
79
80 typedef enum {
81         MTP_TRANSPORT_SLP = 0,
82         MTP_TRANSPORT_FFS,
83         MTP_TRANSPORT_NUMBER,   /* number of supported transports */
84         MTP_TRANSPORT_UNKNOWN,
85 } mtp_transport_type_t;
86
87 /* Maximum repeat count for USB error recovery */
88 #define MTP_USB_ERROR_MAX_RETRY         5
89
90 mtp_bool _transport_select_driver(void);
91 mtp_bool _transport_init_usb_device(void);
92 void _transport_deinit_usb_device(void);
93 void *_transport_thread_usb_write(void *arg);
94 void *_transport_thread_usb_read(void *arg);
95 void *_transport_thread_usb_control(void *arg);
96 mtp_int32 _transport_mq_init(msgq_id_t *rx_mqid, msgq_id_t *tx_mqid);
97 mtp_bool _transport_mq_deinit(msgq_id_t *rx_mqid, msgq_id_t *tx_mqid);
98 mtp_uint32 _transport_get_usb_packet_len(void);
99 mtp_uint32 _get_tx_pkt_size(void);
100 mtp_uint32 _get_rx_pkt_size(void);
101 mtp_transport_type_t _transport_get_type(void);
102
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif /* _MTP_USB_DRIVER_H_ */