msm_fb.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /* drivers/video/msm/msm_fb.c
  2. *
  3. * Core MSM framebuffer driver.
  4. *
  5. * Copyright (C) 2007 Google Incorporated
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <linux/platform_device.h>
  17. #include <linux/module.h>
  18. #include <linux/fb.h>
  19. #include <linux/delay.h>
  20. #include <linux/freezer.h>
  21. #include <linux/wait.h>
  22. #include <linux/msm_mdp.h>
  23. #include <linux/io.h>
  24. #include <linux/uaccess.h>
  25. #include <mach/msm_fb.h>
  26. #include <mach/board.h>
  27. #include <linux/workqueue.h>
  28. #include <linux/clk.h>
  29. #include <linux/debugfs.h>
  30. #include <linux/dma-mapping.h>
  31. #define PRINT_FPS 0
  32. #define PRINT_BLIT_TIME 0
  33. #define SLEEPING 0x4
  34. #define UPDATING 0x3
  35. #define FULL_UPDATE_DONE 0x2
  36. #define WAKING 0x1
  37. #define AWAKE 0x0
  38. #define NONE 0
  39. #define SUSPEND_RESUME 0x1
  40. #define FPS 0x2
  41. #define BLIT_TIME 0x4
  42. #define SHOW_UPDATES 0x8
  43. #define DLOG(mask, fmt, args...) \
  44. do { \
  45. if (msmfb_debug_mask & mask) \
  46. printk(KERN_INFO "msmfb: "fmt, ##args); \
  47. } while (0)
  48. static int msmfb_debug_mask;
  49. module_param_named(msmfb_debug_mask, msmfb_debug_mask, int,
  50. S_IRUGO | S_IWUSR | S_IWGRP);
  51. struct mdp_device *mdp;
  52. struct msmfb_info {
  53. struct fb_info *fb;
  54. struct msm_panel_data *panel;
  55. int xres;
  56. int yres;
  57. unsigned output_format;
  58. unsigned yoffset;
  59. unsigned frame_requested;
  60. unsigned frame_done;
  61. int sleeping;
  62. unsigned update_frame;
  63. struct {
  64. int left;
  65. int top;
  66. int eright; /* exclusive */
  67. int ebottom; /* exclusive */
  68. } update_info;
  69. char *black;
  70. spinlock_t update_lock;
  71. struct mutex panel_init_lock;
  72. wait_queue_head_t frame_wq;
  73. struct workqueue_struct *resume_workqueue;
  74. struct work_struct resume_work;
  75. struct msmfb_callback dma_callback;
  76. struct msmfb_callback vsync_callback;
  77. struct hrtimer fake_vsync;
  78. ktime_t vsync_request_time;
  79. };
  80. static int msmfb_open(struct fb_info *info, int user)
  81. {
  82. return 0;
  83. }
  84. static int msmfb_release(struct fb_info *info, int user)
  85. {
  86. return 0;
  87. }
  88. /* Called from dma interrupt handler, must not sleep */
  89. static void msmfb_handle_dma_interrupt(struct msmfb_callback *callback)
  90. {
  91. unsigned long irq_flags;
  92. struct msmfb_info *msmfb = container_of(callback, struct msmfb_info,
  93. dma_callback);
  94. spin_lock_irqsave(&msmfb->update_lock, irq_flags);
  95. msmfb->frame_done = msmfb->frame_requested;
  96. if (msmfb->sleeping == UPDATING &&
  97. msmfb->frame_done == msmfb->update_frame) {
  98. DLOG(SUSPEND_RESUME, "full update completed\n");
  99. queue_work(msmfb->resume_workqueue, &msmfb->resume_work);
  100. }
  101. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  102. wake_up(&msmfb->frame_wq);
  103. }
  104. static int msmfb_start_dma(struct msmfb_info *msmfb)
  105. {
  106. uint32_t x, y, w, h;
  107. unsigned addr;
  108. unsigned long irq_flags;
  109. uint32_t yoffset;
  110. s64 time_since_request;
  111. struct msm_panel_data *panel = msmfb->panel;
  112. spin_lock_irqsave(&msmfb->update_lock, irq_flags);
  113. time_since_request = ktime_to_ns(ktime_sub(ktime_get(),
  114. msmfb->vsync_request_time));
  115. if (time_since_request > 20 * NSEC_PER_MSEC) {
  116. uint32_t us;
  117. us = do_div(time_since_request, NSEC_PER_MSEC) / NSEC_PER_USEC;
  118. printk(KERN_WARNING "msmfb_start_dma %lld.%03u ms after vsync "
  119. "request\n", time_since_request, us);
  120. }
  121. if (msmfb->frame_done == msmfb->frame_requested) {
  122. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  123. return -1;
  124. }
  125. if (msmfb->sleeping == SLEEPING) {
  126. DLOG(SUSPEND_RESUME, "tried to start dma while asleep\n");
  127. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  128. return -1;
  129. }
  130. x = msmfb->update_info.left;
  131. y = msmfb->update_info.top;
  132. w = msmfb->update_info.eright - x;
  133. h = msmfb->update_info.ebottom - y;
  134. yoffset = msmfb->yoffset;
  135. msmfb->update_info.left = msmfb->xres + 1;
  136. msmfb->update_info.top = msmfb->yres + 1;
  137. msmfb->update_info.eright = 0;
  138. msmfb->update_info.ebottom = 0;
  139. if (unlikely(w > msmfb->xres || h > msmfb->yres ||
  140. w == 0 || h == 0)) {
  141. printk(KERN_INFO "invalid update: %d %d %d "
  142. "%d\n", x, y, w, h);
  143. msmfb->frame_done = msmfb->frame_requested;
  144. goto error;
  145. }
  146. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  147. addr = ((msmfb->xres * (yoffset + y) + x) * 2);
  148. mdp->dma(mdp, addr + msmfb->fb->fix.smem_start,
  149. msmfb->xres * 2, w, h, x, y, &msmfb->dma_callback,
  150. panel->interface_type);
  151. return 0;
  152. error:
  153. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  154. /* some clients need to clear their vsync interrupt */
  155. if (panel->clear_vsync)
  156. panel->clear_vsync(panel);
  157. wake_up(&msmfb->frame_wq);
  158. return 0;
  159. }
  160. /* Called from esync interrupt handler, must not sleep */
  161. static void msmfb_handle_vsync_interrupt(struct msmfb_callback *callback)
  162. {
  163. struct msmfb_info *msmfb = container_of(callback, struct msmfb_info,
  164. vsync_callback);
  165. msmfb_start_dma(msmfb);
  166. }
  167. static enum hrtimer_restart msmfb_fake_vsync(struct hrtimer *timer)
  168. {
  169. struct msmfb_info *msmfb = container_of(timer, struct msmfb_info,
  170. fake_vsync);
  171. msmfb_start_dma(msmfb);
  172. return HRTIMER_NORESTART;
  173. }
  174. static void msmfb_pan_update(struct fb_info *info, uint32_t left, uint32_t top,
  175. uint32_t eright, uint32_t ebottom,
  176. uint32_t yoffset, int pan_display)
  177. {
  178. struct msmfb_info *msmfb = info->par;
  179. struct msm_panel_data *panel = msmfb->panel;
  180. unsigned long irq_flags;
  181. int sleeping;
  182. int retry = 1;
  183. DLOG(SHOW_UPDATES, "update %d %d %d %d %d %d\n",
  184. left, top, eright, ebottom, yoffset, pan_display);
  185. restart:
  186. spin_lock_irqsave(&msmfb->update_lock, irq_flags);
  187. /* if we are sleeping, on a pan_display wait 10ms (to throttle back
  188. * drawing otherwise return */
  189. if (msmfb->sleeping == SLEEPING) {
  190. DLOG(SUSPEND_RESUME, "drawing while asleep\n");
  191. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  192. if (pan_display)
  193. wait_event_interruptible_timeout(msmfb->frame_wq,
  194. msmfb->sleeping != SLEEPING, HZ/10);
  195. return;
  196. }
  197. sleeping = msmfb->sleeping;
  198. /* on a full update, if the last frame has not completed, wait for it */
  199. if (pan_display && (msmfb->frame_requested != msmfb->frame_done ||
  200. sleeping == UPDATING)) {
  201. int ret;
  202. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  203. ret = wait_event_interruptible_timeout(msmfb->frame_wq,
  204. msmfb->frame_done == msmfb->frame_requested &&
  205. msmfb->sleeping != UPDATING, 5 * HZ);
  206. if (ret <= 0 && (msmfb->frame_requested != msmfb->frame_done ||
  207. msmfb->sleeping == UPDATING)) {
  208. if (retry && panel->request_vsync &&
  209. (sleeping == AWAKE)) {
  210. panel->request_vsync(panel,
  211. &msmfb->vsync_callback);
  212. retry = 0;
  213. printk(KERN_WARNING "msmfb_pan_display timeout "
  214. "rerequest vsync\n");
  215. } else {
  216. printk(KERN_WARNING "msmfb_pan_display timeout "
  217. "waiting for frame start, %d %d\n",
  218. msmfb->frame_requested,
  219. msmfb->frame_done);
  220. return;
  221. }
  222. }
  223. goto restart;
  224. }
  225. msmfb->frame_requested++;
  226. /* if necessary, update the y offset, if this is the
  227. * first full update on resume, set the sleeping state */
  228. if (pan_display) {
  229. msmfb->yoffset = yoffset;
  230. if (left == 0 && top == 0 && eright == info->var.xres &&
  231. ebottom == info->var.yres) {
  232. if (sleeping == WAKING) {
  233. msmfb->update_frame = msmfb->frame_requested;
  234. DLOG(SUSPEND_RESUME, "full update starting\n");
  235. msmfb->sleeping = UPDATING;
  236. }
  237. }
  238. }
  239. /* set the update request */
  240. if (left < msmfb->update_info.left)
  241. msmfb->update_info.left = left;
  242. if (top < msmfb->update_info.top)
  243. msmfb->update_info.top = top;
  244. if (eright > msmfb->update_info.eright)
  245. msmfb->update_info.eright = eright;
  246. if (ebottom > msmfb->update_info.ebottom)
  247. msmfb->update_info.ebottom = ebottom;
  248. DLOG(SHOW_UPDATES, "update queued %d %d %d %d %d\n",
  249. msmfb->update_info.left, msmfb->update_info.top,
  250. msmfb->update_info.eright, msmfb->update_info.ebottom,
  251. msmfb->yoffset);
  252. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  253. /* if the panel is all the way on wait for vsync, otherwise sleep
  254. * for 16 ms (long enough for the dma to panel) and then begin dma */
  255. msmfb->vsync_request_time = ktime_get();
  256. if (panel->request_vsync && (sleeping == AWAKE)) {
  257. panel->request_vsync(panel, &msmfb->vsync_callback);
  258. } else {
  259. if (!hrtimer_active(&msmfb->fake_vsync)) {
  260. hrtimer_start(&msmfb->fake_vsync,
  261. ktime_set(0, NSEC_PER_SEC/60),
  262. HRTIMER_MODE_REL);
  263. }
  264. }
  265. }
  266. static void msmfb_update(struct fb_info *info, uint32_t left, uint32_t top,
  267. uint32_t eright, uint32_t ebottom)
  268. {
  269. msmfb_pan_update(info, left, top, eright, ebottom, 0, 0);
  270. }
  271. static void power_on_panel(struct work_struct *work)
  272. {
  273. struct msmfb_info *msmfb =
  274. container_of(work, struct msmfb_info, resume_work);
  275. struct msm_panel_data *panel = msmfb->panel;
  276. unsigned long irq_flags;
  277. mutex_lock(&msmfb->panel_init_lock);
  278. DLOG(SUSPEND_RESUME, "turning on panel\n");
  279. if (msmfb->sleeping == UPDATING) {
  280. if (panel->unblank(panel)) {
  281. printk(KERN_INFO "msmfb: panel unblank failed,"
  282. "not starting drawing\n");
  283. goto error;
  284. }
  285. spin_lock_irqsave(&msmfb->update_lock, irq_flags);
  286. msmfb->sleeping = AWAKE;
  287. wake_up(&msmfb->frame_wq);
  288. spin_unlock_irqrestore(&msmfb->update_lock, irq_flags);
  289. }
  290. error:
  291. mutex_unlock(&msmfb->panel_init_lock);
  292. }
  293. static int msmfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  294. {
  295. if ((var->xres != info->var.xres) ||
  296. (var->yres != info->var.yres) ||
  297. (var->xres_virtual != info->var.xres_virtual) ||
  298. (var->yres_virtual != info->var.yres_virtual) ||
  299. (var->xoffset != info->var.xoffset) ||
  300. (var->bits_per_pixel != info->var.bits_per_pixel) ||
  301. (var->grayscale != info->var.grayscale))
  302. return -EINVAL;
  303. return 0;
  304. }
  305. int msmfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
  306. {
  307. struct msmfb_info *msmfb = info->par;
  308. struct msm_panel_data *panel = msmfb->panel;
  309. /* "UPDT" */
  310. if ((panel->caps & MSMFB_CAP_PARTIAL_UPDATES) &&
  311. (var->reserved[0] == 0x54445055)) {
  312. msmfb_pan_update(info, var->reserved[1] & 0xffff,
  313. var->reserved[1] >> 16,
  314. var->reserved[2] & 0xffff,
  315. var->reserved[2] >> 16, var->yoffset, 1);
  316. } else {
  317. msmfb_pan_update(info, 0, 0, info->var.xres, info->var.yres,
  318. var->yoffset, 1);
  319. }
  320. return 0;
  321. }
  322. static void msmfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
  323. {
  324. cfb_fillrect(p, rect);
  325. msmfb_update(p, rect->dx, rect->dy, rect->dx + rect->width,
  326. rect->dy + rect->height);
  327. }
  328. static void msmfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
  329. {
  330. cfb_copyarea(p, area);
  331. msmfb_update(p, area->dx, area->dy, area->dx + area->width,
  332. area->dy + area->height);
  333. }
  334. static void msmfb_imageblit(struct fb_info *p, const struct fb_image *image)
  335. {
  336. cfb_imageblit(p, image);
  337. msmfb_update(p, image->dx, image->dy, image->dx + image->width,
  338. image->dy + image->height);
  339. }
  340. static int msmfb_blit(struct fb_info *info,
  341. void __user *p)
  342. {
  343. struct mdp_blit_req req;
  344. struct mdp_blit_req_list req_list;
  345. int i;
  346. int ret;
  347. if (copy_from_user(&req_list, p, sizeof(req_list)))
  348. return -EFAULT;
  349. for (i = 0; i < req_list.count; i++) {
  350. struct mdp_blit_req_list *list =
  351. (struct mdp_blit_req_list *)p;
  352. if (copy_from_user(&req, &list->req[i], sizeof(req)))
  353. return -EFAULT;
  354. ret = mdp->blit(mdp, info, &req);
  355. if (ret)
  356. return ret;
  357. }
  358. return 0;
  359. }
  360. DEFINE_MUTEX(mdp_ppp_lock);
  361. static int msmfb_ioctl(struct fb_info *p, unsigned int cmd, unsigned long arg)
  362. {
  363. void __user *argp = (void __user *)arg;
  364. int ret;
  365. switch (cmd) {
  366. case MSMFB_GRP_DISP:
  367. mdp->set_grp_disp(mdp, arg);
  368. break;
  369. case MSMFB_BLIT:
  370. ret = msmfb_blit(p, argp);
  371. if (ret)
  372. return ret;
  373. break;
  374. default:
  375. printk(KERN_INFO "msmfb unknown ioctl: %d\n", cmd);
  376. return -EINVAL;
  377. }
  378. return 0;
  379. }
  380. static struct fb_ops msmfb_ops = {
  381. .owner = THIS_MODULE,
  382. .fb_open = msmfb_open,
  383. .fb_release = msmfb_release,
  384. .fb_check_var = msmfb_check_var,
  385. .fb_pan_display = msmfb_pan_display,
  386. .fb_fillrect = msmfb_fillrect,
  387. .fb_copyarea = msmfb_copyarea,
  388. .fb_imageblit = msmfb_imageblit,
  389. .fb_ioctl = msmfb_ioctl,
  390. };
  391. static unsigned PP[16];
  392. #define BITS_PER_PIXEL 16
  393. static void setup_fb_info(struct msmfb_info *msmfb)
  394. {
  395. struct fb_info *fb_info = msmfb->fb;
  396. int r;
  397. /* finish setting up the fb_info struct */
  398. strncpy(fb_info->fix.id, "msmfb", 16);
  399. fb_info->fix.ypanstep = 1;
  400. fb_info->fbops = &msmfb_ops;
  401. fb_info->flags = FBINFO_DEFAULT;
  402. fb_info->fix.type = FB_TYPE_PACKED_PIXELS;
  403. fb_info->fix.visual = FB_VISUAL_TRUECOLOR;
  404. fb_info->fix.line_length = msmfb->xres * 2;
  405. fb_info->var.xres = msmfb->xres;
  406. fb_info->var.yres = msmfb->yres;
  407. fb_info->var.width = msmfb->panel->fb_data->width;
  408. fb_info->var.height = msmfb->panel->fb_data->height;
  409. fb_info->var.xres_virtual = msmfb->xres;
  410. fb_info->var.yres_virtual = msmfb->yres * 2;
  411. fb_info->var.bits_per_pixel = BITS_PER_PIXEL;
  412. fb_info->var.accel_flags = 0;
  413. fb_info->var.yoffset = 0;
  414. if (msmfb->panel->caps & MSMFB_CAP_PARTIAL_UPDATES) {
  415. fb_info->var.reserved[0] = 0x54445055;
  416. fb_info->var.reserved[1] = 0;
  417. fb_info->var.reserved[2] = (uint16_t)msmfb->xres |
  418. ((uint32_t)msmfb->yres << 16);
  419. }
  420. fb_info->var.red.offset = 11;
  421. fb_info->var.red.length = 5;
  422. fb_info->var.red.msb_right = 0;
  423. fb_info->var.green.offset = 5;
  424. fb_info->var.green.length = 6;
  425. fb_info->var.green.msb_right = 0;
  426. fb_info->var.blue.offset = 0;
  427. fb_info->var.blue.length = 5;
  428. fb_info->var.blue.msb_right = 0;
  429. r = fb_alloc_cmap(&fb_info->cmap, 16, 0);
  430. fb_info->pseudo_palette = PP;
  431. PP[0] = 0;
  432. for (r = 1; r < 16; r++)
  433. PP[r] = 0xffffffff;
  434. }
  435. static int setup_fbmem(struct msmfb_info *msmfb, struct platform_device *pdev)
  436. {
  437. struct fb_info *fb = msmfb->fb;
  438. struct resource *resource;
  439. unsigned long size = msmfb->xres * msmfb->yres *
  440. (BITS_PER_PIXEL >> 3) * 2;
  441. unsigned char *fbram;
  442. /* board file might have attached a resource describing an fb */
  443. resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  444. if (!resource)
  445. return -EINVAL;
  446. /* check the resource is large enough to fit the fb */
  447. if (resource->end - resource->start < size) {
  448. printk(KERN_ERR "allocated resource is too small for "
  449. "fb\n");
  450. return -ENOMEM;
  451. }
  452. fb->fix.smem_start = resource->start;
  453. fb->fix.smem_len = resource->end - resource->start;
  454. fbram = ioremap(resource->start,
  455. resource->end - resource->start);
  456. if (fbram == 0) {
  457. printk(KERN_ERR "msmfb: cannot allocate fbram!\n");
  458. return -ENOMEM;
  459. }
  460. fb->screen_base = fbram;
  461. return 0;
  462. }
  463. static int msmfb_probe(struct platform_device *pdev)
  464. {
  465. struct fb_info *fb;
  466. struct msmfb_info *msmfb;
  467. struct msm_panel_data *panel = pdev->dev.platform_data;
  468. int ret;
  469. if (!panel) {
  470. pr_err("msmfb_probe: no platform data\n");
  471. return -EINVAL;
  472. }
  473. if (!panel->fb_data) {
  474. pr_err("msmfb_probe: no fb_data\n");
  475. return -EINVAL;
  476. }
  477. fb = framebuffer_alloc(sizeof(struct msmfb_info), &pdev->dev);
  478. if (!fb)
  479. return -ENOMEM;
  480. msmfb = fb->par;
  481. msmfb->fb = fb;
  482. msmfb->panel = panel;
  483. msmfb->xres = panel->fb_data->xres;
  484. msmfb->yres = panel->fb_data->yres;
  485. ret = setup_fbmem(msmfb, pdev);
  486. if (ret)
  487. goto error_setup_fbmem;
  488. setup_fb_info(msmfb);
  489. spin_lock_init(&msmfb->update_lock);
  490. mutex_init(&msmfb->panel_init_lock);
  491. init_waitqueue_head(&msmfb->frame_wq);
  492. msmfb->resume_workqueue = create_workqueue("panel_on");
  493. if (msmfb->resume_workqueue == NULL) {
  494. printk(KERN_ERR "failed to create panel_on workqueue\n");
  495. ret = -ENOMEM;
  496. goto error_create_workqueue;
  497. }
  498. INIT_WORK(&msmfb->resume_work, power_on_panel);
  499. msmfb->black = kzalloc(msmfb->fb->var.bits_per_pixel*msmfb->xres,
  500. GFP_KERNEL);
  501. printk(KERN_INFO "msmfb_probe() installing %d x %d panel\n",
  502. msmfb->xres, msmfb->yres);
  503. msmfb->dma_callback.func = msmfb_handle_dma_interrupt;
  504. msmfb->vsync_callback.func = msmfb_handle_vsync_interrupt;
  505. hrtimer_init(&msmfb->fake_vsync, CLOCK_MONOTONIC,
  506. HRTIMER_MODE_REL);
  507. msmfb->fake_vsync.function = msmfb_fake_vsync;
  508. ret = register_framebuffer(fb);
  509. if (ret)
  510. goto error_register_framebuffer;
  511. msmfb->sleeping = WAKING;
  512. return 0;
  513. error_register_framebuffer:
  514. destroy_workqueue(msmfb->resume_workqueue);
  515. error_create_workqueue:
  516. iounmap(fb->screen_base);
  517. error_setup_fbmem:
  518. framebuffer_release(msmfb->fb);
  519. return ret;
  520. }
  521. static struct platform_driver msm_panel_driver = {
  522. /* need to write remove */
  523. .probe = msmfb_probe,
  524. .driver = {.name = "msm_panel"},
  525. };
  526. static int msmfb_add_mdp_device(struct device *dev,
  527. struct class_interface *class_intf)
  528. {
  529. /* might need locking if mulitple mdp devices */
  530. if (mdp)
  531. return 0;
  532. mdp = container_of(dev, struct mdp_device, dev);
  533. return platform_driver_register(&msm_panel_driver);
  534. }
  535. static void msmfb_remove_mdp_device(struct device *dev,
  536. struct class_interface *class_intf)
  537. {
  538. /* might need locking if mulitple mdp devices */
  539. if (dev != &mdp->dev)
  540. return;
  541. platform_driver_unregister(&msm_panel_driver);
  542. mdp = NULL;
  543. }
  544. static struct class_interface msm_fb_interface = {
  545. .add_dev = &msmfb_add_mdp_device,
  546. .remove_dev = &msmfb_remove_mdp_device,
  547. };
  548. static int __init msmfb_init(void)
  549. {
  550. return register_mdp_client(&msm_fb_interface);
  551. }
  552. module_init(msmfb_init);