aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0515-drm-amd-dal-Use-fixed-types-instead-of-int-long-long.patch
blob: 920356176b07b72bfc7332a7171dd1d52a8d029a (plain)
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
From c2e2413d4fcb76a00edca5fe7c9ae5121240af31 Mon Sep 17 00:00:00 2001
From: Jordan Lazare <Jordan.Lazare@amd.com>
Date: Mon, 30 Nov 2015 13:59:48 -0500
Subject: [PATCH 0515/1110] drm/amd/dal: Use fixed types instead of
 int/long/long long

To keep code consistent and particularly with fixed point calcs, we want
to use uint32_t and uint64_t instead of the common int/long/long long
types.

Signed-off-by: Jordan Lazare <Jordan.Lazare@amd.com>
Reviewed-by: Alex Deucher <Alexander.Deucher@amd.com>
---
 drivers/gpu/drm/amd/dal/dc/calcs/bw_fixed.c | 56 ++++++++++++++---------------
 drivers/gpu/drm/amd/dal/dc/inc/bw_fixed.h   |  8 ++---
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/dc/calcs/bw_fixed.c b/drivers/gpu/drm/amd/dal/dc/calcs/bw_fixed.c
index 1716808..8bdd0fb 100644
--- a/drivers/gpu/drm/amd/dal/dc/calcs/bw_fixed.c
+++ b/drivers/gpu/drm/amd/dal/dc/calcs/bw_fixed.c
@@ -29,16 +29,16 @@
 #define BITS_PER_FRACTIONAL_PART 24
 
 #define MIN_I32 \
-	(long long)(-(1LL << (63 - BITS_PER_FRACTIONAL_PART)))
+	(int64_t)(-(1LL << (63 - BITS_PER_FRACTIONAL_PART)))
 
 #define MAX_I32 \
-	(long long)((1ULL << (63 - BITS_PER_FRACTIONAL_PART)) - 1)
+	(int64_t)((1ULL << (63 - BITS_PER_FRACTIONAL_PART)) - 1)
 
 #define MIN_I64 \
-	(long long)(-(1LL << 63))
+	(int64_t)(-(1LL << 63))
 
 #define MAX_I64 \
-	(long long)((1ULL << 63) - 1)
+	(int64_t)((1ULL << 63) - 1)
 
 
 #define FRACTIONAL_PART_MASK \
@@ -50,12 +50,12 @@
 #define GET_FRACTIONAL_PART(x) \
 	(FRACTIONAL_PART_MASK & (x))
 
-static unsigned long long abs_i64(long long arg)
+static uint64_t abs_i64(int64_t arg)
 {
 	if (arg >= 0)
-		return (unsigned long long)(arg);
+		return (uint64_t)(arg);
 	else
-		return (unsigned long long)(-arg);
+		return (uint64_t)(-arg);
 }
 
 struct bw_fixed bw_min3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed v3)
@@ -68,7 +68,7 @@ struct bw_fixed bw_max3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed
 	return bw_max(bw_max(v1, v2), v3);
 }
 
-struct bw_fixed int_to_fixed(long long value)
+struct bw_fixed int_to_fixed(int64_t value)
 {
 	struct bw_fixed res;
 	ASSERT(value < MAX_I32 && value > MIN_I32);
@@ -76,17 +76,17 @@ struct bw_fixed int_to_fixed(long long value)
 	return res;
 }
 
