From patchwork Thu Jan 31 06:59:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10789853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 201B61390 for ; Thu, 31 Jan 2019 07:08:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C5042EFB4 for ; Thu, 31 Jan 2019 07:08:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1038B300F7; Thu, 31 Jan 2019 07:08:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB5922EFB4 for ; Thu, 31 Jan 2019 07:08:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B0A86EBF7; Thu, 31 Jan 2019 07:07:34 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 43CC36EBEE; Thu, 31 Jan 2019 07:07:27 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2019 23:07:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,543,1539673200"; d="scan'208";a="114128626" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga008.jf.intel.com with ESMTP; 30 Jan 2019 23:07:24 -0800 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, tomas.winkler@intel.com, uma.shankar@intel.com Date: Thu, 31 Jan 2019 12:29:52 +0530 Message-Id: <1548917996-28081-37-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548917996-28081-1-git-send-email-ramalingam.c@intel.com> References: <1548917996-28081-1-git-send-email-ramalingam.c@intel.com> Subject: [Intel-gfx] [PATCH v10 36/40] misc/mei/hdcp: Component framework for I915 Interface X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Uma Shankar Reviewed-by: Daniel Vetter --- drivers/misc/mei/hdcp/mei_hdcp.c | 90 +++++++++++++++++++++++++++++++++++++++- drivers/misc/mei/hdcp/mei_hdcp.h | 5 +++ 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c index edfc70fb0617..be2ce12ca460 100644 --- a/drivers/misc/mei/hdcp/mei_hdcp.c +++ b/drivers/misc/mei/hdcp/mei_hdcp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -692,8 +693,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,20 +708,106 @@ struct i915_hdcp_component_ops mei_hdcp_ops = { .close_hdcp_session = mei_close_hdcp_session, }; +static int mei_component_master_bind(struct device *dev) +{ + struct mei_cl_device *cldev = to_mei_cl_device(dev); + struct mei_hdcp_drv_data *drv_data = mei_cldev_get_drvdata(cldev); + int ret; + + dev_info(dev, "%s\n", __func__); + drv_data->comp_master->ops = &mei_hdcp_ops; + drv_data->comp_master->mei_dev = dev; + ret = component_bind_all(dev, drv_data->comp_master); + if (ret < 0) + return ret; + + return 0; +} + +static void mei_component_master_unbind(struct device *dev) +{ + struct mei_cl_device *cldev = to_mei_cl_device(dev); + struct mei_hdcp_drv_data *drv_data = mei_cldev_get_drvdata(cldev); + + dev_info(dev, "%s\n", __func__); + component_unbind_all(dev, drv_data->comp_master); +} + +static const struct component_master_ops mei_component_master_ops = { + .bind = mei_component_master_bind, + .unbind = mei_component_master_unbind, +}; + +static int mei_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) { + struct mei_hdcp_drv_data *drv_data; int ret; ret = mei_cldev_enable(cldev); if (ret < 0) dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret); + drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL); + if (!drv_data) { + ret = -ENOMEM; + goto drv_data_exit; + } + + drv_data->comp_master = kzalloc(sizeof(*drv_data->comp_master), + GFP_KERNEL); + if (!drv_data->comp_master) { + ret = -ENOMEM; + goto comp_master_exit; + } + + drv_data->master_match = NULL; + component_match_add_typed(&cldev->dev, &drv_data->master_match, + mei_hdcp_component_match, + drv_data->comp_master); + if (IS_ERR_OR_NULL(drv_data->master_match)) { + ret = -ENOMEM; + goto match_add_exit; + } + + mei_cldev_set_drvdata(cldev, drv_data); + ret = component_master_add_with_match(&cldev->dev, + &mei_component_master_ops, + drv_data->master_match); + if (ret < 0) { + dev_err(&cldev->dev, "Master comp add failed %d\n", ret); + mei_cldev_set_drvdata(cldev, NULL); + goto match_add_exit; + } + + return 0; + +match_add_exit: + kfree(drv_data->comp_master); +comp_master_exit: + kfree(drv_data); +drv_data_exit: + mei_cldev_disable(cldev); + return ret; } static int mei_hdcp_remove(struct mei_cl_device *cldev) { + struct mei_hdcp_drv_data *drv_data = mei_cldev_get_drvdata(cldev); + + component_master_del(&cldev->dev, &mei_component_master_ops); + kfree(drv_data->comp_master); + kfree(drv_data); + mei_cldev_set_drvdata(cldev, NULL); + return mei_cldev_disable(cldev); } diff --git a/drivers/misc/mei/hdcp/mei_hdcp.h b/drivers/misc/mei/hdcp/mei_hdcp.h index f831db3cbd54..5c872a57ba11 100644 --- a/drivers/misc/mei/hdcp/mei_hdcp.h +++ b/drivers/misc/mei/hdcp/mei_hdcp.h @@ -363,6 +363,11 @@ struct wired_cmd_repeater_auth_stream_req_out { struct hdcp_port_id port; } __packed; +struct mei_hdcp_drv_data { + struct i915_hdcp_comp_master *comp_master; + struct component_match *master_match; +}; + enum mei_hdcp_ddi { MEI_DDI_INVALID_PORT = 0x0,