Mercurial > mplayer.hg
comparison libvo/vo_fbdev.c @ 633:bdaa6d334d01
some cleanup
author | szabii |
---|---|
date | Wed, 25 Apr 2001 12:19:46 +0000 |
parents | b105a9f2bbe7 |
children | ae02d4734ad6 |
comparison
equal
deleted
inserted
replaced
632:10c3c3e0307e | 633:bdaa6d334d01 |
---|---|
23 #include <linux/vt.h> | 23 #include <linux/vt.h> |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "video_out.h" | 26 #include "video_out.h" |
27 #include "video_out_internal.h" | 27 #include "video_out_internal.h" |
28 | |
29 #include "osd.h" | |
30 #include "sub.h" | |
28 | 31 |
29 #include "yuv2rgb.h" | 32 #include "yuv2rgb.h" |
30 extern void rgb15to16_mmx(char *s0, char *d0, int count); | 33 extern void rgb15to16_mmx(char *s0, char *d0, int count); |
31 | 34 |
32 #include "fastmemcpy.h" | 35 #include "fastmemcpy.h" |
706 | 709 |
707 for (i = 0; i < out_height; i++, offset += fb_screen_width) | 710 for (i = 0; i < out_height; i++, offset += fb_screen_width) |
708 memset(frame_buffer + offset, 0x0, out_width * fb_pixel_size); | 711 memset(frame_buffer + offset, 0x0, out_width * fb_pixel_size); |
709 } | 712 } |
710 | 713 |
711 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, | 714 static void lots_of_printf(void) |
712 uint32_t d_height, uint32_t fullscreen, char *title, | 715 { |
713 uint32_t format) | |
714 { | |
715 #define FS (fullscreen & 0x01) | |
716 #define VM (fullscreen & 0x02) | |
717 #define ZOOM (fullscreen & 0x04) | |
718 | |
719 struct fb_cmap *cmap; | |
720 | |
721 if (!fb_preinit_done) | |
722 if (fb_preinit()) | |
723 return 1; | |
724 if (!fb_works) | |
725 return 1; | |
726 | |
727 if (ZOOM) { | |
728 printf(FBDEV "-zoom is not supported\n"); | |
729 return 1; | |
730 } | |
731 if (fb_mode_name && !VM) { | |
732 printf(FBDEV "-fbmode can be used only with -vm" | |
733 " (is it the right behaviour?)\n"); | |
734 return 1; | |
735 } | |
736 if (VM) | |
737 if (parse_fbmode_cfg(fb_mode_cfgfile) < 0) | |
738 return 1; | |
739 if ((!d_width + !d_height) == 1) { | |
740 printf(FBDEV "use both -x and -y, or none of them\n"); | |
741 return 1; | |
742 } | |
743 if (d_width) { | |
744 out_width = d_width; | |
745 out_height = d_height; | |
746 } else { | |
747 out_width = width; | |
748 out_height = height; | |
749 } | |
750 in_width = width; | |
751 in_height = height; | |
752 pixel_format = format; | |
753 | |
754 if (fb_mode_name) { | |
755 if (!(fb_mode = find_mode_by_name(fb_mode_name))) { | |
756 printf(FBDEV "can't find requested video mode\n"); | |
757 return 1; | |
758 } | |
759 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); | |
760 } else if (VM) { | |
761 monitor_hfreq = str2range(monitor_hfreq_str); | |
762 monitor_vfreq = str2range(monitor_vfreq_str); | |
763 monitor_dotclock = str2range(monitor_dotclock_str); | |
764 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { | |
765 printf(FBDEV "you have to specify the capabilities of" | |
766 " the monitor.\n"); | |
767 return 1; | |
768 } | |
769 if (!(fb_mode = find_best_mode(out_width, out_height, | |
770 monitor_hfreq, monitor_vfreq, | |
771 monitor_dotclock))) { | |
772 printf(FBDEV "can't find best video mode\n"); | |
773 return 1; | |
774 } | |
775 printf(FBDEV "using mode %dx%d @ %.1fHz\n", fb_mode->xres, | |
776 fb_mode->yres, vsf(fb_mode)); | |
777 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); | |
778 } | |
779 fb_bpp_we_want = fb_bpp; | |
780 set_bpp(&fb_vinfo, fb_bpp); | |
781 fb_vinfo.xres_virtual = fb_vinfo.xres; | |
782 fb_vinfo.yres_virtual = fb_vinfo.yres; | |
783 | |
784 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { | |
785 printf(FBDEV "Can't put VSCREENINFO: %s\n", strerror(errno)); | |
786 return 1; | |
787 } | |
788 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) { | |
789 printf(FBDEV "Can't get FSCREENINFO: %s\n", strerror(errno)); | |
790 return 1; | |
791 } | |
792 #if 0 | |
793 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { | |
794 printf(FBDEV "Can't get VSCREENINFO: %s\n", strerror(errno)); | |
795 return 1; | |
796 } | |
797 #endif | |
798 | |
799 if (verbose > 0) { | 716 if (verbose > 0) { |
800 printf(FBDEV "var info:\n"); | 717 printf(FBDEV "var info:\n"); |
801 printf(FBDEV "xres: %u\n", fb_vinfo.xres); | 718 printf(FBDEV "xres: %u\n", fb_vinfo.xres); |
802 printf(FBDEV "yres: %u\n", fb_vinfo.yres); | 719 printf(FBDEV "yres: %u\n", fb_vinfo.yres); |
803 printf(FBDEV "xres_virtual: %u\n", fb_vinfo.xres_virtual); | 720 printf(FBDEV "xres_virtual: %u\n", fb_vinfo.xres_virtual); |
854 printf(FBDEV "mmio_start: %p\n", (void *) fb_finfo.mmio_start); | 771 printf(FBDEV "mmio_start: %p\n", (void *) fb_finfo.mmio_start); |
855 printf(FBDEV "mmio_len: %u bytes\n", fb_finfo.mmio_len); | 772 printf(FBDEV "mmio_len: %u bytes\n", fb_finfo.mmio_len); |
856 printf(FBDEV "accel: %u\n", fb_finfo.accel); | 773 printf(FBDEV "accel: %u\n", fb_finfo.accel); |
857 } | 774 } |
858 } | 775 } |
859 | 776 } |
860 switch (fb_finfo.type) { | 777 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, |
861 case FB_TYPE_VGA_PLANES: | 778 uint32_t d_height, uint32_t fullscreen, char *title, |
862 printf(FBDEV "FB_TYPE_VGA_PLANES not supported.\n"); | 779 uint32_t format) |
780 { | |
781 #define FS (fullscreen & 0x01) | |
782 #define VM (fullscreen & 0x02) | |
783 #define ZOOM (fullscreen & 0x04) | |
784 | |
785 struct fb_cmap *cmap; | |
786 | |
787 if (!fb_preinit_done) | |
788 if (fb_preinit()) | |
863 return 1; | 789 return 1; |
864 case FB_TYPE_PLANES: | 790 if (!fb_works) |
865 printf(FBDEV "FB_TYPE_PLANES not supported.\n"); | 791 return 1; |
792 | |
793 if (ZOOM) { | |
794 printf(FBDEV "-zoom is not supported\n"); | |
795 return 1; | |
796 } | |
797 if (fb_mode_name && !VM) { | |
798 printf(FBDEV "-fbmode can be used only with -vm" | |
799 " (is it the right behaviour?)\n"); | |
800 return 1; | |
801 } | |
802 if (VM) | |
803 if (parse_fbmode_cfg(fb_mode_cfgfile) < 0) | |
866 return 1; | 804 return 1; |
867 case FB_TYPE_INTERLEAVED_PLANES: | 805 if ((!d_width + !d_height) == 1) { |
868 printf(FBDEV "FB_TYPE_INTERLEAVED_PLANES not supported.\n"); | 806 printf(FBDEV "use both -x and -y, or none of them\n"); |
807 return 1; | |
808 } | |
809 if (d_width) { | |
810 out_width = d_width; | |
811 out_height = d_height; | |
812 } else { | |
813 out_width = width; | |
814 out_height = height; | |
815 } | |
816 in_width = width; | |
817 in_height = height; | |
818 pixel_format = format; | |
819 | |
820 if (fb_mode_name) { | |
821 if (!(fb_mode = find_mode_by_name(fb_mode_name))) { | |
822 printf(FBDEV "can't find requested video mode\n"); | |
869 return 1; | 823 return 1; |
870 #ifdef FB_TYPE_TEXT | 824 } |
871 case FB_TYPE_TEXT: | 825 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); |
872 printf(FBDEV "FB_TYPE_TEXT not supported.\n"); | 826 } else if (VM) { |
827 monitor_hfreq = str2range(monitor_hfreq_str); | |
828 monitor_vfreq = str2range(monitor_vfreq_str); | |
829 monitor_dotclock = str2range(monitor_dotclock_str); | |
830 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { | |
831 printf(FBDEV "you have to specify the capabilities of" | |
832 " the monitor.\n"); | |
873 return 1; | 833 return 1; |
874 #endif | 834 } |
875 case FB_TYPE_PACKED_PIXELS: | 835 if (!(fb_mode = find_best_mode(out_width, out_height, |
876 /* OK */ | 836 monitor_hfreq, monitor_vfreq, |
877 if (verbose > 0) | 837 monitor_dotclock))) { |
878 printf(FBDEV "FB_TYPE_PACKED_PIXELS: OK\n"); | 838 printf(FBDEV "can't find best video mode\n"); |
879 break; | |
880 default: | |
881 printf(FBDEV "unknown FB_TYPE: %d\n", fb_finfo.type); | |
882 return 1; | 839 return 1; |
840 } | |
841 printf(FBDEV "using mode %dx%d @ %.1fHz\n", fb_mode->xres, | |
842 fb_mode->yres, vsf(fb_mode)); | |
843 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); | |
844 } | |
845 fb_bpp_we_want = fb_bpp; | |
846 set_bpp(&fb_vinfo, fb_bpp); | |
847 fb_vinfo.xres_virtual = fb_vinfo.xres; | |
848 fb_vinfo.yres_virtual = fb_vinfo.yres; | |
849 | |
850 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { | |
851 printf(FBDEV "Can't put VSCREENINFO: %s\n", strerror(errno)); | |
852 return 1; | |
853 } | |
854 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) { | |
855 printf(FBDEV "Can't get FSCREENINFO: %s\n", strerror(errno)); | |
856 return 1; | |
857 } | |
858 | |
859 lots_of_printf(); | |
860 | |
861 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) { | |
862 printf(FBDEV "type %d not supported\n", fb_finfo.type); | |
863 return 1; | |
883 } | 864 } |
884 | 865 |
885 switch (fb_finfo.visual) { | 866 switch (fb_finfo.visual) { |
886 case FB_VISUAL_TRUECOLOR: | 867 case FB_VISUAL_TRUECOLOR: |
887 break; | 868 break; |
904 free(cmap->red); | 885 free(cmap->red); |
905 free(cmap->green); | 886 free(cmap->green); |
906 free(cmap->blue); | 887 free(cmap->blue); |
907 free(cmap); | 888 free(cmap); |
908 break; | 889 break; |
909 case FB_VISUAL_PSEUDOCOLOR: | 890 // case FB_VISUAL_PSEUDOCOLOR: |
910 printf(FBDEV "visual is FB_VISUAL_PSEUDOCOLOR." | 891 // printf(FBDEV "visual is FB_VISUAL_PSEUDOCOLOR." |
911 "it's not tested!\n"); | 892 // "it's not tested!\n"); |
912 break; | 893 // break; |
913 default: | 894 default: |
914 printf(FBDEV "visual: %d not yet supported\n", | 895 printf(FBDEV "visual: %d not yet supported\n", |
915 fb_finfo.visual); | 896 fb_finfo.visual); |
916 return 1; | 897 return 1; |
917 } | 898 } |
992 | 973 |
993 static const vo_info_t *get_info(void) | 974 static const vo_info_t *get_info(void) |
994 { | 975 { |
995 return &vo_info; | 976 return &vo_info; |
996 } | 977 } |
997 | |
998 #include "osd.h" | |
999 | 978 |
1000 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | 979 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
1001 unsigned char *srca, int stride) | 980 unsigned char *srca, int stride) |
1002 { | 981 { |
1003 uint8_t *dst = next_frame + (in_width * y0 + x0) * fb_pixel_size; | 982 uint8_t *dst = next_frame + (in_width * y0 + x0) * fb_pixel_size; |
1074 out_offset += fb_screen_width; | 1053 out_offset += fb_screen_width; |
1075 in_offset += in_width * fb_pixel_size; | 1054 in_offset += in_width * fb_pixel_size; |
1076 } | 1055 } |
1077 } | 1056 } |
1078 | 1057 |
1079 #include "sub.h" | |
1080 | |
1081 static void flip_page(void) | 1058 static void flip_page(void) |
1082 { | 1059 { |
1083 vo_draw_text(in_width, in_height, draw_alpha); | 1060 vo_draw_text(in_width, in_height, draw_alpha); |
1084 check_events(); | 1061 check_events(); |
1085 put_frame(); | 1062 put_frame(); |