Thread: [Redbutton-devel] SF.net SVN: redbutton: [194] redbutton-download/trunk/channels.c
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-01-24 16:52:00
|
Revision: 194
http://svn.sourceforge.net/redbutton/?rev=194&view=rev
Author: skilvington
Date: 2007-01-24 08:51:56 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
something TODO
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-01-23 16:11:01 UTC (rev 193)
+++ redbutton-download/trunk/channels.c 2007-01-24 16:51:56 UTC (rev 194)
@@ -264,6 +264,13 @@
if((needed_params = get_tune_params(service_id)) == NULL)
fatal("service_id %u not found in channels.conf file", service_id);
+/* TODO */
+ /* if no-one was using the frontend when we open it
+ * FE_GET_FRONTEND may say we are tuned to the frequency we want
+ * but when we try to read any data, it fails
+ * => always tune the first time we open the frontend
+ */
+
/* are we already tuned to the right frequency */
vverbose("Current frequency %u; needed %u", current_params.frequency, needed_params->frequency);
if(current_params.frequency != needed_params->frequency)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-01-26 17:01:45
|
Revision: 199
http://svn.sourceforge.net/redbutton/?rev=199&view=rev
Author: skilvington
Date: 2007-01-26 09:01:43 -0800 (Fri, 26 Jan 2007)
Log Message:
-----------
open frontend read-only if we can't open it read/write
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-01-26 16:37:38 UTC (rev 198)
+++ redbutton-download/trunk/channels.c 2007-01-26 17:01:43 UTC (rev 199)
@@ -240,29 +240,34 @@
struct dvb_frontend_event event;
bool lock;
/* need to keep the frontend device open to stop it untuning itself */
- /* TODO: fix this hack */
static int fe_fd = -1;
+ snprintf(fe_dev, sizeof(fe_dev), FE_DEVICE, adapter);
+
+ if(fe_fd < 0)
+ {
+ /*
+ * need O_RDWR if you want to tune, O_RDONLY is okay for getting info
+ * if someone else is using the frontend, we can only open O_RDONLY
+ * => we can still download data, but just not retune
+ */
+ if((fe_fd = open(fe_dev, O_RDWR | O_NONBLOCK)) < 0)
+ {
+ error("Unable to open '%s' read/write; you will not be able to retune", fe_dev);
+ if((fe_fd = open(fe_dev, O_RDONLY | O_NONBLOCK)) < 0)
+ fatal("open '%s': %s", fe_dev, strerror(errno));
+ }
+ }
+
vverbose("Getting frontend info");
- /* see what we are currently tuned to */
- snprintf(fe_dev, sizeof(fe_dev), FE_DEVICE, adapter);
- /*
- * need O_RDWR if you want to tune, O_RDONLY is okay for getting info
- * if someone else is using the frontend, we can only open O_RDONLY
- * => we can still download data, but just not retune
- */
- if(fe_fd != -1)
- close(fe_fd);
- if((fe_fd = open(fe_dev, O_RDONLY | O_NONBLOCK)) < 0)
- fatal("open '%s': %s", fe_dev, strerror(errno));
-
if(ioctl(fe_fd, FE_GET_INFO, &fe_info) < 0)
fatal("ioctl FE_GET_INFO: %s", strerror(errno));
if(fe_info.type != FE_OFDM)
fatal("TODO: Only able to tune DVB-T devices at present");
+ /* see what we are currently tuned to */
if(ioctl(fe_fd, FE_GET_FRONTEND, ¤t_params) < 0)
fatal("ioctl FE_GET_FRONTEND: %s", strerror(errno));
@@ -285,15 +290,12 @@
if(current_params.frequency != needed_params->frequency)
{
verbose("Retuning to frequency %u", needed_params->frequency);
- close(fe_fd);
- if((fe_fd = open(fe_dev, O_RDWR | O_NONBLOCK)) < 0)
- fatal("open '%s': %s", fe_dev, strerror(errno));
/* empty event queue */
while(ioctl(fe_fd, FE_GET_EVENT, &event) >= 0)
; /* do nothing */
/* tune in */
if(ioctl(fe_fd, FE_SET_FRONTEND, needed_params) < 0)
- fatal("ioctl FE_GET_FRONTEND: %s", strerror(errno));
+ fatal("Unable to retune: ioctl FE_SET_FRONTEND: %s", strerror(errno));
/* wait for lock */
vverbose("Waiting for tuner to lock on");
/* TODO: use timeout value here */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-01-26 17:04:52
|
Revision: 200
http://svn.sourceforge.net/redbutton/?rev=200&view=rev
Author: skilvington
Date: 2007-01-26 09:04:50 -0800 (Fri, 26 Jan 2007)
Log Message:
-----------
only snprintf the frontend device name once
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-01-26 17:01:43 UTC (rev 199)
+++ redbutton-download/trunk/channels.c 2007-01-26 17:04:50 UTC (rev 200)
@@ -242,10 +242,9 @@
/* need to keep the frontend device open to stop it untuning itself */
static int fe_fd = -1;
- snprintf(fe_dev, sizeof(fe_dev), FE_DEVICE, adapter);
-
if(fe_fd < 0)
{
+ snprintf(fe_dev, sizeof(fe_dev), FE_DEVICE, adapter);
/*
* need O_RDWR if you want to tune, O_RDONLY is okay for getting info
* if someone else is using the frontend, we can only open O_RDONLY
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-01-27 18:59:29
|
Revision: 201
http://svn.sourceforge.net/redbutton/?rev=201&view=rev
Author: skilvington
Date: 2007-01-27 10:59:26 -0800 (Sat, 27 Jan 2007)
Log Message:
-----------
not a fatal error if you don't have a DVB-T device - it just means you can't retune (yet)
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-01-26 17:04:50 UTC (rev 200)
+++ redbutton-download/trunk/channels.c 2007-01-27 18:59:26 UTC (rev 201)
@@ -264,7 +264,11 @@
fatal("ioctl FE_GET_INFO: %s", strerror(errno));
if(fe_info.type != FE_OFDM)
- fatal("TODO: Only able to tune DVB-T devices at present");
+ {
+/* TODO */
+printf("TODO: Only able to tune DVB-T devices at present\n");
+return false;
+ }
/* see what we are currently tuned to */
if(ioctl(fe_fd, FE_GET_FRONTEND, ¤t_params) < 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-01-28 09:52:06
|
Revision: 202
http://svn.sourceforge.net/redbutton/?rev=202&view=rev
Author: skilvington
Date: 2007-01-28 01:52:02 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
if frontend is not locked when we start, tune it
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-01-27 18:59:26 UTC (rev 201)
+++ redbutton-download/trunk/channels.c 2007-01-28 09:52:02 UTC (rev 202)
@@ -238,6 +238,7 @@
struct dvb_frontend_parameters current_params;
struct dvb_frontend_parameters *needed_params;
struct dvb_frontend_event event;
+ fe_status_t status;
bool lock;
/* need to keep the frontend device open to stop it untuning itself */
static int fe_fd = -1;
@@ -281,16 +282,20 @@
return false;
}
-/* TODO */
/* if no-one was using the frontend when we open it
* FE_GET_FRONTEND may say we are tuned to the frequency we want
* but when we try to read any data, it fails
- * => always tune the first time we open the frontend
+ * so check if we have a lock
*/
+ if(ioctl(fe_fd, FE_READ_STATUS, &status) < 0)
+ lock = false;
+ else
+ lock = status & FE_HAS_LOCK;
/* are we already tuned to the right frequency */
- vverbose("Current frequency %u; needed %u", current_params.frequency, needed_params->frequency);
- if(current_params.frequency != needed_params->frequency)
+ vverbose("Current frequency %u; needed %u; lock=%d", current_params.frequency, needed_params->frequency, lock);
+ if(!lock
+ || current_params.frequency != needed_params->frequency)
{
verbose("Retuning to frequency %u", needed_params->frequency);
/* empty event queue */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-02-13 17:00:09
|
Revision: 215
http://svn.sourceforge.net/redbutton/?rev=215&view=rev
Author: skilvington
Date: 2007-02-13 08:59:54 -0800 (Tue, 13 Feb 2007)
Log Message:
-----------
retry ioctl if it is interrupted by a signal
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-02-13 14:13:03 UTC (rev 214)
+++ redbutton-download/trunk/channels.c 2007-02-13 16:59:54 UTC (rev 215)
@@ -234,6 +234,7 @@
tune_service_id(unsigned int adapter, unsigned int timeout, uint16_t service_id)
{
char fe_dev[PATH_MAX];
+ bool got_info;
struct dvb_frontend_info fe_info;
struct dvb_frontend_parameters current_params;
struct dvb_frontend_parameters *needed_params;
@@ -261,8 +262,14 @@
vverbose("Getting frontend info");
- if(ioctl(fe_fd, FE_GET_INFO, &fe_info) < 0)
- fatal("ioctl FE_GET_INFO: %s", strerror(errno));
+ do
+ {
+ /* maybe interrupted by a signal */
+ got_info = (ioctl(fe_fd, FE_GET_INFO, &fe_info) >= 0);
+ if(!got_info && errno != EINTR)
+ fatal("ioctl FE_GET_INFO: %s", strerror(errno));
+ }
+ while(!got_info);
if(fe_info.type != FE_OFDM)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-25 17:35:25
|
Revision: 293
http://svn.sourceforge.net/redbutton/?rev=293&view=rev
Author: skilvington
Date: 2007-04-25 10:35:23 -0700 (Wed, 25 Apr 2007)
Log Message:
-----------
whitespace
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-25 10:20:11 UTC (rev 292)
+++ redbutton-download/trunk/channels.c 2007-04-25 17:35:23 UTC (rev 293)
@@ -289,7 +289,8 @@
return false;
}
- /* if no-one was using the frontend when we open it
+ /*
+ * if no-one was using the frontend when we open it
* FE_GET_FRONTEND may say we are tuned to the frequency we want
* but when we try to read any data, it fails
* so check if we have a lock
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-26 12:10:37
|
Revision: 294
http://svn.sourceforge.net/redbutton/?rev=294&view=rev
Author: skilvington
Date: 2007-04-26 05:10:34 -0700 (Thu, 26 Apr 2007)
Log Message:
-----------
prepare to allow DVB-S and -C cards to retune too
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-25 17:35:23 UTC (rev 293)
+++ redbutton-download/trunk/channels.c 2007-04-26 12:10:34 UTC (rev 294)
@@ -35,8 +35,12 @@
#include "utils.h"
/* internal functions */
-static struct dvb_frontend_parameters *get_tune_params(uint16_t);
+static bool get_tune_params(fe_type_t, uint16_t, struct dvb_frontend_parameters *);
+static bool get_dvbt_tune_params(uint16_t, struct dvb_frontend_parameters *);
+static bool get_dvbs_tune_params(uint16_t, struct dvb_frontend_parameters *);
+static bool get_dvbc_tune_params(uint16_t, struct dvb_frontend_parameters *);
+
static FILE *_channels = NULL;
/*
@@ -81,6 +85,7 @@
* map strings to frontend enum values
* based on tzap utility in linuxtv dvb-apps package
*/
+
struct param
{
char *name;
@@ -168,13 +173,36 @@
/*
* return the params needed to tune to the given service_id
* the data is read from the channels.conf file
- * returns NULL if the service_id is not found
+ * returns false if the service_id is not found
*/
-static struct dvb_frontend_parameters _params;
+static bool
+get_tune_params(fe_type_t fe_type, uint16_t service_id, struct dvb_frontend_parameters *out)
+{
+ if(_channels == NULL)
+ {
+ verbose("No channels.conf file available");
+ return false;
+ }
-static struct dvb_frontend_parameters *
-get_tune_params(uint16_t service_id)
+ bzero(out, sizeof(struct dvb_frontend_parameters));
+
+ verbose("Searching channels.conf for service_id %u", service_id);
+
+ if(fe_type == FE_OFDM)
+ return get_dvbt_tune_params(service_id, out);
+ else if(fe_type == FE_QPSK)
+ return get_dvbs_tune_params(service_id, out);
+ else if(fe_type == FE_QAM)
+ return get_dvbc_tune_params(service_id, out);
+ else
+ error("Unknown DVB device type (%d)", fe_type);
+
+ return false;
+}
+
+static bool
+get_dvbt_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
{
char line[1024];
unsigned int freq;
@@ -189,16 +217,6 @@
unsigned int id;
int len;
- if(_channels == NULL)
- {
- verbose("No channels.conf file available");
- return NULL;
- }
-
- bzero(&_params, sizeof(_params));
-
- verbose("Searching channels.conf for service_id %u", service_id);
-
rewind(_channels);
while(!feof(_channels))
{
@@ -211,21 +229,35 @@
while(len >= 0 && line[len] == '\n')
line[len--] = '\0';
verbose("%s", line);
- _params.frequency = freq;
- _params.inversion = str2enum(inv, inversion_list, LIST_SIZE(inversion_list));
- _params.u.ofdm.bandwidth = str2enum(bw, bw_list, LIST_SIZE(bw_list));
- _params.u.ofdm.code_rate_HP = str2enum(hp, fec_list, LIST_SIZE(fec_list));
- _params.u.ofdm.code_rate_LP = str2enum(lp, fec_list, LIST_SIZE(fec_list));
- _params.u.ofdm.constellation = str2enum(qam, constellation_list, LIST_SIZE(constellation_list));
- _params.u.ofdm.transmission_mode = str2enum(trans, transmissionmode_list, LIST_SIZE(transmissionmode_list));
- _params.u.ofdm.guard_interval = str2enum(gi, guard_list, LIST_SIZE(guard_list));
- _params.u.ofdm.hierarchy_information = str2enum(hier, hierarchy_list, LIST_SIZE(hierarchy_list));
- return &_params;
+ out->frequency = freq;
+ out->inversion = str2enum(inv, inversion_list, LIST_SIZE(inversion_list));
+ out->u.ofdm.bandwidth = str2enum(bw, bw_list, LIST_SIZE(bw_list));
+ out->u.ofdm.code_rate_HP = str2enum(hp, fec_list, LIST_SIZE(fec_list));
+ out->u.ofdm.code_rate_LP = str2enum(lp, fec_list, LIST_SIZE(fec_list));
+ out->u.ofdm.constellation = str2enum(qam, constellation_list, LIST_SIZE(constellation_list));
+ out->u.ofdm.transmission_mode = str2enum(trans, transmissionmode_list, LIST_SIZE(transmissionmode_list));
+ out->u.ofdm.guard_interval = str2enum(gi, guard_list, LIST_SIZE(guard_list));
+ out->u.ofdm.hierarchy_information = str2enum(hier, hierarchy_list, LIST_SIZE(hierarchy_list));
+ return true;
}
- return NULL;
+ return false;
}
+static bool
+get_dvbs_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
+{
+printf("TODO: tune DVB-S card to service_id %u\n", service_id);
+return false;
+}
+
+static bool
+get_dvbc_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
+{
+printf("TODO: tune DVB-C card to service_id %u\n", service_id);
+return false;
+}
+
/*
* retune to the frequency the given service_id is on
*/
@@ -237,7 +269,7 @@
bool got_info;
struct dvb_frontend_info fe_info;
struct dvb_frontend_parameters current_params;
- struct dvb_frontend_parameters *needed_params;
+ struct dvb_frontend_parameters needed_params;
struct dvb_frontend_event event;
fe_status_t status;
bool lock;
@@ -271,19 +303,12 @@
}
while(!got_info);
- if(fe_info.type != FE_OFDM)
- {
-/* TODO */
-printf("TODO: Only able to tune DVB-T devices at present\n");
-return false;
- }
-
/* see what we are currently tuned to */
if(ioctl(fe_fd, FE_GET_FRONTEND, ¤t_params) < 0)
fatal("ioctl FE_GET_FRONTEND: %s", strerror(errno));
/* find the tuning params for the service */
- if((needed_params = get_tune_params(service_id)) == NULL)
+ if(!get_tune_params(fe_info.type, service_id, &needed_params))
{
error("service_id %u not found in channels.conf file", service_id);
return false;
@@ -301,16 +326,16 @@
lock = status & FE_HAS_LOCK;
/* are we already tuned to the right frequency */
- vverbose("Current frequency %u; needed %u; lock=%d", current_params.frequency, needed_params->frequency, lock);
+ vverbose("Current frequency %u; needed %u; lock=%d", current_params.frequency, needed_params.frequency, lock);
if(!lock
- || current_params.frequency != needed_params->frequency)
+ || current_params.frequency != needed_params.frequency)
{
- verbose("Retuning to frequency %u", needed_params->frequency);
+ verbose("Retuning to frequency %u", needed_params.frequency);
/* empty event queue */
while(ioctl(fe_fd, FE_GET_EVENT, &event) >= 0)
; /* do nothing */
/* tune in */
- if(ioctl(fe_fd, FE_SET_FRONTEND, needed_params) < 0)
+ if(ioctl(fe_fd, FE_SET_FRONTEND, &needed_params) < 0)
fatal("Unable to retune: ioctl FE_SET_FRONTEND: %s", strerror(errno));
/* wait for lock */
vverbose("Waiting for tuner to lock on");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-26 14:37:49
|
Revision: 295
http://svn.sourceforge.net/redbutton/?rev=295&view=rev
Author: skilvington
Date: 2007-04-26 07:37:47 -0700 (Thu, 26 Apr 2007)
Log Message:
-----------
prepare to allow ATSC cards to tune
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-26 12:10:34 UTC (rev 294)
+++ redbutton-download/trunk/channels.c 2007-04-26 14:37:47 UTC (rev 295)
@@ -40,6 +40,7 @@
static bool get_dvbt_tune_params(uint16_t, struct dvb_frontend_parameters *);
static bool get_dvbs_tune_params(uint16_t, struct dvb_frontend_parameters *);
static bool get_dvbc_tune_params(uint16_t, struct dvb_frontend_parameters *);
+static bool get_atsc_tune_params(uint16_t, struct dvb_frontend_parameters *);
static FILE *_channels = NULL;
@@ -195,6 +196,8 @@
return get_dvbs_tune_params(service_id, out);
else if(fe_type == FE_QAM)
return get_dvbc_tune_params(service_id, out);
+ else if(fe_type == FE_ATSC)
+ return get_atsc_tune_params(service_id, out);
else
error("Unknown DVB device type (%d)", fe_type);
@@ -258,6 +261,13 @@
return false;
}
+static bool
+get_atsc_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
+{
+printf("TODO: tune ATSC card to service_id %u\n", service_id);
+return false;
+}
+
/*
* retune to the frequency the given service_id is on
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-28 19:30:53
|
Revision: 297
http://svn.sourceforge.net/redbutton/?rev=297&view=rev
Author: skilvington
Date: 2007-04-28 12:30:47 -0700 (Sat, 28 Apr 2007)
Log Message:
-----------
allow DVB-S cards to retune (in theory anyway, I don't have a DVB-S card to test it)
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-27 09:38:23 UTC (rev 296)
+++ redbutton-download/trunk/channels.c 2007-04-28 19:30:47 UTC (rev 297)
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
@@ -34,14 +35,29 @@
#include "utils.h"
+/* magic DVB-S values from dvbtune */
+#define SLOF (11700*1000UL)
+#define LOF1 (9750*1000UL)
+#define LOF2 (10600*1000UL)
+
/* internal functions */
-static bool get_tune_params(fe_type_t, uint16_t, struct dvb_frontend_parameters *);
+static bool get_tune_params(fe_type_t, uint16_t, struct dvb_frontend_parameters *, char *, unsigned int *);
static bool get_dvbt_tune_params(uint16_t, struct dvb_frontend_parameters *);
-static bool get_dvbs_tune_params(uint16_t, struct dvb_frontend_parameters *);
+static bool get_dvbs_tune_params(uint16_t, struct dvb_frontend_parameters *, char *, unsigned int *);
static bool get_dvbc_tune_params(uint16_t, struct dvb_frontend_parameters *);
static bool get_atsc_tune_params(uint16_t, struct dvb_frontend_parameters *);
+/* DISEQC code from dvbtune, written by Dave Chapman */
+struct diseqc_cmd
+{
+ struct dvb_diseqc_master_cmd cmd;
+ uint32_t wait;
+};
+
+static int do_diseqc(int, int, char, bool);
+static int diseqc_send_msg(int fd, fe_sec_voltage_t, struct diseqc_cmd *, fe_sec_tone_mode_t, fe_sec_mini_cmd_t);
+
/*
* returns "tzap" if the given DVB adapter is DVB-T,
* "szap" if it is DVB-S
@@ -241,7 +257,7 @@
*/
static bool
-get_tune_params(fe_type_t fe_type, uint16_t service_id, struct dvb_frontend_parameters *out)
+get_tune_params(fe_type_t fe_type, uint16_t service_id, struct dvb_frontend_parameters *out, char *pol, unsigned int *sat_no)
{
if(_channels == NULL)
{
@@ -253,10 +269,12 @@
verbose("Searching channels.conf for service_id %u", service_id);
+ rewind(_channels);
+
if(fe_type == FE_OFDM)
return get_dvbt_tune_params(service_id, out);
else if(fe_type == FE_QPSK)
- return get_dvbs_tune_params(service_id, out);
+ return get_dvbs_tune_params(service_id, out, pol, sat_no);
else if(fe_type == FE_QAM)
return get_dvbc_tune_params(service_id, out);
else if(fe_type == FE_ATSC)
@@ -267,6 +285,13 @@
return false;
}
+/*
+ * DVB-T channels.conf format is:
+ * name:freq:inversion:bandwidth:code_rate_HP:code_rate_LP:constellation:transmission_mode:guard_interval:hierarchy:vpid:apid:service_id
+ * eg:
+ * BBC ONE:722166670:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_3_4:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:600:601:4165
+ */
+
static bool
get_dvbt_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
{
@@ -283,7 +308,6 @@
unsigned int id;
int len;
- rewind(_channels);
while(!feof(_channels))
{
if(fgets(line, sizeof(line), _channels) == NULL
@@ -310,11 +334,41 @@
return false;
}
+/*
+ * DVB-S channels.conf format is:
+ * name:freq:polarity:sat_number:symbol_rate:vpid:apid:service_id
+ * eg:
+ * Cartoon Network:10949:v:0:27500:6601:6611:7457
+ */
+
static bool
-get_dvbs_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
+get_dvbs_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out, char *pol, unsigned int *sat_no)
{
-printf("TODO: tune DVB-S card to service_id %u\n", service_id);
-return false;
+ char line[1024];
+ unsigned int freq;
+ unsigned int sr;
+ unsigned int id;
+ int len;
+
+ while(!feof(_channels))
+ {
+ if(fgets(line, sizeof(line), _channels) == NULL
+ || sscanf(line, "%*[^:]:%u:%1[^:]:%u:%u:%*[^:]:%*[^:]:%u", &freq, pol, sat_no, &sr, &id) != 5
+ || id != service_id)
+ continue;
+ /* chop off trailing \n */
+ len = strlen(line) - 1;
+ while(len >= 0 && line[len] == '\n')
+ line[len--] = '\0';
+ verbose("%s", line);
+ out->frequency = freq * 1000;
+ out->inversion = INVERSION_AUTO;
+ out->u.qpsk.symbol_rate = sr;
+ out->u.qpsk.fec_inner = FEC_AUTO;
+ return true;
+ }
+
+ return false;
}
static bool
@@ -331,7 +385,54 @@
return false;
}
+/* DISEQC code from dvbtune, written by Dave Chapman */
+
/*
+ * digital satellite equipment control,
+ * specification is available from http://www.eutelsat.com/
+ */
+
+static int
+do_diseqc(int secfd, int sat_no, char pol, bool hi_lo)
+{
+ bool polv = (toupper(pol) == 'V');
+ struct diseqc_cmd cmd = { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
+
+ /*
+ * param: high nibble: reset bits, low nibble set bits,
+ * bits are: option, position, polarizaion, band
+ */
+ cmd.cmd.msg[3] = 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (polv ? 0 : 2));
+
+ return diseqc_send_msg( secfd,
+ polv ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18,
+ &cmd,
+ hi_lo ? SEC_TONE_ON : SEC_TONE_OFF,
+ (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A);
+}
+
+static int
+diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd, fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
+{
+ if(ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) < 0)
+ return -1;
+ if(ioctl(fd, FE_SET_VOLTAGE, v) < 0)
+ return -1;
+ usleep(15 * 1000);
+ if(ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd) < 0)
+ return -1;
+ usleep(cmd->wait * 1000);
+ usleep(15 * 1000);
+ if(ioctl(fd, FE_DISEQC_SEND_BURST, b) < 0)
+ return -1;
+ usleep(15 * 1000);
+ if(ioctl(fd, FE_SET_TONE, t) < 0)
+ return -1;
+
+ return 0;
+}
+
+/*
* retune to the frequency the given service_id is on
*/
@@ -343,6 +444,9 @@
struct dvb_frontend_info fe_info;
struct dvb_frontend_parameters current_params;
struct dvb_frontend_parameters needed_params;
+ char polarity;
+ unsigned int sat_no;
+ bool hi_lo;
struct dvb_frontend_event event;
fe_status_t status;
bool lock;
@@ -381,7 +485,7 @@
fatal("ioctl FE_GET_FRONTEND: %s", strerror(errno));
/* find the tuning params for the service */
- if(!get_tune_params(fe_info.type, service_id, &needed_params))
+ if(!get_tune_params(fe_info.type, service_id, &needed_params, &polarity, &sat_no))
{
error("service_id %u not found in channels.conf file", service_id);
return false;
@@ -407,6 +511,21 @@
/* empty event queue */
while(ioctl(fe_fd, FE_GET_EVENT, &event) >= 0)
; /* do nothing */
+ /* do DISEQC (whatever that is) for DVB-S */
+ if(fe_info.type == FE_QPSK)
+ {
+ if(needed_params.frequency < SLOF)
+ {
+ needed_params.frequency -= LOF1;
+ hi_lo = false;
+ }
+ else
+ {
+ needed_params.frequency -= LOF2;
+ hi_lo = true;
+ }
+ do_diseqc(fe_fd, sat_no, polarity, hi_lo);
+ }
/* tune in */
if(ioctl(fe_fd, FE_SET_FRONTEND, &needed_params) < 0)
fatal("Unable to retune: ioctl FE_SET_FRONTEND: %s", strerror(errno));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-28 20:14:19
|
Revision: 298
http://svn.sourceforge.net/redbutton/?rev=298&view=rev
Author: skilvington
Date: 2007-04-28 13:13:54 -0700 (Sat, 28 Apr 2007)
Log Message:
-----------
check if DISEQC succeeded
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-28 19:30:47 UTC (rev 297)
+++ redbutton-download/trunk/channels.c 2007-04-28 20:13:54 UTC (rev 298)
@@ -524,7 +524,8 @@
needed_params.frequency -= LOF2;
hi_lo = true;
}
- do_diseqc(fe_fd, sat_no, polarity, hi_lo);
+ if(do_diseqc(fe_fd, sat_no, polarity, hi_lo) < 0)
+ error("DISEQC command failed for service_id %u", service_id);
}
/* tune in */
if(ioctl(fe_fd, FE_SET_FRONTEND, &needed_params) < 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-28 20:17:10
|
Revision: 299
http://svn.sourceforge.net/redbutton/?rev=299&view=rev
Author: skilvington
Date: 2007-04-28 13:17:02 -0700 (Sat, 28 Apr 2007)
Log Message:
-----------
polarity is a char not a string
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-28 20:13:54 UTC (rev 298)
+++ redbutton-download/trunk/channels.c 2007-04-28 20:17:02 UTC (rev 299)
@@ -353,7 +353,7 @@
while(!feof(_channels))
{
if(fgets(line, sizeof(line), _channels) == NULL
- || sscanf(line, "%*[^:]:%u:%1[^:]:%u:%u:%*[^:]:%*[^:]:%u", &freq, pol, sat_no, &sr, &id) != 5
+ || sscanf(line, "%*[^:]:%u:%c:%u:%u:%*[^:]:%*[^:]:%u", &freq, pol, sat_no, &sr, &id) != 5
|| id != service_id)
continue;
/* chop off trailing \n */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-30 20:32:08
|
Revision: 300
http://svn.sourceforge.net/redbutton/?rev=300&view=rev
Author: skilvington
Date: 2007-04-30 13:32:04 -0700 (Mon, 30 Apr 2007)
Log Message:
-----------
typo
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-28 20:17:02 UTC (rev 299)
+++ redbutton-download/trunk/channels.c 2007-04-30 20:32:04 UTC (rev 300)
@@ -56,7 +56,7 @@
};
static int do_diseqc(int, int, char, bool);
-static int diseqc_send_msg(int fd, fe_sec_voltage_t, struct diseqc_cmd *, fe_sec_tone_mode_t, fe_sec_mini_cmd_t);
+static int diseqc_send_msg(int, fe_sec_voltage_t, struct diseqc_cmd *, fe_sec_tone_mode_t, fe_sec_mini_cmd_t);
/*
* returns "tzap" if the given DVB adapter is DVB-T,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-05-01 10:02:22
|
Revision: 301
http://svn.sourceforge.net/redbutton/?rev=301&view=rev
Author: skilvington
Date: 2007-05-01 03:02:18 -0700 (Tue, 01 May 2007)
Log Message:
-----------
allow DVB-C cards to retune (untested)
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-30 20:32:04 UTC (rev 300)
+++ redbutton-download/trunk/channels.c 2007-05-01 10:02:18 UTC (rev 301)
@@ -216,14 +216,14 @@
{ "HIERARCHY_NONE", HIERARCHY_NONE }
};
-static const struct param constellation_list[] =
+static const struct param qam_list[] =
{
{ "QPSK", QPSK },
- { "QAM_128", QAM_128 },
{ "QAM_16", QAM_16 },
- { "QAM_256", QAM_256 },
{ "QAM_32", QAM_32 },
- { "QAM_64", QAM_64 }
+ { "QAM_64", QAM_64 },
+ { "QAM_128", QAM_128 },
+ { "QAM_256", QAM_256 }
};
static const struct param transmissionmode_list[] =
@@ -324,7 +324,7 @@
out->u.ofdm.bandwidth = str2enum(bw, bw_list, LIST_SIZE(bw_list));
out->u.ofdm.code_rate_HP = str2enum(hp, fec_list, LIST_SIZE(fec_list));
out->u.ofdm.code_rate_LP = str2enum(lp, fec_list, LIST_SIZE(fec_list));
- out->u.ofdm.constellation = str2enum(qam, constellation_list, LIST_SIZE(constellation_list));
+ out->u.ofdm.constellation = str2enum(qam, qam_list, LIST_SIZE(qam_list));
out->u.ofdm.transmission_mode = str2enum(trans, transmissionmode_list, LIST_SIZE(transmissionmode_list));
out->u.ofdm.guard_interval = str2enum(gi, guard_list, LIST_SIZE(guard_list));
out->u.ofdm.hierarchy_information = str2enum(hier, hierarchy_list, LIST_SIZE(hierarchy_list));
@@ -371,11 +371,45 @@
return false;
}
+/*
+ * DVB-C channels.conf format is:
+ * name:freq:inversion:symbol_rate:fec:modulation:vpid:apid:service_id
+ * eg:
+ * Eurosport:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:410:420
+ */
+
static bool
get_dvbc_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
{
-printf("TODO: tune DVB-C card to service_id %u\n", service_id);
-return false;
+ char line[1024];
+ unsigned int freq;
+ char inv[32];
+ unsigned int sr;
+ char fec[32];
+ char mod[32];
+ unsigned int id;
+ int len;
+
+ while(!feof(_channels))
+ {
+ if(fgets(line, sizeof(line), _channels) == NULL
+ || sscanf(line, "%*[^:]:%u:%32[^:]:%u:%32[^:]:%32[^:]:%*[^:]:%*[^:]:%u", &freq, inv, &sr, fec, mod, &id) != 6
+ || id != service_id)
+ continue;
+ /* chop off trailing \n */
+ len = strlen(line) - 1;
+ while(len >= 0 && line[len] == '\n')
+ line[len--] = '\0';
+ verbose("%s", line);
+ out->frequency = freq;
+ out->inversion = str2enum(inv, inversion_list, LIST_SIZE(inversion_list));
+ out->u.qam.symbol_rate = sr;
+ out->u.qam.fec_inner = str2enum(fec, fec_list, LIST_SIZE(fec_list));
+ out->u.qam.modulation = str2enum(mod, qam_list, LIST_SIZE(qam_list));
+ return true;
+ }
+
+ return false;
}
static bool
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-05-01 10:06:41
|
Revision: 302
http://svn.sourceforge.net/redbutton/?rev=302&view=rev
Author: skilvington
Date: 2007-05-01 03:06:37 -0700 (Tue, 01 May 2007)
Log Message:
-----------
DVB-S channels.conf stores symbol rate / 1000
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-05-01 10:02:18 UTC (rev 301)
+++ redbutton-download/trunk/channels.c 2007-05-01 10:06:37 UTC (rev 302)
@@ -363,7 +363,7 @@
verbose("%s", line);
out->frequency = freq * 1000;
out->inversion = INVERSION_AUTO;
- out->u.qpsk.symbol_rate = sr;
+ out->u.qpsk.symbol_rate = sr * 1000;
out->u.qpsk.fec_inner = FEC_AUTO;
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-05-01 10:15:33
|
Revision: 303
http://svn.sourceforge.net/redbutton/?rev=303&view=rev
Author: skilvington
Date: 2007-05-01 03:15:32 -0700 (Tue, 01 May 2007)
Log Message:
-----------
allow ATSC cards to retune (untested)
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-05-01 10:06:37 UTC (rev 302)
+++ redbutton-download/trunk/channels.c 2007-05-01 10:15:32 UTC (rev 303)
@@ -412,11 +412,40 @@
return false;
}
+/*
+ * ATSC channels.conf format is:
+ * name:frequency:modulation:vpid:apid:service_id
+ * eg:
+ * Jazz-TV:647000000:QAM_256:49:52:3
+ */
+
static bool
get_atsc_tune_params(uint16_t service_id, struct dvb_frontend_parameters *out)
{
-printf("TODO: tune ATSC card to service_id %u\n", service_id);
-return false;
+ char line[1024];
+ unsigned int freq;
+ char mod[32];
+ unsigned int id;
+ int len;
+
+ while(!feof(_channels))
+ {
+ if(fgets(line, sizeof(line), _channels) == NULL
+ || sscanf(line, "%*[^:]:%u:%32[^:]:%*[^:]:%*[^:]:%u", &freq, mod, &id) != 3
+ || id != service_id)
+ continue;
+ /* chop off trailing \n */
+ len = strlen(line) - 1;
+ while(len >= 0 && line[len] == '\n')
+ line[len--] = '\0';
+ verbose("%s", line);
+ out->frequency = freq;
+ /* out->inversion is not set by azap */
+ out->u.vsb.modulation = str2enum(mod, qam_list, LIST_SIZE(qam_list));
+ return true;
+ }
+
+ return false;
}
/* DISEQC code from dvbtune, written by Dave Chapman */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-05-01 10:19:50
|
Revision: 304
http://svn.sourceforge.net/redbutton/?rev=304&view=rev
Author: skilvington
Date: 2007-05-01 03:19:43 -0700 (Tue, 01 May 2007)
Log Message:
-----------
typo
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-05-01 10:15:32 UTC (rev 303)
+++ redbutton-download/trunk/channels.c 2007-05-01 10:19:43 UTC (rev 304)
@@ -375,7 +375,7 @@
* DVB-C channels.conf format is:
* name:freq:inversion:symbol_rate:fec:modulation:vpid:apid:service_id
* eg:
- * Eurosport:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:410:420
+ * Eurosport:394000000:INVERSION_OFF:6900000:FEC_NONE:QAM_64:410:420:16000
*/
static bool
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-05-01 12:19:58
|
Revision: 305
http://svn.sourceforge.net/redbutton/?rev=305&view=rev
Author: skilvington
Date: 2007-05-01 05:19:57 -0700 (Tue, 01 May 2007)
Log Message:
-----------
include ATSC modulation types
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-05-01 10:19:43 UTC (rev 304)
+++ redbutton-download/trunk/channels.c 2007-05-01 12:19:57 UTC (rev 305)
@@ -223,7 +223,9 @@
{ "QAM_32", QAM_32 },
{ "QAM_64", QAM_64 },
{ "QAM_128", QAM_128 },
- { "QAM_256", QAM_256 }
+ { "QAM_256", QAM_256 },
+ { "8VSB", VSB_8 },
+ { "16VSB", VSB_16 }
};
static const struct param transmissionmode_list[] =
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-05-23 10:31:04
|
Revision: 307
http://svn.sourceforge.net/redbutton/?rev=307&view=rev
Author: skilvington
Date: 2007-05-23 03:31:02 -0700 (Wed, 23 May 2007)
Log Message:
-----------
always retune when we start up
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-05-22 16:13:24 UTC (rev 306)
+++ redbutton-download/trunk/channels.c 2007-05-23 10:31:02 UTC (rev 307)
@@ -513,10 +513,11 @@
unsigned int sat_no;
bool hi_lo;
struct dvb_frontend_event event;
- fe_status_t status;
+// fe_status_t status;
bool lock;
/* need to keep the frontend device open to stop it untuning itself */
static int fe_fd = -1;
+ static bool first_time = true;
if(fe_fd < 0)
{
@@ -560,18 +561,22 @@
* if no-one was using the frontend when we open it
* FE_GET_FRONTEND may say we are tuned to the frequency we want
* but when we try to read any data, it fails
- * so check if we have a lock
+ * checking if we have a lock doesn't seem to work
+ * so, always retune the first time we are called
*/
+#if 0
if(ioctl(fe_fd, FE_READ_STATUS, &status) < 0)
lock = false;
else
lock = status & FE_HAS_LOCK;
+#endif
/* are we already tuned to the right frequency */
- vverbose("Current frequency %u; needed %u; lock=%d", current_params.frequency, needed_params.frequency, lock);
- if(!lock
+ vverbose("Current frequency %u; needed %u; first_time=%d", current_params.frequency, needed_params.frequency, first_time);
+ if(first_time
|| current_params.frequency != needed_params.frequency)
{
+ first_time = false;
verbose("Retuning to frequency %u", needed_params.frequency);
/* empty event queue */
while(ioctl(fe_fd, FE_GET_EVENT, &event) >= 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-05-23 10:45:32
|
Revision: 310
http://svn.sourceforge.net/redbutton/?rev=310&view=rev
Author: skilvington
Date: 2007-05-23 03:45:31 -0700 (Wed, 23 May 2007)
Log Message:
-----------
don't try to retune at start up if we can't open the frontend r/w
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-05-23 10:41:01 UTC (rev 309)
+++ redbutton-download/trunk/channels.c 2007-05-23 10:45:31 UTC (rev 310)
@@ -532,6 +532,8 @@
error("Unable to open '%s' read/write; you will not be able to retune", fe_dev);
if((fe_fd = open(fe_dev, O_RDONLY | O_NONBLOCK)) < 0)
fatal("open '%s': %s", fe_dev, strerror(errno));
+ /* don't try to tune in */
+ first_time = false;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-23 13:10:29
|
Revision: 340
http://redbutton.svn.sourceforge.net/redbutton/?rev=340&view=rev
Author: skilvington
Date: 2007-08-23 06:10:24 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
patch from Mario Rossi to stop rb-download trying to tune unless it really needs to
Modified Paths:
--------------
redbutton-download/trunk/channels.c
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-08-23 12:53:39 UTC (rev 339)
+++ redbutton-download/trunk/channels.c 2007-08-23 13:10:24 UTC (rev 340)
@@ -39,6 +39,7 @@
#define SLOF (11700*1000UL)
#define LOF1 (9750*1000UL)
#define LOF2 (10600*1000UL)
+#define ONE_kHz 1000UL
/* internal functions */
static bool get_tune_params(fe_type_t, uint16_t, struct dvb_frontend_parameters *, char *, unsigned int *);
@@ -575,8 +576,10 @@
/* are we already tuned to the right frequency */
vverbose("Current frequency %u; needed %u; first_time=%d", current_params.frequency, needed_params.frequency, first_time);
+
+ /* frequency resolution is up to 1 kHz */
if(first_time
- || current_params.frequency != needed_params.frequency)
+ || abs(current_params.frequency - needed_params.frequency) >= ONE_kHz)
{
first_time = false;
verbose("Retuning to frequency %u", needed_params.frequency);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|