Module Name:    src
Committed By:   macallan
Date:           Thu Jan 31 10:57:31 UTC 2013

Modified Files:
        src/sys/dev/wscons: wsconsio.h wsdisplay_util.c wsdisplayvar.h

Log Message:
add ioctl(WSDISPLAYIO_GET_FBINFO)


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/wscons/wsconsio.h
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/wscons/wsdisplay_util.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/wscons/wsdisplayvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/wscons/wsconsio.h
diff -u src/sys/dev/wscons/wsconsio.h:1.106 src/sys/dev/wscons/wsconsio.h:1.107
--- src/sys/dev/wscons/wsconsio.h:1.106	Mon Jan 21 14:15:03 2013
+++ src/sys/dev/wscons/wsconsio.h	Thu Jan 31 10:57:30 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wsconsio.h,v 1.106 2013/01/21 14:15:03 macallan Exp $ */
+/* $NetBSD: wsconsio.h,v 1.107 2013/01/31 10:57:30 macallan Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -603,4 +603,51 @@ struct wsdisplayio_edid_info {
 #define WSDISPLAYIO_SET_POLLING	_IOW('W', 103, int)
 #define WSDISPLAYIOMGWEHITANDKILLEDASKUNK WSDISPLAYIO_SET_POLLING
 
+/*
+ * this is supposed to replace WSDISPLAYIO_GINFO, WSDISPLAYIO_GTYPE,
+ * WSDISPLAYIO_LINEBYTES etc.
+ */
+
+/* format type - colour index, 'true' colour etc. */
+#define WSFB_RGB	0
+#define WSFB_CI		1	/* colour indexed, see subtype */
+#define WSFB_GREYSCALE	2
+#define WSFB_YUV	3
+
+struct wsdisplayio_fbinfo {
+	uint64_t fbi_fbsize;		/* framebuffer size in bytes */
+	uint64_t fbi_fboffset;		/* start of visible fb, in bytes */ 
+	uint32_t fbi_width;		/* in pixels */
+	uint32_t fbi_height;		/* in lines */
+	uint32_t fbi_stride;		/* in bytes */
+	uint32_t fbi_bitsperpixel;
+	uint32_t fbi_pixeltype;		/* see above */
+	union _fbi_subtype {
+		struct _fbi_rgbmasks {
+			/* offsets from the right, size in bits */
+			uint32_t red_offset;
+			uint32_t red_size;
+			uint32_t green_offset;
+			uint32_t green_size;
+			uint32_t blue_offset;
+			uint32_t blue_size;
+			uint32_t alpha_offset;
+			uint32_t alpha_size;
+		} fbi_rgbmasks;
+		struct _fbi_cmapinfo {
+			uint32_t cmap_entries;
+		} fbi_cmapinfo;
+		/* 
+		 * TODO:
+		 * add parameter blocks for greyscale, yuv etc.
+		 */
+	} fbi_subtype;
+	uint32_t fbi_flags;
+};
+
+/* fbi_flags */
+#define WSFB_VRAM_IS_RAM	1	/* hint for wsfb - don't shadow */
+
+#define WSDISPLAYIO_GET_FBINFO	_IOWR('W', 104, struct wsdisplayio_fbinfo)
+
 #endif /* _DEV_WSCONS_WSCONSIO_H_ */

Index: src/sys/dev/wscons/wsdisplay_util.c
diff -u src/sys/dev/wscons/wsdisplay_util.c:1.1 src/sys/dev/wscons/wsdisplay_util.c:1.2
--- src/sys/dev/wscons/wsdisplay_util.c:1.1	Wed Jun 29 03:09:37 2011
+++ src/sys/dev/wscons/wsdisplay_util.c	Thu Jan 31 10:57:31 2013
@@ -1,7 +1,7 @@
-/*	$NetBSD: wsdisplay_util.c,v 1.1 2011/06/29 03:09:37 macallan Exp $ */
+/*	$NetBSD: wsdisplay_util.c,v 1.2 2013/01/31 10:57:31 macallan Exp $ */
 
 /*-
- * Copyright (c) 2009 Michael Lorenz
+ * Copyright (c) 2011 Michael Lorenz
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,6 +27,7 @@
  */
 
 /* some utility functions for use with wsdisplay */
+
 #include <sys/param.h>
 #include <sys/stdint.h>
 #include <sys/systm.h>
@@ -35,6 +36,7 @@
 #include <dev/cons.h>
 
 #include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
 #include <dev/wscons/wsconsio.h>
 
 int
@@ -57,3 +59,31 @@ wsdisplayio_get_edid(device_t dev, struc
 	}
 	return ENODEV;
 }
+
+/* convenience function to fill in stuff from rasops_info */
+int
+wsdisplayio_get_fbinfo(struct rasops_info *ri, struct wsdisplayio_fbinfo *fbi)
+{
+	fbi->fbi_width = ri->ri_width;
+	fbi->fbi_height = ri->ri_height;
+	fbi->fbi_stride = ri->ri_stride;
+	fbi->fbi_bitsperpixel = ri->ri_depth;
+	if (ri->ri_depth > 8) {
+		fbi->fbi_pixeltype = WSFB_RGB;
+		fbi->fbi_subtype.fbi_rgbmasks.red_offset = ri->ri_rpos;
+		fbi->fbi_subtype.fbi_rgbmasks.red_size = ri->ri_rnum;
+		fbi->fbi_subtype.fbi_rgbmasks.green_offset = ri->ri_gpos;
+		fbi->fbi_subtype.fbi_rgbmasks.green_size = ri->ri_gnum;
+		fbi->fbi_subtype.fbi_rgbmasks.blue_offset = ri->ri_bpos;
+		fbi->fbi_subtype.fbi_rgbmasks.blue_size = ri->ri_bnum;
+		fbi->fbi_subtype.fbi_rgbmasks.alpha_offset = 0;
+		fbi->fbi_subtype.fbi_rgbmasks.alpha_size = 0;
+	} else {
+		fbi->fbi_pixeltype = WSFB_CI;
+		fbi->fbi_subtype.fbi_cmapinfo.cmap_entries = 1 << ri->ri_depth;
+	}
+	fbi->fbi_flags = 0;
+	fbi->fbi_fbsize = ri->ri_stride * ri->ri_height;
+	fbi->fbi_fboffset = 0;
+	return 0;
+}

Index: src/sys/dev/wscons/wsdisplayvar.h
diff -u src/sys/dev/wscons/wsdisplayvar.h:1.49 src/sys/dev/wscons/wsdisplayvar.h:1.50
--- src/sys/dev/wscons/wsdisplayvar.h:1.49	Wed Jun 29 03:11:59 2011
+++ src/sys/dev/wscons/wsdisplayvar.h	Thu Jan 31 10:57:30 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wsdisplayvar.h,v 1.49 2011/06/29 03:11:59 macallan Exp $ */
+/* $NetBSD: wsdisplayvar.h,v 1.50 2013/01/31 10:57:30 macallan Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -207,6 +207,10 @@ int wsdisplay_cfg_ioctl(struct wsdisplay
 struct wsdisplayio_edid_info;
 int wsdisplayio_get_edid(device_t, struct wsdisplayio_edid_info *);
 
+struct wsdisplayio_fbinfo;
+struct rasops_info;
+int wsdisplayio_get_fbinfo(struct rasops_info *, struct wsdisplayio_fbinfo *);
+
 #ifdef WSDISPLAY_SCROLLSUPPORT
 void wsdisplay_scroll(void *, int);
 #endif

Reply via email to