mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
hdr: correct hdr10+ process path [1/1]
PD#SWPL-16139 Problem: 1. hdr10+ gen ebz curve error 2. hdr10+ process error Solution: 1. fix hdr10+ ebz gen 2. correct hdr10+ process path Verify: verify on TL1 Change-Id: Ia33488ada2e0ebfe9b156f9f667188cf02164089 Signed-off-by: MingLiang Dong <mingliang.dong@amlogic.com>
This commit is contained in:
@@ -664,6 +664,14 @@ static uint customer_master_display_param[12] = {
|
||||
/* content lumin and frame average */
|
||||
};
|
||||
|
||||
static int customer_panel_lumin = 380;
|
||||
module_param(customer_panel_lumin, int, 0664);
|
||||
MODULE_PARM_DESC(customer_panel_lumin, "\n customer_panel_lumin\n");
|
||||
|
||||
int customer_hdr_clipping;
|
||||
module_param(customer_hdr_clipping, int, 0664);
|
||||
MODULE_PARM_DESC(customer_hdr_clipping, "\n customer_hdr_clipping\n");
|
||||
|
||||
module_param(customer_matrix_en, bool, 0664);
|
||||
MODULE_PARM_DESC(customer_matrix_en, "\n if enable customer matrix\n");
|
||||
|
||||
@@ -4679,6 +4687,23 @@ static void vpp_lut_curve_set(enum vpp_lut_sel_e lut_sel,
|
||||
CSC_ON);
|
||||
}
|
||||
}
|
||||
|
||||
static int hdr10p_process(
|
||||
struct vinfo_s *vinfo,
|
||||
struct vframe_master_display_colour_s *master_info,
|
||||
enum vd_path_e vd_path)
|
||||
{
|
||||
if (get_cpu_type() >= MESON_CPU_MAJOR_ID_G12A) {
|
||||
hdr_func(OSD1_HDR, HDR_BYPASS, vinfo);
|
||||
if (vd_path == VD1_PATH)
|
||||
hdr10p_func(VD1_HDR, HDR10P_SDR, vinfo);
|
||||
else
|
||||
hdr10p_func(VD2_HDR, HDR10P_SDR, vinfo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hdr_process(
|
||||
enum vpp_matrix_csc_e csc_type,
|
||||
struct vinfo_s *vinfo,
|
||||
@@ -6381,6 +6406,12 @@ static int sink_support_hlg(const struct vinfo_s *vinfo)
|
||||
|
||||
static int sink_support_hdr10_plus(const struct vinfo_s *vinfo)
|
||||
{
|
||||
/* panel output and TL1 and TM2 */
|
||||
if ((vinfo->viu_color_fmt == COLOR_FMT_RGB444) &&
|
||||
((get_cpu_type() == MESON_CPU_MAJOR_ID_TL1) ||
|
||||
(get_cpu_type() == MESON_CPU_MAJOR_ID_TM2)))
|
||||
return 1;
|
||||
/* hdmi */
|
||||
if ((vinfo->hdr_info.hdr10plus_info.ieeeoui
|
||||
== 0x90848B) &&
|
||||
(vinfo->hdr_info.hdr10plus_info.application_version
|
||||
@@ -6415,11 +6446,13 @@ static enum hdr_type_e get_source_type(enum vd_path_e vd_path)
|
||||
return HDRTYPE_HLG;
|
||||
else if ((signal_transfer_characteristic == 0x30) &&
|
||||
(signal_color_primaries == 9)) {
|
||||
if (sink_support_hdr10_plus(get_current_vinfo()))
|
||||
if (sink_support_hdr10_plus(get_current_vinfo()) &&
|
||||
(vd_path == VD1_PATH))
|
||||
return HDRTYPE_HDR10PLUS;
|
||||
else
|
||||
return HDRTYPE_HDR10;
|
||||
} else if ((signal_transfer_characteristic == 16) ||
|
||||
} else if (
|
||||
(signal_transfer_characteristic == 16) ||
|
||||
(signal_color_primaries == 9))
|
||||
return HDRTYPE_HDR10;
|
||||
else
|
||||
@@ -6455,19 +6488,18 @@ bool is_video_layer_on(enum vd_path_e vd_path)
|
||||
video_layer_wait_on[vd_path];
|
||||
}
|
||||
|
||||
static void hdr10_plus_metadata_update(struct vframe_s *vf,
|
||||
static bool hdr10_plus_metadata_update(
|
||||
struct vframe_s *vf,
|
||||
enum vpp_matrix_csc_e csc_type,
|
||||
struct hdr10plus_para *p)
|
||||
{
|
||||
if (!vf)
|
||||
return;
|
||||
return false;
|
||||
if (csc_type != VPP_MATRIX_BT2020YUV_BT2020RGB_DYNAMIC)
|
||||
return;
|
||||
return false;
|
||||
|
||||
hdr10_plus_parser_metadata(vf);
|
||||
|
||||
hdr10_plus_ootf_gen();
|
||||
|
||||
if (tx_hdr10_plus_support) {
|
||||
hdr10_plus_hdmitx_vsif_parser(p, vf);
|
||||
pr_csc(0x10,
|
||||
@@ -6501,8 +6533,21 @@ static void hdr10_plus_metadata_update(struct vframe_s *vf,
|
||||
((p->graphics_overlay_flag & 0x1) << 7) |
|
||||
((p->no_delay_flag & 0x1) << 6));
|
||||
}
|
||||
//TODO: return false if meta not changed
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct hdr10pgen_param_s hdr10pgen_param;
|
||||
void hdr10_plus_process_update(int force_source_lumin)
|
||||
{
|
||||
hdr10_plus_ootf_gen(
|
||||
customer_panel_lumin,
|
||||
force_source_lumin,
|
||||
&hdr10pgen_param);
|
||||
hdr10p_ebzcurve_update(VD1_HDR, HDR10P_SDR, &hdr10pgen_param);
|
||||
}
|
||||
EXPORT_SYMBOL(hdr10_plus_process_update);
|
||||
|
||||
static struct hdr10plus_para hdmitx_hdr10plus_params[VD_PATH_MAX];
|
||||
static int hdr10_plus_pkt_update;
|
||||
static bool hdr10_plus_pkt_on;
|
||||
@@ -6971,7 +7016,7 @@ static void video_process(
|
||||
VPP_MATRIX_BT2020YUV_BT2020RGB_DYNAMIC)) {
|
||||
// TODO: hdr10_plus_process(vf, mode, vd_path);
|
||||
if (hdr10_plus_process_mode[vd_path] == PROC_MATCH) {
|
||||
hdr_process(csc_type, vinfo, p, vd_path);
|
||||
hdr10p_process(vinfo, p, vd_path);
|
||||
/* hdr10_plus_process(vf); */
|
||||
} else {
|
||||
bypass_hdr_process(
|
||||
@@ -7220,9 +7265,17 @@ static int vpp_matrix_update(
|
||||
}
|
||||
|
||||
if ((vf != NULL) && (flags & CSC_FLAG_TOGGLE_FRAME)) {
|
||||
hdr10_plus_metadata_update(vf, csc_type,
|
||||
hdr10p_meta_updated = hdr10_plus_metadata_update(
|
||||
vf, csc_type,
|
||||
&hdmitx_hdr10plus_params[vd_path]);
|
||||
hdr10p_meta_updated = true;
|
||||
|
||||
if ((csc_type == VPP_MATRIX_BT2020YUV_BT2020RGB_DYNAMIC) ||
|
||||
(csc_type == VPP_MATRIX_BT2020YUV_BT2020RGB)) {
|
||||
if ((vd_path == VD1_PATH) &&
|
||||
(cpu_after_eq(MESON_CPU_MAJOR_ID_G12A)))
|
||||
get_hist(VD1_HDR, HIST_O_BEFORE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cpu_after_eq(MESON_CPU_MAJOR_ID_G12A)) {
|
||||
@@ -7270,6 +7323,10 @@ static int vpp_matrix_update(
|
||||
cur_hdr_policy = get_hdr_policy();
|
||||
}
|
||||
|
||||
if (hdr10p_meta_updated &&
|
||||
hdr10_plus_process_mode[vd_path] == PROC_MATCH)
|
||||
hdr10_plus_process_update(0);
|
||||
|
||||
/* eye protection mode */
|
||||
if (signal_change_flag & SIG_WB_CHG)
|
||||
vpp_eye_protection_process(csc_type, vinfo, vd_path);
|
||||
|
||||
@@ -232,5 +232,8 @@ extern void send_hdr10_plus_pkt(enum vd_path_e vd_path);
|
||||
#define HDRPLUS_PKT_REPEAT 1
|
||||
#define HDRPLUS_PKT_IDLE 0
|
||||
|
||||
void hdr10_plus_process_update(int force_source_lumin);
|
||||
extern int customer_hdr_clipping;
|
||||
|
||||
#endif /* AM_CSC_H */
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ static const char *module_str[7] = {
|
||||
"DI"
|
||||
};
|
||||
|
||||
static const char *process_str[15] = {
|
||||
static const char *process_str[16] = {
|
||||
"UNKNOWN",
|
||||
"HDR_BYPASS",
|
||||
"HDR_SDR",
|
||||
@@ -52,7 +52,8 @@ static const char *process_str[15] = {
|
||||
"HDR_HLG",
|
||||
"RGB_YUV",
|
||||
"RGB_HDR",
|
||||
"RGB_HLG"
|
||||
"RGB_HLG",
|
||||
"HDR10P_SDR"
|
||||
};
|
||||
|
||||
static const char *policy_str[3] = {
|
||||
@@ -865,6 +866,8 @@ static void prepare_hdr_info(
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int content_max_lumin[VD_PATH_MAX];
|
||||
|
||||
void hdmi_packet_process(
|
||||
int signal_change_flag,
|
||||
struct vinfo_s *vinfo,
|
||||
@@ -876,6 +879,15 @@ void hdmi_packet_process(
|
||||
struct master_display_info_s send_info;
|
||||
enum output_format_e cur_output_format = output_format;
|
||||
|
||||
if (customer_hdr_clipping)
|
||||
content_max_lumin[vd_path] =
|
||||
customer_hdr_clipping;
|
||||
else if (p && p->luminance[0])
|
||||
content_max_lumin[vd_path] =
|
||||
p->luminance[0] / 10000;
|
||||
else
|
||||
content_max_lumin[vd_path] = 1250;
|
||||
|
||||
if (!vinfo)
|
||||
return;
|
||||
if (!vinfo->vout_device) {
|
||||
@@ -1067,10 +1079,13 @@ void video_post_process(
|
||||
hdr_proc(VD2_HDR, HDR_BYPASS, vinfo);
|
||||
hdr_proc(OSD1_HDR, SDR_HDR, vinfo);
|
||||
} else if (hdr_process_mode[vd_path] == PROC_HDR_TO_SDR) {
|
||||
if (vd_path == VD1_PATH)
|
||||
if (vd_path == VD1_PATH) {
|
||||
hdr_proc(VD1_HDR, HDR_SDR, vinfo);
|
||||
else
|
||||
hdr10_plus_process_update(
|
||||
content_max_lumin[vd_path]);
|
||||
} else {
|
||||
hdr_proc(VD2_HDR, HDR_SDR, vinfo);
|
||||
}
|
||||
hdr_proc(OSD1_HDR, HDR_BYPASS, vinfo);
|
||||
} else if (hdr_process_mode[vd_path] == PROC_HDR_TO_HLG) {
|
||||
if (vd_path == VD1_PATH)
|
||||
@@ -1124,9 +1139,9 @@ void video_post_process(
|
||||
} else if (hdr10_plus_process_mode[vd_path] ==
|
||||
PROC_HDRP_TO_SDR) {
|
||||
if (vd_path == VD1_PATH)
|
||||
hdr_proc(VD1_HDR, HDR_SDR, vinfo);
|
||||
hdr_proc(VD1_HDR, HDR10P_SDR, vinfo);
|
||||
else
|
||||
hdr_proc(VD2_HDR, HDR_SDR, vinfo);
|
||||
hdr_proc(VD2_HDR, HDR10P_SDR, vinfo);
|
||||
hdr_proc(OSD1_HDR, HDR_BYPASS, vinfo);
|
||||
} else if (hdr10_plus_process_mode[vd_path] ==
|
||||
PROC_HDRP_TO_HLG) {
|
||||
|
||||
@@ -96,6 +96,7 @@ extern struct am_regs_s r_lut_hdr_sdr_level3;
|
||||
#define VD1_HDR2_PROC_WIN2 0x383a
|
||||
#define VD1_HDR2_MATRIXI_EN_CTRL 0x383b
|
||||
#define VD1_HDR2_MATRIXO_EN_CTRL 0x383c
|
||||
#define VD1_HDR2_HIST_CTRL 0x383d
|
||||
|
||||
#define VD2_HDR2_CTRL 0x3850
|
||||
#define VD2_HDR2_CLK_GATE 0x3851
|
||||
|
||||
@@ -136,6 +136,8 @@ void parser_hdr10_plus_medata(char *metadata, uint32_t size)
|
||||
unsigned int num_bezier_curve_anchors = 0;
|
||||
unsigned int color_saturation_mapping_flag = 0;
|
||||
|
||||
memset(&hdr_plus_sei, 0, sizeof(struct vframe_hdr_plus_sei));
|
||||
|
||||
GetBits(metadata, totbitoffset,
|
||||
&value, size, sei_md_bits.len_itu_t_t35_country_code);
|
||||
hdr_plus_sei.itu_t_t35_country_code = (u16)value;
|
||||
@@ -506,69 +508,142 @@ static void hdr10_plus_vf_md_parse(struct vframe_s *vf)
|
||||
|
||||
hdr10p_md_param.application_version =
|
||||
vf->prop.hdr10p_data.pb4_st.app_ver;
|
||||
pr_hdr("vf:app_ver = 0x%x\n", vf->prop.hdr10p_data.pb4_st.app_ver);
|
||||
|
||||
hdr10p_md_param.targeted_max_lum =
|
||||
vf->prop.hdr10p_data.pb4_st.max_lumin;
|
||||
pr_hdr(
|
||||
"vf:target_max_lumin = 0x%x\n",
|
||||
vf->prop.hdr10p_data.pb4_st.max_lumin);
|
||||
|
||||
hdr10p_md_param.average_maxrgb =
|
||||
vf->prop.hdr10p_data.average_maxrgb;
|
||||
pr_hdr(
|
||||
"vf:average_maxrgb = 0x%x\n",
|
||||
vf->prop.hdr10p_data.average_maxrgb);
|
||||
|
||||
/*distribution value*/
|
||||
memcpy(&hdr10p_md_param.distribution_values[0],
|
||||
&vf->prop.hdr10p_data.distrib_valus0,
|
||||
sizeof(uint8_t) * 9);
|
||||
for (i = 0; i < 9; i++)
|
||||
pr_hdr(
|
||||
"vf:hdr10p_md_param.distribution_values[%d] = 0x%x\n",
|
||||
i, hdr10p_md_param.distribution_values[i]);
|
||||
|
||||
hdr10p_md_param.num_bezier_curve_anchors =
|
||||
vf->prop.hdr10p_data.pb15_18_st.num_bezier_curve_anchors;
|
||||
pr_hdr(
|
||||
"vf:num_bezier_curve_anchors = 0x%x\n",
|
||||
vf->prop.hdr10p_data.pb15_18_st.num_bezier_curve_anchors);
|
||||
|
||||
/*if (!hdr10p_md_param.num_bezier_curve_anchors) {*/
|
||||
/* hdr10p_md_param.num_bezier_curve_anchors = 9;*/
|
||||
/* pr_hdr("hdr10p_md_param.num_bezier_curve_anchors = 0\n");*/
|
||||
/*}*/
|
||||
|
||||
hdr10p_md_param.knee_point_x =
|
||||
(vf->prop.hdr10p_data.pb15_18_st.knee_point_x_9_6 << 6) |
|
||||
vf->prop.hdr10p_data.pb15_18_st.knee_point_x_5_0;
|
||||
pr_hdr(
|
||||
"vf:knee_point_x_5_0 = 0x%x, knee_point_x_9_6 = 0x%x\n",
|
||||
vf->prop.hdr10p_data.pb15_18_st.knee_point_x_5_0,
|
||||
vf->prop.hdr10p_data.pb15_18_st.knee_point_x_9_6);
|
||||
|
||||
hdr10p_md_param.knee_point_y =
|
||||
(vf->prop.hdr10p_data.pb15_18_st.knee_point_y_9_8 << 8) |
|
||||
vf->prop.hdr10p_data.pb15_18_st.knee_point_y_7_0;
|
||||
pr_hdr(
|
||||
"vf:knee_point_y_7_0 = 0x%x, knee_point_y_9_8 = 0x%x\n",
|
||||
vf->prop.hdr10p_data.pb15_18_st.knee_point_y_7_0,
|
||||
vf->prop.hdr10p_data.pb15_18_st.knee_point_y_9_8);
|
||||
|
||||
/*bezier curve*/
|
||||
hdr10p_md_param.bezier_curve_anchors[0] =
|
||||
vf->prop.hdr10p_data.pb15_18_st.bezier_curve_anchors0;
|
||||
|
||||
memcpy(&hdr10p_md_param.bezier_curve_anchors[1],
|
||||
&vf->prop.hdr10p_data.bezier_curve_anchors1,
|
||||
sizeof(uint8_t) * 8);
|
||||
for (i = 0; i < 9; i++)
|
||||
pr_hdr(
|
||||
"vf:hdr10p_md_param.bezier_curve_anchors[%d] = 0x%x\n",
|
||||
i, hdr10p_md_param.bezier_curve_anchors[i]);
|
||||
|
||||
hdr10p_md_param.graphics_overlay_flag =
|
||||
vf->prop.hdr10p_data.pb27_st.overlay_flag;
|
||||
hdr10p_md_param.no_delay_flag =
|
||||
vf->prop.hdr10p_data.pb27_st.no_delay_flag;
|
||||
pr_hdr(
|
||||
"vf:overlay_flag = 0x%x\n",
|
||||
vf->prop.hdr10p_data.pb27_st.overlay_flag);
|
||||
pr_hdr(
|
||||
"vf:no_delay_flag = 0x%x\n",
|
||||
vf->prop.hdr10p_data.pb27_st.no_delay_flag);
|
||||
|
||||
|
||||
hdr_plus_sei.application_identifier =
|
||||
hdr10p_md_param.application_version;
|
||||
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.application_identifier = %d\n",
|
||||
hdr_plus_sei.application_identifier);
|
||||
|
||||
/*hdr10 plus default one window*/
|
||||
hdr_plus_sei.num_windows = 1;
|
||||
|
||||
hdr_plus_sei.tgt_sys_disp_max_lumi =
|
||||
hdr10p_md_param.targeted_max_lum << 5;
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.tgt_sys_disp_max_lumi = %d\n",
|
||||
hdr_plus_sei.tgt_sys_disp_max_lumi);
|
||||
|
||||
hdr_plus_sei.average_maxrgb[0] =
|
||||
hdr10p_md_param.average_maxrgb << 4;
|
||||
(hdr10p_md_param.average_maxrgb << 4) * 10;
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.average_maxrgb[0] = %d\n",
|
||||
hdr_plus_sei.average_maxrgb[0]);
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
if (i == 2) {
|
||||
hdr_plus_sei.distribution_maxrgb_percentiles[0][2] =
|
||||
hdr10p_md_param.distribution_values[2];
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.distribution_maxrgb_percentiles[0][%d] = %d\n",
|
||||
i, hdr_plus_sei.distribution_maxrgb_percentiles[0][i]);
|
||||
continue;
|
||||
}
|
||||
hdr_plus_sei.distribution_maxrgb_percentiles[0][i] =
|
||||
(hdr10p_md_param.distribution_values[i] << 4) * 10;
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.distribution_maxrgb_percentiles[0][%d] = %d\n",
|
||||
i, hdr_plus_sei.distribution_maxrgb_percentiles[0][i]);
|
||||
}
|
||||
|
||||
hdr_plus_sei.num_bezier_curve_anchors[0] =
|
||||
hdr10p_md_param.num_bezier_curve_anchors;
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.num_bezier_curve_anchors[0] = %d\n",
|
||||
hdr_plus_sei.num_bezier_curve_anchors[0]);
|
||||
|
||||
hdr_plus_sei.knee_point_x[0] =
|
||||
hdr10p_md_param.knee_point_x << 2;
|
||||
hdr_plus_sei.knee_point_y[0] =
|
||||
hdr10p_md_param.knee_point_y << 2;
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.knee_point_x[0] = %d\n",
|
||||
hdr_plus_sei.knee_point_x[0]);
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.knee_point_y[0] = %d\n",
|
||||
hdr_plus_sei.knee_point_y[0]);
|
||||
|
||||
for (i = 0; i < 9; i++)
|
||||
for (i = 0; i < 9; i++) {
|
||||
hdr_plus_sei.bezier_curve_anchors[0][i] =
|
||||
hdr10p_md_param.bezier_curve_anchors[i] << 2;
|
||||
pr_hdr(
|
||||
"hdr_plus_sei.bezier_curve_anchors[0][%d] = %d\n",
|
||||
i, hdr_plus_sei.bezier_curve_anchors[0][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
if (hdr_plus_sei.bezier_curve_anchors[0][i] != 0) {
|
||||
@@ -624,6 +699,9 @@ void hdr10_plus_parser_metadata(struct vframe_s *vf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_hdr >= 1)
|
||||
debug_hdr--;
|
||||
}
|
||||
|
||||
struct hdr10plus_para dbg_hdr10plus_pkt;
|
||||
@@ -780,57 +858,50 @@ void hdr10_plus_hdmitx_vsif_parser(
|
||||
sizeof(struct hdr10plus_para));
|
||||
}
|
||||
|
||||
void hdr10_plus_process(struct vframe_s *vf)
|
||||
{
|
||||
if (!vf)
|
||||
return;
|
||||
hdr10_plus_ootf_gen();
|
||||
}
|
||||
|
||||
void hdr10_plus_debug(void)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
pr_hdr("itu_t_t35_country_code = 0x%x\n",
|
||||
pr_info("itu_t_t35_country_code = 0x%x\n",
|
||||
hdr_plus_sei.itu_t_t35_country_code);
|
||||
pr_hdr("itu_t_t35_terminal_provider_code = 0x%x\n",
|
||||
pr_info("itu_t_t35_terminal_provider_code = 0x%x\n",
|
||||
hdr_plus_sei.itu_t_t35_terminal_provider_code);
|
||||
pr_hdr("itu_t_t35_terminal_provider_oriented_code = 0x%x\n",
|
||||
pr_info("itu_t_t35_terminal_provider_oriented_code = 0x%x\n",
|
||||
hdr_plus_sei.itu_t_t35_terminal_provider_oriented_code);
|
||||
pr_hdr("application_identifier = 0x%x\n",
|
||||
pr_info("application_identifier = 0x%x\n",
|
||||
hdr_plus_sei.application_identifier);
|
||||
pr_hdr("application_version = 0x%x\n",
|
||||
pr_info("application_version = 0x%x\n",
|
||||
hdr_plus_sei.application_version);
|
||||
pr_hdr("num_windows = 0x%x\n",
|
||||
pr_info("num_windows = 0x%x\n",
|
||||
hdr_plus_sei.num_windows);
|
||||
for (i = 1; i < hdr_plus_sei.num_windows; i++) {
|
||||
pr_hdr("window_upper_left_corner_x[%d] = 0x%x\n",
|
||||
pr_info("window_upper_left_corner_x[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.window_upper_left_corner_x[i]);
|
||||
pr_hdr("window_upper_left_corner_y[%d] = 0x%x\n",
|
||||
pr_info("window_upper_left_corner_y[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.window_upper_left_corner_y[i]);
|
||||
pr_hdr("window_lower_right_corner_x[%d] = 0x%x\n",
|
||||
pr_info("window_lower_right_corner_x[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.window_lower_right_corner_x[i]);
|
||||
pr_hdr("window_lower_right_corner_y[%d] = 0x%x\n",
|
||||
pr_info("window_lower_right_corner_y[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.window_lower_right_corner_y[i]);
|
||||
pr_hdr("center_of_ellipse_x[%d] = 0x%x\n",
|
||||
pr_info("center_of_ellipse_x[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.center_of_ellipse_x[i]);
|
||||
pr_hdr("center_of_ellipse_y[%d] = 0x%x\n",
|
||||
pr_info("center_of_ellipse_y[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.center_of_ellipse_y[i]);
|
||||
pr_hdr("rotation_angle[%d] = 0x%x\n",
|
||||
pr_info("rotation_angle[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.rotation_angle[i]);
|
||||
pr_hdr("semimajor_axis_internal_ellipse[%d] = 0x%x\n",
|
||||
pr_info("semimajor_axis_internal_ellipse[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.semimajor_axis_internal_ellipse[i]);
|
||||
pr_hdr("semimajor_axis_external_ellipse[%d] = 0x%x\n",
|
||||
pr_info("semimajor_axis_external_ellipse[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.semimajor_axis_external_ellipse[i]);
|
||||
pr_hdr("semiminor_axis_external_ellipse[%d] = 0x%x\n",
|
||||
pr_info("semiminor_axis_external_ellipse[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.semiminor_axis_external_ellipse[i]);
|
||||
pr_hdr("overlap_process_option[%d] = 0x%x\n",
|
||||
pr_info("overlap_process_option[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.overlap_process_option[i]);
|
||||
}
|
||||
pr_hdr("targeted_system_display_maximum_luminance = 0x%x\n",
|
||||
pr_info("targeted_system_display_maximum_luminance = 0x%x\n",
|
||||
hdr_plus_sei.tgt_sys_disp_max_lumi);
|
||||
pr_hdr("targeted_system_display_actual_peak_luminance_flag = 0x%x\n",
|
||||
pr_info("targeted_system_display_actual_peak_luminance_flag = 0x%x\n",
|
||||
hdr_plus_sei.tgt_sys_disp_act_pk_lumi_flag);
|
||||
if (hdr_plus_sei.tgt_sys_disp_act_pk_lumi_flag) {
|
||||
for (i = 0;
|
||||
@@ -839,8 +910,9 @@ void hdr10_plus_debug(void)
|
||||
for (j = 0;
|
||||
j < hdr_plus_sei.num_cols_tgt_sys_disp_act_pk_lumi;
|
||||
j++) {
|
||||
pr_hdr("tgt_sys_disp_act_pk_lumi");
|
||||
pr_hdr("[%d][%d] = 0x%x\n",
|
||||
pr_info("tgt_sys_disp_act_pk_lumi");
|
||||
pr_info(
|
||||
"[%d][%d] = 0x%x\n",
|
||||
i, j,
|
||||
hdr_plus_sei.tgt_sys_disp_act_pk_lumi[i][j]);
|
||||
}
|
||||
@@ -849,33 +921,35 @@ void hdr10_plus_debug(void)
|
||||
|
||||
for (i = 0; i < hdr_plus_sei.num_windows; i++) {
|
||||
for (j = 0; j < 3; j++)
|
||||
pr_hdr("maxscl[%d][%d] = 0x%x\n",
|
||||
pr_info("maxscl[%d][%d] = 0x%x\n",
|
||||
i, j, hdr_plus_sei.maxscl[i][j]);
|
||||
|
||||
pr_hdr("average_maxrgb[%d] = 0x%x\n",
|
||||
pr_info("average_maxrgb[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.average_maxrgb[i]);
|
||||
pr_hdr("num_distribution_maxrgb_percentiles[%d] = 0x%x\n",
|
||||
pr_info("num_distribution_maxrgb_percentiles[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.num_distribution_maxrgb_percentiles[i]);
|
||||
for (j = 0;
|
||||
j < hdr_plus_sei.num_distribution_maxrgb_percentiles[i];
|
||||
j++) {
|
||||
pr_hdr("distribution_maxrgb_pcntages[%d][%d] = 0x%x\n",
|
||||
pr_info(
|
||||
"distribution_maxrgb_pcntages[%d][%d] = 0x%x\n",
|
||||
i, j,
|
||||
hdr_plus_sei.distribution_maxrgb_percentages[i][j]);
|
||||
pr_hdr("distribution_maxrgb_pcntiles[%d][%d] = 0x%x\n",
|
||||
pr_info(
|
||||
"distribution_maxrgb_pcntiles[%d][%d] = 0x%x\n",
|
||||
i, j,
|
||||
hdr_plus_sei.distribution_maxrgb_percentiles[i][j]);
|
||||
}
|
||||
pr_hdr("fraction_bright_pixels[%d] = 0x%x\n",
|
||||
pr_info("fraction_bright_pixels[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.fraction_bright_pixels[i]);
|
||||
}
|
||||
|
||||
pr_hdr("mast_disp_act_pk_lumi_flag = 0x%x\n",
|
||||
pr_info("mast_disp_act_pk_lumi_flag = 0x%x\n",
|
||||
hdr_plus_sei.mast_disp_act_pk_lumi_flag);
|
||||
if (hdr_plus_sei.mast_disp_act_pk_lumi_flag) {
|
||||
pr_hdr("num_rows_mast_disp_act_pk_lumi = 0x%x\n",
|
||||
pr_info("num_rows_mast_disp_act_pk_lumi = 0x%x\n",
|
||||
hdr_plus_sei.num_rows_mast_disp_act_pk_lumi);
|
||||
pr_hdr("num_cols_mast_disp_act_pk_lumi = 0x%x\n",
|
||||
pr_info("num_cols_mast_disp_act_pk_lumi = 0x%x\n",
|
||||
hdr_plus_sei.num_cols_mast_disp_act_pk_lumi);
|
||||
for (i = 0;
|
||||
i < hdr_plus_sei.num_rows_mast_disp_act_pk_lumi;
|
||||
@@ -883,56 +957,59 @@ void hdr10_plus_debug(void)
|
||||
for (j = 0;
|
||||
j < hdr_plus_sei.num_cols_mast_disp_act_pk_lumi;
|
||||
j++)
|
||||
pr_hdr("mast_disp_act_pk_lumi[%d][%d] = 0x%x\n",
|
||||
pr_info(
|
||||
"mast_disp_act_pk_lumi[%d][%d] = 0x%x\n",
|
||||
i, j, hdr_plus_sei.mast_disp_act_pk_lumi[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < hdr_plus_sei.num_windows; i++) {
|
||||
pr_hdr("tone_mapping_flag[%d] = 0x%x\n",
|
||||
pr_info("tone_mapping_flag[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.tone_mapping_flag[i]);
|
||||
pr_hdr("knee_point_x[%d] = 0x%x\n",
|
||||
pr_info("knee_point_x[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.knee_point_x[i]);
|
||||
pr_hdr("knee_point_y[%d] = 0x%x\n",
|
||||
pr_info("knee_point_y[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.knee_point_y[i]);
|
||||
pr_hdr("num_bezier_curve_anchors[%d] = 0x%x\n",
|
||||
pr_info("num_bezier_curve_anchors[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.num_bezier_curve_anchors[i]);
|
||||
for (j = 0; j < hdr_plus_sei.num_bezier_curve_anchors[i]; j++)
|
||||
pr_hdr("bezier_curve_anchors[%d][%d] = 0x%x\n",
|
||||
pr_info("bezier_curve_anchors[%d][%d] = 0x%x\n",
|
||||
i, j, hdr_plus_sei.bezier_curve_anchors[i][j]);
|
||||
|
||||
pr_hdr("color_saturation_mapping_flag[%d] = 0x%x\n",
|
||||
pr_info("color_saturation_mapping_flag[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.color_saturation_mapping_flag[i]);
|
||||
pr_hdr("color_saturation_weight[%d] = 0x%x\n",
|
||||
pr_info("color_saturation_weight[%d] = 0x%x\n",
|
||||
i, hdr_plus_sei.color_saturation_weight[i]);
|
||||
}
|
||||
|
||||
pr_hdr("\ntx vsif packet data print begin\n");
|
||||
pr_hdr("application_version = 0x%x\n",
|
||||
pr_info("\ntx vsif packet data print begin\n");
|
||||
pr_info("application_version = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.application_version);
|
||||
pr_hdr("targeted_max_lum = 0x%x\n",
|
||||
pr_info("targeted_max_lum = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.targeted_max_lum);
|
||||
pr_hdr("average_maxrgb = 0x%x\n",
|
||||
pr_info("average_maxrgb = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.average_maxrgb);
|
||||
for (i = 0; i < 9; i++)
|
||||
pr_hdr("distribution_values[%d] = 0x%x\n",
|
||||
pr_info(
|
||||
"distribution_values[%d] = 0x%x\n",
|
||||
i, dbg_hdr10plus_pkt.distribution_values[i]);
|
||||
pr_hdr("num_bezier_curve_anchors = 0x%x\n",
|
||||
pr_info("num_bezier_curve_anchors = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.num_bezier_curve_anchors);
|
||||
pr_hdr("knee_point_x = 0x%x\n",
|
||||
pr_info("knee_point_x = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.knee_point_x);
|
||||
pr_hdr("knee_point_y = 0x%x\n",
|
||||
pr_info("knee_point_y = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.knee_point_y);
|
||||
|
||||
for (i = 0; i < 9; i++)
|
||||
pr_hdr("bezier_curve_anchors[%d] = 0x%x\n",
|
||||
pr_info(
|
||||
"bezier_curve_anchors[%d] = 0x%x\n",
|
||||
i, dbg_hdr10plus_pkt.bezier_curve_anchors[i]);
|
||||
pr_hdr("graphics_overlay_flag = 0x%x\n",
|
||||
pr_info("graphics_overlay_flag = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.graphics_overlay_flag);
|
||||
pr_hdr("no_delay_flag = 0x%x\n",
|
||||
pr_info("no_delay_flag = 0x%x\n",
|
||||
dbg_hdr10plus_pkt.no_delay_flag);
|
||||
pr_hdr("\ntx vsif packet data print end\n");
|
||||
pr_info("\ntx vsif packet data print end\n");
|
||||
|
||||
pr_hdr(HDR10_PLUS_VERSION);
|
||||
pr_info(HDR10_PLUS_VERSION);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,7 @@
|
||||
#define PROCESSING_MAX 12
|
||||
#define PORCESSING_DATA_MAX ((1 << PROCESSING_MAX) - 1)
|
||||
#define PROCESSING_MAX_HALF ((1 << (PROCESSING_MAX - 1)) - 1)
|
||||
#define GAIN_BIT 7
|
||||
#define GAIN_BIT 6
|
||||
#define U16 16
|
||||
#define U16_MAXI ((1 << U16) - 1)
|
||||
#define MIN_LUMINANCE 200
|
||||
@@ -34,24 +34,24 @@
|
||||
#define U32 32
|
||||
#define _U32_MAX 0xffffffff
|
||||
|
||||
struct EBZCurveParameters {
|
||||
struct ebzcurveparameters {
|
||||
int order;
|
||||
int Sx, Sy;
|
||||
int Anchor[N + 1];
|
||||
int sx, sy;
|
||||
int anchor[N + 1];
|
||||
};
|
||||
|
||||
struct Percentiles {
|
||||
struct percentiles {
|
||||
int num_percentile;
|
||||
int percentilePercent[PERCENTILE_ORDER];
|
||||
int percentileValue[PERCENTILE_ORDER];
|
||||
int percentilepercent[PERCENTILE_ORDER];
|
||||
int percentilevalue[PERCENTILE_ORDER];
|
||||
};
|
||||
|
||||
struct Scene2094Metadata {
|
||||
int maxSceneSourceLuminance;
|
||||
int referenceLuminance;
|
||||
int minLuminance;
|
||||
struct Percentiles percentiles;
|
||||
struct EBZCurveParameters EBZCurveParameters;
|
||||
struct scene2094metadata {
|
||||
int maxscenesourceluminance;
|
||||
int referenceluminance;
|
||||
int minluminance;
|
||||
struct percentiles percentiles;
|
||||
struct ebzcurveparameters ebzcurveparameters;
|
||||
};
|
||||
|
||||
struct hdr10_plus_sei_s {
|
||||
@@ -73,7 +73,7 @@ struct hdr10_plus_sei_s {
|
||||
#define ORDER 10
|
||||
#define NPCOEFF (ORDER - 1)
|
||||
#define P1MIN (PORCESSING_DATA_MAX / ORDER)
|
||||
struct BasisOOTF_Params {
|
||||
struct basisootf_params {
|
||||
/*Knee-Point (KP) parameters*/
|
||||
/*KP ramp base thresholds (two bounds KP 1 and KP 2 are computed)*/
|
||||
int SY1_V1;
|
||||
@@ -102,13 +102,13 @@ struct BasisOOTF_Params {
|
||||
|
||||
/* Thresholds to compute relative shape of curve (P2~P9 coefficient)*/
|
||||
/* by pre-defined bounds - as a function of scene percentile*/
|
||||
int P2To9_T1;
|
||||
int P2To9_T2;
|
||||
int P2TO9_T1;
|
||||
int P2TO9_T2;
|
||||
|
||||
/* Defined relative shape bounds (P2~P9 coefficient) for*/
|
||||
/*a given maximum TM dynamic compression (eg : 20x )*/
|
||||
int P2ToP9_MAX1[ORDER - 2];
|
||||
int P2ToP9_MAX2[ORDER - 2];
|
||||
int P2TOP9_MAX1[ORDER - 2];
|
||||
int P2TOP9_MAX2[ORDER - 2];
|
||||
|
||||
/* Ps mixing gain (obtain all Ps coefficients) -*/
|
||||
/*as a function of TM dynamic compression ratio*/
|
||||
@@ -129,7 +129,16 @@ struct BasisOOTF_Params {
|
||||
int RED_P2_T2;
|
||||
};
|
||||
|
||||
extern int hdr10_plus_ootf_gen(void);
|
||||
struct hdr10pgen_param_s {
|
||||
unsigned int shift;
|
||||
/* scale * 1000 for 3bit float point*/
|
||||
unsigned int scale_gmt;
|
||||
unsigned int gain[POINTS];
|
||||
};
|
||||
|
||||
int hdr10_plus_ootf_gen(
|
||||
int panel_lumin,
|
||||
int force_source_lumin,
|
||||
struct hdr10pgen_param_s *hdr10pgen_param);
|
||||
#endif /* AM_HDR10_PLUS_OOTF_H */
|
||||
|
||||
|
||||
@@ -911,11 +911,19 @@ int ncl_2020_709[9] = {
|
||||
/*int ncl_2020_709[9] = {*/
|
||||
/*2543, -459, -36, -88, 2133, 3, -41, -161, 2250};*/
|
||||
|
||||
/* standard2020->dcip3-d65 8bit*/
|
||||
int ncl_2020_p3[9] = {
|
||||
368, -96, -16, -16, 275, -3, 1, -8, 263};
|
||||
/* standard2020->dcip3 8bit*/
|
||||
int ncl_2020_p3dci[9] = {
|
||||
368, -96, -16, -16, 275, -3, 1, -8, 263
|
||||
};
|
||||
|
||||
/* standard2020->d65p3 8bit*/
|
||||
int ncl_2020_p3d65[9] = {
|
||||
344, -72, -15, -16, 275, -2, 0, -5, 260
|
||||
};
|
||||
|
||||
int gamut_bypass_8bit[9] = {
|
||||
256, 0, 0, 0, 256, 0, 0, 0, 256};
|
||||
256, 0, 0, 0, 256, 0, 0, 0, 256
|
||||
};
|
||||
|
||||
/* standard2020->709-d65 8bit*/
|
||||
int ncl_2020_709_8bit[9] = {
|
||||
@@ -1212,7 +1220,8 @@ void hdr_highclip_by_luma(
|
||||
void set_hdr_matrix(
|
||||
enum hdr_module_sel module_sel,
|
||||
enum hdr_matrix_sel mtx_sel,
|
||||
struct hdr_proc_mtx_param_s *hdr_mtx_param)
|
||||
struct hdr_proc_mtx_param_s *hdr_mtx_param,
|
||||
struct hdr10pgen_param_s *p_hdr10pgen_param)
|
||||
{
|
||||
unsigned int MATRIXI_COEF00_01 = 0;
|
||||
unsigned int MATRIXI_COEF02_10 = 0;
|
||||
@@ -1280,6 +1289,8 @@ void set_hdr_matrix(
|
||||
int adpscl_beta[3];
|
||||
int adpscl_beta_s[3];
|
||||
|
||||
int scale_shift = 0;
|
||||
|
||||
int i = 0;
|
||||
int in_mtx[MTX_NUM_PARAM] = {
|
||||
1024, 0, 0,
|
||||
@@ -1682,7 +1693,8 @@ void set_hdr_matrix(
|
||||
for (i = 0; i < 9; i++)
|
||||
gmut_coef[i/3][i%3] =
|
||||
hdr_mtx_param->mtx_gamut[i];
|
||||
if (hdr_mtx_param->p_sel == HDR_SDR)
|
||||
if ((hdr_mtx_param->p_sel == HDR_SDR) ||
|
||||
(hdr_mtx_param->p_sel == HDR10P_SDR))
|
||||
/* use integer mode for gamut coeff */
|
||||
gmut_shift = 0;
|
||||
else
|
||||
@@ -1713,7 +1725,8 @@ void set_hdr_matrix(
|
||||
hdr_mtx_param->p_sel == HLG_IPT)
|
||||
adpscl_alpha[i] = 1000 *
|
||||
(1 << adp_scal_y_shift) / 10000;
|
||||
else if (hdr_mtx_param->p_sel == HDR_SDR)
|
||||
else if ((hdr_mtx_param->p_sel == HDR_SDR) ||
|
||||
(hdr_mtx_param->p_sel == HDR10P_SDR))
|
||||
adpscl_alpha[i] =
|
||||
(1 << adp_scal_y_shift);
|
||||
else
|
||||
@@ -1739,6 +1752,20 @@ void set_hdr_matrix(
|
||||
adpscl_shift[0] = adp_scal_x_shift - 1;
|
||||
adpscl_shift[1] = OO_NOR -
|
||||
_log2((1 << OO_NOR) / oo_y_lut_hdr_sdr[148]) - 1;
|
||||
} else if (hdr_mtx_param->p_sel == HDR10P_SDR) {
|
||||
if (p_hdr10pgen_param)
|
||||
scale_shift = _log2((1 << OO_NOR) /
|
||||
p_hdr10pgen_param->gain[148]);
|
||||
else
|
||||
scale_shift =
|
||||
_log2((1 << OO_NOR) / oo_y_lut_hdr_sdr[148]);
|
||||
/*because input 1/2, shift0/shift1 need change*/
|
||||
adpscl_shift[0] = adp_scal_x_shift - 1;
|
||||
adpscl_shift[1] = OO_NOR - scale_shift - 1;
|
||||
if (p_hdr10pgen_param) {
|
||||
adpscl_shift[0] -= p_hdr10pgen_param->shift;
|
||||
adpscl_shift[1] -= p_hdr10pgen_param->shift;
|
||||
}
|
||||
} else if (hdr_mtx_param->p_sel == HDR_HLG) {
|
||||
adpscl_shift[0] = adp_scal_x_shift;
|
||||
adpscl_shift[1] = OO_NOR -
|
||||
@@ -2109,6 +2136,117 @@ void set_c_gain(
|
||||
VSYNC_WR_MPEG_REG(cgain_lut_data_port, lut[64]);
|
||||
}
|
||||
|
||||
#define NUM_HDR_HIST 16
|
||||
static u32 hdr_hist[NUM_HDR_HIST][128];
|
||||
static u32 hdr_max_rgb;
|
||||
static u8 percentile_percent[7] = {
|
||||
1, 25, 50, 75, 90, 95, 99
|
||||
};
|
||||
|
||||
static u32 percentile[7];
|
||||
|
||||
void set_hist(
|
||||
enum hdr_module_sel module_sel, int enable,
|
||||
enum hdr_hist_sel hist_sel,
|
||||
unsigned int hist_width, unsigned int hist_height)
|
||||
{
|
||||
unsigned int hist_ctrl_port = 0;
|
||||
|
||||
if (module_sel == VD1_HDR)
|
||||
hist_ctrl_port = VD1_HDR2_HIST_CTRL;
|
||||
else
|
||||
return;
|
||||
|
||||
if (enable) {
|
||||
WRITE_VPP_REG(hist_ctrl_port + 1, hist_width - 1);
|
||||
WRITE_VPP_REG(hist_ctrl_port + 2, hist_height - 1);
|
||||
WRITE_VPP_REG(
|
||||
hist_ctrl_port,
|
||||
(1 << 4) | (hist_sel << 0));
|
||||
} else if (READ_VPP_REG_BITS(hist_ctrl_port, 4, 1)) {
|
||||
WRITE_VPP_REG_BITS(hist_ctrl_port, 0, 4, 1);
|
||||
hdr_max_rgb = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void get_hist(enum hdr_module_sel module_sel, enum hdr_hist_sel hist_sel)
|
||||
{
|
||||
unsigned int hist_ctrl_port = 0;
|
||||
unsigned int hist_height, hist_width, i;
|
||||
u32 num_pixel, total_pixel, percentile_index;
|
||||
|
||||
return;
|
||||
|
||||
if (module_sel == VD1_HDR)
|
||||
hist_ctrl_port = VD1_HDR2_HIST_CTRL;
|
||||
else
|
||||
return;
|
||||
|
||||
if (get_cpu_type() >= MESON_CPU_MAJOR_ID_G12A) {
|
||||
hist_width = READ_VPP_REG_BITS(VPP_PREBLEND_H_SIZE, 0, 13);
|
||||
hist_height = READ_VPP_REG_BITS(VPP_PREBLEND_H_SIZE, 16, 13);
|
||||
} else {
|
||||
hist_height = READ_VPP_REG_BITS(VPP_IN_H_V_SIZE, 0, 13);
|
||||
hist_width = READ_VPP_REG_BITS(VPP_IN_H_V_SIZE, 16, 13);
|
||||
}
|
||||
if (!hist_width || !hist_height)
|
||||
return;
|
||||
|
||||
if ((hist_height != READ_VPP_REG(hist_ctrl_port + 2) + 1) ||
|
||||
(hist_width != READ_VPP_REG(hist_ctrl_port + 1) + 1) ||
|
||||
(READ_VPP_REG_BITS(hist_ctrl_port, 4, 1) == 0) ||
|
||||
(READ_VPP_REG_BITS(hist_ctrl_port, 0, 3) != hist_sel)) {
|
||||
set_hist(module_sel, 1, hist_sel, hist_width, hist_height);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_HDR_HIST; i++)
|
||||
memcpy(hdr_hist[i], hdr_hist[i + 1], 128 * sizeof(uint32_t));
|
||||
total_pixel = 0;
|
||||
for (i = 0; i < 128; i++) {
|
||||
WRITE_VPP_REG_BITS(hist_ctrl_port, i, 16, 8);
|
||||
num_pixel = READ_VPP_REG(hist_ctrl_port + 3);
|
||||
total_pixel += num_pixel;
|
||||
hdr_hist[NUM_HDR_HIST - 1][i] = num_pixel;
|
||||
}
|
||||
num_pixel = 0;
|
||||
percentile_index = 0;
|
||||
if (total_pixel) {
|
||||
for (i = 0; i < 128; i++) {
|
||||
num_pixel += hdr_hist[NUM_HDR_HIST - 1][i];
|
||||
if (num_pixel * 100 / total_pixel >=
|
||||
percentile_percent[percentile_index]) {
|
||||
percentile[percentile_index] =
|
||||
(i + 1) * 10000 / 128;
|
||||
percentile_index++;
|
||||
}
|
||||
if (hdr_hist[NUM_HDR_HIST - 1][i])
|
||||
hdr_max_rgb =
|
||||
(i + 1) * 10000 / 128;
|
||||
}
|
||||
}
|
||||
|
||||
if (total_pixel && percentile_index) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
pr_info("hist[%d..]=%d %d %d %d %d %d %d %d\n",
|
||||
i * 8,
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8],
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8 + 1],
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8 + 2],
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8 + 3],
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8 + 4],
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8 + 5],
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8 + 6],
|
||||
hdr_hist[NUM_HDR_HIST - 1][i * 8 + 7]);
|
||||
pr_info("max=%d percentile=%d %d %d %d %d %d %d\n",
|
||||
hdr_max_rgb,
|
||||
percentile[0], percentile[1], percentile[2],
|
||||
percentile[3], percentile[4], percentile[5],
|
||||
percentile[6]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct hdr_proc_lut_param_s hdr_lut_param;
|
||||
|
||||
enum hdr_process_sel hdr_func(enum hdr_module_sel module_sel,
|
||||
@@ -2251,7 +2389,8 @@ enum hdr_process_sel hdr_func(enum hdr_module_sel module_sel,
|
||||
hdr_lut_param.lut_on = LUT_OFF;
|
||||
hdr_lut_param.bitdepth = bit_depth;
|
||||
hdr_lut_param.cgain_en = LUT_OFF;
|
||||
} else if (hdr_process_select == HDR_SDR) {
|
||||
} else if (hdr_process_select == HDR_SDR ||
|
||||
hdr_process_select == HDR10P_SDR) {
|
||||
for (i = 0; i < HDR2_OETF_LUT_SIZE; i++) {
|
||||
hdr_lut_param.oetf_lut[i] = oe_y_lut_sdr[i];
|
||||
hdr_lut_param.ogain_lut[i] = oo_y_lut_hdr_sdr[i];
|
||||
@@ -2515,7 +2654,8 @@ enum hdr_process_sel hdr_func(enum hdr_module_sel module_sel,
|
||||
hdr_mtx_param.mtx_on = MTX_OFF;
|
||||
hdr_mtx_param.p_sel = hdr_process_select;
|
||||
} else if (hdr_process_select == HDR_SDR ||
|
||||
hdr_process_select == HLG_SDR) {
|
||||
hdr_process_select == HLG_SDR ||
|
||||
hdr_process_select == HDR10P_SDR) {
|
||||
hdr_mtx_param.mtx_only = HDR_ONLY;
|
||||
hdr_mtx_param.mtx_gamut_mode = 1;
|
||||
for (i = 0; i < MTX_NUM_PARAM; i++) {
|
||||
@@ -2634,17 +2774,270 @@ enum hdr_process_sel hdr_func(enum hdr_module_sel module_sel,
|
||||
hdr_mtx_param.p_sel = HDR_IPT;
|
||||
}
|
||||
|
||||
set_hdr_matrix(module_sel, HDR_IN_MTX, &hdr_mtx_param);
|
||||
set_hdr_matrix(module_sel, HDR_IN_MTX, &hdr_mtx_param, NULL);
|
||||
|
||||
set_eotf_lut(module_sel, &hdr_lut_param);
|
||||
|
||||
set_hdr_matrix(module_sel, HDR_GAMUT_MTX, &hdr_mtx_param);
|
||||
set_hdr_matrix(module_sel, HDR_GAMUT_MTX, &hdr_mtx_param, NULL);
|
||||
|
||||
set_ootf_lut(module_sel, &hdr_lut_param);
|
||||
|
||||
set_oetf_lut(module_sel, &hdr_lut_param);
|
||||
|
||||
set_hdr_matrix(module_sel, HDR_OUT_MTX, &hdr_mtx_param);
|
||||
set_hdr_matrix(module_sel, HDR_OUT_MTX, &hdr_mtx_param, NULL);
|
||||
|
||||
set_c_gain(module_sel, &hdr_lut_param);
|
||||
|
||||
return hdr_process_select;
|
||||
}
|
||||
|
||||
int hdr10p_ebzcurve_update(
|
||||
enum hdr_module_sel module_sel,
|
||||
enum hdr_process_sel hdr_process_select,
|
||||
struct hdr10pgen_param_s *p_hdr10pgen_param)
|
||||
{
|
||||
int bit_depth;
|
||||
unsigned int i = 0;
|
||||
struct hdr_proc_mtx_param_s hdr_mtx_param;
|
||||
|
||||
memset(&hdr_mtx_param, 0, sizeof(struct hdr_proc_mtx_param_s));
|
||||
memset(&hdr_lut_param, 0, sizeof(struct hdr_proc_lut_param_s));
|
||||
|
||||
if (module_sel == VD1_HDR ||
|
||||
module_sel == VD2_HDR ||
|
||||
module_sel == OSD1_HDR)
|
||||
bit_depth = 12;
|
||||
else if (
|
||||
module_sel == VDIN0_HDR ||
|
||||
module_sel == VDIN1_HDR ||
|
||||
module_sel == DI_HDR)
|
||||
bit_depth = 10;
|
||||
else
|
||||
return 0;
|
||||
|
||||
if (is_meson_tl1_cpu())
|
||||
bit_depth = 10;
|
||||
|
||||
/*lut parameters*/
|
||||
if (hdr_process_select == HDR10P_SDR) {
|
||||
for (i = 0; i < HDR2_OETF_LUT_SIZE; i++) {
|
||||
if (!p_hdr10pgen_param)
|
||||
hdr_lut_param.ogain_lut[i] =
|
||||
oo_y_lut_hdr_sdr[i];
|
||||
else
|
||||
hdr_lut_param.ogain_lut[i] =
|
||||
p_hdr10pgen_param->gain[i];
|
||||
}
|
||||
hdr_lut_param.lut_on = LUT_ON;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#ifdef HDR2_PRINT
|
||||
pr_info("hdr: oo_gain %d = %lld-%lld-%lld, c_gain %d = %lld-%lld-%lld\n",
|
||||
hdr_lut_param.lut_on,
|
||||
hdr_lut_param.ogain_lut[0], hdr_lut_param.ogain_lut[74],
|
||||
hdr_lut_param.ogain_lut[148],
|
||||
hdr_lut_param.cgain_en,
|
||||
hdr_lut_param.cgain_lut[0], hdr_lut_param.cgain_lut[32],
|
||||
hdr_lut_param.cgain_lut[64]);
|
||||
#endif
|
||||
|
||||
hdr_mtx_param.mtx_only = HDR_ONLY;
|
||||
hdr_mtx_param.mtx_gamut_mode = 1;
|
||||
for (i = 0; i < 9; i++) {
|
||||
if (!p_hdr10pgen_param)
|
||||
hdr_mtx_param.mtx_gamut[i] =
|
||||
ncl_2020_709_8bit[i];
|
||||
else
|
||||
hdr_mtx_param.mtx_gamut[i] =
|
||||
ncl_2020_p3d65[i] *
|
||||
p_hdr10pgen_param->scale_gmt / 1024;
|
||||
}
|
||||
|
||||
hdr_mtx_param.mtx_on = MTX_ON;
|
||||
hdr_mtx_param.p_sel = hdr_process_select;
|
||||
|
||||
set_hdr_matrix(
|
||||
module_sel, HDR_GAMUT_MTX,
|
||||
&hdr_mtx_param, p_hdr10pgen_param);
|
||||
|
||||
set_ootf_lut(module_sel, &hdr_lut_param);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum hdr_process_sel hdr10p_func(
|
||||
enum hdr_module_sel module_sel,
|
||||
enum hdr_process_sel hdr_process_select,
|
||||
struct vinfo_s *vinfo)
|
||||
{
|
||||
int bit_depth;
|
||||
unsigned int i = 0;
|
||||
struct hdr_proc_mtx_param_s hdr_mtx_param;
|
||||
bool mtx_only_mode = false;
|
||||
|
||||
memset(&hdr_mtx_param, 0, sizeof(struct hdr_proc_mtx_param_s));
|
||||
memset(&hdr_lut_param, 0, sizeof(struct hdr_proc_lut_param_s));
|
||||
|
||||
if ((module_sel == OSD1_HDR) &&
|
||||
(is_meson_g12() ||
|
||||
is_meson_sm1_cpu() ||
|
||||
is_meson_tl1_cpu())) {
|
||||
/* turn off OSD mtx and use HDR for g12, sm1, tl1 */
|
||||
VSYNC_WR_MPEG_REG(
|
||||
VPP_WRAP_OSD1_MATRIX_EN_CTRL, 0);
|
||||
if (!is_dolby_vision_on()) {
|
||||
if (hdr_process_select == HDR_BYPASS)
|
||||
hdr_process_select = RGB_YUV;
|
||||
/* use in_mtx for g12b rev b, sm1, tl1 */
|
||||
if (hdr_process_select == RGB_YUV &&
|
||||
(is_meson_sm1_cpu() ||
|
||||
is_meson_tl1_cpu()))
|
||||
mtx_only_mode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (module_sel == VD1_HDR ||
|
||||
module_sel == VD2_HDR ||
|
||||
module_sel == OSD1_HDR)
|
||||
bit_depth = 12;
|
||||
else if (module_sel == VDIN0_HDR ||
|
||||
module_sel == VDIN1_HDR ||
|
||||
module_sel == DI_HDR)
|
||||
bit_depth = 10;
|
||||
else
|
||||
return hdr_process_select;
|
||||
|
||||
if (is_meson_tl1_cpu())
|
||||
bit_depth = 10;
|
||||
|
||||
/*lut parameters*/
|
||||
if (hdr_process_select == RGB_YUV) {
|
||||
for (i = 0; i < HDR2_OETF_LUT_SIZE; i++) {
|
||||
hdr_lut_param.oetf_lut[i] = oe_y_lut_bypass[i];
|
||||
hdr_lut_param.ogain_lut[i] = oo_y_lut_bypass[i];
|
||||
if (i < HDR2_EOTF_LUT_SIZE)
|
||||
hdr_lut_param.eotf_lut[i] =
|
||||
eo_y_lut_bypass[i];
|
||||
if (i < HDR2_CGAIN_LUT_SIZE)
|
||||
hdr_lut_param.cgain_lut[i] =
|
||||
cgain_lut_bypass[i] - 1;
|
||||
}
|
||||
hdr_lut_param.bitdepth = bit_depth;
|
||||
if (mtx_only_mode) {
|
||||
hdr_lut_param.lut_on = LUT_OFF;
|
||||
hdr_lut_param.cgain_en = LUT_OFF;
|
||||
} else {
|
||||
hdr_lut_param.lut_on = LUT_ON;
|
||||
hdr_lut_param.cgain_en = LUT_ON;
|
||||
}
|
||||
} else if (hdr_process_select == HDR10P_SDR) {
|
||||
for (i = 0; i < HDR2_OETF_LUT_SIZE; i++) {
|
||||
hdr_lut_param.oetf_lut[i] = oe_y_lut_sdr[i];
|
||||
hdr_lut_param.ogain_lut[i] = oo_y_lut_hdr_sdr[i];
|
||||
if (i < HDR2_EOTF_LUT_SIZE)
|
||||
hdr_lut_param.eotf_lut[i] = eo_y_lut_hdr[i];
|
||||
if (i < HDR2_CGAIN_LUT_SIZE)
|
||||
hdr_lut_param.cgain_lut[i] = cgain_lut1[i] - 1;
|
||||
}
|
||||
hdr_lut_param.lut_on = LUT_ON;
|
||||
hdr_lut_param.bitdepth = bit_depth;
|
||||
hdr_lut_param.cgain_en = LUT_OFF;
|
||||
} else {
|
||||
return hdr_process_select;
|
||||
}
|
||||
#ifdef HDR2_PRINT
|
||||
pr_info("hdr: oo_gain %d = %lld-%lld-%lld, c_gain %d = %lld-%lld-%lld\n",
|
||||
hdr_lut_param.lut_on,
|
||||
hdr_lut_param.ogain_lut[0], hdr_lut_param.ogain_lut[74],
|
||||
hdr_lut_param.ogain_lut[148],
|
||||
hdr_lut_param.cgain_en,
|
||||
hdr_lut_param.cgain_lut[0], hdr_lut_param.cgain_lut[32],
|
||||
hdr_lut_param.cgain_lut[64]);
|
||||
#endif
|
||||
|
||||
/*mtx parameters*/
|
||||
/* default pre/post in:yuv_rgb out:rgb_yuv */
|
||||
for (i = 0; i < 3; i++) {
|
||||
hdr_mtx_param.mtxi_pre_offset[i] =
|
||||
yuv2rgbpre[i];
|
||||
hdr_mtx_param.mtxi_pos_offset[i] =
|
||||
yuv2rgbpos[i];
|
||||
hdr_mtx_param.mtxo_pre_offset[i] =
|
||||
rgb2yuvpre[i];
|
||||
hdr_mtx_param.mtxo_pos_offset[i] =
|
||||
rgb2yuvpos[i];
|
||||
}
|
||||
|
||||
if (hdr_process_select == RGB_YUV) {
|
||||
hdr_mtx_param.mtx_gamut_mode = 1;
|
||||
if (mtx_only_mode) {
|
||||
hdr_mtx_param.mtx_only = MTX_ONLY;
|
||||
for (i = 0; i < MTX_NUM_PARAM; i++) {
|
||||
hdr_mtx_param.mtx_in[i] = rgb2ycbcr_709[i];
|
||||
hdr_mtx_param.mtx_cgain[i] = bypass_coeff[i];
|
||||
hdr_mtx_param.mtx_ogain[i] = bypass_coeff[i];
|
||||
hdr_mtx_param.mtx_out[i] = bypass_coeff[i];
|
||||
if (i < 9)
|
||||
hdr_mtx_param.mtx_gamut[i] =
|
||||
gamut_bypass[i];
|
||||
if (i < 3) {
|
||||
hdr_mtx_param.mtxi_pre_offset[i] =
|
||||
rgb2yuvpre[i];
|
||||
hdr_mtx_param.mtxi_pos_offset[i] =
|
||||
rgb2yuvpos[i];
|
||||
hdr_mtx_param.mtxo_pre_offset[i] =
|
||||
bypass_pre[i];
|
||||
hdr_mtx_param.mtxo_pos_offset[i] =
|
||||
bypass_pos[i];
|
||||
}
|
||||
}
|
||||
hdr_mtx_param.mtx_on = MTX_OFF;
|
||||
} else {
|
||||
hdr_mtx_param.mtx_only = HDR_ONLY;
|
||||
for (i = 0; i < MTX_NUM_PARAM; i++) {
|
||||
hdr_mtx_param.mtx_in[i] = bypass_coeff[i];
|
||||
hdr_mtx_param.mtx_cgain[i] = bypass_coeff[i];
|
||||
hdr_mtx_param.mtx_ogain[i] = bypass_coeff[i];
|
||||
hdr_mtx_param.mtx_out[i] = rgb2ycbcr_709[i];
|
||||
if (i < 9)
|
||||
hdr_mtx_param.mtx_gamut[i] =
|
||||
gamut_bypass[i];
|
||||
if (i < 3) {
|
||||
hdr_mtx_param.mtxi_pre_offset[i] =
|
||||
bypass_pre[i];
|
||||
hdr_mtx_param.mtxi_pos_offset[i] =
|
||||
bypass_pos[i];
|
||||
}
|
||||
}
|
||||
hdr_mtx_param.mtx_on = MTX_ON;
|
||||
}
|
||||
hdr_mtx_param.p_sel = RGB_YUV;
|
||||
} else if (hdr_process_select == HDR10P_SDR ||
|
||||
hdr_process_select == HLG_SDR) {
|
||||
hdr_mtx_param.mtx_only = HDR_ONLY;
|
||||
hdr_mtx_param.mtx_gamut_mode = 1;
|
||||
for (i = 0; i < MTX_NUM_PARAM; i++) {
|
||||
hdr_mtx_param.mtx_in[i] = ycbcr2rgb_ncl2020[i];
|
||||
hdr_mtx_param.mtx_cgain[i] = rgb2ycbcr_709[i];
|
||||
hdr_mtx_param.mtx_ogain[i] = rgb2ycbcr_709[i];
|
||||
hdr_mtx_param.mtx_out[i] = rgb2ycbcr_709[i];
|
||||
if (i < 9) {
|
||||
hdr_mtx_param.mtx_gamut[i] =
|
||||
ncl_2020_p3d65[i];
|
||||
}
|
||||
}
|
||||
hdr_mtx_param.mtx_on = MTX_ON;
|
||||
hdr_mtx_param.p_sel = hdr_process_select;
|
||||
}
|
||||
|
||||
set_hdr_matrix(module_sel, HDR_IN_MTX, &hdr_mtx_param, NULL);
|
||||
|
||||
set_eotf_lut(module_sel, &hdr_lut_param);
|
||||
|
||||
set_oetf_lut(module_sel, &hdr_lut_param);
|
||||
|
||||
set_hdr_matrix(module_sel, HDR_OUT_MTX, &hdr_mtx_param, NULL);
|
||||
|
||||
set_c_gain(module_sel, &hdr_lut_param);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/amlogic/media/vout/vinfo.h>
|
||||
#include "hdr/am_hdr10_plus_ootf.h"
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x1, x2) (double)(x1 > x2 ? x1 : x2)
|
||||
@@ -90,9 +91,19 @@ enum hdr_process_sel {
|
||||
RGB_YUV = 12,
|
||||
RGB_HDR = 13,
|
||||
RGB_HLG = 14,
|
||||
HDR10P_SDR = 15,
|
||||
HDR_p_MAX
|
||||
};
|
||||
|
||||
enum hdr_hist_sel {
|
||||
HIST_E_RGBMAX = 0,
|
||||
HIST_E_LUMA = 1,
|
||||
HIST_E_SAT = 2,
|
||||
HIST_O_BEFORE = 4,
|
||||
HIST_O_AFTER = 6,
|
||||
HIST_MAX
|
||||
};
|
||||
|
||||
#define MTX_ON 1
|
||||
#define MTX_OFF 0
|
||||
|
||||
@@ -183,6 +194,15 @@ extern void mtx_setting(enum vpp_matrix_e mtx_sel,
|
||||
enum mtx_csc_e mtx_csc,
|
||||
int mtx_on);
|
||||
|
||||
unsigned int _log2(unsigned int value);
|
||||
int hdr10p_ebzcurve_update(
|
||||
enum hdr_module_sel module_sel,
|
||||
enum hdr_process_sel hdr_process_select,
|
||||
struct hdr10pgen_param_s *hdr10pgen_param);
|
||||
enum hdr_process_sel hdr10p_func(
|
||||
enum hdr_module_sel module_sel,
|
||||
enum hdr_process_sel hdr_process_select,
|
||||
struct vinfo_s *vinfo);
|
||||
extern void set_ootf_lut(
|
||||
enum hdr_module_sel module_sel,
|
||||
struct hdr_proc_lut_param_s *hdr_lut_param);
|
||||
@@ -196,4 +216,6 @@ extern unsigned int hdr10_force_clip;
|
||||
extern unsigned int hdr10_clip_luma;
|
||||
extern unsigned int hdr10_clip_margin;
|
||||
extern unsigned int hdr10_clip_mode;
|
||||
|
||||
void get_hist(
|
||||
enum hdr_module_sel module_sel,
|
||||
enum hdr_hist_sel hist_sel);
|
||||
|
||||
Reference in New Issue
Block a user