platform/kernel/linux-starfive.git
6 years agomedia: ov772x: Re-organize in-code comments
Jacopo Mondi [Fri, 2 Mar 2018 14:46:39 +0000 (09:46 -0500)]
media: ov772x: Re-organize in-code comments

A lot of comments that would fit a single line were spread on two or
more lines. Also fix capitalization and punctuation where appropriate.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ov772x: Align function parameters
Jacopo Mondi [Fri, 2 Mar 2018 14:46:38 +0000 (09:46 -0500)]
media: ov772x: Align function parameters

Align all function parameters to first open brace when declaring
functions.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tw9910: Replace msleep(1) with usleep_range
Jacopo Mondi [Fri, 2 Mar 2018 14:46:37 +0000 (09:46 -0500)]
media: tw9910: Replace msleep(1) with usleep_range

msleep() can sleep up to 20ms.

As suggested by Documentation/timers/timers_howto.txt replace it with
usleep_range() with up to 5ms delay.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tw9910: Sort includes alphabetically
Jacopo Mondi [Fri, 2 Mar 2018 14:46:36 +0000 (09:46 -0500)]
media: tw9910: Sort includes alphabetically

Sort include directives alphabetically to ease maintenance.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tw9910: Mixed style fixes
Jacopo Mondi [Fri, 2 Mar 2018 14:46:35 +0000 (09:46 -0500)]
media: tw9910: Mixed style fixes

Two minor style fixes, align function parameter and remove un-necessary
spaces.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tw9910: Miscellaneous neatening
Joe Perches [Thu, 1 Mar 2018 12:01:22 +0000 (07:01 -0500)]
media: tw9910: Miscellaneous neatening

Yet more whitespace and style neatening

o Add blank lines before returns
o Reverse a logic test and return early on error
o Move formats to same line as dev_<level> calls
o Remove an unnecessary period from a logging message

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tw9910: Whitespace alignment
Joe Perches [Thu, 1 Mar 2018 11:50:22 +0000 (06:50 -0500)]
media: tw9910: Whitespace alignment

Update multiline statements to open parenthesis.
Update a ?: to a single line.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tw9910: Re-organize in-code comments
Jacopo Mondi [Fri, 2 Mar 2018 14:46:34 +0000 (09:46 -0500)]
media: tw9910: Re-organize in-code comments

A lot of comments that would fit a single line were spread on two or
more lines. Also fix capitalization and punctuation where appropriate.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: add proper polling to the dvbdev_ci file ops
Daniel Scheller [Sun, 25 Feb 2018 17:06:56 +0000 (12:06 -0500)]
media: ngene: add proper polling to the dvbdev_ci file ops

Implement the poll callback for the dvbdev_ci file ops. The ts_poll()
function queries the DVB ring buffers for available data and space, and
reports this as appropriate. Also, set the dvb_device readers, writers
and users to proper values (one reader, one writer, two users).

This fixes the raw CI TS transport in conjunction with TVheadend's
DDCI functionality.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: don't treat non-existing demods as error
Daniel Scheller [Sun, 25 Feb 2018 12:31:38 +0000 (07:31 -0500)]
media: ngene: don't treat non-existing demods as error

When probing the I2C busses in cineS2_probe(), it's no error when there's
no hardware connected to the probed expansion connector, so print this
informal message with info severity.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: check for CXD2099AR presence before attaching
Daniel Scheller [Sun, 25 Feb 2018 12:31:37 +0000 (07:31 -0500)]
media: ngene: check for CXD2099AR presence before attaching

Currently, if there's no CXD2099AR attached to any expansion connector of
the ngene hardware, it will complain with this on every module load:

    cxd2099 1-0040: No CXD2099AR detected at 0x40
    cxd2099: probe of 1-0040 failed with error -5
    ngene 0000:02:00.0: CXD2099AR attach failed

This happens due to the logic assuming such hardware is always there and
blindly tries to attach the cxd2099 I2C driver. Rather add a probe
function (in ngene-cards.c with a prototype in ngene.h) to check for
the existence of such hardware before probing, and don't try further if
no CXD2099 was found.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: deduplicate I2C adapter evaluation
Daniel Scheller [Sun, 25 Feb 2018 12:31:36 +0000 (07:31 -0500)]
media: ngene: deduplicate I2C adapter evaluation

The I2C adapter evaluation (based on chan->number) is duplicated at
several places (tuner_attach_() functions, demod_attach_stv0900() and
cineS2_probe()). Clean this up by wrapping that construct in a separate
function which all users of that can pass the ngene_channel pointer and
get the correct I2C adapter from.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: add support for DuoFlex S2 V4 addon modules
Daniel Scheller [Sun, 25 Feb 2018 12:31:35 +0000 (07:31 -0500)]
media: ngene: add support for DuoFlex S2 V4 addon modules

Add support for the STV0910/STV6111/LNBH25 based DuoFlex S2 V4 DVB-S2
addon modules by recognizing them from their XO2 type value and using
the auxiliary stv0910, stv6111 and lnbh25 driver to form a complete
DVB frontend.

This also adds autoselection (if MEDIA_SUBDRV_AUTOSELECT) of the STV0910,
STV6111 and LNBH25 demod/tuner/LNB-IC drivers to Kconfig.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: add support for Sony CXD28xx-based DuoFlex modules
Daniel Scheller [Sun, 25 Feb 2018 12:31:34 +0000 (07:31 -0500)]
media: ngene: add support for Sony CXD28xx-based DuoFlex modules

Recognize (probe) and support (attach) all Sony CXD28xx based DuoFlex
addon modules/cards, namely the DuoFlex CT2 (CXD2837), ISDB-T (CXD2838),
C2T2 (CXD2843) and C2T2I (CXD2854). Since all these modules are equipped
with a MachXO2 interface, that support is required for the hardware to
work. This functionality utilises the auxiliary cxd2841er and tda18212
drivers.

This also adds autoselection (if MEDIA_SUBDRV_AUTOSELECT) of the CXD2841ER
demod driver to Kconfig. The __maybe_unused annotation can now be removed
from the xo2names array.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: add XO2 module support
Daniel Scheller [Sun, 25 Feb 2018 12:31:33 +0000 (07:31 -0500)]
media: ngene: add XO2 module support

Detect and initialise modules equipped with XO2 interfaces (Lattice
MachXO2). This requires a few more I2C transfer functions which this adds
as well. Defines for the different possible (available) module types are
added to ngene.h. The support for the actual tuners contained on these
addon modules is kept separate from this commit and is being added with
the next commits.

The xo2names array is temporarily marked __maybe_unused to silence a
corresponding compiler warning at this stage.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: support STV0367 DVB-C/T DuoFlex addons
Daniel Scheller [Sun, 25 Feb 2018 12:31:32 +0000 (07:31 -0500)]
media: ngene: support STV0367 DVB-C/T DuoFlex addons

Add support for STV0367+TDA18212 based DuoFlex CT addon modules. For this,
add a demod probe function and all necessary demod/tuner attach functions
which use existing auxiliary drivers (stv0367 and tda18212) to support
this hardware. As tda18212 is an I2C client driver, proper cleanup code
is added to the deregistration sequence in ngene-core. To not cause use-
after-free situations when there's a CXD2099 I2C client connected, which
is rather freed in ngene-core.c:cxd_detach(), add i2c_client_fe to struct
ngene_channel to keep track if the i2c_client was allocated by a frontend
driver, rather than the CI code paths. Also move the I2C access functions
to the top of the file and add the required read_regs() function for the
tda18212 ping to work.

This adds autoselection (if MEDIA_SUBDRV_AUTOSELECT) of the STV0367 demod
driver and TDA18212 tuner driver to Kconfig aswell.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: use defines to identify the demod_type
Daniel Scheller [Sun, 25 Feb 2018 12:31:31 +0000 (07:31 -0500)]
media: ngene: use defines to identify the demod_type

Make it more clear which demod_type is used for which hardware by having
defines for the possible demod_type values. With that, change the
demod_type evaluation in tuner_attach_probe() to a switch-case instead
of an if() for each possible value.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: convert kernellog printing from printk() to dev_*() macros
Daniel Scheller [Sun, 25 Feb 2018 12:31:30 +0000 (07:31 -0500)]
media: ngene: convert kernellog printing from printk() to dev_*() macros

Convert all printk() and pr_*() kernel log printing to rather use the
dev_*() macros. Not only is it discouraged to use printk() (checkpatch
even complains about that), but also this helps identifying the exact PCI
device for any printed event, and it makes almost all printing shorter
in terms of code style since there's no need to use KERN_* DEVICE_NAME
any more (dev_*() will take care of this).

Since the dprintk macro define isn't used anymore, remove it.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: add two additional PCI IDs
Daniel Scheller [Sun, 25 Feb 2018 12:31:29 +0000 (07:31 -0500)]
media: ngene: add two additional PCI IDs

Add two more device IDs for cards supported by the ngene driver.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_ca_en50221: fix severity of successful CAM init log message
Daniel Scheller [Sat, 24 Feb 2018 14:55:57 +0000 (09:55 -0500)]
media: dvb_ca_en50221: fix severity of successful CAM init log message

A successful CA module initialisation isn't an error. Change the
log print to info severity accordingly.

Cc: Jasmin Jessich <jasmin@anw.at>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: usb: don't initialize vars if not needed
Markus Elfring [Thu, 22 Feb 2018 20:45:47 +0000 (15:45 -0500)]
media: usb: don't initialize vars if not needed

Some local variables will be set to an appropriate value before usage.
Thus omit explicit initialisations at the beginning of these functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Alexey Klimov <klimov.linux@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ov772x: constify ov772x_frame_intervals
Mauro Carvalho Chehab [Tue, 6 Mar 2018 15:34:44 +0000 (10:34 -0500)]
media: ov772x: constify ov772x_frame_intervals

The values on this array never changes. Make it const.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2168: change ts bus control logic
Brad Love [Mon, 12 Feb 2018 20:19:04 +0000 (15:19 -0500)]
media: si2168: change ts bus control logic

Move the ts bus control function moved higher, enabling it
after configuring frontend and removeing ts_bus_ctrl callback.

