diff mbox

[3/4] drm/i915/dp: Fetch downstream port info if needed during DPCD fetch

Message ID 1347980330-28544-3-git-send-email-ajax@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Adam Jackson Sept. 18, 2012, 2:58 p.m. UTC
v2: Fix parenthesis mismatch, spotted by Jani Nikula

Tested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 drivers/gpu/drm/i915/intel_dp.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

Comments

Jani Nikula Sept. 20, 2012, 12:28 p.m. UTC | #1
On Tue, 18 Sep 2012, Adam Jackson <ajax@redhat.com> wrote:
> v2: Fix parenthesis mismatch, spotted by Jani Nikula
>
> Tested-by: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Adam Jackson <ajax@redhat.com>
> ---
>  drivers/gpu/drm/i915/intel_dp.c |   25 ++++++++++++++++++++-----
>  1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index ace757a..098119e 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -39,6 +39,7 @@
>  #include "drm_dp_helper.h"
>  
>  #define DP_RECEIVER_CAP_SIZE	0xf
> +#define DP_MAX_DOWNSTREAM_PORTS 0xf

That should be 0x10. It doesn't matter in this series, but would be nice
to fix it for correctness. Sorry I didn't spot this the first time
around.

Otherwise, on the series,

Reviewed-by: Jani Nikula <jani.nikula@intel.com>


>  #define DP_LINK_STATUS_SIZE	6
>  #define DP_LINK_CHECK_TIMEOUT	(10 * 1000)
>  
> @@ -56,6 +57,7 @@ struct intel_dp {
>  	uint8_t link_bw;
>  	uint8_t lane_count;
>  	uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
> +	uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
>  	struct i2c_adapter adapter;
>  	struct i2c_algo_dp_aux_data algo;
>  	bool is_pch_edp;
> @@ -1968,12 +1970,25 @@ static bool
>  intel_dp_get_dpcd(struct intel_dp *intel_dp)
>  {
>  	if (intel_dp_aux_native_read_retry(intel_dp, 0x000, intel_dp->dpcd,
> -					   sizeof(intel_dp->dpcd)) &&
> -	    (intel_dp->dpcd[DP_DPCD_REV] != 0)) {
> -		return true;
> -	}
> +					   sizeof(intel_dp->dpcd)) == 0)
> +		return false; /* aux transfer failed */
>  
> -	return false;
> +	if (intel_dp->dpcd[DP_DPCD_REV] == 0)
> +		return false; /* DPCD not present */
> +
> +	if (!(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
> +	      DP_DWN_STRM_PORT_PRESENT))
> +		return true; /* native DP sink */
> +
> +	if (intel_dp->dpcd[DP_DPCD_REV] == 0x10)
> +		return true; /* no per-port downstream info */
> +
> +	if (intel_dp_aux_native_read_retry(intel_dp, DP_DOWNSTREAM_PORT_0,
> +					   intel_dp->downstream_ports,
> +					   DP_MAX_DOWNSTREAM_PORTS) == 0)
> +		return false; /* downstream port status fetch failed */
> +
> +	return true;
>  }
>  
>  static void
> -- 
> 1.7.7.6
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter Sept. 26, 2012, 12:23 p.m. UTC | #2
On Thu, Sep 20, 2012 at 03:28:45PM +0300, Jani Nikula wrote:
> On Tue, 18 Sep 2012, Adam Jackson <ajax@redhat.com> wrote:
> > v2: Fix parenthesis mismatch, spotted by Jani Nikula
> >
> > Tested-by: Takashi Iwai <tiwai@suse.de>
> > Signed-off-by: Adam Jackson <ajax@redhat.com>
> > ---
> >  drivers/gpu/drm/i915/intel_dp.c |   25 ++++++++++++++++++++-----
> >  1 files changed, 20 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > index ace757a..098119e 100644
> > --- a/drivers/gpu/drm/i915/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > @@ -39,6 +39,7 @@
> >  #include "drm_dp_helper.h"
> >  
> >  #define DP_RECEIVER_CAP_SIZE	0xf
> > +#define DP_MAX_DOWNSTREAM_PORTS 0xf
> 
> That should be 0x10. It doesn't matter in this series, but would be nice
> to fix it for correctness. Sorry I didn't spot this the first time
> around.
> 
> Otherwise, on the series,
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Ok, I've merged these 4 patches, with the #define fixed and a small merge
conflict resolved. Please yell if I've botched things up ...

Thanks, Daniel
> 
> 
> >  #define DP_LINK_STATUS_SIZE	6
> >  #define DP_LINK_CHECK_TIMEOUT	(10 * 1000)
> >  
> > @@ -56,6 +57,7 @@ struct intel_dp {
> >  	uint8_t link_bw;
> >  	uint8_t lane_count;
> >  	uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
> > +	uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
> >  	struct i2c_adapter adapter;
> >  	struct i2c_algo_dp_aux_data algo;
> >  	bool is_pch_edp;
> > @@ -1968,12 +1970,25 @@ static bool
> >  intel_dp_get_dpcd(struct intel_dp *intel_dp)
> >  {
> >  	if (intel_dp_aux_native_read_retry(intel_dp, 0x000, intel_dp->dpcd,
> > -					   sizeof(intel_dp->dpcd)) &&
> > -	    (intel_dp->dpcd[DP_DPCD_REV] != 0)) {
> > -		return true;
> > -	}
> > +					   sizeof(intel_dp->dpcd)) == 0)
> > +		return false; /* aux transfer failed */
> >  
> > -	return false;
> > +	if (intel_dp->dpcd[DP_DPCD_REV] == 0)
> > +		return false; /* DPCD not present */
> > +
> > +	if (!(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
> > +	      DP_DWN_STRM_PORT_PRESENT))
> > +		return true; /* native DP sink */
> > +
> > +	if (intel_dp->dpcd[DP_DPCD_REV] == 0x10)
> > +		return true; /* no per-port downstream info */
> > +
> > +	if (intel_dp_aux_native_read_retry(intel_dp, DP_DOWNSTREAM_PORT_0,
> > +					   intel_dp->downstream_ports,
> > +					   DP_MAX_DOWNSTREAM_PORTS) == 0)
> > +		return false; /* downstream port status fetch failed */
> > +
> > +	return true;
> >  }
> >  
> >  static void
> > -- 
> > 1.7.7.6
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index ace757a..098119e 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -39,6 +39,7 @@ 
 #include "drm_dp_helper.h"
 
 #define DP_RECEIVER_CAP_SIZE	0xf
+#define DP_MAX_DOWNSTREAM_PORTS 0xf
 #define DP_LINK_STATUS_SIZE	6
 #define DP_LINK_CHECK_TIMEOUT	(10 * 1000)
 
@@ -56,6 +57,7 @@  struct intel_dp {
 	uint8_t link_bw;
 	uint8_t lane_count;
 	uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
+	uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
 	struct i2c_adapter adapter;
 	struct i2c_algo_dp_aux_data algo;
 	bool is_pch_edp;
@@ -1968,12 +1970,25 @@  static bool
 intel_dp_get_dpcd(struct intel_dp *intel_dp)
 {
 	if (intel_dp_aux_native_read_retry(intel_dp, 0x000, intel_dp->dpcd,
-					   sizeof(intel_dp->dpcd)) &&
-	    (intel_dp->dpcd[DP_DPCD_REV] != 0)) {
-		return true;
-	}
+					   sizeof(intel_dp->dpcd)) == 0)
+		return false; /* aux transfer failed */
 
-	return false;
+	if (intel_dp->dpcd[DP_DPCD_REV] == 0)
+		return false; /* DPCD not present */
+
+	if (!(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
+	      DP_DWN_STRM_PORT_PRESENT))
+		return true; /* native DP sink */
+
+	if (intel_dp->dpcd[DP_DPCD_REV] == 0x10)
+		return true; /* no per-port downstream info */
+
+	if (intel_dp_aux_native_read_retry(intel_dp, DP_DOWNSTREAM_PORT_0,
+					   intel_dp->downstream_ports,
+					   DP_MAX_DOWNSTREAM_PORTS) == 0)
+		return false; /* downstream port status fetch failed */
+
+	return true;
 }
 
 static void