1 1.1 riastrad /* $NetBSD: intel_vdsc.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad // SPDX-License-Identifier: MIT 4 1.1 riastrad /* 5 1.1 riastrad * Copyright 2018 Intel Corporation 6 1.1 riastrad * 7 1.1 riastrad * Author: Gaurav K Singh <gaurav.k.singh (at) intel.com> 8 1.1 riastrad * Manasi Navare <manasi.d.navare (at) intel.com> 9 1.1 riastrad */ 10 1.1 riastrad 11 1.1 riastrad #include <sys/cdefs.h> 12 1.1 riastrad __KERNEL_RCSID(0, "$NetBSD: intel_vdsc.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $"); 13 1.1 riastrad 14 1.1 riastrad #include <drm/i915_drm.h> 15 1.1 riastrad 16 1.1 riastrad #include "i915_drv.h" 17 1.1 riastrad #include "intel_display_types.h" 18 1.1 riastrad #include "intel_dsi.h" 19 1.1 riastrad #include "intel_vdsc.h" 20 1.1 riastrad 21 1.1 riastrad enum ROW_INDEX_BPP { 22 1.1 riastrad ROW_INDEX_6BPP = 0, 23 1.1 riastrad ROW_INDEX_8BPP, 24 1.1 riastrad ROW_INDEX_10BPP, 25 1.1 riastrad ROW_INDEX_12BPP, 26 1.1 riastrad ROW_INDEX_15BPP, 27 1.1 riastrad MAX_ROW_INDEX 28 1.1 riastrad }; 29 1.1 riastrad 30 1.1 riastrad enum COLUMN_INDEX_BPC { 31 1.1 riastrad COLUMN_INDEX_8BPC = 0, 32 1.1 riastrad COLUMN_INDEX_10BPC, 33 1.1 riastrad COLUMN_INDEX_12BPC, 34 1.1 riastrad COLUMN_INDEX_14BPC, 35 1.1 riastrad COLUMN_INDEX_16BPC, 36 1.1 riastrad MAX_COLUMN_INDEX 37 1.1 riastrad }; 38 1.1 riastrad 39 1.1 riastrad /* From DSC_v1.11 spec, rc_parameter_Set syntax element typically constant */ 40 1.1 riastrad static const u16 rc_buf_thresh[] = { 41 1.1 riastrad 896, 1792, 2688, 3584, 4480, 5376, 6272, 6720, 7168, 7616, 42 1.1 riastrad 7744, 7872, 8000, 8064 43 1.1 riastrad }; 44 1.1 riastrad 45 1.1 riastrad struct rc_parameters { 46 1.1 riastrad u16 initial_xmit_delay; 47 1.1 riastrad u8 first_line_bpg_offset; 48 1.1 riastrad u16 initial_offset; 49 1.1 riastrad u8 flatness_min_qp; 50 1.1 riastrad u8 flatness_max_qp; 51 1.1 riastrad u8 rc_quant_incr_limit0; 52 1.1 riastrad u8 rc_quant_incr_limit1; 53 1.1 riastrad struct drm_dsc_rc_range_parameters rc_range_params[DSC_NUM_BUF_RANGES]; 54 1.1 riastrad }; 55 1.1 riastrad 56 1.1 riastrad /* 57 1.1 riastrad * Selected Rate Control Related Parameter Recommended Values 58 1.1 riastrad * from DSC_v1.11 spec & C Model release: DSC_model_20161212 59 1.1 riastrad */ 60 1.1 riastrad static const struct rc_parameters rc_parameters[][MAX_COLUMN_INDEX] = { 61 1.1 riastrad { 62 1.1 riastrad /* 6BPP/8BPC */ 63 1.1 riastrad { 768, 15, 6144, 3, 13, 11, 11, { 64 1.1 riastrad { 0, 4, 0 }, { 1, 6, -2 }, { 3, 8, -2 }, { 4, 8, -4 }, 65 1.1 riastrad { 5, 9, -6 }, { 5, 9, -6 }, { 6, 9, -6 }, { 6, 10, -8 }, 66 1.1 riastrad { 7, 11, -8 }, { 8, 12, -10 }, { 9, 12, -10 }, { 10, 12, -12 }, 67 1.1 riastrad { 10, 12, -12 }, { 11, 12, -12 }, { 13, 14, -12 } 68 1.1 riastrad } 69 1.1 riastrad }, 70 1.1 riastrad /* 6BPP/10BPC */ 71 1.1 riastrad { 768, 15, 6144, 7, 17, 15, 15, { 72 1.1 riastrad { 0, 8, 0 }, { 3, 10, -2 }, { 7, 12, -2 }, { 8, 12, -4 }, 73 1.1 riastrad { 9, 13, -6 }, { 9, 13, -6 }, { 10, 13, -6 }, { 10, 14, -8 }, 74 1.1 riastrad { 11, 15, -8 }, { 12, 16, -10 }, { 13, 16, -10 }, 75 1.1 riastrad { 14, 16, -12 }, { 14, 16, -12 }, { 15, 16, -12 }, 76 1.1 riastrad { 17, 18, -12 } 77 1.1 riastrad } 78 1.1 riastrad }, 79 1.1 riastrad /* 6BPP/12BPC */ 80 1.1 riastrad { 768, 15, 6144, 11, 21, 19, 19, { 81 1.1 riastrad { 0, 12, 0 }, { 5, 14, -2 }, { 11, 16, -2 }, { 12, 16, -4 }, 82 1.1 riastrad { 13, 17, -6 }, { 13, 17, -6 }, { 14, 17, -6 }, { 14, 18, -8 }, 83 1.1 riastrad { 15, 19, -8 }, { 16, 20, -10 }, { 17, 20, -10 }, 84 1.1 riastrad { 18, 20, -12 }, { 18, 20, -12 }, { 19, 20, -12 }, 85 1.1 riastrad { 21, 22, -12 } 86 1.1 riastrad } 87 1.1 riastrad }, 88 1.1 riastrad /* 6BPP/14BPC */ 89 1.1 riastrad { 768, 15, 6144, 15, 25, 23, 27, { 90 1.1 riastrad { 0, 16, 0 }, { 7, 18, -2 }, { 15, 20, -2 }, { 16, 20, -4 }, 91 1.1 riastrad { 17, 21, -6 }, { 17, 21, -6 }, { 18, 21, -6 }, { 18, 22, -8 }, 92 1.1 riastrad { 19, 23, -8 }, { 20, 24, -10 }, { 21, 24, -10 }, 93 1.1 riastrad { 22, 24, -12 }, { 22, 24, -12 }, { 23, 24, -12 }, 94 1.1 riastrad { 25, 26, -12 } 95 1.1 riastrad } 96 1.1 riastrad }, 97 1.1 riastrad /* 6BPP/16BPC */ 98 1.1 riastrad { 768, 15, 6144, 19, 29, 27, 27, { 99 1.1 riastrad { 0, 20, 0 }, { 9, 22, -2 }, { 19, 24, -2 }, { 20, 24, -4 }, 100 1.1 riastrad { 21, 25, -6 }, { 21, 25, -6 }, { 22, 25, -6 }, { 22, 26, -8 }, 101 1.1 riastrad { 23, 27, -8 }, { 24, 28, -10 }, { 25, 28, -10 }, 102 1.1 riastrad { 26, 28, -12 }, { 26, 28, -12 }, { 27, 28, -12 }, 103 1.1 riastrad { 29, 30, -12 } 104 1.1 riastrad } 105 1.1 riastrad }, 106 1.1 riastrad }, 107 1.1 riastrad { 108 1.1 riastrad /* 8BPP/8BPC */ 109 1.1 riastrad { 512, 12, 6144, 3, 12, 11, 11, { 110 1.1 riastrad { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 111 1.1 riastrad { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 112 1.1 riastrad { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, { 5, 12, -12 }, 113 1.1 riastrad { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 } 114 1.1 riastrad } 115 1.1 riastrad }, 116 1.1 riastrad /* 8BPP/10BPC */ 117 1.1 riastrad { 512, 12, 6144, 7, 16, 15, 15, { 118 1.1 riastrad { 0, 4, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 }, 119 1.1 riastrad { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 120 1.1 riastrad { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 }, 121 1.1 riastrad { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 } 122 1.1 riastrad } 123 1.1 riastrad }, 124 1.1 riastrad /* 8BPP/12BPC */ 125 1.1 riastrad { 512, 12, 6144, 11, 20, 19, 19, { 126 1.1 riastrad { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 }, 127 1.1 riastrad { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 128 1.1 riastrad { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 }, 129 1.1 riastrad { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 }, 130 1.1 riastrad { 21, 23, -12 } 131 1.1 riastrad } 132 1.1 riastrad }, 133 1.1 riastrad /* 8BPP/14BPC */ 134 1.1 riastrad { 512, 12, 6144, 15, 24, 23, 23, { 135 1.1 riastrad { 0, 12, 0 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 }, 136 1.1 riastrad { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 137 1.1 riastrad { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 }, 138 1.1 riastrad { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 }, 139 1.1 riastrad { 24, 25, -12 } 140 1.1 riastrad } 141 1.1 riastrad }, 142 1.1 riastrad /* 8BPP/16BPC */ 143 1.1 riastrad { 512, 12, 6144, 19, 28, 27, 27, { 144 1.1 riastrad { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 }, 145 1.1 riastrad { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 146 1.1 riastrad { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 }, 147 1.1 riastrad { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 }, 148 1.1 riastrad { 28, 29, -12 } 149 1.1 riastrad } 150 1.1 riastrad }, 151 1.1 riastrad }, 152 1.1 riastrad { 153 1.1 riastrad /* 10BPP/8BPC */ 154 1.1 riastrad { 410, 15, 5632, 3, 12, 11, 11, { 155 1.1 riastrad { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 }, 156 1.1 riastrad { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 157 1.1 riastrad { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 }, 158 1.1 riastrad { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 } 159 1.1 riastrad } 160 1.1 riastrad }, 161 1.1 riastrad /* 10BPP/10BPC */ 162 1.1 riastrad { 410, 15, 5632, 7, 16, 15, 15, { 163 1.1 riastrad { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 }, 164 1.1 riastrad { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 165 1.1 riastrad { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 }, 166 1.1 riastrad { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 } 167 1.1 riastrad } 168 1.1 riastrad }, 169 1.1 riastrad /* 10BPP/12BPC */ 170 1.1 riastrad { 410, 15, 5632, 11, 20, 19, 19, { 171 1.1 riastrad { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 }, 172 1.1 riastrad { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 173 1.1 riastrad { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 }, 174 1.1 riastrad { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 }, 175 1.1 riastrad { 19, 20, -12 } 176 1.1 riastrad } 177 1.1 riastrad }, 178 1.1 riastrad /* 10BPP/14BPC */ 179 1.1 riastrad { 410, 15, 5632, 15, 24, 23, 23, { 180 1.1 riastrad { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 }, 181 1.1 riastrad { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 182 1.1 riastrad { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 }, 183 1.1 riastrad { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 }, 184 1.1 riastrad { 23, 24, -12 } 185 1.1 riastrad } 186 1.1 riastrad }, 187 1.1 riastrad /* 10BPP/16BPC */ 188 1.1 riastrad { 410, 15, 5632, 19, 28, 27, 27, { 189 1.1 riastrad { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 }, 190 1.1 riastrad { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 191 1.1 riastrad { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 }, 192 1.1 riastrad { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 }, 193 1.1 riastrad { 27, 28, -12 } 194 1.1 riastrad } 195 1.1 riastrad }, 196 1.1 riastrad }, 197 1.1 riastrad { 198 1.1 riastrad /* 12BPP/8BPC */ 199 1.1 riastrad { 341, 15, 2048, 3, 12, 11, 11, { 200 1.1 riastrad { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 201 1.1 riastrad { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 202 1.1 riastrad { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, 203 1.1 riastrad { 5, 12, -12 }, { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 } 204 1.1 riastrad } 205 1.1 riastrad }, 206 1.1 riastrad /* 12BPP/10BPC */ 207 1.1 riastrad { 341, 15, 2048, 7, 16, 15, 15, { 208 1.1 riastrad { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 }, 209 1.1 riastrad { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 210 1.1 riastrad { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 }, 211 1.1 riastrad { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 } 212 1.1 riastrad } 213 1.1 riastrad }, 214 1.1 riastrad /* 12BPP/12BPC */ 215 1.1 riastrad { 341, 15, 2048, 11, 20, 19, 19, { 216 1.1 riastrad { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 }, 217 1.1 riastrad { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 218 1.1 riastrad { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 }, 219 1.1 riastrad { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 }, 220 1.1 riastrad { 21, 23, -12 } 221 1.1 riastrad } 222 1.1 riastrad }, 223 1.1 riastrad /* 12BPP/14BPC */ 224 1.1 riastrad { 341, 15, 2048, 15, 24, 23, 23, { 225 1.1 riastrad { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 }, 226 1.1 riastrad { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 227 1.1 riastrad { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 }, 228 1.1 riastrad { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 }, 229 1.1 riastrad { 22, 23, -12 } 230 1.1 riastrad } 231 1.1 riastrad }, 232 1.1 riastrad /* 12BPP/16BPC */ 233 1.1 riastrad { 341, 15, 2048, 19, 28, 27, 27, { 234 1.1 riastrad { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 }, 235 1.1 riastrad { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 236 1.1 riastrad { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 }, 237 1.1 riastrad { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 }, 238 1.1 riastrad { 26, 27, -12 } 239 1.1 riastrad } 240 1.1 riastrad }, 241 1.1 riastrad }, 242 1.1 riastrad { 243 1.1 riastrad /* 15BPP/8BPC */ 244 1.1 riastrad { 273, 15, 2048, 3, 12, 11, 11, { 245 1.1 riastrad { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 }, 246 1.1 riastrad { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 }, 247 1.1 riastrad { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 }, 248 1.1 riastrad { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 } 249 1.1 riastrad } 250 1.1 riastrad }, 251 1.1 riastrad /* 15BPP/10BPC */ 252 1.1 riastrad { 273, 15, 2048, 7, 16, 15, 15, { 253 1.1 riastrad { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 }, 254 1.1 riastrad { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 }, 255 1.1 riastrad { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 }, 256 1.1 riastrad { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 } 257 1.1 riastrad } 258 1.1 riastrad }, 259 1.1 riastrad /* 15BPP/12BPC */ 260 1.1 riastrad { 273, 15, 2048, 11, 20, 19, 19, { 261 1.1 riastrad { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 }, 262 1.1 riastrad { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 }, 263 1.1 riastrad { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 }, 264 1.1 riastrad { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 }, 265 1.1 riastrad { 16, 17, -12 } 266 1.1 riastrad } 267 1.1 riastrad }, 268 1.1 riastrad /* 15BPP/14BPC */ 269 1.1 riastrad { 273, 15, 2048, 15, 24, 23, 23, { 270 1.1 riastrad { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 }, 271 1.1 riastrad { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 }, 272 1.1 riastrad { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 }, 273 1.1 riastrad { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 }, 274 1.1 riastrad { 20, 21, -12 } 275 1.1 riastrad } 276 1.1 riastrad }, 277 1.1 riastrad /* 15BPP/16BPC */ 278 1.1 riastrad { 273, 15, 2048, 19, 28, 27, 27, { 279 1.1 riastrad { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 }, 280 1.1 riastrad { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 }, 281 1.1 riastrad { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 }, 282 1.1 riastrad { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 }, 283 1.1 riastrad { 24, 25, -12 } 284 1.1 riastrad } 285 1.1 riastrad } 286 1.1 riastrad } 287 1.1 riastrad 288 1.1 riastrad }; 289 1.1 riastrad 290 1.1 riastrad static int get_row_index_for_rc_params(u16 compressed_bpp) 291 1.1 riastrad { 292 1.1 riastrad switch (compressed_bpp) { 293 1.1 riastrad case 6: 294 1.1 riastrad return ROW_INDEX_6BPP; 295 1.1 riastrad case 8: 296 1.1 riastrad return ROW_INDEX_8BPP; 297 1.1 riastrad case 10: 298 1.1 riastrad return ROW_INDEX_10BPP; 299 1.1 riastrad case 12: 300 1.1 riastrad return ROW_INDEX_12BPP; 301 1.1 riastrad case 15: 302 1.1 riastrad return ROW_INDEX_15BPP; 303 1.1 riastrad default: 304 1.1 riastrad return -EINVAL; 305 1.1 riastrad } 306 1.1 riastrad } 307 1.1 riastrad 308 1.1 riastrad static int get_column_index_for_rc_params(u8 bits_per_component) 309 1.1 riastrad { 310 1.1 riastrad switch (bits_per_component) { 311 1.1 riastrad case 8: 312 1.1 riastrad return COLUMN_INDEX_8BPC; 313 1.1 riastrad case 10: 314 1.1 riastrad return COLUMN_INDEX_10BPC; 315 1.1 riastrad case 12: 316 1.1 riastrad return COLUMN_INDEX_12BPC; 317 1.1 riastrad case 14: 318 1.1 riastrad return COLUMN_INDEX_14BPC; 319 1.1 riastrad case 16: 320 1.1 riastrad return COLUMN_INDEX_16BPC; 321 1.1 riastrad default: 322 1.1 riastrad return -EINVAL; 323 1.1 riastrad } 324 1.1 riastrad } 325 1.1 riastrad 326 1.1 riastrad static const struct rc_parameters *get_rc_params(u16 compressed_bpp, 327 1.1 riastrad u8 bits_per_component) 328 1.1 riastrad { 329 1.1 riastrad int row_index, column_index; 330 1.1 riastrad 331 1.1 riastrad row_index = get_row_index_for_rc_params(compressed_bpp); 332 1.1 riastrad if (row_index < 0) 333 1.1 riastrad return NULL; 334 1.1 riastrad 335 1.1 riastrad column_index = get_column_index_for_rc_params(bits_per_component); 336 1.1 riastrad if (column_index < 0) 337 1.1 riastrad return NULL; 338 1.1 riastrad 339 1.1 riastrad return &rc_parameters[row_index][column_index]; 340 1.1 riastrad } 341 1.1 riastrad 342 1.1 riastrad bool intel_dsc_source_support(struct intel_encoder *encoder, 343 1.1 riastrad const struct intel_crtc_state *crtc_state) 344 1.1 riastrad { 345 1.1 riastrad const struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 346 1.1 riastrad struct drm_i915_private *i915 = to_i915(encoder->base.dev); 347 1.1 riastrad enum transcoder cpu_transcoder = crtc_state->cpu_transcoder; 348 1.1 riastrad enum pipe pipe = crtc->pipe; 349 1.1 riastrad 350 1.1 riastrad if (!INTEL_INFO(i915)->display.has_dsc) 351 1.1 riastrad return false; 352 1.1 riastrad 353 1.1 riastrad /* On TGL, DSC is supported on all Pipes */ 354 1.1 riastrad if (INTEL_GEN(i915) >= 12) 355 1.1 riastrad return true; 356 1.1 riastrad 357 1.1 riastrad if (INTEL_GEN(i915) >= 10 && 358 1.1 riastrad (pipe != PIPE_A || 359 1.1 riastrad (cpu_transcoder == TRANSCODER_EDP || 360 1.1 riastrad cpu_transcoder == TRANSCODER_DSI_0 || 361 1.1 riastrad cpu_transcoder == TRANSCODER_DSI_1))) 362 1.1 riastrad return true; 363 1.1 riastrad 364 1.1 riastrad return false; 365 1.1 riastrad } 366 1.1 riastrad 367 1.1 riastrad static bool is_pipe_dsc(const struct intel_crtc_state *crtc_state) 368 1.1 riastrad { 369 1.1 riastrad const struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 370 1.1 riastrad const struct drm_i915_private *i915 = to_i915(crtc->base.dev); 371 1.1 riastrad enum transcoder cpu_transcoder = crtc_state->cpu_transcoder; 372 1.1 riastrad 373 1.1 riastrad if (INTEL_GEN(i915) >= 12) 374 1.1 riastrad return true; 375 1.1 riastrad 376 1.1 riastrad if (cpu_transcoder == TRANSCODER_EDP || 377 1.1 riastrad cpu_transcoder == TRANSCODER_DSI_0 || 378 1.1 riastrad cpu_transcoder == TRANSCODER_DSI_1) 379 1.1 riastrad return false; 380 1.1 riastrad 381 1.1 riastrad /* There's no pipe A DSC engine on ICL */ 382 1.1 riastrad WARN_ON(crtc->pipe == PIPE_A); 383 1.1 riastrad 384 1.1 riastrad return true; 385 1.1 riastrad } 386 1.1 riastrad 387 1.1 riastrad int intel_dsc_compute_params(struct intel_encoder *encoder, 388 1.1 riastrad struct intel_crtc_state *pipe_config) 389 1.1 riastrad { 390 1.1 riastrad struct drm_dsc_config *vdsc_cfg = &pipe_config->dsc.config; 391 1.1 riastrad u16 compressed_bpp = pipe_config->dsc.compressed_bpp; 392 1.1 riastrad const struct rc_parameters *rc_params; 393 1.1 riastrad u8 i = 0; 394 1.1 riastrad 395 1.1 riastrad vdsc_cfg->pic_width = pipe_config->hw.adjusted_mode.crtc_hdisplay; 396 1.1 riastrad vdsc_cfg->pic_height = pipe_config->hw.adjusted_mode.crtc_vdisplay; 397 1.1 riastrad vdsc_cfg->slice_width = DIV_ROUND_UP(vdsc_cfg->pic_width, 398 1.1 riastrad pipe_config->dsc.slice_count); 399 1.1 riastrad 400 1.1 riastrad /* Gen 11 does not support YCbCr */ 401 1.1 riastrad vdsc_cfg->simple_422 = false; 402 1.1 riastrad /* Gen 11 does not support VBR */ 403 1.1 riastrad vdsc_cfg->vbr_enable = false; 404 1.1 riastrad 405 1.1 riastrad /* Gen 11 only supports integral values of bpp */ 406 1.1 riastrad vdsc_cfg->bits_per_pixel = compressed_bpp << 4; 407 1.1 riastrad vdsc_cfg->bits_per_component = pipe_config->pipe_bpp / 3; 408 1.1 riastrad 409 1.1 riastrad for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++) { 410 1.1 riastrad /* 411 1.1 riastrad * six 0s are appended to the lsb of each threshold value 412 1.1 riastrad * internally in h/w. 413 1.1 riastrad * Only 8 bits are allowed for programming RcBufThreshold 414 1.1 riastrad */ 415 1.1 riastrad vdsc_cfg->rc_buf_thresh[i] = rc_buf_thresh[i] >> 6; 416 1.1 riastrad } 417 1.1 riastrad 418 1.1 riastrad /* 419 1.1 riastrad * For 6bpp, RC Buffer threshold 12 and 13 need a different value 420 1.1 riastrad * as per C Model 421 1.1 riastrad */ 422 1.1 riastrad if (compressed_bpp == 6) { 423 1.1 riastrad vdsc_cfg->rc_buf_thresh[12] = 0x7C; 424 1.1 riastrad vdsc_cfg->rc_buf_thresh[13] = 0x7D; 425 1.1 riastrad } 426 1.1 riastrad 427 1.1 riastrad rc_params = get_rc_params(compressed_bpp, vdsc_cfg->bits_per_component); 428 1.1 riastrad if (!rc_params) 429 1.1 riastrad return -EINVAL; 430 1.1 riastrad 431 1.1 riastrad vdsc_cfg->first_line_bpg_offset = rc_params->first_line_bpg_offset; 432 1.1 riastrad vdsc_cfg->initial_xmit_delay = rc_params->initial_xmit_delay; 433 1.1 riastrad vdsc_cfg->initial_offset = rc_params->initial_offset; 434 1.1 riastrad vdsc_cfg->flatness_min_qp = rc_params->flatness_min_qp; 435 1.1 riastrad vdsc_cfg->flatness_max_qp = rc_params->flatness_max_qp; 436 1.1 riastrad vdsc_cfg->rc_quant_incr_limit0 = rc_params->rc_quant_incr_limit0; 437 1.1 riastrad vdsc_cfg->rc_quant_incr_limit1 = rc_params->rc_quant_incr_limit1; 438 1.1 riastrad 439 1.1 riastrad for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { 440 1.1 riastrad vdsc_cfg->rc_range_params[i].range_min_qp = 441 1.1 riastrad rc_params->rc_range_params[i].range_min_qp; 442 1.1 riastrad vdsc_cfg->rc_range_params[i].range_max_qp = 443 1.1 riastrad rc_params->rc_range_params[i].range_max_qp; 444 1.1 riastrad /* 445 1.1 riastrad * Range BPG Offset uses 2's complement and is only a 6 bits. So 446 1.1 riastrad * mask it to get only 6 bits. 447 1.1 riastrad */ 448 1.1 riastrad vdsc_cfg->rc_range_params[i].range_bpg_offset = 449 1.1 riastrad rc_params->rc_range_params[i].range_bpg_offset & 450 1.1 riastrad DSC_RANGE_BPG_OFFSET_MASK; 451 1.1 riastrad } 452 1.1 riastrad 453 1.1 riastrad /* 454 1.1 riastrad * BitsPerComponent value determines mux_word_size: 455 1.1 riastrad * When BitsPerComponent is 12bpc, muxWordSize will be equal to 64 bits 456 1.1 riastrad * When BitsPerComponent is 8 or 10bpc, muxWordSize will be equal to 457 1.1 riastrad * 48 bits 458 1.1 riastrad */ 459 1.1 riastrad if (vdsc_cfg->bits_per_component == 8 || 460 1.1 riastrad vdsc_cfg->bits_per_component == 10) 461 1.1 riastrad vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC; 462 1.1 riastrad else if (vdsc_cfg->bits_per_component == 12) 463 1.1 riastrad vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC; 464 1.1 riastrad 465 1.1 riastrad /* RC_MODEL_SIZE is a constant across all configurations */ 466 1.1 riastrad vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST; 467 1.1 riastrad /* InitialScaleValue is a 6 bit value with 3 fractional bits (U3.3) */ 468 1.1 riastrad vdsc_cfg->initial_scale_value = (vdsc_cfg->rc_model_size << 3) / 469 1.1 riastrad (vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset); 470 1.1 riastrad 471 1.1 riastrad return 0; 472 1.1 riastrad } 473 1.1 riastrad 474 1.1 riastrad enum intel_display_power_domain 475 1.1 riastrad intel_dsc_power_domain(const struct intel_crtc_state *crtc_state) 476 1.1 riastrad { 477 1.1 riastrad struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 478 1.1 riastrad struct drm_i915_private *i915 = to_i915(crtc->base.dev); 479 1.1 riastrad enum pipe pipe = crtc->pipe; 480 1.1 riastrad 481 1.1 riastrad /* 482 1.1 riastrad * VDSC/joining uses a separate power well, PW2, and requires 483 1.1 riastrad * POWER_DOMAIN_TRANSCODER_VDSC_PW2 power domain in two cases: 484 1.1 riastrad * 485 1.1 riastrad * - ICL eDP/DSI transcoder 486 1.1 riastrad * - TGL pipe A 487 1.1 riastrad * 488 1.1 riastrad * For any other pipe, VDSC/joining uses the power well associated with 489 1.1 riastrad * the pipe in use. Hence another reference on the pipe power domain 490 1.1 riastrad * will suffice. (Except no VDSC/joining on ICL pipe A.) 491 1.1 riastrad */ 492 1.1 riastrad if (INTEL_GEN(i915) >= 12 && pipe == PIPE_A) 493 1.1 riastrad return POWER_DOMAIN_TRANSCODER_VDSC_PW2; 494 1.1 riastrad else if (is_pipe_dsc(crtc_state)) 495 1.1 riastrad return POWER_DOMAIN_PIPE(pipe); 496 1.1 riastrad else 497 1.1 riastrad return POWER_DOMAIN_TRANSCODER_VDSC_PW2; 498 1.1 riastrad } 499 1.1 riastrad 500 1.1 riastrad static void intel_dsc_pps_configure(struct intel_encoder *encoder, 501 1.1 riastrad const struct intel_crtc_state *crtc_state) 502 1.1 riastrad { 503 1.1 riastrad struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 504 1.1 riastrad struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 505 1.1 riastrad const struct drm_dsc_config *vdsc_cfg = &crtc_state->dsc.config; 506 1.1 riastrad enum pipe pipe = crtc->pipe; 507 1.1 riastrad u32 pps_val = 0; 508 1.1 riastrad u32 rc_buf_thresh_dword[4]; 509 1.1 riastrad u32 rc_range_params_dword[8]; 510 1.1 riastrad u8 num_vdsc_instances = (crtc_state->dsc.dsc_split) ? 2 : 1; 511 1.1 riastrad int i = 0; 512 1.1 riastrad 513 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_0 registers */ 514 1.1 riastrad pps_val = DSC_VER_MAJ | vdsc_cfg->dsc_version_minor << 515 1.1 riastrad DSC_VER_MIN_SHIFT | 516 1.1 riastrad vdsc_cfg->bits_per_component << DSC_BPC_SHIFT | 517 1.1 riastrad vdsc_cfg->line_buf_depth << DSC_LINE_BUF_DEPTH_SHIFT; 518 1.1 riastrad if (vdsc_cfg->block_pred_enable) 519 1.1 riastrad pps_val |= DSC_BLOCK_PREDICTION; 520 1.1 riastrad if (vdsc_cfg->convert_rgb) 521 1.1 riastrad pps_val |= DSC_COLOR_SPACE_CONVERSION; 522 1.1 riastrad if (vdsc_cfg->simple_422) 523 1.1 riastrad pps_val |= DSC_422_ENABLE; 524 1.1 riastrad if (vdsc_cfg->vbr_enable) 525 1.1 riastrad pps_val |= DSC_VBR_ENABLE; 526 1.1 riastrad DRM_INFO("PPS0 = 0x%08x\n", pps_val); 527 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 528 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_0, pps_val); 529 1.1 riastrad /* 530 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 531 1.1 riastrad * VDSC 532 1.1 riastrad */ 533 1.1 riastrad if (crtc_state->dsc.dsc_split) 534 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_0, pps_val); 535 1.1 riastrad } else { 536 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_0(pipe), pps_val); 537 1.1 riastrad if (crtc_state->dsc.dsc_split) 538 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_0(pipe), 539 1.1 riastrad pps_val); 540 1.1 riastrad } 541 1.1 riastrad 542 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_1 registers */ 543 1.1 riastrad pps_val = 0; 544 1.1 riastrad pps_val |= DSC_BPP(vdsc_cfg->bits_per_pixel); 545 1.1 riastrad DRM_INFO("PPS1 = 0x%08x\n", pps_val); 546 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 547 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_1, pps_val); 548 1.1 riastrad /* 549 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 550 1.1 riastrad * VDSC 551 1.1 riastrad */ 552 1.1 riastrad if (crtc_state->dsc.dsc_split) 553 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_1, pps_val); 554 1.1 riastrad } else { 555 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_1(pipe), pps_val); 556 1.1 riastrad if (crtc_state->dsc.dsc_split) 557 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_1(pipe), 558 1.1 riastrad pps_val); 559 1.1 riastrad } 560 1.1 riastrad 561 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_2 registers */ 562 1.1 riastrad pps_val = 0; 563 1.1 riastrad pps_val |= DSC_PIC_HEIGHT(vdsc_cfg->pic_height) | 564 1.1 riastrad DSC_PIC_WIDTH(vdsc_cfg->pic_width / num_vdsc_instances); 565 1.1 riastrad DRM_INFO("PPS2 = 0x%08x\n", pps_val); 566 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 567 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_2, pps_val); 568 1.1 riastrad /* 569 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 570 1.1 riastrad * VDSC 571 1.1 riastrad */ 572 1.1 riastrad if (crtc_state->dsc.dsc_split) 573 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_2, pps_val); 574 1.1 riastrad } else { 575 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_2(pipe), pps_val); 576 1.1 riastrad if (crtc_state->dsc.dsc_split) 577 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_2(pipe), 578 1.1 riastrad pps_val); 579 1.1 riastrad } 580 1.1 riastrad 581 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_3 registers */ 582 1.1 riastrad pps_val = 0; 583 1.1 riastrad pps_val |= DSC_SLICE_HEIGHT(vdsc_cfg->slice_height) | 584 1.1 riastrad DSC_SLICE_WIDTH(vdsc_cfg->slice_width); 585 1.1 riastrad DRM_INFO("PPS3 = 0x%08x\n", pps_val); 586 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 587 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_3, pps_val); 588 1.1 riastrad /* 589 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 590 1.1 riastrad * VDSC 591 1.1 riastrad */ 592 1.1 riastrad if (crtc_state->dsc.dsc_split) 593 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_3, pps_val); 594 1.1 riastrad } else { 595 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_3(pipe), pps_val); 596 1.1 riastrad if (crtc_state->dsc.dsc_split) 597 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_3(pipe), 598 1.1 riastrad pps_val); 599 1.1 riastrad } 600 1.1 riastrad 601 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_4 registers */ 602 1.1 riastrad pps_val = 0; 603 1.1 riastrad pps_val |= DSC_INITIAL_XMIT_DELAY(vdsc_cfg->initial_xmit_delay) | 604 1.1 riastrad DSC_INITIAL_DEC_DELAY(vdsc_cfg->initial_dec_delay); 605 1.1 riastrad DRM_INFO("PPS4 = 0x%08x\n", pps_val); 606 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 607 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_4, pps_val); 608 1.1 riastrad /* 609 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 610 1.1 riastrad * VDSC 611 1.1 riastrad */ 612 1.1 riastrad if (crtc_state->dsc.dsc_split) 613 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_4, pps_val); 614 1.1 riastrad } else { 615 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_4(pipe), pps_val); 616 1.1 riastrad if (crtc_state->dsc.dsc_split) 617 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_4(pipe), 618 1.1 riastrad pps_val); 619 1.1 riastrad } 620 1.1 riastrad 621 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_5 registers */ 622 1.1 riastrad pps_val = 0; 623 1.1 riastrad pps_val |= DSC_SCALE_INC_INT(vdsc_cfg->scale_increment_interval) | 624 1.1 riastrad DSC_SCALE_DEC_INT(vdsc_cfg->scale_decrement_interval); 625 1.1 riastrad DRM_INFO("PPS5 = 0x%08x\n", pps_val); 626 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 627 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_5, pps_val); 628 1.1 riastrad /* 629 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 630 1.1 riastrad * VDSC 631 1.1 riastrad */ 632 1.1 riastrad if (crtc_state->dsc.dsc_split) 633 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_5, pps_val); 634 1.1 riastrad } else { 635 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_5(pipe), pps_val); 636 1.1 riastrad if (crtc_state->dsc.dsc_split) 637 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_5(pipe), 638 1.1 riastrad pps_val); 639 1.1 riastrad } 640 1.1 riastrad 641 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_6 registers */ 642 1.1 riastrad pps_val = 0; 643 1.1 riastrad pps_val |= DSC_INITIAL_SCALE_VALUE(vdsc_cfg->initial_scale_value) | 644 1.1 riastrad DSC_FIRST_LINE_BPG_OFFSET(vdsc_cfg->first_line_bpg_offset) | 645 1.1 riastrad DSC_FLATNESS_MIN_QP(vdsc_cfg->flatness_min_qp) | 646 1.1 riastrad DSC_FLATNESS_MAX_QP(vdsc_cfg->flatness_max_qp); 647 1.1 riastrad DRM_INFO("PPS6 = 0x%08x\n", pps_val); 648 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 649 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_6, pps_val); 650 1.1 riastrad /* 651 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 652 1.1 riastrad * VDSC 653 1.1 riastrad */ 654 1.1 riastrad if (crtc_state->dsc.dsc_split) 655 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_6, pps_val); 656 1.1 riastrad } else { 657 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_6(pipe), pps_val); 658 1.1 riastrad if (crtc_state->dsc.dsc_split) 659 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_6(pipe), 660 1.1 riastrad pps_val); 661 1.1 riastrad } 662 1.1 riastrad 663 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_7 registers */ 664 1.1 riastrad pps_val = 0; 665 1.1 riastrad pps_val |= DSC_SLICE_BPG_OFFSET(vdsc_cfg->slice_bpg_offset) | 666 1.1 riastrad DSC_NFL_BPG_OFFSET(vdsc_cfg->nfl_bpg_offset); 667 1.1 riastrad DRM_INFO("PPS7 = 0x%08x\n", pps_val); 668 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 669 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_7, pps_val); 670 1.1 riastrad /* 671 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 672 1.1 riastrad * VDSC 673 1.1 riastrad */ 674 1.1 riastrad if (crtc_state->dsc.dsc_split) 675 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_7, pps_val); 676 1.1 riastrad } else { 677 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_7(pipe), pps_val); 678 1.1 riastrad if (crtc_state->dsc.dsc_split) 679 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_7(pipe), 680 1.1 riastrad pps_val); 681 1.1 riastrad } 682 1.1 riastrad 683 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_8 registers */ 684 1.1 riastrad pps_val = 0; 685 1.1 riastrad pps_val |= DSC_FINAL_OFFSET(vdsc_cfg->final_offset) | 686 1.1 riastrad DSC_INITIAL_OFFSET(vdsc_cfg->initial_offset); 687 1.1 riastrad DRM_INFO("PPS8 = 0x%08x\n", pps_val); 688 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 689 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_8, pps_val); 690 1.1 riastrad /* 691 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 692 1.1 riastrad * VDSC 693 1.1 riastrad */ 694 1.1 riastrad if (crtc_state->dsc.dsc_split) 695 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_8, pps_val); 696 1.1 riastrad } else { 697 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_8(pipe), pps_val); 698 1.1 riastrad if (crtc_state->dsc.dsc_split) 699 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_8(pipe), 700 1.1 riastrad pps_val); 701 1.1 riastrad } 702 1.1 riastrad 703 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_9 registers */ 704 1.1 riastrad pps_val = 0; 705 1.1 riastrad pps_val |= DSC_RC_MODEL_SIZE(DSC_RC_MODEL_SIZE_CONST) | 706 1.1 riastrad DSC_RC_EDGE_FACTOR(DSC_RC_EDGE_FACTOR_CONST); 707 1.1 riastrad DRM_INFO("PPS9 = 0x%08x\n", pps_val); 708 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 709 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_9, pps_val); 710 1.1 riastrad /* 711 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 712 1.1 riastrad * VDSC 713 1.1 riastrad */ 714 1.1 riastrad if (crtc_state->dsc.dsc_split) 715 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_9, pps_val); 716 1.1 riastrad } else { 717 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_9(pipe), pps_val); 718 1.1 riastrad if (crtc_state->dsc.dsc_split) 719 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_9(pipe), 720 1.1 riastrad pps_val); 721 1.1 riastrad } 722 1.1 riastrad 723 1.1 riastrad /* Populate PICTURE_PARAMETER_SET_10 registers */ 724 1.1 riastrad pps_val = 0; 725 1.1 riastrad pps_val |= DSC_RC_QUANT_INC_LIMIT0(vdsc_cfg->rc_quant_incr_limit0) | 726 1.1 riastrad DSC_RC_QUANT_INC_LIMIT1(vdsc_cfg->rc_quant_incr_limit1) | 727 1.1 riastrad DSC_RC_TARGET_OFF_HIGH(DSC_RC_TGT_OFFSET_HI_CONST) | 728 1.1 riastrad DSC_RC_TARGET_OFF_LOW(DSC_RC_TGT_OFFSET_LO_CONST); 729 1.1 riastrad DRM_INFO("PPS10 = 0x%08x\n", pps_val); 730 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 731 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_10, pps_val); 732 1.1 riastrad /* 733 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 734 1.1 riastrad * VDSC 735 1.1 riastrad */ 736 1.1 riastrad if (crtc_state->dsc.dsc_split) 737 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_10, pps_val); 738 1.1 riastrad } else { 739 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_10(pipe), pps_val); 740 1.1 riastrad if (crtc_state->dsc.dsc_split) 741 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_10(pipe), 742 1.1 riastrad pps_val); 743 1.1 riastrad } 744 1.1 riastrad 745 1.1 riastrad /* Populate Picture parameter set 16 */ 746 1.1 riastrad pps_val = 0; 747 1.1 riastrad pps_val |= DSC_SLICE_CHUNK_SIZE(vdsc_cfg->slice_chunk_size) | 748 1.1 riastrad DSC_SLICE_PER_LINE((vdsc_cfg->pic_width / num_vdsc_instances) / 749 1.1 riastrad vdsc_cfg->slice_width) | 750 1.1 riastrad DSC_SLICE_ROW_PER_FRAME(vdsc_cfg->pic_height / 751 1.1 riastrad vdsc_cfg->slice_height); 752 1.1 riastrad DRM_INFO("PPS16 = 0x%08x\n", pps_val); 753 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 754 1.1 riastrad I915_WRITE(DSCA_PICTURE_PARAMETER_SET_16, pps_val); 755 1.1 riastrad /* 756 1.1 riastrad * If 2 VDSC instances are needed, configure PPS for second 757 1.1 riastrad * VDSC 758 1.1 riastrad */ 759 1.1 riastrad if (crtc_state->dsc.dsc_split) 760 1.1 riastrad I915_WRITE(DSCC_PICTURE_PARAMETER_SET_16, pps_val); 761 1.1 riastrad } else { 762 1.1 riastrad I915_WRITE(ICL_DSC0_PICTURE_PARAMETER_SET_16(pipe), pps_val); 763 1.1 riastrad if (crtc_state->dsc.dsc_split) 764 1.1 riastrad I915_WRITE(ICL_DSC1_PICTURE_PARAMETER_SET_16(pipe), 765 1.1 riastrad pps_val); 766 1.1 riastrad } 767 1.1 riastrad 768 1.1 riastrad /* Populate the RC_BUF_THRESH registers */ 769 1.1 riastrad memset(rc_buf_thresh_dword, 0, sizeof(rc_buf_thresh_dword)); 770 1.1 riastrad for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++) { 771 1.1 riastrad rc_buf_thresh_dword[i / 4] |= 772 1.1 riastrad (u32)(vdsc_cfg->rc_buf_thresh[i] << 773 1.1 riastrad BITS_PER_BYTE * (i % 4)); 774 1.1 riastrad DRM_INFO(" RC_BUF_THRESH%d = 0x%08x\n", i, 775 1.1 riastrad rc_buf_thresh_dword[i / 4]); 776 1.1 riastrad } 777 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 778 1.1 riastrad I915_WRITE(DSCA_RC_BUF_THRESH_0, rc_buf_thresh_dword[0]); 779 1.1 riastrad I915_WRITE(DSCA_RC_BUF_THRESH_0_UDW, rc_buf_thresh_dword[1]); 780 1.1 riastrad I915_WRITE(DSCA_RC_BUF_THRESH_1, rc_buf_thresh_dword[2]); 781 1.1 riastrad I915_WRITE(DSCA_RC_BUF_THRESH_1_UDW, rc_buf_thresh_dword[3]); 782 1.1 riastrad if (crtc_state->dsc.dsc_split) { 783 1.1 riastrad I915_WRITE(DSCC_RC_BUF_THRESH_0, 784 1.1 riastrad rc_buf_thresh_dword[0]); 785 1.1 riastrad I915_WRITE(DSCC_RC_BUF_THRESH_0_UDW, 786 1.1 riastrad rc_buf_thresh_dword[1]); 787 1.1 riastrad I915_WRITE(DSCC_RC_BUF_THRESH_1, 788 1.1 riastrad rc_buf_thresh_dword[2]); 789 1.1 riastrad I915_WRITE(DSCC_RC_BUF_THRESH_1_UDW, 790 1.1 riastrad rc_buf_thresh_dword[3]); 791 1.1 riastrad } 792 1.1 riastrad } else { 793 1.1 riastrad I915_WRITE(ICL_DSC0_RC_BUF_THRESH_0(pipe), 794 1.1 riastrad rc_buf_thresh_dword[0]); 795 1.1 riastrad I915_WRITE(ICL_DSC0_RC_BUF_THRESH_0_UDW(pipe), 796 1.1 riastrad rc_buf_thresh_dword[1]); 797 1.1 riastrad I915_WRITE(ICL_DSC0_RC_BUF_THRESH_1(pipe), 798 1.1 riastrad rc_buf_thresh_dword[2]); 799 1.1 riastrad I915_WRITE(ICL_DSC0_RC_BUF_THRESH_1_UDW(pipe), 800 1.1 riastrad rc_buf_thresh_dword[3]); 801 1.1 riastrad if (crtc_state->dsc.dsc_split) { 802 1.1 riastrad I915_WRITE(ICL_DSC1_RC_BUF_THRESH_0(pipe), 803 1.1 riastrad rc_buf_thresh_dword[0]); 804 1.1 riastrad I915_WRITE(ICL_DSC1_RC_BUF_THRESH_0_UDW(pipe), 805 1.1 riastrad rc_buf_thresh_dword[1]); 806 1.1 riastrad I915_WRITE(ICL_DSC1_RC_BUF_THRESH_1(pipe), 807 1.1 riastrad rc_buf_thresh_dword[2]); 808 1.1 riastrad I915_WRITE(ICL_DSC1_RC_BUF_THRESH_1_UDW(pipe), 809 1.1 riastrad rc_buf_thresh_dword[3]); 810 1.1 riastrad } 811 1.1 riastrad } 812 1.1 riastrad 813 1.1 riastrad /* Populate the RC_RANGE_PARAMETERS registers */ 814 1.1 riastrad memset(rc_range_params_dword, 0, sizeof(rc_range_params_dword)); 815 1.1 riastrad for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { 816 1.1 riastrad rc_range_params_dword[i / 2] |= 817 1.1 riastrad (u32)(((vdsc_cfg->rc_range_params[i].range_bpg_offset << 818 1.1 riastrad RC_BPG_OFFSET_SHIFT) | 819 1.1 riastrad (vdsc_cfg->rc_range_params[i].range_max_qp << 820 1.1 riastrad RC_MAX_QP_SHIFT) | 821 1.1 riastrad (vdsc_cfg->rc_range_params[i].range_min_qp << 822 1.1 riastrad RC_MIN_QP_SHIFT)) << 16 * (i % 2)); 823 1.1 riastrad DRM_INFO(" RC_RANGE_PARAM_%d = 0x%08x\n", i, 824 1.1 riastrad rc_range_params_dword[i / 2]); 825 1.1 riastrad } 826 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 827 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_0, 828 1.1 riastrad rc_range_params_dword[0]); 829 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_0_UDW, 830 1.1 riastrad rc_range_params_dword[1]); 831 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_1, 832 1.1 riastrad rc_range_params_dword[2]); 833 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_1_UDW, 834 1.1 riastrad rc_range_params_dword[3]); 835 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_2, 836 1.1 riastrad rc_range_params_dword[4]); 837 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_2_UDW, 838 1.1 riastrad rc_range_params_dword[5]); 839 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_3, 840 1.1 riastrad rc_range_params_dword[6]); 841 1.1 riastrad I915_WRITE(DSCA_RC_RANGE_PARAMETERS_3_UDW, 842 1.1 riastrad rc_range_params_dword[7]); 843 1.1 riastrad if (crtc_state->dsc.dsc_split) { 844 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_0, 845 1.1 riastrad rc_range_params_dword[0]); 846 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_0_UDW, 847 1.1 riastrad rc_range_params_dword[1]); 848 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_1, 849 1.1 riastrad rc_range_params_dword[2]); 850 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_1_UDW, 851 1.1 riastrad rc_range_params_dword[3]); 852 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_2, 853 1.1 riastrad rc_range_params_dword[4]); 854 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_2_UDW, 855 1.1 riastrad rc_range_params_dword[5]); 856 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_3, 857 1.1 riastrad rc_range_params_dword[6]); 858 1.1 riastrad I915_WRITE(DSCC_RC_RANGE_PARAMETERS_3_UDW, 859 1.1 riastrad rc_range_params_dword[7]); 860 1.1 riastrad } 861 1.1 riastrad } else { 862 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_0(pipe), 863 1.1 riastrad rc_range_params_dword[0]); 864 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_0_UDW(pipe), 865 1.1 riastrad rc_range_params_dword[1]); 866 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_1(pipe), 867 1.1 riastrad rc_range_params_dword[2]); 868 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_1_UDW(pipe), 869 1.1 riastrad rc_range_params_dword[3]); 870 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_2(pipe), 871 1.1 riastrad rc_range_params_dword[4]); 872 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_2_UDW(pipe), 873 1.1 riastrad rc_range_params_dword[5]); 874 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_3(pipe), 875 1.1 riastrad rc_range_params_dword[6]); 876 1.1 riastrad I915_WRITE(ICL_DSC0_RC_RANGE_PARAMETERS_3_UDW(pipe), 877 1.1 riastrad rc_range_params_dword[7]); 878 1.1 riastrad if (crtc_state->dsc.dsc_split) { 879 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_0(pipe), 880 1.1 riastrad rc_range_params_dword[0]); 881 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_0_UDW(pipe), 882 1.1 riastrad rc_range_params_dword[1]); 883 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_1(pipe), 884 1.1 riastrad rc_range_params_dword[2]); 885 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_1_UDW(pipe), 886 1.1 riastrad rc_range_params_dword[3]); 887 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_2(pipe), 888 1.1 riastrad rc_range_params_dword[4]); 889 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_2_UDW(pipe), 890 1.1 riastrad rc_range_params_dword[5]); 891 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_3(pipe), 892 1.1 riastrad rc_range_params_dword[6]); 893 1.1 riastrad I915_WRITE(ICL_DSC1_RC_RANGE_PARAMETERS_3_UDW(pipe), 894 1.1 riastrad rc_range_params_dword[7]); 895 1.1 riastrad } 896 1.1 riastrad } 897 1.1 riastrad } 898 1.1 riastrad 899 1.1 riastrad void intel_dsc_get_config(struct intel_encoder *encoder, 900 1.1 riastrad struct intel_crtc_state *crtc_state) 901 1.1 riastrad { 902 1.1 riastrad struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 903 1.1 riastrad struct drm_dsc_config *vdsc_cfg = &crtc_state->dsc.config; 904 1.1 riastrad struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 905 1.1 riastrad enum pipe pipe = crtc->pipe; 906 1.1 riastrad enum intel_display_power_domain power_domain; 907 1.1 riastrad intel_wakeref_t wakeref; 908 1.1 riastrad u32 dss_ctl1, dss_ctl2, val; 909 1.1 riastrad 910 1.1 riastrad if (!intel_dsc_source_support(encoder, crtc_state)) 911 1.1 riastrad return; 912 1.1 riastrad 913 1.1 riastrad power_domain = intel_dsc_power_domain(crtc_state); 914 1.1 riastrad 915 1.1 riastrad wakeref = intel_display_power_get_if_enabled(dev_priv, power_domain); 916 1.1 riastrad if (!wakeref) 917 1.1 riastrad return; 918 1.1 riastrad 919 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 920 1.1 riastrad dss_ctl1 = I915_READ(DSS_CTL1); 921 1.1 riastrad dss_ctl2 = I915_READ(DSS_CTL2); 922 1.1 riastrad } else { 923 1.1 riastrad dss_ctl1 = I915_READ(ICL_PIPE_DSS_CTL1(pipe)); 924 1.1 riastrad dss_ctl2 = I915_READ(ICL_PIPE_DSS_CTL2(pipe)); 925 1.1 riastrad } 926 1.1 riastrad 927 1.1 riastrad crtc_state->dsc.compression_enable = dss_ctl2 & LEFT_BRANCH_VDSC_ENABLE; 928 1.1 riastrad if (!crtc_state->dsc.compression_enable) 929 1.1 riastrad goto out; 930 1.1 riastrad 931 1.1 riastrad crtc_state->dsc.dsc_split = (dss_ctl2 & RIGHT_BRANCH_VDSC_ENABLE) && 932 1.1 riastrad (dss_ctl1 & JOINER_ENABLE); 933 1.1 riastrad 934 1.1 riastrad /* FIXME: add more state readout as needed */ 935 1.1 riastrad 936 1.1 riastrad /* PPS1 */ 937 1.1 riastrad if (!is_pipe_dsc(crtc_state)) 938 1.1 riastrad val = I915_READ(DSCA_PICTURE_PARAMETER_SET_1); 939 1.1 riastrad else 940 1.1 riastrad val = I915_READ(ICL_DSC0_PICTURE_PARAMETER_SET_1(pipe)); 941 1.1 riastrad vdsc_cfg->bits_per_pixel = val; 942 1.1 riastrad crtc_state->dsc.compressed_bpp = vdsc_cfg->bits_per_pixel >> 4; 943 1.1 riastrad out: 944 1.1 riastrad intel_display_power_put(dev_priv, power_domain, wakeref); 945 1.1 riastrad } 946 1.1 riastrad 947 1.1 riastrad static void intel_dsc_dsi_pps_write(struct intel_encoder *encoder, 948 1.1 riastrad const struct intel_crtc_state *crtc_state) 949 1.1 riastrad { 950 1.1 riastrad const struct drm_dsc_config *vdsc_cfg = &crtc_state->dsc.config; 951 1.1 riastrad struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder); 952 1.1 riastrad struct mipi_dsi_device *dsi; 953 1.1 riastrad struct drm_dsc_picture_parameter_set pps; 954 1.1 riastrad enum port port; 955 1.1 riastrad 956 1.1 riastrad drm_dsc_pps_payload_pack(&pps, vdsc_cfg); 957 1.1 riastrad 958 1.1 riastrad for_each_dsi_port(port, intel_dsi->ports) { 959 1.1 riastrad dsi = intel_dsi->dsi_hosts[port]->device; 960 1.1 riastrad 961 1.1 riastrad mipi_dsi_picture_parameter_set(dsi, &pps); 962 1.1 riastrad mipi_dsi_compression_mode(dsi, true); 963 1.1 riastrad } 964 1.1 riastrad } 965 1.1 riastrad 966 1.1 riastrad static void intel_dsc_dp_pps_write(struct intel_encoder *encoder, 967 1.1 riastrad const struct intel_crtc_state *crtc_state) 968 1.1 riastrad { 969 1.1 riastrad struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 970 1.1 riastrad struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); 971 1.1 riastrad const struct drm_dsc_config *vdsc_cfg = &crtc_state->dsc.config; 972 1.1 riastrad struct drm_dsc_pps_infoframe dp_dsc_pps_sdp; 973 1.1 riastrad 974 1.1 riastrad /* Prepare DP SDP PPS header as per DP 1.4 spec, Table 2-123 */ 975 1.1 riastrad drm_dsc_dp_pps_header_init(&dp_dsc_pps_sdp.pps_header); 976 1.1 riastrad 977 1.1 riastrad /* Fill the PPS payload bytes as per DSC spec 1.2 Table 4-1 */ 978 1.1 riastrad drm_dsc_pps_payload_pack(&dp_dsc_pps_sdp.pps_payload, vdsc_cfg); 979 1.1 riastrad 980 1.1 riastrad intel_dig_port->write_infoframe(encoder, crtc_state, 981 1.1 riastrad DP_SDP_PPS, &dp_dsc_pps_sdp, 982 1.1 riastrad sizeof(dp_dsc_pps_sdp)); 983 1.1 riastrad } 984 1.1 riastrad 985 1.1 riastrad void intel_dsc_enable(struct intel_encoder *encoder, 986 1.1 riastrad const struct intel_crtc_state *crtc_state) 987 1.1 riastrad { 988 1.1 riastrad struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 989 1.1 riastrad struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 990 1.1 riastrad enum pipe pipe = crtc->pipe; 991 1.1 riastrad i915_reg_t dss_ctl1_reg, dss_ctl2_reg; 992 1.1 riastrad u32 dss_ctl1_val = 0; 993 1.1 riastrad u32 dss_ctl2_val = 0; 994 1.1 riastrad 995 1.1 riastrad if (!crtc_state->dsc.compression_enable) 996 1.1 riastrad return; 997 1.1 riastrad 998 1.1 riastrad /* Enable Power wells for VDSC/joining */ 999 1.1 riastrad intel_display_power_get(dev_priv, 1000 1.1 riastrad intel_dsc_power_domain(crtc_state)); 1001 1.1 riastrad 1002 1.1 riastrad intel_dsc_pps_configure(encoder, crtc_state); 1003 1.1 riastrad 1004 1.1 riastrad if (encoder->type == INTEL_OUTPUT_DSI) 1005 1.1 riastrad intel_dsc_dsi_pps_write(encoder, crtc_state); 1006 1.1 riastrad else 1007 1.1 riastrad intel_dsc_dp_pps_write(encoder, crtc_state); 1008 1.1 riastrad 1009 1.1 riastrad if (!is_pipe_dsc(crtc_state)) { 1010 1.1 riastrad dss_ctl1_reg = DSS_CTL1; 1011 1.1 riastrad dss_ctl2_reg = DSS_CTL2; 1012 1.1 riastrad } else { 1013 1.1 riastrad dss_ctl1_reg = ICL_PIPE_DSS_CTL1(pipe); 1014 1.1 riastrad dss_ctl2_reg = ICL_PIPE_DSS_CTL2(pipe); 1015 1.1 riastrad } 1016 1.1 riastrad dss_ctl2_val |= LEFT_BRANCH_VDSC_ENABLE; 1017 1.1 riastrad if (crtc_state->dsc.dsc_split) { 1018 1.1 riastrad dss_ctl2_val |= RIGHT_BRANCH_VDSC_ENABLE; 1019 1.1 riastrad dss_ctl1_val |= JOINER_ENABLE; 1020 1.1 riastrad } 1021 1.1 riastrad I915_WRITE(dss_ctl1_reg, dss_ctl1_val); 1022 1.1 riastrad I915_WRITE(dss_ctl2_reg, dss_ctl2_val); 1023 1.1 riastrad } 1024 1.1 riastrad 1025 1.1 riastrad void intel_dsc_disable(const struct intel_crtc_state *old_crtc_state) 1026 1.1 riastrad { 1027 1.1 riastrad struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc); 1028 1.1 riastrad struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 1029 1.1 riastrad enum pipe pipe = crtc->pipe; 1030 1.1 riastrad i915_reg_t dss_ctl1_reg, dss_ctl2_reg; 1031 1.1 riastrad u32 dss_ctl1_val = 0, dss_ctl2_val = 0; 1032 1.1 riastrad 1033 1.1 riastrad if (!old_crtc_state->dsc.compression_enable) 1034 1.1 riastrad return; 1035 1.1 riastrad 1036 1.1 riastrad if (!is_pipe_dsc(old_crtc_state)) { 1037 1.1 riastrad dss_ctl1_reg = DSS_CTL1; 1038 1.1 riastrad dss_ctl2_reg = DSS_CTL2; 1039 1.1 riastrad } else { 1040 1.1 riastrad dss_ctl1_reg = ICL_PIPE_DSS_CTL1(pipe); 1041 1.1 riastrad dss_ctl2_reg = ICL_PIPE_DSS_CTL2(pipe); 1042 1.1 riastrad } 1043 1.1 riastrad dss_ctl1_val = I915_READ(dss_ctl1_reg); 1044 1.1 riastrad if (dss_ctl1_val & JOINER_ENABLE) 1045 1.1 riastrad dss_ctl1_val &= ~JOINER_ENABLE; 1046 1.1 riastrad I915_WRITE(dss_ctl1_reg, dss_ctl1_val); 1047 1.1 riastrad 1048 1.1 riastrad dss_ctl2_val = I915_READ(dss_ctl2_reg); 1049 1.1 riastrad if (dss_ctl2_val & LEFT_BRANCH_VDSC_ENABLE || 1050 1.1 riastrad dss_ctl2_val & RIGHT_BRANCH_VDSC_ENABLE) 1051 1.1 riastrad dss_ctl2_val &= ~(LEFT_BRANCH_VDSC_ENABLE | 1052 1.1 riastrad RIGHT_BRANCH_VDSC_ENABLE); 1053 1.1 riastrad I915_WRITE(dss_ctl2_reg, dss_ctl2_val); 1054 1.1 riastrad 1055 1.1 riastrad /* Disable Power wells for VDSC/joining */ 1056 1.1 riastrad intel_display_power_put_unchecked(dev_priv, 1057 1.1 riastrad intel_dsc_power_domain(old_crtc_state)); 1058 1.1 riastrad } 1059