arkfb.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. /*
  2. * linux/drivers/video/arkfb.c -- Frame buffer device driver for ARK 2000PV
  3. * with ICS 5342 dac (it is easy to add support for different dacs).
  4. *
  5. * Copyright (c) 2007 Ondrej Zajicek <santiago@crfreenet.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file COPYING in the main directory of this archive for
  9. * more details.
  10. *
  11. * Code is based on s3fb
  12. */
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/errno.h>
  16. #include <linux/string.h>
  17. #include <linux/mm.h>
  18. #include <linux/tty.h>
  19. #include <linux/slab.h>
  20. #include <linux/delay.h>
  21. #include <linux/fb.h>
  22. #include <linux/svga.h>
  23. #include <linux/init.h>
  24. #include <linux/pci.h>
  25. #include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
  26. #include <video/vga.h>
  27. #ifdef CONFIG_MTRR
  28. #include <asm/mtrr.h>
  29. #endif
  30. struct arkfb_info {
  31. int mclk_freq;
  32. int mtrr_reg;
  33. struct dac_info *dac;
  34. struct vgastate state;
  35. struct mutex open_lock;
  36. unsigned int ref_count;
  37. u32 pseudo_palette[16];
  38. };
  39. /* ------------------------------------------------------------------------- */
  40. static const struct svga_fb_format arkfb_formats[] = {
  41. { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  42. FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 8},
  43. { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  44. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16},
  45. { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1,
  46. FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16},
  47. { 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  48. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 8},
  49. {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0,
  50. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4},
  51. {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0,
  52. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4},
  53. {24, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
  54. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 8, 8},
  55. {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
  56. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 2},
  57. SVGA_FORMAT_END
  58. };
  59. /* CRT timing register sets */
  60. static const struct vga_regset ark_h_total_regs[] = {{0x00, 0, 7}, {0x41, 7, 7}, VGA_REGSET_END};
  61. static const struct vga_regset ark_h_display_regs[] = {{0x01, 0, 7}, {0x41, 6, 6}, VGA_REGSET_END};
  62. static const struct vga_regset ark_h_blank_start_regs[] = {{0x02, 0, 7}, {0x41, 5, 5}, VGA_REGSET_END};
  63. static const struct vga_regset ark_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7 }, VGA_REGSET_END};
  64. static const struct vga_regset ark_h_sync_start_regs[] = {{0x04, 0, 7}, {0x41, 4, 4}, VGA_REGSET_END};
  65. static const struct vga_regset ark_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END};
  66. static const struct vga_regset ark_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x40, 7, 7}, VGA_REGSET_END};
  67. static const struct vga_regset ark_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x40, 6, 6}, VGA_REGSET_END};
  68. static const struct vga_regset ark_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x40, 5, 5}, VGA_REGSET_END};
  69. // const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 6}, VGA_REGSET_END};
  70. static const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END};
  71. static const struct vga_regset ark_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x40, 4, 4}, VGA_REGSET_END};
  72. static const struct vga_regset ark_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END};
  73. static const struct vga_regset ark_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, VGA_REGSET_END};
  74. static const struct vga_regset ark_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x40, 0, 2}, VGA_REGSET_END};
  75. static const struct vga_regset ark_offset_regs[] = {{0x13, 0, 7}, {0x41, 3, 3}, VGA_REGSET_END};
  76. static const struct svga_timing_regs ark_timing_regs = {
  77. ark_h_total_regs, ark_h_display_regs, ark_h_blank_start_regs,
  78. ark_h_blank_end_regs, ark_h_sync_start_regs, ark_h_sync_end_regs,
  79. ark_v_total_regs, ark_v_display_regs, ark_v_blank_start_regs,
  80. ark_v_blank_end_regs, ark_v_sync_start_regs, ark_v_sync_end_regs,
  81. };
  82. /* ------------------------------------------------------------------------- */
  83. /* Module parameters */
  84. static char *mode_option __devinitdata = "640x480-8@60";
  85. #ifdef CONFIG_MTRR
  86. static int mtrr = 1;
  87. #endif
  88. MODULE_AUTHOR("(c) 2007 Ondrej Zajicek <santiago@crfreenet.org>");
  89. MODULE_LICENSE("GPL");
  90. MODULE_DESCRIPTION("fbdev driver for ARK 2000PV");
  91. module_param(mode_option, charp, 0444);
  92. MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
  93. module_param_named(mode, mode_option, charp, 0444);
  94. MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) (deprecated)");
  95. #ifdef CONFIG_MTRR
  96. module_param(mtrr, int, 0444);
  97. MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)");
  98. #endif
  99. static int threshold = 4;
  100. module_param(threshold, int, 0644);
  101. MODULE_PARM_DESC(threshold, "FIFO threshold");
  102. /* ------------------------------------------------------------------------- */
  103. static void arkfb_settile(struct fb_info *info, struct fb_tilemap *map)
  104. {
  105. const u8 *font = map->data;
  106. u8 __iomem *fb = (u8 __iomem *)info->screen_base;
  107. int i, c;
  108. if ((map->width != 8) || (map->height != 16) ||
  109. (map->depth != 1) || (map->length != 256)) {
  110. printk(KERN_ERR "fb%d: unsupported font parameters: width %d, "
  111. "height %d, depth %d, length %d\n", info->node,
  112. map->width, map->height, map->depth, map->length);
  113. return;
  114. }
  115. fb += 2;
  116. for (c = 0; c < map->length; c++) {
  117. for (i = 0; i < map->height; i++) {
  118. fb_writeb(font[i], &fb[i * 4]);
  119. fb_writeb(font[i], &fb[i * 4 + (128 * 8)]);
  120. }
  121. fb += 128;
  122. if ((c % 8) == 7)
  123. fb += 128*8;
  124. font += map->height;
  125. }
  126. }
  127. static struct fb_tile_ops arkfb_tile_ops = {
  128. .fb_settile = arkfb_settile,
  129. .fb_tilecopy = svga_tilecopy,
  130. .fb_tilefill = svga_tilefill,
  131. .fb_tileblit = svga_tileblit,
  132. .fb_tilecursor = svga_tilecursor,
  133. .fb_get_tilemax = svga_get_tilemax,
  134. };
  135. /* ------------------------------------------------------------------------- */
  136. /* image data is MSB-first, fb structure is MSB-first too */
  137. static inline u32 expand_color(u32 c)
  138. {
  139. return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF;
  140. }
  141. /* arkfb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */
  142. static void arkfb_iplan_imageblit(struct fb_info *info, const struct fb_image *image)
  143. {
  144. u32 fg = expand_color(image->fg_color);
  145. u32 bg = expand_color(image->bg_color);
  146. const u8 *src1, *src;
  147. u8 __iomem *dst1;
  148. u32 __iomem *dst;
  149. u32 val;
  150. int x, y;
  151. src1 = image->data;
  152. dst1 = info->screen_base + (image->dy * info->fix.line_length)
  153. + ((image->dx / 8) * 4);
  154. for (y = 0; y < image->height; y++) {
  155. src = src1;
  156. dst = (u32 __iomem *) dst1;
  157. for (x = 0; x < image->width; x += 8) {
  158. val = *(src++) * 0x01010101;
  159. val = (val & fg) | (~val & bg);
  160. fb_writel(val, dst++);
  161. }
  162. src1 += image->width / 8;
  163. dst1 += info->fix.line_length;
  164. }
  165. }
  166. /* arkfb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */
  167. static void arkfb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  168. {
  169. u32 fg = expand_color(rect->color);
  170. u8 __iomem *dst1;
  171. u32 __iomem *dst;
  172. int x, y;
  173. dst1 = info->screen_base + (rect->dy * info->fix.line_length)
  174. + ((rect->dx / 8) * 4);
  175. for (y = 0; y < rect->height; y++) {
  176. dst = (u32 __iomem *) dst1;
  177. for (x = 0; x < rect->width; x += 8) {
  178. fb_writel(fg, dst++);
  179. }
  180. dst1 += info->fix.line_length;
  181. }
  182. }
  183. /* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */
  184. static inline u32 expand_pixel(u32 c)
  185. {
  186. return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) |
  187. ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF;
  188. }
  189. /* arkfb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */
  190. static void arkfb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image)
  191. {
  192. u32 fg = image->fg_color * 0x11111111;
  193. u32 bg = image->bg_color * 0x11111111;
  194. const u8 *src1, *src;
  195. u8 __iomem *dst1;
  196. u32 __iomem *dst;
  197. u32 val;
  198. int x, y;
  199. src1 = image->data;
  200. dst1 = info->screen_base + (image->dy * info->fix.line_length)
  201. + ((image->dx / 8) * 4);
  202. for (y = 0; y < image->height; y++) {
  203. src = src1;
  204. dst = (u32 __iomem *) dst1;
  205. for (x = 0; x < image->width; x += 8) {
  206. val = expand_pixel(*(src++));
  207. val = (val & fg) | (~val & bg);
  208. fb_writel(val, dst++);
  209. }
  210. src1 += image->width / 8;
  211. dst1 += info->fix.line_length;
  212. }
  213. }
  214. static void arkfb_imageblit(struct fb_info *info, const struct fb_image *image)
  215. {
  216. if ((info->var.bits_per_pixel == 4) && (image->depth == 1)
  217. && ((image->width % 8) == 0) && ((image->dx % 8) == 0)) {
  218. if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)
  219. arkfb_iplan_imageblit(info, image);
  220. else
  221. arkfb_cfb4_imageblit(info, image);
  222. } else
  223. cfb_imageblit(info, image);
  224. }
  225. static void arkfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  226. {
  227. if ((info->var.bits_per_pixel == 4)
  228. && ((rect->width % 8) == 0) && ((rect->dx % 8) == 0)
  229. && (info->fix.type == FB_TYPE_INTERLEAVED_PLANES))
  230. arkfb_iplan_fillrect(info, rect);
  231. else
  232. cfb_fillrect(info, rect);
  233. }
  234. /* ------------------------------------------------------------------------- */
  235. enum
  236. {
  237. DAC_PSEUDO8_8,
  238. DAC_RGB1555_8,
  239. DAC_RGB0565_8,
  240. DAC_RGB0888_8,
  241. DAC_RGB8888_8,
  242. DAC_PSEUDO8_16,
  243. DAC_RGB1555_16,
  244. DAC_RGB0565_16,
  245. DAC_RGB0888_16,
  246. DAC_RGB8888_16,
  247. DAC_MAX
  248. };
  249. struct dac_ops {
  250. int (*dac_get_mode)(struct dac_info *info);
  251. int (*dac_set_mode)(struct dac_info *info, int mode);
  252. int (*dac_get_freq)(struct dac_info *info, int channel);
  253. int (*dac_set_freq)(struct dac_info *info, int channel, u32 freq);
  254. void (*dac_release)(struct dac_info *info);
  255. };
  256. typedef void (*dac_read_regs_t)(void *data, u8 *code, int count);
  257. typedef void (*dac_write_regs_t)(void *data, u8 *code, int count);
  258. struct dac_info
  259. {
  260. struct dac_ops *dacops;
  261. dac_read_regs_t dac_read_regs;
  262. dac_write_regs_t dac_write_regs;
  263. void *data;
  264. };
  265. static inline u8 dac_read_reg(struct dac_info *info, u8 reg)
  266. {
  267. u8 code[2] = {reg, 0};
  268. info->dac_read_regs(info->data, code, 1);
  269. return code[1];
  270. }
  271. static inline void dac_read_regs(struct dac_info *info, u8 *code, int count)
  272. {
  273. info->dac_read_regs(info->data, code, count);
  274. }
  275. static inline void dac_write_reg(struct dac_info *info, u8 reg, u8 val)
  276. {
  277. u8 code[2] = {reg, val};
  278. info->dac_write_regs(info->data, code, 1);
  279. }
  280. static inline void dac_write_regs(struct dac_info *info, u8 *code, int count)
  281. {
  282. info->dac_write_regs(info->data, code, count);
  283. }
  284. static inline int dac_set_mode(struct dac_info *info, int mode)
  285. {
  286. return info->dacops->dac_set_mode(info, mode);
  287. }
  288. static inline int dac_set_freq(struct dac_info *info, int channel, u32 freq)
  289. {
  290. return info->dacops->dac_set_freq(info, channel, freq);
  291. }
  292. static inline void dac_release(struct dac_info *info)
  293. {
  294. info->dacops->dac_release(info);
  295. }
  296. /* ------------------------------------------------------------------------- */
  297. /* ICS5342 DAC */
  298. struct ics5342_info
  299. {
  300. struct dac_info dac;
  301. u8 mode;
  302. };
  303. #define DAC_PAR(info) ((struct ics5342_info *) info)
  304. /* LSB is set to distinguish unused slots */
  305. static const u8 ics5342_mode_table[DAC_MAX] = {
  306. [DAC_PSEUDO8_8] = 0x01, [DAC_RGB1555_8] = 0x21, [DAC_RGB0565_8] = 0x61,
  307. [DAC_RGB0888_8] = 0x41, [DAC_PSEUDO8_16] = 0x11, [DAC_RGB1555_16] = 0x31,
  308. [DAC_RGB0565_16] = 0x51, [DAC_RGB0888_16] = 0x91, [DAC_RGB8888_16] = 0x71
  309. };
  310. static int ics5342_set_mode(struct dac_info *info, int mode)
  311. {
  312. u8 code;
  313. if (mode >= DAC_MAX)
  314. return -EINVAL;
  315. code = ics5342_mode_table[mode];
  316. if (! code)
  317. return -EINVAL;
  318. dac_write_reg(info, 6, code & 0xF0);
  319. DAC_PAR(info)->mode = mode;
  320. return 0;
  321. }
  322. static const struct svga_pll ics5342_pll = {3, 129, 3, 33, 0, 3,
  323. 60000, 250000, 14318};
  324. /* pd4 - allow only posdivider 4 (r=2) */
  325. static const struct svga_pll ics5342_pll_pd4 = {3, 129, 3, 33, 2, 2,
  326. 60000, 335000, 14318};
  327. /* 270 MHz should be upper bound for VCO clock according to specs,
  328. but that is too restrictive in pd4 case */
  329. static int ics5342_set_freq(struct dac_info *info, int channel, u32 freq)
  330. {
  331. u16 m, n, r;
  332. /* only postdivider 4 (r=2) is valid in mode DAC_PSEUDO8_16 */
  333. int rv = svga_compute_pll((DAC_PAR(info)->mode == DAC_PSEUDO8_16)
  334. ? &ics5342_pll_pd4 : &ics5342_pll,
  335. freq, &m, &n, &r, 0);
  336. if (rv < 0) {
  337. return -EINVAL;
  338. } else {
  339. u8 code[6] = {4, 3, 5, m-2, 5, (n-2) | (r << 5)};
  340. dac_write_regs(info, code, 3);
  341. return 0;
  342. }
  343. }
  344. static void ics5342_release(struct dac_info *info)
  345. {
  346. ics5342_set_mode(info, DAC_PSEUDO8_8);
  347. kfree(info);
  348. }
  349. static struct dac_ops ics5342_ops = {
  350. .dac_set_mode = ics5342_set_mode,
  351. .dac_set_freq = ics5342_set_freq,
  352. .dac_release = ics5342_release
  353. };
  354. static struct dac_info * ics5342_init(dac_read_regs_t drr, dac_write_regs_t dwr, void *data)
  355. {
  356. struct dac_info *info = kzalloc(sizeof(struct ics5342_info), GFP_KERNEL);
  357. if (! info)
  358. return NULL;
  359. info->dacops = &ics5342_ops;
  360. info->dac_read_regs = drr;
  361. info->dac_write_regs = dwr;
  362. info->data = data;
  363. DAC_PAR(info)->mode = DAC_PSEUDO8_8; /* estimation */
  364. return info;
  365. }
  366. /* ------------------------------------------------------------------------- */
  367. static unsigned short dac_regs[4] = {0x3c8, 0x3c9, 0x3c6, 0x3c7};
  368. static void ark_dac_read_regs(void *data, u8 *code, int count)
  369. {
  370. u8 regval = vga_rseq(NULL, 0x1C);
  371. while (count != 0)
  372. {
  373. vga_wseq(NULL, 0x1C, regval | (code[0] & 4 ? 0x80 : 0));
  374. code[1] = vga_r(NULL, dac_regs[code[0] & 3]);
  375. count--;
  376. code += 2;
  377. }
  378. vga_wseq(NULL, 0x1C, regval);
  379. }
  380. static void ark_dac_write_regs(void *data, u8 *code, int count)
  381. {
  382. u8 regval = vga_rseq(NULL, 0x1C);
  383. while (count != 0)
  384. {
  385. vga_wseq(NULL, 0x1C, regval | (code[0] & 4 ? 0x80 : 0));
  386. vga_w(NULL, dac_regs[code[0] & 3], code[1]);
  387. count--;
  388. code += 2;
  389. }
  390. vga_wseq(NULL, 0x1C, regval);
  391. }
  392. static void ark_set_pixclock(struct fb_info *info, u32 pixclock)
  393. {
  394. struct arkfb_info *par = info->par;
  395. u8 regval;
  396. int rv = dac_set_freq(par->dac, 0, 1000000000 / pixclock);
  397. if (rv < 0) {
  398. printk(KERN_ERR "fb%d: cannot set requested pixclock, keeping old value\n", info->node);
  399. return;
  400. }
  401. /* Set VGA misc register */
  402. regval = vga_r(NULL, VGA_MIS_R);
  403. vga_w(NULL, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD);
  404. }
  405. /* Open framebuffer */
  406. static int arkfb_open(struct fb_info *info, int user)
  407. {
  408. struct arkfb_info *par = info->par;
  409. mutex_lock(&(par->open_lock));
  410. if (par->ref_count == 0) {
  411. memset(&(par->state), 0, sizeof(struct vgastate));
  412. par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP;
  413. par->state.num_crtc = 0x60;
  414. par->state.num_seq = 0x30;
  415. save_vga(&(par->state));
  416. }
  417. par->ref_count++;
  418. mutex_unlock(&(par->open_lock));
  419. return 0;
  420. }
  421. /* Close framebuffer */
  422. static int arkfb_release(struct fb_info *info, int user)
  423. {
  424. struct arkfb_info *par = info->par;
  425. mutex_lock(&(par->open_lock));
  426. if (par->ref_count == 0) {
  427. mutex_unlock(&(par->open_lock));
  428. return -EINVAL;
  429. }
  430. if (par->ref_count == 1) {
  431. restore_vga(&(par->state));
  432. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  433. }
  434. par->ref_count--;
  435. mutex_unlock(&(par->open_lock));
  436. return 0;
  437. }
  438. /* Validate passed in var */
  439. static int arkfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  440. {
  441. int rv, mem, step;
  442. /* Find appropriate format */
  443. rv = svga_match_format (arkfb_formats, var, NULL);
  444. if (rv < 0)
  445. {
  446. printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node);
  447. return rv;
  448. }
  449. /* Do not allow to have real resoulution larger than virtual */
  450. if (var->xres > var->xres_virtual)
  451. var->xres_virtual = var->xres;
  452. if (var->yres > var->yres_virtual)
  453. var->yres_virtual = var->yres;
  454. /* Round up xres_virtual to have proper alignment of lines */
  455. step = arkfb_formats[rv].xresstep - 1;
  456. var->xres_virtual = (var->xres_virtual+step) & ~step;
  457. /* Check whether have enough memory */
  458. mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual;
  459. if (mem > info->screen_size)
  460. {
  461. printk(KERN_ERR "fb%d: not enough framebuffer memory (%d kB requested , %d kB available)\n", info->node, mem >> 10, (unsigned int) (info->screen_size >> 10));
  462. return -EINVAL;
  463. }
  464. rv = svga_check_timings (&ark_timing_regs, var, info->node);
  465. if (rv < 0)
  466. {
  467. printk(KERN_ERR "fb%d: invalid timings requested\n", info->node);
  468. return rv;
  469. }
  470. /* Interlaced mode is broken */
  471. if (var->vmode & FB_VMODE_INTERLACED)
  472. return -EINVAL;
  473. return 0;
  474. }
  475. /* Set video mode from par */
  476. static int arkfb_set_par(struct fb_info *info)
  477. {
  478. struct arkfb_info *par = info->par;
  479. u32 value, mode, hmul, hdiv, offset_value, screen_size;
  480. u32 bpp = info->var.bits_per_pixel;
  481. u8 regval;
  482. if (bpp != 0) {
  483. info->fix.ypanstep = 1;
  484. info->fix.line_length = (info->var.xres_virtual * bpp) / 8;
  485. info->flags &= ~FBINFO_MISC_TILEBLITTING;
  486. info->tileops = NULL;
  487. /* in 4bpp supports 8p wide tiles only, any tiles otherwise */
  488. info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0);
  489. info->pixmap.blit_y = ~(u32)0;
  490. offset_value = (info->var.xres_virtual * bpp) / 64;
  491. screen_size = info->var.yres_virtual * info->fix.line_length;
  492. } else {
  493. info->fix.ypanstep = 16;
  494. info->fix.line_length = 0;
  495. info->flags |= FBINFO_MISC_TILEBLITTING;
  496. info->tileops = &arkfb_tile_ops;
  497. /* supports 8x16 tiles only */
  498. info->pixmap.blit_x = 1 << (8 - 1);
  499. info->pixmap.blit_y = 1 << (16 - 1);
  500. offset_value = info->var.xres_virtual / 16;
  501. screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64;
  502. }
  503. info->var.xoffset = 0;
  504. info->var.yoffset = 0;
  505. info->var.activate = FB_ACTIVATE_NOW;
  506. /* Unlock registers */
  507. svga_wcrt_mask(0x11, 0x00, 0x80);
  508. /* Blank screen and turn off sync */
  509. svga_wseq_mask(0x01, 0x20, 0x20);
  510. svga_wcrt_mask(0x17, 0x00, 0x80);
  511. /* Set default values */
  512. svga_set_default_gfx_regs(par->state.vgabase);
  513. svga_set_default_atc_regs(par->state.vgabase);
  514. svga_set_default_seq_regs();
  515. svga_set_default_crt_regs();
  516. svga_wcrt_multi(par->state.vgabase, ark_line_compare_regs, 0xFFFFFFFF);
  517. svga_wcrt_multi(par->state.vgabase, ark_start_address_regs, 0);
  518. /* ARK specific initialization */
  519. svga_wseq_mask(0x10, 0x1F, 0x1F); /* enable linear framebuffer and full memory access */
  520. svga_wseq_mask(0x12, 0x03, 0x03); /* 4 MB linear framebuffer size */
  521. vga_wseq(NULL, 0x13, info->fix.smem_start >> 16);
  522. vga_wseq(NULL, 0x14, info->fix.smem_start >> 24);
  523. vga_wseq(NULL, 0x15, 0);
  524. vga_wseq(NULL, 0x16, 0);
  525. /* Set the FIFO threshold register */
  526. /* It is fascinating way to store 5-bit value in 8-bit register */
  527. regval = 0x10 | ((threshold & 0x0E) >> 1) | (threshold & 0x01) << 7 | (threshold & 0x10) << 1;
  528. vga_wseq(NULL, 0x18, regval);
  529. /* Set the offset register */
  530. pr_debug("fb%d: offset register : %d\n", info->node, offset_value);
  531. svga_wcrt_multi(par->state.vgabase, ark_offset_regs, offset_value);
  532. /* fix for hi-res textmode */
  533. svga_wcrt_mask(0x40, 0x08, 0x08);
  534. if (info->var.vmode & FB_VMODE_DOUBLE)
  535. svga_wcrt_mask(0x09, 0x80, 0x80);
  536. else
  537. svga_wcrt_mask(0x09, 0x00, 0x80);
  538. if (info->var.vmode & FB_VMODE_INTERLACED)
  539. svga_wcrt_mask(0x44, 0x04, 0x04);
  540. else
  541. svga_wcrt_mask(0x44, 0x00, 0x04);
  542. hmul = 1;
  543. hdiv = 1;
  544. mode = svga_match_format(arkfb_formats, &(info->var), &(info->fix));
  545. /* Set mode-specific register values */
  546. switch (mode) {
  547. case 0:
  548. pr_debug("fb%d: text mode\n", info->node);
  549. svga_set_textmode_vga_regs();
  550. vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */
  551. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  552. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  553. break;
  554. case 1:
  555. pr_debug("fb%d: 4 bit pseudocolor\n", info->node);
  556. vga_wgfx(NULL, VGA_GFX_MODE, 0x40);
  557. vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */
  558. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  559. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  560. break;
  561. case 2:
  562. pr_debug("fb%d: 4 bit pseudocolor, planar\n", info->node);
  563. vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */
  564. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  565. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  566. break;
  567. case 3:
  568. pr_debug("fb%d: 8 bit pseudocolor\n", info->node);
  569. vga_wseq(NULL, 0x11, 0x16); /* 8bpp accel mode */
  570. if (info->var.pixclock > 20000) {
  571. pr_debug("fb%d: not using multiplex\n", info->node);
  572. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  573. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  574. } else {
  575. pr_debug("fb%d: using multiplex\n", info->node);
  576. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  577. dac_set_mode(par->dac, DAC_PSEUDO8_16);
  578. hdiv = 2;
  579. }
  580. break;
  581. case 4:
  582. pr_debug("fb%d: 5/5/5 truecolor\n", info->node);
  583. vga_wseq(NULL, 0x11, 0x1A); /* 16bpp accel mode */
  584. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  585. dac_set_mode(par->dac, DAC_RGB1555_16);
  586. break;
  587. case 5:
  588. pr_debug("fb%d: 5/6/5 truecolor\n", info->node);
  589. vga_wseq(NULL, 0x11, 0x1A); /* 16bpp accel mode */
  590. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  591. dac_set_mode(par->dac, DAC_RGB0565_16);
  592. break;
  593. case 6:
  594. pr_debug("fb%d: 8/8/8 truecolor\n", info->node);
  595. vga_wseq(NULL, 0x11, 0x16); /* 8bpp accel mode ??? */
  596. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  597. dac_set_mode(par->dac, DAC_RGB0888_16);
  598. hmul = 3;
  599. hdiv = 2;
  600. break;
  601. case 7:
  602. pr_debug("fb%d: 8/8/8/8 truecolor\n", info->node);
  603. vga_wseq(NULL, 0x11, 0x1E); /* 32bpp accel mode */
  604. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  605. dac_set_mode(par->dac, DAC_RGB8888_16);
  606. hmul = 2;
  607. break;
  608. default:
  609. printk(KERN_ERR "fb%d: unsupported mode - bug\n", info->node);
  610. return -EINVAL;
  611. }
  612. ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul);
  613. svga_set_timings(&ark_timing_regs, &(info->var), hmul, hdiv,
  614. (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1,
  615. (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1,
  616. hmul, info->node);
  617. /* Set interlaced mode start/end register */
  618. value = info->var.xres + info->var.left_margin + info->var.right_margin + info->var.hsync_len;
  619. value = ((value * hmul / hdiv) / 8) - 5;
  620. vga_wcrt(NULL, 0x42, (value + 1) / 2);
  621. memset_io(info->screen_base, 0x00, screen_size);
  622. /* Device and screen back on */
  623. svga_wcrt_mask(0x17, 0x80, 0x80);
  624. svga_wseq_mask(0x01, 0x00, 0x20);
  625. return 0;
  626. }
  627. /* Set a colour register */
  628. static int arkfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
  629. u_int transp, struct fb_info *fb)
  630. {
  631. switch (fb->var.bits_per_pixel) {
  632. case 0:
  633. case 4:
  634. if (regno >= 16)
  635. return -EINVAL;
  636. if ((fb->var.bits_per_pixel == 4) &&
  637. (fb->var.nonstd == 0)) {
  638. outb(0xF0, VGA_PEL_MSK);
  639. outb(regno*16, VGA_PEL_IW);
  640. } else {
  641. outb(0x0F, VGA_PEL_MSK);
  642. outb(regno, VGA_PEL_IW);
  643. }
  644. outb(red >> 10, VGA_PEL_D);
  645. outb(green >> 10, VGA_PEL_D);
  646. outb(blue >> 10, VGA_PEL_D);
  647. break;
  648. case 8:
  649. if (regno >= 256)
  650. return -EINVAL;
  651. outb(0xFF, VGA_PEL_MSK);
  652. outb(regno, VGA_PEL_IW);
  653. outb(red >> 10, VGA_PEL_D);
  654. outb(green >> 10, VGA_PEL_D);
  655. outb(blue >> 10, VGA_PEL_D);
  656. break;
  657. case 16:
  658. if (regno >= 16)
  659. return 0;
  660. if (fb->var.green.length == 5)
  661. ((u32*)fb->pseudo_palette)[regno] = ((red & 0xF800) >> 1) |
  662. ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11);
  663. else if (fb->var.green.length == 6)
  664. ((u32*)fb->pseudo_palette)[regno] = (red & 0xF800) |
  665. ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
  666. else
  667. return -EINVAL;
  668. break;
  669. case 24:
  670. case 32:
  671. if (regno >= 16)
  672. return 0;
  673. ((u32*)fb->pseudo_palette)[regno] = ((red & 0xFF00) << 8) |
  674. (green & 0xFF00) | ((blue & 0xFF00) >> 8);
  675. break;
  676. default:
  677. return -EINVAL;
  678. }
  679. return 0;
  680. }
  681. /* Set the display blanking state */
  682. static int arkfb_blank(int blank_mode, struct fb_info *info)
  683. {
  684. switch (blank_mode) {
  685. case FB_BLANK_UNBLANK:
  686. pr_debug("fb%d: unblank\n", info->node);
  687. svga_wseq_mask(0x01, 0x00, 0x20);
  688. svga_wcrt_mask(0x17, 0x80, 0x80);
  689. break;
  690. case FB_BLANK_NORMAL:
  691. pr_debug("fb%d: blank\n", info->node);
  692. svga_wseq_mask(0x01, 0x20, 0x20);
  693. svga_wcrt_mask(0x17, 0x80, 0x80);
  694. break;
  695. case FB_BLANK_POWERDOWN:
  696. case FB_BLANK_HSYNC_SUSPEND:
  697. case FB_BLANK_VSYNC_SUSPEND:
  698. pr_debug("fb%d: sync down\n", info->node);
  699. svga_wseq_mask(0x01, 0x20, 0x20);
  700. svga_wcrt_mask(0x17, 0x00, 0x80);
  701. break;
  702. }
  703. return 0;
  704. }
  705. /* Pan the display */
  706. static int arkfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
  707. {
  708. struct arkfb_info *par = info->par;
  709. unsigned int offset;
  710. /* Calculate the offset */
  711. if (var->bits_per_pixel == 0) {
  712. offset = (var->yoffset / 16) * (var->xres_virtual / 2) + (var->xoffset / 2);
  713. offset = offset >> 2;
  714. } else {
  715. offset = (var->yoffset * info->fix.line_length) +
  716. (var->xoffset * var->bits_per_pixel / 8);
  717. offset = offset >> ((var->bits_per_pixel == 4) ? 2 : 3);
  718. }
  719. /* Set the offset */
  720. svga_wcrt_multi(par->state.vgabase, ark_start_address_regs, offset);
  721. return 0;
  722. }
  723. /* ------------------------------------------------------------------------- */
  724. /* Frame buffer operations */
  725. static struct fb_ops arkfb_ops = {
  726. .owner = THIS_MODULE,
  727. .fb_open = arkfb_open,
  728. .fb_release = arkfb_release,
  729. .fb_check_var = arkfb_check_var,
  730. .fb_set_par = arkfb_set_par,
  731. .fb_setcolreg = arkfb_setcolreg,
  732. .fb_blank = arkfb_blank,
  733. .fb_pan_display = arkfb_pan_display,
  734. .fb_fillrect = arkfb_fillrect,
  735. .fb_copyarea = cfb_copyarea,
  736. .fb_imageblit = arkfb_imageblit,
  737. .fb_get_caps = svga_get_caps,
  738. };
  739. /* ------------------------------------------------------------------------- */
  740. /* PCI probe */
  741. static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  742. {
  743. struct fb_info *info;
  744. struct arkfb_info *par;
  745. int rc;
  746. u8 regval;
  747. /* Ignore secondary VGA device because there is no VGA arbitration */
  748. if (! svga_primary_device(dev)) {
  749. dev_info(&(dev->dev), "ignoring secondary device\n");
  750. return -ENODEV;
  751. }
  752. /* Allocate and fill driver data structure */
  753. info = framebuffer_alloc(sizeof(struct arkfb_info), &(dev->dev));
  754. if (! info) {
  755. dev_err(&(dev->dev), "cannot allocate memory\n");
  756. return -ENOMEM;
  757. }
  758. par = info->par;
  759. mutex_init(&par->open_lock);
  760. info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN;
  761. info->fbops = &arkfb_ops;
  762. /* Prepare PCI device */
  763. rc = pci_enable_device(dev);
  764. if (rc < 0) {
  765. dev_err(info->device, "cannot enable PCI device\n");
  766. goto err_enable_device;
  767. }
  768. rc = pci_request_regions(dev, "arkfb");
  769. if (rc < 0) {
  770. dev_err(info->device, "cannot reserve framebuffer region\n");
  771. goto err_request_regions;
  772. }
  773. par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info);
  774. if (! par->dac) {
  775. rc = -ENOMEM;
  776. dev_err(info->device, "RAMDAC initialization failed\n");
  777. goto err_dac;
  778. }
  779. info->fix.smem_start = pci_resource_start(dev, 0);
  780. info->fix.smem_len = pci_resource_len(dev, 0);
  781. /* Map physical IO memory address into kernel space */
  782. info->screen_base = pci_iomap(dev, 0, 0);
  783. if (! info->screen_base) {
  784. rc = -ENOMEM;
  785. dev_err(info->device, "iomap for framebuffer failed\n");
  786. goto err_iomap;
  787. }
  788. /* FIXME get memsize */
  789. regval = vga_rseq(NULL, 0x10);
  790. info->screen_size = (1 << (regval >> 6)) << 20;
  791. info->fix.smem_len = info->screen_size;
  792. strcpy(info->fix.id, "ARK 2000PV");
  793. info->fix.mmio_start = 0;
  794. info->fix.mmio_len = 0;
  795. info->fix.type = FB_TYPE_PACKED_PIXELS;
  796. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  797. info->fix.ypanstep = 0;
  798. info->fix.accel = FB_ACCEL_NONE;
  799. info->pseudo_palette = (void*) (par->pseudo_palette);
  800. /* Prepare startup mode */
  801. rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
  802. if (! ((rc == 1) || (rc == 2))) {
  803. rc = -EINVAL;
  804. dev_err(info->device, "mode %s not found\n", mode_option);
  805. goto err_find_mode;
  806. }
  807. rc = fb_alloc_cmap(&info->cmap, 256, 0);
  808. if (rc < 0) {
  809. dev_err(info->device, "cannot allocate colormap\n");
  810. goto err_alloc_cmap;
  811. }
  812. rc = register_framebuffer(info);
  813. if (rc < 0) {
  814. dev_err(info->device, "cannot register framebugger\n");
  815. goto err_reg_fb;
  816. }
  817. printk(KERN_INFO "fb%d: %s on %s, %d MB RAM\n", info->node, info->fix.id,
  818. pci_name(dev), info->fix.smem_len >> 20);
  819. /* Record a reference to the driver data */
  820. pci_set_drvdata(dev, info);
  821. #ifdef CONFIG_MTRR
  822. if (mtrr) {
  823. par->mtrr_reg = -1;
  824. par->mtrr_reg = mtrr_add(info->fix.smem_start, info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
  825. }
  826. #endif
  827. return 0;
  828. /* Error handling */
  829. err_reg_fb:
  830. fb_dealloc_cmap(&info->cmap);
  831. err_alloc_cmap:
  832. err_find_mode:
  833. pci_iounmap(dev, info->screen_base);
  834. err_iomap:
  835. dac_release(par->dac);
  836. err_dac:
  837. pci_release_regions(dev);
  838. err_request_regions:
  839. /* pci_disable_device(dev); */
  840. err_enable_device:
  841. framebuffer_release(info);
  842. return rc;
  843. }
  844. /* PCI remove */
  845. static void __devexit ark_pci_remove(struct pci_dev *dev)
  846. {
  847. struct fb_info *info = pci_get_drvdata(dev);
  848. if (info) {
  849. struct arkfb_info *par = info->par;
  850. #ifdef CONFIG_MTRR
  851. if (par->mtrr_reg >= 0) {
  852. mtrr_del(par->mtrr_reg, 0, 0);
  853. par->mtrr_reg = -1;
  854. }
  855. #endif
  856. dac_release(par->dac);
  857. unregister_framebuffer(info);
  858. fb_dealloc_cmap(&info->cmap);
  859. pci_iounmap(dev, info->screen_base);
  860. pci_release_regions(dev);
  861. /* pci_disable_device(dev); */
  862. pci_set_drvdata(dev, NULL);
  863. framebuffer_release(info);
  864. }
  865. }
  866. #ifdef CONFIG_PM
  867. /* PCI suspend */
  868. static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
  869. {
  870. struct fb_info *info = pci_get_drvdata(dev);
  871. struct arkfb_info *par = info->par;
  872. dev_info(info->device, "suspend\n");
  873. console_lock();
  874. mutex_lock(&(par->open_lock));
  875. if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
  876. mutex_unlock(&(par->open_lock));
  877. console_unlock();
  878. return 0;
  879. }
  880. fb_set_suspend(info, 1);
  881. pci_save_state(dev);
  882. pci_disable_device(dev);
  883. pci_set_power_state(dev, pci_choose_state(dev, state));
  884. mutex_unlock(&(par->open_lock));
  885. console_unlock();
  886. return 0;
  887. }
  888. /* PCI resume */
  889. static int ark_pci_resume (struct pci_dev* dev)
  890. {
  891. struct fb_info *info = pci_get_drvdata(dev);
  892. struct arkfb_info *par = info->par;
  893. dev_info(info->device, "resume\n");
  894. console_lock();
  895. mutex_lock(&(par->open_lock));
  896. if (par->ref_count == 0)
  897. goto fail;
  898. pci_set_power_state(dev, PCI_D0);
  899. pci_restore_state(dev);
  900. if (pci_enable_device(dev))
  901. goto fail;
  902. pci_set_master(dev);
  903. arkfb_set_par(info);
  904. fb_set_suspend(info, 0);
  905. fail:
  906. mutex_unlock(&(par->open_lock));
  907. console_unlock();
  908. return 0;
  909. }
  910. #else
  911. #define ark_pci_suspend NULL
  912. #define ark_pci_resume NULL
  913. #endif /* CONFIG_PM */
  914. /* List of boards that we are trying to support */
  915. static struct pci_device_id ark_devices[] __devinitdata = {
  916. {PCI_DEVICE(0xEDD8, 0xA099)},
  917. {0, 0, 0, 0, 0, 0, 0}
  918. };
  919. MODULE_DEVICE_TABLE(pci, ark_devices);
  920. static struct pci_driver arkfb_pci_driver = {
  921. .name = "arkfb",
  922. .id_table = ark_devices,
  923. .probe = ark_pci_probe,
  924. .remove = __devexit_p(ark_pci_remove),
  925. .suspend = ark_pci_suspend,
  926. .resume = ark_pci_resume,
  927. };
  928. /* Cleanup */
  929. static void __exit arkfb_cleanup(void)
  930. {
  931. pr_debug("arkfb: cleaning up\n");
  932. pci_unregister_driver(&arkfb_pci_driver);
  933. }
  934. /* Driver Initialisation */
  935. static int __init arkfb_init(void)
  936. {
  937. #ifndef MODULE
  938. char *option = NULL;
  939. if (fb_get_options("arkfb", &option))
  940. return -ENODEV;
  941. if (option && *option)
  942. mode_option = option;
  943. #endif
  944. pr_debug("arkfb: initializing\n");
  945. return pci_register_driver(&arkfb_pci_driver);
  946. }
  947. module_init(arkfb_init);
  948. module_exit(arkfb_cleanup);