media: mediatek: vcodec: Removing struct 'mtk_vcodec_ctx/dev' for shared interface

The shared struct 'mtk_vcodec_ctx/dev' will be changed to
'mtk_vcodec_enc_ctx/dev' and 'mtk_vcodec_dec_ctx/dev' in order to separate
encoder and decoder. Removing common struct 'mtk_vcodec_ctx/dev' for shared
interface which encoder and decoder used at the same time. Then encoder and
decoder can call the same interface independently.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Yunfei Dong 2023-07-29 10:55:06 +08:00 committed by Mauro Carvalho Chehab
parent 2e9eadccf7
commit 32986215be
7 changed files with 41 additions and 41 deletions

View File

@ -11,32 +11,40 @@
#include "mtk_vcodec_intr.h" #include "mtk_vcodec_intr.h"
#include "mtk_vcodec_util.h" #include "mtk_vcodec_util.h"
int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx, int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned int timeout_ms,
int command, unsigned int timeout_ms,
unsigned int hw_id) unsigned int hw_id)
{ {
struct mtk_vcodec_ctx *ctx = priv;
long timeout_jiff, ret; long timeout_jiff, ret;
int status = 0; int ctx_id, ctx_type, status = 0;
int *ctx_int_cond, *ctx_int_type;
wait_queue_head_t *ctx_queue;
ctx_id = ctx->id;
ctx_type = ctx->type;
ctx_int_cond = ctx->int_cond;
ctx_int_type = ctx->int_type;
ctx_queue = ctx->queue;
timeout_jiff = msecs_to_jiffies(timeout_ms); timeout_jiff = msecs_to_jiffies(timeout_ms);
ret = wait_event_interruptible_timeout(ctx->queue[hw_id], ret = wait_event_interruptible_timeout(ctx_queue[hw_id],
ctx->int_cond[hw_id], ctx_int_cond[hw_id],
timeout_jiff); timeout_jiff);
if (!ret) { if (!ret) {
status = -1; /* timeout */ status = -1; /* timeout */
mtk_v4l2_err("[%d] cmd=%d, type=%d, dec timeout=%ums (%d %d)", mtk_v4l2_err("[%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)", mtk_v4l2_err("[%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;
ctx->int_type[hw_id] = 0; ctx_int_type[hw_id] = 0;
return status; return status;
} }

View File

@ -12,8 +12,7 @@
struct mtk_vcodec_ctx; struct mtk_vcodec_ctx;
/* timeout is ms */ /* timeout is ms */
int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx, int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned int timeout_ms,
int command, unsigned int timeout_ms,
unsigned int hw_id); unsigned int hw_id);
#endif /* _MTK_VCODEC_INTR_H_ */ #endif /* _MTK_VCODEC_INTR_H_ */

View File

@ -21,16 +21,13 @@ int mtk_v4l2_dbg_level;
EXPORT_SYMBOL(mtk_v4l2_dbg_level); EXPORT_SYMBOL(mtk_v4l2_dbg_level);
#endif #endif
void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data, void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx)
unsigned int reg_idx)
{ {
struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data; if (reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
if (!data || reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
mtk_v4l2_err("Invalid arguments, reg_idx=%d", reg_idx); mtk_v4l2_err("Invalid arguments, reg_idx=%d", reg_idx);
return NULL; return NULL;
} }
return ctx->dev->reg_base[reg_idx]; return reg_base[reg_idx];
} }
EXPORT_SYMBOL(mtk_vcodec_get_reg_addr); EXPORT_SYMBOL(mtk_vcodec_get_reg_addr);
@ -48,11 +45,10 @@ int mtk_vcodec_write_vdecsys(struct mtk_vcodec_ctx *ctx, unsigned int reg,
} }
EXPORT_SYMBOL(mtk_vcodec_write_vdecsys); EXPORT_SYMBOL(mtk_vcodec_write_vdecsys);
int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data, int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem)
struct mtk_vcodec_mem *mem)
{ {
unsigned long size = mem->size; unsigned long size = mem->size;
struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data; struct mtk_vcodec_ctx *ctx = priv;
struct device *dev = &ctx->dev->plat_dev->dev; struct device *dev = &ctx->dev->plat_dev->dev;
mem->va = dma_alloc_coherent(dev, size, &mem->dma_addr, GFP_KERNEL); mem->va = dma_alloc_coherent(dev, size, &mem->dma_addr, GFP_KERNEL);
@ -71,11 +67,10 @@ int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
} }
EXPORT_SYMBOL(mtk_vcodec_mem_alloc); EXPORT_SYMBOL(mtk_vcodec_mem_alloc);
void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data, void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
struct mtk_vcodec_mem *mem)
{ {
unsigned long size = mem->size; unsigned long size = mem->size;
struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data; struct mtk_vcodec_ctx *ctx = priv;
struct device *dev = &ctx->dev->plat_dev->dev; struct device *dev = &ctx->dev->plat_dev->dev;
if (!mem->va) { if (!mem->va) {

View File

@ -68,14 +68,10 @@ extern int mtk_vcodec_dbg;
#define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+") #define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+")
#define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-") #define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-")
void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data, void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx);
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, int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem);
unsigned int val); void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem);
int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
struct mtk_vcodec_mem *mem);
void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
struct mtk_vcodec_mem *mem);
void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev, void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
struct mtk_vcodec_ctx *ctx, int hw_idx); struct mtk_vcodec_ctx *ctx, int hw_idx);
struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev, struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev,

