Commit 41f03c67 authored by Yunfei Dong's avatar Yunfei Dong Committed by Mauro Carvalho Chehab

media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message

Adding different macro mtk_v4l2_vdec_dbg and mtk_v4l2_venc_dbg for
encoder and decoder. Then calling the common macro mtk_v4l2_debug to
print debug message.

Replace pr_err with dev_err for 'mtk_v4l2_err' debug message.
Replace pr_debug with dev_dbg for 'mtk_v4l2_debug' debug message.
Signed-off-by: default avatarYunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 0db2fc4e
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "mtk_vcodec_util.h" #include "mtk_vcodec_util.h"
#include "mtk_vcodec_fw.h" #include "mtk_vcodec_fw.h"
static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev) static int mtk_vcodec_get_hw_count(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_dev *dev)
{ {
switch (dev->vdec_pdata->hw_arch) { switch (dev->vdec_pdata->hw_arch) {
case MTK_VDEC_PURE_SINGLE_CORE: case MTK_VDEC_PURE_SINGLE_CORE:
...@@ -37,7 +37,7 @@ static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev) ...@@ -37,7 +37,7 @@ static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev)
case MTK_VDEC_LAT_SINGLE_CORE: case MTK_VDEC_LAT_SINGLE_CORE:
return MTK_VDEC_ONE_LAT_ONE_CORE; return MTK_VDEC_ONE_LAT_ONE_CORE;
default: default:
mtk_v4l2_err("hw arch %d not supported", dev->vdec_pdata->hw_arch); mtk_v4l2_vdec_err(ctx, "hw arch %d not supported", dev->vdec_pdata->hw_arch);
return MTK_VDEC_NO_HW; return MTK_VDEC_NO_HW;
} }
} }
...@@ -65,7 +65,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv) ...@@ -65,7 +65,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
ctx = mtk_vcodec_get_curr_ctx(dev, MTK_VDEC_CORE); ctx = mtk_vcodec_get_curr_ctx(dev, MTK_VDEC_CORE);
if (!mtk_vcodec_is_hw_active(dev)) { if (!mtk_vcodec_is_hw_active(dev)) {
mtk_v4l2_err("DEC ISR, VDEC active is not 0x0"); mtk_v4l2_vdec_err(ctx, "DEC ISR, VDEC active is not 0x0");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -83,9 +83,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv) ...@@ -83,9 +83,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, 0); wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, 0);
mtk_v4l2_debug(3, mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=%x", ctx->id, dec_done_status);
"mtk_vcodec_dec_irq_handler :wake up ctx %d, dec_done_status=%x",
ctx->id, dec_done_status);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -140,7 +138,7 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev) ...@@ -140,7 +138,7 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
if (IS_ERR(dev->reg_base[i])) if (IS_ERR(dev->reg_base[i]))
return PTR_ERR(dev->reg_base[i]); return PTR_ERR(dev->reg_base[i]);
mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]); dev_dbg(&pdev->dev, "reg[%d] base=%p", i, dev->reg_base[i]);
} }
} else { } else {
for (i = 0; i < reg_num; i++) { for (i = 0; i < reg_num; i++) {
...@@ -148,7 +146,7 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev) ...@@ -148,7 +146,7 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
if (IS_ERR(dev->reg_base[i+1])) if (IS_ERR(dev->reg_base[i+1]))
return PTR_ERR(dev->reg_base[i+1]); return PTR_ERR(dev->reg_base[i+1]);
mtk_v4l2_debug(2, "reg[%d] base=%p", i+1, dev->reg_base[i+1]); dev_dbg(&pdev->dev, "reg[%d] base=%p", i + 1, dev->reg_base[i + 1]);
} }
dev->vdecsys_regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, dev->vdecsys_regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
...@@ -216,7 +214,7 @@ static int fops_vcodec_open(struct file *file) ...@@ -216,7 +214,7 @@ static int fops_vcodec_open(struct file *file)
INIT_LIST_HEAD(&ctx->list); INIT_LIST_HEAD(&ctx->list);
ctx->dev = dev; ctx->dev = dev;
if (ctx->dev->vdec_pdata->is_subdev_supported) { if (ctx->dev->vdec_pdata->is_subdev_supported) {
hw_count = mtk_vcodec_get_hw_count(dev); hw_count = mtk_vcodec_get_hw_count(ctx, dev);
if (!hw_count || !dev->subdev_prob_done) { if (!hw_count || !dev->subdev_prob_done) {
ret = -EINVAL; ret = -EINVAL;
goto err_ctrls_setup; goto err_ctrls_setup;
...@@ -236,15 +234,14 @@ static int fops_vcodec_open(struct file *file) ...@@ -236,15 +234,14 @@ static int fops_vcodec_open(struct file *file)
ctx->type = MTK_INST_DECODER; ctx->type = MTK_INST_DECODER;
ret = dev->vdec_pdata->ctrls_setup(ctx); ret = dev->vdec_pdata->ctrls_setup(ctx);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to setup mt vcodec controls"); mtk_v4l2_vdec_err(ctx, "Failed to setup mt vcodec controls");
goto err_ctrls_setup; goto err_ctrls_setup;
} }
ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_dec, ctx, ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_dec, ctx,
&mtk_vcodec_dec_queue_init); &mtk_vcodec_dec_queue_init);
if (IS_ERR((__force void *)ctx->m2m_ctx)) { if (IS_ERR((__force void *)ctx->m2m_ctx)) {
ret = PTR_ERR((__force void *)ctx->m2m_ctx); ret = PTR_ERR((__force void *)ctx->m2m_ctx);
mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)", mtk_v4l2_vdec_err(ctx, "Failed to v4l2_m2m_ctx_init() (%d)", ret);
ret);
goto err_m2m_ctx_init; goto err_m2m_ctx_init;
} }
src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx, src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
...@@ -262,14 +259,14 @@ static int fops_vcodec_open(struct file *file) ...@@ -262,14 +259,14 @@ static int fops_vcodec_open(struct file *file)
* Return 0 if downloading firmware successfully, * Return 0 if downloading firmware successfully,
* otherwise it is failed * otherwise it is failed
*/ */
mtk_v4l2_err("failed to load firmware!"); mtk_v4l2_vdec_err(ctx, "failed to load firmware!");
goto err_load_fw; goto err_load_fw;
} }
dev->dec_capability = dev->dec_capability =
mtk_vcodec_fw_get_vdec_capa(dev->fw_handler); mtk_vcodec_fw_get_vdec_capa(dev->fw_handler);
mtk_v4l2_debug(0, "decoder capability %x", dev->dec_capability); mtk_v4l2_vdec_dbg(0, ctx, "decoder capability %x", dev->dec_capability);
} }
ctx->dev->vdec_pdata->init_vdec_params(ctx); ctx->dev->vdec_pdata->init_vdec_params(ctx);
...@@ -278,8 +275,7 @@ static int fops_vcodec_open(struct file *file) ...@@ -278,8 +275,7 @@ static int fops_vcodec_open(struct file *file)
mtk_vcodec_dbgfs_create(ctx); mtk_vcodec_dbgfs_create(ctx);
mutex_unlock(&dev->dev_mutex); mutex_unlock(&dev->dev_mutex);
mtk_v4l2_debug(0, "%s decoder [%d]", dev_name(&dev->plat_dev->dev), mtk_v4l2_vdec_dbg(0, ctx, "%s decoder [%d]", dev_name(&dev->plat_dev->dev), ctx->id);
ctx->id);
return ret; return ret;
/* Deinit when failure occurred */ /* Deinit when failure occurred */
...@@ -301,7 +297,7 @@ static int fops_vcodec_release(struct file *file) ...@@ -301,7 +297,7 @@ static int fops_vcodec_release(struct file *file)
struct mtk_vcodec_dev *dev = video_drvdata(file); struct mtk_vcodec_dev *dev = video_drvdata(file);
struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data); struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
mtk_v4l2_debug(0, "[%d] decoder", ctx->id); mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id);
mutex_lock(&dev->dev_mutex); mutex_lock(&dev->dev_mutex);
/* /*
...@@ -356,7 +352,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -356,7 +352,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
&rproc_phandle)) { &rproc_phandle)) {
fw_type = SCP; fw_type = SCP;
} else { } else {
mtk_v4l2_err("Could not get vdec IPI device"); dev_dbg(&pdev->dev, "Could not get vdec IPI device");
return -ENODEV; return -ENODEV;
} }
dma_set_max_seg_size(&pdev->dev, UINT_MAX); dma_set_max_seg_size(&pdev->dev, UINT_MAX);
...@@ -376,7 +372,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -376,7 +372,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
alloc_ordered_workqueue("core-decoder", alloc_ordered_workqueue("core-decoder",
WQ_MEM_RECLAIM | WQ_FREEZABLE); WQ_MEM_RECLAIM | WQ_FREEZABLE);
if (!dev->core_workqueue) { if (!dev->core_workqueue) {
mtk_v4l2_err("Failed to create core workqueue"); dev_dbg(&pdev->dev, "Failed to create core workqueue");
ret = -EINVAL; ret = -EINVAL;
goto err_res; goto err_res;
} }
...@@ -392,13 +388,13 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -392,13 +388,13 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
if (ret) { if (ret) {
mtk_v4l2_err("v4l2_device_register err=%d", ret); dev_err(&pdev->dev, "v4l2_device_register err=%d", ret);
goto err_core_workq; goto err_core_workq;
} }
vfd_dec = video_device_alloc(); vfd_dec = video_device_alloc();
if (!vfd_dec) { if (!vfd_dec) {
mtk_v4l2_err("Failed to allocate video device"); dev_err(&pdev->dev, "Failed to allocate video device");
ret = -ENOMEM; ret = -ENOMEM;
goto err_dec_alloc; goto err_dec_alloc;
} }
...@@ -419,7 +415,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -419,7 +415,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
dev->m2m_dev_dec = v4l2_m2m_init(&mtk_vdec_m2m_ops); dev->m2m_dev_dec = v4l2_m2m_init(&mtk_vdec_m2m_ops);
if (IS_ERR((__force void *)dev->m2m_dev_dec)) { if (IS_ERR((__force void *)dev->m2m_dev_dec)) {
mtk_v4l2_err("Failed to init mem2mem dec device"); dev_err(&pdev->dev, "Failed to init mem2mem dec device");
ret = PTR_ERR((__force void *)dev->m2m_dev_dec); ret = PTR_ERR((__force void *)dev->m2m_dev_dec);
goto err_dec_alloc; goto err_dec_alloc;
} }
...@@ -428,7 +424,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -428,7 +424,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
alloc_ordered_workqueue(MTK_VCODEC_DEC_NAME, alloc_ordered_workqueue(MTK_VCODEC_DEC_NAME,
WQ_MEM_RECLAIM | WQ_FREEZABLE); WQ_MEM_RECLAIM | WQ_FREEZABLE);
if (!dev->decode_workqueue) { if (!dev->decode_workqueue) {
mtk_v4l2_err("Failed to create decode workqueue"); dev_err(&pdev->dev, "Failed to create decode workqueue");
ret = -EINVAL; ret = -EINVAL;
goto err_event_workq; goto err_event_workq;
} }
...@@ -437,7 +433,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -437,7 +433,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, ret = of_platform_populate(pdev->dev.of_node, NULL, NULL,
&pdev->dev); &pdev->dev);
if (ret) { if (ret) {
mtk_v4l2_err("Main device of_platform_populate failed."); dev_err(&pdev->dev, "Main device of_platform_populate failed.");
goto err_reg_cont; goto err_reg_cont;
} }
} else { } else {
...@@ -450,7 +446,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -450,7 +446,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, -1); ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, -1);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to register video device"); dev_err(&pdev->dev, "Failed to register video device");
goto err_reg_cont; goto err_reg_cont;
} }
...@@ -469,21 +465,21 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -469,21 +465,21 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec, dev->vfd_dec, ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec, dev->vfd_dec,
MEDIA_ENT_F_PROC_VIDEO_DECODER); MEDIA_ENT_F_PROC_VIDEO_DECODER);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to register media controller"); dev_err(&pdev->dev, "Failed to register media controller");
goto err_dec_mem_init; goto err_dec_mem_init;
} }
ret = media_device_register(&dev->mdev_dec); ret = media_device_register(&dev->mdev_dec);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to register media device"); dev_err(&pdev->dev, "Failed to register media device");
goto err_media_reg; goto err_media_reg;
} }
mtk_v4l2_debug(0, "media registered as /dev/media%d", vfd_dec->minor); dev_dbg(&pdev->dev, "media registered as /dev/media%d", vfd_dec->minor);
} }
mtk_vcodec_dbgfs_init(dev, false); mtk_vcodec_dbgfs_init(dev, false);
mtk_v4l2_debug(0, "decoder registered as /dev/video%d", vfd_dec->minor); dev_dbg(&pdev->dev, "decoder registered as /dev/video%d", vfd_dec->minor);
return 0; return 0;
......
...@@ -77,8 +77,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv) ...@@ -77,8 +77,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv)
/* check if HW active or not */ /* check if HW active or not */
cg_status = readl(dev->reg_base[VDEC_HW_SYS] + VDEC_HW_ACTIVE_ADDR); cg_status = readl(dev->reg_base[VDEC_HW_SYS] + VDEC_HW_ACTIVE_ADDR);
if (cg_status & VDEC_HW_ACTIVE_MASK) { if (cg_status & VDEC_HW_ACTIVE_MASK) {
mtk_v4l2_err("vdec active is not 0x0 (0x%08x)", mtk_v4l2_vdec_err(ctx, "vdec active is not 0x0 (0x%08x)", cg_status);
cg_status);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -93,8 +92,8 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv) ...@@ -93,8 +92,8 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv)
wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx); wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx);
mtk_v4l2_debug(3, "wake up ctx %d, dec_done_status=%x", mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=%x",
ctx->id, dec_done_status); ctx->id, dec_done_status);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -31,7 +31,7 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm * ...@@ -31,7 +31,7 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
if (!dec_clk->clk_info) if (!dec_clk->clk_info)
return -ENOMEM; return -ENOMEM;
} else { } else {
mtk_v4l2_err("Failed to get vdec clock count"); dev_err(&pdev->dev, "Failed to get vdec clock count");
return -EINVAL; return -EINVAL;
} }
...@@ -40,14 +40,13 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm * ...@@ -40,14 +40,13 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
ret = of_property_read_string_index(pdev->dev.of_node, ret = of_property_read_string_index(pdev->dev.of_node,
"clock-names", i, &clk_info->clk_name); "clock-names", i, &clk_info->clk_name);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to get clock name id = %d", i); dev_err(&pdev->dev, "Failed to get clock name id = %d", i);
return ret; return ret;
} }
clk_info->vcodec_clk = devm_clk_get(&pdev->dev, clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
clk_info->clk_name); clk_info->clk_name);
if (IS_ERR(clk_info->vcodec_clk)) { if (IS_ERR(clk_info->vcodec_clk)) {
mtk_v4l2_err("devm_clk_get (%d)%s fail", i, dev_err(&pdev->dev, "devm_clk_get (%d)%s fail", i, clk_info->clk_name);
clk_info->clk_name);
return PTR_ERR(clk_info->vcodec_clk); return PTR_ERR(clk_info->vcodec_clk);
} }
} }
...@@ -62,7 +61,7 @@ static int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm) ...@@ -62,7 +61,7 @@ static int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
ret = pm_runtime_resume_and_get(pm->dev); ret = pm_runtime_resume_and_get(pm->dev);
if (ret) if (ret)
mtk_v4l2_err("pm_runtime_resume_and_get fail %d", ret); dev_err(pm->dev, "pm_runtime_resume_and_get fail %d", ret);
return ret; return ret;
} }
...@@ -73,7 +72,7 @@ static void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm) ...@@ -73,7 +72,7 @@ static void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
ret = pm_runtime_put(pm->dev); ret = pm_runtime_put(pm->dev);
if (ret && ret != -EAGAIN) if (ret && ret != -EAGAIN)
mtk_v4l2_err("pm_runtime_put fail %d", ret); dev_err(pm->dev, "pm_runtime_put fail %d", ret);
} }
static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm) static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
...@@ -85,7 +84,7 @@ static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm) ...@@ -85,7 +84,7 @@ static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
for (i = 0; i < dec_clk->clk_num; i++) { for (i = 0; i < dec_clk->clk_num; i++) {
ret = clk_prepare_enable(dec_clk->clk_info[i].vcodec_clk); ret = clk_prepare_enable(dec_clk->clk_info[i].vcodec_clk);
if (ret) { if (ret) {
mtk_v4l2_err("clk_prepare_enable %d %s fail %d", i, dev_err(pm->dev, "clk_prepare_enable %d %s fail %d", i,
dec_clk->clk_info[i].clk_name, ret); dec_clk->clk_info[i].clk_name, ret);
goto error; goto error;
} }
...@@ -119,7 +118,7 @@ static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_id ...@@ -119,7 +118,7 @@ static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_id
if (subdev_dev) if (subdev_dev)
enable_irq(subdev_dev->dec_irq); enable_irq(subdev_dev->dec_irq);
else else
mtk_v4l2_err("Failed to get hw dev\n"); dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
} else { } else {
enable_irq(vdec_dev->dec_irq); enable_irq(vdec_dev->dec_irq);
} }
...@@ -137,7 +136,7 @@ static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_i ...@@ -137,7 +136,7 @@ static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_i
if (subdev_dev) if (subdev_dev)
disable_irq(subdev_dev->dec_irq); disable_irq(subdev_dev->dec_irq);
else else
mtk_v4l2_err("Failed to get hw dev\n"); dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
} else { } else {
disable_irq(vdec_dev->dec_irq); disable_irq(vdec_dev->dec_irq);
} }
...@@ -184,7 +183,7 @@ static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev *vdec_d ...@@ -184,7 +183,7 @@ static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev *vdec_d
if (subdev_dev) if (subdev_dev)
return &subdev_dev->pm; return &subdev_dev->pm;
mtk_v4l2_err("Failed to get hw dev\n"); dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
return NULL; return NULL;
} }
......
...@@ -232,10 +232,10 @@ static void mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_ctx *ctx, int error ...@@ -232,10 +232,10 @@ static void mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_ctx *ctx, int error
vb2_dst = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); vb2_dst = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
if (vb2_dst) { if (vb2_dst) {
v4l2_m2m_buf_done(vb2_dst, state); v4l2_m2m_buf_done(vb2_dst, state);
mtk_v4l2_debug(2, "free frame buffer id:%d to done list", mtk_v4l2_vdec_dbg(2, ctx, "free frame buffer id:%d to done list",
vb2_dst->vb2_buf.index); vb2_dst->vb2_buf.index);
} else { } else {
mtk_v4l2_err("dst buffer is NULL"); mtk_v4l2_vdec_err(ctx, "dst buffer is NULL");
} }
if (src_buf_req) if (src_buf_req)
...@@ -251,7 +251,7 @@ static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx) ...@@ -251,7 +251,7 @@ static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx)
vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
if (!vb2_v4l2) { if (!vb2_v4l2) {
mtk_v4l2_debug(1, "[%d] dst_buf empty!!", ctx->id); mtk_v4l2_vdec_dbg(1, ctx, "[%d] dst_buf empty!!", ctx->id);
return NULL; return NULL;
} }
...@@ -269,9 +269,10 @@ static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx) ...@@ -269,9 +269,10 @@ static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx)
vb2_dma_contig_plane_dma_addr(dst_buf, 1); vb2_dma_contig_plane_dma_addr(dst_buf, 1);
pfb->base_c.size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[1]; pfb->base_c.size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[1];
} }
mtk_v4l2_debug(1, "id=%d Framebuf pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx frame_count = %d", mtk_v4l2_vdec_dbg(1, ctx,
dst_buf->index, pfb, pfb->base_y.va, &pfb->base_y.dma_addr, "id=%d Framebuf pfb=%p VA=%p Y/C_DMA=%pad_%pad Sz=%zx frame_count = %d",
&pfb->base_c.dma_addr, pfb->base_y.size, ctx->decoded_frame_cnt); dst_buf->index, pfb, pfb->base_y.va, &pfb->base_y.dma_addr,
&pfb->base_c.dma_addr, pfb->base_y.size, ctx->decoded_frame_cnt);
return pfb; return pfb;
} }
...@@ -300,7 +301,7 @@ static void mtk_vdec_worker(struct work_struct *work) ...@@ -300,7 +301,7 @@ static void mtk_vdec_worker(struct work_struct *work)
vb2_v4l2_src = v4l2_m2m_next_src_buf(ctx->m2m_ctx); vb2_v4l2_src = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
if (!vb2_v4l2_src) { if (!vb2_v4l2_src) {
v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
mtk_v4l2_debug(1, "[%d] no available source buffer", ctx->id); mtk_v4l2_vdec_dbg(1, ctx, "[%d] no available source buffer", ctx->id);
return; return;
} }
...@@ -309,33 +310,34 @@ static void mtk_vdec_worker(struct work_struct *work) ...@@ -309,33 +310,34 @@ static void mtk_vdec_worker(struct work_struct *work)
m2m_buf.vb); m2m_buf.vb);
bs_src = &dec_buf_src->bs_buffer; bs_src = &dec_buf_src->bs_buffer;
mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p", ctx->id, mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d, vb=%p", ctx->id,
vb2_src->vb2_queue->type, vb2_src->index, vb2_src); vb2_src->vb2_queue->type, vb2_src->index, vb2_src);
bs_src->va = vb2_plane_vaddr(vb2_src, 0); bs_src->va = vb2_plane_vaddr(vb2_src, 0);
bs_src->dma_addr = vb2_dma_contig_plane_dma_addr(vb2_src, 0); bs_src->dma_addr = vb2_dma_contig_plane_dma_addr(vb2_src, 0);
bs_src->size = (size_t)vb2_src->planes[0].bytesused; bs_src->size = (size_t)vb2_src->planes[0].bytesused;
if (!bs_src->va) { if (!bs_src->va) {
v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
mtk_v4l2_err("[%d] id=%d source buffer is NULL", ctx->id, mtk_v4l2_vdec_err(ctx, "[%d] id=%d source buffer is NULL", ctx->id,
vb2_src->index); vb2_src->index);
return; return;
} }
mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p", mtk_v4l2_vdec_dbg(3, ctx, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
ctx->id, bs_src->va, &bs_src->dma_addr, bs_src->size, vb2_src); ctx->id, bs_src->va, &bs_src->dma_addr, bs_src->size, vb2_src);
/* Apply request controls. */ /* Apply request controls. */
src_buf_req = vb2_src->req_obj.req; src_buf_req = vb2_src->req_obj.req;
if (src_buf_req) if (src_buf_req)
v4l2_ctrl_request_setup(src_buf_req, &ctx->ctrl_hdl); v4l2_ctrl_request_setup(src_buf_req, &ctx->ctrl_hdl);
else else
mtk_v4l2_err("vb2 buffer media request is NULL"); mtk_v4l2_vdec_err(ctx, "vb2 buffer media request is NULL");
ret = vdec_if_decode(ctx, bs_src, NULL, &res_chg); ret = vdec_if_decode(ctx, bs_src, NULL, &res_chg);
if (ret && ret != -EAGAIN) { if (ret && ret != -EAGAIN) {
mtk_v4l2_err(" <===[%d], src_buf[%d] sz=0x%zx pts=%llu vdec_if_decode() ret=%d res_chg=%d===>", mtk_v4l2_vdec_err(ctx,
ctx->id, vb2_src->index, bs_src->size, "[%d] decode src_buf[%d] sz=0x%zx pts=%llu ret=%d res_chg=%d",
vb2_src->timestamp, ret, res_chg); ctx->id, vb2_src->index, bs_src->size,
vb2_src->timestamp, ret, res_chg);
if (ret == -EIO) { if (ret == -EIO) {
mutex_lock(&ctx->lock); mutex_lock(&ctx->lock);
dec_buf_src->error = true; dec_buf_src->error = true;
...@@ -363,7 +365,8 @@ static void vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb) ...@@ -363,7 +365,8 @@ static void vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb)
struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
struct vb2_v4l2_buffer *vb2_v4l2 = to_vb2_v4l2_buffer(vb); struct vb2_v4l2_buffer *vb2_v4l2 = to_vb2_v4l2_buffer(vb);
mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p", ctx->id, vb->vb2_queue->type, vb->index, vb); mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d, vb=%p", ctx->id, vb->vb2_queue->type,
vb->index, vb);
mutex_lock(&ctx->lock); mutex_lock(&ctx->lock);
v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2); v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2);
...@@ -374,9 +377,9 @@ static void vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb) ...@@ -374,9 +377,9 @@ static void vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb)
/* If an OUTPUT buffer, we may need to update the state */ /* If an OUTPUT buffer, we may need to update the state */
if (ctx->state == MTK_STATE_INIT) { if (ctx->state == MTK_STATE_INIT) {
ctx->state = MTK_STATE_HEADER; ctx->state = MTK_STATE_HEADER;
mtk_v4l2_debug(1, "Init driver from init to header."); mtk_v4l2_vdec_dbg(1, ctx, "Init driver from init to header.");
} else { } else {
mtk_v4l2_debug(3, "[%d] already init driver %d", ctx->id, ctx->state); mtk_v4l2_vdec_dbg(3, ctx, "[%d] already init driver %d", ctx->id, ctx->state);
} }
} }
...@@ -393,7 +396,7 @@ static int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx) ...@@ -393,7 +396,7 @@ static int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx)
v4l2_ctrl_handler_init(&ctx->ctrl_hdl, NUM_CTRLS); v4l2_ctrl_handler_init(&ctx->ctrl_hdl, NUM_CTRLS);
if (ctx->ctrl_hdl.error) { if (ctx->ctrl_hdl.error) {
mtk_v4l2_err("v4l2_ctrl_handler_init failed\n"); mtk_v4l2_vdec_err(ctx, "v4l2_ctrl_handler_init failed\n");
return ctx->ctrl_hdl.error; return ctx->ctrl_hdl.error;
} }
...@@ -402,7 +405,8 @@ static int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx) ...@@ -402,7 +405,8 @@ static int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx)
v4l2_ctrl_new_custom(&ctx->ctrl_hdl, &cfg, NULL); v4l2_ctrl_new_custom(&ctx->ctrl_hdl, &cfg, NULL);
if (ctx->ctrl_hdl.error) { if (ctx->ctrl_hdl.error) {
mtk_v4l2_err("Adding control %d failed %d", i, ctx->ctrl_hdl.error); mtk_v4l2_vdec_err(ctx, "Adding control %d failed %d", i,
ctx->ctrl_hdl.error);
return ctx->ctrl_hdl.error; return ctx->ctrl_hdl.error;
} }
} }
...@@ -421,11 +425,11 @@ static int fops_media_request_validate(struct media_request *mreq) ...@@ -421,11 +425,11 @@ static int fops_media_request_validate(struct media_request *mreq)
/* We expect exactly one buffer with the request */ /* We expect exactly one buffer with the request */
break; break;
case 0: case 0:
mtk_v4l2_debug(1, "No buffer provided with the request"); pr_debug(MTK_DBG_VCODEC_STR "No buffer provided with the request.");
return -ENOENT; return -ENOENT;
default: default:
mtk_v4l2_debug(1, "Too many buffers (%d) provided with the request", pr_debug(MTK_DBG_VCODEC_STR "Too many buffers (%d) provided with the request.",
buffer_cnt); buffer_cnt);
return -EINVAL; return -EINVAL;
} }
...@@ -470,13 +474,13 @@ static void mtk_vcodec_add_formats(unsigned int fourcc, ...@@ -470,13 +474,13 @@ static void mtk_vcodec_add_formats(unsigned int fourcc,
mtk_video_formats[count_formats].num_planes = 2; mtk_video_formats[count_formats].num_planes = 2;
break; break;
default: default:
mtk_v4l2_err("Can not add unsupported format type"); mtk_v4l2_vdec_err(ctx, "Can not add unsupported format type");
return; return;
} }
num_formats++; num_formats++;
mtk_v4l2_debug(3, "num_formats: %d dec_capability: 0x%x", mtk_v4l2_vdec_dbg(3, ctx, "num_formats: %d dec_capability: 0x%x",
count_formats, ctx->dev->dec_capability); count_formats, ctx->dev->dec_capability);
} }
static void mtk_vcodec_get_supported_formats(struct mtk_vcodec_ctx *ctx) static void mtk_vcodec_get_supported_formats(struct mtk_vcodec_ctx *ctx)
......
...@@ -97,12 +97,11 @@ static irqreturn_t mtk_vcodec_enc_irq_handler(int irq, void *priv) ...@@ -97,12 +97,11 @@ static irqreturn_t mtk_vcodec_enc_irq_handler(int irq, void *priv)
core_id = dev->venc_pdata->core_id; core_id = dev->venc_pdata->core_id;
if (core_id < 0 || core_id >= NUM_MAX_VCODEC_REG_BASE) { if (core_id < 0 || core_id >= NUM_MAX_VCODEC_REG_BASE) {
mtk_v4l2_err("Invalid core id: %d, ctx id: %d", mtk_v4l2_venc_err(ctx, "Invalid core id: %d, ctx id: %d", core_id, ctx->id);
core_id, ctx->id);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
mtk_v4l2_debug(1, "id: %d, core id: %d", ctx->id, core_id); mtk_v4l2_venc_dbg(1, ctx, "id: %d, core id: %d", ctx->id, core_id);
addr = dev->reg_base[core_id] + MTK_VENC_IRQ_ACK_OFFSET; addr = dev->reg_base[core_id] + MTK_VENC_IRQ_ACK_OFFSET;
...@@ -143,16 +142,14 @@ static int fops_vcodec_open(struct file *file) ...@@ -143,16 +142,14 @@ static int fops_vcodec_open(struct file *file)
ctx->type = MTK_INST_ENCODER; ctx->type = MTK_INST_ENCODER;
ret = mtk_vcodec_enc_ctrls_setup(ctx); ret = mtk_vcodec_enc_ctrls_setup(ctx);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to setup controls() (%d)", mtk_v4l2_venc_err(ctx, "Failed to setup controls() (%d)", ret);
ret);
goto err_ctrls_setup; goto err_ctrls_setup;
} }
ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_enc, ctx, ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_enc, ctx,
&mtk_vcodec_enc_queue_init); &mtk_vcodec_enc_queue_init);
if (IS_ERR((__force void *)ctx->m2m_ctx)) { if (IS_ERR((__force void *)ctx->m2m_ctx)) {
ret = PTR_ERR((__force void *)ctx->m2m_ctx); ret = PTR_ERR((__force void *)ctx->m2m_ctx);
mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)", mtk_v4l2_venc_err(ctx, "Failed to v4l2_m2m_ctx_init() (%d)", ret);
ret);
goto err_m2m_ctx_init; goto err_m2m_ctx_init;
} }
src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx, src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
...@@ -171,23 +168,23 @@ static int fops_vcodec_open(struct file *file) ...@@ -171,23 +168,23 @@ static int fops_vcodec_open(struct file *file)
* Return 0 if downloading firmware successfully, * Return 0 if downloading firmware successfully,
* otherwise it is failed * otherwise it is failed
*/ */
mtk_v4l2_err("vpu_load_firmware failed!"); mtk_v4l2_venc_err(ctx, "vpu_load_firmware failed!");
goto err_load_fw; goto err_load_fw;
} }
dev->enc_capability = dev->enc_capability =
mtk_vcodec_fw_get_venc_capa(dev->fw_handler); mtk_vcodec_fw_get_venc_capa(dev->fw_handler);
mtk_v4l2_debug(0, "encoder capability %x", dev->enc_capability); mtk_v4l2_venc_dbg(0, ctx, "encoder capability %x", dev->enc_capability);
} }
mtk_v4l2_debug(2, "Create instance [%d]@%p m2m_ctx=%p ", mtk_v4l2_venc_dbg(2, ctx, "Create instance [%d]@%p m2m_ctx=%p ",
ctx->id, ctx, ctx->m2m_ctx); ctx->id, ctx, ctx->m2m_ctx);
list_add(&ctx->list, &dev->ctx_list); list_add(&ctx->list, &dev->ctx_list);
mutex_unlock(&dev->dev_mutex); mutex_unlock(&dev->dev_mutex);
mtk_v4l2_debug(0, "%s encoder [%d]", dev_name(&dev->plat_dev->dev), mtk_v4l2_venc_dbg(0, ctx, "%s encoder [%d]", dev_name(&dev->plat_dev->dev),
ctx->id); ctx->id);
return ret; return ret;
/* Deinit when failure occurred */ /* Deinit when failure occurred */
...@@ -209,7 +206,7 @@ static int fops_vcodec_release(struct file *file) ...@@ -209,7 +206,7 @@ static int fops_vcodec_release(struct file *file)
struct mtk_vcodec_dev *dev = video_drvdata(file); struct mtk_vcodec_dev *dev = video_drvdata(file);
struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data); struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
mtk_v4l2_debug(1, "[%d] encoder", ctx->id); mtk_v4l2_venc_dbg(1, ctx, "[%d] encoder", ctx->id);
mutex_lock(&dev->dev_mutex); mutex_lock(&dev->dev_mutex);
v4l2_m2m_ctx_release(ctx->m2m_ctx); v4l2_m2m_ctx_release(ctx->m2m_ctx);
...@@ -255,7 +252,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -255,7 +252,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
&rproc_phandle)) { &rproc_phandle)) {
fw_type = SCP; fw_type = SCP;
} else { } else {
mtk_v4l2_err("Could not get venc IPI device"); dev_err(&pdev->dev, "[MTK VCODEC] Could not get venc IPI device");
return -ENODEV; return -ENODEV;
} }
dma_set_max_seg_size(&pdev->dev, UINT_MAX); dma_set_max_seg_size(&pdev->dev, UINT_MAX);
...@@ -267,7 +264,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -267,7 +264,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
dev->venc_pdata = of_device_get_match_data(&pdev->dev); dev->venc_pdata = of_device_get_match_data(&pdev->dev);
ret = mtk_vcodec_init_enc_clk(dev); ret = mtk_vcodec_init_enc_clk(dev);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to get mtk vcodec clock source!"); dev_err(&pdev->dev, "[MTK VCODEC] Failed to get mtk vcodec clock source!");
goto err_enc_pm; goto err_enc_pm;
} }
...@@ -292,7 +289,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -292,7 +289,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
0, pdev->name, dev); 0, pdev->name, dev);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Failed to install dev->enc_irq %d (%d) core_id (%d)", "[MTK VCODEC] Failed to install dev->enc_irq %d (%d) core_id (%d)",
dev->enc_irq, ret, dev->venc_pdata->core_id); dev->enc_irq, ret, dev->venc_pdata->core_id);
ret = -EINVAL; ret = -EINVAL;
goto err_res; goto err_res;
...@@ -307,14 +304,14 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -307,14 +304,14 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
if (ret) { if (ret) {
mtk_v4l2_err("v4l2_device_register err=%d", ret); dev_err(&pdev->dev, "[MTK VCODEC] v4l2_device_register err=%d", ret);
goto err_res; goto err_res;
} }
/* allocate video device for encoder and register it */ /* allocate video device for encoder and register it */
vfd_enc = video_device_alloc(); vfd_enc = video_device_alloc();
if (!vfd_enc) { if (!vfd_enc) {
mtk_v4l2_err("Failed to allocate video device"); dev_err(&pdev->dev, "[MTK VCODEC] Failed to allocate video device");
ret = -ENOMEM; ret = -ENOMEM;
goto err_enc_alloc; goto err_enc_alloc;
} }
...@@ -335,7 +332,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -335,7 +332,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
dev->m2m_dev_enc = v4l2_m2m_init(&mtk_venc_m2m_ops); dev->m2m_dev_enc = v4l2_m2m_init(&mtk_venc_m2m_ops);
if (IS_ERR((__force void *)dev->m2m_dev_enc)) { if (IS_ERR((__force void *)dev->m2m_dev_enc)) {
mtk_v4l2_err("Failed to init mem2mem enc device"); dev_err(&pdev->dev, "[MTK VCODEC] Failed to init mem2mem enc device");
ret = PTR_ERR((__force void *)dev->m2m_dev_enc); ret = PTR_ERR((__force void *)dev->m2m_dev_enc);
goto err_enc_mem_init; goto err_enc_mem_init;
} }
...@@ -345,20 +342,20 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -345,20 +342,20 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
WQ_MEM_RECLAIM | WQ_MEM_RECLAIM |
WQ_FREEZABLE); WQ_FREEZABLE);
if (!dev->encode_workqueue) { if (!dev->encode_workqueue) {
mtk_v4l2_err("Failed to create encode workqueue"); dev_err(&pdev->dev, "[MTK VCODEC] Failed to create encode workqueue");
ret = -EINVAL; ret = -EINVAL;
goto err_event_workq; goto err_event_workq;
} }
ret = video_register_device(vfd_enc, VFL_TYPE_VIDEO, -1); ret = video_register_device(vfd_enc, VFL_TYPE_VIDEO, -1);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to register video device"); dev_err(&pdev->dev, "[MTK VCODEC] Failed to register video device");
goto err_enc_reg; goto err_enc_reg;
} }
mtk_vcodec_dbgfs_init(dev, true); mtk_vcodec_dbgfs_init(dev, true);
mtk_v4l2_debug(0, "encoder %d registered as /dev/video%d", dev_dbg(&pdev->dev, "[MTK VCODEC] encoder %d registered as /dev/video%d",
dev->venc_pdata->core_id, vfd_enc->num); dev->venc_pdata->core_id, vfd_enc->num);
return 0; return 0;
......
...@@ -34,7 +34,7 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev) ...@@ -34,7 +34,7 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
if (!enc_clk->clk_info) if (!enc_clk->clk_info)
return -ENOMEM; return -ENOMEM;
} else { } else {
mtk_v4l2_err("Failed to get venc clock count"); dev_err(pm->dev, "[MTK VCODEC] Failed to get venc clock count");
return -EINVAL; return -EINVAL;
} }
...@@ -43,13 +43,13 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev) ...@@ -43,13 +43,13 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
ret = of_property_read_string_index(pdev->dev.of_node, ret = of_property_read_string_index(pdev->dev.of_node,
"clock-names", i, &clk_info->clk_name); "clock-names", i, &clk_info->clk_name);
if (ret) { if (ret) {
mtk_v4l2_err("venc failed to get clk name %d", i); dev_err(pm->dev, "[MTK VCODEC] venc failed to get clk name %d", i);
return ret; return ret;
} }
clk_info->vcodec_clk = devm_clk_get(&pdev->dev, clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
clk_info->clk_name); clk_info->clk_name);
if (IS_ERR(clk_info->vcodec_clk)) { if (IS_ERR(clk_info->vcodec_clk)) {
mtk_v4l2_err("venc devm_clk_get (%d)%s fail", i, dev_err(pm->dev, "[MTK VCODEC] venc devm_clk_get (%d)%s fail", i,
clk_info->clk_name); clk_info->clk_name);
return PTR_ERR(clk_info->vcodec_clk); return PTR_ERR(clk_info->vcodec_clk);
} }
...@@ -66,7 +66,7 @@ void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm) ...@@ -66,7 +66,7 @@ void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
for (i = 0; i < enc_clk->clk_num; i++) { for (i = 0; i < enc_clk->clk_num; i++) {
ret = clk_prepare_enable(enc_clk->clk_info[i].vcodec_clk); ret = clk_prepare_enable(enc_clk->clk_info[i].vcodec_clk);
if (ret) { if (ret) {
mtk_v4l2_err("venc clk_prepare_enable %d %s fail %d", i, dev_err(pm->dev, "[MTK VCODEC] venc clk_prepare_enable %d %s fail %d", i,
enc_clk->clk_info[i].clk_name, ret); enc_clk->clk_info[i].clk_name, ret);
goto clkerr; goto clkerr;
} }
......
...@@ -14,7 +14,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type t ...@@ -14,7 +14,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type t
case SCP: case SCP:
return mtk_vcodec_fw_scp_init(priv, fw_use); return mtk_vcodec_fw_scp_init(priv, fw_use);
default: default:
mtk_v4l2_err("invalid vcodec fw type"); pr_err(MTK_DBG_VCODEC_STR "Invalid vcodec fw type");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
} }
......
...@@ -63,7 +63,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_use ...@@ -63,7 +63,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_use
plat_dev = dev->plat_dev; plat_dev = dev->plat_dev;
scp = scp_get(plat_dev); scp = scp_get(plat_dev);
if (!scp) { if (!scp) {
mtk_v4l2_err("could not get vdec scp handle"); dev_err(&dev->plat_dev->dev, "could not get vdec scp handle");
return ERR_PTR(-EPROBE_DEFER); return ERR_PTR(-EPROBE_DEFER);
} }
......
...@@ -56,13 +56,12 @@ static void mtk_vcodec_vpu_reset_handler(void *priv) ...@@ -56,13 +56,12 @@ static void mtk_vcodec_vpu_reset_handler(void *priv)
struct mtk_vcodec_dev *dev = priv; struct mtk_vcodec_dev *dev = priv;
struct mtk_vcodec_ctx *ctx; struct mtk_vcodec_ctx *ctx;
mtk_v4l2_err("Watchdog timeout!!"); dev_err(&dev->plat_dev->dev, "Watchdog timeout!!");
mutex_lock(&dev->dev_mutex); mutex_lock(&dev->dev_mutex);
list_for_each_entry(ctx, &dev->ctx_list, list) { list_for_each_entry(ctx, &dev->ctx_list, list) {
ctx->state = MTK_STATE_ABORT; ctx->state = MTK_STATE_ABORT;
mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ABORT", mtk_v4l2_vdec_dbg(0, ctx, "[%d] Change to state MTK_STATE_ABORT", ctx->id);
ctx->id);
} }
mutex_unlock(&dev->dev_mutex); mutex_unlock(&dev->dev_mutex);
} }
...@@ -98,7 +97,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init(void *priv, enum mtk_vcodec_fw_use ...@@ -98,7 +97,7 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init(void *priv, enum mtk_vcodec_fw_use
plat_dev = dev->plat_dev; plat_dev = dev->plat_dev;
fw_pdev = vpu_get_plat_device(plat_dev); fw_pdev = vpu_get_plat_device(plat_dev);
if (!fw_pdev) { if (!fw_pdev) {
mtk_v4l2_err("firmware device is not ready"); dev_err(&dev->plat_dev->dev, "firmware device is not ready");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
......
...@@ -33,14 +33,14 @@ int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned int timeout_m ...@@ -33,14 +33,14 @@ int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned int timeout_m
if (!ret) { if (!ret) {
status = -1; /* timeout */ status = -1; /* timeout */
mtk_v4l2_err("[%d] cmd=%d, type=%d, dec timeout=%ums (%d %d)", dev_err(&ctx->dev->plat_dev->dev, "[%d] cmd=%d, type=%d, dec timeout=%ums (%d %d)",
ctx_id, command, ctx_type, timeout_ms, ctx_id, command, ctx_type, timeout_ms,
ctx_int_cond[hw_id], ctx_int_type[hw_id]); ctx_int_cond[hw_id], ctx_int_type[hw_id]);
} else if (-ERESTARTSYS == ret) { } else if (-ERESTARTSYS == ret) {
status = -1; status = -1;
mtk_v4l2_err("[%d] cmd=%d, type=%d, dec inter fail (%d %d)", dev_err(&ctx->dev->plat_dev->dev, "[%d] cmd=%d, type=%d, dec inter fail (%d %d)",
ctx_id, command, ctx_type, ctx_id, command, ctx_type,
ctx_int_cond[hw_id], ctx_int_type[hw_id]); ctx_int_cond[hw_id], ctx_int_type[hw_id]);
} }
ctx_int_cond[hw_id] = 0; ctx_int_cond[hw_id] = 0;
......
...@@ -24,7 +24,7 @@ EXPORT_SYMBOL(mtk_v4l2_dbg_level); ...@@ -24,7 +24,7 @@ EXPORT_SYMBOL(mtk_v4l2_dbg_level);
void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx) void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx)
{ {
if (reg_idx >= NUM_MAX_VCODEC_REG_BASE) { if (reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
mtk_v4l2_err("Invalid arguments, reg_idx=%d", reg_idx); pr_err(MTK_DBG_V4L2_STR "Invalid arguments, reg_idx=%d", reg_idx);
return NULL; return NULL;
} }
return reg_base[reg_idx]; return reg_base[reg_idx];
...@@ -53,15 +53,14 @@ int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem) ...@@ -53,15 +53,14 @@ int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem)
mem->va = dma_alloc_coherent(dev, size, &mem->dma_addr, GFP_KERNEL); mem->va = dma_alloc_coherent(dev, size, &mem->dma_addr, GFP_KERNEL);
if (!mem->va) { if (!mem->va) {
mtk_v4l2_err("%s dma_alloc size=%ld failed!", dev_name(dev), mtk_v4l2_vdec_err(ctx, "%s dma_alloc size=%ld failed!", dev_name(dev), size);
size);
return -ENOMEM; return -ENOMEM;
} }
mtk_v4l2_debug(3, "[%d] - va = %p", ctx->id, mem->va); mtk_v4l2_vdec_dbg(3, ctx, "[%d] - va = %p", ctx->id, mem->va);
mtk_v4l2_debug(3, "[%d] - dma = 0x%lx", ctx->id, mtk_v4l2_vdec_dbg(3, ctx, "[%d] - dma = 0x%lx", ctx->id,
(unsigned long)mem->dma_addr); (unsigned long)mem->dma_addr);
mtk_v4l2_debug(3, "[%d] size = 0x%lx", ctx->id, size); mtk_v4l2_vdec_dbg(3, ctx, "[%d] size = 0x%lx", ctx->id, size);
return 0; return 0;
} }
...@@ -74,15 +73,14 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem) ...@@ -74,15 +73,14 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
struct device *dev = &ctx->dev->plat_dev->dev; struct device *dev = &ctx->dev->plat_dev->dev;
if (!mem->va) { if (!mem->va) {
mtk_v4l2_err("%s dma_free size=%ld failed!", dev_name(dev), mtk_v4l2_vdec_err(ctx, "%s dma_free size=%ld failed!", dev_name(dev), size);
size);
return; return;
} }
mtk_v4l2_debug(3, "[%d] - va = %p", ctx->id, mem->va); mtk_v4l2_vdec_dbg(3, ctx, "[%d] - va = %p", ctx->id, mem->va);
mtk_v4l2_debug(3, "[%d] - dma = 0x%lx", ctx->id, mtk_v4l2_vdec_dbg(3, ctx, "[%d] - dma = 0x%lx", ctx->id,
(unsigned long)mem->dma_addr); (unsigned long)mem->dma_addr);
mtk_v4l2_debug(3, "[%d] size = 0x%lx", ctx->id, size); mtk_v4l2_vdec_dbg(3, ctx, "[%d] size = 0x%lx", ctx->id, size);
dma_free_coherent(dev, size, mem->va, mem->dma_addr); dma_free_coherent(dev, size, mem->va, mem->dma_addr);
mem->va = NULL; mem->va = NULL;
...@@ -94,7 +92,7 @@ EXPORT_SYMBOL(mtk_vcodec_mem_free); ...@@ -94,7 +92,7 @@ EXPORT_SYMBOL(mtk_vcodec_mem_free);
void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int hw_idx) void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int hw_idx)
{ {
if (hw_idx >= MTK_VDEC_HW_MAX || hw_idx < 0 || !dev->subdev_dev[hw_idx]) { if (hw_idx >= MTK_VDEC_HW_MAX || hw_idx < 0 || !dev->subdev_dev[hw_idx]) {
mtk_v4l2_err("hw idx is out of range:%d", hw_idx); dev_err(&dev->plat_dev->dev, "hw idx is out of range:%d", hw_idx);
return NULL; return NULL;
} }
...@@ -112,7 +110,7 @@ void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev, ...@@ -112,7 +110,7 @@ void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
if (vdec_dev->vdec_pdata->is_subdev_supported) { if (vdec_dev->vdec_pdata->is_subdev_supported) {
subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx); subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
if (!subdev_dev) { if (!subdev_dev) {
mtk_v4l2_err("Failed to get hw dev"); dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev");
spin_unlock_irqrestore(&vdec_dev->irqlock, flags); spin_unlock_irqrestore(&vdec_dev->irqlock, flags);
return; return;
} }
...@@ -135,7 +133,7 @@ struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev, ...@@ -135,7 +133,7 @@ struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
if (vdec_dev->vdec_pdata->is_subdev_supported) { if (vdec_dev->vdec_pdata->is_subdev_supported) {
subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx); subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
if (!subdev_dev) { if (!subdev_dev) {
mtk_v4l2_err("Failed to get hw dev"); dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev");
spin_unlock_irqrestore(&vdec_dev->irqlock, flags); spin_unlock_irqrestore(&vdec_dev->irqlock, flags);
return NULL; return NULL;
} }
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/dma-direction.h> #include <linux/dma-direction.h>
#define MTK_DBG_VCODEC_STR "[MTK_VCODEC]"
#define MTK_DBG_V4L2_STR "[MTK_V4L2]"
struct mtk_vcodec_mem { struct mtk_vcodec_mem {
size_t size; size_t size;
void *va; void *va;
...@@ -28,8 +31,8 @@ struct mtk_vcodec_dev; ...@@ -28,8 +31,8 @@ struct mtk_vcodec_dev;
#undef pr_fmt #undef pr_fmt
#define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__ #define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__
#define mtk_v4l2_err(fmt, args...) \ #define mtk_v4l2_err(plat_dev, fmt, args...) \
pr_err("[MTK_V4L2][ERROR] " fmt "\n", ##args) dev_err(&(plat_dev)->dev, "[MTK_V4L2][ERROR] " fmt "\n", ##args)
#define mtk_vcodec_err(inst_id, plat_dev, fmt, args...) \ #define mtk_vcodec_err(inst_id, plat_dev, fmt, args...) \
dev_err(&(plat_dev)->dev, "[MTK_VCODEC][ERROR][%d]: " fmt "\n", inst_id, ##args) dev_err(&(plat_dev)->dev, "[MTK_VCODEC][ERROR][%d]: " fmt "\n", inst_id, ##args)
...@@ -38,11 +41,11 @@ struct mtk_vcodec_dev; ...@@ -38,11 +41,11 @@ struct mtk_vcodec_dev;
extern int mtk_v4l2_dbg_level; extern int mtk_v4l2_dbg_level;
extern int mtk_vcodec_dbg; extern int mtk_vcodec_dbg;
#define mtk_v4l2_debug(level, fmt, args...) \ #define mtk_v4l2_debug(plat_dev, level, fmt, args...) \
do { \ do { \
if (mtk_v4l2_dbg_level >= (level)) \ if (mtk_v4l2_dbg_level >= (level)) \
pr_debug("[MTK_V4L2] %s, %d: " fmt "\n", \ dev_dbg(&(plat_dev)->dev, "[MTK_V4L2] %s, %d: " fmt "\n", \
__func__, __LINE__, ##args); \ __func__, __LINE__, ##args); \
} while (0) } while (0)
#define mtk_vcodec_debug(inst_id, plat_dev, fmt, args...) \ #define mtk_vcodec_debug(inst_id, plat_dev, fmt, args...) \
...@@ -52,7 +55,8 @@ extern int mtk_vcodec_dbg; ...@@ -52,7 +55,8 @@ extern int mtk_vcodec_dbg;
inst_id, __func__, __LINE__, ##args); \ inst_id, __func__, __LINE__, ##args); \
} while (0) } while (0)
#else #else
#define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args) #define mtk_v4l2_debug(plat_dev, level, fmt, args...) \
dev_dbg(&(plat_dev)->dev, "[MTK_V4L2]: " fmt "\n", ##args)
#define mtk_vcodec_debug(inst_id, plat_dev, fmt, args...) \ #define mtk_vcodec_debug(inst_id, plat_dev, fmt, args...) \
dev_dbg(&(plat_dev)->dev, "[MTK_VCODEC][%d]: " fmt "\n", inst_id, ##args) dev_dbg(&(plat_dev)->dev, "[MTK_VCODEC][%d]: " fmt "\n", inst_id, ##args)
...@@ -70,6 +74,16 @@ extern int mtk_vcodec_dbg; ...@@ -70,6 +74,16 @@ extern int mtk_vcodec_dbg;
#define mtk_venc_debug(ctx, fmt, args...) \ #define mtk_venc_debug(ctx, fmt, args...) \
mtk_vcodec_debug((ctx)->id, (ctx)->dev->plat_dev, fmt, ##args) mtk_vcodec_debug((ctx)->id, (ctx)->dev->plat_dev, fmt, ##args)
#define mtk_v4l2_vdec_err(ctx, fmt, args...) mtk_v4l2_err((ctx)->dev->plat_dev, fmt, ##args)
#define mtk_v4l2_vdec_dbg(level, ctx, fmt, args...) \
mtk_v4l2_debug((ctx)->dev->plat_dev, level, fmt, ##args)
#define mtk_v4l2_venc_err(ctx, fmt, args...) mtk_v4l2_err((ctx)->dev->plat_dev, fmt, ##args)
#define mtk_v4l2_venc_dbg(level, ctx, fmt, args...) \
mtk_v4l2_debug((ctx)->dev->plat_dev, level, fmt, ##args)
void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx); void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx);
int mtk_vcodec_write_vdecsys(struct mtk_vcodec_ctx *ctx, unsigned int reg, unsigned int val); int mtk_vcodec_write_vdecsys(struct mtk_vcodec_ctx *ctx, unsigned int reg, unsigned int val);
int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem); int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem);
......
...@@ -861,8 +861,8 @@ static void vdec_av1_slice_decrease_ref_count(struct vdec_av1_slice_slot *slots, ...@@ -861,8 +861,8 @@ static void vdec_av1_slice_decrease_ref_count(struct vdec_av1_slice_slot *slots,
frame_info[fb_idx].ref_count--; frame_info[fb_idx].ref_count--;
if (frame_info[fb_idx].ref_count < 0) { if (frame_info[fb_idx].ref_count < 0) {
frame_info[fb_idx].ref_count = 0; frame_info[fb_idx].ref_count = 0;
mtk_v4l2_err("av1_error: %s() fb_idx %d decrease ref_count error\n", pr_err(MTK_DBG_V4L2_STR "av1_error: %s() fb_idx %d decrease ref_count error\n",
__func__, fb_idx); __func__, fb_idx);
} }
vdec_av1_slice_clear_fb(&frame_info[fb_idx]); vdec_av1_slice_clear_fb(&frame_info[fb_idx]);
...@@ -910,7 +910,7 @@ static void vdec_av1_slice_setup_slot(struct vdec_av1_slice_instance *instance, ...@@ -910,7 +910,7 @@ static void vdec_av1_slice_setup_slot(struct vdec_av1_slice_instance *instance,
vsi->slot_id = vdec_av1_slice_get_new_slot(vsi); vsi->slot_id = vdec_av1_slice_get_new_slot(vsi);
if (vsi->slot_id == AV1_INVALID_IDX) { if (vsi->slot_id == AV1_INVALID_IDX) {
mtk_v4l2_err("warning:av1 get invalid index slot\n"); mtk_v4l2_vdec_err(instance->ctx, "warning:av1 get invalid index slot\n");
vsi->slot_id = 0; vsi->slot_id = 0;
} }
cur_frame_info = &vsi->slots.frame_info[vsi->slot_id]; cur_frame_info = &vsi->slots.frame_info[vsi->slot_id];
...@@ -1504,8 +1504,8 @@ static void vdec_av1_slice_setup_ref(struct vdec_av1_slice_pfc *pfc, ...@@ -1504,8 +1504,8 @@ static void vdec_av1_slice_setup_ref(struct vdec_av1_slice_pfc *pfc,
slot_id = frame->ref_frame_map[ref_idx]; slot_id = frame->ref_frame_map[ref_idx];
frame_info = &slots->frame_info[slot_id]; frame_info = &slots->frame_info[slot_id];
if (slot_id == AV1_INVALID_IDX) { if (slot_id == AV1_INVALID_IDX) {
mtk_v4l2_err("cannot match reference[%d] 0x%llx\n", i, pr_err(MTK_DBG_V4L2_STR "cannot match reference[%d] 0x%llx\n", i,
ctrl_fh->reference_frame_ts[ref_idx]); ctrl_fh->reference_frame_ts[ref_idx]);
frame->order_hints[i] = 0; frame->order_hints[i] = 0;
frame->ref_frame_valid[i] = 0; frame->ref_frame_valid[i] = 0;
continue; continue;
......
...@@ -187,7 +187,7 @@ static int alloc_mv_buf(struct vdec_h264_slice_inst *inst, ...@@ -187,7 +187,7 @@ static int alloc_mv_buf(struct vdec_h264_slice_inst *inst,
struct mtk_vcodec_mem *mem = NULL; struct mtk_vcodec_mem *mem = NULL;
unsigned int buf_sz = mtk_vdec_h264_get_mv_buf_size(pic->buf_w, pic->buf_h); unsigned int buf_sz = mtk_vdec_h264_get_mv_buf_size(pic->buf_w, pic->buf_h);
mtk_v4l2_debug(3, "size = 0x%x", buf_sz); mtk_v4l2_vdec_dbg(3, inst->ctx, "size = 0x%x", buf_sz);
for (i = 0; i < H264_MAX_MV_NUM; i++) { for (i = 0; i < H264_MAX_MV_NUM; i++) {
mem = &inst->mv_buf[i]; mem = &inst->mv_buf[i];
if (mem->va) if (mem->va)
...@@ -243,12 +243,12 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst, ...@@ -243,12 +243,12 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
ctx->last_decoded_picinfo.buf_h != ctx->picinfo.buf_h) ctx->last_decoded_picinfo.buf_h != ctx->picinfo.buf_h)
inst->vsi_ctx.dec.realloc_mv_buf = true; inst->vsi_ctx.dec.realloc_mv_buf = true;
mtk_v4l2_debug(1, "ResChg: (%d %d) : old(%d, %d) -> new(%d, %d)", mtk_v4l2_vdec_dbg(1, inst->ctx, "ResChg: (%d %d) : old(%d, %d) -> new(%d, %d)",
inst->vsi_ctx.dec.resolution_changed, inst->vsi_ctx.dec.resolution_changed,
inst->vsi_ctx.dec.realloc_mv_buf, inst->vsi_ctx.dec.realloc_mv_buf,
ctx->last_decoded_picinfo.pic_w, ctx->last_decoded_picinfo.pic_w,
ctx->last_decoded_picinfo.pic_h, ctx->last_decoded_picinfo.pic_h,
ctx->picinfo.pic_w, ctx->picinfo.pic_h); ctx->picinfo.pic_w, ctx->picinfo.pic_h);
} }
} }
......
...@@ -294,7 +294,7 @@ static void vdec_h264_slice_fill_decode_reflist(struct vdec_h264_slice_inst *ins ...@@ -294,7 +294,7 @@ static void vdec_h264_slice_fill_decode_reflist(struct vdec_h264_slice_inst *ins
mtk_vdec_h264_fill_dpb_info(inst->ctx, &slice_param->decode_params, mtk_vdec_h264_fill_dpb_info(inst->ctx, &slice_param->decode_params,
slice_param->h264_dpb_info); slice_param->h264_dpb_info);
mtk_v4l2_debug(3, "cur poc = %d\n", dec_params->bottom_field_order_cnt); mtk_v4l2_vdec_dbg(3, inst->ctx, "cur poc = %d\n", dec_params->bottom_field_order_cnt);
/* Build the reference lists */ /* Build the reference lists */
v4l2_h264_init_reflist_builder(&reflist_builder, dec_params, sps, v4l2_h264_init_reflist_builder(&reflist_builder, dec_params, sps,
inst->dpb); inst->dpb);
...@@ -314,7 +314,7 @@ static int vdec_h264_slice_alloc_mv_buf(struct vdec_h264_slice_inst *inst, ...@@ -314,7 +314,7 @@ static int vdec_h264_slice_alloc_mv_buf(struct vdec_h264_slice_inst *inst,
struct mtk_vcodec_mem *mem; struct mtk_vcodec_mem *mem;
int i, err; int i, err;
mtk_v4l2_debug(3, "size = 0x%x", buf_sz); mtk_v4l2_vdec_dbg(3, inst->ctx, "size = 0x%x", buf_sz);
for (i = 0; i < H264_MAX_MV_NUM; i++) { for (i = 0; i < H264_MAX_MV_NUM; i++) {
mem = &inst->mv_buf[i]; mem = &inst->mv_buf[i];
if (mem->va) if (mem->va)
...@@ -372,12 +372,12 @@ static void vdec_h264_slice_get_pic_info(struct vdec_h264_slice_inst *inst) ...@@ -372,12 +372,12 @@ static void vdec_h264_slice_get_pic_info(struct vdec_h264_slice_inst *inst)
ctx->last_decoded_picinfo.buf_h != ctx->picinfo.buf_h) ctx->last_decoded_picinfo.buf_h != ctx->picinfo.buf_h)
inst->realloc_mv_buf = true; inst->realloc_mv_buf = true;
mtk_v4l2_debug(1, "resChg: (%d %d) : old(%d, %d) -> new(%d, %d)", mtk_v4l2_vdec_dbg(1, inst->ctx, "resChg: (%d %d) : old(%d, %d) -> new(%d, %d)",
inst->resolution_changed, inst->resolution_changed,
inst->realloc_mv_buf, inst->realloc_mv_buf,
ctx->last_decoded_picinfo.pic_w, ctx->last_decoded_picinfo.pic_w,
ctx->last_decoded_picinfo.pic_h, ctx->last_decoded_picinfo.pic_h,
ctx->picinfo.pic_w, ctx->picinfo.pic_h); ctx->picinfo.pic_w, ctx->picinfo.pic_h);
} }
} }
......
...@@ -649,7 +649,7 @@ static int vdec_hevc_slice_alloc_mv_buf(struct vdec_hevc_slice_inst *inst, ...@@ -649,7 +649,7 @@ static int vdec_hevc_slice_alloc_mv_buf(struct vdec_hevc_slice_inst *inst,
struct mtk_vcodec_mem *mem; struct mtk_vcodec_mem *mem;
int i, err; int i, err;
mtk_v4l2_debug(3, "allocate mv buffer size = 0x%x", buf_sz); mtk_v4l2_vdec_dbg(3, inst->ctx, "allocate mv buffer size = 0x%x", buf_sz);
for (i = 0; i < HEVC_MAX_MV_NUM; i++) { for (i = 0; i < HEVC_MAX_MV_NUM; i++) {
mem = &inst->mv_buf[i]; mem = &inst->mv_buf[i];
if (mem->va) if (mem->va)
...@@ -707,12 +707,12 @@ static void vdec_hevc_slice_get_pic_info(struct vdec_hevc_slice_inst *inst) ...@@ -707,12 +707,12 @@ static void vdec_hevc_slice_get_pic_info(struct vdec_hevc_slice_inst *inst)
ctx->last_decoded_picinfo.buf_h != ctx->picinfo.buf_h) ctx->last_decoded_picinfo.buf_h != ctx->picinfo.buf_h)
inst->realloc_mv_buf = true; inst->realloc_mv_buf = true;
mtk_v4l2_debug(1, "resChg: (%d %d) : old(%d, %d) -> new(%d, %d)", mtk_v4l2_vdec_dbg(1, inst->ctx, "resChg: (%d %d) : old(%d, %d) -> new(%d, %d)",
inst->resolution_changed, inst->resolution_changed,
inst->realloc_mv_buf, inst->realloc_mv_buf,
ctx->last_decoded_picinfo.pic_w, ctx->last_decoded_picinfo.pic_w,
ctx->last_decoded_picinfo.pic_h, ctx->last_decoded_picinfo.pic_h,
ctx->picinfo.pic_w, ctx->picinfo.pic_h); ctx->picinfo.pic_w, ctx->picinfo.pic_h);
} }
} }
......
...@@ -75,7 +75,7 @@ int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs, ...@@ -75,7 +75,7 @@ int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
if (bs) { if (bs) {
if ((bs->dma_addr & 63) != 0) { if ((bs->dma_addr & 63) != 0) {
mtk_v4l2_err("bs dma_addr should 64 byte align"); mtk_v4l2_vdec_err(ctx, "bs dma_addr should 64 byte align");
return -EINVAL; return -EINVAL;
} }
} }
...@@ -83,7 +83,7 @@ int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs, ...@@ -83,7 +83,7 @@ int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
if (fb) { if (fb) {
if (((fb->base_y.dma_addr & 511) != 0) || if (((fb->base_y.dma_addr & 511) != 0) ||
((fb->base_c.dma_addr & 511) != 0)) { ((fb->base_c.dma_addr & 511) != 0)) {
mtk_v4l2_err("frame buffer dma_addr should 512 byte align"); mtk_v4l2_vdec_err(ctx, "frame buffer dma_addr should 512 byte align");
return -EINVAL; return -EINVAL;
} }
} }
......
...@@ -77,7 +77,7 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf ...@@ -77,7 +77,7 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf
head = vdec_get_buf_list(msg_ctx->hardware_index, buf); head = vdec_get_buf_list(msg_ctx->hardware_index, buf);
if (!head) { if (!head) {
mtk_v4l2_err("fail to qbuf: %d", msg_ctx->hardware_index); mtk_v4l2_vdec_err(buf->ctx, "fail to qbuf: %d", msg_ctx->hardware_index);
return -EINVAL; return -EINVAL;
} }
...@@ -95,8 +95,8 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf ...@@ -95,8 +95,8 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf
} }
} }
mtk_v4l2_debug(3, "enqueue buf type: %d addr: 0x%p num: %d", mtk_v4l2_vdec_dbg(3, buf->ctx, "enqueue buf type: %d addr: 0x%p num: %d",
msg_ctx->hardware_index, buf, msg_ctx->ready_num); msg_ctx->hardware_index, buf, msg_ctx->ready_num);
spin_unlock(&msg_ctx->ready_lock); spin_unlock(&msg_ctx->ready_lock);
return 0; return 0;
...@@ -123,8 +123,6 @@ struct vdec_lat_buf *vdec_msg_queue_dqbuf(struct vdec_msg_queue_ctx *msg_ctx) ...@@ -123,8 +123,6 @@ struct vdec_lat_buf *vdec_msg_queue_dqbuf(struct vdec_msg_queue_ctx *msg_ctx)
spin_lock(&msg_ctx->ready_lock); spin_lock(&msg_ctx->ready_lock);
if (list_empty(&msg_ctx->ready_queue)) { if (list_empty(&msg_ctx->ready_queue)) {
mtk_v4l2_debug(3, "queue is NULL, type:%d num: %d",
msg_ctx->hardware_index, msg_ctx->ready_num);
spin_unlock(&msg_ctx->ready_lock); spin_unlock(&msg_ctx->ready_lock);
if (msg_ctx->hardware_index == MTK_VDEC_CORE) if (msg_ctx->hardware_index == MTK_VDEC_CORE)
...@@ -146,15 +144,15 @@ struct vdec_lat_buf *vdec_msg_queue_dqbuf(struct vdec_msg_queue_ctx *msg_ctx) ...@@ -146,15 +144,15 @@ struct vdec_lat_buf *vdec_msg_queue_dqbuf(struct vdec_msg_queue_ctx *msg_ctx)
head = vdec_get_buf_list(msg_ctx->hardware_index, buf); head = vdec_get_buf_list(msg_ctx->hardware_index, buf);
if (!head) { if (!head) {
spin_unlock(&msg_ctx->ready_lock); spin_unlock(&msg_ctx->ready_lock);
mtk_v4l2_err("fail to dqbuf: %d", msg_ctx->hardware_index); mtk_v4l2_vdec_err(buf->ctx, "fail to dqbuf: %d", msg_ctx->hardware_index);
return NULL; return NULL;
} }
list_del(head); list_del(head);
vdec_msg_queue_dec(&buf->ctx->msg_queue, msg_ctx->hardware_index); vdec_msg_queue_dec(&buf->ctx->msg_queue, msg_ctx->hardware_index);
msg_ctx->ready_num--; msg_ctx->ready_num--;
mtk_v4l2_debug(3, "dqueue buf type:%d addr: 0x%p num: %d", mtk_v4l2_vdec_dbg(3, buf->ctx, "dqueue buf type:%d addr: 0x%p num: %d",
msg_ctx->hardware_index, buf, msg_ctx->ready_num); msg_ctx->hardware_index, buf, msg_ctx->ready_num);
spin_unlock(&msg_ctx->ready_lock); spin_unlock(&msg_ctx->ready_lock);
return buf; return buf;
...@@ -164,7 +162,7 @@ void vdec_msg_queue_update_ube_rptr(struct vdec_msg_queue *msg_queue, uint64_t u ...@@ -164,7 +162,7 @@ void vdec_msg_queue_update_ube_rptr(struct vdec_msg_queue *msg_queue, uint64_t u
{ {
spin_lock(&msg_queue->lat_ctx.ready_lock); spin_lock(&msg_queue->lat_ctx.ready_lock);
msg_queue->wdma_rptr_addr = ube_rptr; msg_queue->wdma_rptr_addr = ube_rptr;
mtk_v4l2_debug(3, "update ube rprt (0x%llx)", ube_rptr); mtk_v4l2_vdec_dbg(3, msg_queue->ctx, "update ube rprt (0x%llx)", ube_rptr);
spin_unlock(&msg_queue->lat_ctx.ready_lock); spin_unlock(&msg_queue->lat_ctx.ready_lock);
} }
...@@ -172,20 +170,19 @@ void vdec_msg_queue_update_ube_wptr(struct vdec_msg_queue *msg_queue, uint64_t u ...@@ -172,20 +170,19 @@ void vdec_msg_queue_update_ube_wptr(struct vdec_msg_queue *msg_queue, uint64_t u
{ {
spin_lock(&msg_queue->lat_ctx.ready_lock); spin_lock(&msg_queue->lat_ctx.ready_lock);
msg_queue->wdma_wptr_addr = ube_wptr; msg_queue->wdma_wptr_addr = ube_wptr;
mtk_v4l2_debug(3, "update ube wprt: (0x%llx 0x%llx) offset: 0x%llx", mtk_v4l2_vdec_dbg(3, msg_queue->ctx, "update ube wprt: (0x%llx 0x%llx) offset: 0x%llx",
msg_queue->wdma_rptr_addr, msg_queue->wdma_wptr_addr, msg_queue->wdma_rptr_addr, msg_queue->wdma_wptr_addr,
ube_wptr); ube_wptr);
spin_unlock(&msg_queue->lat_ctx.ready_lock); spin_unlock(&msg_queue->lat_ctx.ready_lock);
} }
bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue) bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue)
{ {
if (atomic_read(&msg_queue->lat_list_cnt) == NUM_BUFFER_COUNT) { if (atomic_read(&msg_queue->lat_list_cnt) == NUM_BUFFER_COUNT) {
mtk_v4l2_debug(3, "wait buf full: list(%d %d) ready_num:%d status:%d", mtk_v4l2_vdec_dbg(3, msg_queue->ctx, "wait buf full: (%d %d) ready:%d status:%d",
atomic_read(&msg_queue->lat_list_cnt), atomic_read(&msg_queue->lat_list_cnt),
atomic_read(&msg_queue->core_list_cnt), atomic_read(&msg_queue->core_list_cnt),
msg_queue->lat_ctx.ready_num, msg_queue->lat_ctx.ready_num, msg_queue->status);
msg_queue->status);
return true; return true;
} }
...@@ -193,10 +190,10 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue) ...@@ -193,10 +190,10 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue)
vdec_msg_queue_qbuf(&msg_queue->core_ctx, &msg_queue->empty_lat_buf); vdec_msg_queue_qbuf(&msg_queue->core_ctx, &msg_queue->empty_lat_buf);
wait_event(msg_queue->core_dec_done, msg_queue->flush_done); wait_event(msg_queue->core_dec_done, msg_queue->flush_done);
mtk_v4l2_debug(3, "flush done => ready_num:%d status:%d list(%d %d)", mtk_v4l2_vdec_dbg(3, msg_queue->ctx, "flush done => ready_num:%d status:%d list(%d %d)",
msg_queue->lat_ctx.ready_num, msg_queue->status, msg_queue->lat_ctx.ready_num, msg_queue->status,
atomic_read(&msg_queue->lat_list_cnt), atomic_read(&msg_queue->lat_list_cnt),
atomic_read(&msg_queue->core_list_cnt)); atomic_read(&msg_queue->core_list_cnt));
return false; return false;
} }
...@@ -307,7 +304,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, ...@@ -307,7 +304,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
ctx->picinfo.buf_h); ctx->picinfo.buf_h);
err = mtk_vcodec_mem_alloc(ctx, &msg_queue->wdma_addr); err = mtk_vcodec_mem_alloc(ctx, &msg_queue->wdma_addr);
if (err) { if (err) {
mtk_v4l2_err("failed to allocate wdma_addr buf"); mtk_v4l2_vdec_err(ctx, "failed to allocate wdma_addr buf");
msg_queue->wdma_addr.size = 0; msg_queue->wdma_addr.size = 0;
return -ENOMEM; return -ENOMEM;
} }
...@@ -318,20 +315,21 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, ...@@ -318,20 +315,21 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
msg_queue->empty_lat_buf.core_decode = NULL; msg_queue->empty_lat_buf.core_decode = NULL;
msg_queue->empty_lat_buf.is_last_frame = true; msg_queue->empty_lat_buf.is_last_frame = true;
msg_queue->ctx = ctx;
for (i = 0; i < NUM_BUFFER_COUNT; i++) { for (i = 0; i < NUM_BUFFER_COUNT; i++) {
lat_buf = &msg_queue->lat_buf[i]; lat_buf = &msg_queue->lat_buf[i];
lat_buf->wdma_err_addr.size = VDEC_ERR_MAP_SZ_AVC; lat_buf->wdma_err_addr.size = VDEC_ERR_MAP_SZ_AVC;
err = mtk_vcodec_mem_alloc(ctx, &lat_buf->wdma_err_addr); err = mtk_vcodec_mem_alloc(ctx, &lat_buf->wdma_err_addr);
if (err) { if (err) {
mtk_v4l2_err("failed to allocate wdma_err_addr buf[%d]", i); mtk_v4l2_vdec_err(ctx, "failed to allocate wdma_err_addr buf[%d]", i);
goto mem_alloc_err; goto mem_alloc_err;
} }
lat_buf->slice_bc_addr.size = VDEC_LAT_SLICE_HEADER_SZ; lat_buf->slice_bc_addr.size = VDEC_LAT_SLICE_HEADER_SZ;
err = mtk_vcodec_mem_alloc(ctx, &lat_buf->slice_bc_addr); err = mtk_vcodec_mem_alloc(ctx, &lat_buf->slice_bc_addr);
if (err) { if (err) {
mtk_v4l2_err("failed to allocate wdma_addr buf[%d]", i); mtk_v4l2_vdec_err(ctx, "failed to allocate wdma_addr buf[%d]", i);
goto mem_alloc_err; goto mem_alloc_err;
} }
...@@ -339,14 +337,14 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, ...@@ -339,14 +337,14 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
lat_buf->rd_mv_addr.size = VDEC_RD_MV_BUFFER_SZ; lat_buf->rd_mv_addr.size = VDEC_RD_MV_BUFFER_SZ;
err = mtk_vcodec_mem_alloc(ctx, &lat_buf->rd_mv_addr); err = mtk_vcodec_mem_alloc(ctx, &lat_buf->rd_mv_addr);
if (err) { if (err) {
mtk_v4l2_err("failed to allocate rd_mv_addr buf[%d]", i); mtk_v4l2_vdec_err(ctx, "failed to allocate rd_mv_addr buf[%d]", i);
goto mem_alloc_err; goto mem_alloc_err;
} }
lat_buf->tile_addr.size = VDEC_LAT_TILE_SZ; lat_buf->tile_addr.size = VDEC_LAT_TILE_SZ;
err = mtk_vcodec_mem_alloc(ctx, &lat_buf->tile_addr); err = mtk_vcodec_mem_alloc(ctx, &lat_buf->tile_addr);
if (err) { if (err) {
mtk_v4l2_err("failed to allocate tile_addr buf[%d]", i); mtk_v4l2_vdec_err(ctx, "failed to allocate tile_addr buf[%d]", i);
goto mem_alloc_err; goto mem_alloc_err;
} }
} }
...@@ -362,7 +360,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, ...@@ -362,7 +360,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
lat_buf->is_last_frame = false; lat_buf->is_last_frame = false;
err = vdec_msg_queue_qbuf(&msg_queue->lat_ctx, lat_buf); err = vdec_msg_queue_qbuf(&msg_queue->lat_ctx, lat_buf);
if (err) { if (err) {
mtk_v4l2_err("failed to qbuf buf[%d]", i); mtk_v4l2_vdec_err(ctx, "failed to qbuf buf[%d]", i);
goto mem_alloc_err; goto mem_alloc_err;
} }
} }
......
...@@ -100,6 +100,7 @@ struct vdec_lat_buf { ...@@ -100,6 +100,7 @@ struct vdec_lat_buf {
* @empty_lat_buf: the last lat buf used to flush decode * @empty_lat_buf: the last lat buf used to flush decode
* @core_dec_done: core work queue decode done event * @core_dec_done: core work queue decode done event
* @status: current context decode status for core hardware * @status: current context decode status for core hardware
* @ctx: mtk vcodec context information
*/ */
struct vdec_msg_queue { struct vdec_msg_queue {
struct vdec_lat_buf lat_buf[NUM_BUFFER_COUNT]; struct vdec_lat_buf lat_buf[NUM_BUFFER_COUNT];
...@@ -118,6 +119,7 @@ struct vdec_msg_queue { ...@@ -118,6 +119,7 @@ struct vdec_msg_queue {
struct vdec_lat_buf empty_lat_buf; struct vdec_lat_buf empty_lat_buf;
wait_queue_head_t core_dec_done; wait_queue_head_t core_dec_done;
int status; int status;
struct mtk_vcodec_ctx *ctx;
}; };
/** /**
......
...@@ -91,7 +91,7 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv) ...@@ -91,7 +91,7 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
(unsigned long)msg->ap_inst_addr; (unsigned long)msg->ap_inst_addr;
if (!vpu) { if (!vpu) {
mtk_v4l2_err("ap_inst_addr is NULL, did the SCP hang or crash?"); mtk_v4l2_vdec_err(vpu->ctx, "ap_inst_addr is NULL, did the SCP hang or crash?");
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment