Load adapters for which we have configuration but is not detected

This commit is contained in:
Andreas Öman 2008-04-20 13:38:10 +00:00
parent 718c19e062
commit 69e7c77d42
9 changed files with 62 additions and 51 deletions

View file

@ -59,7 +59,7 @@ tdmi_displayname(th_dvb_mux_instance_t *tdmi, char *buf, size_t len)
{
int f = tdmi->tdmi_fe_params->frequency;
if(tdmi->tdmi_adapter->tda_fe_info->type == FE_QPSK) {
if(tdmi->tdmi_adapter->tda_type == FE_QPSK) {
snprintf(buf, len, "%d kHz %s", f,
dvb_polarisation_to_str(tdmi->tdmi_polarisation));
} else {
@ -88,10 +88,10 @@ ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr,
tcp_qprintf(tq, "<div class=\"infoprefix\">Device:</div>"
"<div>%s</div>",
tda->tda_rootpath);
tda->tda_rootpath ?: "<b><i>Not present</i></b>");
tcp_qprintf(tq, "<div class=\"infoprefix\">Type:</div>"
"<div>%s</div>",
dvb_adaptertype_to_str(tda->tda_fe_info->type));
dvb_adaptertype_to_str(tda->tda_type));
tcp_qprintf(tq, "<div style=\"text-align: center\">"
"<a href=\"javascript:void(0);\" "
@ -117,7 +117,7 @@ ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr)
tcp_qprintf(tq, "<div style=\"overflow: auto; width: 100%\">");
LIST_FOREACH(tda, &dvb_adapters, tda_global_link) {
TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) {
tcp_qprintf(tq, "<div id=\"summary_%s\" "
"style=\"float:left; width: 250px\"></div>",
@ -135,18 +135,20 @@ ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr)
}
/**
* Generate the 'add new...' mux link
* Generate the 'add new...' mux link if the adapter has backing hardware
*
* if result is set we add a fade out of a result from a previous op
*/
static void
dvb_make_add_link(tcp_queue_t *tq, th_dvb_adapter_t *tda, const char *result)
{
tcp_qprintf(tq,
"<p><a href=\"javascript:void(0);\" "
"onClick=\"new Ajax.Updater('addmux', "
"'/ajax/dvbadapteraddmux/%s', {method: 'get'})\""
">Add new...</a></p>", tda->tda_identifier);
if(tda->tda_fe_info != NULL) {
tcp_qprintf(tq,
"<p><a href=\"javascript:void(0);\" "
"onClick=\"new Ajax.Updater('addmux', "
"'/ajax/dvbadapteraddmux/%s', {method: 'get'})\""
">Add new...</a></p>", tda->tda_identifier);
}
if(result) {
tcp_qprintf(tq, "<div id=\"result\">%s</div>", result);
@ -181,42 +183,41 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr,
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Model:</div>"
"<div>%s (%s)</div>",
tda->tda_fe_info->name,
dvb_adaptertype_to_str(tda->tda_fe_info->type));
tda->tda_fe_info ? tda->tda_fe_info->name : "<Unknown>",
dvb_adaptertype_to_str(tda->tda_type));
switch(tda->tda_fe_info->type) {
case FE_QPSK:
a = tda->tda_fe_info->frequency_min;
b = tda->tda_fe_info->frequency_max;
c = tda->tda_fe_info->frequency_stepsize;
break;
if(tda->tda_fe_info != NULL) {
switch(tda->tda_type) {
case FE_QPSK:
a = tda->tda_fe_info->frequency_min;
b = tda->tda_fe_info->frequency_max;
c = tda->tda_fe_info->frequency_stepsize;
break;
default:
a = tda->tda_fe_info->frequency_min / 1000.0f;
b = tda->tda_fe_info->frequency_max / 1000.0f;
c = tda->tda_fe_info->frequency_stepsize / 1000.0f;
break;
}
default:
a = tda->tda_fe_info->frequency_min / 1000.0f;
b = tda->tda_fe_info->frequency_max / 1000.0f;
c = tda->tda_fe_info->frequency_stepsize / 1000.0f;
break;
}
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Freq. Range:</div>"
"<div>%.2f - %.2f kHz, in steps of %.2f kHz</div>",
a, b, c);
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Freq. Range:</div>"
"<div>%.2f - %.2f kHz, in steps of %.2f kHz</div>",
a, b, c);
if(tda->tda_fe_info->symbol_rate_min) {
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Symbolrate:</div>"
"<div>%d - %d BAUD</div>",
tda->tda_fe_info->symbol_rate_min,
tda->tda_fe_info->symbol_rate_max);
if(tda->tda_fe_info->symbol_rate_min) {
tcp_qprintf(tq, "<div class=\"infoprefixwide\">Symbolrate:</div>"
"<div>%d - %d BAUD</div>",
tda->tda_fe_info->symbol_rate_min,
tda->tda_fe_info->symbol_rate_max);
}
/* Capabilities */
// tcp_qprintf(tq, "<div class=\"infoprefixwide\">Capabilities:</div>");
}
/* Capabilities */
// tcp_qprintf(tq, "<div class=\"infoprefixwide\">Capabilities:</div>");
tcp_qprintf(tq, "<div style=\"float: left; width:45%\">");
ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes");
@ -263,6 +264,9 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr,
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
if(tda->tda_fe_info == NULL)
return HTTP_STATUS_BAD_REQUEST;
caps = tda->tda_fe_info->caps;
fetype = tda->tda_fe_info->type;
@ -554,7 +558,7 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr,
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
fetype = tda->tda_fe_info->type;
fetype = tda->tda_type;
/* List of muxes */

