diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-05-01 10:17:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-14 13:58:16 -0400 |
commit | fd74d6eb4c2c1caa18208df32d9d38b5fe9738fc (patch) | |
tree | a76ebd2dfd1e4582e3cd2b2102bfa12070ade349 /drivers/media/common | |
parent | 5da545ad08a3c6ea71d3ba074adc7582e7e9a024 (diff) |
[media] saa7146: move video_fmt from saa7146_fh to saa7146_vv
This is a global structure and does not belong to saa7146_fh.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common')
-rw-r--r-- | drivers/media/common/saa7146_fops.c | 10 | ||||
-rw-r--r-- | drivers/media/common/saa7146_video.c | 62 |
2 files changed, 38 insertions, 34 deletions
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index 68047c93fd9d..b8d0d7df5d67 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c | |||
@@ -504,6 +504,16 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) | |||
504 | fmt->bytesperline = 2 * fmt->width; | 504 | fmt->bytesperline = 2 * fmt->width; |
505 | fmt->sizeimage = fmt->bytesperline * fmt->height; | 505 | fmt->sizeimage = fmt->bytesperline * fmt->height; |
506 | fmt->colorspace = V4L2_COLORSPACE_SRGB; | 506 | fmt->colorspace = V4L2_COLORSPACE_SRGB; |
507 | |||
508 | fmt = &vv->video_fmt; | ||
509 | fmt->width = 384; | ||
510 | fmt->height = 288; | ||
511 | fmt->pixelformat = V4L2_PIX_FMT_BGR24; | ||
512 | fmt->field = V4L2_FIELD_ANY; | ||
513 | fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
514 | fmt->bytesperline = 3 * fmt->width; | ||
515 | fmt->sizeimage = fmt->bytesperline * fmt->height; | ||
516 | |||
507 | vv->ov_fb.capability = V4L2_FBUF_CAP_LIST_CLIPPING; | 517 | vv->ov_fb.capability = V4L2_FBUF_CAP_LIST_CLIPPING; |
508 | vv->ov_fb.flags = V4L2_FBUF_FLAG_PRIMARY; | 518 | vv->ov_fb.flags = V4L2_FBUF_FLAG_PRIMARY; |
509 | dev->vv_data = vv; | 519 | dev->vv_data = vv; |
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index e1b639b76e38..f57dccf851c1 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c | |||
@@ -353,7 +353,7 @@ static int video_begin(struct saa7146_fh *fh) | |||
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | fmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat); | 356 | fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); |
357 | /* we need to have a valid format set here */ | 357 | /* we need to have a valid format set here */ |
358 | BUG_ON(NULL == fmt); | 358 | BUG_ON(NULL == fmt); |
359 | 359 | ||
@@ -405,7 +405,7 @@ static int video_end(struct saa7146_fh *fh, struct file *file) | |||
405 | return -EBUSY; | 405 | return -EBUSY; |
406 | } | 406 | } |
407 | 407 | ||
408 | fmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat); | 408 | fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); |
409 | /* we need to have a valid format set here */ | 409 | /* we need to have a valid format set here */ |
410 | BUG_ON(NULL == fmt); | 410 | BUG_ON(NULL == fmt); |
411 | 411 | ||
@@ -595,7 +595,10 @@ static int vidioc_g_parm(struct file *file, void *fh, | |||
595 | 595 | ||
596 | static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) | 596 | static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) |
597 | { | 597 | { |
598 | f->fmt.pix = ((struct saa7146_fh *)fh)->video_fmt; | 598 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; |
599 | struct saa7146_vv *vv = dev->vv_data; | ||
600 | |||
601 | f->fmt.pix = vv->video_fmt; | ||
599 | return 0; | 602 | return 0; |
600 | } | 603 | } |
601 | 604 | ||
@@ -754,9 +757,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *__fh, struct v4l2_forma | |||
754 | err = vidioc_try_fmt_vid_cap(file, fh, f); | 757 | err = vidioc_try_fmt_vid_cap(file, fh, f); |
755 | if (0 != err) | 758 | if (0 != err) |
756 | return err; | 759 | return err; |
757 | fh->video_fmt = f->fmt.pix; | 760 | vv->video_fmt = f->fmt.pix; |
758 | DEB_EE("set to pixelformat '%4.4s'\n", | 761 | DEB_EE("set to pixelformat '%4.4s'\n", |
759 | (char *)&fh->video_fmt.pixelformat); | 762 | (char *)&vv->video_fmt.pixelformat); |
760 | return 0; | 763 | return 0; |
761 | } | 764 | } |
762 | 765 | ||
@@ -1053,44 +1056,44 @@ static int buffer_prepare(struct videobuf_queue *q, | |||
1053 | DEB_CAP("vbuf:%p\n", vb); | 1056 | DEB_CAP("vbuf:%p\n", vb); |
1054 | 1057 | ||
1055 | /* sanity checks */ | 1058 | /* sanity checks */ |
1056 | if (fh->video_fmt.width < 48 || | 1059 | if (vv->video_fmt.width < 48 || |
1057 | fh->video_fmt.height < 32 || | 1060 | vv->video_fmt.height < 32 || |
1058 | fh->video_fmt.width > vv->standard->h_max_out || | 1061 | vv->video_fmt.width > vv->standard->h_max_out || |
1059 | fh->video_fmt.height > vv->standard->v_max_out) { | 1062 | vv->video_fmt.height > vv->standard->v_max_out) { |
1060 | DEB_D("w (%d) / h (%d) out of bounds\n", | 1063 | DEB_D("w (%d) / h (%d) out of bounds\n", |
1061 | fh->video_fmt.width, fh->video_fmt.height); | 1064 | vv->video_fmt.width, vv->video_fmt.height); |
1062 | return -EINVAL; | 1065 | return -EINVAL; |
1063 | } | 1066 | } |
1064 | 1067 | ||
1065 | size = fh->video_fmt.sizeimage; | 1068 | size = vv->video_fmt.sizeimage; |
1066 | if (0 != buf->vb.baddr && buf->vb.bsize < size) { | 1069 | if (0 != buf->vb.baddr && buf->vb.bsize < size) { |
1067 | DEB_D("size mismatch\n"); | 1070 | DEB_D("size mismatch\n"); |
1068 | return -EINVAL; | 1071 | return -EINVAL; |
1069 | } | 1072 | } |
1070 | 1073 | ||
1071 | DEB_CAP("buffer_prepare [size=%dx%d,bytes=%d,fields=%s]\n", | 1074 | DEB_CAP("buffer_prepare [size=%dx%d,bytes=%d,fields=%s]\n", |
1072 | fh->video_fmt.width, fh->video_fmt.height, | 1075 | vv->video_fmt.width, vv->video_fmt.height, |
1073 | size, v4l2_field_names[fh->video_fmt.field]); | 1076 | size, v4l2_field_names[vv->video_fmt.field]); |
1074 | if (buf->vb.width != fh->video_fmt.width || | 1077 | if (buf->vb.width != vv->video_fmt.width || |
1075 | buf->vb.bytesperline != fh->video_fmt.bytesperline || | 1078 | buf->vb.bytesperline != vv->video_fmt.bytesperline || |
1076 | buf->vb.height != fh->video_fmt.height || | 1079 | buf->vb.height != vv->video_fmt.height || |
1077 | buf->vb.size != size || | 1080 | buf->vb.size != size || |
1078 | buf->vb.field != field || | 1081 | buf->vb.field != field || |
1079 | buf->vb.field != fh->video_fmt.field || | 1082 | buf->vb.field != vv->video_fmt.field || |
1080 | buf->fmt != &fh->video_fmt) { | 1083 | buf->fmt != &vv->video_fmt) { |
1081 | saa7146_dma_free(dev,q,buf); | 1084 | saa7146_dma_free(dev,q,buf); |
1082 | } | 1085 | } |
1083 | 1086 | ||
1084 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | 1087 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { |
1085 | struct saa7146_format *sfmt; | 1088 | struct saa7146_format *sfmt; |
1086 | 1089 | ||
1087 | buf->vb.bytesperline = fh->video_fmt.bytesperline; | 1090 | buf->vb.bytesperline = vv->video_fmt.bytesperline; |
1088 | buf->vb.width = fh->video_fmt.width; | 1091 | buf->vb.width = vv->video_fmt.width; |
1089 | buf->vb.height = fh->video_fmt.height; | 1092 | buf->vb.height = vv->video_fmt.height; |
1090 | buf->vb.size = size; | 1093 | buf->vb.size = size; |
1091 | buf->vb.field = field; | 1094 | buf->vb.field = field; |
1092 | buf->fmt = &fh->video_fmt; | 1095 | buf->fmt = &vv->video_fmt; |
1093 | buf->vb.field = fh->video_fmt.field; | 1096 | buf->vb.field = vv->video_fmt.field; |
1094 | 1097 | ||
1095 | sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); | 1098 | sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); |
1096 | 1099 | ||
@@ -1126,11 +1129,12 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned | |||
1126 | { | 1129 | { |
1127 | struct file *file = q->priv_data; | 1130 | struct file *file = q->priv_data; |
1128 | struct saa7146_fh *fh = file->private_data; | 1131 | struct saa7146_fh *fh = file->private_data; |
1132 | struct saa7146_vv *vv = fh->dev->vv_data; | ||
1129 | 1133 | ||
1130 | if (0 == *count || *count > MAX_SAA7146_CAPTURE_BUFFERS) | 1134 | if (0 == *count || *count > MAX_SAA7146_CAPTURE_BUFFERS) |
1131 | *count = MAX_SAA7146_CAPTURE_BUFFERS; | 1135 | *count = MAX_SAA7146_CAPTURE_BUFFERS; |
1132 | 1136 | ||
1133 | *size = fh->video_fmt.sizeimage; | 1137 | *size = vv->video_fmt.sizeimage; |
1134 | 1138 | ||
1135 | /* check if we exceed the "max_memory" parameter */ | 1139 | /* check if we exceed the "max_memory" parameter */ |
1136 | if( (*count * *size) > (max_memory*1048576) ) { | 1140 | if( (*count * *size) > (max_memory*1048576) ) { |
@@ -1199,16 +1203,6 @@ static void video_init(struct saa7146_dev *dev, struct saa7146_vv *vv) | |||
1199 | static int video_open(struct saa7146_dev *dev, struct file *file) | 1203 | static int video_open(struct saa7146_dev *dev, struct file *file) |
1200 | { | 1204 | { |
1201 | struct saa7146_fh *fh = file->private_data; | 1205 | struct saa7146_fh *fh = file->private_data; |
1202 | struct saa7146_format *sfmt; | ||
1203 | |||
1204 | fh->video_fmt.width = 384; | ||
1205 | fh->video_fmt.height = 288; | ||
1206 | fh->video_fmt.pixelformat = V4L2_PIX_FMT_BGR24; | ||
1207 | fh->video_fmt.bytesperline = 0; | ||
1208 | fh->video_fmt.field = V4L2_FIELD_ANY; | ||
1209 | fh->video_fmt.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
1210 | sfmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat); | ||
1211 | fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8; | ||
1212 | 1206 | ||
1213 | videobuf_queue_sg_init(&fh->video_q, &video_qops, | 1207 | videobuf_queue_sg_init(&fh->video_q, &video_qops, |
1214 | &dev->pci->dev, &dev->slock, | 1208 | &dev->pci->dev, &dev->slock, |