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