Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
linuxdvb: add linuxdvb_frontend_clear(), fixes #2547
  • Loading branch information
perexg committed Dec 15, 2014
1 parent 82cb4f7 commit c08adfd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
61 changes: 38 additions & 23 deletions src/input/mpegts/linuxdvb/linuxdvb_frontend.c
Expand Up @@ -979,6 +979,41 @@ int linuxdvb2tvh_delsys ( int delsys )
}
#endif

int
linuxdvb_frontend_clear
( linuxdvb_frontend_t *lfe )
{
char buf1[256];

/* Open FE */
lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1));

if (lfe->lfe_fe_fd <= 0) {
lfe->lfe_fe_fd = tvh_open(lfe->lfe_fe_path, O_RDWR | O_NONBLOCK, 0);
tvhtrace("linuxdvb", "%s - opening FE %s (%d)", buf1, lfe->lfe_fe_path, lfe->lfe_fe_fd);
if (lfe->lfe_fe_fd <= 0) {
return SM_CODE_TUNING_FAILED;
}
}
lfe->lfe_locked = 0;
lfe->lfe_status = 0;

#if DVB_API_VERSION >= 5
static struct dtv_property clear_p[] = {
{ .cmd = DTV_CLEAR },
};
static struct dtv_properties clear_cmdseq = {
.num = 1,
.props = clear_p
};
if ((ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &clear_cmdseq)) != 0) {
tvherror("linuxdvb", "%s - DTV_CLEAR failed [e=%s]", buf1, strerror(errno));
return -1;
}
#endif

return 0;
}

int
linuxdvb_frontend_tune0
Expand Down Expand Up @@ -1113,18 +1148,10 @@ linuxdvb_frontend_tune0
dvb_mux_conf_t *dmc;
struct dvb_frontend_parameters p;

/* Open FE */
lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1));
r = linuxdvb_frontend_clear(lfe);
if (r) return r;

if (lfe->lfe_fe_fd <= 0) {
lfe->lfe_fe_fd = tvh_open(lfe->lfe_fe_path, O_RDWR | O_NONBLOCK, 0);
tvhtrace("linuxdvb", "%s - opening FE %s (%d)", buf1, lfe->lfe_fe_path, lfe->lfe_fe_fd);
if (lfe->lfe_fe_fd <= 0) {
return SM_CODE_TUNING_FAILED;
}
}
lfe->lfe_locked = 0;
lfe->lfe_status = 0;
lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1));

/*
* copy the universal parameters to the Linux kernel structure
Expand Down Expand Up @@ -1184,18 +1211,6 @@ linuxdvb_frontend_tune0
struct dtv_property cmds[20];
struct dtv_properties cmdseq;

/* Clear Q */
static struct dtv_property clear_p[] = {
{ .cmd = DTV_CLEAR },
};
static struct dtv_properties clear_cmdseq = {
.num = 1,
.props = clear_p
};
if ((ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &clear_cmdseq)) != 0) {
tvherror("linuxdvb", "%s - DTV_CLEAR failed [e=%s]", buf1, strerror(errno));
return -1;
}

if (freq == (uint32_t)-1)
freq = p.frequency;
Expand Down
2 changes: 2 additions & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_private.h
Expand Up @@ -256,6 +256,8 @@ void linuxdvb_frontend_delete ( linuxdvb_frontend_t *lfe );
void linuxdvb_frontend_add_network
( linuxdvb_frontend_t *lfe, linuxdvb_network_t *net );

int linuxdvb_frontend_clear
( linuxdvb_frontend_t *lfe );
int linuxdvb_frontend_tune0
( linuxdvb_frontend_t *lfe, mpegts_mux_instance_t *mmi, uint32_t freq );
int linuxdvb_frontend_tune1
Expand Down
13 changes: 13 additions & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_satconf.c
Expand Up @@ -790,10 +790,23 @@ linuxdvb_satconf_start_mux
f = lse->lse_lnb->lnb_freq(lse->lse_lnb, lm);
if (f == (uint32_t)-1)
return SM_CODE_TUNING_FAILED;
#if 0
// Note: unfortunately, this test also "delays" the valid
// tune request, so it's disabled now until we create
// own parameter validator
if (!lse->lse_en50494) {
r = linuxdvb_frontend_tune0(lfe, mmi, f);
if (r) return r;
} else {
/* Clear the frontend settings, open frontend fd */
r = linuxdvb_frontend_clear(lfe);
if (r) return r;
}
#else
/* Clear the frontend settings, open frontend fd */
r = linuxdvb_frontend_clear(lfe);
if (r) return r;
#endif

/* Diseqc */
ls->ls_mmi = mmi;
Expand Down

0 comments on commit c08adfd

Please sign in to comment.