All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
To: Kamil Debski <kamil@wypas.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	linux-media@vger.kernel.org, linux-sh@vger.kernel.org,
	"j.anaszewski" <j.anaszewski@samsung.com>
Subject: Re: [PATCH v3 1/1] V4L2: platform: Renesas R-Car JPEG codec driver
Date: Fri, 26 Jun 2015 12:23:29 +0000	[thread overview]
Message-ID: <CALi4nhoznAWF2p8WQSdx6vscw7+6wMnEPD+WKqievL9yOCtLUg@mail.gmail.com> (raw)
In-Reply-To: <CAP3TMiFcd-sJvpRw0qtwBrjUAGaDfBB=pxHoebr33UD9q8Fu_Q@mail.gmail.com>

2015-06-26 15:14 GMT+03:00 Kamil Debski <kamil@wypas.org>:
> Hi Mikhail,
>
> On 26 June 2015 at 12:34, Mikhail Ulyanov
> <mikhail.ulyanov@cogentembedded.com> wrote:
>> Hi,
>>
>> Thanks everybody for comments.
>>
>> 2015-06-22 17:54 GMT+03:00 Kamil Debski <kamil@wypas.org>:
>>> Hi,
>>>
>>> I am adding Jacek Anaszewski to CC loop. He was working with the
>>> s5p-jpeg driver some time ago.
>>> I've spoken with him about questions in this email recently. Jacek,
>>> thank you for your comments :)
>>>
>>> On 18 June 2015 at 20:48, Laurent Pinchart
>>> <laurent.pinchart@ideasonboard.com> wrote:
>>>> Hi Mikhail,
>>>>
>>>> (CC'ing Kamil Debski)
>>>>
>>>> On Wednesday 06 May 2015 01:03:10 Mikhail Ulianov wrote:
>>>>> On Mon, 04 May 2015 02:32:05 +0300 Laurent Pinchart wrote:
>>>
>>> [snip]
>>>
>>>>> [snip]
>>>>>
>>>>> >> +/*
>>>>> >> + * ==================================
>>>>> >> + * Queue operations
>>>>> >> + * ==================================
>>>>> >> + */
>>>>> >> +static int jpu_queue_setup(struct vb2_queue *vq,
>>>>> >> +                     const struct v4l2_format *fmt,
>>>>> >> +                     unsigned int *nbuffers, unsigned int
>>>>> >> *nplanes,
>>>>> >> +                     unsigned int sizes[], void
>>>>> >> *alloc_ctxs[])
>>>>> >> +{
>>>>> >> +  struct jpu_ctx *ctx = vb2_get_drv_priv(vq);
>>>>> >> +  struct jpu_q_data *q_data;
>>>>> >> +  unsigned int count = *nbuffers;
>>>>> >> +  unsigned int i;
>>>>> >> +
>>>>> >> +  q_data = jpu_get_q_data(ctx, vq->type);
>>>>> >> +
>>>>> >> +  *nplanes = q_data->format.num_planes;
>>>>> >> +
>>>>> >> +  /*
>>>>> >> +   * Header is parsed during decoding and parsed information
>>>>> >> stored
>>>>> >> +   * in the context so we do not allow another buffer to
>>>>> >> overwrite it.
>>>>> >> +   * For now it works this way, but planned for alternation.
>>>>> >
>>>>> > It shouldn't be difficult to create a jpu_buffer structure that
>>>>> > inherits from vb2_buffer and store the information there instead of
>>>>> > in the context.
>>>>>
>>>>> You are absolutely right. But for this version i want to keep it
>>>>> simple and also at this moment not everything clear for me with this
>>>>> format "autodetection" feature we want to have e.g. for decoder if user
>>>>> requested 2 output buffers and then queue first with some valid JPEG
>>>>> with format -1-(so we setup queues format here), after that
>>>>> another one with format -2-... should we discard second one or just
>>>>> change format of queues? what about same situation if user already
>>>>> requested capture buffers. I mean relations with buf_prepare and
>>>>> queue_setup. AFAIU format should remain the same for all requested
>>>>> buffers. I see only one "solid" solution here - get rid of
>>>>> "autodetection" feature and rely only on format setted by user, so in
>>>>> this case we can just discard queued buffers with inappropriate
>>>>> format(kind of format validation in kernel). This solution will also
>>>>> work well with NV61, NV21, and semiplanar formats we want to add in next
>>>>> version. *But* with this solution header parsing must be done twice(in
>>>>> user and kernel spaces).
>>>>> I'm a little bit frustrated here :)
>>>>
>>>> Yes, it's a bit frustrating indeed. I'm not sure what to advise, I'm not too
>>>> familiar with the m2m API for JPEG.
>>>>
>>>> Kamil, do you have a comment on that ?
>>>
>>> I am not sure whether it is good to get rid of header parsing by the
>>> driver/hardware option. I agree that the buffers should have a
>>> consistent format and size. Maybe the way to go would be to allow
>>> header parsing by the hardware, but to stop processing when the format
>>> has changed? Other solution would be to use the
>>> V4L2_EVENT_SOURCE_CHANGE event to inform user space about the change.
>>> User space then could check whether the buffers are sufficient or
>>> reallocate them. Similar to what happens in MFC when format changes.
>>>
>>> For me implementing resolution change in JPEG seems like an overkill,
>>> but maybe you have a use case that would benefit from this. Initially
>>> the JPEG decoder was designed and written as a one shot device. Could
>>> you give an example of such use case?
>>>
>>> The possible use case I can imagine is having an M-JPEG stream where
>>> all JPEGs have the same dimensions and format. There I can see some
>>> benefits from having more than one buffer on the queues. Then there
>>> would be no change in the buffer parameters, so this should work.
>>
>> That's correct. It's exactly our use case, but we have few cameras. So
>> we serialize buffers in user space and sometimes one(or more) cameras
>> have different configuration. I think i should go with stop processing
>> option.
>
> It could be possible to have frames from each camera decoded in
> different contexts. This way the configuration should be consistent
> for all frames in a context. It will require more memory (more
> buffers) though...

Yes, that's an option. Anyway in latest (v4) version i decided to drop
frames with different format and make driver more strict in general. I
think it's more robust in any case. Nobody knows what user will pass
to kernel :)

>>>>> [snip]
>>>
>>> [snip]
>>>
>
> Best wishes,
> Kamil Debski



-- 
W.B.R, Mikhail.

WARNING: multiple messages have this Message-ID (diff)
From: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
To: Kamil Debski <kamil@wypas.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	linux-media@vger.kernel.org, linux-sh@vger.kernel.org,
	"j.anaszewski" <j.anaszewski@samsung.com>
Subject: Re: [PATCH v3 1/1] V4L2: platform: Renesas R-Car JPEG codec driver
Date: Fri, 26 Jun 2015 15:23:29 +0300	[thread overview]
Message-ID: <CALi4nhoznAWF2p8WQSdx6vscw7+6wMnEPD+WKqievL9yOCtLUg@mail.gmail.com> (raw)
In-Reply-To: <CAP3TMiFcd-sJvpRw0qtwBrjUAGaDfBB=pxHoebr33UD9q8Fu_Q@mail.gmail.com>

2015-06-26 15:14 GMT+03:00 Kamil Debski <kamil@wypas.org>:
> Hi Mikhail,
>
> On 26 June 2015 at 12:34, Mikhail Ulyanov
> <mikhail.ulyanov@cogentembedded.com> wrote:
>> Hi,
>>
>> Thanks everybody for comments.
>>
>> 2015-06-22 17:54 GMT+03:00 Kamil Debski <kamil@wypas.org>:
>>> Hi,
>>>
>>> I am adding Jacek Anaszewski to CC loop. He was working with the
>>> s5p-jpeg driver some time ago.
>>> I've spoken with him about questions in this email recently. Jacek,
>>> thank you for your comments :)
>>>
>>> On 18 June 2015 at 20:48, Laurent Pinchart
>>> <laurent.pinchart@ideasonboard.com> wrote:
>>>> Hi Mikhail,
>>>>
>>>> (CC'ing Kamil Debski)
>>>>
>>>> On Wednesday 06 May 2015 01:03:10 Mikhail Ulianov wrote:
>>>>> On Mon, 04 May 2015 02:32:05 +0300 Laurent Pinchart wrote:
>>>
>>> [snip]
>>>
>>>>> [snip]
>>>>>
>>>>> >> +/*
>>>>> >> + * ====================================================================
>>>>> >> + * Queue operations
>>>>> >> + * ====================================================================
>>>>> >> + */
>>>>> >> +static int jpu_queue_setup(struct vb2_queue *vq,
>>>>> >> +                     const struct v4l2_format *fmt,
>>>>> >> +                     unsigned int *nbuffers, unsigned int
>>>>> >> *nplanes,
>>>>> >> +                     unsigned int sizes[], void
>>>>> >> *alloc_ctxs[])
>>>>> >> +{
>>>>> >> +  struct jpu_ctx *ctx = vb2_get_drv_priv(vq);
>>>>> >> +  struct jpu_q_data *q_data;
>>>>> >> +  unsigned int count = *nbuffers;
>>>>> >> +  unsigned int i;
>>>>> >> +
>>>>> >> +  q_data = jpu_get_q_data(ctx, vq->type);
>>>>> >> +
>>>>> >> +  *nplanes = q_data->format.num_planes;
>>>>> >> +
>>>>> >> +  /*
>>>>> >> +   * Header is parsed during decoding and parsed information
>>>>> >> stored
>>>>> >> +   * in the context so we do not allow another buffer to
>>>>> >> overwrite it.
>>>>> >> +   * For now it works this way, but planned for alternation.
>>>>> >
>>>>> > It shouldn't be difficult to create a jpu_buffer structure that
>>>>> > inherits from vb2_buffer and store the information there instead of
>>>>> > in the context.
>>>>>
>>>>> You are absolutely right. But for this version i want to keep it
>>>>> simple and also at this moment not everything clear for me with this
>>>>> format "autodetection" feature we want to have e.g. for decoder if user
>>>>> requested 2 output buffers and then queue first with some valid JPEG
>>>>> with format -1-(so we setup queues format here), after that
>>>>> another one with format -2-... should we discard second one or just
>>>>> change format of queues? what about same situation if user already
>>>>> requested capture buffers. I mean relations with buf_prepare and
>>>>> queue_setup. AFAIU format should remain the same for all requested
>>>>> buffers. I see only one "solid" solution here - get rid of
>>>>> "autodetection" feature and rely only on format setted by user, so in
>>>>> this case we can just discard queued buffers with inappropriate
>>>>> format(kind of format validation in kernel). This solution will also
>>>>> work well with NV61, NV21, and semiplanar formats we want to add in next
>>>>> version. *But* with this solution header parsing must be done twice(in
>>>>> user and kernel spaces).
>>>>> I'm a little bit frustrated here :)
>>>>
>>>> Yes, it's a bit frustrating indeed. I'm not sure what to advise, I'm not too
>>>> familiar with the m2m API for JPEG.
>>>>
>>>> Kamil, do you have a comment on that ?
>>>
>>> I am not sure whether it is good to get rid of header parsing by the
>>> driver/hardware option. I agree that the buffers should have a
>>> consistent format and size. Maybe the way to go would be to allow
>>> header parsing by the hardware, but to stop processing when the format
>>> has changed? Other solution would be to use the
>>> V4L2_EVENT_SOURCE_CHANGE event to inform user space about the change.
>>> User space then could check whether the buffers are sufficient or
>>> reallocate them. Similar to what happens in MFC when format changes.
>>>
>>> For me implementing resolution change in JPEG seems like an overkill,
>>> but maybe you have a use case that would benefit from this. Initially
>>> the JPEG decoder was designed and written as a one shot device. Could
>>> you give an example of such use case?
>>>
>>> The possible use case I can imagine is having an M-JPEG stream where
>>> all JPEGs have the same dimensions and format. There I can see some
>>> benefits from having more than one buffer on the queues. Then there
>>> would be no change in the buffer parameters, so this should work.
>>
>> That's correct. It's exactly our use case, but we have few cameras. So
>> we serialize buffers in user space and sometimes one(or more) cameras
>> have different configuration. I think i should go with stop processing
>> option.
>
> It could be possible to have frames from each camera decoded in
> different contexts. This way the configuration should be consistent
> for all frames in a context. It will require more memory (more
> buffers) though...

Yes, that's an option. Anyway in latest (v4) version i decided to drop
frames with different format and make driver more strict in general. I
think it's more robust in any case. Nobody knows what user will pass
to kernel :)

>>>>> [snip]
>>>
>>> [snip]
>>>
>
> Best wishes,
> Kamil Debski



-- 
W.B.R, Mikhail.

  reply	other threads:[~2015-06-26 12:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29 21:53 [PATCH v3 1/1] V4L2: platform: Renesas R-Car JPEG codec driver Mikhail Ulyanov
2015-04-29 21:53 ` Mikhail Ulyanov
2015-04-29 21:59 ` Sergei Shtylyov
2015-04-29 21:59   ` Sergei Shtylyov
2015-04-29 22:08   ` Sergei Shtylyov
2015-04-29 22:08     ` Sergei Shtylyov
2015-05-03 10:21 ` Hans Verkuil
2015-05-03 10:21   ` Hans Verkuil
2015-05-03 23:32 ` Laurent Pinchart
2015-05-03 23:32   ` Laurent Pinchart
2015-05-05 22:03   ` Mikhail Ulianov
2015-05-05 22:03     ` Mikhail Ulianov
2015-06-18 19:48     ` Laurent Pinchart
2015-06-18 19:48       ` Laurent Pinchart
2015-06-22 14:54       ` Kamil Debski
2015-06-22 14:54         ` Kamil Debski
2015-06-26 11:34         ` Mikhail Ulyanov
2015-06-26 11:34           ` Mikhail Ulyanov
2015-06-26 12:14           ` Kamil Debski
2015-06-26 12:14             ` Kamil Debski
2015-06-26 12:23             ` Mikhail Ulyanov [this message]
2015-06-26 12:23               ` Mikhail Ulyanov
2015-05-06  5:46   ` Mikhail Ulianov
2015-05-06  5:46     ` Mikhail Ulianov

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=CALi4nhoznAWF2p8WQSdx6vscw7+6wMnEPD+WKqievL9yOCtLUg@mail.gmail.com \
    --to=mikhail.ulyanov@cogentembedded.com \
    --cc=horms@verge.net.au \
    --cc=hverkuil@xs4all.nl \
    --cc=j.anaszewski@samsung.com \
    --cc=kamil@wypas.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=sergei.shtylyov@cogentembedded.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.