aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c11
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c50
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c5
-rw-r--r--drivers/gpu/drm/nouveau/nv04_display.c36
-rw-r--r--drivers/gpu/drm/nouveau/nv04_tv.c6
5 files changed, 23 insertions, 85 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 665f0d64f2c6..3b5523eff43a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -6607,7 +6607,6 @@ static bool
6607nouveau_bios_posted(struct drm_device *dev) 6607nouveau_bios_posted(struct drm_device *dev)
6608{ 6608{
6609 struct drm_nouveau_private *dev_priv = dev->dev_private; 6609 struct drm_nouveau_private *dev_priv = dev->dev_private;
6610 bool was_locked;
6611 unsigned htotal; 6610 unsigned htotal;
6612 6611
6613 if (dev_priv->chipset >= NV_50) { 6612 if (dev_priv->chipset >= NV_50) {
@@ -6617,13 +6616,14 @@ nouveau_bios_posted(struct drm_device *dev)
6617 return true; 6616 return true;
6618 } 6617 }
6619 6618
6620 was_locked = NVLockVgaCrtcs(dev, false); 6619 NVLockVgaCrtcs(dev, false);
6621 htotal = NVReadVgaCrtc(dev, 0, 0x06); 6620 htotal = NVReadVgaCrtc(dev, 0, 0x06);
6622 htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x01) << 8; 6621 htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x01) << 8;
6623 htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x20) << 4; 6622 htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x20) << 4;
6624 htotal |= (NVReadVgaCrtc(dev, 0, 0x25) & 0x01) << 10; 6623 htotal |= (NVReadVgaCrtc(dev, 0, 0x25) & 0x01) << 10;
6625 htotal |= (NVReadVgaCrtc(dev, 0, 0x41) & 0x01) << 11; 6624 htotal |= (NVReadVgaCrtc(dev, 0, 0x41) & 0x01) << 11;
6626 NVLockVgaCrtcs(dev, was_locked); 6625 NVLockVgaCrtcs(dev, true);
6626
6627 return (htotal != 0); 6627 return (htotal != 0);
6628} 6628}
6629 6629
@@ -6632,7 +6632,6 @@ nouveau_bios_init(struct drm_device *dev)
6632{ 6632{
6633 struct drm_nouveau_private *dev_priv = dev->dev_private; 6633 struct drm_nouveau_private *dev_priv = dev->dev_private;
6634 struct nvbios *bios = &dev_priv->vbios; 6634 struct nvbios *bios = &dev_priv->vbios;
6635 bool was_locked;
6636 int ret; 6635 int ret;
6637 6636
6638 if (!NVInitVBIOS(dev)) 6637 if (!NVInitVBIOS(dev))
@@ -6667,14 +6666,14 @@ nouveau_bios_init(struct drm_device *dev)
6667 return ret; 6666 return ret;
6668 6667
6669 /* feature_byte on BMP is poor, but init always sets CR4B */ 6668 /* feature_byte on BMP is poor, but init always sets CR4B */
6670 was_locked = NVLockVgaCrtcs(dev, false); 6669 NVLockVgaCrtcs(dev, false);
6671 if (bios->major_version < 5) 6670 if (bios->major_version < 5)
6672 bios->is_mobile = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_4B) & 0x40; 6671 bios->is_mobile = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_4B) & 0x40;
6673 6672
6674 /* all BIT systems need p_f_m_t for digital_min_front_porch */ 6673 /* all BIT systems need p_f_m_t for digital_min_front_porch */
6675 if (bios->is_mobile || bios->major_version >= 5) 6674 if (bios->is_mobile || bios->major_version >= 5)
6676 ret = parse_fp_mode_table(dev, bios); 6675 ret = parse_fp_mode_table(dev, bios);
6677 NVLockVgaCrtcs(dev, was_locked); 6676 NVLockVgaCrtcs(dev, true);
6678 6677
6679 /* allow subsequent scripts to execute */ 6678 /* allow subsequent scripts to execute */
6680 bios->execute = true; 6679 bios->execute = true;
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 27df0063131e..734e92635e83 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -102,44 +102,12 @@ nouveau_connector_destroy(struct drm_connector *drm_connector)
102 kfree(drm_connector); 102 kfree(drm_connector);
103} 103}
104 104
105static void
106nouveau_connector_ddc_prepare(struct drm_connector *connector, int *flags)
107{
108 struct drm_nouveau_private *dev_priv = connector->dev->dev_private;
109
110 if (dev_priv->card_type >= NV_50)
111 return;
112
113 *flags = 0;
114 if (NVLockVgaCrtcs(dev_priv->dev, false))
115 *flags |= 1;
116 if (nv_heads_tied(dev_priv->dev))
117 *flags |= 2;
118
119 if (*flags & 2)
120 NVSetOwner(dev_priv->dev, 0); /* necessary? */
121}
122
123static void
124nouveau_connector_ddc_finish(struct drm_connector *connector, int flags)
125{
126 struct drm_nouveau_private *dev_priv = connector->dev->dev_private;
127
128 if (dev_priv->card_type >= NV_50)
129 return;
130
131 if (flags & 2)
132 NVSetOwner(dev_priv->dev, 4);
133 if (flags & 1)
134 NVLockVgaCrtcs(dev_priv->dev, true);
135}
136
137static struct nouveau_i2c_chan * 105static struct nouveau_i2c_chan *
138nouveau_connector_ddc_detect(struct drm_connector *connector, 106nouveau_connector_ddc_detect(struct drm_connector *connector,
139 struct nouveau_encoder **pnv_encoder) 107 struct nouveau_encoder **pnv_encoder)
140{ 108{
141 struct drm_device *dev = connector->dev; 109 struct drm_device *dev = connector->dev;
142 int ret, flags, i; 110 int i;
143 111
144 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 112 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
145 struct nouveau_i2c_chan *i2c; 113 struct nouveau_i2c_chan *i2c;
@@ -155,17 +123,9 @@ nouveau_connector_ddc_detect(struct drm_connector *connector,
155 if (!obj) 123 if (!obj)
156 continue; 124 continue;
157 nv_encoder = nouveau_encoder(obj_to_encoder(obj)); 125 nv_encoder = nouveau_encoder(obj_to_encoder(obj));
126 i2c = nouveau_i2c_find(dev, nv_encoder->dcb->i2c_index);
158 127
159 if (nv_encoder->dcb->i2c_index < 0xf) 128 if (i2c && nouveau_probe_i2c_addr(i2c, 0x50)) {
160 i2c = nouveau_i2c_find(dev, nv_encoder->dcb->i2c_index);
161 if (!i2c)
162 continue;
163
164 nouveau_connector_ddc_prepare(connector, &flags);
165 ret = nouveau_probe_i2c_addr(i2c, 0x50);
166 nouveau_connector_ddc_finish(connector, flags);
167
168 if (ret) {
169 *pnv_encoder = nv_encoder; 129 *pnv_encoder = nv_encoder;
170 return i2c; 130 return i2c;
171 } 131 }
@@ -218,7 +178,7 @@ nouveau_connector_detect(struct drm_connector *connector)
218 struct nouveau_connector *nv_connector = nouveau_connector(connector); 178 struct nouveau_connector *nv_connector = nouveau_connector(connector);
219 struct nouveau_encoder *nv_encoder = NULL; 179 struct nouveau_encoder *nv_encoder = NULL;
220 struct nouveau_i2c_chan *i2c; 180 struct nouveau_i2c_chan *i2c;
221 int type, flags; 181 int type;
222 182
223 /* Cleanup the previous EDID block. */ 183 /* Cleanup the previous EDID block. */
224 if (nv_connector->edid) { 184 if (nv_connector->edid) {
@@ -229,9 +189,7 @@ nouveau_connector_detect(struct drm_connector *connector)
229 189
230 i2c = nouveau_connector_ddc_detect(connector, &nv_encoder); 190 i2c = nouveau_connector_ddc_detect(connector, &nv_encoder);
231 if (i2c) { 191 if (i2c) {
232 nouveau_connector_ddc_prepare(connector, &flags);
233 nv_connector->edid = drm_get_edid(connector, &i2c->adapter); 192 nv_connector->edid = drm_get_edid(connector, &i2c->adapter);
234 nouveau_connector_ddc_finish(connector, flags);
235 drm_mode_connector_update_edid_property(connector, 193 drm_mode_connector_update_edid_property(connector,
236 nv_connector->edid); 194 nv_connector->edid);
237 if (!nv_connector->edid) { 195 if (!nv_connector->edid) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 6c8cd38fd116..e93fbcc56da5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -321,10 +321,9 @@ nouveau_pci_resume(struct pci_dev *pdev)
321 NV_ERROR(dev, "Could not pin/map cursor.\n"); 321 NV_ERROR(dev, "Could not pin/map cursor.\n");
322 } 322 }
323 323
324 if (dev_priv->card_type < NV_50) { 324 if (dev_priv->card_type < NV_50)
325 nv04_display_restore(dev); 325 nv04_display_restore(dev);
326 NVLockVgaCrtcs(dev, false); 326 else
327 } else
328 nv50_display_init(dev); 327 nv50_display_init(dev);
329 328
330 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 329 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
diff --git a/drivers/gpu/drm/nouveau/nv04_display.c b/drivers/gpu/drm/nouveau/nv04_display.c
index 93200da8f2d3..c6df391ebb2e 100644
--- a/drivers/gpu/drm/nouveau/nv04_display.c
+++ b/drivers/gpu/drm/nouveau/nv04_display.c
@@ -32,8 +32,6 @@
32#include "nouveau_encoder.h" 32#include "nouveau_encoder.h"
33#include "nouveau_connector.h" 33#include "nouveau_connector.h"
34 34
35#define MULTIPLE_ENCODERS(e) (e & (e - 1))
36
37static void 35static void
38nv04_display_store_initial_head_owner(struct drm_device *dev) 36nv04_display_store_initial_head_owner(struct drm_device *dev)
39{ 37{
@@ -41,7 +39,7 @@ nv04_display_store_initial_head_owner(struct drm_device *dev)
41 39
42 if (dev_priv->chipset != 0x11) { 40 if (dev_priv->chipset != 0x11) {
43 dev_priv->crtc_owner = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44); 41 dev_priv->crtc_owner = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44);
44 goto ownerknown; 42 return;
45 } 43 }
46 44
47 /* reading CR44 is broken on nv11, so we attempt to infer it */ 45 /* reading CR44 is broken on nv11, so we attempt to infer it */
@@ -52,8 +50,6 @@ nv04_display_store_initial_head_owner(struct drm_device *dev)
52 bool tvA = false; 50 bool tvA = false;
53 bool tvB = false; 51 bool tvB = false;
54 52
55 NVLockVgaCrtcs(dev, false);
56
57 slaved_on_B = NVReadVgaCrtc(dev, 1, NV_CIO_CRE_PIXEL_INDEX) & 53 slaved_on_B = NVReadVgaCrtc(dev, 1, NV_CIO_CRE_PIXEL_INDEX) &
58 0x80; 54 0x80;
59 if (slaved_on_B) 55 if (slaved_on_B)
@@ -66,8 +62,6 @@ nv04_display_store_initial_head_owner(struct drm_device *dev)
66 tvA = !(NVReadVgaCrtc(dev, 0, NV_CIO_CRE_LCD__INDEX) & 62 tvA = !(NVReadVgaCrtc(dev, 0, NV_CIO_CRE_LCD__INDEX) &
67 MASK(NV_CIO_CRE_LCD_LCD_SELECT)); 63 MASK(NV_CIO_CRE_LCD_LCD_SELECT));
68 64
69 NVLockVgaCrtcs(dev, true);
70
71 if (slaved_on_A && !tvA) 65 if (slaved_on_A && !tvA)
72 dev_priv->crtc_owner = 0x0; 66 dev_priv->crtc_owner = 0x0;
73 else if (slaved_on_B && !tvB) 67 else if (slaved_on_B && !tvB)
@@ -79,12 +73,6 @@ nv04_display_store_initial_head_owner(struct drm_device *dev)
79 else 73 else
80 dev_priv->crtc_owner = 0x0; 74 dev_priv->crtc_owner = 0x0;
81 } 75 }
82
83ownerknown:
84 /* we need to ensure the heads are not tied henceforth, or reading any
85 * 8 bit reg on head B will fail
86 * setting a single arbitrary head solves that */
87 NVSetOwner(dev, 0);
88} 76}
89 77
90int 78int
@@ -99,8 +87,13 @@ nv04_display_create(struct drm_device *dev)
99 87
100 NV_DEBUG_KMS(dev, "\n"); 88 NV_DEBUG_KMS(dev, "\n");
101 89
102 if (nv_two_heads(dev)) 90 NVLockVgaCrtcs(dev, false);
91
92 if (nv_two_heads(dev)) {
103 nv04_display_store_initial_head_owner(dev); 93 nv04_display_store_initial_head_owner(dev);
94 NVSetOwner(dev, 0);
95 }
96
104 nouveau_hw_save_vga_fonts(dev, 1); 97 nouveau_hw_save_vga_fonts(dev, 1);
105 98
106 drm_mode_config_init(dev); 99 drm_mode_config_init(dev);
@@ -168,8 +161,6 @@ nv04_display_create(struct drm_device *dev)
168 } 161 }
169 162
170 /* Save previous state */ 163 /* Save previous state */
171 NVLockVgaCrtcs(dev, false);
172
173 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) 164 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
174 crtc->funcs->save(crtc); 165 crtc->funcs->save(crtc);
175 166
@@ -185,6 +176,7 @@ nv04_display_create(struct drm_device *dev)
185void 176void
186nv04_display_destroy(struct drm_device *dev) 177nv04_display_destroy(struct drm_device *dev)
187{ 178{
179 struct drm_nouveau_private *dev_priv = dev->dev_private;
188 struct drm_encoder *encoder; 180 struct drm_encoder *encoder;
189 struct drm_crtc *crtc; 181 struct drm_crtc *crtc;
190 182
@@ -200,8 +192,6 @@ nv04_display_destroy(struct drm_device *dev)
200 } 192 }
201 193
202 /* Restore state */ 194 /* Restore state */
203 NVLockVgaCrtcs(dev, false);
204
205 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 195 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
206 struct drm_encoder_helper_funcs *func = encoder->helper_private; 196 struct drm_encoder_helper_funcs *func = encoder->helper_private;
207 197
@@ -214,12 +204,15 @@ nv04_display_destroy(struct drm_device *dev)
214 drm_mode_config_cleanup(dev); 204 drm_mode_config_cleanup(dev);
215 205
216 nouveau_hw_save_vga_fonts(dev, 0); 206 nouveau_hw_save_vga_fonts(dev, 0);
207
208 if (nv_two_heads(dev))
209 NVSetOwner(dev, dev_priv->crtc_owner);
210 NVLockVgaCrtcs(dev, true);
217} 211}
218 212
219void 213void
220nv04_display_restore(struct drm_device *dev) 214nv04_display_restore(struct drm_device *dev)
221{ 215{
222 struct drm_nouveau_private *dev_priv = dev->dev_private;
223 struct drm_encoder *encoder; 216 struct drm_encoder *encoder;
224 struct drm_crtc *crtc; 217 struct drm_crtc *crtc;
225 218
@@ -241,10 +234,5 @@ nv04_display_restore(struct drm_device *dev)
241 234
242 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) 235 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
243 crtc->funcs->restore(crtc); 236 crtc->funcs->restore(crtc);
244
245 if (nv_two_heads(dev))
246 NVSetOwner(dev, dev_priv->crtc_owner);
247
248 NVLockVgaCrtcs(dev, true);
249} 237}
250 238
diff --git a/drivers/gpu/drm/nouveau/nv04_tv.c b/drivers/gpu/drm/nouveau/nv04_tv.c
index 8de1eef3594a..94e299cef0b2 100644
--- a/drivers/gpu/drm/nouveau/nv04_tv.c
+++ b/drivers/gpu/drm/nouveau/nv04_tv.c
@@ -194,7 +194,6 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_entry *entry)
194 struct nouveau_i2c_chan *i2c = 194 struct nouveau_i2c_chan *i2c =
195 nouveau_i2c_find(dev, entry->i2c_index); 195 nouveau_i2c_find(dev, entry->i2c_index);
196 int type, ret; 196 int type, ret;
197 bool was_locked;
198 197
199 /* Ensure that we can talk to this encoder */ 198 /* Ensure that we can talk to this encoder */
200 type = nv04_tv_identify(dev, entry->i2c_index); 199 type = nv04_tv_identify(dev, entry->i2c_index);
@@ -224,13 +223,8 @@ nv04_tv_create(struct drm_connector *connector, struct dcb_entry *entry)
224 nv_encoder->or = ffs(entry->or) - 1; 223 nv_encoder->or = ffs(entry->or) - 1;
225 224
226 /* Run the slave-specific initialization */ 225 /* Run the slave-specific initialization */
227 was_locked = NVLockVgaCrtcs(dev, false);
228
229 ret = drm_i2c_encoder_init(dev, to_encoder_slave(encoder), 226 ret = drm_i2c_encoder_init(dev, to_encoder_slave(encoder),
230 &i2c->adapter, &nv04_tv_encoder_info[type]); 227 &i2c->adapter, &nv04_tv_encoder_info[type]);
231
232 NVLockVgaCrtcs(dev, was_locked);
233
234 if (ret < 0) 228 if (ret < 0)
235 goto fail_cleanup; 229 goto fail_cleanup;
236 230