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