Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/macppc add driver for 'platinum' onboard video foun...
details: https://anonhg.NetBSD.org/src/rev/b1284def3355
branches: trunk
changeset: 345843:b1284def3355
user: macallan <macallan%NetBSD.org@localhost>
date: Fri Jun 10 21:32:46 2016 +0000
description:
add driver for 'platinum' onboard video found in Power Mac 7200 and possibly
other machines
from s_cole
diffstat:
sys/arch/macppc/conf/GENERIC_601 | 10 +-
sys/arch/macppc/conf/files.macppc | 6 +-
sys/arch/macppc/dev/platinumfb.c | 1033 +++++++++++++++++++++++++++++++++++++
3 files changed, 1045 insertions(+), 4 deletions(-)
diffs (truncated from 1090 to 300 lines):
diff -r aeaf47e1ad53 -r b1284def3355 sys/arch/macppc/conf/GENERIC_601
--- a/sys/arch/macppc/conf/GENERIC_601 Fri Jun 10 21:26:43 2016 +0000
+++ b/sys/arch/macppc/conf/GENERIC_601 Fri Jun 10 21:32:46 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC_601,v 1.7 2014/10/21 08:49:55 macallan Exp $
+# $NetBSD: GENERIC_601,v 1.8 2016/06/10 21:32:46 macallan Exp $
#
# GENERIC machine description file
#
@@ -28,7 +28,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-ident "GENERIC-$Revision: 1.7 $"
+ident "GENERIC-$Revision: 1.8 $"
maxusers 32
@@ -216,12 +216,16 @@
# Display devices
#
-# The 7200's onboard video is unsupported ( by OF no less ) so we need either a
+# The 7200's onboard video is unsupported by OF so we need either a
# graphics card that works as OF console or a serial console.
# The only cards known to work ( so far ) are PCI Voodoo3s flashed with the
# official Macintosh firmware from 3Dfx. The others should work but are
# untested with OF 1.0.5
+# this will take over the console if output-device is set to 'screen' or
+# 'platinum'. It will provide a NetBSD console, but still won't work with OF
+platinumfb0 at mainbus?
+
#gffb* at pci? function ? # NVIDIA GeForce2 MX
#machfb* at pci? function ? # ATI Mach 64, Rage, Rage Pro
#r128fb* at pci? function ? # ATI Rage 128
diff -r aeaf47e1ad53 -r b1284def3355 sys/arch/macppc/conf/files.macppc
--- a/sys/arch/macppc/conf/files.macppc Fri Jun 10 21:26:43 2016 +0000
+++ b/sys/arch/macppc/conf/files.macppc Fri Jun 10 21:32:46 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.macppc,v 1.101 2014/10/11 07:03:09 uebayasi Exp $
+# $NetBSD: files.macppc,v 1.102 2016/06/10 21:32:46 macallan Exp $
#
# macppc-specific configuration info
@@ -307,3 +307,7 @@
attach valkyriefb at mainbus
file arch/macppc/dev/valkyriefb.c valkyriefb
defflag opt_valkyriefb.h VALKYRIEFB_DEBUG
+
+device platinumfb: wsemuldisplaydev, rasops8, vcons, videomode
+attach platinumfb at mainbus
+file arch/macppc/dev/platinumfb.c
diff -r aeaf47e1ad53 -r b1284def3355 sys/arch/macppc/dev/platinumfb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/macppc/dev/platinumfb.c Fri Jun 10 21:32:46 2016 +0000
@@ -0,0 +1,1033 @@
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* A console driver for Apple's Platinum onboard video controller,
+ * found in (all?) Catalyst logic boards including the Powermac 7200.
+ *
+ * Used valkyriefb.c from NetBSD, and platinumfb.c/platinumfb.h from
+ * Linux sources as templates.
+ *
+ * Platinum is broken regarding openfirmware video variables. In OF,
+ * for a powermac 7200, doing "dev /platinum .properties" results in:
+ *
+ * name platinum
+ * device_type display
+ * model AAPL,343S1184
+ * AAPL,connector monitor
+ * reg F8000000 00000800
+ * F1000000 01000000
+ * AAPL,interrupts 0000001E
+ *
+ * The first reg is the register set, and the second is for the
+ * framebuffer. There is also a set of colormap registers hardcoded
+ * in platinumfbreg.h that (I think) aren't in openfirmware.
+ *
+ * powermac 7200 VRAM min and max limits are 1 and 4 Mb respectively.
+ * OF claims 16M so we don't use that value. If other machines can
+ * can have more or less VRAM this code will need to be modified
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: platinumfb.c,v 1.1 2016/06/10 21:32:46 macallan Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <uvm/uvm_param.h>
+
+#include <dev/ofw/openfirm.h>
+
+#include <machine/autoconf.h>
+#include <machine/pio.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wsfont/wsfont.h>
+#include <dev/rasops/rasops.h>
+#include <dev/wscons/wsdisplay_vconsvar.h>
+
+#include <dev/videomode/videomode.h>
+
+#include <arch/macppc/dev/platinumfbreg.h>
+
+#include <sys/sysctl.h>
+
+#include "opt_wsemul.h"
+
+/*
+ * here is a link of supported modes and resolutions:
+ * https://support.apple.com/kb/SP343?locale=en_US
+ *
+ * default console and X bpp/depth for built-in X config file,
+ * select 8 or 16 or 32.
+ *
+ */
+#define PLATINUM_CONSOLE_DEPTH 8
+#define PLATINUM_FB_DEPTH 16
+
+/*
+ * resolution, from one of platinumfb_setting vmode_name's.
+ */
+#define PLATINUM_FB_VMODE "1024x768x60"
+
+struct platinumfb_setting {
+ char vmode_name[24];
+ int32_t width;
+ int32_t height;
+ uint8_t freq;
+ uint8_t macmode;
+
+ int32_t pitch[3];
+ uint32_t regs[26];
+ uint8_t offset[3];
+ uint8_t mode[3];
+ uint8_t dacula_ctrl[3];
+ uint8_t clock_params[2][2];
+};
+
+struct platinumfb_softc {
+ device_t sc_dev;
+ int sc_node;
+
+ uint8_t *sc_reg;
+ uint32_t sc_reg_size;
+
+ uint8_t *sc_cmap;
+ uint32_t sc_cmap_size;
+
+ uint8_t *sc_fb;
+ uint32_t sc_fb_size;
+
+ int sc_depth;
+ int sc_width, sc_height, sc_linebytes;
+ const struct videomode *sc_videomode;
+ uint8_t sc_modereg;
+
+ int sc_mode;
+
+ u_char sc_cmap_red[256];
+ u_char sc_cmap_green[256];
+ u_char sc_cmap_blue[256];
+
+ struct vcons_data vd;
+
+ uint8_t sc_cmode;
+ uint8_t sc_dac_type;
+ uint32_t sc_vram;
+ int sc_on;
+ struct platinumfb_setting *sc_pfs;
+};
+
+#define DIV2 0x20
+#define DIV4 0x40
+#define DIV8 0x60
+#define DIV16 0x80
+
+static struct platinumfb_setting platinum_5 = {
+ "640x480x60",
+ 640, 480, 60, 5,
+ { 672, 1312, 2592 },
+ { 0xff0, 4, 0, 0, 0, 0, 0x320, 0,
+ 0, 0x15e, 0xc8, 0x18, 0x18f, 0x2f, 0x35, 0x3e,
+ 0x42, 0x182, 0x18e, 0x41a, 0x418, 2, 7, 0x44,
+ 0x404, 0x408 }, { 0x34, 0x3c, 0x41 },
+ { 2, 0, 0xff }, { 0x11, 0x15, 0x19 },
+ {{ 26, 0 + DIV8 }, { 14, 2 + DIV4 }}
+};
+
+static struct platinumfb_setting platinum_12 = {
+ "800x600x75",
+ 800, 600, 75, 12,
+ { 832, 1632, 3232 },
+ { 0xff0, 4, 0, 0, 0, 0, 0x320, 0,
+ 0, 0x1ce, 0x108, 0x14, 0x20f, 0x27, 0x30, 0x39,
+ 0x72, 0x202, 0x20e, 0x4e2, 0x4e0, 4, 9, 0x2e,
+ 0x4de, 0x4df }, { 0x64, 0x6c, 0x71 },
+ { 2, 0, 0xff }, { 0x11, 0x15, 0x19 },
+ {{ 122, 7 + DIV4 }, { 62, 9 + DIV2 }}
+};
+
+static struct platinumfb_setting platinum_14 = {
+ "1024x768x60",
+ 1024, 768, 60, 14,
+ { 1056, 2080, 4128 },
+ { 0xff0, 4, 0, 0, 0, 0, 0x320, 0,
+ 0, 0x25a, 0x14f, 0x22, 0x29f, 0x43, 0x49, 0x5b,
+ 0x8e, 0x28e, 0x29e, 0x64c, 0x64a, 0xa, 0xf, 0x44,
+ 0x644, 0x646 }, { 0x80, 0x88, 0x8d },
+ { 2, 0, 0xff }, { 0x11, 0x15, 0x19 },
+ {{ 71, 6 + DIV2 }, { 118, 13 + DIV2 }}
+};
+
+static struct platinumfb_setting platinum_20 = {
+ "1280x1024x75",
+ 1280, 1024, 75, 20,
+ { 1312, 2592, 2592 },
+ { 0xffc, 4, 0, 0, 0, 0, 0x428, 0,
+ 0, 0xb3, 0xd3, 0x12, 0x1a5, 0x23, 0x28, 0x2d,
+ 0x5e, 0x19e, 0x1a4, 0x854, 0x852, 4, 9, 0x50,
+ 0x850, 0x851 }, { 0x58, 0x5d, 0x5d },
+ { 0, 0xff, 0xff }, { 0x51, 0x55, 0x55 },
+ {{ 45, 3 }, { 66, 7 }}
+};
+
+static struct platinumfb_setting *pfb_setting[] = {
+ &platinum_5,
+ &platinum_12,
+ &platinum_14,
+ &platinum_20
+};
+
+static struct vcons_screen platinumfb_console_screen;
+
+static int platinumfb_match(device_t, cfdata_t, void *);
+static void platinumfb_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(platinumfb, sizeof(struct platinumfb_softc),
+ platinumfb_match, platinumfb_attach, NULL, NULL);
+
+static int platinumfb_init(device_t);
+static int platinumfb_set_mode(struct platinumfb_softc *,
+ const struct videomode *, int);
+static void platinumfb_set_rasops(struct platinumfb_softc *,
+ struct rasops_info *, int);
+static int platinumfb_ioctl(void *, void *, u_long, void *, int,
+ struct lwp *);
+static paddr_t platinumfb_mmap(void *, void *, off_t, int);
+static void platinumfb_init_screen(void *, struct vcons_screen *, int,
+ long *);
+static int platinumfb_putcmap(struct platinumfb_softc *,
+ struct wsdisplay_cmap *);
+static int platinumfb_getcmap(struct platinumfb_softc *,
+ struct wsdisplay_cmap *);
+static void platinumfb_init_cmap(struct platinumfb_softc *);
+static void platinumfb_restore_palette(struct platinumfb_softc *);
+static void platinumfb_putpalreg(struct platinumfb_softc *,
+ uint8_t, uint8_t, uint8_t, uint8_t);
+static uint32_t platinumfb_line_tweak(struct platinumfb_softc *);
+static paddr_t platinumfb_page_align_up(struct platinumfb_softc *);
+static void platinumfb_set_clock(struct platinumfb_softc *);
+static void platinumfb_dac_type(struct platinumfb_softc *);
+static void platinumfb_memory_size(struct platinumfb_softc *);
+static void platinumfb_set_hardware(struct platinumfb_softc *);
+
+static inline void platinumfb_write_reg(struct platinumfb_softc *,
+ int, uint32_t);
+static inline uint32_t platinumfb_read_reg(struct platinumfb_softc *, int);
+static inline void platinumfb_write_cmap_reg(struct platinumfb_softc *,
+ int, uint8_t);
+static inline uint8_t platinumfb_read_cmap_reg(struct platinumfb_softc *, int);
+static inline void platinumfb_store_d2(struct platinumfb_softc *,
+ uint8_t, uint8_t);
+
Home |
Main Index |
Thread Index |
Old Index