From patchwork Sun Dec 20 09:31:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 346268 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3611163jai; Sun, 20 Dec 2020 01:34:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTmLVT5cUFeYzHkheUAkkJjpHXYcn7Sc1lCe5TAO2cGLugXCWPO/U2+T8lkWit9imJ0JRT X-Received: by 2002:a17:906:e28c:: with SMTP id gg12mr11644329ejb.74.1608456898713; Sun, 20 Dec 2020 01:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608456898; cv=none; d=google.com; s=arc-20160816; b=IiOqHr0PeGB95QEw6CDDS6A7TlSq42+x9BgzrCS6jjdElutb9KDuwi8MqUS/MnXEjt Z+rTwbeU2Nx/A319z1zP33ce9F3DdQYpujs6wDxq3brsHwGFbki3rOT2KR2qCML4N7Wo Jw61kY+2tx8tlzwcOD5oTjXxl0p3kynDwyZAbvRqNUtUkd14Zu7QNoltcs1PYMz1xp+6 PFFMy1fmwKNjvFYAs1K9GZSmT3+gQVJJ7kDX+AmPnx+26X/FlhS3PbUCS3I2473HAzlF FqDcDnZrTbSgcdEq1rJVgskC40WQwU4XJH2auKYJAB3Zzz4vhGyTv5808qR0BAJfiVJu A21g== 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=Nj2lGSChog0xCnNmMClEPjFWH74N06BtrDvRd6GwI/GM4NIqa7srxLqMgpLc04acAI UQsLOaW0wvgMFK14Ac0YsASP4S98OAvaPsegO7f+XB4zXK8jkAdqTAFGiuhtvVZQQFNI cXYkYdhNqZPunYcUrr1cT8gTDBsmL2ywlvHcMQmmBvUR6mxF7w2APMQEfs0rwUxLJCM/ lW6dRRwkEQudpMyTZcppYjvKPutMyq5CtEL1g7VXgkIKuWmUT0jgcY/KSGXtk5b1rKAc oO3BNiwrH9ylsozw9d9yorFFQMY4G7yVOvHWtC9Y9N/eBX3BCAB71HTj84ADTbI6TdHc WSmA== 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-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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.58; Sun, 20 Dec 2020 01:34:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-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-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1727534AbgLTJeb (ORCPT + 15 others); Sun, 20 Dec 2020 04:34:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727514AbgLTJea (ORCPT ); Sun, 20 Dec 2020 04:34:30 -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 7ABD5C0611BB for ; Sun, 20 Dec 2020 01:32:58 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id g24so6746650edw.9 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=F1HGGxfCVMk9DrS2mtW3ifNybaP6RH5KiCNbjMN0e9PfQ/vUb6+pfjhF8j/xf3hCgB +4640qYvtimkU7Lu6t0LQzSav3T5BnqwesIyH5g9ekcsQU7skoj77t2ZmPgnLqoOa4TX yH6pQQJZy1UjRR4es+TSS+YH8sPMuakraV2YcbDq+Xpoc+B26u581v9xOupa6ILiyZaf ICeqWJGv4TX5U/wJW1yatwVmfedNGD7C5qrYGavcTSXfV/m2oU2T3QqlQOzUizxbuNfD yaAE1ZWHzewj280dxwofWojHjVnE9zVI4soRH5y5wsu7NuzbffYHg+qBCZRFAeZpUVrP k46g== X-Gm-Message-State: AOAM530kyghz2AEF73qp7iroHenKCPzTx6OckOSDSKP5E6DIeYRS8xWc CtV1+H2TqQrdBSYUoeqanEuOWQ== 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-arm-msm@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(-) -- 2.17.1 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: