-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathkernel-fbcondecor.patch
More file actions
1839 lines (1788 loc) · 54.9 KB
/
kernel-fbcondecor.patch
File metadata and controls
1839 lines (1788 loc) · 54.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -Naurp -x .git /tmp/linux/Documentation/fb/00-INDEX ./Documentation/fb/00-INDEX
--- /tmp/linux/Documentation/fb/00-INDEX 2008-03-25 07:24:16.000000000 +0100
+++ ./Documentation/fb/00-INDEX 2008-03-25 23:04:10.000000000 +0100
@@ -17,6 +17,8 @@ deferred_io.txt
- an introduction to deferred IO.
fbcon.txt
- intro to and usage guide for the framebuffer console (fbcon).
+fbcondecor.txt
+ - info on the Framebuffer Console Decoration
framebuffer.txt
- introduction to frame buffer devices.
imacfb.txt
diff -Naurp -x .git /tmp/linux/Documentation/fb/fbcondecor.txt ./Documentation/fb/fbcondecor.txt
--- /tmp/linux/Documentation/fb/fbcondecor.txt 1970-01-01 01:00:00.000000000 +0100
+++ ./Documentation/fb/fbcondecor.txt 2008-03-25 23:04:10.000000000 +0100
@@ -0,0 +1,207 @@
+What is it?
+-----------
+
+The framebuffer decorations are a kernel feature which allows displaying a
+background picture on selected consoles.
+
+What do I need to get it to work?
+---------------------------------
+
+To get fbcondecor up-and-running you will have to:
+ 1) get a copy of splashutils [1] or a similar program
+ 2) get some fbcondecor themes
+ 3) build the kernel helper program
+ 4) build your kernel with the FB_CON_DECOR option enabled.
+
+To get fbcondecor operational right after fbcon initialization is finished, you
+will have to include a theme and the kernel helper into your initramfs image.
+Please refer to splashutils documentation for instructions on how to do that.
+
+[1] The splashutils package can be downloaded from:
+ http://dev.gentoo.org/~spock/projects/splashutils/
+
+The userspace helper
+--------------------
+
+The userspace fbcondecor helper (by default: /sbin/fbcondecor_helper) is called by the
+kernel whenever an important event occurs and the kernel needs some kind of
+job to be carried out. Important events include console switches and video
+mode switches (the kernel requests background images and configuration
+parameters for the current console). The fbcondecor helper must be accessible at
+all times. If it's not, fbcondecor will be switched off automatically.
+
+It's possible to set path to the fbcondecor helper by writing it to
+/proc/sys/kernel/fbcondecor.
+
+*****************************************************************************
+
+The information below is mostly technical stuff. There's probably no need to
+read it unless you plan to develop a userspace helper.
+
+The fbcondecor protocol
+-----------------------
+
+The fbcondecor protocol defines a communication interface between the kernel and
+the userspace fbcondecor helper.
+
+The kernel side is responsible for:
+
+ * rendering console text, using an image as a background (instead of a
+ standard solid color fbcon uses),
+ * accepting commands from the user via ioctls on the fbcondecor device,
+ * calling the userspace helper to set things up as soon as the fb subsystem
+ is initialized.
+
+The userspace helper is responsible for everything else, including parsing
+configuration files, decompressing the image files whenever the kernel needs
+it, and communicating with the kernel if necessary.
+
+The fbcondecor protocol specifies how communication is done in both ways:
+kernel->userspace and userspace->helper.
+
+Kernel -> Userspace
+-------------------
+
+The kernel communicates with the userspace helper by calling it and specifying
+the task to be done in a series of arguments.
+
+The arguments follow the pattern:
+<fbcondecor protocol version> <command> <parameters>
+
+All commands defined in fbcondecor protocol v2 have the following parameters:
+ virtual console
+ framebuffer number
+ theme
+
+Fbcondecor protocol v1 specified an additional 'fbcondecor mode' after the
+framebuffer number. Fbcondecor protocol v1 is deprecated and should not be used.
+
+Fbcondecor protocol v2 specifies the following commands:
+
+getpic
+------
+ The kernel issues this command to request image data. It's up to the
+ userspace helper to find a background image appropriate for the specified
+ theme and the current resolution. The userspace helper should respond by
+ issuing the FBIOCONDECOR_SETPIC ioctl.
+
+init
+----
+ The kernel issues this command after the fbcondecor device is created and
+ the fbcondecor interface is initialized. Upon receiving 'init', the userspace
+ helper should parse the kernel command line (/proc/cmdline) or otherwise
+ decide whether fbcondecor is to be activated.
+
+ To activate fbcondecor on the first console the helper should issue the
+ FBIOCONDECOR_SETCFG, FBIOCONDECOR_SETPIC and FBIOCONDECOR_SETSTATE commands,
+ in the above-mentioned order.
+
+ When the userspace helper is called in an early phase of the boot process
+ (right after the initialization of fbcon), no filesystems will be mounted.
+ The helper program should mount sysfs and then create the appropriate
+ framebuffer, fbcondecor and tty0 devices (if they don't already exist) to get
+ current display settings and to be able to communicate with the kernel side.
+ It should probably also mount the procfs to be able to parse the kernel
+ command line parameters.
+
+ Note that the console sem is not held when the kernel calls fbcondecor_helper
+ with the 'init' command. The fbcondecor helper should perform all ioctls with
+ origin set to FBCON_DECOR_IO_ORIG_USER.
+
+modechange
+----------
+ The kernel issues this command on a mode change. The helper's response should
+ be similar to the response to the 'init' command. Note that this time the
+ console sem is held and all ioctls must be performed with origin set to
+ FBCON_DECOR_IO_ORIG_KERNEL.
+
+
+Userspace -> Kernel
+-------------------
+
+Userspace programs can communicate with fbcondecor via ioctls on the
+fbcondecor device. These ioctls are to be used by both the userspace helper
+(called only by the kernel) and userspace configuration tools (run by the users).
+
+The fbcondecor helper should set the origin field to FBCON_DECOR_IO_ORIG_KERNEL
+when doing the appropriate ioctls. All userspace configuration tools should
+use FBCON_DECOR_IO_ORIG_USER. Failure to set the appropriate value in the origin
+field when performing ioctls from the kernel helper will most likely result
+in a console deadlock.
+
+FBCON_DECOR_IO_ORIG_KERNEL instructs fbcondecor not to try to acquire the console
+semaphore. Not surprisingly, FBCON_DECOR_IO_ORIG_USER instructs it to acquire
+the console sem.
+
+The framebuffer console decoration provides the following ioctls (all defined in
+linux/fb.h):
+
+FBIOCONDECOR_SETPIC
+description: loads a background picture for a virtual console
+argument: struct fbcon_decor_iowrapper*; data: struct fb_image*
+notes:
+If called for consoles other than the current foreground one, the picture data
+will be ignored.
+
+If the current virtual console is running in a 8-bpp mode, the cmap substruct
+of fb_image has to be filled appropriately: start should be set to 16 (first
+16 colors are reserved for fbcon), len to a value <= 240 and red, green and
+blue should point to valid cmap data. The transp field is ingored. The fields
+dx, dy, bg_color, fg_color in fb_image are ignored as well.
+
+FBIOCONDECOR_SETCFG
+description: sets the fbcondecor config for a virtual console
+argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
+notes: The structure has to be filled with valid data.
+
+FBIOCONDECOR_GETCFG
+description: gets the fbcondecor config for a virtual console
+argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
+
+FBIOCONDECOR_SETSTATE
+description: sets the fbcondecor state for a virtual console
+argument: struct fbcon_decor_iowrapper*; data: unsigned int*
+ values: 0 = disabled, 1 = enabled.
+
+FBIOCONDECOR_GETSTATE
+description: gets the fbcondecor state for a virtual console
+argument: struct fbcon_decor_iowrapper*; data: unsigned int*
+ values: as in FBIOCONDECOR_SETSTATE
+
+Info on used structures:
+
+Definition of struct vc_decor can be found in linux/console_decor.h. It's
+heavily commented. Note that the 'theme' field should point to a string
+no longer than FBCON_DECOR_THEME_LEN. When FBIOCONDECOR_GETCFG call is
+performed, the theme field should point to a char buffer of length
+FBCON_DECOR_THEME_LEN.
+
+Definition of struct fbcon_decor_iowrapper can be found in linux/fb.h.
+The fields in this struct have the following meaning:
+
+vc:
+Virtual console number.
+
+origin:
+Specifies if the ioctl is performed as a response to a kernel request. The
+fbcondecor helper should set this field to FBCON_DECOR_IO_ORIG_KERNEL, userspace
+programs should set it to FBCON_DECOR_IO_ORIG_USER. This field is necessary to
+avoid console semaphore deadlocks.
+
+data:
+Pointer to a data structure appropriate for the performed ioctl. Type of
+the data struct is specified in the ioctls description.
+
+*****************************************************************************
+
+Credit
+------
+
+Original 'bootsplash' project & implementation by:
+ Volker Poplawski <volker@poplawski.de>, Stefan Reinauer <stepan@suse.de>,
+ Steffen Winterfeldt <snwint@suse.de>, Michael Schroeder <mls@suse.de>,
+ Ken Wimer <wimer@suse.de>.
+
+Fbcondecor, fbcondecor protocol design, current implementation & docs by:
+ Michal Januszewski <spock@gentoo.org>
+
diff -Naurp -x .git /tmp/linux/drivers/Makefile ./drivers/Makefile
--- /tmp/linux/drivers/Makefile 2008-03-25 07:24:16.000000000 +0100
+++ ./drivers/Makefile 2008-03-25 23:04:10.000000000 +0100
@@ -9,6 +9,9 @@ obj-$(CONFIG_HAVE_GPIO_LIB) += gpio/
obj-$(CONFIG_PCI) += pci/
obj-$(CONFIG_PARISC) += parisc/
obj-$(CONFIG_RAPIDIO) += rapidio/
+# char/ comes before serial/ etc so that the VT console is the boot-time
+# default.
+obj-y += char/
obj-y += video/
obj-$(CONFIG_ACPI) += acpi/
# PnP must come after ACPI since it will eventually need to check if acpi
@@ -18,10 +21,6 @@ obj-$(CONFIG_ARM_AMBA) += amba/
obj-$(CONFIG_XEN) += xen/
-# char/ comes before serial/ etc so that the VT console is the boot-time
-# default.
-obj-y += char/
-
obj-$(CONFIG_CONNECTOR) += connector/
# i810fb and intelfb depend on char/agp/
diff -Naurp -x .git /tmp/linux/drivers/video/console/bitblit.c ./drivers/video/console/bitblit.c
--- /tmp/linux/drivers/video/console/bitblit.c 2008-03-25 07:24:16.000000000 +0100
+++ ./drivers/video/console/bitblit.c 2008-03-25 23:04:10.000000000 +0100
@@ -17,6 +17,7 @@
#include <linux/console.h>
#include <asm/types.h>
#include "fbcon.h"
+#include "fbcondecor.h"
/*
* Accelerated handlers.
@@ -54,6 +55,13 @@ static void bit_bmove(struct vc_data *vc
area.height = height * vc->vc_font.height;
area.width = width * vc->vc_font.width;
+ if (fbcon_decor_active(info, vc)) {
+ area.sx += vc->vc_decor.tx;
+ area.sy += vc->vc_decor.ty;
+ area.dx += vc->vc_decor.tx;
+ area.dy += vc->vc_decor.ty;
+ }
+
info->fbops->fb_copyarea(info, &area);
}
@@ -379,11 +387,15 @@ static void bit_cursor(struct vc_data *v
cursor.image.depth = 1;
cursor.rop = ROP_XOR;
- if (info->fbops->fb_cursor)
- err = info->fbops->fb_cursor(info, &cursor);
+ if (fbcon_decor_active(info, vc)) {
+ fbcon_decor_cursor(info, &cursor);
+ } else {
+ if (info->fbops->fb_cursor)
+ err = info->fbops->fb_cursor(info, &cursor);
- if (err)
- soft_cursor(info, &cursor);
+ if (err)
+ soft_cursor(info, &cursor);
+ }
ops->cursor_reset = 0;
}
diff -Naurp -x .git /tmp/linux/drivers/video/console/cfbcondecor.c ./drivers/video/console/cfbcondecor.c
--- /tmp/linux/drivers/video/console/cfbcondecor.c 1970-01-01 01:00:00.000000000 +0100
+++ ./drivers/video/console/cfbcondecor.c 2008-03-25 23:11:30.000000000 +0100
@@ -0,0 +1,471 @@
+/*
+ * linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
+ *
+ * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
+ *
+ * Code based upon "Bootdecor" (C) 2001-2003
+ * Volker Poplawski <volker@poplawski.de>,
+ * Stefan Reinauer <stepan@suse.de>,
+ * Steffen Winterfeldt <snwint@suse.de>,
+ * Michael Schroeder <mls@suse.de>,
+ * Ken Wimer <wimer@suse.de>.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive for
+ * more details.
+ */
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/fb.h>
+#include <linux/selection.h>
+#include <linux/vt_kern.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+
+#include "fbcon.h"
+#include "fbcondecor.h"
+
+#define parse_pixel(shift,bpp,type) \
+ do { \
+ if (d & (0x80 >> (shift))) \
+ dd2[(shift)] = fgx; \
+ else \
+ dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
+ decor_src += (bpp); \
+ } while (0) \
+
+extern int get_color(struct vc_data *vc, struct fb_info *info,
+ u16 c, int is_fg);
+
+void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
+{
+ int i, j, k;
+ int minlen = min(min(info->var.red.length, info->var.green.length),
+ info->var.blue.length);
+ u32 col;
+
+ for (j = i = 0; i < 16; i++) {
+ k = color_table[i];
+
+ col = ((vc->vc_palette[j++] >> (8-minlen))
+ << info->var.red.offset);
+ col |= ((vc->vc_palette[j++] >> (8-minlen))
+ << info->var.green.offset);
+ col |= ((vc->vc_palette[j++] >> (8-minlen))
+ << info->var.blue.offset);
+ ((u32 *)info->pseudo_palette)[k] = col;
+ }
+}
+
+void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
+ int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
+{
+ unsigned int x, y;
+ u32 dd;
+ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
+ unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
+ unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
+ u16 dd2[4];
+
+ u8* decor_src = (u8 *)(info->bgdecor.data + ds);
+ u8* dst = (u8 *)(info->screen_base + d);
+
+ if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
+ return;
+
+ for (y = 0; y < height; y++) {
+ switch (info->var.bits_per_pixel) {
+
+ case 32:
+ for (x = 0; x < width; x++) {
+
+ if ((x & 7) == 0)
+ d = *src++;
+ if (d & 0x80)
+ dd = fgx;
+ else
+ dd = transparent ?
+ *(u32 *)decor_src : bgx;
+
+ d <<= 1;
+ decor_src += 4;
+ fb_writel(dd, dst);
+ dst += 4;
+ }
+ break;
+ case 24:
+ for (x = 0; x < width; x++) {
+
+ if ((x & 7) == 0)
+ d = *src++;
+ if (d & 0x80)
+ dd = fgx;
+ else
+ dd = transparent ?
+ (*(u32 *)decor_src & 0xffffff) : bgx;
+
+ d <<= 1;
+ decor_src += 3;
+#ifdef __LITTLE_ENDIAN
+ fb_writew(dd & 0xffff, dst);
+ dst += 2;
+ fb_writeb((dd >> 16), dst);
+#else
+ fb_writew(dd >> 8, dst);
+ dst += 2;
+ fb_writeb(dd & 0xff, dst);
+#endif
+ dst++;
+ }
+ break;
+ case 16:
+ for (x = 0; x < width; x += 2) {
+ if ((x & 7) == 0)
+ d = *src++;
+
+ parse_pixel(0, 2, u16);
+ parse_pixel(1, 2, u16);
+#ifdef __LITTLE_ENDIAN
+ dd = dd2[0] | (dd2[1] << 16);
+#else
+ dd = dd2[1] | (dd2[0] << 16);
+#endif
+ d <<= 2;
+ fb_writel(dd, dst);
+ dst += 4;
+ }
+ break;
+
+ case 8:
+ for (x = 0; x < width; x += 4) {
+ if ((x & 7) == 0)
+ d = *src++;
+
+ parse_pixel(0, 1, u8);
+ parse_pixel(1, 1, u8);
+ parse_pixel(2, 1, u8);
+ parse_pixel(3, 1, u8);
+
+#ifdef __LITTLE_ENDIAN
+ dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
+#else
+ dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
+#endif
+ d <<= 4;
+ fb_writel(dd, dst);
+ dst += 4;
+ }
+ }
+
+ dst += info->fix.line_length - width * bytespp;
+ decor_src += (info->var.xres - width) * bytespp;
+ }
+}
+
+#define cc2cx(a) \
+ ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
+ info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
+ ((u32*)info->pseudo_palette)[a] : a)
+
+void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
+ const unsigned short *s, int count, int yy, int xx)
+{
+ unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
+ struct fbcon_ops *ops = info->fbcon_par;
+ int fg_color, bg_color, transparent;
+ u8 *src;
+ u32 bgx, fgx;
+ u16 c = scr_readw(s);
+
+ fg_color = get_color(vc, info, c, 1);
+ bg_color = get_color(vc, info, c, 0);
+
+ /* Don't paint the background image if console is blanked */
+ transparent = ops->blank_state ? 0 :
+ (vc->vc_decor.bg_color == bg_color);
+
+ xx = xx * vc->vc_font.width + vc->vc_decor.tx;
+ yy = yy * vc->vc_font.height + vc->vc_decor.ty;
+
+ fgx = cc2cx(fg_color);
+ bgx = cc2cx(bg_color);
+
+ while (count--) {
+ c = scr_readw(s++);
+ src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
+ ((vc->vc_font.width + 7) >> 3);
+
+ fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
+ vc->vc_font.width, src, fgx, bgx, transparent);
+ xx += vc->vc_font.width;
+ }
+}
+
+void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
+{
+ int i;
+ unsigned int dsize, s_pitch;
+ struct fbcon_ops *ops = info->fbcon_par;
+ struct vc_data* vc;
+ u8 *src;
+
+ /* we really don't need any cursors while the console is blanked */
+ if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
+ return;
+
+ vc = vc_cons[ops->currcon].d;
+
+ src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
+ if (!src)
+ return;
+
+ s_pitch = (cursor->image.width + 7) >> 3;
+ dsize = s_pitch * cursor->image.height;
+ if (cursor->enable) {
+ switch (cursor->rop) {
+ case ROP_XOR:
+ for (i = 0; i < dsize; i++)
+ src[i] = cursor->image.data[i] ^ cursor->mask[i];
+ break;
+ case ROP_COPY:
+ default:
+ for (i = 0; i < dsize; i++)
+ src[i] = cursor->image.data[i] & cursor->mask[i];
+ break;
+ }
+ } else
+ memcpy(src, cursor->image.data, dsize);
+
+ fbcon_decor_renderc(info,
+ cursor->image.dy + vc->vc_decor.ty,
+ cursor->image.dx + vc->vc_decor.tx,
+ cursor->image.height,
+ cursor->image.width,
+ (u8*)src,
+ cc2cx(cursor->image.fg_color),
+ cc2cx(cursor->image.bg_color),
+ cursor->image.bg_color == vc->vc_decor.bg_color);
+
+ kfree(src);
+}
+
+static void decorset(u8 *dst, int height, int width, int dstbytes,
+ u32 bgx, int bpp)
+{
+ int i;
+
+ if (bpp == 8)
+ bgx |= bgx << 8;
+ if (bpp == 16 || bpp == 8)
+ bgx |= bgx << 16;
+
+ while (height-- > 0) {
+ u8 *p = dst;
+
+ switch (bpp) {
+
+ case 32:
+ for (i=0; i < width; i++) {
+ fb_writel(bgx, p); p += 4;
+ }
+ break;
+ case 24:
+ for (i=0; i < width; i++) {
+#ifdef __LITTLE_ENDIAN
+ fb_writew((bgx & 0xffff),(u16*)p); p += 2;
+ fb_writeb((bgx >> 16),p++);
+#else
+ fb_writew((bgx >> 8),(u16*)p); p += 2;
+ fb_writeb((bgx & 0xff),p++);
+#endif
+ }
+ case 16:
+ for (i=0; i < width/4; i++) {
+ fb_writel(bgx,p); p += 4;
+ fb_writel(bgx,p); p += 4;
+ }
+ if (width & 2) {
+ fb_writel(bgx,p); p += 4;
+ }
+ if (width & 1)
+ fb_writew(bgx,(u16*)p);
+ break;
+ case 8:
+ for (i=0; i < width/4; i++) {
+ fb_writel(bgx,p); p += 4;
+ }
+
+ if (width & 2) {
+ fb_writew(bgx,p); p += 2;
+ }
+ if (width & 1)
+ fb_writeb(bgx,(u8*)p);
+ break;
+
+ }
+ dst += dstbytes;
+ }
+}
+
+void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
+ int srclinebytes, int bpp)
+{
+ int i;
+
+ while (height-- > 0) {
+ u32 *p = (u32 *)dst;
+ u32 *q = (u32 *)src;
+
+ switch (bpp) {
+
+ case 32:
+ for (i=0; i < width; i++)
+ fb_writel(*q++, p++);
+ break;
+ case 24:
+ for (i=0; i < (width*3/4); i++)
+ fb_writel(*q++, p++);
+ if ((width*3) % 4) {
+ if (width & 2) {
+ fb_writeb(*(u8*)q, (u8*)p);
+ } else if (width & 1) {
+ fb_writew(*(u16*)q, (u16*)p);
+ fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
+ }
+ }
+ break;
+ case 16:
+ for (i=0; i < width/4; i++) {
+ fb_writel(*q++, p++);
+ fb_writel(*q++, p++);
+ }
+ if (width & 2)
+ fb_writel(*q++, p++);
+ if (width & 1)
+ fb_writew(*(u16*)q, (u16*)p);
+ break;
+ case 8:
+ for (i=0; i < width/4; i++)
+ fb_writel(*q++, p++);
+
+ if (width & 2) {
+ fb_writew(*(u16*)q, (u16*)p);
+ q = (u32*) ((u16*)q + 1);
+ p = (u32*) ((u16*)p + 1);
+ }
+ if (width & 1)
+ fb_writeb(*(u8*)q, (u8*)p);
+ break;
+ }
+
+ dst += linebytes;
+ src += srclinebytes;
+ }
+}
+
+static void decorfill(struct fb_info *info, int sy, int sx, int height,
+ int width)
+{
+ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
+ int d = sy * info->fix.line_length + sx * bytespp;
+ int ds = (sy * info->var.xres + sx) * bytespp;
+
+ fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
+ height, width, info->fix.line_length, info->var.xres * bytespp,
+ info->var.bits_per_pixel);
+}
+
+void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
+ int height, int width)
+{
+ int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
+ struct fbcon_ops *ops = info->fbcon_par;
+ u8 *dst;
+ int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
+
+ transparent = (vc->vc_decor.bg_color == bg_color);
+ sy = sy * vc->vc_font.height + vc->vc_decor.ty;
+ sx = sx * vc->vc_font.width + vc->vc_decor.tx;
+ height *= vc->vc_font.height;
+ width *= vc->vc_font.width;
+
+ /* Don't paint the background image if console is blanked */
+ if (transparent && !ops->blank_state) {
+ decorfill(info, sy, sx, height, width);
+ } else {
+ dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
+ sx * ((info->var.bits_per_pixel + 7) >> 3));
+ decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
+ info->var.bits_per_pixel);
+ }
+}
+
+void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
+ int bottom_only)
+{
+ unsigned int tw = vc->vc_cols*vc->vc_font.width;
+ unsigned int th = vc->vc_rows*vc->vc_font.height;
+
+ if (!bottom_only) {
+ /* top margin */
+ decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
+ /* left margin */
+ decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
+ /* right margin */
+ decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
+ info->var.xres - vc->vc_decor.tx - tw);
+ }
+ decorfill(info, vc->vc_decor.ty + th, 0,
+ info->var.yres - vc->vc_decor.ty - th, info->var.xres);
+}
+
+void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
+ int sx, int dx, int width)
+{
+ u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
+ u16 *s = d + (dx - sx);
+ u16 *start = d;
+ u16 *ls = d;
+ u16 *le = d + width;
+ u16 c;
+ int x = dx;
+ u16 attr = 1;
+
+ do {
+ c = scr_readw(d);
+ if (attr != (c & 0xff00)) {
+ attr = c & 0xff00;
+ if (d > start) {
+ fbcon_decor_putcs(vc, info, start, d - start, y, x);
+ x += d - start;
+ start = d;
+ }
+ }
+ if (s >= ls && s < le && c == scr_readw(s)) {
+ if (d > start) {
+ fbcon_decor_putcs(vc, info, start, d - start, y, x);
+ x += d - start + 1;
+ start = d + 1;
+ } else {
+ x++;
+ start++;
+ }
+ }
+ s++;
+ d++;
+ } while (d < le);
+ if (d > start)
+ fbcon_decor_putcs(vc, info, start, d - start, y, x);
+}
+
+void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
+{
+ if (blank) {
+ decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
+ info->fix.line_length, 0, info->var.bits_per_pixel);
+ } else {
+ update_screen(vc);
+ fbcon_decor_clear_margins(vc, info, 0);
+ }
+}
+
diff -Naurp -x .git /tmp/linux/drivers/video/console/fbcon.c ./drivers/video/console/fbcon.c
--- /tmp/linux/drivers/video/console/fbcon.c 2008-03-25 07:24:16.000000000 +0100
+++ ./drivers/video/console/fbcon.c 2008-03-25 23:04:10.000000000 +0100
@@ -90,6 +90,7 @@
#endif
#include "fbcon.h"
+#include "fbcondecor.h"
#ifdef FBCONDEBUG
# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
@@ -105,7 +106,7 @@ enum {
static struct display fb_display[MAX_NR_CONSOLES];
-static signed char con2fb_map[MAX_NR_CONSOLES];
+signed char con2fb_map[MAX_NR_CONSOLES];
static signed char con2fb_map_boot[MAX_NR_CONSOLES];
#ifndef MODULE
static int logo_height;
@@ -315,7 +316,7 @@ static inline int fbcon_is_inactive(stru
vc->vc_mode != KD_TEXT || ops->graphics);
}
-static inline int get_color(struct vc_data *vc, struct fb_info *info,
+inline int get_color(struct vc_data *vc, struct fb_info *info,
u16 c, int is_fg)
{
int depth = fb_get_color_depth(&info->var, &info->fix);
@@ -420,6 +421,7 @@ static void fb_flashcursor(struct work_s
CM_ERASE : CM_DRAW;
ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
get_color(vc, info, c, 0));
+
release_console_sem();
}
@@ -590,6 +592,8 @@ static int fbcon_takeover(int show_logo)
info_idx = -1;
}
+ fbcon_decor_init();
+
return err;
}
@@ -1031,6 +1035,12 @@ static const char *fbcon_startup(void)
rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
cols /= vc->vc_font.width;
rows /= vc->vc_font.height;
+
+ if (fbcon_decor_active(info, vc)) {
+ cols = vc->vc_decor.twidth / vc->vc_font.width;
+ rows = vc->vc_decor.theight / vc->vc_font.height;
+ }
+
vc_resize(vc, cols, rows);
DPRINTK("mode: %s\n", info->fix.id);
@@ -1114,7 +1124,7 @@ static void fbcon_init(struct vc_data *v
cap = info->flags;
if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
- (info->fix.type == FB_TYPE_TEXT))
+ (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
logo = 0;
if (var_to_display(p, &info->var, info))
@@ -1313,6 +1323,11 @@ static void fbcon_clear(struct vc_data *
if (!height || !width)
return;
+ if (fbcon_decor_active(info, vc)) {
+ fbcon_decor_clear(vc, info, sy, sx, height, width);
+ return;
+ }
+
/* Split blits that cross physical y_wrap boundary */
y_break = p->vrows - p->yscroll;
@@ -1332,10 +1347,15 @@ static void fbcon_putcs(struct vc_data *
struct display *p = &fb_display[vc->vc_num];
struct fbcon_ops *ops = info->fbcon_par;
- if (!fbcon_is_inactive(vc, info))
- ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
- get_color(vc, info, scr_readw(s), 1),
- get_color(vc, info, scr_readw(s), 0));
+ if (!fbcon_is_inactive(vc, info)) {
+
+ if (fbcon_decor_active(info, vc))
+ fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
+ else
+ ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
+ get_color(vc, info, scr_readw(s), 1),
+ get_color(vc, info, scr_readw(s), 0));
+ }
}
static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
@@ -1351,8 +1371,13 @@ static void fbcon_clear_margins(struct v
struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
struct fbcon_ops *ops = info->fbcon_par;
- if (!fbcon_is_inactive(vc, info))
- ops->clear_margins(vc, info, bottom_only);
+ if (!fbcon_is_inactive(vc, info)) {
+ if (fbcon_decor_active(info, vc)) {
+ fbcon_decor_clear_margins(vc, info, bottom_only);
+ } else {
+ ops->clear_margins(vc, info, bottom_only);
+ }
+ }
}
static void fbcon_cursor(struct vc_data *vc, int mode)
@@ -1872,7 +1897,7 @@ static int fbcon_scroll(struct vc_data *
count = vc->vc_rows;
if (softback_top)
fbcon_softback_note(vc, t, count);
- if (logo_shown >= 0)
+ if (logo_shown >= 0 || fbcon_decor_active(info, vc))
goto redraw_up;
switch (p->scrollmode) {
case SCROLL_MOVE:
@@ -1965,6 +1990,8 @@ static int fbcon_scroll(struct vc_data *
count = vc->vc_rows;
if (logo_shown >= 0)
goto redraw_down;
+ if (fbcon_decor_active(info, vc))
+ goto redraw_down;
switch (p->scrollmode) {
case SCROLL_MOVE:
fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
@@ -2113,6 +2140,13 @@ static void fbcon_bmove_rec(struct vc_da
}
return;
}
+
+ if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
+ /* must use slower redraw bmove to keep background pic intact */
+ fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
+ return;
+ }
+
ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
height, width);
}
@@ -2183,8 +2217,8 @@ static int fbcon_resize(struct vc_data *
var.yres = virt_h * virt_fh;
x_diff = info->var.xres - var.xres;
y_diff = info->var.yres - var.yres;
- if (x_diff < 0 || x_diff > virt_fw ||
- y_diff < 0 || y_diff > virt_fh) {
+ if ((x_diff < 0 || x_diff > virt_fw ||
+ y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
const struct fb_videomode *mode;
DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
@@ -2220,6 +2254,19 @@ static int fbcon_switch(struct vc_data *
info = registered_fb[con2fb_map[vc->vc_num]];
ops = info->fbcon_par;
+ prev_console = ops->currcon;
+ if (prev_console != -1)
+ old_info = registered_fb[con2fb_map[prev_console]];
+
+ if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
+ struct vc_data *vc_curr = vc_cons[prev_console].d;
+ if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
+ /* Clear the screen to avoid displaying funky colors during
+ * palette updates. */
+ memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
+ 0, info->var.yres * info->fix.line_length);
+ }
+ }
if (softback_top) {
if (softback_lines)
@@ -2238,9 +2285,6 @@ static int fbcon_switch(struct vc_data *
logo_shown = FBCON_LOGO_CANSHOW;
}
- prev_console = ops->currcon;
- if (prev_console != -1)
- old_info = registered_fb[con2fb_map[prev_console]];
/*
* FIXME: If we have multiple fbdev's loaded, we need to
* update all info->currcon. Perhaps, we can place this
@@ -2280,6 +2324,18 @@ static int fbcon_switch(struct vc_data *
fbcon_del_cursor_timer(old_info);
}
+ if (fbcon_decor_active_vc(vc)) {
+ struct vc_data *vc_curr = vc_cons[prev_console].d;
+
+ if (!vc_curr->vc_decor.theme ||
+ strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
+ (fbcon_decor_active_nores(info, vc_curr) &&
+ !fbcon_decor_active(info, vc_curr))) {
+ if (fbcon_decor_call_helper("modechange", vc->vc_num))
+ fbcon_decor_disable(vc, 0);
+ }
+ }
+
if (fbcon_is_inactive(vc, info) ||
ops->blank_state != FB_BLANK_UNBLANK)
fbcon_del_cursor_timer(info);
@@ -2394,8 +2450,12 @@ static int fbcon_blank(struct vc_data *v
fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
ops->cursor_flash = (!blank);
- if (fb_blank(info, blank))
- fbcon_generic_blank(vc, info, blank);
+ if (fb_blank(info, blank)) {
+ if (fbcon_decor_active(info, vc))
+ fbcon_decor_blank(vc, info, blank);
+ else
+ fbcon_generic_blank(vc, info, blank);
+ }
}
if (!blank)
@@ -2546,13 +2606,22 @@ static int fbcon_do_set_font(struct vc_d
}
if (resize) {
+ /* reset wrap/pan */
int cols, rows;
cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
+