ps3fb.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  1. /*
  2. * linux/drivers/video/ps3fb.c -- PS3 GPU frame buffer device
  3. *
  4. * Copyright (C) 2006 Sony Computer Entertainment Inc.
  5. * Copyright 2006, 2007 Sony Corporation
  6. *
  7. * This file is based on :
  8. *
  9. * linux/drivers/video/vfb.c -- Virtual frame buffer device
  10. *
  11. * Copyright (C) 2002 James Simmons
  12. *
  13. * Copyright (C) 1997 Geert Uytterhoeven
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file COPYING in the main directory of this archive for
  17. * more details.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/errno.h>
  22. #include <linux/string.h>
  23. #include <linux/mm.h>
  24. #include <linux/tty.h>
  25. #include <linux/slab.h>
  26. #include <linux/vmalloc.h>
  27. #include <linux/delay.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/console.h>
  30. #include <linux/ioctl.h>
  31. #include <linux/notifier.h>
  32. #include <linux/reboot.h>
  33. #include <linux/kthread.h>
  34. #include <linux/freezer.h>
  35. #include <asm/uaccess.h>
  36. #include <linux/fb.h>
  37. #include <linux/init.h>
  38. #include <asm/time.h>
  39. #include <asm/abs_addr.h>
  40. #include <asm/lv1call.h>
  41. #include <asm/ps3av.h>
  42. #include <asm/ps3fb.h>
  43. #include <asm/ps3.h>
  44. #define DEVICE_NAME "ps3fb"
  45. #ifdef PS3FB_DEBUG
  46. #define DPRINTK(fmt, args...) printk("%s: " fmt, __func__ , ##args)
  47. #else
  48. #define DPRINTK(fmt, args...)
  49. #endif
  50. #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x101
  51. #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP 0x102
  52. #define L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP 0x600
  53. #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601
  54. #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT_SYNC 0x602
  55. #define L1GPU_FB_BLIT_WAIT_FOR_COMPLETION (1ULL << 32)
  56. #define L1GPU_DISPLAY_SYNC_HSYNC 1
  57. #define L1GPU_DISPLAY_SYNC_VSYNC 2
  58. #define DDR_SIZE (0) /* used no ddr */
  59. #define GPU_OFFSET (64 * 1024)
  60. #define GPU_IOIF (0x0d000000UL)
  61. #define PS3FB_FULL_MODE_BIT 0x80
  62. #define GPU_INTR_STATUS_VSYNC_0 0 /* vsync on head A */
  63. #define GPU_INTR_STATUS_VSYNC_1 1 /* vsync on head B */
  64. #define GPU_INTR_STATUS_FLIP_0 3 /* flip head A */
  65. #define GPU_INTR_STATUS_FLIP_1 4 /* flip head B */
  66. #define GPU_INTR_STATUS_QUEUE_0 5 /* queue head A */
  67. #define GPU_INTR_STATUS_QUEUE_1 6 /* queue head B */
  68. #define GPU_DRIVER_INFO_VERSION 0x211
  69. /* gpu internals */
  70. struct display_head {
  71. u64 be_time_stamp;
  72. u32 status;
  73. u32 offset;
  74. u32 res1;
  75. u32 res2;
  76. u32 field;
  77. u32 reserved1;
  78. u64 res3;
  79. u32 raster;
  80. u64 vblank_count;
  81. u32 field_vsync;
  82. u32 reserved2;
  83. };
  84. struct gpu_irq {
  85. u32 irq_outlet;
  86. u32 status;
  87. u32 mask;
  88. u32 video_cause;
  89. u32 graph_cause;
  90. u32 user_cause;
  91. u32 res1;
  92. u64 res2;
  93. u32 reserved[4];
  94. };
  95. struct gpu_driver_info {
  96. u32 version_driver;
  97. u32 version_gpu;
  98. u32 memory_size;
  99. u32 hardware_channel;
  100. u32 nvcore_frequency;
  101. u32 memory_frequency;
  102. u32 reserved[1063];
  103. struct display_head display_head[8];
  104. struct gpu_irq irq;
  105. };
  106. struct ps3fb_priv {
  107. unsigned int irq_no;
  108. u64 context_handle, memory_handle;
  109. void *xdr_ea;
  110. struct gpu_driver_info *dinfo;
  111. u32 res_index;
  112. u64 vblank_count; /* frame count */
  113. wait_queue_head_t wait_vsync;
  114. u32 num_frames; /* num of frame buffers */
  115. atomic_t ext_flip; /* on/off flip with vsync */
  116. atomic_t f_count; /* fb_open count */
  117. int is_blanked;
  118. int is_kicked;
  119. struct task_struct *task;
  120. };
  121. static struct ps3fb_priv ps3fb;
  122. struct ps3fb_res_table {
  123. u32 xres;
  124. u32 yres;
  125. u32 xoff;
  126. u32 yoff;
  127. u32 type;
  128. };
  129. #define PS3FB_RES_FULL 1
  130. static const struct ps3fb_res_table ps3fb_res[] = {
  131. /* res_x,y margin_x,y full */
  132. { 720, 480, 72, 48 , 0},
  133. { 720, 576, 72, 58 , 0},
  134. { 1280, 720, 78, 38 , 0},
  135. { 1920, 1080, 116, 58 , 0},
  136. /* full mode */
  137. { 720, 480, 0, 0 , PS3FB_RES_FULL},
  138. { 720, 576, 0, 0 , PS3FB_RES_FULL},
  139. { 1280, 720, 0, 0 , PS3FB_RES_FULL},
  140. { 1920, 1080, 0, 0 , PS3FB_RES_FULL},
  141. /* vesa: normally full mode */
  142. { 1280, 768, 0, 0 , 0},
  143. { 1280, 1024, 0, 0 , 0},
  144. { 1920, 1200, 0, 0 , 0},
  145. { 0, 0, 0, 0 , 0} };
  146. /* default resolution */
  147. #define GPU_RES_INDEX 0 /* 720 x 480 */
  148. static const struct fb_videomode ps3fb_modedb[] = {
  149. /* 60 Hz broadcast modes (modes "1" to "5") */
  150. {
  151. /* 480i */
  152. "480i", 60, 576, 384, 74074, 130, 89, 78, 57, 63, 6,
  153. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  154. }, {
  155. /* 480p */
  156. "480p", 60, 576, 384, 37037, 130, 89, 78, 57, 63, 6,
  157. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  158. }, {
  159. /* 720p */
  160. "720p", 60, 1124, 644, 13481, 298, 148, 57, 44, 80, 5,
  161. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  162. }, {
  163. /* 1080i */
  164. "1080i", 60, 1688, 964, 13481, 264, 160, 94, 62, 88, 5,
  165. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  166. }, {
  167. /* 1080p */
  168. "1080p", 60, 1688, 964, 6741, 264, 160, 94, 62, 88, 5,
  169. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  170. },
  171. /* 50 Hz broadcast modes (modes "6" to "10") */
  172. {
  173. /* 576i */
  174. "576i", 50, 576, 460, 74074, 142, 83, 97, 63, 63, 5,
  175. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  176. }, {
  177. /* 576p */
  178. "576p", 50, 576, 460, 37037, 142, 83, 97, 63, 63, 5,
  179. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  180. }, {
  181. /* 720p */
  182. "720p", 50, 1124, 644, 13468, 298, 478, 57, 44, 80, 5,
  183. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  184. }, {
  185. /* 1080 */
  186. "1080i", 50, 1688, 964, 13468, 264, 600, 94, 62, 88, 5,
  187. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  188. }, {
  189. /* 1080p */
  190. "1080p", 50, 1688, 964, 6734, 264, 600, 94, 62, 88, 5,
  191. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  192. },
  193. /* VESA modes (modes "11" to "13") */
  194. {
  195. /* WXGA */
  196. "wxga", 60, 1280, 768, 12924, 160, 24, 29, 3, 136, 6,
  197. 0, FB_VMODE_NONINTERLACED,
  198. FB_MODE_IS_VESA
  199. }, {
  200. /* SXGA */
  201. "sxga", 60, 1280, 1024, 9259, 248, 48, 38, 1, 112, 3,
  202. FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED,
  203. FB_MODE_IS_VESA
  204. }, {
  205. /* WUXGA */
  206. "wuxga", 60, 1920, 1200, 6494, 80, 48, 26, 3, 32, 6,
  207. FB_SYNC_HOR_HIGH_ACT, FB_VMODE_NONINTERLACED,
  208. FB_MODE_IS_VESA
  209. },
  210. /* 60 Hz broadcast modes (full resolution versions of modes "1" to "5") */
  211. {
  212. /* 480if */
  213. "480if", 60, 720, 480, 74074, 58, 17, 30, 9, 63, 6,
  214. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  215. }, {
  216. /* 480pf */
  217. "480pf", 60, 720, 480, 37037, 58, 17, 30, 9, 63, 6,
  218. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  219. }, {
  220. /* 720pf */
  221. "720pf", 60, 1280, 720, 13481, 220, 70, 19, 6, 80, 5,
  222. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  223. }, {
  224. /* 1080if */
  225. "1080if", 60, 1920, 1080, 13481, 148, 44, 36, 4, 88, 5,
  226. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  227. }, {
  228. /* 1080pf */
  229. "1080pf", 60, 1920, 1080, 6741, 148, 44, 36, 4, 88, 5,
  230. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  231. },
  232. /* 50 Hz broadcast modes (full resolution versions of modes "6" to "10") */
  233. {
  234. /* 576if */
  235. "576if", 50, 720, 576, 74074, 70, 11, 39, 5, 63, 5,
  236. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  237. }, {
  238. /* 576pf */
  239. "576pf", 50, 720, 576, 37037, 70, 11, 39, 5, 63, 5,
  240. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  241. }, {
  242. /* 720pf */
  243. "720pf", 50, 1280, 720, 13468, 220, 400, 19, 6, 80, 5,
  244. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  245. }, {
  246. /* 1080if */
  247. "1080f", 50, 1920, 1080, 13468, 148, 484, 36, 4, 88, 5,
  248. FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
  249. }, {
  250. /* 1080pf */
  251. "1080pf", 50, 1920, 1080, 6734, 148, 484, 36, 4, 88, 5,
  252. FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
  253. }
  254. };
  255. #define HEAD_A
  256. #define HEAD_B
  257. #define X_OFF(i) (ps3fb_res[i].xoff) /* left/right margin (pixel) */
  258. #define Y_OFF(i) (ps3fb_res[i].yoff) /* top/bottom margin (pixel) */
  259. #define WIDTH(i) (ps3fb_res[i].xres) /* width of FB */
  260. #define HEIGHT(i) (ps3fb_res[i].yres) /* height of FB */
  261. #define BPP 4 /* number of bytes per pixel */
  262. #define VP_OFF(i) (WIDTH(i) * Y_OFF(i) * BPP + X_OFF(i) * BPP)
  263. #define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET)
  264. static int ps3fb_mode;
  265. module_param(ps3fb_mode, int, 0);
  266. static char *mode_option __devinitdata;
  267. static int ps3fb_get_res_table(u32 xres, u32 yres)
  268. {
  269. int full_mode;
  270. unsigned int i;
  271. u32 x, y, f;
  272. full_mode = (ps3fb_mode & PS3FB_FULL_MODE_BIT) ? PS3FB_RES_FULL : 0;
  273. for (i = 0;; i++) {
  274. x = ps3fb_res[i].xres;
  275. y = ps3fb_res[i].yres;
  276. f = ps3fb_res[i].type;
  277. if (!x) {
  278. DPRINTK("ERROR: ps3fb_get_res_table()\n");
  279. return -1;
  280. }
  281. if (full_mode == PS3FB_RES_FULL && f != PS3FB_RES_FULL)
  282. continue;
  283. if (x == xres && (yres == 0 || y == yres))
  284. break;
  285. x = x - 2 * ps3fb_res[i].xoff;
  286. y = y - 2 * ps3fb_res[i].yoff;
  287. if (x == xres && (yres == 0 || y == yres))
  288. break;
  289. }
  290. return i;
  291. }
  292. static unsigned int ps3fb_find_mode(const struct fb_var_screeninfo *var,
  293. u32 *line_length)
  294. {
  295. unsigned int i, mode;
  296. for (i = 0; i < ARRAY_SIZE(ps3fb_modedb); i++)
  297. if (var->xres == ps3fb_modedb[i].xres &&
  298. var->yres == ps3fb_modedb[i].yres &&
  299. var->pixclock == ps3fb_modedb[i].pixclock &&
  300. var->hsync_len == ps3fb_modedb[i].hsync_len &&
  301. var->vsync_len == ps3fb_modedb[i].vsync_len &&
  302. var->left_margin == ps3fb_modedb[i].left_margin &&
  303. var->right_margin == ps3fb_modedb[i].right_margin &&
  304. var->upper_margin == ps3fb_modedb[i].upper_margin &&
  305. var->lower_margin == ps3fb_modedb[i].lower_margin &&
  306. var->sync == ps3fb_modedb[i].sync &&
  307. (var->vmode & FB_VMODE_MASK) == ps3fb_modedb[i].vmode) {
  308. /* Cropped broadcast modes use the full line_length */
  309. *line_length =
  310. ps3fb_modedb[i < 10 ? i + 13 : i].xres * 4;
  311. /* Full broadcast modes have the full mode bit set */
  312. mode = i > 12 ? (i - 12) | PS3FB_FULL_MODE_BIT : i + 1;
  313. DPRINTK("ps3fb_find_mode: mode %u\n", mode);
  314. return mode;
  315. }
  316. DPRINTK("ps3fb_find_mode: mode not found\n");
  317. return 0;
  318. }
  319. static const struct fb_videomode *ps3fb_default_mode(void)
  320. {
  321. u32 mode = ps3fb_mode & PS3AV_MODE_MASK;
  322. u32 flags;
  323. if (mode < 1 || mode > 13)
  324. return NULL;
  325. flags = ps3fb_mode & ~PS3AV_MODE_MASK;
  326. if (mode <= 10 && flags & PS3FB_FULL_MODE_BIT) {
  327. /* Full broadcast mode */
  328. return &ps3fb_modedb[mode + 12];
  329. }
  330. return &ps3fb_modedb[mode - 1];
  331. }
  332. static int ps3fb_sync(u32 frame)
  333. {
  334. int i, status;
  335. u32 xres, yres;
  336. u64 fb_ioif, offset;
  337. i = ps3fb.res_index;
  338. xres = ps3fb_res[i].xres;
  339. yres = ps3fb_res[i].yres;
  340. if (frame > ps3fb.num_frames - 1) {
  341. printk(KERN_WARNING "%s: invalid frame number (%u)\n",
  342. __func__, frame);
  343. return -EINVAL;
  344. }
  345. offset = xres * yres * BPP * frame;
  346. fb_ioif = GPU_IOIF + FB_OFF(i) + offset;
  347. status = lv1_gpu_context_attribute(ps3fb.context_handle,
  348. L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
  349. offset, fb_ioif,
  350. L1GPU_FB_BLIT_WAIT_FOR_COMPLETION |
  351. (xres << 16) | yres,
  352. xres * BPP); /* line_length */
  353. if (status)
  354. printk(KERN_ERR
  355. "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n",
  356. __func__, status);
  357. #ifdef HEAD_A
  358. status = lv1_gpu_context_attribute(ps3fb.context_handle,
  359. L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
  360. 0, offset, 0, 0);
  361. if (status)
  362. printk(KERN_ERR
  363. "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
  364. __func__, status);
  365. #endif
  366. #ifdef HEAD_B
  367. status = lv1_gpu_context_attribute(ps3fb.context_handle,
  368. L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
  369. 1, offset, 0, 0);
  370. if (status)
  371. printk(KERN_ERR
  372. "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
  373. __func__, status);
  374. #endif
  375. return 0;
  376. }
  377. static int ps3fb_open(struct fb_info *info, int user)
  378. {
  379. atomic_inc(&ps3fb.f_count);
  380. return 0;
  381. }
  382. static int ps3fb_release(struct fb_info *info, int user)
  383. {
  384. if (atomic_dec_and_test(&ps3fb.f_count)) {
  385. if (atomic_read(&ps3fb.ext_flip)) {
  386. atomic_set(&ps3fb.ext_flip, 0);
  387. ps3fb_sync(0); /* single buffer */
  388. }
  389. }
  390. return 0;
  391. }
  392. /*
  393. * Setting the video mode has been split into two parts.
  394. * First part, xxxfb_check_var, must not write anything
  395. * to hardware, it should only verify and adjust var.
  396. * This means it doesn't alter par but it does use hardware
  397. * data from it to check this var.
  398. */
  399. static int ps3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  400. {
  401. u32 line_length;
  402. int mode;
  403. int i;
  404. DPRINTK("var->xres:%u info->var.xres:%u\n", var->xres, info->var.xres);
  405. DPRINTK("var->yres:%u info->var.yres:%u\n", var->yres, info->var.yres);
  406. /* FIXME For now we do exact matches only */
  407. mode = ps3fb_find_mode(var, &line_length);
  408. if (!mode)
  409. return -EINVAL;
  410. /*
  411. * FB_VMODE_CONUPDATE and FB_VMODE_SMOOTH_XPAN are equal!
  412. * as FB_VMODE_SMOOTH_XPAN is only used internally
  413. */
  414. if (var->vmode & FB_VMODE_CONUPDATE) {
  415. var->vmode |= FB_VMODE_YWRAP;
  416. var->xoffset = info->var.xoffset;
  417. var->yoffset = info->var.yoffset;
  418. }
  419. /* Virtual screen and panning are not supported */
  420. if (var->xres_virtual > var->xres || var->yres_virtual > var->yres ||
  421. var->xoffset || var->yoffset) {
  422. DPRINTK("Virtual screen and panning are not supported\n");
  423. return -EINVAL;
  424. }
  425. var->xres_virtual = var->xres;
  426. var->yres_virtual = var->yres;
  427. /* We support ARGB8888 only */
  428. if (var->bits_per_pixel > 32 || var->grayscale ||
  429. var->red.offset > 16 || var->green.offset > 8 ||
  430. var->blue.offset > 0 || var->transp.offset > 24 ||
  431. var->red.length > 8 || var->green.length > 8 ||
  432. var->blue.length > 8 || var->transp.length > 8 ||
  433. var->red.msb_right || var->green.msb_right ||
  434. var->blue.msb_right || var->transp.msb_right || var->nonstd) {
  435. DPRINTK("We support ARGB8888 only\n");
  436. return -EINVAL;
  437. }
  438. var->bits_per_pixel = 32;
  439. var->red.offset = 16;
  440. var->green.offset = 8;
  441. var->blue.offset = 0;
  442. var->transp.offset = 24;
  443. var->red.length = 8;
  444. var->green.length = 8;
  445. var->blue.length = 8;
  446. var->transp.length = 8;
  447. var->red.msb_right = 0;
  448. var->green.msb_right = 0;
  449. var->blue.msb_right = 0;
  450. var->transp.msb_right = 0;
  451. /* Rotation is not supported */
  452. if (var->rotate) {
  453. DPRINTK("Rotation is not supported\n");
  454. return -EINVAL;
  455. }
  456. /* Memory limit */
  457. i = ps3fb_get_res_table(var->xres, var->yres);
  458. if (ps3fb_res[i].xres*ps3fb_res[i].yres*BPP > ps3fb_videomemory.size) {
  459. DPRINTK("Not enough memory\n");
  460. return -ENOMEM;
  461. }
  462. var->height = -1;
  463. var->width = -1;
  464. return 0;
  465. }
  466. /*
  467. * This routine actually sets the video mode.
  468. */
  469. static int ps3fb_set_par(struct fb_info *info)
  470. {
  471. unsigned int mode;
  472. int i;
  473. unsigned long offset;
  474. static int first = 1;
  475. DPRINTK("xres:%d xv:%d yres:%d yv:%d clock:%d\n",
  476. info->var.xres, info->var.xres_virtual,
  477. info->var.yres, info->var.yres_virtual, info->var.pixclock);
  478. i = ps3fb_get_res_table(info->var.xres, info->var.yres);
  479. ps3fb.res_index = i;
  480. mode = ps3fb_find_mode(&info->var, &info->fix.line_length);
  481. if (!mode)
  482. return -EINVAL;
  483. offset = FB_OFF(i) + VP_OFF(i);
  484. info->fix.smem_len = ps3fb_videomemory.size - offset;
  485. info->screen_base = (char __iomem *)ps3fb.xdr_ea + offset;
  486. memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size);
  487. ps3fb.num_frames = ps3fb_videomemory.size/
  488. (ps3fb_res[i].xres*ps3fb_res[i].yres*BPP);
  489. /* Keep the special bits we cannot set using fb_var_screeninfo */
  490. ps3fb_mode = (ps3fb_mode & ~PS3AV_MODE_MASK) | mode;
  491. if (ps3av_set_video_mode(ps3fb_mode, first))
  492. return -EINVAL;
  493. first = 0;
  494. return 0;
  495. }
  496. /*
  497. * Set a single color register. The values supplied are already
  498. * rounded down to the hardware's capabilities (according to the
  499. * entries in the var structure). Return != 0 for invalid regno.
  500. */
  501. static int ps3fb_setcolreg(unsigned int regno, unsigned int red,
  502. unsigned int green, unsigned int blue,
  503. unsigned int transp, struct fb_info *info)
  504. {
  505. if (regno >= 16)
  506. return 1;
  507. red >>= 8;
  508. green >>= 8;
  509. blue >>= 8;
  510. transp >>= 8;
  511. ((u32 *)info->pseudo_palette)[regno] = transp << 24 | red << 16 |
  512. green << 8 | blue;
  513. return 0;
  514. }
  515. /*
  516. * As we have a virtual frame buffer, we need our own mmap function
  517. */
  518. static int ps3fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
  519. {
  520. unsigned long size, offset;
  521. int i;
  522. i = ps3fb_get_res_table(info->var.xres, info->var.yres);
  523. if (i == -1)
  524. return -EINVAL;
  525. size = vma->vm_end - vma->vm_start;
  526. offset = vma->vm_pgoff << PAGE_SHIFT;
  527. if (offset + size > info->fix.smem_len)
  528. return -EINVAL;
  529. offset += info->fix.smem_start + FB_OFF(i) + VP_OFF(i);
  530. if (remap_pfn_range(vma, vma->vm_start, offset >> PAGE_SHIFT,
  531. size, vma->vm_page_prot))
  532. return -EAGAIN;
  533. printk(KERN_DEBUG "ps3fb: mmap framebuffer P(%lx)->V(%lx)\n", offset,
  534. vma->vm_start);
  535. return 0;
  536. }
  537. /*
  538. * Blank the display
  539. */
  540. static int ps3fb_blank(int blank, struct fb_info *info)
  541. {
  542. int retval;
  543. DPRINTK("%s: blank:%d\n", __func__, blank);
  544. switch (blank) {
  545. case FB_BLANK_POWERDOWN:
  546. case FB_BLANK_HSYNC_SUSPEND:
  547. case FB_BLANK_VSYNC_SUSPEND:
  548. case FB_BLANK_NORMAL:
  549. retval = ps3av_video_mute(1); /* mute on */
  550. if (!retval)
  551. ps3fb.is_blanked = 1;
  552. break;
  553. default: /* unblank */
  554. retval = ps3av_video_mute(0); /* mute off */
  555. if (!retval)
  556. ps3fb.is_blanked = 0;
  557. break;
  558. }
  559. return retval;
  560. }
  561. static int ps3fb_get_vblank(struct fb_vblank *vblank)
  562. {
  563. memset(vblank, 0, sizeof(&vblank));
  564. vblank->flags = FB_VBLANK_HAVE_VSYNC;
  565. return 0;
  566. }
  567. int ps3fb_wait_for_vsync(u32 crtc)
  568. {
  569. int ret;
  570. u64 count;
  571. count = ps3fb.vblank_count;
  572. ret = wait_event_interruptible_timeout(ps3fb.wait_vsync,
  573. count != ps3fb.vblank_count,
  574. HZ / 10);
  575. if (!ret)
  576. return -ETIMEDOUT;
  577. return 0;
  578. }
  579. EXPORT_SYMBOL_GPL(ps3fb_wait_for_vsync);
  580. void ps3fb_flip_ctl(int on, void *data)
  581. {
  582. struct ps3fb_priv *priv = data;
  583. if (on)
  584. atomic_dec_if_positive(&priv->ext_flip);
  585. else
  586. atomic_inc(&priv->ext_flip);
  587. }
  588. /*
  589. * ioctl
  590. */
  591. static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
  592. unsigned long arg)
  593. {
  594. void __user *argp = (void __user *)arg;
  595. u32 val, old_mode;
  596. int retval = -EFAULT;
  597. switch (cmd) {
  598. case FBIOGET_VBLANK:
  599. {
  600. struct fb_vblank vblank;
  601. DPRINTK("FBIOGET_VBLANK:\n");
  602. retval = ps3fb_get_vblank(&vblank);
  603. if (retval)
  604. break;
  605. if (copy_to_user(argp, &vblank, sizeof(vblank)))
  606. retval = -EFAULT;
  607. break;
  608. }
  609. case FBIO_WAITFORVSYNC:
  610. {
  611. u32 crt;
  612. DPRINTK("FBIO_WAITFORVSYNC:\n");
  613. if (get_user(crt, (u32 __user *) arg))
  614. break;
  615. retval = ps3fb_wait_for_vsync(crt);
  616. break;
  617. }
  618. case PS3FB_IOCTL_SETMODE:
  619. {
  620. const struct fb_videomode *mode;
  621. struct fb_var_screeninfo var;
  622. if (copy_from_user(&val, argp, sizeof(val)))
  623. break;
  624. if (!(val & PS3AV_MODE_MASK)) {
  625. u32 id = ps3av_get_auto_mode(0);
  626. if (id > 0)
  627. val = (val & ~PS3AV_MODE_MASK) | id;
  628. }
  629. DPRINTK("PS3FB_IOCTL_SETMODE:%x\n", val);
  630. retval = -EINVAL;
  631. old_mode = ps3fb_mode;
  632. ps3fb_mode = val;
  633. mode = ps3fb_default_mode();
  634. if (mode) {
  635. var = info->var;
  636. fb_videomode_to_var(&var, mode);
  637. acquire_console_sem();
  638. info->flags |= FBINFO_MISC_USEREVENT;
  639. /* Force, in case only special bits changed */
  640. var.activate |= FB_ACTIVATE_FORCE;
  641. retval = fb_set_var(info, &var);
  642. info->flags &= ~FBINFO_MISC_USEREVENT;
  643. release_console_sem();
  644. }
  645. if (retval)
  646. ps3fb_mode = old_mode;
  647. break;
  648. }
  649. case PS3FB_IOCTL_GETMODE:
  650. val = ps3av_get_mode();
  651. DPRINTK("PS3FB_IOCTL_GETMODE:%x\n", val);
  652. if (!copy_to_user(argp, &val, sizeof(val)))
  653. retval = 0;
  654. break;
  655. case PS3FB_IOCTL_SCREENINFO:
  656. {
  657. struct ps3fb_ioctl_res res;
  658. int i = ps3fb.res_index;
  659. DPRINTK("PS3FB_IOCTL_SCREENINFO:\n");
  660. res.xres = ps3fb_res[i].xres;
  661. res.yres = ps3fb_res[i].yres;
  662. res.xoff = ps3fb_res[i].xoff;
  663. res.yoff = ps3fb_res[i].yoff;
  664. res.num_frames = ps3fb.num_frames;
  665. if (!copy_to_user(argp, &res, sizeof(res)))
  666. retval = 0;
  667. break;
  668. }
  669. case PS3FB_IOCTL_ON:
  670. DPRINTK("PS3FB_IOCTL_ON:\n");
  671. atomic_inc(&ps3fb.ext_flip);
  672. retval = 0;
  673. break;
  674. case PS3FB_IOCTL_OFF:
  675. DPRINTK("PS3FB_IOCTL_OFF:\n");
  676. atomic_dec_if_positive(&ps3fb.ext_flip);
  677. retval = 0;
  678. break;
  679. case PS3FB_IOCTL_FSEL:
  680. if (copy_from_user(&val, argp, sizeof(val)))
  681. break;
  682. DPRINTK("PS3FB_IOCTL_FSEL:%d\n", val);
  683. retval = ps3fb_sync(val);
  684. break;
  685. default:
  686. retval = -ENOIOCTLCMD;
  687. break;
  688. }
  689. return retval;
  690. }
  691. static int ps3fbd(void *arg)
  692. {
  693. while (!kthread_should_stop()) {
  694. try_to_freeze();
  695. set_current_state(TASK_INTERRUPTIBLE);
  696. if (ps3fb.is_kicked) {
  697. ps3fb.is_kicked = 0;
  698. ps3fb_sync(0); /* single buffer */
  699. }
  700. schedule();
  701. }
  702. return 0;
  703. }
  704. static irqreturn_t ps3fb_vsync_interrupt(int irq, void *ptr)
  705. {
  706. u64 v1;
  707. int status;
  708. struct display_head *head = &ps3fb.dinfo->display_head[1];
  709. status = lv1_gpu_context_intr(ps3fb.context_handle, &v1);
  710. if (status) {
  711. printk(KERN_ERR "%s: lv1_gpu_context_intr failed: %d\n",
  712. __func__, status);
  713. return IRQ_NONE;
  714. }
  715. if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) {
  716. /* VSYNC */
  717. ps3fb.vblank_count = head->vblank_count;
  718. if (ps3fb.task && !ps3fb.is_blanked &&
  719. !atomic_read(&ps3fb.ext_flip)) {
  720. ps3fb.is_kicked = 1;
  721. wake_up_process(ps3fb.task);
  722. }
  723. wake_up_interruptible(&ps3fb.wait_vsync);
  724. }
  725. return IRQ_HANDLED;
  726. }
  727. static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo,
  728. struct ps3_system_bus_device *dev)
  729. {
  730. int error;
  731. DPRINTK("version_driver:%x\n", dinfo->version_driver);
  732. DPRINTK("irq outlet:%x\n", dinfo->irq.irq_outlet);
  733. DPRINTK("version_gpu:%x memory_size:%x ch:%x core_freq:%d mem_freq:%d\n",
  734. dinfo->version_gpu, dinfo->memory_size, dinfo->hardware_channel,
  735. dinfo->nvcore_frequency/1000000, dinfo->memory_frequency/1000000);
  736. if (dinfo->version_driver != GPU_DRIVER_INFO_VERSION) {
  737. printk(KERN_ERR "%s: version_driver err:%x\n", __func__,
  738. dinfo->version_driver);
  739. return -EINVAL;
  740. }
  741. error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet,
  742. &ps3fb.irq_no);
  743. if (error) {
  744. printk(KERN_ERR "%s: ps3_alloc_irq failed %d\n", __func__,
  745. error);
  746. return error;
  747. }
  748. error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED,
  749. DEVICE_NAME, dev);
  750. if (error) {
  751. printk(KERN_ERR "%s: request_irq failed %d\n", __func__,
  752. error);
  753. ps3_irq_plug_destroy(ps3fb.irq_no);
  754. return error;
  755. }
  756. dinfo->irq.mask = (1 << GPU_INTR_STATUS_VSYNC_1) |
  757. (1 << GPU_INTR_STATUS_FLIP_1);
  758. return 0;
  759. }
  760. static int ps3fb_xdr_settings(u64 xdr_lpar)
  761. {
  762. int status;
  763. status = lv1_gpu_context_iomap(ps3fb.context_handle, GPU_IOIF,
  764. xdr_lpar, ps3fb_videomemory.size, 0);
  765. if (status) {
  766. printk(KERN_ERR "%s: lv1_gpu_context_iomap failed: %d\n",
  767. __func__, status);
  768. return -ENXIO;
  769. }
  770. DPRINTK("video:%p xdr_ea:%p ioif:%lx lpar:%lx phys:%lx size:%lx\n",
  771. ps3fb_videomemory.address, ps3fb.xdr_ea, GPU_IOIF, xdr_lpar,
  772. virt_to_abs(ps3fb.xdr_ea), ps3fb_videomemory.size);
  773. status = lv1_gpu_context_attribute(ps3fb.context_handle,
  774. L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP,
  775. xdr_lpar, ps3fb_videomemory.size,
  776. GPU_IOIF, 0);
  777. if (status) {
  778. printk(KERN_ERR
  779. "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n",
  780. __func__, status);
  781. return -ENXIO;
  782. }
  783. return 0;
  784. }
  785. static struct fb_ops ps3fb_ops = {
  786. .fb_open = ps3fb_open,
  787. .fb_release = ps3fb_release,
  788. .fb_read = fb_sys_read,
  789. .fb_write = fb_sys_write,
  790. .fb_check_var = ps3fb_check_var,
  791. .fb_set_par = ps3fb_set_par,
  792. .fb_setcolreg = ps3fb_setcolreg,
  793. .fb_fillrect = sys_fillrect,
  794. .fb_copyarea = sys_copyarea,
  795. .fb_imageblit = sys_imageblit,
  796. .fb_mmap = ps3fb_mmap,
  797. .fb_blank = ps3fb_blank,
  798. .fb_ioctl = ps3fb_ioctl,
  799. .fb_compat_ioctl = ps3fb_ioctl
  800. };
  801. static struct fb_fix_screeninfo ps3fb_fix __initdata = {
  802. .id = DEVICE_NAME,
  803. .type = FB_TYPE_PACKED_PIXELS,
  804. .visual = FB_VISUAL_TRUECOLOR,
  805. .accel = FB_ACCEL_NONE,
  806. };
  807. static int ps3fb_set_sync(void)
  808. {
  809. int status;
  810. #ifdef HEAD_A
  811. status = lv1_gpu_context_attribute(0x0,
  812. L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
  813. 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
  814. if (status) {
  815. printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_SYNC "
  816. "failed: %d\n", __func__, status);
  817. return -1;
  818. }
  819. #endif
  820. #ifdef HEAD_B
  821. status = lv1_gpu_context_attribute(0x0,
  822. L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
  823. 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
  824. if (status) {
  825. printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_MODE "
  826. "failed: %d\n", __func__, status);
  827. return -1;
  828. }
  829. #endif
  830. return 0;
  831. }
  832. static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
  833. {
  834. struct fb_info *info;
  835. int retval = -ENOMEM;
  836. u32 xres, yres;
  837. u64 ddr_lpar = 0;
  838. u64 lpar_dma_control = 0;
  839. u64 lpar_driver_info = 0;
  840. u64 lpar_reports = 0;
  841. u64 lpar_reports_size = 0;
  842. u64 xdr_lpar;
  843. int status;
  844. unsigned long offset;
  845. struct task_struct *task;
  846. status = ps3_open_hv_device(dev);
  847. if (status) {
  848. printk(KERN_ERR "%s: ps3_open_hv_device failed\n", __func__);
  849. goto err;
  850. }
  851. if (!ps3fb_mode)
  852. ps3fb_mode = ps3av_get_mode();
  853. DPRINTK("ps3av_mode:%d\n", ps3fb_mode);
  854. if (ps3fb_mode > 0 &&
  855. !ps3av_video_mode2res(ps3fb_mode, &xres, &yres)) {
  856. ps3fb.res_index = ps3fb_get_res_table(xres, yres);
  857. DPRINTK("res_index:%d\n", ps3fb.res_index);
  858. } else
  859. ps3fb.res_index = GPU_RES_INDEX;
  860. atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */
  861. atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */
  862. init_waitqueue_head(&ps3fb.wait_vsync);
  863. ps3fb.num_frames = 1;
  864. ps3fb_set_sync();
  865. /* get gpu context handle */
  866. status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0,
  867. &ps3fb.memory_handle, &ddr_lpar);
  868. if (status) {
  869. printk(KERN_ERR "%s: lv1_gpu_memory_allocate failed: %d\n",
  870. __func__, status);
  871. goto err;
  872. }
  873. DPRINTK("ddr:lpar:0x%lx\n", ddr_lpar);
  874. status = lv1_gpu_context_allocate(ps3fb.memory_handle, 0,
  875. &ps3fb.context_handle,
  876. &lpar_dma_control, &lpar_driver_info,
  877. &lpar_reports, &lpar_reports_size);
  878. if (status) {
  879. printk(KERN_ERR "%s: lv1_gpu_context_attribute failed: %d\n",
  880. __func__, status);
  881. goto err_gpu_memory_free;
  882. }
  883. /* vsync interrupt */
  884. ps3fb.dinfo = ioremap(lpar_driver_info, 128 * 1024);
  885. if (!ps3fb.dinfo) {
  886. printk(KERN_ERR "%s: ioremap failed\n", __func__);
  887. goto err_gpu_context_free;
  888. }
  889. retval = ps3fb_vsync_settings(ps3fb.dinfo, dev);
  890. if (retval)
  891. goto err_iounmap_dinfo;
  892. /* xdr frame buffer */
  893. ps3fb.xdr_ea = ps3fb_videomemory.address;
  894. xdr_lpar = ps3_mm_phys_to_lpar(__pa(ps3fb.xdr_ea));
  895. retval = ps3fb_xdr_settings(xdr_lpar);
  896. if (retval)
  897. goto err_free_irq;
  898. /*
  899. * ps3fb must clear memory to prevent kernel info
  900. * leakage into userspace
  901. */
  902. memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size);
  903. info = framebuffer_alloc(sizeof(u32) * 16, &dev->core);
  904. if (!info)
  905. goto err_free_irq;
  906. offset = FB_OFF(ps3fb.res_index) + VP_OFF(ps3fb.res_index);
  907. info->screen_base = (char __iomem *)ps3fb.xdr_ea + offset;
  908. info->fbops = &ps3fb_ops;
  909. info->fix = ps3fb_fix;
  910. info->fix.smem_start = virt_to_abs(ps3fb.xdr_ea);
  911. info->fix.smem_len = ps3fb_videomemory.size - offset;
  912. info->pseudo_palette = info->par;
  913. info->par = NULL;
  914. info->flags = FBINFO_FLAG_DEFAULT;
  915. retval = fb_alloc_cmap(&info->cmap, 256, 0);
  916. if (retval < 0)
  917. goto err_framebuffer_release;
  918. if (!fb_find_mode(&info->var, info, mode_option, ps3fb_modedb,
  919. ARRAY_SIZE(ps3fb_modedb), ps3fb_default_mode(), 32)) {
  920. retval = -EINVAL;
  921. goto err_fb_dealloc;
  922. }
  923. fb_videomode_to_modelist(ps3fb_modedb, ARRAY_SIZE(ps3fb_modedb),
  924. &info->modelist);
  925. retval = register_framebuffer(info);
  926. if (retval < 0)
  927. goto err_fb_dealloc;
  928. dev->core.driver_data = info;
  929. printk(KERN_INFO
  930. "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n",
  931. info->node, ps3fb_videomemory.size >> 10);
  932. task = kthread_run(ps3fbd, info, DEVICE_NAME);
  933. if (IS_ERR(task)) {
  934. retval = PTR_ERR(task);
  935. goto err_unregister_framebuffer;
  936. }
  937. ps3fb.task = task;
  938. ps3av_register_flip_ctl(ps3fb_flip_ctl, &ps3fb);
  939. return 0;
  940. err_unregister_framebuffer:
  941. unregister_framebuffer(info);
  942. err_fb_dealloc:
  943. fb_dealloc_cmap(&info->cmap);
  944. err_framebuffer_release:
  945. framebuffer_release(info);
  946. err_free_irq:
  947. free_irq(ps3fb.irq_no, dev);
  948. ps3_irq_plug_destroy(ps3fb.irq_no);
  949. err_iounmap_dinfo:
  950. iounmap((u8 __iomem *)ps3fb.dinfo);
  951. err_gpu_context_free:
  952. lv1_gpu_context_free(ps3fb.context_handle);
  953. err_gpu_memory_free:
  954. lv1_gpu_memory_free(ps3fb.memory_handle);
  955. err:
  956. return retval;
  957. }
  958. static int ps3fb_shutdown(struct ps3_system_bus_device *dev)
  959. {
  960. int status;
  961. struct fb_info *info = dev->core.driver_data;
  962. DPRINTK(" -> %s:%d\n", __func__, __LINE__);
  963. ps3fb_flip_ctl(0, &ps3fb); /* flip off */
  964. ps3fb.dinfo->irq.mask = 0;
  965. if (info) {
  966. unregister_framebuffer(info);
  967. fb_dealloc_cmap(&info->cmap);
  968. framebuffer_release(info);
  969. }
  970. ps3av_register_flip_ctl(NULL, NULL);
  971. if (ps3fb.task) {
  972. struct task_struct *task = ps3fb.task;
  973. ps3fb.task = NULL;
  974. kthread_stop(task);
  975. }
  976. if (ps3fb.irq_no) {
  977. free_irq(ps3fb.irq_no, dev);
  978. ps3_irq_plug_destroy(ps3fb.irq_no);
  979. }
  980. iounmap((u8 __iomem *)ps3fb.dinfo);
  981. status = lv1_gpu_context_free(ps3fb.context_handle);
  982. if (status)
  983. DPRINTK("lv1_gpu_context_free failed: %d\n", status);
  984. status = lv1_gpu_memory_free(ps3fb.memory_handle);
  985. if (status)
  986. DPRINTK("lv1_gpu_memory_free failed: %d\n", status);
  987. ps3_close_hv_device(dev);
  988. DPRINTK(" <- %s:%d\n", __func__, __LINE__);
  989. return 0;
  990. }
  991. static struct ps3_system_bus_driver ps3fb_driver = {
  992. .match_id = PS3_MATCH_ID_GRAPHICS,
  993. .core.name = DEVICE_NAME,
  994. .core.owner = THIS_MODULE,
  995. .probe = ps3fb_probe,
  996. .remove = ps3fb_shutdown,
  997. .shutdown = ps3fb_shutdown,
  998. };
  999. static int __init ps3fb_setup(void)
  1000. {
  1001. char *options;
  1002. #ifdef MODULE
  1003. return 0;
  1004. #endif
  1005. if (fb_get_options(DEVICE_NAME, &options))
  1006. return -ENXIO;
  1007. if (!options || !*options)
  1008. return 0;
  1009. while (1) {
  1010. char *this_opt = strsep(&options, ",");
  1011. if (!this_opt)
  1012. break;
  1013. if (!*this_opt)
  1014. continue;
  1015. if (!strncmp(this_opt, "mode:", 5))
  1016. ps3fb_mode = simple_strtoul(this_opt + 5, NULL, 0);
  1017. else
  1018. mode_option = this_opt;
  1019. }
  1020. return 0;
  1021. }
  1022. static int __init ps3fb_init(void)
  1023. {
  1024. if (!ps3fb_videomemory.address || ps3fb_setup())
  1025. return -ENXIO;
  1026. return ps3_system_bus_driver_register(&ps3fb_driver);
  1027. }
  1028. static void __exit ps3fb_exit(void)
  1029. {
  1030. DPRINTK(" -> %s:%d\n", __func__, __LINE__);
  1031. ps3_system_bus_driver_unregister(&ps3fb_driver);
  1032. DPRINTK(" <- %s:%d\n", __func__, __LINE__);
  1033. }
  1034. module_init(ps3fb_init);
  1035. module_exit(ps3fb_exit);
  1036. MODULE_LICENSE("GPL");
  1037. MODULE_DESCRIPTION("PS3 GPU Frame Buffer Driver");
  1038. MODULE_AUTHOR("Sony Computer Entertainment Inc.");
  1039. MODULE_ALIAS(PS3_MODULE_ALIAS_GRAPHICS);