diff mbox series

[05/12] drm/i915: Add some essential functionality for joiners

Message ID 20240718081803.3338564-6-ankit.k.nautiyal@intel.com (mailing list archive)
State New, archived
Headers show
Series Ultrajoiner basic functionality series | expand

Commit Message

Nautiyal, Ankit K July 18, 2024, 8:17 a.m. UTC
From: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>

In most of the cases we now try to avoid mentioning things like
"bigjoiner" or "ultrajoiner" trying to unify the API and refer
mostly to all this functionality as "joiner".
In majority cases that should be way to go.
However in some cases we still need to distinguish between
bigjoiner primaries and secondaries(such as DSC register programming).

Create correspondent helper functions and start using them,
in order be prepared for adding ultrajoiner functionality.

v2: Fixed checkpatch warnings (Ankit)

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c  | 75 ++++++++++++++++---
 drivers/gpu/drm/i915/display/intel_display.h  |  8 +-
 .../drm/i915/display/intel_modeset_verify.c   |  2 +-
 drivers/gpu/drm/i915/display/intel_vdsc.c     |  4 +-
 5 files changed, 76 insertions(+), 15 deletions(-)

Comments

Kandpal, Suraj July 31, 2024, 7:14 a.m. UTC | #1
> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ankit
> Nautiyal
> Sent: Thursday, July 18, 2024 1:48 PM
> To: intel-gfx@lists.freedesktop.org
> Cc: Lisovskiy, Stanislav <stanislav.lisovskiy@intel.com>; Saarinen, Jani
> <jani.saarinen@intel.com>; ville.syrjala@linux.intel.com
> Subject: [PATCH 05/12] drm/i915: Add some essential functionality for joiners
> 
> From: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> 
> In most of the cases we now try to avoid mentioning things like "bigjoiner" or
> "ultrajoiner" trying to unify the API and refer mostly to all this functionality as
> "joiner".
> In majority cases that should be way to go.
> However in some cases we still need to distinguish between bigjoiner primaries
> and secondaries(such as DSC register programming).
> 
> Create correspondent helper functions and start using them, in order be
> prepared for adding ultrajoiner functionality.
> 
> v2: Fixed checkpatch warnings (Ankit)

Use imperatives

> 
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> ---
>  .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
> drivers/gpu/drm/i915/display/intel_display.c  | 75 ++++++++++++++++---
> drivers/gpu/drm/i915/display/intel_display.h  |  8 +-
>  .../drm/i915/display/intel_modeset_verify.c   |  2 +-
>  drivers/gpu/drm/i915/display/intel_vdsc.c     |  4 +-
>  5 files changed, 76 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> index e979786aa5cf..9862d0339e6a 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> @@ -724,7 +724,7 @@ int intel_plane_atomic_check(struct intel_atomic_state
> *state,
> 
>  	if (new_crtc_state && intel_crtc_is_joiner_secondary(new_crtc_state)) {
>  		struct intel_crtc *primary_crtc =
> -			intel_primary_crtc(new_crtc_state);
> +			intel_joiner_primary_crtc(new_crtc_state);
>  		struct intel_plane *primary_crtc_plane =
>  			intel_crtc_get_plane(primary_crtc, plane->id);
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> b/drivers/gpu/drm/i915/display/intel_display.c
> index 26e4b0c2e9f7..38e7c6811bf3 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -252,6 +252,68 @@ static enum pipe joiner_primary_pipe(const struct
> intel_crtc_state *crtc_state)
>  	return ffs(crtc_state->joiner_pipes) - 1;  }
> 
> +int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state) {
> +	return hweight8(crtc_state->joiner_pipes);
> +}

This function is the same as one introduced in patch 2 its being added back in patch 5
> +
> +bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state
> +*crtc_state) {
> +	return intel_joiner_num_pipes(crtc_state) == 4; }
> +
> +static bool intel_is_joiner(const struct intel_crtc_state *crtc_state)
> +{
> +	return intel_joiner_num_pipes(crtc_state) > 1; }
> +

Enums have been defined for no of pipe joiner lets use those and this is exactly why I wanted Ultra Joiner enum declared earlier to avoid comparison with direct numbers.

