The v4l2-compliance tool complains if a video doesn't start
with a zero sequence number.
While this shouldn't cause any real problem for apps, let's
make it happier, in order to better check the v4l2-compliance
differences before and after patchsets.
This is actually an old issue. It is there since at least its
videobuf2 conversion, e. g. changeset 3829fadc461 ("[media]
em28xx: convert to videobuf2"), if VB1 wouldn't suffer from
the same issue.
Cc: stable@vger.kernel.org
Fixes: d3829fadc4 ("[media] em28xx: convert to videobuf2")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Instead of using a register value, use an AMUX name, as otherwise
VIDIOC_G_AUDIO would fail.
Cc: stable@vger.kernel.org
Fixes: 766ed64de5 ("V4L/DVB (11827): Add support for Terratec Grabster AV350")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Follow the V4L2 spec, as warned by v4l2-compliance:
warn: v4l2-test-formats.cpp(732): TRY_FMT cannot handle an invalid pixelformat.
warn: v4l2-test-formats.cpp(733): This may or may not be a problem. For more information see:
warn: v4l2-test-formats.cpp(734): http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
Cc: stable@vger.kernel.org
Fixes: bddcf63313 ("V4L/DVB (9927): em28xx: use a more standard way to specify video formats")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The a->index is not the name of the internal amux entry,
but, instead a value from zero to the maximum number
of audio inputs.
As the actual available inputs depend on each board, build
it dynamically.
This is broken for a really long time. On a quick check,
since at least commit 195a4ef627 ("V4L/DVB (6585): Convert
em28xx to video_ioctl2") this was not implemented right.
Fixes: 195a4ef627 ("V4L/DVB (6585): Convert em28xx to video_ioctl2")
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
As far as I can tell em28xx_audio_urb_init() is called once during
initialization from non atomic context. Memory allocation from
non atomic context should use GFP_KERNEL to avoid using emergency pool
for memory allocation.
Use GFP_KERNEL for memory allocation.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The strcpy() function is being deprecated upstream. Replace
it by the safer strscpy().
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
em28xx_pre_card_setup() is never called in atomic context.
It calls mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep().
This is found by a static analysis tool named DCNS written by myself.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
em28xx_init_usb_xfer() is never called in atomic context.
It calls usb_submit_urb() with GFP_ATOMIC, which is not necessary.
GFP_ATOMIC can be replaced with GFP_KERNEL.
This is found by a static analysis tool named DCNS written by myself.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This patch disables the null packet filter for the Hauppauge
WinTV-dualHD. There are applications which require the unfiltered
transport stream (e.g. DOCSIS segment load analyzers).
Tests showed that the device is capable of delivering two unfiltered
EuroDOCSIS 3.0 transport streams simultaneously, i.e. over 100 Mbit/s
worth of data, without any losses.
Signed-off-by: Robert Schlabbach <Robert.Schlabbach@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The em28xx driver never touched the EM2874 register bits that control
the transport stream packet filters, leaving them at whatever default
the firmware has set. E.g. the Pinnacle 290e disables them by default,
while the Hauppauge WinTV dualHD enables discarding NULL packets by
default.
However, some applications require NULL packets, e.g. to determine the
load in DOCSIS segments, so discarding NULL packets is undesired for
such applications.
This patch simply extends the bit mask when starting or stopping the
transport stream packet capture, so that the filter bits are cleared.
It has been verified that this makes the Hauppauge WinTV dualHD pass
an unfiltered DVB-C stream including NULL packets, which it didn't
before.
Signed-off-by: Robert Schlabbach <Robert.Schlabbach@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Right now, the code that calculates alternate modes is not ready
for devices with dual tuners. That's ok, as we currently don't
have any such devices, but better to add a warning for such
case, as, if anyone adds such device, the logic will need to
be reviewed.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Half-revert: commit 5b1a270d22 ("media: dvb: add alternative USB PID for Hauppauge WinTV-soloHD")'
The PID already exists on the line above.
Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Michael Ira Krufky <mkrufky@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Addresses the following, which introduced a regression itself:
Commit 509f89652f ("media: em28xx: fix a regression with HVR-950")
The regression fix breaks dual transport stream support. Currently,
when a tuner starts streaming it sets alt mode on the USB interface.
The problem is, in a dual tuner model, both tuners share the same
USB interface, so when the second tuner becomes active and sets alt
mode on the interface it kills streaming on the other port.
This patch addresses the regression by only setting alt mode
on the USB interface during em28xx_start_streaming, if the
device is not a dual tuner model. This allows all older and
single tuner devices to explicitly set alt mode during stream
startup. Testers report both isoc and bulk DualHD models work
correctly with the alt mode set only once, in em28xx_dvb_init.
Fixes: 509f89652f ("media: em28xx: fix a regression with HVR-950")
Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Michael Ira Krufky <mkrufky@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Since commit 1eace8344c ("i2c: add param sanity check to
i2c_transfer()"), the I2C core does this check now. We can remove it
from drivers.
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
These two statements are not errors, reduce to appropriate level.
Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
There are two places pointing to an unexisting "m.chehab@kernel.org"
email. I never had such email, so, I'm unsure how it ends there.
Anyway, it is plain wrong.
While here, use my canonical e-mail on a bunch of places that
are pointing to another e-mail. The idea is that, from now on,
all places will be pointing to the same SMTP server.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The use of a hard coded i2c address breaks the creation of the
second tuner in DualHD 01595 models. The issue is compounded
by lack of any error message stating that a driver failed
initialization. Use addr, which contains the correct address
for each tuner.
Fixes: ad32495b15 ("media: em28xx-dvb: simplify DVB module probing logic")
Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Extra code to be able to use this stick, only digital, not analog
nor remote-control.
Signed-off-by: Marcel Stork <mjstork@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
A cosmetic change by combining two sets of boards into one set because
having the same arguments.
Signed-off-by: Marcel Stork <mjstork@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Messages expected during device probe were being marked as errors.
Signed-off-by: Chris Mayo <aklhfex@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Newer DVB receivers of this type have a different USB PID.
Signed-off-by: Rainer Keller <mail@rainerkeller.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Convert the driver to allow its usage with the new I2C
binding way.
Please notice that this patch doesn't convert the
callers to bind to it using the new way.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Commit be7fd3c3a8 ("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
Tested with Hauppauge HVR-950 model A1C0.
Fixes: be7fd3c3a8 ("media: em28xx: Hauppauge DualHD second tuner functionality")
Cc: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
From now on, I'll start using my @kernel.org as my development e-mail.
As such, let's remove the entries that point to the old
mchehab@s-opensource.com at MAINTAINERS file.
For the files written with a copyright with mchehab@s-opensource,
let's keep Samsung on their names, using mchehab+samsung@kernel.org,
in order to keep pointing to my employer, with sponsors the work.
For the files written before I join Samsung (on July, 4 2013),
let's just use mchehab@kernel.org.
For bug reports, we can simply point to just kernel.org, as
this will reach my mchehab+samsung inbox anyway.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Brian Warner <brian.warner@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
The current I2C error handling logic makes static analyzers
confused:
drivers/media/usb/em28xx/em28xx-input.c:96 em28xx_get_key_terratec() error: uninitialized symbol 'b'.
Change it to match the coding style we're using elsewhere.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
The v4l2_subdev core s_power op was used for two different things: power on/off
sensors or video decoders/encoders and to put a tuner in standby (and only the
tuner!). There is no 'tuner wakeup' op, that's done automatically when the tuner
is accessed.
The danger with calling (s_power, 0) to put a tuner into standby is that it is
usually broadcast for all subdevs. So a video receiver subdev that supports
s_power will also be powered off, and since there is no corresponding (s_power, 1)
they will never be powered on again.
In addition, this is specifically meant for tuners only since they draw the most
current.
This patch adds a new tuner op called 'standby' and replaces all calls to
(core, s_power, 0) by (tuner, standby). This prevents confusion between the two
uses of s_power. Note that there is no overlap: bridge drivers either just want
to put the tuner into standby, or they deal with powering on/off sensors. Never
both.
This also makes it easier to replace s_power for the remaining bridge drivers
with some PM code later.
Whether we want something cleaner for tuners in the future is a separate topic.
There is a lot of legacy code surrounding tuners, and I am very hesitant about
making changes there.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
There is a double sizeof() typo here so we don't duplicate the struct
properly.
Fixes: be7fd3c3a8 ("media: em28xx: Hauppauge DualHD second tuner functionality")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
be7fd3c3a8 ("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>
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>
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>