media: rcar-vin: enable field toggle after a set number of lines for Gen3
The VIN Gen3 hardware don't have Line Post-Clip capabilities as VIN Gen2
hardware have. To protect against writing outside the capture window
enable field toggle after a set number of lines have been captured.
Capturing outside the allocated capture buffer where observed on R-Car
Gen3 Salvator-XS H3 from the CVBS input if the standard is
misconfigured. That is if a PAL source is connected to the system but
the adv748x standard is set to NTSC. In this case the format reported by
the adv748x is 720x480 and that is what is used for the media pipeline.
The PAL source generates frames in the format of 720x576 and the field
is not toggled until the VSYNC is detected and at that time data have
already been written outside the allocated capture buffer.
With this change the capture in the situation described above results in
garbage frames but that is far better then writing outside the capture
buffer.
The compatible string "renesas,rcar-gen3-vin" was added before the
Gen3 driver code was added but it's not possible to use. Each SoC in the
Gen3 series require SoC specific knowledge in the driver to function.
Remove it before it is added to any device tree descriptions.
media: cx88: Get rid of spurious call to cx8800_start_vbi_dma()
This was left over from the conversion to VB2, where the call was
getting invoked both in buffer_queue and start_streaming, which
was intermittently causing invalid opcodes on the VBI RISC queue.
This change effectively mirrors the exact same change Hans Verkuil
made in cx88-video.c in commit 389208e1173e ("[media] cx88:
remove leftover start_video_dma() call").
Thanks to Daniel Glöckner for spotting the actual bug after I spent
several days trying to chase down the issue.
The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, but the implementation in this
driver returns an 'int'.
Fix this by returning 'netdev_tx_t' in this driver too.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
media: frontends: fix ops get_algo()'s return type
The method dvb_frontend_ops::get_frontend_algo() is defined as
returning an 'enum dvbfe_algo', but the implementation in this
driver returns an 'int'.
Fix this by returning 'enum dvbfe_algo' on drivers.
[mchehab+samsung@kernel.org: merge similar patches and patch
ddbridge-mci.c the same way] Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Anders Roxell [Mon, 23 Apr 2018 19:31:39 +0000 (15:31 -0400)]
media: drivers: media: platform: make VIDEO_VIU depend on I2C
Commit 7378f1149884 ("media: omap2: omapfb: allow building it with
COMPILE_TEST") broke compilation without CONFIG_I2C selected.
drivers/media/platform/fsl-viu.c: In function ‘viu_of_probe’:
drivers/media/platform/fsl-viu.c:1452:7: error: implicit declaration of function ‘i2c_get_adapter’; did you mean ‘i2c_lock_adapter’? [-Werror=implicit-function-declaration]
ad = i2c_get_adapter(0);
^~~~~~~~~~~~~~~
i2c_lock_adapter
drivers/media/platform/fsl-viu.c:1452:5: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
ad = i2c_get_adapter(0);
^
drivers/media/platform/fsl-viu.c:1534:2: error: implicit declaration of function ‘i2c_put_adapter’; did you mean ‘i2c_lock_adapter’? [-Werror=implicit-function-declaration]
i2c_put_adapter(ad);
^~~~~~~~~~~~~~~
i2c_lock_adapter
Added I2C dependency in order to make all configurations work again.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Commit ee93340e98bc ("media: ngene: deduplicate I2C adapter evaluation")
added a helper to evaluate the I2C adapter to be used for demod/tuner
attachment based on the given ngene_channel, and that helper is used in
many attach functions to initialise the i2c_adapter variable. However,
for some reason in tuner_attach_stv6110() and demod_attach_stv0900(), the
adapter evaluation wasn't removed as in all other functions. Fix (or
finalize, even) the helper use by cleaning up the superfluous I2C adapter
evaluation leftover in these two functions.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Colin Ian King [Wed, 18 Apr 2018 15:06:17 +0000 (11:06 -0400)]
media: include/media: fix missing | operator when setting cfg
The value from a readl is being masked with ITE_REG_CIOCAN_MASK however
this is not being used and cfg is being re-assigned. I believe the
assignment operator should actually be instead the |= operator.
Detected by CoverityScan, CID#1467987 ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
media: tuners: add new i2c driver for Sharp qm1d1b0004 ISDB-S tuner
The tuner is used in Earthsoft PT1/PT2 DVB boards,
and the driver was extraced from (the former) va1j5jf8007s.c of PT1.
it might contain PT1 specific configs.
This patch adds a PLL "description" of Philips TDA6651 for ISDB-T.
It was extracted from (the former) va1j5jf8007t.c of EarthSoft PT1,
thus the desc might include PT1 specific configs.
media: dvb-usb-v2/gl861: use usleep_range() for short delay
As the kernel doc "timers-howto.txt" reads,
short delay with msleep() can take much longer.
In a case of raspbery-pi platform where CONFIG_HZ_100 was set,
it actually affected the init of Friio devices
since it issues lots of i2c transactions with short delay.
media: i2c: tvp5150: Use the correct comment style
This patch resolves checkpatch.pl warnings:
WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
Samuel Williams [Sun, 1 Apr 2018 15:00:27 +0000 (11:00 -0400)]
media: bttv: Fixed oops error when capturing at yuv410p
When capturing at yuv410p, sg_next was called too many times when chroma is
false, eventually returning NULL. This patch does fix this for my hardware.
Signed-off-by: Samuel Williams <sam8641@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Sat, 17 Mar 2018 14:55:32 +0000 (10:55 -0400)]
media: ddbridge, cxd2099: include guard, fix unneeded NULL init, strings
Three really tiny minors in this single commit which all on their own
would just clutter up the commit history unnecessarily:
* ddbridge-regs.h is lacking an include guard. Add it.
* Fix an unnecessary NULL initialisation in ddbridge-ci. The declaration
of the ci struct ptr is immediately followed by kzalloc().
* Clarify that the CXD2099AR is a Sony device in the cxd2099 driver at a
few places including Kconfig.
The -Warray-bounds warning in gcc-8 triggers for a newly added file:
drivers/media/spi/cxd2880-spi.c: In function 'cxd2880_write_reg':
drivers/media/spi/cxd2880-spi.c:111:3: error: 'memcpy' forming offset [133, 258] is out of the bounds [0, 132] of object 'send_data' with type 'u8[132]' {aka 'unsigned char[132]'} [-Werror=array-bounds]
The problem appears to be that we have two range checks in this function,
first comparing against BURST_WRITE_MAX (128) and then comparing against
a literal '255'. The logic checking the buffer size looks at the second
one and decides that this might be the actual maximum data length.
This is understandable behavior from the compiler, but the code is actually
safe. Since the first check is already shorter, we can remove the loop
and only leave that. To be on the safe side in case BURST_WRITE_MAX might
be increased, I'm leaving the check against U8_MAX.
Fixes: bd24fcddf6b8 ("media: cxd2880-spi: Add support for CXD2880 SPI interface") Cc: Martin Sebor <msebor@gmail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
If state is not initialized or is freed, we can't use it:
drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: potential null dereference 'state'. (kzalloc returns null)
drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: we previously assumed 'state' could be null (see line 878)
drivers/media/dvb-frontends/lgdt330x.c:920 lgdt330x_probe() error: dereferencing freed memory 'state'
Fixes: 23ba635d45f5 ("media: lgdt330x: convert it to the new I2C binding way") Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Please notice that there's no scale indication at the driver.
As we don't have the datasheet, let's assume that it is receiving
data at a rate of 10.000 packets per second. Ideally, this should
be read or estimated.
In order to avoid flooding I2C bus with data, the maximum
polling rate for those stats was set to 1 second.
As we're about to convert this driver to use the new i2c
binding way, let's first solve most coding style issues,
in order to avoid mixing coding style changes with code
changes.
Commit be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner
functionality") removed the logic with sets the alternate for the DVB
device. Without setting the right alternate, the device won't be
able to submit URBs, and userspace fails with -EMSGSIZE:
ERROR DMX_SET_PES_FILTER failed (PID = 0x2000): 90 Message too long
Daniel Scheller [Mon, 9 Apr 2018 16:47:50 +0000 (12:47 -0400)]
media: ddbridge: add hardware defs and PCI IDs for MCI cards
Add PCI IDs and ddb_info for the new MCI-based MaxSX8 cards. Also add
needed defines so the cards can be hooked up into ddbridge's probe and
attach handling.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:49 +0000 (12:47 -0400)]
media: ddbridge/max: implement MCI/MaxSX8 attach function
Implement frontend attachment as ddb_fe_attach_mci() into the
ddbridge-max module. The MaxSX8 MCI cards are part of the Max card series
and make use of the LNB controller driven by the already existing lnb
functionality, so here's where this code belongs to.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:48 +0000 (12:47 -0400)]
media: ddbridge: initial support for MCI-based MaxSX8 cards
This adds initial support for the new MCI-based (micro-code interface)
DD cards, with the first one being the MaxSX8 eight-tuner DVB-S/S2/S2X
PCIe card. The MCI is basically a generalized interface implemented in
the card's FPGA firmware and usable for all kind of cards, without the
need to implement any demod/tuner drivers as this interface "hides" any
I2C interface to the actual ICs, in other words any required driver is
implemented in the card firmware.
At this stage, the MCI interface is quite rudimentary with things like
signal statistics reporting missing, but is already working to serve
DVB streams to DVB applications. Missing functionality will be enabled
over time.
This implements only the ddbridge-mci sub-object and hooks it up to the
Makefile so the object gets build. The upcoming commits hook this module
into all other ddbridge parts where required, including device IDs etc.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:47 +0000 (12:47 -0400)]
media: ddbridge: support dummy tuners with 125MByte/s dummy data stream
The Octopus V3 and Octopus Mini devices support set up of a dummy tuner
mode on port 0 that will deliver a continuous data stream of 125MBytes
per second while raising IRQs and filling the DMA buffers, which comes
handy for some stress, PCIe link and IRQ handling testing. The dummy
frontend is registered using dvb_dummy_fe's QAM dummy frontend. Set
ddbridge.dummy_tuner to 1 to enable this on the supported cards.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:46 +0000 (12:47 -0400)]
media: ddbridge: make DMA buffer count and size modparam-configurable
Make the number of DMA buffers and their size configurable using module
parameters. Being able to set these to a higher number might help on
busy systems when handling overall high data rates without having to
edit the driver sources and recompile things.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:45 +0000 (12:47 -0400)]
media: ddbridge: set devid entry for link 0
Currently, /sys/class/ddbridgeX/devid always reports 0 due to devid not
being set at all. Set the devid field alongside while storing all other
hardware ID data.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:44 +0000 (12:47 -0400)]
media: ddbridge: fix output buffer check
A 188 byte gap has to be left between the writer and the consumer. This
requires 2*188 bytes available to be able to write to the output buffers.
So, change ddb_output_free() to report free bytes according to this rule.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Improve IRQ handling in the separated MSG/I2C and IO/TSDATA handlers by
applying a mask for recognized bits immediately upon reading the IRQ mask
from the hardware, so only the bits/IRQs that actually were set will be
acked.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:41 +0000 (12:47 -0400)]
media: ddbridge: add macros to handle IRQs in nibble and byte blocks
Currently, each IRQ requires one IRQ_HANDLE() line to call each IRQ
handler that was set up. Add a IRQ_HANDLE_NIBBLE() and IRQ_HANDLE_BYTE()
macro to call all handlers in blocks of four (_NIBBLE) or eight (_BYTE)
handlers at a time, to make this construct more compact.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:40 +0000 (12:47 -0400)]
media: ddbridge: add helper for IRQ handler setup
Introduce the ddb_irq_set() helper function (along with a matching
prototype in ddbridge.h) to improve the set up of the IRQ handlers
and handler_data, and rework storing this data into the ddb_link
using a new ddb_irq struct. This also does the necessary rework
of affected variables. And while at it, always do queue_work in
input_handler() as there's not much of a difference to directly
calling input_work if there's no ptr at input->redi, or queueing
this call.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:39 +0000 (12:47 -0400)]
media: ddbridge: request/free_irq using pci_irq_vector, enable MSI-X
Instead of trying to manage IRQ numbers on itself, utilise the
pci_irq_vector() function to do this, which will take care of correct IRQ
numbering for MSI and non-MSI IRQs. While at it, request and enable MSI-X
interrupts for hardware (boards and cards) that support this.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:38 +0000 (12:47 -0400)]
media: ddbridge: move MSI IRQ cleanup to a helper function
Introduce the ddb_msi_exit() helper to be used for cleaning up previously
allocated MSI IRQ vectors. Deduplicates code and makes things look
cleaner as for all cleanup work the CONFIG_PCI_MSI ifdeffery is only
needed in the helper now. Also, replace the call to the deprecated
pci_disable_msi() function with pci_free_irq_vectors().
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:37 +0000 (12:47 -0400)]
media: ddbridge: move ddb_wq and the wq+class initialisation to -core
Move the ddbridge module initialisation and cleanup code to ddbridge-core
and set up the ddb_wq workqueue there, and create and destroy the ddb
device class there aswell. Due to this, the prototypes for ddb_wq,
ddb_class_create() and ddb_class_destroy() aren't required in ddbridge.h
anymore, so remove them. Also, declare ddb_wq and the ddb_class_*()
functions static.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:36 +0000 (12:47 -0400)]
media: ddbridge: move modparams to ddbridge-core.c
Besides the 'msi' module option, all options are used from within
ddbridge-core only, so move them over from ddbridge-main, and declare the
associated variables static. Since the prototypes in ddbridge.h aren't
necessary anymore now, remove them. As a side effect, this has the benefit
of aligning things more with the dddvb upstream.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Daniel Scheller [Mon, 9 Apr 2018 16:47:35 +0000 (12:47 -0400)]
media: dvb-frontends/stv0910: fix CNR reporting in read_snr()
The CNR value determined in read_snr() is reported via the wrong variable.
It uses FE_SCALE_DECIBEL, which implies the value to be reported in svalue
instead of uvalue. Fix this accordingly.
Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/i2c/video-i2c.c:55:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static struct v4l2_fmtdesc amg88xx_format = {
^~~~~
drivers/media/i2c/video-i2c.c:59:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
const static struct v4l2_frmsize_discrete amg88xx_size = {
^~~~~