Home | History | Annotate | Line # | Download | only in hpc
bivideo.c revision 1.1
      1  1.1  uch /*	$NetBSD: bivideo.c,v 1.1 2001/02/22 18:37:54 uch Exp $	*/
      2  1.1  uch 
      3  1.1  uch /*-
      4  1.1  uch  * Copyright (c) 1999
      5  1.1  uch  *         Shin Takemura and PocketBSD Project. All rights reserved.
      6  1.1  uch  *
      7  1.1  uch  * Redistribution and use in source and binary forms, with or without
      8  1.1  uch  * modification, are permitted provided that the following conditions
      9  1.1  uch  * are met:
     10  1.1  uch  * 1. Redistributions of source code must retain the above copyright
     11  1.1  uch  *    notice, this list of conditions and the following disclaimer.
     12  1.1  uch  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  uch  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  uch  *    documentation and/or other materials provided with the distribution.
     15  1.1  uch  * 3. All advertising materials mentioning features or use of this software
     16  1.1  uch  *    must display the following acknowledgement:
     17  1.1  uch  *	This product includes software developed by the PocketBSD project
     18  1.1  uch  *	and its contributors.
     19  1.1  uch  * 4. Neither the name of the project nor the names of its contributors
     20  1.1  uch  *    may be used to endorse or promote products derived from this software
     21  1.1  uch  *    without specific prior written permission.
     22  1.1  uch  *
     23  1.1  uch  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.1  uch  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.1  uch  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.1  uch  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.1  uch  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1  uch  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.1  uch  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1  uch  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1  uch  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1  uch  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1  uch  * SUCH DAMAGE.
     34  1.1  uch  *
     35  1.1  uch  */
     36  1.1  uch #define FBDEBUG
     37  1.1  uch static const char _copyright[] __attribute__ ((unused)) =
     38  1.1  uch     "Copyright (c) 1999 Shin Takemura.  All rights reserved.";
     39  1.1  uch static const char _rcsid[] __attribute__ ((unused)) =
     40  1.1  uch     "$Id: bivideo.c,v 1.1 2001/02/22 18:37:54 uch Exp $";
     41  1.1  uch 
     42  1.1  uch #include <sys/param.h>
     43  1.1  uch #include <sys/systm.h>
     44  1.1  uch #include <sys/kernel.h>
     45  1.1  uch #include <sys/device.h>
     46  1.1  uch #include <sys/conf.h>
     47  1.1  uch #include <sys/malloc.h>
     48  1.1  uch #include <sys/buf.h>
     49  1.1  uch #include <sys/ioctl.h>
     50  1.1  uch #include <sys/reboot.h>
     51  1.1  uch 
     52  1.1  uch #include <uvm/uvm_extern.h>
     53  1.1  uch 
     54  1.1  uch #include <machine/bus.h>
     55  1.1  uch #include <machine/autoconf.h>
     56  1.1  uch #include <machine/bootinfo.h>
     57  1.1  uch #include <machine/platid.h>
     58  1.1  uch #include <machine/platid_mask.h>
     59  1.1  uch #include <machine/config_hook.h>
     60  1.1  uch 
     61  1.1  uch #include <dev/wscons/wsconsio.h>
     62  1.1  uch #include <dev/wscons/wsdisplayvar.h>
     63  1.1  uch 
     64  1.1  uch #include <dev/rasops/rasops.h>
     65  1.1  uch 
     66  1.1  uch #include <dev/hpc/hpcfbvar.h>
     67  1.1  uch #include <dev/hpc/hpcfbio.h>
     68  1.1  uch #include <dev/hpc/bivideovar.h>
     69  1.1  uch #include <dev/hpc/hpccmapvar.h>
     70  1.1  uch 
     71  1.1  uch #define VPRINTF(arg)	do { if (bootverbose) printf arg; } while(0);
     72  1.1  uch 
     73  1.1  uch /*
     74  1.1  uch  *  global variables
     75  1.1  uch  */
     76  1.1  uch int bivideo_dont_attach = 0;
     77  1.1  uch 
     78  1.1  uch /*
     79  1.1  uch  *  function prototypes
     80  1.1  uch  */
     81  1.1  uch int	bivideomatch __P((struct device *, struct cfdata *, void *));
     82  1.1  uch void	bivideoattach __P((struct device *, struct device *, void *));
     83  1.1  uch int	bivideo_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
     84  1.1  uch paddr_t	bivideo_mmap __P((void *, off_t, int));
     85  1.1  uch 
     86  1.1  uch struct bivideo_softc {
     87  1.1  uch 	struct device		sc_dev;
     88  1.1  uch 	struct hpcfb_fbconf	sc_fbconf;
     89  1.1  uch 	struct hpcfb_dspconf	sc_dspconf;
     90  1.1  uch 	void			*sc_powerhook;	/* power management hook */
     91  1.1  uch 	int			sc_powerstate;
     92  1.1  uch #define PWRSTAT_SUSPEND		(1<<0)
     93  1.1  uch #define PWRSTAT_LCD		(1<<1)
     94  1.1  uch #define PWRSTAT_BACKLIGHT	(1<<2)
     95  1.1  uch #define PWRSTAT_ALL		(0xffffffff)
     96  1.1  uch };
     97  1.1  uch static int bivideo_init __P((struct hpcfb_fbconf *fb));
     98  1.1  uch static void bivideo_power __P((int, void *));
     99  1.1  uch static void bivideo_update_powerstate __P((struct bivideo_softc *, int));
    100  1.1  uch 
    101  1.1  uch 
    102  1.1  uch /*
    103  1.1  uch  *  static variables
    104  1.1  uch  */
    105  1.1  uch struct cfattach bivideo_ca = {
    106  1.1  uch 	sizeof(struct bivideo_softc), bivideomatch, bivideoattach,
    107  1.1  uch };
    108  1.1  uch struct hpcfb_accessops bivideo_ha = {
    109  1.1  uch 	bivideo_ioctl, bivideo_mmap
    110  1.1  uch };
    111  1.1  uch 
    112  1.1  uch static int console_flag = 0;
    113  1.1  uch static int attach_flag = 0;
    114  1.1  uch 
    115  1.1  uch /*
    116  1.1  uch  *  function bodies
    117  1.1  uch  */
    118  1.1  uch int
    119  1.1  uch bivideomatch(parent, match, aux)
    120  1.1  uch 	struct device *parent;
    121  1.1  uch 	struct cfdata *match;
    122  1.1  uch 	void *aux;
    123  1.1  uch {
    124  1.1  uch 	struct mainbus_attach_args *ma = aux;
    125  1.1  uch 
    126  1.1  uch 	if (bivideo_dont_attach ||
    127  1.1  uch 	    strcmp(ma->ma_name, match->cf_driver->cd_name))
    128  1.1  uch 		return 0;
    129  1.1  uch 
    130  1.1  uch 	return (1);
    131  1.1  uch }
    132  1.1  uch 
    133  1.1  uch void
    134  1.1  uch bivideoattach(parent, self, aux)
    135  1.1  uch 	struct device *parent, *self;
    136  1.1  uch 	void *aux;
    137  1.1  uch {
    138  1.1  uch 	struct bivideo_softc *sc = (struct bivideo_softc *)self;
    139  1.1  uch 	struct hpcfb_attach_args ha;
    140  1.1  uch 
    141  1.1  uch 	if (attach_flag) {
    142  1.1  uch 		panic("%s(%d): bivideo attached twice", __FILE__, __LINE__);
    143  1.1  uch 	}
    144  1.1  uch 	attach_flag = 1;
    145  1.1  uch 
    146  1.1  uch 	printf(": ");
    147  1.1  uch 	if (bivideo_init(&sc->sc_fbconf) != 0) {
    148  1.1  uch 		/* just return so that hpcfb will not be attached */
    149  1.1  uch 		return;
    150  1.1  uch 	}
    151  1.1  uch 
    152  1.1  uch 	printf("pseudo video controller");
    153  1.1  uch 	if (console_flag) {
    154  1.1  uch 		printf(", console");
    155  1.1  uch 	}
    156  1.1  uch 	printf("\n");
    157  1.1  uch 	printf("%s: framebuffer address: 0x%08lx\n",
    158  1.1  uch 		sc->sc_dev.dv_xname, (u_long)bootinfo->fb_addr);
    159  1.1  uch 
    160  1.1  uch 	/* Add a suspend hook to power saving */
    161  1.1  uch 	sc->sc_powerstate = 0;
    162  1.1  uch 	sc->sc_powerhook = powerhook_establish(bivideo_power, sc);
    163  1.1  uch 	if (sc->sc_powerhook == NULL)
    164  1.1  uch 		printf("%s: WARNING: unable to establish power hook\n",
    165  1.1  uch 			sc->sc_dev.dv_xname);
    166  1.1  uch 
    167  1.1  uch 	ha.ha_console = console_flag;
    168  1.1  uch 	ha.ha_accessops = &bivideo_ha;
    169  1.1  uch 	ha.ha_accessctx = sc;
    170  1.1  uch 	ha.ha_curfbconf = 0;
    171  1.1  uch 	ha.ha_nfbconf = 1;
    172  1.1  uch 	ha.ha_fbconflist = &sc->sc_fbconf;
    173  1.1  uch 	ha.ha_curdspconf = 0;
    174  1.1  uch 	ha.ha_ndspconf = 1;
    175  1.1  uch 	ha.ha_dspconflist = &sc->sc_dspconf;
    176  1.1  uch 
    177  1.1  uch 	config_found(self, &ha, hpcfbprint);
    178  1.1  uch }
    179  1.1  uch 
    180  1.1  uch int
    181  1.1  uch bivideo_getcnfb(fb)
    182  1.1  uch 	struct hpcfb_fbconf *fb;
    183  1.1  uch {
    184  1.1  uch 	console_flag = 1;
    185  1.1  uch 
    186  1.1  uch 	return bivideo_init(fb);
    187  1.1  uch }
    188  1.1  uch 
    189  1.1  uch static int
    190  1.1  uch bivideo_init(fb)
    191  1.1  uch 	struct hpcfb_fbconf *fb;
    192  1.1  uch {
    193  1.1  uch 	/*
    194  1.1  uch 	 * get fb settings from bootinfo
    195  1.1  uch 	 */
    196  1.1  uch 	if (bootinfo == NULL ||
    197  1.1  uch 	    bootinfo->fb_addr == 0 ||
    198  1.1  uch 	    bootinfo->fb_line_bytes == 0 ||
    199  1.1  uch 	    bootinfo->fb_width == 0 ||
    200  1.1  uch 	    bootinfo->fb_height == 0) {
    201  1.1  uch 		printf("no frame buffer infomation.\n");
    202  1.1  uch 		return (-1);
    203  1.1  uch 	}
    204  1.1  uch 
    205  1.1  uch 	/* zero fill */
    206  1.1  uch 	bzero(fb, sizeof(*fb));
    207  1.1  uch 
    208  1.1  uch 	fb->hf_conf_index	= 0;	/* configuration index		*/
    209  1.1  uch 	fb->hf_nconfs		= 1;   	/* how many configurations	*/
    210  1.1  uch 	strcpy(fb->hf_name, "built-in video");
    211  1.1  uch 					/* frame buffer name		*/
    212  1.1  uch 	strcpy(fb->hf_conf_name, "default");
    213  1.1  uch 					/* configuration name		*/
    214  1.1  uch 	fb->hf_height		= bootinfo->fb_height;
    215  1.1  uch 	fb->hf_width		= bootinfo->fb_width;
    216  1.1  uch 	fb->hf_baseaddr		= (u_long)bootinfo->fb_addr;
    217  1.1  uch 	fb->hf_offset		= (u_long)bootinfo->fb_addr -
    218  1.1  uch 				      mips_ptob(mips_btop(bootinfo->fb_addr));
    219  1.1  uch 					/* frame buffer start offset   	*/
    220  1.1  uch 	fb->hf_bytes_per_line	= bootinfo->fb_line_bytes;
    221  1.1  uch 	fb->hf_nplanes		= 1;
    222  1.1  uch 	fb->hf_bytes_per_plane	= bootinfo->fb_height *
    223  1.1  uch 					bootinfo->fb_line_bytes;
    224  1.1  uch 
    225  1.1  uch 	fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
    226  1.1  uch 	fb->hf_access_flags |= HPCFB_ACCESS_WORD;
    227  1.1  uch 	fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
    228  1.1  uch 
    229  1.1  uch 	switch (bootinfo->fb_type) {
    230  1.1  uch 		/*
    231  1.1  uch 		 * gray scale
    232  1.1  uch 		 */
    233  1.1  uch 	case BIFB_D2_M2L_3:
    234  1.1  uch 	case BIFB_D2_M2L_3x2:
    235  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
    236  1.1  uch 		/* fall through */
    237  1.1  uch 	case BIFB_D2_M2L_0:
    238  1.1  uch 	case BIFB_D2_M2L_0x2:
    239  1.1  uch 		fb->hf_class = HPCFB_CLASS_GRAYSCALE;
    240  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
    241  1.1  uch 		fb->hf_pack_width = 8;
    242  1.1  uch 		fb->hf_pixels_per_pack = 4;
    243  1.1  uch 		fb->hf_pixel_width = 2;
    244  1.1  uch 		fb->hf_class_data_length = sizeof(struct hf_gray_tag);
    245  1.1  uch 		fb->hf_u.hf_gray.hf_flags = 0;	/* reserved for future use */
    246  1.1  uch 		break;
    247  1.1  uch 
    248  1.1  uch 	case BIFB_D4_M2L_F:
    249  1.1  uch 	case BIFB_D4_M2L_Fx2:
    250  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
    251  1.1  uch 		/* fall through */
    252  1.1  uch 	case BIFB_D4_M2L_0:
    253  1.1  uch 	case BIFB_D4_M2L_0x2:
    254  1.1  uch 		fb->hf_class = HPCFB_CLASS_GRAYSCALE;
    255  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
    256  1.1  uch 		fb->hf_pack_width = 8;
    257  1.1  uch 		fb->hf_pixels_per_pack = 2;
    258  1.1  uch 		fb->hf_pixel_width = 4;
    259  1.1  uch 		fb->hf_class_data_length = sizeof(struct hf_gray_tag);
    260  1.1  uch 		fb->hf_u.hf_gray.hf_flags = 0;	/* reserved for future use */
    261  1.1  uch 		break;
    262  1.1  uch 
    263  1.1  uch 		/*
    264  1.1  uch 		 * indexed color
    265  1.1  uch 		 */
    266  1.1  uch 	case BIFB_D8_FF:
    267  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
    268  1.1  uch 		/* fall through */
    269  1.1  uch 	case BIFB_D8_00:
    270  1.1  uch 		fb->hf_class = HPCFB_CLASS_INDEXCOLOR;
    271  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
    272  1.1  uch 		fb->hf_pack_width = 8;
    273  1.1  uch 		fb->hf_pixels_per_pack = 1;
    274  1.1  uch 		fb->hf_pixel_width = 8;
    275  1.1  uch 		fb->hf_class_data_length = sizeof(struct hf_indexed_tag);
    276  1.1  uch 		fb->hf_u.hf_indexed.hf_flags = 0; /* reserved for future use */
    277  1.1  uch 		break;
    278  1.1  uch 
    279  1.1  uch 		/*
    280  1.1  uch 		 * RGB color
    281  1.1  uch 		 */
    282  1.1  uch 	case BIFB_D16_FFFF:
    283  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
    284  1.1  uch 		/* fall through */
    285  1.1  uch 	case BIFB_D16_0000:
    286  1.1  uch 		fb->hf_class = HPCFB_CLASS_RGBCOLOR;
    287  1.1  uch 		fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
    288  1.1  uch #if BYTE_ORDER == LITTLE_ENDIAN
    289  1.1  uch 		fb->hf_swap_flags = HPCFB_SWAP_BYTE;
    290  1.1  uch #endif
    291  1.1  uch 		fb->hf_pack_width = 16;
    292  1.1  uch 		fb->hf_pixels_per_pack = 1;
    293  1.1  uch 		fb->hf_pixel_width = 16;
    294  1.1  uch 
    295  1.1  uch 		fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
    296  1.1  uch 		fb->hf_u.hf_rgb.hf_flags = 0;	/* reserved for future use */
    297  1.1  uch 
    298  1.1  uch 		fb->hf_u.hf_rgb.hf_red_width = 5;
    299  1.1  uch 		fb->hf_u.hf_rgb.hf_red_shift = 11;
    300  1.1  uch 		fb->hf_u.hf_rgb.hf_green_width = 6;
    301  1.1  uch 		fb->hf_u.hf_rgb.hf_green_shift = 5;
    302  1.1  uch 		fb->hf_u.hf_rgb.hf_blue_width = 5;
    303  1.1  uch 		fb->hf_u.hf_rgb.hf_blue_shift = 0;
    304  1.1  uch 		fb->hf_u.hf_rgb.hf_alpha_width = 0;
    305  1.1  uch 		fb->hf_u.hf_rgb.hf_alpha_shift = 0;
    306  1.1  uch 		break;
    307  1.1  uch 
    308  1.1  uch 	default:
    309  1.1  uch 		printf("unsupported type %d.\n", bootinfo->fb_type);
    310  1.1  uch 		return (-1);
    311  1.1  uch 		break;
    312  1.1  uch 	}
    313  1.1  uch 
    314  1.1  uch 	return (0); /* no error */
    315  1.1  uch }
    316  1.1  uch 
    317  1.1  uch static void
    318  1.1  uch bivideo_power(why, arg)
    319  1.1  uch 	int why;
    320  1.1  uch 	void *arg;
    321  1.1  uch {
    322  1.1  uch 	struct bivideo_softc *sc = arg;
    323  1.1  uch 
    324  1.1  uch 	switch (why) {
    325  1.1  uch 	case PWR_SUSPEND:
    326  1.1  uch 	case PWR_STANDBY:
    327  1.1  uch 		sc->sc_powerstate |= PWRSTAT_SUSPEND;
    328  1.1  uch 		bivideo_update_powerstate(sc, PWRSTAT_ALL);
    329  1.1  uch 		break;
    330  1.1  uch 	case PWR_RESUME:
    331  1.1  uch 		sc->sc_powerstate &= ~PWRSTAT_SUSPEND;
    332  1.1  uch 		bivideo_update_powerstate(sc, PWRSTAT_ALL);
    333  1.1  uch 		break;
    334  1.1  uch 	}
    335  1.1  uch }
    336  1.1  uch 
    337  1.1  uch static void
    338  1.1  uch bivideo_update_powerstate(sc, updates)
    339  1.1  uch 	struct bivideo_softc *sc;
    340  1.1  uch 	int updates;
    341  1.1  uch {
    342  1.1  uch 	if (updates & PWRSTAT_LCD)
    343  1.1  uch 		config_hook_call(CONFIG_HOOK_POWERCONTROL,
    344  1.1  uch 		    CONFIG_HOOK_POWERCONTROL_LCD,
    345  1.1  uch 		    (void*)!(sc->sc_powerstate & PWRSTAT_SUSPEND));
    346  1.1  uch 
    347  1.1  uch 	if (updates & PWRSTAT_BACKLIGHT)
    348  1.1  uch 		config_hook_call(CONFIG_HOOK_POWERCONTROL,
    349  1.1  uch 		    CONFIG_HOOK_POWERCONTROL_LCDLIGHT,
    350  1.1  uch 		    (void*)(!(sc->sc_powerstate & PWRSTAT_SUSPEND) &&
    351  1.1  uch 			     (sc->sc_powerstate & PWRSTAT_BACKLIGHT)));
    352  1.1  uch }
    353  1.1  uch 
    354  1.1  uch int
    355  1.1  uch bivideo_ioctl(v, cmd, data, flag, p)
    356  1.1  uch 	void *v;
    357  1.1  uch 	u_long cmd;
    358  1.1  uch 	caddr_t data;
    359  1.1  uch 	int flag;
    360  1.1  uch 	struct proc *p;
    361  1.1  uch {
    362  1.1  uch 	struct bivideo_softc *sc = (struct bivideo_softc *)v;
    363  1.1  uch 	struct hpcfb_fbconf *fbconf;
    364  1.1  uch 	struct hpcfb_dspconf *dspconf;
    365  1.1  uch 	struct wsdisplay_cmap *cmap;
    366  1.1  uch 	struct wsdisplay_param *dispparam;
    367  1.1  uch 
    368  1.1  uch 	switch (cmd) {
    369  1.1  uch 	case WSDISPLAYIO_GETCMAP:
    370  1.1  uch 		cmap = (struct wsdisplay_cmap*)data;
    371  1.1  uch 
    372  1.1  uch 		if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
    373  1.1  uch 		    sc->sc_fbconf.hf_pack_width != 8 ||
    374  1.1  uch 		    256 <= cmap->index ||
    375  1.1  uch 		    256 < (cmap->index + cmap->count))
    376  1.1  uch 			return (EINVAL);
    377  1.1  uch 
    378  1.1  uch 		if (!uvm_useracc(cmap->red, cmap->count, B_WRITE) ||
    379  1.1  uch 		    !uvm_useracc(cmap->green, cmap->count, B_WRITE) ||
    380  1.1  uch 		    !uvm_useracc(cmap->blue, cmap->count, B_WRITE))
    381  1.1  uch 			return (EFAULT);
    382  1.1  uch 
    383  1.1  uch 		copyout(&bivideo_cmap_r[cmap->index], cmap->red, cmap->count);
    384  1.1  uch 		copyout(&bivideo_cmap_g[cmap->index], cmap->green,cmap->count);
    385  1.1  uch 		copyout(&bivideo_cmap_b[cmap->index], cmap->blue, cmap->count);
    386  1.1  uch 
    387  1.1  uch 		return (0);
    388  1.1  uch 
    389  1.1  uch 	case WSDISPLAYIO_PUTCMAP:
    390  1.1  uch 		/*
    391  1.1  uch 		 * This driver can't set color map.
    392  1.1  uch 		 */
    393  1.1  uch 		return (EINVAL);
    394  1.1  uch 
    395  1.1  uch 	case WSDISPLAYIO_GETPARAM:
    396  1.1  uch 		dispparam = (struct wsdisplay_param*)data;
    397  1.1  uch 		switch (dispparam->param) {
    398  1.1  uch 		case WSDISPLAYIO_PARAM_BACKLIGHT:
    399  1.1  uch 			dispparam->min = 0;
    400  1.1  uch 			dispparam->max = 1;
    401  1.1  uch 			dispparam->curval =
    402  1.1  uch 			    (sc->sc_powerstate & PWRSTAT_BACKLIGHT) ? 1 : 0;
    403  1.1  uch 			VPRINTF(("bivideo_ioctl: GETPARAM:BACKLIGHT:%d\n",
    404  1.1  uch 				dispparam->curval));
    405  1.1  uch 			break;
    406  1.1  uch 		case WSDISPLAYIO_PARAM_CONTRAST:
    407  1.1  uch 			VPRINTF(("bivideo_ioctl: GETPARAM:CONTRAST\n"));
    408  1.1  uch 			return (EINVAL);
    409  1.1  uch 		case WSDISPLAYIO_PARAM_BRIGHTNESS:
    410  1.1  uch 			VPRINTF(("bivideo_ioctl: GETPARAM:BRIGHTNESS\n"));
    411  1.1  uch 			return (EINVAL);
    412  1.1  uch 		default:
    413  1.1  uch 			return (EINVAL);
    414  1.1  uch 		}
    415  1.1  uch 		return (0);
    416  1.1  uch 
    417  1.1  uch 	case WSDISPLAYIO_SETPARAM:
    418  1.1  uch 		dispparam = (struct wsdisplay_param*)data;
    419  1.1  uch 		switch (dispparam->param) {
    420  1.1  uch 		case WSDISPLAYIO_PARAM_BACKLIGHT:
    421  1.1  uch 			if (dispparam->curval < 0 ||
    422  1.1  uch 			    1 < dispparam->curval)
    423  1.1  uch 				return (EINVAL);
    424  1.1  uch 			if (dispparam->curval == 0)
    425  1.1  uch 				sc->sc_powerstate &= ~PWRSTAT_BACKLIGHT;
    426  1.1  uch 			else
    427  1.1  uch 				sc->sc_powerstate |= PWRSTAT_BACKLIGHT;
    428  1.1  uch 			bivideo_update_powerstate(sc, PWRSTAT_BACKLIGHT);
    429  1.1  uch 			VPRINTF(("bivideo_ioctl: SETPARAM:BACKLIGHT:%d\n",
    430  1.1  uch 				(sc->sc_powerstate & PWRSTAT_BACKLIGHT)?1:0));
    431  1.1  uch 			break;
    432  1.1  uch 		case WSDISPLAYIO_PARAM_CONTRAST:
    433  1.1  uch 			VPRINTF(("bivideo_ioctl: SETPARAM:CONTRAST\n"));
    434  1.1  uch 			return (EINVAL);
    435  1.1  uch 		case WSDISPLAYIO_PARAM_BRIGHTNESS:
    436  1.1  uch 			VPRINTF(("mq200_ioctl: SETPARAM:BRIGHTNESS\n"));
    437  1.1  uch 			return (EINVAL);
    438  1.1  uch 		default:
    439  1.1  uch 			return (EINVAL);
    440  1.1  uch 		}
    441  1.1  uch 		return (0);
    442  1.1  uch 
    443  1.1  uch 	case HPCFBIO_GCONF:
    444  1.1  uch 		fbconf = (struct hpcfb_fbconf *)data;
    445  1.1  uch 		if (fbconf->hf_conf_index != 0 &&
    446  1.1  uch 		    fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
    447  1.1  uch 			return (EINVAL);
    448  1.1  uch 		}
    449  1.1  uch 		*fbconf = sc->sc_fbconf;	/* structure assignment */
    450  1.1  uch 		return (0);
    451  1.1  uch 	case HPCFBIO_SCONF:
    452  1.1  uch 		fbconf = (struct hpcfb_fbconf *)data;
    453  1.1  uch 		if (fbconf->hf_conf_index != 0 &&
    454  1.1  uch 		    fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
    455  1.1  uch 			return (EINVAL);
    456  1.1  uch 		}
    457  1.1  uch 		/*
    458  1.1  uch 		 * nothing to do because we have only one configration
    459  1.1  uch 		 */
    460  1.1  uch 		return (0);
    461  1.1  uch 	case HPCFBIO_GDSPCONF:
    462  1.1  uch 		dspconf = (struct hpcfb_dspconf *)data;
    463  1.1  uch 		if ((dspconf->hd_unit_index != 0 &&
    464  1.1  uch 		     dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
    465  1.1  uch 		    (dspconf->hd_conf_index != 0 &&
    466  1.1  uch 		     dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
    467  1.1  uch 			return (EINVAL);
    468  1.1  uch 		}
    469  1.1  uch 		*dspconf = sc->sc_dspconf;	/* structure assignment */
    470  1.1  uch 		return (0);
    471  1.1  uch 	case HPCFBIO_SDSPCONF:
    472  1.1  uch 		dspconf = (struct hpcfb_dspconf *)data;
    473  1.1  uch 		if ((dspconf->hd_unit_index != 0 &&
    474  1.1  uch 		     dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
    475  1.1  uch 		    (dspconf->hd_conf_index != 0 &&
    476  1.1  uch 		     dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
    477  1.1  uch 			return (EINVAL);
    478  1.1  uch 		}
    479  1.1  uch 		/*
    480  1.1  uch 		 * nothing to do
    481  1.1  uch 		 * because we have only one unit and one configration
    482  1.1  uch 		 */
    483  1.1  uch 		return (0);
    484  1.1  uch 	case HPCFBIO_GOP:
    485  1.1  uch 	case HPCFBIO_SOP:
    486  1.1  uch 		/*
    487  1.1  uch 		 * curently not implemented...
    488  1.1  uch 		 */
    489  1.1  uch 		return (EINVAL);
    490  1.1  uch 	}
    491  1.1  uch 
    492  1.1  uch 	return (ENOTTY);
    493  1.1  uch }
    494  1.1  uch 
    495  1.1  uch paddr_t
    496  1.1  uch bivideo_mmap(ctx, offset, prot)
    497  1.1  uch 	void *ctx;
    498  1.1  uch 	off_t offset;
    499  1.1  uch 	int prot;
    500  1.1  uch {
    501  1.1  uch 	struct bivideo_softc *sc = (struct bivideo_softc *)ctx;
    502  1.1  uch 
    503  1.1  uch 	if (offset < 0 ||
    504  1.1  uch 	    (sc->sc_fbconf.hf_bytes_per_plane +
    505  1.1  uch 		sc->sc_fbconf.hf_offset) <  offset)
    506  1.1  uch 		return -1;
    507  1.1  uch 
    508  1.1  uch 	return mips_btop((u_long)bootinfo->fb_addr + offset);
    509  1.1  uch }
    510