Re: [PATCH v6 2/2] [media] s5p-mfc: Handle 'v4l2_pix_format:field' in try_fmt and g_fmt
From: Nicolas Dufresne
Date: Wed Mar 01 2017 - 10:24:28 EST
Le mercredi 01 mars 2017 Ã 14:12 +0100, Andrzej Hajda a ÃcritÂ:
> On 01.03.2017 12:51, Thibault Saunier wrote:
> > It is required by the standard that the field order is set by the
> > driver, default to NONE in case any is provided, but we can
> > basically
> > accept any value provided by the userspace as we will anyway not
> > be able to do any deinterlacing.
> >
> > In this patch we also make sure to pass the interlacing mode
> > provided
> > by userspace from the output to the capture side of the device so
> > that the information is given back to userspace. This way it can
> > handle it and potentially deinterlace afterward.
>
> As I wrote previously:
> - on output side you have encoded bytestream - you cannot say about
> interlacing in such case, so the only valid value is NONE,
Userspace may know. It's important for the driver not to reset it back
to NONE, it would tell the userspace that this encoded format is not
supported when interlaced.
Obviously, when userspace don't know (ANY), it does not matter, it will
fail when we try to set the CAPTURE format. Though, it's quite late in
the process for the userspace, which makes implementing software
fallback difficult.
> - on capture side you have decoded frames, and in this case it
> depends
> on the device and driver capabilities, if the driver/device does not
> support (de-)interlacing (I suppose this is MFC case), interlace type
> field should be filled according to decoded bytestream header (on
> output
> side), but no direct copying from output side!!!
That is exact.
>
> Regards
> Andrzej
>
> >
> > Signed-off-by: Thibault Saunier <thibault.saunier@xxxxxxxxxxxxxxx>
> >
> > ---
> >
> > Changes in v6:
> > - Pass user output field value to the capture as the device is not
> > Â doing any deinterlacing and thus decoded content will still be
> > Â interlaced on the output.
> >
> > Changes in v5:
> > - Just adapt the field and never error out.
> >
> > Changes in v4: None
> > Changes in v3:
> > - Do not check values in the g_fmt functions as Andrzej explained
> > in previous review
> >
> > Changes in v2:
> > - Fix a silly build error that slipped in while rebasing the
> > patches
> >
> > Âdrivers/media/platform/s5p-mfc/s5p_mfc_common.h | 2 ++
> > Âdrivers/media/platform/s5p-mfc/s5p_mfc_dec.cÂÂÂÂ| 6 +++++-
> > Â2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
> > b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
> > index ab23236aa942..3816a37de4bc 100644
> > --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
> > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
> > @@ -652,6 +652,8 @@ struct s5p_mfc_ctx {
> > Â size_t me_buffer_size;
> > Â size_t tmv_buffer_size;
> > Â
> > + enum v4l2_field field;
> > +
> > Â enum v4l2_mpeg_mfc51_video_force_frame_type
> > force_frame_type;
> > Â
> > Â struct list_head ref_queue;
> > diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
> > b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
> > index 367ef8e8dbf0..6e5ca86fb331 100644
> > --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
> > +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
> > @@ -345,7 +345,7 @@ static int vidioc_g_fmt(struct file *file, void
> > *priv, struct v4l2_format *f)
> > Â ÂÂÂrectangle. */
> > Â pix_mp->width = ctx->buf_width;
> > Â pix_mp->height = ctx->buf_height;
> > - pix_mp->field = V4L2_FIELD_NONE;
> > + pix_mp->field = ctx->field;
> > Â pix_mp->num_planes = 2;
> > Â /* Set pixelformat to the format in which MFC
> > Â ÂÂÂoutputs the decoded frame */
> > @@ -380,6 +380,9 @@ static int vidioc_try_fmt(struct file *file,
> > void *priv, struct v4l2_format *f)
> > Â struct s5p_mfc_dev *dev = video_drvdata(file);
> > Â struct s5p_mfc_fmt *fmt;
> > Â
> > + if (f->fmt.pix.field == V4L2_FIELD_ANY)
> > + f->fmt.pix.field = V4L2_FIELD_NONE;
> > +
> > Â mfc_debug(2, "Type is %d\n", f->type);
> > Â if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
> > Â fmt = find_format(f, MFC_FMT_DEC);
> > @@ -436,6 +439,7 @@ static int vidioc_s_fmt(struct file *file, void
> > *priv, struct v4l2_format *f)
> > Â goto out;
> > Â } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
> > Â /* src_fmt is validated by call to vidioc_try_fmt
> > */
> > + ctx->field = f->fmt.pix.field;
> > Â ctx->src_fmt = find_format(f, MFC_FMT_DEC);
> > Â ctx->codec_mode = ctx->src_fmt->codec_mode;
> > Â mfc_debug(2, "The codec number is: %d\n", ctx-
> > >codec_mode);
>
> Attachment:
signature.asc
Description: This is a digitally signed message part