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