Re: [Intel-gfx] [PATCH 5/7] drm/i915: Introduce intel_hpd_enable_detection()

2023-04-14 Thread Govindapillai, Vinod
On Fri, 2023-04-14 at 17:21 +0300, Ville Syrjälä wrote:
> On Fri, Apr 14, 2023 at 01:23:16PM +, Govindapillai, Vinod wrote:
> > Hi Ville
> > 
> > Btw, I dont see the _hotplug_mask() defined anywhere..
> > Am I missing any patch?
> 
> The previous patch in the series.

Thanks! I was following the patchwork to follow the series and patch 4/7 wasnt 
visible in the series
somehow! I can see it now

BR
Vinod
> 
> > 
> > BR
> > Vinod
> > 
> > On Fri, 2023-04-14 at 15:59 +0300, Govindapillai, Vinod wrote:
> > > On Thu, 2023-03-02 at 18:10 +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä 
> > > > 
> > > > Add a mechanism by which we can enable the HPD sense for
> > > > individual encoders.
> > > > 
> > > > This will be used during eDP probing to figure out if
> > > > anything is actually connected. The normal intel_hpd_irq_setup()
> > > > thing doesn't work since we only do that after probing the
> > > > outputs, and we only enable HPD sense for encoders that were
> > > > successfully probed.
> > > > 
> > > > The other idea that crossed my minds was to just turn on
> > > > HPD sense for all pins before output probing and let hpd_irq_setup()
> > > > clean it up afterwards. But that doesn't work for BXT/GLK where
> > > > the HPD invert information comes from the VBT child device.
> > > > So looks like this really needs to be per-encoder.
> > > > 
> > > > v2: Give it a better name (Jani)
> > > > 
> > > > Cc: Jani Nikula 
> > > > Signed-off-by: Ville Syrjälä 
> > > > ---
> > > 
> > > Reviewed-by: Vinod Govindapillai 
> > > 
> > > 
> > > >  drivers/gpu/drm/i915/i915_irq.c | 131 
> > > >  drivers/gpu/drm/i915/i915_irq.h |   2 +
> > > >  2 files changed, 133 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/i915_irq.c 
> > > > b/drivers/gpu/drm/i915/i915_irq.c
> > > > index 1e6a6f14a968..9d00b840727c 100644
> > > > --- a/drivers/gpu/drm/i915/i915_irq.c
> > > > +++ b/drivers/gpu/drm/i915/i915_irq.c
> > > > @@ -2893,6 +2893,15 @@ static void ibx_hpd_detection_setup(struct 
> > > > drm_i915_private
> > > > *dev_priv)
> > > >  intel_hpd_hotplug_enables(dev_priv, 
> > > > ibx_hotplug_enables));
> > > >  }
> > > >  
> > > > +static void ibx_hpd_enable_detection(struct intel_encoder *encoder)
> > > > +{
> > > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > > +
> > > > +   intel_uncore_rmw(>uncore, PCH_PORT_HOTPLUG,
> > > > +    ibx_hotplug_mask(encoder->hpd_pin),
> > > > +    ibx_hotplug_enables(encoder));
> > > > +}
> > > > +
> > > >  static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
> > > >  {
> > > > u32 hotplug_irqs, enabled_irqs;
> > > > @@ -2963,6 +2972,15 @@ static void icp_ddi_hpd_detection_setup(struct 
> > > > drm_i915_private
> > > > *dev_priv)
> > > >  intel_hpd_hotplug_enables(dev_priv, 
> > > > icp_ddi_hotplug_enables));
> > > >  }
> > > >  
> > > > +static void icp_ddi_hpd_enable_detection(struct intel_encoder *encoder)
> > > > +{
> > > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > > +
> > > > +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_DDI,
> > > > +    icp_ddi_hotplug_mask(encoder->hpd_pin),
> > > > +    icp_ddi_hotplug_enables(encoder));
> > > > +}
> > > > +
> > > >  static void icp_tc_hpd_detection_setup(struct drm_i915_private 
> > > > *dev_priv)
> > > >  {
> > > > intel_uncore_rmw(_priv->uncore, SHOTPLUG_CTL_TC,
> > > > @@ -2975,6 +2993,21 @@ static void icp_tc_hpd_detection_setup(struct 
> > > > drm_i915_private
> > > > *dev_priv)
> > > >  intel_hpd_hotplug_enables(dev_priv, 
> > > > icp_tc_hotplug_enables));
> > > >  }
> > > >  
> > > > +static void icp_tc_hpd_enable_detection(struct intel_encoder *encoder)
> > > > +{
> > > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > > +
> > > > +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_TC,
> > > > +    icp_tc_hotplug_mask(encoder->hpd_pin),
> > > > +    icp_tc_hotplug_enables(encoder));
> > > > +}
> > > > +
> > > > +static void icp_hpd_enable_detection(struct intel_encoder *encoder)
> > > > +{
> > > > +   icp_ddi_hpd_enable_detection(encoder);
> > > > +   icp_tc_hpd_enable_detection(encoder);
> > > > +}
> > > > +
> > > >  static void icp_hpd_irq_setup(struct drm_i915_private *dev_priv)
> > > >  {
> > > > u32 hotplug_irqs, enabled_irqs;
> > > > @@ -3025,6 +3058,14 @@ static void dg1_hpd_invert(struct 
> > > > drm_i915_private *i915)
> > > > intel_uncore_rmw(>uncore, SOUTH_CHICKEN1, 0, val);
> > > >  }
> > > >  
> > > > +static void dg1_hpd_enable_detection(struct intel_encoder *encoder)
> > > > +{
> > > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > > +
> > > > +   dg1_hpd_invert(i915);
> > > > +   icp_hpd_enable_detection(encoder);
> 

Re: [Intel-gfx] [PATCH 5/7] drm/i915: Introduce intel_hpd_enable_detection()

2023-04-14 Thread Ville Syrjälä
On Fri, Apr 14, 2023 at 01:23:16PM +, Govindapillai, Vinod wrote:
> Hi Ville
> 
> Btw, I dont see the _hotplug_mask() defined anywhere..
> Am I missing any patch?

The previous patch in the series.

> 
> BR
> Vinod
> 
> On Fri, 2023-04-14 at 15:59 +0300, Govindapillai, Vinod wrote:
> > On Thu, 2023-03-02 at 18:10 +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä 
> > > 
> > > Add a mechanism by which we can enable the HPD sense for
> > > individual encoders.
> > > 
> > > This will be used during eDP probing to figure out if
> > > anything is actually connected. The normal intel_hpd_irq_setup()
> > > thing doesn't work since we only do that after probing the
> > > outputs, and we only enable HPD sense for encoders that were
> > > successfully probed.
> > > 
> > > The other idea that crossed my minds was to just turn on
> > > HPD sense for all pins before output probing and let hpd_irq_setup()
> > > clean it up afterwards. But that doesn't work for BXT/GLK where
> > > the HPD invert information comes from the VBT child device.
> > > So looks like this really needs to be per-encoder.
> > > 
> > > v2: Give it a better name (Jani)
> > > 
> > > Cc: Jani Nikula 
> > > Signed-off-by: Ville Syrjälä 
> > > ---
> > 
> > Reviewed-by: Vinod Govindapillai 
> > 
> > 
> > >  drivers/gpu/drm/i915/i915_irq.c | 131 
> > >  drivers/gpu/drm/i915/i915_irq.h |   2 +
> > >  2 files changed, 133 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/i915_irq.c 
> > > b/drivers/gpu/drm/i915/i915_irq.c
> > > index 1e6a6f14a968..9d00b840727c 100644
> > > --- a/drivers/gpu/drm/i915/i915_irq.c
> > > +++ b/drivers/gpu/drm/i915/i915_irq.c
> > > @@ -2893,6 +2893,15 @@ static void ibx_hpd_detection_setup(struct 
> > > drm_i915_private *dev_priv)
> > >  intel_hpd_hotplug_enables(dev_priv, 
> > > ibx_hotplug_enables));
> > >  }
> > >  
> > > +static void ibx_hpd_enable_detection(struct intel_encoder *encoder)
> > > +{
> > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > +
> > > +   intel_uncore_rmw(>uncore, PCH_PORT_HOTPLUG,
> > > +    ibx_hotplug_mask(encoder->hpd_pin),
> > > +    ibx_hotplug_enables(encoder));
> > > +}
> > > +
> > >  static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
> > >  {
> > > u32 hotplug_irqs, enabled_irqs;
> > > @@ -2963,6 +2972,15 @@ static void icp_ddi_hpd_detection_setup(struct 
> > > drm_i915_private
> > > *dev_priv)
> > >  intel_hpd_hotplug_enables(dev_priv, 
> > > icp_ddi_hotplug_enables));
> > >  }
> > >  
> > > +static void icp_ddi_hpd_enable_detection(struct intel_encoder *encoder)
> > > +{
> > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > +
> > > +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_DDI,
> > > +    icp_ddi_hotplug_mask(encoder->hpd_pin),
> > > +    icp_ddi_hotplug_enables(encoder));
> > > +}
> > > +
> > >  static void icp_tc_hpd_detection_setup(struct drm_i915_private *dev_priv)
> > >  {
> > > intel_uncore_rmw(_priv->uncore, SHOTPLUG_CTL_TC,
> > > @@ -2975,6 +2993,21 @@ static void icp_tc_hpd_detection_setup(struct 
> > > drm_i915_private *dev_priv)
> > >  intel_hpd_hotplug_enables(dev_priv, 
> > > icp_tc_hotplug_enables));
> > >  }
> > >  
> > > +static void icp_tc_hpd_enable_detection(struct intel_encoder *encoder)
> > > +{
> > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > +
> > > +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_TC,
> > > +    icp_tc_hotplug_mask(encoder->hpd_pin),
> > > +    icp_tc_hotplug_enables(encoder));
> > > +}
> > > +
> > > +static void icp_hpd_enable_detection(struct intel_encoder *encoder)
> > > +{
> > > +   icp_ddi_hpd_enable_detection(encoder);
> > > +   icp_tc_hpd_enable_detection(encoder);
> > > +}
> > > +
> > >  static void icp_hpd_irq_setup(struct drm_i915_private *dev_priv)
> > >  {
> > > u32 hotplug_irqs, enabled_irqs;
> > > @@ -3025,6 +3058,14 @@ static void dg1_hpd_invert(struct drm_i915_private 
> > > *i915)
> > > intel_uncore_rmw(>uncore, SOUTH_CHICKEN1, 0, val);
> > >  }
> > >  
> > > +static void dg1_hpd_enable_detection(struct intel_encoder *encoder)
> > > +{
> > > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > > +
> > > +   dg1_hpd_invert(i915);
> > > +   icp_hpd_enable_detection(encoder);
> > > +}
> > > +
> > >  static void dg1_hpd_irq_setup(struct drm_i915_private *dev_priv)
> > >  {
> > > dg1_hpd_invert(dev_priv);
> > > @@ -3043,6 +3084,15 @@ static void gen11_tc_hpd_detection_setup(struct 
> > > drm_i915_private
> > > *dev_priv)
> > >  intel_hpd_hotplug_enables(dev_priv, 
> > > gen11_hotplug_enables));
> > >  }
> > >  
> > > +static void gen11_tc_hpd_enable_detection(struct intel_encoder *encoder)
> > > +{
> > 

Re: [Intel-gfx] [PATCH 5/7] drm/i915: Introduce intel_hpd_enable_detection()

2023-04-14 Thread Govindapillai, Vinod
Hi Ville

Btw, I dont see the _hotplug_mask() defined anywhere..
Am I missing any patch?

BR
Vinod

On Fri, 2023-04-14 at 15:59 +0300, Govindapillai, Vinod wrote:
> On Thu, 2023-03-02 at 18:10 +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä 
> > 
> > Add a mechanism by which we can enable the HPD sense for
> > individual encoders.
> > 
> > This will be used during eDP probing to figure out if
> > anything is actually connected. The normal intel_hpd_irq_setup()
> > thing doesn't work since we only do that after probing the
> > outputs, and we only enable HPD sense for encoders that were
> > successfully probed.
> > 
> > The other idea that crossed my minds was to just turn on
> > HPD sense for all pins before output probing and let hpd_irq_setup()
> > clean it up afterwards. But that doesn't work for BXT/GLK where
> > the HPD invert information comes from the VBT child device.
> > So looks like this really needs to be per-encoder.
> > 
> > v2: Give it a better name (Jani)
> > 
> > Cc: Jani Nikula 
> > Signed-off-by: Ville Syrjälä 
> > ---
> 
> Reviewed-by: Vinod Govindapillai 
> 
> 
> >  drivers/gpu/drm/i915/i915_irq.c | 131 
> >  drivers/gpu/drm/i915/i915_irq.h |   2 +
> >  2 files changed, 133 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_irq.c 
> > b/drivers/gpu/drm/i915/i915_irq.c
> > index 1e6a6f14a968..9d00b840727c 100644
> > --- a/drivers/gpu/drm/i915/i915_irq.c
> > +++ b/drivers/gpu/drm/i915/i915_irq.c
> > @@ -2893,6 +2893,15 @@ static void ibx_hpd_detection_setup(struct 
> > drm_i915_private *dev_priv)
> >  intel_hpd_hotplug_enables(dev_priv, 
> > ibx_hotplug_enables));
> >  }
> >  
> > +static void ibx_hpd_enable_detection(struct intel_encoder *encoder)
> > +{
> > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > +
> > +   intel_uncore_rmw(>uncore, PCH_PORT_HOTPLUG,
> > +    ibx_hotplug_mask(encoder->hpd_pin),
> > +    ibx_hotplug_enables(encoder));
> > +}
> > +
> >  static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  {
> > u32 hotplug_irqs, enabled_irqs;
> > @@ -2963,6 +2972,15 @@ static void icp_ddi_hpd_detection_setup(struct 
> > drm_i915_private
> > *dev_priv)
> >  intel_hpd_hotplug_enables(dev_priv, 
> > icp_ddi_hotplug_enables));
> >  }
> >  
> > +static void icp_ddi_hpd_enable_detection(struct intel_encoder *encoder)
> > +{
> > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > +
> > +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_DDI,
> > +    icp_ddi_hotplug_mask(encoder->hpd_pin),
> > +    icp_ddi_hotplug_enables(encoder));
> > +}
> > +
> >  static void icp_tc_hpd_detection_setup(struct drm_i915_private *dev_priv)
> >  {
> > intel_uncore_rmw(_priv->uncore, SHOTPLUG_CTL_TC,
> > @@ -2975,6 +2993,21 @@ static void icp_tc_hpd_detection_setup(struct 
> > drm_i915_private *dev_priv)
> >  intel_hpd_hotplug_enables(dev_priv, 
> > icp_tc_hotplug_enables));
> >  }
> >  
> > +static void icp_tc_hpd_enable_detection(struct intel_encoder *encoder)
> > +{
> > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > +
> > +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_TC,
> > +    icp_tc_hotplug_mask(encoder->hpd_pin),
> > +    icp_tc_hotplug_enables(encoder));
> > +}
> > +
> > +static void icp_hpd_enable_detection(struct intel_encoder *encoder)
> > +{
> > +   icp_ddi_hpd_enable_detection(encoder);
> > +   icp_tc_hpd_enable_detection(encoder);
> > +}
> > +
> >  static void icp_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  {
> > u32 hotplug_irqs, enabled_irqs;
> > @@ -3025,6 +3058,14 @@ static void dg1_hpd_invert(struct drm_i915_private 
> > *i915)
> > intel_uncore_rmw(>uncore, SOUTH_CHICKEN1, 0, val);
> >  }
> >  
> > +static void dg1_hpd_enable_detection(struct intel_encoder *encoder)
> > +{
> > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > +
> > +   dg1_hpd_invert(i915);
> > +   icp_hpd_enable_detection(encoder);
> > +}
> > +
> >  static void dg1_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  {
> > dg1_hpd_invert(dev_priv);
> > @@ -3043,6 +3084,15 @@ static void gen11_tc_hpd_detection_setup(struct 
> > drm_i915_private
> > *dev_priv)
> >  intel_hpd_hotplug_enables(dev_priv, 
> > gen11_hotplug_enables));
> >  }
> >  
> > +static void gen11_tc_hpd_enable_detection(struct intel_encoder *encoder)
> > +{
> > +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> > +
> > +   intel_uncore_rmw(>uncore, GEN11_TC_HOTPLUG_CTL,
> > +    gen11_hotplug_mask(encoder->hpd_pin),
> > +    gen11_hotplug_enables(encoder));
> > +}
> > +
> >  static void gen11_tbt_hpd_detection_setup(struct drm_i915_private 
> > *dev_priv)
> >  

