Home | History | Annotate | Line # | Download | only in s3c2xx0
s3c24x0_lcd.c revision 1.9
      1  1.9  nisimura /* $NetBSD: s3c24x0_lcd.c,v 1.9 2012/01/30 03:28:33 nisimura Exp $ */
      2  1.1       bsh 
      3  1.1       bsh /*
      4  1.1       bsh  * Copyright (c) 2004  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. The name of Genetec Corporation may not be used to endorse or
     16  1.1       bsh  *    promote products derived from this software without specific prior
     17  1.1       bsh  *    written permission.
     18  1.1       bsh  *
     19  1.1       bsh  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     20  1.1       bsh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1       bsh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1       bsh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     23  1.1       bsh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1       bsh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1       bsh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1       bsh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1       bsh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1       bsh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1       bsh  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1       bsh  */
     31  1.1       bsh 
     32  1.1       bsh /*
     33  1.1       bsh  * Support S3C24[10]0's integrated LCD controller.
     34  1.1       bsh  */
     35  1.1       bsh 
     36  1.1       bsh #include <sys/cdefs.h>
     37  1.9  nisimura __KERNEL_RCSID(0, "$NetBSD: s3c24x0_lcd.c,v 1.9 2012/01/30 03:28:33 nisimura Exp $");
     38  1.1       bsh 
     39  1.1       bsh #include <sys/param.h>
     40  1.1       bsh #include <sys/systm.h>
     41  1.1       bsh #include <sys/conf.h>
     42  1.1       bsh #include <sys/uio.h>
     43  1.1       bsh #include <sys/malloc.h>
     44  1.1       bsh #include <sys/kernel.h>			/* for cold */
     45  1.1       bsh 
     46  1.1       bsh #include <uvm/uvm_extern.h>
     47  1.1       bsh 
     48  1.1       bsh #include <dev/cons.h>
     49  1.1       bsh #include <dev/wscons/wsconsio.h>
     50  1.1       bsh #include <dev/wscons/wsdisplayvar.h>
     51  1.1       bsh #include <dev/wscons/wscons_callbacks.h>
     52  1.1       bsh #include <dev/rasops/rasops.h>
     53  1.1       bsh #include <dev/wsfont/wsfont.h>
     54  1.1       bsh 
     55  1.9  nisimura #include <dev/hpc/hpcfbio.h>
     56  1.9  nisimura 
     57  1.7    dyoung #include <sys/bus.h>
     58  1.1       bsh #include <machine/cpu.h>
     59  1.1       bsh #include <arm/cpufunc.h>
     60  1.1       bsh 
     61  1.1       bsh #include <arm/s3c2xx0/s3c24x0var.h>
     62  1.1       bsh #include <arm/s3c2xx0/s3c24x0reg.h>
     63  1.1       bsh #include <arm/s3c2xx0/s3c24x0_lcd.h>
     64  1.1       bsh 
     65  1.1       bsh #include "wsdisplay.h"
     66  1.1       bsh 
     67  1.1       bsh int lcdintr(void *);
     68  1.1       bsh static void init_palette(struct s3c24x0_lcd_softc *,
     69  1.1       bsh     struct s3c24x0_lcd_screen *);
     70  1.1       bsh 
     71  1.1       bsh #ifdef LCD_DEBUG
     72  1.1       bsh static void
     73  1.1       bsh dump_lcdcon(const char *title, bus_space_tag_t iot, bus_space_handle_t ioh)
     74  1.1       bsh {
     75  1.1       bsh 	int i;
     76  1.1       bsh 
     77  1.1       bsh 	printf("%s\n", title);
     78  1.1       bsh 	for(i=LCDC_LCDCON1; i <= LCDC_LCDSADDR3; i+=4) {
     79  1.1       bsh 		if (i%16 == 0)
     80  1.1       bsh 			printf("\n%03x: ", i);
     81  1.1       bsh 		printf("%08x ", bus_space_read_4(iot, ioh, i));
     82  1.1       bsh 	}
     83  1.1       bsh 
     84  1.1       bsh 	printf("\n");
     85  1.1       bsh }
     86  1.1       bsh 
     87  1.1       bsh void draw_test_pattern(struct s3c24x0_lcd_softc *,
     88  1.1       bsh 	    struct s3c24x0_lcd_screen *scr);
     89  1.1       bsh 
     90  1.1       bsh #endif
     91  1.1       bsh 
     92  1.1       bsh void
     93  1.1       bsh s3c24x0_set_lcd_panel_info(struct s3c24x0_lcd_softc *sc,
     94  1.1       bsh     const struct s3c24x0_lcd_panel_info *info)
     95  1.1       bsh {
     96  1.1       bsh 	bus_space_tag_t iot = sc->iot;
     97  1.1       bsh 	bus_space_handle_t ioh = sc->ioh;
     98  1.1       bsh 	uint32_t reg;
     99  1.1       bsh 	int clkval;
    100  1.1       bsh 	int tft = s3c24x0_lcd_panel_tft(info);
    101  1.1       bsh 	int hclk = s3c2xx0_softc->sc_hclk;
    102  1.1       bsh 
    103  1.1       bsh 	sc->panel_info = info;
    104  1.1       bsh 
    105  1.1       bsh 	/* Set LCDCON1. BPPMODE and ENVID are set later */
    106  1.1       bsh 	if (tft)
    107  1.1       bsh 		clkval = (hclk / info->pixel_clock  / 2) - 1;
    108  1.1       bsh 	else {
    109  1.1       bsh 		/* STN display */
    110  1.1       bsh 		clkval = max(2, hclk / info->pixel_clock / 2);
    111  1.1       bsh 	}
    112  1.1       bsh 
    113  1.1       bsh 	reg =  (info->lcdcon1 & ~LCDCON1_CLKVAL_MASK) |
    114  1.1       bsh 		(clkval << LCDCON1_CLKVAL_SHIFT);
    115  1.1       bsh 	reg &= ~LCDCON1_ENVID;
    116  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON1, reg);
    117  1.1       bsh 
    118  1.1       bsh #if 0
    119  1.1       bsh 	printf("hclk=%d pixel clock=%d, clkval = %x lcdcon1=%x\n",
    120  1.1       bsh 	    hclk, info->pixel_clock, clkval, reg);
    121  1.1       bsh #endif
    122  1.1       bsh 
    123  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON2, info->lcdcon2);
    124  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON3, info->lcdcon3);
    125  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON4, info->lcdcon4);
    126  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON5, info->lcdcon5);
    127  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LPCSEL, info->lpcsel);
    128  1.1       bsh }
    129  1.1       bsh 
    130  1.1       bsh void
    131  1.1       bsh s3c24x0_lcd_attach_sub(struct s3c24x0_lcd_softc *sc,
    132  1.1       bsh     struct s3c2xx0_attach_args *sa,
    133  1.1       bsh     const struct s3c24x0_lcd_panel_info *panel_info)
    134  1.1       bsh {
    135  1.1       bsh 	bus_space_tag_t iot = sa->sa_iot;
    136  1.1       bsh 	bus_space_handle_t ioh;
    137  1.1       bsh 	int error;
    138  1.1       bsh 
    139  1.1       bsh 	sc->n_screens = 0;
    140  1.1       bsh 	LIST_INIT(&sc->screens);
    141  1.1       bsh 
    142  1.1       bsh 	/* map controller registers */
    143  1.1       bsh 	error = bus_space_map(iot, sa->sa_addr, S3C24X0_LCDC_SIZE, 0, &ioh);
    144  1.1       bsh 	if (error) {
    145  1.1       bsh 		printf(": failed to map registers %d", error);
    146  1.1       bsh 		return;
    147  1.1       bsh 	}
    148  1.1       bsh 
    149  1.1       bsh 	sc->iot = iot;
    150  1.1       bsh 	sc->ioh = ioh;
    151  1.1       bsh 	sc->dma_tag = sa->sa_dmat;
    152  1.1       bsh 
    153  1.1       bsh #ifdef notyet
    154  1.1       bsh 	sc->ih = s3c24x0_intr_establish(sa->sa_intr, IPL_BIO, lcdintr, sc);
    155  1.1       bsh 	if (sc->ih == NULL)
    156  1.1       bsh 		printf("%s: unable to establish interrupt at irq %d",
    157  1.1       bsh 		    sc->dev.dv_xname, sa->sa_intr);
    158  1.1       bsh #endif
    159  1.1       bsh 
    160  1.1       bsh 	/* mask LCD interrupts */
    161  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDINTMSK, LCDINT_FICNT|LCDINT_FRSYN);
    162  1.1       bsh 
    163  1.1       bsh 	/* Initialize controller registers based on panel geometry*/
    164  1.1       bsh 	s3c24x0_set_lcd_panel_info(sc, panel_info);
    165  1.1       bsh 
    166  1.1       bsh 	/* XXX: enable clock to LCD controller */
    167  1.1       bsh }
    168  1.1       bsh 
    169  1.1       bsh 
    170  1.1       bsh #ifdef notyet
    171  1.1       bsh int
    172  1.1       bsh lcdintr(void *arg)
    173  1.1       bsh {
    174  1.1       bsh 	struct s3c24x0_lcd_softc *sc = arg;
    175  1.1       bsh 	bus_space_tag_t iot = sc->iot;
    176  1.1       bsh 	bus_space_handle_t ioh = sc->ioh;
    177  1.1       bsh 
    178  1.1       bsh 	static uint32_t status;
    179  1.1       bsh 
    180  1.1       bsh 	return 1;
    181  1.1       bsh }
    182  1.1       bsh #endif
    183  1.1       bsh 
    184  1.1       bsh int
    185  1.1       bsh s3c24x0_lcd_start_dma(struct s3c24x0_lcd_softc *sc,
    186  1.1       bsh     struct s3c24x0_lcd_screen *scr)
    187  1.1       bsh {
    188  1.1       bsh 	bus_space_tag_t iot = sc->iot;
    189  1.1       bsh 	bus_space_handle_t ioh = sc->ioh;
    190  1.1       bsh 	const struct s3c24x0_lcd_panel_info *info = sc->panel_info;
    191  1.1       bsh 	int tft = s3c24x0_lcd_panel_tft(info);
    192  1.1       bsh 	int dual_panel =
    193  1.1       bsh 	    (info->lcdcon1 & LCDCON1_PNRMODE_MASK) == LCDCON1_PNRMODE_DUALSTN4;
    194  1.1       bsh 	uint32_t lcdcon1, val;
    195  1.1       bsh 	paddr_t pa;
    196  1.1       bsh 	int depth = scr->depth;
    197  1.1       bsh 	int stride = scr->stride;
    198  1.1       bsh 	int panel_height = info->panel_height;
    199  1.1       bsh 	int panel_width = info->panel_width;
    200  1.1       bsh 	int offsize;
    201  1.1       bsh 
    202  1.1       bsh 	switch (depth) {
    203  1.1       bsh 	case 1: val = LCDCON1_BPPMODE_STN1; break;
    204  1.1       bsh 	case 2: val = LCDCON1_BPPMODE_STN2; break;
    205  1.1       bsh 	case 4: val = LCDCON1_BPPMODE_STN4; break;
    206  1.1       bsh 	case 8: val = LCDCON1_BPPMODE_STN8; break;
    207  1.1       bsh 	case 12:
    208  1.1       bsh 		if (tft)
    209  1.1       bsh 			return -1;
    210  1.1       bsh 		val = LCDCON1_BPPMODE_STN12;
    211  1.1       bsh 		break;
    212  1.1       bsh 	case 16:
    213  1.1       bsh 		if (!tft)
    214  1.1       bsh 			return -1;
    215  1.1       bsh 		val = LCDCON1_BPPMODE_TFT16;
    216  1.1       bsh 		break;
    217  1.1       bsh 	case 24:
    218  1.1       bsh 		if (!tft)
    219  1.1       bsh 			return -1;
    220  1.1       bsh 		val = LCDCON1_BPPMODE_TFT24;
    221  1.1       bsh 		break;
    222  1.1       bsh 	default:
    223  1.1       bsh 		return -1;
    224  1.1       bsh 	}
    225  1.1       bsh 
    226  1.1       bsh 	if (tft)
    227  1.1       bsh 		val |= LCDCON1_BPPMODE_TFTX;
    228  1.1       bsh 
    229  1.1       bsh 	lcdcon1 = bus_space_read_4(iot, ioh, LCDC_LCDCON1);
    230  1.1       bsh 	lcdcon1 &= ~(LCDCON1_BPPMODE_MASK|LCDCON1_ENVID);
    231  1.1       bsh 	lcdcon1 |= val;
    232  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON1, lcdcon1);
    233  1.1       bsh 
    234  1.1       bsh 	/* Adjust LCDCON3.HOZVAL to meet with restriction */
    235  1.1       bsh 	val = roundup(panel_width, 16 / depth);
    236  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON3,
    237  1.1       bsh 	    (info->lcdcon3 & ~LCDCON3_HOZVAL_MASK) |
    238  1.1       bsh 	    (val - 1) << LCDCON3_HOZVAL_SHIFT);
    239  1.1       bsh 
    240  1.1       bsh 	pa = scr->segs[0].ds_addr;
    241  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDSADDR1, pa >> 1);
    242  1.1       bsh 
    243  1.1       bsh 	if (dual_panel) {
    244  1.1       bsh 		/* XXX */
    245  1.1       bsh 	}
    246  1.1       bsh 	else {
    247  1.1       bsh 		pa += stride * panel_height;
    248  1.1       bsh 		bus_space_write_4(iot, ioh, LCDC_LCDSADDR2, pa >> 1);
    249  1.1       bsh 	}
    250  1.1       bsh 
    251  1.1       bsh 	offsize = stride / sizeof (uint16_t) - (panel_width * depth / 16);
    252  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDSADDR3,
    253  1.1       bsh 	    (offsize << LCDSADDR3_OFFSIZE_SHIFT) |
    254  1.1       bsh 	    (panel_width * depth / 16));
    255  1.1       bsh 
    256  1.1       bsh 	/* set byte- or halfword- swap based on the depth */
    257  1.1       bsh 	val = bus_space_read_4(iot, ioh, LCDC_LCDCON5);
    258  1.1       bsh 	val &= ~(LCDCON5_BSWP|LCDCON5_HWSWP);
    259  1.1       bsh 	switch(depth) {
    260  1.1       bsh 	case 2:
    261  1.1       bsh 	case 4:
    262  1.1       bsh 	case 8:
    263  1.1       bsh 		val |= LCDCON5_BSWP;
    264  1.1       bsh 		break;
    265  1.1       bsh 	case 16:
    266  1.1       bsh 		val |= LCDCON5_HWSWP;
    267  1.1       bsh 		break;
    268  1.1       bsh 	}
    269  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON5, val);
    270  1.1       bsh 
    271  1.1       bsh 
    272  1.1       bsh 	init_palette(sc, scr);
    273  1.1       bsh 
    274  1.1       bsh #if 0
    275  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_TPAL, TPAL_TPALEN|
    276  1.1       bsh 	    (0xff<<TPAL_BLUE_SHIFT));
    277  1.1       bsh #endif
    278  1.1       bsh 
    279  1.1       bsh 	/* Enable LCDC */
    280  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON1, lcdcon1 | LCDCON1_ENVID);
    281  1.1       bsh 
    282  1.1       bsh 	sc->lcd_on = 1;
    283  1.1       bsh 
    284  1.1       bsh #ifdef LCD_DEBUG
    285  1.6     perry 	dump_lcdcon(__func__, iot, ioh);
    286  1.1       bsh #endif
    287  1.1       bsh 
    288  1.1       bsh 	return 0;
    289  1.1       bsh }
    290  1.1       bsh 
    291  1.1       bsh void
    292  1.1       bsh s3c24x0_lcd_power(struct s3c24x0_lcd_softc *sc, int on)
    293  1.1       bsh {
    294  1.1       bsh 	bus_space_tag_t iot = sc->iot;
    295  1.1       bsh 	bus_space_handle_t ioh = sc->ioh;
    296  1.1       bsh 	uint32_t reg;
    297  1.1       bsh 
    298  1.1       bsh 	reg = bus_space_read_4(iot, ioh, LCDC_LCDCON5);
    299  1.1       bsh 
    300  1.1       bsh 	if (on)
    301  1.1       bsh 		reg |= LCDCON5_PWREN;
    302  1.1       bsh 	else
    303  1.1       bsh 		reg &= ~LCDCON5_PWREN;
    304  1.1       bsh 
    305  1.1       bsh 	bus_space_write_4(iot, ioh, LCDC_LCDCON5, reg);
    306  1.1       bsh }
    307  1.1       bsh 
    308  1.1       bsh struct s3c24x0_lcd_screen *
    309  1.1       bsh s3c24x0_lcd_new_screen(struct s3c24x0_lcd_softc *sc,
    310  1.1       bsh     int virtual_width, int virtual_height, int depth)
    311  1.1       bsh {
    312  1.1       bsh 	struct s3c24x0_lcd_screen *scr = NULL;
    313  1.1       bsh 	int width, height;
    314  1.1       bsh 	bus_size_t size;
    315  1.1       bsh         int error, pallet_size;
    316  1.1       bsh 	int busdma_flag = (cold ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK) |
    317  1.1       bsh 	    BUS_DMA_WRITE;
    318  1.1       bsh 	paddr_t align;
    319  1.1       bsh 	const struct s3c24x0_lcd_panel_info *panel_info = sc->panel_info;
    320  1.1       bsh 
    321  1.1       bsh 
    322  1.9  nisimura #if 0 /* Does this make any sense? */
    323  1.1       bsh #ifdef DIAGNOSTIC
    324  1.1       bsh 	if (size > 1 << 22) {
    325  1.1       bsh 		aprint_error("%s: too big screen size\n", sc->dev.dv_xname);
    326  1.1       bsh 		return NULL;
    327  1.1       bsh 	}
    328  1.1       bsh #endif
    329  1.9  nisimura #endif
    330  1.1       bsh 
    331  1.1       bsh 	width = panel_info->panel_width;
    332  1.1       bsh 	height = panel_info->panel_height;
    333  1.1       bsh 	pallet_size = 0;
    334  1.1       bsh 
    335  1.1       bsh 	switch (depth) {
    336  1.1       bsh 	case 1: case 2: case 4: case 8:
    337  1.1       bsh 		virtual_width = roundup(virtual_width, 16 / depth);
    338  1.1       bsh 		break;
    339  1.1       bsh 	case 16:
    340  1.1       bsh 		break;
    341  1.1       bsh 	case 12: case 24:
    342  1.1       bsh 	default:
    343  1.1       bsh 		aprint_error("%s: Unknown depth (%d)\n",
    344  1.9  nisimura 		    device_xname(sc->sc_dev), depth);
    345  1.1       bsh 		return NULL;
    346  1.1       bsh 	}
    347  1.1       bsh 
    348  1.9  nisimura 	scr = malloc(sizeof *scr, M_DEVBUF,
    349  1.1       bsh 	    M_ZERO | (cold ? M_NOWAIT : M_WAITOK));
    350  1.1       bsh 
    351  1.1       bsh 	if (scr == NULL)
    352  1.1       bsh 		return NULL;
    353  1.1       bsh 
    354  1.1       bsh 	scr->nsegs = 0;
    355  1.1       bsh 	scr->depth = depth;
    356  1.1       bsh 	scr->stride = virtual_width * depth / 8;
    357  1.1       bsh 	scr->buf_size = size = scr->stride * virtual_height;
    358  1.1       bsh 	scr->buf_va = NULL;
    359  1.1       bsh 
    360  1.1       bsh 	/* calculate the alignment for LCD frame buffer.
    361  1.1       bsh 	   the buffer can't across 4MB boundary */
    362  1.1       bsh 	align = 1 << 20;
    363  1.1       bsh 	while (align < size)
    364  1.1       bsh 		align <<= 1;
    365  1.1       bsh 
    366  1.9  nisimura 	printf("%s: Allocating LCD frame buffer of size %ld\n",
    367  1.9  nisimura 	       device_xname(sc->sc_dev), size);
    368  1.9  nisimura 
    369  1.1       bsh         error = bus_dmamem_alloc(sc->dma_tag, size, align, 0,
    370  1.1       bsh 	    scr->segs, 1, &(scr->nsegs), busdma_flag);
    371  1.1       bsh 
    372  1.1       bsh         if (error || scr->nsegs != 1)
    373  1.1       bsh 		goto bad;
    374  1.1       bsh 
    375  1.1       bsh 	error = bus_dmamem_map(sc->dma_tag, scr->segs, scr->nsegs,
    376  1.5  christos 	    size, (void **)&(scr->buf_va), busdma_flag | BUS_DMA_COHERENT);
    377  1.1       bsh 	if (error)
    378  1.1       bsh 		goto bad;
    379  1.1       bsh 
    380  1.1       bsh 
    381  1.1       bsh 	memset (scr->buf_va, 0, scr->buf_size);
    382  1.1       bsh 
    383  1.1       bsh 	/* map memory for DMA */
    384  1.1       bsh 	if (bus_dmamap_create(sc->dma_tag, 1024*1024*2, 1,
    385  1.1       bsh 	    1024*1024*2, 0,  busdma_flag, &scr->dma))
    386  1.1       bsh 		goto bad;
    387  1.1       bsh 	error = bus_dmamap_load(sc->dma_tag, scr->dma,
    388  1.1       bsh 	    scr->buf_va, size, NULL, busdma_flag);
    389  1.1       bsh 	if (error)
    390  1.1       bsh 		goto bad;
    391  1.1       bsh 
    392  1.1       bsh 	LIST_INSERT_HEAD(&(sc->screens), scr, link);
    393  1.1       bsh 	sc->n_screens++;
    394  1.1       bsh 
    395  1.1       bsh #ifdef LCD_DEBUG
    396  1.1       bsh 	draw_test_pattern(sc, scr);
    397  1.6     perry 	dump_lcdcon(__func__, sc->iot, sc->ioh);
    398  1.1       bsh #endif
    399  1.1       bsh 	return scr;
    400  1.1       bsh 
    401  1.1       bsh  bad:
    402  1.1       bsh 	if (scr) {
    403  1.1       bsh 		if (scr->buf_va)
    404  1.1       bsh 			bus_dmamem_unmap(sc->dma_tag, scr->buf_va, size);
    405  1.1       bsh 		if (scr->nsegs)
    406  1.1       bsh 			bus_dmamem_free(sc->dma_tag, scr->segs, scr->nsegs);
    407  1.1       bsh 		free(scr, M_DEVBUF);
    408  1.1       bsh 	}
    409  1.1       bsh 	return NULL;
    410  1.1       bsh }
    411  1.1       bsh 
    412  1.1       bsh 
    413  1.1       bsh #define _rgb(r,g,b)	(((r)<<11) | ((g)<<5) | b)
    414  1.1       bsh #define rgb(r,g,b)	_rgb((r)>>1,g,(b)>>1)
    415  1.1       bsh 
    416  1.1       bsh #define L	0x30			/* low intensity */
    417  1.1       bsh #define H	0x3f			/* hight intensity */
    418  1.1       bsh 
    419  1.1       bsh static const uint16_t basic_color_map[] = {
    420  1.1       bsh 	rgb(	0,   0,   0),		/* black */
    421  1.1       bsh 	rgb(	L,   0,   0),		/* red */
    422  1.1       bsh 	rgb(	0,   L,   0),		/* green */
    423  1.1       bsh 	rgb(	L,   L,   0),		/* brown */
    424  1.1       bsh 	rgb(	0,   0,   L),		/* blue */
    425  1.1       bsh 	rgb(	L,   0,   L),		/* magenta */
    426  1.1       bsh 	rgb(	0,   L,   L),		/* cyan */
    427  1.1       bsh 	_rgb(0x1c,0x38,0x1c),		/* white */
    428  1.1       bsh 
    429  1.1       bsh 	rgb(	L,   L,   L),		/* black */
    430  1.1       bsh 	rgb(	H,   0,   0),		/* red */
    431  1.1       bsh 	rgb(	0,   H,   0),		/* green */
    432  1.1       bsh 	rgb(	H,   H,   0),		/* brown */
    433  1.1       bsh 	rgb(	0,   0,   H),		/* blue */
    434  1.1       bsh 	rgb(	H,   0,   H),		/* magenta */
    435  1.1       bsh 	rgb(	0,   H,   H),		/* cyan */
    436  1.1       bsh 	rgb(	H,   H,   H),		/* white */
    437  1.1       bsh };
    438  1.1       bsh 
    439  1.1       bsh #define COLORMAP_LEN (sizeof basic_color_map / sizeof basic_color_map[0])
    440  1.1       bsh 
    441  1.1       bsh #undef H
    442  1.1       bsh #undef L
    443  1.1       bsh 
    444  1.1       bsh static void
    445  1.1       bsh init_palette(struct s3c24x0_lcd_softc *sc, struct s3c24x0_lcd_screen *scr)
    446  1.1       bsh {
    447  1.1       bsh 	int depth = scr->depth;
    448  1.1       bsh 	bus_space_tag_t iot = sc->iot;
    449  1.1       bsh 	bus_space_handle_t ioh = sc->ioh;
    450  1.1       bsh 	int i;
    451  1.1       bsh 
    452  1.1       bsh 	i = 0;
    453  1.1       bsh 
    454  1.1       bsh 	switch(depth) {
    455  1.1       bsh 	default:
    456  1.1       bsh 	case 16:		/* not using palette */
    457  1.1       bsh 		return;
    458  1.1       bsh 	case 8:
    459  1.1       bsh 		while (i < COLORMAP_LEN) {
    460  1.1       bsh 			bus_space_write_4(iot, ioh, LCDC_PALETTE + 4*i,
    461  1.1       bsh 			    basic_color_map[i]);
    462  1.1       bsh 			++i;
    463  1.1       bsh 		}
    464  1.1       bsh 		break;
    465  1.1       bsh 	case 4:
    466  1.1       bsh 	case 2:
    467  1.1       bsh 		/* XXX */
    468  1.1       bsh 		break;
    469  1.1       bsh 	case 1:
    470  1.1       bsh 		bus_space_write_4(iot, ioh, LCDC_PALETTE + 4 * i,
    471  1.1       bsh 		    basic_color_map[i]); /* black */
    472  1.1       bsh 		++i;
    473  1.1       bsh 		bus_space_write_4(iot, ioh, LCDC_PALETTE + 4 * i,
    474  1.1       bsh 		    basic_color_map[7]); /* white */
    475  1.1       bsh 		break;
    476  1.1       bsh 	}
    477  1.1       bsh 
    478  1.1       bsh #ifdef DIAGNOSTIC
    479  1.1       bsh 	/* Fill unused entries */
    480  1.1       bsh 	for ( ; i < 256; ++i )
    481  1.1       bsh 		bus_space_write_4(iot, ioh, LCDC_PALETTE + 4 * i,
    482  1.1       bsh 		    basic_color_map[1]); /* red */
    483  1.1       bsh #endif
    484  1.1       bsh }
    485  1.1       bsh 
    486  1.1       bsh 
    487  1.1       bsh #if NWSDISPLAY > 0
    488  1.1       bsh 
    489  1.1       bsh static void
    490  1.1       bsh s3c24x0_lcd_stop_dma(struct s3c24x0_lcd_softc *sc)
    491  1.1       bsh {
    492  1.1       bsh 	/* Stop LCD output */
    493  1.1       bsh 	bus_space_write_4(sc->iot, sc->ioh, LCDC_LCDCON1,
    494  1.1       bsh 	    ~LCDCON1_ENVID &
    495  1.1       bsh 	    bus_space_read_4(sc->iot, sc->ioh, LCDC_LCDCON1));
    496  1.1       bsh 
    497  1.1       bsh 
    498  1.1       bsh 	sc->lcd_on = 0;
    499  1.1       bsh }
    500  1.1       bsh 
    501  1.1       bsh int
    502  1.1       bsh s3c24x0_lcd_show_screen(void *v, void *cookie, int waitok,
    503  1.1       bsh     void (*cb)(void *, int, int), void *cbarg)
    504  1.1       bsh {
    505  1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    506  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie, *old;
    507  1.1       bsh 
    508  1.1       bsh 	/* XXX: make sure the clock is provided for LCD controller */
    509  1.1       bsh 
    510  1.1       bsh 	old = sc->active;
    511  1.1       bsh 	if (old == scr && sc->lcd_on)
    512  1.1       bsh 		return 0;
    513  1.1       bsh 
    514  1.1       bsh 	if (old)
    515  1.1       bsh 		s3c24x0_lcd_stop_dma(sc);
    516  1.1       bsh 
    517  1.1       bsh 	s3c24x0_lcd_start_dma(sc, scr);
    518  1.1       bsh 	sc->active = scr;
    519  1.1       bsh 	s3c24x0_lcd_power(sc, 1);
    520  1.1       bsh 
    521  1.1       bsh 	/* XXX: callback */
    522  1.1       bsh 
    523  1.1       bsh 	return 0;
    524  1.1       bsh }
    525  1.1       bsh 
    526  1.1       bsh int
    527  1.1       bsh s3c24x0_lcd_alloc_screen(void *v, const struct wsscreen_descr *_type,
    528  1.1       bsh     void **cookiep, int *curxp, int *curyp, long *attrp)
    529  1.1       bsh {
    530  1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    531  1.1       bsh 	struct s3c24x0_lcd_screen *scr;
    532  1.2        he 	const struct s3c24x0_wsscreen_descr *type =
    533  1.2        he 	    (const struct s3c24x0_wsscreen_descr *)_type;
    534  1.1       bsh 
    535  1.1       bsh 	int width, height;
    536  1.1       bsh 
    537  1.1       bsh 	width = type->c.ncols * type->c.fontwidth;
    538  1.1       bsh 	height = type->c.nrows * type->c.fontwidth;
    539  1.1       bsh 
    540  1.1       bsh 	if (width < sc->panel_info->panel_width)
    541  1.1       bsh 		width =   sc->panel_info->panel_width;
    542  1.1       bsh 	if (height < sc->panel_info->panel_height)
    543  1.1       bsh 		height =   sc->panel_info->panel_height;
    544  1.1       bsh 
    545  1.1       bsh 
    546  1.1       bsh 	scr = s3c24x0_lcd_new_screen(sc, width, height, type->depth);
    547  1.1       bsh 	if (scr == NULL)
    548  1.1       bsh 		return -1;
    549  1.1       bsh 
    550  1.1       bsh 	/*
    551  1.1       bsh 	 * initialize raster operation for this screen.
    552  1.1       bsh 	 */
    553  1.1       bsh 	scr->rinfo.ri_flg = 0;
    554  1.1       bsh 	scr->rinfo.ri_depth = type->depth;
    555  1.1       bsh 	scr->rinfo.ri_bits = scr->buf_va;
    556  1.1       bsh 	scr->rinfo.ri_width = width;
    557  1.1       bsh 	scr->rinfo.ri_height = height;
    558  1.1       bsh 	scr->rinfo.ri_stride = scr->stride;
    559  1.1       bsh 
    560  1.1       bsh 	if (type->c.fontwidth || type->c.fontheight) {
    561  1.1       bsh 		/*
    562  1.1       bsh 		 * find a font with specified size
    563  1.1       bsh 		 */
    564  1.1       bsh 		int cookie;
    565  1.1       bsh 
    566  1.1       bsh 		wsfont_init();
    567  1.1       bsh 
    568  1.1       bsh 		cookie = wsfont_find(NULL, type->c.fontwidth,
    569  1.1       bsh 		    type->c.fontheight, 0, WSDISPLAY_FONTORDER_L2R,
    570  1.8  macallan 		    WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
    571  1.1       bsh 
    572  1.1       bsh 		if (cookie > 0) {
    573  1.1       bsh 			if (wsfont_lock(cookie, &scr->rinfo.ri_font))
    574  1.1       bsh 				scr->rinfo.ri_wsfcookie = cookie;
    575  1.1       bsh 		}
    576  1.1       bsh 	}
    577  1.1       bsh 
    578  1.1       bsh 	rasops_init(&scr->rinfo, type->c.nrows, type->c.ncols);
    579  1.1       bsh 
    580  1.1       bsh 	(* scr->rinfo.ri_ops.allocattr)(&scr->rinfo, 0, 0, 0, attrp);
    581  1.1       bsh 
    582  1.1       bsh 	if (type->c.nrows != scr->rinfo.ri_rows ||
    583  1.1       bsh 	    type->c.ncols != scr->rinfo.ri_cols) {
    584  1.1       bsh 
    585  1.1       bsh 		aprint_error("%s: can't allocate a screen with requested size:"
    586  1.1       bsh 		    "%d x %d -> %d x %d\n",
    587  1.9  nisimura 		    device_xname(sc->sc_dev),
    588  1.1       bsh 		    type->c.ncols, type->c.nrows,
    589  1.1       bsh 		    scr->rinfo.ri_cols, scr->rinfo.ri_rows);
    590  1.1       bsh 	}
    591  1.1       bsh 
    592  1.1       bsh 	*cookiep = scr;
    593  1.1       bsh 	*curxp = 0;
    594  1.1       bsh 	*curyp = 0;
    595  1.1       bsh 
    596  1.1       bsh 	return 0;
    597  1.1       bsh }
    598  1.1       bsh 
    599  1.1       bsh 
    600  1.1       bsh void
    601  1.1       bsh s3c24x0_lcd_free_screen(void *v, void *cookie)
    602  1.1       bsh {
    603  1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    604  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    605  1.1       bsh 
    606  1.1       bsh 	LIST_REMOVE(scr, link);
    607  1.1       bsh 	sc->n_screens--;
    608  1.1       bsh 	if (scr == sc->active) {
    609  1.1       bsh 		sc->active = NULL;
    610  1.1       bsh 
    611  1.1       bsh 		/* XXX: We need a good procedure to shutdown the LCD. */
    612  1.1       bsh 
    613  1.1       bsh 		s3c24x0_lcd_stop_dma(sc);
    614  1.1       bsh 		s3c24x0_lcd_power(sc, 0);
    615  1.1       bsh 	}
    616  1.1       bsh 
    617  1.1       bsh 	if (scr->buf_va)
    618  1.1       bsh 		bus_dmamem_unmap(sc->dma_tag, scr->buf_va, scr->map_size);
    619  1.1       bsh 
    620  1.1       bsh 	if (scr->nsegs > 0)
    621  1.1       bsh 		bus_dmamem_free(sc->dma_tag, scr->segs, scr->nsegs);
    622  1.1       bsh 
    623  1.1       bsh 	free(scr, M_DEVBUF);
    624  1.1       bsh }
    625  1.1       bsh 
    626  1.1       bsh int
    627  1.5  christos s3c24x0_lcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
    628  1.4      jmmv     struct lwp *l)
    629  1.1       bsh {
    630  1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    631  1.1       bsh 	struct wsdisplay_fbinfo *wsdisp_info;
    632  1.1       bsh 	struct s3c24x0_lcd_screen *scr;
    633  1.1       bsh 
    634  1.1       bsh 
    635  1.1       bsh 	switch (cmd) {
    636  1.1       bsh 	case WSDISPLAYIO_GTYPE:
    637  1.1       bsh 		*(u_int *)data = WSDISPLAY_TYPE_UNKNOWN; /* XXX */
    638  1.1       bsh 		return 0;
    639  1.1       bsh 
    640  1.1       bsh 	case WSDISPLAYIO_GINFO:
    641  1.1       bsh 		wsdisp_info = (struct wsdisplay_fbinfo *)data;
    642  1.1       bsh 
    643  1.1       bsh 		wsdisp_info->height = sc->panel_info->panel_height;
    644  1.1       bsh 		wsdisp_info->width = sc->panel_info->panel_width;
    645  1.1       bsh 		wsdisp_info->depth = 16; /* XXX */
    646  1.1       bsh 		wsdisp_info->cmsize = 0;
    647  1.1       bsh 		return 0;
    648  1.1       bsh 
    649  1.9  nisimura 	case WSDISPLAYIO_LINEBYTES:
    650  1.9  nisimura 		*(u_int *)data = sc->panel_info->panel_width * (16/8);
    651  1.9  nisimura 		return 0;
    652  1.9  nisimura 
    653  1.1       bsh 	case WSDISPLAYIO_GETCMAP:
    654  1.1       bsh 	case WSDISPLAYIO_PUTCMAP:
    655  1.1       bsh 		return EPASSTHROUGH;	/* XXX Colormap */
    656  1.1       bsh 
    657  1.1       bsh 	case WSDISPLAYIO_SVIDEO:
    658  1.1       bsh 		if (*(int *)data == WSDISPLAYIO_VIDEO_ON) {
    659  1.1       bsh 			scr = sc->active;
    660  1.1       bsh 			if (scr == NULL)
    661  1.1       bsh 				scr = LIST_FIRST(&sc->screens);
    662  1.1       bsh 
    663  1.1       bsh 			if (scr == NULL)
    664  1.1       bsh 				return ENXIO;
    665  1.1       bsh 
    666  1.1       bsh 			s3c24x0_lcd_show_screen(sc, scr, 1, NULL, NULL);
    667  1.1       bsh 		}
    668  1.1       bsh 		else {
    669  1.1       bsh 			s3c24x0_lcd_stop_dma(sc);
    670  1.1       bsh 			s3c24x0_lcd_power(sc, 0);
    671  1.1       bsh 		}
    672  1.1       bsh 		return 0;
    673  1.1       bsh 
    674  1.1       bsh 	case WSDISPLAYIO_GVIDEO:
    675  1.1       bsh 		*(u_int *)data = sc->lcd_on;
    676  1.1       bsh 		return 0;
    677  1.1       bsh 
    678  1.9  nisimura 	/* XXX: Hack to support /usr/sbin/tpctl */
    679  1.9  nisimura 	case HPCFBIO_GCONF:
    680  1.9  nisimura 	{
    681  1.9  nisimura 		struct hpcfb_fbconf *fbconf = (struct hpcfb_fbconf*)data;
    682  1.9  nisimura 		if (fbconf->hf_conf_index != 0 &&
    683  1.9  nisimura 		    fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG)
    684  1.9  nisimura 			return EINVAL;
    685  1.9  nisimura 
    686  1.9  nisimura 		fbconf->hf_nconfs = 1;
    687  1.9  nisimura 		fbconf->hf_class = HPCFB_CLASS_RGBCOLOR;
    688  1.9  nisimura 		strncpy(fbconf->hf_name, "S3C24X0 LCD", HPCFB_MAXNAMELEN);
    689  1.9  nisimura 		strncpy(fbconf->hf_conf_name, "default", HPCFB_MAXNAMELEN);
    690  1.9  nisimura 		fbconf->hf_height = sc->panel_info->panel_height;
    691  1.9  nisimura 		fbconf->hf_width = sc->panel_info->panel_width;
    692  1.9  nisimura 		fbconf->hf_baseaddr = 0x0;
    693  1.9  nisimura 		fbconf->hf_offset = 0x0;
    694  1.9  nisimura 		fbconf->hf_bytes_per_line = sc->panel_info->panel_width * (16/8);
    695  1.9  nisimura 		fbconf->hf_nplanes = 0;
    696  1.9  nisimura 		fbconf->hf_bytes_per_plane = 0;
    697  1.9  nisimura 		fbconf->hf_pack_width = 16;
    698  1.9  nisimura 		fbconf->hf_pixels_per_pack = 1;
    699  1.9  nisimura 		fbconf->hf_pixel_width = 16;
    700  1.9  nisimura 
    701  1.9  nisimura 		fbconf->hf_access_flags = 0;
    702  1.9  nisimura 		fbconf->hf_order_flags = HPCFB_REVORDER_WORD;
    703  1.9  nisimura 		fbconf->hf_reg_offset = 0x0;
    704  1.9  nisimura 
    705  1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_red_width = 5;
    706  1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_red_shift = 11;
    707  1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_green_width = 6;
    708  1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_green_shift = 5;
    709  1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_blue_width = 5;
    710  1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_blue_shift = 0;
    711  1.9  nisimura 
    712  1.9  nisimura 		fbconf->hf_ext_size = 0;
    713  1.9  nisimura 		fbconf->hf_ext_data = NULL;
    714  1.9  nisimura 
    715  1.9  nisimura 		return 0;
    716  1.9  nisimura 	}
    717  1.9  nisimura 
    718  1.1       bsh 	case WSDISPLAYIO_GCURPOS:
    719  1.1       bsh 	case WSDISPLAYIO_SCURPOS:
    720  1.1       bsh 	case WSDISPLAYIO_GCURMAX:
    721  1.1       bsh 	case WSDISPLAYIO_GCURSOR:
    722  1.1       bsh 	case WSDISPLAYIO_SCURSOR:
    723  1.1       bsh 		return EPASSTHROUGH;	/* XXX */
    724  1.1       bsh 	}
    725  1.1       bsh 
    726  1.1       bsh 	return EPASSTHROUGH;
    727  1.1       bsh }
    728  1.1       bsh 
    729  1.1       bsh paddr_t
    730  1.4      jmmv s3c24x0_lcd_mmap(void *v, void *vs, off_t offset, int prot)
    731  1.1       bsh {
    732  1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    733  1.1       bsh 	struct s3c24x0_lcd_screen *screen = sc->active;  /* ??? */
    734  1.9  nisimura 	paddr_t ret;
    735  1.9  nisimura 
    736  1.9  nisimura 	/*	printf("s3c24x0_lcd_mmap: screen: %p, offset: %ld\n", screen, (long)offset);*/
    737  1.1       bsh 
    738  1.1       bsh 	if (screen == NULL)
    739  1.1       bsh 		return -1;
    740  1.1       bsh 
    741  1.9  nisimura 	ret = bus_dmamem_mmap(sc->dma_tag, screen->segs, screen->nsegs,
    742  1.1       bsh 	    offset, prot, BUS_DMA_WAITOK|BUS_DMA_COHERENT);
    743  1.9  nisimura 	/*	printf("s3c24x0_lcd_mmap: ret: %lx\n", ret);*/
    744  1.9  nisimura 	return ret;
    745  1.1       bsh 	return -1;
    746  1.1       bsh }
    747  1.1       bsh 
    748  1.1       bsh 
    749  1.1       bsh static void
    750  1.1       bsh s3c24x0_lcd_cursor(void *cookie, int on, int row, int col)
    751  1.1       bsh {
    752  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    753  1.1       bsh 
    754  1.1       bsh 	(* scr->rinfo.ri_ops.cursor)(&scr->rinfo, on, row, col);
    755  1.1       bsh }
    756  1.1       bsh 
    757  1.1       bsh static int
    758  1.1       bsh s3c24x0_lcd_mapchar(void *cookie, int c, unsigned int *cp)
    759  1.1       bsh {
    760  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    761  1.1       bsh 
    762  1.1       bsh 	return (* scr->rinfo.ri_ops.mapchar)(&scr->rinfo, c, cp);
    763  1.1       bsh }
    764  1.1       bsh 
    765  1.1       bsh static void
    766  1.1       bsh s3c24x0_lcd_putchar(void *cookie, int row, int col, u_int uc, long attr)
    767  1.1       bsh {
    768  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    769  1.1       bsh 
    770  1.1       bsh 	(* scr->rinfo.ri_ops.putchar)(&scr->rinfo,
    771  1.1       bsh 	    row, col, uc, attr);
    772  1.1       bsh }
    773  1.1       bsh 
    774  1.1       bsh static void
    775  1.1       bsh s3c24x0_lcd_copycols(void *cookie, int row, int src, int dst, int num)
    776  1.1       bsh {
    777  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    778  1.1       bsh 
    779  1.1       bsh 	(* scr->rinfo.ri_ops.copycols)(&scr->rinfo,
    780  1.1       bsh 	    row, src, dst, num);
    781  1.1       bsh }
    782  1.1       bsh 
    783  1.1       bsh static void
    784  1.1       bsh s3c24x0_lcd_erasecols(void *cookie, int row, int col, int num, long attr)
    785  1.1       bsh {
    786  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    787  1.1       bsh 
    788  1.1       bsh 	(* scr->rinfo.ri_ops.erasecols)(&scr->rinfo,
    789  1.1       bsh 	    row, col, num, attr);
    790  1.1       bsh }
    791  1.1       bsh 
    792  1.1       bsh static void
    793  1.1       bsh s3c24x0_lcd_copyrows(void *cookie, int src, int dst, int num)
    794  1.1       bsh {
    795  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    796  1.1       bsh 
    797  1.1       bsh 	(* scr->rinfo.ri_ops.copyrows)(&scr->rinfo,
    798  1.1       bsh 	    src, dst, num);
    799  1.1       bsh }
    800  1.1       bsh 
    801  1.1       bsh static void
    802  1.1       bsh s3c24x0_lcd_eraserows(void *cookie, int row, int num, long attr)
    803  1.1       bsh {
    804  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    805  1.1       bsh 
    806  1.1       bsh 	(* scr->rinfo.ri_ops.eraserows)(&scr->rinfo,
    807  1.1       bsh 	    row, num, attr);
    808  1.1       bsh }
    809  1.1       bsh 
    810  1.1       bsh static int
    811  1.1       bsh s3c24x0_lcd_alloc_attr(void *cookie, int fg, int bg, int flg, long *attr)
    812  1.1       bsh {
    813  1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    814  1.1       bsh 
    815  1.1       bsh 	return (* scr->rinfo.ri_ops.allocattr)(&scr->rinfo,
    816  1.1       bsh 	    fg, bg, flg, attr);
    817  1.1       bsh }
    818  1.1       bsh 
    819  1.1       bsh 
    820  1.1       bsh const struct wsdisplay_emulops s3c24x0_lcd_emulops = {
    821  1.1       bsh 	s3c24x0_lcd_cursor,
    822  1.1       bsh 	s3c24x0_lcd_mapchar,
    823  1.1       bsh 	s3c24x0_lcd_putchar,
    824  1.1       bsh 	s3c24x0_lcd_copycols,
    825  1.1       bsh 	s3c24x0_lcd_erasecols,
    826  1.1       bsh 	s3c24x0_lcd_copyrows,
    827  1.1       bsh 	s3c24x0_lcd_eraserows,
    828  1.1       bsh 	s3c24x0_lcd_alloc_attr
    829  1.1       bsh };
    830  1.1       bsh 
    831  1.1       bsh #endif /* NWSDISPLAY > 0 */
    832