Skip to content

Commit

Permalink
drm/mipi-dbi: Remove ->enabled
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
danvet committed Jun 24, 2020
1 parent e8411b7 commit 7e06886
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 32 deletions.
16 changes: 6 additions & 10 deletions drivers/gpu/drm/drm_mipi_dbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
bool full;
void *tr;

if (!dbidev->enabled)
if (WARN_ON(!fb))
return;

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

if (!pipe->crtc.state->active)
return;

if (drm_atomic_helper_damage_merged(old_state, state, &rect))
mipi_dbi_fb_dirty(state->fb, &rect);
}
Expand All @@ -325,9 +328,8 @@ EXPORT_SYMBOL(mipi_dbi_pipe_update);
* @crtc_state: CRTC state
* @plane_state: Plane state
*
* This function sets &mipi_dbi->enabled, flushes the whole framebuffer and
* enables the backlight. Drivers can use this in their
* &drm_simple_display_pipe_funcs->enable callback.
* Flushes the whole framebuffer and enables the backlight. Drivers can use this
* in their &drm_simple_display_pipe_funcs->enable callback.
*
* Note: Drivers which don't use mipi_dbi_pipe_update() because they have custom
* framebuffer flushing, can't use this function since they both use the same
Expand All @@ -349,7 +351,6 @@ void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
if (!drm_dev_enter(&dbidev->drm, &idx))
return;

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

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

if (!dbidev->enabled)
return;

DRM_DEBUG_KMS("\n");

dbidev->enabled = false;

if (dbidev->backlight)
backlight_disable(dbidev->backlight);
else
Expand Down
12 changes: 3 additions & 9 deletions drivers/gpu/drm/tiny/ili9225.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
bool full;
void *tr;

if (!dbidev->enabled)
return;

if (!drm_dev_enter(fb->dev, &idx))
return;

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

if (!pipe->crtc.state->active)
return;

if (drm_atomic_helper_damage_merged(old_state, state, &rect))
ili9225_fb_dirty(state->fb, &rect);
}
Expand Down Expand Up @@ -275,7 +275,6 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,

ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x1017);

dbidev->enabled = true;
ili9225_fb_dirty(fb, &rect);
out_exit:
drm_dev_exit(idx);
Expand All @@ -295,16 +294,11 @@ static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
* unplug.
*/

if (!dbidev->enabled)
return;

ili9225_command(dbi, ILI9225_DISPLAY_CONTROL_1, 0x0000);
msleep(50);
ili9225_command(dbi, ILI9225_POWER_CONTROL_2, 0x0007);
msleep(50);
ili9225_command(dbi, ILI9225_POWER_CONTROL_1, 0x0a02);

dbidev->enabled = false;
}

static int ili9225_dbi_command(struct mipi_dbi *dbi, u8 *cmd, u8 *par,
Expand Down
11 changes: 3 additions & 8 deletions drivers/gpu/drm/tiny/st7586.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
struct mipi_dbi *dbi = &dbidev->dbi;
int start, end, idx, ret = 0;

if (!dbidev->enabled)
return;

if (!drm_dev_enter(fb->dev, &idx))
return;

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

if (!pipe->crtc.state->active)
return;

if (drm_atomic_helper_damage_merged(old_state, state, &rect))
st7586_fb_dirty(state->fb, &rect);
}
Expand Down Expand Up @@ -237,7 +237,6 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,

msleep(100);

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

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

DRM_DEBUG_KMS("\n");

if (!dbidev->enabled)
return;

mipi_dbi_command(&dbidev->dbi, MIPI_DCS_SET_DISPLAY_OFF);
dbidev->enabled = false;
}

static const u32 st7586_formats[] = {
Expand Down
5 changes: 0 additions & 5 deletions include/drm/drm_mipi_dbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ struct mipi_dbi_dev {
*/
struct drm_display_mode mode;

/**
* @enabled: Pipeline is enabled
*/
bool enabled;

/**
* @tx_buf: Buffer used for transfer (copy clip rect area)
*/
Expand Down

0 comments on commit 7e06886

Please sign in to comment.