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

drm/dsc: Split DSC PPS and SDP header initialisations

The DP 1.4 spec defines the SDP header and SDP contents for
a Picture Parameter Set (PPS) that must be sent in advance
of DSC transmission to define the encoding characteristics.

This was done in one struct, drm_dsc_pps_infoframe, which
conatined the SDP header and PPS. Because the PPS is
a property of DSC over any connector, not just DP, and because
drm drivers may have their own SDP structs they wish to use,
make the functions that initialise SDP and PPS headers take
the components they operate on, not drm_dsc_pps_infoframe,

Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Manasi Navare <manasi.d.navare@intel.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190221202001.28430-4-David.Francis@amd.com

authored by

David Francis and committed by
Harry Wentland
dbfbe717 06d7cecd

+62 -63
+58 -59
drivers/gpu/drm/drm_dsc.c
··· 32 32 /** 33 33 * drm_dsc_dp_pps_header_init() - Initializes the PPS Header 34 34 * for DisplayPort as per the DP 1.4 spec. 35 - * @pps_sdp: Secondary data packet for DSC Picture Parameter Set 36 - * as defined in &struct drm_dsc_pps_infoframe 35 + * @pps_header: Secondary data packet header for DSC Picture 36 + * Parameter Set as defined in &struct dp_sdp_header 37 37 * 38 38 * DP 1.4 spec defines the secondary data packet for sending the 39 39 * picture parameter infoframes from the source to the sink. 40 - * This function populates the pps header defined in 41 - * &struct drm_dsc_pps_infoframe as per the header bytes defined 42 - * in &struct dp_sdp_header. 40 + * This function populates the SDP header defined in 41 + * &struct dp_sdp_header. 43 42 */ 44 - void drm_dsc_dp_pps_header_init(struct drm_dsc_pps_infoframe *pps_sdp) 43 + void drm_dsc_dp_pps_header_init(struct dp_sdp_header *pps_header) 45 44 { 46 - memset(&pps_sdp->pps_header, 0, sizeof(pps_sdp->pps_header)); 45 + memset(pps_header, 0, sizeof(*pps_header)); 47 46 48 - pps_sdp->pps_header.HB1 = DP_SDP_PPS; 49 - pps_sdp->pps_header.HB2 = DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1; 47 + pps_header->HB1 = DP_SDP_PPS; 48 + pps_header->HB2 = DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1; 50 49 } 51 50 EXPORT_SYMBOL(drm_dsc_dp_pps_header_init); 52 51 53 52 /** 54 - * drm_dsc_pps_infoframe_pack() - Populates the DSC PPS infoframe 53 + * drm_dsc_pps_payload_pack() - Populates the DSC PPS 55 54 * 56 - * @pps_sdp: 57 - * Secondary data packet for DSC Picture Parameter Set. This is defined 58 - * by &struct drm_dsc_pps_infoframe 55 + * @pps_payload: 56 + * Bitwise struct for DSC Picture Parameter Set. This is defined 57 + * by &struct drm_dsc_picture_parameter_set 59 58 * @dsc_cfg: 60 59 * DSC Configuration data filled by driver as defined by 61 60 * &struct drm_dsc_config 62 61 * 63 - * DSC source device sends a secondary data packet filled with all the 64 - * picture parameter set (PPS) information required by the sink to decode 65 - * the compressed frame. Driver populates the dsC PPS infoframe using the DSC 66 - * configuration parameters in the order expected by the DSC Display Sink 67 - * device. For the DSC, the sink device expects the PPS payload in the big 68 - * endian format for the fields that span more than 1 byte. 62 + * DSC source device sends a picture parameter set (PPS) containing the 63 + * information required by the sink to decode the compressed frame. Driver 64 + * populates the DSC PPS struct using the DSC configuration parameters in 65 + * the order expected by the DSC Display Sink device. For the DSC, the sink 66 + * device expects the PPS payload in big endian format for fields 67 + * that span more than 1 byte. 69 68 */ 70 - void drm_dsc_pps_infoframe_pack(struct drm_dsc_pps_infoframe *pps_sdp, 69 + void drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set *pps_payload, 71 70 const struct drm_dsc_config *dsc_cfg) 72 71 { 73 72 int i; 74 73 75 74 /* Protect against someone accidently changing struct size */ 76 - BUILD_BUG_ON(sizeof(pps_sdp->pps_payload) != 75 + BUILD_BUG_ON(sizeof(*pps_payload) != 77 76 DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1 + 1); 78 77 79 - memset(&pps_sdp->pps_payload, 0, sizeof(pps_sdp->pps_payload)); 78 + memset(pps_payload, 0, sizeof(*pps_payload)); 80 79 81 80 /* PPS 0 */ 82 - pps_sdp->pps_payload.dsc_version = 81 + pps_payload->dsc_version = 83 82 dsc_cfg->dsc_version_minor | 84 83 dsc_cfg->dsc_version_major << DSC_PPS_VERSION_MAJOR_SHIFT; 85 84 86 85 /* PPS 1, 2 is 0 */ 87 86 88 87 /* PPS 3 */ 89 - pps_sdp->pps_payload.pps_3 = 88 + pps_payload->pps_3 = 90 89 dsc_cfg->line_buf_depth | 91 90 dsc_cfg->bits_per_component << DSC_PPS_BPC_SHIFT; 92 91 93 92 /* PPS 4 */ 94 - pps_sdp->pps_payload.pps_4 = 93 + pps_payload->pps_4 = 95 94 ((dsc_cfg->bits_per_pixel & DSC_PPS_BPP_HIGH_MASK) >> 96 95 DSC_PPS_MSB_SHIFT) | 97 96 dsc_cfg->vbr_enable << DSC_PPS_VBR_EN_SHIFT | ··· 99 100 dsc_cfg->block_pred_enable << DSC_PPS_BLOCK_PRED_EN_SHIFT; 100 101 101 102 /* PPS 5 */ 102 - pps_sdp->pps_payload.bits_per_pixel_low = 103 + pps_payload->bits_per_pixel_low = 103 104 (dsc_cfg->bits_per_pixel & DSC_PPS_LSB_MASK); 104 105 105 106 /* ··· 110 111 */ 111 112 112 113 /* PPS 6, 7 */ 113 - pps_sdp->pps_payload.pic_height = cpu_to_be16(dsc_cfg->pic_height); 114 + pps_payload->pic_height = cpu_to_be16(dsc_cfg->pic_height); 114 115 115 116 /* PPS 8, 9 */ 116 - pps_sdp->pps_payload.pic_width = cpu_to_be16(dsc_cfg->pic_width); 117 + pps_payload->pic_width = cpu_to_be16(dsc_cfg->pic_width); 117 118 118 119 /* PPS 10, 11 */ 119 - pps_sdp->pps_payload.slice_height = cpu_to_be16(dsc_cfg->slice_height); 120 + pps_payload->slice_height = cpu_to_be16(dsc_cfg->slice_height); 120 121 121 122 /* PPS 12, 13 */ 122 - pps_sdp->pps_payload.slice_width = cpu_to_be16(dsc_cfg->slice_width); 123 + pps_payload->slice_width = cpu_to_be16(dsc_cfg->slice_width); 123 124 124 125 /* PPS 14, 15 */ 125 - pps_sdp->pps_payload.chunk_size = cpu_to_be16(dsc_cfg->slice_chunk_size); 126 + pps_payload->chunk_size = cpu_to_be16(dsc_cfg->slice_chunk_size); 126 127 127 128 /* PPS 16 */ 128 - pps_sdp->pps_payload.initial_xmit_delay_high = 129 + pps_payload->initial_xmit_delay_high = 129 130 ((dsc_cfg->initial_xmit_delay & 130 131 DSC_PPS_INIT_XMIT_DELAY_HIGH_MASK) >> 131 132 DSC_PPS_MSB_SHIFT); 132 133 133 134 /* PPS 17 */ 134 - pps_sdp->pps_payload.initial_xmit_delay_low = 135 + pps_payload->initial_xmit_delay_low = 135 136 (dsc_cfg->initial_xmit_delay & DSC_PPS_LSB_MASK); 136 137 137 138 /* PPS 18, 19 */ 138 - pps_sdp->pps_payload.initial_dec_delay = 139 + pps_payload->initial_dec_delay = 139 140 cpu_to_be16(dsc_cfg->initial_dec_delay); 140 141 141 142 /* PPS 20 is 0 */ 142 143 143 144 /* PPS 21 */ 144 - pps_sdp->pps_payload.initial_scale_value = 145 + pps_payload->initial_scale_value = 145 146 dsc_cfg->initial_scale_value; 146 147 147 148 /* PPS 22, 23 */ 148 - pps_sdp->pps_payload.scale_increment_interval = 149 + pps_payload->scale_increment_interval = 149 150 cpu_to_be16(dsc_cfg->scale_increment_interval); 150 151 151 152 /* PPS 24 */ 152 - pps_sdp->pps_payload.scale_decrement_interval_high = 153 + pps_payload->scale_decrement_interval_high = 153 154 ((dsc_cfg->scale_decrement_interval & 154 155 DSC_PPS_SCALE_DEC_INT_HIGH_MASK) >> 155 156 DSC_PPS_MSB_SHIFT); 156 157 157 158 /* PPS 25 */ 158 - pps_sdp->pps_payload.scale_decrement_interval_low = 159 + pps_payload->scale_decrement_interval_low = 159 160 (dsc_cfg->scale_decrement_interval & DSC_PPS_LSB_MASK); 160 161 161 162 /* PPS 26[7:0], PPS 27[7:5] RESERVED */ 162 163 163 164 /* PPS 27 */ 164 - pps_sdp->pps_payload.first_line_bpg_offset = 165 + pps_payload->first_line_bpg_offset = 165 166 dsc_cfg->first_line_bpg_offset; 166 167 167 168 /* PPS 28, 29 */ 168 - pps_sdp->pps_payload.nfl_bpg_offset = 169 + pps_payload->nfl_bpg_offset = 169 170 cpu_to_be16(dsc_cfg->nfl_bpg_offset); 170 171 171 172 /* PPS 30, 31 */ 172 - pps_sdp->pps_payload.slice_bpg_offset = 173 + pps_payload->slice_bpg_offset = 173 174 cpu_to_be16(dsc_cfg->slice_bpg_offset); 174 175 175 176 /* PPS 32, 33 */ 176 - pps_sdp->pps_payload.initial_offset = 177 + pps_payload->initial_offset = 177 178 cpu_to_be16(dsc_cfg->initial_offset); 178 179 179 180 /* PPS 34, 35 */ 180 - pps_sdp->pps_payload.final_offset = cpu_to_be16(dsc_cfg->final_offset); 181 + pps_payload->final_offset = cpu_to_be16(dsc_cfg->final_offset); 181 182 182 183 /* PPS 36 */ 183 - pps_sdp->pps_payload.flatness_min_qp = dsc_cfg->flatness_min_qp; 184 + pps_payload->flatness_min_qp = dsc_cfg->flatness_min_qp; 184 185 185 186 /* PPS 37 */ 186 - pps_sdp->pps_payload.flatness_max_qp = dsc_cfg->flatness_max_qp; 187 + pps_payload->flatness_max_qp = dsc_cfg->flatness_max_qp; 187 188 188 189 /* PPS 38, 39 */ 189 - pps_sdp->pps_payload.rc_model_size = 190 + pps_payload->rc_model_size = 190 191 cpu_to_be16(DSC_RC_MODEL_SIZE_CONST); 191 192 192 193 /* PPS 40 */ 193 - pps_sdp->pps_payload.rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST; 194 + pps_payload->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST; 194 195 195 196 /* PPS 41 */ 196 - pps_sdp->pps_payload.rc_quant_incr_limit0 = 197 + pps_payload->rc_quant_incr_limit0 = 197 198 dsc_cfg->rc_quant_incr_limit0; 198 199 199 200 /* PPS 42 */ 200 - pps_sdp->pps_payload.rc_quant_incr_limit1 = 201 + pps_payload->rc_quant_incr_limit1 = 201 202 dsc_cfg->rc_quant_incr_limit1; 202 203 203 204 /* PPS 43 */ 204 - pps_sdp->pps_payload.rc_tgt_offset = DSC_RC_TGT_OFFSET_LO_CONST | 205 + pps_payload->rc_tgt_offset = DSC_RC_TGT_OFFSET_LO_CONST | 205 206 DSC_RC_TGT_OFFSET_HI_CONST << DSC_PPS_RC_TGT_OFFSET_HI_SHIFT; 206 207 207 208 /* PPS 44 - 57 */ 208 209 for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++) 209 - pps_sdp->pps_payload.rc_buf_thresh[i] = 210 + pps_payload->rc_buf_thresh[i] = 210 211 dsc_cfg->rc_buf_thresh[i]; 211 212 212 213 /* PPS 58 - 87 */ ··· 215 216 * are as follows: Min_qp[15:11], max_qp[10:6], offset[5:0] 216 217 */ 217 218 for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { 218 - pps_sdp->pps_payload.rc_range_parameters[i] = 219 + pps_payload->rc_range_parameters[i] = 219 220 ((dsc_cfg->rc_range_params[i].range_min_qp << 220 221 DSC_PPS_RC_RANGE_MINQP_SHIFT) | 221 222 (dsc_cfg->rc_range_params[i].range_max_qp << 222 223 DSC_PPS_RC_RANGE_MAXQP_SHIFT) | 223 224 (dsc_cfg->rc_range_params[i].range_bpg_offset)); 224 - pps_sdp->pps_payload.rc_range_parameters[i] = 225 - cpu_to_be16(pps_sdp->pps_payload.rc_range_parameters[i]); 225 + pps_payload->rc_range_parameters[i] = 226 + cpu_to_be16(pps_payload->rc_range_parameters[i]); 226 227 } 227 228 228 229 /* PPS 88 */ 229 - pps_sdp->pps_payload.native_422_420 = dsc_cfg->native_422 | 230 + pps_payload->native_422_420 = dsc_cfg->native_422 | 230 231 dsc_cfg->native_420 << DSC_PPS_NATIVE_420_SHIFT; 231 232 232 233 /* PPS 89 */ 233 - pps_sdp->pps_payload.second_line_bpg_offset = 234 + pps_payload->second_line_bpg_offset = 234 235 dsc_cfg->second_line_bpg_offset; 235 236 236 237 /* PPS 90, 91 */ 237 - pps_sdp->pps_payload.nsl_bpg_offset = 238 + pps_payload->nsl_bpg_offset = 238 239 cpu_to_be16(dsc_cfg->nsl_bpg_offset); 239 240 240 241 /* PPS 92, 93 */ 241 - pps_sdp->pps_payload.second_line_offset_adj = 242 + pps_payload->second_line_offset_adj = 242 243 cpu_to_be16(dsc_cfg->second_line_offset_adj); 243 244 244 245 /* PPS 94 - 127 are O */ 245 246 } 246 - EXPORT_SYMBOL(drm_dsc_pps_infoframe_pack); 247 + EXPORT_SYMBOL(drm_dsc_pps_payload_pack); 247 248 248 249 /** 249 250 * drm_dsc_compute_rc_parameters() - Write rate control
+2 -2
drivers/gpu/drm/i915/intel_vdsc.c
··· 881 881 struct drm_dsc_pps_infoframe dp_dsc_pps_sdp; 882 882 883 883 /* Prepare DP SDP PPS header as per DP 1.4 spec, Table 2-123 */ 884 - drm_dsc_dp_pps_header_init(&dp_dsc_pps_sdp); 884 + drm_dsc_dp_pps_header_init(&dp_dsc_pps_sdp.pps_header); 885 885 886 886 /* Fill the PPS payload bytes as per DSC spec 1.2 Table 4-1 */ 887 - drm_dsc_pps_infoframe_pack(&dp_dsc_pps_sdp, vdsc_cfg); 887 + drm_dsc_pps_payload_pack(&dp_dsc_pps_sdp.pps_payload, vdsc_cfg); 888 888 889 889 intel_dig_port->write_infoframe(encoder, crtc_state, 890 890 DP_SDP_PPS, &dp_dsc_pps_sdp,
+2 -2
include/drm/drm_dsc.h
··· 601 601 struct drm_dsc_picture_parameter_set pps_payload; 602 602 } __packed; 603 603 604 - void drm_dsc_dp_pps_header_init(struct drm_dsc_pps_infoframe *pps_sdp); 605 - void drm_dsc_pps_infoframe_pack(struct drm_dsc_pps_infoframe *pps_sdp, 604 + void drm_dsc_dp_pps_header_init(struct dp_sdp_header *pps_header); 605 + void drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set *pps_sdp, 606 606 const struct drm_dsc_config *dsc_cfg); 607 607 int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg); 608 608