1 /* $NetBSD: i128.c,v 1.2 2007/10/19 11:59:52 ad Exp $ */
4 * Copyright (c) 2007 Michael Lorenz
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: i128.c,v 1.2 2007/10/19 11:59:52 ad Exp $");
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <sys/device.h>
39 #include <machine/autoconf.h>
41 #include <dev/ic/i128reg.h>
42 #include <dev/ic/i128var.h>
45 i128_init(bus_space_tag_t tag
, bus_space_handle_t regh
, int stride
, int depth
)
47 /* initialize the i128's blitter */
50 bus_space_write_4(tag
, regh
, BUF_CTRL
, BC_PSIZ_8B
);
53 bus_space_write_4(tag
, regh
, BUF_CTRL
, BC_PSIZ_16B
);
56 bus_space_write_4(tag
, regh
, BUF_CTRL
, BC_PSIZ_32B
);
59 aprint_error("i128: unsupported colour depth (%d)\n",
64 bus_space_write_4(tag
, regh
, DE_PGE
, 0);
65 bus_space_write_4(tag
, regh
, DE_SORG
, 0);
66 bus_space_write_4(tag
, regh
, DE_DORG
, 0);
67 bus_space_write_4(tag
, regh
, DE_MSRC
, 0);
68 bus_space_write_4(tag
, regh
, DE_WKEY
, 0);
69 bus_space_write_4(tag
, regh
, DE_SPTCH
, stride
);
70 bus_space_write_4(tag
, regh
, DE_DPTCH
, stride
);
71 bus_space_write_4(tag
, regh
, RMSK
, 0);
72 bus_space_write_4(tag
, regh
, XY4_ZM
, ZOOM_NONE
);
73 bus_space_write_4(tag
, regh
, LPAT
, 0xffffffff);
74 bus_space_write_4(tag
, regh
, ACNTRL
, 0);
75 bus_space_write_4(tag
, regh
, INTM
, 3);
76 bus_space_write_4(tag
, regh
, CLPTL
, 0x00000000);
77 bus_space_write_4(tag
, regh
, CLPBR
, 0x1fff0fff);
78 bus_space_write_4(tag
, regh
, MASK
, 0xffffffff);
82 i128_bitblt(bus_space_tag_t tag
, bus_space_handle_t regh
, int xs
, int ys
,
83 int xd
, int yd
, int wi
, int he
, int rop
)
98 I128_READY(tag
, regh
);
99 bus_space_write_4(tag
, regh
, CMD
,
100 (rop
& 0xff) << 8 | CO_BITBLT
);
101 bus_space_write_4(tag
, regh
, XY3_DIR
, dir
);
102 bus_space_write_4(tag
, regh
, XY2_WH
, (wi
<< 16) | he
);
103 bus_space_write_4(tag
, regh
, XY0_SRC
, (xs
<< 16) | ys
);
104 bus_space_write_4(tag
, regh
, XY1_DST
, (xd
<< 16) | yd
);
105 I128_DONE(tag
, regh
);
109 i128_rectfill(bus_space_tag_t tag
, bus_space_handle_t regh
, int x
, int y
,
110 int wi
, int he
, uint32_t color
)
113 I128_READY(tag
, regh
);
114 bus_space_write_4(tag
, regh
, CMD
,
115 CS_SOLID
<< 16 | (CR_COPY
) << 8 | CO_BITBLT
);
116 bus_space_write_4(tag
, regh
, FORE
, color
);
117 bus_space_write_4(tag
, regh
, XY3_DIR
, 0);
118 bus_space_write_4(tag
, regh
, XY2_WH
, (wi
<< 16) | he
);
119 bus_space_write_4(tag
, regh
, XY0_SRC
, 0);
120 bus_space_write_4(tag
, regh
, XY1_DST
, (x
<< 16) | y
);
121 I128_DONE(tag
, regh
);