Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endless: FIMC driver misc fixes #1

Merged
merged 6 commits into from
Mar 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions drivers/media/platform/s5p-fimc/fimc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static struct fimc_fmt fimc_formats[] = {
}, {
.name = "YUV 4:2:2 planar, Y/Cb/Cr",
.fourcc = V4L2_PIX_FMT_YUV422P,
.depth = { 12 },
.depth = { 16 },
.color = FIMC_FMT_YCBYCR422,
.memplanes = 1,
.colplanes = 3,
Expand Down Expand Up @@ -446,7 +446,7 @@ void fimc_prepare_dma_offset(struct fimc_ctx *ctx, struct fimc_frame *f)
struct fimc_variant *variant = ctx->fimc_dev->variant;
u32 i, depth = 0;

for (i = 0; i < f->fmt->colplanes; i++)
for (i = 0; i < f->fmt->memplanes; i++)
depth += f->fmt->depth[i];

f->dma_offset.y_h = f->offs_h;
Expand Down Expand Up @@ -712,13 +712,8 @@ int fimc_fill_format(struct fimc_frame *frame, struct v4l2_format *f)
bpl = (bpl * frame->fmt->depth[0]) / 8;
pixm->plane_fmt[i].bytesperline = bpl;

if (frame->fmt->flags & FMT_FLAGS_COMPRESSED) {
pixm->plane_fmt[i].sizeimage = frame->payload[i];
continue;
}
pixm->plane_fmt[i].sizeimage = (frame->o_width *
frame->o_height * frame->fmt->depth[i]) / 8;
}
pixm->plane_fmt[i].sizeimage = frame->payload[i];
}
return 0;
}

Expand Down Expand Up @@ -761,20 +756,37 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
for (i = 0; i < pix->num_planes; ++i) {
struct v4l2_plane_pix_format *plane_fmt = &pix->plane_fmt[i];
u32 bpl = plane_fmt->bytesperline;
u32 sizeimage;

if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width))
bpl = pix->width; /* Planar */

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

if (i == 0) /* Same bytesperline for each plane. */
/*
* Currently bytesperline for each plane is same, except
* V4L2_PIX_FMT_YUV420M format. This calculation may need
* to be changed when other multi-planar formats are added
* to the fimc_formats[] array.
*/
if (i == 0)
bytesperline = bpl;
else if (i == 1 && fmt->memplanes == 3)
bytesperline /= 2;

plane_fmt->bytesperline = bytesperline;
plane_fmt->sizeimage = max((pix->width * pix->height *
fmt->depth[i]) / 8, plane_fmt->sizeimage);
sizeimage = pix->width * pix->height * fmt->depth[i] / 8;

/* Ensure full row for tiled formats */
if (tiled_fmt(fmt)) {
/* 64 * 32 * plane_fmt->bytesperline / 64 */
u32 row_size = plane_fmt->bytesperline * 32;
sizeimage = ALIGN(sizeimage, row_size);
}

/* Spec does not allow to using app proposed size */
plane_fmt->sizeimage = plane_fmt->sizeimage;
}
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/media/platform/s5p-fimc/fimc-m2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static int fimc_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,

*num_planes = f->fmt->memplanes;
for (i = 0; i < f->fmt->memplanes; i++) {
sizes[i] = (f->f_width * f->f_height * f->fmt->depth[i]) / 8;
sizes[i] = f->payload[i];
allocators[i] = ctx->fimc_dev->alloc_ctx;
}
return 0;
Expand Down Expand Up @@ -388,9 +388,9 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
/* Update RGB Alpha control state and value range */
fimc_alpha_ctrl_update(ctx);

for (i = 0; i < frame->fmt->colplanes; i++) {
frame->payload[i] =
(pix->width * pix->height * frame->fmt->depth[i]) / 8;
for (i = 0; i < frame->fmt->memplanes; i++) {
struct v4l2_plane_pix_format *plane_fmt = &pix->plane_fmt[i];
frame->payload[i] = plane_fmt->sizeimage;
}

fimc_fill_frame(frame, f);
Expand Down Expand Up @@ -536,7 +536,7 @@ static int fimc_m2m_try_crop(struct fimc_ctx *ctx, struct v4l2_crop *cr)
else
halign = ffs(fimc->variant->min_vsize_align) - 1;

for (i = 0; i < f->fmt->colplanes; i++)
for (i = 0; i < f->fmt->memplanes; i++)
depth += f->fmt->depth[i];

v4l_bound_align_image(&cr->c.width, min_size, f->o_width,
Expand Down