diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-08-04 08:50:26 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-08-09 14:24:29 -0400 |
commit | 400397506f96466a7f57911b33b4b9c075880994 (patch) | |
tree | 94b61d8434b2d0f9ab205a1aa98602bbda248169 | |
parent | 32aad86fe88e7323d4fc5e9e423abcee0d55a03d (diff) |
drm/i915/sdvo: Use an integer mapping for supported tv format modes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r-- | 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 300f110fd180..ce8e4432d1c5 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c | |||
@@ -98,7 +98,7 @@ struct intel_sdvo { | |||
98 | bool is_tv; | 98 | bool is_tv; |
99 | 99 | ||
100 | /* This is for current tv format name */ | 100 | /* This is for current tv format name */ |
101 | char *tv_format_name; | 101 | int tv_format_index; |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * This is set if we treat the device as HDMI, instead of DVI. | 104 | * This is set if we treat the device as HDMI, instead of DVI. |
@@ -141,7 +141,7 @@ struct intel_sdvo_connector { | |||
141 | uint16_t output_flag; | 141 | uint16_t output_flag; |
142 | 142 | ||
143 | /* This contains all current supported TV format */ | 143 | /* This contains all current supported TV format */ |
144 | char *tv_format_supported[TV_FORMAT_NUM]; | 144 | u8 tv_format_supported[TV_FORMAT_NUM]; |
145 | int format_supported_num; | 145 | int format_supported_num; |
146 | struct drm_property *tv_format_property; | 146 | struct drm_property *tv_format_property; |
147 | struct drm_property *tv_format_name_property[TV_FORMAT_NUM]; | 147 | 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, | |||
958 | static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo) | 958 | static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo) |
959 | { | 959 | { |
960 | struct intel_sdvo_tv_format format; | 960 | struct intel_sdvo_tv_format format; |
961 | uint32_t format_map, i; | 961 | uint32_t format_map; |
962 | |||
963 | for (i = 0; i < TV_FORMAT_NUM; i++) | ||
964 | if (tv_format_names[i] == intel_sdvo->tv_format_name) | ||
965 | break; | ||
966 | 962 | ||
967 | format_map = 1 << i; | 963 | format_map = 1 << intel_sdvo->tv_format_index; |
968 | memset(&format, 0, sizeof(format)); | 964 | memset(&format, 0, sizeof(format)); |
969 | memcpy(&format, &format_map, min(sizeof(format), sizeof(format_map))); | 965 | memcpy(&format, &format_map, min(sizeof(format), sizeof(format_map))); |
970 | 966 | ||
@@ -1614,11 +1610,7 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector) | |||
1614 | /* Read the list of supported input resolutions for the selected TV | 1610 | /* Read the list of supported input resolutions for the selected TV |
1615 | * format. | 1611 | * format. |
1616 | */ | 1612 | */ |
1617 | for (i = 0; i < TV_FORMAT_NUM; i++) | 1613 | format_map = 1 << intel_sdvo->tv_format_index; |
1618 | if (tv_format_names[i] == intel_sdvo->tv_format_name) | ||
1619 | break; | ||
1620 | |||
1621 | format_map = (1 << i); | ||
1622 | memcpy(&tv_res, &format_map, | 1614 | memcpy(&tv_res, &format_map, |
1623 | min(sizeof(format_map), sizeof(struct intel_sdvo_sdtv_resolution_request))); | 1615 | min(sizeof(format_map), sizeof(struct intel_sdvo_sdtv_resolution_request))); |
1624 | 1616 | ||
@@ -1640,7 +1632,6 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector) | |||
1640 | if (nmode) | 1632 | if (nmode) |
1641 | drm_mode_probed_add(connector, nmode); | 1633 | drm_mode_probed_add(connector, nmode); |
1642 | } | 1634 | } |
1643 | |||
1644 | } | 1635 | } |
1645 | 1636 | ||
1646 | static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) | 1637 | static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) |
@@ -1768,11 +1759,11 @@ intel_sdvo_set_property(struct drm_connector *connector, | |||
1768 | if (val >= TV_FORMAT_NUM) | 1759 | if (val >= TV_FORMAT_NUM) |
1769 | return -EINVAL; | 1760 | return -EINVAL; |
1770 | 1761 | ||
1771 | if (intel_sdvo->tv_format_name == | 1762 | if (intel_sdvo->tv_format_index == |
1772 | intel_sdvo_connector->tv_format_supported[val]) | 1763 | intel_sdvo_connector->tv_format_supported[val]) |
1773 | return 0; | 1764 | return 0; |
1774 | 1765 | ||
1775 | intel_sdvo->tv_format_name = intel_sdvo_connector->tv_format_supported[val]; | 1766 | intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[val]; |
1776 | changed = true; | 1767 | changed = true; |
1777 | } else if (IS_TV_OR_LVDS(intel_sdvo_connector)) { | 1768 | } else if (IS_TV_OR_LVDS(intel_sdvo_connector)) { |
1778 | cmd = 0; | 1769 | cmd = 0; |
@@ -2271,11 +2262,8 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, | |||
2271 | 2262 | ||
2272 | intel_sdvo_connector->format_supported_num = 0; | 2263 | intel_sdvo_connector->format_supported_num = 0; |
2273 | for (i = 0 ; i < TV_FORMAT_NUM; i++) | 2264 | for (i = 0 ; i < TV_FORMAT_NUM; i++) |
2274 | if (format_map & (1 << i)) { | 2265 | if (format_map & (1 << i)) |
2275 | intel_sdvo_connector->tv_format_supported | 2266 | intel_sdvo_connector->tv_format_supported[intel_sdvo_connector->format_supported_num++] = i; |
2276 | [intel_sdvo_connector->format_supported_num++] = | ||
2277 | tv_format_names[i]; | ||
2278 | } | ||
2279 | 2267 | ||
2280 | 2268 | ||
2281 | intel_sdvo_connector->tv_format_property = | 2269 | intel_sdvo_connector->tv_format_property = |
@@ -2285,9 +2273,9 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, | |||
2285 | for (i = 0; i < intel_sdvo_connector->format_supported_num; i++) | 2273 | for (i = 0; i < intel_sdvo_connector->format_supported_num; i++) |
2286 | drm_property_add_enum( | 2274 | drm_property_add_enum( |
2287 | intel_sdvo_connector->tv_format_property, i, | 2275 | intel_sdvo_connector->tv_format_property, i, |
2288 | i, intel_sdvo_connector->tv_format_supported[i]); | 2276 | i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); |
2289 | 2277 | ||
2290 | intel_sdvo->tv_format_name = intel_sdvo_connector->tv_format_supported[0]; | 2278 | intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[0]; |
2291 | drm_connector_attach_property(&intel_sdvo_connector->base.base, | 2279 | drm_connector_attach_property(&intel_sdvo_connector->base.base, |
2292 | intel_sdvo_connector->tv_format_property, 0); | 2280 | intel_sdvo_connector->tv_format_property, 0); |
2293 | return true; | 2281 | return true; |