[Intel-gfx] [PATCH 2/5] drm/i915: add common intel_digital_port_connected function
Ville Syrjälä
ville.syrjala at linux.intel.com
Wed Aug 19 11:12:17 PDT 2015
On Wed, Aug 19, 2015 at 05:50:52PM +0000, R, Durgadoss wrote:
> >-----Original Message-----
> >From: Nikula, Jani
> >Sent: Wednesday, August 19, 2015 6:04 PM
> >To: intel-gfx at lists.freedesktop.org
> >Cc: R, Durgadoss
> >Subject: Re: [PATCH 2/5] drm/i915: add common intel_digital_port_connected function
> >
> >On Wed, 19 Aug 2015, Jani Nikula <jani.nikula at intel.com> wrote:
> >> Add a common intel_digital_port_connected() that splits out to functions
> >> for different platforms. No functional changes.
> >>
> >> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
> >> ---
> >> drivers/gpu/drm/i915/intel_dp.c | 53 ++++++++++++++++++++++-------------------
> >> 1 file changed, 28 insertions(+), 25 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> >> index 4aa3d664765b..d48af8b0c84e 100644
> >> --- a/drivers/gpu/drm/i915/intel_dp.c
> >> +++ b/drivers/gpu/drm/i915/intel_dp.c
> >> @@ -4473,15 +4473,8 @@ edp_detect(struct intel_dp *intel_dp)
> >> return status;
> >> }
> >>
> >> -/*
> >> - * ibx_digital_port_connected - is the specified port connected?
> >> - * @dev_priv: i915 private structure
> >> - * @port: the port to test
> >> - *
> >> - * Returns true if @port is connected, false otherwise.
> >> - */
> >> -static bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
> >> - struct intel_digital_port *port)
> >> +static int ibx_digital_port_connected(struct drm_i915_private *dev_priv,
> >> + struct intel_digital_port *port)
> >> {
> >> u32 bit;
> >>
> >> @@ -4497,7 +4490,7 @@ static bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
> >> bit = SDE_PORTD_HOTPLUG;
> >> break;
> >> default:
> >> - return true;
> >> + return 1;
> >> }
> >> } else {
> >> switch (port->port) {
> >> @@ -4511,20 +4504,19 @@ static bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
> >> bit = SDE_PORTD_HOTPLUG_CPT;
> >> break;
> >> default:
> >> - return true;
> >> + return 1;
> >
> >BTW a follow-up could look into making the ibx/cpt default cases return
> >-EINVAL like the g4x/vlv/bxt cases do.
>
> But the default case for ibx/cpt currently return 1 .. meaning "connected"
> as default result.. In this case, by returning -EINVAL,
> won't we break existing users ?
>
> or,
> Can we add a WARN_ON()/MISSING_CASE() and then return -EINVAL ?
Can we ever hit the default case except due to bugs somewhere else?
If not, then I suggest we just ignore it and make the thing return
bool.
>
> Thanks,
> Durga
>
> >
> >BR,
> >Jani.
> >
> >
> >> }
> >> }
> >>
> >> - return I915_READ(SDEISR) & bit;
> >> + return I915_READ(SDEISR) & bit ? 1 : 0;
> >> }
> >>
> >> -static int g4x_digital_port_connected(struct drm_device *dev,
> >> - struct intel_digital_port *intel_dig_port)
> >> +static int g4x_digital_port_connected(struct drm_i915_private *dev_priv,
> >> + struct intel_digital_port *intel_dig_port)
> >> {
> >> - struct drm_i915_private *dev_priv = dev->dev_private;
> >> uint32_t bit;
> >>
> >> - if (IS_VALLEYVIEW(dev)) {
> >> + if (IS_VALLEYVIEW(dev_priv)) {
> >> switch (intel_dig_port->port) {
> >> case PORT_B:
> >> bit = PORTB_HOTPLUG_LIVE_STATUS_VLV;
> >> @@ -4559,6 +4551,22 @@ static int g4x_digital_port_connected(struct drm_device *dev,
> >> return 1;
> >> }
> >>
> >> +/*
> >> + * intel_digital_port_connected - is the specified port connected?
> >> + * @dev_priv: i915 private structure
> >> + * @port: the port to test
> >> + *
> >> + * Returns a negative error code on errors, 1 for connected, 0 for disconnected.
> >> + */
> >> +static int intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >> + struct intel_digital_port *port)
> >> +{
> >> + if (HAS_PCH_SPLIT(dev_priv))
> >> + return ibx_digital_port_connected(dev_priv, port);
> >> + else
> >> + return g4x_digital_port_connected(dev_priv, port);
> >> +}
> >> +
> >> static enum drm_connector_status
> >> ironlake_dp_detect(struct intel_dp *intel_dp)
> >> {
> >> @@ -4566,7 +4574,7 @@ ironlake_dp_detect(struct intel_dp *intel_dp)
> >> struct drm_i915_private *dev_priv = dev->dev_private;
> >> struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
> >>
> >> - if (!ibx_digital_port_connected(dev_priv, intel_dig_port))
> >> + if (intel_digital_port_connected(dev_priv, intel_dig_port) != 1)
> >> return connector_status_disconnected;
> >>
> >> return intel_dp_detect_dpcd(intel_dp);
> >> @@ -4589,7 +4597,7 @@ g4x_dp_detect(struct intel_dp *intel_dp)
> >> return status;
> >> }
> >>
> >> - ret = g4x_digital_port_connected(dev, intel_dig_port);
> >> + ret = intel_digital_port_connected(dev->dev_private, intel_dig_port);
> >> if (ret == -EINVAL)
> >> return connector_status_unknown;
> >> else if (ret == 0)
> >> @@ -5055,13 +5063,8 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool
> >long_hpd)
> >> /* indicate that we need to restart link training */
> >> intel_dp->train_set_valid = false;
> >>
> >> - if (HAS_PCH_SPLIT(dev)) {
> >> - if (!ibx_digital_port_connected(dev_priv, intel_dig_port))
> >> - goto mst_fail;
> >> - } else {
> >> - if (g4x_digital_port_connected(dev, intel_dig_port) != 1)
> >> - goto mst_fail;
> >> - }
> >> + if (intel_digital_port_connected(dev_priv, intel_dig_port) != 1)
> >> + goto mst_fail;
> >>
> >> if (!intel_dp_get_dpcd(intel_dp)) {
> >> goto mst_fail;
> >> --
> >> 2.1.4
> >>
> >
> >--
> >Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ville Syrjälä
Intel OTC
More information about the Intel-gfx
mailing list