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