Skip to content

Commit 7e06886

Browse files
committed
drm/mipi-dbi: Remove ->enabled
The atomic helpers try really hard to not lose track of things, duplicating enabled tracking in the driver is at best confusing. Double-enabling or disabling is a bug in atomic helpers. In the fb_dirty function we can just assume that the fb always exists, simple display pipe helpers guarantee that the crtc is only enabled together with the output, so we always have a primary plane around. Now in the update function we need to be a notch more careful, since that can also get called when the crtc is off. And we don't want to upload frames when that's the case, so filter that out too. Reviewed-by: Noralf Trønnes <[email protected]> Acked-by: David Lechner <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: David Lechner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e8411b7 commit 7e06886

File tree

4 files changed

+12
-32
lines changed

4 files changed

+12
-32
lines changed

drivers/gpu/drm/drm_mipi_dbi.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
268268
bool full;
269269
void *tr;
270270

271-
if (!dbidev->enabled)
271+
if (WARN_ON(!fb))
272272
return;
273273

274274
if (!drm_dev_enter(fb->dev, &idx))
@@ -314,6 +314,9 @@ void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
314314
struct drm_plane_state *state = pipe->plane.state;
315315
struct drm_rect rect;
316316

317+
if (!pipe->crtc.state->active)
318+
return;
319+
317320
if (drm_atomic_helper_damage_merged(old_state, state, &rect))
318321
mipi_dbi_fb_dirty(state->fb, &rect);
319322
}
@@ -325,9 +328,8 @@ EXPORT_SYMBOL(mipi_dbi_pipe_update);
325328
* @crtc_state: CRTC state
326329
* @plane_state: Plane state
327330
*
328-
* This function sets &mipi_dbi->enabled, flushes the whole framebuffer and
329-
* enables the backlight. Drivers can use this in their
330-
* &drm_simple_display_pipe_funcs->enable callback.
331+
* Flushes the whole framebuffer and enables the backlight. Drivers can use this
332+
* in their &drm_simple_display_pipe_funcs->enable callback.
331333
*
332334
* Note: Drivers which don't use mipi_dbi_pipe_update() because they have custom
333335
* framebuffer flushing, can't use this function since they both use the same
@@ -349,7 +351,6 @@ void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
349351
if (!drm_dev_enter(&dbidev->drm, &idx))
350352
return;
351353

352-
dbidev->enabled = true;
353354
mipi_dbi_fb_dirty(fb, &rect);
354355
backlight_enable(dbidev->backlight);
355356

@@ -390,13 +391,8 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe)
390391
{
391392
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
392393

393-
if (!dbidev->enabled)
394-
return;
395-
396394
DRM_DEBUG_KMS("\n");
397395

398-
dbidev->enabled = false;
399-
400396
if (dbidev->backlight)
401397
backlight_disable(dbidev->backlight);
402398
else

drivers/gpu/drm/tiny/ili9225.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
8989
bool full;
9090
void *tr;
9191

92-
if (!dbidev->enabled)
93-
return;
94-
9592
if (!drm_dev_enter(fb->dev, &idx))
9693
return;
9794

@@ -167,6 +164,9 @@ static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
167164
struct drm_plane_state *state = pipe->plane.state;
168165
struct drm_rect rect;
169166

167+
if (!pipe->crtc.state->active)
168+
return;
169+
170170
if (drm_atomic_helper_damage_merged(old_state, state, &rect))
171171
ili9225_fb_dirty(state->fb, &rect);
172172
}
@@ -275,7 +275,6 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
275275

276276
ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x1017);
277277

278-
dbidev->enabled = true;
279278
ili9225_fb_dirty(fb, &rect);
280279
out_exit:
281280
drm_dev_exit(idx);
@@ -295,16 +294,11 @@ static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
295294
* unplug.
296295
*/
297296

298-
if (!dbidev->enabled)
299-
return;
300-
301297
ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x0000);
302298
msleep(50);
303299
ili9225_command(dbi, ILI9225_POWER_CONTROL_2, 0x0007);
304300
msleep(50);
305301
ili9225_command(dbi, ILI9225_POWER_CONTROL_1, 0x0a02);
306-
307-
dbidev->enabled = false;
308302
}
309303

310304
static int ili9225_dbi_command(struct mipi_dbi *dbi, u8 *cmd, u8 *par,

drivers/gpu/drm/tiny/st7586.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
118118
struct mipi_dbi *dbi = &dbidev->dbi;
119119
int start, end, idx, ret = 0;
120120

121-
if (!dbidev->enabled)
122-
return;
123-
124121
if (!drm_dev_enter(fb->dev, &idx))
125122
return;
126123

@@ -161,6 +158,9 @@ static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
161158
struct drm_plane_state *state = pipe->plane.state;
162159
struct drm_rect rect;
163160

161+
if (!pipe->crtc.state->active)
162+
return;
163+
164164
if (drm_atomic_helper_damage_merged(old_state, state, &rect))
165165
st7586_fb_dirty(state->fb, &rect);
166166
}
@@ -237,7 +237,6 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
237237

238238
msleep(100);
239239

240-
dbidev->enabled = true;
241240
st7586_fb_dirty(fb, &rect);
242241

243242
mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON);
@@ -258,11 +257,7 @@ static void st7586_pipe_disable(struct drm_simple_display_pipe *pipe)
258257

259258
DRM_DEBUG_KMS("\n");
260259

261-
if (!dbidev->enabled)
262-
return;
263-
264260
mipi_dbi_command(&dbidev->dbi, MIPI_DCS_SET_DISPLAY_OFF);
265-
dbidev->enabled = false;
266261
}
267262

268263
static const u32 st7586_formats[] = {

include/drm/drm_mipi_dbi.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ struct mipi_dbi_dev {
9494
*/
9595
struct drm_display_mode mode;
9696

97-
/**
98-
* @enabled: Pipeline is enabled
99-
*/
100-
bool enabled;
101-
10297
/**
10398
* @tx_buf: Buffer used for transfer (copy clip rect area)
10499
*/

0 commit comments

Comments
 (0)