Commit 41f03c67 authored by Yunfei Dong's avatar Yunfei Dong Committed by Mauro Carvalho Chehab
Browse files

media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message



Adding different macro mtk_v4l2_vdec_dbg and mtk_v4l2_venc_dbg for
encoder and decoder. Then calling the common macro mtk_v4l2_debug to
print debug message.

Replace pr_err with dev_err for 'mtk_v4l2_err' debug message.
Replace pr_debug with dev_dbg for 'mtk_v4l2_debug' debug message.

Signed-off-by: default avatarYunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 0db2fc4e
Loading
Loading
Loading
Loading
+55 −61
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ static int vidioc_decoder_cmd(struct file *file, void *priv,
	if (ret)
		return ret;

	mtk_v4l2_debug(1, "decoder cmd=%u", cmd->cmd);
	mtk_v4l2_vdec_dbg(1, ctx, "decoder cmd=%u", cmd->cmd);
	dst_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
				V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
	switch (cmd->cmd) {
@@ -90,11 +90,11 @@ 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)) {
			mtk_v4l2_debug(1, "Output stream is off. No need to flush.");
			mtk_v4l2_vdec_dbg(1, ctx, "Output stream is off. No need to flush.");
			return 0;
		}
		if (!vb2_is_streaming(dst_vq)) {
			mtk_v4l2_debug(1, "Capture stream is off. No need to flush.");
			mtk_v4l2_vdec_dbg(1, ctx, "Capture stream is off. No need to flush.");
			return 0;
		}
		v4l2_m2m_buf_queue(ctx->m2m_ctx, &ctx->empty_flush_buf.vb);
@@ -172,8 +172,7 @@ static int vidioc_vdec_qbuf(struct file *file, void *priv,
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);

	if (ctx->state == MTK_STATE_ABORT) {
		mtk_v4l2_err("[%d] Call on QBUF after unrecoverable error",
				ctx->id);
		mtk_v4l2_vdec_err(ctx, "[%d] Call on QBUF after unrecoverable error", ctx->id);
		return -EIO;
	}

@@ -186,8 +185,7 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv,
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);

	if (ctx->state == MTK_STATE_ABORT) {
		mtk_v4l2_err("[%d] Call on DQBUF after unrecoverable error",
				ctx->id);
		mtk_v4l2_vdec_err(ctx, "[%d] Call on DQBUF after unrecoverable error", ctx->id);
		return -EIO;
	}

@@ -288,10 +286,9 @@ static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx, struct v4l2_format *f,
		    (pix_fmt_mp->height + 64) <= frmsize->max_height)
			pix_fmt_mp->height += 64;

		mtk_v4l2_debug(0,
			"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,
		mtk_v4l2_vdec_dbg(0, ctx,
				  "before resize wxh=%dx%d, after resize wxh=%dx%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;
@@ -344,7 +341,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
	}

	if (pix_fmt_mp->plane_fmt[0].sizeimage == 0) {
		mtk_v4l2_err("sizeimage of output format must be given");
		mtk_v4l2_vdec_err(ctx, "sizeimage of output format must be given");
		return -EINVAL;
	}

@@ -432,7 +429,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
	const struct mtk_video_fmt *fmt;
	const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;

	mtk_v4l2_debug(3, "[%d]", ctx->id);
	mtk_v4l2_vdec_dbg(3, ctx, "[%d]", ctx->id);

	q_data = mtk_vdec_get_q_data(ctx, f->type);
	if (!q_data)
@@ -446,7 +443,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
	if (!dec_pdata->uses_stateless_api &&
	    f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
	    vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) {
		mtk_v4l2_err("out_q_ctx buffers already requested");
		mtk_v4l2_vdec_err(ctx, "out_q_ctx buffers already requested");
		ret = -EBUSY;
	}

@@ -456,7 +453,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
	 */
	if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
	    vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) {
		mtk_v4l2_err("cap_q_ctx buffers already requested");
		mtk_v4l2_vdec_err(ctx, "cap_q_ctx buffers already requested");
		ret = -EBUSY;
	}

