author | Nanxin Qin <nanxin.qin@amlogic.com> | 2020-02-01 10:37:37 (GMT) |
---|---|---|
committer | Nanxin Qin <nanxin.qin@amlogic.com> | 2020-02-10 03:40:11 (GMT) |
commit | 4eed6421bc41d8b8148633069e5d05887cde7c59 (patch) | |
tree | 7c60cea6f0d16edbe7d63671948962e70f955a2b | |
parent | 46b5a47389d85215beb4946cf379a9701936e0f3 (diff) | |
download | media_modules-4eed6421bc41d8b8148633069e5d05887cde7c59.zip media_modules-4eed6421bc41d8b8148633069e5d05887cde7c59.tar.gz media_modules-4eed6421bc41d8b8148633069e5d05887cde7c59.tar.bz2 |
v4l: opitimize v4l debug module and interface unification. [1/1]
PD#SWPL-20310
Problem:
Opitimize v4l debug module and interface unification.
Solution:
opitimize v4l debug module and interface unification.
Verify:
u212
Change-Id: Ic7ee875c87389771505c838453dd2f5dd1c3e529
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
27 files changed, 1021 insertions, 982 deletions
diff --git a/drivers/amvdec_ports/Makefile b/drivers/amvdec_ports/Makefile index 86bc158..221c0d4 100644 --- a/drivers/amvdec_ports/Makefile +++ b/drivers/amvdec_ports/Makefile @@ -1,7 +1,6 @@ obj-m += amvdec_ports.o amvdec_ports-objs += aml_vcodec_dec_drv.o amvdec_ports-objs += aml_vcodec_dec.o -amvdec_ports-objs += aml_vcodec_dec_pm.o amvdec_ports-objs += aml_vcodec_util.o amvdec_ports-objs += aml_vcodec_adapt.o amvdec_ports-objs += aml_vcodec_vfm.o diff --git a/drivers/amvdec_ports/aml_vcodec_adapt.c b/drivers/amvdec_ports/aml_vcodec_adapt.c index da5637d..7bb8eea 100644 --- a/drivers/amvdec_ports/aml_vcodec_adapt.c +++ b/drivers/amvdec_ports/aml_vcodec_adapt.c @@ -201,7 +201,7 @@ static void change_vbufsize(struct vdec_s *vdec, struct stream_buf_s *pvbuf) { if (pvbuf->buf_start != 0) { - pr_info("streambuf is alloced before\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "streambuf is alloced before\n"); return; } @@ -261,7 +261,7 @@ static int audio_component_init(struct stream_port_s *port, int r; if ((port->flag & PORT_FLAG_AFORMAT) == 0) { - pr_err("aformat not set\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "aformat not set\n"); return 0; } @@ -335,7 +335,7 @@ static int video_component_init(struct stream_port_s *port, struct vdec_s *vdec = ada_ctx->vdec; if ((vdec->port_flag & PORT_FLAG_VFORMAT) == 0) { - pr_err("vformat not set\n"); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "vformat not set\n"); return -EPERM; } @@ -351,7 +351,7 @@ static int video_component_init(struct stream_port_s *port, if (port->type & PORT_TYPE_FRAME) { ret = vdec_init(vdec, pbuf->for_4k); if (ret < 0) { - pr_err("video_component_init %d, failed\n", __LINE__); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "failed\n"); video_component_release(port, pbuf, 2); return ret; } @@ -372,14 +372,14 @@ static int video_component_init(struct stream_port_s *port, ret = stbuf_init(pbuf, vdec, false); if (ret < 0) { - pr_err("video_component_init %d, stbuf_init failed\n", __LINE__); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "stbuf_init failed\n"); return ret; } /* todo: set path based on port flag */ ret = vdec_init(vdec, pbuf->for_4k); if (ret < 0) { - pr_err("video_component_init %d, vdec_init failed\n", __LINE__); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "vdec_init failed\n"); video_component_release(port, pbuf, 2); return ret; } @@ -387,8 +387,7 @@ static int video_component_init(struct stream_port_s *port, if (vdec_dual(vdec)) { ret = vdec_init(vdec->slave, pbuf->for_4k); if (ret < 0) { - pr_err("video_component_init %d, vdec_init failed\n", - __LINE__); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "vdec_init failed\n"); video_component_release(port, pbuf, 2); return ret; } @@ -398,7 +397,7 @@ static int video_component_init(struct stream_port_s *port, ret = esparser_init(pbuf, vdec); if (ret < 0) { video_component_release(port, pbuf, 3); - pr_err("esparser_init() failed\n"); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "esparser_init() failed\n"); return ret; } } @@ -537,7 +536,7 @@ static int vdec_ports_init(struct aml_vdec_adapt *ada_ctx) /* init hw and gate*/ ret = enable_hardware(vdec->port); if (ret < 0) { - pr_info("enable hw fail.\n"); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "enable hw fail.\n"); goto error1; } @@ -548,7 +547,7 @@ static int vdec_ports_init(struct aml_vdec_adapt *ada_ctx) && (vdec->port_flag & PORT_FLAG_AFORMAT)) { ret = audio_component_init(vdec->port, pabuf); if (ret < 0) { - pr_err("audio_component_init failed\n"); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "audio_component_init failed\n"); goto error1; } } @@ -564,7 +563,7 @@ static int vdec_ports_init(struct aml_vdec_adapt *ada_ctx) ret = video_component_init(vdec->port, pvbuf); if (ret < 0) { - pr_err("video_component_init failed\n"); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_ERROR, "video_component_init failed\n"); goto error2; } @@ -592,7 +591,7 @@ int video_decoder_init(struct aml_vdec_adapt *vdec) /* init the buffer work space and connect vdec.*/ ret = vdec_ports_init(vdec); if (ret < 0) { - pr_info("vdec ports init fail.\n"); + v4l_dbg(vdec->ctx, V4L_DEBUG_CODEC_ERROR, "vdec ports init fail.\n"); goto out; } out: @@ -606,14 +605,14 @@ int video_decoder_release(struct aml_vdec_adapt *vdec) ret = vdec_ports_release(port); if (ret < 0) { - pr_info("vdec ports release fail.\n"); + v4l_dbg(vdec->ctx, V4L_DEBUG_CODEC_ERROR, "vdec ports release fail.\n"); goto out; } /* disable gates */ ret = disable_hardware(port); if (ret < 0) { - pr_info("disable hw fail.\n"); + v4l_dbg(vdec->ctx, V4L_DEBUG_CODEC_ERROR, "disable hw fail.\n"); goto out; } out: @@ -652,14 +651,15 @@ int vdec_vbuf_write(struct aml_vdec_adapt *ada_ctx, } while (ret == -EAGAIN && try_cnt--); if (slow_input) { - pr_info("slow_input: es codec write size %x\n", ret); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_PRINFO, + "slow_input: es codec write size %x\n", ret); msleep(10); } #ifdef DATA_DEBUG /* dump to file */ //dump_write(vbuf, size); - //pr_info("vbuf: %p, size: %u, ret: %d\n", vbuf, size, ret); + //v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_PRINFO, "vbuf: %p, size: %u, ret: %d\n", vbuf, size, ret); #endif return ret; @@ -684,7 +684,8 @@ int vdec_vframe_write(struct aml_vdec_adapt *ada_ctx, ret = vdec_write_vframe(vdec, buf, count); if (slow_input) { - pr_info("slow_input: frame codec write size %d\n", ret); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_PRINFO, + "slow_input: frame codec write size %d\n", ret); msleep(30); } @@ -692,8 +693,9 @@ int vdec_vframe_write(struct aml_vdec_adapt *ada_ctx, /* dump to file */ dump_write(buf, count); #endif - aml_v4l2_debug(3, "[%d] write frames, vbuf: %p, size: %u, ret: %d, crc: %x", - ada_ctx->ctx->id, buf, count, ret, crc32_le(0, buf, count)); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_INPUT, + "write frames, vbuf: %p, size: %u, ret: %d, crc: %x\n", + buf, count, ret, crc32_le(0, buf, count)); return ret; } @@ -718,7 +720,8 @@ int aml_codec_reset(struct aml_vdec_adapt *ada_ctx, int *mode) vdec->input.have_frame_num == 0) *mode = V4L_RESET_MODE_LIGHT; - aml_v4l2_debug(2, "%s, reset mode: %d\n", __func__, *mode); + v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_PRINFO, + "reset mode: %d\n", *mode); ret = vdec_v4l2_reset(vdec, *mode); *mode = V4L_RESET_MODE_NORMAL; diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c index d15cfe7..bd36b4d 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec.c +++ b/drivers/amvdec_ports/aml_vcodec_dec.c @@ -26,7 +26,6 @@ //#include "aml_vcodec_intr.h" #include "aml_vcodec_util.h" #include "vdec_drv_if.h" -#include "aml_vcodec_dec_pm.h" #include <linux/delay.h> #include <linux/atomic.h> #include <linux/crc32.h> @@ -184,10 +183,6 @@ static struct aml_video_fmt *aml_vdec_find_format(struct v4l2_format *f) struct aml_video_fmt *fmt; unsigned int k; - aml_v4l2_debug(4, "%s, type: %u, planes: %u, fmt: %u\n", - __func__, f->type, f->fmt.pix_mp.num_planes, - f->fmt.pix_mp.pixelformat); - for (k = 0; k < NUM_FORMATS; k++) { fmt = &aml_video_formats[k]; if (fmt->fourcc == f->fmt.pix_mp.pixelformat) @@ -214,8 +209,8 @@ void aml_vdec_dispatch_event(struct aml_vcodec_ctx *ctx, u32 changes) ctx->state = AML_STATE_ABORT; ATRACE_COUNTER("v4l2_state", ctx->state); changes = V4L2_EVENT_REQUEST_EXIT; - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_ABORT)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_ABORT)\n"); } switch (changes) { @@ -227,18 +222,18 @@ void aml_vdec_dispatch_event(struct aml_vcodec_ctx *ctx, u32 changes) event.u.src_change.changes = changes; break; default: - pr_err("unsupport dispatch event %x\n", changes); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "unsupport dispatch event %x\n", changes); return; } v4l2_event_queue_fh(&ctx->fh, &event); - aml_v4l2_debug(3, "[%d] %s() changes: %x", - ctx->id, __func__, changes); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "changes: %x\n", changes); } static void aml_vdec_flush_decoder(struct aml_vcodec_ctx *ctx) { - aml_v4l2_debug(3, "[%d] %s() [%d]", ctx->id, __func__, __LINE__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "%s\n", __func__); aml_decoder_flush(ctx->ada_ctx); } @@ -249,7 +244,8 @@ static void aml_vdec_pic_info_update(struct aml_vcodec_ctx *ctx) int ret; if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->last_decoded_picinfo)) { - aml_v4l2_err("[%d] Error!! Cannot get param : GET_PARAM_PICTURE_INFO ERR", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Cannot get param : GET_PARAM_PICTURE_INFO ERR\n"); return; } @@ -257,7 +253,8 @@ static void aml_vdec_pic_info_update(struct aml_vcodec_ctx *ctx) ctx->last_decoded_picinfo.visible_height == 0 || ctx->last_decoded_picinfo.coded_width == 0 || ctx->last_decoded_picinfo.coded_height == 0) { - aml_v4l2_err("Cannot get correct pic info"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Cannot get correct pic info\n"); return; } @@ -265,8 +262,9 @@ static void aml_vdec_pic_info_update(struct aml_vcodec_ctx *ctx) (ctx->last_decoded_picinfo.visible_height == ctx->picinfo.visible_height)) return;*/ - aml_v4l2_debug(4, "[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)", - ctx->id, ctx->last_decoded_picinfo.visible_width, + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "new(%d,%d), old(%d,%d), real(%d,%d)\n", + ctx->last_decoded_picinfo.visible_width, ctx->last_decoded_picinfo.visible_height, ctx->picinfo.visible_width, ctx->picinfo.visible_height, ctx->last_decoded_picinfo.coded_width, @@ -274,7 +272,8 @@ static void aml_vdec_pic_info_update(struct aml_vcodec_ctx *ctx) ret = vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpbsize); if (dpbsize == 0) - aml_v4l2_err("[%d] Incorrect dpb size, ret=%d", ctx->id, ret); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Incorrect dpb size, ret=%d\n", ret); /* update picture information */ ctx->dpb_size = dpbsize; @@ -293,7 +292,8 @@ static bool aml_check_inst_quit(struct aml_vcodec_dev *dev, mutex_lock(&dev->dev_mutex); if (list_empty(&dev->ctx_list)) { - pr_info("v4l inst list is empty.\n"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "v4l inst list is empty.\n"); ret = true; goto out; } @@ -335,10 +335,14 @@ void vdec_frame_buffer_release(void *data) decoder_mmu_try_to_release_box(vf->mm_box.mmu_box); } - aml_v4l2_debug(2, "%s vf idx: %d, bmmu idx: %d, bmmu_box: %lx", - __func__, vf->index, vf->mm_box.bmmu_idx, (ulong) vf->mm_box.bmmu_box); - aml_v4l2_debug(2, "%s vf idx: %d, mmu_idx: %d, mmu_box: %lx", - __func__, vf->index, vf->mm_box.mmu_idx, (ulong) vf->mm_box.mmu_box); + v4l_dbg(0, V4L_DEBUG_CODEC_BUFMGR, + "[%d]: vf idx: %d, bmmu idx: %d, bmmu_box: %lx\n", + id, vf->index, vf->mm_box.bmmu_idx, + (ulong) vf->mm_box.bmmu_box); + v4l_dbg(0, V4L_DEBUG_CODEC_BUFMGR, + "[%d]: vf idx: %d, mmu_idx: %d, mmu_box: %lx\n", + id, vf->index, vf->mm_box.mmu_idx, + (ulong) vf->mm_box.mmu_box); } memset(data, 0, sizeof(struct file_private_data)); @@ -366,9 +370,10 @@ int get_fb_from_queue(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer **out_ return -1; } - aml_v4l2_debug(2, "[%d] %s() vbuf idx: %d, state: %d, ready: %d", - ctx->id, __func__, dst_buf->index, dst_buf->state, - v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx)); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "vbuf idx: %d, state: %d, ready: %d\n", + dst_buf->index, dst_buf->state, + v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx)); dst_vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf); dst_buf_info = container_of(dst_vb2_v4l2, struct aml_video_dec_buf, vb); @@ -386,8 +391,8 @@ int get_fb_from_queue(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer **out_ pfb->num_planes = dst_buf->num_planes; pfb->status = FB_ST_NORMAL; - aml_v4l2_debug(4, "[%d] idx: %u, 1 plane, y:(0x%lx, %d)", - ctx->id, dst_buf->index, + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "idx: %u, 1 plane, y:(0x%lx, %d)\n", dst_buf->index, pfb->m.mem[0].addr, pfb->m.mem[0].size); } else if (dst_buf->num_planes == 2) { pfb = &dst_buf_info->frame_buffer; @@ -403,8 +408,8 @@ int get_fb_from_queue(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer **out_ pfb->num_planes = dst_buf->num_planes; pfb->status = FB_ST_NORMAL; - aml_v4l2_debug(4, "[%d] idx: %u, 2 planes, y:(0x%lx, %d), c:(0x%lx, %d)", - ctx->id, dst_buf->index, + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "idx: %u, 2 planes, y:(0x%lx, %d), c:(0x%lx, %d)\n", dst_buf->index, pfb->m.mem[0].addr, pfb->m.mem[0].size, pfb->m.mem[1].addr, pfb->m.mem[1].size); } else { @@ -426,8 +431,9 @@ int get_fb_from_queue(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer **out_ pfb->num_planes = dst_buf->num_planes; pfb->status = FB_ST_NORMAL; - aml_v4l2_debug(4, "[%d] idx: %u, 3 planes, y:(0x%lx, %d), u:(0x%lx, %d), v:(0x%lx, %d)", - ctx->id, dst_buf->index, + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "idx: %u, 3 planes, y:(0x%lx, %d), u:(0x%lx, %d), v:(0x%lx, %d)\n", + dst_buf->index, pfb->m.mem[0].addr, pfb->m.mem[0].size, pfb->m.mem[1].addr, pfb->m.mem[1].size, pfb->m.mem[2].addr, pfb->m.mem[2].size); @@ -454,15 +460,13 @@ int put_fb_to_queue(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer *in_fb) { struct aml_video_dec_buf *dstbuf; - pr_info("[%d] %s() [%d]\n", ctx->id, __func__, __LINE__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "%s\n", __func__); if (in_fb == NULL) { - aml_v4l2_debug(4, "[%d] No free frame buffer", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, "No free frame buffer\n"); return -1; } - aml_v4l2_debug(4, "[%d] tmp_frame_addr = 0x%p", ctx->id, in_fb); - dstbuf = container_of(in_fb, struct aml_video_dec_buf, frame_buffer); mutex_lock(&ctx->lock); @@ -470,10 +474,9 @@ int put_fb_to_queue(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer *in_fb) if (!dstbuf->used) goto out; - aml_v4l2_debug(4, - "[%d] status=%x queue id=%d to rdy_queue", - ctx->id, in_fb->status, - dstbuf->vb.vb2_buf.index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "status=%x queue id=%d to rdy_queue\n", + in_fb->status, dstbuf->vb.vb2_buf.index); v4l2_m2m_buf_queue(ctx->m2m_ctx, &dstbuf->vb); @@ -491,13 +494,13 @@ void trans_vframe_to_user(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer *f struct aml_video_dec_buf *dstbuf = NULL; struct vframe_s *vf = (struct vframe_s *)fb->vf_handle; - aml_v4l2_debug(3, "[%d] FROM (%s %s) vf: %lx, ts: %llx, idx: %d", - ctx->id, vf_get_provider(ctx->ada_ctx->recv_name)->name, + v4l_dbg(ctx, V4L_DEBUG_CODEC_OUTPUT, + "FROM (%s %s) vf: %lx, ts: %llx, idx: %d, " + "Y:(%lx, %u) C/U:(%lx, %u) V:(%lx, %u)\n", + vf_get_provider(ctx->ada_ctx->recv_name)->name, ctx->ada_ctx->vfm_path != FRAME_BASE_PATH_V4L_VIDEO ? "OSD" : "VIDEO", - (ulong) vf, vf->timestamp, vf->index); - - aml_v4l2_debug(4, "[%d] FROM Y:(%lx, %u) C/U:(%lx, %u) V:(%lx, %u)", - ctx->id, fb->m.mem[0].addr, fb->m.mem[0].size, + (ulong) vf, vf->timestamp, vf->index, + fb->m.mem[0].addr, fb->m.mem[0].size, fb->m.mem[1].addr, fb->m.mem[1].size, fb->m.mem[2].addr, fb->m.mem[2].size); @@ -521,14 +524,16 @@ void trans_vframe_to_user(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer *f vb2_set_plane_payload(&dstbuf->vb.vb2_buf, 1, 0); } ctx->has_receive_eos = true; - pr_info("[%d] recevie a empty frame. idx: %d, state: %d\n", - ctx->id, dstbuf->vb.vb2_buf.index, + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "recevie a empty frame. idx: %d, state: %d\n", + dstbuf->vb.vb2_buf.index, dstbuf->vb.vb2_buf.state); ATRACE_COUNTER("v4l2_eos", 0); } - aml_v4l2_debug(4, "[%d] receive vbuf idx: %d, state: %d", - ctx->id, dstbuf->vb.vb2_buf.index, + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "receive vbuf idx: %d, state: %d\n", + dstbuf->vb.vb2_buf.index, dstbuf->vb.vb2_buf.state); if (dstbuf->vb.vb2_buf.state == VB2_BUF_STATE_ACTIVE) { @@ -547,8 +552,8 @@ void trans_vframe_to_user(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffer *f ctx->has_receive_eos) { ctx->state = AML_STATE_FLUSHED; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_FLUSHED)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_FLUSHED)\n"); } mutex_unlock(&ctx->state_lock); @@ -577,16 +582,18 @@ static int get_display_buffer(struct aml_vcodec_ctx *ctx, struct vdec_v4l2_buffe { int ret = -1; - aml_v4l2_debug(4, "[%d] %s()", ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "%s\n", __func__); ret = vdec_if_get_param(ctx, GET_PARAM_DISP_FRAME_BUFFER, out); if (ret) { - aml_v4l2_err("[%d] Cannot get param : GET_PARAM_DISP_FRAME_BUFFER", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Cannot get param : GET_PARAM_DISP_FRAME_BUFFER\n"); return -1; } if (!*out) { - aml_v4l2_debug(4, "[%d] No display frame buffer", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "No display frame buffer\n"); return -1; } @@ -603,10 +610,10 @@ static void aml_check_dpb_ready(struct aml_vcodec_ctx *ctx) if ((ctx->dpb_size) && (ctx->cap_pool.in >= ctx->dpb_size - 4)) ctx->v4l_codec_dpb_ready = true; - aml_v4l2_debug(2, "[%d] %s() dpb: %d, ready: %d, used: %d, dpb is ready: %s", - ctx->id, __func__, ctx->dpb_size, - v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx), - ctx->cap_pool.out, ctx->v4l_codec_dpb_ready ? "yes" : "no"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "dpb: %d, ready: %d, used: %d, dpb is ready: %s\n", + ctx->dpb_size, v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx), + ctx->cap_pool.out, ctx->v4l_codec_dpb_ready ? "yes" : "no"); } } @@ -615,8 +622,8 @@ static int is_vdec_ready(struct aml_vcodec_ctx *ctx) struct aml_vcodec_dev *dev = ctx->dev; if (!is_input_ready(ctx->ada_ctx)) { - pr_err("[%d] %s() the decoder intput has not ready.\n", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "the decoder input has not ready.\n"); v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); return 0; } @@ -628,8 +635,8 @@ static int is_vdec_ready(struct aml_vcodec_ctx *ctx) ATRACE_COUNTER("v4l2_state", ctx->state); ctx->v4l_codec_ready = true; wake_up_interruptible(&ctx->wq); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_READY)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_READY)\n"); } mutex_unlock(&ctx->state_lock); } @@ -640,8 +647,8 @@ static int is_vdec_ready(struct aml_vcodec_ctx *ctx) ctx->m2m_ctx->cap_q_ctx.q.streaming) { ctx->state = AML_STATE_ACTIVE; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_ACTIVE)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_ACTIVE)\n"); } } mutex_unlock(&ctx->state_lock); @@ -673,7 +680,8 @@ static void aml_wait_dpb_ready(struct aml_vcodec_ctx *ctx) u32 ready_num = 0; if (time_after(jiffies, expires)) { - pr_err("the DPB state has not ready.\n"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "the DPB state has not ready.\n"); break; } @@ -695,8 +703,6 @@ static void aml_vdec_worker(struct work_struct *work) struct aml_video_dec_buf *src_buf_info; struct vb2_v4l2_buffer *src_vb2_v4l2; - aml_v4l2_debug(4, "[%d] entry [%d] [%s]", ctx->id, __LINE__, __func__); - if (ctx->state < AML_STATE_INIT || ctx->state > AML_STATE_FLUSHED) { v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); @@ -704,14 +710,15 @@ static void aml_vdec_worker(struct work_struct *work) } if (!is_vdec_ready(ctx)) { - pr_err("[%d] %s() the decoder has not ready.\n", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "the decoder has not ready.\n"); goto out; } src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx); if (src_buf == NULL) { - pr_err("[%d] src_buf empty!\n", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "src_buf empty.\n"); goto out; } @@ -724,7 +731,8 @@ static void aml_vdec_worker(struct work_struct *work) if (src_buf_info->lastframe) { /*the empty data use to flushed the decoder.*/ - aml_v4l2_debug(2, "[%d] Got empty flush input buffer.", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "Got empty flush input buffer.\n"); /* * when inputs a small amount of src buff, then soon to @@ -739,8 +747,8 @@ static void aml_vdec_worker(struct work_struct *work) if (ctx->state == AML_STATE_ACTIVE) { ctx->state = AML_STATE_FLUSHING;// prepare flushing ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_FLUSHING-LASTFRM)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_FLUSHING-LASTFRM)\n"); } mutex_unlock(&ctx->state_lock); @@ -759,19 +767,20 @@ static void aml_vdec_worker(struct work_struct *work) buf.size = src_buf->planes[0].bytesused; if (!buf.vaddr) { v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); - aml_v4l2_err("[%d] id=%d src_addr is NULL!!", - ctx->id, src_buf->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "id=%d src_addr is NULL.\n", src_buf->index); goto out; } src_buf_info->used = true; - /* pr_err("%s() [%d], size: 0x%zx, crc: 0x%x\n", - __func__, __LINE__, buf.size, crc32(0, buf.va, buf.size));*/ + /* v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "size: 0x%zx, crc: 0x%x\n", + buf.size, crc32(0, buf.va, buf.size));*/ /* pts = (time / 10e6) * (90k / fps) */ - aml_v4l2_debug(4, "[%d] %s() timestamp: 0x%llx", ctx->id , __func__, - src_buf->timestamp); + /*v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "timestamp: 0x%llx\n", src_buf->timestamp);*/ ret = vdec_if_decode(ctx, &buf, src_buf->timestamp, &res_chg); if (ret > 0) { @@ -785,8 +794,8 @@ static void aml_vdec_worker(struct work_struct *work) src_buf_info->error = (ret == -EIO ? true : false); src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); v4l2_m2m_buf_done(&src_buf_info->vb, VB2_BUF_STATE_ERROR); - aml_v4l2_err("[%d] %s() error processing src data. %d.", - ctx->id, __func__, ret); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "error processing src data. %d.\n", ret); } else if (res_chg) { /* wait the DPB state to be ready. */ aml_wait_dpb_ready(ctx); @@ -803,8 +812,8 @@ static void aml_vdec_worker(struct work_struct *work) if (ctx->state == AML_STATE_ACTIVE) { ctx->state = AML_STATE_FLUSHING;// prepare flushing ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_FLUSHING-RESCHG)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_FLUSHING-RESCHG)\n"); } mutex_unlock(&ctx->state_lock); @@ -824,28 +833,29 @@ out: static void aml_vdec_reset(struct aml_vcodec_ctx *ctx) { if (ctx->state == AML_STATE_ABORT) { - pr_err("[%d] %s() the decoder will be exited.\n", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "the decoder will be exited.\n"); goto out; } if (aml_codec_reset(ctx->ada_ctx, &ctx->reset_flag)) { ctx->state = AML_STATE_ABORT; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_ABORT)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_ABORT).\n"); goto out; } if (ctx->state == AML_STATE_RESET) { ctx->state = AML_STATE_PROBE; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_PROBE)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_PROBE)\n"); - aml_v4l2_debug(0, "[%d] %s() dpb: %d, ready: %d, used: %d", - ctx->id, __func__, ctx->dpb_size, - v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx), ctx->buf_used_count); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "dpb: %d, ready: %d, used: %d\n", ctx->dpb_size, + v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx), + ctx->buf_used_count); /* vdec has ready to decode subsequence data of new resolution. */ ctx->q_data[AML_Q_DATA_SRC].resolution_changed = false; @@ -882,8 +892,8 @@ void try_to_capture(struct aml_vcodec_ctx *ctx) ret = get_display_buffer(ctx, &fb); if (ret) { - aml_v4l2_debug(4, "[%d] %s() [%d], the que have no disp buf,ret: %d", - ctx->id, __func__, __LINE__, ret); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "the que have no disp buf,ret: %d\n", ret); return; } @@ -903,8 +913,8 @@ static int vdec_thread(void *data) sched_setscheduler(current, SCHED_FIFO, ¶m); for (;;) { - aml_v4l2_debug(3, "[%d] %s() state: %d", ctx->id, - __func__, ctx->state); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "%s, state: %d\n", __func__, ctx->state); if (down_interruptible(&thread->sem)) break; @@ -994,11 +1004,17 @@ EXPORT_SYMBOL_GPL(aml_thread_stop); static int vidioc_try_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd) { + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, cmd: %u\n", __func__, cmd->cmd); + switch (cmd->cmd) { case V4L2_DEC_CMD_STOP: case V4L2_DEC_CMD_START: if (cmd->flags != 0) { - aml_v4l2_err("cmd->flags=%u", cmd->flags); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "cmd->flags=%u\n", cmd->flags); return -EINVAL; } break; @@ -1016,15 +1032,16 @@ static int vidioc_decoder_cmd(struct file *file, void *priv, struct vb2_queue *src_vq, *dst_vq; int ret; + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, cmd: %u\n", __func__, cmd->cmd); + ret = vidioc_try_decoder_cmd(file, priv, cmd); if (ret) return ret; - aml_v4l2_debug(2, "[%d] %s() [%d], cmd: %u", - ctx->id, __func__, __LINE__, cmd->cmd); dst_vq = v4l2_m2m_get_vq(ctx->m2m_ctx, - multiplanar ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : - V4L2_BUF_TYPE_VIDEO_CAPTURE); + multiplanar ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : + V4L2_BUF_TYPE_VIDEO_CAPTURE); switch (cmd->cmd) { case V4L2_DEC_CMD_STOP: ATRACE_COUNTER("v4l2_stop", 0); @@ -1034,8 +1051,8 @@ static int vidioc_decoder_cmd(struct file *file, void *priv, ctx->state = AML_STATE_ABORT; ATRACE_COUNTER("v4l2_state", ctx->state); aml_vdec_dispatch_event(ctx, V4L2_EVENT_REQUEST_EXIT); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_ABORT)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_ABORT)\n"); return 0; } } @@ -1043,12 +1060,14 @@ static int vidioc_decoder_cmd(struct file *file, void *priv, src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); if (!vb2_is_streaming(src_vq)) { - pr_err("[%d] Output stream is off. No need to flush.\n", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Output stream is off. No need to flush.\n"); return 0; } if (!vb2_is_streaming(dst_vq)) { - pr_err("[%d] Capture stream is off. No need to flush.\n", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Capture stream is off. No need to flush.\n"); return 0; } @@ -1059,7 +1078,7 @@ static int vidioc_decoder_cmd(struct file *file, void *priv, break; case V4L2_DEC_CMD_START: - aml_v4l2_debug(4, "[%d] CMD V4L2_DEC_CMD_START ", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "CMD V4L2_DEC_CMD_START\n"); vb2_clear_last_buffer_dequeued(dst_vq);//pay attention break; @@ -1090,8 +1109,8 @@ static int vidioc_decoder_streamon(struct file *file, void *priv, ctx->v4l_codec_ready = false; ctx->v4l_codec_dpb_ready = false; - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_RESET)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_RESET)\n"); aml_vdec_reset(ctx); } mutex_unlock(&ctx->state_lock); @@ -1099,6 +1118,10 @@ static int vidioc_decoder_streamon(struct file *file, void *priv, ctx->is_stream_off = false; } } + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, q->type); + return v4l2_m2m_ioctl_streamon(file, priv, i); } @@ -1114,12 +1137,16 @@ static int vidioc_decoder_streamoff(struct file *file, void *priv, ctx->is_stream_off = true; } + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, q->type); + return v4l2_m2m_ioctl_streamoff(file, priv, i); } static int vidioc_decoder_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *rb) { + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); struct v4l2_fh *fh = file->private_data; struct vb2_queue *q; @@ -1128,9 +1155,34 @@ static int vidioc_decoder_reqbufs(struct file *file, void *priv, if (!rb->count) vb2_queue_release(q); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, q->type); + return v4l2_m2m_ioctl_reqbufs(file, priv, rb); } +static int vidioc_vdec_querybuf(struct file *file, void *priv, + struct v4l2_buffer *buf) +{ + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, buf->type); + + return v4l2_m2m_ioctl_querybuf(file, priv, buf); +} + +static int vidioc_vdec_expbuf(struct file *file, void *priv, + struct v4l2_exportbuffer *eb) +{ + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, eb->type); + + return v4l2_m2m_ioctl_expbuf(file, priv, eb); +} + void aml_vcodec_dec_release(struct aml_vcodec_ctx *ctx) { ulong flags; @@ -1138,8 +1190,8 @@ void aml_vcodec_dec_release(struct aml_vcodec_ctx *ctx) flags = aml_vcodec_ctx_lock(ctx); ctx->state = AML_STATE_ABORT; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_ABORT)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_ABORT)\n"); aml_vcodec_ctx_unlock(ctx, flags); vdec_if_deinit(ctx); @@ -1193,20 +1245,23 @@ void aml_vcodec_dec_set_default_params(struct aml_vcodec_ctx *ctx) ctx->state = AML_STATE_IDLE; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_IDLE)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_IDLE)\n"); } static int vidioc_vdec_qbuf(struct file *file, void *priv, - struct v4l2_buffer *buf) + struct v4l2_buffer *buf) { struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); int ret; + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, buf->type); + if (ctx->state == AML_STATE_ABORT) { - aml_v4l2_err("[%d] Call on QBUF after unrecoverable error, type = %s", - ctx->id, V4L2_TYPE_IS_OUTPUT(buf->type) ? - "OUT" : "IN"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Call on QBUF after unrecoverable error, type = %s\n", + V4L2_TYPE_IS_OUTPUT(buf->type) ? "OUT" : "IN"); return -EIO; } @@ -1222,15 +1277,18 @@ static int vidioc_vdec_qbuf(struct file *file, void *priv, } static int vidioc_vdec_dqbuf(struct file *file, void *priv, - struct v4l2_buffer *buf) + struct v4l2_buffer *buf) { struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); int ret; + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, buf->type); + if (ctx->state == AML_STATE_ABORT) { - aml_v4l2_err("[%d] Call on DQBUF after unrecoverable error, type = %s", - ctx->id, V4L2_TYPE_IS_OUTPUT(buf->type) ? - "OUT" : "IN"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Call on DQBUF after unrecoverable error, type = %s\n", + V4L2_TYPE_IS_OUTPUT(buf->type) ? "OUT" : "IN"); if (!V4L2_TYPE_IS_OUTPUT(buf->type)) return -EIO; } @@ -1266,8 +1324,8 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv, (void*)&aml_buf->privdata, sizeof(struct file_private_data)); ATRACE_COUNTER("v4l2_dqout_ok", aml_buf->privdata.vf.index_disp); - aml_v4l2_debug(4, "[%d] %s, disp: %d, vf: %lx\n", ctx->id, - __func__, aml_buf->privdata.vf.index_disp, + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "disp: %d, vf: %lx\n", + aml_buf->privdata.vf.index_disp, (ulong) v4l_get_vf_handle(vb2_v4l2->private)); } fput(file); @@ -1278,18 +1336,27 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv, } static int vidioc_vdec_querycap(struct file *file, void *priv, - struct v4l2_capability *cap) + struct v4l2_capability *cap) { + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + strlcpy(cap->driver, AML_VCODEC_DEC_NAME, sizeof(cap->driver)); strlcpy(cap->bus_info, AML_PLATFORM_STR, sizeof(cap->bus_info)); strlcpy(cap->card, AML_PLATFORM_STR, sizeof(cap->card)); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s, %s\n", __func__, cap->card); + return 0; } static int vidioc_vdec_subscribe_evt(struct v4l2_fh *fh, - const struct v4l2_event_subscription *sub) + const struct v4l2_event_subscription *sub) { + struct aml_vcodec_ctx *ctx = fh_to_ctx(fh); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, sub->type); + switch (sub->type) { case V4L2_EVENT_EOS: return v4l2_event_subscribe(fh, sub, 2, NULL); @@ -1300,6 +1367,17 @@ static int vidioc_vdec_subscribe_evt(struct v4l2_fh *fh, } } +static int vidioc_vdec_event_unsubscribe(struct v4l2_fh *fh, + const struct v4l2_event_subscription *sub) +{ + struct aml_vcodec_ctx *ctx = fh_to_ctx(fh); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s, type: %d\n", + __func__, sub->type); + + return v4l2_event_unsubscribe(fh, sub); +} + static int vidioc_try_fmt(struct v4l2_format *f, struct aml_video_fmt *fmt) { struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; @@ -1342,12 +1420,6 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct aml_video_fmt *fmt) (pix_fmt_mp->height + 64) <= AML_VDEC_MAX_H) pix_fmt_mp->height += 64; - aml_v4l2_debug(4, - "before resize width=%d, height=%d, after resize width=%d, height=%d, sizeimage=%d", - tmp_w, tmp_h, pix_fmt_mp->width, - pix_fmt_mp->height, - pix_fmt_mp->width * pix_fmt_mp->height); - pix_fmt_mp->num_planes = fmt->num_planes; pix_fmt_mp->plane_fmt[0].sizeimage = pix_fmt_mp->width * pix_fmt_mp->height; @@ -1374,6 +1446,12 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv, struct v4l2_format *f) { struct aml_video_fmt *fmt = NULL; + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %u, planes: %u, fmt: %u\n", + __func__, f->type, f->fmt.pix_mp.num_planes, + f->fmt.pix_mp.pixelformat); fmt = aml_vdec_find_format(f); if (!fmt) @@ -1387,13 +1465,20 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, { struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; struct aml_video_fmt *fmt = NULL; + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %u, planes: %u, fmt: %u\n", + __func__, f->type, f->fmt.pix_mp.num_planes, + f->fmt.pix_mp.pixelformat); fmt = aml_vdec_find_format(f); if (!fmt) return -EINVAL; if (pix_fmt_mp->plane_fmt[0].sizeimage == 0) { - aml_v4l2_err("sizeimage of output format must be given"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "sizeimage of output format must be given\n"); return -EINVAL; } @@ -1401,7 +1486,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, } static int vidioc_vdec_g_selection(struct file *file, void *priv, - struct v4l2_selection *s) + struct v4l2_selection *s) { struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); struct aml_q_data *q_data; @@ -1443,17 +1528,22 @@ static int vidioc_vdec_g_selection(struct file *file, void *priv, s->r.top = 0; s->r.width = q_data->visible_width; s->r.height = q_data->visible_height; - return 0; } + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s, type: %d\n", + __func__, s->type); + return 0; } static int vidioc_vdec_s_selection(struct file *file, void *priv, - struct v4l2_selection *s) + struct v4l2_selection *s) { struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s, type: %d\n", + __func__, s->type); + if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; @@ -1472,7 +1562,7 @@ static int vidioc_vdec_s_selection(struct file *file, void *priv, } static int vidioc_vdec_s_fmt(struct file *file, void *priv, - struct v4l2_format *f) + struct v4l2_format *f) { struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); struct v4l2_pix_format_mplane *pix_mp; @@ -1480,7 +1570,10 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, int ret = 0; struct aml_video_fmt *fmt; - aml_v4l2_debug(4, "[%d] %s()", ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %u, planes: %u, fmt: %u\n", + __func__, f->type, f->fmt.pix_mp.num_planes, + f->fmt.pix_mp.pixelformat); q_data = aml_vdec_get_q_data(ctx, f->type); if (!q_data) @@ -1489,12 +1582,14 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, pix_mp = &f->fmt.pix_mp; if ((f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) && vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) { - aml_v4l2_err("[%d] out_q_ctx buffers already requested", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "out_q_ctx buffers already requested\n"); } if ((!V4L2_TYPE_IS_OUTPUT(f->type)) && vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) { - aml_v4l2_err("[%d] cap_q_ctx buffers already requested", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "cap_q_ctx buffers already requested\n"); } fmt = aml_vdec_find_format(f); @@ -1517,8 +1612,9 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, q_data->coded_width = pix_mp->width; q_data->coded_height = pix_mp->height; - aml_v4l2_debug(4, "[%d] %s() [%d], w: %d, h: %d, size: %d", - ctx->id, __func__, __LINE__, pix_mp->width, pix_mp->height, + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "w: %d, h: %d, size: %d\n", + pix_mp->width, pix_mp->height, pix_mp->plane_fmt[0].sizeimage); ctx->colorspace = f->fmt.pix_mp.colorspace; @@ -1530,15 +1626,15 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, if (ctx->state == AML_STATE_IDLE) { ret = vdec_if_init(ctx, q_data->fmt->fourcc); if (ret) { - aml_v4l2_err("[%d]: vdec_if_init() fail ret=%d", - ctx->id, ret); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "vdec_if_init() fail ret=%d\n", ret); mutex_unlock(&ctx->state_lock); return -EINVAL; } ctx->state = AML_STATE_INIT; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_INIT)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_INIT)\n"); } mutex_unlock(&ctx->state_lock); } @@ -1552,6 +1648,8 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, int i = 0; struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s\n", __func__); + if (fsize->index != 0) return -EINVAL; @@ -1563,20 +1661,21 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, fsize->stepwise = aml_vdec_framesizes[i].stepwise; if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED)) { - aml_v4l2_debug(4, "[%d] 4K is enabled", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "4K is enabled\n"); fsize->stepwise.max_width = VCODEC_DEC_4K_CODED_WIDTH; fsize->stepwise.max_height = VCODEC_DEC_4K_CODED_HEIGHT; } - aml_v4l2_debug(4, "[%d] %x, %d %d %d %d %d %d", - ctx->id, ctx->dev->dec_capability, - fsize->stepwise.min_width, - fsize->stepwise.max_width, - fsize->stepwise.step_width, - fsize->stepwise.min_height, - fsize->stepwise.max_height, - fsize->stepwise.step_height); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "%x, %d %d %d %d %d %d\n", + ctx->dev->dec_capability, + fsize->stepwise.min_width, + fsize->stepwise.max_width, + fsize->stepwise.step_width, + fsize->stepwise.min_height, + fsize->stepwise.max_height, + fsize->stepwise.step_height); return 0; } @@ -1605,20 +1704,28 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue) return -EINVAL; } -static int vidioc_vdec_enum_fmt_vid_cap_mplane(struct file *file, void *pirv, - struct v4l2_fmtdesc *f) +static int vidioc_vdec_enum_fmt_vid_cap_mplane(struct file *file, + void *priv, struct v4l2_fmtdesc *f) { + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s\n", __func__); + return vidioc_enum_fmt(f, false); } -static int vidioc_vdec_enum_fmt_vid_out_mplane(struct file *file, void *priv, - struct v4l2_fmtdesc *f) +static int vidioc_vdec_enum_fmt_vid_out_mplane(struct file *file, + void *priv, struct v4l2_fmtdesc *f) { + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s\n", __func__); + return vidioc_enum_fmt(f, true); } static int vidioc_vdec_g_fmt(struct file *file, void *priv, - struct v4l2_format *f) + struct v4l2_format *f) { struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; @@ -1627,7 +1734,8 @@ static int vidioc_vdec_g_fmt(struct file *file, void *priv, vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); if (!vq) { - aml_v4l2_err("[%d] no vb2 queue for type=%d", ctx->id, f->type); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "no vb2 queue for type=%d\n", f->type); return -EINVAL; } @@ -1700,14 +1808,32 @@ static int vidioc_vdec_g_fmt(struct file *file, void *priv, pix_mp->plane_fmt[1].bytesperline = q_data->bytesperline[1]; pix_mp->plane_fmt[1].sizeimage = q_data->sizeimage[1]; - aml_v4l2_debug(4, "[%d] type=%d state=%d Format information could not be read, not ready yet!", - ctx->id, f->type, ctx->state); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "type=%d state=%d Format information could not be read, not ready yet!\n", + f->type, ctx->state); return -EINVAL; } + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %u, planes: %u, fmt: %u\n", + __func__, f->type, f->fmt.pix_mp.num_planes, + f->fmt.pix_mp.pixelformat); + return 0; } +static int vidioc_vdec_create_bufs(struct file *file, void *priv, + struct v4l2_create_buffers *create) +{ + struct aml_vcodec_ctx *ctx = fh_to_ctx(priv); + + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %u, count: %u\n", + __func__, create->format.type, create->count); + + return v4l2_m2m_ioctl_create_bufs(file, priv, create); +} + /*int vidioc_vdec_g_ctrl(struct file *file, void *fh, struct v4l2_control *a) { @@ -1728,10 +1854,13 @@ static int vb2ops_vdec_queue_setup(struct vb2_queue *vq, struct aml_q_data *q_data; unsigned int i; - q_data = aml_vdec_get_q_data(ctx, vq->type); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s, type: %d\n", + __func__, vq->type); + q_data = aml_vdec_get_q_data(ctx, vq->type); if (q_data == NULL) { - aml_v4l2_err("[%d] vq->type=%d err", ctx->id, vq->type); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "vq->type=%d err\n", vq->type); return -EINVAL; } @@ -1755,8 +1884,9 @@ static int vb2ops_vdec_queue_setup(struct vb2_queue *vq, } } - pr_info("[%d] type: %d, plane: %d, buf cnt: %d, size: [Y: %u, C: %u]\n", - ctx->id, vq->type, *nplanes, *nbuffers, sizes[0], sizes[1]); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "type: %d, plane: %d, buf cnt: %d, size: [Y: %u, C: %u]\n", + vq->type, *nplanes, *nbuffers, sizes[0], sizes[1]); return 0; } @@ -1767,15 +1897,17 @@ static int vb2ops_vdec_buf_prepare(struct vb2_buffer *vb) struct aml_q_data *q_data; int i; - aml_v4l2_debug(4, "[%d] (%d) id=%d", - ctx->id, vb->vb2_queue->type, vb->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d, idx: %d\n", + __func__, vb->vb2_queue->type, vb->index); q_data = aml_vdec_get_q_data(ctx, vb->vb2_queue->type); for (i = 0; i < q_data->fmt->num_planes; i++) { if (vb2_plane_size(vb, i) < q_data->sizeimage[i]) { - aml_v4l2_err("[%d] data will not fit into plane %d (%lu < %d)", - ctx->id, i, vb2_plane_size(vb, i), + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "data will not fit into plane %d (%lu < %d)\n", + i, vb2_plane_size(vb, i), q_data->sizeimage[i]); } } @@ -1794,26 +1926,24 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) vb2_v4l2 = to_vb2_v4l2_buffer(vb); buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb); - aml_v4l2_debug(3, "[%d] %s(), vb: %lx, type: %d, idx: %d, state: %d, used: %d", - ctx->id, __func__, (ulong) vb, vb->vb2_queue->type, + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, vb: %lx, type: %d, idx: %d, state: %d, used: %d\n", + __func__, (ulong) vb, vb->vb2_queue->type, vb->index, vb->state, buf->used); /* * check if this buffer is ready to be used after decode */ if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { - aml_v4l2_debug(3, "[%d] %s() [%d], y_addr: %lx, vf_h: %lx, state: %d", ctx->id, - __func__, __LINE__, buf->frame_buffer.m.mem[0].addr, - buf->frame_buffer.vf_handle, buf->frame_buffer.status); - if (vb->index >= ctx->dpb_size) { - aml_v4l2_debug(2, "[%d] enque capture buf idx %d is invalid.", - ctx->id, vb->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "enque capture buf idx %d is invalid.\n", vb->index); return; } if (!buf->que_in_m2m) { - aml_v4l2_debug(2, "[%d] enque capture buf idx %d, vf: %lx", - ctx->id, vb->index, (ulong) v4l_get_vf_handle(vb2_v4l2->private)); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "enque capture buf idx %d, vf: %lx\n", + vb->index, (ulong) v4l_get_vf_handle(vb2_v4l2->private)); v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2); buf->que_in_m2m = true; @@ -1840,8 +1970,6 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb)); if (ctx->state != AML_STATE_INIT) { - aml_v4l2_debug(4, "[%d] already init driver %d", - ctx->id, ctx->state); return; } @@ -1849,7 +1977,8 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb); if (buf->lastframe) { /* This shouldn't happen. Just in case. */ - aml_v4l2_err("[%d] Invalid flush buffer.", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Invalid flush buffer.\n"); v4l2_m2m_src_buf_remove(ctx->m2m_ctx); return; } @@ -1864,12 +1993,14 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) } if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo)) { - pr_err("[%d] GET_PARAM_PICTURE_INFO err\n", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "GET_PARAM_PICTURE_INFO err\n"); return; } if (vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpb)) { - pr_err("[%d] GET_PARAM_DPB_SIZE err\n", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "GET_PARAM_DPB_SIZE err\n"); return; } @@ -1884,8 +2015,8 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) if (ctx->state == AML_STATE_INIT) { ctx->state = AML_STATE_PROBE; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_PROBE)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_PROBE)\n"); } mutex_unlock(&ctx->state_lock); } @@ -1897,6 +2028,10 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer *vb) struct aml_video_dec_buf *buf = NULL; bool buf_error; + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d, idx: %d\n", + __func__, vb->vb2_queue->type, vb->index); + vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf); buf = container_of(vb2_v4l2, struct aml_video_dec_buf, vb); @@ -1907,11 +2042,12 @@ static void vb2ops_vdec_buf_finish(struct vb2_buffer *vb) buf_error = buf->error; if (buf_error) { - aml_v4l2_err("[%d] Unrecoverable error on buffer.", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Unrecoverable error on buffer.\n"); ctx->state = AML_STATE_ABORT; ATRACE_COUNTER("v4l2_state", ctx->state); - aml_v4l2_debug(1, "[%d] %s() vcodec state (AML_STATE_ABORT)", - ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_STATE, + "vcodec state (AML_STATE_ABORT)\n"); } } @@ -1925,8 +2061,8 @@ static int vb2ops_vdec_buf_init(struct vb2_buffer *vb) unsigned int size, phy_addr = 0; char *owner = __getname(); - aml_v4l2_debug(4, "[%d] (%d) id=%d", - ctx->id, vb->vb2_queue->type, vb->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s, type: %d, idx: %d\n", + __func__, vb->vb2_queue->type, vb->index); if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { buf->used = false; @@ -1947,8 +2083,9 @@ static int vb2ops_vdec_buf_init(struct vb2_buffer *vb) buf->mem[0] = v4l_reqbufs_from_codec_mm(buf->mem_onwer, phy_addr, size, vb->index); - aml_v4l2_debug(3, "[%d] IN alloc, addr: %x, size: %u, idx: %u", - ctx->id, phy_addr, size, vb->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "IN alloc, addr: %x, size: %u, idx: %u\n", + phy_addr, size, vb->index); } else { snprintf(owner, PATH_MAX, "%s-%d", "v4l-output", ctx->id); strncpy(buf->mem_onwer, owner, sizeof(buf->mem_onwer)); @@ -1959,22 +2096,25 @@ static int vb2ops_vdec_buf_init(struct vb2_buffer *vb) phy_addr = vb2_dma_contig_plane_dma_addr(vb, 0); buf->mem[0] = v4l_reqbufs_from_codec_mm(buf->mem_onwer, phy_addr, size, vb->index); - aml_v4l2_debug(3, "[%d] OUT Y alloc, addr: %x, size: %u, idx: %u", - ctx->id, phy_addr, size, vb->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "OUT Y alloc, addr: %x, size: %u, idx: %u\n", + phy_addr, size, vb->index); } else if ((vb->memory == VB2_MEMORY_MMAP) && (vb->num_planes == 2)) { size = vb->planes[0].length; phy_addr = vb2_dma_contig_plane_dma_addr(vb, 0); buf->mem[0] = v4l_reqbufs_from_codec_mm(buf->mem_onwer, phy_addr, size, vb->index); - aml_v4l2_debug(3, "[%d] OUT Y alloc, addr: %x, size: %u, idx: %u", - ctx->id, phy_addr, size, vb->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "OUT Y alloc, addr: %x, size: %u, idx: %u\n", + phy_addr, size, vb->index); size = vb->planes[1].length; phy_addr = vb2_dma_contig_plane_dma_addr(vb, 1); buf->mem[1] = v4l_reqbufs_from_codec_mm(buf->mem_onwer, phy_addr, size, vb->index); - aml_v4l2_debug(3, "[%d] OUT C alloc, addr: %x, size: %u, idx: %u", - ctx->id, phy_addr, size, vb->index); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "OUT C alloc, addr: %x, size: %u, idx: %u\n", + phy_addr, size, vb->index); } } @@ -1999,8 +2139,9 @@ static void codec_mm_bufs_cnt_clean(struct vb2_queue *q) if (V4L2_TYPE_IS_OUTPUT(q->bufs[i]->type)) { v4l_freebufs_back_to_codec_mm(buf->mem_onwer, buf->mem[0]); - aml_v4l2_debug(3, "[%d] IN clean, addr: %lx, size: %u, idx: %u", - ctx->id, buf->mem[0]->phy_addr, buf->mem[0]->buffer_size, i); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "IN clean, addr: %lx, size: %u, idx: %u\n", + buf->mem[0]->phy_addr, buf->mem[0]->buffer_size, i); buf->mem[0] = NULL; continue; } @@ -2009,10 +2150,12 @@ static void codec_mm_bufs_cnt_clean(struct vb2_queue *q) v4l_freebufs_back_to_codec_mm(buf->mem_onwer, buf->mem[0]); v4l_freebufs_back_to_codec_mm(buf->mem_onwer, buf->mem[1]); - aml_v4l2_debug(3, "[%d] OUT Y clean, addr: %lx, size: %u, idx: %u", - ctx->id, buf->mem[0]->phy_addr, buf->mem[0]->buffer_size, i); - aml_v4l2_debug(3, "[%d] OUT C clean, addr: %lx, size: %u, idx: %u", - ctx->id, buf->mem[1]->phy_addr, buf->mem[1]->buffer_size, i); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "OUT Y clean, addr: %lx, size: %u, idx: %u\n", + buf->mem[0]->phy_addr, buf->mem[0]->buffer_size, i); + v4l_dbg(ctx, V4L_DEBUG_CODEC_BUFMGR, + "OUT C clean, addr: %lx, size: %u, idx: %u\n", + buf->mem[1]->phy_addr, buf->mem[1]->buffer_size, i); buf->mem[0] = NULL; buf->mem[1] = NULL; } @@ -2026,6 +2169,9 @@ static int vb2ops_vdec_start_streaming(struct vb2_queue *q, unsigned int count) ctx->has_receive_eos = false; v4l2_m2m_set_dst_buffered(ctx->fh.m2m_ctx, true); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d\n", __func__, q->type); + return 0; } @@ -2036,8 +2182,9 @@ static void vb2ops_vdec_stop_streaming(struct vb2_queue *q) struct aml_vcodec_ctx *ctx = vb2_get_drv_priv(q); int i; - aml_v4l2_debug(3, "[%d] (%d) state=(%x) frame_cnt=%d", - ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, + "%s, type: %d, state: %x, frame_cnt: %d\n", + __func__, q->type, ctx->state, ctx->decoded_frame_cnt); codec_mm_bufs_cnt_clean(q); @@ -2058,7 +2205,7 @@ static void vb2ops_vdec_stop_streaming(struct vb2_queue *q) if (vb2_v4l2->vb2_buf.state == VB2_BUF_STATE_ACTIVE) v4l2_m2m_buf_done(vb2_v4l2, VB2_BUF_STATE_ERROR); - /*pr_info("idx: %d, state: %d\n", + /*v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "idx: %d, state: %d\n", q->bufs[i]->index, q->bufs[i]->state);*/ } } @@ -2072,15 +2219,11 @@ static void m2mops_vdec_device_run(void *priv) struct aml_vcodec_ctx *ctx = priv; struct aml_vcodec_dev *dev = ctx->dev; - aml_v4l2_debug(4, "[%d] %s() [%d]", ctx->id, __func__, __LINE__); - queue_work(dev->decode_workqueue, &ctx->decode_work); } void vdec_device_vf_run(struct aml_vcodec_ctx *ctx) { - aml_v4l2_debug(3, "[%d] %s() [%d]", ctx->id, __func__, __LINE__); - if (ctx->state < AML_STATE_INIT || ctx->state > AML_STATE_FLUSHED) return; @@ -2092,9 +2235,6 @@ static int m2mops_vdec_job_ready(void *m2m_priv) { struct aml_vcodec_ctx *ctx = m2m_priv; - aml_v4l2_debug(4, "[%d] %s(), state: %d", ctx->id, - __func__, ctx->state); - if (ctx->state < AML_STATE_PROBE || ctx->state > AML_STATE_FLUSHED) return 0; @@ -2106,7 +2246,7 @@ static void m2mops_vdec_job_abort(void *priv) { struct aml_vcodec_ctx *ctx = priv; - aml_v4l2_debug(3, "[%d] %s() [%d]", ctx->id, __func__, __LINE__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "%s\n", __func__); } static int aml_vdec_g_v_ctrl(struct v4l2_ctrl *ctrl) @@ -2114,14 +2254,15 @@ static int aml_vdec_g_v_ctrl(struct v4l2_ctrl *ctrl) struct aml_vcodec_ctx *ctx = ctrl_to_ctx(ctrl); int ret = 0; - aml_v4l2_debug(4, "%s() [%d]", __func__, __LINE__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s\n", __func__); switch (ctrl->id) { case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: if (ctx->state >= AML_STATE_PROBE) { ctrl->val = ctx->dpb_size; } else { - pr_err("Seqinfo not ready.\n"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Seqinfo not ready.\n"); ctrl->val = 0; ret = -EINVAL; } @@ -2136,11 +2277,12 @@ static int aml_vdec_try_s_v_ctrl(struct v4l2_ctrl *ctrl) { struct aml_vcodec_ctx *ctx = ctrl_to_ctx(ctrl); - aml_v4l2_debug(4, "%s() [%d]", __func__, __LINE__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s\n", __func__); if (ctrl->id == AML_V4L2_SET_DECMODE) { ctx->is_drm_mode = ctrl->val; - pr_info("set stream mode: %x\n", ctrl->val); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, + "set stream mode: %x\n", ctrl->val); } return 0; @@ -2189,35 +2331,41 @@ int aml_vcodec_dec_ctrls_setup(struct aml_vcodec_ctx *ctx) return 0; err: - aml_v4l2_err("[%d] Adding control failed %d", - ctx->id, ctx->ctrl_hdl.error); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Adding control failed %d\n", + ctx->ctrl_hdl.error); v4l2_ctrl_handler_free(&ctx->ctrl_hdl); return ret; } static int vidioc_vdec_g_parm(struct file *file, void *fh, - struct v4l2_streamparm *a) + struct v4l2_streamparm *a) { struct aml_vcodec_ctx *ctx = fh_to_ctx(fh); if (a->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { if (vdec_if_get_param(ctx, GET_PARAM_CONFIG_INFO, &ctx->config.parm.dec)) { - pr_err("[%d] GET_PARAM_CONFIG_INFO err\n", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "GET_PARAM_CONFIG_INFO err\n"); return -1; } memcpy(a->parm.raw_data, ctx->config.parm.data, sizeof(a->parm.raw_data)); } + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s\n", __func__); + return 0; } static int vidioc_vdec_s_parm(struct file *file, void *fh, - struct v4l2_streamparm *a) + struct v4l2_streamparm *a) { struct aml_vcodec_ctx *ctx = fh_to_ctx(fh); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT, "%s\n", __func__); + if (a->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { struct aml_dec_params *in = (struct aml_dec_params *) a->parm.raw_data; @@ -2244,7 +2392,6 @@ static void m2mops_vdec_lock(void *m2m_priv) { struct aml_vcodec_ctx *ctx = m2m_priv; - aml_v4l2_debug(4, "[%d] %s()", ctx->id, __func__); mutex_lock(&ctx->dev->dev_mutex); } @@ -2252,7 +2399,6 @@ static void m2mops_vdec_unlock(void *m2m_priv) { struct aml_vcodec_ctx *ctx = m2m_priv; - aml_v4l2_debug(4, "[%d] %s()", ctx->id, __func__); mutex_unlock(&ctx->dev->dev_mutex); } @@ -2280,8 +2426,8 @@ const struct v4l2_ioctl_ops aml_vdec_ioctl_ops = { .vidioc_streamon = vidioc_decoder_streamon, .vidioc_streamoff = vidioc_decoder_streamoff, .vidioc_reqbufs = vidioc_decoder_reqbufs, - .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, - .vidioc_expbuf = v4l2_m2m_ioctl_expbuf,//?? + .vidioc_querybuf = vidioc_vdec_querybuf, + .vidioc_expbuf = vidioc_vdec_expbuf,//?? //.vidioc_g_ctrl = vidioc_vdec_g_ctrl, .vidioc_qbuf = vidioc_vdec_qbuf, @@ -2301,7 +2447,7 @@ const struct v4l2_ioctl_ops aml_vdec_ioctl_ops = { .vidioc_g_fmt_vid_out_mplane = vidioc_vdec_g_fmt, .vidioc_g_fmt_vid_out = vidioc_vdec_g_fmt, - .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, + .vidioc_create_bufs = vidioc_vdec_create_bufs, .vidioc_enum_fmt_vid_cap_mplane = vidioc_vdec_enum_fmt_vid_cap_mplane, .vidioc_enum_fmt_vid_cap = vidioc_vdec_enum_fmt_vid_cap_mplane, @@ -2311,7 +2457,7 @@ const struct v4l2_ioctl_ops aml_vdec_ioctl_ops = { .vidioc_querycap = vidioc_vdec_querycap, .vidioc_subscribe_event = vidioc_vdec_subscribe_evt, - .vidioc_unsubscribe_event = v4l2_event_unsubscribe, + .vidioc_unsubscribe_event = vidioc_vdec_event_unsubscribe, .vidioc_g_selection = vidioc_vdec_g_selection, .vidioc_s_selection = vidioc_vdec_s_selection, @@ -2328,7 +2474,7 @@ int aml_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq, struct aml_vcodec_ctx *ctx = priv; int ret = 0; - aml_v4l2_debug(4, "[%d] %s()", ctx->id, __func__); + v4l_dbg(ctx, V4L_DEBUG_CODEC_EXINFO, "%s\n", __func__); src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; src_vq->io_modes = VB2_DMABUF | VB2_MMAP; @@ -2340,7 +2486,8 @@ int aml_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->lock = &ctx->dev->dev_mutex; ret = vb2_queue_init(src_vq); if (ret) { - aml_v4l2_err("[%d] Failed to initialize videobuf2 queue(output)", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Failed to initialize videobuf2 queue(output)\n"); return ret; } @@ -2356,7 +2503,8 @@ int aml_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq, ret = vb2_queue_init(dst_vq); if (ret) { vb2_queue_release(src_vq); - aml_v4l2_err("[%d] Failed to initialize videobuf2 queue(capture)", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Failed to initialize videobuf2 queue(capture)\n"); } return ret; diff --git a/drivers/amvdec_ports/aml_vcodec_dec_drv.c b/drivers/amvdec_ports/aml_vcodec_dec_drv.c index ca35086..f1505fb 100644 --- a/drivers/amvdec_ports/aml_vcodec_dec_drv.c +++ b/drivers/amvdec_ports/aml_vcodec_dec_drv.c @@ -32,7 +32,6 @@ #include "aml_vcodec_drv.h" #include "aml_vcodec_dec.h" -#include "aml_vcodec_dec_pm.h" #include "aml_vcodec_util.h" #include "aml_vcodec_vfm.h" #include <linux/file.h> @@ -92,14 +91,16 @@ static int fops_vcodec_open(struct file *file) ctx->type = AML_INST_DECODER; ret = aml_vcodec_dec_ctrls_setup(ctx); if (ret) { - aml_v4l2_err("Failed to setup vcodec controls"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Failed to setup vcodec controls\n"); goto err_ctrls_setup; } ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_dec, ctx, &aml_vcodec_dec_queue_init); if (IS_ERR((__force void *)ctx->m2m_ctx)) { ret = PTR_ERR((__force void *)ctx->m2m_ctx); - aml_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)", ret); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Failed to v4l2_m2m_ctx_init() (%d)\n", ret); goto err_m2m_ctx_init; } src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx, @@ -110,14 +111,16 @@ static int fops_vcodec_open(struct file *file) ret = aml_thread_start(ctx, try_to_capture, AML_THREAD_CAPTURE, "cap"); if (ret) { - aml_v4l2_err("Failed to creat capture thread."); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Failed to creat capture thread.\n"); goto err_creat_thread; } list_add(&ctx->list, &dev->ctx_list); mutex_unlock(&dev->dev_mutex); - pr_info("[%d] %s decoder %lx\n", ctx->id, dev_name(&dev->plat_dev->dev), (ulong)ctx); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "%s decoder %lx\n", + dev_name(&dev->plat_dev->dev), (ulong)ctx); return ret; @@ -141,7 +144,7 @@ static int fops_vcodec_release(struct file *file) struct aml_vcodec_dev *dev = video_drvdata(file); struct aml_vcodec_ctx *ctx = fh_to_ctx(file->private_data); - pr_info("[%d] release decoder %lx\n", ctx->id, (ulong) ctx); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "release decoder %lx\n", (ulong) ctx); mutex_lock(&dev->dev_mutex); /* @@ -168,8 +171,8 @@ static int fops_vcodec_release(struct file *file) static int v4l2video_file_release(struct inode *inode, struct file *file) { - aml_v4l2_debug(2,"%s: file: %lx, data: %lx", - __func__, (ulong) file, (ulong) file->private_data); + v4l_dbg(0, V4L_DEBUG_CODEC_BUFMGR, "file: %lx, data: %lx\n", + (ulong) file, (ulong) file->private_data); if (file->private_data) vdec_frame_buffer_release(file->private_data); @@ -187,25 +190,28 @@ int v4l2_alloc_fd(int *fd) int file_fd = get_unused_fd_flags(O_CLOEXEC); if (file_fd < 0) { - pr_err("%s: get unused fd fail\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "get unused fd fail\n"); return -ENODEV; } file = anon_inode_getfile("v4l2_meta_file", &v4l2_file_fops, NULL, 0); if (IS_ERR(file)) { put_unused_fd(file_fd); - pr_err("%s: anon_inode_getfile fail\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "anon_inode_getfile fail\n"); return -ENODEV; } file->private_data = kzalloc(sizeof(struct file_private_data), GFP_KERNEL); if (!file->private_data) { - pr_err("%s: alloc priv data faild.\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "alloc priv data faild.\n"); return -ENOMEM; } - aml_v4l2_debug(2, "%s: fd %d, file %lx, data: %lx", __func__, + v4l_dbg(0, V4L_DEBUG_CODEC_BUFMGR, "fd %d, file %lx, data: %lx\n", file_fd, (ulong) file, (ulong) file->private_data); fd_install(file_fd, file); @@ -227,20 +233,23 @@ int v4l2_check_fd(int fd) file = fget(fd); if (!file) { - pr_err("%s: fget fd %d fail!\n", __func__, fd); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "fget fd %d fail!\n", fd); return -EBADF; } if (!is_v4l2_buf_file(file)) { fput(file); - pr_err("%s: is_v4l2_buf_file fail!\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "is_v4l2_buf_file fail!\n"); return -1; } fput(file); - aml_v4l2_debug(5, "%s: ioctl ok, comm %s, pid %d", - __func__, current->comm, current->pid); + v4l_dbg(0, V4L_DEBUG_CODEC_EXINFO, + "ioctl ok, comm %s, pid %d\n", + current->comm, current->pid); return 0; } @@ -252,14 +261,16 @@ int dmabuf_fd_install_data(int fd, void* data, u32 size) file = fget(fd); if (!file) { - pr_err("%s: fget fd %d fail!, comm %s, pid %d\n", - __func__, fd, current->comm, current->pid); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "fget fd %d fail!, comm %s, pid %d\n", + fd, current->comm, current->pid); return -EBADF; } if (!is_v4l2_buf_file(file)) { fput(file); - pr_err("%s the buf file checked fail!\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "the buf file checked fail!\n"); return -EBADF; } @@ -279,22 +290,24 @@ void* v4l_get_vf_handle(int fd) file = fget(fd); if (!file) { - pr_err("%s: fget fd %d fail!, comm %s, pid %d\n", - __func__, fd, current->comm, current->pid); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "fget fd %d fail!, comm %s, pid %d\n", + fd, current->comm, current->pid); return NULL; } if (!is_v4l2_buf_file(file)) { fput(file); - pr_err("%s the buf file checked fail!\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "the buf file checked fail!\n"); return NULL; } data = (struct file_private_data*) file->private_data; if (data) { vf_handle = &data->vf; - aml_v4l2_debug(2, "%s: file: %lx, data: %lx", - __func__, (ulong) file, (ulong) data); + v4l_dbg(0, V4L_DEBUG_CODEC_BUFMGR, "file: %lx, data: %lx\n", + (ulong) file, (ulong) data); } fput(file); @@ -319,8 +332,9 @@ static long v4l2_vcodec_ioctl(struct file *file, if (ret != 0) break; put_user(v4lvideo_fd, (u32 __user *)argp); - aml_v4l2_debug(4, "%s: V4LVIDEO_IOCTL_ALLOC_FD fd %d", - __func__, v4lvideo_fd); + v4l_dbg(0, V4L_DEBUG_CODEC_EXINFO, + "V4LVIDEO_IOCTL_ALLOC_FD fd %d\n", + v4lvideo_fd); break; } case V4LVIDEO_IOCTL_CHECK_FD: @@ -331,8 +345,9 @@ static long v4l2_vcodec_ioctl(struct file *file, ret = v4l2_check_fd(v4lvideo_fd); if (ret != 0) break; - aml_v4l2_debug(4, "%s: V4LVIDEO_IOCTL_CHECK_FD fd %d", - __func__, v4lvideo_fd); + v4l_dbg(0, V4L_DEBUG_CODEC_EXINFO, + "V4LVIDEO_IOCTL_CHECK_FD fd %d\n", + v4lvideo_fd); break; } case V4LVIDEO_IOCTL_SET_CONFIG_PARAMS: @@ -345,7 +360,8 @@ static long v4l2_vcodec_ioctl(struct file *file, ctx = fh_to_ctx(file->private_data); if (copy_from_user((void *)&ctx->config, (void *)argp, sizeof(ctx->config))) { - pr_err("[%s],set config parm err\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "set config parm err\n"); return -EFAULT; } break; @@ -360,7 +376,8 @@ static long v4l2_vcodec_ioctl(struct file *file, ctx = fh_to_ctx(file->private_data); if (copy_to_user((void *)argp, (void *)&ctx->config, sizeof(ctx->config))) { - pr_err("[%s],get config parm err\n", __func__); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "get config parm err\n"); return -EFAULT; } break; @@ -416,7 +433,8 @@ static int aml_vcodec_probe(struct platform_device *pdev) ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) { - aml_v4l2_err("v4l2_device_register err=%d", ret); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "v4l2_device_register err=%d\n", ret); goto err_res; } @@ -424,7 +442,8 @@ static int aml_vcodec_probe(struct platform_device *pdev) vfd_dec = video_device_alloc(); if (!vfd_dec) { - aml_v4l2_err("Failed to allocate video device"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Failed to allocate video device\n"); ret = -ENOMEM; goto err_dec_alloc; } @@ -446,7 +465,8 @@ static int aml_vcodec_probe(struct platform_device *pdev) dev->m2m_dev_dec = v4l2_m2m_init(&aml_vdec_m2m_ops); if (IS_ERR((__force void *)dev->m2m_dev_dec)) { - aml_v4l2_err("Failed to init mem2mem dec device"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Failed to init mem2mem dec device\n"); ret = PTR_ERR((__force void *)dev->m2m_dev_dec); goto err_dec_mem_init; } @@ -455,7 +475,8 @@ static int aml_vcodec_probe(struct platform_device *pdev) alloc_ordered_workqueue(AML_VCODEC_DEC_NAME, WQ_MEM_RECLAIM | WQ_FREEZABLE); if (!dev->decode_workqueue) { - aml_v4l2_err("Failed to create decode workqueue"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Failed to create decode workqueue\n"); ret = -EINVAL; goto err_event_workq; } @@ -464,11 +485,13 @@ static int aml_vcodec_probe(struct platform_device *pdev) ret = video_register_device(vfd_dec, VFL_TYPE_GRABBER, 26); if (ret) { - pr_err("Failed to register video device\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Failed to register video device\n"); goto err_dec_reg; } - pr_info("decoder registered as /dev/video%d\n", vfd_dec->num); + v4l_dbg(0, V4L_DEBUG_CODEC_PRINFO, + "decoder registered as /dev/video%d\n", vfd_dec->num); return 0; @@ -557,8 +580,9 @@ module_init(amvdec_ports_init); module_exit(amvdec_ports_exit); */ -module_param(aml_v4l2_dbg_level, int, 0644); -module_param(aml_vcodec_dbg, bool, 0644); +u32 debug_mode; +EXPORT_SYMBOL(debug_mode); +module_param(debug_mode, uint, 0644); bool aml_set_vfm_enable; EXPORT_SYMBOL(aml_set_vfm_enable); diff --git a/drivers/amvdec_ports/aml_vcodec_dec_pm.c b/drivers/amvdec_ports/aml_vcodec_dec_pm.c deleted file mode 100644 index c801e87..0000000 --- a/drivers/amvdec_ports/aml_vcodec_dec_pm.c +++ b/dev/null @@ -1,206 +0,0 @@ -/* -* Copyright (C) 2017 Amlogic, Inc. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, write to the Free Software Foundation, Inc., -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* Description: -*/ -#include <linux/clk.h> -#include <linux/of_address.h> -#include <linux/of_platform.h> -#include <linux/pm_runtime.h> - -#include "aml_vcodec_dec_pm.h" -#include "aml_vcodec_util.h" -//#include "aml_vpu.h" - -int aml_vcodec_init_dec_pm(struct aml_vcodec_dev *amldev) -{ - struct device_node *node; - struct platform_device *pdev; - struct aml_vcodec_pm *pm; - int ret = 0; - - pdev = amldev->plat_dev; - pm = &amldev->pm; - pm->amldev = amldev; - node = of_parse_phandle(pdev->dev.of_node, "larb", 0); - if (!node) { - aml_v4l2_err("of_parse_phandle larb fail!"); - return -1; - } - - pdev = of_find_device_by_node(node); - if (WARN_ON(!pdev)) { - of_node_put(node); - return -1; - } - pm->larbvdec = &pdev->dev; - pdev = amldev->plat_dev; - pm->dev = &pdev->dev; - - pm->vcodecpll = devm_clk_get(&pdev->dev, "vcodecpll"); - if (IS_ERR(pm->vcodecpll)) { - aml_v4l2_err("devm_clk_get vcodecpll fail"); - ret = PTR_ERR(pm->vcodecpll); - } - - pm->univpll_d2 = devm_clk_get(&pdev->dev, "univpll_d2"); - if (IS_ERR(pm->univpll_d2)) { - aml_v4l2_err("devm_clk_get univpll_d2 fail"); - ret = PTR_ERR(pm->univpll_d2); - } - - pm->clk_cci400_sel = devm_clk_get(&pdev->dev, "clk_cci400_sel"); - if (IS_ERR(pm->clk_cci400_sel)) { - aml_v4l2_err("devm_clk_get clk_cci400_sel fail"); - ret = PTR_ERR(pm->clk_cci400_sel); - } - - pm->vdec_sel = devm_clk_get(&pdev->dev, "vdec_sel"); - if (IS_ERR(pm->vdec_sel)) { - aml_v4l2_err("devm_clk_get vdec_sel fail"); - ret = PTR_ERR(pm->vdec_sel); - } - - pm->vdecpll = devm_clk_get(&pdev->dev, "vdecpll"); - if (IS_ERR(pm->vdecpll)) { - aml_v4l2_err("devm_clk_get vdecpll fail"); - ret = PTR_ERR(pm->vdecpll); - } - - pm->vencpll = devm_clk_get(&pdev->dev, "vencpll"); - if (IS_ERR(pm->vencpll)) { - aml_v4l2_err("devm_clk_get vencpll fail"); - ret = PTR_ERR(pm->vencpll); - } - - pm->venc_lt_sel = devm_clk_get(&pdev->dev, "venc_lt_sel"); - if (IS_ERR(pm->venc_lt_sel)) { - aml_v4l2_err("devm_clk_get venc_lt_sel fail"); - ret = PTR_ERR(pm->venc_lt_sel); - } - - pm->vdec_bus_clk_src = devm_clk_get(&pdev->dev, "vdec_bus_clk_src"); - if (IS_ERR(pm->vdec_bus_clk_src)) { - aml_v4l2_err("devm_clk_get vdec_bus_clk_src"); - ret = PTR_ERR(pm->vdec_bus_clk_src); - } - - pm_runtime_enable(&pdev->dev); - - return ret; -} - -void aml_vcodec_release_dec_pm(struct aml_vcodec_dev *dev) -{ - pm_runtime_disable(dev->pm.dev); -} - -void aml_vcodec_dec_pw_on(struct aml_vcodec_pm *pm) -{ - int ret; - - ret = pm_runtime_get_sync(pm->dev); - if (ret) - aml_v4l2_err("pm_runtime_get_sync fail %d", ret); -} - -void aml_vcodec_dec_pw_off(struct aml_vcodec_pm *pm) -{ - int ret; - - ret = pm_runtime_put_sync(pm->dev); - if (ret) - aml_v4l2_err("pm_runtime_put_sync fail %d", ret); -} - -void aml_vcodec_dec_clock_on(struct aml_vcodec_pm *pm) -{ - int ret; - - ret = clk_set_rate(pm->vcodecpll, 1482 * 1000000); - if (ret) - aml_v4l2_err("clk_set_rate vcodecpll fail %d", ret); - - ret = clk_set_rate(pm->vencpll, 800 * 1000000); - if (ret) - aml_v4l2_err("clk_set_rate vencpll fail %d", ret); - - ret = clk_prepare_enable(pm->vcodecpll); - if (ret) - aml_v4l2_err("clk_prepare_enable vcodecpll fail %d", ret); - - ret = clk_prepare_enable(pm->vencpll); - if (ret) - aml_v4l2_err("clk_prepare_enable vencpll fail %d", ret); - - ret = clk_prepare_enable(pm->vdec_bus_clk_src); - if (ret) - aml_v4l2_err("clk_prepare_enable vdec_bus_clk_src fail %d", - ret); - - ret = clk_prepare_enable(pm->venc_lt_sel); - if (ret) - aml_v4l2_err("clk_prepare_enable venc_lt_sel fail %d", ret); - - ret = clk_set_parent(pm->venc_lt_sel, pm->vdec_bus_clk_src); - if (ret) - aml_v4l2_err("clk_set_parent venc_lt_sel vdec_bus_clk_src fail %d", - ret); - - ret = clk_prepare_enable(pm->univpll_d2); - if (ret) - aml_v4l2_err("clk_prepare_enable univpll_d2 fail %d", ret); - - ret = clk_prepare_enable(pm->clk_cci400_sel); - if (ret) - aml_v4l2_err("clk_prepare_enable clk_cci400_sel fail %d", ret); - - ret = clk_set_parent(pm->clk_cci400_sel, pm->univpll_d2); - if (ret) - aml_v4l2_err("clk_set_parent clk_cci400_sel univpll_d2 fail %d", - ret); - - ret = clk_prepare_enable(pm->vdecpll); - if (ret) - aml_v4l2_err("clk_prepare_enable vdecpll fail %d", ret); - - ret = clk_prepare_enable(pm->vdec_sel); - if (ret) - aml_v4l2_err("clk_prepare_enable vdec_sel fail %d", ret); - - ret = clk_set_parent(pm->vdec_sel, pm->vdecpll); - if (ret) - aml_v4l2_err("clk_set_parent vdec_sel vdecpll fail %d", ret); - - //ret = aml_smi_larb_get(pm->larbvdec); - if (ret) - aml_v4l2_err("aml_smi_larb_get larbvdec fail %d", ret); - -} - -void aml_vcodec_dec_clock_off(struct aml_vcodec_pm *pm) -{ - //aml_smi_larb_put(pm->larbvdec); - clk_disable_unprepare(pm->vdec_sel); - clk_disable_unprepare(pm->vdecpll); - clk_disable_unprepare(pm->univpll_d2); - clk_disable_unprepare(pm->clk_cci400_sel); - clk_disable_unprepare(pm->venc_lt_sel); - clk_disable_unprepare(pm->vdec_bus_clk_src); - clk_disable_unprepare(pm->vencpll); - clk_disable_unprepare(pm->vcodecpll); -} diff --git a/drivers/amvdec_ports/aml_vcodec_dec_pm.h b/drivers/amvdec_ports/aml_vcodec_dec_pm.h deleted file mode 100644 index ccdf313..0000000 --- a/drivers/amvdec_ports/aml_vcodec_dec_pm.h +++ b/dev/null @@ -1,34 +0,0 @@ -/* -* Copyright (C) 2017 Amlogic, Inc. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, write to the Free Software Foundation, Inc., -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -* Description: -*/ - -#ifndef _AML_VCODEC_DEC_PM_H_ -#define _AML_VCODEC_DEC_PM_H_ - -#include "aml_vcodec_drv.h" - -int aml_vcodec_init_dec_pm(struct aml_vcodec_dev *dev); -void aml_vcodec_release_dec_pm(struct aml_vcodec_dev *dev); - -void aml_vcodec_dec_pw_on(struct aml_vcodec_pm *pm); -void aml_vcodec_dec_pw_off(struct aml_vcodec_pm *pm); -void aml_vcodec_dec_clock_on(struct aml_vcodec_pm *pm); -void aml_vcodec_dec_clock_off(struct aml_vcodec_pm *pm); - -#endif /* _AML_VCODEC_DEC_PM_H_ */ diff --git a/drivers/amvdec_ports/aml_vcodec_util.c b/drivers/amvdec_ports/aml_vcodec_util.c index 73a4b74..03180ab 100644 --- a/drivers/amvdec_ports/aml_vcodec_util.c +++ b/drivers/amvdec_ports/aml_vcodec_util.c @@ -21,17 +21,6 @@ #include "aml_vcodec_drv.h" #include "aml_vcodec_util.h" -//#include "aml_vpu.h" - -/* For encoder, this will enable logs in venc/*/ -bool aml_vcodec_dbg; -EXPORT_SYMBOL(aml_vcodec_dbg); - -/* The log level of v4l2 encoder or decoder driver. - * That is, files under aml-vcodec/. - */ -int aml_v4l2_dbg_level; -EXPORT_SYMBOL(aml_v4l2_dbg_level); void __iomem *aml_vcodec_get_reg_addr(struct aml_vcodec_ctx *data, unsigned int reg_idx) @@ -39,7 +28,8 @@ void __iomem *aml_vcodec_get_reg_addr(struct aml_vcodec_ctx *data, struct aml_vcodec_ctx *ctx = (struct aml_vcodec_ctx *)data; if (!data || reg_idx >= NUM_MAX_VCODEC_REG_BASE) { - aml_v4l2_err("Invalid arguments, reg_idx=%d", reg_idx); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "Invalid arguments, reg_idx=%d\n", reg_idx); return NULL; } return ctx->dev->reg_base[reg_idx]; @@ -57,17 +47,17 @@ int aml_vcodec_mem_alloc(struct aml_vcodec_ctx *data, mem->vaddr = codec_mm_dma_alloc_coherent(dev_name(dev), size, &mem->dma_addr, GFP_KERNEL, 0); if (!mem->vaddr) { - aml_v4l2_err("%s dma_alloc size=%ld failed!", dev_name(dev), + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "%s dma_alloc size=%ld failed!\n", dev_name(dev), size); return -ENOMEM; } memset(mem->vaddr, 0, size); - aml_v4l2_debug(4, "[%d] - va = %p", ctx->id, mem->vaddr); - aml_v4l2_debug(4, "[%d] - dma = 0x%lx", ctx->id, - (unsigned long)mem->dma_addr); - aml_v4l2_debug(4, "[%d] size = 0x%lx", ctx->id, size); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "va: %p\n", mem->vaddr); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "dma: 0x%lx\n", (ulong) mem->dma_addr); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "size: 0x%lx\n", size); return 0; } @@ -81,15 +71,15 @@ void aml_vcodec_mem_free(struct aml_vcodec_ctx *data, struct device *dev = &ctx->dev->plat_dev->dev; if (!mem->vaddr) { - aml_v4l2_err("%s dma_free size=%ld failed!", dev_name(dev), + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "%s dma_free size=%ld failed!\n", dev_name(dev), size); return; } - aml_v4l2_debug(4, "[%d] - va = %p", ctx->id, mem->vaddr); - aml_v4l2_debug(4, "[%d] - dma = 0x%lx", ctx->id, - (unsigned long)mem->dma_addr); - aml_v4l2_debug(4, "[%d] size = 0x%lx", ctx->id, size); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "va: %p\n", mem->vaddr); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "dma: 0x%lx\n", (ulong) mem->dma_addr); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "size: 0x%lx\n", size); dma_free_coherent(dev, size, mem->vaddr, mem->dma_addr); mem->vaddr = NULL; diff --git a/drivers/amvdec_ports/aml_vcodec_util.h b/drivers/amvdec_ports/aml_vcodec_util.h index e93900e..da8d725 100644 --- a/drivers/amvdec_ports/aml_vcodec_util.h +++ b/drivers/amvdec_ports/aml_vcodec_util.h @@ -24,14 +24,12 @@ #include <linux/dma-direction.h> #include <linux/amlogic/media/codec_mm/codec_mm.h> -#define DEBUG - -typedef unsigned long long u64; -typedef signed long long s64; -typedef unsigned int u32; -typedef unsigned short int u16; -typedef short int s16; -typedef unsigned char u8; +typedef unsigned long long u64; +typedef signed long long s64; +typedef unsigned int u32; +typedef unsigned short int u16; +typedef short int s16; +typedef unsigned char u8; #define CODEC_MODE(a, b, c, d)\ (((u8)(a) << 24) | ((u8)(b) << 16) | ((u8)(c) << 8) | (u8)(d)) @@ -48,51 +46,46 @@ struct aml_vcodec_mem { struct aml_vcodec_ctx; struct aml_vcodec_dev; -extern int aml_v4l2_dbg_level; -extern bool aml_vcodec_dbg; - +extern u32 debug_mode; -#if defined(DEBUG) +#ifdef v4l_dbg +#undef v4l_dbg +#endif -#define aml_v4l2_debug(level, fmt, args...) \ +/* v4l debug define. */ +#define V4L_DEBUG_CODEC_ERROR (0) +#define V4L_DEBUG_CODEC_PRINFO (1 << 0) +#define V4L_DEBUG_CODEC_STATE (1 << 1) +#define V4L_DEBUG_CODEC_BUFMGR (1 << 2) +#define V4L_DEBUG_CODEC_INPUT (1 << 3) +#define V4L_DEBUG_CODEC_OUTPUT (1 << 4) +#define V4L_DEBUG_CODEC_COUNT (1 << 5) +#define V4L_DEBUG_CODEC_PARSER (1 << 6) +#define V4L_DEBUG_CODEC_PROT (1 << 7) +#define V4L_DEBUG_CODEC_EXINFO (1 << 8) + +#define __v4l_dbg(h, id, fmt, args...) \ do { \ - if (aml_v4l2_dbg_level >= level) \ - pr_info(fmt "\n", ##args); \ + if (h) \ + pr_info("[%d]: " fmt, id, ##args); \ + else \ + pr_info(fmt, ##args); \ } while (0) -#define aml_v4l2_debug_enter() aml_v4l2_debug(3, "+") -#define aml_v4l2_debug_leave() aml_v4l2_debug(3, "-") - -#define aml_vcodec_debug(h, fmt, args...) \ - do { \ - if (aml_vcodec_dbg) \ - pr_info("[%d]: %s() " fmt "\n", \ - ((struct aml_vcodec_ctx *)h->ctx)->id, \ - __func__, ##args); \ +#define v4l_dbg(h, flags, fmt, args...) \ + do { \ + struct aml_vcodec_ctx *__ctx = (struct aml_vcodec_ctx *) h; \ + if ((flags == V4L_DEBUG_CODEC_ERROR) || \ + (flags == V4L_DEBUG_CODEC_PRINFO) || \ + (debug_mode & flags)) { \ + if (flags == V4L_DEBUG_CODEC_ERROR) { \ + __v4l_dbg(h, __ctx->id, "[ERR]: " fmt, ##args); \ + } else { \ + __v4l_dbg(h, __ctx->id, fmt, ##args); \ + } \ + } \ } while (0) -#define aml_vcodec_debug_enter(h) aml_vcodec_debug(h, "+") -#define aml_vcodec_debug_leave(h) aml_vcodec_debug(h, "-") - -#else - -#define aml_v4l2_debug(level, fmt, args...) -#define aml_v4l2_debug_enter() -#define aml_v4l2_debug_leave() - -#define aml_vcodec_debug(h, fmt, args...) -#define aml_vcodec_debug_enter(h) -#define aml_vcodec_debug_leave(h) - -#endif - -#define aml_v4l2_err(fmt, args...) \ - pr_err("[ERR]" fmt "\n", ##args) - -#define aml_vcodec_err(h, fmt, args...) \ - pr_err("[ERR][%d]" fmt "\n", \ - ((struct aml_vcodec_ctx *)h->ctx)->id, ##args) - void __iomem *aml_vcodec_get_reg_addr(struct aml_vcodec_ctx *data, unsigned int reg_idx); int aml_vcodec_mem_alloc(struct aml_vcodec_ctx *data, diff --git a/drivers/amvdec_ports/aml_vcodec_vfm.c b/drivers/amvdec_ports/aml_vcodec_vfm.c index b64be0c..62896ea 100644 --- a/drivers/amvdec_ports/aml_vcodec_vfm.c +++ b/drivers/amvdec_ports/aml_vcodec_vfm.c @@ -56,7 +56,7 @@ static void vdec_vf_put(struct vframe_s *vf, void *op_arg) //vf_notify_provider(vfm->recv_name, VFRAME_EVENT_RECEIVER_PUT, NULL); if (vfq_level(&vfm->vf_que_recycle) > POOL_SIZE - 1) { - pr_info("%s %d vfq full.\n", __func__, __LINE__); + v4l_dbg(vfm->ctx, V4L_DEBUG_CODEC_ERROR, "vfq full.\n"); return; } @@ -95,12 +95,13 @@ void video_vf_put(char *receiver, struct vdec_v4l2_buffer *fb, int id) struct vframe_provider_s *vfp = vf_get_provider(receiver); struct vframe_s *vf = (struct vframe_s *)fb->vf_handle; - aml_v4l2_debug(3, "[%d] TO (%s) vf: %p, idx: %d", - id, vfp->name, vf, vf->index); ATRACE_COUNTER("v4l2_to", vf->index_disp); - aml_v4l2_debug(4, "[%d] TO Y:(%lx, %u) C/U:(%lx, %u) V:(%lx, %u)", - id, fb->m.mem[0].addr, fb->m.mem[0].size, + v4l_dbg(0, V4L_DEBUG_CODEC_OUTPUT, + "[%d]: TO (%s) vf: %p, idx: %d, " + "Y:(%lx, %u) C/U:(%lx, %u) V:(%lx, %u)\n", + id, vfp->name, vf, vf->index, + fb->m.mem[0].addr, fb->m.mem[0].size, fb->m.mem[1].addr, fb->m.mem[1].size, fb->m.mem[2].addr, fb->m.mem[2].size); @@ -122,13 +123,12 @@ static int video_receiver_event_fun(int type, void *data, void *private_data) struct vframe_states states; struct vcodec_vfm_s *vfm = (struct vcodec_vfm_s *)private_data; - //aml_v4l2_debug(4, "[%d] type: %d, vfm: %p", vfm->ctx->id, type, vfm); - switch (type) { case VFRAME_EVENT_PROVIDER_UNREG: { if (vf_get_receiver(vfm->prov_name)) { - aml_v4l2_debug(4, "[%d] unreg %s provider.", - vfm->ctx->id, vfm->prov_name); + v4l_dbg(vfm->ctx, V4L_DEBUG_CODEC_EXINFO, + "unreg %s provider.\n", + vfm->prov_name); vf_unreg_provider(&vfm->vf_prov); } @@ -137,8 +137,9 @@ static int video_receiver_event_fun(int type, void *data, void *private_data) case VFRAME_EVENT_PROVIDER_START: { if (vf_get_receiver(vfm->prov_name)) { - aml_v4l2_debug(4, "[%d] reg %s provider.", - vfm->ctx->id, vfm->prov_name); + v4l_dbg(vfm->ctx, V4L_DEBUG_CODEC_EXINFO, + "reg %s provider.\n", + vfm->prov_name); vf_provider_init(&vfm->vf_prov, vfm->prov_name, &vf_provider, vfm); vf_reg_provider(&vfm->vf_prov); @@ -171,7 +172,7 @@ static int video_receiver_event_fun(int type, void *data, void *private_data) ret = -1; if (ret < 0) { - pr_err("[%d] receiver vf err.\n", vfm->ctx->id); + v4l_dbg(vfm->ctx, V4L_DEBUG_CODEC_ERROR, "receiver vf err.\n"); break; } @@ -190,7 +191,8 @@ static int video_receiver_event_fun(int type, void *data, void *private_data) } default: - aml_v4l2_debug(4, "[%d] the vf event is %d", vfm->ctx->id, type); + v4l_dbg(vfm->ctx, V4L_DEBUG_CODEC_EXINFO, + "the vf event is %d", type); } return ret; diff --git a/drivers/amvdec_ports/decoder/aml_h264_parser.c b/drivers/amvdec_ports/decoder/aml_h264_parser.c index 0e8b881..d0d0198 100644 --- a/drivers/amvdec_ports/decoder/aml_h264_parser.c +++ b/drivers/amvdec_ports/decoder/aml_h264_parser.c @@ -162,7 +162,8 @@ static int decode_hrd_parameters(struct get_bits_context *gb, cpb_count = get_ue_golomb_31(gb) + 1; if (cpb_count > 32U) { - pr_err("cpb_count %d invalid\n", cpb_count); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "cpb_count %d invalid\n", cpb_count); return -1; } @@ -237,7 +238,7 @@ static int decode_vui_parameters(struct get_bits_context *gb, struct h264_SPS_t } if (show_bits1(gb) && get_bits_left(gb) < 10) { - pr_info("Truncated VUI\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Truncated VUI\n"); return 0; } @@ -246,7 +247,8 @@ static int decode_vui_parameters(struct get_bits_context *gb, struct h264_SPS_t unsigned num_units_in_tick = get_bits_long(gb, 32); unsigned time_scale = get_bits_long(gb, 32); if (!num_units_in_tick || !time_scale) { - pr_info("time_scale/num_units_in_tick invalid or unsupported (%u/%u)\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, + "time_scale/num_units_in_tick invalid or unsupported (%u/%u)\n", time_scale, num_units_in_tick); sps->timing_info_present_flag = 0; } else { @@ -287,7 +289,8 @@ static int decode_vui_parameters(struct get_bits_context *gb, struct h264_SPS_t if (sps->num_reorder_frames > 16U /* max_dec_frame_buffering || max_dec_frame_buffering > 16 */) { - pr_info("Clipping illegal num_reorder_frames %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Clipping illegal num_reorder_frames %d\n", sps->num_reorder_frames); sps->num_reorder_frames = 16; return -1; @@ -316,7 +319,8 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s sps_id = get_ue_golomb_31(gb); if (sps_id >= MAX_SPS_COUNT) { - pr_info( "sps_id %u out of range\n", sps_id); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "sps_id %u out of range\n", sps_id); goto fail; } @@ -346,12 +350,14 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s sps->chroma_format_idc = get_ue_golomb_31(gb); if (sps->chroma_format_idc > 3U) { - pr_err("chroma_format_idc %u\n", sps->chroma_format_idc); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "chroma_format_idc %u\n", sps->chroma_format_idc); goto fail; } else if (sps->chroma_format_idc == 3) { sps->residual_color_transform_flag = get_bits1(gb); if (sps->residual_color_transform_flag) { - pr_info( "separate color planes are not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "separate color planes are not supported\n"); goto fail; } } @@ -359,14 +365,16 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s sps->bit_depth_luma = get_ue_golomb(gb) + 8; sps->bit_depth_chroma = get_ue_golomb(gb) + 8; if (sps->bit_depth_chroma != sps->bit_depth_luma) { - pr_err("Different chroma and luma bit depth\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Different chroma and luma bit depth\n"); goto fail; } if (sps->bit_depth_luma < 8 || sps->bit_depth_luma > 14 || sps->bit_depth_chroma < 8 || sps->bit_depth_chroma > 14) { - pr_info("illegal bit depth value (%d, %d)\n", - sps->bit_depth_luma, sps->bit_depth_chroma); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "illegal bit depth value (%d, %d)\n", + sps->bit_depth_luma, sps->bit_depth_chroma); goto fail; } @@ -385,9 +393,9 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s log2_max_frame_num_minus4 = get_ue_golomb(gb); if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 || log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) { - pr_info( - "log2_max_frame_num_minus4 out of range (0-12): %d\n", - log2_max_frame_num_minus4); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "log2_max_frame_num_minus4 out of range (0-12): %d\n", + log2_max_frame_num_minus4); goto fail; } sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4; @@ -396,7 +404,8 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s if (sps->poc_type == 0) { // FIXME #define u32 t = get_ue_golomb(gb); if (t > 12) { - pr_info( "log2_max_poc_lsb (%d) is out of range\n", t); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "log2_max_poc_lsb (%d) is out of range\n", t); goto fail; } sps->log2_max_poc_lsb = t + 4; @@ -407,20 +416,23 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s sps->poc_cycle_length = get_ue_golomb(gb); if ((u32)sps->poc_cycle_length >= ARRAY_SIZE(sps->offset_for_ref_frame)) { - pr_info("poc_cycle_length overflow %d\n", sps->poc_cycle_length); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "poc_cycle_length overflow %d\n", sps->poc_cycle_length); goto fail; } for (i = 0; i < sps->poc_cycle_length; i++) sps->offset_for_ref_frame[i] = get_se_golomb_long(gb); } else if (sps->poc_type != 2) { - pr_info( "illegal POC type %d\n", sps->poc_type); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "illegal POC type %d\n", sps->poc_type); goto fail; } sps->ref_frame_count = get_ue_golomb_31(gb); if (sps->ref_frame_count > MAX_DELAYED_PIC_COUNT) { - pr_info("too many reference frames %d\n", sps->ref_frame_count); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "too many reference frames %d\n", sps->ref_frame_count); goto fail; } sps->gaps_in_frame_num_allowed_flag = get_bits1(gb); @@ -430,7 +442,7 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s sps->frame_mbs_only_flag = get_bits1(gb); if (sps->mb_height >= INT_MAX / 2U) { - pr_info("height overflow\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "height overflow\n"); goto fail; } sps->mb_height *= 2 - sps->frame_mbs_only_flag; @@ -442,7 +454,8 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s if ((u32)sps->mb_width >= INT_MAX / 16 || (u32)sps->mb_height >= INT_MAX / 16) { - pr_info( "mb_width/height overflow\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "mb_width/height overflow\n"); goto fail; } @@ -467,7 +480,9 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s crop_bottom > (u32)INT_MAX / 4 / step_y || (crop_left + crop_right ) * step_x >= width || (crop_top + crop_bottom) * step_y >= height) { - pr_info( "crop values invalid %u %u %u %u / %d %d\n", crop_left, crop_right, crop_top, crop_bottom, width, height); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "crop values invalid %u %u %u %u / %d %d\n", + crop_left, crop_right, crop_top, crop_bottom, width, height); goto fail; } @@ -491,7 +506,9 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s } if (get_bits_left(gb) < 0) { - pr_info("Overread %s by %d bits\n", sps->vui_parameters_present_flag ? "VUI" : "SPS", -get_bits_left(gb)); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Overread %s by %d bits\n", + sps->vui_parameters_present_flag ? "VUI" : "SPS", -get_bits_left(gb)); /*goto out;*/ } @@ -527,7 +544,8 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s (sps->max_dec_frame_buffering < sps->num_reorder_frames)) { sps->num_reorder_frames = sps->max_dec_frame_buffering; - pr_info("set reorder_pic_num to %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, + "set reorder_pic_num to %d\n", sps->num_reorder_frames); } @@ -536,7 +554,8 @@ static int aml_h264_parser_sps(struct get_bits_context *gb, struct h264_SPS_t *s /*out:*/ if (1) { static const char csp[4][5] = { "Gray", "420", "422", "444" }; - pr_info("sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %d/%d b%d reo:%d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, + "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%u/%u/%u/%u %s %s %d/%d b%d reo:%d\n", sps_id, sps->profile_idc, sps->level_idc, sps->poc_type, sps->ref_frame_count, @@ -625,14 +644,16 @@ static int decode_extradata_ps(u8 *data, int size, struct h264_param_sets *ps) if (get_bits1(&gb) != 0) { ret = -1; - pr_err("invalid h264 data,return!\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "invalid h264 data,return!\n"); goto out; } ref_idc = get_bits(&gb, 2); nal_type = get_bits(&gb, 5); - pr_info("nal_unit_type: %d(%s), nal_ref_idc: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, + "nal_unit_type: %d(%s), nal_ref_idc: %d\n", nal_type, h264_nal_unit_name(nal_type), ref_idc); switch (nal_type) { @@ -649,7 +670,8 @@ static int decode_extradata_ps(u8 *data, int size, struct h264_param_sets *ps) ps->pps_parsed = true; break;*/ default: - pr_err("Unsupport parser nal type (%s).\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "Unsupport parser nal type (%s).\n", h264_nal_unit_name(nal_type)); break; } @@ -672,7 +694,8 @@ int h264_decode_extradata_ps(u8 *buf, int size, struct h264_param_sets *ps) len = size - (p - buf); ret = decode_extradata_ps(p, len, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "parse extra data failed. err: %d\n", ret); return ret; } diff --git a/drivers/amvdec_ports/decoder/aml_h264_parser.h b/drivers/amvdec_ports/decoder/aml_h264_parser.h index af48d78..aed5378 100644 --- a/drivers/amvdec_ports/decoder/aml_h264_parser.h +++ b/drivers/amvdec_ports/decoder/aml_h264_parser.h @@ -18,6 +18,7 @@ #ifndef AML_H264_PARSER_H #define AML_H264_PARSER_H +#include "../aml_vcodec_drv.h" #include "../utils/pixfmt.h" #define QP_MAX_NUM (51 + 6 * 6) // The maximum supported qp diff --git a/drivers/amvdec_ports/decoder/aml_hevc_parser.c b/drivers/amvdec_ports/decoder/aml_hevc_parser.c index 03b8356..24977a8 100644 --- a/drivers/amvdec_ports/decoder/aml_hevc_parser.c +++ b/drivers/amvdec_ports/decoder/aml_hevc_parser.c @@ -124,15 +124,15 @@ static int decode_profile_tier_level(struct get_bits_context *gb, struct PTLComm ptl->tier_flag = get_bits1(gb); ptl->profile_idc = get_bits(gb, 5); if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN) - pr_info("Main profile bitstream\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Main profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_10) - pr_info("Main 10 profile bitstream\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Main 10 profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_MAIN_STILL_PICTURE) - pr_info("Main Still Picture profile bitstream\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Main Still Picture profile bitstream\n"); else if (ptl->profile_idc == FF_PROFILE_HEVC_REXT) - pr_info("Range Extension profile bitstream\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Range Extension profile bitstream\n"); else - pr_info("Unknown HEVC profile: %d\n", ptl->profile_idc); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Unknown HEVC profile: %d\n", ptl->profile_idc); for (i = 0; i < 32; i++) { ptl->profile_compatibility_flag[i] = get_bits1(gb); @@ -157,7 +157,7 @@ static int parse_ptl(struct get_bits_context *gb, struct PTL *ptl, int max_num_s int i; if (decode_profile_tier_level(gb, &ptl->general_ptl) < 0 || get_bits_left(gb) < 8 + (8*2 * (max_num_sub_layers - 1 > 0))) { - pr_err("PTL information too short\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "PTL information too short\n"); return -1; } @@ -174,12 +174,12 @@ static int parse_ptl(struct get_bits_context *gb, struct PTL *ptl, int max_num_s for (i = 0; i < max_num_sub_layers - 1; i++) { if (ptl->sub_layer_profile_present_flag[i] && decode_profile_tier_level(gb, &ptl->sub_layer_ptl[i]) < 0) { - pr_err("PTL information for sublayer %i too short\n", i); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "PTL information for sublayer %i too short\n", i); return -1; } if (ptl->sub_layer_level_present_flag[i]) { if (get_bits_left(gb) < 8) { - pr_err("Not enough data for sublayer %i level_idc\n", i); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Not enough data for sublayer %i level_idc\n", i); return -1; } else ptl->sub_layer_ptl[i].level_idc = get_bits(gb, 8); @@ -255,7 +255,7 @@ static int decode_hrd(struct get_bits_context *gb, if (!low_delay) { nb_cpb = get_ue_golomb_long(gb) + 1; if (nb_cpb < 1 || nb_cpb > 32) { - pr_err("nb_cpb %d invalid\n", nb_cpb); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "nb_cpb %d invalid\n", nb_cpb); return -1; } } @@ -273,16 +273,16 @@ int ff_hevc_parse_vps(struct get_bits_context *gb, struct h265_VPS_t *vps) int i,j; int vps_id = 0; - pr_info("Decoding VPS\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Decoding VPS\n"); vps_id = get_bits(gb, 4); if (vps_id >= HEVC_MAX_VPS_COUNT) { - pr_err("VPS id out of range: %d\n", vps_id); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "VPS id out of range: %d\n", vps_id); goto err; } if (get_bits(gb, 2) != 3) { // vps_reserved_three_2bits - pr_err("vps_reserved_three_2bits is not three\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "vps_reserved_three_2bits is not three\n"); goto err; } @@ -291,12 +291,12 @@ int ff_hevc_parse_vps(struct get_bits_context *gb, struct h265_VPS_t *vps) vps->vps_temporal_id_nesting_flag = get_bits1(gb); if (get_bits(gb, 16) != 0xffff) { // vps_reserved_ffff_16bits - pr_err("vps_reserved_ffff_16bits is not 0xffff\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "vps_reserved_ffff_16bits is not 0xffff\n"); goto err; } if (vps->vps_max_sub_layers > HEVC_MAX_SUB_LAYERS) { - pr_err("vps_max_sub_layers out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "vps_max_sub_layers out of range: %d\n", vps->vps_max_sub_layers); goto err; } @@ -313,12 +313,12 @@ int ff_hevc_parse_vps(struct get_bits_context *gb, struct h265_VPS_t *vps) vps->vps_max_latency_increase[i] = get_ue_golomb_long(gb) - 1; if (vps->vps_max_dec_pic_buffering[i] > HEVC_MAX_DPB_SIZE || !vps->vps_max_dec_pic_buffering[i]) { - pr_err("vps_max_dec_pic_buffering_minus1 out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "vps_max_dec_pic_buffering_minus1 out of range: %d\n", vps->vps_max_dec_pic_buffering[i] - 1); goto err; } if (vps->vps_num_reorder_pics[i] > vps->vps_max_dec_pic_buffering[i] - 1) { - pr_err("vps_max_num_reorder_pics out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "vps_max_num_reorder_pics out of range: %d\n", vps->vps_num_reorder_pics[i]); goto err; } @@ -328,7 +328,7 @@ int ff_hevc_parse_vps(struct get_bits_context *gb, struct h265_VPS_t *vps) vps->vps_num_layer_sets = get_ue_golomb_long(gb) + 1; if (vps->vps_num_layer_sets < 1 || vps->vps_num_layer_sets > 1024 || (vps->vps_num_layer_sets - 1LL) * (vps->vps_max_layer_id + 1LL) > get_bits_left(gb)) { - pr_err("too many layer_id_included_flags\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "too many layer_id_included_flags\n"); goto err; } @@ -345,7 +345,7 @@ int ff_hevc_parse_vps(struct get_bits_context *gb, struct h265_VPS_t *vps) vps->vps_num_ticks_poc_diff_one = get_ue_golomb_long(gb) + 1; vps->vps_num_hrd_parameters = get_ue_golomb_long(gb); if (vps->vps_num_hrd_parameters > (u32)vps->vps_num_layer_sets) { - pr_err("vps_num_hrd_parameters %d is invalid\n", vps->vps_num_hrd_parameters); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "vps_num_hrd_parameters %d is invalid\n", vps->vps_num_hrd_parameters); goto err; } for (i = 0; i < vps->vps_num_hrd_parameters; i++) { @@ -360,7 +360,7 @@ int ff_hevc_parse_vps(struct get_bits_context *gb, struct h265_VPS_t *vps) get_bits1(gb); /* vps_extension_flag */ if (get_bits_left(gb) < 0) { - pr_err("Overread VPS by %d bits\n", -get_bits_left(gb)); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Overread VPS by %d bits\n", -get_bits_left(gb)); goto err; } @@ -398,7 +398,7 @@ static int map_pixel_format(struct h265_SPS_t *sps) if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P12; break; default: - pr_info("The following bit-depths are currently specified: 8, 9, 10 and 12 bits, " + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "The following bit-depths are currently specified: 8, 9, 10 and 12 bits, " "chroma_format_idc is %d, depth is %d\n", sps->chroma_format_idc, sps->bit_depth); return -1; @@ -466,7 +466,7 @@ static int scaling_list_data(struct get_bits_context *gb, // Copy from previous array. delta *= (size_id == 3) ? 3 : 1; if (matrix_id < delta) { - pr_err("Invalid delta in scaling list data: %d.\n", delta); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid delta in scaling list data: %d.\n", delta); return -1; } @@ -541,7 +541,7 @@ int ff_hevc_decode_short_term_rps(struct get_bits_context *gb, if (is_slice_header) { u32 delta_idx = get_ue_golomb_long(gb) + 1; if (delta_idx > sps->nb_st_rps) { - pr_err("Invalid value of delta_idx in slice header RPS: %d > %d.\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value of delta_idx in slice header RPS: %d > %d.\n", delta_idx, sps->nb_st_rps); return -1; } @@ -553,7 +553,7 @@ int ff_hevc_decode_short_term_rps(struct get_bits_context *gb, delta_rps_sign = get_bits1(gb); abs_delta_rps = get_ue_golomb_long(gb) + 1; if (abs_delta_rps < 1 || abs_delta_rps > 32768) { - pr_err("Invalid value of abs_delta_rps: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value of abs_delta_rps: %d\n", abs_delta_rps); return -1; } @@ -579,7 +579,7 @@ int ff_hevc_decode_short_term_rps(struct get_bits_context *gb, } if (k >= ARRAY_SIZE(rps->used)) { - pr_err( "Invalid num_delta_pocs: %d\n", k); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid num_delta_pocs: %d\n", k); return -1; } @@ -623,7 +623,7 @@ int ff_hevc_decode_short_term_rps(struct get_bits_context *gb, if (rps->num_negative_pics >= HEVC_MAX_REFS || nb_positive_pics >= HEVC_MAX_REFS) { - pr_err("Too many refs in a short term RPS.\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Too many refs in a short term RPS.\n"); return -1; } @@ -633,7 +633,7 @@ int ff_hevc_decode_short_term_rps(struct get_bits_context *gb, for (i = 0; i < rps->num_negative_pics; i++) { delta_poc = get_ue_golomb_long(gb) + 1; if (delta_poc < 1 || delta_poc > 32768) { - pr_err("Invalid value of delta_poc: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value of delta_poc: %d\n", delta_poc); return -1; } @@ -645,7 +645,7 @@ int ff_hevc_decode_short_term_rps(struct get_bits_context *gb, for (i = 0; i < nb_positive_pics; i++) { delta_poc = get_ue_golomb_long(gb) + 1; if (delta_poc < 1 || delta_poc > 32768) { - pr_err("Invalid value of delta_poc: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value of delta_poc: %d\n", delta_poc); return -1; } @@ -664,7 +664,7 @@ static void decode_vui(struct get_bits_context *gb, struct h265_SPS_t *sps) struct get_bits_context backup; int sar_present, alt = 0; - pr_info("Decoding VUI\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Decoding VUI\n"); sar_present = get_bits1(gb); if (sar_present) { @@ -675,7 +675,8 @@ static void decode_vui(struct get_bits_context *gb, struct h265_SPS_t *sps) vui->sar.num = get_bits(gb, 16); vui->sar.den = get_bits(gb, 16); } else - pr_info("Unknown SAR index: %u.\n", sar_idx); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, + "Unknown SAR index: %u.\n", sar_idx); } vui->overscan_info_present_flag = get_bits1(gb); @@ -732,7 +733,7 @@ static void decode_vui(struct get_bits_context *gb, struct h265_SPS_t *sps) memcpy(&backup_vui, vui, sizeof(backup_vui)); if (get_bits_left(gb) >= 68 && show_bits_long(gb, 21) == 0x100000) { vui->default_display_window_flag = 0; - pr_info("Invalid default display window\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Invalid default display window\n"); } else vui->default_display_window_flag = get_bits1(gb); @@ -752,7 +753,7 @@ timing_info: if (get_bits_left(gb) < 66 && !alt) { // The alternate syntax seem to have timing info located // at where def_disp_win is normally located - pr_info("Strange VUI timing information, retrying...\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Strange VUI timing information, retrying...\n"); memcpy(vui, &backup_vui, sizeof(backup_vui)); memcpy(gb, &backup, sizeof(backup)); alt = 1; @@ -761,7 +762,7 @@ timing_info: vui->vui_num_units_in_tick = get_bits_long(gb, 32); vui->vui_time_scale = get_bits_long(gb, 32); if (alt) { - pr_info("Retry got %u/%u fps\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Retry got %u/%u fps\n", vui->vui_time_scale, vui->vui_num_units_in_tick); } vui->vui_poc_proportional_to_timing_flag = get_bits1(gb); @@ -775,7 +776,7 @@ timing_info: vui->bitstream_restriction_flag = get_bits1(gb); if (vui->bitstream_restriction_flag) { if (get_bits_left(gb) < 8 && !alt) { - pr_info("Strange VUI bitstream restriction information, retrying" + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Strange VUI bitstream restriction information, retrying" " from timing information...\n"); memcpy(vui, &backup_vui, sizeof(backup_vui)); memcpy(gb, &backup, sizeof(backup)); @@ -794,7 +795,7 @@ timing_info: if (get_bits_left(gb) < 1 && !alt) { // XXX: Alternate syntax when sps_range_extension_flag != 0? - pr_info("Overread in VUI, retrying from timing information...\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Overread in VUI, retrying from timing information...\n"); memcpy(vui, &backup_vui, sizeof(backup_vui)); memcpy(gb, &backup, sizeof(backup)); alt = 1; @@ -811,13 +812,13 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->vps_id = get_bits(gb, 4); if (sps->vps_id >= HEVC_MAX_VPS_COUNT) { - pr_err("VPS id out of range: %d\n", sps->vps_id); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "VPS id out of range: %d\n", sps->vps_id); return -1; } sps->max_sub_layers = get_bits(gb, 3) + 1; if (sps->max_sub_layers > HEVC_MAX_SUB_LAYERS) { - pr_err("sps_max_sub_layers out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "sps_max_sub_layers out of range: %d\n", sps->max_sub_layers); return -1; } @@ -829,13 +830,13 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->sps_id = get_ue_golomb_long(gb); if (sps->sps_id >= HEVC_MAX_SPS_COUNT) { - pr_err("SPS id out of range: %d\n", sps->sps_id); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "SPS id out of range: %d\n", sps->sps_id); return -1; } sps->chroma_format_idc = get_ue_golomb_long(gb); if (sps->chroma_format_idc > 3U) { - pr_err("chroma_format_idc %d is invalid\n", sps->chroma_format_idc); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "chroma_format_idc %d is invalid\n", sps->chroma_format_idc); return -1; } @@ -848,7 +849,7 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->width = get_ue_golomb_long(gb); sps->height = get_ue_golomb_long(gb); if (sps->width > 8192 || sps->height > 8192) { - pr_err("width or height oversize.\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "width or height oversize.\n"); return -1; } @@ -865,7 +866,7 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->bit_depth = get_ue_golomb_long(gb) + 8; bit_depth_chroma = get_ue_golomb_long(gb) + 8; if (sps->chroma_format_idc && bit_depth_chroma != sps->bit_depth) { - pr_err("Luma bit depth (%d) is different from chroma bit depth (%d), this is unsupported.\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Luma bit depth (%d) is different from chroma bit depth (%d), this is unsupported.\n", sps->bit_depth, bit_depth_chroma); return -1; } @@ -877,7 +878,7 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->log2_max_poc_lsb = get_ue_golomb_long(gb) + 4; if (sps->log2_max_poc_lsb > 16) { - pr_err("log2_max_pic_order_cnt_lsb_minus4 out range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "log2_max_pic_order_cnt_lsb_minus4 out range: %d\n", sps->log2_max_poc_lsb - 4); return -1; } @@ -889,12 +890,12 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->temporal_layer[i].num_reorder_pics = get_ue_golomb_long(gb); sps->temporal_layer[i].max_latency_increase = get_ue_golomb_long(gb) - 1; if (sps->temporal_layer[i].max_dec_pic_buffering > (u32)HEVC_MAX_DPB_SIZE) { - pr_err("sps_max_dec_pic_buffering_minus1 out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "sps_max_dec_pic_buffering_minus1 out of range: %d\n", sps->temporal_layer[i].max_dec_pic_buffering - 1U); return -1; } if (sps->temporal_layer[i].num_reorder_pics > sps->temporal_layer[i].max_dec_pic_buffering - 1) { - pr_info("sps_max_num_reorder_pics out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "sps_max_num_reorder_pics out of range: %d\n", sps->temporal_layer[i].num_reorder_pics); if (sps->temporal_layer[i].num_reorder_pics > HEVC_MAX_DPB_SIZE - 1) { return -1; @@ -918,22 +919,22 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size + sps->log2_min_tb_size; if (sps->log2_min_cb_size < 3 || sps->log2_min_cb_size > 30) { - pr_err("Invalid value %d for log2_min_cb_size", sps->log2_min_cb_size); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value %d for log2_min_cb_size", sps->log2_min_cb_size); return -1; } if (sps->log2_diff_max_min_coding_block_size > 30) { - pr_err("Invalid value %d for log2_diff_max_min_coding_block_size", sps->log2_diff_max_min_coding_block_size); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value %d for log2_diff_max_min_coding_block_size", sps->log2_diff_max_min_coding_block_size); return -1; } if (sps->log2_min_tb_size >= sps->log2_min_cb_size || sps->log2_min_tb_size < 2) { - pr_err("Invalid value for log2_min_tb_size"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value for log2_min_tb_size"); return -1; } if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) { - pr_err("Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size); return -1; } @@ -962,7 +963,7 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->pcm.log2_max_pcm_cb_size = sps->pcm.log2_min_pcm_cb_size + get_ue_golomb_long(gb); if (FFMAX(sps->pcm.bit_depth, sps->pcm.bit_depth_chroma) > sps->bit_depth) { - pr_err("PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "PCM bit depth (%d, %d) is greater than normal bit depth (%d)\n", sps->pcm.bit_depth, sps->pcm.bit_depth_chroma, sps->bit_depth); return -1; } @@ -972,7 +973,7 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->nb_st_rps = get_ue_golomb_long(gb); if (sps->nb_st_rps > HEVC_MAX_SHORT_TERM_REF_PIC_SETS) { - pr_err("Too many short term RPS: %d.\n", sps->nb_st_rps); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Too many short term RPS: %d.\n", sps->nb_st_rps); return -1; } for (i = 0; i < sps->nb_st_rps; i++) { @@ -984,7 +985,7 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) if (sps->long_term_ref_pics_present_flag) { sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb); if (sps->num_long_term_ref_pics_sps > HEVC_MAX_LONG_TERM_REF_PICS) { - pr_err("Too many long term ref pics: %d.\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Too many long term ref pics: %d.\n", sps->num_long_term_ref_pics_sps); return -1; } @@ -1011,17 +1012,17 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->explicit_rdpcm_enabled_flag = get_bits1(gb); sps->extended_precision_processing_flag = get_bits1(gb); if (sps->extended_precision_processing_flag) - pr_info("extended_precision_processing_flag not yet implemented\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "extended_precision_processing_flag not yet implemented\n"); sps->intra_smoothing_disabled_flag = get_bits1(gb); sps->high_precision_offsets_enabled_flag = get_bits1(gb); if (sps->high_precision_offsets_enabled_flag) - pr_info("high_precision_offsets_enabled_flag not yet implemented\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "high_precision_offsets_enabled_flag not yet implemented\n"); sps->persistent_rice_adaptation_enabled_flag = get_bits1(gb); sps->cabac_bypass_alignment_enabled_flag = get_bits1(gb); if (sps->cabac_bypass_alignment_enabled_flag) - pr_info("cabac_bypass_alignment_enabled_flag not yet implemented\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "cabac_bypass_alignment_enabled_flag not yet implemented\n"); } } @@ -1030,7 +1031,7 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) ow->top_offset >= INT_MAX - ow->bottom_offset || ow->left_offset + ow->right_offset >= sps->width || ow->top_offset + ow->bottom_offset >= sps->height) { - pr_err("Invalid cropping offsets: %u/%u/%u/%u\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid cropping offsets: %u/%u/%u/%u\n", ow->left_offset, ow->right_offset, ow->top_offset, ow->bottom_offset); return -1; } @@ -1041,12 +1042,12 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) sps->log2_min_pu_size = sps->log2_min_cb_size - 1; if (sps->log2_ctb_size > HEVC_MAX_LOG2_CTB_SIZE) { - pr_err("CTB size out of range: 2^%d\n", sps->log2_ctb_size); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "CTB size out of range: 2^%d\n", sps->log2_ctb_size); return -1; } if (sps->log2_ctb_size < 4) { - pr_err("log2_ctb_size %d differs from the bounds of any known profile\n", sps->log2_ctb_size); - pr_err("log2_ctb_size %d", sps->log2_ctb_size); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "log2_ctb_size %d differs from the bounds of any known profile\n", sps->log2_ctb_size); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "log2_ctb_size %d", sps->log2_ctb_size); return -1; } @@ -1065,32 +1066,32 @@ int ff_hevc_parse_sps(struct get_bits_context *gb, struct h265_SPS_t *sps) if (av_mod_uintp2(sps->width, sps->log2_min_cb_size) || av_mod_uintp2(sps->height, sps->log2_min_cb_size)) { - pr_err("Invalid coded frame dimensions.\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid coded frame dimensions.\n"); return -1; } if (sps->max_transform_hierarchy_depth_inter > sps->log2_ctb_size - sps->log2_min_tb_size) { - pr_err("max_transform_hierarchy_depth_inter out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "max_transform_hierarchy_depth_inter out of range: %d\n", sps->max_transform_hierarchy_depth_inter); return -1; } if (sps->max_transform_hierarchy_depth_intra > sps->log2_ctb_size - sps->log2_min_tb_size) { - pr_err("max_transform_hierarchy_depth_intra out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "max_transform_hierarchy_depth_intra out of range: %d\n", sps->max_transform_hierarchy_depth_intra); return -1; } if (sps->log2_max_trafo_size > FFMIN(sps->log2_ctb_size, 5)) { - pr_err("max transform block size out of range: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "max transform block size out of range: %d\n", sps->log2_max_trafo_size); return -1; } if (get_bits_left(gb) < 0) { - pr_err("Overread SPS by %d bits\n", -get_bits_left(gb)); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Overread SPS by %d bits\n", -get_bits_left(gb)); return -1; } - pr_info("Parsed SPS: id %d; ref: %d, coded wxh: %dx%d, cropped wxh: %dx%d; pix_fmt: %d.\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Parsed SPS: id %d; ref: %d, coded wxh: %dx%d, cropped wxh: %dx%d; pix_fmt: %d.\n", sps->sps_id, sps->temporal_layer[0].num_reorder_pics, sps->width, sps->height, sps->width - (sps->output_window.left_offset + sps->output_window.right_offset), sps->height - (sps->output_window.top_offset + sps->output_window.bottom_offset), @@ -1205,7 +1206,7 @@ static int decode_extradata_ps(u8 *data, int size, struct h265_param_sets *ps) if (get_bits1(&gb) != 0) { ret = -1; - pr_err("invalid data, return!\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "invalid data, return!\n"); goto out; } @@ -1241,7 +1242,7 @@ static int decode_extradata_ps(u8 *data, int size, struct h265_param_sets *ps) ps->pps_parsed = true; break;*/ default: - pr_err("Unsupport parser nal type (%s).\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Unsupport parser nal type (%s).\n", hevc_nal_unit_name(nal_type)); break; } @@ -1264,7 +1265,7 @@ int h265_decode_extradata_ps(u8 *buf, int size, struct h265_param_sets *ps) len = size - (p - buf); ret = decode_extradata_ps(p, len, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "parse extra data failed. err: %d\n", ret); return ret; } diff --git a/drivers/amvdec_ports/decoder/aml_hevc_parser.h b/drivers/amvdec_ports/decoder/aml_hevc_parser.h index 267450f..f55c381 100644 --- a/drivers/amvdec_ports/decoder/aml_hevc_parser.h +++ b/drivers/amvdec_ports/decoder/aml_hevc_parser.h @@ -19,6 +19,7 @@ #ifndef AML_HEVC_PARSER_H #define AML_HEVC_PARSER_H +#include "../aml_vcodec_drv.h" #include "../utils/common.h" #define MAX_DPB_SIZE 16 // A.4.1 diff --git a/drivers/amvdec_ports/decoder/aml_mjpeg_parser.c b/drivers/amvdec_ports/decoder/aml_mjpeg_parser.c index 1d9d94b..c582ab0 100644 --- a/drivers/amvdec_ports/decoder/aml_mjpeg_parser.c +++ b/drivers/amvdec_ports/decoder/aml_mjpeg_parser.c @@ -33,7 +33,7 @@ static int find_marker(const u8 **pbuf_ptr, const u8 *buf_end) buf_ptr = buf_end; val = -1; found: - pr_info("find_marker skipped %d bytes\n", skipped); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "find_marker skipped %d bytes\n", skipped); *pbuf_ptr = buf_ptr; return val; @@ -100,7 +100,7 @@ int ff_mjpeg_find_marker(struct MJpegDecodeContext *s, memset(s->buffer + *unescaped_buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); - pr_info("escaping removed %d bytes\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "escaping removed %d bytes\n", (int)((buf_end - *buf_ptr) - (dst - s->buffer))); } else if (start_code == SOS && s->ls) { const u8 *src = *buf_ptr; @@ -131,7 +131,7 @@ int ff_mjpeg_find_marker(struct MJpegDecodeContext *s, if (x == 0xFF && b < t) { x = src[b++]; if (x & 0x80) { - pr_err("Invalid escape sequence\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid escape sequence\n"); x &= 0x7f; } put_bits(&pb, 7, x); @@ -168,14 +168,14 @@ int ff_mjpeg_decode_sof(struct MJpegDecodeContext *s) bits = get_bits(&s->gb, 8); if (bits > 16 || bits < 1) { - pr_err("bits %d is invalid\n", bits); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "bits %d is invalid\n", bits); return -1; } height = get_bits(&s->gb, 16); width = get_bits(&s->gb, 16); - pr_info("sof0: picture: %dx%d\n", width, height); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "sof0: picture: %dx%d\n", width, height); nb_components = get_bits(&s->gb, 8); if (nb_components <= 0 || @@ -197,16 +197,16 @@ int ff_mjpeg_decode_sof(struct MJpegDecodeContext *s) s->v_max = v_count[i]; s->quant_index[i] = get_bits(&s->gb, 8); if (s->quant_index[i] >= 4) { - pr_err("quant_index is invalid\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "quant_index is invalid\n"); return -1; } if (!h_count[i] || !v_count[i]) { - pr_err("Invalid sampling factor in component %d %d:%d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid sampling factor in component %d %d:%d\n", i, h_count[i], v_count[i]); return -1; } - pr_info("component %d %d:%d id: %d quant:%d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "component %d %d:%d id: %d quant:%d\n", i, h_count[i], v_count[i], s->component_id[i], s->quant_index[i]); } @@ -256,21 +256,21 @@ static int ff_mjpeg_decode_frame(u8 *buf, int buf_size, struct MJpegDecodeContex if (start_code < 0) { break; } else if (unescaped_buf_size > INT_MAX / 8) { - pr_err("MJPEG packet 0x%x too big (%d/%d), corrupt data?\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "MJPEG packet 0x%x too big (%d/%d), corrupt data?\n", start_code, unescaped_buf_size, buf_size); return -1; } - pr_info("marker=%x avail_size_in_buf=%d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "marker=%x avail_size_in_buf=%d\n", start_code, (int)(buf_end - buf_ptr)); ret = init_get_bits8(&s->gb, unescaped_buf_ptr, unescaped_buf_size); if (ret < 0) { - pr_err("invalid buffer\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "invalid buffer\n"); goto fail; } s->start_code = start_code; - pr_info("startcode: %X\n", start_code); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "startcode: %X\n", start_code); switch (start_code) { case SOF0: @@ -348,23 +348,23 @@ static int ff_mjpeg_decode_frame(u8 *buf, int buf_size, struct MJpegDecodeContex case SOF14: case SOF15: case JPG: - pr_err("mjpeg: unsupported coding type (%x)\n", start_code); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "mjpeg: unsupported coding type (%x)\n", start_code); break; } skip: /* eof process start code */ buf_ptr += (get_bits_count(&s->gb) + 7) / 8; - pr_info("marker parser used %d bytes (%d bits)\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "marker parser used %d bytes (%d bits)\n", (get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb)); } - pr_err("No JPEG data found in image\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "No JPEG data found in image\n"); return -1; fail: s->got_picture = 0; return ret; the_end: - pr_info("decode frame unused %d bytes\n", (int)(buf_end - buf_ptr)); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "decode frame unused %d bytes\n", (int)(buf_end - buf_ptr)); return 0; } @@ -382,7 +382,7 @@ int mjpeg_decode_extradata_ps(u8 *buf, int size, struct mjpeg_param_sets *ps) ret = ff_mjpeg_decode_frame(buf, size, &ps->dec_ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "parse extra data failed. err: %d\n", ret); vfree(ps->dec_ps.buffer); return ret; } diff --git a/drivers/amvdec_ports/decoder/aml_mjpeg_parser.h b/drivers/amvdec_ports/decoder/aml_mjpeg_parser.h index 20fdbbc..cc4c453 100644 --- a/drivers/amvdec_ports/decoder/aml_mjpeg_parser.h +++ b/drivers/amvdec_ports/decoder/aml_mjpeg_parser.h @@ -1,6 +1,7 @@ #ifndef AML_MPEG12_PARSER_H #define AML_MPEG12_PARSER_H +#include "../aml_vcodec_drv.h" #include "../utils/pixfmt.h" #include "../utils/common.h" #include "../utils/get_bits.h" diff --git a/drivers/amvdec_ports/decoder/aml_mpeg12_parser.h b/drivers/amvdec_ports/decoder/aml_mpeg12_parser.h index de1292d..203bb51 100644 --- a/drivers/amvdec_ports/decoder/aml_mpeg12_parser.h +++ b/drivers/amvdec_ports/decoder/aml_mpeg12_parser.h @@ -1,6 +1,7 @@ #ifndef AML_MPEG12_PARSER_H #define AML_MPEG12_PARSER_H +#include "../aml_vcodec_drv.h" #include "../utils/pixfmt.h" #include "../utils/common.h" diff --git a/drivers/amvdec_ports/decoder/aml_mpeg4_parser.c b/drivers/amvdec_ports/decoder/aml_mpeg4_parser.c index b16c2d1..9c47c08 100644 --- a/drivers/amvdec_ports/decoder/aml_mpeg4_parser.c +++ b/drivers/amvdec_ports/decoder/aml_mpeg4_parser.c @@ -149,7 +149,7 @@ static int decode_studio_vol_header(struct mpeg4_dec_param *ctx, struct get_bits ctx->rgb = get_bits1(gb); /* rgb_components */ s->chroma_format = get_bits(gb, 2); /* chroma_format */ if (!s->chroma_format) { - pr_err("illegal chroma format\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "illegal chroma format\n"); return -1; } @@ -162,7 +162,7 @@ static int decode_studio_vol_header(struct mpeg4_dec_param *ctx, struct get_bits } } else { - pr_err("MPEG-4 Studio profile bit-depth %u", bits_per_raw_sample); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "MPEG-4 Studio profile bit-depth %u", bits_per_raw_sample); return -1; } ctx->bits_per_raw_sample = bits_per_raw_sample; @@ -253,7 +253,7 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex if ((ctx->vol_control_parameters = get_bits1(gb))) { /* vol control parameter */ int chroma_format = get_bits(gb, 2); if (chroma_format != CHROMA_420) - pr_err("illegal chroma format\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "illegal chroma format\n"); s->low_delay = get_bits1(gb); if (get_bits1(gb)) { /* vbv parameters */ @@ -286,9 +286,9 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex ctx->shape = get_bits(gb, 2); /* vol shape */ if (ctx->shape != RECT_SHAPE) - pr_err("only rectangular vol supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "only rectangular vol supported\n"); if (ctx->shape == GRAY_SHAPE && vo_ver_id != 1) { - pr_err("Gray shape not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Gray shape not supported\n"); skip_bits(gb, 4); /* video_object_layer_shape_extension */ } @@ -296,7 +296,7 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex ctx->framerate.num = get_bits(gb, 16); if (!ctx->framerate.num) { - pr_err("framerate==0\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "framerate==0\n"); return -1; } @@ -336,14 +336,14 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex s->progressive_frame = get_bits1(gb) ^ 1; s->interlaced_dct = 0; if (!get_bits1(gb)) /* OBMC Disable */ - pr_info("MPEG-4 OBMC not supported (very likely buggy encoder)\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "MPEG-4 OBMC not supported (very likely buggy encoder)\n"); if (vo_ver_id == 1) ctx->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */ else ctx->vol_sprite_usage = get_bits(gb, 2); /* vol_sprite_usage */ if (ctx->vol_sprite_usage == STATIC_SPRITE) - pr_err("Static Sprites not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Static Sprites not supported\n"); if (ctx->vol_sprite_usage == STATIC_SPRITE || ctx->vol_sprite_usage == GMC_SPRITE) { if (ctx->vol_sprite_usage == STATIC_SPRITE) { @@ -358,7 +358,7 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex } ctx->num_sprite_warping_points = get_bits(gb, 6); if (ctx->num_sprite_warping_points > 3) { - pr_err("%d sprite_warping_points\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "%d sprite_warping_points\n", ctx->num_sprite_warping_points); ctx->num_sprite_warping_points = 0; return -1; @@ -373,9 +373,9 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex if (get_bits1(gb) == 1) { /* not_8_bit */ s->quant_precision = get_bits(gb, 4); /* quant_precision */ if (get_bits(gb, 4) != 8) /* bits_per_pixel */ - pr_err("N-bit not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "N-bit not supported\n"); if (s->quant_precision != 5) - pr_err("quant precision %d\n", s->quant_precision); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "quant precision %d\n", s->quant_precision); if (s->quant_precision<3 || s->quant_precision>9) { s->quant_precision = 5; } @@ -396,7 +396,7 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex for (i = 0; i < 64; i++) { //int j; if (get_bits_left(gb) < 8) { - pr_err("insufficient data for custom matrix\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "insufficient data for custom matrix\n"); return -1; } v = get_bits(gb, 8); @@ -423,7 +423,7 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex for (i = 0; i < 64; i++) { //int j; if (get_bits_left(gb) < 8) { - pr_err("insufficient data for custom matrix\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "insufficient data for custom matrix\n"); return -1; } v = get_bits(gb, 8); @@ -453,7 +453,7 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex s->quarter_sample = 0; if (get_bits_left(gb) < 4) { - pr_err("VOL Header truncated\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "VOL Header truncated\n"); return -1; } @@ -502,7 +502,7 @@ static int decode_vol_header(struct mpeg4_dec_param *ctx, struct get_bits_contex ctx->cplx_estimation_trash_p += 8 * get_bits1(gb); /* qpel */ } } else - pr_err("Invalid Complexity estimation method %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid Complexity estimation method %d\n", estimation_method); } else { @@ -521,12 +521,12 @@ no_cplx_est: if (vo_ver_id != 1) { ctx->new_pred = get_bits1(gb); if (ctx->new_pred) { - pr_err("new pred not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "new pred not supported\n"); skip_bits(gb, 2); /* requested upstream message type */ skip_bits1(gb); /* newpred segment type */ } if (get_bits1(gb)) // reduced_res_vop - pr_err("reduced resolution VOP not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "reduced resolution VOP not supported\n"); } else { ctx->new_pred = 0; } @@ -556,22 +556,21 @@ no_cplx_est: ctx->scalability = 0; *gb = bak; } else - pr_err("scalability not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "scalability not supported\n"); // bin shape stuff FIXME } } if (1) { - pr_info("tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, low_delay:%d %s%s%s%s\n", - ctx->framerate.den, ctx->framerate.num, - ctx->time_increment_bits, - s->quant_precision, - s->progressive_sequence, - s->low_delay, - ctx->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "", - s->data_partitioning ? "partition " : "", ctx->rvlc ? "rvlc " : "" - ); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, low_delay:%d %s%s%s%s\n", + ctx->framerate.den, ctx->framerate.num, + ctx->time_increment_bits, + s->quant_precision, + s->progressive_sequence, + s->low_delay, + ctx->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "", + s->data_partitioning ? "partition " : "", ctx->rvlc ? "rvlc " : ""); } return 0; @@ -616,7 +615,7 @@ static int decode_user_data(struct mpeg4_dec_param *ctx, struct get_bits_context e = sscanf(buf, "Lavc%d.%d.%d", &ver, &ver2, &ver3) + 1; if (e > 1) { if (ver > 0xFFU || ver2 > 0xFFU || ver3 > 0xFFU) { - pr_info("Unknown Lavc version string encountered, %d.%d.%d; " + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Unknown Lavc version string encountered, %d.%d.%d; " "clamping sub-version values to 8-bits.\n", ver, ver2, ver3); } @@ -644,7 +643,7 @@ static int mpeg4_decode_gop_header(struct MpegEncContext *s, struct get_bits_con int hours, minutes, seconds; if (!show_bits(gb, 23)) { - pr_err("GOP header invalid\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "GOP header invalid\n"); return -1; } @@ -685,7 +684,7 @@ static int decode_studiovisualobject(struct mpeg4_dec_param *ctx, struct get_bit skip_bits(gb, 4); /* visual_object_verid */ visual_object_type = get_bits(gb, 4); if (visual_object_type != VOT_VIDEO_ID) { - pr_err("VO type %u", visual_object_type); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "VO type %u", visual_object_type); return -1; } @@ -818,7 +817,7 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex s->pict_type = get_bits(gb, 2) + AV_PICTURE_TYPE_I; /* pict type: I = 0 , P = 1 */ if (s->pict_type == AV_PICTURE_TYPE_B && s->low_delay && ctx->vol_control_parameters == 0) { - pr_err("low_delay flag set incorrectly, clearing it\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "low_delay flag set incorrectly, clearing it\n"); s->low_delay = 0; } @@ -836,7 +835,7 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex if (ctx->time_increment_bits == 0 || !(show_bits(gb, ctx->time_increment_bits + 1) & 1)) { - pr_info("time_increment_bits %d is invalid in relation to the current bitstream, this is likely caused by a missing VOL header\n", ctx->time_increment_bits); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "time_increment_bits %d is invalid in relation to the current bitstream, this is likely caused by a missing VOL header\n", ctx->time_increment_bits); for (ctx->time_increment_bits = 1; ctx->time_increment_bits < 16; @@ -850,7 +849,7 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex break; } - pr_info("time_increment_bits set to %d bits, based on bitstream analysis\n", ctx->time_increment_bits); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "time_increment_bits set to %d bits, based on bitstream analysis\n", ctx->time_increment_bits); if (ctx->framerate.num && 4*ctx->framerate.num < 1<<ctx->time_increment_bits) { ctx->framerate.num = 1<<ctx->time_increment_bits; //ctx->time_base = av_inv_q(av_mul_q(ctx->framerate, (AVRational){ctx->ticks_per_frame, 1})); @@ -900,14 +899,14 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex pts = ROUNDED_DIV(s->time, ctx->framerate.den); else pts = AV_NOPTS_VALUE; - pr_info("MPEG4 PTS: %lld\n", pts); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "MPEG4 PTS: %lld\n", pts); check_marker(gb, "before vop_coded"); /* vop coded */ if (get_bits1(gb) != 1) { if (1) - pr_err("vop not coded\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "vop not coded\n"); return FRAME_SKIPPED; } if (ctx->new_pred) @@ -950,7 +949,7 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex skip_bits_long(gb, ctx->cplx_estimation_trash_b); if (get_bits_left(gb) < 3) { - pr_err("Header truncated\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Header truncated\n"); return -1; } ctx->intra_dc_threshold = ff_mpeg4_dc_threshold[get_bits(gb, 3)]; @@ -969,9 +968,9 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex //if (mpeg4_decode_sprite_trajectory(ctx, gb) < 0) //return -1; if (ctx->sprite_brightness_change) - pr_err("sprite_brightness_change not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "sprite_brightness_change not supported\n"); if (ctx->vol_sprite_usage == STATIC_SPRITE) - pr_err("static sprite not supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "static sprite not supported\n"); } else { memset(s->sprite_offset, 0, sizeof(s->sprite_offset)); memset(s->sprite_delta, 0, sizeof(s->sprite_delta)); @@ -981,14 +980,14 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex if (ctx->shape != BIN_ONLY_SHAPE) { s->chroma_qscale = s->qscale = get_bits(gb, s->quant_precision); if (s->qscale == 0) { - pr_err("Error, header damaged or not MPEG-4 header (qscale=0)\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Error, header damaged or not MPEG-4 header (qscale=0)\n"); return -1; // makes no sense to continue, as there is nothing left from the image then } if (s->pict_type != AV_PICTURE_TYPE_I) { s->f_code = get_bits(gb, 3); /* fcode_for */ if (s->f_code == 0) { - pr_err("Error, header damaged or not MPEG-4 header (f_code=0)\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Error, header damaged or not MPEG-4 header (f_code=0)\n"); s->f_code = 1; return -1; // makes no sense to continue, as there is nothing left from the image then } @@ -998,7 +997,7 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex if (s->pict_type == AV_PICTURE_TYPE_B) { s->b_code = get_bits(gb, 3); if (s->b_code == 0) { - pr_err("Error, header damaged or not MPEG4 header (b_code=0)\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Error, header damaged or not MPEG4 header (b_code=0)\n"); s->b_code=1; return -1; // makes no sense to continue, as the MV decoding will break very quickly } @@ -1006,20 +1005,19 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex s->b_code = 1; if (1) { - pr_info("qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d time:%ld tincr:%d\n", - s->qscale, s->f_code, s->b_code, - s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")), - gb->size_in_bits,s->progressive_sequence, s->alternate_scan, - s->top_field_first, s->quarter_sample ? "q" : "h", - s->data_partitioning, ctx->resync_marker, - ctx->num_sprite_warping_points, s->sprite_warping_accuracy, - 1 - s->no_rounding, s->vo_type, - ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold, - ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p, - ctx->cplx_estimation_trash_b, - s->time, - time_increment - ); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d time:%ld tincr:%d\n", + s->qscale, s->f_code, s->b_code, + s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")), + gb->size_in_bits,s->progressive_sequence, s->alternate_scan, + s->top_field_first, s->quarter_sample ? "q" : "h", + s->data_partitioning, ctx->resync_marker, + ctx->num_sprite_warping_points, s->sprite_warping_accuracy, + 1 - s->no_rounding, s->vo_type, + ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold, + ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p, + ctx->cplx_estimation_trash_b, + s->time, + time_increment); } if (!ctx->scalability) { @@ -1029,7 +1027,7 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex if (ctx->enhancement_type) { int load_backward_shape = get_bits1(gb); if (load_backward_shape) - pr_err("load backward shape isn't supported\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "load backward shape isn't supported\n"); } skip_bits(gb, 2); // ref_select_code } @@ -1039,7 +1037,7 @@ static int decode_vop_header(struct mpeg4_dec_param *ctx, struct get_bits_contex * easily (although it's buggy too) */ if (s->vo_type == 0 && ctx->vol_control_parameters == 0 && ctx->divx_version == -1 && s->picture_number == 0) { - pr_info("looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n"); s->low_delay = 1; } @@ -1088,7 +1086,7 @@ int ff_mpeg4_decode_picture_header(struct mpeg4_dec_param *ctx, struct get_bits_ for (;;) { if (get_bits_count(gb) >= gb->size_in_bits) { if (gb->size_in_bits == 8) { - pr_info("frame skip %d\n", gb->size_in_bits); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "frame skip %d\n", gb->size_in_bits); return FRAME_SKIPPED; // divx bug } else return -1; // end of stream @@ -1102,66 +1100,66 @@ int ff_mpeg4_decode_picture_header(struct mpeg4_dec_param *ctx, struct get_bits_ continue; // no startcode if (1) { //debug - pr_info("startcode: %3X \n", startcode); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "startcode: %3X \n", startcode); if (startcode <= 0x11F) - pr_info("Video Object Start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Video Object Start\n"); else if (startcode <= 0x12F) - pr_info("Video Object Layer Start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Video Object Layer Start\n"); else if (startcode <= 0x13F) - pr_info("Reserved\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Reserved\n"); else if (startcode <= 0x15F) - pr_info("FGS bp start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "FGS bp start\n"); else if (startcode <= 0x1AF) - pr_info("Reserved\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Reserved\n"); else if (startcode == 0x1B0) - pr_info("Visual Object Seq Start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Visual Object Seq Start\n"); else if (startcode == 0x1B1) - pr_info("Visual Object Seq End\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Visual Object Seq End\n"); else if (startcode == 0x1B2) - pr_info("User Data\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "User Data\n"); else if (startcode == 0x1B3) - pr_info("Group of VOP start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Group of VOP start\n"); else if (startcode == 0x1B4) - pr_info("Video Session Error\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Video Session Error\n"); else if (startcode == 0x1B5) - pr_info("Visual Object Start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Visual Object Start\n"); else if (startcode == 0x1B6) - pr_info("Video Object Plane start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Video Object Plane start\n"); else if (startcode == 0x1B7) - pr_info("slice start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "slice start\n"); else if (startcode == 0x1B8) - pr_info("extension start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "extension start\n"); else if (startcode == 0x1B9) - pr_info("fgs start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "fgs start\n"); else if (startcode == 0x1BA) - pr_info("FBA Object start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "FBA Object start\n"); else if (startcode == 0x1BB) - pr_info("FBA Object Plane start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "FBA Object Plane start\n"); else if (startcode == 0x1BC) - pr_info("Mesh Object start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Mesh Object start\n"); else if (startcode == 0x1BD) - pr_info("Mesh Object Plane start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Mesh Object Plane start\n"); else if (startcode == 0x1BE) - pr_info("Still Texture Object start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Still Texture Object start\n"); else if (startcode == 0x1BF) - pr_info("Texture Spatial Layer start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Texture Spatial Layer start\n"); else if (startcode == 0x1C0) - pr_info("Texture SNR Layer start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Texture SNR Layer start\n"); else if (startcode == 0x1C1) - pr_info("Texture Tile start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Texture Tile start\n"); else if (startcode == 0x1C2) - pr_info("Texture Shape Layer start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "Texture Shape Layer start\n"); else if (startcode == 0x1C3) - pr_info("stuffing start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "stuffing start\n"); else if (startcode <= 0x1C5) - pr_info("reserved\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "reserved\n"); else if (startcode <= 0x1FF) - pr_info("System start\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "System start\n"); } if (startcode >= 0x120 && startcode <= 0x12F) { if (vol) { - pr_err("Ignoring multiple VOL headers\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Ignoring multiple VOL headers\n"); continue; } vol++; @@ -1180,7 +1178,7 @@ int ff_mpeg4_decode_picture_header(struct mpeg4_dec_param *ctx, struct get_bits_ next_start_code_studio(gb); extension_and_user_data(s, gb, 0); } else if (s->studio_profile) { - pr_err("Mixes studio and non studio profile\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Mixes studio and non studio profile\n"); return -1; } ctx->profile = profile; @@ -1202,7 +1200,7 @@ int ff_mpeg4_decode_picture_header(struct mpeg4_dec_param *ctx, struct get_bits_ end: if (s->studio_profile) { if (!bits_per_raw_sample) { - pr_err("Missing VOL header\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Missing VOL header\n"); return -1; } return decode_studio_vop_header(ctx, gb); @@ -1221,7 +1219,7 @@ int mpeg4_decode_extradata_ps(u8 *buf, int size, struct mpeg4_param_sets *ps) ret = ff_mpeg4_decode_picture_header(&ps->dec_ps, &gb); if (ret < -1) { - pr_err("Failed to parse extradata\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Failed to parse extradata\n"); return ret; } diff --git a/drivers/amvdec_ports/decoder/aml_mpeg4_parser.h b/drivers/amvdec_ports/decoder/aml_mpeg4_parser.h index 543c631..09f392d 100644 --- a/drivers/amvdec_ports/decoder/aml_mpeg4_parser.h +++ b/drivers/amvdec_ports/decoder/aml_mpeg4_parser.h @@ -1,6 +1,7 @@ #ifndef AVCODEC_MPEG4VIDEO_H #define AVCODEC_MPEG4VIDEO_H +#include "../aml_vcodec_drv.h" #include "../utils/pixfmt.h" #include "../utils/common.h" diff --git a/drivers/amvdec_ports/decoder/aml_vp9_parser.c b/drivers/amvdec_ports/decoder/aml_vp9_parser.c index 2d82dfb..21d5283 100644 --- a/drivers/amvdec_ports/decoder/aml_vp9_parser.c +++ b/drivers/amvdec_ports/decoder/aml_vp9_parser.c @@ -31,11 +31,11 @@ static int read_colorspace_details(struct VP9Context *s, int profile) if (colorspace == AVCOL_SPC_RGB) { // RGB = profile 1 if (profile & 1) { if (get_bits1(&s->gb)) { - pr_err("Reserved bit set in RGB\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Reserved bit set in RGB\n"); return -1; } } else { - pr_err("RGB not supported in profile %d\n", profile); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "RGB not supported in profile %d\n", profile); return -1; } } else { @@ -52,10 +52,10 @@ static int read_colorspace_details(struct VP9Context *s, int profile) s->ss_v = get_bits1(&s->gb); s->pix_fmt = pix_fmt_for_ss[bits][s->ss_v][s->ss_h]; if (s->pix_fmt == AV_PIX_FMT_YUV420P) { - pr_err("YUV 4:2:0 not supported in profile %d\n", profile); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "YUV 4:2:0 not supported in profile %d\n", profile); return -1; } else if (get_bits1(&s->gb)) { - pr_err("Profile %d color details reserved bit set\n", profile); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Profile %d color details reserved bit set\n", profile); return -1; } } else { @@ -73,12 +73,12 @@ int decode_frame_header(const u8 *data, int size, struct VP9Context *s, int *ref /* general header */ if ((ret = init_get_bits8(&s->gb, data, size)) < 0) { - pr_err("Failed to initialize bitstream reader\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Failed to initialize bitstream reader\n"); return ret; } if (get_bits(&s->gb, 2) != 0x2) { // frame marker - pr_err("Invalid frame marker\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid frame marker\n"); return -1; } @@ -88,7 +88,7 @@ int decode_frame_header(const u8 *data, int size, struct VP9Context *s, int *ref profile += get_bits1(&s->gb); if (profile > 3) { - pr_err("Profile %d is not yet supported\n", profile); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Profile %d is not yet supported\n", profile); return -1; } @@ -108,7 +108,7 @@ int decode_frame_header(const u8 *data, int size, struct VP9Context *s, int *ref if (s->s.h.keyframe) { if (get_bits_long(&s->gb, 24) != VP9_SYNCCODE) { // synccode - pr_err("Invalid sync code\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid sync code\n"); return -1; } if ((ret = read_colorspace_details(s,profile)) < 0) @@ -131,7 +131,7 @@ int decode_frame_header(const u8 *data, int size, struct VP9Context *s, int *ref s->s.h.resetctx = s->s.h.errorres ? 0 : get_bits(&s->gb, 2); if (s->s.h.intraonly) { if (get_bits_long(&s->gb, 24) != VP9_SYNCCODE) { // synccode - pr_err("Invalid sync code\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid sync code\n"); return -1; } if (profile >= 1) { @@ -154,7 +154,7 @@ int decode_frame_header(const u8 *data, int size, struct VP9Context *s, int *ref s->render_width = s->width; s->render_height = s->height; } - pr_info("intra res: (%d x %d), render size: (%d x %d)\n", + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "intra res: (%d x %d), render size: (%d x %d)\n", s->width, s->height, s->render_width, s->render_height); } else { s->s.h.refreshrefmask = get_bits(&s->gb, 8); @@ -215,7 +215,7 @@ int vp9_superframe_split_filter(struct vp9_superframe_split *s) total_size += frame_size; if (frame_size < 0 || total_size > s->data_size - idx_size) { - pr_err( "Invalid frame size in a sframe: %d\n", + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "Invalid frame size in a sframe: %d\n", frame_size); ret = -EINVAL; goto fail; @@ -246,7 +246,7 @@ int vp9_superframe_split_filter(struct vp9_superframe_split *s) /* colorspace descriptor */ /* ... */ - pr_info("the frame is a superframe.\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_PARSER, "the frame is a superframe.\n"); } /*pr_err("in: %x, %d, out: %x, sizes %d,%d,%d,%d,%d,%d,%d,%d\n", @@ -277,7 +277,7 @@ int vp9_decode_extradata_ps(u8 *data, int size, struct vp9_param_sets *ps) s.data_size = size; ret = vp9_superframe_split_filter(&s); if (ret) { - pr_err("parse frames failed.\n"); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, "parse frames failed.\n"); return ret; } diff --git a/drivers/amvdec_ports/decoder/aml_vp9_parser.h b/drivers/amvdec_ports/decoder/aml_vp9_parser.h index b9f4489..c016eba 100644 --- a/drivers/amvdec_ports/decoder/aml_vp9_parser.h +++ b/drivers/amvdec_ports/decoder/aml_vp9_parser.h @@ -18,6 +18,7 @@ #ifndef AML_VP9_PARSER_H #define AML_VP9_PARSER_H +#include "../aml_vcodec_drv.h" #include "../utils/pixfmt.h" #include "../utils/get_bits.h" diff --git a/drivers/amvdec_ports/decoder/vdec_h264_if.c b/drivers/amvdec_ports/decoder/vdec_h264_if.c index 30cc441..b1e4945 100644 --- a/drivers/amvdec_ports/decoder/vdec_h264_if.c +++ b/drivers/amvdec_ports/decoder/vdec_h264_if.c @@ -211,11 +211,13 @@ static void get_pic_info(struct vdec_h264_inst *inst, { *pic = inst->vsi->pic; - aml_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)", - pic->visible_width, pic->visible_height, - pic->coded_width, pic->coded_height); - aml_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz, - pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "pic(%d, %d), buf(%d, %d)\n", + pic->visible_width, pic->visible_height, + pic->coded_width, pic->coded_height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Y(%d, %d), C(%d, %d)\n", pic->y_bs_sz, + pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); } static void get_crop_info(struct vdec_h264_inst *inst, struct v4l2_rect *cr) @@ -225,14 +227,15 @@ static void get_crop_info(struct vdec_h264_inst *inst, struct v4l2_rect *cr) cr->width = inst->vsi->crop.width; cr->height = inst->vsi->crop.height; - aml_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d", - cr->left, cr->top, cr->width, cr->height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "l=%d, t=%d, w=%d, h=%d\n", + cr->left, cr->top, cr->width, cr->height); } static void get_dpb_size(struct vdec_h264_inst *inst, unsigned int *dpb_sz) { *dpb_sz = inst->vsi->dec.dpb_sz; - aml_vcodec_debug(inst, "sz=%d", *dpb_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "sz=%d\n", *dpb_sz); } static void skip_aud_data(u8 **data, u32 *size) @@ -314,13 +317,15 @@ static int vdec_h264_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) inst->vfm.ada_ctx = &inst->vdec; ret = vcodec_vfm_init(&inst->vfm); if (ret) { - pr_err("%s, init vfm failed.\n", __func__); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "init vfm failed.\n"); goto err; } ret = video_decoder_init(&inst->vdec); if (ret) { - aml_vcodec_err(inst, "vdec_h264 init err=%d", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "vdec_h264 init err=%d\n", ret); goto err; } @@ -340,7 +345,8 @@ static int vdec_h264_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) init_completion(&inst->comp); - aml_vcodec_debug(inst, "H264 Instance >> %p", inst); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "H264 Instance >> %lx", (ulong) inst); ctx->ada_ctx = &inst->vdec; *h_vdec = (unsigned long)inst; @@ -503,8 +509,9 @@ static void fill_vdec_params(struct vdec_h264_inst *inst, struct h264_SPS_t *sps vdec_config_dw_mode(pic, dw); - aml_vcodec_debug(inst, "[%d] The stream infos, dw: %d, coded:(%d x %d), visible:(%d x %d), DPB: %d, margin: %d\n", - inst->ctx->id, dw, pic->coded_width, pic->coded_height, + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "The stream infos, dw: %d, coded:(%d x %d), visible:(%d x %d), DPB: %d, margin: %d\n", + dw, pic->coded_width, pic->coded_height, pic->visible_width, pic->visible_height, dec->dpb_sz - margin, margin); } @@ -559,7 +566,8 @@ static int stream_parse_by_ucode(struct vdec_h264_inst *inst, u8 *buf, u32 size) ret = vdec_vframe_write(vdec, buf, size, 0); if (ret < 0) { - pr_err("write frame data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "write frame data failed. err: %d\n", ret); return ret; } @@ -591,7 +599,8 @@ static int stream_parse(struct vdec_h264_inst *inst, u8 *buf, u32 size) ret = h264_decode_extradata_ps(buf, size, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "parse extra data failed. err: %d\n", ret); goto out; } @@ -642,8 +651,6 @@ static void vdec_h264_deinit(unsigned long h_vdec) struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec; struct aml_vcodec_ctx *ctx = inst->ctx; - aml_vcodec_debug_enter(inst); - video_decoder_release(&inst->vdec); vcodec_vfm_release(&inst->vfm); @@ -675,14 +682,16 @@ static void vdec_h264_get_vf(struct vdec_h264_inst *inst, struct vdec_v4l2_buffe vf = peek_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "there is no vframe."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "there is no vframe.\n"); *out = NULL; return; } vf = get_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "the vframe is avalid."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vframe is avalid.\n"); *out = NULL; return; } @@ -719,7 +728,7 @@ static int vdec_write_nalu(struct vdec_h264_inst *inst, goto err; nal_type = AVC_NAL_TYPE(buf[nalu_pos]); - //aml_vcodec_debug(inst, "NALU type: %d, size: %u", nal_type, size); + //v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "NALU type: %d, size: %u\n", nal_type, size); if (nal_type == NAL_H264_SPS && !is_combine) { if (inst->vsi->head_offset + size > HEADER_BUFFER_SIZE) { @@ -775,7 +784,7 @@ static int vdec_write_nalu(struct vdec_h264_inst *inst, return ret; err: - aml_vcodec_err(inst, "%s err(%d)", __func__, ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, "err(%d)", ret); return ret; } @@ -813,7 +822,7 @@ static bool monitor_res_change(struct vdec_h264_inst *inst, u8 *buf, u32 size) inst->vsi->cur_pic.profile_idc) || (inst->vsi->pic.ref_frame_count != inst->vsi->cur_pic.ref_frame_count))) { - pr_info("res change\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "res change\n"); inst->vsi->cur_pic = inst->vsi->pic; return true; } @@ -874,7 +883,8 @@ static void get_param_config_info(struct vdec_h264_inst *inst, parms->parms_status |= inst->parms.parms_status; - aml_vcodec_debug(inst, "parms status: %u", parms->parms_status); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "parms status: %u\n", parms->parms_status); } static int vdec_h264_get_param(unsigned long h_vdec, @@ -884,7 +894,8 @@ static int vdec_h264_get_param(unsigned long h_vdec, struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec; if (!inst) { - pr_err("the h264 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the h264 inst of dec is invalid.\n"); return -1; } @@ -913,7 +924,8 @@ static int vdec_h264_get_param(unsigned long h_vdec, get_param_config_info(inst, out); break; default: - aml_vcodec_err(inst, "invalid get parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid get parameter type=%d\n", type); ret = -EINVAL; } @@ -957,7 +969,8 @@ static void set_param_ps_info(struct vdec_h264_inst *inst, /*wake up*/ complete(&inst->comp); - pr_info("Parse from ucode, crop(%d x %d), coded(%d x %d) dpb: %d\n", + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Parse from ucode, crop(%d x %d), coded(%d x %d) dpb: %d\n", ps->visible_width, ps->visible_height, ps->coded_width, ps->coded_height, dec->dpb_sz); @@ -974,14 +987,16 @@ static void set_param_hdr_info(struct vdec_h264_inst *inst, V4L2_CONFIG_PARM_DECODE_HDRINFO; aml_vdec_dispatch_event(inst->ctx, V4L2_EVENT_SRC_CH_HDRINFO); - pr_info("H264 set HDR infos\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "H264 set HDR infos\n"); } } static void set_param_post_event(struct vdec_h264_inst *inst, u32 *event) { aml_vdec_dispatch_event(inst->ctx, *event); - pr_info("H264 post event: %d\n", *event); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "H264 post event: %d\n", *event); } static int vdec_h264_set_param(unsigned long h_vdec, @@ -991,7 +1006,8 @@ static int vdec_h264_set_param(unsigned long h_vdec, struct vdec_h264_inst *inst = (struct vdec_h264_inst *)h_vdec; if (!inst) { - pr_err("the h264 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the h264 inst of dec is invalid.\n"); return -1; } @@ -1012,7 +1028,8 @@ static int vdec_h264_set_param(unsigned long h_vdec, set_param_post_event(inst, in); break; default: - aml_vcodec_err(inst, "invalid set parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid set parameter type=%d\n", type); ret = -EINVAL; } diff --git a/drivers/amvdec_ports/decoder/vdec_hevc_if.c b/drivers/amvdec_ports/decoder/vdec_hevc_if.c index cd4d361..025d521 100644 --- a/drivers/amvdec_ports/decoder/vdec_hevc_if.c +++ b/drivers/amvdec_ports/decoder/vdec_hevc_if.c @@ -122,11 +122,13 @@ static void get_pic_info(struct vdec_hevc_inst *inst, { *pic = inst->vsi->pic; - aml_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)", - pic->visible_width, pic->visible_height, - pic->coded_width, pic->coded_height); - aml_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz, - pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "pic(%d, %d), buf(%d, %d)\n", + pic->visible_width, pic->visible_height, + pic->coded_width, pic->coded_height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Y(%d, %d), C(%d, %d)\n", pic->y_bs_sz, + pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); } static void get_crop_info(struct vdec_hevc_inst *inst, struct v4l2_rect *cr) @@ -136,14 +138,15 @@ static void get_crop_info(struct vdec_hevc_inst *inst, struct v4l2_rect *cr) cr->width = inst->vsi->crop.width; cr->height = inst->vsi->crop.height; - aml_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d", - cr->left, cr->top, cr->width, cr->height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "l=%d, t=%d, w=%d, h=%d\n", + cr->left, cr->top, cr->width, cr->height); } static void get_dpb_size(struct vdec_hevc_inst *inst, unsigned int *dpb_sz) { *dpb_sz = inst->vsi->dec.dpb_sz; - aml_vcodec_debug(inst, "sz=%d", *dpb_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "sz=%d\n", *dpb_sz); } static u32 vdec_config_default_parms(u8 *parm) @@ -223,13 +226,15 @@ static int vdec_hevc_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) inst->vfm.ada_ctx = &inst->vdec; ret = vcodec_vfm_init(&inst->vfm); if (ret) { - pr_err("%s, init vfm failed.\n", __func__); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "init vfm failed.\n"); goto err; } ret = video_decoder_init(&inst->vdec); if (ret) { - aml_vcodec_err(inst, "vdec_hevc init err=%d", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "vdec_hevc init err=%d\n", ret); goto err; } @@ -249,7 +254,8 @@ static int vdec_hevc_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) init_completion(&inst->comp); - aml_vcodec_debug(inst, "hevc Instance >> %p", inst); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "hevc Instance >> %lx\n", (ulong) inst); ctx->ada_ctx = &inst->vdec; *h_vdec = (unsigned long)inst; @@ -396,8 +402,9 @@ static void fill_vdec_params(struct vdec_hevc_inst *inst, struct h265_SPS_t *sps inst->parms.ps.dpb_size = dec->dpb_sz; inst->parms.parms_status |= V4L2_CONFIG_PARM_DECODE_PSINFO; - pr_info("[%d] The stream infos, dw: %d, coded:(%d x %d), visible:(%d x %d), DPB: %d, margin: %d\n", - inst->ctx->id, dw, pic->coded_width, pic->coded_height, + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "The stream infos, dw: %d, coded:(%d x %d), visible:(%d x %d), DPB: %d, margin: %d\n", + dw, pic->coded_width, pic->coded_height, pic->visible_width, pic->visible_height, dec->dpb_sz - margin, margin); } @@ -409,7 +416,8 @@ static int stream_parse_by_ucode(struct vdec_hevc_inst *inst, u8 *buf, u32 size) ret = vdec_vframe_write(vdec, buf, size, 0); if (ret < 0) { - pr_err("write frame data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "write frame data failed. err: %d\n", ret); return ret; } @@ -431,7 +439,8 @@ static int stream_parse(struct vdec_hevc_inst *inst, u8 *buf, u32 size) ret = h265_decode_extradata_ps(buf, size, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "parse extra data failed. err: %d\n", ret); goto out; } @@ -479,8 +488,6 @@ static void vdec_hevc_deinit(unsigned long h_vdec) struct vdec_hevc_inst *inst = (struct vdec_hevc_inst *)h_vdec; struct aml_vcodec_ctx *ctx = inst->ctx; - aml_vcodec_debug_enter(inst); - video_decoder_release(&inst->vdec); vcodec_vfm_release(&inst->vfm); @@ -512,14 +519,16 @@ static void vdec_hevc_get_vf(struct vdec_hevc_inst *inst, struct vdec_v4l2_buffe vf = peek_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "there is no vframe."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "there is no vframe.\n"); *out = NULL; return; } vf = get_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "the vframe is avalid."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vframe is avalid.\n"); *out = NULL; return; } @@ -641,7 +650,8 @@ static int vdec_hevc_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs, parms->parms_status |= inst->parms.parms_status; - aml_vcodec_debug(inst, "parms status: %u", parms->parms_status); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "parms status: %u\n", parms->parms_status); } static int vdec_hevc_get_param(unsigned long h_vdec, @@ -651,7 +661,8 @@ static int vdec_hevc_get_param(unsigned long h_vdec, struct vdec_hevc_inst *inst = (struct vdec_hevc_inst *)h_vdec; if (!inst) { - pr_err("the hevc inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the hevc inst of dec is invalid.\n"); return -1; } @@ -680,7 +691,8 @@ static int vdec_hevc_get_param(unsigned long h_vdec, get_param_config_info(inst, out); break; default: - aml_vcodec_err(inst, "invalid get parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid get parameter type=%d\n", type); ret = -EINVAL; } @@ -724,7 +736,8 @@ static void set_param_ps_info(struct vdec_hevc_inst *inst, /*wake up*/ complete(&inst->comp); - pr_info("Parse from ucode, crop(%d x %d), coded(%d x %d) dpb: %d\n", + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Parse from ucode, crop(%d x %d), coded(%d x %d) dpb: %d\n", pic->visible_width, pic->visible_height, pic->coded_width, pic->coded_height, dec->dpb_sz); @@ -740,14 +753,16 @@ static void set_param_hdr_info(struct vdec_hevc_inst *inst, V4L2_CONFIG_PARM_DECODE_HDRINFO; aml_vdec_dispatch_event(inst->ctx, V4L2_EVENT_SRC_CH_HDRINFO); - pr_info("H265 set HDR infos\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "H265 set HDR infos\n"); } } static void set_param_post_event(struct vdec_hevc_inst *inst, u32 *event) { aml_vdec_dispatch_event(inst->ctx, *event); - pr_info("H265 post event: %d\n", *event); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "H265 post event: %d\n", *event); } static int vdec_hevc_set_param(unsigned long h_vdec, @@ -757,7 +772,8 @@ static int vdec_hevc_set_param(unsigned long h_vdec, struct vdec_hevc_inst *inst = (struct vdec_hevc_inst *)h_vdec; if (!inst) { - pr_err("the hevc inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the hevc inst of dec is invalid.\n"); return -1; } @@ -778,7 +794,8 @@ static int vdec_hevc_set_param(unsigned long h_vdec, set_param_post_event(inst, in); break; default: - aml_vcodec_err(inst, "invalid set parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid set parameter type=%d\n", type); ret = -EINVAL; } diff --git a/drivers/amvdec_ports/decoder/vdec_mjpeg_if.c b/drivers/amvdec_ports/decoder/vdec_mjpeg_if.c index 0db4eca..6a7a4d8 100644 --- a/drivers/amvdec_ports/decoder/vdec_mjpeg_if.c +++ b/drivers/amvdec_ports/decoder/vdec_mjpeg_if.c @@ -118,11 +118,14 @@ static void get_pic_info(struct vdec_mjpeg_inst *inst, { *pic = inst->vsi->pic; - aml_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)", - pic->visible_width, pic->visible_height, - pic->coded_width, pic->coded_height); - aml_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz, - pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "pic(%d, %d), buf(%d, %d)\n", + pic->visible_width, pic->visible_height, + pic->coded_width, pic->coded_height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Y(%d, %d), C(%d, %d)\n", + pic->y_bs_sz, pic->y_len_sz, + pic->c_bs_sz, pic->c_len_sz); } static void get_crop_info(struct vdec_mjpeg_inst *inst, struct v4l2_rect *cr) @@ -132,14 +135,16 @@ static void get_crop_info(struct vdec_mjpeg_inst *inst, struct v4l2_rect *cr) cr->width = inst->vsi->crop.width; cr->height = inst->vsi->crop.height; - aml_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d", - cr->left, cr->top, cr->width, cr->height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "l=%d, t=%d, w=%d, h=%d\n", + cr->left, cr->top, cr->width, cr->height); } static void get_dpb_size(struct vdec_mjpeg_inst *inst, unsigned int *dpb_sz) { *dpb_sz = 20;//inst->vsi->dec.dpb_sz; - aml_vcodec_debug(inst, "sz=%d", *dpb_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "sz=%d\n", *dpb_sz); } static int vdec_mjpeg_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) @@ -172,7 +177,8 @@ static int vdec_mjpeg_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) ret = video_decoder_init(&inst->vdec); if (ret) { - aml_vcodec_err(inst, "vdec_mjpeg init err=%d", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "vdec_mjpeg init err=%d\n", ret); goto error_free_inst; } @@ -199,7 +205,8 @@ static int vdec_mjpeg_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) inst->vsi->pic.c_bs_sz = 0; inst->vsi->pic.c_len_sz = (1920 * 1088 / 2); - aml_vcodec_debug(inst, "mjpeg Instance >> %p", inst); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "mjpeg Instance >> %lx\n", (ulong) inst); ctx->ada_ctx = &inst->vdec; *h_vdec = (unsigned long)inst; @@ -252,8 +259,9 @@ static void fill_vdec_params(struct vdec_mjpeg_inst *inst, /* calc DPB size */ dec->dpb_sz = 9;//refer_buffer_num(sps->level_idc, poc_cnt, mb_w, mb_h); - pr_info("[%d] The stream infos, coded:(%d x %d), visible:(%d x %d), DPB: %d\n", - inst->ctx->id, pic->coded_width, pic->coded_height, + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "The stream infos, coded:(%d x %d), visible:(%d x %d), DPB: %d\n", + pic->coded_width, pic->coded_height, pic->visible_width, pic->visible_height, dec->dpb_sz); } @@ -268,7 +276,8 @@ static int stream_parse(struct vdec_mjpeg_inst *inst, u8 *buf, u32 size) ret = mjpeg_decode_extradata_ps(buf, size, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "parse extra data failed. err: %d\n", ret); goto out; } @@ -311,8 +320,6 @@ static void vdec_mjpeg_deinit(unsigned long h_vdec) if (!inst) return; - aml_vcodec_debug_enter(inst); - video_decoder_release(&inst->vdec); vcodec_vfm_release(&inst->vfm); @@ -340,14 +347,16 @@ static void vdec_mjpeg_get_vf(struct vdec_mjpeg_inst *inst, struct vdec_v4l2_buf vf = peek_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "there is no vframe."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "there is no vframe.\n"); *out = NULL; return; } vf = get_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "the vframe is avalid."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vframe is avalid.\n"); *out = NULL; return; } @@ -418,7 +427,8 @@ static int vdec_mjpeg_get_param(unsigned long h_vdec, struct vdec_mjpeg_inst *inst = (struct vdec_mjpeg_inst *)h_vdec; if (!inst) { - pr_err("the mjpeg inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the mjpeg inst of dec is invalid.\n"); return -1; } @@ -444,7 +454,8 @@ static int vdec_mjpeg_get_param(unsigned long h_vdec, break; default: - aml_vcodec_err(inst, "invalid get parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid get parameter type=%d\n", type); ret = -EINVAL; } @@ -454,7 +465,7 @@ static int vdec_mjpeg_get_param(unsigned long h_vdec, static void set_param_ps_info(struct vdec_mjpeg_inst *inst, struct aml_vdec_ps_infos *ps) { - pr_info("---%s, %d\n", __func__, __LINE__); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "\n"); } static int vdec_mjpeg_set_param(unsigned long h_vdec, @@ -464,7 +475,8 @@ static int vdec_mjpeg_set_param(unsigned long h_vdec, struct vdec_mjpeg_inst *inst = (struct vdec_mjpeg_inst *)h_vdec; if (!inst) { - pr_err("the mjpeg inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the mjpeg inst of dec is invalid.\n"); return -1; } @@ -474,7 +486,8 @@ static int vdec_mjpeg_set_param(unsigned long h_vdec, break; default: - aml_vcodec_err(inst, "invalid set parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid set parameter type=%d\n", type); ret = -EINVAL; } diff --git a/drivers/amvdec_ports/decoder/vdec_mpeg12_if.c b/drivers/amvdec_ports/decoder/vdec_mpeg12_if.c index 5d5ca07..c35a80d 100644 --- a/drivers/amvdec_ports/decoder/vdec_mpeg12_if.c +++ b/drivers/amvdec_ports/decoder/vdec_mpeg12_if.c @@ -118,11 +118,14 @@ static void get_pic_info(struct vdec_mpeg12_inst *inst, { *pic = inst->vsi->pic; - aml_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)", - pic->visible_width, pic->visible_height, - pic->coded_width, pic->coded_height); - aml_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz, - pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "pic(%d, %d), buf(%d, %d)\n", + pic->visible_width, pic->visible_height, + pic->coded_width, pic->coded_height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Y(%d, %d), C(%d, %d)\n", + pic->y_bs_sz, pic->y_len_sz, + pic->c_bs_sz, pic->c_len_sz); } static void get_crop_info(struct vdec_mpeg12_inst *inst, struct v4l2_rect *cr) @@ -132,14 +135,15 @@ static void get_crop_info(struct vdec_mpeg12_inst *inst, struct v4l2_rect *cr) cr->width = inst->vsi->crop.width; cr->height = inst->vsi->crop.height; - aml_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d", - cr->left, cr->top, cr->width, cr->height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "l=%d, t=%d, w=%d, h=%d\n", + cr->left, cr->top, cr->width, cr->height); } static void get_dpb_size(struct vdec_mpeg12_inst *inst, unsigned int *dpb_sz) { *dpb_sz = inst->vsi->dec.dpb_sz; - aml_vcodec_debug(inst, "sz=%d", *dpb_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "sz=%d\n", *dpb_sz); } static int vdec_mpeg12_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) @@ -172,7 +176,8 @@ static int vdec_mpeg12_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) ret = video_decoder_init(&inst->vdec); if (ret) { - aml_vcodec_err(inst, "vdec_mpeg12 init err=%d", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "vdec_mpeg12 init err=%d\n", ret); goto error_free_inst; } @@ -199,7 +204,8 @@ static int vdec_mpeg12_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) inst->vsi->pic.c_bs_sz = 0; inst->vsi->pic.c_len_sz = (1920 * 1088 / 2); - aml_vcodec_debug(inst, "mpeg12 Instance >> %p", inst); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "mpeg12 Instance >> %lx\n", (ulong) inst); ctx->ada_ctx = &inst->vdec; *h_vdec = (unsigned long)inst; @@ -244,8 +250,9 @@ static void fill_vdec_params(struct vdec_mpeg12_inst *inst, /* calc DPB size */ dec->dpb_sz = 9;//refer_buffer_num(sps->level_idc, poc_cnt, mb_w, mb_h); - pr_info("[%d] The stream infos, coded:(%d x %d), visible:(%d x %d), DPB: %d\n", - inst->ctx->id, pic->coded_width, pic->coded_height, + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "The stream infos, coded:(%d x %d), visible:(%d x %d), DPB: %d\n", + pic->coded_width, pic->coded_height, pic->visible_width, pic->visible_height, dec->dpb_sz); } @@ -260,7 +267,8 @@ static int stream_parse(struct vdec_mpeg12_inst *inst, u8 *buf, u32 size) ret = mpeg12_decode_extradata_ps(buf, size, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "parse extra data failed. err: %d\n", ret); goto out; } @@ -303,8 +311,6 @@ static void vdec_mpeg12_deinit(unsigned long h_vdec) if (!inst) return; - aml_vcodec_debug_enter(inst); - video_decoder_release(&inst->vdec); vcodec_vfm_release(&inst->vfm); @@ -332,14 +338,16 @@ static void vdec_mpeg12_get_vf(struct vdec_mpeg12_inst *inst, struct vdec_v4l2_b vf = peek_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "there is no vframe."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "there is no vframe.\n"); *out = NULL; return; } vf = get_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "the vframe is avalid."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vframe is avalid.\n"); *out = NULL; return; } @@ -410,7 +418,8 @@ static int vdec_mpeg12_get_param(unsigned long h_vdec, struct vdec_mpeg12_inst *inst = (struct vdec_mpeg12_inst *)h_vdec; if (!inst) { - pr_err("the mpeg12 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the mpeg12 inst of dec is invalid.\n"); return -1; } @@ -436,7 +445,8 @@ static int vdec_mpeg12_get_param(unsigned long h_vdec, break; default: - aml_vcodec_err(inst, "invalid get parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid get parameter type=%d\n", type); ret = -EINVAL; } @@ -446,7 +456,7 @@ static int vdec_mpeg12_get_param(unsigned long h_vdec, static void set_param_ps_info(struct vdec_mpeg12_inst *inst, struct aml_vdec_ps_infos *ps) { - pr_info("---%s, %d\n", __func__, __LINE__); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "\n"); } static int vdec_mpeg12_set_param(unsigned long h_vdec, @@ -456,7 +466,8 @@ static int vdec_mpeg12_set_param(unsigned long h_vdec, struct vdec_mpeg12_inst *inst = (struct vdec_mpeg12_inst *)h_vdec; if (!inst) { - pr_err("the mpeg12 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the mpeg12 inst of dec is invalid.\n"); return -1; } @@ -466,7 +477,8 @@ static int vdec_mpeg12_set_param(unsigned long h_vdec, break; default: - aml_vcodec_err(inst, "invalid set parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid set parameter type=%d\n", type); ret = -EINVAL; } diff --git a/drivers/amvdec_ports/decoder/vdec_mpeg4_if.c b/drivers/amvdec_ports/decoder/vdec_mpeg4_if.c index ab428af..d031c0e 100644 --- a/drivers/amvdec_ports/decoder/vdec_mpeg4_if.c +++ b/drivers/amvdec_ports/decoder/vdec_mpeg4_if.c @@ -118,11 +118,14 @@ static void get_pic_info(struct vdec_mpeg4_inst *inst, { *pic = inst->vsi->pic; - aml_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)", - pic->visible_width, pic->visible_height, - pic->coded_width, pic->coded_height); - aml_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz, - pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "pic(%d, %d), buf(%d, %d)\n", + pic->visible_width, pic->visible_height, + pic->coded_width, pic->coded_height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Y(%d, %d), C(%d, %d)\n", + pic->y_bs_sz, pic->y_len_sz, + pic->c_bs_sz, pic->c_len_sz); } static void get_crop_info(struct vdec_mpeg4_inst *inst, struct v4l2_rect *cr) @@ -132,14 +135,15 @@ static void get_crop_info(struct vdec_mpeg4_inst *inst, struct v4l2_rect *cr) cr->width = inst->vsi->crop.width; cr->height = inst->vsi->crop.height; - aml_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d", - cr->left, cr->top, cr->width, cr->height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "l=%d, t=%d, w=%d, h=%d\n", + cr->left, cr->top, cr->width, cr->height); } static void get_dpb_size(struct vdec_mpeg4_inst *inst, unsigned int *dpb_sz) { *dpb_sz = 9;//inst->vsi->dec.dpb_sz; - aml_vcodec_debug(inst, "sz=%d", *dpb_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "sz=%d\n", *dpb_sz); } static int vdec_mpeg4_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) @@ -173,7 +177,8 @@ static int vdec_mpeg4_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) ret = video_decoder_init(&inst->vdec); if (ret) { - aml_vcodec_err(inst, "vdec_mpeg4 init err=%d", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "vdec_mpeg4 init err=%d\n", ret); goto error_free_inst; } @@ -200,7 +205,8 @@ static int vdec_mpeg4_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) inst->vsi->pic.c_bs_sz = 0; inst->vsi->pic.c_len_sz = (1920 * 1088 / 2); - aml_vcodec_debug(inst, "mpeg4 Instance >> %p", inst); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "mpeg4 Instance >> %lx\n", (ulong) inst); ctx->ada_ctx = &inst->vdec; *h_vdec = (unsigned long)inst; @@ -253,8 +259,9 @@ static void fill_vdec_params(struct vdec_mpeg4_inst *inst, /* calc DPB size */ dec->dpb_sz = 9;//refer_buffer_num(sps->level_idc, poc_cnt, mb_w, mb_h); - pr_info("[%d] The stream infos, coded:(%d x %d), visible:(%d x %d), DPB: %d\n", - inst->ctx->id, pic->coded_width, pic->coded_height, + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "The stream infos, coded:(%d x %d), visible:(%d x %d), DPB: %d\n", + pic->coded_width, pic->coded_height, pic->visible_width, pic->visible_height, dec->dpb_sz); } @@ -269,7 +276,8 @@ static int stream_parse(struct vdec_mpeg4_inst *inst, u8 *buf, u32 size) ret = mpeg4_decode_extradata_ps(buf, size, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "parse extra data failed. err: %d\n", ret); goto out; } @@ -312,8 +320,6 @@ static void vdec_mpeg4_deinit(unsigned long h_vdec) if (!inst) return; - aml_vcodec_debug_enter(inst); - video_decoder_release(&inst->vdec); vcodec_vfm_release(&inst->vfm); @@ -341,14 +347,16 @@ static void vdec_mpeg4_get_vf(struct vdec_mpeg4_inst *inst, struct vdec_v4l2_buf vf = peek_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "there is no vframe."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "there is no vframe.\n"); *out = NULL; return; } vf = get_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "the vframe is avalid."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vframe is avalid.\n"); *out = NULL; return; } @@ -419,7 +427,8 @@ static int vdec_mpeg4_get_param(unsigned long h_vdec, struct vdec_mpeg4_inst *inst = (struct vdec_mpeg4_inst *)h_vdec; if (!inst) { - pr_err("the mpeg4 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the mpeg4 inst of dec is invalid.\n"); return -1; } @@ -445,7 +454,8 @@ static int vdec_mpeg4_get_param(unsigned long h_vdec, break; default: - aml_vcodec_err(inst, "invalid get parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "invalid get parameter type=%d\n", type); ret = -EINVAL; } @@ -455,7 +465,7 @@ static int vdec_mpeg4_get_param(unsigned long h_vdec, static void set_param_ps_info(struct vdec_mpeg4_inst *inst, struct aml_vdec_ps_infos *ps) { - pr_info("---%s, %d\n", __func__, __LINE__); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "\n"); } static int vdec_mpeg4_set_param(unsigned long h_vdec, @@ -465,7 +475,8 @@ static int vdec_mpeg4_set_param(unsigned long h_vdec, struct vdec_mpeg4_inst *inst = (struct vdec_mpeg4_inst *)h_vdec; if (!inst) { - pr_err("the mpeg4 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the mpeg4 inst of dec is invalid.\n"); return -1; } @@ -475,7 +486,8 @@ static int vdec_mpeg4_set_param(unsigned long h_vdec, break; default: - aml_vcodec_err(inst, "invalid set parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid set parameter type=%d\n", type); ret = -EINVAL; } diff --git a/drivers/amvdec_ports/decoder/vdec_vp9_if.c b/drivers/amvdec_ports/decoder/vdec_vp9_if.c index 7d395ba..3952ae7 100644 --- a/drivers/amvdec_ports/decoder/vdec_vp9_if.c +++ b/drivers/amvdec_ports/decoder/vdec_vp9_if.c @@ -136,11 +136,14 @@ static void get_pic_info(struct vdec_vp9_inst *inst, { *pic = inst->vsi->pic; - aml_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)", - pic->visible_width, pic->visible_height, - pic->coded_width, pic->coded_height); - aml_vcodec_debug(inst, "Y(%d, %d), C(%d, %d)", pic->y_bs_sz, - pic->y_len_sz, pic->c_bs_sz, pic->c_len_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "pic(%d, %d), buf(%d, %d)\n", + pic->visible_width, pic->visible_height, + pic->coded_width, pic->coded_height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Y(%d, %d), C(%d, %d)\n", + pic->y_bs_sz, pic->y_len_sz, + pic->c_bs_sz, pic->c_len_sz); } static void get_crop_info(struct vdec_vp9_inst *inst, struct v4l2_rect *cr) @@ -150,14 +153,15 @@ static void get_crop_info(struct vdec_vp9_inst *inst, struct v4l2_rect *cr) cr->width = inst->vsi->crop.width; cr->height = inst->vsi->crop.height; - aml_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d", - cr->left, cr->top, cr->width, cr->height); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "l=%d, t=%d, w=%d, h=%d\n", + cr->left, cr->top, cr->width, cr->height); } static void get_dpb_size(struct vdec_vp9_inst *inst, unsigned int *dpb_sz) { *dpb_sz = inst->vsi->dec.dpb_sz; - aml_vcodec_debug(inst, "sz=%d", *dpb_sz); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, "sz=%d\n", *dpb_sz); } static u32 vdec_config_default_parms(u8 *parm) @@ -277,7 +281,8 @@ static int vdec_vp9_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) inst->vfm.ada_ctx = &inst->vdec; ret = vcodec_vfm_init(&inst->vfm); if (ret) { - pr_err("%s, init vfm failed.\n", __func__); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "init vfm failed.\n"); goto err; } @@ -297,7 +302,8 @@ static int vdec_vp9_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) init_completion(&inst->comp); - aml_vcodec_debug(inst, "vp9 Instance >> %p", inst); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "vp9 Instance >> %lx\n", (ulong) inst); ctx->ada_ctx = &inst->vdec; *h_vdec = (unsigned long)inst; @@ -305,7 +311,8 @@ static int vdec_vp9_init(struct aml_vcodec_ctx *ctx, unsigned long *h_vdec) /* init decoder. */ ret = video_decoder_init(&inst->vdec); if (ret) { - aml_vcodec_err(inst, "vdec_vp9 init err=%d", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "vdec_vp9 init err=%d\n", ret); goto err; } @@ -425,8 +432,9 @@ static void fill_vdec_params(struct vdec_vp9_inst *inst, inst->parms.ps.dpb_size = dec->dpb_sz; inst->parms.parms_status |= V4L2_CONFIG_PARM_DECODE_PSINFO; - aml_vcodec_debug(inst, "[%d] The stream infos, dw: %d, coded:(%d x %d), visible:(%d x %d), DPB: %d, margin: %d\n", - inst->ctx->id, dw, pic->coded_width, pic->coded_height, + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "The stream infos, dw: %d, coded:(%d x %d), visible:(%d x %d), DPB: %d, margin: %d\n", + dw, pic->coded_width, pic->coded_height, pic->visible_width, pic->visible_height, dec->dpb_sz - margin, margin); } @@ -437,7 +445,8 @@ static int stream_parse_by_ucode(struct vdec_vp9_inst *inst, u8 *buf, u32 size) ret = vdec_write_nalu(inst, buf, size, 0); if (ret < 0) { - pr_err("write frame data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "write frame data failed. err: %d\n", ret); return ret; } @@ -459,7 +468,8 @@ static int stream_parse(struct vdec_vp9_inst *inst, u8 *buf, u32 size) ret = vp9_decode_extradata_ps(buf, size, ps); if (ret) { - pr_err("parse extra data failed. err: %d\n", ret); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "parse extra data failed. err: %d\n", ret); goto out; } @@ -507,8 +517,6 @@ static void vdec_vp9_deinit(unsigned long h_vdec) struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec; struct aml_vcodec_ctx *ctx = inst->ctx; - aml_vcodec_debug_enter(inst); - video_decoder_release(&inst->vdec); vcodec_vfm_release(&inst->vfm); @@ -543,14 +551,16 @@ static void vdec_vp9_get_vf(struct vdec_vp9_inst *inst, struct vdec_v4l2_buffer vf = peek_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "there is no vframe."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "there is no vframe.\n"); *out = NULL; return; } vf = get_video_frame(&inst->vfm); if (!vf) { - aml_vcodec_debug(inst, "the vframe is avalid."); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vframe is avalid.\n"); *out = NULL; return; } @@ -581,7 +591,8 @@ static void add_prefix_data(struct vp9_superframe_split *s, length = s->size + s->nb_frames * PREFIX_SIZE; p = vzalloc(length); if (!p) { - pr_err("alloc size %d failed.\n" ,length); + v4l_dbg(0, V4L_DEBUG_CODEC_ERROR, + "alloc size %d failed.\n" ,length); return; } @@ -631,7 +642,8 @@ static void trigger_decoder(struct aml_vdec_adapt *vdec) frame_size = vp9_trigger_framesize[i]; ret = vdec_vframe_write(vdec, p, frame_size, 0); - pr_err("write trigger frame %d\n", ret); + v4l_dbg(vdec->ctx, V4L_DEBUG_CODEC_ERROR, + "write trigger frame %d\n", ret); p += frame_size; } } @@ -660,7 +672,8 @@ static int vdec_write_nalu(struct vdec_vp9_inst *inst, s.data_size = size; ret = vp9_superframe_split_filter(&s); if (ret) { - pr_err("parse frames failed.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "parse frames failed.\n"); return ret; } @@ -754,7 +767,8 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct aml_vcodec_mem *bs, parms->parms_status |= inst->parms.parms_status; - aml_vcodec_debug(inst, "parms status: %u", parms->parms_status); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "parms status: %u\n", parms->parms_status); } static int vdec_vp9_get_param(unsigned long h_vdec, @@ -764,7 +778,8 @@ static int vdec_vp9_get_param(unsigned long h_vdec, struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec; if (!inst) { - pr_err("the vp9 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vp9 inst of dec is invalid.\n"); return -1; } @@ -793,7 +808,8 @@ static int vdec_vp9_get_param(unsigned long h_vdec, get_param_config_info(inst, out); break; default: - aml_vcodec_err(inst, "invalid get parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid get parameter type=%d\n", type); ret = -EINVAL; } @@ -839,7 +855,8 @@ static void set_param_ps_info(struct vdec_vp9_inst *inst, /*wake up*/ complete(&inst->comp); - pr_info("Parse from ucode, crop(%d x %d), coded(%d x %d) dpb: %d\n", + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "Parse from ucode, crop(%d x %d), coded(%d x %d) dpb: %d\n", ps->visible_width, ps->visible_height, ps->coded_width, ps->coded_height, ps->dpb_size); @@ -855,14 +872,16 @@ static void set_param_hdr_info(struct vdec_vp9_inst *inst, V4L2_CONFIG_PARM_DECODE_HDRINFO; aml_vdec_dispatch_event(inst->ctx, V4L2_EVENT_SRC_CH_HDRINFO); - pr_info("VP9 set HDR infos\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "VP9 set HDR infos\n"); } } static void set_param_post_event(struct vdec_vp9_inst *inst, u32 *event) { aml_vdec_dispatch_event(inst->ctx, *event); - pr_info("VP9 post event: %d\n", *event); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_PRINFO, + "VP9 post event: %d\n", *event); } static int vdec_vp9_set_param(unsigned long h_vdec, @@ -872,7 +891,8 @@ static int vdec_vp9_set_param(unsigned long h_vdec, struct vdec_vp9_inst *inst = (struct vdec_vp9_inst *)h_vdec; if (!inst) { - pr_err("the vp9 inst of dec is invalid.\n"); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "the vp9 inst of dec is invalid.\n"); return -1; } @@ -893,7 +913,8 @@ static int vdec_vp9_set_param(unsigned long h_vdec, set_param_post_event(inst, in); break; default: - aml_vcodec_err(inst, "invalid set parameter type=%d", type); + v4l_dbg(inst->ctx, V4L_DEBUG_CODEC_ERROR, + "invalid set parameter type=%d\n", type); ret = -EINVAL; } diff --git a/drivers/amvdec_ports/vdec_drv_if.c b/drivers/amvdec_ports/vdec_drv_if.c index 4b70ed0..96b0c93 100644 --- a/drivers/amvdec_ports/vdec_drv_if.c +++ b/drivers/amvdec_ports/vdec_drv_if.c @@ -24,7 +24,6 @@ #include "vdec_drv_if.h" #include "aml_vcodec_dec.h" #include "vdec_drv_base.h" -#include "aml_vcodec_dec_pm.h" const struct vdec_common_if *get_h264_dec_comm_if(void); const struct vdec_common_if *get_hevc_dec_comm_if(void); @@ -84,7 +83,8 @@ int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs, if (bs) { if ((bs->dma_addr & 63) != 0) { - aml_v4l2_err("bs dma_addr should 64 byte align"); + v4l_dbg(ctx, V4L_DEBUG_CODEC_ERROR, + "bs dma_addr should 64 byte align\n"); return -EINVAL; } } |