[Commit] mq1100 Makefile,1.2,1.3 mq.c,1.1.1.1,1.2 mq1100.h,1.2,1.3 mqinit.c,1.2,1.3

Keith Packard commit@keithp.com
Mon, 19 May 2003 11:15:41 -0700


Committed by: keithp

Update of /local/src/CVS/mq1100
In directory home.keithp.com:/tmp/cvs-serv25523

Modified Files:
	Makefile mq.c mq1100.h mqinit.c 
Log Message:
Make it work on h5400

Index: Makefile
===================================================================
RCS file: /local/src/CVS/mq1100/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile	10 May 2003 02:26:19 -0000	1.2
+++ Makefile	19 May 2003 18:15:39 -0000	1.3
@@ -1,17 +1,24 @@
+CC=/usr/local/arm/3.2.3/bin/arm-linux-gcc
 CDEBUGFLAGS=-g -O2
 DFLAGS=-D__KERNEL__ -DMODULE
 IFLAGS=-I/usr/src/linux/include
 WFLAGS=-Wall -Wstrict-prototypes -Wno-trigraphs 
 FFLAGS=-fno-strict-aliasing -fno-common -fomit-frame-pointer
-MFLAGS=-mpreferred-stack-boundary=2 -march=i586
+#MFLAGS=-mpreferred-stack-boundary=2 -march=i586
 CFLAGS=$(CDEBUGFLAGS) $(DFLAGS) $(IFLAGS) $(WFLAGS) $(FFLAGS) $(MFLAGS)
-OBJS=mq1100fb.o mqinit.o
-MODULE=mq.o
+SHOBJ=mqinit.o
+MOBJS=mq1100fb.o $(SHOBJ)
+POBJS=mq.o $(SHOBJ)
+$(OBJS): $(MOBJS) $(POBJS)
+MODULE=mq1100.o
 VERSION=2.4.20
+PROG=mq
 DEST=/lib/modules/$(VERSION)/kernel/drivers/video
 
-$(MODULE): $(OBJS)
-	ld -m elf_i386 -r -o $@ $(OBJS)
+all: $(PROG) # $(MODULE) 
+
+$(MODULE): $(MOBJS)
+	ld -m elf_i386 -r -o $@ $(MOBJS)
 
 $(OBJS): mq1100.h
 
@@ -21,3 +28,6 @@
 
 $(DEST):
 	mkdir -p $(DEST)
+
+$(PROG): mq.c mqinit.c mq1100.h
+	$(CC) -o $(PROG) mq.c mqinit.c

Index: mq.c
===================================================================
RCS file: /local/src/CVS/mq1100/mq.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- mq.c	8 May 2003 21:58:36 -0000	1.1.1.1
+++ mq.c	19 May 2003 18:15:39 -0000	1.2
@@ -51,10 +51,26 @@
 #define FALSE 0
 #define TRUE 1
 
+#ifdef __arm__
+#define MEDIAQ_BASE 0x04000000
+#define GPIO_BASE   0x140c0000
+#define GPIOB_DATA  0x140c0014
+#define POWER_MQ    (1 << 4)
+#define POWER_LIGHT (1 << 6)
+#define POWER_LCD   (1 << 7)
+#define MEDIAQ_INIT (&mqInitH5400)
+#define VLIO_BASE   0x48000000
+#define VLIO_REG    0x48000008
+#define VLIO_VALUE  0x26ec26e0
+
+#else
+
 #ifndef KD_MAX_CARD_ADDRESS
 #define KD_MAX_CARD_ADDRESS 8
 #endif
 
+#define MEDIAQ_INIT (&mqInitSharp)
+
 typedef struct _KdCardAttr {
     CARD32  io;
     CARD32  address[KD_MAX_CARD_ADDRESS];
@@ -128,6 +144,7 @@
     fclose (f);
     return ret;
 }
+#endif
 
 void *
 KdMapDevice (CARD32 addr, CARD32 size)
@@ -164,13 +181,61 @@
     munmap (addr, size);
 }
 
+unsigned long peek (unsigned long address)
+{
+    void	    *a;
+    unsigned long   page = address & ~(4*1024 - 1);
+    unsigned long   *addr;
+    unsigned long   value;
+
+    a = KdMapDevice (page, 4*1024);
+    addr = ((unsigned long *) ((char *) a + address - page));
+    value = *addr;
+    printf ("peek 0x%x(0x%x) = 0x%x\n", address, addr, value);
+    KdUnmapDevice (a, 4*1024);
+    return value;
+}
+
+void poke (unsigned long address, unsigned long value)
+{
+    void	    *a;
+    unsigned long   page = address & ~(4*1024 - 1);
+    unsigned long   *addr;
+
+    a = KdMapDevice (page, 4*1024);
+    addr = ((unsigned long *) ((char *) a + address - page));
+    *addr = value;
+    printf ("poke 0x%x(0x%x) = 0x%x(0x%x)\n", address, addr, value, *addr);
+    KdUnmapDevice (a, 4*1024);
+}
+
 Bool
 MqMapDevice (MqMap *map)
 {
-    KdCardAttr	a;
     int		i;
     void	*a0, *a1;
 
+#ifdef __arm__
+    peek (VLIO_REG);
+    /* pb fixed the kernel to set this for us */
+/*    poke (VLIO_REG, VLIO_VALUE); */
+    poke (GPIOB_DATA, (peek (GPIOB_DATA) & 
+		       ~(POWER_LCD|POWER_LIGHT)) | POWER_MQ);
+    
+    a0 = KdMapDevice (MEDIAQ_BASE, 512 * 1024);
+    if (!a0)
+	return FALSE;
+    map->sync = a0;
+    map->reg = a0 + 256 * 1024;
+    map->async = (char *) map->reg;
+    printf ("base 0x%x: config_0 0x%x config_3 0x%x config_4 0x%x\n",
+	    MEDIAQ_BASE,
+	    map->reg->DC.s.config_0,
+	    map->reg->DC.s.config_3,
+	    map->reg->DC.s.config_4);
+#else
+    KdCardAttr	a;
+    
     if (!LinuxFindPci (0x4d51, 0x0120, 0, &a))
     {
 	fprintf (stderr, "No MediaQ device present\n");
@@ -184,6 +249,7 @@
     map->reg = a0;
     map->sync = a1;
     map->async = map->sync + 256 * 1024;
+#endif
     return TRUE;
 }
 
@@ -299,39 +365,89 @@
 }
 
 void
-DumpRegs (char *name, volatile mq32  *bits, int count)
+DumpRegs (char *name, char *base, volatile mq32  *bits, int count)
 {
     int	i;
     
     printf ("%s registers:\n", name);
     for (i = 0; i < count; i++)
-	printf ("\t%s%02x: %08x\n", name, i, bits[i]);
+	printf ("\t%s%02x: %08x %08x\n", name, i, 
+		(char *) &bits[i] - base, bits[i]);
 }
 
 void
 DumpMq (MqMap *mq)
 {
-    DumpRegs ("dc", mq->reg->DC.a, count (mq->reg->DC.a));
-    DumpRegs ("cc", mq->reg->CC.a, count (mq->reg->CC.a));
-    DumpRegs ("mm", mq->reg->MIU.a, count (mq->reg->MIU.a));
-    DumpRegs ("gc", mq->reg->GC.a, count (mq->reg->GC.a));
-    DumpRegs ("fp", mq->reg->FP.a, count (mq->reg->FP.a));
-    DumpRegs ("ge", mq->reg->GE.a, count (mq->reg->GE.a));
+    DumpRegs ("dc", (char *) mq->reg, mq->reg->DC.a, count (mq->reg->DC.a));
+    DumpRegs ("cc", (char *) mq->reg, mq->reg->CC.a, count (mq->reg->CC.a));
+    DumpRegs ("mm", (char *) mq->reg, mq->reg->MIU.a, count (mq->reg->MIU.a));
+    DumpRegs ("gc", (char *) mq->reg, mq->reg->GC.a, count (mq->reg->GC.a));
+    DumpRegs ("fp", (char *) mq->reg, mq->reg->FP.a, count (mq->reg->FP.a));
+    DumpRegs ("ge", (char *) mq->reg, mq->reg->GE.a, count (mq->reg->GE.a));
+}
+
+char *mqVisualName[] = { "Gray", "Pseudo", "True" };
+
+int
+MqRotate(mq16 orient)
+{
+    switch (orient & 0xf) {
+    case MQ_Rotate_0:	return 0;
+    case MQ_Rotate_90:	return 90;
+    case MQ_Rotate_180:	return 180;
+    case MQ_Rotate_270:	return 270;
+    default:		return -1;
+    }
+}
+
+char *
+MqReflect (mq16 orient)
+{
+    switch (orient & (MQ_Reflect_X|MQ_Reflect_Y)) {
+    case 0: return "none";
+    case MQ_Reflect_X: return "X";
+    case MQ_Reflect_Y: return "Y";
+    case MQ_Reflect_Y|MQ_Reflect_X: return "X, Y";
+    default: return "???";
+    }
+}
+
+void
+DumpFormat (MqFormat *mf)
+{
+    printf ("width: %4d height %4d\n", mf->width, mf->height);
+    printf ("bpp: %3d visual: %s\n", mf->bpp, mqVisualName[mf->visual]);
+    printf ("stride: %4d rotate: %3d reflect: %s\n",
+	    mf->stride, MqRotate(mf->orient), MqReflect (mf->orient));
+    printf ("width_mm: %4d height_mm %4d\n", mf->width_mm, mf->height_mm);
 }
 
 main ()
 {
     MqMap	map;
+    MqFormat	mf;
 
+    MqDataToFormat (MEDIAQ_INIT, &mf, 3937);
+    DumpFormat (&mf);
     if (!MqMapDevice (&map))
 	exit (1);
+#ifndef __arm__
     printf ("Found PCI vendor 0x%x/0x%x\n", 
 	    map.reg->PCI.s.vendor_id,
 	    map.reg->PCI.s.device_id);
+#endif
+    DumpRegs ("dc", (char *) map.reg, map.reg->DC.a, count (map.reg->DC.a));
+    map.reg->DC.s.config_1 = MQ_CONFIG_18_OSCILLATOR_INTERNAL;
     map.reg->DC.s.config_2 = MQ_CONFIG_CC_MODULE_ENABLE;
-/*    DumpMq (&map); */
-    MqInit (&map);
-/*     DumpMq (&map); */
+    DumpRegs ("dc", (char *) map.reg, map.reg->DC.a, count (map.reg->DC.a));
+    DumpMq (&map);
+    MqInit (&map, MEDIAQ_INIT);
+    DumpMq (&map);
+    MqPowerGC (&map, MqTrue);
+    poke (GPIOB_DATA, (peek (GPIOB_DATA) | POWER_LCD) | POWER_MQ | POWER_LIGHT);
+    sleep (1);
+    MqPowerGC (&map, MqFalse);
+    poke (GPIOB_DATA, (peek (GPIOB_DATA) &~(POWER_LCD|POWER_MQ|POWER_LIGHT)));
     MqUnmapDevice (&map);
     exit (0);
 }

