Subject: Re: framebuffer access
To: Michael <macallan18@earthlink.net>
From: Radek Kujawa <streamer@cytrynka.infoland.int.pl>
List: port-sparc64
Date: 11/13/2005 18:10:14
Hi

On Sun, 13 Nov 2005, Michael wrote:
> > - off_t offset
> > - size_t size
> > - ? organization - this is very important when accessing fb in
> > non-paletted mode, because now in user-space we have no idea how
> > things are stored in fb memory
>
> At least geometry and colour depth are returned by
> ioctl(WSDISPLAYIO_GINFO), but it doesn't tell you anything about colour
> format, there's no way to tell if it's RGB or BGR in 24bit or 32bit mode
> and you'd have to probe endianness yourself. Well, I've never seen a PCI
> framebuffer that uses anything else than RGB so that may be a safe bet
> but ffb and many SBus framebuffers use BGR (not that we support wscons
> on a single SBus 24bit framebuffer so far, but this will change) so an
> app that assumes RGB would look funny on any of these.

Yes, I know about WSDISPLAYIO_GINFO, I did my homework and read
wsdisplay(4) ;). I meant returning information about endinness and
RGB/BGR/something else in organization field of structure. This will
certainly help in the future (and on other ports).

I'm willing to write it, but I don't know how info about fb organization
should be returned. For example mach64 has two views. Supporting different
views will add complexity to the API. I don't know if it's the right thing
to do.

What do you think of:
WSDISPLAYIO_GMMAPINFO

retruning:
struct wdisplay_mmapinfo {
	u_int views;
	/* number of available views */

	off_t *offset;
	/* (array) offset of each view
	for example on mach64 we would have 2 offsets,
	one for standard view, other for view with endianness
	conversion */

	size_t *size;
	/* array, size of each view */

	u_int *org;
	/* organization of each view */
}

org will be filled with constant:

#define WSDISPLAY_FB_UNKNOWN		0
#define WSDISPLAY_FB_PSEUDOCOLOR	1	/* 8-bit, colormap */
#define WSDISPLAY_FB_RGB24_PLAIN	2	/* 24-bit RGB, plain */
#define WSDISPLAY_FB_RGB24_SWAPENDIAN	3	/* ^ endianness swapped */
#define WSDISPLAY_FB_OTHERFANCYMODE     4	/* ... */
(...)


Example user-side code for finding usable 24-bit view:

int i;
struct wsdisplay_mmapinfo fb_view;
ioctl(fb_fd, WSDISPLAYIO_GMMAPINFO, fb_view);

for(i=0; i<fb_view.views; i++) {
	if(fb_view.org[i] == WSDISPLAY_FB_RGB24_PLAIN)
		printf("We've found usable view at %lx!\n",
			fb_view.offset[i]);
}

Does it make any sense?

Radek