From patchwork Fri Oct 23 12:57:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 292310 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 3DB79C4363A for ; Fri, 23 Oct 2020 12:57:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBA5424248 for ; Fri, 23 Oct 2020 12:57:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aNLgRz5O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S464124AbgJWM53 (ORCPT ); Fri, 23 Oct 2020 08:57:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S464137AbgJWM5Y (ORCPT ); Fri, 23 Oct 2020 08:57:24 -0400 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 43674C0613D6 for ; Fri, 23 Oct 2020 05:57:22 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id e17so1685211wru.12 for ; Fri, 23 Oct 2020 05:57:22 -0700 (PDT) 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=NrL1MV7N8ATs/PXzXCVKhIPAGTP6zOyD9l2GObHN45o=; b=aNLgRz5OfNWd4OVUswB3R+mClvdaOMsQ3yNLaj50D2E2YZeDMQM7UOwmkIS+rq8Qsr VIZy440MXqYI8mkQ4sKRjLfH7Xo7N1FpVP9hD8sKyeiAXnzlp9dJya5yd4wfa7WRqk2X v4Egaa5GIejStfexy1x80XFxLIROT0PXBqGIKW3XzT/0kI2A1nVvccj1EWOK5AfAGGx4 TgFiDRwHQEZA6Ld9Nylc/SZAT0dqMngLX5wsZNKNroPum4pA9oI/Q8Dcft0shtYhNLrO oVzK50Ajoi44aIlj/yTieRcj1OUiujthKWsGt3bNkIZKxvekXsx+JfFWzTXUJsK9vK4F fDzA== 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=NrL1MV7N8ATs/PXzXCVKhIPAGTP6zOyD9l2GObHN45o=; b=he7MNAEb/cjPviegWErNx6LlKXVehf39JIhI6FfCp2TyrOTJAI1iHh5YUCPjNnQRtb lsy1uEwouu92YsH5sGtwwfKP8hkqtXBMIxDKJZHG/BFYI3UE8XkjB4H5b79vnI6hR82W YnSoP3wpXlke7Kq7Zkuq9lL/bNMXwu6u+vZjHYVvy0L4rE4a8c9IgYvjgxSWSVESXKjI sTOH/Wra20VJoT5dTRSmZnXj1DsdRHmlCznimmFjKyGt6CA+VPrOWJHqAVxaVPuzqtyz FjAIb1KlyuPfue2PdAxJzSH6RjFAQ2Ph5LAz+hNRH8RuHnbtx3KTTgjDSs2zELOKg8EJ MvwA== X-Gm-Message-State: AOAM5326biVVdcyPs3zx1J/sHEBYFdMsIH6R7CAKYwkH3BRDoj+p+i5D C2qqIU3y7zxtKQMIqGw7WZ6QfQ== X-Google-Smtp-Source: ABdhPJzXsFAYq8o4JA+bX89U8lRgr1JK8t6fu6sP2QaoFHcwf0aAu9vq25qV4YFATQUCxuV89vzmEQ== X-Received: by 2002:adf:b787:: with SMTP id s7mr2636696wre.390.1603457840965; Fri, 23 Oct 2020 05:57:20 -0700 (PDT) Received: from localhost.localdomain (hst-221-77.medicom.bg. [84.238.221.77]) by smtp.gmail.com with ESMTPSA id s19sm3475873wmc.0.2020.10.23.05.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 05:57:20 -0700 (PDT) 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 , Tomasz Figa , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH 1/4] venus: hfi: Use correct state in unload resources Date: Fri, 23 Oct 2020 15:57:01 +0300 Message-Id: <20201023125704.4984-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023125704.4984-1-stanimir.varbanov@linaro.org> References: <20201023125704.4984-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 --- 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 a59022adb14c..1480a76d4da4 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -376,7 +376,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 Fri Oct 23 12:57:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 284938 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 F1784C388F9 for ; Fri, 23 Oct 2020 12:57:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A07B92168B for ; Fri, 23 Oct 2020 12:57:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YSUyy99R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S464146AbgJWM52 (ORCPT ); Fri, 23 Oct 2020 08:57:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S464124AbgJWM5Y (ORCPT ); Fri, 23 Oct 2020 08:57:24 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 252DFC0613D2 for ; Fri, 23 Oct 2020 05:57:23 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id k18so1422672wmj.5 for ; Fri, 23 Oct 2020 05:57:23 -0700 (PDT) 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=ZFseCIKmd4AutdezcJJkL4SrWd2bZ1+/6MDl5tIHNnc=; b=YSUyy99Rkveptn5PzX5hv4IkjbPMMugLbvjuzfzkr96YHYPqTot2Ym3PIFQbNsDADW +LyYKNtpy9GHP3FWlcFzXQ2vJx+KwdYl8mYo3gYkugu4ORGpP8OsCspJQPQ2eV7S0zKo X8zh8zhobD0GBED+11SQDKq18CGTBwxos/NIalT6kmWUK/qk5gj59feAnpN3DQTa07gn 3arL8KyFlaMixoJ1hmdn/ic95g348jXonXv3DZGxOolqBHnTpTNciXyiAzvu62ItqraW QehWjbwbom5rckpgGNfAiFRN0fwyOCk4umm8X0FzXUJfP9qGPurNsUNXbnEJhX2UZGh6 d++w== 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=ZFseCIKmd4AutdezcJJkL4SrWd2bZ1+/6MDl5tIHNnc=; b=TFYUW5ZoWJPUsQ6YGqdKF7nKz85J4PPc4K6WI0VICVgi23xybwI9KvLq2/B+415Tx/ M5V+hALz9VsS//OluJDXroUypi92BftAVcl7tRFkQXHCQUMOBaBafe3gvStmWfvL+/fu 0RBoiYZV3GOlgaJIE8/US0w7zys+IiroqTT1pmXNYEI2why6fGu/d0ZGOu7VlZBN9DIN cth855hK7oi1Cl24xWp1qq+u6MUFbMwiIcBdyVVTt2ZfHa+jOGmI6ucmQCwyZEhCdVA9 h0N2ECoFKi+d4jOsOvXNCm7ARd6WB3ylZ6a3gDzR2/zgxLMhJgLVRM4eQsaUbb71pRKH d6Uw== X-Gm-Message-State: AOAM532m/Ij9nijqEXmA4H+tB7LB+LwRn/w6l32PpsFyJ1n383JZq+JX /ECFpbjSlueDq0+V/t5Ttcqqxw== X-Google-Smtp-Source: ABdhPJyeZZ9bzyZYKpr/fdm9hlTUGXOVfcvjpWFXRM7+3BGWOKN/dr4ppE4nP9V7lWvvdA17YpLJ0A== X-Received: by 2002:a1c:383:: with SMTP id 125mr660940wmd.175.1603457841937; Fri, 23 Oct 2020 05:57:21 -0700 (PDT) Received: from localhost.localdomain (hst-221-77.medicom.bg. [84.238.221.77]) by smtp.gmail.com with ESMTPSA id s19sm3475873wmc.0.2020.10.23.05.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 05:57:21 -0700 (PDT) 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 , Tomasz Figa , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH 2/4] venus: helpers: Add a new helper for buffer processing Date: Fri, 23 Oct 2020 15:57:02 +0300 Message-Id: <20201023125704.4984-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023125704.4984-1-stanimir.varbanov@linaro.org> References: <20201023125704.4984-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(+) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 2b6925b6c274..8d0ca70d740d 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 a4a0562bc83f..dca4794c05d9 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 Fri Oct 23 12:57:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 292309 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 2AF62C388F9 for ; Fri, 23 Oct 2020 12:57:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C10562168B for ; Fri, 23 Oct 2020 12:57:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GVnhhVaq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S464145AbgJWM5a (ORCPT ); Fri, 23 Oct 2020 08:57:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S464141AbgJWM5Z (ORCPT ); Fri, 23 Oct 2020 08:57:25 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AC2DC0613CE for ; Fri, 23 Oct 2020 05:57:24 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id n6so1682978wrm.13 for ; Fri, 23 Oct 2020 05:57:24 -0700 (PDT) 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=8Un6TK7sYYF4eb6us4s4zFOZ4gYB/IgZ68I4XdameWc=; b=GVnhhVaqfTwCYEap7frqME5MIVrpMpblBVZ/bwoQZw4QzcjO+Mu+KKvTli9SowTkHM vHf3FYM+MmVOQWPHQwp1e00BPKYvEhzDH98lwl6oEA3Fz84Ir1PsQp8SemBH4kbn0Cry HPNxNKnDa1XZivPFke8JL8wdliKbFls003QRmGZOAqWrJeRY35TOPcgYLm6mLpFzAgZp IzF549J/4w+q4ozrkPKPSPgv0q74Rt5CGBuwxTlHqDdzOiwTHwsVFG3Cs4lB9T4PHJk0 0AdmKBDi1Of4eh+208XfIxOG1zMovrIzK4yjzDSp5rw3DKEYXRfXIZWM3C841TklX1aU NzVQ== 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=8Un6TK7sYYF4eb6us4s4zFOZ4gYB/IgZ68I4XdameWc=; b=Eo4nKhGBGnDeZlUAjzdmMDcDQEPsvC1RtRI/wKdB/oNRgvxlOgugJcYKsS6LS8IYSc GrOHrxd8BXubV7hROpyutqSpb/gBh3052es8A/9arx0ql7IZ/+U6+OuUa1+pYpVDxoa4 IiNybk1Sx1n+KrBvnMePbhxP0DdwRRS7lpFOkos4hTdyUzBqCGb5I/L8wycTGbRpsGig PfNb3iygcw7No6certe/QMlySbS977mCc8HxLj8i47GfDEKxSJ9bnI1LjEjX8cjFZNBD Ba7QR9G6M1D7pe5mmvAiv4+DiGnwwDpf0FM2arpu+y3GEHzgEguEYUD3TWYGgTZlZcOY NF7A== X-Gm-Message-State: AOAM533SdwuHhERPVeyIAxIKbrSUlidd2c9kpDksVornaVElTzNPqK+N pFUV+eJnr657jGmq7ZNi20rBDQ== X-Google-Smtp-Source: ABdhPJyBrePHdzmqzdEums6IS7IVMXLHmgOvwinn39Q9GhIQjs3GTFb9SAKKIYWCDCuxUzbe9zm+0g== X-Received: by 2002:adf:9793:: with SMTP id s19mr2541826wrb.139.1603457842847; Fri, 23 Oct 2020 05:57:22 -0700 (PDT) Received: from localhost.localdomain (hst-221-77.medicom.bg. [84.238.221.77]) by smtp.gmail.com with ESMTPSA id s19sm3475873wmc.0.2020.10.23.05.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 05:57:22 -0700 (PDT) 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 , Tomasz Figa , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH 3/4] venus: venc: Handle reset encoder state Date: Fri, 23 Oct 2020 15:57:03 +0300 Message-Id: <20201023125704.4984-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023125704.4984-1-stanimir.varbanov@linaro.org> References: <20201023125704.4984-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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/core.h | 10 +- drivers/media/platform/qcom/venus/venc.c | 242 ++++++++++++++++++----- 2 files changed, 197 insertions(+), 55 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 5c4693678e3f..294d5467a6a1 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -277,11 +277,11 @@ enum venus_dec_state { }; enum venus_enc_state { - VENUS_ENC_STATE_DEINIT = 0, - VENUS_ENC_STATE_INIT = 1, - VENUS_ENC_STATE_ENCODING = 2, - VENUS_ENC_STATE_STOPPED = 3, - VENUS_ENC_STATE_DRAIN = 4, + VENUS_ENC_STATE_INIT = 0, + VENUS_ENC_STATE_ENCODING = 1, + VENUS_ENC_STATE_STOPPED = 2, + VENUS_ENC_STATE_DRAIN = 3, + VENUS_ENC_STATE_RESET = 4, }; struct venus_ts_metadata { diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index c6143b07914c..aa9255ddb0a5 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -565,6 +565,7 @@ 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, }; @@ -850,6 +851,69 @@ static int venc_queue_setup(struct vb2_queue *q, return ret; } +static void venc_release_session(struct venus_inst *inst) +{ + struct venus_core *core = inst->core; + int ret, abort = 0; + + mutex_lock(&inst->lock); + + if (inst->enc_state != VENUS_ENC_STATE_RESET) + dev_dbg(core->dev_enc, VDBGH "wrong state!\n"); + + ret = hfi_session_stop(inst); + abort |= (ret && ret != -EINVAL) ? 1 : 0; + ret = hfi_session_unload_res(inst); + abort |= (ret && ret != -EINVAL) ? 1 : 0; + ret = venus_helper_unregister_bufs(inst); + abort |= (ret && ret != -EINVAL) ? 1 : 0; + ret = venus_helper_intbufs_free(inst); + abort |= (ret && ret != -EINVAL) ? 1 : 0; + 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); + + inst->enc_state = VENUS_ENC_STATE_INIT; + + 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; @@ -881,61 +945,73 @@ 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); - int ret; + int ret = 0; mutex_lock(&inst->lock); - if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + 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)) + goto unlock; - venus_helper_init_instance(inst); + if (inst->enc_state == VENUS_ENC_STATE_INIT) { + 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_set_properties(inst); - if (ret) - goto deinit_sess; + ret = venc_verify_conf(inst); + if (ret) + goto deinit_sess; - ret = venc_verify_conf(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 = venus_helper_set_num_bufs(inst, inst->num_input_bufs, - inst->num_output_bufs, 0); - if (ret) - goto deinit_sess; + ret = venus_helper_vb2_start_streaming(inst); + if (ret) + goto deinit_sess; - 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); - inst->enc_state = VENUS_ENC_STATE_ENCODING; + inst->enc_state = VENUS_ENC_STATE_ENCODING; + } else if (inst->enc_state == VENUS_ENC_STATE_RESET && + V4L2_TYPE_IS_CAPTURE(q->type)) { + ret = venus_helper_vb2_start_streaming(inst); + if (ret) + goto bufs_done; - mutex_unlock(&inst->lock); + venus_helper_process_initial_out_bufs(inst); + venus_helper_process_initial_cap_bufs(inst); - return 0; + inst->enc_state = VENUS_ENC_STATE_ENCODING; + } else if (inst->enc_state == VENUS_ENC_STATE_STOPPED && + V4L2_TYPE_IS_OUTPUT(q->type)) { + inst->enc_state = VENUS_ENC_STATE_ENCODING; + } + +unlock: + mutex_unlock(&inst->lock); + return ret; deinit_sess: 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; @@ -943,33 +1019,97 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) return ret; } -static void venc_vb2_buf_queue(struct vb2_buffer *vb) +static int venc_stop_capture(struct venus_inst *inst) +{ + int ret; + + switch (inst->enc_state) { + case VENUS_ENC_STATE_ENCODING: + case VENUS_ENC_STATE_DRAIN: + case VENUS_ENC_STATE_STOPPED: + inst->enc_state = VENUS_ENC_STATE_RESET; + break; + default: + return -EINVAL; + } + + ret = hfi_session_stop(inst); + ret |= hfi_session_unload_res(inst); + ret |= venus_helper_unregister_bufs(inst); + ret |= venus_helper_intbufs_free(inst); + + return ret; +} + +static int venc_stop_output(struct venus_inst *inst) +{ + switch (inst->enc_state) { + case VENUS_ENC_STATE_ENCODING: + inst->enc_state = VENUS_ENC_STATE_STOPPED; + break; + case VENUS_ENC_STATE_DRAIN: + inst->enc_state = VENUS_ENC_STATE_STOPPED; + break; + default: + return -EINVAL; + } + + return 0; +} + +static void venc_stop_streaming(struct vb2_queue *q) +{ + struct venus_inst *inst = vb2_get_drv_priv(q); + int ret = -EINVAL; + + mutex_lock(&inst->lock); + + if (V4L2_TYPE_IS_OUTPUT(q->type)) + ret = venc_stop_output(inst); + else + ret = venc_stop_capture(inst); + + venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_ERROR); + + if (ret) + goto unlock; + + if (V4L2_TYPE_IS_OUTPUT(q->type)) + inst->streamon_out = 0; + else + inst->streamon_cap = 0; + +unlock: + 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); + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; mutex_lock(&inst->lock); - if (inst->enc_state == VENUS_ENC_STATE_STOPPED) { - 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); - mutex_unlock(&inst->lock); - return; - } + v4l2_m2m_buf_queue(m2m_ctx, vbuf); + + if (!(inst->streamon_out && inst->streamon_cap)) + goto unlock; + + venus_helper_process_buf(vb); - venus_helper_vb2_buf_queue(vb); +unlock: 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_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, @@ -1025,8 +1165,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, }; @@ -1098,11 +1242,9 @@ static int venc_open(struct file *file) inst->core = core; inst->session_type = VIDC_SESSION_TYPE_ENC; inst->clk_data.core_id = VIDC_CORE_ID_DEFAULT; + inst->enc_state = VENUS_ENC_STATE_INIT; inst->core_acquired = false; - if (inst->enc_state == VENUS_ENC_STATE_DEINIT) - inst->enc_state = VENUS_ENC_STATE_INIT; - venus_helper_init_instance(inst); ret = pm_runtime_get_sync(core->dev_enc); @@ -1167,7 +1309,7 @@ static int venc_close(struct file *file) mutex_destroy(&inst->lock); v4l2_fh_del(&inst->fh); v4l2_fh_exit(&inst->fh); - inst->enc_state = VENUS_ENC_STATE_DEINIT; + pm_runtime_put_sync(inst->core->dev_enc); kfree(inst); From patchwork Fri Oct 23 12:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 284937 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 32FEEC4363A for ; Fri, 23 Oct 2020 12:57:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4DEF20E65 for ; Fri, 23 Oct 2020 12:57:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="C1s2PoR5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S464152AbgJWM5a (ORCPT ); Fri, 23 Oct 2020 08:57:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S464143AbgJWM5Z (ORCPT ); Fri, 23 Oct 2020 08:57:25 -0400 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 4D0BBC0613D7 for ; Fri, 23 Oct 2020 05:57:25 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id s9so1695065wro.8 for ; Fri, 23 Oct 2020 05:57:25 -0700 (PDT) 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=+xri++KZd0ajH9qdVfAp67Rdv968jiyDThdwgMpFlQU=; b=C1s2PoR5O3lgcFe585reoiQJvXOXD6IBX9C7RDoyIHQqE+G2XDhpnGVoatJW551ssX FALN9Y7qmuik7OlOkaOrSpRKNMQJ5wts0JBvoOCg7OU2PYFka4ecQDFeZl3FaQ5KJn8E p85w7vrEMAnsJVngcaweMZYCJ2sB8UbLc85G3z226198JwO/rQ6UAk7Y4c+5qnvrKZy8 rB8Rq8XOZ7Vf41a6mVgnyADdcnTpli6x/8BgO0rFBjJQFkMea68RknoIM0Dye1oISd86 SmtYjnqEwg2qPhvjevKr9Gwu/kMjbW9By4O3XXPCXZkx7FmJ5iSU9aBuSFXYHkvEruJ4 hmMA== 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=+xri++KZd0ajH9qdVfAp67Rdv968jiyDThdwgMpFlQU=; b=gnVzLjK5v9WO2zarXG0kBj6WWkqSGH3zsXcPQS5/2Wa2QREbkiMfuPAX+7nkjgzEgv +ABpIFRjg96CSjOm9S3SrvxjTxkY7Wh7x5HvUnKkfpzUPJBN75RC/DbZEo3aHXkAI4t7 fRrnJGUbfpBmqzLa42+BH78RTVk/IkQJciVeKkK3gUiFCEgV3XT1WpTY+bdiVMhs6bF/ B4F0FU57q/PZfXcA8xzaLVMJpgWzRnsfrVvIw+dGn97L4HbxD60+RJetpVrd7g7/FCMn 2oOLg9Gkz7LQmiM0rCPWI1dlEs63SNOfTpjAs3vEisCdNKQbnLtjRylxYRXSLHItzLjk L+8Q== X-Gm-Message-State: AOAM531aPwGsHOA+13CosTJbOi3paD/FmpSH4H6Uxpd1e+VGG0exSgen Q+Md4BSinmouY64swalezZ0F5w== X-Google-Smtp-Source: ABdhPJwNk4Ej8+YvZTaW3P3YHgDEX1teggYAa0I8cBEU+Xl67inPYEEqk39KnkHG1tYLjpq1oK0kXQ== X-Received: by 2002:adf:eccb:: with SMTP id s11mr2529446wro.135.1603457843988; Fri, 23 Oct 2020 05:57:23 -0700 (PDT) Received: from localhost.localdomain (hst-221-77.medicom.bg. [84.238.221.77]) by smtp.gmail.com with ESMTPSA id s19sm3475873wmc.0.2020.10.23.05.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 05:57:23 -0700 (PDT) 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 , Tomasz Figa , Dikshita Agarwal , Stanimir Varbanov Subject: [PATCH 4/4] venus: helpers: Delete unused stop streaming helper Date: Fri, 23 Oct 2020 15:57:04 +0300 Message-Id: <20201023125704.4984-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023125704.4984-1-stanimir.varbanov@linaro.org> References: <20201023125704.4984-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org After re-design of encoder driver this helper is not needed anymore. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 43 --------------------- drivers/media/platform/qcom/venus/helpers.h | 1 - 2 files changed, 44 deletions(-) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 8d0ca70d740d..1668cbaf3c72 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1404,49 +1404,6 @@ void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type, } EXPORT_SYMBOL_GPL(venus_helper_buffers_done); -void venus_helper_vb2_stop_streaming(struct vb2_queue *q) -{ - struct venus_inst *inst = vb2_get_drv_priv(q); - struct venus_core *core = inst->core; - int ret; - - mutex_lock(&inst->lock); - - if (inst->streamon_out & inst->streamon_cap) { - ret = hfi_session_stop(inst); - ret |= hfi_session_unload_res(inst); - ret |= venus_helper_unregister_bufs(inst); - ret |= venus_helper_intbufs_free(inst); - ret |= hfi_session_deinit(inst); - - if (inst->session_error || core->sys_error) - ret = -EIO; - - if (ret) - hfi_session_abort(inst); - - venus_helper_free_dpb_bufs(inst); - - venus_pm_load_scale(inst); - INIT_LIST_HEAD(&inst->registeredbufs); - } - - venus_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, - VB2_BUF_STATE_ERROR); - venus_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - VB2_BUF_STATE_ERROR); - - if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) - inst->streamon_out = 0; - else - inst->streamon_cap = 0; - - venus_pm_release_core(inst); - - mutex_unlock(&inst->lock); -} -EXPORT_SYMBOL_GPL(venus_helper_vb2_stop_streaming); - int venus_helper_process_initial_cap_bufs(struct venus_inst *inst) { struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h index dca4794c05d9..b8d6c5085d4f 100644 --- a/drivers/media/platform/qcom/venus/helpers.h +++ b/drivers/media/platform/qcom/venus/helpers.h @@ -20,7 +20,6 @@ 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); void venus_helper_m2m_job_abort(void *priv);