[Intel-gfx] [PATCH 2/5] drm/i915: add common intel_digital_port_connected function
Jani Nikula
jani.nikula at intel.com
Wed Aug 19 11:10:31 PDT 2015
On Wed, 19 Aug 2015, "R, Durgadoss" <durgadoss.r at intel.com> 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 ?
By "looking into" I really meant figuring out why pch split platforms
are different, and what, if anything, would break. ;)
Thanks for the review.
BR,
Jani.
>
> or,
> Can we add a WARN_ON()/MISSING_CASE() and then return -EINVAL ?
>
> 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
--
Jani Nikula, Intel Open Source Technology Center
More information about the Intel-gfx
mailing list