From patchwork Fri Mar 29 02:39:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 2360481 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) by patchwork2.kernel.org (Postfix) with ESMTP id 81DC4DF2A1 for ; Fri, 29 Mar 2013 02:46:51 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [IPv6:::1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 641D3B00; Fri, 29 Mar 2013 02:45:44 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTP id 982E58A9 for ; Fri, 29 Mar 2013 02:45:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kirsty.vergenet.net (kirsty.vergenet.net [202.4.237.240]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id D24E12018B for ; Fri, 29 Mar 2013 02:45:36 +0000 (UTC) Received: from ayumi.akashicho.tokyo.vergenet.net (p8120-ipbfp1001kobeminato.hyogo.ocn.ne.jp [118.10.137.120]) by kirsty.vergenet.net (Postfix) with ESMTP id 2B7F6267177; Fri, 29 Mar 2013 13:45:32 +1100 (EST) Received: by ayumi.akashicho.tokyo.vergenet.net (Postfix, from userid 7100) id B33FFEDEA28; Fri, 29 Mar 2013 11:45:29 +0900 (JST) From: Simon Horman To: ltsi-dev@lists.linuxfoundation.org Date: Fri, 29 Mar 2013 11:39:28 +0900 Message-Id: <1364525119-31791-40-git-send-email-horms+renesas@verge.net.au> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364525119-31791-1-git-send-email-horms+renesas@verge.net.au> References: <1364525119-31791-1-git-send-email-horms+renesas@verge.net.au> X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Magnus Damm Subject: [LTSI-dev] [PATCH/RFC 039/390] drm: make the connector properties code use the object properties code X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org From: Paulo Zanoni In the future, we may want to kill the internal functions: - drm_connector_attach_property - drm_connector_property_set_value - drm_connector_property_get_value It seems the IOCTL drm_mode_connector_property_set_ioctl will have to live, but we may change libdrm to not use it anymore, if we want. Reviewed-by: Eugeni Dodonov Reviewed-by: Rob Clark Tested-by: Rob Clark Signed-off-by: Paulo Zanoni Signed-off-by: Dave Airlie (cherry picked from commit 0057d8dd8d378bf88f75736496d779f3c9454b5f) Signed-off-by: Simon Horman --- drivers/gpu/drm/drm_crtc.c | 98 ++++++-------------------------------------- 1 file changed, 12 insertions(+), 86 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 103a40c..7bed4a5 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2823,55 +2823,21 @@ EXPORT_SYMBOL(drm_property_destroy); void drm_connector_attach_property(struct drm_connector *connector, struct drm_property *property, uint64_t init_val) { - int i; - - for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { - if (connector->properties.ids[i] == 0) { - connector->properties.ids[i] = property->base.id; - connector->properties.values[i] = init_val; - return; - } - } - - WARN(1, "Failed to attach connector property. Please increase " - "DRM_OBJECT_MAX_PROPERTY by 1 for each time you see this " - "message\n"); + drm_object_attach_property(&connector->base, property, init_val); } EXPORT_SYMBOL(drm_connector_attach_property); int drm_connector_property_set_value(struct drm_connector *connector, struct drm_property *property, uint64_t value) { - int i; - - for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { - if (connector->properties.ids[i] == property->base.id) { - connector->properties.values[i] = value; - break; - } - } - - if (i == DRM_OBJECT_MAX_PROPERTY) - return -EINVAL; - return 0; + return drm_object_property_set_value(&connector->base, property, value); } EXPORT_SYMBOL(drm_connector_property_set_value); int drm_connector_property_get_value(struct drm_connector *connector, struct drm_property *property, uint64_t *val) { - int i; - - for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { - if (connector->properties.ids[i] == property->base.id) { - *val = connector->properties.values[i]; - break; - } - } - - if (i == DRM_OBJECT_MAX_PROPERTY) - return -EINVAL; - return 0; + return drm_object_property_get_value(&connector->base, property, val); } EXPORT_SYMBOL(drm_connector_property_get_value); @@ -3148,56 +3114,16 @@ static bool drm_property_change_is_valid(struct drm_property *property, int drm_mode_connector_property_set_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - struct drm_mode_connector_set_property *out_resp = data; - struct drm_mode_object *obj; - struct drm_property *property; - struct drm_connector *connector; - int ret = -EINVAL; - int i; - - if (!drm_core_check_feature(dev, DRIVER_MODESET)) - return -EINVAL; - - mutex_lock(&dev->mode_config.mutex); - - obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR); - if (!obj) { - goto out; - } - connector = obj_to_connector(obj); - - for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { - if (connector->properties.ids[i] == out_resp->prop_id) - break; - } - - if (i == DRM_OBJECT_MAX_PROPERTY) { - goto out; - } - - obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY); - if (!obj) { - goto out; - } - property = obj_to_property(obj); + struct drm_mode_connector_set_property *conn_set_prop = data; + struct drm_mode_obj_set_property obj_set_prop = { + .value = conn_set_prop->value, + .prop_id = conn_set_prop->prop_id, + .obj_id = conn_set_prop->connector_id, + .obj_type = DRM_MODE_OBJECT_CONNECTOR + }; - if (!drm_property_change_is_valid(property, out_resp->value)) - goto out; - - /* Do DPMS ourselves */ - if (property == connector->dev->mode_config.dpms_property) { - if (connector->funcs->dpms) - (*connector->funcs->dpms)(connector, (int) out_resp->value); - ret = 0; - } else if (connector->funcs->set_property) - ret = connector->funcs->set_property(connector, property, out_resp->value); - - /* store the property value if successful */ - if (!ret) - drm_connector_property_set_value(connector, property, out_resp->value); -out: - mutex_unlock(&dev->mode_config.mutex); - return ret; + /* It does all the locking and checking we need */ + return drm_mode_obj_set_property_ioctl(dev, &obj_set_prop, file_priv); } static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,