2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _MTP_CMD_HANDLER_H_
18 #define _MTP_CMD_HANDLER_H_
20 #include "mtp_object.h"
21 #include "mtp_device.h"
22 #include "ptp_container.h"
23 #include "mtp_event_handler.h"
25 #ifdef MTP_SUPPORT_PRINT_COMMAND
26 #define MTP_MAX_CMD_LENGTH 40
27 #endif /* MTP_SUPPORT_PRINT_COMMAND */
30 * A structure for containing the object infomation. It is used for saving
31 * information in between paired operations like send_obj_info
36 mtp_uint32 store_id; /* The storage ID. */
37 mtp_uint32 h_parent; /* Handle of the parent object */
38 /* Reserved Handle for the incoming object. */
39 mtp_uint32 obj_handle;
40 /* Indicates if the ObjectInfo dataset is valid. */
42 mtp_bool is_data_sent; /* Indicates whether data was actually sent */
44 mtp_obj_t *obj; /* Object containing info for SendObject */
45 } data_4send_object_t;
48 * A structure for handling the operations of the MTP protocol.
49 * It is the main driving structure behind the MTP protocol handling. The
50 * MTP device contains device information and other data buffers.
57 cmd_container_t usb_cmd; /* A USB command container block. */
58 /* Data saved during paired operations: SendObjectInfo/SendObject. */
59 data_4send_object_t data4_send_obj;
60 mtp_uint32 session_id; /* Current session ID. */
61 mtp_uint32 last_opcode; /* Current transaction ID. */
62 mtp_uint16 last_fmt_code; /* Last Format Code */
66 mtp_uint32 recent_tid;
72 * This structure specifies the buffer of Mtp.
75 mtp_char cmd_buf[MTP_MAX_CMD_BLOCK_SIZE];
76 mtp_char header_buf[MTP_USB_HEADER_LENGTH];
79 mtp_uint32 data_count;
80 FILE* fhandle; /* for temporary mtp file */
83 mtp_uint32 size_remaining;
84 /* PC-> Device file transfer user space buffering till 512K*/
89 temp_file_struct_t ftemp_st;
91 wmp_meta_info_t meta_info;
94 void _cmd_hdlr_reset_cmd(mtp_handler_t *hdlr);
95 mtp_bool _cmd_hdlr_send_response(mtp_handler_t *hdlr, mtp_uint16 resp,
96 mtp_uint32 num_param, mtp_uint32 *params);
97 mtp_bool _cmd_hdlr_send_response_code(mtp_handler_t *hdlr, mtp_uint16 resp);
98 void _receive_mq_data_cb(mtp_char *buffer, mtp_int32 buf_len);
100 #endif /* _MTP_CMD_HANDLER_H_ */