]> git.sesse.net Git - vlc/blob - modules/video_output/fb.c
vout_fb: get pitch from line_length field
[vlc] / modules / video_output / fb.c
1 /*****************************************************************************
2  * fb.c : framebuffer plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Jean-Paul Saman
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <errno.h>                                                 /* ENOMEM */
34 #include <signal.h>                                      /* SIGUSR1, SIGUSR2 */
35 #include <fcntl.h>                                                 /* open() */
36 #include <unistd.h>                                               /* close() */
37
38 #include <termios.h>                                       /* struct termios */
39 #include <sys/ioctl.h>
40 #include <sys/mman.h>                                              /* mmap() */
41
42 #include <linux/fb.h>
43 #include <linux/vt.h>                                                /* VT_* */
44 #include <linux/kd.h>                                                 /* KD* */
45
46 #include <vlc_common.h>
47 #include <vlc_plugin.h>
48 #include <vlc_vout_display.h>
49 #include <vlc_picture_pool.h>
50 #include <vlc_charset.h>
51
52 /*****************************************************************************
53  * Module descriptor
54  *****************************************************************************/
55 #define FB_DEV_VAR "fbdev"
56
57 #define DEVICE_TEXT N_("Framebuffer device")
58 #define DEVICE_LONGTEXT N_(\
59     "Framebuffer device to use for rendering (usually /dev/fb0).")
60
61 #define TTY_TEXT N_("Run fb on current tty.")
62 #define TTY_LONGTEXT N_(\
63     "Run framebuffer on current TTY device (default enabled). " \
64     "(disable tty handling with caution)")
65
66 #define FB_MODE_TEXT N_("Framebuffer resolution to use.")
67 #define FB_MODE_LONGTEXT N_(\
68     "Select the resolution for the framebuffer. Currently it supports " \
69     "the values 0=QCIF 1=CIF 2=NTSC 3=PAL, 4=auto (default 4=auto)")
70
71 #define HW_ACCEL_TEXT N_("Framebuffer uses hw acceleration.")
72 #define HW_ACCEL_LONGTEXT N_(\
73     "If your framebuffer supports hardware acceleration or does double buffering " \
74     "in hardware then you must disable this option. It then does double buffering " \
75     "in software.")
76
77 static int  Open (vlc_object_t *);
78 static void Close(vlc_object_t *);
79
80 vlc_module_begin ()
81     set_shortname("Framebuffer")
82     set_category(CAT_VIDEO)
83     set_subcategory(SUBCAT_VIDEO_VOUT)
84     add_file(FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
85               false)
86     add_bool("fb-tty", true, NULL, TTY_TEXT, TTY_LONGTEXT, true)
87     add_obsolete_string("fb-chroma")
88     add_obsolete_string("fb-aspect-ratio")
89     add_integer("fb-mode", 4, NULL, FB_MODE_TEXT, FB_MODE_LONGTEXT,
90                  true)
91     add_bool("fb-hw-accel", true, NULL, HW_ACCEL_TEXT, HW_ACCEL_LONGTEXT,
92               true)
93     set_description(N_("GNU/Linux framebuffer video output"))
94     set_capability("vout display", 30)
95     set_callbacks(Open, Close)
96 vlc_module_end ()
97
98 /*****************************************************************************
99  * Local prototypes
100  *****************************************************************************/
101 static picture_pool_t *Pool  (vout_display_t *, unsigned);
102 static void           Display(vout_display_t *, picture_t *);
103 static int            Control(vout_display_t *, int, va_list);
104 static void           Manage (vout_display_t *);
105
106 /* */
107 static int  OpenDisplay  (vout_display_t *, bool force_resolution);
108 static void CloseDisplay (vout_display_t *);
109 static void SwitchDisplay(int i_signal);
110 static void TextMode     (int tty);
111 static void GfxMode      (int tty);
112
113 static int  TtyInit(vout_display_t *);
114 static void TtyExit(vout_display_t *);
115
116 /* */
117 struct vout_display_sys_t {
118     /* System information */
119     int                 tty;                          /* tty device handle */
120     bool                is_tty;
121     struct termios      old_termios;
122
123     /* Original configuration information */
124     struct sigaction            sig_usr1;           /* USR1 previous handler */
125     struct sigaction            sig_usr2;           /* USR2 previous handler */
126     struct vt_mode              vt_mode;                 /* previous VT mode */
127
128     /* Framebuffer information */
129     int                         fd;                       /* device handle */
130     struct fb_var_screeninfo    old_info;       /* original mode information */
131     struct fb_var_screeninfo    var_info;        /* current mode information */
132     struct fb_fix_screeninfo    fix_info;     /* framebuffer fix information */
133     bool                        has_pan;   /* does device supports panning ? */
134     struct fb_cmap              fb_cmap;                /* original colormap */
135     uint16_t                    *palette;                /* original palette */
136     bool                        is_hw_accel;         /* has hardware support */
137
138     /* Video information */
139     uint32_t width;
140     uint32_t height;
141     int      bytes_per_pixel;
142
143     /* Video memory */
144     uint8_t     *video_ptr;                                  /* base adress */
145     size_t      video_size;                                    /* page size */
146
147     picture_t       *picture;
148     picture_pool_t  *pool;
149 };
150
151 /**
152  * This function allocates and initializes a FB vout method.
153  */
154 static int Open(vlc_object_t *object)
155 {
156     vout_display_t     *vd = (vout_display_t *)object;
157     vout_display_sys_t *sys;
158
159     /* Allocate instance and initialize some members */
160     vd->sys = sys = calloc(1, sizeof(*sys));
161     if (!sys)
162         return VLC_ENOMEM;
163
164     /* Does the framebuffer uses hw acceleration? */
165     sys->is_hw_accel = var_CreateGetBool(vd, "fb-hw-accel");
166
167     /* Set tty and fb devices */
168     sys->tty = 0; /* 0 == /dev/tty0 == current console */
169     sys->is_tty = var_CreateGetBool(vd, "fb-tty");
170 #if !defined(WIN32) &&  defined(HAVE_ISATTY)
171     /* Check that stdin is a TTY */
172     if (sys->is_tty && !isatty(0)) {
173         msg_Warn(vd, "fd 0 is not a TTY");
174         free(sys);
175         return VLC_EGENERIC;
176     }
177     msg_Warn(vd, "disabling tty handling, use with caution because "
178                  "there is no way to return to the tty.");
179 #endif
180
181     const int mode = var_CreateGetInteger(vd, "fb-mode");
182     bool force_resolution = true;
183     switch (mode) {
184     case 0: /* QCIF */
185         sys->width  = 176;
186         sys->height = 144;
187         break;
188     case 1: /* CIF */
189         sys->width  = 352;
190         sys->height = 288;
191         break;
192     case 2: /* NTSC */
193         sys->width  = 640;
194         sys->height = 480;
195         break;
196     case 3: /* PAL */
197         sys->width  = 704;
198         sys->height = 576;
199         break;
200     case 4:
201     default:
202         force_resolution = false;
203         break;
204     }
205
206     /* tty handling */
207     if (sys->is_tty && TtyInit(vd)) {
208         free(sys);
209         return VLC_EGENERIC;
210     }
211
212     /* */
213     sys->video_ptr = MAP_FAILED;
214     sys->picture = NULL;
215     sys->pool = NULL;
216
217     if (OpenDisplay(vd, force_resolution)) {
218         Close(VLC_OBJECT(vd));
219         return VLC_EGENERIC;
220     }
221
222     /* */
223     video_format_t fmt = vd->fmt;
224
225     msg_Err(vd, "var_info.bits_per_pixel = %d", sys->var_info.bits_per_pixel);
226     switch (sys->var_info.bits_per_pixel) {
227     case 8: /* FIXME: set the palette */
228         fmt.i_chroma = VLC_CODEC_RGB8;
229         break;
230     case 15:
231         fmt.i_chroma = VLC_CODEC_RGB15;
232         break;
233     case 16:
234         fmt.i_chroma = VLC_CODEC_RGB16;
235         break;
236     case 24:
237         fmt.i_chroma = VLC_CODEC_RGB24;
238         break;
239     case 32:
240         fmt.i_chroma = VLC_CODEC_RGB32;
241         break;
242     default:
243         msg_Err(vd, "unknown screen depth %i",
244                 sys->var_info.bits_per_pixel);
245         Close(VLC_OBJECT(vd));
246         return VLC_EGENERIC;
247     }
248     if (sys->var_info.bits_per_pixel != 8) {
249         fmt.i_rmask = ((1 << sys->var_info.red.length) - 1)
250                              << sys->var_info.red.offset;
251         fmt.i_gmask = ((1 << sys->var_info.green.length) - 1)
252                              << sys->var_info.green.offset;
253         fmt.i_bmask = ((1 << sys->var_info.blue.length) - 1)
254                              << sys->var_info.blue.offset;
255     }
256     fmt.i_width  = sys->width;
257     fmt.i_height = sys->height;
258
259     /* */
260     vout_display_info_t info = vd->info;
261     info.has_hide_mouse = true;
262
263     /* */
264     vd->fmt     = fmt;
265     vd->info    = info;
266     vd->pool    = Pool;
267     vd->prepare = NULL;
268     vd->display = Display;
269     vd->control = Control;
270     vd->manage  = Manage;
271
272     /* */
273     vout_display_SendEventFullscreen(vd, true);
274     vout_display_SendEventDisplaySize(vd, fmt.i_width, fmt.i_height, true);
275     return VLC_SUCCESS;
276 }
277
278 /**
279  * Terminate an output method created by Open
280  */
281 static void Close(vlc_object_t *object)
282 {
283     vout_display_t *vd = (vout_display_t *)object;
284     vout_display_sys_t *sys = vd->sys;
285
286     if (sys->pool)
287         picture_pool_Delete(sys->pool);
288     if (!sys->is_hw_accel && sys->picture)
289         picture_Release(sys->picture);
290
291     CloseDisplay(vd);
292
293     if (sys->is_tty)
294         TtyExit(vd);
295
296     free(sys);
297 }
298
299 /* */
300 static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
301 {
302     vout_display_sys_t *sys = vd->sys;
303
304     if (!sys->pool) {
305         if (!sys->picture) {
306             picture_resource_t rsc;
307
308             memset(&rsc, 0, sizeof(rsc));
309             rsc.p[0].p_pixels = sys->video_ptr;
310             rsc.p[0].i_lines  = sys->var_info.yres;
311             rsc.p[0].i_pitch = sys->fix_info.line_length;
312
313             sys->picture = picture_NewFromResource(&vd->fmt, &rsc);
314             if (!sys->picture)
315                 return NULL;
316         }
317
318         if (sys->is_hw_accel)
319             sys->pool = picture_pool_New(1, &sys->picture);
320         else
321             sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
322     }
323     return sys->pool;
324 }
325 static void Display(vout_display_t *vd, picture_t *picture)
326 {
327     vout_display_sys_t *sys = vd->sys;
328
329     /* swap the two Y offsets if the drivers supports panning */
330     if (sys->has_pan) {
331         sys->var_info.yoffset = 0;
332         /*vd->sys->var_info.yoffset = vd->sys->var_info.yres; */
333
334         /* the X offset should be 0, but who knows ...
335          * some other app might have played with the framebuffer */
336         sys->var_info.xoffset = 0;
337
338         /* FIXME 'static' is damn wrong and it's dead code ... */
339         static int panned = 0;
340         if (panned < 0) {
341             ioctl(sys->fd, FBIOPAN_DISPLAY, &sys->var_info);
342             panned++;
343         }
344     }
345
346     if (!sys->is_hw_accel)
347         picture_Copy(sys->picture, picture);
348
349     picture_Release(picture);
350 }
351 static int Control(vout_display_t *vd, int query, va_list args)
352 {
353     vout_display_sys_t *sys = vd->sys;
354
355     switch (query) {
356     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: {
357         const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
358         if (cfg->display.width  != sys->width ||
359             cfg->display.height != sys->height)
360             return VLC_EGENERIC;
361         return VLC_SUCCESS;
362     }
363     default:
364         msg_Err(vd, "Unsupported query in vout display fb");
365         return VLC_EGENERIC;
366     }
367 }
368 static void Manage (vout_display_t *vd)
369 {
370     VLC_UNUSED(vd);
371 #if 0
372     /*
373      * Size change
374      */
375     if (vd->i_changes & VOUT_SIZE_CHANGE)
376     {
377         msg_Dbg(vd, "reinitializing framebuffer screen");
378         vd->i_changes &= ~VOUT_SIZE_CHANGE;
379
380         vout_display_SendEventDisplaySize();
381
382         /* Clear screen */
383         memset(vd->sys->video_ptr, 0, vd->sys->video_size);
384
385     }
386 #endif
387 }
388
389 /* following functions are local */
390 static int TtyInit(vout_display_t *vd)
391 {
392     vout_display_sys_t *sys = vd->sys;
393
394     struct termios new_termios;
395
396     GfxMode(sys->tty);
397
398     /* Set keyboard settings */
399     if (tcgetattr(0, &sys->old_termios) == -1) {
400         msg_Err(vd, "tcgetattr failed");
401     }
402
403     if (tcgetattr(0, &new_termios) == -1) {
404         msg_Err(vd, "tcgetattr failed");
405     }
406
407     /* new_termios.c_lflag &= ~ (ICANON | ISIG);
408     new_termios.c_lflag |= (ECHO | ECHOCTL); */
409     new_termios.c_lflag &= ~ (ICANON);
410     new_termios.c_lflag &= ~(ECHO | ECHOCTL);
411     new_termios.c_iflag = 0;
412     new_termios.c_cc[VMIN] = 1;
413     new_termios.c_cc[VTIME] = 0;
414
415     if (tcsetattr(0, TCSAFLUSH, &new_termios) == -1) {
416         msg_Err(vd, "tcsetattr failed");
417     }
418
419     ioctl(sys->tty, VT_RELDISP, VT_ACKACQ);
420
421     /* Set-up tty signal handler to be aware of tty changes */
422     struct sigaction sig_tty;
423     memset(&sig_tty, 0, sizeof(sig_tty));
424     sig_tty.sa_handler = SwitchDisplay;
425     sigemptyset(&sig_tty.sa_mask);
426     if (sigaction(SIGUSR1, &sig_tty, &sys->sig_usr1) ||
427         sigaction(SIGUSR2, &sig_tty, &sys->sig_usr2)) {
428         msg_Err(vd, "cannot set signal handler (%m)");
429         /* FIXME SIGUSR1 could have succeed */
430         goto error_signal;
431     }
432
433     /* Set-up tty according to new signal handler */
434     if (-1 == ioctl(sys->tty, VT_GETMODE, &sys->vt_mode)) {
435         msg_Err(vd, "cannot get terminal mode (%m)");
436         goto error;
437     }
438     struct vt_mode vt_mode = sys->vt_mode;
439     vt_mode.mode   = VT_PROCESS;
440     vt_mode.waitv  = 0;
441     vt_mode.relsig = SIGUSR1;
442     vt_mode.acqsig = SIGUSR2;
443
444     if (-1 == ioctl(sys->tty, VT_SETMODE, &vt_mode)) {
445         msg_Err(vd, "cannot set terminal mode (%m)");
446         goto error;
447     }
448     return VLC_SUCCESS;
449
450 error:
451     sigaction(SIGUSR1, &sys->sig_usr1, NULL);
452     sigaction(SIGUSR2, &sys->sig_usr2, NULL);
453 error_signal:
454     tcsetattr(0, 0, &sys->old_termios);
455     TextMode(sys->tty);
456     return VLC_EGENERIC;
457 }
458 static void TtyExit(vout_display_t *vd)
459 {
460     vout_display_sys_t *sys = vd->sys;
461
462     /* Reset the terminal */
463     ioctl(sys->tty, VT_SETMODE, &sys->vt_mode);
464
465     /* Remove signal handlers */
466     sigaction(SIGUSR1, &sys->sig_usr1, NULL);
467     sigaction(SIGUSR2, &sys->sig_usr2, NULL);
468
469     /* Reset the keyboard state */
470     tcsetattr(0, 0, &sys->old_termios);
471
472     /* Return to text mode */
473     TextMode(sys->tty);
474 }
475
476 /*****************************************************************************
477  * OpenDisplay: initialize framebuffer
478  *****************************************************************************/
479 static int OpenDisplay(vout_display_t *vd, bool force_resolution)
480 {
481     vout_display_sys_t *sys = vd->sys;
482     char *psz_device;                             /* framebuffer device path */
483
484     /* Open framebuffer device */
485     if (!(psz_device = config_GetPsz(vd, FB_DEV_VAR))) {
486         msg_Err(vd, "don't know which fb device to open");
487         return VLC_EGENERIC;
488     }
489
490     sys->fd = utf8_open(psz_device, O_RDWR);
491     if (sys->fd == -1) {
492         msg_Err(vd, "cannot open %s (%m)", psz_device);
493         free(psz_device);
494         return VLC_EGENERIC;
495     }
496     free(psz_device);
497
498     /* Get framebuffer device information */
499     if (ioctl(sys->fd, FBIOGET_VSCREENINFO, &sys->var_info)) {
500         msg_Err(vd, "cannot get fb info (%m)");
501         close(sys->fd);
502         return VLC_EGENERIC;
503     }
504     sys->old_info = sys->var_info;
505
506     /* Get some info on the framebuffer itself */
507     if (force_resolution) {
508         sys->var_info.xres = sys->var_info.xres_virtual = sys->width;
509         sys->var_info.yres = sys->var_info.yres_virtual = sys->height;
510     }
511
512     /* Set some attributes */
513     sys->var_info.activate = sys->is_tty ? FB_ACTIVATE_NXTOPEN :
514                                            FB_ACTIVATE_NOW;
515     sys->var_info.xoffset  =  0;
516     sys->var_info.yoffset  =  0;
517
518     if (ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->var_info)) {
519         msg_Err(vd, "cannot set fb info (%m)");
520         close(sys->fd);
521         return VLC_EGENERIC;
522     }
523
524     /* Get some information again, in the definitive configuration */
525     if (ioctl(sys->fd, FBIOGET_FSCREENINFO, &sys->fix_info) ||
526         ioctl(sys->fd, FBIOGET_VSCREENINFO, &sys->var_info)) {
527         msg_Err(vd, "cannot get additional fb info (%m)");
528
529         /* Restore fb config */
530         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
531
532         close(sys->fd);
533         return VLC_EGENERIC;
534     }
535
536     /* If the fb has limitations on mode change,
537      * then keep the resolution of the fb */
538     if ((sys->height != sys->var_info.yres) ||
539         (sys->width != sys->var_info.xres)) {
540         msg_Warn(vd,
541                  "using framebuffer native resolution instead of requested (%ix%i)",
542                  sys->width, sys->height);
543     }
544     sys->height = sys->var_info.yres;
545     sys->width  = sys->var_info.xres_virtual ? sys->var_info.xres_virtual :
546                                                sys->var_info.xres;
547
548     /* FIXME: if the image is full-size, it gets cropped on the left
549      * because of the xres / xres_virtual slight difference */
550     msg_Dbg(vd, "%ix%i (virtual %ix%i) (request %ix%i)",
551             sys->var_info.xres, sys->var_info.yres,
552             sys->var_info.xres_virtual,
553             sys->var_info.yres_virtual,
554             sys->width, sys->height);
555
556     sys->palette = NULL;
557     sys->has_pan = (sys->fix_info.ypanstep || sys->fix_info.ywrapstep);
558
559     switch (sys->var_info.bits_per_pixel) {
560     case 8:
561         sys->palette = malloc(8 * 256 * sizeof(uint16_t));
562         if (!sys->palette) {
563             /* Restore fb config */
564             ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
565
566             close(sys->fd);
567             return VLC_ENOMEM;
568         }
569         sys->fb_cmap.start = 0;
570         sys->fb_cmap.len = 256;
571         sys->fb_cmap.red = sys->palette;
572         sys->fb_cmap.green = sys->palette + 256 * sizeof(uint16_t);
573         sys->fb_cmap.blue = sys->palette + 2 * 256 * sizeof(uint16_t);
574         sys->fb_cmap.transp = sys->palette + 3 * 256 * sizeof(uint16_t);
575
576         /* Save the colormap */
577         ioctl(sys->fd, FBIOGETCMAP, &sys->fb_cmap);
578
579         sys->bytes_per_pixel = 1;
580         break;
581
582     case 15:
583     case 16:
584         sys->bytes_per_pixel = 2;
585         break;
586
587     case 24:
588         sys->bytes_per_pixel = 3;
589         break;
590
591     case 32:
592         sys->bytes_per_pixel = 4;
593         break;
594
595     default:
596         msg_Err(vd, "screen depth %d is not supported",
597                 sys->var_info.bits_per_pixel);
598
599         /* Restore fb config */
600         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
601
602         close(sys->fd);
603         return VLC_EGENERIC;
604     }
605
606     sys->video_size = sys->fix_info.line_length * sys->var_info.yres_virtual;
607
608     /* Map a framebuffer at the beginning */
609     sys->video_ptr = mmap(NULL, sys->video_size,
610                           PROT_READ | PROT_WRITE, MAP_SHARED, sys->fd, 0);
611
612     if (sys->video_ptr == MAP_FAILED) {
613         msg_Err(vd, "cannot map video memory (%m)");
614
615         if (sys->var_info.bits_per_pixel == 8) {
616             free(sys->palette);
617             sys->palette = NULL;
618         }
619
620         /* Restore fb config */
621         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
622
623         close(sys->fd);
624         return VLC_EGENERIC;
625     }
626     /* Clear the screen */
627     memset(sys->video_ptr, 0, sys->video_size);
628
629     msg_Dbg(vd,
630             "framebuffer type=%d, visual=%d, ypanstep=%d, ywrap=%d, accel=%d",
631             sys->fix_info.type, sys->fix_info.visual,
632             sys->fix_info.ypanstep, sys->fix_info.ywrapstep, sys->fix_info.accel);
633     return VLC_SUCCESS;
634 }
635
636 /*****************************************************************************
637  * CloseDisplay: terminate FB video thread output method
638  *****************************************************************************/
639 static void CloseDisplay(vout_display_t *vd)
640 {
641     vout_display_sys_t *sys = vd->sys;
642
643     if (sys->video_ptr != MAP_FAILED) {
644         /* Clear display */
645         memset(sys->video_ptr, 0, sys->video_size);
646         munmap(sys->video_ptr, sys->video_size);
647     }
648
649     if (sys->fd >= 0) {
650         /* Restore palette */
651         if (sys->var_info.bits_per_pixel == 8) {
652             ioctl(sys->fd, FBIOPUTCMAP, &sys->fb_cmap);
653             free(sys->palette);
654             sys->palette = NULL;
655         }
656
657         /* Restore fb config */
658         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
659
660         /* Close fb */
661         close(sys->fd);
662     }
663 }
664
665 /*****************************************************************************
666  * SwitchDisplay: VT change signal handler
667  *****************************************************************************
668  * This function activates or deactivates the output of the thread. It is
669  * called by the VT driver, on terminal change.
670  *****************************************************************************/
671 static void SwitchDisplay(int i_signal)
672 {
673     VLC_UNUSED(i_signal);
674 #if 0
675     vout_display_t *vd;
676
677     vlc_mutex_lock(&p_vout_bank->lock);
678
679     /* XXX: only test the first video output */
680     if (p_vout_bank->i_count)
681     {
682         vd = p_vout_bank->pp_vout[0];
683
684         switch (i_signal)
685         {
686         case SIGUSR1:                                /* vt has been released */
687             vd->b_active = 0;
688             ioctl(sys->tty, VT_RELDISP, 1);
689             break;
690         case SIGUSR2:                                /* vt has been acquired */
691             vd->b_active = 1;
692             ioctl(sys->tty, VT_RELDISP, VT_ACTIVATE);
693             /* handle blanking */
694             vlc_mutex_lock(&vd->change_lock);
695             vd->i_changes |= VOUT_SIZE_CHANGE;
696             vlc_mutex_unlock(&vd->change_lock);
697             break;
698         }
699     }
700
701     vlc_mutex_unlock(&p_vout_bank->lock);
702 #endif
703 }
704
705 /*****************************************************************************
706  * TextMode and GfxMode : switch tty to text/graphic mode
707  *****************************************************************************
708  * These functions toggle the tty mode.
709  *****************************************************************************/
710 static void TextMode(int tty)
711 {
712     /* return to text mode */
713     if (-1 == ioctl(tty, KDSETMODE, KD_TEXT)) {
714         /*msg_Err(vd, "failed ioctl KDSETMODE KD_TEXT");*/
715     }
716 }
717
718 static void GfxMode(int tty)
719 {
720     /* switch to graphic mode */
721     if (-1 == ioctl(tty, KDSETMODE, KD_GRAPHICS)) {
722         /*msg_Err(vd, "failed ioctl KDSETMODE KD_GRAPHICS");*/
723     }
724 }