pmag-ba-fb.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * linux/drivers/video/pmag-ba-fb.c
  3. *
  4. * PMAG-BA TurboChannel framebuffer card support ... derived from:
  5. * "HP300 Topcat framebuffer support (derived from macfb of all things)
  6. * Phil Blundell <philb@gnu.org> 1998", the original code can be
  7. * found in the file hpfb.c in the same directory.
  8. *
  9. * Based on digital document:
  10. * "PMAG-BA TURBOchannel Color Frame Buffer
  11. * Functional Specification", Revision 1.2, August 27, 1990
  12. *
  13. * DECstation related code Copyright (C) 1999, 2000, 2001 by
  14. * Michael Engel <engel@unix-ag.org>,
  15. * Karsten Merker <merker@linuxtag.org> and
  16. * Harald Koerfgen.
  17. * This file is subject to the terms and conditions of the GNU General
  18. * Public License. See the file COPYING in the main directory of this
  19. * archive for more details.
  20. *
  21. */
  22. #include <linux/module.h>
  23. #include <linux/kernel.h>
  24. #include <linux/sched.h>
  25. #include <linux/errno.h>
  26. #include <linux/string.h>
  27. #include <linux/timer.h>
  28. #include <linux/mm.h>
  29. #include <linux/tty.h>
  30. #include <linux/slab.h>
  31. #include <linux/delay.h>
  32. #include <linux/init.h>
  33. #include <linux/fb.h>
  34. #include <asm/bootinfo.h>
  35. #include <asm/dec/machtype.h>
  36. #include <asm/dec/tc.h>
  37. #include <video/pmag-ba-fb.h>
  38. struct pmag_ba_ramdac_regs {
  39. unsigned char addr_low;
  40. unsigned char pad0[3];
  41. unsigned char addr_hi;
  42. unsigned char pad1[3];
  43. unsigned char data;
  44. unsigned char pad2[3];
  45. unsigned char cmap;
  46. };
  47. /*
  48. * Max 3 TURBOchannel slots -> max 3 PMAG-BA :)
  49. */
  50. static struct fb_info pmagba_fb_info[3];
  51. static struct fb_var_screeninfo pmagbafb_defined = {
  52. .xres = 1024,
  53. .yres = 864,
  54. .xres_virtual = 1024,
  55. .yres_virtual = 864,
  56. .bits_per_pixel = 8,
  57. .red.length = 8,
  58. .green.length = 8,
  59. .blue.length = 8,
  60. .activate = FB_ACTIVATE_NOW,
  61. .height = 274,
  62. .width = 195,
  63. .accel = FB_ACCEL_NONE,
  64. .vmode = FB_VMODE_NONINTERLACED,
  65. };
  66. static struct fb_fix_screeninfo pmagbafb_fix = {
  67. .id = "PMAG-BA",
  68. .smem_len = (1024 * 864),
  69. .type = FB_TYPE_PACKED_PIXELS,
  70. .visual = FB_VISUAL_PSEUDOCOLOR,
  71. .line_length = 1024,
  72. };
  73. /*
  74. * Turn hardware cursor off
  75. */
  76. void pmagbafb_erase_cursor(struct pmag_ba_ramdac_regs *bt459_regs)
  77. {
  78. bt459_regs->addr_low = 0;
  79. bt459_regs->addr_hi = 3;
  80. bt459_regs->data = 0;
  81. }
  82. /*
  83. * Set the palette.
  84. */
  85. static int pmagbafb_setcolreg(unsigned regno, unsigned red, unsigned green,
  86. unsigned blue, unsigned transp,
  87. struct fb_info *info)
  88. {
  89. struct pmag_ba_ramdac_regs *bt459_regs = (struct pmag_ba_ramdac_regs *) info->par;
  90. if (regno >= info->cmap.len)
  91. return 1;
  92. red >>= 8; /* The cmap fields are 16 bits */
  93. green >>= 8; /* wide, but the harware colormap */
  94. blue >>= 8; /* registers are only 8 bits wide */
  95. bt459_regs->addr_low = (__u8) regno;
  96. bt459_regs->addr_hi = 0;
  97. bt459_regs->cmap = red;
  98. bt459_regs->cmap = green;
  99. bt459_regs->cmap = blue;
  100. return 0;
  101. }
  102. static struct fb_ops pmagbafb_ops = {
  103. .owner = THIS_MODULE,
  104. .fb_get_fix = gen_get_fix,
  105. .fb_get_var = gen_get_var,
  106. .fb_setcolreg = pmagbafb_setcolreg,
  107. .fb_fillrect = cfb_fillrect,
  108. .fb_copyarea = cfb_copyarea,
  109. .fb_imageblit = cfb_imageblit,
  110. .fb_cursor = soft_cursor,
  111. };
  112. int __init pmagbafb_init_one(int slot)
  113. {
  114. unsigned long base_addr = get_tc_base_addr(slot);
  115. struct fb_info *info = &pmagba_fb_info[slot];
  116. struct display *disp = &pmagba_disp[slot];
  117. printk("PMAG-BA framebuffer in slot %d\n", slot);
  118. /*
  119. * Framebuffer display memory base address and friends
  120. */
  121. pmagbafb_fix.smem_start = base_addr + PMAG_BA_ONBOARD_FBMEM_OFFSET;
  122. info->par = (base_addr + PMAG_BA_BT459_OFFSET);
  123. /*
  124. * Configure the Bt459 RAM DAC
  125. */
  126. pmagbafb_erase_cursor((struct pmag_ba_ramdac_regs *) info->par);
  127. /*
  128. * Let there be consoles..
  129. */
  130. info->fbops = &pmagbafb_ops;
  131. info->var = pmagbafb_defined;
  132. info->fix = pmagbafb_fix;
  133. info->screen_base = pmagbafb_fix.smem_start;
  134. info->flags = FBINFO_DEFAULT;
  135. fb_alloc_cmap(&fb_info.cmap, 256, 0);
  136. if (register_framebuffer(info) < 0)
  137. return 1;
  138. return 0;
  139. }
  140. /*
  141. * Initialise the framebuffer
  142. */
  143. int __init pmagbafb_init(void)
  144. {
  145. int sid;
  146. int found = 0;
  147. if (fb_get_options("pmagbafb", NULL))
  148. return -ENODEV;
  149. if (TURBOCHANNEL) {
  150. while ((sid = search_tc_card("PMAG-BA")) >= 0) {
  151. found = 1;
  152. claim_tc_card(sid);
  153. pmagbafb_init_one(sid);
  154. }
  155. return found ? 0 : -ENODEV;
  156. } else {
  157. return -ENODEV;
  158. }
  159. }
  160. module_init(pmagbafb_init);
  161. MODULE_LICENSE("GPL");