Re: [Intel-gfx] [PATCH 5/7] drm/i915: Introduce intel_hpd_enable_detection()

2023-04-14 Thread Govindapillai, Vinod
On Thu, 2023-03-02 at 18:10 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä 
> 
> Add a mechanism by which we can enable the HPD sense for
> individual encoders.
> 
> This will be used during eDP probing to figure out if
> anything is actually connected. The normal intel_hpd_irq_setup()
> thing doesn't work since we only do that after probing the
> outputs, and we only enable HPD sense for encoders that were
> successfully probed.
> 
> The other idea that crossed my minds was to just turn on
> HPD sense for all pins before output probing and let hpd_irq_setup()
> clean it up afterwards. But that doesn't work for BXT/GLK where
> the HPD invert information comes from the VBT child device.
> So looks like this really needs to be per-encoder.
> 
> v2: Give it a better name (Jani)
> 
> Cc: Jani Nikula 
> Signed-off-by: Ville Syrjälä 
> ---

Reviewed-by: Vinod Govindapillai 


>  drivers/gpu/drm/i915/i915_irq.c | 131 
>  drivers/gpu/drm/i915/i915_irq.h |   2 +
>  2 files changed, 133 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 1e6a6f14a968..9d00b840727c 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -2893,6 +2893,15 @@ static void ibx_hpd_detection_setup(struct 
> drm_i915_private *dev_priv)
>  intel_hpd_hotplug_enables(dev_priv, 
> ibx_hotplug_enables));
>  }
>  
> +static void ibx_hpd_enable_detection(struct intel_encoder *encoder)
> +{
> +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +
> +   intel_uncore_rmw(>uncore, PCH_PORT_HOTPLUG,
> +    ibx_hotplug_mask(encoder->hpd_pin),
> +    ibx_hotplug_enables(encoder));
> +}
> +
>  static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
>  {
> u32 hotplug_irqs, enabled_irqs;
> @@ -2963,6 +2972,15 @@ static void icp_ddi_hpd_detection_setup(struct 
> drm_i915_private *dev_priv)
>  intel_hpd_hotplug_enables(dev_priv, 
> icp_ddi_hotplug_enables));
>  }
>  
> +static void icp_ddi_hpd_enable_detection(struct intel_encoder *encoder)
> +{
> +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +
> +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_DDI,
> +    icp_ddi_hotplug_mask(encoder->hpd_pin),
> +    icp_ddi_hotplug_enables(encoder));
> +}
> +
>  static void icp_tc_hpd_detection_setup(struct drm_i915_private *dev_priv)
>  {
> intel_uncore_rmw(_priv->uncore, SHOTPLUG_CTL_TC,
> @@ -2975,6 +2993,21 @@ static void icp_tc_hpd_detection_setup(struct 
> drm_i915_private *dev_priv)
>  intel_hpd_hotplug_enables(dev_priv, 
> icp_tc_hotplug_enables));
>  }
>  
> +static void icp_tc_hpd_enable_detection(struct intel_encoder *encoder)
> +{
> +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +
> +   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_TC,
> +    icp_tc_hotplug_mask(encoder->hpd_pin),
> +    icp_tc_hotplug_enables(encoder));
> +}
> +
> +static void icp_hpd_enable_detection(struct intel_encoder *encoder)
> +{
> +   icp_ddi_hpd_enable_detection(encoder);
> +   icp_tc_hpd_enable_detection(encoder);
> +}
> +
>  static void icp_hpd_irq_setup(struct drm_i915_private *dev_priv)
>  {
> u32 hotplug_irqs, enabled_irqs;
> @@ -3025,6 +3058,14 @@ static void dg1_hpd_invert(struct drm_i915_private 
> *i915)
> intel_uncore_rmw(>uncore, SOUTH_CHICKEN1, 0, val);
>  }
>  
> +static void dg1_hpd_enable_detection(struct intel_encoder *encoder)
> +{
> +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +
> +   dg1_hpd_invert(i915);
> +   icp_hpd_enable_detection(encoder);
> +}
> +
>  static void dg1_hpd_irq_setup(struct drm_i915_private *dev_priv)
>  {
> dg1_hpd_invert(dev_priv);
> @@ -3043,6 +3084,15 @@ static void gen11_tc_hpd_detection_setup(struct 
> drm_i915_private *dev_priv)
>  intel_hpd_hotplug_enables(dev_priv, 
> gen11_hotplug_enables));
>  }
>  
> +static void gen11_tc_hpd_enable_detection(struct intel_encoder *encoder)
> +{
> +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +
> +   intel_uncore_rmw(>uncore, GEN11_TC_HOTPLUG_CTL,
> +    gen11_hotplug_mask(encoder->hpd_pin),
> +    gen11_hotplug_enables(encoder));
> +}
> +
>  static void gen11_tbt_hpd_detection_setup(struct drm_i915_private *dev_priv)
>  {
> intel_uncore_rmw(_priv->uncore, GEN11_TBT_HOTPLUG_CTL,
> @@ -3055,6 +3105,26 @@ static void gen11_tbt_hpd_detection_setup(struct 
> drm_i915_private
> *dev_priv)
>  intel_hpd_hotplug_enables(dev_priv, 
> gen11_hotplug_enables));
>  }
>  
> +static void gen11_tbt_hpd_enable_detection(struct intel_encoder *encoder)
> +{
> +   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
> +
> +

[Intel-gfx] [PATCH 5/7] drm/i915: Introduce intel_hpd_enable_detection()

2023-03-02 Thread Ville Syrjala
From: Ville Syrjälä 

Add a mechanism by which we can enable the HPD sense for
individual encoders.

This will be used during eDP probing to figure out if
anything is actually connected. The normal intel_hpd_irq_setup()
thing doesn't work since we only do that after probing the
outputs, and we only enable HPD sense for encoders that were
successfully probed.

The other idea that crossed my minds was to just turn on
HPD sense for all pins before output probing and let hpd_irq_setup()
clean it up afterwards. But that doesn't work for BXT/GLK where
the HPD invert information comes from the VBT child device.
So looks like this really needs to be per-encoder.

v2: Give it a better name (Jani)

Cc: Jani Nikula 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/i915/i915_irq.c | 131 
 drivers/gpu/drm/i915/i915_irq.h |   2 +
 2 files changed, 133 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 1e6a6f14a968..9d00b840727c 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -2893,6 +2893,15 @@ static void ibx_hpd_detection_setup(struct 
drm_i915_private *dev_priv)
 intel_hpd_hotplug_enables(dev_priv, 
ibx_hotplug_enables));
 }
 
+static void ibx_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+   intel_uncore_rmw(>uncore, PCH_PORT_HOTPLUG,
+ibx_hotplug_mask(encoder->hpd_pin),
+ibx_hotplug_enables(encoder));
+}
+
 static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
u32 hotplug_irqs, enabled_irqs;
@@ -2963,6 +2972,15 @@ static void icp_ddi_hpd_detection_setup(struct 
drm_i915_private *dev_priv)
 intel_hpd_hotplug_enables(dev_priv, 
icp_ddi_hotplug_enables));
 }
 
+static void icp_ddi_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_DDI,
+icp_ddi_hotplug_mask(encoder->hpd_pin),
+icp_ddi_hotplug_enables(encoder));
+}
+
 static void icp_tc_hpd_detection_setup(struct drm_i915_private *dev_priv)
 {
intel_uncore_rmw(_priv->uncore, SHOTPLUG_CTL_TC,
@@ -2975,6 +2993,21 @@ static void icp_tc_hpd_detection_setup(struct 
drm_i915_private *dev_priv)
 intel_hpd_hotplug_enables(dev_priv, 
icp_tc_hotplug_enables));
 }
 
+static void icp_tc_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+   intel_uncore_rmw(>uncore, SHOTPLUG_CTL_TC,
+icp_tc_hotplug_mask(encoder->hpd_pin),
+icp_tc_hotplug_enables(encoder));
+}
+
+static void icp_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   icp_ddi_hpd_enable_detection(encoder);
+   icp_tc_hpd_enable_detection(encoder);
+}
+
 static void icp_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
