summaryrefslogtreecommitdiffstats
path: root/libvo/vo_fbdev.c
diff options
context:
space:
mode:
authorszabii <szabii@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-03-28 16:35:14 +0000
committerszabii <szabii@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-03-28 16:35:14 +0000
commit0442aafc860f79aa4c1a294f167abc35ed8cca2f (patch)
treeed2f711bc55716c85bc8f1ea42af8c36a8a51e46 /libvo/vo_fbdev.c
parent90351981265b5117addae91d3861e33f15f3dc96 (diff)
downloadmpv-0442aafc860f79aa4c1a294f167abc35ed8cca2f.tar.bz2
mpv-0442aafc860f79aa4c1a294f167abc35ed8cca2f.tar.xz
maybe it can play avi :)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@230 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_fbdev.c')
-rw-r--r--libvo/vo_fbdev.c124
1 files changed, 83 insertions, 41 deletions
diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c
index 88aa36a0d0..dcb43b2fe9 100644
--- a/libvo/vo_fbdev.c
+++ b/libvo/vo_fbdev.c
@@ -35,6 +35,8 @@ static int fb_dev_fd;
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 uint8_t *next_frame;
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 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
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 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
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 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
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("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);
+ 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);
+
+ 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 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
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 @@ static uint32_t draw_frame(uint8_t *src[])
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;
}