bttv-risc.c (7df8d5cffa87c0976df5d2e4e9aa6a52fe6c0f50) bttv-risc.c (b7ec3212a73abc987e8f33aa42988e6c39c38c92)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3
4 bttv-risc.c -- interfaces to other kernel modules
5
6 bttv risc code handling
7 - memory management
8 - generation

--- 53 unchanged lines hidden (view full) ---

62 while (skip_lines-- > 0) {
63 *(rp++) = cpu_to_le32(BT848_RISC_SKIP | BT848_RISC_SOL |
64 BT848_RISC_EOL | bpl);
65 }
66
67 /* scan lines */
68 sg = sglist;
69 for (line = 0; line < store_lines; line++) {
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3
4 bttv-risc.c -- interfaces to other kernel modules
5
6 bttv risc code handling
7 - memory management
8 - generation

--- 53 unchanged lines hidden (view full) ---

62 while (skip_lines-- > 0) {
63 *(rp++) = cpu_to_le32(BT848_RISC_SKIP | BT848_RISC_SOL |
64 BT848_RISC_EOL | bpl);
65 }
66
67 /* scan lines */
68 sg = sglist;
69 for (line = 0; line < store_lines; line++) {
70 if ((btv->opt_vcr_hack) &&
71 (line >= (store_lines - VCR_HACK_LINES)))
70 if ((line >= (store_lines - VCR_HACK_LINES)) &&
71 (btv->opt_vcr_hack ||
72 (V4L2_FIELD_HAS_BOTH(btv->field) ||
73 btv->field == V4L2_FIELD_ALTERNATE)))
72 continue;
73 while (offset && offset >= sg_dma_len(sg)) {
74 offset -= sg_dma_len(sg);
75 sg = sg_next(sg);
76 }
77 if (bpl <= sg_dma_len(sg)-offset) {
78 /* fits into current chunk */
79 *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_SOL|

--- 278 unchanged lines hidden (view full) ---

358}
359
360/* ---------------------------------------------------------- */
361/* risc group / risc main loop / dma management */
362
363static void bttv_set_risc_status(struct bttv *btv)
364{
365 unsigned long cmd = BT848_RISC_JUMP;
74 continue;
75 while (offset && offset >= sg_dma_len(sg)) {
76 offset -= sg_dma_len(sg);
77 sg = sg_next(sg);
78 }
79 if (bpl <= sg_dma_len(sg)-offset) {
80 /* fits into current chunk */
81 *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_SOL|

--- 278 unchanged lines hidden (view full) ---

360}
361
362/* ---------------------------------------------------------- */
363/* risc group / risc main loop / dma management */
364
365static void bttv_set_risc_status(struct bttv *btv)
366{
367 unsigned long cmd = BT848_RISC_JUMP;
366 /*
367 * The value of btv->loop_irq sets or resets the RISC_STATUS for video
368 * and/or vbi by setting the value of bits [23:16] in the first dword
369 * of the JUMP instruction:
370 * video risc: set (1) and reset (~1)
371 * vbi risc: set(4) and reset (~4)
372 */
373 if (btv->loop_irq) {
374 cmd |= BT848_RISC_IRQ;
375 cmd |= (btv->loop_irq & 0x0f) << 16;
376 cmd |= (~btv->loop_irq & 0x0f) << 20;
377 }
378 btv->main.cpu[RISC_SLOT_LOOP] = cpu_to_le32(cmd);
379}
380

--- 24 unchanged lines hidden (view full) ---

405 return capctl;
406}
407
408static void bttv_start_dma(struct bttv *btv)
409{
410 if (btv->dma_on)
411 return;
412 btwrite(btv->main.dma, BT848_RISC_STRT_ADD);
368 if (btv->loop_irq) {
369 cmd |= BT848_RISC_IRQ;
370 cmd |= (btv->loop_irq & 0x0f) << 16;
371 cmd |= (~btv->loop_irq & 0x0f) << 20;
372 }
373 btv->main.cpu[RISC_SLOT_LOOP] = cpu_to_le32(cmd);
374}
375

--- 24 unchanged lines hidden (view full) ---

400 return capctl;
401}
402
403static void bttv_start_dma(struct bttv *btv)
404{
405 if (btv->dma_on)
406 return;
407 btwrite(btv->main.dma, BT848_RISC_STRT_ADD);
413 btor(0x3, BT848_GPIO_DMA_CTL);
408 btor(BT848_GPIO_DMA_CTL_RISC_ENABLE | BT848_GPIO_DMA_CTL_FIFO_ENABLE,
409 BT848_GPIO_DMA_CTL);
414 btv->dma_on = 1;
415}
416
417static void bttv_stop_dma(struct bttv *btv)
418{
419 if (!btv->dma_on)
420 return;
410 btv->dma_on = 1;
411}
412
413static void bttv_stop_dma(struct bttv *btv)
414{
415 if (!btv->dma_on)
416 return;
421 btand(~0x3, BT848_GPIO_DMA_CTL);
417 btand(~(BT848_GPIO_DMA_CTL_RISC_ENABLE |
418 BT848_GPIO_DMA_CTL_FIFO_ENABLE), BT848_GPIO_DMA_CTL);
422 btv->dma_on = 0;
423}
424
425void bttv_set_dma(struct bttv *btv, int start_capture)
426{
427 int capctl = 0;
428
429 bttv_set_risc_status(btv);

--- 74 unchanged lines hidden (view full) ---

504 }
505 risc->jmp[0] = cpu_to_le32(cmd);
506 risc->jmp[1] = cpu_to_le32(next);
507 btv->main.cpu[slot+1] = cpu_to_le32(risc->dma);
508 }
509 return 0;
510}
511
419 btv->dma_on = 0;
420}
421
422void bttv_set_dma(struct bttv *btv, int start_capture)
423{
424 int capctl = 0;
425
426 bttv_set_risc_status(btv);

--- 74 unchanged lines hidden (view full) ---

501 }
502 risc->jmp[0] = cpu_to_le32(cmd);
503 risc->jmp[1] = cpu_to_le32(next);
504 btv->main.cpu[slot+1] = cpu_to_le32(risc->dma);
505 }
506 return 0;
507}
508
512void
513bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf)
509int bttv_buffer_risc_vbi(struct bttv *btv, struct bttv_buffer *buf)
514{
510{
515 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
511 int r = 0;
512 unsigned int offset;
513 unsigned int bpl = 2044; /* max. vbipack */
514 unsigned int padding = VBI_BPL - bpl;
515 unsigned int skip_lines0 = 0;
516 unsigned int skip_lines1 = 0;
517 unsigned int min_vdelay = MIN_VDELAY;
516
518
517 videobuf_waiton(q, &buf->vb, 0, 0);
518 videobuf_dma_unmap(q->dev, dma);
519 videobuf_dma_free(dma);
520 btcx_riscmem_free(btv->c.pci,&buf->bottom);
521 btcx_riscmem_free(btv->c.pci,&buf->top);
522 buf->vb.state = VIDEOBUF_NEEDS_INIT;
519 const struct bttv_tvnorm *tvnorm = btv->vbi_fmt.tvnorm;
520 struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vbuf.vb2_buf, 0);
521 struct scatterlist *list = sgt->sgl;
522
523 if (btv->vbi_fmt.fmt.count[0] > 0)
524 skip_lines0 = max(0, (btv->vbi_fmt.fmt.start[0] -
525 tvnorm->vbistart[0]));
526 if (btv->vbi_fmt.fmt.count[1] > 0)
527 skip_lines1 = max(0, (btv->vbi_fmt.fmt.start[1] -
528 tvnorm->vbistart[1]));
529
530 if (btv->vbi_fmt.fmt.count[0] > 0) {
531 r = bttv_risc_packed(btv, &buf->top, list, 0, bpl, padding,
532 skip_lines0, btv->vbi_fmt.fmt.count[0]);
533 if (r)
534 return r;
535 }
536
537 if (btv->vbi_fmt.fmt.count[1] > 0) {
538 offset = btv->vbi_fmt.fmt.count[0] * VBI_BPL;
539 r = bttv_risc_packed(btv, &buf->bottom, list, offset, bpl,
540 padding, skip_lines1,
541 btv->vbi_fmt.fmt.count[1]);
542 if (r)
543 return r;
544 }
545
546 if (btv->vbi_fmt.end >= tvnorm->cropcap.bounds.top)
547 min_vdelay += btv->vbi_fmt.end - tvnorm->cropcap.bounds.top;
548
549 /* For bttv_buffer_activate_vbi(). */
550 buf->geo.vdelay = min_vdelay;
551
552 return r;
523}
524
525int
526bttv_buffer_activate_vbi(struct bttv *btv,
527 struct bttv_buffer *vbi)
528{
529 struct btcx_riscmem *top;
530 struct btcx_riscmem *bottom;
531 int top_irq_flags;
532 int bottom_irq_flags;
533
534 top = NULL;
535 bottom = NULL;
536 top_irq_flags = 0;
537 bottom_irq_flags = 0;
538
539 if (vbi) {
540 unsigned int crop, vdelay;
541
553}
554
555int
556bttv_buffer_activate_vbi(struct bttv *btv,
557 struct bttv_buffer *vbi)
558{
559 struct btcx_riscmem *top;
560 struct btcx_riscmem *bottom;
561 int top_irq_flags;
562 int bottom_irq_flags;
563
564 top = NULL;
565 bottom = NULL;
566 top_irq_flags = 0;
567 bottom_irq_flags = 0;
568
569 if (vbi) {
570 unsigned int crop, vdelay;
571
542 vbi->vb.state = VIDEOBUF_ACTIVE;
543 list_del(&vbi->vb.queue);
572 list_del(&vbi->list);
544
545 /* VDELAY is start of video, end of VBI capturing. */
546 crop = btread(BT848_E_CROP);
547 vdelay = btread(BT848_E_VDELAY_LO) + ((crop & 0xc0) << 2);
548
549 if (vbi->geo.vdelay > vdelay) {
550 vdelay = vbi->geo.vdelay & 0xfe;
551 crop = (crop & 0x3f) | ((vbi->geo.vdelay >> 2) & 0xc0);

--- 24 unchanged lines hidden (view full) ---

576
577int
578bttv_buffer_activate_video(struct bttv *btv,
579 struct bttv_buffer_set *set)
580{
581 /* video capture */
582 if (NULL != set->top && NULL != set->bottom) {
583 if (set->top == set->bottom) {
573
574 /* VDELAY is start of video, end of VBI capturing. */
575 crop = btread(BT848_E_CROP);
576 vdelay = btread(BT848_E_VDELAY_LO) + ((crop & 0xc0) << 2);
577
578 if (vbi->geo.vdelay > vdelay) {
579 vdelay = vbi->geo.vdelay & 0xfe;
580 crop = (crop & 0x3f) | ((vbi->geo.vdelay >> 2) & 0xc0);

--- 24 unchanged lines hidden (view full) ---

605
606int
607bttv_buffer_activate_video(struct bttv *btv,
608 struct bttv_buffer_set *set)
609{
610 /* video capture */
611 if (NULL != set->top && NULL != set->bottom) {
612 if (set->top == set->bottom) {
584 set->top->vb.state = VIDEOBUF_ACTIVE;
585 if (set->top->vb.queue.next)
586 list_del(&set->top->vb.queue);
613 if (set->top->list.next)
614 list_del(&set->top->list);
587 } else {
615 } else {
588 set->top->vb.state = VIDEOBUF_ACTIVE;
589 set->bottom->vb.state = VIDEOBUF_ACTIVE;
590 if (set->top->vb.queue.next)
591 list_del(&set->top->vb.queue);
592 if (set->bottom->vb.queue.next)
593 list_del(&set->bottom->vb.queue);
616 if (set->top->list.next)
617 list_del(&set->top->list);
618 if (set->bottom->list.next)
619 list_del(&set->bottom->list);
594 }
595 bttv_apply_geo(btv, &set->top->geo, 1);
596 bttv_apply_geo(btv, &set->bottom->geo,0);
597 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top,
598 set->top_irq);
599 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom,
600 set->frame_irq);
601 btaor((set->top->btformat & 0xf0) | (set->bottom->btformat & 0x0f),
602 ~0xff, BT848_COLOR_FMT);
603 btaor((set->top->btswap & 0x0a) | (set->bottom->btswap & 0x05),
604 ~0x0f, BT848_COLOR_CTL);
605 } else if (NULL != set->top) {
620 }
621 bttv_apply_geo(btv, &set->top->geo, 1);
622 bttv_apply_geo(btv, &set->bottom->geo,0);
623 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top,
624 set->top_irq);
625 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom,
626 set->frame_irq);
627 btaor((set->top->btformat & 0xf0) | (set->bottom->btformat & 0x0f),
628 ~0xff, BT848_COLOR_FMT);
629 btaor((set->top->btswap & 0x0a) | (set->bottom->btswap & 0x05),
630 ~0x0f, BT848_COLOR_CTL);
631 } else if (NULL != set->top) {
606 set->top->vb.state = VIDEOBUF_ACTIVE;
607 if (set->top->vb.queue.next)
608 list_del(&set->top->vb.queue);
632 if (set->top->list.next)
633 list_del(&set->top->list);
609 bttv_apply_geo(btv, &set->top->geo,1);
610 bttv_apply_geo(btv, &set->top->geo,0);
611 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top,
612 set->frame_irq);
613 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, NULL, 0);
614 btaor(set->top->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
615 btaor(set->top->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL);
616 } else if (NULL != set->bottom) {
634 bttv_apply_geo(btv, &set->top->geo,1);
635 bttv_apply_geo(btv, &set->top->geo,0);
636 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top,
637 set->frame_irq);
638 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, NULL, 0);
639 btaor(set->top->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
640 btaor(set->top->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL);
641 } else if (NULL != set->bottom) {
617 set->bottom->vb.state = VIDEOBUF_ACTIVE;
618 if (set->bottom->vb.queue.next)
619 list_del(&set->bottom->vb.queue);
642 if (set->bottom->list.next)
643 list_del(&set->bottom->list);
620 bttv_apply_geo(btv, &set->bottom->geo,1);
621 bttv_apply_geo(btv, &set->bottom->geo,0);
622 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
623 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom,
624 set->frame_irq);
625 btaor(set->bottom->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
626 btaor(set->bottom->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL);
627 } else {

--- 4 unchanged lines hidden (view full) ---

632}
633
634/* ---------------------------------------------------------- */
635
636/* calculate geometry, build risc code */
637int
638bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
639{
644 bttv_apply_geo(btv, &set->bottom->geo,1);
645 bttv_apply_geo(btv, &set->bottom->geo,0);
646 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
647 bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom,
648 set->frame_irq);
649 btaor(set->bottom->btformat & 0xff, ~0xff, BT848_COLOR_FMT);
650 btaor(set->bottom->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL);
651 } else {

--- 4 unchanged lines hidden (view full) ---

656}
657
658/* ---------------------------------------------------------- */
659
660/* calculate geometry, build risc code */
661int
662bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
663{
664 int r = 0;
640 const struct bttv_tvnorm *tvnorm = bttv_tvnorms + btv->tvnorm;
665 const struct bttv_tvnorm *tvnorm = bttv_tvnorms + btv->tvnorm;
641 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
666 struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vbuf.vb2_buf, 0);
667 struct scatterlist *list = sgt->sgl;
668 unsigned long size = (btv->fmt->depth * btv->width * btv->height) >> 3;
642
669
643 dprintk("%d: buffer field: %s format: 0x%08x size: %dx%d\n",
644 btv->c.nr, v4l2_field_names[buf->vb.field],
645 btv->fmt->fourcc, buf->vb.width, buf->vb.height);
646
647 /* packed pixel modes */
648 if (btv->fmt->flags & FORMAT_FLAGS_PACKED) {
670 /* packed pixel modes */
671 if (btv->fmt->flags & FORMAT_FLAGS_PACKED) {
649 int bpl = (btv->fmt->depth >> 3) * buf->vb.width;
650 int bpf = bpl * (buf->vb.height >> 1);
672 int bpl = (btv->fmt->depth >> 3) * btv->width;
673 int bpf = bpl * (btv->height >> 1);
651
674
652 bttv_calc_geo(btv,&buf->geo,buf->vb.width,buf->vb.height,
653 V4L2_FIELD_HAS_BOTH(buf->vb.field),
654 tvnorm, &btv->crop[!!btv->do_crop].rect);
655
656 switch (buf->vb.field) {
675 bttv_calc_geo(btv, &buf->geo, btv->width, btv->height,
676 V4L2_FIELD_HAS_BOTH(buf->vbuf.field), tvnorm,
677 &btv->crop[!!btv->do_crop].rect);
678 switch (buf->vbuf.field) {
657 case V4L2_FIELD_TOP:
679 case V4L2_FIELD_TOP:
658 bttv_risc_packed(btv,&buf->top,dma->sglist,
659 /* offset */ 0,bpl,
660 /* padding */ 0,/* skip_lines */ 0,
661 buf->vb.height);
680 r = bttv_risc_packed(btv, &buf->top, list, 0, bpl, 0,
681 0, btv->height);
662 break;
663 case V4L2_FIELD_BOTTOM:
682 break;
683 case V4L2_FIELD_BOTTOM:
664 bttv_risc_packed(btv,&buf->bottom,dma->sglist,
665 0,bpl,0,0,buf->vb.height);
684 r = bttv_risc_packed(btv, &buf->bottom, list, 0, bpl,
685 0, 0, btv->height);
666 break;
667 case V4L2_FIELD_INTERLACED:
686 break;
687 case V4L2_FIELD_INTERLACED:
668 bttv_risc_packed(btv,&buf->top,dma->sglist,
669 0,bpl,bpl,0,buf->vb.height >> 1);
670 bttv_risc_packed(btv,&buf->bottom,dma->sglist,
671 bpl,bpl,bpl,0,buf->vb.height >> 1);
688 r = bttv_risc_packed(btv, &buf->top, list, 0, bpl,
689 bpl, 0, btv->height >> 1);
690 r = bttv_risc_packed(btv, &buf->bottom, list, bpl,
691 bpl, bpl, 0, btv->height >> 1);
672 break;
673 case V4L2_FIELD_SEQ_TB:
692 break;
693 case V4L2_FIELD_SEQ_TB:
674 bttv_risc_packed(btv,&buf->top,dma->sglist,
675 0,bpl,0,0,buf->vb.height >> 1);
676 bttv_risc_packed(btv,&buf->bottom,dma->sglist,
677 bpf,bpl,0,0,buf->vb.height >> 1);
694 r = bttv_risc_packed(btv, &buf->top, list, 0, bpl, 0,
695 0, btv->height >> 1);
696 r = bttv_risc_packed(btv, &buf->bottom, list, bpf,
697 bpl, 0, 0, btv->height >> 1);
678 break;
679 default:
680 WARN_ON(1);
698 break;
699 default:
700 WARN_ON(1);
701 return -EINVAL;
681 }
682 }
702 }
703 }
683
684 /* planar modes */
685 if (btv->fmt->flags & FORMAT_FLAGS_PLANAR) {
686 int uoffset, voffset;
687 int ypadding, cpadding, lines;
688
689 /* calculate chroma offsets */
704 /* planar modes */
705 if (btv->fmt->flags & FORMAT_FLAGS_PLANAR) {
706 int uoffset, voffset;
707 int ypadding, cpadding, lines;
708
709 /* calculate chroma offsets */
690 uoffset = buf->vb.width * buf->vb.height;
691 voffset = buf->vb.width * buf->vb.height;
710 uoffset = btv->width * btv->height;
711 voffset = btv->width * btv->height;
692 if (btv->fmt->flags & FORMAT_FLAGS_CrCb) {
693 /* Y-Cr-Cb plane order */
694 uoffset >>= btv->fmt->hshift;
695 uoffset >>= btv->fmt->vshift;
696 uoffset += voffset;
697 } else {
698 /* Y-Cb-Cr plane order */
699 voffset >>= btv->fmt->hshift;
700 voffset >>= btv->fmt->vshift;
701 voffset += uoffset;
702 }
712 if (btv->fmt->flags & FORMAT_FLAGS_CrCb) {
713 /* Y-Cr-Cb plane order */
714 uoffset >>= btv->fmt->hshift;
715 uoffset >>= btv->fmt->vshift;
716 uoffset += voffset;
717 } else {
718 /* Y-Cb-Cr plane order */
719 voffset >>= btv->fmt->hshift;
720 voffset >>= btv->fmt->vshift;
721 voffset += uoffset;
722 }
703
704 switch (buf->vb.field) {
723 switch (buf->vbuf.field) {
705 case V4L2_FIELD_TOP:
724 case V4L2_FIELD_TOP:
706 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
707 buf->vb.height,/* both_fields */ 0,
708 tvnorm, &btv->crop[!!btv->do_crop].rect);
709 bttv_risc_planar(btv, &buf->top, dma->sglist,
710 0,buf->vb.width,0,buf->vb.height,
711 uoffset, voffset, btv->fmt->hshift,
712 btv->fmt->vshift, 0);
725 bttv_calc_geo(btv, &buf->geo, btv->width, btv->height,
726 0, tvnorm,
727 &btv->crop[!!btv->do_crop].rect);
728 r = bttv_risc_planar(btv, &buf->top, list, 0,
729 btv->width, 0, btv->height,
730 uoffset, voffset,
731 btv->fmt->hshift,
732 btv->fmt->vshift, 0);
713 break;
714 case V4L2_FIELD_BOTTOM:
733 break;
734 case V4L2_FIELD_BOTTOM:
715 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
716 buf->vb.height,0,
717 tvnorm, &btv->crop[!!btv->do_crop].rect);
718 bttv_risc_planar(btv, &buf->bottom, dma->sglist,
719 0,buf->vb.width,0,buf->vb.height,
720 uoffset, voffset, btv->fmt->hshift,
721 btv->fmt->vshift, 0);
735 bttv_calc_geo(btv, &buf->geo, btv->width, btv->height,
736 0, tvnorm,
737 &btv->crop[!!btv->do_crop].rect);
738 r = bttv_risc_planar(btv, &buf->bottom, list, 0,
739 btv->width, 0, btv->height,
740 uoffset, voffset,
741 btv->fmt->hshift,
742 btv->fmt->vshift, 0);
722 break;
723 case V4L2_FIELD_INTERLACED:
743 break;
744 case V4L2_FIELD_INTERLACED:
724 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
725 buf->vb.height,1,
726 tvnorm, &btv->crop[!!btv->do_crop].rect);
727 lines = buf->vb.height >> 1;
728 ypadding = buf->vb.width;
729 cpadding = buf->vb.width >> btv->fmt->hshift;
730 bttv_risc_planar(btv,&buf->top,
731 dma->sglist,
732 0,buf->vb.width,ypadding,lines,
733 uoffset,voffset,
734 btv->fmt->hshift,
735 btv->fmt->vshift,
736 cpadding);
737 bttv_risc_planar(btv,&buf->bottom,
738 dma->sglist,
739 ypadding,buf->vb.width,ypadding,lines,
740 uoffset+cpadding,
741 voffset+cpadding,
742 btv->fmt->hshift,
743 btv->fmt->vshift,
744 cpadding);
745 bttv_calc_geo(btv, &buf->geo, btv->width, btv->height,
746 1, tvnorm,
747 &btv->crop[!!btv->do_crop].rect);
748 lines = btv->height >> 1;
749 ypadding = btv->width;
750 cpadding = btv->width >> btv->fmt->hshift;
751 r = bttv_risc_planar(btv, &buf->top, list, 0,
752 btv->width, ypadding, lines,
753 uoffset, voffset,
754 btv->fmt->hshift,
755 btv->fmt->vshift, cpadding);
756
757 r = bttv_risc_planar(btv, &buf->bottom, list,
758 ypadding, btv->width, ypadding,
759 lines, uoffset + cpadding,
760 voffset + cpadding,
761 btv->fmt->hshift,
762 btv->fmt->vshift, cpadding);
745 break;
746 case V4L2_FIELD_SEQ_TB:
763 break;
764 case V4L2_FIELD_SEQ_TB:
747 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
748 buf->vb.height,1,
749 tvnorm, &btv->crop[!!btv->do_crop].rect);
750 lines = buf->vb.height >> 1;
751 ypadding = buf->vb.width;
752 cpadding = buf->vb.width >> btv->fmt->hshift;
753 bttv_risc_planar(btv,&buf->top,
754 dma->sglist,
755 0,buf->vb.width,0,lines,
756 uoffset >> 1,
757 voffset >> 1,
758 btv->fmt->hshift,
759 btv->fmt->vshift,
760 0);
761 bttv_risc_planar(btv,&buf->bottom,
762 dma->sglist,
763 lines * ypadding,buf->vb.width,0,lines,
764 lines * ypadding + (uoffset >> 1),
765 lines * ypadding + (voffset >> 1),
766 btv->fmt->hshift,
767 btv->fmt->vshift,
768 0);
765 bttv_calc_geo(btv, &buf->geo, btv->width, btv->height,
766 1, tvnorm,
767 &btv->crop[!!btv->do_crop].rect);
768 lines = btv->height >> 1;
769 ypadding = btv->width;
770 cpadding = btv->width >> btv->fmt->hshift;
771 r = bttv_risc_planar(btv, &buf->top, list, 0,
772 btv->width, 0, lines,
773 uoffset >> 1, voffset >> 1,
774 btv->fmt->hshift,
775 btv->fmt->vshift, 0);
776 r = bttv_risc_planar(btv, &buf->bottom, list,
777 lines * ypadding,
778 btv->width, 0, lines,
779 lines * ypadding + (uoffset >> 1),
780 lines * ypadding + (voffset >> 1),
781 btv->fmt->hshift,
782 btv->fmt->vshift, 0);
769 break;
770 default:
771 WARN_ON(1);
783 break;
784 default:
785 WARN_ON(1);
786 return -EINVAL;
772 }
773 }
787 }
788 }
774
775 /* raw data */
776 if (btv->fmt->flags & FORMAT_FLAGS_RAW) {
777 /* build risc code */
789 /* raw data */
790 if (btv->fmt->flags & FORMAT_FLAGS_RAW) {
791 /* build risc code */
778 buf->vb.field = V4L2_FIELD_SEQ_TB;
779 bttv_calc_geo(btv,&buf->geo,tvnorm->swidth,tvnorm->sheight,
792 buf->vbuf.field = V4L2_FIELD_SEQ_TB;
793 bttv_calc_geo(btv, &buf->geo, tvnorm->swidth, tvnorm->sheight,
780 1, tvnorm, &btv->crop[!!btv->do_crop].rect);
794 1, tvnorm, &btv->crop[!!btv->do_crop].rect);
781 bttv_risc_packed(btv, &buf->top, dma->sglist,
782 /* offset */ 0, RAW_BPL, /* padding */ 0,
783 /* skip_lines */ 0, RAW_LINES);
784 bttv_risc_packed(btv, &buf->bottom, dma->sglist,
785 buf->vb.size/2 , RAW_BPL, 0, 0, RAW_LINES);
795 r = bttv_risc_packed(btv, &buf->top, list, 0, RAW_BPL, 0, 0,
796 RAW_LINES);
797 r = bttv_risc_packed(btv, &buf->bottom, list, size / 2,
798 RAW_BPL, 0, 0, RAW_LINES);
786 }
787
788 /* copy format info */
789 buf->btformat = btv->fmt->btformat;
790 buf->btswap = btv->fmt->btswap;
799 }
800
801 /* copy format info */
802 buf->btformat = btv->fmt->btformat;
803 buf->btswap = btv->fmt->btswap;
791 return 0;
804
805 return r;
792}
806}