/*****************************************************************************
* Preamble
*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <errno.h> /* ENOMEM */
#include <signal.h> /* SIGUSR1, SIGUSR2 */
#include <fcntl.h> /* open() */
#include <linux/vt.h> /* VT_* */
#include <linux/kd.h> /* KD* */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
+#include <vlc_interface.h>
/*****************************************************************************
* Local prototypes
"in hardware then you must disable this option. It then does double buffering " \
"in software." )
-vlc_module_begin();
- set_shortname( "Framebuffer" );
- set_category( CAT_VIDEO );
- set_subcategory( SUBCAT_VIDEO_VOUT );
+vlc_module_begin ()
+ set_shortname( "Framebuffer" )
+ set_category( CAT_VIDEO )
+ set_subcategory( SUBCAT_VIDEO_VOUT )
add_file( FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
- false );
- add_bool( "fb-tty", 1, NULL, TTY_TEXT, TTY_LONGTEXT, true );
+ false )
+ add_bool( "fb-tty", 1, NULL, TTY_TEXT, TTY_LONGTEXT, true )
add_string( "fb-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
- true );
+ true )
add_string( "fb-aspect-ratio", NULL, NULL, ASPECT_RATIO_TEXT,
- ASPECT_RATIO_LONGTEXT, true );
+ ASPECT_RATIO_LONGTEXT, true )
add_integer( "fb-mode", 4, NULL, FB_MODE_TEXT, FB_MODE_LONGTEXT,
- true );
+ true )
add_bool( "fb-hw-accel", true, NULL, HW_ACCEL_TEXT, HW_ACCEL_LONGTEXT,
- true );
- set_description( _("GNU/Linux console framebuffer video output") );
- set_capability( "video output", 30 );
- set_callbacks( Create, Destroy );
-vlc_module_end();
+ true )
+ set_description( N_("GNU/Linux framebuffer video output") )
+ set_capability( "video output", 30 )
+ set_callbacks( Create, Destroy )
+vlc_module_end ()
/*****************************************************************************
* vout_sys_t: video output framebuffer method descriptor
{
/* System information */
int i_tty; /* tty device handle */
- bool b_tty;
+ bool b_tty;
struct termios old_termios;
/* Original configuration information */
int i_fd; /* device handle */
struct fb_var_screeninfo old_info; /* original mode information */
struct fb_var_screeninfo var_info; /* current mode information */
- bool b_pan; /* does device supports panning ? */
+ bool b_pan; /* does device supports panning ? */
struct fb_cmap fb_cmap; /* original colormap */
uint16_t *p_palette; /* original palette */
- bool b_hw_accel; /* has hardware support */
+ bool b_hw_accel; /* has hardware support */
/* Video information */
uint32_t i_width;
uint32_t i_height;
- int i_aspect;
- int i_bytes_per_pixel;
- bool b_auto; /* Automatically adjust video size to fb size */
+ int i_aspect;
+ int i_bytes_per_pixel;
+ bool b_auto; /* Automatically adjust video size to fb size */
vlc_fourcc_t i_chroma;
/* Video memory */
- byte_t * p_video; /* base adress */
+ uint8_t *p_video; /* base adress */
size_t i_page_size; /* page size */
};
struct picture_sys_t
{
- byte_t * p_data; /* base adress */
+ uint8_t * p_data; /* base adress */
};
/*****************************************************************************
/* Allocate instance and initialize some members */
p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
- {
- msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
- };
memset( p_sys, 0, sizeof(vout_sys_t) );
+ p_sys->p_video = MAP_FAILED;
+
p_vout->pf_init = Init;
p_vout->pf_end = End;
p_vout->pf_manage = Manage;
if( OpenDisplay( p_vout ) )
{
- if( p_sys->b_tty )
- {
- ioctl( p_sys->i_tty, VT_SETMODE, &p_vout->p_sys->vt_mode );
- sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
- sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
- tcsetattr(0, 0, &p_vout->p_sys->old_termios);
- TextMode( p_sys->i_tty );
- }
- free( p_vout->p_sys );
+ Destroy( VLC_OBJECT(p_vout) );
return VLC_EGENERIC;
}
*****************************************************************************/
static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
{
+ VLC_UNUSED(p_vout);
free( p_pic->p_sys->p_data );
free( p_pic->p_sys );
p_pic->p_sys = NULL;
}
p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
- if( !p_sys->b_auto )
- {
- p_vout->render.i_width = p_sys->i_width;
- p_vout->render.i_height = p_sys->i_height;
- }
- p_vout->output.i_width = p_vout->fmt_out.i_width = p_sys->i_width;
- p_vout->output.i_height = p_vout->fmt_out.i_height = p_sys->i_height;
+ p_vout->output.i_width =
+ p_vout->fmt_out.i_width =
+ p_vout->fmt_out.i_visible_width = p_sys->i_width;
+ p_vout->output.i_height =
+ p_vout->fmt_out.i_height =
+ p_vout->fmt_out.i_visible_height = p_sys->i_height;
/* Assume we have square pixels */
if( p_sys->i_aspect < 0 )
/* Find an empty picture slot */
for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
{
- if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
+ if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
{
p_pic = p_vout->p_picture + i_index;
break;
*****************************************************************************/
static int Control( vout_thread_t *p_vout, int i_query, va_list args )
{
- switch( i_query )
- {
- default:
- return vout_vaControlDefault( p_vout, i_query, args );
- }
+ (void) p_vout; (void) i_query; (void) args;
+ return VLC_EGENERIC;
}
/*****************************************************************************
switch( buf )
{
case 'q':
- vlc_object_kill( p_vout->p_libvlc );
+ libvlc_Quit( p_vout->p_libvlc );
break;
default:
if( !p_vout->p_sys->b_hw_accel )
{
- p_vout->p_libvlc->pf_memcpy( p_vout->p_sys->p_video, p_pic->p->p_pixels,
- p_vout->p_sys->i_page_size );
+ vlc_memcpy( p_vout->p_sys->p_video, p_pic->p->p_pixels,
+ p_vout->p_sys->i_page_size );
}
}
p_sys->p_palette = malloc( 8 * 256 * sizeof( uint16_t ) );
if( !p_sys->p_palette )
{
- msg_Err( p_vout, "out of memory" );
-
/* Restore fb config */
ioctl( p_sys->i_fd, FBIOPUT_VSCREENINFO, &p_sys->old_info );
p_sys->i_bytes_per_pixel;
/* Map a framebuffer at the beginning */
- p_sys->p_video = mmap( 0, p_sys->i_page_size,
+ p_sys->p_video = mmap( NULL, p_sys->i_page_size,
PROT_READ | PROT_WRITE, MAP_SHARED,
p_sys->i_fd, 0 );
- if( p_sys->p_video == ((void*)-1) )
+ if( p_sys->p_video == MAP_FAILED )
{
msg_Err( p_vout, "cannot map video memory (%m)" );
*****************************************************************************/
static void CloseDisplay( vout_thread_t *p_vout )
{
- /* Clear display */
- 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->p_video != MAP_FAILED )
{
- ioctl( p_vout->p_sys->i_fd,
- FBIOPUTCMAP, &p_vout->p_sys->fb_cmap );
- free( p_vout->p_sys->p_palette );
- p_vout->p_sys->p_palette = NULL;
+ /* Clear display */
+ memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
+ munmap( p_vout->p_sys->p_video, p_vout->p_sys->i_page_size );
}
- /* Restore fb config */
- ioctl( p_vout->p_sys->i_fd,
- FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
+ if( p_vout->p_sys->i_fd >= 0 )
+ {
+ /* Restore palette */
+ 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 );
+ free( p_vout->p_sys->p_palette );
+ p_vout->p_sys->p_palette = NULL;
+ }
- /* Close fb */
- close( p_vout->p_sys->i_fd );
+ /* Restore fb config */
+ ioctl( p_vout->p_sys->i_fd,
+ FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
+
+ /* Close fb */
+ close( p_vout->p_sys->i_fd );
+ }
}
/*****************************************************************************
*****************************************************************************/
static void SwitchDisplay( int i_signal )
{
+ VLC_UNUSED( i_signal );
#if 0
vout_thread_t *p_vout;