platform/upstream/v4l-utils.git
10 years agolibdvbv5: service location descriptor support
André Roth [Wed, 8 Jan 2014 22:12:47 +0000 (19:12 -0300)]
libdvbv5: service location descriptor support

- implement the service location descriptor (0xa1)
- small cleanups

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix reading multisection tables
André Roth [Wed, 8 Jan 2014 22:12:46 +0000 (19:12 -0300)]
libdvbv5: fix reading multisection tables

Unfortunately the section ids are not granted to be incremented by one.
This means the last section id is not necessarily equal to the total
number of sections. The only way to know if everything has been parsed, is
to stop when a repeating section id has been found.

The sections do not need to contain the same table id. In EIT for example,
the id designates the corresponding service.
Thus, allow the table id to differ.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agov4l-utils: run sync-with-kernel, add ioctl32 tests for v4l2-subdev.h
Hans Verkuil [Wed, 15 Jan 2014 08:13:08 +0000 (09:13 +0100)]
v4l-utils: run sync-with-kernel, add ioctl32 tests for v4l2-subdev.h

The v4l2-subdev ioctls were never tested in compat32 mode. Add the v4l2-subdev.h
header to v4l-utils when running sync-with-kernel and fix the gen_ioctl_list.pl
script to generate the subdev ioctls.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4l: Update the link pointing the patch for porting the application to libv4l2
Lad, Prabhakar [Mon, 13 Jan 2014 10:59:46 +0000 (16:29 +0530)]
libv4l: Update the link pointing the patch for porting the application to libv4l2

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
10 years agolibv4l: Update the README name for libv4l
Lad, Prabhakar [Mon, 13 Jan 2014 09:28:06 +0000 (14:58 +0530)]
libv4l: Update the README name for libv4l

The README for libv4l was renamed from README.lib to
README.libv4l but the reference to it was not fixed.
This patch fixes the above.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
10 years agolibdvbv5: implement ATSC EIT
André Roth [Wed, 8 Jan 2014 11:23:28 +0000 (08:23 -0300)]
libdvbv5: implement ATSC EIT

ATSC has a different EIT table then DVB. This implements
the parser according to secifications defined in A/65:2009.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: implement MGT table parser
André Roth [Wed, 8 Jan 2014 11:23:27 +0000 (08:23 -0300)]
libdvbv5: implement MGT table parser

The Master Guide Table is used in ATSC. Implementation
according to specs A/65:2009

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: implement ATSC standard header
André Roth [Wed, 8 Jan 2014 11:23:26 +0000 (08:23 -0300)]
libdvbv5: implement ATSC standard header

The ATSC standard header is slightly different from the one used
in DVB. This implements the parser for it, and will be used by
the VCT table for example.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: cleanup dvb_nit_transport_foreach macro
André Roth [Mon, 30 Dec 2013 12:48:47 +0000 (09:48 -0300)]
libdvbv5: cleanup dvb_nit_transport_foreach macro

Remove a bad indent introduced by mistake.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix missing includes
André Roth [Mon, 30 Dec 2013 12:48:45 +0000 (09:48 -0300)]
libdvbv5: fix missing includes

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: prefix VCT with atsc_ instead of dvb_
André Roth [Mon, 30 Dec 2013 12:48:43 +0000 (09:48 -0300)]
libdvbv5: prefix VCT with atsc_ instead of dvb_

Rename the ATSC-specific parameters to start with ATSC
instead of DVB, to use a better namespace.

Those ATSC parameters are not yet on any public header.
So, changing them for now is ok.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: implement dvb_fe_dummy for logging
André Roth [Mon, 30 Dec 2013 12:48:39 +0000 (09:48 -0300)]
libdvbv5: implement dvb_fe_dummy for logging

The dvbv5 functions use the dvb_v5_fe_parms struct for logging.
This struct is normally obtained by opening a dvb device. For
situations where the opening of a dvb device is not desired,
the dvb_fe_dummy can be used.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix NIT structures
André Roth [Mon, 30 Dec 2013 12:48:38 +0000 (09:48 -0300)]
libdvbv5: fix NIT structures

Add missing __attribute__((packed)) to nit structs.

As this is a binary description of the MPEG NIT table, it should not have
any padding on it.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: VCT bitmap fixup
André Roth [Mon, 30 Dec 2013 12:48:36 +0000 (09:48 -0300)]
libdvbv5: VCT bitmap fixup

The size of bitfield1 is 32 bits. Fix it.

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix get_frontend logic
Mauro Carvalho Chehab [Mon, 16 Dec 2013 10:18:46 +0000 (08:18 -0200)]
libdvbv5: fix get_frontend logic

The patch that added a cache var for get/set broke the get frontend
data logic, as it doesn't copy data back from cache. Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvb-scan: remove ISDB-T hack from it
Mauro Carvalho Chehab [Sun, 15 Dec 2013 15:49:06 +0000 (13:49 -0200)]
dvb-scan: remove ISDB-T hack from it

This hack is not needed/desired, as it overrides what userspace
specified:
- if channel file is a DVBv3 file, those values are already
  filled by the compatibility standard code;
- if channel file is in DVBv5 format, it may override any
ISDB-T parameter.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvb: simplify the logic that sets a (compat) DTV delivery system
Mauro Carvalho Chehab [Sun, 15 Dec 2013 15:32:02 +0000 (13:32 -0200)]
dvb: simplify the logic that sets a (compat) DTV delivery system

Instead of using a loop, just call the existing function for
retrieve a parameter inside an entry.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvb-fe: fix using a DVB-T file for ISDB-T
Mauro Carvalho Chehab [Sun, 15 Dec 2013 15:17:51 +0000 (13:17 -0200)]
dvb-fe: fix using a DVB-T file for ISDB-T

When a DVB-T channel file is used, and the frontend has ISDB-T
instead, put it into ISDB-T auto search mode.

That is better than let the Kernel to use the compatibility mode,
as the output files will have the proper ISDB-T fields.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agolibdvbv5: Only discard the services not found
Mauro Carvalho Chehab [Sun, 15 Dec 2013 14:48:35 +0000 (12:48 -0200)]
libdvbv5: Only discard the services not found

If the PAT table describes a service ID, but it doesn't exist, just
discard it, and not all services after that.

This helps to be a little more resillient to broken PAT tables.

Caught with a test signal that was captured by a friend in Rio. The
tables describe a SD stream that it is not present on the TS.

$ dvbv5-scan ~mchehab/isdb-teste -F -G -T2
INFO     Scanning frequency #1 479142857
Lock   (0x1f) Signal= 78.83% C/N= 0.38% UCB= 252 postBER= 0
INFO     Service Globo HD, provider (null): digital television
INFO     Service Globo SD, provider (null): digital television
WARNING  Service ID 59201 not found on PMT!
INFO     Service Globo 1Seg, provider (null): user defined

Not sure if this is due to some capture error or not, but it is better
to be able to capture the 1Seg stream in any case, and just discard the
broken Service ID.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agolibdvbv5/dvb-fe: Fall back to v3 if needed
Mauro Carvalho Chehab [Fri, 13 Dec 2013 09:31:56 +0000 (07:31 -0200)]
libdvbv5/dvb-fe: Fall back to v3 if needed

if FE_GET_PROPERTY gets error, fallback to DVBv3 stats

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agoqv4l2: fix broken VBI support
Hans Verkuil [Sat, 14 Dec 2013 11:13:40 +0000 (12:13 +0100)]
qv4l2: fix broken VBI support

Using qv4l2 with a vbi node broke when the pixel aspect ratio code was added.
Pixel aspect doesn't apply to vbi, and that wasn't checked.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibdvbv5: fix retrieve parameters for ISDB-T
Mauro Carvalho Chehab [Thu, 12 Dec 2013 12:11:20 +0000 (10:11 -0200)]
libdvbv5: fix retrieve parameters for ISDB-T

ERROR    command MODULATION (4) not found during retrieve
ERROR    command INNER_FEC (9) not found during retrieve

Those parameters are per-layer, and not global.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Fix a warning at isdb_desc_partial_reception_free
Mauro Carvalho Chehab [Thu, 12 Dec 2013 10:24:54 +0000 (08:24 -0200)]
libdvbv5: Fix a warning at isdb_desc_partial_reception_free

