Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp745657ybh; Sun, 12 Jul 2020 23:12:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlcbb7EB1uG5zYAGa6m2/rhD04iPN5RSRPWm8aS21iIGJ+HQymbnbyiSAtnRABk8g1OKR9 X-Received: by 2002:a17:906:82d2:: with SMTP id a18mr70796940ejy.522.1594620721309; Sun, 12 Jul 2020 23:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594620721; cv=none; d=google.com; s=arc-20160816; b=JZHH9lAZ6LS/hwUiZgmxmv2yYM+gsX9aZ0pi/TkG0V+RIS8mzY2+vPidktiPmv4meB CEXYZHAmEeGlAiAL4eP9Ae5w2BKJ0RsPPy+h3/05AGyQzl3P+1oH0AXiIAy66wdfTxxM sle0mEswdBlT8+azdDMASwFd6qgt8rg77s5ENfUvRohVr0t2hlGCxa5xmMYxD5glxF/h 7C8VrNaOgcodZ0EwZT7HNvgpNrZRTlkHCzCCZFXS+zOcRnQCqhF/sWQavH6mnG/0di4q QE1BbNP/J6C0H1KY7VgIhxGWa1zhGh3cDt6Eo3FOWUsxEP1aDmwOjYgnwPIakIsUVLgE Xn8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=od+s8D7sQgTmw85zfRSLd23Y+ImDYFPzNWcvRKsmRCA=; b=opDFiGQnJaLR7xQgwYQ+ByOOXZ8DM9NhvQ3UZJKWGZRfnkjT79UACs+IdMdB7FW5Pl p6Z+x7vhMhiuTWwQ/LKl6rKJe2JuUS/Fynja5PouB4p3dOpvanZFMJYxv2oISFGiG0uN 1sQZP/vFiPiQHjDhzT5J9RWb4d+JwfGUuDrpjdlFB+btp6tuq7M7i22Sxe9scoFnC6ZI vUv9dPjxn/Vo4F0rNaegTwSV8YKdeSS3GN1d47rp6uI2jPlRofHRNzfGhlvJOWc2d8GL +PsQTrGFr5cBvPJcOLbmvMS6oAeDSfXMGtXUxCj1nViC2q0yQVexh9aylnU7eba452cx ygzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Aai3HAWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr25si8330150ejb.622.2020.07.12.23.11.38; Sun, 12 Jul 2020 23:12:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Aai3HAWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729175AbgGMGJZ (ORCPT + 99 others); Mon, 13 Jul 2020 02:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729148AbgGMGJT (ORCPT ); Mon, 13 Jul 2020 02:09:19 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB744C08C5DD for ; Sun, 12 Jul 2020 23:09:19 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id z5so5577804pgb.6 for ; Sun, 12 Jul 2020 23:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=od+s8D7sQgTmw85zfRSLd23Y+ImDYFPzNWcvRKsmRCA=; b=Aai3HAWxaz+GjbxPniSs9/JhAru3ScS+cyevS+ZxJ/l5ccQVp9CucQqLRC/b8i9m0g pPkCrb3A6OEQhRzJos63eQ85MSK7RlhNH4iHm2a4TMuJXRFvZ8EuJ2ZC/JxKdzw2uFtr gUd66HFgfByRQnCCefpO5/pBFw0SPpKnIU8Jc= 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:mime-version:content-transfer-encoding; bh=od+s8D7sQgTmw85zfRSLd23Y+ImDYFPzNWcvRKsmRCA=; b=WusEWrxu+FEJkm0ldLzAE1zCK5AxqwkW791aTDZINO6qIY21EJeRQS5YYjqX9Y0nbv wRc3Ea5MN4FTc6+08IBu1zsMGmHWNpc48vnKqRTI6rYySRBxzjhIthBIy0pvzhiUG9IT SY6TIYW87/1Fdv1zpb0CVM67E8fUaJqgpPUlSfog+3H2+7OhAx+kZzA+f9Q0YRIyaePh ugZ3pXe+sjNmudNyVhq1/lG1gTCgGBXl/lbJ6uj0EjpINsQI6aM+7n19xkcAJyja8Tsl Hr2Jz8YfNfFsUzWhHFoic3ewIPCdfEqYI4aRnijWAJ+tWrIfslrTocLMQXKE5jFz8l/P 4KTQ== X-Gm-Message-State: AOAM531ditFAeWbHwi49NH9vq/nY2cYTlaxOCvu7/4gTTng6Bk0E7Khx iwPqhlnn0yBFzE15Tc8CpUUF1g== X-Received: by 2002:a63:b06:: with SMTP id 6mr65423158pgl.116.1594620559230; Sun, 12 Jul 2020 23:09:19 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:8f:203:eeb1:d7ff:fe57:b7e5]) by smtp.gmail.com with ESMTPSA id c134sm13134934pfc.115.2020.07.12.23.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:09:18 -0700 (PDT) From: Alexandre Courbot To: Tiffany Lin , Andrew-CT Chen , Hans Verkuil , Yunfei Dong , Maoguang Meng Cc: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot Subject: [PATCH v3 03/16] media: mtk-vcodec: add SCP firmware ops Date: Mon, 13 Jul 2020 15:08:29 +0900 Message-Id: <20200713060842.471356-4-acourbot@chromium.org> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200713060842.471356-1-acourbot@chromium.org> References: <20200713060842.471356-1-acourbot@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunfei Dong Add support for communicating with the SCP firmware, which will be used by MT8183. Signed-off-by: Yunfei Dong [acourbot: refactor, cleanup and split] Co-developed-by: Alexandre Courbot Signed-off-by: Alexandre Courbot Acked-by: Tiffany Lin --- drivers/media/platform/Kconfig | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 3 + .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 3 + .../media/platform/mtk-vcodec/mtk_vcodec_fw.c | 56 +++++++++++++++++++ .../media/platform/mtk-vcodec/mtk_vcodec_fw.h | 2 + 5 files changed, 65 insertions(+) diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index c57ee78fa99d..f0dbe048efea 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -256,6 +256,7 @@ config VIDEO_MEDIATEK_VCODEC select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV select VIDEO_MEDIATEK_VPU + select MTK_SCP help Mediatek video codec driver provides HW capability to encode and decode in a range of video formats diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 4f07a5fcce7f..5b5765b98e57 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -225,6 +225,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev) if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu", &rproc_phandle)) { fw_type = VPU; + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp", + &rproc_phandle)) { + fw_type = SCP; } else { mtk_v4l2_err("Could not get vdec IPI device"); return -ENODEV; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c index 4340ea10afd0..42530cd01a30 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c @@ -233,6 +233,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev) if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu", &rproc_phandle)) { fw_type = VPU; + } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp", + &rproc_phandle)) { + fw_type = SCP; } else { mtk_v4l2_err("Could not get venc IPI device"); return -ENODEV; diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c index 967bb100a990..f2a62ea62fc6 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c @@ -19,6 +19,7 @@ struct mtk_vcodec_fw { enum mtk_vcodec_fw_type type; const struct mtk_vcodec_fw_ops *ops; struct platform_device *pdev; + struct mtk_scp *scp; }; static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw) @@ -71,6 +72,48 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = { .ipi_send = mtk_vcodec_vpu_ipi_send, }; +static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw) +{ + return rproc_boot(scp_get_rproc(fw->scp)); +} + +static unsigned int mtk_vcodec_scp_get_vdec_capa(struct mtk_vcodec_fw *fw) +{ + return scp_get_vdec_hw_capa(fw->scp); +} + +static unsigned int mtk_vcodec_scp_get_venc_capa(struct mtk_vcodec_fw *fw) +{ + return scp_get_venc_hw_capa(fw->scp); +} + +static void *mtk_vcodec_vpu_scp_dm_addr(struct mtk_vcodec_fw *fw, + u32 dtcm_dmem_addr) +{ + return scp_mapping_dm_addr(fw->scp, dtcm_dmem_addr); +} + +static int mtk_vcodec_scp_set_ipi_register(struct mtk_vcodec_fw *fw, int id, + mtk_vcodec_ipi_handler handler, const char *name, void *priv) +{ + return scp_ipi_register(fw->scp, id, handler, priv); +} + +static int mtk_vcodec_scp_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf, + unsigned int len, unsigned int wait) +{ + return scp_ipi_send(fw->scp, id, buf, len, wait); +} + +static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = { + .load_firmware = mtk_vcodec_scp_load_firmware, + .get_vdec_capa = mtk_vcodec_scp_get_vdec_capa, + .get_venc_capa = mtk_vcodec_scp_get_venc_capa, + .map_dm_addr = mtk_vcodec_vpu_scp_dm_addr, + .ipi_register = mtk_vcodec_scp_set_ipi_register, + .ipi_send = mtk_vcodec_scp_ipi_send, +}; + static void mtk_vcodec_reset_handler(void *priv) { struct mtk_vcodec_dev *dev = priv; @@ -94,6 +137,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev, const struct mtk_vcodec_fw_ops *ops; struct mtk_vcodec_fw *fw; struct platform_device *fw_pdev = NULL; + struct mtk_scp *scp = NULL; switch (type) { case VPU: @@ -106,6 +150,14 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev, vpu_wdt_reg_handler(fw_pdev, mtk_vcodec_reset_handler, dev, rst_id); break; + case SCP: + ops = &mtk_vcodec_rproc_msg; + scp = scp_get(dev->plat_dev); + if (!scp) { + mtk_v4l2_err("could not get vdec scp handle"); + return ERR_PTR(-EPROBE_DEFER); + } + break; default: mtk_v4l2_err("invalid vcodec fw type"); return ERR_PTR(-EINVAL); @@ -118,6 +170,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev, fw->type = type; fw->ops = ops; fw->pdev = fw_pdev; + fw->scp = scp; return fw; } @@ -129,6 +182,9 @@ void mtk_vcodec_fw_release(struct mtk_vcodec_fw *fw) case VPU: put_device(&fw->pdev->dev); break; + case SCP: + scp_put(fw->scp); + break; } } EXPORT_SYMBOL_GPL(mtk_vcodec_fw_release); diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h index ff25b0c19f74..ced1b6a10e07 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h @@ -4,6 +4,7 @@ #define _MTK_VCODEC_FW_H_ #include +#include #include "../mtk-vpu/mtk_vpu.h" @@ -11,6 +12,7 @@ struct mtk_vcodec_dev; enum mtk_vcodec_fw_type { VPU, + SCP, }; struct mtk_vcodec_fw; -- 2.27.0.383.g050319c2ae-goog