arkfb.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  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. struct arkfb_info {
  28. int mclk_freq;
  29. int wc_cookie;
  30. struct dac_info *dac;
  31. struct vgastate state;
  32. struct mutex open_lock;
  33. unsigned int ref_count;
  34. u32 pseudo_palette[16];
  35. };
  36. /* ------------------------------------------------------------------------- */
  37. static const struct svga_fb_format arkfb_formats[] = {
  38. { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  39. FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 8},
  40. { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  41. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16},
  42. { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1,
  43. FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16},
  44. { 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  45. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 8},
  46. {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0,
  47. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4},
  48. {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0,
  49. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4},
  50. {24, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
  51. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 8, 8},
  52. {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
  53. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 2},
  54. SVGA_FORMAT_END
  55. };
  56. /* CRT timing register sets */
  57. static const struct vga_regset ark_h_total_regs[] = {{0x00, 0, 7}, {0x41, 7, 7}, VGA_REGSET_END};
  58. static const struct vga_regset ark_h_display_regs[] = {{0x01, 0, 7}, {0x41, 6, 6}, VGA_REGSET_END};
  59. static const struct vga_regset ark_h_blank_start_regs[] = {{0x02, 0, 7}, {0x41, 5, 5}, VGA_REGSET_END};
  60. static const struct vga_regset ark_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7 }, VGA_REGSET_END};
  61. static const struct vga_regset ark_h_sync_start_regs[] = {{0x04, 0, 7}, {0x41, 4, 4}, VGA_REGSET_END};
  62. static const struct vga_regset ark_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END};
  63. static const struct vga_regset ark_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x40, 7, 7}, VGA_REGSET_END};
  64. static const struct vga_regset ark_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x40, 6, 6}, VGA_REGSET_END};
  65. 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};
  66. // const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 6}, VGA_REGSET_END};
  67. static const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END};
  68. 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};
  69. static const struct vga_regset ark_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END};
  70. static const struct vga_regset ark_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, VGA_REGSET_END};
  71. static const struct vga_regset ark_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x40, 0, 2}, VGA_REGSET_END};
  72. static const struct vga_regset ark_offset_regs[] = {{0x13, 0, 7}, {0x41, 3, 3}, VGA_REGSET_END};
  73. static const struct svga_timing_regs ark_timing_regs = {
  74. ark_h_total_regs, ark_h_display_regs, ark_h_blank_start_regs,
  75. ark_h_blank_end_regs, ark_h_sync_start_regs, ark_h_sync_end_regs,
  76. ark_v_total_regs, ark_v_display_regs, ark_v_blank_start_regs,
  77. ark_v_blank_end_regs, ark_v_sync_start_regs, ark_v_sync_end_regs,
  78. };
  79. /* ------------------------------------------------------------------------- */
  80. /* Module parameters */
  81. static char *mode_option = "640x480-8@60";
  82. MODULE_AUTHOR("(c) 2007 Ondrej Zajicek <santiago@crfreenet.org>");
  83. MODULE_LICENSE("GPL");
  84. MODULE_DESCRIPTION("fbdev driver for ARK 2000PV");
  85. module_param(mode_option, charp, 0444);
  86. MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
  87. module_param_named(mode, mode_option, charp, 0444);
  88. MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) (deprecated)");
  89. static int threshold = 4;
  90. module_param(threshold, int, 0644);
  91. MODULE_PARM_DESC(threshold, "FIFO threshold");
  92. /* ------------------------------------------------------------------------- */
  93. static void arkfb_settile(struct fb_info *info, struct fb_tilemap *map)
  94. {
  95. const u8 *font = map->data;
  96. u8 __iomem *fb = (u8 __iomem *)info->screen_base;
  97. int i, c;
  98. if ((map->width != 8) || (map->height != 16) ||
  99. (map->depth != 1) || (map->length != 256)) {
  100. fb_err(info, "unsupported font parameters: width %d, height %d, depth %d, length %d\n",
  101. map->width, map->height, map->depth, map->length);
  102. return;
  103. }
  104. fb += 2;
  105. for (c = 0; c < map->length; c++) {
  106. for (i = 0; i < map->height; i++) {
  107. fb_writeb(font[i], &fb[i * 4]);
  108. fb_writeb(font[i], &fb[i * 4 + (128 * 8)]);
  109. }
  110. fb += 128;
  111. if ((c % 8) == 7)
  112. fb += 128*8;
  113. font += map->height;
  114. }
  115. }
  116. static void arkfb_tilecursor(struct fb_info *info, struct fb_tilecursor *cursor)
  117. {
  118. struct arkfb_info *par = info->par;
  119. svga_tilecursor(par->state.vgabase, info, cursor);
  120. }
  121. static struct fb_tile_ops arkfb_tile_ops = {
  122. .fb_settile = arkfb_settile,
  123. .fb_tilecopy = svga_tilecopy,
  124. .fb_tilefill = svga_tilefill,
  125. .fb_tileblit = svga_tileblit,
  126. .fb_tilecursor = arkfb_tilecursor,
  127. .fb_get_tilemax = svga_get_tilemax,
  128. };
  129. /* ------------------------------------------------------------------------- */
  130. /* image data is MSB-first, fb structure is MSB-first too */
  131. static inline u32 expand_color(u32 c)
  132. {
  133. return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF;
  134. }
  135. /* arkfb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */
  136. static void arkfb_iplan_imageblit(struct fb_info *info, const struct fb_image *image)
  137. {
  138. u32 fg = expand_color(image->fg_color);
  139. u32 bg = expand_color(image->bg_color);
  140. const u8 *src1, *src;
  141. u8 __iomem *dst1;
  142. u32 __iomem *dst;
  143. u32 val;
  144. int x, y;
  145. src1 = image->data;
  146. dst1 = info->screen_base + (image->dy * info->fix.line_length)
  147. + ((image->dx / 8) * 4);
  148. for (y = 0; y < image->height; y++) {
  149. src = src1;
  150. dst = (u32 __iomem *) dst1;
  151. for (x = 0; x < image->width; x += 8) {
  152. val = *(src++) * 0x01010101;
  153. val = (val & fg) | (~val & bg);
  154. fb_writel(val, dst++);
  155. }
  156. src1 += image->width / 8;
  157. dst1 += info->fix.line_length;
  158. }
  159. }
  160. /* arkfb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */
  161. static void arkfb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  162. {
  163. u32 fg = expand_color(rect->color);
  164. u8 __iomem *dst1;
  165. u32 __iomem *dst;
  166. int x, y;
  167. dst1 = info->screen_base + (rect->dy * info->fix.line_length)
  168. + ((rect->dx / 8) * 4);
  169. for (y = 0; y < rect->height; y++) {
  170. dst = (u32 __iomem *) dst1;
  171. for (x = 0; x < rect->width; x += 8) {
  172. fb_writel(fg, dst++);
  173. }
  174. dst1 += info->fix.line_length;
  175. }
  176. }
  177. /* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */
  178. static inline u32 expand_pixel(u32 c)
  179. {
  180. return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) |
  181. ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF;
  182. }
  183. /* arkfb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */
  184. static void arkfb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image)
  185. {
  186. u32 fg = image->fg_color * 0x11111111;
  187. u32 bg = image->bg_color * 0x11111111;
  188. const u8 *src1, *src;
  189. u8 __iomem *dst1;
  190. u32 __iomem *dst;
  191. u32 val;
  192. int x, y;
  193. src1 = image->data;
  194. dst1 = info->screen_base + (image->dy * info->fix.line_length)
  195. + ((image->dx / 8) * 4);
  196. for (y = 0; y < image->height; y++) {
  197. src = src1;
  198. dst = (u32 __iomem *) dst1;
  199. for (x = 0; x < image->width; x += 8) {
  200. val = expand_pixel(*(src++));
  201. val = (val & fg) | (~val & bg);
  202. fb_writel(val, dst++);
  203. }
  204. src1 += image->width / 8;
  205. dst1 += info->fix.line_length;
  206. }
  207. }
  208. static void arkfb_imageblit(struct fb_info *info, const struct fb_image *image)
  209. {
  210. if ((info->var.bits_per_pixel == 4) && (image->depth == 1)
  211. && ((image->width % 8) == 0) && ((image->dx % 8) == 0)) {
  212. if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)
  213. arkfb_iplan_imageblit(info, image);
  214. else
  215. arkfb_cfb4_imageblit(info, image);
  216. } else
  217. cfb_imageblit(info, image);
  218. }
  219. static void arkfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  220. {
  221. if ((info->var.bits_per_pixel == 4)
  222. && ((rect->width % 8) == 0) && ((rect->dx % 8) == 0)
  223. && (info->fix.type == FB_TYPE_INTERLEAVED_PLANES))
  224. arkfb_iplan_fillrect(info, rect);
  225. else
  226. cfb_fillrect(info, rect);
  227. }
  228. /* ------------------------------------------------------------------------- */
  229. enum
  230. {
  231. DAC_PSEUDO8_8,
  232. DAC_RGB1555_8,
  233. DAC_RGB0565_8,
  234. DAC_RGB0888_8,
  235. DAC_RGB8888_8,
  236. DAC_PSEUDO8_16,
  237. DAC_RGB1555_16,
  238. DAC_RGB0565_16,
  239. DAC_RGB0888_16,
  240. DAC_RGB8888_16,
  241. DAC_MAX
  242. };
  243. struct dac_ops {
  244. int (*dac_get_mode)(struct dac_info *info);
  245. int (*dac_set_mode)(struct dac_info *info, int mode);
  246. int (*dac_get_freq)(struct dac_info *info, int channel);
  247. int (*dac_set_freq)(struct dac_info *info, int channel, u32 freq);
  248. void (*dac_release)(struct dac_info *info);
  249. };
  250. typedef void (*dac_read_regs_t)(void *data, u8 *code, int count);
  251. typedef void (*dac_write_regs_t)(void *data, u8 *code, int count);
  252. struct dac_info
  253. {
  254. struct dac_ops *dacops;
  255. dac_read_regs_t dac_read_regs;
  256. dac_write_regs_t dac_write_regs;
  257. void *data;
  258. };
  259. static inline u8 dac_read_reg(struct dac_info *info, u8 reg)
  260. {
  261. u8 code[2] = {reg, 0};
  262. info->dac_read_regs(info->data, code, 1);
  263. return code[1];
  264. }
  265. static inline void dac_read_regs(struct dac_info *info, u8 *code, int count)
  266. {
  267. info->dac_read_regs(info->data, code, count);
  268. }
  269. static inline void dac_write_reg(struct dac_info *info, u8 reg, u8 val)
  270. {
  271. u8 code[2] = {reg, val};
  272. info->dac_write_regs(info->data, code, 1);
  273. }
  274. static inline void dac_write_regs(struct dac_info *info, u8 *code, int count)
  275. {
  276. info->dac_write_regs(info->data, code, count);
  277. }
  278. static inline int dac_set_mode(struct dac_info *info, int mode)
  279. {
  280. return info->dacops->dac_set_mode(info, mode);
  281. }
  282. static inline int dac_set_freq(struct dac_info *info, int channel, u32 freq)
  283. {
  284. return info->dacops->dac_set_freq(info, channel, freq);
  285. }
  286. static inline void dac_release(struct dac_info *info)
  287. {
  288. info->dacops->dac_release(info);
  289. }
  290. /* ------------------------------------------------------------------------- */
  291. /* ICS5342 DAC */
  292. struct ics5342_info
  293. {
  294. struct dac_info dac;
  295. u8 mode;
  296. };
  297. #define DAC_PAR(info) ((struct ics5342_info *) info)
  298. /* LSB is set to distinguish unused slots */
  299. static const u8 ics5342_mode_table[DAC_MAX] = {
  300. [DAC_PSEUDO8_8] = 0x01, [DAC_RGB1555_8] = 0x21, [DAC_RGB0565_8] = 0x61,
  301. [DAC_RGB0888_8] = 0x41, [DAC_PSEUDO8_16] = 0x11, [DAC_RGB1555_16] = 0x31,
  302. [DAC_RGB0565_16] = 0x51, [DAC_RGB0888_16] = 0x91, [DAC_RGB8888_16] = 0x71
  303. };
  304. static int ics5342_set_mode(struct dac_info *info, int mode)
  305. {
  306. u8 code;
  307. if (mode >= DAC_MAX)
  308. return -EINVAL;
  309. code = ics5342_mode_table[mode];
  310. if (! code)
  311. return -EINVAL;
  312. dac_write_reg(info, 6, code & 0xF0);
  313. DAC_PAR(info)->mode = mode;
  314. return 0;
  315. }
  316. static const struct svga_pll ics5342_pll = {3, 129, 3, 33, 0, 3,
  317. 60000, 250000, 14318};
  318. /* pd4 - allow only posdivider 4 (r=2) */
  319. static const struct svga_pll ics5342_pll_pd4 = {3, 129, 3, 33, 2, 2,
  320. 60000, 335000, 14318};
  321. /* 270 MHz should be upper bound for VCO clock according to specs,
  322. but that is too restrictive in pd4 case */
  323. static int ics5342_set_freq(struct dac_info *info, int channel, u32 freq)
  324. {
  325. u16 m, n, r;
  326. /* only postdivider 4 (r=2) is valid in mode DAC_PSEUDO8_16 */
  327. int rv = svga_compute_pll((DAC_PAR(info)->mode == DAC_PSEUDO8_16)
  328. ? &ics5342_pll_pd4 : &ics5342_pll,
  329. freq, &m, &n, &r, 0);
  330. if (rv < 0) {
  331. return -EINVAL;
  332. } else {
  333. u8 code[6] = {4, 3, 5, m-2, 5, (n-2) | (r << 5)};
  334. dac_write_regs(info, code, 3);
  335. return 0;
  336. }
  337. }
  338. static void ics5342_release(struct dac_info *info)
  339. {
  340. ics5342_set_mode(info, DAC_PSEUDO8_8);
  341. kfree(info);
  342. }
  343. static struct dac_ops ics5342_ops = {
  344. .dac_set_mode = ics5342_set_mode,
  345. .dac_set_freq = ics5342_set_freq,
  346. .dac_release = ics5342_release
  347. };
  348. static struct dac_info * ics5342_init(dac_read_regs_t drr, dac_write_regs_t dwr, void *data)
  349. {
  350. struct dac_info *info = kzalloc(sizeof(struct ics5342_info), GFP_KERNEL);
  351. if (! info)
  352. return NULL;
  353. info->dacops = &ics5342_ops;
  354. info->dac_read_regs = drr;
  355. info->dac_write_regs = dwr;
  356. info->data = data;
  357. DAC_PAR(info)->mode = DAC_PSEUDO8_8; /* estimation */
  358. return info;
  359. }
  360. /* ------------------------------------------------------------------------- */
  361. static unsigned short dac_regs[4] = {0x3c8, 0x3c9, 0x3c6, 0x3c7};
  362. static void ark_dac_read_regs(void *data, u8 *code, int count)
  363. {
  364. struct fb_info *info = data;
  365. struct arkfb_info *par;
  366. u8 regval;
  367. par = info->par;
  368. regval = vga_rseq(par->state.vgabase, 0x1C);
  369. while (count != 0)
  370. {
  371. vga_wseq(par->state.vgabase, 0x1C, regval | (code[0] & 4 ? 0x80 : 0));
  372. code[1] = vga_r(par->state.vgabase, dac_regs[code[0] & 3]);
  373. count--;
  374. code += 2;
  375. }
  376. vga_wseq(par->state.vgabase, 0x1C, regval);
  377. }
  378. static void ark_dac_write_regs(void *data, u8 *code, int count)
  379. {
  380. struct fb_info *info = data;
  381. struct arkfb_info *par;
  382. u8 regval;
  383. par = info->par;
  384. regval = vga_rseq(par->state.vgabase, 0x1C);
  385. while (count != 0)
  386. {
  387. vga_wseq(par->state.vgabase, 0x1C, regval | (code[0] & 4 ? 0x80 : 0));
  388. vga_w(par->state.vgabase, dac_regs[code[0] & 3], code[1]);
  389. count--;
  390. code += 2;
  391. }
  392. vga_wseq(par->state.vgabase, 0x1C, regval);
  393. }
  394. static void ark_set_pixclock(struct fb_info *info, u32 pixclock)
  395. {
  396. struct arkfb_info *par = info->par;
  397. u8 regval;
  398. int rv = dac_set_freq(par->dac, 0, 1000000000 / pixclock);
  399. if (rv < 0) {
  400. fb_err(info, "cannot set requested pixclock, keeping old value\n");
  401. return;
  402. }
  403. /* Set VGA misc register */
  404. regval = vga_r(par->state.vgabase, VGA_MIS_R);
  405. vga_w(par->state.vgabase, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD);
  406. }
  407. /* Open framebuffer */
  408. static int arkfb_open(struct fb_info *info, int user)
  409. {
  410. struct arkfb_info *par = info->par;
  411. mutex_lock(&(par->open_lock));
  412. if (par->ref_count == 0) {
  413. void __iomem *vgabase = par->state.vgabase;
  414. memset(&(par->state), 0, sizeof(struct vgastate));
  415. par->state.vgabase = vgabase;
  416. par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP;
  417. par->state.num_crtc = 0x60;
  418. par->state.num_seq = 0x30;
  419. save_vga(&(par->state));
  420. }
  421. par->ref_count++;
  422. mutex_unlock(&(par->open_lock));
  423. return 0;
  424. }
  425. /* Close framebuffer */
  426. static int arkfb_release(struct fb_info *info, int user)
  427. {
  428. struct arkfb_info *par = info->par;
  429. mutex_lock(&(par->open_lock));
  430. if (par->ref_count == 0) {
  431. mutex_unlock(&(par->open_lock));
  432. return -EINVAL;
  433. }
  434. if (par->ref_count == 1) {
  435. restore_vga(&(par->state));
  436. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  437. }
  438. par->ref_count--;
  439. mutex_unlock(&(par->open_lock));
  440. return 0;
  441. }
  442. /* Validate passed in var */
  443. static int arkfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  444. {
  445. int rv, mem, step;
  446. /* Find appropriate format */
  447. rv = svga_match_format (arkfb_formats, var, NULL);
  448. if (rv < 0)
  449. {
  450. fb_err(info, "unsupported mode requested\n");
  451. return rv;
  452. }
  453. /* Do not allow to have real resoulution larger than virtual */
  454. if (var->xres > var->xres_virtual)
  455. var->xres_virtual = var->xres;
  456. if (var->yres > var->yres_virtual)
  457. var->yres_virtual = var->yres;
  458. /* Round up xres_virtual to have proper alignment of lines */
  459. step = arkfb_formats[rv].xresstep - 1;
  460. var->xres_virtual = (var->xres_virtual+step) & ~step;
  461. /* Check whether have enough memory */
  462. mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual;
  463. if (mem > info->screen_size)
  464. {
  465. fb_err(info, "not enough framebuffer memory (%d kB requested, %d kB available)\n",
  466. 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. fb_err(info, "invalid timings requested\n");
  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(par->state.vgabase, 0x13, info->fix.smem_start >> 16);
  527. vga_wseq(par->state.vgabase, 0x14, info->fix.smem_start >> 24);
  528. vga_wseq(par->state.vgabase, 0x15, 0);
  529. vga_wseq(par->state.vgabase, 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(par->state.vgabase, 0x18, regval);
  534. /* Set the offset register */
  535. fb_dbg(info, "offset register : %d\n", 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. fb_dbg(info, "text mode\n");
  554. svga_set_textmode_vga_regs(par->state.vgabase);
  555. vga_wseq(par->state.vgabase, 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. fb_dbg(info, "4 bit pseudocolor\n");
  561. vga_wgfx(par->state.vgabase, VGA_GFX_MODE, 0x40);
  562. vga_wseq(par->state.vgabase, 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. fb_dbg(info, "4 bit pseudocolor, planar\n");
  568. vga_wseq(par->state.vgabase, 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. fb_dbg(info, "8 bit pseudocolor\n");
  574. vga_wseq(par->state.vgabase, 0x11, 0x16); /* 8bpp accel mode */
  575. if (info->var.pixclock > 20000) {
  576. fb_dbg(info, "not using multiplex\n");
  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. fb_dbg(info, "using multiplex\n");
  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. fb_dbg(info, "5/5/5 truecolor\n");
  588. vga_wseq(par->state.vgabase, 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. fb_dbg(info, "5/6/5 truecolor\n");
  594. vga_wseq(par->state.vgabase, 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. fb_dbg(info, "8/8/8 truecolor\n");
  600. vga_wseq(par->state.vgabase, 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. fb_dbg(info, "8/8/8/8 truecolor\n");
  608. vga_wseq(par->state.vgabase, 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. fb_err(info, "unsupported mode - bug\n");
  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(par->state.vgabase, 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. fb_dbg(info, "unblank\n");
  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. fb_dbg(info, "blank\n");
  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. fb_dbg(info, "sync down\n");
  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 (info->var.bits_per_pixel == 0) {
  718. offset = (var->yoffset / 16) * (info->var.xres_virtual / 2)
  719. + (var->xoffset / 2);
  720. offset = offset >> 2;
  721. } else {
  722. offset = (var->yoffset * info->fix.line_length) +
  723. (var->xoffset * info->var.bits_per_pixel / 8);
  724. offset = offset >> ((info->var.bits_per_pixel == 4) ? 2 : 3);
  725. }
  726. /* Set the offset */
  727. svga_wcrt_multi(par->state.vgabase, ark_start_address_regs, offset);
  728. return 0;
  729. }
  730. /* ------------------------------------------------------------------------- */
  731. /* Frame buffer operations */
  732. static struct fb_ops arkfb_ops = {
  733. .owner = THIS_MODULE,
  734. .fb_open = arkfb_open,
  735. .fb_release = arkfb_release,
  736. .fb_check_var = arkfb_check_var,
  737. .fb_set_par = arkfb_set_par,
  738. .fb_setcolreg = arkfb_setcolreg,
  739. .fb_blank = arkfb_blank,
  740. .fb_pan_display = arkfb_pan_display,
  741. .fb_fillrect = arkfb_fillrect,
  742. .fb_copyarea = cfb_copyarea,
  743. .fb_imageblit = arkfb_imageblit,
  744. .fb_get_caps = svga_get_caps,
  745. };
  746. /* ------------------------------------------------------------------------- */
  747. /* PCI probe */
  748. static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  749. {
  750. struct pci_bus_region bus_reg;
  751. struct resource vga_res;
  752. struct fb_info *info;
  753. struct arkfb_info *par;
  754. int rc;
  755. u8 regval;
  756. /* Ignore secondary VGA device because there is no VGA arbitration */
  757. if (! svga_primary_device(dev)) {
  758. dev_info(&(dev->dev), "ignoring secondary device\n");
  759. return -ENODEV;
  760. }
  761. /* Allocate and fill driver data structure */
  762. info = framebuffer_alloc(sizeof(struct arkfb_info), &(dev->dev));
  763. if (! info) {
  764. dev_err(&(dev->dev), "cannot allocate memory\n");
  765. return -ENOMEM;
  766. }
  767. par = info->par;
  768. mutex_init(&par->open_lock);
  769. info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN;
  770. info->fbops = &arkfb_ops;
  771. /* Prepare PCI device */
  772. rc = pci_enable_device(dev);
  773. if (rc < 0) {
  774. dev_err(info->device, "cannot enable PCI device\n");
  775. goto err_enable_device;
  776. }
  777. rc = pci_request_regions(dev, "arkfb");
  778. if (rc < 0) {
  779. dev_err(info->device, "cannot reserve framebuffer region\n");
  780. goto err_request_regions;
  781. }
  782. par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info);
  783. if (! par->dac) {
  784. rc = -ENOMEM;
  785. dev_err(info->device, "RAMDAC initialization failed\n");
  786. goto err_dac;
  787. }
  788. info->fix.smem_start = pci_resource_start(dev, 0);
  789. info->fix.smem_len = pci_resource_len(dev, 0);
  790. /* Map physical IO memory address into kernel space */
  791. info->screen_base = pci_iomap_wc(dev, 0, 0);
  792. if (! info->screen_base) {
  793. rc = -ENOMEM;
  794. dev_err(info->device, "iomap for framebuffer failed\n");
  795. goto err_iomap;
  796. }
  797. bus_reg.start = 0;
  798. bus_reg.end = 64 * 1024;
  799. vga_res.flags = IORESOURCE_IO;
  800. pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
  801. par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
  802. /* FIXME get memsize */
  803. regval = vga_rseq(par->state.vgabase, 0x10);
  804. info->screen_size = (1 << (regval >> 6)) << 20;
  805. info->fix.smem_len = info->screen_size;
  806. strcpy(info->fix.id, "ARK 2000PV");
  807. info->fix.mmio_start = 0;
  808. info->fix.mmio_len = 0;
  809. info->fix.type = FB_TYPE_PACKED_PIXELS;
  810. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  811. info->fix.ypanstep = 0;
  812. info->fix.accel = FB_ACCEL_NONE;
  813. info->pseudo_palette = (void*) (par->pseudo_palette);
  814. /* Prepare startup mode */
  815. rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
  816. if (! ((rc == 1) || (rc == 2))) {
  817. rc = -EINVAL;
  818. dev_err(info->device, "mode %s not found\n", mode_option);
  819. goto err_find_mode;
  820. }
  821. rc = fb_alloc_cmap(&info->cmap, 256, 0);
  822. if (rc < 0) {
  823. dev_err(info->device, "cannot allocate colormap\n");
  824. goto err_alloc_cmap;
  825. }
  826. rc = register_framebuffer(info);
  827. if (rc < 0) {
  828. dev_err(info->device, "cannot register framebuffer\n");
  829. goto err_reg_fb;
  830. }
  831. fb_info(info, "%s on %s, %d MB RAM\n",
  832. info->fix.id, pci_name(dev), info->fix.smem_len >> 20);
  833. /* Record a reference to the driver data */
  834. pci_set_drvdata(dev, info);
  835. par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
  836. info->fix.smem_len);
  837. return 0;
  838. /* Error handling */
  839. err_reg_fb:
  840. fb_dealloc_cmap(&info->cmap);
  841. err_alloc_cmap:
  842. err_find_mode:
  843. pci_iounmap(dev, info->screen_base);
  844. err_iomap:
  845. dac_release(par->dac);
  846. err_dac:
  847. pci_release_regions(dev);
  848. err_request_regions:
  849. /* pci_disable_device(dev); */
  850. err_enable_device:
  851. framebuffer_release(info);
  852. return rc;
  853. }
  854. /* PCI remove */
  855. static void ark_pci_remove(struct pci_dev *dev)
  856. {
  857. struct fb_info *info = pci_get_drvdata(dev);
  858. if (info) {
  859. struct arkfb_info *par = info->par;
  860. arch_phys_wc_del(par->wc_cookie);
  861. dac_release(par->dac);
  862. unregister_framebuffer(info);
  863. fb_dealloc_cmap(&info->cmap);
  864. pci_iounmap(dev, info->screen_base);
  865. pci_release_regions(dev);
  866. /* pci_disable_device(dev); */
  867. framebuffer_release(info);
  868. }
  869. }
  870. #ifdef CONFIG_PM
  871. /* PCI suspend */
  872. static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
  873. {
  874. struct fb_info *info = pci_get_drvdata(dev);
  875. struct arkfb_info *par = info->par;
  876. dev_info(info->device, "suspend\n");
  877. console_lock();
  878. mutex_lock(&(par->open_lock));
  879. if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
  880. mutex_unlock(&(par->open_lock));
  881. console_unlock();
  882. return 0;
  883. }
  884. fb_set_suspend(info, 1);
  885. pci_save_state(dev);
  886. pci_disable_device(dev);
  887. pci_set_power_state(dev, pci_choose_state(dev, state));
  888. mutex_unlock(&(par->open_lock));
  889. console_unlock();
  890. return 0;
  891. }
  892. /* PCI resume */
  893. static int ark_pci_resume (struct pci_dev* dev)
  894. {
  895. struct fb_info *info = pci_get_drvdata(dev);
  896. struct arkfb_info *par = info->par;
  897. dev_info(info->device, "resume\n");
  898. console_lock();
  899. mutex_lock(&(par->open_lock));
  900. if (par->ref_count == 0)
  901. goto fail;
  902. pci_set_power_state(dev, PCI_D0);
  903. pci_restore_state(dev);
  904. if (pci_enable_device(dev))
  905. goto fail;
  906. pci_set_master(dev);
  907. arkfb_set_par(info);
  908. fb_set_suspend(info, 0);
  909. fail:
  910. mutex_unlock(&(par->open_lock));
  911. console_unlock();
  912. return 0;
  913. }
  914. #else
  915. #define ark_pci_suspend NULL
  916. #define ark_pci_resume NULL
  917. #endif /* CONFIG_PM */
  918. /* List of boards that we are trying to support */
  919. static struct pci_device_id ark_devices[] = {
  920. {PCI_DEVICE(0xEDD8, 0xA099)},
  921. {0, 0, 0, 0, 0, 0, 0}
  922. };
  923. MODULE_DEVICE_TABLE(pci, ark_devices);
  924. static struct pci_driver arkfb_pci_driver = {
  925. .name = "arkfb",
  926. .id_table = ark_devices,
  927. .probe = ark_pci_probe,
  928. .remove = ark_pci_remove,
  929. .suspend = ark_pci_suspend,
  930. .resume = ark_pci_resume,
  931. };
  932. /* Cleanup */
  933. static void __exit arkfb_cleanup(void)
  934. {
  935. pr_debug("arkfb: cleaning up\n");
  936. pci_unregister_driver(&arkfb_pci_driver);
  937. }
  938. /* Driver Initialisation */
  939. static int __init arkfb_init(void)
  940. {
  941. #ifndef MODULE
  942. char *option = NULL;
  943. if (fb_get_options("arkfb", &option))
  944. return -ENODEV;
  945. if (option && *option)
  946. mode_option = option;
  947. #endif
  948. pr_debug("arkfb: initializing\n");
  949. return pci_register_driver(&arkfb_pci_driver);
  950. }
  951. module_init(arkfb_init);
  952. module_exit(arkfb_cleanup);