descriptors.c:1175:3: warning: initialization from incompatible pointer type [enabled by default]
   .free  = isdb_desc_partial_reception_free,
   ^
descriptors.c:1175:3: warning: (near initialization for 'dvb_descriptors[251].free') [enabled by default]

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agov4l2-ctl: use libv4l2 wrapper for mmap as well.
Hans Verkuil [Wed, 11 Dec 2013 14:37:27 +0000 (15:37 +0100)]
v4l2-ctl: use libv4l2 wrapper for mmap as well.

The streaming code didn't use v4l2_mmap if the -w option was specified.
Correct this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agodvbv5-zap: allow using a frequency for a channel on exit after tuning
Mauro Carvalho Chehab [Wed, 4 Dec 2013 10:51:49 +0000 (08:51 -0200)]
dvbv5-zap: allow using a frequency for a channel on exit after tuning

On exit after tuning, only the frontend is used. So, no need to specify
any PID. Just the transponder/channel frequency is enough.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvbv5-zap: fix frontend status handling
Mauro Carvalho Chehab [Wed, 4 Dec 2013 10:38:45 +0000 (08:38 -0200)]
dvbv5-zap: fix frontend status handling

Currently, check_frontend is doing nothing. Fix it to wait for a
lock, and remove the duplicated "frontend only" option, as this is
the same as exit after locking.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvbv5-zap: on all pids mode, we can use the frequency
Mauro Carvalho Chehab [Wed, 4 Dec 2013 10:30:18 +0000 (08:30 -0200)]
dvbv5-zap: on all pids mode, we can use the frequency

We don't need the service name on all PIDs mode.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvb-fe: be a little less verbose with verbosity level 1
Mauro Carvalho Chehab [Wed, 4 Dec 2013 10:14:42 +0000 (08:14 -0200)]
dvb-fe: be a little less verbose with verbosity level 1

This is too much verbosity when scanning:

DEBUG    Stats for STATUS = 0
DEBUG    Stats for STATUS = 0
DEBUG    Stats for STATUS = 0
       (0x00) Quality= Poor Signal= -62.00dBm C/N= 19.00dB UCB= 497 postBER= 126x10^-18 PER= 86.9x10^-3
  Layer A: Quality= Good UCB= 0 postBER= 0 PER= 0
  Layer B: Quality= Poor UCB= 7030 postBER= 3.79x10^-3 PER= 71.9x10^-3

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agolibdvbv5: Fix memory leak at TS info handler
Mauro Carvalho Chehab [Mon, 2 Dec 2013 03:04:55 +0000 (01:04 -0200)]
libdvbv5: Fix memory leak at TS info handler

parse_string allocates memory. Those need to be freed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agolibdvbv5: fix memory leak at ISDB partial reception handler
Mauro Carvalho Chehab [Mon, 2 Dec 2013 02:54:56 +0000 (00:54 -0200)]
libdvbv5: fix memory leak at ISDB partial reception handler

This descriptor handles allocates memory but never frees it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvbv5-zap: fix all-pids record mode
Mauro Carvalho Chehab [Mon, 2 Dec 2013 02:35:33 +0000 (00:35 -0200)]
dvbv5-zap: fix all-pids record mode

the -P switch was not working fine, as the recorded mpeg file
were being corrupting. Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
10 years agodvb/README: Remove some obsolete data
Mauro Carvalho Chehab [Fri, 29 Nov 2013 12:12:00 +0000 (10:12 -0200)]
dvb/README: Remove some obsolete data

The descriptors handling is now completely different. Remove the
description of the old library from README file, as it doesn't apply
any more.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: simplify VCT table parser
Mauro Carvalho Chehab [Fri, 29 Nov 2013 11:26:20 +0000 (09:26 -0200)]
libdvbv5: simplify VCT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: simplify SDT table parser
Mauro Carvalho Chehab [Fri, 29 Nov 2013 11:25:52 +0000 (09:25 -0200)]
libdvbv5: simplify SDT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: simplify PMT table parser
Mauro Carvalho Chehab [Fri, 29 Nov 2013 11:24:59 +0000 (09:24 -0200)]
libdvbv5: simplify PMT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