While here, also add an error checking and re-add a comment
that were removed by commit 445877742ce3 ("media: si2168:
Add ts bus coontrol, turn off bus on sleep").

[mchehab@s-opensource.com: I ended by applying the first version,
 instead of the right one. So, this patch contains the diff and
 the v2 changelog instead]

Fixes: 445877742ce3 ("media: si2168: Add ts bus coontrol, turn off bus on sleep")

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv0910: rework and fix DiSEqC send
Daniel Scheller [Fri, 9 Feb 2018 18:22:49 +0000 (13:22 -0500)]
media: dvb-frontends/stv0910: rework and fix DiSEqC send

Rework both DiSEqC send functions (send_master_cmd() and send_burst()) to
utilise the new SET_REG() and SET_FIELD() macros. Esp. due to SET_FIELD(),
this makes sure that not all bits (with unrelated purposes) are always
rewritten, but only those needed for sending DiSEqC commands. In
send_burst(), this makes sure that DISEQC_MODE isn't changed from 3 to 2
inbetween when sending SEC_MINI_A. Also, change both functions to write
DISEQC_MODE first before setting DIS_PRECHARGE. This makes diseqc control
work more reliable for "fullblown" DiSEqC strings in VDR's diseqc.conf in
combination with certain multiswitches.

Fixes: 448461af0e19 ("media: dvb-frontends/stv0910: implement diseqc_send_burst")

Reported-by: Helmut Auer <post@helmutauer.de>
Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Helmut Auer <post@helmutauer.de>
Tested-by: Richard Scobie <rascobie@slingshot.co.nz>
Tested-by: Dietmar Spingler <d_spingler@freenet.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cxd2099: move driver out of staging into dvb-frontends
Daniel Scheller [Thu, 8 Feb 2018 19:53:17 +0000 (14:53 -0500)]
media: cxd2099: move driver out of staging into dvb-frontends

According to the TODO file, this driver only landed in staging because of
the way device nodes and data transfers are handled. Besides that this way
(use of secX devices) has become sort of standard to date (ie. VDR
supports this literally since ages via the ddci plugin, TVHeadend received
this functionality lately, and minisatip being currently worked on
regarding this), most importantly this I2C client only driver isn't even
responsible for setting up device nodes, not for handling data
transfer and so on, but only serves as interface for the dvb_ca_en50221
subsystem, just like every other DVB card out in the wild, with hard-wired
or such flexible CA interfaces. And, it would even work with cards having
the cxd2099 controller hard-wired.

Also, this driver received quite some love and even is a proper I2C client
driver by now. So, as this driver acts as a EN50221 frontend device, move
it to dvb-frontends. There is no need to keep it buried in staging.

This commit also updates all affected Kconfig and Makefile's, and adds
MEDIA_AUTOSELECT depends to ddbridge and ngene.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ngene: adapt cxd2099 attach to the new i2c_client way
Daniel Scheller [Thu, 8 Feb 2018 19:53:15 +0000 (14:53 -0500)]
media: ngene: adapt cxd2099 attach to the new i2c_client way

Change the way the cxd2099 hardware is being attached to the new I2C
client interface way.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: staging/cxd2099: convert to regmap API
Daniel Scheller [Sat, 17 Feb 2018 15:03:23 +0000 (10:03 -0500)]
media: staging/cxd2099: convert to regmap API

Convert the cxd2099 driver to use regmap for I2C accesses, removing all
own i2c_*() functions. With that, make the driver a proper I2C client
driver. This also adds the benefit of having a proper cleanup function
(cxd2099_remove() in this case) that takes care of resource cleanup
upon I2C client deregistration.

At this point, keep the static inline declared cxd2099_attach()
function so that drivers using the legacy/proprietary style attach way
still compile, albeit lacking the cxd2099 driver functionality. This
is taken care of in the next two patches.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge/ci: further deduplicate code/logic in ddb_ci_attach()
Daniel Scheller [Thu, 8 Feb 2018 19:53:12 +0000 (14:53 -0500)]
media: ddbridge/ci: further deduplicate code/logic in ddb_ci_attach()

Deduplicate the checks for a valid ptr in port->en, and also handle the
default case to also catch eventually yet unsupported CI hardware.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing with...
Wolfram Sang [Mon, 5 Feb 2018 20:10:00 +0000 (15:10 -0500)]
media: v4l: dvb-frontends: stb0899: fix comparison to bitshift when dealing with a mask

Due to a typo, the mask was destroyed by a comparison instead of a bit
shift.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: sec: Remove PLAT_S5P dependency
Ulf Magnusson [Mon, 5 Feb 2018 01:21:29 +0000 (20:21 -0500)]
media: sec: Remove PLAT_S5P dependency

The PLAT_S5P symbol was removed in commit d78c16ccde96 ("ARM: SAMSUNG:
Remove remaining legacy code").

Remove the PLAT_S5P dependency from VIDEO_SAMSUNG_S5P_CEC.

Discovered with the
https://github.com/ulfalizer/Kconfiglib/blob/master/examples/list_undefined.py
script.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: mantis: remove mantis_vp3028.c/mantis_vp3028.h
Corentin Labbe [Sun, 28 Jan 2018 20:06:18 +0000 (15:06 -0500)]
media: mantis: remove mantis_vp3028.c/mantis_vp3028.h

Thoses files are unused since commit b3b961448f70 ("V4L/DVB (13795): [Mantis/Hopper] Code overhaul, add Hopper devices into the PCI ID list")
8 year after, we could remove it.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: drx-j remove bsp_i2c.h
Corentin Labbe [Fri, 26 Jan 2018 20:14:05 +0000 (15:14 -0500)]
media: drx-j remove bsp_i2c.h

bsp_i2c.h is unused since commit ffe7c4f92183 ("[media] drx-j: Get rid of drx39xyj/bsp_tuner.h")
Remove it from tree.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: sr030pc30: prevent array underflow in try_fmt()
Dan Carpenter [Thu, 25 Jan 2018 14:15:25 +0000 (09:15 -0500)]
media: sr030pc30: prevent array underflow in try_fmt()

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l: omap_vout: vrfb: Use the wrapper for prep_interleaved_dma()
Peter Ujfalusi [Fri, 19 Jan 2018 13:34:34 +0000 (08:34 -0500)]
media: v4l: omap_vout: vrfb: Use the wrapper for prep_interleaved_dma()

Instead of directly accessing to dmadev->device_prep_interleaved_dma() use
the dmaengine_prep_interleaved_dma() wrapper instead.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Enable inversion for Solo/Dual HD DVB models
Brad Love [Wed, 17 Jan 2018 21:32:36 +0000 (16:32 -0500)]
media: em28xx: Enable inversion for Solo/Dual HD DVB models

Hauppauge Solo/Dual HD DVB models use a si2157 tuner, which is set to
produce inverted spectrum. This configures the si2168 DVB demod for
inverted spectrum on both affected models.

[mchehab@s-opensource.com: rebased on the top of upstream]
Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2168: Add spectrum inversion property
Brad Love [Wed, 17 Jan 2018 22:31:58 +0000 (17:31 -0500)]
media: si2168: Add spectrum inversion property

Some tuners produce inverted spectrum, but the si2168 is not
currently set up to accept it. This adds an optional parameter
to set the frontend up to receive inverted spectrum.

Parameter is optional and only boards who enable inversion
will utilize this.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: s3c-camif: fix out-of-bounds array access
Arnd Bergmann [Tue, 16 Jan 2018 21:52:15 +0000 (16:52 -0500)]
media: s3c-camif: fix out-of-bounds array access

While experimenting with older compiler versions, I ran
into a warning that no longer shows up on gcc-4.8 or newer:

drivers/media/platform/s3c-camif/camif-capture.c: In function '__camif_subdev_try_format':
drivers/media/platform/s3c-camif/camif-capture.c:1265:25: error: array subscript is below array bounds

This is an off-by-one bug, leading to an access before the start of the
array, while newer compilers silently assume this undefined behavior
cannot happen and leave the loop at index 0 if no other entry matches.

As Sylvester explains, we actually need to ensure that the
value is within the range, so this reworks the loop to be
easier to parse correctly, and an additional check to fall
back on the first format value for any unexpected input.

I found an existing gcc bug for it and added a reduced version
of the function there.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69249#c3
Fixes: babde1c243b2 ("[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2168: Announce frontend creation failure
Brad Love [Fri, 12 Jan 2018 16:19:40 +0000 (11:19 -0500)]
media: si2168: Announce frontend creation failure

The driver outputs on success, but is silent on failure. Give
one message that probe failed.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lgdt3306a: Announce successful creation
Brad Love [Fri, 12 Jan 2018 16:19:41 +0000 (11:19 -0500)]
media: lgdt3306a: Announce successful creation

The driver is near silent, this adds a simple announcement at the
end of probe after the chip has been detected and upgrades a debug
message to error if probe has failed.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2168: Add ts bus coontrol, turn off bus on sleep
Brad Love [Fri, 12 Jan 2018 16:19:39 +0000 (11:19 -0500)]
media: si2168: Add ts bus coontrol, turn off bus on sleep

Includes a function to set TS MODE property os si2168. The function
either disables the TS output bus, or sets mode to config option.

When going to sleep the TS bus is turned off, this makes the driver
compatible with multiple frontend usage.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx231xx: Add second i2c demod client
Brad Love [Fri, 12 Jan 2018 16:19:37 +0000 (11:19 -0500)]
media: cx231xx: Add second i2c demod client

Include ability to add a i2c device style frontend to cx231xx USB
bridge. All current boards set to use frontend[0]. Changes are
backwards compatible with current behaviour.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx231xx: Add second frontend option
Brad Love [Fri, 12 Jan 2018 16:19:36 +0000 (11:19 -0500)]
media: cx231xx: Add second frontend option

Include ability to add a second dvb attach style frontend to cx231xx
USB bridge. All current boards set to use frontend[0]. Changes are
backwards compatible with current behaviour.

[mchehab@s-opensource.com: fix some coding style issues]
Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cxusb: restore RC_MAP for MyGica T230
Stefan Brüns [Tue, 9 Jan 2018 23:33:39 +0000 (18:33 -0500)]
media: cxusb: restore RC_MAP for MyGica T230

Commit f8585ce655e9 ("[media] dvb-usb-cxusb: Geniatech T230C support")
sneaked in an unrelated change for the older T230 (not C) model.

As the commit was reverted this change was reverted too,
although likely correct.

Fixes: f8585ce655e9 ("[media] dvb-usb-cxusb: Geniatech T230C support")
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-usb-cxusb: Geniatech T230C support
Evgeny Plehov [Tue, 9 Jan 2018 23:33:38 +0000 (18:33 -0500)]
media: dvb-usb-cxusb: Geniatech T230C support

This reverts commit f8585ce655e9cdeabc38e8e2580b05735110e4a5.

The T230C is handled by the dvb-usb-v2/dvbsky.c driver, which should
be preferred over a dvb-usb (v1) driver.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx231xx: Add support for Hauppauge HVR-975
Brad Love [Tue, 9 Jan 2018 16:44:26 +0000 (11:44 -0500)]
media: cx231xx: Add support for Hauppauge HVR-975

Hauppauge HVR-975 is hybrid NTSC/PAL, QAM/ATSC, and DVB-C/T/T2 usb device.

Only ATSC/QAM front end is initially active. Second frontend support is
work in progress.

CX23102 + LG3306A/Si2168(WiP) + Si2157

Changes since v1:
- removed double semicolon

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx231xx: Add support for Hauppauge HVR-935C
Brad Love [Tue, 9 Jan 2018 16:38:35 +0000 (11:38 -0500)]
media: cx231xx: Add support for Hauppauge HVR-935C

HVR-935C is hybrid PAL, DVB-C/T/T2 usb device.

CX23102 + Si2168 + Si2157

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dibx000_common: use strlcpy() instead of strncpy()
Xiongfeng Wang [Mon, 8 Jan 2018 12:52:34 +0000 (07:52 -0500)]
media: dibx000_common: use strlcpy() instead of strncpy()

gcc-8 reports

drivers/media/dvb-frontends/dibx000_common.c: In function
'i2c_adapter_init':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 48 equals destination size [-Wstringop-truncation]

We need to use strlcpy() to make sure the dest string is
nul-terminated.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: exynos4-is: make array 'cmd' static, shrinks object size
Colin Ian King [Sat, 6 Jan 2018 16:03:27 +0000 (11:03 -0500)]
media: exynos4-is: make array 'cmd' static, shrinks object size

Don't populate the const read-only array 'cmd' on the stack but instead
make it static. Makes the object code smaller by 38 bytes:

Before:
   text    data     bss     dec     hex filename
   4950     868       0    5818    16ba fimc-is-regs.o

After:
   text    data     bss     dec     hex filename
   4824     956       0    5780    1694 fimc-is-regs.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx23885: Add support for new Hauppauge QuadHD (885)
Brad Love [Sat, 6 Jan 2018 00:48:22 +0000 (19:48 -0500)]
media: cx23885: Add support for new Hauppauge QuadHD (885)

Add new QuadHD digital only PCIe boards to driver list.
Differentiate them from 888 digital/analog QuadHD models.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx23885: Add support for Hauppauge PCIe Starburst2
Brad Love [Sat, 6 Jan 2018 00:48:21 +0000 (19:48 -0500)]
media: cx23885: Add support for Hauppauge PCIe Starburst2

Add new PCIe DVB-S/S2.
A single port Hauppauge HVR-5525

cx23885 + a8293 + m88rs6000t

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx23885: Add support for Hauppauge PCIe HVR1265 K4
Brad Love [Sat, 6 Jan 2018 00:48:20 +0000 (19:48 -0500)]
media: cx23885: Add support for Hauppauge PCIe HVR1265 K4

Add new PCIe board to driver list and board register/configure functions

cx23885 + lgdt3306a + si2157 digital/analog

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx23885: Enable new Hauppauge PCIe ImpactVCBe variant
Brad Love [Sat, 6 Jan 2018 00:48:19 +0000 (19:48 -0500)]
media: cx23885: Enable new Hauppauge PCIe ImpactVCBe variant

Add ID of new card revision to driver list

Analog PAL/NTSC capture.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-video: fix most coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 19:49:09 +0000 (14:49 -0500)]
media: em28xx-video: fix most coding style issues

There are a number of coding style issues at em28xx-video.
Fix most of them, by using checkpatch in strict mode to point
for it.

Automatic fixes were made with --fix-inplace, but those
were complemented by manual work.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-input: fix most coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 19:26:13 +0000 (14:26 -0500)]
media: em28xx-input: fix most coding style issues

There are a number of coding style issues at em28xx-input.
Fix most of them, by using checkpatch in strict mode to point
for it.

Automatic fixes were made with --fix-inplace, but those
were complemented by manual work.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-i2c: fix most coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 19:15:57 +0000 (14:15 -0500)]
media: em28xx-i2c: fix most coding style issues

