vdin: add vdin output color depth selection from dts
authorxuhua zhang <xuhua.zhang@amlogic.com>
Fri, 27 Jul 2018 09:09:48 +0000 (17:09 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Fri, 3 Aug 2018 10:05:03 +0000 (03:05 -0700)
PD#170749: vdin: add vdin output color depth selection

when vdin receive 4K && 50/60hz && 10bit data,
we can select vdin output color depth 8bit or 10bit from dts

Change-Id: I9c030b4769927dbf53880fad6c80707d7b282e86
Signed-off-by: xuhua zhang <xuhua.zhang@amlogic.com>
arch/arm64/boot/dts/amlogic/txl_t950_p341.dts
arch/arm64/boot/dts/amlogic/txl_t960_p346.dts
arch/arm64/boot/dts/amlogic/txl_t962_p320.dts
arch/arm64/boot/dts/amlogic/txl_t962_p321.dts
arch/arm64/boot/dts/amlogic/txlx_t962e_r321.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts
drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h

index 7e3b1d9e27068559c882ee7d905ce1f43e964222..1cedbe67e0d696ef2b790db3c58a0dd13d7b3cf7 100644 (file)
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin@1 {
index 36103e706f34a054f3f0a81914cf9291aca99c94..c70c0bee0e130cd0849051ca814807035991bde4 100644 (file)
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin@1 {
index de7e529e805eda123260e49daa0ce4387587138c..012940007262cca9da9dbc455ba3a740c9efafa3 100644 (file)
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin@1 {
index 63cf3bde6d88223a091c8e24f06972bec6d71bb4..952748236950ddba20f7b7a0fb269ddb3ccd8804 100644 (file)
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin@1 {
index d1d8f023a4a298c2c1c12a3267e7398e61b2efb6..af1c9842938bdd30d285958d9d0049f791053fb7 100644 (file)
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin1 {
index 690f140ec04baf74f5993726b1b05ee384b00bb1..374c7eeab15a852953c8b68fd14d1c6e36e187ce 100644 (file)
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin1 {
index cd69f4808c0fe04eed6f56a1f050ef12a3b0d4da..4bdef1a4c35131fba693bda60a0da2b3607abec3 100644 (file)
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin1 {
index 08ad64ef4c961754fe0dd1fd599f8cc9571c06d2..44ab2403a5b3549b72a203881d100cf75a73b07a 100644 (file)
                clocks = <&clkc CLKID_FCLK_DIV5>,
                        <&clkc CLKID_VDIN_MEAS_COMP>;
                clock-names = "fclk_div5", "cts_vdin_meas_clk";
-               vdin_id = <0>;
                /* vdin write mem color depth support:
                 * bit0:support 8bit
                 * bit1:support 9bit
                 * bit2:support 10bit
                 * bit3:support 12bit
                 * bit4:support yuv422 10bit full pack mode (from txl new add)
+                * bit8:use 8bit  at 4k_50/60hz_10bit
+                * bit9:use 10bit at 4k_50/60hz_10bit
                 */
-               tv_bit_mode = <21>;
+               tv_bit_mode = <0x215>;
        };
 
        vdin1 {
index d87a2b6c6c2b959a2b302fa723d89e79b64b5db4..1b8e3307d154e3c24cd528d61b994f381ffc00df 100644 (file)
@@ -3291,6 +3291,7 @@ void vdin_set_hvscale(struct vdin_dev_s *devp)
        if (vdin_ctl_dbg)
                pr_info(" dst vactive:%u.\n", devp->v_active);
 }
+
 /*set source_bitdepth
  *     base on color_depth_config:
  *             10, 8, 0, other
@@ -3298,6 +3299,17 @@ void vdin_set_hvscale(struct vdin_dev_s *devp)
 void vdin_set_bitdepth(struct vdin_dev_s *devp)
 {
        unsigned int offset = devp->addr_offset;
+       unsigned int set_width = 0;
+
+       if ((devp->output_color_depth) &&
+               ((devp->prop.fps == 50) || (devp->prop.fps == 60)) &&
+               ((devp->parm.info.fmt == TVIN_SIG_FMT_HDMI_3840_2160_00HZ) ||
+               (devp->parm.info.fmt == TVIN_SIG_FMT_HDMI_4096_2160_00HZ)) &&
+               (devp->prop.colordepth == 10)) {
+               set_width = devp->output_color_depth;
+               pr_info("set output color depth %d bit from dts\n", set_width);
+       }
+
        switch (devp->color_depth_config) {
        case 8:
                devp->source_bitdepth = 8;
@@ -3314,27 +3326,33 @@ void vdin_set_bitdepth(struct vdin_dev_s *devp)
                devp->source_bitdepth is controlled by colordepth
                change default to 10bit for 8in8out detail maybe lost
                 */
-               if (((devp->prop.color_format == TVIN_RGB444) ||
+               if ((devp->prop.color_format == TVIN_RGB444) ||
                        (devp->prop.color_format == TVIN_YUV444) ||
                        (devp->prop.color_format == TVIN_BGGR) ||
                        (devp->prop.color_format == TVIN_RGGB) ||
                        (devp->prop.color_format == TVIN_GBRG) ||
-                       (devp->prop.color_format == TVIN_GRBG)) &&
-                       ((devp->prop.colordepth <= 8) ||
-                       is_meson_txlx_cpu())) {
-                       /*txlx dmc is diff & bandwidth tension*/
+                       (devp->prop.color_format == TVIN_GRBG)) {
+                       devp->source_bitdepth = 8;
+                       wr_bits(offset, VDIN_WR_CTRL2, 0,
+                               VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
+               } else if (devp->prop.colordepth == 8) {
                        devp->source_bitdepth = 8;
                        wr_bits(offset, VDIN_WR_CTRL2, 0,
                                VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                } else if ((devp->color_depth_support &
                        VDIN_WR_COLOR_DEPTH_10BIT) &&
-                       (devp->dv.dv_flag == false) &&
-                       ((devp->dv.dolby_input &
-                               (1 << devp->index)) == false) &&
-                       (is_dolby_vision_enable() == false)) {
-                       devp->source_bitdepth = 10;
-                       wr_bits(offset, VDIN_WR_CTRL2, 1,
-                               VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
+                       (devp->prop.colordepth == 10)) {
+                       if (set_width == 8) {
+                               devp->source_bitdepth = 8;
+                               wr_bits(offset, VDIN_WR_CTRL2, 0,
+                                       VDIN_WR_10BIT_MODE_BIT,
+                                       VDIN_WR_10BIT_MODE_WID);
+                       } else {
+                               devp->source_bitdepth = 10;
+                               wr_bits(offset, VDIN_WR_CTRL2, 1,
+                                       VDIN_WR_10BIT_MODE_BIT,
+                                       VDIN_WR_10BIT_MODE_WID);
+                       }
                } else {
                        devp->source_bitdepth = 8;
                        wr_bits(offset, VDIN_WR_CTRL2, 0,
index ed5c768f1f71643b8858992319427cbdc6a0b1db..64ff21e6b4175e54ab28e8c9ccf61faba4dfeaef 100644 (file)
@@ -2444,9 +2444,17 @@ static int vdin_drv_probe(struct platform_device *pdev)
        if (ret)
                pr_info("no bit mode found, set 8bit as default\n");
 
-       vdevp->color_depth_support = bit_mode;
+       vdevp->color_depth_support = bit_mode & 0xff;
        vdevp->color_depth_config = 0;
 
+       ret = (bit_mode >> 8) & 0xff;
+       if (ret == 0)
+               vdevp->output_color_depth = 0;
+       else if (ret == 1)
+               vdevp->output_color_depth = 8;
+       else if (ret == 2)
+               vdevp->output_color_depth = 10;
+
        if (vdevp->color_depth_support&VDIN_WR_COLOR_DEPTH_10BIT_FULL_PCAK_MODE)
                vdevp->color_depth_mode = 1;
        else
index 1ead28def3c8efdca032661ade137ec0f868a771..4438f8d34859dfb19c5d425746b11c43e865d1a3 100644 (file)
@@ -272,6 +272,11 @@ struct vdin_dev_s {
         *0: config 10bit as 12bit
         */
        unsigned int color_depth_mode;
+       /* output_color_depth:
+        * when tv_input is 4k50hz_10bit or 4k60hz_10bit,
+        * choose output color depth from dts
+        */
+       unsigned int output_color_depth;
        /* cutwindow config */
        bool cutwindow_cfg;
        bool auto_cutwindow_en;