arkfb.c 32 KB

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