1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 #ifndef __HDMI_HAL_H__ 19 #define __HDMI_HAL_H__ 20 21 #include "drv_hdmi_common.h" 22 23 typedef hi_void *hdmi_handle; 24 25 typedef enum { 26 HDMI_DEBUG_CMD_COLOR_BAR, 27 HDMI_DEBUG_CMD_SW_RESET, 28 HDMI_DEBUG_CMD_RGB2YUV, 29 HDMI_DEBUG_CMD_YUV2RGB, 30 HDMI_DEBUG_CMD_DITHER, 31 HDMI_DEBUG_CMD_BYPASS, 32 HDMI_DEBUG_CMD_DDC_FREQ, 33 HDMI_DEBUG_CMD_PHY_DEFAULT_GET, 34 HDMI_DEBUG_CMD_PHY_PARA_SET, 35 HDMI_DEBUG_CMD_DUMP, 36 #if defined(HDMI_SUPPORT_LOGIC_HISIV100) 37 HDMI_DEBUG_CMD_PROC_MACH, 38 HDMI_DEBUG_CMD_PROC_SCDC, 39 HDMI_DEBUG_CMD_PROC_HDCP14, 40 HDMI_DEBUG_CMD_PROC_HDCP22, 41 HDMI_DEBUG_CMD_PROC_DDC, 42 HDMI_DEBUG_CMD_PROC_CECTX, 43 HDMI_DEBUG_CMD_PROC_CECRX, 44 HDMI_DEBUG_CMD_DBG_VIDEO_GET, 45 HDMI_DEBUG_CMD_DBG_VIDEO_SET, 46 HDMI_DEBUG_CMD_SSC, 47 HDMI_DEBUG_CMD_FRL 48 #endif 49 } hdmi_debug_cmd; 50 51 typedef struct { 52 hi_u32 reg_addr; 53 hi_u32 reg_vaule; 54 } hdmi_hal_reg; 55 56 typedef struct { 57 hdmi_handle hdmi_hw; 58 hdmi_handle hdmi_dev; 59 hi_u32 hdmi_id; 60 hdmi_tx_capability_data tx_capability; 61 hdmi_callback callback; 62 hdmi_video_config video_cfg; 63 hdmi_audio_config audio_cfg; 64 hi_char *base_addr; 65 hi_char *phy_addr; 66 } hdmi_hal_context; 67 68 typedef struct { 69 hi_u32 disp_fmt; 70 hi_u32 pix_clk; 71 hdmi_colorspace color_space; 72 hdmi_deep_color deep_color; 73 } hdmi_hal_base_param; 74 75 typedef struct hdmi_hal_ { 76 hdmi_hal_context hal_ctx; 77 hi_void (*hal_hdmi_hardware_init)(const struct hdmi_hal_ *hal); 78 hi_void (*hal_hdmi_tmds_mode_set)(const struct hdmi_hal_ *hal, hdmi_tmds_mode tmds_mode); 79 hi_void (*hal_hdmi_avmute_set)(const struct hdmi_hal_ *hal, hi_bool av_mute); 80 hi_void (*hal_hdmi_infoframe_set)(const struct hdmi_hal_ *, hdmi_infoframe_id, hi_u8 in_buffer[], hi_u32 buf_len); 81 hi_void (*hal_hdmi_infoframe_enable_set)(const struct hdmi_hal_ *, hdmi_infoframe_id, hi_bool); 82 hi_s32 (*hal_hdmi_video_path_set)(const struct hdmi_hal_ *hal, hdmi_video_config *video_cfg); 83 hi_void (*hal_hdmi_phy_output_enable_set)(const struct hdmi_hal_ *hal, hi_bool enable); 84 hi_void (*hal_hdmi_phy_power_enable_set)(const struct hdmi_hal_ *hal, hi_bool enable); 85 hi_void (*hal_hdmi_tx_capability_get)(const struct hdmi_hal_ *hal, hdmi_tx_capability_data *tx_capability); 86 hi_void (*hal_hdmi_emi_status_get)(const struct hdmi_hal_ *hal, hdmi_emi_status *emi_status); 87 hi_void (*hal_hdmi_csc_param_set)(struct hdmi_hal_ *hal, hdmi_video_config *video_cfg); 88 hi_void (*hal_hdmi_phy_set)(const struct hdmi_hal_ *hal, hdmi_phy_cfg *phy_cfg); 89 hi_void (*hal_hdmi_ctrl_reset)(const struct hdmi_hal_ *hal); 90 hi_s32 (*hal_hdmi_phy_hw_spec_set)(const struct hdmi_hal_ *hdmi_hal, hi_u32 tmds_clk, const hdmi_hw_spec *hw_spec); 91 hi_s32 (*hal_hdmi_phy_hw_spec_get)(const struct hdmi_hal_ *hdmi_hal, hdmi_hw_spec *hw_spec); 92 hi_void (*hal_hdmi_sequencer_handler_process)(const struct hdmi_hal_ *hal); 93 hi_void (*hal_hdmi_hardware_status_get)(const struct hdmi_hal_ *hal, hdmi_hardware_status *hw_status); 94 hi_void (*hal_hdmi_hot_plug_status_get)(const struct hdmi_hal_ *hal, hi_bool *hot_plug); 95 hi_void (*hal_hdmi_hdp_intr_status_get)(const struct hdmi_hal_ *hal, hi_bool *intr_status); 96 hi_void (*hal_hdmi_audio_mute_set)(const struct hdmi_hal_ *hal, hi_bool audio_mute); 97 hi_s32 (*hal_hdmi_audio_path_set)(const struct hdmi_hal_ *hal, hdmi_audio_config *audio_cfg); 98 hi_s32 (*hal_hdmi_audio_n_cts_set)(const struct hdmi_hal_ *hal, hdmi_audio_ncts *audio_cfg); 99 hi_void (*hal_hdmi_audio_path_enable_set)(const struct hdmi_hal_ *hal, hi_bool enable); 100 hi_s32 (*hal_hdmi_edid_raw_data_read)(const struct hdmi_hal_ *hal, hi_u32 size, hi_u8 out_buffer[]); 101 hi_void (*hal_hdmi_phy_output_enable_get)(const struct hdmi_hal_ *hal, hi_bool *enable); 102 hi_void (*hal_hdmi_video_mute_set)(const struct hdmi_hal_ *hal, hi_bool video_mute); 103 hi_void (*hal_hdmi_black_data_set)(const struct hdmi_hal_ *hal, hdmi_black_frame_info *black_pram); 104 hi_void (*hal_hdmi_debug)(const struct hdmi_hal_ *hal, hdmi_debug_cmd debug_cmd, hi_void *data); 105 hi_u32 *(*hal_hdmi_base_addr_get)(const struct hdmi_hal_ *hal); 106 #ifdef HDMI_HDR_SUPPORT 107 hi_void (*hal_hdmi_hdr_timer_set)(const struct hdmi_hal_ *hal, hdmi_timer_config *timer_cfg); 108 #endif 109 #ifdef HDMI_SCDC_SUPPORT 110 hi_void (*hal_hdmi_scdc_config)(const struct hdmi_hal_ *hal, hdmi_scdc_config *scdc_config); 111 hi_void (*hal_hdmi_scdc_status_get)(const struct hdmi_hal_ *hal, hdmi_scdc_status *scdc_status); 112 hi_void (*hal_hdmi_scdc_status_set)(const struct hdmi_hal_ *hal, hdmi_scdc_status *scdc_status); 113 hi_s32 (*hal_hdmi_scdc_process)(const struct hdmi_hal_ *hal, scdc_cmd scdc_cmd, hi_void *data); 114 #endif 115 #ifdef HDMI_FRL_SUPPORT 116 hi_s32 (*hal_hdmi_frl_get_train_status)(const struct hdmi_hal_ *hal, hdmi_frl_train *frl_status); 117 hi_s32 (*hal_hdmi_frl_train_config)(const struct hdmi_hal_ *hal, hdmi_frl_train_config *frl_config); 118 hi_s32 (*hal_hdmi_frl_train_start)(const struct hdmi_hal_ *hal); 119 hi_s32 (*hal_hdmi_frl_enable)(const struct hdmi_hal_ *hal, hi_bool enable); 120 #endif 121 } hdmi_hal; 122 123 hi_s32 hal_hdmi_open(hdmi_hal_init *hal_init, hdmi_hal **hal_handle); 124 125 void hal_hdmi_close(hdmi_hal *hal); 126 127 #endif /* __HDMI_HAL_H__ */ 128 129