10
10
#include <linux/io.h>
11
11
#include <linux/err.h>
12
12
13
+ #include <drm/drm_color_mgmt.h>
13
14
#include <video/imx-ipu-v3.h>
14
15
#include "ipu-prv.h"
15
16
@@ -125,6 +126,8 @@ int ipu_dp_set_window_pos(struct ipu_dp *dp, u16 x_pos, u16 y_pos)
125
126
EXPORT_SYMBOL_GPL (ipu_dp_set_window_pos );
126
127
127
128
static void ipu_dp_csc_init (struct ipu_flow * flow ,
129
+ enum drm_color_encoding ycbcr_enc ,
130
+ enum drm_color_range range ,
128
131
enum ipu_color_space in ,
129
132
enum ipu_color_space out ,
130
133
u32 place )
@@ -148,7 +151,18 @@ static void ipu_dp_csc_init(struct ipu_flow *flow,
148
151
flow -> base + DP_CSC_0 );
149
152
writel (0x200 | (2 << 14 ) | (0x200 << 16 ) | (2 << 30 ),
150
153
flow -> base + DP_CSC_1 );
154
+ } else if (ycbcr_enc == DRM_COLOR_YCBCR_BT709 ) {
155
+ /* Rec.709 limited range */
156
+ writel (0x095 | (0x000 << 16 ), flow -> base + DP_CSC_A_0 );
157
+ writel (0x0e5 | (0x095 << 16 ), flow -> base + DP_CSC_A_1 );
158
+ writel (0x3e5 | (0x3bc << 16 ), flow -> base + DP_CSC_A_2 );
159
+ writel (0x095 | (0x10e << 16 ), flow -> base + DP_CSC_A_3 );
160
+ writel (0x000 | (0x3e10 << 16 ) | (1 << 30 ),
161
+ flow -> base + DP_CSC_0 );
162
+ writel (0x09a | (1 << 14 ) | (0x3dbe << 16 ) | (1 << 30 ),
163
+ flow -> base + DP_CSC_1 );
151
164
} else {
165
+ /* BT.601 limited range */
152
166
writel (0x095 | (0x000 << 16 ), flow -> base + DP_CSC_A_0 );
153
167
writel (0x0cc | (0x095 << 16 ), flow -> base + DP_CSC_A_1 );
154
168
writel (0x3ce | (0x398 << 16 ), flow -> base + DP_CSC_A_2 );
@@ -165,6 +179,8 @@ static void ipu_dp_csc_init(struct ipu_flow *flow,
165
179
}
166
180
167
181
int ipu_dp_setup_channel (struct ipu_dp * dp ,
182
+ enum drm_color_encoding ycbcr_enc ,
183
+ enum drm_color_range range ,
168
184
enum ipu_color_space in ,
169
185
enum ipu_color_space out )
170
186
{
@@ -183,7 +199,8 @@ int ipu_dp_setup_channel(struct ipu_dp *dp,
183
199
* foreground and background are of same colorspace, put
184
200
* colorspace converter after combining unit.
185
201
*/
186
- ipu_dp_csc_init (flow , flow -> foreground .in_cs , flow -> out_cs ,
202
+ ipu_dp_csc_init (flow , ycbcr_enc , range ,
203
+ flow -> foreground .in_cs , flow -> out_cs ,
187
204
DP_COM_CONF_CSC_DEF_BOTH );
188
205
} else {
189
206
if (flow -> foreground .in_cs == IPUV3_COLORSPACE_UNKNOWN ||
@@ -192,10 +209,12 @@ int ipu_dp_setup_channel(struct ipu_dp *dp,
192
209
* foreground identical to output, apply color
193
210
* conversion on background
194
211
*/
195
- ipu_dp_csc_init (flow , flow -> background .in_cs ,
212
+ ipu_dp_csc_init (flow , ycbcr_enc , range ,
213
+ flow -> background .in_cs ,
196
214
flow -> out_cs , DP_COM_CONF_CSC_DEF_BG );
197
215
else
198
- ipu_dp_csc_init (flow , flow -> foreground .in_cs ,
216
+ ipu_dp_csc_init (flow , ycbcr_enc , range ,
217
+ flow -> foreground .in_cs ,
199
218
flow -> out_cs , DP_COM_CONF_CSC_DEF_FG );
200
219
}
201
220
0 commit comments