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: 11897973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2B27138B for ; Wed, 11 Nov 2020 14:40:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A1DA20795 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: 11897971 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98A741391 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 6AF10207BB for ; Wed, 11 Nov 2020 14:40:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vcxHdqLG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727170AbgKKOkV (ORCPT ); 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-Google-Smtp-Source: ABdhPJxdzXy/ZsM+pI+WafdPtpTldiOKB3g52X0jJBAJajeZyDs1QAqpZ1FqrEcbwsIsOstirGpJhQ== 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 Reviewed-by: Fritz Koenig --- 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 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:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11897963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0E1A1391 for ; Wed, 11 Nov 2020 14:40:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B84ED207DE for ; Wed, 11 Nov 2020 14:40:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GnjXvNlH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727133AbgKKOkU (ORCPT ); Wed, 11 Nov 2020 09:40:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgKKOie (ORCPT ); Wed, 11 Nov 2020 09:38:34 -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 364B9C061A4C for ; Wed, 11 Nov 2020 06:38:29 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id p8so2760530wrx.5 for ; Wed, 11 Nov 2020 06:38:29 -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=2CVxiw78RvuEwO3JJMPL80Z3ql7fTAJblZZgActuTxc=; b=GnjXvNlHccEzofSPCStx3HQZTpOGU9JVteupoMiWdOT7dr0PNDBfdvXpyggaGk9Qmj xLs+EmoFXmagv5kyKvDL+eCltQJBGxRTSxKsqyjW51wE8GCj8Nqlmni7ziIgF+4uQHCo elNLwXhQJa/CrMhLSHNY+pJc3UINTByhv6tiU+81lrtzWbsyVolO8QbFQafwaPnlI7fp RXDAuV5tLxFog2a63wkAk4hgCQqDddb8Q2Dtj4ggKKu6diUbSRE/kpYV1IYd6ShmA86k QAO13s0JvSL58opvp7GVWl7xQIbRJ6zZ3g9cDuAkrL3W8apbqertuGQZUFwQERhvWSGU TCsg== 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=2CVxiw78RvuEwO3JJMPL80Z3ql7fTAJblZZgActuTxc=; b=EXxVflrzJY/Ljy+uAHzA79/zyWZ99rcVZhBkXEuULMYegk1CODrTbNwbk641xf6uLO +6Y8r1X8+kKo9H3IawJmnug6HXO7WBuc2g9ySBtkqrBcepOc6ncTXegaKcItB/VUcXPc eck5ob+j84Wm8gCRCECN95Qxw9icdHFt/y5pTKOMD2TluTVzELO5PxaJBLcyahhXy9c3 3a8PkOcH6V/Os77euBauoqBtBK90trVEyGFk38rOjKhGA2ulEMcrV/TwB6R1h6dOAPFs odQG0VUt9vJIZ+ljs4t0v4V6X13AKA4WqZmd3EG+gLmtsaT3yl/MXXJNM97BToghS6XS kJrA== X-Gm-Message-State: AOAM531Yw2aTHQYAwpfFmIUaIJwq3w76lkPAv2VJbndH7nrtvUKnwUM4 293s0W5aRnx+DlsF/ZxHQ7EI8wEVieqYDXVi X-Google-Smtp-Source: ABdhPJzgjpuQevq0D98kNNwBGspcXhVbH+57+WmmTaTWnZpt8ijERz1XuF3zP4/d5nVBNug9DDgoBw== X-Received: by 2002:a5d:4883:: with SMTP id g3mr30509001wrq.19.1605105507679; Wed, 11 Nov 2020 06:38:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:27 -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 3/8] venus: hfi_cmds: Allow null buffer address on encoder input Date: Wed, 11 Nov 2020 16:37:50 +0200 Message-Id: <20201111143755.24541-4-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 Allow null buffer address for encoder input buffers. This will be used to send null input buffers to signal end-of-stream. Signed-off-by: Stanimir Varbanov Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/hfi_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index 4f7565834469..2affaa2ed70f 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -278,7 +278,7 @@ int pkt_session_etb_encoder( struct hfi_session_empty_buffer_uncompressed_plane0_pkt *pkt, void *cookie, struct hfi_frame_data *in_frame) { - if (!cookie || !in_frame->device_addr) + if (!cookie) return -EINVAL; pkt->shdr.hdr.size = sizeof(*pkt); 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: 11897969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CE51138B 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 E4B69207BB 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: 11897947 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E1981391 for ; Wed, 11 Nov 2020 14:39:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9FEF207DE for ; Wed, 11 Nov 2020 14:39:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VLMQN0tI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727180AbgKKOin (ORCPT ); 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-Google-Smtp-Source: ABdhPJzxKaWj8b6sqgf5Vs79P5cB7jKpRfK/0sIhOL5lxOS8Yc8dWEfG7A+PioenuQlXvGeHwFWQ+g== 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 Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +++ 1 file changed, 3 insertions(+) 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: 11897945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA53E14C0 for ; Wed, 11 Nov 2020 14:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 918D6207DE for ; Wed, 11 Nov 2020 14:39:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QmA+UejW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727187AbgKKOiq (ORCPT ); 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-Google-Smtp-Source: ABdhPJwZ0P1JYmiuBrLn4FSKP2pDFcznHFEgrw+BxDshi/vutcOK5q4S7aw3K9m2bwFXfHuzAOnX+Q== 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 Reviewed-by: Fritz Koenig --- drivers/media/platform/qcom/venus/venc.c | 77 +++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) 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: 11897961 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71383138B 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 3C4F320795 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, }; From patchwork Wed Nov 11 14:37:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11897955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 626FA1391 for ; Wed, 11 Nov 2020 14:39:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38BA920795 for ; Wed, 11 Nov 2020 14:39:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qzf64FhV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727248AbgKKOjD (ORCPT ); Wed, 11 Nov 2020 09:39:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727153AbgKKOik (ORCPT ); Wed, 11 Nov 2020 09:38:40 -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 3F0A7C061A56 for ; Wed, 11 Nov 2020 06:38:38 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id p8so2761044wrx.5 for ; Wed, 11 Nov 2020 06:38:38 -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=DzUjnsp2X4OnTCyXgn/JbY+DNy5G4LB8TIDONuAc8II=; b=Qzf64FhVyFPIfQD1gu6EoyuhzvYG1X3bVXltED54Gqv32hegCwzWHi3W3muW0j04+T jgF9K5kF2vVLRSanLBmu7r32YPYE4t+qTKbOE2uDoby4tKP1z9dD3DLPJK14KCXR4QTc eFR+8+lixZGzRPhGBRbEoXFm55q7HJat3WH2EW0cgpvQUM5ZTEWWbJPYycrVX/3rIesY k90QNUFB4yXAlAxx7o6lA8seBS45akDOwgrR3E4Khpm4kNnL/ecBUeAhHuUvzNhUjx28 QtYZy+mt6U7R+CB10xXZKxvKyabezUpyRU4G2CSa/OUYhKoobPe0APxaBd5zoFnxf/1p x6zA== 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=DzUjnsp2X4OnTCyXgn/JbY+DNy5G4LB8TIDONuAc8II=; b=BcKGM/fKEPyj6ddT2PYum/xXftlR8OV+mxKnr9veQvSv01kQxVOiUeTFiw2c+QkRgc o+62CD3HGzF2t24FhPoQ2ba7I83D1KzEdcIkjR9ZyjqRW7b9lZQbeSEcj2d2Iy1Qff3V Cv42mOofBhnxdh25hxw1gphvd0qS+mqYBHoSdCe31f3Mxku2VWb7aioOtchMYRI6iC7y as5ZBnHJxuaJq6iiZvvIDq85RrXm7bHVAydiiHSevBv1GpHmWnawU8UPjpxIz5cLEt4T EvBhs9vdhOWxYRgX+G+CIQGvdcIDY0PHO3NG0aWRuijGUoOSr5PpmWhnyeoqQpnz3VQn BnZA== X-Gm-Message-State: AOAM532nOdL1/WBZtUFl15KLlZPe21G4s39Ys89ip773PuI+PYWDvXUO 6BF73oVDcAVm4BrA7ycBmBk+wuSuMb2YsG2q X-Google-Smtp-Source: ABdhPJz3exYiT8GJMsh3/W6jpnBZ3DjMRWetrng5MyjLQM4Di85RFaHmr5jjqSjwNZucXT7uhaHc8Q== X-Received: by 2002:adf:f304:: with SMTP id i4mr17619843wro.268.1605105516778; Wed, 11 Nov 2020 06:38:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 06:38:36 -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 8/8] venus: helpers: Delete unused stop streaming helper Date: Wed, 11 Nov 2020 16:37:55 +0200 Message-Id: <20201111143755.24541-9-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 After re-design of encoder driver this helper is not needed anymore. Signed-off-by: Stanimir Varbanov Reviewed-by: Fritz Koenig --- 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 490c026b58a3..51c80417f361 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1406,49 +1406,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 231af29667e7..3eae2acbcc8e 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);