omap_drv.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. * drivers/gpu/drm/omapdrm/omap_drv.c
  3. *
  4. * Copyright (C) 2011 Texas Instruments
  5. * Author: Rob Clark <rob@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "omap_drv.h"
  20. #include "drm_crtc_helper.h"
  21. #include "drm_fb_helper.h"
  22. #include "omap_dmm_tiler.h"
  23. #define DRIVER_NAME MODULE_NAME
  24. #define DRIVER_DESC "OMAP DRM"
  25. #define DRIVER_DATE "20110917"
  26. #define DRIVER_MAJOR 1
  27. #define DRIVER_MINOR 0
  28. #define DRIVER_PATCHLEVEL 0
  29. static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS;
  30. MODULE_PARM_DESC(num_crtc, "Number of overlays to use as CRTCs");
  31. module_param(num_crtc, int, 0600);
  32. /*
  33. * mode config funcs
  34. */
  35. /* Notes about mapping DSS and DRM entities:
  36. * CRTC: overlay
  37. * encoder: manager.. with some extension to allow one primary CRTC
  38. * and zero or more video CRTC's to be mapped to one encoder?
  39. * connector: dssdev.. manager can be attached/detached from different
  40. * devices
  41. */
  42. static void omap_fb_output_poll_changed(struct drm_device *dev)
  43. {
  44. struct omap_drm_private *priv = dev->dev_private;
  45. DBG("dev=%p", dev);
  46. if (priv->fbdev)
  47. drm_fb_helper_hotplug_event(priv->fbdev);
  48. }
  49. static const struct drm_mode_config_funcs omap_mode_config_funcs = {
  50. .fb_create = omap_framebuffer_create,
  51. .output_poll_changed = omap_fb_output_poll_changed,
  52. };
  53. static int get_connector_type(struct omap_dss_device *dssdev)
  54. {
  55. switch (dssdev->type) {
  56. case OMAP_DISPLAY_TYPE_HDMI:
  57. return DRM_MODE_CONNECTOR_HDMIA;
  58. case OMAP_DISPLAY_TYPE_DPI:
  59. if (!strcmp(dssdev->name, "dvi"))
  60. return DRM_MODE_CONNECTOR_DVID;
  61. /* fallthrough */
  62. default:
  63. return DRM_MODE_CONNECTOR_Unknown;
  64. }
  65. }
  66. static bool channel_used(struct drm_device *dev, enum omap_channel channel)
  67. {
  68. struct omap_drm_private *priv = dev->dev_private;
  69. int i;
  70. for (i = 0; i < priv->num_crtcs; i++) {
  71. struct drm_crtc *crtc = priv->crtcs[i];
  72. if (omap_crtc_channel(crtc) == channel)
  73. return true;
  74. }
  75. return false;
  76. }
  77. static int omap_modeset_init(struct drm_device *dev)
  78. {
  79. struct omap_drm_private *priv = dev->dev_private;
  80. struct omap_dss_device *dssdev = NULL;
  81. int num_ovls = dss_feat_get_num_ovls();
  82. int num_mgrs = dss_feat_get_num_mgrs();
  83. int num_crtcs;
  84. int i, id = 0;
  85. int r;
  86. omap_crtc_pre_init();
  87. drm_mode_config_init(dev);
  88. omap_drm_irq_install(dev);
  89. /*
  90. * We usually don't want to create a CRTC for each manager, at least
  91. * not until we have a way to expose private planes to userspace.
  92. * Otherwise there would not be enough video pipes left for drm planes.
  93. * We use the num_crtc argument to limit the number of crtcs we create.
  94. */
  95. num_crtcs = min3(num_crtc, num_mgrs, num_ovls);
  96. dssdev = NULL;
  97. for_each_dss_dev(dssdev) {
  98. struct drm_connector *connector;
  99. struct drm_encoder *encoder;
  100. enum omap_channel channel;
  101. struct omap_overlay_manager *mgr;
  102. if (!dssdev->driver) {
  103. dev_warn(dev->dev, "%s has no driver.. skipping it\n",
  104. dssdev->name);
  105. continue;
  106. }
  107. if (!(dssdev->driver->get_timings ||
  108. dssdev->driver->read_edid)) {
  109. dev_warn(dev->dev, "%s driver does not support "
  110. "get_timings or read_edid.. skipping it!\n",
  111. dssdev->name);
  112. continue;
  113. }
  114. r = dssdev->driver->connect(dssdev);
  115. if (r) {
  116. dev_err(dev->dev, "could not connect display: %s\n",
  117. dssdev->name);
  118. continue;
  119. }
  120. encoder = omap_encoder_init(dev, dssdev);
  121. if (!encoder) {
  122. dev_err(dev->dev, "could not create encoder: %s\n",
  123. dssdev->name);
  124. return -ENOMEM;
  125. }
  126. connector = omap_connector_init(dev,
  127. get_connector_type(dssdev), dssdev, encoder);
  128. if (!connector) {
  129. dev_err(dev->dev, "could not create connector: %s\n",
  130. dssdev->name);
  131. return -ENOMEM;
  132. }
  133. BUG_ON(priv->num_encoders >= ARRAY_SIZE(priv->encoders));
  134. BUG_ON(priv->num_connectors >= ARRAY_SIZE(priv->connectors));
  135. priv->encoders[priv->num_encoders++] = encoder;
  136. priv->connectors[priv->num_connectors++] = connector;
  137. drm_mode_connector_attach_encoder(connector, encoder);
  138. /*
  139. * if we have reached the limit of the crtcs we are allowed to
  140. * create, let's not try to look for a crtc for this
  141. * panel/encoder and onwards, we will, of course, populate the
  142. * the possible_crtcs field for all the encoders with the final
  143. * set of crtcs we create
  144. */
  145. if (id == num_crtcs)
  146. continue;
  147. /*
  148. * get the recommended DISPC channel for this encoder. For now,
  149. * we only try to get create a crtc out of the recommended, the
  150. * other possible channels to which the encoder can connect are
  151. * not considered.
  152. */
  153. mgr = omapdss_find_mgr_from_display(dssdev);
  154. channel = mgr->id;
  155. /*
  156. * if this channel hasn't already been taken by a previously
  157. * allocated crtc, we create a new crtc for it
  158. */
  159. if (!channel_used(dev, channel)) {
  160. struct drm_plane *plane;
  161. struct drm_crtc *crtc;
  162. plane = omap_plane_init(dev, id, true);
  163. crtc = omap_crtc_init(dev, plane, channel, id);
  164. BUG_ON(priv->num_crtcs >= ARRAY_SIZE(priv->crtcs));
  165. priv->crtcs[id] = crtc;
  166. priv->num_crtcs++;
  167. priv->planes[id] = plane;
  168. priv->num_planes++;
  169. id++;
  170. }
  171. }
  172. /*
  173. * we have allocated crtcs according to the need of the panels/encoders,
  174. * adding more crtcs here if needed
  175. */
  176. for (; id < num_crtcs; id++) {
  177. /* find a free manager for this crtc */
  178. for (i = 0; i < num_mgrs; i++) {
  179. if (!channel_used(dev, i)) {
  180. struct drm_plane *plane;
  181. struct drm_crtc *crtc;
  182. plane = omap_plane_init(dev, id, true);
  183. crtc = omap_crtc_init(dev, plane, i, id);
  184. BUG_ON(priv->num_crtcs >=
  185. ARRAY_SIZE(priv->crtcs));
  186. priv->crtcs[id] = crtc;
  187. priv->num_crtcs++;
  188. priv->planes[id] = plane;
  189. priv->num_planes++;
  190. break;
  191. } else {
  192. continue;
  193. }
  194. }
  195. if (i == num_mgrs) {
  196. /* this shouldn't really happen */
  197. dev_err(dev->dev, "no managers left for crtc\n");
  198. return -ENOMEM;
  199. }
  200. }
  201. /*
  202. * Create normal planes for the remaining overlays:
  203. */
  204. for (; id < num_ovls; id++) {
  205. struct drm_plane *plane = omap_plane_init(dev, id, false);
  206. BUG_ON(priv->num_planes >= ARRAY_SIZE(priv->planes));
  207. priv->planes[priv->num_planes++] = plane;
  208. }
  209. for (i = 0; i < priv->num_encoders; i++) {
  210. struct drm_encoder *encoder = priv->encoders[i];
  211. struct omap_dss_device *dssdev =
  212. omap_encoder_get_dssdev(encoder);
  213. struct omap_dss_device *output;
  214. output = omapdss_find_output_from_display(dssdev);
  215. /* figure out which crtc's we can connect the encoder to: */
  216. encoder->possible_crtcs = 0;
  217. for (id = 0; id < priv->num_crtcs; id++) {
  218. struct drm_crtc *crtc = priv->crtcs[id];
  219. enum omap_channel crtc_channel;
  220. enum omap_dss_output_id supported_outputs;
  221. crtc_channel = omap_crtc_channel(crtc);
  222. supported_outputs =
  223. dss_feat_get_supported_outputs(crtc_channel);
  224. if (supported_outputs & output->id)
  225. encoder->possible_crtcs |= (1 << id);
  226. }
  227. omap_dss_put_device(output);
  228. }
  229. DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n",
  230. priv->num_planes, priv->num_crtcs, priv->num_encoders,
  231. priv->num_connectors);
  232. dev->mode_config.min_width = 32;
  233. dev->mode_config.min_height = 32;
  234. /* note: eventually will need some cpu_is_omapXYZ() type stuff here
  235. * to fill in these limits properly on different OMAP generations..
  236. */
  237. dev->mode_config.max_width = 2048;
  238. dev->mode_config.max_height = 2048;
  239. dev->mode_config.funcs = &omap_mode_config_funcs;
  240. return 0;
  241. }
  242. static void omap_modeset_free(struct drm_device *dev)
  243. {
  244. drm_mode_config_cleanup(dev);
  245. }
  246. /*
  247. * drm ioctl funcs
  248. */
  249. static int ioctl_get_param(struct drm_device *dev, void *data,
  250. struct drm_file *file_priv)
  251. {
  252. struct omap_drm_private *priv = dev->dev_private;
  253. struct drm_omap_param *args = data;
  254. DBG("%p: param=%llu", dev, args->param);
  255. switch (args->param) {
  256. case OMAP_PARAM_CHIPSET_ID:
  257. args->value = priv->omaprev;
  258. break;
  259. default:
  260. DBG("unknown parameter %lld", args->param);
  261. return -EINVAL;
  262. }
  263. return 0;
  264. }
  265. static int ioctl_set_param(struct drm_device *dev, void *data,
  266. struct drm_file *file_priv)
  267. {
  268. struct drm_omap_param *args = data;
  269. switch (args->param) {
  270. default:
  271. DBG("unknown parameter %lld", args->param);
  272. return -EINVAL;
  273. }
  274. return 0;
  275. }
  276. static int ioctl_gem_new(struct drm_device *dev, void *data,
  277. struct drm_file *file_priv)
  278. {
  279. struct drm_omap_gem_new *args = data;
  280. VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv,
  281. args->size.bytes, args->flags);
  282. return omap_gem_new_handle(dev, file_priv, args->size,
  283. args->flags, &args->handle);
  284. }
  285. static int ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
  286. struct drm_file *file_priv)
  287. {
  288. struct drm_omap_gem_cpu_prep *args = data;
  289. struct drm_gem_object *obj;
  290. int ret;
  291. VERB("%p:%p: handle=%d, op=%x", dev, file_priv, args->handle, args->op);
  292. obj = drm_gem_object_lookup(dev, file_priv, args->handle);
  293. if (!obj)
  294. return -ENOENT;
  295. ret = omap_gem_op_sync(obj, args->op);
  296. if (!ret)
  297. ret = omap_gem_op_start(obj, args->op);
  298. drm_gem_object_unreference_unlocked(obj);
  299. return ret;
  300. }
  301. static int ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
  302. struct drm_file *file_priv)
  303. {
  304. struct drm_omap_gem_cpu_fini *args = data;
  305. struct drm_gem_object *obj;
  306. int ret;
  307. VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
  308. obj = drm_gem_object_lookup(dev, file_priv, args->handle);
  309. if (!obj)
  310. return -ENOENT;
  311. /* XXX flushy, flushy */
  312. ret = 0;
  313. if (!ret)
  314. ret = omap_gem_op_finish(obj, args->op);
  315. drm_gem_object_unreference_unlocked(obj);
  316. return ret;
  317. }
  318. static int ioctl_gem_info(struct drm_device *dev, void *data,
  319. struct drm_file *file_priv)
  320. {
  321. struct drm_omap_gem_info *args = data;
  322. struct drm_gem_object *obj;
  323. int ret = 0;
  324. VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
  325. obj = drm_gem_object_lookup(dev, file_priv, args->handle);
  326. if (!obj)
  327. return -ENOENT;
  328. args->size = omap_gem_mmap_size(obj);
  329. args->offset = omap_gem_mmap_offset(obj);
  330. drm_gem_object_unreference_unlocked(obj);
  331. return ret;
  332. }
  333. static struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
  334. DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, DRM_UNLOCKED|DRM_AUTH),
  335. DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  336. DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, DRM_UNLOCKED|DRM_AUTH),
  337. DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, DRM_UNLOCKED|DRM_AUTH),
  338. DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, DRM_UNLOCKED|DRM_AUTH),
  339. DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, DRM_UNLOCKED|DRM_AUTH),
  340. };
  341. /*
  342. * drm driver funcs
  343. */
  344. /**
  345. * load - setup chip and create an initial config
  346. * @dev: DRM device
  347. * @flags: startup flags
  348. *
  349. * The driver load routine has to do several things:
  350. * - initialize the memory manager
  351. * - allocate initial config memory
  352. * - setup the DRM framebuffer with the allocated memory
  353. */
  354. static int dev_load(struct drm_device *dev, unsigned long flags)
  355. {
  356. struct omap_drm_platform_data *pdata = dev->dev->platform_data;
  357. struct omap_drm_private *priv;
  358. int ret;
  359. DBG("load: dev=%p", dev);
  360. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  361. if (!priv)
  362. return -ENOMEM;
  363. priv->omaprev = pdata->omaprev;
  364. dev->dev_private = priv;
  365. priv->wq = alloc_ordered_workqueue("omapdrm", 0);
  366. INIT_LIST_HEAD(&priv->obj_list);
  367. omap_gem_init(dev);
  368. ret = omap_modeset_init(dev);
  369. if (ret) {
  370. dev_err(dev->dev, "omap_modeset_init failed: ret=%d\n", ret);
  371. dev->dev_private = NULL;
  372. kfree(priv);
  373. return ret;
  374. }
  375. ret = drm_vblank_init(dev, priv->num_crtcs);
  376. if (ret)
  377. dev_warn(dev->dev, "could not init vblank\n");
  378. priv->fbdev = omap_fbdev_init(dev);
  379. if (!priv->fbdev) {
  380. dev_warn(dev->dev, "omap_fbdev_init failed\n");
  381. /* well, limp along without an fbdev.. maybe X11 will work? */
  382. }
  383. /* store off drm_device for use in pm ops */
  384. dev_set_drvdata(dev->dev, dev);
  385. drm_kms_helper_poll_init(dev);
  386. return 0;
  387. }
  388. static int dev_unload(struct drm_device *dev)
  389. {
  390. struct omap_drm_private *priv = dev->dev_private;
  391. DBG("unload: dev=%p", dev);
  392. drm_kms_helper_poll_fini(dev);
  393. drm_vblank_cleanup(dev);
  394. omap_drm_irq_uninstall(dev);
  395. omap_fbdev_free(dev);
  396. omap_modeset_free(dev);
  397. omap_gem_deinit(dev);
  398. flush_workqueue(priv->wq);
  399. destroy_workqueue(priv->wq);
  400. kfree(dev->dev_private);
  401. dev->dev_private = NULL;
  402. dev_set_drvdata(dev->dev, NULL);
  403. return 0;
  404. }
  405. static int dev_open(struct drm_device *dev, struct drm_file *file)
  406. {
  407. file->driver_priv = NULL;
  408. DBG("open: dev=%p, file=%p", dev, file);
  409. return 0;
  410. }
  411. static int dev_firstopen(struct drm_device *dev)
  412. {
  413. DBG("firstopen: dev=%p", dev);
  414. return 0;
  415. }
  416. /**
  417. * lastclose - clean up after all DRM clients have exited
  418. * @dev: DRM device
  419. *
  420. * Take care of cleaning up after all DRM clients have exited. In the
  421. * mode setting case, we want to restore the kernel's initial mode (just
  422. * in case the last client left us in a bad state).
  423. */
  424. static void dev_lastclose(struct drm_device *dev)
  425. {
  426. int i;
  427. /* we don't support vga-switcheroo.. so just make sure the fbdev
  428. * mode is active
  429. */
  430. struct omap_drm_private *priv = dev->dev_private;
  431. int ret;
  432. DBG("lastclose: dev=%p", dev);
  433. if (priv->rotation_prop) {
  434. /* need to restore default rotation state.. not sure
  435. * if there is a cleaner way to restore properties to
  436. * default state? Maybe a flag that properties should
  437. * automatically be restored to default state on
  438. * lastclose?
  439. */
  440. for (i = 0; i < priv->num_crtcs; i++) {
  441. drm_object_property_set_value(&priv->crtcs[i]->base,
  442. priv->rotation_prop, 0);
  443. }
  444. for (i = 0; i < priv->num_planes; i++) {
  445. drm_object_property_set_value(&priv->planes[i]->base,
  446. priv->rotation_prop, 0);
  447. }
  448. }
  449. drm_modeset_lock_all(dev);
  450. ret = drm_fb_helper_restore_fbdev_mode(priv->fbdev);
  451. drm_modeset_unlock_all(dev);
  452. if (ret)
  453. DBG("failed to restore crtc mode");
  454. }
  455. static void dev_preclose(struct drm_device *dev, struct drm_file *file)
  456. {
  457. DBG("preclose: dev=%p", dev);
  458. }
  459. static void dev_postclose(struct drm_device *dev, struct drm_file *file)
  460. {
  461. DBG("postclose: dev=%p, file=%p", dev, file);
  462. }
  463. static const struct vm_operations_struct omap_gem_vm_ops = {
  464. .fault = omap_gem_fault,
  465. .open = drm_gem_vm_open,
  466. .close = drm_gem_vm_close,
  467. };
  468. static const struct file_operations omapdriver_fops = {
  469. .owner = THIS_MODULE,
  470. .open = drm_open,
  471. .unlocked_ioctl = drm_ioctl,
  472. .release = drm_release,
  473. .mmap = omap_gem_mmap,
  474. .poll = drm_poll,
  475. .fasync = drm_fasync,
  476. .read = drm_read,
  477. .llseek = noop_llseek,
  478. };
  479. static struct drm_driver omap_drm_driver = {
  480. .driver_features =
  481. DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
  482. .load = dev_load,
  483. .unload = dev_unload,
  484. .open = dev_open,
  485. .firstopen = dev_firstopen,
  486. .lastclose = dev_lastclose,
  487. .preclose = dev_preclose,
  488. .postclose = dev_postclose,
  489. .get_vblank_counter = drm_vblank_count,
  490. .enable_vblank = omap_irq_enable_vblank,
  491. .disable_vblank = omap_irq_disable_vblank,
  492. .irq_preinstall = omap_irq_preinstall,
  493. .irq_postinstall = omap_irq_postinstall,
  494. .irq_uninstall = omap_irq_uninstall,
  495. .irq_handler = omap_irq_handler,
  496. #ifdef CONFIG_DEBUG_FS
  497. .debugfs_init = omap_debugfs_init,
  498. .debugfs_cleanup = omap_debugfs_cleanup,
  499. #endif
  500. .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  501. .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  502. .gem_prime_export = omap_gem_prime_export,
  503. .gem_prime_import = omap_gem_prime_import,
  504. .gem_init_object = omap_gem_init_object,
  505. .gem_free_object = omap_gem_free_object,
  506. .gem_vm_ops = &omap_gem_vm_ops,
  507. .dumb_create = omap_gem_dumb_create,
  508. .dumb_map_offset = omap_gem_dumb_map_offset,
  509. .dumb_destroy = omap_gem_dumb_destroy,
  510. .ioctls = ioctls,
  511. .num_ioctls = DRM_OMAP_NUM_IOCTLS,
  512. .fops = &omapdriver_fops,
  513. .name = DRIVER_NAME,
  514. .desc = DRIVER_DESC,
  515. .date = DRIVER_DATE,
  516. .major = DRIVER_MAJOR,
  517. .minor = DRIVER_MINOR,
  518. .patchlevel = DRIVER_PATCHLEVEL,
  519. };
  520. static int pdev_suspend(struct platform_device *pDevice, pm_message_t state)
  521. {
  522. DBG("");
  523. return 0;
  524. }
  525. static int pdev_resume(struct platform_device *device)
  526. {
  527. DBG("");
  528. return 0;
  529. }
  530. static void pdev_shutdown(struct platform_device *device)
  531. {
  532. DBG("");
  533. }
  534. static int pdev_probe(struct platform_device *device)
  535. {
  536. if (omapdss_is_initialized() == false)
  537. return -EPROBE_DEFER;
  538. DBG("%s", device->name);
  539. return drm_platform_init(&omap_drm_driver, device);
  540. }
  541. static int pdev_remove(struct platform_device *device)
  542. {
  543. DBG("");
  544. drm_platform_exit(&omap_drm_driver, device);
  545. platform_driver_unregister(&omap_dmm_driver);
  546. return 0;
  547. }
  548. #ifdef CONFIG_PM
  549. static const struct dev_pm_ops omapdrm_pm_ops = {
  550. .resume = omap_gem_resume,
  551. };
  552. #endif
  553. static struct platform_driver pdev = {
  554. .driver = {
  555. .name = DRIVER_NAME,
  556. .owner = THIS_MODULE,
  557. #ifdef CONFIG_PM
  558. .pm = &omapdrm_pm_ops,
  559. #endif
  560. },
  561. .probe = pdev_probe,
  562. .remove = pdev_remove,
  563. .suspend = pdev_suspend,
  564. .resume = pdev_resume,
  565. .shutdown = pdev_shutdown,
  566. };
  567. static int __init omap_drm_init(void)
  568. {
  569. DBG("init");
  570. if (platform_driver_register(&omap_dmm_driver)) {
  571. /* we can continue on without DMM.. so not fatal */
  572. dev_err(NULL, "DMM registration failed\n");
  573. }
  574. return platform_driver_register(&pdev);
  575. }
  576. static void __exit omap_drm_fini(void)
  577. {
  578. DBG("fini");
  579. platform_driver_unregister(&pdev);
  580. }
  581. /* need late_initcall() so we load after dss_driver's are loaded */
  582. late_initcall(omap_drm_init);
  583. module_exit(omap_drm_fini);
  584. MODULE_AUTHOR("Rob Clark <rob@ti.com>");
  585. MODULE_DESCRIPTION("OMAP DRM Display Driver");
  586. MODULE_ALIAS("platform:" DRIVER_NAME);
  587. MODULE_LICENSE("GPL v2");