[Intel-gfx] [PATCH 6/8] drm/i915/sdvo: Get rid of the output type<->device index stuff

Jani Nikula jani.nikula at linux.intel.com
Thu Oct 27 14:42:32 UTC 2022


On Wed, 26 Oct 2022, Ville Syrjala <ville.syrjala at linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> Get rid of this silly output type<->device index back and
> forth and just pass the output type directly to the corresponding
> output init function. This was already being done for TV outputs
> anyway.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula at intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_sdvo.c | 47 +++++++++--------------
>  1 file changed, 19 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
> index d7943f9a96e7..4784c05a1b71 100644
> --- a/drivers/gpu/drm/i915/display/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
> @@ -2622,7 +2622,7 @@ intel_sdvo_unselect_i2c_bus(struct intel_sdvo *sdvo)
>  }
>  
>  static bool
> -intel_sdvo_is_hdmi_connector(struct intel_sdvo *intel_sdvo, int device)
> +intel_sdvo_is_hdmi_connector(struct intel_sdvo *intel_sdvo)
>  {
>  	return intel_sdvo_check_supp_encode(intel_sdvo);
>  }
> @@ -2727,7 +2727,7 @@ static struct intel_sdvo_connector *intel_sdvo_connector_alloc(void)
>  }
>  
>  static bool
> -intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
> +intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, u16 type)
>  {
>  	struct drm_encoder *encoder = &intel_sdvo->base.base;
>  	struct drm_connector *connector;
> @@ -2735,16 +2735,13 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
>  	struct intel_connector *intel_connector;
>  	struct intel_sdvo_connector *intel_sdvo_connector;
>  
> -	DRM_DEBUG_KMS("initialising DVI device %d\n", device);
> +	DRM_DEBUG_KMS("initialising DVI type 0x%x\n", type);
>  
>  	intel_sdvo_connector = intel_sdvo_connector_alloc();
>  	if (!intel_sdvo_connector)
>  		return false;
>  
> -	if (device == 0)
> -		intel_sdvo_connector->output_flag = SDVO_OUTPUT_TMDS0;
> -	else if (device == 1)
> -		intel_sdvo_connector->output_flag = SDVO_OUTPUT_TMDS1;
> +	intel_sdvo_connector->output_flag = type;
>  
>  	intel_connector = &intel_sdvo_connector->base;
>  	connector = &intel_connector->base;
> @@ -2764,7 +2761,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
>  	encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
>  	connector->connector_type = DRM_MODE_CONNECTOR_DVID;
>  
> -	if (intel_sdvo_is_hdmi_connector(intel_sdvo, device)) {
> +	if (intel_sdvo_is_hdmi_connector(intel_sdvo)) {
>  		connector->connector_type = DRM_MODE_CONNECTOR_HDMIA;
>  		intel_sdvo_connector->is_hdmi = true;
>  	}
> @@ -2781,14 +2778,14 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
>  }
>  
>  static bool
> -intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int type)
> +intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, u16 type)
>  {
>  	struct drm_encoder *encoder = &intel_sdvo->base.base;
>  	struct drm_connector *connector;
>  	struct intel_connector *intel_connector;
>  	struct intel_sdvo_connector *intel_sdvo_connector;
>  
> -	DRM_DEBUG_KMS("initialising TV type %d\n", type);
> +	DRM_DEBUG_KMS("initialising TV type 0x%x\n", type);
>  
>  	intel_sdvo_connector = intel_sdvo_connector_alloc();
>  	if (!intel_sdvo_connector)
> @@ -2820,14 +2817,14 @@ intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int type)
>  }
>  
>  static bool
> -intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device)
> +intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, u16 type)
>  {
>  	struct drm_encoder *encoder = &intel_sdvo->base.base;
>  	struct drm_connector *connector;
>  	struct intel_connector *intel_connector;
>  	struct intel_sdvo_connector *intel_sdvo_connector;
>  
> -	DRM_DEBUG_KMS("initialising analog device %d\n", device);
> +	DRM_DEBUG_KMS("initialising analog type 0x%x\n", type);
>  
>  	intel_sdvo_connector = intel_sdvo_connector_alloc();
>  	if (!intel_sdvo_connector)
> @@ -2839,10 +2836,7 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device)
>  	encoder->encoder_type = DRM_MODE_ENCODER_DAC;
>  	connector->connector_type = DRM_MODE_CONNECTOR_VGA;
>  
> -	if (device == 0)
> -		intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB0;
> -	else if (device == 1)
> -		intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB1;
> +	intel_sdvo_connector->output_flag = type;
>  
>  	if (intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo) < 0) {
>  		kfree(intel_sdvo_connector);
> @@ -2853,7 +2847,7 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device)
>  }
>  
>  static bool
> -intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device)
> +intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, u16 type)
>  {
>  	struct drm_encoder *encoder = &intel_sdvo->base.base;
>  	struct drm_i915_private *i915 = to_i915(encoder->dev);
> @@ -2861,7 +2855,7 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device)
>  	struct intel_connector *intel_connector;
>  	struct intel_sdvo_connector *intel_sdvo_connector;
>  
> -	DRM_DEBUG_KMS("initialising LVDS device %d\n", device);
> +	DRM_DEBUG_KMS("initialising LVDS type 0x%x\n", type);
>  
>  	intel_sdvo_connector = intel_sdvo_connector_alloc();
>  	if (!intel_sdvo_connector)
> @@ -2872,10 +2866,7 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device)
>  	encoder->encoder_type = DRM_MODE_ENCODER_LVDS;
>  	connector->connector_type = DRM_MODE_CONNECTOR_LVDS;
>  
> -	if (device == 0)
> -		intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS0;
> -	else if (device == 1)
> -		intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1;
> +	intel_sdvo_connector->output_flag = type;
>  
>  	if (intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo) < 0) {
>  		kfree(intel_sdvo_connector);
> @@ -2950,11 +2941,11 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo)
>  	intel_sdvo_select_ddc_bus(i915, intel_sdvo);
>  
>  	if (flags & SDVO_OUTPUT_TMDS0)
> -		if (!intel_sdvo_dvi_init(intel_sdvo, 0))
> +		if (!intel_sdvo_dvi_init(intel_sdvo, SDVO_OUTPUT_TMDS0))
>  			return false;
>  
>  	if (flags & SDVO_OUTPUT_TMDS1)
> -		if (!intel_sdvo_dvi_init(intel_sdvo, 1))
> +		if (!intel_sdvo_dvi_init(intel_sdvo, SDVO_OUTPUT_TMDS1))
>  			return false;
>  
>  	/* TV has no XXX1 function block */
> @@ -2971,19 +2962,19 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo)
>  			return false;
>  
>  	if (flags & SDVO_OUTPUT_RGB0)
> -		if (!intel_sdvo_analog_init(intel_sdvo, 0))
> +		if (!intel_sdvo_analog_init(intel_sdvo, SDVO_OUTPUT_RGB0))
>  			return false;
>  
>  	if (flags & SDVO_OUTPUT_RGB1)
> -		if (!intel_sdvo_analog_init(intel_sdvo, 1))
> +		if (!intel_sdvo_analog_init(intel_sdvo, SDVO_OUTPUT_RGB1))
>  			return false;
>  
>  	if (flags & SDVO_OUTPUT_LVDS0)
> -		if (!intel_sdvo_lvds_init(intel_sdvo, 0))
> +		if (!intel_sdvo_lvds_init(intel_sdvo, SDVO_OUTPUT_LVDS0))
>  			return false;
>  
>  	if (flags & SDVO_OUTPUT_LVDS1)
> -		if (!intel_sdvo_lvds_init(intel_sdvo, 1))
> +		if (!intel_sdvo_lvds_init(intel_sdvo, SDVO_OUTPUT_LVDS1))
>  			return false;
>  
>  	intel_sdvo->base.pipe_mask = ~0;

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the Intel-gfx mailing list