summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/display/intel_sdvo.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2022-10-26 13:11:33 +0300
committerVille Syrjälä <ville.syrjala@linux.intel.com>2022-10-28 14:46:06 +0300
commit79708d142e65c59656aa231aa98e00334ced89a5 (patch)
tree0852b21783e2e9dcf547243cacc9295dacfde415 /drivers/gpu/drm/i915/display/intel_sdvo.c
parent739f8dbccf530277e3781a6a352018e972208522 (diff)
downloadlinux-79708d142e65c59656aa231aa98e00334ced89a5.tar.gz
linux-79708d142e65c59656aa231aa98e00334ced89a5.tar.bz2
linux-79708d142e65c59656aa231aa98e00334ced89a5.zip
drm/i915/sdvo: Reduce copy-pasta in output setup
Avoid having to call the output init function for each output type separately. We can just call the right one based on the "class" of the output. Technically we could just walk the bits of the bitmask but that could change the order in which we initialize the outputs. To avoid any behavioural changes keep to the same explicit probe order as before. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20221026101134.20865-8-ville.syrjala@linux.intel.com Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915/display/intel_sdvo.c')
-rw-r--r--drivers/gpu/drm/i915/display/intel_sdvo.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
index 94c297474adb..1e06c6fb2c62 100644
--- a/drivers/gpu/drm/i915/display/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
@@ -2931,11 +2931,38 @@ static u16 intel_sdvo_filter_output_flags(u16 flags)
return flags;
}
+static bool intel_sdvo_output_init(struct intel_sdvo *sdvo, u16 type)
+{
+ if (type & SDVO_TMDS_MASK)
+ return intel_sdvo_dvi_init(sdvo, type);
+ else if (type & SDVO_TV_MASK)
+ return intel_sdvo_tv_init(sdvo, type);
+ else if (type & SDVO_RGB_MASK)
+ return intel_sdvo_analog_init(sdvo, type);
+ else if (type & SDVO_LVDS_MASK)
+ return intel_sdvo_lvds_init(sdvo, type);
+ else
+ return false;
+}
+
static bool
intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo)
{
+ static const u16 probe_order[] = {
+ SDVO_OUTPUT_TMDS0,
+ SDVO_OUTPUT_TMDS1,
+ /* TV has no XXX1 function block */
+ SDVO_OUTPUT_SVID0,
+ SDVO_OUTPUT_CVBS0,
+ SDVO_OUTPUT_YPRPB0,
+ SDVO_OUTPUT_RGB0,
+ SDVO_OUTPUT_RGB1,
+ SDVO_OUTPUT_LVDS0,
+ SDVO_OUTPUT_LVDS1,
+ };
struct drm_i915_private *i915 = to_i915(intel_sdvo->base.base.dev);
u16 flags;
+ int i;
flags = intel_sdvo_filter_output_flags(intel_sdvo->caps.output_flags);
@@ -2949,42 +2976,15 @@ 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, SDVO_OUTPUT_TMDS0))
- return false;
+ for (i = 0; i < ARRAY_SIZE(probe_order); i++) {
+ u16 type = flags & probe_order[i];
- if (flags & SDVO_OUTPUT_TMDS1)
- if (!intel_sdvo_dvi_init(intel_sdvo, SDVO_OUTPUT_TMDS1))
- return false;
+ if (!type)
+ continue;
- /* TV has no XXX1 function block */
- if (flags & SDVO_OUTPUT_SVID0)
- if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_SVID0))
- return false;
-
- if (flags & SDVO_OUTPUT_CVBS0)
- if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_CVBS0))
- return false;
-
- if (flags & SDVO_OUTPUT_YPRPB0)
- if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_YPRPB0))
- return false;
-
- if (flags & SDVO_OUTPUT_RGB0)
- if (!intel_sdvo_analog_init(intel_sdvo, SDVO_OUTPUT_RGB0))
- return false;
-
- if (flags & SDVO_OUTPUT_RGB1)
- if (!intel_sdvo_analog_init(intel_sdvo, SDVO_OUTPUT_RGB1))
- return false;
-
- if (flags & SDVO_OUTPUT_LVDS0)
- if (!intel_sdvo_lvds_init(intel_sdvo, SDVO_OUTPUT_LVDS0))
- return false;
-
- if (flags & SDVO_OUTPUT_LVDS1)
- if (!intel_sdvo_lvds_init(intel_sdvo, SDVO_OUTPUT_LVDS1))
+ if (!intel_sdvo_output_init(intel_sdvo, type))
return false;
+ }
intel_sdvo->base.pipe_mask = ~0;