vdin: vdin pixel probe [1/1]
authorYong Qin <yong.qin@amlogic.com>
Thu, 22 Aug 2019 07:34:41 +0000 (15:34 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Mon, 26 Aug 2019 06:42:12 +0000 (23:42 -0700)
PD#SWPL-13123

Problem:
add vdin pixel proble function

Solution:
1.matrix sel
2.post select
3.pixel proble

Verify:
TL1

Change-Id: I56f8898e92fee71662952481f06ed32e77b396ce
Signed-off-by: Yong Qin <yong.qin@amlogic.com>
drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c
drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.h
drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h

index cae279d05a02e5d372c9ac16c40cfe9fc2c2fd70..70bfb0ab4f6c44e414b82df33db80ddeb31a7dad 100644 (file)
@@ -631,7 +631,7 @@ enum vdin_format_convert_e vdin_get_format_convert_matrix1(
  *     g 19:10
  *     b 29:20
  */
-void vdin_get_prob_rgb(unsigned int offset,
+void vdin_prob_get_rgb(unsigned int offset,
                unsigned int *r, unsigned int *g, unsigned int *b)
 {
        *b = rgb_info_b = rd_bits(offset, VDIN_MATRIX_PROBE_COLOR,
@@ -642,6 +642,120 @@ void vdin_get_prob_rgb(unsigned int offset,
                COMPONENT0_PROBE_COLOR_BIT, COMPONENT0_PROBE_COLOR_WID);
 }
 
+void vdin_prob_get_yuv(unsigned int offset,
+               unsigned int *rgb_yuv0,
+               unsigned int *rgb_yuv1,
+               unsigned int *rgb_yuv2)
+{
+       *rgb_yuv0 = ((rd_bits(offset, VDIN_MATRIX_PROBE_COLOR,
+               COMPONENT2_PROBE_COLOR_BIT, COMPONENT2_PROBE_COLOR_WID)
+                       << 8) >> 10);
+       *rgb_yuv1 = ((rd_bits(offset, VDIN_MATRIX_PROBE_COLOR,
+               COMPONENT1_PROBE_COLOR_BIT, COMPONENT1_PROBE_COLOR_WID)
+                       << 8) >> 10);
+       *rgb_yuv2 = ((rd_bits(offset, VDIN_MATRIX_PROBE_COLOR,
+               COMPONENT0_PROBE_COLOR_BIT, COMPONENT0_PROBE_COLOR_WID)
+                       << 8) >> 10);
+}
+
+#if 0
+void vdin_prob_set_xy(unsigned int offset,
+               unsigned int x, unsigned int y, struct vdin_dev_s *devp)
+{
+
+       if (devp->fmt_info_p->scan_mode == TVIN_SCAN_MODE_INTERLACED)
+               y = y / 2;
+
+       wr_bits(offset, VDIN_MATRIX_PROBE_POS, y,
+               PROBE_POX_Y_BIT, PROBE_POX_Y_WID);
+       wr_bits(offset, VDIN_MATRIX_PROBE_POS, x,
+               PROBE_POS_X_BIT, PROBE_POS_X_WID);
+}
+#endif
+void vdin_prob_set_before_or_after_mat(unsigned int offset,
+               unsigned int x, struct vdin_dev_s *devp)
+{
+       if ((x != 0) && (x != 1))
+               return;
+       /* 1:probe pixel data after matrix */
+       wr_bits(offset, VDIN_MATRIX_CTRL, x,
+                       VDIN_PROBE_POST_BIT, VDIN_PROBE_POST_WID);
+}
+
+void vdin_prob_matrix_sel(unsigned int offset,
+               unsigned int sel, struct vdin_dev_s *devp)
+{
+       unsigned int x;
+
+       x = sel & 0x03;
+       /* 1:select matrix 1 */
+       wr_bits(offset, VDIN_MATRIX_CTRL, x,
+               VDIN_PROBE_SEL_BIT, VDIN_PROBE_SEL_WID);
+}
+
+
+/* this function set flowing parameters:
+ *a.rgb_info_x b.rgb_info_y
+ *debug usage:
+ *echo rgb_xy x y > /sys/class/vdin/vdinx/attr
+ */
+void vdin_prob_set_xy(unsigned int offset,
+               unsigned int x, unsigned int y, struct vdin_dev_s *devp)
+{
+#if 0
+       enum vdin_format_convert_e format_convert_matrix0;
+       enum vdin_format_convert_e format_convert_matrix1;
+
+       /* set matrix */
+       rgb_info_enable = 1;
+       format_convert_matrix0 = vdin_get_format_convert_matrix0(devp);
+       format_convert_matrix1 = vdin_get_format_convert_matrix1(devp);
+       vdin_set_color_matrix1(devp->addr_offset, devp->fmt_info_p,
+                       format_convert_matrix1,
+                       devp->parm.port,
+                       devp->prop.color_fmt_range,
+                       devp->prop.vdin_hdr_Flag,
+                       devp->color_range_mode);
+       if (is_meson_g12a_cpu() || is_meson_g12b_cpu() ||
+               is_meson_sm1_cpu() || is_meson_tm2_cpu())
+               vdin_set_color_matrix0_g12a(devp->addr_offset,
+                       devp->fmt_info_p,
+                       devp->format_convert,
+                       devp->parm.port,
+                       devp->prop.color_fmt_range,
+                       devp->prop.vdin_hdr_Flag,
+                       devp->color_range_mode);
+       else
+               vdin_set_color_matrix0(devp->addr_offset, devp->fmt_info_p,
+                       format_convert_matrix0,
+                       devp->parm.port,
+                       devp->prop.color_fmt_range,
+                       devp->prop.vdin_hdr_Flag,
+                       devp->color_range_mode);
+#endif
+
+       /* set position */
+       rgb_info_x = x;
+       if (devp->fmt_info_p->scan_mode == TVIN_SCAN_MODE_INTERLACED)
+               rgb_info_y = y / 2;
+       else
+               rgb_info_y = y;
+/* #if defined(VDIN_V1) */
+       wr_bits(offset, VDIN_MATRIX_PROBE_POS, rgb_info_y,
+               PROBE_POX_Y_BIT, PROBE_POX_Y_WID);
+       wr_bits(offset, VDIN_MATRIX_PROBE_POS, rgb_info_x,
+               PROBE_POS_X_BIT, PROBE_POS_X_WID);
+       #if 0
+       /* 1:probe pixel data after matrix */
+       wr_bits(offset, VDIN_MATRIX_CTRL, 1,
+               VDIN_PROBE_POST_BIT, VDIN_PROBE_POST_WID);
+       /* 1:select matrix 1 */
+       wr_bits(offset, VDIN_MATRIX_CTRL, 1,
+               VDIN_PROBE_SEL_BIT, VDIN_PROBE_SEL_WID);
+       #endif
+}
+
+
 /*function:
  *     1.set meas mux based on port_:
  *             0x01: /mpeg/                    0x10: /CVBS/
@@ -1732,63 +1846,6 @@ void vdin_set_matrixs(struct vdin_dev_s *devp, unsigned char id,
        }
 }
 
-/* this function set flowing parameters:
- *a.rgb_info_x b.rgb_info_y
- *debug usage:
- *echo rgb_xy x y > /sys/class/vdin/vdinx/attr
- */
-void vdin_set_prob_xy(unsigned int offset,
-               unsigned int x, unsigned int y, struct vdin_dev_s *devp)
-{
-       enum vdin_format_convert_e format_convert_matrix0;
-       enum vdin_format_convert_e format_convert_matrix1;
-
-       /* set matrix */
-       rgb_info_enable = 1;
-       format_convert_matrix0 = vdin_get_format_convert_matrix0(devp);
-       format_convert_matrix1 = vdin_get_format_convert_matrix1(devp);
-       vdin_set_color_matrix1(devp->addr_offset, devp->fmt_info_p,
-                       format_convert_matrix1,
-                       devp->parm.port,
-                       devp->prop.color_fmt_range,
-                       devp->prop.vdin_hdr_Flag,
-                       devp->color_range_mode);
-       if (is_meson_g12a_cpu() || is_meson_g12b_cpu() ||
-               is_meson_sm1_cpu() || is_meson_tm2_cpu())
-               vdin_set_color_matrix0_g12a(devp->addr_offset,
-                       devp->fmt_info_p,
-                       devp->format_convert,
-                       devp->parm.port,
-                       devp->prop.color_fmt_range,
-                       devp->prop.vdin_hdr_Flag,
-                       devp->color_range_mode);
-       else
-               vdin_set_color_matrix0(devp->addr_offset, devp->fmt_info_p,
-                       format_convert_matrix0,
-                       devp->parm.port,
-                       devp->prop.color_fmt_range,
-                       devp->prop.vdin_hdr_Flag,
-                       devp->color_range_mode);
-       /* set position */
-       rgb_info_x = x;
-       if (devp->fmt_info_p->scan_mode == TVIN_SCAN_MODE_INTERLACED)
-               rgb_info_y = y/2;
-       else
-               rgb_info_y = y;
-/* #if defined(VDIN_V1) */
-       wr_bits(offset, VDIN_MATRIX_PROBE_POS, rgb_info_y,
-               PROBE_POX_Y_BIT, PROBE_POX_Y_WID);
-       wr_bits(offset, VDIN_MATRIX_PROBE_POS, rgb_info_x,
-               PROBE_POS_X_BIT, PROBE_POS_X_WID);
-       /* 1:probe pixel data after matrix */
-       wr_bits(offset, VDIN_MATRIX_CTRL, 1,
-               VDIN_PROBE_POST_BIT, VDIN_PROBE_POST_WID);
-       /* 1:select matrix 1 */
-       wr_bits(offset, VDIN_MATRIX_CTRL, 1,
-               VDIN_PROBE_SEL_BIT, VDIN_PROBE_SEL_WID);
-/* #endif */
-}
-
 /*set block bar
  *base on flowing parameters:
  *a.h_active   b.v_active
index 0d7abf6c059363ea5b89e6569af0df7a8050e303..c693adfdbc93e41257e2b7949ebfe052879f6f3e 100644 (file)
@@ -136,7 +136,7 @@ extern enum vdin_format_convert_e vdin_get_format_convert_matrix1(
                struct vdin_dev_s *devp);
 extern void vdin_set_prob_xy(unsigned int offset, unsigned int x,
                unsigned int y, struct vdin_dev_s *devp);
-extern void vdin_get_prob_rgb(unsigned int offset, unsigned int *r,
+extern void vdin_prob_get_rgb(unsigned int offset, unsigned int *r,
                unsigned int *g, unsigned int *b);
 extern void vdin_set_all_regs(struct vdin_dev_s *devp);
 extern void vdin_set_default_regmap(unsigned int offset);
@@ -222,6 +222,15 @@ extern void vdin_vlock_input_sel(unsigned int type,
 extern void vdin_set_dolby_ll_tunnel(struct vdin_dev_s *devp);
 extern void vdin_check_hdmi_hdr(struct vdin_dev_s *devp);
 extern void vdin_dobly_mdata_write_en(unsigned int offset, unsigned int en);
+extern void vdin_prob_set_xy(unsigned int offset,
+               unsigned int x, unsigned int y, struct vdin_dev_s *devp);
+extern void vdin_prob_set_before_or_after_mat(unsigned int offset,
+               unsigned int x, struct vdin_dev_s *devp);
+extern void vdin_prob_get_yuv(unsigned int offset,
+               unsigned int *rgb_yuv0, unsigned int *rgb_yuv1,
+               unsigned int *rgb_yuv2);
+extern void vdin_prob_matrix_sel(unsigned int offset,
+               unsigned int sel, struct vdin_dev_s *devp);
 
 #endif
 
index 533019cb0186a33299d74883ec4821becfb79620..6e6923753456e0ca72252b7f676b91d3c1e61896 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
 
-static void vdin_get_vdin_yuv_rgb_mat0(unsigned int offset,
-               unsigned int *rgb_yuv0,
-               unsigned int *rgb_yuv1,
-               unsigned int *rgb_yuv2)
-{
-       *rgb_yuv0 = 0;  *rgb_yuv1 = 0;  *rgb_yuv2 = 0;
-
-       *rgb_yuv0 = ((rd_bits(offset, VDIN_MATRIX_PROBE_COLOR,
-               COMPONENT2_PROBE_COLOR_BIT, COMPONENT2_PROBE_COLOR_WID)
-                       << 8) >> 10);
-       *rgb_yuv1 = ((rd_bits(offset, VDIN_MATRIX_PROBE_COLOR,
-               COMPONENT1_PROBE_COLOR_BIT, COMPONENT1_PROBE_COLOR_WID)
-                       << 8) >> 10);
-       *rgb_yuv2 = ((rd_bits(offset, VDIN_MATRIX_PROBE_COLOR,
-               COMPONENT0_PROBE_COLOR_BIT, COMPONENT0_PROBE_COLOR_WID)
-                       << 8) >> 10);
-}
-
-static void vdin_set_prob_matrix0_xy(unsigned int offset,
-               unsigned int x, unsigned int y, struct vdin_dev_s *devp)
-{
-
-       if (devp->fmt_info_p->scan_mode == TVIN_SCAN_MODE_INTERLACED)
-               y = y/2;
-
-       wr_bits(offset, VDIN_MATRIX_PROBE_POS, y,
-               PROBE_POX_Y_BIT, PROBE_POX_Y_WID);
-       wr_bits(offset, VDIN_MATRIX_PROBE_POS, x,
-               PROBE_POS_X_BIT, PROBE_POS_X_WID);
-}
-
-static void vdin_set_before_after_mat0(unsigned int offset,
-               unsigned int x, struct vdin_dev_s *devp)
-{
-       if ((x != 0) && (x != 1))
-               return;
-
-       wr_bits(offset, VDIN_MATRIX_CTRL, x,
-                       VDIN_PROBE_POST_BIT, VDIN_PROBE_POST_WID);
-}
 
 static void vdin_parse_param(char *buf_orig, char **parm)
 {
@@ -1823,7 +1783,7 @@ start_chk:
                reg = VDIN_MISC_CTRL;
                pr_info("0x%04x = 0x%08x\n", (reg), R_VCBUS(reg));
                pr_info("\n");
-       } else if (!strcmp(parm[0], "rgb_xy")) {
+       } else if (!strcmp(parm[0], "prob_xy")) {
                unsigned int x = 0, y = 0;
 #ifdef CONFIG_AMLOGIC_PIXEL_PROBE
                vdin_probe_enable();
@@ -1833,13 +1793,36 @@ start_chk:
                                x = val;
                        if (kstrtoul(parm[2], 10, &val) == 0)
                                y = val;
-                       vdin_set_prob_xy(devp->addr_offset, x, y, devp);
+                       vdin_prob_set_xy(devp->addr_offset, x, y, devp);
                } else
                        pr_err("miss parameters .\n");
-       } else if (!strcmp(parm[0], "rgb_info")) {
+       } else if (!strcmp(parm[0], "prob_rgb")) {
                unsigned int r, g, b;
-               vdin_get_prob_rgb(devp->addr_offset, &r, &g, &b);
+               vdin_prob_get_rgb(devp->addr_offset, &r, &g, &b);
                pr_info("rgb_info-->r:%x,g:%x,b:%x\n", r, g, b);
+       } else if (!strcmp(parm[0], "prob_yuv")) {
+               unsigned int r, g, b;
+
+               vdin_prob_get_yuv(devp->addr_offset, &r, &g, &b);
+               pr_info("yuv_info-->u:%x,v:%x,y:%x\n", r, g, b);
+       } else if (!strcmp(parm[0], "prob_pre_post")) {
+               unsigned int x = 0;
+
+               if (!parm[1])
+                       pr_err("miss parameters .\n");
+               if (kstrtoul(parm[1], 10, &val) == 0)
+                       x = val;
+               pr_info("matrix post sel: %d\n", x);
+               vdin_prob_set_before_or_after_mat(devp->addr_offset, x, devp);
+       } else if (!strcmp(parm[0], "prob_mat_sel")) {
+               unsigned int x = 0;
+
+               if (!parm[1])
+                       pr_err("miss parameters .\n");
+               if (kstrtoul(parm[1], 10, &val) == 0)
+                       x = val;
+               pr_info("matrix sel : %d\n", x);
+               vdin_prob_matrix_sel(devp->addr_offset, x, devp);
        } else if (!strcmp(parm[0], "mpeg2vdin")) {
                if (parm[1] && parm[2]) {
                        if (kstrtoul(parm[1], 10, &val) == 0)
@@ -1851,35 +1834,6 @@ start_chk:
                                devp->h_active, devp->v_active);
                } else
                        pr_err("miss parameters .\n");
-       } else if (!strcmp(parm[0], "yuv_rgb_info")) {
-               unsigned int rgb_yuv0, rgb_yuv1, rgb_yuv2;
-               vdin_get_vdin_yuv_rgb_mat0(devp->addr_offset,
-                               &rgb_yuv0, &rgb_yuv1, &rgb_yuv2);
-               pr_info("rgb_yuv0 :%d, rgb_yuv1 :%d , rgb_yuv2 :%d\n",
-                               rgb_yuv0, rgb_yuv1, rgb_yuv2);
-       } else if (!strcmp(parm[0], "mat0_xy")) {
-               unsigned int x = 0, y = 0;
-#ifdef CONFIG_AMLOGIC_PIXEL_PROBE
-               vdin_probe_enable();
-#endif
-               if (parm[1] && parm[2]) {
-                       if (kstrtoul(parm[1], 10, &val) == 0)
-                               x = val;
-                       if (kstrtoul(parm[2], 10, &val) == 0)
-                               y = val;
-                       pr_info("pos x  :%d, pos y  :%d\n", x, y);
-                       vdin_set_prob_matrix0_xy(devp->addr_offset, x, y, devp);
-               } else
-                       pr_err("miss parameters .\n");
-       } else if (!strcmp(parm[0], "mat0_set")) {
-               unsigned int x = 0;
-
-               if (!parm[1])
-                       pr_err("miss parameters .\n");
-               if (kstrtoul(parm[1], 10, &val) == 0)
-                       x = val;
-               pr_info("matrix set : %d\n", x);
-               vdin_set_before_after_mat0(devp->addr_offset, x, devp);
        } else if (!strcmp(parm[0], "hdr")) {
                int i;
                struct vframe_master_display_colour_s *prop;
index 4b2cf726d989c70ea6c7ed73fecafc6b8748e7fc..a2cc960a2edbd94784100b8403d2d98ac253e3c9 100644 (file)
@@ -48,7 +48,7 @@
 /* Ref.2019/04/25: tl1 vdin0 afbce dynamically switch support,
  *                 vpp also should support this function
  */
-#define VDIN_VER "Ref.2019/08/2:hdmi yuv422 vdin set 10 bit mode"
+#define VDIN_VER "Ref.2019/08/22:add vdin pixel probe feature"
 
 /*the counter of vdin*/
 #define VDIN_MAX_DEVS                  2