From 73072d6d16a87ed3cb27aa74d682221d6f5c98a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Grzesik?= Date: Mon, 31 Jan 2022 13:00:34 +0000 Subject: [PATCH] virtio: video: encoder: set frame rate only if successfully changed Encoders Stream's frame rate was updated before a request was made. This could cause hypervisor to report incorrect frame rate to guest and other invalid behaviour if the request failed. This CL changes the order in which frame rate is updated. First a request is made, and then if successful, the frame rate is updated in the stream structure. BUG=b:160440787 BUG=b:161774071 TEST=v4l2-compliance -d /dev/video1 TEST=v4l2-ctl -d 1 --set-fmt-video-out width=1280,height=1280,pixelformat=NV12 \ --set-output-parm 10 --get-output-parm TEST=tast run eve arc.Video* Change-Id: I11a93d6d6338829ee0622f40f9b544a4ef2a69dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425362 Reviewed-by: Alexandre Courbot Tested-by: kokoro Commit-Queue: Marcin Wojtas --- devices/src/virtio/video/encoder/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devices/src/virtio/video/encoder/mod.rs b/devices/src/virtio/video/encoder/mod.rs index e1c6200bd2..59981fb425 100644 --- a/devices/src/virtio/video/encoder/mod.rs +++ b/devices/src/virtio/video/encoder/mod.rs @@ -1038,8 +1038,6 @@ impl EncoderDevice { // active we will request a dynamic framerate change instead, and it's up to the encoder // backend to return an error on invalid requests. if stream.dst_params.frame_rate != frame_rate { - stream.src_params.frame_rate = frame_rate; - stream.dst_params.frame_rate = frame_rate; if let Some(ref mut encoder_session) = stream.encoder_session { if !resources_queued { create_session = true; @@ -1051,6 +1049,8 @@ impl EncoderDevice { return Err(VideoError::InvalidOperation); } } + stream.src_params.frame_rate = frame_rate; + stream.dst_params.frame_rate = frame_rate; } match queue_type {