Home | History | Annotate | Line # | Download | only in dev
grf_cc.c revision 1.7
      1 #include "grf.h"
      2 #if NGRF > 0
      3 
      4 /* Graphics routines for the AMIGA native custom chip set. */
      5 
      6 /* NOTE: this is now only a more or less rough interface to Chris Hopps'
      7          view driver. Due to some design problems with RTG view can't
      8 	 currently replace grf, but that's an option for the future. */
      9 
     10 #include "param.h"
     11 #include "vm/vm_param.h"
     12 #include "sys/errno.h"
     13 #include "ioctl.h"
     14 #include "grfioctl.h"
     15 #include "grfvar.h"
     16 #include "grf_ccreg.h"
     17 #include "../include/cpu.h"
     18 #include "../amiga/custom.h"
     19 #include "../amiga/cia.h"
     20 #include "../amiga/cc_types.h"
     21 #include "grf/grf_types.h"
     22 #include "grf/grf_bitmap.h"
     23 #include "viewioctl.h"
     24 
     25 /* Initialize hardware.
     26  * Must point g_display at a grfinfo structure describing the hardware.
     27  * Returns 0 if hardware not present, non-zero ow.
     28  */
     29 cc_init(gp, ad)
     30 	struct grf_softc *gp;
     31 	struct amiga_device *ad;
     32 {
     33   bmap_t bm;
     34   struct grfinfo *gi = &gp->g_display;
     35   int rc;
     36   long start, off;
     37   struct view_size vs;
     38 
     39   /* already initialized fail */
     40   if (gp->g_data == (caddr_t) 12345678)
     41     return 0;
     42 
     43   rc = grfcc_probe ();
     44   if (! rc)
     45     return 0;
     46 
     47   viewprobe ();
     48 
     49   /* now it gets REALLY nasty.. view[0] stays open for all time
     50      now.. */
     51   if (viewopen (0, 0))
     52     return 0;
     53 
     54   /* XXX 0 may need to change when virtual added */
     55   XXX_grf_cc_on (0);
     56 
     57   return(1);
     58 }
     59 
     60 cc_config(gp, di)
     61 	register struct grf_softc *gp;
     62 	struct grfdyninfo *di;
     63 {
     64   struct grfinfo *gi = &gp->g_display;
     65 
     66   /* bottom missing... */
     67 
     68 }
     69 
     70 extern struct grf_softc grf_softc[];
     71 #define GPUNIT(ip) (((u_long)ip-(u_long)grf_softc)/sizeof(struct grf_softc))
     72 
     73 /*
     74  * Change the mode of the display.
     75  * Right now all we can do is grfon/grfoff.
     76  * Return a UNIX error number or 0 for success.
     77  */
     78 cc_mode(gp, cmd, arg)
     79 	register struct grf_softc *gp;
     80 	int cmd;
     81 	void *arg;
     82 {
     83   switch (cmd)
     84     {
     85     case GM_GRFON:
     86       XXX_grf_cc_on (GPUNIT (gp));
     87       return 0;
     88 
     89     case GM_GRFOFF:
     90       XXX_grf_cc_off (GPUNIT (gp));
     91       return 0;
     92 
     93     case GM_GRFCONFIG:
     94       return cc_config (gp, (struct grfdyninfo *) arg);
     95 
     96     default:
     97       break;
     98     }
     99 
    100   return EINVAL;
    101 }
    102 
    103 
    104 /* nasty nasty hack. right now grf's unit == ite's unit == view's unit. */
    105 /* to make X work (I guess) we need to update the grf structure's HW */
    106 /* address to the current view (as this may change without grf knowing.) */
    107 /* Thanks to M Hitch. for finding this one. */
    108 XXX_grf_cc_on (unit)
    109     int unit;
    110 {
    111   struct grf_softc *gp = &grf_softc[unit];
    112   struct grfinfo *gi = &gp->g_display;
    113   bmap_t bm;
    114   struct view_size vs;
    115 
    116   viewioctl (unit, VIEW_GETBITMAP, &bm, 0, -1);
    117 
    118   gp->g_data = (caddr_t) 12345678; /* not particularly clean.. */
    119 
    120   gi->gd_regaddr = (caddr_t) 0xdff000;		/* no need to look at regs */
    121   gi->gd_regsize = round_page(sizeof (custom));	/* I mean it X people, for CC */
    122 					/* use the view device. That way */
    123 					/* we can have both X and a console. */
    124 					/* and flip between them.  People */
    125 					/* will be unhappy if this feature */
    126 					/* is so easy and yet not availble. */
    127 					/* (if you wern't using them then */
    128 					/* thanks.) */
    129 					/**** I will remove these soon.****/
    130   gi->gd_fbaddr  = bm.hardware_address;
    131   gi->gd_fbsize  = bm.depth*bm.bytes_per_row*bm.rows;
    132 
    133   if (viewioctl (unit, VIEW_GETSIZE, &vs, 0, -1))
    134     {
    135       /* fill in some default values... XXX */
    136       vs.width = 640; vs.height = 400; vs.depth = 2;
    137     }
    138 
    139   gi->gd_colors = 1 << vs.depth;
    140   gi->gd_planes = vs.depth;
    141 
    142   gi->gd_fbwidth  = vs.width;
    143   gi->gd_fbheight = vs.height;
    144   gi->gd_fbx	  = 0;
    145   gi->gd_fby	  = 0;
    146   gi->gd_dwidth   = vs.width;
    147   gi->gd_dheight  = vs.height;
    148   gi->gd_dx	  = 0;
    149   gi->gd_dy	  = 0;
    150 
    151   gp->g_regkva = 0;	/* builtin */
    152   gp->g_fbkva  = 0;	/* not needed, view internal */
    153 
    154   viewioctl (unit, VIEW_DISPLAY, NULL, 0, -1);
    155 
    156 }
    157 
    158 XXX_grf_cc_off (unit)
    159     int unit;
    160 {
    161     viewioctl (unit, VIEW_REMOVE, NULL, 0, -1);
    162 }
    163 
    164 
    165 #endif
    166 
    167