Skip to content

Fix vcam_enum_framesizes to enumerate all sizes when scaling is enabled#44

Merged
jserv merged 1 commit into
sysprog21:masterfrom
davidzwei:davidzwei/fix-enum-framesizes
May 30, 2026
Merged

Fix vcam_enum_framesizes to enumerate all sizes when scaling is enabled#44
jserv merged 1 commit into
sysprog21:masterfrom
davidzwei:davidzwei/fix-enum-framesizes

Conversation

@davidzwei
Copy link
Copy Markdown
Contributor

@davidzwei davidzwei commented May 24, 2026

When scaling is enabled, vcam_enum_framesizes only returned one frame size because the index guard was never updated after the branch was changed. The original else block also became unreachable dead code.

Fix by removing the dead code and enumerating vcam_sizes[] by index.


Summary by cubic

Fixes vcam_enum_framesizes to return all discrete frame sizes instead of only the current output size when scaling is enabled. Removes redundant branches and adds proper bounds checking.

  • Bug Fixes
    • Iterates vcam_sizes[fsize->index] with >= ARRAY_SIZE(vcam_sizes) guard to enumerate all discrete sizes.
    • Removes the conv_res_on duplicate path and the unreachable stepwise branch.

Written for commit ca444a0. Summary will update on new commits.

Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Copy link
Copy Markdown
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read https://cbea.ms/git-commit/ carefully and enforce the rules.

@jserv
Copy link
Copy Markdown
Collaborator

jserv commented May 29, 2026

Provide test cases to reproduce.

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).
@davidzwei davidzwei force-pushed the davidzwei/fix-enum-framesizes branch from c069436 to ca444a0 Compare May 30, 2026 05:17
@davidzwei
Copy link
Copy Markdown
Contributor Author

I've modified my commit message.

@davidzwei
Copy link
Copy Markdown
Contributor Author

davidzwei commented May 30, 2026

test case to reproduce:

This test case verifies that VIDIOC_ENUM_FRAMESIZES returns all supported frame sizes when scaling is enabled. Before the fix, only the first size was returned due to an incorrect index guard in vcam_enum_framesizes.

sudo insmod vcam.ko allow_scaling=1
sudo ./vcam-util -l        # find the device node, e.g. /dev/video0
v4l2-ctl -d /dev/video0 --list-framesizes=RGB3  # replace with actual device node
sudo rmmod vcam

output before fix:

Size: Discrete 640x480

output after fix:

Size: Discrete 480x360
Size: Discrete 640x480
Size: Discrete 1280x720

@jserv jserv merged commit 559459f into sysprog21:master May 30, 2026
2 checks passed
@jserv
Copy link
Copy Markdown
Collaborator

jserv commented May 30, 2026

Thank @davidzwei for contributing!

@davidzwei davidzwei deleted the davidzwei/fix-enum-framesizes branch May 30, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants