Skip to content

Commit

Permalink
amvideo2: add keep last frame [1/1]
Browse files Browse the repository at this point in the history
PD#OTT-2452

Problem:
Black screen in the middle of the cut.

Solution:
add keep last frame.

Verify:
on U212

Change-Id: Ib24f066e0682c7427024a74d9bf8cc9b8a310d62
Signed-off-by: renjiang.han <renjiang.han@amlogic.com>
  • Loading branch information
renjiang.han authored and jianxinpan committed Mar 20, 2019
1 parent c3b0811 commit a1bf1b1
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 23 deletions.
148 changes: 127 additions & 21 deletions drivers/amlogic/media/video_sink/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ 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);
//int _videopip_set_disable(u32 val);
#endif

static struct device *amvideo_dev;
Expand Down Expand Up @@ -952,6 +952,7 @@ static u32 blackout;
static u32 blackout = 1;
#endif
static u32 force_blackout;
static u32 blackout_pip;

/* disable video */

Expand Down Expand Up @@ -983,6 +984,12 @@ u32 get_video_enabled(void)
{
return video_enabled;
}

u32 get_videopip_enabled(void)
{
return video2_enabled;
}

/* show first frame*/
static bool show_first_frame_nosync;
bool show_first_picture;
Expand Down Expand Up @@ -1154,7 +1161,12 @@ void safe_disble_videolayer(void)
#endif
}


#ifdef VIDEO_PIP
void safe_disble_videolayer2(void)
{
DisableVideoLayer2();
}
#endif
/*********************************************************/
#ifdef VIDEO_PIP
static inline struct vframe_s *pip_vf_peek(void)
Expand Down Expand Up @@ -3184,6 +3196,8 @@ static void pip_toggle_frame(struct vframe_s *vf)
cur_pipbuf = vf;
if (first_picture)
pip_frame_ready_to_set = 1;
if (cur_pipbuf != &local_pip)
video_pip_keeper_new_frame_notify();
}

static void pip_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf)
Expand Down Expand Up @@ -8455,6 +8469,7 @@ static int video_receiver_event_fun(int type, void *data, void *private_data)
static void pip_vf_unreg_provider(void)
{
ulong flags;
int keeped = 0;

/* atomic_set(&video_unreg_flag, 1); */
while (atomic_read(&video_inirq_flag) > 0)
Expand All @@ -8473,11 +8488,25 @@ static void pip_vf_unreg_provider(void)
pip_frame_count = 0;
spin_unlock_irqrestore(&lock, flags);

disable_videopip = VIDEO_DISABLE_FORNEXT;
DisableVideoLayer2();
if (blackout_pip | force_blackout) {
safe_disble_videolayer2();
try_free_keep_videopip(1);
}

if (cur_pipbuf)
keeped = vf_keep_pip_current_locked(cur_pipbuf, NULL);

if (keeped < 0) {/*keep failed.*/
pr_info("videopip keep failed, disable video now!\n");
safe_disble_videolayer2();
try_free_keep_videopip(1);
}

/*disable_videopip = VIDEO_DISABLE_FORNEXT;*/
/*DisableVideoLayer2();*/
}

static void pip_vf_light_unreg_provider(void)
static void pip_vf_light_unreg_provider(int need_keep_frame)
{
ulong flags;

Expand All @@ -8492,6 +8521,11 @@ static void pip_vf_light_unreg_provider(void)
cur_pipbuf = &local_pip;
}
spin_unlock_irqrestore(&lock, flags);
if (need_keep_frame) {
if (cur_pipbuf) {
vf_keep_pip_current_locked(cur_pipbuf, NULL);
}
}
}

static int pip_receiver_event_fun(
Expand All @@ -8500,11 +8534,11 @@ static int pip_receiver_event_fun(
if (type == VFRAME_EVENT_PROVIDER_UNREG)
pip_vf_unreg_provider();
else if (type == VFRAME_EVENT_PROVIDER_RESET)
pip_vf_light_unreg_provider();
pip_vf_light_unreg_provider(1);
else if (type == VFRAME_EVENT_PROVIDER_LIGHT_UNREG)
pip_vf_light_unreg_provider();
pip_vf_light_unreg_provider(0);
else if (type == VFRAME_EVENT_PROVIDER_REG)
pip_vf_light_unreg_provider();
pip_vf_light_unreg_provider(0);
return 0;
}
#endif
Expand All @@ -8529,6 +8563,19 @@ u32 set_blackout_policy(int policy)
}
EXPORT_SYMBOL(set_blackout_policy);

u32 get_blackout_pip_policy(void)
{
return blackout_pip | force_blackout;
}
EXPORT_SYMBOL(get_blackout_pip_policy);

u32 set_blackout_pip_policy(int policy)
{
blackout_pip = policy;
return 0;
}
EXPORT_SYMBOL(set_blackout_pip_policy);

u8 is_vpp_postblend(void)
{
if (READ_VCBUS_REG(VPP_MISC + cur_dev->vpp_off) & VPP_VD1_POSTBLEND)
Expand Down Expand Up @@ -9021,27 +9068,28 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg)
break;

case AMSTREAM_IOC_GET_VIDEOPIP_DISABLE:
put_user(disable_videopip, (u32 __user *)argp);
break;
case AMSTREAM_IOC_GET_VIDEO_DISABLE:
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
put_user(disable_video, (u32 __user *)argp);
break;

case AMSTREAM_IOC_SET_VIDEOPIP_DISABLE:
{
u32 val;

if (copy_from_user(&val, argp, sizeof(u32)) == 0)
ret = _videopip_set_disable(val);
else
ret = -EFAULT;
}
break;
case AMSTREAM_IOC_SET_VIDEO_DISABLE:
{
u32 val;

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
ret = _video_set_disable(val);
} else
ret = -EFAULT;
}
Expand Down Expand Up @@ -9168,6 +9216,24 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg)
}
break;

case AMSTREAM_IOC_GET_BLACKOUT_PIP_POLICY:
if (copy_to_user(argp, &blackout_pip, sizeof(u32)) != 0)
ret = -EFAULT;
break;

case AMSTREAM_IOC_SET_BLACKOUT_PIP_POLICY:{
u32 mode;

if (copy_from_user(&mode, argp, sizeof(u32)) == 0) {
if (mode > 2)
ret = -EINVAL;
else
blackout_pip = mode;
} else
ret = -EFAULT;
}
break;

case AMSTREAM_IOC_CLEAR_VBUF:{
unsigned long flags;
while (atomic_read(&video_inirq_flag) > 0 ||
Expand All @@ -9184,6 +9250,19 @@ static long amvideo_ioctl(struct file *file, unsigned int cmd, ulong arg)
safe_disble_videolayer();
break;

case AMSTREAM_IOC_CLEAR_PIP_VBUF:{
unsigned long flags;

spin_lock_irqsave(&lock, flags);
cur_pipbuf = NULL;
spin_unlock_irqrestore(&lock, flags);
}
break;

case AMSTREAM_IOC_CLEAR_VIDEOPIP:
safe_disble_videolayer2();
break;

case AMSTREAM_IOC_SET_FREERUN_MODE:
if (arg > FREERUN_DUR)
ret = -EFAULT;
Expand Down Expand Up @@ -9460,6 +9539,8 @@ static long amvideo_compat_ioctl(struct file *file, unsigned int cmd, ulong arg)
case AMSTREAM_IOC_SET_VIDEO_DISCONTINUE_REPORT:
case AMSTREAM_IOC_CLEAR_VBUF:
case AMSTREAM_IOC_CLEAR_VIDEO:
case AMSTREAM_IOC_CLEAR_PIP_VBUF:
case AMSTREAM_IOC_CLEAR_VIDEOPIP:
case AMSTREAM_IOC_SET_FREERUN_MODE:
case AMSTREAM_IOC_DISABLE_SLOW_SYNC:
case AMSTREAM_IOC_SET_3D_TYPE:
Expand Down Expand Up @@ -11389,7 +11470,7 @@ static ssize_t video_zorder_store(
}

#ifdef VIDEO_PIP
static int _videopip_set_disable(u32 val)
int _videopip_set_disable(u32 val)
{
if (val > VIDEO_DISABLE_FORNEXT)
return -EINVAL;
Expand All @@ -11402,6 +11483,7 @@ static int _videopip_set_disable(u32 val)
if ((disable_videopip == VIDEO_DISABLE_FORNEXT)
&& cur_pipbuf && (cur_pipbuf != &local_pip))
pip_property_changed = 1;
try_free_keep_videopip(0);
} else {
if (cur_pipbuf && (cur_pipbuf != &local_pip))
EnableVideoLayer2();
Expand All @@ -11410,6 +11492,26 @@ static int _videopip_set_disable(u32 val)
return 0;
}

static ssize_t videopip_blackout_policy_show(struct class *cla,
struct class_attribute *attr,
char *buf)
{
return sprintf(buf, "%d\n", blackout_pip);
}

static ssize_t videopip_blackout_policy_store(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
int r;

r = kstrtoint(buf, 0, &blackout_pip);
if (r < 0)
return -EINVAL;

return count;
}

static ssize_t videopip_axis_show(
struct class *cla,
struct class_attribute *attr,
Expand Down Expand Up @@ -11759,6 +11861,10 @@ static struct class_attribute amvideo_class_attrs[] = {
0664,
video_blackout_policy_show,
video_blackout_policy_store),
__ATTR(blackout_pip_policy,
0664,
videopip_blackout_policy_show,
videopip_blackout_policy_store),
__ATTR(video_seek_flag,
0664,
video_seek_flag_show,
Expand Down
Loading

0 comments on commit a1bf1b1

Please sign in to comment.