CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/patch/misc/0004-bootsplash.patch
Views: 3959
1
diff --git a/drivers/video/fbdev/core/bootsplash_render.c b/drivers/video/fbdev/core/bootsplash_render.c
2
index 8c09c306ff67..07e3a4eab811 100644
3
--- a/drivers/video/fbdev/core/bootsplash_render.c
4
+++ b/drivers/video/fbdev/core/bootsplash_render.c
5
@@ -155,6 +155,7 @@ void bootsplash_do_render_pictures(struct fb_info *info,
6
for (i = 0; i < fp->header->num_pics; i++) {
7
struct splash_blob_priv *bp;
8
struct splash_pic_priv *pp = &fp->pics[i];
9
+ const struct splash_pic_header *ph = pp->pic_header;
10
long dst_xoff, dst_yoff;
11
12
if (pp->blobs_loaded < 1)
13
@@ -165,8 +166,139 @@ void bootsplash_do_render_pictures(struct fb_info *info,
14
if (!bp || bp->blob_header->type != 0)
15
continue;
16
17
- dst_xoff = (info->var.xres - pp->pic_header->width) / 2;
18
- dst_yoff = (info->var.yres - pp->pic_header->height) / 2;
19
+ switch (ph->position) {
20
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_TOP_LEFT:
21
+ dst_xoff = 0;
22
+ dst_yoff = 0;
23
+
24
+ dst_xoff += ph->position_offset;
25
+ dst_yoff += ph->position_offset;
26
+ break;
27
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_TOP:
28
+ dst_xoff = info->var.xres - pp->pic_header->width;
29
+ dst_xoff /= 2;
30
+ dst_yoff = 0;
31
+
32
+ dst_yoff += ph->position_offset;
33
+ break;
34
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_TOP_RIGHT:
35
+ dst_xoff = info->var.xres - pp->pic_header->width;
36
+ dst_yoff = 0;
37
+
38
+ dst_xoff -= ph->position_offset;
39
+ dst_yoff += ph->position_offset;
40
+ break;
41
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_RIGHT:
42
+ dst_xoff = info->var.xres - pp->pic_header->width;
43
+ dst_yoff = info->var.yres - pp->pic_header->height;
44
+ dst_yoff /= 2;
45
+
46
+ dst_xoff -= ph->position_offset;
47
+ break;
48
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_BOTTOM_RIGHT:
49
+ dst_xoff = info->var.xres - pp->pic_header->width;
50
+ dst_yoff = info->var.yres - pp->pic_header->height;
51
+
52
+ dst_xoff -= ph->position_offset;
53
+ dst_yoff -= ph->position_offset;
54
+ break;
55
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_BOTTOM:
56
+ dst_xoff = info->var.xres - pp->pic_header->width;
57
+ dst_xoff /= 2;
58
+ dst_yoff = info->var.yres - pp->pic_header->height;
59
+
60
+ dst_yoff -= ph->position_offset;
61
+ break;
62
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_BOTTOM_LEFT:
63
+ dst_xoff = 0 + ph->position_offset;
64
+ dst_yoff = info->var.yres - pp->pic_header->height
65
+ - ph->position_offset;
66
+ break;
67
+ case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_LEFT:
68
+ dst_xoff = 0;
69
+ dst_yoff = info->var.yres - pp->pic_header->height;
70
+ dst_yoff /= 2;
71
+
72
+ dst_xoff += ph->position_offset;
73
+ break;
74
+
75
+ case SPLASH_CORNER_TOP_LEFT:
76
+ dst_xoff = info->var.xres - pp->pic_header->width;
77
+ dst_xoff /= 2;
78
+ dst_yoff = info->var.yres - pp->pic_header->height;
79
+ dst_yoff /= 2;
80
+
81
+ dst_xoff -= ph->position_offset;
82
+ dst_yoff -= ph->position_offset;
83
+ break;
84
+ case SPLASH_CORNER_TOP:
85
+ dst_xoff = info->var.xres - pp->pic_header->width;
86
+ dst_xoff /= 2;
87
+ dst_yoff = info->var.yres - pp->pic_header->height;
88
+ dst_yoff /= 2;
89
+
90
+ dst_yoff -= ph->position_offset;
91
+ break;
92
+ case SPLASH_CORNER_TOP_RIGHT:
93
+ dst_xoff = info->var.xres - pp->pic_header->width;
94
+ dst_xoff /= 2;
95
+ dst_yoff = info->var.yres - pp->pic_header->height;
96
+ dst_yoff /= 2;
97
+
98
+ dst_xoff += ph->position_offset;
99
+ dst_yoff -= ph->position_offset;
100
+ break;
101
+ case SPLASH_CORNER_RIGHT:
102
+ dst_xoff = info->var.xres - pp->pic_header->width;
103
+ dst_xoff /= 2;
104
+ dst_yoff = info->var.yres - pp->pic_header->height;
105
+ dst_yoff /= 2;
106
+
107
+ dst_xoff += ph->position_offset;
108
+ break;
109
+ case SPLASH_CORNER_BOTTOM_RIGHT:
110
+ dst_xoff = info->var.xres - pp->pic_header->width;
111
+ dst_xoff /= 2;
112
+ dst_yoff = info->var.yres - pp->pic_header->height;
113
+ dst_yoff /= 2;
114
+
115
+ dst_xoff += ph->position_offset;
116
+ dst_yoff += ph->position_offset;
117
+ break;
118
+ case SPLASH_CORNER_BOTTOM:
119
+ dst_xoff = info->var.xres - pp->pic_header->width;
120
+ dst_xoff /= 2;
121
+ dst_yoff = info->var.yres - pp->pic_header->height;
122
+ dst_yoff /= 2;
123
+
124
+ dst_yoff += ph->position_offset;
125
+ break;
126
+ case SPLASH_CORNER_BOTTOM_LEFT:
127
+ dst_xoff = info->var.xres - pp->pic_header->width;
128
+ dst_xoff /= 2;
129
+ dst_yoff = info->var.yres - pp->pic_header->height;
130
+ dst_yoff /= 2;
131
+
132
+ dst_xoff -= ph->position_offset;
133
+ dst_yoff += ph->position_offset;
134
+ break;
135
+ case SPLASH_CORNER_LEFT:
136
+ dst_xoff = info->var.xres - pp->pic_header->width;
137
+ dst_xoff /= 2;
138
+ dst_yoff = info->var.yres - pp->pic_header->height;
139
+ dst_yoff /= 2;
140
+
141
+ dst_xoff -= ph->position_offset;
142
+ break;
143
+
144
+ default:
145
+ /* As a fallback, center the picture. */
146
+ dst_xoff = info->var.xres - pp->pic_header->width;
147
+ dst_xoff /= 2;
148
+ dst_yoff = info->var.yres - pp->pic_header->height;
149
+ dst_yoff /= 2;
150
+ break;
151
+ }
152
153
if (dst_xoff < 0
154
|| dst_yoff < 0
155
diff --git a/include/uapi/linux/bootsplash_file.h b/include/uapi/linux/bootsplash_file.h
156
index 89dc9cca8f0c..71cedcc68933 100644
157
--- a/include/uapi/linux/bootsplash_file.h
158
+++ b/include/uapi/linux/bootsplash_file.h
159
@@ -91,7 +91,32 @@ struct splash_pic_header {
160
*/
161
uint8_t num_blobs;
162
163
- uint8_t padding[27];
164
+ /*
165
+ * Corner to move the picture to / from.
166
+ * 0x00 - Top left
167
+ * 0x01 - Top
168
+ * 0x02 - Top right
169
+ * 0x03 - Right
170
+ * 0x04 - Bottom right
171
+ * 0x05 - Bottom
172
+ * 0x06 - Bottom left
173
+ * 0x07 - Left
174
+ *
175
+ * Flags:
176
+ * 0x10 - Calculate offset from the corner towards the center,
177
+ * rather than from the center towards the corner
178
+ */
179
+ uint8_t position;
180
+
181
+ /*
182
+ * Pixel offset from the selected position.
183
+ * Example: If the picture is in the top right corner, it will
184
+ * be placed position_offset pixels from the top and
185
+ * position_offset pixels from the right margin.
186
+ */
187
+ uint16_t position_offset;
188
+
189
+ uint8_t padding[24];
190
} __attribute__((__packed__));
191
192
193
@@ -115,4 +140,22 @@ struct splash_blob_header {
194
uint8_t padding[9];
195
} __attribute__((__packed__));
196
197
+
198
+
199
+
200
+/*
201
+ * Enums for on-disk types
202
+ */
203
+enum splash_position {
204
+ SPLASH_CORNER_TOP_LEFT = 0,
205
+ SPLASH_CORNER_TOP = 1,
206
+ SPLASH_CORNER_TOP_RIGHT = 2,
207
+ SPLASH_CORNER_RIGHT = 3,
208
+ SPLASH_CORNER_BOTTOM_RIGHT = 4,
209
+ SPLASH_CORNER_BOTTOM = 5,
210
+ SPLASH_CORNER_BOTTOM_LEFT = 6,
211
+ SPLASH_CORNER_LEFT = 7,
212
+ SPLASH_POS_FLAG_CORNER = 0x10,
213
+};
214
+
215
#endif
216
217