intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 44/76] drm/i915: extract modeset config save/restore code
Date: Thu, 26 Jul 2012 20:49:09 +0200	[thread overview]
Message-ID: <1343328581-2324-45-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1343328581-2324-1-git-send-email-daniel.vetter@ffwll.ch>

At the end this won't be of much use to us, but meanwhile just extract
it to get a better overview of what exactly set_config does.

Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/intel_display.c |  127 ++++++++++++++++++++--------------
 1 file changed, 76 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index c5c3078..2e5edc7 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6660,11 +6660,82 @@ static void intel_set_config_free(struct intel_set_config *config)
 	kfree(config);
 }
 
+static int intel_set_config_save_state(struct drm_device *dev,
+				       struct intel_set_config *config)
+{
+	struct drm_crtc *crtc;
+	struct drm_encoder *encoder;
+	struct drm_connector *connector;
+	int count;
+
+	/* Allocate space for the backup of all (non-pointer) crtc, encoder and
+	 * connector data. */
+	config->save_crtcs = kzalloc(dev->mode_config.num_crtc *
+				     sizeof(struct drm_crtc), GFP_KERNEL);
+	if (!config->save_crtcs)
+		return -ENOMEM;
+
+	config->save_encoders = kzalloc(dev->mode_config.num_encoder *
+					sizeof(struct drm_encoder), GFP_KERNEL);
+	if (!config->save_encoders)
+		return -ENOMEM;
+
+	config->save_connectors = kzalloc(dev->mode_config.num_connector *
+					  sizeof(struct drm_connector), GFP_KERNEL);
+	if (!config->save_connectors)
+		return -ENOMEM;
+
+	/* Copy data. Note that driver private data is not affected.
+	 * Should anything bad happen only the expected state is
+	 * restored, not the drivers personal bookkeeping.
+	 */
+	count = 0;
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+		config->save_crtcs[count++] = *crtc;
+	}
+
+	count = 0;
+	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+		config->save_encoders[count++] = *encoder;
+	}
+
+	count = 0;
+	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		config->save_connectors[count++] = *connector;
+	}
+
+	return 0;
+}
+
+static void intel_set_config_restore_state(struct drm_device *dev,
+					   struct intel_set_config *config)
+{
+	struct drm_crtc *crtc;
+	struct drm_encoder *encoder;
+	struct drm_connector *connector;
+	int count;
+
+	count = 0;
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+		*crtc = config->save_crtcs[count++];
+	}
+
+	count = 0;
+	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+		*encoder = config->save_encoders[count++];
+	}
+
+	count = 0;
+	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		*connector = config->save_connectors[count++];
+	}
+}
+
 static int intel_crtc_set_config(struct drm_mode_set *set)
 {
 	struct drm_device *dev;
-	struct drm_crtc *new_crtc, *crtc;
-	struct drm_encoder *new_encoder, *encoder;
+	struct drm_crtc *new_crtc;
+	struct drm_encoder *new_encoder;
 	struct drm_framebuffer *old_fb = NULL;
 	bool mode_changed = false; /* if true do a full mode set */
 	bool fb_changed = false; /* if true and !mode_changed just do a flip */
@@ -6705,42 +6776,10 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
 	if (!config)
 		goto out_config;
 
-	/* Allocate space for the backup of all (non-pointer) crtc, encoder and
-	 * connector data. */
-	config->save_crtcs = kzalloc(dev->mode_config.num_crtc *
-				     sizeof(struct drm_crtc), GFP_KERNEL);
-	if (!config->save_crtcs)
-		goto out_config;
-
-	config->save_encoders = kzalloc(dev->mode_config.num_encoder *
-					sizeof(struct drm_encoder), GFP_KERNEL);
-	if (!config->save_encoders)
-		goto out_config;
-
-	config->save_connectors = kzalloc(dev->mode_config.num_connector *
-					  sizeof(struct drm_connector), GFP_KERNEL);
-	if (!config->save_connectors)
+	ret = intel_set_config_save_state(dev, config);
+	if (ret)
 		goto out_config;
 
-	/* Copy data. Note that driver private data is not affected.
-	 * Should anything bad happen only the expected state is
-	 * restored, not the drivers personal bookkeeping.
-	 */
-	count = 0;
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		config->save_crtcs[count++] = *crtc;
-	}
-
-	count = 0;
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
-		config->save_encoders[count++] = *encoder;
-	}
-
-	count = 0;
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-		config->save_connectors[count++] = *connector;
-	}
-
 	save_set.crtc = set->crtc;
 	save_set.mode = &set->crtc->mode;
 	save_set.x = set->crtc->x;
@@ -6879,21 +6918,7 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
 	return 0;
 
 fail:
-	/* Restore all previous data. */
-	count = 0;
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-		*crtc = config->save_crtcs[count++];
-	}
-
-	count = 0;
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
-		*encoder = config->save_encoders[count++];
-	}
-
-	count = 0;
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-		*connector = config->save_connectors[count++];
-	}
+	intel_set_config_restore_state(dev, config);
 
 	/* Try to restore the config */
 	if (mode_changed &&
-- 
1.7.10.4

  parent reply	other threads:[~2012-07-26 19:57 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 18:48 [PATCH 00/76] modeset rework, lightly reworked Daniel Vetter
2012-07-26 18:48 ` [PATCH 01/76] drm/fb-helper: don't clobber output routing in setup_crtcs Daniel Vetter
2012-08-29 16:57   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 02/76] drm/i915: add missing gen2 pipe A quirk entries Daniel Vetter
2012-08-29 16:58   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 03/76] drm/i915/ns2501: kill pll A enabling hack Daniel Vetter
2012-08-29 16:59   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 04/76] drm/i915: rip out the overlay pipe A workaround Daniel Vetter
2012-08-29 16:59   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 05/76] drm/i915: prepare load-detect pipe code for dpms changes Daniel Vetter
2012-08-29 17:07   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 06/76] drm/i915: simplify dvo dpms interface Daniel Vetter
2012-08-29 17:09   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 07/76] drm/i915: kill a few unused things in dev_priv Daniel Vetter
2012-08-29 17:37   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 08/76] drm/i915: extract ironlake_fdi_pll_disable Daniel Vetter
2012-08-29 17:47   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 09/76] drm/i915: add crtc->enable/disable vfuncs insted of dpms Daniel Vetter
2012-08-29 17:49   ` Jesse Barnes
2012-07-26 18:48 ` [PATCH 10/76] drm/i915: rip out crtc prepare/commit indirection Daniel Vetter
2012-07-26 18:48 ` [PATCH 11/76] drm/i915: add direct encoder disable/enable infrastructure Daniel Vetter
2012-07-26 18:48 ` [PATCH 12/76] drm/i915/hdmi: convert to encoder->disable/enable Daniel Vetter
2012-07-26 18:48 ` [PATCH 13/76] drm/i915/tv: convert to encoder enable/disable Daniel Vetter
2012-07-26 18:48 ` [PATCH 14/76] drm/i915/lvds: convert to encoder disable/enable Daniel Vetter
2012-07-26 18:48 ` [PATCH 15/76] drm/i915/dp: " Daniel Vetter
2012-07-26 18:48 ` [PATCH 16/76] drm/i915/crt: " Daniel Vetter
2012-07-26 18:48 ` [PATCH 17/76] drm/i915/sdvo: " Daniel Vetter
2012-07-26 18:48 ` [PATCH 18/76] drm/i915/dvo: " Daniel Vetter
2012-07-26 18:48 ` [PATCH 19/76] drm/i915: convert dpms functions of dvo/sdvo/crt Daniel Vetter
2012-07-26 18:48 ` [PATCH 20/76] drm/i915: rip out encoder->disable/enable checks Daniel Vetter
2012-07-26 18:48 ` [PATCH 21/76] drm/i915: clean up encoder_prepare/commit Daniel Vetter
2012-07-26 18:48 ` [PATCH 22/76] drm/i915: copy&paste drm_crtc_helper_set_config Daniel Vetter
2012-07-26 18:48 ` [PATCH 23/76] drm/i915: call set_base directly Daniel Vetter
2012-07-26 18:48 ` [PATCH 24/76] drm/i915: inline intel_best_encoder Daniel Vetter
2012-07-26 18:48 ` [PATCH 25/76] drm/i915: copy&paste drm_crtc_helper_set_mode Daniel Vetter
2012-07-26 18:48 ` [PATCH 26/76] drm/i915: simplify intel_crtc_prepare_encoders Daniel Vetter
2012-07-26 18:48 ` [PATCH 27/76] drm/i915: rip out encoder->prepare/commit Daniel Vetter
2012-07-26 18:48 ` [PATCH 28/76] drm/i915: call crtc functions directly Daniel Vetter
2012-07-26 18:48 ` [PATCH 29/76] drm/i915: WARN when trying to enabled an unused crtc Daniel Vetter
2012-07-26 18:48 ` [PATCH 30/76] drm/i915: Add interfaces to read out encoder/connector hw state Daniel Vetter
2012-07-26 18:48 ` [PATCH 31/76] drm/i915/dp: implement get_hw_state Daniel Vetter
2012-07-26 18:48 ` [PATCH 32/76] drm/i915/hdmi: " Daniel Vetter
2012-07-26 18:48 ` [PATCH 33/76] drm/i915/tv: " Daniel Vetter
2012-07-26 18:48 ` [PATCH 34/76] drm/i915/lvds: " Daniel Vetter
2012-07-26 18:49 ` [PATCH 35/76] drm/i915/crt: " Daniel Vetter
2012-07-26 18:49 ` [PATCH 36/76] drm/i915/sdvo: " Daniel Vetter
2012-07-26 18:49 ` [PATCH 37/76] drm/i915/dvo: " Daniel Vetter
2012-07-26 18:49 ` [PATCH 38/76] drm/i915: read out the modeset hw state at load and resume time Daniel Vetter
2012-07-26 18:49 ` [PATCH 39/76] drm/i915: check connector hw/sw state Daniel Vetter
2012-07-26 18:49 ` [PATCH 40/76] drm/i915: rip out intel_crtc->dpms_mode Daniel Vetter
2012-07-26 18:49 ` [PATCH 41/76] drm/i915: rip out intel_dp->dpms_mode Daniel Vetter
2012-07-26 18:49 ` [PATCH 42/76] drm/i915: ensure the force pipe A quirk is actually followed Daniel Vetter
2012-07-26 18:49 ` [PATCH 43/76] drm/i915: introduce struct intel_set_config Daniel Vetter
2012-07-26 18:49 ` Daniel Vetter [this message]
2012-07-26 18:49 ` [PATCH 45/76] drm/i915: extract intel_set_config_compute_mode_changes Daniel Vetter
2012-07-26 18:49 ` [PATCH 46/76] drm/i915: extract intel_set_config_update_output_state Daniel Vetter
2012-07-26 18:49 ` [PATCH 47/76] drm/i915: implement crtc helper semantics relied upon by the fb helper Daniel Vetter
2012-07-26 18:49 ` [PATCH 48/76] drm/i915: don't update the fb base if there is no fb Daniel Vetter
2012-07-26 18:49 ` [PATCH 49/76] drm/i915: convert pointless error checks in set_config to BUGs Daniel Vetter
2012-07-26 18:49 ` [PATCH 50/76] drm/i915: don't save all the encoder/crtc state in set_config Daniel Vetter
2012-07-26 18:49 ` [PATCH 51/76] drm/i915: stage modeset output changes Daniel Vetter
2012-07-26 18:49 ` [PATCH 52/76] drm/i915: push crtc->fb update into pipe_set_base Daniel Vetter
2012-07-26 18:49 ` [PATCH 53/76] drm/i915: remove crtc disabling special case Daniel Vetter
2012-07-26 18:49 ` [PATCH 54/76] drm/i915: move output commit and crtc disabling into set_mode Daniel Vetter
2012-07-26 18:49 ` [PATCH 55/76] drm/i915: extract adjusted mode computation Daniel Vetter
2012-07-26 18:49 ` [PATCH 56/76] drm/i915: use staged outuput config in tv->mode_fixup Daniel Vetter
2012-07-26 18:49 ` [PATCH 57/76] drm/i915: use staged outuput config in lvds->mode_fixup Daniel Vetter
2012-07-26 18:49 ` [PATCH 58/76] drm/i915: compute masks of crtcs affected in set_mode Daniel Vetter
2012-07-26 18:49 ` [PATCH 59/76] drm/i915: implement new set_mode code flow Daniel Vetter
2012-07-26 18:49 ` [PATCH 60/76] drm/i915: push commit_output_state past crtc disabling Daniel Vetter
2012-07-26 18:49 ` [PATCH 61/76] drm/i915: s/intel_encoder_disable/intel_encoder_noop Daniel Vetter
2012-07-26 18:49 ` [PATCH 62/76] drm/i915: WARN if the pipe won't turn off Daniel Vetter
2012-07-26 18:49 ` [PATCH 63/76] drm/i915: switch the load detect code to the staged modeset config Daniel Vetter
2012-07-26 18:49 ` [PATCH 64/76] drm/i915: push commit_output_state past the crtc/encoder preparing Daniel Vetter
2012-07-26 18:49 ` [PATCH 65/76] drm/i915: disable all crtcs at suspend time Daniel Vetter
2012-07-26 18:49 ` [PATCH 66/76] drm/i915: add tons of modeset state checks Daniel Vetter
2012-07-26 18:49 ` [PATCH 67/76] drm/i915: rip out intel_disable_pch_ports Daniel Vetter
2012-07-26 18:49 ` [PATCH 68/76] drm/i915: don't disable fdi links harder in ilk_crtc_enable Daniel Vetter
2012-07-26 18:49 ` [PATCH 69/76] drm/i915: don't call dpms funcs after set_mode Daniel Vetter
2012-07-26 18:49 ` [PATCH 70/76] drm/i915: update dpms property in set_mode Daniel Vetter
2012-07-26 18:49 ` [PATCH 71/76] drm/i915: add encoder->pre_enable/post_disable Daniel Vetter
2012-07-26 18:49 ` [PATCH 72/76] drm/i915: clean up the cpu edp pll special case Daniel Vetter
2012-07-26 18:49 ` [PATCH 73/76] drm/i915: robustify edp_pll_on/off Daniel Vetter
2012-07-26 18:49 ` [PATCH 74/76] drm/i915: rip out dp port enabling cludges^Wchecks Daniel Vetter
2012-07-26 18:49 ` [PATCH 75/76] drm/i915: disable the cpu edp port after the cpu pipe Daniel Vetter
2012-07-26 18:49 ` [PATCH 76/76] drm/i915: move encoder->mode_set calls to crtc_mode_set Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343328581-2324-45-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).