@@ -491,7 +488,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
		if (ctx->state == MTK_STATE_FREE) {
			ret = vdec_if_init(ctx, q_data->fmt->fourcc);
			if (ret) {
				mtk_v4l2_err("[%d]: vdec_if_init() fail ret=%d",
				mtk_v4l2_vdec_err(ctx, "[%d]: vdec_if_init() fail ret=%d",
						  ctx->id, ret);
				return -EINVAL;
			}
@@ -515,7 +512,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
		 */
		ret = vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo);
		if (ret) {
			mtk_v4l2_err("[%d]Error!! Get GET_PARAM_PICTURE_INFO Fail",
			mtk_v4l2_vdec_err(ctx, "[%d]Error!! Get GET_PARAM_PICTURE_INFO Fail",
					  ctx->id);
		}

@@ -540,8 +537,10 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,

		ctx->q_data[MTK_Q_DATA_DST].coded_width = ctx->picinfo.buf_w;
		ctx->q_data[MTK_Q_DATA_DST].coded_height = ctx->picinfo.buf_h;
		mtk_v4l2_debug(2, "[%d] vdec_if_init() num_plane = %d wxh=%dx%d pic wxh=%dx%d sz[0]=0x%x sz[1]=0x%x",
			       ctx->id, pix_mp->num_planes, ctx->picinfo.buf_w, ctx->picinfo.buf_h,
		mtk_v4l2_vdec_dbg(2, ctx,
				  "[%d] init() plane:%d wxh=%dx%d pic wxh=%dx%d sz=0x%x_0x%x",
				  ctx->id, pix_mp->num_planes,
				  ctx->picinfo.buf_w, ctx->picinfo.buf_h,
				  ctx->picinfo.pic_w, ctx->picinfo.pic_h,
				  ctx->q_data[MTK_Q_DATA_DST].sizeimage[0],
				  ctx->q_data[MTK_Q_DATA_DST].sizeimage[1]);
@@ -570,13 +569,10 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
		fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
		fsize->stepwise = dec_pdata->vdec_formats[i].frmsize;

		mtk_v4l2_debug(1, "%x, %d %d %d %d %d %d",
				ctx->dev->dec_capability,
				fsize->stepwise.min_width,
				fsize->stepwise.max_width,
				fsize->stepwise.step_width,
				fsize->stepwise.min_height,
				fsize->stepwise.max_height,
		mtk_v4l2_vdec_dbg(1, ctx, "%x, %d %d %d %d %d %d",
				  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;
@@ -641,7 +637,7 @@ static int vidioc_vdec_g_fmt(struct file *file, void *priv,

	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
	if (!vq) {
		mtk_v4l2_err("no vb2 queue for type=%d", f->type);
		mtk_v4l2_vdec_err(ctx, "no vb2 queue for type=%d", f->type);
		return -EINVAL;
	}

@@ -712,7 +708,7 @@ 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];

		mtk_v4l2_debug(1, "[%d] type=%d state=%d Format information could not be read, not ready yet!",
		mtk_v4l2_vdec_dbg(1, ctx, "[%d] type=%d state=%d Format information not ready!",
				  ctx->id, f->type, ctx->state);
	}

@@ -730,7 +726,7 @@ int vb2ops_vdec_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
	q_data = mtk_vdec_get_q_data(ctx, vq->type);

	if (q_data == NULL) {
		mtk_v4l2_err("vq->type=%d err\n", vq->type);
		mtk_v4l2_vdec_err(ctx, "vq->type=%d err\n", vq->type);
		return -EINVAL;
	}

@@ -756,10 +752,9 @@ int vb2ops_vdec_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
			sizes[i] = q_data->sizeimage[i];
	}

	mtk_v4l2_debug(1,
	mtk_v4l2_vdec_dbg(1, ctx,
			  "[%d]\t type = %d, get %d plane(s), %d buffer(s) of size 0x%x 0x%x ",
			ctx->id, vq->type, *nplanes, *nbuffers,
			sizes[0], sizes[1]);
			  ctx->id, vq->type, *nplanes, *nbuffers, sizes[0], sizes[1]);

	return 0;
}
@@ -770,16 +765,15 @@ int vb2ops_vdec_buf_prepare(struct vb2_buffer *vb)
	struct mtk_q_data *q_data;
	int i;

	mtk_v4l2_debug(3, "[%d] (%d) id=%d",
	mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d",
			  ctx->id, vb->vb2_queue->type, vb->index);

	q_data = mtk_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]) {
			mtk_v4l2_err("data will not fit into plane %d (%lu < %d)",
				i, vb2_plane_size(vb, i),
				q_data->sizeimage[i]);
			mtk_v4l2_vdec_err(ctx, "data will not fit into plane %d (%lu < %d)",
					  i, vb2_plane_size(vb, i), q_data->sizeimage[i]);
			return -EINVAL;
		}
		if (!V4L2_TYPE_IS_OUTPUT(vb->type))
@@ -807,7 +801,7 @@ void vb2ops_vdec_buf_finish(struct vb2_buffer *vb)
	mutex_unlock(&ctx->lock);

	if (buf_error) {
		mtk_v4l2_err("Unrecoverable error on buffer.");
		mtk_v4l2_vdec_err(ctx, "Unrecoverable error on buffer.");
		ctx->state = MTK_STATE_ABORT;
	}
}
@@ -843,7 +837,7 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
	struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
	int ret;

	mtk_v4l2_debug(3, "[%d] (%d) state=(%x) ctx->decoded_frame_cnt=%d",
	mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) state=(%x) ctx->decoded_frame_cnt=%d",
			  ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt);

	if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
