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