Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/dsc/mtl: Add support for fractional bpp

Consider the fractional bpp while reading the qp values.

v2: Use helpers for fractional, integral bits of bits_per_pixel. (Suraj)

Signed-off-by: Vandita Kulkarni <vandita.kulkarni@intel.com>
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
Link: https://patchwork.freedesktop.org/patch/msgid/20231110101020.4067342-6-ankit.k.nautiyal@intel.com

authored by

Vandita Kulkarni and committed by
Ankit Nautiyal
2df50cb4 08fcb5ab

+20 -8
-3
drivers/gpu/drm/i915/display/intel_qp_tables.c
··· 34 34 * These qp tables are as per the C model 35 35 * and it has the rows pointing to bpps which increment 36 36 * in steps of 0.5 37 - * We do not support fractional bpps as of today, 38 - * hence we would skip the fractional bpps during 39 - * our references for qp calclulations. 40 37 */ 41 38 static const u8 rc_range_minqp444_8bpc[DSC_NUM_BUF_RANGES][RC_RANGE_QP444_8BPC_MAX_NUM_BPP] = { 42 39 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+20 -5
drivers/gpu/drm/i915/display/intel_vdsc.c
··· 77 77 static void 78 78 calculate_rc_params(struct drm_dsc_config *vdsc_cfg) 79 79 { 80 + int bpp = to_bpp_int(vdsc_cfg->bits_per_pixel); 80 81 int bpc = vdsc_cfg->bits_per_component; 81 - int bpp = vdsc_cfg->bits_per_pixel >> 4; 82 82 int qp_bpc_modifier = (bpc - 8) * 2; 83 83 int uncompressed_bpg_rate; 84 84 int first_line_bpg_offset; ··· 148 148 static const s8 ofs_und8[] = { 149 149 10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10, -10, -12, -12, -12 150 150 }; 151 - 151 + /* 152 + * For 420 format since bits_per_pixel (bpp) is set to target bpp * 2, 153 + * QP table values for target bpp 4.0 to 4.4375 (rounded to 4.0) are 154 + * actually for bpp 8 to 8.875 (rounded to 4.0 * 2 i.e 8). 155 + * Similarly values for target bpp 4.5 to 4.8375 (rounded to 4.5) 156 + * are for bpp 9 to 9.875 (rounded to 4.5 * 2 i.e 9), and so on. 157 + */ 152 158 bpp_i = bpp - 8; 153 159 for (buf_i = 0; buf_i < DSC_NUM_BUF_RANGES; buf_i++) { 154 160 u8 range_bpg_offset; ··· 184 178 range_bpg_offset & DSC_RANGE_BPG_OFFSET_MASK; 185 179 } 186 180 } else { 181 + /* fractional bpp part * 10000 (for precision up to 4 decimal places) */ 182 + int fractional_bits = to_bpp_frac(vdsc_cfg->bits_per_pixel); 183 + 187 184 static const s8 ofs_und6[] = { 188 185 0, -2, -2, -4, -6, -6, -8, -8, -8, -10, -10, -12, -12, -12, -12 189 186 }; ··· 200 191 10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10, -10, -12, -12, -12 201 192 }; 202 193 203 - bpp_i = (2 * (bpp - 6)); 194 + /* 195 + * QP table rows have values in increment of 0.5. 196 + * So 6.0 bpp to 6.4375 will have index 0, 6.5 to 6.9375 will have index 1, 197 + * and so on. 198 + * 0.5 fractional part with 4 decimal precision becomes 5000 199 + */ 200 + bpp_i = ((bpp - 6) + (fractional_bits < 5000 ? 0 : 1)); 201 + 204 202 for (buf_i = 0; buf_i < DSC_NUM_BUF_RANGES; buf_i++) { 205 203 u8 range_bpg_offset; 206 204 ··· 295 279 /* Gen 11 does not support VBR */ 296 280 vdsc_cfg->vbr_enable = false; 297 281 298 - /* Gen 11 only supports integral values of bpp */ 299 - vdsc_cfg->bits_per_pixel = compressed_bpp << 4; 282 + vdsc_cfg->bits_per_pixel = pipe_config->dsc.compressed_bpp_x16; 300 283 301 284 /* 302 285 * According to DSC 1.2 specs in Section 4.1 if native_420 is set