• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_EXT_H__
19 #define __HDMI_EXT_H__
20 
21 #include <hi_common.h>
22 
23 typedef enum {
24     HI_HDMI_DEV_ID_0,
25     HI_HDMI_DEV_ID_BUTT
26 } hdmi_dev_id;
27 
28 typedef enum {
29     HI_HDMI_COLORIMETRY_ITU601 = 1,              /* colorimetry ITU601 option */
30     HI_HDMI_COLORIMETRY_ITU709,                  /* colorimetry ITU709 option */
31     HI_HDMI_COLORIMETRY_2020_CONST_LUMINOUS = 9, /* colorimetry ITU2020 extended option */
32     HI_HDMI_COLORIMETRY_2020_NON_CONST_LUMINOUS  /* colorimetry ITU2020 extended option */
33 } hdmi_colorimetry;
34 
35 /* EOTF type */
36 typedef enum {
37     HI_HDMI_EOTF_SDR_LUMIN,     /* traditional gamma - SDR luminance range */
38     HI_HDMI_EOTF_HDR_LUMIN,     /* traditional gamma - HDR luminance range */
39     HI_HDMI_EOTF_SMPTE_ST_2048, /* SMPTE ST 2084 */
40     HI_HDMI_EOTF_HLG,           /* hybrid log-gamma(HLG) */
41     HI_HDMI_EOTF_BUTT
42 } hdmi_eote_type;
43 
44 /* metadata descriptor type(ID) */
45 typedef enum {
46     HI_HDMI_HDR_METADATA_ID_0, /* static metadata type 1 */
47     HI_HDMI_HDR_METADATA_ID_BUTT
48 } hdmi_hdr_metadata_id;
49 
50 /* static metadata descriptor type 1 */
51 typedef struct {
52     hi_u16 primaries0_x;        /* display_primaries_x[0], range[0,50000],in units of 0.00002 */
53     hi_u16 primaries0_y;        /* display_primaries_y[0], range[0,50000],in units of 0.00002 */
54     hi_u16 primaries1_x;        /* display_primaries_x[1], range[0,50000],in units of 0.00002 */
55     hi_u16 primaries1_y;        /* display_primaries_y[1], range[0,50000],in units of 0.00002 */
56     hi_u16 primaries2_x;        /* display_primaries_x[2], range[0,50000],in units of 0.00002 */
57     hi_u16 primaries2_y;        /* display_primaries_y[2], range[0,50000],in units of 0.00002 */
58     hi_u16 white_point_x;       /* white_point_x, range[0,50000], in units of 0.00002 */
59     hi_u16 white_point_y;       /* white_point_y, range[0,50000], in units of 0.00002 */
60     hi_u16 max_luminance;       /* max_display_mastering_luminance, in units of 1 cd/m^2 */
61     hi_u16 min_luminance;       /* min_display_mastering_luminance, in units of 0.0001 cd/m^2 */
62     hi_u16 max_light_level;     /* maximum content light level, in units of 1 cd/m^2 */
63     hi_u16 average_light_level; /* maximum frame-average light level, in units of 1 cd/m^2 */
64 } hdmi_meta_descirper_1st;
65 
66 /* static metadata descriptor type */
67 typedef union {
68     hdmi_meta_descirper_1st type1; /* static metadata descriptor type1 */
69 } hdmi_meta_descirper;
70 
71 /* HDR mode */
72 typedef enum {
73     HI_HDMI_HDR_MODE_DISABLE,          /* default.HDR & dolby mode disable */
74     HI_HDMI_HDR_MODE_DOLBY_NORMAL,     /* dolby normal(ycbcr422-12bit) mode enable */
75     HI_HDMI_HDR_MODE_DOLBY_TUNNELING,  /* dolby tunneling(RGB-8bit) mode enable */
76     HI_HDMI_HDR_MODE_CEA_861_3,        /* HDR standard mode enable(according to <CEA-861-3.2015>) */
77     HI_HDMI_HDR_MODE_CEA_861_3_AUTHEN, /* HDR authen mode */
78     HI_HDMI_HDR_MODE_BUTT
79 } hdmi_hdr_mode;
80 
81 /* HDR attribute */
82 typedef struct {
83     hdmi_hdr_mode        hdr_mode;
84     hdmi_eote_type       eotf_type;
85     hdmi_hdr_metadata_id metadata_id;
86     hdmi_meta_descirper  descriptor;
87     hdmi_colorimetry     colorimetry;
88 } hdmi_hdr_attr;
89 
90 typedef enum {
91     HI_HDMI_COLORSPACE_RGB,
92     HI_HDMI_COLORSPACE_YCBCR444 = 2,
93     HI_HDMI_COLORSPACE_BUTT
94 } hdmi_pixel_encoding;
95 
96 typedef enum {
97     HI_HDMI_QUANT_RANGE_LIMITED = 1,
98     HI_HDMI_QUANT_RANGE_FULL,
99     HI_HDMI_QUANT_RANGE_BUTT
100 } hdmi_quant_range;
101 
102 typedef struct {
103     hdmi_colorimetry colorimetry;  /* colorimetry from VDP */
104     hdmi_quant_range quantization; /* quantization from VDP */
105 } hdmi_csc_param;
106 
107 typedef struct {
108     hdmi_pixel_encoding pixel_encoding; /* pixel_encoding from VDP */
109 } hdmi_video_param;
110 
111 /* initial and exit service of hdmi module, called by SYS & VO module */
112 typedef hi_u32 fn_hdmi_init(hi_void);
113 typedef hi_u32 fn_hdmi_exit(hi_void);
114 typedef hi_s32 (*fn_hdmi_stop)(hdmi_dev_id hdmi);
115 typedef hi_s32 (*fn_hdmi_set_hdr_attr)(hdmi_dev_id hdmi, const hdmi_hdr_attr *hdr_attr);
116 typedef hi_s32 (*fn_hdmi_set_csc_param)(hdmi_dev_id hdmi, const hdmi_csc_param *csc_param);
117 typedef hi_s32 (*fn_hdmi_set_video_param)(hdmi_dev_id hdmi, const hdmi_video_param *video_param);
118 
119 typedef struct {
120     fn_hdmi_init           *pfn_init;
121     fn_hdmi_exit           *pfn_exit;
122     fn_hdmi_stop            pfn_stop;
123     fn_hdmi_set_hdr_attr    pfn_set_hdr_attr;
124     fn_hdmi_set_csc_param   pfn_csc_param_set;
125     fn_hdmi_set_video_param pfn_video_param_set;
126 } hdmi_export_func;
127 
128 #define ckfn_hdmi_entry() check_func_entry(HI_ID_HDMI)
129 
130 #define ckfn_hdmi_init() (func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_init != NULL)
131 
132 #define call_hdmi_init() func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_init()
133 
134 #define ckfn_hdmi_deinit() (func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_exit != NULL)
135 
136 #define call_hdmi_deinit() func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_exit()
137 
138 #define ckfn_hdmi_stop(hdmi) (func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_stop != NULL)
139 
140 #define call_hdmi_stop(hdmi) func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_stop(hdmi)
141 
142 #define ckfn_hdmi_set_hdr_attr(hdmi, hdr_attr) (func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_set_hdr_attr != NULL)
143 
144 #define call_hdmi_set_hdr_attr(hdmi, hdr_attr) \
145     func_entry(hdmi_export_func, HI_ID_HDMI)->pfn_set_hdr_attr(hdmi, hdr_attr)
146 
147 #endif /* __HDMI_EXT_H__ */
148 
149