qemu-usb: reduce overhead of capturing one picture

from 3 USB packet to 1 packet per picture. Set the maximal supported
payload to the size of one picture + the size of the required protocol
header.
This commit is contained in:
Alexander Boettcher 2023-09-11 16:28:52 +02:00 committed by Christian Helmuth
parent 385b37dca7
commit 63c5ec7390

View File

@ -412,6 +412,13 @@ static unsigned max_frame_size(unsigned const format)
formats[format].bpp / 8;
}
static void set_video_and_payload_size(unsigned const index,
struct vs_probe_control * const control)
{
control->dwMaxVideoFrameSize = max_frame_size(index);
control->dwMaxPayLoadTransferSize = max_frame_size(index) + sizeof(struct payload_header);
}
static void usb_webcam_init_state(USBWebcamState *state)
{
state->delayed_packet = 0;
@ -667,8 +674,9 @@ static void usb_webcam_handle_control(USBDevice * const dev,
break;
vs_probe_state.bFormatIndex = req->bFormatIndex;
vs_probe_state.dwMaxVideoFrameSize = max_frame_size(vs_probe_state.bFormatIndex - 1);
vs_probe_state.dwMaxPayLoadTransferSize = max_frame_size(vs_probe_state.bFormatIndex - 1) / 2;
set_video_and_payload_size(vs_probe_state.bFormatIndex - 1,
&vs_probe_state);
if (cs == VS_COMMIT_CONTROL) {
bool const notify = vs_commit_state.bFormatIndex != vs_probe_state.bFormatIndex;
@ -801,10 +809,10 @@ static void usb_webcam_register_types(void)
}
vs_commit_state.dwFrameInterval = frame_interval;
vs_commit_state.dwMaxVideoFrameSize = max_frame_size(active_format());
vs_commit_state.dwMaxPayLoadTransferSize = max_frame_size(active_format()) / 2;
vs_commit_state.dwClockFrequency = config.fps;
set_video_and_payload_size(active_format(), &vs_commit_state);
vs_probe_state = vs_commit_state;
/* register device */