Lines Matching refs:rcrtc
29 static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg) in rcar_du_crtc_read() argument
31 struct rcar_du_device *rcdu = rcrtc->group->dev; in rcar_du_crtc_read()
33 return rcar_du_read(rcdu, rcrtc->mmio_offset + reg); in rcar_du_crtc_read()
36 static void rcar_du_crtc_write(struct rcar_du_crtc *rcrtc, u32 reg, u32 data) in rcar_du_crtc_write() argument
38 struct rcar_du_device *rcdu = rcrtc->group->dev; in rcar_du_crtc_write()
40 rcar_du_write(rcdu, rcrtc->mmio_offset + reg, data); in rcar_du_crtc_write()
43 static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, u32 reg, u32 clr) in rcar_du_crtc_clr() argument
45 struct rcar_du_device *rcdu = rcrtc->group->dev; in rcar_du_crtc_clr()
47 rcar_du_write(rcdu, rcrtc->mmio_offset + reg, in rcar_du_crtc_clr()
48 rcar_du_read(rcdu, rcrtc->mmio_offset + reg) & ~clr); in rcar_du_crtc_clr()
51 static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, u32 reg, u32 set) in rcar_du_crtc_set() argument
53 struct rcar_du_device *rcdu = rcrtc->group->dev; in rcar_du_crtc_set()
55 rcar_du_write(rcdu, rcrtc->mmio_offset + reg, in rcar_du_crtc_set()
56 rcar_du_read(rcdu, rcrtc->mmio_offset + reg) | set); in rcar_du_crtc_set()
59 static void rcar_du_crtc_clr_set(struct rcar_du_crtc *rcrtc, u32 reg, in rcar_du_crtc_clr_set() argument
62 struct rcar_du_device *rcdu = rcrtc->group->dev; in rcar_du_crtc_clr_set()
63 u32 value = rcar_du_read(rcdu, rcrtc->mmio_offset + reg); in rcar_du_crtc_clr_set()
65 rcar_du_write(rcdu, rcrtc->mmio_offset + reg, (value & ~clr) | set); in rcar_du_crtc_clr_set()
68 static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_get() argument
72 ret = clk_prepare_enable(rcrtc->clock); in rcar_du_crtc_get()
76 ret = rcar_du_group_get(rcrtc->group); in rcar_du_crtc_get()
78 clk_disable_unprepare(rcrtc->clock); in rcar_du_crtc_get()
83 static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_put() argument
85 rcar_du_group_put(rcrtc->group); in rcar_du_crtc_put()
86 clk_disable_unprepare(rcrtc->clock); in rcar_du_crtc_put()
89 static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_set_display_timing() argument
91 const struct drm_display_mode *mode = &rcrtc->crtc.mode; in rcar_du_crtc_set_display_timing()
97 clk = clk_get_rate(rcrtc->clock); in rcar_du_crtc_set_display_timing()
101 rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? ESCR2 : ESCR, in rcar_du_crtc_set_display_timing()
103 rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? OTAR2 : OTAR, 0); in rcar_du_crtc_set_display_timing()
109 rcar_du_crtc_write(rcrtc, DSMR, value); in rcar_du_crtc_set_display_timing()
112 rcar_du_crtc_write(rcrtc, HDSR, mode->htotal - mode->hsync_start - 19); in rcar_du_crtc_set_display_timing()
113 rcar_du_crtc_write(rcrtc, HDER, mode->htotal - mode->hsync_start + in rcar_du_crtc_set_display_timing()
115 rcar_du_crtc_write(rcrtc, HSWR, mode->hsync_end - in rcar_du_crtc_set_display_timing()
117 rcar_du_crtc_write(rcrtc, HCR, mode->htotal - 1); in rcar_du_crtc_set_display_timing()
119 rcar_du_crtc_write(rcrtc, VDSR, mode->vtotal - mode->vsync_end - 2); in rcar_du_crtc_set_display_timing()
120 rcar_du_crtc_write(rcrtc, VDER, mode->vtotal - mode->vsync_end + in rcar_du_crtc_set_display_timing()
122 rcar_du_crtc_write(rcrtc, VSPR, mode->vtotal - mode->vsync_end + in rcar_du_crtc_set_display_timing()
124 rcar_du_crtc_write(rcrtc, VCR, mode->vtotal - 1); in rcar_du_crtc_set_display_timing()
126 rcar_du_crtc_write(rcrtc, DESR, mode->htotal - mode->hsync_start); in rcar_du_crtc_set_display_timing()
127 rcar_du_crtc_write(rcrtc, DEWR, mode->hdisplay); in rcar_du_crtc_set_display_timing()
133 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_route_output() local
134 struct rcar_du_device *rcdu = rcrtc->group->dev; in rcar_du_crtc_route_output()
139 rcrtc->outputs |= BIT(output); in rcar_du_crtc_route_output()
144 rcdu->dpad0_source = rcrtc->index; in rcar_du_crtc_route_output()
149 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_update_planes() local
157 for (i = 0; i < ARRAY_SIZE(rcrtc->group->planes.planes); ++i) { in rcar_du_crtc_update_planes()
158 struct rcar_du_plane *plane = &rcrtc->group->planes.planes[i]; in rcar_du_crtc_update_planes()
161 if (plane->crtc != &rcrtc->crtc || !plane->enabled) in rcar_du_crtc_update_planes()
195 if (rcrtc->index % 2) { in rcar_du_crtc_update_planes()
196 u32 value = rcar_du_group_read(rcrtc->group, DPTSR); in rcar_du_crtc_update_planes()
206 rcar_du_group_write(rcrtc->group, DPTSR, dptsr); in rcar_du_crtc_update_planes()
207 if (rcrtc->group->used_crtcs) in rcar_du_crtc_update_planes()
208 rcar_du_group_restart(rcrtc->group); in rcar_du_crtc_update_planes()
212 rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR, in rcar_du_crtc_update_planes()
216 static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_start() argument
218 struct drm_crtc *crtc = &rcrtc->crtc; in rcar_du_crtc_start()
221 if (rcrtc->started) in rcar_du_crtc_start()
224 if (WARN_ON(rcrtc->plane->format == NULL)) in rcar_du_crtc_start()
228 rcar_du_crtc_write(rcrtc, DOOR, DOOR_RGB(0, 0, 0)); in rcar_du_crtc_start()
229 rcar_du_crtc_write(rcrtc, BPOR, BPOR_RGB(0, 0, 0)); in rcar_du_crtc_start()
232 rcar_du_crtc_set_display_timing(rcrtc); in rcar_du_crtc_start()
233 rcar_du_group_set_routing(rcrtc->group); in rcar_du_crtc_start()
235 mutex_lock(&rcrtc->group->planes.lock); in rcar_du_crtc_start()
236 rcrtc->plane->enabled = true; in rcar_du_crtc_start()
238 mutex_unlock(&rcrtc->group->planes.lock); in rcar_du_crtc_start()
241 for (i = 0; i < ARRAY_SIZE(rcrtc->group->planes.planes); ++i) { in rcar_du_crtc_start()
242 struct rcar_du_plane *plane = &rcrtc->group->planes.planes[i]; in rcar_du_crtc_start()
254 rcar_du_crtc_clr_set(rcrtc, DSYSR, DSYSR_TVM_MASK, DSYSR_TVM_MASTER); in rcar_du_crtc_start()
256 rcar_du_group_start_stop(rcrtc->group, true); in rcar_du_crtc_start()
258 rcrtc->started = true; in rcar_du_crtc_start()
261 static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_stop() argument
263 struct drm_crtc *crtc = &rcrtc->crtc; in rcar_du_crtc_stop()
265 if (!rcrtc->started) in rcar_du_crtc_stop()
268 mutex_lock(&rcrtc->group->planes.lock); in rcar_du_crtc_stop()
269 rcrtc->plane->enabled = false; in rcar_du_crtc_stop()
271 mutex_unlock(&rcrtc->group->planes.lock); in rcar_du_crtc_stop()
276 rcar_du_crtc_clr_set(rcrtc, DSYSR, DSYSR_TVM_MASK, DSYSR_TVM_SWITCH); in rcar_du_crtc_stop()
278 rcar_du_group_start_stop(rcrtc->group, false); in rcar_du_crtc_stop()
280 rcrtc->started = false; in rcar_du_crtc_stop()
283 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_suspend() argument
285 rcar_du_crtc_stop(rcrtc); in rcar_du_crtc_suspend()
286 rcar_du_crtc_put(rcrtc); in rcar_du_crtc_suspend()
289 void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_resume() argument
291 if (rcrtc->dpms != DRM_MODE_DPMS_ON) in rcar_du_crtc_resume()
294 rcar_du_crtc_get(rcrtc); in rcar_du_crtc_resume()
295 rcar_du_crtc_start(rcrtc); in rcar_du_crtc_resume()
298 static void rcar_du_crtc_update_base(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_update_base() argument
300 struct drm_crtc *crtc = &rcrtc->crtc; in rcar_du_crtc_update_base()
302 rcar_du_plane_compute_base(rcrtc->plane, crtc->primary->fb); in rcar_du_crtc_update_base()
303 rcar_du_plane_update_base(rcrtc->plane); in rcar_du_crtc_update_base()
308 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_dpms() local
310 if (rcrtc->dpms == mode) in rcar_du_crtc_dpms()
314 rcar_du_crtc_get(rcrtc); in rcar_du_crtc_dpms()
315 rcar_du_crtc_start(rcrtc); in rcar_du_crtc_dpms()
317 rcar_du_crtc_stop(rcrtc); in rcar_du_crtc_dpms()
318 rcar_du_crtc_put(rcrtc); in rcar_du_crtc_dpms()
321 rcrtc->dpms = mode; in rcar_du_crtc_dpms()
334 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_mode_prepare() local
339 rcar_du_crtc_get(rcrtc); in rcar_du_crtc_mode_prepare()
344 rcar_du_crtc_stop(rcrtc); in rcar_du_crtc_mode_prepare()
345 rcar_du_plane_release(rcrtc->plane); in rcar_du_crtc_mode_prepare()
347 rcrtc->dpms = DRM_MODE_DPMS_OFF; in rcar_du_crtc_mode_prepare()
356 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_mode_set() local
357 struct rcar_du_device *rcdu = rcrtc->group->dev; in rcar_du_crtc_mode_set()
369 ret = rcar_du_plane_reserve(rcrtc->plane, format); in rcar_du_crtc_mode_set()
373 rcrtc->plane->format = format; in rcar_du_crtc_mode_set()
375 rcrtc->plane->src_x = x; in rcar_du_crtc_mode_set()
376 rcrtc->plane->src_y = y; in rcar_du_crtc_mode_set()
377 rcrtc->plane->width = mode->hdisplay; in rcar_du_crtc_mode_set()
378 rcrtc->plane->height = mode->vdisplay; in rcar_du_crtc_mode_set()
380 rcar_du_plane_compute_base(rcrtc->plane, crtc->primary->fb); in rcar_du_crtc_mode_set()
382 rcrtc->outputs = 0; in rcar_du_crtc_mode_set()
391 rcar_du_crtc_put(rcrtc); in rcar_du_crtc_mode_set()
397 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_mode_commit() local
403 rcar_du_crtc_start(rcrtc); in rcar_du_crtc_mode_commit()
404 rcrtc->dpms = DRM_MODE_DPMS_ON; in rcar_du_crtc_mode_commit()
410 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_mode_set_base() local
412 rcrtc->plane->src_x = x; in rcar_du_crtc_mode_set_base()
413 rcrtc->plane->src_y = y; in rcar_du_crtc_mode_set_base()
415 rcar_du_crtc_update_base(rcrtc); in rcar_du_crtc_mode_set_base()
422 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_disable() local
425 rcar_du_plane_release(rcrtc->plane); in rcar_du_crtc_disable()
438 void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc, in rcar_du_crtc_cancel_page_flip() argument
442 struct drm_device *dev = rcrtc->crtc.dev; in rcar_du_crtc_cancel_page_flip()
449 event = rcrtc->event; in rcar_du_crtc_cancel_page_flip()
451 rcrtc->event = NULL; in rcar_du_crtc_cancel_page_flip()
453 drm_vblank_put(dev, rcrtc->index); in rcar_du_crtc_cancel_page_flip()
458 static void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc) in rcar_du_crtc_finish_page_flip() argument
461 struct drm_device *dev = rcrtc->crtc.dev; in rcar_du_crtc_finish_page_flip()
465 event = rcrtc->event; in rcar_du_crtc_finish_page_flip()
466 rcrtc->event = NULL; in rcar_du_crtc_finish_page_flip()
473 drm_send_vblank_event(dev, rcrtc->index, event); in rcar_du_crtc_finish_page_flip()
476 drm_vblank_put(dev, rcrtc->index); in rcar_du_crtc_finish_page_flip()
481 struct rcar_du_crtc *rcrtc = arg; in rcar_du_crtc_irq() local
485 status = rcar_du_crtc_read(rcrtc, DSSR); in rcar_du_crtc_irq()
486 rcar_du_crtc_write(rcrtc, DSRCR, status & DSRCR_MASK); in rcar_du_crtc_irq()
489 drm_handle_vblank(rcrtc->crtc.dev, rcrtc->index); in rcar_du_crtc_irq()
490 rcar_du_crtc_finish_page_flip(rcrtc); in rcar_du_crtc_irq()
502 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); in rcar_du_crtc_page_flip() local
503 struct drm_device *dev = rcrtc->crtc.dev; in rcar_du_crtc_page_flip()
507 if (rcrtc->event != NULL) { in rcar_du_crtc_page_flip()
514 rcar_du_crtc_update_base(rcrtc); in rcar_du_crtc_page_flip()
517 event->pipe = rcrtc->index; in rcar_du_crtc_page_flip()
518 drm_vblank_get(dev, rcrtc->index); in rcar_du_crtc_page_flip()
520 rcrtc->event = event; in rcar_du_crtc_page_flip()
541 struct rcar_du_crtc *rcrtc = &rcdu->crtcs[index]; in rcar_du_crtc_create() local
542 struct drm_crtc *crtc = &rcrtc->crtc; in rcar_du_crtc_create()
557 rcrtc->clock = devm_clk_get(rcdu->dev, name); in rcar_du_crtc_create()
558 if (IS_ERR(rcrtc->clock)) { in rcar_du_crtc_create()
560 return PTR_ERR(rcrtc->clock); in rcar_du_crtc_create()
563 rcrtc->group = rgrp; in rcar_du_crtc_create()
564 rcrtc->mmio_offset = mmio_offsets[index]; in rcar_du_crtc_create()
565 rcrtc->index = index; in rcar_du_crtc_create()
566 rcrtc->dpms = DRM_MODE_DPMS_OFF; in rcar_du_crtc_create()
567 rcrtc->plane = &rgrp->planes.planes[index % 2]; in rcar_du_crtc_create()
569 rcrtc->plane->crtc = crtc; in rcar_du_crtc_create()
592 dev_name(rcdu->dev), rcrtc); in rcar_du_crtc_create()
602 void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable) in rcar_du_crtc_enable_vblank() argument
605 rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL); in rcar_du_crtc_enable_vblank()
606 rcar_du_crtc_set(rcrtc, DIER, DIER_VBE); in rcar_du_crtc_enable_vblank()
608 rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE); in rcar_du_crtc_enable_vblank()