Home | History | Annotate | Line # | Download | only in ic
i128.c revision 1.1.12.3
      1  1.1.12.3  ad /*	$NetBSD: i128.c,v 1.1.12.3 2007/10/23 20:07:26 ad Exp $ */
      2  1.1.12.2  ad 
      3  1.1.12.2  ad /*-
      4  1.1.12.2  ad  * Copyright (c) 2007 Michael Lorenz
      5  1.1.12.2  ad  * All rights reserved.
      6  1.1.12.2  ad  *
      7  1.1.12.2  ad  * Redistribution and use in source and binary forms, with or without
      8  1.1.12.2  ad  * modification, are permitted provided that the following conditions
      9  1.1.12.2  ad  * are met:
     10  1.1.12.2  ad  * 1. Redistributions of source code must retain the above copyright
     11  1.1.12.2  ad  *    notice, this list of conditions and the following disclaimer.
     12  1.1.12.2  ad  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.12.2  ad  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.12.2  ad  *    documentation and/or other materials provided with the distribution.
     15  1.1.12.2  ad  * 3. Neither the name of The NetBSD Foundation nor the names of its
     16  1.1.12.2  ad  *    contributors may be used to endorse or promote products derived
     17  1.1.12.2  ad  *    from this software without specific prior written permission.
     18  1.1.12.2  ad  *
     19  1.1.12.2  ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1.12.2  ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1.12.2  ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1.12.2  ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1.12.2  ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1.12.2  ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1.12.2  ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1.12.2  ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1.12.2  ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1.12.2  ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1.12.2  ad  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1.12.2  ad  */
     31  1.1.12.2  ad 
     32  1.1.12.2  ad #include <sys/cdefs.h>
     33  1.1.12.3  ad __KERNEL_RCSID(0, "$NetBSD: i128.c,v 1.1.12.3 2007/10/23 20:07:26 ad Exp $");
     34  1.1.12.2  ad 
     35  1.1.12.2  ad #include <sys/param.h>
     36  1.1.12.2  ad #include <sys/systm.h>
     37  1.1.12.2  ad #include <sys/buf.h>
     38  1.1.12.2  ad #include <sys/device.h>
     39  1.1.12.2  ad #include <sys/conf.h>
     40  1.1.12.2  ad 
     41  1.1.12.3  ad #include <sys/bus.h>
     42  1.1.12.2  ad #include <machine/autoconf.h>
     43  1.1.12.2  ad 
     44  1.1.12.2  ad #include <dev/ic/i128reg.h>
     45  1.1.12.2  ad #include <dev/ic/i128var.h>
     46  1.1.12.2  ad 
     47  1.1.12.2  ad void
     48  1.1.12.2  ad i128_init(bus_space_tag_t tag, bus_space_handle_t regh, int stride, int depth)
     49  1.1.12.2  ad {
     50  1.1.12.2  ad 	/* initialize the i128's blitter */
     51  1.1.12.2  ad 	switch (depth) {
     52  1.1.12.2  ad 		case 8:
     53  1.1.12.2  ad 			bus_space_write_4(tag, regh, BUF_CTRL, BC_PSIZ_8B);
     54  1.1.12.2  ad 			break;
     55  1.1.12.2  ad 		case 16:
     56  1.1.12.2  ad 			bus_space_write_4(tag, regh, BUF_CTRL, BC_PSIZ_16B);
     57  1.1.12.2  ad 			break;
     58  1.1.12.2  ad 		case 32:
     59  1.1.12.2  ad 			bus_space_write_4(tag, regh, BUF_CTRL, BC_PSIZ_32B);
     60  1.1.12.2  ad 			break;
     61  1.1.12.2  ad 		default:
     62  1.1.12.2  ad 			aprint_error("i128: unsupported colour depth (%d)\n",
     63  1.1.12.2  ad 			    depth);
     64  1.1.12.2  ad 			return;
     65  1.1.12.2  ad 	}
     66  1.1.12.2  ad 
     67  1.1.12.2  ad 	bus_space_write_4(tag, regh, DE_PGE, 0);
     68  1.1.12.2  ad 	bus_space_write_4(tag, regh, DE_SORG, 0);
     69  1.1.12.2  ad 	bus_space_write_4(tag, regh, DE_DORG, 0);
     70  1.1.12.2  ad 	bus_space_write_4(tag, regh, DE_MSRC, 0);
     71  1.1.12.2  ad 	bus_space_write_4(tag, regh, DE_WKEY, 0);
     72  1.1.12.2  ad 	bus_space_write_4(tag, regh, DE_SPTCH, stride);
     73  1.1.12.2  ad 	bus_space_write_4(tag, regh, DE_DPTCH, stride);
     74  1.1.12.2  ad 	bus_space_write_4(tag, regh, RMSK, 0);
     75  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY4_ZM, ZOOM_NONE);
     76  1.1.12.2  ad 	bus_space_write_4(tag, regh, LPAT, 0xffffffff);
     77  1.1.12.2  ad 	bus_space_write_4(tag, regh, ACNTRL, 0);
     78  1.1.12.2  ad 	bus_space_write_4(tag, regh, INTM, 3);
     79  1.1.12.2  ad 	bus_space_write_4(tag, regh, CLPTL, 0x00000000);
     80  1.1.12.2  ad 	bus_space_write_4(tag, regh, CLPBR, 0x1fff0fff);
     81  1.1.12.2  ad 	bus_space_write_4(tag, regh, MASK, 0xffffffff);
     82  1.1.12.2  ad }
     83  1.1.12.2  ad 
     84  1.1.12.2  ad void
     85  1.1.12.2  ad i128_bitblt(bus_space_tag_t tag, bus_space_handle_t regh, int xs, int ys,
     86  1.1.12.2  ad     int xd, int yd, int wi, int he, int rop)
     87  1.1.12.2  ad {
     88  1.1.12.2  ad 	int dir = 0;
     89  1.1.12.2  ad 
     90  1.1.12.2  ad 	if (xs < xd) {
     91  1.1.12.2  ad 		dir |= DIR_RL;
     92  1.1.12.2  ad 		xs += wi - 1;
     93  1.1.12.2  ad 		xd += wi - 1;
     94  1.1.12.2  ad 	}
     95  1.1.12.2  ad 	if (ys < yd) {
     96  1.1.12.2  ad 		dir |= DIR_BT;
     97  1.1.12.2  ad 		ys += he - 1;
     98  1.1.12.2  ad 		yd += he - 1;
     99  1.1.12.2  ad 	}
    100  1.1.12.2  ad 
    101  1.1.12.2  ad 	I128_READY(tag, regh);
    102  1.1.12.2  ad 	bus_space_write_4(tag, regh, CMD,
    103  1.1.12.2  ad 	    (rop & 0xff) << 8 | CO_BITBLT);
    104  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY3_DIR, dir);
    105  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY2_WH, (wi << 16) | he);
    106  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY0_SRC, (xs << 16) | ys);
    107  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY1_DST, (xd << 16) | yd);
    108  1.1.12.2  ad 	I128_DONE(tag, regh);
    109  1.1.12.2  ad }
    110  1.1.12.2  ad 
    111  1.1.12.2  ad void
    112  1.1.12.2  ad i128_rectfill(bus_space_tag_t tag, bus_space_handle_t regh, int x, int y,
    113  1.1.12.2  ad     int wi, int he, uint32_t color)
    114  1.1.12.2  ad {
    115  1.1.12.2  ad 
    116  1.1.12.2  ad 	I128_READY(tag, regh);
    117  1.1.12.2  ad 	bus_space_write_4(tag, regh, CMD,
    118  1.1.12.2  ad 	    CS_SOLID << 16 | (CR_COPY) << 8 | CO_BITBLT);
    119  1.1.12.2  ad 	bus_space_write_4(tag, regh, FORE, color);
    120  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY3_DIR, 0);
    121  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY2_WH, (wi << 16) | he);
    122  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY0_SRC, 0);
    123  1.1.12.2  ad 	bus_space_write_4(tag, regh, XY1_DST, (x << 16) | y);
    124  1.1.12.2  ad 	I128_DONE(tag, regh);
    125  1.1.12.2  ad }
    126