Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
en50494: optimization for previous patch, move code to linuxdvb_en504…
…94.c, fixes #3081
  • Loading branch information
perexg committed Sep 18, 2015
1 parent 8f8aa97 commit 29eb2eb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
44 changes: 35 additions & 9 deletions src/input/mpegts/linuxdvb/linuxdvb_en50494.c
Expand Up @@ -155,24 +155,49 @@ const idclass_t linuxdvb_en50494_class =
* Class methods
* *************************************************************************/

static int
linuxdvb_en50494_freq0
( linuxdvb_en50494_t *le, int freq, int *rfreq, uint16_t *t )
{
/* transponder value - t */
*t = round((((freq / 1000) + 2 + le->le_frequency) / 4) - 350);
if (*t > 1024) {
tvherror("en50494", "transponder value bigger then 1024");
return -1;
}

/* tune frequency for the frontend */

This comment has been minimized.

Copy link
@Jalle19

Jalle19 Sep 18, 2015

Contributor

I doubt I'd understand this code anyway, but these two integers are pretty indistinguishable from magic in this context.

This comment has been minimized.

Copy link
@InuSasha

InuSasha Sep 20, 2015

Contributor

@Jalle19 this formal is defined by the standard. The values are not described in the standard, only the plain formal is given...
This is meehh... i know :(

*rfreq = (*t + 350) * 4000 - freq;
return 0;
}

static int
linuxdvb_en50494_freq
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, int freq )
{
linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld;
int rfreq;
uint16_t t;

if (linuxdvb_en50494_freq0(le, freq, &rfreq, &t))
return -1;
return freq;
}

static int
linuxdvb_en50494_tune
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm,
linuxdvb_satconf_t *lsp, linuxdvb_satconf_ele_t *sc,
int vol, int pol, int band, int freq )
{
int ret = 0, i, fd = linuxdvb_satconf_fe_fd(lsp);
int ret = 0, i, fd = linuxdvb_satconf_fe_fd(lsp), rfreq;
linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld;

/* transponder value - t*/
uint16_t t = round((( (freq / 1000) + 2 + le->le_frequency) / 4) - 350);
if ( t > 1024) {
tvherror("en50494", "transponder value bigger then 1024");
return -1;
}
uint16_t t;

/* tune frequency for the frontend */
le->le_tune_freq = (t + 350) * 4000 - freq;
if (linuxdvb_en50494_freq0(le, freq, &rfreq, &t))
return -1;
le->le_tune_freq = rfreq;

/* 2 data fields (16bit) */
uint8_t data1, data2;
Expand Down Expand Up @@ -295,6 +320,7 @@ linuxdvb_en50494_create0
le->le_id = 0;
le->le_frequency = 0;
le->le_pin = LINUXDVB_EN50494_NOPIN;
le->ld_freq = linuxdvb_en50494_freq;

ld = linuxdvb_diseqc_create0((linuxdvb_diseqc_t *)le,
NULL, &linuxdvb_en50494_class, conf,
Expand Down
3 changes: 2 additions & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_private.h
Expand Up @@ -309,6 +309,7 @@ struct linuxdvb_diseqc
const char *ld_type;
linuxdvb_satconf_ele_t *ld_satconf;
int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm);
int (*ld_freq) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm, int freq);
int (*ld_tune) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm,
linuxdvb_satconf_t *lsp, linuxdvb_satconf_ele_t *ls,
int vol, int pol, int band, int freq);
Expand All @@ -328,7 +329,7 @@ struct linuxdvb_en50494
{
linuxdvb_diseqc_t;

/* en50494 configuration*/
/* en50494 configuration */
uint16_t le_position; /* satelitte A(0) or B(1) */
uint16_t le_frequency; /* user band frequency in MHz */
uint16_t le_id; /* user band id 0-7 */
Expand Down
10 changes: 5 additions & 5 deletions src/input/mpegts/linuxdvb/linuxdvb_satconf.c
Expand Up @@ -853,15 +853,15 @@ linuxdvb_satconf_start_mux

/* calculate tuning frequency for en50494 */
if (lse->lse_en50494) {
/* transponder value - t*/
uint16_t t = round((( (f / 1000) + 2 + (((linuxdvb_en50494_t*)lse->lse_en50494)->le_frequency)) / 4) - 350);
if ( t > 1024) {
tvherror("en50494", "transponder value bigger then 1024");
r = lse->lse_en50494->ld_freq(lse->lse_en50494, lm, f);
if (r < 0) {
tvherror("en50494", "invalid tuning freq");
return -1;
}
/* tune frequency for the frontend */
f = (t + 350) * 4000 - f;
f = r;
}

r = linuxdvb_frontend_tune0(lfe, mmi, f);
if (r) return r;
} else {
Expand Down

0 comments on commit 29eb2eb

Please sign in to comment.