From patchwork Wed Nov 11 14:37:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 323297 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 0770DC5517A for ; Wed, 11 Nov 2020 14:40:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A217207BB for ; Wed, 11 Nov 2020 14:40:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RlEFTHP8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727308AbgKKOkZ (ORCPT ); Wed, 11 Nov 2020 09:40:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgKKOic (ORCPT ); Wed, 11 Nov 2020 09:38:32 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3A0C061A04 for ; Wed, 11 Nov 2020 06:38:25 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id 33so2748083wrl.7 for ; Wed, 11 Nov 2020 06:38:25 -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=0wZVM3xTH0rIlT8FcnVb9p0qtohia4y51yWQ3iwO6GE=; b=RlEFTHP8vmaXYUOiuFwsUx3f5yXYa4g1nViurvjIWCCsjb5FcrTms+0V4N/40jOC3e E8h2ZGscS5N5sLWUzfPCDdbCgfKIZ9uGbS+JMjA/ekvNSYu/77CAUSx+VtEJUnMm7l7+ 9hbZdB27+ZpQID+qEcIAaue0h5c5dL4cMa7PRLI0PWZ5waoq5xLOWsJmCc8weFbpMUXQ qwE2AIUHP3MVGb2a6Y8OhIg7alUEkSE2IdoZWwHsSx1Qk5Wbxjbu6zrK2vKV+46N8uv4 5v5gC4o9/Csshq31Znz4/i+Til1zX9EanBktZOG47gD8sSv7d7KD0NylmfrEkzKQO/ej gD9A== 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=0wZVM3xTH0rIlT8FcnVb9p0qtohia4y51yWQ3iwO6GE=; b=Lpa/kdPd29OUXrXGI0pBKaTwUTDi2jhyZYQDx3ZsTVrKYU1vrgwp1mLCk5jVcQoNfu fB2pkkwY63Ln6WjLjIzJjPuipgr/gdZPWRWZUAAjpzY8eGcpeZ+3TiiY7pmvzdgIOeza XtZ+XI8ZvTC4nQVFLQoSkAr+FvohV9G/WCRnzA7FsJqIFr3zkGaBDpH3EOayhCrY6d8Q vZg1mVw6bZauTRyRdyQV8qcidROBPtq8qxRxC8cMRDDa0y52rXijksIzJHDzVUBJ5mJS BKT79cgJUiVOpvWqKQoSIBEyBgrm4sa+U9zVtOIhnrVfNepyGwleyFXL5FkTO5np4oyr 6pwA== X-Gm-Message-State: AOAM530TPcgeRR1Tl2qKP9aZ9MqVlksTGDse3GbrR4qJBkOV19rXMvON B2PseVxF/F0780c16v0bzF3ziy4EoYrLqfWX X-Google-Smtp-Source: ABdhPJyPYETqXXhsVmRZfJ5Pt9yt3ddqGh1MaLix9oNs2HvJ1kC7q2qq4bbPe84i1UWicrakUwT0OQ== X-Received: by 2002:a5d:42c9:: with SMTP id t9mr16483576wrr.13.1605105504516; Wed, 11 Nov 2020 06:38:24 -0800 (PST) Received: from localhost.localdomain (hst-221-89.medicom.bg. [84.238.221.89]) by smtp.gmail.com with ESMTPSA id b8sm2991405wrv.57.2020.11.11.06.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:23 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 1/8] venus: hfi: Use correct state in unload resources Date: Wed, 11 Nov 2020 16:37:48 +0200 Message-Id: <20201111143755.24541-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201111143755.24541-1-stanimir.varbanov@linaro.org> References: <20201111143755.24541-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org INST_RELEASE_RESOURCES state is set but not used, correct this by enter into INIT state once the unload resources is done. Signed-off-by: Stanimir Varbanov Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/hfi.c | 2 +- drivers/media/platform/qcom/venus/hfi.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 638ed5cfe05e..4c87228e8e1d 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -388,7 +388,7 @@ int hfi_session_unload_res(struct venus_inst *inst) if (ret) return ret; - inst->state = INST_RELEASE_RESOURCES; + inst->state = INST_INIT; return 0; } diff --git a/drivers/media/platform/qcom/venus/hfi.h b/drivers/media/platform/qcom/venus/hfi.h index f25d412d6553..e9c944271cc1 100644 --- a/drivers/media/platform/qcom/venus/hfi.h +++ b/drivers/media/platform/qcom/venus/hfi.h @@ -87,7 +87,6 @@ struct hfi_event_data { #define INST_LOAD_RESOURCES 4 #define INST_START 5 #define INST_STOP 6 -#define INST_RELEASE_RESOURCES 7 struct venus_core; struct venus_inst; From patchwork Wed Nov 11 14:37:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 323473 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp444465ils; Wed, 11 Nov 2020 06:40:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsVavRuBBkepUPLR3MVo2iUpQrxrF4VwyAMdIV8Fs01Y4thaR4Rkn8dry7YcZAL3IepYYN X-Received: by 2002:a50:ace6:: with SMTP id x93mr5529715edc.368.1605105627124; Wed, 11 Nov 2020 06:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605105627; cv=none; d=google.com; s=arc-20160816; b=rmne/XBpw20bP0cKpIvCZo+TMtXn2UDYxuiTydZglVbc4ZSiIxrqT0EfXiVMqw4anA 0H5eC9sVb6TxtLnS/8ZxuU+cjif4AiA5kMHrLSTp+61sI41uMgijNqTEtJsSZp3kFDcs ExojIK+I9NHi2bFHbcV1litmN1kKzBdqdYnWrmYPJW51IAXJbdSzfoylhk93vA1YjV8U kOaLXOSBJlzmvoTstfn2UbzCro7Qvzs+vw9jrG1q8QN0NzeyVAX7h7mcWvDIOFTvYEol adEjVDE2lXi2I73uWMxtdj9fY1VroTyq3rnv+Ng3gkQkZiCXce0YnfGsTmbRHt0wXvwr pA0g== 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=zbm0xMtaD/LBGoMU6CYy8HGE1zaoqwvW5S2bS4qwSZ8=; b=pMtUCFzWCSx69Fg9UF6WPCJvlywpOH1OTdQpkwIXuqaSXTaLTTmqmhdkecx9pWC4yQ /rvMMJtSoWWIRbQrxTJsfvqkr264PT91b5daKP1xoa7dab/LOmdIkTjMqK15oE0bgg9L 4jBrgU1DI8XhrRW5i8UJpY/JDTwDPkqSLldaUGdQHaLswSlg4VKELL2HlJWJHs4hDrNs P6iP9HDl2L4WWYEMjb22NNtL0Yco3R3wrz0KbxH+MwYVsB8ZUa28nRFl6r+cTRzcE/0D X40XzRQhdFHt3TRcpxWXSAIcp2h50oK3Lp4cZddfvlWCGnhxvGHtfD2IxEvC+DqOZOxK hbbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vcxHdqLG; 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 d18si1659926edx.345.2020.11.11.06.40.26; Wed, 11 Nov 2020 06:40:27 -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=vcxHdqLG; 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 S1727170AbgKKOkV (ORCPT + 4 others); Wed, 11 Nov 2020 09:40:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbgKKOid (ORCPT ); Wed, 11 Nov 2020 09:38:33 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5D6AC061A49 for ; Wed, 11 Nov 2020 06:38:27 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id 33so2748178wrl.7 for ; Wed, 11 Nov 2020 06:38:27 -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=zbm0xMtaD/LBGoMU6CYy8HGE1zaoqwvW5S2bS4qwSZ8=; b=vcxHdqLGDJelSVhVlwwgQW4PNlodm6Kt9WQEYwxE0ELHbLx3s1pNqKNO2mYiE+lQet EbiYMzqjHd+xtRJyhR8GwAPxCbLvz00JQHjOKb4AdfU2T9P/SDoQsozaDXbhFIv51n2g nVhrafatWLIfWHbSYFEfb1p9G6Z6jSwizdMcTwuhKiOkPQnME3QhVF28bCdp0R3mXliS xEMANH+P6extWgHhkvFY8SkGGRrxlRzh86eG1xS8pb+Y8t85NS5J07uPclSYTsMghSB8 gGBXjYLbROKdZ7ET5hAp+359+/t9T4si+NAzug9r4xVvdBWoLo3VLzx6JwXym3fk+fFi kUiQ== 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=zbm0xMtaD/LBGoMU6CYy8HGE1zaoqwvW5S2bS4qwSZ8=; b=IaAuWyQhX6hx7sJdOKbIj6rzRJQHo9S1YMWtlUnjZxkRJRV9r0XneKgOqH7rEc4Ezs mZUSnGjcZlRy/9u6ot6Rz4Kw9wc/yb/BNFfrkE7U7qjzxWYGC84x/YCIPPO5iVcf+rrh P5nfzOYP88apkNMlM9JXT8A1hGc6Iz74/vSmyDTuAO8jZK4eQ51WkXk61MqagOXFOwi7 ajYUnL8XDqMo2+41ct4wKfaxQDC3t40FbiduhJh0NTlmFjGnEzyldE40Y8OdalXkndBp vDPI+az6pZevuHHrEHxdr6D23dyyPE2HBxH4i9a3pRbs4dEJnim3x0bMx27wLiY6wmwn Oj9w== X-Gm-Message-State: AOAM530LTdUOvYnKEMLlWbB0IKUtlVmJCWeT7LbltSHuSfYpgtfftUaV PcMFj6KBX8SV0LfXvQUG/+C/+MlxvJS2wFNB X-Received: by 2002:adf:9e08:: with SMTP id u8mr29366032wre.282.1605105506221; Wed, 11 Nov 2020 06:38:26 -0800 (PST) Received: from localhost.localdomain (hst-221-89.medicom.bg. [84.238.221.89]) by smtp.gmail.com with ESMTPSA id b8sm2991405wrv.57.2020.11.11.06.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:25 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 2/8] venus: helpers: Add a new helper for buffer processing Date: Wed, 11 Nov 2020 16:37:49 +0200 Message-Id: <20201111143755.24541-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201111143755.24541-1-stanimir.varbanov@linaro.org> References: <20201111143755.24541-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The new helper will be used from encoder and decoder drivers to enqueue buffers for processing by firmware. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 20 ++++++++++++++++++++ drivers/media/platform/qcom/venus/helpers.h | 1 + 2 files changed, 21 insertions(+) -- 2.17.1 Reviewed-by: Fritz Koenig diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index efa2781d6f55..688e3e3e8362 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1369,6 +1369,26 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) } EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue); +void venus_helper_process_buf(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + int ret; + + cache_payload(inst, vb); + + if (vb2_start_streaming_called(vb->vb2_queue)) { + ret = is_buf_refed(inst, vbuf); + if (ret) + return; + + ret = session_process_buf(inst, vbuf); + if (ret) + return_buf_error(inst, vbuf); + } +} +EXPORT_SYMBOL_GPL(venus_helper_process_buf); + void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type, enum vb2_buffer_state state) { diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index f36c9f717798..231af29667e7 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -19,6 +19,7 @@ void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type, int venus_helper_vb2_buf_init(struct vb2_buffer *vb); int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb); void venus_helper_vb2_buf_queue(struct vb2_buffer *vb); +void venus_helper_process_buf(struct vb2_buffer *vb); void venus_helper_vb2_stop_streaming(struct vb2_queue *q); int venus_helper_vb2_start_streaming(struct venus_inst *inst); void venus_helper_m2m_device_run(void *priv); From patchwork Wed Nov 11 14:37:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 323298 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 2F693C55ABD for ; Wed, 11 Nov 2020 14:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B78522067D for ; Wed, 11 Nov 2020 14:40:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CBTrBBAS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727092AbgKKOkW (ORCPT ); Wed, 11 Nov 2020 09:40:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727105AbgKKOid (ORCPT ); Wed, 11 Nov 2020 09:38:33 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E623FC061A4F for ; Wed, 11 Nov 2020 06:38:30 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id 19so2487862wmf.1 for ; Wed, 11 Nov 2020 06:38:30 -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=TWPvZ8Q5g6TI75wYwlmr663kYENsDmC3EDOVf4VZUws=; b=CBTrBBASaPzbM0zto16rBPP1OtKXcFcWsvhLYI02MALLIPA8DBtqGeNIIaBw2f+BYF LLSdWMMqLd1cSxXQEsUH2BDaLqw9CDkEnwrTTZW+IKADXbZYpeqKuc2AwrkRnbzBJvzQ RffPysPxe41v9IaY+NabRgB08ToFDJIM4T+iuCGZHbRfAx6f9YQYZ4FoGVyO19YkNfuh ayoF4L+aUqUl6J5nhl6ahgS90QBIiFDv2cj+q6JANh/QZ7oPo2hoe6gTHDLZws9wELu8 rylgwYhm1mNBQ9PCWEvkBrWzy1k0xYBYr5egz1ts4u7OvEe1TY4MEstnEl8C8eOmoNIa b/UQ== 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=TWPvZ8Q5g6TI75wYwlmr663kYENsDmC3EDOVf4VZUws=; b=Ms7nyMGocFN+nSrp8dL5N/k1ULpHfgu5Hxk3u3FFZ9dIN2/2OJQHUX888OcWw/7jwf JMVGbjWI1ct6zL4u1yw6EQFgbdIgKEWsKuky8I7gE16VTjfO7gO/0bDtaSmluQI7+M2m xO7up49YFb7FqM3qbq5l3UbzqcBYsnG16H1euItwG7EXTNWqJIcvP5gYPQy/VzIQ+wcG JebP26niG1WCibU0M2YiDBOWDbHqPgAiR/0qxfCeSlfppO0ZqcdGSTqK5f1coaIFzfq0 wjBglBdkVrFI1eybxRkAaoXl6BDR0Tx5gLoOQdP0IKvxzR+aT+SFM/zrI4dR2CDv2G+C a9mQ== X-Gm-Message-State: AOAM532at6OZeYTZoUrcvZ4KQcqlVc+ovA5oR7tTW59WfBD3TzAR0zc0 EhT1iYQzlm/x43jEmOR0qYPNTqZKZN7x4YF9 X-Google-Smtp-Source: ABdhPJzJnrW6sIsYgEniA1h0eOK20YSa2wpZZMzrO2n9cS7E6RV6QQ+uX601nYZo5UQ2XWvRiiHHRQ== X-Received: by 2002:a7b:c4c3:: with SMTP id g3mr4427544wmk.65.1605105509436; Wed, 11 Nov 2020 06:38:29 -0800 (PST) Received: from localhost.localdomain (hst-221-89.medicom.bg. [84.238.221.89]) by smtp.gmail.com with ESMTPSA id b8sm2991405wrv.57.2020.11.11.06.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:29 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 4/8] venus: helpers: Calculate properly compressed buffer size Date: Wed, 11 Nov 2020 16:37:51 +0200 Message-Id: <20201111143755.24541-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201111143755.24541-1-stanimir.varbanov@linaro.org> References: <20201111143755.24541-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For resolutions below 720p the size of the compressed buffer must be bigger. Correct this by checking the resolution when calculating buffer size and multiply by four. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 688e3e3e8362..490c026b58a3 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -986,6 +986,8 @@ u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height) if (compressed) { sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2 / 2; + if (width < 1280 || height < 720) + sz *= 8; return ALIGN(sz, SZ_4K); } From patchwork Wed Nov 11 14:37:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 323131 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp443339ils; Wed, 11 Nov 2020 06:39:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwDilDi0selZ/E7u51Du4Uv+L1+uybVMNWLzJ9uOv4rLbZ29HWnPUWVT7F9eGfiznO+g/Q X-Received: by 2002:a50:f392:: with SMTP id g18mr27390026edm.140.1605105542048; Wed, 11 Nov 2020 06:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605105542; cv=none; d=google.com; s=arc-20160816; b=LnjCivvxAaG7VQuJ0RVCsrmm6H4ZkrGH21+d4HIRebTJoiumJCA1W/O/5XkJTBPAVE QyE1dMuok5GcgVXLTjWCFD0jQbebyrGTgotWWYIssKvO9fXiiGKlPm8okzR4Wnz0jIA5 u28LhQvU/uxZTeXut+5x8cZS56PZyj2ebiRtdzS+WGogB2NJWMqGVjQ6Wwo5UNwES3Sd nSs+ZE8R/n4yYVoIFxfkoumEdtpPZ1GRLO1cFGSAUo2j5te5ymx96a9FUb85A/dKSs9Z hfKnqZN9S2euFgtfeWY3LolhljaIeETkl9jzKCKhryw2hu1Z1+LThLY7SclIUTOBqfOU zyxQ== 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=r5xw7T/uN4wozQh78haRdLJ4I1daUv56Z3dNKSCf2g8=; b=G+gHvZ9AkCgv3J5551nKs9/5s0dKJcUqv6sIyINliFZkBocrIJ0pAg0galjl0sSVKm CgI7HqmYbqPVRwnBmz8FQOPp2jiBBm6eKVgfYE7EOJr9mDRM3vkmixeFxsvNhgoo37hG gXM6xEGhil4oDAF8GCvqgxU+t/3RuKJFJO+NdsxgGfwZ2SetcBDoWkaebdHEUydZdSN3 5eW4ErCgDhW0t1ZCj8kC5aJpQtPokzugnzhaR1XulTLYGC28zqQdv8zDH/cN1dym0EEK pub6igJHLvfzYWCnnspNcRhs32NQIdXbfDKdmFzRmtbjbeg2zKGp05ajNlfc+P2bd82c Su3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VLMQN0tI; 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 ho36si1583425ejc.640.2020.11.11.06.39.01; Wed, 11 Nov 2020 06:39:02 -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=VLMQN0tI; 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 S1727180AbgKKOin (ORCPT + 4 others); Wed, 11 Nov 2020 09:38:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727041AbgKKOik (ORCPT ); Wed, 11 Nov 2020 09:38:40 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05479C0613D6 for ; Wed, 11 Nov 2020 06:38:33 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id p19so4221348wmg.0 for ; Wed, 11 Nov 2020 06:38:32 -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=r5xw7T/uN4wozQh78haRdLJ4I1daUv56Z3dNKSCf2g8=; b=VLMQN0tIDckLVw+6qF38MEDotF6daCXyJ7OKxjfAfPo8EUhgsvM/0TuRhMQYk/B4QP HwhUQ0BiTaEkyia3CHO73KIboPDuUNJZ36aYWV9SOaJ1XE82K+VzpR3LLo7CJjFIP3my HSeeMNrytUAJIkZDaawi18M2NKeminEA2e1oxKkoCW3ZSrrRi0KAe4EWoBdAIx5kQThK 5ap2Gota1ktTvgR5MLG2WQOKIi8pH05QZNhy8A2CrqREkcMGeALyUjywgg0uCt4klfa6 xDiSuoEnv4jTiHWhVcjKtrZHLSzX6Ej6TtQ55rBPasHv+VkdyLBDv8aBySvTXcCRZQU8 SEeQ== 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=r5xw7T/uN4wozQh78haRdLJ4I1daUv56Z3dNKSCf2g8=; b=LkjykVjM/jSfBxVehHLk8yQQEimEKki9f6XfvMvfajys6ljxWayYcM70hFEsYAbqyh jN4KyiQI1Zc6ePh3Jidm0Um7iKeyJEE2UDDg4eUBqLi+XXhgxCFxfYeFbc8jN71J8j2E +PbZ1peCjoZiqqX3Pd+6/0uFMcqWtbgW4mDALGOU0mGZGfmHUROCaWrLSIqz39HCoDJG utyrCQJlsN9j5McgH/pIwiaJ0bsCRqxZbeOLmJvuoX0W6X1+aE8M1hXV1+dT4p2KBIBn WfZR6I4tltLF0lKMGzHFmixzKPW0WD9V54YUUwjc9aa/7nHtSP6tV6ZlAd3eTLT6azMj APjg== X-Gm-Message-State: AOAM531pXgDFPb00qnvpmme1rcu4WIq03wF5s0bUEwEPTUpp78jIlixz /px6xpEYCfW28Gx9rsetAtwrfiEQd0aOdrHZ X-Received: by 2002:a1c:4646:: with SMTP id t67mr4695545wma.40.1605105511450; Wed, 11 Nov 2020 06:38:31 -0800 (PST) Received: from localhost.localdomain (hst-221-89.medicom.bg. [84.238.221.89]) by smtp.gmail.com with ESMTPSA id b8sm2991405wrv.57.2020.11.11.06.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:31 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 5/8] venus: pm_helpers: Check instance state when calculate instance frequency Date: Wed, 11 Nov 2020 16:37:52 +0200 Message-Id: <20201111143755.24541-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201111143755.24541-1-stanimir.varbanov@linaro.org> References: <20201111143755.24541-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Skip calculating instance frequency if it is not in running state. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 Reviewed-by: Fritz Koenig diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index ca99908ca3d3..cc84dc5e371b 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -940,6 +940,9 @@ static unsigned long calculate_inst_freq(struct venus_inst *inst, mbs_per_sec = load_per_instance(inst); + if (inst->state != INST_START) + return 0; + vpp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vpp_freq; /* 21 / 20 is overhead factor */ vpp_freq += vpp_freq / 20; From patchwork Wed Nov 11 14:37:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 323128 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp443320ils; Wed, 11 Nov 2020 06:39:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzf/lGuZK13itth8EYr/sZPIaAvIy2AtZReHhaYB4Rzp24vCIbWalTBu5uTt2URAvMWgaIB X-Received: by 2002:a17:906:2ddb:: with SMTP id h27mr25171647eji.213.1605105540553; Wed, 11 Nov 2020 06:39:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605105540; cv=none; d=google.com; s=arc-20160816; b=q0dZm/x9hr9HUFPyb2a02GfMonOFiynlOIJc6aI8NxPBIswKPK/wru1365CrHDk8tG 7VCbGOtnZU5tDQtw3W8UHqHF9fWvTmXgx5THkq5BnG8o8iXPTVrJ4mpkBuGwpTPmk6Gd hFmnEOZ8F28hY1gsaoh8kTPCYrCg1BJK1Ou95tpmUIbYc65FoTZYMpydsy7mQbq9PQDu TKwNep2hLZr3F6SsK/cUGvC9wMxZeK4A/TgJDd6jO6PCD5SO+UeeqRc2adxTYwuOuvJz qi8x4Dt2VPCZHQg99RUuQrhxTQwGHu883LHrDdw93o35a93iBJgRHX4+ax4ql3/At92h EPVQ== 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=UgCPIURcil9hG01k4XJ9cyq/wEnYTI+F3ySUT22jgJk=; b=kdTLuyoHkssXJENraCpQO6kHH2ARu8brAYHstg8xUyEptTusRfJlH4qiXbmoQ/C0Ej u2u/GYcWd4Xn5AvHOHzfkFWgSaeMqeP367HnuD/5rhFFSftMMlJ4RSXFowwZQQz913oN ONPbRhC8rkepCTf8qYTTOVVyW8LX3iq1nxoUKRNu5LwDHrtPyNrZTtR6hWKhbk4bg9zS l17pkei7yyHFIGEd3Crspe/PyHMS0JcM+u4Lkj+NJM6fyyfMqaCV9Y0uHIFa38dP9PBt CJVGpocU9llT7d07dk8VBRw9BOcbkIoLa9KvaUA9SpR9zPJ1KSTMmqE14JORLJeJy2pA GBOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QmA+UejW; 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 ho36si1583425ejc.640.2020.11.11.06.39.00; Wed, 11 Nov 2020 06:39:00 -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=QmA+UejW; 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 S1727187AbgKKOiq (ORCPT + 4 others); Wed, 11 Nov 2020 09:38:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727161AbgKKOik (ORCPT ); Wed, 11 Nov 2020 09:38:40 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0CEFC061A51 for ; Wed, 11 Nov 2020 06:38:34 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id p22so2466417wmg.3 for ; Wed, 11 Nov 2020 06:38:34 -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=UgCPIURcil9hG01k4XJ9cyq/wEnYTI+F3ySUT22jgJk=; b=QmA+UejWXh4jwqurZUgb6ou4f8RqKFKwIHPWa9zSxdMz7JyAo8H29Pa38ECLkKBAWR xh9XKvbk0hVLiWDczMfNSjCP6D9Tg+Efbz/g2MMwIIXQncQJE3mHzYtV0NJNXaHNWb36 UUehausaXwSZtWsh4v0FGM88ixXTbnMKNwzmLfJU/SAvs0kmELjfVp93j4Felgg1nBSR qSTfw7yFRpTjvwYj1a+veAz/JlrrIAFw0v/qUDZTqIzQZGNX6+h3RkGDtmgKcKTBUxCt PmLACq4VtWWIMAw55T/e+PB2T/kX3YS/0NgcrxOJHpEERSYvcVTa0BpvTadf1I80tds0 gTXA== 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=UgCPIURcil9hG01k4XJ9cyq/wEnYTI+F3ySUT22jgJk=; b=B1WHMOIc8xRhuNI7E/3B5T+Q+IR9wDPzAHAWkM6sWBMRRThVTvGhy76nPZugaH69a6 Rl4teYgOQpsxYErRqxDzc5tx9QZ4+9s1zEryzmQildTycCOCqUZYqVLBSkDDmeNQLsYQ u08W9Wy96MxtQNgcwHQ5StkVW/tp66el5c+1SwYYvUaNaagEY39IE48AtWxkAnR03q03 zYrRVTCnge1gYOfVH13xJMX/hJhTm4XI5KI+kYEqHBn13n8ipS93Bx1V5YVFZveoil5M ov8caQXQ9Kb1E/DGA/WhKp8lKYbhaOBAp7jy8G3CDJmfCEX4ctppgoh+4UIjj5cSx3kO cFKg== X-Gm-Message-State: AOAM531VIewVKhGH8Ug/PuWAs/vJg2wBSY41PdOS7X6yOd4ldJZ+F5Bu KV6sb2u71M7vkV6HvM0owRDBOWokXBH2Col0 X-Received: by 2002:a7b:cd11:: with SMTP id f17mr4537221wmj.127.1605105513442; Wed, 11 Nov 2020 06:38:33 -0800 (PST) Received: from localhost.localdomain (hst-221-89.medicom.bg. [84.238.221.89]) by smtp.gmail.com with ESMTPSA id b8sm2991405wrv.57.2020.11.11.06.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:32 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Fritz Koenig , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH v2 6/8] venus: venc: add handling for VIDIOC_ENCODER_CMD Date: Wed, 11 Nov 2020 16:37:53 +0200 Message-Id: <20201111143755.24541-7-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201111143755.24541-1-stanimir.varbanov@linaro.org> References: <20201111143755.24541-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Dikshita Agarwal Add handling for below commands in encoder: 1. V4L2_ENC_CMD_STOP 2. V4L2_ENC_CMD_START Signed-off-by: Dikshita Agarwal Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/venc.c | 77 +++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Fritz Koenig diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 99bfabf90bd2..7512e4a16270 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -507,6 +507,59 @@ static int venc_enum_frameintervals(struct file *file, void *fh, return 0; } +static int venc_encoder_cmd(struct file *file, void *fh, + struct v4l2_encoder_cmd *ec) +{ + struct venus_inst *inst = to_inst(file); + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; + struct hfi_frame_data fdata = {0}; + int ret = 0; + + ret = v4l2_m2m_ioctl_try_encoder_cmd(file, fh, ec); + if (ret < 0) + return ret; + + mutex_lock(&inst->lock); + + if (!vb2_is_streaming(&m2m_ctx->cap_q_ctx.q) || + !vb2_is_streaming(&m2m_ctx->out_q_ctx.q)) + goto unlock; + + if (m2m_ctx->is_draining) { + ret = -EBUSY; + goto unlock; + } + + if (ec->cmd == V4L2_ENC_CMD_STOP) { + if (v4l2_m2m_has_stopped(m2m_ctx)) { + ret = 0; + goto unlock; + } + + m2m_ctx->is_draining = true; + + fdata.buffer_type = HFI_BUFFER_INPUT; + fdata.flags |= HFI_BUFFERFLAG_EOS; + fdata.device_addr = 0; + fdata.clnt_data = (u32)-1; + + ret = hfi_session_process_buf(inst, &fdata); + if (ret) + goto unlock; + } + + if (ec->cmd == V4L2_ENC_CMD_START && v4l2_m2m_has_stopped(m2m_ctx)) { + vb2_clear_last_buffer_dequeued(&m2m_ctx->cap_q_ctx.q); + inst->m2m_ctx->has_stopped = false; + venus_helper_process_initial_out_bufs(inst); + venus_helper_process_initial_cap_bufs(inst); + } + +unlock: + mutex_unlock(&inst->lock); + return ret; +} + static const struct v4l2_ioctl_ops venc_ioctl_ops = { .vidioc_querycap = venc_querycap, .vidioc_enum_fmt_vid_cap = venc_enum_fmt, @@ -534,6 +587,8 @@ static const struct v4l2_ioctl_ops venc_ioctl_ops = { .vidioc_enum_frameintervals = venc_enum_frameintervals, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, + .vidioc_try_encoder_cmd = v4l2_m2m_ioctl_try_encoder_cmd, + .vidioc_encoder_cmd = venc_encoder_cmd, }; static int venc_set_properties(struct venus_inst *inst) @@ -946,9 +1001,22 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) static void venc_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); + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; mutex_lock(&inst->lock); - venus_helper_vb2_buf_queue(vb); + + v4l2_m2m_buf_queue(m2m_ctx, vbuf); + + if (!(inst->streamon_out && inst->streamon_cap)) + goto unlock; + + if (v4l2_m2m_has_stopped(m2m_ctx)) + goto unlock; + + venus_helper_process_buf(vb); + +unlock: mutex_unlock(&inst->lock); } @@ -968,6 +1036,7 @@ static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, struct vb2_v4l2_buffer *vbuf; struct vb2_buffer *vb; unsigned int type; + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; if (buf_type == HFI_BUFFER_INPUT) type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; @@ -986,6 +1055,12 @@ static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, vb->planes[0].data_offset = data_offset; vb->timestamp = timestamp_us * NSEC_PER_USEC; vbuf->sequence = inst->sequence_cap++; + + if ((!bytesused && m2m_ctx->is_draining) || + (vbuf->flags & V4L2_BUF_FLAG_LAST)) { + vbuf->flags |= V4L2_BUF_FLAG_LAST; + v4l2_m2m_mark_stopped(inst->m2m_ctx); + } } else { vbuf->sequence = inst->sequence_out++; } From patchwork Wed Nov 11 14:37:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 323299 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 69177C388F9 for ; Wed, 11 Nov 2020 14:40:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09BBC2067D for ; Wed, 11 Nov 2020 14:40:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RFJWXOGA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727236AbgKKOjZ (ORCPT ); Wed, 11 Nov 2020 09:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbgKKOik (ORCPT ); Wed, 11 Nov 2020 09:38:40 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8AC0C061A54 for ; Wed, 11 Nov 2020 06:38:36 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id h2so2498368wmm.0 for ; Wed, 11 Nov 2020 06:38:36 -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=v6PMbdcIaoeKpv1BZw7/QGsGTQk22a+f7y9ODfXyJpE=; b=RFJWXOGAFWIA2m0DXMEeGx7fabcVR1mMGdq6TnQs1KjP24WoouQwbboYBzRcmp8jpB qi9Ny8SkABPKT9dqzlz26bVcCblnJUVm3OoDDfUZLpTjMg2LgEFlOiRSH4vMjpjZChEl vMu2jvUoBdokjDTEeM9ZhroBqIfQpJWpk2WEumL9qDGbn53+qYvWOKy6TlDbkHDARkBl UcnQGFPQTO+rI14M8It/CepOqeJFw/CpN2K2hf3jyZJGUEesPkpOAX84zNwOTE9wMJql l8iQpQFls1hnJOY9ixraUMmToUy9fCC+2LpceNKAGBwy11muuFWfBlupdTv84X/Mpp01 fpEA== 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=v6PMbdcIaoeKpv1BZw7/QGsGTQk22a+f7y9ODfXyJpE=; b=CNuylrhbj97fsnVeaJ2HPIedtKoZeMPQ5xHiyL3cX4TTjmb7jdhXuUTiB3SVtyiB8q 5D+hb0L0wwdi28ri1VeTCOjejJncJL6X0nCcTtP555e/ByqifUAPqcWPEXhlg7cbPliZ h7wHK2DianYWaO/HzWvz20QhebmmNc/qjSYyixtlNIUkm9/OmUBYJqe+B9OhybR8oPek G+LC+e3DZdg2GRM0Cfpt+X9q1TRKCGlQrTovYF6kmZrfT+jpVQa7+tLXZ8nEZYoeuzzz I2X7f4EpXkymtbeQKG93GFKwahNo2HxFaJNJt37Fq1U5BUoR0YK2196H0uBVvq1fAOWN hjZQ== X-Gm-Message-State: AOAM530riJCI7hkh1UKGktv/Ho6Pg8P6fZ6twe0S4Ydt/b0W5mx62tLn CCN29Yjr0KJFp3H60AZv9u57o1CDmke2vCJW X-Google-Smtp-Source: ABdhPJyfhwZZGvSjEExcYWQXwgso+d1TfwdG22b4x1vmEe3V5gSHol4/2Oyx2YXdpspM14ZNTjwJ3w== X-Received: by 2002:a1c:c302:: with SMTP id t2mr4671828wmf.189.1605105515148; Wed, 11 Nov 2020 06:38:35 -0800 (PST) Received: from localhost.localdomain (hst-221-89.medicom.bg. [84.238.221.89]) by smtp.gmail.com with ESMTPSA id b8sm2991405wrv.57.2020.11.11.06.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:34 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 7/8] venus: venc: Handle reset encoder state Date: Wed, 11 Nov 2020 16:37:54 +0200 Message-Id: <20201111143755.24541-8-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201111143755.24541-1-stanimir.varbanov@linaro.org> References: <20201111143755.24541-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Redesign the encoder driver to be compliant with stateful encoder spec - specifically adds handling of Reset state. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/venc.c | 155 ++++++++++++++++++----- 1 file changed, 122 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 7512e4a16270..f1ae89d45a54 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -907,6 +907,54 @@ static int venc_queue_setup(struct vb2_queue *q, return ret; } +static void venc_release_session(struct venus_inst *inst) +{ + int ret, abort = 0; + + mutex_lock(&inst->lock); + + ret = hfi_session_deinit(inst); + abort = (ret && ret != -EINVAL) ? 1 : 0; + + if (inst->session_error) + abort = 1; + + if (abort) + hfi_session_abort(inst); + + venus_pm_load_scale(inst); + INIT_LIST_HEAD(&inst->registeredbufs); + mutex_unlock(&inst->lock); + + venus_pm_release_core(inst); +} + +static int venc_buf_init(struct vb2_buffer *vb) +{ + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + + inst->buf_count++; + + return venus_helper_vb2_buf_init(vb); +} + +static void venc_buf_cleanup(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); + struct venus_buffer *buf = to_venus_buffer(vbuf); + + mutex_lock(&inst->lock); + if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + if (!list_empty(&inst->registeredbufs)) + list_del_init(&buf->reg_list); + mutex_unlock(&inst->lock); + + inst->buf_count--; + if (!inst->buf_count) + venc_release_session(inst); +} + static int venc_verify_conf(struct venus_inst *inst) { enum hfi_version ver = inst->core->res->hfi_version; @@ -938,49 +986,57 @@ static int venc_verify_conf(struct venus_inst *inst) static int venc_start_streaming(struct vb2_queue *q, unsigned int count) { struct venus_inst *inst = vb2_get_drv_priv(q); + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; int ret; mutex_lock(&inst->lock); - if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + v4l2_m2m_update_start_streaming_state(m2m_ctx, q); + + if (V4L2_TYPE_IS_OUTPUT(q->type)) inst->streamon_out = 1; else inst->streamon_cap = 1; - if (!(inst->streamon_out & inst->streamon_cap)) { - mutex_unlock(&inst->lock); - return 0; - } + if (inst->streamon_out && inst->streamon_cap && + inst->state == INST_UNINIT) { + venus_helper_init_instance(inst); - venus_helper_init_instance(inst); + inst->sequence_cap = 0; + inst->sequence_out = 0; - inst->sequence_cap = 0; - inst->sequence_out = 0; + ret = venc_init_session(inst); + if (ret) + goto bufs_done; - ret = venc_init_session(inst); - if (ret) - goto bufs_done; + ret = venus_pm_acquire_core(inst); + if (ret) + goto deinit_sess; - ret = venus_pm_acquire_core(inst); - if (ret) - goto deinit_sess; + ret = venc_verify_conf(inst); + if (ret) + goto deinit_sess; - ret = venc_set_properties(inst); - if (ret) - goto deinit_sess; + ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, + inst->num_output_bufs, 0); + if (ret) + goto deinit_sess; - ret = venc_verify_conf(inst); - if (ret) - goto deinit_sess; + ret = venus_helper_vb2_start_streaming(inst); + if (ret) + goto deinit_sess; - ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, - inst->num_output_bufs, 0); - if (ret) - goto deinit_sess; + venus_helper_process_initial_out_bufs(inst); + venus_helper_process_initial_cap_bufs(inst); + } else if (V4L2_TYPE_IS_CAPTURE(q->type) && inst->streamon_cap && + inst->streamon_out) { + ret = venus_helper_vb2_start_streaming(inst); + if (ret) + goto bufs_done; - ret = venus_helper_vb2_start_streaming(inst); - if (ret) - goto deinit_sess; + venus_helper_process_initial_out_bufs(inst); + venus_helper_process_initial_cap_bufs(inst); + } mutex_unlock(&inst->lock); @@ -990,15 +1046,43 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) hfi_session_deinit(inst); bufs_done: venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); - if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + if (V4L2_TYPE_IS_OUTPUT(q->type)) inst->streamon_out = 0; else inst->streamon_cap = 0; + mutex_unlock(&inst->lock); return ret; } -static void venc_vb2_buf_queue(struct vb2_buffer *vb) +static void venc_stop_streaming(struct vb2_queue *q) +{ + struct venus_inst *inst = vb2_get_drv_priv(q); + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; + int ret = -EINVAL; + + mutex_lock(&inst->lock); + + v4l2_m2m_clear_state(m2m_ctx); + + if (V4L2_TYPE_IS_CAPTURE(q->type)) { + ret = hfi_session_stop(inst); + ret |= hfi_session_unload_res(inst); + ret |= venus_helper_unregister_bufs(inst); + ret |= venus_helper_intbufs_free(inst); + } + + venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR); + + if (V4L2_TYPE_IS_OUTPUT(q->type)) + inst->streamon_out = 0; + else + inst->streamon_cap = 0; + + mutex_unlock(&inst->lock); +} + +static void venc_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); @@ -1022,11 +1106,12 @@ static void venc_vb2_buf_queue(struct vb2_buffer *vb) static const struct vb2_ops venc_vb2_ops = { .queue_setup = venc_queue_setup, - .buf_init = venus_helper_vb2_buf_init, + .buf_init = venc_buf_init, + .buf_cleanup = venc_buf_cleanup, .buf_prepare = venus_helper_vb2_buf_prepare, .start_streaming = venc_start_streaming, - .stop_streaming = venus_helper_vb2_stop_streaming, - .buf_queue = venc_vb2_buf_queue, + .stop_streaming = venc_stop_streaming, + .buf_queue = venc_buf_queue, }; static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, @@ -1084,8 +1169,12 @@ static const struct hfi_inst_ops venc_hfi_ops = { .event_notify = venc_event_notify, }; +static void venc_m2m_device_run(void *priv) +{ +} + static const struct v4l2_m2m_ops venc_m2m_ops = { - .device_run = venus_helper_m2m_device_run, + .device_run = venc_m2m_device_run, .job_abort = venus_helper_m2m_job_abort, };