Index: mq1100.h
===================================================================
RCS file: /local/src/CVS/mq1100/mq1100.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mq1100.h	10 May 2003 02:26:19 -0000	1.2
+++ mq1100.h	19 May 2003 18:15:39 -0000	1.3
@@ -25,6 +25,11 @@
 #ifndef _MQ1100_H_
 #define _MQ1100_H_
 
+#ifndef MQ1100FB_DEBUG
+#define MQ1100FB_DEBUG 1
+#endif
+
+#ifdef __KERNEL__
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -40,10 +45,6 @@
 #include <video/fbcon.h>
 #include <video/fbcon-cfb16.h>
 
-#ifndef MQ1100FB_DEBUG
-#define MQ1100FB_DEBUG 1
-#endif
-
 #if MQ1100FB_DEBUG
 #define debug(f,a...)	printk("%s:" f,  __FUNCTION__ , ## a)
 #else
@@ -51,10 +52,16 @@
 #endif
 
 #define output(f, a...) printk("mq1100fb: " f, ## a)
+#else
+
+#define debug(f,a...)	printf("%s:" f, __FUNCTION__, ## a)
+#define output(f, a...) printf(f, ##a)
+#endif
 
 typedef unsigned char	mq8;
 typedef unsigned short	mq16;
 typedef unsigned int	mq32;
+typedef short		mqs16;
 
 #define count(t)    ((sizeof (t) / sizeof (t[0])))
 		     
@@ -78,7 +85,7 @@
 	    mq32    gpio_control_1;
 	    mq32    cpu_test_mode;
 	} s;
-	mq32	a[3];
+	mq32	a[6];
 	mq8	size[128];
     } CC;
     /*
@@ -135,7 +142,7 @@
 #define MQ_MIU_I2S_TRANSMIT_THRESHOLD_(v)    			    ((v) << 26)
 	    mq32	miu_test_control;
 	} s;
-	mq32	a[2];
+	mq32	a[6];
 	mq8	size[128];
     } MIU;
     /* 
@@ -327,7 +334,7 @@
 	    mq32    window_line_start_address;
 	    mq32    cursor_line_start_address;
 	} s;
-	mq32	a[0x1b];
+	mq32	a[0x20];
 	mq8	size[128];
     } GC;
     /*
@@ -576,7 +583,7 @@
 	    mq32    frc_weight_d8;
 	    mq32    frc_weight_dc;
 	} s;
-	mq32	a[0x38];
+	mq32	a[0x80];
 	mq8	size[512];
     } FP;
     /*
@@ -611,10 +618,10 @@
  */
 typedef struct _MqInitData {
     mq32    dc[0x6];
-    mq32    cc[0x3];
-    mq32    miu[0x2];
+    mq32    cc[0x6];
+    mq32    miu[0x6];
     mq32    gc[0x1b];
-    mq32    fp[0x38];
+    mq32    fp[0x80];
     mq32    ge[0xc];
 } MqInitData;
 
@@ -624,21 +631,6 @@
     volatile unsigned char  *async;	/* 256K not synchronized to GPU */
 } MqMap;
 
-typedef struct _mqSync {
-    int		total;
-    int		width;
-    int		sync_start;
-    int		sync_end;
-    int		blank;
-    int		display_end;
-} MqSync;
-
-typedef struct _mqTiming {
-    char	*name;
-    int		pixel_clock;
-    MqSync	v, h;
-} MqTiming;
-
 typedef int	MqBool;
 
 #define MqTrue	1
@@ -647,10 +639,42 @@
 extern MqInitData   mqInitSharp;
 extern MqInitData   mqInitH5400;
 