There are a number of coding style issues at em28xx-i2c.
Fix most of them, by using checkpatch in strict mode to point
for it.

Automatic fixes were made with --fix-inplace, but those
were complemented by manual work.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-core: fix most coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 18:43:34 +0000 (13:43 -0500)]
media: em28xx-core: fix most coding style issues

There are a number of coding style issues at em28xx-core.
Fix most of them, by using checkpatch in strict mode to point
for it.

Automatic fixes were made with --fix-inplace, but those
were complemented by manual work.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-cards: rework the em28xx probing code
Mauro Carvalho Chehab [Sat, 3 Mar 2018 18:11:11 +0000 (13:11 -0500)]
media: em28xx-cards: rework the em28xx probing code

There is a complex loop there with identifies the em28xx
endpoints. It has lots of identations inside, and big names,
making harder to understand.

Simplify it by moving the main logic into a static function.

While here, rename "interface" var to "intf".

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-cards: fix most coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 17:41:32 +0000 (12:41 -0500)]
media: em28xx-cards: fix most coding style issues

There are a number of coding style issues, pointed by checkpatch
on strict mode.

Fix the ones that don't require code refactor here.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-camera: fix coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 17:17:54 +0000 (12:17 -0500)]
media: em28xx-camera: fix coding style issues

There are some coding style issues at em28xx-camera.

Fix them, by using checkpatch in strict mode to point for it.
Automatic fixes with --fix-inplace were complemented by manual
work.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-audio: fix coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 17:14:02 +0000 (12:14 -0500)]
media: em28xx-audio: fix coding style issues

