stb_dv: send the correct hdmi packet in dv/hdr/sdr mode
authorBrian Zhu <brian.zhu@amlogic.com>
Thu, 17 May 2018 10:55:05 +0000 (18:55 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Fri, 29 Jun 2018 08:49:12 +0000 (01:49 -0700)
PD#166555: stb_dv: send the correct hdmi packet in dv/hdr/sdr mode

hdmitx must clear hdr and dv enable bits when changing mode

Change-Id: I76131c8bdbf1f6a0144d481453f0fa18b3f558d1
Signed-off-by: Brian Zhu <brian.zhu@amlogic.com>
Signed-off-by: Yi Zhou <yi.zhou@amlogic.com>
drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c
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

index fddfef1..88d14c4 100644 (file)
@@ -4071,6 +4071,8 @@ static int prepare_vsif_pkt(
 }
 #endif
 
+/* #define HDMI_SEND_ALL_PKT */
+static u32 last_dst_format = FORMAT_SDR;
 static bool send_hdmi_pkt(
        enum signal_format_e dst_format,
        const struct vinfo_s *vinfo)
@@ -4187,10 +4189,12 @@ static bool send_hdmi_pkt(
                if (vinfo && vinfo->vout_device &&
                        vinfo->vout_device->fresh_tx_hdr_pkt)
                        vinfo->vout_device->fresh_tx_hdr_pkt(&hdr10_data);
+#ifdef HDMI_SEND_ALL_PKT
                if (vinfo && vinfo->vout_device &&
                        vinfo->vout_device->fresh_tx_vsif_pkt)
                        vinfo->vout_device->fresh_tx_vsif_pkt(0, 0, NULL);
-
+#endif
+               last_dst_format = dst_format;
                if (flag) {
                        pr_dolby_dbg("Info frame for hdr10 changed:\n");
                        for (i = 0; i < 3; i++)
@@ -4216,10 +4220,11 @@ static bool send_hdmi_pkt(
 
                memset(&vsif, 0, sizeof(vsif));
 #ifdef V2_4
-       if (vinfo)
-               prepare_vsif_pkt(
-                       &vsif, &dovi_setting, vinfo);
+               if (vinfo)
+                       prepare_vsif_pkt(
+                               &vsif, &dovi_setting, vinfo);
 #endif
+#ifdef HDMI_SEND_ALL_PKT
                hdr10_data.features =
                          (1 << 29)     /* video available */
                        | (5 << 26)     /* unspecified */
@@ -4241,6 +4246,7 @@ static bool send_hdmi_pkt(
                if (vinfo && vinfo->vout_device &&
                        vinfo->vout_device->fresh_tx_hdr_pkt)
                        vinfo->vout_device->fresh_tx_hdr_pkt(&hdr10_data);
+#endif
                if (vinfo && vinfo->vout_device &&
                        vinfo->vout_device->fresh_tx_vsif_pkt) {
 #ifdef V2_4
@@ -4258,31 +4264,38 @@ static bool send_hdmi_pkt(
                                        DOLBY_VISION_OUTPUT_MODE_IPT_TUNNEL
                                        ? RGB_8BIT : YUV422_BIT12, &vsif);
                }
-       } else {
-               hdr10_data.features =
-                         (1 << 29)     /* video available */
-                       | (5 << 26)     /* unspecified */
-                       | (0 << 25)     /* limit */
-                       | (1 << 24)     /* color available */
-                       | (1 << 16)     /* bt709 */
-                       | (1 << 8)      /* bt709 */
-                       | (1 << 0);     /* bt709 */
-               for (i = 0; i < 3; i++) {
-                       hdr10_data.primaries[i][0] = 0;
-                       hdr10_data.primaries[i][1] = 0;
+               last_dst_format = dst_format;
+       } else if (last_dst_format != dst_format) {
+               if (last_dst_format == FORMAT_HDR10) {
+                       hdr10_data.features =
+                                 (1 << 29)     /* video available */
+                               | (5 << 26)     /* unspecified */
+                               | (0 << 25)     /* limit */
+                               | (1 << 24)     /* color available */
+                               | (1 << 16)     /* bt709 */
+                               | (1 << 8)      /* bt709 */
+                               | (1 << 0);     /* bt709 */
+                       for (i = 0; i < 3; i++) {
+                               hdr10_data.primaries[i][0] = 0;
+                               hdr10_data.primaries[i][1] = 0;
+                       }
+                       hdr10_data.white_point[0] = 0;
+                       hdr10_data.white_point[1] = 0;
+                       hdr10_data.luminance[0] = 0;
+                       hdr10_data.luminance[1] = 0;
+                       hdr10_data.max_content = 0;
+                       hdr10_data.max_frame_average = 0;
+                       if (vinfo && vinfo->vout_device &&
+                               vinfo->vout_device->fresh_tx_hdr_pkt)
+                               vinfo->vout_device->fresh_tx_hdr_pkt(
+                                       &hdr10_data);
+               } else if (last_dst_format == FORMAT_DOVI) {
+                       if (vinfo && vinfo->vout_device &&
+                               vinfo->vout_device->fresh_tx_vsif_pkt)
+                               vinfo->vout_device->fresh_tx_vsif_pkt(
+                                       0, 0, NULL);
                }
-               hdr10_data.white_point[0] = 0;
-               hdr10_data.white_point[1] = 0;
-               hdr10_data.luminance[0] = 0;
-               hdr10_data.luminance[1] = 0;
-               hdr10_data.max_content = 0;
-               hdr10_data.max_frame_average = 0;
-               if (vinfo && vinfo->vout_device &&
-                       vinfo->vout_device->fresh_tx_hdr_pkt)
-                       vinfo->vout_device->fresh_tx_hdr_pkt(&hdr10_data);
-               if (vinfo && vinfo->vout_device &&
-                       vinfo->vout_device->fresh_tx_vsif_pkt)
-                       vinfo->vout_device->fresh_tx_vsif_pkt(0, 0, NULL);
+               last_dst_format = dst_format;
        }
        return flag;
 }
index a91bbe3..226ead0 100644 (file)
@@ -1328,6 +1328,9 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                                VEN_DB1[4] = 0x4;
                }
                if (type == EOTF_T_DOLBYVISION) {
+                       /*first disable drm package*/
+                       hdmitx_device.HWOp.SetPacket(HDMI_PACKET_DRM,
+                               NULL, NULL);
                        hdev->HWOp.SetPacket(HDMI_PACKET_VEND, VEN_DB1, VEN_HB);
                        hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
                                CLR_AVI_BT2020);/*BT709*/
@@ -1407,6 +1410,9 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
 
                /*Dolby Vision standard case*/
                if (type == EOTF_T_DOLBYVISION) {
+                       /*first disable drm package*/
+                       hdmitx_device.HWOp.SetPacket(HDMI_PACKET_DRM,
+                               NULL, NULL);
                        hdev->HWOp.SetPacket(HDMI_PACKET_VEND, VEN_DB2, VEN_HB);
                        hdev->HWOp.CntlConfig(hdev, CONF_AVI_BT2020,
                                CLR_AVI_BT2020);/*BT709*/
@@ -1426,6 +1432,9 @@ static void hdmitx_set_vsif_pkt(enum eotf_type type,
                }
                /*Dolby Vision low-latency case*/
                else if  (type == EOTF_T_LL_MODE) {
+                       /*first disable drm package*/
+                       hdmitx_device.HWOp.SetPacket(HDMI_PACKET_DRM,
+                               NULL, NULL);
                        hdev->HWOp.SetPacket(HDMI_PACKET_VEND, VEN_DB2, VEN_HB);
                        if (hdev->RXCap.colorimetry_data & 0xe0)
                                /*if RX support BT2020, then output BT2020*/
index bd9ffba..7317c42 100644 (file)
@@ -4373,6 +4373,16 @@ static void config_hdmi20_tx(enum hdmi_vic vic,
                hdmitx_set_reg_bits(HDMITX_DWC_FC_PACKET_TX_EN, 0, 7, 1);
        }
 
+       /* If RX  support 3D, then enable 3D send out */
+       if (hdev->flag_3dfp || hdev->flag_3dtb || hdev->flag_3dss) {
+               hdmitx_set_reg_bits(HDMITX_DWC_FC_DATAUTO0, 1, 3, 1);
+               hdmitx_set_reg_bits(HDMITX_DWC_FC_PACKET_TX_EN, 1, 4, 1);
+       } else {
+         /* after changing mode, dv will call vsif function again*/
+               hdmitx_set_reg_bits(HDMITX_DWC_FC_DATAUTO0, 0, 3, 1);
+               hdmitx_set_reg_bits(HDMITX_DWC_FC_PACKET_TX_EN, 0, 4, 1);
+       }
+
        hdmitx_wr_reg(HDMITX_DWC_FC_RDRB0,  0);
        hdmitx_wr_reg(HDMITX_DWC_FC_RDRB1,  0);
        hdmitx_wr_reg(HDMITX_DWC_FC_RDRB2,  0);