Make it compile even for systems with Linux DVB API version < 5

This commit is contained in:
Andreas Öman 2009-09-02 21:35:19 +00:00
parent a6ddc44fcc
commit 599d50bf25
5 changed files with 80 additions and 40 deletions

View file

@ -19,9 +19,11 @@
#ifndef DVB_H_
#define DVB_H_
#include <linux/dvb/version.h>
#include <linux/dvb/frontend.h>
#include "htsmsg.h"
TAILQ_HEAD(th_dvb_adapter_queue, th_dvb_adapter);
RB_HEAD(th_dvb_mux_instance_tree, th_dvb_mux_instance);
TAILQ_HEAD(th_dvb_mux_instance_queue, th_dvb_mux_instance);
@ -64,9 +66,11 @@ typedef struct dvb_mux_conf {
struct dvb_frontend_parameters dmc_fe_params;
int dmc_polarisation;
dvb_satconf_t *dmc_satconf;
fe_modulation_t dmc_fe_modulation;
#if DVB_API_VERSION >= 5
fe_modulation_t dmc_fe_modulation;
fe_delivery_system_t dmc_fe_delsys;
fe_rolloff_t dmc_fe_rolloff;
#endif
} dvb_mux_conf_t;

View file

@ -601,12 +601,16 @@ dvb_fe_opts(th_dvb_adapter_t *tda, const char *which)
fe_opts_add(a, "2/3", FEC_2_3);
fe_opts_add(a, "3/4", FEC_3_4);
fe_opts_add(a, "4/5", FEC_4_5);
#if DVB_API_VERSION >= 5
fe_opts_add(a, "3/5", FEC_3_5);
#endif
fe_opts_add(a, "5/6", FEC_5_6);
fe_opts_add(a, "6/7", FEC_6_7);
fe_opts_add(a, "7/8", FEC_7_8);
fe_opts_add(a, "8/9", FEC_8_9);
#if DVB_API_VERSION >= 5
fe_opts_add(a, "9/10", FEC_9_10);
#endif
return a;
}

View file