@@ -870,7 +864,7 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
		 */
		ctx->picinfo = ctx->last_decoded_picinfo;

		mtk_v4l2_debug(2,
		mtk_v4l2_vdec_dbg(2, ctx,
				  "[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)",
				  ctx->id, ctx->last_decoded_picinfo.pic_w,
				  ctx->last_decoded_picinfo.pic_h,
@@ -880,7 +874,7 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q)

		ret = ctx->dev->vdec_pdata->flush_decoder(ctx);
		if (ret)
			mtk_v4l2_err("DecodeFinal failed, ret=%d", ret);
			mtk_v4l2_vdec_err(ctx, "DecodeFinal failed, ret=%d", ret);
	}
	ctx->state = MTK_STATE_FLUSH;

@@ -905,7 +899,7 @@ static int m2mops_vdec_job_ready(void *m2m_priv)
{
	struct mtk_vcodec_ctx *ctx = m2m_priv;

	mtk_v4l2_debug(3, "[%d]", ctx->id);
	mtk_v4l2_vdec_dbg(3, ctx, "[%d]", ctx->id);

	if (ctx->state == MTK_STATE_ABORT)
		return 0;
@@ -973,7 +967,7 @@ int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,
	struct mtk_vcodec_ctx *ctx = priv;
	int ret = 0;

	mtk_v4l2_debug(3, "[%d]", ctx->id);
	mtk_v4l2_vdec_dbg(3, ctx, "[%d]", ctx->id);

	src_vq->type		= V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
	src_vq->io_modes	= VB2_DMABUF | VB2_MMAP;
@@ -988,7 +982,7 @@ int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,

	ret = vb2_queue_init(src_vq);
	if (ret) {
		mtk_v4l2_err("Failed to initialize videobuf2 queue(output)");
		mtk_v4l2_vdec_err(ctx, "Failed to initialize videobuf2 queue(output)");
		return ret;
	}
	dst_vq->type		= V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
@@ -1004,7 +998,7 @@ int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,

	ret = vb2_queue_init(dst_vq);
	if (ret)
		mtk_v4l2_err("Failed to initialize videobuf2 queue(capture)");
		mtk_v4l2_vdec_err(ctx, "Failed to initialize videobuf2 queue(capture)");

	return ret;
}
+25 −29
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
#include "mtk_vcodec_util.h"
#include "mtk_vcodec_fw.h"

static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev)
static int mtk_vcodec_get_hw_count(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_dev *dev)
{
	switch (dev->vdec_pdata->hw_arch) {
	case MTK_VDEC_PURE_SINGLE_CORE:
@@ -37,7 +37,7 @@ static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev)
	case MTK_VDEC_LAT_SINGLE_CORE:
		return MTK_VDEC_ONE_LAT_ONE_CORE;
	default:
		mtk_v4l2_err("hw arch %d not supported", dev->vdec_pdata->hw_arch);
		mtk_v4l2_vdec_err(ctx, "hw arch %d not supported", dev->vdec_pdata->hw_arch);
		return MTK_VDEC_NO_HW;
	}
}
@@ -65,7 +65,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
	ctx = mtk_vcodec_get_curr_ctx(dev, MTK_VDEC_CORE);

	if (!mtk_vcodec_is_hw_active(dev)) {
		mtk_v4l2_err("DEC ISR, VDEC active is not 0x0");
		mtk_v4l2_vdec_err(ctx, "DEC ISR, VDEC active is not 0x0");
		return IRQ_HANDLED;
	}

@@ -83,9 +83,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)

	wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, 0);

	mtk_v4l2_debug(3,
			"mtk_vcodec_dec_irq_handler :wake up ctx %d, dec_done_status=%x",
			ctx->id, dec_done_status);
	mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=%x", ctx->id, dec_done_status);

	return IRQ_HANDLED;
}
@@ -140,7 +138,7 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
			if (IS_ERR(dev->reg_base[i]))
				return PTR_ERR(dev->reg_base[i]);

			mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
			dev_dbg(&pdev->dev, "reg[%d] base=%p", i, dev->reg_base[i]);
		}
	} else {
		for (i = 0; i < reg_num; i++) {
@@ -148,7 +146,7 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
			if (IS_ERR(dev->reg_base[i+1]))
				return PTR_ERR(dev->reg_base[i+1]);

			mtk_v4l2_debug(2, "reg[%d] base=%p", i+1, dev->reg_base[i+1]);
			dev_dbg(&pdev->dev, "reg[%d] base=%p", i + 1, dev->reg_base[i + 1]);
		}

		dev->vdecsys_regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
@@ -216,7 +214,7 @@ static int fops_vcodec_open(struct file *file)
	INIT_LIST_HEAD(&ctx->list);
	ctx->dev = dev;
	if (ctx->dev->vdec_pdata->is_subdev_supported) {
		hw_count = mtk_vcodec_get_hw_count(dev);
		hw_count = mtk_vcodec_get_hw_count(ctx, dev);
		if (!hw_count || !dev->subdev_prob_done) {
			ret = -EINVAL;
			goto err_ctrls_setup;
@@ -236,15 +234,14 @@ static int fops_vcodec_open(struct file *file)
	ctx->type = MTK_INST_DECODER;
	ret = dev->vdec_pdata->ctrls_setup(ctx);
	if (ret) {
		mtk_v4l2_err("Failed to setup mt vcodec controls");
		mtk_v4l2_vdec_err(ctx, "Failed to setup mt vcodec controls");
		goto err_ctrls_setup;
	}
	ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_dec, ctx,
		&mtk_vcodec_dec_queue_init);
	if (IS_ERR((__force void *)ctx->m2m_ctx)) {
		ret = PTR_ERR((__force void *)ctx->m2m_ctx);
		mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)",
			ret);
		mtk_v4l2_vdec_err(ctx, "Failed to v4l2_m2m_ctx_init() (%d)", ret);
		goto err_m2m_ctx_init;
	}
	src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
@@ -262,14 +259,14 @@ static int fops_vcodec_open(struct file *file)
			 * Return 0 if downloading firmware successfully,
			 * otherwise it is failed
			 */
			mtk_v4l2_err("failed to load firmware!");
			mtk_v4l2_vdec_err(ctx, "failed to load firmware!");
			goto err_load_fw;
		}

		dev->dec_capability =
			mtk_vcodec_fw_get_vdec_capa(dev->fw_handler);

		mtk_v4l2_debug(0, "decoder capability %x", dev->dec_capability);
		mtk_v4l2_vdec_dbg(0, ctx, "decoder capability %x", dev->dec_capability);
	}

	ctx->dev->vdec_pdata->init_vdec_params(ctx);
@@ -278,8 +275,7 @@ static int fops_vcodec_open(struct file *file)
	mtk_vcodec_dbgfs_create(ctx);

	mutex_unlock(&dev->dev_mutex);
	mtk_v4l2_debug(0, "%s decoder [%d]", dev_name(&dev->plat_dev->dev),
			ctx->id);
	mtk_v4l2_vdec_dbg(0, ctx, "%s decoder [%d]", dev_name(&dev->plat_dev->dev), ctx->id);
	return ret;

	/* Deinit when failure occurred */
@@ -301,7 +297,7 @@ static int fops_vcodec_release(struct file *file)
	struct mtk_vcodec_dev *dev = video_drvdata(file);
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);

	mtk_v4l2_debug(0, "[%d] decoder", ctx->id);
	mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id);
	mutex_lock(&dev->dev_mutex);

	/*
@@ -356,7 +352,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
					 &rproc_phandle)) {
		fw_type = SCP;
	} else {
		mtk_v4l2_err("Could not get vdec IPI device");
		dev_dbg(&pdev->dev, "Could not get vdec IPI device");
		return -ENODEV;
	}
	dma_set_max_seg_size(&pdev->dev, UINT_MAX);
@@ -376,7 +372,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
			alloc_ordered_workqueue("core-decoder",
						WQ_MEM_RECLAIM | WQ_FREEZABLE);
		if (!dev->core_workqueue) {
			mtk_v4l2_err("Failed to create core workqueue");
			dev_dbg(&pdev->dev, "Failed to create core workqueue");
			ret = -EINVAL;
			goto err_res;
		}
@@ -392,13 +388,13 @@ static int mtk_vcodec_probe(struct platform_device *pdev)

	ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
	if (ret) {
		mtk_v4l2_err("v4l2_device_register err=%d", ret);
		dev_err(&pdev->dev, "v4l2_device_register err=%d", ret);
		goto err_core_workq;
	}

	vfd_dec = video_device_alloc();
	if (!vfd_dec) {
		mtk_v4l2_err("Failed to allocate video device");
		dev_err(&pdev->dev, "Failed to allocate video device");
		ret = -ENOMEM;
		goto err_dec_alloc;
	}
@@ -419,7 +415,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)

	dev->m2m_dev_dec = v4l2_m2m_init(&mtk_vdec_m2m_ops);
	if (IS_ERR((__force void *)dev->m2m_dev_dec)) {
		mtk_v4l2_err("Failed to init mem2mem dec device");
		dev_err(&pdev->dev, "Failed to init mem2mem dec device");
		ret = PTR_ERR((__force void *)dev->m2m_dev_dec);
		goto err_dec_alloc;
	}
@@ -428,7 +424,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
		alloc_ordered_workqueue(MTK_VCODEC_DEC_NAME,
			WQ_MEM_RECLAIM | WQ_FREEZABLE);
	if (!dev->decode_workqueue) {
		mtk_v4l2_err("Failed to create decode workqueue");
		dev_err(&pdev->dev, "Failed to create decode workqueue");
		ret = -EINVAL;
		goto err_event_workq;
	}
@@ -437,7 +433,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
		ret = of_platform_populate(pdev->dev.of_node, NULL, NULL,
					   &pdev->dev);
		if (ret) {
			mtk_v4l2_err("Main device of_platform_populate failed.");
			dev_err(&pdev->dev, "Main device of_platform_populate failed.");
			goto err_reg_cont;
		}
	} else {
@@ -450,7 +446,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)

	ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, -1);
	if (ret) {
		mtk_v4l2_err("Failed to register video device");
		dev_err(&pdev->dev, "Failed to register video device");
		goto err_reg_cont;
	}

@@ -469,21 +465,21 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
		ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec, dev->vfd_dec,
							 MEDIA_ENT_F_PROC_VIDEO_DECODER);
		if (ret) {
			mtk_v4l2_err("Failed to register media controller");
			dev_err(&pdev->dev, "Failed to register media controller");
			goto err_dec_mem_init;
		}

		ret = media_device_register(&dev->mdev_dec);
		if (ret) {
			mtk_v4l2_err("Failed to register media device");
			dev_err(&pdev->dev, "Failed to register media device");
			goto err_media_reg;
		}

		mtk_v4l2_debug(0, "media registered as /dev/media%d", vfd_dec->minor);
		dev_dbg(&pdev->dev, "media registered as /dev/media%d", vfd_dec->minor);
	}

	mtk_vcodec_dbgfs_init(dev, false);
	mtk_v4l2_debug(0, "decoder registered as /dev/video%d", vfd_dec->minor);
	dev_dbg(&pdev->dev, "decoder registered as /dev/video%d", vfd_dec->minor);

	return 0;

+3 −4
Original line number Diff line number Diff line
@@ -77,8 +77,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv)
	/* check if HW active or not */
	cg_status = readl(dev->reg_base[VDEC_HW_SYS] + VDEC_HW_ACTIVE_ADDR);
	if (cg_status & VDEC_HW_ACTIVE_MASK) {
		mtk_v4l2_err("vdec active is not 0x0 (0x%08x)",
			     cg_status);
		mtk_v4l2_vdec_err(ctx, "vdec active is not 0x0 (0x%08x)", cg_status);
		return IRQ_HANDLED;
	}

