linuxdvb: WIP - comitting before I lose it!

This commit is contained in:
Adam Sutton 2013-10-27 21:00:33 +00:00
parent 61a96da207
commit a622f4fffa
10 changed files with 532 additions and 326 deletions

View file

@ -281,7 +281,7 @@ api_linuxdvb_satconf_create
return -EINVAL;
pthread_mutex_lock(&global_lock);
in = (idnode_t*)linuxdvb_satconf_create0(NULL, conf);
in = NULL;//TODO:(idnode_t*)linuxdvb_satconf_create0(NULL, conf);
if (in) {
err = 0;
in->in_class->ic_save(in);

View file

@ -584,8 +584,10 @@ capmt_thread(void *aux)
idnode_set_t *is = idnode_find_all(&linuxdvb_adapter_class);
for (i = 0; i < is->is_count; i++) {
la = (linuxdvb_adapter_t*)is->is_array[i];
#if 0
if (!la || !la->mi_is_enabled) continue;
if (!la->mi_is_enabled((mpegts_input_t*)la)) continue;
#endif
if (la->la_dvb_number > MAX_CA) {
tvhlog(LOG_ERR, "capmt", "adapter number > MAX_CA");
continue;
@ -646,7 +648,7 @@ capmt_table_input(struct th_descrambler *td, struct service *s,
capmt_t *capmt = ct->ct_capmt;
mpegts_service_t *t = (mpegts_service_t*)s;
linuxdvb_frontend_t *lfe;
int adapter_num;
int adapter_num = -1;
int total_caids = 0, current_caid = 0;
/* Validate */
@ -656,7 +658,7 @@ capmt_table_input(struct th_descrambler *td, struct service *s,
lfe = (linuxdvb_frontend_t*)t->s_dvb_active_input;
if (!idnode_is_instance(&lfe->ti_id, &linuxdvb_frontend_class))
return;
adapter_num = ((linuxdvb_adapter_t*)lfe->lh_parent)->la_dvb_number;
//adapter_num = ((linuxdvb_adapter_t*)lfe->lh_parent)->la_dvb_number;
caid_t *c;
@ -895,7 +897,7 @@ capmt_service_start(service_t *s)
lfe = (linuxdvb_frontend_t*)t->s_dvb_active_input;
if (!idnode_is_instance(&lfe->ti_id, &linuxdvb_frontend_class))
return;
tuner = ((linuxdvb_adapter_t*)lfe->lh_parent)->la_dvb_number;
//tuner = ((linuxdvb_adapter_t*)lfe->lh_parent)->la_dvb_number;
TAILQ_FOREACH(capmt, &capmts, capmt_link) {
/* skip, if we're not active */

View file

@ -33,7 +33,4 @@ void linuxdvb_init ( int adapter_mask )
/* Initialsie devices */
linuxdvb_device_init(adapter_mask);
/* Initialise satconfs */
linuxdvb_satconf_init();
}

View file

@ -182,7 +182,7 @@ static int
linuxdvb_frontend_dvbs_class_satconf_set ( void *self, const void *str )
{
linuxdvb_frontend_t *lfe = self;
if (!strcmp(str ?: "", lfe->lfe_satconf->ls_type))
if (lfe->lfe_satconf && !strcmp(str ?: "", lfe->lfe_satconf->ls_type))
return 0;
linuxdvb_satconf_destroy(lfe->lfe_satconf);
lfe->lfe_satconf = linuxdvb_satconf_create(lfe, str);
@ -192,14 +192,13 @@ linuxdvb_frontend_dvbs_class_satconf_set ( void *self, const void *str )
static const void *
linuxdvb_frontend_dvbs_class_satconf_get ( void *self )
{
static const char *s;
linuxdvb_frontend_t *lfe = self;
return &lfe->lfe_satconf->ls_type;
}
static htsmsg_t *
linuxdvb_frontend_dvbs_class_satconf_list ( void *self )
{
return linuxdvb_satconf_types();
if (lfe->lfe_satconf)
s = lfe->lfe_satconf->ls_type;
else
s = NULL;
return &s;
}
const idclass_t linuxdvb_frontend_dvbs_class =
@ -213,9 +212,11 @@ const idclass_t linuxdvb_frontend_dvbs_class =
.type = PT_STR,
.id = "satconf",
.name = "SatConfig",
.opts = PO_NOSAVE,
.set = linuxdvb_frontend_dvbs_class_satconf_set,
.get = linuxdvb_frontend_dvbs_class_satconf_get,
.list = linuxdvb_frontend_dvbs_class_satconf_list,
.list = linuxdvb_satconf_type_list,
.def.s = "simple"
},
{}
}
@ -859,6 +860,10 @@ linuxdvb_frontend_create0
/* Start table thread */
tvhthread_create(&tid, NULL, mpegts_input_table_thread, lfe, 1);
/* Create satconf */
if (type == FE_QPSK && !lfe->lfe_satconf)
lfe->lfe_satconf = linuxdvb_satconf_create(lfe, "");
/* No conf */
if (!conf)
return lfe;
@ -920,6 +925,14 @@ linuxdvb_frontend_save ( linuxdvb_frontend_t *lfe, htsmsg_t *m )
{
mpegts_input_save((mpegts_input_t*)lfe, m);
htsmsg_add_str(m, "type", dvb_type2str(lfe->lfe_info.type));
htsmsg_print(m);
if (lfe->lfe_satconf) {
htsmsg_t *s = htsmsg_create_map();
linuxdvb_satconf_save(lfe->lfe_satconf, s);
htsmsg_add_str(s, "uuid", idnode_uuid_as_str(&lfe->lfe_satconf->ls_id));
htsmsg_add_msg(m, "satconf", s);
}
htsmsg_print(m);
}
/******************************************************************************

View file

@ -103,7 +103,7 @@ linuxdvb_lnb_standard_pol
static int
linuxdvb_lnb_standard_tune
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_t *ls, int fd )
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
{
int pol = linuxdvb_lnb_standard_pol((linuxdvb_lnb_t*)ld, lm);
return linuxdvb_diseqc_set_volt(fd, pol);
@ -148,7 +148,7 @@ linuxdvb_lnb_bandstack_pol
static int
linuxdvb_lnb_bandstack_tune
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_t *ls, int fd )
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
{
int pol = linuxdvb_lnb_bandstack_pol((linuxdvb_lnb_t*)ld, lm);
return linuxdvb_diseqc_set_volt(fd, pol);
@ -257,7 +257,7 @@ linuxdvb_lnb_list ( void *o )
linuxdvb_lnb_t *
linuxdvb_lnb_create0
( const char *name, htsmsg_t *conf, linuxdvb_satconf_t *ls )
( const char *name, htsmsg_t *conf, linuxdvb_satconf_ele_t *ls )
{
int i;

View file

@ -22,15 +22,16 @@
#include "input/mpegts.h"
typedef struct linuxdvb_hardware linuxdvb_hardware_t;
typedef struct linuxdvb_device linuxdvb_device_t;
typedef struct linuxdvb_adapter linuxdvb_adapter_t;
typedef struct linuxdvb_frontend linuxdvb_frontend_t;
typedef struct linuxdvb_satconf linuxdvb_satconf_t;
typedef struct linuxdvb_diseqc linuxdvb_diseqc_t;
typedef struct linuxdvb_lnb linuxdvb_lnb_t;
typedef struct linuxdvb_network linuxdvb_network_t;
typedef struct linuxdvb_mux linuxdvb_mux_t;
typedef struct linuxdvb_hardware linuxdvb_hardware_t;
typedef struct linuxdvb_device linuxdvb_device_t;
typedef struct linuxdvb_adapter linuxdvb_adapter_t;
typedef struct linuxdvb_frontend linuxdvb_frontend_t;
typedef struct linuxdvb_satconf linuxdvb_satconf_t;
typedef struct linuxdvb_satconf_ele linuxdvb_satconf_ele_t;
typedef struct linuxdvb_diseqc linuxdvb_diseqc_t;
typedef struct linuxdvb_lnb linuxdvb_lnb_t;
typedef struct linuxdvb_network linuxdvb_network_t;
typedef struct linuxdvb_mux linuxdvb_mux_t;
typedef LIST_HEAD(,linuxdvb_hardware) linuxdvb_hardware_list_t;
@ -143,16 +144,61 @@ struct linuxdvb_satconf
{
idnode_t ls_id;
const char *ls_type;
/*
* MPEG-TS hooks
*/
mpegts_input_t *ls_frontend; ///< Frontend we're proxying for
mpegts_mux_instance_t *ls_mmi; ///< Used within delay diseqc handler
/*
* Diseqc handling
*/
gtimer_t ls_diseqc_timer;
int ls_diseqc_idx;
int ls_diseqc_repeats;
/*
* Satconf elements
*/
LIST_HEAD(,linuxdvb_satconf_ele) ls_elements;
};
/*
* Internal wrapper for a satconf entry
*
* Note: this is a bit cumbersome, it comes from how I first did the satconf
* and was subsequently bullied (by amet) into changing it (probably
* for the better, just don't tell him, no danger he'll read this!)
*
* maybe one day I'll do it again properly
*/
struct linuxdvb_satconf_ele
{
mpegts_input_t; // This acts as proxy for the frontend
/*
* Parent
*/
linuxdvb_satconf_t *ls_parent;
LIST_ENTRY(linuxdvb_satconf_ele) ls_link;
/*
* Diseqc kit
*/
linuxdvb_lnb_t *ls_lnb;
linuxdvb_diseqc_t *ls_switch;
linuxdvb_diseqc_t *ls_rotor;
};
struct linuxdvb_diseqc
{
idnode_t ld_id;
const char *ld_type;
linuxdvb_satconf_t *ld_satconf;
linuxdvb_satconf_ele_t *ld_satconf;
int (*ld_grace) (linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm);
int (*ld_tune) (linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm,
linuxdvb_satconf_t *ls, int fd);
linuxdvb_satconf_ele_t *ls, int fd);
};
struct linuxdvb_lnb
@ -258,11 +304,9 @@ mpegts_service_t *linuxdvb_service_create0
/*
* Diseqc gear
*/
linuxdvb_diseqc_t *linuxdvb_diseqc_create0
( linuxdvb_diseqc_t *ld, const char *uuid, const idclass_t *idc,
htsmsg_t *conf, const char *type, linuxdvb_satconf_t *parent );
htsmsg_t *conf, const char *type, linuxdvb_satconf_ele_t *parent );
void linuxdvb_diseqc_destroy ( linuxdvb_diseqc_t *ld );
@ -271,11 +315,11 @@ void linuxdvb_diseqc_destroy ( linuxdvb_diseqc_t *ld );
_u, &_d##_class, _c, _t, _p)
linuxdvb_lnb_t *linuxdvb_lnb_create0
( const char *name, htsmsg_t *conf, linuxdvb_satconf_t *ls );
( const char *name, htsmsg_t *conf, linuxdvb_satconf_ele_t *ls );
linuxdvb_diseqc_t *linuxdvb_switch_create0
( const char *name, htsmsg_t *conf, linuxdvb_satconf_t *ls );
( const char *name, htsmsg_t *conf, linuxdvb_satconf_ele_t *ls, int u, int c );
linuxdvb_diseqc_t *linuxdvb_rotor_create0
( const char *name, htsmsg_t *conf, linuxdvb_satconf_t *ls );
( const char *name, htsmsg_t *conf, linuxdvb_satconf_ele_t *ls );
void linuxdvb_lnb_destroy ( linuxdvb_lnb_t *lnb );
void linuxdvb_switch_destroy ( linuxdvb_diseqc_t *ld );
@ -293,14 +337,22 @@ int linuxdvb_diseqc_set_volt (int fd, int volt);
/*
* Satconf
*/
void linuxdvb_satconf_save ( linuxdvb_satconf_t *ls, htsmsg_t *m );
void linuxdvb_satconf_init ( void );
linuxdvb_satconf_ele_t *linuxdvb_satconf_ele_create0
(const char *uuid, htsmsg_t *conf, linuxdvb_satconf_t *ls);
void linuxdvb_satconf_ele_destroy ( linuxdvb_satconf_ele_t *ls );
htsmsg_t *linuxdvb_satconf_type_list ( void *o );
linuxdvb_satconf_t *linuxdvb_satconf_create0(const char *uuid, htsmsg_t *conf);
void linuxdvb_satconf_delete ( linuxdvb_satconf_t *ls );
linuxdvb_satconf_t *linuxdvb_satconf_create
( linuxdvb_frontend_t *lfe, const char *type );
htsmsg_t *linuxdvb_satconf_types ( void );
void linuxdvb_satconf_delete ( linuxdvb_satconf_t *ls );
void linuxdvb_satconf_destroy ( linuxdvb_satconf_t *ls );
linuxdvb_satconf_t *linuxdvb_satconf_create
( linuxdvb_frontend_t *lfe, const char *type );

View file

@ -131,10 +131,10 @@ const idclass_t linuxdvb_rotor_usals_class =
/* GotoX */
static int
linuxdvb_rotor_gotox_tune
( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_t *ls, int fd )
( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
{
int i;
for (i = 0; i <= ls->ls_diseqc_repeats; i++) {
for (i = 0; i <= ls->ls_parent->ls_diseqc_repeats; i++) {
if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) {
tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position);
return -1;
@ -149,7 +149,7 @@ linuxdvb_rotor_gotox_tune
/* USALS */
static int
linuxdvb_rotor_usals_tune
( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_t *ls, int fd )
( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
{
/*
* Code originally written in PR #238 by Jason Millard jsm174
@ -202,7 +202,7 @@ linuxdvb_rotor_usals_tune
fabs(pos), (pos > 0.0) ? 'E' : 'W',
motor_angle, (motor_angle > 0.0) ? "counter-" : "");
for (i = 0; i <= ls->ls_diseqc_repeats; i++) {
for (i = 0; i <= ls->ls_parent->ls_diseqc_repeats; i++) {
if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6E, 2, angle_1, angle_2)) {
tvherror("diseqc", "failed to send USALS command");
return -1;
@ -218,7 +218,7 @@ linuxdvb_rotor_usals_tune
static int
linuxdvb_rotor_tune
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_t *ls, int fd )
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
{
linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld;
@ -275,7 +275,7 @@ linuxdvb_rotor_list ( void *o )
linuxdvb_diseqc_t *
linuxdvb_rotor_create0
( const char *name, htsmsg_t *conf, linuxdvb_satconf_t *ls )
( const char *name, htsmsg_t *conf, linuxdvb_satconf_ele_t *ls )
{
int i;
linuxdvb_diseqc_t *ld = NULL;

File diff suppressed because it is too large Load diff

View file

@ -112,7 +112,7 @@ const idclass_t linuxdvb_switch_class =
static int
linuxdvb_switch_tune
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_t *sc, int fd )
( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd )
{
int i, com, r1 = 0, r2 = 0;
int pol, band;
@ -130,7 +130,7 @@ linuxdvb_switch_tune
com = 0xF0 | (ls->ls_committed << 2) | (pol << 1) | band;
/* Single committed (before repeats) */
if (sc->ls_diseqc_repeats > 0) {
if (sc->ls_parent->ls_diseqc_repeats > 0) {
r2 = 1;
if (linuxdvb_diseqc_send(fd, 0xE0, 0x10, 0x38, 1, com))
return -1;
@ -138,7 +138,7 @@ linuxdvb_switch_tune
}
/* Repeats */
for (i = 0; i <= sc->ls_diseqc_repeats; i++) {
for (i = 0; i <= sc->ls_parent->ls_diseqc_repeats; i++) {
/* Uncommitted */
if (linuxdvb_diseqc_send(fd, 0xE0 | r1, 0x10, 0x39, 1,
@ -181,17 +181,26 @@ linuxdvb_switch_list ( void *o )
linuxdvb_diseqc_t *
linuxdvb_switch_create0
( const char *name, htsmsg_t *conf, linuxdvb_satconf_t *ls )
( const char *name, htsmsg_t *conf, linuxdvb_satconf_ele_t *ls, int u, int c )
{
linuxdvb_diseqc_t *ld = NULL;
linuxdvb_switch_t *ld = NULL;
if (!strcmp(name ?: "", "Generic")) {
ld = linuxdvb_diseqc_create(linuxdvb_switch, NULL, conf, "Generic", ls);
ld = (linuxdvb_switch_t*)linuxdvb_diseqc_create(linuxdvb_switch, NULL, conf, "Generic", ls);
if (ld) {
ld->ld_tune = linuxdvb_switch_tune;
if (!conf) {
if (u >= 0) {
ld->ls_committed = u;
ld->ls_toneburst = u % 2;
}
if (c >= 0) {
ld->ls_committed = c;
}
}
}
}
return ld;
return (linuxdvb_diseqc_t*)ld;
}
void

View file

@ -83,13 +83,13 @@ ts_recv_packet0
if(st->es_cc_valid && cc != st->es_cc) {
/* Incorrect CC */
limitedlog(&st->es_loglimit_cc, "TS", service_component_nicename(st),
"Continuity counter error");
"Continuity counter error");
avgstat_add(&t->s_cc_errors, 1, dispatch_clock);
avgstat_add(&st->es_cc_errors, 1, dispatch_clock);
// Mark as error if this is not the first packet of a payload
if(!pusi)
error |= 0x2;
error |= 0x2;
}
st->es_cc_valid = 1;
st->es_cc = (cc + 1) & 0xf;
@ -143,8 +143,8 @@ ts_process_pcr(mpegts_service_t *t, elementary_stream_t *st, int64_t pcr)
if(d < -90000LL || d > 90000LL) {
st->es_pcr_recovery_fails++;
if(st->es_pcr_recovery_fails > 10) {
st->es_pcr_recovery_fails = 0;
st->es_pcr_real_last = PTS_UNSET;
st->es_pcr_recovery_fails = 0;
st->es_pcr_real_last = PTS_UNSET;
}
return;
}
@ -153,7 +153,7 @@ ts_process_pcr(mpegts_service_t *t, elementary_stream_t *st, int64_t pcr)
if(t->s_pcr_pid == st->es_pid) {
/* This is the registered PCR PID, adjust service PCR drift
via an IIR filter */
via an IIR filter */
t->s_pcr_drift = (t->s_pcr_drift * 255 + st->es_pcr_drift) / 256;
}
@ -207,7 +207,7 @@ ts_recv_packet1(mpegts_service_t *t, const uint8_t *tsb, int64_t *pcrp)
if(error) {
/* Transport Error Indicator */
limitedlog(&t->s_loglimit_tei, "TS", service_nicename((service_t*)t),
"Transport error indicator");
"Transport error indicator");
}
pid = (tsb[1] & 0x1f) << 8 | tsb[2];
@ -245,19 +245,19 @@ ts_recv_packet1(mpegts_service_t *t, const uint8_t *tsb, int64_t *pcrp)
r = td->td_descramble(td, (service_t*)t, st, tsb);
if(r == 0) {
pthread_mutex_unlock(&t->s_stream_mutex);
return 1;
pthread_mutex_unlock(&t->s_stream_mutex);
return 1;
}
if(r == 1)
m++;
m++;
}
if(!error && t->s_scrambled != 0) {
if(n == 0) {
service_set_streaming_status_flags((service_t*)t, TSS_NO_DESCRAMBLER);
service_set_streaming_status_flags((service_t*)t, TSS_NO_DESCRAMBLER);
} else if(m == n) {
service_set_streaming_status_flags((service_t*)t, TSS_NO_ACCESS);
service_set_streaming_status_flags((service_t*)t, TSS_NO_ACCESS);
}
}