Commit 6cb794b964ea4a8f00116c800a7075c3b67fff6b

Authored by Robby Cai
1 parent f1ae217b23

MLK-10057 PxP V4L2 output: force to call pxp_streamoff when device closes

By previous implementation, there's the possibility that last picture remains
on screen when the program exits. This can be reproduced by not calling
STREAMOFF ioctl in v4l2 output application or just trying to kill the v4l2
output program. The driver has faults to handle this case, since it depends on
'pxp->s0_vbq.streaming' variable be true in close() function to call
pxp_streamoff() while the variable is set to 0 after the application calls
munmap().  The driver should call pxp_streamoff() even if the application
does not call STREAMOFF ioctl.

This patch uses the local 'streaming' variable to track the streaming
status to fix this problem.

Signed-off-by: Robby Cai <r63905@freescale.com>

Showing 2 changed files with 9 additions and 3 deletions Side-by-side Diff

drivers/media/platform/mxc/output/mxc_pxp_v4l2.c
... ... @@ -690,11 +690,13 @@
690 690 if (t != V4L2_BUF_TYPE_VIDEO_OUTPUT)
691 691 return -EINVAL;
692 692  
693   - if (pxp->s0_vbq.streaming) {
  693 + if (pxp->streaming) {
694 694 dev_err(&pxp->pdev->dev, "v4l2 output already run!");
695 695 return -EBUSY;
696 696 }
697 697  
  698 + pxp->streaming = true;
  699 +
698 700 _get_cur_fb_blank(pxp);
699 701 set_fb_blank(FB_BLANK_UNBLANK);
700 702  
701 703  
... ... @@ -715,13 +717,15 @@
715 717 if ((t != V4L2_BUF_TYPE_VIDEO_OUTPUT))
716 718 return -EINVAL;
717 719  
718   - if (pxp->s0_vbq.streaming) {
  720 + if (pxp->streaming) {
719 721 ret = videobuf_streamoff(&pxp->s0_vbq);
720 722  
721 723 pxp_show_buf(pxp, (unsigned long)pxp->fb.base);
722 724  
723 725 if (pxp->fb_blank)
724 726 set_fb_blank(FB_BLANK_POWERDOWN);
  727 +
  728 + pxp->streaming = false;
725 729 }
726 730  
727 731 return ret;
728 732  
... ... @@ -1151,8 +1155,9 @@
1151 1155 static int pxp_close(struct file *file)
1152 1156 {
1153 1157 struct pxps *pxp = video_get_drvdata(video_devdata(file));
1154   - if (pxp->s0_vbq.streaming)
  1158 + if (pxp->streaming)
1155 1159 pxp_streamoff(file, NULL, V4L2_BUF_TYPE_VIDEO_OUTPUT);
  1160 +
1156 1161 videobuf_stop(&pxp->s0_vbq);
1157 1162 videobuf_mmap_free(&pxp->s0_vbq);
1158 1163 pxp->active = NULL;
drivers/media/platform/mxc/output/mxc_pxp_v4l2.h
... ... @@ -53,6 +53,7 @@
53 53 struct video_device *vdev;
54 54  
55 55 struct videobuf_queue s0_vbq;
  56 + bool streaming;
56 57 struct pxp_buffer *active;
57 58 struct list_head outq;
58 59 struct pxp_channel *pxp_channel[1]; /* We need 1 channel */