> +static u8 bigjoiner_primary_pipes(const struct intel_crtc_state
> +*crtc_state) {
> +	int lsb = ffs(crtc_state->joiner_pipes) - 1;
> +	int msb = fls(crtc_state->joiner_pipes) - 1;
> +	int i;
> +	u8 bigjoiner_primary_mask = 0;
> +
> +	for (i = lsb; i < msb; i += 4) {
> +		/*
> +		 * Regardless of how joiner_pipes mask is set, currently
> +		 * we always assume, that primary pipe bit goes before
> secondary
> +		 * pipe bit. So in each set of 2 bits, least significant bit is
> +		 * bigjoiner primary pipe and most significant bit is secondary
> pipe.
> +		 */
> +		bigjoiner_primary_mask |=
> +			((BIT(0) | BIT(2)) << i) & crtc_state->joiner_pipes;
> +	}
> +
> +	return bigjoiner_primary_mask;
> +}
> +
> +bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state
> +*crtc_state) {
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +
> +	if (!intel_is_joiner(crtc_state))
> +		return false;
> +
> +	return BIT(crtc->pipe) & bigjoiner_primary_pipes(crtc_state);
> +}
> +
> +bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state
> +*crtc_state) {
> +	if (!intel_is_joiner(crtc_state))
> +		return false;
> +
> +	return !intel_crtc_is_bigjoiner_primary(crtc_state);
> +}
> +
> +bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state
> +*crtc_state) {
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +
> +	return intel_crtc_is_ultrajoiner(crtc_state) &&
> +		(crtc->pipe == joiner_primary_pipe(crtc_state)); }
> +
>  u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state)  {
>  	if (crtc_state->joiner_pipes)
> @@ -276,11 +338,6 @@ bool intel_crtc_is_joiner_primary(const struct
> intel_crtc_state *crtc_state)
>  		crtc->pipe == joiner_primary_pipe(crtc_state);  }
> 
> -int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state) -{
> -	return hweight8(crtc_state->joiner_pipes);
> -}
> -
>  u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)  {
>  	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> @@ -288,7 +345,7 @@ u8 intel_crtc_joined_pipe_mask(const struct
> intel_crtc_state *crtc_state)
>  	return BIT(crtc->pipe) | crtc_state->joiner_pipes;  }
> 
> -struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state)
> +struct intel_crtc *intel_joiner_primary_crtc(const struct
> +intel_crtc_state *crtc_state)
>  {
>  	struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
> 
> @@ -808,7 +865,7 @@ intel_get_crtc_new_encoder(const struct
> intel_atomic_state *state,
>  	int num_encoders = 0;
>  	int i;
> 
> -	primary_crtc = intel_primary_crtc(crtc_state);
> +	primary_crtc = intel_joiner_primary_crtc(crtc_state);
> 
>  	for_each_new_connector_in_state(&state->base, connector,
> connector_state, i) {
>  		if (connector_state->crtc != &primary_crtc->base) @@ -4527,7
> +4584,7 @@ copy_joiner_crtc_state_nomodeset(struct intel_atomic_state
> *state,  {
>  	struct intel_crtc_state *secondary_crtc_state =
>  		intel_atomic_get_new_crtc_state(state, secondary_crtc);
> -	struct intel_crtc *primary_crtc =
> intel_primary_crtc(secondary_crtc_state);
> +	struct intel_crtc *primary_crtc =
> +intel_joiner_primary_crtc(secondary_crtc_state);
>  	const struct intel_crtc_state *primary_crtc_state =
>  		intel_atomic_get_new_crtc_state(state, primary_crtc);
> 
> @@ -4547,7 +4604,7 @@ copy_joiner_crtc_state_modeset(struct
> intel_atomic_state *state,  {
>  	struct intel_crtc_state *secondary_crtc_state =
>  		intel_atomic_get_new_crtc_state(state, secondary_crtc);
> -	struct intel_crtc *primary_crtc =
> intel_primary_crtc(secondary_crtc_state);
> +	struct intel_crtc *primary_crtc =
> +intel_joiner_primary_crtc(secondary_crtc_state);
>  	const struct intel_crtc_state *primary_crtc_state =
>  		intel_atomic_get_new_crtc_state(state, primary_crtc);
>  	struct intel_crtc_state *saved_state;
> diff --git a/drivers/gpu/drm/i915/display/intel_display.h
> b/drivers/gpu/drm/i915/display/intel_display.h
> index bf665f947b97..35e68e4cc712 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.h
> +++ b/drivers/gpu/drm/i915/display/intel_display.h
> @@ -424,10 +424,14 @@ enum phy intel_port_to_phy(struct
> drm_i915_private *i915, enum port port);  bool
> is_trans_port_sync_mode(const struct intel_crtc_state *state);  bool
> is_trans_port_sync_master(const struct intel_crtc_state *state);
>  u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state); -bool
> intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);  bool
> intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state);
> +bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state
> +*crtc_state); bool intel_crtc_is_bigjoiner_primary(const struct
> +intel_crtc_state *crtc_state); bool
> +intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state
> +*crtc_state); bool intel_crtc_is_ultrajoiner(const struct
> +intel_crtc_state *crtc_state); bool
> +intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state
> +*crtc_state);
>  u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state); -
> struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state);
> +struct intel_crtc *intel_joiner_primary_crtc(const struct
> +intel_crtc_state *crtc_state);

I think with all these joiner related functions introduced maybe joiner gets it own file
Quite a lot of functions including enable disable sequences including the functions introduced here can be moved there

Regards,
Suraj Kandpal

>  bool intel_crtc_get_pipe_config(struct intel_crtc_state *crtc_state);  bool
> intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  			       const struct intel_crtc_state *pipe_config, diff --git
> a/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> index 3491db5cad31..b53b810c6470 100644
> --- a/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> +++ b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> @@ -193,7 +193,7 @@ verify_crtc_state(struct intel_atomic_state *state,
>  			"transitional active state does not match atomic hw
> state (expected %i, found %i)\n",
>  			sw_crtc_state->hw.active, crtc->active);
> 
> -	primary_crtc = intel_primary_crtc(sw_crtc_state);
> +	primary_crtc = intel_joiner_primary_crtc(sw_crtc_state);
> 
>  	for_each_encoder_on_crtc(dev, &primary_crtc->base, encoder) {
>  		enum pipe pipe;
> diff --git a/drivers/gpu/drm/i915/display/intel_vdsc.c
> b/drivers/gpu/drm/i915/display/intel_vdsc.c
> index b9687b7692b8..11058bb37d5a 100644
> --- a/drivers/gpu/drm/i915/display/intel_vdsc.c
> +++ b/drivers/gpu/drm/i915/display/intel_vdsc.c
> @@ -761,7 +761,7 @@ void intel_uncompressed_joiner_enable(const struct
> intel_crtc_state *crtc_state)
>  	u32 dss_ctl1_val = 0;
> 
>  	if (crtc_state->joiner_pipes && !crtc_state->dsc.compression_enable) {
> -		if (intel_crtc_is_joiner_secondary(crtc_state))
> +		if (intel_crtc_is_bigjoiner_secondary(crtc_state))
>  			dss_ctl1_val |= UNCOMPRESSED_JOINER_SECONDARY;
>  		else
>  			dss_ctl1_val |= UNCOMPRESSED_JOINER_PRIMARY;
> @@ -790,7 +790,7 @@ void intel_dsc_enable(const struct intel_crtc_state
> *crtc_state)
>  	}
>  	if (crtc_state->joiner_pipes) {
>  		dss_ctl1_val |= BIG_JOINER_ENABLE;
> -		if (!intel_crtc_is_joiner_secondary(crtc_state))
> +		if (intel_crtc_is_bigjoiner_primary(crtc_state))
>  			dss_ctl1_val |= PRIMARY_BIG_JOINER_ENABLE;
>  	}
>  	intel_de_write(dev_priv, dss_ctl1_reg(crtc, crtc_state->cpu_transcoder),
> dss_ctl1_val);
> --
> 2.45.2
Nautiyal, Ankit K Aug. 16, 2024, 8:23 a.m. UTC | #2
On 7/18/2024 1:47 PM, Ankit Nautiyal wrote:
> From: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
>
> In most of the cases we now try to avoid mentioning things like
> "bigjoiner" or "ultrajoiner" trying to unify the API and refer
> mostly to all this functionality as "joiner".
> In majority cases that should be way to go.
> However in some cases we still need to distinguish between
> bigjoiner primaries and secondaries(such as DSC register programming).
>
> Create correspondent helper functions and start using them,
> in order be prepared for adding ultrajoiner functionality.
>
> v2: Fixed checkpatch warnings (Ankit)
>
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> ---
>   .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
>   drivers/gpu/drm/i915/display/intel_display.c  | 75 ++++++++++++++++---
>   drivers/gpu/drm/i915/display/intel_display.h  |  8 +-
>   .../drm/i915/display/intel_modeset_verify.c   |  2 +-
>   drivers/gpu/drm/i915/display/intel_vdsc.c     |  4 +-
>   5 files changed, 76 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> index e979786aa5cf..9862d0339e6a 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> @@ -724,7 +724,7 @@ int intel_plane_atomic_check(struct intel_atomic_state *state,
>   
>   	if (new_crtc_state && intel_crtc_is_joiner_secondary(new_crtc_state)) {
>   		struct intel_crtc *primary_crtc =
> -			intel_primary_crtc(new_crtc_state);
> +			intel_joiner_primary_crtc(new_crtc_state);
>   		struct intel_plane *primary_crtc_plane =
>   			intel_crtc_get_plane(primary_crtc, plane->id);
>   
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 26e4b0c2e9f7..38e7c6811bf3 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -252,6 +252,68 @@ static enum pipe joiner_primary_pipe(const struct intel_crtc_state *crtc_state)
>   	return ffs(crtc_state->joiner_pipes) - 1;
>   }
>   
> +int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
> +{
> +	return hweight8(crtc_state->joiner_pipes);
> +}
> +
> +bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state)
> +{
> +	return intel_joiner_num_pipes(crtc_state) == 4;


On having a re-look, I think we need to change this. Currently there is 
no way of knowing if its 2 set of bigjoiners or 1 ultrajoiner.

Perhaps need one more bit for ultrajoiner or a different flag altogether.

Regards,

Ankit

> +}
> +
> +static bool intel_is_joiner(const struct intel_crtc_state *crtc_state)
> +{
> +	return intel_joiner_num_pipes(crtc_state) > 1;
> +}
> +
> +static u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state)
> +{
> +	int lsb = ffs(crtc_state->joiner_pipes) - 1;
> +	int msb = fls(crtc_state->joiner_pipes) - 1;
> +	int i;
> +	u8 bigjoiner_primary_mask = 0;
> +
> +	for (i = lsb; i < msb; i += 4) {
> +		/*
> +		 * Regardless of how joiner_pipes mask is set, currently
> +		 * we always assume, that primary pipe bit goes before secondary
> +		 * pipe bit. So in each set of 2 bits, least significant bit is
> +		 * bigjoiner primary pipe and most significant bit is secondary pipe.
> +		 */
> +		bigjoiner_primary_mask |=
> +			((BIT(0) | BIT(2)) << i) & crtc_state->joiner_pipes;
> +	}
> +
> +	return bigjoiner_primary_mask;
> +}
> +
> +bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state)
> +{
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +
> +	if (!intel_is_joiner(crtc_state))
> +		return false;
> +
> +	return BIT(crtc->pipe) & bigjoiner_primary_pipes(crtc_state);
> +}
> +
> +bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state)
> +{
> +	if (!intel_is_joiner(crtc_state))
> +		return false;
> +
> +	return !intel_crtc_is_bigjoiner_primary(crtc_state);
> +}
> +
> +bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state)
> +{
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +
> +	return intel_crtc_is_ultrajoiner(crtc_state) &&
> +		(crtc->pipe == joiner_primary_pipe(crtc_state));
> +}
> +
>   u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state)
>   {
>   	if (crtc_state->joiner_pipes)
> @@ -276,11 +338,6 @@ bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state)
>   		crtc->pipe == joiner_primary_pipe(crtc_state);
>   }
>   
> -int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
> -{
> -	return hweight8(crtc_state->joiner_pipes);
> -}
> -
>   u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
>   {
>   	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> @@ -288,7 +345,7 @@ u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
>   	return BIT(crtc->pipe) | crtc_state->joiner_pipes;
>   }
>   
> -struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state)
> +struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state)
>   {
>   	struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
>   
> @@ -808,7 +865,7 @@ intel_get_crtc_new_encoder(const struct intel_atomic_state *state,
>   	int num_encoders = 0;
>   	int i;
>   
> -	primary_crtc = intel_primary_crtc(crtc_state);
> +	primary_crtc = intel_joiner_primary_crtc(crtc_state);
>   
>   	for_each_new_connector_in_state(&state->base, connector, connector_state, i) {
>   		if (connector_state->crtc != &primary_crtc->base)
> @@ -4527,7 +4584,7 @@ copy_joiner_crtc_state_nomodeset(struct intel_atomic_state *state,
>   {
>   	struct intel_crtc_state *secondary_crtc_state =
>   		intel_atomic_get_new_crtc_state(state, secondary_crtc);
> -	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
> +	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
>   	const struct intel_crtc_state *primary_crtc_state =
>   		intel_atomic_get_new_crtc_state(state, primary_crtc);
>   
> @@ -4547,7 +4604,7 @@ copy_joiner_crtc_state_modeset(struct intel_atomic_state *state,
>   {
>   	struct intel_crtc_state *secondary_crtc_state =
>   		intel_atomic_get_new_crtc_state(state, secondary_crtc);
> -	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
> +	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
>   	const struct intel_crtc_state *primary_crtc_state =
>   		intel_atomic_get_new_crtc_state(state, primary_crtc);
>   	struct intel_crtc_state *saved_state;
> diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
> index bf665f947b97..35e68e4cc712 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.h
> +++ b/drivers/gpu/drm/i915/display/intel_display.h
> @@ -424,10 +424,14 @@ enum phy intel_port_to_phy(struct drm_i915_private *i915, enum port port);
>   bool is_trans_port_sync_mode(const struct intel_crtc_state *state);
>   bool is_trans_port_sync_master(const struct intel_crtc_state *state);
>   u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state);
> -bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
>   bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state);
> +bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
> +bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state);
> +bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state);
> +bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state);
> +bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state);
>   u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state);
> -struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state);
> +struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state);
>   bool intel_crtc_get_pipe_config(struct intel_crtc_state *crtc_state);
>   bool intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>   			       const struct intel_crtc_state *pipe_config,
> diff --git a/drivers/gpu/drm/i915/display/intel_modeset_verify.c b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> index 3491db5cad31..b53b810c6470 100644
> --- a/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> +++ b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> @@ -193,7 +193,7 @@ verify_crtc_state(struct intel_atomic_state *state,
>   			"transitional active state does not match atomic hw state (expected %i, found %i)\n",
>   			sw_crtc_state->hw.active, crtc->active);
>   
> -	primary_crtc = intel_primary_crtc(sw_crtc_state);
> +	primary_crtc = intel_joiner_primary_crtc(sw_crtc_state);
>   
>   	for_each_encoder_on_crtc(dev, &primary_crtc->base, encoder) {
>   		enum pipe pipe;
> diff --git a/drivers/gpu/drm/i915/display/intel_vdsc.c b/drivers/gpu/drm/i915/display/intel_vdsc.c
> index b9687b7692b8..11058bb37d5a 100644
> --- a/drivers/gpu/drm/i915/display/intel_vdsc.c
> +++ b/drivers/gpu/drm/i915/display/intel_vdsc.c
> @@ -761,7 +761,7 @@ void intel_uncompressed_joiner_enable(const struct intel_crtc_state *crtc_state)
>   	u32 dss_ctl1_val = 0;
>   
>   	if (crtc_state->joiner_pipes && !crtc_state->dsc.compression_enable) {
> -		if (intel_crtc_is_joiner_secondary(crtc_state))
> +		if (intel_crtc_is_bigjoiner_secondary(crtc_state))
>   			dss_ctl1_val |= UNCOMPRESSED_JOINER_SECONDARY;
>   		else
>   			dss_ctl1_val |= UNCOMPRESSED_JOINER_PRIMARY;
> @@ -790,7 +790,7 @@ void intel_dsc_enable(const struct intel_crtc_state *crtc_state)
>   	}
>   	if (crtc_state->joiner_pipes) {
>   		dss_ctl1_val |= BIG_JOINER_ENABLE;
> -		if (!intel_crtc_is_joiner_secondary(crtc_state))
> +		if (intel_crtc_is_bigjoiner_primary(crtc_state))
>   			dss_ctl1_val |= PRIMARY_BIG_JOINER_ENABLE;
>   	}
>   	intel_de_write(dev_priv, dss_ctl1_reg(crtc, crtc_state->cpu_transcoder), dss_ctl1_val);
Ville Syrjälä Aug. 21, 2024, 1:41 p.m. UTC | #3
On Fri, Aug 16, 2024 at 01:53:20PM +0530, Nautiyal, Ankit K wrote:
> 
> On 7/18/2024 1:47 PM, Ankit Nautiyal wrote:
> > From: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> >
> > In most of the cases we now try to avoid mentioning things like
> > "bigjoiner" or "ultrajoiner" trying to unify the API and refer
> > mostly to all this functionality as "joiner".
> > In majority cases that should be way to go.
> > However in some cases we still need to distinguish between
> > bigjoiner primaries and secondaries(such as DSC register programming).
> >
> > Create correspondent helper functions and start using them,
> > in order be prepared for adding ultrajoiner functionality.
> >
> > v2: Fixed checkpatch warnings (Ankit)
> >
> > Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> > Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> > ---
> >   .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
> >   drivers/gpu/drm/i915/display/intel_display.c  | 75 ++++++++++++++++---
> >   drivers/gpu/drm/i915/display/intel_display.h  |  8 +-
> >   .../drm/i915/display/intel_modeset_verify.c   |  2 +-
> >   drivers/gpu/drm/i915/display/intel_vdsc.c     |  4 +-
> >   5 files changed, 76 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > index e979786aa5cf..9862d0339e6a 100644
> > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > @@ -724,7 +724,7 @@ int intel_plane_atomic_check(struct intel_atomic_state *state,
> >   
> >   	if (new_crtc_state && intel_crtc_is_joiner_secondary(new_crtc_state)) {
> >   		struct intel_crtc *primary_crtc =
> > -			intel_primary_crtc(new_crtc_state);
> > +			intel_joiner_primary_crtc(new_crtc_state);
> >   		struct intel_plane *primary_crtc_plane =
> >   			intel_crtc_get_plane(primary_crtc, plane->id);
> >   
> > diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> > index 26e4b0c2e9f7..38e7c6811bf3 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display.c
> > +++ b/drivers/gpu/drm/i915/display/intel_display.c
> > @@ -252,6 +252,68 @@ static enum pipe joiner_primary_pipe(const struct intel_crtc_state *crtc_state)
> >   	return ffs(crtc_state->joiner_pipes) - 1;
> >   }
> >   
> > +int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
> > +{
> > +	return hweight8(crtc_state->joiner_pipes);
> > +}
> > +
> > +bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state)
> > +{
> > +	return intel_joiner_num_pipes(crtc_state) == 4;
> 
> 
> On having a re-look, I think we need to change this. Currently there is 
> no way of knowing if its 2 set of bigjoiners or 1 ultrajoiner.

There is no such thing as 2 sets of bigjoiners on one crtc.

> 
> Perhaps need one more bit for ultrajoiner or a different flag altogether.
> 
> Regards,
> 
> Ankit
> 
> > +}
> > +
> > +static bool intel_is_joiner(const struct intel_crtc_state *crtc_state)
> > +{
> > +	return intel_joiner_num_pipes(crtc_state) > 1;
> > +}
> > +
> > +static u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state)
> > +{
> > +	int lsb = ffs(crtc_state->joiner_pipes) - 1;
> > +	int msb = fls(crtc_state->joiner_pipes) - 1;
> > +	int i;
> > +	u8 bigjoiner_primary_mask = 0;
> > +
> > +	for (i = lsb; i < msb; i += 4) {
> > +		/*
> > +		 * Regardless of how joiner_pipes mask is set, currently
> > +		 * we always assume, that primary pipe bit goes before secondary
> > +		 * pipe bit. So in each set of 2 bits, least significant bit is
> > +		 * bigjoiner primary pipe and most significant bit is secondary pipe.
> > +		 */
> > +		bigjoiner_primary_mask |=
> > +			((BIT(0) | BIT(2)) << i) & crtc_state->joiner_pipes;
> > +	}
> > +
> > +	return bigjoiner_primary_mask;
> > +}
> > +
> > +bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state)
> > +{
> > +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> > +
> > +	if (!intel_is_joiner(crtc_state))
> > +		return false;
> > +
> > +	return BIT(crtc->pipe) & bigjoiner_primary_pipes(crtc_state);
> > +}
> > +
> > +bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state)
> > +{
> > +	if (!intel_is_joiner(crtc_state))
> > +		return false;
> > +
> > +	return !intel_crtc_is_bigjoiner_primary(crtc_state);
> > +}
> > +
> > +bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state)
> > +{
> > +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> > +
> > +	return intel_crtc_is_ultrajoiner(crtc_state) &&
> > +		(crtc->pipe == joiner_primary_pipe(crtc_state));
> > +}
> > +
> >   u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state)
> >   {
> >   	if (crtc_state->joiner_pipes)
> > @@ -276,11 +338,6 @@ bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state)
> >   		crtc->pipe == joiner_primary_pipe(crtc_state);
> >   }
> >   
> > -int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
> > -{
> > -	return hweight8(crtc_state->joiner_pipes);
> > -}
> > -
> >   u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
> >   {
> >   	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> > @@ -288,7 +345,7 @@ u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
> >   	return BIT(crtc->pipe) | crtc_state->joiner_pipes;
> >   }
> >   
> > -struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state)
> > +struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state)
> >   {
> >   	struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
> >   
> > @@ -808,7 +865,7 @@ intel_get_crtc_new_encoder(const struct intel_atomic_state *state,
> >   	int num_encoders = 0;
> >   	int i;
> >   
> > -	primary_crtc = intel_primary_crtc(crtc_state);
> > +	primary_crtc = intel_joiner_primary_crtc(crtc_state);
> >   
> >   	for_each_new_connector_in_state(&state->base, connector, connector_state, i) {
> >   		if (connector_state->crtc != &primary_crtc->base)
> > @@ -4527,7 +4584,7 @@ copy_joiner_crtc_state_nomodeset(struct intel_atomic_state *state,
> >   {
> >   	struct intel_crtc_state *secondary_crtc_state =
> >   		intel_atomic_get_new_crtc_state(state, secondary_crtc);
> > -	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
> > +	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
> >   	const struct intel_crtc_state *primary_crtc_state =
> >   		intel_atomic_get_new_crtc_state(state, primary_crtc);
> >   
> > @@ -4547,7 +4604,7 @@ copy_joiner_crtc_state_modeset(struct intel_atomic_state *state,
> >   {
> >   	struct intel_crtc_state *secondary_crtc_state =
> >   		intel_atomic_get_new_crtc_state(state, secondary_crtc);
> > -	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
> > +	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
> >   	const struct intel_crtc_state *primary_crtc_state =
> >   		intel_atomic_get_new_crtc_state(state, primary_crtc);
> >   	struct intel_crtc_state *saved_state;
> > diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
> > index bf665f947b97..35e68e4cc712 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display.h
> > +++ b/drivers/gpu/drm/i915/display/intel_display.h
> > @@ -424,10 +424,14 @@ enum phy intel_port_to_phy(struct drm_i915_private *i915, enum port port);
> >   bool is_trans_port_sync_mode(const struct intel_crtc_state *state);
> >   bool is_trans_port_sync_master(const struct intel_crtc_state *state);
> >   u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state);
> > -bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
> >   bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state);
> > +bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
> > +bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state);
> > +bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state);
> > +bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state);
> > +bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state);
> >   u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state);
> > -struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state);
> > +struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state);
> >   bool intel_crtc_get_pipe_config(struct intel_crtc_state *crtc_state);
> >   bool intel_pipe_config_compare(const struct intel_crtc_state *current_config,
> >   			       const struct intel_crtc_state *pipe_config,
> > diff --git a/drivers/gpu/drm/i915/display/intel_modeset_verify.c b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> > index 3491db5cad31..b53b810c6470 100644
> > --- a/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> > +++ b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
> > @@ -193,7 +193,7 @@ verify_crtc_state(struct intel_atomic_state *state,
> >   			"transitional active state does not match atomic hw state (expected %i, found %i)\n",
> >   			sw_crtc_state->hw.active, crtc->active);
> >   
> > -	primary_crtc = intel_primary_crtc(sw_crtc_state);
> > +	primary_crtc = intel_joiner_primary_crtc(sw_crtc_state);
> >   
> >   	for_each_encoder_on_crtc(dev, &primary_crtc->base, encoder) {
> >   		enum pipe pipe;
> > diff --git a/drivers/gpu/drm/i915/display/intel_vdsc.c b/drivers/gpu/drm/i915/display/intel_vdsc.c
> > index b9687b7692b8..11058bb37d5a 100644
> > --- a/drivers/gpu/drm/i915/display/intel_vdsc.c
> > +++ b/drivers/gpu/drm/i915/display/intel_vdsc.c
> > @@ -761,7 +761,7 @@ void intel_uncompressed_joiner_enable(const struct intel_crtc_state *crtc_state)
> >   	u32 dss_ctl1_val = 0;
> >   
> >   	if (crtc_state->joiner_pipes && !crtc_state->dsc.compression_enable) {
> > -		if (intel_crtc_is_joiner_secondary(crtc_state))
> > +		if (intel_crtc_is_bigjoiner_secondary(crtc_state))
> >   			dss_ctl1_val |= UNCOMPRESSED_JOINER_SECONDARY;
> >   		else
> >   			dss_ctl1_val |= UNCOMPRESSED_JOINER_PRIMARY;
> > @@ -790,7 +790,7 @@ void intel_dsc_enable(const struct intel_crtc_state *crtc_state)
> >   	}
> >   	if (crtc_state->joiner_pipes) {
> >   		dss_ctl1_val |= BIG_JOINER_ENABLE;
> > -		if (!intel_crtc_is_joiner_secondary(crtc_state))
> > +		if (intel_crtc_is_bigjoiner_primary(crtc_state))
> >   			dss_ctl1_val |= PRIMARY_BIG_JOINER_ENABLE;
> >   	}
> >   	intel_de_write(dev_priv, dss_ctl1_reg(crtc, crtc_state->cpu_transcoder), dss_ctl1_val);
Nautiyal, Ankit K Aug. 21, 2024, 2:48 p.m. UTC | #4
On 8/21/2024 7:11 PM, Ville Syrjälä wrote:
> On Fri, Aug 16, 2024 at 01:53:20PM +0530, Nautiyal, Ankit K wrote:
>> On 7/18/2024 1:47 PM, Ankit Nautiyal wrote:
>>> From: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
>>>
>>> In most of the cases we now try to avoid mentioning things like
>>> "bigjoiner" or "ultrajoiner" trying to unify the API and refer
>>> mostly to all this functionality as "joiner".
>>> In majority cases that should be way to go.
>>> However in some cases we still need to distinguish between
>>> bigjoiner primaries and secondaries(such as DSC register programming).
>>>
>>> Create correspondent helper functions and start using them,
>>> in order be prepared for adding ultrajoiner functionality.
>>>
>>> v2: Fixed checkpatch warnings (Ankit)
>>>
>>> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
>>> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
>>> ---
>>>    .../gpu/drm/i915/display/intel_atomic_plane.c |  2 +-
>>>    drivers/gpu/drm/i915/display/intel_display.c  | 75 ++++++++++++++++---
>>>    drivers/gpu/drm/i915/display/intel_display.h  |  8 +-
>>>    .../drm/i915/display/intel_modeset_verify.c   |  2 +-
>>>    drivers/gpu/drm/i915/display/intel_vdsc.c     |  4 +-
>>>    5 files changed, 76 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
>>> index e979786aa5cf..9862d0339e6a 100644
>>> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
>>> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
>>> @@ -724,7 +724,7 @@ int intel_plane_atomic_check(struct intel_atomic_state *state,
>>>    
>>>    	if (new_crtc_state && intel_crtc_is_joiner_secondary(new_crtc_state)) {
>>>    		struct intel_crtc *primary_crtc =
>>> -			intel_primary_crtc(new_crtc_state);
>>> +			intel_joiner_primary_crtc(new_crtc_state);
>>>    		struct intel_plane *primary_crtc_plane =
>>>    			intel_crtc_get_plane(primary_crtc, plane->id);
>>>    
>>> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
>>> index 26e4b0c2e9f7..38e7c6811bf3 100644
>>> --- a/drivers/gpu/drm/i915/display/intel_display.c
>>> +++ b/drivers/gpu/drm/i915/display/intel_display.c
>>> @@ -252,6 +252,68 @@ static enum pipe joiner_primary_pipe(const struct intel_crtc_state *crtc_state)
>>>    	return ffs(crtc_state->joiner_pipes) - 1;
>>>    }
>>>    
>>> +int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
>>> +{
>>> +	return hweight8(crtc_state->joiner_pipes);
>>> +}
>>> +
>>> +bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state)
>>> +{
>>> +	return intel_joiner_num_pipes(crtc_state) == 4;
>>
>> On having a re-look, I think we need to change this. Currently there is
>> no way of knowing if its 2 set of bigjoiners or 1 ultrajoiner.
> There is no such thing as 2 sets of bigjoiners on one crtc.

Oh right, sorry for the mixup and confusion.

In case of 2 bigjoiners AB and CD, for pipes A and B the joiner_pipes 
will read 0x3 and for C and D it will read 0xc.

In case of ultrajoiner, for all pipes the joiner_pipes will read 0xf.

Regards,

Ankit

>   
>
>> Perhaps need one more bit for ultrajoiner or a different flag altogether.
>>
>> Regards,
>>
>> Ankit
>>
>>> +}
>>> +
>>> +static bool intel_is_joiner(const struct intel_crtc_state *crtc_state)
>>> +{
>>> +	return intel_joiner_num_pipes(crtc_state) > 1;
>>> +}
>>> +
>>> +static u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state)
>>> +{
>>> +	int lsb = ffs(crtc_state->joiner_pipes) - 1;
>>> +	int msb = fls(crtc_state->joiner_pipes) - 1;
>>> +	int i;
>>> +	u8 bigjoiner_primary_mask = 0;
>>> +
>>> +	for (i = lsb; i < msb; i += 4) {
>>> +		/*
>>> +		 * Regardless of how joiner_pipes mask is set, currently
>>> +		 * we always assume, that primary pipe bit goes before secondary
>>> +		 * pipe bit. So in each set of 2 bits, least significant bit is
>>> +		 * bigjoiner primary pipe and most significant bit is secondary pipe.
>>> +		 */
>>> +		bigjoiner_primary_mask |=
>>> +			((BIT(0) | BIT(2)) << i) & crtc_state->joiner_pipes;
>>> +	}
>>> +
>>> +	return bigjoiner_primary_mask;
>>> +}
>>> +
>>> +bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state)
>>> +{
>>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>> +
>>> +	if (!intel_is_joiner(crtc_state))
>>> +		return false;
>>> +
>>> +	return BIT(crtc->pipe) & bigjoiner_primary_pipes(crtc_state);
>>> +}
>>> +
>>> +bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state)
>>> +{
>>> +	if (!intel_is_joiner(crtc_state))
>>> +		return false;
>>> +
>>> +	return !intel_crtc_is_bigjoiner_primary(crtc_state);
>>> +}
>>> +
>>> +bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state)
>>> +{
>>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>> +
>>> +	return intel_crtc_is_ultrajoiner(crtc_state) &&
>>> +		(crtc->pipe == joiner_primary_pipe(crtc_state));
>>> +}
>>> +
>>>    u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state)
>>>    {
>>>    	if (crtc_state->joiner_pipes)
>>> @@ -276,11 +338,6 @@ bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state)
>>>    		crtc->pipe == joiner_primary_pipe(crtc_state);
>>>    }
>>>    
>>> -int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
>>> -{
>>> -	return hweight8(crtc_state->joiner_pipes);
>>> -}
>>> -
>>>    u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
>>>    {
>>>    	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>> @@ -288,7 +345,7 @@ u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
>>>    	return BIT(crtc->pipe) | crtc_state->joiner_pipes;
>>>    }
>>>    
>>> -struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state)
>>> +struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state)
>>>    {
>>>    	struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
>>>    
>>> @@ -808,7 +865,7 @@ intel_get_crtc_new_encoder(const struct intel_atomic_state *state,
>>>    	int num_encoders = 0;
>>>    	int i;
>>>    
>>> -	primary_crtc = intel_primary_crtc(crtc_state);
>>> +	primary_crtc = intel_joiner_primary_crtc(crtc_state);
>>>    
>>>    	for_each_new_connector_in_state(&state->base, connector, connector_state, i) {
>>>    		if (connector_state->crtc != &primary_crtc->base)
>>> @@ -4527,7 +4584,7 @@ copy_joiner_crtc_state_nomodeset(struct intel_atomic_state *state,
>>>    {
>>>    	struct intel_crtc_state *secondary_crtc_state =
>>>    		intel_atomic_get_new_crtc_state(state, secondary_crtc);
>>> -	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
>>> +	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
>>>    	const struct intel_crtc_state *primary_crtc_state =
>>>    		intel_atomic_get_new_crtc_state(state, primary_crtc);
>>>    
>>> @@ -4547,7 +4604,7 @@ copy_joiner_crtc_state_modeset(struct intel_atomic_state *state,
>>>    {
>>>    	struct intel_crtc_state *secondary_crtc_state =
>>>    		intel_atomic_get_new_crtc_state(state, secondary_crtc);
>>> -	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
>>> +	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
>>>    	const struct intel_crtc_state *primary_crtc_state =
>>>    		intel_atomic_get_new_crtc_state(state, primary_crtc);
>>>    	struct intel_crtc_state *saved_state;
>>> diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
>>> index bf665f947b97..35e68e4cc712 100644
>>> --- a/drivers/gpu/drm/i915/display/intel_display.h
>>> +++ b/drivers/gpu/drm/i915/display/intel_display.h
>>> @@ -424,10 +424,14 @@ enum phy intel_port_to_phy(struct drm_i915_private *i915, enum port port);
>>>    bool is_trans_port_sync_mode(const struct intel_crtc_state *state);
>>>    bool is_trans_port_sync_master(const struct intel_crtc_state *state);
>>>    u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state);
>>> -bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
>>>    bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state);
>>> +bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
>>> +bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state);
>>> +bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state);
>>> +bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state);
>>> +bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state);
>>>    u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state);
>>> -struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state);
>>> +struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state);
>>>    bool intel_crtc_get_pipe_config(struct intel_crtc_state *crtc_state);
>>>    bool intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>>>    			       const struct intel_crtc_state *pipe_config,
>>> diff --git a/drivers/gpu/drm/i915/display/intel_modeset_verify.c b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
>>> index 3491db5cad31..b53b810c6470 100644
>>> --- a/drivers/gpu/drm/i915/display/intel_modeset_verify.c
>>> +++ b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
>>> @@ -193,7 +193,7 @@ verify_crtc_state(struct intel_atomic_state *state,
>>>    			"transitional active state does not match atomic hw state (expected %i, found %i)\n",
>>>    			sw_crtc_state->hw.active, crtc->active);
>>>    
>>> -	primary_crtc = intel_primary_crtc(sw_crtc_state);
>>> +	primary_crtc = intel_joiner_primary_crtc(sw_crtc_state);
>>>    
>>>    	for_each_encoder_on_crtc(dev, &primary_crtc->base, encoder) {
>>>    		enum pipe pipe;
>>> diff --git a/drivers/gpu/drm/i915/display/intel_vdsc.c b/drivers/gpu/drm/i915/display/intel_vdsc.c
>>> index b9687b7692b8..11058bb37d5a 100644
>>> --- a/drivers/gpu/drm/i915/display/intel_vdsc.c
>>> +++ b/drivers/gpu/drm/i915/display/intel_vdsc.c
>>> @@ -761,7 +761,7 @@ void intel_uncompressed_joiner_enable(const struct intel_crtc_state *crtc_state)
>>>    	u32 dss_ctl1_val = 0;
>>>    
>>>    	if (crtc_state->joiner_pipes && !crtc_state->dsc.compression_enable) {
>>> -		if (intel_crtc_is_joiner_secondary(crtc_state))
>>> +		if (intel_crtc_is_bigjoiner_secondary(crtc_state))
>>>    			dss_ctl1_val |= UNCOMPRESSED_JOINER_SECONDARY;
>>>    		else
>>>    			dss_ctl1_val |= UNCOMPRESSED_JOINER_PRIMARY;
>>> @@ -790,7 +790,7 @@ void intel_dsc_enable(const struct intel_crtc_state *crtc_state)
>>>    	}
>>>    	if (crtc_state->joiner_pipes) {
>>>    		dss_ctl1_val |= BIG_JOINER_ENABLE;
>>> -		if (!intel_crtc_is_joiner_secondary(crtc_state))
>>> +		if (intel_crtc_is_bigjoiner_primary(crtc_state))
>>>    			dss_ctl1_val |= PRIMARY_BIG_JOINER_ENABLE;
>>>    	}
>>>    	intel_de_write(dev_priv, dss_ctl1_reg(crtc, crtc_state->cpu_transcoder), dss_ctl1_val);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index e979786aa5cf..9862d0339e6a 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -724,7 +724,7 @@  int intel_plane_atomic_check(struct intel_atomic_state *state,
 
 	if (new_crtc_state && intel_crtc_is_joiner_secondary(new_crtc_state)) {
 		struct intel_crtc *primary_crtc =
-			intel_primary_crtc(new_crtc_state);
+			intel_joiner_primary_crtc(new_crtc_state);
 		struct intel_plane *primary_crtc_plane =
 			intel_crtc_get_plane(primary_crtc, plane->id);
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 26e4b0c2e9f7..38e7c6811bf3 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -252,6 +252,68 @@  static enum pipe joiner_primary_pipe(const struct intel_crtc_state *crtc_state)
 	return ffs(crtc_state->joiner_pipes) - 1;
 }
 
+int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
+{
+	return hweight8(crtc_state->joiner_pipes);
+}
+
+bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state)
+{
+	return intel_joiner_num_pipes(crtc_state) == 4;
+}
+
+static bool intel_is_joiner(const struct intel_crtc_state *crtc_state)
+{
+	return intel_joiner_num_pipes(crtc_state) > 1;
+}
+
+static u8 bigjoiner_primary_pipes(const struct intel_crtc_state *crtc_state)
+{
+	int lsb = ffs(crtc_state->joiner_pipes) - 1;
+	int msb = fls(crtc_state->joiner_pipes) - 1;
+	int i;
+	u8 bigjoiner_primary_mask = 0;
+
+	for (i = lsb; i < msb; i += 4) {
+		/*
+		 * Regardless of how joiner_pipes mask is set, currently
+		 * we always assume, that primary pipe bit goes before secondary
+		 * pipe bit. So in each set of 2 bits, least significant bit is
+		 * bigjoiner primary pipe and most significant bit is secondary pipe.
+		 */
+		bigjoiner_primary_mask |=
+			((BIT(0) | BIT(2)) << i) & crtc_state->joiner_pipes;
+	}
+
+	return bigjoiner_primary_mask;
+}
+
+bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+
+	if (!intel_is_joiner(crtc_state))
+		return false;
+
+	return BIT(crtc->pipe) & bigjoiner_primary_pipes(crtc_state);
+}
+
+bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state)
+{
+	if (!intel_is_joiner(crtc_state))
+		return false;
+
+	return !intel_crtc_is_bigjoiner_primary(crtc_state);
+}
+
+bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+
+	return intel_crtc_is_ultrajoiner(crtc_state) &&
+		(crtc->pipe == joiner_primary_pipe(crtc_state));
+}
+
 u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state)
 {
 	if (crtc_state->joiner_pipes)
@@ -276,11 +338,6 @@  bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state)
 		crtc->pipe == joiner_primary_pipe(crtc_state);
 }
 