While here, add support for multisection PMT.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: cleanup PAT table parser
Mauro Carvalho Chehab [Fri, 29 Nov 2013 11:23:45 +0000 (09:23 -0200)]
libdvbv5: cleanup PAT table parser

Do a cleanup at the code, fixing coding style and moving
the head initialization to the beginning of the file.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: simplify NIT table parser
Mauro Carvalho Chehab [Fri, 29 Nov 2013 11:21:18 +0000 (09:21 -0200)]
libdvbv5: simplify NIT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Simplify PAT handling
Mauro Carvalho Chehab [Fri, 29 Nov 2013 10:48:25 +0000 (08:48 -0200)]
libdvbv5: Simplify PAT handling

Coverity thinks that there's a resource leak by having a pgm
not being properly stored.

While I don't agree with Coverity, the code could be simplified,
and use just one pointer instead of two, in order to fill the
programs linked list.

That makes it easier to be analyzed by both automatic tools and
by manual inspection.

So, simplify it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix some out-of-bound acesses on hexdump()
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:39:45 +0000 (00:39 -0200)]
libdvbv5: fix some out-of-bound acesses on hexdump()

As Coverity points, there are some risk of getting out of bound
on some places. Fix it, and fix the coding style.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix other error conditions for out of memory
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:36:33 +0000 (00:36 -0200)]
libdvbv5: fix other error conditions for out of memory

As Coverity points, there are other places where this error also occurs.

Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: pack NIT table
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:15:19 +0000 (00:15 -0200)]
libdvbv5: pack NIT table

As all tables, this one should be packed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: all tables should have an specified size
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:12:47 +0000 (00:12 -0200)]
libdvbv5/dvb-scan: all tables should have an specified size

If a table has a zero size, reject it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvb5-zap: Better handle the MPEG TS header
Mauro Carvalho Chehab [Fri, 29 Nov 2013 02:08:53 +0000 (00:08 -0200)]
dvb5-zap: Better handle the MPEG TS header

The code is now a little more elegant and easier to read.

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Fix other error conditions for out of memory
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:58:05 +0000 (09:58 -0200)]
libdvbv5: Fix other error conditions for out of memory

As Coverity points, there are other places where this error also occurs.

Fix all of them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix error condition on ISDBT delivery descriptor
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:53:45 +0000 (09:53 -0200)]
libdvbv5: fix error condition on ISDBT delivery descriptor

It should return if an error occur.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix error condition on ATSC service location descriptor
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:51:59 +0000 (09:51 -0200)]
libdvbv5: fix error condition on ATSC service location descriptor

It should return if an error occur.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: fix detection of duplicated freqs at the input file
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:47:03 +0000 (09:47 -0200)]
dvbv5-scan: fix detection of duplicated freqs at the input file

As reported by Coverity, the dvb_scan_handler is always null on
that point. Just removing its check is enough to fix the issue.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: don't use realloc() inside pat.c
Mauro Carvalho Chehab [Thu, 28 Nov 2013 11:34:15 +0000 (09:34 -0200)]
libdvbv5: don't use realloc() inside pat.c

The usage of realloc() inside pat is wrong, as the newly reallocated
data could have a different address, and this is not returned back
to dvb-scan's dvb_read_section_with_id().

While we could do some other tricks to pass the new pointer back,
the entire logic is really not good. Also, the PAT handler uses a
different model than the other tables.

So, change it to use a linked list for the programs. This can, however,
break the API for other applications using it.

Fortunately, the dvb_pat_program_foreach() macro abstracts this
API difference, so, the breakage will not actually happen, if the
other apps use this macro (with is the case of tvdaemon).

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: Remove dead code and add a check after realloc()
Mauro Carvalho Chehab [Thu, 28 Nov 2013 10:50:51 +0000 (08:50 -0200)]
libdvbv5/dvb-scan: Remove dead code and add a check after realloc()

As reported by Coverity scan, the code just before the .init
if check warrants that tbl is always filled. So, checking it again
makes no sense. However, it makes sense to check after calling
realloc().

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: change log level for the two nit handler messages
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:53:22 +0000 (19:53 -0200)]
libdvbv5: change log level for the two nit handler messages

