From f722263191bdfecdb3ee11ced920c8b39b1a8f0c Mon Sep 17 00:00:00 2001 From: Brian Zhu Date: Wed, 16 Jan 2019 05:12:00 +0800 Subject: [PATCH] vpp: add two layers support for each chips [1/6] PD#SWPL-85 Problem: Need support two video layers feature Solution: 1.Add vd2 mif config 2.Add vd2 pps calculation and config 3.Add vd2 axis/crop/screen mode interface by sysfs and ioctl 4.Add layer query/alloc/free interface Verify: Verify on U212 Change-Id: I71fc9ab2ae0230c3e84c4b790e77d2c790951642 Signed-off-by: Brian Zhu --- drivers/amlogic/media/deinterlace/di_pps.h | 1 + drivers/amlogic/media/osd/osd_hw.c | 1 + .../media/video_processor/ppmgr/ppmgr_drv.c | 2 +- .../media/video_processor/ppmgr/ppmgr_vpp.c | 7 +- drivers/amlogic/media/video_sink/video.c | 3729 ++++++++++++++------ drivers/amlogic/media/video_sink/video_keeper.c | 202 +- drivers/amlogic/media/video_sink/video_priv.h | 91 + drivers/amlogic/media/video_sink/vpp.c | 1601 +++++---- .../linux/amlogic/media/registers/regs/vpp_regs.h | 3 + include/linux/amlogic/media/utils/amstream.h | 30 +- include/linux/amlogic/media/vfm/vframe_receiver.h | 1 + include/linux/amlogic/media/video_sink/video.h | 75 +- include/linux/amlogic/media/video_sink/vpp.h | 161 +- 13 files changed, 3923 insertions(+), 1981 deletions(-) diff --git a/drivers/amlogic/media/deinterlace/di_pps.h b/drivers/amlogic/media/deinterlace/di_pps.h index b78a020..9ec789e 100644 --- a/drivers/amlogic/media/deinterlace/di_pps.h +++ b/drivers/amlogic/media/deinterlace/di_pps.h @@ -18,6 +18,7 @@ #ifndef DI_PPS_H #define DI_PPS_H #include +#include #if 0 #define VPP_FLAG_WIDEMODE_MASK 0x0000000F #define VPP_FLAG_INTERLACE_OUT 0x00000010 diff --git a/drivers/amlogic/media/osd/osd_hw.c b/drivers/amlogic/media/osd/osd_hw.c index ee926ca..af078c1 100644 --- a/drivers/amlogic/media/osd/osd_hw.c +++ b/drivers/amlogic/media/osd/osd_hw.c @@ -54,6 +54,7 @@ #endif #ifdef CONFIG_AMLOGIC_MEDIA_VIDEO +#include #include #endif #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION diff --git a/drivers/amlogic/media/video_processor/ppmgr/ppmgr_drv.c b/drivers/amlogic/media/video_processor/ppmgr/ppmgr_drv.c index d33d148..7247159 100644 --- a/drivers/amlogic/media/video_processor/ppmgr/ppmgr_drv.c +++ b/drivers/amlogic/media/video_processor/ppmgr/ppmgr_drv.c @@ -31,11 +31,11 @@ #include #include #include +#include #include "ppmgr_log.h" #include "ppmgr_pri.h" #include "ppmgr_dev.h" -#include #define PPMGRDRV_INFO(fmt, args...) pr_info("PPMGRDRV: info: "fmt"", ## args) #define PPMGRDRV_DBG(fmt, args...) pr_debug("PPMGRDRV: dbg: "fmt"", ## args) diff --git a/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c b/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c index d9560b43..664ad0b 100644 --- a/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c +++ b/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c @@ -46,7 +46,6 @@ #include #include #include -#include /*#include "../amports/video.h"*/ #include /*#include "../amports/vdec_reg.h"*/ @@ -2755,7 +2754,6 @@ static int process_vf_adjust(struct vframe_s *vf, /* extern int get_tv_process_type(struct vframe_s *vf); */ /* #endif */ static struct task_struct *task; -/* extern int video_property_notify(int flag); */ /* extern struct vframe_s *get_cur_dispbuf(void); */ /* extern enum platform_type_t get_platform_type(void); */ @@ -2835,7 +2833,10 @@ static int ppmgr_task(void *data) continue; process_vf_change(vf, context, &ge2d_config); - video_property_notify(2); + vf_notify_receiver( + PROVIDER_NAME, + VFRAME_EVENT_PROVIDER_PROPERTY_CHANGED, + NULL); vfq_lookup_start(&q_ready); vf = vfq_peek(&q_ready); diff --git a/drivers/amlogic/media/video_sink/video.c b/drivers/amlogic/media/video_sink/video.c index 870a418..96e2bbe 100644 --- a/drivers/amlogic/media/video_sink/video.c +++ b/drivers/amlogic/media/video_sink/video.c @@ -81,7 +81,6 @@ MODULE_AMLOG(LOG_LEVEL_ERROR, 0, LOG_DEFAULT_LEVEL_DESC, LOG_MASK_DESC); #define DISPLAY_CANVAS_MAX_INDEX2 0x15 #include "../common/rdma/rdma.h" #endif -#include #include #include @@ -91,6 +90,9 @@ MODULE_AMLOG(LOG_LEVEL_ERROR, 0, LOG_DEFAULT_LEVEL_DESC, LOG_MASK_DESC); #ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND #include #endif + +#define VIDEO_PIP + static u32 osd_vpp_misc; static u32 osd_vpp_misc_mask; static bool update_osd_vpp_misc; @@ -183,16 +185,22 @@ static const struct vframe_receiver_op_s video_vf_receiver = { static struct vframe_receiver_s video_vf_recv; -#define RECEIVER4OSD_NAME "amvideo4osd" -static int video4osd_receiver_event_fun(int type, void *data, void *); +#ifdef VIDEO_PIP +#define RECEIVERPIP_NAME "videopip" +static int pip_receiver_event_fun(int type, void *data, void *); -static const struct vframe_receiver_op_s video4osd_vf_receiver = { - .event_cb = video4osd_receiver_event_fun +static const struct vframe_receiver_op_s videopip_vf_receiver = { + .event_cb = pip_receiver_event_fun }; -static struct vframe_receiver_s video4osd_vf_recv; +static struct vframe_receiver_s videopip_vf_recv; -static struct vframe_provider_s *osd_prov; +static struct vpp_frame_par_s *curpip_frame_par, *nextpip_frame_par; +static struct vpp_frame_par_s pip_frame_parms[2]; +static struct vframe_s *cur_pipbuf; +static struct vframe_s local_pip; +static int _videopip_set_disable(u32 val); +#endif static struct device *amvideo_dev; static struct device *amvideo_poll_dev; @@ -238,10 +246,6 @@ static u32 hdmiin_frame_check_cnt; #define BRIDGE_IRQ_SET() WRITE_CBUS_REG(ISA_TIMERC, 1) #endif - - -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ - #define VD1_MEM_POWER_ON() \ do { \ unsigned long flags; \ @@ -283,22 +287,14 @@ static u32 hdmiin_frame_check_cnt; vpu_mem_power_off_count = VPU_MEM_POWEROFF_DELAY; \ spin_unlock_irqrestore(&delay_work_lock, flags); \ } while (0) -#else -#define VD1_MEM_POWER_ON() -#define VD2_MEM_POWER_ON() -#define PROT_MEM_POWER_ON() -#define VD1_MEM_POWER_OFF() -#define VD2_MEM_POWER_OFF() -#define PROT_MEM_POWER_OFF() -#endif #define VIDEO_LAYER_ON() \ do { \ unsigned long flags; \ spin_lock_irqsave(&video_onoff_lock, flags); \ video_onoff_state = VIDEO_ENABLE_STATE_ON_REQ; \ - video_enabled = 1;\ - video_status_saved = 1;\ + video_enabled = 1; \ + video_status_saved = 1; \ spin_unlock_irqrestore(&video_onoff_lock, flags); \ } while (0) @@ -307,8 +303,8 @@ static u32 hdmiin_frame_check_cnt; unsigned long flags; \ spin_lock_irqsave(&video_onoff_lock, flags); \ video_onoff_state = VIDEO_ENABLE_STATE_OFF_REQ; \ - video_enabled = 0;\ - video_status_saved = 0;\ + video_enabled = 0; \ + video_status_saved = 0; \ spin_unlock_irqrestore(&video_onoff_lock, flags); \ } while (0) @@ -317,6 +313,8 @@ static u32 hdmiin_frame_check_cnt; unsigned long flags; \ spin_lock_irqsave(&video2_onoff_lock, flags); \ video2_onoff_state = VIDEO_ENABLE_STATE_ON_REQ; \ + video2_enabled = 1; \ + video2_status_saved = 1; \ spin_unlock_irqrestore(&video2_onoff_lock, flags); \ } while (0) @@ -325,6 +323,8 @@ static u32 hdmiin_frame_check_cnt; unsigned long flags; \ spin_lock_irqsave(&video2_onoff_lock, flags); \ video2_onoff_state = VIDEO_ENABLE_STATE_OFF_REQ; \ + video2_enabled = 0; \ + video2_status_saved = 0; \ spin_unlock_irqrestore(&video2_onoff_lock, flags); \ } while (0) @@ -334,21 +334,12 @@ static u32 hdmiin_frame_check_cnt; VIDEO_LAYER_ON(); \ } while (0) -#if 0 /*TV_3D_FUNCTION_OPEN*/ -#define EnableVideoLayer2() \ - do { \ - VD2_MEM_POWER_ON(); \ - SET_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ - VPP_VD2_PREBLEND | VPP_PREBLEND_EN | \ - (0x1ff << VPP_VD2_ALPHA_BIT)); \ - } while (0) -#else #define EnableVideoLayer2() \ do { \ VD2_MEM_POWER_ON(); \ VIDEO_LAYER2_ON(); \ } while (0) -#endif + #define VSYNC_EnableVideoLayer2() \ do { \ VD2_MEM_POWER_ON(); \ @@ -360,8 +351,7 @@ static u32 hdmiin_frame_check_cnt; #define DisableVideoLayer() \ do { \ CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ - VPP_VD1_PREBLEND | VPP_VD2_PREBLEND|\ - VPP_VD2_POSTBLEND | VPP_VD1_POSTBLEND); \ + VPP_VD1_PREBLEND | VPP_VD1_POSTBLEND); \ if (!legacy_vpp) { \ WRITE_VCBUS_REG( \ VD1_BLEND_SRC_CTRL + cur_dev->vpp_off, 0); \ @@ -369,13 +359,11 @@ static u32 hdmiin_frame_check_cnt; WRITE_VCBUS_REG(AFBC_ENABLE, 0);\ VIDEO_LAYER_OFF(); \ VD1_MEM_POWER_OFF(); \ - video_prot.video_started = 0; \ if (debug_flag & DEBUG_FLAG_BLACKOUT) { \ pr_info("DisableVideoLayer()\n"); \ } \ } while (0) -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ #define DisableVideoLayer_NoDelay() \ do { \ CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ @@ -390,28 +378,15 @@ static u32 hdmiin_frame_check_cnt; pr_info("DisableVideoLayer_NoDelay()\n"); \ } \ } while (0) -#else -#define DisableVideoLayer_NoDelay() DisableVideoLayer() -#endif -#if 0 /*TV_3D_FUNCTION_OPEN */ -#define DisableVideoLayer2() \ - do { \ - CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ - VPP_VD2_PREBLEND | VPP_PREBLEND_EN | \ - (0x1ff << VPP_VD2_ALPHA_BIT)); \ - WRITE_VCBUS_REG(VD2_AFBC_ENABLE, 0); \ - VD2_MEM_POWER_OFF(); \ - } while (0) -#else + #define DisableVideoLayer2() \ do { \ CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ - VPP_VD2_POSTBLEND | VPP_VD2_PREBLEND | \ - (0x1ff << VPP_VD2_ALPHA_BIT)); \ + VPP_VD2_POSTBLEND | VPP_VD2_PREBLEND); \ VIDEO_LAYER2_OFF(); \ VD2_MEM_POWER_OFF(); \ } while (0) -#endif + #define DisableVideoLayer_PREBELEND() \ do { CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ VPP_VD1_PREBLEND | VPP_VD2_PREBLEND); \ @@ -421,13 +396,6 @@ static u32 hdmiin_frame_check_cnt; } \ } while (0) -#ifndef CONFIG_AM_VIDEO2 -#define DisableVPP2VideoLayer() \ - CLEAR_VCBUS_REG_MASK(VPP2_MISC, \ - VPP_VD1_PREBLEND | VPP_VD2_PREBLEND | \ - VPP_VD2_POSTBLEND | VPP_VD1_POSTBLEND) - -#endif /*********************************************************/ #if DEBUG_TMP static struct switch_dev video1_state_sdev = { @@ -436,16 +404,15 @@ static struct switch_dev video1_state_sdev = { }; #endif +static DEFINE_MUTEX(video_layer_mutex); +static u32 layer_cap; -#define MAX_ZOOM_RATIO 300 +static struct disp_info_s glayer_info[MAX_VD_LAYERS]; -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ +#define MAX_ZOOM_RATIO 300 #define VPP_PREBLEND_VD_V_END_LIMIT 2304 -#else -#define VPP_PREBLEND_VD_V_END_LIMIT 1080 -#endif #define DUR2PTS(x) ((x) - ((x) >> 4)) #define DUR2PTS_RM(x) ((x) & 0xf) @@ -458,11 +425,9 @@ static int vpts_chase_counter; static int vpts_chase_pts_diff; #endif - static int step_enable; static int step_flag; - /*seek values on.video_define.h*/ static int debug_flag; int get_video_debug_flags(void) @@ -547,10 +512,7 @@ struct video_pm_state_s { int mem_pd_vd1; int mem_pd_vd2; int mem_pd_di_post; - int mem_pd_prot2; - int mem_pd_prot3; }; - #endif #define PTS_LOGGING @@ -631,11 +593,9 @@ bool is_dolby_vision_stb_mode(void) #endif static struct amvideocap_req *capture_frame_req; -static struct video_prot_s video_prot; -static u32 video_angle; u32 get_video_angle(void) { - return video_angle; + return glayer_info[0].angle; } EXPORT_SYMBOL(get_video_angle); @@ -818,7 +778,7 @@ static void video_debugfs_exit(void) int video_scaler_notify(int flag) { video_scaler_mode = flag; - video_property_changed = true; + video_property_changed = 1; return 0; } @@ -834,6 +794,8 @@ u32 amvideo_get_scaler_para(int *x, int *y, int *w, int *h, u32 *ratio) void amvideo_set_scaler_para(int x, int y, int w, int h, int flag) { + struct disp_info_s *layer = &glayer_info[0]; + mutex_lock(&video_module_mutex); if (w < 2) w = 0; @@ -847,9 +809,13 @@ void amvideo_set_scaler_para(int x, int y, int w, int h, int flag) content_top = y; content_w = w; content_h = h; - } else - vpp_set_video_layer_position(x, y, w, h); - video_property_changed = true; + } else { + layer->layer_left = x; + layer->layer_top = y; + layer->layer_width = w; + layer->layer_height = h; + } + video_property_changed = 1; mutex_unlock(&video_module_mutex); } @@ -899,6 +865,13 @@ static u32 disp_canvas[2][2]; static u32 rdma_canvas_id; static u32 next_rdma_canvas_id = 1; +#ifdef VIDEO_PIP +static u32 pip_rdma_canvas_id; +static u32 pip_next_rdma_canvas_id = 1; +static struct vframe_s *pip_rdma_buf; +static struct vframe_s *pipbuf_to_put; +#endif + #define DISPBUF_TO_PUT_MAX 8 static struct vframe_s *dispbuf_to_put[DISPBUF_TO_PUT_MAX]; static int dispbuf_to_put_num; @@ -939,9 +912,6 @@ static u32 ori2_end_x_lines; static u32 ori2_start_y_lines; static u32 ori2_end_y_lines; -/* wide settings */ -static u32 wide_setting; - /* black out policy */ #if defined(CONFIG_JPEGLOGO) static u32 blackout; @@ -951,9 +921,29 @@ static u32 blackout = 1; static u32 force_blackout; /* disable video */ + +#ifdef VIDEO_PIP +static u32 pip_frame_count; +static u32 disable_videopip = VIDEO_DISABLE_FORNEXT; +static int pip_property_changed; +static u32 pip_frame_ready_to_set; +static u32 pip_global_output = 1; +#if 0 +static u32 pip_v_skip; +static u32 pip_h_skip; +static u32 pip_start_x_lines; +static u32 pip_end_x_lines; +static u32 pip_start_y_lines; +static u32 pip_end_y_lines; +#endif +static u32 pip_loop; +#endif + static u32 disable_video = VIDEO_DISABLE_NONE; static u32 video_enabled __nosavedata; +static u32 video2_enabled __nosavedata; static u32 video_status_saved __nosavedata; +static u32 video2_status_saved __nosavedata; static u32 hold_video; u32 get_video_enabled(void) @@ -984,20 +974,6 @@ void update_cur_dispbuf(void *buf) { cur_dispbuf = buf; } -int get_video0_frame_info(struct vframe_s *vf) -{ - unsigned long flags; - int ret = -1; - - spin_lock_irqsave(&lock, flags); - if (is_vpp_postblend() && cur_dispbuf && vf) { - *vf = *cur_dispbuf; - ret = 0; - } - spin_unlock_irqrestore(&lock, flags); - return ret; -} -EXPORT_SYMBOL(get_video0_frame_info); static struct vframe_s vf_local, vf_local2; static u32 vsync_pts_inc; @@ -1146,6 +1122,58 @@ void safe_disble_videolayer(void) /*********************************************************/ +#ifdef VIDEO_PIP +static inline struct vframe_s *pip_vf_peek(void) +{ + if (pip_loop) + return cur_dispbuf; + return vf_peek(RECEIVERPIP_NAME); +} + +static inline struct vframe_s *pip_vf_get(void) +{ + struct vframe_s *vf = NULL; + + if (pip_loop) + return cur_dispbuf; + + vf = vf_get(RECEIVERPIP_NAME); + + if (vf) { + /* video_notify_flag |= VIDEO_NOTIFY_PROVIDER_GET; */ + atomic_set(&vf->use_cnt, 1); + } + return vf; + +} + +#if 0 +static int pip_vf_get_states(struct vframe_states *states) +{ + int ret = -1; + unsigned long flags; + + spin_lock_irqsave(&lock, flags); + ret = vf_get_states_by_name(RECEIVERPIP_NAME, states); + spin_unlock_irqrestore(&lock, flags); + return ret; +} +#endif + +static inline void pip_vf_put(struct vframe_s *vf) +{ + struct vframe_provider_s *vfp = vf_get_provider(RECEIVERPIP_NAME); + + if (pip_loop) + return; + + if (vfp && vf && atomic_dec_and_test(&vf->use_cnt)) { + vf_put(vf, RECEIVERPIP_NAME); + /* video_notify_flag |= VIDEO_NOTIFY_PROVIDER_PUT; */ + } +} +#endif + static inline struct vframe_s *video_vf_peek(void) { struct vframe_s *vf = vf_peek(RECEIVER_NAME); @@ -1345,6 +1373,23 @@ int ext_frame_capture_poll(int endflags) } #endif +static void update_layer_info(u8 layer_id) +{ + struct disp_info_s *layer; + + if (layer_id >= MAX_VD_LAYERS) + return; + + if (layer_id == 0) { + layer = &glayer_info[0]; + layer->reverse = reverse; + layer->proc_3d_type = process_3d_type; + } else if (layer_id == 1) { + layer = &glayer_info[1]; + layer->reverse = reverse; + layer->proc_3d_type = 0; + } +} static void vpp_settings_h(struct vpp_frame_par_s *framePtr) { @@ -1367,81 +1412,74 @@ static void vpp_settings_h(struct vpp_frame_par_s *framePtr) (framePtr->supscl_path == PPS_CORE0_POSTBLEND_CORE1)) r3 >>= framePtr->supsc0_hori_ratio; - if (platform_type == 1) { - x_lines = zoom_end_x_lines / (framePtr->hscale_skip_count + 1); - if (process_3d_type & MODE_3D_OUT_TB) { - /* vd1 and vd2 do pre blend */ - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_H_START_END, + x_lines = zoom_end_x_lines / (framePtr->hscale_skip_count + 1); + if (process_3d_type & MODE_3D_OUT_TB) { + /* vd1 and vd2 do pre blend */ + VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_H_START_END, ((zoom_start_x_lines & VPP_VD_SIZE_MASK) << - VPP_VD1_START_BIT) | (((zoom_end_x_lines) & + VPP_VD1_START_BIT) | (((zoom_end_x_lines) & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_H_START_END, + VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_H_START_END, ((zoom_start_x_lines & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | (((zoom_end_x_lines) & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - VSYNC_WR_MPEG_REG(VPP_POSTBLEND_VD1_H_START_END + + VSYNC_WR_MPEG_REG(VPP_POSTBLEND_VD1_H_START_END + cur_dev->vpp_off, ((framePtr->VPP_hsc_startp & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | ((framePtr->VPP_hsc_endp & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } else if (process_3d_type & MODE_3D_OUT_LR) { - /* vd1 and vd2 do pre blend */ - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_H_START_END, + } else if (process_3d_type & MODE_3D_OUT_LR) { + /* vd1 and vd2 do pre blend */ + VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_H_START_END, ((zoom_start_x_lines & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | (((x_lines >> 1) & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_H_START_END, + VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_H_START_END, ((((x_lines + 1) >> 1) & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | ((x_lines & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - VSYNC_WR_MPEG_REG(VPP_POSTBLEND_VD1_H_START_END + + VSYNC_WR_MPEG_REG(VPP_POSTBLEND_VD1_H_START_END + cur_dev->vpp_off, ((framePtr->VPP_hsc_startp & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | ((framePtr->VPP_hsc_endp & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } else{ - if (!legacy_vpp) { - x_lines = (zoom_end_x_lines - - zoom_start_x_lines + 1) - / (framePtr->hscale_skip_count + 1); - VSYNC_WR_MPEG_REG( + } else{ + if (!legacy_vpp) { + x_lines = (zoom_end_x_lines - + zoom_start_x_lines + 1) + / (framePtr->hscale_skip_count + 1); + VSYNC_WR_MPEG_REG( VPP_PREBLEND_VD1_H_START_END, ((0 & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | (((x_lines - 1) & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } - VSYNC_WR_MPEG_REG(VPP_POSTBLEND_VD1_H_START_END + - cur_dev->vpp_off, - ((framePtr->VPP_hsc_startp & VPP_VD_SIZE_MASK) - << VPP_VD1_START_BIT) | - ((framePtr->VPP_hsc_endp & VPP_VD_SIZE_MASK) - << VPP_VD1_END_BIT)); - - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_H_START_END + - cur_dev->vpp_off, - ((framePtr->VPP_hd_start_lines_ & - VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | - ((framePtr->VPP_hd_end_lines_ & - VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); } - } else { - VSYNC_WR_MPEG_REG(VPP_POSTBLEND_VD1_H_START_END + + VSYNC_WR_MPEG_REG( + VPP_POSTBLEND_VD1_H_START_END + cur_dev->vpp_off, ((framePtr->VPP_hsc_startp & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | ((framePtr->VPP_hsc_endp & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_H_START_END + - cur_dev->vpp_off, - ((framePtr->VPP_hd_start_lines_ & - VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | - ((framePtr->VPP_hd_end_lines_ & - VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); +#ifdef VIDEO_PIP + if (!cur_pipbuf) +#endif + { + VSYNC_WR_MPEG_REG( + VPP_BLEND_VD2_H_START_END + + cur_dev->vpp_off, + ((framePtr->VPP_hd_start_lines_ & + VPP_VD_SIZE_MASK) + << VPP_VD1_START_BIT) | + ((framePtr->VPP_hd_end_lines_ & + VPP_VD_SIZE_MASK) + << VPP_VD1_END_BIT)); + } } + VSYNC_WR_MPEG_REG(VPP_HSC_REGION12_STARTP + cur_dev->vpp_off, (0 << VPP_REGION1_BIT) | @@ -1474,12 +1512,14 @@ static void vd2_settings_h(struct vframe_s *vf) VPP_hd_start_lines_ = 0; VPP_hd_end_lines_ = ((vf->type & VIDTYPE_COMPRESS) ? vf->compWidth : vf->width) - 1; - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_H_START_END + - cur_dev->vpp_off, - ((VPP_hd_start_lines_ & - VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | - ((VPP_hd_end_lines_ & - VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); + + VSYNC_WR_MPEG_REG( + VPP_BLEND_VD2_H_START_END + + cur_dev->vpp_off, + ((VPP_hd_start_lines_ & + VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | + ((VPP_hd_end_lines_ & + VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); } } @@ -1491,6 +1531,7 @@ static void vpp_settings_v(struct vpp_frame_par_s *framePtr) u32 v_phase; u32 v_skip_flag = 0; int x, y, w, h; + struct disp_info_s *layer = &glayer_info[0]; r = framePtr->VPP_vsc_endp - framePtr->VPP_vsc_startp; afbc_enble_flag = 0; @@ -1506,7 +1547,11 @@ static void vpp_settings_v(struct vpp_frame_par_s *framePtr) else { afbc_enble_flag = READ_VCBUS_REG(AFBC_ENABLE) & 0x100; v_phase = vpp_filter->vpp_vsc_start_phase_step; - vpp_get_video_layer_position(&x, &y, &w, &h); + + x = layer->layer_left; + y = layer->layer_top; + w = layer->layer_width; + h = layer->layer_height; if (v_phase * (framePtr->vscale_skip_count + 1) > 0x1000000) { if ((afbc_enble_flag) && (y < 0)) { if ((framePtr->VPP_vsc_endp < 0x250) || @@ -1532,34 +1577,33 @@ static void vpp_settings_v(struct vpp_frame_par_s *framePtr) } } - if (platform_type == 1) { - y_lines = zoom_end_y_lines / (framePtr->vscale_skip_count + 1); - if (process_3d_type & MODE_3D_OUT_TB) { - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END, + y_lines = zoom_end_y_lines / (framePtr->vscale_skip_count + 1); + if (process_3d_type & MODE_3D_OUT_TB) { + VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END, ((zoom_start_y_lines & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | (((y_lines >> 1) & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - VSYNC_WR_MPEG_REG( + VSYNC_WR_MPEG_REG( VPP_BLEND_VD2_V_START_END, ((((y_lines + 1) >> 1) & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | ((y_lines & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } else if (process_3d_type & MODE_3D_OUT_LR) { - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END, + } else if (process_3d_type & MODE_3D_OUT_LR) { + VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END, ((zoom_start_y_lines & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | ((zoom_end_y_lines & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_V_START_END, + VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_V_START_END, ((zoom_start_y_lines & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | ((zoom_end_y_lines & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } else { - if ((framePtr->VPP_post_blend_vd_v_end_ - - framePtr->VPP_post_blend_vd_v_start_ + 1) > - VPP_PREBLEND_VD_V_END_LIMIT) { - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END + + } else { + if ((framePtr->VPP_post_blend_vd_v_end_ - + framePtr->VPP_post_blend_vd_v_start_ + 1) > + VPP_PREBLEND_VD_V_END_LIMIT) { + VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END + cur_dev->vpp_off, ((framePtr->VPP_post_blend_vd_v_start_ & VPP_VD_SIZE_MASK) << @@ -1567,72 +1611,36 @@ static void vpp_settings_v(struct vpp_frame_par_s *framePtr) ((framePtr->VPP_post_blend_vd_v_end_ & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } else { - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END + + } else { + VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END + cur_dev->vpp_off, ((0 & VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | (((VPP_PREBLEND_VD_V_END_LIMIT - 1) & VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } - - if (is_need_framepacking_output()) { - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_V_START_END + - cur_dev->vpp_off, - (((((framePtr->VPP_vd_end_lines_ - - framepacking_blank + 1) / 2) + framepacking_blank) & - VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | - (((framePtr->VPP_vd_end_lines_) & - VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } else { - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_V_START_END + - cur_dev->vpp_off, - ((((framePtr->VPP_vd_end_lines_ + 1) / 2) & - VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | - (((framePtr->VPP_vd_end_lines_) & - VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } - } - } else { - if ((framePtr->VPP_post_blend_vd_v_end_ - - framePtr->VPP_post_blend_vd_v_start_ + 1) > - VPP_PREBLEND_VD_V_END_LIMIT) { - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END + - cur_dev->vpp_off, - ((framePtr->VPP_post_blend_vd_v_start_ - & VPP_VD_SIZE_MASK) << - VPP_VD1_START_BIT) | - ((framePtr->VPP_post_blend_vd_v_end_ & - VPP_VD_SIZE_MASK) - << VPP_VD1_END_BIT)); - } else { - VSYNC_WR_MPEG_REG(VPP_PREBLEND_VD1_V_START_END + - cur_dev->vpp_off, - ((0 & VPP_VD_SIZE_MASK) << - VPP_VD1_START_BIT) | - (((VPP_PREBLEND_VD_V_END_LIMIT - 1) & - VPP_VD_SIZE_MASK) << - VPP_VD1_END_BIT)); - } - if (is_need_framepacking_output()) { - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_V_START_END + - cur_dev->vpp_off, - (((((framePtr->VPP_vd_end_lines_ - +#ifdef VIDEO_PIP + if (!cur_pipbuf) +#endif + { + VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_V_START_END + + cur_dev->vpp_off, + ((((framePtr->VPP_vd_end_lines_ + 1) / 2) & + VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | + (((framePtr->VPP_vd_end_lines_) & + VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); + } + if (is_need_framepacking_output()) { + VSYNC_WR_MPEG_REG( + VPP_BLEND_VD2_V_START_END + + cur_dev->vpp_off, + (((((framePtr->VPP_vd_end_lines_ - framepacking_blank + 1) / 2) + framepacking_blank) & - VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | - (((framePtr->VPP_vd_end_lines_) & - VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } else { - VSYNC_WR_MPEG_REG(VPP_BLEND_VD2_V_START_END + - cur_dev->vpp_off, - ((((framePtr->VPP_vd_end_lines_ + 1) / 2) & - VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | - (((framePtr->VPP_vd_end_lines_) & - VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); - } - + VPP_VD_SIZE_MASK) << VPP_VD1_START_BIT) | + (((framePtr->VPP_vd_end_lines_) & + VPP_VD_SIZE_MASK) << VPP_VD1_END_BIT)); + } } VSYNC_WR_MPEG_REG(VPP_VSC_REGION12_STARTP + cur_dev->vpp_off, 0); VSYNC_WR_MPEG_REG(VPP_VSC_REGION34_STARTP + cur_dev->vpp_off, @@ -1674,15 +1682,19 @@ static void vd2_settings_v(struct vframe_s *vf) } #ifdef TV_3D_FUNCTION_OPEN - static void zoom_get_horz_pos(struct vframe_s *vf, u32 vpp_3d_mode, u32 *ls, u32 *le, u32 *rs, u32 *re) { u32 crop_sx, crop_ex, crop_sy, crop_ey; + struct disp_info_s *layer = &glayer_info[0]; if (!vf) return; - vpp_get_video_source_crop(&crop_sy, &crop_sx, &crop_ey, &crop_ex); + + crop_sy = layer->crop_top; + crop_sx = layer->crop_left; + crop_ey = layer->crop_bottom; + crop_ex = layer->crop_right; switch (vpp_3d_mode) { case VPP_3D_MODE_LR: @@ -1728,8 +1740,12 @@ static void zoom_get_vert_pos(struct vframe_s *vf, u32 vpp_3d_mode, u32 *ls, u32 *le, u32 *rs, u32 *re) { u32 crop_sx, crop_ex, crop_sy, crop_ey, height; + struct disp_info_s *layer = &glayer_info[0]; - vpp_get_video_source_crop(&crop_sy, &crop_sx, &crop_ey, &crop_ex); + crop_sy = layer->crop_top; + crop_sx = layer->crop_left; + crop_ey = layer->crop_bottom; + crop_ex = layer->crop_right; if (vf->type & VIDTYPE_INTERLACE) height = vf->height >> 1; @@ -1937,32 +1953,37 @@ static void zoom_display_horz(struct vframe_s *vf, int hscale) ((r_aligned - l_aligned) << 16)); } - VSYNC_WR_MPEG_REG( - VD2_IF0_LUMA_X0 + cur_dev->viu_off, - (ls << VDIF_PIC_START_BIT) | - (le << VDIF_PIC_END_BIT)); +#ifdef VIDEO_PIP + if (!cur_pipbuf) +#endif + { + VSYNC_WR_MPEG_REG( + VD2_IF0_LUMA_X0 + cur_dev->viu_off, + (ls << VDIF_PIC_START_BIT) | + (le << VDIF_PIC_END_BIT)); - VSYNC_WR_MPEG_REG( - VD2_IF0_CHROMA_X0 + cur_dev->viu_off, - (ls / 2 << VDIF_PIC_START_BIT) | - (le / 2 << VDIF_PIC_END_BIT)); + VSYNC_WR_MPEG_REG( + VD2_IF0_CHROMA_X0 + cur_dev->viu_off, + (ls / 2 << VDIF_PIC_START_BIT) | + (le / 2 << VDIF_PIC_END_BIT)); - VSYNC_WR_MPEG_REG( - VD2_IF0_LUMA_X1 + cur_dev->viu_off, - (rs << VDIF_PIC_START_BIT) | - (re << VDIF_PIC_END_BIT)); + VSYNC_WR_MPEG_REG( + VD2_IF0_LUMA_X1 + cur_dev->viu_off, + (rs << VDIF_PIC_START_BIT) | + (re << VDIF_PIC_END_BIT)); - VSYNC_WR_MPEG_REG( - VD2_IF0_CHROMA_X1 + cur_dev->viu_off, - (rs / 2 << VDIF_PIC_START_BIT) | - (re / 2 << VDIF_PIC_END_BIT)); + VSYNC_WR_MPEG_REG( + VD2_IF0_CHROMA_X1 + cur_dev->viu_off, + (rs / 2 << VDIF_PIC_START_BIT) | + (re / 2 << VDIF_PIC_END_BIT)); - VSYNC_WR_MPEG_REG( - VIU_VD2_FMT_W + cur_dev->viu_off, - (((zoom_end_x_lines - zoom_start_x_lines + - 1) >> hscale) << VD1_FMT_LUMA_WIDTH_BIT) | - (((zoom_end_x_lines / 2 - zoom_start_x_lines / 2 + - 1) >> hscale) << VD1_FMT_CHROMA_WIDTH_BIT)); + VSYNC_WR_MPEG_REG( + VIU_VD2_FMT_W + cur_dev->viu_off, + (((zoom_end_x_lines - zoom_start_x_lines + + 1) >> hscale) << VD1_FMT_LUMA_WIDTH_BIT) | + (((zoom_end_x_lines / 2 - zoom_start_x_lines / 2 + + 1) >> hscale) << VD1_FMT_CHROMA_WIDTH_BIT)); + } } static void vd2_zoom_display_horz(struct vframe_s *vf, int hscale) @@ -1977,7 +1998,7 @@ static void vd2_zoom_display_horz(struct vframe_s *vf, int hscale) if (get_cpu_type() >= MESON_CPU_MAJOR_ID_GXBB) { int l_aligned; int r_aligned; - int h_skip = cur_frame_par->hscale_skip_count + 1; + int h_skip = hscale + 1; int c_skip = 2; /* After TL1, afbc supports 420/422/444*/ @@ -2059,26 +2080,14 @@ static void zoom_display_vert(struct vframe_s *vf) u32 ls, le, rs, re; - /*if (platform_type == 1) {*/ - if (process_3d_type & MODE_3D_ENABLE) { - zoom_get_vert_pos(vf, - cur_frame_par->vpp_3d_mode, &ls, - &le, &rs, &re); - } else { - ls = rs = zoom_start_y_lines; - le = re = zoom_end_y_lines; - } - /*} else { - if (process_3d_type & MODE_3D_ENABLE) { - zoom_get_vert_pos(cur_dispbuf, - cur_frame_par->vpp_3d_mode, &ls, - &le, &rs, &re); - } else { - ls = rs = zoom_start_y_lines; - le = re = zoom_end_y_lines; - } + if (process_3d_type & MODE_3D_ENABLE) { + zoom_get_vert_pos(vf, + cur_frame_par->vpp_3d_mode, &ls, + &le, &rs, &re); + } else { + ls = rs = zoom_start_y_lines; + le = re = zoom_end_y_lines; } -*/ if ((vf) && (vf->type & VIDTYPE_MVC)) { if (is_need_framepacking_output()) { @@ -2142,8 +2151,11 @@ static void zoom_display_vert(struct vframe_s *vf) VD1_IF0_CHROMA_Y1 + cur_dev->viu_off, ((rs / 2) << VDIF_PIC_START_BIT) | ((re / 2) << VDIF_PIC_END_BIT)); - if (platform_type == 1) { - /* vd2 */ + +#ifdef VIDEO_PIP + if (!cur_pipbuf) +#endif + { VSYNC_WR_MPEG_REG( VD2_IF0_LUMA_Y0 + cur_dev->viu_off, (ls << VDIF_PIC_START_BIT) | @@ -2214,7 +2226,7 @@ static void zoom_display_vert(struct vframe_s *vf) } } -static void vd2_zoom_display_vert(struct vframe_s *vf) +static void vd2_zoom_display_vert(struct vframe_s *vf, int vscale) { u32 ls, le, rs, re; @@ -2248,7 +2260,7 @@ static void vd2_zoom_display_vert(struct vframe_s *vf) int b_aligned; int ori_t_aligned; int ori_b_aligned; - int v_skip = cur_frame_par->vscale_skip_count + 1; + int v_skip = vscale + 1; int c_skip = 2; /* After TL1, afbc supports 420/422/444*/ @@ -2454,29 +2466,983 @@ static void vsync_video_pattern(void) } #endif -/* for sdr/hdr/single dv switch with dual dv */ -static u32 last_el_status; -/* for dual dv switch with different el size */ -static u32 last_el_w; -bool has_enhanced_layer(struct vframe_s *vf) +static inline void vd1_path_select(bool afbc) { - struct provider_aux_req_s req; - - if (!vf) - return 0; - if (vf->source_type != VFRAME_SOURCE_TYPE_OTHERS) - return 0; - if (!is_dolby_vision_on()) - return 0; + u32 misc_off = cur_dev->vpp_off; - req.vf = vf; - req.bot_flag = 0; - req.aux_buf = NULL; - req.aux_size = 0; - req.dv_enhance_exist = 0; - vf_notify_provider_by_name("dvbldec", - VFRAME_EVENT_RECEIVER_GET_AUX_DATA, - (void *)&req); + if (!legacy_vpp) { + VSYNC_WR_MPEG_REG_BITS( + VD1_AFBCD0_MISC_CTRL, + /* go field sel */ + (0 << 20) | + /* linebuffer en */ + (0 << 16) | + /* vd1 -> dolby -> vpp top */ + (0 << 14) | + /* axi sel: vd1 mif or afbc */ + ((afbc ? 1 : 0) << 12) | + /* data sel: vd1 & afbc0 (not osd4) */ + (0 << 11) | + /* data sel: afbc0 or vd1 */ + ((afbc ? 1 : 0) << 10) | + /* afbc0 to vd1 (not di) */ + (0 << 9) | + /* vd1 mif to vpp (not di) */ + (0 << 8) | + /* afbc0 gclk ctrl */ + (0 << 0), + 0, 22); + if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) + VSYNC_WR_MPEG_REG_BITS( + VD1_AFBCD0_MISC_CTRL, + /* Vd1_afbc0_mem_sel */ + (afbc ? 1 : 0), + 22, 1); + +#ifdef CONFIG_AMLOGIC_MEDIA_DEINTERLACE + if (!cpu_after_eq(MESON_CPU_MAJOR_ID_G12A)) + return; + if ((DI_POST_REG_RD(DI_POST_CTRL) & 0x100) != 0) { + /* check di_vpp_out_en bit */ + VSYNC_WR_MPEG_REG_BITS( + VD1_AFBCD0_MISC_CTRL, + /* vd1 mif to di */ + 1, + 8, 2); + VSYNC_WR_MPEG_REG_BITS( + VD1_AFBCD0_MISC_CTRL, + /* go field select di post */ + 1, + 20, 2); + } +#endif + } else { +#ifdef CONFIG_AMLOGIC_MEDIA_DEINTERLACE + if ((DI_POST_REG_RD(DI_POST_CTRL) & 0x100) == 0) + /* mif sel */ +#endif + VSYNC_WR_MPEG_REG_BITS( + VIU_MISC_CTRL0 + misc_off, + 0, 16, 3); + VSYNC_WR_MPEG_REG_BITS( + VIU_MISC_CTRL0 + misc_off, + (afbc ? 1 : 0), 20, 1); + } +} + +static inline void vd2_path_select(bool afbc) +{ + u32 misc_off = cur_dev->vpp_off; + + if (!legacy_vpp) { + VSYNC_WR_MPEG_REG_BITS( + VD2_AFBCD1_MISC_CTRL, + /* go field sel */ + (0 << 20) | + /* linebuffer en */ + (0 << 16) | + /* TODO: vd2 -> dolby -> vpp top ?? */ + (0 << 14) | + /* axi sel: vd2 mif */ + ((afbc ? 1 : 0) << 12) | + /* data sel: vd2 & afbc1 (not osd4) */ + (0 << 11) | + /* data sel: afbc1 */ + ((afbc ? 1 : 0) << 10) | + /* afbc1 to vd2 (not di) */ + (0 << 9) | + /* vd2 mif to vpp (not di) */ + (0 << 8) | + /* afbc1 gclk ctrl */ + (0 << 0), + 0, 22); + if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) + VSYNC_WR_MPEG_REG_BITS( + VD2_AFBCD1_MISC_CTRL, + /* Vd2_afbc0_mem_sel */ + (afbc ? 1 : 0), + 22, 1); + } else { + VSYNC_WR_MPEG_REG_BITS( + VIU_MISC_CTRL1 + misc_off, + (afbc ? 2 : 0), 0, 2); + } +} + +#ifdef VIDEO_PIP +s32 config_vd_pps( + u8 layer_id, + struct vpp_frame_par_s *cur_frame_par, + struct scaler_setting_s *setting, + const struct vinfo_s *info) +{ + struct vppfilter_mode_s *vpp_filter; + + if (!cur_frame_par || !info || !setting) + return -1; + + vpp_filter = &cur_frame_par->vpp_filter; + setting->frame_par = cur_frame_par; + setting->id = layer_id; + setting->misc_reg_offt = 0; + /* enable pps as default */ + setting->sc_top_enable = true; + setting->sc_h_enable = true; + setting->sc_v_enable = true; + + if ((vpp_filter->vpp_hsc_start_phase_step == 0x1000000) + && (vpp_filter->vpp_vsc_start_phase_step == 0x1000000) + && (vpp_filter->vpp_hsc_start_phase_step == + vpp_filter->vpp_hf_start_phase_step) + && !vpp_filter->vpp_pre_vsc_en + && !vpp_filter->vpp_pre_hsc_en + && !cur_frame_par->supsc0_enable + && !cur_frame_par->supsc1_enable + && bypass_pps) + setting->sc_top_enable = false; + + /* old chip: vd2 has no pps */ + if ((legacy_vpp || is_meson_tl1_cpu()) + && (setting->id != 0)) + setting->sc_top_enable = false; + + setting->vinfo_width = info->width; + setting->vinfo_height = info->height; + return 0; +} + +static inline void vd2_scaler_setting( + struct scaler_setting_s *setting) +{ + u32 misc_off, i; + u32 r1, r2, r3; + struct vpp_frame_par_s *frame_par; + struct vppfilter_mode_s *vpp_filter; + + if (legacy_vpp || !setting + || !setting->frame_par + || is_meson_tl1_cpu()) + return; + + frame_par = setting->frame_par; + misc_off = setting->misc_reg_offt; + vpp_filter = &frame_par->vpp_filter; + + if (setting->sc_top_enable) { + u32 sc_misc_val; + + sc_misc_val = VPP_SC_TOP_EN | VPP_SC_V1OUT_EN; + if (setting->sc_h_enable) { + sc_misc_val |= (((vpp_filter->vpp_pre_hsc_en & 1) + << VPP_SC_PREHORZ_EN_BIT) + | VPP_SC_HORZ_EN); + sc_misc_val |= ((vpp_filter->vpp_horz_coeff[0] & 7) + << VPP_SC_HBANK_LENGTH_BIT); + } + + if (setting->sc_v_enable) { + sc_misc_val |= (((vpp_filter->vpp_pre_vsc_en & 1) + << VPP_SC_PREVERT_EN_BIT) + | VPP_SC_VERT_EN); + sc_misc_val |= ((vpp_filter->vpp_pre_vsc_en & 1) + << VPP_LINE_BUFFER_EN_BIT); + sc_misc_val |= ((vpp_filter->vpp_vert_coeff[0] & 7) + << VPP_SC_VBANK_LENGTH_BIT); + } + VSYNC_WR_MPEG_REG( + VD2_SC_MISC + misc_off, + sc_misc_val); + } else { + setting->sc_v_enable = false; + setting->sc_h_enable = false; + VSYNC_WR_MPEG_REG_BITS( + VD2_SC_MISC + misc_off, + 0, VPP_SC_TOP_EN_BIT, + VPP_SC_TOP_EN_WID); + } + + /* horitontal filter settings */ + if (setting->sc_h_enable) { + if (vpp_filter->vpp_horz_coeff[1] & 0x8000) { + VSYNC_WR_MPEG_REG( + VD2_SCALE_COEF_IDX + misc_off, + VPP_COEF_HORZ | VPP_COEF_9BIT); + } else { + VSYNC_WR_MPEG_REG( + VD2_SCALE_COEF_IDX + misc_off, + VPP_COEF_HORZ); + } + for (i = 0; i < + (vpp_filter->vpp_horz_coeff[1] & 0xff); i++) { + VSYNC_WR_MPEG_REG( + VD2_SCALE_COEF + misc_off, + vpp_filter->vpp_horz_coeff[i + 2]); + } + r1 = frame_par->VPP_hsc_linear_startp + - frame_par->VPP_hsc_startp; + r2 = frame_par->VPP_hsc_linear_endp + - frame_par->VPP_hsc_startp; + r3 = frame_par->VPP_hsc_endp + - frame_par->VPP_hsc_startp; + + VSYNC_WR_MPEG_REG_BITS( + VD2_HSC_PHASE_CTRL + misc_off, + frame_par->VPP_hf_ini_phase_, + VPP_HSC_TOP_INI_PHASE_BIT, + VPP_HSC_TOP_INI_PHASE_WID); + + VSYNC_WR_MPEG_REG( + VD2_HSC_REGION12_STARTP + misc_off, + (0 << VPP_REGION1_BIT) | + ((r1 & VPP_REGION_MASK) + << VPP_REGION2_BIT)); + VSYNC_WR_MPEG_REG( + VD2_HSC_REGION34_STARTP + misc_off, + ((r2 & VPP_REGION_MASK) + << VPP_REGION3_BIT) | + ((r3 & VPP_REGION_MASK) + << VPP_REGION4_BIT)); + VSYNC_WR_MPEG_REG( + VD2_HSC_REGION4_ENDP + misc_off, r3); + + VSYNC_WR_MPEG_REG( + VD2_HSC_START_PHASE_STEP + misc_off, + vpp_filter->vpp_hf_start_phase_step); + + VSYNC_WR_MPEG_REG( + VD2_HSC_REGION1_PHASE_SLOPE + misc_off, + vpp_filter->vpp_hf_start_phase_slope); + + VSYNC_WR_MPEG_REG( + VD2_HSC_REGION3_PHASE_SLOPE + misc_off, + vpp_filter->vpp_hf_end_phase_slope); + } + + /* vertical filter settings */ + if (setting->sc_v_enable) { + VSYNC_WR_MPEG_REG_BITS( + VD2_VSC_PHASE_CTRL + misc_off, + (vpp_filter->vpp_vert_coeff[0] == 2) ? 1 : 0, + VPP_PHASECTL_DOUBLELINE_BIT, + VPP_PHASECTL_DOUBLELINE_WID); + VSYNC_WR_MPEG_REG( + VD2_SCALE_COEF_IDX + misc_off, + VPP_COEF_VERT); + for (i = 0; i < vpp_filter->vpp_vert_coeff[1]; i++) { + VSYNC_WR_MPEG_REG( + VD2_SCALE_COEF + misc_off, + vpp_filter->vpp_vert_coeff[i + 2]); + } + + /* vertical chroma filter settings */ + if (vpp_filter->vpp_vert_chroma_filter_en) { + const u32 *pCoeff = + vpp_filter->vpp_vert_chroma_coeff; + VSYNC_WR_MPEG_REG( + VD2_SCALE_COEF_IDX + misc_off, + VPP_COEF_VERT_CHROMA + |VPP_COEF_SEP_EN); + for (i = 0; i < pCoeff[1]; i++) + VSYNC_WR_MPEG_REG( + VD2_SCALE_COEF + misc_off, + pCoeff[i + 2]); + } + + r1 = frame_par->VPP_vsc_endp + - frame_par->VPP_vsc_startp; + VSYNC_WR_MPEG_REG( + VD2_VSC_REGION12_STARTP + misc_off, 0); + + VSYNC_WR_MPEG_REG( + VD2_VSC_REGION34_STARTP + misc_off, + ((r1 & VPP_REGION_MASK) + << VPP_REGION3_BIT) | + ((r1 & VPP_REGION_MASK) + << VPP_REGION4_BIT)); + + VSYNC_WR_MPEG_REG( + VD2_VSC_REGION4_ENDP + misc_off, r1); + + VSYNC_WR_MPEG_REG( + VD2_VSC_START_PHASE_STEP + misc_off, + vpp_filter->vpp_vsc_start_phase_step); + } + + VSYNC_WR_MPEG_REG( + VPP_VD2_HDR_IN_SIZE + misc_off, + (frame_par->VPP_pic_in_height_ << 16) + | frame_par->VPP_line_in_length_); +} + +s32 config_vd_blend( + u8 layer_id, + struct vpp_frame_par_s *cur_frame_par, + struct vframe_s *vf, + u32 layer_alpha, + struct blend_setting_s *setting) +{ + /* u32 type = 0; */ + u32 vskip, hskip; + + if (!cur_frame_par || !setting || !vf) + return -1; + + setting->frame_par = cur_frame_par; + setting->id = layer_id; + setting->misc_reg_offt = 0; + + setting->layer_alpha = layer_alpha; + setting->preblend_h_start = 0; + setting->preblend_h_end = 4096; + if ((cur_frame_par->VPP_post_blend_vd_v_end_ - + cur_frame_par->VPP_post_blend_vd_v_start_ + 1) + > VPP_PREBLEND_VD_V_END_LIMIT) { + setting->preblend_v_start = + cur_frame_par->VPP_post_blend_vd_v_start_; + setting->preblend_v_end = + cur_frame_par->VPP_post_blend_vd_v_end_; + } else { + setting->preblend_v_start = 0; + setting->preblend_v_end = + VPP_PREBLEND_VD_V_END_LIMIT - 1; + } + + setting->preblend_h_size = + cur_frame_par->VPP_line_in_length_; + + /* old chip, vd2 has no scaler, so only can use mif setting */ + if ((setting->id != 0) && + (legacy_vpp || is_meson_tl1_cpu())) { + vskip = cur_frame_par->vscale_skip_count; + hskip = cur_frame_par->hscale_skip_count; + + setting->postblend_h_start = + cur_frame_par->VPP_hd_start_lines_; + setting->postblend_h_end = + cur_frame_par->VPP_hd_start_lines_ + + (cur_frame_par->VPP_line_in_length_ >> hskip) - 1; + setting->postblend_v_start = + cur_frame_par->VPP_vd_start_lines_; + setting->postblend_v_end = + cur_frame_par->VPP_vd_start_lines_ + + (cur_frame_par->VPP_pic_in_height_ >> vskip) - 1; + setting->postblend_h_size = + cur_frame_par->VPP_post_blend_h_size_; + } else { + setting->postblend_h_start = + cur_frame_par->VPP_hsc_startp; + setting->postblend_h_end = + cur_frame_par->VPP_hsc_endp; + setting->postblend_v_start = + cur_frame_par->VPP_vsc_startp; + setting->postblend_v_end = + cur_frame_par->VPP_vsc_endp; + setting->postblend_h_size = + cur_frame_par->VPP_post_blend_h_size_; + } + + if (!legacy_vpp) { + u32 temp_h = cur_frame_par->VPP_pic_in_height_; + + temp_h <<= 16; + setting->preblend_h_size |= temp_h; + + temp_h = + cur_frame_par->VPP_post_blend_vd_v_end_ + 1; + temp_h <<= 16; + setting->postblend_h_size |= temp_h; + } + +#if 0 + /* TODO: need remove this work around check for afbc */ + type = vf->type; + if (cur_frame_par->nocomp) + type &= ~VIDTYPE_COMPRESS; + + if (type & VIDTYPE_COMPRESS) { + u32 v_phase; + struct vppfilter_mode_s *vpp_filter = + &cur_frame_par->vpp_filter; + v_phase = vpp_filter->vpp_vsc_start_phase_step; + v_phase *= (cur_frame_par->vscale_skip_count + 1); + if ((v_phase > 0x1000000) && + (layer->disp_info.layer_top < 0)) { + if ((cur_frame_par->VPP_vsc_endp > 0x6) && + ((cur_frame_par->VPP_vsc_endp < 0x250) + || (cur_frame_par->VPP_vsc_endp < + cur_frame_par->VPP_post_blend_vd_v_end_/2))) { + setting->postblend_v_end -= 6; + } + } + } +#endif + return 0; +} + +static inline void vd2_vpp_blend_setting( + struct blend_setting_s *setting) +{ + u32 misc_off; + u32 vd_size_mask = VPP_VD_SIZE_MASK; + + if (!setting) + return; + + /* g12a change to 13 bits */ + if (!legacy_vpp) + vd_size_mask = 0x1fff; + + misc_off = 0; + + /* vd2 preblend size should be same postblend size */ + /* preblend setting */ + VSYNC_WR_MPEG_REG( + VPP_BLEND_VD2_H_START_END + misc_off, + ((setting->postblend_h_start & vd_size_mask) + << VPP_VD1_START_BIT) | + ((setting->postblend_h_end & vd_size_mask) + << VPP_VD1_END_BIT)); + + VSYNC_WR_MPEG_REG( + VPP_BLEND_VD2_V_START_END + misc_off, + ((setting->postblend_v_start & vd_size_mask) + << VPP_VD1_START_BIT) | + ((setting->postblend_v_end & vd_size_mask) + << VPP_VD1_END_BIT)); +} + +static inline void proc_vd2_vsc_phase_per_vsync( + struct vpp_frame_par_s *frame_par, + struct vframe_s *vf, + u32 vout_type) +{ + struct f2v_vphase_s *vphase; + u32 misc_off, vin_type; + struct vppfilter_mode_s *vpp_filter; + + if (legacy_vpp || is_meson_tl1_cpu() + || !frame_par || !vf) + return; + + vpp_filter = &frame_par->vpp_filter; + misc_off = 0; + vin_type = vf->type & VIDTYPE_TYPEMASK; + /* vertical phase */ + vphase = &frame_par->VPP_vf_ini_phase_ + [vpp_phase_table[vin_type] + [vout_type]]; + VSYNC_WR_MPEG_REG( + VD2_VSC_INI_PHASE + misc_off, + ((u32) (vphase->phase) << 8)); + + if (vphase->repeat_skip >= 0) { + /* skip lines */ + VSYNC_WR_MPEG_REG_BITS( + VD2_VSC_PHASE_CTRL + misc_off, + skip_tab[vphase->repeat_skip], + VPP_PHASECTL_INIRCVNUMT_BIT, + VPP_PHASECTL_INIRCVNUM_WID + + VPP_PHASECTL_INIRPTNUM_WID); + } else { + /* repeat first line */ + VSYNC_WR_MPEG_REG_BITS( + VD2_VSC_PHASE_CTRL + misc_off, + 4, + VPP_PHASECTL_INIRCVNUMT_BIT, + VPP_PHASECTL_INIRCVNUM_WID); + VSYNC_WR_MPEG_REG_BITS( + VD2_VSC_PHASE_CTRL + misc_off, + 1 - vphase->repeat_skip, + VPP_PHASECTL_INIRPTNUMT_BIT, + VPP_PHASECTL_INIRPTNUM_WID); + } + + VSYNC_WR_MPEG_REG_BITS( + VD2_VSC_PHASE_CTRL + misc_off, + (vpp_filter->vpp_vert_coeff[0] == 2) ? 1 : 0, + VPP_PHASECTL_DOUBLELINE_BIT, + VPP_PHASECTL_DOUBLELINE_WID); +} + +static void pip_toggle_frame(struct vframe_s *vf) +{ + u32 first_picture = 0; + + if (vf == NULL) + return; + + ori2_start_x_lines = 0; + ori2_end_x_lines = ((vf->type & VIDTYPE_COMPRESS) ? + vf->compWidth : vf->width) - 1; + ori2_start_y_lines = 0; + ori2_end_y_lines = ((vf->type & VIDTYPE_COMPRESS) ? + vf->compHeight : vf->height) - 1; + + if (debug_flag & DEBUG_FLAG_PRINT_TOGGLE_FRAME) + pr_info("%s()\n", __func__); + + if ((vf->width == 0) && (vf->height == 0)) { + amlog_level(LOG_LEVEL_ERROR, + "Video: invalid frame dimension\n"); + return; + } + if (cur_pipbuf + && (cur_pipbuf != &local_pip) + && (cur_pipbuf != vf)) { + pip_frame_count++; + if (pip_frame_count == 1) + first_picture = 1; +#ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA + if (is_vsync_rdma_enable()) { + if (pip_rdma_buf == cur_pipbuf) + pipbuf_to_put = cur_pipbuf; + else + pip_vf_put(cur_pipbuf); + } else { + if (pipbuf_to_put) { + pip_vf_put( + pipbuf_to_put); + pipbuf_to_put = NULL; + } + pip_vf_put(cur_pipbuf); + } +#else + pip_vf_put(cur_pipbuf); +#endif + } else if (!cur_pipbuf + || (cur_pipbuf == &local_pip)) + first_picture = 1; + + /* switch buffer */ + if (vf->type & VIDTYPE_COMPRESS) { + VSYNC_WR_MPEG_REG(VD2_AFBC_HEAD_BADDR, + vf->compHeadAddr>>4); + VSYNC_WR_MPEG_REG(VD2_AFBC_BODY_BADDR, + vf->compBodyAddr>>4); + } + if (vf->canvas0Addr != 0) { +#ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA + if (vf->canvas0Addr != (u32)-1) { + canvas_copy(vf->canvas0Addr & 0xff, + disp_canvas_index[pip_rdma_canvas_id][3]); + canvas_copy((vf->canvas0Addr >> 8) & 0xff, + disp_canvas_index[pip_rdma_canvas_id][4]); + canvas_copy((vf->canvas0Addr >> 16) & 0xff, + disp_canvas_index[pip_rdma_canvas_id][5]); + } else { + vframe_canvas_set(&vf->canvas0_config[0], + vf->plane_num, + &disp_canvas_index[pip_rdma_canvas_id][3]); + } + + VSYNC_WR_MPEG_REG( + VD2_IF0_CANVAS0 + cur_dev->viu_off, + disp_canvas[pip_rdma_canvas_id][1]); + + pip_next_rdma_canvas_id = pip_rdma_canvas_id ? 0 : 1; +#endif + } + + if (pip_property_changed) { + first_picture = 1; + pip_property_changed = 0; + } + if (cur_pipbuf != vf) + vf->type_backup = vf->type; + + /* enable new config on the new frames */ + if ((first_picture) || (cur_pipbuf && + ((cur_pipbuf->bufWidth != vf->bufWidth) || + (cur_pipbuf->width != vf->width) || + (cur_pipbuf->height != vf->height) || + (cur_pipbuf->bitdepth != vf->bitdepth) || + (cur_pipbuf->trans_fmt != vf->trans_fmt) || + (cur_pipbuf->ratio_control != vf->ratio_control) || + ((cur_pipbuf->type_backup & VIDTYPE_INTERLACE) != + (vf->type_backup & VIDTYPE_INTERLACE)) || + (cur_pipbuf->type != vf->type)))) { + int iret; + + /* apply new vpp settings */ + nextpip_frame_par = + (&pip_frame_parms[0] == nextpip_frame_par) ? + &pip_frame_parms[1] : &pip_frame_parms[0]; + + update_layer_info(1); + if (legacy_vpp || is_meson_tl1_cpu()) + iret = vpp_set_filters_no_scaler( + &glayer_info[1], vf, + nextpip_frame_par, vinfo); + else + iret = vpp_set_filters( + &glayer_info[1], vf, + nextpip_frame_par, vinfo, + true); + + if (iret == VppFilter_Success_and_Changed) + pip_property_changed = 1; + + pip_frame_ready_to_set = 1; + } + + if (((vf->type & VIDTYPE_NO_VIDEO_ENABLE) == 0) && + (!pip_property_changed || (vf != cur_pipbuf))) { + if (disable_videopip == VIDEO_DISABLE_FORNEXT) { + EnableVideoLayer2(); + disable_videopip = VIDEO_DISABLE_NONE; + } + if (first_picture && + (disable_videopip != + VIDEO_DISABLE_NORMAL)) { + EnableVideoLayer2(); + } + } + cur_pipbuf = vf; + if (first_picture) + pip_frame_ready_to_set = 1; +} + +static void pip_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) +{ + u32 r; + u32 vphase, vini_phase; + u32 pat, loop; + static const u32 vpat[MAX_VSKIP_COUNT + 1] = { + 0, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; + u32 u, v; + u32 type, bit_mode = 0; + + if (!vf || !frame_par) { + pr_err("pip_set_dcu vf is NULL\n"); + return; + } + + type = vf->type; + pr_debug("pip_set_dcu %p, type:0x%x\n", vf, type); + + if (frame_par->nocomp) + type &= ~VIDTYPE_COMPRESS; + + if (type & VIDTYPE_COMPRESS) { + r = (3 << 24) | + (vpp_hold_line << 16) | + ((legacy_vpp ? 1 : 2) << 14) | /* burst1 */ + (vf->bitdepth & BITDEPTH_MASK); + + if (frame_par->hscale_skip_count) + r |= 0x33; + if (frame_par->vscale_skip_count) + r |= 0xcc; + +#ifdef TV_REVERSE + if (reverse) + r |= (1<<26) | (1<<27); +#endif + if (vf->bitdepth & BITDEPTH_SAVING_MODE) + r |= (1<<28); /* mem_saving_mode */ + if (type & VIDTYPE_SCATTER) + r |= (1<<29); + VSYNC_WR_MPEG_REG(VD2_AFBC_MODE, r); + + r = 0x1700; + if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) { + if (vf && (vf->source_type + != VFRAME_SOURCE_TYPE_HDMI)) + r |= (1 << 19); /* dos_uncomp */ + } + VSYNC_WR_MPEG_REG(VD2_AFBC_ENABLE, r); + + r = 0x100; + if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) { + if (type & VIDTYPE_VIU_444) + r |= 0; + else if (type & VIDTYPE_VIU_422) + r |= (1 << 12); + else + r |= (2 << 12); + } + VSYNC_WR_MPEG_REG(VD2_AFBC_CONV_CTRL, r); + + u = (vf->bitdepth >> (BITDEPTH_U_SHIFT)) & 0x3; + v = (vf->bitdepth >> (BITDEPTH_V_SHIFT)) & 0x3; + VSYNC_WR_MPEG_REG(VD2_AFBC_DEC_DEF_COLOR, + 0x3FF00000 | /*Y,bit20+*/ + 0x80 << (u + 10) | + 0x80 << v); + /* chroma formatter */ + r = HFORMATTER_EN | + (0x8 << VFORMATTER_PHASE_BIT) | + VFORMATTER_EN; +#if 0 /* def CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION */ + if (is_meson_txlx_package_962X() + && !is_dolby_vision_stb_mode() + && is_dolby_vision_on()) { + r |= HFORMATTER_REPEAT | + HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_ALWAYS_RPT | + (0 << VFORMATTER_INIPHASE_BIT) | + (0x8 << VFORMATTER_PHASE_BIT) | + VFORMATTER_EN; + } else +#endif + if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) { + r = HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_RPTLINE0_EN | + (0x8 << VFORMATTER_PHASE_BIT) | + VFORMATTER_EN; + + if (is_dolby_vision_on()) + r |= HFORMATTER_REPEAT | + (0xc << VFORMATTER_INIPHASE_BIT); + else + r |= HFORMATTER_RRT_PIXEL0 | + (0 << VFORMATTER_INIPHASE_BIT); + + if (type & VIDTYPE_VIU_444) { + r &= ~HFORMATTER_EN; + r &= ~VFORMATTER_EN; + r &= ~HFORMATTER_YC_RATIO_2_1; + } else if (type & VIDTYPE_VIU_422) { + r &= ~VFORMATTER_EN; + } + } else { + r = HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_RPTLINE0_EN | + (0x8 << VFORMATTER_PHASE_BIT) | + VFORMATTER_EN; + if (is_dolby_vision_on()) + r |= HFORMATTER_REPEAT | + (0xc << VFORMATTER_INIPHASE_BIT); + else + r |= HFORMATTER_RRT_PIXEL0 | + (0 << VFORMATTER_INIPHASE_BIT); + } + VSYNC_WR_MPEG_REG(VD2_AFBC_VD_CFMT_CTRL, r); + + if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) { + if (type & VIDTYPE_COMPRESS_LOSS) + VSYNC_WR_MPEG_REG( + VD2_AFBCDEC_IQUANT_ENABLE, + ((1 << 11) | + (1 << 10) | + (1 << 4) | + (1 << 0))); + else + VSYNC_WR_MPEG_REG( + VD2_AFBCDEC_IQUANT_ENABLE, 0); + } + + vd2_path_select(true); + VSYNC_WR_MPEG_REG(VD2_IF0_GEN_REG + + cur_dev->viu_off, 0); + return; + } + + if ((vf->bitdepth & BITDEPTH_Y10) && + (!frame_par->nocomp)) { + if (vf->type & VIDTYPE_VIU_444) { + bit_mode = 2; + } else { + if (vf->bitdepth & FULL_PACK_422_MODE) + bit_mode = 3; + else + bit_mode = 1; + } + } else { + bit_mode = 0; + } + vd2_path_select(false); + if (!legacy_vpp) { + VSYNC_WR_MPEG_REG_BITS( + G12_VD2_IF0_GEN_REG3, + (bit_mode & 0x3), 8, 2); + } else { + VSYNC_WR_MPEG_REG_BITS( + VD2_IF0_GEN_REG3 + cur_dev->viu_off, + (bit_mode&0x3), 8, 2); + } + if (!(VSYNC_RD_MPEG_REG(VIU_MISC_CTRL1) & 0x1)) + VSYNC_WR_MPEG_REG(VD2_AFBC_ENABLE, 0); + if (type & VIDTYPE_VIU_NV21) + VSYNC_WR_MPEG_REG_BITS( + VD2_IF0_GEN_REG2 + + cur_dev->viu_off, 1, 0, 1); + else + VSYNC_WR_MPEG_REG_BITS( + VD2_IF0_GEN_REG2 + + cur_dev->viu_off, 0, 0, 1); + + r = (3 << VDIF_URGENT_BIT) | + (vpp_hold_line << VDIF_HOLD_LINES_BIT) | + VDIF_FORMAT_SPLIT | + VDIF_CHRO_RPT_LAST | VDIF_ENABLE; + /* | VDIF_RESET_ON_GO_FIELD;*/ + if (debug_flag & DEBUG_FLAG_GOFIELD_MANUL) + r |= 1<<7; /*for manul triggle gofiled.*/ + + if ((type & VIDTYPE_VIU_SINGLE_PLANE) == 0) + r |= VDIF_SEPARATE_EN; + else { + if (type & VIDTYPE_VIU_422) + r |= VDIF_FORMAT_422; + else { + r |= VDIF_FORMAT_RGB888_YUV444 | + VDIF_DEMUX_MODE_RGB_444; + } + } + + if (frame_par->hscale_skip_count) + r |= VDIF_CHROMA_HZ_AVG | VDIF_LUMA_HZ_AVG; + + VSYNC_WR_MPEG_REG(VD2_IF0_GEN_REG + cur_dev->viu_off, r); + +#ifdef TV_REVERSE + if (reverse) { + VSYNC_WR_MPEG_REG_BITS((VD2_IF0_GEN_REG2 + + cur_dev->viu_off), 0xf, 2, 4); + } else { + VSYNC_WR_MPEG_REG_BITS((VD2_IF0_GEN_REG2 + + cur_dev->viu_off), 0, 2, 4); + } +#endif + + /* chroma formatter */ + if (type & VIDTYPE_VIU_444) { + VSYNC_WR_MPEG_REG( + VIU_VD2_FMT_CTRL + cur_dev->viu_off, + HFORMATTER_YC_RATIO_1_1); + } else if (type & VIDTYPE_VIU_FIELD) { + vini_phase = 0xc << VFORMATTER_INIPHASE_BIT; + vphase = ((type & VIDTYPE_VIU_422) ? 0x10 : 0x08) + << VFORMATTER_PHASE_BIT; + if (is_meson_gxtvbb_cpu() || is_meson_txl_cpu() || + is_meson_txlx_cpu()) { + if ((vf->width >= 3840) && + (vf->height >= 2160) && + (type & VIDTYPE_VIU_422)) { + VSYNC_WR_MPEG_REG( + VIU_VD2_FMT_CTRL + cur_dev->viu_off, + HFORMATTER_RRT_PIXEL0 | + HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_RPTLINE0_EN | + vini_phase | vphase); + } else { + VSYNC_WR_MPEG_REG( + VIU_VD2_FMT_CTRL + cur_dev->viu_off, + HFORMATTER_REPEAT | + HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_RPTLINE0_EN | + vini_phase | vphase | + VFORMATTER_EN); + } + } else { + VSYNC_WR_MPEG_REG( + VIU_VD2_FMT_CTRL + cur_dev->viu_off, + HFORMATTER_REPEAT | + HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_RPTLINE0_EN | + vini_phase | vphase | + VFORMATTER_EN); + } + } else if ((type & VIDTYPE_TYPEMASK) == VIDTYPE_INTERLACE_TOP) { + VSYNC_WR_MPEG_REG( + VIU_VD2_FMT_CTRL + cur_dev->viu_off, + HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_RPTLINE0_EN | + (0xe << VFORMATTER_INIPHASE_BIT) | + (((type & VIDTYPE_VIU_422) ? 0x10 : 0x08) + << VFORMATTER_PHASE_BIT) | + VFORMATTER_EN); + } else { + VSYNC_WR_MPEG_REG( + VIU_VD2_FMT_CTRL + cur_dev->viu_off, + HFORMATTER_REPEAT | + HFORMATTER_YC_RATIO_2_1 | + HFORMATTER_EN | + VFORMATTER_RPTLINE0_EN | + (0xc << VFORMATTER_INIPHASE_BIT) | + (((type & VIDTYPE_VIU_422) ? 0x10 : 0x08) + << VFORMATTER_PHASE_BIT) | + VFORMATTER_EN); + } + + if (is_meson_txlx_cpu() + || is_meson_g12a_cpu() + || is_meson_g12b_cpu()) + VSYNC_WR_MPEG_REG_BITS( + VIU_VD2_FMT_CTRL + cur_dev->viu_off, + 1, 29, 1); + + /* LOOP/SKIP pattern */ + pat = vpat[frame_par->vscale_skip_count]; + + if (type & VIDTYPE_VIU_FIELD) { + loop = 0; + + if (type & VIDTYPE_INTERLACE) + pat = vpat[frame_par->vscale_skip_count >> 1]; + } else if (type & VIDTYPE_MVC) { + loop = 0x11; + pat = 0x80; + } else if ((type & VIDTYPE_TYPEMASK) == VIDTYPE_INTERLACE_TOP) { + loop = 0x11; + pat <<= 4; + } else + loop = 0; + + VSYNC_WR_MPEG_REG( + VD2_IF0_RPT_LOOP + cur_dev->viu_off, + (loop << VDIF_CHROMA_LOOP1_BIT) | + (loop << VDIF_LUMA_LOOP1_BIT) | + (loop << VDIF_CHROMA_LOOP0_BIT) | + (loop << VDIF_LUMA_LOOP0_BIT)); + + VSYNC_WR_MPEG_REG( + VD2_IF0_LUMA0_RPT_PAT + cur_dev->viu_off, pat); + VSYNC_WR_MPEG_REG( + VD2_IF0_CHROMA0_RPT_PAT + cur_dev->viu_off, pat); + VSYNC_WR_MPEG_REG( + VD2_IF0_LUMA1_RPT_PAT + cur_dev->viu_off, pat); + VSYNC_WR_MPEG_REG( + VD2_IF0_CHROMA1_RPT_PAT + cur_dev->viu_off, pat); + + VSYNC_WR_MPEG_REG( + VD2_IF0_LUMA_PSEL + cur_dev->viu_off, 0); + VSYNC_WR_MPEG_REG( + VD2_IF0_CHROMA_PSEL + cur_dev->viu_off, 0); +} +#endif + +/* for sdr/hdr/single dv switch with dual dv */ +static u32 last_el_status; +/* for dual dv switch with different el size */ +static u32 last_el_w; +bool has_enhanced_layer(struct vframe_s *vf) +{ + struct provider_aux_req_s req; + + if (!vf) + return 0; + if (vf->source_type != VFRAME_SOURCE_TYPE_OTHERS) + return 0; + if (!is_dolby_vision_on()) + return 0; + + req.vf = vf; + req.bot_flag = 0; + req.aux_buf = NULL; + req.aux_size = 0; + req.dv_enhance_exist = 0; + vf_notify_provider_by_name("dvbldec", + VFRAME_EVENT_RECEIVER_GET_AUX_DATA, + (void *)&req); return req.dv_enhance_exist; } u32 property_changed_true; @@ -2496,12 +3462,16 @@ static void vsync_toggle_frame(struct vframe_s *vf) bool vf_with_el = false; bool force_toggle = false; long long *clk_array; + bool is_mvc = false; if (vf == NULL) return; frame_count++; toggle_count++; + if (vf->type & VIDTYPE_MVC) + is_mvc = true; + if (is_dolby_vision_enable()) vf_with_el = has_enhanced_layer(vf); @@ -2582,8 +3552,7 @@ static void vsync_toggle_frame(struct vframe_s *vf) } if (hold_video) { - if ((cur_dispbuf != vf) - && (vf->source_type != VFRAME_SOURCE_TYPE_OSD)) { + if (cur_dispbuf != vf) { new_frame_count++; if (vf->pts != 0) { amlog_mask(LOG_MASK_TIMESTAMP, @@ -2618,87 +3587,64 @@ static void vsync_toggle_frame(struct vframe_s *vf) if ((cur_dispbuf) && (cur_dispbuf != &vf_local) && (cur_dispbuf != vf) && (video_property_changed != 2)) { - if (cur_dispbuf->source_type == VFRAME_SOURCE_TYPE_OSD) { - if (osd_prov && osd_prov->ops && osd_prov->ops->put) { - osd_prov->ops->put(cur_dispbuf, - osd_prov->op_arg); - if (debug_flag & DEBUG_FLAG_BLACKOUT) { - pr_info( - "[v4o]pre vf is osd,put it\n"); - } - } + new_frame_count++; + if (new_frame_count == 1) first_picture = 1; - if (debug_flag & DEBUG_FLAG_BLACKOUT) { - pr_info( - "[v4o] pre vf is osd, clear it to NULL\n"); - } - } else { - new_frame_count++; - if (new_frame_count == 1) - first_picture = 1; #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA - if (is_vsync_rdma_enable()) { + if (is_vsync_rdma_enable()) { #ifdef RDMA_RECYCLE_ORDERED_VFRAMES - if (dispbuf_to_put_num < DISPBUF_TO_PUT_MAX) { - dispbuf_to_put[dispbuf_to_put_num] = - cur_dispbuf; - dispbuf_to_put_num++; - } else - video_vf_put(cur_dispbuf); + if (dispbuf_to_put_num < DISPBUF_TO_PUT_MAX) { + dispbuf_to_put[dispbuf_to_put_num] = + cur_dispbuf; + dispbuf_to_put_num++; + } else + video_vf_put(cur_dispbuf); #else - if (cur_rdma_buf == cur_dispbuf) { - dispbuf_to_put[0] = cur_dispbuf; - dispbuf_to_put_num = 1; - } else - video_vf_put(cur_dispbuf); + if (cur_rdma_buf == cur_dispbuf) { + dispbuf_to_put[0] = cur_dispbuf; + dispbuf_to_put_num = 1; + } else + video_vf_put(cur_dispbuf); #endif - } else { - int i; + } else { + int i; - for (i = 0; i < dispbuf_to_put_num; i++) { - if (dispbuf_to_put[i]) { - video_vf_put( - dispbuf_to_put[i]); - dispbuf_to_put[i] = NULL; - } - dispbuf_to_put_num = 0; + for (i = 0; i < dispbuf_to_put_num; i++) { + if (dispbuf_to_put[i]) { + video_vf_put( + dispbuf_to_put[i]); + dispbuf_to_put[i] = NULL; } - video_vf_put(cur_dispbuf); + dispbuf_to_put_num = 0; } -#else video_vf_put(cur_dispbuf); + } +#else + video_vf_put(cur_dispbuf); #endif - if (debug_flag & DEBUG_FLAG_LATENCY) { - vf->ready_clock[3] = sched_clock(); - pr_info("video toggle latency %lld ms," - "video get latency %lld ms," - "vdin put latency %lld ms," - "first %lld ms.\n", - func_div(vf->ready_clock[3], 1000), - func_div(vf->ready_clock[2], 1000), - func_div(vf->ready_clock[1], 1000), - func_div(vf->ready_clock[0], 1000)); - cur_dispbuf->ready_clock[4] = sched_clock(); - clk_array = cur_dispbuf->ready_clock; - pr_info("video put latency %lld ms," - "video toggle latency %lld ms," - "video get latency %lld ms," - "vdin put latency %lld ms," - "first %lld ms.\n", - func_div(*(clk_array + 4), 1000), - func_div(*(clk_array + 3), 1000), - func_div(*(clk_array + 2), 1000), - func_div(*(clk_array + 1), 1000), - func_div(*clk_array, 1000)); - } + if (debug_flag & DEBUG_FLAG_LATENCY) { + vf->ready_clock[3] = sched_clock(); + pr_info( + "video toggle latency %lld ms, video get latency %lld ms, vdin put latency %lld ms, first %lld ms.\n", + func_div(vf->ready_clock[3], 1000), + func_div(vf->ready_clock[2], 1000), + func_div(vf->ready_clock[1], 1000), + func_div(vf->ready_clock[0], 1000)); + cur_dispbuf->ready_clock[4] = sched_clock(); + clk_array = cur_dispbuf->ready_clock; + pr_info("video put latency %lld ms, video toggle latency %lld ms, video get latency %lld ms, vdin put latency %lld ms, first %lld ms.\n", + func_div(*(clk_array + 4), 1000), + func_div(*(clk_array + 3), 1000), + func_div(*(clk_array + 2), 1000), + func_div(*(clk_array + 1), 1000), + func_div(*clk_array, 1000)); } - } else first_picture = 1; if (video_property_changed) { property_changed_true = 2; - video_property_changed = false; + video_property_changed = 0; first_picture = 1; } if (property_changed_true > 0) { @@ -2706,15 +3652,11 @@ static void vsync_toggle_frame(struct vframe_s *vf) first_picture = 1; } - if (debug_flag & DEBUG_FLAG_BLACKOUT) { - if (first_picture) { - pr_info - ("[video4osd] first %s picture {%d,%d} pts:%x,\n", - (vf->source_type == - VFRAME_SOURCE_TYPE_OSD) ? "OSD" : "", vf->width, - vf->height, vf->pts); - } - } + if ((debug_flag & DEBUG_FLAG_BLACKOUT) + && first_picture) + pr_info("first picture {%d,%d} pts:%x,\n", + vf->width, vf->height, vf->pts); + /* switch buffer */ post_canvas = vf->canvas0Addr; if ((get_cpu_type() >= MESON_CPU_MAJOR_ID_GXBB) && @@ -2742,7 +3684,7 @@ static void vsync_toggle_frame(struct vframe_s *vf) vf->plane_num, &disp_canvas_index[rdma_canvas_id][0]); } - if (!vf_with_el) { + if (is_mvc) { if (vf->canvas1Addr != (u32)-1) { canvas_copy(vf->canvas1Addr & 0xff, disp_canvas_index[rdma_canvas_id][3]); @@ -2760,46 +3702,33 @@ static void vsync_toggle_frame(struct vframe_s *vf) VSYNC_WR_MPEG_REG( VD1_IF0_CANVAS0 + cur_dev->viu_off, disp_canvas[rdma_canvas_id][0]); - if (platform_type == 0) { - VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + cur_dev->viu_off, - disp_canvas[rdma_canvas_id][0]); - if (!vf_with_el) { - VSYNC_WR_MPEG_REG( - VD2_IF0_CANVAS0 + cur_dev->viu_off, - disp_canvas[rdma_canvas_id][1]); - VSYNC_WR_MPEG_REG( - VD2_IF0_CANVAS1 + cur_dev->viu_off, - disp_canvas[rdma_canvas_id][1]); - } - } else { - if (!vf_with_el) - VSYNC_WR_MPEG_REG( - VD2_IF0_CANVAS0 + cur_dev->viu_off, - disp_canvas[rdma_canvas_id][1]); - if (cur_frame_par && + if (is_mvc) + VSYNC_WR_MPEG_REG( + VD2_IF0_CANVAS0 + cur_dev->viu_off, + disp_canvas[rdma_canvas_id][1]); + if (cur_frame_par && (cur_frame_par->vpp_2pic_mode == 1)) { - VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + + VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[rdma_canvas_id][0]); - if (!vf_with_el) - VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + + if (is_mvc) + VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[rdma_canvas_id][0]); - } else { - VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + + } else { + VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[rdma_canvas_id][1]); - if (!vf_with_el) - VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + + if (is_mvc) + VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[rdma_canvas_id][0]); - } } if (cur_frame_par && (process_3d_type & MODE_3D_ENABLE) && (process_3d_type & MODE_3D_TO_2D_R) && (cur_frame_par->vpp_2pic_mode == VPP_SELECT_PIC1) - && !vf_with_el) { + && is_mvc) { VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS0 + cur_dev->viu_off, disp_canvas[rdma_canvas_id][1]); VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + cur_dev->viu_off, @@ -2809,8 +3738,6 @@ static void vsync_toggle_frame(struct vframe_s *vf) VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[rdma_canvas_id][1]); } - /* VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1,*/ - /*disp_canvas[rdma_canvas_id][1]); */ next_rdma_canvas_id = rdma_canvas_id ? 0 : 1; #else canvas_copy(vf->canvas0Addr & 0xff, disp_canvas_index[0]); @@ -2818,91 +3745,65 @@ static void vsync_toggle_frame(struct vframe_s *vf) disp_canvas_index[1]); canvas_copy((vf->canvas0Addr >> 16) & 0xff, disp_canvas_index[2]); - canvas_copy(vf->canvas1Addr & 0xff, disp_canvas_index[3]); - canvas_copy((vf->canvas1Addr >> 8) & 0xff, - disp_canvas_index[4]); - canvas_copy((vf->canvas1Addr >> 16) & 0xff, - disp_canvas_index[5]); - if (platform_type == 0) { - VSYNC_WR_MPEG_REG( - VD1_IF0_CANVAS0 + cur_dev->viu_off, - disp_canvas[0]); - VSYNC_WR_MPEG_REG( - VD1_IF0_CANVAS1 + cur_dev->viu_off, - disp_canvas[0]); - if (!vf_with_el) { - VSYNC_WR_MPEG_REG( - VD2_IF0_CANVAS0 + cur_dev->viu_off, - disp_canvas[1]); - VSYNC_WR_MPEG_REG( - VD2_IF0_CANVAS1 + cur_dev->viu_off, - disp_canvas[1]); - } - } else { - VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS0 + cur_dev->viu_off, - disp_canvas[0]); - if (!vf_with_el) - VSYNC_WR_MPEG_REG( - VD2_IF0_CANVAS0 + cur_dev->viu_off, - disp_canvas[0]); - if (cur_frame_par && + if (is_mvc) { + canvas_copy(vf->canvas1Addr & 0xff, + disp_canvas_index[3]); + canvas_copy((vf->canvas1Addr >> 8) & 0xff, + disp_canvas_index[4]); + canvas_copy((vf->canvas1Addr >> 16) & 0xff, + disp_canvas_index[5]); + } + VSYNC_WR_MPEG_REG( + VD1_IF0_CANVAS0 + cur_dev->viu_off, + disp_canvas[0]); + if (is_mvc) + VSYNC_WR_MPEG_REG( + VD2_IF0_CANVAS0 + cur_dev->viu_off, + disp_canvas[0]); + if (cur_frame_par && (cur_frame_par->vpp_2pic_mode == 1)) { - VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + + VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[0]); - if (!vf_with_el) - VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + + if (is_mvc) + VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[0]); - } else { - VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + + } else { + VSYNC_WR_MPEG_REG(VD1_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[1]); - if (!vf_with_el) - VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + + if (is_mvc) + VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 + cur_dev->viu_off, disp_canvas[1]); - } - /* VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS0 +*/ - /*cur_dev->viu_off, disp_canvas[0]); */ - /* VSYNC_WR_MPEG_REG(VD2_IF0_CANVAS1 +*/ - /*cur_dev->viu_off, disp_canvas[1]); */ } #endif } /* set video PTS */ if (cur_dispbuf != vf) { - if (vf->source_type != VFRAME_SOURCE_TYPE_OSD) { - if (vf->pts != 0) { - amlog_mask(LOG_MASK_TIMESTAMP, - "vpts to: 0x%x, scr: 0x%x, abs_scr: 0x%x\n", - vf->pts, timestamp_pcrscr_get(), - READ_MPEG_REG(SCR_HIU)); - - timestamp_vpts_set(vf->pts); - } else if (cur_dispbuf) { - amlog_mask(LOG_MASK_TIMESTAMP, - "vpts inc: 0x%x, scr: 0x%x, abs_scr: 0x%x\n", - timestamp_vpts_get() + - DUR2PTS(cur_dispbuf->duration), - timestamp_pcrscr_get(), - READ_MPEG_REG(SCR_HIU)); - - timestamp_vpts_inc(DUR2PTS - (cur_dispbuf->duration)); - - vpts_remainder += - DUR2PTS_RM(cur_dispbuf->duration); - if (vpts_remainder >= 0xf) { - vpts_remainder -= 0xf; - timestamp_vpts_inc(-1); - } - } - } else { - first_picture = 1; - if (debug_flag & DEBUG_FLAG_BLACKOUT) { - pr_info( - "[v4o] cur vframe is osd, do not set PTS\n"); + if (vf->pts != 0) { + amlog_mask(LOG_MASK_TIMESTAMP, + "vpts to: 0x%x, scr: 0x%x, abs_scr: 0x%x\n", + vf->pts, timestamp_pcrscr_get(), + READ_MPEG_REG(SCR_HIU)); + timestamp_vpts_set(vf->pts); + } else if (cur_dispbuf) { + amlog_mask(LOG_MASK_TIMESTAMP, + "vpts inc: 0x%x, scr: 0x%x, abs_scr: 0x%x\n", + timestamp_vpts_get() + + DUR2PTS(cur_dispbuf->duration), + timestamp_pcrscr_get(), + READ_MPEG_REG(SCR_HIU)); + + timestamp_vpts_inc(DUR2PTS + (cur_dispbuf->duration)); + + vpts_remainder += + DUR2PTS_RM(cur_dispbuf->duration); + if (vpts_remainder >= 0xf) { + vpts_remainder -= 0xf; + timestamp_vpts_inc(-1); } } vf->type_backup = vf->type; @@ -2933,6 +3834,8 @@ static void vsync_toggle_frame(struct vframe_s *vf) ((cur_dispbuf->type_backup & VIDTYPE_INTERLACE) != (vf->type_backup & VIDTYPE_INTERLACE)) || (cur_dispbuf->type != vf->type)))) { + int iret; + last_process_3d_type = process_3d_type; atomic_inc(&video_sizechange); wake_up_interruptible(&amvideo_sizechange_wait); @@ -2952,42 +3855,39 @@ static void vsync_toggle_frame(struct vframe_s *vf) next_frame_par = (&frame_parms[0] == next_frame_par) ? &frame_parms[1] : &frame_parms[0]; - vpp_set_filters(process_3d_type, wide_setting, vf, + update_layer_info(0); + iret = vpp_set_filters( + &glayer_info[0], vf, next_frame_par, vinfo, (is_dolby_vision_on() && is_dolby_vision_stb_mode())); + if (iret == VppFilter_Success_and_Changed) + video_property_changed = 1; + /* apply new vpp settings */ frame_par_ready_to_set = 1; - /* #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ - if ((get_cpu_type() >= MESON_CPU_MAJOR_ID_M8) - && !is_meson_mtvd_cpu()) { - if (((vf->width > 1920) && (vf->height > 1088)) || - ((vf->type & VIDTYPE_COMPRESS) && - (vf->compWidth > 1920) && - (vf->compHeight > 1080))) { - if (vpu_clk_level == 0) { - vpu_clk_level = 1; - - spin_lock_irqsave(&lock, flags); - vpu_delay_work_flag |= - VPU_DELAYWORK_VPU_CLK; - spin_unlock_irqrestore(&lock, flags); - } - } else { - if (vpu_clk_level == 1) { - vpu_clk_level = 0; - - spin_lock_irqsave(&lock, flags); - vpu_delay_work_flag |= - VPU_DELAYWORK_VPU_CLK; - spin_unlock_irqrestore(&lock, flags); - } + if (((vf->width > 1920) && (vf->height > 1088)) || + ((vf->type & VIDTYPE_COMPRESS) && + (vf->compWidth > 1920) && + (vf->compHeight > 1080))) { + if (vpu_clk_level == 0) { + vpu_clk_level = 1; + spin_lock_irqsave(&lock, flags); + vpu_delay_work_flag |= + VPU_DELAYWORK_VPU_CLK; + spin_unlock_irqrestore(&lock, flags); + } + } else { + if (vpu_clk_level == 1) { + vpu_clk_level = 0; + spin_lock_irqsave(&lock, flags); + vpu_delay_work_flag |= + VPU_DELAYWORK_VPU_CLK; + spin_unlock_irqrestore(&lock, flags); } } - /* #endif */ - } last_el_status = vf_with_el; @@ -2999,7 +3899,6 @@ static void vsync_toggle_frame(struct vframe_s *vf) } if (first_picture && (disable_video != VIDEO_DISABLE_NORMAL)) { EnableVideoLayer(); - if ((vf->type & VIDTYPE_MVC) || (cur_dispbuf2 && (cur_dispbuf2->type & VIDTYPE_VD2))) EnableVideoLayer2(); @@ -3057,108 +3956,6 @@ static void vsync_toggle_frame(struct vframe_s *vf) } } } -static inline void vd1_path_select(bool afbc) -{ - u32 misc_off = cur_dev->vpp_off; - - if (!legacy_vpp) { - VSYNC_WR_MPEG_REG_BITS( - VD1_AFBCD0_MISC_CTRL, - /* go field sel */ - (0 << 20) | - /* linebuffer en */ - (0 << 16) | - /* vd1 -> dolby -> vpp top */ - (0 << 14) | - /* axi sel: vd1 mif or afbc */ - ((afbc ? 1 : 0) << 12) | - /* data sel: vd1 & afbc0 (not osd4) */ - (0 << 11) | - /* data sel: afbc0 or vd1 */ - ((afbc ? 1 : 0) << 10) | - /* afbc0 to vd1 (not di) */ - (0 << 9) | - /* vd1 mif to vpp (not di) */ - (0 << 8) | - /* afbc0 gclk ctrl */ - (0 << 0), - 0, 22); - if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) - VSYNC_WR_MPEG_REG_BITS( - VD1_AFBCD0_MISC_CTRL, - /* Vd1_afbc0_mem_sel */ - (afbc ? 1 : 0), - 22, 1); - -#ifdef CONFIG_AMLOGIC_MEDIA_DEINTERLACE - if (!cpu_after_eq(MESON_CPU_MAJOR_ID_G12A)) - return; - if ((DI_POST_REG_RD(DI_POST_CTRL) & 0x100) != 0) { - /* check di_vpp_out_en bit */ - VSYNC_WR_MPEG_REG_BITS( - VD1_AFBCD0_MISC_CTRL, - /* vd1 mif to di */ - 1, - 8, 2); - VSYNC_WR_MPEG_REG_BITS( - VD1_AFBCD0_MISC_CTRL, - /* go field select di post */ - 1, - 20, 2); - } -#endif - } else { -#ifdef CONFIG_AMLOGIC_MEDIA_DEINTERLACE - if ((DI_POST_REG_RD(DI_POST_CTRL) & 0x100) == 0) - /* mif sel */ -#endif - VSYNC_WR_MPEG_REG_BITS( - VIU_MISC_CTRL0 + misc_off, - 0, 16, 3); - VSYNC_WR_MPEG_REG_BITS( - VIU_MISC_CTRL0 + misc_off, - (afbc ? 1 : 0), 20, 1); - } -} - -static inline void vd2_path_select(bool afbc) -{ - u32 misc_off = cur_dev->vpp_off; - - if (!legacy_vpp) { - VSYNC_WR_MPEG_REG_BITS( - VD2_AFBCD1_MISC_CTRL, - /* go field sel */ - (0 << 20) | - /* linebuffer en */ - (0 << 16) | - /* TODO: vd2 -> dolby -> vpp top ?? */ - (0 << 14) | - /* axi sel: vd2 mif */ - ((afbc ? 1 : 0) << 12) | - /* data sel: vd2 & afbc1 (not osd4) */ - (0 << 11) | - /* data sel: afbc1 */ - ((afbc ? 1 : 0) << 10) | - /* afbc1 to vd2 (not di) */ - (0 << 9) | - /* vd2 mif to vpp (not di) */ - (0 << 8) | - /* afbc1 gclk ctrl */ - (0 << 0), - 0, 22); - if (cpu_after_eq(MESON_CPU_MAJOR_ID_TL1)) - VSYNC_WR_MPEG_REG_BITS( - VD2_AFBCD1_MISC_CTRL, - /* Vd2_afbc0_mem_sel */ - (afbc ? 1 : 0), - 22, 1); - } else { - VSYNC_WR_MPEG_REG_BITS( - VIU_MISC_CTRL1 + misc_off, - (afbc ? 2 : 0), 0, 2); - } -} static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) { @@ -3169,13 +3966,17 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) 0, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; u32 u, v; u32 type, bit_mode = 0; - bool vf_with_el = false; + bool is_mvc = false; if (vf == NULL) { pr_info("viu_set_dcu vf NULL, return\n"); return; } + type = vf->type; + if (type & VIDTYPE_MVC) + is_mvc = true; + pr_debug("set dcu for vd1 %p, type:0x%x\n", vf, type); if (get_cpu_type() >= MESON_CPU_MAJOR_ID_GXBB) { if (frame_par->nocomp) @@ -3305,7 +4106,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VSYNC_WR_MPEG_REG_BITS( G12_VD1_IF0_GEN_REG3, (bit_mode & 0x3), 8, 2); - if ((vf->type & VIDTYPE_MVC) && (!vf_with_el)) + if (is_mvc) VSYNC_WR_MPEG_REG_BITS( G12_VD2_IF0_GEN_REG3, (bit_mode & 0x3), 8, 2); @@ -3314,7 +4115,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VD1_IF0_GEN_REG3 + cur_dev->viu_off, (bit_mode & 0x3), 8, 2); - if ((vf->type & VIDTYPE_MVC) && (!vf_with_el)) + if (is_mvc) VSYNC_WR_MPEG_REG_BITS( VD2_IF0_GEN_REG3 + cur_dev->viu_off, @@ -3353,15 +4154,14 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VDIF_DEMUX_MODE_RGB_444; } } - if (is_dolby_vision_enable()) - vf_with_el = has_enhanced_layer(vf); + if (frame_par->hscale_skip_count) r |= VDIF_CHROMA_HZ_AVG | VDIF_LUMA_HZ_AVG; /*enable go field reset default according to vlsi*/ r |= VDIF_RESET_ON_GO_FIELD; VSYNC_WR_MPEG_REG(VD1_IF0_GEN_REG + cur_dev->viu_off, r); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG( VD2_IF0_GEN_REG + cur_dev->viu_off, r); @@ -3374,39 +4174,21 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VSYNC_WR_MPEG_REG_BITS(VD1_IF0_GEN_REG2 + cur_dev->viu_off, 0, 0, 1); } -#if HAS_VPU_PROT - if (has_vpu_prot()) { - if (use_prot) { - if (vf->video_angle == 2) { - VSYNC_WR_MPEG_REG_BITS(VD1_IF0_GEN_REG2 - + - cur_dev->viu_off, - 0xf, 2, 4); - } else { - VSYNC_WR_MPEG_REG_BITS(VD1_IF0_GEN_REG2 - + - cur_dev->viu_off, - 0, 2, 4); - } - } - } -#else #ifdef TV_REVERSE if (reverse) { VSYNC_WR_MPEG_REG_BITS((VD1_IF0_GEN_REG2 + cur_dev->viu_off), 0xf, 2, 4); - if ((vf->type & VIDTYPE_MVC) && (!vf_with_el)) + if (is_mvc) VSYNC_WR_MPEG_REG_BITS((VD2_IF0_GEN_REG2 + cur_dev->viu_off), 0xf, 2, 4); } else { VSYNC_WR_MPEG_REG_BITS((VD1_IF0_GEN_REG2 + cur_dev->viu_off), 0, 2, 4); - if ((vf->type & VIDTYPE_MVC) && (!vf_with_el)) + if (is_mvc) VSYNC_WR_MPEG_REG_BITS((VD2_IF0_GEN_REG2 + cur_dev->viu_off), 0, 2, 4); } #endif -#endif } /* #endif */ @@ -3414,7 +4196,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) if (type & VIDTYPE_VIU_444) { VSYNC_WR_MPEG_REG(VIU_VD1_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_1_1); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG(VIU_VD2_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_1_1); } else if (type & VIDTYPE_VIU_FIELD) { @@ -3455,7 +4237,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VIU_VD1_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_2_1 | HFORMATTER_EN | VFORMATTER_RPTLINE0_EN | vini_phase | vphase); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG( VIU_VD2_FMT_CTRL + cur_dev->viu_off, HFORMATTER_RRT_PIXEL0 | @@ -3471,7 +4253,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) HFORMATTER_YC_RATIO_2_1 | HFORMATTER_EN | VFORMATTER_RPTLINE0_EN | vini_phase | vphase | vformatter); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG( VIU_VD2_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_2_1 | @@ -3489,7 +4271,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VFORMATTER_RPTLINE0_EN | vini_phase | vphase | vformatter); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG( VIU_VD2_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_2_1 | @@ -3506,7 +4288,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) (0xe << VFORMATTER_INIPHASE_BIT) | (((type & VIDTYPE_VIU_422) ? 0x10 : 0x08) << VFORMATTER_PHASE_BIT) | VFORMATTER_EN); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG(VIU_VD2_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_2_1 | HFORMATTER_EN | VFORMATTER_RPTLINE0_EN | (0xa << @@ -3521,7 +4303,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VFORMATTER_INIPHASE_BIT) | (((type & VIDTYPE_VIU_422) ? 0x10 : 0x08) << VFORMATTER_PHASE_BIT) | VFORMATTER_EN); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG(VIU_VD2_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_2_1 | HFORMATTER_EN | @@ -3555,7 +4337,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) (((type & VIDTYPE_VIU_422) ? 0x10 : 0x08) << VFORMATTER_PHASE_BIT) | VFORMATTER_EN); } - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG(VIU_VD2_FMT_CTRL + cur_dev->viu_off, HFORMATTER_YC_RATIO_2_1 | HFORMATTER_EN | @@ -3602,7 +4384,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) (loop << VDIF_LUMA_LOOP1_BIT) | (loop << VDIF_CHROMA_LOOP0_BIT) | (loop << VDIF_LUMA_LOOP0_BIT)); - if (!vf_with_el) + if (is_mvc) VSYNC_WR_MPEG_REG( VD2_IF0_RPT_LOOP + cur_dev->viu_off, (loop << VDIF_CHROMA_LOOP1_BIT) | @@ -3620,8 +4402,6 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) pat = 0; else pat = 0x88; - } - if (!vf_with_el) { VSYNC_WR_MPEG_REG( VD2_IF0_LUMA0_RPT_PAT + cur_dev->viu_off, pat); VSYNC_WR_MPEG_REG( @@ -3632,46 +4412,14 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VD2_IF0_CHROMA1_RPT_PAT + cur_dev->viu_off, pat); } - if (platform_type == 0) { - /* picture 0/1 control */ - if (((type & VIDTYPE_INTERLACE) == 0) && - ((type & VIDTYPE_VIU_FIELD) == 0) && - ((type & VIDTYPE_MVC) == 0)) { - /* progressive frame in two pictures */ - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + - cur_dev->viu_off, (2 << 26) | /* two pic mode */ - (2 << 24) | /* use own last line */ - (2 << 8) | /* toggle pic 0 and 1, use pic0 first */ - (0x01)); /* loop pattern */ - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + - cur_dev->viu_off, - (2 << 26) | /* two pic mode */ - (2 << 24) | /* use own last line */ - (2 << 8) | /* toggle pic 0 and 1, use pic0 first */ - (0x01)); /* loop pattern */ - } else { + /* picture 0/1 control */ + if ((((type & VIDTYPE_INTERLACE) == 0) && + ((type & VIDTYPE_VIU_FIELD) == 0) && + ((type & VIDTYPE_MVC) == 0)) || + (frame_par->vpp_2pic_mode & 0x3)) { + /* progressive frame in two pictures */ + if (frame_par->vpp_2pic_mode & VPP_PIC1_FIRST) { VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + - cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + - cur_dev->viu_off, 0); - if (!vf_with_el) { - VSYNC_WR_MPEG_REG( - VD2_IF0_LUMA_PSEL + - cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG( - VD2_IF0_CHROMA_PSEL + - cur_dev->viu_off, 0); - } - } - } else { - /* picture 0/1 control */ - if ((((type & VIDTYPE_INTERLACE) == 0) && - ((type & VIDTYPE_VIU_FIELD) == 0) && - ((type & VIDTYPE_MVC) == 0)) || - (frame_par->vpp_2pic_mode & 0x3)) { - /* progressive frame in two pictures */ - if (frame_par->vpp_2pic_mode & VPP_PIC1_FIRST) { - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, (2 << 26) | /* two pic mode */ (2 << 24) | @@ -3680,7 +4428,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) /* toggle pic 0 and 1, use pic1 first*/ (0x01)); /* loop pattern */ - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, (2 << 26) | /* two pic mode */ (2 << 24) | @@ -3689,8 +4437,8 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) /* toggle pic 0 and 1,use pic1 first */ (0x01)); /* loop pattern */ - } else { - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + + } else { + VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, (2 << 26) | /* two pic mode */ (2 << 24) | @@ -3699,7 +4447,7 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) /* toggle pic 0 and 1, use pic0 first */ (0x01)); /* loop pattern */ - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, (2 << 26) | /* two pic mode */ (2 << 24) | @@ -3708,34 +4456,33 @@ static void viu_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) /* toggle pic 0 and 1, use pic0 first */ (0x01)); /* loop pattern */ - } - } else if (process_3d_type & MODE_3D_OUT_FA_MASK) { - /*FA LR/TB output , do nothing*/ - } else { - if (frame_par->vpp_2pic_mode & VPP_SELECT_PIC1) { - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + + } + } else if (process_3d_type & MODE_3D_OUT_FA_MASK) { + /*FA LR/TB output , do nothing*/ + } else { + if (frame_par->vpp_2pic_mode & VPP_SELECT_PIC1) { + VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, 0); - if (!vf_with_el) { - VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + + if (is_mvc) { + VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + cur_dev->viu_off, 0); - } - } else { - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + + } + } else { + VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, 0); - if (!vf_with_el) { - VSYNC_WR_MPEG_REG( - VD2_IF0_LUMA_PSEL + - cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG( - VD2_IF0_CHROMA_PSEL + - cur_dev->viu_off, 0); - } + if (is_mvc) { + VSYNC_WR_MPEG_REG( + VD2_IF0_LUMA_PSEL + + cur_dev->viu_off, 0); + VSYNC_WR_MPEG_REG( + VD2_IF0_CHROMA_PSEL + + cur_dev->viu_off, 0); } } } @@ -4148,8 +4895,6 @@ static void vd2_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) } } -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 */ - static int detect_vout_type(void) { int vout_type = VOUT_TYPE_PROG; @@ -4175,37 +4920,6 @@ static int detect_vout_type(void) return vout_type; } -#else -static int detect_vout_type(void) -{ -#if defined(CONFIG_AM_TCON_OUTPUT) - return VOUT_TYPE_PROG; -#else - int vout_type; - int encp_enable = READ_VCBUS_REG(ENCP_VIDEO_EN) & 1; - - if (encp_enable) { - if (READ_VCBUS_REG(ENCP_VIDEO_MODE) & (1 << 12)) { - /* 1080I */ - if (READ_VCBUS_REG(VENC_ENCP_LINE) < 562) - vout_type = VOUT_TYPE_TOP_FIELD; - - else - vout_type = VOUT_TYPE_BOT_FIELD; - - } else - vout_type = VOUT_TYPE_PROG; - - } else { - vout_type = (READ_VCBUS_REG(VENC_STATA) & 1) ? - VOUT_TYPE_BOT_FIELD : VOUT_TYPE_TOP_FIELD; - } - - return vout_type; -#endif -} -#endif - #ifdef INTERLACE_FIELD_MATCH_PROCESS static inline bool interlace_field_type_need_match(int vout_type, struct vframe_s *vf) @@ -4777,37 +5491,35 @@ static enum vframe_disp_mode_e video_vf_disp_mode_get(struct vframe_s *vf) VFRAME_EVENT_RECEIVER_DISP_MODE, (void *)&req); } else vf_notify_provider_by_name("vdin0", - VFRAME_EVENT_RECEIVER_DISP_MODE, (void *)&req); - return req.disp_mode; -} -static inline bool video_vf_dirty_put(struct vframe_s *vf) -{ - if (!vf->frame_dirty) - return false; - if (cur_dispbuf != vf) { - if (vf->source_type != VFRAME_SOURCE_TYPE_OSD) { - if (vf->pts != 0) { - amlog_mask(LOG_MASK_TIMESTAMP, - "vpts to vf->pts:0x%x,scr:0x%x,abs_scr: 0x%x\n", - vf->pts, timestamp_pcrscr_get(), - READ_MPEG_REG(SCR_HIU)); - timestamp_vpts_set(vf->pts); - } else if (cur_dispbuf) { - amlog_mask(LOG_MASK_TIMESTAMP, - "vpts inc:0x%x,scr: 0x%x, abs_scr: 0x%x\n", - timestamp_vpts_get() + - DUR2PTS(cur_dispbuf->duration), - timestamp_pcrscr_get(), - READ_MPEG_REG(SCR_HIU)); - timestamp_vpts_inc( - DUR2PTS(cur_dispbuf->duration)); - - vpts_remainder += - DUR2PTS_RM(cur_dispbuf->duration); - if (vpts_remainder >= 0xf) { - vpts_remainder -= 0xf; - timestamp_vpts_inc(-1); - } + VFRAME_EVENT_RECEIVER_DISP_MODE, (void *)&req); + return req.disp_mode; +} +static inline bool video_vf_dirty_put(struct vframe_s *vf) +{ + if (!vf->frame_dirty) + return false; + if (cur_dispbuf != vf) { + if (vf->pts != 0) { + amlog_mask(LOG_MASK_TIMESTAMP, + "vpts to vf->pts:0x%x,scr:0x%x,abs_scr: 0x%x\n", + vf->pts, timestamp_pcrscr_get(), + READ_MPEG_REG(SCR_HIU)); + timestamp_vpts_set(vf->pts); + } else if (cur_dispbuf) { + amlog_mask(LOG_MASK_TIMESTAMP, + "vpts inc:0x%x,scr: 0x%x, abs_scr: 0x%x\n", + timestamp_vpts_get() + + DUR2PTS(cur_dispbuf->duration), + timestamp_pcrscr_get(), + READ_MPEG_REG(SCR_HIU)); + timestamp_vpts_inc( + DUR2PTS(cur_dispbuf->duration)); + + vpts_remainder += + DUR2PTS_RM(cur_dispbuf->duration); + if (vpts_remainder >= 0xf) { + vpts_remainder -= 0xf; + timestamp_vpts_inc(-1); } } } @@ -5195,7 +5907,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id) vinfo->sync_duration_num; vsync_pts_inc_scale = vinfo->sync_duration_den; vsync_pts_inc_scale_base = vinfo->sync_duration_num; - video_property_changed = true; + video_property_changed = 1; pr_info("Change to video 0\n"); } } else { @@ -5207,7 +5919,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id) vinfo->sync_duration_num; vsync_pts_inc_scale = vinfo->sync_duration_den; vsync_pts_inc_scale_base = vinfo->sync_duration_num; - video_property_changed = true; + video_property_changed = 1; pr_info("Change to video 1\n"); } } @@ -5253,7 +5965,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id) if ((vf) && ((vf->type & VIDTYPE_NO_VIDEO_ENABLE) == 0)) { if ((old_vmode != new_vmode) || (debug_flag == 8)) { debug_flag = 1; - video_property_changed = true; + video_property_changed = 1; pr_info("detect vout mode change!!!!!!!!!!!!\n"); old_vmode = new_vmode; } @@ -5416,25 +6128,21 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id) goto exit; #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA - if (is_vsync_rdma_enable()) + if (is_vsync_rdma_enable()) { rdma_canvas_id = next_rdma_canvas_id; - else { - if (rdma_enable_pre) { - /*do not write register directly before RDMA is done */ - /*#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6TV */ - if (is_meson_mtvd_cpu()) { - if (debug_flag & DEBUG_FLAG_RDMA_WAIT_1) { - while - ( - ((READ_VCBUS_REG(ENCL_INFO_READ) >> 16) - & 0x1fff) < 50); - } - } - /* #endif */ +#ifdef VIDEO_PIP + pip_rdma_canvas_id = pip_next_rdma_canvas_id; +#endif + } else { + if (rdma_enable_pre) goto exit; - } + rdma_canvas_id = 0; next_rdma_canvas_id = 1; +#ifdef VIDEO_PIP + pip_rdma_canvas_id = 0; + pip_next_rdma_canvas_id = 1; +#endif } for (i = 0; i < dispbuf_to_put_num; i++) { @@ -5444,21 +6152,13 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id) } dispbuf_to_put_num = 0; } -#endif - - if (osd_prov && osd_prov->ops && osd_prov->ops->get) { - vf = osd_prov->ops->get(osd_prov->op_arg); - if (vf) { - vf->source_type = VFRAME_SOURCE_TYPE_OSD; - vsync_toggle_frame(vf); - if (debug_flag & DEBUG_FLAG_BLACKOUT) { - pr_info - ("[video4osd] toggle osd_vframe {%d,%d}\n", - vf->width, vf->height); - } - goto SET_FILTER; - } +#ifdef VIDEO_PIP + if (pipbuf_to_put) { + pip_vf_put(pipbuf_to_put); + pipbuf_to_put = NULL; } +#endif +#endif if ((!cur_dispbuf) || (cur_dispbuf == &vf_local)) { @@ -5507,7 +6207,7 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id) } vsync_toggle_frame(cur_dispbuf); } else - video_property_changed = false; + video_property_changed = 0; } else { goto SET_FILTER; } @@ -5780,6 +6480,21 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id) #endif SET_FILTER: +#ifdef VIDEO_PIP + vf = pip_vf_peek(); + /* setting video display property in underflow mode */ + if ((!vf) && cur_pipbuf && (pip_property_changed)) + pip_toggle_frame(cur_pipbuf); + if (vf) { + vf = pip_vf_get(); + if (vf) { + if (!vf->frame_dirty) + pip_toggle_frame(vf); + else + pip_vf_put(vf); + } + } +#endif #if defined(CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM) amvecm_on_vs( (cur_dispbuf != &vf_local) @@ -5916,183 +6631,260 @@ SET_FILTER: last_el_status = 0; } } - { -#if 0 - if (get_cpu_type() >= MESON_CPU_MAJOR_ID_GXBB) { - if (cur_dispbuf->type & VIDTYPE_COMPRESS) { - /*SET_VCBUS_REG_MASK(VIU_MISC_CTRL0,*/ - /*VIU_MISC_AFBC_VD1);*/ - VSYNC_WR_MPEG_REG_BITS(VIU_MISC_CTRL0 + - cur_dev->viu_off, 1, 20, 1); - } else { - /*CLEAR_VCBUS_REG_MASK(VIU_MISC_CTRL0,*/ - /*VIU_MISC_AFBC_VD1);*/ - VSYNC_WR_MPEG_REG_BITS(VIU_MISC_CTRL0 + - cur_dev->viu_off, 0, 20, 1); - } - } -#endif - if (platform_type == 1) { - if (cur_frame_par && cur_frame_par->hscale_skip_count) { - VSYNC_WR_MPEG_REG_BITS(VIU_VD1_FMT_CTRL + - cur_dev->viu_off, 1, 20, 1); - /* HFORMATTER_EN */ - VSYNC_WR_MPEG_REG_BITS(VIU_VD2_FMT_CTRL + - cur_dev->viu_off, 1, 20, 1); - /* HFORMATTER_EN */ - } - if (process_3d_type & MODE_3D_OUT_FA_MASK) { - if (toggle_3d_fa_frame == OUT_FA_A_FRAME) { - VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - cur_dev->vpp_off, 1, 14, 1); - /* VPP_VD1_PREBLEND disable */ - VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - cur_dev->vpp_off, 1, 10, 1); - /* VPP_VD1_POSTBLEND disable */ - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + + if (cur_frame_par && + cur_frame_par->hscale_skip_count) { + VSYNC_WR_MPEG_REG_BITS(VIU_VD1_FMT_CTRL + + cur_dev->viu_off, 1, 20, 1); + /* HFORMATTER_EN */ +#ifdef VIDEO_PIP + if (!cur_pipbuf) +#endif + VSYNC_WR_MPEG_REG_BITS(VIU_VD2_FMT_CTRL + + cur_dev->viu_off, 1, 20, 1); + /* HFORMATTER_EN */ + } + if (process_3d_type & MODE_3D_OUT_FA_MASK) { + if (toggle_3d_fa_frame == OUT_FA_A_FRAME) { + VSYNC_WR_MPEG_REG_BITS(VPP_MISC + + cur_dev->vpp_off, 1, 14, 1); + /* VPP_VD1_PREBLEND disable */ + VSYNC_WR_MPEG_REG_BITS(VPP_MISC + + cur_dev->vpp_off, 1, 10, 1); + /* VPP_VD1_POSTBLEND disable */ + VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, 0x4000000); - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, 0x4000000); - VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + + VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + cur_dev->viu_off, 0x4000000); - VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + cur_dev->viu_off, 0x4000000); - } else if (OUT_FA_B_FRAME == + } else if (OUT_FA_B_FRAME == toggle_3d_fa_frame) { - VSYNC_WR_MPEG_REG_BITS(VPP_MISC + + VSYNC_WR_MPEG_REG_BITS(VPP_MISC + cur_dev->vpp_off, 1, 14, 1); - /* VPP_VD1_PREBLEND disable */ - VSYNC_WR_MPEG_REG_BITS(VPP_MISC + + /* VPP_VD1_PREBLEND disable */ + VSYNC_WR_MPEG_REG_BITS(VPP_MISC + cur_dev->vpp_off, 1, 10, 1); - /* VPP_VD1_POSTBLEND disable */ - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + + /* VPP_VD1_POSTBLEND disable */ + VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG( - VD2_IF0_LUMA_PSEL + - cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG( - VD2_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG( + VD2_IF0_LUMA_PSEL + cur_dev->viu_off, 0); - } else if (toggle_3d_fa_frame == + VSYNC_WR_MPEG_REG( + VD2_IF0_CHROMA_PSEL + + cur_dev->viu_off, 0); + } else if (toggle_3d_fa_frame == OUT_FA_BANK_FRAME) { - /* output a banking frame */ - VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - cur_dev->vpp_off, 0, 14, 1); - /* VPP_VD1_PREBLEND disable */ - VSYNC_WR_MPEG_REG_BITS(VPP_MISC + + /* output a banking frame */ + VSYNC_WR_MPEG_REG_BITS(VPP_MISC + + cur_dev->vpp_off, 0, 14, 1); + /* VPP_VD1_PREBLEND disable */ + VSYNC_WR_MPEG_REG_BITS(VPP_MISC + cur_dev->vpp_off, 0, 10, 1); - /* VPP_VD1_POSTBLEND disable */ - } + /* VPP_VD1_POSTBLEND disable */ } - if ((process_3d_type & MODE_3D_OUT_TB) - || (process_3d_type & MODE_3D_OUT_LR)) { - if (cur_frame_par && - (cur_frame_par->vpp_2pic_mode & + } + if ((process_3d_type & MODE_3D_OUT_TB) + || (process_3d_type & MODE_3D_OUT_LR)) { + if (cur_frame_par && + (cur_frame_par->vpp_2pic_mode & VPP_PIC1_FIRST)) { - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, 0x4000000); - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, 0x4000000); - VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + + VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + cur_dev->viu_off, 0); - } else { - VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + + } else { + VSYNC_WR_MPEG_REG(VD1_IF0_LUMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD1_IF0_CHROMA_PSEL + cur_dev->viu_off, 0); - VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + + VSYNC_WR_MPEG_REG(VD2_IF0_LUMA_PSEL + cur_dev->viu_off, 0x4000000); - VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + + VSYNC_WR_MPEG_REG(VD2_IF0_CHROMA_PSEL + cur_dev->viu_off, 0x4000000); - } -/* - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,1,15,1);//VPP_VD2_PREBLEND enable - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,1,11,1);//VPP_VD2_POSTBLEND enable - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,1,6,1);//PREBLEND enable must be set! - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,0x1ff, - *VPP_VD2_ALPHA_BIT,9);//vd2 alpha must set - */ } - -/* - *else{ - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,0,15,1);//VPP_VD2_PREBLEND enable - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,1,11,1);//VPP_VD2_POSTBLEND enable - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,0,6,1);//PREBLEND enable - *VSYNC_WR_MPEG_REG_BITS(VPP_MISC + - *cur_dev->vpp_off,0,VPP_VD2_ALPHA_BIT,9);//vd2 alpha must set - *} - */ } - /* vertical phase */ - vphase = - &cur_frame_par->VPP_vf_ini_phase_ + /* vertical phase */ + vphase = &cur_frame_par->VPP_vf_ini_phase_ [vpp_phase_table[vin_type] [vout_type]]; - VSYNC_WR_MPEG_REG(VPP_VSC_INI_PHASE + cur_dev->vpp_off, - ((u32) (vphase->phase) << 8)); + VSYNC_WR_MPEG_REG( + VPP_VSC_INI_PHASE + cur_dev->vpp_off, + ((u32) (vphase->phase) << 8)); - if (vphase->repeat_skip >= 0) { - /* skip lines */ - VSYNC_WR_MPEG_REG_BITS(VPP_VSC_PHASE_CTRL + + if (vphase->repeat_skip >= 0) { + /* skip lines */ + VSYNC_WR_MPEG_REG_BITS(VPP_VSC_PHASE_CTRL + cur_dev->vpp_off, skip_tab[vphase->repeat_skip], VPP_PHASECTL_INIRCVNUMT_BIT, VPP_PHASECTL_INIRCVNUM_WID + VPP_PHASECTL_INIRPTNUM_WID); - - } else { - /* repeat first line */ - VSYNC_WR_MPEG_REG_BITS(VPP_VSC_PHASE_CTRL + + } else { + /* repeat first line */ + VSYNC_WR_MPEG_REG_BITS(VPP_VSC_PHASE_CTRL + cur_dev->vpp_off, 4, VPP_PHASECTL_INIRCVNUMT_BIT, VPP_PHASECTL_INIRCVNUM_WID); - VSYNC_WR_MPEG_REG_BITS(VPP_VSC_PHASE_CTRL + + VSYNC_WR_MPEG_REG_BITS(VPP_VSC_PHASE_CTRL + cur_dev->vpp_off, 1 - vphase->repeat_skip, VPP_PHASECTL_INIRPTNUMT_BIT, VPP_PHASECTL_INIRPTNUM_WID); + } + if (force_3d_scaler == 3 && + cur_frame_par && + cur_frame_par->vpp_3d_scale) { + VSYNC_WR_MPEG_REG_BITS( + VPP_VSC_PHASE_CTRL, 3, + VPP_PHASECTL_DOUBLELINE_BIT, 2); + } else if (force_3d_scaler == 1 && + cur_frame_par && + cur_frame_par->vpp_3d_scale) { + VSYNC_WR_MPEG_REG_BITS( + VPP_VSC_PHASE_CTRL, 1, + VPP_PHASECTL_DOUBLELINE_BIT, + VPP_PHASECTL_DOUBLELINE_WID); + } else if (force_3d_scaler == 2 && + cur_frame_par && + cur_frame_par->vpp_3d_scale) { + VSYNC_WR_MPEG_REG_BITS( + VPP_VSC_PHASE_CTRL, 2, + VPP_PHASECTL_DOUBLELINE_BIT, 2); + } else { + VSYNC_WR_MPEG_REG_BITS( + VPP_VSC_PHASE_CTRL, 0, + VPP_PHASECTL_DOUBLELINE_BIT, 2); + } + } +#ifdef VIDEO_PIP + if (pip_frame_ready_to_set) + curpip_frame_par = nextpip_frame_par; + + if (cur_pipbuf) { + int need_afbc = (cur_pipbuf->type & VIDTYPE_COMPRESS); + int afbc_need_reset = + video2_enabled && + need_afbc && + (!(READ_VCBUS_REG(VD2_AFBC_ENABLE) & 0x100)); + /*video on && afbc is off && is compress frame.*/ + if (pip_frame_ready_to_set || afbc_need_reset) + pip_set_dcu(curpip_frame_par, cur_pipbuf); + + if (cur_pipbuf && curpip_frame_par) { + if (curpip_frame_par->hscale_skip_count) { + VSYNC_WR_MPEG_REG_BITS( + VIU_VD2_FMT_CTRL + + cur_dev->viu_off, 1, 20, 1); + /* HFORMATTER_EN */ } - if (platform_type == 1) { - if (force_3d_scaler == 3 && - cur_frame_par && - cur_frame_par->vpp_3d_scale) { - VSYNC_WR_MPEG_REG_BITS( - VPP_VSC_PHASE_CTRL, 3, - VPP_PHASECTL_DOUBLELINE_BIT, 2); - } else if (force_3d_scaler == 1 && - cur_frame_par && - cur_frame_par->vpp_3d_scale) { - VSYNC_WR_MPEG_REG_BITS( - VPP_VSC_PHASE_CTRL, 1, - VPP_PHASECTL_DOUBLELINE_BIT, - VPP_PHASECTL_DOUBLELINE_WID); - } else if (force_3d_scaler == 2 && - cur_frame_par && - cur_frame_par->vpp_3d_scale) { - VSYNC_WR_MPEG_REG_BITS( - VPP_VSC_PHASE_CTRL, 2, - VPP_PHASECTL_DOUBLELINE_BIT, 2); - } else { - VSYNC_WR_MPEG_REG_BITS( - VPP_VSC_PHASE_CTRL, 0, - VPP_PHASECTL_DOUBLELINE_BIT, 2); - } + proc_vd2_vsc_phase_per_vsync( + curpip_frame_par, cur_pipbuf, vout_type); + } + } + + if (pip_frame_ready_to_set) { +#if 0 + u32 h_size, v_size; + + if (pip_start_x_lines < pip_end_x_lines) + h_size = pip_end_x_lines - pip_start_x_lines + 1; + else + h_size = ori2_end_x_lines - ori2_start_x_lines + 1; + + if (pip_start_y_lines < pip_end_y_lines) + v_size = pip_end_y_lines - pip_start_y_lines + 1; + else + v_size = ori2_end_y_lines - ori2_start_y_lines + 1; + + zoom2_start_x_lines = ori2_start_x_lines; + zoom2_end_x_lines = ori2_end_x_lines; + zoom2_start_y_lines = ori2_start_y_lines; + zoom2_end_y_lines = ori2_end_y_lines; + + if (h_size < (zoom2_end_x_lines - zoom2_start_x_lines + 1)) + zoom2_end_x_lines = zoom2_start_x_lines + h_size - 1; + else if (h_size > (zoom2_end_x_lines - zoom2_start_x_lines + 1)) + h_size = zoom2_end_x_lines - zoom2_start_x_lines + 1; + + if (v_size < (zoom2_end_y_lines - zoom2_start_y_lines + 1)) + zoom2_end_y_lines = zoom2_start_y_lines + v_size - 1; + else if (v_size > (zoom2_end_y_lines - zoom2_start_y_lines + 1)) + v_size = (zoom2_end_y_lines - zoom2_start_y_lines + 1); + + if (vinfo) { + if (pip_start_x_lines + h_size > vinfo->width) { + h_size = vinfo->width - pip_start_x_lines; + zoom2_end_x_lines = + zoom2_start_x_lines + h_size - 1; + } + if (pip_start_y_lines + v_size > vinfo->height) { + v_size = vinfo->height - pip_start_y_lines; + zoom2_end_y_lines = + zoom2_start_y_lines + v_size - 1; + } + } +#endif + struct scaler_setting_s local_pps; + struct blend_setting_s local_blend; + struct vpp_frame_par_s *par = curpip_frame_par; + + if (cur_pipbuf->type & VIDTYPE_INTERLACE) { + if (cur_pipbuf->type & VIDTYPE_VIU_FIELD) { + zoom2_start_y_lines = + par->VPP_vd_start_lines_ >> 1; + zoom2_end_y_lines = + ((par->VPP_vd_end_lines_ + 1) + >> 1) - 1; + } else { + zoom2_start_y_lines = + par->VPP_vd_start_lines_; + zoom2_end_y_lines = + par->VPP_vd_end_lines_; + } + } else { + if (cur_pipbuf->type & VIDTYPE_VIU_FIELD) { + zoom2_start_y_lines = + par->VPP_vd_start_lines_; + zoom2_end_y_lines = + par->VPP_vd_end_lines_; + } else { + zoom2_start_y_lines = + par->VPP_vd_start_lines_ >> 1; + zoom2_end_y_lines = + ((par->VPP_vd_end_lines_ + 1) + >> 1) - 1; } } + zoom2_start_x_lines = + par->VPP_hd_start_lines_; + zoom2_end_x_lines = + par->VPP_hd_end_lines_; + config_vd_pps( + 1, par, &local_pps, vinfo); + config_vd_blend( + 1, par, cur_pipbuf, + (legacy_vpp ? 0x1ff : 0x100), &local_blend); + vd2_scaler_setting(&local_pps); + vd2_zoom_display_horz( + cur_pipbuf, + par->hscale_skip_count); + vd2_zoom_display_vert( + cur_pipbuf, + par->vscale_skip_count); + vd2_vpp_blend_setting(&local_blend); + pip_frame_ready_to_set = 0; } +#endif if (((frame_par_ready_to_set) || (frame_par_force_to_set)) && (cur_frame_par)) { @@ -6154,8 +6946,10 @@ SET_FILTER: zoom2_end_y_lines = ori2_end_y_lines; correct_vd2_mif_size_for_DV( cur_frame_par, cur_dispbuf); - vd2_zoom_display_horz(cur_dispbuf2, 0); - vd2_zoom_display_vert(cur_dispbuf2); + vd2_zoom_display_horz(cur_dispbuf2, + cur_frame_par->hscale_skip_count); + vd2_zoom_display_vert(cur_dispbuf2, + cur_frame_par->vscale_skip_count); } } /*vpp input size setting*/ @@ -6435,6 +7229,17 @@ SET_FILTER: (VPP_OSD1_POSTBLEND | VPP_OSD2_POSTBLEND)) vpp_misc_set |= VPP_POSTBLEND_EN; } + +#ifdef VIDEO_PIP + if (cur_pipbuf && (video2_enabled == 1) + && ((vpp_misc_save & VPP_VD2_POSTBLEND) == 0) + && (video2_onoff_state == VIDEO_ENABLE_STATE_IDLE)) { + vpp_misc_set |= + VPP_VD2_POSTBLEND | + VPP_POSTBLEND_EN; + } +#endif + if ((video_enabled == 1) && ((vpp_misc_save & VPP_VD1_POSTBLEND) == 0) && (video_onoff_state == VIDEO_ENABLE_STATE_IDLE)) { vpp_misc_set |= @@ -6455,7 +7260,7 @@ SET_FILTER: VPP_VSC_START_PHASE_STEP + cur_dev->vpp_off); if ((vpp_filter->vpp_hf_start_phase_step != h_phase_step) || (vpp_filter->vpp_vsc_start_phase_step != v_phase_step)) { - video_property_changed = true; + video_property_changed = 1; /*pr_info("frame info register rdma write fail!\n");*/ } } @@ -6533,7 +7338,13 @@ SET_FILTER: else vpp_misc_set |= VPP_VD2_PREBLEND | VPP_PREBLEND_EN; - +#ifdef VIDEO_PIP + if (cur_pipbuf) { + vpp_misc_set &= + ~(VPP_PREBLEND_EN | VPP_VD2_PREBLEND); + vpp_misc_set |= VPP_VD2_POSTBLEND; + } +#endif /* g12a has no alpha overflow check in hardware */ if (!legacy_vpp) vpp_misc_set |= (0x100 << VPP_VD2_ALPHA_BIT); @@ -6546,7 +7357,8 @@ SET_FILTER: pr_info("VsyncEnableVideoLayer2\n"); } else if (video2_onoff_state == VIDEO_ENABLE_STATE_OFF_REQ) { vpp_misc_set &= ~(VPP_VD2_PREBLEND | - VPP_VD2_POSTBLEND | VPP_PREBLEND_EN); + VPP_VD2_POSTBLEND | VPP_PREBLEND_EN + | (0x1ff << VPP_VD2_ALPHA_BIT)); video2_onoff_state = VIDEO_ENABLE_STATE_IDLE; video_onoff_time = jiffies_to_msecs(jiffies); @@ -6564,6 +7376,11 @@ SET_FILTER: VPP_VD2_POSTBLEND | VPP_VD1_POSTBLEND | VPP_PREBLEND_EN); +#ifdef VIDEO_PIP + /* should keep video2 display */ + if (cur_pipbuf && video2_enabled) + vpp_misc_set |= VPP_VD2_POSTBLEND; +#endif } else { video_enabled = video_status_saved; } @@ -6571,11 +7388,24 @@ SET_FILTER: if (!video_enabled && (vpp_misc_set & VPP_VD1_POSTBLEND)) vpp_misc_set &= ~(VPP_VD1_PREBLEND | - VPP_VD2_PREBLEND | - VPP_VD2_POSTBLEND | VPP_VD1_POSTBLEND | VPP_PREBLEND_EN); +#ifdef VIDEO_PIP + if (pip_global_output == 0) { + video2_enabled = 0; + vpp_misc_set &= ~(VPP_VD2_PREBLEND | + VPP_VD2_POSTBLEND); + } else { + video2_enabled = video2_status_saved; + } + + if (!video2_enabled && + (vpp_misc_set & VPP_VD2_POSTBLEND)) + vpp_misc_set &= ~(VPP_VD2_PREBLEND | + VPP_VD2_POSTBLEND); +#endif + if (!legacy_vpp) { u32 set_value = 0; @@ -6589,6 +7419,14 @@ SET_FILTER: VPP_PREBLEND_EN | VPP_POSTBLEND_EN | 0xf); + + /* if vd2 is bottom layer, need remove alpha for vd2 */ + if (((vpp_misc_set & VPP_VD1_POSTBLEND) == 0) + && (vpp_misc_set & VPP_VD2_POSTBLEND)) { + vpp_misc_set &= ~(0x1ff << VPP_VD2_ALPHA_BIT); + vpp_misc_set |= (0x100 << VPP_VD2_ALPHA_BIT); + } + vpp_misc_save &= ((1 << 29) | VPP_CM_ENABLE | (0x1ff << VPP_VD2_ALPHA_BIT) | @@ -6615,7 +7453,7 @@ SET_FILTER: if (vpp_misc_set & VPP_VD2_POSTBLEND) set_value = ((1 << 20) | - (1 << 16) | /* post bld premult*/ + (0 << 16) | /* post bld premult*/ (2 << 8)); /* post src */ else if (vpp_misc_set & VPP_VD2_PREBLEND) set_value = @@ -6624,6 +7462,7 @@ SET_FILTER: VSYNC_WR_MPEG_REG( VD2_BLEND_SRC_CTRL + cur_dev->vpp_off, set_value); + set_value = vpp_misc_set; set_value &= ((1 << 29) | VPP_CM_ENABLE | @@ -6650,6 +7489,37 @@ SET_FILTER: /*vpp_misc_set maybe have same,but need off.*/ /* if vd1 off, disable vd2 also */ +#ifdef VIDEO_PIP + if (video2_off_req && cur_pipbuf) { + if ((debug_flag & DEBUG_FLAG_BLACKOUT) + && video2_off_req) + pr_info("VD2 AFBC off now.\n"); + VSYNC_WR_MPEG_REG(VD2_AFBC_ENABLE, 0); + VSYNC_WR_MPEG_REG(VD2_IF0_GEN_REG, 0); + if (!legacy_vpp) { + VSYNC_WR_MPEG_REG( + VD2_BLEND_SRC_CTRL + cur_dev->vpp_off, 0); + } + if (cur_pipbuf && (cur_pipbuf == &local_pip)) + cur_pipbuf = NULL; + } else if (!cur_pipbuf && + (video2_off_req || video1_off_req)) { + if ((debug_flag & DEBUG_FLAG_BLACKOUT) + && video2_off_req) + pr_info("VD2 AFBC off now.\n"); + VSYNC_WR_MPEG_REG(VD2_AFBC_ENABLE, 0); + VSYNC_WR_MPEG_REG(VD2_IF0_GEN_REG, 0); + if (!legacy_vpp) { + VSYNC_WR_MPEG_REG( + VD2_BLEND_SRC_CTRL + cur_dev->vpp_off, 0); + } + last_el_w = 0; + last_el_status = 0; + if (cur_dispbuf2 && (cur_dispbuf2 == &vf_local2)) + cur_dispbuf2 = NULL; + need_disable_vd2 = false; + } +#else if (video2_off_req || video1_off_req) { if ((debug_flag & DEBUG_FLAG_BLACKOUT) && video2_off_req) @@ -6667,6 +7537,8 @@ SET_FILTER: cur_dispbuf2 = NULL; need_disable_vd2 = false; } +#endif + if (video1_off_req) { /* * video layer off, swith off afbc, @@ -6697,6 +7569,9 @@ SET_FILTER: } #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA cur_rdma_buf = cur_dispbuf; +#ifdef VIDEO_PIP + pip_rdma_buf = cur_pipbuf; +#endif /* vsync_rdma_config(); */ vsync_rdma_process(); if (debug_flag & DEBUG_FLAG_PRINT_RDMA) { @@ -6840,7 +7715,9 @@ int get_current_vscale_skip_count(struct vframe_s *vf) int ret = 0; static struct vpp_frame_par_s frame_par; - vpp_set_filters(process_3d_type, wide_setting, vf, &frame_par, vinfo, + vpp_set_filters( + &glayer_info[0], + vf, &frame_par, vinfo, (is_dolby_vision_on() && is_dolby_vision_stb_mode())); ret = frame_par.vscale_skip_count; @@ -6917,9 +7794,30 @@ static void video_vf_unreg_provider(void) vsync_freerun = 0; vsync_pts_align = 0; vsync_pts_aligned = false; - video_prot.video_started = 0; + +#ifdef VIDEO_PIP + if (pip_loop) { +#ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA + pipbuf_to_put = NULL; + pip_rdma_buf = NULL; +#endif + if (cur_pipbuf) { + local_pip = *cur_pipbuf; + cur_pipbuf = &local_pip; + cur_pipbuf->video_angle = 0; + } + pip_frame_count = 0; + } +#endif spin_unlock_irqrestore(&lock, flags); +#ifdef VIDEO_PIP + if (pip_loop) { + disable_videopip = VIDEO_DISABLE_FORNEXT; + DisableVideoLayer2(); + } +#endif + if (blackout | force_blackout) { safe_disble_videolayer(); try_free_keep_video(1); @@ -7029,10 +7927,16 @@ static int get_display_info(void *data) s32 w, h, x, y; struct vdisplay_info_s *info_para = (struct vdisplay_info_s *)data; const struct vinfo_s *info = get_current_vinfo(); + struct disp_info_s *layer = &glayer_info[0]; if ((!cur_frame_par) || (!info)) return -1; - vpp_get_video_layer_position(&x, &y, &w, &h); + + x = layer->layer_left; + y = layer->layer_top; + w = layer->layer_width; + h = layer->layer_height; + if ((w == 0) || (w > info->width)) w = info->width; if ((h == 0) || (h > info->height)) @@ -7148,25 +8052,68 @@ static int video_receiver_event_fun(int type, void *data, void *private_data) #endif } else if (type == VFRAME_EVENT_PROVIDER_QUREY_DISPLAY_INFO) { get_display_info(data); - } + } else if (type == VFRAME_EVENT_PROVIDER_PROPERTY_CHANGED) + video_property_changed = 1; return 0; } -static int video4osd_receiver_event_fun(int type, void *data, - void *private_data) +#ifdef VIDEO_PIP +static void pip_vf_unreg_provider(void) { - if (type == VFRAME_EVENT_PROVIDER_UNREG) { - osd_prov = NULL; - if (debug_flag & DEBUG_FLAG_BLACKOUT) - pr_info("[video4osd] clear osd_prov\n"); - } else if (type == VFRAME_EVENT_PROVIDER_REG) { - osd_prov = vf_get_provider(RECEIVER4OSD_NAME); + ulong flags; - if (debug_flag & DEBUG_FLAG_BLACKOUT) - pr_info("[video4osd] set osd_prov\n"); + /* atomic_set(&video_unreg_flag, 1); */ + while (atomic_read(&video_inirq_flag) > 0) + schedule(); + spin_lock_irqsave(&lock, flags); + +#ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA + pipbuf_to_put = NULL; + pip_rdma_buf = NULL; +#endif + if (cur_pipbuf) { + local_pip = *cur_pipbuf; + cur_pipbuf = &local_pip; + cur_pipbuf->video_angle = 0; + } + pip_frame_count = 0; + spin_unlock_irqrestore(&lock, flags); + + disable_videopip = VIDEO_DISABLE_FORNEXT; + DisableVideoLayer2(); +} + +static void pip_vf_light_unreg_provider(void) +{ + ulong flags; + + spin_lock_irqsave(&lock, flags); +#ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA + pipbuf_to_put = NULL; + pip_rdma_buf = NULL; +#endif + + if (cur_pipbuf) { + local_pip = *cur_pipbuf; + cur_pipbuf = &local_pip; } + spin_unlock_irqrestore(&lock, flags); +} + +static int pip_receiver_event_fun( + int type, void *data, void *private_data) +{ + if (type == VFRAME_EVENT_PROVIDER_UNREG) + pip_vf_unreg_provider(); + else if (type == VFRAME_EVENT_PROVIDER_RESET) + pip_vf_light_unreg_provider(); + else if (type == VFRAME_EVENT_PROVIDER_LIGHT_UNREG) + pip_vf_light_unreg_provider(); + else if (type == VFRAME_EVENT_PROVIDER_REG) + pip_vf_light_unreg_provider(); return 0; } +#endif unsigned int get_post_canvas(void) { @@ -7216,33 +8163,49 @@ int _video_set_disable(u32 val) if ((disable_video == VIDEO_DISABLE_FORNEXT) && cur_dispbuf && (cur_dispbuf != &vf_local)) - video_property_changed = true; + video_property_changed = 1; try_free_keep_video(0); } else { if (cur_dispbuf && (cur_dispbuf != &vf_local)) { EnableVideoLayer(); - video_property_changed = true; + video_property_changed = 1; } } return 0; } -static void _set_video_crop(int *p) +static void _set_video_crop( + struct disp_info_s *layer, int *p) { int last_l, last_r, last_t, last_b; int new_l, new_r, new_t, new_b; - vpp_get_video_source_crop(&last_t, &last_l, &last_b, &last_r); - vpp_set_video_source_crop(p[0], p[1], p[2], p[3]); - vpp_get_video_source_crop(&new_t, &new_l, &new_b, &new_r); + if (!layer) + return; + + last_t = layer->crop_top; + last_l = layer->crop_left; + last_b = layer->crop_bottom; + last_r = layer->crop_right; + + new_t = layer->crop_top = p[0]; + new_l = layer->crop_left = p[1]; + new_b = layer->crop_bottom = p[2]; + new_r = layer->crop_right = p[3]; if ((new_t != last_t) || (new_l != last_l) - || (new_b != last_b) || (new_r != last_r)) { - video_property_changed = true; + || (new_b != last_b) || (new_r != last_r)) { + if (layer->layer_id == 0) + video_property_changed = 1; +#ifdef VIDEO_PIP + else if (layer->layer_id == 1) + pip_property_changed = 1; +#endif } } -static void _set_video_window(int *p) +static void _set_video_window( + struct disp_info_s *layer, int *p) { int w, h; int *parsed = p; @@ -7251,10 +8214,13 @@ static void _set_video_window(int *p) #ifdef TV_REVERSE int temp, temp1; const struct vinfo_s *info = get_current_vinfo(); +#endif - /* pr_info(KERN_DEBUG "%s: %u*/ - /*get vinfo(%d,%d).\n", __func__, __LINE__,*/ - /*info->width, info->height); */ + if (!layer) + return; + +#ifdef TV_REVERSE + /* FIXME: use layer info */ if (reverse) { temp = parsed[0]; temp1 = parsed[1]; @@ -7264,7 +8230,12 @@ static void _set_video_window(int *p) parsed[3] = info->height - temp1 - 1; } #endif - vpp_get_video_layer_position(&last_x, &last_y, &last_w, &last_h); + + last_x = layer->layer_left; + last_y = layer->layer_top; + last_w = layer->layer_width; + last_h = layer->layer_height; + if (parsed[0] < 0 && parsed[2] < 2) { parsed[2] = 2; parsed[0] = 0; @@ -7294,19 +8265,31 @@ static void _set_video_window(int *p) } else #endif { - if ((w == 1) && (h == 1)) { - w = h = 0; - vpp_set_video_layer_position(parsed[0], parsed[1], 0, - 0); - } else if ((w > 0) && (h > 0)) { - vpp_set_video_layer_position(parsed[0], parsed[1], w, - h); + if ((w > 0) && (h > 0)) { + if ((w == 1) && (h == 1)) { + w = 0; + h = 0; + } + layer->layer_left = parsed[0]; + layer->layer_top = parsed[1]; + layer->layer_width = w; + layer->layer_height = h; } } - vpp_get_video_layer_position(&new_x, &new_y, &new_w, &new_h); + + new_x = layer->layer_left; + new_y = layer->layer_top; + new_w = layer->layer_width; + new_h = layer->layer_height; + if ((last_x != new_x) || (last_y != new_y) - || (last_w != new_w) || (last_h != new_h)) { - video_property_changed = true; + || (last_w != new_w) || (last_h != new_h)) { + if (layer->layer_id == 0) + video_property_changed = 1; +#ifdef VIDEO_PIP + else if (layer->layer_id == 1) + pip_property_changed = 1; +#endif } } #if ENABLE_UPDATE_HDR_FROM_USER @@ -7431,6 +8414,47 @@ static void set_omx_pts(u32 *p) mutex_unlock(&omx_mutex); } +static int alloc_layer(u32 layer_id) +{ + int ret = -EINVAL; + + if (layer_id == 0) { + if (layer_cap & LAYER0_BUSY) { + ret = -EBUSY; + } else if (layer_cap & LAYER0_AVAIL) { + ret = 0; + layer_cap |= LAYER0_BUSY; + } + } else if (layer_id == 1) { + if (layer_cap & LAYER1_BUSY) { + ret = -EBUSY; + } else if (layer_cap & LAYER1_AVAIL) { + ret = 0; + layer_cap |= LAYER1_BUSY; + } + } + return ret; +} + +static int free_layer(u32 layer_id) +{ + int ret = -EINVAL; + + if (layer_id == 0) { + if ((layer_cap & LAYER0_BUSY) + && (layer_cap & LAYER0_AVAIL)) { + ret = 0; + layer_cap &= ~LAYER0_BUSY; + } + } else if (layer_id == 1) { + if ((layer_cap & LAYER1_BUSY) + && (layer_cap & LAYER1_AVAIL)) { + ret = 0; + layer_cap &= ~LAYER1_BUSY; + } + } + return ret; +} /********************************************************* * /dev/amvideo APIs @@ -7438,29 +8462,25 @@ static void set_omx_pts(u32 *p) */ static int amvideo_open(struct inode *inode, struct file *file) { + file->private_data = NULL; return 0; } static int amvideo_poll_open(struct inode *inode, struct file *file) { + file->private_data = NULL; return 0; } static int amvideo_release(struct inode *inode, struct file *file) { - if (blackout | force_blackout) { - /* DisableVideoLayer();*/ - /*don't need it ,it have problem on pure music playing */ - } + file->private_data = NULL; return 0; } static int amvideo_poll_release(struct inode *inode, struct file *file) { - if (blackout | force_blackout) { - /* DisableVideoLayer();*/ - /*don't need it ,it have problem on pure music playing */ - } + file->private_data = NULL; return 0; } @@ -7468,6 +8488,30 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) { long ret = 0; void __user *argp = (void __user *)arg; + struct disp_info_s *layer = &glayer_info[0]; + u32 layer_id; + + switch (cmd) { + case AMSTREAM_IOC_GLOBAL_SET_VIDEOPIP_OUTPUT: + case AMSTREAM_IOC_GLOBAL_GET_VIDEOPIP_OUTPUT: + case AMSTREAM_IOC_GET_VIDEOPIP_DISABLE: + case AMSTREAM_IOC_SET_VIDEOPIP_DISABLE: + case AMSTREAM_IOC_GET_VIDEOPIP_AXIS: + case AMSTREAM_IOC_SET_VIDEOPIP_AXIS: + case AMSTREAM_IOC_GET_VIDEOPIP_CROP: + case AMSTREAM_IOC_SET_VIDEOPIP_CROP: + case AMSTREAM_IOC_GET_PIP_SCREEN_MODE: + case AMSTREAM_IOC_SET_PIP_SCREEN_MODE: + case AMSTREAM_IOC_GET_PIP_ZORDER: + case AMSTREAM_IOC_SET_PIP_ZORDER: + layer = &glayer_info[1]; + break; + default: + break; + } + + if (file->private_data) + layer = (struct disp_info_s *)file->private_data; switch (cmd) { case AMSTREAM_IOC_SET_HDR_INFO:{ @@ -7582,19 +8626,32 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) } break; + case AMSTREAM_IOC_GET_VIDEOPIP_DISABLE: case AMSTREAM_IOC_GET_VIDEO_DISABLE: - put_user(disable_video, (u32 __user *)argp); + if (layer->layer_id == 0) + put_user(disable_video, (u32 __user *)argp); +#ifdef VIDEO_PIP + else if (layer->layer_id == 1) + put_user(disable_videopip, (u32 __user *)argp); +#endif break; - case AMSTREAM_IOC_SET_VIDEO_DISABLE:{ - u32 val; + case AMSTREAM_IOC_SET_VIDEOPIP_DISABLE: + case AMSTREAM_IOC_SET_VIDEO_DISABLE: + { + u32 val; - if (copy_from_user(&val, argp, sizeof(u32)) == 0) - ret = _video_set_disable(val); - else - ret = -EFAULT; + if (copy_from_user(&val, argp, sizeof(u32)) == 0) { + if (layer->layer_id == 0) + ret = _video_set_disable(val); +#ifdef VIDEO_PIP + else if (layer->layer_id == 1) + ret = _videopip_set_disable(val); +#endif + } else + ret = -EFAULT; + } break; - } case AMSTREAM_IOC_GET_VIDEO_DISCONTINUE_REPORT: put_user(enable_video_discontinue_report, (u32 __user *)argp); @@ -7604,10 +8661,12 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) enable_video_discontinue_report = (arg == 0) ? 0 : 1; break; - case AMSTREAM_IOC_GET_VIDEO_AXIS:{ + case AMSTREAM_IOC_GET_VIDEOPIP_AXIS: + case AMSTREAM_IOC_GET_VIDEO_AXIS: + { int axis[4]; #ifdef CONFIG_AMLOGIC_POST_PROCESS_MANAGER_PPSCALER - if (video_scaler_mode) { + if (video_scaler_mode && (layer->layer_id == 0)) { axis[0] = content_left; axis[1] = content_top; axis[2] = content_w; @@ -7615,10 +8674,10 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) } else #endif { - vpp_get_video_layer_position( - &axis[0], &axis[1], - &axis[2], - &axis[3]); + axis[0] = layer->layer_left; + axis[1] = layer->layer_top; + axis[2] = layer->layer_width; + axis[3] = layer->layer_height; } axis[2] = axis[0] + axis[2] - 1; @@ -7629,21 +8688,27 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) } break; - case AMSTREAM_IOC_SET_VIDEO_AXIS:{ + case AMSTREAM_IOC_SET_VIDEOPIP_AXIS: + case AMSTREAM_IOC_SET_VIDEO_AXIS: + { int axis[4]; if (copy_from_user(axis, argp, sizeof(axis)) == 0) - _set_video_window(axis); + _set_video_window(layer, axis); else ret = -EFAULT; } break; - case AMSTREAM_IOC_GET_VIDEO_CROP:{ + case AMSTREAM_IOC_GET_VIDEOPIP_CROP: + case AMSTREAM_IOC_GET_VIDEO_CROP: + { int crop[4]; { - vpp_get_video_source_crop(&crop[0], &crop[1], - &crop[2], &crop[3]); + crop[0] = layer->crop_top; + crop[1] = layer->crop_left; + crop[2] = layer->crop_bottom; + crop[3] = layer->crop_right; } if (copy_to_user(argp, &crop[0], sizeof(crop)) != 0) @@ -7651,30 +8716,40 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) } break; - case AMSTREAM_IOC_SET_VIDEO_CROP:{ + case AMSTREAM_IOC_SET_VIDEOPIP_CROP: + case AMSTREAM_IOC_SET_VIDEO_CROP: + { int crop[4]; if (copy_from_user(crop, argp, sizeof(crop)) == 0) - _set_video_crop(crop); + _set_video_crop(layer, crop); else ret = -EFAULT; } break; + case AMSTREAM_IOC_GET_PIP_SCREEN_MODE: case AMSTREAM_IOC_GET_SCREEN_MODE: - if (copy_to_user(argp, &wide_setting, sizeof(u32)) != 0) + if (copy_to_user(argp, &layer->wide_mode, sizeof(u32)) != 0) ret = -EFAULT; break; - case AMSTREAM_IOC_SET_SCREEN_MODE:{ + case AMSTREAM_IOC_SET_PIP_SCREEN_MODE: + case AMSTREAM_IOC_SET_SCREEN_MODE: + { u32 mode; if (copy_from_user(&mode, argp, sizeof(u32)) == 0) { if (mode >= VIDEO_WIDEOPTION_MAX) ret = -EINVAL; - else if (mode != wide_setting) { - wide_setting = mode; - video_property_changed = true; + else if (mode != layer->wide_mode) { + layer->wide_mode = mode; + if (layer->layer_id == 0) + video_property_changed = 1; +#ifdef VIDEO_PIP + else if (layer->layer_id == 1) + pip_property_changed = 1; +#endif } } else ret = -EFAULT; @@ -7748,7 +8823,7 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) process_3d_type = type; if (mvc_flag) process_3d_type |= MODE_3D_MVC; - video_property_changed = true; + video_property_changed = 1; if ((process_3d_type & MODE_3D_FA) && cur_dispbuf && !cur_dispbuf->trans_fmt) @@ -7801,15 +8876,32 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) vsync_slow_factor = arg; break; + case AMSTREAM_IOC_GLOBAL_SET_VIDEOPIP_OUTPUT: case AMSTREAM_IOC_GLOBAL_SET_VIDEO_OUTPUT: - if (arg != 0) - video_global_output = 1; - else - video_global_output = 0; + if (layer->layer_id == 0) { + if (arg != 0) + video_global_output = 1; + else + video_global_output = 0; + } +#ifdef VIDEO_PIP + else if (layer->layer_id == 1) { + if (arg != 0) + pip_global_output = 1; + else + pip_global_output = 0; + } +#endif break; + case AMSTREAM_IOC_GLOBAL_GET_VIDEOPIP_OUTPUT: case AMSTREAM_IOC_GLOBAL_GET_VIDEO_OUTPUT: - put_user(video_global_output, (u32 __user *)argp); + if (layer->layer_id == 0) + put_user(video_global_output, (u32 __user *)argp); +#ifdef VIDEO_PIP + else if (layer->layer_id == 1) + put_user(pip_global_output, (u32 __user *)argp); +#endif break; case AMSTREAM_IOC_GET_VIDEO_LAYER1_ON: { @@ -7838,6 +8930,54 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg) videopeek = true; nopostvideostart = true; break; + + case AMSTREAM_IOC_GET_PIP_ZORDER: + case AMSTREAM_IOC_GET_ZORDER: + break; + + case AMSTREAM_IOC_SET_PIP_ZORDER: + case AMSTREAM_IOC_SET_ZORDER: + break; + + case AMSTREAM_IOC_QUERY_LAYER: + mutex_lock(&video_layer_mutex); + put_user(layer_cap, (u32 __user *)argp); + mutex_unlock(&video_layer_mutex); + ret = 0; + break; + + case AMSTREAM_IOC_ALLOC_LAYER: + if (copy_from_user(&layer_id, argp, sizeof(u32)) == 0) { + if (layer_id >= MAX_VD_LAYERS) { + ret = -EINVAL; + } else { + mutex_lock(&video_layer_mutex); + if (file->private_data) { + ret = -EBUSY; + } else { + ret = alloc_layer(layer_id); + if (!ret) + file->private_data = + (void *)&glayer_info[layer_id]; + } + mutex_unlock(&video_layer_mutex); + } + } else + ret = -EFAULT; + break; + + case AMSTREAM_IOC_FREE_LAYER: + mutex_lock(&video_layer_mutex); + if (!file->private_data) { + ret = -EINVAL; + } else { + ret = free_layer(layer->layer_id); + if (!ret) + file->private_data = NULL; + } + mutex_unlock(&video_layer_mutex); + break; + default: return -EINVAL; } @@ -7879,6 +9019,23 @@ static long amvideo_compat_ioctl(struct file *file, unsigned int cmd, ulong arg) case AMSTREAM_IOC_GET_VSYNC_SLOW_FACTOR: case AMSTREAM_IOC_GLOBAL_GET_VIDEO_OUTPUT: case AMSTREAM_IOC_GET_VIDEO_LAYER1_ON: + case AMSTREAM_IOC_GLOBAL_SET_VIDEOPIP_OUTPUT: + case AMSTREAM_IOC_GLOBAL_GET_VIDEOPIP_OUTPUT: + case AMSTREAM_IOC_GET_VIDEOPIP_DISABLE: + case AMSTREAM_IOC_SET_VIDEOPIP_DISABLE: + case AMSTREAM_IOC_GET_VIDEOPIP_AXIS: + case AMSTREAM_IOC_SET_VIDEOPIP_AXIS: + case AMSTREAM_IOC_GET_VIDEOPIP_CROP: + case AMSTREAM_IOC_SET_VIDEOPIP_CROP: + case AMSTREAM_IOC_GET_PIP_SCREEN_MODE: + case AMSTREAM_IOC_SET_PIP_SCREEN_MODE: + case AMSTREAM_IOC_GET_PIP_ZORDER: + case AMSTREAM_IOC_SET_PIP_ZORDER: + case AMSTREAM_IOC_GET_ZORDER: + case AMSTREAM_IOC_SET_ZORDER: + case AMSTREAM_IOC_QUERY_LAYER: + case AMSTREAM_IOC_ALLOC_LAYER: + case AMSTREAM_IOC_FREE_LAYER: arg = (unsigned long) compat_ptr(arg); case AMSTREAM_IOC_TRICKMODE: case AMSTREAM_IOC_VPAUSE: @@ -8000,12 +9157,13 @@ static int parse_para(const char *para, int para_num, int *result) return count; } -static void set_video_crop(const char *para) +static void set_video_crop( + struct disp_info_s *layer, const char *para) { int parsed[4]; if (likely(parse_para(para, 4, parsed) == 4)) - _set_video_crop(parsed); + _set_video_crop(layer, parsed); amlog_mask(LOG_MASK_SYSFS, "video crop=>x0:%d,y0:%d,x1:%d,y1:%d\n ", parsed[0], parsed[1], parsed[2], parsed[3]); @@ -8014,19 +9172,23 @@ static void set_video_crop(const char *para) static void set_video_speed_check(const char *para) { int parsed[2]; + struct disp_info_s *layer = &glayer_info[0]; - if (likely(parse_para(para, 2, parsed) == 2)) - vpp_set_video_speed_check(parsed[0], parsed[1]); + if (likely(parse_para(para, 2, parsed) == 2)) { + layer->speed_check_height = parsed[0]; + layer->speed_check_width = parsed[1]; + } amlog_mask(LOG_MASK_SYSFS, "video speed_check=>h:%d,w:%d\n ", parsed[0], parsed[1]); } -static void set_video_window(const char *para) +static void set_video_window( + struct disp_info_s *layer, const char *para) { int parsed[4]; if (likely(parse_para(para, 4, parsed) == 4)) - _set_video_window(parsed); + _set_video_window(layer, parsed); amlog_mask(LOG_MASK_SYSFS, "video=>x0:%d,y0:%d,x1:%d,y1:%d\n ", parsed[0], parsed[1], parsed[2], parsed[3]); @@ -8039,13 +9201,14 @@ static ssize_t video_3d_scale_store(struct class *cla, #ifdef TV_3D_FUNCTION_OPEN u32 enable; int r; + struct disp_info_s *layer = &glayer_info[0]; r = kstrtouint(buf, 0, &enable); if (r < 0) return -EINVAL; - vpp_set_3d_scale(enable); - video_property_changed = true; + layer->vpp_3d_scale = enable ? true : false; + video_property_changed = 1; amlog_mask(LOG_MASK_SYSFS, "%s:%s 3d scale.\n", __func__, enable ? "enable" : "disable"); #endif @@ -8068,7 +9231,7 @@ static ssize_t video_sr_store(struct class *cla, if (likely(parse_para(buf, 1, parsed) == 1)) { if (super_scaler != (parsed[0] & 0x1)) { super_scaler = parsed[0] & 0x1; - video_property_changed = true; + video_property_changed = 1; } } mutex_unlock(&video_module_mutex); @@ -8080,8 +9243,12 @@ static ssize_t video_crop_show(struct class *cla, struct class_attribute *attr, char *buf) { u32 t, l, b, r; + struct disp_info_s *layer = &glayer_info[0]; - vpp_get_video_source_crop(&t, &l, &b, &r); + t = layer->crop_top; + l = layer->crop_left; + b = layer->crop_bottom; + r = layer->crop_right; return snprintf(buf, 40, "%d %d %d %d\n", t, l, b, r); } @@ -8089,9 +9256,11 @@ static ssize_t video_crop_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { + struct disp_info_s *layer = &glayer_info[0]; + mutex_lock(&video_module_mutex); - set_video_crop(buf); + set_video_crop(layer, buf); mutex_unlock(&video_module_mutex); @@ -8224,6 +9393,8 @@ static ssize_t video_axis_show(struct class *cla, char *buf) { int x, y, w, h; + struct disp_info_s *layer = &glayer_info[0]; + #ifdef CONFIG_AMLOGIC_POST_PROCESS_MANAGER_PPSCALER if (video_scaler_mode) { x = content_left; @@ -8233,7 +9404,10 @@ static ssize_t video_axis_show(struct class *cla, } else #endif { - vpp_get_video_layer_position(&x, &y, &w, &h); + x = layer->layer_left; + y = layer->layer_top; + w = layer->layer_width; + h = layer->layer_height; } return snprintf(buf, 40, "%d %d %d %d\n", x, y, x + w - 1, y + h - 1); } @@ -8242,9 +9416,11 @@ static ssize_t video_axis_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { + struct disp_info_s *layer = &glayer_info[0]; + mutex_lock(&video_module_mutex); - set_video_window(buf); + set_video_window(layer, buf); mutex_unlock(&video_module_mutex); @@ -8255,8 +9431,10 @@ static ssize_t video_global_offset_show(struct class *cla, struct class_attribute *attr, char *buf) { int x, y; + struct disp_info_s *layer = &glayer_info[0]; - vpp_get_global_offset(&x, &y); + x = layer->global_offset_x; + y = layer->global_offset_y; return snprintf(buf, 40, "%d %d\n", x, y); } @@ -8266,12 +9444,14 @@ static ssize_t video_global_offset_store(struct class *cla, const char *buf, size_t count) { int parsed[2]; + struct disp_info_s *layer = &glayer_info[0]; mutex_lock(&video_module_mutex); if (likely(parse_para(buf, 2, parsed) == 2)) { - vpp_set_global_offset(parsed[0], parsed[1]); - video_property_changed = true; + layer->global_offset_x = parsed[0]; + layer->global_offset_y = parsed[1]; + video_property_changed = 1; amlog_mask(LOG_MASK_SYSFS, "video_offset=>x0:%d,y0:%d\n ", @@ -8287,7 +9467,10 @@ static ssize_t video_zoom_show(struct class *cla, struct class_attribute *attr, char *buf) { - u32 r = vpp_get_zoom_ratio(); + u32 r; + struct disp_info_s *layer = &glayer_info[0]; + + r = layer->zoom_ratio; return snprintf(buf, 40, "%d\n", r); } @@ -8298,14 +9481,15 @@ static ssize_t video_zoom_store(struct class *cla, { unsigned long r; int ret = 0; + struct disp_info_s *layer = &glayer_info[0]; ret = kstrtoul(buf, 0, (unsigned long *)&r); if (ret < 0) return -EINVAL; - if ((r <= MAX_ZOOM_RATIO) && (r != vpp_get_zoom_ratio())) { - vpp_set_zoom_ratio(r); - video_property_changed = true; + if ((r <= MAX_ZOOM_RATIO) && (r != layer->zoom_ratio)) { + layer->zoom_ratio = r; + video_property_changed = 1; } return count; @@ -8314,6 +9498,7 @@ static ssize_t video_zoom_store(struct class *cla, static ssize_t video_screen_mode_show(struct class *cla, struct class_attribute *attr, char *buf) { + struct disp_info_s *layer = &glayer_info[0]; static const char * const wide_str[] = { "normal", "full stretch", "4-3", "16-9", "non-linear", "normal-noscaleup", @@ -8322,9 +9507,10 @@ static ssize_t video_screen_mode_show(struct class *cla, "16-9 combined", "Custom AR", "AFD" }; - if (wide_setting < ARRAY_SIZE(wide_str)) { - return sprintf(buf, "%d:%s\n", wide_setting, - wide_str[wide_setting]); + if (layer->wide_mode < ARRAY_SIZE(wide_str)) { + return sprintf(buf, "%d:%s\n", + layer->wide_mode, + wide_str[layer->wide_mode]); } else return 0; } @@ -8335,14 +9521,16 @@ static ssize_t video_screen_mode_store(struct class *cla, { unsigned long mode; int ret = 0; + struct disp_info_s *layer = &glayer_info[0]; ret = kstrtoul(buf, 0, (unsigned long *)&mode); if (ret < 0) return -EINVAL; - if ((mode < VIDEO_WIDEOPTION_MAX) && (mode != wide_setting)) { - wide_setting = mode; - video_property_changed = true; + if ((mode < VIDEO_WIDEOPTION_MAX) + && (mode != layer->wide_mode)) { + layer->wide_mode = mode; + video_property_changed = 1; } return count; @@ -8911,7 +10099,12 @@ static ssize_t video_nonlinear_factor_show(struct class *cla, struct class_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", vpp_get_nonlinear_factor()); + u32 factor; + struct disp_info_s *layer = &glayer_info[0]; + + factor = vpp_get_nonlinear_factor(layer); + + return sprintf(buf, "%d\n", factor); } static ssize_t video_nonlinear_factor_store(struct class *cla, @@ -8920,13 +10113,14 @@ static ssize_t video_nonlinear_factor_store(struct class *cla, { int r; u32 factor; + struct disp_info_s *layer = &glayer_info[0]; r = kstrtoint(buf, 0, &factor); if (r < 0) return -EINVAL; - if (vpp_set_nonlinear_factor(factor) == 0) - video_property_changed = true; + if (vpp_set_nonlinear_factor(layer, factor) == 0) + video_property_changed = 1; return count; } @@ -9026,8 +10220,10 @@ static ssize_t video_speed_check_show(struct class *cla, struct class_attribute *attr, char *buf) { u32 h, w; + struct disp_info_s *layer = &glayer_info[0]; - vpp_get_video_speed_check(&h, &w); + h = layer->speed_check_height; + w = layer->speed_check_width; return snprintf(buf, 40, "%d %d\n", h, w); } @@ -9036,9 +10232,7 @@ static ssize_t video_speed_check_store(struct class *cla, struct class_attribute *attr, const char *buf, size_t count) { - set_video_speed_check(buf); - return strnlen(buf, count); } @@ -9059,7 +10253,7 @@ static ssize_t threedim_mode_store(struct class *cla, process_3d_type = type; if (mvc_flag) process_3d_type |= MODE_3D_MVC; - video_property_changed = true; + video_property_changed = 1; if ((process_3d_type & MODE_3D_FA) && cur_dispbuf && !cur_dispbuf->trans_fmt) /*notify di 3d mode is frame alternative mode,1*/ @@ -9555,11 +10749,11 @@ static ssize_t video_layer1_state_show(struct class *cla, void set_video_angle(u32 s_value) { - if ((s_value <= 3) && (video_angle != s_value)) { - video_angle = s_value; - video_prot.angle_changed = 1; - video_prot.video_started = 1; - pr_info("video_prot angle:%d\n", video_angle); + struct disp_info_s *layer = &glayer_info[0]; + + if ((s_value <= 3) && (layer->angle != s_value)) { + layer->angle = s_value; + pr_info("video angle:%d\n", layer->angle); } } EXPORT_SYMBOL(set_video_angle); @@ -9567,7 +10761,9 @@ EXPORT_SYMBOL(set_video_angle); static ssize_t video_angle_show(struct class *cla, struct class_attribute *attr, char *buf) { - return snprintf(buf, 40, "%d\n", video_angle); + struct disp_info_s *layer = &glayer_info[0]; + + return snprintf(buf, 40, "%d\n", layer->angle); } static ssize_t video_angle_store(struct class *cla, @@ -9739,6 +10935,323 @@ static ssize_t video_inuse_store(struct class *class, return count; } +#ifdef VIDEO_PIP +static int _videopip_set_disable(u32 val) +{ + if (val > VIDEO_DISABLE_FORNEXT) + return -EINVAL; + + disable_videopip = val; + + if (disable_videopip != VIDEO_DISABLE_NONE) { + DisableVideoLayer2(); + + if ((disable_videopip == VIDEO_DISABLE_FORNEXT) + && cur_pipbuf && (cur_pipbuf != &local_pip)) + pip_property_changed = 1; + } else { + if (cur_pipbuf && (cur_pipbuf != &local_pip)) + EnableVideoLayer2(); + } + + return 0; +} + +static ssize_t videopip_axis_show( + struct class *cla, + struct class_attribute *attr, + char *buf) +{ + int x0, y0, x1, y1; + struct disp_info_s *layer = &glayer_info[1]; + + x0 = layer->layer_left; + y0 = layer->layer_top; + x1 = layer->layer_width + x0 - 1; + y1 = layer->layer_height + y0 - 1; + return snprintf(buf, 40, "%d %d %d %d\n", x0, y0, x1, y1); +} + +static ssize_t videopip_axis_store( + struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + struct disp_info_s *layer = &glayer_info[1]; + + mutex_lock(&video_module_mutex); + + set_video_window(layer, buf); + + mutex_unlock(&video_module_mutex); + + return strnlen(buf, count); +} + +static ssize_t videopip_crop_show( + struct class *cla, + struct class_attribute *attr, + char *buf) +{ + u32 t, l, b, r; + struct disp_info_s *layer = &glayer_info[1]; + + t = layer->crop_top; + l = layer->crop_left; + b = layer->crop_bottom; + r = layer->crop_right; + return snprintf(buf, 40, "%d %d %d %d\n", t, l, b, r); +} + +static ssize_t videopip_crop_store( + struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + struct disp_info_s *layer = &glayer_info[1]; + + mutex_lock(&video_module_mutex); + + set_video_crop(layer, buf); + + mutex_unlock(&video_module_mutex); + + return strnlen(buf, count); +} + +static ssize_t videopip_disable_show( + struct class *cla, struct class_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", disable_videopip); +} + +static ssize_t videopip_disable_store( + struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + + int r; + int val; + + if (debug_flag & DEBUG_FLAG_BLACKOUT) + pr_info("%s(%s)\n", __func__, buf); + + r = kstrtoint(buf, 0, &val); + if (r < 0) + return -EINVAL; + + if (_videopip_set_disable(val) < 0) + return -EINVAL; + + return count; +} + +static ssize_t videopip_screen_mode_show( + struct class *cla, + struct class_attribute *attr, + char *buf) +{ + struct disp_info_s *layer = &glayer_info[1]; + static const char * const wide_str[] = { + "normal", "full stretch", "4-3", "16-9", "non-linear", + "normal-noscaleup", + "4-3 ignore", "4-3 letter box", "4-3 pan scan", "4-3 combined", + "16-9 ignore", "16-9 letter box", "16-9 pan scan", + "16-9 combined", "Custom AR", "AFD" + }; + + if (layer->wide_mode < ARRAY_SIZE(wide_str)) { + return sprintf(buf, "%d:%s\n", + layer->wide_mode, + wide_str[layer->wide_mode]); + } else + return 0; +} + +static ssize_t videopip_screen_mode_store( + struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + unsigned long mode; + int ret = 0; + struct disp_info_s *layer = &glayer_info[1]; + + ret = kstrtoul(buf, 0, (unsigned long *)&mode); + if (ret < 0) + return -EINVAL; + + if ((mode < VIDEO_WIDEOPTION_MAX) + && (mode != layer->wide_mode)) { + layer->wide_mode = mode; + pip_property_changed = 1; + } + return count; +} + +static ssize_t videopip_loop_show( + struct class *cla, struct class_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", pip_loop); +} + +static ssize_t videopip_loop_store( + struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + int r; + int val; + + r = kstrtoint(buf, 0, &val); + if (r < 0) + return -EINVAL; + + pip_loop = val; + return count; +} + +static ssize_t videopip_global_output_show( + struct class *cla, + struct class_attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", pip_global_output); +} + +static ssize_t videopip_global_output_store( + struct class *cla, + struct class_attribute *attr, + const char *buf, size_t count) +{ + int r; + + r = kstrtoint(buf, 0, &pip_global_output); + if (r < 0) + return -EINVAL; + + pr_info("%s(%d)\n", __func__, pip_global_output); + + return count; +} + +static ssize_t videopip_state_show( + struct class *cla, + struct class_attribute *attr, + char *buf) +{ + ssize_t len = 0; + struct vppfilter_mode_s *vpp_filter = NULL; + + if (!curpip_frame_par) + return len; + vpp_filter = &curpip_frame_par->vpp_filter; + len += sprintf(buf + len, + "zoom2_start_x_lines:%u.zoom2_end_x_lines:%u.\n", + zoom2_start_x_lines, zoom2_end_x_lines); + len += sprintf(buf + len, + "zoom2_start_y_lines:%u.zoom2_end_y_lines:%u.\n", + zoom2_start_y_lines, zoom2_end_y_lines); + len += sprintf(buf + len, "frame parameters: pic_in_height %u.\n", + curpip_frame_par->VPP_pic_in_height_); + len += sprintf(buf + len, + "frame parameters: VPP_line_in_length_ %u.\n", + curpip_frame_par->VPP_line_in_length_); + len += sprintf(buf + len, "vscale_skip_count %u.\n", + curpip_frame_par->vscale_skip_count); + len += sprintf(buf + len, "hscale_skip_count %u.\n", + curpip_frame_par->hscale_skip_count); + len += sprintf(buf + len, "supscl_path %u.\n", + curpip_frame_par->supscl_path); + len += sprintf(buf + len, "supsc0_enable %u.\n", + curpip_frame_par->supsc0_enable); + len += sprintf(buf + len, "supsc1_enable %u.\n", + curpip_frame_par->supsc1_enable); + len += sprintf(buf + len, "supsc0_hori_ratio %u.\n", + curpip_frame_par->supsc0_hori_ratio); + len += sprintf(buf + len, "supsc1_hori_ratio %u.\n", + curpip_frame_par->supsc1_hori_ratio); + len += sprintf(buf + len, "supsc0_vert_ratio %u.\n", + curpip_frame_par->supsc0_vert_ratio); + len += sprintf(buf + len, "supsc1_vert_ratio %u.\n", + curpip_frame_par->supsc1_vert_ratio); + len += sprintf(buf + len, "spsc0_h_in %u.\n", + curpip_frame_par->spsc0_h_in); + len += sprintf(buf + len, "spsc1_h_in %u.\n", + curpip_frame_par->spsc1_h_in); + len += sprintf(buf + len, "spsc0_w_in %u.\n", + curpip_frame_par->spsc0_w_in); + len += sprintf(buf + len, "spsc1_w_in %u.\n", + curpip_frame_par->spsc1_w_in); + len += sprintf(buf + len, "video_input_w %u.\n", + curpip_frame_par->video_input_w); + len += sprintf(buf + len, "video_input_h %u.\n", + curpip_frame_par->video_input_h); + len += sprintf(buf + len, "clk_in_pps %u.\n", + curpip_frame_par->clk_in_pps); + len += + sprintf(buf + len, "hscale phase step 0x%x.\n", + vpp_filter->vpp_hsc_start_phase_step); + len += + sprintf(buf + len, "vscale phase step 0x%x.\n", + vpp_filter->vpp_vsc_start_phase_step); + len += + sprintf(buf + len, "pps pre hsc enable %d.\n", + vpp_filter->vpp_pre_hsc_en); + len += + sprintf(buf + len, "pps pre vsc enable %d.\n", + vpp_filter->vpp_pre_vsc_en); + len += + sprintf(buf + len, "hscale filter coef %d.\n", + vpp_filter->vpp_horz_filter); + len += + sprintf(buf + len, "vscale filter coef %d.\n", + vpp_filter->vpp_vert_filter); + len += + sprintf(buf + len, "vpp_vert_chroma_filter_en %d.\n", + vpp_filter->vpp_vert_chroma_filter_en); + len += + sprintf(buf + len, "post_blend_vd_h_start 0x%x.\n", + curpip_frame_par->VPP_post_blend_vd_h_start_); + len += + sprintf(buf + len, "post_blend_vd_h_end 0x%x.\n", + curpip_frame_par->VPP_post_blend_vd_h_end_); + len += + sprintf(buf + len, "post_blend_vd_v_start 0x%x.\n", + curpip_frame_par->VPP_post_blend_vd_v_start_); + len += + sprintf(buf + len, "post_blend_vd_v_end 0x%x.\n", + curpip_frame_par->VPP_post_blend_vd_v_end_); + len += + sprintf(buf + len, "VPP_hd_start_lines_ 0x%x.\n", + curpip_frame_par->VPP_hd_start_lines_); + len += + sprintf(buf + len, "VPP_hd_end_lines_ 0x%x.\n", + curpip_frame_par->VPP_hd_end_lines_); + len += + sprintf(buf + len, "VPP_vd_start_lines_ 0x%x.\n", + curpip_frame_par->VPP_vd_start_lines_); + len += + sprintf(buf + len, "VPP_vd_end_lines_ 0x%x.\n", + curpip_frame_par->VPP_vd_end_lines_); + len += + sprintf(buf + len, "VPP_hsc_startp 0x%x.\n", + curpip_frame_par->VPP_hsc_startp); + len += + sprintf(buf + len, "VPP_hsc_endp 0x%x.\n", + curpip_frame_par->VPP_hsc_endp); + len += + sprintf(buf + len, "VPP_vsc_startp 0x%x.\n", + curpip_frame_par->VPP_vsc_startp); + len += + sprintf(buf + len, "VPP_vsc_endp 0x%x.\n", + curpip_frame_par->VPP_vsc_endp); + return len; +} + +#endif + static struct class_attribute amvideo_class_attrs[] = { __ATTR(axis, 0664, @@ -9773,9 +11286,9 @@ static struct class_attribute amvideo_class_attrs[] = { video_disable_show, video_disable_store), __ATTR(video_global_output, - 0664, - video_global_output_show, - video_global_output_store), + 0664, + video_global_output_show, + video_global_output_store), __ATTR(hold_video, 0664, video_hold_show, @@ -9899,6 +11412,33 @@ static struct class_attribute amvideo_class_attrs[] = { __ATTR_RO(fps_info), __ATTR_RO(video_layer1_state), __ATTR_RO(pic_mode_info), +#ifdef VIDEO_PIP + __ATTR(axis_pip, + 0664, + videopip_axis_show, + videopip_axis_store), + __ATTR(crop_pip, + 0664, + videopip_crop_show, + videopip_crop_store), + __ATTR(disable_videopip, + 0664, + videopip_disable_show, + videopip_disable_store), + __ATTR(screen_mode_pip, + 0664, + videopip_screen_mode_show, + videopip_screen_mode_store), + __ATTR(videopip_loop, + 0664, + videopip_loop_show, + videopip_loop_store), + __ATTR(pip_global_output, + 0664, + videopip_global_output_show, + videopip_global_output_store), + __ATTR_RO(videopip_state), +#endif __ATTR_NULL }; @@ -10043,10 +11583,8 @@ int vout_notify_callback(struct notifier_block *block, unsigned long cmd, new_vmode = vinfo->mode; break; case VOUT_EVENT_OSD_PREBLEND_ENABLE: - vpp_set_osd_layer_preblend(para); break; case VOUT_EVENT_OSD_DISP_AXIS: - vpp_set_osd_layer_position(para); break; } return 0; @@ -10075,10 +11613,8 @@ int vout2_notify_callback(struct notifier_block *block, unsigned long cmd, spin_unlock_irqrestore(&lock, flags); break; case VOUT_EVENT_OSD_PREBLEND_ENABLE: - vpp_set_osd_layer_preblend(para); break; case VOUT_EVENT_OSD_DISP_AXIS: - vpp_set_osd_layer_position(para); break; } return 0; @@ -10289,20 +11825,6 @@ static int __init video_early_init(void) u32 cur_hold_line; -#if 0 /* if (0 >= VMODE_MAX) //DEBUG_TMP */ -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 */ - if (cpu_after_eq(MESON_CPU_MAJOR_ID_GXTVBB)) - WRITE_VCBUS_REG_BITS(VPP_OFIFO_SIZE, 0xfff, - VPP_OFIFO_SIZE_BIT, VPP_OFIFO_SIZE_WID); - else - WRITE_VCBUS_REG_BITS(VPP_OFIFO_SIZE, 0x77f, - VPP_OFIFO_SIZE_BIT, VPP_OFIFO_SIZE_WID); -#if 0 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESONG9TV */ - WRITE_VCBUS_REG_BITS(VPP_OFIFO_SIZE, 0x800, VPP_OFIFO_SIZE_BIT, - VPP_OFIFO_SIZE_WID); -#endif -#endif /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 */ -#else if (!legacy_vpp) { WRITE_VCBUS_REG_BITS(VPP_OFIFO_SIZE, 0x1000, VPP_OFIFO_SIZE_BIT, VPP_OFIFO_SIZE_WID); @@ -10311,12 +11833,10 @@ static int __init video_early_init(void) } else if (cpu_after_eq(MESON_CPU_MAJOR_ID_GXTVBB)) WRITE_VCBUS_REG_BITS(VPP_OFIFO_SIZE, 0xfff, VPP_OFIFO_SIZE_BIT, VPP_OFIFO_SIZE_WID); -#endif -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ WRITE_VCBUS_REG(VPP_PREBLEND_VD1_H_START_END, 4096); WRITE_VCBUS_REG(VPP_BLEND_VD2_H_START_END, 4096); -#endif + if (is_meson_txl_cpu() || is_meson_txlx_cpu()) { /* fifo max size on txl :128*3=384[0x180] */ WRITE_VCBUS_REG( @@ -10325,27 +11845,9 @@ static int __init video_early_init(void) VD2_IF0_LUMA_FIFO_SIZE + cur_dev->viu_off, 0x180); } -#if 0 /* if (0 >= VMODE_MAX) //DEBUG_TMP */ - CLEAR_VCBUS_REG_MASK(VPP_VSC_PHASE_CTRL, - VPP_PHASECTL_TYPE_INTERLACE); - SET_VCBUS_REG_MASK(VPP_MISC, VPP_OUT_SATURATE); - WRITE_VCBUS_REG(VPP_HOLD_LINES + cur_dev->vpp_off, 0x08080808); -#endif - #ifdef CONFIG_SUPPORT_VIDEO_ON_VPP2 -#if 0 /* if (0 >= VMODE_MAX) //DEBUG_TMP */ - CLEAR_VCBUS_REG_MASK(VPP2_VSC_PHASE_CTRL, - VPP_PHASECTL_TYPE_INTERLACE); - SET_VCBUS_REG_MASK(VPP2_MISC, VPP_OUT_SATURATE); - WRITE_VCBUS_REG(VPP2_HOLD_LINES, 0x08080808); -#endif -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ WRITE_VCBUS_REG_BITS(VPP2_OFIFO_SIZE, 0x800, - VPP_OFIFO_SIZE_BIT, VPP_OFIFO_SIZE_WID); -#else - WRITE_VCBUS_REG_BITS(VPP2_OFIFO_SIZE, 0x780, - VPP_OFIFO_SIZE_BIT, VPP_OFIFO_SIZE_WID); -#endif + VPP_OFIFO_SIZE_BIT, VPP_OFIFO_SIZE_WID); /* *WRITE_VCBUS_REG_BITS(VPU_OSD3_MMC_CTRL, 1, 12, 2); *select vdisp_mmc_arb for VIU2_OSD1 request @@ -10387,11 +11889,15 @@ static int __init video_early_init(void) vpp_hold_line = cur_hold_line; /* Temp force set dmc */ - if (!legacy_vpp) + if (!legacy_vpp) { WRITE_DMCREG( DMC_AM0_CHAN_CTRL, 0x8ff403cf); - + /* for vd1 & vd2 dummy alpha*/ + WRITE_VCBUS_REG( + VPP_POST_BLEND_DUMMY_ALPHA, + 0x7fffffff); + } if (is_meson_tl1_cpu()) { /* force bypass dolby for TL1, no dolby function */ WRITE_VCBUS_REG_BITS( @@ -10529,7 +12035,7 @@ static struct platform_driver amvideom_driver = { static int __init video_init(void) { - int r = 0; + int r = 0, i; /* *#ifdef CONFIG_ARCH_MESON1 *ulong clk = clk_get_rate(clk_get_sys("clk_other_pll", NULL)); @@ -10659,6 +12165,33 @@ static int __init video_init(void) goto err5; } + for (i = 0; i < MAX_VD_LAYERS; i++) { + vpp_disp_info_init(&glayer_info[i], i); + glayer_info[i].wide_mode = 1; + } + + if (legacy_vpp) + layer_cap = + LAYER1_AFBC | + LAYER1_AVAIL | + LAYER0_AFBC | + LAYER0_SCALER | + LAYER0_AVAIL; + else if (is_meson_tl1_cpu()) + layer_cap = + LAYER1_AVAIL | + LAYER0_AFBC | + LAYER0_SCALER | + LAYER0_AVAIL; + else + layer_cap = + LAYER1_AFBC | + LAYER1_SCALER | + LAYER1_AVAIL | + LAYER0_AFBC | + LAYER0_SCALER | + LAYER0_AVAIL; + init_waitqueue_head(&amvideo_trick_wait); init_waitqueue_head(&amvideo_sizechange_wait); #if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ @@ -10708,9 +12241,13 @@ static int __init video_init(void) NULL); vf_reg_receiver(&video_vf_recv); - vf_receiver_init(&video4osd_vf_recv, RECEIVER4OSD_NAME, - &video4osd_vf_receiver, NULL); - vf_reg_receiver(&video4osd_vf_recv); +#ifdef VIDEO_PIP + vf_receiver_init( + &videopip_vf_recv, RECEIVERPIP_NAME, + &videopip_vf_receiver, NULL); + vf_reg_receiver(&videopip_vf_recv); +#endif + #if DEBUG_TMP switch_dev_register(&video1_state_sdev); switch_set_state(&video1_state_sdev, 0); @@ -10751,7 +12288,9 @@ static void __exit video_exit(void) video_debugfs_exit(); vf_unreg_receiver(&video_vf_recv); - vf_unreg_receiver(&video4osd_vf_recv); +#ifdef VIDEO_PIP + vf_unreg_receiver(&videopip_vf_recv); +#endif DisableVideoLayer(); DisableVideoLayer2(); diff --git a/drivers/amlogic/media/video_sink/video_keeper.c b/drivers/amlogic/media/video_sink/video_keeper.c index 1dbfcd4..ad8b02b 100644 --- a/drivers/amlogic/media/video_sink/video_keeper.c +++ b/drivers/amlogic/media/video_sink/video_keeper.c @@ -145,8 +145,9 @@ static int ge2d_store_frame_YUV444(u32 cur_index) yaddr = keep_phy_addr(keep_y_addr); canvas_config(ydupindex, - (ulong) yaddr, - cs.width, cs.height, CANVAS_ADDR_NOWRAP, cs.blkmode); + (ulong) yaddr, + cs.width, cs.height, + CANVAS_ADDR_NOWRAP, cs.blkmode); canvas_read(ydupindex, &cd); src_index = y_index; @@ -194,8 +195,9 @@ static int ge2d_store_frame_YUV444(u32 cur_index) return -1; } - stretchblt_noalpha(ge2d_video_context, 0, 0, cs.width, cs.height, - 0, 0, cs.width, cs.height); + stretchblt_noalpha(ge2d_video_context, + 0, 0, cs.width, cs.height, + 0, 0, cs.width, cs.height); return 0; } @@ -226,11 +228,13 @@ static int ge2d_store_frame_NV21(u32 cur_index) canvas_read(y_index, &cs0); canvas_read(u_index, &cs1); canvas_config(ydupindex, - (ulong) yaddr, - cs0.width, cs0.height, CANVAS_ADDR_NOWRAP, cs0.blkmode); + (ulong) yaddr, + cs0.width, cs0.height, + CANVAS_ADDR_NOWRAP, cs0.blkmode); canvas_config(udupindex, - (ulong) uaddr, - cs1.width, cs1.height, CANVAS_ADDR_NOWRAP, cs1.blkmode); + (ulong) uaddr, + cs1.width, cs1.height, + CANVAS_ADDR_NOWRAP, cs1.blkmode); canvas_read(ydupindex, &cd); src_index = ((y_index & 0xff) | ((u_index << 8) & 0x0000ff00)); @@ -280,8 +284,9 @@ static int ge2d_store_frame_NV21(u32 cur_index) return -1; } - stretchblt_noalpha(ge2d_video_context, 0, 0, cs0.width, cs0.height, - 0, 0, cs0.width, cs0.height); + stretchblt_noalpha(ge2d_video_context, + 0, 0, cs0.width, cs0.height, + 0, 0, cs0.width, cs0.height); return 0; } @@ -322,8 +327,10 @@ static int ge2d_store_frame_YUV420(u32 cur_index) yaddr = keep_phy_addr(keep_y_addr); canvas_config(ydupindex, - (ulong) yaddr, - cs.width, cs.height, CANVAS_ADDR_NOWRAP, cs.blkmode); + (ulong) yaddr, + cs.width, cs.height, + CANVAS_ADDR_NOWRAP, cs.blkmode); + canvas_read(ydupindex, &cd); ge2d_config.dst_planes[0].addr = cd.addr; ge2d_config.dst_planes[0].w = cd.width; @@ -371,8 +378,9 @@ static int ge2d_store_frame_YUV420(u32 cur_index) pr_info("++ge2d configing error.\n"); return -1; } - stretchblt_noalpha(ge2d_video_context, 0, 0, cs.width, cs.height, 0, 0, - cs.width, cs.height); + stretchblt_noalpha(ge2d_video_context, + 0, 0, cs.width, cs.height, + 0, 0, cs.width, cs.height); /* U data */ ge2d_config.alu_const_color = 0; @@ -393,8 +401,10 @@ static int ge2d_store_frame_YUV420(u32 cur_index) uaddr = keep_phy_addr(keep_u_addr); canvas_config(udupindex, - (ulong) uaddr, - cs.width, cs.height, CANVAS_ADDR_NOWRAP, cs.blkmode); + (ulong) uaddr, + cs.width, cs.height, + CANVAS_ADDR_NOWRAP, cs.blkmode); + canvas_read(udupindex, &cd); ge2d_config.dst_planes[0].addr = cd.addr; ge2d_config.dst_planes[0].w = cd.width; @@ -442,8 +452,9 @@ static int ge2d_store_frame_YUV420(u32 cur_index) pr_info("++ge2d configing error.\n"); return -1; } - stretchblt_noalpha(ge2d_video_context, 0, 0, cs.width, cs.height, 0, 0, - cs.width, cs.height); + stretchblt_noalpha(ge2d_video_context, + 0, 0, cs.width, cs.height, + 0, 0, cs.width, cs.height); /* operation top line */ /* V data */ @@ -465,8 +476,10 @@ static int ge2d_store_frame_YUV420(u32 cur_index) vaddr = keep_phy_addr(keep_v_addr); canvas_config(vdupindex, - (ulong) vaddr, - cs.width, cs.height, CANVAS_ADDR_NOWRAP, cs.blkmode); + (ulong) vaddr, + cs.width, cs.height, + CANVAS_ADDR_NOWRAP, cs.blkmode); + ge2d_config.dst_planes[0].addr = cd.addr; ge2d_config.dst_planes[0].w = cd.width; ge2d_config.dst_planes[0].h = cd.height; @@ -513,14 +526,14 @@ static int ge2d_store_frame_YUV420(u32 cur_index) pr_info("++ge2d configing error.\n"); return -1; } - stretchblt_noalpha(ge2d_video_context, 0, 0, cs.width, cs.height, 0, 0, - cs.width, cs.height); + stretchblt_noalpha(ge2d_video_context, + 0, 0, cs.width, cs.height, + 0, 0, cs.width, cs.height); return 0; } static void ge2d_keeplastframe_block(int cur_index, int format) { - /* u32 cur_index; */ u32 y_index, u_index, v_index; #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA u32 y_index2, u_index2, v_index2; @@ -579,10 +592,9 @@ static void ge2d_keeplastframe_block(int cur_index, int format) video_module_unlock(); } - #endif -#define FETCHBUF_SIZE (64*1024) /*DEBUG_TMP*/ +#define FETCHBUF_SIZE (64*1024) /*DEBUG_TMP*/ static int canvas_dup(ulong dst, ulong src_paddr, ulong size) { void *src_addr = codec_mm_phys_to_virt(src_paddr); @@ -636,13 +648,14 @@ static int alloc_keep_buffer(void) flags = CODEC_MM_FLAGS_DMA | CODEC_MM_FLAGS_FOR_VDECODER; #endif if ((flags & CODEC_MM_FLAGS_FOR_VDECODER) && - codec_mm_video_tvp_enabled())/*TVP TODO for MULTI*/ + codec_mm_video_tvp_enabled()) + /*TVP TODO for MULTI*/ flags |= CODEC_MM_FLAGS_TVP; if (!keep_y_addr) { keep_y_addr = codec_mm_alloc_for_dma( - MEM_NAME, - PAGE_ALIGN(Y_BUFFER_SIZE)/PAGE_SIZE, 0, flags); + MEM_NAME, + PAGE_ALIGN(Y_BUFFER_SIZE)/PAGE_SIZE, 0, flags); if (!keep_y_addr) { pr_err("%s: failed to alloc y addr\n", __func__); goto err1; @@ -651,8 +664,8 @@ static int alloc_keep_buffer(void) if (!keep_u_addr) { keep_u_addr = codec_mm_alloc_for_dma( - MEM_NAME, - PAGE_ALIGN(U_BUFFER_SIZE)/PAGE_SIZE, 0, flags); + MEM_NAME, + PAGE_ALIGN(U_BUFFER_SIZE)/PAGE_SIZE, 0, flags); if (!keep_u_addr) { pr_err("%s: failed to alloc u addr\n", __func__); goto err1; @@ -661,8 +674,8 @@ static int alloc_keep_buffer(void) if (!keep_v_addr) { keep_v_addr = codec_mm_alloc_for_dma( - MEM_NAME, - PAGE_ALIGN(V_BUFFER_SIZE)/PAGE_SIZE, 0, flags); + MEM_NAME, + PAGE_ALIGN(V_BUFFER_SIZE)/PAGE_SIZE, 0, flags); if (!keep_v_addr) { pr_err("%s: failed to alloc v addr\n", __func__); goto err1; @@ -680,7 +693,6 @@ static int alloc_keep_buffer(void) return -ENOMEM; } - /* *flags,used per bit: *deflaut free alloced keeper buffer. @@ -708,7 +720,6 @@ void try_free_keep_video(int flags) mutex_unlock(&video_keeper_mutex); } EXPORT_SYMBOL(try_free_keep_video); - #endif static void video_keeper_update_keeper_mem( @@ -730,6 +741,7 @@ static void video_keeper_update_keeper_mem( *id = ret; } } + static int video_keeper_frame_keep_locked( struct vframe_s *cur_dispbuf, struct vframe_s *cur_dispbuf_el) @@ -795,6 +807,7 @@ void video_keeper_new_frame_notify(void) } return; } + static unsigned int vf_keep_current_locked( struct vframe_s *cur_dispbuf, struct vframe_s *cur_dispbuf_el) @@ -809,28 +822,28 @@ static unsigned int vf_keep_current_locked( return 0; } - if (cur_dispbuf->source_type == VFRAME_SOURCE_TYPE_OSD) { - pr_info("keep exit is osd\n"); - return 0; - } - if (get_video_debug_flags() & DEBUG_FLAG_TOGGLE_SKIP_KEEP_CURRENT) { + if (get_video_debug_flags() & + DEBUG_FLAG_TOGGLE_SKIP_KEEP_CURRENT) { pr_info("keep exit is skip current\n"); return 0; } #ifdef CONFIG_AMLOGIC_MEDIA_VIDEOCAPTURE - ext_frame_capture_poll(1); /*pull if have capture end frame */ + ext_frame_capture_poll(1); /*pull if have capture end frame */ #endif + if (get_blackout_policy()) { pr_info("keep exit is skip current\n"); return 0; } + if (VSYNC_RD_MPEG_REG(DI_IF1_GEN_REG) & 0x1) { pr_info("keep exit is di\n"); return 0; } - ret = video_keeper_frame_keep_locked(cur_dispbuf, + ret = video_keeper_frame_keep_locked( + cur_dispbuf, cur_dispbuf_el); if (ret) { /*keeped ok with codec keeper!*/ @@ -844,34 +857,34 @@ static unsigned int vf_keep_current_locked( } #endif - if ((get_cpu_type() >= MESON_CPU_MAJOR_ID_GXBB) && - (cur_dispbuf->type & VIDTYPE_COMPRESS)) { + if (cur_dispbuf->type & VIDTYPE_COMPRESS) { /* todo: duplicate compressed video frame */ pr_info("keep exit is skip VIDTYPE_COMPRESS\n"); return -1; } cur_index = READ_VCBUS_REG(VD1_IF0_CANVAS0 + - get_video_cur_dev()->viu_off); + get_video_cur_dev()->viu_off); y_index = cur_index & 0xff; u_index = (cur_index >> 8) & 0xff; v_index = (cur_index >> 16) & 0xff; canvas_read(y_index, &cd); - if ((cd.width * cd.height) <= 2048 * 1088 && - !keep_y_addr) { + if ((cd.width * cd.height) <= 2048 * 1088 + && !keep_y_addr) { alloc_keep_buffer(); } if (!keep_y_addr - || (cur_dispbuf->type & VIDTYPE_VIU_422) == VIDTYPE_VIU_422) { + || (cur_dispbuf->type & VIDTYPE_VIU_422) + == VIDTYPE_VIU_422) { /* no support VIDTYPE_VIU_422... */ pr_info("%s:no support VIDTYPE_VIU_422\n", __func__); return -1; } - if (get_video_debug_flags() & DEBUG_FLAG_BLACKOUT) { - pr_info("%s keep_y_addr=%p %x\n", __func__, (void *)keep_y_addr, - canvas_get_addr(y_index)); + pr_info("%s keep_y_addr=%p %x\n", + __func__, (void *)keep_y_addr, + canvas_get_addr(y_index)); } if ((cur_dispbuf->type & VIDTYPE_VIU_422) == VIDTYPE_VIU_422) { @@ -886,21 +899,20 @@ static unsigned int vf_keep_current_locked( return -1; } if (keep_phy_addr(keep_y_addr) != canvas_get_addr(y_index) && - canvas_dup(keep_phy_addr(keep_y_addr), - canvas_get_addr(y_index), - (cd.width) * (cd.height))) { + canvas_dup(keep_phy_addr(keep_y_addr), + canvas_get_addr(y_index), + (cd.width) * (cd.height))) { #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA canvas_update_addr(disp_canvas_index[0][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); canvas_update_addr(disp_canvas_index[1][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); #else canvas_update_addr(y_index, keep_phy_addr(keep_y_addr)); #endif if (get_video_debug_flags() & DEBUG_FLAG_BLACKOUT) pr_info("%s: VIDTYPE_VIU_422\n", __func__); - } */ } else if ((cur_dispbuf->type & VIDTYPE_VIU_444) == VIDTYPE_VIU_444) { @@ -916,17 +928,17 @@ static unsigned int vf_keep_current_locked( ge2d_keeplastframe_block(cur_index, GE2D_FORMAT_M24_YUV444); #else if (keep_phy_addr(keep_y_addr) != canvas_get_addr(y_index) && - canvas_dup(keep_phy_addr(keep_y_addr), - canvas_get_addr(y_index), - (cd.width) * (cd.height))) { + canvas_dup(keep_phy_addr(keep_y_addr), + canvas_get_addr(y_index), + (cd.width) * (cd.height))) { #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA canvas_update_addr(disp_canvas_index[0][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); canvas_update_addr(disp_canvas_index[1][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); #else canvas_update_addr(y_index, - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); #endif } #endif @@ -936,7 +948,7 @@ static unsigned int vf_keep_current_locked( canvas_read(y_index, &cs0); canvas_read(u_index, &cs1); if ((Y_BUFFER_SIZE < (cs0.width * cs0.height)) - || (U_BUFFER_SIZE < (cs1.width * cs1.height))) { + || (U_BUFFER_SIZE < (cs1.width * cs1.height))) { pr_info("## [%s::%d] error: yuv data size larger", __func__, __LINE__); return -1; @@ -945,21 +957,21 @@ static unsigned int vf_keep_current_locked( ge2d_keeplastframe_block(cur_index, GE2D_FORMAT_M24_NV21); #else if (keep_phy_addr(keep_y_addr) != canvas_get_addr(y_index) && - canvas_dup(keep_phy_addr(keep_y_addr), - canvas_get_addr(y_index), - (cs0.width * cs0.height)) - && canvas_dup(keep_phy_addr(keep_u_addr), - canvas_get_addr(u_index), - (cs1.width * cs1.height))) { + canvas_dup(keep_phy_addr(keep_y_addr), + canvas_get_addr(y_index), + (cs0.width * cs0.height)) + && canvas_dup(keep_phy_addr(keep_u_addr), + canvas_get_addr(u_index), + (cs1.width * cs1.height))) { #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA canvas_update_addr(disp_canvas_index[0][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); canvas_update_addr(disp_canvas_index[1][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); canvas_update_addr(disp_canvas_index[0][1], - keep_phy_addr(keep_u_addr)); + keep_phy_addr(keep_u_addr)); canvas_update_addr(disp_canvas_index[1][1], - keep_phy_addr(keep_u_addr)); + keep_phy_addr(keep_u_addr)); #else canvas_update_addr(y_index, keep_phy_addr(keep_y_addr)); @@ -976,13 +988,13 @@ static unsigned int vf_keep_current_locked( canvas_read(v_index, &cs2); if ((Y_BUFFER_SIZE < (cs0.width * cs0.height)) - || (U_BUFFER_SIZE < (cs1.width * cs1.height)) - || (V_BUFFER_SIZE < (cs2.width * cs2.height))) { + || (U_BUFFER_SIZE < (cs1.width * cs1.height)) + || (V_BUFFER_SIZE < (cs2.width * cs2.height))) { pr_info("## [%s::%d] error: yuv data size larger than buf size: %x,%x,%x, %x,%x, %x,%x, %x,%x,\n", - __func__, __LINE__, Y_BUFFER_SIZE, - U_BUFFER_SIZE, V_BUFFER_SIZE, cs0.width, - cs0.height, cs1.width, cs1.height, cs2.width, - cs2.height); + __func__, __LINE__, Y_BUFFER_SIZE, + U_BUFFER_SIZE, V_BUFFER_SIZE, cs0.width, + cs0.height, cs1.width, cs1.height, cs2.width, + cs2.height); return -1; } #ifdef CONFIG_GE2D_KEEP_FRAME @@ -990,28 +1002,28 @@ static unsigned int vf_keep_current_locked( #else if (keep_phy_addr(keep_y_addr) != canvas_get_addr(y_index) && /*must not the same address */ - canvas_dup(keep_phy_addr(keep_y_addr), - canvas_get_addr(y_index), - (cs0.width * cs0.height)) - && canvas_dup(keep_phy_addr(keep_u_addr), - canvas_get_addr(u_index), - (cs1.width * cs1.height)) + canvas_dup(keep_phy_addr(keep_y_addr), + canvas_get_addr(y_index), + (cs0.width * cs0.height)) + && canvas_dup(keep_phy_addr(keep_u_addr), + canvas_get_addr(u_index), + (cs1.width * cs1.height)) && canvas_dup(keep_phy_addr(keep_v_addr), - canvas_get_addr(v_index), - (cs2.width * cs2.height))) { + canvas_get_addr(v_index), + (cs2.width * cs2.height))) { #ifdef CONFIG_AMLOGIC_MEDIA_VSYNC_RDMA canvas_update_addr(disp_canvas_index[0][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); canvas_update_addr(disp_canvas_index[1][0], - keep_phy_addr(keep_y_addr)); + keep_phy_addr(keep_y_addr)); canvas_update_addr(disp_canvas_index[0][1], - keep_phy_addr(keep_u_addr)); + keep_phy_addr(keep_u_addr)); canvas_update_addr(disp_canvas_index[1][1], - keep_phy_addr(keep_u_addr)); + keep_phy_addr(keep_u_addr)); canvas_update_addr(disp_canvas_index[0][2], - keep_phy_addr(keep_v_addr)); + keep_phy_addr(keep_v_addr)); canvas_update_addr(disp_canvas_index[1][2], - keep_phy_addr(keep_v_addr)); + keep_phy_addr(keep_v_addr)); #else canvas_update_addr(y_index, keep_phy_addr(keep_y_addr)); @@ -1038,8 +1050,8 @@ unsigned int vf_keep_current( unsigned int ret; mutex_lock(&video_keeper_mutex); - ret = vf_keep_current_locked(cur_dispbuf, - cur_dispbuf2); + ret = vf_keep_current_locked( + cur_dispbuf, cur_dispbuf2); mutex_unlock(&video_keeper_mutex); return ret; } diff --git a/drivers/amlogic/media/video_sink/video_priv.h b/drivers/amlogic/media/video_sink/video_priv.h index cca1ddf..446a8a9 100644 --- a/drivers/amlogic/media/video_sink/video_priv.h +++ b/drivers/amlogic/media/video_sink/video_priv.h @@ -17,6 +17,9 @@ #ifndef VIDEO_PRIV_HEADER_HH #define VIDEO_PRIV_HEADER_HH + +#include + #define DEBUG_FLAG_BLACKOUT 0x1 #define DEBUG_FLAG_PRINT_TOGGLE_FRAME 0x2 #define DEBUG_FLAG_PRINT_RDMA 0x4 @@ -38,10 +41,97 @@ #define VIDEO_DISABLE_NORMAL 1 #define VIDEO_DISABLE_FORNEXT 2 +#define VIDEO_NOTIFY_TRICK_WAIT 0x01 +#define VIDEO_NOTIFY_PROVIDER_GET 0x02 +#define VIDEO_NOTIFY_PROVIDER_PUT 0x04 +#define VIDEO_NOTIFY_FRAME_WAIT 0x08 +#define VIDEO_NOTIFY_POS_CHANGED 0x10 + struct video_dev_s { int vpp_off; int viu_off; }; + +struct mif_pos_s { + u32 id; + u32 vd_reg_offt; + u32 afbc_reg_offt; + + /* frame original size */ + u32 src_w; + u32 src_h; + + /* mif start - end lines */ + u32 start_x_lines; + u32 end_x_lines; + u32 start_y_lines; + u32 end_y_lines; + + /* left and right eye position, skip flag. */ + /* And if non 3d case, left eye = right eye */ + u32 l_hs_luma; + u32 l_he_luma; + u32 l_hs_chrm; + u32 l_he_chrm; + u32 r_hs_luma; + u32 r_he_luma; + u32 r_hs_chrm; + u32 r_he_chrm; + u32 h_skip; + u32 l_vs_luma; + u32 l_ve_luma; + u32 l_vs_chrm; + u32 l_ve_chrm; + u32 r_vs_luma; + u32 r_ve_luma; + u32 r_vs_chrm; + u32 r_ve_chrm; + u32 v_skip; + + bool reverse; + + bool skip_afbc; +}; + +struct scaler_setting_s { + u32 id; + u32 misc_reg_offt; + + bool sc_h_enable; + bool sc_v_enable; + bool sc_top_enable; + + u32 vinfo_width; + u32 vinfo_height; + /* u32 VPP_pic_in_height_; */ + /* u32 VPP_line_in_length_; */ + + struct vpp_frame_par_s *frame_par; +}; + +struct blend_setting_s { + u32 id; + u32 misc_reg_offt; + + u32 layer_alpha; + + u32 preblend_h_start; + u32 preblend_h_end; + u32 preblend_v_start; + u32 preblend_v_end; + + u32 preblend_h_size; + + u32 postblend_h_start; + u32 postblend_h_end; + u32 postblend_v_start; + u32 postblend_v_end; + + u32 postblend_h_size; + + struct vpp_frame_par_s *frame_par; +}; + void safe_disble_videolayer(void); void update_cur_dispbuf(void *buf); @@ -54,6 +144,7 @@ struct vframe_s *get_cur_dispbuf(void); int get_video_debug_flags(void); int _video_set_disable(u32 val); u32 get_video_enabled(void); +struct device *get_video_device(void); #ifdef CONFIG_AMLOGIC_MEDIA_VIDEOCAPTURE int ext_frame_capture_poll(int endflags); diff --git a/drivers/amlogic/media/video_sink/vpp.c b/drivers/amlogic/media/video_sink/vpp.c index 17d1384..5eda6a0 100644 --- a/drivers/amlogic/media/video_sink/vpp.c +++ b/drivers/amlogic/media/video_sink/vpp.c @@ -18,21 +18,12 @@ #include #include #include -/* #include */ #include - #include - #include #include #include -#include -#include -/*#include */ - -#include - #include "videolog.h" /* #define CONFIG_VIDEO_LOG */ #ifdef CONFIG_VIDEO_LOG @@ -42,6 +33,10 @@ #include #include +#include "video_priv.h" + +#define MAX_NONLINEAR_FACTOR 0x40 + /* vpp filter coefficients */ #define COEF_BICUBIC 0 #define COEF_3POINT_TRIANGLE 1 @@ -56,13 +51,21 @@ #define COEF_NULL 0xff #define TOTAL_FILTERS 10 -#define MAX_NONLINEAR_FACTOR 0x40 - #define VPP_SPEED_FACTOR 0x110ULL #define SUPER_SCALER_V_FACTOR 100 #define PPS_FRAC_BITS 24 #define PPS_INT_BITS 4 +struct filter_info_s { + u32 cur_vert_filter; + u32 cur_horz_filter; + u32 last_vert_filter; + u32 last_horz_filter; + u32 scaler_filter_cnt; +}; + +static struct filter_info_s gfilter[MAX_VD_LAYERS]; + const u32 vpp_filter_coefs_bicubic_sharp[] = { 3, 33 | 0x8000, @@ -248,8 +251,8 @@ MODULE_PARM_DESC(vpp_filter_fix, "vpp_filter_fix"); module_param(vpp_filter_fix, uint, 0664); #define MAX_COEFF_LEVEL 5 -uint num_coeff_level = MAX_COEFF_LEVEL; -uint vert_coeff_settings[MAX_COEFF_LEVEL] = { +static uint num_coeff_level = MAX_COEFF_LEVEL; +static uint vert_coeff_settings[MAX_COEFF_LEVEL] = { /* in:out */ COEF_BICUBIC, /* ratio < 1 */ @@ -269,7 +272,7 @@ uint vert_coeff_settings[MAX_COEFF_LEVEL] = { /* this setting is most smooth */ }; -uint horz_coeff_settings[MAX_COEFF_LEVEL] = { +static uint horz_coeff_settings[MAX_COEFF_LEVEL] = { /* in:out */ COEF_BICUBIC, /* ratio < 1 */ @@ -334,40 +337,40 @@ MODULE_PARM_DESC(vert_coeff_settings, "\n vert_coeff_settings\n"); module_param_array(horz_coeff_settings, uint, &num_coeff_level, 0664); MODULE_PARM_DESC(horz_coeff_settings, "\n horz_coeff_settings\n"); -bool vert_chroma_filter_en = true; +static bool vert_chroma_filter_en = true; module_param(vert_chroma_filter_en, bool, 0664); MODULE_PARM_DESC(vert_chroma_filter_en, "enable vertical chromafilter\n"); -bool vert_chroma_filter_force_en; +static bool vert_chroma_filter_force_en; module_param(vert_chroma_filter_force_en, bool, 0664); MODULE_PARM_DESC(vert_chroma_filter_force_en, "force enable vertical chromafilter\n"); -uint vert_chroma_filter_limit = 480; +static uint vert_chroma_filter_limit = 480; module_param(vert_chroma_filter_limit, uint, 0664); MODULE_PARM_DESC(vert_chroma_filter_limit, "vertical chromafilter limit\n"); -uint num_chroma_filter = TOTAL_FILTERS; +static uint num_chroma_filter = TOTAL_FILTERS; module_param_array(chroma_filter_table, uint, &num_chroma_filter, 0664); MODULE_PARM_DESC(chroma_filter_table, "\n chroma_filter_table\n"); -uint cur_vert_chroma_filter; +static uint cur_vert_chroma_filter; MODULE_PARM_DESC(cur_vert_chroma_filter, "cur_vert_chroma_filter"); module_param(cur_vert_chroma_filter, int, 0444); -uint cur_vert_filter; +static uint cur_vert_filter; MODULE_PARM_DESC(cur_vert_filter, "cur_vert_filter"); module_param(cur_vert_filter, int, 0444); -uint cur_horz_filter; +static uint cur_horz_filter; MODULE_PARM_DESC(cur_horz_filter, "cur_horz_filter"); module_param(cur_horz_filter, int, 0444); -uint cur_skip_line; +static uint cur_skip_line; MODULE_PARM_DESC(cur_skip_line, "cur_skip_line"); module_param(cur_skip_line, int, 0444); -unsigned int super_scaler_v_ratio = 133; +static unsigned int super_scaler_v_ratio = 133; MODULE_PARM_DESC(super_scaler_v_ratio, "super_scaler_v_ratio"); module_param(super_scaler_v_ratio, uint, 0664); @@ -375,31 +378,11 @@ static u32 skip_policy = 0x81; module_param(skip_policy, uint, 0664); MODULE_PARM_DESC(skip_policy, "\n skip_policy\n"); -unsigned int scaler_filter_cnt_limit = 10; +static unsigned int scaler_filter_cnt_limit = 10; MODULE_PARM_DESC(scaler_filter_cnt_limit, "scaler_filter_cnt_limit"); module_param(scaler_filter_cnt_limit, uint, 0664); -static uint last_vert_filter; -static uint last_horz_filter; -static uint scaler_filter_cnt; - -static u32 vpp_wide_mode; -static u32 vpp_zoom_ratio = 100; -static s32 vpp_zoom_center_x, vpp_zoom_center_y; -static u32 nonlinear_factor = MAX_NONLINEAR_FACTOR / 2; -static u32 osd_layer_preblend; -static s32 video_layer_top, video_layer_left, video_layer_width, - video_layer_height; -static u32 video_source_crop_top, video_source_crop_left, - video_source_crop_bottom, video_source_crop_right; -static u32 video_crop_top_resv, video_crop_left_resv, - video_crop_bottom_resv, video_crop_right_resv; -static s32 video_layer_global_offset_x, video_layer_global_offset_y; -static s32 osd_layer_top, osd_layer_left, osd_layer_width, osd_layer_height; -static u32 video_speed_check_width = 1800, video_speed_check_height = 1400; - #ifdef TV_3D_FUNCTION_OPEN -static bool vpp_3d_scale; static int force_filter_mode = 1; MODULE_PARM_DESC(force_filter_mode, "force_filter_mode"); module_param(force_filter_mode, int, 0664); @@ -446,15 +429,15 @@ static unsigned int sr0_sr1_refresh = 1; module_param(sr0_sr1_refresh, uint, 0664); MODULE_PARM_DESC(sr0_sr1_refresh, "sr0_sr1_refresh"); -bool pre_scaler_en = true; +static bool pre_scaler_en = true; module_param(pre_scaler_en, bool, 0664); MODULE_PARM_DESC(pre_scaler_en, "pre_scaler_en"); -unsigned int force_vskip_cnt; +static unsigned int force_vskip_cnt; MODULE_PARM_DESC(force_vskip_cnt, "force_vskip_cnt"); module_param(force_vskip_cnt, uint, 0664); -unsigned int disable_adapted; +static unsigned int disable_adapted; MODULE_PARM_DESC(disable_adapted, "disable_adapted"); module_param(disable_adapted, uint, 0664); @@ -554,13 +537,15 @@ static void f2v_get_vertical_phase(u32 zoom_ratio, /* * V-shape non-linear mode */ -static void -calculate_non_linear_ratio(unsigned int middle_ratio, - unsigned int width_out, - struct vpp_frame_par_s *next_frame_par) +static void calculate_non_linear_ratio( + unsigned int nonlinear_factor, + unsigned int middle_ratio, + unsigned int width_out, + struct vpp_frame_par_s *next_frame_par) { unsigned int diff_ratio; - struct vppfilter_mode_s *vpp_filter = &next_frame_par->vpp_filter; + struct vppfilter_mode_s *vpp_filter = + &next_frame_par->vpp_filter; diff_ratio = middle_ratio * nonlinear_factor; vpp_filter->vpp_hf_start_phase_step = (middle_ratio << 6) - diff_ratio; @@ -589,23 +574,23 @@ calculate_non_linear_ratio(unsigned int middle_ratio, * (1.25 * 3840 / 1920) for 1080p mode. */ #define MIN_RATIO_1000 1250 -unsigned int min_skip_ratio = MIN_RATIO_1000; +static unsigned int min_skip_ratio = MIN_RATIO_1000; MODULE_PARM_DESC(min_skip_ratio, "min_skip_ratio"); module_param(min_skip_ratio, uint, 0664); -unsigned int max_proc_height = 2160; +static unsigned int max_proc_height = 2160; MODULE_PARM_DESC(max_proc_height, "max_proc_height"); module_param(max_proc_height, uint, 0664); -unsigned int cur_proc_height; +static unsigned int cur_proc_height; MODULE_PARM_DESC(cur_proc_height, "cur_proc_height"); module_param(cur_proc_height, uint, 0444); -unsigned int cur_skip_ratio; +static unsigned int cur_skip_ratio; MODULE_PARM_DESC(cur_skip_ratio, "cur_skip_ratio"); module_param(cur_skip_ratio, uint, 0444); -unsigned int cur_vf_type; +static unsigned int cur_vf_type; MODULE_PARM_DESC(cur_vf_type, "cur_vf_type"); module_param(cur_vf_type, uint, 0444); -unsigned int custom_ar; +static unsigned int custom_ar; MODULE_PARM_DESC(custom_ar, "custom_ar"); module_param(custom_ar, uint, 0664); @@ -627,13 +612,16 @@ module_param(custom_ar, uint, 0664); *So need adjust bypass_ratio; */ -static int -vpp_process_speed_check(s32 width_in, - s32 height_in, - s32 height_out, - s32 height_screen, - struct vpp_frame_par_s *next_frame_par, - const struct vinfo_s *vinfo, struct vframe_s *vf) +static int vpp_process_speed_check( + u32 layer_id, + s32 width_in, + s32 height_in, + s32 height_out, + s32 height_screen, + u32 video_speed_check_width, + u32 video_speed_check_height, + struct vpp_frame_par_s *next_frame_par, + const struct vinfo_s *vinfo, struct vframe_s *vf) { u32 cur_ratio, bpp = 1; int min_ratio_1000 = 0; @@ -642,12 +630,16 @@ vpp_process_speed_check(s32 width_in, u32 width_out = 0; u32 vpu_clk = 0, max_height = 2160; /* 4k mode */ - if (vf) + if (!vf) + return SPEED_CHECK_DONE; + + /* store the debug info for legacy */ + if (layer_id == 0) cur_vf_type = vf->type; - else - return 0; + if (force_vskip_cnt == 0xff)/*for debug*/ return SPEED_CHECK_DONE; + if (next_frame_par->vscale_skip_count < force_vskip_cnt) return SPEED_CHECK_VSKIP; @@ -726,39 +718,45 @@ vpp_process_speed_check(s32 width_in, if (get_cpu_type() >= MESON_CPU_MAJOR_ID_GXBB) { cur_ratio = div_u64((u64)height_in * - (u64)vinfo->height * - 1000, - height_out * max_height); + (u64)vinfo->height * + 1000, + height_out * max_height); /* di process first, need more a bit of ratio */ if (vf->type & VIDTYPE_PRE_INTERLACE) cur_ratio = (cur_ratio * 105) / 100; if ((next_frame_par->vscale_skip_count > 0) && (vf->type & VIDTYPE_VIU_444)) cur_ratio = cur_ratio * 2; - cur_skip_ratio = cur_ratio; + + /* store the debug info for legacy */ + if (layer_id == 0) + cur_skip_ratio = cur_ratio; + if ((cur_ratio > min_ratio_1000) && - (vf->source_type != VFRAME_SOURCE_TYPE_TUNER) && - (vf->source_type != VFRAME_SOURCE_TYPE_CVBS)) + (vf->source_type != + VFRAME_SOURCE_TYPE_TUNER) && + (vf->source_type != + VFRAME_SOURCE_TYPE_CVBS)) return SPEED_CHECK_VSKIP; } if (vf->type & VIDTYPE_VIU_422) { /*TODO vpu */ - if (height_out == 0 - || div_u64((u64)VPP_SPEED_FACTOR * - (u64)width_in * - (u64)height_in * - (u64)vinfo->sync_duration_num * - (u64)vtotal, - height_out * - vinfo->sync_duration_den * - bypass_ratio) > clk_in_pps) + if (height_out == 0 || + div_u64((u64)VPP_SPEED_FACTOR * + (u64)width_in * + (u64)height_in * + (u64)vinfo->sync_duration_num * + (u64)vtotal, + height_out * + vinfo->sync_duration_den * + bypass_ratio) > clk_in_pps) return SPEED_CHECK_VSKIP; else return SPEED_CHECK_DONE; } else { /*TODO vpu */ - if (height_out == 0 - || div_u64((u64)VPP_SPEED_FACTOR * + if (height_out == 0 || + div_u64((u64)VPP_SPEED_FACTOR * (u64)width_in * (u64)height_in * (u64)vinfo->sync_duration_num * @@ -770,16 +768,15 @@ vpp_process_speed_check(s32 width_in, /* 4K down scaling to non 4K > 30hz,*/ /*skip lines for memory bandwidth */ else if ((((vf->type & VIDTYPE_COMPRESS) - == 0) || (next_frame_par->nocomp)) - && - (height_in > 2048) && - (height_out < 2048) && - (vinfo->sync_duration_num > - (30 * vinfo->sync_duration_den)) && - (get_cpu_type() != - MESON_CPU_MAJOR_ID_GXTVBB) && - (get_cpu_type() != - MESON_CPU_MAJOR_ID_GXM)) + == 0) || (next_frame_par->nocomp)) + && (height_in > 2048) + && (height_out < 2048) + && (vinfo->sync_duration_num > + (30 * vinfo->sync_duration_den)) + && (get_cpu_type() != + MESON_CPU_MAJOR_ID_GXTVBB) + && (get_cpu_type() != + MESON_CPU_MAJOR_ID_GXM)) return SPEED_CHECK_VSKIP; else return SPEED_CHECK_DONE; @@ -787,8 +784,8 @@ vpp_process_speed_check(s32 width_in, } else if (next_frame_par->hscale_skip_count == 0) { /*TODO vpu */ if (div_u64(VPP_SPEED_FACTOR * width_in * - vinfo->sync_duration_num * height_screen, - vinfo->sync_duration_den * 256) + vinfo->sync_duration_num * height_screen, + vinfo->sync_duration_den * 256) > get_vpu_clk()) return SPEED_CHECK_HSKIP; else @@ -818,8 +815,9 @@ vpp_process_speed_check(s32 width_in, return SPEED_CHECK_VSKIP; } -static void -vpp_set_filters2(u32 process_3d_type, u32 width_in, +static int vpp_set_filters_internal( + struct disp_info_s *input, + u32 width_in, u32 height_in, u32 wid_out, u32 hei_out, @@ -854,35 +852,68 @@ vpp_set_filters2(u32 process_3d_type, u32 width_in, u32 screen_aspect = 0; bool skip_policy_check = true; u32 vskip_step; + s32 video_layer_global_offset_x, video_layer_global_offset_y; + u32 video_source_crop_top, video_source_crop_left; + u32 video_source_crop_bottom, video_source_crop_right; + u32 vpp_zoom_ratio, nonlinear_factor; + u32 speed_check_width, speed_check_height; + s32 video_layer_top, video_layer_left; + s32 video_layer_width, video_layer_height; + u32 cur_custom_ar; +#ifdef TV_REVERSE + bool reverse = false; +#endif + int ret = VppFilter_Success; + u32 vert_chroma_filter; + struct filter_info_s *cur_filter; + s32 vpp_zoom_center_x, vpp_zoom_center_y; + + if (!input) + return VppFilter_Fail; + + cur_filter = &gfilter[input->layer_id]; + cur_custom_ar = input->custom_ar; + vpp_zoom_ratio = input->zoom_ratio; + vpp_zoom_center_x = input->zoom_center_x; + vpp_zoom_center_y = input->zoom_center_y; + speed_check_width = input->speed_check_width; + speed_check_height = input->speed_check_height; + nonlinear_factor = input->nonlinear_factor; + video_layer_global_offset_x = input->global_offset_x; + video_layer_global_offset_y = input->global_offset_y; + + video_layer_top = input->layer_top; + video_layer_left = input->layer_left; + video_layer_width = input->layer_width; + video_layer_height = input->layer_height; +#ifdef TV_REVERSE + reverse = input->reverse; +#endif - if (get_cpu_type() >= MESON_CPU_MAJOR_ID_GXTVBB) { - if (likely(w_in > - (video_source_crop_left + video_source_crop_right))) { - w_in -= video_source_crop_left; - w_in -= video_source_crop_right; - h_crop_enable = true; - } - - if (likely(h_in > - (video_source_crop_top + video_source_crop_bottom))) { - h_in -= video_source_crop_top; - h_in -= video_source_crop_bottom; - v_crop_enable = true; - } + if (vf->type & VIDTYPE_MVC) { + video_source_crop_left = 0; + video_source_crop_right = 0; + video_source_crop_top = 0; + video_source_crop_bottom = 0; } else { - if (likely(w_in > - (video_source_crop_left + video_source_crop_right))) { - w_in -= video_source_crop_left; - w_in -= video_source_crop_right; - h_crop_enable = true; - } + video_source_crop_left = input->crop_left; + video_source_crop_right = input->crop_right; + video_source_crop_top = input->crop_top; + video_source_crop_bottom = input->crop_bottom; + } - if (likely(h_in > - (video_source_crop_top + video_source_crop_bottom))) { - h_in -= video_source_crop_top; - h_in -= video_source_crop_bottom; - v_crop_enable = true; - } + if (likely(w_in > + (video_source_crop_left + video_source_crop_right))) { + w_in -= video_source_crop_left; + w_in -= video_source_crop_right; + h_crop_enable = true; + } + + if (likely(h_in > + (video_source_crop_top + video_source_crop_bottom))) { + h_in -= video_source_crop_top; + h_in -= video_source_crop_bottom; + v_crop_enable = true; } #ifndef TV_3D_FUNCTION_OPEN @@ -900,7 +931,7 @@ vpp_set_filters2(u32 process_3d_type, u32 width_in, #ifdef TV_3D_FUNCTION_OPEN else if ((next_frame_par->vpp_3d_mode == VPP_3D_MODE_LA) - && (process_3d_type & MODE_3D_ENABLE)) + && (input->proc_3d_type & MODE_3D_ENABLE)) vskip_step = 2; #endif else @@ -908,6 +939,7 @@ vpp_set_filters2(u32 process_3d_type, u32 width_in, RESTART: aspect_factor = (vpp_flags & VPP_FLAG_AR_MASK) >> VPP_FLAG_AR_BITS; + /* don't use input->wide_mode */ wide_mode = vpp_flags & VPP_FLAG_WIDEMODE_MASK; /* keep 8 bits resolution for aspect conversion */ @@ -924,22 +956,22 @@ RESTART: aspect_factor = 0x90; wide_mode = VIDEO_WIDEOPTION_NORMAL; } else if ((wide_mode >= VIDEO_WIDEOPTION_4_3_IGNORE) - && (wide_mode <= VIDEO_WIDEOPTION_4_3_COMBINED)) { + && (wide_mode <= VIDEO_WIDEOPTION_4_3_COMBINED)) { if (aspect_factor != 0xc0) fill_match = false; orig_aspect = aspect_factor; screen_aspect = 0xc0; } else if ((wide_mode >= VIDEO_WIDEOPTION_16_9_IGNORE) - && (wide_mode <= VIDEO_WIDEOPTION_16_9_COMBINED)) { + && (wide_mode <= VIDEO_WIDEOPTION_16_9_COMBINED)) { if (aspect_factor != 0x90) fill_match = false; orig_aspect = aspect_factor; screen_aspect = 0x90; } else if (wide_mode == VIDEO_WIDEOPTION_CUSTOM) { - if (custom_ar != 0) - aspect_factor = custom_ar & 0x3ff; + if (cur_custom_ar != 0) + aspect_factor = cur_custom_ar & 0x3ff; wide_mode = VIDEO_WIDEOPTION_NORMAL; } else if (wide_mode == VIDEO_WIDEOPTION_AFD) { if (aspect_factor == 0x90) @@ -964,9 +996,6 @@ RESTART: width_out * h_in * aspect_ratio_out); } - if (osd_layer_preblend) - aspect_factor = 0x100; - height_after_ratio = (h_in * aspect_factor) >> 8; /* @@ -975,43 +1004,28 @@ RESTART: * it will override the input width_out/height_out for * ratio calculations, a.k.a we have a window for video content */ - if (osd_layer_preblend) { - if ((osd_layer_width == 0) || (osd_layer_height == 0)) { - video_top = 0; - video_left = 0; - video_width = width_out; - video_height = height_out; - - } else { - video_top = osd_layer_top; - video_left = osd_layer_left; - video_width = osd_layer_width; - video_height = osd_layer_height; - } + video_top = video_layer_top; + video_left = video_layer_left; + video_width = video_layer_width; + video_height = video_layer_height; + if ((video_top == 0) && (video_left == 0) && (video_width <= 1) + && (video_height <= 1)) { + /* special case to do full screen display */ + video_width = width_out; + video_height = height_out; } else { - video_top = video_layer_top; - video_left = video_layer_left; - video_width = video_layer_width; - video_height = video_layer_height; - if ((video_top == 0) && (video_left == 0) && (video_width <= 1) - && (video_height <= 1)) { - /* special case to do full screen display */ + if ((video_layer_width < 16) + && (video_layer_height < 16)) { + /* + *sanity check to move + *video out when the target size is too small + */ video_width = width_out; video_height = height_out; - } else { - if ((video_layer_width < 16) - && (video_layer_height < 16)) { - /* - *sanity check to move - *video out when the target size is too small - */ - video_width = width_out; - video_height = height_out; - video_left = width_out * 2; - } - video_top += video_layer_global_offset_y; - video_left += video_layer_global_offset_x; + video_left = width_out * 2; } + video_top += video_layer_global_offset_y; + video_left += video_layer_global_offset_x; } /*aspect ratio match */ @@ -1062,8 +1076,7 @@ RESTART: } ratio_x = screen_ratio_x * w_in / video_width; - ratio_y = - screen_ratio_y * h_in / orig_aspect * + ratio_y = screen_ratio_y * h_in / orig_aspect * screen_aspect / video_height; } else { screen_width = video_width * vpp_zoom_ratio / 100; @@ -1082,9 +1095,10 @@ RESTART: ratio_y = (height_after_ratio << 18) / screen_height; if (super_debug) - pr_info("height_after_ratio=%d,%d,%d,%d,%d\n", - height_after_ratio, ratio_x, ratio_y, - aspect_factor, wide_mode); + pr_info("layer%d: height_after_ratio=%d,%d,%d,%d,%d\n", + input->layer_id, + height_after_ratio, ratio_x, ratio_y, + aspect_factor, wide_mode); if (wide_mode == VIDEO_WIDEOPTION_NORMAL) { ratio_x = ratio_y = max(ratio_x, ratio_y); @@ -1125,26 +1139,16 @@ RESTART: ini_vphase = vpp_zoom_center_y & 0xff; /* screen position for source */ -#ifdef TV_REVERSE - start = - video_top + (video_height + 1) / 2 - ((h_in << 17) + - (vpp_zoom_center_y << 10) + - (ratio_y >> 1)) / ratio_y; + start = video_top + (video_height + 1) / 2 - + ((h_in << 17) + + (vpp_zoom_center_y << 10) + + (ratio_y >> 1)) / ratio_y; end = ((h_in << 18) + (ratio_y >> 1)) / ratio_y + start - 1; if (super_debug) - pr_info("top:start =%d,%d,%d,%d %d,%d,%d\n", - start, end, video_top, - video_height, h_in, ratio_y, vpp_zoom_center_y); -#else - start = - video_top + video_height / 2 - ((h_in << 17) + - (vpp_zoom_center_y << 10)) / ratio_y; - end = (h_in << 18) / ratio_y + start - 1; - if (super_debug) - pr_info("top:start =%d,%d,%d,%d %d,%d,%d\n", + pr_info("layer%d: top:start =%d,%d,%d,%d %d,%d,%d\n", + input->layer_id, start, end, video_top, video_height, h_in, ratio_y, vpp_zoom_center_y); -#endif #ifdef TV_REVERSE if (reverse) { @@ -1154,10 +1158,8 @@ RESTART: temp = (-start * ratio_y) >> 18; next_frame_par->VPP_vd_end_lines_ = h_in - 1 - temp; - } else next_frame_par->VPP_vd_end_lines_ = h_in - 1; - } else { if (start < video_top) { temp = ((video_top - start) * ratio_y) >> 18; @@ -1166,8 +1168,7 @@ RESTART: } else next_frame_par->VPP_vd_end_lines_ = h_in - 1; } - temp = - next_frame_par->VPP_vd_end_lines_ - + temp = next_frame_par->VPP_vd_end_lines_ - (video_height * ratio_y >> 18); next_frame_par->VPP_vd_start_lines_ = (temp >= 0) ? temp : 0; } else @@ -1177,7 +1178,6 @@ RESTART: if (start < 0) { temp = (-start * ratio_y) >> 18; next_frame_par->VPP_vd_start_lines_ = temp; - } else next_frame_par->VPP_vd_start_lines_ = 0; temp_height = min((video_top + video_height - 1), @@ -1186,15 +1186,12 @@ RESTART: if (start < video_top) { temp = ((video_top - start) * ratio_y) >> 18; next_frame_par->VPP_vd_start_lines_ = temp; - } else next_frame_par->VPP_vd_start_lines_ = 0; temp_height = min((video_top + video_height - 1), (vinfo->height - 1)) - video_top + 1; } - - temp = - next_frame_par->VPP_vd_start_lines_ + + temp = next_frame_par->VPP_vd_start_lines_ + (temp_height * ratio_y >> 18); next_frame_par->VPP_vd_end_lines_ = (temp <= (h_in - 1)) ? temp : (h_in - 1); @@ -1226,15 +1223,14 @@ RESTART: if (start >= end) { /* nothing to display */ next_frame_par->VPP_vsc_startp = 0; - next_frame_par->VPP_vsc_endp = 0; - } else { next_frame_par->VPP_vsc_startp = - (vpp_flags & VPP_FLAG_INTERLACE_OUT) ? (start >> 1) : start; - + (vpp_flags & VPP_FLAG_INTERLACE_OUT) ? + (start >> 1) : start; next_frame_par->VPP_vsc_endp = - (vpp_flags & VPP_FLAG_INTERLACE_OUT) ? (end >> 1) : end; + (vpp_flags & VPP_FLAG_INTERLACE_OUT) ? + (end >> 1) : end; } /* set filter co-efficients */ @@ -1260,27 +1256,16 @@ RESTART: next_frame_par->VPP_hf_ini_phase_ = vpp_zoom_center_x & 0xff; /* screen position for source */ -#ifdef TV_REVERSE - start = - video_left + (video_width + 1) / 2 - ((w_in << 17) + - (vpp_zoom_center_x << 10) + - (ratio_x >> 1)) / ratio_x; + start = video_left + (video_width + 1) / 2 - ((w_in << 17) + + (vpp_zoom_center_x << 10) + + (ratio_x >> 1)) / ratio_x; end = ((w_in << 18) + (ratio_x >> 1)) / ratio_x + start - 1; if (super_debug) - pr_info("left:start =%d,%d,%d,%d %d,%d,%d\n", + pr_info("layer%d: left:start =%d,%d,%d,%d %d,%d,%d\n", + input->layer_id, start, end, video_left, video_width, w_in, ratio_x, vpp_zoom_center_x); -#else - start = - video_left + video_width / 2 - ((w_in << 17) + - (vpp_zoom_center_x << 10)) / - ratio_x; - end = (w_in << 18) / ratio_x + start - 1; - if (super_debug) - pr_info("left:start =%d,%d,%d,%d %d,%d,%d\n", - start, end, video_left, - video_width, w_in, ratio_x, vpp_zoom_center_x); -#endif + /* calculate source horizontal clip */ #ifdef TV_REVERSE if (reverse) { @@ -1324,8 +1309,7 @@ RESTART: temp_width = min((video_left + video_width - 1), (vinfo->width - 1)) - video_left + 1; } - temp = - next_frame_par->VPP_hd_start_lines_ + + temp = next_frame_par->VPP_hd_start_lines_ + (temp_width * ratio_x >> 18); next_frame_par->VPP_hd_end_lines_ = (temp <= (w_in - 1)) ? temp : (w_in - 1); @@ -1364,9 +1348,10 @@ RESTART: } if ((wide_mode == VIDEO_WIDEOPTION_NONLINEAR) && (end > start)) { - calculate_non_linear_ratio(ratio_x, end - start, - next_frame_par); - + calculate_non_linear_ratio( + nonlinear_factor, + ratio_x, end - start, + next_frame_par); next_frame_par->VPP_hsc_linear_startp = next_frame_par->VPP_hsc_linear_endp = (start + end) / 2; } @@ -1381,6 +1366,7 @@ RESTART: || !next_frame_par->hscale_skip_count) && (!(vpp_flags & VPP_FLAG_VSCALE_DISABLE))) { int skip = vpp_process_speed_check( + input->layer_id, (next_frame_par->VPP_hd_end_lines_ - next_frame_par->VPP_hd_start_lines_ + 1) / (next_frame_par->hscale_skip_count + 1), @@ -1391,6 +1377,8 @@ RESTART: next_frame_par->VPP_vsc_startp + 1), vinfo->height >> ((vpp_flags & VPP_FLAG_INTERLACE_OUT) ? 1 : 0), + speed_check_width, + speed_check_height, next_frame_par, vinfo, vf); @@ -1412,7 +1400,9 @@ RESTART: (vf->canvas0Addr != 0) && (next_frame_par->vscale_skip_count > 1) && (!next_frame_par->nocomp)) { - pr_info("Try DW buffer for compressed frame scaling.\n"); + pr_info( + "layer%d: Try DW buffer for compressed frame scaling.\n", + input->layer_id); /* for VIDTYPE_COMPRESS, check if we can use double write * buffer when primary frame can not be scaled. @@ -1422,7 +1412,6 @@ RESTART: h_in = height_in = vf->height; next_frame_par->hscale_skip_count = 0; next_frame_par->vscale_skip_count = 0; - goto RESTART; } @@ -1457,40 +1446,43 @@ RESTART: /* coeff selection before skip and apply pre_scaler */ filter->vpp_vert_filter = coeff(vert_coeff_settings, - filter->vpp_vsc_start_phase_step * - (next_frame_par->vscale_skip_count + 1), - 1, - ((vf->type_original & VIDTYPE_TYPEMASK) - != VIDTYPE_PROGRESSIVE), - vf->combing_cur_lev); + filter->vpp_vsc_start_phase_step * + (next_frame_par->vscale_skip_count + 1), + 1, + ((vf->type_original & VIDTYPE_TYPEMASK) + != VIDTYPE_PROGRESSIVE), + vf->combing_cur_lev); + filter->vpp_vert_coeff = filter_table[filter->vpp_vert_filter]; /* when local interlace or AV or ATV */ /* TODO: add 420 check for local */ if (vert_chroma_filter_force_en || (vert_chroma_filter_en - && (((vf->source_type == VFRAME_SOURCE_TYPE_OTHERS) - && (((vf->type_original & VIDTYPE_TYPEMASK) != VIDTYPE_PROGRESSIVE) || - (vf->height < vert_chroma_filter_limit))) - || (vf->source_type == VFRAME_SOURCE_TYPE_CVBS) - || (vf->source_type == VFRAME_SOURCE_TYPE_TUNER)))) { - cur_vert_chroma_filter - = chroma_filter_table[filter->vpp_vert_filter]; - filter->vpp_vert_chroma_coeff - = filter_table[cur_vert_chroma_filter]; + && (((vf->source_type == VFRAME_SOURCE_TYPE_OTHERS) + && (((vf->type_original & VIDTYPE_TYPEMASK) + != VIDTYPE_PROGRESSIVE) + || (vf->height < vert_chroma_filter_limit))) + || (vf->source_type == VFRAME_SOURCE_TYPE_CVBS) + || (vf->source_type == VFRAME_SOURCE_TYPE_TUNER)))) { + vert_chroma_filter = + chroma_filter_table[filter->vpp_vert_filter]; + filter->vpp_vert_chroma_coeff = + filter_table[vert_chroma_filter]; filter->vpp_vert_chroma_filter_en = true; } else { - cur_vert_chroma_filter = COEF_NULL; + vert_chroma_filter = COEF_NULL; filter->vpp_vert_chroma_filter_en = false; } + /* avoid hscaler fitler adjustion affect on picture shift*/ filter->vpp_horz_filter = coeff(horz_coeff_settings, - filter->vpp_hf_start_phase_step, - next_frame_par->VPP_hf_ini_phase_, - ((vf->type_original & VIDTYPE_TYPEMASK) - != VIDTYPE_PROGRESSIVE), - vf->combing_cur_lev); + filter->vpp_hf_start_phase_step, + next_frame_par->VPP_hf_ini_phase_, + ((vf->type_original & VIDTYPE_TYPEMASK) + != VIDTYPE_PROGRESSIVE), + vf->combing_cur_lev); /*for gxl cvbs out index*/ if ((vinfo->mode == VMODE_CVBS) && //DEBUG_TMP (filter->vpp_hf_start_phase_step == (1 << 24))) @@ -1514,9 +1506,8 @@ RESTART: filter->vpp_vsc_start_phase_step >>= 1; ratio_y >>= 1; f2v_get_vertical_phase(ratio_y, ini_vphase, - next_frame_par->VPP_vf_ini_phase_, - vpp_flags & VPP_FLAG_INTERLACE_OUT); - + next_frame_par->VPP_vf_ini_phase_, + vpp_flags & VPP_FLAG_INTERLACE_OUT); } else filter->vpp_pre_vsc_en = 0; @@ -1544,13 +1535,13 @@ RESTART: filter->vpp_vert_filter = vert_scaler_filter; } if (vert_chroma_filter_force_en && - vert_chroma_scaler_filter <= COEF_3D_FILTER) { - cur_vert_chroma_filter = vert_chroma_scaler_filter; - filter->vpp_vert_chroma_coeff - = filter_table[cur_vert_chroma_filter]; - filter->vpp_vert_chroma_filter_en = true; + (vert_chroma_scaler_filter <= COEF_3D_FILTER)) { + vert_chroma_filter = vert_chroma_scaler_filter; + filter->vpp_vert_chroma_coeff = + filter_table[vert_chroma_filter]; + filter->vpp_vert_chroma_filter_en = true; } else { - cur_vert_chroma_filter = COEF_NULL; + vert_chroma_filter = COEF_NULL; filter->vpp_vert_chroma_filter_en = false; } @@ -1559,90 +1550,44 @@ RESTART: filter->vpp_horz_filter = horz_scaler_filter; } -#ifdef TV_3D_FUNCTION_OPEN +#ifdef TV_3D_FUNCTION_OPEN /* final stage for 3D filter overwrite */ if ((next_frame_par->vpp_3d_scale) && force_filter_mode) { filter->vpp_vert_coeff = filter_table[COEF_3D_FILTER]; filter->vpp_vert_filter = COEF_3D_FILTER; } #endif - if ((last_vert_filter != filter->vpp_vert_filter) || - (last_horz_filter != filter->vpp_horz_filter)) { - last_vert_filter = filter->vpp_vert_filter; - last_horz_filter = filter->vpp_horz_filter; - scaler_filter_cnt = 0; - } else { - scaler_filter_cnt++; - } - if ((scaler_filter_cnt >= scaler_filter_cnt_limit) && - ((cur_vert_filter != filter->vpp_vert_filter) || - (cur_horz_filter != filter->vpp_horz_filter))) { - video_property_notify(1); - cur_vert_filter = filter->vpp_vert_filter; - cur_horz_filter = filter->vpp_horz_filter; - scaler_filter_cnt = scaler_filter_cnt_limit; - } - cur_skip_line = next_frame_par->vscale_skip_count; - -#if HAS_VPU_PROT - if (has_vpu_prot()) { - if (get_prot_status()) { - s32 tmp_height = - (((s32) next_frame_par->VPP_vd_end_lines_ + - 1) << 18) / tmp_ratio_y; - s32 tmp_top = 0; - s32 tmp_bottom = 0; - -/* pr_info("height_out %d video_height %d\n", height_out, video_height); */ -/* pr_info("vf1 %d %d %d %d vs %d %d\n", next_frame_par->VPP_hd_start_lines_,*/ -/* next_frame_par->VPP_hd_end_lines_, */ -/* next_frame_par->VPP_vd_start_lines_, next_frame_par->VPP_vd_end_lines_, */ -/* next_frame_par->hscale_skip_count, next_frame_par->vscale_skip_count); */ - if ((s32) video_height > tmp_height) { - tmp_top = (s32) video_top + - (((s32) video_height - tmp_height) >> 1); - } else - tmp_top = (s32) video_top; - tmp_bottom = tmp_top + - (((s32) next_frame_par->VPP_vd_end_lines_ + 1) << 18) / - (s32) tmp_ratio_y; - if (tmp_bottom > (s32) height_out - && tmp_top < (s32) height_out) { - s32 tmp_end = - (s32) next_frame_par->VPP_vd_end_lines_ - - ((tmp_bottom - - (s32) height_out) * - (s32) tmp_ratio_y >> 18); - if (tmp_end < - (s32) next_frame_par->VPP_vd_end_lines_) { - next_frame_par->VPP_vd_end_lines_ = - tmp_end; - } - } else if (tmp_bottom > (s32) height_out - && tmp_top >= (s32) height_out) - next_frame_par->VPP_vd_end_lines_ = 1; - next_frame_par->VPP_vd_end_lines_ = - next_frame_par->VPP_vd_end_lines_ - - h_in / height_out; - if ((s32) next_frame_par->VPP_vd_end_lines_ < - (s32) next_frame_par->VPP_vd_start_lines_) { - next_frame_par->VPP_vd_end_lines_ = - next_frame_par->VPP_vd_start_lines_; - } - if ((s32) next_frame_par->VPP_hd_end_lines_ < - (s32) next_frame_par->VPP_hd_start_lines_) { - next_frame_par->VPP_hd_end_lines_ = - next_frame_par->VPP_hd_start_lines_; - } -/* pr_info("tmp_top %d tmp_bottom %d tmp_height %d\n",*/ -/* tmp_top, tmp_bottom, tmp_height); */ -/* pr_info("vf2 %d %d %d %d\n", next_frame_par->VPP_hd_start_lines_,*/ -/* next_frame_par->VPP_hd_end_lines_, */ -/* next_frame_par->VPP_vd_start_lines_, next_frame_par->VPP_vd_end_lines_); */ - } - } -#endif + if ((cur_filter->last_vert_filter != filter->vpp_vert_filter) || + (cur_filter->last_horz_filter != filter->vpp_horz_filter)) { + cur_filter->last_vert_filter = filter->vpp_vert_filter; + cur_filter->last_horz_filter = filter->vpp_horz_filter; + cur_filter->scaler_filter_cnt = 0; + } else { + cur_filter->scaler_filter_cnt++; + } + if ((cur_filter->scaler_filter_cnt >= + scaler_filter_cnt_limit) && + ((cur_filter->cur_vert_filter != + filter->vpp_vert_filter) || + (cur_filter->cur_horz_filter != + filter->vpp_horz_filter))) { + cur_filter->cur_vert_filter = filter->vpp_vert_filter; + cur_filter->cur_horz_filter = filter->vpp_horz_filter; + cur_filter->scaler_filter_cnt = scaler_filter_cnt_limit; + ret = VppFilter_Success_and_Changed; + } + + /* store the debug info for legacy */ + if (input->layer_id == 0) { + cur_vert_filter = cur_filter->cur_vert_filter; + cur_horz_filter = cur_filter->cur_horz_filter; + cur_vert_chroma_filter = vert_chroma_filter; + cur_skip_line = + next_frame_par->vscale_skip_count; + } + + return ret; } /* *VPP_SRSHARP0_CTRL:0x1d91 @@ -1650,19 +1595,20 @@ RESTART: *[1]if sharpness is enable or vscaler is enable,must set to 1, *sharpness1;reg can only to be w on gxtvbb;which is fix after txl */ -int vpp_set_super_scaler_regs(int scaler_path_sel, - int reg_srscl0_enable, - int reg_srscl0_hsize, - int reg_srscl0_vsize, - int reg_srscl0_hori_ratio, - int reg_srscl0_vert_ratio, - int reg_srscl1_enable, - int reg_srscl1_hsize, - int reg_srscl1_vsize, - int reg_srscl1_hori_ratio, - int reg_srscl1_vert_ratio, - int vpp_postblend_out_width, - int vpp_postblend_out_height) +int vpp_set_super_scaler_regs( + int scaler_path_sel, + int reg_srscl0_enable, + int reg_srscl0_hsize, + int reg_srscl0_vsize, + int reg_srscl0_hori_ratio, + int reg_srscl0_vert_ratio, + int reg_srscl1_enable, + int reg_srscl1_hsize, + int reg_srscl1_vsize, + int reg_srscl1_hori_ratio, + int reg_srscl1_vert_ratio, + int vpp_postblend_out_width, + int vpp_postblend_out_height) { int tmp_data = 0; @@ -1673,94 +1619,101 @@ int vpp_set_super_scaler_regs(int scaler_path_sel, tmp_data = VSYNC_RD_MPEG_REG(VPP_SRSHARP0_CTRL); if (sr0_sr1_refresh) { if (reg_srscl0_hsize > SUPER_CORE0_WIDTH_MAX) { - if (((tmp_data >> 1)&0x1) != 0) + if (((tmp_data >> 1) & 0x1) != 0) VSYNC_WR_MPEG_REG_BITS(VPP_SRSHARP0_CTRL, 0, 1, 1); } else { - if (((tmp_data >> 1)&0x1) != 1) + if (((tmp_data >> 1) & 0x1) != 1) VSYNC_WR_MPEG_REG_BITS(VPP_SRSHARP0_CTRL, 1, 1, 1); } - if ((tmp_data&0x1) != 1) + if ((tmp_data & 0x1) != 1) VSYNC_WR_MPEG_REG_BITS(VPP_SRSHARP0_CTRL, 1, 0, 1); } tmp_data = VSYNC_RD_MPEG_REG(VPP_SRSHARP1_CTRL); if (sr0_sr1_refresh) { - if (((tmp_data >> 1)&0x1) != 1) + if (((tmp_data >> 1) & 0x1) != 1) VSYNC_WR_MPEG_REG_BITS(VPP_SRSHARP1_CTRL, 1, 1, 1); - if ((tmp_data&0x1) != 1) + if ((tmp_data & 0x1) != 1) VSYNC_WR_MPEG_REG_BITS(VPP_SRSHARP1_CTRL, 1, 0, 1); } /* core0 config */ tmp_data = VSYNC_RD_MPEG_REG( SRSHARP0_SHARP_SR2_CTRL + sr_reg_offt); if (sr0_sr1_refresh) { - if (((tmp_data >> 5)&0x1) != (reg_srscl0_vert_ratio&0x1)) + if (((tmp_data >> 5) & 0x1) != (reg_srscl0_vert_ratio&0x1)) VSYNC_WR_MPEG_REG_BITS( SRSHARP0_SHARP_SR2_CTRL + sr_reg_offt, reg_srscl0_vert_ratio&0x1, 5, 1); - if (((tmp_data >> 4)&0x1) != (reg_srscl0_hori_ratio&0x1)) + if (((tmp_data >> 4) & 0x1) != (reg_srscl0_hori_ratio&0x1)) VSYNC_WR_MPEG_REG_BITS( SRSHARP0_SHARP_SR2_CTRL + sr_reg_offt, reg_srscl0_hori_ratio&0x1, 4, 1); if (reg_srscl0_hsize > SUPER_CORE0_WIDTH_MAX) { - if (((tmp_data >> 2)&0x1) != 0) + if (((tmp_data >> 2) & 0x1) != 0) VSYNC_WR_MPEG_REG_BITS( SRSHARP0_SHARP_SR2_CTRL + sr_reg_offt, 0, 2, 1); } else { - if (((tmp_data >> 2)&0x1) != 1) + if (((tmp_data >> 2) & 0x1) != 1) VSYNC_WR_MPEG_REG_BITS( SRSHARP0_SHARP_SR2_CTRL + sr_reg_offt, 1, 2, 1); } - if ((tmp_data & 0x1) == (reg_srscl0_hori_ratio&0x1)) + if ((tmp_data & 0x1) == (reg_srscl0_hori_ratio & 0x1)) VSYNC_WR_MPEG_REG_BITS( SRSHARP0_SHARP_SR2_CTRL + sr_reg_offt, - ((~(reg_srscl0_hori_ratio&0x1))&0x1), 0, 1); + ((~(reg_srscl0_hori_ratio & 0x1)) & 0x1), 0, 1); } /* core1 config */ if (sr_support & SUPER_CORE1_SUPPORT) { - if (is_meson_gxtvbb_cpu()) - tmp_data = sharpness1_sr2_ctrl_32d7; - else - tmp_data = VSYNC_RD_MPEG_REG( - SRSHARP1_SHARP_SR2_CTRL + sr_reg_offt2);/*0xc80*/ - if (is_meson_gxtvbb_cpu() || - (((tmp_data >> 5)&0x1) != (reg_srscl1_vert_ratio&0x1)) || - (((tmp_data >> 4)&0x1) != (reg_srscl1_hori_ratio&0x1)) || - ((tmp_data & 0x1) == (reg_srscl1_hori_ratio&0x1)) || - (((tmp_data >> 2)&0x1) != 1)) { - tmp_data = tmp_data & (~(1 << 5)); - tmp_data = tmp_data & (~(1 << 4)); - tmp_data = tmp_data & (~(1 << 2)); - tmp_data = tmp_data & (~(1 << 0)); - tmp_data |= ((reg_srscl1_vert_ratio&0x1) << 5); - tmp_data |= ((reg_srscl1_hori_ratio&0x1) << 4); - tmp_data |= (1 << 2); - tmp_data |= (((~(reg_srscl1_hori_ratio&0x1))&0x1) << 0); - if (sr0_sr1_refresh) { - VSYNC_WR_MPEG_REG( - SRSHARP1_SHARP_SR2_CTRL + sr_reg_offt2,/*0xc80*/ - tmp_data); - sharpness1_sr2_ctrl_32d7 = tmp_data; + if (is_meson_gxtvbb_cpu()) + tmp_data = sharpness1_sr2_ctrl_32d7; + else + tmp_data = VSYNC_RD_MPEG_REG( + SRSHARP1_SHARP_SR2_CTRL + + sr_reg_offt2); /*0xc80*/ + if (is_meson_gxtvbb_cpu() || + (((tmp_data >> 5) & 0x1) != + (reg_srscl1_vert_ratio & 0x1)) || + (((tmp_data >> 4) & 0x1) != + (reg_srscl1_hori_ratio & 0x1)) || + ((tmp_data & 0x1) == + (reg_srscl1_hori_ratio & 0x1)) || + (((tmp_data >> 2) & 0x1) != 1)) { + tmp_data = tmp_data & (~(1 << 5)); + tmp_data = tmp_data & (~(1 << 4)); + tmp_data = tmp_data & (~(1 << 2)); + tmp_data = tmp_data & (~(1 << 0)); + tmp_data |= ((reg_srscl1_vert_ratio & 0x1) << 5); + tmp_data |= ((reg_srscl1_hori_ratio & 0x1) << 4); + tmp_data |= (1 << 2); + tmp_data |= + (((~(reg_srscl1_hori_ratio & 0x1)) & 0x1) << 0); + if (sr0_sr1_refresh) { + VSYNC_WR_MPEG_REG( + SRSHARP1_SHARP_SR2_CTRL + + sr_reg_offt2, /*0xc80*/ + tmp_data); + sharpness1_sr2_ctrl_32d7 = tmp_data; + } } } - } /* size config */ tmp_data = ((reg_srscl0_hsize & 0x1fff) << 16) | - (reg_srscl0_vsize & 0x1fff); + (reg_srscl0_vsize & 0x1fff); tmp_data2 = VSYNC_RD_MPEG_REG( SRSHARP0_SHARP_HVSIZE + sr_reg_offt); if (tmp_data != tmp_data2) - VSYNC_WR_MPEG_REG(SRSHARP0_SHARP_HVSIZE + sr_reg_offt, - tmp_data); + VSYNC_WR_MPEG_REG( + SRSHARP0_SHARP_HVSIZE + sr_reg_offt, + tmp_data); tmp_data = ((reg_srscl1_hsize & 0x1fff) << 16) | - (reg_srscl1_vsize & 0x1fff); + (reg_srscl1_vsize & 0x1fff); if (sr_support & SUPER_CORE1_SUPPORT) { if (get_cpu_type() != MESON_CPU_MAJOR_ID_GXTVBB) @@ -1860,9 +1813,11 @@ int vpp_set_super_scaler_regs(int scaler_path_sel, return 0; } -static void vpp_set_super_scaler(const struct vinfo_s *vinfo, - struct vpp_frame_par_s *next_frame_par, - bool bypass_sr0, bool bypass_sr1) +static void vpp_set_super_scaler( + u32 vpp_wide_mode, + const struct vinfo_s *vinfo, + struct vpp_frame_par_s *next_frame_par, + bool bypass_sr0, bool bypass_sr1) { unsigned int hor_sc_multiple_num, ver_sc_multiple_num, temp; u32 width_out = next_frame_par->VPP_hsc_endp - @@ -1889,14 +1844,14 @@ static void vpp_set_super_scaler(const struct vinfo_s *vinfo, /* step1: judge core0&core1 vertical enable or disable*/ if (ver_sc_multiple_num >= 2*SUPER_SCALER_V_FACTOR) { next_frame_par->supsc0_vert_ratio = - ((src_width < SUPER_CORE0_WIDTH_MAX/2) && + ((src_width < SUPER_CORE0_WIDTH_MAX / 2) && (sr_support & SUPER_CORE0_SUPPORT)) ? 1 : 0; next_frame_par->supsc1_vert_ratio = ((width_out < SUPER_CORE1_WIDTH_MAX) && - (src_width < SUPER_CORE1_WIDTH_MAX/2) && + (src_width < SUPER_CORE1_WIDTH_MAX / 2) && (sr_support & SUPER_CORE1_SUPPORT)) ? 1 : 0; if (next_frame_par->supsc0_vert_ratio && - (ver_sc_multiple_num < 4*SUPER_SCALER_V_FACTOR)) + (ver_sc_multiple_num < 4 * SUPER_SCALER_V_FACTOR)) next_frame_par->supsc1_vert_ratio = 0; next_frame_par->supsc0_enable = next_frame_par->supsc0_vert_ratio ? 1 : 0; @@ -1912,15 +1867,15 @@ static void vpp_set_super_scaler(const struct vinfo_s *vinfo, if ((hor_sc_multiple_num >= 2) && (vpp_wide_mode != VIDEO_WIDEOPTION_NONLINEAR)) { if ((src_width > SUPER_CORE0_WIDTH_MAX) || - ((src_width > SUPER_CORE0_WIDTH_MAX/2) && + ((src_width > SUPER_CORE0_WIDTH_MAX / 2) && next_frame_par->supsc0_vert_ratio) || - (((src_width << 1) > SUPER_CORE1_WIDTH_MAX/2) && + (((src_width << 1) > SUPER_CORE1_WIDTH_MAX / 2) && next_frame_par->supsc1_vert_ratio)) next_frame_par->supsc0_hori_ratio = 0; else if (sr_support & SUPER_CORE0_SUPPORT) next_frame_par->supsc0_hori_ratio = 1; if (((width_out >> 1) > SUPER_CORE1_WIDTH_MAX) || - (((width_out >> 1) > SUPER_CORE1_WIDTH_MAX/2) && + (((width_out >> 1) > SUPER_CORE1_WIDTH_MAX / 2) && next_frame_par->supsc1_vert_ratio) || (next_frame_par->supsc0_hori_ratio && (hor_sc_multiple_num < 4))) @@ -1951,7 +1906,7 @@ static void vpp_set_super_scaler(const struct vinfo_s *vinfo, } /* option add patch */ if ((ver_sc_multiple_num <= super_scaler_v_ratio) && - (src_height >= SUPER_CORE0_WIDTH_MAX/2) && + (src_height >= SUPER_CORE0_WIDTH_MAX / 2) && (src_height <= 1088) && (ver_sc_multiple_num > SUPER_SCALER_V_FACTOR) && (vinfo->height >= 2000)) { @@ -2117,7 +2072,7 @@ static void vpp_set_super_scaler(const struct vinfo_s *vinfo, width_out >> next_frame_par->supsc0_hori_ratio; } else if ((next_frame_par->supscl_path == PPS_CORE0_CORE1) || (next_frame_par->supscl_path == - PPS_CORE0_POSTBLEND_CORE1)){/*tl1*/ + PPS_CORE0_POSTBLEND_CORE1)){ /*tl1*/ next_frame_par->spsc0_h_in = (height_out >> next_frame_par->supsc0_vert_ratio) >> next_frame_par->supsc1_vert_ratio; @@ -2181,15 +2136,15 @@ static void vpp_set_super_scaler(const struct vinfo_s *vinfo, next_frame_par->supsc1_vert_ratio; } if (super_debug) { - pr_info("spsc0_w_in=%u, spsc0_h_in=%u, spsc1_w_in=%u, spsc1_h_in=%u.\n", + pr_info("layer0: spsc0_w_in=%u, spsc0_h_in=%u, spsc1_w_in=%u, spsc1_h_in=%u.\n", next_frame_par->spsc0_w_in, next_frame_par->spsc0_h_in, next_frame_par->spsc1_w_in, next_frame_par->spsc1_h_in); - pr_info("supsc0_hori=%d,supsc1_hori=%d,supsc0_v=%d,supsc1_v=%d\n", + pr_info("layer0: supsc0_hori=%d,supsc1_hori=%d,supsc0_v=%d,supsc1_v=%d\n", next_frame_par->supsc0_hori_ratio, next_frame_par->supsc1_hori_ratio, next_frame_par->supsc0_vert_ratio, next_frame_par->supsc1_vert_ratio); - pr_info("VPP_hd_start_lines= %d,%d,%d,%d, %d,%d,%d,%d, %d,%d\n", + pr_info("layer0: VPP_hd_start_lines= %d,%d,%d,%d, %d,%d,%d,%d, %d,%d\n", next_frame_par->VPP_hd_start_lines_, next_frame_par->VPP_hd_end_lines_, next_frame_par->VPP_vd_start_lines_, @@ -2202,8 +2157,10 @@ static void vpp_set_super_scaler(const struct vinfo_s *vinfo, next_frame_par->VPP_vsc_endp); } } + #ifdef TV_3D_FUNCTION_OPEN -void get_vpp_3d_mode(u32 process_3d_type, u32 trans_fmt, u32 *vpp_3d_mode) +void get_vpp_3d_mode( + u32 process_3d_type, u32 trans_fmt, u32 *vpp_3d_mode) { switch (trans_fmt) { case TVIN_TFMT_3D_LRH_OLOR: @@ -2231,19 +2188,20 @@ void get_vpp_3d_mode(u32 process_3d_type, u32 trans_fmt, u32 *vpp_3d_mode) break; } } -static void -vpp_get_video_source_size(u32 *src_width, u32 *src_height, + +static void vpp_get_video_source_size( + u32 *src_width, u32 *src_height, u32 process_3d_type, struct vframe_s *vf, struct vpp_frame_par_s *next_frame_par) { if ((process_3d_type & MODE_3D_AUTO) || - (((process_3d_type & MODE_3D_TO_2D_R) || - (process_3d_type & MODE_3D_TO_2D_L) || - (process_3d_type & MODE_3D_LR_SWITCH) || - (process_3d_type & MODE_FORCE_3D_TO_2D_TB) || - (process_3d_type & MODE_FORCE_3D_TO_2D_LR)) && - (process_3d_type & MODE_3D_ENABLE))) { + (((process_3d_type & MODE_3D_TO_2D_R) || + (process_3d_type & MODE_3D_TO_2D_L) || + (process_3d_type & MODE_3D_LR_SWITCH) || + (process_3d_type & MODE_FORCE_3D_TO_2D_TB) || + (process_3d_type & MODE_FORCE_3D_TO_2D_LR)) && + (process_3d_type & MODE_3D_ENABLE))) { if (vf->trans_fmt) { if (process_3d_type & MODE_3D_TO_2D_MASK) *src_height = vf->left_eye.height; @@ -2289,7 +2247,7 @@ vpp_get_video_source_size(u32 *src_width, u32 *src_height, } } else if ((process_3d_type & MODE_3D_LR) || - (process_3d_type & MODE_FORCE_3D_LR)) { + (process_3d_type & MODE_FORCE_3D_LR)) { next_frame_par->vpp_3d_mode = VPP_3D_MODE_LR; if (process_3d_type & MODE_3D_TO_2D_MASK) { *src_width = vf->width >> 1; @@ -2305,7 +2263,7 @@ vpp_get_video_source_size(u32 *src_width, u32 *src_height, } } else if ((process_3d_type & MODE_3D_TB) || - (process_3d_type & MODE_FORCE_3D_TB)) { + (process_3d_type & MODE_FORCE_3D_TB)) { next_frame_par->vpp_3d_mode = VPP_3D_MODE_TB; if (process_3d_type & MODE_3D_TO_2D_MASK) { *src_width = vf->width; @@ -2344,12 +2302,11 @@ vpp_get_video_source_size(u32 *src_width, u32 *src_height, next_frame_par->vpp_3d_scale = 0; } } else if ((process_3d_type & MODE_3D_FA) - || (process_3d_type & MODE_FORCE_3D_FA_LR) - || (process_3d_type & MODE_FORCE_3D_FA_TB)) { + || (process_3d_type & MODE_FORCE_3D_FA_LR) + || (process_3d_type & MODE_FORCE_3D_FA_TB)) { next_frame_par->vpp_3d_mode = VPP_3D_MODE_FA; if (process_3d_type & MODE_3D_TO_2D_MASK) { - if (process_3d_type & MODE_FORCE_3D_FA_TB) { next_frame_par->vpp_3d_mode = VPP_3D_MODE_TB; *src_width = vf->width; @@ -2414,163 +2371,468 @@ vpp_get_video_source_size(u32 *src_width, u32 *src_height, } } #endif -void -vpp_set_filters(u32 process_3d_type, u32 wide_mode, - struct vframe_s *vf, - struct vpp_frame_par_s *next_frame_par, + +static int vpp_set_filters_no_scaler_internal( + struct disp_info_s *input, + u32 width_in, + u32 height_in, + u32 wid_out, + u32 hei_out, const struct vinfo_s *vinfo, - bool bypass_sr) + u32 vpp_flags, + struct vpp_frame_par_s *next_frame_par, struct vframe_s *vf) { - u32 src_width = 0; - u32 src_height = 0; - u32 vpp_flags = 0; - u32 aspect_ratio = 0; - - WARN_ON(vinfo == NULL); - - next_frame_par->VPP_post_blend_vd_v_start_ = 0; - next_frame_par->VPP_post_blend_vd_h_start_ = 0; - - next_frame_par->VPP_postproc_misc_ = 0x200; -#ifdef TV_3D_FUNCTION_OPEN - next_frame_par->vscale_skip_count = 0; - next_frame_par->hscale_skip_count = 0; - /* - *check 3d mode change in display buffer or 3d type - *get the source size according to 3d mode - */ - if (process_3d_type & MODE_3D_ENABLE) { - vpp_get_video_source_size(&src_width, &src_height, - process_3d_type, vf, next_frame_par); - } else { - if (vf->type & VIDTYPE_COMPRESS) { - src_width = vf->compWidth; - src_height = vf->compHeight; - } else { - src_width = vf->width; - src_height = vf->height; - } - next_frame_par->vpp_3d_mode = VPP_3D_MODE_NULL; - next_frame_par->vpp_2pic_mode = 0; - next_frame_par->vpp_3d_scale = 0; - } - next_frame_par->trans_fmt = vf->trans_fmt; - get_vpp_3d_mode(process_3d_type, next_frame_par->trans_fmt, - &next_frame_par->vpp_3d_mode); - if (vpp_3d_scale) - next_frame_par->vpp_3d_scale = 1; - amlog_mask(LOG_MASK_VPP, "%s: src_width %u,src_height %u.\n", __func__, - src_width, src_height); + s32 start, end; + s32 video_top, video_left, temp; + u32 video_width, video_height; + u32 ratio_x = 0; + u32 ratio_y = 0; + u32 ratio_tmp = 0; + int temp_width; + int temp_height; + struct vppfilter_mode_s *filter = &next_frame_par->vpp_filter; + u32 wide_mode; + s32 height_shift = 0; + u32 w_in = width_in; + u32 h_in = height_in; + bool h_crop_enable = false, v_crop_enable = false; + bool skip_policy_check = true; + u32 vskip_step; + s32 video_layer_global_offset_x, video_layer_global_offset_y; + u32 video_source_crop_top, video_source_crop_left; + u32 video_source_crop_bottom, video_source_crop_right; + s32 video_layer_top, video_layer_left; + s32 video_layer_width, video_layer_height; +#ifdef TV_REVERSE + bool reverse = false; #endif - /* check force ratio change flag in display buffer also - * if it exist then it will override the settings in display side - */ - if (vf->ratio_control & DISP_RATIO_FORCECONFIG) { - if ((vf->ratio_control & DISP_RATIO_CTRL_MASK) == - DISP_RATIO_KEEPRATIO) { - if (wide_mode == VIDEO_WIDEOPTION_FULL_STRETCH) - wide_mode = VIDEO_WIDEOPTION_NORMAL; - } else { - if (wide_mode == VIDEO_WIDEOPTION_NORMAL) - wide_mode = VIDEO_WIDEOPTION_FULL_STRETCH; - } - if (vf->ratio_control & DISP_RATIO_FORCE_NORMALWIDE) - wide_mode = VIDEO_WIDEOPTION_NORMAL; - else if (vf->ratio_control & DISP_RATIO_FORCE_FULL_STRETCH) - wide_mode = VIDEO_WIDEOPTION_FULL_STRETCH; - } - - aspect_ratio = (vf->ratio_control & DISP_RATIO_ASPECT_RATIO_MASK) - >> DISP_RATIO_ASPECT_RATIO_BIT; + int ret = VppFilter_Success; - if (vf->type & VIDTYPE_INTERLACE) - vpp_flags = VPP_FLAG_INTERLACE_IN; + if (!input) + return VppFilter_Fail; - if (vf->ratio_control & DISP_RATIO_PORTRAIT_MODE) - vpp_flags |= VPP_FLAG_PORTRAIT_MODE; + video_layer_global_offset_x = input->global_offset_x; + video_layer_global_offset_y = input->global_offset_y; - if (vf->type & VIDTYPE_VSCALE_DISABLE) - vpp_flags |= VPP_FLAG_VSCALE_DISABLE; -#ifndef TV_3D_FUNCTION_OPEN - if (vf->type & VIDTYPE_COMPRESS) { - src_width = vf->compWidth; - src_height = vf->compHeight; - } else { - src_width = vf->width; - src_height = vf->height; - } + video_layer_top = input->layer_top; + video_layer_left = input->layer_left; + video_layer_width = input->layer_width; + video_layer_height = input->layer_height; +#ifdef TV_REVERSE + reverse = input->reverse; #endif + if (vf->type & VIDTYPE_MVC) { - video_source_crop_top = 0; video_source_crop_left = 0; - video_source_crop_bottom = 0; video_source_crop_right = 0; + video_source_crop_top = 0; + video_source_crop_bottom = 0; } else { - video_source_crop_top = video_crop_top_resv; - video_source_crop_left = video_crop_left_resv; - video_source_crop_bottom = video_crop_bottom_resv; - video_source_crop_right = video_crop_right_resv; + video_source_crop_left = input->crop_left; + video_source_crop_right = input->crop_right; + video_source_crop_top = input->crop_top; + video_source_crop_bottom = input->crop_bottom; } - if ((vf->ratio_control & DISP_RATIO_ADAPTED_PICMODE) - && !disable_adapted) { - if (vf->pic_mode.screen_mode != 0xff) - wide_mode = vf->pic_mode.screen_mode; - if (vf->pic_mode.provider == PIC_MODE_PROVIDER_WSS) { - /* from wss, need add global setting */ - video_source_crop_top += vf->pic_mode.vs; - video_source_crop_left += vf->pic_mode.hs; - video_source_crop_bottom += vf->pic_mode.ve; - video_source_crop_right += vf->pic_mode.he; - } else { - /* from PQ database, final setting */ - video_source_crop_top = vf->pic_mode.vs; - video_source_crop_left = vf->pic_mode.hs; - video_source_crop_bottom = vf->pic_mode.ve; - video_source_crop_right = vf->pic_mode.he; - } - if (vf->pic_mode.AFD_enable - && (vf->ratio_control & DISP_RATIO_INFOFRAME_AVAIL)) - wide_mode = VIDEO_WIDEOPTION_AFD; - if (wide_mode == VIDEO_WIDEOPTION_CUSTOM) - custom_ar = vf->pic_mode.custom_ar; + if (likely(w_in > + (video_source_crop_left + video_source_crop_right))) { + w_in -= video_source_crop_left; + w_in -= video_source_crop_right; + h_crop_enable = true; } - vpp_wide_mode = wide_mode; - vpp_flags |= wide_mode | (aspect_ratio << VPP_FLAG_AR_BITS); - - if (vinfo->field_height != vinfo->height) - vpp_flags |= VPP_FLAG_INTERLACE_OUT; - next_frame_par->VPP_post_blend_vd_v_end_ = vinfo->field_height - 1; - next_frame_par->VPP_post_blend_vd_h_end_ = vinfo->width - 1; - next_frame_par->VPP_post_blend_h_size_ = vinfo->width; - vpp_set_filters2(process_3d_type, src_width, src_height, - vinfo->width, vinfo->height, - vinfo, vpp_flags, next_frame_par, vf); - /*config super scaler after set next_frame_par is calc ok for pps*/ - vpp_set_super_scaler(vinfo, next_frame_par, - (bypass_sr | bypass_spscl0), - (bypass_sr | bypass_spscl1)); -} + if (likely(h_in > + (video_source_crop_top + video_source_crop_bottom))) { + h_in -= video_source_crop_top; + h_in -= video_source_crop_bottom; + v_crop_enable = true; + } -void prot_get_parameter(u32 wide_mode, - struct vframe_s *vf, - struct vpp_frame_par_s *next_frame_par, - const struct vinfo_s *vinfo) -{ - u32 src_width = 0; - u32 src_height = 0; - u32 vpp_flags = 0; - u32 aspect_ratio = 0; - u32 process_3d_type = VPP_3D_MODE_NULL; + next_frame_par->vscale_skip_count = 0; + next_frame_par->hscale_skip_count = 0; + next_frame_par->nocomp = false; + if (vpp_flags & VPP_FLAG_INTERLACE_IN) + next_frame_par->vscale_skip_count++; + if (vpp_flags & VPP_FLAG_INTERLACE_OUT) + height_shift++; - WARN_ON(vinfo == NULL); + if (vpp_flags & VPP_FLAG_INTERLACE_IN) + vskip_step = 2; + else + vskip_step = 1; - next_frame_par->VPP_post_blend_vd_v_start_ = 0; - next_frame_par->VPP_post_blend_vd_h_start_ = 0; +RESTART: + /* don't use input->wide_mode */ + wide_mode = vpp_flags & VPP_FLAG_WIDEMODE_MASK; - next_frame_par->VPP_postproc_misc_ = 0x200; + /* + *if we have ever set a cropped display area for video layer + * (by checking video_layer_width/video_height), then + * it will override the input width_out/height_out for + * ratio calculations, a.k.a we have a window for video content + */ + video_top = video_layer_top; + video_left = video_layer_left; + video_width = video_layer_width; + video_height = video_layer_height; + if ((video_top == 0) && (video_left == 0) && (video_width <= 1) + && (video_height <= 1)) { + /* special case to do full screen display */ + video_width = video_layer_width; + video_height = video_layer_height; + } else { + video_top += video_layer_global_offset_y; + video_left += video_layer_global_offset_x; + } + + ratio_x = (1 << 18); + ratio_y = (1 << 18); + + /* screen position for source */ + start = video_top + (video_height + 1) / 2 - + ((h_in << 17) + + (ratio_y >> 1)) / ratio_y; + end = ((h_in << 18) + (ratio_y >> 1)) / ratio_y + start - 1; + if (super_debug) + pr_info("layer%d: top:start =%d,%d,%d,%d %d,%d\n", + input->layer_id, + start, end, video_top, + video_height, h_in, ratio_y); + +#ifdef TV_REVERSE + if (reverse) { + /* calculate source vertical clip */ + if (video_top < 0) { + if (start < 0) { + temp = (-start * ratio_y) >> 18; + next_frame_par->VPP_vd_end_lines_ = + h_in - 1 - temp; + } else + next_frame_par->VPP_vd_end_lines_ = h_in - 1; + } else { + if (start < video_top) { + temp = ((video_top - start) * ratio_y) >> 18; + next_frame_par->VPP_vd_end_lines_ = + h_in - 1 - temp; + } else + next_frame_par->VPP_vd_end_lines_ = h_in - 1; + } + temp = next_frame_par->VPP_vd_end_lines_ - + (video_height * ratio_y >> 18); + next_frame_par->VPP_vd_start_lines_ = (temp >= 0) ? temp : 0; + } else +#endif + { + if (video_top < 0) { + if (start < 0) { + temp = (-start * ratio_y) >> 18; + next_frame_par->VPP_vd_start_lines_ = temp; + } else + next_frame_par->VPP_vd_start_lines_ = 0; + temp_height = min((video_top + video_height - 1), + (vinfo->height - 1)); + } else { + if (start < video_top) { + temp = ((video_top - start) * ratio_y) >> 18; + next_frame_par->VPP_vd_start_lines_ = temp; + } else + next_frame_par->VPP_vd_start_lines_ = 0; + temp_height = min((video_top + video_height - 1), + (vinfo->height - 1)) - video_top + 1; + } + temp = next_frame_par->VPP_vd_start_lines_ + + (temp_height * ratio_y >> 18); + next_frame_par->VPP_vd_end_lines_ = + (temp <= (h_in - 1)) ? temp : (h_in - 1); + } + + if (v_crop_enable) { + next_frame_par->VPP_vd_start_lines_ += video_source_crop_top; + next_frame_par->VPP_vd_end_lines_ += video_source_crop_top; + } + + if (vpp_flags & VPP_FLAG_INTERLACE_IN) + next_frame_par->VPP_vd_start_lines_ &= ~1; + + next_frame_par->VPP_pic_in_height_ = + next_frame_par->VPP_vd_end_lines_ - + next_frame_par->VPP_vd_start_lines_ + 1; + next_frame_par->VPP_pic_in_height_ = + next_frame_par->VPP_pic_in_height_ / + (next_frame_par->vscale_skip_count + 1); + /* + *find overlapped region between + *[start, end], [0, height_out-1], + *[video_top, video_top+video_height-1] + */ + start = max(start, max(0, video_top)); + end = min(end, min((s32)(vinfo->height - 1), + (s32)(video_top + video_height - 1))); + + if (start >= end) { + /* nothing to display */ + next_frame_par->VPP_vsc_startp = 0; + next_frame_par->VPP_vsc_endp = 0; + } else { + next_frame_par->VPP_vsc_startp = + (vpp_flags & VPP_FLAG_INTERLACE_OUT) ? + (start >> 1) : start; + next_frame_par->VPP_vsc_endp = + (vpp_flags & VPP_FLAG_INTERLACE_OUT) ? + (end >> 1) : end; + } + + /* set filter co-efficients */ + ratio_y <<= height_shift; + ratio_tmp = ratio_y / (next_frame_par->vscale_skip_count + 1); + ratio_y = ratio_tmp; + + filter->vpp_vsc_start_phase_step = 0x1000000; + + /* horizontal */ + filter->vpp_hf_start_phase_slope = 0; + filter->vpp_hf_end_phase_slope = 0; + filter->vpp_hf_start_phase_step = 0x1000000; + + next_frame_par->VPP_hsc_linear_startp = next_frame_par->VPP_hsc_startp; + next_frame_par->VPP_hsc_linear_endp = next_frame_par->VPP_hsc_endp; + + filter->vpp_hsc_start_phase_step = 0x1000000; + next_frame_par->VPP_hf_ini_phase_ = 0; + /* screen position for source */ + start = video_left + (video_width + 1) / 2 - + ((w_in << 17) + (ratio_x >> 1)) / ratio_x; + end = ((w_in << 18) + (ratio_x >> 1)) / ratio_x + start - 1; + if (super_debug) + pr_info("layer%d: left:start =%d,%d,%d,%d %d,%d\n", + input->layer_id, + start, end, video_left, + video_width, w_in, ratio_x); + + /* calculate source horizontal clip */ +#ifdef TV_REVERSE + if (reverse) { + if (video_left < 0) { + if (start < 0) { + temp = (-start * ratio_x) >> 18; + next_frame_par->VPP_hd_end_lines_ = + w_in - 1 - temp; + } else + next_frame_par->VPP_hd_end_lines_ = w_in - 1; + } else { + if (start < video_left) { + temp = ((video_left - start) * ratio_x) >> 18; + next_frame_par->VPP_hd_end_lines_ = + w_in - 1 - temp; + } else + next_frame_par->VPP_hd_end_lines_ = w_in - 1; + } + temp = next_frame_par->VPP_hd_end_lines_ - + (video_width * ratio_x >> 18); + next_frame_par->VPP_hd_start_lines_ = (temp >= 0) ? temp : 0; + } else +#endif + { + if (video_left < 0) { + if (start < 0) { + temp = (-start * ratio_x) >> 18; + next_frame_par->VPP_hd_start_lines_ = temp; + + } else + next_frame_par->VPP_hd_start_lines_ = 0; + temp_width = min((video_left + video_width - 1), + (vinfo->width - 1)); + } else { + if (start < video_left) { + temp = ((video_left - start) * ratio_x) >> 18; + next_frame_par->VPP_hd_start_lines_ = temp; + + } else + next_frame_par->VPP_hd_start_lines_ = 0; + temp_width = min((video_left + video_width - 1), + (vinfo->width - 1)) - video_left + 1; + } + temp = next_frame_par->VPP_hd_start_lines_ + + (temp_width * ratio_x >> 18); + next_frame_par->VPP_hd_end_lines_ = + (temp <= (w_in - 1)) ? temp : (w_in - 1); + } + + if (h_crop_enable) { + next_frame_par->VPP_hd_start_lines_ += video_source_crop_left; + next_frame_par->VPP_hd_end_lines_ += video_source_crop_left; + } + + next_frame_par->VPP_line_in_length_ = + next_frame_par->VPP_hd_end_lines_ - + next_frame_par->VPP_hd_start_lines_ + 1; + /* + *find overlapped region between + * [start, end], [0, width_out-1], + * [video_left, video_left+video_width-1] + */ + start = max(start, max(0, video_left)); + end = min(end, + min((s32)(vinfo->width - 1), + (s32)(video_left + video_width - 1))); + + if (start >= end) { + /* nothing to display */ + next_frame_par->VPP_hsc_startp = 0; + next_frame_par->VPP_hsc_endp = 0; + /* avoid mif set wrong or di out size overflow */ + next_frame_par->VPP_hd_start_lines_ = 0; + next_frame_par->VPP_hd_end_lines_ = 0; + next_frame_par->VPP_line_in_length_ = 0; + } else { + next_frame_par->VPP_hsc_startp = start; + next_frame_par->VPP_hsc_endp = end; + } + + /* + *check the painful bandwidth limitation and see + * if we need skip half resolution on source side for progressive + * frames. + */ + /* check vskip and hskip */ + if (((next_frame_par->vscale_skip_count < MAX_VSKIP_COUNT) + || !next_frame_par->hscale_skip_count) + && (!(vpp_flags & VPP_FLAG_VSCALE_DISABLE))) { + int skip = SPEED_CHECK_DONE; + + if (skip == SPEED_CHECK_VSKIP) { + u32 next_vskip = + next_frame_par->vscale_skip_count + vskip_step; + + if (next_vskip <= MAX_VSKIP_COUNT) { + next_frame_par->vscale_skip_count = next_vskip; + goto RESTART; + } else + next_frame_par->hscale_skip_count = 1; + } else if (skip == SPEED_CHECK_HSKIP) + next_frame_par->hscale_skip_count = 1; + } + + if ((vf->type & VIDTYPE_COMPRESS) && + (vf->canvas0Addr != 0) && + (next_frame_par->vscale_skip_count > 1) && + (!next_frame_par->nocomp)) { + pr_info( + "layer%d: Try DW buffer for compressed frame scaling.\n", + input->layer_id); + + /* for VIDTYPE_COMPRESS, check if we can use double write + * buffer when primary frame can not be scaled. + */ + next_frame_par->nocomp = true; + w_in = width_in = vf->width; + h_in = height_in = vf->height; + next_frame_par->hscale_skip_count = 0; + next_frame_par->vscale_skip_count = 0; + goto RESTART; + } + + if ((skip_policy & 0xf0) && (skip_policy_check == true)) { + skip_policy_check = false; + if (skip_policy & 0x40) { + next_frame_par->vscale_skip_count = skip_policy & 0xf; + goto RESTART; + } else if (skip_policy & 0x80) { + if ((((vf->width >= 4096) && + (!(vf->type & VIDTYPE_COMPRESS))) || + (vf->flag & VFRAME_FLAG_HIGH_BANDWIDTH)) + && (next_frame_par->vscale_skip_count == 0)) { + next_frame_par->vscale_skip_count = + skip_policy & 0xf; + goto RESTART; + } + } + } + + next_frame_par->video_input_h = next_frame_par->VPP_vd_end_lines_ - + next_frame_par->VPP_vd_start_lines_ + 1; + next_frame_par->video_input_h = next_frame_par->video_input_h / + (next_frame_par->vscale_skip_count + 1); + next_frame_par->video_input_w = next_frame_par->VPP_hd_end_lines_ - + next_frame_par->VPP_hd_start_lines_ + 1; + next_frame_par->video_input_w = next_frame_par->video_input_w / + (next_frame_par->hscale_skip_count + 1); + + filter->vpp_hsc_start_phase_step = 0x1000000; + + /* apply line skip */ + if (next_frame_par->hscale_skip_count) { + filter->vpp_hf_start_phase_step >>= 1; + filter->vpp_hsc_start_phase_step >>= 1; + next_frame_par->VPP_line_in_length_ >>= 1; + } + + return ret; +} + +int vpp_set_filters( + struct disp_info_s *input, + struct vframe_s *vf, + struct vpp_frame_par_s *next_frame_par, + const struct vinfo_s *vinfo, + bool bypass_sr) +{ + u32 src_width = 0; + u32 src_height = 0; + u32 vpp_flags = 0; + u32 aspect_ratio = 0; + u32 process_3d_type; + u32 wide_mode; + int ret = VppFilter_Fail; + struct disp_info_s local_input; + + if (!input) + return ret; + + WARN_ON(vinfo == NULL); + + /* use local var to avoid the input data be overwriten */ + memcpy(&local_input, input, sizeof(struct disp_info_s)); + + process_3d_type = local_input.proc_3d_type; + wide_mode = local_input.wide_mode; + + next_frame_par->VPP_post_blend_vd_v_start_ = 0; + next_frame_par->VPP_post_blend_vd_h_start_ = 0; + + next_frame_par->VPP_postproc_misc_ = 0x200; +#ifdef TV_3D_FUNCTION_OPEN + next_frame_par->vscale_skip_count = 0; + next_frame_par->hscale_skip_count = 0; + /* + *check 3d mode change in display buffer or 3d type + *get the source size according to 3d mode + */ + if (process_3d_type & MODE_3D_ENABLE) { + vpp_get_video_source_size(&src_width, &src_height, + process_3d_type, vf, next_frame_par); + } else { + if (vf->type & VIDTYPE_COMPRESS) { + src_width = vf->compWidth; + src_height = vf->compHeight; + } else { + src_width = vf->width; + src_height = vf->height; + } + next_frame_par->vpp_3d_mode = VPP_3D_MODE_NULL; + next_frame_par->vpp_2pic_mode = 0; + next_frame_par->vpp_3d_scale = 0; + } + next_frame_par->trans_fmt = vf->trans_fmt; + get_vpp_3d_mode(process_3d_type, + next_frame_par->trans_fmt, + &next_frame_par->vpp_3d_mode); + if (local_input.vpp_3d_scale) + next_frame_par->vpp_3d_scale = 1; + amlog_mask(LOG_MASK_VPP, "%s: src_width %u,src_height %u.\n", __func__, + src_width, src_height); +#endif /* check force ratio change flag in display buffer also * if it exist then it will override the settings in display side */ @@ -2600,136 +2862,185 @@ void prot_get_parameter(u32 wide_mode, if (vf->type & VIDTYPE_VSCALE_DISABLE) vpp_flags |= VPP_FLAG_VSCALE_DISABLE; +#ifndef TV_3D_FUNCTION_OPEN + if (vf->type & VIDTYPE_COMPRESS) { + src_width = vf->compWidth; + src_height = vf->compHeight; + } else { + src_width = vf->width; + src_height = vf->height; + } +#endif + + if ((vf->ratio_control & DISP_RATIO_ADAPTED_PICMODE) + && !disable_adapted) { + if (vf->pic_mode.screen_mode != 0xff) + wide_mode = vf->pic_mode.screen_mode; - src_width = vf->width; - src_height = vf->height; + if (vf->pic_mode.AFD_enable + && (vf->ratio_control & DISP_RATIO_INFOFRAME_AVAIL)) + wide_mode = VIDEO_WIDEOPTION_AFD; + if (wide_mode == VIDEO_WIDEOPTION_CUSTOM) { + if (!custom_ar) + local_input.custom_ar = custom_ar; + else + local_input.custom_ar = + vf->pic_mode.custom_ar; + } + if (vf->pic_mode.provider == PIC_MODE_PROVIDER_WSS) { + /* from wss, need add global setting */ + local_input.crop_top += vf->pic_mode.vs; + local_input.crop_left += vf->pic_mode.hs; + local_input.crop_bottom += vf->pic_mode.ve; + local_input.crop_right += vf->pic_mode.he; + } else { + /* from PQ database, final setting */ + local_input.crop_top = vf->pic_mode.vs; + local_input.crop_left = vf->pic_mode.hs; + local_input.crop_bottom = vf->pic_mode.ve; + local_input.crop_right = vf->pic_mode.he; + } + } - vpp_wide_mode = wide_mode; + /* don't restore the wide mode */ + /* input->wide_mode = wide_mode; */ vpp_flags |= wide_mode | (aspect_ratio << VPP_FLAG_AR_BITS); if (vinfo->field_height != vinfo->height) vpp_flags |= VPP_FLAG_INTERLACE_OUT; - next_frame_par->VPP_post_blend_vd_v_end_ = - vinfo->field_height - 1; - next_frame_par->VPP_post_blend_vd_h_end_ = - vinfo->width - 1; + next_frame_par->VPP_post_blend_vd_v_end_ = vinfo->field_height - 1; + next_frame_par->VPP_post_blend_vd_h_end_ = vinfo->width - 1; next_frame_par->VPP_post_blend_h_size_ = vinfo->width; - vpp_set_filters2(process_3d_type, src_width, src_height, - vinfo->width, vinfo->height, - vinfo, vpp_flags, next_frame_par, vf); -} + ret = vpp_set_filters_internal( + &local_input, src_width, src_height, + vinfo->width, vinfo->height, + vinfo, vpp_flags, next_frame_par, vf); -void vpp_set_osd_layer_preblend(u32 *enable) -{ - osd_layer_preblend = *enable; + /*config super scaler after set next_frame_par is calc ok for pps*/ + if (local_input.layer_id == 0) + vpp_set_super_scaler( + wide_mode, + vinfo, next_frame_par, + (bypass_sr | bypass_spscl0), + (bypass_sr | bypass_spscl1)); + return ret; } -void vpp_set_osd_layer_position(s32 *para) +int vpp_set_filters_no_scaler( + struct disp_info_s *input, + struct vframe_s *vf, + struct vpp_frame_par_s *next_frame_par, + const struct vinfo_s *vinfo) { - if (IS_ERR_OR_NULL(¶[3])) { - pr_info("para[3] is null\n"); - return; - } - if (para[2] < 2 || para[3] < 2) - return; + u32 src_width = 0; + u32 src_height = 0; + u32 vpp_flags = 0; + u32 aspect_ratio = 0; + u32 wide_mode; + int ret = VppFilter_Fail; + struct disp_info_s local_input; - osd_layer_left = para[0]; - osd_layer_top = para[1]; - osd_layer_width = para[2]; - osd_layer_height = para[3]; -} + if (!input) + return ret; -void vpp_set_video_source_crop(u32 t, u32 l, u32 b, u32 r) -{ - video_crop_top_resv = t; - video_crop_left_resv = l; - video_crop_bottom_resv = b; - video_crop_right_resv = r; -} + WARN_ON(vinfo == NULL); -void vpp_get_video_source_crop(u32 *t, u32 *l, u32 *b, u32 *r) -{ - *t = video_crop_top_resv; - *l = video_crop_left_resv; - *b = video_crop_bottom_resv; - *r = video_crop_right_resv; -} + /* use local var to avoid the input data be overwriten */ + memcpy(&local_input, input, sizeof(struct disp_info_s)); + /* wide_mode = local_input.wide_mode; */ + wide_mode = VIDEO_WIDEOPTION_NORMAL; + next_frame_par->VPP_post_blend_vd_v_start_ = 0; + next_frame_par->VPP_post_blend_vd_h_start_ = 0; -void vpp_set_video_layer_position(s32 x, s32 y, s32 w, s32 h) -{ - if ((w < 0) || (h < 0)) - return; + next_frame_par->VPP_postproc_misc_ = 0x200; + next_frame_par->vscale_skip_count = 0; + next_frame_par->hscale_skip_count = 0; + if (vf->type & VIDTYPE_COMPRESS) { + src_width = vf->compWidth; + src_height = vf->compHeight; + } else { + src_width = vf->width; + src_height = vf->height; + } +#ifdef TV_3D_FUNCTION_OPEN + next_frame_par->vpp_3d_mode = VPP_3D_MODE_NULL; + next_frame_par->vpp_2pic_mode = 0; + next_frame_par->vpp_3d_scale = 0; + next_frame_par->trans_fmt = vf->trans_fmt; +#endif - video_layer_left = x; - video_layer_top = y; - video_layer_width = w; - video_layer_height = h; -} + if (vf->type & VIDTYPE_INTERLACE) + vpp_flags = VPP_FLAG_INTERLACE_IN; -void vpp_get_video_layer_position(s32 *x, s32 *y, s32 *w, s32 *h) -{ - *x = video_layer_left; - *y = video_layer_top; - *w = video_layer_width; - *h = video_layer_height; -} + if ((vf->ratio_control & DISP_RATIO_ADAPTED_PICMODE) + && !disable_adapted) { + if (vf->pic_mode.provider == PIC_MODE_PROVIDER_WSS) { + /* from wss, need add global setting */ + local_input.crop_top += vf->pic_mode.vs; + local_input.crop_left += vf->pic_mode.hs; + local_input.crop_bottom += vf->pic_mode.ve; + local_input.crop_right += vf->pic_mode.he; + } else { + /* from PQ database, final setting */ + local_input.crop_top = vf->pic_mode.vs; + local_input.crop_left = vf->pic_mode.hs; + local_input.crop_bottom = vf->pic_mode.ve; + local_input.crop_right = vf->pic_mode.he; + } + } -void vpp_set_global_offset(s32 x, s32 y) -{ - video_layer_global_offset_x = x; - video_layer_global_offset_y = y; -} + aspect_ratio = + (vf->ratio_control & DISP_RATIO_ASPECT_RATIO_MASK) + >> DISP_RATIO_ASPECT_RATIO_BIT; -void vpp_get_global_offset(s32 *x, s32 *y) -{ - *x = video_layer_global_offset_x; - *y = video_layer_global_offset_y; -} + /* don't restore the wide mode */ + /* input->wide_mode = wide_mode; */ + vpp_flags |= wide_mode | (aspect_ratio << VPP_FLAG_AR_BITS); + + if (vinfo->field_height != vinfo->height) + vpp_flags |= VPP_FLAG_INTERLACE_OUT; -s32 vpp_set_nonlinear_factor(u32 f) + next_frame_par->VPP_post_blend_vd_v_end_ = vinfo->field_height - 1; + next_frame_par->VPP_post_blend_vd_h_end_ = vinfo->width - 1; + next_frame_par->VPP_post_blend_h_size_ = vinfo->width; + + ret = vpp_set_filters_no_scaler_internal( + &local_input, src_width, src_height, + vinfo->width, vinfo->height, + vinfo, vpp_flags, next_frame_par, vf); + return ret; +} +s32 vpp_set_nonlinear_factor( + struct disp_info_s *info, u32 f) { if (f < MAX_NONLINEAR_FACTOR) { - nonlinear_factor = f; + info->nonlinear_factor = f; return 0; } return -1; } -u32 vpp_get_nonlinear_factor(void) -{ - return nonlinear_factor; -} - -void vpp_set_zoom_ratio(u32 r) -{ - vpp_zoom_ratio = r; -} - -u32 vpp_get_zoom_ratio(void) -{ - return vpp_zoom_ratio; -} - -void vpp_set_video_speed_check(u32 h, u32 w) +u32 vpp_get_nonlinear_factor( + struct disp_info_s *info) { - video_speed_check_height = h; - video_speed_check_width = w; + return info->nonlinear_factor; } -void vpp_get_video_speed_check(u32 *h, u32 *w) +void vpp_disp_info_init( + struct disp_info_s *info, u8 id) { - *h = video_speed_check_height; - *w = video_speed_check_width; -} - -#ifdef TV_3D_FUNCTION_OPEN -void vpp_set_3d_scale(bool enable) -{ - vpp_3d_scale = enable; + if (info) { + memset(info, 0, sizeof(struct disp_info_s)); + info->nonlinear_factor = MAX_NONLINEAR_FACTOR / 2; + info->zoom_ratio = 100; + info->speed_check_width = 1800; + info->speed_check_height = 1400; + info->layer_id = id; + memset(&gfilter[id], 0, sizeof(struct filter_info_s)); + } } -#endif void vpp_super_scaler_support(void) { diff --git a/include/linux/amlogic/media/registers/regs/vpp_regs.h b/include/linux/amlogic/media/registers/regs/vpp_regs.h index 7daba09..b59bc6c 100644 --- a/include/linux/amlogic/media/registers/regs/vpp_regs.h +++ b/include/linux/amlogic/media/registers/regs/vpp_regs.h @@ -245,6 +245,9 @@ #define OSD1_BLEND_SRC_CTRL 0x1dfd #define OSD2_BLEND_SRC_CTRL 0x1dfe +#define VPP_POST_BLEND_BLEND_DUMMY_DATA 0x3968 +#define VPP_POST_BLEND_DUMMY_ALPHA 0x3969 + /* after g12b */ #define SRSHARP0_SHARP_SYNC_CTRL 0x3eb0 #define SRSHARP1_SHARP_SYNC_CTRL 0x3fb0 diff --git a/include/linux/amlogic/media/utils/amstream.h b/include/linux/amlogic/media/utils/amstream.h index 5b44f40..d845ae1 100644 --- a/include/linux/amlogic/media/utils/amstream.h +++ b/include/linux/amlogic/media/utils/amstream.h @@ -91,6 +91,31 @@ #define AMSTREAM_IOC_GLOBAL_SET_VIDEO_OUTPUT _IOW((_A_M), 0x22, int) #define AMSTREAM_IOC_GET_VIDEO_LAYER1_ON _IOR((_A_M), 0x23, int) +#define AMSTREAM_IOC_GLOBAL_GET_VIDEOPIP_OUTPUT _IOR((_A_M), 0x2b, int) +#define AMSTREAM_IOC_GLOBAL_SET_VIDEOPIP_OUTPUT _IOW((_A_M), 0x2c, int) +#define AMSTREAM_IOC_GET_VIDEOPIP_DISABLE _IOR((_A_M), 0x2d, int) +#define AMSTREAM_IOC_SET_VIDEOPIP_DISABLE _IOW((_A_M), 0x2e, int) +#define AMSTREAM_IOC_GET_VIDEOPIP_AXIS _IOR((_A_M), 0x2f, int) +#define AMSTREAM_IOC_SET_VIDEOPIP_AXIS _IOW((_A_M), 0x30, int) +#define AMSTREAM_IOC_GET_VIDEOPIP_CROP _IOR((_A_M), 0x31, int) +#define AMSTREAM_IOC_SET_VIDEOPIP_CROP _IOW((_A_M), 0x32, int) +#define AMSTREAM_IOC_GET_PIP_SCREEN_MODE _IOR((_A_M), 0x33, int) +#define AMSTREAM_IOC_SET_PIP_SCREEN_MODE _IOW((_A_M), 0x34, int) +#define AMSTREAM_IOC_GET_PIP_ZORDER _IOW((_A_M), 0x35, unsigned int) +#define AMSTREAM_IOC_SET_PIP_ZORDER _IOW((_A_M), 0x36, unsigned int) + +#define AMSTREAM_IOC_GET_ZORDER _IOW((_A_M), 0x37, unsigned int) +#define AMSTREAM_IOC_SET_ZORDER _IOW((_A_M), 0x38, unsigned int) + +#define AMSTREAM_IOC_QUERY_LAYER _IOW((_A_M), 0x39, unsigned int) +#define AMSTREAM_IOC_ALLOC_LAYER _IOW((_A_M), 0x3a, unsigned int) +#define AMSTREAM_IOC_FREE_LAYER _IOW((_A_M), 0x3b, unsigned int) + +/* VPP.3D IOCTL command list^M */ +#define AMSTREAM_IOC_SET_3D_TYPE _IOW((_A_M), 0x3c, unsigned int) +#define AMSTREAM_IOC_GET_3D_TYPE _IOW((_A_M), 0x3d, unsigned int) +#define AMSTREAM_IOC_GET_SOURCE_VIDEO_3D_TYPE _IOW((_A_M), 0x3e, unsigned int) + #define AMSTREAM_IOC_APTS _IOR((_A_M), 0x40, int) #define AMSTREAM_IOC_VPTS _IOR((_A_M), 0x41, int) #define AMSTREAM_IOC_PCRSCR _IOR((_A_M), 0x42, int) @@ -108,11 +133,6 @@ #define AMSTREAM_IOC_SET_VIDEO_CROP _IOW((_A_M), 0x4e, int) #define AMSTREAM_IOC_PCRID _IOW((_A_M), 0x4f, int) -/* VPP.3D IOCTL command list^M */ -#define AMSTREAM_IOC_SET_3D_TYPE _IOW((_A_M), 0x3c, unsigned int) -#define AMSTREAM_IOC_GET_3D_TYPE _IOW((_A_M), 0x3d, unsigned int) -#define AMSTREAM_IOC_GET_SOURCE_VIDEO_3D_TYPE _IOW((_A_M), 0x3e, unsigned int) - #define AMSTREAM_IOC_SUB_NUM _IOR((_A_M), 0x50, int) #define AMSTREAM_IOC_SUB_INFO _IOR((_A_M), 0x51, int) #define AMSTREAM_IOC_GET_BLACKOUT_POLICY _IOR((_A_M), 0x52, int) diff --git a/include/linux/amlogic/media/vfm/vframe_receiver.h b/include/linux/amlogic/media/vfm/vframe_receiver.h index eac4cd8..74ed848 100644 --- a/include/linux/amlogic/media/vfm/vframe_receiver.h +++ b/include/linux/amlogic/media/vfm/vframe_receiver.h @@ -39,6 +39,7 @@ #define VFRAME_EVENT_PROVIDER_FR_HINT 13 #define VFRAME_EVENT_PROVIDER_FR_END_HINT 14 #define VFRAME_EVENT_PROVIDER_QUREY_DISPLAY_INFO 15 +#define VFRAME_EVENT_PROVIDER_PROPERTY_CHANGED 16 enum receviver_start_e { RECEIVER_STATE_NULL = -1, diff --git a/include/linux/amlogic/media/video_sink/video.h b/include/linux/amlogic/media/video_sink/video.h index 548fcea..8ef2538 100644 --- a/include/linux/amlogic/media/video_sink/video.h +++ b/include/linux/amlogic/media/video_sink/video.h @@ -17,7 +17,19 @@ #ifndef VIDEO_H #define VIDEO_H -#include "vpp.h" + +#define MAX_VD_LAYERS 2 + +#define LAYER1_BUSY (1 << 11) +#define LAYER1_AFBC (1 << 10) +#define LAYER1_SCALER (1 << 9) +#define LAYER1_AVAIL (1 << 8) +#define LAYER0_BUSY (1 << 3) +#define LAYER0_AFBC (1 << 2) +#define LAYER0_SCALER (1 << 1) +#define LAYER0_AVAIL (1 << 0) + +#define LAYER_BITS_SHFIT 8 enum { VIDEO_WIDEOPTION_NORMAL = 0, @@ -39,16 +51,6 @@ enum { VIDEO_WIDEOPTION_MAX = 16 }; -extern bool pre_scaler_en; -extern bool super_scaler; -#define VIDEO_NOTIFY_TRICK_WAIT 0x01 -#define VIDEO_NOTIFY_PROVIDER_GET 0x02 -#define VIDEO_NOTIFY_PROVIDER_PUT 0x04 -#define VIDEO_NOTIFY_FRAME_WAIT 0x08 -#define VIDEO_NOTIFY_POS_CHANGED 0x10 - -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 */ - /* TODO: move to register headers */ #define VPP_VADJ2_BLMINUS_EN (1 << 3) #define VPP_VADJ2_EN (1 << 2) @@ -160,7 +162,7 @@ extern bool super_scaler; #define VPP_PHASECTL_TYPE_INTERLACE (1<<16) #define VPP_PHASECTL_VSL0B (1<<15) #define VPP_PHASECTL_DOUBLELINE_BIT 17 -#define VPP_PHASECTL_DOUBLELINE_WID 1 +#define VPP_PHASECTL_DOUBLELINE_WID 2 #define VPP_PHASECTL_INIRPTNUM_MASK 0x3 #define VPP_PHASECTL_INIRPTNUM_WID 2 #define VPP_PHASECTL_INIRPTNUMB_BIT 13 @@ -207,11 +209,7 @@ extern bool super_scaler; #define VPP_FORCE_FIELD_BOTTOM (1 << 16) #define VPP_FOURCE_GO_FIELD (1 << 15) #define VPP_FOURCE_GO_LINE (1 << 14) -#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ #define VPP_OFIFO_SIZE_WID 13 -#else -#define VPP_OFIFO_SIZE_WID 12 -#endif /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ #define VPP_OFIFO_SIZE_MASK 0xfff #define VPP_OFIFO_SIZE_BIT 0 @@ -226,44 +224,6 @@ extern bool super_scaler; #define VPP_COEF_INDEX_MASK 0x7f #define VPP_COEF_INDEX_BIT 0 -#define P_VFIFO2VD_LINE_TOP_START P_ENCP_VFIFO2VD_LINE_TOP_START -#endif - -#if 0 /* MESON_CPU_TYPE < MESON_CPU_TYPE_MESON8 */ -#define READ_VCBUS_REG(r) READ_CBUS_REG(r) -#define WRITE_VCBUS_REG(r, val) WRITE_CBUS_REG(r, val) -#define WRITE_VCBUS_REG_BITS(r, val, from, size) \ - WRITE_CBUS_REG_BITS(r, val, from, size) -#define SET_VCBUS_REG_MASK(r, mask) SET_CBUS_REG_MASK(r, mask) -#define CLEAR_VCBUS_REG_MASK(r, mask) CLEAR_CBUS_REG_MASK(r, mask) -#endif - -#ifdef CONFIG_CLK81_DFS -extern int check_and_set_clk81(void); -#endif - -#ifdef CONFIG_GAMMA_PROC -extern int gamma_adjust(void); -#endif -#ifdef CONFIG_SCREEN_ON_EARLY -extern void osd_resume_early(void); -extern void vout_pll_resume_early(void); -extern void resume_vout_early(void); -extern int power_key_pressed; -#endif - -#ifdef CONFIG_AM_VIDEO2 -extern void set_clone_frame_rate(unsigned int frame_rate, unsigned int delay); -#endif -extern struct vframe_provider_s *vf_get_provider_by_name( - const char *provider_name); - -extern void prot_get_parameter(u32 wide_mode, struct vframe_s *vf, - struct vpp_frame_par_s *next_frame_par, - const struct vinfo_s *vinfo); -u32 get_blackout_policy(void); -int get_video0_frame_info(struct vframe_s *vf); - #define AMVIDEO_UPDATE_OSD_MODE 0x00000001 #ifdef CONFIG_AMLOGIC_MEDIA_VIDEO int amvideo_notifier_call_chain(unsigned long val, void *v); @@ -275,8 +235,11 @@ static inline int amvideo_notifier_call_chain(unsigned long val, void *v) #endif int query_video_status(int type, int *value); -int get_video0_frame_info(struct vframe_s *vf); -struct device *get_video_device(void); +u32 set_blackout_policy(int policy); +u32 get_blackout_policy(void); +void set_video_angle(u32 s_value); +u32 get_video_angle(void); extern unsigned int DI_POST_REG_RD(unsigned int addr); extern int DI_POST_WR_REG_BITS(u32 adr, u32 val, u32 start, u32 len); + #endif /* VIDEO_H */ diff --git a/include/linux/amlogic/media/video_sink/vpp.h b/include/linux/amlogic/media/video_sink/vpp.h index 8f2c7db..62ee86a 100644 --- a/include/linux/amlogic/media/video_sink/vpp.h +++ b/include/linux/amlogic/media/video_sink/vpp.h @@ -17,8 +17,13 @@ #ifndef VPP_H #define VPP_H + #include -#include + +#define TV_3D_FUNCTION_OPEN +#define TV_REVERSE + +extern bool super_scaler; #define VPP_FLAG_WIDEMODE_MASK 0x0000000F #define VPP_FLAG_INTERLACE_OUT 0x00000010 @@ -43,6 +48,12 @@ #define SPEED_CHECK_HSKIP 1 #define SPEED_CHECK_VSKIP 2 +enum vppfilter_state_e { + VppFilter_Fail = -1, + VppFilter_Success = 0, + VppFilter_Success_and_Changed, +}; + enum f2v_vphase_type_e { F2V_IT2IT = 0, F2V_IB2IB, @@ -54,7 +65,7 @@ enum f2v_vphase_type_e { F2V_IB2P, F2V_P2P, F2V_TYPE_MAX -}; /* frame to video conversion type */ +}; /* frame to video conversion type */ struct f2v_vphase_s { s8 repeat_skip; @@ -142,21 +153,34 @@ struct vpp_frame_par_s { }; -#if 1 - -/* - *(MESON_CPU_TYPE==MESON_CPU_TYPE_MESON6TV)|| - *(MESON_CPU_TYPE==MESON_CPU_TYPE_MESONG9TV) - */ -#define TV_3D_FUNCTION_OPEN -#endif +struct disp_info_s { + u8 layer_id; -#define TV_REVERSE + u32 angle; + u32 custom_ar; -#ifdef TV_REVERSE -extern bool reverse; -#endif -extern bool platform_type; + bool reverse; + u32 proc_3d_type; + bool vpp_3d_scale; + u32 nonlinear_factor; + + u32 wide_mode; + u32 zoom_ratio; + s32 zoom_center_x; + s32 zoom_center_y; + s32 layer_top; + s32 layer_left; + s32 layer_width; + s32 layer_height; + u32 crop_top; + u32 crop_left; + u32 crop_bottom; + u32 crop_right; + s32 global_offset_x; + s32 global_offset_y; + u32 speed_check_width; + u32 speed_check_height; +}; enum select_scaler_path_e { CORE0_PPS_CORE1 = 0, /*CORE0_PPS_CORE1_POSTBLEND*/ @@ -187,7 +211,6 @@ enum select_scaler_path_e { #ifdef TV_3D_FUNCTION_OPEN - /*cmd use for 3d operation*/ #define MODE_3D_DISABLE 0x00000000 #define MODE_3D_ENABLE 0x00000001 @@ -222,11 +245,16 @@ enum select_scaler_path_e { #define MODE_3D_OUT_FA_MASK \ (MODE_3D_OUT_FA_L_FIRST | \ - MODE_3D_OUT_FA_R_FIRST|MODE_3D_OUT_FA_LB_FIRST|MODE_3D_OUT_FA_RB_FIRST) + MODE_3D_OUT_FA_R_FIRST | \ + MODE_3D_OUT_FA_LB_FIRST | \ + MODE_3D_OUT_FA_RB_FIRST) #define MODE_3D_TO_2D_MASK \ - (MODE_3D_TO_2D_L|MODE_3D_TO_2D_R|MODE_3D_OUT_FA_MASK | \ - MODE_FORCE_3D_TO_2D_LR | MODE_FORCE_3D_TO_2D_TB) + (MODE_3D_TO_2D_L | \ + MODE_3D_TO_2D_R | \ + MODE_3D_OUT_FA_MASK | \ + MODE_FORCE_3D_TO_2D_LR | \ + MODE_FORCE_3D_TO_2D_TB) #define VPP_3D_MODE_NULL 0x0 #define VPP_3D_MODE_LR 0x1 @@ -240,78 +268,49 @@ enum select_scaler_path_e { #define VPP_PIC0_FIRST 0x0 #define VPP_PIC1_FIRST 0x8 -extern -void vpp_set_3d_scale(bool enable); -extern -void get_vpp_3d_mode(u32 process_3d_type, u32 trans_fmt, u32 *vpp_3d_mode); +extern void get_vpp_3d_mode(u32 process_3d_type, + u32 trans_fmt, u32 *vpp_3d_mode); #endif -extern void -vpp_set_filters(u32 process_3d_type, u32 wide_mode, struct vframe_s *vf, - struct vpp_frame_par_s *next_frame_par, - const struct vinfo_s *vinfo, - bool bypass_sr); - -extern void vpp_set_video_source_crop(u32 t, u32 l, u32 b, u32 r); - -extern void vpp_get_video_source_crop(u32 *t, u32 *l, u32 *b, u32 *r); - -extern void vpp_set_video_layer_position(s32 x, s32 y, s32 w, s32 h); - -extern void vpp_get_video_layer_position(s32 *x, s32 *y, s32 *w, s32 *h); - -extern void vpp_set_global_offset(s32 x, s32 y); - -extern void vpp_get_global_offset(s32 *x, s32 *y); - -extern void vpp_set_zoom_ratio(u32 r); +extern int vpp_set_filters( + struct disp_info_s *input, + struct vframe_s *vf, + struct vpp_frame_par_s *next_frame_par, + const struct vinfo_s *vinfo, + bool bypass_sr); -extern u32 vpp_get_zoom_ratio(void); +extern int vpp_set_filters_no_scaler( + struct disp_info_s *input, + struct vframe_s *vf, + struct vpp_frame_par_s *next_frame_par, + const struct vinfo_s *vinfo); -extern void vpp_set_osd_layer_preblend(u32 *enable); +extern s32 vpp_set_nonlinear_factor( + struct disp_info_s *info, u32 f); -extern void vpp_set_osd_layer_position(s32 *para); +extern u32 vpp_get_nonlinear_factor( + struct disp_info_s *info); -extern s32 vpp_set_nonlinear_factor(u32 f); - -extern u32 vpp_get_nonlinear_factor(void); - -extern void vpp_set_video_speed_check(u32 h, u32 w); - -extern void vpp_get_video_speed_check(u32 *h, u32 *w); +extern void vpp_disp_info_init( + struct disp_info_s *info, u8 id); extern void vpp_super_scaler_support(void); extern void vpp_bypass_ratio_config(void); -#ifdef CONFIG_AM_VIDEO2 -extern void -vpp2_set_filters(u32 wide_mode, struct vframe_s *vf, - struct vpp_frame_par_s *next_frame_par, - const struct vinfo_s *vinfo); - -extern void vpp2_set_video_layer_position(s32 x, s32 y, s32 w, s32 h); - -extern void vpp2_get_video_layer_position(s32 *x, s32 *y, s32 *w, s32 *h); - -extern void vpp2_set_zoom_ratio(u32 r); - -extern u32 vpp2_get_zoom_ratio(void); -#endif -extern int video_property_notify(int flag); - -extern int vpp_set_super_scaler_regs(int scaler_path_sel, - int reg_srscl0_enable, - int reg_srscl0_hsize, - int reg_srscl0_vsize, - int reg_srscl0_hori_ratio, - int reg_srscl0_vert_ratio, - int reg_srscl1_enable, - int reg_srscl1_hsize, - int reg_srscl1_vsize, - int reg_srscl1_hori_ratio, - int reg_srscl1_vert_ratio, - int vpp_postblend_out_width, - int vpp_postblend_out_height); +extern int vpp_set_super_scaler_regs( + int scaler_path_sel, + int reg_srscl0_enable, + int reg_srscl0_hsize, + int reg_srscl0_vsize, + int reg_srscl0_hori_ratio, + int reg_srscl0_vert_ratio, + int reg_srscl1_enable, + int reg_srscl1_hsize, + int reg_srscl1_vsize, + int reg_srscl1_hori_ratio, + int reg_srscl1_vert_ratio, + int vpp_postblend_out_width, + int vpp_postblend_out_height); #endif /* VPP_H */ -- 2.7.4