Hans Verkuil [Tue, 24 Dec 2013 15:42:19 +0000 (12:42 -0300)]
[media] [for,v3.14] sn9c102: fix build dependency
This driver should only build if MEDIA_USB_SUPPORT is set.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reported-by: Jim Davis <jim.epost@gmail.com> Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Sachin Kamat [Tue, 24 Dec 2013 11:42:03 +0000 (08:42 -0300)]
[media] s5k5baf: Fix build warning
Fixes the following warnings:
drivers/media/i2c/s5k5baf.c: In function 's5k5baf_fw_parse':
drivers/media/i2c/s5k5baf.c:362:3: warning:
format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat=]
drivers/media/i2c/s5k5baf.c:383:4: warning:
format '%d' expects argument of type 'int', but argument 4 has type 'size_t' [-Wformat=]
[media] cx231xx: Add missing KERN_CONT to i2c debug prints
Fix continuation lines.
[m.chehab@samsung.com: This was actually part of a v2 patch meant to
fix i2c debug prints. As version 1 was already applied, I'm applying
here the diff and fixing the patch subject/description]
Frank Schaefer [Sun, 22 Dec 2013 14:17:46 +0000 (11:17 -0300)]
[media] em28xx: fix I2S audio sample rate definitions and info output
The audio configuration in chip config register 0x00 and eeprom are always
consistent. But currently the audio configuration #defines for the chip config
register say 0x20 means 3 sample rates and 0x30 5 sample rates, while the eeprom
info output says 0x20 means 1 sample rate and 0x30 3 sample rates.
I've checked the datasheet excerpts I have and it seems that the meaning of
these bits is different for em2820/40 (1 and 3 sample rates) and em2860+
(3 and 5 smaple rates).
I have also checked my Hauppauge WinTV USB 2 (em2840) and the chip/eeprom
audio config 0x20 matches the sample rates reproted by the USB device
descriptor (32k only).
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
[media] omap3isp: ccdc: Don't hang when the SBL fails to become idle
Under abnormal conditions (such as glitches on the HSYNC/VSYNC signals)
the CCDC output SBL can fail to become idle. The driver currently logs
this condition to the kernel log and doesn't restart the CCDC. This
results in CCDC video capture hanging without any notification to
userspace.
Cancel the pipeline and mark the CCDC as crashed instead of hanging.
Userspace will be notified of the problem and will then be able to close
and reopen the device to trigger a reset of the ISP.
Modules failing to stop are fatal errors for the preview engine only.
Flag that condition separately from the other stop failures to prepare
support for more fatal errors.
[media] omap3isp: Cancel streaming when a fatal error occurs
When a fatal error that prevents any further video streaming occurs in a
pipeline, all queued buffers must be marked as erroneous and new buffers
must be prevented from being queued. Implement this behaviour with a new
omap3isp_pipeline_cancel_stream() function that can be used by
submodules to cancel streaming.
Hans Verkuil [Sat, 14 Dec 2013 11:28:27 +0000 (08:28 -0300)]
[media] saa7134: share resource management between normal and empress nodes
The empress video node can share resource management with the normal
video nodes, thus allowing for code sharing and making the empress node
non-exclusive.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Hans Verkuil [Fri, 13 Dec 2013 16:13:46 +0000 (13:13 -0300)]
[media] DocBook: drop the word 'only'
There are already video output drivers that allow STREAMON without
any buffers queued, and with the change in vb2 there are now more
drivers like that.
So saying "The ioctl will succeed only when at least one output
buffer is in the incoming queue." isn't true. Just drop the word
'only'. We cannot say that it will also work if no output buffers are
queued as long as not all drivers are converted to vb2.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Hans Verkuil [Fri, 13 Dec 2013 16:13:43 +0000 (13:13 -0300)]
[media] vb2: don't set index, don't start streaming for write()
Two fixes:
- there is no need to set the index when calling dqbuf: dqbuf will
overwrite it.
- __vb2_init_fileio already starts streaming for write(), so there is
no need to do it again in __vb2_perform_fileio. It can never have
worked anyway: either __vb2_init_fileio succeeds in starting streaming
or it is never going to happen.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Hans Verkuil [Fri, 13 Dec 2013 16:13:42 +0000 (13:13 -0300)]
[media] vb2: retry start_streaming in case of insufficient buffers
If start_streaming returns -ENOBUFS, then it will be retried the next time
a buffer is queued. This means applications no longer need to know how many
buffers need to be queued before STREAMON can be called. This is particularly
useful for output stream I/O.
If a DMA engine needs at least X buffers before it can start streaming, then
for applications to get a buffer out as soon as possible they need to know
the minimum number of buffers to queue before STREAMON can be called. You can't
just try STREAMON after every buffer since on failure STREAMON will dequeue
all your buffers. (Is that a bug or a feature? Frankly, I'm not sure).
This patch simplifies applications substantially: they can just call STREAMON
at the beginning and then start queuing buffers and the DMA engine will
kick in automagically once enough buffers are available.
This also fixes using write() to stream video: the fileio implementation
calls streamon without having any queued buffers, which will fail today for
any driver that requires a minimum number of buffers.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Hans Verkuil [Fri, 13 Dec 2013 16:13:41 +0000 (13:13 -0300)]
[media] vb2: remove the 'fileio = NULL' hack
The read/write implementation in vb2 reuses existing vb2 functions, but
it sets q->fileio to NULL before calling them in order to skip the
'q->fileio != NULL' check.
This works today due to the synchronous nature of read/write, but it
1) is ugly, and 2) will fail in an asynchronous use-case such as a
thread queuing and dequeuing buffers. This last example will be necessary
in order to implement vb2 DVB support.
This patch removes the hack by splitting up the dqbuf/qbuf/streamon/streamoff
functions into an external and an internal version. The external version
checks q->fileio and then calls the internal version. The read/write
implementation now just uses the internal version, removing the need to
set q->fileio to NULL.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Hans Verkuil [Fri, 13 Dec 2013 16:13:40 +0000 (13:13 -0300)]
[media] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF
When preparing a buffer the queue lock is released for a short while
if the memory mode is USERPTR (see __buf_prepare for the details), which
would allow a race with a REQBUFS which can free the buffers. Removing the
buffers from underneath __buf_prepare is obviously a bad idea, so we
check if any of the buffers is in the state PREPARING, and if so we
just return -EAGAIN.
If this happens, then the application does something really strange. The
REQBUFS call can be retried safely, since this situation is transient.
Hans Verkuil [Fri, 13 Dec 2013 16:13:39 +0000 (13:13 -0300)]
[media] vb2: simplify qbuf/prepare_buf by removing callback
The callback used to merge the common code of the qbuf/prepare_buf
code can be removed now that the mmap_sem handling is pushed down to
__buf_prepare(). This makes the code more readable.
Hans Verkuil [Fri, 13 Dec 2013 16:13:38 +0000 (13:13 -0300)]
[media] vb2: push the mmap semaphore down to __buf_prepare()
Rather than taking the mmap semaphore at a relatively high-level function,
push it down to the place where it is really needed.
It was placed in vb2_queue_or_prepare_buf() to prevent racing with other
vb2 calls. The only way I can see that a race can happen is when two
threads queue the same buffer. The solution for that it to introduce
a PREPARING state.
Moving it down offers opportunities to simplify the code.
Archit Taneja [Thu, 12 Dec 2013 08:36:04 +0000 (05:36 -0300)]
[media] v4l: ti-vpe: Add a type specifier to describe vpdma data format type
The struct vpdma_data_format holds the color format depth and the data_type
value needed to be programmed in the data descriptors. However, it doesn't
tell what type of color format is it, i.e, whether it is RGB, YUV or Misc.
This information is needed when by vpdma library when forming descriptors. We
modify the depth parameter for the chroma portion of the NV12 format. For this,
we check if the data_type value is C420. This isn't sufficient as there are
many YUV and RGB vpdma formats which have the same data_type value. Hence, we
need to hold the type of the color format for the above case, and possibly more
cases in the future.
Archit Taneja [Thu, 12 Dec 2013 08:36:03 +0000 (05:36 -0300)]
[media] v4l: ti-vpe: enable CSC support for VPE
Use the csc library functions to configure the CSC block in VPE.
Some changes are required in try_fmt to handle the pix->colorspace parameter
more correctly. Previously, we copied the source queue colorspace to the
destination queue colorspace as we didn't support RGB formats. Now, we configure
pix->colorspace based on the color format set(and the height of the image if
it's a YUV format).
Add basic RGB color formats to the list of supported vpe formats.
If the destination format is RGB colorspace, we also need to use the RGB output
port instead of the Luma and Chroma output ports. This requires configuring the
output data descriptors differently.
Also, make the default colorspace V4L2_COLORSPACE_SMPTE170M as that resembles
the Standard Definition colorspace more closely.
Archit Taneja [Thu, 12 Dec 2013 08:36:02 +0000 (05:36 -0300)]
[media] v4l: ti-vpe: Add helper to perform color conversion
The CSC block can be used for color space conversion between YUV and RGB
formats.
It is configurable via a programmable set of coefficients. Add functionality to
choose the appropriate CSC coefficients and program them in the CSC registers.
We take the source and destination colorspace formats as the arguments, and
choose the coefficient table accordingly.
YUV to RGB coefficients are provided for standard and high definition
colorspaces. The coefficients can also be limited or full range. For now, only
full range coefficients are chosen. We would need some sort of control ioctl for
the user to specify the range needed. Not sure if there is a generic control
ioctl for this already?
Archit Taneja [Thu, 12 Dec 2013 08:36:01 +0000 (05:36 -0300)]
[media] v4l: ti-vpe: create a color space converter block library
VPE and VIP IPs in DAR7x contain a color space converter(CSC) sub block. Create
a library which will perform CSC related configurations and hold CSC register
definitions. The functions provided by this library will be called by the vpe
and vip drivers using a csc_data handle.
The vpe_dev holds the csc_data handle. The handle represents an instance of the
CSC hardware, and the vpe driver uses it to access the CSC register offsets or
helper functions to configure these registers.
The CSC register offsets are now relative to the CSC block itself, so we need
to use the macro GET_OFFSET_TOP to get the CSC register offset relative to the
VPE IP in the vpe driver.
Archit Taneja [Thu, 12 Dec 2013 08:36:00 +0000 (05:36 -0300)]
[media] v4l: ti-vpe: enable basic scaler support
Add the required SC register configurations which lets us perform linear scaling
for the supported range of horizontal and vertical scaling ratios.
The horizontal scaler performs polyphase scaling using it's 8 tap 32 phase
filter, decimation is performed when downscaling passes beyond 2x or 4x.
The vertical scaler performs polyphase scaling using it's 5 tap 32 phase filter,
it switches to a simpler form of scaling using the running average filter when
the downscale ratio is more than 4x.
Many of the SC features like peaking, trimming and non-linear scaling aren't
implemented for now. Only the minimal register fields required for basic scaling
operation are configured.
The function to configure SC registers takes the sc_data handle, the source and
destination widths and heights, and the scaler address data block offsets for
the current context so that they can be configured.
Archit Taneja [Thu, 12 Dec 2013 08:35:59 +0000 (05:35 -0300)]
[media] v4l: ti-vpe: make vpe driver load scaler coefficients
Make the driver allocate dma buffers to store horizontal and scaler coeffs.
Use the scaler library api to choose and copy scaler coefficients to a
the above buffers based on the scaling ratio. Since the SC block comes after
the de-interlacer, make sure that the source height is doubled if de-interlacer
was used.
These buffers now need to be used by VPDMA to load the coefficients into the
SRAM within SC.
In device_run, add configuration descriptors which have payloads pointing to
the scaler coefficients in memory. Use the members in sc_data handle to prevent
addition of these descriptors if there isn't a need to re-load coefficients into
SC. This comes helps unnecessary re-loading of the coefficients when we switch
back and forth between vpe contexts.
Archit Taneja [Thu, 12 Dec 2013 08:35:58 +0000 (05:35 -0300)]
[media] v4l: ti-vpe: support loading of scaler coefficients
The SC block in VPE/VIP contains a SRAM within it. This internal memory
requires to be loaded with appropriate scaler coefficients from a contiguous
block of memory through VPDMA.
The horizontal and vertical scaler each require 2 sets of scaler coefficients
for luma and chroma scaling. The horizontal polyphase scaler requires
coefficients for a 32 phase and 8 tap filter. Similarly, the vertical scaler
requires coefficients for a 5 tap filter.
The choice of the scaler coefficients depends on the scaling ratio. Add
coefficient tables for different scaling ratios in sc_coeffs.h. In the case of
horizontal downscaling, we need to consider the change in ratio caused by
decimation performed by the horizontal scaler.
In order to load the scaler coefficients via VPDMA, a configuration descriptor
is used in block mode. The payload for the descriptor is the scaler coefficients
copied to memory. Coefficients for each phase have to be placed in memory in a
particular order understood by the scaler hardware.
The choice of the scaler coefficients, and the loading of the coefficients from
our tables to a contiguous buffer is managed by the functions
sc_set_hs_coefficients and sc_set_vs_coefficients.
The sc_data handle is now added with some parameters to describe the state of
the coefficients loaded in the SC block. 'loaded_coeff_h' and 'loaded_coeff_v'
hold the address of the last dma buffer which was used by VPDMA to copy
coefficients. This information can be used by a vpe mem-to-mem context to decide
whether it should load coefficients or not. 'hs_index' and 'vs_index' provide
some optimization by preventing loading of coefficients if the scaling ratio
didn't change between 2 contexts. 'load_coeff_h' and 'load_coeff_v' tell the
vpe/vip driver whether we need to load the coefficients through VPDMA or not.
Archit Taneja [Thu, 12 Dec 2013 08:35:57 +0000 (05:35 -0300)]
[media] v4l: ti-vpe: create a scaler block library
VPE and VIP IPs in DAR7x contain a scaler(SC) sub block. Create a library which
will perform scaler block related configurations and hold SC register
definitions. The functions provided by this library will be called by the vpe
and vip drivers using a sc_data handle.
The vpe_dev holds the sc_data handle. The handle represents an instance of the
SC hardware, and the vpe driver uses it to access the scaler register offsets
or helper functions to configure these registers.
We move the SC register definitions to sc.h so that they aren't specific to
VPE anymore. The register offsets are now relative to the sub-block, and not the
VPE IP as a whole. In order for VPDMA to configure registers, it requires it's
offset from the top level VPE module. A macro called GET_OFFSET_TOP is added to
return the offset of the register relative to the VPE IP.
Hans Verkuil [Mon, 16 Dec 2013 08:45:37 +0000 (05:45 -0300)]
[media] v4l2: move tracepoints to video_usercopy
The (d)qbuf ioctls were traced in the low-level v4l2 ioctl function. The
trace was outside the serialization lock, so that can affect the usefulness
of the timing. In addition, the __user pointer was expected instead of a
proper kernel pointer.
By moving the tracepoints to video_usercopy we ensure that the trace calls
use the correct kernel pointer, and that it happens right after the ioctl
call to the driver, so certainly inside the serialization lock.
In addition, we only trace if the call was successful.
Antonio Ospite [Mon, 16 Dec 2013 08:16:45 +0000 (05:16 -0300)]
[media] Documentation/DocBook/media/v4l/subdev-formats.xml: fix a typo
The xref to the v4l2-mbus-pixelcode-yuv8 table gets rendered as "Table
4.22, “YUV Formats”", so use the verb in the third person singular
because it refers to "Table":
s/list/lists/
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Do not shift the already 7bit i2c address.
Print a message also for write+read transactions.
For write+read, print the read buffer correctly instead of using the write
buffer.
Hans Verkuil [Fri, 20 Dec 2013 09:03:58 +0000 (06:03 -0300)]
[media] adv7842: set LLC DLL phase from platform_data
The correct LLC DLL phase depends on the board layout, so this
should be part of the platform_data.
Also updated the platform_data in ezkit to ensure that what was the old
default value is now explicitly specified, so the behavior for that board
is unchanged.
Tested-by: Martin Bugge <marbugge@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: Scott Jiang <scott.jiang.linux@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Martin Bugge [Fri, 20 Dec 2013 09:02:24 +0000 (06:02 -0300)]
[media] adv7842: obtain free-run mode from the platform_data
The free-run mode can be board-specific.
Also updated the platform_data in ezkit to ensure that what was the old
default value is now explicitly specified, so the behavior for that board
is unchanged.
Signed-off-by: Martin Bugge <marbugge@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: Scott Jiang <scott.jiang.linux@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Martin Bugge [Tue, 10 Dec 2013 15:00:06 +0000 (12:00 -0300)]
[media] adv7842: restart STDI once if format is not found
The STDI block may measure wrong values, especially for lcvs and lcf.
If the driver can not find any valid timing, the STDI block is restarted
to measure the video timings again. The function will return an error,
but the restart of STDI will generate a new STDI interrupt and the format
detection process will restart.
Copied from adv7604.
Signed-off-by: Martin Bugge <marbugge@cisco.com> Cc: Mats Randgaard <matrandg@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Martin Bugge [Thu, 5 Dec 2013 14:52:39 +0000 (11:52 -0300)]
[media] adv7842: 625/525 line standard jitter fix
Both the PAL and NTSC standards are interlaced where a
frame consist of two fields. Total number of lines in a frame in both systems
are an odd number so the two fields will have different length.
In the 625 line standard ("PAL") the odd field of the frame is transmitted first,
while in the 525 standard ("NTSC") the even field is transmitted first.
This adds the possibility to change output config between the fields and standards.
This setting will reduce the "format-jitter" on the signal sent by the pixelport
moving the difference between the fields to vertical front/back-porch only.
Signed-off-by: Martin Bugge <marbugge@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Hans Verkuil [Fri, 20 Dec 2013 08:44:27 +0000 (05:44 -0300)]
[media] adv7842: support YCrCb analog input, receive CEA formats as RGB on VGA input
Added support for YCrCb analog input.
If input is ADV7842_MODE_RGB and RGB quantization range is set to
V4L2_DV_RGB_RANGE_AUTO, then video with CEA timings will be received
as RGB. For ADV7842_MODE_COMP, automatic CSC mode will be selected.
See table 48 on page 281 in "ADV7842 Hardware Manual, Rev. 0, January 2011"
for details.
Make sure that when switching inputs the RGB quantization range is
updated as well.
Also updated the platform_data in ezkit to ensure that what was the old
default value is now explicitly specified, so the behavior for that board
is unchanged.
Signed-off-by: Mats Randgaard <matrandg@cisco.com> Signed-off-by: Martin Bugge <marbugge@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: Scott Jiang <scott.jiang.linux@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Martin Bugge [Tue, 10 Dec 2013 14:14:26 +0000 (11:14 -0300)]
[media] adv7842: properly enable/disable the irqs
The method of disabling the irq-output pin caused many "empty"
interrupts. Instead, actually disable/enable the interrupts by
changing the interrupt masks.
Also enable STORE_MASKED_IRQ in INT1 configuration, otherwise when HDMI
events happen while the interrupt is masked those events will be ignored
when the interrupt is unmasked.
Signed-off-by: Martin Bugge <marbugge@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Mats Randgaard [Thu, 5 Dec 2013 13:33:41 +0000 (10:33 -0300)]
[media] adv7604: improve HDMI audio handling
- Mute audio before switching inputs to avoid noise/pops
- Mute audio if audio FIFO over-/underflows (AD Recommended setting)
- Reset FIFO if it over-/underflows (AD Recommended setting)
Mats Randgaard [Thu, 5 Dec 2013 13:26:11 +0000 (10:26 -0300)]
[media] adv7604: remove debouncing of ADV7604_FMT_CHANGE events
ADV7604_FMT_CHANGE events was debounced in adv7604_isr() to avoid
that a receiver with a unstable input signal would block the event
handling for other inputs. This solution was prone to errors.
A better protection agains interrupt blocking is to delay the call
of the interrupt service routine in the adv7604 driver if too many
interrupts are received within a given time.
Mats Randgaard [Tue, 10 Dec 2013 12:57:09 +0000 (09:57 -0300)]
[media] adv7604: improve EDID handling
- split edid_write_block()
- do not use edid->edid before the validity check
- Return -EINVAL if edid->pad is invalid
- Save both registers for SPA port A
- Set SPA location to default value if it is not found
Mats Randgaard [Thu, 5 Dec 2013 13:05:58 +0000 (10:05 -0300)]
[media] adv7604: Receive CEA formats as RGB on VGA (RGB) input
If the input is ADV7604_INPUT_VGA_RGB and RGB quantization range is
set to V4L2_DV_RGB_RANGE_AUTO, video with CEA timings will be
received as RGB. For ADV7604_INPUT_VGA_COMP, automatic CSC mode
will be selected.
See table 44 on page 205 in "ADV7604 Hardware Manual, Rev. F, August 2010"
for details.