Commit 26b9d6c0 authored by Abylay Ospan's avatar Abylay Ospan Committed by Mauro Carvalho Chehab

V4L/DVB (13271): TS speed check. Logging transport stream speed in Kbits per second

[mchehab@redhat.com: add asm/div64.h and allocate vars only if dvb_demux_speedcheck specified]
Signed-off-by: default avatarAbylay Ospan <aospan@netup.ru>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 117e1348
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/div64.h>
#include "dvb_demux.h" #include "dvb_demux.h"
...@@ -44,6 +45,11 @@ module_param(dvb_demux_tscheck, int, 0644); ...@@ -44,6 +45,11 @@ module_param(dvb_demux_tscheck, int, 0644);
MODULE_PARM_DESC(dvb_demux_tscheck, MODULE_PARM_DESC(dvb_demux_tscheck,
"enable transport stream continuity and TEI check"); "enable transport stream continuity and TEI check");
static int dvb_demux_speedcheck;
module_param(dvb_demux_speedcheck, int, 0644);
MODULE_PARM_DESC(dvb_demux_speedcheck,
"enable transport stream speed check");
#define dprintk_tscheck(x...) do { \ #define dprintk_tscheck(x...) do { \
if (dvb_demux_tscheck && printk_ratelimit()) \ if (dvb_demux_tscheck && printk_ratelimit()) \
printk(x); \ printk(x); \
...@@ -387,6 +393,39 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) ...@@ -387,6 +393,39 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
u16 pid = ts_pid(buf); u16 pid = ts_pid(buf);
int dvr_done = 0; int dvr_done = 0;
if (dvb_demux_speedcheck) {
struct timespec cur_time, delta_time;
u64 speed_bytes, speed_timedelta;
demux->speed_pkts_cnt++;
/* show speed every SPEED_PKTS_INTERVAL packets */
if (!(demux->speed_pkts_cnt % SPEED_PKTS_INTERVAL)) {
cur_time = current_kernel_time();
if (demux->speed_last_time.tv_sec != 0 &&
demux->speed_last_time.tv_nsec != 0) {
delta_time = timespec_sub(cur_time,
demux->speed_last_time);
speed_bytes = (u64)demux->speed_pkts_cnt
* 188 * 8;
/* convert to 1024 basis */
speed_bytes = 1000 * div64_u64(speed_bytes,
1024);
speed_timedelta =
(u64)timespec_to_ns(&delta_time);
speed_timedelta = div64_u64(speed_timedelta,
1000000); /* nsec -> usec */
printk(KERN_INFO "TS speed %llu Kbits/sec \n",
div64_u64(speed_bytes,
speed_timedelta));
};
demux->speed_last_time = cur_time;
demux->speed_pkts_cnt = 0;
};
};
if (dvb_demux_tscheck) { if (dvb_demux_tscheck) {
if (!demux->cnt_storage) if (!demux->cnt_storage)
demux->cnt_storage = vmalloc(MAX_PID + 1); demux->cnt_storage = vmalloc(MAX_PID + 1);
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#define MAX_PID 0x1fff #define MAX_PID 0x1fff
#define SPEED_PKTS_INTERVAL 50000
struct dvb_demux_filter { struct dvb_demux_filter {
struct dmx_section_filter filter; struct dmx_section_filter filter;
u8 maskandmode[DMX_MAX_FILTER_SIZE]; u8 maskandmode[DMX_MAX_FILTER_SIZE];
...@@ -131,6 +133,9 @@ struct dvb_demux { ...@@ -131,6 +133,9 @@ struct dvb_demux {
spinlock_t lock; spinlock_t lock;
uint8_t *cnt_storage; /* for TS continuity check */ uint8_t *cnt_storage; /* for TS continuity check */
struct timespec speed_last_time; /* for TS speed check */
uint32_t speed_pkts_cnt; /* for TS speed check */
}; };
int dvb_dmx_init(struct dvb_demux *dvbdemux); int dvb_dmx_init(struct dvb_demux *dvbdemux);
......
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