aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2013-01-11 04:36:19 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-05 14:28:48 -0500
commitfa8880bece7321d61a7a5e7bf4b67832071ee047 (patch)
treea7c425b7b3b7a2a69faad5a42ce11f7f22d1636e /drivers/media/platform
parent33133ea7aca7eedf8b1b4cee514c76dce7654a8c (diff)
[media] s5p-fimc: Fix bytesperline value for V4L2_PIX_FMT_YUV420M format
Make sure bytesperline for Cb, Cr planes for V4L2_PIX_FMT_YUV420M format is half of the Y plane value, rather than having same bytesperline for all planes. While at it, simplify the bytesperline parameter handling by storing it when image format is set and returning those values when getting the format, instead of recalculating bytesperline from intermediate parameters. Reported-by: Sebastian Dröge <sebastian.droege@collabora.co.uk> 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/platform')
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-capture.c8
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-core.c27
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-core.h4
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-m2m.c7
4 files changed, 24 insertions, 22 deletions
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 18a70e4a0b0f..df6fc6c7eecd 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -950,9 +950,9 @@ static int fimc_cap_g_fmt_mplane(struct file *file, void *fh,
950 struct v4l2_format *f) 950 struct v4l2_format *f)
951{ 951{
952 struct fimc_dev *fimc = video_drvdata(file); 952 struct fimc_dev *fimc = video_drvdata(file);
953 struct fimc_ctx *ctx = fimc->vid_cap.ctx;
954 953
955 return fimc_fill_format(&ctx->d_frame, f); 954 __fimc_get_format(&fimc->vid_cap.ctx->d_frame, f);
955 return 0;
956} 956}
957 957
958static int fimc_cap_try_fmt_mplane(struct file *file, void *fh, 958static int fimc_cap_try_fmt_mplane(struct file *file, void *fh,
@@ -1074,8 +1074,10 @@ static int __fimc_capture_set_format(struct fimc_dev *fimc,
1074 return ret; 1074 return ret;
1075 } 1075 }
1076 1076
1077 for (i = 0; i < ff->fmt->memplanes; i++) 1077 for (i = 0; i < ff->fmt->memplanes; i++) {
1078 ff->bytesperline[i] = pix->plane_fmt[i].bytesperline;
1078 ff->payload[i] = pix->plane_fmt[i].sizeimage; 1079 ff->payload[i] = pix->plane_fmt[i].sizeimage;
1080 }
1079 1081
1080 set_frame_bounds(ff, pix->width, pix->height); 1082 set_frame_bounds(ff, pix->width, pix->height);
1081 /* Reset the composition rectangle if not yet configured */ 1083 /* Reset the composition rectangle if not yet configured */
diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c b/drivers/media/platform/s5p-fimc/fimc-core.c
index 2e86f44edd23..92d477c91811 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.c
+++ b/drivers/media/platform/s5p-fimc/fimc-core.c
@@ -691,7 +691,7 @@ void fimc_alpha_ctrl_update(struct fimc_ctx *ctx)
691 v4l2_ctrl_unlock(ctrl); 691 v4l2_ctrl_unlock(ctrl);
692} 692}
693 693
694int fimc_fill_format(struct fimc_frame *frame, struct v4l2_format *f) 694void __fimc_get_format(struct fimc_frame *frame, struct v4l2_format *f)
695{ 695{
696 struct v4l2_pix_format_mplane *pixm = &f->fmt.pix_mp; 696 struct v4l2_pix_format_mplane *pixm = &f->fmt.pix_mp;
697 int i; 697 int i;
@@ -704,19 +704,9 @@ int fimc_fill_format(struct fimc_frame *frame, struct v4l2_format *f)
704 pixm->num_planes = frame->fmt->memplanes; 704 pixm->num_planes = frame->fmt->memplanes;
705 705
706 for (i = 0; i < pixm->num_planes; ++i) { 706 for (i = 0; i < pixm->num_planes; ++i) {
707 int bpl = frame->f_width; 707 pixm->plane_fmt[i].bytesperline = frame->bytesperline[i];
708 if (frame->fmt->colplanes == 1) /* packed formats */ 708 pixm->plane_fmt[i].sizeimage = frame->payload[i];
709 bpl = (bpl * frame->fmt->depth[0]) / 8;
710 pixm->plane_fmt[i].bytesperline = bpl;
711
712 if (frame->fmt->flags & FMT_FLAGS_COMPRESSED) {
713 pixm->plane_fmt[i].sizeimage = frame->payload[i];
714 continue;
715 }
716 pixm->plane_fmt[i].sizeimage = (frame->o_width *
717 frame->o_height * frame->fmt->depth[i]) / 8;
718 } 709 }
719 return 0;
720} 710}
721 711
722void fimc_fill_frame(struct fimc_frame *frame, struct v4l2_format *f) 712void fimc_fill_frame(struct fimc_frame *frame, struct v4l2_format *f)
@@ -765,9 +755,16 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
765 if (fmt->colplanes == 1 && /* Packed */ 755 if (fmt->colplanes == 1 && /* Packed */
766 (bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width)) 756 (bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width))
767 bpl = (pix->width * fmt->depth[0]) / 8; 757 bpl = (pix->width * fmt->depth[0]) / 8;
768 758 /*
769 if (i == 0) /* Same bytesperline for each plane. */ 759 * Currently bytesperline for each plane is same, except
760 * V4L2_PIX_FMT_YUV420M format. This calculation may need
761 * to be changed when other multi-planar formats are added
762 * to the fimc_formats[] array.
763 */
764 if (i == 0)
770 bytesperline = bpl; 765 bytesperline = bpl;
766 else if (i == 1 && fmt->memplanes == 3)
767 bytesperline /= 2;
771 768
772 plane_fmt->bytesperline = bytesperline; 769 plane_fmt->bytesperline = bytesperline;
773 plane_fmt->sizeimage = max((pix->width * pix->height * 770 plane_fmt->sizeimage = max((pix->width * pix->height *
diff --git a/drivers/media/platform/s5p-fimc/fimc-core.h b/drivers/media/platform/s5p-fimc/fimc-core.h
index 424ff960f0d9..cf760c364099 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.h
+++ b/drivers/media/platform/s5p-fimc/fimc-core.h
@@ -265,6 +265,7 @@ struct fimc_vid_buffer {
265 * @width: image pixel width 265 * @width: image pixel width
266 * @height: image pixel weight 266 * @height: image pixel weight
267 * @payload: image size in bytes (w x h x bpp) 267 * @payload: image size in bytes (w x h x bpp)
268 * @bytesperline: bytesperline value for each plane
268 * @paddr: image frame buffer physical addresses 269 * @paddr: image frame buffer physical addresses
269 * @dma_offset: DMA offset in bytes 270 * @dma_offset: DMA offset in bytes
270 * @fmt: fimc color format pointer 271 * @fmt: fimc color format pointer
@@ -279,6 +280,7 @@ struct fimc_frame {
279 u32 width; 280 u32 width;
280 u32 height; 281 u32 height;
281 unsigned int payload[VIDEO_MAX_PLANES]; 282 unsigned int payload[VIDEO_MAX_PLANES];
283 unsigned int bytesperline[VIDEO_MAX_PLANES];
282 struct fimc_addr paddr; 284 struct fimc_addr paddr;
283 struct fimc_dma_offset dma_offset; 285 struct fimc_dma_offset dma_offset;
284 struct fimc_fmt *fmt; 286 struct fimc_fmt *fmt;
@@ -637,7 +639,7 @@ int fimc_ctrls_create(struct fimc_ctx *ctx);
637void fimc_ctrls_delete(struct fimc_ctx *ctx); 639void fimc_ctrls_delete(struct fimc_ctx *ctx);
638void fimc_ctrls_activate(struct fimc_ctx *ctx, bool active); 640void fimc_ctrls_activate(struct fimc_ctx *ctx, bool active);
639void fimc_alpha_ctrl_update(struct fimc_ctx *ctx); 641void fimc_alpha_ctrl_update(struct fimc_ctx *ctx);
640int fimc_fill_format(struct fimc_frame *frame, struct v4l2_format *f); 642void __fimc_get_format(struct fimc_frame *frame, struct v4l2_format *f);
641void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height, 643void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
642 struct v4l2_pix_format_mplane *pix); 644 struct v4l2_pix_format_mplane *pix);
643struct fimc_fmt *fimc_find_format(const u32 *pixelformat, const u32 *mbus_code, 645struct fimc_fmt *fimc_find_format(const u32 *pixelformat, const u32 *mbus_code,
diff --git a/drivers/media/platform/s5p-fimc/fimc-m2m.c b/drivers/media/platform/s5p-fimc/fimc-m2m.c
index 1d57f3b87aa3..1eabd7e74849 100644
--- a/drivers/media/platform/s5p-fimc/fimc-m2m.c
+++ b/drivers/media/platform/s5p-fimc/fimc-m2m.c
@@ -294,7 +294,8 @@ static int fimc_m2m_g_fmt_mplane(struct file *file, void *fh,
294 if (IS_ERR(frame)) 294 if (IS_ERR(frame))
295 return PTR_ERR(frame); 295 return PTR_ERR(frame);
296 296
297 return fimc_fill_format(frame, f); 297 __fimc_get_format(frame, f);
298 return 0;
298} 299}
299 300
300static int fimc_try_fmt_mplane(struct fimc_ctx *ctx, struct v4l2_format *f) 301static int fimc_try_fmt_mplane(struct fimc_ctx *ctx, struct v4l2_format *f)
@@ -389,8 +390,8 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
389 fimc_alpha_ctrl_update(ctx); 390 fimc_alpha_ctrl_update(ctx);
390 391
391 for (i = 0; i < frame->fmt->colplanes; i++) { 392 for (i = 0; i < frame->fmt->colplanes; i++) {
392 frame->payload[i] = 393 frame->bytesperline[i] = pix->plane_fmt[i].bytesperline;
393 (pix->width * pix->height * frame->fmt->depth[i]) / 8; 394 frame->payload[i] = pix->plane_fmt[i].sizeimage;
394 } 395 }
395 396
396 fimc_fill_frame(frame, f); 397 fimc_fill_frame(frame, f);