aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_modes.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-02-06 04:58:17 -0500
committerDave Airlie <airlied@redhat.com>2012-02-09 05:15:18 -0500
commit4a67d39190315558631d944b1cea4466ed4c86d8 (patch)
tree1d90ec7e35c2f6048bf38ba3dfcb838d9df52a16 /drivers/gpu/drm/i915/intel_modes.c
parent198ceac091049003ffcc4b7cda76785510fc3b59 (diff)
drm: add convenience function to create an enum property
Creating an enum property is a common pattern, so create a convenience function for this and use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_modes.c')
-rw-r--r--drivers/gpu/drm/i915/intel_modes.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/gpu/drm/i915/intel_modes.c b/drivers/gpu/drm/i915/intel_modes.c
index be2c6fe07d12..961f75dbeae1 100644
--- a/drivers/gpu/drm/i915/intel_modes.c
+++ b/drivers/gpu/drm/i915/intel_modes.c
@@ -83,10 +83,10 @@ int intel_ddc_get_modes(struct drm_connector *connector,
83 return ret; 83 return ret;
84} 84}
85 85
86static const char *force_audio_names[] = { 86static const struct drm_prop_enum_list force_audio_names[] = {
87 "off", 87 { -1, "off" },
88 "auto", 88 { 0, "auto" },
89 "on", 89 { 1, "on" },
90}; 90};
91 91
92void 92void
@@ -95,27 +95,24 @@ intel_attach_force_audio_property(struct drm_connector *connector)
95 struct drm_device *dev = connector->dev; 95 struct drm_device *dev = connector->dev;
96 struct drm_i915_private *dev_priv = dev->dev_private; 96 struct drm_i915_private *dev_priv = dev->dev_private;
97 struct drm_property *prop; 97 struct drm_property *prop;
98 int i;
99 98
100 prop = dev_priv->force_audio_property; 99 prop = dev_priv->force_audio_property;
101 if (prop == NULL) { 100 if (prop == NULL) {
102 prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, 101 prop = drm_property_create_enum(dev, 0,
103 "audio", 102 "audio",
103 force_audio_names,
104 ARRAY_SIZE(force_audio_names)); 104 ARRAY_SIZE(force_audio_names));
105 if (prop == NULL) 105 if (prop == NULL)
106 return; 106 return;
107 107
108 for (i = 0; i < ARRAY_SIZE(force_audio_names); i++)
109 drm_property_add_enum(prop, i, i-1, force_audio_names[i]);
110
111 dev_priv->force_audio_property = prop; 108 dev_priv->force_audio_property = prop;
112 } 109 }
113 drm_connector_attach_property(connector, prop, 0); 110 drm_connector_attach_property(connector, prop, 0);
114} 111}
115 112
116static const char *broadcast_rgb_names[] = { 113static const struct drm_prop_enum_list broadcast_rgb_names[] = {
117 "Full", 114 { 0, "Full" },
118 "Limited 16:235", 115 { 1, "Limited 16:235" },
119}; 116};
120 117
121void 118void
@@ -124,19 +121,16 @@ intel_attach_broadcast_rgb_property(struct drm_connector *connector)
124 struct drm_device *dev = connector->dev; 121 struct drm_device *dev = connector->dev;
125 struct drm_i915_private *dev_priv = dev->dev_private; 122 struct drm_i915_private *dev_priv = dev->dev_private;
126 struct drm_property *prop; 123 struct drm_property *prop;
127 int i;
128 124
129 prop = dev_priv->broadcast_rgb_property; 125 prop = dev_priv->broadcast_rgb_property;
130 if (prop == NULL) { 126 if (prop == NULL) {
131 prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, 127 prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM,
132 "Broadcast RGB", 128 "Broadcast RGB",
129 broadcast_rgb_names,
133 ARRAY_SIZE(broadcast_rgb_names)); 130 ARRAY_SIZE(broadcast_rgb_names));
134 if (prop == NULL) 131 if (prop == NULL)
135 return; 132 return;
136 133
137 for (i = 0; i < ARRAY_SIZE(broadcast_rgb_names); i++)
138 drm_property_add_enum(prop, i, i, broadcast_rgb_names[i]);
139
140 dev_priv->broadcast_rgb_property = prop; 134 dev_priv->broadcast_rgb_property = prop;
141 } 135 }
142 136