Skip to content

Commit f730ece

Browse files
committed
drm/tinydrm/mi0283qt: Let the display pipe handle power
It's better to leave power handling and controller init to the modesetting machinery using the simple pipe .enable and .disable callbacks. Remove unused mipi_dbi_pipe_enable(). Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Reviewed-by: David Lechner <david@lechnology.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180110185940.53841-6-noralf@tronnes.org
1 parent 070ab12 commit f730ece

3 files changed

Lines changed: 15 additions & 66 deletions

File tree

‎drivers/gpu/drm/tinydrm/mi0283qt.c‎

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,21 @@
4747
#define ILI9341_MADCTL_MX BIT(6)
4848
#define ILI9341_MADCTL_MY BIT(7)
4949

50-
static int mi0283qt_init(struct mipi_dbi *mipi)
50+
static void mi0283qt_enable(struct drm_simple_display_pipe *pipe,
51+
struct drm_crtc_state *crtc_state)
5152
{
53+
struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
54+
struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
5255
u8 addr_mode;
5356
int ret;
5457

5558
DRM_DEBUG_KMS("\n");
5659

5760
ret = mipi_dbi_poweron_conditional_reset(mipi);
5861
if (ret < 0)
59-
return ret;
62+
return;
6063
if (ret == 1)
61-
return 0;
64+
goto out_enable;
6265

6366
mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF);
6467

@@ -121,19 +124,12 @@ static int mi0283qt_init(struct mipi_dbi *mipi)
121124
mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON);
122125
msleep(100);
123126

124-
return 0;
125-
}
126-
127-
static void mi0283qt_fini(void *data)
128-
{
129-
struct mipi_dbi *mipi = data;
130-
131-
DRM_DEBUG_KMS("\n");
132-
regulator_disable(mipi->regulator);
127+
out_enable:
128+
mipi_dbi_enable_flush(mipi);
133129
}
134130

135131
static const struct drm_simple_display_pipe_funcs mi0283qt_pipe_funcs = {
136-
.enable = mipi_dbi_pipe_enable,
132+
.enable = mi0283qt_enable,
137133
.disable = mipi_dbi_pipe_disable,
138134
.update = tinydrm_display_pipe_update,
139135
.prepare_fb = tinydrm_display_pipe_prepare_fb,
@@ -214,17 +210,6 @@ static int mi0283qt_probe(struct spi_device *spi)
214210
if (ret)
215211
return ret;
216212

217-
ret = mi0283qt_init(mipi);
218-
if (ret)
219-
return ret;
220-
221-
/* use devres to fini after drm unregister (drv->remove is before) */
222-
ret = devm_add_action(dev, mi0283qt_fini, mipi);
223-
if (ret) {
224-
mi0283qt_fini(mipi);
225-
return ret;
226-
}
227-
228213
spi_set_drvdata(spi, mipi);
229214

230215
return devm_tinydrm_register(&mipi->tinydrm);
@@ -240,25 +225,13 @@ static void mi0283qt_shutdown(struct spi_device *spi)
240225
static int __maybe_unused mi0283qt_pm_suspend(struct device *dev)
241226
{
242227
struct mipi_dbi *mipi = dev_get_drvdata(dev);
243-
int ret;
244-
245-
ret = drm_mode_config_helper_suspend(mipi->tinydrm.drm);
246-
if (ret)
247-
return ret;
248-
249-
mi0283qt_fini(mipi);
250228

251-
return 0;
229+
return drm_mode_config_helper_suspend(mipi->tinydrm.drm);
252230
}
253231

254232
static int __maybe_unused mi0283qt_pm_resume(struct device *dev)
255233
{
256234
struct mipi_dbi *mipi = dev_get_drvdata(dev);
257-
int ret;
258-
259-
ret = mi0283qt_init(mipi);
260-
if (ret)
261-
return ret;
262235

263236
drm_mode_config_helper_resume(mipi->tinydrm.drm);
264237

‎drivers/gpu/drm/tinydrm/mipi-dbi.c‎

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -290,31 +290,6 @@ void mipi_dbi_enable_flush(struct mipi_dbi *mipi)
290290
}
291291
EXPORT_SYMBOL(mipi_dbi_enable_flush);
292292

293-
/**
294-
* mipi_dbi_pipe_enable - MIPI DBI pipe enable helper
295-
* @pipe: Display pipe
296-
* @crtc_state: CRTC state
297-
*
298-
* This function enables backlight. Drivers can use this as their
299-
* &drm_simple_display_pipe_funcs->enable callback.
300-
*/
301-
void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe,
302-
struct drm_crtc_state *crtc_state)
303-
{
304-
struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
305-
struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
306-
struct drm_framebuffer *fb = pipe->plane.fb;
307-
308-
DRM_DEBUG_KMS("\n");
309-
310-
mipi->enabled = true;
311-
if (fb)
312-
fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0);
313-
314-
tinydrm_enable_backlight(mipi->backlight);
315-
}
316-
EXPORT_SYMBOL(mipi_dbi_pipe_enable);
317-
318293
static void mipi_dbi_blank(struct mipi_dbi *mipi)
319294
{
320295
struct drm_device *drm = mipi->tinydrm.drm;
@@ -336,8 +311,8 @@ static void mipi_dbi_blank(struct mipi_dbi *mipi)
336311
* mipi_dbi_pipe_disable - MIPI DBI pipe disable helper
337312
* @pipe: Display pipe
338313
*
339-
* This function disables backlight if present or if not the
340-
* display memory is blanked. Drivers can use this as their
314+
* This function disables backlight if present, if not the display memory is
315+
* blanked. The regulator is disabled if in use. Drivers can use this as their
341316
* &drm_simple_display_pipe_funcs->disable callback.
342317
*/
343318
void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe)
@@ -353,6 +328,9 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe)
353328
tinydrm_disable_backlight(mipi->backlight);
354329
else
355330
mipi_dbi_blank(mipi);
331+
332+
if (mipi->regulator)
333+
regulator_disable(mipi->regulator);
356334
}
357335
EXPORT_SYMBOL(mipi_dbi_pipe_disable);
358336

‎include/drm/tinydrm/mipi-dbi.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi,
6868
struct drm_driver *driver,
6969
const struct drm_display_mode *mode, unsigned int rotation);
7070
void mipi_dbi_enable_flush(struct mipi_dbi *mipi);
71-
void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe,
72-
struct drm_crtc_state *crtc_state);
7371
void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe);
7472
void mipi_dbi_hw_reset(struct mipi_dbi *mipi);
7573
bool mipi_dbi_display_is_on(struct mipi_dbi *mipi);

0 commit comments

Comments
 (0)