mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
hdr: add hdr tone mapping ioctrol [1/1]
PD#SWPL-13948 Problem: customer want to set hdr tone mapping curve themself, we provide hdr interface for them Solution: add hdr iocontrol interface Verify: verify on TL1 Change-Id: I9b7d5b33e0a72c6d1ca1fca2ebffe2a3c7e460aa Signed-off-by: MingLiang Dong <mingliang.dong@amlogic.com>
This commit is contained in:
@@ -3914,6 +3914,11 @@ int signal_type_changed(struct vframe_s *vf,
|
||||
change_flag |= SIG_SRC_OUTPUT_CHG;
|
||||
}
|
||||
|
||||
if (vecm_latch_flag & FLAG_HDR_OOTF_LATCH) {
|
||||
change_flag |= SIG_HDR_OOTF_CHG;
|
||||
vecm_latch_flag &= ~FLAG_HDR_OOTF_LATCH;
|
||||
}
|
||||
|
||||
return change_flag;
|
||||
}
|
||||
|
||||
@@ -6696,7 +6701,8 @@ static void video_process(
|
||||
SIG_KNEE_FACTOR |
|
||||
SIG_HDR_MODE |
|
||||
SIG_HDR_SUPPORT |
|
||||
SIG_HLG_MODE)
|
||||
SIG_HLG_MODE |
|
||||
SIG_HDR_OOTF_CHG)
|
||||
) ||
|
||||
(cur_csc_type[vd_path] <
|
||||
VPP_MATRIX_BT2020YUV_BT2020RGB)) {
|
||||
@@ -6725,7 +6731,8 @@ static void video_process(
|
||||
SIG_KNEE_FACTOR |
|
||||
SIG_HDR_MODE |
|
||||
SIG_HDR_SUPPORT |
|
||||
SIG_HLG_MODE)
|
||||
SIG_HLG_MODE |
|
||||
SIG_HDR_OOTF_CHG)
|
||||
) ||
|
||||
(cur_csc_type[vd_path] <
|
||||
VPP_MATRIX_BT2020YUV_BT2020RGB)) {
|
||||
@@ -6750,7 +6757,8 @@ static void video_process(
|
||||
SIG_KNEE_FACTOR |
|
||||
SIG_HDR_MODE |
|
||||
SIG_HDR_SUPPORT |
|
||||
SIG_HLG_MODE)
|
||||
SIG_HLG_MODE |
|
||||
SIG_HDR_OOTF_CHG)
|
||||
) ||
|
||||
(cur_csc_type[vd_path] <
|
||||
VPP_MATRIX_BT2020YUV_BT2020RGB)) {
|
||||
@@ -6778,7 +6786,8 @@ static void video_process(
|
||||
SIG_KNEE_FACTOR |
|
||||
SIG_HDR_MODE |
|
||||
SIG_HDR_SUPPORT |
|
||||
SIG_HLG_MODE)) ||
|
||||
SIG_HLG_MODE |
|
||||
SIG_HDR_OOTF_CHG)) ||
|
||||
(cur_csc_type[vd_path] <
|
||||
VPP_MATRIX_BT2020YUV_BT2020RGB)) {
|
||||
bypass_hdr_process(csc_type, vinfo, p,
|
||||
@@ -7015,7 +7024,7 @@ static int vpp_matrix_update(
|
||||
& (SIG_CS_CHG | SIG_PRI_INFO | SIG_KNEE_FACTOR | SIG_HDR_MODE |
|
||||
SIG_HDR_SUPPORT | SIG_HLG_MODE | SIG_OP_CHG |
|
||||
SIG_SRC_OUTPUT_CHG | SIG_HDR10_PLUS_MODE |
|
||||
SIG_SRC_CHG))) {
|
||||
SIG_SRC_CHG | SIG_HDR_OOTF_CHG))) {
|
||||
if (cpu_after_eq(MESON_CPU_MAJOR_ID_G12A) &&
|
||||
(get_cpu_type() != MESON_CPU_MAJOR_ID_TL1))
|
||||
video_post_process(csc_type, vinfo, vd_path);
|
||||
|
||||
@@ -115,6 +115,7 @@ enum output_format_e {
|
||||
#define SIG_HDR10_PLUS_MODE 0x800
|
||||
#define SIG_COLORIMETRY_SUPPORT 0x1000
|
||||
#define SIG_OUTPUT_MODE_CHG 0x2000
|
||||
#define SIG_HDR_OOTF_CHG 0x4000
|
||||
|
||||
#define LUT_289_SIZE 289
|
||||
extern unsigned int lut_289_mapping[LUT_289_SIZE];
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
#include "hdr/am_hdr10_plus.h"
|
||||
#include "local_contrast.h"
|
||||
#include "arch/vpp_hdr_regs.h"
|
||||
|
||||
#include "set_hdr2_v0.h"
|
||||
|
||||
#define pr_amvecm_dbg(fmt, args...)\
|
||||
do {\
|
||||
@@ -1458,6 +1458,30 @@ static void parse_overscan_table(unsigned int length,
|
||||
atv_source_flg = 0;
|
||||
}
|
||||
|
||||
static void hdr_tone_mapping_get(
|
||||
unsigned int length,
|
||||
unsigned int *hdr_tm)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (hdr_tm) {
|
||||
for (i = 0; i < length; i++)
|
||||
oo_y_lut_hdr_sdr[i] = hdr_tm[i];
|
||||
}
|
||||
|
||||
vecm_latch_flag |= FLAG_HDR_OOTF_LATCH;
|
||||
|
||||
if (debug_amvecm & 4) {
|
||||
for (i = 0; i < length; i++) {
|
||||
pr_info("oo_y_lut_hdr_sdr[%d] = %d",
|
||||
i, oo_y_lut_hdr_sdr[i]);
|
||||
if (i % 8 == 0)
|
||||
pr_info("\n");
|
||||
}
|
||||
pr_info("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static long amvecm_ioctl(struct file *file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
@@ -1467,6 +1491,8 @@ static long amvecm_ioctl(struct file *file,
|
||||
struct ve_pq_load_s vpp_pq_load;
|
||||
struct ve_pq_table_s *vpp_pq_load_table = NULL;
|
||||
enum color_primary_e color_pri;
|
||||
struct hdr_tone_mapping_s hdr_tone_mapping;
|
||||
unsigned int *hdr_tm = NULL;
|
||||
|
||||
if (debug_amvecm & 2)
|
||||
pr_info("[amvecm..] %s: cmd_nr = 0x%x\n",
|
||||
@@ -1668,6 +1694,36 @@ static long amvecm_ioctl(struct file *file,
|
||||
}
|
||||
parse_overscan_table(vpp_pq_load.length, vpp_pq_load_table);
|
||||
break;
|
||||
case AMVECM_IOC_S_HDR_TM:
|
||||
if (copy_from_user(
|
||||
&hdr_tone_mapping,
|
||||
(void __user *)arg,
|
||||
sizeof(struct hdr_tone_mapping_s))) {
|
||||
ret = -EFAULT;
|
||||
pr_amvecm_dbg("hdr ioc fail!!!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (hdr_tone_mapping.lutlength > HDR2_OOTF_LUT_SIZE) {
|
||||
pr_amvecm_dbg("hdr tm over size !!!\n");
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
}
|
||||
mem_size = hdr_tone_mapping.lutlength * sizeof(unsigned int);
|
||||
hdr_tm = kmalloc(mem_size, GFP_KERNEL);
|
||||
argp = hdr_tone_mapping.tm_lut;
|
||||
if (!hdr_tm) {
|
||||
ret = -EFAULT;
|
||||
pr_amvecm_dbg("hdr tm kmalloc fail!!!\n");
|
||||
break;
|
||||
}
|
||||
if (copy_from_user(hdr_tm, argp, mem_size)) {
|
||||
pr_amvecm_dbg("[amvecm..] hdr_tm copy fail!!\n");
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
}
|
||||
hdr_tone_mapping_get(hdr_tone_mapping.lutlength, hdr_tm);
|
||||
break;
|
||||
case AMVECM_IOC_G_DNLP_STATE:
|
||||
if (copy_to_user((void __user *)arg,
|
||||
&dnlp_en, sizeof(enum dnlp_state_e)))
|
||||
@@ -1803,7 +1859,9 @@ static long amvecm_ioctl(struct file *file,
|
||||
break;
|
||||
}
|
||||
if (vpp_pq_load_table != NULL)
|
||||
kfree(vpp_pq_load_table);
|
||||
kfree(vpp_pq_load_table);
|
||||
|
||||
kfree(hdr_tm);
|
||||
return ret;
|
||||
}
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
||||
@@ -187,4 +187,5 @@ extern void set_ootf_lut(
|
||||
enum hdr_module_sel module_sel,
|
||||
struct hdr_proc_lut_param_s *hdr_lut_param);
|
||||
extern struct hdr_proc_lut_param_s hdr_lut_param;
|
||||
extern int oo_y_lut_hdr_sdr[149];
|
||||
|
||||
|
||||
@@ -27,13 +27,12 @@
|
||||
|
||||
|
||||
/* struct ve_dnlp_s video_ve_dnlp; */
|
||||
|
||||
#define FLAG_RSV31 (1 << 31)
|
||||
#define FLAG_VADJ1_COLOR (1 << 30)
|
||||
#define FLAG_VE_DNLP (1 << 29)
|
||||
#define FLAG_VE_NEW_DNLP (1 << 28)
|
||||
#define FLAG_VE_LC_CURV (1 << 27)
|
||||
#define FLAG_RSV26 (1 << 26)
|
||||
#define FLAG_HDR_OOTF_LATCH BIT(26)
|
||||
#define FLAG_3D_BLACK_DIS (1 << 25)
|
||||
#define FLAG_3D_BLACK_EN (1 << 24)
|
||||
#define FLAG_3D_SYNC_DIS (1 << 23)
|
||||
@@ -223,6 +222,14 @@ enum pc_mode_e {
|
||||
/*Local contrast command list*/
|
||||
#define AMVECM_IOC_S_LC_CURVE _IOW(_VE_CM, 0x62, struct ve_lc_curve_parm_s)
|
||||
|
||||
/*tone mapping struct*/
|
||||
struct hdr_tone_mapping_s {
|
||||
unsigned int lutlength;
|
||||
unsigned int *tm_lut;
|
||||
};
|
||||
|
||||
#define AMVECM_IOC_S_HDR_TM _IOW(_VE_CM, 0x63, struct hdr_tone_mapping_s)
|
||||
#define AMVECM_IOC_G_HDR_TM _IOR(_VE_CM, 0x64, struct hdr_tone_mapping_s)
|
||||
|
||||
struct am_vdj_mode_s {
|
||||
int flag;
|
||||
|
||||
Reference in New Issue
Block a user