aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-05-29 06:14:59 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-07-18 13:23:49 -0400
commit74fa39e5902faf1f5eb3ee642e2e069875a0343e (patch)
tree366466eba8244327ee89222002d92ef50bc34e90 /drivers
parent3e0e38e6e4b6f64f22f2fb6aca36b25f10f779cb (diff)
V4L/DVB (5727): Remove VIVI_SCATTER
vivi scatter method were used as a proof of concept. It can be safelly removed from mainstream, since the current method is faster and better than the previous solution. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/vivi.c163
1 files changed, 0 insertions, 163 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 3ef4d0159c33..582c6ba7c608 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -145,9 +145,6 @@ struct vivi_buffer {
145 145
146 struct vivi_fmt *fmt; 146 struct vivi_fmt *fmt;
147 147
148#ifdef CONFIG_VIVI_SCATTER
149 struct sg_to_addr *to_addr;
150#endif
151}; 148};
152 149
153struct vivi_dmaqueue { 150struct vivi_dmaqueue {
@@ -232,68 +229,13 @@ static u8 bars[8][3] = {
232#define TSTAMP_MAX_Y TSTAMP_MIN_Y+15 229#define TSTAMP_MAX_Y TSTAMP_MIN_Y+15
233#define TSTAMP_MIN_X 64 230#define TSTAMP_MIN_X 64
234 231
235#ifdef CONFIG_VIVI_SCATTER
236static void prep_to_addr(struct sg_to_addr to_addr[],
237 struct videobuf_buffer *vb)
238{
239 int i, pos=0;
240
241 for (i=0;i<vb->dma.nr_pages;i++) {
242 to_addr[i].sg=&vb->dma.sglist[i];
243 to_addr[i].pos=pos;
244 pos += vb->dma.sglist[i].length;
245 }
246}
247
248static int get_addr_pos(int pos, int pages, struct sg_to_addr to_addr[])
249{
250 int p1=0,p2=pages-1,p3=pages/2;
251
252 /* Sanity test */
253 BUG_ON (pos>=to_addr[p2].pos+to_addr[p2].sg->length);
254
255 while (p1+1<p2) {
256 if (pos < to_addr[p3].pos) {
257 p2=p3;
258 } else {
259 p1=p3;
260 }
261 p3=(p1+p2)/2;
262 }
263 if (pos >= to_addr[p2].pos)
264 p1=p2;
265
266 return (p1);
267}
268#endif
269 232
270#ifdef CONFIG_VIVI_SCATTER
271static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
272 int hmax, int line, char *timestr)
273#else
274static void gen_line(char *basep,int inipos,int wmax, 233static void gen_line(char *basep,int inipos,int wmax,
275 int hmax, int line, char *timestr) 234 int hmax, int line, char *timestr)
276#endif
277{ 235{
278 int w,i,j,pos=inipos,y; 236 int w,i,j,pos=inipos,y;
279 char *p,*s; 237 char *p,*s;
280 u8 chr,r,g,b,color; 238 u8 chr,r,g,b,color;
281#ifdef CONFIG_VIVI_SCATTER
282 int pgpos,oldpg;
283 char *basep;
284 struct page *pg;
285
286 unsigned long flags;
287 spinlock_t spinlock;
288
289 spin_lock_init(&spinlock);
290
291 /* Get first addr pointed to pixel position */
292 oldpg=get_addr_pos(pos,pages,to_addr);
293 pg=pfn_to_page(sg_dma_address(to_addr[oldpg].sg) >> PAGE_SHIFT);
294 spin_lock_irqsave(&spinlock,flags);
295 basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
296#endif
297 239
298 /* We will just duplicate the second pixel at the packet */ 240 /* We will just duplicate the second pixel at the packet */
299 wmax/=2; 241 wmax/=2;
@@ -305,18 +247,7 @@ static void gen_line(char *basep,int inipos,int wmax,
305 b=bars[w*7/wmax][2]; 247 b=bars[w*7/wmax][2];
306 248
307 for (color=0;color<4;color++) { 249 for (color=0;color<4;color++) {
308#ifdef CONFIG_VIVI_SCATTER
309 pgpos=get_addr_pos(pos,pages,to_addr);
310 if (pgpos!=oldpg) {
311 pg=pfn_to_page(sg_dma_address(to_addr[pgpos].sg) >> PAGE_SHIFT);
312 kunmap_atomic(basep, KM_BOUNCE_READ);
313 basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset;
314 oldpg=pgpos;
315 }
316 p=basep+pos-to_addr[pgpos].pos;
317#else
318 p=basep+pos; 250 p=basep+pos;
319#endif
320 251
321 switch (color) { 252 switch (color) {
322 case 0: 253 case 0:
@@ -361,23 +292,7 @@ static void gen_line(char *basep,int inipos,int wmax,
361 292
362 pos=inipos+j*2; 293 pos=inipos+j*2;
363 for (color=0;color<4;color++) { 294 for (color=0;color<4;color++) {
364#ifdef CONFIG_VIVI_SCATTER
365 pgpos=get_addr_pos(pos,pages,to_addr);
366 if (pgpos!=oldpg) {
367 pg=pfn_to_page(sg_dma_address(
368 to_addr[pgpos].sg)
369 >> PAGE_SHIFT);
370 kunmap_atomic(basep,
371 KM_BOUNCE_READ);
372 basep= kmap_atomic(pg,
373 KM_BOUNCE_READ)+
374 to_addr[pgpos].sg->offset;
375 oldpg=pgpos;
376 }
377 p=basep+pos-to_addr[pgpos].pos;
378#else
379 p=basep+pos; 295 p=basep+pos;
380#endif
381 296
382 y=TO_Y(r,g,b); 297 y=TO_Y(r,g,b);
383 298
@@ -402,12 +317,7 @@ static void gen_line(char *basep,int inipos,int wmax,
402 317
403 318
404end: 319end:
405#ifdef CONFIG_VIVI_SCATTER
406 kunmap_atomic(basep, KM_BOUNCE_READ);
407 spin_unlock_irqrestore(&spinlock,flags);
408#else
409 return; 320 return;
410#endif
411} 321}
412static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf) 322static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
413{ 323{
@@ -415,35 +325,16 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
415 int hmax = buf->vb.height; 325 int hmax = buf->vb.height;
416 int wmax = buf->vb.width; 326 int wmax = buf->vb.width;
417 struct timeval ts; 327 struct timeval ts;
418#ifdef CONFIG_VIVI_SCATTER
419 struct sg_to_addr *to_addr=buf->to_addr;
420 struct videobuf_buffer *vb=&buf->vb;
421#else
422 char *tmpbuf; 328 char *tmpbuf;
423#endif
424
425#ifdef CONFIG_VIVI_SCATTER
426 /* Test if DMA mapping is ready */
427 if (!sg_dma_address(&vb->dma.sglist[0]))
428 return;
429
430 prep_to_addr(to_addr,vb);
431 329
432 /* Check if there is enough memory */
433 BUG_ON(buf->vb.dma.nr_pages << PAGE_SHIFT < (buf->vb.width*buf->vb.height)*2);
434#else
435 if (buf->vb.dma.varea) { 330 if (buf->vb.dma.varea) {
436 tmpbuf=kmalloc (wmax*2, GFP_KERNEL); 331 tmpbuf=kmalloc (wmax*2, GFP_KERNEL);
437 } else { 332 } else {
438 tmpbuf=buf->vb.dma.vmalloc; 333 tmpbuf=buf->vb.dma.vmalloc;
439 } 334 }
440 335
441#endif
442 336
443 for (h=0;h<hmax;h++) { 337 for (h=0;h<hmax;h++) {
444#ifdef CONFIG_VIVI_SCATTER
445 gen_line(to_addr,pos,vb->dma.nr_pages,wmax,hmax,h,dev->timestr);
446#else
447 if (buf->vb.dma.varea) { 338 if (buf->vb.dma.varea) {
448 gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr); 339 gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr);
449 /* FIXME: replacing to __copy_to_user */ 340 /* FIXME: replacing to __copy_to_user */
@@ -452,7 +343,6 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
452 } else { 343 } else {
453 gen_line(tmpbuf,pos,wmax,hmax,h,dev->timestr); 344 gen_line(tmpbuf,pos,wmax,hmax,h,dev->timestr);
454 } 345 }
455#endif
456 pos += wmax*2; 346 pos += wmax*2;
457 } 347 }
458 348
@@ -718,11 +608,6 @@ static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
718 if (in_interrupt()) 608 if (in_interrupt())
719 BUG(); 609 BUG();
720 610
721#ifdef CONFIG_VIVI_SCATTER
722 /*FIXME: Maybe a spinlock is required here */
723 kfree(buf->to_addr);
724 buf->to_addr=NULL;
725#endif
726 611
727 videobuf_waiton(&buf->vb,0,0); 612 videobuf_waiton(&buf->vb,0,0);
728 videobuf_dma_unmap(vq, &buf->vb.dma); 613 videobuf_dma_unmap(vq, &buf->vb.dma);
@@ -768,12 +653,6 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
768 653
769 buf->vb.state = STATE_PREPARED; 654 buf->vb.state = STATE_PREPARED;
770 655
771#ifdef CONFIG_VIVI_SCATTER
772 if (NULL == (buf->to_addr = kmalloc(sizeof(*buf->to_addr) * vb->dma.nr_pages,GFP_KERNEL))) {
773 rc=-ENOMEM;
774 goto fail;
775 }
776#endif
777 return 0; 656 return 0;
778 657
779fail: 658fail:
@@ -838,40 +717,6 @@ static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb
838 free_buffer(vq,buf); 717 free_buffer(vq,buf);
839} 718}
840 719
841#ifdef CONFIG_VIVI_SCATTER
842static int vivi_map_sg(void *dev, struct scatterlist *sg, int nents,
843 int direction)
844{
845 int i;
846
847 dprintk(1,"%s, number of pages=%d\n",__FUNCTION__,nents);
848 BUG_ON(direction == DMA_NONE);
849
850 for (i = 0; i < nents; i++ ) {
851 BUG_ON(!sg[i].page);
852
853 sg_dma_address(&sg[i]) = page_to_phys(sg[i].page) + sg[i].offset;
854 }
855
856 return nents;
857}
858
859static int vivi_unmap_sg(void *dev,struct scatterlist *sglist,int nr_pages,
860 int direction)
861{
862 dprintk(1,"%s\n",__FUNCTION__);
863 return 0;
864}
865
866static int vivi_dma_sync_sg(void *dev,struct scatterlist *sglist, int nr_pages,
867 int direction)
868{
869// dprintk(1,"%s\n",__FUNCTION__);
870
871// flush_write_buffers();
872 return 0;
873}
874#endif
875 720
876static struct videobuf_queue_ops vivi_video_qops = { 721static struct videobuf_queue_ops vivi_video_qops = {
877 .buf_setup = buffer_setup, 722 .buf_setup = buffer_setup,
@@ -1260,19 +1105,11 @@ static int vivi_open(struct inode *inode, struct file *file)
1260 sprintf(dev->timestr,"%02d:%02d:%02d:%03d", 1105 sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
1261 dev->h,dev->m,dev->s,(dev->us+500)/1000); 1106 dev->h,dev->m,dev->s,(dev->us+500)/1000);
1262 1107
1263#ifdef CONFIG_VIVI_SCATTER
1264 videobuf_queue_init(&fh->vb_vidq,VIDEOBUF_DMA_SCATTER, &vivi_video_qops,
1265 NULL, NULL,
1266 fh->type,
1267 V4L2_FIELD_INTERLACED,
1268 sizeof(struct vivi_buffer),fh);
1269#else
1270 videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops, 1108 videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops,
1271 NULL, NULL, 1109 NULL, NULL,
1272 fh->type, 1110 fh->type,
1273 V4L2_FIELD_INTERLACED, 1111 V4L2_FIELD_INTERLACED,
1274 sizeof(struct vivi_buffer),fh); 1112 sizeof(struct vivi_buffer),fh);
1275#endif
1276 1113
1277 return 0; 1114 return 0;
1278} 1115}