@@ -93,7 +92,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void *priv)

	wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx);

	mtk_v4l2_debug(3, "wake up ctx %d, dec_done_status=%x",
	mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=%x",
			  ctx->id, dec_done_status);

	return IRQ_HANDLED;
+9 −10
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
		if (!dec_clk->clk_info)
			return -ENOMEM;
	} else {
		mtk_v4l2_err("Failed to get vdec clock count");
		dev_err(&pdev->dev, "Failed to get vdec clock count");
		return -EINVAL;
	}

@@ -40,14 +40,13 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
		ret = of_property_read_string_index(pdev->dev.of_node,
			"clock-names", i, &clk_info->clk_name);
		if (ret) {
			mtk_v4l2_err("Failed to get clock name id = %d", i);
			dev_err(&pdev->dev, "Failed to get clock name id = %d", i);
			return ret;
		}
		clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
			clk_info->clk_name);
		if (IS_ERR(clk_info->vcodec_clk)) {
			mtk_v4l2_err("devm_clk_get (%d)%s fail", i,
				clk_info->clk_name);
			dev_err(&pdev->dev, "devm_clk_get (%d)%s fail", i, clk_info->clk_name);
			return PTR_ERR(clk_info->vcodec_clk);
		}
	}
@@ -62,7 +61,7 @@ static int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)

	ret = pm_runtime_resume_and_get(pm->dev);
	if (ret)
		mtk_v4l2_err("pm_runtime_resume_and_get fail %d", ret);
		dev_err(pm->dev, "pm_runtime_resume_and_get fail %d", ret);

	return ret;
}
@@ -73,7 +72,7 @@ static void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)

	ret = pm_runtime_put(pm->dev);
	if (ret && ret != -EAGAIN)
		mtk_v4l2_err("pm_runtime_put fail %d", ret);
		dev_err(pm->dev, "pm_runtime_put fail %d", ret);
}

static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
@@ -85,7 +84,7 @@ static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
	for (i = 0; i < dec_clk->clk_num; i++) {
		ret = clk_prepare_enable(dec_clk->clk_info[i].vcodec_clk);
		if (ret) {
			mtk_v4l2_err("clk_prepare_enable %d %s fail %d", i,
			dev_err(pm->dev, "clk_prepare_enable %d %s fail %d", i,
				dec_clk->clk_info[i].clk_name, ret);
			goto error;
		}
@@ -119,7 +118,7 @@ static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_id
		if (subdev_dev)
			enable_irq(subdev_dev->dec_irq);
		else
			mtk_v4l2_err("Failed to get hw dev\n");
			dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
	} else {
		enable_irq(vdec_dev->dec_irq);
	}
@@ -137,7 +136,7 @@ static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_i
		if (subdev_dev)
			disable_irq(subdev_dev->dec_irq);
		else
			mtk_v4l2_err("Failed to get hw dev\n");
			dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
	} else {
		disable_irq(vdec_dev->dec_irq);
	}
@@ -184,7 +183,7 @@ static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev *vdec_d
		if (subdev_dev)
			return &subdev_dev->pm;

		mtk_v4l2_err("Failed to get hw dev\n");
		dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
		return NULL;
	}

+73 −70

File changed.

Preview size limit exceeded, changes collapsed.

Loading