Re: [PATCH v3 2/3] media: hantro: Support color conversion via post-processing

From: Ezequiel Garcia
Date: Thu Dec 05 2019 - 11:03:07 EST


On Thu, 2019-12-05 at 15:46 +0100, Philipp Zabel wrote:
> On Thu, 2019-12-05 at 11:33 -0300, Ezequiel Garcia wrote:
> > Hello Philipp,
> >
> > On Fri, 2019-11-15 at 12:44 -0300, Ezequiel Garcia wrote:
> > > Hello Philipp,
> > >
> > > Thanks for reviewing.
> > >
> > > On Thu, 2019-11-14 at 10:48 +0100, Philipp Zabel wrote:
> > > > Hi Ezequiel,
> > > >
> > > > On Wed, 2019-11-13 at 14:56 -0300, Ezequiel Garcia wrote:
> > > > > The Hantro G1 decoder is able to enable a post-processor
> > > > > on the decoding pipeline, which can be used to perform
> > > > > scaling and color conversion.
> > > > >
> > > > > The post-processor is integrated to the decoder, and it's
> > > > > possible to use it in a way that is completely transparent
> > > > > to the user.
> > > > >
> > > > > This commit enables color conversion via post-processing,
> > > > > which means the driver now exposes YUV packed, in addition to NV12.
> > > > >
> > > > > Signed-off-by: Ezequiel Garcia <ezequiel@xxxxxxxxxxxxx>
> > > > > ---
> > > > > drivers/staging/media/hantro/Makefile | 1 +
> > > > > drivers/staging/media/hantro/hantro.h | 64 +++++++-
> > > > > drivers/staging/media/hantro/hantro_drv.c | 8 +-
> > > > > .../staging/media/hantro/hantro_g1_h264_dec.c | 2 +-
> > > > > .../media/hantro/hantro_g1_mpeg2_dec.c | 2 +-
> > > > > drivers/staging/media/hantro/hantro_g1_regs.h | 53 +++++++
> > > > > .../staging/media/hantro/hantro_g1_vp8_dec.c | 2 +-
> > > > > drivers/staging/media/hantro/hantro_h264.c | 6 +-
> > > > > drivers/staging/media/hantro/hantro_hw.h | 13 ++
> > > > > .../staging/media/hantro/hantro_postproc.c | 141 ++++++++++++++++++
> > > > > drivers/staging/media/hantro/hantro_v4l2.c | 52 ++++++-
> > > > > drivers/staging/media/hantro/rk3288_vpu_hw.c | 10 ++
> > > > > 12 files changed, 343 insertions(+), 11 deletions(-)
> > > > > create mode 100644 drivers/staging/media/hantro/hantro_postproc.c
> > > > >
> > > > >
> > [..]
> > > > > pix_mp->plane_fmt[0].sizeimage +=
> > > > > 128 * DIV_ROUND_UP(pix_mp->width, 16) *
> > > > > DIV_ROUND_UP(pix_mp->height, 16);
> > > > > @@ -611,10 +643,23 @@ static int hantro_start_streaming(struct vb2_queue *q, unsigned int count)
> > > > >
> > > > > vpu_debug(4, "Codec mode = %d\n", codec_mode);
> > > > > ctx->codec_ops = &ctx->dev->variant->codec_ops[codec_mode];
> > > > > - if (ctx->codec_ops->init)
> > > > > + if (ctx->codec_ops->init) {
> > > > > ret = ctx->codec_ops->init(ctx);
> > > > > + if (ret)
> > > > > + return ret;
> > > > > + }
> > > > > +
> > > > > + if (hantro_needs_postproc(ctx)) {
> > > > > + ret = hantro_postproc_alloc(ctx);
> > > >
> > > > Why is this done in start_streaming? Wouldn't capture side REQBUFS be a
> > > > better place for this?
> > > >
> > >
> > > Yes, makes sense as well.
> > >
> >
> > This didn't work so well, so I have decided to leave it as-is in the
> > just submitted v4 series.
> >
> > The vb2 framework provides two mechanism for drivers to allocate
> > buffers, REQBUFS and CREATEBUFS, so the bounce buffer allocation
> > has to be hooked on both of them.
>
> That is a good point, now that we don't allocate VB2_MAX_FRAME bounce
> buffers at start_streaming time anymore, what happens if additional
> capture buffers are created with CREATEBUFS while streaming?
>

If I understand vb2 logic correctly, then I do not think anything
will happen, because the newly created buffers won't be queued.

Regards,
Ezequiel