Module Name: src
Committed By: macallan
Date: Wed Nov 11 16:56:52 UTC 2009
Modified Files:
src/sys/dev/ofw: ofw_subr.c openfirm.h
Log Message:
add another convenience function - of_get_mode_string() to extract a Sun-like
video mode specifier from output-device
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ofw/ofw_subr.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ofw/openfirm.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/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.14 src/sys/dev/ofw/ofw_subr.c:1.15
--- src/sys/dev/ofw/ofw_subr.c:1.14 Sat Mar 14 21:04:21 2009
+++ src/sys/dev/ofw/ofw_subr.c Wed Nov 11 16:56:52 2009
@@ -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;
+}
Index: src/sys/dev/ofw/openfirm.h
diff -u src/sys/dev/ofw/openfirm.h:1.26 src/sys/dev/ofw/openfirm.h:1.27
--- src/sys/dev/ofw/openfirm.h:1.26 Tue Dec 25 18:33:40 2007
+++ src/sys/dev/ofw/openfirm.h Wed Nov 11 16:56:52 2009
@@ -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_*/