]> git.sesse.net Git - vlc/blobdiff - modules/video_output/fb.c
* include/vlc_common.h:
[vlc] / modules / video_output / fb.c
index f3d4c25566a21076802337695315e1a7afbb6d69..3da78ff4d3f6de7347c439b6722d6d75d27912fb 100644 (file)
@@ -2,15 +2,15 @@
  * fb.c : framebuffer plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: fb.c,v 1.2 2003/02/15 04:43:19 ipkiss 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
@@ -64,10 +64,10 @@ static void GfxMode        ( int i_tty );
  *****************************************************************************/
 #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();
@@ -95,7 +95,7 @@ struct vout_sys_t
     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;
@@ -124,7 +124,7 @@ static int Create( vlc_object_t *p_this )
     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;
@@ -175,7 +175,7 @@ static int Create( vlc_object_t *p_this )
         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 */
@@ -188,7 +188,7 @@ static int Create( vlc_object_t *p_this )
         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;
@@ -204,7 +204,7 @@ static int Create( vlc_object_t *p_this )
         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 ) )
@@ -215,10 +215,10 @@ static int Create( vlc_object_t *p_this )
         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;
 }
 
 /*****************************************************************************
@@ -248,7 +248,7 @@ static int Init( vout_thread_t *p_vout )
         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 */
@@ -285,7 +285,7 @@ static int Init( vout_thread_t *p_vout )
     /* Allocate the picture */
     if( p_pic == NULL )
     {
-        return 0;
+        return VLC_EGENERIC;
     }
 
     /* We know the chroma, allocate a buffer which will be used
@@ -317,7 +317,7 @@ static int Init( vout_thread_t *p_vout )
 
     I_OUTPUTPICTURES++;
 
-    return 0;
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -337,7 +337,7 @@ static void End( vout_thread_t *p_vout )
 static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
-    
+
     CloseDisplay( p_vout );
 
     /* Reset the terminal */
@@ -366,7 +366,7 @@ static void Destroy( vlc_object_t *p_this )
 static int Manage( vout_thread_t *p_vout )
 {
 #if 0
-    u8 buf;
+    uint8_t buf;
 
     if ( read(0, &buf, 1) == 1)
     {
@@ -397,7 +397,7 @@ static int Manage( vout_thread_t *p_vout )
         if( Init( p_vout ) )
         {
             msg_Err( p_vout, "cannot reinit framebuffer screen" );
-            return( 1 );
+            return VLC_EGENERIC;
         }
 
         /* Clear screen */
@@ -410,7 +410,7 @@ static int Manage( vout_thread_t *p_vout )
 #endif
     }
 
-    return 0;
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -421,24 +421,28 @@ static int Manage( vout_thread_t *p_vout )
  *****************************************************************************/
 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 };
 
@@ -460,7 +464,7 @@ static int OpenDisplay( vout_thread_t *p_vout )
     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);
@@ -469,7 +473,7 @@ static int OpenDisplay( vout_thread_t *p_vout )
     {
         msg_Err( p_vout, "cannot open %s (%s)", psz_device, strerror(errno) );
         free( psz_device );
-        return( 1 );
+        return VLC_EGENERIC;
     }
     free( psz_device );
 
@@ -479,16 +483,11 @@ static int OpenDisplay( vout_thread_t *p_vout )
     {
         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;
@@ -500,7 +499,7 @@ static int OpenDisplay( vout_thread_t *p_vout )
     {
         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 */
@@ -513,10 +512,10 @@ static int OpenDisplay( vout_thread_t *p_vout )
 
         /* 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
@@ -537,13 +536,13 @@ static int OpenDisplay( vout_thread_t *p_vout )
     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 );
@@ -570,10 +569,10 @@ static int OpenDisplay( vout_thread_t *p_vout )
 
         /* 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 *
@@ -595,16 +594,16 @@ static int OpenDisplay( vout_thread_t *p_vout )
 
         /* 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;
 }
 
 /*****************************************************************************
@@ -625,7 +624,7 @@ static void CloseDisplay( vout_thread_t *p_vout )
 
     /* 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 );