sticore.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. #ifndef STICORE_H
  2. #define STICORE_H
  3. /* generic STI structures & functions */
  4. #if 0
  5. #define DPRINTK(x) printk x
  6. #else
  7. #define DPRINTK(x)
  8. #endif
  9. #define MAX_STI_ROMS 4 /* max no. of ROMs which this driver handles */
  10. #define STI_REGION_MAX 8 /* hardcoded STI constants */
  11. #define STI_DEV_NAME_LENGTH 32
  12. #define STI_MONITOR_MAX 256
  13. #define STI_FONT_HPROMAN8 1
  14. #define STI_FONT_KANA8 2
  15. /* The latency of the STI functions cannot really be reduced by setting
  16. * this to 0; STI doesn't seem to be designed to allow calling a different
  17. * function (or the same function with different arguments) after a
  18. * function exited with 1 as return value.
  19. *
  20. * As all of the functions below could be called from interrupt context,
  21. * we have to spin_lock_irqsave around the do { ret = bla(); } while(ret==1)
  22. * block. Really bad latency there.
  23. *
  24. * Probably the best solution to all this is have the generic code manage
  25. * the screen buffer and a kernel thread to call STI occasionally.
  26. *
  27. * Luckily, the frame buffer guys have the same problem so we can just wait
  28. * for them to fix it and steal their solution. prumpf
  29. */
  30. #define STI_WAIT 1
  31. #include <asm/io.h> /* for USE_HPPA_IOREMAP */
  32. #if USE_HPPA_IOREMAP
  33. #define STI_PTR(p) (p)
  34. #define PTR_STI(p) (p)
  35. static inline int STI_CALL( unsigned long func,
  36. void *flags, void *inptr, void *outptr, void *glob_cfg )
  37. {
  38. int (*f)(void *,void *,void *,void *);
  39. f = (void*)func;
  40. return f(flags, inptr, outptr, glob_cfg);
  41. }
  42. #else /* !USE_HPPA_IOREMAP */
  43. #define STI_PTR(p) ( virt_to_phys(p) )
  44. #define PTR_STI(p) ( phys_to_virt((long)p) )
  45. #define STI_CALL(func, flags, inptr, outptr, glob_cfg) \
  46. ({ \
  47. pdc_sti_call( func, (unsigned long)STI_PTR(flags), \
  48. (unsigned long)STI_PTR(inptr), \
  49. (unsigned long)STI_PTR(outptr), \
  50. (unsigned long)STI_PTR(glob_cfg)); \
  51. })
  52. #endif /* USE_HPPA_IOREMAP */
  53. #define sti_onscreen_x(sti) (sti->glob_cfg->onscreen_x)
  54. #define sti_onscreen_y(sti) (sti->glob_cfg->onscreen_y)
  55. /* sti_font_xy() use the native font ROM ! */
  56. #define sti_font_x(sti) (PTR_STI(sti->font)->width)
  57. #define sti_font_y(sti) (PTR_STI(sti->font)->height)
  58. /* STI function configuration structs */
  59. typedef union region {
  60. struct {
  61. u32 offset : 14; /* offset in 4kbyte page */
  62. u32 sys_only : 1; /* don't map to user space */
  63. u32 cache : 1; /* map to data cache */
  64. u32 btlb : 1; /* map to block tlb */
  65. u32 last : 1; /* last region in list */
  66. u32 length : 14; /* length in 4kbyte page */
  67. } region_desc;
  68. u32 region; /* complete region value */
  69. } region_t;
  70. #define REGION_OFFSET_TO_PHYS( rt, hpa ) \
  71. (((rt).region_desc.offset << 12) + (hpa))
  72. struct sti_glob_cfg_ext {
  73. u8 curr_mon; /* current monitor configured */
  74. u8 friendly_boot; /* in friendly boot mode */
  75. s16 power; /* power calculation (in Watts) */
  76. s32 freq_ref; /* frequency refrence */
  77. u32 sti_mem_addr; /* pointer to global sti memory (size=sti_mem_request) */
  78. u32 future_ptr; /* pointer to future data */
  79. };
  80. struct sti_glob_cfg {
  81. s32 text_planes; /* number of planes used for text */
  82. s16 onscreen_x; /* screen width in pixels */
  83. s16 onscreen_y; /* screen height in pixels */
  84. s16 offscreen_x; /* offset width in pixels */
  85. s16 offscreen_y; /* offset height in pixels */
  86. s16 total_x; /* frame buffer width in pixels */
  87. s16 total_y; /* frame buffer height in pixels */
  88. u32 region_ptrs[STI_REGION_MAX]; /* region pointers */
  89. s32 reent_lvl; /* storage for reentry level value */
  90. u32 save_addr; /* where to save or restore reentrant state */
  91. u32 ext_ptr; /* pointer to extended glob_cfg data structure */
  92. };
  93. /* STI init function structs */
  94. struct sti_init_flags {
  95. u32 wait : 1; /* should routine idle wait or not */
  96. u32 reset : 1; /* hard reset the device? */
  97. u32 text : 1; /* turn on text display planes? */
  98. u32 nontext : 1; /* turn on non-text display planes? */
  99. u32 clear : 1; /* clear text display planes? */
  100. u32 cmap_blk : 1; /* non-text planes cmap black? */
  101. u32 enable_be_timer : 1; /* enable bus error timer */
  102. u32 enable_be_int : 1; /* enable bus error timer interrupt */
  103. u32 no_chg_tx : 1; /* don't change text settings */
  104. u32 no_chg_ntx : 1; /* don't change non-text settings */
  105. u32 no_chg_bet : 1; /* don't change berr timer settings */
  106. u32 no_chg_bei : 1; /* don't change berr int settings */
  107. u32 init_cmap_tx : 1; /* initialize cmap for text planes */
  108. u32 cmt_chg : 1; /* change current monitor type */
  109. u32 retain_ie : 1; /* don't allow reset to clear int enables */
  110. u32 caller_bootrom : 1; /* set only by bootrom for each call */
  111. u32 caller_kernel : 1; /* set only by kernel for each call */
  112. u32 caller_other : 1; /* set only by non-[BR/K] caller */
  113. u32 pad : 14; /* pad to word boundary */
  114. u32 future_ptr; /* pointer to future data */
  115. };
  116. struct sti_init_inptr_ext {
  117. u8 config_mon_type; /* configure to monitor type */
  118. u8 pad[1]; /* pad to word boundary */
  119. u16 inflight_data; /* inflight data possible on PCI */
  120. u32 future_ptr; /* pointer to future data */
  121. };
  122. struct sti_init_inptr {
  123. s32 text_planes; /* number of planes to use for text */
  124. u32 ext_ptr; /* pointer to extended init_graph inptr data structure*/
  125. };
  126. struct sti_init_outptr {
  127. s32 errno; /* error number on failure */
  128. s32 text_planes; /* number of planes used for text */
  129. u32 future_ptr; /* pointer to future data */
  130. };
  131. /* STI configuration function structs */
  132. struct sti_conf_flags {
  133. u32 wait : 1; /* should routine idle wait or not */
  134. u32 pad : 31; /* pad to word boundary */
  135. u32 future_ptr; /* pointer to future data */
  136. };
  137. struct sti_conf_inptr {
  138. u32 future_ptr; /* pointer to future data */
  139. };
  140. struct sti_conf_outptr_ext {
  141. u32 crt_config[3]; /* hardware specific X11/OGL information */
  142. u32 crt_hdw[3];
  143. u32 future_ptr;
  144. };
  145. struct sti_conf_outptr {
  146. s32 errno; /* error number on failure */
  147. s16 onscreen_x; /* screen width in pixels */
  148. s16 onscreen_y; /* screen height in pixels */
  149. s16 offscreen_x; /* offscreen width in pixels */
  150. s16 offscreen_y; /* offscreen height in pixels */
  151. s16 total_x; /* frame buffer width in pixels */
  152. s16 total_y; /* frame buffer height in pixels */
  153. s32 bits_per_pixel; /* bits/pixel device has configured */
  154. s32 bits_used; /* bits which can be accessed */
  155. s32 planes; /* number of fb planes in system */
  156. u8 dev_name[STI_DEV_NAME_LENGTH]; /* null terminated product name */
  157. u32 attributes; /* flags denoting attributes */
  158. u32 ext_ptr; /* pointer to future data */
  159. };
  160. struct sti_rom {
  161. u8 type[4];
  162. u8 res004;
  163. u8 num_mons;
  164. u8 revno[2];
  165. u32 graphics_id[2];
  166. u32 font_start;
  167. u32 statesize;
  168. u32 last_addr;
  169. u32 region_list;
  170. u16 reentsize;
  171. u16 maxtime;
  172. u32 mon_tbl_addr;
  173. u32 user_data_addr;
  174. u32 sti_mem_req;
  175. u32 user_data_size;
  176. u16 power;
  177. u8 bus_support;
  178. u8 ext_bus_support;
  179. u8 alt_code_type;
  180. u8 ext_dd_struct[3];
  181. u32 cfb_addr;
  182. u32 init_graph;
  183. u32 state_mgmt;
  184. u32 font_unpmv;
  185. u32 block_move;
  186. u32 self_test;
  187. u32 excep_hdlr;
  188. u32 inq_conf;
  189. u32 set_cm_entry;
  190. u32 dma_ctrl;
  191. u8 res040[7 * 4];
  192. u32 init_graph_addr;
  193. u32 state_mgmt_addr;
  194. u32 font_unp_addr;
  195. u32 block_move_addr;
  196. u32 self_test_addr;
  197. u32 excep_hdlr_addr;
  198. u32 inq_conf_addr;
  199. u32 set_cm_entry_addr;
  200. u32 image_unpack_addr;
  201. u32 pa_risx_addrs[7];
  202. };
  203. struct sti_rom_font {
  204. u16 first_char;
  205. u16 last_char;
  206. u8 width;
  207. u8 height;
  208. u8 font_type; /* language type */
  209. u8 bytes_per_char;
  210. u32 next_font;
  211. u8 underline_height;
  212. u8 underline_pos;
  213. u8 res008[2];
  214. };
  215. /* sticore internal font handling */
  216. struct sti_cooked_font {
  217. struct sti_rom_font *raw;
  218. struct sti_cooked_font *next_font;
  219. };
  220. struct sti_cooked_rom {
  221. struct sti_rom *raw;
  222. struct sti_cooked_font *font_start;
  223. };
  224. /* STI font printing function structs */
  225. struct sti_font_inptr {
  226. u32 font_start_addr; /* address of font start */
  227. s16 index; /* index into font table of character */
  228. u8 fg_color; /* foreground color of character */
  229. u8 bg_color; /* background color of character */
  230. s16 dest_x; /* X location of character upper left */
  231. s16 dest_y; /* Y location of character upper left */
  232. u32 future_ptr; /* pointer to future data */
  233. };
  234. struct sti_font_flags {
  235. u32 wait : 1; /* should routine idle wait or not */
  236. u32 non_text : 1; /* font unpack/move in non_text planes =1, text =0 */
  237. u32 pad : 30; /* pad to word boundary */
  238. u32 future_ptr; /* pointer to future data */
  239. };
  240. struct sti_font_outptr {
  241. s32 errno; /* error number on failure */
  242. u32 future_ptr; /* pointer to future data */
  243. };
  244. /* STI blockmove structs */
  245. struct sti_blkmv_flags {
  246. u32 wait : 1; /* should routine idle wait or not */
  247. u32 color : 1; /* change color during move? */
  248. u32 clear : 1; /* clear during move? */
  249. u32 non_text : 1; /* block move in non_text planes =1, text =0 */
  250. u32 pad : 28; /* pad to word boundary */
  251. u32 future_ptr; /* pointer to future data */
  252. };
  253. struct sti_blkmv_inptr {
  254. u8 fg_color; /* foreground color after move */
  255. u8 bg_color; /* background color after move */
  256. s16 src_x; /* source upper left pixel x location */
  257. s16 src_y; /* source upper left pixel y location */
  258. s16 dest_x; /* dest upper left pixel x location */
  259. s16 dest_y; /* dest upper left pixel y location */
  260. s16 width; /* block width in pixels */
  261. s16 height; /* block height in pixels */
  262. u32 future_ptr; /* pointer to future data */
  263. };
  264. struct sti_blkmv_outptr {
  265. s32 errno; /* error number on failure */
  266. u32 future_ptr; /* pointer to future data */
  267. };
  268. /* internal generic STI struct */
  269. struct sti_struct {
  270. spinlock_t lock;
  271. /* the following fields needs to be filled in by the word/byte routines */
  272. int font_width;
  273. int font_height;
  274. /* char **mon_strings; */
  275. int sti_mem_request;
  276. u32 graphics_id[2];
  277. struct sti_cooked_rom *rom;
  278. unsigned long font_unpmv;
  279. unsigned long block_move;
  280. unsigned long init_graph;
  281. unsigned long inq_conf;
  282. /* all following fields are initialized by the generic routines */
  283. int text_planes;
  284. region_t regions[STI_REGION_MAX];
  285. unsigned long regions_phys[STI_REGION_MAX];
  286. struct sti_glob_cfg *glob_cfg;
  287. struct sti_cooked_font *font; /* ptr to selected font (cooked) */
  288. struct sti_conf_outptr outptr; /* configuration */
  289. struct sti_conf_outptr_ext outptr_ext;
  290. /* PCI data structures (pg. 17ff from sti.pdf) */
  291. struct pci_dev *pd;
  292. u8 rm_entry[16]; /* pci region mapper array == pci config space offset */
  293. /* pointer to the fb_info where this STI device is used */
  294. struct fb_info *info;
  295. };
  296. /* sticore interface functions */
  297. struct sti_struct *sti_get_rom(unsigned int index); /* 0: default sti */
  298. /* functions to call the STI ROM directly */
  299. int sti_init_graph(struct sti_struct *sti);
  300. void sti_inq_conf(struct sti_struct *sti);
  301. void sti_putc(struct sti_struct *sti, int c, int y, int x);
  302. void sti_set(struct sti_struct *sti, int src_y, int src_x,
  303. int height, int width, u8 color);
  304. void sti_clear(struct sti_struct *sti, int src_y, int src_x,
  305. int height, int width, int c);
  306. void sti_bmove(struct sti_struct *sti, int src_y, int src_x,
  307. int dst_y, int dst_x, int height, int width);
  308. #endif /* STICORE_H */