From patchwork Wed Jun 27 08:40:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10490949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A62BA60375 for ; Wed, 27 Jun 2018 08:53:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 952841FE8A for ; Wed, 27 Jun 2018 08:53:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 896EF28641; Wed, 27 Jun 2018 08:53:28 +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=ham 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 2F9041FE8A for ; Wed, 27 Jun 2018 08:53:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7515B6E7FB; Wed, 27 Jun 2018 08:51:17 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69D676E7FB; Wed, 27 Jun 2018 08:51:16 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2018 01:51:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,278,1526367600"; d="scan'208";a="211536205" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga004.jf.intel.com with ESMTP; 27 Jun 2018 01:51:13 -0700 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel@ffwll.ch, tomas.winkler@intel.com, alexander.usyskin@intel.com, uma.shankar@intel.com Date: Wed, 27 Jun 2018 14:10:17 +0530 Message-Id: <1530088829-11730-29-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530088829-11730-1-git-send-email-ramalingam.c@intel.com> References: <1530088829-11730-1-git-send-email-ramalingam.c@intel.com> Subject: [Intel-gfx] [PATCH v5 28/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] Signed-off-by: Ramalingam C --- drivers/misc/mei/hdcp/mei_hdcp.c | 94 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c index 4cd6fdd01181..ba7550215b7f 100644 --- a/drivers/misc/mei/hdcp/mei_hdcp.c +++ b/drivers/misc/mei/hdcp/mei_hdcp.c @@ -31,6 +31,83 @@ #include #include #include +#include +#include + +bool mei_hdcp_component_registered; +static struct mei_cl_device *mei_cldev; + +struct i915_hdcp_component_ops mei_hdcp_component_ops = { + .owner = THIS_MODULE, + .initiate_hdcp2_session = NULL, + .verify_receiver_cert_prepare_km = NULL, + .verify_hprime = NULL, + .store_pairing_info = NULL, + .initiate_locality_check = NULL, + .verify_lprime = NULL, + .get_session_key = NULL, + .repeater_check_flow_prepare_ack = NULL, + .verify_mprime = NULL, + .enable_hdcp_authentication = NULL, + .close_hdcp_session = NULL, +}; + +static int mei_hdcp_component_bind(struct device *mei_kdev, + struct device *i915_kdev, void *data) +{ + struct i915_hdcp_component *comp = data; + + WARN_ON(!mutex_is_locked(&comp->mutex)); + if (WARN_ON(comp->ops || comp->dev)) + return -EEXIST; + + dev_info(mei_kdev, "MEI HDCP comp bind\n"); + comp->ops = &mei_hdcp_component_ops; + comp->i915_kdev = i915_kdev; + comp->mei_cldev = mei_cldev; + mei_cldev_set_drvdata(mei_cldev, (void *)comp); + + return 0; +} + +static void mei_hdcp_component_unbind(struct device *mei_kdev, + struct device *i915_kdev, void *data) +{ + struct i915_hdcp_component *comp = data; + + WARN_ON(!mutex_is_locked(&comp->mutex)); + dev_info(mei_kdev, "MEI HDCP comp unbind\n"); + comp->ops = NULL; + comp->dev = NULL; + comp->mei_cldev = NULL; +} + +static const struct component_ops mei_hdcp_component_bind_ops = { + .bind = mei_hdcp_component_bind, + .unbind = mei_hdcp_component_unbind, +}; + +void mei_hdcp_component_init(struct device *dev) +{ + int ret; + + ret = component_add(dev, &mei_hdcp_component_bind_ops); + if (ret < 0) { + dev_err(dev, "Failed to add MEI HDCP comp (%d)\n", ret); + return; + } + + mei_hdcp_component_registered = true; +} + +void mei_hdcp_component_cleanup(struct device *dev) +{ + if (!mei_hdcp_component_registered) + return; + + component_del(dev, &mei_hdcp_component_bind_ops); + mei_hdcp_component_registered = false; +} static int mei_hdcp_probe(struct mei_cl_device *cldev, const struct mei_cl_device_id *id) @@ -38,15 +115,28 @@ static int mei_hdcp_probe(struct mei_cl_device *cldev, int ret; ret = mei_cldev_enable(cldev); - if (ret < 0) + if (ret < 0) { dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret); + return ret; + } - return ret; + mei_cldev = cldev; + mei_hdcp_component_init(&cldev->dev); + return 0; } static int mei_hdcp_remove(struct mei_cl_device *cldev) { + struct i915_hdcp_component *comp; + + comp = mei_cldev_get_drvdata(cldev); + if (comp && comp->master_ops && comp->master_ops->pull_down_interface) + comp->master_ops->pull_down_interface(comp->i915_kdev); + + mei_cldev = NULL; mei_cldev_set_drvdata(cldev, NULL); + mei_hdcp_component_cleanup(&cldev->dev); + return mei_cldev_disable(cldev); }