[PATCH v10 36/39] misc/mei/hdcp: Component framework for I915 Interface
Ramalingam C
ramalingam.c at intel.com
Tue Jan 29 14:43:24 UTC 2019
Mei hdcp driver is designed as component slave for the I915 component
master.
v2: Rebased.
v3:
Notifier chain is adopted for cldev state update [Tomas]
v4:
Made static dummy functions as inline in mei_hdcp.h
API for polling client device status
IS_ENABLED used in header, for config status for mei_hdcp.
v5:
Replacing the notifier with component framework. [Daniel]
v6:
Rebased on the I915 comp master redesign.
v7:
mei_hdcp_component_registered is made static [Uma]
Need for global static variable mei_cldev is removed.
v8:
master comp is added to be matched with i915 subcomponent [daniel]
Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
Reviewed-by: Uma Shankar <uma.shankar at intel.com>
---
drivers/misc/mei/hdcp/mei_hdcp.c | 70 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 68 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c
index 0dc2ea84c337..f5774d83183a 100644
--- a/drivers/misc/mei/hdcp/mei_hdcp.c
+++ b/drivers/misc/mei/hdcp/mei_hdcp.c
@@ -23,12 +23,16 @@
#include <linux/slab.h>
#include <linux/uuid.h>
#include <linux/mei_cl_bus.h>
+#include <linux/component.h>
#include <drm/drm_connector.h>
#include <drm/i915_component.h>
#include <drm/i915_mei_hdcp_interface.h>
#include "mei_hdcp.h"
+static struct i915_hdcp_comp_master *comp_master;
+static struct component_match *master_match;
+
/**
* mei_initiate_hdcp2_session() - Initiate a Wired HDCP2.2 Tx Session in ME FW
* @dev: device corresponding to the mei_cl_device
@@ -692,8 +696,7 @@ mei_close_hdcp_session(struct device *dev, struct hdcp_port_data *data)
return 0;
}
-static __attribute__((unused))
-struct i915_hdcp_component_ops mei_hdcp_ops = {
+static struct i915_hdcp_component_ops mei_hdcp_ops = {
.owner = THIS_MODULE,
.initiate_hdcp2_session = mei_initiate_hdcp2_session,
.verify_receiver_cert_prepare_km = mei_verify_receiver_cert_prepare_km,
@@ -708,6 +711,38 @@ struct i915_hdcp_component_ops mei_hdcp_ops = {
.close_hdcp_session = mei_close_hdcp_session,
};
+static int mei_component_master_bind(struct device *dev)
+{
+ int ret;
+
+ dev_info(dev, "%s\n", __func__);
+ comp_master->ops = &mei_hdcp_ops;
+ comp_master->mei_dev = dev;
+ ret = component_bind_all(dev, comp_master);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static void mei_component_master_unbind(struct device *dev)
+{
+ dev_info(dev, "%s\n", __func__);
+ component_unbind_all(dev, comp_master);
+}
+
+static const struct component_master_ops mei_component_master_ops = {
+ .bind = mei_component_master_bind,
+ .unbind = mei_component_master_unbind,
+};
+
+static int i915_hdcp_component_match(struct device *dev, int subcomponent,
+ void *data)
+{
+ return !strcmp(dev->driver->name, "i915") &&
+ subcomponent == I915_COMPONENT_HDCP;
+}
+
static int mei_hdcp_probe(struct mei_cl_device *cldev,
const struct mei_cl_device_id *id)
{
@@ -717,11 +752,42 @@ static int mei_hdcp_probe(struct mei_cl_device *cldev,
if (ret < 0)
dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret);
+ comp_master = kzalloc(sizeof(*comp_master), GFP_KERNEL);
+ if (!comp_master) {
+ ret = -ENOMEM;
+ goto master_alloc_exit;
+ }
+
+ component_match_add_typed(&cldev->dev, &master_match,
+ i915_hdcp_component_match, comp_master);
+ if (IS_ERR_OR_NULL(master_match)) {
+ ret = -ENOMEM;
+ goto master_add_exit;
+ }
+
+ ret = component_master_add_with_match(&cldev->dev,
+ &mei_component_master_ops,
+ master_match);
+ if (ret < 0) {
+ dev_err(&cldev->dev, "Master comp add failed %d\n", ret);
+ goto master_add_exit;
+ }
+
+ return 0;
+
+master_add_exit:
+ kfree(comp_master);
+master_alloc_exit:
+ mei_cldev_disable(cldev);
+
return ret;
}
static int mei_hdcp_remove(struct mei_cl_device *cldev)
{
+ component_master_del(&cldev->dev, &mei_component_master_ops);
+ kfree(comp_master);
+
return mei_cldev_disable(cldev);
}
--
2.7.4
More information about the Intel-gfx-trybot
mailing list