hdmitx: use bt2020 in aviinfo on dv LL mode
authorYi Zhou <yi.zhou@amlogic.com>
Tue, 10 Apr 2018 06:39:33 +0000 (14:39 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 11 Apr 2018 06:15:26 +0000 (22:15 -0800)
PD#163981: hdmitx: use bt2020 in aviinfo on dv LL mode

1.add bt2020 in aviinfo
2.porting PD151662 to kernel4.9
3.use system 422 mode

Change-Id: Ia4cd60c02e6fc02eef001d296ca20b504f1f3e2a
Signed-off-by: Yi Zhou <yi.zhou@amlogic.com>
drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c
drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hw/hdmi_tx_hw.c
include/linux/amlogic/media/vout/vinfo.h

index 07333f1..b4954b3 100644 (file)
@@ -1135,9 +1135,12 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                pr_info("hdmitx: not support DolbyVision\n");
                return;
        }
-/*ver0 and ver1_15 use hdmi 1.4b VSIF*/
+       /*ver0 and ver1_15 and ver1_12bit with ll= 0 use hdmi 1.4b VSIF*/
        if ((hdev->RXCap.dv_info.ver == 0) || ((hdev->RXCap.dv_info.ver == 1)
-               && (hdev->RXCap.dv_info.length == 0xE))) {
+               && (hdev->RXCap.dv_info.length == 0xE))
+               || ((hdev->RXCap.dv_info.ver == 1)
+               && (hdev->RXCap.dv_info.length == 0xB)
+               && (hdev->RXCap.dv_info.low_latency == 0))) {
                if ((vic == HDMI_3840x2160p30_16x9) ||
                    (vic == HDMI_3840x2160p25_16x9) ||
                    (vic == HDMI_3840x2160p24_16x9) ||
@@ -1179,6 +1182,8 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                }
                if (type == EOTF_T_DOLBYVISION) {
                        hdev->HWOp.SetPacket(HDMI_PACKET_VEND, VEN_DB1, VEN_HB);
+                       hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
+                               CLR_AVI_BT2020);/*BT709*/
                        if (tunnel_mode == RGB_8BIT) {
                                hdev->HWOp.CntlConfig(hdev,
                                        CONF_AVI_RGBYCC_INDIC,
@@ -1205,12 +1210,15 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                                CONF_AVI_Q01, RGB_RANGE_LIM);
                        hdev->HWOp.CntlConfig(hdev,
                                CONF_AVI_YQ01, YCC_RANGE_LIM);
+                       hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
+                               CLR_AVI_BT2020);/*BT709*/
                }
 
        }
-       /*ver1_12 and ver2 use Dolby VSIF*/
+       /*ver1_12  with low_latency = 1 and ver2 use Dolby VSIF*/
        if ((hdev->RXCap.dv_info.ver == 2) || ((hdev->RXCap.dv_info.ver == 1)
-               && (hdev->RXCap.dv_info.length == 0xB))
+               && (hdev->RXCap.dv_info.length == 0xB)
+               && (hdev->RXCap.dv_info.low_latency == 1))
                || (type == EOTF_T_LL_MODE)) {
 
                if (data == NULL)
@@ -1253,6 +1261,8 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                /*Dolby Vision standard case*/
                if (type == EOTF_T_DOLBYVISION) {
                        hdev->HWOp.SetPacket(HDMI_PACKET_VEND, VEN_DB2, VEN_HB);
+                       hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
+                               CLR_AVI_BT2020);/*BT709*/
                        if (tunnel_mode == RGB_8BIT) {/*RGB444*/
                                hdev->HWOp.CntlConfig(hdev,
                                        CONF_AVI_RGBYCC_INDIC,
@@ -1270,6 +1280,13 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                /*Dolby Vision low-latency case*/
                else if  (type == EOTF_T_LL_MODE) {
                        hdev->HWOp.SetPacket(HDMI_PACKET_VEND, VEN_DB2, VEN_HB);
+                       if (hdev->RXCap.colorimetry_data & 0xe0)
+                               /*if RX support BT2020, then output BT2020*/
+                               hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
+                                       SET_AVI_BT2020);/*BT2020*/
+                       else
+                               hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
+                                       CLR_AVI_BT2020);/*BT709*/
                        if (tunnel_mode == RGB_10_12BIT) {/*10/12bit RGB444*/
                                hdev->HWOp.CntlConfig(hdev,
                                        CONF_AVI_RGBYCC_INDIC,
@@ -1308,6 +1325,8 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                                CONF_AVI_Q01, RGB_RANGE_LIM);
                        hdev->HWOp.CntlConfig(hdev,
                                CONF_AVI_YQ01, YCC_RANGE_LIM);
+                       hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
+                               CLR_AVI_BT2020);/*BT709*/
                }
        }
 }
index d24a9f5..c0ed458 100644 (file)
@@ -1928,6 +1928,12 @@ void hdmitx_set_enc_hw(struct hdmitx_dev *hdev)
                hd_set_reg_bits(P_VPU_HDMI_SETTING, 1, 8, 1);
        }
 
