] linux fbdev display driver prototype.
RFC PATCH 1/1 ] linux fbdev display driver prototype.
Display works with 32 bpp (both host + guest) only. Which surprisingly didn't cause much problems so far in my testing. Host runs with kms and inteldrmfb.
Mouse support isn't available yet.
I've cheated by passed through the hosts usb mouse for testing.
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 enougth 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>).
For some strange reason console switching from X11 to qemu doesn't work. Anything else (including X11 -> text console -> qemu) works fine. To be investigated ...
--- Makefile.objs | 1 + console.h | 3 + fbdev.c | 770 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ linux-keynames.h | 386 +++++++++++++++++++++++++++ qemu-options.hx | 10 + sysemu.h | 1 + vl.c | 10 + 7 files changed, 1181 insertions(+), 0 deletions(-) create mode 100644 fbdev.c create mode 100644 linux-keynames.h
Makefile.objs +1 -0
@@ -102,6 +102,7 @@ common-obj-y += $(addprefix audio/, $(audio-obj-y)) common-obj-y += keymaps.o common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o common-obj-$(CONFIG_CURSES) += curses.o +common-obj-$(CONFIG_LINUX) += fbdev.o common-obj-y += vnc.o acl.o d3des.o common-obj-y += vnc-encoding-zlib.o vnc-encoding-hextile.o common-obj-y += iov.o
console.h +3 -0
@@ -338,6 +338,9 @@ 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 */ +void fbdev_display_init (DisplayState *ds,const char *device); +/* cocoa.m */ void cocoa_display_init (DisplayState *ds,int full_screen);
fbdev.c new file +770 -0
770 lines not on this page · raw message
linux-keynames.h new file +386 -0
386 lines not on this page · raw message
qemu-options.hx +10 -0
@@ -663,6 +663,16 @@ STEXI Enable SDL. ETEXI +#ifdef CONFIG_LINUX +DEF("fbdev", 0, QEMU_OPTION_fbdev, + "-fbdev enable fbdev\n", QEMU_ARCH_ALL) +#endif +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
@@ -98,6 +98,7 @@ typedef enum DisplayTypeDT_CURSES ,DT_SDL ,DT_VNC , +DT_FBDEV ,DT_NOGRAPHIC , } DisplayType;
vl.c +10 -0
@@ -3216,6 +3216,11 @@ int main(int argc, char **argv, char **envp) display_type =DT_SDL ;break ;#endif +#ifdef CONFIG_LINUX +case QEMU_OPTION_fbdev: + display_type =DT_FBDEV ; +break ; +#endif case QEMU_OPTION_pidfile: pid_file = optarg;break ;
@@ -3781,6 +3786,11 @@ int main(int argc, char **argv, char **envp)curses_display_init (ds, full_screen);break ;#endif +#if defined(CONFIG_LINUX ) +case DT_FBDEV : +fbdev_display_init (ds,NULL ); +break ; +#endif #if defined(CONFIG_SDL )case DT_SDL :sdl_display_init (ds, full_screen, no_frame);
Signature · 1 line
1.6.6.1
Quoted 25 lines · Gerd Hoffmann
Display works with 32 bpp (both host + guest) only. Which surprisingly didn't cause much problems so far in my testing. Host runs with kms and inteldrmfb.
Mouse support isn't available yet.
I've cheated by passed through the hosts usb mouse for testing.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 enougth 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>).
Quoted 4 lines
For some strange reason console switching from X11 to qemu doesn't work. Anything else (including X11 -> text console -> qemu) works fine. To be investigated ...
Not bad for quick start!
Does qemu->qemu switching work when running multiple VMs?
Hi,
Quoted 1 line
Does
qemu->qemuswitching work when running multiple VMs?
Yes.
cheers,
Gerd
Quoted 25 lines · Gerd Hoffmann
Display works with 32 bpp (both host + guest) only. Which surprisingly didn't cause much problems so far in my testing. Host runs with kms and inteldrmfb.
Mouse support isn't available yet.
I've cheated by passed through the hosts usb mouse for testing.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 enougth 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>).
Quoted 4 lines
For some strange reason console switching from X11 to qemu doesn't work. Anything else (including X11 -> text console -> qemu) works fine. To be investigated ...
This looks very promissing.
I just got a couple of observations:
- Your patch does not work on my machine with the vesafb driver. It reports "can't handle 8 bpp frame buffers". It turns out that the vesafb driver seems to initialize the framebuffer in PSEUDOCOLOR mode. I think we should add a piece of code which tries reinitialize the framebuffer with the suitable parametters (32bpp/TRUECOLOR). It works fine with inteldrmfb though.
- You should register a Display Allocator and override the create_displaysurface() method like I did in the DirectFB driver. This way you save qemu a data copy. fbdev_render_32() should only be used when the guest framebuffer is not compatible with the physical framebuffer (guest_bpp != physical_bbp || guest_linesize != physical_linesize).
- A cool feature would be to be able to stretch the guest display in fullscreen. My DirectFB driver implements a fullscreen toggle command by pressing the Ctrl-Alt-Return keys. I think Stefano added a SDL zoom feature a while ago which we could reuse for this.
- I'm not very familiar with the scancode stuff, but I think that if you set your VT fd in the K_RAW keyboard mode, you'll be able to get true keyboard scancodes that you can directly give to the guest using the kbd_put_keycode() function. This way we could avoid having to define keymaps and this scancode map inside qemu.
Cheers,
Julian
Quoted 6 lines · Julian Pidancet
This looks very promissing.
I just got a couple of observations:
- Your patch does not work on my machine with the vesafb driver. It reports "can't handle 8 bpp frame buffers". It turns out that the vesafb driver seems to initialize the framebuffer in PSEUDOCOLOR mode. I think we should add a piece of code which tries reinitialize the framebuffer with the suitable parametters (32bpp/TRUECOLOR). It works fine with inteldrmfb though.
32bpp would be ideal, but we could probably handle 24 and 16 bpp too
Quoted 2 lines
- You should register a Display Allocator and override the
create_displaysurface()method like I did in the DirectFB driver. This way you save qemu a data copy.fbdev_render_32()should only be used when the guest framebuffer is not compatible with the physical framebuffer (guest_bpp!=physical_bbp||guest_linesize!=physical_linesize).
agreed
Quoted 2 lines
- A cool feature would be to be able to stretch the guest display in fullscreen. My DirectFB driver implements a fullscreen toggle command by pressing the Ctrl-Alt-Return keys. I think Stefano added a SDL zoom feature a while ago which we could reuse for this.
sdl_zoom.c is actually generic and not SDL specific, so it shouldn't be difficult to reuse it here
Quoted 8 lines
This looks very promissing.
I just got a couple of observations:
- Your patch does not work on my machine with the vesafb driver. It reports "can't handle 8 bpp frame buffers". It turns out that the vesafb driver seems to initialize the framebuffer in PSEUDOCOLOR mode.
Depends on the video mode you ask for via vga=$nr, there are also 32bpp modes.
Quoted 2 lines
I think we should add a piece of code which tries reinitialize the framebuffer with the suitable parametters (32bpp/TRUECOLOR).
With vesafb it wouldn't work anyway, you can't switch these parameters at runtime. I think the *drmfb fbdev interface is quite limited too in what it allows to change.
Quoted 6 lines
- You should register a Display Allocator and override the
create_displaysurface()method like I did in the DirectFB driver. This way you save qemu a data copy.fbdev_render_32()should only be used when the guest framebuffer is not compatible with the physical framebuffer (guest_bpp!=physical_bbp||guest_linesize!=physical_linesize).
Isn't a trivial move though. If the console is switched you must stop drawing on the framebuffer.
Right now this is easy: just stop copying. Likewise restoring the screen when switching back is easy: just copy everything.
If we give out pointers to the framebuffer to other qemu code which doesn't know anything about console switching we have to be quite careful get things right ...
Quoted 4 lines
- A cool feature would be to be able to stretch the guest display in fullscreen. My DirectFB driver implements a fullscreen toggle command by pressing the Ctrl-Alt-Return keys. I think Stefano added a SDL zoom feature a while ago which we could reuse for this.
The actual stretching is done by SDL I think. For that kind of stuff a rendering library is actually helpful ...
Quoted 4 lines
- I'm not very familiar with the scancode stuff, but I think that if you set your VT fd in the
K_RAWkeyboard mode, you'll be able to get true keyboard scancodes that you can directly give to the guest using thekbd_put_keycode()function.
I'm not sure this is really portable. What do you get in K_RAW mode on !x86 platforms? K_MEDIUMRAW gives you linux input layer key codes no matter what. Also the translation to keysyms (for text consoles) is easier with mediumraw.
cheers,
Gerd
Quoted 3 lines · Gerd Hoffmann
The actual stretching is done by SDL I think. For that kind of stuff a rendering library is actually helpful ...
not really, the sdl_zoom* stuff is completely generic
Quoted 10 lines · Gerd Hoffmann
Quoted 6 lines
- You should register a Display Allocator and override the
create_displaysurface()method like I did in the DirectFB driver. This way you save qemu a data copy.fbdev_render_32()should only be used when the guest framebuffer is not compatible with the physical framebuffer (guest_bpp!=physical_bbp||guest_linesize!=physical_linesize).Isn't a trivial move though. If the console is switched you must stop drawing on the framebuffer.
Quoted 7 lines
Right now this is easy: just stop copying. Likewise restoring the screen when switching back is easy: just copy everything.
If we give out pointers to the framebuffer to other qemu code which doesn't know anything about console switching we have to be quite careful get things right ...
When loosing the focus, you can force display surface reallocation by calling hw_invalidate(), this way you can give qemu a temporary pointer to prevent drawing on the framebuffer. When switching back, you just have to copy the content of the temporary pointer location to the framebuffer.
Cheers,
Julian Pidancet