All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: keithp@keithp.com
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 16/16] drm/i915: Share the common force-audio property between connectors
Date: Thu, 12 May 2011 22:17:24 +0100	[thread overview]
Message-ID: <1305235044-9159-17-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1305235044-9159-1-git-send-email-chris@chris-wilson.co.uk>

Make the audio property creation routine common and share the single
property between the connectors.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.h    |    1 +
 drivers/gpu/drm/i915/intel_dp.c    |   15 ++-------------
 drivers/gpu/drm/i915/intel_drv.h   |    1 +
 drivers/gpu/drm/i915/intel_hdmi.c  |   14 ++------------
 drivers/gpu/drm/i915/intel_modes.c |   30 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_sdvo.c  |   14 ++------------
 6 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ae1ab1b..d787a3d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -712,6 +712,7 @@ typedef struct drm_i915_private {
 	struct intel_fbdev *fbdev;
 
 	struct drm_property *broadcast_rgb_property;
+	struct drm_property *force_audio_property;
 
 	atomic_t forcewake_count;
 } drm_i915_private_t;
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index a4d8031..391b55f 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -59,8 +59,6 @@ struct intel_dp {
 	bool is_pch_edp;
 	uint8_t	train_set[4];
 	uint8_t link_status[DP_LINK_STATUS_SIZE];
-
-	struct drm_property *force_audio_property;
 };
 
 /**
@@ -1702,7 +1700,7 @@ intel_dp_set_property(struct drm_connector *connector,
 	if (ret)
 		return ret;
 
-	if (property == intel_dp->force_audio_property) {
+	if (property == dev_priv->force_audio_property) {
 		int i = val;
 		bool has_audio;
 
@@ -1841,16 +1839,7 @@ bool intel_dpd_is_edp(struct drm_device *dev)
 static void
 intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector)
 {
-	struct drm_device *dev = connector->dev;
-
-	intel_dp->force_audio_property =
-		drm_property_create(dev, DRM_MODE_PROP_RANGE, "force_audio", 2);
-	if (intel_dp->force_audio_property) {
-		intel_dp->force_audio_property->values[0] = -1;
-		intel_dp->force_audio_property->values[1] = 1;
-		drm_connector_attach_property(connector, intel_dp->force_audio_property, 0);
-	}
-
+	intel_attach_force_audio_property(connector);
 	intel_attach_broadcast_rgb_property(connector);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 2e49b62..fed46b7 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -236,6 +236,7 @@ struct intel_unpin_work {
 int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
 extern bool intel_ddc_probe(struct intel_encoder *intel_encoder, int ddc_bus);
 
+extern void intel_attach_force_audio_property(struct drm_connector *connector);
 extern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
 
 extern void intel_crt_init(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index f289b86..70cde9e 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -45,7 +45,6 @@ struct intel_hdmi {
 	bool has_hdmi_sink;
 	bool has_audio;
 	int force_audio;
-	struct drm_property *force_audio_property;
 };
 
 static struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder)
@@ -287,7 +286,7 @@ intel_hdmi_set_property(struct drm_connector *connector,
 	if (ret)
 		return ret;
 
-	if (property == intel_hdmi->force_audio_property) {
+	if (property == dev_priv->force_audio_property) {
 		int i = val;
 		bool has_audio;
 
@@ -365,16 +364,7 @@ static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
 static void
 intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
 {
-	struct drm_device *dev = connector->dev;
-
-	intel_hdmi->force_audio_property =
-		drm_property_create(dev, DRM_MODE_PROP_RANGE, "force_audio", 2);
-	if (intel_hdmi->force_audio_property) {
-		intel_hdmi->force_audio_property->values[0] = -1;
-		intel_hdmi->force_audio_property->values[1] = 1;
-		drm_connector_attach_property(connector, intel_hdmi->force_audio_property, 0);
-	}
-
+	intel_attach_force_audio_property(connector);
 	intel_attach_broadcast_rgb_property(connector);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_modes.c b/drivers/gpu/drm/i915/intel_modes.c
index 9034dd8f..3b26a3b 100644
--- a/drivers/gpu/drm/i915/intel_modes.c
+++ b/drivers/gpu/drm/i915/intel_modes.c
@@ -81,6 +81,36 @@ int intel_ddc_get_modes(struct drm_connector *connector,
 	return ret;
 }
 
+static const char *force_audio_names[] = {
+	"off",
+	"auto",
+	"on",
+};
+
+void
+intel_attach_force_audio_property(struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_property *prop;
+	int i;
+
+	prop = dev_priv->force_audio_property;
+	if (prop == NULL) {
+		prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
+					   "audio",
+					   ARRAY_SIZE(force_audio_names));
+		if (prop == NULL)
+			return;
+
+		for (i = 0; i < ARRAY_SIZE(force_audio_names); i++)
+			drm_property_add_enum(prop, i, i-1, force_audio_names[i]);
+
+		dev_priv->force_audio_property = prop;
+	}
+	drm_connector_attach_property(connector, prop, 0);
+}
+
 static const char *broadcast_rgb_names[] = {
 	"Full",
 	"Limited 16:235",
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 4324f33..d4cb369 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -148,8 +148,6 @@ struct intel_sdvo_connector {
 	int   format_supported_num;
 	struct drm_property *tv_format;
 
-	struct drm_property *force_audio_property;
-
 	/* add the property for the SDVO-TV */
 	struct drm_property *left;
 	struct drm_property *right;
