Patchwork [05/19] chardev: add braille support to qapi

login
register
mail settings
Submitter Gerd Hoffmann
Date March 12, 2013, 8:56 a.m.
Message ID <1363078589-15233-6-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/226843/
State New
Headers show

Comments

Gerd Hoffmann - March 12, 2013, 8:56 a.m.
This patch adds 'braille' support to qapi and also switches over
the braille chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 backends/baum.c     |    4 ++--
 include/char/char.h |    3 +++
 qapi-schema.json    |    3 ++-
 qemu-char.c         |    5 +++++
 4 files changed, 12 insertions(+), 3 deletions(-)

Patch

diff --git a/backends/baum.c b/backends/baum.c
index 9063aea..d7d658c 100644
--- a/backends/baum.c
+++ b/backends/baum.c
@@ -561,7 +561,7 @@  static void baum_close(struct CharDriverState *chr)
     g_free(baum);
 }
 
-static CharDriverState *chr_baum_init(QemuOpts *opts)
+CharDriverState *chr_baum_init(void)
 {
     BaumDriverState *baum;
     CharDriverState *chr;
@@ -627,7 +627,7 @@  fail_handle:
 
 static void register_types(void)
 {
-    register_char_driver("braille", chr_baum_init);
+    register_char_driver_qapi("braille", CHARDEV_BACKEND_KIND_BRAILLE, NULL);
 }
 
 type_init(register_types);
diff --git a/include/char/char.h b/include/char/char.h
index 80e8e30..d6a0351 100644
--- a/include/char/char.h
+++ b/include/char/char.h
@@ -264,4 +264,7 @@  CharDriverState *qemu_char_get_next_serial(void);
 /* msmouse */
 CharDriverState *qemu_chr_open_msmouse(void);
 
+/* baum.c */
+CharDriverState *chr_baum_init(void);
+
 #endif
diff --git a/qapi-schema.json b/qapi-schema.json
index b14c5c7..5dcfbfe 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3211,7 +3211,8 @@ 
                                        'pty'    : 'ChardevDummy',
                                        'null'   : 'ChardevDummy',
                                        'mux'    : 'ChardevMux',
-                                       'msmouse': 'ChardevDummy' } }
+                                       'msmouse': 'ChardevDummy',
+                                       'braille': 'ChardevDummy' } }
 
 ##
 # @ChardevReturn:
diff --git a/qemu-char.c b/qemu-char.c
index c5244d7..1991c82 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3698,6 +3698,11 @@  ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
     case CHARDEV_BACKEND_KIND_MSMOUSE:
         chr = qemu_chr_open_msmouse();
         break;
+#ifdef CONFIG_BRLAPI
+    case CHARDEV_BACKEND_KIND_BRAILLE:
+        chr = chr_baum_init();
+        break;
+#endif
     default:
         error_setg(errp, "unknown chardev backend (%d)", backend->kind);
         break;