+typedef struct _MqBits {
+    mq16    width;
+    mq16    offset;
+} MqBits;
+
+typedef enum _MqVisual {
+    MqVisualGray, MqVisualPseudo, MqVisualTrue
+} MqVisual;
+
+#define MQ_Rotate_0	1
+#define MQ_Rotate_90	2
+#define MQ_Rotate_180	4
+#define MQ_Rotate_270	8
+
+#define MQ_Reflect_X	16
+#define MQ_Reflect_Y	32
+
+typedef struct _MqFormat {
+    mq16	width, height;
+    MqVisual	visual;
+    mq16	bpp;
+    mq16	stride;
+    mq16	orient;
+    mq16	width_mm, height_mm;
+} MqFormat;
+
 MqBool
 MqPowerGC (MqMap *mq, MqBool on);
 
 MqBool
 MqInit (MqMap *mq, MqInitData *md);
+
+MqBool
+MqDataToFormat (MqInitData *md, MqFormat *mf, mq16 ppm);
+
+MqBool
+MqReorientData (MqInitData *src, MqInitData *dst, mq16 orient);
 
 #endif /* _MQ1100_H_ */

Index: mqinit.c
===================================================================
RCS file: /local/src/CVS/mq1100/mqinit.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mqinit.c	10 May 2003 02:26:19 -0000	1.2
+++ mqinit.c	19 May 2003 18:15:39 -0000	1.3
@@ -28,6 +28,14 @@
 
 #define MQ_INIT_SET		0x1
 
