Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ofw add another convenience function - of_get_mode_s...



details:   https://anonhg.NetBSD.org/src/rev/64981c282ee4
branches:  trunk
changeset: 748955:64981c282ee4
user:      macallan <macallan%NetBSD.org@localhost>
date:      Wed Nov 11 16:56:52 2009 +0000

description:
add another convenience function - of_get_mode_string() to extract a Sun-like
video mode specifier from output-device

diffstat:

 sys/dev/ofw/ofw_subr.c |  35 +++++++++++++++++++++++++++++++++--
 sys/dev/ofw/openfirm.h |   3 ++-
 2 files changed, 35 insertions(+), 3 deletions(-)

diffs (69 lines):

diff -r f1b03bf8b328 -r 64981c282ee4 sys/dev/ofw/ofw_subr.c
--- a/sys/dev/ofw/ofw_subr.c    Wed Nov 11 16:50:17 2009 +0000
+++ b/sys/dev/ofw/ofw_subr.c    Wed Nov 11 16:56:52 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw_subr.c,v 1.14 2009/03/14 21:04:21 dsl Exp $        */
+/*     $NetBSD: ofw_subr.c,v 1.15 2009/11/11 16:56:52 macallan Exp $   */
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.14 2009/03/14 21:04:21 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.15 2009/11/11 16:56:52 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -291,3 +291,34 @@
        data = prop_data_create_data(prop, len);
        return(prop_dictionary_set(dict, propname, data));
 }
+
+/*
+ * look at output-device, see if there's a Sun-typical video mode specifier as
+ * in screen:r1024x768x60 attached. If found copy it into *buffer, otherwise
+ * return NULL
+ */
+
+char *
+of_get_mode_string(char *buffer, int len)
+{
+       int options;
+       char *pos, output_device[256];
+
+       /*
+        * finally, let's see if there's a video mode specified in
+        * output-device and pass it on so there's at least some way
+        * to program video modes
+        */
+       options = OF_finddevice("/options");
+       if ((options == 0) || (options == -1))
+               return NULL;
+       if (OF_getprop(options, "output-device", output_device, 256) == 0)
+               return NULL;
+
+       /* find the mode string if there is one */
+       pos = strstr(output_device, ":r");
+       if (pos == NULL)
+               return NULL;
+       strncpy(buffer, pos + 2, len);
+       return buffer;
+}
diff -r f1b03bf8b328 -r 64981c282ee4 sys/dev/ofw/openfirm.h
--- a/sys/dev/ofw/openfirm.h    Wed Nov 11 16:50:17 2009 +0000
+++ b/sys/dev/ofw/openfirm.h    Wed Nov 11 16:56:52 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: openfirm.h,v 1.26 2007/12/25 18:33:40 perry Exp $      */
+/*     $NetBSD: openfirm.h,v 1.27 2009/11/11 16:56:52 macallan Exp $   */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -113,5 +113,6 @@
     const char *);
 
 int    *of_network_decode_media(int, int *, int *);
+char   *of_get_mode_string(char *, int);
 
 #endif /*_OPENFIRM_H_*/



Home | Main Index | Thread Index | Old Index