aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/saa7164/saa7164-buffer.c14
-rw-r--r--drivers/media/video/saa7164/saa7164-core.c61
-rw-r--r--drivers/media/video/saa7164/saa7164.h8
3 files changed, 82 insertions, 1 deletions
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
index 5fccecd588ce..0760891d5fa8 100644
--- a/drivers/media/video/saa7164/saa7164-buffer.c
+++ b/drivers/media/video/saa7164/saa7164-buffer.c
@@ -180,6 +180,20 @@ int saa7164_buffer_dealloc(struct saa7164_buffer *buf)
180 return SAA_OK; 180 return SAA_OK;
181} 181}
182 182
183int saa7164_buffer_zero_offsets(struct saa7164_port *port, int i)
184{
185 struct saa7164_dev *dev = port->dev;
186
187 if ((i < 0) || (i >= port->hwcfg.buffercount))
188 return -EINVAL;
189
190 dprintk(DBGLVL_BUF, "%s(idx = %d)\n", __func__, i);
191
192 saa7164_writel(port->bufoffset + (sizeof(u32) * i), 0);
193
194 return 0;
195}
196
183/* Write a buffer into the hardware */ 197/* Write a buffer into the hardware */
184int saa7164_buffer_activate(struct saa7164_buffer *buf, int i) 198int saa7164_buffer_activate(struct saa7164_buffer *buf, int i)
185{ 199{
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
diff --git a/drivers/media/video/saa7164/saa7164.h b/drivers/media/video/saa7164/saa7164.h
index ef98a958b75e..25044a0de8b0 100644
--- a/drivers/media/video/saa7164/saa7164.h
+++ b/drivers/media/video/saa7164/saa7164.h
@@ -375,6 +375,13 @@ struct saa7164_port {
375 struct saa7164_buffer list_buf_used; 375 struct saa7164_buffer list_buf_used;
376 struct saa7164_buffer list_buf_free; 376 struct saa7164_buffer list_buf_free;
377 wait_queue_head_t wait_read; 377 wait_queue_head_t wait_read;
378
379 /* Debug */
380 u32 sync_errors;
381 u32 v_cc_errors;
382 u32 a_cc_errors;
383 u8 last_v_cc;
384 u8 last_a_cc;
378}; 385};
379 386
380struct saa7164_dev { 387struct saa7164_dev {
@@ -521,6 +528,7 @@ extern int saa7164_buffer_cfg_port(struct saa7164_port *port);
521extern struct saa7164_user_buffer *saa7164_buffer_alloc_user( 528extern struct saa7164_user_buffer *saa7164_buffer_alloc_user(
522 struct saa7164_dev *dev, u32 len); 529 struct saa7164_dev *dev, u32 len);
523extern void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf); 530extern void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf);
531extern int saa7164_buffer_zero_offsets(struct saa7164_port *port, int i);
524 532
525 533
526/* ----------------------------------------------------------- */ 534/* ----------------------------------------------------------- */