+#ifdef __arm__
+#define MQ_INIT_PCI		0x0
+#define MQ_INIT_ARM		MQ_INIT_SET
+#else
+#define MQ_INIT_PCI		MQ_INIT_SET
+#define MQ_INIT_ARM		0x0
+#endif
+
 MqInitData  mqInitValid = {
     /* DC */
     {
@@ -43,11 +51,18 @@
 	/* cc00 */		MQ_INIT_SET,
 	/* cc01 */		MQ_INIT_SET,
 	/* cc02 */		MQ_INIT_SET,
+	/* cc03 */		MQ_INIT_SET,
+	/* cc04 */		MQ_INIT_SET,
+	/* cc05 */		MQ_INIT_SET,
     },
     /* MIU */
     {
 	/* mm00 */		MQ_INIT_SET,
 	/* mm01 */		MQ_INIT_SET,
+	/* mm02 */		MQ_INIT_SET,
+	/* mm03 */		MQ_INIT_SET,
+	/* mm04 */		MQ_INIT_SET,
+	/* mm05 */		MQ_INIT_SET,
     },
     /* GC */
     {
@@ -67,16 +82,16 @@
 	/* gc0d */		MQ_INIT_SET,
 	/* gc0e */		MQ_INIT_SET,
 	/* gc0f NOT SET */	0x0,
-	/* gc10 NOT SET */	0x0,
-	/* gc11 NOT SET */	0x0,
+	/* gc10 */		MQ_INIT_SET,
+	/* gc11 */		MQ_INIT_SET,
 	/* gc12 NOT SET */	0x0,
 	/* gc13 NOT SET */	0x0,
-	/* gc14 NOT SET */	0x0,
-	/* gc15 NOT SET */	0x0,
-	/* gc16 NOT SET */	0x0,
-	/* gc17 NOT SET */	0x0,
-	/* gc18 NOT SET */	0x0,
-	/* gc19 NOT SET */	0x0,
+	/* gc14 */		MQ_INIT_SET,
+	/* gc15 */		MQ_INIT_SET,
+	/* gc16 */		MQ_INIT_SET,
+	/* gc17 */		MQ_INIT_SET,
+	/* gc18 */		MQ_INIT_SET,
+	/* gc19 */		MQ_INIT_SET,
 	/* gc1a */		MQ_INIT_SET,
     },
     /* FP */
@@ -113,22 +128,22 @@
 	/* fp1d */		MQ_INIT_SET,
 	/* fp1e */		MQ_INIT_SET,
 	/* fp1f */		MQ_INIT_SET,
-	/* fp20 */		MQ_INIT_SET,
-	/* fp21 */		MQ_INIT_SET,
-	/* fp22 */		MQ_INIT_SET,
-	/* fp23 */		MQ_INIT_SET,
-	/* fp24 */		MQ_INIT_SET,
-	/* fp25 */		MQ_INIT_SET,
-	/* fp26 */		MQ_INIT_SET,
-	/* fp27 */		MQ_INIT_SET,
-	/* fp28 */		MQ_INIT_SET,
-	/* fp29 */		MQ_INIT_SET,
-	/* fp2a */		MQ_INIT_SET,
-	/* fp2b */		MQ_INIT_SET,
-	/* fp2c */		MQ_INIT_SET,
-	/* fp2d */		MQ_INIT_SET,
-	/* fp2e */		MQ_INIT_SET,
-	/* fp2f */		MQ_INIT_SET,
+	/* fp20 */		MQ_INIT_PCI,
+	/* fp21 */		MQ_INIT_PCI,
+	/* fp22 */		MQ_INIT_PCI,
+	/* fp23 */		MQ_INIT_PCI,
+	/* fp24 */		MQ_INIT_PCI,
+	/* fp25 */		MQ_INIT_PCI,
+	/* fp26 */		MQ_INIT_PCI,
+	/* fp27 */		MQ_INIT_PCI,
+	/* fp28 */		MQ_INIT_PCI,
+	/* fp29 */		MQ_INIT_PCI,
+	/* fp2a */		MQ_INIT_PCI,
+	/* fp2b */		MQ_INIT_PCI,
+	/* fp2c */		MQ_INIT_PCI,
+	/* fp2d */		MQ_INIT_PCI,
+	/* fp2e */		MQ_INIT_PCI,
+	/* fp2f */		MQ_INIT_PCI,
 	/* fp30 */		MQ_INIT_SET,
 	/* fp31 */		MQ_INIT_SET,
 	/* fp32 */		MQ_INIT_SET,
@@ -137,6 +152,70 @@
 	/* fp35 */		MQ_INIT_SET,
 	/* fp36 */		MQ_INIT_SET,
 	/* fp37 */		MQ_INIT_SET,
+	/* fp38 */		MQ_INIT_ARM,
+	/* fp39 */		MQ_INIT_ARM,
+	/* fp3a */		MQ_INIT_ARM,
+	/* fp3b */		MQ_INIT_ARM,
+	/* fp3c */		MQ_INIT_ARM,
+	/* fp3d */		MQ_INIT_ARM,
+	/* fp3e */		MQ_INIT_ARM,
+	/* fp3f */		MQ_INIT_ARM,
+	/* fp40 */		0x0,
+	/* fp41 */		0x0,
+	/* fp42 */		0x0,
+	/* fp43 */		0x0,
+	/* fp44 */		0x0,
+	/* fp45 */		0x0,
+	/* fp46 */		0x0,
+	/* fp47 */		0x0,
+	/* fp48 */		0x0,
+	/* fp49 */		0x0,
+	/* fp4a */		0x0,
+	/* fp4b */		0x0,
+	/* fp4c */		0x0,
+	/* fp4d */		0x0,
+	/* fp4e */		0x0,
+	/* fp4f */		0x0,
+	/* fp50 */		0x0,
+	/* fp51 */		0x0,
+	/* fp52 */		0x0,
+	/* fp53 */		0x0,
+	/* fp54 */		0x0,
+	/* fp55 */		0x0,
+	/* fp56 */		0x0,
+	/* fp57 */		0x0,
+	/* fp58 */		0x0,
+	/* fp59 */		0x0,
+	/* fp5a */		0x0,
+	/* fp5b */		0x0,
+	/* fp5c */		0x0,
+	/* fp5d */		0x0,
+	/* fp5e */		0x0,
+	/* fp5f */		0x0,
+	/* fp60 */		0x0,
+	/* fp61 */		0x0,
+	/* fp62 */		0x0,
+	/* fp63 */		0x0,
+	/* fp64 */		0x0,
+	/* fp65 */		0x0,
+	/* fp66 */		0x0,
+	/* fp67 */		0x0,
+	/* fp68 */		0x0,
+	/* fp69 */		0x0,
+	/* fp6a */		0x0,
+	/* fp6b */		0x0,
+	/* fp6c */		0x0,
+	/* fp6d */		0x0,
+	/* fp6e */		0x0,
+	/* fp6f */		0x0,
+	/* fp70 */		MQ_INIT_ARM,
+	/* fp71 */		MQ_INIT_ARM,
+	/* fp72 */		MQ_INIT_ARM,
+	/* fp73 */		MQ_INIT_ARM,
+	/* fp74 */		MQ_INIT_ARM,
+	/* fp75 */		MQ_INIT_ARM,
+	/* fp76 */		MQ_INIT_ARM,
+	/* fp77 */		MQ_INIT_ARM,
     },
     /* GE */
     {
@@ -170,11 +249,18 @@
 	/* cc00 */		0x00000002,
 	/* cc01 */		0x00001010,
 	/* cc02 */		0x00000aa0,
+	/* cc03 */		0x00000000,
+	/* cc04 */		0x00000000,
+	/* cc05 */		0x00000000,
     },
     /* MIU */
     {
 	/* mm00 */		0x00000001,
 	/* mm01 */		0x1b676ca8,
+	/* mm02 */		0x00000000,
+	/* mm03 */		0x00000000,
+	/* mm04 */		0x00000000,
+	/* mm05 */		0x00000000,
     },
     /* GC */
     {
@@ -194,16 +280,16 @@
 	/* gc0d */		0x0001c408,
 	/* gc0e */		0x00000280,
 	/* gc0f NOT SET */	0x0,
-	/* gc10 NOT SET */	0x0,
-	/* gc11 NOT SET */	0x0,
+	/* gc10 */		0x02ff07ff,
+	/* gc11 */		0x000000ff,
 	/* gc12 NOT SET */	0x0,
 	/* gc13 NOT SET */	0x0,
-	/* gc14 NOT SET */	0x0,
-	/* gc15 NOT SET */	0x0,
-	/* gc16 NOT SET */	0x0,
-	/* gc17 NOT SET */	0x0,
-	/* gc18 NOT SET */	0x0,
-	/* gc19 NOT SET */	0x0,
+	/* gc14 */		0x00000000,
+	/* gc15 */		0x00000000,
+	/* gc16 */		0x00000000,
+	/* gc17 */		0x00000000,
+	/* gc18 */		0x00000000,
+	/* gc19 */		0x00000000,
 	/* gc1a */		0x00000000,
     },
     /* FP */
@@ -297,11 +383,18 @@
 	/* cc00 */		0x00000000,
 	/* cc01 */		0x00001010,
 	/* cc02 */		0x00000a22,
+	/* cc03 */		0x00000000,
+	/* cc04 */		0x00000004,
+	/* cc05 */		0x00000000,
     },
     /* MIU */
     {
 	/* mm00 */		0x00000001,
 	/* mm01 */		0x1b676ca8,
+	/* mm02 */		0x00000000,
+	/* mm03 */		0x00001479,
+	/* mm04 */		0x6bfc2d76,
+	/* mm05 */		0x00000001,
     },
     /* GC */
     {
@@ -321,16 +414,16 @@
 	/* gc0d */		0x00066373,
 	/* gc0e */		0x000001e0,
 	/* gc0f NOT SET */	0x0,
-	/* gc10 NOT SET */	0x0,
-	/* gc11 NOT SET */	0x0,
+	/* gc10 */		0x02ff07ff,
+	/* gc11 */		0x000000ff,
 	/* gc12 NOT SET */	0x0,
 	/* gc13 NOT SET */	0x0,
-	/* gc14 NOT SET */	0x0,
-	/* gc15 NOT SET */	0x0,
-	/* gc16 NOT SET */	0x0,
-	/* gc17 NOT SET */	0x0,
-	/* gc18 NOT SET */	0x0,
-	/* gc19 NOT SET */	0x0,
+	/* gc14 */		0x00000000,
+	/* gc15 */		0x00000000,
+	/* gc16 */		0x00000000,
+	/* gc17 */		0x00000000,
+	/* gc18 */		0x00000000,
+	/* gc19 */		0x00000000,
 	/* gc1a */		0x00000000,
     },
     /* FP */
@@ -367,22 +460,23 @@
 	/* fp1d */		0x3c2d710,
 	/* fp1e */		0xb7f7f7d9,
 	/* fp1f */		0x1894640a,
-	/* fp20 */		0x2765a257,
-	/* fp21 */		0x19fdd8bc,
-	/* fp22 */		0xfffdfcfd,
-	/* fp23 */		0x611785ff,
-	/* fp24 */		0xbdbd2ec5,
-	/* fp25 */		0xff928b26,
-	/* fp26 */		0xe848ee2a,
-	/* fp27 */		0x6b6da937,
-	/* fp28 */		0xf2d64077,
-	/* fp29 */		0xffffffff,
-	/* fp2a */		0x350724f4,
-	/* fp2b */		0x3cef467c,
-	/* fp2c */		0x26e3db53,
-	/* fp2d */		0x3c2d710,
-	/* fp2e */		0xb7f7f7d9,
-	/* fp2f */		0x1894f62a,
+	/* fp20 */		0x0,
+	/* fp21 */		0x0,
+	/* fp22 */		0x0,
+	/* fp23 */		0x0,
+	/* fp24 */		0x0,
+	/* fp25 */		0x0,
+	/* fp26 */		0x0,
+	/* fp27 */		0x0,
+	/* fp28 */		0x0,
+	/* fp29 */		0x0,
+	/* fp2a */		0x0,
+	/* fp2b */		0x0,
+	/* fp2c */		0x0,
+	/* fp2d */		0x0,
+	/* fp2e */		0x0,
+	/* fp2f */		0x0,
+#if 0
 	/* fp30 */		0xfbbbfc5b,
 	/* fp31 */		0xfd6779c3,
 	/* fp32 */		0xdfffb7ba,
@@ -391,6 +485,92 @@
 	/* fp35 */		0x7af04b8d,
 	/* fp36 */		0x7acb011d,
 	/* fp37 */		0xa21ec1e6,