@ -174,6 +174,8 @@ dvb_fe_stop(th_dvb_mux_instance_t *tdmi)
}
#if DVB_API_VERSION >= 5
static int check_frontend (int fe_fd, int dvr, int human_readable) {
(void)dvr;
fe_status_t status;
@ -282,6 +284,7 @@ dvb_fe_tune_s2(th_dvb_mux_instance_t *tdmi, const char *name)
}
#endif
/**
*
@ -353,9 +356,11 @@ dvb_fe_tune(th_dvb_mux_instance_t *tdmi, const char *reason)
"dvb", "\"%s\" tuning to \"%s\" (%s)", tda->tda_rootpath, buf,
reason);
#if DVB_API_VERSION >= 5
if (tda->tda_type == FE_QPSK)
r = dvb_fe_tune_s2(tdmi, buf);
else
#endif
r = 0;
if(r)

View file

@ -133,10 +133,13 @@ tdmi_compare_conf(int adapter_type,
case FE_QPSK:
return memcmp(&a->dmc_fe_params.u.qpsk,
&b->dmc_fe_params.u.qpsk,
sizeof(a->dmc_fe_params.u.qpsk)) ||
a->dmc_fe_modulation != b->dmc_fe_modulation ||
sizeof(a->dmc_fe_params.u.qpsk))
#if DVB_API_VERSION >= 5
|| a->dmc_fe_modulation != b->dmc_fe_modulation
a->dmc_fe_delsys != b->dmc_fe_delsys ||
a->dmc_fe_rolloff != b->dmc_fe_rolloff;
a->dmc_fe_rolloff != b->dmc_fe_rolloff
#endif
;
}
return 0;
}
@ -320,6 +323,7 @@ dvb_mux_find_by_identifier(const char *identifier)
}
#if DVB_API_VERSION >= 5
static struct strtab rollofftab[] = {
{ "ROLLOFF_35", ROLLOFF_35 },
{ "ROLLOFF_20", ROLLOFF_20 },
@ -327,37 +331,6 @@ static struct strtab rollofftab[] = {
{ "ROLLOFF_AUTO", ROLLOFF_AUTO }
};
static struct strtab fectab[] = {
{ "NONE", FEC_NONE },
{ "1/2", FEC_1_2 },
{ "2/3", FEC_2_3 },
{ "3/4", FEC_3_4 },
{ "4/5", FEC_4_5 },
{ "5/6", FEC_5_6 },
{ "6/7", FEC_6_7 },
{ "7/8", FEC_7_8 },
{ "8/9", FEC_8_9 },
{ "AUTO", FEC_AUTO },
{ "3/5", FEC_3_4 },
{ "9/10", FEC_9_10 }
};
static struct strtab qamtab[] = {
{ "QPSK", QPSK },
{ "QAM16", QAM_16 },
{ "QAM32", QAM_32 },
{ "QAM64", QAM_64 },
{ "QAM128", QAM_128 },
{ "QAM256", QAM_256 },
{ "AUTO", QAM_AUTO },
{ "8VSB", VSB_8 },
{ "16VSB", VSB_16 },
{ "PSK_8", PSK_8 },
{ "APSK_16", APSK_16 },
{ "APSK_32", APSK_32 },
{ "DQPSK", DQPSK }
};
static struct strtab delsystab[] = {
{ "SYS_UNDEFINED", SYS_UNDEFINED },
{ "SYS_DVBC_ANNEX_AC", SYS_DVBC_ANNEX_AC },
@ -376,6 +349,44 @@ static struct strtab delsystab[] = {
{ "SYS_CMMB", SYS_CMMB },
{ "SYS_DAB", SYS_DAB }
};
#endif
static struct strtab fectab[] = {
{ "NONE", FEC_NONE },
{ "1/2", FEC_1_2 },
{ "2/3", FEC_2_3 },
{ "3/4", FEC_3_4 },
{ "4/5", FEC_4_5 },
{ "5/6", FEC_5_6 },
{ "6/7", FEC_6_7 },
{ "7/8", FEC_7_8 },
{ "8/9", FEC_8_9 },
{ "AUTO", FEC_AUTO },
#if DVB_API_VERSION >= 5
{ "3/5", FEC_3_5 },
{ "9/10", FEC_9_10 }
#endif
};
static struct strtab qamtab[] = {
{ "QPSK", QPSK },
{ "QAM16", QAM_16 },
{ "QAM32", QAM_32 },
{ "QAM64", QAM_64 },
{ "QAM128", QAM_128 },
{ "QAM256", QAM_256 },
{ "AUTO", QAM_AUTO },
{ "8VSB", VSB_8 },
{ "16VSB", VSB_16 },
#if DVB_API_VERSION >= 5
{ "PSK_8", PSK_8 },
{ "APSK_16", APSK_16 },
{ "APSK_32", APSK_32 },
{ "DQPSK", DQPSK }
#endif
};
static struct strtab bwtab[] = {
{ "8MHz", BANDWIDTH_8_MHZ },
@ -467,6 +478,7 @@ dvb_mux_save(th_dvb_mux_instance_t *tdmi)
htsmsg_add_str(m, "polarisation",
val2str(tdmi->tdmi_conf.dmc_polarisation, poltab));
#if DVB_API_VERSION >= 5
htsmsg_add_str(m, "modulation",
val2str(tdmi->tdmi_conf.dmc_fe_modulation, qamtab));
@ -475,6 +487,7 @@ dvb_mux_save(th_dvb_mux_instance_t *tdmi)
htsmsg_add_str(m, "rolloff",
val2str(tdmi->tdmi_conf.dmc_fe_rolloff, rollofftab));
#endif
break;
case FE_QAM:
@ -574,6 +587,7 @@ tdmi_create_by_msg(th_dvb_adapter_t *tda, htsmsg_t *m, const char *identifier)
return "Invalid polarisation";
dmc.dmc_polarisation = r;
#if DVB_API_VERSION >= 5
s = htsmsg_get_str(m, "modulation");
if(s == NULL || (r = str2val(s, qamtab)) < 0) {
r = str2val("QPSK", qamtab);
@ -597,6 +611,7 @@ tdmi_create_by_msg(th_dvb_adapter_t *tda, htsmsg_t *m, const char *identifier)
"dvb", "no rolloff for mux found, defaulting to ROLLOFF_35");
}
dmc.dmc_fe_rolloff = r;
#endif
break;
case FE_QAM:

View file

@ -802,8 +802,19 @@ dvb_cat_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
*/
static const fe_code_rate_t fec_tab [16] = {
FEC_AUTO, FEC_1_2, FEC_2_3, FEC_3_4,
FEC_5_6, FEC_7_8, FEC_8_9, FEC_3_5,
FEC_4_5, FEC_9_10, FEC_NONE, FEC_NONE,
FEC_5_6, FEC_7_8, FEC_8_9,
#if DVB_API_VERSION >= 5
FEC_3_5,
#else
FEC_NONE,
#endif
FEC_4_5,
#if DVB_API_VERSION >= 5
FEC_9_10,
#else
FEC_NONE,
#endif
FEC_NONE, FEC_NONE,
FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE
};
@ -864,7 +875,7 @@ static int
dvb_table_sat_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
uint16_t tsid)
{
int freq, symrate, modulation;
int freq, symrate;
struct dvb_mux_conf dmc;
if(!tdmi->tdmi_adapter->tda_autodiscovery)
@ -892,7 +903,8 @@ dvb_table_sat_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
// Same satconf (lnb, switch, etc)
dmc.dmc_satconf = tdmi->tdmi_conf.dmc_satconf;
modulation = (ptr[6] & 0x03);
#if DVB_API_VERSION >= 5
int modulation = (ptr[6] & 0x03);
if (modulation == 0x01)
dmc.dmc_fe_modulation = QPSK;
@ -926,7 +938,7 @@ dvb_table_sat_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
dmc.dmc_fe_delsys = SYS_DVBS;
dmc.dmc_fe_rolloff = ROLLOFF_35;
}
#endif
dvb_mux_create(tdmi->tdmi_adapter, &dmc, tsid, NULL,
"automatic mux discovery", 1, NULL);