10
10
11
11
#include <linux/clk.h>
12
12
#include <linux/dma-mapping.h>
13
+ #include <linux/io.h>
13
14
#include <linux/module.h>
14
15
#include <linux/of_device.h>
16
+ #include <linux/platform_device.h>
15
17
#include <linux/pm_runtime.h>
16
- #include <linux/spinlock.h>
17
18
18
- #include <drm/drm_atomic.h>
19
19
#include <drm/drm_atomic_helper.h>
20
- #include <drm/drm_crtc.h>
20
+ #include <drm/drm_bridge.h>
21
+ #include <drm/drm_connector.h>
21
22
#include <drm/drm_drv.h>
22
23
#include <drm/drm_fb_helper.h>
23
24
#include <drm/drm_gem_cma_helper.h>
24
25
#include <drm/drm_gem_framebuffer_helper.h>
25
26
#include <drm/drm_irq.h>
27
+ #include <drm/drm_mode_config.h>
26
28
#include <drm/drm_of.h>
27
29
#include <drm/drm_probe_helper.h>
28
- #include <drm/drm_simple_kms_helper.h>
29
30
#include <drm/drm_vblank.h>
30
31
31
32
#include "mxsfb_drv.h"
@@ -57,22 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
57
58
},
58
59
};
59
60
60
- static const uint32_t mxsfb_formats [] = {
61
- DRM_FORMAT_XRGB8888 ,
62
- DRM_FORMAT_RGB565
63
- };
64
-
65
- static const uint64_t mxsfb_modifiers [] = {
66
- DRM_FORMAT_MOD_LINEAR ,
67
- DRM_FORMAT_MOD_INVALID
68
- };
69
-
70
- static struct mxsfb_drm_private *
71
- drm_pipe_to_mxsfb_drm_private (struct drm_simple_display_pipe * pipe )
72
- {
73
- return container_of (pipe , struct mxsfb_drm_private , pipe );
74
- }
75
-
76
61
void mxsfb_enable_axi_clk (struct mxsfb_drm_private * mxsfb )
77
62
{
78
63
if (mxsfb -> clk_axi )
@@ -95,77 +80,6 @@ static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = {
95
80
.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm ,
96
81
};
97
82
98
- static void mxsfb_pipe_enable (struct drm_simple_display_pipe * pipe ,
99
- struct drm_crtc_state * crtc_state ,
100
- struct drm_plane_state * plane_state )
101
- {
102
- struct mxsfb_drm_private * mxsfb = drm_pipe_to_mxsfb_drm_private (pipe );
103
- struct drm_device * drm = pipe -> plane .dev ;
104
-
105
- pm_runtime_get_sync (drm -> dev );
106
- mxsfb_crtc_enable (mxsfb );
107
- }
108
-
109
- static void mxsfb_pipe_disable (struct drm_simple_display_pipe * pipe )
110
- {
111
- struct mxsfb_drm_private * mxsfb = drm_pipe_to_mxsfb_drm_private (pipe );
112
- struct drm_device * drm = pipe -> plane .dev ;
113
- struct drm_crtc * crtc = & pipe -> crtc ;
114
- struct drm_pending_vblank_event * event ;
115
-
116
- mxsfb_crtc_disable (mxsfb );
117
- pm_runtime_put_sync (drm -> dev );
118
-
119
- spin_lock_irq (& drm -> event_lock );
120
- event = crtc -> state -> event ;
121
- if (event ) {
122
- crtc -> state -> event = NULL ;
123
- drm_crtc_send_vblank_event (crtc , event );
124
- }
125
- spin_unlock_irq (& drm -> event_lock );
126
- }
127
-
128
- static void mxsfb_pipe_update (struct drm_simple_display_pipe * pipe ,
129
- struct drm_plane_state * plane_state )
130
- {
131
- struct mxsfb_drm_private * mxsfb = drm_pipe_to_mxsfb_drm_private (pipe );
132
-
133
- mxsfb_plane_atomic_update (mxsfb , plane_state );
134
- }
135
-
136
- static int mxsfb_pipe_enable_vblank (struct drm_simple_display_pipe * pipe )
137
- {
138
- struct mxsfb_drm_private * mxsfb = drm_pipe_to_mxsfb_drm_private (pipe );
139
-
140
- /* Clear and enable VBLANK IRQ */
141
- mxsfb_enable_axi_clk (mxsfb );
142
- writel (CTRL1_CUR_FRAME_DONE_IRQ , mxsfb -> base + LCDC_CTRL1 + REG_CLR );
143
- writel (CTRL1_CUR_FRAME_DONE_IRQ_EN , mxsfb -> base + LCDC_CTRL1 + REG_SET );
144
- mxsfb_disable_axi_clk (mxsfb );
145
-
146
- return 0 ;
147
- }
148
-
149
- static void mxsfb_pipe_disable_vblank (struct drm_simple_display_pipe * pipe )
150
- {
151
- struct mxsfb_drm_private * mxsfb = drm_pipe_to_mxsfb_drm_private (pipe );
152
-
153
- /* Disable and clear VBLANK IRQ */
154
- mxsfb_enable_axi_clk (mxsfb );
155
- writel (CTRL1_CUR_FRAME_DONE_IRQ_EN , mxsfb -> base + LCDC_CTRL1 + REG_CLR );
156
- writel (CTRL1_CUR_FRAME_DONE_IRQ , mxsfb -> base + LCDC_CTRL1 + REG_CLR );
157
- mxsfb_disable_axi_clk (mxsfb );
158
- }
159
-
160
- static struct drm_simple_display_pipe_funcs mxsfb_funcs = {
161
- .enable = mxsfb_pipe_enable ,
162
- .disable = mxsfb_pipe_disable ,
163
- .update = mxsfb_pipe_update ,
164
- .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb ,
165
- .enable_vblank = mxsfb_pipe_enable_vblank ,
166
- .disable_vblank = mxsfb_pipe_disable_vblank ,
167
- };
168
-
169
83
static int mxsfb_attach_bridge (struct mxsfb_drm_private * mxsfb )
170
84
{
171
85
struct drm_device * drm = mxsfb -> drm ;
@@ -189,7 +103,7 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
189
103
if (!bridge )
190
104
return - ENODEV ;
191
105
192
- ret = drm_simple_display_pipe_attach_bridge (& mxsfb -> pipe , bridge );
106
+ ret = drm_bridge_attach (& mxsfb -> encoder , bridge , NULL , 0 );
193
107
if (ret ) {
194
108
DRM_DEV_ERROR (drm -> dev ,
195
109
"failed to attach bridge: %d\n" , ret );
@@ -256,11 +170,9 @@ static int mxsfb_load(struct drm_device *drm)
256
170
/* Modeset init */
257
171
drm_mode_config_init (drm );
258
172
259
- ret = drm_simple_display_pipe_init (drm , & mxsfb -> pipe , & mxsfb_funcs ,
260
- mxsfb_formats , ARRAY_SIZE (mxsfb_formats ),
261
- mxsfb_modifiers , NULL );
173
+ ret = mxsfb_kms_init (mxsfb );
262
174
if (ret < 0 ) {
263
- dev_err (drm -> dev , "Cannot setup simple display pipe \n" );
175
+ dev_err (drm -> dev , "Failed to initialize KMS pipeline \n" );
264
176
goto err_vblank ;
265
177
}
266
178
@@ -316,11 +228,11 @@ static void mxsfb_unload(struct drm_device *drm)
316
228
pm_runtime_disable (drm -> dev );
317
229
}
318
230
319
- static void mxsfb_irq_preinstall (struct drm_device * drm )
231
+ static void mxsfb_irq_disable (struct drm_device * drm )
320
232
{
321
233
struct mxsfb_drm_private * mxsfb = drm -> dev_private ;
322
234
323
- mxsfb_pipe_disable_vblank (& mxsfb -> pipe );
235
+ mxsfb -> crtc . funcs -> disable_vblank (& mxsfb -> crtc );
324
236
}
325
237
326
238
static irqreturn_t mxsfb_irq_handler (int irq , void * data )
@@ -334,7 +246,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
334
246
reg = readl (mxsfb -> base + LCDC_CTRL1 );
335
247
336
248
if (reg & CTRL1_CUR_FRAME_DONE_IRQ )
337
- drm_crtc_handle_vblank (& mxsfb -> pipe . crtc );
249
+ drm_crtc_handle_vblank (& mxsfb -> crtc );
338
250
339
251
writel (CTRL1_CUR_FRAME_DONE_IRQ , mxsfb -> base + LCDC_CTRL1 + REG_CLR );
340
252
@@ -348,8 +260,8 @@ DEFINE_DRM_GEM_CMA_FOPS(fops);
348
260
static struct drm_driver mxsfb_driver = {
349
261
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC ,
350
262
.irq_handler = mxsfb_irq_handler ,
351
- .irq_preinstall = mxsfb_irq_preinstall ,
352
- .irq_uninstall = mxsfb_irq_preinstall ,
263
+ .irq_preinstall = mxsfb_irq_disable ,
264
+ .irq_uninstall = mxsfb_irq_disable ,
353
265
DRM_GEM_CMA_DRIVER_OPS ,
354
266
.fops = & fops ,
355
267
.name = "mxsfb-drm" ,
0 commit comments