comparison vidix/drivers/mach64_vid.c @ 4769:75a701b39d61

BGR15, BGR16, BGR32 support
author michael
date Wed, 20 Feb 2002 17:23:00 +0000
parents bc69f5fc18fe
children 75f2935e9984
comparison
equal deleted inserted replaced
4768:a64075b4970a 4769:75a701b39d61
532 532
533 mach64_wait_for_idle(); 533 mach64_wait_for_idle();
534 vf = INREG(VIDEO_FORMAT); 534 vf = INREG(VIDEO_FORMAT);
535 535
536 // Bits 16-19 seem to select the format 536 // Bits 16-19 seem to select the format
537 // Bit 28 seems to toggle something affects luma & chroma 537 // 0x0 dunno behaves strange
538 // 0x1 dunno behaves strange
539 // 0x2 dunno behaves strange
540 // 0x3 BGR15
541 // 0x4 BGR16
542 // 0x5 BGR16 (hmm, that need investigation, 2 BGR16 formats, i guess 1 will have only 5bits for green)
543 // 0x6 BGR32
544 // 0x7 BGR32 with somehow mixed even / odd pixels ?
545 // 0x8 YYYYUVUV
546 // 0x9 YVU9
547 // 0xA YV12
548 // 0xB YUY2
549 // 0xC UYVY
550 // 0xD UYVY (not again ... dont ask me, i dunno the difference)
551 // 0xE dunno behaves strange
552 // 0xF dunno behaves strange
553 // Bit 28 all values are assumed to be 7 bit with chroma=64 for black (tested with YV12 & YUY2)
538 // the remaining bits seem to have no effect 554 // the remaining bits seem to have no effect
555
539 556
540 switch(besr.fourcc) 557 switch(besr.fourcc)
541 { 558 {
559 /* BGR formats */
560 case IMGFMT_BGR15: OUTREG(VIDEO_FORMAT, 0x00030000); break;
561 case IMGFMT_BGR16: OUTREG(VIDEO_FORMAT, 0x00040000); break;
562 case IMGFMT_BGR32: OUTREG(VIDEO_FORMAT, 0x00060000); break;
542 /* 4:2:0 */ 563 /* 4:2:0 */
543 case IMGFMT_IYUV: 564 case IMGFMT_IYUV:
544 case IMGFMT_I420: 565 case IMGFMT_I420:
545 case IMGFMT_YV12: OUTREG(VIDEO_FORMAT, (vf & ~0xF0000) | 0xA0000); break; 566 case IMGFMT_YV12: OUTREG(VIDEO_FORMAT, 0x000A0000); break;
546 /* 4:2:2 */ 567 /* 4:2:2 */
547 case IMGFMT_YVYU: 568 case IMGFMT_YVYU:
548 case IMGFMT_UYVY: OUTREG(VIDEO_FORMAT, (vf & ~0xF0000) | 0xC0000); break; 569 case IMGFMT_UYVY: OUTREG(VIDEO_FORMAT, 0x000C0000); break;
549 case IMGFMT_YUY2: 570 case IMGFMT_YUY2:
550 default: OUTREG(VIDEO_FORMAT, (vf & ~0xF0000) | 0xB0000); break; 571 default: OUTREG(VIDEO_FORMAT, 0x000B0000); break;
551 } 572 }
552 if(__verbose > VERBOSE_LEVEL) mach64_vid_dump_regs(); 573 if(__verbose > VERBOSE_LEVEL) mach64_vid_dump_regs();
553 } 574 }
554 575
555 static int mach64_vid_init_video( vidix_playback_t *config ) 576 static int mach64_vid_init_video( vidix_playback_t *config )
574 case IMGFMT_YV12: 595 case IMGFMT_YV12:
575 case IMGFMT_I420: pitch = (src_w + mpitch) & ~mpitch; 596 case IMGFMT_I420: pitch = (src_w + mpitch) & ~mpitch;
576 config->dest.pitch.y = 597 config->dest.pitch.y =
577 config->dest.pitch.u = 598 config->dest.pitch.u =
578 config->dest.pitch.v = best_pitch; 599 config->dest.pitch.v = best_pitch;
600 besr.vid_buf_pitch= pitch;
579 break; 601 break;
580 /* RGB 4:4:4:4 */ 602 /* RGB 4:4:4:4 */
581 case IMGFMT_RGB32: 603 case IMGFMT_RGB32:
582 case IMGFMT_BGR32: pitch = (src_w*4 + mpitch) & ~mpitch; 604 case IMGFMT_BGR32: pitch = (src_w*4 + mpitch) & ~mpitch;
583 config->dest.pitch.y = 605 config->dest.pitch.y =
584 config->dest.pitch.u = 606 config->dest.pitch.u =
585 config->dest.pitch.v = best_pitch; 607 config->dest.pitch.v = best_pitch;
608 besr.vid_buf_pitch= pitch>>2;
586 break; 609 break;
587 /* 4:2:2 */ 610 /* 4:2:2 */
588 default: /* RGB15, RGB16, YVYU, UYVY, YUY2 */ 611 default: /* RGB15, RGB16, YVYU, UYVY, YUY2 */
589 pitch = ((src_w*2) + mpitch) & ~mpitch; 612 pitch = ((src_w*2) + mpitch) & ~mpitch;
590 config->dest.pitch.y = 613 config->dest.pitch.y =
591 config->dest.pitch.u = 614 config->dest.pitch.u =
592 config->dest.pitch.v = best_pitch; 615 config->dest.pitch.v = best_pitch;
616 besr.vid_buf_pitch= pitch>>1;
593 break; 617 break;
594 } 618 }
595 dest_w = config->dest.w; 619 dest_w = config->dest.w;
596 dest_h = config->dest.h; 620 dest_h = config->dest.h;
597 besr.fourcc = config->fourcc; 621 besr.fourcc = config->fourcc;
658 if(mach64_is_dbl_scan()) y_pos*=2; 682 if(mach64_is_dbl_scan()) y_pos*=2;
659 else 683 else
660 if(mach64_is_interlace()) y_pos/=2; 684 if(mach64_is_interlace()) y_pos/=2;
661 besr.y_x_end = y_pos | ((config->dest.x + dest_w) << 16); 685 besr.y_x_end = y_pos | ((config->dest.x + dest_w) << 16);
662 besr.height_width = ((src_w - left)<<16) | (src_h - top); 686 besr.height_width = ((src_w - left)<<16) | (src_h - top);
663 besr.vid_buf_pitch = is_420 ? pitch : pitch/2; 687
664 return 0; 688 return 0;
665 } 689 }
666 690
667 691
668 uint32_t supported_fourcc[] = 692 uint32_t supported_fourcc[] =
669 { 693 {
670 IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, 694 IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV,
671 IMGFMT_UYVY, IMGFMT_YUY2, IMGFMT_YVYU 695 IMGFMT_UYVY, IMGFMT_YUY2, IMGFMT_YVYU,
696 IMGFMT_BGR15,IMGFMT_BGR16,IMGFMT_BGR32
672 }; 697 };
673 698
674 __inline__ static int is_supported_fourcc(uint32_t fourcc) 699 __inline__ static int is_supported_fourcc(uint32_t fourcc)
675 { 700 {
676 unsigned i; 701 unsigned i;
752 off[1] = besr.vid_buf1_base_adrs; 777 off[1] = besr.vid_buf1_base_adrs;
753 off[2] = besr.vid_buf2_base_adrs; 778 off[2] = besr.vid_buf2_base_adrs;
754 off[3] = besr.vid_buf3_base_adrs; 779 off[3] = besr.vid_buf3_base_adrs;
755 off[4] = besr.vid_buf4_base_adrs; 780 off[4] = besr.vid_buf4_base_adrs;
756 off[5] = besr.vid_buf5_base_adrs; 781 off[5] = besr.vid_buf5_base_adrs;
782 #if 0 // debuging code, can be removed
783 {
784 int x,y;
785 char *buf0= (char *)mach64_mem_base + mach64_overlay_offset;
786 char *buf1= (char *)mach64_mem_base + mach64_overlay_offset;
787 char *buf2= (char *)mach64_mem_base + mach64_overlay_offset;
788 buf0 += ((besr.vid_buf0_base_adrs)&~15) - mach64_overlay_offset;
789 buf1 += ((besr.vid_buf1_base_adrs)&~15) - mach64_overlay_offset;
790 buf2 += ((besr.vid_buf2_base_adrs)&~15) - mach64_overlay_offset;
791 /*for(y=0; y<480/4; y++)
792 {
793 for(x=0; x<640/4; x++)
794 {
795 buf1[x + y*160]= 0; // buf1[2*x + y*160*4];
796 buf2[x + y*160]= 0; //buf2[2*x + y*160*4];
797 }
798 }*/
799 /*)for(y=479; y>0; y--)
800 {
801 for(x=0; x<640; x++)
802 {
803 buf0[x*2 + y*1280+1]=
804 buf0[x*2 + y*1280]= buf0[x + y*640];
805 }
806 }*/
807 for(y=0; y<480; y++)
808 {
809 // for(x=0; x<1280; x++) buf0[x + y*1280]=0;
810 for(x=0; x<1280/4; x++)
811 {
812 // 1-> gray0
813 // buf0[x*2 + y*1280 +0] ^= buf0[x*2 + y*1280 +1];
814 // buf0[x*2 + y*1280 +1] ^= buf0[x*2 + y*1280 +0];
815 // buf0[x*2 + y*1280 +0] ^= buf0[x*2 + y*1280 +1];
816
817 buf0[x*4 + y*1280 +1] =x; //buf0[x*4 + y*1280 +0]>>1;
818 buf0[x*4 + y*1280 +3] =128; //buf0[x*4 + y*1280 +2]>>1;
819 buf0[x*4 + y*1280 +0] =128;
820 buf0[x*4 + y*1280 +2] =128;
821
822 // buf0[x*8 + y*1280 +0]= 1;
823 // buf0[x*2 + y*1280 +1]= 7;
824 // buf0[x*2 + y*1280+6 ]= 255;
825 }
826 // Y, Y, Y, Y, U, V, U, V
827 }
828 /*for(y=0; y<480; y++)
829 {
830 // for(x=0; x<1280; x++) buf0[x + y*1280]=128;
831 for(x=0; x<640; x++)
832 {
833 buf0[x + y*640 ]>>=1;
834 buf0[x + y*640 ]|=128;
835 }
836 }
837 for(y=0; y<480/2; y++)
838 {
839 // for(x=0; x<1280; x++) buf0[x + y*1280]=128;
840 for(x=0; x<640/2; x++)
841 {
842 buf1[x + y*320 ]>>=1;
843 buf2[x + y*320 ]>>=1;
844 }
845 }*/
846 }
847 #endif
757 } 848 }
758 849
759 mach64_wait_vsync(); 850 mach64_wait_vsync();
760 mach64_wait_for_idle(); 851 mach64_wait_for_idle();
761 mach64_fifo_wait(7); 852 mach64_fifo_wait(7);