s3cfb.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. #ifndef __S3CFB_H
  2. #define __S3CFB_H
  3. /*
  4. * linux/drivers/video/s3cfb.h
  5. *
  6. * $Id: s3cfb.h,v 1.13 2008/05/26 07:58:22 jsgood Exp $
  7. *
  8. * Copyright (c)2005 rahul tanwar <rahul.tanwar@samsung.com>
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file COPYING in the main directory of this archive for
  12. * more details.
  13. *
  14. * S3C LCD Controller Frame Buffer Driver
  15. * based on skeletonfb.c, sa1100fb.h
  16. *
  17. */
  18. #define BIT0 0x00000001
  19. #define BIT1 0x00000002
  20. #define BIT2 0x00000004
  21. #define BIT3 0x00000008
  22. #define BIT4 0x00000010
  23. #define BIT5 0x00000020
  24. #define BIT6 0x00000040
  25. #define BIT7 0x00000080
  26. #define BIT8 0x00000100
  27. #define BIT9 0x00000200
  28. #define BIT10 0x00000400
  29. #define BIT11 0x00000800
  30. #define BIT12 0x00001000
  31. #define BIT13 0x00002000
  32. #define BIT14 0x00004000
  33. #define BIT15 0x00008000
  34. #define BIT16 0x00010000
  35. #define BIT17 0x00020000
  36. #define BIT18 0x00040000
  37. #define BIT19 0x00080000
  38. #define BIT20 0x00100000
  39. #define BIT21 0x00200000
  40. #define BIT22 0x00400000
  41. #define BIT23 0x00800000
  42. #define BIT24 0x01000000
  43. #define BIT25 0x02000000
  44. #define BIT26 0x04000000
  45. #define BIT27 0x08000000
  46. #define BIT28 0x10000000
  47. #define BIT29 0x20000000
  48. #define BIT30 0x40000000
  49. #define BIT31 0x80000000
  50. #define MIN_XRES 64
  51. #define MIN_YRES 64
  52. struct s3c_fb_rgb {
  53. struct fb_bitfield red;
  54. struct fb_bitfield green;
  55. struct fb_bitfield blue;
  56. struct fb_bitfield transp;
  57. };
  58. const static struct s3c_fb_rgb s3c_fb_rgb_8 = {
  59. .red = {.offset = 0, .length = 8,},
  60. .green = {.offset = 0, .length = 8,},
  61. .blue = {.offset = 0, .length = 8,},
  62. .transp = {.offset = 0, .length = 0,},
  63. };
  64. const static struct s3c_fb_rgb s3c_fb_rgb_16 = {
  65. .red = {.offset = 11, .length = 5,},
  66. .green = {.offset = 5, .length = 6,},
  67. .blue = {.offset = 0, .length = 5,},
  68. .transp = {.offset = 0, .length = 0,},
  69. };
  70. const static struct s3c_fb_rgb s3c_fb_rgb_24 = {
  71. .red = {.offset = 16, .length = 8,},
  72. .green = {.offset = 8, .length = 8,},
  73. .blue = {.offset = 0, .length = 8,},
  74. .transp = {.offset = 0, .length = 0,},
  75. };
  76. const static struct s3c_fb_rgb s3c_fb_rgb_32 = {
  77. .red={.offset=16, .length=8,},
  78. .green={.offset=8, .length=8,},
  79. .blue={.offset=0, .length=8,},
  80. .transp={.offset= 24, .length=8,},
  81. };
  82. struct s3c_fb_info {
  83. struct fb_info fb;
  84. struct device *dev;
  85. // YREOM 2007 add for supporting many OSD
  86. u_int win_id;
  87. u_int max_bpp;
  88. u_int max_xres;
  89. u_int max_yres;
  90. /* raw memory addresses */
  91. dma_addr_t map_dma_f1; /* physical */
  92. u_char * map_cpu_f1; /* virtual */
  93. u_int map_size_f1;
  94. /* addresses of pieces placed in raw buffer */
  95. u_char * screen_cpu_f1; /* virtual address of frame buffer */
  96. dma_addr_t screen_dma_f1; /* physical address of frame buffer */
  97. /* raw memory addresses */
  98. dma_addr_t map_dma_f2; /* physical */
  99. u_char * map_cpu_f2; /* virtual */
  100. u_int map_size_f2;
  101. /* addresses of pieces placed in raw buffer */
  102. u_char * screen_cpu_f2; /* virtual address of frame buffer */
  103. dma_addr_t screen_dma_f2; /* physical address of frame buffer */
  104. unsigned int palette_ready;
  105. unsigned int fb_change_ready;
  106. /* keep these registers in case we need to re-write palette */
  107. u32 palette_buffer[256];
  108. u32 pseudo_pal[16];
  109. };
  110. #define PALETTE_BUFF_CLEAR (0x80000000) /* entry is clear/invalid */
  111. int s3c_fb_init(void);
  112. #if 0
  113. #define dprintk(msg...) printk("s3c_fb: " msg)
  114. #else
  115. #define dprintk(msg...) while (0) { }
  116. #endif
  117. struct s3c_fb_mach_info {
  118. /* Screen size */
  119. int width;
  120. int height;
  121. /* Screen info */
  122. int xres;
  123. int yres;
  124. /* Virtual Screen info */
  125. int xres_virtual;
  126. int yres_virtual;
  127. int xoffset;
  128. int yoffset;
  129. /* OSD Screen size */
  130. int osd_width;
  131. int osd_height;
  132. /* OSD Screen info */
  133. int osd_xres;
  134. int osd_yres;
  135. /* OSD Screen info */
  136. int osd_xres_virtual;
  137. int osd_yres_virtual;
  138. int bpp;
  139. int bytes_per_pixel;
  140. unsigned long pixclock;
  141. int hsync_len;
  142. int left_margin;
  143. int right_margin;
  144. int vsync_len;
  145. int upper_margin;
  146. int lower_margin;
  147. int sync;
  148. int cmap_grayscale:1, cmap_inverse:1, cmap_static:1, unused:29;
  149. /* lcd configuration registers */
  150. unsigned long lcdcon1;
  151. unsigned long lcdcon2;
  152. unsigned long lcdcon3;
  153. unsigned long lcdcon4;
  154. unsigned long lcdcon5;
  155. /* GPIOs */
  156. unsigned long gpcup;
  157. unsigned long gpcup_mask;
  158. unsigned long gpccon;
  159. unsigned long gpccon_mask;
  160. unsigned long gpdup;
  161. unsigned long gpdup_mask;
  162. unsigned long gpdcon;
  163. unsigned long gpdcon_mask;
  164. /* lpc3600 control register */
  165. unsigned long lpcsel;
  166. unsigned long lcdtcon1;
  167. unsigned long lcdtcon2;
  168. unsigned long lcdtcon3;
  169. unsigned long lcdosd1;
  170. unsigned long lcdosd2;
  171. unsigned long lcdosd3;
  172. unsigned long lcdsaddrb1;
  173. unsigned long lcdsaddrb2;
  174. unsigned long lcdsaddrf1;
  175. unsigned long lcdsaddrf2;
  176. unsigned long lcdeaddrb1;
  177. unsigned long lcdeaddrb2;
  178. unsigned long lcdeaddrf1;
  179. unsigned long lcdeaddrf2;
  180. unsigned long lcdvscrb1;
  181. unsigned long lcdvscrb2;
  182. unsigned long lcdvscrf1;
  183. unsigned long lcdvscrf2;
  184. unsigned long lcdintcon;
  185. unsigned long lcdkeycon;
  186. unsigned long lcdkeyval;
  187. unsigned long lcdbgcon;
  188. unsigned long lcdfgcon;
  189. unsigned long lcddithcon;
  190. /* For s3c2443, s3c6400 */
  191. unsigned long vidcon0;
  192. unsigned long vidcon1;
  193. unsigned long vidtcon0;
  194. unsigned long vidtcon1;
  195. unsigned long vidtcon2;
  196. unsigned long vidtcon3;
  197. unsigned long wincon0;
  198. unsigned long wincon2;
  199. unsigned long wincon1;
  200. unsigned long wincon3;
  201. unsigned long wincon4;
  202. unsigned long vidosd0a;
  203. unsigned long vidosd0b;
  204. unsigned long vidosd0c;
  205. unsigned long vidosd1a;
  206. unsigned long vidosd1b;
  207. unsigned long vidosd1c;
  208. unsigned long vidosd1d;
  209. unsigned long vidosd2a;
  210. unsigned long vidosd2b;
  211. unsigned long vidosd2c;
  212. unsigned long vidosd2d;
  213. unsigned long vidosd3a;
  214. unsigned long vidosd3b;
  215. unsigned long vidosd3c;
  216. unsigned long vidosd4a;
  217. unsigned long vidosd4b;
  218. unsigned long vidosd4c;
  219. unsigned long vidw00add0b0;
  220. unsigned long vidw00add0b1;
  221. unsigned long vidw01add0;
  222. unsigned long vidw01add0b0;
  223. unsigned long vidw01add0b1;
  224. unsigned long vidw00add1b0;
  225. unsigned long vidw00add1b1;
  226. unsigned long vidw01add1;
  227. unsigned long vidw01add1b0;
  228. unsigned long vidw01add1b1;
  229. unsigned long vidw00add2b0;
  230. unsigned long vidw00add2b1;
  231. unsigned long vidw02add0;
  232. unsigned long vidw03add0;
  233. unsigned long vidw04add0;
  234. unsigned long vidw02add1;
  235. unsigned long vidw03add1;
  236. unsigned long vidw04add1;
  237. unsigned long vidw00add2;
  238. unsigned long vidw01add2;
  239. unsigned long vidw02add2;
  240. unsigned long vidw03add2;
  241. unsigned long vidw04add2;
  242. unsigned long vidintcon;
  243. unsigned long vidintcon0;
  244. unsigned long vidintcon1;
  245. unsigned long w1keycon0;
  246. unsigned long w1keycon1;
  247. unsigned long w2keycon0;
  248. unsigned long w2keycon1;
  249. unsigned long w3keycon0;
  250. unsigned long w3keycon1;
  251. unsigned long w4keycon0;
  252. unsigned long w4keycon1;
  253. unsigned long win0map;
  254. unsigned long win1map;
  255. unsigned long win2map;
  256. unsigned long win3map;
  257. unsigned long win4map;
  258. unsigned long wpalcon;
  259. unsigned long dithmode;
  260. unsigned long intclr0;
  261. unsigned long intclr1;
  262. unsigned long intclr2;
  263. unsigned long win0pal;
  264. unsigned long win1pal;
  265. /* backlight info */
  266. int backlight_min;
  267. int backlight_max;
  268. int backlight_default;
  269. /* Utility fonctions */
  270. void (*backlight_power)(int);
  271. void (*lcd_power)(int);
  272. void (*set_brightness)(int);
  273. };
  274. typedef struct {
  275. int Bpp;
  276. int LeftTop_x;
  277. int LeftTop_y;
  278. int Width;
  279. int Height;
  280. } s3c_win_info_t;
  281. typedef struct {
  282. int width;
  283. int height;
  284. int bpp;
  285. int offset;
  286. int v_width;
  287. int v_height;
  288. } vs_info_t;
  289. typedef struct {
  290. int direction;
  291. unsigned int compkey_red;
  292. unsigned int compkey_green;
  293. unsigned int compkey_blue;
  294. } s3c_color_key_info_t;
  295. typedef struct {
  296. unsigned int colval_red;
  297. unsigned int colval_green;
  298. unsigned int colval_blue;
  299. } s3c_color_val_info_t;
  300. #ifndef MHZ
  301. #define MHZ (1000*1000)
  302. #endif
  303. #define print_mhz(m) ((m) / MHZ), ((m / 1000) % 1000)
  304. extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
  305. extern struct s3c_fb_mach_info mach_info;
  306. extern void set_brightness(int);
  307. extern int s3c_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg);
  308. extern int __init s3c_fb_map_video_memory(struct s3c_fb_info *fbi);
  309. extern void s3c_fb_unmap_video_memory(struct s3c_fb_info *fbi);
  310. extern void Init_LDI(void);
  311. extern int s3c_fb_init_registers(struct s3c_fb_info *fbi);
  312. extern void s3c_fb_set_lcdaddr(struct s3c_fb_info *fbi);
  313. extern void s3c_fb_activate_var(struct s3c_fb_info *fbi, struct fb_var_screeninfo *var);
  314. extern void s3c_fb_set_fb_change(int req_fb);
  315. extern int s3c_fb_init_win (struct s3c_fb_info *fbi, int Bpp, int LeftTop_x, int LeftTop_y, int Width, int Height, int OnOff);
  316. extern int s3c_fb_win_onoff(struct s3c_fb_info *fbi, int On);
  317. extern int s3c_fb_set_alpha_level(struct s3c_fb_info *fbi);
  318. extern int s3c_fb_set_alpha_mode(struct s3c_fb_info *fbi, int Alpha_mode, int Alpha_level);
  319. extern int s3c_fb_set_position_win(struct s3c_fb_info *fbi, int LeftTop_x, int LeftTop_y, int Width, int Height);
  320. extern int s3c_fb_set_size_win(struct s3c_fb_info *fbi, int Width, int Height);
  321. extern int s3c_fb_set_bpp(struct s3c_fb_info *fbi, int Bpp);
  322. extern int s3c_fb_set_memory_size_win(struct s3c_fb_info *fbi);
  323. extern int s3c_fb_set_out_path(struct s3c_fb_info *fbi, int Path);
  324. /* For color key support */
  325. #define COLOR_KEY_DIR_BG_DISPLAY 0
  326. #define COLOR_KEY_DIR_FG_DISPLAY 1
  327. int s3c_fb_color_key_alpha_onoff(struct s3c_fb_info *fbi, int On);
  328. int s3c_fb_color_key_onoff(struct s3c_fb_info *fbi, int On);
  329. int s3c_fb_setup_color_key_register(struct s3c_fb_info *fbi, s3c_color_key_info_t colkey_info);
  330. int s3c_fb_set_color_value(struct s3c_fb_info *fbi, s3c_color_val_info_t colval_info);
  331. #if defined(CONFIG_CPU_S3C2412)
  332. #define S3C_FB_MAX_NUM 1
  333. #elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C2416)
  334. #define S3C_FB_MAX_NUM 2
  335. #elif defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410)
  336. #define S3C_FB_MAX_NUM 5
  337. #else
  338. #define S3C_FB_MAX_NUM 1
  339. #endif
  340. // (WAITFORVSYNC)
  341. #define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t)
  342. typedef struct
  343. {
  344. wait_queue_head_t waitQueue;
  345. int count;
  346. } s3cfb_vSyncInfoType;
  347. extern int s3cfb_wait_for_sync(u_int32_t crtc);
  348. //(WAITFORVSYNC)
  349. #define FB_MAX_NUM(x,y) ((x)>(y) ? (y) : (x))
  350. #define S3C_FB_NUM FB_MAX_NUM(S3C_FB_MAX_NUM, CONFIG_FB_NUM)
  351. struct s3c_fb_dma_info
  352. {
  353. dma_addr_t map_dma_f1;
  354. dma_addr_t map_dma_f2;
  355. };
  356. #endif