Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) STMicroelectronics SA 2014 |
| 3 | * Authors: Benjamin Gaignard <benjamin.gaignard@st.com> |
| 4 | * Fabien Dessenne <fabien.dessenne@st.com> |
| 5 | * for STMicroelectronics. |
| 6 | * License terms: GNU General Public License (GPL), version 2 |
| 7 | */ |
| 8 | |
| 9 | #include <linux/clk.h> |
| 10 | |
| 11 | #include <drm/drmP.h> |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 12 | #include <drm/drm_atomic.h> |
| 13 | #include <drm/drm_atomic_helper.h> |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 14 | #include <drm/drm_crtc_helper.h> |
Daniel Vetter | 3cb9ae4 | 2014-10-29 10:03:57 +0100 | [diff] [blame] | 15 | #include <drm/drm_plane_helper.h> |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 16 | |
| 17 | #include "sti_compositor.h" |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 18 | #include "sti_crtc.h" |
| 19 | #include "sti_drv.h" |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 20 | #include "sti_vtg.h" |
| 21 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 22 | static void sti_crtc_dpms(struct drm_crtc *crtc, int mode) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 23 | { |
| 24 | DRM_DEBUG_KMS("\n"); |
| 25 | } |
| 26 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 27 | static void sti_crtc_prepare(struct drm_crtc *crtc) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 28 | { |
| 29 | struct sti_mixer *mixer = to_sti_mixer(crtc); |
| 30 | struct device *dev = mixer->dev; |
| 31 | struct sti_compositor *compo = dev_get_drvdata(dev); |
| 32 | |
Benjamin Gaignard | 5e03abc | 2014-12-08 17:32:36 +0100 | [diff] [blame] | 33 | mixer->enabled = true; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 34 | |
| 35 | /* Prepare and enable the compo IP clock */ |
| 36 | if (mixer->id == STI_MIXER_MAIN) { |
| 37 | if (clk_prepare_enable(compo->clk_compo_main)) |
| 38 | DRM_INFO("Failed to prepare/enable compo_main clk\n"); |
| 39 | } else { |
| 40 | if (clk_prepare_enable(compo->clk_compo_aux)) |
| 41 | DRM_INFO("Failed to prepare/enable compo_aux clk\n"); |
| 42 | } |
Benjamin Gaignard | 2f7d0e82c | 2014-12-04 11:17:32 +0100 | [diff] [blame] | 43 | |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 44 | sti_mixer_clear_all_planes(mixer); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 47 | static void sti_crtc_commit(struct drm_crtc *crtc) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 48 | { |
| 49 | struct sti_mixer *mixer = to_sti_mixer(crtc); |
| 50 | struct device *dev = mixer->dev; |
| 51 | struct sti_compositor *compo = dev_get_drvdata(dev); |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 52 | struct sti_plane *plane; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 53 | |
| 54 | if ((!mixer || !compo)) { |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 55 | DRM_ERROR("Can't find mixer or compositor)\n"); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 56 | return; |
| 57 | } |
| 58 | |
| 59 | /* get GDP which is reserved to the CRTC FB */ |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 60 | plane = to_sti_plane(crtc->primary); |
| 61 | if (!plane) |
| 62 | DRM_ERROR("Can't find CRTC dedicated plane (GDP0)\n"); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 63 | |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 64 | /* Enable plane on mixer */ |
| 65 | if (sti_mixer_set_plane_status(mixer, plane, true)) |
| 66 | DRM_ERROR("Cannot enable plane at mixer\n"); |
Benjamin Gaignard | ca614aa | 2014-12-04 11:27:45 +0100 | [diff] [blame] | 67 | |
| 68 | drm_crtc_vblank_on(crtc); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 69 | } |
| 70 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 71 | static bool sti_crtc_mode_fixup(struct drm_crtc *crtc, |
| 72 | const struct drm_display_mode *mode, |
| 73 | struct drm_display_mode *adjusted_mode) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 74 | { |
| 75 | /* accept the provided drm_display_mode, do not fix it up */ |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | static int |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 80 | sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 81 | { |
| 82 | struct sti_mixer *mixer = to_sti_mixer(crtc); |
| 83 | struct device *dev = mixer->dev; |
| 84 | struct sti_compositor *compo = dev_get_drvdata(dev); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 85 | struct clk *clk; |
| 86 | int rate = mode->clock * 1000; |
| 87 | int res; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 88 | |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 89 | DRM_DEBUG_KMS("CRTC:%d (%s) mode:%d (%s)\n", |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 90 | crtc->base.id, sti_mixer_to_str(mixer), |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 91 | mode->base.id, mode->name); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 92 | |
| 93 | DRM_DEBUG_KMS("%d %d %d %d %d %d %d %d %d %d 0x%x 0x%x\n", |
| 94 | mode->vrefresh, mode->clock, |
| 95 | mode->hdisplay, |
| 96 | mode->hsync_start, mode->hsync_end, |
| 97 | mode->htotal, |
| 98 | mode->vdisplay, |
| 99 | mode->vsync_start, mode->vsync_end, |
| 100 | mode->vtotal, mode->type, mode->flags); |
| 101 | |
| 102 | /* Set rate and prepare/enable pixel clock */ |
| 103 | if (mixer->id == STI_MIXER_MAIN) |
| 104 | clk = compo->clk_pix_main; |
| 105 | else |
| 106 | clk = compo->clk_pix_aux; |
| 107 | |
| 108 | res = clk_set_rate(clk, rate); |
| 109 | if (res < 0) { |
| 110 | DRM_ERROR("Cannot set rate (%dHz) for pix clk\n", rate); |
| 111 | return -EINVAL; |
| 112 | } |
| 113 | if (clk_prepare_enable(clk)) { |
| 114 | DRM_ERROR("Failed to prepare/enable pix clk\n"); |
| 115 | return -EINVAL; |
| 116 | } |
| 117 | |
| 118 | sti_vtg_set_config(mixer->id == STI_MIXER_MAIN ? |
| 119 | compo->vtg_main : compo->vtg_aux, &crtc->mode); |
| 120 | |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 121 | res = sti_mixer_active_video_area(mixer, &crtc->mode); |
| 122 | if (res) { |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 123 | DRM_ERROR("Can't set active video area\n"); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 124 | return -EINVAL; |
| 125 | } |
| 126 | |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 127 | return res; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 128 | } |
| 129 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 130 | static void sti_crtc_disable(struct drm_crtc *crtc) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 131 | { |
| 132 | struct sti_mixer *mixer = to_sti_mixer(crtc); |
| 133 | struct device *dev = mixer->dev; |
| 134 | struct sti_compositor *compo = dev_get_drvdata(dev); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 135 | |
Benjamin Gaignard | 5e03abc | 2014-12-08 17:32:36 +0100 | [diff] [blame] | 136 | if (!mixer->enabled) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 137 | return; |
| 138 | |
| 139 | DRM_DEBUG_KMS("CRTC:%d (%s)\n", crtc->base.id, sti_mixer_to_str(mixer)); |
| 140 | |
| 141 | /* Disable Background */ |
| 142 | sti_mixer_set_background_status(mixer, false); |
| 143 | |
Benjamin Gaignard | ca614aa | 2014-12-04 11:27:45 +0100 | [diff] [blame] | 144 | drm_crtc_vblank_off(crtc); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 145 | |
| 146 | /* Disable pixel clock and compo IP clocks */ |
| 147 | if (mixer->id == STI_MIXER_MAIN) { |
| 148 | clk_disable_unprepare(compo->clk_pix_main); |
| 149 | clk_disable_unprepare(compo->clk_compo_main); |
| 150 | } else { |
| 151 | clk_disable_unprepare(compo->clk_pix_aux); |
| 152 | clk_disable_unprepare(compo->clk_compo_aux); |
| 153 | } |
| 154 | |
Benjamin Gaignard | 5e03abc | 2014-12-08 17:32:36 +0100 | [diff] [blame] | 155 | mixer->enabled = false; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 156 | } |
| 157 | |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 158 | static void |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 159 | sti_crtc_mode_set_nofb(struct drm_crtc *crtc) |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 160 | { |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 161 | sti_crtc_prepare(crtc); |
| 162 | sti_crtc_mode_set(crtc, &crtc->state->adjusted_mode); |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 163 | } |
| 164 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 165 | static void sti_crtc_atomic_begin(struct drm_crtc *crtc) |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 166 | { |
| 167 | struct sti_mixer *mixer = to_sti_mixer(crtc); |
| 168 | |
| 169 | if (crtc->state->event) { |
| 170 | crtc->state->event->pipe = drm_crtc_index(crtc); |
| 171 | |
| 172 | WARN_ON(drm_crtc_vblank_get(crtc) != 0); |
| 173 | |
| 174 | mixer->pending_event = crtc->state->event; |
| 175 | crtc->state->event = NULL; |
| 176 | } |
| 177 | } |
| 178 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 179 | static void sti_crtc_atomic_flush(struct drm_crtc *crtc) |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 180 | { |
| 181 | } |
| 182 | |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 183 | static struct drm_crtc_helper_funcs sti_crtc_helper_funcs = { |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 184 | .dpms = sti_crtc_dpms, |
| 185 | .prepare = sti_crtc_prepare, |
| 186 | .commit = sti_crtc_commit, |
| 187 | .mode_fixup = sti_crtc_mode_fixup, |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 188 | .mode_set = drm_helper_crtc_mode_set, |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 189 | .mode_set_nofb = sti_crtc_mode_set_nofb, |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 190 | .mode_set_base = drm_helper_crtc_mode_set_base, |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 191 | .disable = sti_crtc_disable, |
| 192 | .atomic_begin = sti_crtc_atomic_begin, |
| 193 | .atomic_flush = sti_crtc_atomic_flush, |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 194 | }; |
| 195 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 196 | static void sti_crtc_destroy(struct drm_crtc *crtc) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 197 | { |
| 198 | DRM_DEBUG_KMS("\n"); |
| 199 | drm_crtc_cleanup(crtc); |
| 200 | } |
| 201 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 202 | static int sti_crtc_set_property(struct drm_crtc *crtc, |
| 203 | struct drm_property *property, |
| 204 | uint64_t val) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 205 | { |
| 206 | DRM_DEBUG_KMS("\n"); |
| 207 | return 0; |
| 208 | } |
| 209 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 210 | int sti_crtc_vblank_cb(struct notifier_block *nb, |
| 211 | unsigned long event, void *data) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 212 | { |
| 213 | struct drm_device *drm_dev; |
| 214 | struct sti_compositor *compo = |
| 215 | container_of(nb, struct sti_compositor, vtg_vblank_nb); |
| 216 | int *crtc = data; |
| 217 | unsigned long flags; |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 218 | struct sti_private *priv; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 219 | |
| 220 | drm_dev = compo->mixer[*crtc]->drm_crtc.dev; |
| 221 | priv = drm_dev->dev_private; |
| 222 | |
| 223 | if ((event != VTG_TOP_FIELD_EVENT) && |
| 224 | (event != VTG_BOTTOM_FIELD_EVENT)) { |
| 225 | DRM_ERROR("unknown event: %lu\n", event); |
| 226 | return -EINVAL; |
| 227 | } |
| 228 | |
| 229 | drm_handle_vblank(drm_dev, *crtc); |
| 230 | |
| 231 | spin_lock_irqsave(&drm_dev->event_lock, flags); |
| 232 | if (compo->mixer[*crtc]->pending_event) { |
| 233 | drm_send_vblank_event(drm_dev, -1, |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 234 | compo->mixer[*crtc]->pending_event); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 235 | drm_vblank_put(drm_dev, *crtc); |
| 236 | compo->mixer[*crtc]->pending_event = NULL; |
| 237 | } |
| 238 | spin_unlock_irqrestore(&drm_dev->event_lock, flags); |
| 239 | |
| 240 | return 0; |
| 241 | } |
| 242 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 243 | int sti_crtc_enable_vblank(struct drm_device *dev, int crtc) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 244 | { |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 245 | struct sti_private *dev_priv = dev->dev_private; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 246 | struct sti_compositor *compo = dev_priv->compo; |
| 247 | struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; |
| 248 | |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 249 | DRM_DEBUG_DRIVER("\n"); |
| 250 | |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 251 | if (sti_vtg_register_client(crtc == STI_MIXER_MAIN ? |
| 252 | compo->vtg_main : compo->vtg_aux, |
| 253 | vtg_vblank_nb, crtc)) { |
| 254 | DRM_ERROR("Cannot register VTG notifier\n"); |
| 255 | return -EINVAL; |
| 256 | } |
| 257 | |
| 258 | return 0; |
| 259 | } |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 260 | EXPORT_SYMBOL(sti_crtc_enable_vblank); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 261 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 262 | void sti_crtc_disable_vblank(struct drm_device *dev, int crtc) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 263 | { |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 264 | struct sti_private *priv = dev->dev_private; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 265 | struct sti_compositor *compo = priv->compo; |
| 266 | struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 267 | |
| 268 | DRM_DEBUG_DRIVER("\n"); |
| 269 | |
| 270 | if (sti_vtg_unregister_client(crtc == STI_MIXER_MAIN ? |
| 271 | compo->vtg_main : compo->vtg_aux, vtg_vblank_nb)) |
| 272 | DRM_DEBUG_DRIVER("Warning: cannot unregister VTG notifier\n"); |
| 273 | |
| 274 | /* free the resources of the pending requests */ |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 275 | if (compo->mixer[crtc]->pending_event) { |
| 276 | drm_vblank_put(dev, crtc); |
| 277 | compo->mixer[crtc]->pending_event = NULL; |
| 278 | } |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 279 | } |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 280 | EXPORT_SYMBOL(sti_crtc_disable_vblank); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 281 | |
| 282 | static struct drm_crtc_funcs sti_crtc_funcs = { |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 283 | .set_config = drm_atomic_helper_set_config, |
| 284 | .page_flip = drm_atomic_helper_page_flip, |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 285 | .destroy = sti_crtc_destroy, |
| 286 | .set_property = sti_crtc_set_property, |
Benjamin Gaignard | de4b00b | 2015-03-19 13:35:16 +0100 | [diff] [blame] | 287 | .reset = drm_atomic_helper_crtc_reset, |
| 288 | .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, |
| 289 | .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 290 | }; |
| 291 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 292 | bool sti_crtc_is_main(struct drm_crtc *crtc) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 293 | { |
| 294 | struct sti_mixer *mixer = to_sti_mixer(crtc); |
| 295 | |
| 296 | if (mixer->id == STI_MIXER_MAIN) |
| 297 | return true; |
| 298 | |
| 299 | return false; |
| 300 | } |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 301 | EXPORT_SYMBOL(sti_crtc_is_main); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 302 | |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 303 | int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer, |
| 304 | struct drm_plane *primary, struct drm_plane *cursor) |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 305 | { |
| 306 | struct drm_crtc *crtc = &mixer->drm_crtc; |
| 307 | int res; |
| 308 | |
| 309 | res = drm_crtc_init_with_planes(drm_dev, crtc, primary, cursor, |
Vincent Abriou | 9e1f05b | 2015-07-31 11:32:34 +0200 | [diff] [blame^] | 310 | &sti_crtc_funcs); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 311 | if (res) { |
Vincent Abriou | 871bcdf | 2015-07-31 11:32:13 +0200 | [diff] [blame] | 312 | DRM_ERROR("Can't initialze CRTC\n"); |
Benjamin Gaignard | 9bbf86f | 2014-07-31 09:39:11 +0200 | [diff] [blame] | 313 | return -EINVAL; |
| 314 | } |
| 315 | |
| 316 | drm_crtc_helper_add(crtc, &sti_crtc_helper_funcs); |
| 317 | |
| 318 | DRM_DEBUG_DRIVER("drm CRTC:%d mapped to %s\n", |
| 319 | crtc->base.id, sti_mixer_to_str(mixer)); |
| 320 | |
| 321 | return 0; |
| 322 | } |