The patch number 11930 was added via Abylay Ospan <aos...@netup.ru> to http://linuxtv.org/hg/v4l-dvb master development tree.
Kernel patches in this development tree may be modified to be backward compatible with older kernels. Compatibility modifications will be removed before inclusion into the mainstream Kernel If anyone has any objections, please let us know by sending a message to: Linux Media Mailing List <linux-me...@vger.kernel.org> ------ TS continuity check: show error message when discontinuity detected or TEI flag detected in header Signed-off-by: Abylay Ospan <aos...@netup.ru> --- linux/drivers/media/dvb/dvb-core/dvb_demux.c | 42 +++++++++++++++++++ linux/drivers/media/dvb/dvb-core/dvb_demux.h | 4 + 2 files changed, 46 insertions(+) diff -r 5ed2a853b692 -r ed3781a79c73 linux/drivers/media/dvb/dvb-core/dvb_demux.c --- a/linux/drivers/media/dvb/dvb-core/dvb_demux.c Sat Jun 06 08:15:26 2009 -0300 +++ b/linux/drivers/media/dvb/dvb-core/dvb_demux.c Sat Jun 06 16:31:34 2009 +0400 @@ -38,6 +38,16 @@ */ // #define DVB_DEMUX_SECTION_LOSS_LOG +static int dvb_demux_tscheck; +module_param(dvb_demux_tscheck, int, 0644); +MODULE_PARM_DESC(dvb_demux_tscheck, + "enable transport stream continuity and TEI check"); + +#define dprintk_tscheck(x...) do { \ + if (dvb_demux_tscheck && printk_ratelimit()) \ + printk(x); \ + } while (0) + /****************************************************************************** * static inlined helper functions ******************************************************************************/ @@ -376,6 +386,36 @@ static void dvb_dmx_swfilter_packet(stru u16 pid = ts_pid(buf); int dvr_done = 0; + if (dvb_demux_tscheck) { + if (!demux->cnt_storage) + demux->cnt_storage = vmalloc(MAX_PID + 1); + + if (!demux->cnt_storage) { + printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n"); + dvb_demux_tscheck = 0; + goto no_dvb_demux_tscheck; + } + + /* check pkt counter */ + if (pid < MAX_PID) { + if (buf[1] & 0x80) + dprintk_tscheck("TEI detected. " + "PID=0x%x data1=0x%x\n", + pid, buf[1]); + + if ((buf[3] & 0xf) != demux->cnt_storage[pid]) + dprintk_tscheck("TS packet counter mismatch. " + "PID=0x%x expected 0x%x " + "got 0x%x\n", + pid, demux->cnt_storage[pid], + buf[3] & 0xf); + + demux->cnt_storage[pid] = ((buf[3] & 0xf) + 1)&0xf; + }; + /* end check */ + }; +no_dvb_demux_tscheck: + list_for_each_entry(feed, &demux->feed_list, list_head) { if ((feed->pid != pid) && (feed->pid != 0x2000)) continue; @@ -1160,6 +1200,7 @@ int dvb_dmx_init(struct dvb_demux *dvbde int i; struct dmx_demux *dmx = &dvbdemux->dmx; + dvbdemux->cnt_storage = NULL; dvbdemux->users = 0; dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter)); @@ -1226,6 +1267,7 @@ EXPORT_SYMBOL(dvb_dmx_init); void dvb_dmx_release(struct dvb_demux *dvbdemux) { + vfree(dvbdemux->cnt_storage); vfree(dvbdemux->filter); vfree(dvbdemux->feed); } diff -r 5ed2a853b692 -r ed3781a79c73 linux/drivers/media/dvb/dvb-core/dvb_demux.h --- a/linux/drivers/media/dvb/dvb-core/dvb_demux.h Sat Jun 06 08:15:26 2009 -0300 +++ b/linux/drivers/media/dvb/dvb-core/dvb_demux.h Sat Jun 06 16:31:34 2009 +0400 @@ -42,6 +42,8 @@ #define DMX_STATE_GO 4 #define DVB_DEMUX_MASK_MAX 18 + +#define MAX_PID 0x1fff struct dvb_demux_filter { struct dmx_section_filter filter; @@ -128,6 +130,8 @@ struct dvb_demux { struct mutex mutex; spinlock_t lock; + + uint8_t *cnt_storage; /* for TS continuity check */ }; int dvb_dmx_init(struct dvb_demux *dvbdemux); --- Patch is available at: http://linuxtv.org/hg/v4l-dvb/rev/ed3781a79c734f35b800d0b55d276cd62d793141 _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits