| 1 | |
|---|
| 2 | |
|---|
| 3 | #ifndef BSETTOP_HDMI_H__ |
|---|
| 4 | #define BSETTOP_HDMI_H__ |
|---|
| 5 | |
|---|
| 6 | #include "bsettop_types.h" |
|---|
| 7 | #include "bsettop_display.h" |
|---|
| 8 | #include "bsettop_decode_audio.h" |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | #define boutput_hdmi_cec_max_transmit_length 15 /* + 1 for CEC header length */ |
|---|
| 12 | #define boutput_hdmi_cec_broadcast_address 0xF /* CEC Broadcast address */ |
|---|
| 13 | |
|---|
| 14 | #define CEC_CMD_ABORT 0x00 |
|---|
| 15 | #define CEC_CMD_IMAGE_VIEW_ON 0x04 |
|---|
| 16 | #define CEC_CMD_TEXT_VIEW_ON 0x0d |
|---|
| 17 | #define CEC_CMD_STANDBY 0x36 |
|---|
| 18 | #define CEC_CMD_GIVE_AUDIO_STATUS 0x71 |
|---|
| 19 | #define CEC_CMD_REPORT_AUDIO_STATUS 0x7a |
|---|
| 20 | #define CEC_CMD_ACTIVE_SOURCE 0x82 |
|---|
| 21 | #define CEC_CMD_GET_PHYSICAL_ADDRESS 0x83 |
|---|
| 22 | #define CEC_CMD_REPORT_PHYSICAL_ADDRESS 0x84 |
|---|
| 23 | #define CEC_CMD_REQUEST_ACTIVE_SOURCE 0x85 |
|---|
| 24 | #define CEC_CMD_DEVICE_VENDOR_ID 0x87 |
|---|
| 25 | #define CEC_CMD_DEVICE_VENDOR_CMD 0x89 /* vendor specific command */ |
|---|
| 26 | #define CEC_CMD_GIVE_DEVICE_VENDOR_ID 0x8c |
|---|
| 27 | #define CEC_CMD_GIVE_DEVICE_POWER_STATUS 0x8f |
|---|
| 28 | #define CEC_CMD_REPORT_POWER_STATUS 0x90 |
|---|
| 29 | #define CEC_CMD_INACTIVE_SOURCE 0x9d |
|---|
| 30 | #define CEC_CMD_CEC_VERSION 0x9e |
|---|
| 31 | #define CEC_CMD_GET_CEC_VERSION 0x9f |
|---|
| 32 | |
|---|
| 33 | /* |
|---|
| 34 | Summary: |
|---|
| 35 | HDMI output handle returned by boutput_hdmi_open() |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | typedef struct boutput_hdmi *boutput_hdmi_t; |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | Summary: |
|---|
| 42 | Settings for SPDIF output |
|---|
| 43 | **/ |
|---|
| 44 | typedef struct boutput_spdif_channel_status { |
|---|
| 45 | bool professional_mode; /* [0:0] The professional mode flag. |
|---|
| 46 | TRUE: Professional mode. Other user |
|---|
| 47 | options will not be considered. |
|---|
| 48 | FALSE: Consumer mode. - Read Only*/ |
|---|
| 49 | |
|---|
| 50 | bool pcm; /* [1:1] For output Linear bLinear_PCM=true, |
|---|
| 51 | If output is Compressed bLinear_PCM=false - Read Only */ |
|---|
| 52 | |
|---|
| 53 | bool copyright; /* [2:2] Software CopyRight assert. |
|---|
| 54 | TRUE: CopyRight is asserted |
|---|
| 55 | FALSE: CopyRight is not asserted */ |
|---|
| 56 | |
|---|
| 57 | uint8_t pre_emphasis; /*[3:5] pre-emphasis */ |
|---|
| 58 | |
|---|
| 59 | uint8_t channel_status_mode;/* [6:7] Gives channel status - Read Only*/ |
|---|
| 60 | |
|---|
| 61 | uint8_t category_code; /* [8:15] Category code in spdif channel status, including L-bit */ |
|---|
| 62 | |
|---|
| 63 | uint8_t source_number; /*[16:19] Source number*/ |
|---|
| 64 | |
|---|
| 65 | bool channel_num; /*[20:23] TRUE: Left channel num = 0000 |
|---|
| 66 | Right Channel Num = 0000 |
|---|
| 67 | FALSE: Left channel num = 1000 |
|---|
| 68 | Right Channel Num = 0100 */ |
|---|
| 69 | |
|---|
| 70 | uint8_t sampling_frequency; /*[24:27]Sampling frequency - Read Only*/ |
|---|
| 71 | |
|---|
| 72 | uint8_t clock_accuracy; /* [28:29] Clock Accuracy */ |
|---|
| 73 | |
|---|
| 74 | bool max_word_length; /* [32:32] For setting of 32bit of Channel Status |
|---|
| 75 | Bit 32 0 Maximum audio sample word length is 20 bits |
|---|
| 76 | 1 Maximum audio sample word length is 24 bits */ |
|---|
| 77 | |
|---|
| 78 | uint8_t sample_word_length; /* [33:35] Sample word length */ |
|---|
| 79 | |
|---|
| 80 | uint8_t original_sampling_frequency;/* [36:39] Original sampling frequency*/ |
|---|
| 81 | |
|---|
| 82 | uint8_t cgms_a; /* [40:41] */ |
|---|
| 83 | } boutput_spdif_channel_status; |
|---|
| 84 | |
|---|
| 85 | /* |
|---|
| 86 | Summary: |
|---|
| 87 | Settings returned by bdisplay_get_format_settings |
|---|
| 88 | */ |
|---|
| 89 | typedef struct bvideo_format_settings { |
|---|
| 90 | unsigned width; /* height of video format in pixels */ |
|---|
| 91 | unsigned height; /* width of video format in lines */ |
|---|
| 92 | unsigned refresh_rate; /* 20061213 DEPRECATED -- refresh rate of video format in Hz */ |
|---|
| 93 | bvideo_frame_rate frame_rate; /* 20061213 bandrews - replaces refresh_rate */ |
|---|
| 94 | bool interlaced; |
|---|
| 95 | } bvideo_format_settings; |
|---|
| 96 | |
|---|
| 97 | /* |
|---|
| 98 | Summary: |
|---|
| 99 | HDMI HDCP Status |
|---|
| 100 | */ |
|---|
| 101 | typedef enum boutput_hdmi_hdcp_state |
|---|
| 102 | { |
|---|
| 103 | boutput_hdmi_hdcp_state_internal_err, |
|---|
| 104 | boutput_hdmi_hdcp_state_disabled, |
|---|
| 105 | boutput_hdmi_hdcp_state_init, |
|---|
| 106 | boutput_hdmi_hdcp_state_auth_fail, |
|---|
| 107 | |
|---|
| 108 | boutput_hdmi_hdcp_state_ri_fail, |
|---|
| 109 | boutput_hdmi_hdcp_state_pj_fail, |
|---|
| 110 | boutput_hdmi_hdcp_state_repeater_fail, |
|---|
| 111 | |
|---|
| 112 | boutput_hdmi_hdcp_state_enabled |
|---|
| 113 | } boutput_hdmi_hdcp_state; |
|---|
| 114 | |
|---|
| 115 | /* |
|---|
| 116 | Summary: |
|---|
| 117 | HDMI CEC message type |
|---|
| 118 | */ |
|---|
| 119 | typedef enum boutput_hdmi_cec_message_type |
|---|
| 120 | { |
|---|
| 121 | boutput_hdmi_cec_message_type_transmit = 0, |
|---|
| 122 | boutput_hdmi_cec_message_type_receive = 1 |
|---|
| 123 | } boutput_hdmi_cec_message_type ; |
|---|
| 124 | |
|---|
| 125 | /* |
|---|
| 126 | Summary: |
|---|
| 127 | All information from a received CEC message or to |
|---|
| 128 | transmit a CEC message |
|---|
| 129 | */ |
|---|
| 130 | typedef struct boutput_hdmi_cec_message_data |
|---|
| 131 | { |
|---|
| 132 | boutput_hdmi_cec_message_type message_type; |
|---|
| 133 | uint8_t initiator_addr; |
|---|
| 134 | uint8_t destination_addr; |
|---|
| 135 | uint8_t opcode; |
|---|
| 136 | uint8_t message_buffer[boutput_hdmi_cec_max_transmit_length]; |
|---|
| 137 | uint8_t message_length; |
|---|
| 138 | } boutput_hdmi_cec_message_data; |
|---|
| 139 | |
|---|
| 140 | /* |
|---|
| 141 | Summary: |
|---|
| 142 | All CEC related information from the device. |
|---|
| 143 | */ |
|---|
| 144 | typedef struct boutput_hdmi_cec_configuration |
|---|
| 145 | { |
|---|
| 146 | uint8_t logical_address; |
|---|
| 147 | uint8_t physical_address[2]; |
|---|
| 148 | uint8_t device_type; |
|---|
| 149 | } boutput_hdmi_cec_configuration; |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | typedef struct bsettop_hdmi *bsettop_hdmi_t; |
|---|
| 153 | |
|---|
| 154 | typedef void (*bsettop_hdcp_authentication_cb_t)( |
|---|
| 155 | bool authenticated /* authenticated or not */ |
|---|
| 156 | ); |
|---|
| 157 | |
|---|
| 158 | #ifdef __cplusplus |
|---|
| 159 | extern "C" { |
|---|
| 160 | #endif |
|---|
| 161 | |
|---|
| 162 | /* |
|---|
| 163 | Summary: |
|---|
| 164 | HDMI deep color mode enum |
|---|
| 165 | */ |
|---|
| 166 | typedef enum boutput_hdmi_color_depth |
|---|
| 167 | { |
|---|
| 168 | boutput_hdmi_color_depth_8bit, |
|---|
| 169 | boutput_hdmi_color_depth_10bit, |
|---|
| 170 | boutput_hdmi_color_depth_12bit, |
|---|
| 171 | boutput_hdmi_color_depth_16bit |
|---|
| 172 | } boutput_hdmi_color_depth; |
|---|
| 173 | |
|---|
| 174 | #if 0 |
|---|
| 175 | /** |
|---|
| 176 | Summary: |
|---|
| 177 | Settings for HDMI output |
|---|
| 178 | **/ |
|---|
| 179 | typedef struct boutput_hdmi_settings { |
|---|
| 180 | bvideo_format edid_preferred_format ; /* format preferred by attached DVI/HDMI device */ |
|---|
| 181 | bvideo_format_settings vesa_settings ; /* if format == bvideo_format_vesa, |
|---|
| 182 | then these settings are used. */ |
|---|
| 183 | |
|---|
| 184 | bool hdcp ; |
|---|
| 185 | uint16_t hdcp_failure_retry_delay ; |
|---|
| 186 | bool hdcp_pj_checking_enable ; |
|---|
| 187 | bool preemphasis_support ; |
|---|
| 188 | bool hdcp_disable_blue_screen; /* If true, upon HDCP failure, a OSD message will be displayed on HDMI |
|---|
| 189 | instead of blue screen */ |
|---|
| 190 | bool validate_edid_format; /* If true, bdisplay_set will only accept formats |
|---|
| 191 | that are valid in the attached device's EDID data. */ |
|---|
| 192 | unsigned hdmi_avmute_delay_pre_format_change; /* Delay (in ms) after sending AVMute and before the format change */ |
|---|
| 193 | unsigned hdmi_avmute_delay_post_format_change; /* Delay (in ms) before sending AVUnMute and after the format change */ |
|---|
| 194 | bsettop_callback hdmi_hotplug_callback; /* Called when a device connects */ |
|---|
| 195 | bsettop_callback hdmi_disconnect_callback; /* Called when a device disconnects */ |
|---|
| 196 | bsettop_callback hdmi_hdcp_status_callback; /* Called when HDCP status changes */ |
|---|
| 197 | bsettop_callback hdmi_cec_message_callback; /* Called when a CEC message is received */ |
|---|
| 198 | void *callback_context; /* all callbacks share this context */ |
|---|
| 199 | |
|---|
| 200 | boutput_hdmi_audio_mode hdmi_audio_mode; /* Audio mode for HDMI */ |
|---|
| 201 | baudio_format compressed_audio_format; /* compressed output format. If hdmi_audio_mode = compressed and this is |
|---|
| 202 | set to a valid format (e.g. baudio_format_dts), output will be |
|---|
| 203 | transcoded to that format. By default this is baudio_format_unknown, |
|---|
| 204 | which will leave the compressed data in the original format. */ |
|---|
| 205 | boutput_spdif_channel_status hdmi_spdif_channel_status; /* HDMI's Spdif audio output's Channel status */ |
|---|
| 206 | unsigned audio_delay; /* delay, in ms, applied to the HDMI audio output */ |
|---|
| 207 | boutput_hdmi_color_depth hdmi_color_depth; /* color depth settings 8, 10, 12, or 16bits */ |
|---|
| 208 | } boutput_hdmi_settings; |
|---|
| 209 | |
|---|
| 210 | /** |
|---|
| 211 | Summary: |
|---|
| 212 | Set new HDMI settings. |
|---|
| 213 | Description: |
|---|
| 214 | These settings will not be applied until bdisplay_set is called with the |
|---|
| 215 | HDMI handle assigned. |
|---|
| 216 | **/ |
|---|
| 217 | bresult boutput_hdmi_set(boutput_hdmi_t dvi, |
|---|
| 218 | const boutput_hdmi_settings *settings); |
|---|
| 219 | |
|---|
| 220 | /** |
|---|
| 221 | Summary: |
|---|
| 222 | Get the current HDMI settings. |
|---|
| 223 | **/ |
|---|
| 224 | void boutput_hdmi_get(boutput_hdmi_t dvi, |
|---|
| 225 | boutput_hdmi_settings *settings /* [out] */ |
|---|
| 226 | ); |
|---|
| 227 | |
|---|
| 228 | /** |
|---|
| 229 | Summary: |
|---|
| 230 | DVI/HDMI device capabilities |
|---|
| 231 | **/ |
|---|
| 232 | typedef struct boutput_hdmi_capabilities |
|---|
| 233 | { |
|---|
| 234 | bvideo_format preferred_video_format; |
|---|
| 235 | bool video_format_is_supported[bvideo_format_count]; |
|---|
| 236 | |
|---|
| 237 | boutput_hdmi_audio_mode preferred_audio_mode; |
|---|
| 238 | bool audio_mode_is_supported[boutput_hdmi_audio_mode_count]; |
|---|
| 239 | |
|---|
| 240 | bool hdmi; /* True if HDMI, false if DVI */ |
|---|
| 241 | boutput_hdmi_rx_edid_info rx_edid_info; /* contians HDMI Rx EDID info. */ |
|---|
| 242 | } boutput_hdmi_capabilities; |
|---|
| 243 | |
|---|
| 244 | /** |
|---|
| 245 | Summary: |
|---|
| 246 | Get the current HDMI device capabilities. |
|---|
| 247 | **/ |
|---|
| 248 | bresult boutput_hdmi_get_capabilities(boutput_hdmi_t dvi, |
|---|
| 249 | boutput_hdmi_capabilities *caps /* [out] */ |
|---|
| 250 | ); |
|---|
| 251 | #endif |
|---|
| 252 | |
|---|
| 253 | /** |
|---|
| 254 | Summary: |
|---|
| 255 | The current HDMI status |
|---|
| 256 | **/ |
|---|
| 257 | typedef struct boutput_hdmi_status |
|---|
| 258 | { |
|---|
| 259 | bool connected; |
|---|
| 260 | bvideo_format preferred; |
|---|
| 261 | bool is_hdmi; |
|---|
| 262 | boutput_hdmi_hdcp_state hdcp_state; |
|---|
| 263 | } boutput_hdmi_status; |
|---|
| 264 | |
|---|
| 265 | /** |
|---|
| 266 | Summary: |
|---|
| 267 | Get the current HDCP status |
|---|
| 268 | **/ |
|---|
| 269 | bresult boutput_hdmi_get_status(bsettop_hdmi_t h_hdmi, |
|---|
| 270 | boutput_hdmi_status *status /* [out] */ |
|---|
| 271 | ); |
|---|
| 272 | |
|---|
| 273 | /** |
|---|
| 274 | Summary: |
|---|
| 275 | Get the received CEC message |
|---|
| 276 | **/ |
|---|
| 277 | bresult boutput_hdmi_cec_get_message(boutput_hdmi_t dvi, |
|---|
| 278 | boutput_hdmi_cec_message_data *cec_message_data /* [out] */ |
|---|
| 279 | ); |
|---|
| 280 | |
|---|
| 281 | /** |
|---|
| 282 | Summary: |
|---|
| 283 | Send CEC message |
|---|
| 284 | **/ |
|---|
| 285 | bresult boutput_hdmi_cec_send_message(boutput_hdmi_t dvi, |
|---|
| 286 | const boutput_hdmi_cec_message_data *cec_message_data |
|---|
| 287 | ); |
|---|
| 288 | |
|---|
| 289 | /** |
|---|
| 290 | Summary: |
|---|
| 291 | Get the CEC configuration from the device |
|---|
| 292 | **/ |
|---|
| 293 | bresult boutput_hdmi_cec_get_configuration(boutput_hdmi_t dvi, |
|---|
| 294 | boutput_hdmi_cec_configuration *cec_configuration /* [out] */ |
|---|
| 295 | ); |
|---|
| 296 | |
|---|
| 297 | /** |
|---|
| 298 | Summary: |
|---|
| 299 | Check the current status of the device |
|---|
| 300 | **/ |
|---|
| 301 | bool boutput_hdmi_cec_is_device_ready(boutput_hdmi_t dvi); |
|---|
| 302 | |
|---|
| 303 | /** |
|---|
| 304 | Summary: |
|---|
| 305 | Enable CEC core to receive CEC messages |
|---|
| 306 | **/ |
|---|
| 307 | bresult boutput_hdmi_cec_enable_receive(boutput_hdmi_t dvi); |
|---|
| 308 | |
|---|
| 309 | bresult bsettop_hdmi_open( |
|---|
| 310 | bsettop_hdmi_t *h_hdmi, |
|---|
| 311 | bdisplay_t display, /* display on which the graphics are displayed */ |
|---|
| 312 | baudio_decode_t audio_decode, |
|---|
| 313 | bsettop_hdcp_authentication_cb_t hdcp_authentication_cb |
|---|
| 314 | ); |
|---|
| 315 | void bsettop_hdmi_close(bsettop_hdmi_t h_hdmi); |
|---|
| 316 | |
|---|
| 317 | void bsettop_hdmi_disconnect_audio(bsettop_hdmi_t h_hdmi); |
|---|
| 318 | |
|---|
| 319 | void bsettop_hdmi_connect_audio(bsettop_hdmi_t h_hdmi); |
|---|
| 320 | |
|---|
| 321 | BERR_Code bsettop_hdmi_cec_cmd(int cecCmd, int destinationAddr); |
|---|
| 322 | |
|---|
| 323 | bool bsettop_hdmi_get_RGB_output(void); |
|---|
| 324 | |
|---|
| 325 | bresult bsettop_hdmi_set_RGB_output(bool bRGB); |
|---|
| 326 | |
|---|
| 327 | bool bsettop_hdmi_get_native_audio_mode(void); |
|---|
| 328 | BERR_Code bsettop_hdmi_set_native_audio_mode(bool native); |
|---|
| 329 | |
|---|
| 330 | bool bsettop_hdmi_is_video_fmt_supported(bsettop_display_format_t fmt); |
|---|
| 331 | bvideo_format bsettop_hdmi_get_preferred_format(bsettop_hdmi_t h_hdmi); |
|---|
| 332 | bool bsettop_hdmi_is_dvi(bsettop_hdmi_t h_hdmi); |
|---|
| 333 | void bsettop_hdmi_mark_dsp_fmt_valid(bsettop_hdmi_t h_hdmi); |
|---|
| 334 | /** |
|---|
| 335 | Summary: |
|---|
| 336 | check if HDCP authentication is successful or not |
|---|
| 337 | **/ |
|---|
| 338 | bool bsettop_hdmi_check_hdcp_authentication_status(bsettop_hdmi_t h_hdmi); |
|---|
| 339 | |
|---|
| 340 | #ifdef __cplusplus |
|---|
| 341 | } |
|---|
| 342 | #endif |
|---|
| 343 | |
|---|
| 344 | #endif /* BSETTOP_HDMI_H */ |
|---|
| 345 | |
|---|