xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* Modifying xenfb colour depth from Android domU
@ 2014-08-28  9:21 Gareth Stockwell
  2014-08-28 10:15 ` David Vrabel
  2014-08-28 12:43 ` David Vrabel
  0 siblings, 2 replies; 5+ messages in thread
From: Gareth Stockwell @ 2014-08-28  9:21 UTC (permalink / raw)
  To: xen-devel

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 int
xenfb_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.

diff --git a/include/xen/interface/io/fbif.h
b/include/xen/interface/io/fbif.h
index 974a51e..42b1258 100644
--- a/include/xen/interface/io/fbif.h
+++ b/include/xen/interface/io/fbif.h
@@ -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.

diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 02e1c01..b65a485 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Modifying xenfb colour depth from Android domU
  2014-08-28  9:21 Modifying xenfb colour depth from Android domU Gareth Stockwell
@ 2014-08-28 10:15 ` David Vrabel
  2014-08-28 11:16   ` Gareth Stockwell
  2014-08-28 12:43 ` David Vrabel
  1 sibling, 1 reply; 5+ messages in thread
From: David Vrabel @ 2014-08-28 10:15 UTC (permalink / raw)
  To: Gareth Stockwell, xen-devel

On 28/08/14 10:21, Gareth Stockwell wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Modifying xenfb colour depth from Android domU
  2014-08-28 10:15 ` David Vrabel
@ 2014-08-28 11:16   ` Gareth Stockwell
  0 siblings, 0 replies; 5+ messages in thread
From: Gareth Stockwell @ 2014-08-28 11:16 UTC (permalink / raw)
  To: xen-devel

On 28/08/14 11:15, David Vrabel wrote:
> On 28/08/14 10:21, Gareth Stockwell wrote:
>> 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
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Modifying xenfb colour depth from Android domU
  2014-08-28  9:21 Modifying xenfb colour depth from Android domU Gareth Stockwell
  2014-08-28 10:15 ` David Vrabel
@ 2014-08-28 12:43 ` David Vrabel
  2014-09-04 22:38   ` Stefano Stabellini
  1 sibling, 1 reply; 5+ messages in thread
From: David Vrabel @ 2014-08-28 12:43 UTC (permalink / raw)
  To: Gareth Stockwell, xen-devel

On 28/08/14 10:21, Gareth Stockwell wrote:
> 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.

> 2. Allow the guest to modify the framebuffer depth.
> 
> diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
> index 02e1c01..b65a485 100644
> --- a/drivers/video/xen-fbfront.c
> +++ b/drivers/video/xen-fbfront.c
> @@ -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?

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Modifying xenfb colour depth from Android domU
  2014-08-28 12:43 ` David Vrabel
@ 2014-09-04 22:38   ` Stefano Stabellini
  0 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2014-09-04 22:38 UTC (permalink / raw)
  To: David Vrabel; +Cc: Gareth Stockwell, xen-devel

On Thu, 28 Aug 2014, David Vrabel wrote:
> On 28/08/14 10:21, Gareth Stockwell wrote:
> > 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.
> 
> > 2. Allow the guest to modify the framebuffer depth.
> > 
> > diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
> > index 02e1c01..b65a485 100644
> > --- a/drivers/video/xen-fbfront.c
> > +++ b/drivers/video/xen-fbfront.c
> > @@ -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?
> 
> 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().

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.


> When posting the patch, please Cc the framebuffer list and maintainers
> in addition to xen-devel.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-04 22:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-28  9:21 Modifying xenfb colour depth from Android domU Gareth Stockwell
2014-08-28 10:15 ` David Vrabel
2014-08-28 11:16   ` Gareth Stockwell
2014-08-28 12:43 ` David Vrabel
2014-09-04 22:38   ` Stefano Stabellini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).