#define GFX_PALETTE 2 /* Has colour palette */
#define GFX_OFFSCREEN 4 /* Offscreen memory */
#define GFX_VBLANK 8
-#define GFX_ENABLE 16 /* Separate mode we enable/disable */
#define GFX_MULTIMODE 32 /* Has multiple modes */
#define GFX_PALETTE_SET 64 /* Has settable colour palette */
#define GFX_TEXT 128 /* Console text works in this mode */
};
#define GFXIOC_GETINFO 0x0300 /* Query display info for this tty */
-#define GFXIOC_ENABLE 0x0301 /* Enter graphics mode */
-#define GFXIOC_DISABLE 0x0302 /* Exit graphics mode */
#define GFXIOC_GETPALETTE 0x0303 /* Get a palette entry */
#define GFXIOC_SETPALETTE 0x0304 /* Set a palette entry */
#define GFXIOC_MAP 0x0305 /* Map into process if supported */
#include <graphics.h>
#include <devgfx.h>
-static const struct display trsdisplay = {
- 0,
- 640, 240,
- 1024, 256,
- 1, 1, /* Need adding to ioctls */
- FMT_MONO_BW,
- HW_TRS80GFX,
- GFX_ENABLE|GFX_MAPPABLE|GFX_OFFSCREEN, /* Can in theory do pans */
- 32,
- GFX_DRAW|GFX_READ|GFX_WRITE
+static const struct display trsdisplay[2] = {
+ {
+ /* Once we get around to it this is probably best described as
+ 160 x 72 sixel */
+ 0,
+ 80, 24,
+ 80, 24,
+ 255, 255,
+ FMT_TEXT,
+ HW_UNACCEL,
+ 0,
+ 2,
+ 0
+ },
+ {
+ 1,
+ 640, 240,
+ 1024, 256,
+ 1, 1, /* Need adding to ioctls */
+ FMT_MONO_BW,
+ HW_TRS80GFX,
+ GFX_MAPPABLE|GFX_OFFSCREEN, /* Can in theory do pans */
+ 32,
+ GFX_DRAW|GFX_READ|GFX_WRITE
+ }
};
/* Assumes a Tandy board */
__sfr __at 0x83 gfx_ctrl;
+static uint8_t vmode;
+
static int gfx_draw_op(uarg_t arg, char *ptr, uint8_t *buf)
{
int l;
int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr)
{
uint8_t *tmp;
+ uint8_t m;
int err;
if (arg >> 8 != 0x03)
switch(arg) {
case GFXIOC_GETINFO:
- return uput(&trsdisplay, ptr, sizeof(trsdisplay));
- case GFXIOC_ENABLE:
- gfx_ctrl = 3; /* we might want 1 for special cases */
+ return uput(&trsdisplay[vmode], ptr, sizeof(struct display));
+ case GFXIOC_GETMODE:
+ case GFXIOC_SETMODE:
+ m = ugetc(ptr);
+ if (m > 1)
+ break;
+ if (arg == GFXIOC_GETMODE)
+ return uput(&trsdisplay[m], ptr, sizeof(struct display));
+ vmode = m;
+ gfx_ctrl = m ? 3 : 0; /* we might want 1 for special cases */
return 0;
- case GFXIOC_DISABLE:
- 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:
+ if (vmode == 0)
+ break;
return uput(&trsmap, ptr, sizeof(trsmap));
case GFXIOC_DRAW:
case GFXIOC_READ:
case GFXIOC_WRITE:
- tmp = (uint8_t *)tmpbuf();
- err = gfx_draw_op(arg, ptr, tmp);
- brelse((bufptr) tmp);
- if (err) {
- udata.u_error = err;
- err = -1;
+ if (vmode == 1) {
+ tmp = (uint8_t *)tmpbuf();
+ err = gfx_draw_op(arg, ptr, tmp);
+ brelse((bufptr) tmp);
+ if (err) {
+ udata.u_error = err;
+ err = -1;
+ }
+ return err;
}
- return err;
- default:
- udata.u_error = EINVAL;
- return -1;
+ /* Fall through */
}
+ udata.u_error = EINVAL;
+ return -1;
}
#define GFX_PALETTE 2 /* Has colour palette */
#define GFX_OFFSCREEN 4 /* Offscreen memory */
#define GFX_VBLANK 8
-#define GFX_ENABLE 16 /* Separate mode we enable/disable */
#define GFX_MULTIMODE 32 /* Has multiple modes */
#define GFX_PALETTE_SET 64 /* Has settable colour palette */
#define GFX_TEXT 128 /* Console text works in this mode */
};
#define GFXIOC_GETINFO 0x0300 /* Query display info for this tty */
-#define GFXIOC_ENABLE 0x0301 /* Enter graphics mode */
-#define GFXIOC_DISABLE 0x0302 /* Exit graphics mode */
#define GFXIOC_GETPALETTE 0x0303 /* Get a palette entry */
#define GFXIOC_SETPALETTE 0x0304 /* Set a palette entry */
#define GFXIOC_MAP 0x0305 /* Map into process if supported */