about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/amdgpu-pro/patches/0006-Fix-crtc_gamma-functions-for-4.8.0.patch
blob: 566b7039bb3e807a36016b5c26406835192130ce (plain) (blame)
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
From 12660ae02838f99c0784194908f7a189bc2ab0ae Mon Sep 17 00:00:00 2001
From: "Luke A. Guest" <laguest@archeia.com>
Date: Sun, 25 Sep 2016 16:56:47 +0100
Subject: [PATCH 06/11] Fix crtc_gamma functions for 4.8.0

---
 amd/amdgpu/dce_v10_0.c              | 19 +++++++++++++++++++
 amd/amdgpu/dce_v11_0.c              | 19 +++++++++++++++++++
 amd/amdgpu/dce_v8_0.c               | 19 +++++++++++++++++++
 amd/dal/amdgpu_dm/amdgpu_dm_types.c | 12 ++++++++++++
 4 files changed, 69 insertions(+)

diff --git a/amd/amdgpu/dce_v10_0.c b/amd/amdgpu/dce_v10_0.c
index b1880ac..53746fa 100644
--- a/amd/amdgpu/dce_v10_0.c
+++ b/amd/amdgpu/dce_v10_0.c
@@ -2627,6 +2627,24 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+	int i;
+
+	/* userspace palettes are always correct as is */
+	for (i = 0; i < size; i++) {
+		amdgpu_crtc->lut_r[i] = red[i] >> 6;
+		amdgpu_crtc->lut_g[i] = green[i] >> 6;
+		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
+	}
+	dce_v10_0_crtc_load_lut(crtc);
+
+	return 0;
+}
+#else
 static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
 				    u16 *blue, uint32_t start, uint32_t size)
 {
@@ -2641,6 +2659,7 @@ static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green
 	}
 	dce_v10_0_crtc_load_lut(crtc);
 }
+#endif
 
 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
 {
diff --git a/amd/amdgpu/dce_v11_0.c b/amd/amdgpu/dce_v11_0.c
index b654b64..3edd66d 100644
--- a/amd/amdgpu/dce_v11_0.c
+++ b/amd/amdgpu/dce_v11_0.c
@@ -2643,6 +2643,24 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+	int i;
+
+	/* userspace palettes are always correct as is */
+	for (i = 0; i < size; i++) {
+		amdgpu_crtc->lut_r[i] = red[i] >> 6;
+		amdgpu_crtc->lut_g[i] = green[i] >> 6;
+		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
+	}
+	dce_v11_0_crtc_load_lut(crtc);
+
+	return 0;
+}
+#else
 static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
 				    u16 *blue, uint32_t start, uint32_t size)
 {
@@ -2657,6 +2675,7 @@ static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green
 	}
 	dce_v11_0_crtc_load_lut(crtc);
 }
+#endif
 
 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
 {
diff --git a/amd/amdgpu/dce_v8_0.c b/amd/amdgpu/dce_v8_0.c
index b598caa..d203894 100644
--- a/amd/amdgpu/dce_v8_0.c
+++ b/amd/amdgpu/dce_v8_0.c
@@ -2478,6 +2478,24 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+	int i;
+
+	/* userspace palettes are always correct as is */
+	for (i = 0; i < size; i++) {
+		amdgpu_crtc->lut_r[i] = red[i] >> 6;
+		amdgpu_crtc->lut_g[i] = green[i] >> 6;
+		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
+	}
+	dce_v8_0_crtc_load_lut(crtc);
+
+	return 0;
+}
+#else
 static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
 				    u16 *blue, uint32_t start, uint32_t size)
 {
@@ -2492,6 +2510,7 @@ static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
 	}
 	dce_v8_0_crtc_load_lut(crtc);
 }
+#endif
 
 static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
 {
diff --git a/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
index edc8e86..32755a9 100644
--- a/amd/dal/amdgpu_dm/amdgpu_dm_types.c
+++ b/amd/dal/amdgpu_dm/amdgpu_dm_types.c
@@ -998,6 +998,13 @@ void amdgpu_dm_crtc_destroy(struct drm_crtc *crtc)
 	kfree(crtc);
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+static int amdgpu_dm_atomic_crtc_gamma_set(struct drm_crtc *crtc,
+					   u16 *red,
+					   u16 *green,
+					   u16 *blue,
+					   uint32_t size)
+#else
 static void amdgpu_dm_atomic_crtc_gamma_set(
 		struct drm_crtc *crtc,
 		u16 *red,
@@ -1005,6 +1012,7 @@ static void amdgpu_dm_atomic_crtc_gamma_set(
 		u16 *blue,
 		uint32_t start,
 		uint32_t size)
+#endif
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_property *prop = dev->mode_config.prop_crtc_id;
@@ -1012,6 +1020,10 @@ static void amdgpu_dm_atomic_crtc_gamma_set(
 	crtc->state->mode.private_flags |= AMDGPU_CRTC_MODE_PRIVATE_FLAGS_GAMMASET;
 
 	drm_atomic_helper_crtc_set_property(crtc, prop, 0);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	return 0;
+#endif
 }
 
 static int dm_crtc_funcs_atomic_set_property(
-- 
2.11.0