u32 hotplug_irqs, enabled_irqs;
@@ -3025,6 +3058,14 @@ static void dg1_hpd_invert(struct drm_i915_private *i915)
intel_uncore_rmw(>uncore, SOUTH_CHICKEN1, 0, val);
 }
 
+static void dg1_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+   dg1_hpd_invert(i915);
+   icp_hpd_enable_detection(encoder);
+}
+
 static void dg1_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
dg1_hpd_invert(dev_priv);
@@ -3043,6 +3084,15 @@ static void gen11_tc_hpd_detection_setup(struct 
drm_i915_private *dev_priv)
 intel_hpd_hotplug_enables(dev_priv, 
gen11_hotplug_enables));
 }
 
+static void gen11_tc_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+   intel_uncore_rmw(>uncore, GEN11_TC_HOTPLUG_CTL,
+gen11_hotplug_mask(encoder->hpd_pin),
+gen11_hotplug_enables(encoder));
+}
+
 static void gen11_tbt_hpd_detection_setup(struct drm_i915_private *dev_priv)
 {
intel_uncore_rmw(_priv->uncore, GEN11_TBT_HOTPLUG_CTL,
@@ -3055,6 +3105,26 @@ static void gen11_tbt_hpd_detection_setup(struct 
drm_i915_private *dev_priv)
 intel_hpd_hotplug_enables(dev_priv, 
gen11_hotplug_enables));
 }
 
+static void gen11_tbt_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+   intel_uncore_rmw(>uncore, GEN11_TBT_HOTPLUG_CTL,
+gen11_hotplug_mask(encoder->hpd_pin),
+gen11_hotplug_enables(encoder));
+}
+
+static void gen11_hpd_enable_detection(struct intel_encoder *encoder)
+{
+   struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+