aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-05-31 07:30:49 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-17 09:08:53 -0400
commit813b9dffa0cfefdd71b262e1ec4ad5f7d1fb8f89 (patch)
tree718f9a5dbff62635dd5bbf569be9e31cd7923c58 /drivers/media
parentb12262f9472d714341d9d83f47cccd76c977aa0e (diff)
[media] saa7134: move fmt/width/height from saa7134_fh to saa7134_dev
These fields are global, not per-filehandle. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c57
-rw-r--r--drivers/media/pci/saa7134/saa7134.h4
2 files changed, 32 insertions, 29 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 331eded72ebc..30832d38fb54 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1024,38 +1024,38 @@ static int buffer_prepare(struct videobuf_queue *q,
1024 int err; 1024 int err;
1025 1025
1026 /* sanity checks */ 1026 /* sanity checks */
1027 if (NULL == fh->fmt) 1027 if (NULL == dev->fmt)
1028 return -EINVAL; 1028 return -EINVAL;
1029 if (fh->width < 48 || 1029 if (dev->width < 48 ||
1030 fh->height < 32 || 1030 dev->height < 32 ||
1031 fh->width/4 > dev->crop_current.width || 1031 dev->width/4 > dev->crop_current.width ||
1032 fh->height/4 > dev->crop_current.height || 1032 dev->height/4 > dev->crop_current.height ||
1033 fh->width > dev->crop_bounds.width || 1033 dev->width > dev->crop_bounds.width ||
1034 fh->height > dev->crop_bounds.height) 1034 dev->height > dev->crop_bounds.height)
1035 return -EINVAL; 1035 return -EINVAL;
1036 size = (fh->width * fh->height * fh->fmt->depth) >> 3; 1036 size = (dev->width * dev->height * dev->fmt->depth) >> 3;
1037 if (0 != buf->vb.baddr && buf->vb.bsize < size) 1037 if (0 != buf->vb.baddr && buf->vb.bsize < size)
1038 return -EINVAL; 1038 return -EINVAL;
1039 1039
1040 dprintk("buffer_prepare [%d,size=%dx%d,bytes=%d,fields=%s,%s]\n", 1040 dprintk("buffer_prepare [%d,size=%dx%d,bytes=%d,fields=%s,%s]\n",
1041 vb->i,fh->width,fh->height,size,v4l2_field_names[field], 1041 vb->i, dev->width, dev->height, size, v4l2_field_names[field],
1042 fh->fmt->name); 1042 dev->fmt->name);
1043 if (buf->vb.width != fh->width || 1043 if (buf->vb.width != dev->width ||
1044 buf->vb.height != fh->height || 1044 buf->vb.height != dev->height ||
1045 buf->vb.size != size || 1045 buf->vb.size != size ||
1046 buf->vb.field != field || 1046 buf->vb.field != field ||
1047 buf->fmt != fh->fmt) { 1047 buf->fmt != dev->fmt) {
1048 saa7134_dma_free(q,buf); 1048 saa7134_dma_free(q,buf);
1049 } 1049 }
1050 1050
1051 if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { 1051 if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
1052 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); 1052 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
1053 1053
1054 buf->vb.width = fh->width; 1054 buf->vb.width = dev->width;
1055 buf->vb.height = fh->height; 1055 buf->vb.height = dev->height;
1056 buf->vb.size = size; 1056 buf->vb.size = size;
1057 buf->vb.field = field; 1057 buf->vb.field = field;
1058 buf->fmt = fh->fmt; 1058 buf->fmt = dev->fmt;
1059 buf->pt = &fh->pt_cap; 1059 buf->pt = &fh->pt_cap;
1060 dev->video_q.curr = NULL; 1060 dev->video_q.curr = NULL;
1061 1061
@@ -1082,8 +1082,9 @@ static int
1082buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) 1082buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
1083{ 1083{
1084 struct saa7134_fh *fh = q->priv_data; 1084 struct saa7134_fh *fh = q->priv_data;
1085 struct saa7134_dev *dev = fh->dev;
1085 1086
1086 *size = fh->fmt->depth * fh->width * fh->height >> 3; 1087 *size = dev->fmt->depth * dev->width * dev->height >> 3;
1087 if (0 == *count) 1088 if (0 == *count)
1088 *count = gbuffers; 1089 *count = gbuffers;
1089 *count = saa7134_buffer_count(*size,*count); 1090 *count = saa7134_buffer_count(*size,*count);
@@ -1334,9 +1335,6 @@ static int video_open(struct file *file)
1334 v4l2_fh_init(&fh->fh, vdev); 1335 v4l2_fh_init(&fh->fh, vdev);
1335 file->private_data = fh; 1336 file->private_data = fh;
1336 fh->dev = dev; 1337 fh->dev = dev;
1337 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
1338 fh->width = 720;
1339 fh->height = 576;
1340 1338
1341 videobuf_queue_sg_init(&fh->cap, &video_qops, 1339 videobuf_queue_sg_init(&fh->cap, &video_qops,
1342 &dev->pci->dev, &dev->slock, 1340 &dev->pci->dev, &dev->slock,
@@ -1556,13 +1554,14 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv,
1556 struct v4l2_format *f) 1554 struct v4l2_format *f)
1557{ 1555{
1558 struct saa7134_fh *fh = priv; 1556 struct saa7134_fh *fh = priv;
1557 struct saa7134_dev *dev = fh->dev;
1559 1558
1560 f->fmt.pix.width = fh->width; 1559 f->fmt.pix.width = dev->width;
1561 f->fmt.pix.height = fh->height; 1560 f->fmt.pix.height = dev->height;
1562 f->fmt.pix.field = fh->cap.field; 1561 f->fmt.pix.field = fh->cap.field;
1563 f->fmt.pix.pixelformat = fh->fmt->fourcc; 1562 f->fmt.pix.pixelformat = dev->fmt->fourcc;
1564 f->fmt.pix.bytesperline = 1563 f->fmt.pix.bytesperline =
1565 (f->fmt.pix.width * fh->fmt->depth) >> 3; 1564 (f->fmt.pix.width * dev->fmt->depth) >> 3;
1566 f->fmt.pix.sizeimage = 1565 f->fmt.pix.sizeimage =
1567 f->fmt.pix.height * f->fmt.pix.bytesperline; 1566 f->fmt.pix.height * f->fmt.pix.bytesperline;
1568 return 0; 1567 return 0;
@@ -1652,15 +1651,16 @@ static int saa7134_s_fmt_vid_cap(struct file *file, void *priv,
1652 struct v4l2_format *f) 1651 struct v4l2_format *f)
1653{ 1652{
1654 struct saa7134_fh *fh = priv; 1653 struct saa7134_fh *fh = priv;
1654 struct saa7134_dev *dev = fh->dev;
1655 int err; 1655 int err;
1656 1656
1657 err = saa7134_try_fmt_vid_cap(file, priv, f); 1657 err = saa7134_try_fmt_vid_cap(file, priv, f);
1658 if (0 != err) 1658 if (0 != err)
1659 return err; 1659 return err;
1660 1660
1661 fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); 1661 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
1662 fh->width = f->fmt.pix.width; 1662 dev->width = f->fmt.pix.width;
1663 fh->height = f->fmt.pix.height; 1663 dev->height = f->fmt.pix.height;
1664 fh->cap.field = f->fmt.pix.field; 1664 fh->cap.field = f->fmt.pix.field;
1665 return 0; 1665 return 0;
1666} 1666}
@@ -2451,6 +2451,9 @@ int saa7134_video_init1(struct saa7134_dev *dev)
2451 dev->video_q.timeout.function = saa7134_buffer_timeout; 2451 dev->video_q.timeout.function = saa7134_buffer_timeout;
2452 dev->video_q.timeout.data = (unsigned long)(&dev->video_q); 2452 dev->video_q.timeout.data = (unsigned long)(&dev->video_q);
2453 dev->video_q.dev = dev; 2453 dev->video_q.dev = dev;
2454 dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
2455 dev->width = 720;
2456 dev->height = 576;
2454 2457
2455 if (saa7134_boards[dev->board].video_out) 2458 if (saa7134_boards[dev->board].video_out)
2456 saa7134_videoport_init(dev); 2459 saa7134_videoport_init(dev);
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index fa21d14ea16e..8a62ff733343 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -475,8 +475,6 @@ struct saa7134_fh {
475 struct pm_qos_request qos_request; 475 struct pm_qos_request qos_request;
476 476
477 /* video capture */ 477 /* video capture */
478 struct saa7134_format *fmt;
479 unsigned int width,height;
480 struct videobuf_queue cap; 478 struct videobuf_queue cap;
481 struct saa7134_pgtable pt_cap; 479 struct saa7134_pgtable pt_cap;
482 480
@@ -595,6 +593,8 @@ struct saa7134_dev {
595 struct saa7134_dmaqueue vbi_q; 593 struct saa7134_dmaqueue vbi_q;
596 unsigned int video_fieldcount; 594 unsigned int video_fieldcount;
597 unsigned int vbi_fieldcount; 595 unsigned int vbi_fieldcount;
596 struct saa7134_format *fmt;
597 unsigned int width, height;
598 598
599 /* various v4l controls */ 599 /* various v4l controls */
600 struct saa7134_tvnorm *tvnorm; /* video */ 600 struct saa7134_tvnorm *tvnorm; /* video */