graphics: fill out how MAP might work
authorAlan Cox <alan@linux.intel.com>
Tue, 31 Mar 2015 23:00:50 +0000 (00:00 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 31 Mar 2015 23:00:50 +0000 (00:00 +0100)
Kernel/include/graphics.h
Kernel/platform-trs80/devgfx.c

index 256a9bc..b3d26e8 100644 (file)
@@ -18,6 +18,7 @@ struct display {
 #define HW_UNACCEL     1       /* Simple display */
 #define HW_VDP_9918    128     /* Not neccessarily MSX... */
 #define HW_VDP_9938    129
+#define HW_TRS80GFX    130     /* TRS80 model 4 graphics board */
   uint16_t features;
 #define GFX_MAPPABLE   1       /* Can map into process memory */
 #define GFX_PALETTE    2       /* Has colour palette */
@@ -63,6 +64,26 @@ struct attribute {
   uint8_t flags;
 };
 
+/* Returned from a successful GFXIOC_MAP */
+struct videomap {
+  uaddr_t mmio;                        /* Memory mapped register base */
+  uaddr_t pio;                 /* I/O space register base */
+  uaddr_t fbmem;               /* Frame buffer memory */
+  usize_t fbsize;
+  uint8_t mmio_seg;            /* For the 8086 */
+  uint8_t fbmem_seg;
+  uint8_t spacing;             /* Multiplier for non standard register spacing */
+  uint8_t flags;               /* Which maps are valid */
+#define MAP_MMIO       1
+#define MAP_MMIO_SEG   2
+#define MAP_PIO                4
+#define MAP_FBMEM      8
+#define MAP_FBMEM_SEG  16
+#define MAP_FBMEM_SIMPLE 32    /* Normal mapping of linear framebuffer as
+                                  mode would imply */
+};
+
+
 #define GFX_BUFLEN             64      /* Default buffer length  (128 byte) */
 
 #define GFXIOC_GETINFO         0x0300  /* Query display info for this tty */
index b8ba5be..6cb385b 100644 (file)
 #include <graphics.h>
 #include <devgfx.h>
 
-static struct display trsdisplay = {
+static const struct display trsdisplay = {
   640, 240,
   1024, 256,
   1, 1,                /* Need adding to ioctls */
   FMT_MONO_BW,
-  HW_UNACCEL,
-  GFX_ENABLE,
+  HW_TRS80GFX,
+  GFX_ENABLE|GFX_MAPPABLE|GFX_OFFSCREEN,
   32,
   GFX_SETPIXEL,
   0
 };
 
+/* Assumes a Tandy board */
+static const struct videomap trsmap = {
+  0,
+  0x80,        /* I/O ports.. 80-83 + 8C-8E */
+  0, 0,                /* Not mapped into main memory */
+  0, 0,        /* No segmentation */
+  1,           /* Standard spacing */
+  MAP_PIO
+};
+
 uint16_t video_op[GFX_BUFLEN];
 
 __sfr __at 0x83 gfx_ctrl;
@@ -40,8 +50,13 @@ int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
     gfx_ctrl = 3;      /* we might want 1 for special cases */
     return 0;
   case GFXIOC_DISABLE:
-    gfx_ctrl = 0;      /* we might want 1 for special cases */
+    gfx_ctrl = 0;
+  case GFXIOC_UNMAP:
     return 0;
+  /* Users can "map" 8) the I/O ports into their process and use the
+     card directly */
+  case GFXIOC_MAP:
+    return uput(&trsmap, ptr, sizeof(trsmap));
   case GFXIOC_SETATTR:
     return uget(&video_attr, ptr, sizeof(video_attr));
   case GFXIOC_SETPIXEL: