Mercurial > mplayer.hg
changeset 225:62ec84961b27
vo_fbdev added
author | szabii |
---|---|
date | Wed, 28 Mar 2001 12:08:44 +0000 |
parents | 725e31b1c94b |
children | f311c67d906a |
files | cfg-mplayer.h configure libvo/video_out.c libvo/vo_fbdev.c mplayer.c |
diffstat | 5 files changed, 310 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cfg-mplayer.h Wed Mar 28 11:44:49 2001 +0000 +++ b/cfg-mplayer.h Wed Mar 28 12:08:44 2001 +0000 @@ -9,6 +9,9 @@ CONF_TYPE_PRINT, CONF_NOCFG, 0, 0}, {"vo", &video_driver, CONF_TYPE_STRING, 0, 0, 0}, {"dsp", &dsp, CONF_TYPE_STRING, 0, 0, 0}, +#ifdef HAVE_FBDEV + {"fb", &fb_dev_name, CONF_TYPE_STRING, 0, 0, 0}, +#endif {"encode", &encode_name, CONF_TYPE_STRING, 0, 0, 0}, {"font", &font_name, CONF_TYPE_STRING, 0, 0, 0}, {"ffactor", &font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0},
--- a/configure Wed Mar 28 11:44:49 2001 +0000 +++ b/configure Wed Mar 28 12:08:44 2001 +0000 @@ -82,6 +82,7 @@ --enable-xv build with Xv render support for X 4.x [autodetect] --enable-vm build with XF86VidMode support for x11 driver --enable-x11 build with X11 render support [autodetect] + --enable-fbdev build with FBDev render support [_not_ autodetected] --enable-mlib build with MLIB support ( only Solaris ) --enable-termcap use termcap database for key codes @@ -166,6 +167,7 @@ _mpg123=no _xmga=no _dga=no +_fbdev=no _lirc=no _x=1 @@ -457,6 +459,9 @@ --enable-syncfb) _syncfb=yes ;; + --enable-fbdev) + _fbdev=yes + ;; --enable-mlib) _mlib=yes ;; @@ -508,6 +513,9 @@ --disable-dga) _dga=no ;; + --disable-fbdev) + _fbdev=no + ;; --disable-termcap) _termcap=no ;; @@ -548,6 +556,7 @@ echo "Checking for X11 ... $_x11" echo "Checking for DGA ... $_dga" echo "Checking for Xf86VM ... $_vm" +echo "Checking for FBDev ... $_fbdev" # write conf files. if [ $_gl = yes ]; then @@ -718,6 +727,13 @@ _dga='#undef HAVE_DGA' fi +if [ $_fbdev = yes ]; then + _fbdev='#define HAVE_FBDEV' + _vosrc=$_vosrc' vo_fbdev.c' +else + _fbdev='#undef HAVE_FBDEV' +fi + if [ $_mpg123 = yes ]; then _mpg123='#define DEFAULT_MPG123' else @@ -795,6 +811,7 @@ $_3dfx $_mga $_syncfb +$_fbdev #if defined(HAVE_GL)||defined(HAVE_X11)||defined(HAVE_XV) #define X11_FULLSCREEN
--- a/libvo/video_out.c Wed Mar 28 11:44:49 2001 +0000 +++ b/libvo/video_out.c Wed Mar 28 12:08:44 2001 +0000 @@ -49,6 +49,7 @@ extern vo_functions_t video_out_pgm; extern vo_functions_t video_out_md5; extern vo_functions_t video_out_syncfb; +extern vo_functions_t video_out_fbdev; vo_functions_t* video_out_drivers[] = { @@ -84,6 +85,7 @@ &video_out_odivx, &video_out_pgm, &video_out_md5, + &video_out_fbdev, NULL };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libvo/vo_fbdev.c Wed Mar 28 12:08:44 2001 +0000 @@ -0,0 +1,286 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> + +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <linux/fb.h> +#include <linux/vt.h> + +#include "config.h" +#include "video_out.h" +#include "video_out_internal.h" + +#include "yuv2rgb.h" + +LIBVO_EXTERN(fbdev) + +//#include "yuv2rgb.h" + +static vo_info_t vo_info = { + "Framebuffer Device", + "fbdev", + "Szabolcs Berecz <szabi@inf.elte.hu>", + "" +}; + +static int vt_active; +static int vt_fd; + +char *fb_dev_name = NULL; +static int fb_dev_fd; +static size_t fb_size; +static uint8_t *frame_buffer; +static int fb_bpp; + +static int in_width; +static int in_height; +static int out_width; +static int out_height; +static uint8_t *next_frame; +static int screen_width; +static uint32_t pixel_format; + +static int 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) +{ + 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; + + /* get a free vt */ + if ((fd = open("/dev/tty0", O_WRONLY, 0)) == -1) { + printf("Can't open /dev/tty0: %s\n", strerror(errno)); + return 1; + } + if (ioctl(fd, VT_OPENQRY, &vt) < 0 || vt == -1) { + printf("Can't open a free VT: %s\n", strerror(errno)); + return 1; + } + close(fd); + + /* open the vt */ + snprintf(vt_name, 10, "/dev/tty%d", vt); + if ((vt_fd = open(vt_name, O_RDWR | O_NONBLOCK, 0)) == -1) { + printf("Can't open %s: %s\n", vt_name, strerror(errno)); + return 1; + } + + /* save the current vtnum */ + if (!ioctl(vt_fd, VT_GETSTATE, &vt_state)) + vt_active = vt_state.v_active; + + /* detach the controlling tty */ + if ((fd = open("/dev/tty", O_RDWR)) >= 0) { + ioctl(fd, TIOCNOTTY, 0); + close(fd); + } +#if 0 + /* switch to the new vt */ + if (ioctl(vt_fd, VT_ACTIVATE, vt_active)) + printf("ioctl VT_ACTIVATE: %s\n", strerror(errno)); + if (ioctl(vt_fd, VT_WAITACTIVE, vt_active)) + printf("ioctl VT_WAITACTIVE: %s\n", strerror(errno)); + if (ioctl(vt_fd, VT_GETMODE, &vt_mode) < 0) { + printf("ioctl VT_GETMODE: %s\n", strerror(errno)); + return 1; + } + signal(SIGUSR1, vt_request); + vt_mode.mode = VT_PROCESS; + vt_mode.relsig = SIGUSR1; + vt_mode.acqsig = SIGUSR1; + if (ioctl(vt_fd, VT_SETMODE, &vt_mode) < 0) { + printf("ioctl VT_SETMODE: %s\n", strerror(errno)); + return 1; + } +#endif + + if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) + fb_dev_name = "/dev/fb0"; + if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) { + printf("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)); + return 1; + } + + if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fix_info)) { + printf("Can't get VSCREENINFO: %s\n", strerror(errno)); + return 1; + } + switch (fix_info.type) { + case FB_TYPE_VGA_PLANES: + printf("FB_TYPE_VGA_PLANES not supported.\n"); + return 1; + break; + case FB_TYPE_PLANES: + printf("FB_TYPE_PLANES not supported.\n"); + return 1; + break; + case FB_TYPE_INTERLEAVED_PLANES: + printf("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"); + return 1; + break; +#endif + case FB_TYPE_PACKED_PIXELS: + /* OK */ + break; + default: + printf("unknown FB_TYPE: %d\n", fix_info.type); + return 1; + } + fb_size = 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)); + 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); + + in_width = width; + in_height = height; + out_width = width; + out_height = height; + pixel_format = format; + if (!(next_frame = (uint8_t *) malloc(in_width * in_height * (fb_bpp / 8)))) { + printf("Can't malloc next_frame: %s\n", strerror(errno)); + return 1; + } + + 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; + switch (format) { + case IMGFMT_YV12: + return 1; + case IMGFMT_RGB32: + if (fb_bpp == 32) + return 1; + break; + case IMGFMT_RGB24: + if (fb_bpp == 24) + return 1; + break; + case IMGFMT_RGB16: + if (fb_bpp == 16) + return 1; + break; + case IMGFMT_RGB15: + if (fb_bpp == 15) + return 1; + break; + } + return 0; +} + +static const vo_info_t *get_info(void) +{ + return &vo_info; +} + +static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, + unsigned char *srca, int stride) +{ + int x, y; + uint8_t *dst; + + if (pixel_format == IMGFMT_YV12) { + for (y = 0; y < h; y++){ + dst = next_frame + (in_width * (y0 + y) + x0) * (fb_bpp / 8); + for (x = 0; x < w; x++) { + if (srca[x]) { + dst[0] = (dst[0]*(srca[x]^255)+src[x]*(srca[x]))>>8; + dst[1] = (dst[1]*(srca[x]^255)+src[x]*(srca[x]))>>8; + dst[2] = (dst[2]*(srca[x]^255)+src[x]*(srca[x]))>>8; + } + dst += fb_bpp / 8; + } + src += stride; + srca += stride; + } + } +} + +static uint32_t draw_frame(uint8_t *src[]) +{ + if (pixel_format == IMGFMT_YV12) { + yuv2rgb(next_frame, src[0], src[1], src[2], in_width, + in_height, in_width * (fb_bpp / 8), + in_width, in_width / 2); + } else { + int i; + for (i = 0; i < in_height; i++) + memcpy(next_frame, src[0], in_width * (fb_bpp / 8)); + } + return 0; +} + +static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, + int y) +{ + uint8_t *dest; + + dest = next_frame + (in_width * y + x) * (fb_bpp / 8); + yuv2rgb(dest, src[0], src[1], src[2], w, h, in_width * (fb_bpp / 8), + stride[0], stride[1]); + return 0; +} + +static void check_events(void) +{ +} + +static void flip_page(void) +{ + int i, out_offset = 0, in_offset = 0; + + vo_draw_text(in_width, in_height, draw_alpha); + check_events(); + for (i = 0; i < in_height; i++) { + memcpy(frame_buffer + out_offset, next_frame + in_offset, + in_width * (fb_bpp / 8)); + out_offset += screen_width; + in_offset += in_width * (fb_bpp / 8); + } +} + +static void uninit(void) +{ + if (vt_active >= 0) + ioctl(vt_fd, VT_ACTIVATE, vt_active); + printf("vo_fbdev: uninit\n"); + free(next_frame); + munmap(frame_buffer, fb_size); +}
--- a/mplayer.c Wed Mar 28 11:44:49 2001 +0000 +++ b/mplayer.c Wed Mar 28 12:08:44 2001 +0000 @@ -72,6 +72,8 @@ XMM_PluginSound *pSound=NULL; #endif +extern char *fb_dev_name; + extern int vo_screenwidth; extern char* win32_codec_name; // must be set before calling DrvOpen() !!! @@ -1931,7 +1933,6 @@ --osd_visible; if(!osd_visible) vo_osd_progbar_type=-1; // disable } - } // while(v_frame<a_frame || force_redraw)