From 5c032058b9bab97b363d6fb90f1250bbbeb0c7c6 Mon Sep 17 00:00:00 2001 From: Ralph Metzler Date: Fri, 11 Aug 2017 16:03:45 +0200 Subject: [PATCH] add support for PLS --- frontends/mxl5xx.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/frontends/mxl5xx.c b/frontends/mxl5xx.c index 6d3b6f9..6e7d481 100644 --- a/frontends/mxl5xx.c +++ b/frontends/mxl5xx.c @@ -424,9 +424,22 @@ static int get_algo(struct dvb_frontend *fe) return DVBFE_ALGO_HW; } -/* -static int cfg_scrambler(struct mxl *state) +/* This should maybe go into dvb-core/dvb_math.c */ + +static u32 gold2root(u32 gold) { + u32 x, g; + + if (gold >= 0x3ffff) + gold = 0; + for (g = 0, x = 1; g < gold; g++) + x = (((x ^ (x >> 7)) & 1) << 17) | (x >> 1); + return x; +} + +static int cfg_scrambler(struct mxl *state, u32 gold) +{ + u32 root; u8 buf[26] = { MXL_HYDRA_PLID_CMD_WRITE, 24, 0, MXL_HYDRA_DEMOD_SCRAMBLE_CODE_CMD, 0, 0, @@ -435,11 +448,18 @@ static int cfg_scrambler(struct mxl *state) 0, 0, 0, 0, 1, 0, 0, 0, }; + if (gold != NO_SCRAMBLING_CODE) + root = gold2root(gold); + else + root = 1; + buf[25] = (root >> 24) & 0xff; + buf[24] = (root >> 16) & 0xff; + buf[23] = (root >> 8) & 0xff; + buf[22] = root & 0xff; + return send_command(state, sizeof(buf), buf); } -*/ - static int CfgDemodAbortTune(struct mxl *state) { MXL_HYDRA_DEMOD_ABORT_TUNE_T abortTuneCmd; @@ -510,7 +530,7 @@ static int set_parameters(struct dvb_frontend *fe) demodChanCfg.rollOff = MXL_HYDRA_ROLLOFF_AUTO; demodChanCfg.modulationScheme = MXL_HYDRA_MOD_AUTO; demodChanCfg.pilots = MXL_HYDRA_PILOTS_AUTO; - //cfg_scrambler(state); + cfg_scrambler(state, p->pls); break; default: return -EINVAL;