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

drm/amd/display: Info frame cleanup

* Use provided infopacket in stream (if valid) instead of reconstructing
in set_vendor_info_packet()
* Use proper format for enums
* Use dc info packet struct instead

Signed-off-by: Harmanprit Tatla <Harmanprit.Tatla@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Harmanprit Tatla and committed by
Alex Deucher
ecd0136b 242b0c8f

+42 -142
+4 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 72 72 73 73 #include "modules/inc/mod_freesync.h" 74 74 #include "modules/power/power_helpers.h" 75 + #include "modules/inc/mod_info_packet.h" 75 76 76 77 #define FIRMWARE_RAVEN_DMCU "amdgpu/raven_dmcu.bin" 77 78 MODULE_FIRMWARE(FIRMWARE_RAVEN_DMCU); ··· 2931 2930 2932 2931 if (dm_state && dm_state->freesync_capable) 2933 2932 stream->ignore_msa_timing_param = true; 2933 + 2934 2934 finish: 2935 2935 if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL && aconnector->base.force != DRM_FORCE_ON) 2936 2936 dc_sink_release(sink); ··· 4425 4423 dm->freesync_module, 4426 4424 new_stream, 4427 4425 &vrr, 4428 - packet_type_vrr, 4429 - transfer_func_unknown, 4426 + PACKET_TYPE_VRR, 4427 + TRANSFER_FUNC_UNKNOWN, 4430 4428 &vrr_infopacket); 4431 4429 4432 4430 new_crtc_state->freesync_timing_changed =
+6 -104
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
··· 2233 2233 struct dc_info_packet *info_packet, 2234 2234 struct dc_stream_state *stream) 2235 2235 { 2236 - uint32_t length = 0; 2237 - bool hdmi_vic_mode = false; 2238 - uint8_t checksum = 0; 2239 - uint32_t i = 0; 2240 - enum dc_timing_3d_format format; 2241 - // Can be different depending on packet content /*todo*/ 2242 - // unsigned int length = pPathMode->dolbyVision ? 24 : 5; 2236 + /* SPD info packet for FreeSync */ 2243 2237 2244 - info_packet->valid = false; 2245 - 2246 - format = stream->timing.timing_3d_format; 2247 - if (stream->view_format == VIEW_3D_FORMAT_NONE) 2248 - format = TIMING_3D_FORMAT_NONE; 2249 - 2250 - /* Can be different depending on packet content */ 2251 - length = 5; 2252 - 2253 - if (stream->timing.hdmi_vic != 0 2254 - && stream->timing.h_total >= 3840 2255 - && stream->timing.v_total >= 2160) 2256 - hdmi_vic_mode = true; 2257 - 2258 - /* According to HDMI 1.4a CTS, VSIF should be sent 2259 - * for both 3D stereo and HDMI VIC modes. 2260 - * For all other modes, there is no VSIF sent. */ 2261 - 2262 - if (format == TIMING_3D_FORMAT_NONE && !hdmi_vic_mode) 2238 + /* Check if Freesync is supported. Return if false. If true, 2239 + * set the corresponding bit in the info packet 2240 + */ 2241 + if (!stream->vsp_infopacket.valid) 2263 2242 return; 2264 2243 2265 - /* 24bit IEEE Registration identifier (0x000c03). LSB first. */ 2266 - info_packet->sb[1] = 0x03; 2267 - info_packet->sb[2] = 0x0C; 2268 - info_packet->sb[3] = 0x00; 2269 - 2270 - /*PB4: 5 lower bytes = 0 (reserved). 3 higher bits = HDMI_Video_Format. 2271 - * The value for HDMI_Video_Format are: 2272 - * 0x0 (0b000) - No additional HDMI video format is presented in this 2273 - * packet 2274 - * 0x1 (0b001) - Extended resolution format present. 1 byte of HDMI_VIC 2275 - * parameter follows 2276 - * 0x2 (0b010) - 3D format indication present. 3D_Structure and 2277 - * potentially 3D_Ext_Data follows 2278 - * 0x3..0x7 (0b011..0b111) - reserved for future use */ 2279 - if (format != TIMING_3D_FORMAT_NONE) 2280 - info_packet->sb[4] = (2 << 5); 2281 - else if (hdmi_vic_mode) 2282 - info_packet->sb[4] = (1 << 5); 2283 - 2284 - /* PB5: If PB4 claims 3D timing (HDMI_Video_Format = 0x2): 2285 - * 4 lower bites = 0 (reserved). 4 higher bits = 3D_Structure. 2286 - * The value for 3D_Structure are: 2287 - * 0x0 - Frame Packing 2288 - * 0x1 - Field Alternative 2289 - * 0x2 - Line Alternative 2290 - * 0x3 - Side-by-Side (full) 2291 - * 0x4 - L + depth 2292 - * 0x5 - L + depth + graphics + graphics-depth 2293 - * 0x6 - Top-and-Bottom 2294 - * 0x7 - Reserved for future use 2295 - * 0x8 - Side-by-Side (Half) 2296 - * 0x9..0xE - Reserved for future use 2297 - * 0xF - Not used */ 2298 - switch (format) { 2299 - case TIMING_3D_FORMAT_HW_FRAME_PACKING: 2300 - case TIMING_3D_FORMAT_SW_FRAME_PACKING: 2301 - info_packet->sb[5] = (0x0 << 4); 2302 - break; 2303 - 2304 - case TIMING_3D_FORMAT_SIDE_BY_SIDE: 2305 - case TIMING_3D_FORMAT_SBS_SW_PACKED: 2306 - info_packet->sb[5] = (0x8 << 4); 2307 - length = 6; 2308 - break; 2309 - 2310 - case TIMING_3D_FORMAT_TOP_AND_BOTTOM: 2311 - case TIMING_3D_FORMAT_TB_SW_PACKED: 2312 - info_packet->sb[5] = (0x6 << 4); 2313 - break; 2314 - 2315 - default: 2316 - break; 2317 - } 2318 - 2319 - /*PB5: If PB4 is set to 0x1 (extended resolution format) 2320 - * fill PB5 with the correct HDMI VIC code */ 2321 - if (hdmi_vic_mode) 2322 - info_packet->sb[5] = stream->timing.hdmi_vic; 2323 - 2324 - /* Header */ 2325 - info_packet->hb0 = HDMI_INFOFRAME_TYPE_VENDOR; /* VSIF packet type. */ 2326 - info_packet->hb1 = 0x01; /* Version */ 2327 - 2328 - /* 4 lower bits = Length, 4 higher bits = 0 (reserved) */ 2329 - info_packet->hb2 = (uint8_t) (length); 2330 - 2331 - /* Calculate checksum */ 2332 - checksum = 0; 2333 - checksum += info_packet->hb0; 2334 - checksum += info_packet->hb1; 2335 - checksum += info_packet->hb2; 2336 - 2337 - for (i = 1; i <= length; i++) 2338 - checksum += info_packet->sb[i]; 2339 - 2340 - info_packet->sb[0] = (uint8_t) (0x100 - checksum); 2341 - 2342 - info_packet->valid = true; 2244 + *info_packet = stream->vsp_infopacket; 2343 2245 } 2344 2246 2345 2247 static void set_spd_info_packet(
+2
drivers/gpu/drm/amd/display/dc/dc_stream.h
··· 56 56 struct dc_crtc_timing_adjust adjust; 57 57 struct dc_info_packet vrr_infopacket; 58 58 struct dc_info_packet vsc_infopacket; 59 + struct dc_info_packet vsp_infopacket; 59 60 60 61 struct rect src; /* composition area */ 61 62 struct rect dst; /* stream addressable area */ ··· 130 129 struct dc_crtc_timing_adjust *adjust; 131 130 struct dc_info_packet *vrr_infopacket; 132 131 struct dc_info_packet *vsc_infopacket; 132 + struct dc_info_packet *vsp_infopacket; 133 133 134 134 bool *dpms_off; 135 135
+5 -5
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
··· 608 608 static void build_vrr_infopacket_fs2_data(enum color_transfer_func app_tf, 609 609 struct dc_info_packet *infopacket) 610 610 { 611 - if (app_tf != transfer_func_unknown) { 611 + if (app_tf != TRANSFER_FUNC_UNKNOWN) { 612 612 infopacket->valid = true; 613 613 614 614 infopacket->sb[6] |= 0x08; // PB6 = [Bit 3 = Native Color Active] 615 615 616 - if (app_tf == transfer_func_gamma_22) { 616 + if (app_tf == TRANSFER_FUNC_GAMMA_22) { 617 617 infopacket->sb[9] |= 0x04; // PB6 = [Bit 2 = Gamma 2.2 EOTF Active] 618 618 } 619 619 } ··· 688 688 return; 689 689 690 690 switch (packet_type) { 691 - case packet_type_fs2: 691 + case PACKET_TYPE_FS2: 692 692 build_vrr_infopacket_v2(stream->signal, vrr, app_tf, infopacket); 693 693 break; 694 - case packet_type_vrr: 695 - case packet_type_fs1: 694 + case PACKET_TYPE_VRR: 695 + case PACKET_TYPE_FS1: 696 696 default: 697 697 build_vrr_infopacket_v1(stream->signal, vrr, infopacket); 698 698 }
+6 -8
drivers/gpu/drm/amd/display/modules/inc/mod_info_packet.h
··· 26 26 #ifndef MOD_INFO_PACKET_H_ 27 27 #define MOD_INFO_PACKET_H_ 28 28 29 - struct info_packet_inputs { 30 - const struct dc_stream_state *pStream; 31 - }; 29 + #include "mod_shared.h" 32 30 33 - struct info_packets { 34 - struct dc_info_packet *pVscInfoPacket; 35 - }; 31 + //Forward Declarations 32 + struct dc_stream_state; 33 + struct dc_info_packet; 36 34 37 - void mod_build_infopackets(struct info_packet_inputs *inputs, 38 - struct info_packets *info_packets); 35 + void mod_build_vsc_infopacket(const struct dc_stream_state *stream, 36 + struct dc_info_packet *info_packet); 39 37 40 38 #endif
+13 -14
drivers/gpu/drm/amd/display/modules/inc/mod_shared.h
··· 23 23 * 24 24 */ 25 25 26 - 27 26 #ifndef MOD_SHARED_H_ 28 27 #define MOD_SHARED_H_ 29 28 30 29 enum color_transfer_func { 31 - transfer_func_unknown, 32 - transfer_func_srgb, 33 - transfer_func_bt709, 34 - transfer_func_pq2084, 35 - transfer_func_pq2084_interim, 36 - transfer_func_linear_0_1, 37 - transfer_func_linear_0_125, 38 - transfer_func_dolbyvision, 39 - transfer_func_gamma_22, 40 - transfer_func_gamma_26 30 + TRANSFER_FUNC_UNKNOWN, 31 + TRANSFER_FUNC_SRGB, 32 + TRANSFER_FUNC_BT709, 33 + TRANSFER_FUNC_PQ2084, 34 + TRANSFER_FUNC_PQ2084_INTERIM, 35 + TRANSFER_FUNC_LINEAR_0_1, 36 + TRANSFER_FUNC_LINEAR_0_125, 37 + TRANSFER_FUNC_GAMMA_22, 38 + TRANSFER_FUNC_GAMMA_26 41 39 }; 42 40 43 41 enum vrr_packet_type { 44 - packet_type_vrr, 45 - packet_type_fs1, 46 - packet_type_fs2 42 + PACKET_TYPE_VRR, 43 + PACKET_TYPE_FS1, 44 + PACKET_TYPE_FS2 47 45 }; 46 + 48 47 49 48 #endif /* MOD_SHARED_H_ */
+6 -9
drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c
··· 25 25 26 26 #include "mod_info_packet.h" 27 27 #include "core_types.h" 28 + #include "dc_types.h" 29 + #include "mod_shared.h" 30 + 31 + #define HDMI_INFOFRAME_TYPE_VENDOR 0x81 28 32 29 33 enum ColorimetryRGBDP { 30 34 ColorimetryRGB_DP_sRGB = 0, ··· 45 41 ColorimetryYCC_DP_ITU2020YCbCr = 7, 46 42 }; 47 43 48 - static void mod_build_vsc_infopacket(const struct dc_stream_state *stream, 44 + void mod_build_vsc_infopacket(const struct dc_stream_state *stream, 49 45 struct dc_info_packet *info_packet) 50 46 { 51 47 unsigned int vscPacketRevision = 0; ··· 163 159 * DPCD register is exposed in the new Extended Receiver Capability field for DPCD Rev. 1.4 164 160 * (and higher). When MISC1. bit 6. is Set to 1, a Source device uses a VSC SDP to indicate 165 161 * the Pixel Encoding/Colorimetry Format and that a Sink device must ignore MISC1, bit 7, and 166 - * MISC0, bits 7:1 (MISC1, bit 7. and MISC0, bits 7:1 become “don’t care”).) 162 + * MISC0, bits 7:1 (MISC1, bit 7. and MISC0, bits 7:1 become "don't care").) 167 163 */ 168 164 if (vscPacketRevision == 0x5) { 169 165 /* Secondary-data Packet ID = 0 */ ··· 322 318 info_packet->sb[18] = 0; 323 319 } 324 320 325 - } 326 - 327 - void mod_build_infopackets(struct info_packet_inputs *inputs, 328 - struct info_packets *info_packets) 329 - { 330 - if (info_packets->pVscInfoPacket != NULL) 331 - mod_build_vsc_infopacket(inputs->pStream, info_packets->pVscInfoPacket); 332 321 } 333 322