All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 4/7] drm/i915/sdvo: Use an integer mapping for supported tv format modes
Date: Mon, 19 Jul 2010 14:25:45 +0100	[thread overview]
Message-ID: <1279545948-24378-5-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1279545948-24378-1-git-send-email-chris@chris-wilson.co.uk>

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_sdvo.c |   34 +++++++++++-----------------------
 1 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index ba50755..a30d751 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -98,7 +98,7 @@ struct intel_sdvo {
 	bool is_tv;
 
 	/* This is for current tv format name */
-	char *tv_format_name;
+	int tv_format_index;
 
 	/**
 	 * This is set if we treat the device as HDMI, instead of DVI.
@@ -141,7 +141,7 @@ struct intel_sdvo_connector {
 	uint16_t output_flag;
 
 	/* This contains all current supported TV format */
-	char *tv_format_supported[TV_FORMAT_NUM];
+	u8 tv_format_supported[TV_FORMAT_NUM];
 	int   format_supported_num;
 	struct drm_property *tv_format_property;
 	struct drm_property *tv_format_name_property[TV_FORMAT_NUM];
@@ -958,13 +958,9 @@ static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo,
 static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo)
 {
 	struct intel_sdvo_tv_format format;
-	uint32_t format_map, i;
-
-	for (i = 0; i < TV_FORMAT_NUM; i++)
-		if (tv_format_names[i] == intel_sdvo->tv_format_name)
-			break;
+	uint32_t format_map;
 
-	format_map = 1 << i;
+	format_map = 1 << intel_sdvo->tv_format_index;
 	memset(&format, 0, sizeof(format));
 	memcpy(&format, &format_map, min(sizeof(format), sizeof(format_map)));
 
@@ -1612,11 +1608,7 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
 	/* Read the list of supported input resolutions for the selected TV
 	 * format.
 	 */
-	for (i = 0; i < TV_FORMAT_NUM; i++)
-		if (tv_format_names[i] ==  intel_sdvo->tv_format_name)
-			break;
-
-	format_map = (1 << i);
+	format_map = 1 << intel_sdvo->tv_format_index;
 	memcpy(&tv_res, &format_map,
 	       min(sizeof(format_map), sizeof(struct intel_sdvo_sdtv_resolution_request)));
 
@@ -1638,7 +1630,6 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
 			if (nmode)
 				drm_mode_probed_add(connector, nmode);
 		}
-
 }
 
 static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
@@ -1766,11 +1757,11 @@ intel_sdvo_set_property(struct drm_connector *connector,
 		if (val >= TV_FORMAT_NUM)
 			return -EINVAL;
 
-		if (intel_sdvo->tv_format_name ==
+		if (intel_sdvo->tv_format_index ==
 		    intel_sdvo_connector->tv_format_supported[val])
 			return 0;
 
-		intel_sdvo->tv_format_name = intel_sdvo_connector->tv_format_supported[val];
+		intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[val];
 		changed = true;
 	} else if (IS_TV_OR_LVDS(intel_sdvo_connector)) {
 		cmd = 0;
@@ -2269,11 +2260,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
 
 	intel_sdvo_connector->format_supported_num = 0;
 	for (i = 0 ; i < TV_FORMAT_NUM; i++)
-		if (format_map & (1 << i)) {
-			intel_sdvo_connector->tv_format_supported
-			[intel_sdvo_connector->format_supported_num++] =
-			tv_format_names[i];
-		}
+		if (format_map & (1 << i))
+			intel_sdvo_connector->tv_format_supported[intel_sdvo_connector->format_supported_num++] = i;
 
 
 	intel_sdvo_connector->tv_format_property =
@@ -2283,9 +2271,9 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
 	for (i = 0; i < intel_sdvo_connector->format_supported_num; i++)
 		drm_property_add_enum(
 				intel_sdvo_connector->tv_format_property, i,
-				i, intel_sdvo_connector->tv_format_supported[i]);
+				i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]);
 
-	intel_sdvo->tv_format_name = intel_sdvo_connector->tv_format_supported[0];
+	intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[0];
 	drm_connector_attach_property(&intel_sdvo_connector->base.base,
 				      intel_sdvo_connector->tv_format_property, 0);
 	return true;
-- 
1.7.1

  parent reply	other threads:[~2010-07-19 13:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-19 13:25 Revamp intel_sdvo and add missing properties Chris Wilson
2010-07-19 13:25 ` [PATCH 1/7] drm/i915: Subclass intel_encoder Chris Wilson
2010-08-02  2:43   ` Eric Anholt
2010-07-19 13:25 ` [PATCH 2/7] drm/i915: Subclass intel_connector Chris Wilson
2010-07-19 13:25 ` [PATCH 3/7] drm/i915/sdvo: Propagate errors from reading/writing control bus Chris Wilson
2010-07-19 13:25 ` Chris Wilson [this message]
2010-07-19 13:25 ` [PATCH 5/7] drm/i915/sdvo: Check for allocation failure when constructing properties Chris Wilson
2010-07-19 13:25 ` [PATCH 6/7] drm/i915/sdvo: Add missing TV filters Chris Wilson
2010-07-19 13:25 ` [PATCH 7/7] drm/i915/sdvo: Add dot crawl property Chris Wilson
2010-08-04 12:50 SVDO properties patchset Chris Wilson
2010-08-04 12:50 ` [PATCH 4/7] drm/i915/sdvo: Use an integer mapping for supported tv format modes Chris Wilson

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=1279545948-24378-5-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.