sunxi_mixer.c revision 1.5 1 1.5 jmcneill /* $NetBSD: sunxi_mixer.c,v 1.5 2019/02/05 21:01:38 jmcneill Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2019 Jared D. McNeill <jmcneill (at) invisible.ca>
5 1.1 jmcneill * All rights reserved.
6 1.1 jmcneill *
7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.1 jmcneill * modification, are permitted provided that the following conditions
9 1.1 jmcneill * are met:
10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill *
16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 jmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 jmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 jmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 jmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 jmcneill * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 jmcneill * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 jmcneill * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 jmcneill * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 jmcneill * SUCH DAMAGE.
27 1.1 jmcneill */
28 1.1 jmcneill
29 1.1 jmcneill #include <sys/cdefs.h>
30 1.5 jmcneill __KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.5 2019/02/05 21:01:38 jmcneill Exp $");
31 1.1 jmcneill
32 1.1 jmcneill #include <sys/param.h>
33 1.1 jmcneill #include <sys/bus.h>
34 1.1 jmcneill #include <sys/device.h>
35 1.1 jmcneill #include <sys/intr.h>
36 1.1 jmcneill #include <sys/systm.h>
37 1.1 jmcneill #include <sys/kernel.h>
38 1.1 jmcneill #include <sys/conf.h>
39 1.1 jmcneill
40 1.1 jmcneill #include <drm/drmP.h>
41 1.1 jmcneill #include <drm/drm_crtc.h>
42 1.1 jmcneill #include <drm/drm_crtc_helper.h>
43 1.1 jmcneill #include <drm/drm_plane_helper.h>
44 1.1 jmcneill
45 1.1 jmcneill #include <dev/fdt/fdtvar.h>
46 1.1 jmcneill #include <dev/fdt/fdt_port.h>
47 1.1 jmcneill
48 1.1 jmcneill #include <arm/sunxi/sunxi_drm.h>
49 1.1 jmcneill
50 1.1 jmcneill #define SUNXI_MIXER_FREQ 432000000
51 1.1 jmcneill
52 1.1 jmcneill #define GLB_BASE 0x00000
53 1.1 jmcneill #define BLD_BASE 0x01000
54 1.1 jmcneill #define OVL_BASE(n) (0x02000 + (n) * 0x1000)
55 1.3 jmcneill #define OVL_V_BASE OVL_BASE(0)
56 1.1 jmcneill #define OVL_UI_BASE OVL_BASE(1)
57 1.4 jmcneill #define VSU_BASE 0x20000
58 1.4 jmcneill #define CSC_BASE(n) ((n) == 0 ? 0xaa050 : 0xa0000)
59 1.1 jmcneill
60 1.1 jmcneill /* GLB registers */
61 1.1 jmcneill #define GLB_CTL 0x000
62 1.1 jmcneill #define GLB_CTL_EN __BIT(0)
63 1.1 jmcneill #define GLB_STS 0x004
64 1.1 jmcneill #define GLB_DBUFFER 0x008
65 1.1 jmcneill #define GLB_DBUFFER_DOUBLE_BUFFER_RDY __BIT(0)
66 1.1 jmcneill #define GLB_SIZE 0x00c
67 1.1 jmcneill
68 1.1 jmcneill /* BLD registers */
69 1.1 jmcneill #define BLD_FILL_COLOR_CTL 0x000
70 1.3 jmcneill #define BLD_FILL_COLOR_CTL_P1_EN __BIT(9)
71 1.1 jmcneill #define BLD_FILL_COLOR_CTL_P0_EN __BIT(8)
72 1.1 jmcneill #define BLD_CH_ISIZE(n) (0x008 + (n) * 0x10)
73 1.1 jmcneill #define BLD_CH_OFFSET(n) (0x00c + (n) * 0x10)
74 1.1 jmcneill #define BLD_CH_RTCTL 0x080
75 1.3 jmcneill #define BLD_CH_RTCTL_P1 __BITS(7,4)
76 1.1 jmcneill #define BLD_CH_RTCTL_P0 __BITS(3,0)
77 1.1 jmcneill #define BLD_SIZE 0x08c
78 1.1 jmcneill #define BLD_CTL(n) (0x090 + (n) * 0x04)
79 1.1 jmcneill
80 1.3 jmcneill /* OVL_V registers */
81 1.3 jmcneill #define OVL_V_ATTCTL(n) (0x000 + (n) * 0x30)
82 1.3 jmcneill #define OVL_V_ATTCTL_VIDEO_UI_SEL __BIT(15)
83 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT __BITS(12,8)
84 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_VYUY 0x00
85 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_YVYU 0x01
86 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_UYVY 0x02
87 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_YUYV 0x03
88 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_YUV422 0x06
89 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_YUV420 0x0a
90 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_YUV411 0x0e
91 1.3 jmcneill #define OVL_V_ATTCTL_LAY_FBFMT_XRGB_8888 0x04
92 1.3 jmcneill #define OVL_V_ATTCTL_LAY0_EN __BIT(0)
93 1.3 jmcneill #define OVL_V_MBSIZE(n) (0x004 + (n) * 0x30)
94 1.3 jmcneill #define OVL_V_COOR(n) (0x008 + (n) * 0x30)
95 1.3 jmcneill #define OVL_V_PITCH0(n) (0x00c + (n) * 0x30)
96 1.3 jmcneill #define OVL_V_PITCH1(n) (0x010 + (n) * 0x30)
97 1.3 jmcneill #define OVL_V_PITCH2(n) (0x014 + (n) * 0x30)
98 1.3 jmcneill #define OVL_V_TOP_LADD0(n) (0x018 + (n) * 0x30)
99 1.3 jmcneill #define OVL_V_TOP_LADD1(n) (0x01c + (n) * 0x30)
100 1.3 jmcneill #define OVL_V_TOP_LADD2(n) (0x020 + (n) * 0x30)
101 1.3 jmcneill #define OVL_V_FILL_COLOR(n) (0x0c0 + (n) * 0x4)
102 1.3 jmcneill #define OVL_V_TOP_HADD0 0x0d0
103 1.3 jmcneill #define OVL_V_TOP_HADD1 0x0d4
104 1.3 jmcneill #define OVL_V_TOP_HADD2 0x0d8
105 1.3 jmcneill #define OVL_V_TOP_HADD_LAYER0 __BITS(7,0)
106 1.3 jmcneill #define OVL_V_SIZE 0x0e8
107 1.3 jmcneill #define OVL_V_HDS_CTL0 0x0f0
108 1.3 jmcneill #define OVL_V_HDS_CTL1 0x0f4
109 1.3 jmcneill #define OVL_V_VDS_CTL0 0x0f8
110 1.3 jmcneill #define OVL_V_VDS_CTL1 0x0fc
111 1.3 jmcneill
112 1.1 jmcneill /* OVL_UI registers */
113 1.1 jmcneill #define OVL_UI_ATTR_CTL(n) (0x000 + (n) * 0x20)
114 1.1 jmcneill #define OVL_UI_ATTR_CTL_LAY_FBFMT __BITS(12,8)
115 1.1 jmcneill #define OVL_UI_ATTR_CTL_LAY_FBFMT_XRGB_8888 0x04
116 1.1 jmcneill #define OVL_UI_ATTR_CTL_LAY_EN __BIT(0)
117 1.1 jmcneill #define OVL_UI_MBSIZE(n) (0x004 + (n) * 0x20)
118 1.1 jmcneill #define OVL_UI_COOR(n) (0x008 + (n) * 0x20)
119 1.1 jmcneill #define OVL_UI_PITCH(n) (0x00c + (n) * 0x20)
120 1.1 jmcneill #define OVL_UI_TOP_LADD(n) (0x010 + (n) * 0x20)
121 1.1 jmcneill #define OVL_UI_TOP_HADD 0x080
122 1.1 jmcneill #define OVL_UI_TOP_HADD_LAYER0 __BITS(7,0)
123 1.1 jmcneill #define OVL_UI_SIZE 0x088
124 1.1 jmcneill
125 1.4 jmcneill /* VSU registers */
126 1.4 jmcneill #define VS_CTRL_REG 0x000
127 1.4 jmcneill #define VS_CTRL_COEF_SWITCH_EN __BIT(4)
128 1.4 jmcneill #define VS_CTRL_EN __BIT(0)
129 1.4 jmcneill #define VS_STATUS_REG 0x008
130 1.4 jmcneill #define VS_FIELD_CTRL_REG 0x00c
131 1.4 jmcneill #define VS_OUT_SIZE_REG 0x040
132 1.4 jmcneill #define VS_Y_SIZE_REG 0x080
133 1.4 jmcneill #define VS_Y_HSTEP_REG 0x088
134 1.4 jmcneill #define VS_Y_VSTEP_REG 0x08c
135 1.4 jmcneill #define VS_Y_HPHASE_REG 0x090
136 1.4 jmcneill #define VS_Y_VPHASE0_REG 0x098
137 1.4 jmcneill #define VS_Y_VPHASE1_REG 0x09c
138 1.4 jmcneill #define VS_C_SIZE_REG 0x0c0
139 1.4 jmcneill #define VS_C_HSTEP_REG 0x0c8
140 1.4 jmcneill #define VS_C_VSTEP_REG 0x0cc
141 1.4 jmcneill #define VS_C_HPHASE_REG 0x0d0
142 1.4 jmcneill #define VS_C_VPHASE0_REG 0x0d8
143 1.4 jmcneill #define VS_C_VPHASE1_REG 0x0dc
144 1.4 jmcneill #define VS_Y_HCOEF0_REG(n) (0x200 + (n) * 0x4)
145 1.4 jmcneill #define VS_Y_HCOEF1_REG(n) (0x300 + (n) * 0x4)
146 1.4 jmcneill #define VS_Y_VCOEF_REG(n) (0x400 + (n) * 0x4)
147 1.4 jmcneill #define VS_C_HCOEF0_REG(n) (0x600 + (n) * 0x4)
148 1.4 jmcneill #define VS_C_HCOEF1_REG(n) (0x700 + (n) * 0x4)
149 1.4 jmcneill #define VS_C_VCOEF_REG(n) (0x800 + (n) * 0x4)
150 1.4 jmcneill
151 1.4 jmcneill /* CSC registers */
152 1.4 jmcneill #define CSC_BYPASS_REG 0x000
153 1.4 jmcneill #define CSC_BYPASS_DISABLE __BIT(0)
154 1.4 jmcneill #define CSC_COEFF0_REG(n) (0x10 + 0x10 * (n))
155 1.4 jmcneill #define GLB_ALPHA_REG 0x040
156 1.4 jmcneill
157 1.1 jmcneill enum {
158 1.1 jmcneill MIXER_PORT_OUTPUT = 1,
159 1.1 jmcneill };
160 1.1 jmcneill
161 1.1 jmcneill static const char * const compatible[] = {
162 1.2 jmcneill "allwinner,sun8i-h3-de2-mixer-0",
163 1.1 jmcneill "allwinner,sun50i-a64-de2-mixer-0",
164 1.1 jmcneill "allwinner,sun50i-a64-de2-mixer-1",
165 1.1 jmcneill NULL
166 1.1 jmcneill };
167 1.1 jmcneill
168 1.1 jmcneill struct sunxi_mixer_softc;
169 1.1 jmcneill
170 1.1 jmcneill struct sunxi_mixer_crtc {
171 1.1 jmcneill struct drm_crtc base;
172 1.1 jmcneill struct sunxi_mixer_softc *sc;
173 1.1 jmcneill };
174 1.1 jmcneill
175 1.3 jmcneill struct sunxi_mixer_overlay {
176 1.3 jmcneill struct drm_plane base;
177 1.3 jmcneill struct sunxi_mixer_softc *sc;
178 1.3 jmcneill };
179 1.3 jmcneill
180 1.1 jmcneill struct sunxi_mixer_softc {
181 1.1 jmcneill device_t sc_dev;
182 1.1 jmcneill bus_space_tag_t sc_bst;
183 1.1 jmcneill bus_space_handle_t sc_bsh;
184 1.1 jmcneill int sc_phandle;
185 1.1 jmcneill
186 1.1 jmcneill struct sunxi_mixer_crtc sc_crtc;
187 1.3 jmcneill struct sunxi_mixer_overlay sc_overlay;
188 1.1 jmcneill
189 1.1 jmcneill struct fdt_device_ports sc_ports;
190 1.1 jmcneill };
191 1.1 jmcneill
192 1.1 jmcneill #define GLB_READ(sc, reg) \
193 1.1 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, GLB_BASE + (reg))
194 1.1 jmcneill #define GLB_WRITE(sc, reg, val) \
195 1.1 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, GLB_BASE + (reg), (val))
196 1.1 jmcneill
197 1.1 jmcneill #define BLD_READ(sc, reg) \
198 1.1 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, BLD_BASE + (reg))
199 1.1 jmcneill #define BLD_WRITE(sc, reg, val) \
200 1.1 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, BLD_BASE + (reg), (val))
201 1.1 jmcneill
202 1.3 jmcneill #define OVL_V_READ(sc, reg) \
203 1.3 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, OVL_V_BASE + (reg))
204 1.3 jmcneill #define OVL_V_WRITE(sc, reg, val) \
205 1.3 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, OVL_V_BASE + (reg), (val))
206 1.3 jmcneill
207 1.1 jmcneill #define OVL_UI_READ(sc, reg) \
208 1.1 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, OVL_UI_BASE + (reg))
209 1.1 jmcneill #define OVL_UI_WRITE(sc, reg, val) \
210 1.1 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, OVL_UI_BASE + (reg), (val))
211 1.1 jmcneill
212 1.4 jmcneill #define VSU_READ(sc, reg) \
213 1.4 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, VSU_BASE + (reg))
214 1.4 jmcneill #define VSU_WRITE(sc, reg, val) \
215 1.4 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, VSU_BASE + (reg), (val))
216 1.4 jmcneill
217 1.4 jmcneill #define CSC_READ(sc, n, reg) \
218 1.4 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, CSC_BASE(n) + (reg))
219 1.4 jmcneill #define CSC_WRITE(sc, n, reg, val) \
220 1.4 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, CSC_BASE(n) + (reg), (val))
221 1.4 jmcneill
222 1.3 jmcneill #define to_sunxi_mixer_crtc(x) container_of(x, struct sunxi_mixer_crtc, base)
223 1.3 jmcneill #define to_sunxi_mixer_overlay(x) container_of(x, struct sunxi_mixer_overlay, base)
224 1.1 jmcneill
225 1.5 jmcneill static int
226 1.5 jmcneill sunxi_mixer_mode_do_set_base(struct drm_crtc *crtc, struct drm_framebuffer *fb,
227 1.5 jmcneill int x, int y, int atomic)
228 1.5 jmcneill {
229 1.5 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
230 1.5 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
231 1.5 jmcneill struct sunxi_drm_framebuffer *sfb = atomic?
232 1.5 jmcneill to_sunxi_drm_framebuffer(fb) :
233 1.5 jmcneill to_sunxi_drm_framebuffer(crtc->primary->fb);
234 1.5 jmcneill
235 1.5 jmcneill uint64_t paddr = (uint64_t)sfb->obj->dmamap->dm_segs[0].ds_addr;
236 1.5 jmcneill
237 1.5 jmcneill uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0;
238 1.5 jmcneill uint32_t laddr = paddr & 0xffffffff;
239 1.5 jmcneill
240 1.5 jmcneill /* Framebuffer start address */
241 1.5 jmcneill OVL_UI_WRITE(sc, OVL_UI_TOP_HADD, haddr);
242 1.5 jmcneill OVL_UI_WRITE(sc, OVL_UI_TOP_LADD(0), laddr);
243 1.5 jmcneill
244 1.5 jmcneill return 0;
245 1.5 jmcneill }
246 1.5 jmcneill
247 1.1 jmcneill static void
248 1.1 jmcneill sunxi_mixer_destroy(struct drm_crtc *crtc)
249 1.1 jmcneill {
250 1.1 jmcneill drm_crtc_cleanup(crtc);
251 1.1 jmcneill }
252 1.1 jmcneill
253 1.5 jmcneill static int
254 1.5 jmcneill sunxi_mixer_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
255 1.5 jmcneill struct drm_pending_vblank_event *event, uint32_t flags)
256 1.5 jmcneill {
257 1.5 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
258 1.5 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
259 1.5 jmcneill unsigned long irqflags;
260 1.5 jmcneill
261 1.5 jmcneill drm_crtc_wait_one_vblank(crtc);
262 1.5 jmcneill
263 1.5 jmcneill sunxi_mixer_mode_do_set_base(crtc, fb, 0, 0, true);
264 1.5 jmcneill
265 1.5 jmcneill /* Commit settings */
266 1.5 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
267 1.5 jmcneill
268 1.5 jmcneill if (event) {
269 1.5 jmcneill spin_lock_irqsave(&crtc->dev->event_lock, irqflags);
270 1.5 jmcneill drm_send_vblank_event(crtc->dev, drm_crtc_index(crtc), event);
271 1.5 jmcneill spin_unlock_irqrestore(&crtc->dev->event_lock, irqflags);
272 1.5 jmcneill }
273 1.5 jmcneill
274 1.5 jmcneill return 0;
275 1.5 jmcneill }
276 1.5 jmcneill
277 1.1 jmcneill static const struct drm_crtc_funcs sunxi_mixer_crtc_funcs = {
278 1.1 jmcneill .set_config = drm_crtc_helper_set_config,
279 1.5 jmcneill .page_flip = sunxi_mixer_page_flip,
280 1.1 jmcneill .destroy = sunxi_mixer_destroy,
281 1.1 jmcneill };
282 1.1 jmcneill
283 1.1 jmcneill static void
284 1.1 jmcneill sunxi_mixer_dpms(struct drm_crtc *crtc, int mode)
285 1.1 jmcneill {
286 1.1 jmcneill }
287 1.1 jmcneill
288 1.1 jmcneill static bool
289 1.1 jmcneill sunxi_mixer_mode_fixup(struct drm_crtc *crtc,
290 1.1 jmcneill const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode)
291 1.1 jmcneill {
292 1.1 jmcneill return true;
293 1.1 jmcneill }
294 1.1 jmcneill
295 1.1 jmcneill static int
296 1.1 jmcneill sunxi_mixer_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
297 1.1 jmcneill struct drm_display_mode *adjusted_mode, int x, int y,
298 1.1 jmcneill struct drm_framebuffer *old_fb)
299 1.1 jmcneill {
300 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
301 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
302 1.1 jmcneill uint32_t val;
303 1.1 jmcneill
304 1.1 jmcneill const uint32_t size = ((adjusted_mode->vdisplay - 1) << 16) |
305 1.1 jmcneill (adjusted_mode->hdisplay - 1);
306 1.1 jmcneill const uint32_t offset = (y << 16) | x;
307 1.1 jmcneill
308 1.1 jmcneill /* Set global size */
309 1.1 jmcneill GLB_WRITE(sc, GLB_SIZE, size);
310 1.1 jmcneill
311 1.1 jmcneill /* Enable pipe 0 */
312 1.3 jmcneill val = BLD_READ(sc, BLD_FILL_COLOR_CTL);
313 1.3 jmcneill val |= BLD_FILL_COLOR_CTL_P0_EN;
314 1.3 jmcneill BLD_WRITE(sc, BLD_FILL_COLOR_CTL, val);
315 1.1 jmcneill
316 1.1 jmcneill /* Set blender 0 input size */
317 1.1 jmcneill BLD_WRITE(sc, BLD_CH_ISIZE(0), size);
318 1.1 jmcneill /* Set blender 0 offset */
319 1.1 jmcneill BLD_WRITE(sc, BLD_CH_OFFSET(0), offset);
320 1.1 jmcneill /* Route channel 1 to pipe 0 */
321 1.3 jmcneill val = BLD_READ(sc, BLD_CH_RTCTL);
322 1.3 jmcneill val &= ~BLD_CH_RTCTL_P0;
323 1.3 jmcneill val |= __SHIFTIN(1, BLD_CH_RTCTL_P0);
324 1.3 jmcneill BLD_WRITE(sc, BLD_CH_RTCTL, val);
325 1.1 jmcneill /* Set blender output size */
326 1.1 jmcneill BLD_WRITE(sc, BLD_SIZE, size);
327 1.1 jmcneill
328 1.1 jmcneill /* Enable UI overlay in XRGB8888 mode */
329 1.1 jmcneill val = OVL_UI_ATTR_CTL_LAY_EN |
330 1.1 jmcneill __SHIFTIN(OVL_UI_ATTR_CTL_LAY_FBFMT_XRGB_8888, OVL_UI_ATTR_CTL_LAY_FBFMT);
331 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_ATTR_CTL(0), val);
332 1.1 jmcneill /* Set UI overlay layer size */
333 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_MBSIZE(0), size);
334 1.1 jmcneill /* Set UI overlay offset */
335 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_COOR(0), offset);
336 1.1 jmcneill /* Set UI overlay line size */
337 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_PITCH(0), adjusted_mode->hdisplay * 4);
338 1.1 jmcneill /* Set UI overlay window size */
339 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_SIZE, size);
340 1.1 jmcneill
341 1.1 jmcneill sunxi_mixer_mode_do_set_base(crtc, old_fb, x, y, 0);
342 1.1 jmcneill
343 1.1 jmcneill return 0;
344 1.1 jmcneill }
345 1.1 jmcneill
346 1.1 jmcneill static int
347 1.1 jmcneill sunxi_mixer_mode_set_base(struct drm_crtc *crtc, int x, int y,
348 1.1 jmcneill struct drm_framebuffer *old_fb)
349 1.1 jmcneill {
350 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
351 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
352 1.1 jmcneill
353 1.1 jmcneill sunxi_mixer_mode_do_set_base(crtc, old_fb, x, y, 0);
354 1.1 jmcneill
355 1.1 jmcneill /* Commit settings */
356 1.1 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
357 1.1 jmcneill
358 1.1 jmcneill return 0;
359 1.1 jmcneill }
360 1.1 jmcneill
361 1.1 jmcneill static int
362 1.1 jmcneill sunxi_mixer_mode_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
363 1.1 jmcneill int x, int y, enum mode_set_atomic state)
364 1.1 jmcneill {
365 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
366 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
367 1.1 jmcneill
368 1.1 jmcneill sunxi_mixer_mode_do_set_base(crtc, fb, x, y, 1);
369 1.1 jmcneill
370 1.1 jmcneill /* Commit settings */
371 1.1 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
372 1.1 jmcneill
373 1.1 jmcneill return 0;
374 1.1 jmcneill }
375 1.1 jmcneill
376 1.1 jmcneill static void
377 1.1 jmcneill sunxi_mixer_disable(struct drm_crtc *crtc)
378 1.1 jmcneill {
379 1.1 jmcneill }
380 1.1 jmcneill
381 1.1 jmcneill static void
382 1.1 jmcneill sunxi_mixer_prepare(struct drm_crtc *crtc)
383 1.1 jmcneill {
384 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
385 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
386 1.1 jmcneill
387 1.1 jmcneill /* RT enable */
388 1.1 jmcneill GLB_WRITE(sc, GLB_CTL, GLB_CTL_EN);
389 1.1 jmcneill }
390 1.1 jmcneill
391 1.1 jmcneill static void
392 1.1 jmcneill sunxi_mixer_commit(struct drm_crtc *crtc)
393 1.1 jmcneill {
394 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
395 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
396 1.1 jmcneill
397 1.1 jmcneill /* Commit settings */
398 1.1 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
399 1.1 jmcneill }
400 1.1 jmcneill
401 1.1 jmcneill static const struct drm_crtc_helper_funcs sunxi_mixer_crtc_helper_funcs = {
402 1.1 jmcneill .dpms = sunxi_mixer_dpms,
403 1.1 jmcneill .mode_fixup = sunxi_mixer_mode_fixup,
404 1.1 jmcneill .mode_set = sunxi_mixer_mode_set,
405 1.1 jmcneill .mode_set_base = sunxi_mixer_mode_set_base,
406 1.1 jmcneill .mode_set_base_atomic = sunxi_mixer_mode_set_base_atomic,
407 1.1 jmcneill .disable = sunxi_mixer_disable,
408 1.1 jmcneill .prepare = sunxi_mixer_prepare,
409 1.1 jmcneill .commit = sunxi_mixer_commit,
410 1.1 jmcneill };
411 1.1 jmcneill
412 1.3 jmcneill static void
413 1.3 jmcneill sunxi_mixer_overlay_destroy(struct drm_plane *plane)
414 1.3 jmcneill {
415 1.3 jmcneill }
416 1.3 jmcneill
417 1.3 jmcneill static bool
418 1.4 jmcneill sunxi_mixer_overlay_rgb(uint32_t drm_format)
419 1.3 jmcneill {
420 1.3 jmcneill switch (drm_format) {
421 1.3 jmcneill case DRM_FORMAT_XRGB8888:
422 1.3 jmcneill return true;
423 1.3 jmcneill default:
424 1.3 jmcneill return false;
425 1.3 jmcneill }
426 1.3 jmcneill }
427 1.3 jmcneill
428 1.3 jmcneill static u_int
429 1.3 jmcneill sunxi_mixer_overlay_format(uint32_t drm_format)
430 1.3 jmcneill {
431 1.3 jmcneill switch (drm_format) {
432 1.3 jmcneill case DRM_FORMAT_XRGB8888: return OVL_V_ATTCTL_LAY_FBFMT_XRGB_8888;
433 1.3 jmcneill case DRM_FORMAT_VYUY: return OVL_V_ATTCTL_LAY_FBFMT_VYUY;
434 1.3 jmcneill case DRM_FORMAT_YVYU: return OVL_V_ATTCTL_LAY_FBFMT_YVYU;
435 1.3 jmcneill case DRM_FORMAT_UYVY: return OVL_V_ATTCTL_LAY_FBFMT_UYVY;
436 1.3 jmcneill case DRM_FORMAT_YUYV: return OVL_V_ATTCTL_LAY_FBFMT_YUYV;
437 1.3 jmcneill case DRM_FORMAT_YUV422: return OVL_V_ATTCTL_LAY_FBFMT_YUV422;
438 1.3 jmcneill case DRM_FORMAT_YUV420: return OVL_V_ATTCTL_LAY_FBFMT_YUV420;
439 1.3 jmcneill case DRM_FORMAT_YUV411: return OVL_V_ATTCTL_LAY_FBFMT_YUV411;
440 1.3 jmcneill default: return 0; /* shouldn't happen */
441 1.3 jmcneill }
442 1.3 jmcneill }
443 1.3 jmcneill
444 1.4 jmcneill static const uint32_t lan3coefftab32_left[512] = {
445 1.4 jmcneill 0x40000000, 0x40fe0000, 0x3ffd0100, 0x3efc0100,
446 1.4 jmcneill 0x3efb0100, 0x3dfa0200, 0x3cf90200, 0x3bf80200,
447 1.4 jmcneill 0x39f70200, 0x37f70200, 0x35f70200, 0x33f70200,
448 1.4 jmcneill 0x31f70200, 0x2ef70200, 0x2cf70200, 0x2af70200,
449 1.4 jmcneill 0x27f70200, 0x24f80100, 0x22f80100, 0x1ef90100,
450 1.4 jmcneill 0x1cf90100, 0x19fa0100, 0x17fa0100, 0x14fb0100,
451 1.4 jmcneill 0x11fc0000, 0x0ffc0000, 0x0cfd0000, 0x0afd0000,
452 1.4 jmcneill 0x08fe0000, 0x05ff0000, 0x03ff0000, 0x02000000,
453 1.4 jmcneill
454 1.4 jmcneill 0x40000000, 0x40fe0000, 0x3ffd0100, 0x3efc0100,
455 1.4 jmcneill 0x3efb0100, 0x3dfa0200, 0x3cf90200, 0x3bf80200,
456 1.4 jmcneill 0x39f70200, 0x37f70200, 0x35f70200, 0x33f70200,
457 1.4 jmcneill 0x31f70200, 0x2ef70200, 0x2cf70200, 0x2af70200,
458 1.4 jmcneill 0x27f70200, 0x24f80100, 0x22f80100, 0x1ef90100,
459 1.4 jmcneill 0x1cf90100, 0x19fa0100, 0x17fa0100, 0x14fb0100,
460 1.4 jmcneill 0x11fc0000, 0x0ffc0000, 0x0cfd0000, 0x0afd0000,
461 1.4 jmcneill 0x08fe0000, 0x05ff0000, 0x03ff0000, 0x02000000,
462 1.4 jmcneill
463 1.4 jmcneill 0x3806fc02, 0x3805fc02, 0x3803fd01, 0x3801fe01,
464 1.4 jmcneill 0x3700fe01, 0x35ffff01, 0x35fdff01, 0x34fc0001,
465 1.4 jmcneill 0x34fb0000, 0x33fa0000, 0x31fa0100, 0x2ff90100,
466 1.4 jmcneill 0x2df80200, 0x2bf80200, 0x2af70200, 0x28f70200,
467 1.4 jmcneill 0x27f70200, 0x24f70300, 0x22f70300, 0x1ff70300,
468 1.4 jmcneill 0x1ef70300, 0x1cf70300, 0x1af70300, 0x18f70300,
469 1.4 jmcneill 0x16f80300, 0x13f80300, 0x11f90300, 0x0ef90300,
470 1.4 jmcneill 0x0efa0200, 0x0cfa0200, 0x0afb0200, 0x08fb0200,
471 1.4 jmcneill
472 1.4 jmcneill 0x320bfa02, 0x3309fa02, 0x3208fb02, 0x3206fb02,
473 1.4 jmcneill 0x3205fb02, 0x3104fc02, 0x3102fc01, 0x3001fd01,
474 1.4 jmcneill 0x3000fd01, 0x2ffffd01, 0x2efefe01, 0x2dfdfe01,
475 1.4 jmcneill 0x2bfcff01, 0x29fcff01, 0x28fbff01, 0x27fa0001,
476 1.4 jmcneill 0x26fa0000, 0x24f90000, 0x22f90100, 0x20f90100,
477 1.4 jmcneill 0x1ff80100, 0x1ef80100, 0x1cf80100, 0x1af80200,
478 1.4 jmcneill 0x18f80200, 0x17f80200, 0x15f80200, 0x12f80200,
479 1.4 jmcneill 0x11f90200, 0x0ff90200, 0x0df90200, 0x0cfa0200,
480 1.4 jmcneill
481 1.4 jmcneill 0x2e0efa01, 0x2f0dfa01, 0x2f0bfa01, 0x2e0afa01,
482 1.4 jmcneill 0x2e09fa01, 0x2e07fb01, 0x2d06fb01, 0x2d05fb01,
483 1.4 jmcneill 0x2c04fb01, 0x2b03fc01, 0x2a02fc01, 0x2a01fc01,
484 1.4 jmcneill 0x2800fd01, 0x28fffd01, 0x26fefd01, 0x25fefe01,
485 1.4 jmcneill 0x24fdfe01, 0x23fcfe01, 0x21fcff01, 0x20fbff01,
486 1.4 jmcneill 0x1efbff01, 0x1efbff00, 0x1cfa0000, 0x1bfa0000,
487 1.4 jmcneill 0x19fa0000, 0x18fa0000, 0x17f90000, 0x15f90100,
488 1.4 jmcneill 0x14f90100, 0x12f90100, 0x11f90100, 0x0ff90100,
489 1.4 jmcneill
490 1.4 jmcneill 0x2b10fa00, 0x2b0ffa00, 0x2b0efa00, 0x2b0cfa00,
491 1.4 jmcneill 0x2b0bfa00, 0x2a0afb01, 0x2a09fb01, 0x2908fb01,
492 1.4 jmcneill 0x2807fb01, 0x2806fb01, 0x2805fb01, 0x2604fc01,
493 1.4 jmcneill 0x2503fc01, 0x2502fc01, 0x2401fc01, 0x2301fc01,
494 1.4 jmcneill 0x2100fd01, 0x21fffd01, 0x21fffd01, 0x20fefd01,
495 1.4 jmcneill 0x1dfefe01, 0x1cfdfe01, 0x1cfdfe00, 0x1bfcfe00,
496 1.4 jmcneill 0x19fcff00, 0x19fbff00, 0x17fbff00, 0x16fbff00,
497 1.4 jmcneill 0x15fbff00, 0x14fb0000, 0x13fa0000, 0x11fa0000,
498 1.4 jmcneill
499 1.4 jmcneill 0x2811fcff, 0x2810fcff, 0x280ffbff, 0x280efbff,
500 1.4 jmcneill 0x270dfb00, 0x270cfb00, 0x270bfb00, 0x260afb00,
501 1.4 jmcneill 0x2609fb00, 0x2508fb00, 0x2507fb00, 0x2407fb00,
502 1.4 jmcneill 0x2406fc00, 0x2305fc00, 0x2204fc00, 0x2203fc00,
503 1.4 jmcneill 0x2103fc00, 0x2002fc00, 0x1f01fd00, 0x1e01fd00,
504 1.4 jmcneill 0x1d00fd00, 0x1dfffd00, 0x1cfffd00, 0x1bfefd00,
505 1.4 jmcneill 0x1afefe00, 0x19fefe00, 0x18fdfe00, 0x17fdfe00,
506 1.4 jmcneill 0x16fdfe00, 0x15fcff00, 0x13fcff00, 0x12fcff00,
507 1.4 jmcneill
508 1.4 jmcneill 0x2512fdfe, 0x2511fdff, 0x2410fdff, 0x240ffdff,
509 1.4 jmcneill 0x240efcff, 0x240dfcff, 0x240dfcff, 0x240cfcff,
510 1.4 jmcneill 0x230bfcff, 0x230afc00, 0x2209fc00, 0x2108fc00,
511 1.4 jmcneill 0x2108fc00, 0x2007fc00, 0x2006fc00, 0x2005fc00,
512 1.4 jmcneill 0x1f05fc00, 0x1e04fc00, 0x1e03fc00, 0x1c03fd00,
513 1.4 jmcneill 0x1c02fd00, 0x1b02fd00, 0x1b01fd00, 0x1a00fd00,
514 1.4 jmcneill 0x1900fd00, 0x1800fd00, 0x17fffe00, 0x16fffe00,
515 1.4 jmcneill 0x16fefe00, 0x14fefe00, 0x13fefe00, 0x13fdfe00,
516 1.4 jmcneill
517 1.4 jmcneill 0x2212fffe, 0x2211fefe, 0x2211fefe, 0x2110fefe,
518 1.4 jmcneill 0x210ffeff, 0x220efdff, 0x210dfdff, 0x210dfdff,
519 1.4 jmcneill 0x210cfdff, 0x210bfdff, 0x200afdff, 0x200afdff,
520 1.4 jmcneill 0x1f09fdff, 0x1f08fdff, 0x1d08fd00, 0x1c07fd00,
521 1.4 jmcneill 0x1d06fd00, 0x1b06fd00, 0x1b05fd00, 0x1c04fd00,
522 1.4 jmcneill 0x1b04fd00, 0x1a03fd00, 0x1a03fd00, 0x1902fd00,
523 1.4 jmcneill 0x1802fd00, 0x1801fd00, 0x1701fd00, 0x1600fd00,
524 1.4 jmcneill 0x1400fe00, 0x1400fe00, 0x14fffe00, 0x13fffe00,
525 1.4 jmcneill
526 1.4 jmcneill 0x201200fe, 0x201100fe, 0x1f11fffe, 0x2010fffe,
527 1.4 jmcneill 0x1f0ffffe, 0x1e0ffffe, 0x1f0efeff, 0x1f0dfeff,
528 1.4 jmcneill 0x1f0dfeff, 0x1e0cfeff, 0x1e0bfeff, 0x1d0bfeff,
529 1.4 jmcneill 0x1d0afeff, 0x1d09fdff, 0x1d09fdff, 0x1c08fdff,
530 1.4 jmcneill 0x1c07fdff, 0x1b07fd00, 0x1b06fd00, 0x1a06fd00,
531 1.4 jmcneill 0x1a05fd00, 0x1805fd00, 0x1904fd00, 0x1804fd00,
532 1.4 jmcneill 0x1703fd00, 0x1703fd00, 0x1602fe00, 0x1502fe00,
533 1.4 jmcneill 0x1501fe00, 0x1401fe00, 0x1301fe00, 0x1300fe00,
534 1.4 jmcneill
535 1.4 jmcneill 0x1c1202fe, 0x1c1102fe, 0x1b1102fe, 0x1c1001fe,
536 1.4 jmcneill 0x1b1001fe, 0x1b0f01ff, 0x1b0e00ff, 0x1b0e00ff,
537 1.4 jmcneill 0x1b0d00ff, 0x1a0d00ff, 0x1a0c00ff, 0x1a0cffff,
538 1.4 jmcneill 0x1a0bffff, 0x1a0bffff, 0x1a0affff, 0x180affff,
539 1.4 jmcneill 0x1909ffff, 0x1809ffff, 0x1808ffff, 0x1808feff,
540 1.4 jmcneill 0x1807feff, 0x1707fe00, 0x1606fe00, 0x1506fe00,
541 1.4 jmcneill 0x1605fe00, 0x1505fe00, 0x1504fe00, 0x1304fe00,
542 1.4 jmcneill 0x1304fe00, 0x1303fe00, 0x1203fe00, 0x1203fe00,
543 1.4 jmcneill
544 1.4 jmcneill 0x181104ff, 0x191103ff, 0x191003ff, 0x181003ff,
545 1.4 jmcneill 0x180f03ff, 0x190f02ff, 0x190e02ff, 0x180e02ff,
546 1.4 jmcneill 0x180d02ff, 0x180d01ff, 0x180d01ff, 0x180c01ff,
547 1.4 jmcneill 0x180c01ff, 0x180b00ff, 0x170b00ff, 0x170a00ff,
548 1.4 jmcneill 0x170a00ff, 0x170900ff, 0x160900ff, 0x160900ff,
549 1.4 jmcneill 0x1608ffff, 0x1508ffff, 0x1507ff00, 0x1507ff00,
550 1.4 jmcneill 0x1407ff00, 0x1306ff00, 0x1306ff00, 0x1305ff00,
551 1.4 jmcneill 0x1205ff00, 0x1105ff00, 0x1204ff00, 0x1104ff00,
552 1.4 jmcneill
553 1.4 jmcneill 0x171005ff, 0x171005ff, 0x171004ff, 0x170f04ff,
554 1.4 jmcneill 0x160f04ff, 0x170f03ff, 0x170e03ff, 0x160e03ff,
555 1.4 jmcneill 0x160d03ff, 0x160d02ff, 0x160d02ff, 0x160c02ff,
556 1.4 jmcneill 0x160c02ff, 0x160c02ff, 0x160b01ff, 0x150b01ff,
557 1.4 jmcneill 0x150a01ff, 0x150a01ff, 0x150a01ff, 0x140901ff,
558 1.4 jmcneill 0x14090000, 0x14090000, 0x14080000, 0x13080000,
559 1.4 jmcneill 0x13070000, 0x12070000, 0x12070000, 0x12060000,
560 1.4 jmcneill 0x11060000, 0x11060000, 0x11050000, 0x1105ff00,
561 1.4 jmcneill
562 1.4 jmcneill 0x14100600, 0x15100500, 0x150f0500, 0x150f0500,
563 1.4 jmcneill 0x140f0500, 0x150e0400, 0x140e0400, 0x130e0400,
564 1.4 jmcneill 0x140d0400, 0x150d0300, 0x130d0300, 0x140c0300,
565 1.4 jmcneill 0x140c0300, 0x140c0200, 0x140b0200, 0x130b0200,
566 1.4 jmcneill 0x120b0200, 0x130a0200, 0x130a0200, 0x130a0100,
567 1.4 jmcneill 0x13090100, 0x12090100, 0x11090100, 0x12080100,
568 1.4 jmcneill 0x11080100, 0x10080100, 0x11070100, 0x11070000,
569 1.4 jmcneill 0x10070000, 0x11060000, 0x10060000, 0x10060000,
570 1.4 jmcneill
571 1.4 jmcneill 0x140f0600, 0x140f0600, 0x130f0600, 0x140f0500,
572 1.4 jmcneill 0x140e0500, 0x130e0500, 0x130e0500, 0x140d0400,
573 1.4 jmcneill 0x140d0400, 0x130d0400, 0x120d0400, 0x130c0400,
574 1.4 jmcneill 0x130c0300, 0x130c0300, 0x130b0300, 0x130b0300,
575 1.4 jmcneill 0x110b0300, 0x130a0200, 0x120a0200, 0x120a0200,
576 1.4 jmcneill 0x120a0200, 0x12090200, 0x10090200, 0x11090100,
577 1.4 jmcneill 0x11080100, 0x11080100, 0x10080100, 0x10080100,
578 1.4 jmcneill 0x10070100, 0x10070100, 0x0f070100, 0x10060100,
579 1.4 jmcneill
580 1.4 jmcneill 0x120f0701, 0x130f0601, 0x130e0601, 0x130e0601,
581 1.4 jmcneill 0x120e0601, 0x130e0501, 0x130e0500, 0x130d0500,
582 1.4 jmcneill 0x120d0500, 0x120d0500, 0x130c0400, 0x130c0400,
583 1.4 jmcneill 0x120c0400, 0x110c0400, 0x120b0400, 0x120b0300,
584 1.4 jmcneill 0x120b0300, 0x120b0300, 0x120a0300, 0x110a0300,
585 1.4 jmcneill 0x110a0200, 0x11090200, 0x11090200, 0x10090200,
586 1.4 jmcneill 0x10090200, 0x10080200, 0x10080200, 0x10080100,
587 1.4 jmcneill 0x0f080100, 0x10070100, 0x0f070100, 0x0f070100
588 1.4 jmcneill };
589 1.4 jmcneill
590 1.4 jmcneill static const uint32_t lan3coefftab32_right[512] = {
591 1.4 jmcneill 0x00000000, 0x00000002, 0x0000ff04, 0x0000ff06,
592 1.4 jmcneill 0x0000fe08, 0x0000fd0a, 0x0000fd0c, 0x0000fc0f,
593 1.4 jmcneill 0x0000fc12, 0x0001fb14, 0x0001fa17, 0x0001fa19,
594 1.4 jmcneill 0x0001f91c, 0x0001f91f, 0x0001f822, 0x0001f824,
595 1.4 jmcneill 0x0002f727, 0x0002f72a, 0x0002f72c, 0x0002f72f,
596 1.4 jmcneill 0x0002f731, 0x0002f733, 0x0002f735, 0x0002f737,
597 1.4 jmcneill 0x0002f73a, 0x0002f83b, 0x0002f93c, 0x0002fa3d,
598 1.4 jmcneill 0x0001fb3e, 0x0001fc3f, 0x0001fd40, 0x0000fe40,
599 1.4 jmcneill
600 1.4 jmcneill 0x00000000, 0x00000002, 0x0000ff04, 0x0000ff06,
601 1.4 jmcneill 0x0000fe08, 0x0000fd0a, 0x0000fd0c, 0x0000fc0f,
602 1.4 jmcneill 0x0000fc12, 0x0001fb14, 0x0001fa17, 0x0001fa19,
603 1.4 jmcneill 0x0001f91c, 0x0001f91f, 0x0001f822, 0x0001f824,
604 1.4 jmcneill 0x0002f727, 0x0002f72a, 0x0002f72c, 0x0002f72f,
605 1.4 jmcneill 0x0002f731, 0x0002f733, 0x0002f735, 0x0002f737,
606 1.4 jmcneill 0x0002f73a, 0x0002f83b, 0x0002f93c, 0x0002fa3d,
607 1.4 jmcneill 0x0001fb3e, 0x0001fc3f, 0x0001fd40, 0x0000fe40,
608 1.4 jmcneill
609 1.4 jmcneill 0x0002fc06, 0x0002fb08, 0x0002fb0a, 0x0002fa0c,
610 1.4 jmcneill 0x0002fa0e, 0x0003f910, 0x0003f912, 0x0003f814,
611 1.4 jmcneill 0x0003f816, 0x0003f719, 0x0003f71a, 0x0003f71d,
612 1.4 jmcneill 0x0003f71f, 0x0003f721, 0x0003f723, 0x0003f725,
613 1.4 jmcneill 0x0002f727, 0x0002f729, 0x0002f72b, 0x0002f82d,
614 1.4 jmcneill 0x0002f82e, 0x0001f930, 0x0001fa31, 0x0000fa34,
615 1.4 jmcneill 0x0000fb34, 0x0100fc35, 0x01fffd36, 0x01ffff37,
616 1.4 jmcneill 0x01fe0037, 0x01fe0138, 0x01fd0338, 0x02fc0538,
617 1.4 jmcneill
618 1.4 jmcneill 0x0002fa0b, 0x0002fa0c, 0x0002f90e, 0x0002f910,
619 1.4 jmcneill 0x0002f911, 0x0002f813, 0x0002f816, 0x0002f817,
620 1.4 jmcneill 0x0002f818, 0x0002f81a, 0x0001f81c, 0x0001f81e,
621 1.4 jmcneill 0x0001f820, 0x0001f921, 0x0001f923, 0x0000f925,
622 1.4 jmcneill 0x0000fa26, 0x0100fa28, 0x01fffb29, 0x01fffc2a,
623 1.4 jmcneill 0x01fffc2c, 0x01fefd2d, 0x01fefe2e, 0x01fdff2f,
624 1.4 jmcneill 0x01fd0030, 0x01fd0130, 0x01fc0232, 0x02fc0432,
625 1.4 jmcneill 0x02fb0532, 0x02fb0633, 0x02fb0833, 0x02fa0933,
626 1.4 jmcneill
627 1.4 jmcneill 0x0001fa0e, 0x0001f90f, 0x0001f911, 0x0001f913,
628 1.4 jmcneill 0x0001f914, 0x0001f915, 0x0000f918, 0x0000fa18,
629 1.4 jmcneill 0x0000fa1a, 0x0000fa1b, 0x0000fa1d, 0x00fffb1e,
630 1.4 jmcneill 0x01fffb1f, 0x01fffb20, 0x01fffc22, 0x01fefc23,
631 1.4 jmcneill 0x01fefd24, 0x01fefe25, 0x01fdfe27, 0x01fdff28,
632 1.4 jmcneill 0x01fd0029, 0x01fc012a, 0x01fc022b, 0x01fc032b,
633 1.4 jmcneill 0x01fb042d, 0x01fb052d, 0x01fb062e, 0x01fb072e,
634 1.4 jmcneill 0x01fa092e, 0x01fa0a2f, 0x01fa0b2f, 0x01fa0d2f,
635 1.4 jmcneill
636 1.4 jmcneill 0x0000fa11, 0x0000fa12, 0x0000fa13, 0x0000fb14,
637 1.4 jmcneill 0x00fffb16, 0x00fffb16, 0x00fffb17, 0x00fffb19,
638 1.4 jmcneill 0x00fffc1a, 0x00fefc1c, 0x00fefd1c, 0x01fefd1d,
639 1.4 jmcneill 0x01fefe1e, 0x01fdfe20, 0x01fdff21, 0x01fdff22,
640 1.4 jmcneill 0x01fd0023, 0x01fc0124, 0x01fc0124, 0x01fc0225,
641 1.4 jmcneill 0x01fc0326, 0x01fc0427, 0x01fb0528, 0x01fb0629,
642 1.4 jmcneill 0x01fb0729, 0x01fb0829, 0x01fb092a, 0x01fb0a2a,
643 1.4 jmcneill 0x00fa0b2c, 0x00fa0c2b, 0x00fa0e2b, 0x00fa0f2c,
644 1.4 jmcneill
645 1.4 jmcneill 0x00fffc11, 0x00fffc12, 0x00fffc14, 0x00fffc15,
646 1.4 jmcneill 0x00fefd16, 0x00fefd17, 0x00fefd18, 0x00fefe19,
647 1.4 jmcneill 0x00fefe1a, 0x00fdfe1d, 0x00fdff1d, 0x00fdff1e,
648 1.4 jmcneill 0x00fd001d, 0x00fd011e, 0x00fd0120, 0x00fc0221,
649 1.4 jmcneill 0x00fc0321, 0x00fc0323, 0x00fc0423, 0x00fc0523,
650 1.4 jmcneill 0x00fc0624, 0x00fb0725, 0x00fb0726, 0x00fb0827,
651 1.4 jmcneill 0x00fb0926, 0x00fb0a26, 0x00fb0b27, 0x00fb0c27,
652 1.4 jmcneill 0x00fb0d27, 0xfffb0e28, 0xfffb0f29, 0xfffc1028,
653 1.4 jmcneill
654 1.4 jmcneill 0x00fefd13, 0x00fefd13, 0x00fefe14, 0x00fefe15,
655 1.4 jmcneill 0x00fefe17, 0x00feff17, 0x00feff17, 0x00fd0018,
656 1.4 jmcneill 0x00fd001a, 0x00fd001a, 0x00fd011b, 0x00fd021c,
657 1.4 jmcneill 0x00fd021c, 0x00fd031d, 0x00fc031f, 0x00fc041f,
658 1.4 jmcneill 0x00fc051f, 0x00fc0521, 0x00fc0621, 0x00fc0721,
659 1.4 jmcneill 0x00fc0821, 0x00fc0822, 0x00fc0922, 0x00fc0a23,
660 1.4 jmcneill 0xfffc0b24, 0xfffc0c24, 0xfffc0d24, 0xfffc0d25,
661 1.4 jmcneill 0xfffc0e25, 0xfffd0f25, 0xfffd1025, 0xfffd1125,
662 1.4 jmcneill
663 1.4 jmcneill 0x00feff12, 0x00feff14, 0x00feff14, 0x00fe0015,
664 1.4 jmcneill 0x00fe0015, 0x00fd0017, 0x00fd0118, 0x00fd0118,
665 1.4 jmcneill 0x00fd0218, 0x00fd0219, 0x00fd031a, 0x00fd031a,
666 1.4 jmcneill 0x00fd041b, 0x00fd041c, 0x00fd051c, 0x00fd061d,
667 1.4 jmcneill 0x00fd061d, 0x00fd071e, 0x00fd081e, 0xfffd081f,
668 1.4 jmcneill 0xfffd091f, 0xfffd0a20, 0xfffd0a20, 0xfffd0b21,
669 1.4 jmcneill 0xfffd0c21, 0xfffd0d21, 0xfffd0d22, 0xfffd0e23,
670 1.4 jmcneill 0xfffe0f22, 0xfefe1022, 0xfefe1122, 0xfefe1123,
671 1.4 jmcneill
672 1.4 jmcneill 0x00fe0012, 0x00fe0013, 0x00fe0114, 0x00fe0114,
673 1.4 jmcneill 0x00fe0116, 0x00fe0216, 0x00fe0216, 0x00fd0317,
674 1.4 jmcneill 0x00fd0317, 0x00fd0418, 0x00fd0419, 0x00fd0519,
675 1.4 jmcneill 0x00fd051a, 0x00fd061b, 0x00fd061b, 0x00fd071c,
676 1.4 jmcneill 0xfffd071e, 0xfffd081d, 0xfffd091d, 0xfffd091e,
677 1.4 jmcneill 0xfffe0a1d, 0xfffe0b1e, 0xfffe0b1e, 0xfffe0c1e,
678 1.4 jmcneill 0xfffe0d1f, 0xfffe0d1f, 0xfffe0e1f, 0xfeff0f1f,
679 1.4 jmcneill 0xfeff0f20, 0xfeff1020, 0xfeff1120, 0xfe001120,
680 1.4 jmcneill
681 1.4 jmcneill 0x00fe0212, 0x00fe0312, 0x00fe0313, 0x00fe0314,
682 1.4 jmcneill 0x00fe0414, 0x00fe0414, 0x00fe0416, 0x00fe0515,
683 1.4 jmcneill 0x00fe0516, 0x00fe0616, 0x00fe0617, 0x00fe0717,
684 1.4 jmcneill 0xfffe0719, 0xfffe0818, 0xffff0818, 0xffff0919,
685 1.4 jmcneill 0xffff0919, 0xffff0a19, 0xffff0a1a, 0xffff0b1a,
686 1.4 jmcneill 0xffff0b1b, 0xffff0c1a, 0xff000c1b, 0xff000d1b,
687 1.4 jmcneill 0xff000d1b, 0xff000e1b, 0xff000e1c, 0xff010f1c,
688 1.4 jmcneill 0xfe01101c, 0xfe01101d, 0xfe02111c, 0xfe02111c,
689 1.4 jmcneill
690 1.4 jmcneill 0x00ff0411, 0x00ff0411, 0x00ff0412, 0x00ff0512,
691 1.4 jmcneill 0x00ff0513, 0x00ff0513, 0x00ff0613, 0x00ff0614,
692 1.4 jmcneill 0x00ff0714, 0x00ff0715, 0x00ff0715, 0xffff0816,
693 1.4 jmcneill 0xffff0816, 0xff000916, 0xff000917, 0xff000918,
694 1.4 jmcneill 0xff000a17, 0xff000a18, 0xff000b18, 0xff000b18,
695 1.4 jmcneill 0xff010c18, 0xff010c19, 0xff010d18, 0xff010d18,
696 1.4 jmcneill 0xff020d18, 0xff020e19, 0xff020e19, 0xff020f19,
697 1.4 jmcneill 0xff030f19, 0xff031019, 0xff031019, 0xff031119,
698 1.4 jmcneill
699 1.4 jmcneill 0x00ff0511, 0x00ff0511, 0x00000511, 0x00000611,
700 1.4 jmcneill 0x00000612, 0x00000612, 0x00000712, 0x00000713,
701 1.4 jmcneill 0x00000714, 0x00000814, 0x00000814, 0x00000914,
702 1.4 jmcneill 0x00000914, 0xff010914, 0xff010a15, 0xff010a16,
703 1.4 jmcneill 0xff010a17, 0xff010b16, 0xff010b16, 0xff020c16,
704 1.4 jmcneill 0xff020c16, 0xff020c16, 0xff020d16, 0xff020d17,
705 1.4 jmcneill 0xff030d17, 0xff030e17, 0xff030e17, 0xff030f17,
706 1.4 jmcneill 0xff040f17, 0xff040f17, 0xff041017, 0xff051017,
707 1.4 jmcneill
708 1.4 jmcneill 0x00000610, 0x00000610, 0x00000611, 0x00000611,
709 1.4 jmcneill 0x00000711, 0x00000712, 0x00010712, 0x00010812,
710 1.4 jmcneill 0x00010812, 0x00010812, 0x00010913, 0x00010913,
711 1.4 jmcneill 0x00010913, 0x00010a13, 0x00020a13, 0x00020a14,
712 1.4 jmcneill 0x00020b14, 0x00020b14, 0x00020b14, 0x00020c14,
713 1.4 jmcneill 0x00030c14, 0x00030c15, 0x00030d15, 0x00030d15,
714 1.4 jmcneill 0x00040d15, 0x00040e15, 0x00040e15, 0x00040e16,
715 1.4 jmcneill 0x00050f15, 0x00050f15, 0x00050f16, 0x00051015,
716 1.4 jmcneill
717 1.4 jmcneill 0x00000611, 0x00010610, 0x00010710, 0x00010710,
718 1.4 jmcneill 0x00010711, 0x00010811, 0x00010811, 0x00010812,
719 1.4 jmcneill 0x00010812, 0x00010912, 0x00020912, 0x00020912,
720 1.4 jmcneill 0x00020a12, 0x00020a12, 0x00020a13, 0x00020a13,
721 1.4 jmcneill 0x00030b13, 0x00030b13, 0x00030b14, 0x00030c13,
722 1.4 jmcneill 0x00030c13, 0x00040c13, 0x00040d14, 0x00040d14,
723 1.4 jmcneill 0x00040d15, 0x00040d15, 0x00050e14, 0x00050e14,
724 1.4 jmcneill 0x00050e15, 0x00050f14, 0x00060f14, 0x00060f14,
725 1.4 jmcneill
726 1.4 jmcneill 0x0001070f, 0x0001070f, 0x00010710, 0x00010710,
727 1.4 jmcneill 0x00010810, 0x00010810, 0x00020810, 0x00020811,
728 1.4 jmcneill 0x00020911, 0x00020911, 0x00020912, 0x00020912,
729 1.4 jmcneill 0x00020a12, 0x00030a12, 0x00030a12, 0x00030b12,
730 1.4 jmcneill 0x00030b12, 0x00030b12, 0x00040b12, 0x00040c12,
731 1.4 jmcneill 0x00040c13, 0x00040c14, 0x00040c14, 0x00050d13,
732 1.4 jmcneill 0x00050d13, 0x00050d14, 0x00050e13, 0x01050e13,
733 1.4 jmcneill 0x01060e13, 0x01060e13, 0x01060e14, 0x01060f13
734 1.4 jmcneill };
735 1.4 jmcneill
736 1.4 jmcneill static const uint32_t lan2coefftab32[512] = {
737 1.4 jmcneill 0x00004000, 0x000140ff, 0x00033ffe, 0x00043ffd, 0x00063efc, 0xff083dfc, 0x000a3bfb, 0xff0d39fb,
738 1.4 jmcneill 0xff0f37fb, 0xff1136fa, 0xfe1433fb, 0xfe1631fb, 0xfd192ffb, 0xfd1c2cfb, 0xfd1f29fb, 0xfc2127fc,
739 1.4 jmcneill 0xfc2424fc, 0xfc2721fc, 0xfb291ffd, 0xfb2c1cfd, 0xfb2f19fd, 0xfb3116fe, 0xfb3314fe, 0xfa3611ff,
740 1.4 jmcneill 0xfb370fff, 0xfb390dff, 0xfb3b0a00, 0xfc3d08ff, 0xfc3e0600, 0xfd3f0400, 0xfe3f0300, 0xff400100,
741 1.4 jmcneill
742 1.4 jmcneill 0x00004000, 0x000140ff, 0x00033ffe, 0x00043ffd, 0x00063efc, 0xff083dfc, 0x000a3bfb, 0xff0d39fb,
743 1.4 jmcneill 0xff0f37fb, 0xff1136fa, 0xfe1433fb, 0xfe1631fb, 0xfd192ffb, 0xfd1c2cfb, 0xfd1f29fb, 0xfc2127fc,
744 1.4 jmcneill 0xfc2424fc, 0xfc2721fc, 0xfb291ffd, 0xfb2c1cfd, 0xfb2f19fd, 0xfb3116fe, 0xfb3314fe, 0xfa3611ff,
745 1.4 jmcneill 0xfb370fff, 0xfb390dff, 0xfb3b0a00, 0xfc3d08ff, 0xfc3e0600, 0xfd3f0400, 0xfe3f0300, 0xff400100,
746 1.4 jmcneill
747 1.4 jmcneill 0xff053804, 0xff063803, 0xff083801, 0xff093701, 0xff0a3700, 0xff0c3500, 0xff0e34ff, 0xff1033fe,
748 1.4 jmcneill 0xff1232fd, 0xfe1431fd, 0xfe162ffd, 0xfe182dfd, 0xfd1b2cfc, 0xfd1d2afc, 0xfd1f28fc, 0xfd2126fc,
749 1.4 jmcneill 0xfd2323fd, 0xfc2621fd, 0xfc281ffd, 0xfc2a1dfd, 0xfc2c1bfd, 0xfd2d18fe, 0xfd2f16fe, 0xfd3114fe,
750 1.4 jmcneill 0xfd3212ff, 0xfe3310ff, 0xff340eff, 0x00350cff, 0x00360a00, 0x01360900, 0x02370700, 0x03370600,
751 1.4 jmcneill
752 1.4 jmcneill 0xff083207, 0xff093206, 0xff0a3205, 0xff0c3203, 0xff0d3103, 0xff0e3102, 0xfe113001, 0xfe132f00,
753 1.4 jmcneill 0xfe142e00, 0xfe162dff, 0xfe182bff, 0xfe192aff, 0xfe1b29fe, 0xfe1d27fe, 0xfe1f25fe, 0xfd2124fe,
754 1.4 jmcneill 0xfe2222fe, 0xfe2421fd, 0xfe251ffe, 0xfe271dfe, 0xfe291bfe, 0xff2a19fe, 0xff2b18fe, 0xff2d16fe,
755 1.4 jmcneill 0x002e14fe, 0x002f12ff, 0x013010ff, 0x02300fff, 0x03310dff, 0x04310cff, 0x05310a00, 0x06310900,
756 1.4 jmcneill
757 1.4 jmcneill 0xff0a2e09, 0xff0b2e08, 0xff0c2e07, 0xff0e2d06, 0xff0f2d05, 0xff102d04, 0xff122c03, 0xfe142c02,
758 1.4 jmcneill 0xfe152b02, 0xfe172a01, 0xfe182901, 0xfe1a2800, 0xfe1b2700, 0xfe1d2500, 0xff1e24ff, 0xfe2023ff,
759 1.4 jmcneill 0xff2121ff, 0xff2320fe, 0xff241eff, 0x00251dfe, 0x00261bff, 0x00281afe, 0x012818ff, 0x012a16ff,
760 1.4 jmcneill 0x022a15ff, 0x032b13ff, 0x032c12ff, 0x052c10ff, 0x052d0fff, 0x062d0d00, 0x072d0c00, 0x082d0b00,
761 1.4 jmcneill
762 1.4 jmcneill 0xff0c2a0b, 0xff0d2a0a, 0xff0e2a09, 0xff0f2a08, 0xff102a07, 0xff112a06, 0xff132905, 0xff142904,
763 1.4 jmcneill 0xff162803, 0xff172703, 0xff182702, 0xff1a2601, 0xff1b2501, 0xff1c2401, 0xff1e2300, 0xff1f2200,
764 1.4 jmcneill 0x00202000, 0x00211f00, 0x01221d00, 0x01231c00, 0x01251bff, 0x02251aff, 0x032618ff, 0x032717ff,
765 1.4 jmcneill 0x042815ff, 0x052814ff, 0x052913ff, 0x06291100, 0x072a10ff, 0x082a0e00, 0x092a0d00, 0x0a2a0c00,
766 1.4 jmcneill
767 1.4 jmcneill 0xff0d280c, 0xff0e280b, 0xff0f280a, 0xff102809, 0xff112808, 0xff122708, 0xff142706, 0xff152705,
768 1.4 jmcneill 0xff162605, 0xff172604, 0xff192503, 0xff1a2403, 0x001b2302, 0x001c2202, 0x001d2201, 0x001e2101,
769 1.4 jmcneill 0x011f1f01, 0x01211e00, 0x01221d00, 0x02221c00, 0x02231b00, 0x03241900, 0x04241800, 0x04251700,
770 1.4 jmcneill 0x052616ff, 0x06261400, 0x072713ff, 0x08271100, 0x08271100, 0x09271000, 0x0a280e00, 0x0b280d00,
771 1.4 jmcneill
772 1.4 jmcneill 0xff0e260d, 0xff0f260c, 0xff10260b, 0xff11260a, 0xff122609, 0xff132608, 0xff142508, 0xff152507,
773 1.4 jmcneill 0x00152506, 0x00172405, 0x00182305, 0x00192304, 0x001b2203, 0x001c2103, 0x011d2002, 0x011d2002,
774 1.4 jmcneill 0x011f1f01, 0x021f1e01, 0x02201d01, 0x03211c00, 0x03221b00, 0x04221a00, 0x04231801, 0x05241700,
775 1.4 jmcneill 0x06241600, 0x07241500, 0x08251300, 0x09251200, 0x09261100, 0x0a261000, 0x0b260f00, 0x0c260e00,
776 1.4 jmcneill
777 1.4 jmcneill 0xff0e250e, 0xff0f250d, 0xff10250c, 0xff11250b, 0x0011250a, 0x00132409, 0x00142408, 0x00152407,
778 1.4 jmcneill 0x00162307, 0x00172306, 0x00182206, 0x00192205, 0x011a2104, 0x011b2004, 0x011c2003, 0x021c1f03,
779 1.4 jmcneill 0x021e1e02, 0x031e1d02, 0x03201c01, 0x04201b01, 0x04211a01, 0x05221900, 0x05221801, 0x06231700,
780 1.4 jmcneill 0x07231600, 0x07241500, 0x08241400, 0x09241300, 0x0a241200, 0x0b241100, 0x0c241000, 0x0d240f00,
781 1.4 jmcneill
782 1.4 jmcneill 0x000e240e, 0x000f240d, 0x0010240c, 0x0011240b, 0x0013230a, 0x0013230a, 0x00142309, 0x00152308,
783 1.4 jmcneill 0x00162208, 0x00172207, 0x01182106, 0x01192105, 0x011a2005, 0x021b1f04, 0x021b1f04, 0x021d1e03,
784 1.4 jmcneill 0x031d1d03, 0x031e1d02, 0x041e1c02, 0x041f1b02, 0x05201a01, 0x05211901, 0x06211801, 0x07221700,
785 1.4 jmcneill 0x07221601, 0x08231500, 0x09231400, 0x0a231300, 0x0a231300, 0x0b231200, 0x0c231100, 0x0d231000,
786 1.4 jmcneill
787 1.4 jmcneill 0x000f220f, 0x0010220e, 0x0011220d, 0x0012220c, 0x0013220b, 0x0013220b, 0x0015210a, 0x0015210a,
788 1.4 jmcneill 0x01162108, 0x01172008, 0x01182007, 0x02191f06, 0x02191f06, 0x021a1e06, 0x031a1e05, 0x031c1d04,
789 1.4 jmcneill 0x041c1c04, 0x041d1c03, 0x051d1b03, 0x051e1a03, 0x061f1902, 0x061f1902, 0x07201801, 0x08201701,
790 1.4 jmcneill 0x08211601, 0x09211501, 0x0a211500, 0x0b211400, 0x0b221300, 0x0c221200, 0x0d221100, 0x0e221000,
791 1.4 jmcneill
792 1.4 jmcneill 0x0010210f, 0x0011210e, 0x0011210e, 0x0012210d, 0x0013210c, 0x0014200c, 0x0114200b, 0x0115200a,
793 1.4 jmcneill 0x01161f0a, 0x01171f09, 0x02171f08, 0x02181e08, 0x03181e07, 0x031a1d06, 0x031a1d06, 0x041b1c05,
794 1.4 jmcneill 0x041c1c04, 0x051c1b04, 0x051d1a04, 0x061d1a03, 0x071d1903, 0x071e1803, 0x081e1802, 0x081f1702,
795 1.4 jmcneill 0x091f1602, 0x0a201501, 0x0b1f1501, 0x0b201401, 0x0c211300, 0x0d211200, 0x0e201200, 0x0e211100,
796 1.4 jmcneill
797 1.4 jmcneill 0x00102010, 0x0011200f, 0x0012200e, 0x0013200d, 0x0013200d, 0x01141f0c, 0x01151f0b, 0x01151f0b,
798 1.4 jmcneill 0x01161f0a, 0x02171e09, 0x02171e09, 0x03181d08, 0x03191d07, 0x03191d07, 0x041a1c06, 0x041b1c05,
799 1.4 jmcneill 0x051b1b05, 0x051c1b04, 0x061c1a04, 0x071d1903, 0x071d1903, 0x081d1803, 0x081e1703, 0x091e1702,
800 1.4 jmcneill 0x0a1f1601, 0x0a1f1502, 0x0b1f1501, 0x0c1f1401, 0x0d201300, 0x0d201300, 0x0e201200, 0x0f201100,
801 1.4 jmcneill
802 1.4 jmcneill 0x00102010, 0x0011200f, 0x00121f0f, 0x00131f0e, 0x00141f0d, 0x01141f0c, 0x01141f0c, 0x01151e0c,
803 1.4 jmcneill 0x02161e0a, 0x02171e09, 0x03171d09, 0x03181d08, 0x03181d08, 0x04191c07, 0x041a1c06, 0x051a1b06,
804 1.4 jmcneill 0x051b1b05, 0x061b1a05, 0x061c1a04, 0x071c1904, 0x081c1903, 0x081d1803, 0x091d1703, 0x091e1702,
805 1.4 jmcneill 0x0a1e1602, 0x0b1e1502, 0x0c1e1501, 0x0c1f1401, 0x0d1f1400, 0x0e1f1300, 0x0e1f1201, 0x0f1f1200,
806 1.4 jmcneill
807 1.4 jmcneill 0x00111e11, 0x00121e10, 0x00131e0f, 0x00131e0f, 0x01131e0e, 0x01141d0e, 0x02151d0c, 0x02151d0c,
808 1.4 jmcneill 0x02161d0b, 0x03161c0b, 0x03171c0a, 0x04171c09, 0x04181b09, 0x05181b08, 0x05191b07, 0x06191a07,
809 1.4 jmcneill 0x061a1a06, 0x071a1906, 0x071b1905, 0x081b1805, 0x091b1804, 0x091c1704, 0x0a1c1703, 0x0a1c1604,
810 1.4 jmcneill 0x0b1d1602, 0x0c1d1502, 0x0c1d1502, 0x0d1d1402, 0x0e1d1401, 0x0e1e1301, 0x0f1e1300, 0x101e1200,
811 1.4 jmcneill
812 1.4 jmcneill 0x00111e11, 0x00121e10, 0x00131d10, 0x01131d0f, 0x01141d0e, 0x01141d0e, 0x02151c0d, 0x02151c0d,
813 1.4 jmcneill 0x03161c0b, 0x03161c0b, 0x04171b0a, 0x04171b0a, 0x05171b09, 0x05181a09, 0x06181a08, 0x06191a07,
814 1.4 jmcneill 0x07191907, 0x071a1906, 0x081a1806, 0x081a1806, 0x091a1805, 0x0a1b1704, 0x0a1b1704, 0x0b1c1603,
815 1.4 jmcneill 0x0b1c1603, 0x0c1c1503, 0x0d1c1502, 0x0d1d1402, 0x0e1d1401, 0x0f1d1301, 0x0f1d1301, 0x101e1200,
816 1.4 jmcneill };
817 1.4 jmcneill
818 1.4 jmcneill static void
819 1.4 jmcneill sunxi_mixer_vsu_init(struct sunxi_mixer_softc *sc, u_int src_w, u_int src_h,
820 1.4 jmcneill u_int crtc_w, u_int crtc_h, uint32_t pixel_format)
821 1.4 jmcneill {
822 1.4 jmcneill const u_int hstep = (src_w << 16) / crtc_w;
823 1.4 jmcneill const u_int vstep = (src_h << 16) / crtc_h;
824 1.4 jmcneill
825 1.4 jmcneill const int hsub = drm_format_horz_chroma_subsampling(pixel_format);
826 1.4 jmcneill const int vsub = drm_format_vert_chroma_subsampling(pixel_format);
827 1.4 jmcneill
828 1.4 jmcneill const u_int src_cw = src_w / hsub;
829 1.4 jmcneill const u_int src_ch = src_h / vsub;
830 1.4 jmcneill
831 1.4 jmcneill VSU_WRITE(sc, VS_OUT_SIZE_REG, ((crtc_h - 1) << 16) | (crtc_w - 1));
832 1.4 jmcneill VSU_WRITE(sc, VS_Y_SIZE_REG, ((src_h - 1) << 16) | (src_w - 1));
833 1.4 jmcneill VSU_WRITE(sc, VS_Y_HSTEP_REG, hstep << 4);
834 1.4 jmcneill VSU_WRITE(sc, VS_Y_VSTEP_REG, vstep << 4);
835 1.4 jmcneill VSU_WRITE(sc, VS_Y_HPHASE_REG, 0);
836 1.4 jmcneill VSU_WRITE(sc, VS_Y_VPHASE0_REG, 0);
837 1.4 jmcneill VSU_WRITE(sc, VS_Y_VPHASE1_REG, 0);
838 1.4 jmcneill VSU_WRITE(sc, VS_C_SIZE_REG, ((src_ch - 1) << 16) | (src_cw - 1));
839 1.4 jmcneill VSU_WRITE(sc, VS_C_HSTEP_REG, (hstep / hsub) << 4);
840 1.4 jmcneill VSU_WRITE(sc, VS_C_VSTEP_REG, (vstep / vsub) << 4);
841 1.4 jmcneill VSU_WRITE(sc, VS_C_HPHASE_REG, 0);
842 1.4 jmcneill VSU_WRITE(sc, VS_C_VPHASE0_REG, 0);
843 1.4 jmcneill VSU_WRITE(sc, VS_C_VPHASE1_REG, 0);
844 1.4 jmcneill
845 1.4 jmcneill /* XXX */
846 1.4 jmcneill const u_int coef_base = 0;
847 1.4 jmcneill
848 1.4 jmcneill for (int i = 0; i < 32; i++) {
849 1.4 jmcneill VSU_WRITE(sc, VS_Y_HCOEF0_REG(i), lan3coefftab32_left[coef_base + i]);
850 1.4 jmcneill VSU_WRITE(sc, VS_Y_HCOEF1_REG(i), lan3coefftab32_right[coef_base + i]);
851 1.4 jmcneill VSU_WRITE(sc, VS_Y_VCOEF_REG(i), lan2coefftab32[coef_base + i]);
852 1.4 jmcneill VSU_WRITE(sc, VS_C_HCOEF0_REG(i), lan3coefftab32_left[coef_base + i]);
853 1.4 jmcneill VSU_WRITE(sc, VS_C_HCOEF1_REG(i), lan3coefftab32_right[coef_base + i]);
854 1.4 jmcneill VSU_WRITE(sc, VS_C_VCOEF_REG(i), lan2coefftab32[coef_base + i]);
855 1.4 jmcneill }
856 1.4 jmcneill
857 1.4 jmcneill /* Commit settings and enable scaler */
858 1.4 jmcneill VSU_WRITE(sc, VS_CTRL_REG, VS_CTRL_COEF_SWITCH_EN | VS_CTRL_EN);
859 1.4 jmcneill }
860 1.4 jmcneill
861 1.4 jmcneill static const u32 yuv2rgb[] = {
862 1.4 jmcneill 0x000004A8, 0x00000000, 0x00000662, 0xFFFC865A,
863 1.4 jmcneill 0x000004A8, 0xFFFFFE6F, 0xFFFFFCBF, 0x00021FF4,
864 1.4 jmcneill 0x000004A8, 0x00000813, 0x00000000, 0xFFFBAE4A,
865 1.4 jmcneill };
866 1.4 jmcneill
867 1.4 jmcneill static void
868 1.4 jmcneill sunxi_mixer_csc_init(struct sunxi_mixer_softc *sc, uint32_t pixel_format)
869 1.4 jmcneill {
870 1.4 jmcneill const u_int crtc_index = drm_crtc_index(&sc->sc_crtc.base);
871 1.4 jmcneill
872 1.4 jmcneill for (int i = 0; i < __arraycount(yuv2rgb); i++)
873 1.4 jmcneill CSC_WRITE(sc, crtc_index, CSC_COEFF0_REG(0) + i * 4, yuv2rgb[i]);
874 1.4 jmcneill
875 1.4 jmcneill CSC_WRITE(sc, crtc_index, CSC_BYPASS_REG, CSC_BYPASS_DISABLE);
876 1.4 jmcneill }
877 1.4 jmcneill
878 1.4 jmcneill static void
879 1.4 jmcneill sunxi_mixer_csc_disable(struct sunxi_mixer_softc *sc)
880 1.4 jmcneill {
881 1.4 jmcneill const u_int crtc_index = drm_crtc_index(&sc->sc_crtc.base);
882 1.4 jmcneill
883 1.4 jmcneill CSC_WRITE(sc, crtc_index, CSC_BYPASS_REG, 0);
884 1.4 jmcneill }
885 1.4 jmcneill
886 1.3 jmcneill static int
887 1.3 jmcneill sunxi_mixer_overlay_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
888 1.3 jmcneill struct drm_framebuffer *fb, int crtc_x, int crtc_y, u_int crtc_w, u_int crtc_h,
889 1.3 jmcneill uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h)
890 1.3 jmcneill {
891 1.3 jmcneill struct sunxi_mixer_overlay *overlay = to_sunxi_mixer_overlay(plane);
892 1.3 jmcneill struct sunxi_mixer_softc * const sc = overlay->sc;
893 1.3 jmcneill struct sunxi_drm_framebuffer *sfb = to_sunxi_drm_framebuffer(fb);
894 1.3 jmcneill uint32_t val;
895 1.3 jmcneill
896 1.3 jmcneill const u_int fbfmt = sunxi_mixer_overlay_format(fb->pixel_format);
897 1.3 jmcneill const uint64_t paddr = (uint64_t)sfb->obj->dmamap->dm_segs[0].ds_addr;
898 1.3 jmcneill
899 1.3 jmcneill const uint32_t input_size = (((src_h >> 16) - 1) << 16) | ((src_w >> 16) - 1);
900 1.3 jmcneill const uint32_t input_pos = ((src_y >> 16) << 16) | (src_x >> 16);
901 1.3 jmcneill
902 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_MBSIZE(0), input_size);
903 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_COOR(0), input_pos);
904 1.3 jmcneill
905 1.4 jmcneill /* Note: DRM and hardware's ideas of pitch 1 and 2 are swapped */
906 1.4 jmcneill
907 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_PITCH0(0), fb->pitches[0]);
908 1.4 jmcneill OVL_V_WRITE(sc, OVL_V_PITCH1(0), fb->pitches[2]);
909 1.4 jmcneill OVL_V_WRITE(sc, OVL_V_PITCH2(0), fb->pitches[1]);
910 1.3 jmcneill
911 1.3 jmcneill const uint64_t paddr0 = paddr + fb->offsets[0] +
912 1.3 jmcneill (src_x >> 16) * drm_format_plane_cpp(fb->pixel_format, 0) +
913 1.3 jmcneill (src_y >> 16) * fb->pitches[0];
914 1.4 jmcneill const uint64_t paddr1 = paddr + fb->offsets[2] +
915 1.4 jmcneill (src_x >> 16) * drm_format_plane_cpp(fb->pixel_format, 2) +
916 1.4 jmcneill (src_y >> 16) * fb->pitches[2];
917 1.4 jmcneill const uint64_t paddr2 = paddr + fb->offsets[1] +
918 1.3 jmcneill (src_x >> 16) * drm_format_plane_cpp(fb->pixel_format, 1) +
919 1.3 jmcneill (src_y >> 16) * fb->pitches[1];
920 1.3 jmcneill
921 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_TOP_HADD0, (paddr0 >> 32) & OVL_V_TOP_HADD_LAYER0);
922 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_TOP_HADD1, (paddr1 >> 32) & OVL_V_TOP_HADD_LAYER0);
923 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_TOP_HADD2, (paddr2 >> 32) & OVL_V_TOP_HADD_LAYER0);
924 1.3 jmcneill
925 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_TOP_LADD0(0), paddr0 & 0xffffffff);
926 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_TOP_LADD1(0), paddr1 & 0xffffffff);
927 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_TOP_LADD2(0), paddr2 & 0xffffffff);
928 1.3 jmcneill
929 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_SIZE, input_size);
930 1.3 jmcneill
931 1.3 jmcneill val = OVL_V_ATTCTL_LAY0_EN;
932 1.3 jmcneill val |= __SHIFTIN(fbfmt, OVL_V_ATTCTL_LAY_FBFMT);
933 1.4 jmcneill if (sunxi_mixer_overlay_rgb(fb->pixel_format) == true)
934 1.3 jmcneill val |= OVL_V_ATTCTL_VIDEO_UI_SEL;
935 1.3 jmcneill OVL_V_WRITE(sc, OVL_V_ATTCTL(0), val);
936 1.3 jmcneill
937 1.4 jmcneill /* Enable video scaler */
938 1.4 jmcneill sunxi_mixer_vsu_init(sc, src_w >> 16, src_h >> 16, crtc_w, crtc_h, fb->pixel_format);
939 1.4 jmcneill
940 1.4 jmcneill /* Enable colour space conversion for non-RGB formats */
941 1.4 jmcneill if (sunxi_mixer_overlay_rgb(fb->pixel_format) == false)
942 1.4 jmcneill sunxi_mixer_csc_init(sc, fb->pixel_format);
943 1.4 jmcneill else
944 1.4 jmcneill sunxi_mixer_csc_disable(sc);
945 1.4 jmcneill
946 1.3 jmcneill /* Set blender 1 input size */
947 1.4 jmcneill BLD_WRITE(sc, BLD_CH_ISIZE(1), ((crtc_h - 1) << 16) | (crtc_w - 1));
948 1.3 jmcneill /* Set blender 1 offset */
949 1.3 jmcneill BLD_WRITE(sc, BLD_CH_OFFSET(1), (crtc_y << 16) | crtc_x);
950 1.3 jmcneill /* Route channel 0 to pipe 1 */
951 1.3 jmcneill val = BLD_READ(sc, BLD_CH_RTCTL);
952 1.3 jmcneill val &= ~BLD_CH_RTCTL_P1;
953 1.3 jmcneill val |= __SHIFTIN(0, BLD_CH_RTCTL_P1);
954 1.3 jmcneill BLD_WRITE(sc, BLD_CH_RTCTL, val);
955 1.3 jmcneill
956 1.3 jmcneill /* Enable pipe 1 */
957 1.3 jmcneill val = BLD_READ(sc, BLD_FILL_COLOR_CTL);
958 1.3 jmcneill val |= BLD_FILL_COLOR_CTL_P1_EN;
959 1.3 jmcneill BLD_WRITE(sc, BLD_FILL_COLOR_CTL, val);
960 1.3 jmcneill
961 1.3 jmcneill /* Commit settings */
962 1.3 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
963 1.3 jmcneill
964 1.3 jmcneill return 0;
965 1.3 jmcneill }
966 1.3 jmcneill
967 1.3 jmcneill static int
968 1.3 jmcneill sunxi_mixer_overlay_disable_plane(struct drm_plane *plane)
969 1.3 jmcneill {
970 1.3 jmcneill struct sunxi_mixer_overlay *overlay = to_sunxi_mixer_overlay(plane);
971 1.3 jmcneill struct sunxi_mixer_softc * const sc = overlay->sc;
972 1.3 jmcneill uint32_t val;
973 1.3 jmcneill
974 1.4 jmcneill sunxi_mixer_csc_disable(sc);
975 1.4 jmcneill
976 1.3 jmcneill val = BLD_READ(sc, BLD_FILL_COLOR_CTL);
977 1.3 jmcneill val &= ~BLD_FILL_COLOR_CTL_P1_EN;
978 1.3 jmcneill BLD_WRITE(sc, BLD_FILL_COLOR_CTL, val);
979 1.3 jmcneill
980 1.3 jmcneill /* Commit settings */
981 1.3 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
982 1.3 jmcneill
983 1.3 jmcneill return 0;
984 1.3 jmcneill }
985 1.3 jmcneill
986 1.3 jmcneill static const struct drm_plane_funcs sunxi_mixer_overlay_funcs = {
987 1.3 jmcneill .update_plane = sunxi_mixer_overlay_update_plane,
988 1.3 jmcneill .disable_plane = sunxi_mixer_overlay_disable_plane,
989 1.3 jmcneill .destroy = sunxi_mixer_overlay_destroy,
990 1.3 jmcneill };
991 1.3 jmcneill
992 1.3 jmcneill static uint32_t sunxi_mixer_overlay_formats[] = {
993 1.3 jmcneill DRM_FORMAT_XRGB8888,
994 1.3 jmcneill #if notyet
995 1.3 jmcneill DRM_FORMAT_VYUY,
996 1.3 jmcneill DRM_FORMAT_YVYU,
997 1.3 jmcneill DRM_FORMAT_UYVY,
998 1.3 jmcneill DRM_FORMAT_YUYV,
999 1.4 jmcneill #endif
1000 1.3 jmcneill DRM_FORMAT_YUV422,
1001 1.3 jmcneill DRM_FORMAT_YUV420,
1002 1.3 jmcneill DRM_FORMAT_YUV411,
1003 1.3 jmcneill };
1004 1.3 jmcneill
1005 1.1 jmcneill static int
1006 1.1 jmcneill sunxi_mixer_ep_activate(device_t dev, struct fdt_endpoint *ep, bool activate)
1007 1.1 jmcneill {
1008 1.1 jmcneill struct sunxi_mixer_softc * const sc = device_private(dev);
1009 1.1 jmcneill struct drm_device *ddev;
1010 1.1 jmcneill
1011 1.1 jmcneill if (!activate)
1012 1.1 jmcneill return EINVAL;
1013 1.1 jmcneill
1014 1.1 jmcneill ddev = sunxi_drm_endpoint_device(ep);
1015 1.1 jmcneill if (ddev == NULL) {
1016 1.1 jmcneill DRM_ERROR("couldn't find DRM device\n");
1017 1.1 jmcneill return ENXIO;
1018 1.1 jmcneill }
1019 1.1 jmcneill
1020 1.1 jmcneill sc->sc_crtc.sc = sc;
1021 1.3 jmcneill sc->sc_overlay.sc = sc;
1022 1.1 jmcneill
1023 1.1 jmcneill drm_crtc_init(ddev, &sc->sc_crtc.base, &sunxi_mixer_crtc_funcs);
1024 1.1 jmcneill drm_crtc_helper_add(&sc->sc_crtc.base, &sunxi_mixer_crtc_helper_funcs);
1025 1.1 jmcneill
1026 1.3 jmcneill drm_universal_plane_init(ddev, &sc->sc_overlay.base,
1027 1.3 jmcneill 1 << drm_crtc_index(&sc->sc_crtc.base), &sunxi_mixer_overlay_funcs,
1028 1.3 jmcneill sunxi_mixer_overlay_formats, __arraycount(sunxi_mixer_overlay_formats),
1029 1.3 jmcneill DRM_PLANE_TYPE_OVERLAY);
1030 1.3 jmcneill
1031 1.1 jmcneill return fdt_endpoint_activate(ep, activate);
1032 1.1 jmcneill }
1033 1.1 jmcneill
1034 1.1 jmcneill static void *
1035 1.1 jmcneill sunxi_mixer_ep_get_data(device_t dev, struct fdt_endpoint *ep)
1036 1.1 jmcneill {
1037 1.1 jmcneill struct sunxi_mixer_softc * const sc = device_private(dev);
1038 1.1 jmcneill
1039 1.1 jmcneill return &sc->sc_crtc;
1040 1.1 jmcneill }
1041 1.1 jmcneill
1042 1.1 jmcneill static int
1043 1.1 jmcneill sunxi_mixer_match(device_t parent, cfdata_t cf, void *aux)
1044 1.1 jmcneill {
1045 1.1 jmcneill struct fdt_attach_args * const faa = aux;
1046 1.1 jmcneill
1047 1.1 jmcneill return of_match_compatible(faa->faa_phandle, compatible);
1048 1.1 jmcneill }
1049 1.1 jmcneill
1050 1.1 jmcneill static void
1051 1.1 jmcneill sunxi_mixer_attach(device_t parent, device_t self, void *aux)
1052 1.1 jmcneill {
1053 1.1 jmcneill struct sunxi_mixer_softc * const sc = device_private(self);
1054 1.1 jmcneill struct fdt_attach_args * const faa = aux;
1055 1.1 jmcneill struct fdt_endpoint *out_ep;
1056 1.1 jmcneill const int phandle = faa->faa_phandle;
1057 1.1 jmcneill struct clk *clk_bus, *clk_mod;
1058 1.1 jmcneill struct fdtbus_reset *rst;
1059 1.1 jmcneill bus_addr_t addr;
1060 1.1 jmcneill bus_size_t size;
1061 1.1 jmcneill
1062 1.1 jmcneill if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
1063 1.1 jmcneill aprint_error(": couldn't get registers\n");
1064 1.1 jmcneill return;
1065 1.1 jmcneill }
1066 1.1 jmcneill
1067 1.1 jmcneill rst = fdtbus_reset_get_index(phandle, 0);
1068 1.1 jmcneill if (rst == NULL || fdtbus_reset_deassert(rst) != 0) {
1069 1.1 jmcneill aprint_error(": couldn't de-assert reset\n");
1070 1.1 jmcneill return;
1071 1.1 jmcneill }
1072 1.1 jmcneill
1073 1.1 jmcneill clk_bus = fdtbus_clock_get(phandle, "bus");
1074 1.1 jmcneill if (clk_bus == NULL || clk_enable(clk_bus) != 0) {
1075 1.1 jmcneill aprint_error(": couldn't enable bus clock\n");
1076 1.1 jmcneill return;
1077 1.1 jmcneill }
1078 1.1 jmcneill
1079 1.1 jmcneill clk_mod = fdtbus_clock_get(phandle, "mod");
1080 1.1 jmcneill if (clk_mod == NULL ||
1081 1.1 jmcneill clk_set_rate(clk_mod, SUNXI_MIXER_FREQ) != 0 ||
1082 1.1 jmcneill clk_enable(clk_mod) != 0) {
1083 1.1 jmcneill aprint_error(": couldn't enable mod clock\n");
1084 1.1 jmcneill return;
1085 1.1 jmcneill }
1086 1.1 jmcneill
1087 1.1 jmcneill sc->sc_dev = self;
1088 1.1 jmcneill sc->sc_bst = faa->faa_bst;
1089 1.1 jmcneill if (bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh) != 0) {
1090 1.1 jmcneill aprint_error(": couldn't map registers\n");
1091 1.1 jmcneill return;
1092 1.1 jmcneill }
1093 1.1 jmcneill sc->sc_phandle = faa->faa_phandle;
1094 1.1 jmcneill
1095 1.1 jmcneill aprint_naive("\n");
1096 1.1 jmcneill aprint_normal(": Display Engine Mixer\n");
1097 1.1 jmcneill
1098 1.1 jmcneill sc->sc_ports.dp_ep_activate = sunxi_mixer_ep_activate;
1099 1.1 jmcneill sc->sc_ports.dp_ep_get_data = sunxi_mixer_ep_get_data;
1100 1.1 jmcneill fdt_ports_register(&sc->sc_ports, self, phandle, EP_DRM_CRTC);
1101 1.1 jmcneill
1102 1.1 jmcneill out_ep = fdt_endpoint_get_from_index(&sc->sc_ports, MIXER_PORT_OUTPUT, 0);
1103 1.1 jmcneill if (out_ep != NULL)
1104 1.1 jmcneill sunxi_drm_register_endpoint(phandle, out_ep);
1105 1.1 jmcneill }
1106 1.1 jmcneill
1107 1.1 jmcneill CFATTACH_DECL_NEW(sunxi_mixer, sizeof(struct sunxi_mixer_softc),
1108 1.1 jmcneill sunxi_mixer_match, sunxi_mixer_attach, NULL, NULL);
1109