hdr: add osd lut table for nts test

PD#164627: hdr: add osd lut table for nts test

1. debug fs : /sys/kernel/debug/hdr/cfg_en_osd_100
	1: enable new osd lut table (for nts test)
	0: use old osd lut table
2. dts: amlvecm:cfg_en_osd_100
	1: enable new osd lut table (for nts test)
	0/not define: use old osd lut table

Change-Id: If3c51eaba58f7d83188b8920ad7dca78d3b38c19
Signed-off-by: Jihong Sui <jihong.sui@amlogic.com>
This commit is contained in:
Jihong Sui
2018-05-22 17:28:36 +08:00
committed by Yixun Lan
parent 715a75cd69
commit 95a15520ca
22 changed files with 286 additions and 27 deletions

View File

@@ -1075,6 +1075,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1129,6 +1129,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1075,6 +1075,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1085,6 +1085,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1130,6 +1130,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1117,6 +1117,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1172,6 +1172,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1001,6 +1001,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1001,6 +1001,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1070,6 +1070,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1140,6 +1140,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1209,6 +1209,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1140,6 +1140,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1208,6 +1208,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
unifykey{

View File

@@ -1098,6 +1098,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
amdolby_vision {
compatible = "amlogic, dolby_vision_gxm";

View File

@@ -1084,6 +1084,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
partitions: partitions{

View File

@@ -1081,6 +1081,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
amdolby_vision {
compatible = "amlogic, dolby_vision_gxm";

View File

@@ -1091,6 +1091,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
amdolby_vision {
compatible = "amlogic, dolby_vision_gxm";

View File

@@ -938,6 +938,8 @@
gamma_en = <0>;/*1:enabel ;0:disable*/
wb_en = <0>;/*1:enabel ;0:disable*/
cm_en = <0>;/*1:enabel ;0:disable*/
/*1:enabel osd lut 100 table;0:disable*/
cfg_en_osd_100 = <1>;
};
amdolby_vision {
compatible = "amlogic, dolby_vision_gxm";

View File

@@ -21,6 +21,9 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/debugfs.h>
#include <linux/uaccess.h>
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/video_common.h>
#include <linux/amlogic/media/amvecm/amvecm.h>
@@ -47,6 +50,136 @@ signed int vd1_contrast_offset;
signed int saturation_offset;
/*hdr------------------------------------*/
static struct hdr_data_t *phdr;
struct hdr_data_t *hdr_get_data(void)
{
return phdr;
}
int is_hdr_cfg_osd_100(void)
{
int ret = 0;
if (phdr) {
if (phdr->hdr_cfg.en_osd_lut_100)
ret = 1;
}
return ret;
}
void hdr_set_cfg_osd_100(int val)
{
if (val == 1)
phdr->hdr_cfg.en_osd_lut_100 = 1;
else
phdr->hdr_cfg.en_osd_lut_100 = 0;
}
static ssize_t read_file_hdr_cfgosd(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos)
{
char buf[20];
ssize_t len;
len = snprintf(buf, 20, "%d\n", phdr->hdr_cfg.en_osd_lut_100);
return simple_read_from_buffer(userbuf, count, ppos, buf, len);
}
static ssize_t write_file_hdr_cfgosd(
struct file *file, const char __user *userbuf,
size_t count, loff_t *ppos)
{
int val;
char buf[20];
int ret = 0;
count = min_t(size_t, count, (sizeof(buf)-1));
if (copy_from_user(buf, userbuf, count))
return -EFAULT;
buf[count] = 0;
ret = kstrtoint(buf, 0, &val);
if (ret != 0) {
pr_info("cfg_en_osd_100 do nothing!\n");
return -EINVAL;
}
hdr_set_cfg_osd_100(val);
pr_info("hdr:en_osd_lut_100: %d\n", phdr->hdr_cfg.en_osd_lut_100);
return count;
}
static const struct file_operations file_ops_hdr_cfgosd = {
.open = simple_open,
.read = read_file_hdr_cfgosd,
.write = write_file_hdr_cfgosd,
};
struct hdr_debugfs_files_t {
const char *name;
const umode_t mode;
const struct file_operations *fops;
};
static struct hdr_debugfs_files_t hdr_debugfs_files[] = {
{"cfg_en_osd_100", S_IFREG | 0644, &file_ops_hdr_cfgosd},
};
static void hdr_debugfs_init(void)
{
int i;
struct dentry *ent;
if (phdr == NULL)
return;
if (phdr->dbg_root)
return;
phdr->dbg_root = debugfs_create_dir("hdr", NULL);
if (!phdr->dbg_root) {
pr_err("can't create debugfs dir hdr\n");
return;
}
for (i = 0; i < ARRAY_SIZE(hdr_debugfs_files); i++) {
ent = debugfs_create_file(hdr_debugfs_files[i].name,
hdr_debugfs_files[i].mode,
phdr->dbg_root, NULL,
hdr_debugfs_files[i].fops);
if (!ent)
pr_err("debugfs create failed\n");
}
}
static void hdr_debugfs_exit(void)
{
if (phdr && phdr->dbg_root)
debugfs_remove(phdr->dbg_root);
}
void hdr_init(struct hdr_data_t *phdr_data)
{
if (phdr_data) {
phdr = phdr_data;
} else {
phdr = NULL;
pr_err("%s failed\n", __func__);
return;
}
hdr_debugfs_init();
}
void hdr_exit(void)
{
hdr_debugfs_exit();
}
/*-----------------------------------------*/
static void vpp_set_mtx_en_write(void);
struct hdr_osd_reg_s hdr_osd_reg = {
@@ -1422,6 +1555,25 @@ static unsigned int osd_oetf_41_2084_mapping[OSD_OETF_LUT_SIZE] = {
1023
};
/* osd eotf lut: 709 from baozheng */
static unsigned int osd_eotf_33_709_mapping_100[EOTF_LUT_SIZE] = {
0, 8, 37, 90, 169, 276, 412, 579,
776, 1006, 1268, 1564, 1894, 2258, 2658, 3094,
3566, 4075, 4621, 5204, 5826, 6486, 7185, 7923,
8701, 9518, 10376, 11274, 12213, 13194, 14215, 15279,
16384
};
/* osd oetf lut: 2084 from baozheng */
static unsigned int osd_oetf_41_2084_mapping_100[OSD_OETF_LUT_SIZE] = {
0, 110, 141, 162, 178, 191, 203, 212,
221, 270, 302, 325, 344, 360, 374, 386,
396, 406, 415, 423, 431, 438, 445, 451,
457, 462, 468, 473, 478, 482, 487, 491,
495, 499, 503, 507, 510, 514, 517, 520,
523
};
/* osd eotf lut: sdr->hlg */
static unsigned int osd_eotf_33_sdr2hlg_mapping[EOTF_LUT_SIZE] = {
0, 512, 1024, 1536, 2048, 2560, 3072, 3584,
@@ -4206,12 +4358,20 @@ static int hdr_process(
/*(VIU_OSD1_BLK0_CFG_W0,0, 7, 1); */
/* eotf lut 709 */
set_vpp_lut(VPP_LUT_OSD_EOTF,
osd_eotf_33_709_mapping, /* R */
osd_eotf_33_709_mapping, /* G */
osd_eotf_33_709_mapping, /* B */
CSC_ON);
if (is_hdr_cfg_osd_100()) {
set_vpp_lut(VPP_LUT_OSD_EOTF,
osd_eotf_33_709_mapping_100, /* R */
osd_eotf_33_709_mapping_100, /* G */
osd_eotf_33_709_mapping_100, /* B */
CSC_ON);
} else {
set_vpp_lut(VPP_LUT_OSD_EOTF,
osd_eotf_33_709_mapping, /* R */
osd_eotf_33_709_mapping, /* G */
osd_eotf_33_709_mapping, /* B */
CSC_ON);
}
/* eotf matrix 709->2020 */
osd_mtx[EOTF_COEFF_SIZE - 1] = osd_m.right_shift;
for (i = 0; i < 3; i++)
@@ -4227,12 +4387,19 @@ static int hdr_process(
CSC_ON);
/* oetf lut 2084 */
set_vpp_lut(VPP_LUT_OSD_OETF,
osd_oetf_41_2084_mapping, /* R */
osd_oetf_41_2084_mapping, /* G */
osd_oetf_41_2084_mapping, /* B */
CSC_ON);
if (is_hdr_cfg_osd_100()) {
set_vpp_lut(VPP_LUT_OSD_OETF,
osd_oetf_41_2084_mapping_100, /* R */
osd_oetf_41_2084_mapping_100, /* G */
osd_oetf_41_2084_mapping_100, /* B */
CSC_ON);
} else {
set_vpp_lut(VPP_LUT_OSD_OETF,
osd_oetf_41_2084_mapping, /* R */
osd_oetf_41_2084_mapping, /* G */
osd_oetf_41_2084_mapping, /* B */
CSC_ON);
}
/* osd matrix RGB2020 to YUV2020 limit */
set_vpp_matrix(VPP_MATRIX_OSD,
RGB2020_to_YUV2020l_coeff,
@@ -4601,19 +4768,27 @@ static void bypass_hdr_process(
(vinfo->viu_color_fmt != COLOR_FMT_RGB444))) {
/* OSD convert to HDR to match HDR video */
/* osd eotf lut 709 */
if (get_hdr_type() & HLG_FLAG)
if (get_hdr_type() & HLG_FLAG) {
set_vpp_lut(VPP_LUT_OSD_EOTF,
osd_eotf_33_sdr2hlg_mapping, /* R */
osd_eotf_33_sdr2hlg_mapping, /* G */
osd_eotf_33_sdr2hlg_mapping, /* B */
CSC_ON);
else
set_vpp_lut(VPP_LUT_OSD_EOTF,
osd_eotf_33_709_mapping, /* R */
osd_eotf_33_709_mapping, /* G */
osd_eotf_33_709_mapping, /* B */
CSC_ON);
} else {
if (is_hdr_cfg_osd_100()) {
set_vpp_lut(VPP_LUT_OSD_EOTF,
osd_eotf_33_709_mapping_100,
osd_eotf_33_709_mapping_100,
osd_eotf_33_709_mapping_100,
CSC_ON);
} else {
set_vpp_lut(VPP_LUT_OSD_EOTF,
osd_eotf_33_709_mapping, /*R*/
osd_eotf_33_709_mapping, /*G*/
osd_eotf_33_709_mapping, /*B*/
CSC_ON);
}
}
/* osd eotf matrix 709->2020 */
if (master_info->present_flag & 1) {
pr_csc("\tMaster_display_colour available.\n");
@@ -4646,19 +4821,27 @@ static void bypass_hdr_process(
CSC_ON);
/* osd oetf lut 2084 */
if (get_hdr_type() & HLG_FLAG)
if (get_hdr_type() & HLG_FLAG) {
set_vpp_lut(VPP_LUT_OSD_OETF,
osd_oetf_41_sdr2hlg_mapping, /* R */
osd_oetf_41_sdr2hlg_mapping, /* G */
osd_oetf_41_sdr2hlg_mapping, /* B */
CSC_ON);
else
set_vpp_lut(VPP_LUT_OSD_OETF,
osd_oetf_41_2084_mapping, /* R */
osd_oetf_41_2084_mapping, /* G */
osd_oetf_41_2084_mapping, /* B */
CSC_ON);
} else {
if (is_hdr_cfg_osd_100()) {
set_vpp_lut(VPP_LUT_OSD_OETF,
osd_oetf_41_2084_mapping_100,
osd_oetf_41_2084_mapping_100,
osd_oetf_41_2084_mapping_100,
CSC_ON);
} else {
set_vpp_lut(VPP_LUT_OSD_OETF,
osd_oetf_41_2084_mapping,
osd_oetf_41_2084_mapping,
osd_oetf_41_2084_mapping,
CSC_ON);
}
}
/* osd matrix RGB2020 to YUV2020 limit */
set_vpp_matrix(VPP_MATRIX_OSD,
RGB2020_to_YUV2020l_coeff,

View File

@@ -143,5 +143,25 @@ extern int VSYNC_WR_MPEG_REG(u32 adr, u32 val);
extern u32 get_video_enabled(void);
extern void get_hdr_source_type(void);
/*hdr*/
/*#define DBG_BUF_SIZE (1024)*/
struct hdr_cfg_t {
unsigned int en_osd_lut_100;
};
struct hdr_data_t {
struct hdr_cfg_t hdr_cfg;
/*debug_fs*/
struct dentry *dbg_root;
/*char dbg_buf[DBG_BUF_SIZE];*/
};
extern void hdr_init(struct hdr_data_t *phdr_data);
extern void hdr_exit(void);
extern void hdr_set_cfg_osd_100(int val);
#endif /* AM_CSC_H */

View File

@@ -79,6 +79,9 @@ struct amvecm_dev_s {
struct device *dev;
struct class *clsp;
wait_queue_head_t hdr_queue;
/*hdr*/
struct hdr_data_t hdr_d;
};
static struct amvecm_dev_s amvecm_dev;
@@ -4470,6 +4473,16 @@ static void aml_vecm_dt_parse(struct platform_device *pdev)
pr_info("Can't find wb_sel.\n");
else
video_rgb_ogo_xvy_mtx = val;
/*hdr:cfg:osd_100*/
ret = of_property_read_u32(node, "cfg_en_osd_100", &val);
if (ret) {
hdr_set_cfg_osd_100(0);
pr_info("hdr:Can't find cfg_en_osd_100.\n");
} else {
hdr_set_cfg_osd_100((int)val);
}
}
/* init module status */
amvecm_wb_init(wb_en);
@@ -4595,7 +4608,9 @@ static int aml_vecm_probe(struct platform_device *pdev)
vlock_en = 1;
else
vlock_en = 0;
hdr_init(&amvecm_dev.hdr_d);
aml_vecm_dt_parse(pdev);
probe_ok = 1;
pr_info("%s: ok\n", __func__);
return 0;
@@ -4624,6 +4639,8 @@ fail_alloc_region:
static int __exit aml_vecm_remove(struct platform_device *pdev)
{
struct amvecm_dev_s *devp = &amvecm_dev;
hdr_exit();
device_destroy(devp->clsp, devp->devno);
cdev_del(&devp->cdev);
class_destroy(devp->clsp);
@@ -4660,6 +4677,7 @@ static void amvecm_shutdown(struct platform_device *pdev)
{
struct amvecm_dev_s *devp = &amvecm_dev;
hdr_exit();
ve_disable_dnlp();
amcm_disable();
WRITE_VPP_REG(VPP_VADJ_CTRL, 0x0);