]> git.sesse.net Git - vlc/blob - modules/video_output/fb.c
Updated vout display modules after ::get -> ::pool change.
[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     bool                        has_pan;   /* does device supports panning ? */
133     struct fb_cmap              fb_cmap;                /* original colormap */
134     uint16_t                    *palette;                /* original palette */
135     bool                        is_hw_accel;         /* has hardware support */
136
137     /* Video information */
138     uint32_t width;
139     uint32_t height;
140     int      bytes_per_pixel;
141
142     /* Video memory */
143     uint8_t     *video_ptr;                                  /* base adress */
144     size_t      video_size;                                    /* page size */
145
146     picture_t       *picture;
147     picture_pool_t  *pool;
148 };
149
150 /**
151  * This function allocates and initializes a FB vout method.
152  */
153 static int Open(vlc_object_t *object)
154 {
155     vout_display_t     *vd = (vout_display_t *)object;
156     vout_display_sys_t *sys;
157
158     /* Allocate instance and initialize some members */
159     vd->sys = sys = calloc(1, sizeof(*sys));
160     if (!sys)
161         return VLC_ENOMEM;
162
163     /* Does the framebuffer uses hw acceleration? */
164     sys->is_hw_accel = var_CreateGetBool(vd, "fb-hw-accel");
165
166     /* Set tty and fb devices */
167     sys->tty = 0; /* 0 == /dev/tty0 == current console */
168     sys->is_tty = var_CreateGetBool(vd, "fb-tty");
169 #if !defined(WIN32) &&  defined(HAVE_ISATTY)
170     /* Check that stdin is a TTY */
171     if (sys->is_tty && !isatty(0)) {
172         msg_Warn(vd, "fd 0 is not a TTY");
173         free(sys);
174         return VLC_EGENERIC;
175     }
176     msg_Warn(vd, "disabling tty handling, use with caution because "
177                  "there is no way to return to the tty.");
178 #endif
179
180     const int mode = var_CreateGetInteger(vd, "fb-mode");
181     bool force_resolution = true;
182     switch (mode) {
183     case 0: /* QCIF */
184         sys->width  = 176;
185         sys->height = 144;
186         break;
187     case 1: /* CIF */
188         sys->width  = 352;
189         sys->height = 288;
190         break;
191     case 2: /* NTSC */
192         sys->width  = 640;
193         sys->height = 480;
194         break;
195     case 3: /* PAL */
196         sys->width  = 704;
197         sys->height = 576;
198         break;
199     case 4:
200     default:
201         force_resolution = false;
202         break;
203     }
204
205     /* tty handling */
206     if (sys->is_tty && TtyInit(vd)) {
207         free(sys);
208         return VLC_EGENERIC;
209     }
210
211     /* */
212     sys->video_ptr = MAP_FAILED;
213     sys->picture = NULL;
214     sys->pool = NULL;
215
216     if (OpenDisplay(vd, force_resolution)) {
217         Close(VLC_OBJECT(vd));
218         return VLC_EGENERIC;
219     }
220
221     /* */
222     video_format_t fmt = vd->fmt;
223
224     msg_Err(vd, "var_info.bits_per_pixel = %d", sys->var_info.bits_per_pixel);
225     switch (sys->var_info.bits_per_pixel) {
226     case 8: /* FIXME: set the palette */
227         fmt.i_chroma = VLC_CODEC_RGB8;
228         break;
229     case 15:
230         fmt.i_chroma = VLC_CODEC_RGB15;
231         break;
232     case 16:
233         fmt.i_chroma = VLC_CODEC_RGB16;
234         break;
235     case 24:
236         fmt.i_chroma = VLC_CODEC_RGB24;
237         break;
238     case 32:
239         fmt.i_chroma = VLC_CODEC_RGB32;
240         break;
241     default:
242         msg_Err(vd, "unknown screen depth %i",
243                 sys->var_info.bits_per_pixel);
244         Close(VLC_OBJECT(vd));
245         return VLC_EGENERIC;
246     }
247     if (sys->var_info.bits_per_pixel != 8) {
248         fmt.i_rmask = ((1 << sys->var_info.red.length) - 1)
249                              << sys->var_info.red.offset;
250         fmt.i_gmask = ((1 << sys->var_info.green.length) - 1)
251                              << sys->var_info.green.offset;
252         fmt.i_bmask = ((1 << sys->var_info.blue.length) - 1)
253                              << sys->var_info.blue.offset;
254     }
255     fmt.i_width  = sys->width;
256     fmt.i_height = sys->height;
257
258     /* */
259     vout_display_info_t info = vd->info;
260     info.has_hide_mouse = true;
261
262     /* */
263     vd->fmt     = fmt;
264     vd->info    = info;
265     vd->pool    = Pool;
266     vd->prepare = NULL;
267     vd->display = Display;
268     vd->control = Control;
269     vd->manage  = Manage;
270
271     /* */
272     vout_display_SendEventFullscreen(vd, true);
273     vout_display_SendEventDisplaySize(vd, fmt.i_width, fmt.i_height, true);
274     return VLC_SUCCESS;
275 }
276
277 /**
278  * Terminate an output method created by Open
279  */
280 static void Close(vlc_object_t *object)
281 {
282     vout_display_t *vd = (vout_display_t *)object;
283     vout_display_sys_t *sys = vd->sys;
284
285     if (sys->pool)
286         picture_pool_Delete(sys->pool);
287     if (!sys->is_hw_accel && sys->picture)
288         picture_Release(sys->picture);
289
290     CloseDisplay(vd);
291
292     if (sys->is_tty)
293         TtyExit(vd);
294
295     free(sys);
296 }
297
298 /* */
299 static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
300 {
301     vout_display_sys_t *sys = vd->sys;
302
303     if (!sys->pool) {
304         if (!sys->picture) {
305             picture_resource_t rsc;
306
307             memset(&rsc, 0, sizeof(rsc));
308             rsc.p[0].p_pixels = sys->video_ptr;
309             rsc.p[0].i_lines  = sys->var_info.yres;
310             if (sys->var_info.xres_virtual)
311                 rsc.p[0].i_pitch = sys->var_info.xres_virtual *
312                                    sys->bytes_per_pixel;
313             else
314                 rsc.p[0].i_pitch = sys->var_info.xres *
315                                    sys->bytes_per_pixel;
316
317             sys->picture = picture_NewFromResource(&vd->fmt, &rsc);
318             if (!sys->picture)
319                 return NULL;
320         }
321
322         if (sys->is_hw_accel)
323             sys->pool = picture_pool_New(1, &sys->picture);
324         else
325             sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
326     }
327     return sys->pool;
328 }
329 static void Display(vout_display_t *vd, picture_t *picture)
330 {
331     vout_display_sys_t *sys = vd->sys;
332
333     /* swap the two Y offsets if the drivers supports panning */
334     if (sys->has_pan) {
335         sys->var_info.yoffset = 0;
336         /*vd->sys->var_info.yoffset = vd->sys->var_info.yres; */
337
338         /* the X offset should be 0, but who knows ...
339          * some other app might have played with the framebuffer */
340         sys->var_info.xoffset = 0;
341
342         /* FIXME 'static' is damn wrong and it's dead code ... */
343         static int panned = 0;
344         if (panned < 0) {
345             ioctl(sys->fd, FBIOPAN_DISPLAY, &sys->var_info);
346             panned++;
347         }
348     }
349
350     if (!sys->is_hw_accel)
351         picture_Copy(sys->picture, picture);
352
353     picture_Release(picture);
354 }
355 static int Control(vout_display_t *vd, int query, va_list args)
356 {
357     vout_display_sys_t *sys = vd->sys;
358
359     switch (query) {
360     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: {
361         const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
362         if (cfg->display.width  != sys->width ||
363             cfg->display.height != sys->height)
364             return VLC_EGENERIC;
365         return VLC_SUCCESS;
366     }
367     default:
368         msg_Err(vd, "Unsupported query in vout display fb");
369         return VLC_EGENERIC;
370     }
371 }
372 static void Manage (vout_display_t *vd)
373 {
374     VLC_UNUSED(vd);
375 #if 0
376     /*
377      * Size change
378      */
379     if (vd->i_changes & VOUT_SIZE_CHANGE)
380     {
381         msg_Dbg(vd, "reinitializing framebuffer screen");
382         vd->i_changes &= ~VOUT_SIZE_CHANGE;
383
384         vout_display_SendEventDisplaySize();
385
386         /* Clear screen */
387         memset(vd->sys->video_ptr, 0, vd->sys->video_size);
388
389     }
390 #endif
391 }
392
393 /* following functions are local */
394 static int TtyInit(vout_display_t *vd)
395 {
396     vout_display_sys_t *sys = vd->sys;
397
398     struct termios new_termios;
399
400     GfxMode(sys->tty);
401
402     /* Set keyboard settings */
403     if (tcgetattr(0, &sys->old_termios) == -1) {
404         msg_Err(vd, "tcgetattr failed");
405     }
406
407     if (tcgetattr(0, &new_termios) == -1) {
408         msg_Err(vd, "tcgetattr failed");
409     }
410
411     /* new_termios.c_lflag &= ~ (ICANON | ISIG);
412     new_termios.c_lflag |= (ECHO | ECHOCTL); */
413     new_termios.c_lflag &= ~ (ICANON);
414     new_termios.c_lflag &= ~(ECHO | ECHOCTL);
415     new_termios.c_iflag = 0;
416     new_termios.c_cc[VMIN] = 1;
417     new_termios.c_cc[VTIME] = 0;
418
419     if (tcsetattr(0, TCSAFLUSH, &new_termios) == -1) {
420         msg_Err(vd, "tcsetattr failed");
421     }
422
423     ioctl(sys->tty, VT_RELDISP, VT_ACKACQ);
424
425     /* Set-up tty signal handler to be aware of tty changes */
426     struct sigaction sig_tty;
427     memset(&sig_tty, 0, sizeof(sig_tty));
428     sig_tty.sa_handler = SwitchDisplay;
429     sigemptyset(&sig_tty.sa_mask);
430     if (sigaction(SIGUSR1, &sig_tty, &sys->sig_usr1) ||
431         sigaction(SIGUSR2, &sig_tty, &sys->sig_usr2)) {
432         msg_Err(vd, "cannot set signal handler (%m)");
433         /* FIXME SIGUSR1 could have succeed */
434         goto error_signal;
435     }
436
437     /* Set-up tty according to new signal handler */
438     if (-1 == ioctl(sys->tty, VT_GETMODE, &sys->vt_mode)) {
439         msg_Err(vd, "cannot get terminal mode (%m)");
440         goto error;
441     }
442     struct vt_mode vt_mode = sys->vt_mode;
443     vt_mode.mode   = VT_PROCESS;
444     vt_mode.waitv  = 0;
445     vt_mode.relsig = SIGUSR1;
446     vt_mode.acqsig = SIGUSR2;
447
448     if (-1 == ioctl(sys->tty, VT_SETMODE, &vt_mode)) {
449         msg_Err(vd, "cannot set terminal mode (%m)");
450         goto error;
451     }
452     return VLC_SUCCESS;
453
454 error:
455     sigaction(SIGUSR1, &sys->sig_usr1, NULL);
456     sigaction(SIGUSR2, &sys->sig_usr2, NULL);
457 error_signal:
458     tcsetattr(0, 0, &sys->old_termios);
459     TextMode(sys->tty);
460     return VLC_EGENERIC;
461 }
462 static void TtyExit(vout_display_t *vd)
463 {
464     vout_display_sys_t *sys = vd->sys;
465
466     /* Reset the terminal */
467     ioctl(sys->tty, VT_SETMODE, &sys->vt_mode);
468
469     /* Remove signal handlers */
470     sigaction(SIGUSR1, &sys->sig_usr1, NULL);
471     sigaction(SIGUSR2, &sys->sig_usr2, NULL);
472
473     /* Reset the keyboard state */
474     tcsetattr(0, 0, &sys->old_termios);
475
476     /* Return to text mode */
477     TextMode(sys->tty);
478 }
479
480 /*****************************************************************************
481  * OpenDisplay: initialize framebuffer
482  *****************************************************************************/
483 static int OpenDisplay(vout_display_t *vd, bool force_resolution)
484 {
485     vout_display_sys_t *sys = vd->sys;
486     char *psz_device;                             /* framebuffer device path */
487     struct fb_fix_screeninfo    fix_info;     /* framebuffer fix information */
488
489     /* Open framebuffer device */
490     if (!(psz_device = config_GetPsz(vd, FB_DEV_VAR))) {
491         msg_Err(vd, "don't know which fb device to open");
492         return VLC_EGENERIC;
493     }
494
495     sys->fd = utf8_open(psz_device, O_RDWR);
496     if (sys->fd == -1) {
497         msg_Err(vd, "cannot open %s (%m)", psz_device);
498         free(psz_device);
499         return VLC_EGENERIC;
500     }
501     free(psz_device);
502
503     /* Get framebuffer device information */
504     if (ioctl(sys->fd, FBIOGET_VSCREENINFO, &sys->var_info)) {
505         msg_Err(vd, "cannot get fb info (%m)");
506         close(sys->fd);
507         return VLC_EGENERIC;
508     }
509     sys->old_info = sys->var_info;
510
511     /* Get some info on the framebuffer itself */
512     if (force_resolution) {
513         sys->var_info.xres = sys->var_info.xres_virtual = sys->width;
514         sys->var_info.yres = sys->var_info.yres_virtual = sys->height;
515     }
516
517     /* Set some attributes */
518     sys->var_info.activate = sys->is_tty ? FB_ACTIVATE_NXTOPEN :
519                                            FB_ACTIVATE_NOW;
520     sys->var_info.xoffset  =  0;
521     sys->var_info.yoffset  =  0;
522
523     if (ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->var_info)) {
524         msg_Err(vd, "cannot set fb info (%m)");
525         close(sys->fd);
526         return VLC_EGENERIC;
527     }
528
529     /* Get some information again, in the definitive configuration */
530     if (ioctl(sys->fd, FBIOGET_FSCREENINFO, &fix_info) ||
531         ioctl(sys->fd, FBIOGET_VSCREENINFO, &sys->var_info)) {
532         msg_Err(vd, "cannot get additional fb info (%m)");
533
534         /* Restore fb config */
535         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
536
537         close(sys->fd);
538         return VLC_EGENERIC;
539     }
540
541     /* If the fb has limitations on mode change,
542      * then keep the resolution of the fb */
543     if ((sys->height != sys->var_info.yres) ||
544         (sys->width != sys->var_info.xres)) {
545         msg_Warn(vd,
546                  "using framebuffer native resolution instead of requested (%ix%i)",
547                  sys->width, sys->height);
548     }
549     sys->height = sys->var_info.yres;
550     sys->width  = sys->var_info.xres_virtual ? sys->var_info.xres_virtual :
551                                                sys->var_info.xres;
552
553     /* FIXME: if the image is full-size, it gets cropped on the left
554      * because of the xres / xres_virtual slight difference */
555     msg_Dbg(vd, "%ix%i (virtual %ix%i) (request %ix%i)",
556             sys->var_info.xres, sys->var_info.yres,
557             sys->var_info.xres_virtual,
558             sys->var_info.yres_virtual,
559             sys->width, sys->height);
560
561     sys->palette = NULL;
562     sys->has_pan = (fix_info.ypanstep || fix_info.ywrapstep);
563
564     switch (sys->var_info.bits_per_pixel) {
565     case 8:
566         sys->palette = malloc(8 * 256 * sizeof(uint16_t));
567         if (!sys->palette) {
568             /* Restore fb config */
569             ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
570
571             close(sys->fd);
572             return VLC_ENOMEM;
573         }
574         sys->fb_cmap.start = 0;
575         sys->fb_cmap.len = 256;
576         sys->fb_cmap.red = sys->palette;
577         sys->fb_cmap.green = sys->palette + 256 * sizeof(uint16_t);
578         sys->fb_cmap.blue = sys->palette + 2 * 256 * sizeof(uint16_t);
579         sys->fb_cmap.transp = sys->palette + 3 * 256 * sizeof(uint16_t);
580
581         /* Save the colormap */
582         ioctl(sys->fd, FBIOGETCMAP, &sys->fb_cmap);
583
584         sys->bytes_per_pixel = 1;
585         break;
586
587     case 15:
588     case 16:
589         sys->bytes_per_pixel = 2;
590         break;
591
592     case 24:
593         sys->bytes_per_pixel = 3;
594         break;
595
596     case 32:
597         sys->bytes_per_pixel = 4;
598         break;
599
600     default:
601         msg_Err(vd, "screen depth %d is not supported",
602                 sys->var_info.bits_per_pixel);
603
604         /* Restore fb config */
605         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
606
607         close(sys->fd);
608         return VLC_EGENERIC;
609     }
610
611     sys->video_size = sys->width * sys->height * sys->bytes_per_pixel;
612
613     /* Map a framebuffer at the beginning */
614     sys->video_ptr = mmap(NULL, sys->video_size,
615                           PROT_READ | PROT_WRITE, MAP_SHARED, sys->fd, 0);
616
617     if (sys->video_ptr == MAP_FAILED) {
618         msg_Err(vd, "cannot map video memory (%m)");
619
620         if (sys->var_info.bits_per_pixel == 8) {
621             free(sys->palette);
622             sys->palette = NULL;
623         }
624
625         /* Restore fb config */
626         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
627
628         close(sys->fd);
629         return VLC_EGENERIC;
630     }
631     /* Clear the screen */
632     memset(sys->video_ptr, 0, sys->video_size);
633
634     msg_Dbg(vd,
635             "framebuffer type=%d, visual=%d, ypanstep=%d, ywrap=%d, accel=%d",
636             fix_info.type, fix_info.visual,
637             fix_info.ypanstep, fix_info.ywrapstep, fix_info.accel);
638     return VLC_SUCCESS;
639 }
640
641 /*****************************************************************************
642  * CloseDisplay: terminate FB video thread output method
643  *****************************************************************************/
644 static void CloseDisplay(vout_display_t *vd)
645 {
646     vout_display_sys_t *sys = vd->sys;
647
648     if (sys->video_ptr != MAP_FAILED) {
649         /* Clear display */
650         memset(sys->video_ptr, 0, sys->video_size);
651         munmap(sys->video_ptr, sys->video_size);
652     }
653
654     if (sys->fd >= 0) {
655         /* Restore palette */
656         if (sys->var_info.bits_per_pixel == 8) {
657             ioctl(sys->fd, FBIOPUTCMAP, &sys->fb_cmap);
658             free(sys->palette);
659             sys->palette = NULL;
660         }
661
662         /* Restore fb config */
663         ioctl(sys->fd, FBIOPUT_VSCREENINFO, &sys->old_info);
664
665         /* Close fb */
666         close(sys->fd);
667     }
668 }
669
670 /*****************************************************************************
671  * SwitchDisplay: VT change signal handler
672  *****************************************************************************
673  * This function activates or deactivates the output of the thread. It is
674  * called by the VT driver, on terminal change.
675  *****************************************************************************/
676 static void SwitchDisplay(int i_signal)
677 {
678     VLC_UNUSED(i_signal);
679 #if 0
680     vout_display_t *vd;
681
682     vlc_mutex_lock(&p_vout_bank->lock);
683
684     /* XXX: only test the first video output */
685     if (p_vout_bank->i_count)
686     {
687         vd = p_vout_bank->pp_vout[0];
688
689         switch (i_signal)
690         {
691         case SIGUSR1:                                /* vt has been released */
692             vd->b_active = 0;
693             ioctl(sys->tty, VT_RELDISP, 1);
694             break;
695         case SIGUSR2:                                /* vt has been acquired */
696             vd->b_active = 1;
697             ioctl(sys->tty, VT_RELDISP, VT_ACTIVATE);
698             /* handle blanking */
699             vlc_mutex_lock(&vd->change_lock);
700             vd->i_changes |= VOUT_SIZE_CHANGE;
701             vlc_mutex_unlock(&vd->change_lock);
702             break;
703         }
704     }
705
706     vlc_mutex_unlock(&p_vout_bank->lock);
707 #endif
708 }
709
710 /*****************************************************************************
711  * TextMode and GfxMode : switch tty to text/graphic mode
712  *****************************************************************************
713  * These functions toggle the tty mode.
714  *****************************************************************************/
715 static void TextMode(int tty)
716 {
717     /* return to text mode */
718     if (-1 == ioctl(tty, KDSETMODE, KD_TEXT)) {
719         /*msg_Err(vd, "failed ioctl KDSETMODE KD_TEXT");*/
720     }
721 }
722
723 static void GfxMode(int tty)
724 {
725     /* switch to graphic mode */
726     if (-1 == ioctl(tty, KDSETMODE, KD_GRAPHICS)) {
727         /*msg_Err(vd, "failed ioctl KDSETMODE KD_GRAPHICS");*/
728     }
729 }