Skip to content

Commit e2b066e

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. Return an error on fie.index > 1 as there is only one framerate entry per pixelformat. Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent 7f2a66e commit e2b066e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/video/video_sw_generator.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,18 @@ static int video_sw_generator_enum_frmival(const struct device *dev, struct vide
280280
{
281281
int i = 0;
282282

283-
while (fmts[i].pixelformat && (fmts[i].pixelformat != fie->format->pixelformat)) {
283+
if (fie->index >= 1) {
284+
return -ERANGE;
285+
}
286+
287+
while (fmts[i].pixelformat && (fmts[i].pixelformat != fie->format->pixelformat) &&
288+
IN_RANGE(fie->format->width, fmts[i].width_min, fmts[i].width_max) &&
289+
IN_RANGE(fie->format->height, fmts[i].height_min, fmts[i].height_max)) {
284290
i++;
285291
}
286292

287-
if ((i == ARRAY_SIZE(fmts)) ||
288-
!IN_RANGE(fie->format->width, fmts[i].width_min, fmts[i].width_max) &&
289-
!IN_RANGE(fie->format->height, fmts[i].height_min, fmts[i].height_max)) {
293+
if (i == ARRAY_SIZE(fmts) - 1) {
294+
LOG_ERR("Nothing matching the requested format was found");
290295
return -EINVAL;
291296
}
292297

0 commit comments

Comments
 (0)