Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3404823pxu; Sun, 20 Dec 2020 01:37:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzzyIBE1zHWAO3D/5iQE30bOxenWq15bLgRQwzdIT0SrLiUEqvmp8CIuVhBcuI69i2nYmz X-Received: by 2002:a17:906:1741:: with SMTP id d1mr833390eje.182.1608457051316; Sun, 20 Dec 2020 01:37:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608457051; cv=none; d=google.com; s=arc-20160816; b=TPveBjKXGdgyetJHsN/lYhJYFANiKXebNI9X3QlJ8mIo06jAfQB/UH9lEl9wFLim3g IQaaSPXQ7/vUtyFMhyBWsPNukTGbJCe+k4+/vPRn0RWqDx54z4wzc02RH1J5Z4hjlNwG IQ2KJu+kl8JuQEXoRV0xxTsga43//YHAAJexOyKQl2/o9waYQLtJdP+dg7jND2ZaCFk7 dlRjjSjaugNywZYz+WY/30gIixB0r6lUCfTbjlSMrPugYOEW7TBSMTKW7Qxf3hGiwy4Q vU5mJHmtkbtMQGOpjzJN8jLvLb/Y9xwSK2TV7liyMwuBhn3jSFlVEV+7X0toGtDcITKy vL/g== 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=FN/bEnipr2y9sCYb7N5bkHhgN7bbMj0oywhCqcGevOA=; b=r0u2dRJOFdkPSPn/q+TWPnl+S2/63H6bF0b4tiAB0O0rSrNqKjDOADX74x1XETGcUW RCCj9fQv7sjPaoGhsE1d8uvcUseWUWLECwclap+zZ++gwpZ3j6eMIIcVUkLXIcvhgM7G VUUFaoIV5565dMcBe9E2U9v51ILnHlID/YEpaTp0WuuICl3GcgDFU8szTv5w2iYL9Bw2 q6bXInZd3lyw0QBPV8QFeVPEZ54MamBaIOxRGro1T3QC2ZAaxnoCZQaKy+ST7CBqTlZO yN1j99xrhsVarqQ+46HFqNF+ZYxyKTQfAM31YpXCVuEDGhagkvXChTVZ5cUHEoYwxvv0 rpLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v8peECqP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 k10si9234360eds.206.2020.12.20.01.37.09; Sun, 20 Dec 2020 01:37:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=v8peECqP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727557AbgLTJe4 (ORCPT + 99 others); Sun, 20 Dec 2020 04:34:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727519AbgLTJez (ORCPT ); Sun, 20 Dec 2020 04:34:55 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C090C0619D2 for ; Sun, 20 Dec 2020 01:32:58 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id i24so6746783edj.8 for ; Sun, 20 Dec 2020 01:32:58 -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=FN/bEnipr2y9sCYb7N5bkHhgN7bbMj0oywhCqcGevOA=; b=v8peECqPJNg/N1Yfh3YW+bJ2bILnI7awKKkhkrReWPnl/5fCBwvh+TNnZL67PVh4Kn XSAEFs4KQysDNHgmyqYGHyUw9GcCBRNi1aPsjDTCeVlZATkgeAjb+lT79oiyCzXQ/9cR xscBUogVFwPiyRmtTZVALTDMzdaDCcOASaVV16cYXs0Sev/lOcwrihNeYZz0iM6rlqMv bQdRfPQBffPJG8gSggx//jcGxC7PYp65g0iXUT5Uf6/wINmN4ZbWmA3a4eXu+qPI8nbT DfY0pWzvnr0zzb05kzuox4X9DfH5M7uCS7OBQf3tn+Sn1PPAhi/TBPLK/G0bft3s7/JR rdjQ== 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=FN/bEnipr2y9sCYb7N5bkHhgN7bbMj0oywhCqcGevOA=; b=c4PgLwZqYoIFAl39OxhkDoBjoIusApPdmk2wLLHDpXKvwnouFYTBOLxv3M10okHXiO JHnS34M6letYbRZxQ1mOFWwj63pQR/+tTAUv/jX+Coqg3q/UZAR9SzuaTRFPtUmJf6y/ XoKcFLVqJ3jmqq8bkqrt3WKNsUXFlRHJeuCBW/BLkmpx4zf/teq/QTZ5cJMzAK0BHT5S ssSPHosgoRipIlh3qW5KBKZHnBJrPLtRXAk2yAomD9BqyUJwWMRFKJsKb7FgZwbx8Rfh Gqtsx7x56vYzDcPAMQ7pDq10j9Anq+VFOO73o5vsUwZEnC8dtG1+TNeURN50aqLo5gXp H8Vw== X-Gm-Message-State: AOAM530d6C8SD+6/RvXg5izLgR3rj6ykDvPyaA/yei7jduo4uWZEFOfp TR9dvhaO7t+eUxFaQcQYynLqXA== X-Received: by 2002:a05:6402:2292:: with SMTP id cw18mr11885156edb.336.1608456777231; Sun, 20 Dec 2020 01:32:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:56 -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 5/5] venus: vdec: Handle DRC after drain Date: Sun, 20 Dec 2020 11:31:30 +0200 Message-Id: <20201220093130.10177-6-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-kernel@vger.kernel.org From: Fritz Koenig If the DRC is near the end of the stream the client may send a V4L2_DEC_CMD_STOP before the DRC occurs. V4L2_DEC_CMD_STOP puts the driver into the VENUS_DEC_STATE_DRAIN state. DRC must be aware so that after the DRC event the state can be restored correctly. Signed-off-by: Fritz Koenig Signed-off-by: Stanimir Varbanov --- Changes since v2 (from Fritz): - moved state transition from vdec_event_notify to vdec_event_change. drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/vdec.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index db0e6738281e..765ab7ed881b 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -413,6 +413,7 @@ struct venus_inst { unsigned int core_acquired: 1; unsigned int bit_depth; bool next_buf_last; + bool drain_active; }; #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index d27f4fd0ca01..6cc35ffe2d6e 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -519,8 +519,10 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) ret = hfi_session_process_buf(inst, &fdata); - if (!ret && inst->codec_state == VENUS_DEC_STATE_DECODING) + if (!ret && inst->codec_state == VENUS_DEC_STATE_DECODING) { inst->codec_state = VENUS_DEC_STATE_DRAIN; + inst->drain_active = true; + } } unlock: @@ -969,9 +971,13 @@ static int vdec_start_capture(struct venus_inst *inst) inst->codec_state = VENUS_DEC_STATE_DECODING; + if (inst->drain_active) + inst->codec_state = VENUS_DEC_STATE_DRAIN; + inst->streamon_cap = 1; inst->sequence_cap = 0; inst->reconfig = false; + inst->drain_active = false; return 0; @@ -1097,6 +1103,7 @@ static int vdec_stop_capture(struct venus_inst *inst) fallthrough; case VENUS_DEC_STATE_DRAIN: inst->codec_state = VENUS_DEC_STATE_STOPPED; + inst->drain_active = false; fallthrough; case VENUS_DEC_STATE_SEEK: vdec_cancel_dst_buffers(inst); @@ -1296,8 +1303,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, v4l2_event_queue_fh(&inst->fh, &ev); - if (inst->codec_state == VENUS_DEC_STATE_DRAIN) + if (inst->codec_state == VENUS_DEC_STATE_DRAIN) { + inst->drain_active = false; inst->codec_state = VENUS_DEC_STATE_STOPPED; + } } if (!bytesused) @@ -1373,6 +1382,7 @@ static void vdec_event_change(struct venus_inst *inst, inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; break; case VENUS_DEC_STATE_DECODING: + case VENUS_DEC_STATE_DRAIN: inst->codec_state = VENUS_DEC_STATE_DRC; break; default: -- 2.17.1