pmagb-b-fb.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * linux/drivers/video/pmagb-b-fb.c
  3. *
  4. * PMAGB-B 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. * DECstation related code Copyright (C) 1999, 2000, 2001 by
  10. * Michael Engel <engel@unix-ag.org>,
  11. * Karsten Merker <merker@linuxtag.org> and
  12. * Harald Koerfgen.
  13. * This file is subject to the terms and conditions of the GNU General
  14. * Public License. See the file COPYING in the main directory of this
  15. * archive for more details.
  16. *
  17. */
  18. /*
  19. * We currently only support the PMAGB-B in high resolution mode
  20. * as I know of no way to detect low resolution mode set via jumper.
  21. * KM, 2001/01/07
  22. */
  23. #include <linux/module.h>
  24. #include <linux/kernel.h>
  25. #include <linux/sched.h>
  26. #include <linux/errno.h>
  27. #include <linux/string.h>
  28. #include <linux/timer.h>
  29. #include <linux/mm.h>
  30. #include <linux/tty.h>
  31. #include <linux/slab.h>
  32. #include <linux/delay.h>
  33. #include <linux/init.h>
  34. #include <linux/fb.h>
  35. #include <asm/bootinfo.h>
  36. #include <asm/dec/machtype.h>
  37. #include <asm/dec/tc.h>
  38. #include <video/pmagb-b-fb.h>
  39. struct pmagb_b_ramdac_regs {
  40. unsigned char addr_low;
  41. unsigned char pad0[3];
  42. unsigned char addr_hi;
  43. unsigned char pad1[3];
  44. unsigned char data;
  45. unsigned char pad2[3];
  46. unsigned char cmap;
  47. };
  48. /*
  49. * Max 3 TURBOchannel slots -> max 3 PMAGB-B :)
  50. */
  51. static struct fb_info pmagbb_fb_info[3];
  52. static struct fb_var_screeninfo pmagbbfb_defined = {
  53. .xres = 1280,
  54. .yres = 1024,
  55. .xres_virtual = 1280,
  56. .yres_virtual = 1024,
  57. .bits_per_pixel = 8,
  58. .red.length = 8,
  59. .green.length = 8,
  60. .blue.length = 8,
  61. .activate = FB_ACTIVATE_NOW,
  62. .height = 274,
  63. .width = 195,
  64. .accel_flags = FB_ACCEL_NONE,
  65. .vmode = FB_VMODE_NONINTERLACED,
  66. };
  67. static struct fb_fix_screeninfo pmagbafb_fix = {
  68. .id = "PMAGB-BA",
  69. .smem_len = (1280 * 1024),
  70. .type = FB_TYPE_PACKED_PIXELS,
  71. .visual = FB_VISUAL_PSEUDOCOLOR,
  72. .line_length = 1280,
  73. }
  74. /*
  75. * Turn hardware cursor off
  76. */
  77. void pmagbbfb_erase_cursor(struct pmagb_b_ramdac_regs *bt459_regs)
  78. {
  79. bt459_regs->addr_low = 0;
  80. bt459_regs->addr_hi = 3;
  81. bt459_regs->data = 0;
  82. }
  83. /*
  84. * Set the palette.
  85. */
  86. static int pmagbbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
  87. unsigned blue, unsigned transp,
  88. struct fb_info *info)
  89. {
  90. struct pmagb_b_ramdac_regs *bt459_regs = (struct pmagb_b_ramdac_regs *) info->par;
  91. if (regno >= info->cmap.len)
  92. return 1;
  93. red >>= 8; /* The cmap fields are 16 bits */
  94. green >>= 8; /* wide, but the harware colormap */
  95. blue >>= 8; /* registers are only 8 bits wide */
  96. bt459_regs->addr_low = (__u8) regno;
  97. bt459_regs->addr_hi = 0;
  98. bt459_regs->cmap = red;
  99. bt459_regs->cmap = green;
  100. bt459_regs->cmap = blue;
  101. return 0;
  102. }
  103. static struct fb_ops pmagbbfb_ops = {
  104. .owner = THIS_MODULE,
  105. .fb_setcolreg = pmagbbfb_setcolreg,
  106. .fb_fillrect = cfb_fillrect,
  107. .fb_copyarea = cfb_copyarea,
  108. .fb_imageblit = cfb_imageblit,
  109. .fb_cursor = soft_cursor,
  110. };
  111. int __init pmagbbfb_init_one(int slot)
  112. {
  113. unsigned long base_addr = get_tc_base_addr(slot);
  114. struct fb_info *info = &pmagbb_fb_info[slot];
  115. printk("PMAGB-BA framebuffer in slot %d\n", slot);
  116. /*
  117. * Framebuffer display memory base address and friends
  118. */
  119. pmagbbfb_fix.smem_start = base_addr + PMAGB_B_ONBOARD_FBMEM_OFFSET;
  120. info->par = (base_addr + PMAGB_B_BT459_OFFSET);
  121. /*
  122. * Configure the Bt459 RAM DAC
  123. */
  124. pmagbbfb_erase_cursor((struct pmagb_b_ramdac_regs *) info->par);
  125. /*
  126. * Let there be consoles..
  127. */
  128. info->fbops = &pmagbbfb_ops;
  129. info->var = pmagbbfb_defined;
  130. info->fix = pmagbbfb_fix;
  131. info->screen_base = pmagbbfb_fix.smem_start;
  132. info->flags = FBINFO_DEFAULT;
  133. fb_alloc_cmap(&fb_info.cmap, 256, 0);
  134. if (register_framebuffer(info) < 0)
  135. return 1;
  136. return 0;
  137. }
  138. /*
  139. * Initialise the framebuffer
  140. */
  141. int __init pmagbbfb_init(void)
  142. {
  143. int sid;
  144. int found = 0;
  145. if (fb_get_options("pmagbbfb", NULL))
  146. return -ENODEV;
  147. if (TURBOCHANNEL) {
  148. while ((sid = search_tc_card("PMAGB-BA")) >= 0) {
  149. found = 1;
  150. claim_tc_card(sid);
  151. pmagbbfb_init_one(sid);
  152. }
  153. return found ? 0 : -ENODEV;
  154. } else {
  155. return -ENODEV;
  156. }
  157. }
  158. module_init(pmagbbfb_init);
  159. MODULE_LICENSE("GPL");