aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-06 13:31:59 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:41 -0400
commita4a787187bcf94b1bf4deb74cbe30eb442519875 (patch)
tree833bb178c23fc385726f701fb6ac8f5d4d6d7a16
parentfdf9c9979a355916433262ea5e5e64bed5def86e (diff)
V4L/DVB (10486): ivtv/cx18: fix g_fmt and try_fmt for raw video
The raw video device didn't report the image size correctly. When setting a new image the image height has to be a multiple of 32 lines. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c17
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c14
2 files changed, 20 insertions, 11 deletions
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index 0f0cd560226..5c8e9cb244f 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -160,10 +160,8 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
160 pixfmt->priv = 0; 160 pixfmt->priv = 0;
161 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { 161 if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
162 pixfmt->pixelformat = V4L2_PIX_FMT_HM12; 162 pixfmt->pixelformat = V4L2_PIX_FMT_HM12;
163 /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ 163 /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */
164 pixfmt->sizeimage = 164 pixfmt->sizeimage = pixfmt->height * 720 * 3 / 2;
165 pixfmt->height * pixfmt->width +
166 pixfmt->height * (pixfmt->width / 2);
167 pixfmt->bytesperline = 720; 165 pixfmt->bytesperline = 720;
168 } else { 166 } else {
169 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; 167 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG;
@@ -228,11 +226,18 @@ static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
228 struct cx18 *cx = id->cx; 226 struct cx18 *cx = id->cx;
229 int w = fmt->fmt.pix.width; 227 int w = fmt->fmt.pix.width;
230 int h = fmt->fmt.pix.height; 228 int h = fmt->fmt.pix.height;
229 int min_h = 2;
231 230
232 w = min(w, 720); 231 w = min(w, 720);
233 w = max(w, 1); 232 w = max(w, 2);
233 if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
234 /* YUV height must be a multiple of 32 */
235 h &= ~0x1f;
236 min_h = 32;
237 }
234 h = min(h, cx->is_50hz ? 576 : 480); 238 h = min(h, cx->is_50hz ? 576 : 480);
235 h = max(h, 2); 239 h = max(h, min_h);
240
236 cx18_g_fmt_vid_cap(file, fh, fmt); 241 cx18_g_fmt_vid_cap(file, fh, fmt);
237 fmt->fmt.pix.width = w; 242 fmt->fmt.pix.width = w;
238 fmt->fmt.pix.height = h; 243 fmt->fmt.pix.height = h;
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index c13bd2aa0be..e8621da26d8 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -345,10 +345,8 @@ static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
345 pixfmt->priv = 0; 345 pixfmt->priv = 0;
346 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { 346 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) {
347 pixfmt->pixelformat = V4L2_PIX_FMT_HM12; 347 pixfmt->pixelformat = V4L2_PIX_FMT_HM12;
348 /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ 348 /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */
349 pixfmt->sizeimage = 349 pixfmt->sizeimage = pixfmt->height * 720 * 3 / 2;
350 pixfmt->height * pixfmt->width +
351 pixfmt->height * (pixfmt->width / 2);
352 pixfmt->bytesperline = 720; 350 pixfmt->bytesperline = 720;
353 } else { 351 } else {
354 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; 352 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG;
@@ -469,11 +467,17 @@ static int ivtv_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format
469 struct ivtv *itv = id->itv; 467 struct ivtv *itv = id->itv;
470 int w = fmt->fmt.pix.width; 468 int w = fmt->fmt.pix.width;
471 int h = fmt->fmt.pix.height; 469 int h = fmt->fmt.pix.height;
470 int min_h = 2;
472 471
473 w = min(w, 720); 472 w = min(w, 720);
474 w = max(w, 2); 473 w = max(w, 2);
474 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) {
475 /* YUV height must be a multiple of 32 */
476 h &= ~0x1f;
477 min_h = 32;
478 }
475 h = min(h, itv->is_50hz ? 576 : 480); 479 h = min(h, itv->is_50hz ? 576 : 480);
476 h = max(h, 2); 480 h = max(h, min_h);
477 ivtv_g_fmt_vid_cap(file, fh, fmt); 481 ivtv_g_fmt_vid_cap(file, fh, fmt);
478 fmt->fmt.pix.width = w; 482 fmt->fmt.pix.width = w;
479 fmt->fmt.pix.height = h; 483 fmt->fmt.pix.height = h;