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 _PTP_CONTAINER_H_
18 #define _PTP_CONTAINER_H_
20 #include "mtp_datatype.h"
22 #define MAX_MTP_PARAMS 5
23 #define MTP_USB_HEADER_LENGTH 12
26 CONTAINER_UNDEFINED = 0x00,
34 * A generic USB container header.
37 mtp_uint32 len; /* the valid container size in BYTES */
38 mtp_uint16 type; /* Container type */
39 mtp_uint16 code; /* Operation, response or Event code */
40 mtp_uint32 tid; /* host generated transaction id */
44 * A generic USB container.
47 mtp_uint32 len; /* the valid container size in BYTES */
48 mtp_uint16 type; /* Container type */
49 mtp_uint16 code; /* Operation, response or Event code */
50 mtp_uint32 tid; /* host generated transaction id */
51 mtp_uint32 params[MAX_MTP_PARAMS];
56 * A USB container for sending data.
59 mtp_uint32 len; /* the valid container size in BYTES */
60 mtp_uint16 type; /* Container type */
61 mtp_uint16 code; /* Operation, response or Event code */
62 mtp_uint32 tid; /* host generated transaction id */
63 mtp_uint32 params[MAX_MTP_PARAMS];
68 typedef cmd_container_t cmd_blk_t;
69 typedef cmd_container_t resp_blk_t;
70 typedef data_container_t data_blk_t;
72 void _hdlr_init_cmd_container(cmd_container_t *cntr);
73 mtp_uint32 _hdlr_get_param_cmd_container(cmd_container_t *cntr,
75 void _hdlr_copy_cmd_container_unknown_params(cmd_container_t *src,
76 cmd_container_t *dst);
77 void _hdlr_copy_cmd_container(cmd_container_t *src, cmd_container_t *dst);
78 mtp_bool _hdlr_add_param_resp_container(resp_blk_t *dst, mtp_uint32 num,
80 mtp_bool _hdlr_validate_cmd_container(mtp_uchar *blk, mtp_uint32 size);
81 void _hdlr_init_data_container(data_container_t *dst, mtp_uint16 code,
83 mtp_uchar *_hdlr_alloc_buf_data_container(data_container_t *dst,
84 mtp_uint32 bufsz, mtp_uint64 pkt_size);
85 mtp_bool _hdlr_send_data_container(data_container_t *dst);
86 mtp_bool _hdlr_send_bulk_data(mtp_uchar *dst, mtp_uint32 len);
87 mtp_bool _hdlr_rcv_data_container(data_container_t *dst, mtp_uint32 size);
88 mtp_bool _hdlr_rcv_file_in_data_container(data_container_t *dst,
89 mtp_char *filepath, mtp_uint32 path_len);
90 mtp_uint32 _hdlr_get_payload_size(data_container_t *dst);
91 mtp_uchar *_hdlr_get_payload_data(data_container_t *dst);
92 void _hdlr_resp_container_init(cmd_container_t *dst, mtp_uint16 resp_code,
94 mtp_bool _hdlr_send_resp_container(cmd_container_t *dst);
95 void _hdlr_init_event_container(cmd_container_t *dst, mtp_uint16 code,
96 mtp_uint32 tid, mtp_uint32 param1, mtp_uint32 param2);
97 void _hdlr_init_event_container_with_param(cmd_container_t *dst,
98 mtp_uint16 code, mtp_uint32 tid, mtp_uint32 param1, mtp_uint32 param2);
99 mtp_bool _hdlr_send_event_container(cmd_container_t *dst);
100 void _hdlr_conv_cmd_container_byte_order(cmd_container_t *dst);
101 void _hdlr_conv_data_container_byte_order(data_container_t *dst);
103 #endif /* _PTP_CONTAINER_H_ */