Skip to content

Commit 7b3e0af

Browse files
committed
Merge pull request #1 from ndufresne/endless
Endless: FIMC driver misc fixes
2 parents 17c2094 + c4c9889 commit 7b3e0af

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

drivers/media/platform/s5p-fimc/fimc-core.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static struct fimc_fmt fimc_formats[] = {
118118
}, {
119119
.name = "YUV 4:2:2 planar, Y/Cb/Cr",
120120
.fourcc = V4L2_PIX_FMT_YUV422P,
121-
.depth = { 12 },
121+
.depth = { 16 },
122122
.color = FIMC_FMT_YCBYCR422,
123123
.memplanes = 1,
124124
.colplanes = 3,
@@ -446,7 +446,7 @@ void fimc_prepare_dma_offset(struct fimc_ctx *ctx, struct fimc_frame *f)
446446
struct fimc_variant *variant = ctx->fimc_dev->variant;
447447
u32 i, depth = 0;
448448

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

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

715-
if (frame->fmt->flags & FMT_FLAGS_COMPRESSED) {
716-
pixm->plane_fmt[i].sizeimage = frame->payload[i];
717-
continue;
718-
}
719-
pixm->plane_fmt[i].sizeimage = (frame->o_width *
720-
frame->o_height * frame->fmt->depth[i]) / 8;
721-
}
715+
pixm->plane_fmt[i].sizeimage = frame->payload[i];
716+
}
722717
return 0;
723718
}
724719

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

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

768764
if (fmt->colplanes == 1 && /* Packed */
769765
(bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width))
770766
bpl = (pix->width * fmt->depth[0]) / 8;
771-
772-
if (i == 0) /* Same bytesperline for each plane. */
767+
/*
768+
* Currently bytesperline for each plane is same, except
769+
* V4L2_PIX_FMT_YUV420M format. This calculation may need
770+
* to be changed when other multi-planar formats are added
771+
* to the fimc_formats[] array.
772+
*/
773+
if (i == 0)
773774
bytesperline = bpl;
775+
else if (i == 1 && fmt->memplanes == 3)
776+
bytesperline /= 2;
774777

775778
plane_fmt->bytesperline = bytesperline;
776-
plane_fmt->sizeimage = max((pix->width * pix->height *
777-
fmt->depth[i]) / 8, plane_fmt->sizeimage);
779+
sizeimage = pix->width * pix->height * fmt->depth[i] / 8;
780+
781+
/* Ensure full row for tiled formats */
782+
if (tiled_fmt(fmt)) {
783+
/* 64 * 32 * plane_fmt->bytesperline / 64 */
784+
u32 row_size = plane_fmt->bytesperline * 32;
785+
sizeimage = ALIGN(sizeimage, row_size);
786+
}
787+
788+
/* Spec does not allow to using app proposed size */
789+
plane_fmt->sizeimage = plane_fmt->sizeimage;
778790
}
779791
}
780792

drivers/media/platform/s5p-fimc/fimc-m2m.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static int fimc_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
193193

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

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

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

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

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

0 commit comments

Comments
 (0)