Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 1 | /* |
Rob Clark | 8bb0daf | 2013-02-11 12:43:09 -0500 | [diff] [blame] | 2 | * drivers/gpu/drm/omapdrm/omap_drv.c |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2011 Texas Instruments |
| 5 | * Author: Rob Clark <rob@ti.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published by |
| 9 | * the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | * more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "omap_drv.h" |
| 21 | |
| 22 | #include "drm_crtc_helper.h" |
| 23 | #include "drm_fb_helper.h" |
Andy Gross | 5c13779 | 2012-03-05 10:48:39 -0600 | [diff] [blame] | 24 | #include "omap_dmm_tiler.h" |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 25 | |
| 26 | #define DRIVER_NAME MODULE_NAME |
| 27 | #define DRIVER_DESC "OMAP DRM" |
| 28 | #define DRIVER_DATE "20110917" |
| 29 | #define DRIVER_MAJOR 1 |
| 30 | #define DRIVER_MINOR 0 |
| 31 | #define DRIVER_PATCHLEVEL 0 |
| 32 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 33 | static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS; |
| 34 | |
| 35 | MODULE_PARM_DESC(num_crtc, "Number of overlays to use as CRTCs"); |
| 36 | module_param(num_crtc, int, 0600); |
| 37 | |
| 38 | /* |
| 39 | * mode config funcs |
| 40 | */ |
| 41 | |
| 42 | /* Notes about mapping DSS and DRM entities: |
| 43 | * CRTC: overlay |
| 44 | * encoder: manager.. with some extension to allow one primary CRTC |
| 45 | * and zero or more video CRTC's to be mapped to one encoder? |
| 46 | * connector: dssdev.. manager can be attached/detached from different |
| 47 | * devices |
| 48 | */ |
| 49 | |
| 50 | static void omap_fb_output_poll_changed(struct drm_device *dev) |
| 51 | { |
| 52 | struct omap_drm_private *priv = dev->dev_private; |
| 53 | DBG("dev=%p", dev); |
YAMANE Toshiaki | c7f904b | 2012-11-14 19:30:38 +0900 | [diff] [blame] | 54 | if (priv->fbdev) |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 55 | drm_fb_helper_hotplug_event(priv->fbdev); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 56 | } |
| 57 | |
Laurent Pinchart | e6ecefa | 2012-05-17 13:27:23 +0200 | [diff] [blame] | 58 | static const struct drm_mode_config_funcs omap_mode_config_funcs = { |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 59 | .fb_create = omap_framebuffer_create, |
| 60 | .output_poll_changed = omap_fb_output_poll_changed, |
| 61 | }; |
| 62 | |
| 63 | static int get_connector_type(struct omap_dss_device *dssdev) |
| 64 | { |
| 65 | switch (dssdev->type) { |
| 66 | case OMAP_DISPLAY_TYPE_HDMI: |
| 67 | return DRM_MODE_CONNECTOR_HDMIA; |
Tomi Valkeinen | 4635c17 | 2013-05-14 14:14:15 +0300 | [diff] [blame] | 68 | case OMAP_DISPLAY_TYPE_DVI: |
| 69 | return DRM_MODE_CONNECTOR_DVID; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 70 | default: |
| 71 | return DRM_MODE_CONNECTOR_Unknown; |
| 72 | } |
| 73 | } |
| 74 | |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 75 | static bool channel_used(struct drm_device *dev, enum omap_channel channel) |
| 76 | { |
| 77 | struct omap_drm_private *priv = dev->dev_private; |
| 78 | int i; |
| 79 | |
| 80 | for (i = 0; i < priv->num_crtcs; i++) { |
| 81 | struct drm_crtc *crtc = priv->crtcs[i]; |
| 82 | |
| 83 | if (omap_crtc_channel(crtc) == channel) |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | return false; |
| 88 | } |
Archit Taneja | cc823bd | 2014-01-02 14:49:52 +0530 | [diff] [blame] | 89 | static void omap_disconnect_dssdevs(void) |
| 90 | { |
| 91 | struct omap_dss_device *dssdev = NULL; |
| 92 | |
| 93 | for_each_dss_dev(dssdev) |
| 94 | dssdev->driver->disconnect(dssdev); |
| 95 | } |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 96 | |
Archit Taneja | 3a01ab2 | 2014-01-02 14:49:51 +0530 | [diff] [blame] | 97 | static int omap_connect_dssdevs(void) |
| 98 | { |
| 99 | int r; |
| 100 | struct omap_dss_device *dssdev = NULL; |
| 101 | bool no_displays = true; |
| 102 | |
| 103 | for_each_dss_dev(dssdev) { |
| 104 | r = dssdev->driver->connect(dssdev); |
| 105 | if (r == -EPROBE_DEFER) { |
| 106 | omap_dss_put_device(dssdev); |
| 107 | goto cleanup; |
| 108 | } else if (r) { |
| 109 | dev_warn(dssdev->dev, "could not connect display: %s\n", |
| 110 | dssdev->name); |
| 111 | } else { |
| 112 | no_displays = false; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | if (no_displays) |
| 117 | return -EPROBE_DEFER; |
| 118 | |
| 119 | return 0; |
| 120 | |
| 121 | cleanup: |
| 122 | /* |
| 123 | * if we are deferring probe, we disconnect the devices we previously |
| 124 | * connected |
| 125 | */ |
Archit Taneja | cc823bd | 2014-01-02 14:49:52 +0530 | [diff] [blame] | 126 | omap_disconnect_dssdevs(); |
Archit Taneja | 3a01ab2 | 2014-01-02 14:49:51 +0530 | [diff] [blame] | 127 | |
| 128 | return r; |
| 129 | } |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 130 | |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 131 | static int omap_modeset_create_crtc(struct drm_device *dev, int id, |
| 132 | enum omap_channel channel) |
| 133 | { |
| 134 | struct omap_drm_private *priv = dev->dev_private; |
| 135 | struct drm_plane *plane; |
| 136 | struct drm_crtc *crtc; |
| 137 | |
Laurent Pinchart | ef6b0e0 | 2015-01-11 00:11:18 +0200 | [diff] [blame] | 138 | plane = omap_plane_init(dev, id, DRM_PLANE_TYPE_PRIMARY); |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 139 | if (IS_ERR(plane)) |
| 140 | return PTR_ERR(plane); |
| 141 | |
| 142 | crtc = omap_crtc_init(dev, plane, channel, id); |
| 143 | |
| 144 | BUG_ON(priv->num_crtcs >= ARRAY_SIZE(priv->crtcs)); |
| 145 | priv->crtcs[id] = crtc; |
| 146 | priv->num_crtcs++; |
| 147 | |
| 148 | priv->planes[id] = plane; |
| 149 | priv->num_planes++; |
| 150 | |
| 151 | return 0; |
| 152 | } |
| 153 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 154 | static int omap_modeset_init(struct drm_device *dev) |
| 155 | { |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 156 | struct omap_drm_private *priv = dev->dev_private; |
| 157 | struct omap_dss_device *dssdev = NULL; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 158 | int num_ovls = dss_feat_get_num_ovls(); |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 159 | int num_mgrs = dss_feat_get_num_mgrs(); |
| 160 | int num_crtcs; |
| 161 | int i, id = 0; |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 162 | int ret; |
Tomi Valkeinen | 04b1fc0 | 2013-05-14 10:55:19 +0300 | [diff] [blame] | 163 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 164 | drm_mode_config_init(dev); |
| 165 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 166 | omap_drm_irq_install(dev); |
Andy Gross | 71e8831 | 2011-12-05 19:19:21 -0600 | [diff] [blame] | 167 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 168 | /* |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 169 | * We usually don't want to create a CRTC for each manager, at least |
| 170 | * not until we have a way to expose private planes to userspace. |
| 171 | * Otherwise there would not be enough video pipes left for drm planes. |
| 172 | * We use the num_crtc argument to limit the number of crtcs we create. |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 173 | */ |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 174 | num_crtcs = min3(num_crtc, num_mgrs, num_ovls); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 175 | |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 176 | dssdev = NULL; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 177 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 178 | for_each_dss_dev(dssdev) { |
| 179 | struct drm_connector *connector; |
| 180 | struct drm_encoder *encoder; |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 181 | enum omap_channel channel; |
Tomi Valkeinen | a7e71e7 | 2013-05-08 16:23:32 +0300 | [diff] [blame] | 182 | struct omap_overlay_manager *mgr; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 183 | |
Archit Taneja | 3a01ab2 | 2014-01-02 14:49:51 +0530 | [diff] [blame] | 184 | if (!omapdss_device_is_connected(dssdev)) |
Archit Taneja | 581382e | 2013-03-26 19:15:18 +0530 | [diff] [blame] | 185 | continue; |
Tomi Valkeinen | a7e71e7 | 2013-05-08 16:23:32 +0300 | [diff] [blame] | 186 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 187 | encoder = omap_encoder_init(dev, dssdev); |
| 188 | |
| 189 | if (!encoder) { |
| 190 | dev_err(dev->dev, "could not create encoder: %s\n", |
| 191 | dssdev->name); |
| 192 | return -ENOMEM; |
| 193 | } |
| 194 | |
| 195 | connector = omap_connector_init(dev, |
| 196 | get_connector_type(dssdev), dssdev, encoder); |
| 197 | |
| 198 | if (!connector) { |
| 199 | dev_err(dev->dev, "could not create connector: %s\n", |
| 200 | dssdev->name); |
| 201 | return -ENOMEM; |
| 202 | } |
| 203 | |
| 204 | BUG_ON(priv->num_encoders >= ARRAY_SIZE(priv->encoders)); |
| 205 | BUG_ON(priv->num_connectors >= ARRAY_SIZE(priv->connectors)); |
| 206 | |
| 207 | priv->encoders[priv->num_encoders++] = encoder; |
| 208 | priv->connectors[priv->num_connectors++] = connector; |
| 209 | |
| 210 | drm_mode_connector_attach_encoder(connector, encoder); |
| 211 | |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 212 | /* |
| 213 | * if we have reached the limit of the crtcs we are allowed to |
| 214 | * create, let's not try to look for a crtc for this |
| 215 | * panel/encoder and onwards, we will, of course, populate the |
| 216 | * the possible_crtcs field for all the encoders with the final |
| 217 | * set of crtcs we create |
| 218 | */ |
| 219 | if (id == num_crtcs) |
| 220 | continue; |
| 221 | |
| 222 | /* |
| 223 | * get the recommended DISPC channel for this encoder. For now, |
| 224 | * we only try to get create a crtc out of the recommended, the |
| 225 | * other possible channels to which the encoder can connect are |
| 226 | * not considered. |
| 227 | */ |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 228 | |
Tomi Valkeinen | a7e71e7 | 2013-05-08 16:23:32 +0300 | [diff] [blame] | 229 | mgr = omapdss_find_mgr_from_display(dssdev); |
| 230 | channel = mgr->id; |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 231 | /* |
| 232 | * if this channel hasn't already been taken by a previously |
| 233 | * allocated crtc, we create a new crtc for it |
| 234 | */ |
| 235 | if (!channel_used(dev, channel)) { |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 236 | ret = omap_modeset_create_crtc(dev, id, channel); |
| 237 | if (ret < 0) { |
| 238 | dev_err(dev->dev, |
| 239 | "could not create CRTC (channel %u)\n", |
| 240 | channel); |
| 241 | return ret; |
| 242 | } |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 243 | |
| 244 | id++; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | /* |
| 249 | * we have allocated crtcs according to the need of the panels/encoders, |
| 250 | * adding more crtcs here if needed |
| 251 | */ |
| 252 | for (; id < num_crtcs; id++) { |
| 253 | |
| 254 | /* find a free manager for this crtc */ |
| 255 | for (i = 0; i < num_mgrs; i++) { |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 256 | if (!channel_used(dev, i)) |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 257 | break; |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | if (i == num_mgrs) { |
| 261 | /* this shouldn't really happen */ |
| 262 | dev_err(dev->dev, "no managers left for crtc\n"); |
| 263 | return -ENOMEM; |
| 264 | } |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 265 | |
| 266 | ret = omap_modeset_create_crtc(dev, id, i); |
| 267 | if (ret < 0) { |
| 268 | dev_err(dev->dev, |
| 269 | "could not create CRTC (channel %u)\n", i); |
| 270 | return ret; |
| 271 | } |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /* |
| 275 | * Create normal planes for the remaining overlays: |
| 276 | */ |
| 277 | for (; id < num_ovls; id++) { |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 278 | struct drm_plane *plane; |
| 279 | |
Laurent Pinchart | ef6b0e0 | 2015-01-11 00:11:18 +0200 | [diff] [blame] | 280 | plane = omap_plane_init(dev, id, DRM_PLANE_TYPE_OVERLAY); |
Laurent Pinchart | fb9a35f | 2015-01-11 16:30:44 +0200 | [diff] [blame] | 281 | if (IS_ERR(plane)) |
| 282 | return PTR_ERR(plane); |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 283 | |
| 284 | BUG_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)); |
| 285 | priv->planes[priv->num_planes++] = plane; |
| 286 | } |
| 287 | |
| 288 | for (i = 0; i < priv->num_encoders; i++) { |
| 289 | struct drm_encoder *encoder = priv->encoders[i]; |
| 290 | struct omap_dss_device *dssdev = |
| 291 | omap_encoder_get_dssdev(encoder); |
Tomi Valkeinen | 1f68d9c | 2013-04-19 15:09:34 +0300 | [diff] [blame] | 292 | struct omap_dss_device *output; |
Tomi Valkeinen | be8e8e1 | 2013-04-23 15:35:35 +0300 | [diff] [blame] | 293 | |
| 294 | output = omapdss_find_output_from_display(dssdev); |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 295 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 296 | /* figure out which crtc's we can connect the encoder to: */ |
| 297 | encoder->possible_crtcs = 0; |
| 298 | for (id = 0; id < priv->num_crtcs; id++) { |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 299 | struct drm_crtc *crtc = priv->crtcs[id]; |
| 300 | enum omap_channel crtc_channel; |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 301 | |
| 302 | crtc_channel = omap_crtc_channel(crtc); |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 303 | |
Tomi Valkeinen | 1733729 | 2014-09-03 19:25:49 +0000 | [diff] [blame] | 304 | if (output->dispc_channel == crtc_channel) { |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 305 | encoder->possible_crtcs |= (1 << id); |
Tomi Valkeinen | 1733729 | 2014-09-03 19:25:49 +0000 | [diff] [blame] | 306 | break; |
| 307 | } |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 308 | } |
Tomi Valkeinen | 820caab | 2013-04-25 14:53:18 +0300 | [diff] [blame] | 309 | |
| 310 | omap_dss_put_device(output); |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 311 | } |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 312 | |
Archit Taneja | 0d8f371 | 2013-03-26 19:15:19 +0530 | [diff] [blame] | 313 | DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n", |
| 314 | priv->num_planes, priv->num_crtcs, priv->num_encoders, |
| 315 | priv->num_connectors); |
| 316 | |
Rob Clark | 6b8ca4c | 2012-01-08 19:37:37 -0600 | [diff] [blame] | 317 | dev->mode_config.min_width = 32; |
| 318 | dev->mode_config.min_height = 32; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 319 | |
| 320 | /* note: eventually will need some cpu_is_omapXYZ() type stuff here |
| 321 | * to fill in these limits properly on different OMAP generations.. |
| 322 | */ |
| 323 | dev->mode_config.max_width = 2048; |
| 324 | dev->mode_config.max_height = 2048; |
| 325 | |
| 326 | dev->mode_config.funcs = &omap_mode_config_funcs; |
| 327 | |
| 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | static void omap_modeset_free(struct drm_device *dev) |
| 332 | { |
| 333 | drm_mode_config_cleanup(dev); |
| 334 | } |
| 335 | |
| 336 | /* |
| 337 | * drm ioctl funcs |
| 338 | */ |
| 339 | |
| 340 | |
| 341 | static int ioctl_get_param(struct drm_device *dev, void *data, |
| 342 | struct drm_file *file_priv) |
| 343 | { |
Rob Clark | 5e3b087 | 2012-10-29 09:31:12 +0100 | [diff] [blame] | 344 | struct omap_drm_private *priv = dev->dev_private; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 345 | struct drm_omap_param *args = data; |
| 346 | |
| 347 | DBG("%p: param=%llu", dev, args->param); |
| 348 | |
| 349 | switch (args->param) { |
| 350 | case OMAP_PARAM_CHIPSET_ID: |
Rob Clark | 5e3b087 | 2012-10-29 09:31:12 +0100 | [diff] [blame] | 351 | args->value = priv->omaprev; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 352 | break; |
| 353 | default: |
| 354 | DBG("unknown parameter %lld", args->param); |
| 355 | return -EINVAL; |
| 356 | } |
| 357 | |
| 358 | return 0; |
| 359 | } |
| 360 | |
| 361 | static int ioctl_set_param(struct drm_device *dev, void *data, |
| 362 | struct drm_file *file_priv) |
| 363 | { |
| 364 | struct drm_omap_param *args = data; |
| 365 | |
| 366 | switch (args->param) { |
| 367 | default: |
| 368 | DBG("unknown parameter %lld", args->param); |
| 369 | return -EINVAL; |
| 370 | } |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | static int ioctl_gem_new(struct drm_device *dev, void *data, |
| 376 | struct drm_file *file_priv) |
| 377 | { |
| 378 | struct drm_omap_gem_new *args = data; |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 379 | VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv, |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 380 | args->size.bytes, args->flags); |
| 381 | return omap_gem_new_handle(dev, file_priv, args->size, |
| 382 | args->flags, &args->handle); |
| 383 | } |
| 384 | |
| 385 | static int ioctl_gem_cpu_prep(struct drm_device *dev, void *data, |
| 386 | struct drm_file *file_priv) |
| 387 | { |
| 388 | struct drm_omap_gem_cpu_prep *args = data; |
| 389 | struct drm_gem_object *obj; |
| 390 | int ret; |
| 391 | |
| 392 | VERB("%p:%p: handle=%d, op=%x", dev, file_priv, args->handle, args->op); |
| 393 | |
| 394 | obj = drm_gem_object_lookup(dev, file_priv, args->handle); |
YAMANE Toshiaki | c7f904b | 2012-11-14 19:30:38 +0900 | [diff] [blame] | 395 | if (!obj) |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 396 | return -ENOENT; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 397 | |
| 398 | ret = omap_gem_op_sync(obj, args->op); |
| 399 | |
YAMANE Toshiaki | c7f904b | 2012-11-14 19:30:38 +0900 | [diff] [blame] | 400 | if (!ret) |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 401 | ret = omap_gem_op_start(obj, args->op); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 402 | |
| 403 | drm_gem_object_unreference_unlocked(obj); |
| 404 | |
| 405 | return ret; |
| 406 | } |
| 407 | |
| 408 | static int ioctl_gem_cpu_fini(struct drm_device *dev, void *data, |
| 409 | struct drm_file *file_priv) |
| 410 | { |
| 411 | struct drm_omap_gem_cpu_fini *args = data; |
| 412 | struct drm_gem_object *obj; |
| 413 | int ret; |
| 414 | |
| 415 | VERB("%p:%p: handle=%d", dev, file_priv, args->handle); |
| 416 | |
| 417 | obj = drm_gem_object_lookup(dev, file_priv, args->handle); |
YAMANE Toshiaki | c7f904b | 2012-11-14 19:30:38 +0900 | [diff] [blame] | 418 | if (!obj) |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 419 | return -ENOENT; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 420 | |
| 421 | /* XXX flushy, flushy */ |
| 422 | ret = 0; |
| 423 | |
YAMANE Toshiaki | c7f904b | 2012-11-14 19:30:38 +0900 | [diff] [blame] | 424 | if (!ret) |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 425 | ret = omap_gem_op_finish(obj, args->op); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 426 | |
| 427 | drm_gem_object_unreference_unlocked(obj); |
| 428 | |
| 429 | return ret; |
| 430 | } |
| 431 | |
| 432 | static int ioctl_gem_info(struct drm_device *dev, void *data, |
| 433 | struct drm_file *file_priv) |
| 434 | { |
| 435 | struct drm_omap_gem_info *args = data; |
| 436 | struct drm_gem_object *obj; |
| 437 | int ret = 0; |
| 438 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 439 | VERB("%p:%p: handle=%d", dev, file_priv, args->handle); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 440 | |
| 441 | obj = drm_gem_object_lookup(dev, file_priv, args->handle); |
YAMANE Toshiaki | c7f904b | 2012-11-14 19:30:38 +0900 | [diff] [blame] | 442 | if (!obj) |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 443 | return -ENOENT; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 444 | |
Rob Clark | f7f9f45 | 2011-12-05 19:19:22 -0600 | [diff] [blame] | 445 | args->size = omap_gem_mmap_size(obj); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 446 | args->offset = omap_gem_mmap_offset(obj); |
| 447 | |
| 448 | drm_gem_object_unreference_unlocked(obj); |
| 449 | |
| 450 | return ret; |
| 451 | } |
| 452 | |
Rob Clark | baa7094 | 2013-08-02 13:27:49 -0400 | [diff] [blame] | 453 | static const struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = { |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 454 | DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, DRM_UNLOCKED|DRM_AUTH), |
| 455 | DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 456 | DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, DRM_UNLOCKED|DRM_AUTH), |
| 457 | DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, DRM_UNLOCKED|DRM_AUTH), |
| 458 | DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, DRM_UNLOCKED|DRM_AUTH), |
| 459 | DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, DRM_UNLOCKED|DRM_AUTH), |
| 460 | }; |
| 461 | |
| 462 | /* |
| 463 | * drm driver funcs |
| 464 | */ |
| 465 | |
| 466 | /** |
| 467 | * load - setup chip and create an initial config |
| 468 | * @dev: DRM device |
| 469 | * @flags: startup flags |
| 470 | * |
| 471 | * The driver load routine has to do several things: |
| 472 | * - initialize the memory manager |
| 473 | * - allocate initial config memory |
| 474 | * - setup the DRM framebuffer with the allocated memory |
| 475 | */ |
| 476 | static int dev_load(struct drm_device *dev, unsigned long flags) |
| 477 | { |
Rob Clark | 5e3b087 | 2012-10-29 09:31:12 +0100 | [diff] [blame] | 478 | struct omap_drm_platform_data *pdata = dev->dev->platform_data; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 479 | struct omap_drm_private *priv; |
| 480 | int ret; |
| 481 | |
| 482 | DBG("load: dev=%p", dev); |
| 483 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 484 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
Joe Perches | 78110bb | 2013-02-11 09:41:29 -0800 | [diff] [blame] | 485 | if (!priv) |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 486 | return -ENOMEM; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 487 | |
Rob Clark | 5e3b087 | 2012-10-29 09:31:12 +0100 | [diff] [blame] | 488 | priv->omaprev = pdata->omaprev; |
| 489 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 490 | dev->dev_private = priv; |
| 491 | |
Tejun Heo | 4619cdb | 2012-08-22 16:49:44 -0700 | [diff] [blame] | 492 | priv->wq = alloc_ordered_workqueue("omapdrm", 0); |
Rob Clark | 5609f7f | 2012-03-05 10:48:32 -0600 | [diff] [blame] | 493 | |
Rob Clark | f6b6036 | 2012-03-05 10:48:36 -0600 | [diff] [blame] | 494 | INIT_LIST_HEAD(&priv->obj_list); |
| 495 | |
Rob Clark | f7f9f45 | 2011-12-05 19:19:22 -0600 | [diff] [blame] | 496 | omap_gem_init(dev); |
| 497 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 498 | ret = omap_modeset_init(dev); |
| 499 | if (ret) { |
| 500 | dev_err(dev->dev, "omap_modeset_init failed: ret=%d\n", ret); |
| 501 | dev->dev_private = NULL; |
| 502 | kfree(priv); |
| 503 | return ret; |
| 504 | } |
| 505 | |
Rob Clark | f5f9454 | 2012-12-04 13:59:12 -0600 | [diff] [blame] | 506 | ret = drm_vblank_init(dev, priv->num_crtcs); |
| 507 | if (ret) |
| 508 | dev_warn(dev->dev, "could not init vblank\n"); |
| 509 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 510 | priv->fbdev = omap_fbdev_init(dev); |
| 511 | if (!priv->fbdev) { |
| 512 | dev_warn(dev->dev, "omap_fbdev_init failed\n"); |
| 513 | /* well, limp along without an fbdev.. maybe X11 will work? */ |
| 514 | } |
| 515 | |
Andy Gross | e78edba | 2012-12-19 14:53:37 -0600 | [diff] [blame] | 516 | /* store off drm_device for use in pm ops */ |
| 517 | dev_set_drvdata(dev->dev, dev); |
| 518 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 519 | drm_kms_helper_poll_init(dev); |
| 520 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | static int dev_unload(struct drm_device *dev) |
| 525 | { |
Rob Clark | 5609f7f | 2012-03-05 10:48:32 -0600 | [diff] [blame] | 526 | struct omap_drm_private *priv = dev->dev_private; |
Tomi Valkeinen | e2f8fd7 | 2014-04-02 14:31:57 +0300 | [diff] [blame] | 527 | int i; |
Rob Clark | 5609f7f | 2012-03-05 10:48:32 -0600 | [diff] [blame] | 528 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 529 | DBG("unload: dev=%p", dev); |
| 530 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 531 | drm_kms_helper_poll_fini(dev); |
| 532 | |
Tomi Valkeinen | c7c1aec | 2014-09-25 19:24:26 +0000 | [diff] [blame^] | 533 | if (priv->fbdev) |
| 534 | omap_fbdev_free(dev); |
Tomi Valkeinen | e2f8fd7 | 2014-04-02 14:31:57 +0300 | [diff] [blame] | 535 | |
| 536 | /* flush crtcs so the fbs get released */ |
| 537 | for (i = 0; i < priv->num_crtcs; i++) |
| 538 | omap_crtc_flush(priv->crtcs[i]); |
| 539 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 540 | omap_modeset_free(dev); |
Rob Clark | f7f9f45 | 2011-12-05 19:19:22 -0600 | [diff] [blame] | 541 | omap_gem_deinit(dev); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 542 | |
Rob Clark | 5609f7f | 2012-03-05 10:48:32 -0600 | [diff] [blame] | 543 | destroy_workqueue(priv->wq); |
| 544 | |
Archit Taneja | 80e4ed5 | 2014-01-02 14:49:54 +0530 | [diff] [blame] | 545 | drm_vblank_cleanup(dev); |
| 546 | omap_drm_irq_uninstall(dev); |
| 547 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 548 | kfree(dev->dev_private); |
| 549 | dev->dev_private = NULL; |
| 550 | |
Andy Gross | e78edba | 2012-12-19 14:53:37 -0600 | [diff] [blame] | 551 | dev_set_drvdata(dev->dev, NULL); |
| 552 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | static int dev_open(struct drm_device *dev, struct drm_file *file) |
| 557 | { |
| 558 | file->driver_priv = NULL; |
| 559 | |
| 560 | DBG("open: dev=%p, file=%p", dev, file); |
| 561 | |
| 562 | return 0; |
| 563 | } |
| 564 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 565 | /** |
| 566 | * lastclose - clean up after all DRM clients have exited |
| 567 | * @dev: DRM device |
| 568 | * |
| 569 | * Take care of cleaning up after all DRM clients have exited. In the |
| 570 | * mode setting case, we want to restore the kernel's initial mode (just |
| 571 | * in case the last client left us in a bad state). |
| 572 | */ |
| 573 | static void dev_lastclose(struct drm_device *dev) |
| 574 | { |
Rob Clark | 3c810c6 | 2012-08-15 15:18:01 -0500 | [diff] [blame] | 575 | int i; |
| 576 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 577 | /* we don't support vga-switcheroo.. so just make sure the fbdev |
| 578 | * mode is active |
| 579 | */ |
| 580 | struct omap_drm_private *priv = dev->dev_private; |
| 581 | int ret; |
| 582 | |
| 583 | DBG("lastclose: dev=%p", dev); |
| 584 | |
Rob Clark | c2a6a55 | 2012-10-25 17:14:13 -0500 | [diff] [blame] | 585 | if (priv->rotation_prop) { |
| 586 | /* need to restore default rotation state.. not sure |
| 587 | * if there is a cleaner way to restore properties to |
| 588 | * default state? Maybe a flag that properties should |
| 589 | * automatically be restored to default state on |
| 590 | * lastclose? |
| 591 | */ |
| 592 | for (i = 0; i < priv->num_crtcs; i++) { |
| 593 | drm_object_property_set_value(&priv->crtcs[i]->base, |
| 594 | priv->rotation_prop, 0); |
| 595 | } |
Rob Clark | 3c810c6 | 2012-08-15 15:18:01 -0500 | [diff] [blame] | 596 | |
Rob Clark | c2a6a55 | 2012-10-25 17:14:13 -0500 | [diff] [blame] | 597 | for (i = 0; i < priv->num_planes; i++) { |
| 598 | drm_object_property_set_value(&priv->planes[i]->base, |
| 599 | priv->rotation_prop, 0); |
| 600 | } |
Rob Clark | 3c810c6 | 2012-08-15 15:18:01 -0500 | [diff] [blame] | 601 | } |
| 602 | |
Tomi Valkeinen | c7c1aec | 2014-09-25 19:24:26 +0000 | [diff] [blame^] | 603 | if (priv->fbdev) { |
| 604 | ret = drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev); |
| 605 | if (ret) |
| 606 | DBG("failed to restore crtc mode"); |
| 607 | } |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | static void dev_preclose(struct drm_device *dev, struct drm_file *file) |
| 611 | { |
| 612 | DBG("preclose: dev=%p", dev); |
| 613 | } |
| 614 | |
| 615 | static void dev_postclose(struct drm_device *dev, struct drm_file *file) |
| 616 | { |
| 617 | DBG("postclose: dev=%p, file=%p", dev, file); |
| 618 | } |
| 619 | |
Laurent Pinchart | 78b6855 | 2012-05-17 13:27:22 +0200 | [diff] [blame] | 620 | static const struct vm_operations_struct omap_gem_vm_ops = { |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 621 | .fault = omap_gem_fault, |
| 622 | .open = drm_gem_vm_open, |
| 623 | .close = drm_gem_vm_close, |
| 624 | }; |
| 625 | |
Rob Clark | ff4f387 | 2012-01-16 12:51:14 -0600 | [diff] [blame] | 626 | static const struct file_operations omapdriver_fops = { |
Laurent Pinchart | 222025e | 2015-01-11 00:02:07 +0200 | [diff] [blame] | 627 | .owner = THIS_MODULE, |
| 628 | .open = drm_open, |
| 629 | .unlocked_ioctl = drm_ioctl, |
| 630 | .release = drm_release, |
| 631 | .mmap = omap_gem_mmap, |
| 632 | .poll = drm_poll, |
| 633 | .read = drm_read, |
| 634 | .llseek = noop_llseek, |
Rob Clark | ff4f387 | 2012-01-16 12:51:14 -0600 | [diff] [blame] | 635 | }; |
| 636 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 637 | static struct drm_driver omap_drm_driver = { |
Laurent Pinchart | 222025e | 2015-01-11 00:02:07 +0200 | [diff] [blame] | 638 | .driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM |
| 639 | | DRIVER_PRIME, |
| 640 | .load = dev_load, |
| 641 | .unload = dev_unload, |
| 642 | .open = dev_open, |
| 643 | .lastclose = dev_lastclose, |
| 644 | .preclose = dev_preclose, |
| 645 | .postclose = dev_postclose, |
| 646 | .set_busid = drm_platform_set_busid, |
| 647 | .get_vblank_counter = drm_vblank_count, |
| 648 | .enable_vblank = omap_irq_enable_vblank, |
| 649 | .disable_vblank = omap_irq_disable_vblank, |
| 650 | .irq_preinstall = omap_irq_preinstall, |
| 651 | .irq_postinstall = omap_irq_postinstall, |
| 652 | .irq_uninstall = omap_irq_uninstall, |
| 653 | .irq_handler = omap_irq_handler, |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 654 | #ifdef CONFIG_DEBUG_FS |
Laurent Pinchart | 222025e | 2015-01-11 00:02:07 +0200 | [diff] [blame] | 655 | .debugfs_init = omap_debugfs_init, |
| 656 | .debugfs_cleanup = omap_debugfs_cleanup, |
Andy Gross | 6169a148 | 2011-12-15 21:05:17 -0600 | [diff] [blame] | 657 | #endif |
Laurent Pinchart | 222025e | 2015-01-11 00:02:07 +0200 | [diff] [blame] | 658 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
| 659 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
| 660 | .gem_prime_export = omap_gem_prime_export, |
| 661 | .gem_prime_import = omap_gem_prime_import, |
| 662 | .gem_free_object = omap_gem_free_object, |
| 663 | .gem_vm_ops = &omap_gem_vm_ops, |
| 664 | .dumb_create = omap_gem_dumb_create, |
| 665 | .dumb_map_offset = omap_gem_dumb_map_offset, |
| 666 | .dumb_destroy = drm_gem_dumb_destroy, |
| 667 | .ioctls = ioctls, |
| 668 | .num_ioctls = DRM_OMAP_NUM_IOCTLS, |
| 669 | .fops = &omapdriver_fops, |
| 670 | .name = DRIVER_NAME, |
| 671 | .desc = DRIVER_DESC, |
| 672 | .date = DRIVER_DATE, |
| 673 | .major = DRIVER_MAJOR, |
| 674 | .minor = DRIVER_MINOR, |
| 675 | .patchlevel = DRIVER_PATCHLEVEL, |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 676 | }; |
| 677 | |
| 678 | static int pdev_suspend(struct platform_device *pDevice, pm_message_t state) |
| 679 | { |
| 680 | DBG(""); |
| 681 | return 0; |
| 682 | } |
| 683 | |
| 684 | static int pdev_resume(struct platform_device *device) |
| 685 | { |
| 686 | DBG(""); |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | static void pdev_shutdown(struct platform_device *device) |
| 691 | { |
| 692 | DBG(""); |
| 693 | } |
| 694 | |
| 695 | static int pdev_probe(struct platform_device *device) |
| 696 | { |
Archit Taneja | 3a01ab2 | 2014-01-02 14:49:51 +0530 | [diff] [blame] | 697 | int r; |
| 698 | |
Tomi Valkeinen | 591a0ac | 2013-05-23 12:07:50 +0300 | [diff] [blame] | 699 | if (omapdss_is_initialized() == false) |
| 700 | return -EPROBE_DEFER; |
| 701 | |
Archit Taneja | 3a01ab2 | 2014-01-02 14:49:51 +0530 | [diff] [blame] | 702 | omap_crtc_pre_init(); |
| 703 | |
| 704 | r = omap_connect_dssdevs(); |
| 705 | if (r) { |
| 706 | omap_crtc_pre_uninit(); |
| 707 | return r; |
| 708 | } |
| 709 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 710 | DBG("%s", device->name); |
| 711 | return drm_platform_init(&omap_drm_driver, device); |
| 712 | } |
| 713 | |
| 714 | static int pdev_remove(struct platform_device *device) |
| 715 | { |
| 716 | DBG(""); |
Andy Gross | 5c13779 | 2012-03-05 10:48:39 -0600 | [diff] [blame] | 717 | |
Tomi Valkeinen | 707cf58 | 2014-04-02 13:47:43 +0300 | [diff] [blame] | 718 | drm_put_dev(platform_get_drvdata(device)); |
| 719 | |
Archit Taneja | cc823bd | 2014-01-02 14:49:52 +0530 | [diff] [blame] | 720 | omap_disconnect_dssdevs(); |
| 721 | omap_crtc_pre_uninit(); |
Daniel Vetter | fd3c025 | 2013-12-11 11:34:26 +0100 | [diff] [blame] | 722 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 723 | return 0; |
| 724 | } |
| 725 | |
Andy Gross | e78edba | 2012-12-19 14:53:37 -0600 | [diff] [blame] | 726 | #ifdef CONFIG_PM |
| 727 | static const struct dev_pm_ops omapdrm_pm_ops = { |
| 728 | .resume = omap_gem_resume, |
| 729 | }; |
| 730 | #endif |
| 731 | |
Tomi Valkeinen | 6717cd2 | 2013-04-10 10:44:00 +0300 | [diff] [blame] | 732 | static struct platform_driver pdev = { |
Laurent Pinchart | 222025e | 2015-01-11 00:02:07 +0200 | [diff] [blame] | 733 | .driver = { |
| 734 | .name = DRIVER_NAME, |
Andy Gross | e78edba | 2012-12-19 14:53:37 -0600 | [diff] [blame] | 735 | #ifdef CONFIG_PM |
Laurent Pinchart | 222025e | 2015-01-11 00:02:07 +0200 | [diff] [blame] | 736 | .pm = &omapdrm_pm_ops, |
Andy Gross | e78edba | 2012-12-19 14:53:37 -0600 | [diff] [blame] | 737 | #endif |
Laurent Pinchart | 222025e | 2015-01-11 00:02:07 +0200 | [diff] [blame] | 738 | }, |
| 739 | .probe = pdev_probe, |
| 740 | .remove = pdev_remove, |
| 741 | .suspend = pdev_suspend, |
| 742 | .resume = pdev_resume, |
| 743 | .shutdown = pdev_shutdown, |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 744 | }; |
| 745 | |
| 746 | static int __init omap_drm_init(void) |
| 747 | { |
Tomi Valkeinen | ea7e3a6 | 2014-04-02 14:31:50 +0300 | [diff] [blame] | 748 | int r; |
| 749 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 750 | DBG("init"); |
Tomi Valkeinen | ea7e3a6 | 2014-04-02 14:31:50 +0300 | [diff] [blame] | 751 | |
| 752 | r = platform_driver_register(&omap_dmm_driver); |
| 753 | if (r) { |
| 754 | pr_err("DMM driver registration failed\n"); |
| 755 | return r; |
Rob Clark | be0775a | 2012-04-05 10:34:56 -0500 | [diff] [blame] | 756 | } |
Tomi Valkeinen | ea7e3a6 | 2014-04-02 14:31:50 +0300 | [diff] [blame] | 757 | |
| 758 | r = platform_driver_register(&pdev); |
| 759 | if (r) { |
| 760 | pr_err("omapdrm driver registration failed\n"); |
| 761 | platform_driver_unregister(&omap_dmm_driver); |
| 762 | return r; |
| 763 | } |
| 764 | |
| 765 | return 0; |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | static void __exit omap_drm_fini(void) |
| 769 | { |
| 770 | DBG("fini"); |
Tomi Valkeinen | ea7e3a6 | 2014-04-02 14:31:50 +0300 | [diff] [blame] | 771 | |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 772 | platform_driver_unregister(&pdev); |
Tomi Valkeinen | ea7e3a6 | 2014-04-02 14:31:50 +0300 | [diff] [blame] | 773 | |
| 774 | platform_driver_unregister(&omap_dmm_driver); |
Rob Clark | cd5351f | 2011-11-12 12:09:40 -0600 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | /* need late_initcall() so we load after dss_driver's are loaded */ |
| 778 | late_initcall(omap_drm_init); |
| 779 | module_exit(omap_drm_fini); |
| 780 | |
| 781 | MODULE_AUTHOR("Rob Clark <rob@ti.com>"); |
| 782 | MODULE_DESCRIPTION("OMAP DRM Display Driver"); |
| 783 | MODULE_ALIAS("platform:" DRIVER_NAME); |
| 784 | MODULE_LICENSE("GPL v2"); |