]> git.sesse.net Git - vlc/blobdiff - modules/video_output/fb.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / modules / video_output / fb.c
index 33b4bdee863d02d369e8a8d7490b459e257994a2..ecd5f34c82ff1b4248802781506639017737ecc7 100644 (file)
@@ -30,7 +30,6 @@
 # include "config.h"
 #endif
 
-#include <errno.h>                                                 /* ENOMEM */
 #include <signal.h>                                      /* SIGUSR1, SIGUSR2 */
 #include <fcntl.h>                                                 /* open() */
 #include <unistd.h>                                               /* close() */
@@ -47,7 +46,7 @@
 #include <vlc_plugin.h>
 #include <vlc_vout_display.h>
 #include <vlc_picture_pool.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
 
 /*****************************************************************************
  * Module descriptor
 #define DEVICE_LONGTEXT N_(\
     "Framebuffer device to use for rendering (usually /dev/fb0).")
 
-#define TTY_TEXT N_("Run fb on current tty.")
+#define TTY_TEXT N_("Run fb on current tty")
 #define TTY_LONGTEXT N_(\
     "Run framebuffer on current TTY device (default enabled). " \
     "(disable tty handling with caution)")
 
-#define FB_MODE_TEXT N_("Framebuffer resolution to use.")
+#define FB_MODE_TEXT N_("Framebuffer resolution to use")
 #define FB_MODE_LONGTEXT N_(\
     "Select the resolution for the framebuffer. Currently it supports " \
     "the values 0=QCIF 1=CIF 2=NTSC 3=PAL, 4=auto (default 4=auto)")
 
-#define HW_ACCEL_TEXT N_("Framebuffer uses hw acceleration.")
+#define HW_ACCEL_TEXT N_("Framebuffer uses hw acceleration")
 #define HW_ACCEL_LONGTEXT N_(\
     "If your framebuffer supports hardware acceleration or does double buffering " \
     "in hardware then you must disable this option. It then does double buffering " \
     "in software.")
 
-#define CHROMA_TEXT N_("Image format (default RGB).")
+#define CHROMA_TEXT N_("Image format (default RGB)")
 #define CHROMA_LONGTEXT N_("Chroma fourcc used by the framebuffer. Default is RGB since the fb device has no way to report its chroma.")
 
 static int  Open (vlc_object_t *);
@@ -109,7 +108,9 @@ static void           Manage (vout_display_t *);
 /* */
 static int  OpenDisplay  (vout_display_t *, bool force_resolution);
 static void CloseDisplay (vout_display_t *);
+#if 0
 static void SwitchDisplay(int i_signal);
+#endif
 static void TextMode     (int tty);
 static void GfxMode      (int tty);
 
