[PATCH 05/21] drm/dp: Turn link capabilities into booleans
Andrzej Hajda
a.hajda at samsung.com
Thu Aug 8 11:52:36 UTC 2019
On 05.08.2019 14:23, Thierry Reding wrote:
> From: Thierry Reding <treding at nvidia.com>
>
> Rather than storing capabilities as flags in an integer, use a separate
> boolean per capability. This simplifies the code that checks for these
> capabilities.
>
> Cc: Rob Clark <robdclark at gmail.com>
> Signed-off-by: Thierry Reding <treding at nvidia.com>
> ---
> drivers/gpu/drm/bridge/tc358767.c | 9 ++++-----
> drivers/gpu/drm/drm_dp_helper.c | 19 ++++++++++++++++---
> drivers/gpu/drm/msm/edp/edp_ctrl.c | 4 ++--
> drivers/gpu/drm/tegra/sor.c | 4 ++--
> include/drm/drm_dp_helper.h | 17 ++++++++++++++---
> 5 files changed, 38 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index a39036e89cf7..1bbfcc5534ab 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -699,8 +699,8 @@ static int tc_get_display_props(struct tc_data *tc)
> tc->link.base.revision >> 4, tc->link.base.revision & 0x0f,
> (tc->link.base.rate == 162000) ? "1.62Gbps" : "2.7Gbps",
> tc->link.base.lanes,
> - (tc->link.base.capabilities & DP_LINK_CAP_ENHANCED_FRAMING) ?
> - "enhanced" : "non-enhanced");
> + tc->link.base.caps.enhanced_framing ? "enhanced" :
> + "non-enhanced");
> dev_dbg(tc->dev, "Downspread: %s, scrambler: %s\n",
> tc->link.spread ? "0.5%" : "0.0%",
> tc->link.scrambler_dis ? "disabled" : "enabled");
> @@ -1013,8 +1013,7 @@ static int tc_main_link_enable(struct tc_data *tc)
>
> /* Enable DP0 to start Link Training */
> ret = regmap_write(tc->regmap, DP0CTL,
> - ((tc->link.base.capabilities &
> - DP_LINK_CAP_ENHANCED_FRAMING) ? EF_EN : 0) |
> + (tc->link.base.caps.enhanced_framing ? EF_EN : 0) |
> DP_EN);
> if (ret)
> return ret;
> @@ -1165,7 +1164,7 @@ static int tc_stream_enable(struct tc_data *tc)
> return ret;
>
> value = VID_MN_GEN | DP_EN;
> - if (tc->link.base.capabilities & DP_LINK_CAP_ENHANCED_FRAMING)
> + if (tc->link.base.caps.enhanced_framing)
> value |= EF_EN;
> ret = regmap_write(tc->regmap, DP0CTL, value);
> if (ret)
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 365de63a02fb..bdf999bb6cfa 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -336,6 +336,18 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
> }
> EXPORT_SYMBOL(drm_dp_dpcd_read_link_status);
>
> +static void drm_dp_link_caps_reset(struct drm_dp_link_caps *caps)
> +{
> + caps->enhanced_framing = false;
> +}
> +
> +void drm_dp_link_caps_copy(struct drm_dp_link_caps *dest,
> + const struct drm_dp_link_caps *src)
> +{
> + dest->enhanced_framing = src->enhanced_framing;
> +}
> +EXPORT_SYMBOL(drm_dp_link_caps_copy);
Probably this could be replaced by direct assignment:
*dest = *src;
> +
> static void drm_dp_link_reset(struct drm_dp_link *link)
> {
> if (!link)
> @@ -344,7 +356,8 @@ static void drm_dp_link_reset(struct drm_dp_link *link)
> link->revision = 0;
> link->max_rate = 0;
> link->max_lanes = 0;
> - link->capabilities = 0;
> +
> + drm_dp_link_caps_reset(&link->caps);
>
> link->rate = 0;
> link->lanes = 0;
> @@ -377,7 +390,7 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link)
> link->max_lanes = values[2] & DP_MAX_LANE_COUNT_MASK;
>
> if (values[2] & DP_ENHANCED_FRAME_CAP)
> - link->capabilities |= DP_LINK_CAP_ENHANCED_FRAMING;
> + link->caps.enhanced_framing = true;
>
> link->rate = link->max_rate;
> link->lanes = link->max_lanes;
> @@ -470,7 +483,7 @@ int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link)
> values[0] = drm_dp_link_rate_to_bw_code(link->rate);
> values[1] = link->lanes;
>
> - if (link->capabilities & DP_LINK_CAP_ENHANCED_FRAMING)
> + if (link->caps.enhanced_framing)
> values[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
>
> err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, values, sizeof(values));
Anyway for bridge and core part:
Reviewed-by: Andrzej Hajda <a.hajda at samsung.com>
--
Regards
Andrzej
More information about the dri-devel
mailing list