2 bttv-risc.c -- interfaces to other kernel modules
4 bttv risc code handling
8 (c) 2000-2003 Gerd Knorr <kraxel@bytesex.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/pci.h>
29 #include <linux/vmalloc.h>
30 #include <linux/interrupt.h>
32 #include <asm/pgtable.h>
36 #define VCR_HACK_LINES 4
38 /* ---------------------------------------------------------- */
39 /* risc code generators */
42 bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
43 struct scatterlist *sglist,
44 unsigned int offset, unsigned int bpl,
45 unsigned int padding, unsigned int lines)
47 u32 instructions,line,todo;
48 struct scatterlist *sg;
52 /* estimate risc mem: worst case is one write per page border +
53 one write per scan line + sync + jump (all 2 dwords) */
54 instructions = (bpl * lines) / PAGE_SIZE + lines;
56 if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0)
59 /* sync instruction */
61 *(rp++) = cpu_to_le32(BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1);
62 *(rp++) = cpu_to_le32(0);
66 for (line = 0; line < lines; line++) {
67 if ((btv->opt_vcr_hack) &&
68 (line >= (lines - VCR_HACK_LINES)))
70 while (offset && offset >= sg_dma_len(sg)) {
71 offset -= sg_dma_len(sg);
74 if (bpl <= sg_dma_len(sg)-offset) {
75 /* fits into current chunk */
76 *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_SOL|
78 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
81 /* scanline needs to be splitted */
83 *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_SOL|
84 (sg_dma_len(sg)-offset));
85 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
86 todo -= (sg_dma_len(sg)-offset);
89 while (todo > sg_dma_len(sg)) {
90 *(rp++)=cpu_to_le32(BT848_RISC_WRITE|
92 *(rp++)=cpu_to_le32(sg_dma_address(sg));
93 todo -= sg_dma_len(sg);
96 *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_EOL|
98 *(rp++)=cpu_to_le32(sg_dma_address(sg));
103 dprintk("bttv%d: risc planar: %d sglist elems\n", btv->c.nr, (int)(sg-sglist));
105 /* save pointer to jmp instruction address */
111 bttv_risc_planar(struct bttv *btv, struct btcx_riscmem *risc,
112 struct scatterlist *sglist,
113 unsigned int yoffset, unsigned int ybpl,
114 unsigned int ypadding, unsigned int ylines,
115 unsigned int uoffset, unsigned int voffset,
116 unsigned int hshift, unsigned int vshift,
117 unsigned int cpadding)
119 unsigned int instructions,line,todo,ylen,chroma;
121 struct scatterlist *ysg;
122 struct scatterlist *usg;
123 struct scatterlist *vsg;
126 /* estimate risc mem: worst case is one write per page border +
127 one write per scan line (5 dwords)
128 plus sync + jump (2 dwords) */
129 instructions = (ybpl * ylines * 2) / PAGE_SIZE + ylines;
131 if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*4*5)) < 0)
134 /* sync instruction */
136 *(rp++) = cpu_to_le32(BT848_RISC_SYNC|BT848_FIFO_STATUS_FM3);
137 *(rp++) = cpu_to_le32(0);
143 for (line = 0; line < ylines; line++) {
144 if ((btv->opt_vcr_hack) &&
145 (line >= (ylines - VCR_HACK_LINES)))
148 case 0: chroma = 1; break;
149 case 1: chroma = !(line & 1); break;
150 case 2: chroma = !(line & 3); break;
153 for (todo = ybpl; todo > 0; todo -= ylen) {
154 /* go to next sg entry if needed */
155 while (yoffset && yoffset >= sg_dma_len(ysg)) {
156 yoffset -= sg_dma_len(ysg);
159 while (uoffset && uoffset >= sg_dma_len(usg)) {
160 uoffset -= sg_dma_len(usg);
163 while (voffset && voffset >= sg_dma_len(vsg)) {
164 voffset -= sg_dma_len(vsg);
168 /* calculate max number of bytes we can write */
170 if (yoffset + ylen > sg_dma_len(ysg))
171 ylen = sg_dma_len(ysg) - yoffset;
173 if (uoffset + (ylen>>hshift) > sg_dma_len(usg))
174 ylen = (sg_dma_len(usg) - uoffset) << hshift;
175 if (voffset + (ylen>>hshift) > sg_dma_len(vsg))
176 ylen = (sg_dma_len(vsg) - voffset) << hshift;
177 ri = BT848_RISC_WRITE123;
179 ri = BT848_RISC_WRITE1S23;
182 ri |= BT848_RISC_SOL;
184 ri |= BT848_RISC_EOL;
186 /* write risc instruction */
187 *(rp++)=cpu_to_le32(ri | ylen);
188 *(rp++)=cpu_to_le32(((ylen >> hshift) << 16) |
190 *(rp++)=cpu_to_le32(sg_dma_address(ysg)+yoffset);
193 *(rp++)=cpu_to_le32(sg_dma_address(usg)+uoffset);
194 uoffset += ylen >> hshift;
195 *(rp++)=cpu_to_le32(sg_dma_address(vsg)+voffset);
196 voffset += ylen >> hshift;
206 /* save pointer to jmp instruction address */
212 bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
213 const struct bttv_format *fmt, struct bttv_overlay *ov,
214 int skip_even, int skip_odd)
216 int instructions,rc,line,maxy,start,end,skip,nskips;
217 struct btcx_skiplist *skips;
221 /* skip list for window clipping */
222 if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL)))
225 /* estimate risc mem: worst case is (clip+1) * lines instructions
226 + sync + jump (all 2 dwords) */
227 instructions = (ov->nclips + 1) *
228 ((skip_even || skip_odd) ? ov->w.height>>1 : ov->w.height);
230 if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0) {
235 /* sync instruction */
237 *(rp++) = cpu_to_le32(BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1);
238 *(rp++) = cpu_to_le32(0);
240 addr = (unsigned long)btv->fbuf.base;
241 addr += btv->fbuf.fmt.bytesperline * ov->w.top;
242 addr += (fmt->depth >> 3) * ov->w.left;
245 for (maxy = -1, line = 0; line < ov->w.height;
246 line++, addr += btv->fbuf.fmt.bytesperline) {
247 if ((btv->opt_vcr_hack) &&
248 (line >= (ov->w.height - VCR_HACK_LINES)))
250 if ((line%2) == 0 && skip_even)
252 if ((line%2) == 1 && skip_odd)
255 /* calculate clipping */
257 btcx_calc_skips(line, ov->w.width, &maxy,
258 skips, &nskips, ov->clips, ov->nclips);
260 /* write out risc code */
261 for (start = 0, skip = 0; start < ov->w.width; start = end) {
262 if (skip >= nskips) {
263 ri = BT848_RISC_WRITE;
265 } else if (start < skips[skip].start) {
266 ri = BT848_RISC_WRITE;
267 end = skips[skip].start;
269 ri = BT848_RISC_SKIP;
270 end = skips[skip].end;
273 if (BT848_RISC_WRITE == ri)
274 ra = addr + (fmt->depth>>3)*start;
279 ri |= BT848_RISC_SOL;
280 if (ov->w.width == end)
281 ri |= BT848_RISC_EOL;
282 ri |= (fmt->depth>>3) * (end-start);
284 *(rp++)=cpu_to_le32(ri);
286 *(rp++)=cpu_to_le32(ra);
290 /* save pointer to jmp instruction address */
296 /* ---------------------------------------------------------- */
299 bttv_calc_geo(struct bttv *btv, struct bttv_geometry *geo,
300 int width, int height, int interleaved, int norm)
302 const struct bttv_tvnorm *tvnorm = &bttv_tvnorms[norm];
306 int swidth = tvnorm->swidth;
307 int totalwidth = tvnorm->totalwidth;
308 int scaledtwidth = tvnorm->scaledtwidth;
310 if (bttv_tvcards[btv->c.type].muxsel[btv->input] < 0) {
316 vdelay = tvnorm->vdelay;
318 if (vdelay < btv->vbi.lines*2)
319 vdelay = btv->vbi.lines*2;
322 xsf = (width*scaledtwidth)/swidth;
323 geo->hscale = ((totalwidth*4096UL)/xsf-4096);
324 geo->hdelay = tvnorm->hdelayx1;
325 geo->hdelay = (geo->hdelay*width)/swidth;
326 geo->hdelay &= 0x3fe;
327 sr = ((tvnorm->sheight >> (interleaved?0:1))*512)/height - 512;
328 geo->vscale = (0x10000UL-sr) & 0x1fff;
329 geo->crop = ((width>>8)&0x03) | ((geo->hdelay>>6)&0x0c) |
330 ((tvnorm->sheight>>4)&0x30) | ((vdelay>>2)&0xc0);
331 geo->vscale |= interleaved ? (BT848_VSCALE_INT<<8) : 0;
332 geo->vdelay = vdelay;
334 geo->sheight = tvnorm->sheight;
335 geo->vtotal = tvnorm->vtotal;
337 if (btv->opt_combfilter) {
338 geo->vtc = (width < 193) ? 2 : ((width < 385) ? 1 : 0);
339 geo->comb = (width < 769) ? 1 : 0;
347 bttv_apply_geo(struct bttv *btv, struct bttv_geometry *geo, int odd)
349 int off = odd ? 0x80 : 0x00;
352 btor(BT848_VSCALE_COMB, BT848_E_VSCALE_HI+off);
354 btand(~BT848_VSCALE_COMB, BT848_E_VSCALE_HI+off);
356 btwrite(geo->vtc, BT848_E_VTC+off);
357 btwrite(geo->hscale >> 8, BT848_E_HSCALE_HI+off);
358 btwrite(geo->hscale & 0xff, BT848_E_HSCALE_LO+off);
359 btaor((geo->vscale>>8), 0xe0, BT848_E_VSCALE_HI+off);
360 btwrite(geo->vscale & 0xff, BT848_E_VSCALE_LO+off);
361 btwrite(geo->width & 0xff, BT848_E_HACTIVE_LO+off);
362 btwrite(geo->hdelay & 0xff, BT848_E_HDELAY_LO+off);
363 btwrite(geo->sheight & 0xff, BT848_E_VACTIVE_LO+off);
364 btwrite(geo->vdelay & 0xff, BT848_E_VDELAY_LO+off);
365 btwrite(geo->crop, BT848_E_CROP+off);
366 btwrite(geo->vtotal>>8, BT848_VTOTAL_HI);
367 btwrite(geo->vtotal & 0xff, BT848_VTOTAL_LO);
370 /* ---------------------------------------------------------- */
371 /* risc group / risc main loop / dma management */
374 bttv_set_dma(struct bttv *btv, int override, int irqflags)
380 if (NULL != btv->curr.top) btv->cap_ctl |= 0x02;
381 if (NULL != btv->curr.bottom) btv->cap_ctl |= 0x01;
382 if (NULL != btv->cvbi) btv->cap_ctl |= 0x0c;
385 capctl |= (btv->cap_ctl & 0x03) ? 0x03 : 0x00; /* capture */
386 capctl |= (btv->cap_ctl & 0x0c) ? 0x0c : 0x00; /* vbi data */
390 "bttv%d: capctl=%x irq=%d top=%08Lx/%08Lx even=%08Lx/%08Lx\n",
391 btv->c.nr,capctl,irqflags,
392 btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0,
393 btv->curr.top ? (unsigned long long)btv->curr.top->top.dma : 0,
394 btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0,
395 btv->curr.bottom ? (unsigned long long)btv->curr.bottom->bottom.dma : 0);
397 cmd = BT848_RISC_JUMP;
399 cmd |= BT848_RISC_IRQ;
400 cmd |= (irqflags & 0x0f) << 16;
401 cmd |= (~irqflags & 0x0f) << 20;
403 if (irqflags || btv->cvbi) {
404 mod_timer(&btv->timeout, jiffies+BTTV_TIMEOUT);
406 del_timer(&btv->timeout);
408 btv->main.cpu[RISC_SLOT_LOOP] = cpu_to_le32(cmd);
410 btaor(capctl, ~0x0f, BT848_CAP_CTL);
414 btwrite(btv->main.dma, BT848_RISC_STRT_ADD);
415 btor(3, BT848_GPIO_DMA_CTL);
420 btand(~3, BT848_GPIO_DMA_CTL);
427 bttv_risc_init_main(struct bttv *btv)
431 if ((rc = btcx_riscmem_alloc(btv->c.pci,&btv->main,PAGE_SIZE)) < 0)
433 dprintk(KERN_DEBUG "bttv%d: risc main @ %08Lx\n",
434 btv->c.nr,(unsigned long long)btv->main.dma);
436 btv->main.cpu[0] = cpu_to_le32(BT848_RISC_SYNC | BT848_RISC_RESYNC |
437 BT848_FIFO_STATUS_VRE);
438 btv->main.cpu[1] = cpu_to_le32(0);
439 btv->main.cpu[2] = cpu_to_le32(BT848_RISC_JUMP);
440 btv->main.cpu[3] = cpu_to_le32(btv->main.dma + (4<<2));
443 btv->main.cpu[4] = cpu_to_le32(BT848_RISC_JUMP);
444 btv->main.cpu[5] = cpu_to_le32(btv->main.dma + (6<<2));
445 btv->main.cpu[6] = cpu_to_le32(BT848_RISC_JUMP);
446 btv->main.cpu[7] = cpu_to_le32(btv->main.dma + (8<<2));
448 btv->main.cpu[8] = cpu_to_le32(BT848_RISC_SYNC | BT848_RISC_RESYNC |
449 BT848_FIFO_STATUS_VRO);
450 btv->main.cpu[9] = cpu_to_le32(0);
453 btv->main.cpu[10] = cpu_to_le32(BT848_RISC_JUMP);
454 btv->main.cpu[11] = cpu_to_le32(btv->main.dma + (12<<2));
455 btv->main.cpu[12] = cpu_to_le32(BT848_RISC_JUMP);
456 btv->main.cpu[13] = cpu_to_le32(btv->main.dma + (14<<2));
458 /* jump back to top field */
459 btv->main.cpu[14] = cpu_to_le32(BT848_RISC_JUMP);
460 btv->main.cpu[15] = cpu_to_le32(btv->main.dma + (0<<2));
466 bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
470 unsigned long next = btv->main.dma + ((slot+2) << 2);
473 d2printk(KERN_DEBUG "bttv%d: risc=%p slot[%d]=NULL\n",
474 btv->c.nr,risc,slot);
475 btv->main.cpu[slot+1] = cpu_to_le32(next);
477 d2printk(KERN_DEBUG "bttv%d: risc=%p slot[%d]=%08Lx irq=%d\n",
478 btv->c.nr,risc,slot,(unsigned long long)risc->dma,irqflags);
479 cmd = BT848_RISC_JUMP;
481 cmd |= BT848_RISC_IRQ;
482 cmd |= (irqflags & 0x0f) << 16;
483 cmd |= (~irqflags & 0x0f) << 20;
485 risc->jmp[0] = cpu_to_le32(cmd);
486 risc->jmp[1] = cpu_to_le32(next);
487 btv->main.cpu[slot+1] = cpu_to_le32(risc->dma);
493 bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf)
497 videobuf_waiton(&buf->vb,0,0);
498 videobuf_dma_pci_unmap(btv->c.pci, &buf->vb.dma);
499 videobuf_dma_free(&buf->vb.dma);
500 btcx_riscmem_free(btv->c.pci,&buf->bottom);
501 btcx_riscmem_free(btv->c.pci,&buf->top);
502 buf->vb.state = STATE_NEEDS_INIT;
506 bttv_buffer_activate_vbi(struct bttv *btv,
507 struct bttv_buffer *vbi)
511 vbi->vb.state = STATE_ACTIVE;
512 list_del(&vbi->vb.queue);
513 bttv_risc_hook(btv, RISC_SLOT_O_VBI, &vbi->top, 0);
514 bttv_risc_hook(btv, RISC_SLOT_E_VBI, &vbi->bottom, 4);
516 bttv_risc_hook(btv, RISC_SLOT_O_VBI, NULL, 0);
517 bttv_risc_hook(btv, RISC_SLOT_E_VBI, NULL, 0);
523 bttv_buffer_activate_video(struct bttv *btv,
524 struct bttv_buffer_set *set)
527 if (NULL != set->top && NULL != set->bottom) {
528 if (set->top == set->bottom) {
529 set->top->vb.state = STATE_ACTIVE;
530 if (set->top->vb.queue.next)
531 list_del(&set->top->vb.queue);
533 set->top->vb.state = STATE_ACTIVE;
534 set->bottom->vb.state = STATE_ACTIVE;
535 if (set->top->vb.queue.next)
536 list_del(&set->top->vb.queue);
537 if (set->bottom->vb.queue.next)
538 list_del(&set->bottom->vb.queue);
540 bttv_apply_geo(btv, &set->top->geo, 1);
541 bttv_apply_geo(btv, &set->bottom->geo,0);
542 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top, set->topirq);
543 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom, 0);
544 btaor((set->top->btformat & 0xf0) | (set->bottom->btformat & 0x0f),
545 ~0xff, BT848_COLOR_FMT);
546 btaor((set->top->btswap & 0x0a) | (set->bottom->btswap & 0x05),
547 ~0x0f, BT848_COLOR_CTL);
548 } else if (NULL != set->top) {
549 set->top->vb.state = STATE_ACTIVE;
550 if (set->top->vb.queue.next)
551 list_del(&set->top->vb.queue);
552 bttv_apply_geo(btv, &set->top->geo,1);
553 bttv_apply_geo(btv, &set->top->geo,0);
554 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top, 0);
555 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, NULL, 0);
556 btaor(set->top->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
557 btaor(set->top->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL);
558 } else if (NULL != set->bottom) {
559 set->bottom->vb.state = STATE_ACTIVE;
560 if (set->bottom->vb.queue.next)
561 list_del(&set->bottom->vb.queue);
562 bttv_apply_geo(btv, &set->bottom->geo,1);
563 bttv_apply_geo(btv, &set->bottom->geo,0);
564 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
565 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom, 0);
566 btaor(set->bottom->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
567 btaor(set->bottom->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL);
569 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
570 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, NULL, 0);
575 /* ---------------------------------------------------------- */
577 /* calculate geometry, build risc code */
579 bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
581 const struct bttv_tvnorm *tvnorm = bttv_tvnorms + buf->tvnorm;
584 "bttv%d: buffer field: %s format: %s size: %dx%d\n",
585 btv->c.nr, v4l2_field_names[buf->vb.field],
586 buf->fmt->name, buf->vb.width, buf->vb.height);
588 /* packed pixel modes */
589 if (buf->fmt->flags & FORMAT_FLAGS_PACKED) {
590 int bpl = (buf->fmt->depth >> 3) * buf->vb.width;
591 int bpf = bpl * (buf->vb.height >> 1);
593 bttv_calc_geo(btv,&buf->geo,buf->vb.width,buf->vb.height,
594 V4L2_FIELD_HAS_BOTH(buf->vb.field),buf->tvnorm);
596 switch (buf->vb.field) {
598 bttv_risc_packed(btv,&buf->top,buf->vb.dma.sglist,
599 0,bpl,0,buf->vb.height);
601 case V4L2_FIELD_BOTTOM:
602 bttv_risc_packed(btv,&buf->bottom,buf->vb.dma.sglist,
603 0,bpl,0,buf->vb.height);
605 case V4L2_FIELD_INTERLACED:
606 bttv_risc_packed(btv,&buf->top,buf->vb.dma.sglist,
607 0,bpl,bpl,buf->vb.height >> 1);
608 bttv_risc_packed(btv,&buf->bottom,buf->vb.dma.sglist,
609 bpl,bpl,bpl,buf->vb.height >> 1);
611 case V4L2_FIELD_SEQ_TB:
612 bttv_risc_packed(btv,&buf->top,buf->vb.dma.sglist,
613 0,bpl,0,buf->vb.height >> 1);
614 bttv_risc_packed(btv,&buf->bottom,buf->vb.dma.sglist,
615 bpf,bpl,0,buf->vb.height >> 1);
623 if (buf->fmt->flags & FORMAT_FLAGS_PLANAR) {
624 int uoffset, voffset;
625 int ypadding, cpadding, lines;
627 /* calculate chroma offsets */
628 uoffset = buf->vb.width * buf->vb.height;
629 voffset = buf->vb.width * buf->vb.height;
630 if (buf->fmt->flags & FORMAT_FLAGS_CrCb) {
631 /* Y-Cr-Cb plane order */
632 uoffset >>= buf->fmt->hshift;
633 uoffset >>= buf->fmt->vshift;
636 /* Y-Cb-Cr plane order */
637 voffset >>= buf->fmt->hshift;
638 voffset >>= buf->fmt->vshift;
642 switch (buf->vb.field) {
644 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
645 buf->vb.height,0,buf->tvnorm);
646 bttv_risc_planar(btv, &buf->top, buf->vb.dma.sglist,
647 0,buf->vb.width,0,buf->vb.height,
648 uoffset,voffset,buf->fmt->hshift,
651 case V4L2_FIELD_BOTTOM:
652 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
653 buf->vb.height,0,buf->tvnorm);
654 bttv_risc_planar(btv, &buf->bottom, buf->vb.dma.sglist,
655 0,buf->vb.width,0,buf->vb.height,
656 uoffset,voffset,buf->fmt->hshift,
659 case V4L2_FIELD_INTERLACED:
660 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
661 buf->vb.height,1,buf->tvnorm);
662 lines = buf->vb.height >> 1;
663 ypadding = buf->vb.width;
664 cpadding = buf->vb.width >> buf->fmt->hshift;
665 bttv_risc_planar(btv,&buf->top,
667 0,buf->vb.width,ypadding,lines,
672 bttv_risc_planar(btv,&buf->bottom,
674 ypadding,buf->vb.width,ypadding,lines,
681 case V4L2_FIELD_SEQ_TB:
682 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
683 buf->vb.height,1,buf->tvnorm);
684 lines = buf->vb.height >> 1;
685 ypadding = buf->vb.width;
686 cpadding = buf->vb.width >> buf->fmt->hshift;
687 bttv_risc_planar(btv,&buf->top,
689 0,buf->vb.width,0,lines,
695 bttv_risc_planar(btv,&buf->bottom,
697 lines * ypadding,buf->vb.width,0,lines,
698 lines * ypadding + (uoffset >> 1),
699 lines * ypadding + (voffset >> 1),
710 if (buf->fmt->flags & FORMAT_FLAGS_RAW) {
711 /* build risc code */
712 buf->vb.field = V4L2_FIELD_SEQ_TB;
713 bttv_calc_geo(btv,&buf->geo,tvnorm->swidth,tvnorm->sheight,
715 bttv_risc_packed(btv, &buf->top, buf->vb.dma.sglist,
716 0, RAW_BPL, 0, RAW_LINES);
717 bttv_risc_packed(btv, &buf->bottom, buf->vb.dma.sglist,
718 buf->vb.size/2 , RAW_BPL, 0, RAW_LINES);
721 /* copy format info */
722 buf->btformat = buf->fmt->btformat;
723 buf->btswap = buf->fmt->btswap;
727 /* ---------------------------------------------------------- */
729 /* calculate geometry, build risc code */
731 bttv_overlay_risc(struct bttv *btv,
732 struct bttv_overlay *ov,
733 const struct bttv_format *fmt,
734 struct bttv_buffer *buf)
736 /* check interleave, bottom+top fields */
738 "bttv%d: overlay fields: %s format: %s size: %dx%d\n",
739 btv->c.nr, v4l2_field_names[buf->vb.field],
740 fmt->name,ov->w.width,ov->w.height);
742 /* calculate geometry */
743 bttv_calc_geo(btv,&buf->geo,ov->w.width,ov->w.height,
744 V4L2_FIELD_HAS_BOTH(ov->field), ov->tvnorm);
746 /* build risc code */
749 bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 0);
751 case V4L2_FIELD_BOTTOM:
752 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 0);
754 case V4L2_FIELD_INTERLACED:
756 bttv_risc_overlay(btv, &buf->top, fmt, ov, 1, 0);
757 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 1);
759 bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 1);
760 bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 1, 0);
767 /* copy format info */
768 buf->btformat = fmt->btformat;
769 buf->btswap = fmt->btswap;
770 buf->vb.field = ov->field;