From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilija Hadzic Subject: [PATCH 03/19] drm: use drm_mode_group in drm_mode_getplane_res Date: Thu, 12 Apr 2012 14:19:28 -0400 Message-ID: <1334254784-3200-4-git-send-email-ihadzic@research.bell-labs.com> References: <1334254784-3200-1-git-send-email-ihadzic@research.bell-labs.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from ihemail4.lucent.com (ihemail4.lucent.com [135.245.0.39]) by gabe.freedesktop.org (Postfix) with ESMTP id C15C9A0AA4 for ; Thu, 12 Apr 2012 11:20:46 -0700 (PDT) Received: from usnavsmail2.ndc.alcatel-lucent.com (usnavsmail2.ndc.alcatel-lucent.com [135.3.39.10]) by ihemail4.lucent.com (8.13.8/IER-o) with ESMTP id q3CIKjM6027615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Apr 2012 13:20:45 -0500 (CDT) Received: from umail.lucent.com (umail-ce2.ndc.lucent.com [135.3.40.63]) by usnavsmail2.ndc.alcatel-lucent.com (8.14.3/8.14.3/GMO) with ESMTP id q3CIKiig009639 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 12 Apr 2012 13:20:44 -0500 In-Reply-To: <1334254784-3200-1-git-send-email-ihadzic@research.bell-labs.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org drm_mode_group structure now tracks planes, so use it in in drm_mode_getplane_res(ources) IOCTL. Signed-off-by: Ilija Hadzic --- drivers/gpu/drm/drm_crtc.c | 46 +++++++++++++++++++++++++++++++++---------- 1 files changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 29ede0a..eafb49d 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1564,7 +1564,6 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_mode_get_plane_res *plane_resp = data; - struct drm_mode_config *config; struct drm_plane *plane; uint32_t __user *plane_ptr; int copied = 0, ret = 0; @@ -1573,25 +1572,50 @@ int drm_mode_getplane_res(struct drm_device *dev, void *data, return -EINVAL; mutex_lock(&dev->mode_config.mutex); - config = &dev->mode_config; /* * This ioctl is called twice, once to determine how much space is * needed, and the 2nd time to fill it. */ - if (config->num_plane && - (plane_resp->count_planes >= config->num_plane)) { - plane_ptr = (uint32_t __user *)(unsigned long)plane_resp->plane_id_ptr; + plane_ptr = (uint32_t __user *)(unsigned long)plane_resp->plane_id_ptr; + if (file_priv->minor->type == DRM_MINOR_CONTROL) { + struct drm_mode_config *config = &dev->mode_config; - list_for_each_entry(plane, &config->plane_list, head) { - if (put_user(plane->base.id, plane_ptr + copied)) { - ret = -EFAULT; - goto out; + if (config->num_plane && + (plane_resp->count_planes >= config->num_plane)) { + list_for_each_entry(plane, &config->plane_list, head) { + if (put_user(plane->base.id, + plane_ptr + copied)) { + ret = -EFAULT; + goto out; + } + copied++; + } + } + plane_resp->count_planes = config->num_plane; + } else { + int i; + struct drm_mode_group *mode_group = + &file_priv->minor->mode_group; + + if (mode_group->num_planes && + (plane_resp->count_planes >= mode_group->num_planes)) { + int start; + + start = mode_group->num_crtcs; + start += mode_group->num_encoders; + start += mode_group->num_connectors; + for (i = start; i < start + mode_group->num_planes; i++) { + if (put_user(mode_group->id_list[i], + plane_ptr + copied)) { + ret = -EFAULT; + goto out; + } + copied++; } - copied++; } + plane_resp->count_planes = mode_group->num_planes; } - plane_resp->count_planes = config->num_plane; out: mutex_unlock(&dev->mode_config.mutex); -- 1.7.8.5