Skip to content
Snippets Groups Projects
Commit fee0795f authored by Mattijs Korpershoek's avatar Mattijs Korpershoek Committed by Guillaume LA ROQUE
Browse files

V4L2Decoder: Use TRY_DECODER_CMD when checking flush support

Commit 05617941 ("V4L2Device: Refactor querying capabilities")
changed behaviour when testing if V4L2_DEC_CMD_STOP is supported
by the device.

Before, it used VIDIOC_TRY_DECODER_CMD
Now, it uses VIDIOC_DECODER_CMD

According to the kernel docs [1], VIDIOC_TRY_DECODER_CMD can be used to
try a command without actually executing it.

In V4L2Decoder::start(), it seems we want to try if V4L2_DEC_CMD_STOP is
supported, not actually executing it.

Introduce a new helper function, tryV4L2DecoderCmd() to do so and use
that instead.

[1] https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-decoder-cmd.html#description
Fixes: 05617941 ("V4L2Device: Refactor querying capabilities")
Link: https://android-review.googlesource.com/c/platform/external/v4l2_codec2/+/3301216


Change-Id: I523baa430951c65aa904cdb9f5636bb424ab2dd6
Signed-off-by: default avatarGuillaume La Roque <glaroque@baylibre.com>
Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
parent f521d9ca
No related branches found
No related tags found
1 merge request!15Backport all patches for TI
......@@ -144,7 +144,7 @@ bool V4L2Decoder::start(const VideoCodec& codec, const size_t inputBufferSize,
return false;
}
if (!sendV4L2DecoderCmd(false)) {
if (!tryV4L2DecoderCmd(false)) {
ALOGE("Device does not support flushing (V4L2_DEC_CMD_STOP)");
return false;
}
......@@ -986,6 +986,20 @@ bool V4L2Decoder::sendV4L2DecoderCmd(bool start) {
return true;
}
bool V4L2Decoder::tryV4L2DecoderCmd(bool start) {
ALOGV("%s(start=%d)", __func__, start);
ALOG_ASSERT(mTaskRunner->RunsTasksInCurrentSequence());
struct v4l2_decoder_cmd cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.cmd = start ? V4L2_DEC_CMD_START : V4L2_DEC_CMD_STOP;
if (mDevice->ioctl(VIDIOC_TRY_DECODER_CMD, &cmd) != 0) {
return false;
}
return true;
}
void V4L2Decoder::onError() {
ALOGV("%s()", __func__);
ALOG_ASSERT(mTaskRunner->RunsTasksInCurrentSequence());
......
......@@ -95,6 +95,7 @@ private:
std::optional<struct v4l2_format> getFormatInfo();
Rect getVisibleRect(const ui::Size& codedSize);
bool sendV4L2DecoderCmd(bool start);
bool tryV4L2DecoderCmd(bool start);
void setState(State newState);
void onError();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment