summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorMichael Hunold <devnull@localhost>2004-01-04 17:40:39 +0000
committerMichael Hunold <devnull@localhost>2004-01-04 17:40:39 +0000
commiteaef046bcb06617776887ce5876c3bc4ffb60f2d (patch)
tree0b6511ceac89d1c195fdcd061e8cb1684e6caf66 /linux/drivers
parenta1b4d25468ad76345f2453e243133e453eed9e5c (diff)
downloadmediapointer-dvb-s2-eaef046bcb06617776887ce5876c3bc4ffb60f2d.tar.gz
mediapointer-dvb-s2-eaef046bcb06617776887ce5876c3bc4ffb60f2d.tar.bz2
- some small indentation fixes in saa7146_hlp.c
- deny usage of planar formats for video overlay - more intelligent checks in VIDIOC_STREAMON and VIDIOC_STREAMOFF - fix read() capture while overlay is running
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/common/saa7146_hlp.c13
-rw-r--r--linux/drivers/media/common/saa7146_video.c40
2 files changed, 39 insertions, 14 deletions
diff --git a/linux/drivers/media/common/saa7146_hlp.c b/linux/drivers/media/common/saa7146_hlp.c
index 16375072b..044d37a76 100644
--- a/linux/drivers/media/common/saa7146_hlp.c
+++ b/linux/drivers/media/common/saa7146_hlp.c
@@ -152,8 +152,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev,
if( 1 == xpsc ) {
xacm = 1;
dcgx = 0;
- }
- else {
+ } else {
xacm = 0;
/* get best match in the table of attenuations
for horizontal scaling */
@@ -268,8 +267,7 @@ static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field
ype = ysci / 16;
ypo = ype + (ysci / 64);
- }
- else {
+ } else {
yacm = 1;
/* calculate scaling increment */
@@ -285,8 +283,7 @@ static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field
... */
if ( ysci < 512) {
yacl = 0;
- }
- else {
+ } else {
yacl = ( ysci / (1024 - ysci) );
}
@@ -628,7 +625,7 @@ static void saa7146_set_output_format(struct saa7146_dev *dev, unsigned long pal
void saa7146_set_picture_prop(struct saa7146_dev *dev, int brightness, int contrast, int colour)
{
- u32 bcs_ctrl = 0;
+ u32 bcs_ctrl = 0;
calculate_bcs_ctrl_register(dev, brightness, contrast, colour, &bcs_ctrl);
saa7146_write(dev, BCS_CTRL, bcs_ctrl);
@@ -711,6 +708,7 @@ void saa7146_write_out_dma(struct saa7146_dev* dev, int which, struct saa7146_vi
printk("vdma%d.num_line_byte: 0x%08x\n", which,vdma->num_line_byte);
*/
}
+
static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa7146_buf *buf)
{
struct saa7146_vv *vv = dev->vv_data;
@@ -792,7 +790,6 @@ static int calc_planar_422(struct saa7146_vv *vv, struct saa7146_buf *buf, struc
vdma3->prot_addr = buf->pt[2].offset;
vdma3->base_even = ((vdma3->pitch/2)*height)+buf->pt[2].offset;
vdma3->base_odd = vdma3->base_even - (vdma3->pitch/2);
-
} else {
vdma3->base_even = buf->pt[2].offset;
vdma3->base_odd = vdma3->base_even + (vdma3->pitch/2);
diff --git a/linux/drivers/media/common/saa7146_video.c b/linux/drivers/media/common/saa7146_video.c
index 5a404407c..537f771ba 100644
--- a/linux/drivers/media/common/saa7146_video.c
+++ b/linux/drivers/media/common/saa7146_video.c
@@ -695,7 +695,7 @@ static int video_begin(struct saa7146_fh *fh)
if( fh == vv->streaming ) {
DEB_S(("already capturing.\n"));
- return 0;
+ return -EBUSY;
}
if( vv->streaming != 0 ) {
DEB_S(("already capturing, but in another open.\n"));
@@ -870,7 +870,6 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
int restart_overlay = 0;
DEB_EE(("VIDIOC_S_FBUF\n"));
-
/*
if(!capable(CAP_SYS_ADMIN)) { // && !capable(CAP_SYS_RAWIO)) {
DEB_D(("VIDIOC_S_FBUF: not CAP_SYS_ADMIN or CAP_SYS_RAWIO.\n"));
@@ -883,9 +882,13 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
if (NULL == fmt) {
return -EINVAL;
}
-
+
+ /* planar formats are not allowed for overlay video, clipping and video dma would clash */
+ if (0 != (fmt->flags & FORMAT_IS_PLANAR)) {
+ DEB_S(("planar pixelformat '%4.4s' not allowed for overlay\n",(char *)&fmt->pixelformat));
+ }
+
down(&dev->lock);
-
if( vv->ov_data != NULL ) {
ov_fh = vv->ov_data->fh;
saa7146_stop_preview(ov_fh);
@@ -1141,6 +1144,11 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
int *type = arg;
DEB_D(("VIDIOC_STREAMON, type:%d\n",*type));
+ if( fh == vv->streaming ) {
+ DEB_D(("already capturing.\n"));
+ return 0;
+ }
+
err = video_begin(fh);
if( 0 != err) {
return err;
@@ -1152,6 +1160,12 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
int *type = arg;
DEB_D(("VIDIOC_STREAMOFF, type:%d\n",*type));
+
+ if( fh != vv->streaming ) {
+ DEB_D(("this open is not capturing.\n"));
+ return -EINVAL;
+ }
+
err = videobuf_streamoff(file,q);
video_end(fh, file);
return err;
@@ -1378,6 +1392,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
sizeof(struct saa7146_buf));
init_MUTEX(&fh->video_q.lock);
+
return 0;
}
@@ -1431,25 +1446,38 @@ static ssize_t video_read(struct file *file, char *data, size_t count, loff_t *p
DEB_EE(("called.\n"));
+ /* fixme: should we allow read() captures while streaming capture? */
+ if( 0 != vv->streaming ) {
+ DEB_S(("already capturing.\n"));
+ return -EBUSY;
+ }
+
+ /* stop any active overlay */
if( vv->ov_data != NULL ) {
ov_fh = vv->ov_data->fh;
saa7146_stop_preview(ov_fh);
+ saa7146_res_free(ov_fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP);
restart_overlay = 1;
}
ret = video_begin(fh);
if( 0 != ret) {
- return ret;
+ goto out;
}
ret = videobuf_read_one(file,&fh->video_q , data, count, ppos);
video_end(fh, file);
+out:
/* restart overlay if it was active before */
if( 0 != restart_overlay ) {
+ if (0 == saa7146_res_get(ov_fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP)) {
+ DEB_D(("cannot get overlay resources again!\n"));
+ BUG();
+ }
saa7146_start_preview(ov_fh);
}
-
+
return ret;
}