@@ -1712,7 +1710,7 @@ intel_sdvo_set_property(struct drm_connector *connector,
 	if (ret)
 		return ret;
 
-	if (property == intel_sdvo_connector->force_audio_property) {
+	if (property == dev_priv->force_audio_property) {
 		int i = val;
 		bool has_audio;
 
@@ -2037,15 +2035,7 @@ intel_sdvo_add_hdmi_properties(struct intel_sdvo_connector *connector)
 {
 	struct drm_device *dev = connector->base.base.dev;
 
-	connector->force_audio_property =
-		drm_property_create(dev, DRM_MODE_PROP_RANGE, "force_audio", 2);
-	if (connector->force_audio_property) {
-		connector->force_audio_property->values[0] = -1;
-		connector->force_audio_property->values[1] = 1;
-		drm_connector_attach_property(&connector->base.base,
-					      connector->force_audio_property, 0);
-	}
-
+	intel_attach_force_audio_property(&connector->base.base);
 	if (INTEL_INFO(dev)->gen >= 4 && IS_MOBILE(dev))
 		intel_attach_broadcast_rgb_property(&connector->base.base);
 }
-- 
1.7.5.1

  parent reply	other threads:[~2011-05-12 21:17 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 21:17 Select patches for 2.6.40 Chris Wilson
2011-05-12 21:17 ` [PATCH 01/16] drm/i915: Cache GT fifo count for SandyBridge Chris Wilson
2011-05-12 21:17 ` [PATCH 02/16] drm/i915: Refactor pwrite/pread to use single copy of get_user_pages Chris Wilson
2011-05-13  0:21   ` Keith Packard
2011-05-15  8:00     ` Chris Wilson
2011-05-15 15:36       ` Keith Packard
2011-05-12 21:17 ` [PATCH 03/16] drm/i915: s/addr & ~PAGE_MASK/offset_in_page(addr)/ Chris Wilson
2011-05-13  0:26   ` Keith Packard
2011-05-12 21:17 ` [PATCH 04/16] drm/i915: Only print out the actual number of fences for i915_error_state Chris Wilson
2011-05-13  0:28   ` Keith Packard
2011-05-12 21:17 ` [PATCH 05/16] drm/i915/tv: Use a direct pointer for tv_mode Chris Wilson
2011-05-13  0:30   ` Keith Packard
2011-05-12 21:17 ` [PATCH 06/16] drm/i915: Replace ironlake_compute_wm0 with g4x_compute_wm0 Chris Wilson
2011-05-13  0:34   ` Keith Packard
2011-05-13  9:19     ` Chris Wilson
2011-05-13 15:00       ` Keith Packard
2011-05-12 21:17 ` [PATCH 07/16] drm/i915/crt: Explicitly return false if connected to a digital monitor Chris Wilson
2011-05-12 21:17 ` [PATCH 08/16] drm/i915/i2c: Convert from using GMBUS1 + reg_offset idiom to reg + 0 Chris Wilson
2011-05-13  0:36   ` Keith Packard
2011-05-13  0:40   ` Keith Packard
2011-05-13  9:28     ` Chris Wilson
2011-05-13 15:00       ` Keith Packard
2011-06-03 20:55         ` Keith Packard
2011-06-03 23:09           ` Chris Wilson
2011-06-03 23:48             ` Keith Packard
2011-07-13 18:33             ` Keith Packard
2011-07-13 19:22               ` Chris Wilson
2011-05-12 21:17 ` [PATCH 09/16] drm/i915/gmbus: Reset the controller on initialisation Chris Wilson
2011-05-13  0:41   ` Keith Packard
2011-05-13  9:32     ` Chris Wilson
2011-05-13 15:01       ` Keith Packard
2011-05-13 15:53         ` Chris Wilson
2011-06-03 20:56   ` Keith Packard
2011-05-12 21:17 ` [PATCH 10/16] drm/i915: Retire requests before disabling pagefaults Chris Wilson
2011-05-13  1:08   ` Keith Packard
2011-05-12 21:17 ` [PATCH 11/16] drm/i915: not finding a fence is a non-recoverable condition Chris Wilson
2011-05-13  1:10   ` Keith Packard
2011-05-15 20:38     ` Daniel Vetter
2011-05-12 21:17 ` [PATCH 12/16] drm/915: fix relaxed tiling on gen2: tile height Chris Wilson
2011-05-13  1:13   ` Keith Packard
2011-05-15 20:43     ` Daniel Vetter
2011-05-15 21:58       ` Keith Packard
2011-05-16 17:48         ` Daniel Vetter
2011-05-12 21:17 ` [PATCH 13/16] drm/i915: Remove unused enum "chip_family" Chris Wilson
2011-05-13  1:13   ` Keith Packard
2011-05-12 21:17 ` [PATCH 14/16] drm/i915: Use PCI-ID to identify Broadwater and Crestline Chris Wilson
2011-05-13  1:16   ` Keith Packard
2011-05-13  9:39     ` Chris Wilson
2011-05-15 20:49     ` Daniel Vetter
2011-05-15 22:01       ` Keith Packard
2011-06-03 20:59   ` Keith Packard
2011-05-12 21:17 ` [PATCH 15/16] drm/i915: Convert partial to full CPU read domain if we touch every page Chris Wilson
2011-05-13  1:17   ` Keith Packard
2011-05-12 21:17 ` Chris Wilson [this message]
2011-05-13  1:21   ` [PATCH 16/16] drm/i915: Share the common force-audio property between connectors Keith Packard
2011-05-13  3:39 ` Select patches for 2.6.40 Zou, Nanhai

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=1305235044-9159-17-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=keithp@keithp.com \
    /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.