From patchwork Tue Nov 27 10:43:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10700219 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 4330117F0 for ; Tue, 27 Nov 2018 10:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 330E12AABF for ; Tue, 27 Nov 2018 10:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 279EE2AAC7; Tue, 27 Nov 2018 10:48:55 +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 C24BF2AAC4 for ; Tue, 27 Nov 2018 10:48:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 894816E139; Tue, 27 Nov 2018 10:48:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 379DB897E3; Tue, 27 Nov 2018 10:48:30 +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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2018 02:48:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,286,1539673200"; d="scan'208";a="95578086" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga008.jf.intel.com with ESMTP; 27 Nov 2018 02:48:27 -0800 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, tomas.winkler@intel.com Subject: [PATCH v8 31/35] misc/mei/hdcp: Component framework for I915 Interface Date: Tue, 27 Nov 2018 16:13:29 +0530 Message-Id: <1543315413-24302-32-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543315413-24302-1-git-send-email-ramalingam.c@intel.com> References: <1543315413-24302-1-git-send-email-ramalingam.c@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: uma.shankar@intel.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: Adjust to the new mei-i915 interface. Signed-off-by: Ramalingam C Reviewed-by: Uma Shankar --- drivers/misc/mei/hdcp/mei_hdcp.c | 71 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c index 6e14e7cb49a5..1941b9783011 100644 --- a/drivers/misc/mei/hdcp/mei_hdcp.c +++ b/drivers/misc/mei/hdcp/mei_hdcp.c @@ -13,11 +13,14 @@ #include #include #include +#include #include #include #include "mei_hdcp.h" +static bool mei_hdcp_component_registered; + /* * mei_initiate_hdcp2_session: * Function to start a Wired HDCP2.2 Tx Session with ME FW @@ -705,8 +708,7 @@ static int mei_close_hdcp_session(struct device *dev, void *hdcp_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, @@ -721,20 +723,81 @@ struct i915_hdcp_component_ops mei_hdcp_ops = { .close_hdcp_session = mei_close_hdcp_session, }; +static int mei_hdcp_component_bind(struct device *mei_kdev, + struct device *i915_kdev, void *data) +{ + struct i915_hdcp_component_master *master_comp = data; + + mutex_lock(&master_comp->mutex); + dev_info(mei_kdev, "MEI HDCP comp bind\n"); + WARN_ON(master_comp->ops); + master_comp->ops = &mei_hdcp_ops; + master_comp->dev = mei_kdev; + mutex_unlock(&master_comp->mutex); + + return 0; +} + +static void mei_hdcp_component_unbind(struct device *mei_kdev, + struct device *i915_kdev, void *data) +{ + struct i915_hdcp_component_master *master_comp = data; + + mutex_lock(&master_comp->mutex); + dev_info(mei_kdev, "MEI HDCP comp unbind\n"); + master_comp->ops = NULL; + master_comp->dev = NULL; + mutex_unlock(&master_comp->mutex); +} + +static const struct component_ops mei_hdcp_component_bind_ops = { + .bind = mei_hdcp_component_bind, + .unbind = mei_hdcp_component_unbind, +}; + +static void mei_hdcp_component_init(struct device *dev) +{ + int ret; + + dev_info(dev, "MEI HDCP comp init\n"); + 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; +} + +static void mei_hdcp_component_cleanup(struct device *dev) +{ + if (!mei_hdcp_component_registered) + return; + + dev_info(dev, "MEI HDCP comp cleanup\n"); + 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) { 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; + } + mei_hdcp_component_init(&cldev->dev); - return ret; + return 0; } static int mei_hdcp_remove(struct mei_cl_device *cldev) { + mei_hdcp_component_cleanup(&cldev->dev); + return mei_cldev_disable(cldev); }