Skip to content

Commit 0f7c7cc

Browse files
committed
drivers: video: sw_generator: fix video_sw_generator_enum_frmival()
Fix video_sw_generator_enum_frmival() only matching the first size of a pixel format. The selection loop was stopping at the first matching pixel format rather than pixel format + size pair. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 6d47411 commit 0f7c7cc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/video/video_sw_generator.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,14 @@ static int video_sw_generator_enum_frmival(const struct device *dev, enum video_
318318
return -EINVAL;
319319
}
320320

321-
while (fmts[i].pixelformat && (fmts[i].pixelformat != fie->format->pixelformat)) {
321+
while (fmts[i].pixelformat && (fmts[i].pixelformat != fie->format->pixelformat) &&
322+
IN_RANGE(fie->format->width, fmts[i].width_min, fmts[i].width_max) &&
323+
IN_RANGE(fie->format->height, fmts[i].height_min, fmts[i].height_max)) {
322324
i++;
323325
}
324326

325-
if ((i == ARRAY_SIZE(fmts)) ||
326-
!IN_RANGE(fie->format->width, fmts[i].width_min, fmts[i].width_max) &&
327-
!IN_RANGE(fie->format->height, fmts[i].height_min, fmts[i].height_max)) {
327+
if (i == ARRAY_SIZE(fmts) - 1) {
328+
LOG_ERR("Nothing matching the requested format was found");
328329
return -EINVAL;
329330
}
330331

0 commit comments

Comments
 (0)