Line data Source code
1 : /*
2 : * linux/drivers/video/hgafb.c -- Hercules graphics adaptor frame buffer device
3 : *
4 : * Created 25 Nov 1999 by Ferenc Bakonyi (fero@drama.obuda.kando.hu)
5 : * Based on skeletonfb.c by Geert Uytterhoeven and
6 : * mdacon.c by Andrew Apted
7 : *
8 : * History:
9 : *
10 : * - Revision 0.1.8 (23 Oct 2002): Ported to new framebuffer api.
11 : *
12 : * - Revision 0.1.7 (23 Jan 2001): fix crash resulting from MDA only cards
13 : * being detected as Hercules. (Paul G.)
14 : * - Revision 0.1.6 (17 Aug 2000): new style structs
15 : * documentation
16 : * - Revision 0.1.5 (13 Mar 2000): spinlocks instead of saveflags();cli();etc
17 : * minor fixes
18 : * - Revision 0.1.4 (24 Jan 2000): fixed a bug in hga_card_detect() for
19 : * HGA-only systems
20 : * - Revision 0.1.3 (22 Jan 2000): modified for the new fb_info structure
21 : * screen is cleared after rmmod
22 : * virtual resolutions
23 : * module parameter 'nologo={0|1}'
24 : * the most important: boot logo :)
25 : * - Revision 0.1.0 (6 Dec 1999): faster scrolling and minor fixes
26 : * - First release (25 Nov 1999)
27 : *
28 : * This file is subject to the terms and conditions of the GNU General Public
29 : * License. See the file COPYING in the main directory of this archive
30 : * for more details.
31 : */
32 :
33 : #include <linux/module.h>
34 : #include <linux/kernel.h>
35 : #include <linux/errno.h>
36 : #include <linux/spinlock.h>
37 : #include <linux/string.h>
38 : #include <linux/mm.h>
39 : #include <linux/slab.h>
40 : #include <linux/delay.h>
41 : #include <linux/fb.h>
42 : #include <linux/init.h>
43 : #include <linux/ioport.h>
44 : #include <linux/platform_device.h>
45 : #include <asm/io.h>
46 : #include <asm/vga.h>
47 :
48 : #if 0
49 : #define DPRINTK(args...) printk(KERN_DEBUG __FILE__": " ##args)
50 : #else
51 : #define DPRINTK(args...)
52 : #endif
53 :
54 : #if 0
55 : #define CHKINFO(ret) if (info != &fb_info) { printk(KERN_DEBUG __FILE__": This should never happen, line:%d \n", __LINE__); return ret; }
56 : #else
57 : #define CHKINFO(ret)
58 : #endif
59 :
60 : /* Description of the hardware layout */
61 :
62 1 : static void __iomem *hga_vram; /* Base of video memory */
63 1 : static unsigned long hga_vram_len; /* Size of video memory */
64 :
65 : #define HGA_ROWADDR(row) ((row%4)*8192 + (row>>2)*90)
66 : #define HGA_TXT 0
67 : #define HGA_GFX 1
68 :
69 : static inline u8 __iomem * rowaddr(struct fb_info *info, u_int row)
70 : {
71 : return info->screen_base + HGA_ROWADDR(row);
72 : }
73 :
74 1 : static int hga_mode = -1; /* 0 = txt, 1 = gfx mode */
75 1 :
76 1 : static enum { TYPE_HERC, TYPE_HERCPLUS, TYPE_HERCCOLOR } hga_type;
77 1 : static char *hga_type_name;
78 :
79 : #define HGA_INDEX_PORT 0x3b4 /* Register select port */
80 : #define HGA_VALUE_PORT 0x3b5 /* Register value port */
81 : #define HGA_MODE_PORT 0x3b8 /* Mode control port */
82 : #define HGA_STATUS_PORT 0x3ba /* Status and Config port */
83 : #define HGA_GFX_PORT 0x3bf /* Graphics control port */
84 :
85 : /* HGA register values */
86 :
87 : #define HGA_CURSOR_BLINKING 0x00
88 : #define HGA_CURSOR_OFF 0x20
89 : #define HGA_CURSOR_SLOWBLINK 0x60
90 :
91 : #define HGA_MODE_GRAPHICS 0x02
92 : #define HGA_MODE_VIDEO_EN 0x08
93 : #define HGA_MODE_BLINK_EN 0x20
94 : #define HGA_MODE_GFX_PAGE1 0x80
95 :
96 : #define HGA_STATUS_HSYNC 0x01
97 : #define HGA_STATUS_VSYNC 0x80
98 : #define HGA_STATUS_VIDEO 0x08
99 :
100 : #define HGA_CONFIG_COL132 0x08
101 : #define HGA_GFX_MODE_EN 0x01
102 : #define HGA_GFX_PAGE_EN 0x02
103 :
104 : /* Global locks */
105 :
106 1 : static DEFINE_SPINLOCK(hga_reg_lock);
107 :
108 : /* Framebuffer driver structures */
109 :
110 1 : static struct fb_var_screeninfo __initdata hga_default_var = {
111 : .xres = 720,
112 : .yres = 348,
113 : .xres_virtual = 720,
114 : .yres_virtual = 348,
115 : .bits_per_pixel = 1,
116 : .red = {0, 1, 0},
117 : .green = {0, 1, 0},
118 : .blue = {0, 1, 0},
119 : .transp = {0, 0, 0},
120 : .height = -1,
121 : .width = -1,
122 : };
123 :
124 1 : static struct fb_fix_screeninfo __initdata hga_fix = {
125 : .id = "HGA",
126 : .type = FB_TYPE_PACKED_PIXELS, /* (not sure) */
127 : .visual = FB_VISUAL_MONO10,
128 : .xpanstep = 8,
129 : .ypanstep = 8,
130 : .line_length = 90,
131 : .accel = FB_ACCEL_NONE
132 : };
133 :
134 : /* Don't assume that tty1 will be the initial current console. */
135 1 : static int release_io_port = 0;
136 1 : static int release_io_ports = 0;
137 1 : static int nologo = 0;
138 :
139 : /* -------------------------------------------------------------------------
140 : *
141 : * Low level hardware functions
142 : *
143 : * ------------------------------------------------------------------------- */
144 :
145 : static void write_hga_b(unsigned int val, unsigned char reg)
146 : {
147 72 : outb_p(reg, HGA_INDEX_PORT);
148 72 : outb_p(val, HGA_VALUE_PORT);
149 36 : }
150 :
151 : static void write_hga_w(unsigned int val, unsigned char reg)
152 : {
153 28 : outb_p(reg, HGA_INDEX_PORT); outb_p(val >> 8, HGA_VALUE_PORT);
154 28 : outb_p(reg+1, HGA_INDEX_PORT); outb_p(val & 0xff, HGA_VALUE_PORT);
155 7 : }
156 :
157 : static int test_hga_b(unsigned char val, unsigned char reg)
158 : {
159 6 : outb_p(reg, HGA_INDEX_PORT);
160 4 : outb (val, HGA_VALUE_PORT);
161 8 : udelay(20); val = (inb_p(HGA_VALUE_PORT) == val);
162 2 : return val;
163 : }
164 :
165 : static void hga_clear_screen(void)
166 : {
167 6 : unsigned char fillchar = 0xbf; /* magic */
168 3 : unsigned long flags;
169 3 :
170 9 : spin_lock_irqsave(&hga_reg_lock, flags);
171 6 : if (hga_mode == HGA_TXT)
172 3 : fillchar = ' ';
173 6 : else if (hga_mode == HGA_GFX)
174 3 : fillchar = 0x00;
175 6 : spin_unlock_irqrestore(&hga_reg_lock, flags);
176 6 : if (fillchar != 0xbf)
177 3 : memset_io(hga_vram, fillchar, hga_vram_len);
178 3 : }
179 :
180 : static void hga_txt_mode(void)
181 : {
182 2 : unsigned long flags;
183 2 :
184 6 : spin_lock_irqsave(&hga_reg_lock, flags);
185 4 : outb_p(HGA_MODE_VIDEO_EN | HGA_MODE_BLINK_EN, HGA_MODE_PORT);
186 4 : outb_p(0x00, HGA_GFX_PORT);
187 4 : outb_p(0x00, HGA_STATUS_PORT);
188 :
189 4 : write_hga_b(0x61, 0x00); /* horizontal total */
190 4 : write_hga_b(0x50, 0x01); /* horizontal displayed */
191 4 : write_hga_b(0x52, 0x02); /* horizontal sync pos */
192 4 : write_hga_b(0x0f, 0x03); /* horizontal sync width */
193 :
194 4 : write_hga_b(0x19, 0x04); /* vertical total */
195 4 : write_hga_b(0x06, 0x05); /* vertical total adjust */
196 4 : write_hga_b(0x19, 0x06); /* vertical displayed */
197 4 : write_hga_b(0x19, 0x07); /* vertical sync pos */
198 :
199 4 : write_hga_b(0x02, 0x08); /* interlace mode */
200 4 : write_hga_b(0x0d, 0x09); /* maximum scanline */
201 4 : write_hga_b(0x0c, 0x0a); /* cursor start */
202 4 : write_hga_b(0x0d, 0x0b); /* cursor end */
203 :
204 4 : write_hga_w(0x0000, 0x0c); /* start address */
205 4 : write_hga_w(0x0000, 0x0e); /* cursor location */
206 :
207 2 : hga_mode = HGA_TXT;
208 4 : spin_unlock_irqrestore(&hga_reg_lock, flags);
209 2 : }
210 :
211 : static void hga_gfx_mode(void)
212 : {
213 1 : unsigned long flags;
214 1 :
215 3 : spin_lock_irqsave(&hga_reg_lock, flags);
216 2 : outb_p(0x00, HGA_STATUS_PORT);
217 2 : outb_p(HGA_GFX_MODE_EN, HGA_GFX_PORT);
218 2 : outb_p(HGA_MODE_VIDEO_EN | HGA_MODE_GRAPHICS, HGA_MODE_PORT);
219 :
220 2 : write_hga_b(0x35, 0x00); /* horizontal total */
221 2 : write_hga_b(0x2d, 0x01); /* horizontal displayed */
222 2 : write_hga_b(0x2e, 0x02); /* horizontal sync pos */
223 2 : write_hga_b(0x07, 0x03); /* horizontal sync width */
224 :
225 2 : write_hga_b(0x5b, 0x04); /* vertical total */
226 2 : write_hga_b(0x02, 0x05); /* vertical total adjust */
227 2 : write_hga_b(0x57, 0x06); /* vertical displayed */
228 2 : write_hga_b(0x57, 0x07); /* vertical sync pos */
229 :
230 2 : write_hga_b(0x02, 0x08); /* interlace mode */
231 2 : write_hga_b(0x03, 0x09); /* maximum scanline */
232 2 : write_hga_b(0x00, 0x0a); /* cursor start */
233 2 : write_hga_b(0x00, 0x0b); /* cursor end */
234 :
235 2 : write_hga_w(0x0000, 0x0c); /* start address */
236 2 : write_hga_w(0x0000, 0x0e); /* cursor location */
237 :
238 1 : hga_mode = HGA_GFX;
239 2 : spin_unlock_irqrestore(&hga_reg_lock, flags);
240 1 : }
241 :
242 : static void hga_show_logo(struct fb_info *info)
243 : {
244 1 : /*
245 : void __iomem *dest = hga_vram;
246 : char *logo = linux_logo_bw;
247 : int x, y;
248 :
249 : for (y = 134; y < 134 + 80 ; y++) * this needs some cleanup *
250 : for (x = 0; x < 10 ; x++)
251 : writeb(~*(logo++),(dest + HGA_ROWADDR(y) + x + 40));
252 : */
253 : }
254 :
255 : static void hga_pan(unsigned int xoffset, unsigned int yoffset)
256 : {
257 1 : unsigned int base;
258 1 : unsigned long flags;
259 1 :
260 1 : base = (yoffset / 8) * 90 + xoffset;
261 3 : spin_lock_irqsave(&hga_reg_lock, flags);
262 2 : write_hga_w(base, 0x0c); /* start address */
263 2 : spin_unlock_irqrestore(&hga_reg_lock, flags);
264 1 : DPRINTK("hga_pan: base:%d\n", base);
265 : }
266 :
267 : static void hga_blank(int blank_mode)
268 : {
269 1 : unsigned long flags;
270 1 :
271 3 : spin_lock_irqsave(&hga_reg_lock, flags);
272 2 : if (blank_mode) {
273 2 : outb_p(0x00, HGA_MODE_PORT); /* disable video */
274 : } else {
275 2 : outb_p(HGA_MODE_VIDEO_EN | HGA_MODE_GRAPHICS, HGA_MODE_PORT);
276 : }
277 4 : spin_unlock_irqrestore(&hga_reg_lock, flags);
278 1 : }
279 :
280 : static int __init hga_card_detect(void)
281 : {
282 2 : int count = 0;
283 1 : void __iomem *p, *q;
284 1 : unsigned short p_save, q_save;
285 1 :
286 2 : hga_vram_len = 0x08000;
287 1 :
288 3 : hga_vram = ioremap(0xb0000, hga_vram_len);
289 1 :
290 4 : if (request_region(0x3b0, 12, "hgafb"))
291 2 : release_io_ports = 1;
292 4 : if (request_region(0x3bf, 1, "hgafb"))
293 2 : release_io_port = 1;
294 1 :
295 1 : /* do a memory check */
296 :
297 1 : p = hga_vram;
298 1 : q = hga_vram + 0x01000;
299 :
300 4 : p_save = readw(p); q_save = readw(q);
301 :
302 7 : writew(0xaa55, p); if (readw(p) == 0xaa55) count++;
303 7 : writew(0x55aa, p); if (readw(p) == 0x55aa) count++;
304 2 : writew(p_save, p);
305 :
306 2 : if (count != 2)
307 1 : goto error;
308 :
309 : /* Ok, there is definitely a card registering at the correct
310 : * memory location, so now we do an I/O port test.
311 : */
312 :
313 4 : if (!test_hga_b(0x66, 0x0f)) /* cursor low register */
314 1 : goto error;
315 :
316 4 : if (!test_hga_b(0x99, 0x0f)) /* cursor low register */
317 1 : goto error;
318 :
319 : /* See if the card is a Hercules, by checking whether the vsync
320 : * bit of the status register is changing. This test lasts for
321 : * approximately 1/10th of a second.
322 : */
323 :
324 4 : p_save = q_save = inb_p(HGA_STATUS_PORT) & HGA_STATUS_VSYNC;
325 :
326 7 : for (count=0; count < 50000 && p_save == q_save; count++) {
327 4 : q_save = inb(HGA_STATUS_PORT) & HGA_STATUS_VSYNC;
328 3 : udelay(2);
329 : }
330 :
331 2 : if (p_save == q_save)
332 1 : goto error;
333 :
334 2 : switch (inb_p(HGA_STATUS_PORT) & 0x70) {
335 3 : case 0x10:
336 1 : hga_type = TYPE_HERCPLUS;
337 1 : hga_type_name = "HerculesPlus";
338 1 : break;
339 4 : case 0x50:
340 1 : hga_type = TYPE_HERCCOLOR;
341 1 : hga_type_name = "HerculesColor";
342 1 : break;
343 2 : default:
344 2 : hga_type = TYPE_HERC;
345 1 : hga_type_name = "Hercules";
346 1 : break;
347 : }
348 1 : return 1;
349 4 : error:
350 8 : if (release_io_ports)
351 4 : release_region(0x3b0, 12);
352 8 : if (release_io_port)
353 4 : release_region(0x3bf, 1);
354 4 : return 0;
355 : }
356 :
357 : /**
358 : * hgafb_open - open the framebuffer device
359 : * @info:pointer to fb_info object containing info for current hga board
360 : * @int:open by console system or userland.
361 : */
362 :
363 : static int hgafb_open(struct fb_info *info, int init)
364 : {
365 2 : hga_gfx_mode();
366 2 : hga_clear_screen();
367 4 : if (!nologo) hga_show_logo(info);
368 2 : return 0;
369 : }
370 :
371 : /**
372 : * hgafb_open - open the framebuffer device
373 : * @info:pointer to fb_info object containing info for current hga board
374 : * @int:open by console system or userland.
375 : */
376 :
377 : static int hgafb_release(struct fb_info *info, int init)
378 : {
379 2 : hga_txt_mode();
380 2 : hga_clear_screen();
381 1 : return 0;
382 : }
383 :
384 : /**
385 : * hgafb_setcolreg - set color registers
386 : * @regno:register index to set
387 : * @red:red value, unused
388 : * @green:green value, unused
389 : * @blue:blue value, unused
390 : * @transp:transparency value, unused
391 : * @info:unused
392 : *
393 : * This callback function is used to set the color registers of a HGA
394 : * board. Since we have only two fixed colors only @regno is checked.
395 : * A zero is returned on success and 1 for failure.
396 : */
397 :
398 : static int hgafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
399 : u_int transp, struct fb_info *info)
400 : {
401 2 : if (regno > 1)
402 1 : return 1;
403 1 : return 0;
404 : }
405 :
406 : /**
407 : * hga_pan_display - pan or wrap the display
408 : * @var:contains new xoffset, yoffset and vmode values
409 : * @info:pointer to fb_info object containing info for current hga board
410 : *
411 : * This function looks only at xoffset, yoffset and the %FB_VMODE_YWRAP
412 : * flag in @var. If input parameters are correct it calls hga_pan() to
413 : * program the hardware. @info->var is updated to the new values.
414 : * A zero is returned on success and %-EINVAL for failure.
415 : */
416 :
417 : static int hgafb_pan_display(struct fb_var_screeninfo *var,
418 : struct fb_info *info)
419 : {
420 2 : if (var->vmode & FB_VMODE_YWRAP) {
421 4 : if (var->yoffset < 0 ||
422 : var->yoffset >= info->var.yres_virtual ||
423 : var->xoffset)
424 1 : return -EINVAL;
425 : } else {
426 6 : if (var->xoffset + var->xres > info->var.xres_virtual
427 : || var->yoffset + var->yres > info->var.yres_virtual
428 : || var->yoffset % 8)
429 1 : return -EINVAL;
430 : }
431 :
432 2 : hga_pan(var->xoffset, var->yoffset);
433 1 : return 0;
434 : }
435 :
436 : /**
437 : * hgafb_blank - (un)blank the screen
438 : * @blank_mode:blanking method to use
439 : * @info:unused
440 : *
441 : * Blank the screen if blank_mode != 0, else unblank.
442 : * Implements VESA suspend and powerdown modes on hardware that supports
443 : * disabling hsync/vsync:
444 : * @blank_mode == 2 means suspend vsync,
445 : * @blank_mode == 3 means suspend hsync,
446 : * @blank_mode == 4 means powerdown.
447 : */
448 :
449 : static int hgafb_blank(int blank_mode, struct fb_info *info)
450 : {
451 2 : hga_blank(blank_mode);
452 1 : return 0;
453 : }
454 :
455 : /*
456 : * Accel functions
457 : */
458 : #ifdef CONFIG_FB_HGA_ACCEL
459 : static void hgafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
460 : {
461 : u_int rows, y;
462 : u8 __iomem *dest;
463 :
464 : y = rect->dy;
465 :
466 : for (rows = rect->height; rows--; y++) {
467 : dest = rowaddr(info, y) + (rect->dx >> 3);
468 : switch (rect->rop) {
469 : case ROP_COPY:
470 : //fb_memset(dest, rect->color, (rect->width >> 3));
471 : break;
472 : case ROP_XOR:
473 : fb_writeb(~(fb_readb(dest)), dest);
474 : break;
475 : }
476 : }
477 : }
478 :
479 : static void hgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
480 : {
481 : u_int rows, y1, y2;
482 : u8 __iomem *src;
483 : u8 __iomem *dest;
484 :
485 : if (area->dy <= area->sy) {
486 : y1 = area->sy;
487 : y2 = area->dy;
488 :
489 : for (rows = area->height; rows--; ) {
490 : src = rowaddr(info, y1) + (area->sx >> 3);
491 : dest = rowaddr(info, y2) + (area->dx >> 3);
492 : //fb_memmove(dest, src, (area->width >> 3));
493 : y1++;
494 : y2++;
495 : }
496 : } else {
497 : y1 = area->sy + area->height - 1;
498 : y2 = area->dy + area->height - 1;
499 :
500 : for (rows = area->height; rows--;) {
501 : src = rowaddr(info, y1) + (area->sx >> 3);
502 : dest = rowaddr(info, y2) + (area->dx >> 3);
503 : //fb_memmove(dest, src, (area->width >> 3));
504 : y1--;
505 : y2--;
506 : }
507 : }
508 : }
509 :
510 : static void hgafb_imageblit(struct fb_info *info, const struct fb_image *image)
511 : {
512 : u8 __iomem *dest;
513 : u8 *cdat = (u8 *) image->data;
514 : u_int rows, y = image->dy;
515 : u8 d;
516 :
517 : for (rows = image->height; rows--; y++) {
518 : d = *cdat++;
519 : dest = rowaddr(info, y) + (image->dx >> 3);
520 : fb_writeb(d, dest);
521 : }
522 : }
523 : #else /* !CONFIG_FB_HGA_ACCEL */
524 : #define hgafb_fillrect cfb_fillrect
525 : #define hgafb_copyarea cfb_copyarea
526 : #define hgafb_imageblit cfb_imageblit
527 : #endif /* CONFIG_FB_HGA_ACCEL */
528 :
529 :
530 1 : static struct fb_ops hgafb_ops = {
531 : .owner = THIS_MODULE,
532 : .fb_open = hgafb_open,
533 : .fb_release = hgafb_release,
534 : .fb_setcolreg = hgafb_setcolreg,
535 : .fb_pan_display = hgafb_pan_display,
536 : .fb_blank = hgafb_blank,
537 : .fb_fillrect = hgafb_fillrect,
538 : .fb_copyarea = hgafb_copyarea,
539 : .fb_imageblit = hgafb_imageblit,
540 : };
541 :
542 : /* ------------------------------------------------------------------------- *
543 : *
544 : * Functions in fb_info
545 : *
546 : * ------------------------------------------------------------------------- */
547 :
548 : /* ------------------------------------------------------------------------- */
549 :
550 : /*
551 : * Initialization
552 : */
553 :
554 : static int __init hgafb_probe(struct platform_device *pdev)
555 : {
556 1 : struct fb_info *info;
557 1 :
558 9 : if (! hga_card_detect()) {
559 1 : printk(KERN_INFO "hgafb: HGA card not detected.\n");
560 2 : if (hga_vram)
561 1 : iounmap(hga_vram);
562 1 : return -EINVAL;
563 : }
564 :
565 1 : printk(KERN_INFO "hgafb: %s with %ldK of memory detected.\n",
566 : hga_type_name, hga_vram_len/1024);
567 :
568 1 : info = framebuffer_alloc(0, &pdev->dev);
569 2 : if (!info) {
570 1 : iounmap(hga_vram);
571 1 : return -ENOMEM;
572 : }
573 :
574 1 : hga_fix.smem_start = (unsigned long)hga_vram;
575 1 : hga_fix.smem_len = hga_vram_len;
576 :
577 1 : info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
578 1 : info->var = hga_default_var;
579 1 : info->fix = hga_fix;
580 1 : info->monspecs.hfmin = 0;
581 1 : info->monspecs.hfmax = 0;
582 1 : info->monspecs.vfmin = 10000;
583 1 : info->monspecs.vfmax = 10000;
584 1 : info->monspecs.dpms = 0;
585 1 : info->fbops = &hgafb_ops;
586 1 : info->screen_base = hga_vram;
587 :
588 4 : if (register_framebuffer(info) < 0) {
589 1 : framebuffer_release(info);
590 1 : iounmap(hga_vram);
591 1 : return -EINVAL;
592 : }
593 :
594 1 : printk(KERN_INFO "fb%d: %s frame buffer device\n",
595 : info->node, info->fix.id);
596 1 : platform_set_drvdata(pdev, info);
597 1 : return 0;
598 : }
599 :
600 : static int hgafb_remove(struct platform_device *pdev)
601 : {
602 4 : struct fb_info *info = platform_get_drvdata(pdev);
603 1 :
604 2 : hga_txt_mode();
605 2 : hga_clear_screen();
606 :
607 2 : if (info) {
608 2 : unregister_framebuffer(info);
609 1 : framebuffer_release(info);
610 : }
611 :
612 2 : iounmap(hga_vram);
613 :
614 4 : if (release_io_ports)
615 2 : release_region(0x3b0, 12);
616 :
617 4 : if (release_io_port)
618 2 : release_region(0x3bf, 1);
619 :
620 2 : return 0;
621 : }
622 :
623 1 : static struct platform_driver hgafb_driver = {
624 : .probe = hgafb_probe,
625 : .remove = hgafb_remove,
626 : .driver = {
627 : .name = "hgafb",
628 : },
629 : };
630 :
631 1 : static struct platform_device *hgafb_device;
632 :
633 : static int __init hgafb_init(void)
634 : {
635 1 : int ret;
636 1 :
637 4 : if (fb_get_options("hgafb", NULL))
638 2 : return -ENODEV;
639 :
640 2 : ret = platform_driver_register(&hgafb_driver);
641 :
642 2 : if (!ret) {
643 1 : hgafb_device = platform_device_register_simple("hgafb", 0, NULL, 0);
644 :
645 4 : if (IS_ERR(hgafb_device)) {
646 2 : platform_driver_unregister(&hgafb_driver);
647 3 : ret = PTR_ERR(hgafb_device);
648 : }
649 : }
650 :
651 3 : return ret;
652 : }
653 :
654 : static void __exit hgafb_exit(void)
655 : {
656 2 : platform_device_unregister(hgafb_device);
657 4 : platform_driver_unregister(&hgafb_driver);
658 2 : }
659 :
660 : /* -------------------------------------------------------------------------
661 : *
662 : * Modularization
663 : *
664 : * ------------------------------------------------------------------------- */
665 :
666 : MODULE_AUTHOR("Ferenc Bakonyi (fero@drama.obuda.kando.hu)");
667 : MODULE_DESCRIPTION("FBDev driver for Hercules Graphics Adaptor");
668 : MODULE_LICENSE("GPL");
669 :
670 : module_param(nologo, bool, 0);
671 : MODULE_PARM_DESC(nologo, "Disables startup logo if != 0 (default=0)");
672 : module_init(hgafb_init);
673 : module_exit(hgafb_exit);
|