There are a number of coding style issues at em28xx-audio.
Fix them, by using checkpatch in strict mode to point for it.
Automatic fixes with --fix-inplace were complemented by manual
work.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-reg.h: Fix coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 16:54:19 +0000 (11:54 -0500)]
media: em28xx-reg.h: Fix coding style issues

Use BIT() macros and fix one comment that is not following
the Kernel coding style.

It should be noticed that the registers bit masks should be
casted to unsigned char, as, otherwise, it would produce
warnings like:

drivers/media/usb/em28xx/em28xx-cards.c:81:33: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  {EM2820_R08_GPIO_CTRL, 0x6d,   ~EM_GPIO_4, 10},
                                 ^

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx.h: Fix most coding style issues
Mauro Carvalho Chehab [Sat, 3 Mar 2018 16:49:27 +0000 (11:49 -0500)]
media: em28xx.h: Fix most coding style issues

There used to have a lot of coding style issues there. The
ones detected by checkpatch, in strict mode, got fixed.

Still, we need to work more on it, in order to document all
struct fields using kernel-doc macros, but this will be done
on some future patch.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Add SPDX license tags where needed
Mauro Carvalho Chehab [Sat, 3 Mar 2018 15:43:14 +0000 (10:43 -0500)]
media: em28xx: Add SPDX license tags where needed

Most of the files there are missing a SPDX license tag. Add.

While here fix some DRIVER_LICENSE macro in order to reflect
the source file license, as some of the headers are GPL v2
only.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-dvb: do some coding style improvements
Mauro Carvalho Chehab [Sat, 3 Mar 2018 14:49:42 +0000 (09:49 -0500)]
media: em28xx-dvb: do some coding style improvements

As we're touching a lot on this file, let's solve several
Coding Style issues there using checkpatch --fix-inline --strict,
and manually adjusting the results.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: s5h14*.h: fix typos for CONTINUOUS
Mauro Carvalho Chehab [Sat, 3 Mar 2018 14:53:32 +0000 (09:53 -0500)]
media: s5h14*.h: fix typos for CONTINUOUS

There is a typo at the several s5h14*.h headers: continuous were
spelled incorrectly.

Fix it with this script:

for i in $(git grep -l S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK); do
sed s,S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,g -i $i
done
for i in $(git grep -l -i continous drivers/media); do sed s,CONTINOUS,CONTINUOUS,g -i $i; done

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx-dvb: simplify DVB module probing logic
Mauro Carvalho Chehab [Fri, 2 Mar 2018 14:23:04 +0000 (09:23 -0500)]
media: em28xx-dvb: simplify DVB module probing logic

The module probing logic there is a way more complex than
it should be, and requires some special magic to avoid
stack overflows when KASAN is enabled.

Solve it by creating ancillary functions to setup the
platform data and request module.

Now, the probing functions are cleaner and easier to understand.

As a side effect, the size of the module was reduced by
about 9.7% on x86_64:

Before this patch:
   text    data     bss     dec     hex filename
  51090   14192      96   65378    ff62 drivers/media/usb/em28xx/em28xx-dvb.o

After this patch:
   text    data     bss     dec     hex filename
  44743   14192      96   59031    e697 drivers/media/usb/em28xx/em28xx-dvb.o

Tested with a PCTV 461e device.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-core: add helper functions for I2C binding
Mauro Carvalho Chehab [Fri, 2 Mar 2018 15:21:16 +0000 (10:21 -0500)]
media: dvb-core: add helper functions for I2C binding

The dvb_attach()/dvb_detach() methods are ugly hacks designed
to keep using the I2C low-level API. The proper way is to
do I2C bus bindings instead.

Several modules were already converted to use it. Yet,
it is painful to use it, as lots of code need to be
duplicated.

Make it easier by providing two new helper functions:
- dvb_module_probe()
- dvb_module_release()

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: split up em28xx_dvb_init to reduce stack size
Arnd Bergmann [Mon, 11 Dec 2017 12:05:02 +0000 (07:05 -0500)]
media: em28xx: split up em28xx_dvb_init to reduce stack size

With CONFIG_KASAN, the init function uses a large amount of kernel stack:

drivers/media/usb/em28xx/em28xx-dvb.c: In function 'em28xx_dvb_init.part.4':
drivers/media/usb/em28xx/em28xx-dvb.c:2061:1: error: the frame size of 3232 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]

Using gcc-7 with -fsanitize-address-use-after-scope makes this even worse:

drivers/media/usb/em28xx/em28xx-dvb.c: In function 'em28xx_dvb_init':
drivers/media/usb/em28xx/em28xx-dvb.c:2069:1: error: the frame size of 4280 bytes is larger than 3072 bytes [-Werror=frame-larger-than=]

By splitting out each part of the switch/case statement that has its own local
variables into a separate function, no single one of them uses more than 500 bytes,
and with a noinline_for_stack annotation we can ensure that they are not merged
back together.

