Re: [Intel-gfx] [PATCH v3 3/9] drm/i915/dp: Move vswing/pre-emphasis adjustment calculation

2020-01-15 Thread Jani Nikula
On Mon, 06 Jan 2020, "Manna, Animesh"  wrote:
> Sure Manasi, I will make intel_get_adjust_train() non-static and keep in 
> intel_dp_link_training.c.
> Now as suggested by Jani before 
> (https://patchwork.freedesktop.org/patch/345823/?series=71121=1#comment_640087)
>  other non static functions are not following the rule,
> should I change the function name or keep it as it is?

Please prefix it intel_dp_. I think intel_dp_link_training_ is too long
here. :)

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Graphics Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH v3 3/9] drm/i915/dp: Move vswing/pre-emphasis adjustment calculation

2020-01-06 Thread Manna, Animesh

On 04-01-2020 05:18, Manasi Navare wrote:

On Thu, Jan 02, 2020 at 03:56:09PM +0530, Manna, Animesh wrote:

On 02-01-2020 14:48, Jani Nikula wrote:

On Mon, 30 Dec 2019, Animesh Manna  wrote:

vswing/pre-emphasis adjustment calculation is needed in processing
of auto phy compliance request other than link training, so moved
the same function in intel_dp.c.

I guess I'm still asking why you think this is better located in
intel_dp.c than intel_dp_link_training.c, as the function has been moved
once in the other direction already to split out stuff from intel_dp.c
and to make the file smaller. Even the file name suggests it should
really be in intel_dp_link_training.c, right?

Just a thought, can we change the name to "intel_dp_link_config.c" from 
"intel_dp_link_training.c" which will provide little wider scope
and all the function playing with link configuration can be under it and also 
exposed through header file.

AFAIK, processing phy compliance request always do not need link training. I 
understood link training is very specific process consisting of clock recovery 
+ channel eq.
So I am afraid of exposing intel_get_adjust_train() from 
intel_dp_link_training.c which is not only specific to link-training. Need your 
suggestion.

Regards,
Animesh


I agree with Jani here and I think I had even suggested this earlier that 
instead of moving this function to intel_dp.c
we should make it non static so it can be used even for PHY compliance but 
since this function still deals
with adjusting training patterns IMHO it should still stay in 
intel_dp_link_training.c

Manasi


Sure Manasi, I will make intel_get_adjust_train() non-static and keep in 
intel_dp_link_training.c.
Now as suggested by Jani before 
(https://patchwork.freedesktop.org/patch/345823/?series=71121=1#comment_640087)
 other non static functions are not following the rule,
should I change the function name or keep it as it is?

Regards,
Animesh

  

BR,
Jani.



No functional change.

v1: initial patch.
v2:
- used "intel_dp" prefix in function name. (Jani)
- used array notation instead pointer for link_status. (Ville)

Signed-off-by: Animesh Manna 
---
  drivers/gpu/drm/i915/display/intel_dp.c   | 34 ++
  drivers/gpu/drm/i915/display/intel_dp.h   |  4 +++
  .../drm/i915/display/intel_dp_link_training.c | 36 ++-
  3 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 991f343579ef..2a27ee106089 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -4110,6 +4110,40 @@ ivb_cpu_edp_signal_levels(u8 train_set)
}
  }
+void
+intel_dp_get_adjust_train(struct intel_dp *intel_dp,
+ const u8 link_status[DP_LINK_STATUS_SIZE])
+{
+   u8 v = 0;
+   u8 p = 0;
+   int lane;
+   u8 voltage_max;
+   u8 preemph_max;
+
+   for (lane = 0; lane < intel_dp->lane_count; lane++) {
+   u8 this_v = drm_dp_get_adjust_request_voltage(link_status,
+ lane);
+   u8 this_p = drm_dp_get_adjust_request_pre_emphasis(link_status,
+  lane);
+
+   if (this_v > v)
+   v = this_v;
+   if (this_p > p)
+   p = this_p;
+   }
+
+   voltage_max = intel_dp_voltage_max(intel_dp);
+   if (v >= voltage_max)
+   v = voltage_max | DP_TRAIN_MAX_SWING_REACHED;
+
+   preemph_max = intel_dp_pre_emphasis_max(intel_dp, v);
+   if (p >= preemph_max)
+   p = preemph_max | DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
+
+   for (lane = 0; lane < 4; lane++)
+   intel_dp->train_set[lane] = v | p;
+}
+
  void
  intel_dp_set_signal_levels(struct intel_dp *intel_dp)
  {
diff --git a/drivers/gpu/drm/i915/display/intel_dp.h 
b/drivers/gpu/drm/i915/display/intel_dp.h
index 3da166054788..83eadc87af26 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.h
+++ b/drivers/gpu/drm/i915/display/intel_dp.h
@@ -9,6 +9,7 @@
  #include 
  #include 
+#include 
  #include "i915_reg.h"
@@ -91,6 +92,9 @@ void
  intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
   u8 dp_train_pat);
  void
+intel_dp_get_adjust_train(struct intel_dp *intel_dp,
+ const u8 link_status[DP_LINK_STATUS_SIZE]);
+void
  intel_dp_set_signal_levels(struct intel_dp *intel_dp);
  void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
  u8
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c 
b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
index 2a1130dd1ad0..e8ff9e279800 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -34,38 +34,6 @@ intel_dp_dump_link_status(const u8 

Re: [Intel-gfx] [PATCH v3 3/9] drm/i915/dp: Move vswing/pre-emphasis adjustment calculation

2020-01-03 Thread Manasi Navare
On Thu, Jan 02, 2020 at 03:56:09PM +0530, Manna, Animesh wrote:
> On 02-01-2020 14:48, Jani Nikula wrote:
> >On Mon, 30 Dec 2019, Animesh Manna  wrote:
> >>vswing/pre-emphasis adjustment calculation is needed in processing
> >>of auto phy compliance request other than link training, so moved
> >>the same function in intel_dp.c.
> >I guess I'm still asking why you think this is better located in
> >intel_dp.c than intel_dp_link_training.c, as the function has been moved
> >once in the other direction already to split out stuff from intel_dp.c
> >and to make the file smaller. Even the file name suggests it should
> >really be in intel_dp_link_training.c, right?
> 
> Just a thought, can we change the name to "intel_dp_link_config.c" from 
> "intel_dp_link_training.c" which will provide little wider scope
> and all the function playing with link configuration can be under it and also 
> exposed through header file.
> 
> AFAIK, processing phy compliance request always do not need link training. I 
> understood link training is very specific process consisting of clock 
> recovery + channel eq.
> So I am afraid of exposing intel_get_adjust_train() from 
> intel_dp_link_training.c which is not only specific to link-training. Need 
> your suggestion.
> 
> Regards,
> Animesh
>

I agree with Jani here and I think I had even suggested this earlier that 
instead of moving this function to intel_dp.c
we should make it non static so it can be used even for PHY compliance but 
since this function still deals
with adjusting training patterns IMHO it should still stay in 
intel_dp_link_training.c

Manasi
 
> >
> >BR,
> >Jani.
> >
> >
> >>No functional change.
> >>
> >>v1: initial patch.
> >>v2:
> >>- used "intel_dp" prefix in function name. (Jani)
> >>- used array notation instead pointer for link_status. (Ville)
> >>
> >>Signed-off-by: Animesh Manna 
> >>---
> >>  drivers/gpu/drm/i915/display/intel_dp.c   | 34 ++
> >>  drivers/gpu/drm/i915/display/intel_dp.h   |  4 +++
> >>  .../drm/i915/display/intel_dp_link_training.c | 36 ++-
> >>  3 files changed, 40 insertions(+), 34 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
> >>b/drivers/gpu/drm/i915/display/intel_dp.c
> >>index 991f343579ef..2a27ee106089 100644
> >>--- a/drivers/gpu/drm/i915/display/intel_dp.c
> >>+++ b/drivers/gpu/drm/i915/display/intel_dp.c
> >>@@ -4110,6 +4110,40 @@ ivb_cpu_edp_signal_levels(u8 train_set)
> >>}
> >>  }
> >>+void
> >>+intel_dp_get_adjust_train(struct intel_dp *intel_dp,
> >>+ const u8 link_status[DP_LINK_STATUS_SIZE])
> >>+{
> >>+   u8 v = 0;
> >>+   u8 p = 0;
> >>+   int lane;
> >>+   u8 voltage_max;
> >>+   u8 preemph_max;
> >>+
> >>+   for (lane = 0; lane < intel_dp->lane_count; lane++) {
> >>+   u8 this_v = drm_dp_get_adjust_request_voltage(link_status,
> >>+ lane);
> >>+   u8 this_p = drm_dp_get_adjust_request_pre_emphasis(link_status,
> >>+  lane);
> >>+
> >>+   if (this_v > v)
> >>+   v = this_v;
> >>+   if (this_p > p)
> >>+   p = this_p;
> >>+   }
> >>+
> >>+   voltage_max = intel_dp_voltage_max(intel_dp);
> >>+   if (v >= voltage_max)
> >>+   v = voltage_max | DP_TRAIN_MAX_SWING_REACHED;
> >>+
> >>+   preemph_max = intel_dp_pre_emphasis_max(intel_dp, v);
> >>+   if (p >= preemph_max)
> >>+   p = preemph_max | DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
> >>+
> >>+   for (lane = 0; lane < 4; lane++)
> >>+   intel_dp->train_set[lane] = v | p;
> >>+}
> >>+
> >>  void
> >>  intel_dp_set_signal_levels(struct intel_dp *intel_dp)
> >>  {
> >>diff --git a/drivers/gpu/drm/i915/display/intel_dp.h 
> >>b/drivers/gpu/drm/i915/display/intel_dp.h
> >>index 3da166054788..83eadc87af26 100644
> >>--- a/drivers/gpu/drm/i915/display/intel_dp.h
> >>+++ b/drivers/gpu/drm/i915/display/intel_dp.h
> >>@@ -9,6 +9,7 @@
> >>  #include 
> >>  #include 
> >>+#include 
> >>  #include "i915_reg.h"
> >>@@ -91,6 +92,9 @@ void
> >>  intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
> >>   u8 dp_train_pat);
> >>  void
> >>+intel_dp_get_adjust_train(struct intel_dp *intel_dp,
> >>+ const u8 link_status[DP_LINK_STATUS_SIZE]);
> >>+void
> >>  intel_dp_set_signal_levels(struct intel_dp *intel_dp);
> >>  void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
> >>  u8
> >>diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c 
> >>b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
> >>index 2a1130dd1ad0..e8ff9e279800 100644
> >>--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
> >>+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
> >>@@ -34,38 +34,6 @@ intel_dp_dump_link_status(const u8 
> >>link_status[DP_LINK_STATUS_SIZE])
> >>  link_status[3], link_status[4], 

Re: [Intel-gfx] [PATCH v3 3/9] drm/i915/dp: Move vswing/pre-emphasis adjustment calculation

2020-01-02 Thread Manna, Animesh

On 02-01-2020 14:48, Jani Nikula wrote:

On Mon, 30 Dec 2019, Animesh Manna  wrote:

vswing/pre-emphasis adjustment calculation is needed in processing
of auto phy compliance request other than link training, so moved
the same function in intel_dp.c.

I guess I'm still asking why you think this is better located in
intel_dp.c than intel_dp_link_training.c, as the function has been moved
once in the other direction already to split out stuff from intel_dp.c
and to make the file smaller. Even the file name suggests it should
really be in intel_dp_link_training.c, right?


Just a thought, can we change the name to "intel_dp_link_config.c" from 
"intel_dp_link_training.c" which will provide little wider scope
and all the function playing with link configuration can be under it and also 
exposed through header file.

AFAIK, processing phy compliance request always do not need link training. I 
understood link training is very specific process consisting of clock recovery 
+ channel eq.
So I am afraid of exposing intel_get_adjust_train() from 
intel_dp_link_training.c which is not only specific to link-training. Need your 
suggestion.

Regards,
Animesh



BR,
Jani.



No functional change.

v1: initial patch.
v2:
- used "intel_dp" prefix in function name. (Jani)
- used array notation instead pointer for link_status. (Ville)

Signed-off-by: Animesh Manna 
---
  drivers/gpu/drm/i915/display/intel_dp.c   | 34 ++
  drivers/gpu/drm/i915/display/intel_dp.h   |  4 +++
  .../drm/i915/display/intel_dp_link_training.c | 36 ++-
  3 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 991f343579ef..2a27ee106089 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -4110,6 +4110,40 @@ ivb_cpu_edp_signal_levels(u8 train_set)
}
  }
  
+void

+intel_dp_get_adjust_train(struct intel_dp *intel_dp,
+ const u8 link_status[DP_LINK_STATUS_SIZE])
+{
+   u8 v = 0;
+   u8 p = 0;
+   int lane;
+   u8 voltage_max;
+   u8 preemph_max;
+
+   for (lane = 0; lane < intel_dp->lane_count; lane++) {
+   u8 this_v = drm_dp_get_adjust_request_voltage(link_status,
+ lane);
+   u8 this_p = drm_dp_get_adjust_request_pre_emphasis(link_status,
+  lane);
+
+   if (this_v > v)
+   v = this_v;
+   if (this_p > p)
+   p = this_p;
+   }
+
+   voltage_max = intel_dp_voltage_max(intel_dp);
+   if (v >= voltage_max)
+   v = voltage_max | DP_TRAIN_MAX_SWING_REACHED;
+
+   preemph_max = intel_dp_pre_emphasis_max(intel_dp, v);
+   if (p >= preemph_max)
+   p = preemph_max | DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
+
+   for (lane = 0; lane < 4; lane++)
+   intel_dp->train_set[lane] = v | p;
+}
+
  void
  intel_dp_set_signal_levels(struct intel_dp *intel_dp)
  {
diff --git a/drivers/gpu/drm/i915/display/intel_dp.h 
b/drivers/gpu/drm/i915/display/intel_dp.h
index 3da166054788..83eadc87af26 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.h
+++ b/drivers/gpu/drm/i915/display/intel_dp.h
@@ -9,6 +9,7 @@
  #include 
  
  #include 

+#include 
  
  #include "i915_reg.h"
  
@@ -91,6 +92,9 @@ void

  intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
   u8 dp_train_pat);
  void
+intel_dp_get_adjust_train(struct intel_dp *intel_dp,
+ const u8 link_status[DP_LINK_STATUS_SIZE]);
+void
  intel_dp_set_signal_levels(struct intel_dp *intel_dp);
  void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
  u8
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c 
b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
index 2a1130dd1ad0..e8ff9e279800 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -34,38 +34,6 @@ intel_dp_dump_link_status(const u8 
link_status[DP_LINK_STATUS_SIZE])
  link_status[3], link_status[4], link_status[5]);
  }
  
-static void

-intel_get_adjust_train(struct intel_dp *intel_dp,
-  const u8 link_status[DP_LINK_STATUS_SIZE])
-{
-   u8 v = 0;
-   u8 p = 0;
-   int lane;
-   u8 voltage_max;
-   u8 preemph_max;
-
-   for (lane = 0; lane < intel_dp->lane_count; lane++) {
-   u8 this_v = drm_dp_get_adjust_request_voltage(link_status, 
lane);
-   u8 this_p = drm_dp_get_adjust_request_pre_emphasis(link_status, 
lane);
-
-   if (this_v > v)
-   v = this_v;
-   if (this_p > p)
-   p = this_p;
-   }
-
-   voltage_max = 

Re: [Intel-gfx] [PATCH v3 3/9] drm/i915/dp: Move vswing/pre-emphasis adjustment calculation

2020-01-02 Thread Jani Nikula
On Mon, 30 Dec 2019, Animesh Manna  wrote:
> vswing/pre-emphasis adjustment calculation is needed in processing
> of auto phy compliance request other than link training, so moved
> the same function in intel_dp.c.

I guess I'm still asking why you think this is better located in
intel_dp.c than intel_dp_link_training.c, as the function has been moved
once in the other direction already to split out stuff from intel_dp.c
and to make the file smaller. Even the file name suggests it should
really be in intel_dp_link_training.c, right?

BR,
Jani.


>
> No functional change.
>
> v1: initial patch.
> v2:
> - used "intel_dp" prefix in function name. (Jani)
> - used array notation instead pointer for link_status. (Ville)
>
> Signed-off-by: Animesh Manna 
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c   | 34 ++
>  drivers/gpu/drm/i915/display/intel_dp.h   |  4 +++
>  .../drm/i915/display/intel_dp_link_training.c | 36 ++-
>  3 files changed, 40 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
> b/drivers/gpu/drm/i915/display/intel_dp.c
> index 991f343579ef..2a27ee106089 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -4110,6 +4110,40 @@ ivb_cpu_edp_signal_levels(u8 train_set)
>   }
>  }
>  
> +void
> +intel_dp_get_adjust_train(struct intel_dp *intel_dp,
> +   const u8 link_status[DP_LINK_STATUS_SIZE])
> +{
> + u8 v = 0;
> + u8 p = 0;
> + int lane;
> + u8 voltage_max;
> + u8 preemph_max;
> +
> + for (lane = 0; lane < intel_dp->lane_count; lane++) {
> + u8 this_v = drm_dp_get_adjust_request_voltage(link_status,
> +   lane);
> + u8 this_p = drm_dp_get_adjust_request_pre_emphasis(link_status,
> +lane);
> +
> + if (this_v > v)
> + v = this_v;
> + if (this_p > p)
> + p = this_p;
> + }
> +
> + voltage_max = intel_dp_voltage_max(intel_dp);
> + if (v >= voltage_max)
> + v = voltage_max | DP_TRAIN_MAX_SWING_REACHED;
> +
> + preemph_max = intel_dp_pre_emphasis_max(intel_dp, v);
> + if (p >= preemph_max)
> + p = preemph_max | DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
> +
> + for (lane = 0; lane < 4; lane++)
> + intel_dp->train_set[lane] = v | p;
> +}
> +
>  void
>  intel_dp_set_signal_levels(struct intel_dp *intel_dp)
>  {
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.h 
> b/drivers/gpu/drm/i915/display/intel_dp.h
> index 3da166054788..83eadc87af26 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.h
> +++ b/drivers/gpu/drm/i915/display/intel_dp.h
> @@ -9,6 +9,7 @@
>  #include 
>  
>  #include 
> +#include 
>  
>  #include "i915_reg.h"
>  
> @@ -91,6 +92,9 @@ void
>  intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
>  u8 dp_train_pat);
>  void
> +intel_dp_get_adjust_train(struct intel_dp *intel_dp,
> +   const u8 link_status[DP_LINK_STATUS_SIZE]);
> +void
>  intel_dp_set_signal_levels(struct intel_dp *intel_dp);
>  void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
>  u8
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c 
> b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
> index 2a1130dd1ad0..e8ff9e279800 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
> @@ -34,38 +34,6 @@ intel_dp_dump_link_status(const u8 
> link_status[DP_LINK_STATUS_SIZE])
> link_status[3], link_status[4], link_status[5]);
>  }
>  
> -static void
> -intel_get_adjust_train(struct intel_dp *intel_dp,
> -const u8 link_status[DP_LINK_STATUS_SIZE])
> -{
> - u8 v = 0;
> - u8 p = 0;
> - int lane;
> - u8 voltage_max;
> - u8 preemph_max;
> -
> - for (lane = 0; lane < intel_dp->lane_count; lane++) {
> - u8 this_v = drm_dp_get_adjust_request_voltage(link_status, 
> lane);
> - u8 this_p = drm_dp_get_adjust_request_pre_emphasis(link_status, 
> lane);
> -
> - if (this_v > v)
> - v = this_v;
> - if (this_p > p)
> - p = this_p;
> - }
> -
> - voltage_max = intel_dp_voltage_max(intel_dp);
> - if (v >= voltage_max)
> - v = voltage_max | DP_TRAIN_MAX_SWING_REACHED;
> -
> - preemph_max = intel_dp_pre_emphasis_max(intel_dp, v);
> - if (p >= preemph_max)
> - p = preemph_max | DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
> -
> - for (lane = 0; lane < 4; lane++)
> - intel_dp->train_set[lane] = v | p;
> -}
> -
>  static bool
>  intel_dp_set_link_train(struct intel_dp *intel_dp,
>   u8 dp_train_pat)
> @@ -215,7 +183,7 @@