diff options
-rw-r--r-- | linux/drivers/media/common/saa7146_fops.c | 14 | ||||
-rw-r--r-- | linux/drivers/media/common/saa7146_video.c | 60 |
2 files changed, 40 insertions, 34 deletions
diff --git a/linux/drivers/media/common/saa7146_fops.c b/linux/drivers/media/common/saa7146_fops.c index d22311d28..fc5f4157d 100644 --- a/linux/drivers/media/common/saa7146_fops.c +++ b/linux/drivers/media/common/saa7146_fops.c @@ -10,14 +10,14 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit) struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; - if (fh->resources & bit) + if (fh->resources & bit) { + DEB_D(("already allocated! want: 0x%02x, cur:0x%02x\n",bit,vv->resources)); /* have it already allocated */ return 1; - + } + /* is it free? */ - DEB_D(("getting lock...\n")); down(&dev->lock); - DEB_D(("got lock\n")); if (vv->resources & bit) { DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit)); /* no, someone else uses it */ @@ -27,7 +27,7 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit) /* it's free, grab it */ fh->resources |= bit; vv->resources |= bit; - DEB_D(("res: get %d\n",bit)); + DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources)); up(&dev->lock); return 1; } @@ -51,12 +51,10 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits) if ((fh->resources & bits) != bits) BUG(); - DEB_D(("getting lock...\n")); down(&dev->lock); - DEB_D(("got lock\n")); fh->resources &= ~bits; vv->resources &= ~bits; - DEB_D(("res: put %d\n",bits)); + DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources)); up(&dev->lock); } diff --git a/linux/drivers/media/common/saa7146_video.c b/linux/drivers/media/common/saa7146_video.c index 2b5544ef6..875bfe535 100644 --- a/linux/drivers/media/common/saa7146_video.c +++ b/linux/drivers/media/common/saa7146_video.c @@ -311,7 +311,7 @@ int saa7146_stop_preview(struct saa7146_fh *fh) if( fh != vv->ov_data->fh ) { DEB_D(("overlay is active, but for another open.\n")); - return 0; + return 1; } vv->ov_data = NULL; @@ -697,11 +697,17 @@ static int video_begin(struct saa7146_fh *fh) DEB_S(("already capturing.\n")); return -EBUSY; } + if( vv->streaming != 0 ) { DEB_S(("already capturing, but in another open.\n")); return -EBUSY; } + if( 0 != vv->ov_data ) { + DEB_S(("overlay is active. disable it first.\n")); + return -EBUSY; + } + fmt = format_by_fourcc(dev,fh->video_fmt.pixelformat); /* we need to have a valid format set here */ BUG_ON(NULL == fmt); @@ -1084,45 +1090,42 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int int on = *(int *)arg; int err = 0; + DEB_D(("VIDIOC_OVERLAY on:%d\n",on)); + if( NULL == vv->ov_fmt && on != 0 ) { DEB_D(("VIDIOC_OVERLAY: no framebuffer informations. call S_FBUF first!\n")); return -EAGAIN; } - DEB_D(("VIDIOC_OVERLAY on:%d\n",on)); - if( 0 != on ) { - if( vv->ov_data != NULL ) { - if( fh != vv->ov_data->fh) { - DEB_D(("overlay already active in another open\n")); - return -EAGAIN; - } + if( vv->ov_data != NULL ) { + if( fh != vv->ov_data->fh) { + DEB_D(("overlay already active in another open\n")); + return -EAGAIN; } - - if (0 == saa7146_res_get(fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP)) { - DEB_D(("cannot get overlay resources\n")); - return -EBUSY; + if (on != 0) { + DEB_D(("overlay is already active.\n")); + return 0; } - spin_lock_irqsave(&dev->slock,flags); - err = saa7146_start_preview(fh); + err = saa7146_stop_preview(fh); spin_unlock_irqrestore(&dev->slock,flags); + /* free resources */ + saa7146_res_free(fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP); return err; } - - if( vv->ov_data != NULL ) { - if( fh != vv->ov_data->fh) { - DEB_D(("overlay is active, but in another open\n")); - return -EAGAIN; - } - } else { - DEB_D(("overlay is not active\n")); - return 0; + if (on == 0) { + DEB_D(("overlay not running. doing nothing.\n")); + return 0; } + + if (0 == saa7146_res_get(fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP)) { + DEB_D(("cannot get overlay resources\n")); + return -EBUSY; + } + spin_lock_irqsave(&dev->slock,flags); - err = saa7146_stop_preview(fh); + err = saa7146_start_preview(fh); spin_unlock_irqrestore(&dev->slock,flags); - /* free resources */ - saa7146_res_free(fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP); return err; } case VIDIOC_REQBUFS: { @@ -1170,6 +1173,11 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int DEB_D(("VIDIOC_STREAMOFF, type:%d\n",*type)); + if (NULL == vv->streaming ) { + DEB_D(("not capturing\n")); + return 0; + } + if( fh != vv->streaming ) { DEB_D(("this open is not capturing.\n")); return -EINVAL; |