diff mbox series

[1/2] drm/i915/display: Refactor pch_panel_fitting to use local variables for crtc dimensions

Message ID 20240726095357.1261804-2-nemesa.garg@intel.com (mailing list archive)
State New, archived
Headers show
Series Consider joiner calculation for panel fitting | expand

Commit Message

Nemesa Garg July 26, 2024, 9:53 a.m. UTC
Refactor pch_panel_fitting to use local variables for crtc_hdisplay
and crtc_vdisplay. This will help to adjust the hdisplay at one place
when big/ultra joiner is involved. Introduce local variables crtc_hdisplay
and crtc_vdisplay and update all references to adjusted_mode->crtc_hdisplay
and adjusted_mode->crtc_vdisplay to use the new local variables.

Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
 drivers/gpu/drm/i915/display/intel_panel.c | 34 ++++++++++++----------
 1 file changed, 18 insertions(+), 16 deletions(-)

Comments

Nautiyal, Ankit K July 29, 2024, 2:43 p.m. UTC | #1
On 7/26/2024 3:23 PM, Nemesa Garg wrote:
> Refactor pch_panel_fitting to use local variables for crtc_hdisplay
> and crtc_vdisplay. This will help to adjust the hdisplay at one place
> when big/ultra joiner is involved. Introduce local variables crtc_hdisplay
> and crtc_vdisplay and update all references to adjusted_mode->crtc_hdisplay
> and adjusted_mode->crtc_vdisplay to use the new local variables.
>
> Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>

LGTM.

Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>


