diff mbox series

[v14,03/32] drm/i915: MEI interface implementation

Message ID 1550263881-16082-4-git-send-email-ramalingam.c@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Implement HDCP2.2 | expand

Commit Message

kernel test robot via dri-devel Feb. 15, 2019, 8:50 p.m. UTC
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]
v8:
  subcomponent name is dropped as it is already merged.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> [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 ++++++++++++++++++++++++++++++++-
 6 files changed, 419 insertions(+), 1 deletion(-)

Comments

kernel test robot via dri-devel Feb. 16, 2019, 1:40 a.m. UTC | #1
Hi Ramalingam,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on next-20190215]
[cannot apply to v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Ramalingam-C/drm-i915-Implement-HDCP2-2/20190216-090245
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-x007-201906 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-20) 8.2.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/drm/i915_component.h:27,
                    from drivers/gpu/drm/i915/intel_hdcp.c:10:
>> include/drm/drm_audio_component.h:22:27: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*get_power)(struct device *);
                              ^~~~~~
   include/drm/drm_audio_component.h:28:27: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*put_power)(struct device *);
                              ^~~~~~
   include/drm/drm_audio_component.h:32:37: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*codec_wake_override)(struct device *, bool enable);
                                        ^~~~~~
   include/drm/drm_audio_component.h:36:31: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*get_cdclk_freq)(struct device *);
                                  ^~~~~~
   include/drm/drm_audio_component.h:43:32: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
                                   ^~~~~~
   include/drm/drm_audio_component.h:56:24: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*get_eld)(struct device *, int port, int pipe, bool *enabled,
                           ^~~~~~
   include/drm/drm_audio_component.h:90:28: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*master_bind)(struct device *dev, struct drm_audio_component *);
                               ^~~~~~
   include/drm/drm_audio_component.h:97:31: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*master_unbind)(struct device *dev, struct drm_audio_component *);
                                  ^~~~~~
   In file included from drivers/gpu/drm/i915/intel_drv.h:34,
                    from drivers/gpu/drm/i915/intel_hdcp.c:15:
   drivers/gpu/drm/i915/i915_drv.h:58:10: fatal error: drm/i915_mei_hdcp_interface.h: No such file or directory
    #include <drm/i915_mei_hdcp_interface.h>
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   compilation terminated.
--
   In file included from include/drm/i915_component.h:27,
                    from drivers/gpu//drm/i915/intel_hdcp.c:10:
>> include/drm/drm_audio_component.h:22:27: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*get_power)(struct device *);
                              ^~~~~~
   include/drm/drm_audio_component.h:28:27: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*put_power)(struct device *);
                              ^~~~~~
   include/drm/drm_audio_component.h:32:37: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*codec_wake_override)(struct device *, bool enable);
                                        ^~~~~~
   include/drm/drm_audio_component.h:36:31: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*get_cdclk_freq)(struct device *);
                                  ^~~~~~
   include/drm/drm_audio_component.h:43:32: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
                                   ^~~~~~
   include/drm/drm_audio_component.h:56:24: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*get_eld)(struct device *, int port, int pipe, bool *enabled,
                           ^~~~~~
   include/drm/drm_audio_component.h:90:28: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     int (*master_bind)(struct device *dev, struct drm_audio_component *);
                               ^~~~~~
   include/drm/drm_audio_component.h:97:31: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
     void (*master_unbind)(struct device *dev, struct drm_audio_component *);
                                  ^~~~~~
   In file included from drivers/gpu//drm/i915/intel_drv.h:34,
                    from drivers/gpu//drm/i915/intel_hdcp.c:15:
   drivers/gpu//drm/i915/i915_drv.h:58:10: fatal error: drm/i915_mei_hdcp_interface.h: No such file or directory
    #include <drm/i915_mei_hdcp_interface.h>
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   compilation terminated.

vim +22 include/drm/drm_audio_component.h

a57942bf Takashi Iwai 2018-07-11   8  
ae891abe Takashi Iwai 2018-07-11   9  /**
ae891abe Takashi Iwai 2018-07-11  10   * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver
ae891abe Takashi Iwai 2018-07-11  11   */
ae891abe Takashi Iwai 2018-07-11  12  struct drm_audio_component_ops {
ae891abe Takashi Iwai 2018-07-11  13  	/**
ae891abe Takashi Iwai 2018-07-11  14  	 * @owner: drm module to pin down
ae891abe Takashi Iwai 2018-07-11  15  	 */
ae891abe Takashi Iwai 2018-07-11  16  	struct module *owner;
ae891abe Takashi Iwai 2018-07-11  17  	/**
ae891abe Takashi Iwai 2018-07-11  18  	 * @get_power: get the POWER_DOMAIN_AUDIO power well
ae891abe Takashi Iwai 2018-07-11  19  	 *
ae891abe Takashi Iwai 2018-07-11  20  	 * Request the power well to be turned on.
ae891abe Takashi Iwai 2018-07-11  21  	 */
ae891abe Takashi Iwai 2018-07-11 @22  	void (*get_power)(struct device *);
ae891abe Takashi Iwai 2018-07-11  23  	/**
ae891abe Takashi Iwai 2018-07-11  24  	 * @put_power: put the POWER_DOMAIN_AUDIO power well
ae891abe Takashi Iwai 2018-07-11  25  	 *
ae891abe Takashi Iwai 2018-07-11  26  	 * Allow the power well to be turned off.
ae891abe Takashi Iwai 2018-07-11  27  	 */
ae891abe Takashi Iwai 2018-07-11  28  	void (*put_power)(struct device *);
ae891abe Takashi Iwai 2018-07-11  29  	/**
ae891abe Takashi Iwai 2018-07-11  30  	 * @codec_wake_override: Enable/disable codec wake signal
ae891abe Takashi Iwai 2018-07-11  31  	 */
ae891abe Takashi Iwai 2018-07-11  32  	void (*codec_wake_override)(struct device *, bool enable);
ae891abe Takashi Iwai 2018-07-11  33  	/**
ae891abe Takashi Iwai 2018-07-11  34  	 * @get_cdclk_freq: Get the Core Display Clock in kHz
ae891abe Takashi Iwai 2018-07-11  35  	 */
ae891abe Takashi Iwai 2018-07-11  36  	int (*get_cdclk_freq)(struct device *);
ae891abe Takashi Iwai 2018-07-11  37  	/**
ae891abe Takashi Iwai 2018-07-11  38  	 * @sync_audio_rate: set n/cts based on the sample rate
ae891abe Takashi Iwai 2018-07-11  39  	 *
ae891abe Takashi Iwai 2018-07-11  40  	 * Called from audio driver. After audio driver sets the
ae891abe Takashi Iwai 2018-07-11  41  	 * sample rate, it will call this function to set n/cts
ae891abe Takashi Iwai 2018-07-11  42  	 */
ae891abe Takashi Iwai 2018-07-11  43  	int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
ae891abe Takashi Iwai 2018-07-11  44  	/**
ae891abe Takashi Iwai 2018-07-11  45  	 * @get_eld: fill the audio state and ELD bytes for the given port
ae891abe Takashi Iwai 2018-07-11  46  	 *
ae891abe Takashi Iwai 2018-07-11  47  	 * Called from audio driver to get the HDMI/DP audio state of the given
ae891abe Takashi Iwai 2018-07-11  48  	 * digital port, and also fetch ELD bytes to the given pointer.
ae891abe Takashi Iwai 2018-07-11  49  	 *
ae891abe Takashi Iwai 2018-07-11  50  	 * It returns the byte size of the original ELD (not the actually
ae891abe Takashi Iwai 2018-07-11  51  	 * copied size), zero for an invalid ELD, or a negative error code.
ae891abe Takashi Iwai 2018-07-11  52  	 *
ae891abe Takashi Iwai 2018-07-11  53  	 * Note that the returned size may be over @max_bytes.  Then it
ae891abe Takashi Iwai 2018-07-11  54  	 * implies that only a part of ELD has been copied to the buffer.
ae891abe Takashi Iwai 2018-07-11  55  	 */
ae891abe Takashi Iwai 2018-07-11  56  	int (*get_eld)(struct device *, int port, int pipe, bool *enabled,
ae891abe Takashi Iwai 2018-07-11  57  		       unsigned char *buf, int max_bytes);
ae891abe Takashi Iwai 2018-07-11  58  };
ae891abe Takashi Iwai 2018-07-11  59  

:::::: The code at line 22 was first introduced by commit
:::::: ae891abe7c2ccf75b69ca8330225e37ecc06924e drm/i915: Split audio component to a generic type

:::::: TO: Takashi Iwai <tiwai@suse.de>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot via dri-devel Feb. 16, 2019, 3:28 a.m. UTC | #2
Hi Ramalingam,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on next-20190215]
[cannot apply to v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Ramalingam-C/drm-i915-Implement-HDCP2-2/20190216-090245
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-l1-02160931 (attached as .config)
compiler: gcc-5 (Debian 5.5.0-3) 5.4.1 20171010
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/drm/i915_component.h:27:0,
                    from drivers/gpu/drm/i915/intel_hdcp.c:10:
>> include/drm/drm_audio_component.h:22:27: warning: 'struct device' declared inside parameter list
     void (*get_power)(struct device *);
                              ^
>> include/drm/drm_audio_component.h:22:27: warning: its scope is only this definition or declaration, which is probably not what you want
   include/drm/drm_audio_component.h:28:27: warning: 'struct device' declared inside parameter list
     void (*put_power)(struct device *);
                              ^
   include/drm/drm_audio_component.h:32:37: warning: 'struct device' declared inside parameter list
     void (*codec_wake_override)(struct device *, bool enable);
                                        ^
   include/drm/drm_audio_component.h:36:31: warning: 'struct device' declared inside parameter list
     int (*get_cdclk_freq)(struct device *);
                                  ^
   include/drm/drm_audio_component.h:43:32: warning: 'struct device' declared inside parameter list
     int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
                                   ^
   include/drm/drm_audio_component.h:57:10: warning: 'struct device' declared inside parameter list
             unsigned char *buf, int max_bytes);
             ^
   include/drm/drm_audio_component.h:90:48: warning: 'struct device' declared inside parameter list
     int (*master_bind)(struct device *dev, struct drm_audio_component *);
                                                   ^
   include/drm/drm_audio_component.h:97:51: warning: 'struct device' declared inside parameter list
     void (*master_unbind)(struct device *dev, struct drm_audio_component *);
                                                      ^
   In file included from drivers/gpu/drm/i915/intel_drv.h:34:0,
                    from drivers/gpu/drm/i915/intel_hdcp.c:15:
   drivers/gpu/drm/i915/i915_drv.h:58:41: fatal error: drm/i915_mei_hdcp_interface.h: No such file or directory
   compilation terminated.
--
   In file included from include/drm/i915_component.h:27:0,
                    from drivers/gpu//drm/i915/intel_hdcp.c:10:
>> include/drm/drm_audio_component.h:22:27: warning: 'struct device' declared inside parameter list
     void (*get_power)(struct device *);
                              ^
>> include/drm/drm_audio_component.h:22:27: warning: its scope is only this definition or declaration, which is probably not what you want
   include/drm/drm_audio_component.h:28:27: warning: 'struct device' declared inside parameter list
     void (*put_power)(struct device *);
                              ^
   include/drm/drm_audio_component.h:32:37: warning: 'struct device' declared inside parameter list
     void (*codec_wake_override)(struct device *, bool enable);
                                        ^
   include/drm/drm_audio_component.h:36:31: warning: 'struct device' declared inside parameter list
     int (*get_cdclk_freq)(struct device *);
                                  ^
   include/drm/drm_audio_component.h:43:32: warning: 'struct device' declared inside parameter list
     int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
                                   ^
   include/drm/drm_audio_component.h:57:10: warning: 'struct device' declared inside parameter list
             unsigned char *buf, int max_bytes);
             ^
   include/drm/drm_audio_component.h:90:48: warning: 'struct device' declared inside parameter list
     int (*master_bind)(struct device *dev, struct drm_audio_component *);
                                                   ^
   include/drm/drm_audio_component.h:97:51: warning: 'struct device' declared inside parameter list
     void (*master_unbind)(struct device *dev, struct drm_audio_component *);
                                                      ^
   In file included from drivers/gpu//drm/i915/intel_drv.h:34:0,
                    from drivers/gpu//drm/i915/intel_hdcp.c:15:
   drivers/gpu//drm/i915/i915_drv.h:58:41: fatal error: drm/i915_mei_hdcp_interface.h: No such file or directory
   compilation terminated.

vim +22 include/drm/drm_audio_component.h

a57942bf Takashi Iwai 2018-07-11   8  
ae891abe Takashi Iwai 2018-07-11   9  /**
ae891abe Takashi Iwai 2018-07-11  10   * struct drm_audio_component_ops - Ops implemented by DRM driver, called by hda driver
ae891abe Takashi Iwai 2018-07-11  11   */
ae891abe Takashi Iwai 2018-07-11  12  struct drm_audio_component_ops {
ae891abe Takashi Iwai 2018-07-11  13  	/**
ae891abe Takashi Iwai 2018-07-11  14  	 * @owner: drm module to pin down
ae891abe Takashi Iwai 2018-07-11  15  	 */
ae891abe Takashi Iwai 2018-07-11  16  	struct module *owner;
ae891abe Takashi Iwai 2018-07-11  17  	/**
ae891abe Takashi Iwai 2018-07-11  18  	 * @get_power: get the POWER_DOMAIN_AUDIO power well
ae891abe Takashi Iwai 2018-07-11  19  	 *
ae891abe Takashi Iwai 2018-07-11  20  	 * Request the power well to be turned on.
ae891abe Takashi Iwai 2018-07-11  21  	 */
ae891abe Takashi Iwai 2018-07-11 @22  	void (*get_power)(struct device *);
ae891abe Takashi Iwai 2018-07-11  23  	/**
ae891abe Takashi Iwai 2018-07-11  24  	 * @put_power: put the POWER_DOMAIN_AUDIO power well
ae891abe Takashi Iwai 2018-07-11  25  	 *
ae891abe Takashi Iwai 2018-07-11  26  	 * Allow the power well to be turned off.
ae891abe Takashi Iwai 2018-07-11  27  	 */
ae891abe Takashi Iwai 2018-07-11  28  	void (*put_power)(struct device *);
ae891abe Takashi Iwai 2018-07-11  29  	/**
ae891abe Takashi Iwai 2018-07-11  30  	 * @codec_wake_override: Enable/disable codec wake signal
ae891abe Takashi Iwai 2018-07-11  31  	 */
ae891abe Takashi Iwai 2018-07-11  32  	void (*codec_wake_override)(struct device *, bool enable);
ae891abe Takashi Iwai 2018-07-11  33  	/**
ae891abe Takashi Iwai 2018-07-11  34  	 * @get_cdclk_freq: Get the Core Display Clock in kHz
ae891abe Takashi Iwai 2018-07-11  35  	 */
ae891abe Takashi Iwai 2018-07-11  36  	int (*get_cdclk_freq)(struct device *);
ae891abe Takashi Iwai 2018-07-11  37  	/**
ae891abe Takashi Iwai 2018-07-11  38  	 * @sync_audio_rate: set n/cts based on the sample rate
ae891abe Takashi Iwai 2018-07-11  39  	 *
ae891abe Takashi Iwai 2018-07-11  40  	 * Called from audio driver. After audio driver sets the
ae891abe Takashi Iwai 2018-07-11  41  	 * sample rate, it will call this function to set n/cts
ae891abe Takashi Iwai 2018-07-11  42  	 */
ae891abe Takashi Iwai 2018-07-11  43  	int (*sync_audio_rate)(struct device *, int port, int pipe, int rate);
ae891abe Takashi Iwai 2018-07-11  44  	/**
ae891abe Takashi Iwai 2018-07-11  45  	 * @get_eld: fill the audio state and ELD bytes for the given port
ae891abe Takashi Iwai 2018-07-11  46  	 *
ae891abe Takashi Iwai 2018-07-11  47  	 * Called from audio driver to get the HDMI/DP audio state of the given
ae891abe Takashi Iwai 2018-07-11  48  	 * digital port, and also fetch ELD bytes to the given pointer.
ae891abe Takashi Iwai 2018-07-11  49  	 *
ae891abe Takashi Iwai 2018-07-11  50  	 * It returns the byte size of the original ELD (not the actually
ae891abe Takashi Iwai 2018-07-11  51  	 * copied size), zero for an invalid ELD, or a negative error code.
ae891abe Takashi Iwai 2018-07-11  52  	 *
ae891abe Takashi Iwai 2018-07-11  53  	 * Note that the returned size may be over @max_bytes.  Then it
ae891abe Takashi Iwai 2018-07-11  54  	 * implies that only a part of ELD has been copied to the buffer.
ae891abe Takashi Iwai 2018-07-11  55  	 */
ae891abe Takashi Iwai 2018-07-11  56  	int (*get_eld)(struct device *, int port, int pipe, bool *enabled,
ae891abe Takashi Iwai 2018-07-11  57  		       unsigned char *buf, int max_bytes);
ae891abe Takashi Iwai 2018-07-11  58  };
ae891abe Takashi Iwai 2018-07-11  59  

:::::: The code at line 22 was first introduced by commit
:::::: ae891abe7c2ccf75b69ca8330225e37ecc06924e drm/i915: Split audio component to a generic type

:::::: TO: Takashi Iwai <tiwai@suse.de>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

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(&dev_priv->av_mutex);
 	mutex_init(&dev_priv->wm.wm_mutex);
 	mutex_init(&dev_priv->pps_mutex);
+	mutex_init(&dev_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 5c8d0489a1cd..d375d1cf86f5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -55,6 +55,7 @@ 
 #include <drm/drm_util.h>
 #include <drm/drm_dsc.h>
 #include <drm/drm_connector.h>
+#include <drm/i915_mei_hdcp_interface.h>
 
 #include "i915_fixed.h"
 #include "i915_params.h"
@@ -2052,6 +2053,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 73a107b6eb9a..acb993ce7eaa 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -15453,6 +15453,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);
 
@@ -16314,6 +16316,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 <drm/drm_rect.h>
 #include <drm/drm_vblank.h>
 #include <drm/drm_atomic.h>
+#include <drm/i915_mei_hdcp_interface.h>
 #include <media/cec-notifier.h>
 
 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 intel_hdcp_capable(struct intel_connector *connector);
+void intel_hdcp_component_init(struct drm_i915_private *dev_priv);
+void intel_hdcp_component_fini(struct drm_i915_private *dev_priv);
+void intel_hdcp_cleanup(struct intel_connector *connector);
 
 /* intel_psr.c */
 #define CAN_PSR(dev_priv) (HAS_PSR(dev_priv) && dev_priv->psr.sink_support)
diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
index 7b1097d79fb8..d06bef9d1ab2 100644
--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -7,8 +7,10 @@ 
  */
 
 #include <drm/drm_hdcp.h>
+#include <drm/i915_component.h>
 #include <linux/i2c.h>
 #include <linux/random.h>
+#include <linux/component.h>
 
 #include "intel_drv.h"
 #include "i915_reg.h"
@@ -832,6 +834,347 @@  bool is_hdcp_supported(struct drm_i915_private *dev_priv, enum port port)
 	return INTEL_GEN(dev_priv) >= 9 && port < PORT_E;
 }
 
+static __attribute__((unused)) int
+hdcp2_prepare_ake_init(struct intel_connector *connector,
+		       struct hdcp2_ake_init *ake_data)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->initiate_hdcp2_session(comp->mei_dev, data, ake_data);
+	if (ret)
+		DRM_DEBUG_KMS("Prepare_ake_init failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused)) int
+hdcp2_verify_rx_cert_prepare_km(struct intel_connector *connector,
+				struct hdcp2_ake_send_cert *rx_cert,
+				bool *paired,
+				struct hdcp2_ake_no_stored_km *ek_pub_km,
+				size_t *msg_sz)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->verify_receiver_cert_prepare_km(comp->mei_dev, data,
+							 rx_cert, paired,
+							 ek_pub_km, msg_sz);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Verify rx_cert failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused)) int
+hdcp2_verify_hprime(struct intel_connector *connector,
+		    struct hdcp2_ake_send_hprime *rx_hprime)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->verify_hprime(comp->mei_dev, data, rx_hprime);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Verify hprime failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused)) int
+hdcp2_store_pairing_info(struct intel_connector *connector,
+			 struct hdcp2_ake_send_pairing_info *pairing_info)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->store_pairing_info(comp->mei_dev, data, pairing_info);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Store pairing info failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused)) int
+hdcp2_prepare_lc_init(struct intel_connector *connector,
+		      struct hdcp2_lc_init *lc_init)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->initiate_locality_check(comp->mei_dev, data, lc_init);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Prepare lc_init failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused)) int
+hdcp2_verify_lprime(struct intel_connector *connector,
+		    struct hdcp2_lc_send_lprime *rx_lprime)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->verify_lprime(comp->mei_dev, data, rx_lprime);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Verify L_Prime failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused))
+int hdcp2_prepare_skey(struct intel_connector *connector,
+		       struct hdcp2_ske_send_eks *ske_data)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->get_session_key(comp->mei_dev, data, ske_data);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Get session key failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused)) int
+hdcp2_verify_rep_topology_prepare_ack(struct intel_connector *connector,
+				      struct hdcp2_rep_send_receiverid_list
+								*rep_topology,
+				      struct hdcp2_rep_send_ack *rep_send_ack)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->repeater_check_flow_prepare_ack(comp->mei_dev, data,
+							 rep_topology,
+							 rep_send_ack);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Verify rep topology failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused)) int
+hdcp2_verify_mprime(struct intel_connector *connector,
+		    struct hdcp2_rep_stream_ready *stream_ready)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->verify_mprime(comp->mei_dev, data, stream_ready);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Verify mprime failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused))
+int hdcp2_authenticate_port(struct intel_connector *connector)
+{
+	struct hdcp_port_data *data = &connector->hdcp.port_data;
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->enable_hdcp_authentication(comp->mei_dev, data);
+	if (ret < 0)
+		DRM_DEBUG_KMS("Enable hdcp auth failed. %d\n", ret);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused))
+int hdcp2_close_mei_session(struct intel_connector *connector)
+{
+	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+	struct i915_hdcp_comp_master *comp;
+	int ret;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	comp = dev_priv->hdcp_master;
+
+	if (!comp || !comp->ops) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return -EINVAL;
+	}
+
+	ret = comp->ops->close_hdcp_session(comp->mei_dev,
+					     &connector->hdcp.port_data);
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return ret;
+}
+
+static __attribute__((unused))
+int hdcp2_deauthenticate_port(struct intel_connector *connector)
+{
+	return hdcp2_close_mei_session(connector);
+}
+
+static int i915_hdcp_component_bind(struct device *i915_kdev,
+				    struct device *mei_kdev, void *data)
+{
+	struct drm_i915_private *dev_priv = kdev_to_i915(i915_kdev);
+
+	DRM_DEBUG("I915 HDCP comp bind\n");
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	dev_priv->hdcp_master = (struct i915_hdcp_comp_master *)data;
+	dev_priv->hdcp_master->mei_dev = mei_kdev;
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	return 0;
+}
+
+static void i915_hdcp_component_unbind(struct device *i915_kdev,
+				       struct device *mei_kdev, void *data)
+{
+	struct drm_i915_private *dev_priv = kdev_to_i915(i915_kdev);
+
+	DRM_DEBUG("I915 HDCP comp unbind\n");
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	dev_priv->hdcp_master = NULL;
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+}
+
+static const struct component_ops i915_hdcp_component_ops = {
+	.bind   = i915_hdcp_component_bind,
+	.unbind = i915_hdcp_component_unbind,
+};
+
+static inline int initialize_hdcp_port_data(struct intel_connector *connector)
+{
+	struct intel_hdcp *hdcp = &connector->hdcp;
+	struct hdcp_port_data *data = &hdcp->port_data;
+
+	data->port = connector->encoder->port;
+	data->port_type = (u8)HDCP_PORT_TYPE_INTEGRATED;
+	data->protocol = (u8)hdcp->shim->protocol;
+
+	data->k = 1;
+	if (!data->streams)
+		data->streams = kcalloc(data->k,
+					sizeof(struct hdcp2_streamid_type),
+					GFP_KERNEL);
+	if (!data->streams) {
+		DRM_ERROR("Out of Memory\n");
+		return -ENOMEM;
+	}
+
+	data->streams[0].stream_id = 0;
+	data->streams[0].stream_type = hdcp->content_type;
+
+	return 0;
+}
+
 static bool is_hdcp2_supported(struct drm_i915_private *dev_priv)
 {
 	if (!IS_ENABLED(CONFIG_INTEL_MEI_HDCP))
@@ -841,11 +1184,40 @@  static bool is_hdcp2_supported(struct drm_i915_private *dev_priv)
 		IS_KABYLAKE(dev_priv));
 }
 
