summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-12-21 02:34:34 +0000
committerAndrew de Quincy <devnull@localhost>2004-12-21 02:34:34 +0000
commitc962b78e10cb99b0681d3982dfa001d53b18831d (patch)
tree69865bb4a145d1d227a331482c3c798f69d88b2c
parent23ef57a66311f901ac512128a1734a9512f53e37 (diff)
downloadmediapointer-dvb-s2-c962b78e10cb99b0681d3982dfa001d53b18831d.tar.gz
mediapointer-dvb-s2-c962b78e10cb99b0681d3982dfa001d53b18831d.tar.bz2
Fix the frontend thread problem by initialising everything.
Hide private data.
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_frontend.c342
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_frontend.h25
2 files changed, 199 insertions, 168 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
index 405659248..3e1525251 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -89,9 +89,36 @@ MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB vola
static DECLARE_MUTEX(frontend_mutex);
+struct dvb_frontend_private {
+
+ struct dvb_device *dvbdev;
+ struct dvb_frontend_parameters parameters;
+ struct dvb_fe_events events;
+ struct semaphore sem;
+ struct list_head list_head;
+ wait_queue_head_t wait_queue;
+ pid_t thread_pid;
+ unsigned long release_jiffies;
+ int state;
+ int bending;
+ int lnb_drift;
+ int inversion;
+ int auto_step;
+ int auto_sub_step;
+ int started_auto_step;
+ int min_delay;
+ int max_drift;
+ int step_size;
+ int exit;
+ int wakeup;
+ fe_status_t status;
+};
+
+
static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
{
- struct dvb_fe_events *events = &fe->events;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
+ struct dvb_fe_events *events = &fepriv->events;
struct dvb_frontend_event *e;
int wp;
@@ -109,7 +136,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
e = &events->events[events->eventw];
- memcpy (&e->parameters, &fe->parameters,
+ memcpy (&e->parameters, &fepriv->parameters,
sizeof (struct dvb_frontend_parameters));
if (status & FE_HAS_LOCK)
@@ -128,7 +155,8 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
static int dvb_frontend_get_event(struct dvb_frontend *fe,
struct dvb_frontend_event *event, int flags)
{
- struct dvb_fe_events *events = &fe->events;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
+ struct dvb_fe_events *events = &fepriv->events;
dprintk ("%s\n", __FUNCTION__);
@@ -143,12 +171,12 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe,
if (flags & O_NONBLOCK)
return -EWOULDBLOCK;
- up(&fe->sem);
+ up(&fepriv->sem);
ret = wait_event_interruptible (events->wait_queue,
events->eventw != events->eventr);
- if (down_interruptible (&fe->sem))
+ if (down_interruptible (&fepriv->sem))
return -ERESTARTSYS;
if (ret < 0)
@@ -206,27 +234,28 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)
{
int autoinversion;
int ready = 0;
- int original_inversion = fe->parameters.inversion;
- u32 original_frequency = fe->parameters.frequency;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
+ int original_inversion = fepriv->parameters.inversion;
+ u32 original_frequency = fepriv->parameters.frequency;
/* are we using autoinversion? */
autoinversion = ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&
- (fe->parameters.inversion == INVERSION_AUTO));
+ (fepriv->parameters.inversion == INVERSION_AUTO));
/* setup parameters correctly */
while(!ready) {
/* calculate the lnb_drift */
- fe->lnb_drift = fe->auto_step * fe->step_size;
+ fepriv->lnb_drift = fepriv->auto_step * fepriv->step_size;
/* wrap the auto_step if we've exceeded the maximum drift */
- if (fe->lnb_drift > fe->max_drift) {
- fe->auto_step = 0;
- fe->auto_sub_step = 0;
- fe->lnb_drift = 0;
+ if (fepriv->lnb_drift > fepriv->max_drift) {
+ fepriv->auto_step = 0;
+ fepriv->auto_sub_step = 0;
+ fepriv->lnb_drift = 0;
}
/* perform inversion and +/- zigzag */
- switch(fe->auto_sub_step) {
+ switch(fepriv->auto_sub_step) {
case 0:
/* try with the current inversion and current drift setting */
ready = 1;
@@ -235,68 +264,70 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)
case 1:
if (!autoinversion) break;
- fe->inversion = (fe->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
+ fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
ready = 1;
break;
case 2:
- if (fe->lnb_drift == 0) break;
+ if (fepriv->lnb_drift == 0) break;
- fe->lnb_drift = -fe->lnb_drift;
+ fepriv->lnb_drift = -fepriv->lnb_drift;
ready = 1;
break;
case 3:
- if (fe->lnb_drift == 0) break;
+ if (fepriv->lnb_drift == 0) break;
if (!autoinversion) break;
- fe->inversion = (fe->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
- fe->lnb_drift = -fe->lnb_drift;
+ fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
+ fepriv->lnb_drift = -fepriv->lnb_drift;
ready = 1;
break;
default:
- fe->auto_step++;
- fe->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */
+ fepriv->auto_step++;
+ fepriv->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */
break;
}
- if (!ready) fe->auto_sub_step++;
+ if (!ready) fepriv->auto_sub_step++;
}
/* if this attempt would hit where we started, indicate a complete
* iteration has occurred */
- if ((fe->auto_step == fe->started_auto_step) &&
- (fe->auto_sub_step == 0) && check_wrapped) {
+ if ((fepriv->auto_step == fepriv->started_auto_step) &&
+ (fepriv->auto_sub_step == 0) && check_wrapped) {
return 1;
}
dprintk("%s: drift:%i inversion:%i auto_step:%i "
"auto_sub_step:%i started_auto_step:%i\n",
- __FUNCTION__, fe->lnb_drift, fe->inversion,
- fe->auto_step, fe->auto_sub_step, fe->started_auto_step);
+ __FUNCTION__, fepriv->lnb_drift, fepriv->inversion,
+ fepriv->auto_step, fepriv->auto_sub_step, fepriv->started_auto_step);
/* set the frontend itself */
- fe->parameters.frequency += fe->lnb_drift;
+ fepriv->parameters.frequency += fepriv->lnb_drift;
if (autoinversion)
- fe->parameters.inversion = fe->inversion;
+ fepriv->parameters.inversion = fepriv->inversion;
if (fe->ops->set_frontend)
- fe->ops->set_frontend(fe, &fe->parameters);
+ fe->ops->set_frontend(fe, &fepriv->parameters);
- fe->parameters.frequency = original_frequency;
- fe->parameters.inversion = original_inversion;
+ fepriv->parameters.frequency = original_frequency;
+ fepriv->parameters.inversion = original_inversion;
- fe->auto_sub_step++;
+ fepriv->auto_sub_step++;
return 0;
}
static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
{
- if (fe->exit)
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
+
+ if (fepriv->exit)
return 1;
- if (fe->dvbdev->writers == 1)
- if (jiffies - fe->release_jiffies > dvb_shutdown_timeout * HZ)
+ if (fepriv->dvbdev->writers == 1)
+ if (jiffies - fepriv->release_jiffies > dvb_shutdown_timeout * HZ)
return 1;
return 0;
@@ -304,8 +335,10 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
{
- if (fe->wakeup) {
- fe->wakeup = 0;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
+
+ if (fepriv->wakeup) {
+ fepriv->wakeup = 0;
return 1;
}
return dvb_frontend_is_exiting(fe);
@@ -313,8 +346,10 @@ static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
static void dvb_frontend_wakeup(struct dvb_frontend *fe)
{
- fe->wakeup = 1;
- wake_up_interruptible(&fe->wait_queue);
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
+
+ fepriv->wakeup = 1;
+ wake_up_interruptible(&fepriv->wait_queue);
}
/*
@@ -323,6 +358,7 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
static int dvb_frontend_thread(void *data)
{
struct dvb_frontend *fe = (struct dvb_frontend *) data;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
unsigned long timeout;
char name [15];
int quality = 0, delay = 3*HZ;
@@ -338,14 +374,14 @@ static int dvb_frontend_thread(void *data)
sigfillset(&current->blocked);
unlock_kernel();
- fe->status = 0;
+ fepriv->status = 0;
dvb_frontend_init(fe);
- fe->wakeup = 0;
+ fepriv->wakeup = 0;
while (1) {
- up(&fe->sem); /* is locked when we enter the thread... */
+ up(&fepriv->sem); /* is locked when we enter the thread... */
- timeout = wait_event_interruptible_timeout(fe->wait_queue,
+ timeout = wait_event_interruptible_timeout(fepriv->wait_queue,
dvb_frontend_should_wakeup(fe),
delay);
if (0 != dvb_frontend_is_exiting(fe)) {
@@ -356,11 +392,11 @@ static int dvb_frontend_thread(void *data)
if (current->flags & PF_FREEZE)
refrigerator(PF_FREEZE);
- if (down_interruptible(&fe->sem))
+ if (down_interruptible(&fepriv->sem))
break;
/* if we've got no parameters, just keep idling */
- if (fe->state & FESTATE_IDLE) {
+ if (fepriv->state & FESTATE_IDLE) {
delay = 3*HZ;
quality = 0;
continue;
@@ -368,32 +404,32 @@ static int dvb_frontend_thread(void *data)
retune:
/* get the frontend status */
- if (fe->state & FESTATE_RETUNE) {
+ if (fepriv->state & FESTATE_RETUNE) {
s = 0;
} else {
if (fe->ops->read_status)
fe->ops->read_status(fe, &s);
- if (s != fe->status) {
+ if (s != fepriv->status) {
dvb_frontend_add_event(fe, s);
- fe->status = s;
+ fepriv->status = s;
}
}
/* if we're not tuned, and we have a lock, move to the TUNED state */
- if ((fe->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {
- update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
- fe->state = FESTATE_TUNED;
+ if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {
+ update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
+ fepriv->state = FESTATE_TUNED;
/* if we're tuned, then we have determined the correct inversion */
if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&
- (fe->parameters.inversion == INVERSION_AUTO)) {
- fe->parameters.inversion = fe->inversion;
+ (fepriv->parameters.inversion == INVERSION_AUTO)) {
+ fepriv->parameters.inversion = fepriv->inversion;
}
continue;
}
/* if we are tuned already, check we're still locked */
- if (fe->state & FESTATE_TUNED) {
- update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
+ if (fepriv->state & FESTATE_TUNED) {
+ update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
/* we're tuned, and the lock is still good... */
if (s & FE_HAS_LOCK)
@@ -401,49 +437,49 @@ retune:
else {
/* if we _WERE_ tuned, but now don't have a lock,
* need to zigzag */
- fe->state = FESTATE_ZIGZAG_FAST;
- fe->started_auto_step = fe->auto_step;
+ fepriv->state = FESTATE_ZIGZAG_FAST;
+ fepriv->started_auto_step = fepriv->auto_step;
check_wrapped = 0;
}
}
/* don't actually do anything if we're in the LOSTLOCK state,
* the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */
- if ((fe->state & FESTATE_LOSTLOCK) &&
- (fe->ops->info.caps & FE_CAN_RECOVER) && (fe->max_drift == 0)) {
- update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
+ if ((fepriv->state & FESTATE_LOSTLOCK) &&
+ (fe->ops->info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) {
+ update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
continue;
}
/* don't do anything if we're in the DISEQC state, since this
* might be someone with a motorized dish controlled by DISEQC.
* If its actually a re-tune, there will be a SET_FRONTEND soon enough. */
- if (fe->state & FESTATE_DISEQC) {
- update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
+ if (fepriv->state & FESTATE_DISEQC) {
+ update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
continue;
}
/* if we're in the RETUNE state, set everything up for a brand
* new scan, keeping the current inversion setting, as the next
* tune is _very_ likely to require the same */
- if (fe->state & FESTATE_RETUNE) {
- fe->lnb_drift = 0;
- fe->auto_step = 0;
- fe->auto_sub_step = 0;
- fe->started_auto_step = 0;
+ if (fepriv->state & FESTATE_RETUNE) {
+ fepriv->lnb_drift = 0;
+ fepriv->auto_step = 0;
+ fepriv->auto_sub_step = 0;
+ fepriv->started_auto_step = 0;
check_wrapped = 0;
}
/* fast zigzag. */
- if ((fe->state & FESTATE_SEARCHING_FAST) || (fe->state & FESTATE_RETUNE)) {
- delay = fe->min_delay;
+ if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) {
+ delay = fepriv->min_delay;
/* peform a tune */
if (dvb_frontend_autotune(fe, check_wrapped)) {
/* OK, if we've run out of trials at the fast speed.
* Drop back to slow for the _next_ attempt */
- fe->state = FESTATE_SEARCHING_SLOW;
- fe->started_auto_step = fe->auto_step;
+ fepriv->state = FESTATE_SEARCHING_SLOW;
+ fepriv->started_auto_step = fepriv->auto_step;
continue;
}
check_wrapped = 1;
@@ -452,15 +488,15 @@ retune:
* This ensures we cannot return from an
* FE_SET_FRONTEND ioctl before the first frontend tune
* occurs */
- if (fe->state & FESTATE_RETUNE) {
- fe->state = FESTATE_TUNING_FAST;
+ if (fepriv->state & FESTATE_RETUNE) {
+ fepriv->state = FESTATE_TUNING_FAST;
goto retune;
}
}
/* slow zigzag */
- if (fe->state & FESTATE_SEARCHING_SLOW) {
- update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
+ if (fepriv->state & FESTATE_SEARCHING_SLOW) {
+ update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
/* Note: don't bother checking for wrapping; we stay in this
* state until we get a lock */
@@ -469,14 +505,14 @@ retune:
}
if (dvb_shutdown_timeout) {
- if (dvb_powerdown_on_sleep)
+ if (dvb_powerdown_on_sleep)
if (fe->ops->set_voltage)
fe->ops->set_voltage(fe, SEC_VOLTAGE_OFF);
if (fe->ops->sleep)
fe->ops->sleep(fe);
}
- fe->thread_pid = 0;
+ fepriv->thread_pid = 0;
mb();
dvb_frontend_wakeup(fe);
@@ -486,21 +522,22 @@ retune:
static void dvb_frontend_stop(struct dvb_frontend *fe)
{
unsigned long ret;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__);
- fe->exit = 1;
+ fepriv->exit = 1;
mb();
- if (!fe->thread_pid)
+ if (!fepriv->thread_pid)
return;
/* check if the thread is really alive */
- if (kill_proc(fe->thread_pid, 0, 1) == -ESRCH) {
+ if (kill_proc(fepriv->thread_pid, 0, 1) == -ESRCH) {
printk("dvb_frontend_stop: thread PID %d already died\n",
- fe->thread_pid);
+ fepriv->thread_pid);
/* make sure the mutex was not held by the thread */
- init_MUTEX (&fe->sem);
+ init_MUTEX (&fepriv->sem);
return;
}
@@ -508,27 +545,28 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
dvb_frontend_wakeup(fe);
/* wait until the frontend thread has exited */
- ret = wait_event_interruptible(fe->wait_queue,0 == fe->thread_pid);
+ ret = wait_event_interruptible(fepriv->wait_queue,0 == fepriv->thread_pid);
if (-ERESTARTSYS != ret) {
- fe->state = FESTATE_IDLE;
+ fepriv->state = FESTATE_IDLE;
return;
}
- fe->state = FESTATE_IDLE;
+ fepriv->state = FESTATE_IDLE;
/* paranoia check in case a signal arrived */
- if (fe->thread_pid)
+ if (fepriv->thread_pid)
printk("dvb_frontend_stop: warning: thread PID %d won't exit\n",
- fe->thread_pid);
+ fepriv->thread_pid);
}
static int dvb_frontend_start(struct dvb_frontend *fe)
{
int ret;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__);
- if (fe->thread_pid) {
- if (!fe->exit)
+ if (fepriv->thread_pid) {
+ if (!fepriv->exit)
return 0;
else
dvb_frontend_stop (fe);
@@ -536,22 +574,22 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
if (signal_pending(current))
return -EINTR;
- if (down_interruptible (&fe->sem))
+ if (down_interruptible (&fepriv->sem))
return -EINTR;
- fe->state = FESTATE_IDLE;
- fe->exit = 0;
- fe->thread_pid = 0;
+ fepriv->state = FESTATE_IDLE;
+ fepriv->exit = 0;
+ fepriv->thread_pid = 0;
mb();
ret = kernel_thread (dvb_frontend_thread, fe, 0);
if (ret < 0) {
printk("dvb_frontend_start: failed to start kernel_thread (%d)\n", ret);
- up(&fe->sem);
+ up(&fepriv->sem);
return ret;
}
- fe->thread_pid = ret;
+ fepriv->thread_pid = ret;
return 0;
}
@@ -561,11 +599,12 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
{
struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
int err = -EOPNOTSUPP;
dprintk ("%s\n", __FUNCTION__);
- if (!fe || fe->exit)
+ if (!fe || fepriv->exit)
return -ENODEV;
if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
@@ -573,7 +612,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
cmd == FE_DISEQC_RECV_SLAVE_REPLY))
return -EPERM;
- if (down_interruptible (&fe->sem))
+ if (down_interruptible (&fepriv->sem))
return -ERESTARTSYS;
switch (cmd) {
@@ -617,48 +656,48 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
case FE_DISEQC_RESET_OVERLOAD:
if (fe->ops->diseqc_reset_overload) {
err = fe->ops->diseqc_reset_overload(fe);
- fe->state = FESTATE_DISEQC;
- fe->status = 0;
+ fepriv->state = FESTATE_DISEQC;
+ fepriv->status = 0;
}
break;
case FE_DISEQC_SEND_MASTER_CMD:
if (fe->ops->diseqc_send_master_cmd) {
err = fe->ops->diseqc_send_master_cmd(fe, (struct dvb_diseqc_master_cmd*) parg);
- fe->state = FESTATE_DISEQC;
- fe->status = 0;
+ fepriv->state = FESTATE_DISEQC;
+ fepriv->status = 0;
}
break;
case FE_DISEQC_SEND_BURST:
if (fe->ops->diseqc_send_burst) {
err = fe->ops->diseqc_send_burst(fe, (fe_sec_mini_cmd_t) parg);
- fe->state = FESTATE_DISEQC;
- fe->status = 0;
+ fepriv->state = FESTATE_DISEQC;
+ fepriv->status = 0;
}
break;
case FE_SET_TONE:
if (fe->ops->set_tone) {
err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg);
- fe->state = FESTATE_DISEQC;
- fe->status = 0;
+ fepriv->state = FESTATE_DISEQC;
+ fepriv->status = 0;
}
break;
case FE_SET_VOLTAGE:
if (fe->ops->set_voltage) {
err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg);
- fe->state = FESTATE_DISEQC;
- fe->status = 0;
+ fepriv->state = FESTATE_DISEQC;
+ fepriv->status = 0;
}
break;
case FE_DISHNETWORK_SEND_LEGACY_CMD:
if (fe->ops->dishnetwork_send_legacy_command) {
err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned int) parg);
- fe->state = FESTATE_DISEQC;
- fe->status = 0;
+ fepriv->state = FESTATE_DISEQC;
+ fepriv->status = 0;
}
break;
@@ -675,7 +714,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
case FE_SET_FRONTEND: {
struct dvb_frontend_tune_settings fetunesettings;
- memcpy (&fe->parameters, parg,
+ memcpy (&fepriv->parameters, parg,
sizeof (struct dvb_frontend_parameters));
memset(&fetunesettings, 0, sizeof(struct dvb_frontend_tune_settings));
@@ -684,41 +723,41 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
/* force auto frequency inversion if requested */
if (dvb_force_auto_inversion) {
- fe->parameters.inversion = INVERSION_AUTO;
+ fepriv->parameters.inversion = INVERSION_AUTO;
fetunesettings.parameters.inversion = INVERSION_AUTO;
}
if (fe->ops->info.type == FE_OFDM) {
/* without hierachical coding code_rate_LP is irrelevant,
* so we tolerate the otherwise invalid FEC_NONE setting */
- if (fe->parameters.u.ofdm.hierarchy_information == HIERARCHY_NONE &&
- fe->parameters.u.ofdm.code_rate_LP == FEC_NONE)
- fe->parameters.u.ofdm.code_rate_LP = FEC_AUTO;
+ if (fepriv->parameters.u.ofdm.hierarchy_information == HIERARCHY_NONE &&
+ fepriv->parameters.u.ofdm.code_rate_LP == FEC_NONE)
+ fepriv->parameters.u.ofdm.code_rate_LP = FEC_AUTO;
}
/* get frontend-specific tuning settings */
if (fe->ops->get_tune_settings && (fe->ops->get_tune_settings(fe, &fetunesettings) == 0)) {
- fe->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000;
- fe->max_drift = fetunesettings.max_drift;
- fe->step_size = fetunesettings.step_size;
+ fepriv->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000;
+ fepriv->max_drift = fetunesettings.max_drift;
+ fepriv->step_size = fetunesettings.step_size;
} else {
/* default values */
switch(fe->ops->info.type) {
case FE_QPSK:
- fe->min_delay = HZ/20;
- fe->step_size = fe->parameters.u.qpsk.symbol_rate / 16000;
- fe->max_drift = fe->parameters.u.qpsk.symbol_rate / 2000;
+ fepriv->min_delay = HZ/20;
+ fepriv->step_size = fepriv->parameters.u.qpsk.symbol_rate / 16000;
+ fepriv->max_drift = fepriv->parameters.u.qpsk.symbol_rate / 2000;
break;
case FE_QAM:
- fe->min_delay = HZ/20;
- fe->step_size = 0; /* no zigzag */
- fe->max_drift = 0;
+ fepriv->min_delay = HZ/20;
+ fepriv->step_size = 0; /* no zigzag */
+ fepriv->max_drift = 0;
break;
case FE_OFDM:
- fe->min_delay = HZ/20;
- fe->step_size = fe->ops->info.frequency_stepsize * 2;
- fe->max_drift = (fe->ops->info.frequency_stepsize * 2) + 1;
+ fepriv->min_delay = HZ/20;
+ fepriv->step_size = fe->ops->info.frequency_stepsize * 2;
+ fepriv->max_drift = (fe->ops->info.frequency_stepsize * 2) + 1;
break;
case FE_ATSC:
printk("dvb-core: FE_ATSC not handled yet.\n");
@@ -726,12 +765,12 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
}
}
if (dvb_override_tune_delay > 0)
- fe->min_delay = (dvb_override_tune_delay * HZ) / 1000;
+ fepriv->min_delay = (dvb_override_tune_delay * HZ) / 1000;
- fe->state = FESTATE_RETUNE;
+ fepriv->state = FESTATE_RETUNE;
dvb_frontend_wakeup(fe);
dvb_frontend_add_event(fe, 0);
- fe->status = 0;
+ fepriv->status = 0;
err = 0;
break;
}
@@ -742,13 +781,13 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
case FE_GET_FRONTEND:
if (fe->ops->get_frontend) {
- memcpy (parg, &fe->parameters, sizeof (struct dvb_frontend_parameters));
+ memcpy (parg, &fepriv->parameters, sizeof (struct dvb_frontend_parameters));
err = fe->ops->get_frontend(fe, (struct dvb_frontend_parameters*) parg);
}
break;
};
- up (&fe->sem);
+ up (&fepriv->sem);
return err;
}
@@ -756,12 +795,13 @@ static unsigned int dvb_frontend_poll(struct file *file, struct poll_table_struc
{
struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__);
- poll_wait (file, &fe->events.wait_queue, wait);
+ poll_wait (file, &fepriv->events.wait_queue, wait);
- if (fe->events.eventw != fe->events.eventr)
+ if (fepriv->events.eventw != fepriv->events.eventr)
return (POLLIN | POLLRDNORM | POLLPRI);
return 0;
@@ -771,6 +811,7 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
int ret;
dprintk ("%s\n", __FUNCTION__);
@@ -784,7 +825,7 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
dvb_generic_release (inode, file);
/* empty event queue */
- fe->events.eventr = fe->events.eventw = 0;
+ fepriv->events.eventr = fepriv->events.eventw = 0;
}
return ret;
@@ -794,11 +835,12 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__);
if ((file->f_flags & O_ACCMODE) != O_RDONLY)
- fe->release_jiffies = jiffies;
+ fepriv->release_jiffies = jiffies;
return dvb_generic_release (inode, file);
}
@@ -814,6 +856,7 @@ static struct file_operations dvb_frontend_fops = {
int dvb_register_frontend(struct dvb_adapter* dvb,
struct dvb_frontend* fe)
{
+ struct dvb_frontend_private *fepriv;
static const struct dvb_device dvbdev_template = {
.users = ~0,
.writers = 1,
@@ -827,20 +870,26 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
if (down_interruptible (&frontend_mutex))
return -ERESTARTSYS;
- init_MUTEX (&fe->sem);
- init_waitqueue_head (&fe->wait_queue);
- init_waitqueue_head (&fe->events.wait_queue);
- init_MUTEX (&fe->events.sem);
- fe->events.eventw = fe->events.eventr = 0;
- fe->events.overflow = 0;
+ fe->frontend_priv = kmalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL);
+ if (fe->frontend_priv == NULL) {
+ up(&frontend_mutex);
+ return -ENOMEM;
+ }
+ fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
+ memset(&fe->frontend_priv, 0, sizeof(struct dvb_frontend_private));
+
+ init_MUTEX (&fepriv->sem);
+ init_waitqueue_head (&fepriv->wait_queue);
+ init_waitqueue_head (&fepriv->events.wait_queue);
+ init_MUTEX (&fepriv->events.sem);
fe->dvb = dvb;
- fe->inversion = INVERSION_OFF;
+ fepriv->inversion = INVERSION_OFF;
printk ("DVB: registering frontend %i (%s)...\n",
fe->dvb->num,
fe->ops->info.name);
- dvb_register_device (fe->dvb, &fe->dvbdev, &dvbdev_template,
+ dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template,
fe, DVB_DEVICE_FRONTEND);
up (&frontend_mutex);
@@ -850,15 +899,18 @@ EXPORT_SYMBOL(dvb_register_frontend);
int dvb_unregister_frontend(struct dvb_frontend* fe)
{
+ struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__);
down (&frontend_mutex);
- dvb_unregister_device (fe->dvbdev);
+ dvb_unregister_device (fepriv->dvbdev);
dvb_frontend_stop (fe);
if (fe->ops->release)
fe->ops->release(fe);
else
printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops->info.name);
+ if (fe->frontend_priv)
+ kfree(fe->frontend_priv);
up (&frontend_mutex);
return 0;
}
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h
index 038abac17..d2b021792 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -1,4 +1,4 @@
-/*
+/*
* dvb_frontend.h
*
* Copyright (C) 2001 convergence integrated media GmbH
@@ -115,28 +115,7 @@ struct dvb_frontend {
struct dvb_frontend_ops* ops;
struct dvb_adapter *dvb;
void* demodulator_priv;
-
- struct dvb_device *dvbdev;
- struct dvb_frontend_parameters parameters;
- struct dvb_fe_events events;
- struct semaphore sem;
- struct list_head list_head;
- wait_queue_head_t wait_queue;
- pid_t thread_pid;
- unsigned long release_jiffies;
- int state;
- int bending;
- int lnb_drift;
- int inversion;
- int auto_step;
- int auto_sub_step;
- int started_auto_step;
- int min_delay;
- int max_drift;
- int step_size;
- int exit;
- int wakeup;
- fe_status_t status;
+ void* frontend_priv;
};
extern int dvb_register_frontend(struct dvb_adapter* dvb,