+	/* fp38 */		0xf67fb56a,
+	/* fp39 */		0xe2b5fea9,
+	/* fp3a */		0xc277c3f7,
+	/* fp3b */		0xdb75d79f,
+	/* fp3c */		0x8bffe979,
+	/* fp3d */		0xad2f17ce, /* XXX borrowed */
+	/* fp3e */		0x1f2c4d70, /* XXX borrowed */
+	/* fp3f */		0xe96b538a, /* XXX borrowed */
+#else
+	/* fp30 */		0xe0d3b28f,
+	/* fp31 */		0x1694ac75,
+	/* fp32 */		0xa497f6cb,
+	/* fp33 */		0x52d0e831,
+	/* fp34 */		0x3d0e6f52,
+	/* fp35 */		0xcb4971a8,
+	/* fp36 */		0x794a2b16,
+	/* fp37 */		0x8f0d35ec,
+	/* fp38 */		0x86b5d4e9,
+	/* fp39 */		0x70f2ca13,
+	/* fp3a */		0xc2f190ad,
+	/* fp3b */		0x34b68e57,
+	/* fp3c */		0x5b680934,
+	/* fp3d */		0xad2f17ce,
+	/* fp3e */		0x1f2c4d70,
+	/* fp3f */		0xe96b538a,
+#endif
+	/* fp40 */		0x0,
+	/* fp41 */		0x0,
+	/* fp42 */		0x0,
+	/* fp43 */		0x0,
+	/* fp44 */		0x0,
+	/* fp45 */		0x0,
+	/* fp46 */		0x0,
+	/* fp47 */		0x0,
+	/* fp48 */		0x0,
+	/* fp49 */		0x0,
+	/* fp4a */		0x0,
+	/* fp4b */		0x0,
+	/* fp4c */		0x0,
+	/* fp4d */		0x0,
+	/* fp4e */		0x0,
+	/* fp4f */		0x0,
+	/* fp50 */		0x0,
+	/* fp51 */		0x0,
+	/* fp52 */		0x0,
+	/* fp53 */		0x0,
+	/* fp54 */		0x0,
+	/* fp55 */		0x0,
+	/* fp56 */		0x0,
+	/* fp57 */		0x0,
+	/* fp58 */		0x0,
+	/* fp59 */		0x0,
+	/* fp5a */		0x0,
+	/* fp5b */		0x0,
+	/* fp5c */		0x0,
+	/* fp5d */		0x0,
+	/* fp5e */		0x0,
+	/* fp5f */		0x0,
+	/* fp60 */		0x0,
+	/* fp61 */		0x0,
+	/* fp62 */		0x0,
+	/* fp63 */		0x0,
+	/* fp64 */		0x0,
+	/* fp65 */		0x0,
+	/* fp66 */		0x0,
+	/* fp67 */		0x0,
+	/* fp68 */		0x0,
+	/* fp69 */		0x0,
+	/* fp6a */		0x0,
+	/* fp6b */		0x0,
+	/* fp6c */		0x0,
+	/* fp6d */		0x0,
+	/* fp6e */		0x0,
+	/* fp6f */		0x0,
+	/* 
+	 * experimentally determined.  Don't mess with these, you'll
+	 * just lock up the device
+	 */
+	/* fp70 */		0x00000510,
+	/* fp71 */		0x80800000,
+	/* fp72 */		0x00000001,
+	/* fp73 */		0x00000000,
+	/* fp74 */		0x00000000,
+	/* fp75 */		0x00000000,
+	/* fp76 */		0x88888420,
+	/* fp77 */		0x94a49248,
     },
     /* GE */
     {
@@ -432,10 +612,17 @@
 static MqBool
 MqInitDC (MqMap *mq, MqInitData *md)
 {
-#if 0
     mq32    v;
-#endif
     
+#if 0
+    v = md->dc[1];
+    v |= MQ_CONFIG_SOFTWARE_CHIP_RESET;
+    mq->reg->DC.s.config_1 = v;
+    mq->reg->DC.s.config_2 = 0;
+    usleep (MQ_RESET_DELAY_US);
+    mq->reg->DC.s.config_1 = md->dc[1];
+    mq->reg->DC.s.config_2 = md->dc[2];
+#endif
     MqLoad ("dc", mq->reg->DC.a, md->dc, mqInitValid.dc, count (md->dc));
 
 #if 0
@@ -502,25 +689,53 @@
 	for (x = 0; x < width; x++)
 	{
 	    if (base[y*stride+x])
-		printk ("*");
+		output ("*");
 	    else
-		printk (" ");
+		output (" ");
 	}
-	printk ("\n");
+	output ("\n");
     }
 }
 
 /*
  * Memory Interface Unit (MIU)
  */
