Skip to content

Commit 79708d1

Browse files
committed
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ä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Jani Nikula <[email protected]>
1 parent 739f8db commit 79708d1

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

drivers/gpu/drm/i915/display/intel_sdvo.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,11 +2931,38 @@ static u16 intel_sdvo_filter_output_flags(u16 flags)
29312931
return flags;
29322932
}
29332933

2934+
static bool intel_sdvo_output_init(struct intel_sdvo *sdvo, u16 type)
2935+
{
2936+
if (type & SDVO_TMDS_MASK)
2937+
return intel_sdvo_dvi_init(sdvo, type);
2938+
else if (type & SDVO_TV_MASK)
2939+
return intel_sdvo_tv_init(sdvo, type);
2940+
else if (type & SDVO_RGB_MASK)
2941+
return intel_sdvo_analog_init(sdvo, type);
2942+
else if (type & SDVO_LVDS_MASK)
2943+
return intel_sdvo_lvds_init(sdvo, type);
2944+
else
2945+
return false;
2946+
}
2947+
29342948
static bool
29352949
intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo)
29362950
{
2951+
static const u16 probe_order[] = {
2952+
SDVO_OUTPUT_TMDS0,
2953+
SDVO_OUTPUT_TMDS1,
2954+
/* TV has no XXX1 function block */
2955+
SDVO_OUTPUT_SVID0,
2956+
SDVO_OUTPUT_CVBS0,
2957+
SDVO_OUTPUT_YPRPB0,
2958+
SDVO_OUTPUT_RGB0,
2959+
SDVO_OUTPUT_RGB1,
2960+
SDVO_OUTPUT_LVDS0,
2961+
SDVO_OUTPUT_LVDS1,
2962+
};
29372963
struct drm_i915_private *i915 = to_i915(intel_sdvo->base.base.dev);
29382964
u16 flags;
2965+
int i;
29392966

29402967
flags = intel_sdvo_filter_output_flags(intel_sdvo->caps.output_flags);
29412968

@@ -2949,42 +2976,15 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo)
29492976

29502977
intel_sdvo_select_ddc_bus(i915, intel_sdvo);
29512978

2952-
if (flags & SDVO_OUTPUT_TMDS0)
2953-
if (!intel_sdvo_dvi_init(intel_sdvo, SDVO_OUTPUT_TMDS0))
2954-
return false;
2979+
for (i = 0; i < ARRAY_SIZE(probe_order); i++) {
2980+
u16 type = flags & probe_order[i];
29552981

2956-
if (flags & SDVO_OUTPUT_TMDS1)
2957-
if (!intel_sdvo_dvi_init(intel_sdvo, SDVO_OUTPUT_TMDS1))
2958-
return false;
2982+
if (!type)
2983+
continue;
29592984

2960-
/* TV has no XXX1 function block */
2961-
if (flags & SDVO_OUTPUT_SVID0)
2962-
if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_SVID0))
2963-
return false;
2964-
2965-
if (flags & SDVO_OUTPUT_CVBS0)
2966-
if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_CVBS0))
2967-
return false;
2968-
2969-
if (flags & SDVO_OUTPUT_YPRPB0)
2970-
if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_YPRPB0))
2971-
return false;
2972-
2973-
if (flags & SDVO_OUTPUT_RGB0)
2974-
if (!intel_sdvo_analog_init(intel_sdvo, SDVO_OUTPUT_RGB0))
2975-
return false;
2976-
2977-
if (flags & SDVO_OUTPUT_RGB1)
2978-
if (!intel_sdvo_analog_init(intel_sdvo, SDVO_OUTPUT_RGB1))
2979-
return false;
2980-
2981-
if (flags & SDVO_OUTPUT_LVDS0)
2982-
if (!intel_sdvo_lvds_init(intel_sdvo, SDVO_OUTPUT_LVDS0))
2983-
return false;
2984-
2985-
if (flags & SDVO_OUTPUT_LVDS1)
2986-
if (!intel_sdvo_lvds_init(intel_sdvo, SDVO_OUTPUT_LVDS1))
2985+
if (!intel_sdvo_output_init(intel_sdvo, type))
29872986
return false;
2987+
}
29882988

29892989
intel_sdvo->base.pipe_mask = ~0;
29902990

0 commit comments

Comments
 (0)