aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-08-04 08:50:24 -0400
committerEric Anholt <eric@anholt.net>2010-08-09 14:24:28 -0400
commit615fb93f6d99cce2ab36dcf09986e321e17c356f (patch)
treee3c614917bfc39df6f029d335bc62edbc281c959 /drivers
parentea5b213ad4b161463e76b63dbb115ea20e2200f0 (diff)
drm/i915: Subclass intel_connector.
Make the code that tiny bit clearer by reducing the pointer dance. 2 files changed, 130 insertions(+), 147 deletions(-) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h1
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c276
2 files changed, 130 insertions, 147 deletions
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 520b22cd708e..1075d4386b87 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -109,7 +109,6 @@ struct intel_encoder {
109 109
110struct intel_connector { 110struct intel_connector {
111 struct drm_connector base; 111 struct drm_connector base;
112 void *dev_priv;
113}; 112};
114 113
115struct intel_crtc; 114struct intel_crtc;
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 2fc9da4c0791..dca123527d5f 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -134,6 +134,8 @@ struct intel_sdvo {
134}; 134};
135 135
136struct intel_sdvo_connector { 136struct intel_sdvo_connector {
137 struct intel_connector base;
138
137 /* Mark the type of connector */ 139 /* Mark the type of connector */
138 uint16_t output_flag; 140 uint16_t output_flag;
139 141
@@ -180,6 +182,11 @@ static struct intel_sdvo *enc_to_intel_sdvo(struct drm_encoder *encoder)
180 return container_of(enc_to_intel_encoder(encoder), struct intel_sdvo, base); 182 return container_of(enc_to_intel_encoder(encoder), struct intel_sdvo, base);
181} 183}
182 184
185static struct intel_sdvo_connector *to_intel_sdvo_connector(struct drm_connector *connector)
186{
187 return container_of(to_intel_connector(connector), struct intel_sdvo_connector, base);
188}
189
183static bool 190static bool
184intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, uint16_t flags); 191intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, uint16_t flags);
185static void 192static void
@@ -1502,8 +1509,7 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1502{ 1509{
1503 struct drm_encoder *encoder = intel_attached_encoder(connector); 1510 struct drm_encoder *encoder = intel_attached_encoder(connector);
1504 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); 1511 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1505 struct intel_connector *intel_connector = to_intel_connector(connector); 1512 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1506 struct intel_sdvo_connector *sdvo_connector = intel_connector->dev_priv;
1507 enum drm_connector_status status = connector_status_connected; 1513 enum drm_connector_status status = connector_status_connected;
1508 struct edid *edid = NULL; 1514 struct edid *edid = NULL;
1509 1515
@@ -1543,7 +1549,7 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1543 1549
1544 if (edid != NULL) { 1550 if (edid != NULL) {
1545 bool is_digital = !!(edid->input & DRM_EDID_INPUT_DIGITAL); 1551 bool is_digital = !!(edid->input & DRM_EDID_INPUT_DIGITAL);
1546 bool need_digital = !!(sdvo_connector->output_flag & SDVO_TMDS_MASK); 1552 bool need_digital = !!(intel_sdvo_connector->output_flag & SDVO_TMDS_MASK);
1547 1553
1548 /* DDC bus is shared, match EDID to connector type */ 1554 /* DDC bus is shared, match EDID to connector type */
1549 if (is_digital && need_digital) 1555 if (is_digital && need_digital)
@@ -1566,8 +1572,7 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
1566 u8 status; 1572 u8 status;
1567 struct drm_encoder *encoder = intel_attached_encoder(connector); 1573 struct drm_encoder *encoder = intel_attached_encoder(connector);
1568 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); 1574 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1569 struct intel_connector *intel_connector = to_intel_connector(connector); 1575 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1570 struct intel_sdvo_connector *sdvo_connector = intel_connector->dev_priv;
1571 enum drm_connector_status ret; 1576 enum drm_connector_status ret;
1572 1577
1573 intel_sdvo_write_cmd(intel_sdvo, 1578 intel_sdvo_write_cmd(intel_sdvo,
@@ -1588,7 +1593,7 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
1588 1593
1589 intel_sdvo->attached_output = response; 1594 intel_sdvo->attached_output = response;
1590 1595
1591 if ((sdvo_connector->output_flag & response) == 0) 1596 if ((intel_sdvo_connector->output_flag & response) == 0)
1592 ret = connector_status_disconnected; 1597 ret = connector_status_disconnected;
1593 else if (response & SDVO_TMDS_MASK) 1598 else if (response & SDVO_TMDS_MASK)
1594 ret = intel_sdvo_hdmi_sink_detect(connector); 1599 ret = intel_sdvo_hdmi_sink_detect(connector);
@@ -1784,12 +1789,11 @@ end:
1784 1789
1785static int intel_sdvo_get_modes(struct drm_connector *connector) 1790static int intel_sdvo_get_modes(struct drm_connector *connector)
1786{ 1791{
1787 struct intel_connector *intel_connector = to_intel_connector(connector); 1792 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1788 struct intel_sdvo_connector *sdvo_connector = intel_connector->dev_priv;
1789 1793
1790 if (IS_TV(sdvo_connector)) 1794 if (IS_TV(intel_sdvo_connector))
1791 intel_sdvo_get_tv_modes(connector); 1795 intel_sdvo_get_tv_modes(connector);
1792 else if (IS_LVDS(sdvo_connector)) 1796 else if (IS_LVDS(intel_sdvo_connector))
1793 intel_sdvo_get_lvds_modes(connector); 1797 intel_sdvo_get_lvds_modes(connector);
1794 else 1798 else
1795 intel_sdvo_get_ddc_modes(connector); 1799 intel_sdvo_get_ddc_modes(connector);
@@ -1802,48 +1806,46 @@ static int intel_sdvo_get_modes(struct drm_connector *connector)
1802static 1806static
1803void intel_sdvo_destroy_enhance_property(struct drm_connector *connector) 1807void intel_sdvo_destroy_enhance_property(struct drm_connector *connector)
1804{ 1808{
1805 struct intel_connector *intel_connector = to_intel_connector(connector); 1809 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1806 struct intel_sdvo_connector *intel_sdvo = intel_connector->dev_priv;
1807 struct drm_device *dev = connector->dev; 1810 struct drm_device *dev = connector->dev;
1808 1811
1809 if (IS_TV(intel_sdvo)) { 1812 if (IS_TV(intel_sdvo_connector)) {
1810 if (intel_sdvo->left_property) 1813 if (intel_sdvo_connector->left_property)
1811 drm_property_destroy(dev, intel_sdvo->left_property); 1814 drm_property_destroy(dev, intel_sdvo_connector->left_property);
1812 if (intel_sdvo->right_property) 1815 if (intel_sdvo_connector->right_property)
1813 drm_property_destroy(dev, intel_sdvo->right_property); 1816 drm_property_destroy(dev, intel_sdvo_connector->right_property);
1814 if (intel_sdvo->top_property) 1817 if (intel_sdvo_connector->top_property)
1815 drm_property_destroy(dev, intel_sdvo->top_property); 1818 drm_property_destroy(dev, intel_sdvo_connector->top_property);
1816 if (intel_sdvo->bottom_property) 1819 if (intel_sdvo_connector->bottom_property)
1817 drm_property_destroy(dev, intel_sdvo->bottom_property); 1820 drm_property_destroy(dev, intel_sdvo_connector->bottom_property);
1818 if (intel_sdvo->hpos_property) 1821 if (intel_sdvo_connector->hpos_property)
1819 drm_property_destroy(dev, intel_sdvo->hpos_property); 1822 drm_property_destroy(dev, intel_sdvo_connector->hpos_property);
1820 if (intel_sdvo->vpos_property) 1823 if (intel_sdvo_connector->vpos_property)
1821 drm_property_destroy(dev, intel_sdvo->vpos_property); 1824 drm_property_destroy(dev, intel_sdvo_connector->vpos_property);
1822 if (intel_sdvo->saturation_property) 1825 if (intel_sdvo_connector->saturation_property)
1823 drm_property_destroy(dev, 1826 drm_property_destroy(dev,
1824 intel_sdvo->saturation_property); 1827 intel_sdvo_connector->saturation_property);
1825 if (intel_sdvo->contrast_property) 1828 if (intel_sdvo_connector->contrast_property)
1826 drm_property_destroy(dev, 1829 drm_property_destroy(dev,
1827 intel_sdvo->contrast_property); 1830 intel_sdvo_connector->contrast_property);
1828 if (intel_sdvo->hue_property) 1831 if (intel_sdvo_connector->hue_property)
1829 drm_property_destroy(dev, intel_sdvo->hue_property); 1832 drm_property_destroy(dev, intel_sdvo_connector->hue_property);
1830 } 1833 }
1831 if (IS_TV(intel_sdvo) || IS_LVDS(intel_sdvo)) { 1834 if (IS_TV(intel_sdvo_connector) || IS_LVDS(intel_sdvo_connector)) {
1832 if (intel_sdvo->brightness_property) 1835 if (intel_sdvo_connector->brightness_property)
1833 drm_property_destroy(dev, 1836 drm_property_destroy(dev,
1834 intel_sdvo->brightness_property); 1837 intel_sdvo_connector->brightness_property);
1835 } 1838 }
1836 return; 1839 return;
1837} 1840}
1838 1841
1839static void intel_sdvo_destroy(struct drm_connector *connector) 1842static void intel_sdvo_destroy(struct drm_connector *connector)
1840{ 1843{
1841 struct intel_connector *intel_connector = to_intel_connector(connector); 1844 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1842 struct intel_sdvo_connector *sdvo_connector = intel_connector->dev_priv;
1843 1845
1844 if (sdvo_connector->tv_format_property) 1846 if (intel_sdvo_connector->tv_format_property)
1845 drm_property_destroy(connector->dev, 1847 drm_property_destroy(connector->dev,
1846 sdvo_connector->tv_format_property); 1848 intel_sdvo_connector->tv_format_property);
1847 1849
1848 intel_sdvo_destroy_enhance_property(connector); 1850 intel_sdvo_destroy_enhance_property(connector);
1849 drm_sysfs_connector_remove(connector); 1851 drm_sysfs_connector_remove(connector);
@@ -1858,8 +1860,7 @@ intel_sdvo_set_property(struct drm_connector *connector,
1858{ 1860{
1859 struct drm_encoder *encoder = intel_attached_encoder(connector); 1861 struct drm_encoder *encoder = intel_attached_encoder(connector);
1860 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); 1862 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1861 struct intel_connector *intel_connector = to_intel_connector(connector); 1863 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1862 struct intel_sdvo_connector *sdvo_connector = intel_connector->dev_priv;
1863 struct drm_crtc *crtc = encoder->crtc; 1864 struct drm_crtc *crtc = encoder->crtc;
1864 int ret = 0; 1865 int ret = 0;
1865 bool changed = false; 1866 bool changed = false;
@@ -1870,101 +1871,101 @@ intel_sdvo_set_property(struct drm_connector *connector,
1870 if (ret < 0) 1871 if (ret < 0)
1871 goto out; 1872 goto out;
1872 1873
1873 if (property == sdvo_connector->tv_format_property) { 1874 if (property == intel_sdvo_connector->tv_format_property) {
1874 if (val >= TV_FORMAT_NUM) { 1875 if (val >= TV_FORMAT_NUM) {
1875 ret = -EINVAL; 1876 ret = -EINVAL;
1876 goto out; 1877 goto out;
1877 } 1878 }
1878 if (intel_sdvo->tv_format_name == 1879 if (intel_sdvo->tv_format_name ==
1879 sdvo_connector->tv_format_supported[val]) 1880 intel_sdvo_connector->tv_format_supported[val])
1880 goto out; 1881 goto out;
1881 1882
1882 intel_sdvo->tv_format_name = sdvo_connector->tv_format_supported[val]; 1883 intel_sdvo->tv_format_name = intel_sdvo_connector->tv_format_supported[val];
1883 changed = true; 1884 changed = true;
1884 } 1885 }
1885 1886
1886 if (IS_TV(sdvo_connector) || IS_LVDS(sdvo_connector)) { 1887 if (IS_TV(intel_sdvo_connector) || IS_LVDS(intel_sdvo_connector)) {
1887 cmd = 0; 1888 cmd = 0;
1888 temp_value = val; 1889 temp_value = val;
1889 if (sdvo_connector->left_property == property) { 1890 if (intel_sdvo_connector->left_property == property) {
1890 drm_connector_property_set_value(connector, 1891 drm_connector_property_set_value(connector,
1891 sdvo_connector->right_property, val); 1892 intel_sdvo_connector->right_property, val);
1892 if (sdvo_connector->left_margin == temp_value) 1893 if (intel_sdvo_connector->left_margin == temp_value)
1893 goto out; 1894 goto out;
1894 1895
1895 sdvo_connector->left_margin = temp_value; 1896 intel_sdvo_connector->left_margin = temp_value;
1896 sdvo_connector->right_margin = temp_value; 1897 intel_sdvo_connector->right_margin = temp_value;
1897 temp_value = sdvo_connector->max_hscan - 1898 temp_value = intel_sdvo_connector->max_hscan -
1898 sdvo_connector->left_margin; 1899 intel_sdvo_connector->left_margin;
1899 cmd = SDVO_CMD_SET_OVERSCAN_H; 1900 cmd = SDVO_CMD_SET_OVERSCAN_H;
1900 } else if (sdvo_connector->right_property == property) { 1901 } else if (intel_sdvo_connector->right_property == property) {
1901 drm_connector_property_set_value(connector, 1902 drm_connector_property_set_value(connector,
1902 sdvo_connector->left_property, val); 1903 intel_sdvo_connector->left_property, val);
1903 if (sdvo_connector->right_margin == temp_value) 1904 if (intel_sdvo_connector->right_margin == temp_value)
1904 goto out; 1905 goto out;
1905 1906
1906 sdvo_connector->left_margin = temp_value; 1907 intel_sdvo_connector->left_margin = temp_value;
1907 sdvo_connector->right_margin = temp_value; 1908 intel_sdvo_connector->right_margin = temp_value;
1908 temp_value = sdvo_connector->max_hscan - 1909 temp_value = intel_sdvo_connector->max_hscan -
1909 sdvo_connector->left_margin; 1910 intel_sdvo_connector->left_margin;
1910 cmd = SDVO_CMD_SET_OVERSCAN_H; 1911 cmd = SDVO_CMD_SET_OVERSCAN_H;
1911 } else if (sdvo_connector->top_property == property) { 1912 } else if (intel_sdvo_connector->top_property == property) {
1912 drm_connector_property_set_value(connector, 1913 drm_connector_property_set_value(connector,
1913 sdvo_connector->bottom_property, val); 1914 intel_sdvo_connector->bottom_property, val);
1914 if (sdvo_connector->top_margin == temp_value) 1915 if (intel_sdvo_connector->top_margin == temp_value)
1915 goto out; 1916 goto out;
1916 1917
1917 sdvo_connector->top_margin = temp_value; 1918 intel_sdvo_connector->top_margin = temp_value;
1918 sdvo_connector->bottom_margin = temp_value; 1919 intel_sdvo_connector->bottom_margin = temp_value;
1919 temp_value = sdvo_connector->max_vscan - 1920 temp_value = intel_sdvo_connector->max_vscan -
1920 sdvo_connector->top_margin; 1921 intel_sdvo_connector->top_margin;
1921 cmd = SDVO_CMD_SET_OVERSCAN_V; 1922 cmd = SDVO_CMD_SET_OVERSCAN_V;
1922 } else if (sdvo_connector->bottom_property == property) { 1923 } else if (intel_sdvo_connector->bottom_property == property) {
1923 drm_connector_property_set_value(connector, 1924 drm_connector_property_set_value(connector,
1924 sdvo_connector->top_property, val); 1925 intel_sdvo_connector->top_property, val);
1925 if (sdvo_connector->bottom_margin == temp_value) 1926 if (intel_sdvo_connector->bottom_margin == temp_value)
1926 goto out; 1927 goto out;
1927 sdvo_connector->top_margin = temp_value; 1928 intel_sdvo_connector->top_margin = temp_value;
1928 sdvo_connector->bottom_margin = temp_value; 1929 intel_sdvo_connector->bottom_margin = temp_value;
1929 temp_value = sdvo_connector->max_vscan - 1930 temp_value = intel_sdvo_connector->max_vscan -
1930 sdvo_connector->top_margin; 1931 intel_sdvo_connector->top_margin;
1931 cmd = SDVO_CMD_SET_OVERSCAN_V; 1932 cmd = SDVO_CMD_SET_OVERSCAN_V;
1932 } else if (sdvo_connector->hpos_property == property) { 1933 } else if (intel_sdvo_connector->hpos_property == property) {
1933 if (sdvo_connector->cur_hpos == temp_value) 1934 if (intel_sdvo_connector->cur_hpos == temp_value)
1934 goto out; 1935 goto out;
1935 1936
1936 cmd = SDVO_CMD_SET_POSITION_H; 1937 cmd = SDVO_CMD_SET_POSITION_H;
1937 sdvo_connector->cur_hpos = temp_value; 1938 intel_sdvo_connector->cur_hpos = temp_value;
1938 } else if (sdvo_connector->vpos_property == property) { 1939 } else if (intel_sdvo_connector->vpos_property == property) {
1939 if (sdvo_connector->cur_vpos == temp_value) 1940 if (intel_sdvo_connector->cur_vpos == temp_value)
1940 goto out; 1941 goto out;
1941 1942
1942 cmd = SDVO_CMD_SET_POSITION_V; 1943 cmd = SDVO_CMD_SET_POSITION_V;
1943 sdvo_connector->cur_vpos = temp_value; 1944 intel_sdvo_connector->cur_vpos = temp_value;
1944 } else if (sdvo_connector->saturation_property == property) { 1945 } else if (intel_sdvo_connector->saturation_property == property) {
1945 if (sdvo_connector->cur_saturation == temp_value) 1946 if (intel_sdvo_connector->cur_saturation == temp_value)
1946 goto out; 1947 goto out;
1947 1948
1948 cmd = SDVO_CMD_SET_SATURATION; 1949 cmd = SDVO_CMD_SET_SATURATION;
1949 sdvo_connector->cur_saturation = temp_value; 1950 intel_sdvo_connector->cur_saturation = temp_value;
1950 } else if (sdvo_connector->contrast_property == property) { 1951 } else if (intel_sdvo_connector->contrast_property == property) {
1951 if (sdvo_connector->cur_contrast == temp_value) 1952 if (intel_sdvo_connector->cur_contrast == temp_value)
1952 goto out; 1953 goto out;
1953 1954
1954 cmd = SDVO_CMD_SET_CONTRAST; 1955 cmd = SDVO_CMD_SET_CONTRAST;
1955 sdvo_connector->cur_contrast = temp_value; 1956 intel_sdvo_connector->cur_contrast = temp_value;
1956 } else if (sdvo_connector->hue_property == property) { 1957 } else if (intel_sdvo_connector->hue_property == property) {
1957 if (sdvo_connector->cur_hue == temp_value) 1958 if (intel_sdvo_connector->cur_hue == temp_value)
1958 goto out; 1959 goto out;
1959 1960
1960 cmd = SDVO_CMD_SET_HUE; 1961 cmd = SDVO_CMD_SET_HUE;
1961 sdvo_connector->cur_hue = temp_value; 1962 intel_sdvo_connector->cur_hue = temp_value;
1962 } else if (sdvo_connector->brightness_property == property) { 1963 } else if (intel_sdvo_connector->brightness_property == property) {
1963 if (sdvo_connector->cur_brightness == temp_value) 1964 if (intel_sdvo_connector->cur_brightness == temp_value)
1964 goto out; 1965 goto out;
1965 1966
1966 cmd = SDVO_CMD_SET_BRIGHTNESS; 1967 cmd = SDVO_CMD_SET_BRIGHTNESS;
1967 sdvo_connector->cur_brightness = temp_value; 1968 intel_sdvo_connector->cur_brightness = temp_value;
1968 } 1969 }
1969 if (cmd) { 1970 if (cmd) {
1970 intel_sdvo_write_cmd(intel_sdvo, cmd, &temp_value, 2); 1971 intel_sdvo_write_cmd(intel_sdvo, cmd, &temp_value, 2);
@@ -2139,24 +2140,6 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, int sdvo_reg)
2139 return 0x72; 2140 return 0x72;
2140} 2141}
2141 2142
2142static bool
2143intel_sdvo_connector_alloc (struct intel_connector **ret)
2144{
2145 struct intel_connector *intel_connector;
2146 struct intel_sdvo_connector *sdvo_connector;
2147
2148 *ret = kzalloc(sizeof(*intel_connector) +
2149 sizeof(*sdvo_connector), GFP_KERNEL);
2150 if (!*ret)
2151 return false;
2152
2153 intel_connector = *ret;
2154 sdvo_connector = (struct intel_sdvo_connector *)(intel_connector + 1);
2155 intel_connector->dev_priv = sdvo_connector;
2156
2157 return true;
2158}
2159
2160static void 2143static void
2161intel_sdvo_connector_create (struct drm_encoder *encoder, 2144intel_sdvo_connector_create (struct drm_encoder *encoder,
2162 struct drm_connector *connector) 2145 struct drm_connector *connector)
@@ -2180,21 +2163,21 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2180 struct drm_encoder *encoder = &intel_sdvo->base.enc; 2163 struct drm_encoder *encoder = &intel_sdvo->base.enc;
2181 struct drm_connector *connector; 2164 struct drm_connector *connector;
2182 struct intel_connector *intel_connector; 2165 struct intel_connector *intel_connector;
2183 struct intel_sdvo_connector *sdvo_connector; 2166 struct intel_sdvo_connector *intel_sdvo_connector;
2184 2167
2185 if (!intel_sdvo_connector_alloc(&intel_connector)) 2168 intel_sdvo_connector = kzalloc(sizeof(struct intel_sdvo_connector), GFP_KERNEL);
2169 if (!intel_sdvo_connector)
2186 return false; 2170 return false;
2187 2171
2188 sdvo_connector = intel_connector->dev_priv;
2189
2190 if (device == 0) { 2172 if (device == 0) {
2191 intel_sdvo->controlled_output |= SDVO_OUTPUT_TMDS0; 2173 intel_sdvo->controlled_output |= SDVO_OUTPUT_TMDS0;
2192 sdvo_connector->output_flag = SDVO_OUTPUT_TMDS0; 2174 intel_sdvo_connector->output_flag = SDVO_OUTPUT_TMDS0;
2193 } else if (device == 1) { 2175 } else if (device == 1) {
2194 intel_sdvo->controlled_output |= SDVO_OUTPUT_TMDS1; 2176 intel_sdvo->controlled_output |= SDVO_OUTPUT_TMDS1;
2195 sdvo_connector->output_flag = SDVO_OUTPUT_TMDS1; 2177 intel_sdvo_connector->output_flag = SDVO_OUTPUT_TMDS1;
2196 } 2178 }
2197 2179
2180 intel_connector = &intel_sdvo_connector->base;
2198 connector = &intel_connector->base; 2181 connector = &intel_connector->base;
2199 connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; 2182 connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
2200 encoder->encoder_type = DRM_MODE_ENCODER_TMDS; 2183 encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
@@ -2223,18 +2206,19 @@ intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int type)
2223 struct drm_encoder *encoder = &intel_sdvo->base.enc; 2206 struct drm_encoder *encoder = &intel_sdvo->base.enc;
2224 struct drm_connector *connector; 2207 struct drm_connector *connector;
2225 struct intel_connector *intel_connector; 2208 struct intel_connector *intel_connector;
2226 struct intel_sdvo_connector *sdvo_connector; 2209 struct intel_sdvo_connector *intel_sdvo_connector;
2227 2210
2228 if (!intel_sdvo_connector_alloc(&intel_connector)) 2211 intel_sdvo_connector = kzalloc(sizeof(struct intel_sdvo_connector), GFP_KERNEL);
2229 return false; 2212 if (!intel_sdvo_connector)
2213 return false;
2230 2214
2215 intel_connector = &intel_sdvo_connector->base;
2231 connector = &intel_connector->base; 2216 connector = &intel_connector->base;
2232 encoder->encoder_type = DRM_MODE_ENCODER_TVDAC; 2217 encoder->encoder_type = DRM_MODE_ENCODER_TVDAC;
2233 connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO; 2218 connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO;
2234 sdvo_connector = intel_connector->dev_priv;
2235 2219
2236 intel_sdvo->controlled_output |= type; 2220 intel_sdvo->controlled_output |= type;
2237 sdvo_connector->output_flag = type; 2221 intel_sdvo_connector->output_flag = type;
2238 2222
2239 intel_sdvo->is_tv = true; 2223 intel_sdvo->is_tv = true;
2240 intel_sdvo->base.needs_tv_clock = true; 2224 intel_sdvo->base.needs_tv_clock = true;
@@ -2255,23 +2239,24 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device)
2255 struct drm_encoder *encoder = &intel_sdvo->base.enc; 2239 struct drm_encoder *encoder = &intel_sdvo->base.enc;
2256 struct drm_connector *connector; 2240 struct drm_connector *connector;
2257 struct intel_connector *intel_connector; 2241 struct intel_connector *intel_connector;
2258 struct intel_sdvo_connector *sdvo_connector; 2242 struct intel_sdvo_connector *intel_sdvo_connector;
2259 2243
2260 if (!intel_sdvo_connector_alloc(&intel_connector)) 2244 intel_sdvo_connector = kzalloc(sizeof(struct intel_sdvo_connector), GFP_KERNEL);
2261 return false; 2245 if (!intel_sdvo_connector)
2246 return false;
2262 2247
2248 intel_connector = &intel_sdvo_connector->base;
2263 connector = &intel_connector->base; 2249 connector = &intel_connector->base;
2264 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 2250 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
2265 encoder->encoder_type = DRM_MODE_ENCODER_DAC; 2251 encoder->encoder_type = DRM_MODE_ENCODER_DAC;
2266 connector->connector_type = DRM_MODE_CONNECTOR_VGA; 2252 connector->connector_type = DRM_MODE_CONNECTOR_VGA;
2267 sdvo_connector = intel_connector->dev_priv;
2268 2253
2269 if (device == 0) { 2254 if (device == 0) {
2270 intel_sdvo->controlled_output |= SDVO_OUTPUT_RGB0; 2255 intel_sdvo->controlled_output |= SDVO_OUTPUT_RGB0;
2271 sdvo_connector->output_flag = SDVO_OUTPUT_RGB0; 2256 intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB0;
2272 } else if (device == 1) { 2257 } else if (device == 1) {
2273 intel_sdvo->controlled_output |= SDVO_OUTPUT_RGB1; 2258 intel_sdvo->controlled_output |= SDVO_OUTPUT_RGB1;
2274 sdvo_connector->output_flag = SDVO_OUTPUT_RGB1; 2259 intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB1;
2275 } 2260 }
2276 2261
2277 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 2262 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
@@ -2287,24 +2272,25 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device)
2287 struct drm_encoder *encoder = &intel_sdvo->base.enc; 2272 struct drm_encoder *encoder = &intel_sdvo->base.enc;
2288 struct drm_connector *connector; 2273 struct drm_connector *connector;
2289 struct intel_connector *intel_connector; 2274 struct intel_connector *intel_connector;
2290 struct intel_sdvo_connector *sdvo_connector; 2275 struct intel_sdvo_connector *intel_sdvo_connector;
2291 2276
2292 if (!intel_sdvo_connector_alloc(&intel_connector)) 2277 intel_sdvo_connector = kzalloc(sizeof(struct intel_sdvo_connector), GFP_KERNEL);
2293 return false; 2278 if (!intel_sdvo_connector)
2279 return false;
2294 2280
2295 connector = &intel_connector->base; 2281 intel_connector = &intel_sdvo_connector->base;
2282 connector = &intel_connector->base;
2296 encoder->encoder_type = DRM_MODE_ENCODER_LVDS; 2283 encoder->encoder_type = DRM_MODE_ENCODER_LVDS;
2297 connector->connector_type = DRM_MODE_CONNECTOR_LVDS; 2284 connector->connector_type = DRM_MODE_CONNECTOR_LVDS;
2298 sdvo_connector = intel_connector->dev_priv;
2299 2285
2300 intel_sdvo->is_lvds = true; 2286 intel_sdvo->is_lvds = true;
2301 2287
2302 if (device == 0) { 2288 if (device == 0) {
2303 intel_sdvo->controlled_output |= SDVO_OUTPUT_LVDS0; 2289 intel_sdvo->controlled_output |= SDVO_OUTPUT_LVDS0;
2304 sdvo_connector->output_flag = SDVO_OUTPUT_LVDS0; 2290 intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS0;
2305 } else if (device == 1) { 2291 } else if (device == 1) {
2306 intel_sdvo->controlled_output |= SDVO_OUTPUT_LVDS1; 2292 intel_sdvo->controlled_output |= SDVO_OUTPUT_LVDS1;
2307 sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1; 2293 intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1;
2308 } 2294 }
2309 2295
2310 intel_sdvo->base.clone_mask = ((1 << INTEL_ANALOG_CLONE_BIT) | 2296 intel_sdvo->base.clone_mask = ((1 << INTEL_ANALOG_CLONE_BIT) |
@@ -2376,8 +2362,7 @@ static void intel_sdvo_tv_create_property(struct drm_connector *connector, int t
2376{ 2362{
2377 struct drm_encoder *encoder = intel_attached_encoder(connector); 2363 struct drm_encoder *encoder = intel_attached_encoder(connector);
2378 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); 2364 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
2379 struct intel_connector *intel_connector = to_intel_connector(connector); 2365 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
2380 struct intel_sdvo_connector *sdvo_connector = intel_connector->dev_priv;
2381 struct intel_sdvo_tv_format format; 2366 struct intel_sdvo_tv_format format;
2382 uint32_t format_map, i; 2367 uint32_t format_map, i;
2383 uint8_t status; 2368 uint8_t status;
@@ -2397,28 +2382,28 @@ static void intel_sdvo_tv_create_property(struct drm_connector *connector, int t
2397 if (format_map == 0) 2382 if (format_map == 0)
2398 return; 2383 return;
2399 2384
2400 sdvo_connector->format_supported_num = 0; 2385 intel_sdvo_connector->format_supported_num = 0;
2401 for (i = 0 ; i < TV_FORMAT_NUM; i++) 2386 for (i = 0 ; i < TV_FORMAT_NUM; i++)
2402 if (format_map & (1 << i)) { 2387 if (format_map & (1 << i)) {
2403 sdvo_connector->tv_format_supported 2388 intel_sdvo_connector->tv_format_supported
2404 [sdvo_connector->format_supported_num++] = 2389 [intel_sdvo_connector->format_supported_num++] =
2405 tv_format_names[i]; 2390 tv_format_names[i];
2406 } 2391 }
2407 2392
2408 2393
2409 sdvo_connector->tv_format_property = 2394 intel_sdvo_connector->tv_format_property =
2410 drm_property_create( 2395 drm_property_create(
2411 connector->dev, DRM_MODE_PROP_ENUM, 2396 connector->dev, DRM_MODE_PROP_ENUM,
2412 "mode", sdvo_connector->format_supported_num); 2397 "mode", intel_sdvo_connector->format_supported_num);
2413 2398
2414 for (i = 0; i < sdvo_connector->format_supported_num; i++) 2399 for (i = 0; i < intel_sdvo_connector->format_supported_num; i++)
2415 drm_property_add_enum( 2400 drm_property_add_enum(
2416 sdvo_connector->tv_format_property, i, 2401 intel_sdvo_connector->tv_format_property, i,
2417 i, sdvo_connector->tv_format_supported[i]); 2402 i, intel_sdvo_connector->tv_format_supported[i]);
2418 2403
2419 intel_sdvo->tv_format_name = sdvo_connector->tv_format_supported[0]; 2404 intel_sdvo->tv_format_name = intel_sdvo_connector->tv_format_supported[0];
2420 drm_connector_attach_property( 2405 drm_connector_attach_property(
2421 connector, sdvo_connector->tv_format_property, 0); 2406 connector, intel_sdvo_connector->tv_format_property, 0);
2422 2407
2423} 2408}
2424 2409
@@ -2426,8 +2411,7 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2426{ 2411{
2427 struct drm_encoder *encoder = intel_attached_encoder(connector); 2412 struct drm_encoder *encoder = intel_attached_encoder(connector);
2428 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); 2413 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
2429 struct intel_connector *intel_connector = to_intel_connector(connector); 2414 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
2430 struct intel_sdvo_connector *intel_sdvo_connector = intel_connector->dev_priv;
2431 struct intel_sdvo_enhancements_reply sdvo_data; 2415 struct intel_sdvo_enhancements_reply sdvo_data;
2432 struct drm_device *dev = connector->dev; 2416 struct drm_device *dev = connector->dev;
2433 uint8_t status; 2417 uint8_t status;