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