vout: add bist test on vout [1/1]

PD#SWPL-1630

Problem:
add cvbs/hdmi/lcd bist test on vout

Solution:
add cvbs bist test on vout

Verify:
test pass on u200/p212

Change-Id: Ie61d9b0d63649ec3022fd720068b689f4d721e3b
Signed-off-by: Nian Jing <nian.jing@amlogic.com>
This commit is contained in:
Nian Jing
2018-11-01 20:55:47 +08:00
committed by Jianxin Pan
parent 0484916ae7
commit d9f755a9a3
12 changed files with 225 additions and 67 deletions

View File

@@ -148,8 +148,6 @@ static int cvbs_vdac_power_level;
static void vdac_power_level_store(char *para);
SET_CVBS_CLASS_ATTR(vdac_power_level, vdac_power_level_store);
static void bist_test_store(char *para);
static void cvbs_debug_store(char *para);
SET_CVBS_CLASS_ATTR(debug, cvbs_debug_store);
@@ -650,6 +648,102 @@ static int cvbs_vout_get_state(void)
return cvbs_vout_state;
}
static char *cvbs_out_bist_str[] = {
"OFF", /* 0 */
"Color Bar", /* 1 */
"Thin Line", /* 2 */
"Dot Grid", /* 3 */
"White",
"Red",
"Green",
"Blue",
"Black",
};
static void cvbs_bist_test(unsigned int bist)
{
switch (bist) {
case 1:
case 2:
case 3:
cvbs_out_reg_write(ENCI_TST_CLRBAR_STRT, 0x112);
cvbs_out_reg_write(ENCI_TST_CLRBAR_WIDTH, 0xb4);
cvbs_out_reg_write(ENCI_TST_MDSEL, bist);
cvbs_out_reg_write(ENCI_TST_Y, 0x200);
cvbs_out_reg_write(ENCI_TST_CB, 0x200);
cvbs_out_reg_write(ENCI_TST_CR, 0x200);
cvbs_out_reg_write(ENCI_TST_EN, 1);
pr_info("show bist pattern %d: %s\n",
bist, cvbs_out_bist_str[bist]);
break;
case 4:
cvbs_out_reg_write(ENCI_TST_CLRBAR_STRT, 0x112);
cvbs_out_reg_write(ENCI_TST_CLRBAR_WIDTH, 0xb4);
cvbs_out_reg_write(ENCI_TST_MDSEL, 0);
cvbs_out_reg_write(ENCI_TST_Y, 0x3ff);
cvbs_out_reg_write(ENCI_TST_CB, 0x200);
cvbs_out_reg_write(ENCI_TST_CR, 0x200);
cvbs_out_reg_write(ENCI_TST_EN, 1);
pr_info("show bist pattern %d: %s\n",
bist, cvbs_out_bist_str[bist]);
break;
case 5:
cvbs_out_reg_write(ENCI_TST_CLRBAR_STRT, 0x112);
cvbs_out_reg_write(ENCI_TST_CLRBAR_WIDTH, 0xb4);
cvbs_out_reg_write(ENCI_TST_MDSEL, 0);
cvbs_out_reg_write(ENCI_TST_Y, 0x200);
cvbs_out_reg_write(ENCI_TST_CB, 0x0);
cvbs_out_reg_write(ENCI_TST_CR, 0x3ff);
cvbs_out_reg_write(ENCI_TST_EN, 1);
pr_info("show bist pattern %d: %s\n",
bist, cvbs_out_bist_str[bist]);
break;
case 6:
cvbs_out_reg_write(ENCI_TST_CLRBAR_STRT, 0x112);
cvbs_out_reg_write(ENCI_TST_CLRBAR_WIDTH, 0xb4);
cvbs_out_reg_write(ENCI_TST_MDSEL, 0);
cvbs_out_reg_write(ENCI_TST_Y, 0x200);
cvbs_out_reg_write(ENCI_TST_CB, 0x0);
cvbs_out_reg_write(ENCI_TST_CR, 0x0);
cvbs_out_reg_write(ENCI_TST_EN, 1);
pr_info("show bist pattern %d: %s\n",
bist, cvbs_out_bist_str[bist]);
break;
case 7:
cvbs_out_reg_write(ENCI_TST_CLRBAR_STRT, 0x112);
cvbs_out_reg_write(ENCI_TST_CLRBAR_WIDTH, 0xb4);
cvbs_out_reg_write(ENCI_TST_MDSEL, 0);
cvbs_out_reg_write(ENCI_TST_Y, 0x200);
cvbs_out_reg_write(ENCI_TST_CB, 0x3ff);
cvbs_out_reg_write(ENCI_TST_CR, 0x0);
cvbs_out_reg_write(ENCI_TST_EN, 1);
pr_info("show bist pattern %d: %s\n",
bist, cvbs_out_bist_str[bist]);
break;
case 8:
cvbs_out_reg_write(ENCI_TST_CLRBAR_STRT, 0x112);
cvbs_out_reg_write(ENCI_TST_CLRBAR_WIDTH, 0xb4);
cvbs_out_reg_write(ENCI_TST_MDSEL, 0);
cvbs_out_reg_write(ENCI_TST_Y, 0x0);
cvbs_out_reg_write(ENCI_TST_CB, 0x200);
cvbs_out_reg_write(ENCI_TST_CR, 0x200);
cvbs_out_reg_write(ENCI_TST_EN, 1);
pr_info("show bist pattern %d: %s\n",
bist, cvbs_out_bist_str[bist]);
break;
case 0:
default:
cvbs_out_reg_write(ENCI_TST_MDSEL, 1);
cvbs_out_reg_write(ENCI_TST_Y, 0x200);
cvbs_out_reg_write(ENCI_TST_CB, 0x200);
cvbs_out_reg_write(ENCI_TST_CR, 0x200);
cvbs_out_reg_write(ENCI_TST_EN, 0);
pr_info("show bist pattern %d: %s\n",
bist, cvbs_out_bist_str[0]);
break;
}
}
#ifdef CONFIG_PM
static int cvbs_suspend(void)
{
@@ -684,6 +778,7 @@ static struct vout_server_s cvbs_vout_server = {
.set_vframe_rate_end_hint = NULL,
.set_vframe_rate_policy = NULL,
.get_vframe_rate_policy = NULL,
.set_bist = cvbs_bist_test,
#ifdef CONFIG_PM
.vout_suspend = cvbs_suspend,
.vout_resume = cvbs_resume,
@@ -707,6 +802,7 @@ static struct vout_server_s cvbs_vout2_server = {
.set_vframe_rate_end_hint = NULL,
.set_vframe_rate_policy = NULL,
.get_vframe_rate_policy = NULL,
.set_bist = cvbs_bist_test,
#ifdef CONFIG_PM
.vout_suspend = cvbs_suspend,
.vout_resume = cvbs_resume,
@@ -732,67 +828,6 @@ static void cvbs_init_vout(void)
#endif
}
/* **************************************************** */
static char *cvbs_out_bist_str[] = {
"Fix Value", /* 0 */
"Color Bar", /* 1 */
"Thin Line", /* 2 */
"Dot Grid", /* 3 */
};
static void bist_test_store(char *para)
{
unsigned long num;
enum vmode_e mode;
unsigned int start, width;
int ret;
mode = info->vinfo->mode;
if (mode != VMODE_CVBS) {
pr_info("NOT VMODE_CVBS,RETURN\n");
return;
}
ret = kstrtoul(para, 10, (unsigned long *)&num);
if (num > 3) {
switch (local_cvbs_mode) {
case MODE_480CVBS:
case MODE_576CVBS:
case MODE_PAL_M:
case MODE_PAL_N:
cvbs_out_reg_write(ENCI_TST_EN, 0);
break;
default:
cvbs_out_reg_setb(ENCP_VIDEO_MODE_ADV, 1, 3, 1);
cvbs_out_reg_write(VENC_VIDEO_TST_EN, 0);
break;
}
pr_info("disable bist pattern\n");
} else {
switch (local_cvbs_mode) {
case MODE_480CVBS:
case MODE_576CVBS:
case MODE_PAL_M:
case MODE_PAL_N:
cvbs_out_reg_write(ENCI_TST_CLRBAR_STRT, 0x112);
cvbs_out_reg_write(ENCI_TST_CLRBAR_WIDTH, 0xb4);
cvbs_out_reg_write(ENCI_TST_MDSEL, (unsigned int)num);
cvbs_out_reg_write(ENCI_TST_EN, 1);
break;
default:
start = cvbs_out_reg_read(ENCP_VIDEO_HAVON_BEGIN);
width = info->vinfo->width / 9;
cvbs_out_reg_write(VENC_VIDEO_TST_CLRBAR_STRT, start);
cvbs_out_reg_write(VENC_VIDEO_TST_CLRBAR_WIDTH, width);
cvbs_out_reg_write(VENC_VIDEO_TST_MDSEL, 1);
cvbs_out_reg_setb(ENCP_VIDEO_MODE_ADV, 0, 3, 1);
cvbs_out_reg_write(VENC_VIDEO_TST_EN, 1);
break;
}
pr_info("show bist pattern %ld: %s\n",
num, cvbs_out_bist_str[num]);
}
}
static void vdac_power_level_store(char *para)
{
unsigned long level = 0;
@@ -956,7 +991,7 @@ static void cvbs_debug_store(char *buf)
{
unsigned int ret = 0;
unsigned long addr, start, end, value, length, old;
unsigned int argc;
unsigned int argc, bist;
char *p = NULL, *para = NULL,
*argv[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
char *str_type = NULL;
@@ -1129,11 +1164,16 @@ static void cvbs_debug_store(char *buf)
case CMD_BIST:
if (argc != 2) {
print_info("[%s] cmd_bist format:\n"
"\tbist 0/1/2/3/off\n", __func__);
"\tbist 1/2/3/4/5/6/7/8/0\n", __func__);
goto DEBUG_END;
}
ret = kstrtouint(argv[1], 10, &bist);
if (ret) {
print_info("cvbs: invalid bist\n");
goto DEBUG_END;
}
cvbs_bist_test(bist);
bist_test_store(argv[1]);
break;
case CMD_VP_SET:

View File

@@ -25,7 +25,7 @@
#include <linux/amlogic/media/vout/vout_notify.h>
#include "cvbs_mode.h"
#define CVBSOUT_VER "Ref.2018/07/02"
#define CVBSOUT_VER "Ref.2018/11/07"
#define CVBS_CLASS_NAME "cvbs"
#define CVBS_NAME "cvbs"

View File

@@ -3512,6 +3512,7 @@ static struct vout_server_s hdmitx_vout_server = {
.set_state = hdmitx_vout_set_state,
.clr_state = hdmitx_vout_clr_state,
.get_state = hdmitx_vout_get_state,
.set_bist = NULL,
#ifdef CONFIG_PM
.vout_suspend = NULL,
.vout_resume = NULL,
@@ -3531,6 +3532,7 @@ static struct vout_server_s hdmitx_vout2_server = {
.set_state = hdmitx_vout_set_state,
.clr_state = hdmitx_vout_clr_state,
.get_state = hdmitx_vout_get_state,
.set_bist = NULL,
#ifdef CONFIG_PM
.vout_suspend = NULL,
.vout_resume = NULL,

View File

@@ -382,6 +382,7 @@ static struct vout_server_s lcd_vout_server = {
.set_vframe_rate_end_hint = lcd_set_vframe_rate_end_hint,
.set_vframe_rate_policy = lcd_set_vframe_rate_policy,
.get_vframe_rate_policy = lcd_get_vframe_rate_policy,
.set_bist = lcd_debug_test,
#ifdef CONFIG_PM
.vout_suspend = lcd_suspend,
.vout_resume = lcd_resume,
@@ -405,6 +406,7 @@ static struct vout_server_s lcd_vout2_server = {
.set_vframe_rate_end_hint = lcd_set_vframe_rate_end_hint,
.set_vframe_rate_policy = lcd_set_vframe_rate_policy,
.get_vframe_rate_policy = lcd_get_vframe_rate_policy,
.set_bist = lcd_debug_test,
#ifdef CONFIG_PM
.vout_suspend = lcd_suspend,
.vout_resume = lcd_resume,

View File

@@ -657,6 +657,7 @@ static struct vout_server_s lcd_vout_server = {
.set_vframe_rate_end_hint = lcd_set_vframe_rate_end_hint,
.set_vframe_rate_policy = lcd_set_vframe_rate_policy,
.get_vframe_rate_policy = lcd_get_vframe_rate_policy,
.set_bist = lcd_debug_test,
#ifdef CONFIG_PM
.vout_suspend = lcd_suspend,
.vout_resume = lcd_resume,

View File

@@ -174,6 +174,15 @@ int get_vframe2_rate_policy(void)
}
EXPORT_SYMBOL(get_vframe2_rate_policy);
/*
* interface export to client who want to set test bist.
*/
void set_vout2_bist(unsigned int bist)
{
vout_func_set_test_bist(2, bist);
}
EXPORT_SYMBOL(set_vout2_bist);
int vout2_suspend(void)
{
return vout_func_vout_suspend(2);

View File

@@ -59,6 +59,7 @@ static struct class *vout2_class;
static DEFINE_MUTEX(vout2_serve_mutex);
static char vout2_mode[VMODE_NAME_LEN_MAX];
static char local_name[VMODE_NAME_LEN_MAX] = {0};
static unsigned int bist_mode2;
static char vout2_axis[64];
@@ -156,6 +157,7 @@ static struct vout_server_s nulldisp_vout2_server = {
.set_state = nulldisp_vout_set_state,
.clr_state = nulldisp_vout_clr_state,
.get_state = nulldisp_vout_get_state,
.set_bist = NULL,
},
};
@@ -355,6 +357,36 @@ static ssize_t vout2_fr_policy_store(struct class *class,
return count;
}
static ssize_t vout2_bist_show(struct class *class,
struct class_attribute *attr, char *buf)
{
int ret = 0;
ret = sprintf(buf, "%d\n", bist_mode2);
return ret;
}
static ssize_t vout2_bist_store(struct class *class,
struct class_attribute *attr, const char *buf, size_t count)
{
int ret = 0;
mutex_lock(&vout2_serve_mutex);
ret = kstrtouint(buf, 10, &bist_mode2);
if (ret) {
pr_info("%s: invalid data\n", __func__);
mutex_unlock(&vout2_serve_mutex);
return -EINVAL;
}
set_vout2_bist(bist_mode2);
mutex_unlock(&vout2_serve_mutex);
return count;
}
static ssize_t vout2_vinfo_show(struct class *class,
struct class_attribute *attr, char *buf)
{
@@ -448,6 +480,7 @@ static struct class_attribute vout2_class_attrs[] = {
__ATTR(axis, 0644, vout2_axis_show, vout2_axis_store),
__ATTR(fr_policy, 0644,
vout2_fr_policy_show, vout2_fr_policy_store),
__ATTR(bist, 0644, vout2_bist_show, vout2_bist_store),
__ATTR(vinfo, 0444, vout2_vinfo_show, NULL),
};

View File

@@ -440,6 +440,31 @@ int vout_func_get_vframe_rate_policy(int index)
}
EXPORT_SYMBOL(vout_func_get_vframe_rate_policy);
/*
* interface export to client who want to set test bist.
*/
void vout_func_set_test_bist(int index, unsigned int bist)
{
struct vout_server_s *p_server = NULL;
mutex_lock(&vout_mutex);
if (index == 1)
p_server = vout_module.curr_vout_server;
#ifdef CONFIG_AMLOGIC_VOUT2_SERVE
else if (index == 2)
p_server = vout2_module.curr_vout_server;
#endif
if (!IS_ERR_OR_NULL(p_server)) {
if (p_server->op.set_bist)
p_server->op.set_bist(bist);
}
mutex_unlock(&vout_mutex);
}
EXPORT_SYMBOL(vout_func_set_test_bist);
int vout_func_vout_suspend(int index)
{
int ret = 0;

View File

@@ -64,6 +64,7 @@ extern int vout_func_set_vframe_rate_hint(int index, int duration);
extern int vout_func_set_vframe_rate_end_hint(int index);
extern int vout_func_set_vframe_rate_policy(int index, int policy);
extern int vout_func_get_vframe_rate_policy(int index);
extern void vout_func_set_test_bist(int index, unsigned int bist);
extern int vout_func_vout_suspend(int index);
extern int vout_func_vout_resume(int index);
extern int vout_func_vout_shutdown(int index);

View File

@@ -192,6 +192,15 @@ int get_vframe_rate_policy(void)
}
EXPORT_SYMBOL(get_vframe_rate_policy);
/*
* interface export to client who want to set test bist.
*/
void set_vout_bist(unsigned int bist)
{
vout_func_set_test_bist(1, bist);
}
EXPORT_SYMBOL(set_vout_bist);
#ifdef CONFIG_SCREEN_ON_EARLY
static int wake_up_flag;
void wakeup_early_suspend_proc(void)

View File

@@ -63,6 +63,7 @@ static char vout_mode[VMODE_NAME_LEN_MAX] __nosavedata;
static char local_name[VMODE_NAME_LEN_MAX] = {0};
static u32 vout_init_vmode = VMODE_INIT_NULL;
static int uboot_display;
static unsigned int bist_mode;
static char vout_axis[64] __nosavedata;
@@ -204,6 +205,7 @@ static struct vout_server_s nulldisp_vout_server = {
.set_state = nulldisp_vout_set_state,
.clr_state = nulldisp_vout_clr_state,
.get_state = nulldisp_vout_get_state,
.set_bist = NULL,
},
};
@@ -429,6 +431,36 @@ static ssize_t vout_fr_policy_store(struct class *class,
return count;
}
static ssize_t vout_bist_show(struct class *class,
struct class_attribute *attr, char *buf)
{
int ret = 0;
ret = sprintf(buf, "%d\n", bist_mode);
return ret;
}
static ssize_t vout_bist_store(struct class *class,
struct class_attribute *attr, const char *buf, size_t count)
{
int ret = 0;
mutex_lock(&vout_serve_mutex);
ret = kstrtouint(buf, 10, &bist_mode);
if (ret) {
pr_info("%s: invalid data\n", __func__);
mutex_unlock(&vout_serve_mutex);
return -EINVAL;
}
set_vout_bist(bist_mode);
mutex_unlock(&vout_serve_mutex);
return count;
}
static ssize_t vout_vinfo_show(struct class *class,
struct class_attribute *attr, char *buf)
{
@@ -523,6 +555,7 @@ static struct class_attribute vout_class_attrs[] = {
__ATTR(axis, 0644, vout_axis_show, vout_axis_store),
__ATTR(fr_policy, 0644,
vout_fr_policy_show, vout_fr_policy_store),
__ATTR(bist, 0644, vout_bist_show, vout_bist_store),
__ATTR(vinfo, 0444, vout_vinfo_show, NULL),
};

View File

@@ -46,6 +46,7 @@ struct vout_op_s {
int (*set_vframe_rate_end_hint)(void);
int (*set_vframe_rate_policy)(int);
int (*get_vframe_rate_policy)(void);
void (*set_bist)(unsigned int);
int (*vout_suspend)(void);
int (*vout_resume)(void);
int (*vout_shutdown)(void);
@@ -74,6 +75,7 @@ extern int set_vframe_rate_hint(int duration);
extern int set_vframe_rate_end_hint(void);
extern int set_vframe_rate_policy(int pol);
extern int get_vframe_rate_policy(void);
extern void set_vout_bist(unsigned int bist);
#ifdef CONFIG_AMLOGIC_VOUT2_SERVE
extern int vout2_register_client(struct notifier_block *p);
@@ -88,6 +90,7 @@ extern int set_vframe2_rate_hint(int duration);
extern int set_vframe2_rate_end_hint(void);
extern int set_vframe2_rate_policy(int pol);
extern int get_vframe2_rate_policy(void);
extern void set_vout2_bist(unsigned int bist);
#endif