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;
......
This diff is collapsed.
...@@ -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