> ---
>   drivers/gpu/drm/i915/display/intel_panel.c | 34 ++++++++++++----------
>   1 file changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c
> index 71454ddef20f..dd18136d1c61 100644
> --- a/drivers/gpu/drm/i915/display/intel_panel.c
> +++ b/drivers/gpu/drm/i915/display/intel_panel.c
> @@ -392,10 +392,12 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
>   	int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
>   	int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
>   	int x, y, width, height;
> +	u16 crtc_hdisplay = adjusted_mode->crtc_hdisplay;
> +	u16 crtc_vdisplay = adjusted_mode->crtc_vdisplay;
>   
>   	/* Native modes don't need fitting */
> -	if (adjusted_mode->crtc_hdisplay == pipe_src_w &&
> -	    adjusted_mode->crtc_vdisplay == pipe_src_h &&
> +	if (crtc_hdisplay == pipe_src_w &&
> +	    crtc_vdisplay == pipe_src_h &&
>   	    crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420)
>   		return 0;
>   
> @@ -403,45 +405,45 @@ static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
>   	case DRM_MODE_SCALE_CENTER:
>   		width = pipe_src_w;
>   		height = pipe_src_h;
> -		x = (adjusted_mode->crtc_hdisplay - width + 1)/2;
> -		y = (adjusted_mode->crtc_vdisplay - height + 1)/2;
> +		x = (crtc_hdisplay - width + 1) / 2;
> +		y = (crtc_vdisplay - height + 1) / 2;
>   		break;
>   
>   	case DRM_MODE_SCALE_ASPECT:
>   		/* Scale but preserve the aspect ratio */
>   		{
> -			u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h;
> -			u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay;
> +			u32 scaled_width = crtc_hdisplay * pipe_src_h;
> +			u32 scaled_height = pipe_src_w * crtc_vdisplay;
>   			if (scaled_width > scaled_height) { /* pillar */
>   				width = scaled_height / pipe_src_h;
>   				if (width & 1)
>   					width++;
> -				x = (adjusted_mode->crtc_hdisplay - width + 1) / 2;
> +				x = (crtc_hdisplay - width + 1) / 2;
>   				y = 0;
> -				height = adjusted_mode->crtc_vdisplay;
> +				height = crtc_vdisplay;
>   			} else if (scaled_width < scaled_height) { /* letter */
>   				height = scaled_width / pipe_src_w;
>   				if (height & 1)
>   				    height++;
> -				y = (adjusted_mode->crtc_vdisplay - height + 1) / 2;
> +				y = (crtc_vdisplay - height + 1) / 2;
>   				x = 0;
> -				width = adjusted_mode->crtc_hdisplay;
> +				width = crtc_hdisplay;
>   			} else {
>   				x = y = 0;
> -				width = adjusted_mode->crtc_hdisplay;
> -				height = adjusted_mode->crtc_vdisplay;
> +				width = crtc_hdisplay;
> +				height = crtc_vdisplay;
>   			}
>   		}
>   		break;
>   
>   	case DRM_MODE_SCALE_NONE:
> -		WARN_ON(adjusted_mode->crtc_hdisplay != pipe_src_w);
> -		WARN_ON(adjusted_mode->crtc_vdisplay != pipe_src_h);
> +		WARN_ON(crtc_hdisplay != pipe_src_w);
> +		WARN_ON(crtc_vdisplay != pipe_src_h);
>   		fallthrough;
>   	case DRM_MODE_SCALE_FULLSCREEN:
>   		x = y = 0;
> -		width = adjusted_mode->crtc_hdisplay;
> -		height = adjusted_mode->crtc_vdisplay;
> +		width = crtc_hdisplay;
> +		height = crtc_vdisplay;
>   		break;
>   
>   	default:
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c
index 71454ddef20f..dd18136d1c61 100644
--- a/drivers/gpu/drm/i915/display/intel_panel.c
+++ b/drivers/gpu/drm/i915/display/intel_panel.c
@@ -392,10 +392,12 @@  static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
 	int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
 	int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
 	int x, y, width, height;
+	u16 crtc_hdisplay = adjusted_mode->crtc_hdisplay;
+	u16 crtc_vdisplay = adjusted_mode->crtc_vdisplay;
 
 	/* Native modes don't need fitting */
-	if (adjusted_mode->crtc_hdisplay == pipe_src_w &&
-	    adjusted_mode->crtc_vdisplay == pipe_src_h &&
+	if (crtc_hdisplay == pipe_src_w &&
+	    crtc_vdisplay == pipe_src_h &&
 	    crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420)
 		return 0;
 
@@ -403,45 +405,45 @@  static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
 	case DRM_MODE_SCALE_CENTER:
 		width = pipe_src_w;
 		height = pipe_src_h;
-		x = (adjusted_mode->crtc_hdisplay - width + 1)/2;
-		y = (adjusted_mode->crtc_vdisplay - height + 1)/2;
+		x = (crtc_hdisplay - width + 1) / 2;
+		y = (crtc_vdisplay - height + 1) / 2;
 		break;
 
 	case DRM_MODE_SCALE_ASPECT:
 		/* Scale but preserve the aspect ratio */
 		{
-			u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h;
-			u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay;
+			u32 scaled_width = crtc_hdisplay * pipe_src_h;
+			u32 scaled_height = pipe_src_w * crtc_vdisplay;
 			if (scaled_width > scaled_height) { /* pillar */
 				width = scaled_height / pipe_src_h;
 				if (width & 1)
 					width++;
-				x = (adjusted_mode->crtc_hdisplay - width + 1) / 2;
+				x = (crtc_hdisplay - width + 1) / 2;
 				y = 0;
-				height = adjusted_mode->crtc_vdisplay;
+				height = crtc_vdisplay;
 			} else if (scaled_width < scaled_height) { /* letter */
 				height = scaled_width / pipe_src_w;
 				if (height & 1)
 				    height++;
-				y = (adjusted_mode->crtc_vdisplay - height + 1) / 2;
+				y = (crtc_vdisplay - height + 1) / 2;
 				x = 0;
-				width = adjusted_mode->crtc_hdisplay;
+				width = crtc_hdisplay;
 			} else {
 				x = y = 0;
-				width = adjusted_mode->crtc_hdisplay;
-				height = adjusted_mode->crtc_vdisplay;
+				width = crtc_hdisplay;
+				height = crtc_vdisplay;
 			}
 		}
 		break;
 
 	case DRM_MODE_SCALE_NONE:
-		WARN_ON(adjusted_mode->crtc_hdisplay != pipe_src_w);
-		WARN_ON(adjusted_mode->crtc_vdisplay != pipe_src_h);
+		WARN_ON(crtc_hdisplay != pipe_src_w);
+		WARN_ON(crtc_vdisplay != pipe_src_h);
 		fallthrough;
 	case DRM_MODE_SCALE_FULLSCREEN:
 		x = y = 0;
-		width = adjusted_mode->crtc_hdisplay;
-		height = adjusted_mode->crtc_vdisplay;
+		width = crtc_hdisplay;
+		height = crtc_vdisplay;
 		break;
 
 	default: