]> git.sesse.net Git - vlc/blob - modules/video_output/fb.c
* ./modules/video_output/fb.c: fixed a bug that prevented proper console
[vlc] / modules / video_output / fb.c
1 /*****************************************************************************
2  * fb.c : framebuffer plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  * $Id: fb.c,v 1.6 2003/04/20 21:15:31 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <errno.h>                                                 /* ENOMEM */
28 #include <signal.h>                                      /* SIGUSR1, SIGUSR2 */
29 #include <stdlib.h>                                                /* free() */
30 #include <string.h>                                            /* strerror() */
31 #include <fcntl.h>                                                 /* open() */
32 #include <unistd.h>                                               /* close() */
33
34 #include <termios.h>                                       /* struct termios */
35 #include <sys/ioctl.h>
36 #include <sys/mman.h>                                              /* mmap() */
37
38 #include <linux/fb.h>
39 #include <linux/vt.h>                                                /* VT_* */
40 #include <linux/kd.h>                                                 /* KD* */
41
42 #include <vlc/vlc.h>
43 #include <vlc/vout.h>
44
45 /*****************************************************************************
46  * Local prototypes
47  *****************************************************************************/
48 static int  Create    ( vlc_object_t * );
49 static void Destroy   ( vlc_object_t * );
50
51 static int  Init      ( vout_thread_t * );
52 static void End       ( vout_thread_t * );
53 static int  Manage    ( vout_thread_t * );
54 static void Display   ( vout_thread_t *, picture_t * );
55
56 static int  OpenDisplay    ( vout_thread_t * );
57 static void CloseDisplay   ( vout_thread_t * );
58 static void SwitchDisplay  ( int i_signal );
59 static void TextMode       ( int i_tty );
60 static void GfxMode        ( int i_tty );
61
62 /*****************************************************************************
63  * Module descriptor
64  *****************************************************************************/
65 #define FB_DEV_VAR "fbdev"
66
67 vlc_module_begin();
68     add_category_hint( N_("Frame Buffer"), NULL, VLC_FALSE );
69     add_file( FB_DEV_VAR, "/dev/fb0", NULL, N_("framebuffer device"), NULL, VLC_FALSE );
70     set_description( _("Linux console framebuffer video output") );
71     set_capability( "video output", 30 );
72     set_callbacks( Create, Destroy );
73 vlc_module_end();
74
75 /*****************************************************************************
76  * vout_sys_t: video output framebuffer method descriptor
77  *****************************************************************************
78  * This structure is part of the video output thread descriptor.
79  * It describes the FB specific properties of an output thread.
80  *****************************************************************************/
81 struct vout_sys_t
82 {
83     /* System informations */
84     int                 i_tty;                          /* tty device handle */
85     struct termios      old_termios;
86
87     /* Original configuration informations */
88     struct sigaction            sig_usr1;           /* USR1 previous handler */
89     struct sigaction            sig_usr2;           /* USR2 previous handler */
90     struct vt_mode              vt_mode;                 /* previous VT mode */
91
92     /* Framebuffer information */
93     int                         i_fd;                       /* device handle */
94     struct fb_var_screeninfo    old_info;      /* original mode informations */
95     struct fb_var_screeninfo    var_info;       /* current mode informations */
96     vlc_bool_t                  b_pan;     /* does device supports panning ? */
97     struct fb_cmap              fb_cmap;                /* original colormap */
98     uint16_t                    *p_palette;              /* original palette */
99
100     /* Video information */
101     int i_width;
102     int i_height;
103     int i_bytes_per_pixel;
104
105     /* Video memory */
106     byte_t *    p_video;                                      /* base adress */
107     size_t      i_page_size;                                    /* page size */
108 };
109
110 /*****************************************************************************
111  * Create: allocates FB video thread output method
112  *****************************************************************************
113  * This function allocates and initializes a FB vout method.
114  *****************************************************************************/
115 static int Create( vlc_object_t *p_this )
116 {
117     vout_thread_t *p_vout = (vout_thread_t *)p_this;
118
119     struct sigaction    sig_tty;                 /* sigaction for tty change */
120     struct vt_mode      vt_mode;                          /* vt current mode */
121     struct termios      new_termios;
122
123     /* Allocate instance and initialize some members */
124     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
125     if( p_vout->p_sys == NULL )
126     {
127         return VLC_ENOMEM;
128     };
129
130     p_vout->pf_init = Init;
131     p_vout->pf_end = End;
132     p_vout->pf_manage = Manage;
133     p_vout->pf_render = NULL;
134     p_vout->pf_display = Display;
135
136     /* Set tty and fb devices */
137     p_vout->p_sys->i_tty = 0;           /* 0 == /dev/tty0 == current console */
138
139     GfxMode( p_vout->p_sys->i_tty );
140
141     /* Set keyboard settings */
142     if (tcgetattr(0, &p_vout->p_sys->old_termios) == -1)
143     {
144         msg_Err( p_vout, "tcgetattr failed" );
145     }
146
147     if (tcgetattr(0, &new_termios) == -1)
148     {
149         msg_Err( p_vout, "tcgetattr failed" );
150     }
151
152  /* new_termios.c_lflag &= ~ (ICANON | ISIG);
153     new_termios.c_lflag |= (ECHO | ECHOCTL); */
154     new_termios.c_lflag &= ~ (ICANON);
155     new_termios.c_lflag &= ~(ECHO | ECHOCTL);
156     new_termios.c_iflag = 0;
157     new_termios.c_cc[VMIN] = 1;
158     new_termios.c_cc[VTIME] = 0;
159
160     if (tcsetattr(0, TCSAFLUSH, &new_termios) == -1)
161     {
162         msg_Err( p_vout, "tcsetattr failed" );
163     }
164
165     ioctl( p_vout->p_sys->i_tty, VT_RELDISP, VT_ACKACQ );
166
167     /* Set-up tty signal handler to be aware of tty changes */
168     memset( &sig_tty, 0, sizeof( sig_tty ) );
169     sig_tty.sa_handler = SwitchDisplay;
170     sigemptyset( &sig_tty.sa_mask );
171     if( sigaction( SIGUSR1, &sig_tty, &p_vout->p_sys->sig_usr1 ) ||
172         sigaction( SIGUSR2, &sig_tty, &p_vout->p_sys->sig_usr2 ) )
173     {
174         msg_Err( p_vout, "cannot set signal handler (%s)", strerror(errno) );
175         tcsetattr(0, 0, &p_vout->p_sys->old_termios);
176         TextMode( p_vout->p_sys->i_tty );
177         free( p_vout->p_sys );
178         return VLC_EGENERIC;
179     }
180
181     /* Set-up tty according to new signal handler */
182     if( -1 == ioctl( p_vout->p_sys->i_tty,
183                      VT_GETMODE, &p_vout->p_sys->vt_mode ) )
184     {
185         msg_Err( p_vout, "cannot get terminal mode (%s)", strerror(errno) );
186         sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
187         sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
188         tcsetattr(0, 0, &p_vout->p_sys->old_termios);
189         TextMode( p_vout->p_sys->i_tty );
190         free( p_vout->p_sys );
191         return VLC_EGENERIC;
192     }
193     memcpy( &vt_mode, &p_vout->p_sys->vt_mode, sizeof( vt_mode ) );
194     vt_mode.mode   = VT_PROCESS;
195     vt_mode.waitv  = 0;
196     vt_mode.relsig = SIGUSR1;
197     vt_mode.acqsig = SIGUSR2;
198
199     if( -1 == ioctl( p_vout->p_sys->i_tty, VT_SETMODE, &vt_mode ) )
200     {
201         msg_Err( p_vout, "cannot set terminal mode (%s)", strerror(errno) );
202         sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
203         sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
204         tcsetattr(0, 0, &p_vout->p_sys->old_termios);
205         TextMode( p_vout->p_sys->i_tty );
206         free( p_vout->p_sys );
207         return VLC_EGENERIC;
208     }
209
210     if( OpenDisplay( p_vout ) )
211     {
212         ioctl( p_vout->p_sys->i_tty, VT_SETMODE, &p_vout->p_sys->vt_mode );
213         sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
214         sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
215         tcsetattr(0, 0, &p_vout->p_sys->old_termios);
216         TextMode( p_vout->p_sys->i_tty );
217         free( p_vout->p_sys );
218         return VLC_EGENERIC;
219     }
220
221     return VLC_SUCCESS;
222 }
223
224 /*****************************************************************************
225  * Init: initialize framebuffer video thread output method
226  *****************************************************************************/
227 static int Init( vout_thread_t *p_vout )
228 {
229     int i_index;
230     picture_t *p_pic;
231
232     I_OUTPUTPICTURES = 0;
233
234     /* Initialize the output structure: RGB with square pixels, whatever
235      * the input format is, since it's the only format we know */
236     switch( p_vout->p_sys->var_info.bits_per_pixel )
237     {
238         case 8: /* FIXME: set the palette */
239             p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2'); break;
240         case 15:
241             p_vout->output.i_chroma = VLC_FOURCC('R','V','1','5'); break;
242         case 16:
243             p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6'); break;
244         case 24:
245             p_vout->output.i_chroma = VLC_FOURCC('R','V','2','4'); break;
246         case 32:
247             p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2'); break;
248         default:
249             msg_Err( p_vout, "unknown screen depth %i",
250                      p_vout->p_sys->var_info.bits_per_pixel );
251             return VLC_EGENERIC;
252     }
253
254     /* Only useful for p_vout->p_sys->var_info.bits_per_pixel != 8 */
255     p_vout->output.i_rmask = ( (1 << p_vout->p_sys->var_info.red.length) - 1 )
256                      << p_vout->p_sys->var_info.red.offset;
257     p_vout->output.i_gmask = ( (1 << p_vout->p_sys->var_info.green.length) - 1 )
258                      << p_vout->p_sys->var_info.green.offset;
259     p_vout->output.i_bmask = ( (1 << p_vout->p_sys->var_info.blue.length) - 1 )
260                      << p_vout->p_sys->var_info.blue.offset;
261
262     p_vout->output.i_width = p_vout->p_sys->i_width;
263     p_vout->output.i_height = p_vout->p_sys->i_height;
264
265     /* Assume we have square pixels */
266     p_vout->output.i_aspect = p_vout->p_sys->i_width
267                                * VOUT_ASPECT_FACTOR / p_vout->p_sys->i_height;
268
269     /* Clear the screen */
270     memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
271
272     /* Try to initialize 1 direct buffer */
273     p_pic = NULL;
274
275     /* Find an empty picture slot */
276     for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
277     {
278         if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
279         {
280             p_pic = p_vout->p_picture + i_index;
281             break;
282         }
283     }
284
285     /* Allocate the picture */
286     if( p_pic == NULL )
287     {
288         return VLC_EGENERIC;
289     }
290
291     /* We know the chroma, allocate a buffer which will be used
292      * directly by the decoder */
293     p_pic->p->p_pixels = p_vout->p_sys->p_video;
294     p_pic->p->i_pixel_pitch = p_vout->p_sys->i_bytes_per_pixel;
295     p_pic->p->i_lines = p_vout->p_sys->var_info.yres;
296
297     if( p_vout->p_sys->var_info.xres_virtual )
298     {
299         p_pic->p->i_pitch = p_vout->p_sys->var_info.xres_virtual
300                              * p_vout->p_sys->i_bytes_per_pixel;
301     }
302     else
303     {
304         p_pic->p->i_pitch = p_vout->p_sys->var_info.xres
305                              * p_vout->p_sys->i_bytes_per_pixel;
306     }
307
308     p_pic->p->i_visible_pitch = p_vout->p_sys->var_info.xres
309                                  * p_vout->p_sys->i_bytes_per_pixel;
310
311     p_pic->i_planes = 1;
312
313     p_pic->i_status = DESTROYED_PICTURE;
314     p_pic->i_type   = DIRECT_PICTURE;
315
316     PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
317
318     I_OUTPUTPICTURES++;
319
320     return VLC_SUCCESS;
321 }
322
323 /*****************************************************************************
324  * End: terminate framebuffer video thread output method
325  *****************************************************************************/
326 static void End( vout_thread_t *p_vout )
327 {
328     /* Clear the screen */
329     memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
330 }
331
332 /*****************************************************************************
333  * Destroy: destroy FB video thread output method
334  *****************************************************************************
335  * Terminate an output method created by Create
336  *****************************************************************************/
337 static void Destroy( vlc_object_t *p_this )
338 {
339     vout_thread_t *p_vout = (vout_thread_t *)p_this;
340     
341     CloseDisplay( p_vout );
342
343     /* Reset the terminal */
344     ioctl( p_vout->p_sys->i_tty, VT_SETMODE, &p_vout->p_sys->vt_mode );
345
346     /* Remove signal handlers */
347     sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
348     sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
349
350     /* Reset the keyboard state */
351     tcsetattr( 0, 0, &p_vout->p_sys->old_termios );
352
353     /* Return to text mode */
354     TextMode( p_vout->p_sys->i_tty );
355
356     /* Destroy structure */
357     free( p_vout->p_sys );
358 }
359
360 /*****************************************************************************
361  * Manage: handle FB events
362  *****************************************************************************
363  * This function should be called regularly by video output thread. It manages
364  * console events. It returns a non null value on error.
365  *****************************************************************************/
366 static int Manage( vout_thread_t *p_vout )
367 {
368 #if 0
369     u8 buf;
370
371     if ( read(0, &buf, 1) == 1)
372     {
373         switch( buf )
374         {
375         case 'q':
376             p_vout->p_vlc->b_die = 1;
377             break;
378
379         default:
380             break;
381         }
382     }
383 #endif
384
385     /*
386      * Size change
387      */
388     if( p_vout->i_changes & VOUT_SIZE_CHANGE )
389     {
390         msg_Dbg( p_vout, "reinitializing framebuffer screen" );
391         p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
392
393         /* Destroy XImages to change their size */
394         End( p_vout );
395
396         /* Recreate XImages. If SysInit failed, the thread can't go on. */
397         if( Init( p_vout ) )
398         {
399             msg_Err( p_vout, "cannot reinit framebuffer screen" );
400             return VLC_EGENERIC;
401         }
402
403         /* Clear screen */
404         memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
405
406 #if 0
407         /* Tell the video output thread that it will need to rebuild YUV
408          * tables. This is needed since conversion buffer size may have changed */
409         p_vout->i_changes |= VOUT_YUV_CHANGE;
410 #endif
411     }
412
413     return VLC_SUCCESS;
414 }
415
416 /*****************************************************************************
417  * Display: displays previously rendered output
418  *****************************************************************************
419  * This function send the currently rendered image to FB image, waits until
420  * it is displayed and switch the two rendering buffers, preparing next frame.
421  *****************************************************************************/
422 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
423 {
424 static int panned=0;
425     /* swap the two Y offsets if the drivers supports panning */
426     if( p_vout->p_sys->b_pan )
427     {
428         p_vout->p_sys->var_info.yoffset = 0;
429         /*p_vout->p_sys->var_info.yoffset = p_vout->p_sys->var_info.yres; */
430    
431         /* the X offset should be 0, but who knows ...
432          * some other app might have played with the framebuffer */
433         p_vout->p_sys->var_info.xoffset = 0;
434
435 if(panned < 0) {
436         ioctl( p_vout->p_sys->i_fd,
437                FBIOPAN_DISPLAY, &p_vout->p_sys->var_info );
438 panned++;
439 }
440     }
441 }
442
443 #if 0
444 static void SetPalette( vout_thread_t *p_vout,
445                              u16 *red, u16 *green, u16 *blue, u16 *transp )
446 {
447     struct fb_cmap cmap = { 0, 256, red, green, blue, transp };
448
449     ioctl( p_vout->p_sys->i_fd, FBIOPUTCMAP, &cmap );
450 }
451 #endif
452
453 /* following functions are local */
454
455 /*****************************************************************************
456  * OpenDisplay: initialize framebuffer
457  *****************************************************************************/
458 static int OpenDisplay( vout_thread_t *p_vout )
459 {
460     char *psz_device;                             /* framebuffer device path */
461     struct fb_fix_screeninfo    fix_info;     /* framebuffer fix information */
462
463     /* Open framebuffer device */
464     if( !(psz_device = config_GetPsz( p_vout, FB_DEV_VAR )) )
465     {
466         msg_Err( p_vout, "don't know which fb device to open" );
467         return VLC_EGENERIC;
468     }
469
470     p_vout->p_sys->i_fd = open( psz_device, O_RDWR);
471
472     if( p_vout->p_sys->i_fd == -1 )
473     {
474         msg_Err( p_vout, "cannot open %s (%s)", psz_device, strerror(errno) );
475         free( psz_device );
476         return VLC_EGENERIC;
477     }
478     free( psz_device );
479
480     /* Get framebuffer device informations */
481     if( ioctl( p_vout->p_sys->i_fd,
482                FBIOGET_VSCREENINFO, &p_vout->p_sys->var_info ) )
483     {
484         msg_Err( p_vout, "cannot get fb info (%s)", strerror(errno) );
485         close( p_vout->p_sys->i_fd );
486         return VLC_EGENERIC;
487     }
488
489     memcpy( &p_vout->p_sys->old_info, &p_vout->p_sys->var_info,
490             sizeof( struct fb_var_screeninfo ) );
491
492     /* Set some attributes */
493     p_vout->p_sys->var_info.activate = FB_ACTIVATE_NXTOPEN;
494     p_vout->p_sys->var_info.xoffset =  0;
495     p_vout->p_sys->var_info.yoffset =  0;
496
497     if( ioctl( p_vout->p_sys->i_fd,
498                FBIOPUT_VSCREENINFO, &p_vout->p_sys->var_info ) )
499     {
500         msg_Err( p_vout, "cannot set fb info (%s)", strerror(errno) );
501         close( p_vout->p_sys->i_fd );
502         return VLC_EGENERIC;
503     }
504
505     /* Get some informations again, in the definitive configuration */
506     if( ioctl( p_vout->p_sys->i_fd, FBIOGET_FSCREENINFO, &fix_info )
507          || ioctl( p_vout->p_sys->i_fd,
508                    FBIOGET_VSCREENINFO, &p_vout->p_sys->var_info ) )
509     {
510         msg_Err( p_vout, "cannot get additional fb info (%s)",
511                           strerror(errno) );
512
513         /* Restore fb config */
514         ioctl( p_vout->p_sys->i_fd,
515                FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
516
517         close( p_vout->p_sys->i_fd );
518         return VLC_EGENERIC;
519     }
520
521     /* FIXME: if the image is full-size, it gets cropped on the left
522      * because of the xres / xres_virtual slight difference */
523     msg_Dbg( p_vout, "%ix%i (virtual %ix%i)",
524              p_vout->p_sys->var_info.xres, p_vout->p_sys->var_info.yres,
525              p_vout->p_sys->var_info.xres_virtual,
526              p_vout->p_sys->var_info.yres_virtual );
527
528     p_vout->p_sys->i_height = p_vout->p_sys->var_info.yres;
529     p_vout->p_sys->i_width  = p_vout->p_sys->var_info.xres_virtual
530                                ? p_vout->p_sys->var_info.xres_virtual
531                                : p_vout->p_sys->var_info.xres;
532
533     p_vout->p_sys->p_palette = NULL;
534     p_vout->p_sys->b_pan = ( fix_info.ypanstep || fix_info.ywrapstep );
535
536     switch( p_vout->p_sys->var_info.bits_per_pixel )
537     {
538     case 8:
539         p_vout->p_sys->p_palette = malloc( 8 * 256 * sizeof( u16 ) );
540         p_vout->p_sys->fb_cmap.start = 0;
541         p_vout->p_sys->fb_cmap.len = 256;
542         p_vout->p_sys->fb_cmap.red = p_vout->p_sys->p_palette;
543         p_vout->p_sys->fb_cmap.green = p_vout->p_sys->p_palette + 256 * sizeof( u16 );
544         p_vout->p_sys->fb_cmap.blue = p_vout->p_sys->p_palette + 2 * 256 * sizeof( u16 );
545         p_vout->p_sys->fb_cmap.transp = p_vout->p_sys->p_palette + 3 * 256 * sizeof( u16 );
546
547         /* Save the colormap */
548         ioctl( p_vout->p_sys->i_fd, FBIOGETCMAP, &p_vout->p_sys->fb_cmap );
549
550         p_vout->p_sys->i_bytes_per_pixel = 1;
551         break;
552
553     case 15:
554     case 16:
555         p_vout->p_sys->i_bytes_per_pixel = 2;
556         break;
557
558     case 24:
559         p_vout->p_sys->i_bytes_per_pixel = 3;
560         break;
561
562     case 32:
563         p_vout->p_sys->i_bytes_per_pixel = 4;
564         break;
565
566     default:
567         msg_Err( p_vout, "screen depth %d is not supported",
568                          p_vout->p_sys->var_info.bits_per_pixel );
569
570         /* Restore fb config */
571         ioctl( p_vout->p_sys->i_fd,
572                FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
573
574         close( p_vout->p_sys->i_fd );
575         return VLC_EGENERIC;
576     }
577
578     p_vout->p_sys->i_page_size = p_vout->p_sys->i_width *
579                 p_vout->p_sys->i_height * p_vout->p_sys->i_bytes_per_pixel;
580
581     /* Map a framebuffer at the beginning */
582     p_vout->p_sys->p_video = mmap( 0, p_vout->p_sys->i_page_size,
583                                    PROT_READ | PROT_WRITE, MAP_SHARED,
584                                    p_vout->p_sys->i_fd, 0 );
585
586     if( p_vout->p_sys->p_video == ((void*)-1) )
587     {
588         msg_Err( p_vout, "cannot map video memory (%s)", strerror(errno) );
589
590         if( p_vout->p_sys->var_info.bits_per_pixel == 8 )
591         {
592             free( p_vout->p_sys->p_palette );
593         }
594
595         /* Restore fb config */
596         ioctl( p_vout->p_sys->i_fd,
597                FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
598
599         close( p_vout->p_sys->i_fd );
600         return VLC_EGENERIC;
601     }
602
603     msg_Dbg( p_vout, "framebuffer type=%d, visual=%d, ypanstep=%d, "
604              "ywrap=%d, accel=%d", fix_info.type, fix_info.visual,
605              fix_info.ypanstep, fix_info.ywrapstep, fix_info.accel );
606     return VLC_SUCCESS;
607 }
608
609 /*****************************************************************************
610  * CloseDisplay: terminate FB video thread output method
611  *****************************************************************************/
612 static void CloseDisplay( vout_thread_t *p_vout )
613 {
614     /* Clear display */
615     memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
616
617     /* Restore palette */
618     if( p_vout->p_sys->var_info.bits_per_pixel == 8 )
619     {
620         ioctl( p_vout->p_sys->i_fd,
621                FBIOPUTCMAP, &p_vout->p_sys->fb_cmap );
622         free( p_vout->p_sys->p_palette );
623     }
624
625     /* Restore fb config */
626     ioctl( p_vout->p_sys->i_fd,
627            FBIOPUT_VSCREENINFO, &p_vout->p_sys->old_info );
628
629     /* Close fb */
630     close( p_vout->p_sys->i_fd );
631 }
632
633 /*****************************************************************************
634  * SwitchDisplay: VT change signal handler
635  *****************************************************************************
636  * This function activates or deactivates the output of the thread. It is
637  * called by the VT driver, on terminal change.
638  *****************************************************************************/
639 static void SwitchDisplay(int i_signal)
640 {
641 #if 0
642     vout_thread_t *p_vout;
643
644     vlc_mutex_lock( &p_vout_bank->lock );
645
646     /* XXX: only test the first video output */
647     if( p_vout_bank->i_count )
648     {
649         p_vout = p_vout_bank->pp_vout[0];
650
651         switch( i_signal )
652         {
653         case SIGUSR1:                                /* vt has been released */
654             p_vout->b_active = 0;
655             ioctl( p_vout->p_sys->i_tty, VT_RELDISP, 1 );
656             break;
657         case SIGUSR2:                                /* vt has been acquired */
658             p_vout->b_active = 1;
659             ioctl( p_vout->p_sys->i_tty, VT_RELDISP, VT_ACTIVATE );
660             /* handle blanking */
661             vlc_mutex_lock( &p_vout->change_lock );
662             p_vout->i_changes |= VOUT_SIZE_CHANGE;
663             vlc_mutex_unlock( &p_vout->change_lock );
664             break;
665         }
666     }
667
668     vlc_mutex_unlock( &p_vout_bank->lock );
669 #endif
670 }
671
672 /*****************************************************************************
673  * TextMode and GfxMode : switch tty to text/graphic mode
674  *****************************************************************************
675  * These functions toggle the tty mode.
676  *****************************************************************************/
677 static void TextMode( int i_tty )
678 {
679     /* return to text mode */
680     if( -1 == ioctl(i_tty, KDSETMODE, KD_TEXT) )
681     {
682         /*msg_Err( p_vout, "failed ioctl KDSETMODE KD_TEXT" );*/
683     }
684 }
685
686 static void GfxMode( int i_tty )
687 {
688     /* switch to graphic mode */
689     if( -1 == ioctl(i_tty, KDSETMODE, KD_GRAPHICS) )
690     {
691         /*msg_Err( p_vout, "failed ioctl KDSETMODE KD_GRAPHICS" );*/
692     }
693 }
694