From patchwork Sun Dec 20 09:31:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 346315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C511C3526D for ; Sun, 20 Dec 2020 09:34:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20BB623121 for ; Sun, 20 Dec 2020 09:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727410AbgLTJeP (ORCPT ); Sun, 20 Dec 2020 04:34:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727258AbgLTJeO (ORCPT ); Sun, 20 Dec 2020 04:34:14 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1DBAC061257 for ; Sun, 20 Dec 2020 01:32:51 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id h16so6740426edt.7 for ; Sun, 20 Dec 2020 01:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6aeKehIdQ3xcJ7hMUC4Ib4NuGjCL36W4Z1hVfxcOU/w=; b=AKMIpW0t/uOojgm3AC0fIqDChEHOQJp3IGk02LFscyCN8TyKCv6Gd/MwhcCsKfLSLA 4eY1vGAWnuBrPs0pHHeraBgoDBT6gy97vHve1DoV6Tkbid/C3qlD0Fevwh35Eb9k+0Vr L7Q2DDOUylBLELF+kDHhy32M/TlIhYpjl5uprRs7JazqJ2RtdzxZCIh3w/vs/3c1FzYu q3rnBdPyCZnV4lSZK7plEqKtppcDfdjd8BKc6ragOGBoqfVfAhwu5AHhw8XLDOKueT90 AcyoEnL6pOIyWRC/MB2jFtfLibw0e5Mu9diVYT7RExfPJ+h1S4Kedh/eV3/y1zXCujGs n4fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6aeKehIdQ3xcJ7hMUC4Ib4NuGjCL36W4Z1hVfxcOU/w=; b=hKuWwen2SK64Po7jSjiqwaGXdeKPV4Ugt7LUWtfjR0Qh3wiZdrhgDs4qsAbjB0i9O6 XcfxHENKSld7gq+y8qtMdz8Mw+2AhCHRGL8OHFIemWCil9TfV+a5TDr/zzZrcC+6lB0L FgjqRJ1Ud+5TeqLGRVuaET1P8KkUh1w4Vy2UUoSkcFN2z1/4xKNRtfWAhWzGUWd3gkvP C8uy6iiTmRw427s4Depu5MbmxL2hj1UUpqg4YYJ+Mm8Ckam2txiti72q+CqZcXK8NZZH sPOyXcKVQfTaPsWiBMk6KVtO9uVd6todeasx+z5FvbKJCjn1r1lVTU17AZRmEF8gJ0Ri XD7g== X-Gm-Message-State: AOAM5302xOVTwSbDyVTFhl+xIiOkPixl3usm8LtPK20TB6sEZRkW8XOG mBil78VJGJ+XqJuTCWLJ5jZU3wz4CxLlIsK3 X-Google-Smtp-Source: ABdhPJzzREjzhchYCHTThWuix1wKQGYXdzMrIEvGVcAySZtt6PpnMDYjf2ecxImdEjoXcSTTFmKk+Q== X-Received: by 2002:a05:6402:17cb:: with SMTP id s11mr11401957edy.119.1608456770484; Sun, 20 Dec 2020 01:32:50 -0800 (PST) Received: from localhost.localdomain (hst-221-118.medicom.bg. [84.238.221.118]) by smtp.gmail.com with ESMTPSA id z12sm7769814ejr.17.2020.12.20.01.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:50 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgarodia@codeaurora.org, acourbot@chromium.org, Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 1/5] venus: vdec: Fix non reliable setting of LAST flag Date: Sun, 20 Dec 2020 11:31:26 +0200 Message-Id: <20201220093130.10177-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201220093130.10177-1-stanimir.varbanov@linaro.org> References: <20201220093130.10177-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In real use of dynamic-resolution-change it is observed that the LAST buffer flag (which marks the last decoded buffer with the resolution before the resolution-change event) is not reliably set. Fix this by set the LAST buffer flag on next queued capture buffer after the resolution-change event. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 5 +-- drivers/media/platform/qcom/venus/helpers.c | 6 +++ drivers/media/platform/qcom/venus/vdec.c | 45 ++++++++++++--------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index f03ed427accd..db0e6738281e 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -285,7 +285,6 @@ enum venus_dec_state { VENUS_DEC_STATE_DRAIN = 5, VENUS_DEC_STATE_DECODING = 6, VENUS_DEC_STATE_DRC = 7, - VENUS_DEC_STATE_DRC_FLUSH_DONE = 8, }; struct venus_ts_metadata { @@ -350,7 +349,7 @@ struct venus_ts_metadata { * @priv: a private for HFI operations callbacks * @session_type: the type of the session (decoder or encoder) * @hprop: a union used as a holder by get property - * @last_buf: last capture buffer for dynamic-resoluton-change + * @next_buf_last: a flag to mark next queued capture buffer as last */ struct venus_inst { struct list_head list; @@ -413,7 +412,7 @@ struct venus_inst { union hfi_get_property hprop; unsigned int core_acquired: 1; unsigned int bit_depth; - struct vb2_buffer *last_buf; + bool next_buf_last; }; #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 50439eb1ffea..5ca3920237c5 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1347,6 +1347,12 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) v4l2_m2m_buf_queue(m2m_ctx, vbuf); + /* Skip processing queued capture buffers after LAST flag */ + if (inst->session_type == VIDC_SESSION_TYPE_DEC && + V4L2_TYPE_IS_CAPTURE(vb->vb2_queue->type) && + inst->codec_state == VENUS_DEC_STATE_DRC) + goto unlock; + cache_payload(inst, vb); if (inst->session_type == VIDC_SESSION_TYPE_ENC && diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 8488411204c3..eb94e167e282 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -917,10 +917,6 @@ static int vdec_start_capture(struct venus_inst *inst) return 0; reconfigure: - ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, true); - if (ret) - return ret; - ret = vdec_output_conf(inst); if (ret) return ret; @@ -948,6 +944,8 @@ static int vdec_start_capture(struct venus_inst *inst) venus_pm_load_scale(inst); + inst->next_buf_last = false; + ret = hfi_session_continue(inst); if (ret) goto free_dpb_bufs; @@ -988,6 +986,7 @@ static int vdec_start_output(struct venus_inst *inst) venus_helper_init_instance(inst); inst->sequence_out = 0; inst->reconfig = false; + inst->next_buf_last = false; ret = vdec_set_properties(inst); if (ret) @@ -1081,9 +1080,7 @@ static int vdec_stop_capture(struct venus_inst *inst) inst->codec_state = VENUS_DEC_STATE_STOPPED; break; case VENUS_DEC_STATE_DRC: - WARN_ON(1); - fallthrough; - case VENUS_DEC_STATE_DRC_FLUSH_DONE: + ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, true); inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; venus_helper_free_dpb_bufs(inst); break; @@ -1207,9 +1204,28 @@ static void vdec_buf_cleanup(struct vb2_buffer *vb) static void vdec_vb2_buf_queue(struct vb2_buffer *vb) { struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + static const struct v4l2_event eos = { .type = V4L2_EVENT_EOS }; vdec_pm_get_put(inst); + mutex_lock(&inst->lock); + + if (inst->next_buf_last && V4L2_TYPE_IS_CAPTURE(vb->vb2_queue->type) && + inst->codec_state == VENUS_DEC_STATE_DRC) { + vbuf->flags |= V4L2_BUF_FLAG_LAST; + vbuf->sequence = inst->sequence_cap++; + vbuf->field = V4L2_FIELD_NONE; + vb2_set_plane_payload(vb, 0, 0); + v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); + v4l2_event_queue_fh(&inst->fh, &eos); + inst->next_buf_last = false; + mutex_unlock(&inst->lock); + return; + } + + mutex_unlock(&inst->lock); + venus_helper_vb2_buf_queue(vb); } @@ -1253,13 +1269,6 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, vb->timestamp = timestamp_us * NSEC_PER_USEC; vbuf->sequence = inst->sequence_cap++; - if (inst->last_buf == vb) { - inst->last_buf = NULL; - vbuf->flags |= V4L2_BUF_FLAG_LAST; - vb2_set_plane_payload(vb, 0, 0); - vb->timestamp = 0; - } - if (vbuf->flags & V4L2_BUF_FLAG_LAST) { const struct v4l2_event ev = { .type = V4L2_EVENT_EOS }; @@ -1359,12 +1368,9 @@ static void vdec_event_change(struct venus_inst *inst, */ if (!sufficient && inst->codec_state == VENUS_DEC_STATE_DRC) { - struct vb2_v4l2_buffer *last; int ret; - last = v4l2_m2m_last_dst_buf(inst->m2m_ctx); - if (last) - inst->last_buf = &last->vb2_buf; + inst->next_buf_last = true; ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, false); if (ret) @@ -1413,8 +1419,7 @@ static void vdec_event_notify(struct venus_inst *inst, u32 event, static void vdec_flush_done(struct venus_inst *inst) { - if (inst->codec_state == VENUS_DEC_STATE_DRC) - inst->codec_state = VENUS_DEC_STATE_DRC_FLUSH_DONE; + dev_dbg(inst->core->dev_dec, VDBGH "flush done\n"); } static const struct hfi_inst_ops vdec_hfi_ops = { From patchwork Sun Dec 20 09:31:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 346265 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3611121jai; Sun, 20 Dec 2020 01:34:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMSernwuX0rWTSFi8FXNg6eacTYcQYGEKgLCZznnTb8Uyh3d0jzw01vK6N4k0hRoIOGTng X-Received: by 2002:a05:6402:318f:: with SMTP id di15mr11757927edb.237.1608456894920; Sun, 20 Dec 2020 01:34:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608456894; cv=none; d=google.com; s=arc-20160816; b=PnmO4cY4GZAw750dISjtinShLZRL3Wdsaffs6widNBgd/OOXFb6p1c+RQXOurUB5pW 6+yXgGaZhfJkBUKu8pqLwyUbucVLwh9FE9O4tjeyP1VE8ON/lkVnNWKj3iBRDLjNRjLo aPWUcpPjUnL+vRvF7Qru1XOCvvGOH28XNoLzVUvWCyBRmwZDizA6FjNXVoKAGN4zc5Vk 7Kkm0vlnVJDhtIGaiEqJiQpKckdczZXiJNc0MMSEqf7pDy89ySKoWwQMnBF+4yzF+4Ql qgNi9+dMkQhlSnCdEy1wjP9kNsf/I//jVm8F0YEWk4q4KYCMpfI4QeenaWh2mnoRqFNB BjaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=DEs1jlqfRpmRp1QgU14zLhiXveVi1mzRfOntspJCdks=; b=dirQwfea1m70fo4rgbPEKl5tg8y1rqqXpmfMguSk6pj/MtXSsZ1PXUkJU6sDYfOXbW eINhOxpmKBsE+yPzgcOXDUoXE3nb5rEmqnXfCDI/9BE5fnSlTLmnlxjhhqeCWUOoE+yn 9ZGQygugN4xF8fbKRzqX4RI7dxK76F8wXFhhB+PMWyFkE0ElgpjedLnopCov46nTfm4E 1QVRNJFocUA54xaWxWRpFjP5gD5QSKruQ99EgjZfMSnHrEf5NrsYmYIrbxEMO7T5chu3 MKRzeYYGVE4B2yr0qB+LHQ7AyVOpXrU0Ib+oEl7e0SvwEYXEYqKOFEfV19IJz8G6KkYl bTnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=orl0kZnm; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg19si7151815ejc.365.2020.12.20.01.34.54; Sun, 20 Dec 2020 01:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=orl0kZnm; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727429AbgLTJeQ (ORCPT + 4 others); Sun, 20 Dec 2020 04:34:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727377AbgLTJeO (ORCPT ); Sun, 20 Dec 2020 04:34:14 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6CBC0611CB for ; Sun, 20 Dec 2020 01:32:53 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id cm17so6763204edb.4 for ; Sun, 20 Dec 2020 01:32:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DEs1jlqfRpmRp1QgU14zLhiXveVi1mzRfOntspJCdks=; b=orl0kZnme9l+fSwfq5e9A2EEgrbjubKmvQbOTNY8CScosT9Xk5vgZWmBaHn1kkj5my 9xFP52PSre+xRstUWHc7lghm5waUTIV+WnKSO7SoICuRuzYMHl5K316J3LNsCiY54wLU sZ7xd/0C0yVaZyEYVpBmNlsAuM4xF5SdwXY4GOdUHi1jzHB+W7V9TAhIZXeyzSb8SmG5 vhM2Kix9934u3reP40/XW70vqV8/226ex5Wg/ElA6WBrCiJqHPZ+4OMlkspgnN9HbOP4 JppWLFoek7j7nulrzeZhm9FkGLAZZpAIXmZZ54DP3FZ17YTJJ0Y9QGk3Or/8K93jVGFG F3OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DEs1jlqfRpmRp1QgU14zLhiXveVi1mzRfOntspJCdks=; b=GemXLE8suX5xoJurczeIvuvs/NzN/RPYk7V2TbbjPm25xQ8pJuXhnZenffh8bwcemN 55GcvDLRimu/IbbC25Oxs5aDETj9x286UIplhMIss+78LKIrna0d/NfEFpkwCiLxXDOr Z0NxghU2nQgluZVHBhSkfJ8dUUBuvHiIoO61D+ctZgR7HUf4uMV2dkV33i0Vj09Fs062 xHHS8JIMG+NRGyXV0n9qzpImZQM+78KrPEakOL9a4qM3n5+In2cU3e22IHbHtKmRo4qt nZYhd+ErIyIloC/m6yy6mmHJ5puQ7pHRknjZgOPq57BnQytQ/stUdCbMKuSaJXUciClH GzXg== X-Gm-Message-State: AOAM530WFqaV33Vdu80m2Z2POVgwTgXZ7yVeQYcbu/xhVvGQ0UUhU/f2 VEVoeMjnpKxYuqQpUHi8Hlh1TfKY6xjOPnCu X-Received: by 2002:aa7:cac2:: with SMTP id l2mr11618071edt.141.1608456772331; Sun, 20 Dec 2020 01:32:52 -0800 (PST) Received: from localhost.localdomain (hst-221-118.medicom.bg. [84.238.221.118]) by smtp.gmail.com with ESMTPSA id z12sm7769814ejr.17.2020.12.20.01.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:51 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgarodia@codeaurora.org, acourbot@chromium.org, Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 2/5] venus: vdec: Make decoder return LAST flag for sufficient event Date: Sun, 20 Dec 2020 11:31:27 +0200 Message-Id: <20201220093130.10177-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201220093130.10177-1-stanimir.varbanov@linaro.org> References: <20201220093130.10177-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This makes the decoder to behaives equally for sufficient and insufficient events. After this change the LAST buffer flag will be set when the new resolution (in dynamic-resolution-change state) is smaller then the old bitstream resolution. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 41 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index eb94e167e282..4ce23c2fc6eb 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -637,6 +637,7 @@ static int vdec_output_conf(struct venus_inst *inst) { struct venus_core *core = inst->core; struct hfi_enable en = { .enable = 1 }; + struct hfi_buffer_requirements bufreq; u32 width = inst->out_width; u32 height = inst->out_height; u32 out_fmt, out2_fmt; @@ -712,6 +713,22 @@ static int vdec_output_conf(struct venus_inst *inst) } if (IS_V3(core) || IS_V4(core)) { + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); + if (ret) + return ret; + + if (bufreq.size > inst->output_buf_size) + return -EINVAL; + + if (inst->dpb_fmt) { + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT2, &bufreq); + if (ret) + return ret; + + if (bufreq.size > inst->output2_buf_size) + return -EINVAL; + } + if (inst->output2_buf_size) { ret = venus_helper_set_bufsize(inst, inst->output2_buf_size, @@ -1346,19 +1363,15 @@ static void vdec_event_change(struct venus_inst *inst, dev_dbg(dev, VDBGM "event %s sufficient resources (%ux%u)\n", sufficient ? "" : "not", ev_data->width, ev_data->height); - if (sufficient) { - hfi_session_continue(inst); - } else { - switch (inst->codec_state) { - case VENUS_DEC_STATE_INIT: - inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; - break; - case VENUS_DEC_STATE_DECODING: - inst->codec_state = VENUS_DEC_STATE_DRC; - break; - default: - break; - } + switch (inst->codec_state) { + case VENUS_DEC_STATE_INIT: + inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; + break; + case VENUS_DEC_STATE_DECODING: + inst->codec_state = VENUS_DEC_STATE_DRC; + break; + default: + break; } /* @@ -1367,7 +1380,7 @@ static void vdec_event_change(struct venus_inst *inst, * itself doesn't mark the last decoder output buffer with HFI EOS flag. */ - if (!sufficient && inst->codec_state == VENUS_DEC_STATE_DRC) { + if (inst->codec_state == VENUS_DEC_STATE_DRC) { int ret; inst->next_buf_last = true; From patchwork Sun Dec 20 09:31:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 346267 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3611140jai; Sun, 20 Dec 2020 01:34:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyF8maNL7M4Sik06EycWYhH/pKiE5zdE9O6QCfcoGVOeWjOoODVSnQc92VifXmU/OTqL/2S X-Received: by 2002:a05:6402:14c5:: with SMTP id f5mr11565822edx.232.1608456896530; Sun, 20 Dec 2020 01:34:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608456896; cv=none; d=google.com; s=arc-20160816; b=mnRgOuVH48tSyGCYYz8z+kqJSJ6oqn8iWbr4Kjrq5fpyuo6lkTUBMY8uqVAdtiuFCp BDe6e0D1VXdNb9+rdBnW8gQzgPwAs3ytzTusFhYy/QjKmPm6sS6fdqSl6hzMzC4jMNIt +Z9qEZrNFk3XNbY6H1kD34saTdUWOlPlf0G0S3EY6dMkdslwuh58kFKYKSgbgZF5tNlH ioirlCHcaa9xDydyE1NhNsw1w/hPOB7hR2GqYW4waK74l7d3MfDpUTY8YahrJh1wHqoq eA3OMcjpuAv6FE6puKZnVHOFGgGtDXZqMbPebeK/UAD0WbsT5r6zDP331BvLOKmyMKVW PL5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=xJWHNxMCkDCEyrMRNKllf8ulu4dBqb0sn+GPkcIS48k=; b=ji0C9SYaAgmzk5RZGm3BveOH+tOUOcOj9q2/OZSPX7jr3sxX+r1e14gA9xCGozS9pw pcKSPGFQx715y8cOk7kwqvFx5hU36enyrPd9w5iZre3cNKylrbkOK/08z5ThVKjsxd7+ BsrxcNpyJb47YXE/c4AfQqf1/jDbMxNX3hcvERVFUDCHZWx2ff7/92ZT4SzzASRFRIRs 3GqUXMj8NW/QPb9OE7YYuWDa0OvG9zHoaavErZrL7+JoYgCIKraKqKyU5RGWqx2aUmcZ MkBvjXSx8wKjXslaHuFUyTNDCFXrlHXoLJBRrPPdf2RrFEs0KbYXSoMm4XQO4Osho5Ca yaxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F4B8GnMt; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg19si7151815ejc.365.2020.12.20.01.34.56; Sun, 20 Dec 2020 01:34:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F4B8GnMt; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727444AbgLTJeV (ORCPT + 4 others); Sun, 20 Dec 2020 04:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727391AbgLTJeP (ORCPT ); Sun, 20 Dec 2020 04:34:15 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E05C0611CE for ; Sun, 20 Dec 2020 01:32:55 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id p22so6714969edu.11 for ; Sun, 20 Dec 2020 01:32:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xJWHNxMCkDCEyrMRNKllf8ulu4dBqb0sn+GPkcIS48k=; b=F4B8GnMtgYPmuWkyGKdO+mCwavMP7yX8XX8leC8vRBx6ryHCxdwHnB5xhAa8IGmsrw 1wKmH2uyBlf86AIAwJANVDnEe/4XF9IH6vcJ97OjaSVc8uvR/DujyaytMaUYiupB0K16 MqDdLk+qZmpj81I7IWzUz6AWPEgNvfWeyfl/+ZkSzG2WMMLVbvO0KXlA2Aueh+CVpV0m unsIJUixZU7n75wbXhtGnwhl33pcyYNa2m3lu3fbdBwrRZybM5J/lxUGDGDHSJx21KQJ NoD4q4Nj5YhHpGh40Hlc3OmSIgG6qJNkfeZAXUgJp+Fvl+L39n+y8LMDw3ws/Q8derws 8MMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xJWHNxMCkDCEyrMRNKllf8ulu4dBqb0sn+GPkcIS48k=; b=ROS1/7QTYQxqVwQciB1++fRVm9LGXtI5+2sdoNFpcmjmI16TFyJH7dgNEAYXnzgpph yeA4nH0/5lZtErfeNKe2b1iA5dRKW66htcY4oV+n6jGFFzzUQHVO7FfNJAEbuv2I6oBz XhRujU1x7YHrmADVF3Ghy/1Psfz0Zq2+5cQMrXrj0n0Vv76edDdyQChk8hLsvDaUkKUl oUiB4E5zdJHlR7dUZTME0unvoi+sW/6h8kG4WlUrB7AJCENcPTUfYsQrAd5n6icooHkd tsqNc6g1Zv0EnuvZHbgEV+bRWHuMVWB7DG8Myr/jMZUlO31oOb9SE7Mxx7s7ZXNX2Exn L9ig== X-Gm-Message-State: AOAM533PjOX49FZVRdtYDFfQZno+fjmez4wwUZchMPYwxCYf2lP3kN25 k4ZQTOp32KxtyzljPZrc9Jx2WmBnDEOF9TkJ X-Received: by 2002:a05:6402:491:: with SMTP id k17mr6139719edv.342.1608456774044; Sun, 20 Dec 2020 01:32:54 -0800 (PST) Received: from localhost.localdomain (hst-221-118.medicom.bg. [84.238.221.118]) by smtp.gmail.com with ESMTPSA id z12sm7769814ejr.17.2020.12.20.01.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:53 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgarodia@codeaurora.org, acourbot@chromium.org, Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 3/5] venus: helpers: Lock outside of buffer queue helper Date: Sun, 20 Dec 2020 11:31:28 +0200 Message-Id: <20201220093130.10177-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201220093130.10177-1-stanimir.varbanov@linaro.org> References: <20201220093130.10177-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org After adding more logic in vdec buf_queue vb2 op it is not practical to have two lock/unlock for one decoder buf_queue. So move the instance lock in encoder and decoder vb2 buf_queue operations. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 11 +++-------- drivers/media/platform/qcom/venus/vdec.c | 3 +-- drivers/media/platform/qcom/venus/venc.c | 11 ++++++++++- 3 files changed, 14 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 5ca3920237c5..2b6925b6c274 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1343,34 +1343,29 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; int ret; - mutex_lock(&inst->lock); - v4l2_m2m_buf_queue(m2m_ctx, vbuf); /* Skip processing queued capture buffers after LAST flag */ if (inst->session_type == VIDC_SESSION_TYPE_DEC && V4L2_TYPE_IS_CAPTURE(vb->vb2_queue->type) && inst->codec_state == VENUS_DEC_STATE_DRC) - goto unlock; + return; cache_payload(inst, vb); if (inst->session_type == VIDC_SESSION_TYPE_ENC && !(inst->streamon_out && inst->streamon_cap)) - goto unlock; + return; if (vb2_start_streaming_called(vb->vb2_queue)) { ret = is_buf_refed(inst, vbuf); if (ret) - goto unlock; + return; ret = session_process_buf(inst, vbuf); if (ret) return_buf_error(inst, vbuf); } - -unlock: - mutex_unlock(&inst->lock); } EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue); diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 4ce23c2fc6eb..9f2c7b3e7d4c 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1241,9 +1241,8 @@ static void vdec_vb2_buf_queue(struct vb2_buffer *vb) return; } - mutex_unlock(&inst->lock); - venus_helper_vb2_buf_queue(vb); + mutex_unlock(&inst->lock); } static const struct vb2_ops vdec_vb2_ops = { diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 1c61602c5de1..4ecf78e30b59 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -929,13 +929,22 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) return ret; } +static void venc_vb2_buf_queue(struct vb2_buffer *vb) +{ + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + + mutex_lock(&inst->lock); + venus_helper_vb2_buf_queue(vb); + mutex_unlock(&inst->lock); +} + static const struct vb2_ops venc_vb2_ops = { .queue_setup = venc_queue_setup, .buf_init = venus_helper_vb2_buf_init, .buf_prepare = venus_helper_vb2_buf_prepare, .start_streaming = venc_start_streaming, .stop_streaming = venus_helper_vb2_stop_streaming, - .buf_queue = venus_helper_vb2_buf_queue, + .buf_queue = venc_vb2_buf_queue, }; static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, From patchwork Sun Dec 20 09:31:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 346266 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3611124jai; Sun, 20 Dec 2020 01:34:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzN7Ld6rKIlzGXb2KgEhwxW/OdWm8w4wj/2Dp1KdY0pY9r5jpNM8nIYHsIi6W7wMH5In5F4 X-Received: by 2002:aa7:d7d2:: with SMTP id e18mr11894921eds.256.1608456895324; Sun, 20 Dec 2020 01:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608456895; cv=none; d=google.com; s=arc-20160816; b=juivlgeZdJ6ZlboVStHTPMntLs0AMJXMbx1ekIw79UDacPuLZIDoCiFGBU8yocnkTm GSOX+eUW38YlWEMS6Aw+C6QhgeCrZ9OeTXsvnwDy5glQY0nIkqWH3abiR/rHVZsg5Laa TzNpWLGDkgBv1HZC/HDQR48ELO2bD22YeOPFghiexdFJ2WAA3Y6/L1SHpKA01v0ODHXt 1PRqvlwE9kxvYb7HpFtExs0/9Cyn6x1FumOGbF1P+0c9YavwQVXg5UibEGlvzGzoBcpB XJ0k3jDSXcti7jnOhqmtQyLCR0AM51a5xndK3Cx/YPrWT/58PHRG5fqYgo/PfrtMxcQ5 9UAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=flHi69N3bIoMbwYxkKr1cV0kS4hH3i/8NcXPvU/7pKU=; b=vYzNp2IvHWy25gi1d530VfXd8kuRWxdEHwk+HcQrhgjAWK10r8klstm1kSDcc3+qMn GLRLLmxXTUcIdW/8Iu1eh971PbRQ31yHOf1oEfwi6/xST187u9zRbQSmko9lqL+0r4zI SnLaS/Rsh4n359KBtrfGnF6NojC1PkRXn08n5WCo7JAlwuSAhxoEyJ8VtER7j0rBrQmd KL3lBkRmHM38dRkt8eGuDnz1T3NGURQgbxHT5e/2cNg1malOKSdlodfGlogeouYKs1a3 kJ3T393yMotgmlPYE/o12uJQHjb8aMl26WmFVbe68ZNtzZVVzRNjSgWPcuNWZIWiTFfX UUbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1sYNLjL; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg19si7151815ejc.365.2020.12.20.01.34.55; Sun, 20 Dec 2020 01:34:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1sYNLjL; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727439AbgLTJeS (ORCPT + 4 others); Sun, 20 Dec 2020 04:34:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727418AbgLTJeQ (ORCPT ); Sun, 20 Dec 2020 04:34:16 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1562EC0611E4 for ; Sun, 20 Dec 2020 01:32:57 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id i24so6746757edj.8 for ; Sun, 20 Dec 2020 01:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=flHi69N3bIoMbwYxkKr1cV0kS4hH3i/8NcXPvU/7pKU=; b=f1sYNLjLN1NrdLn3Tep0+1IOr4uhU/P8+ZNbmSQnTym4qb3SaU5ZP/utbB58d0Akar e01qnrKcuBI3z0RUxBQILcHaLAXSryj6b5cKHkqk7N+G4h69Wd7Akquz3pOzUm+2UyLe SmXzrAs6bi/9lUrZf/IpC1dsMLw3K6jBQBcpXA8Ae3ndiDcGGmhDtxTnizvIpJ4JRcrd qQFH9YA8DXncWd4pcIbns95PV6klwqTr9bdFKb9gQ01cRW2urKRIJrczDXybIXF1ZISe d9Nmm1yMWbsTGTxEniqzW6QrRw3uJSOHchPKDNXyWaAB28TTI1Sf/u+IBOYL46tXzxMv jvJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=flHi69N3bIoMbwYxkKr1cV0kS4hH3i/8NcXPvU/7pKU=; b=I8GMASbu92X1rMP6r9mt4S8i/P1MC+HQEx3Lc/i8XpyH9+urz5/fnZgSNpYZm28TFk uat5vPG12AadpRyRhC3E/6v2wkvLUlkxb5tUD5Ie7WBFBktwXfNvd7NAJWrzuO3PBhi4 j1MWDQPYFmxzt9IirnxtbvL+phROt8Ne58+BSXhXftSWi+uNgZG92KO5RRQgfGClsUrJ YmSHvfuTkhOaFkABucgje7mxBQ3xzndtiZPg1b2vP3DJTOKda3eoJ/6PBTjrw4VCM3il h1Eu7a1+IEwo+HONrD8H+kYAo0p8gjloMLs0MeaVxxJ/CBVXTbIGGAOvNka5V7shoJVr Lg0g== X-Gm-Message-State: AOAM532naVwxSrnEwNP2pC4Ph3fTNv12N/gG5+nHMiCo4e2/qF6HykDt NOlrapsJokMv5HjS5fXAQ0CdZIHl0GXzTlJB X-Received: by 2002:a05:6402:3192:: with SMTP id di18mr11659143edb.332.1608456775650; Sun, 20 Dec 2020 01:32:55 -0800 (PST) Received: from localhost.localdomain (hst-221-118.medicom.bg. [84.238.221.118]) by smtp.gmail.com with ESMTPSA id z12sm7769814ejr.17.2020.12.20.01.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:55 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgarodia@codeaurora.org, acourbot@chromium.org, Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 4/5] media: venus: preserve DRC state across seeks Date: Sun, 20 Dec 2020 11:31:29 +0200 Message-Id: <20201220093130.10177-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201220093130.10177-1-stanimir.varbanov@linaro.org> References: <20201220093130.10177-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Alexandre Courbot DRC events can happen virtually at anytime, including when we are starting a seek. Should this happen, we must make sure to return to the DRC state, otherwise the firmware will expect buffers of the new resolution whereas userspace will still work with the old one. Returning to the DRC state upon resume for seeking makes sure that the client will get the DRC event and will reallocate the buffers to fit the firmware's expectations. Signed-off-by: Alexandre Courbot Signed-off-by: Stanimir Varbanov --- No changes since v1. drivers/media/platform/qcom/venus/vdec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 9f2c7b3e7d4c..d27f4fd0ca01 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -987,7 +987,10 @@ static int vdec_start_output(struct venus_inst *inst) if (inst->codec_state == VENUS_DEC_STATE_SEEK) { ret = venus_helper_process_initial_out_bufs(inst); - inst->codec_state = VENUS_DEC_STATE_DECODING; + if (inst->next_buf_last) + inst->codec_state = VENUS_DEC_STATE_DRC; + else + inst->codec_state = VENUS_DEC_STATE_DECODING; goto done; } @@ -1093,8 +1096,10 @@ static int vdec_stop_capture(struct venus_inst *inst) ret = hfi_session_flush(inst, HFI_FLUSH_ALL, true); fallthrough; case VENUS_DEC_STATE_DRAIN: - vdec_cancel_dst_buffers(inst); inst->codec_state = VENUS_DEC_STATE_STOPPED; + fallthrough; + case VENUS_DEC_STATE_SEEK: + vdec_cancel_dst_buffers(inst); break; case VENUS_DEC_STATE_DRC: ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, true); @@ -1116,6 +1121,7 @@ static int vdec_stop_output(struct venus_inst *inst) case VENUS_DEC_STATE_DECODING: case VENUS_DEC_STATE_DRAIN: case VENUS_DEC_STATE_STOPPED: + case VENUS_DEC_STATE_DRC: ret = hfi_session_flush(inst, HFI_FLUSH_ALL, true); inst->codec_state = VENUS_DEC_STATE_SEEK; break; @@ -1389,6 +1395,7 @@ static void vdec_event_change(struct venus_inst *inst, dev_dbg(dev, VDBGH "flush output error %d\n", ret); } + inst->next_buf_last = true; inst->reconfig = true; v4l2_event_queue_fh(&inst->fh, &ev); wake_up(&inst->reconf_wait);