From patchwork Wed Aug 31 16:09:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9307425 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 BB9E060756 for ; Wed, 31 Aug 2016 16:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD29F28FA0 for ; Wed, 31 Aug 2016 16:09:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A249528FA2; Wed, 31 Aug 2016 16:09:30 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 91F0628FA1 for ; Wed, 31 Aug 2016 16:09:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D0F06E1D7; Wed, 31 Aug 2016 16:09:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 013FE6E7A0 for ; Wed, 31 Aug 2016 16:09:22 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id w207so4089783wmw.0 for ; Wed, 31 Aug 2016 09:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uOm2rMNeRNDjpXF41qfslEzvshteZ8Izx3TKCauOBgo=; b=d0E6B8Vy9y34aNkDm1WPPGl/D+kzbZo+hCzRxZHPieGZEBdQXt50q9NU4crB0GbvbN ZZW/+xaBPpcZi9mqpMl5O/hbdbaTKJNiEcZZJatCf+Nw0CFXyHcByFqaua6sEK5QkoRR 9F8RtcU7oH+PfTBOGFl7eAZTNb4NVxC2GAexs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uOm2rMNeRNDjpXF41qfslEzvshteZ8Izx3TKCauOBgo=; b=Rs/4xrvvZevFiIkzwdCEK4fGI7v8MdeCQRAeLHXfqWtJDFpvPEnCXsce0ASQPSxYr/ 7VoEPwMc6Q8MxUeINyWYbnlh7uEgCM1654cf+Tf+j/fd3YsoqIJyNT7acXKVqQpqG8tM G+ZrshaiimnY5sUiQPgfHLFEdRYnDFxbvjo903hXt8CsdK03PaJkwRzjLZ5nfOa5SEY9 t5kxMa6SEns7c3Ih+J/GJgPLjyqQdAh/Dts5yLfgGza8HDI0Puxw46JEQesuMj0ZrZ0O uRlJElUUY5TvL2BH/G/qZCvmjAsFhi1dLXFnYJhBZMl/X8DVQrf8FnFmw1sHxzXgAxNA R3gw== X-Gm-Message-State: AE9vXwMSmRk7531lHffOey/ohUGQnLHbgH+9Q6bMKwtUZzX/An03lhdVnxThTmiNutsojw== X-Received: by 10.28.169.203 with SMTP id s194mr10652551wme.95.1472659761525; Wed, 31 Aug 2016 09:09:21 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56c9:0:decc:6e78:7e96:b452]) by smtp.gmail.com with ESMTPSA id b128sm24456537wmb.21.2016.08.31.09.09.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Aug 2016 09:09:20 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 01/10] drm: Move a few macros away from drm_crtc.h Date: Wed, 31 Aug 2016 18:09:04 +0200 Message-Id: <20160831160913.12991-2-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160831160913.12991-1-daniel.vetter@ffwll.ch> References: <20160831160913.12991-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Virus-Scanned: ClamAV using ClamSMTP Now that there's less stuff in there I noticed that I overlooked them. Sprinkle some docs over them while at it. Signed-off-by: Daniel Vetter Reviewed-by: Sean Paul --- include/drm/drm_connector.h | 24 ++++++++++++++++++++++-- include/drm/drm_crtc.h | 32 -------------------------------- include/drm/drm_encoder.h | 22 ++++++++++++++++++++++ include/drm/drm_framebuffer.h | 17 +++++++++++++++++ include/drm/drm_modes.h | 2 ++ include/drm/drm_property.h | 1 + 6 files changed, 64 insertions(+), 34 deletions(-) diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 66b7d6744dd2..e4e545e9516d 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -181,14 +181,19 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info, /** * struct drm_connector_state - mutable connector state * @connector: backpointer to the connector - * @crtc: CRTC to connect connector to, NULL if disabled * @best_encoder: can be used by helpers and drivers to select the encoder * @state: backpointer to global drm_atomic_state */ struct drm_connector_state { struct drm_connector *connector; - struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ + /** + * @crtc: CRTC to connect connector to, NULL if disabled. + * + * Do not change this directly, use drm_atomic_set_crtc_for_connector() + * instead. + */ + struct drm_crtc *crtc; struct drm_encoder *best_encoder; @@ -744,4 +749,19 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector, int drm_mode_connector_set_tile_property(struct drm_connector *connector); int drm_mode_connector_update_edid_property(struct drm_connector *connector, const struct edid *edid); + +/** + * drm_for_each_connector - iterate over all connectors + * @connector: the loop cursor + * @dev: the DRM device + * + * Iterate over all connectors of @dev. + */ +#define drm_for_each_connector(connector, dev) \ + for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \ + connector = list_first_entry(&(dev)->mode_config.connector_list, \ + struct drm_connector, head); \ + &connector->head != (&(dev)->mode_config.connector_list); \ + connector = list_next_entry(connector, head)) + #endif diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 4880606e2ffd..2a642ae96127 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1991,22 +1991,7 @@ struct drm_mode_config { list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \ for_each_if ((plane_mask) & (1 << drm_plane_index(plane))) -/** - * drm_for_each_encoder_mask - iterate over encoders specified by bitmask - * @encoder: the loop cursor - * @dev: the DRM device - * @encoder_mask: bitmask of encoder indices - * - * Iterate over all encoders specified by bitmask. - */ -#define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \ - list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \ - for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder))) - #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) -#define obj_to_mode(x) container_of(x, struct drm_display_mode, base) -#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) -#define obj_to_blob(x) container_of(x, struct drm_property_blob, base) #define obj_to_plane(x) container_of(x, struct drm_plane, base) extern __printf(6, 7) @@ -2174,23 +2159,6 @@ assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config) !drm_modeset_is_locked(&mode_config->connection_mutex)); } -#define drm_for_each_connector(connector, dev) \ - for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \ - connector = list_first_entry(&(dev)->mode_config.connector_list, \ - struct drm_connector, head); \ - &connector->head != (&(dev)->mode_config.connector_list); \ - connector = list_next_entry(connector, head)) - -#define drm_for_each_encoder(encoder, dev) \ - list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head) - -#define drm_for_each_fb(fb, dev) \ - for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \ - fb = list_first_entry(&(dev)->mode_config.fb_list, \ - struct drm_framebuffer, head); \ - &fb->head != (&(dev)->mode_config.fb_list); \ - fb = list_next_entry(fb, head)) - /* drm_edid.c */ bool drm_probe_ddc(struct i2c_adapter *adapter); struct edid *drm_get_edid(struct drm_connector *connector, diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h index fce0203094f7..387e33a4d6ee 100644 --- a/include/drm/drm_encoder.h +++ b/include/drm/drm_encoder.h @@ -224,4 +224,26 @@ static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev, void drm_encoder_cleanup(struct drm_encoder *encoder); +/** + * drm_for_each_encoder_mask - iterate over encoders specified by bitmask + * @encoder: the loop cursor + * @dev: the DRM device + * @encoder_mask: bitmask of encoder indices + * + * Iterate over all encoders specified by bitmask. + */ +#define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \ + list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \ + for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder))) + +/** + * drm_for_each_encoder - iterate over all encoders + * @encoder: the loop cursor + * @dev: the DRM device + * + * Iterate over all encoders of @dev. + */ +#define drm_for_each_encoder(encoder, dev) \ + list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head) + #endif diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h index b2554c50a903..f5ae1f436a4b 100644 --- a/include/drm/drm_framebuffer.h +++ b/include/drm/drm_framebuffer.h @@ -206,6 +206,8 @@ struct drm_framebuffer { struct list_head filp_head; }; +#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) + int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, const struct drm_framebuffer_funcs *funcs); @@ -247,4 +249,19 @@ static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb) { return atomic_read(&fb->base.refcount.refcount); } + +/** + * drm_for_each_fb - iterate over all framebuffers + * @fb: the loop cursor + * @dev: the DRM device + * + * Iterate over all framebuffers of @dev. User must hold the fb_lock from + * &drm_mode_config. + */ +#define drm_for_each_fb(fb, dev) \ + for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \ + fb = list_first_entry(&(dev)->mode_config.fb_list, \ + struct drm_framebuffer, head); \ + &fb->head != (&(dev)->mode_config.fb_list); \ + fb = list_next_entry(fb, head)) #endif diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h index 011f199d3bcf..986ed6ff635a 100644 --- a/include/drm/drm_modes.h +++ b/include/drm/drm_modes.h @@ -403,6 +403,8 @@ struct drm_display_mode { enum hdmi_picture_aspect picture_aspect_ratio; }; +#define obj_to_mode(x) container_of(x, struct drm_display_mode, base) + /** * drm_mode_is_stereo - check for stereo mode flags * @mode: drm_display_mode to check diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h index 30ab289be05d..43c4b6a2046d 100644 --- a/include/drm/drm_property.h +++ b/include/drm/drm_property.h @@ -219,6 +219,7 @@ struct drm_prop_enum_list { }; #define obj_to_property(x) container_of(x, struct drm_property, base) +#define obj_to_blob(x) container_of(x, struct drm_property_blob, base) /** * drm_property_type_is - check the type of a property