Skip to contentSkip to conversation

Fix a bug in scan, which outputs the wrong frequency if the current tuned transponder is scanned only

PATCH In review e9hack 3 participants 14 messages Nov 17, 2008 – Dec 8, 2008 Media (V4L/DVB)

lore
Share & tools
lore

e9hack

author
#0 lore raw

PATCH 1/1 Fix a bug in scan, which outputs the wrong frequency if the current tuned transponder is scanned only

Hi,

if the current tuned transponder is scanned only and the output needs the frequency of the transponder, it is used the last frequency, which is found during the NIT scanning. This is wrong. The attached patch will fix this problem.

Regards,
Hartmut

util/scan/scan.c +7 -5
diff -r afd0efc0f9d2 util/scan/scan.c
@@ -221,8 +221,6 @@ static struct transponder *find_transpon
 
 	list_for_each(pos, &scanned_transponders) {
 		tp = list_entry(pos, struct transponder, list);
-		if (current_tp_only)
-			return tp;
 		if (is_same_transponder(tp->param.frequency, frequency))
 			return tp;
 	}
@@ -879,9 +877,10 @@ static void parse_nit (const unsigned ch
 		if (tn.type == fe_info.type) {
 			/* only add if develivery_descriptor matches FE type */
 			t = find_transponder(tn.param.frequency);
-			if (!t)
+			if (!t && !current_tp_only)
 				t = alloc_transponder(tn.param.frequency);
-			copy_transponder(t, &tn);
+			if (t)
+				copy_transponder(t, &tn);
 		}
 
 		section_length -= descriptors_loop_len + 6;
@@ -2284,7 +2283,10 @@ int main (int argc, char **argv)
 	signal(SIGINT, handle_sigint);
 
 	if (current_tp_only) {
-		current_tp = alloc_transponder(0); /* dummy */
+		struct dvb_frontend_parameters frontend_params;
+		if (ioctl(frontend_fd, FE_GET_FRONTEND, &frontend_params) < 0)
+			fatal("FE_GET_FRONTEND failed: %d %m\n", errno);
+		current_tp = alloc_transponder(frontend_params.frequency);
 		/* move TP from "new" to "scanned" list */
 		list_del_init(&current_tp->list);
 		list_add_tail(&current_tp->list, &scanned_transponders);

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#1 lore raw

2008/11/17 e9hack <[email protected]>:

Quoted 5 lines

Hi,

if the current tuned transponder is scanned only and the output needs the frequency of the transponder, it is used the last frequency, which is found during the NIT scanning. This is wrong. The attached patch will fix this problem.

Any opinion about this patch? It seems ok from a quick look, so I'll apply it soon if nobody objects.

Quoted 2 lines

Regards,
Hartmut

Thanks,

Christoph

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#2 lore raw
Quoted 8 lines · Christoph Pfister

2008/11/17 e9hack <[email protected]>:

Quoted 3 lines

Hi,

if the current tuned transponder is scanned only and the output needs the

frequency of the

Quoted 1 line

transponder, it is used the last frequency, which is found during the NIT

scanning. This

Quoted 1 line

is wrong. The attached patch will fix this problem.

I probably missed that post (or forgot about it already :)).

What scan is being discused? dvb-apps scan utility (or the scan-s2 that I maintain)?

Quoted 4 lines

Any opinion about this patch? It seems ok from a quick look, so I'll apply it soon if nobody objects.

I don't understand what's wrong with NIT advartised frequency? For example, many satelite sites (such as lyngsat) have different frequencies listed for the same channel, generally a difference of 1 MHz here and there. That's probably caused since wide scans are probably done on all the possible frequencies.
Since driver tunning algorithm can zigzag in some frequency bounds it will probably be able to lock on the channel if you'll specify frequencies such as the following, assuming the real channel frequency is 12000000:
11998000
11999000
12000000
12001000
12002000

NIT specifies the correct frequency and that one should be used next time to tune.

Am I missing something?

Quoted 5 lines
Quoted 4 lines

Regards,
Hartmut

Quoted 9 lines

Thanks,

Christoph

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#13 lore raw
In reply to Christoph Pfister
Quoted 9 lines · Christoph Pfister

2008/11/17 e9hack <[email protected]>:

Quoted 5 lines

Hi,

if the current tuned transponder is scanned only and the output needs the frequency of the transponder, it is used the last frequency, which is found during the NIT scanning. This is wrong. The attached patch will fix this problem.

Any opinion about this patch? It seems ok from a quick look, so I'll apply it soon if nobody objects.

After some more investigation, my patch has some problems:

1)Usually the patch is only necessary for transponders, which transmits NIT data of other transponders (DVB-C only?).

