atafb_mfb.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/string.h>
  12. #include <linux/fb.h>
  13. #include "atafb.h"
  14. #include "atafb_utils.h"
  15. /*
  16. * Monochrome
  17. */
  18. void atafb_mfb_copyarea(struct fb_info *info, u_long next_line,
  19. int sy, int sx, int dy, int dx,
  20. int height, int width)
  21. {
  22. u8 *src, *dest;
  23. u_int rows;
  24. if (sx == 0 && dx == 0 && width == next_line) {
  25. src = (u8 *)info->screen_base + sy * (width >> 3);
  26. dest = (u8 *)info->screen_base + dy * (width >> 3);
  27. fb_memmove(dest, src, height * (width >> 3));
  28. } else if (dy <= sy) {
  29. src = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
  30. dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
  31. for (rows = height; rows--;) {
  32. fb_memmove(dest, src, width >> 3);
  33. src += next_line;
  34. dest += next_line;
  35. }
  36. } else {
  37. src = (u8 *)info->screen_base + (sy + height - 1) * next_line + (sx >> 3);
  38. dest = (u8 *)info->screen_base + (dy + height - 1) * next_line + (dx >> 3);
  39. for (rows = height; rows--;) {
  40. fb_memmove(dest, src, width >> 3);
  41. src -= next_line;
  42. dest -= next_line;
  43. }
  44. }
  45. }
  46. void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color,
  47. int sy, int sx, int height, int width)
  48. {
  49. u8 *dest;
  50. u_int rows;
  51. dest = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
  52. if (sx == 0 && width == next_line) {
  53. if (color)
  54. fb_memset255(dest, height * (width >> 3));
  55. else
  56. fb_memclear(dest, height * (width >> 3));
  57. } else {
  58. for (rows = height; rows--; dest += next_line) {
  59. if (color)
  60. fb_memset255(dest, width >> 3);
  61. else
  62. fb_memclear_small(dest, width >> 3);
  63. }
  64. }
  65. }
  66. void atafb_mfb_linefill(struct fb_info *info, u_long next_line,
  67. int dy, int dx, u32 width,
  68. const u8 *data, u32 bgcolor, u32 fgcolor)
  69. {
  70. u8 *dest;
  71. u_int rows;
  72. dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
  73. for (rows = width / 8; rows--; /* check margins */ ) {
  74. // use fast_memmove or fb_memmove
  75. *dest++ = *data++;
  76. }
  77. }