xref: /openbmc/linux/include/video/uvesafb.h (revision 293d5b43)
1 #ifndef _UVESAFB_H
2 #define _UVESAFB_H
3 
4 #include <uapi/video/uvesafb.h>
5 
6 
7 /* VBE CRTC Info Block */
8 struct vbe_crtc_ib {
9 	u16 horiz_total;
10 	u16 horiz_start;
11 	u16 horiz_end;
12 	u16 vert_total;
13 	u16 vert_start;
14 	u16 vert_end;
15 	u8  flags;
16 	u32 pixel_clock;
17 	u16 refresh_rate;
18 	u8  reserved[40];
19 } __attribute__ ((packed));
20 
21 #define VBE_MODE_VGACOMPAT	0x20
22 #define VBE_MODE_COLOR		0x08
23 #define VBE_MODE_SUPPORTEDHW	0x01
24 #define VBE_MODE_GRAPHICS	0x10
25 #define VBE_MODE_LFB		0x80
26 
27 #define VBE_MODE_MASK		(VBE_MODE_COLOR | VBE_MODE_SUPPORTEDHW | \
28 				VBE_MODE_GRAPHICS | VBE_MODE_LFB)
29 
30 /* VBE Mode Info Block */
31 struct vbe_mode_ib {
32 	/* for all VBE revisions */
33 	u16 mode_attr;
34 	u8  winA_attr;
35 	u8  winB_attr;
36 	u16 win_granularity;
37 	u16 win_size;
38 	u16 winA_seg;
39 	u16 winB_seg;
40 	u32 win_func_ptr;
41 	u16 bytes_per_scan_line;
42 
43 	/* for VBE 1.2+ */
44 	u16 x_res;
45 	u16 y_res;
46 	u8  x_char_size;
47 	u8  y_char_size;
48 	u8  planes;
49 	u8  bits_per_pixel;
50 	u8  banks;
51 	u8  memory_model;
52 	u8  bank_size;
53 	u8  image_pages;
54 	u8  reserved1;
55 
56 	/* Direct color fields for direct/6 and YUV/7 memory models. */
57 	/* Offsets are bit positions of lsb in the mask. */
58 	u8  red_len;
59 	u8  red_off;
60 	u8  green_len;
61 	u8  green_off;
62 	u8  blue_len;
63 	u8  blue_off;
64 	u8  rsvd_len;
65 	u8  rsvd_off;
66 	u8  direct_color_info;	/* direct color mode attributes */
67 
68 	/* for VBE 2.0+ */
69 	u32 phys_base_ptr;
70 	u8  reserved2[6];
71 
72 	/* for VBE 3.0+ */
73 	u16 lin_bytes_per_scan_line;
74 	u8  bnk_image_pages;
75 	u8  lin_image_pages;
76 	u8  lin_red_len;
77 	u8  lin_red_off;
78 	u8  lin_green_len;
79 	u8  lin_green_off;
80 	u8  lin_blue_len;
81 	u8  lin_blue_off;
82 	u8  lin_rsvd_len;
83 	u8  lin_rsvd_off;
84 	u32 max_pixel_clock;
85 	u16 mode_id;
86 	u8  depth;
87 } __attribute__ ((packed));
88 
89 #define UVESAFB_DEFAULT_MODE "640x480-16"
90 
91 /* How long to wait for a reply from userspace [ms] */
92 #define UVESAFB_TIMEOUT 5000
93 
94 /* Max number of concurrent tasks */
95 #define UVESAFB_TASKS_MAX 16
96 
97 #define dac_reg	(0x3c8)
98 #define dac_val	(0x3c9)
99 
100 struct uvesafb_pal_entry {
101 	u_char blue, green, red, pad;
102 } __attribute__ ((packed));
103 
104 struct uvesafb_ktask {
105 	struct uvesafb_task t;
106 	void *buf;
107 	struct completion *done;
108 	u32 ack;
109 };
110 
111 static int uvesafb_exec(struct uvesafb_ktask *tsk);
112 
113 #define UVESAFB_EXACT_RES	1
114 #define UVESAFB_EXACT_DEPTH	2
115 
116 struct uvesafb_par {
117 	struct vbe_ib vbe_ib;		/* VBE Info Block */
118 	struct vbe_mode_ib *vbe_modes;	/* list of supported VBE modes */
119 	int vbe_modes_cnt;
120 
121 	u8 nocrtc;
122 	u8 ypan;			/* 0 - nothing, 1 - ypan, 2 - ywrap */
123 	u8 pmi_setpal;			/* PMI for palette changes */
124 	u16 *pmi_base;			/* protected mode interface location */
125 	void *pmi_start;
126 	void *pmi_pal;
127 	u8 *vbe_state_orig;		/*
128 					 * original hardware state, before the
129 					 * driver was loaded
130 					 */
131 	u8 *vbe_state_saved;		/* state saved by fb_save_state */
132 	int vbe_state_size;
133 	atomic_t ref_count;
134 
135 	int mode_idx;
136 	struct vbe_crtc_ib crtc;
137 	int mtrr_handle;
138 };
139 
140 #endif /* _UVESAFB_H */
141