[fbdev_backend]: support of DIRECTCOLOR Frame buffer
Marc Chalain
marc.chalain at gmail.com
Fri Jun 7 08:13:59 PDT 2013
>From e30486e0288e7be526fc358a5318b344522e407b Mon Sep 17 00:00:00 2001
From: mchalain <marc.chalain at gmail.com>
Date: Fri, 7 Jun 2013 17:12:31 +0200
Subject: [PATCH] [fbdev_backend]: support of DIRECTCOLOR Frame buffer
---
src/compositor-fbdev.c | 49
+++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 46 insertions(+), 3 deletions(-)
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 9c3d17e..d6d911a 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -203,9 +203,42 @@ finish_frame_handler(void *data)
return 1;
}
+static int
+build_cmap(struct fb_var_screeninfo *vinfo,
+ struct fb_cmap *cmap)
+{
+ uint16_t *colors;
+ int i;
+ int rcols = 1 << vinfo->red.length;
+ int gcols = 1 << vinfo->green.length;
+ int bcols = 1 << vinfo->blue.length;
+
+ /* Make our palette the length of the deepest color */
+ int cols = (rcols > gcols ? rcols : gcols);
+ cols = (cols > bcols ? cols : bcols);
+
+ colors = malloc(sizeof(uint16_t) * cols);
+ if (!colors) return -1;
+
+ for (i = 0; i < rcols; i++)
+ colors[i] = (UINT16_MAX / (rcols - 1)) * i;
+
+ cmap->start = 0;
+ cmap->len = cols;
+ cmap->red = colors;
+ cmap->blue = colors;
+ cmap->green = colors;
+ if (vinfo->transp.length)
+ cmap->transp = colors;
+ else
+ cmap->transp = NULL;
+ return 0;
+}
+
static pixman_format_code_t
calculate_pixman_format(struct fb_var_screeninfo *vinfo,
- struct fb_fix_screeninfo *finfo)
+ struct fb_fix_screeninfo *finfo,
+ struct fb_cmap *cmap)
{
/* Calculate the pixman format supported by the frame buffer from the
* buffer's metadata. Return 0 if no known pixman format is supported
@@ -241,7 +274,10 @@ calculate_pixman_format(struct fb_var_screeninfo
*vinfo,
if (finfo->type != FB_TYPE_PACKED_PIXELS)
return 0;
- /* We only handle true-colour frame buffers at the moment. */
+ if (finfo->visual == FB_VISUAL_DIRECTCOLOR)
+ build_cmap(vinfo, cmap);
+ else
+ /* We only handle true-colour frame buffers at the moment. */
if (finfo->visual != FB_VISUAL_TRUECOLOR || vinfo->grayscale != 0)
return 0;
@@ -304,6 +340,9 @@ fbdev_query_screen_info(struct fbdev_output *output,
int fd,
{
struct fb_var_screeninfo varinfo;
struct fb_fix_screeninfo fixinfo;
+ struct fb_cmap cmap;
+
+ memset(&cmap, 0, sizeof(cmap));
/* Probe the device for screen information. */
if (ioctl(fd, FBIOGET_FSCREENINFO, &fixinfo) < 0 ||
@@ -322,9 +361,13 @@ fbdev_query_screen_info(struct fbdev_output *output,
int fd,
info->line_length = fixinfo.line_length;
strncpy(info->id, fixinfo.id, sizeof(info->id) / sizeof(*info->id));
- info->pixel_format = calculate_pixman_format(&varinfo, &fixinfo);
+ info->pixel_format = calculate_pixman_format(&varinfo, &fixinfo,
&cmap);
info->refresh_rate = calculate_refresh_rate(&varinfo);
+ if (cmap.red != NULL) {
+ ioctl(fd, FBIOPUTCMAP, &cmap);
+ free(cmap.red);
+ }
if (info->pixel_format == 0) {
weston_log("Frame buffer uses an unsupported format.\n");
return -1;
--
1.7.9.5
2013/6/7 Pekka Paalanen <ppaalanen at gmail.com>
> On Fri, 7 Jun 2013 16:03:18 +0200
> Marc Chalain <marc.chalain at gmail.com> wrote:
>
> > > You should execute the ioctl in fbdev_set_screen_info.
> > fbdev_set_screen_info is used only when the fb device is reenabled. The
> > colors map has to be initialized at the beginning in all cases.
> > If we use this function we will call it in all cases and it's not
> required.
> >
> >
> > >I don't see the codepath which results in cmap.transp being not set in
> the
> > test for it.
> > Yes... I forgot => new patch
> >
> >
> > >You don't initialize cmap.red so the test for it gives an undefined
> result.
> > Yes... error => new patch
> >
> >
> > >Don't define macros in the middle of code with a literal that's only
> used
> > once.
> > In fact that comes from the cmap.transp which are not always initialized.
> > In some cases transparency is useless. But I will repair => new patch
> >
> > New patch
>
> Also, please use git-format-patch, and send the patches inline, not as
> attachments. Furthermore, using git-send-email would guarantee, that the
> patches do not get mangled by your email client.
>
>
> Thanks,
> pq
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130607/9b039917/attachment-0001.html>
More information about the wayland-devel
mailing list