mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 22:26:55 +00:00
media: mediatek: vcodec: Get the chip name for each platform
Store the name of the chip in the context of the driver in order to be able to choose the correct configuration values for the different codecs. Use a enum value instead of an integer to store a more descriptive name. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com> Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
parent
3591c53ae9
commit
8830bf13af
3 changed files with 41 additions and 23 deletions
|
@ -208,36 +208,14 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv,
|
||||||
return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
|
return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mtk_vcodec_dec_get_chip_name(void *priv)
|
|
||||||
{
|
|
||||||
struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
|
|
||||||
struct device *dev = &ctx->dev->plat_dev->dev;
|
|
||||||
|
|
||||||
if (of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-dec"))
|
|
||||||
return 8173;
|
|
||||||
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8183-vcodec-dec"))
|
|
||||||
return 8183;
|
|
||||||
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8192-vcodec-dec"))
|
|
||||||
return 8192;
|
|
||||||
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8195-vcodec-dec"))
|
|
||||||
return 8195;
|
|
||||||
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8186-vcodec-dec"))
|
|
||||||
return 8186;
|
|
||||||
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8188-vcodec-dec"))
|
|
||||||
return 8188;
|
|
||||||
else
|
|
||||||
return 8173;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vidioc_vdec_querycap(struct file *file, void *priv,
|
static int vidioc_vdec_querycap(struct file *file, void *priv,
|
||||||
struct v4l2_capability *cap)
|
struct v4l2_capability *cap)
|
||||||
{
|
{
|
||||||
struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
|
struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
|
||||||
struct device *dev = &ctx->dev->plat_dev->dev;
|
struct device *dev = &ctx->dev->plat_dev->dev;
|
||||||
int platform_name = mtk_vcodec_dec_get_chip_name(priv);
|
|
||||||
|
|
||||||
strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
|
strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
|
||||||
snprintf(cap->card, sizeof(cap->card), "MT%d video decoder", platform_name);
|
snprintf(cap->card, sizeof(cap->card), "MT%d video decoder", ctx->dev->chip_name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,6 +326,26 @@ static const struct v4l2_file_operations mtk_vcodec_fops = {
|
||||||
.mmap = v4l2_m2m_fop_mmap,
|
.mmap = v4l2_m2m_fop_mmap,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void mtk_vcodec_dec_get_chip_name(struct mtk_vcodec_dec_dev *vdec_dev)
|
||||||
|
{
|
||||||
|
struct device *dev = &vdec_dev->plat_dev->dev;
|
||||||
|
|
||||||
|
if (of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-dec"))
|
||||||
|
vdec_dev->chip_name = MTK_VDEC_MT8173;
|
||||||
|
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8183-vcodec-dec"))
|
||||||
|
vdec_dev->chip_name = MTK_VDEC_MT8183;
|
||||||
|
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8192-vcodec-dec"))
|
||||||
|
vdec_dev->chip_name = MTK_VDEC_MT8192;
|
||||||
|
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8195-vcodec-dec"))
|
||||||
|
vdec_dev->chip_name = MTK_VDEC_MT8195;
|
||||||
|
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8186-vcodec-dec"))
|
||||||
|
vdec_dev->chip_name = MTK_VDEC_MT8186;
|
||||||
|
else if (of_device_is_compatible(dev->of_node, "mediatek,mt8188-vcodec-dec"))
|
||||||
|
vdec_dev->chip_name = MTK_VDEC_MT8188;
|
||||||
|
else
|
||||||
|
vdec_dev->chip_name = MTK_VDEC_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
static int mtk_vcodec_probe(struct platform_device *pdev)
|
static int mtk_vcodec_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct mtk_vcodec_dec_dev *dev;
|
struct mtk_vcodec_dec_dev *dev;
|
||||||
|
@ -341,6 +361,12 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
|
||||||
INIT_LIST_HEAD(&dev->ctx_list);
|
INIT_LIST_HEAD(&dev->ctx_list);
|
||||||
dev->plat_dev = pdev;
|
dev->plat_dev = pdev;
|
||||||
|
|
||||||
|
mtk_vcodec_dec_get_chip_name(dev);
|
||||||
|
if (dev->chip_name == MTK_VDEC_INVAL) {
|
||||||
|
dev_err(&pdev->dev, "Failed to get decoder chip name");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
dev->vdec_pdata = of_device_get_match_data(&pdev->dev);
|
dev->vdec_pdata = of_device_get_match_data(&pdev->dev);
|
||||||
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)) {
|
||||||
|
|
|
@ -18,6 +18,16 @@
|
||||||
#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
|
#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
|
||||||
#define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING)
|
#define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING)
|
||||||
|
|
||||||
|
enum mtk_vcodec_dec_chip_name {
|
||||||
|
MTK_VDEC_INVAL = 0,
|
||||||
|
MTK_VDEC_MT8173 = 8173,
|
||||||
|
MTK_VDEC_MT8183 = 8183,
|
||||||
|
MTK_VDEC_MT8186 = 8186,
|
||||||
|
MTK_VDEC_MT8188 = 8188,
|
||||||
|
MTK_VDEC_MT8192 = 8192,
|
||||||
|
MTK_VDEC_MT8195 = 8195,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* enum mtk_vdec_format_types - Structure used to get supported
|
* enum mtk_vdec_format_types - Structure used to get supported
|
||||||
* format types according to decoder capability
|
* format types according to decoder capability
|
||||||
|
@ -249,6 +259,8 @@ struct mtk_vcodec_dec_ctx {
|
||||||
* @vdec_racing_info: record register value
|
* @vdec_racing_info: record register value
|
||||||
* @dec_racing_info_mutex: mutex lock used for inner racing mode
|
* @dec_racing_info_mutex: mutex lock used for inner racing mode
|
||||||
* @dbgfs: debug log related information
|
* @dbgfs: debug log related information
|
||||||
|
*
|
||||||
|
* @chip_name: used to distinguish platforms and select the correct codec configuration values
|
||||||
*/
|
*/
|
||||||
struct mtk_vcodec_dec_dev {
|
struct mtk_vcodec_dec_dev {
|
||||||
struct v4l2_device v4l2_dev;
|
struct v4l2_device v4l2_dev;
|
||||||
|
@ -289,6 +301,8 @@ struct mtk_vcodec_dec_dev {
|
||||||
/* Protects access to vdec_racing_info data */
|
/* Protects access to vdec_racing_info data */
|
||||||
struct mutex dec_racing_info_mutex;
|
struct mutex dec_racing_info_mutex;
|
||||||
struct mtk_vcodec_dbgfs dbgfs;
|
struct mtk_vcodec_dbgfs dbgfs;
|
||||||
|
|
||||||
|
enum mtk_vcodec_dec_chip_name chip_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx(struct v4l2_fh *fh)
|
static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx(struct v4l2_fh *fh)
|
||||||
|
|
Loading…
Reference in a new issue