exynos_drm_drv.c 17 KB

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