1
2
3
4
5
6
7
8
9
10
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/tty.h>
17#include <linux/slab.h>
18#include <linux/delay.h>
19#include <linux/fb.h>
20#include <linux/init.h>
21
22#include <video/fbcon.h>
23
24
25
26
27
28
29
30
31
32
33struct xxxfb_info {
34
35
36
37
38
39 struct fb_info_gen gen;
40
41
42
43 struct fb_info info;
44
45
46
47
48};
49
50
51struct xxxfb_par {
52
53
54
55
56
57
58};
59
60
61
62
63
64
65
66static struct xxxfb_info fb_info;
67static struct xxxfb_par current_par;
68static int current_par_valid = 0;
69static struct display disp;
70
71static struct fb_var_screeninfo default_var;
72
73static int currcon = 0;
74static int inverse = 0;
75
76int xxxfb_init(void);
77int xxxfb_setup(char*);
78
79
80
81
82static void xxx_detect(void)
83{
84
85
86
87
88
89 struct xxxfb_par par;
90
91
92 xxx_get_par(&par);
93 xxx_encode_var(&default_var, &par);
94}
95
96static int xxx_encode_fix(struct fb_fix_screeninfo *fix, struct xxxfb_par *par,
97 const struct fb_info *info)
98{
99
100
101
102
103
104
105 return 0;
106}
107
108static int xxx_decode_var(struct fb_var_screeninfo *var, struct xxxfb_par *par,
109 const struct fb_info *info)
110{
111
112
113
114
115
116
117
118
119
120
121
122
123 if (!fbmon_valid_timings(pixclock, htotal, vtotal, info))
124 return -EINVAL;
125
126 return 0;
127}
128
129static int xxx_encode_var(struct fb_var_screeninfo *var, struct xxxfb_par *par,
130 const struct fb_info *info)
131{
132
133
134
135
136
137
138 return 0;
139}
140
141static void xxx_get_par(struct xxxfb_par *par, const struct fb_info *info)
142{
143
144
145
146
147 if (current_par_valid)
148 *par = current_par;
149 else {
150
151 }
152}
153
154static void xxx_set_par(struct xxxfb_par *par, const struct fb_info *info)
155{
156
157
158
159
160 current_par = *par;
161 current_par_valid = 1;
162
163}
164
165static int xxx_getcolreg(unsigned regno, unsigned *red, unsigned *green,
166 unsigned *blue, unsigned *transp,
167 const struct fb_info *info)
168{
169
170
171
172
173
174
175
176 return 0;
177}
178
179static int xxx_setcolreg(unsigned regno, unsigned red, unsigned green,
180 unsigned blue, unsigned transp,
181 const struct fb_info *info)
182{
183
184
185
186
187
188
189 if (regno < 16) {
190
191
192
193 if (is_cfb15)
194 ...fbcon_cmap.cfb16[regno] = ((red & 0xf800) >> 1) |
195 ((green & 0xf800) >> 6) |
196 ((blue & 0xf800) >> 11);
197 if (is_cfb16)
198 ...fbcon_cmap.cfb16[regno] = (red & 0xf800) |
199 ((green & 0xfc00) >> 5) |
200 ((blue & 0xf800) >> 11);
201 if (is_cfb24)
202 ...fbcon_cmap.cfb24[regno] = ((red & 0xff00) << 8) |
203 (green & 0xff00) |
204 ((blue & 0xff00) >> 8);
205 if (is_cfb32)
206 ...fbcon_cmap.cfb32[regno] = ((red & 0xff00) << 16) |
207 ((green & 0xff00) << 8) |
208 (blue & 0xff00) |
209 ((transp & 0xff00) >> 8);
210 }
211
212 return 0;
213}
214
215static int xxx_pan_display(struct fb_var_screeninfo *var,
216 struct xxxfb_par *par, const struct fb_info *info)
217{
218
219
220
221
222
223
224
225 return 0;
226}
227
228static int xxx_blank(int blank_mode, const struct fb_info *info)
229{
230
231
232
233
234
235
236
237
238
239
240
241
242 return 0;
243}
244
245static void xxx_set_disp(const void *par, struct display *disp,
246 struct fb_info_gen *info)
247{
248
249
250
251
252
253
254
255
256
257 disp->screen_base = virtual_frame_buffer_address;
258#ifdef FBCON_HAS_CFB8
259 if (is_cfb8) {
260 disp->dispsw = fbcon_cfb8;
261 } else
262#endif
263#ifdef FBCON_HAS_CFB16
264 if (is_cfb16) {
265 disp->dispsw = fbcon_cfb16;
266 disp->dispsw_data = ...fbcon_cmap.cfb16;
267 } else
268#endif
269#ifdef FBCON_HAS_CFB24
270 if (is_cfb24) {
271 disp->dispsw = fbcon_cfb24;
272 disp->dispsw_data = ...fbcon_cmap.cfb24;
273 } else
274#endif
275#ifdef FBCON_HAS_CFB32
276 if (is_cfb32) {
277 disp->dispsw = fbcon_cfb32;
278 disp->dispsw_data = ...fbcon_cmap.cfb32;
279 } else
280#endif
281 disp->dispsw = &fbcon_dummy;
282}
283
284
285
286
287
288struct fbgen_hwswitch xxx_switch = {
289 xxx_detect, xxx_encode_fix, xxx_decode_var, xxx_encode_var, xxx_get_par,
290 xxx_set_par, xxx_getcolreg, xxx_setcolreg, xxx_pan_display, xxx_blank,
291 xxx_set_disp
292};
293
294
295
296
297
298
299
300
301
302
303int __init xxxfb_init(void)
304{
305 fb_info.gen.fbhw = &xxx_switch;
306 fb_info.gen.fbhw->detect();
307 strcpy(fb_info.gen.info.modename, "XXX");
308 fb_info.gen.info.changevar = NULL;
309 fb_info.gen.info.node = -1;
310 fb_info.gen.info.fbops = &xxxfb_ops;
311 fb_info.gen.info.disp = &disp;
312 fb_info.gen.info.switch_con = &xxxfb_switch;
313 fb_info.gen.info.updatevar = &xxxfb_update_var;
314 fb_info.gen.info.blank = &xxxfb_blank;
315 fb_info.gen.info.flags = FBINFO_FLAG_DEFAULT;
316
317 fbgen_get_var(&disp.var, -1, &fb_info.gen.info);
318 fbgen_do_set_var(&disp.var, 1, &fb_info.gen);
319 fbgen_set_disp(-1, &fb_info.gen);
320 fbgen_install_cmap(0, &fb_info.gen);
321 if (register_framebuffer(&fb_info.gen.info) < 0)
322 return -EINVAL;
323 printk(KERN_INFO "fb%d: %s frame buffer device\n", GET_FB_IDX(fb_info.gen.info.node),
324 fb_info.gen.info.modename);
325
326
327
328 return 0;
329}
330
331
332
333
334
335
336void xxxfb_cleanup(struct fb_info *info)
337{
338
339
340
341
342
343 unregister_framebuffer(info);
344
345}
346
347
348
349
350
351
352int __init xxxfb_setup(char *options)
353{
354
355}
356
357
358
359
360
361
362
363
364
365
366static int xxxfb_open(const struct fb_info *info, int user)
367{
368 return 0;
369}
370
371
372static int xxxfb_release(const struct fb_info *info, int user)
373{
374 return 0;
375}
376
377
378
379
380
381
382
383static struct fb_ops xxxfb_ops = {
384 owner: THIS_MODULE,
385 fb_open: xxxfb_open,
386 fb_release: xxxfb_release,
387 fb_get_fix: fbgen_get_fix,
388 fb_get_var: fbgen_get_var,
389 fb_set_var: fbgen_set_var,
390 fb_get_cmap: fbgen_get_cmap,
391 fb_set_cmap: fbgen_set_cmap,
392 fb_pan_display: fbgen_pan_display,
393 fb_ioctl: xxxfb_ioctl,
394};
395
396
397
398
399
400
401
402
403
404#ifdef MODULE
405MODULE_LICENSE("GPL");
406int init_module(void)
407{
408 return xxxfb_init();
409}
410
411void cleanup_module(void)
412{
413 xxxfb_cleanup(void);
414}
415#endif
416