From: Jaroslav Kysela Date: Sat, 13 Oct 2018 10:36:05 +0000 (+0200) Subject: linuxdvb: support properly PLS ROOT X-Git-Tag: v4.2.8~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81f56cc89b844fbbd1085b1bee1e271c64179458;p=thirdparty%2Ftvheadend.git linuxdvb: support properly PLS ROOT --- diff --git a/src/input/mpegts/dvb.h b/src/input/mpegts/dvb.h index 2b5533564..7eabd9c8a 100644 --- a/src/input/mpegts/dvb.h +++ b/src/input/mpegts/dvb.h @@ -679,6 +679,8 @@ static inline int dvb_modulation_is_none_or_auto ( int modulation ) modulation == DVB_MOD_QAM_AUTO; } +uint32_t dvb_sat_pls( dvb_mux_conf_t *dmc ); + #endif /* ENABLE_MPEGTS_DVB */ void dvb_init ( void ); diff --git a/src/input/mpegts/dvb_support.c b/src/input/mpegts/dvb_support.c index 5641464e6..8febb24ec 100644 --- a/src/input/mpegts/dvb_support.c +++ b/src/input/mpegts/dvb_support.c @@ -1170,6 +1170,23 @@ dvb_sat_position_from_str( const char *buf ) return (maj * 10 + min) * (c == 'W' ? -1 : 1); } +uint32_t +dvb_sat_pls( dvb_mux_conf_t *dmc ) +{ + if (dmc->dmc_fe_pls_mode == DVB_PLS_ROOT) { + uint32_t x, g; + const uint32_t root = dmc->dmc_fe_pls_code & 0x3ffff; + + for (g = 0, x = 1; g < 0x3ffff; g++) { + if (root == x) + return g; + x = (((x ^ (x >> 7)) & 1) << 17) | (x >> 1); + } + return 0x3ffff; + } + return dmc->dmc_fe_pls_code & 0x3ffff; +} + #endif /* ENABLE_MPEGTS_DVB */ /** diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 62214a3a8..7d2371f92 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -1836,7 +1836,7 @@ linuxdvb_frontend_tune0 #if DVB_VER_ATLEAST(5,9) S2CMD(DTV_STREAM_ID, r); #if DVB_VER_ATLEAST(5,11) - S2CMD(DTV_SCRAMBLING_SEQUENCE_INDEX, dmc->dmc_fe_pls_code & 0x3FFFF); + S2CMD(DTV_SCRAMBLING_SEQUENCE_INDEX, dvb_sat_pls(dmc)); #endif #elif DVB_VER_ATLEAST(5,3) S2CMD(DTV_DVBT2_PLP_ID, r); @@ -1877,7 +1877,7 @@ linuxdvb_frontend_tune0 #if DVB_VER_ATLEAST(5,9) S2CMD(DTV_STREAM_ID, r); #if DVB_VER_ATLEAST(5,11) - S2CMD(DTV_SCRAMBLING_SEQUENCE_INDEX, dmc->dmc_fe_pls_code & 0x3FFFF); + S2CMD(DTV_SCRAMBLING_SEQUENCE_INDEX, dvb_sat_pls(dmc)); #endif #elif DVB_VER_ATLEAST(5,3) S2CMD(DTV_DVBT2_PLP_ID, r);