forked from Minki/linux
media: mtk-vcodec: Correct return type for mem2mem buffer helpers
Fix the assigned type of mem2mem buffer handling API. Namely, these functions: v4l2_m2m_next_buf v4l2_m2m_last_buf v4l2_m2m_buf_remove v4l2_m2m_next_src_buf v4l2_m2m_next_dst_buf v4l2_m2m_last_src_buf v4l2_m2m_last_dst_buf v4l2_m2m_src_buf_remove v4l2_m2m_dst_buf_remove return a struct vb2_v4l2_buffer, and not a struct vb2_buffer. Fixing this is necessary to fix the mem2mem buffer handling API, changing the return to the correct struct vb2_v4l2_buffer instead of a void pointer. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
9af469c5be
commit
0650a91499
@ -325,13 +325,12 @@ static void mtk_vdec_worker(struct work_struct *work)
|
|||||||
struct mtk_vcodec_ctx *ctx = container_of(work, struct mtk_vcodec_ctx,
|
struct mtk_vcodec_ctx *ctx = container_of(work, struct mtk_vcodec_ctx,
|
||||||
decode_work);
|
decode_work);
|
||||||
struct mtk_vcodec_dev *dev = ctx->dev;
|
struct mtk_vcodec_dev *dev = ctx->dev;
|
||||||
struct vb2_buffer *src_buf, *dst_buf;
|
struct vb2_v4l2_buffer *src_buf, *dst_buf;
|
||||||
struct mtk_vcodec_mem buf;
|
struct mtk_vcodec_mem buf;
|
||||||
struct vdec_fb *pfb;
|
struct vdec_fb *pfb;
|
||||||
bool res_chg = false;
|
bool res_chg = false;
|
||||||
int ret;
|
int ret;
|
||||||
struct mtk_video_dec_buf *dst_buf_info, *src_buf_info;
|
struct mtk_video_dec_buf *dst_buf_info, *src_buf_info;
|
||||||
struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
|
|
||||||
|
|
||||||
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
||||||
if (src_buf == NULL) {
|
if (src_buf == NULL) {
|
||||||
@ -347,26 +346,23 @@ static void mtk_vdec_worker(struct work_struct *work)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_vb2_v4l2 = container_of(src_buf, struct vb2_v4l2_buffer, vb2_buf);
|
src_buf_info = container_of(src_buf, struct mtk_video_dec_buf, vb);
|
||||||
src_buf_info = container_of(src_vb2_v4l2, struct mtk_video_dec_buf, vb);
|
dst_buf_info = container_of(dst_buf, struct mtk_video_dec_buf, vb);
|
||||||
|
|
||||||
dst_vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf);
|
|
||||||
dst_buf_info = container_of(dst_vb2_v4l2, struct mtk_video_dec_buf, vb);
|
|
||||||
|
|
||||||
pfb = &dst_buf_info->frame_buffer;
|
pfb = &dst_buf_info->frame_buffer;
|
||||||
pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0);
|
pfb->base_y.va = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
|
||||||
pfb->base_y.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
|
pfb->base_y.dma_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
|
||||||
pfb->base_y.size = ctx->picinfo.y_bs_sz + ctx->picinfo.y_len_sz;
|
pfb->base_y.size = ctx->picinfo.y_bs_sz + ctx->picinfo.y_len_sz;
|
||||||
|
|
||||||
pfb->base_c.va = vb2_plane_vaddr(dst_buf, 1);
|
pfb->base_c.va = vb2_plane_vaddr(&dst_buf->vb2_buf, 1);
|
||||||
pfb->base_c.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 1);
|
pfb->base_c.dma_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 1);
|
||||||
pfb->base_c.size = ctx->picinfo.c_bs_sz + ctx->picinfo.c_len_sz;
|
pfb->base_c.size = ctx->picinfo.c_bs_sz + ctx->picinfo.c_len_sz;
|
||||||
pfb->status = 0;
|
pfb->status = 0;
|
||||||
mtk_v4l2_debug(3, "===>[%d] vdec_if_decode() ===>", ctx->id);
|
mtk_v4l2_debug(3, "===>[%d] vdec_if_decode() ===>", ctx->id);
|
||||||
|
|
||||||
mtk_v4l2_debug(3,
|
mtk_v4l2_debug(3,
|
||||||
"id=%d Framebuf pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx",
|
"id=%d Framebuf pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx",
|
||||||
dst_buf->index, pfb,
|
dst_buf->vb2_buf.index, pfb,
|
||||||
pfb->base_y.va, &pfb->base_y.dma_addr,
|
pfb->base_y.va, &pfb->base_y.dma_addr,
|
||||||
&pfb->base_c.dma_addr, pfb->base_y.size);
|
&pfb->base_c.dma_addr, pfb->base_y.size);
|
||||||
|
|
||||||
@ -384,19 +380,19 @@ static void mtk_vdec_worker(struct work_struct *work)
|
|||||||
clean_display_buffer(ctx);
|
clean_display_buffer(ctx);
|
||||||
vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 0, 0);
|
vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 0, 0);
|
||||||
vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 1, 0);
|
vb2_set_plane_payload(&dst_buf_info->vb.vb2_buf, 1, 0);
|
||||||
dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_LAST;
|
dst_buf->flags |= V4L2_BUF_FLAG_LAST;
|
||||||
v4l2_m2m_buf_done(&dst_buf_info->vb, VB2_BUF_STATE_DONE);
|
v4l2_m2m_buf_done(&dst_buf_info->vb, VB2_BUF_STATE_DONE);
|
||||||
clean_free_buffer(ctx);
|
clean_free_buffer(ctx);
|
||||||
v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
|
v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf.va = vb2_plane_vaddr(src_buf, 0);
|
buf.va = vb2_plane_vaddr(&src_buf->vb2_buf, 0);
|
||||||
buf.dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
|
buf.dma_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);
|
||||||
buf.size = (size_t)src_buf->planes[0].bytesused;
|
buf.size = (size_t)src_buf->planes[0].bytesused;
|
||||||
if (!buf.va) {
|
if (!buf.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 src_addr is NULL!!",
|
mtk_v4l2_err("[%d] id=%d src_addr is NULL!!",
|
||||||
ctx->id, src_buf->index);
|
ctx->id, src_buf->vb2_buf.index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
|
mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
|
||||||
@ -416,10 +412,10 @@ static void mtk_vdec_worker(struct work_struct *work)
|
|||||||
mtk_v4l2_err(
|
mtk_v4l2_err(
|
||||||
" <===[%d], src_buf[%d] sz=0x%zx pts=%llu dst_buf[%d] vdec_if_decode() ret=%d res_chg=%d===>",
|
" <===[%d], src_buf[%d] sz=0x%zx pts=%llu dst_buf[%d] vdec_if_decode() ret=%d res_chg=%d===>",
|
||||||
ctx->id,
|
ctx->id,
|
||||||
src_buf->index,
|
src_buf->vb2_buf.index,
|
||||||
buf.size,
|
buf.size,
|
||||||
src_buf_info->vb.vb2_buf.timestamp,
|
src_buf_info->vb.vb2_buf.timestamp,
|
||||||
dst_buf->index,
|
dst_buf->vb2_buf.index,
|
||||||
ret, res_chg);
|
ret, res_chg);
|
||||||
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
|
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
|
||||||
if (ret == -EIO) {
|
if (ret == -EIO) {
|
||||||
@ -1103,7 +1099,7 @@ static int vb2ops_vdec_buf_prepare(struct vb2_buffer *vb)
|
|||||||
|
|
||||||
static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
|
static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
|
||||||
{
|
{
|
||||||
struct vb2_buffer *src_buf;
|
struct vb2_v4l2_buffer *src_buf;
|
||||||
struct mtk_vcodec_mem src_mem;
|
struct mtk_vcodec_mem src_mem;
|
||||||
bool res_chg = false;
|
bool res_chg = false;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -1149,8 +1145,7 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
|
|||||||
mtk_v4l2_err("No src buffer");
|
mtk_v4l2_err("No src buffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
|
buf = container_of(src_buf, struct mtk_video_dec_buf, vb);
|
||||||
buf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);
|
|
||||||
if (buf->lastframe) {
|
if (buf->lastframe) {
|
||||||
/* This shouldn't happen. Just in case. */
|
/* This shouldn't happen. Just in case. */
|
||||||
mtk_v4l2_err("Invalid flush buffer.");
|
mtk_v4l2_err("Invalid flush buffer.");
|
||||||
@ -1158,8 +1153,8 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_mem.va = vb2_plane_vaddr(src_buf, 0);
|
src_mem.va = vb2_plane_vaddr(&src_buf->vb2_buf, 0);
|
||||||
src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
|
src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0);
|
||||||
src_mem.size = (size_t)src_buf->planes[0].bytesused;
|
src_mem.size = (size_t)src_buf->planes[0].bytesused;
|
||||||
mtk_v4l2_debug(2,
|
mtk_v4l2_debug(2,
|
||||||
"[%d] buf id=%d va=%p dma=%pad size=%zx",
|
"[%d] buf id=%d va=%p dma=%pad size=%zx",
|
||||||
@ -1181,11 +1176,9 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb)
|
|||||||
mtk_v4l2_err("[%d] Unrecoverable error in vdec_if_decode.",
|
mtk_v4l2_err("[%d] Unrecoverable error in vdec_if_decode.",
|
||||||
ctx->id);
|
ctx->id);
|
||||||
ctx->state = MTK_STATE_ABORT;
|
ctx->state = MTK_STATE_ABORT;
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
|
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
|
||||||
VB2_BUF_STATE_ERROR);
|
|
||||||
} else {
|
} else {
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
|
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
|
||||||
VB2_BUF_STATE_DONE);
|
|
||||||
}
|
}
|
||||||
mtk_v4l2_debug(ret ? 0 : 1,
|
mtk_v4l2_debug(ret ? 0 : 1,
|
||||||
"[%d] vdec_if_decode() src_buf=%d, size=%zu, fail=%d, res_chg=%d",
|
"[%d] vdec_if_decode() src_buf=%d, size=%zu, fail=%d, res_chg=%d",
|
||||||
@ -1281,7 +1274,7 @@ static int vb2ops_vdec_start_streaming(struct vb2_queue *q, unsigned int count)
|
|||||||
|
|
||||||
static void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
|
static void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
|
||||||
{
|
{
|
||||||
struct vb2_buffer *src_buf = NULL, *dst_buf = NULL;
|
struct vb2_v4l2_buffer *src_buf = NULL, *dst_buf = NULL;
|
||||||
struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
|
struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
|
||||||
|
|
||||||
mtk_v4l2_debug(3, "[%d] (%d) state=(%x) ctx->decoded_frame_cnt=%d",
|
mtk_v4l2_debug(3, "[%d] (%d) state=(%x) ctx->decoded_frame_cnt=%d",
|
||||||
@ -1289,12 +1282,10 @@ static void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
|
|||||||
|
|
||||||
if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
|
if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
|
||||||
while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) {
|
while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) {
|
||||||
struct vb2_v4l2_buffer *vb2_v4l2 =
|
|
||||||
to_vb2_v4l2_buffer(src_buf);
|
|
||||||
struct mtk_video_dec_buf *buf_info = container_of(
|
struct mtk_video_dec_buf *buf_info = container_of(
|
||||||
vb2_v4l2, struct mtk_video_dec_buf, vb);
|
src_buf, struct mtk_video_dec_buf, vb);
|
||||||
if (!buf_info->lastframe)
|
if (!buf_info->lastframe)
|
||||||
v4l2_m2m_buf_done(vb2_v4l2,
|
v4l2_m2m_buf_done(src_buf,
|
||||||
VB2_BUF_STATE_ERROR);
|
VB2_BUF_STATE_ERROR);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1323,10 +1314,9 @@ static void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
|
|||||||
ctx->state = MTK_STATE_FLUSH;
|
ctx->state = MTK_STATE_FLUSH;
|
||||||
|
|
||||||
while ((dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx))) {
|
while ((dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx))) {
|
||||||
vb2_set_plane_payload(dst_buf, 0, 0);
|
vb2_set_plane_payload(&dst_buf->vb2_buf, 0, 0);
|
||||||
vb2_set_plane_payload(dst_buf, 1, 0);
|
vb2_set_plane_payload(&dst_buf->vb2_buf, 1, 0);
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf),
|
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR);
|
||||||
VB2_BUF_STATE_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -887,7 +887,7 @@ err_set_param:
|
|||||||
static void vb2ops_venc_stop_streaming(struct vb2_queue *q)
|
static void vb2ops_venc_stop_streaming(struct vb2_queue *q)
|
||||||
{
|
{
|
||||||
struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
|
struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
|
||||||
struct vb2_buffer *src_buf, *dst_buf;
|
struct vb2_v4l2_buffer *src_buf, *dst_buf;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mtk_v4l2_debug(2, "[%d]-> type=%d", ctx->id, q->type);
|
mtk_v4l2_debug(2, "[%d]-> type=%d", ctx->id, q->type);
|
||||||
@ -895,13 +895,11 @@ static void vb2ops_venc_stop_streaming(struct vb2_queue *q)
|
|||||||
if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
|
if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
|
||||||
while ((dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx))) {
|
while ((dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx))) {
|
||||||
dst_buf->planes[0].bytesused = 0;
|
dst_buf->planes[0].bytesused = 0;
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf),
|
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR);
|
||||||
VB2_BUF_STATE_ERROR);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx)))
|
while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx)))
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
|
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
|
||||||
VB2_BUF_STATE_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
|
if ((q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
|
||||||
@ -937,8 +935,7 @@ static int mtk_venc_encode_header(void *priv)
|
|||||||
{
|
{
|
||||||
struct mtk_vcodec_ctx *ctx = priv;
|
struct mtk_vcodec_ctx *ctx = priv;
|
||||||
int ret;
|
int ret;
|
||||||
struct vb2_buffer *src_buf, *dst_buf;
|
struct vb2_v4l2_buffer *src_buf, *dst_buf;
|
||||||
struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
|
|
||||||
struct mtk_vcodec_mem bs_buf;
|
struct mtk_vcodec_mem bs_buf;
|
||||||
struct venc_done_result enc_result;
|
struct venc_done_result enc_result;
|
||||||
|
|
||||||
@ -948,14 +945,14 @@ static int mtk_venc_encode_header(void *priv)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bs_buf.va = vb2_plane_vaddr(dst_buf, 0);
|
bs_buf.va = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
|
||||||
bs_buf.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
|
bs_buf.dma_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
|
||||||
bs_buf.size = (size_t)dst_buf->planes[0].length;
|
bs_buf.size = (size_t)dst_buf->planes[0].length;
|
||||||
|
|
||||||
mtk_v4l2_debug(1,
|
mtk_v4l2_debug(1,
|
||||||
"[%d] buf id=%d va=0x%p dma_addr=0x%llx size=%zu",
|
"[%d] buf id=%d va=0x%p dma_addr=0x%llx size=%zu",
|
||||||
ctx->id,
|
ctx->id,
|
||||||
dst_buf->index, bs_buf.va,
|
dst_buf->vb2_buf.index, bs_buf.va,
|
||||||
(u64)bs_buf.dma_addr,
|
(u64)bs_buf.dma_addr,
|
||||||
bs_buf.size);
|
bs_buf.size);
|
||||||
|
|
||||||
@ -964,26 +961,23 @@ static int mtk_venc_encode_header(void *priv)
|
|||||||
NULL, &bs_buf, &enc_result);
|
NULL, &bs_buf, &enc_result);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dst_buf->planes[0].bytesused = 0;
|
dst_buf->vb2_buf.planes[0].bytesused = 0;
|
||||||
ctx->state = MTK_STATE_ABORT;
|
ctx->state = MTK_STATE_ABORT;
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf),
|
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR);
|
||||||
VB2_BUF_STATE_ERROR);
|
|
||||||
mtk_v4l2_err("venc_if_encode failed=%d", ret);
|
mtk_v4l2_err("venc_if_encode failed=%d", ret);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
||||||
if (src_buf) {
|
if (src_buf) {
|
||||||
src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
|
dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
|
||||||
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
|
dst_buf->timecode = src_buf->timecode;
|
||||||
dst_buf->timestamp = src_buf->timestamp;
|
|
||||||
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
|
|
||||||
} else {
|
} else {
|
||||||
mtk_v4l2_err("No timestamp for the header buffer.");
|
mtk_v4l2_err("No timestamp for the header buffer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->state = MTK_STATE_HEADER;
|
ctx->state = MTK_STATE_HEADER;
|
||||||
dst_buf->planes[0].bytesused = enc_result.bs_size;
|
dst_buf->planes[0].bytesused = enc_result.bs_size;
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf), VB2_BUF_STATE_DONE);
|
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -991,9 +985,7 @@ static int mtk_venc_encode_header(void *priv)
|
|||||||
static int mtk_venc_param_change(struct mtk_vcodec_ctx *ctx)
|
static int mtk_venc_param_change(struct mtk_vcodec_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct venc_enc_param enc_prm;
|
struct venc_enc_param enc_prm;
|
||||||
struct vb2_buffer *vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
struct vb2_v4l2_buffer *vb2_v4l2 = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
||||||
struct vb2_v4l2_buffer *vb2_v4l2 =
|
|
||||||
container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
|
|
||||||
struct mtk_video_enc_buf *mtk_buf =
|
struct mtk_video_enc_buf *mtk_buf =
|
||||||
container_of(vb2_v4l2, struct mtk_video_enc_buf, vb);
|
container_of(vb2_v4l2, struct mtk_video_enc_buf, vb);
|
||||||
|
|
||||||
@ -1067,12 +1059,11 @@ static void mtk_venc_worker(struct work_struct *work)
|
|||||||
{
|
{
|
||||||
struct mtk_vcodec_ctx *ctx = container_of(work, struct mtk_vcodec_ctx,
|
struct mtk_vcodec_ctx *ctx = container_of(work, struct mtk_vcodec_ctx,
|
||||||
encode_work);
|
encode_work);
|
||||||
struct vb2_buffer *src_buf, *dst_buf;
|
struct vb2_v4l2_buffer *src_buf, *dst_buf;
|
||||||
struct venc_frm_buf frm_buf;
|
struct venc_frm_buf frm_buf;
|
||||||
struct mtk_vcodec_mem bs_buf;
|
struct mtk_vcodec_mem bs_buf;
|
||||||
struct venc_done_result enc_result;
|
struct venc_done_result enc_result;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
|
|
||||||
|
|
||||||
/* check dst_buf, dst_buf may be removed in device_run
|
/* check dst_buf, dst_buf may be removed in device_run
|
||||||
* to stored encdoe header so we need check dst_buf and
|
* to stored encdoe header so we need check dst_buf and
|
||||||
@ -1086,15 +1077,15 @@ static void mtk_venc_worker(struct work_struct *work)
|
|||||||
|
|
||||||
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
|
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
|
||||||
memset(&frm_buf, 0, sizeof(frm_buf));
|
memset(&frm_buf, 0, sizeof(frm_buf));
|
||||||
for (i = 0; i < src_buf->num_planes ; i++) {
|
for (i = 0; i < src_buf->vb2_buf.num_planes ; i++) {
|
||||||
frm_buf.fb_addr[i].dma_addr =
|
frm_buf.fb_addr[i].dma_addr =
|
||||||
vb2_dma_contig_plane_dma_addr(src_buf, i);
|
vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, i);
|
||||||
frm_buf.fb_addr[i].size =
|
frm_buf.fb_addr[i].size =
|
||||||
(size_t)src_buf->planes[i].length;
|
(size_t)src_buf->vb2_buf.planes[i].length;
|
||||||
}
|
}
|
||||||
bs_buf.va = vb2_plane_vaddr(dst_buf, 0);
|
bs_buf.va = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
|
||||||
bs_buf.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
|
bs_buf.dma_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0);
|
||||||
bs_buf.size = (size_t)dst_buf->planes[0].length;
|
bs_buf.size = (size_t)dst_buf->vb2_buf.planes[0].length;
|
||||||
|
|
||||||
mtk_v4l2_debug(2,
|
mtk_v4l2_debug(2,
|
||||||
"Framebuf PA=%llx Size=0x%zx;PA=0x%llx Size=0x%zx;PA=0x%llx Size=%zu",
|
"Framebuf PA=%llx Size=0x%zx;PA=0x%llx Size=0x%zx;PA=0x%llx Size=%zu",
|
||||||
@ -1108,28 +1099,21 @@ static void mtk_venc_worker(struct work_struct *work)
|
|||||||
ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
|
ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
|
||||||
&frm_buf, &bs_buf, &enc_result);
|
&frm_buf, &bs_buf, &enc_result);
|
||||||
|
|
||||||
src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
|
dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
|
||||||
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
|
dst_buf->timecode = src_buf->timecode;
|
||||||
|
|
||||||
dst_buf->timestamp = src_buf->timestamp;
|
|
||||||
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
|
|
||||||
|
|
||||||
if (enc_result.is_key_frm)
|
if (enc_result.is_key_frm)
|
||||||
dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
|
dst_buf->flags |= V4L2_BUF_FLAG_KEYFRAME;
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
|
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
|
||||||
VB2_BUF_STATE_ERROR);
|
|
||||||
dst_buf->planes[0].bytesused = 0;
|
dst_buf->planes[0].bytesused = 0;
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf),
|
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR);
|
||||||
VB2_BUF_STATE_ERROR);
|
|
||||||
mtk_v4l2_err("venc_if_encode failed=%d", ret);
|
mtk_v4l2_err("venc_if_encode failed=%d", ret);
|
||||||
} else {
|
} else {
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
|
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
|
||||||
VB2_BUF_STATE_DONE);
|
|
||||||
dst_buf->planes[0].bytesused = enc_result.bs_size;
|
dst_buf->planes[0].bytesused = enc_result.bs_size;
|
||||||
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(dst_buf),
|
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE);
|
||||||
VB2_BUF_STATE_DONE);
|
|
||||||
mtk_v4l2_debug(2, "venc_if_encode bs size=%d",
|
mtk_v4l2_debug(2, "venc_if_encode bs size=%d",
|
||||||
enc_result.bs_size);
|
enc_result.bs_size);
|
||||||
}
|
}
|
||||||
@ -1137,7 +1121,7 @@ static void mtk_venc_worker(struct work_struct *work)
|
|||||||
v4l2_m2m_job_finish(ctx->dev->m2m_dev_enc, ctx->m2m_ctx);
|
v4l2_m2m_job_finish(ctx->dev->m2m_dev_enc, ctx->m2m_ctx);
|
||||||
|
|
||||||
mtk_v4l2_debug(1, "<=== src_buf[%d] dst_buf[%d] venc_if_encode ret=%d Size=%u===>",
|
mtk_v4l2_debug(1, "<=== src_buf[%d] dst_buf[%d] venc_if_encode ret=%d Size=%u===>",
|
||||||
src_buf->index, dst_buf->index, ret,
|
src_buf->vb2_buf.index, dst_buf->vb2_buf.index, ret,
|
||||||
enc_result.bs_size);
|
enc_result.bs_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user