From a6de6457d2e3e8fd72df1e5aaf12ef1f41f5007d Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 19 Feb 2019 17:20:57 +0100 Subject: [PATCH] Convert SDL to a Nitpicker client library Fixes #138 --- ports/libxml2.hash | 2 +- ports/libxml2.port | 2 +- recipes/pkg/abuse/archives | 1 - recipes/pkg/abuse/runtime | 55 ++---- recipes/pkg/chocolate-doom/archives | 1 - recipes/pkg/chocolate-doom/runtime | 56 +----- recipes/src/sdl/used_apis | 1 + run/atari800.run | 2 +- run/avplay.run | 116 +----------- run/chocolate-doom.run | 173 +----------------- run/grafx2.run | 126 +------------ run/ltris.run | 23 +-- ...{framebuffer_app.inc => nitpicker_app.inc} | 50 ++++- run/numptyphysics.run | 17 +- run/sdl.run | 94 +--------- run/supertux.run | 15 +- run/tuxmath.run | 7 +- run/tyrian.run | 136 +------------- run/uhexen2.run | 129 ++----------- src/app/uhexen2/net_udp_genode.c | 3 +- src/app/uhexen2/target.mk | 2 +- src/lib/sdl/video/SDL_genode_fb_events.cc | 21 ++- src/lib/sdl/video/SDL_genode_fb_video.cc | 71 ++++--- src/test/sdl/main.cc | 1 - 24 files changed, 192 insertions(+), 912 deletions(-) rename run/{framebuffer_app.inc => nitpicker_app.inc} (52%) diff --git a/ports/libxml2.hash b/ports/libxml2.hash index 43e2fe0..28d9893 100644 --- a/ports/libxml2.hash +++ b/ports/libxml2.hash @@ -1 +1 @@ -b24c400f7a93a67b3b92d819bd6946c8e94a88e9 +eb3143d9b96a51dd960e53a4229df48bff1daccd diff --git a/ports/libxml2.port b/ports/libxml2.port index d6e8834..9e52093 100644 --- a/ports/libxml2.port +++ b/ports/libxml2.port @@ -2,7 +2,7 @@ LICENSE := MIT VERSION := git DOWNLOADS := libxml2.git -URL(libxml2) := git://git.gnome.org/libxml2 +URL(libxml2) := https://gitlab.gnome.org/GNOME/libxml2.git DIR(libxml2) := src/lib/libxml2 REV(libxml2) := v2.9.4 diff --git a/recipes/pkg/abuse/archives b/recipes/pkg/abuse/archives index c2de2eb..a106c4c 100644 --- a/recipes/pkg/abuse/archives +++ b/recipes/pkg/abuse/archives @@ -2,7 +2,6 @@ _/raw/abuse _/src/abuse _/src/jpeg _/src/libc -_/src/nit_fb _/src/sdl _/src/sdl_image _/src/sdl_mixer diff --git a/recipes/pkg/abuse/runtime b/recipes/pkg/abuse/runtime index 9235d29..fe4e686 100644 --- a/recipes/pkg/abuse/runtime +++ b/recipes/pkg/abuse/runtime @@ -1,23 +1,21 @@ - + + - - - @@ -28,45 +26,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1996-02-29 12:00 - - - - - - + + + + + + + + + + diff --git a/recipes/pkg/chocolate-doom/archives b/recipes/pkg/chocolate-doom/archives index 26d2cdf..f052874 100644 --- a/recipes/pkg/chocolate-doom/archives +++ b/recipes/pkg/chocolate-doom/archives @@ -1,7 +1,6 @@ _/src/chocolate-doom cnuke/raw/shareware-wads/18.08 _/src/libc -_/src/nit_fb _/src/sdl _/src/sdl_mixer _/src/sdl_net diff --git a/recipes/pkg/chocolate-doom/runtime b/recipes/pkg/chocolate-doom/runtime index ffe97f7..c16cfd1 100644 --- a/recipes/pkg/chocolate-doom/runtime +++ b/recipes/pkg/chocolate-doom/runtime @@ -1,15 +1,11 @@ - + - + - - - - @@ -19,47 +15,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2018-08-31 18:00 - - - - - - - - - - + + + + + + + diff --git a/recipes/src/sdl/used_apis b/recipes/src/sdl/used_apis index f88cce1..3cb71dd 100644 --- a/recipes/src/sdl/used_apis +++ b/recipes/src/sdl/used_apis @@ -6,4 +6,5 @@ zlib audio_out_session framebuffer_session input_session +nitpicker_session timer_session diff --git a/run/atari800.run b/run/atari800.run index 57921e0..3e31efc 100644 --- a/run/atari800.run +++ b/run/atari800.run @@ -34,4 +34,4 @@ set boot_modules { vfs.lib.so } -source ${genode_dir}/repos/world/run/framebuffer_app.inc +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/avplay.run b/run/avplay.run index 25b4a6d..80182dc 100644 --- a/run/avplay.run +++ b/run/avplay.run @@ -1,18 +1,4 @@ -# -# Build -# - -set build_components { - core init - timer - drivers/framebuffer drivers/input drivers/audio - app/avplay drivers/acpi -} - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components +set build_components { app/avplay } # # Download media file @@ -24,71 +10,7 @@ if {![file exists bin/mediafile]} { catch { exec wget -O bin/mediafile $media_url } } -proc audio_drv_attr { } { - if {[have_spec linux]} { - return {ld="no"} } - return ""; -} - -# -# Generate config -# - -create_boot_directory - -set config { - - - - - - - - - - - - - - - -} - -append_if [have_spec sdl] config { - - - - - - - - } - -append_platform_drv_config - -append_if [have_spec framebuffer] config { - - - - - } - -append_if [have_spec ps2] config { - - - - } - -append config { - - - - - - - - - +set app_config { @@ -103,38 +25,14 @@ append config { - - - - - - - -} + } -install_config $config - -# -# Boot modules -# - -append boot_modules { - core init timer } [audio_drv_binary] { avplay - ld.lib.so libc.lib.so vfs.lib.so vfs.lib.so vfs.lib.so libm.lib.so zlib.lib.so sdl.lib.so +set boot_modules { + avplay + libc.lib.so vfs.lib.so vfs.lib.so vfs.lib.so libm.lib.so zlib.lib.so sdl.lib.so avfilter.lib.so avutil.lib.so avcodec.lib.so avformat.lib.so swscale.lib.so avresample.lib.so mediafile } -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec framebuffer] boot_modules fb_drv -lappend_if [have_spec ps2] boot_modules ps2_drv - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - -append qemu_args " -soundhw es1370" - -run_genode_until forever - +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/chocolate-doom.run b/run/chocolate-doom.run index 87b444f..34d5fba 100644 --- a/run/chocolate-doom.run +++ b/run/chocolate-doom.run @@ -1,140 +1,6 @@ -# -# Build -# +set build_components { app/chocolate-doom/doom } -if {[have_include "power_on/qemu"]} { - puts "\nRunning on Qemu is not recommended.\n" - exit 1 -} - - -# -# On x86 systems w/o ps2 only use usb input -# -set use_usb_input_only 0 - -set use_audio [expr ![have_spec arm]] - -set build_components { - core init - timer - drivers/framebuffer - drivers/input - - app/chocolate-doom/doom -} - - -if {[have_spec linux]} { - set use_usb_input_only 1 -} - -lappend_if $use_audio build_components drivers/audio - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - - -lappend_if [expr ![have_spec linux]] build_components drivers/usb -lappend_if [expr !$use_usb_input_only] build_components server/input_merger - -build $build_components - -create_boot_directory - -# -# Generate config -# - -append config { - - - - - - - - - - - - - - - - - - - - - - - } - -append_if [have_spec sdl] config { - - - - - - - } - -append_platform_drv_config - -append_if [have_spec vesa] config { - - - - - } - -append_if [have_spec pl11x] config { - - - - } - -append_if [expr [have_spec ps2] && !$use_usb_input_only] config { - - - - } - -append_if [expr ![have_spec linux]] config { - - - - - - - } - -append_if $use_audio config { - - - - - } - -append_if [expr !$use_usb_input_only] config { - - - - - - - - - - - - - - - } - -append config { +set app_config { @@ -146,16 +12,8 @@ append config { - } -append_if [expr !$use_usb_input_only] config { - } -append config { - - - -} + } -install_config $config if {![file exists bin/data.tar]} { if {![file exists bin/doom1.wad]} { @@ -168,29 +26,10 @@ if {![file exists bin/data.tar]} { } } -# -# Boot modules -# - -# generic modules -append boot_modules { - core init timer } [audio_drv_binary] { - ld.lib.so libc.lib.so vfs.lib.so libm.lib.so pthread.lib.so +set boot_modules { + libc.lib.so vfs.lib.so libm.lib.so sdl.lib.so sdl_net.lib.so sdl_mixer.lib.so chocolate-doom doom1.wad } -# platform-specific modules -append_platform_drv_boot_modules - -lappend_if $use_audio boot_modules audio_drv -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec vesa] boot_modules fb_drv -lappend_if [expr ![have_spec linux]] boot_modules usb_drv -lappend_if [expr !$use_usb_input_only] boot_modules input_merger -lappend_if [expr [have_spec ps2] && !$use_usb_input_only] boot_modules ps2_drv -lappend_if [have_spec pl11x] boot_modules fb_drv - -build_boot_image $boot_modules - -run_genode_until forever +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/grafx2.run b/run/grafx2.run index 08ab75c..309e22e 100644 --- a/run/grafx2.run +++ b/run/grafx2.run @@ -1,97 +1,6 @@ -# -# Build -# - -set build_components { - core init - timer - app/grafx2 server/ram_fs - drivers/framebuffer drivers/platform drivers/input -} - -lappend_if [have_spec usb] build_components drivers/usb - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -append config { - - - - - - - - - - - - - - - - - - - - - - - } - -append_platform_drv_config - -append_if [have_spec sdl] config { - - - - - - - } - -append_if [have_spec platform_rpi] config { - - - - - } - -append_if [have_spec framebuffer] config { - - - - - } - -append_if [have_spec ps2] config { - - - - } - -append_if [expr ![have_spec ps2] && [have_spec usb]] config { - - - - - } - -append config { - - - - - +set build_components { app/grafx2 } +set app_config { @@ -99,30 +8,18 @@ append config { - + - -} + } -install_config $config - -# -# Boot modules -# - -# generic modules set boot_modules { - core init - timer ram_fs grafx2 jpeg.lib.so - ld.lib.so libc.lib.so vfs.lib.so libm.lib.so libpng.lib.so - pthread.lib.so sdl_image.lib.so sdl.lib.so zlib.lib.so @@ -130,17 +27,4 @@ set boot_modules { grafx2_data.tar } -# platform-specific modules -append_platform_drv_boot_modules - -# platform-specific modules -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec framebuffer] boot_modules fb_drv -lappend_if [have_spec ps2] boot_modules ps2_drv -lappend_if [have_spec usb] boot_modules usb_drv -lappend_if [have_spec platform_rpi] boot_modules platform_drv - -build_boot_image $boot_modules - - -run_genode_until forever +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/ltris.run b/run/ltris.run index a27e37d..f412482 100644 --- a/run/ltris.run +++ b/run/ltris.run @@ -1,18 +1,6 @@ -set build_components { app/ltris server/ram_fs } +set build_components { app/ltris } set app_config { - - - - - - - - - - - - @@ -22,17 +10,16 @@ set app_config { 2000-01-01 00:00 - + + } set boot_modules { - ram_fs ltris libc.lib.so vfs.lib.so libm.lib.so - pthread.lib.so sdl_mixer.lib.so sdl.lib.so stdcxx.lib.so @@ -40,6 +27,4 @@ set boot_modules { ltris_data.tar } -set fb_config {} - -source ${genode_dir}/repos/world/run/framebuffer_app.inc +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/framebuffer_app.inc b/run/nitpicker_app.inc similarity index 52% rename from run/framebuffer_app.inc rename to run/nitpicker_app.inc index 58a00dd..41aae7b 100644 --- a/run/framebuffer_app.inc +++ b/run/nitpicker_app.inc @@ -11,9 +11,11 @@ create_boot_directory -import_from_depot genodelabs/src/[base_src] \ - genodelabs/pkg/[drivers_interactive_pkg] \ - genodelabs/src/init +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/pkg/[drivers_interactive_pkg] \ + [depot_user]/src/init \ + [depot_user]/src/nitpicker \ + [depot_user]/pkg/motif_wm \ if {![info exists fb_config]} { @@ -39,6 +41,8 @@ install_config { + + @@ -63,12 +67,52 @@ install_config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } $app_config { } build $build_components +# +# Pin the nitpicker focus to the window manager by providing a static focus ROM +# +set fd [open [run_dir]/genode/focus w] +puts $fd " wm -> \"/>" +close $fd + +file copy -force [genode_dir]/repos/gems/recipes/raw/motif_wm/wm.config [run_dir]/genode/ + build_boot_image $boot_modules run_genode_until forever diff --git a/run/numptyphysics.run b/run/numptyphysics.run index 870a328..0a2a8b6 100644 --- a/run/numptyphysics.run +++ b/run/numptyphysics.run @@ -1,15 +1,6 @@ -set build_components { app/numptyphysics server/ram_fs } - -set fb_config { } +set build_components { app/numptyphysics } set app_config { - - - - - - - @@ -19,20 +10,18 @@ set app_config { 2000-01-01 00:00 - + } set boot_modules { - ram_fs numptyphysics freetype.lib.so jpeg.lib.so libc.lib.so vfs.lib.so libm.lib.so libpng.lib.so - pthread.lib.so sdl_image.lib.so sdl.lib.so sdl_ttf.lib.so @@ -41,4 +30,4 @@ set boot_modules { numptyphysics_data.tar } -source ${genode_dir}/repos/world/run/framebuffer_app.inc +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/sdl.run b/run/sdl.run index 3f3d94d..de66718 100644 --- a/run/sdl.run +++ b/run/sdl.run @@ -1,101 +1,17 @@ -# -# Build -# +set build_components { test/sdl } -set build_components { - core init - timer - test/sdl - drivers/framebuffer drivers/input -} - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -append config { - - - - - - - - - - - - - - - } - -append_if [have_spec sdl] config { - - - - - - - } - -append_platform_drv_config - -append_if [have_spec framebuffer] config { - - - - } - -append_if [have_spec ps2] config { - - - - } - -append config { - - - - +set app_config { - -} + } -install_config $config - -# -# Boot modules -# - -# generic modules set boot_modules { - core init - timer test-sdl - ld.lib.so libc.lib.so vfs.lib.so libm.lib.so sdl.lib.so + libc.lib.so vfs.lib.so libm.lib.so sdl.lib.so } -# platform-specific modules -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec framebuffer] boot_modules fb_drv -lappend_if [have_spec ps2] boot_modules ps2_drv - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - - -run_genode_until forever +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/supertux.run b/run/supertux.run index d2c9273..f9ce3f2 100644 --- a/run/supertux.run +++ b/run/supertux.run @@ -1,13 +1,6 @@ -set build_components { app/supertux server/ram_fs } +set build_components { app/supertux } set app_config { - - - - - - - @@ -17,19 +10,17 @@ set app_config { 2000-01-01 00:00 - + } set boot_modules { - ram_fs supertux jpeg.lib.so libc.lib.so vfs.lib.so libm.lib.so libpng.lib.so - pthread.lib.so sdl_image.lib.so sdl_mixer.lib.so sdl.lib.so @@ -38,4 +29,4 @@ set boot_modules { supertux_data.tar } -source ${genode_dir}/repos/world/run/framebuffer_app.inc +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/tuxmath.run b/run/tuxmath.run index d60caa9..477f6a8 100644 --- a/run/tuxmath.run +++ b/run/tuxmath.run @@ -1,8 +1,8 @@ set build_components { app/tuxmath } set app_config { - - + + @@ -18,7 +18,6 @@ set boot_modules { tuxmath libc.lib.so vfs.lib.so libm.lib.so - pthread.lib.so libiconv.lib.so jpeg.lib.so freetype.lib.so @@ -32,4 +31,4 @@ set boot_modules { tuxmath_data.tar } -source ${genode_dir}/repos/world/run/framebuffer_app.inc +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/tyrian.run b/run/tyrian.run index 5181d06..0900fae 100644 --- a/run/tyrian.run +++ b/run/tyrian.run @@ -1,104 +1,8 @@ -# -# Build -# +set build_components { app/opentyrian } -set build_components { - core init - drivers/audio - drivers/framebuffer - drivers/input - drivers/input/dummy - timer - app/opentyrian -} - -source ${genode_dir}/repos/base/run/platform_drv.inc -# override default platform driver policy -proc platform_drv_policy {} { - return { - - - - } -} - -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -append config { - - - - - - - - - - - - - - - - - - } - -append_platform_drv_config - -append_if [have_spec sdl] config { - - - - - - - - - - } - -append_if [have_spec vesa] config { - - - - - } - -append_if [have_spec pl11x] config { - - - - - } - -append_if [have_spec ps2] config { - - - - } - -append config { - - - - - - - - - +set app_config { - @@ -109,45 +13,19 @@ append config { - -} + } -install_config $config +create_boot_directory -# -# Boot modules -# +file copy -force app/opentyrian/tyrian.tar [run_dir]/genode -file copy -force app/opentyrian/tyrian.tar bin - -# generic modules -append boot_modules { - core init -} [audio_drv_binary] { - dummy_input_drv - ld.lib.so +set boot_modules { libc.lib.so vfs.lib.so libm.lib.so libpng.lib.so - pthread.lib.so - posix.lib.so sdl.lib.so sdl_net.lib.so - stdcxx.lib.so - timer opentyrian tyrian.tar } -# platform-specific modules -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec vesa] boot_modules fb_drv -lappend_if [have_spec ps2] boot_modules ps2_drv -lappend_if [have_spec pl11x] boot_modules fb_drv - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - -append qemu_args " -soundhw es1370 " - -run_genode_until forever +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/run/uhexen2.run b/run/uhexen2.run index fbb94e3..4db4aac 100644 --- a/run/uhexen2.run +++ b/run/uhexen2.run @@ -1,115 +1,27 @@ - -# Build -# - - set build_components { - core init - timer - drivers/audio - drivers/usb - drivers/framebuffer drivers/input app/uhexen2 + lib/vfs/lwip + server/nic_loopback } -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -append config { - - - - - - - - - - - - - - - - - - - - +set app_config { + - - } - -append_if [have_spec sdl] config { - - - - - - - } - -append_platform_drv_config - -append_if [have_spec vesa] config { - - - - - - - - - - } - -append_if [have_spec pl11x] config { - - - - } - -append_if [have_spec ps2] config { - - - - } - -append config { - - - - + - + - + + + - - - - - -} - -install_config $config + } if {![file exists bin/hexen2demo_data.tar]} { set hexen2demo_dir "hexen2demo_nov1997" @@ -137,22 +49,11 @@ if {![file exists bin/hexen2demo_data.tar]} { # generic modules append boot_modules { - core init timer } [audio_drv_binary] { - ld.lib.so libc.lib.so vfs.lib.so libm.lib.solwip_legacy.lib.so - pthread.lib.so sdl.lib.so sdl_mixer.lib.so + libc.lib.so vfs.lib.so libm.lib.so + sdl.lib.so sdl_mixer.lib.so uhexen2 hexen2demo_data.tar + vfs_lwip.lib.so + nic_loopback } -# platform-specific modules -append_platform_drv_boot_modules - -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec vesa] boot_modules fb_drv -lappend_if [have_spec ps2] boot_modules ps2_drv -lappend_if [have_spec pl11x] boot_modules fb_drv - -build_boot_image $boot_modules - -append qemu_args " -soundhw es1370 " - -run_genode_until forever +source ${genode_dir}/repos/world/run/nitpicker_app.inc diff --git a/src/app/uhexen2/net_udp_genode.c b/src/app/uhexen2/net_udp_genode.c index 38101d4..2392ea0 100644 --- a/src/app/uhexen2/net_udp_genode.c +++ b/src/app/uhexen2/net_udp_genode.c @@ -138,8 +138,7 @@ int UDP_OpenSocket (int port) if ((newsocket = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return -1; - if (ioctl (newsocket, FIONBIO, (char *)&_true) == -1) - goto ErrorReturn; + ioctl (newsocket, FIONBIO, (char *)&_true); address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; diff --git a/src/app/uhexen2/target.mk b/src/app/uhexen2/target.mk index e9beee9..b01eb3b 100644 --- a/src/app/uhexen2/target.mk +++ b/src/app/uhexen2/target.mk @@ -118,7 +118,7 @@ CC_OPT += -DNO_ALSA_AUDIO -DNO_OSS_AUDIO -DNO_SUN_AUDIO CC_OPT += -DDEMOBUILD -LIBS = libc libc_lwip lwip libm sdl sdlmain sdl_mixer +LIBS = libc libm sdl sdlmain sdl_mixer vpath % $(UHEXEN2_DIR)/common vpath % $(UHEXEN2_DIR)/engine/hexen2 diff --git a/src/lib/sdl/video/SDL_genode_fb_events.cc b/src/lib/sdl/video/SDL_genode_fb_events.cc index e22d903..0a1f117 100644 --- a/src/lib/sdl/video/SDL_genode_fb_events.cc +++ b/src/lib/sdl/video/SDL_genode_fb_events.cc @@ -30,6 +30,7 @@ */ /* Genode includes */ +#include #include #include #include @@ -45,15 +46,26 @@ Video video_events; static Genode::Env *_global_env = nullptr; +static Genode::Constructible _global_nitpicker { }; -Genode::Env *global_env() + +Genode::Env &global_env() { if (!_global_env) { Genode::error("sdl_init_genode() not called, aborting"); throw Genode::Exception(); } - return _global_env; + return *_global_env; +} + + +Nitpicker::Connection &global_nitpicker() +{ + if (!_global_nitpicker.constructed()) + _global_nitpicker.construct(global_env(), "SDL"); + + return *_global_nitpicker; } @@ -71,7 +83,7 @@ extern "C" { #include "SDL_genode_fb_events.h" - static Genode::Constructible input; + static Genode::Constructible input; static const int KEYNUM_MAX = 512; static SDLKey keymap[KEYNUM_MAX]; static int buttonmap[KEYNUM_MAX]; @@ -154,7 +166,8 @@ extern "C" { void Genode_Fb_InitOSKeymap(SDL_VideoDevice *t) { try { - input.construct(*_global_env); + input.construct(_global_env->rm(), + _global_nitpicker->input_session()); } catch (...) { Genode::error("no input driver available!"); return; diff --git a/src/lib/sdl/video/SDL_genode_fb_video.cc b/src/lib/sdl/video/SDL_genode_fb_video.cc index 6b0ad25..18aaa5a 100644 --- a/src/lib/sdl/video/SDL_genode_fb_video.cc +++ b/src/lib/sdl/video/SDL_genode_fb_video.cc @@ -32,13 +32,14 @@ /* Genode includes */ #include #include -#include +#include /* local includes */ #include -extern Genode::Env *global_env(); +extern Genode::Env &global_env(); +extern Nitpicker::Connection &global_nitpicker(); extern Genode::Lock event_lock; extern Video video_events; @@ -61,16 +62,16 @@ extern "C" { struct Sdl_framebuffer { - Genode::Env &_env; - - Framebuffer::Mode _mode; - Framebuffer::Connection _fb { _env, _mode }; + Genode::Env &_env; + Nitpicker::Connection &_nitpicker; + Nitpicker::Session::View_handle _view { + _nitpicker.create_view() }; void _handle_mode_change() { Genode::Lock_guard guard(event_lock); - Framebuffer::Mode mode = _fb.mode(); + Framebuffer::Mode mode = _nitpicker.mode(); df_mode.w = mode.width(); df_mode.h = mode.height(); @@ -82,22 +83,41 @@ extern "C" { Genode::Signal_handler _mode_handler { _env.ep(), *this, &Sdl_framebuffer::_handle_mode_change }; - Sdl_framebuffer(Genode::Env &env) : _env(env) { - _fb.mode_sigh(_mode_handler); } - - bool valid() const { return _fb.cap().valid(); } + Sdl_framebuffer(Genode::Env &env, Nitpicker::Connection &nitpicker) + : _env(env), _nitpicker(nitpicker) { + _nitpicker.mode_sigh(_mode_handler); } /************************************ ** Framebuffer::Session Interface ** ************************************/ - Genode::Dataspace_capability dataspace() { return _fb.dataspace(); } + Genode::Dataspace_capability dataspace(int width, int height) + { + _nitpicker.buffer( + ::Framebuffer::Mode(width, height, Framebuffer::Mode::RGB565), + false); - Framebuffer::Mode mode() const { return _fb.mode(); } + ::Framebuffer::Mode mode = _nitpicker.framebuffer()->mode(); + + using namespace Nitpicker; + Area area( + Genode::min(mode.width(), width), + Genode::min(mode.height(), height)); + + typedef Nitpicker::Session::Command Command; + _nitpicker.enqueue( + _view, Rect(Point(0, 0), area)); + _nitpicker.execute(); + + return _nitpicker.framebuffer()->dataspace(); + } + + Framebuffer::Mode mode() const { + return _nitpicker.mode(); } void refresh(int x, int y, int w, int h) { - _fb.refresh(x, y, w, h); } + _nitpicker.framebuffer()->refresh(x, y, w, h); } }; static Genode::Constructible framebuffer; @@ -265,12 +285,7 @@ extern "C" { static int Genode_Fb_Available(void) { if (!framebuffer.constructed()) { - framebuffer.construct(*global_env()); - } - - if (!framebuffer->valid()) { - Genode::error("could not obtain framebuffer session"); - return 0; + framebuffer.construct(global_env(), global_nitpicker()); } return 1; @@ -362,6 +377,7 @@ extern "C" { /* Get the framebuffer size and mode infos */ scr_mode = framebuffer->mode(); + t->info.current_w = scr_mode.width(); t->info.current_h = scr_mode.height(); Genode::log("Framebuffer has " @@ -407,22 +423,20 @@ extern "C" { } if (t->hidden->buffer) { - global_env()->rm().detach(t->hidden->buffer); + global_env().rm().detach(t->hidden->buffer); t->hidden->buffer = nullptr; } } /** - * List the available video modes for the given pixel format, - * sorted from largest to smallest. + * Any mode is okay if the pixel format is 16bit */ SDL_Rect **Genode_Fb_ListModes(SDL_VideoDevice *t, SDL_PixelFormat *format, Uint32 flags) { - if(format->BitsPerPixel != 16) { return (SDL_Rect **) 0; } - return modes; + return (SDL_Rect **)((format->BitsPerPixel == 16) ? -1 : 0); } @@ -457,17 +471,18 @@ extern "C" { } /* Map the buffer */ - Genode::Dataspace_capability fb_ds_cap = framebuffer->dataspace(); + Genode::Dataspace_capability fb_ds_cap = + framebuffer->dataspace(width, height); if (!fb_ds_cap.valid()) { Genode::error("could not request dataspace for frame buffer"); return nullptr; } if (t->hidden->buffer) { - global_env()->rm().detach(t->hidden->buffer); + global_env().rm().detach(t->hidden->buffer); } - t->hidden->buffer = global_env()->rm().attach(fb_ds_cap); + t->hidden->buffer = global_env().rm().attach(fb_ds_cap); if (!t->hidden->buffer) { Genode::error("no buffer for requested mode"); diff --git a/src/test/sdl/main.cc b/src/test/sdl/main.cc index 0bbae81..f6e9c92 100644 --- a/src/test/sdl/main.cc +++ b/src/test/sdl/main.cc @@ -34,7 +34,6 @@ /* Genode includes */ #include -#include #include