From patchwork Tue Apr 3 13:57:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10321205 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 E00D360532 for ; Tue, 3 Apr 2018 14:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D263C28C05 for ; Tue, 3 Apr 2018 14:11:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D102928C08; Tue, 3 Apr 2018 14:11:48 +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=-4.2 required=2.0 tests=BAYES_00, 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 EEB2228D88 for ; Tue, 3 Apr 2018 14:10:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 92EB86E513; Tue, 3 Apr 2018 14:08:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 026136E4F7; Tue, 3 Apr 2018 14:08:53 +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 fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 07:05:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,401,1517904000"; d="scan'208";a="30680932" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga008.jf.intel.com with ESMTP; 03 Apr 2018 07:05:01 -0700 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, seanpaul@chromium.org, daniel@ffwll.ch, chris@chris-wilson.co.uk, jani.nikula@linux.intel.com, tomas.winkler@intel.com, alexander.usyskin@intel.com Subject: [PATCH v3 22/40] drm/i915: Wrappers for mei HDCP2.2 services Date: Tue, 3 Apr 2018 19:27:35 +0530 Message-Id: <1522763873-23041-23-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522763873-23041-1-git-send-email-ramalingam.c@intel.com> References: <1522763873-23041-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: rodrigo.vivi@intel.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adds the wrapper for all mei hdcp2.2 service functions. v2: Rebased. v3: cldev is moved from mei_hdcp_data to hdcp. Signed-off-by: Ramalingam C --- drivers/gpu/drm/i915/intel_hdcp.c | 194 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c index 1cca4f349064..b4d56b21cf9b 100644 --- a/drivers/gpu/drm/i915/intel_hdcp.c +++ b/drivers/gpu/drm/i915/intel_hdcp.c @@ -10,10 +10,13 @@ #include #include #include +#include #include "intel_drv.h" #include "i915_reg.h" +#define GET_MEI_DDI_INDEX(port) (((port) == PORT_A) ? DDI_A : \ + (enum hdcp_physical_port) (port)) #define KEY_LOAD_TRIES 5 static int intel_hdcp_poll_ksv_fifo(struct intel_digital_port *intel_dig_port, @@ -817,3 +820,194 @@ int intel_hdcp_check_link(struct intel_connector *connector) mutex_unlock(&hdcp->hdcp_mutex); return ret; } + +static int +hdcp2_prepare_ake_init(struct intel_hdcp *hdcp, struct hdcp2_ake_init *ake_data) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + struct intel_connector *connector = container_of(hdcp, + struct intel_connector, + hdcp); + + if (!hdcp->cldev) + return -EINVAL; + + if (data->port == INVALID_PORT && connector->encoder) + data->port = GET_MEI_DDI_INDEX(connector->encoder->port); + + /* Clear ME FW instance for the port, just incase */ + mei_close_hdcp_session(hdcp->cldev, data); + + return mei_initiate_hdcp2_session(hdcp->cldev, data, ake_data); +} + +static int hdcp2_close_mei_session(struct intel_hdcp *hdcp) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + + if (!hdcp->cldev || data->port == INVALID_PORT) + return -EINVAL; + + return mei_close_hdcp_session(hdcp->cldev, data); +} + +static int +hdcp2_verify_rx_cert_prepare_km(struct intel_hdcp *hdcp, + struct hdcp2_ake_send_cert *rx_cert, + bool *paired, + struct hdcp2_ake_no_stored_km *ek_pub_km, + size_t *msg_sz) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_verify_receiver_cert_prepare_km(hdcp->cldev, data, rx_cert, + paired, ek_pub_km, msg_sz); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static int hdcp2_verify_hprime(struct intel_hdcp *hdcp, + struct hdcp2_ake_send_hprime *rx_hprime) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_verify_hprime(hdcp->cldev, data, rx_hprime); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static int +hdcp2_store_paring_info(struct intel_hdcp *hdcp, + struct hdcp2_ake_send_pairing_info *pairing_info) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_store_pairing_info(hdcp->cldev, data, pairing_info); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static int +hdcp2_prepare_lc_init(struct intel_hdcp *hdcp, struct hdcp2_lc_init *lc_init) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_initiate_locality_check(hdcp->cldev, data, lc_init); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static int +hdcp2_verify_lprime(struct intel_hdcp *hdcp, + struct hdcp2_lc_send_lprime *rx_lprime) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_verify_lprime(hdcp->cldev, data, rx_lprime); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static int hdcp2_prepare_skey(struct intel_hdcp *hdcp, + struct hdcp2_ske_send_eks *ske_data) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_get_session_key(hdcp->cldev, data, ske_data); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static int +hdcp2_verify_rep_topology_prepare_ack( + struct intel_hdcp *hdcp, + struct hdcp2_rep_send_receiverid_list *rep_topology, + struct hdcp2_rep_send_ack *rep_send_ack) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_repeater_check_flow_prepare_ack(hdcp->cldev, data, + rep_topology, rep_send_ack); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static int +hdcp2_verify_mprime(struct intel_hdcp *hdcp, + struct hdcp2_rep_stream_ready *stream_ready) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_verify_mprime(hdcp->cldev, data, stream_ready); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + + +static int hdcp2_authenticate_port(struct intel_hdcp *hdcp) +{ + struct mei_hdcp_data *data = &hdcp->mei_data; + int ret; + + if (!hdcp->cldev) + return -EINVAL; + + ret = mei_enable_hdcp_authentication(hdcp->cldev, data); + if (ret < 0) + mei_close_hdcp_session(hdcp->cldev, data); + + return ret; +} + +static inline int hdcp2_deauthenticate_port(struct intel_hdcp *hdcp) +{ + return hdcp2_close_mei_session(hdcp); +}