+
+static mq16	colors[] = { 
+    0x1000, 0x3000, 0x7000, 0xf000,
+    0x0080, 0x0180, 0x0380, 0x0780,
+    0x0002, 0x0006, 0x000e, 0x001e,
+    0x1082, 0x3186, 0x738e, 0xf79e,
+};
+
+#define BLOCK	32
+
 static MqBool
 MqInitMIU (MqMap *mq, MqInitData *md)
 {
+    mq16    *a;
+    int	    n;
+    int	    r, c;
+    int	    x, y;
+    int	    i = 0;
+    
     if (!MqLoad ("mm", mq->reg->MIU.a, md->miu, mqInitValid.miu, count (md->miu)))
 	return MqFalse;
-    memset ((void*) mq->sync, 0xff, 320 * 240 * 2);
-    MqLine ((mq16*) mq->sync, 321, 0, 200);
-    MqShow ((mq16*) mq->sync, 320, 50, 50);
+    memset ((void*) mq->sync, 0xff, 256 * 1024);
+#if 1
+    a = (mq16 *) mq->sync;
+    for (r = 0; r < 320 / BLOCK; r ++)
+	for (c = 0; c < 240 / BLOCK; c++)
+	{
+	    for (y = 0; y < BLOCK; y++)
+		for (x = 0; x < BLOCK; x++)
+		    a[(r * BLOCK + y) * 240 + (c * BLOCK + x)] = colors[i];
+	    i++;
+	    if (i == count(colors))
+		i = 0;
+	}
+#endif
+    MqLine (a, 241, 0xffff, 120);
     return MqTrue;
 }
 
@@ -582,9 +797,96 @@
 	return MqFalse;
     if (!MqInitGE (mq, md))
 	return MqFalse;
-#if 0
-    if (!MqPowerGC (mq, md))
-	return MqFalse;
-#endif
     return MqTrue;
+}
+
+MqBool
+MqDataToFormat (MqInitData *md, MqFormat *mf, mq16 ppm)
+{
+    mq32    control = md->gc[0];
+    mq32    horizontal_display = md->gc[2];
+    mq32    vertical_display = md->gc[3];
+    mq32    window_stride = md->gc[0xe];
+    mqs16   stride;
+    
+    switch (control & MQ_GC_DEPTH) {
+    case MQ_GC_DEPTH_PSEUDO_1:
+	mf->bpp = 1;
+	mf->visual = MqVisualPseudo;
+	break;
+    case MQ_GC_DEPTH_PSEUDO_2:
+	mf->bpp = 2;
+	mf->visual = MqVisualPseudo;
+	break;
+    case MQ_GC_DEPTH_PSEUDO_4:
+	mf->bpp = 4;
+	mf->visual = MqVisualPseudo;
+	break;
+    case MQ_GC_DEPTH_PSEUDO_8:
+	mf->bpp = 8;
+	mf->visual = MqVisualPseudo;
+	break;
+    case MQ_GC_DEPTH_GRAY_1:
+	mf->bpp = 1;
+	mf->visual = MqVisualGray;
+	break;
+    case MQ_GC_DEPTH_GRAY_2:
+	mf->bpp = 2;
+	mf->visual = MqVisualGray;
+	break;
+    case MQ_GC_DEPTH_GRAY_4:
+	mf->bpp = 4;
+	mf->visual = MqVisualGray;
+	break;
+    case MQ_GC_DEPTH_GRAY_8:
+	mf->bpp = 8;
+	mf->visual = MqVisualGray;
+	break;
+    case MQ_GC_DEPTH_TRUE_16:
+	mf->bpp = 16;
+	mf->visual = MqVisualTrue;
+	break;
+    }
+    mf->width = (horizontal_display & MQ_GC_HORIZONTAL_DISPLAY_END) >> 16;
+    mf->height = ((vertical_display & MQ_GC_VERTICAL_DISPLAY_END) >> 16) + 1;
+    stride = (mqs16) window_stride;
+    if (stride < 0)
+	mf->stride = -stride;
+    else
+	mf->stride = stride;
+    switch (control & (MQ_GC_X_SCANNING_DIRECTION|MQ_GC_LINE_SCANNING_DIRECTION)) {
+    case 0:
+	if (stride >= 0)
+	    mf->orient = MQ_Rotate_0;				    /* 000 */
+	else	    
+	    mf->orient |= MQ_Rotate_0 | MQ_Reflect_Y;		    /* 010 */
+	break;
+    case MQ_GC_X_SCANNING_DIRECTION:
+	if (stride >= 0)
+	    mf->orient = MQ_Rotate_0 | MQ_Reflect_X;		    /* 001 */
+	else
+	    mf->orient = MQ_Rotate_180;				    /* 011 */
+	break;
+    case MQ_GC_LINE_SCANNING_DIRECTION:
+	if (stride >= 0)
+	    mf->orient = MQ_Rotate_90 | MQ_Reflect_X;		    /* 100 */
+	else
+	    mf->orient = MQ_Rotate_90;				    /* 110 */
+	break;
+    case MQ_GC_LINE_SCANNING_DIRECTION|MQ_GC_X_SCANNING_DIRECTION:
+	if (stride >= 0)
+	    mf->orient = MQ_Rotate_270;				    /* 101 */
+	else
+	    mf->orient = MQ_Rotate_270 | MQ_Reflect_X;		    /* 111 */
+	break;
+    }
+    mf->width_mm = mf->width * 1000 / ppm;
+    mf->height_mm = mf->height * 1000 / ppm;
+    return MqTrue;
+}
+
+MqBool
+MqReorientData (MqInitData *src, MqInitData *dst, mq16 orient)
+{
+    return MqFalse;
 }