minisatip.patch: cleanups, fix signal levels

This commit is contained in:
Jaroslav Kysela 2015-04-08 09:47:50 +02:00
parent 1298322a02
commit 2838c945b5

View File

@ -1,5 +1,5 @@
diff --git a/adapter.c b/adapter.c diff --git a/adapter.c b/adapter.c
index 285faea..086242d 100755 index 285faea..fe3ce54 100755
--- a/adapter.c --- a/adapter.c
+++ b/adapter.c +++ b/adapter.c
@@ -29,10 +29,15 @@ @@ -29,10 +29,15 @@
@ -106,38 +106,27 @@ index 285faea..086242d 100755
if (a[na].fe > 0) if (a[na].fe > 0)
close (a[na].fe); close (a[na].fe);
if (a[na].sock >= 0) if (a[na].sock >= 0)
@@ -366,7 +416,29 @@ close_adapter_for_stream (int sid, int aid) @@ -366,8 +416,8 @@ close_adapter_for_stream (int sid, int aid)
// delete the attached PIDs as well // delete the attached PIDs as well
mark_pids_deleted (aid, sid, NULL); mark_pids_deleted (aid, sid, NULL);
update_pids (aid); update_pids (aid);
-// if (a[aid].sid_cnt == 0) -// if (a[aid].sid_cnt == 0)
+#ifdef AXE -// close_adapter (aid);
+ if (a[aid].sid_cnt == 0) { + if (a[aid].sid_cnt == 0)
+ int i; + close_adapter (aid);
+ char buf[50];
+ axe_fe_reset(a[aid].fe);
+ axe_set_tuner_led(aid + 1, 0);
+ for (i = 0; i < 4; i++)
+ if (i != aid && a[i].sid_cnt > 0) break;
+ if (i >= 4) {
+ LOG("AXE standby");
+ for (i = 0; i < 4; i++) {
+ axe_fe_standby(a[i].fe, -1);
+ ioctl(a[i].fe, FE_SET_VOLTAGE, SEC_VOLTAGE_OFF);
+ a[i].tp.old_diseqc = a[i].tp.old_pol = a[i].tp.old_hiband = -1;
+ }
+ } else {
+ LOG("AXE standby: adapter %d busy (%d), keeping", i, a[i].sid_cnt);
+ }
+ sockets_del(a[aid].sock);
+ a[aid].sock = -1;
+ }
+#endif
+// if (a[aid].sid_cnt == 0)
// close_adapter (aid);
} }
@@ -419,7 +491,10 @@ int tune (int aid, int sid)
@@ -410,7 +460,7 @@ update_pids (int aid)
int tune (int aid, int sid)
{
adapter *ad = get_adapter(aid);
- int i, rv = 0;
+ int rv = 0;
if(!ad) return -400;
ad->last_sort = getTick ();
@@ -419,7 +469,10 @@ int tune (int aid, int sid)
ad->tp.switch_type = ad->switch_type; ad->tp.switch_type = ad->switch_type;
ad->tp.uslot = ad->uslot; ad->tp.uslot = ad->uslot;
ad->tp.ufreq = ad->ufreq; ad->tp.ufreq = ad->ufreq;
@ -149,26 +138,18 @@ index 285faea..086242d 100755
rv = tune_it_s2 (ad->fe, &ad->tp); rv = tune_it_s2 (ad->fe, &ad->tp);
a[aid].status = 0; a[aid].status = 0;
a[aid].status_cnt = 0; a[aid].status_cnt = 0;
@@ -428,6 +503,18 @@ int tune (int aid, int sid) @@ -428,6 +481,10 @@ int tune (int aid, int sid)
close_streams_for_adapter (aid, sid); close_streams_for_adapter (aid, sid);
update_pids (aid); update_pids (aid);
} }
+#ifdef AXE +#ifdef AXE
+ if (a[aid].dvr < 0) {
+ char buf[32];
+ sprintf (buf, "/dev/axe/demuxts-%d", a[i].pa);
+ a[aid].dvr = open (buf, O_RDONLY | O_NONBLOCK);
+ a[i].sock =
+ sockets_add (a[i].dvr, NULL, i, TYPE_DVR, (socket_action) read_dmx,
+ (socket_action) close_adapter_for_socket, (socket_action ) adapter_timeout);
+ }
+ if (rv < 0) + if (rv < 0)
+ axe_set_tuner_led(aid + 1, 0); + axe_set_tuner_led(aid + 1, 0);
+#endif +#endif
} }
else else
LOG ("not tuning for SID %d (do_tune=%d, master_sid=%d)", sid, LOG ("not tuning for SID %d (do_tune=%d, master_sid=%d)", sid,
@@ -684,7 +771,11 @@ describe_adapter (int sid, int aid) @@ -684,7 +741,11 @@ describe_adapter (int sid, int aid)
memset (dad, 0, sizeof (dad)); memset (dad, 0, sizeof (dad));
x = 0; x = 0;
// do just max 3 signal check 1s after tune // do just max 3 signal check 1s after tune
@ -180,7 +161,7 @@ index 285faea..086242d 100755
{ {
int new_gs = 1; int new_gs = 1;
ts = getTick (); ts = getTick ();
@@ -701,11 +792,20 @@ describe_adapter (int sid, int aid) @@ -701,11 +762,20 @@ describe_adapter (int sid, int aid)
if (ad->max_snr <= ad->snr) ad->max_snr = (ad->snr>0)?ad->snr:1; if (ad->max_snr <= ad->snr) ad->max_snr = (ad->snr>0)?ad->snr:1;
LOG ("get_signal%s took %d ms for adapter %d handle %d (status: %d, ber: %d, strength:%d, snr: %d, max_strength: %d, max_snr: %d %d)", LOG ("get_signal%s took %d ms for adapter %d handle %d (status: %d, ber: %d, strength:%d, snr: %d, max_strength: %d, max_snr: %d %d)",
new_gs?"":"_new", getTick () - ts, aid, ad->fe, ad->status, ad->ber, ad->strength, ad->snr, ad->max_strength, ad->max_snr, opts.force_scan); new_gs?"":"_new", getTick () - ts, aid, ad->fe, ad->status, ad->ber, ad->strength, ad->snr, ad->max_strength, ad->max_snr, opts.force_scan);
@ -191,7 +172,7 @@ index 285faea..086242d 100755
ad->snr = ad->snr * 15 / ad->max_snr; ad->snr = ad->snr * 15 / ad->max_snr;
} }
+#else +#else
+ ad->strength = ad->strength * 240 / 9000; + ad->strength = ad->strength * 240 / 24000;
+ if (ad->strength > 240) + if (ad->strength > 240)
+ ad->strength = 240; + ad->strength = 240;
+ ad->snr = ad->snr * 15 / 54000; + ad->snr = ad->snr * 15 / 54000;
@ -201,7 +182,7 @@ index 285faea..086242d 100755
} }
if(use_ad) if(use_ad)
{ {
@@ -715,14 +815,14 @@ describe_adapter (int sid, int aid) @@ -715,14 +785,14 @@ describe_adapter (int sid, int aid)
} }
if (t->sys == SYS_DVBS || t->sys == SYS_DVBS2) if (t->sys == SYS_DVBS || t->sys == SYS_DVBS2)
sprintf (dad, "ver=1.0;src=%d;tuner=%d,%d,%d,%d,%d,%s,%s,%s,%s,%s,%d,%s;pids=", sprintf (dad, "ver=1.0;src=%d;tuner=%d,%d,%d,%d,%d,%s,%s,%s,%s,%s,%d,%s;pids=",
@ -339,7 +320,7 @@ index 0000000..c29131d
+ +
+#endif +#endif
diff --git a/dvb.c b/dvb.c diff --git a/dvb.c b/dvb.c
index 5701bd2..b75918c 100755 index 5701bd2..f55d26e 100755
--- a/dvb.c --- a/dvb.c
+++ b/dvb.c +++ b/dvb.c
@@ -41,6 +41,10 @@ @@ -41,6 +41,10 @@
@ -440,7 +421,7 @@ index 5701bd2..b75918c 100755
}else }else
{ {
if(tp->old_pol != pol || tp->old_hiband != hiband || tp->old_diseqc != diseqc) if(tp->old_pol != pol || tp->old_hiband != hiband || tp->old_diseqc != diseqc)
@@ -343,6 +395,25 @@ int setup_switch (int frontend_fd, transponder *tp) @@ -343,6 +395,26 @@ int setup_switch (int frontend_fd, transponder *tp)
else else
LOGL(3, "Skip sending diseqc commands since the switch position doesn't need to be changed: pol %d, hiband %d, switch position %d", pol, hiband, diseqc); LOGL(3, "Skip sending diseqc commands since the switch position doesn't need to be changed: pol %d, hiband %d, switch position %d", pol, hiband, diseqc);
} }
@ -450,6 +431,7 @@ index 5701bd2..b75918c 100755
+ if (tp->switch_type != SWITCH_UNICABLE && tp->switch_type != SWITCH_JESS) { + if (tp->switch_type != SWITCH_UNICABLE && tp->switch_type != SWITCH_JESS) {
+ for (aid = 0; aid < 4; aid++) { + for (aid = 0; aid < 4; aid++) {
+ adapter *a = get_adapter(aid); + adapter *a = get_adapter(aid);
+ LOGL(3, "axe adapter %i fe fd %d", aid, a->fe);
+ if (a && a->fe == frontend_fd) + if (a && a->fe == frontend_fd)
+ break; + break;
+ } + }
@ -466,7 +448,7 @@ index 5701bd2..b75918c 100755
tp->old_pol = pol; tp->old_pol = pol;
tp->old_hiband = hiband; tp->old_hiband = hiband;
@@ -383,8 +454,10 @@ tune_it_s2 (int fd_frontend, transponder * tp) @@ -383,8 +455,10 @@ tune_it_s2 (int fd_frontend, transponder * tp)
{.cmd = DTV_INVERSION,.u.data = 0}, {.cmd = DTV_INVERSION,.u.data = 0},
{.cmd = DTV_SYMBOL_RATE,.u.data = 0}, {.cmd = DTV_SYMBOL_RATE,.u.data = 0},
{.cmd = DTV_INNER_FEC,.u.data = 0}, {.cmd = DTV_INNER_FEC,.u.data = 0},
@ -477,7 +459,7 @@ index 5701bd2..b75918c 100755
{.cmd = DTV_TUNE}, {.cmd = DTV_TUNE},
}; };
static struct dtv_properties dvbs2_cmdseq = static struct dtv_properties dvbs2_cmdseq =
@@ -465,8 +538,10 @@ tune_it_s2 (int fd_frontend, transponder * tp) @@ -465,8 +539,10 @@ tune_it_s2 (int fd_frontend, transponder * tp)
p = &dvbs2_cmdseq; p = &dvbs2_cmdseq;
p->props[DELSYS].u.data = tp->sys; p->props[DELSYS].u.data = tp->sys;
p->props[MODULATION].u.data = tp->mtype; p->props[MODULATION].u.data = tp->mtype;
@ -488,7 +470,7 @@ index 5701bd2..b75918c 100755
p->props[INVERSION].u.data = tp->inversion; p->props[INVERSION].u.data = tp->inversion;
p->props[SYMBOL_RATE].u.data = tp->sr; p->props[SYMBOL_RATE].u.data = tp->sr;
p->props[FEC_INNER].u.data = tp->fec; p->props[FEC_INNER].u.data = tp->fec;
@@ -475,7 +550,12 @@ tune_it_s2 (int fd_frontend, transponder * tp) @@ -475,7 +551,12 @@ tune_it_s2 (int fd_frontend, transponder * tp)
LOG("tuning to %d(%d) pol: %s (%d) sr:%d fec:%s delsys:%s mod:%s rolloff:%s pilot:%s, ts clear=%d, ts pol=%d", LOG("tuning to %d(%d) pol: %s (%d) sr:%d fec:%s delsys:%s mod:%s rolloff:%s pilot:%s, ts clear=%d, ts pol=%d",
tp->freq, p->props[FREQUENCY].u.data, get_pol(tp->pol), tp->pol, p->props[SYMBOL_RATE].u.data, fe_fec[p->props[FEC_INNER].u.data], tp->freq, p->props[FREQUENCY].u.data, get_pol(tp->pol), tp->pol, p->props[SYMBOL_RATE].u.data, fe_fec[p->props[FEC_INNER].u.data],
fe_delsys[p->props[DELSYS].u.data], fe_modulation[p->props[MODULATION].u.data], fe_delsys[p->props[DELSYS].u.data], fe_modulation[p->props[MODULATION].u.data],
@ -502,7 +484,7 @@ index 5701bd2..b75918c 100755
break; break;
@@ -560,6 +640,20 @@ set_pid (int hw, int ad, uint16_t i_pid) @@ -560,6 +641,20 @@ set_pid (int hw, int ad, uint16_t i_pid)
char buf[100]; char buf[100];
int fd; int fd;
@ -523,7 +505,7 @@ index 5701bd2..b75918c 100755
if ( i_pid > 8192 ) if ( i_pid > 8192 )
LOG_AND_RETURN(-1, "pid %d > 8192 for /dev/dvb/adapter%d/demux%d", i_pid, hw, ad); LOG_AND_RETURN(-1, "pid %d > 8192 for /dev/dvb/adapter%d/demux%d", i_pid, hw, ad);
@@ -585,6 +679,7 @@ set_pid (int hw, int ad, uint16_t i_pid) @@ -585,6 +680,7 @@ set_pid (int hw, int ad, uint16_t i_pid)
} }
LOG ("setting filter on PID %d for fd %d", i_pid, fd); LOG ("setting filter on PID %d for fd %d", i_pid, fd);
@ -531,7 +513,7 @@ index 5701bd2..b75918c 100755
return fd; return fd;
} }
@@ -592,6 +687,17 @@ set_pid (int hw, int ad, uint16_t i_pid) @@ -592,6 +688,17 @@ set_pid (int hw, int ad, uint16_t i_pid)
int del_filters (int fd, int pid) int del_filters (int fd, int pid)
{ {
@ -542,14 +524,14 @@ index 5701bd2..b75918c 100755
+ if ((fd & 0xffff) != pid) + if ((fd & 0xffff) != pid)
+ LOG_AND_RETURN(0, "AXE PID remove on an invalid handle %d, pid %d", fd, pid); + LOG_AND_RETURN(0, "AXE PID remove on an invalid handle %d, pid %d", fd, pid);
+ if (axe_dmxts_remove_pid(a->dvr, pid) < 0) + if (axe_dmxts_remove_pid(a->dvr, pid) < 0)
+ LOG ("AXE PID removew failed on PID %d ADAPTER %d: %s", pid, a->pa, strerror (errno)) + LOG ("AXE PID remove failed on PID %d ADAPTER %d: %s", pid, a->pa, strerror (errno))
+ else + else
+ LOG ("clearing filters on PID %d ADAPTER %d", pid, a->pa); + LOG ("clearing filters on PID %d ADAPTER %d", pid, a->pa);
+#else +#else
if (fd < 0) if (fd < 0)
LOG_AND_RETURN(0, "DMX_STOP on an invalid handle %d, pid %d", fd, pid); LOG_AND_RETURN(0, "DMX_STOP on an invalid handle %d, pid %d", fd, pid);
if (ioctl (fd, DMX_STOP) < 0) if (ioctl (fd, DMX_STOP) < 0)
@@ -599,6 +705,7 @@ int del_filters (int fd, int pid) @@ -599,6 +706,7 @@ int del_filters (int fd, int pid)
else else
LOG ("clearing filters on PID %d FD %d", pid, fd); LOG ("clearing filters on PID %d FD %d", pid, fd);
close (fd); close (fd);
@ -557,7 +539,7 @@ index 5701bd2..b75918c 100755
return 0; return 0;
} }
@@ -606,6 +713,15 @@ int del_filters (int fd, int pid) @@ -606,6 +714,15 @@ int del_filters (int fd, int pid)
fe_delivery_system_t fe_delivery_system_t
dvb_delsys (int aid, int fd, fe_delivery_system_t *sys) dvb_delsys (int aid, int fd, fe_delivery_system_t *sys)
{ {
@ -573,7 +555,7 @@ index 5701bd2..b75918c 100755
int i, res, rv = 0; int i, res, rv = 0;
struct dvb_frontend_info fe_info; struct dvb_frontend_info fe_info;
@@ -703,6 +819,7 @@ dvb_delsys (int aid, int fd, fe_delivery_system_t *sys) @@ -703,6 +820,7 @@ dvb_delsys (int aid, int fd, fe_delivery_system_t *sys)
LOG ("returning default from dvb_delsys => %s (count %d)", fe_delsys[rv] , nsys); LOG ("returning default from dvb_delsys => %s (count %d)", fe_delsys[rv] , nsys);
return (fe_delivery_system_t) rv; return (fe_delivery_system_t) rv;