@@ -124,8 +125,10 @@ struct vout_display_sys_t {
     struct termios      old_termios;
 
     /* Original configuration information */
+#if 0
     struct sigaction            sig_usr1;           /* USR1 previous handler */
     struct sigaction            sig_usr2;           /* USR2 previous handler */
+#endif
     struct vt_mode              vt_mode;                 /* previous VT mode */
 
     /* Framebuffer information */
@@ -145,7 +148,7 @@ struct vout_display_sys_t {
     int      bytes_per_pixel;
 
     /* Video memory */
-    uint8_t     *video_ptr;                                  /* base adress */
+    uint8_t     *video_ptr;                                 /* base address */
     size_t      video_size;                                    /* page size */
 
     picture_t       *picture;
@@ -153,13 +156,11 @@ struct vout_display_sys_t {
 };
 
 
-static void clear_screen(vout_display_sys_t *sys)
+static void ClearScreen(vout_display_sys_t *sys)
 {
-    switch (sys->chroma)
-    {
+    switch (sys->chroma) {
     /* XXX: add other chromas */
-    case VLC_CODEC_UYVY:
-    {
+    case VLC_CODEC_UYVY: {
         unsigned int j, size = sys->video_size / 4;
         uint32_t *ptr = (uint32_t*)((uintptr_t)(sys->video_ptr + 3) & ~3);
         for(j=0; j < size; j++)
@@ -193,12 +194,12 @@ static int Open(vlc_object_t *object)
 #if !defined(WIN32) &&  defined(HAVE_ISATTY)
     /* Check that stdin is a TTY */
     if (sys->is_tty && !isatty(0)) {
-        msg_Warn(vd, "fd 0 is not a TTY");
+        msg_Warn(vd, "standard input is not a TTY");
         free(sys);
         return VLC_EGENERIC;
     }
-    msg_Warn(vd, "disabling tty handling, use with caution because "
-                 "there is no way to return to the tty.");
+    msg_Warn(vd, "disabling TTY handling, use with caution because "
+                 "there is no way to return to the TTY");
 #endif
 
     const int mode = var_CreateGetInteger(vd, "fb-mode");
@@ -226,19 +227,17 @@ static int Open(vlc_object_t *object)
         break;
     }
 
-    char *psz_chroma = var_CreateGetNonEmptyString (vd, "fb-chroma");
-    if (psz_chroma)
-    {
-        sys->chroma = vlc_fourcc_GetCodecFromString (VIDEO_ES, psz_chroma);
+    char *chroma = var_CreateGetNonEmptyString(vd, "fb-chroma");
+    if (chroma) {
+        sys->chroma = vlc_fourcc_GetCodecFromString(VIDEO_ES, chroma);
 
         if (sys->chroma)
-            msg_Dbg (vd, "forcing chroma '%s'", psz_chroma);
+            msg_Dbg(vd, "forcing chroma '%s'", chroma);
         else
-            msg_Warn (vd, "chroma %s invalid, using default", psz_chroma);
+            msg_Warn(vd, "chroma %s invalid, using default", chroma);
 
-        free(psz_chroma);
-    }
-    else
+        free(chroma);
+    } else
         sys->chroma = 0;
 
     /* tty handling */
@@ -256,19 +255,17 @@ static int Open(vlc_object_t *object)
         Close(VLC_OBJECT(vd));
         return VLC_EGENERIC;
     }
+    vout_display_DeleteWindow(vd, NULL);
 
     /* */
     video_format_t fmt = vd->fmt;
 
-    if (sys->chroma)
-    {
+    if (sys->chroma) {
         fmt.i_chroma = sys->chroma;
-    }
-    else
-    {
+    } else {
         /* Assume RGB */
 
-        msg_Dbg (vd, "%d bppd", sys->var_info.bits_per_pixel);
+        msg_Dbg(vd, "%d bppd", sys->var_info.bits_per_pixel);
         switch (sys->var_info.bits_per_pixel) {
         case 8: /* FIXME: set the palette */
             fmt.i_chroma = VLC_CODEC_RGB8;
@@ -426,7 +423,7 @@ static void Manage (vout_display_t *vd)
 
         vout_display_SendEventDisplaySize();
 
-        clear_screen (vd->sys);
+        ClearScreen(vd->sys);
     }
 #endif
 }
@@ -463,6 +460,7 @@ static int TtyInit(vout_display_t *vd)
 
     ioctl(sys->tty, VT_RELDISP, VT_ACKACQ);
 
+#if 0
     /* Set-up tty signal handler to be aware of tty changes */
     struct sigaction sig_tty;
     memset(&sig_tty, 0, sizeof(sig_tty));
@@ -474,6 +472,7 @@ static int TtyInit(vout_display_t *vd)
         /* FIXME SIGUSR1 could have succeed */
         goto error_signal;
     }
+#endif
 
     /* Set-up tty according to new signal handler */
     if (-1 == ioctl(sys->tty, VT_GETMODE, &sys->vt_mode)) {
@@ -493,9 +492,11 @@ static int TtyInit(vout_display_t *vd)
     return VLC_SUCCESS;
 
 error:
+#if 0
     sigaction(SIGUSR1, &sys->sig_usr1, NULL);
     sigaction(SIGUSR2, &sys->sig_usr2, NULL);
 error_signal:
+#endif
     tcsetattr(0, 0, &sys->old_termios);
     TextMode(sys->tty);
     return VLC_EGENERIC;
@@ -507,9 +508,11 @@ static void TtyExit(vout_display_t *vd)
     /* Reset the terminal */
     ioctl(sys->tty, VT_SETMODE, &sys->vt_mode);
 
+#if 0
     /* Remove signal handlers */
     sigaction(SIGUSR1, &sys->sig_usr1, NULL);
     sigaction(SIGUSR2, &sys->sig_usr2, NULL);
+#endif
 
     /* Reset the keyboard state */
     tcsetattr(0, 0, &sys->old_termios);
@@ -527,12 +530,12 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
     char *psz_device;                             /* framebuffer device path */
 
     /* Open framebuffer device */
-    if (!(psz_device = config_GetPsz(vd, FB_DEV_VAR))) {
+    if (!(psz_device = var_InheritString(vd, FB_DEV_VAR))) {
         msg_Err(vd, "don't know which fb device to open");
         return VLC_EGENERIC;
     }
 
-    sys->fd = utf8_open(psz_device, O_RDWR);
+    sys->fd = vlc_open(psz_device, O_RDWR);
     if (sys->fd == -1) {
         msg_Err(vd, "cannot open %s (%m)", psz_device);
         free(psz_device);
@@ -671,7 +674,7 @@ static int OpenDisplay(vout_display_t *vd, bool force_resolution)
         return VLC_EGENERIC;
     }
 
-    clear_screen (sys);
+    ClearScreen(sys);
 
     msg_Dbg(vd,
             "framebuffer type=%d, visual=%d, ypanstep=%d, ywrap=%d, accel=%d",
@@ -688,7 +691,7 @@ static void CloseDisplay(vout_display_t *vd)
     vout_display_sys_t *sys = vd->sys;
 
     if (sys->video_ptr != MAP_FAILED) {
-        clear_screen (sys);
+        ClearScreen(sys);
         munmap(sys->video_ptr, sys->video_size);
     }
 
@@ -708,6 +711,7 @@ static void CloseDisplay(vout_display_t *vd)
     }
 }
 
+#if 0
 /*****************************************************************************
  * SwitchDisplay: VT change signal handler
  *****************************************************************************
@@ -716,8 +720,6 @@ static void CloseDisplay(vout_display_t *vd)
  *****************************************************************************/
 static void SwitchDisplay(int i_signal)
 {
-    VLC_UNUSED(i_signal);
-#if 0
     vout_display_t *vd;
 
     vlc_mutex_lock(&p_vout_bank->lock);
@@ -745,8 +747,8 @@ static void SwitchDisplay(int i_signal)
     }
 
     vlc_mutex_unlock(&p_vout_bank->lock);
-#endif
 }
+#endif
 
 /*****************************************************************************
  * TextMode and GfxMode : switch tty to text/graphic mode