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 | * TV service command enumeration and parameter types. |
30 | */ |
31 | |
32 | #ifndef _VC_TVSERVICE_DEFS_H_ |
33 | #define _VC_TVSERVICE_DEFS_H_ |
34 | #include "vcinclude/common.h" |
35 | #include "interface/vchi/message_drivers/message.h" |
36 | #include "vc_hdmi.h" |
37 | #include "vc_sdtv.h" |
38 | |
39 | #define VC_TVSERVICE_VER 1 |
40 | |
41 | #define TVSERVICE_MSGFIFO_SIZE 1024 |
42 | #define TVSERVICE_CLIENT_NAME MAKE_FOURCC("TVSV") |
43 | #define TVSERVICE_NOTIFY_NAME MAKE_FOURCC("TVNT") |
44 | |
45 | #define TVSERVICE_MAX_CALLBACKS 5 |
46 | |
47 | //TV service commands |
48 | typedef enum { |
49 | VC_TV_GET_STATE = 0, |
50 | VC_TV_HDMI_ON_PREFERRED, |
51 | VC_TV_HDMI_ON_BEST, |
52 | VC_TV_HDMI_ON_EXPLICIT, |
53 | VC_TV_SDTV_ON, |
54 | VC_TV_OFF, |
55 | VC_TV_QUERY_SUPPORTED_MODES, |
56 | VC_TV_QUERY_MODE_SUPPORT, |
57 | VC_TV_QUERY_AUDIO_SUPPORT, |
58 | VC_TV_ENABLE_COPY_PROTECT, |
59 | VC_TV_DISABLE_COPY_PROTECT, |
60 | VC_TV_SHOW_INFO, |
61 | VC_TV_GET_AV_LATENCY, |
62 | VC_TV_HDCP_SET_KEY, |
63 | VC_TV_HDCP_SET_SRM, |
64 | VC_TV_SET_SPD, |
65 | VC_TV_SET_DISPLAY_OPTIONS, |
66 | VC_TV_TEST_MODE_START, |
67 | VC_TV_TEST_MODE_STOP, |
68 | VC_TV_DDC_READ, |
69 | VC_TV_SET_ATTACHED, |
70 | VC_TV_SET_PROP, |
71 | VC_TV_GET_PROP, |
72 | VC_TV_GET_DISPLAY_STATE, |
73 | VC_TV_QUERY_SUPPORTED_MODES_ACTUAL, |
74 | VC_TV_GET_DEVICE_ID, |
75 | |
76 | VC_TV_GET_ATTACHED_DEVICES, |
77 | //Add more commands here |
78 | |
79 | VC_TV_END_OF_LIST |
80 | } VC_TV_CMD_CODE_T; |
81 | |
82 | // Define a bit in the command that sets whether command contains a display ID |
83 | #define TVSERVICE_COMMAND_HAS_DISPLAY_ID (1 << 31) |
84 | |
85 | //Parameters for each command (padded to multiple of 16 bytes) |
86 | //See vc_hdmi.h and vc_sdtv.h for details |
87 | |
88 | //GET_STATE |
89 | //Parameters: none |
90 | //Reply: state (flags of VC_HDMI_NOTIFY_T and VC_SDTV_NOTIFY_T) |
91 | // current width |
92 | // current height |
93 | // current refresh rate |
94 | // current scan mode |
95 | |
96 | typedef struct { |
97 | uint32_t state; /**<TV state is a union of bitmask of VC_HDMI_NOTIFY_T and VC_SDTV_NOTIFY_T */ |
98 | uint32_t width; /**<Current display width if TV is on */ |
99 | uint32_t height; /**<Current display height if TV is on */ |
100 | uint16_t frame_rate;/**<Current refresh rate is TV is on */ |
101 | uint16_t scan_mode; /**<Current scanmode 0 for progressive, 1 for interlaced */ |
102 | } TV_GET_STATE_RESP_T; |
103 | |
104 | //Generic single returned interpreted based on the command |
105 | typedef struct { |
106 | int32_t ret; //Single return value |
107 | } TV_GENERAL_RESP_T; |
108 | |
109 | //HDMI_ON_PREFERRED |
110 | //Parameters: 3d mode (on/off) |
111 | //Reply: single return value interpreted as HDMI_RESULT_T or SDTV equivalent (all single reply value will be of this form) |
112 | typedef struct { |
113 | uint32_t in_3d; |
114 | } TV_HDMI_ON_PREFERRED_PARAM_T; |
115 | |
116 | //HDMI_ON_BEST |
117 | //Parameters: width, height, frame rate, scan mode, matching flag (EDID_MODE_MATCH_FLAG_T), 3d mode (on/off) |
118 | //Reply: single return value interpreted as HDMI_RESULT_T or SDTV equivalent |
119 | typedef struct { |
120 | uint32_t width; |
121 | uint32_t height; |
122 | uint32_t frame_rate; |
123 | uint32_t scan_mode; |
124 | uint32_t match_flags; |
125 | uint32_t in_3d; |
126 | } TV_HDMI_ON_BEST_PARAM_T; |
127 | |
128 | //HDMI_ON_EXPLICIT |
129 | //Parameters: hdmi_mode, standard, mode |
130 | //Reply: same as above |
131 | typedef struct { |
132 | uint32_t hdmi_mode; //DVI or HDMI |
133 | uint32_t group; |
134 | uint32_t mode; |
135 | } TV_HDMI_ON_EXPLICIT_PARAM_T; |
136 | |
137 | //SDTV_ON |
138 | //Parameters: SDTV mode, aspect ratio |
139 | //Reply: Same as above |
140 | typedef struct { |
141 | uint32_t mode; |
142 | uint32_t aspect; |
143 | } TV_SDTV_ON_PARAM_T; |
144 | |
145 | //TV_OFF |
146 | //Parameters: none |
147 | //Reply: none |
148 | |
149 | //TV_QUERY_SUPPORTED_MODES |
150 | //Parameters: standard (CEA/DMT) sent as uint32_t |
151 | //Reply: how many modes there are in this group, |
152 | // preferred resolution |
153 | |
154 | //TV_QUERY_SUPPORTED_MODES_ACTUAL (This downloads the array of supported modes) |
155 | //Parameters: standard (CEA/DMT) sent as uint32_t, |
156 | // table size supplied |
157 | //Reply: how many modes which will be returned, |
158 | // prefer resolution, |
159 | // the actual array of modes (via bulk transfer) |
160 | |
161 | typedef struct { |
162 | uint32_t scan_mode : 1; /**<1 is interlaced, 0 for progressive */ |
163 | uint32_t native : 1; /**<1 means native mode, 0 otherwise */ |
164 | uint32_t group : 3; /**<group */ |
165 | uint32_t code : 7; /**<mode code */ |
166 | uint32_t pixel_rep : 3; /**<pixel repetition (zero means no repetition)*/ |
167 | uint32_t aspect_ratio : 5; /**<aspect ratio of the format */ |
168 | uint16_t frame_rate; /**<frame rate */ |
169 | uint16_t width; /**<frame width */ |
170 | uint16_t height; /**<frame height */ |
171 | uint32_t pixel_freq; /**<pixel clock in Hz */ |
172 | uint32_t struct_3d_mask;/**<3D structure supported for this mode, only valid if group == CEA. This is a bitmask of HDMI_3D_STRUCT_T */ |
173 | } TV_SUPPORTED_MODE_NEW_T; |
174 | |
175 | typedef struct { |
176 | uint16_t scan_mode : 1; /**<1 is interlaced, 0 for progressive */ |
177 | uint16_t native : 1; /**<1 means native mode, 0 otherwise */ |
178 | uint16_t code : 7; /**<mode code */ |
179 | uint16_t frame_rate; /**<frame rate */ |
180 | uint16_t width; /**<frame width */ |
181 | uint16_t height; /**<frame height */ |
182 | } TV_SUPPORTED_MODE_T; |
183 | |
184 | typedef struct { |
185 | uint32_t num_supported_modes; |
186 | uint32_t preferred_group; |
187 | uint32_t preferred_mode; |
188 | } TV_QUERY_SUPPORTED_MODES_RESP_T; |
189 | |
190 | //num_supported_modes is the no. of modes available in that group for TV_QUERY_SUPPORTED_MODES |
191 | //and no. of modes which will be bulk sent across in TV_QUERY_SUPPORTED_MODES_ACTUAL |
192 | |
193 | //For TV_QUERY_SUPPORTED_MODES_ACTUAL, there will be a separate bulk receive |
194 | //containing the supported modes array |
195 | |
196 | //TV_QUERY_MODE_SUPPORT |
197 | //Parameters: stardard, mode |
198 | //Reply: yes/no |
199 | //but the return value meaning is reversed (zero is unsupported, non-zero is supported) |
200 | typedef struct { |
201 | uint32_t group; |
202 | uint32_t mode; |
203 | } TV_QUERY_MODE_SUPPORT_PARAM_T; |
204 | |
205 | //TV_QUERY_AUDIO_SUPPORT |
206 | //Parameters: audio format, no. of channels, sampling frequency, bitrate/sample size |
207 | //Reply: single value interpreted as flags EDID_AUDIO_SUPPORT_FLAG_T |
208 | typedef struct { |
209 | uint32_t audio_format; //EDID_AudioFormat (if format is eExtended, add EDID_AudioCodingExtension to the audio format) |
210 | uint32_t num_channels; // 1-8 |
211 | uint32_t fs; // EDID_AudioSampleRate |
212 | uint32_t bitrate; // EDID_AudioSampleSize if format == PCM, bitrate otherwise |
213 | } TV_QUERY_AUDIO_SUPPORT_PARAM_T; |
214 | |
215 | //TV_ENABLE_COPY_PROTECT |
216 | //Parameters: copy protect mode (for HDMI it will always be HDCP), timeout |
217 | //Reply: single return value - cp result arrive via callback |
218 | typedef struct { |
219 | uint32_t cp_mode; |
220 | uint32_t timeout; |
221 | } TV_ENABLE_COPY_PROTECT_PARAM_T; |
222 | |
223 | //TV_DISABLE_COPY_PROTECT |
224 | //Parameters: none |
225 | //Reply: single value return - results arrive via callback |
226 | |
227 | //TV_SHOW_INFO |
228 | //Parameters: visible |
229 | //Reply: none |
230 | typedef struct { |
231 | uint32_t visible; //0 to hide the screen |
232 | } TV_SHOW_INFO_PARAM_T; |
233 | |
234 | //TV_GET_AV_LATENCY |
235 | //Parameters: none |
236 | //Reply: single value interpreted as latency in ms |
237 | |
238 | |
239 | //TV_HDCP_SET_KEY |
240 | //Parameters: key block buffer (fixed size HDCP_KEY_BLOCK_SIZE) |
241 | //Reply: none, key validity result arrives via callback |
242 | typedef struct { |
243 | uint8_t key[HDCP_KEY_BLOCK_SIZE]; |
244 | } TV_HDCP_SET_KEY_PARAM_T; |
245 | |
246 | //TV_HDCP_SET_SRM |
247 | //Parameters: num of keys, pointer to revocation list (transferred as buffer) |
248 | //Reply: none, callback indicates no. of keys set |
249 | typedef struct { |
250 | uint32_t num_keys; |
251 | } TV_HDCP_SET_SRM_PARAM_T; |
252 | |
253 | //TV_SET_SPD |
254 | //Parameters: name [8], description [16], type |
255 | //Reply: none |
256 | #define TV_SPD_NAME_LEN 8 |
257 | #define TV_SPD_DESC_LEN 16 |
258 | typedef struct { |
259 | char manufacturer[TV_SPD_NAME_LEN]; |
260 | char description[TV_SPD_DESC_LEN]; |
261 | uint32_t type; |
262 | } TV_SET_SPD_PARAM_T; |
263 | |
264 | //TV_SET_DISPLAY_OPTIONS |
265 | //Parameters: aspect ratio (HDMI_ASPECT_T), vert bar present (bool), |
266 | // left bar width, right bar width, horiz bar present (bool) |
267 | // top bar height, bottom bar height |
268 | //Reply: none |
269 | typedef struct { |
270 | uint32_t aspect; |
271 | uint32_t vertical_bar_present; |
272 | uint32_t left_bar_width; |
273 | uint32_t right_bar_width; |
274 | uint32_t horizontal_bar_present; |
275 | uint32_t top_bar_height; |
276 | uint32_t bottom_bar_height; |
277 | uint32_t overscan_flags; |
278 | } TV_SET_DISPLAY_OPTIONS_PARAM_T; |
279 | |
280 | //TV_TEST_MODE_START |
281 | //Parameters: rgb colour, test mode |
282 | //Reply: none |
283 | |
284 | //Actual enums used for test mode |
285 | typedef enum { |
286 | TV_TEST_MODE_DISABLED = 0, //Test mode disabled |
287 | TV_TEST_MODE_SOLID_BACKGND = 1, //Solid background colur |
288 | TV_TEST_MODE_SOLID_VERTICAL = 2, //Vertical bars |
289 | TV_TEST_MODE_SHADED_VERTICAL = 3, //Shaded vertical bars |
290 | TV_TEST_MODE_SHADED_WHITE_V = 4, //White vertical bars |
291 | TV_TEST_MODE_SHADED_WHITE_H = 5, //White horizontal bars |
292 | TV_TEST_MODE_SHADED_RGB = 6, //Shaded RGB + white bars |
293 | TV_TEST_MODE_WALKING = 7, //Walking one across 24-bit RGB |
294 | TV_TEST_MODE_DELAYED = 8, //Delayed shaded RGB bars |
295 | TV_TEST_MODE_HVD = 9, //Horizontal G, Vert. B, Diag. R bars |
296 | TV_TEST_MODE_ODD_CH =10, //Odd field crosshairs |
297 | TV_TEST_MODE_EVEN_CH =11, //Even field crosshairs |
298 | TV_TEST_MODE_32x32 =12, //32x32 white grid |
299 | TV_TEST_MODE_WYCGMRBK_SOLID =13, //Solid blah blah |
300 | TV_TEST_MODE_WYCGMRBK_SHADED =14, //Shaded blah blah |
301 | TV_TEST_MODE_32x32_DIAGONAL =15 //32x32 white diagonal grid |
302 | } TV_TEST_MODE_T; |
303 | |
304 | typedef struct { |
305 | uint32_t colour; //RGB colour |
306 | uint32_t test_mode; //one of the TV_TEST_MODE_T enums above |
307 | } TV_TEST_MODE_START_PARAM_T; |
308 | |
309 | //TV_TEST_MODE_STOP |
310 | //Parameters: none |
311 | //Reply: none |
312 | |
313 | //TV_DDC_READ |
314 | //Parameters: offset, length |
315 | //Reply: length of data actually read (so zero means error), |
316 | //and fills in the passed in buffer if no error |
317 | typedef struct { |
318 | uint32_t offset; |
319 | uint32_t length; |
320 | } TV_DDC_READ_PARAM_T; |
321 | |
322 | //TV_SET_ATTACHED |
323 | //Parameters: uint32_t attached or not (0 = hotplug low, 1 = hotplug high) |
324 | |
325 | //TV_SET_PROP |
326 | //Parameters: HDMI_PROPERTY_PARAM_T |
327 | //Reply: 0 = set successful, non-zero if error (int32_t) |
328 | #define HDMI_PROPERTY_SIZE_IN_WORDS (sizeof(HDMI_PROPERTY_T)/sizeof(uint32_t)) |
329 | |
330 | //TV_GET_PROP |
331 | //Parameters: parameter type (sent as uint32_t) |
332 | //Reply param1/param2 of the passed in property and return code |
333 | typedef struct { |
334 | int32_t ret; /**<Return code */ |
335 | HDMI_PROPERTY_PARAM_T property; /**<HDMI_PROPERTY_PARAM_T */ |
336 | } TV_GET_PROP_PARAM_T; |
337 | |
338 | //TV_GET_DISPLAY_STATE |
339 | //Parameters: none |
340 | //Return TV display state |
341 | typedef struct { |
342 | uint32_t state; /** This will be the state of HDMI | SDTV */ |
343 | union { |
344 | SDTV_DISPLAY_STATE_T sdtv; /** If SDTV is active, this is the state of SDTV */ |
345 | HDMI_DISPLAY_STATE_T hdmi; /** If HDMI is active, this is the state of HDMI */ |
346 | } display; |
347 | } TV_DISPLAY_STATE_T; |
348 | |
349 | //TV_GET_DEVICE_ID |
350 | //Parameter: none |
351 | //Return device ID information from EDID |
352 | typedef struct { |
353 | char vendor[EDID_DEVICE_VENDOR_ID_LENGTH+1]; |
354 | char monitor_name[EDID_DESC_ASCII_STRING_LEN+1]; |
355 | uint32_t serial_num; |
356 | } TV_DEVICE_ID_T; |
357 | |
358 | // state flag for LCD attached |
359 | enum { |
360 | VC_LCD_ATTACHED_DEFAULT = (1 <<22), /**<LCD display is attached and default */ |
361 | }; |
362 | |
363 | #define TV_MAX_ATTACHED_DISPLAYS 16 |
364 | typedef struct { |
365 | int32_t num_attached; /** How many devices are attached **/ |
366 | uint8_t display_number[TV_MAX_ATTACHED_DISPLAYS]; /** The display number of attached devices in order |
367 | Display number example DISPMANX_ID_MAIN_LCD, see vc_dispmanx_types.h **/ |
368 | } TV_ATTACHED_DEVICES_T; |
369 | |
370 | #endif |
371 | |