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