diff options
-rw-r--r-- | drivers/media/video/ivtv/ivtv-ioctl.c | 112 |
1 files changed, 67 insertions, 45 deletions
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 49b297e788db..584ffc61c982 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -378,6 +378,8 @@ static int ivtv_g_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_fo | |||
378 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 378 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
379 | struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; | 379 | struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; |
380 | 380 | ||
381 | vbifmt->reserved[0] = 0; | ||
382 | vbifmt->reserved[1] = 0; | ||
381 | if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT)) | 383 | if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT)) |
382 | return -EINVAL; | 384 | return -EINVAL; |
383 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; | 385 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; |
@@ -396,21 +398,24 @@ static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f | |||
396 | { | 398 | { |
397 | struct ivtv_open_id *id = fh; | 399 | struct ivtv_open_id *id = fh; |
398 | struct ivtv *itv = id->itv; | 400 | struct ivtv *itv = id->itv; |
399 | 401 | struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; | |
400 | fmt->fmt.pix.width = itv->params.width; | 402 | |
401 | fmt->fmt.pix.height = itv->params.height; | 403 | pixfmt->width = itv->params.width; |
402 | fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 404 | pixfmt->height = itv->params.height; |
403 | fmt->fmt.pix.field = V4L2_FIELD_INTERLACED; | 405 | pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; |
404 | if (id->type == IVTV_ENC_STREAM_TYPE_YUV || | 406 | pixfmt->field = V4L2_FIELD_INTERLACED; |
405 | id->type == IVTV_DEC_STREAM_TYPE_YUV) { | 407 | pixfmt->priv = 0; |
406 | fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_HM12; | 408 | if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { |
409 | pixfmt->pixelformat = V4L2_PIX_FMT_HM12; | ||
407 | /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ | 410 | /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ |
408 | fmt->fmt.pix.sizeimage = | 411 | pixfmt->sizeimage = |
409 | fmt->fmt.pix.height * fmt->fmt.pix.width + | 412 | pixfmt->height * pixfmt->width + |
410 | fmt->fmt.pix.height * (fmt->fmt.pix.width / 2); | 413 | pixfmt->height * (pixfmt->width / 2); |
414 | pixfmt->bytesperline = 720; | ||
411 | } else { | 415 | } else { |
412 | fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 416 | pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; |
413 | fmt->fmt.pix.sizeimage = 128 * 1024; | 417 | pixfmt->sizeimage = 128 * 1024; |
418 | pixfmt->bytesperline = 0; | ||
414 | } | 419 | } |
415 | return 0; | 420 | return 0; |
416 | } | 421 | } |
@@ -418,14 +423,18 @@ static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f | |||
418 | static int ivtv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt) | 423 | static int ivtv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt) |
419 | { | 424 | { |
420 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 425 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
421 | 426 | struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi; | |
422 | fmt->fmt.vbi.sampling_rate = 27000000; | 427 | |
423 | fmt->fmt.vbi.offset = 248; | 428 | vbifmt->sampling_rate = 27000000; |
424 | fmt->fmt.vbi.samples_per_line = itv->vbi.raw_decoder_line_size - 4; | 429 | vbifmt->offset = 248; |
425 | fmt->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | 430 | vbifmt->samples_per_line = itv->vbi.raw_decoder_line_size - 4; |
426 | fmt->fmt.vbi.start[0] = itv->vbi.start[0]; | 431 | vbifmt->sample_format = V4L2_PIX_FMT_GREY; |
427 | fmt->fmt.vbi.start[1] = itv->vbi.start[1]; | 432 | vbifmt->start[0] = itv->vbi.start[0]; |
428 | fmt->fmt.vbi.count[0] = fmt->fmt.vbi.count[1] = itv->vbi.count; | 433 | vbifmt->start[1] = itv->vbi.start[1]; |
434 | vbifmt->count[0] = vbifmt->count[1] = itv->vbi.count; | ||
435 | vbifmt->flags = 0; | ||
436 | vbifmt->reserved[0] = 0; | ||
437 | vbifmt->reserved[1] = 0; | ||
429 | return 0; | 438 | return 0; |
430 | } | 439 | } |
431 | 440 | ||
@@ -435,6 +444,8 @@ static int ivtv_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo | |||
435 | struct ivtv_open_id *id = fh; | 444 | struct ivtv_open_id *id = fh; |
436 | struct ivtv *itv = id->itv; | 445 | struct ivtv *itv = id->itv; |
437 | 446 | ||
447 | vbifmt->reserved[0] = 0; | ||
448 | vbifmt->reserved[1] = 0; | ||
438 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; | 449 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; |
439 | 450 | ||
440 | if (id->type == IVTV_DEC_STREAM_TYPE_VBI) { | 451 | if (id->type == IVTV_DEC_STREAM_TYPE_VBI) { |
@@ -453,42 +464,39 @@ static int ivtv_g_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *f | |||
453 | { | 464 | { |
454 | struct ivtv_open_id *id = fh; | 465 | struct ivtv_open_id *id = fh; |
455 | struct ivtv *itv = id->itv; | 466 | struct ivtv *itv = id->itv; |
467 | struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; | ||
456 | 468 | ||
457 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | 469 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) |
458 | return -EINVAL; | 470 | return -EINVAL; |
459 | fmt->fmt.pix.width = itv->main_rect.width; | 471 | pixfmt->width = itv->main_rect.width; |
460 | fmt->fmt.pix.height = itv->main_rect.height; | 472 | pixfmt->height = itv->main_rect.height; |
461 | fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 473 | pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; |
462 | fmt->fmt.pix.field = V4L2_FIELD_INTERLACED; | 474 | pixfmt->field = V4L2_FIELD_INTERLACED; |
475 | pixfmt->priv = 0; | ||
463 | if (id->type == IVTV_DEC_STREAM_TYPE_YUV) { | 476 | if (id->type == IVTV_DEC_STREAM_TYPE_YUV) { |
464 | switch (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) { | 477 | switch (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) { |
465 | case IVTV_YUV_MODE_INTERLACED: | 478 | case IVTV_YUV_MODE_INTERLACED: |
466 | fmt->fmt.pix.field = (itv->yuv_info.lace_mode & IVTV_YUV_SYNC_MASK) ? | 479 | pixfmt->field = (itv->yuv_info.lace_mode & IVTV_YUV_SYNC_MASK) ? |
467 | V4L2_FIELD_INTERLACED_BT : V4L2_FIELD_INTERLACED_TB; | 480 | V4L2_FIELD_INTERLACED_BT : V4L2_FIELD_INTERLACED_TB; |
468 | break; | 481 | break; |
469 | case IVTV_YUV_MODE_PROGRESSIVE: | 482 | case IVTV_YUV_MODE_PROGRESSIVE: |
470 | fmt->fmt.pix.field = V4L2_FIELD_NONE; | 483 | pixfmt->field = V4L2_FIELD_NONE; |
471 | break; | 484 | break; |
472 | default: | 485 | default: |
473 | fmt->fmt.pix.field = V4L2_FIELD_ANY; | 486 | pixfmt->field = V4L2_FIELD_ANY; |
474 | break; | 487 | break; |
475 | } | 488 | } |
476 | fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_HM12; | 489 | pixfmt->pixelformat = V4L2_PIX_FMT_HM12; |
477 | fmt->fmt.pix.bytesperline = 720; | 490 | pixfmt->bytesperline = 720; |
478 | fmt->fmt.pix.width = itv->yuv_info.v4l2_src_w; | 491 | pixfmt->width = itv->yuv_info.v4l2_src_w; |
479 | fmt->fmt.pix.height = itv->yuv_info.v4l2_src_h; | 492 | pixfmt->height = itv->yuv_info.v4l2_src_h; |
480 | /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ | ||
481 | fmt->fmt.pix.sizeimage = | ||
482 | 1080 * ((fmt->fmt.pix.height + 31) & ~31); | ||
483 | } else if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { | ||
484 | fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_HM12; | ||
485 | /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ | 493 | /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ |
486 | fmt->fmt.pix.sizeimage = | 494 | pixfmt->sizeimage = |
487 | fmt->fmt.pix.height * fmt->fmt.pix.width + | 495 | 1080 * ((pixfmt->height + 31) & ~31); |
488 | fmt->fmt.pix.height * (fmt->fmt.pix.width / 2); | ||
489 | } else { | 496 | } else { |
490 | fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 497 | pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; |
491 | fmt->fmt.pix.sizeimage = 128 * 1024; | 498 | pixfmt->sizeimage = 128 * 1024; |
499 | pixfmt->bytesperline = 0; | ||
492 | } | 500 | } |
493 | return 0; | 501 | return 0; |
494 | } | 502 | } |
@@ -496,11 +504,19 @@ static int ivtv_g_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *f | |||
496 | static int ivtv_g_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt) | 504 | static int ivtv_g_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt) |
497 | { | 505 | { |
498 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 506 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
507 | struct v4l2_window *winfmt = &fmt->fmt.win; | ||
499 | 508 | ||
500 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | 509 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) |
501 | return -EINVAL; | 510 | return -EINVAL; |
502 | fmt->fmt.win.chromakey = itv->osd_chroma_key; | 511 | winfmt->chromakey = itv->osd_chroma_key; |
503 | fmt->fmt.win.global_alpha = itv->osd_global_alpha; | 512 | winfmt->global_alpha = itv->osd_global_alpha; |
513 | winfmt->field = V4L2_FIELD_INTERLACED; | ||
514 | winfmt->clips = NULL; | ||
515 | winfmt->clipcount = 0; | ||
516 | winfmt->bitmap = NULL; | ||
517 | winfmt->w.top = winfmt->w.left = 0; | ||
518 | winfmt->w.width = itv->osd_rect.width; | ||
519 | winfmt->w.height = itv->osd_rect.height; | ||
504 | return 0; | 520 | return 0; |
505 | } | 521 | } |
506 | 522 | ||
@@ -542,7 +558,8 @@ static int ivtv_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_ | |||
542 | 558 | ||
543 | /* set sliced VBI capture format */ | 559 | /* set sliced VBI capture format */ |
544 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; | 560 | vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; |
545 | memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); | 561 | vbifmt->reserved[0] = 0; |
562 | vbifmt->reserved[1] = 0; | ||
546 | 563 | ||
547 | if (vbifmt->service_set) | 564 | if (vbifmt->service_set) |
548 | ivtv_expand_service_set(vbifmt, itv->is_50hz); | 565 | ivtv_expand_service_set(vbifmt, itv->is_50hz); |
@@ -581,9 +598,14 @@ static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format | |||
581 | static int ivtv_try_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt) | 598 | static int ivtv_try_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt) |
582 | { | 599 | { |
583 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; | 600 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
601 | u32 chromakey = fmt->fmt.win.chromakey; | ||
602 | u8 global_alpha = fmt->fmt.win.global_alpha; | ||
584 | 603 | ||
585 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | 604 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) |
586 | return -EINVAL; | 605 | return -EINVAL; |
606 | ivtv_g_fmt_vid_out_overlay(file, fh, fmt); | ||
607 | fmt->fmt.win.chromakey = chromakey; | ||
608 | fmt->fmt.win.global_alpha = global_alpha; | ||
587 | return 0; | 609 | return 0; |
588 | } | 610 | } |
589 | 611 | ||