mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-16 10:06:44 +07:00
media: mtk-vcodec: add SCP firmware ops
Add support for communicating with the SCP firmware, which will be used by MT8183. [acourbot: refactor, cleanup and split] [hverkuil: fixed some checkpatch alignment warnings] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Co-developed-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Acked-by: Tiffany Lin <tiffany.lin@mediatek.com> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
97b022a828
commit
c7244811b1
@ -256,6 +256,7 @@ config VIDEO_MEDIATEK_VCODEC
|
|||||||
select VIDEOBUF2_DMA_CONTIG
|
select VIDEOBUF2_DMA_CONTIG
|
||||||
select V4L2_MEM2MEM_DEV
|
select V4L2_MEM2MEM_DEV
|
||||||
select VIDEO_MEDIATEK_VPU
|
select VIDEO_MEDIATEK_VPU
|
||||||
|
select MTK_SCP
|
||||||
help
|
help
|
||||||
Mediatek video codec driver provides HW capability to
|
Mediatek video codec driver provides HW capability to
|
||||||
encode and decode in a range of video formats
|
encode and decode in a range of video formats
|
||||||
|
@ -225,6 +225,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
|
|||||||
if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
|
if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
|
||||||
&rproc_phandle)) {
|
&rproc_phandle)) {
|
||||||
fw_type = VPU;
|
fw_type = VPU;
|
||||||
|
} else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
|
||||||
|
&rproc_phandle)) {
|
||||||
|
fw_type = SCP;
|
||||||
} else {
|
} else {
|
||||||
mtk_v4l2_err("Could not get vdec IPI device");
|
mtk_v4l2_err("Could not get vdec IPI device");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -233,6 +233,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
|
|||||||
if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
|
if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu",
|
||||||
&rproc_phandle)) {
|
&rproc_phandle)) {
|
||||||
fw_type = VPU;
|
fw_type = VPU;
|
||||||
|
} else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp",
|
||||||
|
&rproc_phandle)) {
|
||||||
|
fw_type = SCP;
|
||||||
} else {
|
} else {
|
||||||
mtk_v4l2_err("Could not get venc IPI device");
|
mtk_v4l2_err("Could not get venc IPI device");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -19,6 +19,7 @@ struct mtk_vcodec_fw {
|
|||||||
enum mtk_vcodec_fw_type type;
|
enum mtk_vcodec_fw_type type;
|
||||||
const struct mtk_vcodec_fw_ops *ops;
|
const struct mtk_vcodec_fw_ops *ops;
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
|
struct mtk_scp *scp;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
|
static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
|
||||||
@ -72,6 +73,49 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = {
|
|||||||
.ipi_send = mtk_vcodec_vpu_ipi_send,
|
.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)
|
static void mtk_vcodec_reset_handler(void *priv)
|
||||||
{
|
{
|
||||||
struct mtk_vcodec_dev *dev = priv;
|
struct mtk_vcodec_dev *dev = priv;
|
||||||
@ -95,6 +139,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev,
|
|||||||
const struct mtk_vcodec_fw_ops *ops;
|
const struct mtk_vcodec_fw_ops *ops;
|
||||||
struct mtk_vcodec_fw *fw;
|
struct mtk_vcodec_fw *fw;
|
||||||
struct platform_device *fw_pdev = NULL;
|
struct platform_device *fw_pdev = NULL;
|
||||||
|
struct mtk_scp *scp = NULL;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VPU:
|
case VPU:
|
||||||
@ -107,6 +152,14 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev,
|
|||||||
vpu_wdt_reg_handler(fw_pdev, mtk_vcodec_reset_handler,
|
vpu_wdt_reg_handler(fw_pdev, mtk_vcodec_reset_handler,
|
||||||
dev, rst_id);
|
dev, rst_id);
|
||||||
break;
|
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:
|
default:
|
||||||
mtk_v4l2_err("invalid vcodec fw type");
|
mtk_v4l2_err("invalid vcodec fw type");
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@ -119,6 +172,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev,
|
|||||||
fw->type = type;
|
fw->type = type;
|
||||||
fw->ops = ops;
|
fw->ops = ops;
|
||||||
fw->pdev = fw_pdev;
|
fw->pdev = fw_pdev;
|
||||||
|
fw->scp = scp;
|
||||||
|
|
||||||
return fw;
|
return fw;
|
||||||
}
|
}
|
||||||
@ -130,6 +184,9 @@ void mtk_vcodec_fw_release(struct mtk_vcodec_fw *fw)
|
|||||||
case VPU:
|
case VPU:
|
||||||
put_device(&fw->pdev->dev);
|
put_device(&fw->pdev->dev);
|
||||||
break;
|
break;
|
||||||
|
case SCP:
|
||||||
|
scp_put(fw->scp);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mtk_vcodec_fw_release);
|
EXPORT_SYMBOL_GPL(mtk_vcodec_fw_release);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define _MTK_VCODEC_FW_H_
|
#define _MTK_VCODEC_FW_H_
|
||||||
|
|
||||||
#include <linux/remoteproc.h>
|
#include <linux/remoteproc.h>
|
||||||
|
#include <linux/remoteproc/mtk_scp.h>
|
||||||
|
|
||||||
#include "../mtk-vpu/mtk_vpu.h"
|
#include "../mtk-vpu/mtk_vpu.h"
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ struct mtk_vcodec_dev;
|
|||||||
|
|
||||||
enum mtk_vcodec_fw_type {
|
enum mtk_vcodec_fw_type {
|
||||||
VPU,
|
VPU,
|
||||||
|
SCP,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mtk_vcodec_fw;
|
struct mtk_vcodec_fw;
|
||||||
|
Loading…
Reference in New Issue
Block a user