exynos_drm_vidi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /* exynos_drm_vidi.c
  2. *
  3. * Copyright (C) 2012 Samsung Electronics Co.Ltd
  4. * Authors:
  5. * Inki Dae <inki.dae@samsung.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 as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. */
  13. #include <drm/drmP.h>
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/platform_device.h>
  17. #include <drm/exynos_drm.h>
  18. #include <drm/drm_edid.h>
  19. #include <drm/drm_crtc_helper.h>
  20. #include "exynos_drm_drv.h"
  21. #include "exynos_drm_crtc.h"
  22. #include "exynos_drm_encoder.h"
  23. /* vidi has totally three virtual windows. */
  24. #define WINDOWS_NR 3
  25. #define get_vidi_context(dev) platform_get_drvdata(to_platform_device(dev))
  26. struct vidi_win_data {
  27. unsigned int offset_x;
  28. unsigned int offset_y;
  29. unsigned int ovl_width;
  30. unsigned int ovl_height;
  31. unsigned int fb_width;
  32. unsigned int fb_height;
  33. unsigned int bpp;
  34. dma_addr_t dma_addr;
  35. unsigned int buf_offsize;
  36. unsigned int line_size; /* bytes */
  37. bool enabled;
  38. };
  39. struct vidi_context {
  40. struct exynos_drm_subdrv subdrv;
  41. struct drm_crtc *crtc;
  42. struct vidi_win_data win_data[WINDOWS_NR];
  43. struct edid *raw_edid;
  44. unsigned int clkdiv;
  45. unsigned int default_win;
  46. unsigned long irq_flags;
  47. unsigned int connected;
  48. bool vblank_on;
  49. bool suspended;
  50. bool direct_vblank;
  51. struct work_struct work;
  52. struct mutex lock;
  53. };
  54. static const char fake_edid_info[] = {
  55. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x4c, 0x2d, 0x05, 0x05,
  56. 0x00, 0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78,
  57. 0x0a, 0xee, 0x91, 0xa3, 0x54, 0x4c, 0x99, 0x26, 0x0f, 0x50, 0x54, 0xbd,
  58. 0xee, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  59. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x66, 0x21, 0x50, 0xb0, 0x51, 0x00,
  60. 0x1b, 0x30, 0x40, 0x70, 0x36, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e,
  61. 0x01, 0x1d, 0x00, 0x72, 0x51, 0xd0, 0x1e, 0x20, 0x6e, 0x28, 0x55, 0x00,
  62. 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x18,
  63. 0x4b, 0x1a, 0x44, 0x17, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  64. 0x00, 0x00, 0x00, 0xfc, 0x00, 0x53, 0x41, 0x4d, 0x53, 0x55, 0x4e, 0x47,
  65. 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0xbc, 0x02, 0x03, 0x1e, 0xf1,
  66. 0x46, 0x84, 0x05, 0x03, 0x10, 0x20, 0x22, 0x23, 0x09, 0x07, 0x07, 0x83,
  67. 0x01, 0x00, 0x00, 0xe2, 0x00, 0x0f, 0x67, 0x03, 0x0c, 0x00, 0x10, 0x00,
  68. 0xb8, 0x2d, 0x01, 0x1d, 0x80, 0x18, 0x71, 0x1c, 0x16, 0x20, 0x58, 0x2c,
  69. 0x25, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x9e, 0x8c, 0x0a, 0xd0, 0x8a,
  70. 0x20, 0xe0, 0x2d, 0x10, 0x10, 0x3e, 0x96, 0x00, 0xa0, 0x5a, 0x00, 0x00,
  71. 0x00, 0x18, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, 0x58, 0x2c,
  72. 0x45, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
  73. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  74. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  75. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76. 0x00, 0x00, 0x00, 0x06
  77. };
  78. static bool vidi_display_is_connected(struct device *dev)
  79. {
  80. struct vidi_context *ctx = get_vidi_context(dev);
  81. DRM_DEBUG_KMS("%s\n", __FILE__);
  82. /*
  83. * connection request would come from user side
  84. * to do hotplug through specific ioctl.
  85. */
  86. return ctx->connected ? true : false;
  87. }
  88. static struct edid *vidi_get_edid(struct device *dev,
  89. struct drm_connector *connector)
  90. {
  91. struct vidi_context *ctx = get_vidi_context(dev);
  92. struct edid *edid;
  93. int edid_len;
  94. DRM_DEBUG_KMS("%s\n", __FILE__);
  95. /*
  96. * the edid data comes from user side and it would be set
  97. * to ctx->raw_edid through specific ioctl.
  98. */
  99. if (!ctx->raw_edid) {
  100. DRM_DEBUG_KMS("raw_edid is null.\n");
  101. return ERR_PTR(-EFAULT);
  102. }
  103. edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH;
  104. edid = kzalloc(edid_len, GFP_KERNEL);
  105. if (!edid) {
  106. DRM_DEBUG_KMS("failed to allocate edid\n");
  107. return ERR_PTR(-ENOMEM);
  108. }
  109. memcpy(edid, ctx->raw_edid, edid_len);
  110. return edid;
  111. }
  112. static void *vidi_get_panel(struct device *dev)
  113. {
  114. DRM_DEBUG_KMS("%s\n", __FILE__);
  115. /* TODO. */
  116. return NULL;
  117. }
  118. static int vidi_check_timing(struct device *dev, void *timing)
  119. {
  120. DRM_DEBUG_KMS("%s\n", __FILE__);
  121. /* TODO. */
  122. return 0;
  123. }
  124. static int vidi_display_power_on(struct device *dev, int mode)
  125. {
  126. DRM_DEBUG_KMS("%s\n", __FILE__);
  127. /* TODO */
  128. return 0;
  129. }
  130. static struct exynos_drm_display_ops vidi_display_ops = {
  131. .type = EXYNOS_DISPLAY_TYPE_VIDI,
  132. .is_connected = vidi_display_is_connected,
  133. .get_edid = vidi_get_edid,
  134. .get_panel = vidi_get_panel,
  135. .check_timing = vidi_check_timing,
  136. .power_on = vidi_display_power_on,
  137. };
  138. static void vidi_dpms(struct device *subdrv_dev, int mode)
  139. {
  140. struct vidi_context *ctx = get_vidi_context(subdrv_dev);
  141. DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode);
  142. mutex_lock(&ctx->lock);
  143. switch (mode) {
  144. case DRM_MODE_DPMS_ON:
  145. /* TODO. */
  146. break;
  147. case DRM_MODE_DPMS_STANDBY:
  148. case DRM_MODE_DPMS_SUSPEND:
  149. case DRM_MODE_DPMS_OFF:
  150. /* TODO. */
  151. break;
  152. default:
  153. DRM_DEBUG_KMS("unspecified mode %d\n", mode);
  154. break;
  155. }
  156. mutex_unlock(&ctx->lock);
  157. }
  158. static void vidi_apply(struct device *subdrv_dev)
  159. {
  160. struct vidi_context *ctx = get_vidi_context(subdrv_dev);
  161. struct exynos_drm_manager *mgr = ctx->subdrv.manager;
  162. struct exynos_drm_manager_ops *mgr_ops = mgr->ops;
  163. struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops;
  164. struct vidi_win_data *win_data;
  165. int i;
  166. DRM_DEBUG_KMS("%s\n", __FILE__);
  167. for (i = 0; i < WINDOWS_NR; i++) {
  168. win_data = &ctx->win_data[i];
  169. if (win_data->enabled && (ovl_ops && ovl_ops->commit))
  170. ovl_ops->commit(subdrv_dev, i);
  171. }
  172. if (mgr_ops && mgr_ops->commit)
  173. mgr_ops->commit(subdrv_dev);
  174. }
  175. static void vidi_commit(struct device *dev)
  176. {
  177. struct vidi_context *ctx = get_vidi_context(dev);
  178. DRM_DEBUG_KMS("%s\n", __FILE__);
  179. if (ctx->suspended)
  180. return;
  181. }
  182. static int vidi_enable_vblank(struct device *dev)
  183. {
  184. struct vidi_context *ctx = get_vidi_context(dev);
  185. DRM_DEBUG_KMS("%s\n", __FILE__);
  186. if (ctx->suspended)
  187. return -EPERM;
  188. if (!test_and_set_bit(0, &ctx->irq_flags))
  189. ctx->vblank_on = true;
  190. ctx->direct_vblank = true;
  191. /*
  192. * in case of page flip request, vidi_finish_pageflip function
  193. * will not be called because direct_vblank is true and then
  194. * that function will be called by overlay_ops->commit callback
  195. */
  196. schedule_work(&ctx->work);
  197. return 0;
  198. }
  199. static void vidi_disable_vblank(struct device *dev)
  200. {
  201. struct vidi_context *ctx = get_vidi_context(dev);
  202. DRM_DEBUG_KMS("%s\n", __FILE__);
  203. if (ctx->suspended)
  204. return;
  205. if (test_and_clear_bit(0, &ctx->irq_flags))
  206. ctx->vblank_on = false;
  207. }
  208. static struct exynos_drm_manager_ops vidi_manager_ops = {
  209. .dpms = vidi_dpms,
  210. .apply = vidi_apply,
  211. .commit = vidi_commit,
  212. .enable_vblank = vidi_enable_vblank,
  213. .disable_vblank = vidi_disable_vblank,
  214. };
  215. static void vidi_win_mode_set(struct device *dev,
  216. struct exynos_drm_overlay *overlay)
  217. {
  218. struct vidi_context *ctx = get_vidi_context(dev);
  219. struct vidi_win_data *win_data;
  220. int win;
  221. unsigned long offset;
  222. DRM_DEBUG_KMS("%s\n", __FILE__);
  223. if (!overlay) {
  224. dev_err(dev, "overlay is NULL\n");
  225. return;
  226. }
  227. win = overlay->zpos;
  228. if (win == DEFAULT_ZPOS)
  229. win = ctx->default_win;
  230. if (win < 0 || win > WINDOWS_NR)
  231. return;
  232. offset = overlay->fb_x * (overlay->bpp >> 3);
  233. offset += overlay->fb_y * overlay->pitch;
  234. DRM_DEBUG_KMS("offset = 0x%lx, pitch = %x\n", offset, overlay->pitch);
  235. win_data = &ctx->win_data[win];
  236. win_data->offset_x = overlay->crtc_x;
  237. win_data->offset_y = overlay->crtc_y;
  238. win_data->ovl_width = overlay->crtc_width;
  239. win_data->ovl_height = overlay->crtc_height;
  240. win_data->fb_width = overlay->fb_width;
  241. win_data->fb_height = overlay->fb_height;
  242. win_data->dma_addr = overlay->dma_addr[0] + offset;
  243. win_data->bpp = overlay->bpp;
  244. win_data->buf_offsize = (overlay->fb_width - overlay->crtc_width) *
  245. (overlay->bpp >> 3);
  246. win_data->line_size = overlay->crtc_width * (overlay->bpp >> 3);
  247. /*
  248. * some parts of win_data should be transferred to user side
  249. * through specific ioctl.
  250. */
  251. DRM_DEBUG_KMS("offset_x = %d, offset_y = %d\n",
  252. win_data->offset_x, win_data->offset_y);
  253. DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
  254. win_data->ovl_width, win_data->ovl_height);
  255. DRM_DEBUG_KMS("paddr = 0x%lx\n", (unsigned long)win_data->dma_addr);
  256. DRM_DEBUG_KMS("fb_width = %d, crtc_width = %d\n",
  257. overlay->fb_width, overlay->crtc_width);
  258. }
  259. static void vidi_win_commit(struct device *dev, int zpos)
  260. {
  261. struct vidi_context *ctx = get_vidi_context(dev);
  262. struct vidi_win_data *win_data;
  263. int win = zpos;
  264. DRM_DEBUG_KMS("%s\n", __FILE__);
  265. if (ctx->suspended)
  266. return;
  267. if (win == DEFAULT_ZPOS)
  268. win = ctx->default_win;
  269. if (win < 0 || win > WINDOWS_NR)
  270. return;
  271. win_data = &ctx->win_data[win];
  272. win_data->enabled = true;
  273. DRM_DEBUG_KMS("dma_addr = 0x%x\n", win_data->dma_addr);
  274. if (ctx->vblank_on)
  275. schedule_work(&ctx->work);
  276. }
  277. static void vidi_win_disable(struct device *dev, int zpos)
  278. {
  279. struct vidi_context *ctx = get_vidi_context(dev);
  280. struct vidi_win_data *win_data;
  281. int win = zpos;
  282. DRM_DEBUG_KMS("%s\n", __FILE__);
  283. if (win == DEFAULT_ZPOS)
  284. win = ctx->default_win;
  285. if (win < 0 || win > WINDOWS_NR)
  286. return;
  287. win_data = &ctx->win_data[win];
  288. win_data->enabled = false;
  289. /* TODO. */
  290. }
  291. static struct exynos_drm_overlay_ops vidi_overlay_ops = {
  292. .mode_set = vidi_win_mode_set,
  293. .commit = vidi_win_commit,
  294. .disable = vidi_win_disable,
  295. };
  296. static struct exynos_drm_manager vidi_manager = {
  297. .pipe = -1,
  298. .ops = &vidi_manager_ops,
  299. .overlay_ops = &vidi_overlay_ops,
  300. .display_ops = &vidi_display_ops,
  301. };
  302. static void vidi_fake_vblank_handler(struct work_struct *work)
  303. {
  304. struct vidi_context *ctx = container_of(work, struct vidi_context,
  305. work);
  306. struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
  307. struct exynos_drm_manager *manager = subdrv->manager;
  308. if (manager->pipe < 0)
  309. return;
  310. /* refresh rate is about 50Hz. */
  311. usleep_range(16000, 20000);
  312. mutex_lock(&ctx->lock);
  313. if (ctx->direct_vblank) {
  314. drm_handle_vblank(subdrv->drm_dev, manager->pipe);
  315. ctx->direct_vblank = false;
  316. mutex_unlock(&ctx->lock);
  317. return;
  318. }
  319. mutex_unlock(&ctx->lock);
  320. exynos_drm_crtc_finish_pageflip(subdrv->drm_dev, manager->pipe);
  321. }
  322. static int vidi_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
  323. {
  324. DRM_DEBUG_KMS("%s\n", __FILE__);
  325. /*
  326. * enable drm irq mode.
  327. * - with irq_enabled = 1, we can use the vblank feature.
  328. *
  329. * P.S. note that we wouldn't use drm irq handler but
  330. * just specific driver own one instead because
  331. * drm framework supports only one irq handler.
  332. */
  333. drm_dev->irq_enabled = 1;
  334. /*
  335. * with vblank_disable_allowed = 1, vblank interrupt will be disabled
  336. * by drm timer once a current process gives up ownership of
  337. * vblank event.(after drm_vblank_put function is called)
  338. */
  339. drm_dev->vblank_disable_allowed = 1;
  340. return 0;
  341. }
  342. static void vidi_subdrv_remove(struct drm_device *drm_dev, struct device *dev)
  343. {
  344. DRM_DEBUG_KMS("%s\n", __FILE__);
  345. /* TODO. */
  346. }
  347. static int vidi_power_on(struct vidi_context *ctx, bool enable)
  348. {
  349. struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
  350. struct device *dev = subdrv->dev;
  351. DRM_DEBUG_KMS("%s\n", __FILE__);
  352. if (enable != false && enable != true)
  353. return -EINVAL;
  354. if (enable) {
  355. ctx->suspended = false;
  356. /* if vblank was enabled status, enable it again. */
  357. if (test_and_clear_bit(0, &ctx->irq_flags))
  358. vidi_enable_vblank(dev);
  359. vidi_apply(dev);
  360. } else {
  361. ctx->suspended = true;
  362. }
  363. return 0;
  364. }
  365. static int vidi_show_connection(struct device *dev,
  366. struct device_attribute *attr, char *buf)
  367. {
  368. int rc;
  369. struct vidi_context *ctx = get_vidi_context(dev);
  370. mutex_lock(&ctx->lock);
  371. rc = sprintf(buf, "%d\n", ctx->connected);
  372. mutex_unlock(&ctx->lock);
  373. return rc;
  374. }
  375. static int vidi_store_connection(struct device *dev,
  376. struct device_attribute *attr,
  377. const char *buf, size_t len)
  378. {
  379. struct vidi_context *ctx = get_vidi_context(dev);
  380. int ret;
  381. DRM_DEBUG_KMS("%s\n", __FILE__);
  382. ret = kstrtoint(buf, 0, &ctx->connected);
  383. if (ret)
  384. return ret;
  385. if (ctx->connected > 1)
  386. return -EINVAL;
  387. /* use fake edid data for test. */
  388. if (!ctx->raw_edid)
  389. ctx->raw_edid = (struct edid *)fake_edid_info;
  390. /* if raw_edid isn't same as fake data then it can't be tested. */
  391. if (ctx->raw_edid != (struct edid *)fake_edid_info) {
  392. DRM_DEBUG_KMS("edid data is not fake data.\n");
  393. return -EINVAL;
  394. }
  395. DRM_DEBUG_KMS("requested connection.\n");
  396. drm_helper_hpd_irq_event(ctx->subdrv.drm_dev);
  397. return len;
  398. }
  399. static DEVICE_ATTR(connection, 0644, vidi_show_connection,
  400. vidi_store_connection);
  401. int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
  402. struct drm_file *file_priv)
  403. {
  404. struct vidi_context *ctx = NULL;
  405. struct drm_encoder *encoder;
  406. struct exynos_drm_manager *manager;
  407. struct exynos_drm_display_ops *display_ops;
  408. struct drm_exynos_vidi_connection *vidi = data;
  409. int edid_len;
  410. DRM_DEBUG_KMS("%s\n", __FILE__);
  411. if (!vidi) {
  412. DRM_DEBUG_KMS("user data for vidi is null.\n");
  413. return -EINVAL;
  414. }
  415. if (vidi->connection > 1) {
  416. DRM_DEBUG_KMS("connection should be 0 or 1.\n");
  417. return -EINVAL;
  418. }
  419. list_for_each_entry(encoder, &drm_dev->mode_config.encoder_list,
  420. head) {
  421. manager = exynos_drm_get_manager(encoder);
  422. display_ops = manager->display_ops;
  423. if (display_ops->type == EXYNOS_DISPLAY_TYPE_VIDI) {
  424. ctx = get_vidi_context(manager->dev);
  425. break;
  426. }
  427. }
  428. if (!ctx) {
  429. DRM_DEBUG_KMS("not found virtual device type encoder.\n");
  430. return -EINVAL;
  431. }
  432. if (ctx->connected == vidi->connection) {
  433. DRM_DEBUG_KMS("same connection request.\n");
  434. return -EINVAL;
  435. }
  436. if (vidi->connection) {
  437. struct edid *raw_edid = (struct edid *)(uint32_t)vidi->edid;
  438. if (!drm_edid_is_valid(raw_edid)) {
  439. DRM_DEBUG_KMS("edid data is invalid.\n");
  440. return -EINVAL;
  441. }
  442. edid_len = (1 + raw_edid->extensions) * EDID_LENGTH;
  443. ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL);
  444. if (!ctx->raw_edid) {
  445. DRM_DEBUG_KMS("failed to allocate raw_edid.\n");
  446. return -ENOMEM;
  447. }
  448. memcpy(ctx->raw_edid, raw_edid, edid_len);
  449. } else {
  450. /*
  451. * with connection = 0, free raw_edid
  452. * only if raw edid data isn't same as fake data.
  453. */
  454. if (ctx->raw_edid && ctx->raw_edid !=
  455. (struct edid *)fake_edid_info) {
  456. kfree(ctx->raw_edid);
  457. ctx->raw_edid = NULL;
  458. }
  459. }
  460. ctx->connected = vidi->connection;
  461. drm_helper_hpd_irq_event(ctx->subdrv.drm_dev);
  462. return 0;
  463. }
  464. static int vidi_probe(struct platform_device *pdev)
  465. {
  466. struct device *dev = &pdev->dev;
  467. struct vidi_context *ctx;
  468. struct exynos_drm_subdrv *subdrv;
  469. int ret;
  470. DRM_DEBUG_KMS("%s\n", __FILE__);
  471. ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
  472. if (!ctx)
  473. return -ENOMEM;
  474. ctx->default_win = 0;
  475. INIT_WORK(&ctx->work, vidi_fake_vblank_handler);
  476. subdrv = &ctx->subdrv;
  477. subdrv->dev = dev;
  478. subdrv->manager = &vidi_manager;
  479. subdrv->probe = vidi_subdrv_probe;
  480. subdrv->remove = vidi_subdrv_remove;
  481. mutex_init(&ctx->lock);
  482. platform_set_drvdata(pdev, ctx);
  483. ret = device_create_file(&pdev->dev, &dev_attr_connection);
  484. if (ret < 0)
  485. DRM_INFO("failed to create connection sysfs.\n");
  486. exynos_drm_subdrv_register(subdrv);
  487. return 0;
  488. }
  489. static int vidi_remove(struct platform_device *pdev)
  490. {
  491. struct vidi_context *ctx = platform_get_drvdata(pdev);
  492. DRM_DEBUG_KMS("%s\n", __FILE__);
  493. exynos_drm_subdrv_unregister(&ctx->subdrv);
  494. if (ctx->raw_edid != (struct edid *)fake_edid_info) {
  495. kfree(ctx->raw_edid);
  496. ctx->raw_edid = NULL;
  497. }
  498. return 0;
  499. }
  500. #ifdef CONFIG_PM_SLEEP
  501. static int vidi_suspend(struct device *dev)
  502. {
  503. struct vidi_context *ctx = get_vidi_context(dev);
  504. return vidi_power_on(ctx, false);
  505. }
  506. static int vidi_resume(struct device *dev)
  507. {
  508. struct vidi_context *ctx = get_vidi_context(dev);
  509. return vidi_power_on(ctx, true);
  510. }
  511. #endif
  512. static const struct dev_pm_ops vidi_pm_ops = {
  513. SET_SYSTEM_SLEEP_PM_OPS(vidi_suspend, vidi_resume)
  514. };
  515. struct platform_driver vidi_driver = {
  516. .probe = vidi_probe,
  517. .remove = vidi_remove,
  518. .driver = {
  519. .name = "exynos-drm-vidi",
  520. .owner = THIS_MODULE,
  521. .pm = &vidi_pm_ops,
  522. },
  523. };