BIN
dvb.c

Binary file not shown.

2
dvb.h
View file

@ -28,7 +28,7 @@ enum polarisation {
#define DVB_FEC_ERROR_LIMIT 20
extern struct th_dvb_adapter_list dvb_adapters;
extern struct th_dvb_adapter_queue dvb_adapters;
extern struct th_dvb_mux_instance_list dvb_muxes;
void dvb_init(void);

View file

@ -145,6 +145,9 @@ dvb_start_feed(th_transport_t *t, unsigned int weight, int status)
th_dvb_adapter_t *tda = t->tht_dvb_mux_instance->tdmi_adapter;
th_dvb_mux_instance_t *tdmi = tda->tda_mux_current;
if(tda->tda_rootpath == NULL)
return 1; /* hardware not present */
/* Check if adapter is idle, or already tuned */
if(tdmi != NULL && tdmi != t->tht_dvb_mux_instance) {

View file

@ -85,7 +85,7 @@ dvb_fe_manager(void *aux)
p = *tdmi->tdmi_fe_params;
if(tda->tda_fe_info->type == FE_QPSK) {
if(tda->tda_type == FE_QPSK) {
/* DVB-S */
int lowfreq, hifreq, switchfreq, hiband;

View file

@ -104,7 +104,7 @@ dvb_mux_store(FILE *fp, th_dvb_mux_instance_t *tdmi)
fprintf(fp, "\tfrequency = %d\n", f->frequency);
switch(tdmi->tdmi_adapter->tda_fe_info->type) {
switch(tdmi->tdmi_adapter->tda_type) {
case FE_OFDM:
fprintf(fp, "\tbandwidth = %s\n",
val2str(f->u.ofdm.bandwidth, bwtab));
@ -188,7 +188,7 @@ dvb_mux_create_str(th_dvb_adapter_t *tda,
if(f.frequency == 0)
return "Invalid frequency";
switch(tda->tda_fe_info->type) {
switch(tda->tda_type) {
case FE_OFDM:
if(bwstr == NULL || (r = str2val(bwstr, bwtab)) < 0)
return "Invalid bandwidth";

View file

@ -219,6 +219,13 @@ static struct strtab adaptertype[] = {
{ "ATSC", FE_ATSC },
};
int
dvb_str_to_adaptertype(const char *str)
{
return str2val(str, adaptertype);
}
const char *
dvb_adaptertype_to_str(int type)
{
@ -264,7 +271,7 @@ dvb_adapter_find_by_identifier(const char *identifier)
{
th_dvb_adapter_t *tda;
LIST_FOREACH(tda, &dvb_adapters, tda_global_link)
TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link)
if(!strcmp(identifier, tda->tda_identifier))
return tda;
return NULL;
@ -304,7 +311,7 @@ dvb_mux_status(th_dvb_mux_instance_t *tdmi)
void
dvb_mux_nicename(char *buf, size_t size, th_dvb_mux_instance_t *tdmi)
{
if(tdmi->tdmi_adapter->tda_fe_info->type == FE_QPSK)
if(tdmi->tdmi_adapter->tda_type == FE_QPSK)
snprintf(buf, size, "%dkHz %s port %d", tdmi->tdmi_fe_params->frequency,
dvb_polarisation_to_str_long(tdmi->tdmi_polarisation),
tdmi->tdmi_switchport);

View file

@ -55,6 +55,7 @@ int dvb_get_string_with_len(char *dst, size_t dstlen,
time_t dvb_convert_date(uint8_t *dvb_buf);
const char *dvb_adaptertype_to_str(int type);
int dvb_str_to_adaptertype(const char *str);
const char *dvb_polarisation_to_str(int pol);
th_dvb_adapter_t *dvb_adapter_find_by_identifier(const char *identifier);
th_dvb_mux_instance_t *dvb_mux_find_by_identifier(const char *identifier);

View file

@ -73,7 +73,7 @@ LIST_HEAD(th_subscription_list, th_subscription);
LIST_HEAD(th_channel_list, th_channel);
TAILQ_HEAD(th_channel_queue, th_channel);
TAILQ_HEAD(th_channel_group_queue, th_channel_group);
LIST_HEAD(th_dvb_adapter_list, th_dvb_adapter);
TAILQ_HEAD(th_dvb_adapter_queue, th_dvb_adapter);
LIST_HEAD(th_v4l_adapter_list, th_v4l_adapter);
LIST_HEAD(event_list, event);
TAILQ_HEAD(event_queue, event);
@ -209,12 +209,7 @@ typedef struct th_dvb_table {
*/
typedef struct th_dvb_adapter {
LIST_ENTRY(th_dvb_adapter) tda_global_link;
enum {
TDA_STATE_RUNNING, /* Running */
TDA_STATE_ZOMBIE, /* Configured but not found */
} tda_state;
TAILQ_ENTRY(th_dvb_adapter) tda_global_link;
struct th_dvb_mux_instance_list tda_muxes;
th_dvb_mux_instance_t *tda_mux_current;
@ -230,6 +225,7 @@ typedef struct th_dvb_adapter {
int tda_fe_errors;
int tda_fe_fd;
int tda_type;
struct dvb_frontend_info *tda_fe_info;
char *tda_demux_path;