Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
a4a78718 fdf9c997

+20 -11
+11 -6
drivers/media/video/cx18/cx18-ioctl.c
··· 160 160 pixfmt->priv = 0; 161 161 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { 162 162 pixfmt->pixelformat = V4L2_PIX_FMT_HM12; 163 - /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ 164 - pixfmt->sizeimage = 165 - pixfmt->height * pixfmt->width + 166 - pixfmt->height * (pixfmt->width / 2); 163 + /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */ 164 + pixfmt->sizeimage = pixfmt->height * 720 * 3 / 2; 167 165 pixfmt->bytesperline = 720; 168 166 } else { 169 167 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; ··· 226 228 struct cx18 *cx = id->cx; 227 229 int w = fmt->fmt.pix.width; 228 230 int h = fmt->fmt.pix.height; 231 + int min_h = 2; 229 232 230 233 w = min(w, 720); 231 - w = max(w, 1); 234 + w = max(w, 2); 235 + if (id->type == CX18_ENC_STREAM_TYPE_YUV) { 236 + /* YUV height must be a multiple of 32 */ 237 + h &= ~0x1f; 238 + min_h = 32; 239 + } 232 240 h = min(h, cx->is_50hz ? 576 : 480); 233 - h = max(h, 2); 241 + h = max(h, min_h); 242 + 234 243 cx18_g_fmt_vid_cap(file, fh, fmt); 235 244 fmt->fmt.pix.width = w; 236 245 fmt->fmt.pix.height = h;
+9 -5
drivers/media/video/ivtv/ivtv-ioctl.c
··· 345 345 pixfmt->priv = 0; 346 346 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { 347 347 pixfmt->pixelformat = V4L2_PIX_FMT_HM12; 348 - /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ 349 - pixfmt->sizeimage = 350 - pixfmt->height * pixfmt->width + 351 - pixfmt->height * (pixfmt->width / 2); 348 + /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */ 349 + pixfmt->sizeimage = pixfmt->height * 720 * 3 / 2; 352 350 pixfmt->bytesperline = 720; 353 351 } else { 354 352 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; ··· 467 469 struct ivtv *itv = id->itv; 468 470 int w = fmt->fmt.pix.width; 469 471 int h = fmt->fmt.pix.height; 472 + int min_h = 2; 470 473 471 474 w = min(w, 720); 472 475 w = max(w, 2); 476 + if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { 477 + /* YUV height must be a multiple of 32 */ 478 + h &= ~0x1f; 479 + min_h = 32; 480 + } 473 481 h = min(h, itv->is_50hz ? 576 : 480); 474 - h = max(h, 2); 482 + h = max(h, min_h); 475 483 ivtv_g_fmt_vid_cap(file, fh, fmt); 476 484 fmt->fmt.pix.width = w; 477 485 fmt->fmt.pix.height = h;