@@ -8,16 +8,16 @@ Add XRGB8888 emulation helper for devices that only support BGR888.
8
8
9
9
Signed-off-by: Kerem Karabay <
[email protected] >
10
10
---
11
- drivers/gpu/drm/drm_format_helper.c | 53 + +++++++++++++
12
- .../gpu/drm/tests/drm_format_helper_test.c | 69 +++++++++++++++++++
11
+ drivers/gpu/drm/drm_format_helper.c | 54 +++++++++++++
12
+ .../gpu/drm/tests/drm_format_helper_test.c | 81 +++++++++++++++++++
13
13
include/drm/drm_format_helper.h | 3 +
14
- 3 files changed, 125 insertions(+)
14
+ 3 files changed, 138 insertions(+)
15
15
16
16
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
17
- index b1be458ed4dda5..24836384554a47 100644
17
+ index b1be458ed..28c0e76a1 100644
18
18
--- a/drivers/gpu/drm/drm_format_helper.c
19
19
+++ b/drivers/gpu/drm/drm_format_helper.c
20
- @@ -702,6 +702,58 @@ void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pi
20
+ @@ -702,6 +702,57 @@ void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pi
21
21
}
22
22
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888);
23
23
@@ -61,22 +61,21 @@ index b1be458ed4dda5..24836384554a47 100644
61
61
+ */
62
62
+ void drm_fb_xrgb8888_to_bgr888(struct iosys_map *dst, const unsigned int *dst_pitch,
63
63
+ const struct iosys_map *src, const struct drm_framebuffer *fb,
64
- + const struct drm_rect *clip,
65
- + struct drm_format_conv_state *state)
64
+ + const struct drm_rect *clip, struct drm_format_conv_state *state)
66
65
+ {
67
66
+ static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
68
67
+ 3,
69
68
+ };
70
69
+
71
- + drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
72
- + state, drm_fb_xrgb8888_to_bgr888_line);
70
+ + drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false, state,
71
+ + drm_fb_xrgb8888_to_bgr888_line);
73
72
+ }
74
73
+ EXPORT_SYMBOL(drm_fb_xrgb8888_to_bgr888);
75
74
+
76
75
static void drm_fb_xrgb8888_to_argb8888_line(void *dbuf, const void *sbuf, unsigned int pixels)
77
76
{
78
77
__le32 *dbuf32 = dbuf;
79
- @@ -1035,6 +1087 ,9 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d
78
+ @@ -1035,6 +1086 ,9 @@ int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t d
80
79
} else if (dst_format == DRM_FORMAT_RGB888) {
81
80
drm_fb_xrgb8888_to_rgb888(dst, dst_pitch, src, fb, clip, state);
82
81
return 0;
@@ -87,10 +86,10 @@ index b1be458ed4dda5..24836384554a47 100644
87
86
drm_fb_xrgb8888_to_argb8888(dst, dst_pitch, src, fb, clip, state);
88
87
return 0;
89
88
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
90
- index 474bb7a1c..dff7fabd9 100644
89
+ index 08992636e..e54f0f6e7 100644
91
90
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
92
91
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
93
- @@ -52 ,6 +52 ,11 @@ struct convert_to_rgb888_result {
92
+ @@ -60 ,6 +60 ,11 @@ struct convert_to_rgb888_result {
94
93
const u8 expected[TEST_BUF_SIZE];
95
94
};
96
95
@@ -102,15 +101,15 @@ index 474bb7a1c..dff7fabd9 100644
102
101
struct convert_to_argb8888_result {
103
102
unsigned int dst_pitch;
104
103
const u32 expected[TEST_BUF_SIZE];
105
- @@ -84 ,6 +89 ,7 @@ struct convert_xrgb8888_case {
104
+ @@ -107 ,6 +112 ,7 @@ struct convert_xrgb8888_case {
106
105
struct convert_to_argb1555_result argb1555_result;
107
106
struct convert_to_rgba5551_result rgba5551_result;
108
107
struct convert_to_rgb888_result rgb888_result;
109
108
+ struct convert_to_bgr888_result bgr888_result;
110
109
struct convert_to_argb8888_result argb8888_result;
111
110
struct convert_to_xrgb2101010_result xrgb2101010_result;
112
111
struct convert_to_argb2101010_result argb2101010_result;
113
- @@ -125 ,6 +131 ,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
112
+ @@ -151 ,6 +157 ,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
114
113
.dst_pitch = TEST_USE_DEFAULT_PITCH,
115
114
.expected = { 0x00, 0x00, 0xFF },
116
115
},
@@ -121,7 +120,7 @@ index 474bb7a1c..dff7fabd9 100644
121
120
.argb8888_result = {
122
121
.dst_pitch = TEST_USE_DEFAULT_PITCH,
123
122
.expected = { 0xFFFF0000 },
124
- @@ -179 ,6 +189 ,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
123
+ @@ -217 ,6 +227 ,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
125
124
.dst_pitch = TEST_USE_DEFAULT_PITCH,
126
125
.expected = { 0x00, 0x00, 0xFF },
127
126
},
@@ -132,7 +131,7 @@ index 474bb7a1c..dff7fabd9 100644
132
131
.argb8888_result = {
133
132
.dst_pitch = TEST_USE_DEFAULT_PITCH,
134
133
.expected = { 0xFFFF0000 },
135
- @@ -280 ,6 +294 ,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
134
+ @@ -330 ,6 +344 ,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
136
135
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
137
136
},
138
137
},
@@ -148,7 +147,7 @@ index 474bb7a1c..dff7fabd9 100644
148
147
.argb8888_result = {
149
148
.dst_pitch = TEST_USE_DEFAULT_PITCH,
150
149
.expected = {
151
- @@ -391 ,6 +414 ,17 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
150
+ @@ -468 ,6 +491 ,17 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = {
152
151
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153
152
},
154
153
},
@@ -166,7 +165,7 @@ index 474bb7a1c..dff7fabd9 100644
166
165
.argb8888_result = {
167
166
.dst_pitch = 20,
168
167
.expected = {
169
- @@ -727 ,6 +761,40 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test)
168
+ @@ -914 ,6 +948,52 @@ static void drm_test_fb_xrgb8888_to_rgb888(struct kunit *test)
170
169
KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
171
170
}
172
171
@@ -200,14 +199,26 @@ index 474bb7a1c..dff7fabd9 100644
200
199
+ * BGR888 expected results are already in little-endian
201
200
+ * order, so there's no need to convert the test output.
202
201
+ */
203
- + drm_fb_xrgb8888_to_bgr888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip);
202
+ + drm_fb_xrgb8888_to_bgr888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip,
203
+ + &fmtcnv_state, true);
204
+ + KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
205
+ +
206
+ + buf = dst.vaddr; /* restore original value of buf */
207
+ + memset(buf, 0, dst_size);
208
+ +
209
+ + int blit_result = 0;
210
+ +
211
+ + blit_result = drm_fb_blit(&dst, dst_pitch, DRM_FORMAT_BGR888, &src, &fb, ¶ms->clip,
212
+ + &fmtcnv_state);
213
+ +
214
+ + KUNIT_EXPECT_FALSE(test, blit_result);
204
215
+ KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
205
216
+ }
206
217
+
207
218
static void drm_test_fb_xrgb8888_to_argb8888(struct kunit *test)
208
219
{
209
220
const struct convert_xrgb8888_case *params = test->param_value;
210
- @@ -858 ,6 +926 ,7 @@ static struct kunit_case drm_format_helper_test_cases[] = {
221
+ @@ -1851 ,6 +1931 ,7 @@ static struct kunit_case drm_format_helper_test_cases[] = {
211
222
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb1555, convert_xrgb8888_gen_params),
212
223
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgba5551, convert_xrgb8888_gen_params),
213
224
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888, convert_xrgb8888_gen_params),
@@ -216,10 +227,10 @@ index 474bb7a1c..dff7fabd9 100644
216
227
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010, convert_xrgb8888_gen_params),
217
228
KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_argb2101010, convert_xrgb8888_gen_params),
218
229
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
219
- index 291deb094..7fc553318 100644
230
+ index f13b34e0b..b53cf85ca 100644
220
231
--- a/include/drm/drm_format_helper.h
221
232
+++ b/include/drm/drm_format_helper.h
222
- @@ -42 ,6 +42 ,9 @@ void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_
233
+ @@ -95 ,6 +95 ,9 @@ void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_
223
234
void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
224
235
const struct iosys_map *src, const struct drm_framebuffer *fb,
225
236
const struct drm_rect *clip, struct drm_format_conv_state *state);
@@ -230,5 +241,5 @@ index 291deb094..7fc553318 100644
230
241
const struct iosys_map *src, const struct drm_framebuffer *fb,
231
242
const struct drm_rect *clip, struct drm_format_conv_state *state);
232
243
- -
233
- 2.42.0
244
+ 2.34.1
234
245
0 commit comments