Add QEMU DirectFB display driver
PATCH 1/1 Add QEMU DirectFB display driver
This patch implements a DirectFB driver for QEMU. It allows Qemu to draw a VM graphic output directly in the framebuffer of the host, without having to rely on X11.
DirectFB also provides with a generic interface take advantage of graphic hardware acceleration for a bunch of different supported cards.
In this driver, the DirectFB library gives Qemu a pointer to mapped video memory, which allows Qemu to update the display without extra copy. In the case where the guest framebuffer is not compatible with the host framebuffer, DirectFB surface blitting functions are used and can be accellerated wherever it is possible with the hardware.
DirectFB is a thin library heavily used in embedded or minimal systems which don't require X11 overhead. One use case would be to build a Xen-based client-class hypervisor, with a minimal dom0 running Qemu as device-model. The dom0 could render the domU graphical outputs on the physical screen using this patch without having X11 installed.
The other solution would be to use the DirectFB driver for SDL which would allow to do slightly the same as this patch. But that would mean having to deal with an additional layer in the graphical stack, which is not exactly what one wants from a performance or a complexity point of view.
As an example, the SDL library gives no garantee that the surface pointer returned by SDL_SetVideoMode(), if called with the SDL_HWSURFACE, will be located in video memory [1], especially if the SDL main surface is not fullscreen. For this reason, you can never assume that SDL will not perform extra copy operations on your behalf without notifying you.
[1] http://www.libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode
--- Makefile | 4 + Makefile.objs | 1 + configure | 21 +++ console.h | 3 + directfb.c | 394 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 10 ++ sysemu.h | 1 + vl.c | 12 ++ 8 files changed, 446 insertions(+), 0 deletions(-) create mode 100644 directfb.c
Makefile +4 -0
@@ -106,6 +106,10 @@ sdl.o: sdl.c keymaps.h sdl_keysym.h sdl_zoom.h sdl.o audio/sdlaudio.o sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) +directfb.o: directfb.c + +directfb.o: QEMU_CFLAGS += $(DIRECTFB_CFLAGS) + acl.o: acl.h acl.c vnc.h: vnc-tls.h vnc-auth-vencrypt.h vnc-auth-sasl.h keymaps.h
Makefile.objs +1 -0
@@ -102,6 +102,7 @@ common-obj-y += $(addprefix audio/, $(audio-obj-y)) common-obj-y += keymaps.o common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o common-obj-$(CONFIG_CURSES) += curses.o +common-obj-$(CONFIG_DIRECTFB) += directfb.o common-obj-y += vnc.o acl.o d3des.o common-obj-y += vnc-encoding-zlib.o vnc-encoding-hextile.o common-obj-y += iov.o
configure +21 -0
@@ -258,6 +258,7 @@ kvm="" kvm_para="" nptl="" sdl="" +directfb="no" sparse="no" uuid="" vde=""
@@ -502,6 +503,10 @@ for opt do ;; --sysconfdir=*) sysconfdir="$optarg" ;; + --disable-directfb) directfb="no" + ;; + --enable-directfb) directfb="yes" + ;; --disable-sdl) sdl="no" ;; --enable-sdl) sdl="yes"
@@ -763,6 +768,8 @@ echo " --disable-strip disable stripping binaries" echo " --disable-werror disable compilation abort on warning" echo " --disable-sdl disable SDL" echo " --enable-sdl enable SDL" +echo " --disable-directfb disable DirectFB" +echo " --enable-directfb enable DirectFB" echo " --enable-cocoa enable COCOA (Mac OS X only)" echo " --audio-drv-list=LIST set audio drivers list:" echo " Available drivers: $audio_possible_drivers"
@@ -1062,6 +1069,15 @@ if test "$sparse" != "no" ; then fi ########################################## +# DirectFB probe + +if test "$directfb" = "yes" ; then + directfb_libs=`directfb-config --libs` + directfb_cflags=`directfb-config --cflags` + libs_softmmu="$directfb_libs $libs_softmmu" +fi + +########################################## # SDL probe if $pkgconfig sdl --modversion >/dev/null 2>&1; then
@@ -1999,6 +2015,7 @@ if test "$darwin" = "yes" ; then echo "Cocoa support $cocoa" fi echo "SDL support $sdl" +echo "DirectFB support $directfb" echo "curses support $curses" echo "curl support $curl" echo "check support $check_utests"
@@ -2169,6 +2186,10 @@ fi if test "$cocoa" = "yes" ; then echo "CONFIG_COCOA=y" >> $config_host_mak fi +if test "$directfb" = "yes" ; then + echo "CONFIG_DIRECTFB=y" >> $config_host_mak + echo "DIRECTFB_CFLAGS=$directfb_cflags" >> $config_host_mak +fi if test "$curses" = "yes" ; then echo "CONFIG_CURSES=y" >> $config_host_mak fi
console.h +3 -0
@@ -335,6 +335,9 @@ void qemu_console_resize(DisplayState *ds, int width, int height);void qemu_console_copy (DisplayState *ds,int src_x,int src_y,int dst_x,int dst_y,int w,int h); +/* directfb.c */ +void directfb_display_init (DisplayState *ds); +/* sdl.c */ void sdl_display_init (DisplayState *ds,int full_screen,int no_frame);
directfb.c new file +394 -0
394 lines not on this page · raw message
qemu-options.hx +10 -0
@@ -608,6 +608,16 @@ QEMU can display the VGA output when in text mode using a curses/ncurses interface. Nothing is displayed in graphical mode. ETEXI +#ifdef CONFIG_DIRECTFB +DEF("directfb", 0, QEMU_OPTION_directfb, + "-directfb enable DirectFB\n") +#endif +STEXI +@item -directfb +@findex -directfb +Enable DirectFB. +ETEXI + #ifdef CONFIG_SDL DEF("no-frame", 0, QEMU_OPTION_no_frame, "-no-frame open SDL window without a frame and window decorations\n",
sysemu.h +1 -0
@@ -98,6 +98,7 @@ typedef enum DisplayTypeDT_CURSES ,DT_SDL ,DT_VNC , +DT_DIRECTFB ,DT_NOGRAPHIC , } DisplayType;
vl.c +12 -0
@@ -3199,6 +3199,11 @@ int main(int argc, char **argv, char **envp)case QEMU_OPTION_full_screen: full_screen =1 ;break ; +#ifdef CONFIG_DIRECTFB +case QEMU_OPTION_directfb: + display_type =DT_DIRECTFB ; +break ; +#endif #ifdef CONFIG_SDL case QEMU_OPTION_no_frame: no_frame =1 ;
@@ -3765,6 +3770,8 @@ int main(int argc, char **argv, char **envp)if (display_type ==DT_DEFAULT ) {#if defined(CONFIG_SDL ) || defined(CONFIG_COCOA ) display_type =DT_SDL ; +#elif defined(CONFIG_DIRECTFB ) + display_type =DT_DIRECTFB ;#else display_type =DT_VNC ; vnc_display ="localhost:0,to=99" ;
@@ -3781,6 +3788,11 @@ int main(int argc, char **argv, char **envp)curses_display_init (ds, full_screen);break ;#endif +#if defined(CONFIG_DIRECTFB ) +case DT_DIRECTFB : +directfb_display_init (ds); +break ; +#endif #if defined(CONFIG_SDL )case DT_SDL :sdl_display_init (ds, full_screen, no_frame);
Signature · 1 line
1.7.0.3