Skip to content

Commit 684ab6d

Browse files
naushirpopcornmix
authored andcommitted
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 abd2676 commit 684ab6d

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
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
@@ -1074,9 +1074,16 @@ static void pispbe_set_plane_params(struct v4l2_format *f,
10741074
for (unsigned int i = 0; i < nplanes; i++) {
10751075
struct v4l2_plane_pix_format *p = &f->fmt.pix_mp.plane_fmt[i];
10761076
unsigned int bpl, plane_size;
1077+
/*
1078+
* If a stride has been provided, ensure it meets the minimal
1079+
* alignment constraints. If not provided, use an optimal stride
1080+
* alignment for efficiency.
1081+
*/
1082+
const unsigned int align =
1083+
p->bytesperline ? fmt->min_align : fmt->opt_align;
10771084

10781085
bpl = (f->fmt.pix_mp.width * fmt->bit_depth) >> 3;
1079-
bpl = ALIGN(max(p->bytesperline, bpl), fmt->opt_align);
1086+
bpl = ALIGN(max(p->bytesperline, bpl), align);
10801087

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

0 commit comments

Comments
 (0)