[mchehab@s-opensource.com: fix conflict with changeset
 be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality")]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: adjust I2C timeout according with I2C speed
Mauro Carvalho Chehab [Thu, 1 Mar 2018 17:54:06 +0000 (12:54 -0500)]
media: em28xx: adjust I2C timeout according with I2C speed

If the I2C speed is too slow, it should wait more for an
answer.

While here, change disconnected type from char to unsigned
int, just like all other bitmask fields there at em28xx
struct.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: constify most static structs
Mauro Carvalho Chehab [Thu, 1 Mar 2018 15:34:34 +0000 (10:34 -0500)]
media: em28xx: constify most static structs

There are several em28xx static structs that can now be constified.

That caused a significant reduction at data segment:

Before:
   text    data     bss     dec     hex filename
  85017   59588     576  145181   2371d drivers/media/usb/em28xx/em28xx.o

After:
   text    data     bss     dec     hex filename
 112345   32292     576  145213   2373d drivers/media/usb/em28xx/em28xx.o

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: stop rewriting device's struct
Mauro Carvalho Chehab [Thu, 1 Mar 2018 15:08:42 +0000 (10:08 -0500)]
media: em28xx: stop rewriting device's struct

Writing at the device's struct is evil, as two em28xx devices
may be using it. So, stop abusing it, storing the values
inside struct em28xx_dev.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: improve the logic with sets Xclk and I2C speed
Mauro Carvalho Chehab [Thu, 1 Mar 2018 14:59:28 +0000 (09:59 -0500)]
media: em28xx: improve the logic with sets Xclk and I2C speed

The logic there should be called on two places. Also,
ideally, it should not be modifying the device struct.

So, change the logic accordingly.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: don't use coherent buffer for DMA transfers
Mauro Carvalho Chehab [Tue, 27 Feb 2018 11:08:09 +0000 (06:08 -0500)]
media: em28xx: don't use coherent buffer for DMA transfers

While coherent memory is cheap on x86, it may cause performance
impacts on other archs. As we don't have any good reason to
use it, let's change the logic by allocating memory via kmalloc()
and letting the USB core to do the DMA mapping and memory free
for us.

While here, also fixes an issue that it was not de-allocating
memories if something gets wrong during memory block
allocation.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lgdt3306a: Fix a double kfree on i2c device remove
Brad Love [Fri, 5 Jan 2018 14:57:13 +0000 (09:57 -0500)]
media: lgdt3306a: Fix a double kfree on i2c device remove

Both lgdt33606a_release and lgdt3306a_remove kfree state, but _release is
called first, then _remove operates on states members before kfree'ing it.
This can lead to random oops/GPF/etc on USB disconnect.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lgdt3306a: Fix module count mismatch on usb unplug
Brad Love [Fri, 5 Jan 2018 14:57:12 +0000 (09:57 -0500)]
media: lgdt3306a: Fix module count mismatch on usb unplug

When used as an i2c device there is a module usage count mismatch on
removal, preventing the driver from being used thereafter. dvb_attach
increments the usage count so it is properly balanced on removal.

On disconnect of Hauppauge SoloHD/DualHD before:

lsmod | grep lgdt3306a
lgdt3306a              28672  -1
i2c_mux                16384  1 lgdt3306a

On disconnect of Hauppauge SoloHD/DualHD after:

lsmod | grep lgdt3306a
lgdt3306a              28672  0
i2c_mux                16384  1 lgdt3306a

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lgdt3306a: Add QAM AUTO support
Brad Love [Fri, 5 Jan 2018 00:04:19 +0000 (19:04 -0500)]
media: lgdt3306a: Add QAM AUTO support

As configured currently, modulation in the driver is set to auto detect,
no matter what the user sets modulation to. This leads to both QAM64
and QAM256 having the same effect. QAM AUTO is explicitly added here for
compatibility with scanning software who can use AUTO instead of doing
essentially the same scan twice.
Also included is a module option to enforce a specific QAM modulation if
desired. The true modulation is read before calculating the snr.
Changes are backwards compatible with current behaviour.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lgdt3306a: QAM streaming improvement
Brad Love [Fri, 5 Jan 2018 01:30:24 +0000 (20:30 -0500)]
media: lgdt3306a: QAM streaming improvement

Add some register updates required for stable viewing
on Cablevision in NY. Does not adversely affect other providers.

Changes since v1:
- Change upper case hex to lower case.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lgdt3306a: Set fe ops.release to NULL if probed
Brad Love [Fri, 5 Jan 2018 00:04:17 +0000 (19:04 -0500)]
media: lgdt3306a: Set fe ops.release to NULL if probed

If release is part of frontend ops then it is called in the
course of dvb_frontend_detach. The process also decrements
the module usage count. The problem is if the lgdt3306a
driver is reached via i2c_new_device, then when it is
eventually destroyed remove is called, which further
decrements the module usage count to negative. After this
occurs the driver is in a bad state and no longer works.
Also fixed by NULLing out the release callback is a double
kfree of state, which introduces arbitrary oopses/GPF.
This problem is only currently reachable via the em28xx driver.

On disconnect of Hauppauge SoloHD before:

lsmod | grep lgdt3306a
lgdt3306a              28672  -1
i2c_mux                16384  1 lgdt3306a

On disconnect of Hauppauge SoloHD after:

lsmod | grep lgdt3306a
lgdt3306a              28672  0
i2c_mux                16384  1 lgdt3306a

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Enable Hauppauge SoloHD rebranded 292e SE
Brad Love [Fri, 5 Jan 2018 00:04:16 +0000 (19:04 -0500)]
media: em28xx: Enable Hauppauge SoloHD rebranded 292e SE

Add a missing device to the driver table.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Add Hauppauge SoloHD/DualHD bulk models
Brad Love [Fri, 5 Jan 2018 00:04:15 +0000 (19:04 -0500)]
media: em28xx: Add Hauppauge SoloHD/DualHD bulk models

Add additional pids to driver list

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Increase max em28xx boards to max dvb adapters
Brad Love [Fri, 5 Jan 2018 00:04:14 +0000 (19:04 -0500)]
media: em28xx: Increase max em28xx boards to max dvb adapters

Maximum 4 em28xx boards is too low, this can be maxed out by two devices.
This allows all the dvb adapters in the system to be em28xx if so desired.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: USB bulk packet size fix
Brad Love [Fri, 5 Jan 2018 00:04:13 +0000 (19:04 -0500)]
media: em28xx: USB bulk packet size fix

Hauppauge em28xx bulk devices exhibit continuity errors and corrupted
packets, when run in VMWare virtual machines. Unknown if other
manufacturers bulk models exhibit the same issue. KVM/Qemu is unaffected.

According to documentation the maximum packet multiplier for em28xx in bulk
transfer mode is 256 * 188 bytes. This changes the size of bulk transfers
to maximum supported value and have a bonus beneficial alignment.

Before:

After:

This sets up USB to expect just as many bytes as the em28xx is set to emit.

Successful usage under load afterwards natively and in both VMWare
and KVM/Qemu virtual machines.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Bulk transfer implementation fix
Brad Love [Thu, 1 Feb 2018 22:04:37 +0000 (17:04 -0500)]
media: em28xx: Bulk transfer implementation fix

Set appropriate bulk/ISOC transfer multiplier on capture start.
This sets ISOC transfer to USB endpoint configuration
This sets bulk transfer to 48128 bytes (188 * 256)

The bulk multiplier is maximum allowed according to Empia.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: constify a new function
Mauro Carvalho Chehab [Tue, 6 Mar 2018 09:30:22 +0000 (04:30 -0500)]
media: em28xx: constify a new function

em28xx_duplicate_dev() is static. This were supposed to be
merged on the last patch, but somehow, I forgot "-a" when
I called git commit --amend.

Fixes: be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality")
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Hauppauge DualHD second tuner functionality
Brad Love [Fri, 5 Jan 2018 00:04:11 +0000 (19:04 -0500)]
media: em28xx: Hauppauge DualHD second tuner functionality

Implement use of secondary TS port on em28xx.
Adds has_dual_ts field, allows secondary demod/tuner to be
added to a single em28xx device.

Hauppauge DualHD models are configured to use this feature.

[mchehab@s-opensource.com: em28xx_duplicate_dev() should be static]
Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ABS macro parameter parenthesization
Dan Gopstein [Mon, 25 Dec 2017 21:16:14 +0000 (16:16 -0500)]
media: ABS macro parameter parenthesization

Replace usages of the locally defined ABS() macro with calls to the
canonical abs() from kernel.h and remove the old definitions of ABS()

This change was originally motivated by two local definitions of the
ABS (absolute value) macro that fail to parenthesize their parameter
properly. This can lead to a bad expansion for low-precedence
expression arguments.

For example: ABS(1-2) currently expands to ((1-2) < 0 ? (-1-2) : (1-2))
which evaluates to -3. But the correct expansion would be
((1-2) < 0 ? -(1-2) : (1-2)) which evaluates to 1.

Signed-off-by: Dan Gopstein <dgopstein@nyu.edu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontend/mxl5xx: add support for physical layer scrambling
Daniel Scheller [Wed, 20 Dec 2017 16:29:48 +0000 (11:29 -0500)]
media: dvb-frontend/mxl5xx: add support for physical layer scrambling

The MaxLinear MxL5xx has support for physical layer scrambling, which was
recently added to the DVB core via the new scrambling_sequence_index
property. Add required bits to the mxl5xx driver.

Picked up from dddvb master, commit 5c032058b9ba ("add support for PLS")
by Ralph Metzler <rjkm@metzlerbros.de>, adapted to the different naming
of the pls property (pls vs. scrambling_sequence_index).

Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agoMerge commit 'v4.16-rc4~0' into patchwork
Mauro Carvalho Chehab [Mon, 5 Mar 2018 12:39:06 +0000 (07:39 -0500)]
Merge commit 'v4.16-rc4~0' into patchwork

* commit 'v4.16-rc4~0': (900 commits)
  Linux 4.16-rc4
  memremap: fix softlockup reports at teardown
  libnvdimm: re-enable deep flush for pmem devices via fsync()
  MAINTAINERS: take over Kconfig maintainership
  vfio: disable filesystem-dax page pinning
  kconfig: fix line number in recursive inclusion error message
  Coccinelle: memdup: Fix typo in warning messages
  i2c: octeon: Prevent error message on bus error
  parisc: Reduce irq overhead when run in qemu
  parisc: Use cr16 interval timers unconditionally on qemu
  parisc: Check if secondary CPUs want own PDC calls
  parisc: Hide virtual kernel memory layout
  parisc: Fix ordering of cache and TLB flushes
  kconfig: Update ncurses package names for menuconfig
  kbuild/kallsyms: trivial typo fix
  kbuild: test --build-id linker flag by ld-option instead of cc-ldoption
  kbuild: drop superfluous GCC_PLUGINS_CFLAGS assignment
  kconfig: Don't leak choice names during parsing
  sh: fix build error for empty CONFIG_BUILTIN_DTB_SOURCE
  kconfig: set SYMBOL_AUTO to the symbol marked with defconfig_list
  ...

6 years agoLinux 4.16-rc4
Linus Torvalds [Sun, 4 Mar 2018 22:54:11 +0000 (14:54 -0800)]
Linux 4.16-rc4

6 years agoMerge branch 'x86/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Linus Torvalds [Sun, 4 Mar 2018 20:12:48 +0000 (12:12 -0800)]
Merge branch 'x86/urgent' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:
 "A small set of fixes for x86:

   - Add missing instruction suffixes to assembly code so it can be
     compiled by newer GAS versions without warnings.

   - Switch refcount WARN exceptions to UD2 as we did in general

   - Make the reboot on Intel Edison platforms work

   - A small documentation update so text and sample command match"

* 'x86/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  Documentation, x86, resctrl: Make text and sample command match
  x86/platform/intel-mid: Handle Intel Edison reboot correctly
  x86/asm: Add instruction suffixes to bitops
  x86/entry/64: Add instruction suffix
  x86/refcounts: Switch to UD2 for exceptions

6 years agoMerge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 4 Mar 2018 19:40:16 +0000 (11:40 -0800)]
Merge branch 'x86-pti-for-linus' of git://git./linux/kernel/git/tip/tip

