On 09/06/2018 09:01 AM, Hans Verkuil wrote:
> On 09/05/2018 06:29 PM, Paul Kocialkowski wrote:
>> Hi and thanks for the review!
>>
>> Le lundi 03 septembre 2018 à 11:11 +0200, Hans Verkuil a écrit :
>>> On 08/28/2018 09:34 AM, Paul Kocialkowski wrote:
>>>> +static int cedrus_queue_setup(struct vb2_queue *vq, unsigned int *nbufs,
>>>> +                        unsigned int *nplanes, unsigned int sizes[],
>>>> +                        struct device *alloc_devs[])
>>>> +{
>>>> +  struct cedrus_ctx *ctx = vb2_get_drv_priv(vq);
>>>> +  struct cedrus_dev *dev = ctx->dev;
>>>> +  struct v4l2_pix_format_mplane *mplane_fmt;
>>>> +  struct cedrus_format *fmt;
>>>> +  unsigned int i;
>>>> +
>>>> +  switch (vq->type) {
>>>> +  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
>>>> +          mplane_fmt = &ctx->src_fmt;
>>>> +          fmt = cedrus_find_format(mplane_fmt->pixelformat,
>>>> +                                   CEDRUS_DECODE_SRC,
>>>> +                                   dev->capabilities);
>>>> +          break;
>>>> +
>>>> +  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
>>>> +          mplane_fmt = &ctx->dst_fmt;
>>>> +          fmt = cedrus_find_format(mplane_fmt->pixelformat,
>>>> +                                   CEDRUS_DECODE_DST,
>>>> +                                   dev->capabilities);
>>>> +          break;
>>>> +
>>>> +  default:
>>>> +          return -EINVAL;
>>>> +  }
>>>> +
>>>> +  if (!fmt)
>>>> +          return -EINVAL;
>>>> +
>>>> +  if (fmt->num_buffers == 1) {
>>>> +          sizes[0] = 0;
>>>> +
>>>> +          for (i = 0; i < fmt->num_planes; i++)
>>>> +                  sizes[0] += mplane_fmt->plane_fmt[i].sizeimage;
>>>> +  } else if (fmt->num_buffers == fmt->num_planes) {
>>>> +          for (i = 0; i < fmt->num_planes; i++)
>>>> +                  sizes[i] = mplane_fmt->plane_fmt[i].sizeimage;
>>>> +  } else {
>>>> +          return -EINVAL;
>>>> +  }
>>>> +
>>>> +  *nplanes = fmt->num_buffers;
>>>
>>> This code does not take VIDIOC_CREATE_BUFFERS into account.
>>>
>>> If it is called from that ioctl, then *nplanes is non-zero and you need
>>> to check if *nplanes equals fmt->num_buffers and that sizes[n] is >=
>>> the required size of the format. If so, then return 0, otherwise return
>>> -EINVAL.
>>
>> Thanks for spotting this, I'll fix it as you suggested in the next
>> revision.
>>
>>> Doesn't v4l2-compliance fail on that? Or is that test skipped because this
>>> is a decoder for which streaming is not supported (yet)?
>>
>> Apparently, v4l2-compliance doesn't fail since I'm getting:
>> test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> 
> It is tested, but only with the -s option. I'll see if I can improve the
> tests.

I've improved the tests. v4l2-compliance should now fail when run (without the
-s option) against this driver. Can you check that that is indeed the case?

Thanks!

        Hans
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to