From patchwork Wed Jul 12 08:28:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 9836273 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 9C97B60393 for ; Wed, 12 Jul 2017 08:30:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F78C1FF2D for ; Wed, 12 Jul 2017 08:30:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8448E284FF; Wed, 12 Jul 2017 08:30:47 +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=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 2E01F1FF2D for ; Wed, 12 Jul 2017 08:30:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 58EB36E3DB; Wed, 12 Jul 2017 08:29:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 72F4F6E3D9; Wed, 12 Jul 2017 08:29:50 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2017 01:29:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,349,1496127600"; d="scan'208";a="126135092" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by fmsmga006.fm.intel.com with ESMTP; 12 Jul 2017 01:29:47 -0700 From: Ramalingam C To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@intel.com Date: Wed, 12 Jul 2017 13:58:56 +0530 Message-Id: <1499848144-8456-13-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499848144-8456-1-git-send-email-ramalingam.c@intel.com> References: <1499848144-8456-1-git-send-email-ramalingam.c@intel.com> Subject: [Intel-gfx] [RFC v1 12/20] drm/hdcp: Atomic set and get property for hdcp X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 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 Atomic ioctl request is pruned based on the platform and panel's HDCP capabilities along with current state of HDCP protection on the connector. Valid enable and disable requests are passed on to the HDCP stack. get_property also updated with current state of the HDCP on connector. Signed-off-by: Ramalingam C --- drivers/gpu/drm/drm_atomic.c | 5 +++++ drivers/gpu/drm/drm_hdcp.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_hdcp.h | 1 + 3 files changed, 59 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 09ca662..9d4af3b 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "drm_crtc_internal.h" @@ -1188,6 +1189,8 @@ int drm_atomic_connector_set_property(struct drm_connector *connector, */ if (state->link_status != DRM_LINK_STATUS_GOOD) state->link_status = val; + } else if (property == config->hdcp_property) { + return drm_hdcp_set_property(connector, val); } else if (property == config->aspect_ratio_property) { state->picture_aspect_ratio = val; } else if (property == connector->scaling_mode_property) { @@ -1268,6 +1271,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->tv.hue; } else if (property == config->link_status_property) { *val = state->link_status; + } else if (property == config->hdcp_property) { + *val = connector->hdcp_state; } else if (property == config->aspect_ratio_property) { *val = state->picture_aspect_ratio; } else if (property == connector->scaling_mode_property) { diff --git a/drivers/gpu/drm/drm_hdcp.c b/drivers/gpu/drm/drm_hdcp.c index 89c7c5e..9b3bf92 100644 --- a/drivers/gpu/drm/drm_hdcp.c +++ b/drivers/gpu/drm/drm_hdcp.c @@ -69,6 +69,59 @@ int drm_hdcp_disable(struct drm_connector *connector) return 0; } + +/** + * @drm_hdcp_set_property: + * + * Entry function for hdcp_enable and hdcp_disable. + */ +int drm_hdcp_set_property(struct drm_connector *connector, + uint64_t req_state) +{ + struct drm_hdcp *hdcp = connector->hdcp; + uint64_t cur_state = connector->hdcp_state; + uint8_t stream_type; + + if (connector->status != connector_status_connected) + return -EINVAL; + + if (!hdcp) + return -EINVAL; + + DRM_DEBUG("Prop_val: Current : 0x%llx, Request: 0x%llx\n", + cur_state, req_state); + + if (!(cur_state & DRM_HDCP_VER_SUPPORT_MASK)) { + DRM_ERROR("None of the HDCP Ver is supported\n"); + return -EINVAL; + } + + if ((cur_state & DRM_HDCP_ENABLE) == + (req_state & DRM_HDCP_ENABLE)) { + DRM_DEBUG("Req for current state is redundant\n"); + return -EINVAL; + } + + if (!(cur_state & DRM_HDCP2_SUPPORTED) && + req_state & DRM_HDCP_TYPE_BIT0) { + DRM_ERROR("Type 1 HDCP is not available\n"); + return -EINVAL; + } + + if (cur_state & DRM_HDCP_WIP) + return -EBUSY; + + if (req_state & DRM_HDCP_ENABLE) { + stream_type = (req_state & DRM_HDCP_TYPE_MASK) >> + DRM_HDCP_TYPE_SHIFT; + return drm_hdcp_enable(connector, stream_type); + } else { + drm_hdcp_disable(connector); + } + + return 0; +} + void drm_hdcp_late_init(struct drm_connector *connector) { struct drm_hdcp *hdcp = connector->hdcp; diff --git a/include/drm/drm_hdcp.h b/include/drm/drm_hdcp.h index 89879ff..eb7149b 100644 --- a/include/drm/drm_hdcp.h +++ b/include/drm/drm_hdcp.h @@ -169,5 +169,6 @@ extern int drm_hdcp_init(struct drm_connector *connector, uint8_t spec_supported); extern void drm_hdcp_connector_state_change_handler( struct drm_connector *connector); +int drm_hdcp_set_property(struct drm_connector *connector, uint64_t val); #endif /* __DRM_HDCP_H__ */