| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: rk_dwhdmi.c,v 1.7 2021/12/19 11:01:10 riastradh Exp $ */ | | 1 | /* $NetBSD: rk_dwhdmi.c,v 1.8 2023/04/11 08:40:19 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2019 Jared D. McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2019 Jared D. McNeill <jmcneill@invisible.ca> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: rk_dwhdmi.c,v 1.7 2021/12/19 11:01:10 riastradh Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: rk_dwhdmi.c,v 1.8 2023/04/11 08:40:19 riastradh Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/bus.h> | | 33 | #include <sys/bus.h> |
34 | #include <sys/conf.h> | | 34 | #include <sys/conf.h> |
35 | #include <sys/device.h> | | 35 | #include <sys/device.h> |
36 | #include <sys/intr.h> | | 36 | #include <sys/intr.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
38 | #include <sys/systm.h> | | 38 | #include <sys/systm.h> |
39 | | | 39 | |
40 | #include <dev/fdt/fdt_port.h> | | 40 | #include <dev/fdt/fdt_port.h> |
41 | #include <dev/fdt/fdtvar.h> | | 41 | #include <dev/fdt/fdtvar.h> |
42 | #include <dev/fdt/syscon.h> | | 42 | #include <dev/fdt/syscon.h> |
43 | | | 43 | |
| @@ -96,74 +96,41 @@ struct rk_dwhdmi_softc { | | | @@ -96,74 +96,41 @@ struct rk_dwhdmi_softc { |
96 | #define to_rk_dwhdmi_encoder(x) container_of(x, struct rk_dwhdmi_softc, sc_encoder) | | 96 | #define to_rk_dwhdmi_encoder(x) container_of(x, struct rk_dwhdmi_softc, sc_encoder) |
97 | | | 97 | |
98 | static void | | 98 | static void |
99 | rk_dwhdmi_select_input(struct rk_dwhdmi_softc *sc, u_int crtc_index) | | 99 | rk_dwhdmi_select_input(struct rk_dwhdmi_softc *sc, u_int crtc_index) |
100 | { | | 100 | { |
101 | const uint32_t write_mask = HDMI_LCDC_SEL << 16; | | 101 | const uint32_t write_mask = HDMI_LCDC_SEL << 16; |
102 | const uint32_t write_val = crtc_index == 0 ? HDMI_LCDC_SEL : 0; | | 102 | const uint32_t write_val = crtc_index == 0 ? HDMI_LCDC_SEL : 0; |
103 | | | 103 | |
104 | syscon_lock(sc->sc_grf); | | 104 | syscon_lock(sc->sc_grf); |
105 | syscon_write_4(sc->sc_grf, RK3399_GRF_SOC_CON20, write_mask | write_val); | | 105 | syscon_write_4(sc->sc_grf, RK3399_GRF_SOC_CON20, write_mask | write_val); |
106 | syscon_unlock(sc->sc_grf); | | 106 | syscon_unlock(sc->sc_grf); |
107 | } | | 107 | } |
108 | | | 108 | |
109 | static bool | | | |
110 | rk_dwhdmi_encoder_mode_fixup(struct drm_encoder *encoder, | | | |
111 | const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) | | | |
112 | { | | | |
113 | return true; | | | |
114 | } | | | |
115 | | | | |
116 | static void | | | |
117 | rk_dwhdmi_encoder_mode_set(struct drm_encoder *encoder, | | | |
118 | struct drm_display_mode *mode, struct drm_display_mode *adjusted) | | | |
119 | { | | | |
120 | } | | | |
121 | | | | |
122 | static void | | 109 | static void |
123 | rk_dwhdmi_encoder_enable(struct drm_encoder *encoder) | | 110 | rk_dwhdmi_encoder_enable(struct drm_encoder *encoder) |
124 | { | | 111 | { |
125 | } | | | |
126 | | | | |
127 | static void | | | |
128 | rk_dwhdmi_encoder_disable(struct drm_encoder *encoder) | | | |
129 | { | | | |
130 | } | | | |
131 | | | | |
132 | static void | | | |
133 | rk_dwhdmi_encoder_prepare(struct drm_encoder *encoder) | | | |
134 | { | | | |
135 | struct rk_dwhdmi_softc * const sc = to_rk_dwhdmi_encoder(encoder); | | 112 | struct rk_dwhdmi_softc * const sc = to_rk_dwhdmi_encoder(encoder); |
136 | const u_int crtc_index = drm_crtc_index(encoder->crtc); | | 113 | const u_int crtc_index = drm_crtc_index(encoder->crtc); |
137 | | | 114 | |
138 | rk_dwhdmi_select_input(sc, crtc_index); | | 115 | rk_dwhdmi_select_input(sc, crtc_index); |
139 | } | | 116 | } |
140 | | | 117 | |
141 | static void | | | |
142 | rk_dwhdmi_encoder_commit(struct drm_encoder *encoder) | | | |
143 | { | | | |
144 | } | | | |
145 | | | | |
146 | static const struct drm_encoder_funcs rk_dwhdmi_encoder_funcs = { | | 118 | static const struct drm_encoder_funcs rk_dwhdmi_encoder_funcs = { |
147 | .destroy = drm_encoder_cleanup, | | 119 | .destroy = drm_encoder_cleanup, |
148 | }; | | 120 | }; |
149 | | | 121 | |
150 | static const struct drm_encoder_helper_funcs rk_dwhdmi_encoder_helper_funcs = { | | 122 | static const struct drm_encoder_helper_funcs rk_dwhdmi_encoder_helper_funcs = { |
151 | .prepare = rk_dwhdmi_encoder_prepare, | | | |
152 | .mode_fixup = rk_dwhdmi_encoder_mode_fixup, | | | |
153 | .mode_set = rk_dwhdmi_encoder_mode_set, | | | |
154 | .enable = rk_dwhdmi_encoder_enable, | | 123 | .enable = rk_dwhdmi_encoder_enable, |
155 | .disable = rk_dwhdmi_encoder_disable, | | | |
156 | .commit = rk_dwhdmi_encoder_commit, | | | |
157 | }; | | 124 | }; |
158 | | | 125 | |
159 | static int | | 126 | static int |
160 | rk_dwhdmi_ep_activate(device_t dev, struct fdt_endpoint *ep, bool activate) | | 127 | rk_dwhdmi_ep_activate(device_t dev, struct fdt_endpoint *ep, bool activate) |
161 | { | | 128 | { |
162 | struct rk_dwhdmi_softc * const sc = device_private(dev); | | 129 | struct rk_dwhdmi_softc * const sc = device_private(dev); |
163 | struct fdt_endpoint *in_ep = fdt_endpoint_remote(ep); | | 130 | struct fdt_endpoint *in_ep = fdt_endpoint_remote(ep); |
164 | struct fdt_endpoint *out_ep, *out_rep; | | 131 | struct fdt_endpoint *out_ep, *out_rep; |
165 | struct drm_crtc *crtc; | | 132 | struct drm_crtc *crtc; |
166 | int error; | | 133 | int error; |
167 | | | 134 | |
168 | if (sc->sc_activated != false) { | | 135 | if (sc->sc_activated != false) { |
169 | return 0; | | 136 | return 0; |