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