Pull x86/pti fixes from Thomas Gleixner:
 "Three fixes related to melted spectrum:

   - Sync the cpu_entry_area page table to initial_page_table on 32 bit.

     Otherwise suspend/resume fails because resume uses
     initial_page_table and triggers a triple fault when accessing the
     cpu entry area.

   - Zero the SPEC_CTL MRS on XEN before suspend to address a
     shortcoming in the hypervisor.

   - Fix another switch table detection issue in objtool"

* 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/cpu_entry_area: Sync cpu_entry_area to initial_page_table
  objtool: Fix another switch table detection issue
  x86/xen: Zero MSR_IA32_SPEC_CTRL before suspend

6 years agoMerge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 4 Mar 2018 19:34:49 +0000 (11:34 -0800)]
Merge branch 'timers-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull timer fixes from Thomas Gleixner:
 "A small set of fixes from the timer departement:

   - Add a missing timer wheel clock forward when migrating timers off a
     unplugged CPU to prevent operating on a stale clock base and
     missing timer deadlines.

   - Use the proper shift count to extract data from a register value to
     prevent evaluating unrelated bits

   - Make the error return check in the FSL timer driver work correctly.
     Checking an unsigned variable for less than zero does not really
     work well.

   - Clarify the confusing comments in the ARC timer code"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  timers: Forward timer base before migrating timers
  clocksource/drivers/arc_timer: Update some comments
  clocksource/drivers/mips-gic-timer: Use correct shift count to extract data
  clocksource/drivers/fsl_ftm_timer: Fix error return checking

6 years agoMerge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 4 Mar 2018 19:33:04 +0000 (11:33 -0800)]
Merge branch 'irq-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull irq fixlet from Thomas Gleixner:
 "Just a documentation update for the missing device tree property of
  the R-Car M3N interrupt controller"

* 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  dt-bindings/irqchip/renesas-irqc: Document R-Car M3-N support

6 years agoMerge tag 'for-4.16-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
Linus Torvalds [Sun, 4 Mar 2018 19:04:27 +0000 (11:04 -0800)]
Merge tag 'for-4.16-rc3-tag' of git://git./linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:

 - when NR_CPUS is large, a SRCU structure can significantly inflate
   size of the main filesystem structure that would not be possible to
   allocate by kmalloc, so the kvalloc fallback is used

 - improved error handling

 - fix endiannes when printing some filesystem attributes via sysfs,
   this is could happen when a filesystem is moved between different
   endianity hosts

 - send fixes: the NO_HOLE mode should not send a write operation for a
   file hole

 - fix log replay for for special files followed by file hardlinks

 - fix log replay failure after unlink and link combination

 - fix max chunk size calculation for DUP allocation

* tag 'for-4.16-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  Btrfs: fix log replay failure after unlink and link combination
  Btrfs: fix log replay failure after linking special file and fsync
  Btrfs: send, fix issuing write op when processing hole in no data mode
  btrfs: use proper endianness accessors for super_copy
  btrfs: alloc_chunk: fix DUP stripe size handling
  btrfs: Handle btrfs_set_extent_delalloc failure in relocate_file_extent_cluster
  btrfs: handle failure of add_pending_csums
  btrfs: use kvzalloc to allocate btrfs_fs_info

