Skip to content

Commit df852a6

Browse files
committed
drivers: media: pisp_be: Add minimal alinment to the format structure
Add a new minimal alignment field to the format structure. This minimal alignment will be used if a stride has been provided by userland. If no stride has been provided by userland (bytesperline == 0), the optimal alignemnt will be used in the stride calculation. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 8153625 commit df852a6

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

drivers/media/platform/raspberrypi/pisp_be/pisp_be.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,9 +1104,16 @@ static void pispbe_set_plane_params(struct v4l2_format *f,
11041104
for (unsigned int i = 0; i < nplanes; i++) {
11051105
struct v4l2_plane_pix_format *p = &f->fmt.pix_mp.plane_fmt[i];
11061106
unsigned int bpl, plane_size;
1107+
/*
1108+
* If a stride has been provided, ensure it meets the minimal
1109+
* alignment constraints. If not provided, use an optimal stride
1110+
* alignment for efficiency.
1111+
*/
1112+
const unsigned int align =
1113+
p->bytesperline ? fmt->min_align : fmt->opt_align;
11071114

11081115
bpl = (f->fmt.pix_mp.width * fmt->bit_depth) >> 3;
1109-
bpl = ALIGN(max(p->bytesperline, bpl), fmt->opt_align);
1116+
bpl = ALIGN(max(p->bytesperline, bpl), align);
11101117

11111118
plane_size = bpl * f->fmt.pix_mp.height *
11121119
(nplanes > 1 ? fmt->plane_factor[i] : total_plane_factor);

0 commit comments

Comments
 (0)