fbcon_rotate.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * linux/drivers/video/console/fbcon_rotate.h -- Software Display Rotation
  3. *
  4. * Copyright (C) 2005 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
  8. * for more details.
  9. */
  10. #ifndef _FBCON_ROTATE_H
  11. #define _FBCON_ROTATE_H
  12. #define FNTCHARCNT(fd) (((int *)(fd))[-3])
  13. #define GETVYRES(s,i) ({ \
  14. (s == SCROLL_REDRAW || s == SCROLL_MOVE) ? \
  15. (i)->var.yres : (i)->var.yres_virtual; })
  16. #define GETVXRES(s,i) ({ \
  17. (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \
  18. (i)->var.xres : (i)->var.xres_virtual; })
  19. static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat)
  20. {
  21. u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
  22. pat +=index;
  23. return (*pat) & (0x80 >> bit);
  24. }
  25. static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
  26. {
  27. u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
  28. pat += index;
  29. (*pat) |= 0x80 >> bit;
  30. }
  31. static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
  32. {
  33. int i, j;
  34. int shift = (8 - (width % 8)) & 7;
  35. width = (width + 7) & ~7;
  36. for (i = 0; i < height; i++) {
  37. for (j = 0; j < width; j++) {
  38. if (pattern_test_bit(j, i, width, in))
  39. pattern_set_bit(width - (1 + j + shift),
  40. height - (1 + i),
  41. width, out);
  42. }
  43. }
  44. }
  45. static inline void rotate_cw(const char *in, char *out, u32 width, u32 height)
  46. {
  47. int i, j, h = height, w = width;
  48. int shift = (8 - (height % 8)) & 7;
  49. width = (width + 7) & ~7;
  50. height = (height + 7) & ~7;
  51. for (i = 0; i < h; i++) {
  52. for (j = 0; j < w; j++) {
  53. if (pattern_test_bit(j, i, width, in))
  54. pattern_set_bit(height - 1 - i - shift, j,
  55. height, out);
  56. }
  57. }
  58. }
  59. static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)
  60. {
  61. int i, j, h = height, w = width;
  62. int shift = (8 - (width % 8)) & 7;
  63. width = (width + 7) & ~7;
  64. height = (height + 7) & ~7;
  65. for (i = 0; i < h; i++) {
  66. for (j = 0; j < w; j++) {
  67. if (pattern_test_bit(j, i, width, in))
  68. pattern_set_bit(i, width - 1 - j - shift,
  69. height, out);
  70. }
  71. }
  72. }
  73. extern void fbcon_rotate_cw(struct fbcon_ops *ops);
  74. extern void fbcon_rotate_ud(struct fbcon_ops *ops);
  75. extern void fbcon_rotate_ccw(struct fbcon_ops *ops);
  76. #endif