summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorJohannes Stezenbach <devnull@localhost>2004-08-02 12:52:05 +0000
committerJohannes Stezenbach <devnull@localhost>2004-08-02 12:52:05 +0000
commitb87e695cffe777aa4e68e985289687ba0bd8a6f0 (patch)
tree7e23d96d7779f30dea0f03c4062cf3bbd75ee50a /linux
parent86e506d061b0c95c2f5fec093678b6320b8c1f0a (diff)
downloadmediapointer-dvb-s2-b87e695cffe777aa4e68e985289687ba0bd8a6f0.tar.gz
mediapointer-dvb-s2-b87e695cffe777aa4e68e985289687ba0bd8a6f0.tar.bz2
- clean up whitespace at eol
- change C++ comments into C comments
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_frontend.c192
1 files changed, 99 insertions, 93 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
index fd3fe99b9..429cd09ec 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -4,9 +4,9 @@
*
* Copyright (C) 1999-2001 Ralph Metzler
* Marcus Metzler
- * Holger Waechtler
+ * Holger Waechtler
* for convergence integrated media GmbH
- *
+ *
* Copyright (C) 2004 Andrew de Quincey (tuning thread cleanup)
*
* This program is free software; you can redistribute it and/or
@@ -153,7 +153,7 @@ static LIST_HEAD(frontend_notifier_list);
static DECLARE_MUTEX(frontend_mutex);
-static int dvb_frontend_internal_ioctl (struct dvb_frontend *frontend,
+static int dvb_frontend_internal_ioctl (struct dvb_frontend *frontend,
unsigned int cmd, void *arg)
{
int err = -EOPNOTSUPP;
@@ -178,7 +178,7 @@ static int dvb_frontend_internal_ioctl (struct dvb_frontend *frontend,
* if 2 tuners are located side by side you can get interferences when
* they try to tune to the same frequency, so both lose sync.
* We will slightly mistune in this case. The AFC of the demodulator
- * should make it still possible to receive the requested transponder
+ * should make it still possible to receive the requested transponder
* on both tuners...
*/
static void dvb_bend_frequency (struct dvb_frontend_data *this_fe, int recursive)
@@ -276,7 +276,7 @@ static void dvb_frontend_add_event (struct dvb_frontend_data *fe, fe_status_t st
e = &events->events[events->eventw];
- memcpy (&e->parameters, &fe->parameters,
+ memcpy (&e->parameters, &fe->parameters,
sizeof (struct dvb_frontend_parameters));
if (status & FE_HAS_LOCK)
@@ -351,23 +351,23 @@ static void dvb_frontend_init (struct dvb_frontend_data *fe)
static void update_delay (int *quality, int *delay, int min_delay, int locked)
{
int q2;
-
+
dprintk ("%s\n", __FUNCTION__);
-
+
if (locked)
(*quality) = (*quality * 220 + 36*256) / 256;
else
(*quality) = (*quality * 220 + 0) / 256;
-
+
q2 = *quality - 128;
q2 *= q2;
-
+
*delay = min_delay + q2 * HZ / (128*128);
}
/**
* Performs automatic twiddling of frontend parameters.
- *
+ *
* @param fe The frontend concerned.
* @param check_wrapped Checks if an iteration has completed. DO NOT SET ON THE FIRST ATTEMPT
* @returns Number of complete iterations that have been performed.
@@ -379,82 +379,84 @@ static int dvb_frontend_autotune(struct dvb_frontend_data *fe, int check_wrapped
int original_inversion = fe->parameters.inversion;
u32 original_frequency = fe->parameters.frequency;
- // are we using autoinversion?
- autoinversion = ((!(fe->info->caps & FE_CAN_INVERSION_AUTO)) && (fe->parameters.inversion == INVERSION_AUTO));
+ /* are we using autoinversion? */
+ autoinversion = ((!(fe->info->caps & FE_CAN_INVERSION_AUTO)) &&
+ (fe->parameters.inversion == INVERSION_AUTO));
- // setup parameters correctly
+ /* setup parameters correctly */
while(!ready) {
- // calculate the lnb_drift
+ /* calculate the lnb_drift */
fe->lnb_drift = fe->auto_step * fe->step_size;
- // wrap the auto_step if we've exceeded the maximum drift
+ /* 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;
}
- // perform inversion and +/- zigzag
+ /* perform inversion and +/- zigzag */
switch(fe->auto_sub_step) {
case 0:
- // try with the current inversion and current drift setting
+ /* try with the current inversion and current drift setting */
ready = 1;
break;
-
+
case 1:
if (!autoinversion) break;
fe->inversion = (fe->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
ready = 1;
break;
-
+
case 2:
if (fe->lnb_drift == 0) break;
-
+
fe->lnb_drift = -fe->lnb_drift;
ready = 1;
break;
-
+
case 3:
if (fe->lnb_drift == 0) break;
if (!autoinversion) break;
-
+
fe->inversion = (fe->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
fe->lnb_drift = -fe->lnb_drift;
ready = 1;
break;
-
+
default:
fe->auto_step++;
- fe->auto_sub_step = -1; // it'll be incremented to 0 in a moment
+ fe->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */
break;
}
-
+
if (!ready) fe->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 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) {
return 1;
}
- // perform frequency bending if necessary
+ /* perform frequency bending if necessary */
if ((dvb_override_frequency_bending != 1) && do_frequency_bending)
dvb_bend_frequency(fe, 0);
- // instrumentation
- dprintk("%s: drift:%i bending:%i inversion:%i auto_step:%i auto_sub_step:%i started_auto_step:%i\n",
- __FUNCTION__, fe->lnb_drift, fe->bending, fe->inversion, fe->auto_step, fe->auto_sub_step,
- fe->started_auto_step);
-
- // set the frontend itself
+ dprintk("%s: drift:%i bending:%i inversion:%i auto_step:%i "
+ "auto_sub_step:%i started_auto_step:%i\n",
+ __FUNCTION__, fe->lnb_drift, fe->bending, fe->inversion,
+ fe->auto_step, fe->auto_sub_step, fe->started_auto_step);
+
+ /* set the frontend itself */
fe->parameters.frequency += fe->lnb_drift + fe->bending;
if (autoinversion) fe->parameters.inversion = fe->inversion;
dvb_frontend_internal_ioctl (&fe->frontend, FE_SET_FRONTEND, &fe->parameters);
fe->parameters.frequency = original_frequency;
fe->parameters.inversion = original_inversion;
- // normal return
fe->auto_sub_step++;
return 0;
}
@@ -519,14 +521,14 @@ static int dvb_frontend_thread (void *data)
if (down_interruptible (&fe->sem))
break;
- // if we've got no parameters, just keep idling
+ /* if we've got no parameters, just keep idling */
if (fe->state & FESTATE_IDLE) {
delay = 3*HZ;
quality = 0;
continue;
}
-
- // get the frontend status
+
+ /* get the frontend status */
if (fe->state & FESTATE_RETUNE) {
s = 0;
} else {
@@ -535,53 +537,54 @@ static int dvb_frontend_thread (void *data)
dvb_frontend_add_event (fe, s);
}
}
- // if we're not tuned, and we have a lock, move to the TUNED state
+ /* 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 we're tuned, then we have determined the correct inversion
- if ((!(fe->info->caps & FE_CAN_INVERSION_AUTO)) && (fe->parameters.inversion == INVERSION_AUTO)) {
+ /* if we're tuned, then we have determined the correct inversion */
+ if ((!(fe->info->caps & FE_CAN_INVERSION_AUTO)) &&
+ (fe->parameters.inversion == INVERSION_AUTO)) {
fe->parameters.inversion = fe->inversion;
}
continue;
}
- // if we are tuned already, check we're still locked
+ /* 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);
-
- // we're tuned, and the lock is still good...
- if (s & FE_HAS_LOCK) {
+
+ /* we're tuned, and the lock is still good... */
+ if (s & FE_HAS_LOCK)
continue;
- } else {
- // if we _WERE_ tuned, but now don't have a lock, need to zigzag
+ 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;
check_wrapped = 0;
- // fallthrough
}
}
- // 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) &&
+ /* 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->info->caps & FE_CAN_RECOVER) && (fe->max_drift == 0)) {
update_delay(&quality, &delay, fe->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.
+
+ /* 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);
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 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;
@@ -590,41 +593,42 @@ static int dvb_frontend_thread (void *data)
check_wrapped = 0;
}
- // fast zigzag.
+ /* fast zigzag. */
if ((fe->state & FESTATE_SEARCHING_FAST) || (fe->state & FESTATE_RETUNE)) {
delay = fe->min_delay;
- // peform a tune
+ /* 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
+ /* 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;
continue;
}
check_wrapped = 1;
- // if we've just retuned, enter the ZIGZAG_FAST state. This ensures
- // we cannot return from an FE_SET_FRONTEND ioctl before the first frontend
- // tune occurs
+ /* if we've just retuned, enter the ZIGZAG_FAST state.
+ * 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;
wake_up_interruptible(&fe->wait_queue);
}
}
- // slow zigzag
+ /* slow zigzag */
if (fe->state & FESTATE_SEARCHING_SLOW) {
update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK);
-
- // Note: don't bother checking for wrapping; we stay in this state
- // until we get a lock
+
+ /* Note: don't bother checking for wrapping; we stay in this
+ * state until we get a lock */
dvb_frontend_autotune(fe, 0);
}
};
if (dvb_shutdown_timeout)
- dvb_frontend_internal_ioctl (&fe->frontend, FE_SLEEP, NULL);
+ dvb_frontend_internal_ioctl (&fe->frontend, FE_SLEEP, NULL);
fe->thread_pid = 0;
mb();
@@ -637,7 +641,7 @@ static int dvb_frontend_thread (void *data)
static void dvb_frontend_stop (struct dvb_frontend_data *fe)
{
unsigned long ret;
-
+
dprintk ("%s\n", __FUNCTION__);
fe->exit = 1;
@@ -743,42 +747,43 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
case FE_SET_FRONTEND:
fe->state = FESTATE_RETUNE;
-
+
memcpy (&fe->parameters, parg,
sizeof (struct dvb_frontend_parameters));
memset(&fetunesettings, 0, sizeof(struct dvb_frontend_tune_settings));
memcpy(&fetunesettings.parameters, parg,
sizeof (struct dvb_frontend_parameters));
-
- // force auto frequency inversion if requested
+
+ /* force auto frequency inversion if requested */
if (dvb_force_auto_inversion) {
fe->parameters.inversion = INVERSION_AUTO;
fetunesettings.parameters.inversion = INVERSION_AUTO;
}
- // get frontend-specific tuning settings
- if (dvb_frontend_internal_ioctl(&fe->frontend, FE_GET_TUNE_SETTINGS, &fetunesettings) == 0) {
+ /* get frontend-specific tuning settings */
+ if (dvb_frontend_internal_ioctl(&fe->frontend, FE_GET_TUNE_SETTINGS,
+ &fetunesettings) == 0) {
fe->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000;
fe->max_drift = fetunesettings.max_drift;
fe->step_size = fetunesettings.step_size;
} else {
- // default values
+ /* default values */
switch(fe->info->type) {
case FE_QPSK:
- fe->min_delay = HZ/20; // default mindelay of 50ms
+ 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;
break;
-
+
case FE_QAM:
- fe->min_delay = HZ/20; // default mindelay of 50ms
- fe->step_size = 0;
- fe->max_drift = 0; // don't want any zigzagging under DVB-C frontends
+ fe->min_delay = HZ/20;
+ fe->step_size = 0; /* no zigzag */
+ fe->max_drift = 0;
break;
-
+
case FE_OFDM:
- fe->min_delay = HZ/20; // default mindelay of 50ms
+ fe->min_delay = HZ/20;
fe->step_size = fe->info->frequency_stepsize * 2;
fe->max_drift = (fe->info->frequency_stepsize * 2) + 1;
break;
@@ -788,14 +793,14 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
fe->min_delay = (dvb_override_tune_delay * HZ) / 1000;
}
- dvb_frontend_wakeup(fe);
- dvb_frontend_add_event (fe, 0);
+ dvb_frontend_wakeup(fe);
+ dvb_frontend_add_event (fe, 0);
break;
case FE_GET_EVENT:
err = dvb_frontend_get_event (fe, parg, file->f_flags);
break;
-
+
case FE_GET_FRONTEND:
memcpy (parg, &fe->parameters,
sizeof (struct dvb_frontend_parameters));
@@ -803,17 +808,18 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
default:
err = dvb_frontend_internal_ioctl (&fe->frontend, cmd, parg);
};
-
+
up (&fe->sem);
if (err < 0)
return err;
- // Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't do it, it is done for it.
+ /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't
+ * do it, it is done for it. */
if ((cmd == FE_GET_INFO) && (err == 0)) {
struct dvb_frontend_info* tmp = (struct dvb_frontend_info*) parg;
tmp->caps |= FE_CAN_INVERSION_AUTO;
}
-
+
return err;
}
@@ -974,7 +980,7 @@ dvb_remove_frontend_ioctls (struct dvb_adapter *adapter,
{
list_del (&ioctl->list_head);
kfree (ioctl);
-
+
break;
}
}
@@ -1061,7 +1067,7 @@ dvb_remove_frontend_notifier (struct dvb_adapter *adapter,
{
list_del (&notifier->list_head);
kfree (notifier);
-
+
break;
}
}
@@ -1161,7 +1167,7 @@ dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
if ((info->caps & FE_NEEDS_BENDING) || (dvb_override_frequency_bending == 2))
do_frequency_bending = 1;
-
+
up (&frontend_mutex);
return 0;