@@ -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
0 commit comments