2)It will not work with DVB-S. On DVB-S the returned frequency from frontend is the LNB-IF. It must be convert to the transponder frequency depend on the LNB configuration. Scan can't read the LNB configuration from frontend. It must trust the given parameters.

3)On DVB-S, the reported frequency from frontend contains the offset from zigzag scan. If the offset is greater than 2kHz, scan can't find the correct frequency within the NIT data.

3)The reported frequency from many frontends contains a measured offset. If the offset is
greater than 2kHz, see above.

Depend on this 4 points, scan should not report any transponder infos, if the current transponder is scanned only (scan does not tune itself) and if the output format must contain the frequency of the transponder.

-Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#3 lore raw
In reply to Alex Betis
Quoted 4 lines · Alex Betis

I don't understand what's wrong with NIT advartised frequency? For example, many satelite sites (such as lyngsat) have different frequencies listed for the same channel, generally a difference of 1 MHz here and there.

If I do scan the tuned transponder only (parameter '-c'), scan will copy all NIT entries to the same transponder data. The output contains the last frequency, which was found. On DVB-C, the NIT contains the frequencies of all transponders. If VDR has tuned to the 113MHz transponder and I scan this transponder, I should got 113MHz and QAM64 modulation, but I get e.g. 466MHz and QAM256 modulation. The frequency changes on every scan.

-Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#4 lore raw
Quoted 6 lines · On Tue, Dec 2, 2008 at 9:43 PM, e9hack <[email protected]> wrote:
Quoted 4 lines · Alex Betis

I don't understand what's wrong with NIT advartised frequency? For example, many satelite sites (such as lyngsat) have different frequencies listed for the same channel, generally a difference of 1 MHz here and there.

Quoted 10 lines

If I do scan the tuned transponder only (parameter '-c'), scan will copy all NIT entries
to the same transponder data. The output contains the last frequency, which was found. On
DVB-C, the NIT contains the frequencies of all transponders. If VDR has tuned to the
113MHz transponder and I scan this transponder, I should got 113MHz and QAM64 modulation,
but I get e.g. 466MHz and QAM256 modulation. The frequency changes on every scan.

What driver and scan utility do you use?
If you use S2API driver, please try my scan-s2 from here:
http://mercurial.intuxication.org/hg/scan-s2/

I did several fixes in that area. If it still doesn't work, please run it with "-vv" or "-vvv", (don't remember what level is needed) until you'll see a HEX dump of the messages, send it to me and I'll take a look.

Quoted 10 lines

-Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#5 lore raw
Quoted 1 line · Alex Betis

What driver and scan utility do you use?

I'm using the current linuxtv.org repository. I'm a DVB-C user. DVB-S2 isn't important for me.

Quoted 2 lines

If you use S2API driver, please try my scan-s2 from here:
http://mercurial.intuxication.org/hg/scan-s2/

If I use 'scan-s2 -c -o vdr', the output is wrong. I get:

Bayerisches FS Süd;ARD:201:202=deu,203=2ch;206=deu:204:0:28107:41985:1101:0

I should get:

Bayerisches FS Süd;ARD:346:M256:C:6900:201:202=deu,203=2ch;206=deu:204:0:28107:41985:0:0

Frequency, modulation, DVB type and symbol rate are still missing.

Quoted 1 line

I did several fixes in that area.

