aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-11-08 20:36:33 -0500
committerBen Skeggs <bskeggs@redhat.com>2011-12-21 04:01:33 -0500
commit2a44e4997c5fee8e1da1589ff57e0bd1c53f03ce (patch)
tree26fa7eb5269183d1fbc5314db7cad4f4a8abc720 /drivers
parentd2edab4acffb35a6e24259886d377774efd37e6e (diff)
drm/nouveau/disp: introduce proper init/fini, separate from create/destroy
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c6
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c24
-rw-r--r--drivers/gpu/drm/nouveau/nv04_display.c5
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c17
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvd0_display.c8
7 files changed, 39 insertions, 31 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 38623a25d0b1..803248d467fb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -262,7 +262,10 @@ nouveau_display_create(struct drm_device *dev)
262 if (ret) 262 if (ret)
263 return ret; 263 return ret;
264 264
265 return 0; 265 ret = disp->init(dev);
266 if (ret)
267 disp->destroy(dev);
268 return ret;
266} 269}
267 270
268void 271void
@@ -271,6 +274,7 @@ nouveau_display_destroy(struct drm_device *dev)
271 struct drm_nouveau_private *dev_priv = dev->dev_private; 274 struct drm_nouveau_private *dev_priv = dev->dev_private;
272 struct nouveau_display_engine *disp = &dev_priv->engine.display; 275 struct nouveau_display_engine *disp = &dev_priv->engine.display;
273 276
277 disp->fini(dev);
274 disp->destroy(dev); 278 disp->destroy(dev);
275 drm_mode_config_cleanup(dev); 279 drm_mode_config_cleanup(dev);
276} 280}
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index dc88248f2305..a22ca4735943 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -396,8 +396,9 @@ struct nouveau_display_engine {
396 int (*early_init)(struct drm_device *); 396 int (*early_init)(struct drm_device *);
397 void (*late_takedown)(struct drm_device *); 397 void (*late_takedown)(struct drm_device *);
398 int (*create)(struct drm_device *); 398 int (*create)(struct drm_device *);
399 int (*init)(struct drm_device *);
400 void (*destroy)(struct drm_device *); 399 void (*destroy)(struct drm_device *);
400 int (*init)(struct drm_device *);
401 void (*fini)(struct drm_device *);
401 402
402 struct drm_property *dithering_mode; 403 struct drm_property *dithering_mode;
403 struct drm_property *dithering_depth; 404 struct drm_property *dithering_depth;
@@ -1343,13 +1344,15 @@ extern int nv17_tv_create(struct drm_connector *, struct dcb_entry *);
1343extern int nv04_display_early_init(struct drm_device *); 1344extern int nv04_display_early_init(struct drm_device *);
1344extern void nv04_display_late_takedown(struct drm_device *); 1345extern void nv04_display_late_takedown(struct drm_device *);
1345extern int nv04_display_create(struct drm_device *); 1346extern int nv04_display_create(struct drm_device *);
1346extern int nv04_display_init(struct drm_device *);
1347extern void nv04_display_destroy(struct drm_device *); 1347extern void nv04_display_destroy(struct drm_device *);
1348extern int nv04_display_init(struct drm_device *);
1349extern void nv04_display_fini(struct drm_device *);
1348 1350
1349/* nvd0_display.c */ 1351/* nvd0_display.c */
1350extern int nvd0_display_create(struct drm_device *); 1352extern int nvd0_display_create(struct drm_device *);
1351extern int nvd0_display_init(struct drm_device *);
1352extern void nvd0_display_destroy(struct drm_device *); 1353extern void nvd0_display_destroy(struct drm_device *);
1354extern int nvd0_display_init(struct drm_device *);
1355extern void nvd0_display_fini(struct drm_device *);
1353 1356
1354/* nv04_crtc.c */ 1357/* nv04_crtc.c */
1355extern int nv04_crtc_create(struct drm_device *, int index); 1358extern int nv04_crtc_create(struct drm_device *, int index);
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 46831fea7861..0c3368b36e6c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -80,8 +80,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
80 engine->display.early_init = nv04_display_early_init; 80 engine->display.early_init = nv04_display_early_init;
81 engine->display.late_takedown = nv04_display_late_takedown; 81 engine->display.late_takedown = nv04_display_late_takedown;
82 engine->display.create = nv04_display_create; 82 engine->display.create = nv04_display_create;
83 engine->display.init = nv04_display_init;
84 engine->display.destroy = nv04_display_destroy; 83 engine->display.destroy = nv04_display_destroy;
84 engine->display.init = nv04_display_init;
85 engine->display.fini = nv04_display_fini;
85 engine->gpio.init = nouveau_stub_init; 86 engine->gpio.init = nouveau_stub_init;
86 engine->gpio.takedown = nouveau_stub_takedown; 87 engine->gpio.takedown = nouveau_stub_takedown;
87 engine->gpio.get = NULL; 88 engine->gpio.get = NULL;
@@ -129,8 +130,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
129 engine->display.early_init = nv04_display_early_init; 130 engine->display.early_init = nv04_display_early_init;
130 engine->display.late_takedown = nv04_display_late_takedown; 131 engine->display.late_takedown = nv04_display_late_takedown;
131 engine->display.create = nv04_display_create; 132 engine->display.create = nv04_display_create;
132 engine->display.init = nv04_display_init;
133 engine->display.destroy = nv04_display_destroy; 133 engine->display.destroy = nv04_display_destroy;
134 engine->display.init = nv04_display_init;
135 engine->display.fini = nv04_display_fini;
134 engine->gpio.init = nouveau_stub_init; 136 engine->gpio.init = nouveau_stub_init;
135 engine->gpio.takedown = nouveau_stub_takedown; 137 engine->gpio.takedown = nouveau_stub_takedown;
136 engine->gpio.get = nv10_gpio_get; 138 engine->gpio.get = nv10_gpio_get;
@@ -178,8 +180,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
178 engine->display.early_init = nv04_display_early_init; 180 engine->display.early_init = nv04_display_early_init;
179 engine->display.late_takedown = nv04_display_late_takedown; 181 engine->display.late_takedown = nv04_display_late_takedown;
180 engine->display.create = nv04_display_create; 182 engine->display.create = nv04_display_create;
181 engine->display.init = nv04_display_init;
182 engine->display.destroy = nv04_display_destroy; 183 engine->display.destroy = nv04_display_destroy;
184 engine->display.init = nv04_display_init;
185 engine->display.fini = nv04_display_fini;
183 engine->gpio.init = nouveau_stub_init; 186 engine->gpio.init = nouveau_stub_init;
184 engine->gpio.takedown = nouveau_stub_takedown; 187 engine->gpio.takedown = nouveau_stub_takedown;
185 engine->gpio.get = nv10_gpio_get; 188 engine->gpio.get = nv10_gpio_get;
@@ -227,8 +230,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
227 engine->display.early_init = nv04_display_early_init; 230 engine->display.early_init = nv04_display_early_init;
228 engine->display.late_takedown = nv04_display_late_takedown; 231 engine->display.late_takedown = nv04_display_late_takedown;
229 engine->display.create = nv04_display_create; 232 engine->display.create = nv04_display_create;
230 engine->display.init = nv04_display_init;
231 engine->display.destroy = nv04_display_destroy; 233 engine->display.destroy = nv04_display_destroy;
234 engine->display.init = nv04_display_init;
235 engine->display.fini = nv04_display_fini;
232 engine->gpio.init = nouveau_stub_init; 236 engine->gpio.init = nouveau_stub_init;
233 engine->gpio.takedown = nouveau_stub_takedown; 237 engine->gpio.takedown = nouveau_stub_takedown;
234 engine->gpio.get = nv10_gpio_get; 238 engine->gpio.get = nv10_gpio_get;
@@ -279,8 +283,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
279 engine->display.early_init = nv04_display_early_init; 283 engine->display.early_init = nv04_display_early_init;
280 engine->display.late_takedown = nv04_display_late_takedown; 284 engine->display.late_takedown = nv04_display_late_takedown;
281 engine->display.create = nv04_display_create; 285 engine->display.create = nv04_display_create;
282 engine->display.init = nv04_display_init;
283 engine->display.destroy = nv04_display_destroy; 286 engine->display.destroy = nv04_display_destroy;
287 engine->display.init = nv04_display_init;
288 engine->display.fini = nv04_display_fini;
284 engine->gpio.init = nouveau_stub_init; 289 engine->gpio.init = nouveau_stub_init;
285 engine->gpio.takedown = nouveau_stub_takedown; 290 engine->gpio.takedown = nouveau_stub_takedown;
286 engine->gpio.get = nv10_gpio_get; 291 engine->gpio.get = nv10_gpio_get;
@@ -336,8 +341,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
336 engine->display.early_init = nv50_display_early_init; 341 engine->display.early_init = nv50_display_early_init;
337 engine->display.late_takedown = nv50_display_late_takedown; 342 engine->display.late_takedown = nv50_display_late_takedown;
338 engine->display.create = nv50_display_create; 343 engine->display.create = nv50_display_create;
339 engine->display.init = nv50_display_init;
340 engine->display.destroy = nv50_display_destroy; 344 engine->display.destroy = nv50_display_destroy;
345 engine->display.init = nv50_display_init;
346 engine->display.fini = nv50_display_fini;
341 engine->gpio.init = nv50_gpio_init; 347 engine->gpio.init = nv50_gpio_init;
342 engine->gpio.takedown = nv50_gpio_fini; 348 engine->gpio.takedown = nv50_gpio_fini;
343 engine->gpio.get = nv50_gpio_get; 349 engine->gpio.get = nv50_gpio_get;
@@ -411,8 +417,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
411 engine->display.early_init = nv50_display_early_init; 417 engine->display.early_init = nv50_display_early_init;
412 engine->display.late_takedown = nv50_display_late_takedown; 418 engine->display.late_takedown = nv50_display_late_takedown;
413 engine->display.create = nv50_display_create; 419 engine->display.create = nv50_display_create;
414 engine->display.init = nv50_display_init;
415 engine->display.destroy = nv50_display_destroy; 420 engine->display.destroy = nv50_display_destroy;
421 engine->display.init = nv50_display_init;
422 engine->display.fini = nv50_display_fini;
416 engine->gpio.init = nv50_gpio_init; 423 engine->gpio.init = nv50_gpio_init;
417 engine->gpio.takedown = nouveau_stub_takedown; 424 engine->gpio.takedown = nouveau_stub_takedown;
418 engine->gpio.get = nv50_gpio_get; 425 engine->gpio.get = nv50_gpio_get;
@@ -463,8 +470,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
463 engine->display.early_init = nouveau_stub_init; 470 engine->display.early_init = nouveau_stub_init;
464 engine->display.late_takedown = nouveau_stub_takedown; 471 engine->display.late_takedown = nouveau_stub_takedown;
465 engine->display.create = nvd0_display_create; 472 engine->display.create = nvd0_display_create;
466 engine->display.init = nvd0_display_init;
467 engine->display.destroy = nvd0_display_destroy; 473 engine->display.destroy = nvd0_display_destroy;
474 engine->display.init = nvd0_display_init;
475 engine->display.fini = nvd0_display_fini;
468 engine->gpio.init = nv50_gpio_init; 476 engine->gpio.init = nv50_gpio_init;
469 engine->gpio.takedown = nouveau_stub_takedown; 477 engine->gpio.takedown = nouveau_stub_takedown;
470 engine->gpio.get = nvd0_gpio_get; 478 engine->gpio.get = nvd0_gpio_get;
diff --git a/drivers/gpu/drm/nouveau/nv04_display.c b/drivers/gpu/drm/nouveau/nv04_display.c
index 6bd8518d7b2e..7047d37e8dab 100644
--- a/drivers/gpu/drm/nouveau/nv04_display.c
+++ b/drivers/gpu/drm/nouveau/nv04_display.c
@@ -243,6 +243,11 @@ nv04_display_init(struct drm_device *dev)
243 return 0; 243 return 0;
244} 244}
245 245
246void
247nv04_display_fini(struct drm_device *dev)
248{
249}
250
246static void 251static void
247nv04_vblank_crtc0_isr(struct drm_device *dev) 252nv04_vblank_crtc0_isr(struct drm_device *dev)
248{ 253{
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index a59d0b923cc8..7a57c30e2728 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -264,7 +264,8 @@ nv50_display_init(struct drm_device *dev)
264 return nv50_display_sync(dev); 264 return nv50_display_sync(dev);
265} 265}
266 266
267static int nv50_display_disable(struct drm_device *dev) 267void
268nv50_display_fini(struct drm_device *dev)
268{ 269{
269 struct drm_nouveau_private *dev_priv = dev->dev_private; 270 struct drm_nouveau_private *dev_priv = dev->dev_private;
270 struct nv50_display *disp = nv50_display(dev); 271 struct nv50_display *disp = nv50_display(dev);
@@ -337,16 +338,16 @@ static int nv50_display_disable(struct drm_device *dev)
337 nv_wr32(dev, 0xe074, 0xffffffff); 338 nv_wr32(dev, 0xe074, 0xffffffff);
338 nv_wr32(dev, 0xe070, 0x00000000); 339 nv_wr32(dev, 0xe070, 0x00000000);
339 } 340 }
340 return 0;
341} 341}
342 342
343int nv50_display_create(struct drm_device *dev) 343int
344nv50_display_create(struct drm_device *dev)
344{ 345{
345 struct drm_nouveau_private *dev_priv = dev->dev_private; 346 struct drm_nouveau_private *dev_priv = dev->dev_private;
346 struct dcb_table *dcb = &dev_priv->vbios.dcb; 347 struct dcb_table *dcb = &dev_priv->vbios.dcb;
347 struct drm_connector *connector, *ct; 348 struct drm_connector *connector, *ct;
348 struct nv50_display *priv; 349 struct nv50_display *priv;
349 int ret, i; 350 int i;
350 351
351 NV_DEBUG_KMS(dev, "\n"); 352 NV_DEBUG_KMS(dev, "\n");
352 353
@@ -399,13 +400,6 @@ int nv50_display_create(struct drm_device *dev)
399 400
400 tasklet_init(&priv->tasklet, nv50_display_bh, (unsigned long)dev); 401 tasklet_init(&priv->tasklet, nv50_display_bh, (unsigned long)dev);
401 nouveau_irq_register(dev, 26, nv50_display_isr); 402 nouveau_irq_register(dev, 26, nv50_display_isr);
402
403 ret = nv50_display_init(dev);
404 if (ret) {
405 nv50_display_destroy(dev);
406 return ret;
407 }
408
409 return 0; 403 return 0;
410} 404}
411 405
@@ -416,7 +410,6 @@ nv50_display_destroy(struct drm_device *dev)
416 410
417 NV_DEBUG_KMS(dev, "\n"); 411 NV_DEBUG_KMS(dev, "\n");
418 412
419 nv50_display_disable(dev);
420 nouveau_irq_unregister(dev, 26); 413 nouveau_irq_unregister(dev, 26);
421 kfree(disp); 414 kfree(disp);
422} 415}
diff --git a/drivers/gpu/drm/nouveau/nv50_display.h b/drivers/gpu/drm/nouveau/nv50_display.h
index 0cd8819a53f6..11e2f1efd411 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.h
+++ b/drivers/gpu/drm/nouveau/nv50_display.h
@@ -69,6 +69,7 @@ int nv50_display_early_init(struct drm_device *dev);
69void nv50_display_late_takedown(struct drm_device *dev); 69void nv50_display_late_takedown(struct drm_device *dev);
70int nv50_display_create(struct drm_device *dev); 70int nv50_display_create(struct drm_device *dev);
71int nv50_display_init(struct drm_device *dev); 71int nv50_display_init(struct drm_device *dev);
72void nv50_display_fini(struct drm_device *dev);
72void nv50_display_destroy(struct drm_device *dev); 73void nv50_display_destroy(struct drm_device *dev);
73int nv50_crtc_blank(struct nouveau_crtc *, bool blank); 74int nv50_crtc_blank(struct nouveau_crtc *, bool blank);
74int nv50_crtc_set_clock(struct drm_device *, int head, int pclk); 75int nv50_crtc_set_clock(struct drm_device *, int head, int pclk);
diff --git a/drivers/gpu/drm/nouveau/nvd0_display.c b/drivers/gpu/drm/nouveau/nvd0_display.c
index 75f995852796..614c6520a520 100644
--- a/drivers/gpu/drm/nouveau/nvd0_display.c
+++ b/drivers/gpu/drm/nouveau/nvd0_display.c
@@ -1341,7 +1341,7 @@ nvd0_display_intr(struct drm_device *dev)
1341/****************************************************************************** 1341/******************************************************************************
1342 * Init 1342 * Init
1343 *****************************************************************************/ 1343 *****************************************************************************/
1344static void 1344void
1345nvd0_display_fini(struct drm_device *dev) 1345nvd0_display_fini(struct drm_device *dev)
1346{ 1346{
1347 int i; 1347 int i;
@@ -1461,8 +1461,6 @@ nvd0_display_destroy(struct drm_device *dev)
1461 struct nvd0_display *disp = nvd0_display(dev); 1461 struct nvd0_display *disp = nvd0_display(dev);
1462 struct pci_dev *pdev = dev->pdev; 1462 struct pci_dev *pdev = dev->pdev;
1463 1463
1464 nvd0_display_fini(dev);
1465
1466 pci_free_consistent(pdev, PAGE_SIZE, disp->evo[0].ptr, disp->evo[0].handle); 1464 pci_free_consistent(pdev, PAGE_SIZE, disp->evo[0].ptr, disp->evo[0].handle);
1467 nouveau_gpuobj_ref(NULL, &disp->mem); 1465 nouveau_gpuobj_ref(NULL, &disp->mem);
1468 nouveau_irq_unregister(dev, 26); 1466 nouveau_irq_unregister(dev, 26);
@@ -1588,10 +1586,6 @@ nvd0_display_create(struct drm_device *dev)
1588 goto out; 1586 goto out;
1589 } 1587 }
1590 1588
1591 ret = nvd0_display_init(dev);
1592 if (ret)
1593 goto out;
1594
1595out: 1589out:
1596 if (ret) 1590 if (ret)
1597 nvd0_display_destroy(dev); 1591 nvd0_display_destroy(dev);