This patch adds a fbdev monitor command to enable/disable the fbdev display at runtime to both qmp and hmp.
qmp: framebuffer-display enable=on|off hmp: framebuffer-display on|off Signed-off-by: Gerd Hoffmann <kra...@redhat.com> --- hmp-commands.hx | 15 +++++++++++++++ hmp.c | 9 +++++++++ hmp.h | 1 + qapi-schema.json | 13 +++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 19 +++++++++++++++++++ 6 files changed, 63 insertions(+), 0 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index ed67e99..93e75ab 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1377,6 +1377,21 @@ passed since 1970, i.e. unix epoch. ETEXI { + .name = "framebuffer-display", + .args_type = "enable:b", + .params = "on|off", + .help = "enable/disable linux console framebuffer display", + .mhandler.cmd = hmp_framebuffer_display, + }, + +STEXI +@item framebuffer-display on | off +@findex framebuffer-display + +enable/disable linux console framebuffer display. +ETEXI + + { .name = "info", .args_type = "item:s?", .params = "[subcommand]", diff --git a/hmp.c b/hmp.c index ba6fbd3..9677ef6 100644 --- a/hmp.c +++ b/hmp.c @@ -1168,3 +1168,12 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict) qmp_screendump(filename, &err); hmp_handle_error(mon, &err); } + +void hmp_framebuffer_display(Monitor *mon, const QDict *qdict) +{ + int enable = qdict_get_bool(qdict, "enable"); + Error *errp = NULL; + + qmp_framebuffer_display(enable, &errp); + hmp_handle_error(mon, &errp); +} diff --git a/hmp.h b/hmp.h index 48b9c59..20aa08c 100644 --- a/hmp.h +++ b/hmp.h @@ -73,5 +73,6 @@ void hmp_getfd(Monitor *mon, const QDict *qdict); void hmp_closefd(Monitor *mon, const QDict *qdict); void hmp_send_key(Monitor *mon, const QDict *qdict); void hmp_screen_dump(Monitor *mon, const QDict *qdict); +void hmp_framebuffer_display(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 14e4419..87c77f7 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2619,3 +2619,16 @@ # Since: 0.14.0 ## { 'command': 'screendump', 'data': {'filename': 'str'} } + +# @framebuffer-display: +# +# Enable/disable linux console framebuffer display. +# +# @enable: whenever the framebuffer display should be enabled or disabled. +# +# Returns: Nothing. +# +# Since: 1.3 +# +## +{ 'command': 'framebuffer-display', 'data': {'enable': 'bool'} } diff --git a/qmp-commands.hx b/qmp-commands.hx index 6e21ddb..e0a747a 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2539,3 +2539,9 @@ EQMP .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_target, }, + + { + .name = "framebuffer-display", + .args_type = "enable:b", + .mhandler.cmd_new = qmp_marshal_input_framebuffer_display, + }, diff --git a/qmp.c b/qmp.c index 8463922..56e007f 100644 --- a/qmp.c +++ b/qmp.c @@ -391,6 +391,25 @@ void qmp_change(const char *device, const char *target, } } +void qmp_framebuffer_display(bool enable, Error **errp) +{ +#if defined(CONFIG_LINUX) + DisplayState *ds = get_displaystate(); + + if (enable) { + if (fbdev_display_init(ds, NULL, errp) != 0) { + if (!error_is_set(errp)) { + error_setg(errp, "fbdev initialization failed"); + } + } + } else { + fbdev_display_uninit(ds); + } +#else + error_setg(errp, "fbdev support disabled at compile time"); +#endif +} + static void qom_list_types_tramp(ObjectClass *klass, void *data) { ObjectTypeInfoList *e, **pret = data; -- 1.7.1