diff options
author | Jyri Sarha <jsarha@ti.com> | 2016-06-22 09:27:54 -0400 |
---|---|---|
committer | Jyri Sarha <jsarha@ti.com> | 2016-08-08 16:05:17 -0400 |
commit | 47bfd6c01efe639d4c44b1e3fce3816d36b23d46 (patch) | |
tree | 3f87bdef74a8eda986588240da0f4381c0dbe9e0 | |
parent | 514d1a1f47eb94348b6abf168b913af194cdf1a9 (diff) |
drm/tilcdc: Get rid of legacy dpms mechanism
Get rid of legacy dpms mechanism. This simplifies the code quite a
bit. The old start() and stop() functions become tilcdc_crtc_enable()
and *_disable(). The functions are added with all the necessary
mechanisms from the old dpms function and they are used directly as
the crtc helper enable() and disable() callbacks.
Signed-off-by: Jyri Sarha <jsarha@ti.com>
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 109 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_drv.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_drv.h | 3 |
3 files changed, 50 insertions, 70 deletions
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index 773bee27a2d0..400d8c45b075 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c | |||
@@ -30,7 +30,7 @@ struct tilcdc_crtc { | |||
30 | struct drm_plane primary; | 30 | struct drm_plane primary; |
31 | const struct tilcdc_panel_info *info; | 31 | const struct tilcdc_panel_info *info; |
32 | struct drm_pending_vblank_event *event; | 32 | struct drm_pending_vblank_event *event; |
33 | int dpms; | 33 | bool enabled; |
34 | wait_queue_head_t frame_done_wq; | 34 | wait_queue_head_t frame_done_wq; |
35 | bool frame_done; | 35 | bool frame_done; |
36 | spinlock_t irq_lock; | 36 | spinlock_t irq_lock; |
@@ -137,9 +137,15 @@ static void reset(struct drm_crtc *crtc) | |||
137 | tilcdc_clear(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET); | 137 | tilcdc_clear(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET); |
138 | } | 138 | } |
139 | 139 | ||
140 | static void start(struct drm_crtc *crtc) | 140 | static void tilcdc_crtc_enable(struct drm_crtc *crtc) |
141 | { | 141 | { |
142 | struct drm_device *dev = crtc->dev; | 142 | struct drm_device *dev = crtc->dev; |
143 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | ||
144 | |||
145 | if (tilcdc_crtc->enabled) | ||
146 | return; | ||
147 | |||
148 | pm_runtime_get_sync(dev->dev); | ||
143 | 149 | ||
144 | reset(crtc); | 150 | reset(crtc); |
145 | 151 | ||
@@ -150,14 +156,19 @@ static void start(struct drm_crtc *crtc) | |||
150 | tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE); | 156 | tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE); |
151 | 157 | ||
152 | drm_crtc_vblank_on(crtc); | 158 | drm_crtc_vblank_on(crtc); |
159 | |||
160 | tilcdc_crtc->enabled = true; | ||
153 | } | 161 | } |
154 | 162 | ||
155 | static void stop(struct drm_crtc *crtc) | 163 | void tilcdc_crtc_disable(struct drm_crtc *crtc) |
156 | { | 164 | { |
157 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 165 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
158 | struct drm_device *dev = crtc->dev; | 166 | struct drm_device *dev = crtc->dev; |
159 | struct tilcdc_drm_private *priv = dev->dev_private; | 167 | struct tilcdc_drm_private *priv = dev->dev_private; |
160 | 168 | ||
169 | if (!tilcdc_crtc->enabled) | ||
170 | return; | ||
171 | |||
161 | tilcdc_crtc->frame_done = false; | 172 | tilcdc_crtc->frame_done = false; |
162 | tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE); | 173 | tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE); |
163 | 174 | ||
@@ -177,13 +188,37 @@ static void stop(struct drm_crtc *crtc) | |||
177 | drm_crtc_vblank_off(crtc); | 188 | drm_crtc_vblank_off(crtc); |
178 | 189 | ||
179 | tilcdc_crtc_disable_irqs(dev); | 190 | tilcdc_crtc_disable_irqs(dev); |
191 | |||
192 | pm_runtime_put_sync(dev->dev); | ||
193 | |||
194 | if (tilcdc_crtc->next_fb) { | ||
195 | drm_flip_work_queue(&tilcdc_crtc->unref_work, | ||
196 | tilcdc_crtc->next_fb); | ||
197 | tilcdc_crtc->next_fb = NULL; | ||
198 | } | ||
199 | |||
200 | if (tilcdc_crtc->curr_fb) { | ||
201 | drm_flip_work_queue(&tilcdc_crtc->unref_work, | ||
202 | tilcdc_crtc->curr_fb); | ||
203 | tilcdc_crtc->curr_fb = NULL; | ||
204 | } | ||
205 | |||
206 | drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq); | ||
207 | tilcdc_crtc->last_vblank = ktime_set(0, 0); | ||
208 | |||
209 | tilcdc_crtc->enabled = false; | ||
210 | } | ||
211 | |||
212 | static bool tilcdc_crtc_is_on(struct drm_crtc *crtc) | ||
213 | { | ||
214 | return crtc->state && crtc->state->enable && crtc->state->active; | ||
180 | } | 215 | } |
181 | 216 | ||
182 | static void tilcdc_crtc_destroy(struct drm_crtc *crtc) | 217 | static void tilcdc_crtc_destroy(struct drm_crtc *crtc) |
183 | { | 218 | { |
184 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 219 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
185 | 220 | ||
186 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); | 221 | tilcdc_crtc_disable(crtc); |
187 | 222 | ||
188 | of_node_put(crtc->port); | 223 | of_node_put(crtc->port); |
189 | drm_crtc_cleanup(crtc); | 224 | drm_crtc_cleanup(crtc); |
@@ -237,52 +272,6 @@ int tilcdc_crtc_page_flip(struct drm_crtc *crtc, | |||
237 | return 0; | 272 | return 0; |
238 | } | 273 | } |
239 | 274 | ||
240 | void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode) | ||
241 | { | ||
242 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | ||
243 | struct drm_device *dev = crtc->dev; | ||
244 | struct tilcdc_drm_private *priv = dev->dev_private; | ||
245 | |||
246 | /* we really only care about on or off: */ | ||
247 | if (mode != DRM_MODE_DPMS_ON) | ||
248 | mode = DRM_MODE_DPMS_OFF; | ||
249 | |||
250 | if (tilcdc_crtc->dpms == mode) | ||
251 | return; | ||
252 | |||
253 | tilcdc_crtc->dpms = mode; | ||
254 | |||
255 | if (mode == DRM_MODE_DPMS_ON) { | ||
256 | pm_runtime_get_sync(dev->dev); | ||
257 | start(crtc); | ||
258 | } else { | ||
259 | stop(crtc); | ||
260 | pm_runtime_put_sync(dev->dev); | ||
261 | |||
262 | if (tilcdc_crtc->next_fb) { | ||
263 | drm_flip_work_queue(&tilcdc_crtc->unref_work, | ||
264 | tilcdc_crtc->next_fb); | ||
265 | tilcdc_crtc->next_fb = NULL; | ||
266 | } | ||
267 | |||
268 | if (tilcdc_crtc->curr_fb) { | ||
269 | drm_flip_work_queue(&tilcdc_crtc->unref_work, | ||
270 | tilcdc_crtc->curr_fb); | ||
271 | tilcdc_crtc->curr_fb = NULL; | ||
272 | } | ||
273 | |||
274 | drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq); | ||
275 | tilcdc_crtc->last_vblank = ktime_set(0, 0); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | int tilcdc_crtc_current_dpms_state(struct drm_crtc *crtc) | ||
280 | { | ||
281 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | ||
282 | |||
283 | return tilcdc_crtc->dpms; | ||
284 | } | ||
285 | |||
286 | static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc, | 275 | static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc, |
287 | const struct drm_display_mode *mode, | 276 | const struct drm_display_mode *mode, |
288 | struct drm_display_mode *adjusted_mode) | 277 | struct drm_display_mode *adjusted_mode) |
@@ -312,16 +301,6 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc, | |||
312 | return true; | 301 | return true; |
313 | } | 302 | } |
314 | 303 | ||
315 | static void tilcdc_crtc_disable(struct drm_crtc *crtc) | ||
316 | { | ||
317 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); | ||
318 | } | ||
319 | |||
320 | static void tilcdc_crtc_enable(struct drm_crtc *crtc) | ||
321 | { | ||
322 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_ON); | ||
323 | } | ||
324 | |||
325 | static void tilcdc_crtc_mode_set_nofb(struct drm_crtc *crtc) | 304 | static void tilcdc_crtc_mode_set_nofb(struct drm_crtc *crtc) |
326 | { | 305 | { |
327 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 306 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
@@ -655,18 +634,15 @@ void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc, | |||
655 | 634 | ||
656 | void tilcdc_crtc_update_clk(struct drm_crtc *crtc) | 635 | void tilcdc_crtc_update_clk(struct drm_crtc *crtc) |
657 | { | 636 | { |
658 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | ||
659 | struct drm_device *dev = crtc->dev; | 637 | struct drm_device *dev = crtc->dev; |
660 | struct tilcdc_drm_private *priv = dev->dev_private; | 638 | struct tilcdc_drm_private *priv = dev->dev_private; |
661 | int dpms = tilcdc_crtc->dpms; | ||
662 | unsigned long lcd_clk; | 639 | unsigned long lcd_clk; |
663 | const unsigned clkdiv = 2; /* using a fixed divider of 2 */ | 640 | const unsigned clkdiv = 2; /* using a fixed divider of 2 */ |
664 | int ret; | 641 | int ret; |
665 | 642 | ||
666 | pm_runtime_get_sync(dev->dev); | 643 | pm_runtime_get_sync(dev->dev); |
667 | 644 | ||
668 | if (dpms == DRM_MODE_DPMS_ON) | 645 | tilcdc_crtc_disable(crtc); |
669 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); | ||
670 | 646 | ||
671 | /* mode.clock is in KHz, set_rate wants parameter in Hz */ | 647 | /* mode.clock is in KHz, set_rate wants parameter in Hz */ |
672 | ret = clk_set_rate(priv->clk, crtc->mode.clock * 1000 * clkdiv); | 648 | ret = clk_set_rate(priv->clk, crtc->mode.clock * 1000 * clkdiv); |
@@ -690,8 +666,8 @@ void tilcdc_crtc_update_clk(struct drm_crtc *crtc) | |||
690 | LCDC_V2_DMA_CLK_EN | LCDC_V2_LIDD_CLK_EN | | 666 | LCDC_V2_DMA_CLK_EN | LCDC_V2_LIDD_CLK_EN | |
691 | LCDC_V2_CORE_CLK_EN); | 667 | LCDC_V2_CORE_CLK_EN); |
692 | 668 | ||
693 | if (dpms == DRM_MODE_DPMS_ON) | 669 | if (tilcdc_crtc_is_on(crtc)) |
694 | tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_ON); | 670 | tilcdc_crtc_enable(crtc); |
695 | 671 | ||
696 | out: | 672 | out: |
697 | pm_runtime_put_sync(dev->dev); | 673 | pm_runtime_put_sync(dev->dev); |
@@ -802,7 +778,6 @@ struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev) | |||
802 | if (ret < 0) | 778 | if (ret < 0) |
803 | goto fail; | 779 | goto fail; |
804 | 780 | ||
805 | tilcdc_crtc->dpms = DRM_MODE_DPMS_OFF; | ||
806 | init_waitqueue_head(&tilcdc_crtc->frame_done_wq); | 781 | init_waitqueue_head(&tilcdc_crtc->frame_done_wq); |
807 | 782 | ||
808 | drm_flip_work_init(&tilcdc_crtc->unref_work, | 783 | drm_flip_work_init(&tilcdc_crtc->unref_work, |
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index a9624b2e1815..3404d245d28d 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c | |||
@@ -113,12 +113,18 @@ static int tilcdc_commit(struct drm_device *dev, | |||
113 | * current layout. | 113 | * current layout. |
114 | */ | 114 | */ |
115 | 115 | ||
116 | /* Keep HW on while we commit the state. */ | ||
117 | pm_runtime_get_sync(dev->dev); | ||
118 | |||
116 | drm_atomic_helper_commit_modeset_disables(dev, state); | 119 | drm_atomic_helper_commit_modeset_disables(dev, state); |
117 | 120 | ||
118 | drm_atomic_helper_commit_planes(dev, state, false); | 121 | drm_atomic_helper_commit_planes(dev, state, false); |
119 | 122 | ||
120 | drm_atomic_helper_commit_modeset_enables(dev, state); | 123 | drm_atomic_helper_commit_modeset_enables(dev, state); |
121 | 124 | ||
125 | /* Now HW should remain on if need becase the crtc is enabled */ | ||
126 | pm_runtime_put_sync(dev->dev); | ||
127 | |||
122 | drm_atomic_helper_wait_for_vblanks(dev, state); | 128 | drm_atomic_helper_wait_for_vblanks(dev, state); |
123 | 129 | ||
124 | drm_atomic_helper_cleanup_planes(dev, state); | 130 | drm_atomic_helper_cleanup_planes(dev, state); |
@@ -183,7 +189,7 @@ static int tilcdc_unload(struct drm_device *dev) | |||
183 | { | 189 | { |
184 | struct tilcdc_drm_private *priv = dev->dev_private; | 190 | struct tilcdc_drm_private *priv = dev->dev_private; |
185 | 191 | ||
186 | tilcdc_crtc_dpms(priv->crtc, DRM_MODE_DPMS_OFF); | 192 | tilcdc_crtc_disable(priv->crtc); |
187 | 193 | ||
188 | tilcdc_remove_external_encoders(dev); | 194 | tilcdc_remove_external_encoders(dev); |
189 | 195 | ||
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h index 5e645ce2b509..a02eb3736d75 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h | |||
@@ -170,8 +170,7 @@ void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc, | |||
170 | bool simulate_vesa_sync); | 170 | bool simulate_vesa_sync); |
171 | int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode); | 171 | int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode); |
172 | int tilcdc_crtc_max_width(struct drm_crtc *crtc); | 172 | int tilcdc_crtc_max_width(struct drm_crtc *crtc); |
173 | void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode); | 173 | void tilcdc_crtc_disable(struct drm_crtc *crtc); |
174 | int tilcdc_crtc_current_dpms_state(struct drm_crtc *crtc); | ||
175 | int tilcdc_crtc_page_flip(struct drm_crtc *crtc, | 174 | int tilcdc_crtc_page_flip(struct drm_crtc *crtc, |
176 | struct drm_framebuffer *fb, | 175 | struct drm_framebuffer *fb, |
177 | struct drm_pending_vblank_event *event, | 176 | struct drm_pending_vblank_event *event, |