Those msgs are just warn for someone debuging the code. Don't
show them as errors.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix terrestrial delivery constellation table
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:23:23 +0000 (19:23 -0200)]
libdvbv5: fix terrestrial delivery constellation table

constellation == 2 means QAM64, according with ETSI EN 300 468 V1.11.1.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix dvb-scan handler for T2 descriptor
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:16:02 +0000 (19:16 -0200)]
libdvbv5: fix dvb-scan handler for T2 descriptor

The handler should take into account that not all descriptors
have all fields filled.

Also, while we don't have any sample of this descriptor
with a frequency table, better to not change the properties
for each new transponder's frequency.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix T2 delivery descriptor handler
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:13:14 +0000 (19:13 -0200)]
libdvbv5: fix T2 delivery descriptor handler

The data struct were not properly filled. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix extension descriptor handler
Mauro Carvalho Chehab [Wed, 27 Nov 2013 21:11:33 +0000 (19:11 -0200)]
libdvbv5: fix extension descriptor handler

There are several issues at the extension handler:

1) the size is wrong, as it is getting data from
   descriptors.c, instead of from the extensions;

2) there are memory leaks;

3) It doesn't print the extension descriptors.

Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: only handle SIGALRM if need
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:56:07 +0000 (14:56 -0200)]
dvbv5-zap: only handle SIGALRM if need

If timeout is not specified, or a SIGTERM/SIGINT was not received,
there's no need for handling SIGALRM.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: handle SIGTERM/SIGINT nicely
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:36:05 +0000 (14:36 -0200)]
dvbv5-scan: handle SIGTERM/SIGINT nicely

Instead of just dying whenever a signal arrives, finish what it was
done. This way, already scanned channels will be written at the file.

At the worse case, after receiving a SIGTERM/SIGINT, it will die after
5 seconds, or after receiving a second SIGTERM/SIGINT.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: exit nicely on SIGTERM/SIGINT
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:20:46 +0000 (14:20 -0200)]
dvbv5-zap: exit nicely on SIGTERM/SIGINT

If the program is killed or aborted with CTRL-C, dies nicely.

That warrants that any data being processed to be handled, that
opened files will be closed and that the memory gets freed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: handle timeout also while in monitor mode
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:11:54 +0000 (14:11 -0200)]
dvbv5-zap: handle timeout also while in monitor mode

The timeout parameter specifies the maximum time where the zap will
be looping. This works everywhere, except while in monitor mode.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-demux: fix CodingStyle
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:07:24 +0000 (14:07 -0200)]
libdvbv5/dvb-demux: fix CodingStyle

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: clear data before setting a dmx filter
Mauro Carvalho Chehab [Wed, 27 Nov 2013 16:04:02 +0000 (14:04 -0200)]
libdvbv5: clear data before setting a dmx filter

This fixes this Valgrind error:

==25172== Syscall param ioctl(generic) points to uninitialised byte(s)
==25172==    at 0x38CCAECEB7: ioctl (syscall-template.S:81)
==25172==    by 0x4043A8: dvb_set_pesfilter (dvb-demux.c:78)
==25172==    by 0x402F9D: do_traffic_monitor (dvbv5-zap.c:546)
==25172==    by 0x403AEA: main (dvbv5-zap.c:745)

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: make Valgrind happy
Mauro Carvalho Chehab [Wed, 27 Nov 2013 15:59:42 +0000 (13:59 -0200)]
dvbv5-zap: make Valgrind happy

Don't let leaks at the end: close all files, free all allocated
data.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-zap: allow using transponder frequency while in monitor mode
Mauro Carvalho Chehab [Wed, 27 Nov 2013 15:10:38 +0000 (13:10 -0200)]
dvbv5-zap: allow using transponder frequency while in monitor mode

When this tool is using i monitor mode, we don't need audio or video
PID's. So, a "channel" type of file, with the transponders frequency,
plus the transponders parameters are enough. Add support for it.

This way, it is possible to do:

dvbv5-zap -I channel -c dvbc-test 573000000 -m

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors.c: fix two warnings
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:29:46 +0000 (09:29 -0200)]
libdvbv5/descriptors.c: fix two warnings

descriptors.c:134:4: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'int' [-Wformat=]
    dvb_logwarn("descriptor type 0x%02x is truncated: desc len %ld, section len %zd",
    ^
descriptors/desc_frequency_list.c: In function 'dvb_desc_frequency_list_init':
descriptors/desc_frequency_list.c:31:12: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
  char *p = buf;

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: some error handling improvements on dvb-file
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:18:14 +0000 (09:18 -0200)]
libdvbv5: some error handling improvements on dvb-file

All messages used during scan use the dvb_foo macros, excecpt for
those two places. Replace them.

Ok, ideally, all msgs should use this macro, but changing the other
ones is currently out of the scope.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Fix the size of the LCN descriptor
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:10:41 +0000 (09:10 -0200)]
libdvbv5: Fix the size of the LCN descriptor

Instead of using the main struct, it was using the channel number
struct. That's bad, especially since the size is not enough to store
the struct dvb_desc data on it, causing reading paste buffers.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Improve descriptor error logs
Mauro Carvalho Chehab [Wed, 27 Nov 2013 11:10:36 +0000 (09:10 -0200)]
libdvbv5: Improve descriptor error logs

When a descriptor is too small or too big, print a better log
message. Also, those are non-fatal errors. So, tag them as
WARNING.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: handle NIT descriptors when verbose is not enabled
Mauro Carvalho Chehab [Wed, 27 Nov 2013 10:13:00 +0000 (08:13 -0200)]
libdvbv5: handle NIT descriptors when verbose is not enabled

When verbose is enabled, the logic was supposed to check NIT
transport entries even without a callback, in order to print errors,
if a descriptor is found but not handled.

Unfortunately, the logic was wrong, effectively requiring verbose to
be on, in order to parse such descriptors.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: get rid of dvb-scan-table-handler.[ch]
Mauro Carvalho Chehab [Wed, 27 Nov 2013 09:41:53 +0000 (07:41 -0200)]
libdvbv5: get rid of dvb-scan-table-handler.[ch]

those files were useful during the transition to use the
descriptors library. However, after all code changes, they
became too tiny, and dependent of dvb-scan.[ch]. So, merge
the code and header back into them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: properly handle ISDB-T partial reception
Mauro Carvalho Chehab [Tue, 26 Nov 2013 20:20:59 +0000 (18:20 -0200)]
libdvbv5: properly handle ISDB-T partial reception

Tag the 1seg service IDs as partial reception.

That's IMHO the last missing bit from the descriptors library
porting logic.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: better implement the NIT parser
Mauro Carvalho Chehab [Tue, 26 Nov 2013 19:41:21 +0000 (17:41 -0200)]
libdvbv5: better implement the NIT parser

The code that were implementing the NIT parser were becoming too
complex, and had some common duplicated code.

Re-implement it, creating a helper routine to parse any NIT data,
and re-using the same routine to allow updating both the current
transponder and the detected transponders on a cleaner and saner
way.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: remove the remaining bits from the NIT parsers
Mauro Carvalho Chehab [Sun, 24 Nov 2013 23:16:02 +0000 (21:16 -0200)]
libdvbv5: remove the remaining bits from the NIT parsers

The previous NIT parser used to fill the entries data based on
the information detected on each transponder/channel.

Well, if the frontend was able to lock on the transponder, that
means that the parameters there at the entry are already correct
for the current channel, and that there's no need to use the NIT
table.

For new transponders frequencies, those data should be applied,
but this is done already inside dvb_add_scaned_transponders().

So, remove this code. As this is the last part using the old
descriptors logic, remove the struct definitions as well.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add support for DVB-T2 at NIT parser
Mauro Carvalho Chehab [Tue, 26 Nov 2013 12:24:37 +0000 (10:24 -0200)]
libdvbv5: add support for DVB-T2 at NIT parser

Add support on dvb-scan for DVB-T2 transponder parsing.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add support for DVB-S/S2 at NIT parser
Mauro Carvalho Chehab [Mon, 25 Nov 2013 00:43:39 +0000 (22:43 -0200)]
libdvbv5: add support for DVB-S/S2 at NIT parser