+void intel_hdcp_component_init(struct drm_i915_private *dev_priv)
+{
+	int ret;
+
+	if (!is_hdcp2_supported(dev_priv))
+		return;
+
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	WARN_ON(dev_priv->hdcp_comp_added);
+
+	dev_priv->hdcp_comp_added = true;
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+	ret = component_add_typed(dev_priv->drm.dev, &i915_hdcp_component_ops,
+				  I915_COMPONENT_HDCP);
+	if (ret < 0) {
+		DRM_DEBUG_KMS("Failed at component add(%d)\n", ret);
+		mutex_lock(&dev_priv->hdcp_comp_mutex);
+		dev_priv->hdcp_comp_added = false;
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return;
+	}
+}
+
 static void intel_hdcp2_init(struct intel_connector *connector)
 {
 	struct intel_hdcp *hdcp = &connector->hdcp;
+	int ret;
+
+	ret = initialize_hdcp_port_data(connector);
+	if (ret) {
+		DRM_DEBUG_KMS("Mei hdcp data init failed\n");
+		return;
+	}
 
-	/* TODO: MEI interface needs to be initialized here */
 	hdcp->hdcp2_supported = true;
 }
 
@@ -917,6 +1289,30 @@  int intel_hdcp_disable(struct intel_connector *connector)
 	return ret;
 }
 
+void intel_hdcp_component_fini(struct drm_i915_private *dev_priv)
+{
+	mutex_lock(&dev_priv->hdcp_comp_mutex);
+	if (!dev_priv->hdcp_comp_added) {
+		mutex_unlock(&dev_priv->hdcp_comp_mutex);
+		return;
+	}
+
+	dev_priv->hdcp_comp_added = false;
+	mutex_unlock(&dev_priv->hdcp_comp_mutex);
+
+	component_del(dev_priv->drm.dev, &i915_hdcp_component_ops);
+}
+
+void intel_hdcp_cleanup(struct intel_connector *connector)
+{
+	if (!connector->hdcp.shim)
+		return;
+
+	mutex_lock(&connector->hdcp.mutex);
+	kfree(connector->hdcp.port_data.streams);
+	mutex_unlock(&connector->hdcp.mutex);
+}
+
 void intel_hdcp_atomic_check(struct drm_connector *connector,
 			     struct drm_connector_state *old_state,
 			     struct drm_connector_state *new_state)