From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 7/8] drm/i915/sdvo: Reduce copy-pasta in output setup
Date: Thu, 27 Oct 2022 17:45:02 +0300 [thread overview]
Message-ID: <87bkpxcolt.fsf@intel.com> (raw)
In-Reply-To: <20221026101134.20865-8-ville.syrjala@linux.intel.com>
On Wed, 26 Oct 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> 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>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_sdvo.c | 66 +++++++++++------------
> 1 file 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 4784c05a1b71..58d147cc7633 100644
> --- a/drivers/gpu/drm/i915/display/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
> @@ -2922,11 +2922,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);
>
> @@ -2940,42 +2967,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;
> -
> - if (flags & SDVO_OUTPUT_TMDS1)
> - if (!intel_sdvo_dvi_init(intel_sdvo, SDVO_OUTPUT_TMDS1))
> - return false;
> -
> - /* 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;
> + for (i = 0; i < ARRAY_SIZE(probe_order); i++) {
> + u16 type = flags & probe_order[i];
>
> - 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 (!type)
> + continue;
>
> - 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;
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2022-10-27 14:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 10:11 [Intel-gfx] [PATCH 0/8] drm/i915/sdvo: Fix LVDS fixed mode setup and clean up output setup Ville Syrjala
2022-10-26 10:11 ` [Intel-gfx] [PATCH 1/8] drm/i915/sdvo: Filter out invalid outputs more sensibly Ville Syrjala
2022-10-26 10:11 ` Ville Syrjala
2022-10-27 14:32 ` [Intel-gfx] " Jani Nikula
2022-10-26 10:11 ` [Intel-gfx] [PATCH 2/8] drm/i915/sdvo: Setup DDC fully before output init Ville Syrjala
2022-10-26 10:11 ` Ville Syrjala
2022-10-27 14:36 ` [Intel-gfx] " Jani Nikula
2022-10-27 14:49 ` Ville Syrjälä
2022-10-27 14:54 ` Ville Syrjälä
2022-10-27 17:33 ` Jani Nikula
2022-10-26 10:11 ` [Intel-gfx] [PATCH 3/8] drm/i915/sdvo: Grab mode_config.mutex during LVDS init to avoid WARNs Ville Syrjala
2022-10-26 10:11 ` Ville Syrjala
2022-10-27 14:37 ` [Intel-gfx] " Jani Nikula
2022-10-26 10:11 ` [Intel-gfx] [PATCH 4/8] drm/i915/sdvo: Simplify output setup debugs Ville Syrjala
2022-10-27 14:38 ` Jani Nikula
2022-10-26 10:11 ` [Intel-gfx] [PATCH 5/8] drm/i915/sdvo: Don't add DDC modes for LVDS Ville Syrjala
2022-10-27 14:42 ` Jani Nikula
2022-10-26 10:11 ` [Intel-gfx] [PATCH 6/8] drm/i915/sdvo: Get rid of the output type<->device index stuff Ville Syrjala
2022-10-27 14:42 ` Jani Nikula
2022-10-26 10:11 ` [Intel-gfx] [PATCH 7/8] drm/i915/sdvo: Reduce copy-pasta in output setup Ville Syrjala
2022-10-27 14:45 ` Jani Nikula [this message]
2022-10-26 10:11 ` [Intel-gfx] [PATCH 8/8] drm/i915/sdvo: Fix debug print Ville Syrjala
2022-10-27 14:48 ` Jani Nikula
2022-10-26 11:25 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/sdvo: Fix LVDS fixed mode setup and clean up output setup Patchwork
2022-10-26 21:40 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkpxcolt.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.