Add support on dvb-scan for DVB-S/S2 transponder parsing.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Re-add parser for ISDB-T NIT transponders addition
Mauro Carvalho Chehab [Mon, 25 Nov 2013 00:24:09 +0000 (22:24 -0200)]
libdvbv5: Re-add parser for ISDB-T NIT transponders addition

Add logic to handle NIT table for DVB-T on dvb-scan.c

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Re-add parser for ISDB-T NIT transponders addition
Mauro Carvalho Chehab [Sun, 24 Nov 2013 23:54:14 +0000 (21:54 -0200)]
libdvbv5: Re-add parser for ISDB-T NIT transponders addition

Add logic to handle NIT table for ISDB-T on dvb-scan.c

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Re-add NIT transponders addition
Mauro Carvalho Chehab [Sun, 24 Nov 2013 23:07:43 +0000 (21:07 -0200)]
libdvbv5: Re-add NIT transponders addition

Move the logic that add new transponders into the library and add
support there for DVB-C.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: move scanning code into dvb_scan_transponder()
Mauro Carvalho Chehab [Sun, 24 Nov 2013 12:29:43 +0000 (10:29 -0200)]
dvbv5-scan: move scanning code into dvb_scan_transponder()

This makes the scan library more complete, and allows reusing the
code there into other applications.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: describe the service type on the logs
Mauro Carvalho Chehab [Sun, 24 Nov 2013 10:41:32 +0000 (08:41 -0200)]
libdvbv5/dvb-file: describe the service type on the logs

While we currently don't store the service type on the channel
file, it could be useful for the use to know what was found. So,
add the information there at the output information.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: improve debug messages
Mauro Carvalho Chehab [Sun, 24 Nov 2013 09:54:23 +0000 (07:54 -0200)]
libdvbv5: improve debug messages

Add several improvements at the debug messages:

- Without verbose, show only the Virtual channels or
  services to be stored in the file;

- instead of using fprintf for errors, use the error
  macros. That will make errors colored;

- With verbose=1, will show all parsed data;

- With verbose=2, will show all unparsed descriptors and
their hexdump contents;

- With verbose=3, will show all descriptors and their
hexdump contents, including the ones without a parser.

Verbose levels 2 and 3 helps to detect if some improvements would
be needed inside the descriptor parser's library.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: shut up a few compilation warnings
Mauro Carvalho Chehab [Sun, 24 Nov 2013 09:39:38 +0000 (07:39 -0200)]
libdvbv5: shut up a few compilation warnings

remove a couple compilation warnings:

descriptors/desc_extension.c:148:3: warning: passing argument 3 of 'init' from incompatible pointer type [enabled by default]
   init(parms, p, desc, ext->descriptor);
   ^
descriptors/desc_extension.c:148:3: note: expected 'struct dvb_extension_descriptor *' but argument is of type 'struct dvb_desc *'
descriptors/desc_extension.c: In function 'extension_descriptor_free':
descriptors/desc_extension.c:154:19: warning: unused variable 'desc' [-Wunused-variable]

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on VCT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 16:11:22 +0000 (14:11 -0200)]
libdvbv5: be sure to not go past buffer on VCT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on SDT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 16:03:58 +0000 (14:03 -0200)]
libdvbv5: be sure to not go past buffer on SDT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on PMT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 15:57:48 +0000 (13:57 -0200)]
libdvbv5: be sure to not go past buffer on PMT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: Add missing dvb_dmx_stop() on error handling
Mauro Carvalho Chehab [Wed, 20 Nov 2013 14:54:36 +0000 (12:54 -0200)]
libdvbv5: Add missing dvb_dmx_stop() on error handling

If the table can't be loaded, stop streaming.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: don't cause crash if NIT is missing on fe-file.c
Mauro Carvalho Chehab [Wed, 20 Nov 2013 14:54:11 +0000 (12:54 -0200)]
libdvbv5: don't cause crash if NIT is missing on fe-file.c

If NIT table is not read, it is not possible to get the vchannel
data from it.

Instead of crashing, fails nicely.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: fix debug msg for Network PID
Mauro Carvalho Chehab [Wed, 20 Nov 2013 12:08:36 +0000 (10:08 -0200)]
libdvbv5: fix debug msg for Network PID

