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