Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp833181ybh; Thu, 12 Mar 2020 11:58:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs7gcaZIeZLsc9H6BEGELeBlX59ekqB7+YFwxfbuB0TCmZUB+jyBOfD8pzHt4jTS5hPsH2K X-Received: by 2002:aca:f4d0:: with SMTP id s199mr3925723oih.109.1584039491539; Thu, 12 Mar 2020 11:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584039491; cv=none; d=google.com; s=arc-20160816; b=FWmbedbC4YuUAo9l5ZcS/u9FgY/CE4eveEWDd7aPUUiBNi2kO/ZDnk29+jKmuQYJwv 8aNf2ZB79HssEhYPZ6rlZlE+hTLYQIt8WhTy87m9ktkcFta7ILHlEHxLHxV+fclf0+Qk 5BFSA+ya1SggtwlpmqaaUSG+bkbraeY4wLbPUXbpoQw2uJGi7awV1hiZ/S/+3+0U3e9c z9E0AJ7/ZX2+NEHE6wlo6VyYA8ONbMUbF8m8E4z0XfAIoGKs4fc2dkzzVvC7z5Zcxr4s Xw1/TYAwQrFdPlItP7lkyAXcRX0z41VxCZm0H5FIWL6HPiFsnCVmu4L081UCA7BxuAB7 xAtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=fb+o65Uot0J8uKJF0VIG4K45eAKvXITiVF9xtLDLePk=; b=0FUODW9vqMJLxDuDxEsprSkuqmWWeycBiXKQhoL/himBlAOpyL43UD6lgPQPBtuIal eg/fBY7viPEdlbCtwWyT79oE+W+ur+99nAU3no60As84RLpTFWn2ol96IGjUxhJc9YCy CjTXR/cpkLxm4nkdPhHbzmdLMj8is7/wdcuVOb3MhQXOOFpImvA7QXLIL6l4diC0uK7F ThE2rvCEGcDN2DdnCEpoLh4HWh3rMkGIep6KzCokukrGxv/Lu/o53ApFKzCLC4Jrjkk+ xMqRTAuHnd42bU5YVD2HuU0qMZW+NG3XMx/eKRQBsYp8eLuO4wJxFBwAkdAsA3ReOg4B er7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TDDm2qev; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d201si2808739oib.1.2020.03.12.11.57.59; Thu, 12 Mar 2020 11:58:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TDDm2qev; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbgCLS4n (ORCPT + 99 others); Thu, 12 Mar 2020 14:56:43 -0400 Received: from mail-pj1-f74.google.com ([209.85.216.74]:51059 "EHLO mail-pj1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbgCLS4l (ORCPT ); Thu, 12 Mar 2020 14:56:41 -0400 Received: by mail-pj1-f74.google.com with SMTP id na17so3817387pjb.0 for ; Thu, 12 Mar 2020 11:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=fb+o65Uot0J8uKJF0VIG4K45eAKvXITiVF9xtLDLePk=; b=TDDm2qevwFX9GxIUmGOA/T9YmUiTAfhfF+Pn5w3zUMH3htOEfnTc/sZVwhxxas1N5/ xwLUIIZ9d+6lSSfzIbW/H4v8vukxyzLTYud+FF0Jwpd5RZSYYysfKrce7s8MSYRgZYnl ka9K8ueBHqyRxJwaIKZKT0UrhhSOmna7xLVJdNGYJUslcPC0QhROXXs8C9OGAevwQZB2 qEEqp2vFcwDnagGzDZ5JfpHPx2KW8P96cekkfvJDMsMMz9YpDrOuUuNumZ8KqTDtUEJt RcsB+7JXR+tenFPv5KKvwktko0k8Jxzf/kbfr7PtGeyfUrfqrCbchftFHA+KtpKyXuEA KwSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fb+o65Uot0J8uKJF0VIG4K45eAKvXITiVF9xtLDLePk=; b=Sb27B/477fXYMF7OnOgt7XUTH31/aEqgC8qygX1qOcg36W451gNvVI/6j7+hXUIFQY 09pDkmlkydiLI1zVgDwTXGmohZXHx/lgydu9pE+CINkWn/YiipEzvVHfku5RDxyASpIN jJm4Vbf4wjc2W5ytguQ9klIF+DqXotQuEUs3ehknrZCwh7kN1kNkNzKBQ8CrVQNYLPY2 KxOQpvLF2sfSzzGy8ecNJzD5aVaPIsFLB4NOFnqJQnrR4Js0qtxRnNfz/0tzVn18a7hU dHSqYKST8epZF3EnDrWO9A5adLKLljYRYxj+oWBg/754SgQoD3b4qOlsQ5Xyem8wy0Gn 6f7w== X-Gm-Message-State: ANhLgQ2ZbWCOKG/gDIj9Xqh6iVFdZ6wXanp7jzWA0iwzdV55RfCwMC+a ReTspIyZN5T2fe2MvIrvRPrzFGiduJew X-Received: by 2002:a17:90a:1f8d:: with SMTP id x13mr5635664pja.27.1584039399008; Thu, 12 Mar 2020 11:56:39 -0700 (PDT) Date: Thu, 12 Mar 2020 11:56:26 -0700 In-Reply-To: <20200312185629.141280-1-rajatja@google.com> Message-Id: <20200312185629.141280-3-rajatja@google.com> Mime-Version: 1.0 References: <20200312185629.141280-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog Subject: [PATCH v9 2/5] drm/connector: Add support for privacy-screen property From: Rajat Jain To: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , "=?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?=" , Chris Wilson , Imre Deak , "=?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?=" , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org, mathewk@google.com, Daniel Thompson , Jonathan Corbet , Pavel Machek , seanpaul@google.com, Duncan Laurie , jsbarnes@google.com, Thierry Reding , mpearson@lenovo.com, Nitin Joshi1 , Sugumaran Lacshiminarayanan , Tomoki Maruichi Cc: Rajat Jain , rajatxjain@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for generic electronic privacy screen property, that can be added by systems that have an integrated EPS. Signed-off-by: Rajat Jain --- v9: rebased on top of https://cgit.freedesktop.org/drm/drm-tip:drm-tip v8: Remove the ...destroy_privacy_screen() method and let the property be destroyed along with others at the time of device destruction. (because drm core doesn't also like properties destroyed in late_register()). v7: * Initial version, formed by moving the privacy-screen property into drm core. * Break the init_property() into create_property() and attach_property() so that property can be created while registering connector, but attached in late_register() (after ACPI node detection). drivers/gpu/drm/drm_atomic_uapi.c | 4 +++ drivers/gpu/drm/drm_connector.c | 51 +++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 24 +++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index a1e5e262bae2d..843a8cdacd149 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -766,6 +766,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, fence_ptr); } else if (property == connector->max_bpc_property) { state->max_requested_bpc = val; + } else if (property == connector->privacy_screen_property) { + state->privacy_screen_status = val; } else if (connector->funcs->atomic_set_property) { return connector->funcs->atomic_set_property(connector, state, property, val); @@ -842,6 +844,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = 0; } else if (property == connector->max_bpc_property) { *val = state->max_requested_bpc; + } else if (property == connector->privacy_screen_property) { + *val = state->privacy_screen_status; } else if (connector->funcs->atomic_get_property) { return connector->funcs->atomic_get_property(connector, state, property, val); diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 644f0ad106717..182aa557962b2 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1186,6 +1186,10 @@ static const struct drm_prop_enum_list dp_colorspaces[] = { * can also expose this property to external outputs, in which case they * must support "None", which should be the default (since external screens * have a built-in scaler). + * + * privacy-screen: + * This optional property can be used to enable / disable an integrated + * electronic privacy screen that is available on some displays. */ int drm_connector_create_standard_properties(struct drm_device *dev) @@ -2152,6 +2156,53 @@ int drm_connector_set_panel_orientation_with_quirk( } EXPORT_SYMBOL(drm_connector_set_panel_orientation_with_quirk); +static const struct drm_prop_enum_list privacy_screen_enum[] = { + { PRIVACY_SCREEN_DISABLED, "Disabled" }, + { PRIVACY_SCREEN_ENABLED, "Enabled" }, +}; + +/** + * drm_connector_create_privacy_screen_property - + * create the drm connecter's privacy-screen property. + * @connector: connector for which to create the privacy-screen property + * + * This function creates the "privacy-screen" property for the + * connector. It is not attached. + */ +void +drm_connector_create_privacy_screen_property(struct drm_connector *connector) +{ + if (connector->privacy_screen_property) + return; + + connector->privacy_screen_property = + drm_property_create_enum(connector->dev, DRM_MODE_PROP_ENUM, + "privacy-screen", privacy_screen_enum, + ARRAY_SIZE(privacy_screen_enum)); +} +EXPORT_SYMBOL(drm_connector_create_privacy_screen_property); + +/** + * drm_connector_attach_privacy_screen_property - + * attach the drm connecter's privacy-screen property. + * @connector: connector on which to attach the privacy-screen property + * + * This function attaches the "privacy-screen" property to the + * connector. Initial state of privacy-screen is set to disabled. + */ +void +drm_connector_attach_privacy_screen_property(struct drm_connector *connector) +{ + struct drm_property *prop = connector->privacy_screen_property; + + if (!prop) + return; + + drm_object_attach_property(&connector->base, prop, + PRIVACY_SCREEN_DISABLED); +} +EXPORT_SYMBOL(drm_connector_attach_privacy_screen_property); + int drm_connector_set_obj_prop(struct drm_mode_object *obj, struct drm_property *property, uint64_t value) diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 19ae6bb5c85be..f9ce89cc13542 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -271,6 +271,20 @@ struct drm_monitor_range_info { u8 max_vfreq; }; +/** + * enum drm_privacy_screen_status - privacy screen status + * + * This enum is used to track and control the state of the integrated privacy + * screen present on some display panels, via the "privacy-screen" property. + * + * @PRIVACY_SCREEN_DISABLED: The privacy-screen on the panel is disabled + * @PRIVACY_SCREEN_ENABLED: The privacy-screen on the panel is enabled + **/ +enum drm_privacy_screen_status { + PRIVACY_SCREEN_DISABLED = 0, + PRIVACY_SCREEN_ENABLED = 1, +}; + /* * This is a consolidated colorimetry list supported by HDMI and * DP protocol standard. The respective connectors will register @@ -686,6 +700,8 @@ struct drm_connector_state { */ u8 max_bpc; + enum drm_privacy_screen_status privacy_screen_status; + /** * @hdr_output_metadata: * DRM blob property for HDR output metadata @@ -1285,6 +1301,12 @@ struct drm_connector { */ struct drm_property *max_bpc_property; + /** + * @privacy_screen_property: Optional property for the connector to + * control the integrated privacy screen, if available. + */ + struct drm_property *privacy_screen_property; + #define DRM_CONNECTOR_POLL_HPD (1 << 0) #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) @@ -1598,6 +1620,8 @@ int drm_connector_set_panel_orientation_with_quirk( int width, int height); int drm_connector_attach_max_bpc_property(struct drm_connector *connector, int min, int max); +void drm_connector_create_privacy_screen_property(struct drm_connector *conn); +void drm_connector_attach_privacy_screen_property(struct drm_connector *conn); /** * struct drm_tile_group - Tile group metadata -- 2.25.1.481.gfbce0eb801-goog