From 90157135f164892385a1e5debedc626e2080fbbf Mon Sep 17 00:00:00 2001 From: Xihai Zhu Date: Thu, 11 Jul 2019 06:05:38 -0400 Subject: [PATCH] amvecm: update pixel probe [1/2] PD#SWPL-11790 Problem: related register usage is wrong Solution: have probe register usage aligned with correct spec Verify: TL1 Change-Id: I8345f58d96ac0f3447c47065a61c747907341c1d Signed-off-by: Xihai Zhu --- drivers/amlogic/media/enhancement/amvecm/amvecm.c | 96 +++++++++++++++++++---- drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c | 2 +- drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c | 13 ++- 3 files changed, 90 insertions(+), 21 deletions(-) diff --git a/drivers/amlogic/media/enhancement/amvecm/amvecm.c b/drivers/amlogic/media/enhancement/amvecm/amvecm.c index 3918863..d407704 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amvecm.c +++ b/drivers/amlogic/media/enhancement/amvecm/amvecm.c @@ -39,6 +39,9 @@ #include #include #include +#ifdef CONFIG_AMLOGIC_PIXEL_PROBE +#include +#endif #include #include #include @@ -65,6 +68,7 @@ #include "local_contrast.h" #include "arch/vpp_hdr_regs.h" + #define pr_amvecm_dbg(fmt, args...)\ do {\ if (debug_amvecm)\ @@ -3449,41 +3453,90 @@ static ssize_t set_hdr_289lut_store(struct class *cls, static ssize_t amvecm_set_post_matrix_show(struct class *cla, struct class_attribute *attr, char *buf) { - return sprintf(buf, "0x%x\n", (int)(READ_VPP_REG(VPP_MATRIX_CTRL))); + int val; + + pr_info("Usage:\n"); + pr_info("echo port > /sys/class/amvecm/matrix_set\n"); + pr_info("1 : vadj1 input\n"); + pr_info("2 : vadj2 input\n"); + pr_info("4 : osd2 input\n"); + pr_info("8 : postblend input\n"); + pr_info("16 : osd1 input\n"); + pr_info("33 : vadj1 output\n"); + pr_info("34 : vadj2 output\n"); + pr_info("36 : osd2 output\n"); + pr_info("40 : postblend output\n"); + pr_info("48: osd1 output\n"); + + val = READ_VPP_REG(VPP_MATRIX_CTRL); + pr_info("current setting: %d\n", (val >> 10) & 0x3f); + + return 0; } static ssize_t amvecm_set_post_matrix_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; - int val; + int val, reg_val; - r = sscanf(buf, "0x%x", &val); - if ((r != 1) || (val & 0xffff0000)) + if (kstrtoint(buf, 10, &val) < 0) return -EINVAL; - WRITE_VPP_REG(VPP_MATRIX_CTRL, val); + reg_val = READ_VPP_REG(VPP_MATRIX_CTRL); + reg_val = reg_val & 0xffff03ff; + reg_val = reg_val | ((val & 0x3f) << 10); + + WRITE_VPP_REG(VPP_MATRIX_CTRL, reg_val); + + pr_info("VPP_MATRIX_CTRL is set\n"); return count; } static ssize_t amvecm_post_matrix_pos_show(struct class *cla, struct class_attribute *attr, char *buf) { - return sprintf(buf, "0x%x\n", - (int)(READ_VPP_REG(VPP_MATRIX_PROBE_POS))); + int val; + + pr_info("Usage:\n"); + pr_info("echo x y > /sys/class/amvecm/matrix_pos\n"); + + val = READ_VPP_REG(VPP_MATRIX_PROBE_POS); + pr_info("current position: %d %d\n", + (val >> 16) & 0x1fff, + (val >> 0) & 0x1fff); + return 0; } static ssize_t amvecm_post_matrix_pos_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - size_t r; - int val; + int val_x, val_y, reg_val; + char *buf_orig, *parm[2] = {NULL}; - r = sscanf(buf, "0x%x", &val); - if ((r != 1) || (val & 0xe000e000)) + if (!buf) + return count; + buf_orig = kstrdup(buf, GFP_KERNEL); + parse_param_amvecm(buf_orig, (char **)&parm); + + if (kstrtoint(parm[0], 10, &val_x) < 0) { + kfree(buf_orig); return -EINVAL; + } + if (kstrtoint(parm[1], 10, &val_y) < 0) { + kfree(buf_orig); + return -EINVAL; + } + + val_x = val_x & 0x1fff; + val_y = val_y & 0x1fff; - WRITE_VPP_REG(VPP_MATRIX_PROBE_POS, val); + reg_val = READ_VPP_REG(VPP_MATRIX_PROBE_POS); + reg_val = reg_val & 0xe000e000; + reg_val = reg_val | (val_x << 16) | val_y; + + WRITE_VPP_REG(VPP_MATRIX_PROBE_POS, reg_val); + + kfree(buf_orig); return count; } @@ -3493,13 +3546,19 @@ static ssize_t amvecm_post_matrix_data_show(struct class *cla, int len = 0, val1 = 0, val2 = 0; val1 = READ_VPP_REG(VPP_MATRIX_PROBE_COLOR); -/* #if (MESON_CPU_TYPE >= MESON_CPU_TYPE_MESONG9TV) */ - val2 = READ_VPP_REG(VPP_MATRIX_PROBE_COLOR1); -/* #endif */ - len += sprintf(buf+len, + if (cpu_after_eq(MESON_CPU_MAJOR_ID_G12A)) { + len += sprintf(buf+len, + "VPP_MATRIX_PROBE_COLOR %d, %d, %d\n", + (val1 >> 20) & 0x3ff, + (val1 >> 10) & 0x3ff, + (val1 >> 0) & 0x3ff); + } else { + val2 = READ_VPP_REG(VPP_MATRIX_PROBE_COLOR1); + len += sprintf(buf+len, "VPP_MATRIX_PROBE_COLOR %x, %x, %x\n", ((val2 & 0xf) << 8) | ((val1 >> 24) & 0xff), (val1 >> 12) & 0xfff, val1 & 0xfff); + } return len; } @@ -6788,6 +6847,9 @@ static void aml_vecm_dt_parse(struct platform_device *pdev) vlock_status_init(); } /* init module status */ +#ifdef CONFIG_AMLOGIC_PIXEL_PROBE + vpp_probe_enable(); +#endif amvecm_wb_init(wb_en); amvecm_gamma_init(0); #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c index 58aac94..cae279d 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c @@ -635,7 +635,7 @@ void vdin_get_prob_rgb(unsigned int offset, unsigned int *r, unsigned int *g, unsigned int *b) { *b = rgb_info_b = rd_bits(offset, VDIN_MATRIX_PROBE_COLOR, - COMPONENT0_PROBE_COLOR_BIT, COMPONENT0_PROBE_COLOR_WID); + COMPONENT2_PROBE_COLOR_BIT, COMPONENT0_PROBE_COLOR_WID); *g = rgb_info_g = rd_bits(offset, VDIN_MATRIX_PROBE_COLOR, COMPONENT1_PROBE_COLOR_BIT, COMPONENT1_PROBE_COLOR_WID); *r = rgb_info_r = rd_bits(offset, VDIN_MATRIX_PROBE_COLOR, diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c index dae5087..533019c 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c @@ -27,6 +27,9 @@ #include #include #include +#ifdef CONFIG_AMLOGIC_PIXEL_PROBE +#include +#endif /* Local Headers */ #include "../tvin_format_table.h" #include "vdin_drv.h" @@ -1822,7 +1825,9 @@ start_chk: pr_info("\n"); } else if (!strcmp(parm[0], "rgb_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; @@ -1834,7 +1839,7 @@ start_chk: } else if (!strcmp(parm[0], "rgb_info")) { unsigned int r, g, b; vdin_get_prob_rgb(devp->addr_offset, &r, &g, &b); - pr_info("rgb_info-->r:%d,g:%d,b:%d\n", r, g, b); + pr_info("rgb_info-->r:%x,g:%x,b:%x\n", r, g, b); } else if (!strcmp(parm[0], "mpeg2vdin")) { if (parm[1] && parm[2]) { if (kstrtoul(parm[1], 10, &val) == 0) @@ -1854,7 +1859,9 @@ start_chk: 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; -- 2.7.4