6 years agoMerge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 3 Mar 2018 22:55:20 +0000 (14:55 -0800)]
Merge branch 'i2c/for-current-fixed' of git://git./linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
 "A driver fix and a documentation fix (which makes dependency handling
  for the next cycle easier)"

* 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: octeon: Prevent error message on bus error
  dt-bindings: at24: sort manufacturers alphabetically

6 years agoMerge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdim...
Linus Torvalds [Sat, 3 Mar 2018 22:32:00 +0000 (14:32 -0800)]
Merge branch 'libnvdimm-fixes' of git://git./linux/kernel/git/nvdimm/nvdimm

Pull libnvdimm fixes from Dan Williams:
 "A 4.16 regression fix, three fixes for -stable, and a cleanup fix:

   - During the merge window support for the new ACPI NVDIMM Platform
     Capabilities structure disabled support for "deep flush", a
     force-unit- access like mechanism for persistent memory. Restore
     that mechanism.

   - VFIO like RDMA is yet one more memory registration / pinning
     interface that is incompatible with Filesystem-DAX. Disable long
     term pins of Filesystem-DAX mappings via VFIO.

   - The Filesystem-DAX detection to prevent long terms pins mistakenly
     also disabled Device-DAX pins which are not subject to the same
     block- map collision concerns.

   - Similar to the setup path, softlockup warnings can trigger in the
     shutdown path for large persistent memory namespaces. Teach
     for_each_device_pfn() to perform cond_resched() in all cases.

   - Boaz noticed that the might_sleep() in dax_direct_access() is stale
     as of the v4.15 kernel.

  These have received a build success notification from the 0day robot,
  and the longterm pin fixes have appeared in -next. However, I recently
  rebased the tree to remove some other fixes that need to be reworked
  after review feedback.

* 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
  memremap: fix softlockup reports at teardown
  libnvdimm: re-enable deep flush for pmem devices via fsync()
  vfio: disable filesystem-dax page pinning
  dax: fix vma_is_fsdax() helper
  dax: ->direct_access does not sleep anymore

6 years agoMerge tag 'kbuild-fixes-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masah...
Linus Torvalds [Sat, 3 Mar 2018 18:37:01 +0000 (10:37 -0800)]
Merge tag 'kbuild-fixes-v4.16' of git://git./linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - suppress sparse warnings about unknown attributes

 - fix typos and stale comments

 - fix build error of arch/sh

 - fix wrong use of ld-option vs cc-ldoption

 - remove redundant GCC_PLUGINS_CFLAGS assignment

 - fix another memory leak of Kconfig

 - fix line number in error messages of Kconfig

 - do not write confusing CONFIG_DEFCONFIG_LIST out to .config

 - add xstrdup() to Kconfig to handle memory shortage errors

 - show also a Debian package name if ncurses is missing

* tag 'kbuild-fixes-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  MAINTAINERS: take over Kconfig maintainership
  kconfig: fix line number in recursive inclusion error message
  Coccinelle: memdup: Fix typo in warning messages
  kconfig: Update ncurses package names for menuconfig
  kbuild/kallsyms: trivial typo fix
  kbuild: test --build-id linker flag by ld-option instead of cc-ldoption
  kbuild: drop superfluous GCC_PLUGINS_CFLAGS assignment
  kconfig: Don't leak choice names during parsing
  sh: fix build error for empty CONFIG_BUILTIN_DTB_SOURCE
  kconfig: set SYMBOL_AUTO to the symbol marked with defconfig_list
  kconfig: add xstrdup() helper
  kbuild: disable sparse warnings about unknown attributes
  Makefile: Fix lying comment re. silentoldconfig

6 years agoMerge tag 'media/v4.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
Linus Torvalds [Sat, 3 Mar 2018 18:27:14 +0000 (10:27 -0800)]
Merge tag 'media/v4.16-3' of git://git./linux/kernel/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:

  - some build fixes with randconfigs

  - an m88ds3103 fix to prevent an OOPS if the chip doesn't provide the
    right version during probe (with can happen if the hardware hangs)

  - a potential out of array bounds reference in tvp5150

  - some fixes and improvements in the DVB memory mapped API (added for
    kernel 4.16)

* tag 'media/v4.16-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  media: vb2: Makefile: place vb2-trace together with vb2-core
  media: Don't let tvp5150_get_vbi() go out of vbi_ram_default array
  media: dvb: update buffer mmaped flags and frame counter
  media: dvb: add continuity error indicators for memory mapped buffers
  media: dmxdev: Fix the logic that enables DMA mmap support
  media: dmxdev: fix error code for invalid ioctls
  media: m88ds3103: don't call a non-initalized function
  media: au0828: add VIDEO_V4L2 dependency
  media: dvb: fix DVB_MMAP dependency
  media: dvb: fix DVB_MMAP symbol name
  media: videobuf2: fix build issues with vb2-trace
  media: videobuf2: Add VIDEOBUF2_V4L2 Kconfig option for VB2 V4L2 part

6 years agoMerge tag 'linux-watchdog-4.16-fixes-1' of git://www.linux-watchdog.org/linux-watchdog
Linus Torvalds [Sat, 3 Mar 2018 17:59:51 +0000 (09:59 -0800)]
Merge tag 'linux-watchdog-4.16-fixes-1' of git://linux-watchdog.org/linux-watchdog

Pull watchdog fixes from Wim Van Sebroeck:

 - rave-sp: add NVMEM dependency

 - build fixes for i6300esb_wdt, xen_wdt and sp5100_tco

* tag 'linux-watchdog-4.16-fixes-1' of git://www.linux-watchdog.org/linux-watchdog:
  watchdog: sp5100_tco.c: fix potential build failure
  watchdog: xen_wdt: fix potential build failure
  watchdog: i6300esb: fix build failure
  watchdog: rave-sp: add NVMEM dependency

6 years agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Sat, 3 Mar 2018 03:40:43 +0000 (19:40 -0800)]
Merge tag 'for-linus' of git://git./virt/kvm/kvm

Pull KVM fixes from Radim Krčmář:
 "x86:

   - fix NULL dereference when using userspace lapic

   - optimize spectre v1 mitigations by allowing guests to use LFENCE

   - make microcode revision configurable to prevent guests from
     unnecessarily blacklisting spectre v2 mitigation feature"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: x86: fix vcpu initialization with userspace lapic
  KVM: X86: Allow userspace to define the microcode version
  KVM: X86: Introduce kvm_get_msr_feature()
  KVM: SVM: Add MSR-based feature support for serializing LFENCE
  KVM: x86: Add a framework for supporting MSR-based features