08 Feb, 2019

25 commits

  • The v4l2_m2m_buf_copy_data helper is used to copy the buffer
    metadata, such as its timestamp and its flags.

    Therefore, the v4l2_m2m_buf_copy_metadata name is more clear
    and avoids confusion with a payload data copy.

    Signed-off-by: Ezequiel Garcia
    Signed-off-by: Hans Verkuil
    [hverkuil-cisco@xs4all.nl: also fix cedrus_dec.c]
    Signed-off-by: Mauro Carvalho Chehab

    Ezequiel Garcia
     
  • The .buf_out_validate callback is mandatory for OUTPUT
    queues. Mark it as such in the callback's doc.

    Fixes: 28d77c21cb ("media: vb2: add buf_out_validate callback")

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

    Ezequiel Garcia
     
  • In the .s_frame_interval() subdev op, don't accept or set a
    frame interval with a zero numerator or denominator. This fixes
    a v4l2-compliance failure:

    fail: v4l2-test-formats.cpp(1146):
    cap->timeperframe.numerator == 0 || cap->timeperframe.denominator == 0
    test VIDIOC_G/S_PARM: FAIL

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

    Steve Longerbeam
     
  • It seems that it is possible that dev to be null, as there's
    a warning printing:
    "Instance released before the end of transaction"

    Solves this warning:
    drivers/media/platform/vim2m.c: drivers/media/platform/vim2m.c:525 device_work() warn: variable dereferenced before check 'curr_ctx' (see line 523)

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • To correctly set the size of the image in a plane, it's needed
    to divide the height of image by the vertical down sampling factor.
    This was only happening in vivid_try_fmt_vid_cap(), but now it
    applied in others sizeimage calculations as well.

    Signed-off-by: André Almeida
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    André Almeida
     
  • Add a linear pipeline logic for the stream control. It's created by
    walking backwards on the entity graph. When the stream starts it will
    simply loop through the pipeline calling the respective process_frame
    function of each entity.

    Fixes: f2fe89061d797 ("vimc: Virtual Media Controller core, capture
    and sensor")

    Cc: stable@vger.kernel.org # for v4.20
    Signed-off-by: Lucas A. M. Magalhães
    Acked-by: Helen Koike
    Signed-off-by: Hans Verkuil
    [hverkuil-cisco@xs4all.nl: fixed small space-after-tab issue in the patch]
    Signed-off-by: Mauro Carvalho Chehab

    Lucas A. M. Magalhães
     
  • This function is no longer used, so drop it.

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

    Hans Verkuil
     
  • Just like vb2 does, use u64 internally to store the timestamps
    of the buffers. Only convert to timeval when interfacing with
    userspace.

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

    Hans Verkuil
     
  • Just like vb2 does, use u64 internally to store the timestamps
    of the buffers. Only convert to timeval when interfacing with
    userspace.

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

    Hans Verkuil
     
  • Just like vb2 does, use u64 internally to store the timestamps
    of the buffers. Only convert to timeval when interfacing with
    userspace.

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

    Hans Verkuil
     
  • Just like vb2 does, use u64 internally to store the timestamps
    of the buffers. Only convert to timeval when interfacing with
    userspace.

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

    Hans Verkuil
     
  • Just like vb2 does, use u64 internally to store the timestamps
    of the buffers. Only convert to timeval when interfacing with
    userspace.

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

    Hans Verkuil
     
  • Just like vb2 does, use u64 internally to store the timestamps
    of the buffers. Only convert to timeval when interfacing with
    userspace.

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

    Hans Verkuil
     
  • Internally use ktime_get_ns() to get the timestamp of the event.
    Only convert to timespec when interfacing with userspace.

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

    Hans Verkuil
     
  • The comparison css->pipes[pipe].bindex < 0 is always false because
    bindex is an unsigned int. Fix this by using a signed integer for
    the comparison.

    Detected by CoverityScan, CID#1476023 ("Unsigned compared against 0")

    Fixes: f5f2e4273518 ("media: staging/intel-ipu3: Add css pipeline programming")

    Signed-off-by: Colin Ian King
    Signed-off-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab

    Colin Ian King
     
  • Since ipu3_css_buf_dequeue() never returns NULL, remove the
    dead code to fix static checker warning:

    drivers/staging/media/ipu3/ipu3.c:493 imgu_isr_threaded()
    warn: 'b' is an error pointer or valid

    Reported-by: Dan Carpenter
    [Bug report: https://lore.kernel.org/linux-media/20190104122856.GA1169@kadam/]
    Signed-off-by: Yong Zhi
    Reviewed-by: Tomasz Figa
    Signed-off-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab

    Yong Zhi
     
  • This addresses the below TODO item.
    - Use V4L2_CTRL_TYPE_MENU for dual-pipe mode control. (Sakari)

    Signed-off-by: Yong Zhi
    Reviewed-by: Tomasz Figa
    Signed-off-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab

    Yong Zhi
     
  • The UVC video driver converts the timestamp from hardware specific unit
    to one known by the kernel at the time when the buffer is dequeued. This
    is fine in general, but the streamoff operation consists of the
    following steps (among other things):

    1. uvc_video_clock_cleanup --- the hardware clock sample array is
    released and the pointer to the array is set to NULL,

    2. buffers in active state are returned to the user and

    3. buf_finish callback is called on buffers that are prepared.
    buf_finish includes calling uvc_video_clock_update that accesses the
    hardware clock sample array.

    The above is serialised by a queue specific mutex. Address the problem
    by skipping the clock conversion if the hardware clock sample array is
    already released.

    Fixes: 9c0863b1cc48 ("[media] vb2: call buf_finish from __queue_cancel")

    Reported-by: Chiranjeevi Rapolu
    Tested-by: Chiranjeevi Rapolu
    Signed-off-by: Sakari Ailus
    Cc: stable@vger.kernel.org
    Signed-off-by: Laurent Pinchart
    Signed-off-by: Mauro Carvalho Chehab

    Sakari Ailus
     
  • When initially testing the Camera Terminal Descriptor wTerminalType
    field (buffer[4]), no mask is used. Later in the function, the MSB is
    overloaded to store the descriptor subtype, and so a mask of 0x7fff
    is used to check the type.

    If a descriptor is specially crafted to set this overloaded bit in the
    original wTerminalType field, the initial type check will fail (falling
    through, without adjusting the buffer size), but the later type checks
    will pass, assuming the buffer has been made suitably large, causing an
    overflow.

    Avoid this problem by checking for the MSB in the wTerminalType field.
    If the bit is set, assume the descriptor is bad, and abort parsing it.

    Originally reported here:
    https://groups.google.com/forum/#!topic/syzkaller/Ot1fOE6v1d8
    A similar (non-compiling) patch was provided at that time.

    Reported-by: syzbot
    Signed-off-by: Alistair Strachan
    Signed-off-by: Laurent Pinchart
    Signed-off-by: Mauro Carvalho Chehab

    Alistair Strachan
     
  • The SOURCE_CHANGE event is decoder specific, so don't allow it for
    encoders.

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

    Hans Verkuil
     
  • It is good practice to fill in the bus_info.

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

    Hans Verkuil
     
  • It is good practice to fill in bus_info.

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

    Hans Verkuil
     
  • Check that the selection buf_type is valid before calling get_q_data() to
    avoid hitting the WARN(1) in that function if the buffer type is not valid.

    Signed-off-by: Hans Verkuil
    Reported-by: syzbot+44b24cff6bf96006ecfa@syzkaller.appspotmail.com
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     
  • Fix a copy&paste error to make RGB -> BT.2020 YUV conversion actually
    selectable. Fixes the following warning:

    drivers/media/platform/imx-pxp.c:683:24: warning: duplicated ‘if’ condition [-Wduplicated-cond]

    Fixes: 51abcf7fdb70 ("media: imx-pxp: add i.MX Pixel Pipeline driver")

    Reported-by: David Binderman
    Signed-off-by: Philipp Zabel
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Philipp Zabel
     
  • Commit 2cc1802f62e5 ("media: vb2: Keep dma-buf buffers mapped until
    they are freed") removed code leaving a local variable unused.

    Remove it to avoid a compiler warning.

    Fixes: 2cc1802f62e5 ("media: vb2: Keep dma-buf buffers mapped until they are freed")

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

    Hans Verkuil
     

01 Feb, 2019

3 commits

  • While there's a control to allow setting it at runtime, as the
    control handler is per file handler, only the application setting
    the m2m device can change it. As this is a custom control, it is
    unlikely that existing apps would be able to set it.

    Due to that, and due to the fact that v4l2-mem2mem serializes all
    accesses to a m2m device, trying to setup two GStreamer
    v4l2videoconvert instance at the same time will cause frame drops.

    So, add an alternate way of setting its default via a modprobe parameter.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • It doesn't make sense to have a per-device work queue, as the
    scheduler should be called per file handler. Having a single
    one causes failures if multiple streams are filtered by vim2m.

    So, move it to be inside the context structure.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Despite vim2m is reporting that it supports RGB565BE and YUYV,
    that's not true.

    Right now, it just says that it supports both format, but it
    doesn't actually support them.

    Also, horizontal flip is not properly implemented. It sounds
    that it was designed to do a pseudo-horizontal flip using 8
    tiles. Yet, as it doesn't do format conversion, the result
    is a mess.

    I suspect that it was done this way in order to save CPU time,
    at the time of OMAP2 days.

    That's messy and doesn't really help if someone wants to
    use vim2m to test a pipeline.

    Worse than that, the unique RGB format it says it supports is
    RGB565BE, with is not supported by Gstreamer. That prevents
    practical usage of it, even for tests.

    So, instead, properly implement fourcc format conversions,
    adding a few more RGB formats:

    - RGB and BGR with 24 bits
    - RGB565LE (known as RGB16 at gstreamer)

    Also allows using any of the 5 supported formats as either
    capture or output.

    Note: The YUYV conversion routines are based on the conversion code
    written by Hans de Goede inside libv4lconvert (part of v4l-utils),
    released under LGPGL 2.1 (GPL 2.0 compatible).

    Tested all possible format combinations except for RGB565BE,
    as Gstreamer currently doesn't support it.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     

31 Jan, 2019

12 commits

  • The wrong size check was performed for output formats like NV24 which
    set vfmt->buffers to 1, but vfmt->planes is 2. It was incorrectly
    checking the payload size for plane 1, which doesn't exist.

    Note: vfmt->buffers refers to the number of per-plane-buffers that
    should be allocated. vfmt->planes refers to the number of planes
    that make up an image. vfmt->planes may be > vfmt->buffers.

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

    Hans Verkuil
     
  • The buf_out_validate is required for output queues in combination
    with requests. Check this.

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

    Hans Verkuil
     
  • Validate the field for an output buffer. This ensures that the
    field is validated when the buffer is queued to a request, and
    not when the request itself is queued, which is too late.

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

    Hans Verkuil
     
  • Validate the field for an output buffer. This ensures that the
    field is validated when the buffer is queued to a request, and
    not when the request itself is queued, which is too late.

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

    Hans Verkuil
     
  • Validate the field for an output buffer. This ensures that the
    field is validated when the buffer is queued to a request, and
    not when the request itself is queued, which is too late.

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

    Hans Verkuil
     
  • When queueing a buffer to a request the 'field' value is not validated.
    That field is only validated when the _buf_prepare() is called,
    which happens when the request is queued.

    However, this validation should happen at QBUF time, since you want
    to know about this as soon as possible. Also, the spec requires that
    the 'field' value is validated at QBUF time.

    This patch adds a new buf_out_validate callback to validate the
    output buffer at buf_prepare time or when QBUF queues an unprepared
    buffer to a request. This callback is mandatory for output queues
    that support requests.

    This issue was found by v4l2-compliance since it failed to replace
    V4L2_FIELD_ANY by a proper field value when testing the vivid video
    output in combination with requests.

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

    Hans Verkuil
     
  • Access to reference frames that were imported from dma-buf was taken
    care of and is no longer a pending item on the driver's TODO list.

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

    Paul Kocialkowski
     
  • When using vb2 for video decoding, dequeued capture buffers may still
    be accessed by the hardware: this is the case when they are used as
    reference frames for decoding subsequent frames.

    When the buffer is imported with dma-buf, it needs to be mapped before
    access. Until now, it was mapped when queuing and unmapped when
    dequeuing, which doesn't work for access as a reference frames.

    One way to solve this would be to map the buffer again when it is
    needed as a reference, but the mapping/unmapping operations can
    seriously impact performance. As a result, map the buffer once (when it
    is first needed when queued) and keep it mapped until it is freed.

    Reviewed-on: https://chromium-review.googlesource.com/334103
    [Paul: Updated for mainline and changed commit message]

    Signed-off-by: Pawel Osciak
    Signed-off-by: Paul Kocialkowski
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Pawel Osciak
     
  • This reverts commit cf20ae1535eb690a87c29b9cc7af51881384e967.

    The vb2_find_timestamp helper was modified to allow finding buffers
    regardless of their current state in the queue. This means that we
    no longer have to take particular care of references to the current
    capture buffer.

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

    Paul Kocialkowski
     
  • There really is no reason why vb2_find_timestamp can't just find
    buffers in any state. Drop that part of the test.

    This also means that vb->timestamp should only be set to 0 when
    the driver doesn't copy timestamps.

    This change allows for more efficient pipelining (i.e. you can use
    a buffer for a reference frame even when it is queued).

    Signed-off-by: Hans Verkuil
    Reviewed-by: Tomasz Figa
    Reviewed-by: Alexandre Courbot
    Reviewed-by: Paul Kocialkowski
    Signed-off-by: Mauro Carvalho Chehab

    Hans Verkuil
     
  • Vdec: Using standard CCF interface to set parent clock and
    clock rate in dtsi and using common interface to open/close
    video decoder clock.
    Venc: Using standard CCF interface to set parent clock in dtsi
    and using common interface to open/close video encoder clock.

    Signed-off-by: Yunfei Dong
    Signed-off-by: Qianqian Yan
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Yunfei Dong
     
  • Fix MTK binding document for MT8173 dtsi changed in order
    to use standard CCF interface.
    MT8173 SoC from Mediatek.

    Signed-off-by: Yunfei Dong
    Signed-off-by: Qianqian Yan
    Reviewed-by: Rob Herring
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Yunfei Dong