diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2013-02-11 05:15:03 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2013-02-20 01:00:56 -0500 |
commit | 5ed502096f698b978c12a435f04be5afb195b485 (patch) | |
tree | fcf757a36ab027728b47f7cb87a981db54a684a3 /drivers/gpu/drm | |
parent | df3ef6a1091fbdfb57306b0205edef33a1f1dcb4 (diff) |
drm/nouveau: store i2c port pointer directly in nouveau_encoder
This is about to become somewhat more complicated to determine in a
number of cases, so store the "common" case (DDC/AUX) directly inside
the encoder structure.
Pre-nv50 code not touched except to fill the pointer, don't care.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_connector.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_dp.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_encoder.h | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_display.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv50_display.c | 24 |
5 files changed, 33 insertions, 22 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 9c4b3f5fba01..4dd7ae2ac6c6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c | |||
@@ -112,7 +112,6 @@ nouveau_connector_ddc_detect(struct drm_connector *connector, | |||
112 | struct nouveau_connector *nv_connector = nouveau_connector(connector); | 112 | struct nouveau_connector *nv_connector = nouveau_connector(connector); |
113 | struct nouveau_drm *drm = nouveau_drm(dev); | 113 | struct nouveau_drm *drm = nouveau_drm(dev); |
114 | struct nouveau_gpio *gpio = nouveau_gpio(drm->device); | 114 | struct nouveau_gpio *gpio = nouveau_gpio(drm->device); |
115 | struct nouveau_i2c *i2c = nouveau_i2c(drm->device); | ||
116 | struct nouveau_i2c_port *port = NULL; | 115 | struct nouveau_i2c_port *port = NULL; |
117 | int i, panel = -ENODEV; | 116 | int i, panel = -ENODEV; |
118 | 117 | ||
@@ -142,8 +141,7 @@ nouveau_connector_ddc_detect(struct drm_connector *connector, | |||
142 | continue; | 141 | continue; |
143 | nv_encoder = nouveau_encoder(obj_to_encoder(obj)); | 142 | nv_encoder = nouveau_encoder(obj_to_encoder(obj)); |
144 | 143 | ||
145 | if (nv_encoder->dcb->i2c_index < 0xf) | 144 | port = nv_encoder->i2c; |
146 | port = i2c->find(i2c, nv_encoder->dcb->i2c_index); | ||
147 | if (port && nv_probe_i2c(port, 0x50)) { | 145 | if (port && nv_probe_i2c(port, 0x50)) { |
148 | *pnv_encoder = nv_encoder; | 146 | *pnv_encoder = nv_encoder; |
149 | break; | 147 | break; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index a87c3674157f..d4da57f21258 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c | |||
@@ -238,13 +238,12 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate, | |||
238 | nouveau_encoder_connector_get(nv_encoder); | 238 | nouveau_encoder_connector_get(nv_encoder); |
239 | struct drm_device *dev = encoder->dev; | 239 | struct drm_device *dev = encoder->dev; |
240 | struct nouveau_drm *drm = nouveau_drm(dev); | 240 | struct nouveau_drm *drm = nouveau_drm(dev); |
241 | struct nouveau_i2c *i2c = nouveau_i2c(drm->device); | ||
242 | struct nouveau_gpio *gpio = nouveau_gpio(drm->device); | 241 | struct nouveau_gpio *gpio = nouveau_gpio(drm->device); |
243 | const u32 bw_list[] = { 270000, 162000, 0 }; | 242 | const u32 bw_list[] = { 270000, 162000, 0 }; |
244 | const u32 *link_bw = bw_list; | 243 | const u32 *link_bw = bw_list; |
245 | struct dp_state dp; | 244 | struct dp_state dp; |
246 | 245 | ||
247 | dp.auxch = i2c->find(i2c, nv_encoder->dcb->i2c_index); | 246 | dp.auxch = nv_encoder->i2c; |
248 | if (!dp.auxch) | 247 | if (!dp.auxch) |
249 | return false; | 248 | return false; |
250 | 249 | ||
@@ -311,12 +310,10 @@ nouveau_dp_dpms(struct drm_encoder *encoder, int mode, u32 datarate, | |||
311 | struct nouveau_object *core) | 310 | struct nouveau_object *core) |
312 | { | 311 | { |
313 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 312 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
314 | struct nouveau_drm *drm = nouveau_drm(encoder->dev); | ||
315 | struct nouveau_i2c *i2c = nouveau_i2c(drm->device); | ||
316 | struct nouveau_i2c_port *auxch; | 313 | struct nouveau_i2c_port *auxch; |
317 | u8 status; | 314 | u8 status; |
318 | 315 | ||
319 | auxch = i2c->find(i2c, nv_encoder->dcb->i2c_index); | 316 | auxch = nv_encoder->i2c; |
320 | if (!auxch) | 317 | if (!auxch) |
321 | return; | 318 | return; |
322 | 319 | ||
@@ -357,12 +354,11 @@ nouveau_dp_detect(struct drm_encoder *encoder) | |||
357 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 354 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
358 | struct drm_device *dev = encoder->dev; | 355 | struct drm_device *dev = encoder->dev; |
359 | struct nouveau_drm *drm = nouveau_drm(dev); | 356 | struct nouveau_drm *drm = nouveau_drm(dev); |
360 | struct nouveau_i2c *i2c = nouveau_i2c(drm->device); | ||
361 | struct nouveau_i2c_port *auxch; | 357 | struct nouveau_i2c_port *auxch; |
362 | u8 *dpcd = nv_encoder->dp.dpcd; | 358 | u8 *dpcd = nv_encoder->dp.dpcd; |
363 | int ret; | 359 | int ret; |
364 | 360 | ||
365 | auxch = i2c->find(i2c, nv_encoder->dcb->i2c_index); | 361 | auxch = nv_encoder->i2c; |
366 | if (!auxch) | 362 | if (!auxch) |
367 | return false; | 363 | return false; |
368 | 364 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h b/drivers/gpu/drm/nouveau/nouveau_encoder.h index d0d95bd511ab..e24341229d5e 100644 --- a/drivers/gpu/drm/nouveau/nouveau_encoder.h +++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h | |||
@@ -36,19 +36,12 @@ | |||
36 | 36 | ||
37 | struct nouveau_i2c_port; | 37 | struct nouveau_i2c_port; |
38 | 38 | ||
39 | struct dp_train_func { | ||
40 | void (*link_set)(struct drm_device *, struct dcb_output *, int crtc, | ||
41 | int nr, u32 bw, bool enhframe); | ||
42 | void (*train_set)(struct drm_device *, struct dcb_output *, u8 pattern); | ||
43 | void (*train_adj)(struct drm_device *, struct dcb_output *, | ||
44 | u8 lane, u8 swing, u8 preem); | ||
45 | }; | ||
46 | |||
47 | struct nouveau_encoder { | 39 | struct nouveau_encoder { |
48 | struct drm_encoder_slave base; | 40 | struct drm_encoder_slave base; |
49 | 41 | ||
50 | struct dcb_output *dcb; | 42 | struct dcb_output *dcb; |
51 | int or; | 43 | int or; |
44 | struct nouveau_i2c_port *i2c; | ||
52 | 45 | ||
53 | /* different to drm_encoder.crtc, this reflects what's | 46 | /* different to drm_encoder.crtc, this reflects what's |
54 | * actually programmed on the hw, not the proposed crtc */ | 47 | * actually programmed on the hw, not the proposed crtc */ |
diff --git a/drivers/gpu/drm/nouveau/nv04_display.c b/drivers/gpu/drm/nouveau/nv04_display.c index edc31560b848..e61f7406fefa 100644 --- a/drivers/gpu/drm/nouveau/nv04_display.c +++ b/drivers/gpu/drm/nouveau/nv04_display.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include "nouveau_encoder.h" | 34 | #include "nouveau_encoder.h" |
35 | #include "nouveau_connector.h" | 35 | #include "nouveau_connector.h" |
36 | 36 | ||
37 | #include <subdev/i2c.h> | ||
38 | |||
37 | int | 39 | int |
38 | nv04_display_early_init(struct drm_device *dev) | 40 | nv04_display_early_init(struct drm_device *dev) |
39 | { | 41 | { |
@@ -56,6 +58,7 @@ int | |||
56 | nv04_display_create(struct drm_device *dev) | 58 | nv04_display_create(struct drm_device *dev) |
57 | { | 59 | { |
58 | struct nouveau_drm *drm = nouveau_drm(dev); | 60 | struct nouveau_drm *drm = nouveau_drm(dev); |
61 | struct nouveau_i2c *i2c = nouveau_i2c(drm->device); | ||
59 | struct dcb_table *dcb = &drm->vbios.dcb; | 62 | struct dcb_table *dcb = &drm->vbios.dcb; |
60 | struct drm_connector *connector, *ct; | 63 | struct drm_connector *connector, *ct; |
61 | struct drm_encoder *encoder; | 64 | struct drm_encoder *encoder; |
@@ -122,6 +125,11 @@ nv04_display_create(struct drm_device *dev) | |||
122 | } | 125 | } |
123 | } | 126 | } |
124 | 127 | ||
128 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | ||
129 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | ||
130 | nv_encoder->i2c = i2c->find(i2c, nv_encoder->dcb->i2c_index); | ||
131 | } | ||
132 | |||
125 | /* Save previous state */ | 133 | /* Save previous state */ |
126 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) | 134 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
127 | crtc->funcs->save(crtc); | 135 | crtc->funcs->save(crtc); |
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index 102a8734d377..75d116137c0a 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <subdev/timer.h> | 43 | #include <subdev/timer.h> |
44 | #include <subdev/bar.h> | 44 | #include <subdev/bar.h> |
45 | #include <subdev/fb.h> | 45 | #include <subdev/fb.h> |
46 | #include <subdev/i2c.h> | ||
46 | 47 | ||
47 | #define EVO_DMA_NR 9 | 48 | #define EVO_DMA_NR 9 |
48 | 49 | ||
@@ -1554,20 +1555,23 @@ static const struct drm_encoder_funcs nv50_dac_func = { | |||
1554 | static int | 1555 | static int |
1555 | nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe) | 1556 | nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe) |
1556 | { | 1557 | { |
1557 | struct drm_device *dev = connector->dev; | 1558 | struct nouveau_drm *drm = nouveau_drm(connector->dev); |
1559 | struct nouveau_i2c *i2c = nouveau_i2c(drm->device); | ||
1558 | struct nouveau_encoder *nv_encoder; | 1560 | struct nouveau_encoder *nv_encoder; |
1559 | struct drm_encoder *encoder; | 1561 | struct drm_encoder *encoder; |
1562 | int type = DRM_MODE_ENCODER_DAC; | ||
1560 | 1563 | ||
1561 | nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); | 1564 | nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); |
1562 | if (!nv_encoder) | 1565 | if (!nv_encoder) |
1563 | return -ENOMEM; | 1566 | return -ENOMEM; |
1564 | nv_encoder->dcb = dcbe; | 1567 | nv_encoder->dcb = dcbe; |
1565 | nv_encoder->or = ffs(dcbe->or) - 1; | 1568 | nv_encoder->or = ffs(dcbe->or) - 1; |
1569 | nv_encoder->i2c = i2c->find(i2c, dcbe->i2c_index); | ||
1566 | 1570 | ||
1567 | encoder = to_drm_encoder(nv_encoder); | 1571 | encoder = to_drm_encoder(nv_encoder); |
1568 | encoder->possible_crtcs = dcbe->heads; | 1572 | encoder->possible_crtcs = dcbe->heads; |
1569 | encoder->possible_clones = 0; | 1573 | encoder->possible_clones = 0; |
1570 | drm_encoder_init(dev, encoder, &nv50_dac_func, DRM_MODE_ENCODER_DAC); | 1574 | drm_encoder_init(connector->dev, encoder, &nv50_dac_func, type); |
1571 | drm_encoder_helper_add(encoder, &nv50_dac_hfunc); | 1575 | drm_encoder_helper_add(encoder, &nv50_dac_hfunc); |
1572 | 1576 | ||
1573 | drm_mode_connector_attach_encoder(connector, encoder); | 1577 | drm_mode_connector_attach_encoder(connector, encoder); |
@@ -1893,21 +1897,33 @@ static const struct drm_encoder_funcs nv50_sor_func = { | |||
1893 | static int | 1897 | static int |
1894 | nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe) | 1898 | nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe) |
1895 | { | 1899 | { |
1896 | struct drm_device *dev = connector->dev; | 1900 | struct nouveau_drm *drm = nouveau_drm(connector->dev); |
1901 | struct nouveau_i2c *i2c = nouveau_i2c(drm->device); | ||
1897 | struct nouveau_encoder *nv_encoder; | 1902 | struct nouveau_encoder *nv_encoder; |
1898 | struct drm_encoder *encoder; | 1903 | struct drm_encoder *encoder; |
1904 | int type; | ||
1905 | |||
1906 | switch (dcbe->type) { | ||
1907 | case DCB_OUTPUT_LVDS: type = DRM_MODE_ENCODER_LVDS; break; | ||
1908 | case DCB_OUTPUT_TMDS: | ||
1909 | case DCB_OUTPUT_DP: | ||
1910 | default: | ||
1911 | type = DRM_MODE_ENCODER_TMDS; | ||
1912 | break; | ||
1913 | } | ||
1899 | 1914 | ||
1900 | nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); | 1915 | nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); |
1901 | if (!nv_encoder) | 1916 | if (!nv_encoder) |
1902 | return -ENOMEM; | 1917 | return -ENOMEM; |
1903 | nv_encoder->dcb = dcbe; | 1918 | nv_encoder->dcb = dcbe; |
1904 | nv_encoder->or = ffs(dcbe->or) - 1; | 1919 | nv_encoder->or = ffs(dcbe->or) - 1; |
1920 | nv_encoder->i2c = i2c->find(i2c, dcbe->i2c_index); | ||
1905 | nv_encoder->last_dpms = DRM_MODE_DPMS_OFF; | 1921 | nv_encoder->last_dpms = DRM_MODE_DPMS_OFF; |
1906 | 1922 | ||
1907 | encoder = to_drm_encoder(nv_encoder); | 1923 | encoder = to_drm_encoder(nv_encoder); |
1908 | encoder->possible_crtcs = dcbe->heads; | 1924 | encoder->possible_crtcs = dcbe->heads; |
1909 | encoder->possible_clones = 0; | 1925 | encoder->possible_clones = 0; |
1910 | drm_encoder_init(dev, encoder, &nv50_sor_func, DRM_MODE_ENCODER_TMDS); | 1926 | drm_encoder_init(connector->dev, encoder, &nv50_sor_func, type); |
1911 | drm_encoder_helper_add(encoder, &nv50_sor_hfunc); | 1927 | drm_encoder_helper_add(encoder, &nv50_sor_hfunc); |
1912 | 1928 | ||
1913 | drm_mode_connector_attach_encoder(connector, encoder); | 1929 | drm_mode_connector_attach_encoder(connector, encoder); |