Skip to content

Commit 5ab5e4e

Browse files
nathanchancealexdeucher
authored andcommitted
drm/amd/display: Add a conversion function for transmitter and phy_id enums
Clang warns: ../drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:2520:42: error: implicit conversion from enumeration type 'enum transmitter' to different enumeration type 'enum physical_phy_id' [-Werror,-Wenum-conversion] psr_context->smuPhyId = link->link_enc->transmitter; ~ ~~~~~~~~~~~~~~~~^~~~~~~~~~~ 1 error generated. As the comment above this assignment states, this is intentional. To match previous warnings of this nature, add a conversion function that explicitly converts between the enums and warns when there is a mismatch. See commit 828cfa2 ("drm/amdgpu: Fix amdgpu ras to ta enums conversion") and commit d9ec5cf ("drm/amd/display: Use switch table for dc_to_smu_clock_type") for previous examples of this. v2: use PHYLD_UNKNOWN for the default case. Fixes: e0d08a4 ("drm/amd/display: Add debugfs entry for reading psr state") Link: ClangBuiltLinux#758 Reviewed-by: Nicholas Kazlauskas <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 5e8f547 commit 5ab5e4e

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

drivers/gpu/drm/amd/display/dc/core/dc_link.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,41 @@ bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state)
24472447
return true;
24482448
}
24492449

2450+
static inline enum physical_phy_id
2451+
transmitter_to_phy_id(enum transmitter transmitter_value)
2452+
{
2453+
switch (transmitter_value) {
2454+
case TRANSMITTER_UNIPHY_A:
2455+
return PHYLD_0;
2456+
case TRANSMITTER_UNIPHY_B:
2457+
return PHYLD_1;
2458+
case TRANSMITTER_UNIPHY_C:
2459+
return PHYLD_2;
2460+
case TRANSMITTER_UNIPHY_D:
2461+
return PHYLD_3;
2462+
case TRANSMITTER_UNIPHY_E:
2463+
return PHYLD_4;
2464+
case TRANSMITTER_UNIPHY_F:
2465+
return PHYLD_5;
2466+
case TRANSMITTER_NUTMEG_CRT:
2467+
return PHYLD_6;
2468+
case TRANSMITTER_TRAVIS_CRT:
2469+
return PHYLD_7;
2470+
case TRANSMITTER_TRAVIS_LCD:
2471+
return PHYLD_8;
2472+
case TRANSMITTER_UNIPHY_G:
2473+
return PHYLD_9;
2474+
case TRANSMITTER_COUNT:
2475+
return PHYLD_COUNT;
2476+
case TRANSMITTER_UNKNOWN:
2477+
return PHYLD_UNKNOWN;
2478+
default:
2479+
WARN_ONCE(1, "Unknown transmitter value %d\n",
2480+
transmitter_value);
2481+
return PHYLD_UNKNOWN;
2482+
}
2483+
}
2484+
24502485
bool dc_link_setup_psr(struct dc_link *link,
24512486
const struct dc_stream_state *stream, struct psr_config *psr_config,
24522487
struct psr_context *psr_context)
@@ -2517,7 +2552,8 @@ bool dc_link_setup_psr(struct dc_link *link,
25172552
/* Hardcoded for now. Can be Pcie or Uniphy (or Unknown)*/
25182553
psr_context->phyType = PHY_TYPE_UNIPHY;
25192554
/*PhyId is associated with the transmitter id*/
2520-
psr_context->smuPhyId = link->link_enc->transmitter;
2555+
psr_context->smuPhyId =
2556+
transmitter_to_phy_id(link->link_enc->transmitter);
25212557

25222558
psr_context->crtcTimingVerticalTotal = stream->timing.v_total;
25232559
psr_context->vsyncRateHz = div64_u64(div64_u64((stream->

0 commit comments

Comments
 (0)