1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | /* |
29 | * CEC service command enumeration and parameter types. |
30 | */ |
31 | |
32 | /** |
33 | * \file |
34 | * This file contains definition shared by host side and |
35 | * Videocore side CEC service: |
36 | * |
37 | * In general, a zero return value indicates success of the function |
38 | * A non-zero value indicates VCHI error |
39 | * A positive value indicates alternative return value (for some functions). |
40 | * |
41 | */ |
42 | |
43 | |
44 | #ifndef _VC_CECSERVICE_DEFS_H_ |
45 | #define _VC_CECSERVICE_DEFS_H_ |
46 | #include "vcinclude/common.h" |
47 | #include "interface/vcos/vcos.h" |
48 | #include "interface/vcos/vcos_logging.h" |
49 | #include "interface/vchi/message_drivers/message.h" |
50 | |
51 | //CEC VCOS logging stuff |
52 | #define CECHOST_LOG_CATEGORY (&cechost_log_category) |
53 | #define vc_cec_log_trace(...) _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_TRACE, __VA_ARGS__) |
54 | #define vc_cec_log_warn(...) _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_WARN, __VA_ARGS__) |
55 | #define vc_cec_log_error(...) _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_ERROR, __VA_ARGS__) |
56 | #define vc_cec_log_info(...) _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_INFO, __VA_ARGS__) |
57 | extern VCOS_LOG_CAT_T cechost_log_category; //The actual object lives in CEC host side service code |
58 | |
59 | #define VC_CECSERVICE_VER 1 |
60 | #define CECSERVICE_MSGFIFO_SIZE 1024 |
61 | #define CECSERVICE_CLIENT_NAME MAKE_FOURCC("CECS") |
62 | #define CECSERVICE_NOTIFY_NAME MAKE_FOURCC("CECN") |
63 | |
64 | //CEC service commands |
65 | typedef enum { |
66 | VC_CEC_REGISTER_CMD = 0, |
67 | VC_CEC_REGISTER_ALL, |
68 | VC_CEC_DEREGISTER_CMD, |
69 | VC_CEC_DEREGISTER_ALL, |
70 | VC_CEC_SEND_MSG, |
71 | VC_CEC_GET_LOGICAL_ADDR, |
72 | VC_CEC_ALLOC_LOGICAL_ADDR, |
73 | VC_CEC_RELEASE_LOGICAL_ADDR, |
74 | VC_CEC_GET_TOPOLOGY, |
75 | VC_CEC_SET_VENDOR_ID, |
76 | VC_CEC_SET_OSD_NAME, |
77 | VC_CEC_GET_PHYSICAL_ADDR, |
78 | VC_CEC_GET_VENDOR_ID, |
79 | |
80 | //The following 3 commands are used when CEC middleware is |
81 | //running in passive mode (i.e. it does not allocate |
82 | //logical address automatically) |
83 | VC_CEC_POLL_ADDR, |
84 | VC_CEC_SET_LOGICAL_ADDR, |
85 | VC_CEC_ADD_DEVICE, |
86 | VC_CEC_SET_PASSIVE, |
87 | //Add more commands here |
88 | VC_CEC_END_OF_LIST |
89 | } VC_CEC_CMD_CODE_T; |
90 | |
91 | //See vc_cec.h for details |
92 | //REGISTER_CMD |
93 | //Parameters: opcode to register (CEC_OPCODE_T sent as uint32) |
94 | //Reply: none |
95 | |
96 | //REGISTER_ALL |
97 | //Parameters: none |
98 | //Reply: none |
99 | |
100 | //DEREGISTER_CMD |
101 | //Parameters: opcode to deregister (CEC_OPCODE_T sent as uint32) |
102 | //Reply: none |
103 | |
104 | //DEREGISTER_ALL |
105 | //Parameters: none |
106 | //Reply: none |
107 | |
108 | //SEND_MSG |
109 | //Parameters: destination, length, 16 bytes buffer (message can only be at most 15 bytes however) |
110 | //Reply: none (callback) |
111 | typedef struct { |
112 | uint32_t follower; |
113 | uint32_t length; |
114 | uint8_t payload[16]; //max. 15 bytes padded to 16 |
115 | uint32_t is_reply; //non-zero if this is a reply, zero otherwise |
116 | } CEC_SEND_MSG_PARAM_T; |
117 | |
118 | //GET_LOGICAL_ADDR |
119 | //Parameters: none |
120 | //Reply: logical address (uint8 returned as uint32) |
121 | |
122 | //ALLOC_LOGICAL_ADDR |
123 | //Parameters: none |
124 | //Reply: none (callback) |
125 | |
126 | //GET_TOPOLOGY |
127 | //Parameters: none |
128 | //Reply: topology (see VC_TOPOLOGY_T) |
129 | |
130 | //SET_VENDOR_ID |
131 | //Parameters: vendor id (uint32) |
132 | //Reply: none |
133 | |
134 | //Set OSD name |
135 | //Parameters: 14 byte char |
136 | //Reply: none |
137 | #define OSD_NAME_LENGTH 14 |
138 | |
139 | //GET_PHYSICAL_ADDR |
140 | //Parameter: none |
141 | //Reply: packed physical address returned as uint16 |
142 | |
143 | //GET_VENDOR_ID |
144 | //Parameter: logical address (CEC_AllDevices_T sent as uint32_t) |
145 | //Reply: (uint32_t vendor id) |
146 | |
147 | //POLL_LOGICAL_ADDR (only for passive mode) |
148 | //Used by host to test a logical address to see if it is available for use |
149 | //Only available if CEC is compiled in passive mode and while the host |
150 | //is testing the availability of a logical address |
151 | //Parameter: logical address |
152 | //Reply: |
153 | |
154 | //SET_LOGICAL_ADDR [(only for passive mode) This will be changed when we support multiple logical addresses] |
155 | //Set the logical address used |
156 | //Only available if CEC is compiled in passive mode |
157 | //Parameter: logical address, device type, vendor ID |
158 | //Reply: (int32_t - zero means success, non-zero otherwise) |
159 | //This function will result in a VC_CEC_LOGICAL_ADDR callback |
160 | typedef struct { |
161 | uint32_t logical_address; |
162 | uint32_t device_type; |
163 | uint32_t vendor_id; |
164 | } CEC_SET_LOGICAL_ADDR_PARAM_T; |
165 | |
166 | //ADD_DEVICE (only for passive mode) |
167 | //Only available if CEC is compiled in passive mode |
168 | //Parameter: logical address, physical address, device type, last device? |
169 | //Reply: (int32_t - zero means success, non-zero otherwise) |
170 | typedef struct { |
171 | uint32_t logical_address; /**<logical address */ |
172 | uint32_t physical_address; /**<16-bit packed physical address in big endian */ |
173 | uint32_t device_type; /**<CEC_DEVICE_TYPE_T */ |
174 | uint32_t last_device; /**<True (non-zero) or false (zero) */ |
175 | } CEC_ADD_DEVICE_PARAM_T; |
176 | |
177 | //SET PASSIVE (only for passive mode) |
178 | //Enable/disable passive mode |
179 | //Parameter: non-zero to enable passive mode, zero to disable |
180 | //Reply: (int32_t - zero means success, non-zero otherwise, non zero will be VCHI errors) |
181 | |
182 | #endif //#ifndef _VC_CECSERVICE_DEFS_H_ |
183 | |