ipaq_lcd.c revision 1.3.2.3 1 1.3.2.3 thorpej /* $NetBSD: ipaq_lcd.c,v 1.3.2.3 2002/01/10 19:43:36 thorpej Exp $ */
2 1.3.2.2 lukem #define IPAQ_LCD_DEBUG
3 1.3.2.2 lukem
4 1.3.2.2 lukem /*
5 1.3.2.2 lukem * Copyright (c) 2001 The NetBSD Foundation, Inc.
6 1.3.2.2 lukem * All rights reserved.
7 1.3.2.2 lukem *
8 1.3.2.2 lukem * This code is derived from software contributed to The NetBSD Foundation
9 1.3.2.2 lukem * by Ichiro FUKUHARA (ichiro (at) ichiro.org).
10 1.3.2.2 lukem *
11 1.3.2.2 lukem * Redistribution and use in source and binary forms, with or without
12 1.3.2.2 lukem * modification, are permitted provided that the following conditions
13 1.3.2.2 lukem * are met:
14 1.3.2.2 lukem * 1. Redistributions of source code must retain the above copyright
15 1.3.2.2 lukem * notice, this list of conditions and the following disclaimer.
16 1.3.2.2 lukem * 2. Redistributions in binary form must reproduce the above copyright
17 1.3.2.2 lukem * notice, this list of conditions and the following disclaimer in the
18 1.3.2.2 lukem * documentation and/or other materials provided with the distribution.
19 1.3.2.2 lukem * 3. All advertising materials mentioning features or use of this software
20 1.3.2.2 lukem * must display the following acknowledgement:
21 1.3.2.2 lukem * This product includes software developed by the NetBSD
22 1.3.2.2 lukem * Foundation, Inc. and its contributors.
23 1.3.2.2 lukem * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.3.2.2 lukem * contributors may be used to endorse or promote products derived
25 1.3.2.2 lukem * from this software without specific prior written permission.
26 1.3.2.2 lukem *
27 1.3.2.2 lukem * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.3.2.2 lukem * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.3.2.2 lukem * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.3.2.2 lukem * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.3.2.2 lukem * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.3.2.2 lukem * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.3.2.2 lukem * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.3.2.2 lukem * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.3.2.2 lukem * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.3.2.2 lukem * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.3.2.2 lukem * POSSIBILITY OF SUCH DAMAGE.
38 1.3.2.2 lukem */
39 1.3.2.2 lukem
40 1.3.2.2 lukem #include <sys/types.h>
41 1.3.2.2 lukem #include <sys/param.h>
42 1.3.2.2 lukem #include <sys/systm.h>
43 1.3.2.2 lukem #include <sys/kernel.h>
44 1.3.2.2 lukem #include <sys/time.h>
45 1.3.2.2 lukem #include <sys/device.h>
46 1.3.2.2 lukem
47 1.3.2.2 lukem #include <uvm/uvm_extern.h>
48 1.3.2.2 lukem
49 1.3.2.2 lukem #include <dev/wscons/wsconsio.h>
50 1.3.2.2 lukem
51 1.3.2.2 lukem #include <machine/bootinfo.h>
52 1.3.2.2 lukem #include <machine/bus.h>
53 1.3.2.3 thorpej #include <machine/intr.h>
54 1.3.2.3 thorpej #include <arm/cpufunc.h>
55 1.3.2.3 thorpej #include <arm/arm32/katelib.h>
56 1.3.2.2 lukem
57 1.3.2.2 lukem #include <hpcarm/sa11x0/sa11x0_reg.h>
58 1.3.2.2 lukem #include <hpcarm/sa11x0/sa11x0_gpioreg.h>
59 1.3.2.2 lukem
60 1.3.2.2 lukem #include <hpcarm/dev/ipaq_gpioreg.h>
61 1.3.2.2 lukem #include <hpcarm/dev/ipaq_saipvar.h>
62 1.3.2.2 lukem #include <hpcarm/dev/ipaq_lcdreg.h>
63 1.3.2.2 lukem #include <hpcarm/dev/ipaq_lcdvar.h>
64 1.3.2.2 lukem
65 1.3.2.2 lukem #ifdef IPAQ_LCD_DEBUG
66 1.3.2.2 lukem #define DPRINTFN(n, x) if (ipaqlcddebug > (n)) printf x
67 1.3.2.2 lukem int ipaqlcddebug = 0xff;
68 1.3.2.2 lukem #else
69 1.3.2.2 lukem #define DPRINTFN(n, x)
70 1.3.2.2 lukem #endif
71 1.3.2.2 lukem #define DPRINTF(x) DPRINTFN(0, x)
72 1.3.2.2 lukem
73 1.3.2.2 lukem static int ipaqlcd_match(struct device *, struct cfdata *, void *);
74 1.3.2.2 lukem static void ipaqlcd_attach(struct device *, struct device *, void *);
75 1.3.2.2 lukem static void ipaqlcd_init(struct ipaqlcd_softc *);
76 1.3.2.2 lukem static int ipaqlcd_fbinit(struct ipaqlcd_softc *);
77 1.3.2.2 lukem static int ipaqlcd_ioctl(void *, u_long, caddr_t, int, struct proc *);
78 1.3.2.2 lukem static paddr_t ipaqlcd_mmap(void *, off_t offset, int);
79 1.3.2.2 lukem
80 1.3.2.2 lukem #if defined __mips__ || defined __sh__ || defined __arm__
81 1.3.2.2 lukem #define __BTOP(x) ((paddr_t)(x) >> PGSHIFT)
82 1.3.2.2 lukem #define __PTOB(x) ((paddr_t)(x) << PGSHIFT)
83 1.3.2.2 lukem #else
84 1.3.2.2 lukem #error "define btop, ptob."
85 1.3.2.2 lukem #endif
86 1.3.2.2 lukem
87 1.3.2.2 lukem struct cfattach ipaqlcd_ca = {
88 1.3.2.2 lukem sizeof(struct ipaqlcd_softc), ipaqlcd_match, ipaqlcd_attach
89 1.3.2.2 lukem };
90 1.3.2.2 lukem
91 1.3.2.2 lukem struct hpcfb_accessops ipaqlcd_ha = {
92 1.3.2.2 lukem ipaqlcd_ioctl, ipaqlcd_mmap
93 1.3.2.2 lukem };
94 1.3.2.2 lukem static int console_flag = 0;
95 1.3.2.2 lukem
96 1.3.2.2 lukem static int
97 1.3.2.2 lukem ipaqlcd_match(parent, match, aux)
98 1.3.2.2 lukem struct device *parent;
99 1.3.2.2 lukem struct cfdata *match;
100 1.3.2.2 lukem void *aux;
101 1.3.2.2 lukem {
102 1.3.2.2 lukem return (1);
103 1.3.2.2 lukem }
104 1.3.2.2 lukem
105 1.3.2.2 lukem void
106 1.3.2.2 lukem ipaqlcd_attach(parent, self, aux)
107 1.3.2.2 lukem struct device *parent;
108 1.3.2.2 lukem struct device *self;
109 1.3.2.2 lukem void *aux;
110 1.3.2.2 lukem {
111 1.3.2.2 lukem struct ipaqlcd_softc *sc = (struct ipaqlcd_softc*)self;
112 1.3.2.2 lukem struct hpcfb_attach_args ha;
113 1.3.2.2 lukem struct ipaq_softc *psc = (struct ipaq_softc *)parent;
114 1.3.2.2 lukem
115 1.3.2.2 lukem sc->sc_iot = psc->sc_iot;
116 1.3.2.2 lukem sc->sc_parent = (struct ipaq_softc *)parent;
117 1.3.2.2 lukem
118 1.3.2.2 lukem ipaqlcd_init(sc);
119 1.3.2.2 lukem ipaqlcd_fbinit(sc);
120 1.3.2.2 lukem
121 1.3.2.2 lukem printf("\n");
122 1.3.2.2 lukem printf("%s: iPAQ internal LCD controller\n", sc->sc_dev.dv_xname);
123 1.3.2.2 lukem
124 1.3.2.2 lukem DPRINTF(("framebuffer_baseaddr=%lx\n", (u_long)bootinfo->fb_addr));
125 1.3.2.2 lukem
126 1.3.2.2 lukem ha.ha_console = console_flag;
127 1.3.2.2 lukem ha.ha_accessops = &ipaqlcd_ha;
128 1.3.2.2 lukem ha.ha_accessctx = sc;
129 1.3.2.2 lukem ha.ha_curfbconf = 0;
130 1.3.2.2 lukem ha.ha_nfbconf = 1;
131 1.3.2.2 lukem ha.ha_fbconflist = &sc->sc_fbconf;
132 1.3.2.2 lukem ha.ha_curdspconf = 0;
133 1.3.2.2 lukem ha.ha_ndspconf = 1;
134 1.3.2.2 lukem ha.ha_dspconflist = &sc->sc_dspconf;
135 1.3.2.2 lukem
136 1.3.2.2 lukem config_found(&sc->sc_dev, &ha, hpcfbprint);
137 1.3.2.2 lukem }
138 1.3.2.2 lukem
139 1.3.2.2 lukem void
140 1.3.2.2 lukem ipaqlcd_init(sc)
141 1.3.2.2 lukem struct ipaqlcd_softc *sc;
142 1.3.2.2 lukem {
143 1.3.2.2 lukem /* Initialization of Extended GPIO */
144 1.3.2.2 lukem sc->sc_parent->ipaq_egpio |= EGPIO_LCD_INIT;
145 1.3.2.2 lukem bus_space_write_2(sc->sc_iot, sc->sc_parent->sc_egpioh,
146 1.3.2.2 lukem 0, sc->sc_parent->ipaq_egpio);
147 1.3.2.2 lukem
148 1.3.2.2 lukem if (bus_space_map(sc->sc_iot, SALCD_BASE, SALCD_NPORTS,
149 1.3.2.2 lukem 0, &sc->sc_ioh))
150 1.3.2.2 lukem panic("ipaqlcd_init:Cannot map registers\n");
151 1.3.2.2 lukem
152 1.3.2.2 lukem (u_long)bootinfo->fb_addr =
153 1.3.2.2 lukem bus_space_read_4(sc->sc_iot, sc->sc_ioh, SALCD_BA1);
154 1.3.2.2 lukem
155 1.3.2.2 lukem /*
156 1.3.2.2 lukem * Initialize LCD Control Register 0 - 3
157 1.3.2.2 lukem * must initialize DMA Channel Base Address Register
158 1.3.2.2 lukem * before enabling LCD(LEN = 1)
159 1.3.2.2 lukem */
160 1.3.2.2 lukem bus_space_write_4(sc->sc_iot, sc->sc_ioh,
161 1.3.2.2 lukem SALCD_CR1, IPAQ_LCCR1);
162 1.3.2.2 lukem bus_space_write_4(sc->sc_iot, sc->sc_ioh,
163 1.3.2.2 lukem SALCD_CR2, IPAQ_LCCR2);
164 1.3.2.2 lukem bus_space_write_4(sc->sc_iot, sc->sc_ioh,
165 1.3.2.2 lukem SALCD_CR3, IPAQ_LCCR3);
166 1.3.2.2 lukem bus_space_write_4(sc->sc_iot, sc->sc_ioh,
167 1.3.2.2 lukem SALCD_CR0, IPAQ_LCCR0);
168 1.3.2.2 lukem
169 1.3.2.2 lukem DPRINTF(("\n"
170 1.3.2.2 lukem "DMA_BASE= %08x : DMA_CUR = %08x \n"
171 1.3.2.2 lukem "LCCR0 = %08x : LCCR1 = %08x \n"
172 1.3.2.2 lukem "LCCR2 = %08x : LCCR3 = %08x",
173 1.3.2.2 lukem bus_space_read_4(sc->sc_iot, sc->sc_ioh, SALCD_BA1),
174 1.3.2.2 lukem bus_space_read_4(sc->sc_iot, sc->sc_ioh, SALCD_CA1),
175 1.3.2.2 lukem bus_space_read_4(sc->sc_iot, sc->sc_ioh, SALCD_CR0),
176 1.3.2.2 lukem bus_space_read_4(sc->sc_iot, sc->sc_ioh, SALCD_CR1),
177 1.3.2.2 lukem bus_space_read_4(sc->sc_iot, sc->sc_ioh, SALCD_CR2),
178 1.3.2.2 lukem bus_space_read_4(sc->sc_iot, sc->sc_ioh, SALCD_CR3)));
179 1.3.2.2 lukem
180 1.3.2.2 lukem }
181 1.3.2.2 lukem
182 1.3.2.2 lukem int
183 1.3.2.2 lukem ipaqlcd_fbinit(sc)
184 1.3.2.2 lukem struct ipaqlcd_softc *sc;
185 1.3.2.2 lukem {
186 1.3.2.2 lukem struct hpcfb_fbconf *fb;
187 1.3.2.2 lukem
188 1.3.2.2 lukem fb = &sc->sc_fbconf;
189 1.3.2.2 lukem
190 1.3.2.2 lukem /* Initialize fb */
191 1.3.2.2 lukem memset(fb, 0, sizeof(*fb));
192 1.3.2.2 lukem
193 1.3.2.2 lukem fb->hf_conf_index = 0; /* configuration index */
194 1.3.2.2 lukem fb->hf_nconfs = 1;
195 1.3.2.2 lukem strcpy(fb->hf_name, "built-in video");
196 1.3.2.2 lukem strcpy(fb->hf_conf_name, "LCD");
197 1.3.2.2 lukem /* configuration name */
198 1.3.2.2 lukem fb->hf_height = bootinfo->fb_height;
199 1.3.2.2 lukem fb->hf_width = bootinfo->fb_width;
200 1.3.2.2 lukem
201 1.3.2.2 lukem if (bus_space_map(sc->sc_iot, (bus_addr_t)bootinfo->fb_addr,
202 1.3.2.2 lukem bootinfo->fb_height * bootinfo->fb_line_bytes,
203 1.3.2.2 lukem 0, &fb->hf_baseaddr)) {
204 1.3.2.2 lukem printf("unable to map framebuffer\n");
205 1.3.2.2 lukem return (-1);
206 1.3.2.2 lukem }
207 1.3.2.2 lukem
208 1.3.2.2 lukem fb->hf_offset = (u_long)bootinfo->fb_addr -
209 1.3.2.2 lukem __PTOB(__BTOP(bootinfo->fb_addr));
210 1.3.2.2 lukem /* frame buffer start offset */
211 1.3.2.2 lukem fb->hf_bytes_per_line = bootinfo->fb_line_bytes;
212 1.3.2.2 lukem fb->hf_nplanes = 1;
213 1.3.2.2 lukem fb->hf_bytes_per_plane = bootinfo->fb_height *
214 1.3.2.2 lukem bootinfo->fb_line_bytes;
215 1.3.2.2 lukem
216 1.3.2.2 lukem fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
217 1.3.2.2 lukem fb->hf_access_flags |= HPCFB_ACCESS_WORD;
218 1.3.2.2 lukem fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
219 1.3.2.2 lukem
220 1.3.2.2 lukem switch (bootinfo->fb_type) {
221 1.3.2.2 lukem /*
222 1.3.2.2 lukem * gray scale
223 1.3.2.2 lukem */
224 1.3.2.2 lukem case BIFB_D2_M2L_3:
225 1.3.2.2 lukem case BIFB_D2_M2L_3x2:
226 1.3.2.2 lukem fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
227 1.3.2.2 lukem case BIFB_D2_M2L_0:
228 1.3.2.2 lukem case BIFB_D2_M2L_0x2:
229 1.3.2.2 lukem fb->hf_class = HPCFB_CLASS_GRAYSCALE;
230 1.3.2.2 lukem break;
231 1.3.2.2 lukem case BIFB_D4_M2L_F:
232 1.3.2.2 lukem case BIFB_D4_M2L_Fx2:
233 1.3.2.2 lukem fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
234 1.3.2.2 lukem case BIFB_D4_M2L_0:
235 1.3.2.2 lukem case BIFB_D4_M2L_0x2:
236 1.3.2.2 lukem fb->hf_class = HPCFB_CLASS_GRAYSCALE;
237 1.3.2.2 lukem break;
238 1.3.2.2 lukem /*
239 1.3.2.2 lukem * indexed color
240 1.3.2.2 lukem */
241 1.3.2.2 lukem case BIFB_D8_FF:
242 1.3.2.2 lukem case BIFB_D8_00:
243 1.3.2.2 lukem fb->hf_offset = 0x200;
244 1.3.2.2 lukem break;
245 1.3.2.2 lukem /*
246 1.3.2.2 lukem * RGB color
247 1.3.2.2 lukem */
248 1.3.2.2 lukem case BIFB_D16_FFFF:
249 1.3.2.2 lukem case BIFB_D16_0000:
250 1.3.2.2 lukem fb->hf_class = HPCFB_CLASS_RGBCOLOR;
251 1.3.2.2 lukem fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
252 1.3.2.2 lukem fb->hf_order_flags = HPCFB_REVORDER_BYTE;
253 1.3.2.2 lukem fb->hf_pack_width = 16;
254 1.3.2.2 lukem fb->hf_pixels_per_pack = 1;
255 1.3.2.2 lukem fb->hf_pixel_width = 16;
256 1.3.2.2 lukem
257 1.3.2.2 lukem fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
258 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_flags = 0;
259 1.3.2.2 lukem /* reserved for future use */
260 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_red_width = 5;
261 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_red_shift = 11;
262 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_green_width = 6;
263 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_green_shift = 5;
264 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_blue_width = 5;
265 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_blue_shift = 0;
266 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_alpha_width = 0;
267 1.3.2.2 lukem fb->hf_u.hf_rgb.hf_alpha_shift = 0;
268 1.3.2.2 lukem break;
269 1.3.2.2 lukem default :
270 1.3.2.2 lukem printf("unknown type (=%d).\n", bootinfo->fb_type);
271 1.3.2.2 lukem return (-1);
272 1.3.2.2 lukem break;
273 1.3.2.2 lukem }
274 1.3.2.2 lukem
275 1.3.2.2 lukem return(0);
276 1.3.2.2 lukem }
277 1.3.2.2 lukem
278 1.3.2.2 lukem int
279 1.3.2.2 lukem ipaqlcd_ioctl(v, cmd, data, flag, p)
280 1.3.2.2 lukem void *v;
281 1.3.2.2 lukem u_long cmd;
282 1.3.2.2 lukem caddr_t data;
283 1.3.2.2 lukem int flag;
284 1.3.2.2 lukem struct proc *p;
285 1.3.2.2 lukem {
286 1.3.2.2 lukem struct ipaqlcd_softc *sc = (struct ipaqlcd_softc *)v;
287 1.3.2.2 lukem struct hpcfb_fbconf *fbconf;
288 1.3.2.2 lukem struct hpcfb_dspconf *dspconf;
289 1.3.2.2 lukem struct wsdisplay_cmap *cmap;
290 1.3.2.2 lukem struct wsdisplay_param *dispparam;
291 1.3.2.2 lukem
292 1.3.2.2 lukem switch (cmd) {
293 1.3.2.2 lukem case WSDISPLAYIO_GETCMAP:
294 1.3.2.2 lukem cmap = (struct wsdisplay_cmap*)data;
295 1.3.2.2 lukem
296 1.3.2.2 lukem if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
297 1.3.2.2 lukem sc->sc_fbconf.hf_pack_width != 8 ||
298 1.3.2.2 lukem 256 <= cmap->index ||
299 1.3.2.2 lukem 256 < (cmap->index + cmap->count))
300 1.3.2.2 lukem return (EINVAL);
301 1.3.2.2 lukem return (0);
302 1.3.2.2 lukem case WSDISPLAYIO_PUTCMAP:
303 1.3.2.2 lukem return (EINVAL);
304 1.3.2.2 lukem case WSDISPLAYIO_GETPARAM:
305 1.3.2.2 lukem dispparam = (struct wsdisplay_param*)data;
306 1.3.2.2 lukem switch (dispparam->param) {
307 1.3.2.2 lukem case WSDISPLAYIO_PARAM_BACKLIGHT:
308 1.3.2.2 lukem DPRINTF(("ipaqlcd_ioctl: GETPARAM:BACKLIGHT\n"));
309 1.3.2.2 lukem return (EINVAL);
310 1.3.2.2 lukem case WSDISPLAYIO_PARAM_CONTRAST:
311 1.3.2.2 lukem DPRINTF(("ipaqlcd_ioctl: GETPARAM:CONTRAST\n"));
312 1.3.2.2 lukem return (EINVAL);
313 1.3.2.2 lukem case WSDISPLAYIO_PARAM_BRIGHTNESS:
314 1.3.2.2 lukem DPRINTF(("ipaqlcd_ioctl: GETPARAM:BRIGHTNESS\n"));
315 1.3.2.2 lukem return (EINVAL);
316 1.3.2.2 lukem default:
317 1.3.2.2 lukem return (EINVAL);
318 1.3.2.2 lukem }
319 1.3.2.2 lukem return (0);
320 1.3.2.2 lukem case WSDISPLAYIO_SETPARAM:
321 1.3.2.2 lukem dispparam = (struct wsdisplay_param*)data;
322 1.3.2.2 lukem switch (dispparam->param) {
323 1.3.2.2 lukem case WSDISPLAYIO_PARAM_BACKLIGHT:
324 1.3.2.2 lukem DPRINTF(("ipaqlcd_ioctl: GETPARAM:BACKLIGHT\n"));
325 1.3.2.2 lukem return (EINVAL);
326 1.3.2.2 lukem case WSDISPLAYIO_PARAM_CONTRAST:
327 1.3.2.2 lukem DPRINTF(("ipaqlcd_ioctl: GETPARAM:CONTRAST\n"));
328 1.3.2.2 lukem return (EINVAL);
329 1.3.2.2 lukem case WSDISPLAYIO_PARAM_BRIGHTNESS:
330 1.3.2.2 lukem DPRINTF(("ipaqlcd_ioctl: GETPARAM:BRIGHTNESS\n"));
331 1.3.2.2 lukem return (EINVAL);
332 1.3.2.2 lukem default:
333 1.3.2.2 lukem return (EINVAL);
334 1.3.2.2 lukem }
335 1.3.2.2 lukem return (0);
336 1.3.2.2 lukem
337 1.3.2.2 lukem case HPCFBIO_GCONF:
338 1.3.2.2 lukem fbconf = (struct hpcfb_fbconf *)data;
339 1.3.2.2 lukem if (fbconf->hf_conf_index != 0 &&
340 1.3.2.2 lukem fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
341 1.3.2.2 lukem return (EINVAL);
342 1.3.2.2 lukem }
343 1.3.2.2 lukem *fbconf = sc->sc_fbconf; /* structure assignment */
344 1.3.2.2 lukem return (0);
345 1.3.2.2 lukem case HPCFBIO_SCONF:
346 1.3.2.2 lukem fbconf = (struct hpcfb_fbconf *)data;
347 1.3.2.2 lukem if (fbconf->hf_conf_index != 0 &&
348 1.3.2.2 lukem fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
349 1.3.2.2 lukem return (EINVAL);
350 1.3.2.2 lukem }
351 1.3.2.2 lukem /*
352 1.3.2.2 lukem * nothing to do because we have only one configration
353 1.3.2.2 lukem */
354 1.3.2.2 lukem return (0);
355 1.3.2.2 lukem case HPCFBIO_GDSPCONF:
356 1.3.2.2 lukem dspconf = (struct hpcfb_dspconf *)data;
357 1.3.2.2 lukem if ((dspconf->hd_unit_index != 0 &&
358 1.3.2.2 lukem dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
359 1.3.2.2 lukem (dspconf->hd_conf_index != 0 &&
360 1.3.2.2 lukem dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
361 1.3.2.2 lukem return (EINVAL);
362 1.3.2.2 lukem }
363 1.3.2.2 lukem *dspconf = sc->sc_dspconf; /* structure assignment */
364 1.3.2.2 lukem return (0);
365 1.3.2.2 lukem case HPCFBIO_SDSPCONF:
366 1.3.2.2 lukem dspconf = (struct hpcfb_dspconf *)data;
367 1.3.2.2 lukem if ((dspconf->hd_unit_index != 0 &&
368 1.3.2.2 lukem dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
369 1.3.2.2 lukem (dspconf->hd_conf_index != 0 &&
370 1.3.2.2 lukem dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
371 1.3.2.2 lukem return (EINVAL);
372 1.3.2.2 lukem }
373 1.3.2.2 lukem /*
374 1.3.2.2 lukem * nothing to do
375 1.3.2.2 lukem * because we have only one unit and one configration
376 1.3.2.2 lukem */
377 1.3.2.2 lukem return (0);
378 1.3.2.2 lukem
379 1.3.2.2 lukem case HPCFBIO_GOP:
380 1.3.2.2 lukem case HPCFBIO_SOP:
381 1.3.2.2 lukem return (EINVAL);
382 1.3.2.2 lukem }
383 1.3.2.2 lukem return (ENOTTY);
384 1.3.2.2 lukem }
385 1.3.2.2 lukem
386 1.3.2.2 lukem paddr_t
387 1.3.2.2 lukem ipaqlcd_mmap(ctx, offset, prot)
388 1.3.2.2 lukem void *ctx;
389 1.3.2.2 lukem off_t offset;
390 1.3.2.2 lukem int prot;
391 1.3.2.2 lukem {
392 1.3.2.2 lukem struct ipaqlcd_softc *sc = (struct ipaqlcd_softc *)ctx;
393 1.3.2.2 lukem
394 1.3.2.2 lukem if (offset < 0 ||
395 1.3.2.2 lukem (sc->sc_fbconf.hf_bytes_per_plane +
396 1.3.2.2 lukem sc->sc_fbconf.hf_offset) < offset)
397 1.3.2.2 lukem return -1;
398 1.3.2.2 lukem
399 1.3.2.2 lukem return __BTOP((u_long)bootinfo->fb_addr + offset);
400 1.3.2.2 lukem }
401