forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/arc/arcpgu_crtc.c
....@@ -1,24 +1,16 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ARC PGU DRM driver.
34 *
45 * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
156 */
167
178 #include <drm/drm_atomic_helper.h>
18
-#include <drm/drm_crtc_helper.h>
9
+#include <drm/drm_device.h>
1910 #include <drm/drm_fb_cma_helper.h>
2011 #include <drm/drm_gem_cma_helper.h>
2112 #include <drm/drm_plane_helper.h>
13
+#include <drm/drm_probe_helper.h>
2214 #include <linux/clk.h>
2315 #include <linux/platform_data/simplefb.h>
2416
....@@ -27,9 +19,10 @@
2719
2820 #define ENCODE_PGU_XY(x, y) ((((x) - 1) << 16) | ((y) - 1))
2921
30
-static struct simplefb_format supported_formats[] = {
31
- { "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0}, DRM_FORMAT_RGB565 },
32
- { "r8g8b8", 24, {16, 8}, {8, 8}, {0, 8}, {0, 0}, DRM_FORMAT_RGB888 },
22
+static const u32 arc_pgu_supported_formats[] = {
23
+ DRM_FORMAT_RGB565,
24
+ DRM_FORMAT_XRGB8888,
25
+ DRM_FORMAT_ARGB8888,
3326 };
3427
3528 static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
....@@ -37,22 +30,24 @@
3730 struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
3831 const struct drm_framebuffer *fb = crtc->primary->state->fb;
3932 uint32_t pixel_format = fb->format->format;
40
- struct simplefb_format *format = NULL;
33
+ u32 format = DRM_FORMAT_INVALID;
4134 int i;
35
+ u32 reg_ctrl;
4236
43
- for (i = 0; i < ARRAY_SIZE(supported_formats); i++) {
44
- if (supported_formats[i].fourcc == pixel_format)
45
- format = &supported_formats[i];
37
+ for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
38
+ if (arc_pgu_supported_formats[i] == pixel_format)
39
+ format = arc_pgu_supported_formats[i];
4640 }
4741
48
- if (WARN_ON(!format))
42
+ if (WARN_ON(format == DRM_FORMAT_INVALID))
4943 return;
5044
51
- if (format->fourcc == DRM_FORMAT_RGB888)
52
- arc_pgu_write(arcpgu, ARCPGU_REG_CTRL,
53
- arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) |
54
- ARCPGU_MODE_RGB888_MASK);
55
-
45
+ reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
46
+ if (format == DRM_FORMAT_RGB565)
47
+ reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
48
+ else
49
+ reg_ctrl |= ARCPGU_MODE_XRGB8888;
50
+ arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
5651 }
5752
5853 static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
....@@ -142,26 +137,9 @@
142137 ~ARCPGU_CTRL_ENABLE_MASK);
143138 }
144139
145
-static void arc_pgu_crtc_atomic_begin(struct drm_crtc *crtc,
146
- struct drm_crtc_state *state)
147
-{
148
- struct drm_pending_vblank_event *event = crtc->state->event;
149
-
150
- if (event) {
151
- crtc->state->event = NULL;
152
-
153
- spin_lock_irq(&crtc->dev->event_lock);
154
- drm_crtc_send_vblank_event(crtc, event);
155
- spin_unlock_irq(&crtc->dev->event_lock);
156
- }
157
-}
158
-
159140 static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
160141 .mode_valid = arc_pgu_crtc_mode_valid,
161
- .mode_set = drm_helper_crtc_mode_set,
162
- .mode_set_base = drm_helper_crtc_mode_set_base,
163142 .mode_set_nofb = arc_pgu_crtc_mode_set_nofb,
164
- .atomic_begin = arc_pgu_crtc_atomic_begin,
165143 .atomic_enable = arc_pgu_crtc_atomic_enable,
166144 .atomic_disable = arc_pgu_crtc_atomic_disable,
167145 };
....@@ -186,7 +164,6 @@
186164
187165 static void arc_pgu_plane_destroy(struct drm_plane *plane)
188166 {
189
- drm_plane_helper_disable(plane, NULL);
190167 drm_plane_cleanup(plane);
191168 }
192169
....@@ -203,18 +180,15 @@
203180 {
204181 struct arcpgu_drm_private *arcpgu = drm->dev_private;
205182 struct drm_plane *plane = NULL;
206
- u32 formats[ARRAY_SIZE(supported_formats)], i;
207183 int ret;
208184
209185 plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
210186 if (!plane)
211187 return ERR_PTR(-ENOMEM);
212188
213
- for (i = 0; i < ARRAY_SIZE(supported_formats); i++)
214
- formats[i] = supported_formats[i].fourcc;
215
-
216189 ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
217
- formats, ARRAY_SIZE(formats),
190
+ arc_pgu_supported_formats,
191
+ ARRAY_SIZE(arc_pgu_supported_formats),
218192 NULL,
219193 DRM_PLANE_TYPE_PRIMARY, NULL);
220194 if (ret)