26 Mar, 2019

1 commit

  • If requests are used when they shouldn't, or not used when they should,
    then return EBADR (Invalid request descriptor) instead of EACCES.

    The reason for this change is that EACCES has more to do with permissions
    (not being the owner of the resource), but in this case the request file
    descriptor is just wrong for the current mode of the device.

    Update the documentation accordingly.

    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     

21 Nov, 2018

1 commit


11 Sep, 2018

3 commits

  • If requests are not supported by the driver, then return EACCES, not
    EPERM.

    If you attempt to mix queueing buffers directly and using requests,
    then EBUSY is returned instead of EPERM: once a specific queueing mode
    has been chosen the queue is 'busy' if you attempt the other mode
    (i.e. direct queueing vs via a request).

    Signed-off-by: Hans Verkuil
    Reviewed-by: Tomasz Figa
    Acked-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     
  • Add helper functions to prevent a completed request from being
    re-inited while it is being accessed.

    Signed-off-by: Hans Verkuil
    Reviewed-by: Tomasz Figa
    Acked-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     
  • Instead of returning -ENOENT when a request_fd was not found (VIDIOC_QBUF
    and VIDIOC_G/S/TRY_EXT_CTRLS), we now return -EINVAL. This is in line
    with what we do when invalid dmabuf fds are passed to e.g. VIDIOC_QBUF.

    Also document that EINVAL is returned for invalid m.fd values, we never
    documented that.

    Signed-off-by: Hans Verkuil
    Reviewed-by: Tomasz Figa
    Acked-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     

31 Aug, 2018

3 commits

  • Add media_request_object_find to find a request object inside a
    request based on ops and priv values.

    Objects of the same type (vb2 buffer, control handler) will have
    the same ops value. And objects that refer to the same 'parent'
    object (e.g. the v4l2_ctrl_handler that has the current driver
    state) will have the same priv value.

    The caller has to call media_request_object_put() for the returned
    object since this function increments the refcount.

    Signed-off-by: Hans Verkuil
    Acked-by: Sakari Ailus
    Reviewed-by: Mauro Carvalho Chehab
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     
  • Add media_request_get_by_fd() to find a request based on the file
    descriptor.

    The caller has to call media_request_put() for the returned
    request since this function increments the refcount.

    Signed-off-by: Hans Verkuil
    Acked-by: Sakari Ailus
    Reviewed-by: Mauro Carvalho Chehab
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     
  • Add initial media request support:

    1) Add MEDIA_IOC_REQUEST_ALLOC ioctl support to media-device.c
    2) Add struct media_request to store request objects.
    3) Add struct media_request_object to represent a request object.
    4) Add MEDIA_REQUEST_IOC_QUEUE/REINIT ioctl support.

    Basic lifecycle: the application allocates a request, adds
    objects to it, queues the request, polls until it is completed
    and can then read the final values of the objects at the time
    of completion. When it closes the file descriptor the request
    memory will be freed (actually, when the last user of that request
    releases the request).

    Drivers will bind an object to a request (the 'adds objects to it'
    phase), when MEDIA_REQUEST_IOC_QUEUE is called the request is
    validated (req_validate op), then queued (the req_queue op).

    When done with an object it can either be unbound from the request
    (e.g. when the driver has finished with a vb2 buffer) or marked as
    completed (e.g. for controls associated with a buffer). When all
    objects in the request are completed (or unbound), then the request
    fd will signal an exception (poll).

    Co-developed-by: Sakari Ailus
    Co-developed-by: Laurent Pinchart
    Co-developed-by: Alexandre Courbot

    Signed-off-by: Hans Verkuil
    Signed-off-by: Sakari Ailus
    Reviewed-by: Mauro Carvalho Chehab
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil