71c789760f
The mtk-vcodec uses some internal defined debug formats for printing. This patch fixes some things in those defines: 1. use the 'pr_fmt' define to print function name and line. 2. remove 'if(DEBUG)' condition for the defines. This condition prevents the debugs from being shown in case of dynamic debugs. Instead replace 'pr_info' with 'pr_debug' 3. remove module parameters that enable/disable debug. There is no reason for the driver to have those params. Having those params require the user to explicitly set them when user wants to see debug prints instead of using the global debugs setting as expected by drivers to conform. In addition to that, fix some warnings about debug formatting [hverkuil: used %zu instead of %lu for sizeof() arguments] Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.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>
99 lines
2.6 KiB
C
99 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2016 MediaTek Inc.
|
|
* Author: PC Chen <pc.chen@mediatek.com>
|
|
* Tiffany Lin <tiffany.lin@mediatek.com>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include "mtk_vcodec_drv.h"
|
|
#include "mtk_vcodec_util.h"
|
|
|
|
void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
|
|
unsigned int reg_idx)
|
|
{
|
|
struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
|
|
|
|
if (!data || reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
|
|
mtk_v4l2_err("Invalid arguments, reg_idx=%d", reg_idx);
|
|
return NULL;
|
|
}
|
|
return ctx->dev->reg_base[reg_idx];
|
|
}
|
|
EXPORT_SYMBOL(mtk_vcodec_get_reg_addr);
|
|
|
|
int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
|
|
struct mtk_vcodec_mem *mem)
|
|
{
|
|
unsigned long size = mem->size;
|
|
struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
|
|
struct device *dev = &ctx->dev->plat_dev->dev;
|
|
|
|
mem->va = dma_alloc_coherent(dev, size, &mem->dma_addr, GFP_KERNEL);
|
|
if (!mem->va) {
|
|
mtk_v4l2_err("%s dma_alloc size=%ld failed!", dev_name(dev),
|
|
size);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
mtk_v4l2_debug(3, "[%d] - va = %p", ctx->id, mem->va);
|
|
mtk_v4l2_debug(3, "[%d] - dma = 0x%lx", ctx->id,
|
|
(unsigned long)mem->dma_addr);
|
|
mtk_v4l2_debug(3, "[%d] size = 0x%lx", ctx->id, size);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(mtk_vcodec_mem_alloc);
|
|
|
|
void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
|
|
struct mtk_vcodec_mem *mem)
|
|
{
|
|
unsigned long size = mem->size;
|
|
struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
|
|
struct device *dev = &ctx->dev->plat_dev->dev;
|
|
|
|
if (!mem->va) {
|
|
mtk_v4l2_err("%s dma_free size=%ld failed!", dev_name(dev),
|
|
size);
|
|
return;
|
|
}
|
|
|
|
mtk_v4l2_debug(3, "[%d] - va = %p", ctx->id, mem->va);
|
|
mtk_v4l2_debug(3, "[%d] - dma = 0x%lx", ctx->id,
|
|
(unsigned long)mem->dma_addr);
|
|
mtk_v4l2_debug(3, "[%d] size = 0x%lx", ctx->id, size);
|
|
|
|
dma_free_coherent(dev, size, mem->va, mem->dma_addr);
|
|
mem->va = NULL;
|
|
mem->dma_addr = 0;
|
|
mem->size = 0;
|
|
}
|
|
EXPORT_SYMBOL(mtk_vcodec_mem_free);
|
|
|
|
void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *dev,
|
|
struct mtk_vcodec_ctx *ctx)
|
|
{
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&dev->irqlock, flags);
|
|
dev->curr_ctx = ctx;
|
|
spin_unlock_irqrestore(&dev->irqlock, flags);
|
|
}
|
|
EXPORT_SYMBOL(mtk_vcodec_set_curr_ctx);
|
|
|
|
struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev)
|
|
{
|
|
unsigned long flags;
|
|
struct mtk_vcodec_ctx *ctx;
|
|
|
|
spin_lock_irqsave(&dev->irqlock, flags);
|
|
ctx = dev->curr_ctx;
|
|
spin_unlock_irqrestore(&dev->irqlock, flags);
|
|
return ctx;
|
|
}
|
|
EXPORT_SYMBOL(mtk_vcodec_get_curr_ctx);
|
|
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_DESCRIPTION("Mediatek video codec driver");
|