]> git.sesse.net Git - vlc/commitdiff
HW Pixel Doubling and Backlight-on for Maemo devices
authorRémi Denis-Courmont <rem@videolan.org>
Wed, 9 May 2007 18:48:21 +0000 (18:48 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Wed, 9 May 2007 18:48:21 +0000 (18:48 +0000)
Patch courtesy of Tapio Hiltunen, Technical Research Center of Finland

THANKS
configure.ac
modules/video_output/x11/xcommon.c
modules/video_output/x11/xcommon.h

diff --git a/THANKS b/THANKS
index 88b2bcaee4798eae4ff8359d8ee87516384fd67a..b5ab9950b048be206f87606dd3682f005d375545 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -171,6 +171,7 @@ Steve Brown <sbrown at cortland.com> - fix for optional PES size bug
 Steven M. Schultz <sms at TO.GD-ES.COM> - BSD/OS port
 Steven Sheehy - wxWidgets interface fix
 Tadashi Jokagi <elf2000 at users.sourceforge dot net> - Japanese translation
+Tapio Hiltunen <Tapio dot Hiltunen at vtt dot fi> - Maemo X11 enhancements
 Tim 'O Callaghan <tim.ocallaghan at limestudios dot com> - pvr input cleaning patch
 Tim Schuerewegen <ma054331 at skynet dot be> - contrib fixes
 Thomas Graf <tgraf at europe.com> - gettext support, German translation
index d4303996167320596cd7120b6d9e2540fd673a61..d95654d6b4e93a963d82d0391c737b93f0fffa2f 100644 (file)
@@ -5578,6 +5578,18 @@ fi
 AC_LANG_POP(C++)
 AM_CONDITIONAL(BUILD_MOZILLA,${mozilla})
 
+dnl Tests for Osso and Xsp
+AC_CHECK_LIB(osso, osso_display_blanking_pause,[
+   PKG_CHECK_MODULES(GLIB2, glib-2.0, [                                                  
+       VLC_ADD_CPPFLAGS([x11],[-DHAVE_OSSO ${DBUS_CFLAGS} ${GLIB2_CFLAGS}])
+       VLC_ADD_LDFLAGS([x11],[-losso])
+   ])
+])
+AC_CHECK_LIB(Xsp, XSPSetPixelDoubling,[
+   VLC_ADD_CPPFLAGS([x11],[-DHAVE_XSP])
+   VLC_ADD_LDFLAGS([x11],[-lXsp])
+])
+
 dnl
 dnl  Mediacontrol Python bindings
 dnl
index 6d47910fa58908fffbb2d11de5ad62d38bdf2d16..03c8630505145a55b8e661ea1eb28a37a73c889a 100644 (file)
 #   include <netinet/in.h>                            /* BSD: struct in_addr */
 #endif
 
+#ifdef HAVE_XSP
+#include <X11/extensions/Xsp.h>
+#endif
+
 #ifdef HAVE_SYS_SHM_H
 #   include <sys/shm.h>                                /* shmget(), shmctl() */
 #endif
@@ -149,6 +153,17 @@ static int WindowOnTop( vout_thread_t *, vlc_bool_t );
 
 static int X11ErrorHandler( Display *, XErrorEvent * );
 
+#ifdef HAVE_XSP
+static void EnablePixelDoubling( vout_thread_t *p_vout );
+static void DisablePixelDoubling( vout_thread_t *p_vout );
+#endif
+
+#ifdef HAVE_OSSO
+static const int i_backlight_on_interval = 300;
+#endif
+
+
+
 /*****************************************************************************
  * Activate: allocate X11 video thread output method
  *****************************************************************************
@@ -371,6 +386,20 @@ int E_(Activate) ( vlc_object_t *p_this )
     p_vout->p_sys->last_date = 0;
 #endif
 
+#ifdef HAVE_XSP
+    p_vout->p_sys->i_hw_scale = 1;
+#endif
+    
+#ifdef HAVE_OSSO
+    p_vout->p_sys->i_backlight_on_counter = i_backlight_on_interval; 
+    p_vout->p_sys->p_octx = osso_initialize( "vlc", VERSION, 0, NULL );
+    if ( p_vout->p_sys->p_octx == NULL ) {
+        msg_Err( p_vout, "Could not get osso context" );
+    } else {
+        msg_Dbg( p_vout, "Initialized osso context" );
+    }
+#endif
+                   
     /* Variable to indicate if the window should be on top of others */
     /* Trigger a callback right now */
     var_Get( p_vout, "video-on-top", &val );
@@ -428,6 +457,10 @@ void E_(Deactivate) ( vlc_object_t *p_this )
     }
 #endif
 
+#ifdef HAVE_XSP
+    DisablePixelDoubling(p_vout);
+#endif
+           
     DestroyCursor( p_vout );
     EnableXScreenSaver( p_vout );
     DestroyWindow( p_vout, &p_vout->p_sys->original_window );
@@ -439,6 +472,13 @@ void E_(Deactivate) ( vlc_object_t *p_this )
     free_context_lock( &p_vout->p_sys->xvmc_lock );
 #endif
 
+#ifdef HAVE_OSSO
+    if ( p_vout->p_sys->p_octx != NULL ) {
+        msg_Dbg( p_vout, "Deinitializing osso context" );
+        osso_deinitialize( p_vout->p_sys->p_octx );
+    }
+#endif
+       
     free( p_vout->p_sys );
 }
 
@@ -673,6 +713,41 @@ static void RenderVideo( vout_thread_t *p_vout, picture_t *p_pic )
 }
 #endif
 
+#ifdef HAVE_XSP
+/*****************************************************************************
+ * EnablePixelDoubling: Enables pixel doubling
+ *****************************************************************************
+ * Checks if the double size image fits in current window, and enables pixel
+ * doubling accordingly. The i_hw_scale is the integer scaling factor.
+ *****************************************************************************/
+static void EnablePixelDoubling( vout_thread_t *p_vout )
+{
+    int i_hor_scale = ( p_vout->p_sys->p_win->i_width ) / p_vout->render.i_width;
+    int i_vert_scale =  ( p_vout->p_sys->p_win->i_height ) / p_vout->render.i_height;
+    if ( ( i_hor_scale > 1 ) && ( i_vert_scale > 1 ) ) {
+        p_vout->p_sys->i_hw_scale = 2;
+        msg_Dbg( p_vout, "Enabling pixel doubling, scaling factor %d", p_vout->p_sys->i_hw_scale );
+        XSPSetPixelDoubling( p_vout->p_sys->p_display, 0, 1 );
+    }
+}
+
+/*****************************************************************************
+ * DisablePixelDoubling: Disables pixel doubling
+ *****************************************************************************
+ * The scaling factor i_hw_scale is reset to the no-scaling value 1.
+ *****************************************************************************/
+static void DisablePixelDoubling( vout_thread_t *p_vout )
+{
+    if ( p_vout->p_sys->i_hw_scale > 1 ) {
+        msg_Dbg( p_vout, "Disabling pixel doubling" );
+        XSPSetPixelDoubling( p_vout->p_sys->p_display, 0, 0 );
+        p_vout->p_sys->i_hw_scale = 1;
+    }
+}
+#endif
+
+
+
 /*****************************************************************************
  * InitVideo: initialize X11 video thread output method
  *****************************************************************************
@@ -743,11 +818,19 @@ static int InitVideo( vout_thread_t *p_vout )
             return VLC_SUCCESS;
     }
 
+#ifdef HAVE_XSP
+    vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width  / p_vout->p_sys->i_hw_scale,
+                       p_vout->p_sys->p_win->i_height  / p_vout->p_sys->i_hw_scale,
+                       &i_index, &i_index,
+                       &p_vout->fmt_out.i_visible_width,
+                       &p_vout->fmt_out.i_visible_height );
+#else
     vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width,
                        p_vout->p_sys->p_win->i_height,
                        &i_index, &i_index,
                        &p_vout->fmt_out.i_visible_width,
                        &p_vout->fmt_out.i_visible_height );
+#endif
 
     p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
 
@@ -1421,7 +1504,22 @@ static int ManageVideo( vout_thread_t *p_vout )
 #ifdef MODULE_NAME_IS_xvmc
     xvmc_context_reader_unlock( &p_vout->p_sys->xvmc_lock );
 #endif
-
+    
+#ifdef HAVE_OSSO
+    if ( p_vout->p_sys->p_octx != NULL ) {
+        if ( p_vout->p_sys->i_backlight_on_counter == i_backlight_on_interval ) {
+            if ( osso_display_blanking_pause( p_vout->p_sys->p_octx ) != OSSO_OK ) {
+                msg_Err( p_vout, "Could not disable backlight blanking" );
+           } else {
+                msg_Dbg( p_vout, "Backlight blanking disabled" );
+            }
+            p_vout->p_sys->i_backlight_on_counter = 0;
+        } else {
+            p_vout->p_sys->i_backlight_on_counter ++;
+        }
+    }
+#endif
+           
     vlc_mutex_unlock( &p_vout->p_sys->lock );
     return 0;
 }
@@ -2117,11 +2215,20 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
                            p_vout->p_sys->p_win->i_y,
                            p_vout->p_sys->p_win->i_width,
                            p_vout->p_sys->p_win->i_height );
+
+#ifdef HAVE_XSP
+        EnablePixelDoubling( p_vout );
+#endif
+               
     }
     else
     {
         msg_Dbg( p_vout, "leaving fullscreen mode" );
 
+#ifdef HAVE_XSP
+        DisablePixelDoubling( p_vout );
+#endif
+
         XReparentWindow( p_vout->p_sys->p_display,
                          p_vout->p_sys->original_window.video_window,
                          p_vout->p_sys->original_window.base_window, 0, 0 );
index b16768b5255becb892041f9947ec7c2f9299dba4..9618994c1e0cdb1f24fb575254a818df8053fbc8 100644 (file)
@@ -51,6 +51,9 @@
         VLC_FOURCC( i & 0xff, (i >> 8) & 0xff, (i >> 16) & 0xff, \
                     (i >> 24) & 0xff )
 
+#ifdef HAVE_OSSO
+#include <libosso.h>
+#endif
 
 /*****************************************************************************
  * x11_window_t: X11 window descriptor
@@ -206,6 +209,17 @@ struct vout_sys_t
 
     //alphablend_t       alphablend_extra_data;
 #endif
+
+#ifdef HAVE_XSP
+    int                 i_hw_scale;
+#endif 
+
+#ifdef HAVE_OSSO
+    osso_context_t      *p_octx;
+    int                 i_backlight_on_counter;
+#endif
+
+    
 };
 
 /*****************************************************************************