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
|
From e1004cd1a1252a17219f5ebd13749c91e8ddc09b Mon Sep 17 00:00:00 2001
From: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
Date: Mon, 25 Apr 2022 10:59:49 +0300
Subject: [PATCH 10/17] Rework flip as function pointer
It allows making parse_command and psplash_main independent of FB.
drm-backend backport from:
https://patchwork.yoctoproject.org/project/yocto/cover/20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com/
Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
---
psplash-draw.h | 3 +++
psplash-fb.c | 8 +++++---
psplash-fb.h | 3 ---
psplash.c | 16 ++++++++--------
4 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/psplash-draw.h b/psplash-draw.h
index 44546b0..292ddd9 100644
--- a/psplash-draw.h
+++ b/psplash-draw.h
@@ -36,6 +36,9 @@ typedef struct PSplashCanvas
int green_length;
int blue_offset;
int blue_length;
+
+ void *priv;
+ void (*flip)(struct PSplashCanvas *canvas, int sync);
}
PSplashCanvas;
diff --git a/psplash-fb.c b/psplash-fb.c
index dd50a5a..d41c477 100644
--- a/psplash-fb.c
+++ b/psplash-fb.c
@@ -18,9 +18,10 @@ psplash_wait_for_vsync(PSplashFB *fb)
fprintf(stderr, "Error, FB vsync ioctl [%d]\n", err);
}
-void
-psplash_fb_flip(PSplashFB *fb, int sync)
+static void
+psplash_fb_flip(PSplashCanvas *canvas, int sync)
{
+ PSplashFB *fb = canvas->priv;
char *tmp;
if (fb->double_buffering) {
@@ -154,7 +155,8 @@ psplash_fb_new (int angle, int fbdev_id)
}
memset (fb, 0, sizeof(PSplashFB));
-
+ fb->canvas.priv = fb;
+ fb->canvas.flip = psplash_fb_flip;
fb->fd = -1;
if ((fb->fd = open (fbdev, O_RDWR)) < 0)
diff --git a/psplash-fb.h b/psplash-fb.h
index 1b16bd5..979d23a 100644
--- a/psplash-fb.h
+++ b/psplash-fb.h
@@ -40,7 +40,4 @@ psplash_fb_destroy (PSplashFB *fb);
PSplashFB*
psplash_fb_new (int angle, int fbdev_id);
-void
-psplash_fb_flip(PSplashFB *fb, int sync);
-
#endif
diff --git a/psplash.c b/psplash.c
index c234d46..036dfb1 100644
--- a/psplash.c
+++ b/psplash.c
@@ -100,7 +100,7 @@ psplash_draw_progress(PSplashCanvas *canvas, int value)
#endif /* PSPLASH_SHOW_PROGRESS_BAR */
static int
-parse_command (PSplashFB *fb, char *string)
+parse_command(PSplashCanvas *canvas, char *string)
{
char *command;
@@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string)
char *arg = strtok(NULL, "\0");
if (arg)
- psplash_draw_msg(&fb->canvas, arg);
+ psplash_draw_msg(canvas, arg);
}
#ifdef PSPLASH_SHOW_PROGRESS_BAR
else if (!strcmp(command,"PROGRESS"))
@@ -124,7 +124,7 @@ parse_command (PSplashFB *fb, char *string)
char *arg = strtok(NULL, "\0");
if (arg)
- psplash_draw_progress(&fb->canvas, atoi(arg));
+ psplash_draw_progress(canvas, atoi(arg));
}
#endif
else if (!strcmp(command,"QUIT"))
@@ -132,12 +132,12 @@ parse_command (PSplashFB *fb, char *string)
return 1;
}
- psplash_fb_flip(fb, 0);
+ canvas->flip(canvas, 0);
return 0;
}
void
-psplash_main (PSplashFB *fb, int pipe_fd, int timeout)
+psplash_main(PSplashCanvas *canvas, int pipe_fd, int timeout)
{
int err;
ssize_t length = 0;
@@ -200,7 +200,7 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout)
continue;
}
- if (parse_command(fb, cmd))
+ if (parse_command(canvas, cmd))
return;
length -= cmdlen;
@@ -345,9 +345,9 @@ main (int argc, char** argv)
* text and progress bar change which overwrite the specific areas with every
* update.
*/
- psplash_fb_flip(fb, 1);
+ canvas->flip(canvas, 1);
- psplash_main (fb, pipe_fd, 0);
+ psplash_main(canvas, pipe_fd, 0);
psplash_fb_destroy (fb);
--
2.25.1
|