When program_number is 0, the PID refers to the Network PID,
according with ISO 13.818-1. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: add multisection support for PAT table
Mauro Carvalho Chehab [Wed, 20 Nov 2013 10:24:42 +0000 (08:24 -0200)]
libdvbv5: add multisection support for PAT table

As PAT can be multisection, add support for it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: be sure to not go past buffer on PAT parsing
Mauro Carvalho Chehab [Wed, 20 Nov 2013 10:19:26 +0000 (08:19 -0200)]
libdvbv5: be sure to not go past buffer on PAT parsing

Add checks to avoid read more data than available on buffer.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5: avoid nit to read out of the buffer
Mauro Carvalho Chehab [Wed, 20 Nov 2013 00:15:02 +0000 (22:15 -0200)]
libdvbv5: avoid nit to read out of the buffer

As reported by Valgrind:
==6709== Invalid write of size 8
==6709==    at 0x4099F2: dvb_parse_descriptors (descriptors.c:61)
==6709==    by 0x40B9CB: dvb_table_nit_init (nit.c:92)
==6709==    by 0x408F07: dvb_read_section_with_id (dvb-scan.c:200)
==6709==    by 0x40946A: dvb_get_ts_tables (dvb-scan.c:80)
==6709==    by 0x4025E2: run_scan (dvbv5-scan.c:477)

Sometimes, we're reading past of the buffer on NIT parser.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: Don't leave memory leaks on channel store failure
Mauro Carvalho Chehab [Tue, 19 Nov 2013 21:15:00 +0000 (19:15 -0200)]
libdvbv5/dvb-file: Don't leave memory leaks on channel store failure

If channel store fails, the channel var should be freed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: don't leak memory on error
Mauro Carvalho Chehab [Tue, 19 Nov 2013 20:26:11 +0000 (18:26 -0200)]
libdvbv5/descriptors: don't leak memory on error

Check buffer size before alloc, to avoid memory leaks.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: Fix extension descriptor handling
Mauro Carvalho Chehab [Tue, 19 Nov 2013 17:34:05 +0000 (15:34 -0200)]
libdvbv5/descriptors: Fix extension descriptor handling

The extension descriptor handling was wrong. Rewrite the code,
in order to make it right.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/descriptors: Fix error handling routine
Mauro Carvalho Chehab [Tue, 19 Nov 2013 17:07:57 +0000 (15:07 -0200)]
libdvbv5/descriptors: Fix error handling routine

the "current" structure is not allocated yet. Don't use it too
early.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: Fix the logic for program found check
Mauro Carvalho Chehab [Tue, 19 Nov 2013 16:41:00 +0000 (14:41 -0200)]
libdvbv5/dvb-file: Fix the logic for program found check

The logic is broken, causing a crash. Fix it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: require PAT also for ATSC
Mauro Carvalho Chehab [Tue, 19 Nov 2013 16:09:06 +0000 (14:09 -0200)]
libdvbv5/dvb-scan: require PAT also for ATSC

If the PAT table is not found, it can't proceed, even for ATSC.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvb/dvbv5-zap: Fix help message
Mauro Carvalho Chehab [Tue, 19 Nov 2013 16:08:51 +0000 (14:08 -0200)]
dvb/dvbv5-zap: Fix help message

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-scan: avoid memory leak on table read timeout
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:52:53 +0000 (07:52 -0200)]
libdvbv5/dvb-scan: avoid memory leak on table read timeout

Free buf, if table read fails with timeout.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agolibdvbv5/dvb-file: Allow using SDT for ATSC
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:49:45 +0000 (07:49 -0200)]
libdvbv5/dvb-file: Allow using SDT for ATSC

When SDT table parsing is forced, allow using it for ATSC.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvbv5-scan: release resources on errors
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:41:43 +0000 (07:41 -0200)]
dvbv5-scan: release resources on errors

If an error occurs, release memory and close the file descriptor,
if opened.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
10 years agodvb-fe: don't cause memory leak on open errors
Mauro Carvalho Chehab [Mon, 18 Nov 2013 09:41:08 +0000 (07:41 -0200)]
dvb-fe: don't cause memory leak on open errors

If open fails, release memory.

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