msm_fb.c 17 KB

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