From patchwork Fri Mar 28 00:44:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 3900391 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 19927BF549 for ; Fri, 28 Mar 2014 00:44:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48BC22017B for ; Fri, 28 Mar 2014 00:44:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2A44B202BE for ; Fri, 28 Mar 2014 00:44:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A21F6EB7E; Thu, 27 Mar 2014 17:44:26 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id A4A046EB74 for ; Thu, 27 Mar 2014 17:44:24 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 27 Mar 2014 17:44:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,746,1389772800"; d="scan'208";a="501364190" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.215]) by fmsmga001.fm.intel.com with ESMTP; 27 Mar 2014 17:44:24 -0700 Received: from mattrope by mdroper-hswdev with local (Exim 4.82) (envelope-from ) id 1WTKw7-0007yH-69; Thu, 27 Mar 2014 17:46:19 -0700 From: Matt Roper To: dri-devel@lists.freedesktop.org Subject: [PATCHv4 09/13] drm: Add plane max width/height properties Date: Thu, 27 Mar 2014 17:44:34 -0700 Message-Id: <1395967478-30549-10-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1395967478-30549-1-git-send-email-matthew.d.roper@intel.com> References: <1395967478-30549-1-git-send-email-matthew.d.roper@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some hardware has different size limits for different planes (e.g., sprites/overlays can't always be as large as the upper bound for the primary plane). Adding read-only plane properties allows userspace to check these limits. By default, mode_config.max_{width,height} are used for non-cursor planes and mode_config.cursor_{width,height} are used for cursors; drivers should override these defaults after calling plane_init, if necessary. Signed-off-by: Matt Roper --- drivers/gpu/drm/drm_crtc.c | 30 ++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 0c70101..24226de 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1028,6 +1028,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, enum drm_plane_type type) { int ret; + uint32_t maxwidth, maxheight; drm_modeset_lock_all(dev); @@ -1061,6 +1062,28 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, dev->mode_config.plane_type_property, plane->type); + /* + * Drivers may override default max width/height after calling + * plane_init. + */ + if (plane->type == DRM_PLANE_TYPE_CURSOR) { + maxwidth = dev->mode_config.cursor_width; + if (!maxwidth) + maxwidth = 64; + maxheight = dev->mode_config.cursor_height; + if (!maxheight) + maxheight = 64; + } else { + maxwidth = dev->mode_config.max_width; + maxheight = dev->mode_config.max_height; + } + drm_object_attach_property(&plane->base, + dev->mode_config.plane_maxwidth_property, + maxwidth); + drm_object_attach_property(&plane->base, + dev->mode_config.plane_maxheight_property, + maxheight); + out: drm_modeset_unlock_all(dev); @@ -1175,6 +1198,7 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev) static int drm_mode_create_standard_plane_properties(struct drm_device *dev) { struct drm_property *type; + struct drm_property *maxwidth, *maxheight; /* * Standard properties (apply to all planes) @@ -1182,7 +1206,13 @@ static int drm_mode_create_standard_plane_properties(struct drm_device *dev) type = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, "type", drm_plane_type_enum_list, ARRAY_SIZE(drm_plane_type_enum_list)); + maxwidth = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, + "max width", 1, INT_MAX); + maxheight = drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, + "max height", 1, INT_MAX); dev->mode_config.plane_type_property = type; + dev->mode_config.plane_maxwidth_property = maxwidth; + dev->mode_config.plane_maxheight_property = maxheight; return 0; } diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 4c4f792..78cf825 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -772,6 +772,8 @@ struct drm_mode_config { struct drm_property *edid_property; struct drm_property *dpms_property; struct drm_property *plane_type_property; + struct drm_property *plane_maxwidth_property; + struct drm_property *plane_maxheight_property; /* DVI-I properties */ struct drm_property *dvi_i_subconnector_property;