+       if (hdev->para->cs == COLORSPACE_YUV422) {
+               hd_set_reg_bits(P_VPU_HDMI_FMT_CTRL, 1, 0, 2);
+               hd_set_reg_bits(P_VPU_HDMI_SETTING, 0, 4, 4);
+               hd_set_reg_bits(P_VPU_HDMI_SETTING, 0, 8, 1);
+       }
+
        switch (hdev->para->cd) {
        case COLORDEPTH_30B:
        case COLORDEPTH_36B:
@@ -1935,7 +1941,7 @@ void hdmitx_set_enc_hw(struct hdmitx_dev *hdev)
                if (hdev->chip_type >= MESON_CPU_ID_GXM) {
                        unsigned int hs_flag = 0;
                        /* 12-10 dithering on */
-                       hd_set_reg_bits(P_VPU_HDMI_FMT_CTRL, 1, 4, 1);
+                       hd_set_reg_bits(P_VPU_HDMI_FMT_CTRL, 0, 4, 1);
                        /* hsync/vsync not invert */
                        hs_flag = (hd_read_reg(P_VPU_HDMI_SETTING) >> 2) & 0x3;
                        hd_set_reg_bits(P_VPU_HDMI_SETTING, 0, 2, 2);
@@ -3855,20 +3861,34 @@ static void config_hdmi20_tx(enum hdmi_vic vic,
        hdmitx_wr_reg(HDMITX_TOP_BIST_CNTL, data32);
 
        /* Configure video */
-       vid_map = (input_color_format == COLORSPACE_RGB444) ?
-               ((color_depth == COLORDEPTH_24B) ? 0x01 :
-               (color_depth == COLORDEPTH_30B) ? 0x03 :
-               (color_depth == COLORDEPTH_36B) ? 0x05 :
-               0x07) :
-               ((input_color_format == COLORSPACE_YUV444) ||
-               (input_color_format == COLORSPACE_YUV420)) ?
-               ((color_depth == COLORDEPTH_24B) ? 0x09 :
-               (color_depth == COLORDEPTH_30B) ? 0x0b :
-               (color_depth == COLORDEPTH_36B) ? 0x0d :
-               0x0f) :
-               ((color_depth == COLORDEPTH_24B) ? 0x16 :
-               (color_depth == COLORDEPTH_30B) ? 0x14 :
-               0x12);
+       if (input_color_format == COLORSPACE_RGB444) {
+               if (color_depth == COLORDEPTH_24B)
+                       vid_map = 0x01;
+               else if (color_depth == COLORDEPTH_30B)
+                       vid_map = 0x03;
+               else if (color_depth == COLORDEPTH_36B)
+                       vid_map = 0x05;
+               else
+                       vid_map = 0x07;
+       } else if (((input_color_format == COLORSPACE_YUV444) ||
+               (input_color_format == COLORSPACE_YUV420)) &&
+               (output_color_format != COLORSPACE_YUV422)) {
+               if (color_depth == COLORDEPTH_24B)
+                       vid_map = 0x09;
+               else if (color_depth == COLORDEPTH_30B)
+                       vid_map = 0x0b;
+               else if (color_depth == COLORDEPTH_36B)
+                       vid_map = 0x0d;
+               else
+                       vid_map = 0x0f;
+       } else {
+               if (color_depth == COLORDEPTH_24B)
+                       vid_map = 0x16;
+               else if (color_depth == COLORDEPTH_30B)
+                       vid_map = 0x14;
+               else
+                       vid_map = 0x12;
+       }
 
        data32  = 0;
        data32 |= (0 << 7);
@@ -3897,8 +3917,6 @@ static void config_hdmi20_tx(enum hdmi_vic vic,
        data32  = 0;
        data32 |= ((((input_color_format == COLORSPACE_YUV422) &&
                (output_color_format != COLORSPACE_YUV422)) ? 2 : 0) << 4);
-       data32 |= ((((input_color_format != COLORSPACE_YUV422) &&
-               (output_color_format == COLORSPACE_YUV422)) ? 1 : 0) << 0);
        hdmitx_wr_reg(HDMITX_DWC_CSC_CFG, data32);
        hdmitx_csc_config(input_color_format, output_color_format, color_depth);
 
@@ -3912,12 +3930,8 @@ static void config_hdmi20_tx(enum hdmi_vic vic,
        if ((data32 & 0xf0) == 0x40)
                data32 &= ~(0xf << 4);
        hdmitx_wr_reg(HDMITX_DWC_VP_PR_CD,  data32);
-       if (output_color_format == COLORSPACE_YUV422) {
-               if (color_depth == COLORDEPTH_24B)
-                       hdmitx_set_reg_bits(HDMITX_DWC_VP_PR_CD, 0x4, 4, 4);
-               else
-                       hdmitx_set_reg_bits(HDMITX_DWC_VP_PR_CD, 0, 4, 4);
-       }
+       if (output_color_format == COLORSPACE_YUV422)
+               hdmitx_set_reg_bits(HDMITX_DWC_VP_PR_CD, 0x4, 4, 4);
 
        /* Video Packet Stuffing */
        data32  = 0;
index 21e3617..80625b1 100644 (file)
@@ -138,7 +138,7 @@ struct dv_info {
        uint8_t tmaxLUM;
        uint8_t colorimetry:1;/* ver1*/
        uint8_t tminLUM;
-       uint8_t low_latency:1;/* ver1_12 and 2*/
+       uint8_t low_latency;/* ver1_12 and 2*/
        uint8_t sup_backlight_control:1;/*only ver2*/
        uint8_t backlt_min_luma;/*only ver2*/
        uint8_t Interface;/*only ver2*/