Commit 87df0e8a authored by Jean-Paul Saman's avatar Jean-Paul Saman

fb: select device file by name

parent a6fb7aec
...@@ -80,6 +80,11 @@ static void GfxMode ( int i_tty ); ...@@ -80,6 +80,11 @@ static void GfxMode ( int i_tty );
#define DEVICE_LONGTEXT N_( \ #define DEVICE_LONGTEXT N_( \
"Framebuffer device to use for rendering (usually /dev/fb0).") "Framebuffer device to use for rendering (usually /dev/fb0).")
#define NAME_TEXT N_("Framebuffer device's name")
#define NAME_LONGTEXT N_( \
"If set, select framebuffer device by name rather than by path. " \
"Example: cat /sys/class/graphics/fb0/name" )
#define TTY_TEXT N_("Run fb on current tty.") #define TTY_TEXT N_("Run fb on current tty.")
#define TTY_LONGTEXT N_( \ #define TTY_LONGTEXT N_( \
"Run framebuffer on current TTY device (default enabled). " \ "Run framebuffer on current TTY device (default enabled). " \
...@@ -110,6 +115,9 @@ vlc_module_begin () ...@@ -110,6 +115,9 @@ vlc_module_begin ()
set_subcategory( SUBCAT_VIDEO_VOUT ) set_subcategory( SUBCAT_VIDEO_VOUT )
add_file( FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT, add_file( FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
false ) false )
add_string( "fb-name", "dm_vid0_fb", NULL, NAME_TEXT, NAME_LONGTEXT,
false );
add_bool( "fb-tty", 1, NULL, TTY_TEXT, TTY_LONGTEXT, true ) add_bool( "fb-tty", 1, NULL, TTY_TEXT, TTY_LONGTEXT, true )
add_string( "fb-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, add_string( "fb-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
true ) true )
...@@ -754,7 +762,39 @@ static void SetPalette( vout_thread_t *p_vout, uint16_t *red, uint16_t *green, ...@@ -754,7 +762,39 @@ static void SetPalette( vout_thread_t *p_vout, uint16_t *red, uint16_t *green,
} }
#endif #endif
/* following functions are local */ /*****************************************************************************
* OpenFbByName: select framebuffer by name
*****************************************************************************/
static int OpenFbByName( const char *psz_name )
{
int i_fd = -1;
int i; /* begins with /dev/fb0 */
char *psz_device;
struct fb_fix_screeninfo info;
for( i = 0; i < FB_MAX; i++ )
{
if( asprintf( &psz_device, "/dev/fb%d", i++ ) == -1 )
return -1;
i_fd = open( psz_device, O_RDWR);
free( psz_device );
if( i_fd == -1 )
return -1; /* check errno */
if( ioctl( i_fd, FBIOGET_FSCREENINFO, &info ) == -1 )
{
close( i_fd );
continue;
}
if( !strcmp( info.id, psz_name ) )
return i_fd;
close( i_fd );
}
return -1;
}
/***************************************************************************** /*****************************************************************************
* OpenDisplay: initialize framebuffer * OpenDisplay: initialize framebuffer
...@@ -766,17 +806,28 @@ static int OpenDisplay( vout_thread_t *p_vout ) ...@@ -766,17 +806,28 @@ static int OpenDisplay( vout_thread_t *p_vout )
struct fb_fix_screeninfo fix_info; /* framebuffer fix information */ struct fb_fix_screeninfo fix_info; /* framebuffer fix information */
/* Open framebuffer device */ /* Open framebuffer device */
if( !(psz_device = config_GetPsz( p_vout, FB_DEV_VAR )) ) if( (psz_device = config_GetPsz( p_vout, "fb-name" )) )
{ {
msg_Err( p_vout, "don't know which fb device to open" ); if( (p_sys->i_fd = OpenFbByName( psz_device )) == -1 )
return VLC_EGENERIC; {
msg_Err( p_vout, "cannot open fb by name %s (%m)", psz_device );
free( psz_device );
return VLC_EGENERIC;
}
} }
else if( (psz_device = config_GetPsz( p_vout, FB_DEV_VAR )) )
p_sys->i_fd = open( psz_device, O_RDWR);
if( p_sys->i_fd == -1 )
{ {
msg_Err( p_vout, "cannot open %s (%m)", psz_device ); p_sys->i_fd = open( psz_device, O_RDWR );
free( psz_device ); if( p_sys->i_fd == -1 )
{
msg_Err( p_vout, "cannot open %s (%m)", psz_device );
free( psz_device );
return VLC_EGENERIC;
}
}
else
{
msg_Err( p_vout, "don't know which fb device to open" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
free( psz_device ); free( psz_device );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment