diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-08-04 08:50:28 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-08-09 14:24:29 -0400 |
commit | c55217064eb728fc9348de781979b533e7cc116c (patch) | |
tree | 7bb21d6228b34655d29a7bbc287e64e24033244c /drivers/gpu/drm/i915 | |
parent | fcc8d6721cef2158398139d66cc99b5e843126a0 (diff) |
drm/i915/sdvo: Add missing TV filters
Reference:
Bug 28634 - missing TV parameter "Flicker Filter"
https://bugs.freedesktop.org/show_bug.cgi?id=28634
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r-- | drivers/gpu/drm/i915/intel_sdvo.c | 644 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_sdvo_regs.h | 48 |
2 files changed, 308 insertions, 384 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index 72fec054c264..2344fb056793 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c | |||
@@ -143,31 +143,31 @@ struct intel_sdvo_connector { | |||
143 | /* This contains all current supported TV format */ | 143 | /* This contains all current supported TV format */ |
144 | u8 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; |
147 | struct drm_property *tv_format_name_property[TV_FORMAT_NUM]; | ||
148 | |||
149 | /** | ||
150 | * Returned SDTV resolutions allowed for the current format, if the | ||
151 | * device reported it. | ||
152 | */ | ||
153 | struct intel_sdvo_sdtv_resolution_reply sdtv_resolutions; | ||
154 | 147 | ||
155 | /* add the property for the SDVO-TV */ | 148 | /* add the property for the SDVO-TV */ |
156 | struct drm_property *left_property; | 149 | struct drm_property *left; |
157 | struct drm_property *right_property; | 150 | struct drm_property *right; |
158 | struct drm_property *top_property; | 151 | struct drm_property *top; |
159 | struct drm_property *bottom_property; | 152 | struct drm_property *bottom; |
160 | struct drm_property *hpos_property; | 153 | struct drm_property *hpos; |
161 | struct drm_property *vpos_property; | 154 | struct drm_property *vpos; |
155 | struct drm_property *contrast; | ||
156 | struct drm_property *saturation; | ||
157 | struct drm_property *hue; | ||
158 | struct drm_property *sharpness; | ||
159 | struct drm_property *flicker_filter; | ||
160 | struct drm_property *flicker_filter_adaptive; | ||
161 | struct drm_property *flicker_filter_2d; | ||
162 | struct drm_property *tv_chroma_filter; | ||
163 | struct drm_property *tv_luma_filter; | ||
162 | 164 | ||
163 | /* add the property for the SDVO-TV/LVDS */ | 165 | /* add the property for the SDVO-TV/LVDS */ |
164 | struct drm_property *brightness_property; | 166 | struct drm_property *brightness; |
165 | struct drm_property *contrast_property; | ||
166 | struct drm_property *saturation_property; | ||
167 | struct drm_property *hue_property; | ||
168 | 167 | ||
169 | /* Add variable to record current setting for the above property */ | 168 | /* Add variable to record current setting for the above property */ |
170 | u32 left_margin, right_margin, top_margin, bottom_margin; | 169 | u32 left_margin, right_margin, top_margin, bottom_margin; |
170 | |||
171 | /* this is to get the range of margin.*/ | 171 | /* this is to get the range of margin.*/ |
172 | u32 max_hscan, max_vscan; | 172 | u32 max_hscan, max_vscan; |
173 | u32 max_hpos, cur_hpos; | 173 | u32 max_hpos, cur_hpos; |
@@ -176,6 +176,12 @@ struct intel_sdvo_connector { | |||
176 | u32 cur_contrast, max_contrast; | 176 | u32 cur_contrast, max_contrast; |
177 | u32 cur_saturation, max_saturation; | 177 | u32 cur_saturation, max_saturation; |
178 | u32 cur_hue, max_hue; | 178 | u32 cur_hue, max_hue; |
179 | u32 cur_sharpness, max_sharpness; | ||
180 | u32 cur_flicker_filter, max_flicker_filter; | ||
181 | u32 cur_flicker_filter_adaptive, max_flicker_filter_adaptive; | ||
182 | u32 cur_flicker_filter_2d, max_flicker_filter_2d; | ||
183 | u32 cur_tv_chroma_filter, max_tv_chroma_filter; | ||
184 | u32 cur_tv_luma_filter, max_tv_luma_filter; | ||
179 | }; | 185 | }; |
180 | 186 | ||
181 | static struct intel_sdvo *enc_to_intel_sdvo(struct drm_encoder *encoder) | 187 | static struct intel_sdvo *enc_to_intel_sdvo(struct drm_encoder *encoder) |
@@ -329,13 +335,14 @@ static const struct _sdvo_cmd_name { | |||
329 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT), | 335 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT), |
330 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT), | 336 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT), |
331 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS), | 337 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS), |
338 | |||
332 | /* Add the op code for SDVO enhancements */ | 339 | /* Add the op code for SDVO enhancements */ |
333 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_POSITION_H), | 340 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_HPOS), |
334 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POSITION_H), | 341 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HPOS), |
335 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_POSITION_H), | 342 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HPOS), |
336 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_POSITION_V), | 343 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_VPOS), |
337 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POSITION_V), | 344 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_VPOS), |
338 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_POSITION_V), | 345 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_VPOS), |
339 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_SATURATION), | 346 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_SATURATION), |
340 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SATURATION), | 347 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SATURATION), |
341 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_SATURATION), | 348 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_SATURATION), |
@@ -354,6 +361,27 @@ static const struct _sdvo_cmd_name { | |||
354 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_OVERSCAN_V), | 361 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_OVERSCAN_V), |
355 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OVERSCAN_V), | 362 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_OVERSCAN_V), |
356 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OVERSCAN_V), | 363 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_OVERSCAN_V), |
364 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_FLICKER_FILTER), | ||
365 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_FLICKER_FILTER), | ||
366 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_FLICKER_FILTER), | ||
367 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_FLICKER_FILTER_ADAPTIVE), | ||
368 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_FLICKER_FILTER_ADAPTIVE), | ||
369 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_FLICKER_FILTER_ADAPTIVE), | ||
370 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_FLICKER_FILTER_2D), | ||
371 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_FLICKER_FILTER_2D), | ||
372 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_FLICKER_FILTER_2D), | ||
373 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_SHARPNESS), | ||
374 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SHARPNESS), | ||
375 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_SHARPNESS), | ||
376 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_DOT_CRAWL), | ||
377 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_DOT_CRAWL), | ||
378 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_TV_CHROMA_FILTER), | ||
379 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_CHROMA_FILTER), | ||
380 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_CHROMA_FILTER), | ||
381 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_MAX_TV_LUMA_FILTER), | ||
382 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_LUMA_FILTER), | ||
383 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_LUMA_FILTER), | ||
384 | |||
357 | /* HDMI op code */ | 385 | /* HDMI op code */ |
358 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPP_ENCODE), | 386 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPP_ENCODE), |
359 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ENCODE), | 387 | SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ENCODE), |
@@ -1693,43 +1721,47 @@ intel_sdvo_destroy_enhance_property(struct drm_connector *connector) | |||
1693 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); | 1721 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); |
1694 | struct drm_device *dev = connector->dev; | 1722 | struct drm_device *dev = connector->dev; |
1695 | 1723 | ||
1696 | if (IS_TV(intel_sdvo_connector)) { | 1724 | if (intel_sdvo_connector->left) |
1697 | if (intel_sdvo_connector->left_property) | 1725 | drm_property_destroy(dev, intel_sdvo_connector->left); |
1698 | drm_property_destroy(dev, intel_sdvo_connector->left_property); | 1726 | if (intel_sdvo_connector->right) |
1699 | if (intel_sdvo_connector->right_property) | 1727 | drm_property_destroy(dev, intel_sdvo_connector->right); |
1700 | drm_property_destroy(dev, intel_sdvo_connector->right_property); | 1728 | if (intel_sdvo_connector->top) |
1701 | if (intel_sdvo_connector->top_property) | 1729 | drm_property_destroy(dev, intel_sdvo_connector->top); |
1702 | drm_property_destroy(dev, intel_sdvo_connector->top_property); | 1730 | if (intel_sdvo_connector->bottom) |
1703 | if (intel_sdvo_connector->bottom_property) | 1731 | drm_property_destroy(dev, intel_sdvo_connector->bottom); |
1704 | drm_property_destroy(dev, intel_sdvo_connector->bottom_property); | 1732 | if (intel_sdvo_connector->hpos) |
1705 | if (intel_sdvo_connector->hpos_property) | 1733 | drm_property_destroy(dev, intel_sdvo_connector->hpos); |
1706 | drm_property_destroy(dev, intel_sdvo_connector->hpos_property); | 1734 | if (intel_sdvo_connector->vpos) |
1707 | if (intel_sdvo_connector->vpos_property) | 1735 | drm_property_destroy(dev, intel_sdvo_connector->vpos); |
1708 | drm_property_destroy(dev, intel_sdvo_connector->vpos_property); | 1736 | if (intel_sdvo_connector->saturation) |
1709 | if (intel_sdvo_connector->saturation_property) | 1737 | drm_property_destroy(dev, intel_sdvo_connector->saturation); |
1710 | drm_property_destroy(dev, | 1738 | if (intel_sdvo_connector->contrast) |
1711 | intel_sdvo_connector->saturation_property); | 1739 | drm_property_destroy(dev, intel_sdvo_connector->contrast); |
1712 | if (intel_sdvo_connector->contrast_property) | 1740 | if (intel_sdvo_connector->hue) |
1713 | drm_property_destroy(dev, | 1741 | drm_property_destroy(dev, intel_sdvo_connector->hue); |
1714 | intel_sdvo_connector->contrast_property); | 1742 | if (intel_sdvo_connector->sharpness) |
1715 | if (intel_sdvo_connector->hue_property) | 1743 | drm_property_destroy(dev, intel_sdvo_connector->sharpness); |
1716 | drm_property_destroy(dev, intel_sdvo_connector->hue_property); | 1744 | if (intel_sdvo_connector->flicker_filter) |
1717 | } | 1745 | drm_property_destroy(dev, intel_sdvo_connector->flicker_filter); |
1718 | if (IS_TV_OR_LVDS(intel_sdvo_connector)) { | 1746 | if (intel_sdvo_connector->flicker_filter_2d) |
1719 | if (intel_sdvo_connector->brightness_property) | 1747 | drm_property_destroy(dev, intel_sdvo_connector->flicker_filter_2d); |
1720 | drm_property_destroy(dev, | 1748 | if (intel_sdvo_connector->flicker_filter_adaptive) |
1721 | intel_sdvo_connector->brightness_property); | 1749 | drm_property_destroy(dev, intel_sdvo_connector->flicker_filter_adaptive); |
1722 | } | 1750 | if (intel_sdvo_connector->tv_luma_filter) |
1723 | return; | 1751 | drm_property_destroy(dev, intel_sdvo_connector->tv_luma_filter); |
1752 | if (intel_sdvo_connector->tv_chroma_filter) | ||
1753 | drm_property_destroy(dev, intel_sdvo_connector->tv_chroma_filter); | ||
1754 | if (intel_sdvo_connector->brightness) | ||
1755 | drm_property_destroy(dev, intel_sdvo_connector->brightness); | ||
1724 | } | 1756 | } |
1725 | 1757 | ||
1726 | static void intel_sdvo_destroy(struct drm_connector *connector) | 1758 | static void intel_sdvo_destroy(struct drm_connector *connector) |
1727 | { | 1759 | { |
1728 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); | 1760 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); |
1729 | 1761 | ||
1730 | if (intel_sdvo_connector->tv_format_property) | 1762 | if (intel_sdvo_connector->tv_format) |
1731 | drm_property_destroy(connector->dev, | 1763 | drm_property_destroy(connector->dev, |
1732 | intel_sdvo_connector->tv_format_property); | 1764 | intel_sdvo_connector->tv_format); |
1733 | 1765 | ||
1734 | intel_sdvo_destroy_enhance_property(connector); | 1766 | intel_sdvo_destroy_enhance_property(connector); |
1735 | drm_sysfs_connector_remove(connector); | 1767 | drm_sysfs_connector_remove(connector); |
@@ -1745,8 +1777,6 @@ intel_sdvo_set_property(struct drm_connector *connector, | |||
1745 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1777 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
1746 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | 1778 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); |
1747 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); | 1779 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); |
1748 | struct drm_crtc *crtc = encoder->crtc; | ||
1749 | bool changed = false; | ||
1750 | uint16_t temp_value; | 1780 | uint16_t temp_value; |
1751 | uint8_t cmd; | 1781 | uint8_t cmd; |
1752 | int ret; | 1782 | int ret; |
@@ -1755,7 +1785,16 @@ intel_sdvo_set_property(struct drm_connector *connector, | |||
1755 | if (ret) | 1785 | if (ret) |
1756 | return ret; | 1786 | return ret; |
1757 | 1787 | ||
1758 | if (property == intel_sdvo_connector->tv_format_property) { | 1788 | #define CHECK_PROPERTY(name, NAME) \ |
1789 | if (intel_sdvo_connector->name == property) { \ | ||
1790 | if (intel_sdvo_connector->cur_##name == temp_value) return 0; \ | ||
1791 | if (intel_sdvo_connector->max_##name < temp_value) return -EINVAL; \ | ||
1792 | cmd = SDVO_CMD_SET_##NAME; \ | ||
1793 | intel_sdvo_connector->cur_##name = temp_value; \ | ||
1794 | goto set_value; \ | ||
1795 | } | ||
1796 | |||
1797 | if (property == intel_sdvo_connector->tv_format) { | ||
1759 | if (val >= TV_FORMAT_NUM) | 1798 | if (val >= TV_FORMAT_NUM) |
1760 | return -EINVAL; | 1799 | return -EINVAL; |
1761 | 1800 | ||
@@ -1764,24 +1803,24 @@ intel_sdvo_set_property(struct drm_connector *connector, | |||
1764 | return 0; | 1803 | return 0; |
1765 | 1804 | ||
1766 | intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[val]; | 1805 | intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[val]; |
1767 | changed = true; | 1806 | goto done; |
1768 | } else if (IS_TV_OR_LVDS(intel_sdvo_connector)) { | 1807 | } else if (IS_TV_OR_LVDS(intel_sdvo_connector)) { |
1769 | cmd = 0; | ||
1770 | temp_value = val; | 1808 | temp_value = val; |
1771 | if (intel_sdvo_connector->left_property == property) { | 1809 | if (intel_sdvo_connector->left == property) { |
1772 | drm_connector_property_set_value(connector, | 1810 | drm_connector_property_set_value(connector, |
1773 | intel_sdvo_connector->right_property, val); | 1811 | intel_sdvo_connector->right, val); |
1774 | if (intel_sdvo_connector->left_margin == temp_value) | 1812 | if (intel_sdvo_connector->left_margin == temp_value) |
1775 | return 0; | 1813 | return 0; |
1776 | 1814 | ||
1777 | intel_sdvo_connector->left_margin = temp_value; | 1815 | intel_sdvo_connector->left_margin = temp_value; |
1778 | intel_sdvo_connector->right_margin = temp_value; | 1816 | intel_sdvo_connector->right_margin = temp_value; |
1779 | temp_value = intel_sdvo_connector->max_hscan - | 1817 | temp_value = intel_sdvo_connector->max_hscan - |
1780 | intel_sdvo_connector->left_margin; | 1818 | intel_sdvo_connector->left_margin; |
1781 | cmd = SDVO_CMD_SET_OVERSCAN_H; | 1819 | cmd = SDVO_CMD_SET_OVERSCAN_H; |
1782 | } else if (intel_sdvo_connector->right_property == property) { | 1820 | goto set_value; |
1821 | } else if (intel_sdvo_connector->right == property) { | ||
1783 | drm_connector_property_set_value(connector, | 1822 | drm_connector_property_set_value(connector, |
1784 | intel_sdvo_connector->left_property, val); | 1823 | intel_sdvo_connector->left, val); |
1785 | if (intel_sdvo_connector->right_margin == temp_value) | 1824 | if (intel_sdvo_connector->right_margin == temp_value) |
1786 | return 0; | 1825 | return 0; |
1787 | 1826 | ||
@@ -1790,76 +1829,63 @@ intel_sdvo_set_property(struct drm_connector *connector, | |||
1790 | temp_value = intel_sdvo_connector->max_hscan - | 1829 | temp_value = intel_sdvo_connector->max_hscan - |
1791 | intel_sdvo_connector->left_margin; | 1830 | intel_sdvo_connector->left_margin; |
1792 | cmd = SDVO_CMD_SET_OVERSCAN_H; | 1831 | cmd = SDVO_CMD_SET_OVERSCAN_H; |
1793 | } else if (intel_sdvo_connector->top_property == property) { | 1832 | goto set_value; |
1833 | } else if (intel_sdvo_connector->top == property) { | ||
1794 | drm_connector_property_set_value(connector, | 1834 | drm_connector_property_set_value(connector, |
1795 | intel_sdvo_connector->bottom_property, val); | 1835 | intel_sdvo_connector->bottom, val); |
1796 | if (intel_sdvo_connector->top_margin == temp_value) | 1836 | if (intel_sdvo_connector->top_margin == temp_value) |
1797 | return 0; | 1837 | return 0; |
1798 | 1838 | ||
1799 | intel_sdvo_connector->top_margin = temp_value; | 1839 | intel_sdvo_connector->top_margin = temp_value; |
1800 | intel_sdvo_connector->bottom_margin = temp_value; | 1840 | intel_sdvo_connector->bottom_margin = temp_value; |
1801 | temp_value = intel_sdvo_connector->max_vscan - | 1841 | temp_value = intel_sdvo_connector->max_vscan - |
1802 | intel_sdvo_connector->top_margin; | 1842 | intel_sdvo_connector->top_margin; |
1803 | cmd = SDVO_CMD_SET_OVERSCAN_V; | 1843 | cmd = SDVO_CMD_SET_OVERSCAN_V; |
1804 | } else if (intel_sdvo_connector->bottom_property == property) { | 1844 | goto set_value; |
1845 | } else if (intel_sdvo_connector->bottom == property) { | ||
1805 | drm_connector_property_set_value(connector, | 1846 | drm_connector_property_set_value(connector, |
1806 | intel_sdvo_connector->top_property, val); | 1847 | intel_sdvo_connector->top, val); |
1807 | if (intel_sdvo_connector->bottom_margin == temp_value) | 1848 | if (intel_sdvo_connector->bottom_margin == temp_value) |
1808 | return 0; | 1849 | return 0; |
1809 | 1850 | ||
1810 | intel_sdvo_connector->top_margin = temp_value; | 1851 | intel_sdvo_connector->top_margin = temp_value; |
1811 | intel_sdvo_connector->bottom_margin = temp_value; | 1852 | intel_sdvo_connector->bottom_margin = temp_value; |
1812 | temp_value = intel_sdvo_connector->max_vscan - | 1853 | temp_value = intel_sdvo_connector->max_vscan - |
1813 | intel_sdvo_connector->top_margin; | 1854 | intel_sdvo_connector->top_margin; |
1814 | cmd = SDVO_CMD_SET_OVERSCAN_V; | 1855 | cmd = SDVO_CMD_SET_OVERSCAN_V; |
1815 | } else if (intel_sdvo_connector->hpos_property == property) { | 1856 | goto set_value; |
1816 | if (intel_sdvo_connector->cur_hpos == temp_value) | 1857 | } |
1817 | return 0; | 1858 | CHECK_PROPERTY(hpos, HPOS) |
1818 | 1859 | CHECK_PROPERTY(vpos, VPOS) | |
1819 | cmd = SDVO_CMD_SET_POSITION_H; | 1860 | CHECK_PROPERTY(saturation, SATURATION) |
1820 | intel_sdvo_connector->cur_hpos = temp_value; | 1861 | CHECK_PROPERTY(contrast, CONTRAST) |
1821 | } else if (intel_sdvo_connector->vpos_property == property) { | 1862 | CHECK_PROPERTY(hue, HUE) |
1822 | if (intel_sdvo_connector->cur_vpos == temp_value) | 1863 | CHECK_PROPERTY(brightness, BRIGHTNESS) |
1823 | return 0; | 1864 | CHECK_PROPERTY(sharpness, SHARPNESS) |
1824 | 1865 | CHECK_PROPERTY(flicker_filter, FLICKER_FILTER) | |
1825 | cmd = SDVO_CMD_SET_POSITION_V; | 1866 | CHECK_PROPERTY(flicker_filter_2d, FLICKER_FILTER_2D) |
1826 | intel_sdvo_connector->cur_vpos = temp_value; | 1867 | CHECK_PROPERTY(flicker_filter_adaptive, FLICKER_FILTER_ADAPTIVE) |
1827 | } else if (intel_sdvo_connector->saturation_property == property) { | 1868 | CHECK_PROPERTY(tv_chroma_filter, TV_CHROMA_FILTER) |
1828 | if (intel_sdvo_connector->cur_saturation == temp_value) | 1869 | CHECK_PROPERTY(tv_luma_filter, TV_LUMA_FILTER) |
1829 | return 0; | 1870 | } |
1830 | 1871 | ||
1831 | cmd = SDVO_CMD_SET_SATURATION; | 1872 | return -EINVAL; /* unknown property */ |
1832 | intel_sdvo_connector->cur_saturation = temp_value; | ||
1833 | } else if (intel_sdvo_connector->contrast_property == property) { | ||
1834 | if (intel_sdvo_connector->cur_contrast == temp_value) | ||
1835 | return 0; | ||
1836 | 1873 | ||
1837 | cmd = SDVO_CMD_SET_CONTRAST; | 1874 | set_value: |
1838 | intel_sdvo_connector->cur_contrast = temp_value; | 1875 | if (!intel_sdvo_set_value(intel_sdvo, cmd, &temp_value, 2)) |
1839 | } else if (intel_sdvo_connector->hue_property == property) { | 1876 | return -EIO; |
1840 | if (intel_sdvo_connector->cur_hue == temp_value) | ||
1841 | return 0; | ||
1842 | 1877 | ||
1843 | cmd = SDVO_CMD_SET_HUE; | ||
1844 | intel_sdvo_connector->cur_hue = temp_value; | ||
1845 | } else if (intel_sdvo_connector->brightness_property == property) { | ||
1846 | if (intel_sdvo_connector->cur_brightness == temp_value) | ||
1847 | return 0; | ||
1848 | 1878 | ||
1849 | cmd = SDVO_CMD_SET_BRIGHTNESS; | 1879 | done: |
1850 | intel_sdvo_connector->cur_brightness = temp_value; | 1880 | if (encoder->crtc) { |
1851 | } | 1881 | struct drm_crtc *crtc = encoder->crtc; |
1852 | if (cmd) { | ||
1853 | if (!intel_sdvo_set_value(intel_sdvo, cmd, &temp_value, 2)) | ||
1854 | return -EINVAL; | ||
1855 | 1882 | ||
1856 | changed = true; | ||
1857 | } | ||
1858 | } | ||
1859 | if (changed && crtc) | ||
1860 | drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x, | 1883 | drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x, |
1861 | crtc->y, crtc->fb); | 1884 | crtc->y, crtc->fb); |
1885 | } | ||
1886 | |||
1862 | return 0; | 1887 | return 0; |
1888 | #undef CHECK_PROPERTY | ||
1863 | } | 1889 | } |
1864 | 1890 | ||
1865 | static const struct drm_encoder_helper_funcs intel_sdvo_helper_funcs = { | 1891 | static const struct drm_encoder_helper_funcs intel_sdvo_helper_funcs = { |
@@ -2268,296 +2294,194 @@ static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, | |||
2268 | intel_sdvo_connector->tv_format_supported[intel_sdvo_connector->format_supported_num++] = i; | 2294 | intel_sdvo_connector->tv_format_supported[intel_sdvo_connector->format_supported_num++] = i; |
2269 | 2295 | ||
2270 | 2296 | ||
2271 | intel_sdvo_connector->tv_format_property = | 2297 | intel_sdvo_connector->tv_format = |
2272 | drm_property_create(dev, DRM_MODE_PROP_ENUM, | 2298 | drm_property_create(dev, DRM_MODE_PROP_ENUM, |
2273 | "mode", intel_sdvo_connector->format_supported_num); | 2299 | "mode", intel_sdvo_connector->format_supported_num); |
2274 | if (!intel_sdvo_connector->tv_format_property) | 2300 | if (!intel_sdvo_connector->tv_format) |
2275 | return false; | 2301 | return false; |
2276 | 2302 | ||
2277 | for (i = 0; i < intel_sdvo_connector->format_supported_num; i++) | 2303 | for (i = 0; i < intel_sdvo_connector->format_supported_num; i++) |
2278 | drm_property_add_enum( | 2304 | drm_property_add_enum( |
2279 | intel_sdvo_connector->tv_format_property, i, | 2305 | intel_sdvo_connector->tv_format, i, |
2280 | i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); | 2306 | i, tv_format_names[intel_sdvo_connector->tv_format_supported[i]]); |
2281 | 2307 | ||
2282 | intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[0]; | 2308 | intel_sdvo->tv_format_index = intel_sdvo_connector->tv_format_supported[0]; |
2283 | drm_connector_attach_property(&intel_sdvo_connector->base.base, | 2309 | drm_connector_attach_property(&intel_sdvo_connector->base.base, |
2284 | intel_sdvo_connector->tv_format_property, 0); | 2310 | intel_sdvo_connector->tv_format, 0); |
2285 | return true; | 2311 | return true; |
2286 | 2312 | ||
2287 | } | 2313 | } |
2288 | 2314 | ||
2289 | static bool intel_sdvo_create_enhance_property(struct intel_sdvo *intel_sdvo, | 2315 | #define ENHANCEMENT(name, NAME) do { \ |
2290 | struct intel_sdvo_connector *intel_sdvo_connector) | 2316 | if (enhancements.name) { \ |
2317 | if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_MAX_##NAME, &data_value, 4) || \ | ||
2318 | !intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_##NAME, &response, 2)) \ | ||
2319 | return false; \ | ||
2320 | intel_sdvo_connector->max_##name = data_value[0]; \ | ||
2321 | intel_sdvo_connector->cur_##name = response; \ | ||
2322 | intel_sdvo_connector->name = \ | ||
2323 | drm_property_create(dev, DRM_MODE_PROP_RANGE, #name, 2); \ | ||
2324 | if (!intel_sdvo_connector->name) return false; \ | ||
2325 | intel_sdvo_connector->name->values[0] = 0; \ | ||
2326 | intel_sdvo_connector->name->values[1] = data_value[0]; \ | ||
2327 | drm_connector_attach_property(connector, \ | ||
2328 | intel_sdvo_connector->name, \ | ||
2329 | intel_sdvo_connector->cur_##name); \ | ||
2330 | DRM_DEBUG_KMS(#name ": max %d, default %d, current %d\n", \ | ||
2331 | data_value[0], data_value[1], response); \ | ||
2332 | } \ | ||
2333 | } while(0) | ||
2334 | |||
2335 | static bool | ||
2336 | intel_sdvo_create_enhance_property_tv(struct intel_sdvo *intel_sdvo, | ||
2337 | struct intel_sdvo_connector *intel_sdvo_connector, | ||
2338 | struct intel_sdvo_enhancements_reply enhancements) | ||
2291 | { | 2339 | { |
2292 | struct drm_device *dev = intel_sdvo->base.enc.dev; | 2340 | struct drm_device *dev = intel_sdvo->base.enc.dev; |
2293 | struct drm_connector *connector = &intel_sdvo_connector->base.base; | 2341 | struct drm_connector *connector = &intel_sdvo_connector->base.base; |
2294 | struct intel_sdvo_enhancements_reply sdvo_data; | ||
2295 | uint16_t response, data_value[2]; | 2342 | uint16_t response, data_value[2]; |
2296 | 2343 | ||
2297 | if (!intel_sdvo_get_value(intel_sdvo, | 2344 | /* when horizontal overscan is supported, Add the left/right property */ |
2298 | SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS, | 2345 | if (enhancements.overscan_h) { |
2299 | &sdvo_data, sizeof(sdvo_data))) | 2346 | if (!intel_sdvo_get_value(intel_sdvo, |
2300 | return false; | 2347 | SDVO_CMD_GET_MAX_OVERSCAN_H, |
2301 | 2348 | &data_value, 4)) | |
2302 | response = *((uint16_t *)&sdvo_data); | 2349 | return false; |
2303 | if (!response) { | ||
2304 | DRM_DEBUG_KMS("No enhancement is supported\n"); | ||
2305 | return true; | ||
2306 | } | ||
2307 | if (IS_TV(intel_sdvo_connector)) { | ||
2308 | /* when horizontal overscan is supported, Add the left/right | ||
2309 | * property | ||
2310 | */ | ||
2311 | if (sdvo_data.overscan_h) { | ||
2312 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2313 | SDVO_CMD_GET_MAX_OVERSCAN_H, | ||
2314 | &data_value, 4)) | ||
2315 | return false; | ||
2316 | |||
2317 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2318 | SDVO_CMD_GET_OVERSCAN_H, | ||
2319 | &response, 2)) | ||
2320 | return false; | ||
2321 | |||
2322 | intel_sdvo_connector->max_hscan = data_value[0]; | ||
2323 | intel_sdvo_connector->left_margin = data_value[0] - response; | ||
2324 | intel_sdvo_connector->right_margin = intel_sdvo_connector->left_margin; | ||
2325 | intel_sdvo_connector->left_property = | ||
2326 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | ||
2327 | "left_margin", 2); | ||
2328 | if (!intel_sdvo_connector->left_property) | ||
2329 | return false; | ||
2330 | |||
2331 | intel_sdvo_connector->left_property->values[0] = 0; | ||
2332 | intel_sdvo_connector->left_property->values[1] = data_value[0]; | ||
2333 | drm_connector_attach_property(connector, | ||
2334 | intel_sdvo_connector->left_property, | ||
2335 | intel_sdvo_connector->left_margin); | ||
2336 | |||
2337 | intel_sdvo_connector->right_property = | ||
2338 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | ||
2339 | "right_margin", 2); | ||
2340 | if (!intel_sdvo_connector->right_property) | ||
2341 | return false; | ||
2342 | |||
2343 | intel_sdvo_connector->right_property->values[0] = 0; | ||
2344 | intel_sdvo_connector->right_property->values[1] = data_value[0]; | ||
2345 | drm_connector_attach_property(connector, | ||
2346 | intel_sdvo_connector->right_property, | ||
2347 | intel_sdvo_connector->right_margin); | ||
2348 | DRM_DEBUG_KMS("h_overscan: max %d, " | ||
2349 | "default %d, current %d\n", | ||
2350 | data_value[0], data_value[1], response); | ||
2351 | } | ||
2352 | if (sdvo_data.overscan_v) { | ||
2353 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2354 | SDVO_CMD_GET_MAX_OVERSCAN_V, | ||
2355 | &data_value, 4)) | ||
2356 | return false; | ||
2357 | |||
2358 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2359 | SDVO_CMD_GET_OVERSCAN_V, | ||
2360 | &response, 2)) | ||
2361 | return false; | ||
2362 | 2350 | ||
2363 | intel_sdvo_connector->max_vscan = data_value[0]; | 2351 | if (!intel_sdvo_get_value(intel_sdvo, |
2364 | intel_sdvo_connector->top_margin = data_value[0] - response; | 2352 | SDVO_CMD_GET_OVERSCAN_H, |
2365 | intel_sdvo_connector->bottom_margin = intel_sdvo_connector->top_margin; | 2353 | &response, 2)) |
2366 | intel_sdvo_connector->top_property = | 2354 | return false; |
2367 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | ||
2368 | "top_margin", 2); | ||
2369 | if (!intel_sdvo_connector->top_property) | ||
2370 | return false; | ||
2371 | 2355 | ||
2372 | intel_sdvo_connector->top_property->values[0] = 0; | 2356 | intel_sdvo_connector->max_hscan = data_value[0]; |
2373 | intel_sdvo_connector->top_property->values[1] = data_value[0]; | 2357 | intel_sdvo_connector->left_margin = data_value[0] - response; |
2374 | drm_connector_attach_property(connector, | 2358 | intel_sdvo_connector->right_margin = intel_sdvo_connector->left_margin; |
2375 | intel_sdvo_connector->top_property, | 2359 | intel_sdvo_connector->left = |
2376 | intel_sdvo_connector->top_margin); | 2360 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
2361 | "left_margin", 2); | ||
2362 | if (!intel_sdvo_connector->left) | ||
2363 | return false; | ||
2377 | 2364 | ||
2378 | intel_sdvo_connector->bottom_property = | 2365 | intel_sdvo_connector->left->values[0] = 0; |
2379 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | 2366 | intel_sdvo_connector->left->values[1] = data_value[0]; |
2380 | "bottom_margin", 2); | 2367 | drm_connector_attach_property(connector, |
2381 | if (!intel_sdvo_connector->bottom_property) | 2368 | intel_sdvo_connector->left, |
2382 | return false; | 2369 | intel_sdvo_connector->left_margin); |
2383 | 2370 | ||
2384 | intel_sdvo_connector->bottom_property->values[0] = 0; | 2371 | intel_sdvo_connector->right = |
2385 | intel_sdvo_connector->bottom_property->values[1] = data_value[0]; | 2372 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
2386 | drm_connector_attach_property(connector, | 2373 | "right_margin", 2); |
2387 | intel_sdvo_connector->bottom_property, | 2374 | if (!intel_sdvo_connector->right) |
2388 | intel_sdvo_connector->bottom_margin); | 2375 | return false; |
2389 | DRM_DEBUG_KMS("v_overscan: max %d, " | ||
2390 | "default %d, current %d\n", | ||
2391 | data_value[0], data_value[1], response); | ||
2392 | } | ||
2393 | if (sdvo_data.position_h) { | ||
2394 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2395 | SDVO_CMD_GET_MAX_POSITION_H, | ||
2396 | &data_value, 4)) | ||
2397 | return false; | ||
2398 | 2376 | ||
2399 | if (!intel_sdvo_get_value(intel_sdvo, | 2377 | intel_sdvo_connector->right->values[0] = 0; |
2400 | SDVO_CMD_GET_POSITION_H, | 2378 | intel_sdvo_connector->right->values[1] = data_value[0]; |
2401 | &response, 2)) | 2379 | drm_connector_attach_property(connector, |
2402 | return false; | 2380 | intel_sdvo_connector->right, |
2381 | intel_sdvo_connector->right_margin); | ||
2382 | DRM_DEBUG_KMS("h_overscan: max %d, " | ||
2383 | "default %d, current %d\n", | ||
2384 | data_value[0], data_value[1], response); | ||
2385 | } | ||
2403 | 2386 | ||
2404 | intel_sdvo_connector->max_hpos = data_value[0]; | 2387 | if (enhancements.overscan_v) { |
2405 | intel_sdvo_connector->cur_hpos = response; | 2388 | if (!intel_sdvo_get_value(intel_sdvo, |
2406 | intel_sdvo_connector->hpos_property = | 2389 | SDVO_CMD_GET_MAX_OVERSCAN_V, |
2407 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | 2390 | &data_value, 4)) |
2408 | "hpos", 2); | 2391 | return false; |
2409 | if (!intel_sdvo_connector->hpos_property) | ||
2410 | return false; | ||
2411 | 2392 | ||
2412 | intel_sdvo_connector->hpos_property->values[0] = 0; | 2393 | if (!intel_sdvo_get_value(intel_sdvo, |
2413 | intel_sdvo_connector->hpos_property->values[1] = data_value[0]; | 2394 | SDVO_CMD_GET_OVERSCAN_V, |
2414 | drm_connector_attach_property(connector, | 2395 | &response, 2)) |
2415 | intel_sdvo_connector->hpos_property, | 2396 | return false; |
2416 | intel_sdvo_connector->cur_hpos); | ||
2417 | DRM_DEBUG_KMS("h_position: max %d, " | ||
2418 | "default %d, current %d\n", | ||
2419 | data_value[0], data_value[1], response); | ||
2420 | } | ||
2421 | if (sdvo_data.position_v) { | ||
2422 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2423 | SDVO_CMD_GET_MAX_POSITION_V, | ||
2424 | &data_value, 4)) | ||
2425 | return false; | ||
2426 | 2397 | ||
2427 | if (!intel_sdvo_get_value(intel_sdvo, | 2398 | intel_sdvo_connector->max_vscan = data_value[0]; |
2428 | SDVO_CMD_GET_POSITION_V, | 2399 | intel_sdvo_connector->top_margin = data_value[0] - response; |
2429 | &response, 2)) | 2400 | intel_sdvo_connector->bottom_margin = intel_sdvo_connector->top_margin; |
2430 | return false; | 2401 | intel_sdvo_connector->top = |
2402 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | ||
2403 | "top_margin", 2); | ||
2404 | if (!intel_sdvo_connector->top) | ||
2405 | return false; | ||
2431 | 2406 | ||
2432 | intel_sdvo_connector->max_vpos = data_value[0]; | 2407 | intel_sdvo_connector->top->values[0] = 0; |
2433 | intel_sdvo_connector->cur_vpos = response; | 2408 | intel_sdvo_connector->top->values[1] = data_value[0]; |
2434 | intel_sdvo_connector->vpos_property = | 2409 | drm_connector_attach_property(connector, |
2435 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | 2410 | intel_sdvo_connector->top, |
2436 | "vpos", 2); | 2411 | intel_sdvo_connector->top_margin); |
2437 | if (!intel_sdvo_connector->vpos_property) | ||
2438 | return false; | ||
2439 | 2412 | ||
2440 | intel_sdvo_connector->vpos_property->values[0] = 0; | 2413 | intel_sdvo_connector->bottom = |
2441 | intel_sdvo_connector->vpos_property->values[1] = data_value[0]; | 2414 | drm_property_create(dev, DRM_MODE_PROP_RANGE, |
2442 | drm_connector_attach_property(connector, | 2415 | "bottom_margin", 2); |
2443 | intel_sdvo_connector->vpos_property, | 2416 | if (!intel_sdvo_connector->bottom) |
2444 | intel_sdvo_connector->cur_vpos); | 2417 | return false; |
2445 | DRM_DEBUG_KMS("v_position: max %d, " | ||
2446 | "default %d, current %d\n", | ||
2447 | data_value[0], data_value[1], response); | ||
2448 | } | ||
2449 | if (sdvo_data.saturation) { | ||
2450 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2451 | SDVO_CMD_GET_MAX_SATURATION, | ||
2452 | &data_value, 4)) | ||
2453 | return false; | ||
2454 | 2418 | ||
2455 | if (!intel_sdvo_get_value(intel_sdvo, | 2419 | intel_sdvo_connector->bottom->values[0] = 0; |
2456 | SDVO_CMD_GET_SATURATION, | 2420 | intel_sdvo_connector->bottom->values[1] = data_value[0]; |
2457 | &response, 2)) | 2421 | drm_connector_attach_property(connector, |
2458 | return false; | 2422 | intel_sdvo_connector->bottom, |
2423 | intel_sdvo_connector->bottom_margin); | ||
2424 | DRM_DEBUG_KMS("v_overscan: max %d, " | ||
2425 | "default %d, current %d\n", | ||
2426 | data_value[0], data_value[1], response); | ||
2427 | } | ||
2459 | 2428 | ||
2460 | intel_sdvo_connector->max_saturation = data_value[0]; | 2429 | ENHANCEMENT(hpos, HPOS); |
2461 | intel_sdvo_connector->cur_saturation = response; | 2430 | ENHANCEMENT(vpos, VPOS); |
2462 | intel_sdvo_connector->saturation_property = | 2431 | ENHANCEMENT(saturation, SATURATION); |
2463 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | 2432 | ENHANCEMENT(contrast, CONTRAST); |
2464 | "saturation", 2); | 2433 | ENHANCEMENT(hue, HUE); |
2465 | if (!intel_sdvo_connector->saturation_property) | 2434 | ENHANCEMENT(sharpness, SHARPNESS); |
2466 | return false; | 2435 | ENHANCEMENT(brightness, BRIGHTNESS); |
2436 | ENHANCEMENT(flicker_filter, FLICKER_FILTER); | ||
2437 | ENHANCEMENT(flicker_filter_adaptive, FLICKER_FILTER_ADAPTIVE); | ||
2438 | ENHANCEMENT(flicker_filter_2d, FLICKER_FILTER_2D); | ||
2439 | ENHANCEMENT(tv_chroma_filter, TV_CHROMA_FILTER); | ||
2440 | ENHANCEMENT(tv_luma_filter, TV_LUMA_FILTER); | ||
2467 | 2441 | ||
2468 | intel_sdvo_connector->saturation_property->values[0] = 0; | 2442 | return true; |
2469 | intel_sdvo_connector->saturation_property->values[1] = | 2443 | } |
2470 | data_value[0]; | ||
2471 | drm_connector_attach_property(connector, | ||
2472 | intel_sdvo_connector->saturation_property, | ||
2473 | intel_sdvo_connector->cur_saturation); | ||
2474 | DRM_DEBUG_KMS("saturation: max %d, " | ||
2475 | "default %d, current %d\n", | ||
2476 | data_value[0], data_value[1], response); | ||
2477 | } | ||
2478 | if (sdvo_data.contrast) { | ||
2479 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2480 | SDVO_CMD_GET_MAX_CONTRAST, &data_value, 4)) | ||
2481 | return false; | ||
2482 | 2444 | ||
2483 | if (!intel_sdvo_get_value(intel_sdvo, | 2445 | static bool |
2484 | SDVO_CMD_GET_CONTRAST, &response, 2)) | 2446 | intel_sdvo_create_enhance_property_lvds(struct intel_sdvo *intel_sdvo, |
2485 | return false; | 2447 | struct intel_sdvo_connector *intel_sdvo_connector, |
2448 | struct intel_sdvo_enhancements_reply enhancements) | ||
2449 | { | ||
2450 | struct drm_device *dev = intel_sdvo->base.enc.dev; | ||
2451 | struct drm_connector *connector = &intel_sdvo_connector->base.base; | ||
2452 | uint16_t response, data_value[2]; | ||
2486 | 2453 | ||
2487 | intel_sdvo_connector->max_contrast = data_value[0]; | 2454 | ENHANCEMENT(brightness, BRIGHTNESS); |
2488 | intel_sdvo_connector->cur_contrast = response; | ||
2489 | intel_sdvo_connector->contrast_property = | ||
2490 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | ||
2491 | "contrast", 2); | ||
2492 | if (!intel_sdvo_connector->contrast_property) | ||
2493 | return false; | ||
2494 | 2455 | ||
2495 | intel_sdvo_connector->contrast_property->values[0] = 0; | 2456 | return true; |
2496 | intel_sdvo_connector->contrast_property->values[1] = data_value[0]; | 2457 | } |
2497 | drm_connector_attach_property(connector, | 2458 | #undef ENHANCEMENT |
2498 | intel_sdvo_connector->contrast_property, | ||
2499 | intel_sdvo_connector->cur_contrast); | ||
2500 | DRM_DEBUG_KMS("contrast: max %d, " | ||
2501 | "default %d, current %d\n", | ||
2502 | data_value[0], data_value[1], response); | ||
2503 | } | ||
2504 | if (sdvo_data.hue) { | ||
2505 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2506 | SDVO_CMD_GET_MAX_HUE, &data_value, 4)) | ||
2507 | return false; | ||
2508 | 2459 | ||
2509 | if (!intel_sdvo_get_value(intel_sdvo, | 2460 | static bool intel_sdvo_create_enhance_property(struct intel_sdvo *intel_sdvo, |
2510 | SDVO_CMD_GET_HUE, &response, 2)) | 2461 | struct intel_sdvo_connector *intel_sdvo_connector) |
2511 | return false; | 2462 | { |
2463 | union { | ||
2464 | struct intel_sdvo_enhancements_reply reply; | ||
2465 | uint16_t response; | ||
2466 | } enhancements; | ||
2512 | 2467 | ||
2513 | intel_sdvo_connector->max_hue = data_value[0]; | 2468 | if (!intel_sdvo_get_value(intel_sdvo, |
2514 | intel_sdvo_connector->cur_hue = response; | 2469 | SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS, |
2515 | intel_sdvo_connector->hue_property = | 2470 | &enhancements, sizeof(enhancements))) |
2516 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | 2471 | return false; |
2517 | "hue", 2); | ||
2518 | if (!intel_sdvo_connector->hue_property) | ||
2519 | return false; | ||
2520 | 2472 | ||
2521 | intel_sdvo_connector->hue_property->values[0] = 0; | 2473 | if (enhancements.response == 0) { |
2522 | intel_sdvo_connector->hue_property->values[1] = | 2474 | DRM_DEBUG_KMS("No enhancement is supported\n"); |
2523 | data_value[0]; | 2475 | return true; |
2524 | drm_connector_attach_property(connector, | ||
2525 | intel_sdvo_connector->hue_property, | ||
2526 | intel_sdvo_connector->cur_hue); | ||
2527 | DRM_DEBUG_KMS("hue: max %d, default %d, current %d\n", | ||
2528 | data_value[0], data_value[1], response); | ||
2529 | } | ||
2530 | } | 2476 | } |
2531 | if (IS_TV_OR_LVDS(intel_sdvo_connector)) { | ||
2532 | if (sdvo_data.brightness) { | ||
2533 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2534 | SDVO_CMD_GET_MAX_BRIGHTNESS, &data_value, 4)) | ||
2535 | return false; | ||
2536 | |||
2537 | if (!intel_sdvo_get_value(intel_sdvo, | ||
2538 | SDVO_CMD_GET_BRIGHTNESS, &response, 2)) | ||
2539 | return false; | ||
2540 | 2477 | ||
2541 | intel_sdvo_connector->max_brightness = data_value[0]; | 2478 | if (IS_TV(intel_sdvo_connector)) |
2542 | intel_sdvo_connector->cur_brightness = response; | 2479 | return intel_sdvo_create_enhance_property_tv(intel_sdvo, intel_sdvo_connector, enhancements.reply); |
2543 | intel_sdvo_connector->brightness_property = | 2480 | else if(IS_LVDS(intel_sdvo_connector)) |
2544 | drm_property_create(dev, DRM_MODE_PROP_RANGE, | 2481 | return intel_sdvo_create_enhance_property_lvds(intel_sdvo, intel_sdvo_connector, enhancements.reply); |
2545 | "brightness", 2); | 2482 | else |
2546 | if (!intel_sdvo_connector->brightness_property) | 2483 | return true; |
2547 | return false; | ||
2548 | 2484 | ||
2549 | intel_sdvo_connector->brightness_property->values[0] = 0; | ||
2550 | intel_sdvo_connector->brightness_property->values[1] = | ||
2551 | data_value[0]; | ||
2552 | drm_connector_attach_property(connector, | ||
2553 | intel_sdvo_connector->brightness_property, | ||
2554 | intel_sdvo_connector->cur_brightness); | ||
2555 | DRM_DEBUG_KMS("brightness: max %d, " | ||
2556 | "default %d, current %d\n", | ||
2557 | data_value[0], data_value[1], response); | ||
2558 | } | ||
2559 | } | ||
2560 | return true; | ||
2561 | } | 2485 | } |
2562 | 2486 | ||
2563 | bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg) | 2487 | bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg) |
diff --git a/drivers/gpu/drm/i915/intel_sdvo_regs.h b/drivers/gpu/drm/i915/intel_sdvo_regs.h index 4988660f661b..a386b022e538 100644 --- a/drivers/gpu/drm/i915/intel_sdvo_regs.h +++ b/drivers/gpu/drm/i915/intel_sdvo_regs.h | |||
@@ -596,32 +596,32 @@ struct intel_sdvo_enhancements_reply { | |||
596 | unsigned int overscan_h:1; | 596 | unsigned int overscan_h:1; |
597 | 597 | ||
598 | unsigned int overscan_v:1; | 598 | unsigned int overscan_v:1; |
599 | unsigned int position_h:1; | 599 | unsigned int hpos:1; |
600 | unsigned int position_v:1; | 600 | unsigned int vpos:1; |
601 | unsigned int sharpness:1; | 601 | unsigned int sharpness:1; |
602 | unsigned int dot_crawl:1; | 602 | unsigned int dot_crawl:1; |
603 | unsigned int dither:1; | 603 | unsigned int dither:1; |
604 | unsigned int max_tv_chroma_filter:1; | 604 | unsigned int tv_chroma_filter:1; |
605 | unsigned int max_tv_luma_filter:1; | 605 | unsigned int tv_luma_filter:1; |
606 | } __attribute__((packed)); | 606 | } __attribute__((packed)); |
607 | 607 | ||
608 | /* Picture enhancement limits below are dependent on the current TV format, | 608 | /* Picture enhancement limits below are dependent on the current TV format, |
609 | * and thus need to be queried and set after it. | 609 | * and thus need to be queried and set after it. |
610 | */ | 610 | */ |
611 | #define SDVO_CMD_GET_MAX_FLICKER_FITER 0x4d | 611 | #define SDVO_CMD_GET_MAX_FLICKER_FILTER 0x4d |
612 | #define SDVO_CMD_GET_MAX_ADAPTIVE_FLICKER_FITER 0x7b | 612 | #define SDVO_CMD_GET_MAX_FLICKER_FILTER_ADAPTIVE 0x7b |
613 | #define SDVO_CMD_GET_MAX_2D_FLICKER_FITER 0x52 | 613 | #define SDVO_CMD_GET_MAX_FLICKER_FILTER_2D 0x52 |
614 | #define SDVO_CMD_GET_MAX_SATURATION 0x55 | 614 | #define SDVO_CMD_GET_MAX_SATURATION 0x55 |
615 | #define SDVO_CMD_GET_MAX_HUE 0x58 | 615 | #define SDVO_CMD_GET_MAX_HUE 0x58 |
616 | #define SDVO_CMD_GET_MAX_BRIGHTNESS 0x5b | 616 | #define SDVO_CMD_GET_MAX_BRIGHTNESS 0x5b |
617 | #define SDVO_CMD_GET_MAX_CONTRAST 0x5e | 617 | #define SDVO_CMD_GET_MAX_CONTRAST 0x5e |
618 | #define SDVO_CMD_GET_MAX_OVERSCAN_H 0x61 | 618 | #define SDVO_CMD_GET_MAX_OVERSCAN_H 0x61 |
619 | #define SDVO_CMD_GET_MAX_OVERSCAN_V 0x64 | 619 | #define SDVO_CMD_GET_MAX_OVERSCAN_V 0x64 |
620 | #define SDVO_CMD_GET_MAX_POSITION_H 0x67 | 620 | #define SDVO_CMD_GET_MAX_HPOS 0x67 |
621 | #define SDVO_CMD_GET_MAX_POSITION_V 0x6a | 621 | #define SDVO_CMD_GET_MAX_VPOS 0x6a |
622 | #define SDVO_CMD_GET_MAX_SHARPNESS_V 0x6d | 622 | #define SDVO_CMD_GET_MAX_SHARPNESS 0x6d |
623 | #define SDVO_CMD_GET_MAX_TV_CHROMA 0x74 | 623 | #define SDVO_CMD_GET_MAX_TV_CHROMA_FILTER 0x74 |
624 | #define SDVO_CMD_GET_MAX_TV_LUMA 0x77 | 624 | #define SDVO_CMD_GET_MAX_TV_LUMA_FILTER 0x77 |
625 | struct intel_sdvo_enhancement_limits_reply { | 625 | struct intel_sdvo_enhancement_limits_reply { |
626 | u16 max_value; | 626 | u16 max_value; |
627 | u16 default_value; | 627 | u16 default_value; |
@@ -638,10 +638,10 @@ struct intel_sdvo_enhancement_limits_reply { | |||
638 | 638 | ||
639 | #define SDVO_CMD_GET_FLICKER_FILTER 0x4e | 639 | #define SDVO_CMD_GET_FLICKER_FILTER 0x4e |
640 | #define SDVO_CMD_SET_FLICKER_FILTER 0x4f | 640 | #define SDVO_CMD_SET_FLICKER_FILTER 0x4f |
641 | #define SDVO_CMD_GET_ADAPTIVE_FLICKER_FITER 0x50 | 641 | #define SDVO_CMD_GET_FLICKER_FILTER_ADAPTIVE 0x50 |
642 | #define SDVO_CMD_SET_ADAPTIVE_FLICKER_FITER 0x51 | 642 | #define SDVO_CMD_SET_FLICKER_FILTER_ADAPTIVE 0x51 |
643 | #define SDVO_CMD_GET_2D_FLICKER_FITER 0x53 | 643 | #define SDVO_CMD_GET_FLICKER_FILTER_2D 0x53 |
644 | #define SDVO_CMD_SET_2D_FLICKER_FITER 0x54 | 644 | #define SDVO_CMD_SET_FLICKER_FILTER_2D 0x54 |
645 | #define SDVO_CMD_GET_SATURATION 0x56 | 645 | #define SDVO_CMD_GET_SATURATION 0x56 |
646 | #define SDVO_CMD_SET_SATURATION 0x57 | 646 | #define SDVO_CMD_SET_SATURATION 0x57 |
647 | #define SDVO_CMD_GET_HUE 0x59 | 647 | #define SDVO_CMD_GET_HUE 0x59 |
@@ -654,16 +654,16 @@ struct intel_sdvo_enhancement_limits_reply { | |||
654 | #define SDVO_CMD_SET_OVERSCAN_H 0x63 | 654 | #define SDVO_CMD_SET_OVERSCAN_H 0x63 |
655 | #define SDVO_CMD_GET_OVERSCAN_V 0x65 | 655 | #define SDVO_CMD_GET_OVERSCAN_V 0x65 |
656 | #define SDVO_CMD_SET_OVERSCAN_V 0x66 | 656 | #define SDVO_CMD_SET_OVERSCAN_V 0x66 |
657 | #define SDVO_CMD_GET_POSITION_H 0x68 | 657 | #define SDVO_CMD_GET_HPOS 0x68 |
658 | #define SDVO_CMD_SET_POSITION_H 0x69 | 658 | #define SDVO_CMD_SET_HPOS 0x69 |
659 | #define SDVO_CMD_GET_POSITION_V 0x6b | 659 | #define SDVO_CMD_GET_VPOS 0x6b |
660 | #define SDVO_CMD_SET_POSITION_V 0x6c | 660 | #define SDVO_CMD_SET_VPOS 0x6c |
661 | #define SDVO_CMD_GET_SHARPNESS 0x6e | 661 | #define SDVO_CMD_GET_SHARPNESS 0x6e |
662 | #define SDVO_CMD_SET_SHARPNESS 0x6f | 662 | #define SDVO_CMD_SET_SHARPNESS 0x6f |
663 | #define SDVO_CMD_GET_TV_CHROMA 0x75 | 663 | #define SDVO_CMD_GET_TV_CHROMA_FILTER 0x75 |
664 | #define SDVO_CMD_SET_TV_CHROMA 0x76 | 664 | #define SDVO_CMD_SET_TV_CHROMA_FILTER 0x76 |
665 | #define SDVO_CMD_GET_TV_LUMA 0x78 | 665 | #define SDVO_CMD_GET_TV_LUMA_FILTER 0x78 |
666 | #define SDVO_CMD_SET_TV_LUMA 0x79 | 666 | #define SDVO_CMD_SET_TV_LUMA_FILTER 0x79 |
667 | struct intel_sdvo_enhancements_arg { | 667 | struct intel_sdvo_enhancements_arg { |
668 | u16 value; | 668 | u16 value; |
669 | }__attribute__((packed)); | 669 | }__attribute__((packed)); |