116 files changed, 25845 insertions, 36303 deletions
diff --git a/drivers/amvdec_ports/aml_vcodec_dec_drv.c b/drivers/amvdec_ports/aml_vcodec_dec_drv.c index 43ff0c5..7758ca8 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> @@ -49,8 +48,8 @@ #define V4LVIDEO_IOCTL_SET_CONFIG_PARAMS _IOWR(V4LVIDEO_IOC_MAGIC, 0x04, struct v4l2_config_parm) #define V4LVIDEO_IOCTL_GET_CONFIG_PARAMS _IOWR(V4LVIDEO_IOC_MAGIC, 0x05, struct v4l2_config_parm) -bool scatter_mem_enable; -bool param_sets_from_ucode; +bool param_sets_from_ucode = 1; +bool enable_drm_mode; static int fops_vcodec_open(struct file *file) { @@ -83,41 +82,49 @@ static int fops_vcodec_open(struct file *file) mutex_init(&ctx->state_lock); mutex_init(&ctx->lock); spin_lock_init(&ctx->slock); - init_waitqueue_head(&ctx->wq); init_completion(&ctx->comp); - ctx->scatter_mem_enable = scatter_mem_enable ? 1 : 0; ctx->param_sets_from_ucode = param_sets_from_ucode ? 1 : 0; + if (enable_drm_mode) { + ctx->is_drm_mode = true; + ctx->param_sets_from_ucode = true; + } + 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, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + ctx->output_thread_ready = true; ctx->empty_flush_buf->vb.vb2_buf.vb2_queue = src_vq; ctx->empty_flush_buf->lastframe = true; aml_vcodec_dec_set_default_params(ctx); 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\n", ctx->id, dev_name(&dev->plat_dev->dev)); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "%s decoder %lx\n", + dev_name(&dev->plat_dev->dev), (ulong)ctx); return ret; @@ -141,7 +148,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\n", ctx->id); + v4l_dbg(ctx, V4L_DEBUG_CODEC_PRINFO, "release decoder %lx\n", (ulong) ctx); mutex_lock(&dev->dev_mutex); /* @@ -168,8 +175,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: 0x%p, data: %p", - __func__, file, 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 +194,29 @@ 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 %p", __func__, file_fd, file); + 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); *fd = file_fd; @@ -226,20 +237,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; } @@ -251,14 +265,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; } @@ -278,20 +294,25 @@ 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) + if (data) { vf_handle = &data->vf; + v4l_dbg(0, V4L_DEBUG_CODEC_BUFMGR, "file: %lx, data: %lx\n", + (ulong) file, (ulong) data); + } fput(file); @@ -315,8 +336,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: @@ -327,8 +349,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: @@ -341,7 +364,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; @@ -356,7 +380,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; @@ -412,7 +437,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; } @@ -420,7 +446,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; } @@ -442,7 +469,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; } @@ -451,7 +479,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; } @@ -460,11 +489,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; @@ -553,8 +584,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); @@ -580,12 +612,16 @@ bool multiplanar; EXPORT_SYMBOL(multiplanar); module_param(multiplanar, bool, 0644); -EXPORT_SYMBOL(scatter_mem_enable); -module_param(scatter_mem_enable, bool, 0644); +bool dump_capture_frame; +EXPORT_SYMBOL(dump_capture_frame); +module_param(dump_capture_frame, bool, 0644); EXPORT_SYMBOL(param_sets_from_ucode); module_param(param_sets_from_ucode, bool, 0644); +EXPORT_SYMBOL(enable_drm_mode); +module_param(enable_drm_mode, bool, 0644); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("AML video codec V4L2 decoder driver"); |