Skip to content

Commit ae1ed00

Browse files
pinchartlagners
authored andcommitted
drm: mxsfb: Stop using DRM simple display pipeline helper
The DRM simple display pipeline helper only supports a single plane. In order to prepare for support of the alpha plane on i.MX6SX and i.MX7, move away from the helper. No new feature is added. Signed-off-by: Laurent Pinchart <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Stefan Agner <[email protected]> Signed-off-by: Stefan Agner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 40a726b commit ae1ed00

File tree

3 files changed

+203
-124
lines changed

3 files changed

+203
-124
lines changed

drivers/gpu/drm/mxsfb/mxsfb_drv.c

Lines changed: 13 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@
1010

1111
#include <linux/clk.h>
1212
#include <linux/dma-mapping.h>
13+
#include <linux/io.h>
1314
#include <linux/module.h>
1415
#include <linux/of_device.h>
16+
#include <linux/platform_device.h>
1517
#include <linux/pm_runtime.h>
16-
#include <linux/spinlock.h>
1718

18-
#include <drm/drm_atomic.h>
1919
#include <drm/drm_atomic_helper.h>
20-
#include <drm/drm_crtc.h>
20+
#include <drm/drm_bridge.h>
21+
#include <drm/drm_connector.h>
2122
#include <drm/drm_drv.h>
2223
#include <drm/drm_fb_helper.h>
2324
#include <drm/drm_gem_cma_helper.h>
2425
#include <drm/drm_gem_framebuffer_helper.h>
2526
#include <drm/drm_irq.h>
27+
#include <drm/drm_mode_config.h>
2628
#include <drm/drm_of.h>
2729
#include <drm/drm_probe_helper.h>
28-
#include <drm/drm_simple_kms_helper.h>
2930
#include <drm/drm_vblank.h>
3031

3132
#include "mxsfb_drv.h"
@@ -57,22 +58,6 @@ static const struct mxsfb_devdata mxsfb_devdata[] = {
5758
},
5859
};
5960

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-
7661
void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
7762
{
7863
if (mxsfb->clk_axi)
@@ -95,77 +80,6 @@ static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = {
9580
.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
9681
};
9782

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-
16983
static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
17084
{
17185
struct drm_device *drm = mxsfb->drm;
@@ -189,7 +103,7 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
189103
if (!bridge)
190104
return -ENODEV;
191105

192-
ret = drm_simple_display_pipe_attach_bridge(&mxsfb->pipe, bridge);
106+
ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, 0);
193107
if (ret) {
194108
DRM_DEV_ERROR(drm->dev,
195109
"failed to attach bridge: %d\n", ret);
@@ -256,11 +170,9 @@ static int mxsfb_load(struct drm_device *drm)
256170
/* Modeset init */
257171
drm_mode_config_init(drm);
258172

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);
262174
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");
264176
goto err_vblank;
265177
}
266178

@@ -316,11 +228,11 @@ static void mxsfb_unload(struct drm_device *drm)
316228
pm_runtime_disable(drm->dev);
317229
}
318230

319-
static void mxsfb_irq_preinstall(struct drm_device *drm)
231+
static void mxsfb_irq_disable(struct drm_device *drm)
320232
{
321233
struct mxsfb_drm_private *mxsfb = drm->dev_private;
322234

323-
mxsfb_pipe_disable_vblank(&mxsfb->pipe);
235+
mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc);
324236
}
325237

326238
static irqreturn_t mxsfb_irq_handler(int irq, void *data)
@@ -334,7 +246,7 @@ static irqreturn_t mxsfb_irq_handler(int irq, void *data)
334246
reg = readl(mxsfb->base + LCDC_CTRL1);
335247

336248
if (reg & CTRL1_CUR_FRAME_DONE_IRQ)
337-
drm_crtc_handle_vblank(&mxsfb->pipe.crtc);
249+
drm_crtc_handle_vblank(&mxsfb->crtc);
338250

339251
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
340252

@@ -348,8 +260,8 @@ DEFINE_DRM_GEM_CMA_FOPS(fops);
348260
static struct drm_driver mxsfb_driver = {
349261
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
350262
.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,
353265
DRM_GEM_CMA_DRIVER_OPS,
354266
.fops = &fops,
355267
.name = "mxsfb-drm",

drivers/gpu/drm/mxsfb/mxsfb_drv.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
#ifndef __MXSFB_DRV_H__
99
#define __MXSFB_DRV_H__
1010

11-
struct drm_device;
11+
#include <drm/drm_crtc.h>
12+
#include <drm/drm_device.h>
13+
#include <drm/drm_encoder.h>
14+
#include <drm/drm_plane.h>
15+
16+
struct clk;
1217

1318
struct mxsfb_devdata {
1419
unsigned int transfer_count;
@@ -29,20 +34,22 @@ struct mxsfb_drm_private {
2934
struct clk *clk_disp_axi;
3035

3136
struct drm_device *drm;
32-
struct drm_simple_display_pipe pipe;
37+
struct drm_plane plane;
38+
struct drm_crtc crtc;
39+
struct drm_encoder encoder;
3340
struct drm_connector *connector;
3441
struct drm_bridge *bridge;
3542
};
3643

37-
int mxsfb_setup_crtc(struct drm_device *dev);
38-
int mxsfb_create_output(struct drm_device *dev);
44+
static inline struct mxsfb_drm_private *
45+
to_mxsfb_drm_private(struct drm_device *drm)
46+
{
47+
return drm->dev_private;
48+
}
3949

4050
void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb);
4151
void mxsfb_disable_axi_clk(struct mxsfb_drm_private *mxsfb);
4252

43-
void mxsfb_crtc_enable(struct mxsfb_drm_private *mxsfb);
44-
void mxsfb_crtc_disable(struct mxsfb_drm_private *mxsfb);
45-
void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb,
46-
struct drm_plane_state *state);
53+
int mxsfb_kms_init(struct mxsfb_drm_private *mxsfb);
4754

4855
#endif /* __MXSFB_DRV_H__ */

0 commit comments

Comments
 (0)