Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/wscons add ioctl(WSDISPLAYIO_GET_FBINFO)



details:   https://anonhg.NetBSD.org/src/rev/563c6507958d
branches:  trunk
changeset: 784530:563c6507958d
user:      macallan <macallan%NetBSD.org@localhost>
date:      Thu Jan 31 10:57:30 2013 +0000

description:
add ioctl(WSDISPLAYIO_GET_FBINFO)

diffstat:

 sys/dev/wscons/wsconsio.h       |  49 ++++++++++++++++++++++++++++++++++++++++-
 sys/dev/wscons/wsdisplay_util.c |  34 ++++++++++++++++++++++++++-
 sys/dev/wscons/wsdisplayvar.h   |   6 ++++-
 3 files changed, 85 insertions(+), 4 deletions(-)

diffs (142 lines):

diff -r 27f547a8aa78 -r 563c6507958d sys/dev/wscons/wsconsio.h
--- a/sys/dev/wscons/wsconsio.h Thu Jan 31 07:11:08 2013 +0000
+++ b/sys/dev/wscons/wsconsio.h Thu Jan 31 10:57:30 2013 +0000
@@ -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 @@
 #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_ */
diff -r 27f547a8aa78 -r 563c6507958d sys/dev/wscons/wsdisplay_util.c
--- a/sys/dev/wscons/wsdisplay_util.c   Thu Jan 31 07:11:08 2013 +0000
+++ b/sys/dev/wscons/wsdisplay_util.c   Thu Jan 31 10:57:30 2013 +0000
@@ -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 @@
        }
        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;
+}
diff -r 27f547a8aa78 -r 563c6507958d sys/dev/wscons/wsdisplayvar.h
--- a/sys/dev/wscons/wsdisplayvar.h     Thu Jan 31 07:11:08 2013 +0000
+++ b/sys/dev/wscons/wsdisplayvar.h     Thu Jan 31 10:57:30 2013 +0000
@@ -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 @@
 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



Home | Main Index | Thread Index | Old Index