From ca444a020d89b6899d5b210e8a45fc3b931d0fc6 Mon Sep 17 00:00:00 2001 From: David Tang Date: Sun, 24 May 2026 21:45:10 +0800 Subject: [PATCH] Fix vcam_enum_framesizes to allow size enumeration When scaling is enabled (conv_res_on), vcam_enum_framesizes previously duplicated a branch that returned only the current output size with a hardcoded index guard of > 0, making it impossible to enumerate all supported sizes. Remove the redundant branch and iterate over vcam_sizes[] with proper bounds checking using ARRAY_SIZE(vcam_sizes). --- device.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/device.c b/device.c index 3aaf13e..aa8042a 100644 --- a/device.c +++ b/device.c @@ -306,25 +306,14 @@ static int vcam_enum_framesizes(struct file *file, size_discrete = &fsize->discrete; size_discrete->width = dev->output_format.width; size_discrete->height = dev->output_format.height; - } else if (dev->conv_res_on) { - if (fsize->index > 0) + } else { + if (fsize->index >= ARRAY_SIZE(vcam_sizes)) return -EINVAL; fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; size_discrete = &fsize->discrete; - size_discrete->width = dev->output_format.width; - size_discrete->height = dev->output_format.height; - } else { - if (fsize->index > 0) - return -EINVAL; - - fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; - fsize->stepwise.min_width = 64; - fsize->stepwise.max_width = 1280; - fsize->stepwise.step_width = 2; - fsize->stepwise.min_height = 64; - fsize->stepwise.max_height = 720; - fsize->stepwise.step_height = 2; + size_discrete->width = vcam_sizes[fsize->index].width; + size_discrete->height = vcam_sizes[fsize->index].height; } return 0;