changeset 229:a8170ba5496f

maybe it can play avi :)
author szabii
date Wed, 28 Mar 2001 16:35:14 +0000
parents 1f174547a087
children 2605bca34a96
files libvo/vo_fbdev.c
diffstat 1 files changed, 83 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_fbdev.c	Wed Mar 28 16:30:47 2001 +0000
+++ b/libvo/vo_fbdev.c	Wed Mar 28 16:35:14 2001 +0000
@@ -35,6 +35,8 @@
 static size_t fb_size;
 static uint8_t *frame_buffer;
 static int fb_bpp;
+struct fb_fix_screeninfo fb_fix_info;
+struct fb_var_screeninfo fb_var_info;
 
 static int in_width;
 static int in_height;
@@ -44,19 +46,16 @@
 static int screen_width;
 static uint32_t pixel_format;
 
-static int init_done = 0;
+static int fb_init_done = 0;
 
-static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
-		uint32_t d_height, uint32_t fullscreen, char *title,
-		uint32_t format)
+static int fb_init(void)
 {
 	int fd, vt;
 	char vt_name[11];
 	struct vt_stat vt_state;
 	struct vt_mode vt_mode;
-	struct fb_fix_screeninfo fix_info;
-	struct fb_var_screeninfo var_info;
 
+#if 0
 	/* get a free vt */
 	if ((fd = open("/dev/tty0", O_WRONLY, 0)) == -1) {
 		printf("Can't open /dev/tty0: %s\n", strerror(errno));
@@ -67,7 +66,8 @@
 		return 1;
 	}
 	close(fd);
-
+#endif
+#if 0
 	/* open the vt */
 	snprintf(vt_name, 10, "/dev/tty%d", vt);
 	if ((vt_fd = open(vt_name, O_RDWR | O_NONBLOCK, 0)) == -1) {
@@ -84,6 +84,7 @@
 		ioctl(fd, TIOCNOTTY, 0);
 		close(fd);
 	}
+#endif
 #if 0
 	/* switch to the new vt */
 	if (ioctl(vt_fd, VT_ACTIVATE, vt_active))
@@ -103,62 +104,75 @@
 		return 1;
 	}
 #endif
-
 	if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER")))
 		fb_dev_name = "/dev/fb0";
+	printf("fb_init: using %s\n", fb_dev_name);
 	if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) {
-		printf("Can't open %s: %s\n", fb_dev_name, strerror(errno));
+		printf("fb_init: Can't open %s: %s\n", fb_dev_name, strerror(errno));
 		return 1;
 	}
-	if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &var_info)) {
-		printf("Can't get VSCREENINFO: %s\n", strerror(errno));
+	if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_var_info)) {
+		printf("fb_init: Can't get VSCREENINFO: %s\n", strerror(errno));
 		return 1;
 	}
-
-	if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fix_info)) {
-		printf("Can't get VSCREENINFO: %s\n", strerror(errno));
+	if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_fix_info)) {
+		printf("fb_init: Can't get VSCREENINFO: %s\n", strerror(errno));
 		return 1;
 	}
