Modifying xenfb colour depth from Android domU
Subsystems (2)
I'm facing some problems getting xenfb to work with an Android domU, on ARM.
The issue is that the framebuffer is created with a depth of 32bpp, while the Android guest is rendering RGB565.
I tried to fix this by using the fbdev API to request a change of pixel format, during the Android startup:
int set_fb_pixel_format()
{
int fd = open("/dev/graphics/fb0", O_RDWR, 0);
struct fb_var_screeninfo info;
if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) {
return -errno;
}
info.red.offset = 11;
info.red.length = 5;
info.green.offset = 5;
info.green.length = 6;
info.blue.offset = 0;
info.blue.length = 5;
info.transp.offset = 0;
info.transp.length = 0;
info.bits_per_pixel = 16;
info.activate = FB_ACTIVATE_NOW;
if (ioctl(fd, FBIOPUT_VSCREENINFO, &info) == -1) {
ALOGE("Selecting RGB565 failed");
return -errno;
}
...
}This however fails in the xen-fbfront driver, due to bits_per_pixel not matching the current framebuffer depth (which comes from #define XENFB_DEPTH 32):
static intxenfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{
...if (var->bits_per_pixel == xenfb_info->page->depth &&
var->xres <= info->fix.line_length / (XENFB_DEPTH / 8) &&
required_mem_len <= info->fix.smem_len) {
var->xres_virtual = var->xres;
var->yres_virtual = var->yres;
return 0;
}
return -EINVAL;
}I found that I can fix this in one of two ways:
1. Change the initial depth to 16. This of course means that guest rendering in other depths is incorrectly displayed.
(quoted diff) +0 -0
b/include/xen/interface/io/fbif.h
index 974a51e..42b1258 100644
include/xen/interface/io/fbif.h +1 -1
@@ -137,7 +137,7 @@ struct xenfb_page {#ifdef __KERNEL__#define XENFB_WIDTH 800#define XENFB_HEIGHT 600 -#define XENFB_DEPTH 32 +#define XENFB_DEPTH 16#endif
2. Allow the guest to modify the framebuffer depth.
drivers/video/xen-fbfront.c +0 -0
@@ -295,12 +295,11 @@ xenfb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info)
if (var->xres > video[KPARAM_WIDTH] || var->yres >
video[KPARAM_HEIGHT])
return -EINVAL;- required_mem_len = var->xres * var->yres *xenfb_info->page->depth / 8;
- if (var->bits_per_pixel == xenfb_info->page->depth &&
- var->xres <= info->fix.line_length / (XENFB_DEPTH / 8) &&
- required_mem_len <= info->fix.smem_len) {
+ required_mem_len = var->xres * var->yres * var->bits_per_pixel / 8;
+ if (required_mem_len <= info->fix.smem_len) {
var->xres_virtual = var->xres;
var->yres_virtual = var->yres;
+ info->fix.line_length = var->xres * var->bits_per_pixel / 8;
return 0;
}
return -EINVAL;This works for my case, but involves modifying the fb_info.fix.line_length value - is this allowed?
Code being used:
linux: refs/tags/v3.10.16, plus "b1a3b1c xen/fb: allow xenfb initialization for hvm guests"
qemu: refs/tags/v2.1.0-rc3
xen: refs/tags/RELEASE-4.4.0
Note that xenfb_check_var is unchanged in linux master.
Gareth
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590 ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782
Quoted 8 lines · Gareth Stockwell
I'm facing some problems getting xenfb to work with an Android domU, on ARM.
The issue is that the framebuffer is created with a depth of 32bpp, while the Android guest is rendering RGB565.
I tried to fix this by using the fbdev API to request a change of pixel format, during the Android startup:
I'm not very familiar with the xenfb driver but it looks like it would all just work provided you have a backend that supports feature-resize.
What backend are you using?
David
Quoted 12 lines · David Vrabel
Quoted 8 lines · Gareth Stockwell
I'm facing some problems getting xenfb to work with an Android domU, on ARM.
The issue is that the framebuffer is created with a depth of 32bpp, while the Android guest is rendering RGB565.
I tried to fix this by using the fbdev API to request a change of pixel format, during the Android startup:
I'm not very familiar with the xenfb driver but it looks like it would all just work provided you have a backend that supports feature-resize.
Quoted 9 lines
What backend are you using?
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
I've tried with both VNC and SDL backends.
If I read correctly the xenstore fragment below, it's reporting that the VNC backend does support feature-resize, but FBIOPUT_VSCREENINFO still fails as I described previously.
root@dom0:~# xenstore-ls /local/domain/0/backend/vfb 2 = "" 0 = "" frontend = "/local/domain/2/device/vfb/0" frontend-id = "2" online = "1" state = "2" domain = "ree" vnc = "1" vnclisten = "0.0.0.0" vncdisplay = "2" vncunused = "1" sdl = "0" opengl = "0" feature-resize = "1" hotplug-status = "connected"
Gareth
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590 ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782
Quoted 8 lines · Gareth Stockwell
I'm facing some problems getting xenfb to work with an Android domU, on ARM.
The issue is that the framebuffer is created with a depth of 32bpp, while the Android guest is rendering RGB565.
I tried to fix this by using the fbdev API to request a change of pixel format, during the Android startup:
Looked at this more closely.
Quoted 27 lines
2. Allow the guest to modify the framebuffer depth.
drivers/video/xen-fbfront.c +3
-4@@ -295,12 +295,11 @@ xenfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)if (var->xres > video[KPARAM_WIDTH ] || var->yres > video[KPARAM_HEIGHT ])return -EINVAL ; - required_mem_len = var->xres * var->yres * xenfb_info->page->depth /8 ; -if (var->bits_per_pixel == xenfb_info->page->depth && - var->xres <= info->fix.line_length / (XENFB_DEPTH /8 ) && - required_mem_len <= info->fix.smem_len) { + required_mem_len = var->xres * var->yres * var->bits_per_pixel /8 ; +if (required_mem_len <= info->fix.smem_len) { var->xres_virtual = var->xres; var->yres_virtual = var->yres; + info->fix.line_length = var->xres * var->bits_per_pixel/ 8; return 0; } return -EINVAL;
Quoted 2 lines
This works for my case, but involves modifying the fb_info.fix.line_length value - is this allowed?
You must not in change it in xenfb_check_var() since is only for validating the mode. Instead you should change it in xenfb_set_par().
When posting the patch, please Cc the framebuffer list and maintainers in addition to xen-devel.
David
Quoted 39 lines · David Vrabel
Quoted 8 lines · Gareth Stockwell
I'm facing some problems getting xenfb to work with an Android domU, on ARM.
The issue is that the framebuffer is created with a depth of 32bpp, while the Android guest is rendering RGB565.
I tried to fix this by using the fbdev API to request a change of pixel format, during the Android startup:
Looked at this more closely.
Quoted 27 lines
2. Allow the guest to modify the framebuffer depth.
drivers/video/xen-fbfront.c +3
-4@@ -295,12 +295,11 @@ xenfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)if (var->xres > video[KPARAM_WIDTH ] || var->yres > video[KPARAM_HEIGHT ])return -EINVAL ; - required_mem_len = var->xres * var->yres * xenfb_info->page->depth /8 ; -if (var->bits_per_pixel == xenfb_info->page->depth && - var->xres <= info->fix.line_length / (XENFB_DEPTH /8 ) && - required_mem_len <= info->fix.smem_len) { + required_mem_len = var->xres * var->yres * var->bits_per_pixel /8 ; +if (required_mem_len <= info->fix.smem_len) { var->xres_virtual = var->xres; var->yres_virtual = var->yres; + info->fix.line_length = var->xres * var->bits_per_pixel/ 8; return 0; } return -EINVAL;
Quoted 5 lines
Quoted 2 lines
This works for my case, but involves modifying the fb_info.fix.line_length value - is this allowed?
You must not in change it in
xenfb_check_var()since is only for validating the mode. Instead you should change it inxenfb_set_par().
As David wrote, yes, you are allowed to change info->fix.line_length, but you need to do it from xenfb_set_par.
Of course you also need to fix the check in xenfb_check_var.
Quoted 2 lines
When posting the patch, please Cc the framebuffer list and maintainers in addition to xen-devel.