atafb_mfb.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * linux/drivers/video/mfb.c -- Low level frame buffer operations for
  3. * monochrome
  4. *
  5. * Created 5 Apr 1997 by Geert Uytterhoeven
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file COPYING in the main directory of this archive for
  9. * more details.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/string.h>
  13. #include <linux/fb.h>
  14. #include "atafb.h"
  15. #include "atafb_utils.h"
  16. /*
  17. * Monochrome
  18. */
  19. void atafb_mfb_copyarea(struct fb_info *info, u_long next_line,
  20. int sy, int sx, int dy, int dx,
  21. int height, int width)
  22. {
  23. u8 *src, *dest;
  24. u_int rows;
  25. if (sx == 0 && dx == 0 && width == next_line) {
  26. src = (u8 *)info->screen_base + sy * (width >> 3);
  27. dest = (u8 *)info->screen_base + dy * (width >> 3);
  28. fb_memmove(dest, src, height * (width >> 3));
  29. } else if (dy <= sy) {
  30. src = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
  31. dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
  32. for (rows = height; rows--;) {
  33. fb_memmove(dest, src, width >> 3);
  34. src += next_line;
  35. dest += next_line;
  36. }
  37. } else {
  38. src = (u8 *)info->screen_base + (sy + height - 1) * next_line + (sx >> 3);
  39. dest = (u8 *)info->screen_base + (dy + height - 1) * next_line + (dx >> 3);
  40. for (rows = height; rows--;) {
  41. fb_memmove(dest, src, width >> 3);
  42. src -= next_line;
  43. dest -= next_line;
  44. }
  45. }
  46. }
  47. void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color,
  48. int sy, int sx, int height, int width)
  49. {
  50. u8 *dest;
  51. u_int rows;
  52. dest = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
  53. if (sx == 0 && width == next_line) {
  54. if (color)
  55. fb_memset255(dest, height * (width >> 3));
  56. else
  57. fb_memclear(dest, height * (width >> 3));
  58. } else {
  59. for (rows = height; rows--; dest += next_line) {
  60. if (color)
  61. fb_memset255(dest, width >> 3);
  62. else
  63. fb_memclear_small(dest, width >> 3);
  64. }
  65. }
  66. }
  67. void atafb_mfb_linefill(struct fb_info *info, u_long next_line,
  68. int dy, int dx, u32 width,
  69. const u8 *data, u32 bgcolor, u32 fgcolor)
  70. {
  71. u8 *dest;
  72. u_int rows;
  73. dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
  74. for (rows = width / 8; rows--; /* check margins */ ) {
  75. // use fast_memmove or fb_memmove
  76. *dest++ = *data++;
  77. }
  78. }
  79. #ifdef MODULE
  80. MODULE_LICENSE("GPL");
  81. int init_module(void)
  82. {
  83. return 0;
  84. }
  85. void cleanup_module(void)
  86. {
  87. }
  88. #endif /* MODULE */
  89. /*
  90. * Visible symbols for modules
  91. */
  92. EXPORT_SYMBOL(atafb_mfb_copyarea);
  93. EXPORT_SYMBOL(atafb_mfb_fillrect);
  94. EXPORT_SYMBOL(atafb_mfb_linefill);