Hans Verkuil [Fri, 8 Aug 2014 12:59:02 +0000 (09:59 -0300)]
[media] vb2: use pr_info instead of pr_debug
Modern kernels enable dynamic printk support, which is fine, except when it is
combined with a debug module option. Enabling debug in videobuf2-core now produces
no debugging unless it is also enabled through the dynamic printk support in debugfs.
Either use a debug module option + pr_info, or use pr_debug without a debug module
option. In this case the fact that you can set various debug levels is very useful,
so I believe that for videobuf2-core.c we should use pr_info.
The mix of the two is very confusing: I've spent too much time already trying to
figure out why I am not seeing any debug output in the kernel log when I do:
The reason is that vb2_fop_mmap and vb2_fop_get_unmapped_area take the core lock
while they are called with the mmap_sem semaphore held. But elsewhere in the code
the core lock is taken first but calls to copy_to/from_user() can take the mmap_sem
semaphore as well, potentially causing a classical A-B/B-A deadlock.
However, the mmap/get_unmapped_area calls really shouldn't take the core lock
at all. So what would happen if they don't take the core lock anymore?
There are two situations that need to be taken into account: calling mmap while
new buffers are being added and calling mmap while buffers are being deleted.
The first case works almost fine without a lock: in all cases mmap relies on
correctly filled-in q->num_buffers/q->num_planes values and those are only
updated by reqbufs and create_buffers *after* any new buffers have been
initialized completely. Except in one case: if an error occurred while allocating
the buffers it will increase num_buffers and rely on __vb2_queue_free to
decrease it again. So there is a short period where the buffer information
may be wrong.
The second case definitely does pose a problem: buffers may be in the process
of being deleted, without the internal structure being updated.
In order to fix this a new mutex is added to vb2_queue that is taken when
buffers are allocated or deleted, and in vb2_mmap. That way vb2_mmap won't
get stale buffer data. Note that this is a problem only for MEMORY_MMAP, so
even though __qbuf_userptr and __qbuf_dmabuf also mess around with buffers
(mem_priv in particular), this doesn't clash with vb2_mmap or
vb2_get_unmapped_area since those are MMAP specific.
As an additional bonus the hack in __buf_prepare, the USERPTR case, can be
removed as well since mmap() no longer takes the core lock.
All in all a much cleaner solution.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Dan Carpenter [Tue, 5 Aug 2014 08:11:13 +0000 (05:11 -0300)]
[media] vmalloc_sg: off by one in error handling
The "i--" needs to happen at the start of the loop or it will try to
release something bogus (probably it will crash) and it won't release
the first ->vaddr_page[].
Fixes: 7b4eeed174b7 ('[media] vmalloc_sg: make sure all pages in vmalloc area are really DMA-ready') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Wed, 6 Aug 2014 11:02:23 +0000 (08:02 -0300)]
[media] coda: checkpatch cleanup
This patch breaks most long lines, concatenates broken up text strings,
and adds or removes parentheses where needed to make checkpatch happy.
The long codec list lines and a few 81-wide lines remain.
Philipp Zabel [Tue, 5 Aug 2014 17:00:20 +0000 (14:00 -0300)]
[media] coda: disable old cropping ioctls
Since we neither support composing on the OUTPUT side, nor cropping
on the CAPTURE side, disable VIDIOC_CROPCAP and VIDIOC_G/S_CROP
altogether. This silences a GStreamer warning when GStreamer tries
to obtain the pixel aspect ratio using VIDIOC_CROPCAP.
Philipp Zabel [Tue, 5 Aug 2014 17:00:19 +0000 (14:00 -0300)]
[media] coda: set capture frame size with output S_FMT
This patch makes coda_s_fmt_vid_out propagate the output frame size
to the capture side.
The GStreamer v4l2videodec only ever calls S_FMT on the output side
and then expects G_FMT on the capture side to return a valid format.
Philipp Zabel [Tue, 5 Aug 2014 17:00:17 +0000 (14:00 -0300)]
[media] coda: fix timestamp list handling
Lock modification of the timestamp list with bitstream_mutex and do not
try to remove a timestamp element if the list is empty. This can happen
if the userspace feeds us garbage or multiple encoded frames in a single
buffer.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Tue, 5 Aug 2014 17:00:14 +0000 (14:00 -0300)]
[media] coda: increase max vertical frame size to 1088
This patch increases the maximum vertical frame size reported
by enum_fmt and accepted by try_fmt/s_fmt from 1080 to 1088.
Since for 16x16-pixel macroblocks 1080p will be rounded up to
this anyway, we may as well admit that we support it.
Philipp Zabel [Wed, 23 Jul 2014 15:28:43 +0000 (12:28 -0300)]
[media] coda: move per-instance buffer allocation and cleanup
This patch moves the context buffer allocation into the context start_streaming
callbacks. The context buffer and internal framebuffer cleanup is moved into
the context release callback.
Philipp Zabel [Wed, 23 Jul 2014 15:28:40 +0000 (12:28 -0300)]
[media] coda: add context ops
Add a struct coda_context_ops that encapsulates context specific operations.
This will simplify adding JPEG support in the future and helps to avoid
exporting all functions individually when they move out of the main code
file.
Philipp Zabel [Wed, 23 Jul 2014 15:28:38 +0000 (12:28 -0300)]
[media] coda: move coda driver into its own directory
The coda driver has grown significantly and will continue to grow.
Move the coda driver into its own directory so it can be split.
Rename coda.h to coda_regs.h as it contains the register defines.
Philipp Zabel [Fri, 18 Jul 2014 10:22:43 +0000 (07:22 -0300)]
[media] coda: split format enumeration for encoder end decoder device
Let the decoder capture side and encoder output side only list
uncompressed formats, and the decoder output and encoder capture
side only list compressed formats.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:42 +0000 (07:22 -0300)]
[media] coda: split userspace interface into encoder and decoder device
Userspace has a hard time making sense of format enumerations on V4L2
mem2mem devices if there are restrictions on which input and output
formats can be used together. Alleviate the problem by splitting the
video4linux device into separate encoder and decoder devices which list
only raw formats on one side and only encoded formats on the other side.
With this patch, the instance type (encoder or decoder) is already
determined by the open file operation.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Michael Olbrich [Fri, 18 Jul 2014 10:22:40 +0000 (07:22 -0300)]
[media] coda: delay coda_fill_bitstream()
coda_fill_bitstream() calls v4l2_m2m_buf_done() which is no longer allowed
before streaming was started.
Delay coda_fill_bitstream() until coda_start_streaming() and explicitly set
'start_streaming_called' before calling coda_fill_bitstream()
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Philipp Zabel [Fri, 18 Jul 2014 10:22:36 +0000 (07:22 -0300)]
[media] coda: initialize hardware on pm runtime resume only if firmware available
If no firmware was found and the coda module is unloaded, coda_runtime_resume
will be called without an allocated code buffer. Do not call coda_hw_init in
this case.
[media] omap3isp: resizer: Protect against races when updating crop
When updating the crop rectangle during streaming, the IRQ handler will
reprogram the resizer after the current frame. A race condition
currently exists between the set selection operation and the IRQ
handler: if the set selection operation is called twice in a row and the
IRQ handler runs only during the second call, it could reprogram the
hardware with partially updated values. Use a spinlock to protect
against that.
[media] omap3isp: resizer: Remove slow debugging message from interrupt handler
The resizer_set_input_size() function prints a debugging message with
the input width and height values. As the function is called from
interrupt context, printing that message to the serial console could
slow down the interrupt handler and cause it to miss the start of the
next frame, causing image corruption.
Fix this by reorganizing the resizer debug messages. The driver now
prints the input size, the crop rectangle and the output size in the set
selection handler instead of scattering debug messages in various
places.
Laurent Pinchart [Tue, 10 Jun 2014 13:28:48 +0000 (10:28 -0300)]
[media] omap3isp: ccdc: Restart the CCDC immediately after an underrun in BT.656
As the CCDC doesn't generate interrupts when stopped in BT.656 mode,
restart it immediately when the next buffer after an underrun is queued
instead of relying on the interrupt handler to restart the CCDC.
Laurent Pinchart [Tue, 10 Jun 2014 13:26:28 +0000 (10:26 -0300)]
[media] omap3isp: ccdc: Don't timeout on stream off when the CCDC is stopped
When the CCDC is already stopped due to a buffer underrun, the stop
state machine won't advance in BT.656 mode as no interrupt are generated
by the stopped CCDC in that mode. Handle this case explicitly in the
ccdc_disable() function.
Laurent Pinchart [Tue, 10 Jun 2014 12:41:57 +0000 (09:41 -0300)]
[media] omap3isp: ccdc: Fix freeze when a short frame is received
In BT.656 mode the synchronization signals are generated by the CCDC
from the embedded sync codes. The VD0 and VD1 interrupts are thus only
triggered when the CCDC is enabled, unlike external sync mode where the
line counter runs even when the CCDC is stopped. We can't disable the
CCDC at VD1 time, as no VD0 interrupt would be generated for a short
frame, which would result in the CCDC being stopped and no VD interrupt
generated anymore. The CCDC is stopped from the VD0 interrupt handler
instead for BT.656.
[media] omap3isp: ccdc: Only complete buffer when all fields are captured
Checking that the captured field corresponds to the last required field
depending on the requested field order before completing the buffer
isn't enough. When the first field at stream start corresponds to the
last required field, this would result in returning an interlaced buffer
containing a single field.
Fix this by keeping track of the fields captured in the buffer, and make
sure that both fields are present for alternate field orders.
Laurent Pinchart [Tue, 10 Jun 2014 14:51:34 +0000 (11:51 -0300)]
[media] omap3isp: ccdc: Disable the video port when unused
The video port doesn't support YUV formats. Disable it when the CCDC
sink pad format is set to YUV instead of leaving it enabled and relying
on downstream modules not to process data they receive from the video
port.
Experiments showed that this fixes some of the CCDC failures to stop,
especially in BT.656 mode.
Laurent Pinchart [Tue, 20 May 2014 17:18:53 +0000 (14:18 -0300)]
[media] omap3isp: ccdc: Add support for BT.656 YUV format at the CCDC input
Query the CCDC input media bus type from the subdev connected to the
CCDC sink pad and configure the CCDC accordingly to support BT.656
synchronization.
Laurent Pinchart [Mon, 19 May 2014 19:37:38 +0000 (16:37 -0300)]
[media] omap3isp: ccdc: Add basic support for interlaced video
When the CCDC input is interlaced enable the alternate field order on
the CCDC output video node. The field signal polarity is specified
through platform data.
Laurent Pinchart [Mon, 19 May 2014 13:33:15 +0000 (10:33 -0300)]
[media] omap3isp: Move non-critical code out of the mutex-protected section
The isp_video_pix_to_mbus() and isp_video_mbus_to_pix() calls in
isp_video_set_format() only access static fields of the isp_video
structure. They don't need to be protected by a mutex.
Laurent Pinchart [Mon, 19 May 2014 14:36:23 +0000 (11:36 -0300)]
[media] v4l: subdev: Extend default link validation to cover field order
The field order must match between the source and sink pads, or the sink
pad field order must be NONE. This allows connecting an interlaced
source to a bridge that has no hardware support for interlaced formats.
Sakari Ailus [Wed, 21 May 2014 19:58:11 +0000 (16:58 -0300)]
[media] smiapp: Implement the test pattern control
Add support for the V4L2_CID_TEST_PATTERN control. When the solid colour
mode is selected, additional controls become available for setting the
solid four solid colour components.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sakari Ailus [Wed, 28 May 2014 12:38:21 +0000 (09:38 -0300)]
[media] v4l: Add test pattern colour component controls
In many cases the test pattern has selectable values for each colour
component. Implement controls for raw bayer components. Additional controls
should be defined for colour components that are not covered by these
controls.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
xc5000_set_params() is a bad name for a function that
handles only digital TV. Rename it to xc5000_set_digital_params(),
and proper name the generic function that works for both
digital and analog.
[media] xc5000: Split config and set code for analog/radio
As we need a function that reapply the last tuned radio,
in order to do resume, split the code that validates and
updates the internal priv struct from the ones that
actually set radio and TV.
[media] au0828: move the code that sets DTV on a separate function
As we'll be adding a code to resume tuner operation, we
need to move the code that actually sets DTV on a separate
function, to be called by the resume code.
[media] dvb-frontend: add core support for tuner suspend/resume
While several tuners have some sort of suspend/resume
implementation, this is currently mangled with an optional
.sleep callback that it is also used to put the device on
low power mode.
Not all drivers implement it, as returning the driver from
low power may require to re-load the firmware, with takes
some time. Also, some drivers may delay it.
So, the more coherent is to add two new optional callbacks
that will let the tuners to directy implement suspend and
resume callbacks if they need.