You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
9.8 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2019. All rights reserved.
* Description: hdmi driver main header file
* Author: Hisilicon
* Create: 2019-06-22
*/
#ifndef __DRV_HDMITX_H__
#define __DRV_HDMITX_H__
#include <td_type.h>
#include "osal_ext.h"
#include "drv_hdmitx_ext.h"
#include "drv_repeater_dip.h"
#include "drv_ao_dip.h"
#include "drv_hdmitx_common.h"
#include "drv_hdmitx_infoframe.h"
/* switch mode define */
#define HDMITX_SWITCH_MODE_TMDS_2_TMDS 0
#define HDMITX_SWITCH_MODE_TMDS_2_FRL 1
#define HDMITX_SWITCH_MODE_FRL_2_TMDS 2
#define HDMITX_SWITCH_MODE_FRL_2_FRL 3
struct ext_hdmitx;
struct avi_infoframe {
td_bool enable;
struct hdmitx_avi_infoframe avi;
};
struct hf14_vsif_infoframe {
td_bool enable;
struct hdmitx_vendor_infoframe hf14;
};
struct dolby_vsif_infoframe {
td_bool enable;
struct hdmitx_dolby_vendor_infoframe dolby;
};
struct cuva_monitor_vsif_infoframe {
td_bool enable;
struct hdmitx_cuva_monitor_vsif cuva_monitor;
};
struct hf_vsif_infoframe {
td_bool enable;
struct hdmitx_forum_vendor_infoframe hf_vsif;
};
struct drm_infoframe {
td_u32 drm_type;
struct hdmitx_drm_infoframe drm;
};
struct vrr_infoframe {
td_bool enable;
struct hdmitx_vt_ext_metadata vrr;
};
struct cuva_hdr_infoframe {
td_bool enable;
struct hdmitx_cuva_hdr_ext_metadata cuva;
};
struct hdmitx_infoframe {
/* avi infoframe */
struct avi_infoframe avi_info;
/* vendor infoframe */
struct hf14_vsif_infoframe hf14_vsif; /* for hdmi1.4 or dolby vision v2 */
struct hf_vsif_infoframe hf_vsif; /* for allm */
struct dolby_vsif_infoframe dolby_vsif; /* for dolby vision v3 */
struct drm_infoframe drm_info;
struct vrr_infoframe vrr_info;
struct cuva_hdr_infoframe cuva_hdr_info;
struct cuva_monitor_vsif_infoframe cuva_monitor_info;
};
/*
* @attach: This callback function is used when bind a vo to a display interface
* @dettach: This callback function is used when unbind a vo with a display interface
* @mode_validate: This called is used to validate the if the mode is supported by the interface or not
* before setting the display mode.
* @prepare: This callback should prepare the display interface for a subsequent modeset
* @mode_set: This callback is used to update the display mode of an display interface.
* @display_on: This callback is used to turn on the interface signal to the display
* @display_off: This callback is used to turn off the interface signal to the display
*/
struct hdmitx_vo_ops {
td_void (*suspend)(struct ext_hdmitx *dev, td_bool lower_power);
td_s32 (*resume)(struct ext_hdmitx *dev, td_bool lower_power);
td_s32 (*attach)(const struct ext_hdmitx *dev, const td_void *data);
td_s32 (*detach)(const struct ext_hdmitx *dev, const td_void *data);
td_s32 (*mode_validate)(const struct ext_hdmitx *dev, td_u32 mode, struct ext_display_mode *dispaly_mode);
td_s32 (*prepare)(struct ext_hdmitx *dev, td_u32 mode, struct ext_display_mode *dispaly_mode);
td_s32 (*mode_set)(struct ext_hdmitx *dev, td_u32 mode);
td_s32 (*atomic_mode_set)(const struct ext_hdmitx *dev, td_u32 mode,
const struct ext_display_mode *dispaly_mode);
td_s32 (*display_on)(const struct ext_hdmitx *dev);
td_s32 (*display_off)(struct ext_hdmitx *dev);
};
struct hdmitx_ao_ops {
/* get sink's audio capability */
td_s32 (*get_eld)(const struct ext_hdmitx *dev, const td_void *data, td_u8 *buf, td_size_t len);
/* check audio attr valid */
td_s32 (*hw_params_validate)(const struct ext_hdmitx *dev, const struct ao_attr *attr);
/* set audio attr */
td_s32 (*hw_params)(const struct ext_hdmitx *dev, const struct ao_attr *attr);
/* mute hdmi audio */
td_s32 (*digital_mute)(const struct ext_hdmitx *dev, const td_void *data, td_bool enable);
/* detect hdmi hotplug status */
td_s32 (*hpd_detect)(const struct ext_hdmitx *dev, td_u32 *status);
/* used to received audio interface broadcast msg */
td_s32 (*register_notifier)(struct ext_hdmitx *dev, struct hdmitx_notifier *notifier);
td_s32 (*unregister_notifier)(struct ext_hdmitx *dev, const struct hdmitx_notifier *notifier);
};
struct ext_hdmitx {
td_u32 id;
td_u32 version;
osal_dev hdmitx_dev; /* This is for IOCTL */
td_bool attached; /* whether the hdmi is attached */
td_s8 name[16]; /* name max size is 16. */
struct hdmitx_phy *phy; /* Phy reference */
struct hdmitx_controller *controller;
struct hdmitx_crg *crg;
struct hdmitx_notifier_head notifier_list; /* Notifier head, now only for ao */
osal_mutex notifier_mutex;
osal_mutex disp_mutex;
struct hdmitx_vo_ops *vo_ops;
struct hdmitx_ao_ops *ao_ops;
td_bool is_suspend;
td_bool is_start_output;
osal_delayedwork work_compat_hdr;
struct hdmitx_infoframe per_infoframe;
struct hdmitx_infoframe cur_infoframe;
osal_semaphore ioctl_mutex;
};
/*
* hdmi source capability -caps
* bit0: cec_support 0: no support; 1: support.
* bit1: hdcp14_support 0: no support; 1: support.
* bit2: hdcp2x_support 0: no support; 1: support.
* bit3: dvi_support 0: no support; 1: support.
* bit4: hdmi_support 0: no support; 1: support.
* bit5: max_tmds_clock 0: 340M; 1: 600M.
* bit6: scdc_present 0: no support; 1: support.
* bit7: scdc_lte_340mcsc 0: no support; 1: support.
* bit8: bpc_30 0: no support; 1: support.
* bit9: bpc_36 0: no support; 1: support.
* bit10: bpc_48 0: no support; 1: support.
* bit11-14: max_frl_rate 0: no support; 1: 3G3L; 2: 6G3L; 3: 6G4L;
* 4: 8G4L; 5: 10G4L; 6: 12G4L; [7~15]: RESVER.
* bit15-17: ffe_levels 0: FFE0; 1: FFE1; 2: FFE2; 3: FFE3; [4~7]: RESVER.
* bit18: dsc_support 0: no support; 1: support;
* bit19: native_y420 0: no support; 1: support;
* bit20: dsc_10bpc 0: no support; 1: support;
* bit21: dsc_12bpc 0: no support; 1: support;
* bit22-25: max_slice_count 0: no support; 1: 1 slices; 2: 2 slices;
* 3: 4 slices; 4: 8 slices; 5: 12 slices;
* 6: 16 slices; [7~15]: RESVER.
* bit26-27: max_pixel_clk_per_slice 0: 340; 1: 400; [2~3]: RESVER.
* bit28: rgb2yuv 0: no support; 1: support.
* bit29: ycbcr444 0: no support; 1: support.
* bit30: ycbcr422 0: no support; 1: support.
* bit31: ycbcr420 0: no support; 1: support.
*/
/* bit0: cec */
#define CEC_SUPPORT_MASK (1 << 0)
#define CEC_SUPPORT_SHIFT 0
/* bit1~2:hdcp */
#define HDCP14_SUPPORT_MASK (1 << 1)
#define HDCP14_SUPPORT_SHIFT 1
#define HDCP2X_SUPPORT_MASK (1 << 2)
#define HDCP2X_SUPPORT_SHIFT 2
/* bit3~5:tmds */
#define DVI_SUPPORT_MASK (1 << 3)
#define DVI_SUPPORT_SHIFT 3
#define HDMITX_SUPPORT_MASK (1 << 4)
#define HDMI_SUPPORT_SHIFT 4
#define MAX_TMDS_CLOCK_MASK (1 << 5)
#define MAX_TMDS_CLOCK_SHIFT 5
/* bit6~7:scdc */
#define SCDC_PRESENT_MASK (1 << 6)
#define SCDC_PRESENT_SHIFT 6
#define SCDC_LTE_340MCSC_MASK (1 << 7)
#define SCDC_LTE_340MCSC_SHIFT 7
/* bit8~10:deepcolor */
#define BPC_30_MASK (1 << 8)
#define BPC_30_SHIFT 8
#define BPC_36_MASK (1 << 9)
#define BPC_36_SHIFT 9
#define BPC_48_MASK (1 << 10)
#define BPC_48_SHIFT 10
/* bit11~17:frl */
#define MAX_FRL_RATE_MASK (0xf << 11)
#define MAX_FRL_RATE_SHIFT 11
#define FFE_LEVELS_MASK (0x7 << 15)
#define FFE_LEVELS_SHIFT 15
/* bit18~27:dsc */
#define DSC_SUPPORT_MASK (1 << 18)
#define DSC_SUPPORT_SHIFT 18
#define NATIVE_Y420_MASK (1 << 19)
#define NATIVE_Y420_SHIFT 19
#define DSC_10BPC_MASK (1 << 20)
#define DSC_10BPC_SHIFT 20
#define DSC_12BPC_MASK (1 << 21)
#define DSC_12BPC_SHIFT 21
#define MAX_SLICE_COUNT_MASK (0xf << 22)
#define MAX_SLICE_COUNT_SHIFT 22
#define MAX_PIXEL_CLK_PER_SLICE_MASK (0x3 << 26)
#define MAX_PIXEL_CLK_PER_SLICE_SHIFT 26
/* bit28~31:csc */
#define RGB2YUV_MASK (1 << 28)
#define RGB2YUV_SHIFT 28
#define YCBCR444_MASK (1 << 29)
#define YCBCR444_SHIFT 29
#define YCBCR422_MASK (1 << 30)
#define YCBCR422_SHIFT 30
#define YCBCR420_MASK (1 << 31)
#define YCBCR420_SHIFT 31
/*
* hdmi source capability 2 -caps2
* bit0: yuv2rgb 0: no support; 1: support.
* bit1: dither_support 0: no support; 1: support.
* bit2-5: max_pixel_clock 0: 340M; 1: 600M; 2: 1188M; 3: 2376M;
* 4: 4752M; [5~15]: RESVER.
* bit6: vrr_support 0: no support; 1: support.
* bit7: cuva_support 0: no support; 1: support.
* bit8-31: reserved.
*/
/* bit0~1: csc */
#define YUV2RGB_MASK (1 << 0)
#define YUV2RGB_SHIFT 0
#define DITHER_SUPPORT_MASK (1 << 1)
#define DITHER_SUPPORT_SHIFT 1
/* bit2-5: max_pixel_clock */
#define MAX_PIXEL_CLOCK_MASK (0xf << 2)
#define MAX_PIXEL_CLOCK_SHIFT 2
/* bit6: vrr_support */
#define VRR_MASK (1 << 6)
#define VRR_SHIFT 6
/* bit7: cuva_support */
#define CUVA_MASK (1 << 7)
#define CUVA_SHIFT 7
#define HDMITX_PROTOCAL_VERSION_1_4 0x1
#define HDMITX_PROTOCAL_VERSION_2_0 0x2
#define HDMITX_PROTOCAL_VERSION_2_1 0x3
td_void hdmi_sysfs_event(osal_dev *hdmitx_dev, td_char *event, td_u32 size);
td_s32 hdmi_phy_fcg_set(const struct ext_hdmitx *hdmi);
td_void hdmi_crg_set(const struct ext_hdmitx *hdmi);
td_void hdmi_ao_notifiers(struct ext_hdmitx *hdmi, td_u32 val);
td_void drv_hdmitx_disp_event(struct ext_hdmitx *hdmi, ext_drv_rpt_tx_event event);
td_s32 hdmitx_set_phy_cross_en(td_bool enable);
#endif