Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sgimips/dev Add support for overriding the video mo...
details: https://anonhg.NetBSD.org/src/rev/eef3d9d39e1b
branches: trunk
changeset: 360585:eef3d9d39e1b
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Mar 17 13:14:27 2018 +0000
description:
Add support for overriding the video mode by setting an ARCS environment
variable.
If the "crmfb_mode" environment variable is set, treat it as a mode
string in the form WIDTHxHEIGHT[@REFRESH] and generate monitor timings
using the VESA GTF formula. If set, this overrides the EDID preferred
mode.
diffstat:
sys/arch/sgimips/dev/crmfb.c | 54 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 47 insertions(+), 7 deletions(-)
diffs (100 lines):
diff -r 5f96c0b8aa00 -r eef3d9d39e1b sys/arch/sgimips/dev/crmfb.c
--- a/sys/arch/sgimips/dev/crmfb.c Sat Mar 17 11:07:26 2018 +0000
+++ b/sys/arch/sgimips/dev/crmfb.c Sat Mar 17 13:14:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crmfb.c,v 1.44 2017/05/19 19:25:53 macallan Exp $ */
+/* $NetBSD: crmfb.c,v 1.45 2018/03/17 13:14:27 jmcneill Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crmfb.c,v 1.44 2017/05/19 19:25:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crmfb.c,v 1.45 2018/03/17 13:14:27 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -57,6 +57,7 @@
#include <dev/i2c/i2c_bitbang.h>
#include <dev/i2c/ddcvar.h>
#include <dev/videomode/videomode.h>
+#include <dev/videomode/vesagtf.h>
#include <dev/videomode/edidvar.h>
#include <arch/sgimips/dev/crmfbreg.h>
@@ -232,6 +233,7 @@
/* mode setting stuff */
static uint32_t calc_pll(int); /* frequency in kHz */
static int crmfb_set_mode(struct crmfb_softc *, const struct videomode *);
+static int crmfb_parse_mode(const char *, struct videomode *);
CFATTACH_DECL_NEW(crmfb, sizeof(struct crmfb_softc),
crmfb_match, crmfb_attach, NULL, NULL);
@@ -254,6 +256,8 @@
unsigned long v;
long defattr;
const char *consdev;
+ const char *modestr;
+ struct videomode mode, *pmode;
int rv, i;
sc = device_private(self);
@@ -305,11 +309,16 @@
sc->sc_console_depth = 8;
crmfb_setup_ddc(sc);
- if ((sc->sc_edid_info.edid_preferred_mode != NULL)) {
- if (crmfb_set_mode(sc, sc->sc_edid_info.edid_preferred_mode))
- aprint_normal_dev(sc->sc_dev, "using %dx%d\n",
- sc->sc_width, sc->sc_height);
- }
+ pmode = sc->sc_edid_info.edid_preferred_mode;
+
+ modestr = arcbios_GetEnvironmentVariable("crmfb_mode");
+ if (crmfb_parse_mode(modestr, &mode) == 0)
+ pmode = &mode;
+
+ if (pmode != NULL && crmfb_set_mode(sc, pmode))
+ aprint_normal_dev(sc->sc_dev, "using %dx%d\n",
+ sc->sc_width, sc->sc_height);
+
/*
* first determine how many tiles we need
* in 32bit each tile is 128x128 pixels
@@ -1859,3 +1868,34 @@
return TRUE;
}
+
+/*
+ * Parse a mode string in the form WIDTHxHEIGHT[@REFRESH] and return
+ * monitor timings generated using the VESA GTF formula.
+ */
+static int
+crmfb_parse_mode(const char *modestr, struct videomode *mode)
+{
+ char *x, *at;
+ int width, height, refresh;
+
+ if (modestr == NULL)
+ return EINVAL;
+
+ x = strchr(modestr, 'x');
+ at = strchr(modestr, '@');
+
+ if (x == NULL || (at != NULL && at < x))
+ return EINVAL;
+
+ width = strtoul(modestr, NULL, 10);
+ height = strtoul(x + 1, NULL, 10);
+ refresh = at ? strtoul(at + 1, NULL, 10) : 60;
+
+ if (width == 0 || height == 0 || refresh == 0)
+ return EINVAL;
+
+ vesagtf_mode(width, height, refresh, mode);
+
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index