fsl-diu-fb.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * Freescale DIU Frame Buffer device driver
  5. *
  6. * Authors: Hongjun Chen <hong-jun.chen@freescale.com>
  7. * Paul Widmer <paul.widmer@freescale.com>
  8. * Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
  9. * York Sun <yorksun@freescale.com>
  10. *
  11. * Based on imxfb.c Copyright (C) 2004 S.Hauer, Pengutronix
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. */
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/errno.h>
  22. #include <linux/string.h>
  23. #include <linux/slab.h>
  24. #include <linux/fb.h>
  25. #include <linux/init.h>
  26. #include <linux/dma-mapping.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/clk.h>
  30. #include <linux/uaccess.h>
  31. #include <linux/vmalloc.h>
  32. #include <linux/spinlock.h>
  33. #include <sysdev/fsl_soc.h>
  34. #include <linux/fsl-diu-fb.h>
  35. #include "edid.h"
  36. #define NUM_AOIS 5 /* 1 for plane 0, 2 for planes 1 & 2 each */
  37. /* HW cursor parameters */
  38. #define MAX_CURS 32
  39. /* INT_STATUS/INT_MASK field descriptions */
  40. #define INT_VSYNC 0x01 /* Vsync interrupt */
  41. #define INT_VSYNC_WB 0x02 /* Vsync interrupt for write back operation */
  42. #define INT_UNDRUN 0x04 /* Under run exception interrupt */
  43. #define INT_PARERR 0x08 /* Display parameters error interrupt */
  44. #define INT_LS_BF_VS 0x10 /* Lines before vsync. interrupt */
  45. /*
  46. * List of supported video modes
  47. *
  48. * The first entry is the default video mode. The remain entries are in
  49. * order if increasing resolution and frequency. The 320x240-60 mode is
  50. * the initial AOI for the second and third planes.
  51. */
  52. static struct fb_videomode __devinitdata fsl_diu_mode_db[] = {
  53. {
  54. .refresh = 60,
  55. .xres = 1024,
  56. .yres = 768,
  57. .pixclock = 15385,
  58. .left_margin = 160,
  59. .right_margin = 24,
  60. .upper_margin = 29,
  61. .lower_margin = 3,
  62. .hsync_len = 136,
  63. .vsync_len = 6,
  64. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  65. .vmode = FB_VMODE_NONINTERLACED
  66. },
  67. {
  68. .refresh = 60,
  69. .xres = 320,
  70. .yres = 240,
  71. .pixclock = 79440,
  72. .left_margin = 16,
  73. .right_margin = 16,
  74. .upper_margin = 16,
  75. .lower_margin = 5,
  76. .hsync_len = 48,
  77. .vsync_len = 1,
  78. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  79. .vmode = FB_VMODE_NONINTERLACED
  80. },
  81. {
  82. .refresh = 60,
  83. .xres = 640,
  84. .yres = 480,
  85. .pixclock = 39722,
  86. .left_margin = 48,
  87. .right_margin = 16,
  88. .upper_margin = 33,
  89. .lower_margin = 10,
  90. .hsync_len = 96,
  91. .vsync_len = 2,
  92. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  93. .vmode = FB_VMODE_NONINTERLACED
  94. },
  95. {
  96. .refresh = 72,
  97. .xres = 640,
  98. .yres = 480,
  99. .pixclock = 32052,
  100. .left_margin = 128,
  101. .right_margin = 24,
  102. .upper_margin = 28,
  103. .lower_margin = 9,
  104. .hsync_len = 40,
  105. .vsync_len = 3,
  106. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  107. .vmode = FB_VMODE_NONINTERLACED
  108. },
  109. {
  110. .refresh = 75,
  111. .xres = 640,
  112. .yres = 480,
  113. .pixclock = 31747,
  114. .left_margin = 120,
  115. .right_margin = 16,
  116. .upper_margin = 16,
  117. .lower_margin = 1,
  118. .hsync_len = 64,
  119. .vsync_len = 3,
  120. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  121. .vmode = FB_VMODE_NONINTERLACED
  122. },
  123. {
  124. .refresh = 90,
  125. .xres = 640,
  126. .yres = 480,
  127. .pixclock = 25057,
  128. .left_margin = 120,
  129. .right_margin = 32,
  130. .upper_margin = 14,
  131. .lower_margin = 25,
  132. .hsync_len = 40,
  133. .vsync_len = 14,
  134. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  135. .vmode = FB_VMODE_NONINTERLACED
  136. },
  137. {
  138. .refresh = 100,
  139. .xres = 640,
  140. .yres = 480,
  141. .pixclock = 22272,
  142. .left_margin = 48,
  143. .right_margin = 32,
  144. .upper_margin = 17,
  145. .lower_margin = 22,
  146. .hsync_len = 128,
  147. .vsync_len = 12,
  148. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  149. .vmode = FB_VMODE_NONINTERLACED
  150. },
  151. {
  152. .refresh = 60,
  153. .xres = 800,
  154. .yres = 480,
  155. .pixclock = 33805,
  156. .left_margin = 96,
  157. .right_margin = 24,
  158. .upper_margin = 10,
  159. .lower_margin = 3,
  160. .hsync_len = 72,
  161. .vsync_len = 7,
  162. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  163. .vmode = FB_VMODE_NONINTERLACED
  164. },
  165. {
  166. .refresh = 60,
  167. .xres = 800,
  168. .yres = 600,
  169. .pixclock = 25000,
  170. .left_margin = 88,
  171. .right_margin = 40,
  172. .upper_margin = 23,
  173. .lower_margin = 1,
  174. .hsync_len = 128,
  175. .vsync_len = 4,
  176. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  177. .vmode = FB_VMODE_NONINTERLACED
  178. },
  179. {
  180. .refresh = 60,
  181. .xres = 854,
  182. .yres = 480,
  183. .pixclock = 31518,
  184. .left_margin = 104,
  185. .right_margin = 16,
  186. .upper_margin = 13,
  187. .lower_margin = 1,
  188. .hsync_len = 88,
  189. .vsync_len = 3,
  190. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  191. .vmode = FB_VMODE_NONINTERLACED
  192. },
  193. {
  194. .refresh = 70,
  195. .xres = 1024,
  196. .yres = 768,
  197. .pixclock = 16886,
  198. .left_margin = 3,
  199. .right_margin = 3,
  200. .upper_margin = 2,
  201. .lower_margin = 2,
  202. .hsync_len = 40,
  203. .vsync_len = 18,
  204. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  205. .vmode = FB_VMODE_NONINTERLACED
  206. },
  207. {
  208. .refresh = 75,
  209. .xres = 1024,
  210. .yres = 768,
  211. .pixclock = 15009,
  212. .left_margin = 3,
  213. .right_margin = 3,
  214. .upper_margin = 2,
  215. .lower_margin = 2,
  216. .hsync_len = 80,
  217. .vsync_len = 32,
  218. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  219. .vmode = FB_VMODE_NONINTERLACED
  220. },
  221. {
  222. .refresh = 60,
  223. .xres = 1280,
  224. .yres = 480,
  225. .pixclock = 18939,
  226. .left_margin = 353,
  227. .right_margin = 47,
  228. .upper_margin = 39,
  229. .lower_margin = 4,
  230. .hsync_len = 8,
  231. .vsync_len = 2,
  232. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  233. .vmode = FB_VMODE_NONINTERLACED
  234. },
  235. {
  236. .refresh = 60,
  237. .xres = 1280,
  238. .yres = 720,
  239. .pixclock = 13426,
  240. .left_margin = 192,
  241. .right_margin = 64,
  242. .upper_margin = 22,
  243. .lower_margin = 1,
  244. .hsync_len = 136,
  245. .vsync_len = 3,
  246. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  247. .vmode = FB_VMODE_NONINTERLACED
  248. },
  249. {
  250. .refresh = 60,
  251. .xres = 1280,
  252. .yres = 1024,
  253. .pixclock = 9375,
  254. .left_margin = 38,
  255. .right_margin = 128,
  256. .upper_margin = 2,
  257. .lower_margin = 7,
  258. .hsync_len = 216,
  259. .vsync_len = 37,
  260. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  261. .vmode = FB_VMODE_NONINTERLACED
  262. },
  263. {
  264. .refresh = 70,
  265. .xres = 1280,
  266. .yres = 1024,
  267. .pixclock = 9380,
  268. .left_margin = 6,
  269. .right_margin = 6,
  270. .upper_margin = 4,
  271. .lower_margin = 4,
  272. .hsync_len = 60,
  273. .vsync_len = 94,
  274. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  275. .vmode = FB_VMODE_NONINTERLACED
  276. },
  277. {
  278. .refresh = 75,
  279. .xres = 1280,
  280. .yres = 1024,
  281. .pixclock = 9380,
  282. .left_margin = 6,
  283. .right_margin = 6,
  284. .upper_margin = 4,
  285. .lower_margin = 4,
  286. .hsync_len = 60,
  287. .vsync_len = 15,
  288. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  289. .vmode = FB_VMODE_NONINTERLACED
  290. },
  291. {
  292. .refresh = 60,
  293. .xres = 1920,
  294. .yres = 1080,
  295. .pixclock = 5787,
  296. .left_margin = 328,
  297. .right_margin = 120,
  298. .upper_margin = 34,
  299. .lower_margin = 1,
  300. .hsync_len = 208,
  301. .vsync_len = 3,
  302. .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  303. .vmode = FB_VMODE_NONINTERLACED
  304. },
  305. };
  306. static char *fb_mode;
  307. static unsigned long default_bpp = 32;
  308. static enum fsl_diu_monitor_port monitor_port;
  309. static char *monitor_string;
  310. #if defined(CONFIG_NOT_COHERENT_CACHE)
  311. static u8 *coherence_data;
  312. static size_t coherence_data_size;
  313. static unsigned int d_cache_line_size;
  314. #endif
  315. static DEFINE_SPINLOCK(diu_lock);
  316. enum mfb_index {
  317. PLANE0 = 0, /* Plane 0, only one AOI that fills the screen */
  318. PLANE1_AOI0, /* Plane 1, first AOI */
  319. PLANE1_AOI1, /* Plane 1, second AOI */
  320. PLANE2_AOI0, /* Plane 2, first AOI */
  321. PLANE2_AOI1, /* Plane 2, second AOI */
  322. };
  323. struct mfb_info {
  324. enum mfb_index index;
  325. char *id;
  326. int registered;
  327. unsigned long pseudo_palette[16];
  328. struct diu_ad *ad;
  329. int cursor_reset;
  330. unsigned char g_alpha;
  331. unsigned int count;
  332. int x_aoi_d; /* aoi display x offset to physical screen */
  333. int y_aoi_d; /* aoi display y offset to physical screen */
  334. struct fsl_diu_data *parent;
  335. u8 *edid_data;
  336. };
  337. /**
  338. * struct fsl_diu_data - per-DIU data structure
  339. * @dma_addr: DMA address of this structure
  340. * @fsl_diu_info: fb_info objects, one per AOI
  341. * @dev_attr: sysfs structure
  342. * @irq: IRQ
  343. * @monitor_port: the monitor port this DIU is connected to
  344. * @diu_reg: pointer to the DIU hardware registers
  345. * @reg_lock: spinlock for register access
  346. * @dummy_aoi: video buffer for the 4x4 32-bit dummy AOI
  347. * dummy_ad: DIU Area Descriptor for the dummy AOI
  348. * @ad[]: Area Descriptors for each real AOI
  349. * @gamma: gamma color table
  350. * @cursor: hardware cursor data
  351. *
  352. * This data structure must be allocated with 32-byte alignment, so that the
  353. * internal fields can be aligned properly.
  354. */
  355. struct fsl_diu_data {
  356. dma_addr_t dma_addr;
  357. struct fb_info fsl_diu_info[NUM_AOIS];
  358. struct mfb_info mfb[NUM_AOIS];
  359. struct device_attribute dev_attr;
  360. unsigned int irq;
  361. enum fsl_diu_monitor_port monitor_port;
  362. struct diu __iomem *diu_reg;
  363. spinlock_t reg_lock;
  364. u8 dummy_aoi[4 * 4 * 4];
  365. struct diu_ad dummy_ad __aligned(8);
  366. struct diu_ad ad[NUM_AOIS] __aligned(8);
  367. u8 gamma[256 * 3] __aligned(32);
  368. u8 cursor[MAX_CURS * MAX_CURS * 2] __aligned(32);
  369. } __aligned(32);
  370. /* Determine the DMA address of a member of the fsl_diu_data structure */
  371. #define DMA_ADDR(p, f) ((p)->dma_addr + offsetof(struct fsl_diu_data, f))
  372. static struct mfb_info mfb_template[] = {
  373. {
  374. .index = PLANE0,
  375. .id = "Panel0",
  376. .registered = 0,
  377. .count = 0,
  378. .x_aoi_d = 0,
  379. .y_aoi_d = 0,
  380. },
  381. {
  382. .index = PLANE1_AOI0,
  383. .id = "Panel1 AOI0",
  384. .registered = 0,
  385. .g_alpha = 0xff,
  386. .count = 0,
  387. .x_aoi_d = 0,
  388. .y_aoi_d = 0,
  389. },
  390. {
  391. .index = PLANE1_AOI1,
  392. .id = "Panel1 AOI1",
  393. .registered = 0,
  394. .g_alpha = 0xff,
  395. .count = 0,
  396. .x_aoi_d = 0,
  397. .y_aoi_d = 480,
  398. },
  399. {
  400. .index = PLANE2_AOI0,
  401. .id = "Panel2 AOI0",
  402. .registered = 0,
  403. .g_alpha = 0xff,
  404. .count = 0,
  405. .x_aoi_d = 640,
  406. .y_aoi_d = 0,
  407. },
  408. {
  409. .index = PLANE2_AOI1,
  410. .id = "Panel2 AOI1",
  411. .registered = 0,
  412. .g_alpha = 0xff,
  413. .count = 0,
  414. .x_aoi_d = 640,
  415. .y_aoi_d = 480,
  416. },
  417. };
  418. /**
  419. * fsl_diu_name_to_port - convert a port name to a monitor port enum
  420. *
  421. * Takes the name of a monitor port ("dvi", "lvds", or "dlvds") and returns
  422. * the enum fsl_diu_monitor_port that corresponds to that string.
  423. *
  424. * For compatibility with older versions, a number ("0", "1", or "2") is also
  425. * supported.
  426. *
  427. * If the string is unknown, DVI is assumed.
  428. *
  429. * If the particular port is not supported by the platform, another port
  430. * (platform-specific) is chosen instead.
  431. */
  432. static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s)
  433. {
  434. enum fsl_diu_monitor_port port = FSL_DIU_PORT_DVI;
  435. unsigned long val;
  436. if (s) {
  437. if (!strict_strtoul(s, 10, &val) && (val <= 2))
  438. port = (enum fsl_diu_monitor_port) val;
  439. else if (strncmp(s, "lvds", 4) == 0)
  440. port = FSL_DIU_PORT_LVDS;
  441. else if (strncmp(s, "dlvds", 5) == 0)
  442. port = FSL_DIU_PORT_DLVDS;
  443. }
  444. return diu_ops.valid_monitor_port(port);
  445. }
  446. /*
  447. * Workaround for failed writing desc register of planes.
  448. * Needed with MPC5121 DIU rev 2.0 silicon.
  449. */
  450. void wr_reg_wa(u32 *reg, u32 val)
  451. {
  452. do {
  453. out_be32(reg, val);
  454. } while (in_be32(reg) != val);
  455. }
  456. static void fsl_diu_enable_panel(struct fb_info *info)
  457. {
  458. struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
  459. struct diu_ad *ad = mfbi->ad;
  460. struct fsl_diu_data *data = mfbi->parent;
  461. struct diu __iomem *hw = data->diu_reg;
  462. switch (mfbi->index) {
  463. case PLANE0:
  464. if (hw->desc[0] != ad->paddr)
  465. wr_reg_wa(&hw->desc[0], ad->paddr);
  466. break;
  467. case PLANE1_AOI0:
  468. cmfbi = &data->mfb[2];
  469. if (hw->desc[1] != ad->paddr) { /* AOI0 closed */
  470. if (cmfbi->count > 0) /* AOI1 open */
  471. ad->next_ad =
  472. cpu_to_le32(cmfbi->ad->paddr);
  473. else
  474. ad->next_ad = 0;
  475. wr_reg_wa(&hw->desc[1], ad->paddr);
  476. }
  477. break;
  478. case PLANE2_AOI0:
  479. cmfbi = &data->mfb[4];
  480. if (hw->desc[2] != ad->paddr) { /* AOI0 closed */
  481. if (cmfbi->count > 0) /* AOI1 open */
  482. ad->next_ad =
  483. cpu_to_le32(cmfbi->ad->paddr);
  484. else
  485. ad->next_ad = 0;
  486. wr_reg_wa(&hw->desc[2], ad->paddr);
  487. }
  488. break;
  489. case PLANE1_AOI1:
  490. pmfbi = &data->mfb[1];
  491. ad->next_ad = 0;
  492. if (hw->desc[1] == data->dummy_ad.paddr)
  493. wr_reg_wa(&hw->desc[1], ad->paddr);
  494. else /* AOI0 open */
  495. pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
  496. break;
  497. case PLANE2_AOI1:
  498. pmfbi = &data->mfb[3];
  499. ad->next_ad = 0;
  500. if (hw->desc[2] == data->dummy_ad.paddr)
  501. wr_reg_wa(&hw->desc[2], ad->paddr);
  502. else /* AOI0 was open */
  503. pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
  504. break;
  505. }
  506. }
  507. static void fsl_diu_disable_panel(struct fb_info *info)
  508. {
  509. struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
  510. struct diu_ad *ad = mfbi->ad;
  511. struct fsl_diu_data *data = mfbi->parent;
  512. struct diu __iomem *hw = data->diu_reg;
  513. switch (mfbi->index) {
  514. case PLANE0:
  515. if (hw->desc[0] != data->dummy_ad.paddr)
  516. wr_reg_wa(&hw->desc[0], data->dummy_ad.paddr);
  517. break;
  518. case PLANE1_AOI0:
  519. cmfbi = &data->mfb[2];
  520. if (cmfbi->count > 0) /* AOI1 is open */
  521. wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr);
  522. /* move AOI1 to the first */
  523. else /* AOI1 was closed */
  524. wr_reg_wa(&hw->desc[1], data->dummy_ad.paddr);
  525. /* close AOI 0 */
  526. break;
  527. case PLANE2_AOI0:
  528. cmfbi = &data->mfb[4];
  529. if (cmfbi->count > 0) /* AOI1 is open */
  530. wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr);
  531. /* move AOI1 to the first */
  532. else /* AOI1 was closed */
  533. wr_reg_wa(&hw->desc[2], data->dummy_ad.paddr);
  534. /* close AOI 0 */
  535. break;
  536. case PLANE1_AOI1:
  537. pmfbi = &data->mfb[1];
  538. if (hw->desc[1] != ad->paddr) {
  539. /* AOI1 is not the first in the chain */
  540. if (pmfbi->count > 0)
  541. /* AOI0 is open, must be the first */
  542. pmfbi->ad->next_ad = 0;
  543. } else /* AOI1 is the first in the chain */
  544. wr_reg_wa(&hw->desc[1], data->dummy_ad.paddr);
  545. /* close AOI 1 */
  546. break;
  547. case PLANE2_AOI1:
  548. pmfbi = &data->mfb[3];
  549. if (hw->desc[2] != ad->paddr) {
  550. /* AOI1 is not the first in the chain */
  551. if (pmfbi->count > 0)
  552. /* AOI0 is open, must be the first */
  553. pmfbi->ad->next_ad = 0;
  554. } else /* AOI1 is the first in the chain */
  555. wr_reg_wa(&hw->desc[2], data->dummy_ad.paddr);
  556. /* close AOI 1 */
  557. break;
  558. }
  559. }
  560. static void enable_lcdc(struct fb_info *info)
  561. {
  562. struct mfb_info *mfbi = info->par;
  563. struct fsl_diu_data *data = mfbi->parent;
  564. struct diu __iomem *hw = data->diu_reg;
  565. out_be32(&hw->diu_mode, MFB_MODE1);
  566. }
  567. static void disable_lcdc(struct fb_info *info)
  568. {
  569. struct mfb_info *mfbi = info->par;
  570. struct fsl_diu_data *data = mfbi->parent;
  571. struct diu __iomem *hw = data->diu_reg;
  572. out_be32(&hw->diu_mode, 0);
  573. }
  574. static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
  575. struct fb_info *info)
  576. {
  577. struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par;
  578. struct fsl_diu_data *data = mfbi->parent;
  579. int available_height, upper_aoi_bottom;
  580. enum mfb_index index = mfbi->index;
  581. int lower_aoi_is_open, upper_aoi_is_open;
  582. __u32 base_plane_width, base_plane_height, upper_aoi_height;
  583. base_plane_width = data->fsl_diu_info[0].var.xres;
  584. base_plane_height = data->fsl_diu_info[0].var.yres;
  585. if (mfbi->x_aoi_d < 0)
  586. mfbi->x_aoi_d = 0;
  587. if (mfbi->y_aoi_d < 0)
  588. mfbi->y_aoi_d = 0;
  589. switch (index) {
  590. case PLANE0:
  591. if (mfbi->x_aoi_d != 0)
  592. mfbi->x_aoi_d = 0;
  593. if (mfbi->y_aoi_d != 0)
  594. mfbi->y_aoi_d = 0;
  595. break;
  596. case PLANE1_AOI0:
  597. case PLANE2_AOI0:
  598. lower_aoi_mfbi = data->fsl_diu_info[index+1].par;
  599. lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0;
  600. if (var->xres > base_plane_width)
  601. var->xres = base_plane_width;
  602. if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
  603. mfbi->x_aoi_d = base_plane_width - var->xres;
  604. if (lower_aoi_is_open)
  605. available_height = lower_aoi_mfbi->y_aoi_d;
  606. else
  607. available_height = base_plane_height;
  608. if (var->yres > available_height)
  609. var->yres = available_height;
  610. if ((mfbi->y_aoi_d + var->yres) > available_height)
  611. mfbi->y_aoi_d = available_height - var->yres;
  612. break;
  613. case PLANE1_AOI1:
  614. case PLANE2_AOI1:
  615. upper_aoi_mfbi = data->fsl_diu_info[index-1].par;
  616. upper_aoi_height = data->fsl_diu_info[index-1].var.yres;
  617. upper_aoi_bottom = upper_aoi_mfbi->y_aoi_d + upper_aoi_height;
  618. upper_aoi_is_open = upper_aoi_mfbi->count > 0 ? 1 : 0;
  619. if (var->xres > base_plane_width)
  620. var->xres = base_plane_width;
  621. if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
  622. mfbi->x_aoi_d = base_plane_width - var->xres;
  623. if (mfbi->y_aoi_d < 0)
  624. mfbi->y_aoi_d = 0;
  625. if (upper_aoi_is_open) {
  626. if (mfbi->y_aoi_d < upper_aoi_bottom)
  627. mfbi->y_aoi_d = upper_aoi_bottom;
  628. available_height = base_plane_height
  629. - upper_aoi_bottom;
  630. } else
  631. available_height = base_plane_height;
  632. if (var->yres > available_height)
  633. var->yres = available_height;
  634. if ((mfbi->y_aoi_d + var->yres) > base_plane_height)
  635. mfbi->y_aoi_d = base_plane_height - var->yres;
  636. break;
  637. }
  638. }
  639. /*
  640. * Checks to see if the hardware supports the state requested by var passed
  641. * in. This function does not alter the hardware state! If the var passed in
  642. * is slightly off by what the hardware can support then we alter the var
  643. * PASSED in to what we can do. If the hardware doesn't support mode change
  644. * a -EINVAL will be returned by the upper layers.
  645. */
  646. static int fsl_diu_check_var(struct fb_var_screeninfo *var,
  647. struct fb_info *info)
  648. {
  649. if (var->xres_virtual < var->xres)
  650. var->xres_virtual = var->xres;
  651. if (var->yres_virtual < var->yres)
  652. var->yres_virtual = var->yres;
  653. if (var->xoffset < 0)
  654. var->xoffset = 0;
  655. if (var->yoffset < 0)
  656. var->yoffset = 0;
  657. if (var->xoffset + info->var.xres > info->var.xres_virtual)
  658. var->xoffset = info->var.xres_virtual - info->var.xres;
  659. if (var->yoffset + info->var.yres > info->var.yres_virtual)
  660. var->yoffset = info->var.yres_virtual - info->var.yres;
  661. if ((var->bits_per_pixel != 32) && (var->bits_per_pixel != 24) &&
  662. (var->bits_per_pixel != 16))
  663. var->bits_per_pixel = default_bpp;
  664. switch (var->bits_per_pixel) {
  665. case 16:
  666. var->red.length = 5;
  667. var->red.offset = 11;
  668. var->red.msb_right = 0;
  669. var->green.length = 6;
  670. var->green.offset = 5;
  671. var->green.msb_right = 0;
  672. var->blue.length = 5;
  673. var->blue.offset = 0;
  674. var->blue.msb_right = 0;
  675. var->transp.length = 0;
  676. var->transp.offset = 0;
  677. var->transp.msb_right = 0;
  678. break;
  679. case 24:
  680. var->red.length = 8;
  681. var->red.offset = 0;
  682. var->red.msb_right = 0;
  683. var->green.length = 8;
  684. var->green.offset = 8;
  685. var->green.msb_right = 0;
  686. var->blue.length = 8;
  687. var->blue.offset = 16;
  688. var->blue.msb_right = 0;
  689. var->transp.length = 0;
  690. var->transp.offset = 0;
  691. var->transp.msb_right = 0;
  692. break;
  693. case 32:
  694. var->red.length = 8;
  695. var->red.offset = 16;
  696. var->red.msb_right = 0;
  697. var->green.length = 8;
  698. var->green.offset = 8;
  699. var->green.msb_right = 0;
  700. var->blue.length = 8;
  701. var->blue.offset = 0;
  702. var->blue.msb_right = 0;
  703. var->transp.length = 8;
  704. var->transp.offset = 24;
  705. var->transp.msb_right = 0;
  706. break;
  707. }
  708. var->height = -1;
  709. var->width = -1;
  710. var->grayscale = 0;
  711. /* Copy nonstd field to/from sync for fbset usage */
  712. var->sync |= var->nonstd;
  713. var->nonstd |= var->sync;
  714. adjust_aoi_size_position(var, info);
  715. return 0;
  716. }
  717. static void set_fix(struct fb_info *info)
  718. {
  719. struct fb_fix_screeninfo *fix = &info->fix;
  720. struct fb_var_screeninfo *var = &info->var;
  721. struct mfb_info *mfbi = info->par;
  722. strncpy(fix->id, mfbi->id, sizeof(fix->id));
  723. fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
  724. fix->type = FB_TYPE_PACKED_PIXELS;
  725. fix->accel = FB_ACCEL_NONE;
  726. fix->visual = FB_VISUAL_TRUECOLOR;
  727. fix->xpanstep = 1;
  728. fix->ypanstep = 1;
  729. }
  730. static void update_lcdc(struct fb_info *info)
  731. {
  732. struct fb_var_screeninfo *var = &info->var;
  733. struct mfb_info *mfbi = info->par;
  734. struct fsl_diu_data *data = mfbi->parent;
  735. struct diu __iomem *hw;
  736. int i, j;
  737. u8 *gamma_table_base;
  738. u32 temp;
  739. hw = data->diu_reg;
  740. diu_ops.set_monitor_port(data->monitor_port);
  741. gamma_table_base = data->gamma;
  742. /* Prep for DIU init - gamma table, cursor table */
  743. for (i = 0; i <= 2; i++)
  744. for (j = 0; j <= 255; j++)
  745. *gamma_table_base++ = j;
  746. if (diu_ops.set_gamma_table)
  747. diu_ops.set_gamma_table(data->monitor_port, data->gamma);
  748. disable_lcdc(info);
  749. /* Program DIU registers */
  750. out_be32(&hw->gamma, DMA_ADDR(data, gamma));
  751. out_be32(&hw->cursor, DMA_ADDR(data, cursor));
  752. out_be32(&hw->bgnd, 0x007F7F7F); /* BGND */
  753. out_be32(&hw->bgnd_wb, 0); /* BGND_WB */
  754. out_be32(&hw->disp_size, (var->yres << 16 | var->xres));
  755. /* DISP SIZE */
  756. out_be32(&hw->wb_size, 0); /* WB SIZE */
  757. out_be32(&hw->wb_mem_addr, 0); /* WB MEM ADDR */
  758. /* Horizontal and vertical configuration register */
  759. temp = var->left_margin << 22 | /* BP_H */
  760. var->hsync_len << 11 | /* PW_H */
  761. var->right_margin; /* FP_H */
  762. out_be32(&hw->hsyn_para, temp);
  763. temp = var->upper_margin << 22 | /* BP_V */
  764. var->vsync_len << 11 | /* PW_V */
  765. var->lower_margin; /* FP_V */
  766. out_be32(&hw->vsyn_para, temp);
  767. diu_ops.set_pixel_clock(var->pixclock);
  768. out_be32(&hw->syn_pol, 0); /* SYNC SIGNALS POLARITY */
  769. out_be32(&hw->int_status, 0); /* INTERRUPT STATUS */
  770. out_be32(&hw->plut, 0x01F5F666);
  771. /* Enable the DIU */
  772. enable_lcdc(info);
  773. }
  774. static int map_video_memory(struct fb_info *info)
  775. {
  776. u32 smem_len = info->fix.line_length * info->var.yres_virtual;
  777. void *p;
  778. p = alloc_pages_exact(smem_len, GFP_DMA | __GFP_ZERO);
  779. if (!p) {
  780. dev_err(info->dev, "unable to allocate fb memory\n");
  781. return -ENOMEM;
  782. }
  783. mutex_lock(&info->mm_lock);
  784. info->screen_base = p;
  785. info->fix.smem_start = virt_to_phys(info->screen_base);
  786. info->fix.smem_len = smem_len;
  787. mutex_unlock(&info->mm_lock);
  788. info->screen_size = info->fix.smem_len;
  789. return 0;
  790. }
  791. static void unmap_video_memory(struct fb_info *info)
  792. {
  793. void *p = info->screen_base;
  794. size_t l = info->fix.smem_len;
  795. mutex_lock(&info->mm_lock);
  796. info->screen_base = NULL;
  797. info->fix.smem_start = 0;
  798. info->fix.smem_len = 0;
  799. mutex_unlock(&info->mm_lock);
  800. if (p)
  801. free_pages_exact(p, l);
  802. }
  803. /*
  804. * Using the fb_var_screeninfo in fb_info we set the aoi of this
  805. * particular framebuffer. It is a light version of fsl_diu_set_par.
  806. */
  807. static int fsl_diu_set_aoi(struct fb_info *info)
  808. {
  809. struct fb_var_screeninfo *var = &info->var;
  810. struct mfb_info *mfbi = info->par;
  811. struct diu_ad *ad = mfbi->ad;
  812. /* AOI should not be greater than display size */
  813. ad->offset_xyi = cpu_to_le32((var->yoffset << 16) | var->xoffset);
  814. ad->offset_xyd = cpu_to_le32((mfbi->y_aoi_d << 16) | mfbi->x_aoi_d);
  815. return 0;
  816. }
  817. /**
  818. * fsl_diu_get_pixel_format: return the pixel format for a given color depth
  819. *
  820. * The pixel format is a 32-bit value that determine which bits in each
  821. * pixel are to be used for each color. This is the default function used
  822. * if the platform does not define its own version.
  823. */
  824. static u32 fsl_diu_get_pixel_format(unsigned int bits_per_pixel)
  825. {
  826. #define PF_BYTE_F 0x10000000
  827. #define PF_ALPHA_C_MASK 0x0E000000
  828. #define PF_ALPHA_C_SHIFT 25
  829. #define PF_BLUE_C_MASK 0x01800000
  830. #define PF_BLUE_C_SHIFT 23
  831. #define PF_GREEN_C_MASK 0x00600000
  832. #define PF_GREEN_C_SHIFT 21
  833. #define PF_RED_C_MASK 0x00180000
  834. #define PF_RED_C_SHIFT 19
  835. #define PF_PALETTE 0x00040000
  836. #define PF_PIXEL_S_MASK 0x00030000
  837. #define PF_PIXEL_S_SHIFT 16
  838. #define PF_COMP_3_MASK 0x0000F000
  839. #define PF_COMP_3_SHIFT 12
  840. #define PF_COMP_2_MASK 0x00000F00
  841. #define PF_COMP_2_SHIFT 8
  842. #define PF_COMP_1_MASK 0x000000F0
  843. #define PF_COMP_1_SHIFT 4
  844. #define PF_COMP_0_MASK 0x0000000F
  845. #define PF_COMP_0_SHIFT 0
  846. #define MAKE_PF(alpha, red, blue, green, size, c0, c1, c2, c3) \
  847. cpu_to_le32(PF_BYTE_F | (alpha << PF_ALPHA_C_SHIFT) | \
  848. (blue << PF_BLUE_C_SHIFT) | (green << PF_GREEN_C_SHIFT) | \
  849. (red << PF_RED_C_SHIFT) | (c3 << PF_COMP_3_SHIFT) | \
  850. (c2 << PF_COMP_2_SHIFT) | (c1 << PF_COMP_1_SHIFT) | \
  851. (c0 << PF_COMP_0_SHIFT) | (size << PF_PIXEL_S_SHIFT))
  852. switch (bits_per_pixel) {
  853. case 32:
  854. /* 0x88883316 */
  855. return MAKE_PF(3, 2, 0, 1, 3, 8, 8, 8, 8);
  856. case 24:
  857. /* 0x88082219 */
  858. return MAKE_PF(4, 0, 1, 2, 2, 0, 8, 8, 8);
  859. case 16:
  860. /* 0x65053118 */
  861. return MAKE_PF(4, 2, 1, 0, 1, 5, 6, 5, 0);
  862. default:
  863. pr_err("fsl-diu: unsupported color depth %u\n", bits_per_pixel);
  864. return 0;
  865. }
  866. }
  867. /*
  868. * Using the fb_var_screeninfo in fb_info we set the resolution of this
  869. * particular framebuffer. This function alters the fb_fix_screeninfo stored
  870. * in fb_info. It does not alter var in fb_info since we are using that
  871. * data. This means we depend on the data in var inside fb_info to be
  872. * supported by the hardware. fsl_diu_check_var is always called before
  873. * fsl_diu_set_par to ensure this.
  874. */
  875. static int fsl_diu_set_par(struct fb_info *info)
  876. {
  877. unsigned long len;
  878. struct fb_var_screeninfo *var = &info->var;
  879. struct mfb_info *mfbi = info->par;
  880. struct fsl_diu_data *data = mfbi->parent;
  881. struct diu_ad *ad = mfbi->ad;
  882. struct diu __iomem *hw;
  883. hw = data->diu_reg;
  884. set_fix(info);
  885. mfbi->cursor_reset = 1;
  886. len = info->var.yres_virtual * info->fix.line_length;
  887. /* Alloc & dealloc each time resolution/bpp change */
  888. if (len != info->fix.smem_len) {
  889. if (info->fix.smem_start)
  890. unmap_video_memory(info);
  891. /* Memory allocation for framebuffer */
  892. if (map_video_memory(info)) {
  893. dev_err(info->dev, "unable to allocate fb memory 1\n");
  894. return -ENOMEM;
  895. }
  896. }
  897. if (diu_ops.get_pixel_format)
  898. ad->pix_fmt = diu_ops.get_pixel_format(data->monitor_port,
  899. var->bits_per_pixel);
  900. else
  901. ad->pix_fmt = fsl_diu_get_pixel_format(var->bits_per_pixel);
  902. ad->addr = cpu_to_le32(info->fix.smem_start);
  903. ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) |
  904. var->xres_virtual) | mfbi->g_alpha;
  905. /* AOI should not be greater than display size */
  906. ad->aoi_size = cpu_to_le32((var->yres << 16) | var->xres);
  907. ad->offset_xyi = cpu_to_le32((var->yoffset << 16) | var->xoffset);
  908. ad->offset_xyd = cpu_to_le32((mfbi->y_aoi_d << 16) | mfbi->x_aoi_d);
  909. /* Disable chroma keying function */
  910. ad->ckmax_r = 0;
  911. ad->ckmax_g = 0;
  912. ad->ckmax_b = 0;
  913. ad->ckmin_r = 255;
  914. ad->ckmin_g = 255;
  915. ad->ckmin_b = 255;
  916. if (mfbi->index == PLANE0)
  917. update_lcdc(info);
  918. return 0;
  919. }
  920. static inline __u32 CNVT_TOHW(__u32 val, __u32 width)
  921. {
  922. return ((val << width) + 0x7FFF - val) >> 16;
  923. }
  924. /*
  925. * Set a single color register. The values supplied have a 16 bit magnitude
  926. * which needs to be scaled in this function for the hardware. Things to take
  927. * into consideration are how many color registers, if any, are supported with
  928. * the current color visual. With truecolor mode no color palettes are
  929. * supported. Here a pseudo palette is created which we store the value in
  930. * pseudo_palette in struct fb_info. For pseudocolor mode we have a limited
  931. * color palette.
  932. */
  933. static int fsl_diu_setcolreg(unsigned int regno, unsigned int red,
  934. unsigned int green, unsigned int blue,
  935. unsigned int transp, struct fb_info *info)
  936. {
  937. int ret = 1;
  938. /*
  939. * If greyscale is true, then we convert the RGB value
  940. * to greyscale no matter what visual we are using.
  941. */
  942. if (info->var.grayscale)
  943. red = green = blue = (19595 * red + 38470 * green +
  944. 7471 * blue) >> 16;
  945. switch (info->fix.visual) {
  946. case FB_VISUAL_TRUECOLOR:
  947. /*
  948. * 16-bit True Colour. We encode the RGB value
  949. * according to the RGB bitfield information.
  950. */
  951. if (regno < 16) {
  952. u32 *pal = info->pseudo_palette;
  953. u32 v;
  954. red = CNVT_TOHW(red, info->var.red.length);
  955. green = CNVT_TOHW(green, info->var.green.length);
  956. blue = CNVT_TOHW(blue, info->var.blue.length);
  957. transp = CNVT_TOHW(transp, info->var.transp.length);
  958. v = (red << info->var.red.offset) |
  959. (green << info->var.green.offset) |
  960. (blue << info->var.blue.offset) |
  961. (transp << info->var.transp.offset);
  962. pal[regno] = v;
  963. ret = 0;
  964. }
  965. break;
  966. }
  967. return ret;
  968. }
  969. /*
  970. * Pan (or wrap, depending on the `vmode' field) the display using the
  971. * 'xoffset' and 'yoffset' fields of the 'var' structure. If the values
  972. * don't fit, return -EINVAL.
  973. */
  974. static int fsl_diu_pan_display(struct fb_var_screeninfo *var,
  975. struct fb_info *info)
  976. {
  977. if ((info->var.xoffset == var->xoffset) &&
  978. (info->var.yoffset == var->yoffset))
  979. return 0; /* No change, do nothing */
  980. if (var->xoffset < 0 || var->yoffset < 0
  981. || var->xoffset + info->var.xres > info->var.xres_virtual
  982. || var->yoffset + info->var.yres > info->var.yres_virtual)
  983. return -EINVAL;
  984. info->var.xoffset = var->xoffset;
  985. info->var.yoffset = var->yoffset;
  986. if (var->vmode & FB_VMODE_YWRAP)
  987. info->var.vmode |= FB_VMODE_YWRAP;
  988. else
  989. info->var.vmode &= ~FB_VMODE_YWRAP;
  990. fsl_diu_set_aoi(info);
  991. return 0;
  992. }
  993. static int fsl_diu_ioctl(struct fb_info *info, unsigned int cmd,
  994. unsigned long arg)
  995. {
  996. struct mfb_info *mfbi = info->par;
  997. struct diu_ad *ad = mfbi->ad;
  998. struct mfb_chroma_key ck;
  999. unsigned char global_alpha;
  1000. struct aoi_display_offset aoi_d;
  1001. __u32 pix_fmt;
  1002. void __user *buf = (void __user *)arg;
  1003. if (!arg)
  1004. return -EINVAL;
  1005. switch (cmd) {
  1006. case MFB_SET_PIXFMT_OLD:
  1007. dev_warn(info->dev,
  1008. "MFB_SET_PIXFMT value of 0x%08x is deprecated.\n",
  1009. MFB_SET_PIXFMT_OLD);
  1010. case MFB_SET_PIXFMT:
  1011. if (copy_from_user(&pix_fmt, buf, sizeof(pix_fmt)))
  1012. return -EFAULT;
  1013. ad->pix_fmt = pix_fmt;
  1014. break;
  1015. case MFB_GET_PIXFMT_OLD:
  1016. dev_warn(info->dev,
  1017. "MFB_GET_PIXFMT value of 0x%08x is deprecated.\n",
  1018. MFB_GET_PIXFMT_OLD);
  1019. case MFB_GET_PIXFMT:
  1020. pix_fmt = ad->pix_fmt;
  1021. if (copy_to_user(buf, &pix_fmt, sizeof(pix_fmt)))
  1022. return -EFAULT;
  1023. break;
  1024. case MFB_SET_AOID:
  1025. if (copy_from_user(&aoi_d, buf, sizeof(aoi_d)))
  1026. return -EFAULT;
  1027. mfbi->x_aoi_d = aoi_d.x_aoi_d;
  1028. mfbi->y_aoi_d = aoi_d.y_aoi_d;
  1029. fsl_diu_check_var(&info->var, info);
  1030. fsl_diu_set_aoi(info);
  1031. break;
  1032. case MFB_GET_AOID:
  1033. aoi_d.x_aoi_d = mfbi->x_aoi_d;
  1034. aoi_d.y_aoi_d = mfbi->y_aoi_d;
  1035. if (copy_to_user(buf, &aoi_d, sizeof(aoi_d)))
  1036. return -EFAULT;
  1037. break;
  1038. case MFB_GET_ALPHA:
  1039. global_alpha = mfbi->g_alpha;
  1040. if (copy_to_user(buf, &global_alpha, sizeof(global_alpha)))
  1041. return -EFAULT;
  1042. break;
  1043. case MFB_SET_ALPHA:
  1044. /* set panel information */
  1045. if (copy_from_user(&global_alpha, buf, sizeof(global_alpha)))
  1046. return -EFAULT;
  1047. ad->src_size_g_alpha = (ad->src_size_g_alpha & (~0xff)) |
  1048. (global_alpha & 0xff);
  1049. mfbi->g_alpha = global_alpha;
  1050. break;
  1051. case MFB_SET_CHROMA_KEY:
  1052. /* set panel winformation */
  1053. if (copy_from_user(&ck, buf, sizeof(ck)))
  1054. return -EFAULT;
  1055. if (ck.enable &&
  1056. (ck.red_max < ck.red_min ||
  1057. ck.green_max < ck.green_min ||
  1058. ck.blue_max < ck.blue_min))
  1059. return -EINVAL;
  1060. if (!ck.enable) {
  1061. ad->ckmax_r = 0;
  1062. ad->ckmax_g = 0;
  1063. ad->ckmax_b = 0;
  1064. ad->ckmin_r = 255;
  1065. ad->ckmin_g = 255;
  1066. ad->ckmin_b = 255;
  1067. } else {
  1068. ad->ckmax_r = ck.red_max;
  1069. ad->ckmax_g = ck.green_max;
  1070. ad->ckmax_b = ck.blue_max;
  1071. ad->ckmin_r = ck.red_min;
  1072. ad->ckmin_g = ck.green_min;
  1073. ad->ckmin_b = ck.blue_min;
  1074. }
  1075. break;
  1076. default:
  1077. dev_err(info->dev, "unknown ioctl command (0x%08X)\n", cmd);
  1078. return -ENOIOCTLCMD;
  1079. }
  1080. return 0;
  1081. }
  1082. /* turn on fb if count == 1
  1083. */
  1084. static int fsl_diu_open(struct fb_info *info, int user)
  1085. {
  1086. struct mfb_info *mfbi = info->par;
  1087. int res = 0;
  1088. /* free boot splash memory on first /dev/fb0 open */
  1089. if ((mfbi->index == PLANE0) && diu_ops.release_bootmem)
  1090. diu_ops.release_bootmem();
  1091. spin_lock(&diu_lock);
  1092. mfbi->count++;
  1093. if (mfbi->count == 1) {
  1094. fsl_diu_check_var(&info->var, info);
  1095. res = fsl_diu_set_par(info);
  1096. if (res < 0)
  1097. mfbi->count--;
  1098. else
  1099. fsl_diu_enable_panel(info);
  1100. }
  1101. spin_unlock(&diu_lock);
  1102. return res;
  1103. }
  1104. /* turn off fb if count == 0
  1105. */
  1106. static int fsl_diu_release(struct fb_info *info, int user)
  1107. {
  1108. struct mfb_info *mfbi = info->par;
  1109. int res = 0;
  1110. spin_lock(&diu_lock);
  1111. mfbi->count--;
  1112. if (mfbi->count == 0)
  1113. fsl_diu_disable_panel(info);
  1114. spin_unlock(&diu_lock);
  1115. return res;
  1116. }
  1117. static struct fb_ops fsl_diu_ops = {
  1118. .owner = THIS_MODULE,
  1119. .fb_check_var = fsl_diu_check_var,
  1120. .fb_set_par = fsl_diu_set_par,
  1121. .fb_setcolreg = fsl_diu_setcolreg,
  1122. .fb_pan_display = fsl_diu_pan_display,
  1123. .fb_fillrect = cfb_fillrect,
  1124. .fb_copyarea = cfb_copyarea,
  1125. .fb_imageblit = cfb_imageblit,
  1126. .fb_ioctl = fsl_diu_ioctl,
  1127. .fb_open = fsl_diu_open,
  1128. .fb_release = fsl_diu_release,
  1129. };
  1130. static int __devinit install_fb(struct fb_info *info)
  1131. {
  1132. int rc;
  1133. struct mfb_info *mfbi = info->par;
  1134. const char *aoi_mode, *init_aoi_mode = "320x240";
  1135. struct fb_videomode *db = fsl_diu_mode_db;
  1136. unsigned int dbsize = ARRAY_SIZE(fsl_diu_mode_db);
  1137. int has_default_mode = 1;
  1138. info->var.activate = FB_ACTIVATE_NOW;
  1139. info->fbops = &fsl_diu_ops;
  1140. info->flags = FBINFO_DEFAULT | FBINFO_VIRTFB | FBINFO_PARTIAL_PAN_OK |
  1141. FBINFO_READS_FAST;
  1142. info->pseudo_palette = mfbi->pseudo_palette;
  1143. rc = fb_alloc_cmap(&info->cmap, 16, 0);
  1144. if (rc)
  1145. return rc;
  1146. if (mfbi->index == PLANE0) {
  1147. if (mfbi->edid_data) {
  1148. /* Now build modedb from EDID */
  1149. fb_edid_to_monspecs(mfbi->edid_data, &info->monspecs);
  1150. fb_videomode_to_modelist(info->monspecs.modedb,
  1151. info->monspecs.modedb_len,
  1152. &info->modelist);
  1153. db = info->monspecs.modedb;
  1154. dbsize = info->monspecs.modedb_len;
  1155. }
  1156. aoi_mode = fb_mode;
  1157. } else {
  1158. aoi_mode = init_aoi_mode;
  1159. }
  1160. rc = fb_find_mode(&info->var, info, aoi_mode, db, dbsize, NULL,
  1161. default_bpp);
  1162. if (!rc) {
  1163. /*
  1164. * For plane 0 we continue and look into
  1165. * driver's internal modedb.
  1166. */
  1167. if ((mfbi->index == PLANE0) && mfbi->edid_data)
  1168. has_default_mode = 0;
  1169. else
  1170. return -EINVAL;
  1171. }
  1172. if (!has_default_mode) {
  1173. rc = fb_find_mode(&info->var, info, aoi_mode, fsl_diu_mode_db,
  1174. ARRAY_SIZE(fsl_diu_mode_db), NULL, default_bpp);
  1175. if (rc)
  1176. has_default_mode = 1;
  1177. }
  1178. /* Still not found, use preferred mode from database if any */
  1179. if (!has_default_mode && info->monspecs.modedb) {
  1180. struct fb_monspecs *specs = &info->monspecs;
  1181. struct fb_videomode *modedb = &specs->modedb[0];
  1182. /*
  1183. * Get preferred timing. If not found,
  1184. * first mode in database will be used.
  1185. */
  1186. if (specs->misc & FB_MISC_1ST_DETAIL) {
  1187. int i;
  1188. for (i = 0; i < specs->modedb_len; i++) {
  1189. if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
  1190. modedb = &specs->modedb[i];
  1191. break;
  1192. }
  1193. }
  1194. }
  1195. info->var.bits_per_pixel = default_bpp;
  1196. fb_videomode_to_var(&info->var, modedb);
  1197. }
  1198. if (fsl_diu_check_var(&info->var, info)) {
  1199. dev_err(info->dev, "fsl_diu_check_var failed\n");
  1200. unmap_video_memory(info);
  1201. fb_dealloc_cmap(&info->cmap);
  1202. return -EINVAL;
  1203. }
  1204. if (register_framebuffer(info) < 0) {
  1205. dev_err(info->dev, "register_framebuffer failed\n");
  1206. unmap_video_memory(info);
  1207. fb_dealloc_cmap(&info->cmap);
  1208. return -EINVAL;
  1209. }
  1210. mfbi->registered = 1;
  1211. dev_info(info->dev, "%s registered successfully\n", mfbi->id);
  1212. return 0;
  1213. }
  1214. static void uninstall_fb(struct fb_info *info)
  1215. {
  1216. struct mfb_info *mfbi = info->par;
  1217. if (!mfbi->registered)
  1218. return;
  1219. if (mfbi->index == PLANE0)
  1220. kfree(mfbi->edid_data);
  1221. unregister_framebuffer(info);
  1222. unmap_video_memory(info);
  1223. if (&info->cmap)
  1224. fb_dealloc_cmap(&info->cmap);
  1225. mfbi->registered = 0;
  1226. }
  1227. static irqreturn_t fsl_diu_isr(int irq, void *dev_id)
  1228. {
  1229. struct diu __iomem *hw = dev_id;
  1230. unsigned int status = in_be32(&hw->int_status);
  1231. if (status) {
  1232. /* This is the workaround for underrun */
  1233. if (status & INT_UNDRUN) {
  1234. out_be32(&hw->diu_mode, 0);
  1235. udelay(1);
  1236. out_be32(&hw->diu_mode, 1);
  1237. }
  1238. #if defined(CONFIG_NOT_COHERENT_CACHE)
  1239. else if (status & INT_VSYNC) {
  1240. unsigned int i;
  1241. for (i = 0; i < coherence_data_size;
  1242. i += d_cache_line_size)
  1243. __asm__ __volatile__ (
  1244. "dcbz 0, %[input]"
  1245. ::[input]"r"(&coherence_data[i]));
  1246. }
  1247. #endif
  1248. return IRQ_HANDLED;
  1249. }
  1250. return IRQ_NONE;
  1251. }
  1252. static int request_irq_local(struct fsl_diu_data *data)
  1253. {
  1254. struct diu __iomem *hw = data->diu_reg;
  1255. u32 ints;
  1256. int ret;
  1257. /* Read to clear the status */
  1258. in_be32(&hw->int_status);
  1259. ret = request_irq(data->irq, fsl_diu_isr, 0, "fsl-diu-fb", hw);
  1260. if (!ret) {
  1261. ints = INT_PARERR | INT_LS_BF_VS;
  1262. #if !defined(CONFIG_NOT_COHERENT_CACHE)
  1263. ints |= INT_VSYNC;
  1264. #endif
  1265. /* Read to clear the status */
  1266. in_be32(&hw->int_status);
  1267. out_be32(&hw->int_mask, ints);
  1268. }
  1269. return ret;
  1270. }
  1271. static void free_irq_local(struct fsl_diu_data *data)
  1272. {
  1273. struct diu __iomem *hw = data->diu_reg;
  1274. /* Disable all LCDC interrupt */
  1275. out_be32(&hw->int_mask, 0x1f);
  1276. free_irq(data->irq, NULL);
  1277. }
  1278. #ifdef CONFIG_PM
  1279. /*
  1280. * Power management hooks. Note that we won't be called from IRQ context,
  1281. * unlike the blank functions above, so we may sleep.
  1282. */
  1283. static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state)
  1284. {
  1285. struct fsl_diu_data *data;
  1286. data = dev_get_drvdata(&ofdev->dev);
  1287. disable_lcdc(data->fsl_diu_info);
  1288. return 0;
  1289. }
  1290. static int fsl_diu_resume(struct platform_device *ofdev)
  1291. {
  1292. struct fsl_diu_data *data;
  1293. data = dev_get_drvdata(&ofdev->dev);
  1294. enable_lcdc(data->fsl_diu_info);
  1295. return 0;
  1296. }
  1297. #else
  1298. #define fsl_diu_suspend NULL
  1299. #define fsl_diu_resume NULL
  1300. #endif /* CONFIG_PM */
  1301. static ssize_t store_monitor(struct device *device,
  1302. struct device_attribute *attr, const char *buf, size_t count)
  1303. {
  1304. enum fsl_diu_monitor_port old_monitor_port;
  1305. struct fsl_diu_data *data =
  1306. container_of(attr, struct fsl_diu_data, dev_attr);
  1307. old_monitor_port = data->monitor_port;
  1308. data->monitor_port = fsl_diu_name_to_port(buf);
  1309. if (old_monitor_port != data->monitor_port) {
  1310. /* All AOIs need adjust pixel format
  1311. * fsl_diu_set_par only change the pixsel format here
  1312. * unlikely to fail. */
  1313. unsigned int i;
  1314. for (i=0; i < NUM_AOIS; i++)
  1315. fsl_diu_set_par(&data->fsl_diu_info[i]);
  1316. }
  1317. return count;
  1318. }
  1319. static ssize_t show_monitor(struct device *device,
  1320. struct device_attribute *attr, char *buf)
  1321. {
  1322. struct fsl_diu_data *data =
  1323. container_of(attr, struct fsl_diu_data, dev_attr);
  1324. switch (data->monitor_port) {
  1325. case FSL_DIU_PORT_DVI:
  1326. return sprintf(buf, "DVI\n");
  1327. case FSL_DIU_PORT_LVDS:
  1328. return sprintf(buf, "Single-link LVDS\n");
  1329. case FSL_DIU_PORT_DLVDS:
  1330. return sprintf(buf, "Dual-link LVDS\n");
  1331. }
  1332. return 0;
  1333. }
  1334. static int __devinit fsl_diu_probe(struct platform_device *pdev)
  1335. {
  1336. struct device_node *np = pdev->dev.of_node;
  1337. struct mfb_info *mfbi;
  1338. struct fsl_diu_data *data;
  1339. int diu_mode;
  1340. dma_addr_t dma_addr; /* DMA addr of fsl_diu_data struct */
  1341. unsigned int i;
  1342. int ret;
  1343. data = dma_alloc_coherent(&pdev->dev, sizeof(struct fsl_diu_data),
  1344. &dma_addr, GFP_DMA | __GFP_ZERO);
  1345. if (!data)
  1346. return -ENOMEM;
  1347. data->dma_addr = dma_addr;
  1348. /*
  1349. * dma_alloc_coherent() uses a page allocator, so the address is
  1350. * always page-aligned. We need the memory to be 32-byte aligned,
  1351. * so that's good. However, if one day the allocator changes, we
  1352. * need to catch that. It's not worth the effort to handle unaligned
  1353. * alloctions now because it's highly unlikely to ever be a problem.
  1354. */
  1355. if ((unsigned long)data & 31) {
  1356. dev_err(&pdev->dev, "misaligned allocation");
  1357. ret = -ENOMEM;
  1358. goto error;
  1359. }
  1360. spin_lock_init(&data->reg_lock);
  1361. for (i = 0; i < NUM_AOIS; i++) {
  1362. struct fb_info *info = &data->fsl_diu_info[i];
  1363. info->device = &pdev->dev;
  1364. info->par = &data->mfb[i];
  1365. /*
  1366. * We store the physical address of the AD in the reserved
  1367. * 'paddr' field of the AD itself.
  1368. */
  1369. data->ad[i].paddr = DMA_ADDR(data, ad[i]);
  1370. info->fix.smem_start = 0;
  1371. /* Initialize the AOI data structure */
  1372. mfbi = info->par;
  1373. memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
  1374. mfbi->parent = data;
  1375. mfbi->ad = &data->ad[i];
  1376. if (mfbi->index == PLANE0) {
  1377. const u8 *prop;
  1378. int len;
  1379. /* Get EDID */
  1380. prop = of_get_property(np, "edid", &len);
  1381. if (prop && len == EDID_LENGTH)
  1382. mfbi->edid_data = kmemdup(prop, EDID_LENGTH,
  1383. GFP_KERNEL);
  1384. }
  1385. }
  1386. data->diu_reg = of_iomap(np, 0);
  1387. if (!data->diu_reg) {
  1388. dev_err(&pdev->dev, "cannot map DIU registers\n");
  1389. ret = -EFAULT;
  1390. goto error;
  1391. }
  1392. diu_mode = in_be32(&data->diu_reg->diu_mode);
  1393. if (diu_mode == MFB_MODE0)
  1394. out_be32(&data->diu_reg->diu_mode, 0); /* disable DIU */
  1395. /* Get the IRQ of the DIU */
  1396. data->irq = irq_of_parse_and_map(np, 0);
  1397. if (!data->irq) {
  1398. dev_err(&pdev->dev, "could not get DIU IRQ\n");
  1399. ret = -EINVAL;
  1400. goto error;
  1401. }
  1402. data->monitor_port = monitor_port;
  1403. /* Initialize the dummy Area Descriptor */
  1404. data->dummy_ad.addr = cpu_to_le32(DMA_ADDR(data, dummy_aoi));
  1405. data->dummy_ad.pix_fmt = 0x88882317;
  1406. data->dummy_ad.src_size_g_alpha = cpu_to_le32((4 << 12) | 4);
  1407. data->dummy_ad.aoi_size = cpu_to_le32((4 << 16) | 2);
  1408. data->dummy_ad.offset_xyi = 0;
  1409. data->dummy_ad.offset_xyd = 0;
  1410. data->dummy_ad.next_ad = 0;
  1411. data->dummy_ad.paddr = DMA_ADDR(data, dummy_ad);
  1412. /*
  1413. * Let DIU display splash screen if it was pre-initialized
  1414. * by the bootloader, set dummy area descriptor otherwise.
  1415. */
  1416. if (diu_mode == MFB_MODE0)
  1417. out_be32(&data->diu_reg->desc[0], data->dummy_ad.paddr);
  1418. out_be32(&data->diu_reg->desc[1], data->dummy_ad.paddr);
  1419. out_be32(&data->diu_reg->desc[2], data->dummy_ad.paddr);
  1420. for (i = 0; i < NUM_AOIS; i++) {
  1421. ret = install_fb(&data->fsl_diu_info[i]);
  1422. if (ret) {
  1423. dev_err(&pdev->dev, "could not register fb %d\n", i);
  1424. goto error;
  1425. }
  1426. }
  1427. if (request_irq_local(data)) {
  1428. dev_err(&pdev->dev, "could not claim irq\n");
  1429. goto error;
  1430. }
  1431. sysfs_attr_init(&data->dev_attr.attr);
  1432. data->dev_attr.attr.name = "monitor";
  1433. data->dev_attr.attr.mode = S_IRUGO|S_IWUSR;
  1434. data->dev_attr.show = show_monitor;
  1435. data->dev_attr.store = store_monitor;
  1436. ret = device_create_file(&pdev->dev, &data->dev_attr);
  1437. if (ret) {
  1438. dev_err(&pdev->dev, "could not create sysfs file %s\n",
  1439. data->dev_attr.attr.name);
  1440. }
  1441. dev_set_drvdata(&pdev->dev, data);
  1442. return 0;
  1443. error:
  1444. for (i = 0; i < NUM_AOIS; i++)
  1445. uninstall_fb(&data->fsl_diu_info[i]);
  1446. iounmap(data->diu_reg);
  1447. dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), data,
  1448. data->dma_addr);
  1449. return ret;
  1450. }
  1451. static int fsl_diu_remove(struct platform_device *pdev)
  1452. {
  1453. struct fsl_diu_data *data;
  1454. int i;
  1455. data = dev_get_drvdata(&pdev->dev);
  1456. disable_lcdc(&data->fsl_diu_info[0]);
  1457. free_irq_local(data);
  1458. for (i = 0; i < NUM_AOIS; i++)
  1459. uninstall_fb(&data->fsl_diu_info[i]);
  1460. iounmap(data->diu_reg);
  1461. dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), data,
  1462. data->dma_addr);
  1463. return 0;
  1464. }
  1465. #ifndef MODULE
  1466. static int __init fsl_diu_setup(char *options)
  1467. {
  1468. char *opt;
  1469. unsigned long val;
  1470. if (!options || !*options)
  1471. return 0;
  1472. while ((opt = strsep(&options, ",")) != NULL) {
  1473. if (!*opt)
  1474. continue;
  1475. if (!strncmp(opt, "monitor=", 8)) {
  1476. monitor_port = fsl_diu_name_to_port(opt + 8);
  1477. } else if (!strncmp(opt, "bpp=", 4)) {
  1478. if (!strict_strtoul(opt + 4, 10, &val))
  1479. default_bpp = val;
  1480. } else
  1481. fb_mode = opt;
  1482. }
  1483. return 0;
  1484. }
  1485. #endif
  1486. static struct of_device_id fsl_diu_match[] = {
  1487. #ifdef CONFIG_PPC_MPC512x
  1488. {
  1489. .compatible = "fsl,mpc5121-diu",
  1490. },
  1491. #endif
  1492. {
  1493. .compatible = "fsl,diu",
  1494. },
  1495. {}
  1496. };
  1497. MODULE_DEVICE_TABLE(of, fsl_diu_match);
  1498. static struct platform_driver fsl_diu_driver = {
  1499. .driver = {
  1500. .name = "fsl-diu-fb",
  1501. .owner = THIS_MODULE,
  1502. .of_match_table = fsl_diu_match,
  1503. },
  1504. .probe = fsl_diu_probe,
  1505. .remove = fsl_diu_remove,
  1506. .suspend = fsl_diu_suspend,
  1507. .resume = fsl_diu_resume,
  1508. };
  1509. static int __init fsl_diu_init(void)
  1510. {
  1511. #ifdef CONFIG_NOT_COHERENT_CACHE
  1512. struct device_node *np;
  1513. const u32 *prop;
  1514. #endif
  1515. int ret;
  1516. #ifndef MODULE
  1517. char *option;
  1518. /*
  1519. * For kernel boot options (in 'video=xxxfb:<options>' format)
  1520. */
  1521. if (fb_get_options("fslfb", &option))
  1522. return -ENODEV;
  1523. fsl_diu_setup(option);
  1524. #else
  1525. monitor_port = fsl_diu_name_to_port(monitor_string);
  1526. #endif
  1527. pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n");
  1528. #ifdef CONFIG_NOT_COHERENT_CACHE
  1529. np = of_find_node_by_type(NULL, "cpu");
  1530. if (!np) {
  1531. pr_err("fsl-diu-fb: can't find 'cpu' device node\n");
  1532. return -ENODEV;
  1533. }
  1534. prop = of_get_property(np, "d-cache-size", NULL);
  1535. if (prop == NULL) {
  1536. pr_err("fsl-diu-fb: missing 'd-cache-size' property' "
  1537. "in 'cpu' node\n");
  1538. of_node_put(np);
  1539. return -ENODEV;
  1540. }
  1541. /*
  1542. * Freescale PLRU requires 13/8 times the cache size to do a proper
  1543. * displacement flush
  1544. */
  1545. coherence_data_size = be32_to_cpup(prop) * 13;
  1546. coherence_data_size /= 8;
  1547. prop = of_get_property(np, "d-cache-line-size", NULL);
  1548. if (prop == NULL) {
  1549. pr_err("fsl-diu-fb: missing 'd-cache-line-size' property' "
  1550. "in 'cpu' node\n");
  1551. of_node_put(np);
  1552. return -ENODEV;
  1553. }
  1554. d_cache_line_size = be32_to_cpup(prop);
  1555. of_node_put(np);
  1556. coherence_data = vmalloc(coherence_data_size);
  1557. if (!coherence_data)
  1558. return -ENOMEM;
  1559. #endif
  1560. ret = platform_driver_register(&fsl_diu_driver);
  1561. if (ret) {
  1562. pr_err("fsl-diu-fb: failed to register platform driver\n");
  1563. #if defined(CONFIG_NOT_COHERENT_CACHE)
  1564. vfree(coherence_data);
  1565. #endif
  1566. }
  1567. return ret;
  1568. }
  1569. static void __exit fsl_diu_exit(void)
  1570. {
  1571. platform_driver_unregister(&fsl_diu_driver);
  1572. #if defined(CONFIG_NOT_COHERENT_CACHE)
  1573. vfree(coherence_data);
  1574. #endif
  1575. }
  1576. module_init(fsl_diu_init);
  1577. module_exit(fsl_diu_exit);
  1578. MODULE_AUTHOR("York Sun <yorksun@freescale.com>");
  1579. MODULE_DESCRIPTION("Freescale DIU framebuffer driver");
  1580. MODULE_LICENSE("GPL");
  1581. module_param_named(mode, fb_mode, charp, 0);
  1582. MODULE_PARM_DESC(mode,
  1583. "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
  1584. module_param_named(bpp, default_bpp, ulong, 0);
  1585. MODULE_PARM_DESC(bpp, "Specify bit-per-pixel if not specified in 'mode'");
  1586. module_param_named(monitor, monitor_string, charp, 0);
  1587. MODULE_PARM_DESC(monitor, "Specify the monitor port "
  1588. "(\"dvi\", \"lvds\", or \"dlvds\") if supported by the platform");