tileblit.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * linux/drivers/video/console/tileblit.c -- Tile Blitting Operation
  3. *
  4. * Copyright (C) 2004 Antonino Daplas <adaplas @pol.net>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive for
  8. * more details.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/module.h>
  12. #include <linux/string.h>
  13. #include <linux/fb.h>
  14. #include <linux/vt_kern.h>
  15. #include <linux/console.h>
  16. #include <asm/types.h>
  17. #include "fbcon.h"
  18. static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy,
  19. int sx, int dy, int dx, int height, int width)
  20. {
  21. struct fb_tilearea area;
  22. area.sx = sx;
  23. area.sy = sy;
  24. area.dx = dx;
  25. area.dy = dy;
  26. area.height = height;
  27. area.width = width;
  28. info->tileops->fb_tilecopy(info, &area);
  29. }
  30. static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy,
  31. int sx, int height, int width)
  32. {
  33. struct fb_tilerect rect;
  34. int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
  35. int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
  36. rect.index = vc->vc_video_erase_char &
  37. ((vc->vc_hi_font_mask) ? 0x1ff : 0xff);
  38. rect.fg = attr_fgcol_ec(fgshift, vc);
  39. rect.bg = attr_bgcol_ec(bgshift, vc);
  40. rect.sx = sx;
  41. rect.sy = sy;
  42. rect.width = width;
  43. rect.height = height;
  44. rect.rop = ROP_COPY;
  45. info->tileops->fb_tilefill(info, &rect);
  46. }
  47. static void tile_putcs(struct vc_data *vc, struct fb_info *info,
  48. const unsigned short *s, int count, int yy, int xx,
  49. int fg, int bg)
  50. {
  51. struct fb_tileblit blit;
  52. unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
  53. int size = sizeof(u32) * count, i;
  54. blit.sx = xx;
  55. blit.sy = yy;
  56. blit.width = count;
  57. blit.height = 1;
  58. blit.fg = fg;
  59. blit.bg = bg;
  60. blit.length = count;
  61. blit.indices = (u32 *) fb_get_buffer_offset(info, &info->pixmap, size);
  62. for (i = 0; i < count; i++)
  63. blit.indices[i] = (u32)(scr_readw(s++) & charmask);
  64. info->tileops->fb_tileblit(info, &blit);
  65. }
  66. static void tile_clear_margins(struct vc_data *vc, struct fb_info *info,
  67. int bottom_only)
  68. {
  69. return;
  70. }
  71. static void tile_cursor(struct vc_data *vc, struct fb_info *info,
  72. struct display *p, int mode, int softback_lines,
  73. int fg, int bg)
  74. {
  75. struct fb_tilecursor cursor;
  76. int use_sw = (vc->vc_cursor_type & 0x01);
  77. cursor.sx = vc->vc_x;
  78. cursor.sy = vc->vc_y;
  79. cursor.mode = (mode == CM_ERASE || use_sw) ? 0 : 1;
  80. cursor.fg = fg;
  81. cursor.bg = bg;
  82. switch (vc->vc_cursor_type & 0x0f) {
  83. case CUR_NONE:
  84. cursor.shape = FB_TILE_CURSOR_NONE;
  85. break;
  86. case CUR_UNDERLINE:
  87. cursor.shape = FB_TILE_CURSOR_UNDERLINE;
  88. break;
  89. case CUR_LOWER_THIRD:
  90. cursor.shape = FB_TILE_CURSOR_LOWER_THIRD;
  91. break;
  92. case CUR_LOWER_HALF:
  93. cursor.shape = FB_TILE_CURSOR_LOWER_HALF;
  94. break;
  95. case CUR_TWO_THIRDS:
  96. cursor.shape = FB_TILE_CURSOR_TWO_THIRDS;
  97. break;
  98. case CUR_BLOCK:
  99. default:
  100. cursor.shape = FB_TILE_CURSOR_BLOCK;
  101. break;
  102. }
  103. info->tileops->fb_tilecursor(info, &cursor);
  104. }
  105. void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info,
  106. struct display *p, struct fbcon_ops *ops)
  107. {
  108. struct fb_tilemap map;
  109. ops->bmove = tile_bmove;
  110. ops->clear = tile_clear;
  111. ops->putcs = tile_putcs;
  112. ops->clear_margins = tile_clear_margins;
  113. ops->cursor = tile_cursor;
  114. if (p) {
  115. map.width = vc->vc_font.width;
  116. map.height = vc->vc_font.height;
  117. map.depth = 1;
  118. map.length = (p->userfont) ?
  119. FNTCHARCNT(p->fontdata) : 256;
  120. map.data = p->fontdata;
  121. info->tileops->fb_settile(info, &map);
  122. }
  123. }
  124. EXPORT_SYMBOL(fbcon_set_tileops);
  125. MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
  126. MODULE_DESCRIPTION("Tile Blitting Operation");
  127. MODULE_LICENSE("GPL");