From: yicheng shen Date: Thu, 26 Apr 2018 13:33:32 +0000 (+0800) Subject: vdin: add force_color_range control[1/2] X-Git-Tag: khadas-vims-v0.9.6-release~2118 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc307b359a9ee0d2914d469d79c8ab93f226535b;p=platform%2Fkernel%2Flinux-amlogic.git vdin: add force_color_range control[1/2] PD#165178: vdin: add force_color_range control[1/2] Change-Id: I5f8a94ed0416867841bc8d1c744e176cced64fc6 Signed-off-by: yicheng shen --- diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.h b/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.h index afdd128..8110ff4 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.h +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.h @@ -196,5 +196,6 @@ extern void vdin_set_display_ratio(struct vdin_dev_s *devp, extern void vdin_source_bitdepth_reinit(struct vdin_dev_s *devp); extern void set_invert_top_bot(bool invert_flag); extern void vdin_clk_onoff(struct vdin_dev_s *devp, bool onoff); +extern enum tvin_force_color_range_e color_range_force; #endif diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c index c4de748..051e375 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c @@ -139,6 +139,8 @@ MODULE_PARM_DESC(game_mode, "game_mode"); static int irq_max_count; +enum tvin_force_color_range_e color_range_force = COLOR_RANGE_AUTO; + static void vdin_backup_histgram(struct vframe_s *vf, struct vdin_dev_s *devp); char *vf_get_receiver_name(const char *provider_name); @@ -2139,6 +2141,26 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (vdin_dbg_en) pr_info("TVIN_IOC_SNOWOFF(%d) ok\n\n", devp->index); break; + case TVIN_IOC_GET_COLOR_RANGE: + if (copy_to_user(argp, + &color_range_force, + sizeof(enum tvin_force_color_range_e))) { + ret = -EFAULT; + pr_info("TVIN_IOC_GET_COLOR_RANGE err\n\n"); + break; + } + pr_info("get color range-%d\n\n", color_range_force); + break; + case TVIN_IOC_SET_COLOR_RANGE: + if (copy_from_user(&color_range_force, + argp, + sizeof(enum tvin_force_color_range_e))) { + ret = -EFAULT; + pr_info("TVIN_IOC_SET_COLOR_RANGE err\n\n"); + break; + } + pr_info("force color range-%d\n\n", color_range_force); + break; default: ret = -ENOIOCTLCMD; /* pr_info("%s %d is not supported command\n", __func__, cmd); */ diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c index 9b32c76..7200239 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c @@ -140,6 +140,25 @@ MODULE_PARM_DESC(nosig2_unstable_cnt, "nosig2_unstable_cnt"); static int signal_status = TVIN_SIG_STATUS_NULL; module_param(signal_status, int, 0664); MODULE_PARM_DESC(signal_status, "signal_status"); +enum tvin_color_fmt_range_e tvin_get_force_fmt_range( + enum tvin_color_fmt_range_e fmt_range, + enum tvin_color_fmt_e color_fmt) +{ + if (color_fmt == TVIN_YUV444 || + color_fmt == TVIN_YUV422) { + if (color_range_force == COLOR_RANGE_FULL) + fmt_range = TVIN_YUV_FULL; + else if (color_range_force == COLOR_RANGE_LIMIT) + fmt_range = TVIN_YUV_LIMIT; + } else if (color_fmt == TVIN_RGB444) { + if (color_range_force == COLOR_RANGE_FULL) + fmt_range = TVIN_RGB_FULL; + else if (color_range_force == COLOR_RANGE_LIMIT) + fmt_range = TVIN_RGB_LIMIT; + } + return fmt_range; +} + /* * check hdmirx color format */ @@ -181,6 +200,10 @@ static void hdmirx_color_fmt_handler(struct vdin_dev_s *devp) vdin_hdr_flag = prop->vdin_hdr_Flag; pre_vdin_hdr_flag = pre_prop->vdin_hdr_Flag; + if (color_range_force) + prop->color_fmt_range = + tvin_get_force_fmt_range(pre_prop->color_fmt_range, + pre_prop->color_format); vdin_fmt_range = prop->color_fmt_range; pre_vdin_fmt_range = pre_prop->color_fmt_range; diff --git a/include/linux/amlogic/media/frame_provider/tvin/tvin.h b/include/linux/amlogic/media/frame_provider/tvin/tvin.h index 7d5de0a..88776bc 100644 --- a/include/linux/amlogic/media/frame_provider/tvin/tvin.h +++ b/include/linux/amlogic/media/frame_provider/tvin/tvin.h @@ -291,6 +291,11 @@ enum tvin_color_fmt_range_e { TVIN_COLOR_FMT_RANGE_MAX, }; +enum tvin_force_color_range_e { + COLOR_RANGE_AUTO = 0, + COLOR_RANGE_FULL, + COLOR_RANGE_LIMIT, +}; const char *tvin_color_fmt_str(enum tvin_color_fmt_e color_fmt); enum tvin_scan_mode_e { TVIN_SCAN_MODE_NULL = 0, @@ -421,6 +426,10 @@ struct tvafe_pin_mux_s { #define TVIN_IOC_UNFREEZE_VF _IO(_TM_T, 0x46) #define TVIN_IOC_SNOWON _IO(_TM_T, 0x47) #define TVIN_IOC_SNOWOFF _IO(_TM_T, 0x48) +#define TVIN_IOC_GET_COLOR_RANGE _IOR(_TM_T, 0X49,\ + enum tvin_force_color_range_e) +#define TVIN_IOC_SET_COLOR_RANGE _IOW(_TM_T, 0X4a,\ + enum tvin_force_color_range_e) /* TVAFE */ #define TVIN_IOC_S_AFE_VGA_PARM _IOW(_TM_T, 0x16, struct tvafe_vga_parm_s)