A fix for the lack ONID I did sent some time ago
(http://linuxtv.org/pipermail/linux-dvb/2007-April/017266.html). Nobody was interested. The including of the polarization into the comparison of the transponders was also discussed in the German vdr portal
(http://www.vdr-portal.de/board/thread.php?postid=746738#post746738).

I think there is a bug in the DVB-S/DVB-S2 code. If a NIT from a DVB-S transponder was scanned and a new transponder was found, parse_nit() should create a transponder for DVB-S and DVB-S2. Currently one new transponder is created and it is first initialized for DVB-S and some lines later, it is reinitialized for DVB-S2.

-Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#6 lore raw
Quoted 4 lines · On Wed, Dec 3, 2008 at 12:07 AM, e9hack <[email protected]> wrote:
Quoted 1 line · Alex Betis

What driver and scan utility do you use?

I'm using the current linuxtv.org repository. I'm a DVB-C user. DVB-S2 isn't important for me.

I have only DVB-S/S2, so I can only guess. Your help will be appreciated in order to fix DVB-C issues.

Quoted 5 lines
Quoted 3 lines

If you use S2API driver, please try my scan-s2 from here:
http://mercurial.intuxication.org/hg/scan-s2/

If I use 'scan-s2 -c -o vdr', the output is wrong. I get:

Quoted 8 lines

Bayerisches FS Süd;ARD:201:202=deu,203=2ch;206=deu:204:0:28107:41985:1101:0

I should get:

Bayerisches FS Süd;ARD:346:M256:C:6900:201:202=deu,203=2ch;206=deu:204:0:28107:41985:0:0

Frequency, modulation, DVB type and symbol rate are still missing.

That's interesting. That means the utility doesn't know what delivery system is used. Probably because it didn't tune the driver.
I'll check that. It should happen with DVB-S as well.
Can you scan the same channel without "-c" and report if the dump is correct?

Quoted 6 lines
Quoted 3 lines

I did several fixes in that area.

A fix for the lack ONID I did sent some time ago
(http://linuxtv.org/pipermail/linux-dvb/2007-April/017266.html). Nobody was interested.

That was already fixed few days ago. Take latest version.

Quoted 5 lines

The including of the polarization into the comparison of the transponders was also
discussed in the German vdr portal
(http://www.vdr-portal.de/board/thread.php?postid=746738#post746738).

That was already fixed few weeks ago.

Quoted 9 lines

I think there is a bug in the DVB-S/DVB-S2 code. If a NIT from a DVB-S transponder was
scanned and a new transponder was found, parse_nit() should create a transponder for DVB-S
and DVB-S2. Currently one new transponder is created and it is first initialized for DVB-S
and some lines later, it is reinitialized for DVB-S2.

You're right, transponder allocation is missing there. Will fix it, thanks.

Quoted 10 lines

-Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#7 lore raw
Quoted 8 lines · Alex Betis
Quoted 8 lines
Quoted 2 lines

If you use S2API driver, please try my scan-s2 from here:
http://mercurial.intuxication.org/hg/scan-s2/

If I use 'scan-s2 -c -o vdr', the output is wrong. I get:

Bayerisches FS Süd;ARD:201:202=deu,203=2ch;206=deu:204:0:28107:41985:1101:0

I should get:

Quoted 8 lines
Quoted 4 lines

Bayerisches FS Süd;ARD:346:M256:C:6900:201:202=deu,203=2ch;206=deu:204:0:28107:41985:0:0

Frequency, modulation, DVB type and symbol rate are still missing.

That's interesting. That means the utility doesn't know what delivery system is used. Probably because it didn't tune the driver.
I'll check that. It should happen with DVB-S as well.

For the current transponder scanning, it isn't set any filter for NIT parsing. Since the output format is zap and vdr only, it must be always setup a NIT filter:

scan.c Wed Dec 03 18:04:10 2008 +0100 renamed from scan.c Mon Dec 01 23:36:50 2008 +0200 +1 -1
diff -r 51eceb97c3bd scan.c
@@ -2495,7 +2503,7 @@ static void scan_tp_dvb (void)
        add_filter (&s0);
        add_filter (&s1);
 
-       if (!current_tp_only) {
+       if (/*!current_tp_only*/1) {
                setup_filter (&s2, demux_devname, PID_NIT_ST, TID_NIT_ACTUAL, -1, 1, 0,

15); /* NIT */

                add_filter (&s2);
                if (get_other_nits) {
Quoted 2 lines

Can you scan the same channel without "-c" and report if the dump is correct?

I need a little patch for tuning to DVB-C transponders:

scan.c Wed Dec 03 18:04:10 2008 +0100 renamed from scan.c Mon Dec 01 23:36:50 2008 +0200 +8 -0
diff -r 51eceb97c3bd scan.c
@@ -1729,6 +1729,14 @@ static int __tune_to_transponder (int fr
 
        switch(t->delivery_system)
        {
+       case SYS_DVBC_ANNEX_AC:
+               if_freq = t->frequency;
+
+               if (verbosity >= 2){
+                       dprintf(1,"DVB-C frequency is %d\n", if_freq);
+               }
+               break;
+
        case SYS_DVBS:
        case SYS_DVBS2:
                if (lnb_type.high_val) {

It seems that the output is correct (currently not tested with vdr).

Regards,
Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#8 lore raw

2008/12/3 e9hack <[email protected]>

Quoted 16 lines

For the current transponder scanning, it isn't set any filter for NIT parsing. Since the
output format is zap and vdr only, it must be always setup a NIT filter:

diff -r 51eceb97c3bd scan.c

scan.c Wed Dec 03 18:04:10 2008 +0100 renamed from scan.c Mon Dec 01 23:36:50 2008 +0200 +1 -1
@@ -2495,7 +2503,7 @@ static void scan_tp_dvb (void)
       add_filter (&s0);
       add_filter (&s1);
 
-       if (!current_tp_only) {
+       if (/*!current_tp_only*/1) {
               setup_filter (&s2, demux_devname, PID_NIT_ST,
 TID_NIT_ACTUAL, -1, 1, 0,

15); /* NIT */

Quoted 3 lines
               add_filter (&s2);
               if (get_other_nits) {

I forgot, frequency and modulation are wrong as in the original scan application. The values are from last parsed NIT entry, which isn't from the current transponder.

Regards,
Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#9 lore raw

2008/12/3 <[email protected]>

Quoted 13 lines

2008/12/3 e9hack <[email protected]>

Quoted 11 lines

For the current transponder scanning, it isn't set any filter for NIT parsing. Since the
output format is zap and vdr only, it must be always setup a NIT filter:

diff -r 51eceb97c3bd scan.c

scan.c Wed Dec 03 18:04:10 2008 +0100 renamed from scan.c Mon Dec 01 23:36:50 2008 +0200 +0 -0
@@ -2495,7 +2503,7 @@ static void scan_tp_dvb (void)
       add_filter (&s0);
       add_filter (&s1);
 
Quoted 12 lines
Quoted 8 lines
scan.c Wed Dec 03 18:04:10 2008 +0100 renamed from scan.c Mon Dec 01 23:36:50 2008 +0200 +1 -1
-       if (!current_tp_only) {
+       if (/*!current_tp_only*/1) {
               setup_filter (&s2, demux_devname, PID_NIT_ST,
 TID_NIT_ACTUAL, -1, 1, 0,

15); /* NIT */

               add_filter (&s2);
               if (get_other_nits) {

I forgot, frequency and modulation are wrong as in the original scan application. The values are from last parsed NIT entry, which isn't from the current transponder.

There is no need for NIT message. I've added query from driver for currently tuned parameters - should work for DVB-T and DVB-C users. DVB-S/S2 will get IF frequency, which is not the real transponder frequency. Please update to latest version.
Your other patch for DVB-C scan is also there.

Let me know if it helps.

Regards,
Alex.

Quoted 10 lines

Regards,
Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#10 lore raw
Quoted 8 lines · Alex Betis

There is no need for NIT message. I've added query from driver for currently tuned parameters - should work for DVB-T and DVB-C users. DVB-S/S2 will get IF frequency, which is not the real transponder frequency. Please update to latest version.
Your other patch for DVB-C scan is also there.

Let me know if it helps.

It works with the stv0297 and the tda10021 frontend. If the transponder was tuned with the modulation QAM_AUTO, it would be better to read the current modulation from the frontend. Currently, QAM_AUTO isn't implemented for a DVB-C frontend, but I'm working on an implementation for the stv0297.

Regards,
Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#11 lore raw
Quoted 10 lines · On Mon, Dec 8, 2008 at 10:21 PM, e9hack <[email protected]> wrote:
Quoted 1 line · Alex Betis

There is no need for NIT message. I've added query from driver for

currently

Quoted 1 line

tuned parameters - should work for DVB-T and DVB-C users. DVB-S/S2 will

get

Quoted 4 lines

IF frequency, which is not the real transponder frequency. Please update to latest version.
Your other patch for DVB-C scan is also there.

Quoted 7 lines
Quoted 2 lines

Let me know if it helps.

It works with the stv0297 and the tda10021 frontend. If the transponder was tuned with the
modulation QAM_AUTO, it would be better to read the current modulation from the frontend.

All the tuned parameters are read from the frontend, the problem is that the frontend returns the values that were used to tune, not the real tuned values, so if tuning was done with QAM_AUTO, scan-s2 output will not include modulation since frontend returned QAM_AUTO.

Quoted 4 lines

Currently, QAM_AUTO isn't implemented for a DVB-C frontend, but I'm working on an
implementation for the stv0297.

Quoted 8 lines

Regards,
Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

author
#12 lore raw
Quoted 4 lines · Alex Betis

All the tuned parameters are read from the frontend, the problem is that the frontend returns the values that were used to tune, not the real tuned values, so if tuning was done with QAM_AUTO, scan-s2 output will not include modulation since frontend returned QAM_AUTO.

The parameters are read from property cache and not from frontend. I've add a second ioctl call for FE_GET_FRONTEND. This will read the real modulation type.

Regards,
Hartmut

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb