From: Stanimir Varbanov <stanimir.varbanov@linaro.org>
To: linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
Vikash Garodia <vgarodia@codeaurora.org>,
Tomasz Figa <tfiga@chromium.org>,
Alexandre Courbot <acourbot@chromium.org>,
Stanimir Varbanov <stanimir.varbanov@linaro.org>
Subject: [PATCH v2 11/11] venus: dec: populate properly timestamps and flags for capture buffers
Date: Fri, 28 Jun 2019 16:00:02 +0300 [thread overview]
Message-ID: <20190628130002.24293-12-stanimir.varbanov@linaro.org> (raw)
In-Reply-To: <20190628130002.24293-1-stanimir.varbanov@linaro.org>
Cache flags, timestamps and timecode structure of OUTPUT buffers
in per-instance structure array and fill correctly the same when
the CAPTURE buffers are done.
This will make v4l2-compliance decoder streaming test happy.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
---
drivers/media/platform/qcom/venus/core.h | 8 +++
drivers/media/platform/qcom/venus/helpers.c | 54 +++++++++++++++++++++
drivers/media/platform/qcom/venus/helpers.h | 2 +
drivers/media/platform/qcom/venus/vdec.c | 2 +
4 files changed, 66 insertions(+)
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 139b5d786375..5c6d4145138d 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -220,6 +220,13 @@ enum venus_dec_state {
VENUS_DEC_STATE_DRC = 7
};
+struct venus_ts_metadata {
+ bool used;
+ u64 ts_ns;
+ u64 ts_us;
+ u32 flags;
+ struct v4l2_timecode tc;
+};
/**
* struct venus_inst - holds per instance parameters
@@ -305,6 +312,7 @@ struct venus_inst {
wait_queue_head_t reconf_wait;
unsigned int subscriptions;
int buf_count;
+ struct venus_ts_metadata tss[VIDEO_MAX_FRAME];
u64 fps;
struct v4l2_fract timeperframe;
const struct venus_format *fmt_out;
diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index c948c4e809b5..b42a1fce273a 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -463,6 +463,57 @@ static void return_buf_error(struct venus_inst *inst,
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
}
+static void
+put_ts_metadata(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf)
+{
+ struct vb2_buffer *vb = &vbuf->vb2_buf;
+ unsigned int i;
+ int slot = -1;
+ u64 ts_us = vb->timestamp;
+
+ for (i = 0; i < ARRAY_SIZE(inst->tss); i++) {
+ if (!inst->tss[i].used) {
+ slot = i;
+ break;
+ }
+ }
+
+ if (slot == -1) {
+ dev_dbg(inst->core->dev, "%s: no free slot\n", __func__);
+ return;
+ }
+
+ do_div(ts_us, NSEC_PER_USEC);
+
+ inst->tss[slot].used = true;
+ inst->tss[slot].flags = vbuf->flags;
+ inst->tss[slot].tc = vbuf->timecode;
+ inst->tss[slot].ts_us = ts_us;
+ inst->tss[slot].ts_ns = vb->timestamp;
+}
+
+void venus_helper_get_ts_metadata(struct venus_inst *inst, u64 timestamp_us,
+ struct vb2_v4l2_buffer *vbuf)
+{
+ struct vb2_buffer *vb = &vbuf->vb2_buf;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(inst->tss); ++i) {
+ if (!inst->tss[i].used)
+ continue;
+
+ if (inst->tss[i].ts_us != timestamp_us)
+ continue;
+
+ inst->tss[i].used = false;
+ vbuf->flags |= inst->tss[i].flags;
+ vbuf->timecode = inst->tss[i].tc;
+ vb->timestamp = inst->tss[i].ts_ns;
+ break;
+ }
+}
+EXPORT_SYMBOL(venus_helper_get_ts_metadata);
+
static int
session_process_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf)
{
@@ -487,6 +538,9 @@ session_process_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf)
if (vbuf->flags & V4L2_BUF_FLAG_LAST || !fdata.filled_len)
fdata.flags |= HFI_BUFFERFLAG_EOS;
+
+ if (inst->session_type == VIDC_SESSION_TYPE_DEC)
+ put_ts_metadata(inst, vbuf);
} else if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if (inst->session_type == VIDC_SESSION_TYPE_ENC)
fdata.buffer_type = HFI_BUFFER_OUTPUT;
diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
index f2e111555bd9..791c35c64ca3 100644
--- a/drivers/media/platform/qcom/venus/helpers.h
+++ b/drivers/media/platform/qcom/venus/helpers.h
@@ -63,4 +63,6 @@ int venus_helper_unregister_bufs(struct venus_inst *inst);
int venus_helper_load_scale_clocks(struct venus_core *core);
int venus_helper_process_initial_cap_bufs(struct venus_inst *inst);
int venus_helper_process_initial_out_bufs(struct venus_inst *inst);
+void venus_helper_get_ts_metadata(struct venus_inst *inst, u64 timestamp_us,
+ struct vb2_v4l2_buffer *vbuf);
#endif
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index 336d49132d19..0b7d65db5cdc 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -1135,6 +1135,8 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type,
vbuf->sequence = inst->sequence_out++;
}
+ venus_helper_get_ts_metadata(inst, timestamp_us, vbuf);
+
if (hfi_flags & HFI_BUFFERFLAG_READONLY)
venus_helper_acquire_buf_ref(vbuf);
--
2.17.1
next prev parent reply other threads:[~2019-06-28 13:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 12:59 [PATCH v2 00/11] Venus stateful Codec API Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 01/11] venus: venc: amend buffer size for bitstream plane Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 02/11] venus: helpers: export few helper functions Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 03/11] venus: hfi: add type argument to hfi flush function Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 04/11] venus: hfi: export few HFI functions Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 05/11] venus: hfi: return an error if session_init is already called Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 06/11] venus: helpers: add three more helper functions Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 07/11] venus: vdec_ctrls: get real minimum buffers for capture Stanimir Varbanov
2019-06-28 12:59 ` [PATCH v2 08/11] venus: vdec: allow bigger sizeimage set by clients Stanimir Varbanov
2019-06-28 13:00 ` [PATCH v2 09/11] venus: make decoder compliant with stateful codec API Stanimir Varbanov
2019-06-28 13:00 ` [PATCH v2 10/11] venus: helpers: handle correctly vbuf field Stanimir Varbanov
2019-06-28 13:00 ` Stanimir Varbanov [this message]
2019-06-28 13:37 ` [PATCH v2 00/11] Venus stateful Codec API Hans Verkuil
2019-06-28 14:23 ` Stanimir Varbanov
2019-06-28 14:25 ` Hans Verkuil
2019-06-28 14:31 ` Nicolas Dufresne
2019-06-28 14:32 ` Nicolas Dufresne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190628130002.24293-12-stanimir.varbanov@linaro.org \
--to=stanimir.varbanov@linaro.org \
--cc=acourbot@chromium.org \
--cc=hverkuil@xs4all.nl \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=tfiga@chromium.org \
--cc=vgarodia@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).