linux framebuffer display driver
v2 cover linux framebuffer display driver
Hi,
Second round of the framebuffer display driver patches.
Changes: Addressed the review comments. Added a few more patches on top: Using the pixman library for raster ops now. Added support for
mouse pointer rendering and guest display scaling.
cheers,
Gerd
Gerd Hoffmann (9):
QLIST-ify display change listeners.
add unregister_displaychangelistener
move set_mouse + cursor_define callbacks
fbdev: add linux framebuffer display driver.
fbdev: add monitor command to enable/disable
fbdev: make configurable at compile time.
fbdev: move to pixman
fbdev: add mouse pointer support
fbdev: add display scaling support
configure | 24 ++ console.c | 2 +- console.h | 123 ++++-- hmp-commands.hx | 15 + hmp.c | 9 + hmp.h | 1 + hw/jazz_led.c | 2 +- hw/qxl-render.c | 2 +- hw/vga.c | 10 +- hw/vmware_vga.c | 11 +- hw/xenfb.c | 2 +- qapi-schema.json | 14 + qemu-options.hx | 8 + qmp-commands.hx | 6 + qmp.c | 17 + sysemu.h | 1 + trace-events | 15 + ui/Makefile.objs | 1 + ui/fbdev.c | 1121 +++++++++++++++++++++++++++++++++++++++++++++++++++ ui/linux-keynames.h | 388 ++++++++++++++++++ ui/sdl.c | 8 +- ui/spice-display.c | 4 +- ui/vnc.c | 8 +- vl.c | 50 ++- 24 files changed, 1768 insertions(+), 74 deletions(-) create mode 100644 ui/fbdev.c create mode 100644 ui/linux-keynames.h
PATCH v2 1/9 QLIST-ify display change listeners.
--- console.h | 72 +++++++++++++++++++++++++++++++---------------------------- hw/xenfb.c | 2 +- vl.c | 9 ++----- 3 files changed, 42 insertions(+), 41 deletions(-)
console.h +38 -34
@@ -164,7 +164,7 @@ struct DisplayChangeListener { int w, int h, uint32_t c);void (*dpy_text_cursor)(struct DisplayState *s,int x,int y); -struct DisplayChangeListener *next; +QLIST_ENTRY (DisplayChangeListener) next; };struct DisplayAllocator {
@@ -179,7 +179,7 @@ struct DisplayState {struct QEMUTimer *gui_timer;struct DisplayAllocator * allocator; -struct DisplayChangeListener * listeners; + QLIST_HEAD(, DisplayChangeListener) listeners;void (*mouse_set)(int x,int y,int on);void (*cursor_define)(QEMUCursor *cursor);
@@ -231,72 +231,76 @@ static inline int is_buffer_shared(DisplaySurface *surface)static inline void register_displaychangelistener (DisplayState *ds,DisplayChangeListener *dcl) { - dcl->next = ds->listeners; - ds->listeners = dcl; +QLIST_INSERT_HEAD (&ds->listeners, dcl, next); }static inline void dpy_update (DisplayState *s,int x,int y,int w,int h) { -struct DisplayChangeListener *dcl = s->listeners; -while (dcl !=NULL ) { +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { dcl->dpy_update (s, x, y, w, h); - dcl = dcl->next; } }static inline void dpy_resize (DisplayState *s) { -struct DisplayChangeListener *dcl = s->listeners; -while (dcl !=NULL ) { +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { dcl->dpy_resize (s); - dcl = dcl->next; } }static inline void dpy_setdata (DisplayState *s) { -struct DisplayChangeListener *dcl = s->listeners; -while (dcl !=NULL ) { -if (dcl->dpy_setdata) dcl->dpy_setdata (s); - dcl = dcl->next; +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_setdata) { + dcl->dpy_setdata (s); + } } }static inline void dpy_refresh (DisplayState *s) { -struct DisplayChangeListener *dcl = s->listeners; -while (dcl !=NULL ) { -if (dcl->dpy_refresh) dcl->dpy_refresh (s); - dcl = dcl->next; +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_refresh) { + dcl->dpy_refresh (s); + } } }static inline void dpy_copy (struct DisplayState *s,int src_x,int src_y, -int dst_x,int dst_y,int w,int h) { -struct DisplayChangeListener *dcl = s->listeners; -while (dcl !=NULL ) { -if (dcl->dpy_copy) +int dst_x,int dst_y,int w,int h) +{ +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_copy) { dcl->dpy_copy (s, src_x, src_y, dst_x, dst_y, w, h); -else /* TODO */ + }else {/* TODO */ dcl->dpy_update (s, dst_x, dst_y, w, h); - dcl = dcl->next; + } } }static inline void dpy_fill (struct DisplayState *s,int x,int y, -int w,int h,uint32_t c) { -struct DisplayChangeListener *dcl = s->listeners; -while (dcl !=NULL ) { -if (dcl->dpy_fill) dcl->dpy_fill (s, x, y, w, h, c); - dcl = dcl->next; +int w,int h,uint32_t c) +{ +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_fill) { + dcl->dpy_fill (s, x, y, w, h, c); + } } } -static inline void dpy_cursor (struct DisplayState *s,int x,int y) { -struct DisplayChangeListener *dcl = s->listeners; -while (dcl !=NULL ) { -if (dcl->dpy_text_cursor) dcl->dpy_text_cursor (s, x, y); - dcl = dcl->next; +static inline void dpy_cursor (struct DisplayState *s,int x,int y) +{ +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_text_cursor) { + dcl->dpy_text_cursor (s, x, y); + } } }
hw/xenfb.c +1 -1
@@ -717,7 +717,7 @@ static void xenfb_update(void *opaque)if (xenfb_queue_full (xenfb))return ; -for (l = xenfb->c.ds->listeners; l !=NULL ; l = l->next) { + QLIST_FOREACH(l, &xenfb->c.ds->listeners, next) {if (l->idle)continue ; idle =0 ;
vl.c +3 -6
@@ -1276,15 +1276,14 @@ static void gui_update(void *opaque) {uint64_t interval =GUI_REFRESH_INTERVAL ;DisplayState *ds = opaque; -DisplayChangeListener *dcl = ds->listeners; +DisplayChangeListener *dcl;dpy_refresh (ds); -while (dcl !=NULL ) { + QLIST_FOREACH(dcl, &ds->listeners, next) {if (dcl->gui_timer_interval && dcl->gui_timer_interval < interval) interval = dcl->gui_timer_interval; - dcl = dcl->next; }qemu_mod_timer (ds->gui_timer, interval +qemu_get_clock_ms (rt_clock)); }
@@ -3699,14 +3698,12 @@ int main(int argc, char **argv, char **envp)/* display setup */ dpy_resize (ds); - dcl = ds->listeners; -while (dcl !=NULL ) { + QLIST_FOREACH(dcl, &ds->listeners, next) {if (dcl->dpy_refresh !=NULL ) { ds->gui_timer =qemu_new_timer_ms (rt_clock, gui_update, ds);qemu_mod_timer (ds->gui_timer,qemu_get_clock_ms (rt_clock));break ; } - dcl = dcl->next; }text_consoles_set_display (ds);
Signature · 1 line
1.7.1
PATCH v2 2/9 add unregister_displaychangelistener
In reply to Gerd HoffmannAlso change the way the gui_timer is initialized: each time a displaychangelistener is registered or unregistered we'll check whenever we need a timer (due to dpy_refresh callback being present) and if so setup a timer, otherwise zap it. This way the gui timer works correctly with displaychangelisteners coming and going.
--- console.h | 10 ++++++++++ vl.c | 31 +++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-)
console.h +10 -0
@@ -229,9 +229,19 @@ static inline int is_buffer_shared(DisplaySurface *surface) !(surface->flags & QEMU_REALPIXELS_FLAG)); } +void gui_setup_refresh (DisplayState *ds); +static inline void register_displaychangelistener (DisplayState *ds,DisplayChangeListener *dcl) {QLIST_INSERT_HEAD (&ds->listeners, dcl, next); +gui_setup_refresh (ds); +} + +static inline void unregister_displaychangelistener (DisplayState *ds, +DisplayChangeListener *dcl) +{ +QLIST_REMOVE (dcl, next); +gui_setup_refresh (ds); }static inline void dpy_update (DisplayState *s,int x,int y,int w,int h)
vl.c +23 -8
@@ -1288,6 +1288,29 @@ static void gui_update(void *opaque)qemu_mod_timer (ds->gui_timer, interval +qemu_get_clock_ms (rt_clock)); } +void gui_setup_refresh (DisplayState *ds) +{ +DisplayChangeListener *dcl; +bool need_timer = false; + + QLIST_FOREACH(dcl, &ds->listeners, next) { +if (dcl->dpy_refresh !=NULL ) { + need_timer = true; +break ; + } + } + +if (need_timer && ds->gui_timer ==NULL ) { + ds->gui_timer =qemu_new_timer_ms (rt_clock, gui_update, ds); +qemu_mod_timer (ds->gui_timer,qemu_get_clock_ms (rt_clock)); + } +if (!need_timer && ds->gui_timer !=NULL ) { +qemu_del_timer (ds->gui_timer); +qemu_free_timer (ds->gui_timer); + ds->gui_timer =NULL ; + } +} +struct vm_change_state_entry {VMChangeStateHandler *cb;void *opaque;
@@ -2350,7 +2373,6 @@ int main(int argc, char **argv, char **envp)const char *kernel_filename, *kernel_cmdline;char boot_devices[33 ] ="cad" ;/* default to HD->floppy->CD-ROM */ DisplayState *ds; -DisplayChangeListener *dcl;int cyls, heads, secs, translation;QemuOpts *hda_opts =NULL , *opts, *machine_opts;QemuOptsList *olist;
@@ -3698,13 +3720,6 @@ int main(int argc, char **argv, char **envp)/* display setup */ dpy_resize (ds); - QLIST_FOREACH(dcl, &ds->listeners, next) { -if (dcl->dpy_refresh !=NULL ) { - ds->gui_timer =qemu_new_timer_ms (rt_clock, gui_update, ds); -qemu_mod_timer (ds->gui_timer,qemu_get_clock_ms (rt_clock)); -break ; - } - }text_consoles_set_display (ds);if (foreach_device_config (DEV_GDB , gdbserver_start) <0 ) {
Signature · 1 line
1.7.1
PATCH v2 3/9 move set_mouse + cursor_define callbacks
In reply to Gerd HoffmannWhen adding DisplayChangeListeners the set_mouse and cursor_define callbacks have been left in DisplayState for some reason. Fix it.
--- console.c | 2 +- console.h | 39 +++++++++++++++++++++++++++++++++++---- hw/jazz_led.c | 2 +- hw/qxl-render.c | 2 +- hw/vga.c | 10 +++++----- hw/vmware_vga.c | 11 ++++++----- ui/sdl.c | 8 ++++---- ui/spice-display.c | 4 ++-- ui/vnc.c | 8 ++++---- 9 files changed, 59 insertions(+), 27 deletions(-)
console.c +1 -1
@@ -1239,7 +1239,7 @@ static void text_console_update(void *opaque, console_ch_t *chardata) s->text_y[1 ] =0 ; }if (s->cursor_invalidate) { -dpy_cursor (s->ds, s->x, s->y); +dpy_text_cursor (s->ds, s->x, s->y); s->cursor_invalidate =0 ; } }
console.h +35 -4
@@ -164,6 +164,9 @@ struct DisplayChangeListener { int w, int h, uint32_t c);void (*dpy_text_cursor)(struct DisplayState *s,int x,int y); +void (*dpy_mouse_set)(struct DisplayState *s,int x,int y,int on); +void (*dpy_cursor_define)(struct DisplayState *s,QEMUCursor *cursor); +QLIST_ENTRY (DisplayChangeListener) next; };
@@ -181,9 +184,6 @@ struct DisplayState {struct DisplayAllocator * allocator; QLIST_HEAD(, DisplayChangeListener) listeners; -void (*mouse_set)(int x,int y,int on); -void (*cursor_define)(QEMUCursor *cursor); -struct DisplayState *next; };
@@ -304,7 +304,7 @@ static inline void dpy_fill(struct DisplayState *s, int x, int y, } } -static inline void dpy_cursor (struct DisplayState *s,int x,int y) +static inline void dpy_text_cursor (struct DisplayState *s,int x,int y) {struct DisplayChangeListener *dcl; QLIST_FOREACH(dcl, &s->listeners, next) {
@@ -314,6 +314,37 @@ static inline void dpy_cursor(struct DisplayState *s, int x, int y) } } +static inline void dpy_mouse_set (struct DisplayState *s,int x,int y,int on) +{ +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_mouse_set) { + dcl->dpy_mouse_set (s, x, y, on); + } + } +} + +static inline void dpy_cursor_define (struct DisplayState *s,QEMUCursor *cursor) +{ +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_cursor_define) { + dcl->dpy_cursor_define (s, cursor); + } + } +} + +static inline bool dpy_cursor_define_supported (struct DisplayState *s) +{ +struct DisplayChangeListener *dcl; + QLIST_FOREACH(dcl, &s->listeners, next) { +if (dcl->dpy_cursor_define) { +return true; + } + } +return false; +} +static inline int ds_get_linesize (DisplayState *ds) {return ds->surface->linesize;
hw/jazz_led.c +1 -1
@@ -210,7 +210,7 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)LedState *s = opaque;char buf[2 ]; -dpy_cursor (s->ds,-1 ,-1 ); +dpy_text_cursor (s->ds,-1 ,-1 );qemu_console_resize (s->ds,2 ,1 );/* TODO: draw the segments */
hw/qxl-render.c +1 -1
@@ -238,7 +238,7 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)return 1 ; } -if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) { +if (!dpy_cursor_define_supported (qxl->ssd.ds)) {return 0 ; }
hw/vga.c +5 -5
@@ -2077,11 +2077,11 @@ static void vga_update_text(void *opaque, console_ch_t *chardata) s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end || full_update) { cursor_visible = !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 );if (cursor_visible && cursor_offset < size && cursor_offset >=0 ) -dpy_cursor (s->ds, -TEXTMODE_X (cursor_offset), -TEXTMODE_Y (cursor_offset)); +dpy_text_cursor (s->ds, +TEXTMODE_X (cursor_offset), +TEXTMODE_Y (cursor_offset));else -dpy_cursor (s->ds,-1 ,-1 ); +dpy_text_cursor (s->ds,-1 ,-1 ); s->cursor_offset = cursor_offset; s->cursor_start = s->cr[VGA_CRTC_CURSOR_START ]; s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ];
@@ -2142,7 +2142,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)/* Display a message */ s->last_width =60 ; s->last_height = height =3 ; -dpy_cursor (s->ds,-1 ,-1 ); +dpy_text_cursor (s->ds,-1 ,-1 ); s->ds->surface->width = s->last_width; s->ds->surface->height = height;dpy_resize (s->ds);
hw/vmware_vga.c +6 -5
@@ -479,8 +479,7 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s, qc = cursor_builtin_left_ptr(); } -if (s->vga.ds->cursor_define) - s->vga.ds->cursor_define (qc); +dpy_cursor_define (s->vga.ds, qc);cursor_put (qc); }#endif
@@ -755,9 +754,10 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) caps |=SVGA_CAP_RECT_FILL ;#endif #ifdef HW_MOUSE_ACCEL -if (s->vga.ds->mouse_set) +if (dpy_cursor_define_supported (s->vga.ds)) { caps |=SVGA_CAP_CURSOR |SVGA_CAP_CURSOR_BYPASS_2 |SVGA_CAP_CURSOR_BYPASS ; + }#endif return caps;
@@ -904,8 +904,9 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) s->cursor.on |= (value ==SVGA_CURSOR_ON_SHOW ); s->cursor.on &= (value !=SVGA_CURSOR_ON_HIDE );#ifdef HW_MOUSE_ACCEL -if (s->vga.ds->mouse_set && value <=SVGA_CURSOR_ON_SHOW ) - s->vga.ds->mouse_set (s->cursor.x, s->cursor.y, s->cursor.on); +if (value <=SVGA_CURSOR_ON_SHOW ) { +dpy_mouse_set (s->vga.ds, s->cursor.x, s->cursor.y, s->cursor.on); + }#endif break ;
ui/sdl.c +4 -4
@@ -905,7 +905,7 @@ static void sdl_fill(DisplayState *ds, int x, int y, int w, int h, uint32_t c)SDL_FillRect (real_screen, &dst, c); } -static void sdl_mouse_warp (int x,int y,int on) +static void sdl_mouse_warp (DisplayState *ds,int x,int y,int on) {if (on) {if (!guest_cursor)
@@ -921,7 +921,7 @@ static void sdl_mouse_warp(int x, int y, int on) guest_x = x, guest_y = y; } -static void sdl_mouse_define (QEMUCursor *c) +static void sdl_mouse_define (DisplayState *ds,QEMUCursor *c) {uint8_t *image, *mask;int bpl;
@@ -1025,8 +1025,8 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) dcl->dpy_refresh = sdl_refresh; dcl->dpy_setdata = sdl_setdata; dcl->dpy_fill = sdl_fill; - ds->mouse_set = sdl_mouse_warp; - ds->cursor_define = sdl_mouse_define; + dcl->dpy_mouse_set = sdl_mouse_warp; + dcl->dpy_cursor_define = sdl_mouse_define;register_displaychangelistener (ds, dcl); da =g_malloc0 (sizeof (DisplayAllocator));
ui/spice-display.c +2 -2
@@ -367,12 +367,12 @@ void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)void qemu_spice_cursor_refresh_unlocked (SimpleSpiceDisplay *ssd) {if (ssd->cursor) { - ssd->ds->cursor_define (ssd->cursor); +dpy_cursor_define (ssd->ds, ssd->cursor);cursor_put (ssd->cursor); ssd->cursor =NULL ; }if (ssd->mouse_x !=-1 && ssd->mouse_y !=-1 ) { - ssd->ds->mouse_set (ssd->mouse_x, ssd->mouse_y,1 ); +dpy_mouse_set (ssd->ds, ssd->mouse_x, ssd->mouse_y,1 ); ssd->mouse_x =-1 ; ssd->mouse_y =-1 ; }
ui/vnc.c +4 -4
@@ -798,7 +798,7 @@ static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int } } -static void vnc_mouse_set (int x,int y,int visible) +static void vnc_mouse_set (DisplayState *ds,int x,int y,int visible) {/* can we ask the client(s) to move the pointer ??? */ }
@@ -825,7 +825,7 @@ static int vnc_cursor_define(VncState *vs)return -1 ; } -static void vnc_dpy_cursor_define (QEMUCursor *c) +static void vnc_dpy_cursor_define (DisplayState *ds,QEMUCursor *c) {VncDisplay *vd = vnc_display;VncState *vs;
@@ -2751,9 +2751,9 @@ void vnc_display_init(DisplayState *ds) dcl->dpy_update = vnc_dpy_update; dcl->dpy_resize = vnc_dpy_resize; dcl->dpy_setdata = vnc_dpy_setdata; + dcl->dpy_mouse_set = vnc_mouse_set; + dcl->dpy_cursor_define = vnc_dpy_cursor_define;register_displaychangelistener (ds, dcl); - ds->mouse_set = vnc_mouse_set; - ds->cursor_define = vnc_dpy_cursor_define; }
Signature · 1 line
1.7.1
PATCH v2 4/9 fbdev: add linux framebuffer display driver.
In reply to Gerd HoffmannDisplay works, requires truecolor framebuffer with 16 or 32 bpp on the host. 32bpp is recommended. The framebuffer is used as-is, qemu doesn't try to switch modes. With LCD displays mode switching is pretty pointless IMHO, also it wouldn't work anyway with the most common fbdev drivers (vesafb, KMS). Guest display is centered on the host screen.
Mouse works, uses /dev/input/mice.
Keyboard works. Guest screen has whatever keymap you load inside the guest. Text windows (monitor, serial, ...) have a simple en-us keymap. Good enougth to type monitor commands. Not goot enougth to work seriously on a serial terminal. But the qemu terminal emulation isn't good enough for that anyway ;)
Hot keys:
Ctrl-Alt-F<nr> -> host console switching. Ctrl-Alt-<nr> -> qemu console switching. Ctrl-Alt-ESC -> exit qemu.
Special feature: Sane console switching. Switching away stops screen updates. Switching back redraws the screen. When started from the linux console qemu uses the vt you've started it from (requires just read/write access to /dev/fb0). When starting from somewhere else qemu tries to open a unused virtual terminal and switch to it (usually requires root privileges to open /dev/tty<nr>).
--- console.h | 4 + qemu-options.hx | 8 + sysemu.h | 1 + trace-events | 15 + ui/Makefile.objs | 1 + ui/fbdev.c | 953 +++++++++++++++++++++++++++++++++++++++++++++++++++ ui/linux-keynames.h | 388 +++++++++++++++++++++ vl.c | 12 + 8 files changed, 1382 insertions(+), 0 deletions(-) create mode 100644 ui/fbdev.c create mode 100644 ui/linux-keynames.h
console.h +4 -0
@@ -417,6 +417,10 @@ void qemu_console_copy(DisplayState *ds, int src_x, int src_y,/* sdl.c */ void sdl_display_init (DisplayState *ds,int full_screen,int no_frame); +/* fbdev.c */ +int fbdev_display_init (DisplayState *ds,const char *device); +void fbdev_display_uninit (DisplayState *ds); +/* cocoa.m */ void cocoa_display_init (DisplayState *ds,int full_screen);
qemu-options.hx +8 -0
@@ -942,6 +942,14 @@ Enable/disable spice seamless migration. Default is off. @end table ETEXI +DEF("fbdev", 0, QEMU_OPTION_fbdev, + "-fbdev enable fbdev\n", QEMU_ARCH_ALL) +STEXI +@item -fbdev +@findex -fbdev +Enable fbdev (linux framebuffer). +ETEXI + DEF("portrait", 0, QEMU_OPTION_portrait, "-portrait rotate graphical output 90 deg left (only PXA LCD)\n", QEMU_ARCH_ALL)
sysemu.h +1 -0
@@ -93,6 +93,7 @@ typedef enum DisplayTypeDT_DEFAULT ,DT_CURSES ,DT_SDL , +DT_FBDEV ,DT_NOGRAPHIC ,DT_NONE , } DisplayType;
trace-events +15 -0
@@ -987,3 +987,18 @@ spapr_pci_rtas_ibm_change_msi(unsigned func, unsigned req) "func %u, requested % spapr_pci_rtas_ibm_query_interrupt_source_number(unsigned ioa, unsigned intr) "queries for #%u, IRQ%u" spapr_pci_msi_write(uint64_t addr, uint64_t data, uint32_t dt_irq) "@%"PRIx64"<=%"PRIx64" IRQ %u" spapr_pci_lsi_set(const char *busname, int pin, uint32_t irq) "%s PIN%d IRQ %u" + +# ui/fbdev.c +fbdev_enabled(void) "" +fbdev_cleanup(void) "" +fbdev_vt_activate(int vtno, int wait) "vtno %d, wait %d" +fbdev_vt_activated(void) "" +fbdev_vt_release_request(void) "" +fbdev_vt_released(void) "" +fbdev_vt_aquire_request(void) "" +fbdev_vt_aquired(void) "" +fbdev_kbd_raw(int enable) "enable %d" +fbdev_kbd_event(int keycode, const char *kname, int up) "keycode 0x%x [%s], down %d" +fbdev_dpy_resize(int w, int h) "%dx%d" +fbdev_dpy_redraw(void) +
ui/Makefile.objs +1 -0
@@ -12,3 +12,4 @@ common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o common-obj-$(CONFIG_COCOA) += cocoa.o common-obj-$(CONFIG_CURSES) += curses.o common-obj-$(CONFIG_VNC) += $(vnc-obj-y) +common-obj-$(CONFIG_LINUX) += fbdev.o
ui/fbdev.c new file +953 -0
953 lines not on this page · raw message
ui/linux-keynames.h new file +388 -0
388 lines not on this page · raw message
vl.c +12 -0
@@ -3041,6 +3041,11 @@ int main(int argc, char **argv, char **envp)fprintf (stderr,"SDL support is disabled\n" );exit (1 );#endif +#ifdef CONFIG_LINUX +case QEMU_OPTION_fbdev: + display_type =DT_FBDEV ; +break ; +#endif case QEMU_OPTION_pidfile: pid_file = optarg;break ;
@@ -3681,6 +3686,13 @@ int main(int argc, char **argv, char **envp)curses_display_init (ds, full_screen);break ;#endif +#if defined(CONFIG_LINUX ) +case DT_FBDEV : +if (fbdev_display_init (ds,NULL ) !=0 ) { +exit (1 ); + } +break ; +#endif #if defined(CONFIG_SDL )case DT_SDL :sdl_display_init (ds, full_screen, no_frame);
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 4/9] fbdev: add linux framebuffer display driver.
Quoted 7 lines · Gerd Hoffmann
Display works, requires truecolor framebuffer with 16 or 32 bpp on the host. 32bpp is recommended. The framebuffer is used as-is, qemu doesn't try to switch modes. With LCD displays mode switching is pretty pointless IMHO, also it wouldn't work anyway with the most common fbdev drivers (vesafb, KMS). Guest display is centered on the host screen.
Quoted 7 lines
Mouse works, uses
/dev/input/mice.Keyboard works. Guest screen has whatever keymap you load inside the guest. Text windows (monitor, serial, ...) have a simple en-us keymap. Good enougth to type monitor commands. Not goot enougth to work seriously on a serial terminal. But the qemu terminal emulation isn't good enough for that anyway ;)
You fixed one instance of "enougth", but left in the other two.
[...]
PATCH v2 5/9 fbdev: add monitor command to enable/disable
In reply to Gerd HoffmannThis patch adds a fbdev monitor command to enable/disable the fbdev display at runtime to both qmp and hmp.
qmp: fbdev enable=on|off
hmp: fbdev on|off
--- hmp-commands.hx | 15 +++++++++++++++ hmp.c | 9 +++++++++ hmp.h | 1 + qapi-schema.json | 14 ++++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 17 +++++++++++++++++ 6 files changed, 62 insertions(+), 0 deletions(-)
hmp-commands.hx +15 -0
@@ -1377,6 +1377,21 @@ passed since 1970, i.e. unix epoch. ETEXI { + .name = "fbdev", + .args_type = "enable:b", + .params = "on|off", + .help = "enable/disable fbdev", + .mhandler.cmd = hmp_fbdev, + }, + +STEXI +@item fbdev on | off +@findex fbdev + +enable/disable fbdev +ETEXI + + { .name = "info", .args_type = "item:s?", .params = "[subcommand]",
hmp.c +9 -0
@@ -1168,3 +1168,12 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict)qmp_screendump (filename, &err);hmp_handle_error (mon, &err); } + +void hmp_fbdev (Monitor *mon,const QDict *qdict) +{ +int enable =qdict_get_bool (qdict,"enable" ); +Error *errp =NULL ; + +qmp_fbdev (enable, &errp); +hmp_handle_error (mon, &errp); +}
hmp.h +1 -0
@@ -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_fbdev (Monitor *mon,const QDict *qdict);#endif
qapi-schema.json +14 -0
@@ -2555,3 +2555,17 @@ # Since: 0.14.0 ## { 'command': 'screendump', 'data': {'filename': 'str'} } + +# @fbdev: +# +# Enable/disable fbdev. +# +# @enable: true to set the link status to be up +# +# Returns: Nothing on success +# GenericError on failure. +# +# Since: 1.3 +# +## +{ 'command': 'fbdev', 'data': {'enable': 'bool'} }
qmp-commands.hx +6 -0
@@ -2539,3 +2539,9 @@ EQMP .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_target, }, + + { + .name = "fbdev", + .args_type = "enable:b", + .mhandler.cmd_new = qmp_marshal_input_fbdev, + },
qmp.c +17 -0
@@ -391,6 +391,23 @@ void qmp_change(const char *device, const char *target, } } +void qmp_fbdev (bool enable,Error **errp) +{ +#if defined(CONFIG_LINUX ) +DisplayState *ds =get_displaystate (); + +if (enable) { +if (fbdev_display_init (ds,NULL ) !=0 ) { +error_setg (errp,"fbdev initialization failed" ); + } + }else { +fbdev_display_uninit (ds); + } +#else +error_set (errp,QERR_FEATURE_DISABLED ,"fbdev" ); +#endif +} +static void qom_list_types_tramp (ObjectClass *klass,void *data) {ObjectTypeInfoList *e, **pret = data;
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 5/9] fbdev: add monitor command to enable/disable
Quoted 75 lines · Gerd Hoffmann
This patch adds a fbdev monitor command to enable/disable the fbdev display at runtime to both qmp and hmp.
qmp: fbdev enable=on|off
hmp: fbdev on|offSigned-off-by Gerd Hoffmann <[email protected]>--- hmp-commands.hx | 15 +++++++++++++++ hmp.c | 9 +++++++++ hmp.h | 1 + qapi-schema.json | 14 ++++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 17 +++++++++++++++++ 6 files changed, 62 insertions(+), 0 deletions(-)hmp-commands.hx +15
-0@@ -1377,6 +1377,21 @@ passed since 1970, i.e. unix epoch. ETEXI { + .name = "fbdev", + .args_type = "enable:b", + .params = "on|off", + .help = "enable/disable fbdev", + .mhandler.cmd = hmp_fbdev, + }, + +STEXI +@item fbdev on | off +@findex fbdev + +enable/disable fbdev +ETEXI + + { .name = "info", .args_type = "item:s?", .params = "[subcommand]",hmp.c +9
-0@@ -1168,3 +1168,12 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict)qmp_screendump (filename, &err);hmp_handle_error (mon, &err); } + +void hmp_fbdev (Monitor *mon,const QDict *qdict) +{ +int enable =qdict_get_bool (qdict,"enable" ); +Error *errp =NULL ; + +qmp_fbdev (enable, &errp); +hmp_handle_error (mon, &errp); +}hmp.h +1
-0@@ -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_fbdev (Monitor *mon,const QDict *qdict);#endif qapi-schema.json +0
-0
qapi-schema.json line 2562
Quoted 8 lines
qapi-schema.json +5
-0@@ -2555,3 +2555,17 @@ # Since: 0.14.0 ## { 'command': 'screendump', 'data': {'filename': 'str'} } + +# @fbdev: +# +# Enable/disable fbdev. +#
You fixed the doc pasto in "Returns:" below (thanks), but missed this one:
qapi-schema.json line 2563
Quoted 1 line
qapi-schema.json +1
-0+# @enable: true to set the link status to be up
Guess I should've marked it more clearly in my review.
Quoted 8 lines
qapi-schema.json +8
-0+# +# Returns: Nothing on success +# GenericError on failure. +# +# Since: 1.3 +# +## +{ 'command': 'fbdev', 'data': {'enable': 'bool'} }
[...]
PATCH v2 6/9 fbdev: make configurable at compile time.
In reply to Gerd HoffmannAdd CONFIG_FBDEV, add --enable-fbdev and --disable-fbdev configure switches so fbdev can be enabled/disabled at compile time.
--- configure | 12 ++++++++++++ qmp.c | 2 +- ui/Makefile.objs | 2 +- vl.c | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-)
configure +12 -0
@@ -149,6 +149,7 @@ docs="" fdt="" nptl="" sdl="" +fbdev="no" virtfs="" vnc="yes" sparse="no"
@@ -528,6 +529,7 @@ Haiku) usb="linux" kvm="yes" vhost_net="yes" + fbdev="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" fi
@@ -659,6 +661,10 @@ for opt do ;; --enable-sdl) sdl="yes" ;; + --disable-fbdev) fbdev="no" + ;; + --enable-fbdev) fbdev="yes" + ;; --disable-virtfs) virtfs="no" ;; --enable-virtfs) virtfs="yes"
@@ -1073,6 +1079,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-fbdev disable linux framebuffer" +echo " --enable-fbdev enable linux framebuffer" echo " --disable-virtfs disable VirtFS" echo " --enable-virtfs enable VirtFS" echo " --disable-vnc disable VNC"
@@ -3127,6 +3135,7 @@ if test "$darwin" = "yes" ; then echo "Cocoa support $cocoa" fi echo "SDL support $sdl" +echo "fbdev support $fbdev" echo "curses support $curses" echo "curl support $curl" echo "mingw32 support $mingw32"
@@ -3335,6 +3344,9 @@ if test "$sdl" = "yes" ; then echo "CONFIG_SDL=y" >> $config_host_mak echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak fi +if test "$fbdev" = "yes" ; then + echo "CONFIG_FBDEV=y" >> $config_host_mak +fi if test "$cocoa" = "yes" ; then echo "CONFIG_COCOA=y" >> $config_host_mak fi
qmp.c +1 -1
@@ -393,7 +393,7 @@ void qmp_change(const char *device, const char *target,void qmp_fbdev (bool enable,Error **errp) { -#if defined(CONFIG_LINUX ) +#if defined(CONFIG_FBDEV )DisplayState *ds =get_displaystate ();if (enable) {
ui/Makefile.objs +1 -1
@@ -12,4 +12,4 @@ common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o common-obj-$(CONFIG_COCOA) += cocoa.o common-obj-$(CONFIG_CURSES) += curses.o common-obj-$(CONFIG_VNC) += $(vnc-obj-y) -common-obj-$(CONFIG_LINUX) += fbdev.o +common-obj-$(CONFIG_FBDEV) += fbdev.o
vl.c +2 -2
@@ -3041,7 +3041,7 @@ int main(int argc, char **argv, char **envp)fprintf (stderr,"SDL support is disabled\n" );exit (1 );#endif -#ifdef CONFIG_LINUX +#ifdef CONFIG_FBDEV case QEMU_OPTION_fbdev: display_type =DT_FBDEV ;break ;
@@ -3686,7 +3686,7 @@ int main(int argc, char **argv, char **envp)curses_display_init (ds, full_screen);break ;#endif -#if defined(CONFIG_LINUX ) +#if defined(CONFIG_FBDEV )case DT_FBDEV :if (fbdev_display_init (ds,NULL ) !=0 ) {exit (1 );
Signature · 1 line
1.7.1
PATCH v2 7/9 fbdev: move to pixman
In reply to Gerd HoffmannStop reinventing the wheel. Use the pixman library for raster ops.
--- configure | 12 ++++ ui/fbdev.c | 172 +++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 114 insertions(+), 70 deletions(-)
configure +12 -0
@@ -149,6 +149,7 @@ docs="" fdt="" nptl="" sdl="" +pixman="" fbdev="no" virtfs="" vnc="yes"
@@ -2151,6 +2152,17 @@ else exit 1 fi +if $pkg_config pixman-1 > /dev/null 2>&1 +then + pixman="yes" + pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null` + pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null` + QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags" + libs_softmmu="$libs_softmmu $pixman_libs" +else + fbdev="no" +fi + ########################################## # libcap probe
ui/fbdev.c +102 -70
237 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 8/9 fbdev: add mouse pointer support
In reply to Gerd HoffmannAdd mouse_set and cursor_define DisplayChangeListener callbacks and mouse pointer rendering support.
--- ui/fbdev.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-)
ui/fbdev.c +95 -0
@@ -82,6 +82,12 @@ static pixman_image_t *framebuffer;static pixman_transform_t transform;static pixman_region16_t dirty; +static QEMUCursor *ptr_cursor; +static pixman_image_t *ptr_image; +static int ptr_refresh; +static int px, py, pw, ph; +static int mx, my, mon; +/* fwd decls */ static int fbdev_activate_vt (int tty,int vtno,bool wait);
@@ -865,6 +871,51 @@ static void fbdev_render(DisplayState *ds)pixman_region_init (&dirty); } +static void fbdev_unrender_ptr (DisplayState *ds) +{ +if (!pw && !ph) { +return ; + } +pixman_region_union_rect (&dirty, &dirty, px, py, pw, ph); + ph = pw =0 ; +} + +static void fbdev_render_ptr (DisplayState *ds) +{ +pixman_region16_t region; +pixman_transform_t transform; + +if (!mon || !ptr_image) { +return ; + } +if (mx <0 || mx >= cw || my <0 || my >= ch) { +return ; + } + + px = mx - ptr_cursor->hot_x; + py = my - ptr_cursor->hot_y; + pw = ptr_cursor->width; + ph = ptr_cursor->height; + +pixman_transform_init_identity (&transform); +pixman_transform_translate (&transform,NULL , +pixman_int_to_fixed (-cx), +pixman_int_to_fixed (-cy)); +pixman_transform_translate (&transform,NULL , +pixman_int_to_fixed (-px), +pixman_int_to_fixed (-py)); +pixman_image_set_transform (ptr_image, &transform); + +pixman_region_init_rect (®ion,0 ,0 , pw, ph); +pixman_image_set_clip_region (ptr_image, ®ion); + +pixman_image_composite (PIXMAN_OP_OVER , ptr_image,NULL , framebuffer, +0 ,0 ,0 ,0 ,0 ,0 , fb_var.xres, fb_var.yres); + +pixman_region_fini (®ion); + ptr_refresh =0 ; +} +/* -------------------------------------------------------------------- */ /* qemu interfaces */
@@ -906,6 +957,9 @@ static void fbdev_update(DisplayState *ds, int x, int y, int w, int h) }pixman_region_union_rect (&dirty, &dirty, x, y, w, h); +if (ptr_image && mon && pw && ph) { + ptr_refresh++; + } }static void fbdev_resize (DisplayState *ds)
@@ -933,9 +987,48 @@ static void fbdev_refresh(DisplayState *ds)fbdev_update (ds,0 ,0 ,0 ,0 ); } +if (ptr_refresh) { +fbdev_unrender_ptr (ds); + }if (pixman_region_not_empty (&dirty)) {fbdev_render (ds); } +if (ptr_refresh) { +fbdev_render_ptr (ds); + } +} + +static void fbdev_mouse_set (DisplayState *ds,int x,int y,int on) +{ + ptr_refresh++; + mx = x; + my = y; + mon = on; +} + +static void fbdev_cursor_define (DisplayState *ds,QEMUCursor *cursor) +{ + ptr_refresh++; + +if (ptr_cursor) { +cursor_put (ptr_cursor); + ptr_cursor =NULL ; + } +if (ptr_image) { +pixman_image_unref (ptr_image); + ptr_image =NULL ; + } + +if (!cursor) { +return ; + } + + ptr_cursor = cursor; +cursor_get (ptr_cursor); + ptr_image =pixman_image_create_bits (PIXMAN_a8r8g8b8, + cursor->width, cursor->height, + cursor->data, + cursor->width *4 ); }static void fbdev_exit_notifier (Notifier *notifier,void *data)
@@ -963,6 +1056,8 @@ int fbdev_display_init(DisplayState *ds, const char *device) dcl->dpy_update = fbdev_update; dcl->dpy_resize = fbdev_resize; dcl->dpy_refresh = fbdev_refresh; + dcl->dpy_mouse_set = fbdev_mouse_set; + dcl->dpy_cursor_define = fbdev_cursor_define;register_displaychangelistener (ds, dcl);trace_fbdev_enabled ();
Signature · 1 line
1.7.1
PATCH v2 9/9 fbdev: add display scaling support
In reply to Gerd HoffmannAdd support for scaling the guest display.
Ctrl-Alt-S hotkey toggles scaling.
--- ui/fbdev.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 51 insertions(+), 10 deletions(-)
ui/fbdev.c +51 -10
@@ -81,6 +81,7 @@ static pixman_image_t *surface;static pixman_image_t *framebuffer;static pixman_transform_t transform;static pixman_region16_t dirty; +static double scale;static QEMUCursor *ptr_cursor;static pixman_image_t *ptr_image;
@@ -88,6 +89,10 @@ static int ptr_refresh;static int px, py, pw, ph;static int mx, my, mon; +/* options */ +static int use_scale =1 ; +static pixman_filter_t pfilter =PIXMAN_FILTER_GOOD ; +/* fwd decls */ static int fbdev_activate_vt (int tty,int vtno,bool wait);
@@ -182,13 +187,14 @@ static void read_mouse(void *opaque)if (ay <0 ) { ay =0 ; } -if (ax >= cw) { - ax = cw-1 ; +if (ax >= cw*scale) { + ax = cw*scale-1 ; } -if (ay >= ch) { - ay = ch-1 ; +if (ay >= ch*scale) { + ay = ch*scale-1 ; } -kbd_mouse_event (ax *0x7FFF / cw, ay *0x7FFF / ch,0 , b); +kbd_mouse_event (ax *0x7FFF / (cw*scale), + ay *0x7FFF / (ch*scale),0 , b); }else {kbd_mouse_event (x, y,0 , b); }
@@ -543,6 +549,12 @@ static void read_mediumraw(void *opaque) "(ctrl-alt-esc) ===\n");exit (1 ); } +if (keycode ==KEY_S ) { + use_scale = !use_scale; + resize_screen++; + redraw_screen++; +continue ; + }if (keycode >=KEY_F1 && keycode <=KEY_F10 ) {fbdev_activate_vt (tty, keycode+1 -KEY_F1 , false); key_down[keycode] = false;
@@ -901,6 +913,11 @@ static void fbdev_render_ptr(DisplayState *ds)pixman_transform_translate (&transform,NULL ,pixman_int_to_fixed (-cx),pixman_int_to_fixed (-cy)); +if (use_scale) { +pixman_transform_scale (&transform,NULL , +pixman_double_to_fixed (1 /scale), +pixman_double_to_fixed (1 /scale)); + }pixman_transform_translate (&transform,NULL ,pixman_int_to_fixed (-px),pixman_int_to_fixed (-py));
@@ -926,16 +943,32 @@ static void fbdev_update(DisplayState *ds, int x, int y, int w, int h) }if (resize_screen) { +double xs, ys; +trace_fbdev_dpy_resize (ds_get_width (ds),ds_get_height (ds)); resize_screen =0 ; cx =0 ; cy =0 ; cw =ds_get_width (ds); ch =ds_get_height (ds); -if (ds_get_width (ds) < fb_var.xres) { - cx = (fb_var.xres -ds_get_width (ds)) /2 ; - } -if (ds_get_height (ds) < fb_var.yres) { - cy = (fb_var.yres -ds_get_height (ds)) /2 ; + +if (use_scale) { + xs = (double )fb_var.xres / cw; + ys = (double )fb_var.yres / ch; +if (xs > ys) { + scale = ys; + cx = (fb_var.xres -ds_get_width (ds)*scale) /2 ; + }else { + scale = xs; + cy = (fb_var.yres -ds_get_height (ds)*scale) /2 ; + } + }else { + scale =1 ; +if (ds_get_width (ds) < fb_var.xres) { + cx = (fb_var.xres -ds_get_width (ds)) /2 ; + } +if (ds_get_height (ds) < fb_var.yres) { + cy = (fb_var.yres -ds_get_height (ds)) /2 ; + } }if (surface) {pixman_image_unref (surface);
@@ -946,7 +979,14 @@ static void fbdev_update(DisplayState *ds, int x, int y, int w, int h)pixman_transform_translate (&transform,NULL ,pixman_int_to_fixed (-cx),pixman_int_to_fixed (-cy)); +if (use_scale) { +pixman_transform_scale (&transform,NULL , +pixman_double_to_fixed (1 /scale), +pixman_double_to_fixed (1 /scale)); + }pixman_image_set_transform (surface, &transform); + +pixman_image_set_filter (surface, pfilter,NULL ,0 ); }if (redraw_screen) {
@@ -1029,6 +1069,7 @@ static void fbdev_cursor_define(DisplayState *ds, QEMUCursor *cursor) cursor->width, cursor->height, cursor->data, cursor->width * 4); +pixman_image_set_filter (ptr_image, pfilter,NULL ,0 ); }static void fbdev_exit_notifier (Notifier *notifier,void *data)
Signature · 1 line
1.7.1