From: MingLiang Dong Date: Wed, 23 May 2018 12:49:55 +0000 (+0800) Subject: hdr: set bt2020 output when connect hdr tv X-Git-Tag: khadas-vims-v0.9.6-release~1969 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfe3685971df6e64bcbc84cad15f833354ad9e00;p=platform%2Fkernel%2Flinux-amlogic.git hdr: set bt2020 output when connect hdr tv PD#165557: hdr set bt2020 output when connect hdr tv Change-Id: I7409d48cffe471bd1276dc2158bfbc9d39073726 Signed-off-by: MingLiang Dong --- diff --git a/arch/arm64/boot/dts/amlogic/g12a_pxp.dts b/arch/arm64/boot/dts/amlogic/g12a_pxp.dts index 2b18ebc..f0beb37 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_pxp.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_pxp.dts @@ -204,6 +204,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { compatible = "amlogic, dolby_vision_g12a"; diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt.dts b/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt.dts index 72f52d5..f0e08f4 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt.dts @@ -390,6 +390,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt_buildroot.dts b/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt_buildroot.dts index 5e3dfe4..3817688 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905d2_skt_buildroot.dts @@ -391,6 +391,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200.dts b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200.dts index ffb4a09..6a54f1c 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200.dts @@ -429,6 +429,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_buildroot.dts b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_buildroot.dts index c5ae862..a0e1518 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_buildroot.dts @@ -497,6 +497,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_drm_buildroot.dts b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_drm_buildroot.dts index 9577627..b4d6705 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_drm_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_drm_buildroot.dts @@ -498,6 +498,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u220.dts b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u220.dts index a7f5475..afa09be 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905d2_u220.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905d2_u220.dts @@ -416,6 +416,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211.dts b/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211.dts index 4ca68cf..c489d22 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211.dts @@ -430,6 +430,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211_buildroot.dts b/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211_buildroot.dts index 4c84536..5dbb4dc 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905x2_u211_buildroot.dts @@ -504,6 +504,8 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/g12a_s905y2_u221.dts b/arch/arm64/boot/dts/amlogic/g12a_s905y2_u221.dts index e3f2f4c..2a83e09 100644 --- a/arch/arm64/boot/dts/amlogic/g12a_s905y2_u221.dts +++ b/arch/arm64/boot/dts/amlogic/g12a_s905y2_u221.dts @@ -390,6 +390,9 @@ gamma_en = <0>;/*1:enabel ;0:disable*/ wb_en = <0>;/*1:enabel ;0:disable*/ cm_en = <0>;/*1:enabel ;0:disable*/ + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; + }; amdolby_vision { diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts index 960e6d8..d73bb8a 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_1g.dts @@ -1079,6 +1079,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_1g_buildroot.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_1g_buildroot.dts index 776c1fb..7b61b8d 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_1g_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_1g_buildroot.dts @@ -1133,6 +1133,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_1g_hd.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_1g_hd.dts index dff87f5..070ebe3c 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_1g_hd.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_1g_hd.dts @@ -1079,6 +1079,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts index addc640d..ba687a2 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_2g.dts @@ -1089,6 +1089,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p212_2g_buildroot.dts b/arch/arm64/boot/dts/amlogic/gxl_p212_2g_buildroot.dts index bd759d8..dc2989b 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p212_2g_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p212_2g_buildroot.dts @@ -1134,6 +1134,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts b/arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts index 357f82c..b720dae 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p230_2g.dts @@ -1121,6 +1121,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p230_2g_buildroot.dts b/arch/arm64/boot/dts/amlogic/gxl_p230_2g_buildroot.dts index 7b315dd..7756139 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p230_2g_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p230_2g_buildroot.dts @@ -1176,6 +1176,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p231_1g.dts b/arch/arm64/boot/dts/amlogic/gxl_p231_1g.dts index 4546b4f..6fd4893 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p231_1g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p231_1g.dts @@ -1003,6 +1003,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p231_2g.dts b/arch/arm64/boot/dts/amlogic/gxl_p231_2g.dts index 81a0062..c12eb8d 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p231_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p231_2g.dts @@ -1003,6 +1003,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p231_2g_buildroot.dts b/arch/arm64/boot/dts/amlogic/gxl_p231_2g_buildroot.dts index 3298a6a..7eb89fd 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p231_2g_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p231_2g_buildroot.dts @@ -1072,6 +1072,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p241_1g.dts b/arch/arm64/boot/dts/amlogic/gxl_p241_1g.dts index 12dab2a..8cdf896 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p241_1g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p241_1g.dts @@ -1142,6 +1142,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p241_1g_buildroot.dts b/arch/arm64/boot/dts/amlogic/gxl_p241_1g_buildroot.dts index fc4b7cb..b35c5ea 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p241_1g_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p241_1g_buildroot.dts @@ -1211,6 +1211,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p241_v2-1g.dts b/arch/arm64/boot/dts/amlogic/gxl_p241_v2-1g.dts index 39b765a..e01aa2d 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p241_v2-1g.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p241_v2-1g.dts @@ -1,3 +1,4 @@ + /* * arch/arm64/boot/dts/amlogic/gxl_p241_v2-1g.dts * @@ -1142,6 +1143,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxl_p241_v2_1g_buildroot.dts b/arch/arm64/boot/dts/amlogic/gxl_p241_v2_1g_buildroot.dts index ee89031..2407e82 100644 --- a/arch/arm64/boot/dts/amlogic/gxl_p241_v2_1g_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/gxl_p241_v2_1g_buildroot.dts @@ -1210,6 +1210,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; unifykey{ diff --git a/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts b/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts index 378a1e3..80d5d13d 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_q200_2g.dts @@ -1102,6 +1102,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { compatible = "amlogic, dolby_vision_gxm"; diff --git a/arch/arm64/boot/dts/amlogic/gxm_q200_2g_buildroot.dts b/arch/arm64/boot/dts/amlogic/gxm_q200_2g_buildroot.dts index eec6016..0fb2a67 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_q200_2g_buildroot.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_q200_2g_buildroot.dts @@ -1088,6 +1088,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; partitions: partitions{ diff --git a/arch/arm64/boot/dts/amlogic/gxm_q201_1g.dts b/arch/arm64/boot/dts/amlogic/gxm_q201_1g.dts index 93e4d37..5c676f0 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_q201_1g.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_q201_1g.dts @@ -1083,6 +1083,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { compatible = "amlogic, dolby_vision_gxm"; diff --git a/arch/arm64/boot/dts/amlogic/gxm_q201_2g.dts b/arch/arm64/boot/dts/amlogic/gxm_q201_2g.dts index aeef3c0..5ebc693 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_q201_2g.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_q201_2g.dts @@ -1093,6 +1093,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { compatible = "amlogic, dolby_vision_gxm"; diff --git a/arch/arm64/boot/dts/amlogic/gxm_skt.dts b/arch/arm64/boot/dts/amlogic/gxm_skt.dts index f5243d0..0a19dd2 100644 --- a/arch/arm64/boot/dts/amlogic/gxm_skt.dts +++ b/arch/arm64/boot/dts/amlogic/gxm_skt.dts @@ -940,6 +940,8 @@ cm_en = <0>;/*1:enabel ;0:disable*/ /*1:enabel osd lut 100 table;0:disable*/ cfg_en_osd_100 = <1>; + /*0: 709/601 1: bt2020*/ + tx_op_color_primary = <0>; }; amdolby_vision { compatible = "amlogic, dolby_vision_gxm"; diff --git a/drivers/amlogic/media/enhancement/amvecm/amcsc.c b/drivers/amlogic/media/enhancement/amvecm/amcsc.c index 6f3f8a7..f981544 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amcsc.c +++ b/drivers/amlogic/media/enhancement/amvecm/amcsc.c @@ -1319,6 +1319,17 @@ static int YUV709l_to_RGB709_coeff[MATRIX_5x3_COEF_SIZE] = { 0, 0, 0 /* mode, right_shift, clip_en */ }; +static int YUV709l_to_YUV2020_coeff[MATRIX_5x3_COEF_SIZE] = { + -64, -512, -512, /* pre offset */ + 0x400, 0x1fe4, 0x2b, + 0, 0x39f, 0x1fe5, + 0x0, 0xc, 0x321, + 0, 0, 0, /* 30/31/32 */ + 0, 0, 0, /* 40/41/42 */ + 64, 512, 512, /* offset */ + 0, 0, 0 /* mode, right_shift, clip_en */ +}; + static int YUV709f_to_RGB709_coeff[MATRIX_5x3_COEF_SIZE] = { 0, -512, -512, /* pre offset */ COEFF_NORM(1.0), COEFF_NORM(0.00000), COEFF_NORM(1.575), @@ -5043,6 +5054,305 @@ static void bypass_hdr_process( vpp_set_mtx_en_write(); } +static void set_bt2020csc_process( + enum vpp_matrix_csc_e csc_type, + struct vinfo_s *vinfo, + struct vframe_master_display_colour_s *master_info) +{ + struct matrix_s osd_m = { + {0, 0, 0}, + { + {0x505, 0x2A2, 0x059}, + {0x08E, 0x75B, 0x017}, + {0x022, 0x0B4, 0x72A}, + }, + {0, 0, 0}, + 1 + }; + int osd_mtx[EOTF_COEFF_SIZE] = { + EOTF_COEFF_NORM(0.627441), EOTF_COEFF_NORM(0.329285), + EOTF_COEFF_NORM(0.043274), + EOTF_COEFF_NORM(0.069092), EOTF_COEFF_NORM(0.919556), + EOTF_COEFF_NORM(0.011322), + EOTF_COEFF_NORM(0.016418), EOTF_COEFF_NORM(0.088058), + EOTF_COEFF_NORM(0.895554), + EOTF_COEFF_RIGHTSHIFT + }; + int i, j; + + /*vpp matrix mux read*/ + vpp_set_mtx_en_read(); + if (get_cpu_type() > MESON_CPU_MAJOR_ID_GXTVBB) { + /************** OSD ***************/ + /* RGB to YUV */ + /* not using old RGB2YUV convert HW */ + /* use new 10bit OSD convert matrix */ + /* WRITE_VPP_REG_BITS*/ + /*(VIU_OSD1_BLK0_CFG_W0,0, 7, 1);*/ + if ((csc_type == VPP_MATRIX_BT2020YUV_BT2020RGB) && + ((vinfo->hdr_info.hdr_support & 0x4) && + (vinfo->viu_color_fmt != COLOR_FMT_RGB444))) { + /* OSD convert to HDR to match HDR video */ + /* osd eotf lut 709 */ + if (get_hdr_type() & HLG_FLAG) + set_vpp_lut(VPP_LUT_OSD_EOTF, + osd_eotf_33_sdr2hlg_mapping, /* R */ + osd_eotf_33_sdr2hlg_mapping, /* G */ + osd_eotf_33_sdr2hlg_mapping, /* B */ + CSC_ON); + else + set_vpp_lut(VPP_LUT_OSD_EOTF, + osd_eotf_33_709_mapping, /* R */ + osd_eotf_33_709_mapping, /* G */ + osd_eotf_33_709_mapping, /* B */ + CSC_ON); + + /* osd eotf matrix 709->2020 */ + if (master_info->present_flag & 1) { + pr_csc("\tMaster_display_colour available.\n"); + print_primaries_info(master_info); + prepare_customer_matrix( + &master_info->primaries, + &master_info->white_point, + vinfo, &osd_m, 1); + } else { + pr_csc("\tNo master_display_colour.\n"); + prepare_customer_matrix( + &bt2020_primaries, + &bt2020_white_point, + vinfo, &osd_m, 1); + } + osd_mtx[EOTF_COEFF_SIZE - 1] = osd_m.right_shift; + for (i = 0; i < 3; i++) + for (j = 0; j < 3; j++) { + if (osd_m.matrix[i][j] & 0x1000) { + osd_mtx[i * 3 + j] = + (~osd_m.matrix[i][j]) & 0xfff; + osd_mtx[i * 3 + j] = + -(1 + osd_mtx[i * 3 + j]); + } else + osd_mtx[i * 3 + j] = + osd_m.matrix[i][j]; + } + set_vpp_matrix(VPP_MATRIX_OSD_EOTF, + osd_mtx, + CSC_ON); + + /* osd oetf lut 2084 */ + if (get_hdr_type() & HLG_FLAG) + set_vpp_lut(VPP_LUT_OSD_OETF, + osd_oetf_41_sdr2hlg_mapping, /* R */ + osd_oetf_41_sdr2hlg_mapping, /* G */ + osd_oetf_41_sdr2hlg_mapping, /* B */ + CSC_ON); + else + set_vpp_lut(VPP_LUT_OSD_OETF, + osd_oetf_41_2084_mapping, /* R */ + osd_oetf_41_2084_mapping, /* G */ + osd_oetf_41_2084_mapping, /* B */ + CSC_ON); + + /* osd matrix RGB2020 to YUV2020 limit */ + set_vpp_matrix(VPP_MATRIX_OSD, + RGB2020_to_YUV2020l_coeff, + CSC_ON); + } else { + /* OSD convert to 709 limited to match SDR video */ + /* eotf lut bypass */ + set_vpp_lut(VPP_LUT_OSD_EOTF, + eotf_33_linear_mapping, /* R */ + eotf_33_linear_mapping, /* G */ + eotf_33_linear_mapping, /* B */ + CSC_OFF); + + /* eotf matrix bypass */ + set_vpp_matrix(VPP_MATRIX_OSD_EOTF, + eotf_bypass_coeff, + CSC_OFF); + + /* oetf lut bypass */ + set_vpp_lut(VPP_LUT_OSD_OETF, + oetf_41_linear_mapping, /* R */ + oetf_41_linear_mapping, /* G */ + oetf_41_linear_mapping, /* B */ + CSC_OFF); + + /* osd matrix RGB709 to YUV709 limit/full */ + if (range_control) + set_vpp_matrix(VPP_MATRIX_OSD, + RGB709_to_YUV709_coeff, + CSC_ON); /* use full range */ + else + set_vpp_matrix(VPP_MATRIX_OSD, + RGB709_to_YUV709l_coeff, + CSC_ON); /* use limit range */ + } + + /************** VIDEO **************/ + /* vd1 matrix: bypass */ + if (csc_type == VPP_MATRIX_BT2020YUV_BT2020RGB) + set_vpp_matrix(VPP_MATRIX_VD1, + bypass_coeff, + CSC_OFF); /* limit->limit range */ + else { + if (vinfo->viu_color_fmt == COLOR_FMT_RGB444) { + if (signal_range == 0) {/* limit range */ + if (csc_type == VPP_MATRIX_YUV601_RGB) + set_vpp_matrix(VPP_MATRIX_VD1, + range_control ? + YUV601l_to_YUV709f_coeff : + YUV601l_to_YUV709l_coeff, + CSC_ON); + else + set_vpp_matrix(VPP_MATRIX_VD1, + range_control ? + YUV709l_to_YUV709f_coeff : + bypass_coeff, + CSC_ON); + } else { + if (csc_type == VPP_MATRIX_YUV601_RGB) + set_vpp_matrix(VPP_MATRIX_VD1, + range_control ? + YUV601f_to_YUV709f_coeff : + YUV601f_to_YUV709l_coeff, + CSC_ON); + else + set_vpp_matrix(VPP_MATRIX_VD1, + range_control ? + bypass_coeff : + YUV709f_to_YUV709l_coeff, + CSC_ON); + } + } else { + /*default limit range */ + if (vd1_mtx_sel == VPP_MATRIX_NULL) + set_vpp_matrix(VPP_MATRIX_VD1, + bypass_coeff, + CSC_OFF); + else if (vd1_mtx_sel == + VPP_MATRIX_YUV601L_YUV709L) + set_vpp_matrix(VPP_MATRIX_VD1, + YUV601l_to_YUV709l_coeff, + CSC_ON); + else if (vd1_mtx_sel == + VPP_MATRIX_YUV709L_YUV601L) + set_vpp_matrix(VPP_MATRIX_VD1, + YUV709l_to_YUV601l_coeff, + CSC_ON); + } + } + + /* post matrix bypass */ + if (vinfo->viu_color_fmt != COLOR_FMT_RGB444) + /* yuv2rgb for eye protect mode */ + set_vpp_matrix(VPP_MATRIX_POST, + YUV709l_to_YUV2020_coeff, + CSC_ON); + else {/* matrix yuv2rgb for LCD */ + if (range_control) + set_vpp_matrix(VPP_MATRIX_POST, + YUV709f_to_RGB709_coeff, + CSC_ON); + else + set_vpp_matrix(VPP_MATRIX_POST, + YUV709l_to_RGB709_coeff, + CSC_ON); + } + /* xvycc inv lut */ + if (sdr_process_mode && + (csc_type < VPP_MATRIX_BT2020YUV_BT2020RGB) && + ((get_cpu_type() == MESON_CPU_MAJOR_ID_GXTVBB) || + (get_cpu_type() == MESON_CPU_MAJOR_ID_TXL))) + set_vpp_lut(VPP_LUT_INV_EOTF, + NULL, + NULL, + NULL, + CSC_ON); + else + set_vpp_lut(VPP_LUT_INV_EOTF, + NULL, + NULL, + NULL, + CSC_OFF); + + /* eotf lut bypass */ + set_vpp_lut(VPP_LUT_EOTF, + NULL, /* R */ + NULL, /* G */ + NULL, /* B */ + CSC_OFF); + + /* eotf matrix bypass */ + set_vpp_matrix(VPP_MATRIX_EOTF, + bypass_coeff, + CSC_OFF); + + /* oetf lut bypass */ + set_vpp_lut(VPP_LUT_OETF, + NULL, + NULL, + NULL, + CSC_OFF); + + /* xvycc matrix full2limit or bypass */ + if (vinfo->viu_color_fmt != COLOR_FMT_RGB444) { + if (csc_type == VPP_MATRIX_BT2020YUV_BT2020RGB) + set_vpp_matrix(VPP_MATRIX_XVYCC, + bypass_coeff, + CSC_ON); + else + set_vpp_matrix(VPP_MATRIX_XVYCC, + bypass_coeff, + CSC_OFF); + } + } else { + /* OSD */ + /* keep RGB */ + + /* VIDEO */ + if (csc_type == VPP_MATRIX_BT2020YUV_BT2020RGB) { + /* vd1 matrix: convert YUV to RGB */ + csc_type = VPP_MATRIX_YUV709_RGB; + } + /* vd1 matrix on to convert YUV to RGB */ + vpp_set_matrix(VPP_MATRIX_VD1, CSC_ON, + csc_type, NULL); + /* post matrix off */ + vpp_set_matrix(VPP_MATRIX_POST, CSC_OFF, + csc_type, NULL); + /* xvycc lut off */ + load_knee_lut(CSC_OFF); + /* xvycc inv lut */ + + if (sdr_process_mode) + set_vpp_lut(VPP_LUT_INV_EOTF, + NULL, + NULL, + NULL, + CSC_ON); + else + set_vpp_lut(VPP_LUT_INV_EOTF, + NULL, + NULL, + NULL, + CSC_OFF); + + vecm_latch_flag |= FLAG_VADJ1_BRI; + hdr_process_pq_enable(1); + /* if GXTVBB HDMI output(YUV) case */ + /* xvyccc matrix3: RGB to YUV */ + /* other cases */ + /* xvyccc matrix3: bypass */ + if ((vinfo->viu_color_fmt != COLOR_FMT_RGB444) && + (get_cpu_type() == MESON_CPU_MAJOR_ID_GXTVBB)) + vpp_set_matrix3(CSC_ON, VPP_MATRIX_RGB_YUV709); + else + vpp_set_matrix3(CSC_OFF, VPP_MATRIX_NULL); + } + /*vpp matrix mux write*/ + vpp_set_mtx_en_write(); +} + static void hlg_hdr_process( enum vpp_matrix_csc_e csc_type, struct vinfo_s *vinfo, @@ -5556,7 +5866,8 @@ static int vpp_matrix_update( /* send hdr info */ /* use the features to discribe source info */ send_info.features = - (1 << 29) /* video available */ + (0 << 30) /*sdr output 709*/ + | (1 << 29) /*video available*/ | (5 << 26) /* unspecified */ | (0 << 25) /* limit */ | (1 << 24) /* color available */ @@ -5578,10 +5889,11 @@ static int vpp_matrix_update( /* source is hdr, send hdr info */ /* use the features to discribe source info */ send_info.features = - (1 << 29) /* video available */ + (0 << 30) /*sdr output 709*/ + | (1 << 29) /*video available*/ | (5 << 26) /* unspecified */ | (0 << 25) /* limit */ - | (1 << 24) /* color available */ + | (1 << 24) /*color available*/ /* bt2020 */ | (signal_color_primaries << 16) /* bt2020-10 */ @@ -5603,10 +5915,11 @@ static int vpp_matrix_update( /* use the features to discribe source info */ if (get_hdr_type() & HLG_FLAG) send_info.features = - (1 << 29) /* video available */ + (0 << 30) /*sdr output 709*/ + | (1 << 29) /*video available*/ | (5 << 26) /* unspecified */ | (0 << 25) /* limit */ - | (1 << 24) /* color available */ + | (1 << 24) /*color available*/ /* bt2020 */ | (9 << 16) /* bt2020-10 */ @@ -5614,10 +5927,11 @@ static int vpp_matrix_update( | (10 << 0); /* bt2020c */ else send_info.features = - (1 << 29) /* video available */ + (0 << 30) /*sdr output 709*/ + | (1 << 29) /*video available*/ | (5 << 26) /* unspecified */ | (0 << 25) /* limit */ - | (1 << 24) /* color available */ + | (1 << 24) /*color available*/ /* bt2020 */ | (signal_color_primaries << 16) /* bt2020-10 */ @@ -5639,10 +5953,11 @@ static int vpp_matrix_update( /* use the features to discribe source info */ if (get_hdr_type() & HLG_FLAG) send_info.features = - (1 << 29) /* video available */ + (0 << 30) /*sdr output 709*/ + | (1 << 29) /*video available*/ | (5 << 26) /* unspecified */ | (0 << 25) /* limit */ - | (1 << 24) /* color available */ + | (1 << 24) /*color available*/ /* bt2020 */ | (signal_color_primaries << 16) /* bt2020-10 */ @@ -5651,10 +5966,11 @@ static int vpp_matrix_update( else send_info.features = /* default 709 full */ - (1 << 29) /* video available */ + (0 << 30) /*sdr output 709*/ + | (1 << 29) /*video available*/ | (5 << 26) /* unspecified */ | (0 << 25) /* limit */ - | (1 << 24) /* color available */ + | (1 << 24) /*color available*/ | (1 << 16) /* bt709 */ | (1 << 8) /* bt709 */ | (1 << 0); /* bt709 */ @@ -5670,12 +5986,28 @@ static int vpp_matrix_update( } else { /* sdr source send normal info*/ /* use the features to discribe source info */ - send_info.features = + if (((vinfo->hdr_info.hdr_support & HDR_SUPPORT) | + (vinfo->hdr_info.hdr_support & HLG_SUPPORT)) && + (csc_type < VPP_MATRIX_BT2020YUV_BT2020RGB) && + tx_op_color_primary) + send_info.features = /* default 709 limit */ - (1 << 29) /* video available */ + (1 << 30) /*sdr output 2020*/ + | (1 << 29) /*video available*/ | (5 << 26) /* unspecified */ | (0 << 25) /* limit */ - | (1 << 24) /* color available */ + | (1 << 24) /*color available*/ + | (1 << 16) /* bt709 */ + | (1 << 8) /* bt709 */ + | (1 << 0); /* bt709 */ + else + send_info.features = + /* default 709 limit */ + (0 << 30) /*sdr output 709*/ + | (1 << 29) /*video available*/ + | (5 << 26) /* unspecified */ + | (0 << 25) /* limit */ + | (1 << 24) /*color available*/ | (1 << 16) /* bt709 */ | (1 << 8) /* bt709 */ | (1 << 0); /* bt709 */ @@ -5804,9 +6136,21 @@ static int vpp_matrix_update( if (get_cpu_type() == MESON_CPU_MAJOR_ID_G12A) { hdrbypass_func(VD1_HDR); hdrbypass_func(OSD1_HDR); - } else + } else { /* for gxtvbb and gxl HDR bypass process */ - bypass_hdr_process(csc_type, vinfo, p); + if (((vinfo->hdr_info.hdr_support & + HDR_SUPPORT) || + (vinfo->hdr_info.hdr_support & + HLG_SUPPORT)) && + (csc_type < + VPP_MATRIX_BT2020YUV_BT2020RGB) + && tx_op_color_primary) + set_bt2020csc_process(csc_type, + vinfo, p); + else + bypass_hdr_process(csc_type, + vinfo, p); + } } } diff --git a/drivers/amlogic/media/enhancement/amvecm/amcsc.h b/drivers/amlogic/media/enhancement/amvecm/amcsc.h index bd698b8..7c8d47d 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amcsc.h +++ b/drivers/amlogic/media/enhancement/amvecm/amcsc.h @@ -126,6 +126,7 @@ extern uint sdr_mode; extern uint hdr_flag; extern int video_rgb_ogo_xvy_mtx_latch; extern int video_rgb_ogo_xvy_mtx; +extern int tx_op_color_primary; extern int amvecm_matrix_process( struct vframe_s *vf, struct vframe_s *vf_rpt, int flags); diff --git a/drivers/amlogic/media/enhancement/amvecm/amvecm.c b/drivers/amlogic/media/enhancement/amvecm/amvecm.c index bf3beef..35676ae 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amvecm.c +++ b/drivers/amlogic/media/enhancement/amvecm/amvecm.c @@ -153,6 +153,12 @@ unsigned int pq_user_latch_flag; module_param(pq_user_latch_flag, uint, 0664); MODULE_PARM_DESC(pq_user_latch_flag, "\n pq_user_latch_flag\n"); +/*0: 709/601 1: bt2020*/ +int tx_op_color_primary; +module_param(tx_op_color_primary, int, 0664); +MODULE_PARM_DESC(tx_op_color_primary, + "tx output color_primary"); + unsigned int pq_user_value; unsigned int hdr_source_type = 0x1; @@ -4495,7 +4501,11 @@ static void aml_vecm_dt_parse(struct platform_device *pdev) } else { hdr_set_cfg_osd_100((int)val); } - + ret = of_property_read_u32(node, "tx_op_color_primary", &val); + if (ret) + pr_info("Can't find tx_op_color_primary.\n"); + else + tx_op_color_primary = val; } /* init module status */ amvecm_wb_init(wb_en);