From: Jaroslav Kysela Date: Thu, 22 Sep 2016 15:39:47 +0000 (+0200) Subject: linuxdvb: unicable II - correct frequency calculation X-Git-Tag: v4.2.1~303 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f79dff5c02eea389dc5a395d4d457a5849ccd02;p=thirdparty%2Ftvheadend.git linuxdvb: unicable II - correct frequency calculation --- diff --git a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c index dd92d98fc..d7ce5f327 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c @@ -221,8 +221,8 @@ linuxdvb_en50494_freq0 { /* transponder value - t */ *t = round((((freq / 1000) + 2 + le->le_frequency) / 4) - 350); - if (*t > 1024) { - tvherror(LS_EN50494, "transponder value bigger then 1024"); + if (*t >= 1023) { + tvherror(LS_EN50494, "transponder value bigger then 1023 for freq %d (%d)", freq, le->le_frequency); return -1; } @@ -231,6 +231,22 @@ linuxdvb_en50494_freq0 return 0; } +static int +linuxdvb_en50607_freq0 + ( linuxdvb_en50494_t *le, int freq, int *rfreq, uint16_t *t ) +{ + /* transponder value - t */ + *t = round(freq / 1000) - 100; + if (*t > 2047) { + tvherror(LS_EN50494, "transponder value bigger then 2047 for freq %d (%d)", freq, le->le_frequency); + return -1; + } + + /* tune frequency for the frontend */ + *rfreq = le->le_frequency * 1000; + return 0; +} + static int linuxdvb_en50494_freq ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, int freq ) @@ -263,12 +279,12 @@ linuxdvb_en50494_tune uint8_t data1, data2, data3; uint16_t t; - /* tune frequency for the frontend */ - if (linuxdvb_en50494_freq0(le, freq, &rfreq, &t)) - return -1; - le->le_tune_freq = rfreq; if (!ver2) { + /* tune frequency for the frontend */ + if (linuxdvb_en50494_freq0(le, freq, &rfreq, &t)) + return -1; + le->le_tune_freq = rfreq; /* 2 data fields (16bit) */ data1 = (le->le_id & 7) << 5; /* 3bit user-band */ data1 |= (le->le_position & 1) << 4; /* 1bit position (satellite A(0)/B(1)) */ @@ -278,6 +294,10 @@ linuxdvb_en50494_tune data2 = t & 0xff; /* 8bit transponder value bit 3-10 */ data3 = 0; } else { + /* tune frequency for the frontend */ + if (linuxdvb_en50607_freq0(le, freq, &rfreq, &t)) + return -1; + le->le_tune_freq = rfreq; /* 3 data fields (24bit) */ data1 = (le->le_id & 0x1f) << 3; /* 5bit user-band */ data1 |= (t >> 8) & 7; /* 3bit transponder value bit 1-3 */