tileblit.c 3.8 KB

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