pxa2x0_lcd.c revision 1.14 1 1.14 ober /* $NetBSD: pxa2x0_lcd.c,v 1.14 2006/12/16 03:39:05 ober Exp $ */
2 1.1 bsh
3 1.1 bsh /*
4 1.1 bsh * Copyright (c) 2002 Genetec Corporation. All rights reserved.
5 1.1 bsh * Written by Hiroyuki Bessho for Genetec Corporation.
6 1.1 bsh *
7 1.1 bsh * Redistribution and use in source and binary forms, with or without
8 1.1 bsh * modification, are permitted provided that the following conditions
9 1.1 bsh * are met:
10 1.1 bsh * 1. Redistributions of source code must retain the above copyright
11 1.1 bsh * notice, this list of conditions and the following disclaimer.
12 1.1 bsh * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 bsh * notice, this list of conditions and the following disclaimer in the
14 1.1 bsh * documentation and/or other materials provided with the distribution.
15 1.1 bsh * 3. All advertising materials mentioning features or use of this software
16 1.1 bsh * must display the following acknowledgement:
17 1.1 bsh * This product includes software developed for the NetBSD Project by
18 1.1 bsh * Genetec Corporation.
19 1.1 bsh * 4. The name of Genetec Corporation may not be used to endorse or
20 1.1 bsh * promote products derived from this software without specific prior
21 1.1 bsh * written permission.
22 1.1 bsh *
23 1.1 bsh * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
24 1.1 bsh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 1.1 bsh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 1.1 bsh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
27 1.1 bsh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 1.1 bsh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 1.1 bsh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 1.1 bsh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 1.1 bsh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 1.1 bsh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 1.1 bsh * POSSIBILITY OF SUCH DAMAGE.
34 1.1 bsh */
35 1.1 bsh
36 1.1 bsh /*
37 1.1 bsh * Support PXA2[15]0's integrated LCD controller.
38 1.1 bsh */
39 1.6 lukem
40 1.6 lukem #include <sys/cdefs.h>
41 1.14 ober __KERNEL_RCSID(0, "$NetBSD: pxa2x0_lcd.c,v 1.14 2006/12/16 03:39:05 ober Exp $");
42 1.6 lukem
43 1.1 bsh #include <sys/param.h>
44 1.1 bsh #include <sys/systm.h>
45 1.1 bsh #include <sys/conf.h>
46 1.1 bsh #include <sys/uio.h>
47 1.1 bsh #include <sys/malloc.h>
48 1.1 bsh #include <sys/kernel.h> /* for cold */
49 1.1 bsh
50 1.2 thorpej #include <uvm/uvm_extern.h>
51 1.2 thorpej
52 1.1 bsh #include <dev/cons.h>
53 1.1 bsh #include <dev/wscons/wsconsio.h>
54 1.1 bsh #include <dev/wscons/wsdisplayvar.h>
55 1.1 bsh #include <dev/wscons/wscons_callbacks.h>
56 1.1 bsh #include <dev/rasops/rasops.h>
57 1.1 bsh #include <dev/wsfont/wsfont.h>
58 1.1 bsh
59 1.1 bsh #include <machine/bus.h>
60 1.1 bsh #include <machine/cpu.h>
61 1.1 bsh #include <arm/cpufunc.h>
62 1.1 bsh
63 1.10 bsh #include <arm/xscale/pxa2x0cpu.h>
64 1.1 bsh #include <arm/xscale/pxa2x0var.h>
65 1.1 bsh #include <arm/xscale/pxa2x0reg.h>
66 1.1 bsh #include <arm/xscale/pxa2x0_lcd.h>
67 1.5 bsh #include <arm/xscale/pxa2x0_gpio.h>
68 1.1 bsh
69 1.1 bsh #include "wsdisplay.h"
70 1.1 bsh
71 1.14 ober /*
72 1.14 ober * Console variables. These are necessary since console is setup very early,
73 1.14 ober * before devices get attached.
74 1.14 ober */
75 1.14 ober struct {
76 1.14 ober bus_space_tag_t iot;
77 1.14 ober bus_space_handle_t ioh;
78 1.14 ober bus_dma_tag_t dma_tag;
79 1.14 ober const struct lcd_panel_geometry *geometry;
80 1.14 ober struct pxa2x0_lcd_screen scr;
81 1.14 ober } pxa2x0_lcd_console;
82 1.14 ober
83 1.14 ober int lcdintr(void *);
84 1.14 ober void pxa2x0_lcd_initialize(struct pxa2x0_lcd_softc *sc,
85 1.14 ober const struct lcd_panel_geometry *geom);
86 1.14 ober void pxa2x0_lcd_setup_console(struct pxa2x0_lcd_softc *sc,
87 1.14 ober const struct pxa2x0_wsscreen_descr *descr);
88 1.14 ober void pxa2x0_lcd_setup_rasops(struct rasops_info *rinfo,
89 1.14 ober struct pxa2x0_wsscreen_descr *descr,
90 1.14 ober const struct lcd_panel_geometry *geom);
91 1.1 bsh
92 1.1 bsh void
93 1.4 bsh pxa2x0_lcd_geometry(struct pxa2x0_lcd_softc *sc,
94 1.4 bsh const struct lcd_panel_geometry *info)
95 1.1 bsh {
96 1.14 ober bus_space_tag_t iot;
97 1.14 ober bus_space_handle_t ioh;
98 1.14 ober uint32_t ccr0;
99 1.1 bsh int lines;
100 1.1 bsh
101 1.14 ober if (sc != NULL) {
102 1.14 ober iot = sc->iot;
103 1.14 ober ioh = sc->ioh;
104 1.14 ober sc->geometry = info;
105 1.14 ober } else {
106 1.14 ober iot = pxa2x0_lcd_console.iot;
107 1.14 ober ioh = pxa2x0_lcd_console.ioh;
108 1.14 ober pxa2x0_lcd_console.geometry = info;
109 1.14 ober }
110 1.1 bsh
111 1.1 bsh ccr0 = LCCR0_IMASK;
112 1.4 bsh if (info->panel_info & LCDPANEL_ACTIVE)
113 1.4 bsh ccr0 |= LCCR0_PAS; /* active mode */
114 1.4 bsh if ((info->panel_info & (LCDPANEL_DUAL|LCDPANEL_ACTIVE))
115 1.4 bsh == LCDPANEL_DUAL)
116 1.1 bsh ccr0 |= LCCR0_SDS; /* dual panel */
117 1.4 bsh if (info->panel_info & LCDPANEL_MONOCHROME)
118 1.1 bsh ccr0 |= LCCR0_CMS;
119 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCCR0, ccr0);
120 1.1 bsh
121 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCCR1,
122 1.1 bsh (info->panel_width-1)
123 1.1 bsh | ((info->hsync_pulse_width-1)<<10)
124 1.1 bsh | ((info->end_line_wait-1)<<16)
125 1.4 bsh | ((info->beg_line_wait-1)<<24));
126 1.1 bsh
127 1.4 bsh if (info->panel_info & LCDPANEL_DUAL)
128 1.1 bsh lines = info->panel_height/2 + info->extra_lines;
129 1.1 bsh else
130 1.1 bsh lines = info->panel_height + info->extra_lines;
131 1.1 bsh
132 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCCR2,
133 1.1 bsh (lines-1)
134 1.1 bsh | (info->vsync_pulse_width<<10)
135 1.1 bsh | (info->end_frame_wait<<16)
136 1.4 bsh | (info->beg_frame_wait<<24));
137 1.1 bsh
138 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCCR3,
139 1.1 bsh (info->pixel_clock_div<<0)
140 1.1 bsh | (info->ac_bias << 8)
141 1.1 bsh | ((info->panel_info &
142 1.1 bsh (LCDPANEL_VSP|LCDPANEL_HSP|LCDPANEL_PCP|LCDPANEL_OEP))
143 1.1 bsh <<20)
144 1.4 bsh | (4 << 24) /* 16bpp */
145 1.1 bsh | ((info->panel_info & LCDPANEL_DPC) ? (1<<27) : 0)
146 1.1 bsh );
147 1.1 bsh }
148 1.1 bsh
149 1.14 ober /*
150 1.14 ober * Initialize the LCD controller.
151 1.14 ober */
152 1.1 bsh void
153 1.14 ober pxa2x0_lcd_initialize(struct pxa2x0_lcd_softc *sc,
154 1.14 ober const struct lcd_panel_geometry *geom)
155 1.1 bsh {
156 1.14 ober bus_space_tag_t iot;
157 1.1 bsh bus_space_handle_t ioh;
158 1.14 ober uint32_t lccr0, lscr;
159 1.14 ober int nldd;
160 1.1 bsh
161 1.14 ober if (sc != NULL) {
162 1.14 ober iot = sc->iot;
163 1.14 ober ioh = sc->ioh;
164 1.14 ober } else {
165 1.14 ober iot = pxa2x0_lcd_console.iot;
166 1.14 ober ioh = pxa2x0_lcd_console.ioh;
167 1.14 ober }
168 1.1 bsh
169 1.14 ober /* Check if LCD is enabled before programming, it should not
170 1.14 ober * be enabled while it is being reprogrammed, therefore disable
171 1.14 ober * it first.
172 1.14 ober */
173 1.14 ober lccr0 = bus_space_read_4(iot, ioh, LCDC_LCCR0);
174 1.14 ober if (lccr0 & LCCR0_ENB) {
175 1.14 ober lccr0 |= LCCR0_LDM;
176 1.14 ober bus_space_write_4(iot, ioh, LCDC_LCCR0, lccr0);
177 1.14 ober lccr0 = bus_space_read_4(iot, ioh, LCDC_LCCR0); /* paranoia */
178 1.14 ober lccr0 |= LCCR0_DIS;
179 1.14 ober bus_space_write_4(iot, ioh, LCDC_LCCR0, lccr0);
180 1.14 ober do {
181 1.14 ober lscr = bus_space_read_4(iot, ioh, LCDC_LCSR);
182 1.14 ober } while (!(lscr & LCSR_LDD));
183 1.1 bsh }
184 1.1 bsh
185 1.1 bsh /* enable clock */
186 1.5 bsh pxa2x0_clkman_config(CKEN_LCD, 1);
187 1.1 bsh
188 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCCR0, LCCR0_IMASK);
189 1.1 bsh
190 1.1 bsh /*
191 1.1 bsh * setup GP[77:58] for LCD
192 1.1 bsh */
193 1.3 scw /* Always use [FLP]CLK, ACBIAS */
194 1.3 scw pxa2x0_gpio_set_function(74, GPIO_ALT_FN_2_OUT);
195 1.3 scw pxa2x0_gpio_set_function(75, GPIO_ALT_FN_2_OUT);
196 1.3 scw pxa2x0_gpio_set_function(76, GPIO_ALT_FN_2_OUT);
197 1.3 scw pxa2x0_gpio_set_function(77, GPIO_ALT_FN_2_OUT);
198 1.3 scw
199 1.3 scw if ((geom->panel_info & LCDPANEL_ACTIVE) ||
200 1.3 scw ((geom->panel_info & (LCDPANEL_MONOCHROME|LCDPANEL_DUAL)) ==
201 1.3 scw LCDPANEL_DUAL)) {
202 1.3 scw /* active and color dual panel need L_DD[15:0] */
203 1.3 scw nldd = 16;
204 1.14 ober } else if ((geom->panel_info & LCDPANEL_DUAL) ||
205 1.3 scw !(geom->panel_info & LCDPANEL_MONOCHROME)) {
206 1.3 scw /* dual or color need L_DD[7:0] */
207 1.3 scw nldd = 8;
208 1.3 scw } else {
209 1.3 scw /* Otherwise just L_DD[3:0] */
210 1.3 scw nldd = 4;
211 1.1 bsh }
212 1.1 bsh
213 1.10 bsh if (CPU_IS_PXA270 && nldd==16) {
214 1.10 bsh pxa2x0_gpio_set_function(86, GPIO_ALT_FN_2_OUT);
215 1.10 bsh pxa2x0_gpio_set_function(87, GPIO_ALT_FN_2_OUT);
216 1.10 bsh }
217 1.14 ober
218 1.3 scw while (nldd--)
219 1.3 scw pxa2x0_gpio_set_function(58 + nldd, GPIO_ALT_FN_2_OUT);
220 1.1 bsh
221 1.4 bsh pxa2x0_lcd_geometry(sc, geom);
222 1.1 bsh }
223 1.1 bsh
224 1.14 ober /*
225 1.14 ober * Common driver attachment code.
226 1.14 ober */
227 1.14 ober void
228 1.14 ober pxa2x0_lcd_attach_sub(struct pxa2x0_lcd_softc *sc,
229 1.14 ober struct pxaip_attach_args *pxa, struct pxa2x0_wsscreen_descr *descr,
230 1.14 ober const struct lcd_panel_geometry *geom, int console)
231 1.14 ober {
232 1.14 ober bus_space_tag_t iot = pxa->pxa_iot;
233 1.14 ober bus_space_handle_t ioh;
234 1.14 ober int error;
235 1.14 ober
236 1.14 ober sc->n_screens = 0;
237 1.14 ober LIST_INIT(&sc->screens);
238 1.1 bsh
239 1.14 ober /* map controller registers */
240 1.14 ober if (console) {
241 1.14 ober iot = pxa2x0_lcd_console.iot;
242 1.14 ober ioh = pxa2x0_lcd_console.ioh;
243 1.14 ober } else {
244 1.14 ober error = bus_space_map(iot, PXA2X0_LCDC_BASE,
245 1.14 ober PXA2X0_LCDC_SIZE, 0, &ioh);
246 1.14 ober if (error) {
247 1.14 ober printf(": failed to map registers %d", error);
248 1.14 ober return;
249 1.14 ober }
250 1.14 ober }
251 1.14 ober
252 1.14 ober sc->iot = iot;
253 1.14 ober sc->ioh = ioh;
254 1.14 ober sc->dma_tag = &pxa2x0_bus_dma_tag;
255 1.14 ober
256 1.14 ober sc->ih = pxa2x0_intr_establish(17, IPL_BIO, lcdintr, sc);
257 1.14 ober if (sc->ih == NULL)
258 1.14 ober printf("%s: unable to establish interrupt at irq %d",
259 1.14 ober sc->dev.dv_xname, 17);
260 1.14 ober
261 1.14 ober if (console != 0) {
262 1.14 ober /* complete console attachment */
263 1.14 ober pxa2x0_lcd_setup_console(sc, descr);
264 1.14 ober } else {
265 1.14 ober struct rasops_info dummy;
266 1.14 ober
267 1.14 ober pxa2x0_lcd_initialize(sc, geom);
268 1.14 ober
269 1.14 ober /*
270 1.14 ober * Initialize a dummy rasops_info to compute fontsize and
271 1.14 ober * the screen size in chars.
272 1.14 ober */
273 1.14 ober memset(&dummy, 0, sizeof(dummy));
274 1.14 ober pxa2x0_lcd_setup_rasops(&dummy, descr, geom);
275 1.14 ober }
276 1.14 ober }
277 1.14 ober
278 1.14 ober /*
279 1.14 ober * Interrupt handler.
280 1.14 ober */
281 1.1 bsh int
282 1.1 bsh lcdintr(void *arg)
283 1.1 bsh {
284 1.1 bsh struct pxa2x0_lcd_softc *sc = arg;
285 1.1 bsh bus_space_tag_t iot = sc->iot;
286 1.1 bsh bus_space_handle_t ioh = sc->ioh;
287 1.1 bsh
288 1.1 bsh static uint32_t status;
289 1.1 bsh
290 1.4 bsh status = bus_space_read_4(iot, ioh, LCDC_LCSR);
291 1.1 bsh /* Clear stickey status bits */
292 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCSR, status);
293 1.1 bsh
294 1.1 bsh return 1;
295 1.1 bsh }
296 1.1 bsh
297 1.14 ober /*
298 1.14 ober * Enable DMA to cause the display to be refreshed periodically.
299 1.14 ober * This brings the screen to life...
300 1.14 ober */
301 1.1 bsh void
302 1.4 bsh pxa2x0_lcd_start_dma(struct pxa2x0_lcd_softc *sc,
303 1.4 bsh struct pxa2x0_lcd_screen *scr)
304 1.1 bsh {
305 1.14 ober bus_space_tag_t iot;
306 1.14 ober bus_space_handle_t ioh;
307 1.1 bsh uint32_t tmp;
308 1.1 bsh int val, save;
309 1.1 bsh
310 1.14 ober if (sc != NULL) {
311 1.14 ober iot = sc->iot;
312 1.14 ober ioh = sc->ioh;
313 1.14 ober } else {
314 1.14 ober iot = pxa2x0_lcd_console.iot;
315 1.14 ober ioh = pxa2x0_lcd_console.ioh;
316 1.14 ober }
317 1.14 ober
318 1.4 bsh save = disable_interrupts(I32_bit);
319 1.1 bsh
320 1.4 bsh switch (scr->depth) {
321 1.1 bsh case 1: val = 0; break;
322 1.1 bsh case 2: val = 1; break;
323 1.1 bsh case 4: val = 2; break;
324 1.1 bsh case 8: val = 3; break;
325 1.10 bsh case 16: val = 4; break;
326 1.10 bsh case 18: val = 5; break;
327 1.10 bsh case 24: val = 33; break;
328 1.1 bsh default:
329 1.1 bsh val = 4; break;
330 1.1 bsh }
331 1.1 bsh
332 1.4 bsh tmp = bus_space_read_4(iot, ioh, LCDC_LCCR3);
333 1.10 bsh if (CPU_IS_PXA270)
334 1.10 bsh bus_space_write_4(iot, ioh, LCDC_LCCR3,
335 1.10 bsh (tmp & ~(LCCR3_BPP|(1<<29))) | (val << LCCR3_BPP_SHIFT));
336 1.10 bsh else
337 1.10 bsh bus_space_write_4(iot, ioh, LCDC_LCCR3,
338 1.10 bsh (tmp & ~LCCR3_BPP) | (val << LCCR3_BPP_SHIFT));
339 1.1 bsh
340 1.4 bsh bus_space_write_4(iot, ioh, LCDC_FDADR0,
341 1.10 bsh scr->depth >= 16 ? scr->dma_desc_pa :
342 1.4 bsh scr->dma_desc_pa + 2 * sizeof (struct lcd_dma_descriptor));
343 1.4 bsh bus_space_write_4(iot, ioh, LCDC_FDADR1,
344 1.4 bsh scr->dma_desc_pa + 1 * sizeof (struct lcd_dma_descriptor));
345 1.1 bsh
346 1.1 bsh /* clear status */
347 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCSR, 0);
348 1.1 bsh
349 1.1 bsh delay(1000); /* ??? */
350 1.1 bsh
351 1.1 bsh /* Enable LCDC */
352 1.4 bsh tmp = bus_space_read_4(iot, ioh, LCDC_LCCR0);
353 1.1 bsh /*tmp &= ~LCCR0_SFM;*/
354 1.4 bsh bus_space_write_4(iot, ioh, LCDC_LCCR0, tmp | LCCR0_ENB);
355 1.1 bsh
356 1.4 bsh restore_interrupts(save);
357 1.1 bsh }
358 1.1 bsh
359 1.5 bsh #if NWSDISPLAY > 0
360 1.14 ober /*
361 1.14 ober * Disable screen refresh.
362 1.14 ober */
363 1.1 bsh static void
364 1.4 bsh pxa2x0_lcd_stop_dma(struct pxa2x0_lcd_softc *sc)
365 1.1 bsh {
366 1.1 bsh /* Stop LCD DMA after current frame */
367 1.4 bsh bus_space_write_4(sc->iot, sc->ioh, LCDC_LCCR0,
368 1.1 bsh LCCR0_DIS |
369 1.4 bsh bus_space_read_4(sc->iot, sc->ioh, LCDC_LCCR0));
370 1.1 bsh
371 1.1 bsh /* wait for disabling done.
372 1.1 bsh XXX: use interrupt. */
373 1.4 bsh while (LCCR0_ENB &
374 1.4 bsh bus_space_read_4(sc->iot, sc->ioh, LCDC_LCCR0))
375 1.1 bsh ;
376 1.1 bsh
377 1.4 bsh bus_space_write_4(sc->iot, sc->ioh, LCDC_LCCR0,
378 1.1 bsh ~LCCR0_DIS &
379 1.4 bsh bus_space_read_4(sc->iot, sc->ioh, LCDC_LCCR0));
380 1.1 bsh }
381 1.5 bsh #endif
382 1.1 bsh
383 1.1 bsh #define _rgb(r,g,b) (((r)<<11) | ((g)<<5) | b)
384 1.1 bsh #define rgb(r,g,b) _rgb((r)>>1,g,(b)>>1)
385 1.1 bsh
386 1.1 bsh #define L 0x1f /* low intensity */
387 1.1 bsh #define H 0x3f /* hight intensity */
388 1.1 bsh
389 1.1 bsh static uint16_t basic_color_map[] = {
390 1.1 bsh rgb( 0, 0, 0), /* black */
391 1.1 bsh rgb( L, 0, 0), /* red */
392 1.1 bsh rgb( 0, L, 0), /* green */
393 1.1 bsh rgb( L, L, 0), /* brown */
394 1.1 bsh rgb( 0, 0, L), /* blue */
395 1.1 bsh rgb( L, 0, L), /* magenta */
396 1.1 bsh rgb( 0, L, L), /* cyan */
397 1.1 bsh _rgb(0x1c,0x38,0x1c), /* white */
398 1.1 bsh
399 1.1 bsh rgb( L, L, L), /* black */
400 1.1 bsh rgb( H, 0, 0), /* red */
401 1.1 bsh rgb( 0, H, 0), /* green */
402 1.1 bsh rgb( H, H, 0), /* brown */
403 1.1 bsh rgb( 0, 0, H), /* blue */
404 1.1 bsh rgb( H, 0, H), /* magenta */
405 1.1 bsh rgb( 0, H, H), /* cyan */
406 1.1 bsh rgb( H, H, H)
407 1.1 bsh };
408 1.1 bsh
409 1.1 bsh #undef H
410 1.1 bsh #undef L
411 1.1 bsh
412 1.1 bsh static void
413 1.4 bsh init_pallet(uint16_t *buf, int depth)
414 1.1 bsh {
415 1.1 bsh int i;
416 1.1 bsh
417 1.1 bsh /* convert RGB332 to RGB565 */
418 1.4 bsh switch (depth) {
419 1.1 bsh case 8:
420 1.1 bsh case 4:
421 1.1 bsh #if 0
422 1.4 bsh for (i=0; i <= 255; ++i) {
423 1.1 bsh buf[i] = ((9 * ((i>>5) & 0x07)) <<11) |
424 1.1 bsh ((9 * ((i>>2) & 0x07)) << 5) |
425 1.4 bsh ((21 * (i & 0x03))/2);
426 1.1 bsh }
427 1.1 bsh #else
428 1.4 bsh memcpy(buf, basic_color_map, sizeof basic_color_map);
429 1.4 bsh for (i=16; i < (1<<depth); ++i)
430 1.1 bsh buf[i] = 0xffff;
431 1.1 bsh #endif
432 1.1 bsh break;
433 1.8 bsh case 16:
434 1.8 bsh /* pallet is not needed */
435 1.8 bsh break;
436 1.1 bsh default:
437 1.8 bsh /* other depths are not supported */
438 1.8 bsh break;
439 1.1 bsh }
440 1.1 bsh }
441 1.1 bsh
442 1.14 ober /*
443 1.14 ober * Create and initialize a new screen buffer.
444 1.14 ober */
445 1.14 ober int
446 1.4 bsh pxa2x0_lcd_new_screen(struct pxa2x0_lcd_softc *sc,
447 1.14 ober struct pxa2x0_lcd_screen *scr,
448 1.4 bsh int depth)
449 1.1 bsh {
450 1.14 ober bus_space_tag_t iot;
451 1.14 ober bus_space_handle_t ioh;
452 1.14 ober bus_dma_tag_t dma_tag;
453 1.14 ober const struct lcd_panel_geometry *geometry;
454 1.1 bsh int width, height;
455 1.1 bsh bus_size_t size;
456 1.12 simonb int error, pallet_size;
457 1.1 bsh int busdma_flag = (cold ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
458 1.1 bsh struct lcd_dma_descriptor *desc;
459 1.1 bsh paddr_t buf_pa, desc_pa;
460 1.1 bsh
461 1.14 ober if (sc != NULL) {
462 1.14 ober iot = sc->iot;
463 1.14 ober ioh = sc->ioh;
464 1.14 ober dma_tag = sc->dma_tag;
465 1.14 ober geometry = sc->geometry;
466 1.14 ober } else {
467 1.14 ober /* We are creating the console screen. */
468 1.14 ober iot = pxa2x0_lcd_console.iot;
469 1.14 ober ioh = pxa2x0_lcd_console.ioh;
470 1.14 ober dma_tag = pxa2x0_lcd_console.dma_tag;
471 1.14 ober geometry = pxa2x0_lcd_console.geometry;
472 1.14 ober }
473 1.14 ober
474 1.14 ober width = geometry->panel_width;
475 1.14 ober height = geometry->panel_height;
476 1.1 bsh pallet_size = 0;
477 1.1 bsh
478 1.4 bsh switch (depth) {
479 1.1 bsh case 1:
480 1.1 bsh case 2:
481 1.1 bsh case 4:
482 1.1 bsh case 8:
483 1.1 bsh pallet_size = (1<<depth) * sizeof (uint16_t);
484 1.1 bsh /* FALLTHROUGH */
485 1.1 bsh case 16:
486 1.1 bsh size = roundup(width,4)*depth/8 * height;
487 1.1 bsh break;
488 1.10 bsh case 18:
489 1.10 bsh case 24:
490 1.10 bsh size = roundup(width,4) * 4 * height;
491 1.10 bsh break;
492 1.10 bsh case 19:
493 1.10 bsh case 25:
494 1.14 ober printf("%s: Not supported depth (%d)\n",
495 1.14 ober sc ? sc->dev.dv_xname : "console",
496 1.14 ober depth);
497 1.14 ober return EINVAL;
498 1.1 bsh default:
499 1.14 ober printf("%s: Unknown depth (%d)\n",
500 1.14 ober sc ? sc->dev.dv_xname : "console", depth);
501 1.14 ober return EINVAL;
502 1.1 bsh }
503 1.1 bsh
504 1.14 ober memset(scr, 0, sizeof(*scr));
505 1.1 bsh
506 1.1 bsh scr->nsegs = 0;
507 1.1 bsh scr->depth = depth;
508 1.1 bsh scr->buf_size = size;
509 1.1 bsh scr->buf_va = NULL;
510 1.1 bsh size = roundup(size,16) + 3 * sizeof (struct lcd_dma_descriptor)
511 1.1 bsh + pallet_size;
512 1.1 bsh
513 1.12 simonb error = bus_dmamem_alloc(sc->dma_tag, size, 16, 0,
514 1.4 bsh scr->segs, 1, &(scr->nsegs), busdma_flag);
515 1.1 bsh
516 1.12 simonb if (error || scr->nsegs != 1) {
517 1.12 simonb /* XXX:
518 1.12 simonb * Actually we can handle nsegs>1 case by means
519 1.12 simonb * of multiple DMA descriptors for a panel. It
520 1.12 simonb * will make code here a bit hairly.
521 1.12 simonb */
522 1.14 ober if (error == 0)
523 1.14 ober error = E2BIG;
524 1.1 bsh goto bad;
525 1.12 simonb }
526 1.1 bsh
527 1.4 bsh error = bus_dmamem_map(sc->dma_tag, scr->segs, scr->nsegs,
528 1.4 bsh size, (caddr_t *)&(scr->buf_va), busdma_flag | BUS_DMA_COHERENT);
529 1.4 bsh if (error)
530 1.1 bsh goto bad;
531 1.1 bsh
532 1.4 bsh memset (scr->buf_va, 0, scr->buf_size);
533 1.1 bsh
534 1.1 bsh /* map memory for DMA */
535 1.4 bsh if (bus_dmamap_create(sc->dma_tag, 1024*1024*2, 1,
536 1.4 bsh 1024*1024*2, 0, busdma_flag, &scr->dma))
537 1.1 bsh goto bad;
538 1.4 bsh error = bus_dmamap_load(sc->dma_tag, scr->dma,
539 1.4 bsh scr->buf_va, size, NULL, busdma_flag);
540 1.4 bsh if (error) {
541 1.1 bsh goto bad;
542 1.1 bsh }
543 1.1 bsh
544 1.1 bsh buf_pa = scr->segs[0].ds_addr;
545 1.2 thorpej desc_pa = buf_pa + roundup(size, PAGE_SIZE) - 3*sizeof *desc;
546 1.1 bsh
547 1.1 bsh /* make descriptors at the top of mapped memory */
548 1.1 bsh desc = (struct lcd_dma_descriptor *)(
549 1.2 thorpej (caddr_t)(scr->buf_va) + roundup(size, PAGE_SIZE) -
550 1.2 thorpej 3*sizeof *desc);
551 1.1 bsh
552 1.1 bsh desc[0].fdadr = desc_pa;
553 1.1 bsh desc[0].fsadr = buf_pa;
554 1.1 bsh desc[0].ldcmd = scr->buf_size;
555 1.1 bsh
556 1.4 bsh if (pallet_size) {
557 1.4 bsh init_pallet((uint16_t *)((char *)desc - pallet_size), depth);
558 1.1 bsh
559 1.1 bsh desc[2].fdadr = desc_pa; /* chain to panel 0 */
560 1.1 bsh desc[2].fsadr = desc_pa - pallet_size;
561 1.1 bsh desc[2].ldcmd = pallet_size | LDCMD_PAL;
562 1.1 bsh }
563 1.1 bsh
564 1.4 bsh if (sc->geometry->panel_info & LCDPANEL_DUAL) {
565 1.1 bsh /* Dual panel */
566 1.1 bsh desc[1].fdadr = desc_pa + sizeof *desc;
567 1.1 bsh desc[1].fsadr = buf_pa + scr->buf_size/2;
568 1.1 bsh desc[0].ldcmd = desc[1].ldcmd = scr->buf_size/2;
569 1.1 bsh
570 1.1 bsh }
571 1.1 bsh
572 1.1 bsh #if 0
573 1.1 bsh desc[0].ldcmd |= LDCMD_SOFINT;
574 1.1 bsh desc[1].ldcmd |= LDCMD_SOFINT;
575 1.1 bsh #endif
576 1.1 bsh
577 1.1 bsh scr->dma_desc = desc;
578 1.1 bsh scr->dma_desc_pa = desc_pa;
579 1.1 bsh scr->map_size = size; /* used when unmap this. */
580 1.1 bsh
581 1.4 bsh LIST_INSERT_HEAD(&(sc->screens), scr, link);
582 1.1 bsh sc->n_screens++;
583 1.1 bsh
584 1.14 ober return 0;
585 1.1 bsh
586 1.1 bsh bad:
587 1.4 bsh if (scr) {
588 1.4 bsh if (scr->buf_va)
589 1.4 bsh bus_dmamem_unmap(sc->dma_tag, scr->buf_va, size);
590 1.4 bsh if (scr->nsegs)
591 1.4 bsh bus_dmamem_free(sc->dma_tag, scr->segs, scr->nsegs);
592 1.1 bsh }
593 1.14 ober return error;
594 1.14 ober }
595 1.14 ober
596 1.14 ober /*
597 1.14 ober * Initialize rasops for a screen, as well as struct wsscreen_descr if this
598 1.14 ober * is the first screen creation.
599 1.14 ober */
600 1.14 ober void
601 1.14 ober pxa2x0_lcd_setup_rasops(struct rasops_info *rinfo,
602 1.14 ober struct pxa2x0_wsscreen_descr *descr,
603 1.14 ober const struct lcd_panel_geometry *geom)
604 1.14 ober {
605 1.14 ober
606 1.14 ober rinfo->ri_flg = descr->flags;
607 1.14 ober rinfo->ri_depth = descr->depth;
608 1.14 ober rinfo->ri_width = geom->panel_width;
609 1.14 ober rinfo->ri_height = geom->panel_height;
610 1.14 ober rinfo->ri_stride = rinfo->ri_width * rinfo->ri_depth / 8;
611 1.14 ober #ifdef notyet
612 1.14 ober rinfo->ri_wsfcookie = -1; /* XXX */
613 1.14 ober #endif
614 1.14 ober
615 1.14 ober /* swap B and R */
616 1.14 ober if (descr->depth == 16) {
617 1.14 ober rinfo->ri_rnum = 5;
618 1.14 ober rinfo->ri_rpos = 11;
619 1.14 ober rinfo->ri_gnum = 6;
620 1.14 ober rinfo->ri_gpos = 5;
621 1.14 ober rinfo->ri_bnum = 5;
622 1.14 ober rinfo->ri_bpos = 0;
623 1.14 ober }
624 1.14 ober
625 1.14 ober if (descr->c.nrows == 0) {
626 1.14 ober /* get rasops to compute screen size the first time */
627 1.14 ober rasops_init(rinfo, 100, 100);
628 1.14 ober } else
629 1.14 ober #ifndef zaurus /* XXX */
630 1.14 ober rasops_init(rinfo, descr->c.nrows, descr->c.ncols);
631 1.14 ober #else
632 1.14 ober /* XXX swap rows/cols for second call because of rotation */
633 1.14 ober rasops_init(rinfo, descr->c.ncols, descr->c.nrows);
634 1.14 ober #endif /* XXX */
635 1.14 ober
636 1.14 ober descr->c.nrows = rinfo->ri_rows;
637 1.14 ober descr->c.ncols = rinfo->ri_cols;
638 1.14 ober descr->c.capabilities = rinfo->ri_caps;
639 1.14 ober descr->c.textops = &rinfo->ri_ops;
640 1.14 ober }
641 1.14 ober
642 1.14 ober /*
643 1.14 ober * Early console attachment.
644 1.14 ober * This initializes the LCD, then creates and displays a screen buffer.
645 1.14 ober * This screen will be accounted for in the softc when the lcd device attaches.
646 1.14 ober */
647 1.14 ober int
648 1.14 ober pxa2x0_lcd_cnattach(struct pxa2x0_wsscreen_descr *descr,
649 1.14 ober const struct lcd_panel_geometry *geom)
650 1.14 ober {
651 1.14 ober struct rasops_info *ri;
652 1.14 ober long defattr;
653 1.14 ober int error;
654 1.14 ober
655 1.14 ober /* map controller registers */
656 1.14 ober pxa2x0_lcd_console.iot = &pxa2x0_bs_tag;
657 1.14 ober error = bus_space_map(pxa2x0_lcd_console.iot,
658 1.14 ober PXA2X0_LCDC_BASE, PXA2X0_LCDC_SIZE, 0, &pxa2x0_lcd_console.ioh);
659 1.14 ober if (error)
660 1.14 ober return error;
661 1.14 ober
662 1.14 ober pxa2x0_lcd_console.dma_tag = &pxa2x0_bus_dma_tag;
663 1.14 ober pxa2x0_lcd_console.geometry = geom;
664 1.14 ober
665 1.14 ober pxa2x0_lcd_initialize(NULL, pxa2x0_lcd_console.geometry);
666 1.14 ober
667 1.14 ober error = pxa2x0_lcd_new_screen(NULL, &pxa2x0_lcd_console.scr,
668 1.14 ober descr->depth);
669 1.14 ober if (error)
670 1.14 ober return error;
671 1.14 ober
672 1.14 ober ri = &pxa2x0_lcd_console.scr.rinfo;
673 1.14 ober ri->ri_hw = (void *)&pxa2x0_lcd_console.scr;
674 1.14 ober ri->ri_bits = pxa2x0_lcd_console.scr.buf_va;
675 1.14 ober pxa2x0_lcd_setup_rasops(ri, descr, pxa2x0_lcd_console.geometry);
676 1.14 ober
677 1.14 ober /* assumes 16 bpp */
678 1.14 ober (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
679 1.14 ober
680 1.14 ober pxa2x0_lcd_start_dma(NULL, &pxa2x0_lcd_console.scr);
681 1.14 ober
682 1.14 ober wsdisplay_cnattach(&descr->c, ri, ri->ri_ccol, ri->ri_crow, defattr);
683 1.14 ober
684 1.14 ober return 0;
685 1.14 ober }
686 1.14 ober
687 1.14 ober /*
688 1.14 ober * Do the necessary accounting to bring the console variables in the softc.
689 1.14 ober */
690 1.14 ober void
691 1.14 ober pxa2x0_lcd_setup_console(struct pxa2x0_lcd_softc *sc,
692 1.14 ober const struct pxa2x0_wsscreen_descr *descr)
693 1.14 ober {
694 1.14 ober struct pxa2x0_lcd_screen *scr = &pxa2x0_lcd_console.scr;
695 1.14 ober
696 1.14 ober /*
697 1.14 ober * Register the console screen as if it had been created
698 1.14 ober * when the lcd device attached.
699 1.14 ober */
700 1.14 ober LIST_INSERT_HEAD(&(sc->screens), &pxa2x0_lcd_console.scr, link);
701 1.14 ober sc->n_screens++;
702 1.14 ober sc->active = scr;
703 1.14 ober }
704 1.14 ober
705 1.14 ober /*
706 1.14 ober * Power management
707 1.14 ober */
708 1.14 ober void
709 1.14 ober pxa2x0_lcd_suspend(struct pxa2x0_lcd_softc *sc)
710 1.14 ober {
711 1.14 ober
712 1.14 ober if (sc->active != NULL) {
713 1.14 ober pxa2x0_lcd_stop_dma(sc);
714 1.14 ober pxa2x0_clkman_config(CKEN_LCD, 0);
715 1.14 ober }
716 1.14 ober }
717 1.14 ober
718 1.14 ober void
719 1.14 ober pxa2x0_lcd_resume(struct pxa2x0_lcd_softc *sc)
720 1.14 ober {
721 1.14 ober
722 1.14 ober if (sc->active != NULL) {
723 1.14 ober pxa2x0_lcd_initialize(sc, sc->geometry);
724 1.14 ober pxa2x0_lcd_start_dma(sc, sc->active);
725 1.14 ober }
726 1.1 bsh }
727 1.1 bsh
728 1.14 ober void
729 1.14 ober pxa2x0_lcd_power(int why, void *v)
730 1.14 ober {
731 1.14 ober struct pxa2x0_lcd_softc *sc = v;
732 1.14 ober
733 1.14 ober switch (why) {
734 1.14 ober case PWR_SUSPEND:
735 1.14 ober case PWR_STANDBY:
736 1.14 ober pxa2x0_lcd_suspend(sc);
737 1.14 ober break;
738 1.14 ober
739 1.14 ober case PWR_RESUME:
740 1.14 ober pxa2x0_lcd_resume(sc);
741 1.14 ober break;
742 1.14 ober }
743 1.14 ober }
744 1.1 bsh
745 1.1 bsh #if NWSDISPLAY > 0
746 1.1 bsh /*
747 1.1 bsh * Initialize struct wsscreen_descr based on values calculated by
748 1.1 bsh * raster operation subsystem.
749 1.1 bsh */
750 1.1 bsh int
751 1.1 bsh pxa2x0_lcd_setup_wsscreen(struct pxa2x0_wsscreen_descr *descr,
752 1.1 bsh const struct lcd_panel_geometry *geom,
753 1.4 bsh const char *fontname)
754 1.1 bsh {
755 1.1 bsh int width = geom->panel_width;
756 1.1 bsh int height = geom->panel_height;
757 1.1 bsh int cookie = -1;
758 1.1 bsh struct rasops_info rinfo;
759 1.1 bsh
760 1.4 bsh memset(&rinfo, 0, sizeof rinfo);
761 1.1 bsh
762 1.4 bsh if (fontname) {
763 1.1 bsh wsfont_init();
764 1.9 he cookie = wsfont_find(fontname, 0, 0, 0,
765 1.4 bsh WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R);
766 1.4 bsh if (cookie < 0 ||
767 1.4 bsh wsfont_lock(cookie, &rinfo.ri_font))
768 1.1 bsh return -1;
769 1.1 bsh }
770 1.1 bsh else {
771 1.1 bsh /* let rasops_init() choose any font */
772 1.1 bsh }
773 1.1 bsh
774 1.1 bsh /* let rasops_init calculate # of cols and rows in character */
775 1.1 bsh rinfo.ri_flg = 0;
776 1.1 bsh rinfo.ri_depth = descr->depth;
777 1.1 bsh rinfo.ri_bits = NULL;
778 1.1 bsh rinfo.ri_width = width;
779 1.1 bsh rinfo.ri_height = height;
780 1.1 bsh rinfo.ri_stride = width * rinfo.ri_depth / 8;
781 1.10 bsh #ifdef CPU_XSCALE_PXA270
782 1.10 bsh if (rinfo.ri_depth > 16) rinfo.ri_stride = width * 4;
783 1.10 bsh #endif
784 1.1 bsh rinfo.ri_wsfcookie = cookie;
785 1.1 bsh
786 1.4 bsh rasops_init(&rinfo, 100, 100);
787 1.1 bsh
788 1.1 bsh descr->c.nrows = rinfo.ri_rows;
789 1.1 bsh descr->c.ncols = rinfo.ri_cols;
790 1.1 bsh descr->c.capabilities = rinfo.ri_caps;
791 1.1 bsh
792 1.1 bsh return cookie;
793 1.1 bsh }
794 1.1 bsh
795 1.1 bsh int
796 1.1 bsh pxa2x0_lcd_show_screen(void *v, void *cookie, int waitok,
797 1.1 bsh void (*cb)(void *, int, int), void *cbarg)
798 1.1 bsh {
799 1.1 bsh struct pxa2x0_lcd_softc *sc = v;
800 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie, *old;
801 1.1 bsh
802 1.1 bsh old = sc->active;
803 1.4 bsh if (old == scr)
804 1.1 bsh return 0;
805 1.1 bsh
806 1.4 bsh if (old)
807 1.4 bsh pxa2x0_lcd_stop_dma(sc);
808 1.1 bsh
809 1.4 bsh pxa2x0_lcd_start_dma(sc, scr);
810 1.1 bsh
811 1.1 bsh sc->active = scr;
812 1.1 bsh return 0;
813 1.1 bsh }
814 1.1 bsh
815 1.1 bsh int
816 1.1 bsh pxa2x0_lcd_alloc_screen(void *v, const struct wsscreen_descr *_type,
817 1.1 bsh void **cookiep, int *curxp, int *curyp, long *attrp)
818 1.1 bsh {
819 1.1 bsh struct pxa2x0_lcd_softc *sc = v;
820 1.1 bsh struct pxa2x0_lcd_screen *scr;
821 1.9 he const struct pxa2x0_wsscreen_descr *type =
822 1.9 he (const struct pxa2x0_wsscreen_descr *)_type;
823 1.14 ober int error;
824 1.1 bsh
825 1.14 ober scr = malloc(sizeof *scr, M_DEVBUF, (cold ? M_NOWAIT : M_WAITOK));
826 1.4 bsh if (scr == NULL)
827 1.14 ober return (ENOMEM);
828 1.14 ober
829 1.14 ober error = pxa2x0_lcd_new_screen(sc, scr, type->depth);
830 1.14 ober if (error != 0) {
831 1.14 ober free(scr, M_DEVBUF);
832 1.14 ober return (error);
833 1.14 ober }
834 1.14 ober
835 1.1 bsh /*
836 1.1 bsh * initialize raster operation for this screen.
837 1.1 bsh */
838 1.1 bsh scr->rinfo.ri_flg = 0;
839 1.1 bsh scr->rinfo.ri_depth = type->depth;
840 1.1 bsh scr->rinfo.ri_bits = scr->buf_va;
841 1.1 bsh scr->rinfo.ri_width = sc->geometry->panel_width;
842 1.1 bsh scr->rinfo.ri_height = sc->geometry->panel_height;
843 1.1 bsh scr->rinfo.ri_stride = scr->rinfo.ri_width * scr->rinfo.ri_depth / 8;
844 1.10 bsh #ifdef CPU_XSCALE_PXA270
845 1.10 bsh if (scr->rinfo.ri_depth > 16)
846 1.10 bsh scr->rinfo.ri_stride = scr->rinfo.ri_width * 4;
847 1.10 bsh #endif
848 1.1 bsh scr->rinfo.ri_wsfcookie = -1; /* XXX */
849 1.1 bsh
850 1.4 bsh rasops_init(&scr->rinfo, type->c.nrows, type->c.ncols);
851 1.1 bsh
852 1.4 bsh (* scr->rinfo.ri_ops.allocattr)(&scr->rinfo, 0, 0, 0, attrp);
853 1.1 bsh
854 1.1 bsh *cookiep = scr;
855 1.1 bsh *curxp = 0;
856 1.1 bsh *curyp = 0;
857 1.1 bsh
858 1.1 bsh return 0;
859 1.1 bsh }
860 1.1 bsh
861 1.1 bsh void
862 1.1 bsh pxa2x0_lcd_free_screen(void *v, void *cookie)
863 1.1 bsh {
864 1.1 bsh struct pxa2x0_lcd_softc *sc = v;
865 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
866 1.1 bsh
867 1.4 bsh LIST_REMOVE(scr, link);
868 1.1 bsh sc->n_screens--;
869 1.4 bsh if (scr == sc->active) {
870 1.1 bsh /* at first, we need to stop LCD DMA */
871 1.1 bsh sc->active = NULL;
872 1.1 bsh
873 1.4 bsh printf("lcd_free on active screen\n");
874 1.1 bsh
875 1.1 bsh pxa2x0_lcd_stop_dma(sc);
876 1.1 bsh }
877 1.1 bsh
878 1.4 bsh if (scr->buf_va)
879 1.4 bsh bus_dmamem_unmap(sc->dma_tag, scr->buf_va, scr->map_size);
880 1.1 bsh
881 1.4 bsh if (scr->nsegs > 0)
882 1.4 bsh bus_dmamem_free(sc->dma_tag, scr->segs, scr->nsegs);
883 1.1 bsh
884 1.4 bsh free(scr, M_DEVBUF);
885 1.1 bsh }
886 1.1 bsh
887 1.1 bsh int
888 1.13 jmmv pxa2x0_lcd_ioctl(void *v, void *vs, u_long cmd, caddr_t data, int flag,
889 1.13 jmmv struct lwp *l)
890 1.1 bsh {
891 1.1 bsh struct pxa2x0_lcd_softc *sc = v;
892 1.1 bsh struct wsdisplay_fbinfo *wsdisp_info;
893 1.1 bsh uint32_t ccr0;
894 1.1 bsh
895 1.1 bsh switch (cmd) {
896 1.1 bsh case WSDISPLAYIO_GTYPE:
897 1.1 bsh *(u_int *)data = WSDISPLAY_TYPE_UNKNOWN; /* XXX */
898 1.1 bsh return 0;
899 1.1 bsh
900 1.1 bsh case WSDISPLAYIO_GINFO:
901 1.1 bsh wsdisp_info = (struct wsdisplay_fbinfo *)data;
902 1.1 bsh
903 1.1 bsh wsdisp_info->height = sc->geometry->panel_height;
904 1.1 bsh wsdisp_info->width = sc->geometry->panel_width;
905 1.10 bsh wsdisp_info->depth = sc->active->depth;
906 1.1 bsh wsdisp_info->cmsize = 0;
907 1.1 bsh return 0;
908 1.1 bsh
909 1.1 bsh case WSDISPLAYIO_GETCMAP:
910 1.1 bsh case WSDISPLAYIO_PUTCMAP:
911 1.1 bsh return EPASSTHROUGH; /* XXX Colormap */
912 1.1 bsh
913 1.1 bsh case WSDISPLAYIO_SVIDEO:
914 1.4 bsh if (*(int *)data == WSDISPLAYIO_VIDEO_ON) {
915 1.1 bsh /* turn it on */
916 1.1 bsh }
917 1.1 bsh else {
918 1.1 bsh /* start LCD shutdown */
919 1.1 bsh /* sleep until interrupt */
920 1.1 bsh }
921 1.1 bsh return 0;
922 1.1 bsh
923 1.1 bsh case WSDISPLAYIO_GVIDEO:
924 1.4 bsh ccr0 = bus_space_read_4(sc->iot, sc->ioh, LCDC_LCCR0);
925 1.1 bsh *(u_int *)data = (ccr0 & (LCCR0_ENB|LCCR0_DIS)) == LCCR0_ENB ?
926 1.1 bsh WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF;
927 1.1 bsh return 0;
928 1.1 bsh
929 1.1 bsh case WSDISPLAYIO_GCURPOS:
930 1.1 bsh case WSDISPLAYIO_SCURPOS:
931 1.1 bsh case WSDISPLAYIO_GCURMAX:
932 1.1 bsh case WSDISPLAYIO_GCURSOR:
933 1.1 bsh case WSDISPLAYIO_SCURSOR:
934 1.1 bsh return EPASSTHROUGH; /* XXX */
935 1.1 bsh }
936 1.1 bsh
937 1.1 bsh return EPASSTHROUGH;
938 1.1 bsh }
939 1.1 bsh
940 1.1 bsh paddr_t
941 1.13 jmmv pxa2x0_lcd_mmap(void *v, void *vs, off_t offset, int prot)
942 1.1 bsh {
943 1.1 bsh struct pxa2x0_lcd_softc *sc = v;
944 1.1 bsh struct pxa2x0_lcd_screen *screen = sc->active; /* ??? */
945 1.1 bsh
946 1.4 bsh if (screen == NULL)
947 1.1 bsh return -1;
948 1.1 bsh
949 1.4 bsh return bus_dmamem_mmap(sc->dma_tag, screen->segs, screen->nsegs,
950 1.4 bsh offset, prot, BUS_DMA_WAITOK|BUS_DMA_COHERENT);
951 1.1 bsh return -1;
952 1.1 bsh }
953 1.1 bsh
954 1.1 bsh
955 1.1 bsh static void
956 1.4 bsh pxa2x0_lcd_cursor(void *cookie, int on, int row, int col)
957 1.1 bsh {
958 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
959 1.1 bsh
960 1.4 bsh (* scr->rinfo.ri_ops.cursor)(&scr->rinfo, on, row, col);
961 1.1 bsh }
962 1.1 bsh
963 1.1 bsh static int
964 1.4 bsh pxa2x0_lcd_mapchar(void *cookie, int c, unsigned int *cp)
965 1.1 bsh {
966 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
967 1.1 bsh
968 1.4 bsh return (* scr->rinfo.ri_ops.mapchar)(&scr->rinfo, c, cp);
969 1.1 bsh }
970 1.1 bsh
971 1.1 bsh static void
972 1.4 bsh pxa2x0_lcd_putchar(void *cookie, int row, int col, u_int uc, long attr)
973 1.1 bsh {
974 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
975 1.1 bsh
976 1.4 bsh (* scr->rinfo.ri_ops.putchar)(&scr->rinfo,
977 1.4 bsh row, col, uc, attr);
978 1.1 bsh }
979 1.1 bsh
980 1.1 bsh static void
981 1.4 bsh pxa2x0_lcd_copycols(void *cookie, int row, int src, int dst, int num)
982 1.1 bsh {
983 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
984 1.1 bsh
985 1.4 bsh (* scr->rinfo.ri_ops.copycols)(&scr->rinfo,
986 1.4 bsh row, src, dst, num);
987 1.1 bsh }
988 1.1 bsh
989 1.1 bsh static void
990 1.4 bsh pxa2x0_lcd_erasecols(void *cookie, int row, int col, int num, long attr)
991 1.1 bsh {
992 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
993 1.1 bsh
994 1.4 bsh (* scr->rinfo.ri_ops.erasecols)(&scr->rinfo,
995 1.4 bsh row, col, num, attr);
996 1.1 bsh }
997 1.1 bsh
998 1.1 bsh static void
999 1.4 bsh pxa2x0_lcd_copyrows(void *cookie, int src, int dst, int num)
1000 1.1 bsh {
1001 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
1002 1.1 bsh
1003 1.4 bsh (* scr->rinfo.ri_ops.copyrows)(&scr->rinfo,
1004 1.4 bsh src, dst, num);
1005 1.1 bsh }
1006 1.1 bsh
1007 1.1 bsh static void
1008 1.4 bsh pxa2x0_lcd_eraserows(void *cookie, int row, int num, long attr)
1009 1.1 bsh {
1010 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
1011 1.1 bsh
1012 1.4 bsh (* scr->rinfo.ri_ops.eraserows)(&scr->rinfo,
1013 1.4 bsh row, num, attr);
1014 1.1 bsh }
1015 1.1 bsh
1016 1.1 bsh static int
1017 1.4 bsh pxa2x0_lcd_alloc_attr(void *cookie, int fg, int bg, int flg, long *attr)
1018 1.1 bsh {
1019 1.1 bsh struct pxa2x0_lcd_screen *scr = cookie;
1020 1.1 bsh
1021 1.4 bsh return (* scr->rinfo.ri_ops.allocattr)(&scr->rinfo,
1022 1.4 bsh fg, bg, flg, attr);
1023 1.1 bsh }
1024 1.1 bsh
1025 1.1 bsh
1026 1.1 bsh const struct wsdisplay_emulops pxa2x0_lcd_emulops = {
1027 1.1 bsh pxa2x0_lcd_cursor,
1028 1.1 bsh pxa2x0_lcd_mapchar,
1029 1.1 bsh pxa2x0_lcd_putchar,
1030 1.1 bsh pxa2x0_lcd_copycols,
1031 1.1 bsh pxa2x0_lcd_erasecols,
1032 1.1 bsh pxa2x0_lcd_copyrows,
1033 1.1 bsh pxa2x0_lcd_eraserows,
1034 1.1 bsh pxa2x0_lcd_alloc_attr
1035 1.1 bsh };
1036 1.1 bsh
1037 1.1 bsh #endif /* NWSDISPLAY > 0 */
1038