linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tiffany lin <tiffany.lin@mediatek.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Hans Verkuil <hans.verkuil@cisco.com>,
	<daniel.thompson@linaro.org>, "Rob Herring" <robh+dt@kernel.org>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Daniel Kurtz <djkurtz@chromium.org>,
	Pawel Osciak <posciak@chromium.org>,
	Eddie Huang <eddie.huang@mediatek.com>,
	Yingjoe Chen <yingjoe.chen@mediatek.com>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-media@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>, <PoChun.Lin@mediatek.com>
Subject: Re: [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver
Date: Mon, 18 Apr 2016 13:40:46 +0800	[thread overview]
Message-ID: <1460958046.7861.48.camel@mtksdaap41> (raw)
In-Reply-To: <5710FA3A.2030603@xs4all.nl>


snipped.

> > +
> > +void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx)
> > +{
> > +	struct mtk_q_data *q_data;
> > +
> > +	ctx->m2m_ctx->q_lock = &ctx->dev->dev_mutex;
> > +	ctx->fh.m2m_ctx = ctx->m2m_ctx;
> > +	ctx->fh.ctrl_handler = &ctx->ctrl_hdl;
> > +	INIT_WORK(&ctx->decode_work, mtk_vdec_worker);
> > +
> > +	q_data = &ctx->q_data[MTK_Q_DATA_SRC];
> > +	memset(q_data, 0, sizeof(struct mtk_q_data));
> > +	q_data->visible_width = DFT_CFG_WIDTH;
> > +	q_data->visible_height = DFT_CFG_HEIGHT;
> > +	q_data->fmt = &mtk_video_formats[OUT_FMT_IDX];
> > +	q_data->colorspace = V4L2_COLORSPACE_REC709;
> > +	q_data->field = V4L2_FIELD_NONE;
> > +	ctx->q_data[MTK_Q_DATA_DST].sizeimage[0] =
> > +		DFT_CFG_WIDTH * DFT_CFG_HEIGHT;
> > +	ctx->q_data[MTK_Q_DATA_DST].bytesperline[0] = 0;
> > +
> > +
> > +	q_data = &ctx->q_data[MTK_Q_DATA_DST];
> > +	memset(q_data, 0, sizeof(struct mtk_q_data));
> > +	q_data->visible_width = DFT_CFG_WIDTH;
> > +	q_data->visible_height = DFT_CFG_HEIGHT;
> > +	q_data->coded_width = DFT_CFG_WIDTH;
> > +	q_data->coded_height = DFT_CFG_HEIGHT;
> > +	q_data->colorspace = V4L2_COLORSPACE_REC709;
> > +	q_data->field = V4L2_FIELD_NONE;
> > +
> > +	q_data->fmt = &mtk_video_formats[CAP_FMT_IDX];
> > +
> > +	v4l_bound_align_image(&q_data->coded_width,
> > +					MTK_VDEC_MIN_W,
> > +					MTK_VDEC_MAX_W, 4,
> > +					&q_data->coded_height,
> > +					MTK_VDEC_MIN_H,
> > +					MTK_VDEC_MAX_H, 5, 6);
> > +
> > +	q_data->sizeimage[0] = q_data->coded_width * q_data->coded_height;
> > +	q_data->bytesperline[0] = q_data->coded_width;
> > +	q_data->sizeimage[1] = q_data->sizeimage[0] / 2;
> > +	q_data->bytesperline[1] = q_data->coded_width;
> > +
> > +}
> > +
> > +static int vidioc_vdec_streamon(struct file *file, void *priv,
> > +				enum v4l2_buf_type type)
> > +{
> > +	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +
> > +	mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
> > +
> > +	return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
> > +}
> > +
> > +static int vidioc_vdec_streamoff(struct file *file, void *priv,
> > +				 enum v4l2_buf_type type)
> > +{
> > +	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +
> > +	mtk_v4l2_debug(3, "[%d] (%d)", ctx->idx, type);
> > +	return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
> > +}
> > +
> > +static int vidioc_vdec_reqbufs(struct file *file, void *priv,
> > +			       struct v4l2_requestbuffers *reqbufs)
> > +{
> > +	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> > +	int ret;
> > +
> > +	mtk_v4l2_debug(3, "[%d] (%d) count=%d", ctx->idx,
> > +			 reqbufs->type, reqbufs->count);
> > +	ret = v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
> > +
> > +	return ret;
> > +}
> 
> Please use the v4l2_m2m_ioctl_* helper functions were applicable.
> 



snipped.
> > +static unsigned int fops_vcodec_poll(struct file *file,
> > +				     struct poll_table_struct *wait)
> > +{
> > +	struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
> > +	struct mtk_vcodec_dev *dev = ctx->dev;
> > +	int ret;
> > +
> > +	mutex_lock(&dev->dev_mutex);
> > +	ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
> > +	mutex_unlock(&dev->dev_mutex);
> > +
> > +	return ret;
> > +}
> > +
> > +static int fops_vcodec_mmap(struct file *file, struct vm_area_struct *vma)
> > +{
> > +	struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
> > +
> > +	return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
> > +}
> > +
> > +static const struct v4l2_file_operations mtk_vcodec_fops = {
> > +	.owner				= THIS_MODULE,
> > +	.open				= fops_vcodec_open,
> > +	.release			= fops_vcodec_release,
> > +	.poll				= fops_vcodec_poll,
> > +	.unlocked_ioctl			= video_ioctl2,
> > +	.mmap				= fops_vcodec_mmap,
> 
> You should be able to use the v4l2_m2m_fop helper functions for poll and mmap.
> 

Hi Hans,

We are plaining to remove m2m framework in th feature, although we think
it is easy to use and could save a lot of code similar to what m2m
framework implemented and reduce code size.
The main reason is that in v4l2_m2m_try_schedule, it required that at
least one output buffer and one capture buffer to run device_run.
We want to start device_run without capture buffer queued.
Is there any suggestion that we could use m2m framework but trigger
device_run with only output buffer.
Or we need to remove m2m and write our own implementation.



snipped.


best regards,
Tiffany

  parent reply	other threads:[~2016-04-18  5:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 12:01 [PATCH 0/7] Add MT8173 Video Decoder Driver Tiffany Lin
2016-04-13 12:01 ` [PATCH 1/7] [media]: v4l: add Mediatek MT21 video block format Tiffany Lin
2016-04-13 12:01   ` [PATCH 2/7] dt-bindings: Add a binding for Mediatek Video Decoder Tiffany Lin
2016-04-13 12:01     ` [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver Tiffany Lin
2016-04-13 12:01       ` [PATCH 4/7] [media] vcodec: mediatek: Add Mediatek H264 " Tiffany Lin
2016-04-13 12:01         ` [PATCH 5/7] [media] vcodec: mediatek: Add Mediatek VP8 " Tiffany Lin
2016-04-13 12:01           ` [PATCH 6/7] [media] vcodec: mediatek: Add Mediatek VP9 " Tiffany Lin
2016-04-13 12:01             ` [PATCH 7/7] arm64: dts: mediatek: Add Video Encoder for MT8173 Tiffany Lin
2016-04-15 14:27       ` [PATCH 3/7] [Media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver Hans Verkuil
2016-04-18  4:00         ` tiffany lin
2016-04-18  5:40         ` tiffany lin [this message]
2016-04-18  7:32           ` Hans Verkuil
2016-04-18  8:22             ` tiffany lin
2016-04-18 17:48               ` Nicolas Dufresne
2016-04-19  6:46                 ` tiffany lin
2016-04-14 16:15     ` [PATCH 2/7] dt-bindings: Add a binding for Mediatek Video Decoder Rob Herring
2016-04-13 14:23   ` [PATCH 1/7] [media]: v4l: add Mediatek MT21 video block format Nicolas Dufresne
2016-04-14  6:13     ` tiffany lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460958046.7861.48.camel@mtksdaap41 \
    --to=tiffany.lin@mediatek.com \
    --cc=PoChun.Lin@mediatek.com \
    --cc=daniel.thompson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=djkurtz@chromium.org \
    --cc=eddie.huang@mediatek.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@osg.samsung.com \
    --cc=posciak@chromium.org \
    --cc=robh+dt@kernel.org \
    --cc=yingjoe.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).