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