-struct bw_fixed frc_to_fixed(long long numerator, long long denominator)
+struct bw_fixed frc_to_fixed(int64_t numerator, int64_t denominator)
 {
 	struct bw_fixed res;
 	bool arg1_negative = numerator < 0;
 	bool arg2_negative = denominator < 0;
-	unsigned long long arg1_value;
-	unsigned long long arg2_value;
-	unsigned long long remainder;
+	uint64_t arg1_value;
+	uint64_t arg2_value;
+	uint64_t remainder;
 
 	/* determine integer part */
-	unsigned long long res_value;
+	uint64_t res_value;
 
 	ASSERT(denominator != 0);
 
@@ -98,7 +98,7 @@ struct bw_fixed frc_to_fixed(long long numerator, long long denominator)
 
 	/* determine fractional part */
 	{
-		unsigned int i = BITS_PER_FRACTIONAL_PART;
+		uint32_t i = BITS_PER_FRACTIONAL_PART;
 
 		do
 		{
@@ -116,14 +116,14 @@ struct bw_fixed frc_to_fixed(long long numerator, long long denominator)
 
 	/* round up LSB */
 	{
-		unsigned long long summand = (remainder << 1) >= arg2_value;
+		uint64_t summand = (remainder << 1) >= arg2_value;
 
 		ASSERT(res_value <= MAX_I64 - summand);
 
 		res_value += summand;
 	}
 
-	res.value = (signed long long)(res_value);
+	res.value = (int64_t)(res_value);
 
 	if (arg1_negative ^ arg2_negative)
 		res.value = -res.value;
@@ -185,16 +185,16 @@ struct bw_fixed mul(const struct bw_fixed arg1, const struct bw_fixed arg2)
 	bool arg1_negative = arg1.value < 0;
 	bool arg2_negative = arg2.value < 0;
 
-	unsigned long long arg1_value = abs_i64(arg1.value);
-	unsigned long long arg2_value = abs_i64(arg2.value);
+	uint64_t arg1_value = abs_i64(arg1.value);
+	uint64_t arg2_value = abs_i64(arg2.value);
 
-	unsigned long long arg1_int = GET_INTEGER_PART(arg1_value);
-	unsigned long long arg2_int = GET_INTEGER_PART(arg2_value);
+	uint64_t arg1_int = GET_INTEGER_PART(arg1_value);
+	uint64_t arg2_int = GET_INTEGER_PART(arg2_value);
 
-	unsigned long long arg1_fra = GET_FRACTIONAL_PART(arg1_value);
-	unsigned long long arg2_fra = GET_FRACTIONAL_PART(arg2_value);
+	uint64_t arg1_fra = GET_FRACTIONAL_PART(arg1_value);
+	uint64_t arg2_fra = GET_FRACTIONAL_PART(arg2_value);
 
-	unsigned long long tmp;
+	uint64_t tmp;
 
 	res.value = arg1_int * arg2_int;
 
@@ -204,22 +204,22 @@ struct bw_fixed mul(const struct bw_fixed arg1, const struct bw_fixed arg2)
 
 	tmp = arg1_int * arg2_fra;
 
-	ASSERT(tmp <= (unsigned long long)(MAX_I64 - res.value));
+	ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
 
 	res.value += tmp;
 
 	tmp = arg2_int * arg1_fra;
 
-	ASSERT(tmp <= (unsigned long long)(MAX_I64 - res.value));
+	ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
 
 	res.value += tmp;
 
 	tmp = arg1_fra * arg2_fra;
 
 	tmp = (tmp >> BITS_PER_FRACTIONAL_PART) +
-		(tmp >= (unsigned long long)(frc_to_fixed(1, 2).value));
+		(tmp >= (uint64_t)(frc_to_fixed(1, 2).value));
 
-	ASSERT(tmp <= (unsigned long long)(MAX_I64 - res.value));
+	ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
 
 	res.value += tmp;
 
@@ -234,7 +234,7 @@ struct bw_fixed bw_div(const struct bw_fixed arg1, const struct bw_fixed arg2)
 	return res;
 }
 
-struct bw_fixed fixed31_32_to_bw_fixed(long long raw)
+struct bw_fixed fixed31_32_to_bw_fixed(int64_t raw)
 {
 	struct bw_fixed result = { 0 };
 
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/bw_fixed.h b/drivers/gpu/drm/amd/dal/dc/inc/bw_fixed.h
index f9e267b..254cf76 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/bw_fixed.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/bw_fixed.h
@@ -27,18 +27,18 @@
 #define BW_FIXED_H_
 
 struct bw_fixed {
-	signed long long value;
+	int64_t value;
 };
 
 struct bw_fixed bw_min3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed v3);
 
 struct bw_fixed bw_max3(struct bw_fixed v1, struct bw_fixed v2, struct bw_fixed v3);
 
-struct bw_fixed int_to_fixed(long long value);
+struct bw_fixed int_to_fixed(int64_t value);
 
-struct bw_fixed frc_to_fixed(long long num, long long denum);
+struct bw_fixed frc_to_fixed(int64_t num, int64_t denum);
 
-struct bw_fixed fixed31_32_to_bw_fixed(long long raw);
+struct bw_fixed fixed31_32_to_bw_fixed(int64_t raw);
 
 struct bw_fixed add(const struct bw_fixed arg1, const struct bw_fixed arg2);
 struct bw_fixed sub(const struct bw_fixed arg1, const struct bw_fixed arg2);
-- 
2.7.4