Skip to content

Commit

Permalink
vpp: add black_threshold to disable video when window is too small [1/1]
Browse files Browse the repository at this point in the history
PD#TV-3641

Problem:
Add new interface to disable video when window is too small

Solution:
Add the black_threshold interface to control the threshold size.
And set the default value is width=20, height=30.

Verify:
verified by x301

Change-Id: Ifeb376c2e2edbb5706b2cdc2d08421bd0086b01e
Signed-off-by: Brian Zhu <brian.zhu@amlogic.com>
  • Loading branch information
Brian Zhu authored and kongsuozt committed Mar 28, 2019
1 parent c715f0d commit 4e6774d
Showing 1 changed file with 62 additions and 2 deletions.
64 changes: 62 additions & 2 deletions drivers/amlogic/media/video_sink/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ static struct vframe_pic_mode_s gPic_info[MAX_VD_LAYERS];

static u32 reference_zorder = 128;

/* default value 20 30 */
static s32 black_threshold_width = 20;
static s32 black_threshold_height = 30;

#define MAX_ZOOM_RATIO 300

#define VPP_PREBLEND_VD_V_END_LIMIT 2304
Expand Down Expand Up @@ -6076,6 +6080,32 @@ static int vpp_zorder_check(void)
return force_flush;
}

static bool black_threshold_check(u8 id)
{
struct disp_info_s *layer = NULL;
bool ret = false;

if (id >= MAX_VD_LAYERS)
return ret;

if ((black_threshold_width <= 0)
|| (black_threshold_height <= 0))
return ret;

layer = &glayer_info[id];
if ((layer->layer_top == 0)
&& (layer->layer_left == 0)
&& (layer->layer_width <= 1)
&& (layer->layer_height <= 1))
/* special case to do full screen display */
return ret;

if ((layer->layer_width <= black_threshold_width)
|| (layer->layer_height <= black_threshold_height))
ret = true;
return ret;
}

#ifdef TV_3D_FUNCTION_OPEN
inline void switch_3dView_per_vsync(void)
{
Expand Down Expand Up @@ -7746,7 +7776,8 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
spin_unlock_irqrestore(&video2_onoff_lock, flags);
}

if (video_global_output == 0) {
if ((video_global_output == 0)
|| black_threshold_check(0)) {
video_enabled = 0;
vpp_misc_set &= ~(VPP_VD1_PREBLEND |
VPP_VD2_PREBLEND |
Expand All @@ -7769,7 +7800,8 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
VPP_PREBLEND_EN);

#ifdef VIDEO_PIP
if (pip_global_output == 0) {
if ((pip_global_output == 0)
|| black_threshold_check(1)) {
video2_enabled = 0;
vpp_misc_set &= ~(VPP_VD2_PREBLEND |
VPP_VD2_POSTBLEND);
Expand Down Expand Up @@ -11499,6 +11531,30 @@ static ssize_t video_zorder_store(
return count;
}

static ssize_t black_threshold_show(
struct class *cla,
struct class_attribute *attr,
char *buf)
{
return sprintf(buf, "width: %d, height: %d\n",
black_threshold_width,
black_threshold_height);
}

static ssize_t black_threshold_store(
struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
int parsed[2];

if (likely(parse_para(buf, 2, parsed) == 2)) {
black_threshold_width = parsed[0];
black_threshold_height = parsed[1];
}
return strnlen(buf, count);
}

#ifdef VIDEO_PIP
int _videopip_set_disable(u32 val)
{
Expand Down Expand Up @@ -12021,6 +12077,10 @@ static struct class_attribute amvideo_class_attrs[] = {
0664,
video_zorder_show,
video_zorder_store),
__ATTR(black_threshold,
0664,
black_threshold_show,
black_threshold_store),
__ATTR_RO(frame_addr),
__ATTR_RO(frame_canvas_width),
__ATTR_RO(frame_canvas_height),
Expand Down

0 comments on commit 4e6774d

Please sign in to comment.