View File

@ -165,12 +165,14 @@ struct vdec_vp8_inst {
static void get_hw_reg_base(struct vdec_vp8_inst *inst) static void get_hw_reg_base(struct vdec_vp8_inst *inst)
{ {
inst->reg_base.top = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_TOP); void __iomem **reg_base = inst->ctx->dev->reg_base;
inst->reg_base.cm = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_CM);
inst->reg_base.hwd = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWD); inst->reg_base.top = mtk_vcodec_get_reg_addr(reg_base, VDEC_TOP);
inst->reg_base.misc = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_MISC); inst->reg_base.cm = mtk_vcodec_get_reg_addr(reg_base, VDEC_CM);
inst->reg_base.ld = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_LD); inst->reg_base.hwd = mtk_vcodec_get_reg_addr(reg_base, VDEC_HWD);
inst->reg_base.hwb = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWB); inst->reg_base.misc = mtk_vcodec_get_reg_addr(reg_base, VDEC_MISC);
inst->reg_base.ld = mtk_vcodec_get_reg_addr(reg_base, VDEC_LD);
inst->reg_base.hwb = mtk_vcodec_get_reg_addr(reg_base, VDEC_HWB);
} }
static void write_hw_segmentation_data(struct vdec_vp8_inst *inst) static void write_hw_segmentation_data(struct vdec_vp8_inst *inst)

View File

@ -612,7 +612,7 @@ static int h264_enc_init(struct mtk_vcodec_ctx *ctx)
inst->ctx = ctx; inst->ctx = ctx;
inst->vpu_inst.ctx = ctx; inst->vpu_inst.ctx = ctx;
inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264; inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264;
inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_SYS); inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VENC_SYS);
mtk_vcodec_debug_enter(inst); mtk_vcodec_debug_enter(inst);

View File

@ -336,7 +336,7 @@ static int vp8_enc_init(struct mtk_vcodec_ctx *ctx)
inst->ctx = ctx; inst->ctx = ctx;
inst->vpu_inst.ctx = ctx; inst->vpu_inst.ctx = ctx;
inst->vpu_inst.id = IPI_VENC_VP8; inst->vpu_inst.id = IPI_VENC_VP8;
inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_LT_SYS); inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VENC_LT_SYS);
mtk_vcodec_debug_enter(inst); mtk_vcodec_debug_enter(inst);