-int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
-{
-	return hweight8(crtc_state->joiner_pipes);
-}
-
 u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
@@ -288,7 +345,7 @@  u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
 	return BIT(crtc->pipe) | crtc_state->joiner_pipes;
 }
 
-struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state)
+struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state)
 {
 	struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
 
@@ -808,7 +865,7 @@  intel_get_crtc_new_encoder(const struct intel_atomic_state *state,
 	int num_encoders = 0;
 	int i;
 
-	primary_crtc = intel_primary_crtc(crtc_state);
+	primary_crtc = intel_joiner_primary_crtc(crtc_state);
 
 	for_each_new_connector_in_state(&state->base, connector, connector_state, i) {
 		if (connector_state->crtc != &primary_crtc->base)
@@ -4527,7 +4584,7 @@  copy_joiner_crtc_state_nomodeset(struct intel_atomic_state *state,
 {
 	struct intel_crtc_state *secondary_crtc_state =
 		intel_atomic_get_new_crtc_state(state, secondary_crtc);
-	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
+	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
 	const struct intel_crtc_state *primary_crtc_state =
 		intel_atomic_get_new_crtc_state(state, primary_crtc);
 
@@ -4547,7 +4604,7 @@  copy_joiner_crtc_state_modeset(struct intel_atomic_state *state,
 {
 	struct intel_crtc_state *secondary_crtc_state =
 		intel_atomic_get_new_crtc_state(state, secondary_crtc);
-	struct intel_crtc *primary_crtc = intel_primary_crtc(secondary_crtc_state);
+	struct intel_crtc *primary_crtc = intel_joiner_primary_crtc(secondary_crtc_state);
 	const struct intel_crtc_state *primary_crtc_state =
 		intel_atomic_get_new_crtc_state(state, primary_crtc);
 	struct intel_crtc_state *saved_state;
diff --git a/drivers/gpu/drm/i915/display/intel_display.h b/drivers/gpu/drm/i915/display/intel_display.h
index bf665f947b97..35e68e4cc712 100644
--- a/drivers/gpu/drm/i915/display/intel_display.h
+++ b/drivers/gpu/drm/i915/display/intel_display.h
@@ -424,10 +424,14 @@  enum phy intel_port_to_phy(struct drm_i915_private *i915, enum port port);
 bool is_trans_port_sync_mode(const struct intel_crtc_state *state);
 bool is_trans_port_sync_master(const struct intel_crtc_state *state);
 u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state);
-bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
 bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state);
+bool intel_crtc_is_joiner_secondary(const struct intel_crtc_state *crtc_state);
+bool intel_crtc_is_bigjoiner_primary(const struct intel_crtc_state *crtc_state);
+bool intel_crtc_is_bigjoiner_secondary(const struct intel_crtc_state *crtc_state);
+bool intel_crtc_is_ultrajoiner(const struct intel_crtc_state *crtc_state);
+bool intel_crtc_is_ultrajoiner_primary(const struct intel_crtc_state *crtc_state);
 u8 intel_crtc_joiner_secondary_pipes(const struct intel_crtc_state *crtc_state);
-struct intel_crtc *intel_primary_crtc(const struct intel_crtc_state *crtc_state);
+struct intel_crtc *intel_joiner_primary_crtc(const struct intel_crtc_state *crtc_state);
 bool intel_crtc_get_pipe_config(struct intel_crtc_state *crtc_state);
 bool intel_pipe_config_compare(const struct intel_crtc_state *current_config,
 			       const struct intel_crtc_state *pipe_config,
diff --git a/drivers/gpu/drm/i915/display/intel_modeset_verify.c b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
index 3491db5cad31..b53b810c6470 100644
--- a/drivers/gpu/drm/i915/display/intel_modeset_verify.c
+++ b/drivers/gpu/drm/i915/display/intel_modeset_verify.c
@@ -193,7 +193,7 @@  verify_crtc_state(struct intel_atomic_state *state,
 			"transitional active state does not match atomic hw state (expected %i, found %i)\n",
 			sw_crtc_state->hw.active, crtc->active);
 
-	primary_crtc = intel_primary_crtc(sw_crtc_state);
+	primary_crtc = intel_joiner_primary_crtc(sw_crtc_state);
 
 	for_each_encoder_on_crtc(dev, &primary_crtc->base, encoder) {
 		enum pipe pipe;
diff --git a/drivers/gpu/drm/i915/display/intel_vdsc.c b/drivers/gpu/drm/i915/display/intel_vdsc.c
index b9687b7692b8..11058bb37d5a 100644
--- a/drivers/gpu/drm/i915/display/intel_vdsc.c
+++ b/drivers/gpu/drm/i915/display/intel_vdsc.c
@@ -761,7 +761,7 @@  void intel_uncompressed_joiner_enable(const struct intel_crtc_state *crtc_state)
 	u32 dss_ctl1_val = 0;
 
 	if (crtc_state->joiner_pipes && !crtc_state->dsc.compression_enable) {
-		if (intel_crtc_is_joiner_secondary(crtc_state))
+		if (intel_crtc_is_bigjoiner_secondary(crtc_state))
 			dss_ctl1_val |= UNCOMPRESSED_JOINER_SECONDARY;
 		else
 			dss_ctl1_val |= UNCOMPRESSED_JOINER_PRIMARY;
@@ -790,7 +790,7 @@  void intel_dsc_enable(const struct intel_crtc_state *crtc_state)
 	}
 	if (crtc_state->joiner_pipes) {
 		dss_ctl1_val |= BIG_JOINER_ENABLE;
-		if (!intel_crtc_is_joiner_secondary(crtc_state))
+		if (intel_crtc_is_bigjoiner_primary(crtc_state))
 			dss_ctl1_val |= PRIMARY_BIG_JOINER_ENABLE;
 	}
 	intel_de_write(dev_priv, dss_ctl1_reg(crtc, crtc_state->cpu_transcoder), dss_ctl1_val);