exynos_drm_drv.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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. * 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.
  12. */
  13. #include <linux/pm_runtime.h>
  14. #include <drm/drmP.h>
  15. #include <drm/drm_crtc_helper.h>
  16. #include <linux/anon_inodes.h>
  17. #include <linux/component.h>
  18. #include <drm/exynos_drm.h>
  19. #include "exynos_drm_drv.h"
  20. #include "exynos_drm_crtc.h"
  21. #include "exynos_drm_encoder.h"
  22. #include "exynos_drm_fbdev.h"
  23. #include "exynos_drm_fb.h"
  24. #include "exynos_drm_gem.h"
  25. #include "exynos_drm_plane.h"
  26. #include "exynos_drm_vidi.h"
  27. #include "exynos_drm_dmabuf.h"
  28. #include "exynos_drm_g2d.h"
  29. #include "exynos_drm_ipp.h"
  30. #include "exynos_drm_iommu.h"
  31. #define DRIVER_NAME "exynos"
  32. #define DRIVER_DESC "Samsung SoC DRM"
  33. #define DRIVER_DATE "20110530"
  34. #define DRIVER_MAJOR 1
  35. #define DRIVER_MINOR 0
  36. static struct platform_device *exynos_drm_pdev;
  37. static DEFINE_MUTEX(drm_component_lock);
  38. static LIST_HEAD(drm_component_list);
  39. struct component_dev {
  40. struct list_head list;
  41. struct device *crtc_dev;
  42. struct device *conn_dev;
  43. enum exynos_drm_output_type out_type;
  44. unsigned int dev_type_flag;
  45. };
  46. static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
  47. {
  48. struct exynos_drm_private *private;
  49. int ret;
  50. int nr;
  51. private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL);
  52. if (!private)
  53. return -ENOMEM;
  54. INIT_LIST_HEAD(&private->pageflip_event_list);
  55. dev_set_drvdata(dev->dev, dev);
  56. dev->dev_private = (void *)private;
  57. /*
  58. * create mapping to manage iommu table and set a pointer to iommu
  59. * mapping structure to iommu_mapping of private data.
  60. * also this iommu_mapping can be used to check if iommu is supported
  61. * or not.
  62. */
  63. ret = drm_create_iommu_mapping(dev);
  64. if (ret < 0) {
  65. DRM_ERROR("failed to create iommu mapping.\n");
  66. goto err_free_private;
  67. }
  68. drm_mode_config_init(dev);
  69. exynos_drm_mode_config_init(dev);
  70. for (nr = 0; nr < MAX_PLANE; nr++) {
  71. struct drm_plane *plane;
  72. unsigned long possible_crtcs = (1 << MAX_CRTC) - 1;
  73. plane = exynos_plane_init(dev, possible_crtcs, false);
  74. if (!plane)
  75. goto err_mode_config_cleanup;
  76. }
  77. /* init kms poll for handling hpd */
  78. drm_kms_helper_poll_init(dev);
  79. ret = drm_vblank_init(dev, MAX_CRTC);
  80. if (ret)
  81. goto err_mode_config_cleanup;
  82. /* setup possible_clones. */
  83. exynos_drm_encoder_setup(dev);
  84. platform_set_drvdata(dev->platformdev, dev);
  85. /* Try to bind all sub drivers. */
  86. ret = component_bind_all(dev->dev, dev);
  87. if (ret)
  88. goto err_cleanup_vblank;
  89. /* Probe non kms sub drivers and virtual display driver. */
  90. ret = exynos_drm_device_subdrv_probe(dev);
  91. if (ret)
  92. goto err_unbind_all;
  93. /* force connectors detection */
  94. drm_helper_hpd_irq_event(dev);
  95. return 0;
  96. err_unbind_all:
  97. component_unbind_all(dev->dev, dev);
  98. err_cleanup_vblank:
  99. drm_vblank_cleanup(dev);
  100. err_mode_config_cleanup:
  101. drm_mode_config_cleanup(dev);
  102. drm_release_iommu_mapping(dev);
  103. err_free_private:
  104. kfree(private);
  105. return ret;
  106. }
  107. static int exynos_drm_unload(struct drm_device *dev)
  108. {
  109. exynos_drm_device_subdrv_remove(dev);
  110. exynos_drm_fbdev_fini(dev);
  111. drm_vblank_cleanup(dev);
  112. drm_kms_helper_poll_fini(dev);
  113. drm_mode_config_cleanup(dev);
  114. drm_release_iommu_mapping(dev);
  115. kfree(dev->dev_private);
  116. component_unbind_all(dev->dev, dev);
  117. dev->dev_private = NULL;
  118. return 0;
  119. }
  120. static const struct file_operations exynos_drm_gem_fops = {
  121. .mmap = exynos_drm_gem_mmap_buffer,
  122. };
  123. static int exynos_drm_suspend(struct drm_device *dev, pm_message_t state)
  124. {
  125. struct drm_connector *connector;
  126. drm_modeset_lock_all(dev);
  127. list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
  128. int old_dpms = connector->dpms;
  129. if (connector->funcs->dpms)
  130. connector->funcs->dpms(connector, DRM_MODE_DPMS_OFF);
  131. /* Set the old mode back to the connector for resume */
  132. connector->dpms = old_dpms;
  133. }
  134. drm_modeset_unlock_all(dev);
  135. return 0;
  136. }
  137. static int exynos_drm_resume(struct drm_device *dev)
  138. {
  139. struct drm_connector *connector;
  140. drm_modeset_lock_all(dev);
  141. list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
  142. if (connector->funcs->dpms)
  143. connector->funcs->dpms(connector, connector->dpms);
  144. }
  145. drm_modeset_unlock_all(dev);
  146. drm_helper_resume_force_mode(dev);
  147. return 0;
  148. }
  149. static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
  150. {
  151. struct drm_exynos_file_private *file_priv;
  152. struct file *anon_filp;
  153. int ret;
  154. file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
  155. if (!file_priv)
  156. return -ENOMEM;
  157. file->driver_priv = file_priv;
  158. ret = exynos_drm_subdrv_open(dev, file);
  159. if (ret)
  160. goto err_file_priv_free;
  161. anon_filp = anon_inode_getfile("exynos_gem", &exynos_drm_gem_fops,
  162. NULL, 0);
  163. if (IS_ERR(anon_filp)) {
  164. ret = PTR_ERR(anon_filp);
  165. goto err_subdrv_close;
  166. }
  167. anon_filp->f_mode = FMODE_READ | FMODE_WRITE;
  168. file_priv->anon_filp = anon_filp;
  169. return ret;
  170. err_subdrv_close:
  171. exynos_drm_subdrv_close(dev, file);
  172. err_file_priv_free:
  173. kfree(file_priv);
  174. file->driver_priv = NULL;
  175. return ret;
  176. }
  177. static void exynos_drm_preclose(struct drm_device *dev,
  178. struct drm_file *file)
  179. {
  180. exynos_drm_subdrv_close(dev, file);
  181. }
  182. static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
  183. {
  184. struct exynos_drm_private *private = dev->dev_private;
  185. struct drm_exynos_file_private *file_priv;
  186. struct drm_pending_vblank_event *v, *vt;
  187. struct drm_pending_event *e, *et;
  188. unsigned long flags;
  189. if (!file->driver_priv)
  190. return;
  191. /* Release all events not unhandled by page flip handler. */
  192. spin_lock_irqsave(&dev->event_lock, flags);
  193. list_for_each_entry_safe(v, vt, &private->pageflip_event_list,
  194. base.link) {
  195. if (v->base.file_priv == file) {
  196. list_del(&v->base.link);
  197. drm_vblank_put(dev, v->pipe);
  198. v->base.destroy(&v->base);
  199. }
  200. }
  201. /* Release all events handled by page flip handler but not freed. */
  202. list_for_each_entry_safe(e, et, &file->event_list, link) {
  203. list_del(&e->link);
  204. e->destroy(e);
  205. }
  206. spin_unlock_irqrestore(&dev->event_lock, flags);
  207. file_priv = file->driver_priv;
  208. if (file_priv->anon_filp)
  209. fput(file_priv->anon_filp);
  210. kfree(file->driver_priv);
  211. file->driver_priv = NULL;
  212. }
  213. static void exynos_drm_lastclose(struct drm_device *dev)
  214. {
  215. exynos_drm_fbdev_restore_mode(dev);
  216. }
  217. static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
  218. .fault = exynos_drm_gem_fault,
  219. .open = drm_gem_vm_open,
  220. .close = drm_gem_vm_close,
  221. };
  222. static const struct drm_ioctl_desc exynos_ioctls[] = {
  223. DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
  224. DRM_UNLOCKED | DRM_AUTH),
  225. DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP_OFFSET,
  226. exynos_drm_gem_map_offset_ioctl, DRM_UNLOCKED |
  227. DRM_AUTH),
  228. DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MMAP,
  229. exynos_drm_gem_mmap_ioctl, DRM_UNLOCKED | DRM_AUTH),
  230. DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET,
  231. exynos_drm_gem_get_ioctl, DRM_UNLOCKED),
  232. DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION,
  233. vidi_connection_ioctl, DRM_UNLOCKED | DRM_AUTH),
  234. DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER,
  235. exynos_g2d_get_ver_ioctl, DRM_UNLOCKED | DRM_AUTH),
  236. DRM_IOCTL_DEF_DRV(EXYNOS_G2D_SET_CMDLIST,
  237. exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED | DRM_AUTH),
  238. DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC,
  239. exynos_g2d_exec_ioctl, DRM_UNLOCKED | DRM_AUTH),
  240. DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY,
  241. exynos_drm_ipp_get_property, DRM_UNLOCKED | DRM_AUTH),
  242. DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY,
  243. exynos_drm_ipp_set_property, DRM_UNLOCKED | DRM_AUTH),
  244. DRM_IOCTL_DEF_DRV(EXYNOS_IPP_QUEUE_BUF,
  245. exynos_drm_ipp_queue_buf, DRM_UNLOCKED | DRM_AUTH),
  246. DRM_IOCTL_DEF_DRV(EXYNOS_IPP_CMD_CTRL,
  247. exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH),
  248. };
  249. static const struct file_operations exynos_drm_driver_fops = {
  250. .owner = THIS_MODULE,
  251. .open = drm_open,
  252. .mmap = exynos_drm_gem_mmap,
  253. .poll = drm_poll,
  254. .read = drm_read,
  255. .unlocked_ioctl = drm_ioctl,
  256. #ifdef CONFIG_COMPAT
  257. .compat_ioctl = drm_compat_ioctl,
  258. #endif
  259. .release = drm_release,
  260. };
  261. static struct drm_driver exynos_drm_driver = {
  262. .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
  263. .load = exynos_drm_load,
  264. .unload = exynos_drm_unload,
  265. .suspend = exynos_drm_suspend,
  266. .resume = exynos_drm_resume,
  267. .open = exynos_drm_open,
  268. .preclose = exynos_drm_preclose,
  269. .lastclose = exynos_drm_lastclose,
  270. .postclose = exynos_drm_postclose,
  271. .get_vblank_counter = drm_vblank_count,
  272. .enable_vblank = exynos_drm_crtc_enable_vblank,
  273. .disable_vblank = exynos_drm_crtc_disable_vblank,
  274. .gem_free_object = exynos_drm_gem_free_object,
  275. .gem_vm_ops = &exynos_drm_gem_vm_ops,
  276. .dumb_create = exynos_drm_gem_dumb_create,
  277. .dumb_map_offset = exynos_drm_gem_dumb_map_offset,
  278. .dumb_destroy = drm_gem_dumb_destroy,
  279. .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  280. .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  281. .gem_prime_export = exynos_dmabuf_prime_export,
  282. .gem_prime_import = exynos_dmabuf_prime_import,
  283. .ioctls = exynos_ioctls,
  284. .num_ioctls = ARRAY_SIZE(exynos_ioctls),
  285. .fops = &exynos_drm_driver_fops,
  286. .name = DRIVER_NAME,
  287. .desc = DRIVER_DESC,
  288. .date = DRIVER_DATE,
  289. .major = DRIVER_MAJOR,
  290. .minor = DRIVER_MINOR,
  291. };
  292. #ifdef CONFIG_PM_SLEEP
  293. static int exynos_drm_sys_suspend(struct device *dev)
  294. {
  295. struct drm_device *drm_dev = dev_get_drvdata(dev);
  296. pm_message_t message;
  297. if (pm_runtime_suspended(dev) || !drm_dev)
  298. return 0;
  299. message.event = PM_EVENT_SUSPEND;
  300. return exynos_drm_suspend(drm_dev, message);
  301. }
  302. static int exynos_drm_sys_resume(struct device *dev)
  303. {
  304. struct drm_device *drm_dev = dev_get_drvdata(dev);
  305. if (pm_runtime_suspended(dev) || !drm_dev)
  306. return 0;
  307. return exynos_drm_resume(drm_dev);
  308. }
  309. #endif
  310. static const struct dev_pm_ops exynos_drm_pm_ops = {
  311. SET_SYSTEM_SLEEP_PM_OPS(exynos_drm_sys_suspend, exynos_drm_sys_resume)
  312. };
  313. int exynos_drm_component_add(struct device *dev,
  314. enum exynos_drm_device_type dev_type,
  315. enum exynos_drm_output_type out_type)
  316. {
  317. struct component_dev *cdev;
  318. if (dev_type != EXYNOS_DEVICE_TYPE_CRTC &&
  319. dev_type != EXYNOS_DEVICE_TYPE_CONNECTOR) {
  320. DRM_ERROR("invalid device type.\n");
  321. return -EINVAL;
  322. }
  323. mutex_lock(&drm_component_lock);
  324. /*
  325. * Make sure to check if there is a component which has two device
  326. * objects, for connector and for encoder/connector.
  327. * It should make sure that crtc and encoder/connector drivers are
  328. * ready before exynos drm core binds them.
  329. */
  330. list_for_each_entry(cdev, &drm_component_list, list) {
  331. if (cdev->out_type == out_type) {
  332. /*
  333. * If crtc and encoder/connector device objects are
  334. * added already just return.
  335. */
  336. if (cdev->dev_type_flag == (EXYNOS_DEVICE_TYPE_CRTC |
  337. EXYNOS_DEVICE_TYPE_CONNECTOR)) {
  338. mutex_unlock(&drm_component_lock);
  339. return 0;
  340. }
  341. if (dev_type == EXYNOS_DEVICE_TYPE_CRTC) {
  342. cdev->crtc_dev = dev;
  343. cdev->dev_type_flag |= dev_type;
  344. }
  345. if (dev_type == EXYNOS_DEVICE_TYPE_CONNECTOR) {
  346. cdev->conn_dev = dev;
  347. cdev->dev_type_flag |= dev_type;
  348. }
  349. mutex_unlock(&drm_component_lock);
  350. return 0;
  351. }
  352. }
  353. mutex_unlock(&drm_component_lock);
  354. cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
  355. if (!cdev)
  356. return -ENOMEM;
  357. if (dev_type == EXYNOS_DEVICE_TYPE_CRTC)
  358. cdev->crtc_dev = dev;
  359. if (dev_type == EXYNOS_DEVICE_TYPE_CONNECTOR)
  360. cdev->conn_dev = dev;
  361. cdev->out_type = out_type;
  362. cdev->dev_type_flag = dev_type;
  363. mutex_lock(&drm_component_lock);
  364. list_add_tail(&cdev->list, &drm_component_list);
  365. mutex_unlock(&drm_component_lock);
  366. return 0;
  367. }
  368. void exynos_drm_component_del(struct device *dev,
  369. enum exynos_drm_device_type dev_type)
  370. {
  371. struct component_dev *cdev, *next;
  372. mutex_lock(&drm_component_lock);
  373. list_for_each_entry_safe(cdev, next, &drm_component_list, list) {
  374. if (dev_type == EXYNOS_DEVICE_TYPE_CRTC) {
  375. if (cdev->crtc_dev == dev) {
  376. cdev->crtc_dev = NULL;
  377. cdev->dev_type_flag &= ~dev_type;
  378. }
  379. }
  380. if (dev_type == EXYNOS_DEVICE_TYPE_CONNECTOR) {
  381. if (cdev->conn_dev == dev) {
  382. cdev->conn_dev = NULL;
  383. cdev->dev_type_flag &= ~dev_type;
  384. }
  385. }
  386. /*
  387. * Release cdev object only in case that both of crtc and
  388. * encoder/connector device objects are NULL.
  389. */
  390. if (!cdev->crtc_dev && !cdev->conn_dev) {
  391. list_del(&cdev->list);
  392. kfree(cdev);
  393. }
  394. break;
  395. }
  396. mutex_unlock(&drm_component_lock);
  397. }
  398. static int compare_of(struct device *dev, void *data)
  399. {
  400. return dev == (struct device *)data;
  401. }
  402. static int exynos_drm_add_components(struct device *dev, struct master *m)
  403. {
  404. struct component_dev *cdev;
  405. unsigned int attach_cnt = 0;
  406. mutex_lock(&drm_component_lock);
  407. list_for_each_entry(cdev, &drm_component_list, list) {
  408. int ret;
  409. /*
  410. * Add components to master only in case that crtc and
  411. * encoder/connector device objects exist.
  412. */
  413. if (!cdev->crtc_dev || !cdev->conn_dev)
  414. continue;
  415. attach_cnt++;
  416. mutex_unlock(&drm_component_lock);
  417. /*
  418. * fimd and dpi modules have same device object so add
  419. * only crtc device object in this case.
  420. *
  421. * TODO. if dpi module follows driver-model driver then
  422. * below codes can be removed.
  423. */
  424. if (cdev->crtc_dev == cdev->conn_dev) {
  425. ret = component_master_add_child(m, compare_of,
  426. cdev->crtc_dev);
  427. if (ret < 0)
  428. return ret;
  429. goto out_lock;
  430. }
  431. /*
  432. * Do not chage below call order.
  433. * crtc device first should be added to master because
  434. * connector/encoder need pipe number of crtc when they
  435. * are created.
  436. */
  437. ret = component_master_add_child(m, compare_of, cdev->crtc_dev);
  438. ret |= component_master_add_child(m, compare_of,
  439. cdev->conn_dev);
  440. if (ret < 0)
  441. return ret;
  442. out_lock:
  443. mutex_lock(&drm_component_lock);
  444. }
  445. mutex_unlock(&drm_component_lock);
  446. return attach_cnt ? 0 : -ENODEV;
  447. }
  448. static int exynos_drm_bind(struct device *dev)
  449. {
  450. return drm_platform_init(&exynos_drm_driver, to_platform_device(dev));
  451. }
  452. static void exynos_drm_unbind(struct device *dev)
  453. {
  454. drm_put_dev(dev_get_drvdata(dev));
  455. }
  456. static const struct component_master_ops exynos_drm_ops = {
  457. .add_components = exynos_drm_add_components,
  458. .bind = exynos_drm_bind,
  459. .unbind = exynos_drm_unbind,
  460. };
  461. static int exynos_drm_platform_probe(struct platform_device *pdev)
  462. {
  463. int ret;
  464. pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
  465. exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
  466. #ifdef CONFIG_DRM_EXYNOS_FIMD
  467. ret = platform_driver_register(&fimd_driver);
  468. if (ret < 0)
  469. return ret;
  470. #endif
  471. #ifdef CONFIG_DRM_EXYNOS_DP
  472. ret = platform_driver_register(&dp_driver);
  473. if (ret < 0)
  474. goto err_unregister_fimd_drv;
  475. #endif
  476. #ifdef CONFIG_DRM_EXYNOS_DSI
  477. ret = platform_driver_register(&dsi_driver);
  478. if (ret < 0)
  479. goto err_unregister_dp_drv;
  480. #endif
  481. #ifdef CONFIG_DRM_EXYNOS_HDMI
  482. ret = platform_driver_register(&mixer_driver);
  483. if (ret < 0)
  484. goto err_unregister_dsi_drv;
  485. ret = platform_driver_register(&hdmi_driver);
  486. if (ret < 0)
  487. goto err_unregister_mixer_drv;
  488. #endif
  489. #ifdef CONFIG_DRM_EXYNOS_G2D
  490. ret = platform_driver_register(&g2d_driver);
  491. if (ret < 0)
  492. goto err_unregister_hdmi_drv;
  493. #endif
  494. #ifdef CONFIG_DRM_EXYNOS_FIMC
  495. ret = platform_driver_register(&fimc_driver);
  496. if (ret < 0)
  497. goto err_unregister_g2d_drv;
  498. #endif
  499. #ifdef CONFIG_DRM_EXYNOS_ROTATOR
  500. ret = platform_driver_register(&rotator_driver);
  501. if (ret < 0)
  502. goto err_unregister_fimc_drv;
  503. #endif
  504. #ifdef CONFIG_DRM_EXYNOS_GSC
  505. ret = platform_driver_register(&gsc_driver);
  506. if (ret < 0)
  507. goto err_unregister_rotator_drv;
  508. #endif
  509. #ifdef CONFIG_DRM_EXYNOS_IPP
  510. ret = platform_driver_register(&ipp_driver);
  511. if (ret < 0)
  512. goto err_unregister_gsc_drv;
  513. ret = exynos_platform_device_ipp_register();
  514. if (ret < 0)
  515. goto err_unregister_ipp_drv;
  516. #endif
  517. ret = component_master_add(&pdev->dev, &exynos_drm_ops);
  518. if (ret < 0)
  519. DRM_DEBUG_KMS("re-tried by last sub driver probed later.\n");
  520. return 0;
  521. #ifdef CONFIG_DRM_EXYNOS_IPP
  522. err_unregister_ipp_drv:
  523. platform_driver_unregister(&ipp_driver);
  524. err_unregister_gsc_drv:
  525. #endif
  526. #ifdef CONFIG_DRM_EXYNOS_GSC
  527. platform_driver_unregister(&gsc_driver);
  528. err_unregister_rotator_drv:
  529. #endif
  530. #ifdef CONFIG_DRM_EXYNOS_ROTATOR
  531. platform_driver_unregister(&rotator_driver);
  532. err_unregister_fimc_drv:
  533. #endif
  534. #ifdef CONFIG_DRM_EXYNOS_FIMC
  535. platform_driver_unregister(&fimc_driver);
  536. err_unregister_g2d_drv:
  537. #endif
  538. #ifdef CONFIG_DRM_EXYNOS_G2D
  539. platform_driver_unregister(&g2d_driver);
  540. err_unregister_hdmi_drv:
  541. #endif
  542. #ifdef CONFIG_DRM_EXYNOS_HDMI
  543. platform_driver_unregister(&hdmi_driver);
  544. err_unregister_mixer_drv:
  545. platform_driver_unregister(&mixer_driver);
  546. err_unregister_dsi_drv:
  547. #endif
  548. #ifdef CONFIG_DRM_EXYNOS_DSI
  549. platform_driver_unregister(&dsi_driver);
  550. err_unregister_dp_drv:
  551. #endif
  552. #ifdef CONFIG_DRM_EXYNOS_DP
  553. platform_driver_unregister(&dp_driver);
  554. err_unregister_fimd_drv:
  555. #endif
  556. #ifdef CONFIG_DRM_EXYNOS_FIMD
  557. platform_driver_unregister(&fimd_driver);
  558. #endif
  559. return ret;
  560. }
  561. static int exynos_drm_platform_remove(struct platform_device *pdev)
  562. {
  563. #ifdef CONFIG_DRM_EXYNOS_IPP
  564. exynos_platform_device_ipp_unregister();
  565. platform_driver_unregister(&ipp_driver);
  566. #endif
  567. #ifdef CONFIG_DRM_EXYNOS_GSC
  568. platform_driver_unregister(&gsc_driver);
  569. #endif
  570. #ifdef CONFIG_DRM_EXYNOS_ROTATOR
  571. platform_driver_unregister(&rotator_driver);
  572. #endif
  573. #ifdef CONFIG_DRM_EXYNOS_FIMC
  574. platform_driver_unregister(&fimc_driver);
  575. #endif
  576. #ifdef CONFIG_DRM_EXYNOS_G2D
  577. platform_driver_unregister(&g2d_driver);
  578. #endif
  579. #ifdef CONFIG_DRM_EXYNOS_HDMI
  580. platform_driver_unregister(&mixer_driver);
  581. platform_driver_unregister(&hdmi_driver);
  582. #endif
  583. #ifdef CONFIG_DRM_EXYNOS_FIMD
  584. platform_driver_unregister(&fimd_driver);
  585. #endif
  586. #ifdef CONFIG_DRM_EXYNOS_DSI
  587. platform_driver_unregister(&dsi_driver);
  588. #endif
  589. #ifdef CONFIG_DRM_EXYNOS_DP
  590. platform_driver_unregister(&dp_driver);
  591. #endif
  592. component_master_del(&pdev->dev, &exynos_drm_ops);
  593. return 0;
  594. }
  595. static struct platform_driver exynos_drm_platform_driver = {
  596. .probe = exynos_drm_platform_probe,
  597. .remove = exynos_drm_platform_remove,
  598. .driver = {
  599. .owner = THIS_MODULE,
  600. .name = "exynos-drm",
  601. .pm = &exynos_drm_pm_ops,
  602. },
  603. };
  604. static int exynos_drm_init(void)
  605. {
  606. int ret;
  607. exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1,
  608. NULL, 0);
  609. if (IS_ERR(exynos_drm_pdev))
  610. return PTR_ERR(exynos_drm_pdev);
  611. #ifdef CONFIG_DRM_EXYNOS_VIDI
  612. ret = exynos_drm_probe_vidi();
  613. if (ret < 0)
  614. goto err_unregister_pd;
  615. #endif
  616. ret = platform_driver_register(&exynos_drm_platform_driver);
  617. if (ret)
  618. goto err_remove_vidi;
  619. return 0;
  620. err_remove_vidi:
  621. #ifdef CONFIG_DRM_EXYNOS_VIDI
  622. exynos_drm_remove_vidi();
  623. err_unregister_pd:
  624. #endif
  625. platform_device_unregister(exynos_drm_pdev);
  626. return ret;
  627. }
  628. static void exynos_drm_exit(void)
  629. {
  630. platform_driver_unregister(&exynos_drm_platform_driver);
  631. #ifdef CONFIG_DRM_EXYNOS_VIDI
  632. exynos_drm_remove_vidi();
  633. #endif
  634. platform_device_unregister(exynos_drm_pdev);
  635. }
  636. module_init(exynos_drm_init);
  637. module_exit(exynos_drm_exit);
  638. MODULE_AUTHOR("Inki Dae <inki.dae@samsung.com>");
  639. MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
  640. MODULE_AUTHOR("Seung-Woo Kim <sw0312.kim@samsung.com>");
  641. MODULE_DESCRIPTION("Samsung SoC DRM Driver");
  642. MODULE_LICENSE("GPL");