summaryrefslogtreecommitdiff
path: root/include/linux/platform_data/git@git.tavy.me:linux.git
diff options
context:
space:
mode:
authorXu Yang <xu.yang_2@nxp.com>2026-01-13 17:53:07 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-14 16:03:17 +0100
commit2edc1acb1a2512843425aa19d0c6060a0a924605 (patch)
treeac45846478068c727cf63393b593429545b4305a /include/linux/platform_data/git@git.tavy.me:linux.git
parent42c85d89b8d677b51f6a75569c69299a46d9f03d (diff)
usb: gadget: uvc: fix req_payload_size calculation
Current req_payload_size calculation has 2 issue: (1) When the first time calculate req_payload_size for all the buffers, reqs_per_frame = 0 will be the divisor of DIV_ROUND_UP(). So the result is undefined. This happens because VIDIOC_STREAMON is always executed after VIDIOC_QBUF. So video->reqs_per_frame will be 0 until VIDIOC_STREAMON is run. (2) The buf->req_payload_size may be bigger than max_req_size. Take YUYV pixel format as example: If bInterval = 1, video->interval = 666666, high-speed: video->reqs_per_frame = 666666 / 1250 = 534 720p: buf->req_payload_size = 1843200 / 534 = 3452 1080p: buf->req_payload_size = 4147200 / 534 = 7766 Based on such req_payload_size, the controller can't run normally. To fix above issue, assign max_req_size to buf->req_payload_size when video->reqs_per_frame = 0. And limit buf->req_payload_size to video->req_size if it's large than video->req_size. Since max_req_size is used at many place, add it to struct uvc_video and set the value once endpoint is enabled. Fixes: 98ad03291560 ("usb: gadget: uvc: set req_length based on payload by nreqs instead of req_size") Cc: stable@vger.kernel.org Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Link: https://patch.msgid.link/20260113-uvc-gadget-fix-patch-v2-1-62950ef5bcb5@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/platform_data/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions