Skip to content

Commit

Permalink
[media] s5p-fimc: Fix bytesperline and plane payload setup
Browse files Browse the repository at this point in the history
Make sure the sizeimage for 3-planar color formats is
width * height * 3/2 and the bytesperline is same for each
plane in case of a multi-planar format.

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>
  • Loading branch information
Sylwester Nawrocki authored and Mauro Carvalho Chehab committed Apr 19, 2011
1 parent c4a6273 commit 045030f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
6 changes: 4 additions & 2 deletions drivers/media/video/s5p-fimc/fimc-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,10 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
return -EINVAL;
}

for (i = 0; i < frame->fmt->colplanes; i++)
frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height;
for (i = 0; i < frame->fmt->colplanes; i++) {
frame->payload[i] =
(pix->width * pix->height * frame->fmt->depth[i]) >> 3;
}

/* Output DMA frame pixel size and offsets. */
frame->f_width = pix->plane_fmt[0].bytesperline * 8
Expand Down
30 changes: 16 additions & 14 deletions drivers/media/video/s5p-fimc/fimc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,23 +927,23 @@ int fimc_vidioc_try_fmt_mplane(struct file *file, void *priv,
pix->num_planes = fmt->memplanes;
pix->colorspace = V4L2_COLORSPACE_JPEG;

for (i = 0; i < pix->num_planes; ++i) {
int bpl = pix->plane_fmt[i].bytesperline;

dbg("[%d] bpl: %d, depth: %d, w: %d, h: %d",
i, bpl, fmt->depth[i], pix->width, pix->height);
for (i = 0; i < pix->num_planes; ++i) {
u32 bpl = pix->plane_fmt[i].bytesperline;
u32 *sizeimage = &pix->plane_fmt[i].sizeimage;

if (!bpl || (bpl * 8 / fmt->depth[i]) > pix->width)
bpl = (pix->width * fmt->depth[0]) >> 3;
if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width))
bpl = pix->width; /* Planar */

if (!pix->plane_fmt[i].sizeimage)
pix->plane_fmt[i].sizeimage = pix->height * bpl;
if (fmt->colplanes == 1 && /* Packed */
(bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width))
bpl = (pix->width * fmt->depth[0]) / 8;

pix->plane_fmt[i].bytesperline = bpl;
if (i == 0) /* Same bytesperline for each plane. */
mod_x = bpl;

dbg("[%d]: bpl: %d, sizeimage: %d",
i, pix->plane_fmt[i].bytesperline,
pix->plane_fmt[i].sizeimage);
pix->plane_fmt[i].bytesperline = mod_x;
*sizeimage = (pix->width * pix->height * fmt->depth[i]) / 8;
}

return 0;
Expand Down Expand Up @@ -985,8 +985,10 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv,
if (!frame->fmt)
return -EINVAL;

for (i = 0; i < frame->fmt->colplanes; i++)
frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height;
for (i = 0; i < frame->fmt->colplanes; i++) {
frame->payload[i] =
(pix->width * pix->height * frame->fmt->depth[i]) / 8;
}

frame->f_width = pix->plane_fmt[0].bytesperline * 8 /
frame->fmt->depth[0];
Expand Down

0 comments on commit 045030f

Please sign in to comment.