diff options
author | Ramalingam C <ramalingam.c@intel.com> | 2019-02-21 13:12:09 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2019-02-25 11:03:01 -0500 |
commit | fa301ad9fa8f6f738b9c22da3ede7824e3286693 (patch) | |
tree | f41532d3cf6e5238ed8449ae0c3dccbb34c1d31f /drivers/misc/mei | |
parent | 62c2b3221fa027573f02ca43b7678f95cde62eaf (diff) |
misc/mei/hdcp: Component framework for I915 Interface
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]
v9:
only comp_master is set and retrieved as driver_data [Daniel]
Reviewed-by Daniel.
v10:
small corrections at probe [Tomas]
v11:
bind and unbind logs are made as debug logs [Tomas]
cldev_enable failure is handled [Tomas]
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/1550772730-23280-16-git-send-email-ramalingam.c@intel.com
Diffstat (limited to 'drivers/misc/mei')
-rw-r--r-- | drivers/misc/mei/hdcp/mei_hdcp.c | 86 |
1 files changed, 83 insertions, 3 deletions
diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c index deb579ad15e8..90b6ae8e9dae 100644 --- a/drivers/misc/mei/hdcp/mei_hdcp.c +++ b/drivers/misc/mei/hdcp/mei_hdcp.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/uuid.h> | 24 | #include <linux/uuid.h> |
25 | #include <linux/mei_cl_bus.h> | 25 | #include <linux/mei_cl_bus.h> |
26 | #include <linux/component.h> | ||
26 | #include <drm/drm_connector.h> | 27 | #include <drm/drm_connector.h> |
27 | #include <drm/i915_component.h> | 28 | #include <drm/i915_component.h> |
28 | #include <drm/i915_mei_hdcp_interface.h> | 29 | #include <drm/i915_mei_hdcp_interface.h> |
@@ -711,8 +712,7 @@ mei_hdcp_close_session(struct device *dev, struct hdcp_port_data *data) | |||
711 | return 0; | 712 | return 0; |
712 | } | 713 | } |
713 | 714 | ||
714 | static const __attribute__((unused)) | 715 | static const struct i915_hdcp_component_ops mei_hdcp_ops = { |
715 | struct i915_hdcp_component_ops mei_hdcp_ops = { | ||
716 | .owner = THIS_MODULE, | 716 | .owner = THIS_MODULE, |
717 | .initiate_hdcp2_session = mei_hdcp_initiate_session, | 717 | .initiate_hdcp2_session = mei_hdcp_initiate_session, |
718 | .verify_receiver_cert_prepare_km = | 718 | .verify_receiver_cert_prepare_km = |
@@ -729,20 +729,100 @@ struct i915_hdcp_component_ops mei_hdcp_ops = { | |||
729 | .close_hdcp_session = mei_hdcp_close_session, | 729 | .close_hdcp_session = mei_hdcp_close_session, |
730 | }; | 730 | }; |
731 | 731 | ||
732 | static int mei_component_master_bind(struct device *dev) | ||
733 | { | ||
734 | struct mei_cl_device *cldev = to_mei_cl_device(dev); | ||
735 | struct i915_hdcp_comp_master *comp_master = | ||
736 | mei_cldev_get_drvdata(cldev); | ||
737 | int ret; | ||
738 | |||
739 | dev_dbg(dev, "%s\n", __func__); | ||
740 | comp_master->ops = &mei_hdcp_ops; | ||
741 | comp_master->mei_dev = dev; | ||
742 | ret = component_bind_all(dev, comp_master); | ||
743 | if (ret < 0) | ||
744 | return ret; | ||
745 | |||
746 | return 0; | ||
747 | } | ||
748 | |||
749 | static void mei_component_master_unbind(struct device *dev) | ||
750 | { | ||
751 | struct mei_cl_device *cldev = to_mei_cl_device(dev); | ||
752 | struct i915_hdcp_comp_master *comp_master = | ||
753 | mei_cldev_get_drvdata(cldev); | ||
754 | |||
755 | dev_dbg(dev, "%s\n", __func__); | ||
756 | component_unbind_all(dev, comp_master); | ||
757 | } | ||
758 | |||
759 | static const struct component_master_ops mei_component_master_ops = { | ||
760 | .bind = mei_component_master_bind, | ||
761 | .unbind = mei_component_master_unbind, | ||
762 | }; | ||
763 | |||
764 | static int mei_hdcp_component_match(struct device *dev, int subcomponent, | ||
765 | void *data) | ||
766 | { | ||
767 | return !strcmp(dev->driver->name, "i915") && | ||
768 | subcomponent == I915_COMPONENT_HDCP; | ||
769 | } | ||
770 | |||
732 | static int mei_hdcp_probe(struct mei_cl_device *cldev, | 771 | static int mei_hdcp_probe(struct mei_cl_device *cldev, |
733 | const struct mei_cl_device_id *id) | 772 | const struct mei_cl_device_id *id) |
734 | { | 773 | { |
774 | struct i915_hdcp_comp_master *comp_master; | ||
775 | struct component_match *master_match; | ||
735 | int ret; | 776 | int ret; |
736 | 777 | ||
737 | ret = mei_cldev_enable(cldev); | 778 | ret = mei_cldev_enable(cldev); |
738 | if (ret < 0) | 779 | if (ret < 0) { |
739 | dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret); | 780 | dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret); |
781 | goto enable_err_exit; | ||
782 | } | ||
783 | |||
784 | comp_master = kzalloc(sizeof(*comp_master), GFP_KERNEL); | ||
785 | if (!comp_master) { | ||
786 | ret = -ENOMEM; | ||
787 | goto err_exit; | ||
788 | } | ||
789 | |||
790 | master_match = NULL; | ||
791 | component_match_add_typed(&cldev->dev, &master_match, | ||
792 | mei_hdcp_component_match, comp_master); | ||
793 | if (IS_ERR_OR_NULL(master_match)) { | ||
794 | ret = -ENOMEM; | ||
795 | goto err_exit; | ||
796 | } | ||
797 | |||
798 | mei_cldev_set_drvdata(cldev, comp_master); | ||
799 | ret = component_master_add_with_match(&cldev->dev, | ||
800 | &mei_component_master_ops, | ||
801 | master_match); | ||
802 | if (ret < 0) { | ||
803 | dev_err(&cldev->dev, "Master comp add failed %d\n", ret); | ||
804 | goto err_exit; | ||
805 | } | ||
740 | 806 | ||
807 | return 0; | ||
808 | |||
809 | err_exit: | ||
810 | mei_cldev_set_drvdata(cldev, NULL); | ||
811 | kfree(comp_master); | ||
812 | mei_cldev_disable(cldev); | ||
813 | enable_err_exit: | ||
741 | return ret; | 814 | return ret; |
742 | } | 815 | } |
743 | 816 | ||
744 | static int mei_hdcp_remove(struct mei_cl_device *cldev) | 817 | static int mei_hdcp_remove(struct mei_cl_device *cldev) |
745 | { | 818 | { |
819 | struct i915_hdcp_comp_master *comp_master = | ||
820 | mei_cldev_get_drvdata(cldev); | ||
821 | |||
822 | component_master_del(&cldev->dev, &mei_component_master_ops); | ||
823 | kfree(comp_master); | ||
824 | mei_cldev_set_drvdata(cldev, NULL); | ||
825 | |||
746 | return mei_cldev_disable(cldev); | 826 | return mei_cldev_disable(cldev); |
747 | } | 827 | } |
748 | 828 | ||