diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2010-12-20 08:28:03 -0800 |
---|---|---|
committer | Vladimir Chtchetkine <vchtchetkine@google.com> | 2010-12-20 08:28:03 -0800 |
commit | e95660aadc669784406d5f5a867988b8ecc2ed0d (patch) | |
tree | 480b3feaa14f6d392ceed62dba9cd0334dcba48d /android/console.c | |
parent | aec5741a217d98db6007219c4e28dc24d3ecdb03 (diff) | |
download | external_qemu-e95660aadc669784406d5f5a867988b8ecc2ed0d.zip external_qemu-e95660aadc669784406d5f5a867988b8ecc2ed0d.tar.gz external_qemu-e95660aadc669784406d5f5a867988b8ecc2ed0d.tar.bz2 |
Resubmit framebuffer service implementation
Change-Id: I184e27a1e8d88835bc9f0502eccfa3f64a7aaf9e
Diffstat (limited to 'android/console.c')
-rw-r--r-- | android/console.c | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/android/console.c b/android/console.c index 68b9480..398218a 100644 --- a/android/console.c +++ b/android/console.c @@ -25,7 +25,6 @@ #include "qemu-char.h" #include "sysemu.h" #include "android/android.h" -#include "sockets.h" #include "cpu.h" #include "hw/goldfish_device.h" #include "hw/power_supply.h" @@ -52,6 +51,8 @@ #include "android/keycode-array.h" #include "android/charmap.h" #include "android/core-ui-protocol.h" +#include "android/display-core.h" +#include "android/framebuffer-core.h" #if defined(CONFIG_SLIRP) #include "libslirp.h" @@ -112,9 +113,14 @@ typedef struct ControlGlobalRec_ } ControlGlobalRec; +#ifdef CONFIG_STANDALONE_CORE /* UI client currently attached to the core. */ ControlClient attached_ui_client = NULL; +/* Core framebuffer service client. */ +ControlClient framebuffer_client = NULL; +#endif // CONFIG_STANDALONE_CORE + static int control_global_add_redir( ControlGlobal global, int host_port, @@ -214,10 +220,21 @@ control_client_destroy( ControlClient client ) D(( "destroying control client %p\n", client )); +#ifdef CONFIG_STANDALONE_CORE if (client == attached_ui_client) { attached_ui_client = NULL; } + if (client == framebuffer_client) { + CoreFramebuffer* core_fb = coredisplay_detach_fb_service(); + if (core_fb != NULL) { + corefb_destroy(core_fb); + AFREE(core_fb); + } + framebuffer_client = NULL; + } +#endif // CONFIG_STANDALONE_CORE + sock = control_client_detach( client ); if (sock >= 0) socket_close(sock); @@ -2436,6 +2453,7 @@ do_qemu_monitor( ControlClient client, char* args ) return 0; } +#ifdef CONFIG_STANDALONE_CORE /* UI settings, passed to the core via -ui-settings command line parameter. */ extern char* android_op_ui_settings; @@ -2463,16 +2481,73 @@ do_attach_ui( ControlClient client, char* args ) return 0; } +/* Core display instance. */ +extern CoreDisplay core_display; + +static int +do_create_framebuffer_service( ControlClient client, char* args ) +{ + CoreFramebuffer* core_fb; + const char* protocol = "-raw"; // Default framebuffer exchange protocol. + + // Protocol type is defined by the arguments passed with the stream switch + // command. + if (args != NULL && *args != '\0') { + size_t token_len; + const char* param_end = strchr(args, ' '); + if (param_end == NULL) { + param_end = args + strlen(args); + } + token_len = param_end - args; + protocol = args; + + // Make sure that this is one of the supported protocols. + if (strncmp(protocol, "-raw", token_len) && + strncmp(protocol, "-shared", token_len)) { + derror("Invalid framebuffer parameter %s\n", protocol); + control_write( client, "KO: Invalid parameter\r\n" ); + control_client_destroy(client); + return -1; + } + } + + // Make sure that there are no framebuffer client already existing. + if (framebuffer_client != NULL) { + control_write( client, "KO: Another framebuffer service is already existing!\r\n" ); + control_client_destroy(client); + return -1; + } + + core_fb = corefb_create(client->sock, protocol); + if (!coredisplay_attach_fb_service(core_fb)) { + framebuffer_client = client; + control_write( client, "OK\r\n"); + } else { + control_write( client, "KO\r\n" ); + control_client_destroy(client); + return -1; + } + + return 0; +} +#endif // CONFIG_STANDALONE_CORE + static const CommandDefRec qemu_commands[] = { { "monitor", "enter QEMU monitor", "Enter the QEMU virtual machine monitor\r\n", NULL, do_qemu_monitor, NULL }, +#ifdef CONFIG_STANDALONE_CORE { "attach UI", "attach UI to the core", "Attach UI to the core\r\n", NULL, do_attach_ui, NULL }, + { "framebuffer", "create framebuffer service", + "Create framebuffer service\r\n", + NULL, do_create_framebuffer_service, NULL }, +#endif // CONFIG_STANDALONE_CORE + { NULL, NULL, NULL, NULL, NULL, NULL } }; |