diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2011-06-13 10:09:40 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-09-06 16:41:37 -0400 |
commit | cf52df8acfda9442d64ab4d3d6085877f6d88d46 (patch) | |
tree | bc3146a84c3bd0c867ccb7bbc76e36a5887e57e7 /drivers/media/video/s5p-fimc/fimc-capture.c | |
parent | 9e803a0450a5973d1c252980ea69e5b171d7f0ca (diff) |
[media] s5p-fimc: Correct color format enumeration
Replace fimc_find_format() and find_mbus_format() with single function
that can return a pointer to the private format description based
on fourcc, media bus code or index in the table.
Create separate VIDIOC_ENUM_FMT ioctl handlers for video capture
and mem-to-mem video node. This is needed because some formats are
valid only for the video capture and some only for the mem-to-mem
video node.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s5p-fimc/fimc-capture.c')
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-capture.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index 6c4dca0925a9..32c285489be7 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c | |||
@@ -389,6 +389,22 @@ static int fimc_vidioc_querycap_capture(struct file *file, void *priv, | |||
389 | return 0; | 389 | return 0; |
390 | } | 390 | } |
391 | 391 | ||
392 | static int fimc_cap_enum_fmt_mplane(struct file *file, void *priv, | ||
393 | struct v4l2_fmtdesc *f) | ||
394 | { | ||
395 | struct fimc_fmt *fmt; | ||
396 | |||
397 | fmt = fimc_find_format(NULL, NULL, FMT_FLAGS_CAM | FMT_FLAGS_M2M, | ||
398 | f->index); | ||
399 | if (!fmt) | ||
400 | return -EINVAL; | ||
401 | strncpy(f->description, fmt->name, sizeof(f->description) - 1); | ||
402 | f->pixelformat = fmt->fourcc; | ||
403 | if (fmt->fourcc == V4L2_MBUS_FMT_JPEG_1X8) | ||
404 | f->flags |= V4L2_FMT_FLAG_COMPRESSED; | ||
405 | return 0; | ||
406 | } | ||
407 | |||
392 | /* Synchronize formats of the camera interface input and attached sensor. */ | 408 | /* Synchronize formats of the camera interface input and attached sensor. */ |
393 | static int sync_capture_fmt(struct fimc_ctx *ctx) | 409 | static int sync_capture_fmt(struct fimc_ctx *ctx) |
394 | { | 410 | { |
@@ -407,7 +423,7 @@ static int sync_capture_fmt(struct fimc_ctx *ctx) | |||
407 | } | 423 | } |
408 | dbg("w: %d, h: %d, code= %d", fmt->width, fmt->height, fmt->code); | 424 | dbg("w: %d, h: %d, code= %d", fmt->width, fmt->height, fmt->code); |
409 | 425 | ||
410 | frame->fmt = find_mbus_format(fmt, FMT_FLAGS_CAM); | 426 | frame->fmt = fimc_find_format(NULL, &fmt->code, FMT_FLAGS_CAM, -1); |
411 | if (!frame->fmt) { | 427 | if (!frame->fmt) { |
412 | err("fimc source format not found\n"); | 428 | err("fimc source format not found\n"); |
413 | return -EINVAL; | 429 | return -EINVAL; |
@@ -469,12 +485,10 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, | |||
469 | frame = &ctx->d_frame; | 485 | frame = &ctx->d_frame; |
470 | 486 | ||
471 | pix = &f->fmt.pix_mp; | 487 | pix = &f->fmt.pix_mp; |
472 | frame->fmt = find_format(f, FMT_FLAGS_M2M | FMT_FLAGS_CAM); | 488 | frame->fmt = fimc_find_format(&pix->pixelformat, NULL, |
473 | if (!frame->fmt) { | 489 | FMT_FLAGS_M2M | FMT_FLAGS_CAM, 0); |
474 | v4l2_err(fimc->vid_cap.vfd, | 490 | if (WARN(frame->fmt == NULL, "Pixel format lookup failed\n")) |
475 | "Not supported capture (FIMC target) color format\n"); | ||
476 | return -EINVAL; | 491 | return -EINVAL; |
477 | } | ||
478 | 492 | ||
479 | for (i = 0; i < frame->fmt->colplanes; i++) { | 493 | for (i = 0; i < frame->fmt->colplanes; i++) { |
480 | frame->payload[i] = | 494 | frame->payload[i] = |
@@ -654,7 +668,7 @@ static int fimc_cap_s_crop(struct file *file, void *fh, struct v4l2_crop *cr) | |||
654 | static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = { | 668 | static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = { |
655 | .vidioc_querycap = fimc_vidioc_querycap_capture, | 669 | .vidioc_querycap = fimc_vidioc_querycap_capture, |
656 | 670 | ||
657 | .vidioc_enum_fmt_vid_cap_mplane = fimc_vidioc_enum_fmt_mplane, | 671 | .vidioc_enum_fmt_vid_cap_mplane = fimc_cap_enum_fmt_mplane, |
658 | .vidioc_try_fmt_vid_cap_mplane = fimc_cap_try_fmt_mplane, | 672 | .vidioc_try_fmt_vid_cap_mplane = fimc_cap_try_fmt_mplane, |
659 | .vidioc_s_fmt_vid_cap_mplane = fimc_cap_s_fmt_mplane, | 673 | .vidioc_s_fmt_vid_cap_mplane = fimc_cap_s_fmt_mplane, |
660 | .vidioc_g_fmt_vid_cap_mplane = fimc_cap_g_fmt_mplane, | 674 | .vidioc_g_fmt_vid_cap_mplane = fimc_cap_g_fmt_mplane, |
@@ -715,7 +729,6 @@ int fimc_register_capture_device(struct fimc_dev *fimc, | |||
715 | struct video_device *vfd; | 729 | struct video_device *vfd; |
716 | struct fimc_vid_cap *vid_cap; | 730 | struct fimc_vid_cap *vid_cap; |
717 | struct fimc_ctx *ctx; | 731 | struct fimc_ctx *ctx; |
718 | struct v4l2_format f; | ||
719 | struct fimc_frame *fr; | 732 | struct fimc_frame *fr; |
720 | struct vb2_queue *q; | 733 | struct vb2_queue *q; |
721 | int ret = -ENOMEM; | 734 | int ret = -ENOMEM; |
@@ -730,9 +743,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc, | |||
730 | ctx->state = FIMC_CTX_CAP; | 743 | ctx->state = FIMC_CTX_CAP; |
731 | 744 | ||
732 | /* Default format of the output frames */ | 745 | /* Default format of the output frames */ |
733 | f.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32; | ||
734 | fr = &ctx->d_frame; | 746 | fr = &ctx->d_frame; |
735 | fr->fmt = find_format(&f, FMT_FLAGS_M2M); | 747 | fr->fmt = fimc_find_format(NULL, NULL, FMT_FLAGS_CAM, 0); |
736 | fr->width = fr->f_width = fr->o_width = 640; | 748 | fr->width = fr->f_width = fr->o_width = 640; |
737 | fr->height = fr->f_height = fr->o_height = 480; | 749 | fr->height = fr->f_height = fr->o_height = 480; |
738 | 750 | ||