-	switch (fix_info.type) {
+	switch (fb_fix_info.type) {
 		case FB_TYPE_VGA_PLANES:
-			printf("FB_TYPE_VGA_PLANES not supported.\n");
+			printf("fb_init: FB_TYPE_VGA_PLANES not supported.\n");
 			return 1;
 			break;
 		case FB_TYPE_PLANES:
-			printf("FB_TYPE_PLANES not supported.\n");
+			printf("fb_init: FB_TYPE_PLANES not supported.\n");
 			return 1;
 			break;
 		case FB_TYPE_INTERLEAVED_PLANES:
-			printf("FB_TYPE_INTERLEAVED_PLANES not supported.\n");
+			printf("fb_init: FB_TYPE_INTERLEAVED_PLANES not supported.\n");
 			return 1;
 			break;
 #ifdef FB_TYPE_TEXT
 		case FB_TYPE_TEXT:
-			printf("FB_TYPE_TEXT not supported.\n");
+			printf("fb_init: FB_TYPE_TEXT not supported.\n");
 			return 1;
 			break;
 #endif
 		case FB_TYPE_PACKED_PIXELS:
 			/* OK */
+			printf("fb_init: FB_TYPE_PACKED_PIXELS: OK\n");
 			break;
 		default:
-			printf("unknown FB_TYPE: %d\n", fix_info.type);
+			printf("fb_init: unknown FB_TYPE: %d\n", fb_fix_info.type);
 			return 1;
 	}			
-	fb_size = fix_info.smem_len;
+	fb_bpp = fb_var_info.bits_per_pixel;
+	screen_width = fb_fix_info.line_length;
+	fb_size = fb_fix_info.smem_len;
 	if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
 				MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) {
-		printf("Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
+		printf("fb_init: Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
 		return 1;
 	}
 	close(fb_dev_fd);
-	fb_bpp = var_info.bits_per_pixel;
-	screen_width = fix_info.line_length;
+
+	printf("fb_init: framebuffer @ %p\n", frame_buffer);
+	printf("fb_init: framebuffer size: %d bytes\n", fb_size);
+	printf("fb_init: bpp: %d\n", fb_bpp);
+	printf("fb_init: pixel per line: %d\n", screen_width / (fb_bpp / 8));
+	printf("fb_init: visual: %d\n", fb_fix_info.visual);
 
-	printf("vo_fbdev: frame_buffer @ %p\n", frame_buffer);
-	printf("vo_fbdev: frame_buffer size: %d bytes\n", fb_size);
-	printf("vo_fbdev: bits_per_pixel: %d\n", fb_bpp);
-	printf("vo_fbdev: visual: %d\n", fix_info.visual);
+	fb_init_done = 1;
+	return 0;
+}
+
+static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
+		uint32_t d_height, uint32_t fullscreen, char *title,
+		uint32_t format)
+{
+	if (!fb_init_done)
+		if (fb_init())
+			return 1;
 
 	in_width = width;
 	in_height = height;
@@ -172,37 +186,59 @@
 
 	if (format == IMGFMT_YV12)
 		yuv2rgb_init(fb_bpp, MODE_RGB);
-	init_done = 1;
 	return 0;
 }
 
 static uint32_t query_format(uint32_t format)
 {
-	if (format == IMGFMT_YV12)
-		return 1;
-	if (format == IMGFMT_RGB32 && fb_bpp == 32)
-		return 1;
+	if (!fb_init_done)
+		if (fb_init())
+			return 0;
+	printf("vo_fbdev: query_format(%#x): ", format);
+	if (format & IMGFMT_BGR_MASK == IMGFMT_BGR)
+		goto not_supported;
 	switch (format) {
 		case IMGFMT_YV12:
-			return 1;
+			goto supported;
 		case IMGFMT_RGB32:
 			if (fb_bpp == 32)
-				return 1;
+				goto supported;
 			break;
 		case IMGFMT_RGB24:
 			if (fb_bpp == 24)
-				return 1;
+				goto supported;
 			break;
 		case IMGFMT_RGB16:
 			if (fb_bpp == 16)
-				return 1;
+				goto supported;
 			break;
 		case IMGFMT_RGB15:
 			if (fb_bpp == 15)
-				return 1;
+				goto supported;
+			break;
+		case IMGFMT_BGR|32:
+			if (fb_bpp == 32)
+				goto supported;
+			break;
+		case IMGFMT_BGR|24:
+			if (fb_bpp == 24)
+				goto supported;
+			break;
+		case IMGFMT_BGR|16:
+			if (fb_bpp == 16)
+				goto supported;
+			break;
+		case IMGFMT_BGR|15:
+			if (fb_bpp == 15)
+				goto supported;
 			break;
 	}
+not_supported:
+	printf("not_supported\n");
 	return 0;
+supported:
+	printf("supported\n");
+	return 1;
 }
 
 static const vo_info_t *get_info(void)
@@ -239,10 +275,16 @@
 		yuv2rgb(next_frame, src[0], src[1], src[2], in_width,
 				in_height, in_width * (fb_bpp / 8),
 				in_width, in_width / 2);
-	} else {
+	} else if ((pixel_format & IMGFMT_RGB_MASK) == IMGFMT_RGB) {
 		int i;
-		for (i = 0; i < in_height; i++)
-			memcpy(next_frame, src[0], in_width * (fb_bpp / 8));
+		uint8_t *dst = next_frame;
+		uint8_t *s = src[0];
+		for (i = 0; i < in_height; i++) {
+			memcpy(next_frame, s, in_width * (fb_bpp / 8));
+			dst += screen_width;
+			s += in_width * (fb_bpp / 8);
+		}
+	} else {
 	}
 	return 0;
 }