* fb.c : framebuffer plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: fb.c,v 1.1 2002/08/13 11:59:36 sam Exp $
+ * $Id: fb.c,v 1.7 2003/10/25 00:49:14 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*****************************************************************************/
#define FB_DEV_VAR "fbdev"
-vlc_module_begin();
- add_category_hint( N_("Miscellaneous"), NULL );
- add_string( FB_DEV_VAR, "/dev/fb0", NULL, N_("framebuffer device"), NULL );
- set_description( _("Linux console framebuffer module") );
+vlc_module_begin();
+ add_category_hint( N_("Frame Buffer"), NULL, VLC_FALSE );
+ add_file( FB_DEV_VAR, "/dev/fb0", NULL, N_("framebuffer device"), NULL, VLC_FALSE );
+ set_description( _("Linux console framebuffer video output") );
set_capability( "video output", 30 );
set_callbacks( Create, Destroy );
vlc_module_end();
struct fb_var_screeninfo var_info; /* current mode informations */
vlc_bool_t b_pan; /* does device supports panning ? */
struct fb_cmap fb_cmap; /* original colormap */
- u16 *p_palette; /* original palette */
+ uint16_t *p_palette; /* original palette */
/* Video information */
int i_width;
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
- return( 1 );
+ return VLC_ENOMEM;
};
p_vout->pf_init = Init;
tcsetattr(0, 0, &p_vout->p_sys->old_termios);
TextMode( p_vout->p_sys->i_tty );
free( p_vout->p_sys );
- return( 1 );
+ return VLC_EGENERIC;
}
/* Set-up tty according to new signal handler */
tcsetattr(0, 0, &p_vout->p_sys->old_termios);
TextMode( p_vout->p_sys->i_tty );
free( p_vout->p_sys );
- return( 1 );
+ return VLC_EGENERIC;
}
memcpy( &vt_mode, &p_vout->p_sys->vt_mode, sizeof( vt_mode ) );
vt_mode.mode = VT_PROCESS;
tcsetattr(0, 0, &p_vout->p_sys->old_termios);
TextMode( p_vout->p_sys->i_tty );
free( p_vout->p_sys );
- return( 1 );
+ return VLC_EGENERIC;
}
if( OpenDisplay( p_vout ) )
tcsetattr(0, 0, &p_vout->p_sys->old_termios);
TextMode( p_vout->p_sys->i_tty );
free( p_vout->p_sys );
- return( 1 );
+ return VLC_EGENERIC;
}
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
default:
msg_Err( p_vout, "unknown screen depth %i",
p_vout->p_sys->var_info.bits_per_pixel );
- return 0;
+ return VLC_EGENERIC;
}
/* Only useful for p_vout->p_sys->var_info.bits_per_pixel != 8 */
/* Allocate the picture */
if( p_pic == NULL )
{
- return 0;
+ return VLC_EGENERIC;
}
/* We know the chroma, allocate a buffer which will be used
I_OUTPUTPICTURES++;
- return 0;
+ return VLC_SUCCESS;
}
/*****************************************************************************
static void Destroy( vlc_object_t *p_this )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
-
+
CloseDisplay( p_vout );
/* Reset the terminal */
static int Manage( vout_thread_t *p_vout )
{
#if 0
- u8 buf;
+ uint8_t buf;
if ( read(0, &buf, 1) == 1)
{
if( Init( p_vout ) )
{
msg_Err( p_vout, "cannot reinit framebuffer screen" );
- return( 1 );
+ return VLC_EGENERIC;
}
/* Clear screen */
#endif
}
- return 0;
+ return VLC_SUCCESS;
}
/*****************************************************************************
*****************************************************************************/
static void Display( vout_thread_t *p_vout, picture_t *p_pic )
{
+static int panned=0;
/* swap the two Y offsets if the drivers supports panning */
if( p_vout->p_sys->b_pan )
{
p_vout->p_sys->var_info.yoffset = 0;
/*p_vout->p_sys->var_info.yoffset = p_vout->p_sys->var_info.yres; */
-
+
/* the X offset should be 0, but who knows ...
* some other app might have played with the framebuffer */
p_vout->p_sys->var_info.xoffset = 0;
+if(panned < 0) {
ioctl( p_vout->p_sys->i_fd,
FBIOPAN_DISPLAY, &p_vout->p_sys->var_info );
+panned++;
+}
}
}
#if 0
-static void SetPalette( vout_thread_t *p_vout,
- u16 *red, u16 *green, u16 *blue, u16 *transp )
+static void SetPalette( vout_thread_t *p_vout, uint16_t *red, uint16_t *green,
+ uint16_t *blue, uint16_t *transp )
{
struct fb_cmap cmap = { 0, 256, red, green, blue, transp };
if( !(psz_device = config_GetPsz( p_vout, FB_DEV_VAR )) )
{
msg_Err( p_vout, "don't know which fb device to open" );
- return( 1 );
+ return VLC_EGENERIC;
}
p_vout->p_sys->i_fd = open( psz_device, O_RDWR);
{
msg_Err( p_vout, "cannot open %s (%s)", psz_device, strerror(errno) );
free( psz_device );
- return( 1 );
+ return VLC_EGENERIC;
}
free( psz_device );
{
msg_Err( p_vout, "cannot get fb info (%s)", strerror(errno) );
close( p_vout->p_sys->i_fd );
- return( 1 );
+ return VLC_EGENERIC;
}
- if( ioctl( p_vout->p_sys->i_fd,
- FBIOGET_VSCREENINFO, &p_vout->p_sys->old_info ) )
- {
- msg_Err( p_vout, "cannot get 2nd fb info (%s)", strerror(errno) );
- close( p_vout->p_sys->i_fd );
- return( 1 );
- }
+ memcpy( &p_vout->p_sys->old_info, &p_vout->p_sys->var_info,
+ sizeof( struct fb_var_screeninfo ) );
/* Set some attributes */
p_vout->p_sys->var_info.activate = FB_ACTIVATE_NXTOPEN;
{
msg_Err( p_vout, "cannot set fb info (%s)", strerror(errno) );
close( p_vout->p_sys->i_fd );
- return( 1 );
+ return VLC_EGENERIC;
}
/* Get some informations again, in the definitive configuration */
/* Restore fb config */
ioctl( p_vout->p_sys->i_fd,
- FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info );
+ FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
close( p_vout->p_sys->i_fd );
- return( 1 );
+ return VLC_EGENERIC;
}
/* FIXME: if the image is full-size, it gets cropped on the left
switch( p_vout->p_sys->var_info.bits_per_pixel )
{
case 8:
- p_vout->p_sys->p_palette = malloc( 8 * 256 * sizeof( u16 ) );
+ p_vout->p_sys->p_palette = malloc( 8 * 256 * sizeof( uint16_t ) );
p_vout->p_sys->fb_cmap.start = 0;
p_vout->p_sys->fb_cmap.len = 256;
p_vout->p_sys->fb_cmap.red = p_vout->p_sys->p_palette;
- p_vout->p_sys->fb_cmap.green = p_vout->p_sys->p_palette + 256 * sizeof( u16 );
- p_vout->p_sys->fb_cmap.blue = p_vout->p_sys->p_palette + 2 * 256 * sizeof( u16 );
- p_vout->p_sys->fb_cmap.transp = p_vout->p_sys->p_palette + 3 * 256 * sizeof( u16 );
+ p_vout->p_sys->fb_cmap.green = p_vout->p_sys->p_palette + 256 * sizeof( uint16_t );
+ p_vout->p_sys->fb_cmap.blue = p_vout->p_sys->p_palette + 2 * 256 * sizeof( uint16_t );
+ p_vout->p_sys->fb_cmap.transp = p_vout->p_sys->p_palette + 3 * 256 * sizeof( uint16_t );
/* Save the colormap */
ioctl( p_vout->p_sys->i_fd, FBIOGETCMAP, &p_vout->p_sys->fb_cmap );
/* Restore fb config */
ioctl( p_vout->p_sys->i_fd,
- FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info );
+ FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
close( p_vout->p_sys->i_fd );
- return 1;
+ return VLC_EGENERIC;
}
p_vout->p_sys->i_page_size = p_vout->p_sys->i_width *
/* Restore fb config */
ioctl( p_vout->p_sys->i_fd,
- FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info );
+ FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
close( p_vout->p_sys->i_fd );
- return( 1 );
+ return VLC_EGENERIC;
}
msg_Dbg( p_vout, "framebuffer type=%d, visual=%d, ypanstep=%d, "
"ywrap=%d, accel=%d", fix_info.type, fix_info.visual,
fix_info.ypanstep, fix_info.ywrapstep, fix_info.accel );
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
/* Restore palette */
- if( p_vout->p_sys->var_info.bits_per_pixel == 8 );
+ if( p_vout->p_sys->var_info.bits_per_pixel == 8 )
{
ioctl( p_vout->p_sys->i_fd,
FBIOPUTCMAP, &p_vout->p_sys->fb_cmap );
/* Restore fb config */
ioctl( p_vout->p_sys->i_fd,
- FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info );
+ FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
/* Close fb */
close( p_vout->p_sys->i_fd );