Commit 5bbb6e2c authored by Yunfei Dong's avatar Yunfei Dong Committed by Mauro Carvalho Chehab

media: mediatek: vcodec: add params to record lat and core lat_buf count

Using lat_buf to share decoder information between lat and core work
queue, adding params to record the buf count.

Fixes: 365e4ba0 ("media: mtk-vcodec: Add work queue for core hardware decode")
Signed-off-by: default avatarYunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 3b514e79
...@@ -52,6 +52,22 @@ static struct list_head *vdec_get_buf_list(int hardware_index, struct vdec_lat_b ...@@ -52,6 +52,22 @@ static struct list_head *vdec_get_buf_list(int hardware_index, struct vdec_lat_b
} }
} }
static void vdec_msg_queue_inc(struct vdec_msg_queue *msg_queue, int hardware_index)
{
if (hardware_index == MTK_VDEC_CORE)
atomic_inc(&msg_queue->core_list_cnt);
else
atomic_inc(&msg_queue->lat_list_cnt);
}
static void vdec_msg_queue_dec(struct vdec_msg_queue *msg_queue, int hardware_index)
{
if (hardware_index == MTK_VDEC_CORE)
atomic_dec(&msg_queue->core_list_cnt);
else
atomic_dec(&msg_queue->lat_list_cnt);
}
int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf *buf) int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf *buf)
{ {
struct list_head *head; struct list_head *head;
...@@ -66,6 +82,7 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf ...@@ -66,6 +82,7 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_buf
list_add_tail(head, &msg_ctx->ready_queue); list_add_tail(head, &msg_ctx->ready_queue);
msg_ctx->ready_num++; msg_ctx->ready_num++;
vdec_msg_queue_inc(&buf->ctx->msg_queue, msg_ctx->hardware_index);
if (msg_ctx->hardware_index != MTK_VDEC_CORE) if (msg_ctx->hardware_index != MTK_VDEC_CORE)
wake_up_all(&msg_ctx->ready_to_use); wake_up_all(&msg_ctx->ready_to_use);
else else
...@@ -127,6 +144,7 @@ struct vdec_lat_buf *vdec_msg_queue_dqbuf(struct vdec_msg_queue_ctx *msg_ctx) ...@@ -127,6 +144,7 @@ struct vdec_lat_buf *vdec_msg_queue_dqbuf(struct vdec_msg_queue_ctx *msg_ctx)
return NULL; return NULL;
} }
list_del(head); list_del(head);
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_debug(3, "dqueue buf type:%d addr: 0x%p num: %d",
...@@ -241,10 +259,13 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue, ...@@ -241,10 +259,13 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
vdec_msg_queue_init_ctx(&msg_queue->lat_ctx, MTK_VDEC_LAT0); vdec_msg_queue_init_ctx(&msg_queue->lat_ctx, MTK_VDEC_LAT0);
INIT_WORK(&msg_queue->core_work, vdec_msg_queue_core_work); INIT_WORK(&msg_queue->core_work, vdec_msg_queue_core_work);
atomic_set(&msg_queue->lat_list_cnt, 0);
atomic_set(&msg_queue->core_list_cnt, 0);
msg_queue->wdma_addr.size = msg_queue->wdma_addr.size =
vde_msg_queue_get_trans_size(ctx->picinfo.buf_w, vde_msg_queue_get_trans_size(ctx->picinfo.buf_w,
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_err("failed to allocate wdma_addr buf");
......
...@@ -72,6 +72,9 @@ struct vdec_lat_buf { ...@@ -72,6 +72,9 @@ struct vdec_lat_buf {
* @wdma_wptr_addr: ube write point * @wdma_wptr_addr: ube write point
* @core_work: core hardware work * @core_work: core hardware work
* @lat_ctx: used to store lat buffer list * @lat_ctx: used to store lat buffer list
*
* @lat_list_cnt: used to record each instance lat list count
* @core_list_cnt: used to record each instance core list count
*/ */
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];
...@@ -82,6 +85,9 @@ struct vdec_msg_queue { ...@@ -82,6 +85,9 @@ struct vdec_msg_queue {
struct work_struct core_work; struct work_struct core_work;
struct vdec_msg_queue_ctx lat_ctx; struct vdec_msg_queue_ctx lat_ctx;
atomic_t lat_list_cnt;
atomic_t core_list_cnt;
}; };
/** /**
......
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