aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7164/saa7164-core.c
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2010-07-31 14:06:49 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 05:54:50 -0400
commit9230acaac461c492ff9dea24bbe6a7f568b62cf6 (patch)
tree87e073c93af1d28a88db076a13f00414857703e0 /drivers/media/video/saa7164/saa7164-core.c
parent5fa56ccdacc54f5f694141c1a74f781cf77874bb (diff)
[media] saa7164: patches to monitor TS payload for inconsistencies
... and report errors to console. (Debugging a DMA buffering issue). These are made optional in later patches. Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7164/saa7164-core.c')
-rw-r--r--drivers/media/video/saa7164/saa7164-core.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
index 20257664b40b..0c10aea081f8 100644
--- a/drivers/media/video/saa7164/saa7164-core.c
+++ b/drivers/media/video/saa7164/saa7164-core.c
@@ -68,6 +68,57 @@ LIST_HEAD(saa7164_devlist);
68 68
69#define INT_SIZE 16 69#define INT_SIZE 16
70 70
71static void saa7164_ts_verifier(struct saa7164_buffer *buf)
72{
73 struct saa7164_port *port = buf->port;
74 struct saa7164_dev *dev = port->dev;
75 u32 i;
76 u8 tmp, cc, a;
77 u8 *bufcpu = (u8 *)buf->cpu;
78
79 port->sync_errors = 0;
80 port->v_cc_errors = 0;
81 port->a_cc_errors = 0;
82
83 for (i = 0; i < buf->actual_size; i += 188) {
84 if (*(bufcpu + i) != 0x47)
85 port->sync_errors++;
86
87 /* Query pid lower 8 bits */
88 tmp = *(bufcpu + i + 2);
89 cc = *(bufcpu + i + 3) & 0x0f;
90
91 if (tmp == 0xf1) {
92 a = ((port->last_v_cc + 1) & 0x0f);
93 if (a != cc) {
94 printk(KERN_ERR "video cc last = %x current = %x i = %d\n", port->last_v_cc, cc, i);
95 port->v_cc_errors++;
96 }
97
98 port->last_v_cc = cc;
99 } else
100 if (tmp == 0xf2) {
101 a = ((port->last_a_cc + 1) & 0x0f);
102 if (a != cc) {
103 printk(KERN_ERR "audio cc last = %x current = %x i = %d\n", port->last_a_cc, cc, i);
104 port->a_cc_errors++;
105 }
106
107 port->last_a_cc = cc;
108 }
109
110 }
111
112 if (port->v_cc_errors)
113 printk(KERN_ERR "video pid cc, %d errors\n", port->v_cc_errors);
114
115 if (port->a_cc_errors)
116 printk(KERN_ERR "audio pid cc, %d errors\n", port->a_cc_errors);
117
118 if (port->sync_errors)
119 printk(KERN_ERR "sync_errors = %d\n", port->sync_errors);
120}
121
71static void saa7164_histogram_reset(struct saa7164_histogram *hg, char *name) 122static void saa7164_histogram_reset(struct saa7164_histogram *hg, char *name)
72{ 123{
73 int i; 124 int i;
@@ -188,7 +239,10 @@ static void saa7164_work_enchandler(struct work_struct *w)
188 dprintk(DBGLVL_IRQ, "%s() wp: %d processing: %d\n", 239 dprintk(DBGLVL_IRQ, "%s() wp: %d processing: %d\n",
189 __func__, wp, rp); 240 __func__, wp, rp);
190 241
191 /* */ 242 /* Validate the incoming buffer content */
243 if (port->encoder_params.stream_type == V4L2_MPEG_STREAM_TYPE_MPEG2_TS)
244 saa7164_ts_verifier(buf);
245
192 /* find a free user buffer and clone to it */ 246 /* find a free user buffer and clone to it */
193 if (!list_empty(&port->list_buf_free.list)) { 247 if (!list_empty(&port->list_buf_free.list)) {
194 248
@@ -212,6 +266,11 @@ static void saa7164_work_enchandler(struct work_struct *w)
212 } else 266 } else
213 printk(KERN_ERR "encirq no free buffers\n"); 267 printk(KERN_ERR "encirq no free buffers\n");
214 268
269 /* Ensure offset into buffer remains 0, fill buffer
270 * with known bad data. */
271 saa7164_buffer_zero_offsets(port, rp);
272 memset(buf->cpu, 0xDE, buf->pci_size);
273
215 break; 274 break;
216 } 275 }
217 276