Commit d12f9fba authored by Johannes Stezenbach's avatar Johannes Stezenbach Committed by Linus Torvalds

[PATCH] dvb: add ATSC support, misc fixes

- [DVB] dvb-core: vfree() checking cleanups, patch by Domen Puncer
- [DVB] dvb-core: fix handling of discontinuity indicator in section filter,
        bug reported by Frank Rosengart
- [DVB] dvb-core: handle PUSI in section filter correctly, patch by Emard,
        bug reported by Patrick Valsecchi
- [DVB] dvb-core: add support for ATSC/VSB frontends, patch by Taylor Jacob
- [DVB] dvb-core: removed semi-colon from a very wrong place; FE_ENABLE_HIGH_LNB_VOLTAGE
        kernel oops; thanks to Christophe Massiot
- [DVB] dvb-core: Fixed slow tuning problems, remove frequeny bending support from
        frontend code, code simplification
Signed-off-by: default avatarMichael Hunold <hunold@linuxtv.org>
Signed-off-by: default avatarJohannes Stezenbach <js@linuxtv.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fc745e5d
...@@ -247,7 +247,22 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) ...@@ -247,7 +247,22 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
} }
/* /*
** Losless Section Demux 1.4 by Emard ** Losless Section Demux 1.4.1 by Emard
** Valsecchi Patrick:
** - middle of section A (no PUSI)
** - end of section A and start of section B
** (with PUSI pointing to the start of the second section)
**
** In this case, without feed->pusi_seen you'll receive a garbage section
** consisting of the end of section A. Basically because tsfeedp
** is incemented and the use=0 condition is not raised
** when the second packet arrives.
**
** Fix:
** when demux is started, let feed->pusi_seen = 0 to
** prevent initial feeding of garbage from the end of
** previous section. When you for the first time see PUSI=1
** then set feed->pusi_seen = 1
*/ */
static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len) static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len)
{ {
...@@ -293,7 +308,12 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const ...@@ -293,7 +308,12 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const
sec->seclen = seclen; sec->seclen = seclen;
sec->crc_val = ~0; sec->crc_val = ~0;
/* dump [secbuf .. secbuf+seclen) */ /* dump [secbuf .. secbuf+seclen) */
if(feed->pusi_seen)
dvb_dmx_swfilter_section_feed(feed); dvb_dmx_swfilter_section_feed(feed);
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
else
printk("dvb_demux.c pusi not seen, discarding section data\n");
#endif
sec->secbufp += seclen; /* secbufp and secbuf moving together is */ sec->secbufp += seclen; /* secbufp and secbuf moving together is */
sec->secbuf += seclen; /* redundand but saves pointer arithmetic */ sec->secbuf += seclen; /* redundand but saves pointer arithmetic */
} }
...@@ -305,7 +325,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const ...@@ -305,7 +325,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const
static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf) static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
{ {
u8 p, count; u8 p, count;
int ccok; int ccok, dc_i = 0;
u8 cc; u8 cc;
count = payload(buf); count = payload(buf);
...@@ -316,31 +336,41 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 ...@@ -316,31 +336,41 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8
p = 188-count; /* payload start */ p = 188-count; /* payload start */
cc = buf[3] & 0x0f; cc = buf[3] & 0x0f;
ccok = ((feed->cc+1) & 0x0f) == cc ? 1 : 0; ccok = ((feed->cc + 1) & 0x0f) == cc;
feed->cc = cc; feed->cc = cc;
if(ccok == 0)
{ if (buf[3] & 0x20) {
/* adaption field present, check for discontinuity_indicator */
if ((buf[4] > 0) && (buf[5] & 0x80))
dc_i = 1;
}
if (!ccok || dc_i) {
#ifdef DVB_DEMUX_SECTION_LOSS_LOG #ifdef DVB_DEMUX_SECTION_LOSS_LOG
printk("dvb_demux.c discontinuity detected %d bytes lost\n", count); printk("dvb_demux.c discontinuity detected %d bytes lost\n", count);
/* those bytes under sume circumstances will again be reported /* those bytes under sume circumstances will again be reported
** in the following dvb_dmx_swfilter_section_new ** in the following dvb_dmx_swfilter_section_new
*/ */
#endif #endif
/* Discontinuity detected. Reset pusi_seen = 0 to
** stop feeding of suspicious data until next PUSI=1 arrives
*/
feed->pusi_seen = 0;
dvb_dmx_swfilter_section_new(feed); dvb_dmx_swfilter_section_new(feed);
return 0; return 0;
} }
if(buf[1] & 0x40) if (buf[1] & 0x40) {
{
// PUSI=1 (is set), section boundary is here // PUSI=1 (is set), section boundary is here
if(count > 1 && buf[p] < count) if (count > 1 && buf[p] < count) {
{
const u8 *before = buf+p+1; const u8 *before = buf+p+1;
u8 before_len = buf[p]; u8 before_len = buf[p];
const u8 *after = before+before_len; const u8 *after = before+before_len;
u8 after_len = count-1-before_len; u8 after_len = count-1-before_len;
dvb_dmx_swfilter_section_copy_dump(feed, before, before_len); dvb_dmx_swfilter_section_copy_dump(feed, before, before_len);
/* before start of new section, set pusi_seen = 1 */
feed->pusi_seen = 1;
dvb_dmx_swfilter_section_new(feed); dvb_dmx_swfilter_section_new(feed);
dvb_dmx_swfilter_section_copy_dump(feed, after, after_len); dvb_dmx_swfilter_section_copy_dump(feed, after, after_len);
} }
...@@ -349,9 +379,7 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 ...@@ -349,9 +379,7 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8
if(count > 0) if(count > 0)
printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count);
#endif #endif
} } else {
else
{
// PUSI=0 (is not set), no section boundary // PUSI=0 (is not set), no section boundary
const u8 *entire = buf+p; const u8 *entire = buf+p;
u8 entire_len = count; u8 entire_len = count;
...@@ -784,10 +812,8 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ ...@@ -784,10 +812,8 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_
} }
#ifndef NOBUFS #ifndef NOBUFS
if (feed->buffer) {
vfree(feed->buffer); vfree(feed->buffer);
feed->buffer=0; feed->buffer=0;
}
#endif #endif
feed->state = DMX_STATE_FREE; feed->state = DMX_STATE_FREE;
...@@ -1055,10 +1081,8 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, ...@@ -1055,10 +1081,8 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
return -EINVAL; return -EINVAL;
} }
#ifndef NOBUFS #ifndef NOBUFS
if (dvbdmxfeed->buffer) {
vfree(dvbdmxfeed->buffer); vfree(dvbdmxfeed->buffer);
dvbdmxfeed->buffer=0; dvbdmxfeed->buffer=0;
}
#endif #endif
dvbdmxfeed->state=DMX_STATE_FREE; dvbdmxfeed->state=DMX_STATE_FREE;
...@@ -1269,9 +1293,7 @@ int dvb_dmx_release(struct dvb_demux *dvbdemux) ...@@ -1269,9 +1293,7 @@ int dvb_dmx_release(struct dvb_demux *dvbdemux)
struct dmx_demux *dmx = &dvbdemux->dmx; struct dmx_demux *dmx = &dvbdemux->dmx;
dmx_unregister_demux(dmx); dmx_unregister_demux(dmx);
if (dvbdemux->filter)
vfree(dvbdemux->filter); vfree(dvbdemux->filter);
if (dvbdemux->feed)
vfree(dvbdemux->feed); vfree(dvbdemux->feed);
return 0; return 0;
} }
......
...@@ -93,6 +93,7 @@ struct dvb_demux_feed { ...@@ -93,6 +93,7 @@ struct dvb_demux_feed {
enum dmx_ts_pes pes_type; enum dmx_ts_pes pes_type;
int cc; int cc;
int pusi_seen; /* prevents feeding of garbage from previous section */
u16 peslen; u16 peslen;
......
...@@ -89,9 +89,36 @@ MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB vola ...@@ -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); 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) 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; struct dvb_frontend_event *e;
int wp; int wp;
...@@ -109,7 +136,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) ...@@ -109,7 +136,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
e = &events->events[events->eventw]; e = &events->events[events->eventw];
memcpy (&e->parameters, &fe->parameters, memcpy (&e->parameters, &fepriv->parameters,
sizeof (struct dvb_frontend_parameters)); sizeof (struct dvb_frontend_parameters));
if (status & FE_HAS_LOCK) if (status & FE_HAS_LOCK)
...@@ -128,7 +155,8 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) ...@@ -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, static int dvb_frontend_get_event(struct dvb_frontend *fe,
struct dvb_frontend_event *event, int flags) 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__); dprintk ("%s\n", __FUNCTION__);
...@@ -143,12 +171,12 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe, ...@@ -143,12 +171,12 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe,
if (flags & O_NONBLOCK) if (flags & O_NONBLOCK)
return -EWOULDBLOCK; return -EWOULDBLOCK;
up(&fe->sem); up(&fepriv->sem);
ret = wait_event_interruptible (events->wait_queue, ret = wait_event_interruptible (events->wait_queue,
events->eventw != events->eventr); events->eventw != events->eventr);
if (down_interruptible (&fe->sem)) if (down_interruptible (&fepriv->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
if (ret < 0) if (ret < 0)
...@@ -206,27 +234,28 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped) ...@@ -206,27 +234,28 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)
{ {
int autoinversion; int autoinversion;
int ready = 0; int ready = 0;
int original_inversion = fe->parameters.inversion; struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
u32 original_frequency = fe->parameters.frequency; int original_inversion = fepriv->parameters.inversion;
u32 original_frequency = fepriv->parameters.frequency;
/* are we using autoinversion? */ /* are we using autoinversion? */
autoinversion = ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) && autoinversion = ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&
(fe->parameters.inversion == INVERSION_AUTO)); (fepriv->parameters.inversion == INVERSION_AUTO));
/* setup parameters correctly */ /* setup parameters correctly */
while(!ready) { while(!ready) {
/* calculate the lnb_drift */ /* 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 */ /* wrap the auto_step if we've exceeded the maximum drift */
if (fe->lnb_drift > fe->max_drift) { if (fepriv->lnb_drift > fepriv->max_drift) {
fe->auto_step = 0; fepriv->auto_step = 0;
fe->auto_sub_step = 0; fepriv->auto_sub_step = 0;
fe->lnb_drift = 0; fepriv->lnb_drift = 0;
} }
/* perform inversion and +/- zigzag */ /* perform inversion and +/- zigzag */
switch(fe->auto_sub_step) { switch(fepriv->auto_sub_step) {
case 0: case 0:
/* try with the current inversion and current drift setting */ /* try with the current inversion and current drift setting */
ready = 1; ready = 1;
...@@ -235,68 +264,70 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped) ...@@ -235,68 +264,70 @@ static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)
case 1: case 1:
if (!autoinversion) break; 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; ready = 1;
break; break;
case 2: 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; ready = 1;
break; break;
case 3: case 3:
if (fe->lnb_drift == 0) break; if (fepriv->lnb_drift == 0) break;
if (!autoinversion) break; if (!autoinversion) break;
fe->inversion = (fe->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF; fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
fe->lnb_drift = -fe->lnb_drift; fepriv->lnb_drift = -fepriv->lnb_drift;
ready = 1; ready = 1;
break; break;
default: default:
fe->auto_step++; fepriv->auto_step++;
fe->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */ fepriv->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */
break; break;
} }
if (!ready) fe->auto_sub_step++; if (!ready) fepriv->auto_sub_step++;
} }
/* if this attempt would hit where we started, indicate a complete /* if this attempt would hit where we started, indicate a complete
* iteration has occurred */ * iteration has occurred */
if ((fe->auto_step == fe->started_auto_step) && if ((fepriv->auto_step == fepriv->started_auto_step) &&
(fe->auto_sub_step == 0) && check_wrapped) { (fepriv->auto_sub_step == 0) && check_wrapped) {
return 1; return 1;
} }
dprintk("%s: drift:%i inversion:%i auto_step:%i " dprintk("%s: drift:%i inversion:%i auto_step:%i "
"auto_sub_step:%i started_auto_step:%i\n", "auto_sub_step:%i started_auto_step:%i\n",
__FUNCTION__, fe->lnb_drift, fe->inversion, __FUNCTION__, fepriv->lnb_drift, fepriv->inversion,
fe->auto_step, fe->auto_sub_step, fe->started_auto_step); fepriv->auto_step, fepriv->auto_sub_step, fepriv->started_auto_step);
/* set the frontend itself */ /* set the frontend itself */
fe->parameters.frequency += fe->lnb_drift; fepriv->parameters.frequency += fepriv->lnb_drift;
if (autoinversion) if (autoinversion)
fe->parameters.inversion = fe->inversion; fepriv->parameters.inversion = fepriv->inversion;
if (fe->ops->set_frontend) if (fe->ops->set_frontend)
fe->ops->set_frontend(fe, &fe->parameters); fe->ops->set_frontend(fe, &fepriv->parameters);
fe->parameters.frequency = original_frequency; fepriv->parameters.frequency = original_frequency;
fe->parameters.inversion = original_inversion; fepriv->parameters.inversion = original_inversion;
fe->auto_sub_step++; fepriv->auto_sub_step++;
return 0; return 0;
} }
static int dvb_frontend_is_exiting(struct dvb_frontend *fe) 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; return 1;
if (fe->dvbdev->writers == 1) if (fepriv->dvbdev->writers == 1)
if (jiffies - fe->release_jiffies > dvb_shutdown_timeout * HZ) if (jiffies - fepriv->release_jiffies > dvb_shutdown_timeout * HZ)
return 1; return 1;
return 0; return 0;
...@@ -304,8 +335,10 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe) ...@@ -304,8 +335,10 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
static int dvb_frontend_should_wakeup(struct dvb_frontend *fe) static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
{ {
if (fe->wakeup) { struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
fe->wakeup = 0;
if (fepriv->wakeup) {
fepriv->wakeup = 0;
return 1; return 1;
} }
return dvb_frontend_is_exiting(fe); return dvb_frontend_is_exiting(fe);
...@@ -313,8 +346,10 @@ static int dvb_frontend_should_wakeup(struct dvb_frontend *fe) ...@@ -313,8 +346,10 @@ static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
static void dvb_frontend_wakeup(struct dvb_frontend *fe) static void dvb_frontend_wakeup(struct dvb_frontend *fe)
{ {
fe->wakeup = 1; struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
wake_up_interruptible(&fe->wait_queue);
fepriv->wakeup = 1;
wake_up_interruptible(&fepriv->wait_queue);
} }
/* /*
...@@ -323,6 +358,7 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe) ...@@ -323,6 +358,7 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)
static int dvb_frontend_thread (void *data) static int dvb_frontend_thread (void *data)
{ {
struct dvb_frontend *fe = (struct dvb_frontend *) data; struct dvb_frontend *fe = (struct dvb_frontend *) data;
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
unsigned long timeout; unsigned long timeout;
char name [15]; char name [15];
int quality = 0, delay = 3*HZ; int quality = 0, delay = 3*HZ;
...@@ -338,14 +374,14 @@ static int dvb_frontend_thread (void *data) ...@@ -338,14 +374,14 @@ static int dvb_frontend_thread (void *data)
sigfillset (&current->blocked); sigfillset (&current->blocked);
unlock_kernel (); unlock_kernel ();
fe->status = 0; fepriv->status = 0;
dvb_frontend_init (fe); dvb_frontend_init (fe);
fe->wakeup = 0; fepriv->wakeup = 0;
while (1) { 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), dvb_frontend_should_wakeup(fe),
delay); delay);
if (0 != dvb_frontend_is_exiting (fe)) { if (0 != dvb_frontend_is_exiting (fe)) {
...@@ -356,44 +392,43 @@ static int dvb_frontend_thread (void *data) ...@@ -356,44 +392,43 @@ static int dvb_frontend_thread (void *data)
if (current->flags & PF_FREEZE) if (current->flags & PF_FREEZE)
refrigerator(PF_FREEZE); refrigerator(PF_FREEZE);
if (down_interruptible (&fe->sem)) if (down_interruptible(&fepriv->sem))
break; break;
/* if we've got no parameters, just keep idling */ /* if we've got no parameters, just keep idling */
if (fe->state & FESTATE_IDLE) { if (fepriv->state & FESTATE_IDLE) {
delay = 3*HZ; delay = 3*HZ;
quality = 0; quality = 0;
continue; continue;
} }
retune:
/* get the frontend status */ /* get the frontend status */
if (fe->state & FESTATE_RETUNE) { if (fepriv->state & FESTATE_RETUNE) {
s = 0; s = 0;
} else { } else {
if (fe->ops->read_status) if (fe->ops->read_status)
fe->ops->read_status(fe, &s); fe->ops->read_status(fe, &s);
if (s != fe->status) { if (s != fepriv->status) {
dvb_frontend_add_event (fe, s); 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 we're not tuned, and we have a lock, move to the TUNED state */
if ((fe->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) { if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {
update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK); update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
fe->state = FESTATE_TUNED; fepriv->state = FESTATE_TUNED;
/* if we're tuned, then we have determined the correct inversion */ /* if we're tuned, then we have determined the correct inversion */
if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) && if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&
(fe->parameters.inversion == INVERSION_AUTO)) { (fepriv->parameters.inversion == INVERSION_AUTO)) {
fe->parameters.inversion = fe->inversion; fepriv->parameters.inversion = fepriv->inversion;
} }
continue; 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) { if (fepriv->state & FESTATE_TUNED) {
update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK); update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
/* we're tuned, and the lock is still good... */ /* we're tuned, and the lock is still good... */
if (s & FE_HAS_LOCK) if (s & FE_HAS_LOCK)
...@@ -401,49 +436,49 @@ static int dvb_frontend_thread (void *data) ...@@ -401,49 +436,49 @@ static int dvb_frontend_thread (void *data)
else { else {
/* if we _WERE_ tuned, but now don't have a lock, /* if we _WERE_ tuned, but now don't have a lock,
* need to zigzag */ * need to zigzag */
fe->state = FESTATE_ZIGZAG_FAST; fepriv->state = FESTATE_ZIGZAG_FAST;
fe->started_auto_step = fe->auto_step; fepriv->started_auto_step = fepriv->auto_step;
check_wrapped = 0; check_wrapped = 0;
} }
} }
/* don't actually do anything if we're in the LOSTLOCK state, /* 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 */ * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */
if ((fe->state & FESTATE_LOSTLOCK) && if ((fepriv->state & FESTATE_LOSTLOCK) &&
(fe->ops->info.caps & FE_CAN_RECOVER) && (fe->max_drift == 0)) { (fe->ops->info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) {
update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK); update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
continue; continue;
} }
/* don't do anything if we're in the DISEQC state, since this /* don't do anything if we're in the DISEQC state, since this
* might be someone with a motorized dish controlled by DISEQC. * 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 its actually a re-tune, there will be a SET_FRONTEND soon enough. */
if (fe->state & FESTATE_DISEQC) { if (fepriv->state & FESTATE_DISEQC) {
update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK); update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
continue; continue;
} }
/* if we're in the RETUNE state, set everything up for a brand /* if we're in the RETUNE state, set everything up for a brand
* new scan, keeping the current inversion setting, as the next * new scan, keeping the current inversion setting, as the next
* tune is _very_ likely to require the same */ * tune is _very_ likely to require the same */
if (fe->state & FESTATE_RETUNE) { if (fepriv->state & FESTATE_RETUNE) {
fe->lnb_drift = 0; fepriv->lnb_drift = 0;
fe->auto_step = 0; fepriv->auto_step = 0;
fe->auto_sub_step = 0; fepriv->auto_sub_step = 0;
fe->started_auto_step = 0; fepriv->started_auto_step = 0;
check_wrapped = 0; check_wrapped = 0;
} }
/* fast zigzag. */ /* fast zigzag. */
if ((fe->state & FESTATE_SEARCHING_FAST) || (fe->state & FESTATE_RETUNE)) { if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) {
delay = fe->min_delay; delay = fepriv->min_delay;
/* peform a tune */ /* peform a tune */
if (dvb_frontend_autotune(fe, check_wrapped)) { if (dvb_frontend_autotune(fe, check_wrapped)) {
/* OK, if we've run out of trials at the fast speed. /* OK, if we've run out of trials at the fast speed.
* Drop back to slow for the _next_ attempt */ * Drop back to slow for the _next_ attempt */
fe->state = FESTATE_SEARCHING_SLOW; fepriv->state = FESTATE_SEARCHING_SLOW;
fe->started_auto_step = fe->auto_step; fepriv->started_auto_step = fepriv->auto_step;
continue; continue;
} }
check_wrapped = 1; check_wrapped = 1;
...@@ -452,15 +487,14 @@ static int dvb_frontend_thread (void *data) ...@@ -452,15 +487,14 @@ static int dvb_frontend_thread (void *data)
* This ensures we cannot return from an * This ensures we cannot return from an
* FE_SET_FRONTEND ioctl before the first frontend tune * FE_SET_FRONTEND ioctl before the first frontend tune
* occurs */ * occurs */
if (fe->state & FESTATE_RETUNE) { if (fepriv->state & FESTATE_RETUNE) {
fe->state = FESTATE_TUNING_FAST; fepriv->state = FESTATE_TUNING_FAST;
goto retune;
} }
} }
/* slow zigzag */ /* slow zigzag */
if (fe->state & FESTATE_SEARCHING_SLOW) { if (fepriv->state & FESTATE_SEARCHING_SLOW) {
update_delay(&quality, &delay, fe->min_delay, s & FE_HAS_LOCK); update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);
/* Note: don't bother checking for wrapping; we stay in this /* Note: don't bother checking for wrapping; we stay in this
* state until we get a lock */ * state until we get a lock */
...@@ -476,7 +510,7 @@ static int dvb_frontend_thread (void *data) ...@@ -476,7 +510,7 @@ static int dvb_frontend_thread (void *data)
fe->ops->sleep(fe); fe->ops->sleep(fe);
} }
fe->thread_pid = 0; fepriv->thread_pid = 0;
mb(); mb();
dvb_frontend_wakeup(fe); dvb_frontend_wakeup(fe);
...@@ -486,21 +520,22 @@ static int dvb_frontend_thread (void *data) ...@@ -486,21 +520,22 @@ static int dvb_frontend_thread (void *data)
static void dvb_frontend_stop(struct dvb_frontend *fe) static void dvb_frontend_stop(struct dvb_frontend *fe)
{ {
unsigned long ret; unsigned long ret;
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
fe->exit = 1; fepriv->exit = 1;
mb(); mb();
if (!fe->thread_pid) if (!fepriv->thread_pid)
return; return;
/* check if the thread is really alive */ /* 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", 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 */ /* make sure the mutex was not held by the thread */
init_MUTEX (&fe->sem); init_MUTEX (&fepriv->sem);
return; return;
} }
...@@ -508,27 +543,28 @@ static void dvb_frontend_stop(struct dvb_frontend *fe) ...@@ -508,27 +543,28 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
dvb_frontend_wakeup(fe); dvb_frontend_wakeup(fe);
/* wait until the frontend thread has exited */ /* 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) { if (-ERESTARTSYS != ret) {
fe->state = FESTATE_IDLE; fepriv->state = FESTATE_IDLE;
return; return;
} }
fe->state = FESTATE_IDLE; fepriv->state = FESTATE_IDLE;
/* paranoia check in case a signal arrived */ /* 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", 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) static int dvb_frontend_start(struct dvb_frontend *fe)
{ {
int ret; int ret;
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
if (fe->thread_pid) { if (fepriv->thread_pid) {
if (!fe->exit) if (!fepriv->exit)
return 0; return 0;
else else
dvb_frontend_stop (fe); dvb_frontend_stop (fe);
...@@ -536,21 +572,22 @@ static int dvb_frontend_start(struct dvb_frontend *fe) ...@@ -536,21 +572,22 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
if (signal_pending(current)) if (signal_pending(current))
return -EINTR; return -EINTR;
if (down_interruptible (&fe->sem)) if (down_interruptible (&fepriv->sem))
return -EINTR; return -EINTR;
fe->state = FESTATE_IDLE; fepriv->state = FESTATE_IDLE;
fe->exit = 0; fepriv->exit = 0;
fe->thread_pid = 0; fepriv->thread_pid = 0;
mb(); mb();
ret = kernel_thread (dvb_frontend_thread, fe, 0); ret = kernel_thread (dvb_frontend_thread, fe, 0);
if (ret < 0) { if (ret < 0) {
printk("dvb_frontend_start: failed to start kernel_thread (%d)\n", ret); printk("dvb_frontend_start: failed to start kernel_thread (%d)\n", ret);
up(&fe->sem); up(&fepriv->sem);
return ret; return ret;
} }
fe->thread_pid = ret; fepriv->thread_pid = ret;
return 0; return 0;
} }
...@@ -561,11 +598,12 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file, ...@@ -561,11 +598,12 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
{ {
struct dvb_device *dvbdev = file->private_data; struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv; struct dvb_frontend *fe = dvbdev->priv;
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
if (!fe || fe->exit) if (!fe || fepriv->exit)
return -ENODEV; return -ENODEV;
if ((file->f_flags & O_ACCMODE) == O_RDONLY && if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
...@@ -573,7 +611,7 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file, ...@@ -573,7 +611,7 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
cmd == FE_DISEQC_RECV_SLAVE_REPLY)) cmd == FE_DISEQC_RECV_SLAVE_REPLY))
return -EPERM; return -EPERM;
if (down_interruptible (&fe->sem)) if (down_interruptible (&fepriv->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
switch (cmd) { switch (cmd) {
...@@ -617,48 +655,48 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file, ...@@ -617,48 +655,48 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
case FE_DISEQC_RESET_OVERLOAD: case FE_DISEQC_RESET_OVERLOAD:
if (fe->ops->diseqc_reset_overload) { if (fe->ops->diseqc_reset_overload) {
err = fe->ops->diseqc_reset_overload(fe); err = fe->ops->diseqc_reset_overload(fe);
fe->state = FESTATE_DISEQC; fepriv->state = FESTATE_DISEQC;
fe->status = 0; fepriv->status = 0;
} }
break; break;
case FE_DISEQC_SEND_MASTER_CMD: case FE_DISEQC_SEND_MASTER_CMD:
if (fe->ops->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); err = fe->ops->diseqc_send_master_cmd(fe, (struct dvb_diseqc_master_cmd*) parg);
fe->state = FESTATE_DISEQC; fepriv->state = FESTATE_DISEQC;
fe->status = 0; fepriv->status = 0;
} }
break; break;
case FE_DISEQC_SEND_BURST: case FE_DISEQC_SEND_BURST:
if (fe->ops->diseqc_send_burst) { if (fe->ops->diseqc_send_burst) {
err = fe->ops->diseqc_send_burst(fe, (fe_sec_mini_cmd_t) parg); err = fe->ops->diseqc_send_burst(fe, (fe_sec_mini_cmd_t) parg);
fe->state = FESTATE_DISEQC; fepriv->state = FESTATE_DISEQC;
fe->status = 0; fepriv->status = 0;
} }
break; break;
case FE_SET_TONE: case FE_SET_TONE:
if (fe->ops->set_tone) { if (fe->ops->set_tone) {
err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg); err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg);
fe->state = FESTATE_DISEQC; fepriv->state = FESTATE_DISEQC;
fe->status = 0; fepriv->status = 0;
} }
break; break;
case FE_SET_VOLTAGE: case FE_SET_VOLTAGE:
if (fe->ops->set_voltage) { if (fe->ops->set_voltage) {
err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg); err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg);
fe->state = FESTATE_DISEQC; fepriv->state = FESTATE_DISEQC;
fe->status = 0; fepriv->status = 0;
} }
break; break;
case FE_DISHNETWORK_SEND_LEGACY_CMD: case FE_DISHNETWORK_SEND_LEGACY_CMD:
if (fe->ops->dishnetwork_send_legacy_command) { if (fe->ops->dishnetwork_send_legacy_command) {
err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned int) parg); err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned int) parg);
fe->state = FESTATE_DISEQC; fepriv->state = FESTATE_DISEQC;
fe->status = 0; fepriv->status = 0;
} }
break; break;
...@@ -668,14 +706,14 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file, ...@@ -668,14 +706,14 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
break; break;
case FE_ENABLE_HIGH_LNB_VOLTAGE: case FE_ENABLE_HIGH_LNB_VOLTAGE:
if (fe->ops->enable_high_lnb_voltage); if (fe->ops->enable_high_lnb_voltage)
err = fe->ops->enable_high_lnb_voltage(fe, (int) parg); err = fe->ops->enable_high_lnb_voltage(fe, (int) parg);
break; break;
case FE_SET_FRONTEND: { case FE_SET_FRONTEND: {
struct dvb_frontend_tune_settings fetunesettings; struct dvb_frontend_tune_settings fetunesettings;
memcpy (&fe->parameters, parg, memcpy (&fepriv->parameters, parg,
sizeof (struct dvb_frontend_parameters)); sizeof (struct dvb_frontend_parameters));
memset(&fetunesettings, 0, sizeof(struct dvb_frontend_tune_settings)); memset(&fetunesettings, 0, sizeof(struct dvb_frontend_tune_settings));
...@@ -684,41 +722,41 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file, ...@@ -684,41 +722,41 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
/* force auto frequency inversion if requested */ /* force auto frequency inversion if requested */
if (dvb_force_auto_inversion) { if (dvb_force_auto_inversion) {
fe->parameters.inversion = INVERSION_AUTO; fepriv->parameters.inversion = INVERSION_AUTO;
fetunesettings.parameters.inversion = INVERSION_AUTO; fetunesettings.parameters.inversion = INVERSION_AUTO;
} }
if (fe->ops->info.type == FE_OFDM) { if (fe->ops->info.type == FE_OFDM) {
/* without hierachical coding code_rate_LP is irrelevant, /* without hierachical coding code_rate_LP is irrelevant,
* so we tolerate the otherwise invalid FEC_NONE setting */ * so we tolerate the otherwise invalid FEC_NONE setting */
if (fe->parameters.u.ofdm.hierarchy_information == HIERARCHY_NONE && if (fepriv->parameters.u.ofdm.hierarchy_information == HIERARCHY_NONE &&
fe->parameters.u.ofdm.code_rate_LP == FEC_NONE) fepriv->parameters.u.ofdm.code_rate_LP == FEC_NONE)
fe->parameters.u.ofdm.code_rate_LP = FEC_AUTO; fepriv->parameters.u.ofdm.code_rate_LP = FEC_AUTO;
} }
/* get frontend-specific tuning settings */ /* get frontend-specific tuning settings */
if (fe->ops->get_tune_settings && (fe->ops->get_tune_settings(fe, &fetunesettings) == 0)) { if (fe->ops->get_tune_settings && (fe->ops->get_tune_settings(fe, &fetunesettings) == 0)) {
fe->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000; fepriv->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000;
fe->max_drift = fetunesettings.max_drift; fepriv->max_drift = fetunesettings.max_drift;
fe->step_size = fetunesettings.step_size; fepriv->step_size = fetunesettings.step_size;
} else { } else {
/* default values */ /* default values */
switch(fe->ops->info.type) { switch(fe->ops->info.type) {
case FE_QPSK: case FE_QPSK:
fe->min_delay = HZ/20; fepriv->min_delay = HZ/20;
fe->step_size = fe->parameters.u.qpsk.symbol_rate / 16000; fepriv->step_size = fepriv->parameters.u.qpsk.symbol_rate / 16000;
fe->max_drift = fe->parameters.u.qpsk.symbol_rate / 2000; fepriv->max_drift = fepriv->parameters.u.qpsk.symbol_rate / 2000;
break; break;
case FE_QAM: case FE_QAM:
fe->min_delay = HZ/20; fepriv->min_delay = HZ/20;
fe->step_size = 0; /* no zigzag */ fepriv->step_size = 0; /* no zigzag */
fe->max_drift = 0; fepriv->max_drift = 0;
break; break;
case FE_OFDM: case FE_OFDM:
fe->min_delay = HZ/20; fepriv->min_delay = HZ/20;
fe->step_size = fe->ops->info.frequency_stepsize * 2; fepriv->step_size = fe->ops->info.frequency_stepsize * 2;
fe->max_drift = (fe->ops->info.frequency_stepsize * 2) + 1; fepriv->max_drift = (fe->ops->info.frequency_stepsize * 2) + 1;
break; break;
case FE_ATSC: case FE_ATSC:
printk("dvb-core: FE_ATSC not handled yet.\n"); printk("dvb-core: FE_ATSC not handled yet.\n");
...@@ -726,12 +764,12 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file, ...@@ -726,12 +764,12 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
} }
} }
if (dvb_override_tune_delay > 0) 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_wakeup(fe);
dvb_frontend_add_event (fe, 0); dvb_frontend_add_event (fe, 0);
fe->status = 0; fepriv->status = 0;
err = 0; err = 0;
break; break;
} }
...@@ -742,13 +780,13 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file, ...@@ -742,13 +780,13 @@ static int dvb_frontend_ioctl (struct inode *inode, struct file *file,
case FE_GET_FRONTEND: case FE_GET_FRONTEND:
if (fe->ops->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); err = fe->ops->get_frontend(fe, (struct dvb_frontend_parameters*) parg);
} }
break; break;
}; };
up (&fe->sem); up (&fepriv->sem);
return err; return err;
} }
...@@ -757,12 +795,13 @@ static unsigned int dvb_frontend_poll (struct file *file, struct poll_table_stru ...@@ -757,12 +795,13 @@ static unsigned int dvb_frontend_poll (struct file *file, struct poll_table_stru
{ {
struct dvb_device *dvbdev = file->private_data; struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv; struct dvb_frontend *fe = dvbdev->priv;
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__); 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 (POLLIN | POLLRDNORM | POLLPRI);
return 0; return 0;
...@@ -773,6 +812,7 @@ static int dvb_frontend_open (struct inode *inode, struct file *file) ...@@ -773,6 +812,7 @@ static int dvb_frontend_open (struct inode *inode, struct file *file)
{ {
struct dvb_device *dvbdev = file->private_data; struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv; struct dvb_frontend *fe = dvbdev->priv;
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
int ret; int ret;
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
...@@ -786,7 +826,7 @@ static int dvb_frontend_open (struct inode *inode, struct file *file) ...@@ -786,7 +826,7 @@ static int dvb_frontend_open (struct inode *inode, struct file *file)
dvb_generic_release (inode, file); dvb_generic_release (inode, file);
/* empty event queue */ /* empty event queue */
fe->events.eventr = fe->events.eventw = 0; fepriv->events.eventr = fepriv->events.eventw = 0;
} }
return ret; return ret;
...@@ -797,11 +837,12 @@ static int dvb_frontend_release (struct inode *inode, struct file *file) ...@@ -797,11 +837,12 @@ static int dvb_frontend_release (struct inode *inode, struct file *file)
{ {
struct dvb_device *dvbdev = file->private_data; struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend *fe = dvbdev->priv; struct dvb_frontend *fe = dvbdev->priv;
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
if ((file->f_flags & O_ACCMODE) != O_RDONLY) if ((file->f_flags & O_ACCMODE) != O_RDONLY)
fe->release_jiffies = jiffies; fepriv->release_jiffies = jiffies;
return dvb_generic_release (inode, file); return dvb_generic_release (inode, file);
} }
...@@ -818,6 +859,7 @@ static struct file_operations dvb_frontend_fops = { ...@@ -818,6 +859,7 @@ static struct file_operations dvb_frontend_fops = {
int dvb_register_frontend(struct dvb_adapter* dvb, int dvb_register_frontend(struct dvb_adapter* dvb,
struct dvb_frontend* fe) struct dvb_frontend* fe)
{ {
struct dvb_frontend_private *fepriv;
static const struct dvb_device dvbdev_template = { static const struct dvb_device dvbdev_template = {
.users = ~0, .users = ~0,
.writers = 1, .writers = 1,
...@@ -831,20 +873,26 @@ int dvb_register_frontend(struct dvb_adapter* dvb, ...@@ -831,20 +873,26 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
if (down_interruptible (&frontend_mutex)) if (down_interruptible (&frontend_mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
init_MUTEX (&fe->sem); fe->frontend_priv = kmalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL);
init_waitqueue_head (&fe->wait_queue); if (fe->frontend_priv == NULL) {
init_waitqueue_head (&fe->events.wait_queue); up(&frontend_mutex);
init_MUTEX (&fe->events.sem); return -ENOMEM;
fe->events.eventw = fe->events.eventr = 0; }
fe->events.overflow = 0; 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->dvb = dvb;
fe->inversion = INVERSION_OFF; fepriv->inversion = INVERSION_OFF;
printk ("DVB: registering frontend %i (%s)...\n", printk ("DVB: registering frontend %i (%s)...\n",
fe->dvb->num, fe->dvb->num,
fe->ops->info.name); 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); fe, DVB_DEVICE_FRONTEND);
up (&frontend_mutex); up (&frontend_mutex);
...@@ -854,15 +902,18 @@ EXPORT_SYMBOL(dvb_register_frontend); ...@@ -854,15 +902,18 @@ EXPORT_SYMBOL(dvb_register_frontend);
int dvb_unregister_frontend(struct dvb_frontend* fe) int dvb_unregister_frontend(struct dvb_frontend* fe)
{ {
struct dvb_frontend_private *fepriv = (struct dvb_frontend_private*) fe->frontend_priv;
dprintk ("%s\n", __FUNCTION__); dprintk ("%s\n", __FUNCTION__);
down (&frontend_mutex); down (&frontend_mutex);
dvb_unregister_device (fe->dvbdev); dvb_unregister_device (fepriv->dvbdev);
dvb_frontend_stop (fe); dvb_frontend_stop (fe);
if (fe->ops->release) if (fe->ops->release)
fe->ops->release(fe); fe->ops->release(fe);
else else
printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops->info.name); 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); up (&frontend_mutex);
return 0; return 0;
} }
......
...@@ -115,28 +115,7 @@ struct dvb_frontend { ...@@ -115,28 +115,7 @@ struct dvb_frontend {
struct dvb_frontend_ops* ops; struct dvb_frontend_ops* ops;
struct dvb_adapter *dvb; struct dvb_adapter *dvb;
void* demodulator_priv; void* demodulator_priv;
void* frontend_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;
}; };
extern int dvb_register_frontend(struct dvb_adapter* dvb, extern int dvb_register_frontend(struct dvb_adapter* dvb,
......
...@@ -123,7 +123,6 @@ static void hexdump( const unsigned char *buf, unsigned short len ) ...@@ -123,7 +123,6 @@ static void hexdump( const unsigned char *buf, unsigned short len )
struct dvb_net_priv { struct dvb_net_priv {
int in_use; int in_use;
struct net_device_stats stats; struct net_device_stats stats;
char name[6];
u16 pid; u16 pid;
struct dvb_net *host; struct dvb_net *host;
struct dmx_demux *demux; struct dmx_demux *demux;
...@@ -1165,12 +1164,17 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype) ...@@ -1165,12 +1164,17 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
if ((if_num = get_if(dvbnet)) < 0) if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL; return -EINVAL;
net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", dvb_net_setup);
dvb_net_setup);
if (!net) if (!net)
return -ENOMEM; return -ENOMEM;
sprintf(net->name, "dvb%d_%d", dvbnet->dvbdev->adapter->num, if_num); if (dvbnet->dvbdev->id)
snprintf(net->name, IFNAMSIZ, "dvb%d%u%d",
dvbnet->dvbdev->adapter->num, dvbnet->dvbdev->id, if_num);
else
/* compatibility fix to keep dvb0_0 format */
snprintf(net->name, IFNAMSIZ, "dvb%d_%d",
dvbnet->dvbdev->adapter->num, if_num);
net->addr_len = 6; net->addr_len = 6;
memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6); memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
...@@ -1196,6 +1200,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype) ...@@ -1196,6 +1200,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
free_netdev(net); free_netdev(net);
return result; return result;
} }
printk("dvb_net: created network interface %s\n", net->name);
return if_num; return if_num;
} }
...@@ -1214,6 +1219,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num) ...@@ -1214,6 +1219,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num)
dvb_net_stop(net); dvb_net_stop(net);
flush_scheduled_work(); flush_scheduled_work();
printk("dvb_net: removed network interface %s\n", net->name);
unregister_netdev(net); unregister_netdev(net);
dvbnet->state[num]=0; dvbnet->state[num]=0;
dvbnet->device[num] = NULL; dvbnet->device[num] = NULL;
......
...@@ -756,7 +756,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec) ...@@ -756,7 +756,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec)
if (!dec->iso_stream_count) { if (!dec->iso_stream_count) {
for (i = 0; i < ISO_BUF_COUNT; i++) for (i = 0; i < ISO_BUF_COUNT; i++)
usb_unlink_urb(dec->iso_urb[i]); usb_kill_urb(dec->iso_urb[i]);
} }
up(&dec->iso_sem); up(&dec->iso_sem);
...@@ -821,7 +821,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) ...@@ -821,7 +821,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
"error %d\n", __FUNCTION__, i, result); "error %d\n", __FUNCTION__, i, result);
while (i) { while (i) {
usb_unlink_urb(dec->iso_urb[i - 1]); usb_kill_urb(dec->iso_urb[i - 1]);
i--; i--;
} }
...@@ -1379,7 +1379,7 @@ static void ttusb_dec_exit_usb(struct ttusb_dec *dec) ...@@ -1379,7 +1379,7 @@ static void ttusb_dec_exit_usb(struct ttusb_dec *dec)
dec->iso_stream_count = 0; dec->iso_stream_count = 0;
for (i = 0; i < ISO_BUF_COUNT; i++) for (i = 0; i < ISO_BUF_COUNT; i++)
usb_unlink_urb(dec->iso_urb[i]); usb_kill_urb(dec->iso_urb[i]);
ttusb_dec_free_iso_urbs(dec); ttusb_dec_free_iso_urbs(dec);
} }
......
...@@ -158,10 +158,11 @@ typedef enum fe_modulation { ...@@ -158,10 +158,11 @@ typedef enum fe_modulation {
QAM_64, QAM_64,
QAM_128, QAM_128,
QAM_256, QAM_256,
QAM_AUTO QAM_AUTO,
VSB_8,
VSB_16
} fe_modulation_t; } fe_modulation_t;
typedef enum fe_transmit_mode { typedef enum fe_transmit_mode {
TRANSMISSION_MODE_2K, TRANSMISSION_MODE_2K,
TRANSMISSION_MODE_8K, TRANSMISSION_MODE_8K,
...@@ -206,6 +207,9 @@ struct dvb_qam_parameters { ...@@ -206,6 +207,9 @@ struct dvb_qam_parameters {
fe_modulation_t modulation; /* modulation type (see above) */ fe_modulation_t modulation; /* modulation type (see above) */
}; };
struct dvb_vsb_parameters {
fe_modulation_t modulation; /* modulation type (see above) */
};
struct dvb_ofdm_parameters { struct dvb_ofdm_parameters {
fe_bandwidth_t bandwidth; fe_bandwidth_t bandwidth;
...@@ -219,13 +223,14 @@ struct dvb_ofdm_parameters { ...@@ -219,13 +223,14 @@ struct dvb_ofdm_parameters {
struct dvb_frontend_parameters { struct dvb_frontend_parameters {
__u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM */ __u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM/ATSC */
/* intermediate frequency in kHz for QPSK */ /* intermediate frequency in kHz for QPSK */
fe_spectral_inversion_t inversion; fe_spectral_inversion_t inversion;
union { union {
struct dvb_qpsk_parameters qpsk; struct dvb_qpsk_parameters qpsk;
struct dvb_qam_parameters qam; struct dvb_qam_parameters qam;
struct dvb_ofdm_parameters ofdm; struct dvb_ofdm_parameters ofdm;
struct dvb_vsb_parameters vsb;
} u; } u;
}; };
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define _DVBVERSION_H_ #define _DVBVERSION_H_
#define DVB_API_VERSION 3 #define DVB_API_VERSION 3
#define DVB_API_VERSION_MINOR 1
#endif /*_DVBVERSION_H_*/ #endif /*_DVBVERSION_H_*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment