Home | History | Annotate | Line # | Download | only in s3c2xx0
s3c24x0_lcd.c revision 1.12.18.1
      1  1.12.18.1  pgoyette /* $NetBSD: s3c24x0_lcd.c,v 1.12.18.1 2018/09/06 06:55:27 pgoyette 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.12.18.1  pgoyette __KERNEL_RCSID(0, "$NetBSD: s3c24x0_lcd.c,v 1.12.18.1 2018/09/06 06:55:27 pgoyette 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.12.18.1  pgoyette 		clkval = uimax(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.10       chs 		    device_xname(sc->dev), 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 	bus_size_t size;
    314       1.11     htodd         int error;
    315        1.1       bsh 	int busdma_flag = (cold ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK) |
    316        1.1       bsh 	    BUS_DMA_WRITE;
    317        1.1       bsh 	paddr_t align;
    318        1.1       bsh 
    319        1.9  nisimura #if 0 /* Does this make any sense? */
    320        1.1       bsh #ifdef DIAGNOSTIC
    321        1.1       bsh 	if (size > 1 << 22) {
    322       1.10       chs 		aprint_error_dev(sc->dev, "too big screen size\n");
    323        1.1       bsh 		return NULL;
    324        1.1       bsh 	}
    325        1.1       bsh #endif
    326        1.9  nisimura #endif
    327        1.1       bsh 
    328        1.1       bsh 	switch (depth) {
    329        1.1       bsh 	case 1: case 2: case 4: case 8:
    330        1.1       bsh 		virtual_width = roundup(virtual_width, 16 / depth);
    331        1.1       bsh 		break;
    332        1.1       bsh 	case 16:
    333        1.1       bsh 		break;
    334        1.1       bsh 	case 12: case 24:
    335        1.1       bsh 	default:
    336        1.1       bsh 		aprint_error("%s: Unknown depth (%d)\n",
    337        1.9  nisimura 		    device_xname(sc->sc_dev), depth);
    338        1.1       bsh 		return NULL;
    339        1.1       bsh 	}
    340        1.1       bsh 
    341        1.9  nisimura 	scr = malloc(sizeof *scr, M_DEVBUF,
    342        1.1       bsh 	    M_ZERO | (cold ? M_NOWAIT : M_WAITOK));
    343        1.1       bsh 
    344        1.1       bsh 	if (scr == NULL)
    345        1.1       bsh 		return NULL;
    346        1.1       bsh 
    347        1.1       bsh 	scr->nsegs = 0;
    348        1.1       bsh 	scr->depth = depth;
    349        1.1       bsh 	scr->stride = virtual_width * depth / 8;
    350        1.1       bsh 	scr->buf_size = size = scr->stride * virtual_height;
    351        1.1       bsh 	scr->buf_va = NULL;
    352        1.1       bsh 
    353        1.1       bsh 	/* calculate the alignment for LCD frame buffer.
    354        1.1       bsh 	   the buffer can't across 4MB boundary */
    355        1.1       bsh 	align = 1 << 20;
    356        1.1       bsh 	while (align < size)
    357        1.1       bsh 		align <<= 1;
    358        1.1       bsh 
    359        1.9  nisimura 	printf("%s: Allocating LCD frame buffer of size %ld\n",
    360        1.9  nisimura 	       device_xname(sc->sc_dev), size);
    361        1.9  nisimura 
    362        1.1       bsh         error = bus_dmamem_alloc(sc->dma_tag, size, align, 0,
    363        1.1       bsh 	    scr->segs, 1, &(scr->nsegs), busdma_flag);
    364        1.1       bsh 
    365        1.1       bsh         if (error || scr->nsegs != 1)
    366        1.1       bsh 		goto bad;
    367        1.1       bsh 
    368        1.1       bsh 	error = bus_dmamem_map(sc->dma_tag, scr->segs, scr->nsegs,
    369        1.5  christos 	    size, (void **)&(scr->buf_va), busdma_flag | BUS_DMA_COHERENT);
    370        1.1       bsh 	if (error)
    371        1.1       bsh 		goto bad;
    372        1.1       bsh 
    373        1.1       bsh 
    374        1.1       bsh 	memset (scr->buf_va, 0, scr->buf_size);
    375        1.1       bsh 
    376        1.1       bsh 	/* map memory for DMA */
    377        1.1       bsh 	if (bus_dmamap_create(sc->dma_tag, 1024*1024*2, 1,
    378        1.1       bsh 	    1024*1024*2, 0,  busdma_flag, &scr->dma))
    379        1.1       bsh 		goto bad;
    380        1.1       bsh 	error = bus_dmamap_load(sc->dma_tag, scr->dma,
    381        1.1       bsh 	    scr->buf_va, size, NULL, busdma_flag);
    382        1.1       bsh 	if (error)
    383        1.1       bsh 		goto bad;
    384        1.1       bsh 
    385        1.1       bsh 	LIST_INSERT_HEAD(&(sc->screens), scr, link);
    386        1.1       bsh 	sc->n_screens++;
    387        1.1       bsh 
    388        1.1       bsh #ifdef LCD_DEBUG
    389        1.1       bsh 	draw_test_pattern(sc, scr);
    390        1.6     perry 	dump_lcdcon(__func__, sc->iot, sc->ioh);
    391        1.1       bsh #endif
    392        1.1       bsh 	return scr;
    393        1.1       bsh 
    394        1.1       bsh  bad:
    395        1.1       bsh 	if (scr) {
    396        1.1       bsh 		if (scr->buf_va)
    397        1.1       bsh 			bus_dmamem_unmap(sc->dma_tag, scr->buf_va, size);
    398        1.1       bsh 		if (scr->nsegs)
    399        1.1       bsh 			bus_dmamem_free(sc->dma_tag, scr->segs, scr->nsegs);
    400        1.1       bsh 		free(scr, M_DEVBUF);
    401        1.1       bsh 	}
    402        1.1       bsh 	return NULL;
    403        1.1       bsh }
    404        1.1       bsh 
    405        1.1       bsh 
    406        1.1       bsh #define _rgb(r,g,b)	(((r)<<11) | ((g)<<5) | b)
    407        1.1       bsh #define rgb(r,g,b)	_rgb((r)>>1,g,(b)>>1)
    408        1.1       bsh 
    409        1.1       bsh #define L	0x30			/* low intensity */
    410        1.1       bsh #define H	0x3f			/* hight intensity */
    411        1.1       bsh 
    412        1.1       bsh static const uint16_t basic_color_map[] = {
    413        1.1       bsh 	rgb(	0,   0,   0),		/* black */
    414        1.1       bsh 	rgb(	L,   0,   0),		/* red */
    415        1.1       bsh 	rgb(	0,   L,   0),		/* green */
    416        1.1       bsh 	rgb(	L,   L,   0),		/* brown */
    417        1.1       bsh 	rgb(	0,   0,   L),		/* blue */
    418        1.1       bsh 	rgb(	L,   0,   L),		/* magenta */
    419        1.1       bsh 	rgb(	0,   L,   L),		/* cyan */
    420        1.1       bsh 	_rgb(0x1c,0x38,0x1c),		/* white */
    421        1.1       bsh 
    422        1.1       bsh 	rgb(	L,   L,   L),		/* black */
    423        1.1       bsh 	rgb(	H,   0,   0),		/* red */
    424        1.1       bsh 	rgb(	0,   H,   0),		/* green */
    425        1.1       bsh 	rgb(	H,   H,   0),		/* brown */
    426        1.1       bsh 	rgb(	0,   0,   H),		/* blue */
    427        1.1       bsh 	rgb(	H,   0,   H),		/* magenta */
    428        1.1       bsh 	rgb(	0,   H,   H),		/* cyan */
    429        1.1       bsh 	rgb(	H,   H,   H),		/* white */
    430        1.1       bsh };
    431        1.1       bsh 
    432        1.1       bsh #define COLORMAP_LEN (sizeof basic_color_map / sizeof basic_color_map[0])
    433        1.1       bsh 
    434        1.1       bsh #undef H
    435        1.1       bsh #undef L
    436        1.1       bsh 
    437        1.1       bsh static void
    438        1.1       bsh init_palette(struct s3c24x0_lcd_softc *sc, struct s3c24x0_lcd_screen *scr)
    439        1.1       bsh {
    440        1.1       bsh 	int depth = scr->depth;
    441        1.1       bsh 	bus_space_tag_t iot = sc->iot;
    442        1.1       bsh 	bus_space_handle_t ioh = sc->ioh;
    443        1.1       bsh 	int i;
    444        1.1       bsh 
    445        1.1       bsh 	i = 0;
    446        1.1       bsh 
    447        1.1       bsh 	switch(depth) {
    448        1.1       bsh 	default:
    449        1.1       bsh 	case 16:		/* not using palette */
    450        1.1       bsh 		return;
    451        1.1       bsh 	case 8:
    452        1.1       bsh 		while (i < COLORMAP_LEN) {
    453        1.1       bsh 			bus_space_write_4(iot, ioh, LCDC_PALETTE + 4*i,
    454        1.1       bsh 			    basic_color_map[i]);
    455        1.1       bsh 			++i;
    456        1.1       bsh 		}
    457        1.1       bsh 		break;
    458        1.1       bsh 	case 4:
    459        1.1       bsh 	case 2:
    460        1.1       bsh 		/* XXX */
    461        1.1       bsh 		break;
    462        1.1       bsh 	case 1:
    463        1.1       bsh 		bus_space_write_4(iot, ioh, LCDC_PALETTE + 4 * i,
    464        1.1       bsh 		    basic_color_map[i]); /* black */
    465        1.1       bsh 		++i;
    466        1.1       bsh 		bus_space_write_4(iot, ioh, LCDC_PALETTE + 4 * i,
    467        1.1       bsh 		    basic_color_map[7]); /* white */
    468        1.1       bsh 		break;
    469        1.1       bsh 	}
    470        1.1       bsh 
    471        1.1       bsh #ifdef DIAGNOSTIC
    472        1.1       bsh 	/* Fill unused entries */
    473        1.1       bsh 	for ( ; i < 256; ++i )
    474        1.1       bsh 		bus_space_write_4(iot, ioh, LCDC_PALETTE + 4 * i,
    475        1.1       bsh 		    basic_color_map[1]); /* red */
    476        1.1       bsh #endif
    477        1.1       bsh }
    478        1.1       bsh 
    479        1.1       bsh 
    480        1.1       bsh #if NWSDISPLAY > 0
    481        1.1       bsh 
    482        1.1       bsh static void
    483        1.1       bsh s3c24x0_lcd_stop_dma(struct s3c24x0_lcd_softc *sc)
    484        1.1       bsh {
    485        1.1       bsh 	/* Stop LCD output */
    486        1.1       bsh 	bus_space_write_4(sc->iot, sc->ioh, LCDC_LCDCON1,
    487        1.1       bsh 	    ~LCDCON1_ENVID &
    488        1.1       bsh 	    bus_space_read_4(sc->iot, sc->ioh, LCDC_LCDCON1));
    489        1.1       bsh 
    490        1.1       bsh 
    491        1.1       bsh 	sc->lcd_on = 0;
    492        1.1       bsh }
    493        1.1       bsh 
    494        1.1       bsh int
    495        1.1       bsh s3c24x0_lcd_show_screen(void *v, void *cookie, int waitok,
    496        1.1       bsh     void (*cb)(void *, int, int), void *cbarg)
    497        1.1       bsh {
    498        1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    499        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie, *old;
    500        1.1       bsh 
    501        1.1       bsh 	/* XXX: make sure the clock is provided for LCD controller */
    502        1.1       bsh 
    503        1.1       bsh 	old = sc->active;
    504        1.1       bsh 	if (old == scr && sc->lcd_on)
    505        1.1       bsh 		return 0;
    506        1.1       bsh 
    507        1.1       bsh 	if (old)
    508        1.1       bsh 		s3c24x0_lcd_stop_dma(sc);
    509        1.1       bsh 
    510        1.1       bsh 	s3c24x0_lcd_start_dma(sc, scr);
    511        1.1       bsh 	sc->active = scr;
    512        1.1       bsh 	s3c24x0_lcd_power(sc, 1);
    513        1.1       bsh 
    514        1.1       bsh 	/* XXX: callback */
    515        1.1       bsh 
    516        1.1       bsh 	return 0;
    517        1.1       bsh }
    518        1.1       bsh 
    519        1.1       bsh int
    520        1.1       bsh s3c24x0_lcd_alloc_screen(void *v, const struct wsscreen_descr *_type,
    521        1.1       bsh     void **cookiep, int *curxp, int *curyp, long *attrp)
    522        1.1       bsh {
    523        1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    524        1.1       bsh 	struct s3c24x0_lcd_screen *scr;
    525        1.2        he 	const struct s3c24x0_wsscreen_descr *type =
    526        1.2        he 	    (const struct s3c24x0_wsscreen_descr *)_type;
    527        1.1       bsh 
    528        1.1       bsh 	int width, height;
    529        1.1       bsh 
    530        1.1       bsh 	width = type->c.ncols * type->c.fontwidth;
    531        1.1       bsh 	height = type->c.nrows * type->c.fontwidth;
    532        1.1       bsh 
    533        1.1       bsh 	if (width < sc->panel_info->panel_width)
    534        1.1       bsh 		width =   sc->panel_info->panel_width;
    535        1.1       bsh 	if (height < sc->panel_info->panel_height)
    536        1.1       bsh 		height =   sc->panel_info->panel_height;
    537        1.1       bsh 
    538        1.1       bsh 
    539        1.1       bsh 	scr = s3c24x0_lcd_new_screen(sc, width, height, type->depth);
    540        1.1       bsh 	if (scr == NULL)
    541        1.1       bsh 		return -1;
    542        1.1       bsh 
    543        1.1       bsh 	/*
    544        1.1       bsh 	 * initialize raster operation for this screen.
    545        1.1       bsh 	 */
    546        1.1       bsh 	scr->rinfo.ri_flg = 0;
    547        1.1       bsh 	scr->rinfo.ri_depth = type->depth;
    548        1.1       bsh 	scr->rinfo.ri_bits = scr->buf_va;
    549        1.1       bsh 	scr->rinfo.ri_width = width;
    550        1.1       bsh 	scr->rinfo.ri_height = height;
    551        1.1       bsh 	scr->rinfo.ri_stride = scr->stride;
    552        1.1       bsh 
    553        1.1       bsh 	if (type->c.fontwidth || type->c.fontheight) {
    554        1.1       bsh 		/*
    555        1.1       bsh 		 * find a font with specified size
    556        1.1       bsh 		 */
    557        1.1       bsh 		int cookie;
    558        1.1       bsh 
    559        1.1       bsh 		wsfont_init();
    560        1.1       bsh 
    561        1.1       bsh 		cookie = wsfont_find(NULL, type->c.fontwidth,
    562        1.1       bsh 		    type->c.fontheight, 0, WSDISPLAY_FONTORDER_L2R,
    563        1.8  macallan 		    WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
    564        1.1       bsh 
    565        1.1       bsh 		if (cookie > 0) {
    566        1.1       bsh 			if (wsfont_lock(cookie, &scr->rinfo.ri_font))
    567        1.1       bsh 				scr->rinfo.ri_wsfcookie = cookie;
    568        1.1       bsh 		}
    569        1.1       bsh 	}
    570        1.1       bsh 
    571        1.1       bsh 	rasops_init(&scr->rinfo, type->c.nrows, type->c.ncols);
    572        1.1       bsh 
    573        1.1       bsh 	(* scr->rinfo.ri_ops.allocattr)(&scr->rinfo, 0, 0, 0, attrp);
    574        1.1       bsh 
    575        1.1       bsh 	if (type->c.nrows != scr->rinfo.ri_rows ||
    576        1.1       bsh 	    type->c.ncols != scr->rinfo.ri_cols) {
    577        1.1       bsh 
    578        1.1       bsh 		aprint_error("%s: can't allocate a screen with requested size:"
    579        1.1       bsh 		    "%d x %d -> %d x %d\n",
    580        1.9  nisimura 		    device_xname(sc->sc_dev),
    581        1.1       bsh 		    type->c.ncols, type->c.nrows,
    582        1.1       bsh 		    scr->rinfo.ri_cols, scr->rinfo.ri_rows);
    583        1.1       bsh 	}
    584        1.1       bsh 
    585        1.1       bsh 	*cookiep = scr;
    586        1.1       bsh 	*curxp = 0;
    587        1.1       bsh 	*curyp = 0;
    588        1.1       bsh 
    589        1.1       bsh 	return 0;
    590        1.1       bsh }
    591        1.1       bsh 
    592        1.1       bsh 
    593        1.1       bsh void
    594        1.1       bsh s3c24x0_lcd_free_screen(void *v, void *cookie)
    595        1.1       bsh {
    596        1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    597        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    598        1.1       bsh 
    599        1.1       bsh 	LIST_REMOVE(scr, link);
    600        1.1       bsh 	sc->n_screens--;
    601        1.1       bsh 	if (scr == sc->active) {
    602        1.1       bsh 		sc->active = NULL;
    603        1.1       bsh 
    604        1.1       bsh 		/* XXX: We need a good procedure to shutdown the LCD. */
    605        1.1       bsh 
    606        1.1       bsh 		s3c24x0_lcd_stop_dma(sc);
    607        1.1       bsh 		s3c24x0_lcd_power(sc, 0);
    608        1.1       bsh 	}
    609        1.1       bsh 
    610        1.1       bsh 	if (scr->buf_va)
    611        1.1       bsh 		bus_dmamem_unmap(sc->dma_tag, scr->buf_va, scr->map_size);
    612        1.1       bsh 
    613        1.1       bsh 	if (scr->nsegs > 0)
    614        1.1       bsh 		bus_dmamem_free(sc->dma_tag, scr->segs, scr->nsegs);
    615        1.1       bsh 
    616        1.1       bsh 	free(scr, M_DEVBUF);
    617        1.1       bsh }
    618        1.1       bsh 
    619        1.1       bsh int
    620        1.5  christos s3c24x0_lcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
    621        1.4      jmmv     struct lwp *l)
    622        1.1       bsh {
    623        1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    624        1.1       bsh 	struct wsdisplay_fbinfo *wsdisp_info;
    625        1.1       bsh 	struct s3c24x0_lcd_screen *scr;
    626        1.1       bsh 
    627        1.1       bsh 
    628        1.1       bsh 	switch (cmd) {
    629        1.1       bsh 	case WSDISPLAYIO_GTYPE:
    630        1.1       bsh 		*(u_int *)data = WSDISPLAY_TYPE_UNKNOWN; /* XXX */
    631        1.1       bsh 		return 0;
    632        1.1       bsh 
    633        1.1       bsh 	case WSDISPLAYIO_GINFO:
    634        1.1       bsh 		wsdisp_info = (struct wsdisplay_fbinfo *)data;
    635        1.1       bsh 
    636        1.1       bsh 		wsdisp_info->height = sc->panel_info->panel_height;
    637        1.1       bsh 		wsdisp_info->width = sc->panel_info->panel_width;
    638        1.1       bsh 		wsdisp_info->depth = 16; /* XXX */
    639        1.1       bsh 		wsdisp_info->cmsize = 0;
    640        1.1       bsh 		return 0;
    641        1.1       bsh 
    642        1.9  nisimura 	case WSDISPLAYIO_LINEBYTES:
    643        1.9  nisimura 		*(u_int *)data = sc->panel_info->panel_width * (16/8);
    644        1.9  nisimura 		return 0;
    645        1.9  nisimura 
    646        1.1       bsh 	case WSDISPLAYIO_GETCMAP:
    647        1.1       bsh 	case WSDISPLAYIO_PUTCMAP:
    648        1.1       bsh 		return EPASSTHROUGH;	/* XXX Colormap */
    649        1.1       bsh 
    650        1.1       bsh 	case WSDISPLAYIO_SVIDEO:
    651        1.1       bsh 		if (*(int *)data == WSDISPLAYIO_VIDEO_ON) {
    652        1.1       bsh 			scr = sc->active;
    653        1.1       bsh 			if (scr == NULL)
    654        1.1       bsh 				scr = LIST_FIRST(&sc->screens);
    655        1.1       bsh 
    656        1.1       bsh 			if (scr == NULL)
    657        1.1       bsh 				return ENXIO;
    658        1.1       bsh 
    659        1.1       bsh 			s3c24x0_lcd_show_screen(sc, scr, 1, NULL, NULL);
    660        1.1       bsh 		}
    661        1.1       bsh 		else {
    662        1.1       bsh 			s3c24x0_lcd_stop_dma(sc);
    663        1.1       bsh 			s3c24x0_lcd_power(sc, 0);
    664        1.1       bsh 		}
    665        1.1       bsh 		return 0;
    666        1.1       bsh 
    667        1.1       bsh 	case WSDISPLAYIO_GVIDEO:
    668        1.1       bsh 		*(u_int *)data = sc->lcd_on;
    669        1.1       bsh 		return 0;
    670        1.1       bsh 
    671        1.9  nisimura 	/* XXX: Hack to support /usr/sbin/tpctl */
    672        1.9  nisimura 	case HPCFBIO_GCONF:
    673        1.9  nisimura 	{
    674        1.9  nisimura 		struct hpcfb_fbconf *fbconf = (struct hpcfb_fbconf*)data;
    675        1.9  nisimura 		if (fbconf->hf_conf_index != 0 &&
    676        1.9  nisimura 		    fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG)
    677        1.9  nisimura 			return EINVAL;
    678        1.9  nisimura 
    679        1.9  nisimura 		fbconf->hf_nconfs = 1;
    680        1.9  nisimura 		fbconf->hf_class = HPCFB_CLASS_RGBCOLOR;
    681        1.9  nisimura 		strncpy(fbconf->hf_name, "S3C24X0 LCD", HPCFB_MAXNAMELEN);
    682        1.9  nisimura 		strncpy(fbconf->hf_conf_name, "default", HPCFB_MAXNAMELEN);
    683        1.9  nisimura 		fbconf->hf_height = sc->panel_info->panel_height;
    684        1.9  nisimura 		fbconf->hf_width = sc->panel_info->panel_width;
    685        1.9  nisimura 		fbconf->hf_baseaddr = 0x0;
    686        1.9  nisimura 		fbconf->hf_offset = 0x0;
    687        1.9  nisimura 		fbconf->hf_bytes_per_line = sc->panel_info->panel_width * (16/8);
    688        1.9  nisimura 		fbconf->hf_nplanes = 0;
    689        1.9  nisimura 		fbconf->hf_bytes_per_plane = 0;
    690        1.9  nisimura 		fbconf->hf_pack_width = 16;
    691        1.9  nisimura 		fbconf->hf_pixels_per_pack = 1;
    692        1.9  nisimura 		fbconf->hf_pixel_width = 16;
    693        1.9  nisimura 
    694        1.9  nisimura 		fbconf->hf_access_flags = 0;
    695        1.9  nisimura 		fbconf->hf_order_flags = HPCFB_REVORDER_WORD;
    696        1.9  nisimura 		fbconf->hf_reg_offset = 0x0;
    697        1.9  nisimura 
    698        1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_red_width = 5;
    699        1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_red_shift = 11;
    700        1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_green_width = 6;
    701        1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_green_shift = 5;
    702        1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_blue_width = 5;
    703        1.9  nisimura 		fbconf->hf_u.hf_rgb.hf_blue_shift = 0;
    704        1.9  nisimura 
    705        1.9  nisimura 		fbconf->hf_ext_size = 0;
    706        1.9  nisimura 		fbconf->hf_ext_data = NULL;
    707        1.9  nisimura 
    708        1.9  nisimura 		return 0;
    709        1.9  nisimura 	}
    710        1.9  nisimura 
    711        1.1       bsh 	case WSDISPLAYIO_GCURPOS:
    712        1.1       bsh 	case WSDISPLAYIO_SCURPOS:
    713        1.1       bsh 	case WSDISPLAYIO_GCURMAX:
    714        1.1       bsh 	case WSDISPLAYIO_GCURSOR:
    715        1.1       bsh 	case WSDISPLAYIO_SCURSOR:
    716        1.1       bsh 		return EPASSTHROUGH;	/* XXX */
    717        1.1       bsh 	}
    718        1.1       bsh 
    719        1.1       bsh 	return EPASSTHROUGH;
    720        1.1       bsh }
    721        1.1       bsh 
    722        1.1       bsh paddr_t
    723        1.4      jmmv s3c24x0_lcd_mmap(void *v, void *vs, off_t offset, int prot)
    724        1.1       bsh {
    725        1.1       bsh 	struct s3c24x0_lcd_softc *sc = v;
    726        1.1       bsh 	struct s3c24x0_lcd_screen *screen = sc->active;  /* ??? */
    727        1.9  nisimura 	paddr_t ret;
    728        1.9  nisimura 
    729        1.9  nisimura 	/*	printf("s3c24x0_lcd_mmap: screen: %p, offset: %ld\n", screen, (long)offset);*/
    730        1.1       bsh 
    731        1.1       bsh 	if (screen == NULL)
    732        1.1       bsh 		return -1;
    733        1.1       bsh 
    734        1.9  nisimura 	ret = bus_dmamem_mmap(sc->dma_tag, screen->segs, screen->nsegs,
    735        1.1       bsh 	    offset, prot, BUS_DMA_WAITOK|BUS_DMA_COHERENT);
    736        1.9  nisimura 	/*	printf("s3c24x0_lcd_mmap: ret: %lx\n", ret);*/
    737        1.9  nisimura 	return ret;
    738        1.1       bsh }
    739        1.1       bsh 
    740        1.1       bsh 
    741        1.1       bsh static void
    742        1.1       bsh s3c24x0_lcd_cursor(void *cookie, int on, int row, int col)
    743        1.1       bsh {
    744        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    745        1.1       bsh 
    746        1.1       bsh 	(* scr->rinfo.ri_ops.cursor)(&scr->rinfo, on, row, col);
    747        1.1       bsh }
    748        1.1       bsh 
    749        1.1       bsh static int
    750        1.1       bsh s3c24x0_lcd_mapchar(void *cookie, int c, unsigned int *cp)
    751        1.1       bsh {
    752        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    753        1.1       bsh 
    754        1.1       bsh 	return (* scr->rinfo.ri_ops.mapchar)(&scr->rinfo, c, cp);
    755        1.1       bsh }
    756        1.1       bsh 
    757        1.1       bsh static void
    758        1.1       bsh s3c24x0_lcd_putchar(void *cookie, int row, int col, u_int uc, long attr)
    759        1.1       bsh {
    760        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    761        1.1       bsh 
    762        1.1       bsh 	(* scr->rinfo.ri_ops.putchar)(&scr->rinfo,
    763        1.1       bsh 	    row, col, uc, attr);
    764        1.1       bsh }
    765        1.1       bsh 
    766        1.1       bsh static void
    767        1.1       bsh s3c24x0_lcd_copycols(void *cookie, int row, int src, int dst, int num)
    768        1.1       bsh {
    769        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    770        1.1       bsh 
    771        1.1       bsh 	(* scr->rinfo.ri_ops.copycols)(&scr->rinfo,
    772        1.1       bsh 	    row, src, dst, num);
    773        1.1       bsh }
    774        1.1       bsh 
    775        1.1       bsh static void
    776        1.1       bsh s3c24x0_lcd_erasecols(void *cookie, int row, int col, int num, long attr)
    777        1.1       bsh {
    778        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    779        1.1       bsh 
    780        1.1       bsh 	(* scr->rinfo.ri_ops.erasecols)(&scr->rinfo,
    781        1.1       bsh 	    row, col, num, attr);
    782        1.1       bsh }
    783        1.1       bsh 
    784        1.1       bsh static void
    785        1.1       bsh s3c24x0_lcd_copyrows(void *cookie, int src, int dst, int num)
    786        1.1       bsh {
    787        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    788        1.1       bsh 
    789        1.1       bsh 	(* scr->rinfo.ri_ops.copyrows)(&scr->rinfo,
    790        1.1       bsh 	    src, dst, num);
    791        1.1       bsh }
    792        1.1       bsh 
    793        1.1       bsh static void
    794        1.1       bsh s3c24x0_lcd_eraserows(void *cookie, int row, int num, long attr)
    795        1.1       bsh {
    796        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    797        1.1       bsh 
    798        1.1       bsh 	(* scr->rinfo.ri_ops.eraserows)(&scr->rinfo,
    799        1.1       bsh 	    row, num, attr);
    800        1.1       bsh }
    801        1.1       bsh 
    802        1.1       bsh static int
    803        1.1       bsh s3c24x0_lcd_alloc_attr(void *cookie, int fg, int bg, int flg, long *attr)
    804        1.1       bsh {
    805        1.1       bsh 	struct s3c24x0_lcd_screen *scr = cookie;
    806        1.1       bsh 
    807        1.1       bsh 	return (* scr->rinfo.ri_ops.allocattr)(&scr->rinfo,
    808        1.1       bsh 	    fg, bg, flg, attr);
    809        1.1       bsh }
    810        1.1       bsh 
    811        1.1       bsh 
    812        1.1       bsh const struct wsdisplay_emulops s3c24x0_lcd_emulops = {
    813        1.1       bsh 	s3c24x0_lcd_cursor,
    814        1.1       bsh 	s3c24x0_lcd_mapchar,
    815        1.1       bsh 	s3c24x0_lcd_putchar,
    816        1.1       bsh 	s3c24x0_lcd_copycols,
    817        1.1       bsh 	s3c24x0_lcd_erasecols,
    818        1.1       bsh 	s3c24x0_lcd_copyrows,
    819        1.1       bsh 	s3c24x0_lcd_eraserows,
    820        1.1       bsh 	s3c24x0_lcd_alloc_attr
    821        1.1       bsh };
    822        1.1       bsh 
    823        1.1       bsh #endif /* NWSDISPLAY > 0 */
    824