drm/amd/display: Add a conversion function for transmitter and phy_id enums
Subsystems (3)
PATCH 1/1 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 828cfa29093f ("drm/amdgpu: Fix amdgpu ras to ta enums conversion") and commit d9ec5cfd5a2e ("drm/amd/display: Use switch table for dc_to_smu_clock_type") for previous examples of this.
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +37 -1
@@ -2447,6 +2447,41 @@ bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state)return true; } +static inline enum physical_phy_id +transmitter_to_phy_id (enum transmitter transmitter_value) +{ +switch (transmitter_value) { +case TRANSMITTER_UNIPHY_A : +return PHYLD_0 ; +case TRANSMITTER_UNIPHY_B : +return PHYLD_1 ; +case TRANSMITTER_UNIPHY_C : +return PHYLD_2 ; +case TRANSMITTER_UNIPHY_D : +return PHYLD_3 ; +case TRANSMITTER_UNIPHY_E : +return PHYLD_4 ; +case TRANSMITTER_UNIPHY_F : +return PHYLD_5 ; +case TRANSMITTER_NUTMEG_CRT : +return PHYLD_6 ; +case TRANSMITTER_TRAVIS_CRT : +return PHYLD_7 ; +case TRANSMITTER_TRAVIS_LCD : +return PHYLD_8 ; +case TRANSMITTER_UNIPHY_G : +return PHYLD_9 ; +case TRANSMITTER_COUNT : +return PHYLD_COUNT ; +case TRANSMITTER_UNKNOWN : +return PHYLD_UNKNOWN ; +default : +WARN_ONCE (1 ,"Unknown transmitter value %d\n" , + transmitter_value); +return PHYLD_0 ; + } +} +bool dc_link_setup_psr (struct dc_link *link,const struct dc_stream_state *stream,struct psr_config *psr_config,struct psr_context *psr_context)
@@ -2517,7 +2552,8 @@ bool dc_link_setup_psr(struct dc_link *link,/* Hardcoded for now. Can be Pcie or Uniphy (or Unknown)*/ psr_context->phyType =PHY_TYPE_UNIPHY ;/*PhyId is associated with the transmitter id*/ - psr_context->smuPhyId = link->link_enc->transmitter; + psr_context->smuPhyId = +transmitter_to_phy_id (link->link_enc->transmitter); psr_context->crtcTimingVerticalTotal = stream->timing.v_total; psr_context->vsyncRateHz = div64_u64(div64_u64((stream->
Signature · 1 line
2.24.0.rc1
Quoted 15 lines · Nathan Chancellor
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 'enumphysical_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.
Quoted 7 lines
See commit
828cfa29093f("drm/amdgpu: Fix amdgpu ras to ta enums conversion") and commitd9ec5cfd5a2e("drm/amd/display: Use switch table fordc_to_smu_clock_type") for previous examples of this.Fixes e0d08a40a63b ("drm/amd/display: Add debugfs entry for reading psr state")Signed-off-by Nathan Chancellor <[email protected]>
With the small nitpick that maybe the default case should be PHYLD_UNKNOWN, but well get the warning if that happens anyway.
Nicholas Kazlauskas
Quoted 52 lines
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/display/dc/core/dc_link.c +35
-0@@ -2447,6 +2447,41 @@ bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state)return true; } +static inline enum physical_phy_id +transmitter_to_phy_id (enum transmitter transmitter_value) +{ +switch (transmitter_value) { +case TRANSMITTER_UNIPHY_A : +return PHYLD_0 ; +case TRANSMITTER_UNIPHY_B : +return PHYLD_1 ; +case TRANSMITTER_UNIPHY_C : +return PHYLD_2 ; +case TRANSMITTER_UNIPHY_D : +return PHYLD_3 ; +case TRANSMITTER_UNIPHY_E : +return PHYLD_4 ; +case TRANSMITTER_UNIPHY_F : +return PHYLD_5 ; +case TRANSMITTER_NUTMEG_CRT : +return PHYLD_6 ; +case TRANSMITTER_TRAVIS_CRT : +return PHYLD_7 ; +case TRANSMITTER_TRAVIS_LCD : +return PHYLD_8 ; +case TRANSMITTER_UNIPHY_G : +return PHYLD_9 ; +case TRANSMITTER_COUNT : +return PHYLD_COUNT ; +case TRANSMITTER_UNKNOWN : +return PHYLD_UNKNOWN ; +default : +WARN_ONCE (1 ,"Unknown transmitter value %d\n" , + transmitter_value); +return PHYLD_0 ; + } +} +bool dc_link_setup_psr (struct dc_link *link,const struct dc_stream_state *stream,struct psr_config *psr_config,struct psr_context *psr_context)
drivers/gpu/drm/amd/display/dc/core/dc_link.c bool dc_link_setup_psr(struct dc_link *link, · line 2559
Quoted 9 lines
drivers/gpu/drm/amd/display/dc/core/dc_link.c +2
-1@@ -2517,7 +2552,8 @@ bool dc_link_setup_psr(struct dc_link *link,/* Hardcoded for now. Can be Pcie or Uniphy (or Unknown)*/ psr_context->phyType =PHY_TYPE_UNIPHY ;/*PhyId is associated with the transmitter id*/ - psr_context->smuPhyId = link->link_enc->transmitter; + psr_context->smuPhyId = +transmitter_to_phy_id (link->link_enc->transmitter); psr_context->crtcTimingVerticalTotal = stream->timing.v_total; psr_context->vsyncRateHz = div64_u64(div64_u64((stream->
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 21 lines · Nicholas
Quoted 19 lines · Nathan Chancellor
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 'enumphysical_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
828cfa29093f("drm/amdgpu: Fix amdgpu ras to ta enums conversion") and commitd9ec5cfd5a2e("drm/amd/display: Use switch table fordc_to_smu_clock_type") for previous examples of this.
Quoted 9 lines
Quoted 3 lines
Fixes e0d08a40a63b ("drm/amd/display: Add debugfs entry for reading psr state")Signed-off-by Nathan Chancellor <[email protected]>Reviewed-by Nicholas Kazlauskas <[email protected]>With the small nitpick that maybe the default case should be
PHYLD_UNKNOWN, but well get the warning if that happens anyway.
Applied with that change.
Thanks!
Alex
Quoted 68 lines
Nicholas Kazlauskas
Quoted 52 lines
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/display/dc/core/dc_link.c +35
-0@@ -2447,6 +2447,41 @@ bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state)return true; } +static inline enum physical_phy_id +transmitter_to_phy_id (enum transmitter transmitter_value) +{ +switch (transmitter_value) { +case TRANSMITTER_UNIPHY_A : +return PHYLD_0 ; +case TRANSMITTER_UNIPHY_B : +return PHYLD_1 ; +case TRANSMITTER_UNIPHY_C : +return PHYLD_2 ; +case TRANSMITTER_UNIPHY_D : +return PHYLD_3 ; +case TRANSMITTER_UNIPHY_E : +return PHYLD_4 ; +case TRANSMITTER_UNIPHY_F : +return PHYLD_5 ; +case TRANSMITTER_NUTMEG_CRT : +return PHYLD_6 ; +case TRANSMITTER_TRAVIS_CRT : +return PHYLD_7 ; +case TRANSMITTER_TRAVIS_LCD : +return PHYLD_8 ; +case TRANSMITTER_UNIPHY_G : +return PHYLD_9 ; +case TRANSMITTER_COUNT : +return PHYLD_COUNT ; +case TRANSMITTER_UNKNOWN : +return PHYLD_UNKNOWN ; +default : +WARN_ONCE (1 ,"Unknown transmitter value %d\n" , + transmitter_value); +return PHYLD_0 ; + } +} +bool dc_link_setup_psr (struct dc_link *link,const struct dc_stream_state *stream,struct psr_config *psr_config,struct psr_context *psr_context)drivers/gpu/drm/amd/display/dc/core/dc_link.c bool dc_link_setup_psr(struct dc_link *link, · line 2559
Quoted 9 lines
drivers/gpu/drm/amd/display/dc/core/dc_link.c +2
-1@@ -2517,7 +2552,8 @@ bool dc_link_setup_psr(struct dc_link *link,/* Hardcoded for now. Can be Pcie or Uniphy (or Unknown)*/ psr_context->phyType =PHY_TYPE_UNIPHY ;/*PhyId is associated with the transmitter id*/ - psr_context->smuPhyId = link->link_enc->transmitter; + psr_context->smuPhyId = +transmitter_to_phy_id (link->link_enc->transmitter); psr_context->crtcTimingVerticalTotal = stream->timing.v_total; psr_context->vsyncRateHz = div64_u64(div64_u64((stream->_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx