[PATCH v14 05/35] drm/i915: MEI interface definition

2019-02-16 Thread Ramalingam C via dri-devel
Defining the mei-i915 interface functions and initialization of
the interface.

v2:
  Adjust to the new interface changes. [Tomas]
  Added further debug logs for the failures at MEI i/f.
  port in hdcp_port data is equipped to handle -ve values.
v3:
  mei comp is matched for global i915 comp master. [Daniel]
  In hdcp_shim hdcp_protocol() is replaced with const variable. [Daniel]
  mei wrappers are adjusted as per the i/f change [Daniel]
v4:
  port initialization is done only at hdcp2_init only [Danvet]
v5:
  I915 registers a subcomponent to be matched with mei_hdcp [Daniel]
v6:
  HDCP_disable for all connectors incase of comp_unbind.
  Tear down HDCP comp interface at i915_unload [Daniel]
v7:
  Component init and fini are moved out of connector ops [Daniel]
  hdcp_disable is not called from unbind. [Daniel]

Signed-off-by: Ramalingam C 
Reviewed-by: Daniel Vetter  [v11]
---
 drivers/gpu/drm/i915/i915_drv.c|   1 +
 drivers/gpu/drm/i915/i915_drv.h|   7 +
 drivers/gpu/drm/i915/intel_connector.c |   2 +
 drivers/gpu/drm/i915/intel_display.c   |   4 +
 drivers/gpu/drm/i915/intel_drv.h   |   8 +
 drivers/gpu/drm/i915/intel_hdcp.c  | 398 -
 include/drm/i915_component.h   |   3 +
 7 files changed, 422 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 6630212f2faf..c6354f6cdbdb 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -906,6 +906,7 @@ static int i915_driver_init_early(struct drm_i915_private 
*dev_priv)
mutex_init(_priv->av_mutex);
mutex_init(_priv->wm.wm_mutex);
mutex_init(_priv->pps_mutex);
+   mutex_init(_priv->hdcp_comp_mutex);
 
i915_memcpy_init_early(dev_priv);
intel_runtime_pm_init_early(dev_priv);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 17fe942eaafa..a09c82c92ea5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "i915_fixed.h"
 #include "i915_params.h"
@@ -2051,6 +2052,12 @@ struct drm_i915_private {
 
struct i915_pmu pmu;
 
+   struct i915_hdcp_comp_master *hdcp_master;
+   bool hdcp_comp_added;
+
+   /* Mutex to protect the above hdcp component related values. */
+   struct mutex hdcp_comp_mutex;
+
/*
 * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
 * will be rejected. Instead look for a better place.
diff --git a/drivers/gpu/drm/i915/intel_connector.c 
b/drivers/gpu/drm/i915/intel_connector.c
index ee16758747c5..66ed3ee5998a 100644
--- a/drivers/gpu/drm/i915/intel_connector.c
+++ b/drivers/gpu/drm/i915/intel_connector.c
@@ -88,6 +88,8 @@ void intel_connector_destroy(struct drm_connector *connector)
 
kfree(intel_connector->detect_edid);
 
+   intel_hdcp_cleanup(intel_connector);
+
if (!IS_ERR_OR_NULL(intel_connector->edid))
kfree(intel_connector->edid);
 
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 0a8913b2059e..97bce4707a4c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -15459,6 +15459,8 @@ int intel_modeset_init(struct drm_device *dev)
intel_update_czclk(dev_priv);
intel_modeset_init_hw(dev);
 
+   intel_hdcp_component_init(dev_priv);
+
if (dev_priv->max_cdclk_freq == 0)
intel_update_max_cdclk(dev_priv);
 
@@ -16320,6 +16322,8 @@ void intel_modeset_cleanup(struct drm_device *dev)
/* flush any delayed tasks or pending work */
flush_scheduled_work();
 
+   intel_hdcp_component_fini(dev_priv);
+
drm_mode_config_cleanup(dev);
 
intel_overlay_cleanup(dev_priv);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 11c696025085..f8e8482573c8 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 struct drm_printer;
@@ -395,6 +396,9 @@ struct intel_hdcp_shim {
/* Detects panel's hdcp capability. This is optional for HDMI. */
int (*hdcp_capable)(struct intel_digital_port *intel_dig_port,
bool *hdcp_capable);
+
+   /* HDCP adaptation(DP/HDMI) required on the port */
+   enum hdcp_wired_protocol protocol;
 };
 
 struct intel_hdcp {
@@ -415,6 +419,7 @@ struct intel_hdcp {
 * content can flow only through a link protected by HDCP2.2.
 */
u8 content_type;
+   struct hdcp_port_data port_data;
 };
 
 struct intel_connector {
@@ -2088,6 +2093,9 @@ int intel_hdcp_disable(struct intel_connector *connector);
 int intel_hdcp_check_link(struct intel_connector *connector);
 bool is_hdcp_supported(struct drm_i915_private *dev_priv, enum port port);
 bool 

Re: [PATCH v14 05/35] drm/i915: MEI interface definition

2019-02-15 Thread Daniel Vetter
On Fri, Feb 15, 2019 at 02:05:00PM +0530, Ramalingam C wrote:
> Defining the mei-i915 interface functions and initialization of
> the interface.
> 
> v2:
>   Adjust to the new interface changes. [Tomas]
>   Added further debug logs for the failures at MEI i/f.
>   port in hdcp_port data is equipped to handle -ve values.
> v3:
>   mei comp is matched for global i915 comp master. [Daniel]
>   In hdcp_shim hdcp_protocol() is replaced with const variable. [Daniel]
>   mei wrappers are adjusted as per the i/f change [Daniel]
> v4:
>   port initialization is done only at hdcp2_init only [Danvet]
> v5:
>   I915 registers a subcomponent to be matched with mei_hdcp [Daniel]
> v6:
>   HDCP_disable for all connectors incase of comp_unbind.
>   Tear down HDCP comp interface at i915_unload [Daniel]
> v7:
>   Component init and fini are moved out of connector ops [Daniel]
>   hdcp_disable is not called from unbind. [Daniel]
> 
> Signed-off-by: Ramalingam C 
> Reviewed-by: Daniel Vetter  [v11]
> ---
>  drivers/gpu/drm/i915/i915_drv.c|   1 +
>  drivers/gpu/drm/i915/i915_drv.h|   7 +
>  drivers/gpu/drm/i915/intel_connector.c |   2 +
>  drivers/gpu/drm/i915/intel_display.c   |   4 +
>  drivers/gpu/drm/i915/intel_drv.h   |   8 +
>  drivers/gpu/drm/i915/intel_hdcp.c  | 398 
> -
>  include/drm/i915_component.h   |   3 +
>  7 files changed, 422 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 6630212f2faf..c6354f6cdbdb 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -906,6 +906,7 @@ static int i915_driver_init_early(struct drm_i915_private 
> *dev_priv)
>   mutex_init(_priv->av_mutex);
>   mutex_init(_priv->wm.wm_mutex);
>   mutex_init(_priv->pps_mutex);
> + mutex_init(_priv->hdcp_comp_mutex);
>  
>   i915_memcpy_init_early(dev_priv);
>   intel_runtime_pm_init_early(dev_priv);
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 17fe942eaafa..a09c82c92ea5 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -55,6 +55,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "i915_fixed.h"
>  #include "i915_params.h"
> @@ -2051,6 +2052,12 @@ struct drm_i915_private {
>  
>   struct i915_pmu pmu;
>  
> + struct i915_hdcp_comp_master *hdcp_master;
> + bool hdcp_comp_added;
> +
> + /* Mutex to protect the above hdcp component related values. */
> + struct mutex hdcp_comp_mutex;
> +
>   /*
>* NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
>* will be rejected. Instead look for a better place.
> diff --git a/drivers/gpu/drm/i915/intel_connector.c 
> b/drivers/gpu/drm/i915/intel_connector.c
> index ee16758747c5..66ed3ee5998a 100644
> --- a/drivers/gpu/drm/i915/intel_connector.c
> +++ b/drivers/gpu/drm/i915/intel_connector.c
> @@ -88,6 +88,8 @@ void intel_connector_destroy(struct drm_connector 
> *connector)
>  
>   kfree(intel_connector->detect_edid);
>  
> + intel_hdcp_cleanup(intel_connector);
> +
>   if (!IS_ERR_OR_NULL(intel_connector->edid))
>   kfree(intel_connector->edid);
>  
> diff --git a/drivers/gpu/drm/i915/intel_display.c 
> b/drivers/gpu/drm/i915/intel_display.c
> index 0a8913b2059e..97bce4707a4c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -15459,6 +15459,8 @@ int intel_modeset_init(struct drm_device *dev)
>   intel_update_czclk(dev_priv);
>   intel_modeset_init_hw(dev);
>  
> + intel_hdcp_component_init(dev_priv);
> +
>   if (dev_priv->max_cdclk_freq == 0)
>   intel_update_max_cdclk(dev_priv);
>  
> @@ -16320,6 +16322,8 @@ void intel_modeset_cleanup(struct drm_device *dev)
>   /* flush any delayed tasks or pending work */
>   flush_scheduled_work();
>  
> + intel_hdcp_component_fini(dev_priv);
> +
>   drm_mode_config_cleanup(dev);
>  
>   intel_overlay_cleanup(dev_priv);
> diff --git a/drivers/gpu/drm/i915/intel_drv.h 
> b/drivers/gpu/drm/i915/intel_drv.h
> index 11c696025085..f8e8482573c8 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -41,6 +41,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  struct drm_printer;
> @@ -395,6 +396,9 @@ struct intel_hdcp_shim {
>   /* Detects panel's hdcp capability. This is optional for HDMI. */
>   int (*hdcp_capable)(struct intel_digital_port *intel_dig_port,
>   bool *hdcp_capable);
> +
> + /* HDCP adaptation(DP/HDMI) required on the port */
> + enum hdcp_wired_protocol protocol;
>  };
>  
>  struct intel_hdcp {
> @@ -415,6 +419,7 @@ struct intel_hdcp {
>* content can flow only through a link protected by HDCP2.2.
>*/
>   u8 content_type;
> + struct hdcp_port_data