Lines Matching +full:dc +full:- +full:dc +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0+
11 #include <linux/dma-mapping.h>
17 #include <video/imx-ipu-v3.h>
26 #include "imx-drm.h"
27 #include "ipuv3-plane.h"
38 struct ipu_dc *dc; member
53 struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); in ipu_crtc_atomic_enable()
57 ipu_dc_enable_channel(ipu_crtc->dc); in ipu_crtc_atomic_enable()
58 ipu_di_enable(ipu_crtc->di); in ipu_crtc_atomic_enable()
69 if (plane == &ipu_crtc->plane[0]->base) in ipu_crtc_disable_planes()
71 if (ipu_crtc->plane[1] && plane == &ipu_crtc->plane[1]->base) in ipu_crtc_disable_planes()
76 ipu_plane_disable(ipu_crtc->plane[1], true); in ipu_crtc_disable_planes()
78 ipu_plane_disable(ipu_crtc->plane[0], true); in ipu_crtc_disable_planes()
87 struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); in ipu_crtc_atomic_disable()
89 ipu_dc_disable_channel(ipu_crtc->dc); in ipu_crtc_atomic_disable()
90 ipu_di_disable(ipu_crtc->di); in ipu_crtc_atomic_disable()
92 * Planes must be disabled before DC clock is removed, as otherwise the in ipu_crtc_atomic_disable()
102 spin_lock_irq(&crtc->dev->event_lock); in ipu_crtc_atomic_disable()
103 if (crtc->state->event && !crtc->state->active) { in ipu_crtc_atomic_disable()
104 drm_crtc_send_vblank_event(crtc, crtc->state->event); in ipu_crtc_atomic_disable()
105 crtc->state->event = NULL; in ipu_crtc_atomic_disable()
107 spin_unlock_irq(&crtc->dev->event_lock); in ipu_crtc_atomic_disable()
114 if (crtc->state) in imx_drm_crtc_reset()
115 __drm_atomic_helper_crtc_destroy_state(crtc->state); in imx_drm_crtc_reset()
117 kfree(to_imx_crtc_state(crtc->state)); in imx_drm_crtc_reset()
118 crtc->state = NULL; in imx_drm_crtc_reset()
122 __drm_atomic_helper_crtc_reset(crtc, &state->base); in imx_drm_crtc_reset()
133 __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); in imx_drm_crtc_duplicate_state()
135 WARN_ON(state->base.crtc != crtc); in imx_drm_crtc_duplicate_state()
136 state->base.crtc = crtc; in imx_drm_crtc_duplicate_state()
138 return &state->base; in imx_drm_crtc_duplicate_state()
152 enable_irq(ipu_crtc->irq); in ipu_enable_vblank()
161 disable_irq_nosync(ipu_crtc->irq); in ipu_disable_vblank()
177 struct drm_crtc *crtc = &ipu_crtc->base; in ipu_irq_handler()
183 if (ipu_crtc->event) { in ipu_irq_handler()
184 for (i = 0; i < ARRAY_SIZE(ipu_crtc->plane); i++) { in ipu_irq_handler()
185 struct ipu_plane *plane = ipu_crtc->plane[i]; in ipu_irq_handler()
190 if (ipu_plane_atomic_update_pending(&plane->base)) in ipu_irq_handler()
194 if (i == ARRAY_SIZE(ipu_crtc->plane)) { in ipu_irq_handler()
195 spin_lock_irqsave(&crtc->dev->event_lock, flags); in ipu_irq_handler()
196 drm_crtc_send_vblank_event(crtc, ipu_crtc->event); in ipu_irq_handler()
197 ipu_crtc->event = NULL; in ipu_irq_handler()
199 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); in ipu_irq_handler()
207 const struct drm_display_mode *mode, in ipu_crtc_mode_fixup() argument
216 ret = ipu_di_adjust_videomode(ipu_crtc->di, &vm); in ipu_crtc_mode_fixup()
233 u32 primary_plane_mask = drm_plane_mask(crtc->primary); in ipu_crtc_atomic_check()
235 if (crtc_state->active && (primary_plane_mask & crtc_state->plane_mask) == 0) in ipu_crtc_atomic_check()
236 return -EINVAL; in ipu_crtc_atomic_check()
250 spin_lock_irq(&crtc->dev->event_lock); in ipu_crtc_atomic_flush()
251 if (crtc->state->event) { in ipu_crtc_atomic_flush()
255 ipu_crtc->event = crtc->state->event; in ipu_crtc_atomic_flush()
256 crtc->state->event = NULL; in ipu_crtc_atomic_flush()
258 spin_unlock_irq(&crtc->dev->event_lock); in ipu_crtc_atomic_flush()
263 struct drm_device *dev = crtc->dev; in ipu_crtc_mode_set_nofb()
266 struct drm_display_mode *mode = &crtc->state->adjusted_mode; in ipu_crtc_mode_set_nofb() local
267 struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc->state); in ipu_crtc_mode_set_nofb()
271 dev_dbg(ipu_crtc->dev, "%s: mode->hdisplay: %d\n", __func__, in ipu_crtc_mode_set_nofb()
272 mode->hdisplay); in ipu_crtc_mode_set_nofb()
273 dev_dbg(ipu_crtc->dev, "%s: mode->vdisplay: %d\n", __func__, in ipu_crtc_mode_set_nofb()
274 mode->vdisplay); in ipu_crtc_mode_set_nofb()
276 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { in ipu_crtc_mode_set_nofb()
277 if (encoder->crtc == crtc) in ipu_crtc_mode_set_nofb()
278 encoder_types |= BIT(encoder->encoder_type); in ipu_crtc_mode_set_nofb()
281 dev_dbg(ipu_crtc->dev, "%s: attached to encoder types 0x%lx\n", in ipu_crtc_mode_set_nofb()
297 sig_cfg.enable_pol = !(imx_crtc_state->bus_flags & DRM_BUS_FLAG_DE_LOW); in ipu_crtc_mode_set_nofb()
299 sig_cfg.clk_pol = !!(imx_crtc_state->bus_flags & in ipu_crtc_mode_set_nofb()
301 sig_cfg.bus_format = imx_crtc_state->bus_format; in ipu_crtc_mode_set_nofb()
303 sig_cfg.hsync_pin = imx_crtc_state->di_hsync_pin; in ipu_crtc_mode_set_nofb()
304 sig_cfg.vsync_pin = imx_crtc_state->di_vsync_pin; in ipu_crtc_mode_set_nofb()
306 drm_display_mode_to_videomode(mode, &sig_cfg.mode); in ipu_crtc_mode_set_nofb()
307 if (!IS_ALIGNED(sig_cfg.mode.hactive, 8)) { in ipu_crtc_mode_set_nofb()
308 unsigned int new_hactive = ALIGN(sig_cfg.mode.hactive, 8); in ipu_crtc_mode_set_nofb()
310 dev_warn(ipu_crtc->dev, "8-pixel align hactive %d -> %d\n", in ipu_crtc_mode_set_nofb()
311 sig_cfg.mode.hactive, new_hactive); in ipu_crtc_mode_set_nofb()
313 sig_cfg.mode.hfront_porch -= new_hactive - sig_cfg.mode.hactive; in ipu_crtc_mode_set_nofb()
314 sig_cfg.mode.hactive = new_hactive; in ipu_crtc_mode_set_nofb()
317 ipu_dc_init_sync(ipu_crtc->dc, ipu_crtc->di, in ipu_crtc_mode_set_nofb()
318 mode->flags & DRM_MODE_FLAG_INTERLACE, in ipu_crtc_mode_set_nofb()
319 imx_crtc_state->bus_format, sig_cfg.mode.hactive); in ipu_crtc_mode_set_nofb()
320 ipu_di_init_sync_panel(ipu_crtc->di, &sig_cfg); in ipu_crtc_mode_set_nofb()
337 if (!IS_ERR_OR_NULL(ipu_crtc->dc)) in ipu_put_resources()
338 ipu_dc_put(ipu_crtc->dc); in ipu_put_resources()
339 if (!IS_ERR_OR_NULL(ipu_crtc->di)) in ipu_put_resources()
340 ipu_di_put(ipu_crtc->di); in ipu_put_resources()
346 struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); in ipu_get_resources()
349 ipu_crtc->dc = ipu_dc_get(ipu, pdata->dc); in ipu_get_resources()
350 if (IS_ERR(ipu_crtc->dc)) in ipu_get_resources()
351 return PTR_ERR(ipu_crtc->dc); in ipu_get_resources()
357 ipu_crtc->di = ipu_di_get(ipu, pdata->di); in ipu_get_resources()
358 if (IS_ERR(ipu_crtc->di)) in ipu_get_resources()
359 return PTR_ERR(ipu_crtc->di); in ipu_get_resources()
366 struct ipu_client_platformdata *pdata = dev->platform_data; in ipu_drm_bind()
367 struct ipu_soc *ipu = dev_get_drvdata(dev->parent); in ipu_drm_bind()
372 int dp = -EINVAL; in ipu_drm_bind()
375 if (pdata->dp >= 0) in ipu_drm_bind()
377 primary_plane = ipu_plane_init(drm, ipu, pdata->dma[0], dp, 0, in ipu_drm_bind()
383 &primary_plane->base, NULL, in ipu_drm_bind()
388 ipu_crtc->dev = dev; in ipu_drm_bind()
389 ipu_crtc->plane[0] = primary_plane; in ipu_drm_bind()
391 crtc = &ipu_crtc->base; in ipu_drm_bind()
392 crtc->port = pdata->of_node; in ipu_drm_bind()
397 dev_err(ipu_crtc->dev, "getting resources failed with %d.\n", in ipu_drm_bind()
403 if (pdata->dp >= 0 && pdata->dma[1] > 0) { in ipu_drm_bind()
404 ipu_crtc->plane[1] = ipu_plane_init(drm, ipu, pdata->dma[1], in ipu_drm_bind()
406 drm_crtc_mask(&ipu_crtc->base), in ipu_drm_bind()
408 if (IS_ERR(ipu_crtc->plane[1])) in ipu_drm_bind()
409 ipu_crtc->plane[1] = NULL; in ipu_drm_bind()
412 ipu_crtc->irq = ipu_plane_irq(ipu_crtc->plane[0]); in ipu_drm_bind()
413 ret = devm_request_irq(ipu_crtc->dev, ipu_crtc->irq, ipu_irq_handler, 0, in ipu_drm_bind()
416 dev_err(ipu_crtc->dev, "irq request failed with %d.\n", ret); in ipu_drm_bind()
420 disable_irq(ipu_crtc->irq); in ipu_drm_bind()
431 struct device *dev = &pdev->dev; in ipu_drm_probe()
434 if (!dev->platform_data) in ipu_drm_probe()
435 return -EINVAL; in ipu_drm_probe()
446 component_del(&pdev->dev, &ipu_crtc_ops); in ipu_drm_remove()
452 .name = "imx-ipuv3-crtc",