v4l2-ctl: --all should also show multiplanar formats.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-compliance: add bytesperline sanity check for multiplanar formats.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-compliance: add streaming tests

Add tests for the streaming ioctls. If the -s flag is specified then the
streaming tests are enabled. These assume a valid input/output and/or
frequency. Options to set those are also added.

Currently only single plane video capture is supported. This is however
90% of all drivers, so this should be OK for now while work progresses
on other formats. Also the DMABUF streaming is not tested.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-compliance: fix broken test for V4L2_FRMIVAL_TYPE_CONTINUOUS

Don't test for 'step > (max - min)' for the continuous type. Step should
be ignored in that case.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-ctl: add support for fields

It is now possible to specify the field to use when setting a format, and
new options --list-fields and --list-fields-out are added to list the available
fields for the current format.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-compliance: fix read() test and reopen after read/write

Fixed the test checking for the read() result in case the READWRITE cap
was not set.

Also reopen the file after the read/write tests to clear the 'file I/O'
state of the filehandle. Otherwise VIDIOC_REQBUFS would just return
EBUSY.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-ctl: automatically detect single/multiplanar buffer type.

Instead of having both single and multiplanar variants of options it is
easier for everyone to just test for the multiplanar capabilities and, if
set, use multiplanar buffer types.

This was already done for the streaming options and now it is done elsewhere
as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-compliance: test streaming with bogus v4l2_buffer values.

Check that invalid inputs do not crash anything.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-compliance: check if USERPTR is actually supported.

Don't fail if this memory mode isn't supported.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
dvb-scan: fix a print message

The % is at the wrong place, causing the message to print weird
values.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
descriptors: be sure to not read past the buffer

The loop will read 2 bytes from ptr, to get descriptor type and
length. Be sure that those two bytes are available.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
vct: avoid read descriptors past the buffer

On some ATSC streams found in KR, the descriptor_length at the
VCT tables are found to be bigger than the remaining buffer
size.

While this could be due to some other problem, add a logic to
prevent going paste the buffer.

Likely, this patch should also be ported to other places where
dvb_parse_descriptors() is called.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb-demux: add code for DVB section filter

Instead of hardcoding its call inside dvb-scan, add a function
to set a section filter at the proper place (dmx-demux.c).

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb: Fix VCT handling

Protocol version is wrong. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb-scan: don't handle NIT table by default on ATSC

With ATSC, the NIT table data is not useful at scan, as the only
non-automatically-detected parameter is the modulation. Well, the
modulation is mandatory anyway.

So, the scanning tool don't need the NIT table at all.

As NIT table is not always present (it isn't in KR), that makes
the scan procedure faster.

We could eventually disable it for other delivery systems, but
that would require an extra parameter on two functions, and this
would break userspace API. So, let's apply this patch instead.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb-fe: Add support for setting the LNA before tuning

Sometimes, we need to control the Low Noise Amplifier (LNA)
at the antena, in order to get a signal. This is dependent on
the way the tuner is connected to the antena, and if the antena
has support for it.

Add a logic at the code to set it. By default, LNA will be in auto
mode, with is the DVB core's default.

Enabling or disabling it is just a matter of changing parms->lna.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb: add support for LNA setting at scan and zap

Add a new parameter to allow to explicitly enable or disable LNA
while zapping or scanning.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb-fe: Use a separate call to change LNA settings

Setting the LNA mode may fail, as this is not implemented on
all drivers. So, move this into a separate call, and don't
make it a fatal error.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
v4l2-compliance: restore the initial formats after testing S_FMT

The format you end up with after S_FMT has been run through its paces
is the smallest possible format. However, that's not what you want for
the streaming tests. So we restore the initial formats at the end of
the tests.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
v4l2-compliance: add EXPBUF and DMABUF streaming tests.

At the moment only single planar VIDEO_CAPTURE buffer types are supported.

To test DMABUF streaming you need a /dev/video device that supports
VIDIOC_EXPBUF. In addition, that device needs to be set to a format that
creates large enough buffers to support the device under test.

You can specify which device to use by passing the --expbuf-device option.

Devices that support EXPBUF are generally found in embedded drivers,
however work is in progress to support it in the saa7134 driver and that
is what I have been using to test this.

Hardware using the saa7134 is easy to find, so this is a reasonable
option.

It would be nice if we could also use GPU drivers for this, but someone
with more knowledge than myself needs to help out for that.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>