regs-fb.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /* arch/arm/mach-s3c6400/include/mach/regs-fb.h
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * http://armlinux.simtec.co.uk/
  6. * Ben Dooks <ben@simtec.co.uk>
  7. *
  8. * S3C64XX - new-style framebuffer register definitions
  9. *
  10. * This is the register set for the new style framebuffer interface
  11. * found from the S3C2443 onwards and specifically the S3C64XX series
  12. * S3C6400 and S3C6410.
  13. *
  14. * The file contains the cpu specific items which change between whichever
  15. * architecture is selected. See <plat/regs-fb.h> for the core definitions
  16. * that are the same.
  17. *
  18. * This program is free software; you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License version 2 as
  20. * published by the Free Software Foundation.
  21. */
  22. /* include the core definitions here, in case we really do need to
  23. * override them at a later date.
  24. */
  25. #include <plat/regs-fb.h>
  26. #define S3C_FB_MAX_WIN (5) /* number of hardware windows available. */
  27. #define VIDCON1_FSTATUS_EVEN (1 << 15)
  28. /* Video timing controls */
  29. #define VIDTCON0 (0x10)
  30. #define VIDTCON1 (0x14)
  31. #define VIDTCON2 (0x18)
  32. /* Window position controls */
  33. #define WINCON(_win) (0x20 + ((_win) * 4))
  34. /* OSD1 and OSD4 do not have register D */
  35. #define VIDOSD_A(_win) (0x40 + ((_win) * 16))
  36. #define VIDOSD_B(_win) (0x44 + ((_win) * 16))
  37. #define VIDOSD_C(_win) (0x48 + ((_win) * 16))
  38. #define VIDOSD_D(_win) (0x4C + ((_win) * 16))
  39. /* Video buffer addresses */
  40. #define VIDW_BUF_START(_buff) (0xA0 + ((_buff) * 8))
  41. #define VIDW_BUF_START1(_buff) (0xA4 + ((_buff) * 8))
  42. #define VIDW_BUF_END(_buff) (0xD0 + ((_buff) * 8))
  43. #define VIDW_BUF_END1(_buff) (0xD4 + ((_buff) * 8))
  44. #define VIDW_BUF_SIZE(_buff) (0x100 + ((_buff) * 4))
  45. #define VIDINTCON0 (0x130)
  46. #define WxKEYCONy(_win, _con) ((0x140 + ((_win) * 8)) + ((_con) * 4))
  47. /* WINCONx */
  48. #define WINCONx_CSCWIDTH_MASK (0x3 << 26)
  49. #define WINCONx_CSCWIDTH_SHIFT (26)
  50. #define WINCONx_CSCWIDTH_WIDE (0x0 << 26)
  51. #define WINCONx_CSCWIDTH_NARROW (0x3 << 26)
  52. #define WINCONx_ENLOCAL (1 << 22)
  53. #define WINCONx_BUFSTATUS (1 << 21)
  54. #define WINCONx_BUFSEL (1 << 20)
  55. #define WINCONx_BUFAUTOEN (1 << 19)
  56. #define WINCONx_YCbCr (1 << 13)
  57. #define WINCON1_LOCALSEL_CAMIF (1 << 23)
  58. #define WINCON2_LOCALSEL_CAMIF (1 << 23)
  59. #define WINCON2_BLD_PIX (1 << 6)
  60. #define WINCON2_ALPHA_SEL (1 << 1)
  61. #define WINCON2_BPPMODE_MASK (0xf << 2)
  62. #define WINCON2_BPPMODE_SHIFT (2)
  63. #define WINCON2_BPPMODE_1BPP (0x0 << 2)
  64. #define WINCON2_BPPMODE_2BPP (0x1 << 2)
  65. #define WINCON2_BPPMODE_4BPP (0x2 << 2)
  66. #define WINCON2_BPPMODE_8BPP_1232 (0x4 << 2)
  67. #define WINCON2_BPPMODE_16BPP_565 (0x5 << 2)
  68. #define WINCON2_BPPMODE_16BPP_A1555 (0x6 << 2)
  69. #define WINCON2_BPPMODE_16BPP_I1555 (0x7 << 2)
  70. #define WINCON2_BPPMODE_18BPP_666 (0x8 << 2)
  71. #define WINCON2_BPPMODE_18BPP_A1665 (0x9 << 2)
  72. #define WINCON2_BPPMODE_19BPP_A1666 (0xa << 2)
  73. #define WINCON2_BPPMODE_24BPP_888 (0xb << 2)
  74. #define WINCON2_BPPMODE_24BPP_A1887 (0xc << 2)
  75. #define WINCON2_BPPMODE_25BPP_A1888 (0xd << 2)
  76. #define WINCON2_BPPMODE_28BPP_A4888 (0xd << 2)
  77. #define WINCON3_BLD_PIX (1 << 6)
  78. #define WINCON3_ALPHA_SEL (1 << 1)
  79. #define WINCON3_BPPMODE_MASK (0xf << 2)
  80. #define WINCON3_BPPMODE_SHIFT (2)
  81. #define WINCON3_BPPMODE_1BPP (0x0 << 2)
  82. #define WINCON3_BPPMODE_2BPP (0x1 << 2)
  83. #define WINCON3_BPPMODE_4BPP (0x2 << 2)
  84. #define WINCON3_BPPMODE_16BPP_565 (0x5 << 2)
  85. #define WINCON3_BPPMODE_16BPP_A1555 (0x6 << 2)
  86. #define WINCON3_BPPMODE_16BPP_I1555 (0x7 << 2)
  87. #define WINCON3_BPPMODE_18BPP_666 (0x8 << 2)
  88. #define WINCON3_BPPMODE_18BPP_A1665 (0x9 << 2)
  89. #define WINCON3_BPPMODE_19BPP_A1666 (0xa << 2)
  90. #define WINCON3_BPPMODE_24BPP_888 (0xb << 2)
  91. #define WINCON3_BPPMODE_24BPP_A1887 (0xc << 2)
  92. #define WINCON3_BPPMODE_25BPP_A1888 (0xd << 2)
  93. #define WINCON3_BPPMODE_28BPP_A4888 (0xd << 2)
  94. #define VIDINTCON0_FIFIOSEL_WINDOW2 (0x10 << 5)
  95. #define VIDINTCON0_FIFIOSEL_WINDOW3 (0x20 << 5)
  96. #define VIDINTCON0_FIFIOSEL_WINDOW4 (0x40 << 5)
  97. #define DITHMODE (0x170)
  98. #define WINxMAP(_win) (0x180 + ((_win) * 4))
  99. #define DITHMODE_R_POS_MASK (0x3 << 5)
  100. #define DITHMODE_R_POS_SHIFT (5)
  101. #define DITHMODE_R_POS_8BIT (0x0 << 5)
  102. #define DITHMODE_R_POS_6BIT (0x1 << 5)
  103. #define DITHMODE_R_POS_5BIT (0x2 << 5)
  104. #define DITHMODE_G_POS_MASK (0x3 << 3)
  105. #define DITHMODE_G_POS_SHIFT (3)
  106. #define DITHMODE_G_POS_8BIT (0x0 << 3)
  107. #define DITHMODE_G_POS_6BIT (0x1 << 3)
  108. #define DITHMODE_G_POS_5BIT (0x2 << 3)
  109. #define DITHMODE_B_POS_MASK (0x3 << 1)
  110. #define DITHMODE_B_POS_SHIFT (1)
  111. #define DITHMODE_B_POS_8BIT (0x0 << 1)
  112. #define DITHMODE_B_POS_6BIT (0x1 << 1)
  113. #define DITHMODE_B_POS_5BIT (0x2 << 1)
  114. #define DITHMODE_DITH_EN (1 << 0)
  115. #define WPALCON (0x1A0)
  116. #define WPALCON_W4PAL_16BPP_A555 (1 << 8)
  117. #define WPALCON_W3PAL_16BPP_A555 (1 << 7)
  118. #define WPALCON_W2PAL_16BPP_A555 (1 << 6)
  119. /* Palette registers */
  120. #define WIN2_PAL(_entry) (0x300 + ((_entry) * 2))
  121. #define WIN3_PAL(_entry) (0x320 + ((_entry) * 2))
  122. #define WIN4_PAL(_entry) (0x340 + ((_entry) * 2))
  123. #define WIN0_PAL(_entry) (0x400 + ((_entry) * 4))
  124. #define WIN1_PAL(_entry) (0x800 + ((_entry) * 4))
  125. /* system specific implementation code for palette sizes, and other
  126. * information that changes depending on which architecture is being
  127. * compiled.
  128. */
  129. /* return true if window _win has OSD register D */
  130. #define s3c_fb_has_osd_d(_win) ((_win) != 4 && (_win) != 0)
  131. static inline unsigned int s3c_fb_win_pal_size(unsigned int win)
  132. {
  133. if (win < 2)
  134. return 256;
  135. if (win < 4)
  136. return 16;
  137. if (win == 4)
  138. return 4;
  139. BUG(); /* shouldn't get here */
  140. }
  141. static inline int s3c_fb_validate_win_bpp(unsigned int win, unsigned int bpp)
  142. {
  143. /* all windows can do 1/2 bpp */
  144. if ((bpp == 25 || bpp == 19) && win == 0)
  145. return 0; /* win 0 does not have 19 or 25bpp modes */
  146. if (bpp == 4 && win == 4)
  147. return 0;
  148. if (bpp == 8 && (win >= 3))
  149. return 0; /* win 3/4 cannot do 8bpp in any mode */
  150. return 1;
  151. }
  152. static inline unsigned int s3c_fb_pal_reg(unsigned int window, int reg)
  153. {
  154. switch (window) {
  155. case 0: return WIN0_PAL(reg);
  156. case 1: return WIN1_PAL(reg);
  157. case 2: return WIN2_PAL(reg);
  158. case 3: return WIN3_PAL(reg);
  159. case 4: return WIN4_PAL(reg);
  160. }
  161. BUG();
  162. }
  163. static inline int s3c_fb_pal_is16(unsigned int window)
  164. {
  165. return window > 1;
  166. }
  167. struct s3c_fb_palette {
  168. struct fb_bitfield r;
  169. struct fb_bitfield g;
  170. struct fb_bitfield b;
  171. struct fb_bitfield a;
  172. };
  173. static inline void s3c_fb_init_palette(unsigned int window,
  174. struct s3c_fb_palette *palette)
  175. {
  176. if (window < 2) {
  177. /* Windows 0/1 are 8/8/8 or A/8/8/8 */
  178. palette->r.offset = 16;
  179. palette->r.length = 8;
  180. palette->g.offset = 8;
  181. palette->g.length = 8;
  182. palette->b.offset = 0;
  183. palette->b.length = 8;
  184. } else {
  185. /* currently we assume RGB 5/6/5 */
  186. palette->r.offset = 11;
  187. palette->r.length = 5;
  188. palette->g.offset = 5;
  189. palette->g.length = 6;
  190. palette->b.offset = 0;
  191. palette->b.length = 5;
  192. }
  193. }
  194. /* Notes on per-window bpp settings
  195. *
  196. * Value Win0 Win1 Win2 Win3 Win 4
  197. * 0000 1(P) 1(P) 1(P) 1(P) 1(P)
  198. * 0001 2(P) 2(P) 2(P) 2(P) 2(P)
  199. * 0010 4(P) 4(P) 4(P) 4(P) -none-
  200. * 0011 8(P) 8(P) -none- -none- -none-
  201. * 0100 -none- 8(A232) 8(A232) -none- -none-
  202. * 0101 16(565) 16(565) 16(565) 16(565) 16(565)
  203. * 0110 -none- 16(A555) 16(A555) 16(A555) 16(A555)
  204. * 0111 16(I555) 16(I565) 16(I555) 16(I555) 16(I555)
  205. * 1000 18(666) 18(666) 18(666) 18(666) 18(666)
  206. * 1001 -none- 18(A665) 18(A665) 18(A665) 16(A665)
  207. * 1010 -none- 19(A666) 19(A666) 19(A666) 19(A666)
  208. * 1011 24(888) 24(888) 24(888) 24(888) 24(888)
  209. * 1100 -none- 24(A887) 24(A887) 24(A887) 24(A887)
  210. * 1101 -none- 25(A888) 25(A888) 25(A888) 25(A888)
  211. * 1110 -none- -none- -none- -none- -none-
  212. * 1111 -none- -none- -none- -none- -none-
  213. */