Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 3 | * Authors: |
| 4 | * Inki Dae <inki.dae@samsung.com> |
| 5 | * Joonyoung Shim <jy0922.shim@samsung.com> |
| 6 | * Seung-Woo Kim <sw0312.kim@samsung.com> |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the "Software"), |
| 10 | * to deal in the Software without restriction, including without limitation |
| 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | * and/or sell copies of the Software, and to permit persons to whom the |
| 13 | * Software is furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice (including the next |
| 16 | * paragraph) shall be included in all copies or substantial portions of the |
| 17 | * Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 23 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 24 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 25 | * OTHER DEALINGS IN THE SOFTWARE. |
| 26 | */ |
| 27 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 28 | #include <drm/drmP.h> |
| 29 | #include <drm/drm_crtc_helper.h> |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 30 | |
| 31 | #include <drm/exynos_drm.h> |
| 32 | |
| 33 | #include "exynos_drm_drv.h" |
| 34 | #include "exynos_drm_crtc.h" |
Inki Dae | d081f56 | 2012-02-15 11:25:19 +0900 | [diff] [blame] | 35 | #include "exynos_drm_encoder.h" |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 36 | #include "exynos_drm_fbdev.h" |
| 37 | #include "exynos_drm_fb.h" |
| 38 | #include "exynos_drm_gem.h" |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 39 | #include "exynos_drm_plane.h" |
Inki Dae | b73d123 | 2012-03-21 10:55:26 +0900 | [diff] [blame] | 40 | #include "exynos_drm_vidi.h" |
Inki Dae | b2df26c | 2012-04-23 21:01:28 +0900 | [diff] [blame] | 41 | #include "exynos_drm_dmabuf.h" |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 42 | #include "exynos_drm_g2d.h" |
Eunchul Kim | cb471f14 | 2012-12-14 18:10:31 +0900 | [diff] [blame] | 43 | #include "exynos_drm_ipp.h" |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 44 | #include "exynos_drm_iommu.h" |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 45 | |
Inki Dae | 0edf993 | 2011-12-15 17:31:24 +0900 | [diff] [blame] | 46 | #define DRIVER_NAME "exynos" |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 47 | #define DRIVER_DESC "Samsung SoC DRM" |
| 48 | #define DRIVER_DATE "20110530" |
| 49 | #define DRIVER_MAJOR 1 |
| 50 | #define DRIVER_MINOR 0 |
| 51 | |
Inki Dae | 52c6881 | 2011-12-16 21:31:12 +0900 | [diff] [blame] | 52 | #define VBLANK_OFF_DELAY 50000 |
| 53 | |
Rahul Sharma | 422bd00 | 2012-10-16 05:50:12 +0530 | [diff] [blame] | 54 | /* platform device pointer for eynos drm device. */ |
| 55 | static struct platform_device *exynos_drm_pdev; |
| 56 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 57 | static int exynos_drm_load(struct drm_device *dev, unsigned long flags) |
| 58 | { |
| 59 | struct exynos_drm_private *private; |
| 60 | int ret; |
| 61 | int nr; |
| 62 | |
| 63 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 64 | |
| 65 | private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL); |
| 66 | if (!private) { |
| 67 | DRM_ERROR("failed to allocate private\n"); |
| 68 | return -ENOMEM; |
| 69 | } |
| 70 | |
| 71 | INIT_LIST_HEAD(&private->pageflip_event_list); |
| 72 | dev->dev_private = (void *)private; |
| 73 | |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 74 | /* |
| 75 | * create mapping to manage iommu table and set a pointer to iommu |
| 76 | * mapping structure to iommu_mapping of private data. |
| 77 | * also this iommu_mapping can be used to check if iommu is supported |
| 78 | * or not. |
| 79 | */ |
| 80 | ret = drm_create_iommu_mapping(dev); |
| 81 | if (ret < 0) { |
| 82 | DRM_ERROR("failed to create iommu mapping.\n"); |
| 83 | goto err_crtc; |
| 84 | } |
| 85 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 86 | drm_mode_config_init(dev); |
| 87 | |
Seung-Woo Kim | 7db3eba | 2011-10-18 16:58:05 +0900 | [diff] [blame] | 88 | /* init kms poll for handling hpd */ |
| 89 | drm_kms_helper_poll_init(dev); |
| 90 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 91 | exynos_drm_mode_config_init(dev); |
| 92 | |
| 93 | /* |
| 94 | * EXYNOS4 is enough to have two CRTCs and each crtc would be used |
| 95 | * without dependency of hardware. |
| 96 | */ |
| 97 | for (nr = 0; nr < MAX_CRTC; nr++) { |
| 98 | ret = exynos_drm_crtc_create(dev, nr); |
| 99 | if (ret) |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 100 | goto err_release_iommu_mapping; |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 101 | } |
| 102 | |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 103 | for (nr = 0; nr < MAX_PLANE; nr++) { |
Joonyoung Shim | b5d2eb3 | 2012-06-27 14:27:04 +0900 | [diff] [blame] | 104 | struct drm_plane *plane; |
| 105 | unsigned int possible_crtcs = (1 << MAX_CRTC) - 1; |
| 106 | |
| 107 | plane = exynos_plane_init(dev, possible_crtcs, false); |
| 108 | if (!plane) |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 109 | goto err_release_iommu_mapping; |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 110 | } |
| 111 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 112 | ret = drm_vblank_init(dev, MAX_CRTC); |
| 113 | if (ret) |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 114 | goto err_release_iommu_mapping; |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 115 | |
| 116 | /* |
| 117 | * probe sub drivers such as display controller and hdmi driver, |
| 118 | * that were registered at probe() of platform driver |
| 119 | * to the sub driver and create encoder and connector for them. |
| 120 | */ |
| 121 | ret = exynos_drm_device_register(dev); |
| 122 | if (ret) |
| 123 | goto err_vblank; |
| 124 | |
Inki Dae | d081f56 | 2012-02-15 11:25:19 +0900 | [diff] [blame] | 125 | /* setup possible_clones. */ |
| 126 | exynos_drm_encoder_setup(dev); |
| 127 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 128 | /* |
| 129 | * create and configure fb helper and also exynos specific |
| 130 | * fbdev object. |
| 131 | */ |
| 132 | ret = exynos_drm_fbdev_init(dev); |
| 133 | if (ret) { |
| 134 | DRM_ERROR("failed to initialize drm fbdev\n"); |
| 135 | goto err_drm_device; |
| 136 | } |
| 137 | |
Inki Dae | 52c6881 | 2011-12-16 21:31:12 +0900 | [diff] [blame] | 138 | drm_vblank_offdelay = VBLANK_OFF_DELAY; |
| 139 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 140 | return 0; |
| 141 | |
| 142 | err_drm_device: |
| 143 | exynos_drm_device_unregister(dev); |
| 144 | err_vblank: |
| 145 | drm_vblank_cleanup(dev); |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 146 | err_release_iommu_mapping: |
| 147 | drm_release_iommu_mapping(dev); |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 148 | err_crtc: |
| 149 | drm_mode_config_cleanup(dev); |
| 150 | kfree(private); |
| 151 | |
| 152 | return ret; |
| 153 | } |
| 154 | |
| 155 | static int exynos_drm_unload(struct drm_device *dev) |
| 156 | { |
| 157 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 158 | |
| 159 | exynos_drm_fbdev_fini(dev); |
| 160 | exynos_drm_device_unregister(dev); |
| 161 | drm_vblank_cleanup(dev); |
Seung-Woo Kim | 7db3eba | 2011-10-18 16:58:05 +0900 | [diff] [blame] | 162 | drm_kms_helper_poll_fini(dev); |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 163 | drm_mode_config_cleanup(dev); |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 164 | |
| 165 | drm_release_iommu_mapping(dev); |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 166 | kfree(dev->dev_private); |
| 167 | |
| 168 | dev->dev_private = NULL; |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
Joonyoung Shim | 9084f7b | 2012-03-16 18:47:09 +0900 | [diff] [blame] | 173 | static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) |
Inki Dae | ccf4d88 | 2011-10-14 13:29:51 +0900 | [diff] [blame] | 174 | { |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 175 | struct drm_exynos_file_private *file_priv; |
| 176 | |
Joonyoung Shim | 6f81150 | 2012-02-15 11:25:18 +0900 | [diff] [blame] | 177 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
Inki Dae | ccf4d88 | 2011-10-14 13:29:51 +0900 | [diff] [blame] | 178 | |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 179 | file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL); |
| 180 | if (!file_priv) |
| 181 | return -ENOMEM; |
| 182 | |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 183 | file->driver_priv = file_priv; |
Inki Dae | b2df26c | 2012-04-23 21:01:28 +0900 | [diff] [blame] | 184 | |
Joonyoung Shim | 9084f7b | 2012-03-16 18:47:09 +0900 | [diff] [blame] | 185 | return exynos_drm_subdrv_open(dev, file); |
| 186 | } |
| 187 | |
Inki Dae | ccf4d88 | 2011-10-14 13:29:51 +0900 | [diff] [blame] | 188 | static void exynos_drm_preclose(struct drm_device *dev, |
| 189 | struct drm_file *file) |
| 190 | { |
Joonyoung Shim | 3ab09435 | 2012-03-16 18:47:07 +0900 | [diff] [blame] | 191 | struct exynos_drm_private *private = dev->dev_private; |
| 192 | struct drm_pending_vblank_event *e, *t; |
| 193 | unsigned long flags; |
| 194 | |
Inki Dae | ccf4d88 | 2011-10-14 13:29:51 +0900 | [diff] [blame] | 195 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 196 | |
Joonyoung Shim | 3ab09435 | 2012-03-16 18:47:07 +0900 | [diff] [blame] | 197 | /* release events of current file */ |
| 198 | spin_lock_irqsave(&dev->event_lock, flags); |
| 199 | list_for_each_entry_safe(e, t, &private->pageflip_event_list, |
| 200 | base.link) { |
| 201 | if (e->base.file_priv == file) { |
| 202 | list_del(&e->base.link); |
| 203 | e->base.destroy(&e->base); |
| 204 | } |
| 205 | } |
| 206 | spin_unlock_irqrestore(&dev->event_lock, flags); |
Joonyoung Shim | 9084f7b | 2012-03-16 18:47:09 +0900 | [diff] [blame] | 207 | |
| 208 | exynos_drm_subdrv_close(dev, file); |
Inki Dae | ccf4d88 | 2011-10-14 13:29:51 +0900 | [diff] [blame] | 209 | } |
| 210 | |
Inki Dae | 53ef299 | 2012-02-15 11:25:22 +0900 | [diff] [blame] | 211 | static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file) |
| 212 | { |
| 213 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 214 | |
| 215 | if (!file->driver_priv) |
| 216 | return; |
| 217 | |
| 218 | kfree(file->driver_priv); |
| 219 | file->driver_priv = NULL; |
| 220 | } |
| 221 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 222 | static void exynos_drm_lastclose(struct drm_device *dev) |
| 223 | { |
| 224 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 225 | |
| 226 | exynos_drm_fbdev_restore_mode(dev); |
| 227 | } |
| 228 | |
Laurent Pinchart | 78b6855 | 2012-05-17 13:27:22 +0200 | [diff] [blame] | 229 | static const struct vm_operations_struct exynos_drm_gem_vm_ops = { |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 230 | .fault = exynos_drm_gem_fault, |
| 231 | .open = drm_gem_vm_open, |
| 232 | .close = drm_gem_vm_close, |
| 233 | }; |
| 234 | |
| 235 | static struct drm_ioctl_desc exynos_ioctls[] = { |
| 236 | DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl, |
| 237 | DRM_UNLOCKED | DRM_AUTH), |
| 238 | DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP_OFFSET, |
| 239 | exynos_drm_gem_map_offset_ioctl, DRM_UNLOCKED | |
| 240 | DRM_AUTH), |
| 241 | DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MMAP, |
| 242 | exynos_drm_gem_mmap_ioctl, DRM_UNLOCKED | DRM_AUTH), |
Inki Dae | 40cd7e0 | 2012-05-04 15:51:17 +0900 | [diff] [blame] | 243 | DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, |
| 244 | exynos_drm_gem_get_ioctl, DRM_UNLOCKED), |
Inki Dae | b73d123 | 2012-03-21 10:55:26 +0900 | [diff] [blame] | 245 | DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, |
| 246 | vidi_connection_ioctl, DRM_UNLOCKED | DRM_AUTH), |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 247 | DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER, |
| 248 | exynos_g2d_get_ver_ioctl, DRM_UNLOCKED | DRM_AUTH), |
| 249 | DRM_IOCTL_DEF_DRV(EXYNOS_G2D_SET_CMDLIST, |
| 250 | exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED | DRM_AUTH), |
| 251 | DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC, |
| 252 | exynos_g2d_exec_ioctl, DRM_UNLOCKED | DRM_AUTH), |
Eunchul Kim | cb471f14 | 2012-12-14 18:10:31 +0900 | [diff] [blame] | 253 | DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY, |
| 254 | exynos_drm_ipp_get_property, DRM_UNLOCKED | DRM_AUTH), |
| 255 | DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY, |
| 256 | exynos_drm_ipp_set_property, DRM_UNLOCKED | DRM_AUTH), |
| 257 | DRM_IOCTL_DEF_DRV(EXYNOS_IPP_QUEUE_BUF, |
| 258 | exynos_drm_ipp_queue_buf, DRM_UNLOCKED | DRM_AUTH), |
| 259 | DRM_IOCTL_DEF_DRV(EXYNOS_IPP_CMD_CTRL, |
| 260 | exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH), |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 261 | }; |
| 262 | |
Joonyoung Shim | ac2bdf7 | 2011-12-08 15:00:20 +0900 | [diff] [blame] | 263 | static const struct file_operations exynos_drm_driver_fops = { |
| 264 | .owner = THIS_MODULE, |
| 265 | .open = drm_open, |
| 266 | .mmap = exynos_drm_gem_mmap, |
| 267 | .poll = drm_poll, |
| 268 | .read = drm_read, |
| 269 | .unlocked_ioctl = drm_ioctl, |
Keith Packard | 804d74a | 2012-07-09 15:40:07 -0700 | [diff] [blame] | 270 | #ifdef CONFIG_COMPAT |
| 271 | .compat_ioctl = drm_compat_ioctl, |
| 272 | #endif |
Joonyoung Shim | ac2bdf7 | 2011-12-08 15:00:20 +0900 | [diff] [blame] | 273 | .release = drm_release, |
| 274 | }; |
| 275 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 276 | static struct drm_driver exynos_drm_driver = { |
Laurent Pinchart | 293a1c1 | 2012-05-16 17:08:53 +0200 | [diff] [blame] | 277 | .driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET | |
| 278 | DRIVER_GEM | DRIVER_PRIME, |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 279 | .load = exynos_drm_load, |
| 280 | .unload = exynos_drm_unload, |
Joonyoung Shim | 9084f7b | 2012-03-16 18:47:09 +0900 | [diff] [blame] | 281 | .open = exynos_drm_open, |
Inki Dae | ccf4d88 | 2011-10-14 13:29:51 +0900 | [diff] [blame] | 282 | .preclose = exynos_drm_preclose, |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 283 | .lastclose = exynos_drm_lastclose, |
Inki Dae | 53ef299 | 2012-02-15 11:25:22 +0900 | [diff] [blame] | 284 | .postclose = exynos_drm_postclose, |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 285 | .get_vblank_counter = drm_vblank_count, |
| 286 | .enable_vblank = exynos_drm_crtc_enable_vblank, |
| 287 | .disable_vblank = exynos_drm_crtc_disable_vblank, |
| 288 | .gem_init_object = exynos_drm_gem_init_object, |
| 289 | .gem_free_object = exynos_drm_gem_free_object, |
| 290 | .gem_vm_ops = &exynos_drm_gem_vm_ops, |
| 291 | .dumb_create = exynos_drm_gem_dumb_create, |
| 292 | .dumb_map_offset = exynos_drm_gem_dumb_map_offset, |
| 293 | .dumb_destroy = exynos_drm_gem_dumb_destroy, |
Inki Dae | b2df26c | 2012-04-23 21:01:28 +0900 | [diff] [blame] | 294 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
| 295 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
| 296 | .gem_prime_export = exynos_dmabuf_prime_export, |
| 297 | .gem_prime_import = exynos_dmabuf_prime_import, |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 298 | .ioctls = exynos_ioctls, |
Joonyoung Shim | ac2bdf7 | 2011-12-08 15:00:20 +0900 | [diff] [blame] | 299 | .fops = &exynos_drm_driver_fops, |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 300 | .name = DRIVER_NAME, |
| 301 | .desc = DRIVER_DESC, |
| 302 | .date = DRIVER_DATE, |
| 303 | .major = DRIVER_MAJOR, |
| 304 | .minor = DRIVER_MINOR, |
| 305 | }; |
| 306 | |
| 307 | static int exynos_drm_platform_probe(struct platform_device *pdev) |
| 308 | { |
| 309 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 310 | |
Rahul Sharma | 422bd00 | 2012-10-16 05:50:12 +0530 | [diff] [blame] | 311 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 312 | exynos_drm_driver.num_ioctls = DRM_ARRAY_SIZE(exynos_ioctls); |
| 313 | |
| 314 | return drm_platform_init(&exynos_drm_driver, pdev); |
| 315 | } |
| 316 | |
| 317 | static int exynos_drm_platform_remove(struct platform_device *pdev) |
| 318 | { |
| 319 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 320 | |
| 321 | drm_platform_exit(&exynos_drm_driver, pdev); |
| 322 | |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | static struct platform_driver exynos_drm_platform_driver = { |
| 327 | .probe = exynos_drm_platform_probe, |
| 328 | .remove = __devexit_p(exynos_drm_platform_remove), |
| 329 | .driver = { |
| 330 | .owner = THIS_MODULE, |
Marek Szyprowski | 9866b6c | 2012-03-05 12:02:30 +0100 | [diff] [blame] | 331 | .name = "exynos-drm", |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 332 | }, |
| 333 | }; |
| 334 | |
| 335 | static int __init exynos_drm_init(void) |
| 336 | { |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 337 | int ret; |
| 338 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 339 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 340 | |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 341 | #ifdef CONFIG_DRM_EXYNOS_FIMD |
| 342 | ret = platform_driver_register(&fimd_driver); |
| 343 | if (ret < 0) |
| 344 | goto out_fimd; |
| 345 | #endif |
| 346 | |
| 347 | #ifdef CONFIG_DRM_EXYNOS_HDMI |
| 348 | ret = platform_driver_register(&hdmi_driver); |
| 349 | if (ret < 0) |
| 350 | goto out_hdmi; |
| 351 | ret = platform_driver_register(&mixer_driver); |
| 352 | if (ret < 0) |
| 353 | goto out_mixer; |
| 354 | ret = platform_driver_register(&exynos_drm_common_hdmi_driver); |
| 355 | if (ret < 0) |
| 356 | goto out_common_hdmi; |
Rahul Sharma | ae9dace | 2012-10-16 05:50:13 +0530 | [diff] [blame] | 357 | |
| 358 | ret = exynos_platform_device_hdmi_register(); |
| 359 | if (ret < 0) |
| 360 | goto out_common_hdmi_dev; |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 361 | #endif |
| 362 | |
Inki Dae | b73d123 | 2012-03-21 10:55:26 +0900 | [diff] [blame] | 363 | #ifdef CONFIG_DRM_EXYNOS_VIDI |
| 364 | ret = platform_driver_register(&vidi_driver); |
| 365 | if (ret < 0) |
| 366 | goto out_vidi; |
| 367 | #endif |
| 368 | |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 369 | #ifdef CONFIG_DRM_EXYNOS_G2D |
| 370 | ret = platform_driver_register(&g2d_driver); |
| 371 | if (ret < 0) |
| 372 | goto out_g2d; |
| 373 | #endif |
| 374 | |
Eunchul Kim | 16102ed | 2012-12-14 17:58:55 +0900 | [diff] [blame] | 375 | #ifdef CONFIG_DRM_EXYNOS_FIMC |
| 376 | ret = platform_driver_register(&fimc_driver); |
| 377 | if (ret < 0) |
| 378 | goto out_fimc; |
| 379 | #endif |
| 380 | |
Eunchul Kim | bea8a42 | 2012-12-14 17:58:56 +0900 | [diff] [blame^] | 381 | #ifdef CONFIG_DRM_EXYNOS_ROTATOR |
| 382 | ret = platform_driver_register(&rotator_driver); |
| 383 | if (ret < 0) |
| 384 | goto out_rotator; |
| 385 | #endif |
| 386 | |
Eunchul Kim | cb471f14 | 2012-12-14 18:10:31 +0900 | [diff] [blame] | 387 | #ifdef CONFIG_DRM_EXYNOS_IPP |
| 388 | ret = platform_driver_register(&ipp_driver); |
| 389 | if (ret < 0) |
| 390 | goto out_ipp; |
| 391 | #endif |
| 392 | |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 393 | ret = platform_driver_register(&exynos_drm_platform_driver); |
| 394 | if (ret < 0) |
Rahul Sharma | 422bd00 | 2012-10-16 05:50:12 +0530 | [diff] [blame] | 395 | goto out_drm; |
| 396 | |
| 397 | exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1, |
| 398 | NULL, 0); |
| 399 | if (IS_ERR_OR_NULL(exynos_drm_pdev)) { |
| 400 | ret = PTR_ERR(exynos_drm_pdev); |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 401 | goto out; |
Rahul Sharma | 422bd00 | 2012-10-16 05:50:12 +0530 | [diff] [blame] | 402 | } |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 403 | |
| 404 | return 0; |
| 405 | |
| 406 | out: |
Rahul Sharma | 422bd00 | 2012-10-16 05:50:12 +0530 | [diff] [blame] | 407 | platform_driver_unregister(&exynos_drm_platform_driver); |
| 408 | |
| 409 | out_drm: |
Eunchul Kim | cb471f14 | 2012-12-14 18:10:31 +0900 | [diff] [blame] | 410 | #ifdef CONFIG_DRM_EXYNOS_IPP |
| 411 | platform_driver_unregister(&ipp_driver); |
| 412 | out_ipp: |
| 413 | #endif |
| 414 | |
Eunchul Kim | bea8a42 | 2012-12-14 17:58:56 +0900 | [diff] [blame^] | 415 | #ifdef CONFIG_DRM_EXYNOS_ROTATOR |
| 416 | platform_driver_unregister(&rotator_driver); |
| 417 | out_rotator: |
| 418 | #endif |
| 419 | |
Eunchul Kim | 16102ed | 2012-12-14 17:58:55 +0900 | [diff] [blame] | 420 | #ifdef CONFIG_DRM_EXYNOS_FIMC |
| 421 | platform_driver_unregister(&fimc_driver); |
| 422 | out_fimc: |
| 423 | #endif |
| 424 | |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 425 | #ifdef CONFIG_DRM_EXYNOS_G2D |
| 426 | platform_driver_unregister(&g2d_driver); |
| 427 | out_g2d: |
| 428 | #endif |
| 429 | |
Inki Dae | b73d123 | 2012-03-21 10:55:26 +0900 | [diff] [blame] | 430 | #ifdef CONFIG_DRM_EXYNOS_VIDI |
Inki Dae | b73d123 | 2012-03-21 10:55:26 +0900 | [diff] [blame] | 431 | platform_driver_unregister(&vidi_driver); |
Rahul Sharma | ae9dace | 2012-10-16 05:50:13 +0530 | [diff] [blame] | 432 | out_vidi: |
Inki Dae | b73d123 | 2012-03-21 10:55:26 +0900 | [diff] [blame] | 433 | #endif |
| 434 | |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 435 | #ifdef CONFIG_DRM_EXYNOS_HDMI |
Rahul Sharma | ae9dace | 2012-10-16 05:50:13 +0530 | [diff] [blame] | 436 | exynos_platform_device_hdmi_unregister(); |
| 437 | out_common_hdmi_dev: |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 438 | platform_driver_unregister(&exynos_drm_common_hdmi_driver); |
| 439 | out_common_hdmi: |
| 440 | platform_driver_unregister(&mixer_driver); |
| 441 | out_mixer: |
| 442 | platform_driver_unregister(&hdmi_driver); |
| 443 | out_hdmi: |
| 444 | #endif |
| 445 | |
| 446 | #ifdef CONFIG_DRM_EXYNOS_FIMD |
| 447 | platform_driver_unregister(&fimd_driver); |
| 448 | out_fimd: |
| 449 | #endif |
| 450 | return ret; |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | static void __exit exynos_drm_exit(void) |
| 454 | { |
| 455 | DRM_DEBUG_DRIVER("%s\n", __FILE__); |
| 456 | |
Rahul Sharma | 422bd00 | 2012-10-16 05:50:12 +0530 | [diff] [blame] | 457 | platform_device_unregister(exynos_drm_pdev); |
| 458 | |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 459 | platform_driver_unregister(&exynos_drm_platform_driver); |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 460 | |
Eunchul Kim | cb471f14 | 2012-12-14 18:10:31 +0900 | [diff] [blame] | 461 | #ifdef CONFIG_DRM_EXYNOS_IPP |
| 462 | platform_driver_unregister(&ipp_driver); |
| 463 | #endif |
| 464 | |
Eunchul Kim | bea8a42 | 2012-12-14 17:58:56 +0900 | [diff] [blame^] | 465 | #ifdef CONFIG_DRM_EXYNOS_ROTATOR |
| 466 | platform_driver_unregister(&rotator_driver); |
| 467 | #endif |
| 468 | |
Eunchul Kim | 16102ed | 2012-12-14 17:58:55 +0900 | [diff] [blame] | 469 | #ifdef CONFIG_DRM_EXYNOS_FIMC |
| 470 | platform_driver_unregister(&fimc_driver); |
| 471 | #endif |
| 472 | |
Joonyoung Shim | d7f1642 | 2012-05-17 20:06:32 +0900 | [diff] [blame] | 473 | #ifdef CONFIG_DRM_EXYNOS_G2D |
| 474 | platform_driver_unregister(&g2d_driver); |
| 475 | #endif |
| 476 | |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 477 | #ifdef CONFIG_DRM_EXYNOS_HDMI |
Rahul Sharma | ae9dace | 2012-10-16 05:50:13 +0530 | [diff] [blame] | 478 | exynos_platform_device_hdmi_unregister(); |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 479 | platform_driver_unregister(&exynos_drm_common_hdmi_driver); |
| 480 | platform_driver_unregister(&mixer_driver); |
| 481 | platform_driver_unregister(&hdmi_driver); |
| 482 | #endif |
| 483 | |
Inki Dae | b73d123 | 2012-03-21 10:55:26 +0900 | [diff] [blame] | 484 | #ifdef CONFIG_DRM_EXYNOS_VIDI |
| 485 | platform_driver_unregister(&vidi_driver); |
| 486 | #endif |
| 487 | |
Joonyoung Shim | 132a5b9 | 2012-03-16 18:47:08 +0900 | [diff] [blame] | 488 | #ifdef CONFIG_DRM_EXYNOS_FIMD |
| 489 | platform_driver_unregister(&fimd_driver); |
| 490 | #endif |
Inki Dae | 1c248b7 | 2011-10-04 19:19:01 +0900 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | module_init(exynos_drm_init); |
| 494 | module_exit(exynos_drm_exit); |
| 495 | |
| 496 | MODULE_AUTHOR("Inki Dae <inki.dae@samsung.com>"); |
| 497 | MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); |
| 498 | MODULE_AUTHOR("Seung-Woo Kim <sw0312.kim@samsung.com>"); |
| 499 | MODULE_DESCRIPTION("Samsung SoC DRM Driver"); |
| 500 | MODULE_LICENSE("GPL"); |