2009-12-11 17:24:15 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Stephane Marchesin
|
|
|
|
* Copyright 2008 Stuart Bennett
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/swab.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-12-11 17:24:15 +08:00
|
|
|
#include "drmP.h"
|
|
|
|
#include "drm.h"
|
|
|
|
#include "drm_sarea.h"
|
|
|
|
#include "drm_crtc_helper.h"
|
|
|
|
#include <linux/vgaarb.h>
|
2010-02-01 13:38:10 +08:00
|
|
|
#include <linux/vga_switcheroo.h>
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
#include "nouveau_drv.h"
|
|
|
|
#include "nouveau_drm.h"
|
2010-03-30 13:34:13 +08:00
|
|
|
#include "nouveau_fbcon.h"
|
2010-09-01 13:24:31 +08:00
|
|
|
#include "nouveau_ramht.h"
|
2009-12-11 17:24:15 +08:00
|
|
|
#include "nv50_display.h"
|
|
|
|
|
|
|
|
static void nouveau_stub_takedown(struct drm_device *dev) {}
|
2010-07-26 07:28:25 +08:00
|
|
|
static int nouveau_stub_init(struct drm_device *dev) { return 0; }
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
static int nouveau_init_engine_ptrs(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
struct nouveau_engine *engine = &dev_priv->engine;
|
|
|
|
|
|
|
|
switch (dev_priv->chipset & 0xf0) {
|
|
|
|
case 0x00:
|
|
|
|
engine->instmem.init = nv04_instmem_init;
|
|
|
|
engine->instmem.takedown = nv04_instmem_takedown;
|
|
|
|
engine->instmem.suspend = nv04_instmem_suspend;
|
|
|
|
engine->instmem.resume = nv04_instmem_resume;
|
|
|
|
engine->instmem.populate = nv04_instmem_populate;
|
|
|
|
engine->instmem.clear = nv04_instmem_clear;
|
|
|
|
engine->instmem.bind = nv04_instmem_bind;
|
|
|
|
engine->instmem.unbind = nv04_instmem_unbind;
|
2010-07-08 09:29:10 +08:00
|
|
|
engine->instmem.flush = nv04_instmem_flush;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->mc.init = nv04_mc_init;
|
|
|
|
engine->mc.takedown = nv04_mc_takedown;
|
|
|
|
engine->timer.init = nv04_timer_init;
|
|
|
|
engine->timer.read = nv04_timer_read;
|
|
|
|
engine->timer.takedown = nv04_timer_takedown;
|
|
|
|
engine->fb.init = nv04_fb_init;
|
|
|
|
engine->fb.takedown = nv04_fb_takedown;
|
|
|
|
engine->graph.grclass = nv04_graph_grclass;
|
|
|
|
engine->graph.init = nv04_graph_init;
|
|
|
|
engine->graph.takedown = nv04_graph_takedown;
|
|
|
|
engine->graph.fifo_access = nv04_graph_fifo_access;
|
|
|
|
engine->graph.channel = nv04_graph_channel;
|
|
|
|
engine->graph.create_context = nv04_graph_create_context;
|
|
|
|
engine->graph.destroy_context = nv04_graph_destroy_context;
|
|
|
|
engine->graph.load_context = nv04_graph_load_context;
|
|
|
|
engine->graph.unload_context = nv04_graph_unload_context;
|
|
|
|
engine->fifo.channels = 16;
|
|
|
|
engine->fifo.init = nv04_fifo_init;
|
|
|
|
engine->fifo.takedown = nouveau_stub_takedown;
|
|
|
|
engine->fifo.disable = nv04_fifo_disable;
|
|
|
|
engine->fifo.enable = nv04_fifo_enable;
|
|
|
|
engine->fifo.reassign = nv04_fifo_reassign;
|
2009-12-14 03:07:42 +08:00
|
|
|
engine->fifo.cache_flush = nv04_fifo_cache_flush;
|
|
|
|
engine->fifo.cache_pull = nv04_fifo_cache_pull;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channel_id = nv04_fifo_channel_id;
|
|
|
|
engine->fifo.create_context = nv04_fifo_create_context;
|
|
|
|
engine->fifo.destroy_context = nv04_fifo_destroy_context;
|
|
|
|
engine->fifo.load_context = nv04_fifo_load_context;
|
|
|
|
engine->fifo.unload_context = nv04_fifo_unload_context;
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.early_init = nv04_display_early_init;
|
|
|
|
engine->display.late_takedown = nv04_display_late_takedown;
|
|
|
|
engine->display.create = nv04_display_create;
|
|
|
|
engine->display.init = nv04_display_init;
|
|
|
|
engine->display.destroy = nv04_display_destroy;
|
2010-07-26 07:28:25 +08:00
|
|
|
engine->gpio.init = nouveau_stub_init;
|
|
|
|
engine->gpio.takedown = nouveau_stub_takedown;
|
|
|
|
engine->gpio.get = NULL;
|
|
|
|
engine->gpio.set = NULL;
|
|
|
|
engine->gpio.irq_enable = NULL;
|
2009-12-11 17:24:15 +08:00
|
|
|
break;
|
|
|
|
case 0x10:
|
|
|
|
engine->instmem.init = nv04_instmem_init;
|
|
|
|
engine->instmem.takedown = nv04_instmem_takedown;
|
|
|
|
engine->instmem.suspend = nv04_instmem_suspend;
|
|
|
|
engine->instmem.resume = nv04_instmem_resume;
|
|
|
|
engine->instmem.populate = nv04_instmem_populate;
|
|
|
|
engine->instmem.clear = nv04_instmem_clear;
|
|
|
|
engine->instmem.bind = nv04_instmem_bind;
|
|
|
|
engine->instmem.unbind = nv04_instmem_unbind;
|
2010-07-08 09:29:10 +08:00
|
|
|
engine->instmem.flush = nv04_instmem_flush;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->mc.init = nv04_mc_init;
|
|
|
|
engine->mc.takedown = nv04_mc_takedown;
|
|
|
|
engine->timer.init = nv04_timer_init;
|
|
|
|
engine->timer.read = nv04_timer_read;
|
|
|
|
engine->timer.takedown = nv04_timer_takedown;
|
|
|
|
engine->fb.init = nv10_fb_init;
|
|
|
|
engine->fb.takedown = nv10_fb_takedown;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->fb.set_region_tiling = nv10_fb_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->graph.grclass = nv10_graph_grclass;
|
|
|
|
engine->graph.init = nv10_graph_init;
|
|
|
|
engine->graph.takedown = nv10_graph_takedown;
|
|
|
|
engine->graph.channel = nv10_graph_channel;
|
|
|
|
engine->graph.create_context = nv10_graph_create_context;
|
|
|
|
engine->graph.destroy_context = nv10_graph_destroy_context;
|
|
|
|
engine->graph.fifo_access = nv04_graph_fifo_access;
|
|
|
|
engine->graph.load_context = nv10_graph_load_context;
|
|
|
|
engine->graph.unload_context = nv10_graph_unload_context;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->graph.set_region_tiling = nv10_graph_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channels = 32;
|
|
|
|
engine->fifo.init = nv10_fifo_init;
|
|
|
|
engine->fifo.takedown = nouveau_stub_takedown;
|
|
|
|
engine->fifo.disable = nv04_fifo_disable;
|
|
|
|
engine->fifo.enable = nv04_fifo_enable;
|
|
|
|
engine->fifo.reassign = nv04_fifo_reassign;
|
2009-12-14 03:07:42 +08:00
|
|
|
engine->fifo.cache_flush = nv04_fifo_cache_flush;
|
|
|
|
engine->fifo.cache_pull = nv04_fifo_cache_pull;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channel_id = nv10_fifo_channel_id;
|
|
|
|
engine->fifo.create_context = nv10_fifo_create_context;
|
|
|
|
engine->fifo.destroy_context = nv10_fifo_destroy_context;
|
|
|
|
engine->fifo.load_context = nv10_fifo_load_context;
|
|
|
|
engine->fifo.unload_context = nv10_fifo_unload_context;
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.early_init = nv04_display_early_init;
|
|
|
|
engine->display.late_takedown = nv04_display_late_takedown;
|
|
|
|
engine->display.create = nv04_display_create;
|
|
|
|
engine->display.init = nv04_display_init;
|
|
|
|
engine->display.destroy = nv04_display_destroy;
|
2010-07-26 07:28:25 +08:00
|
|
|
engine->gpio.init = nouveau_stub_init;
|
|
|
|
engine->gpio.takedown = nouveau_stub_takedown;
|
|
|
|
engine->gpio.get = nv10_gpio_get;
|
|
|
|
engine->gpio.set = nv10_gpio_set;
|
|
|
|
engine->gpio.irq_enable = NULL;
|
2009-12-11 17:24:15 +08:00
|
|
|
break;
|
|
|
|
case 0x20:
|
|
|
|
engine->instmem.init = nv04_instmem_init;
|
|
|
|
engine->instmem.takedown = nv04_instmem_takedown;
|
|
|
|
engine->instmem.suspend = nv04_instmem_suspend;
|
|
|
|
engine->instmem.resume = nv04_instmem_resume;
|
|
|
|
engine->instmem.populate = nv04_instmem_populate;
|
|
|
|
engine->instmem.clear = nv04_instmem_clear;
|
|
|
|
engine->instmem.bind = nv04_instmem_bind;
|
|
|
|
engine->instmem.unbind = nv04_instmem_unbind;
|
2010-07-08 09:29:10 +08:00
|
|
|
engine->instmem.flush = nv04_instmem_flush;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->mc.init = nv04_mc_init;
|
|
|
|
engine->mc.takedown = nv04_mc_takedown;
|
|
|
|
engine->timer.init = nv04_timer_init;
|
|
|
|
engine->timer.read = nv04_timer_read;
|
|
|
|
engine->timer.takedown = nv04_timer_takedown;
|
|
|
|
engine->fb.init = nv10_fb_init;
|
|
|
|
engine->fb.takedown = nv10_fb_takedown;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->fb.set_region_tiling = nv10_fb_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->graph.grclass = nv20_graph_grclass;
|
|
|
|
engine->graph.init = nv20_graph_init;
|
|
|
|
engine->graph.takedown = nv20_graph_takedown;
|
|
|
|
engine->graph.channel = nv10_graph_channel;
|
|
|
|
engine->graph.create_context = nv20_graph_create_context;
|
|
|
|
engine->graph.destroy_context = nv20_graph_destroy_context;
|
|
|
|
engine->graph.fifo_access = nv04_graph_fifo_access;
|
|
|
|
engine->graph.load_context = nv20_graph_load_context;
|
|
|
|
engine->graph.unload_context = nv20_graph_unload_context;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->graph.set_region_tiling = nv20_graph_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channels = 32;
|
|
|
|
engine->fifo.init = nv10_fifo_init;
|
|
|
|
engine->fifo.takedown = nouveau_stub_takedown;
|
|
|
|
engine->fifo.disable = nv04_fifo_disable;
|
|
|
|
engine->fifo.enable = nv04_fifo_enable;
|
|
|
|
engine->fifo.reassign = nv04_fifo_reassign;
|
2009-12-14 03:07:42 +08:00
|
|
|
engine->fifo.cache_flush = nv04_fifo_cache_flush;
|
|
|
|
engine->fifo.cache_pull = nv04_fifo_cache_pull;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channel_id = nv10_fifo_channel_id;
|
|
|
|
engine->fifo.create_context = nv10_fifo_create_context;
|
|
|
|
engine->fifo.destroy_context = nv10_fifo_destroy_context;
|
|
|
|
engine->fifo.load_context = nv10_fifo_load_context;
|
|
|
|
engine->fifo.unload_context = nv10_fifo_unload_context;
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.early_init = nv04_display_early_init;
|
|
|
|
engine->display.late_takedown = nv04_display_late_takedown;
|
|
|
|
engine->display.create = nv04_display_create;
|
|
|
|
engine->display.init = nv04_display_init;
|
|
|
|
engine->display.destroy = nv04_display_destroy;
|
2010-07-26 07:28:25 +08:00
|
|
|
engine->gpio.init = nouveau_stub_init;
|
|
|
|
engine->gpio.takedown = nouveau_stub_takedown;
|
|
|
|
engine->gpio.get = nv10_gpio_get;
|
|
|
|
engine->gpio.set = nv10_gpio_set;
|
|
|
|
engine->gpio.irq_enable = NULL;
|
2009-12-11 17:24:15 +08:00
|
|
|
break;
|
|
|
|
case 0x30:
|
|
|
|
engine->instmem.init = nv04_instmem_init;
|
|
|
|
engine->instmem.takedown = nv04_instmem_takedown;
|
|
|
|
engine->instmem.suspend = nv04_instmem_suspend;
|
|
|
|
engine->instmem.resume = nv04_instmem_resume;
|
|
|
|
engine->instmem.populate = nv04_instmem_populate;
|
|
|
|
engine->instmem.clear = nv04_instmem_clear;
|
|
|
|
engine->instmem.bind = nv04_instmem_bind;
|
|
|
|
engine->instmem.unbind = nv04_instmem_unbind;
|
2010-07-08 09:29:10 +08:00
|
|
|
engine->instmem.flush = nv04_instmem_flush;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->mc.init = nv04_mc_init;
|
|
|
|
engine->mc.takedown = nv04_mc_takedown;
|
|
|
|
engine->timer.init = nv04_timer_init;
|
|
|
|
engine->timer.read = nv04_timer_read;
|
|
|
|
engine->timer.takedown = nv04_timer_takedown;
|
2010-07-22 03:08:11 +08:00
|
|
|
engine->fb.init = nv30_fb_init;
|
|
|
|
engine->fb.takedown = nv30_fb_takedown;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->fb.set_region_tiling = nv10_fb_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->graph.grclass = nv30_graph_grclass;
|
|
|
|
engine->graph.init = nv30_graph_init;
|
|
|
|
engine->graph.takedown = nv20_graph_takedown;
|
|
|
|
engine->graph.fifo_access = nv04_graph_fifo_access;
|
|
|
|
engine->graph.channel = nv10_graph_channel;
|
|
|
|
engine->graph.create_context = nv20_graph_create_context;
|
|
|
|
engine->graph.destroy_context = nv20_graph_destroy_context;
|
|
|
|
engine->graph.load_context = nv20_graph_load_context;
|
|
|
|
engine->graph.unload_context = nv20_graph_unload_context;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->graph.set_region_tiling = nv20_graph_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channels = 32;
|
|
|
|
engine->fifo.init = nv10_fifo_init;
|
|
|
|
engine->fifo.takedown = nouveau_stub_takedown;
|
|
|
|
engine->fifo.disable = nv04_fifo_disable;
|
|
|
|
engine->fifo.enable = nv04_fifo_enable;
|
|
|
|
engine->fifo.reassign = nv04_fifo_reassign;
|
2009-12-14 03:07:42 +08:00
|
|
|
engine->fifo.cache_flush = nv04_fifo_cache_flush;
|
|
|
|
engine->fifo.cache_pull = nv04_fifo_cache_pull;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channel_id = nv10_fifo_channel_id;
|
|
|
|
engine->fifo.create_context = nv10_fifo_create_context;
|
|
|
|
engine->fifo.destroy_context = nv10_fifo_destroy_context;
|
|
|
|
engine->fifo.load_context = nv10_fifo_load_context;
|
|
|
|
engine->fifo.unload_context = nv10_fifo_unload_context;
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.early_init = nv04_display_early_init;
|
|
|
|
engine->display.late_takedown = nv04_display_late_takedown;
|
|
|
|
engine->display.create = nv04_display_create;
|
|
|
|
engine->display.init = nv04_display_init;
|
|
|
|
engine->display.destroy = nv04_display_destroy;
|
2010-07-26 07:28:25 +08:00
|
|
|
engine->gpio.init = nouveau_stub_init;
|
|
|
|
engine->gpio.takedown = nouveau_stub_takedown;
|
|
|
|
engine->gpio.get = nv10_gpio_get;
|
|
|
|
engine->gpio.set = nv10_gpio_set;
|
|
|
|
engine->gpio.irq_enable = NULL;
|
2009-12-11 17:24:15 +08:00
|
|
|
break;
|
|
|
|
case 0x40:
|
|
|
|
case 0x60:
|
|
|
|
engine->instmem.init = nv04_instmem_init;
|
|
|
|
engine->instmem.takedown = nv04_instmem_takedown;
|
|
|
|
engine->instmem.suspend = nv04_instmem_suspend;
|
|
|
|
engine->instmem.resume = nv04_instmem_resume;
|
|
|
|
engine->instmem.populate = nv04_instmem_populate;
|
|
|
|
engine->instmem.clear = nv04_instmem_clear;
|
|
|
|
engine->instmem.bind = nv04_instmem_bind;
|
|
|
|
engine->instmem.unbind = nv04_instmem_unbind;
|
2010-07-08 09:29:10 +08:00
|
|
|
engine->instmem.flush = nv04_instmem_flush;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->mc.init = nv40_mc_init;
|
|
|
|
engine->mc.takedown = nv40_mc_takedown;
|
|
|
|
engine->timer.init = nv04_timer_init;
|
|
|
|
engine->timer.read = nv04_timer_read;
|
|
|
|
engine->timer.takedown = nv04_timer_takedown;
|
|
|
|
engine->fb.init = nv40_fb_init;
|
|
|
|
engine->fb.takedown = nv40_fb_takedown;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->fb.set_region_tiling = nv40_fb_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->graph.grclass = nv40_graph_grclass;
|
|
|
|
engine->graph.init = nv40_graph_init;
|
|
|
|
engine->graph.takedown = nv40_graph_takedown;
|
|
|
|
engine->graph.fifo_access = nv04_graph_fifo_access;
|
|
|
|
engine->graph.channel = nv40_graph_channel;
|
|
|
|
engine->graph.create_context = nv40_graph_create_context;
|
|
|
|
engine->graph.destroy_context = nv40_graph_destroy_context;
|
|
|
|
engine->graph.load_context = nv40_graph_load_context;
|
|
|
|
engine->graph.unload_context = nv40_graph_unload_context;
|
2009-12-16 19:12:27 +08:00
|
|
|
engine->graph.set_region_tiling = nv40_graph_set_region_tiling;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channels = 32;
|
|
|
|
engine->fifo.init = nv40_fifo_init;
|
|
|
|
engine->fifo.takedown = nouveau_stub_takedown;
|
|
|
|
engine->fifo.disable = nv04_fifo_disable;
|
|
|
|
engine->fifo.enable = nv04_fifo_enable;
|
|
|
|
engine->fifo.reassign = nv04_fifo_reassign;
|
2009-12-14 03:07:42 +08:00
|
|
|
engine->fifo.cache_flush = nv04_fifo_cache_flush;
|
|
|
|
engine->fifo.cache_pull = nv04_fifo_cache_pull;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->fifo.channel_id = nv10_fifo_channel_id;
|
|
|
|
engine->fifo.create_context = nv40_fifo_create_context;
|
|
|
|
engine->fifo.destroy_context = nv40_fifo_destroy_context;
|
|
|
|
engine->fifo.load_context = nv40_fifo_load_context;
|
|
|
|
engine->fifo.unload_context = nv40_fifo_unload_context;
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.early_init = nv04_display_early_init;
|
|
|
|
engine->display.late_takedown = nv04_display_late_takedown;
|
|
|
|
engine->display.create = nv04_display_create;
|
|
|
|
engine->display.init = nv04_display_init;
|
|
|
|
engine->display.destroy = nv04_display_destroy;
|
2010-07-26 07:28:25 +08:00
|
|
|
engine->gpio.init = nouveau_stub_init;
|
|
|
|
engine->gpio.takedown = nouveau_stub_takedown;
|
|
|
|
engine->gpio.get = nv10_gpio_get;
|
|
|
|
engine->gpio.set = nv10_gpio_set;
|
|
|
|
engine->gpio.irq_enable = NULL;
|
2009-12-11 17:24:15 +08:00
|
|
|
break;
|
|
|
|
case 0x50:
|
|
|
|
case 0x80: /* gotta love NVIDIA's consistency.. */
|
|
|
|
case 0x90:
|
|
|
|
case 0xA0:
|
|
|
|
engine->instmem.init = nv50_instmem_init;
|
|
|
|
engine->instmem.takedown = nv50_instmem_takedown;
|
|
|
|
engine->instmem.suspend = nv50_instmem_suspend;
|
|
|
|
engine->instmem.resume = nv50_instmem_resume;
|
|
|
|
engine->instmem.populate = nv50_instmem_populate;
|
|
|
|
engine->instmem.clear = nv50_instmem_clear;
|
|
|
|
engine->instmem.bind = nv50_instmem_bind;
|
|
|
|
engine->instmem.unbind = nv50_instmem_unbind;
|
2010-07-15 09:02:54 +08:00
|
|
|
if (dev_priv->chipset == 0x50)
|
|
|
|
engine->instmem.flush = nv50_instmem_flush;
|
|
|
|
else
|
|
|
|
engine->instmem.flush = nv84_instmem_flush;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->mc.init = nv50_mc_init;
|
|
|
|
engine->mc.takedown = nv50_mc_takedown;
|
|
|
|
engine->timer.init = nv04_timer_init;
|
|
|
|
engine->timer.read = nv04_timer_read;
|
|
|
|
engine->timer.takedown = nv04_timer_takedown;
|
2010-03-01 08:18:39 +08:00
|
|
|
engine->fb.init = nv50_fb_init;
|
|
|
|
engine->fb.takedown = nv50_fb_takedown;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine->graph.grclass = nv50_graph_grclass;
|
|
|
|
engine->graph.init = nv50_graph_init;
|
|
|
|
engine->graph.takedown = nv50_graph_takedown;
|
|
|
|
engine->graph.fifo_access = nv50_graph_fifo_access;
|
|
|
|
engine->graph.channel = nv50_graph_channel;
|
|
|
|
engine->graph.create_context = nv50_graph_create_context;
|
|
|
|
engine->graph.destroy_context = nv50_graph_destroy_context;
|
|
|
|
engine->graph.load_context = nv50_graph_load_context;
|
|
|
|
engine->graph.unload_context = nv50_graph_unload_context;
|
|
|
|
engine->fifo.channels = 128;
|
|
|
|
engine->fifo.init = nv50_fifo_init;
|
|
|
|
engine->fifo.takedown = nv50_fifo_takedown;
|
|
|
|
engine->fifo.disable = nv04_fifo_disable;
|
|
|
|
engine->fifo.enable = nv04_fifo_enable;
|
|
|
|
engine->fifo.reassign = nv04_fifo_reassign;
|
|
|
|
engine->fifo.channel_id = nv50_fifo_channel_id;
|
|
|
|
engine->fifo.create_context = nv50_fifo_create_context;
|
|
|
|
engine->fifo.destroy_context = nv50_fifo_destroy_context;
|
|
|
|
engine->fifo.load_context = nv50_fifo_load_context;
|
|
|
|
engine->fifo.unload_context = nv50_fifo_unload_context;
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.early_init = nv50_display_early_init;
|
|
|
|
engine->display.late_takedown = nv50_display_late_takedown;
|
|
|
|
engine->display.create = nv50_display_create;
|
|
|
|
engine->display.init = nv50_display_init;
|
|
|
|
engine->display.destroy = nv50_display_destroy;
|
2010-07-26 07:28:25 +08:00
|
|
|
engine->gpio.init = nv50_gpio_init;
|
|
|
|
engine->gpio.takedown = nouveau_stub_takedown;
|
|
|
|
engine->gpio.get = nv50_gpio_get;
|
|
|
|
engine->gpio.set = nv50_gpio_set;
|
|
|
|
engine->gpio.irq_enable = nv50_gpio_irq_enable;
|
2009-12-11 17:24:15 +08:00
|
|
|
break;
|
2010-08-03 08:00:56 +08:00
|
|
|
case 0xC0:
|
|
|
|
engine->instmem.init = nvc0_instmem_init;
|
|
|
|
engine->instmem.takedown = nvc0_instmem_takedown;
|
|
|
|
engine->instmem.suspend = nvc0_instmem_suspend;
|
|
|
|
engine->instmem.resume = nvc0_instmem_resume;
|
|
|
|
engine->instmem.populate = nvc0_instmem_populate;
|
|
|
|
engine->instmem.clear = nvc0_instmem_clear;
|
|
|
|
engine->instmem.bind = nvc0_instmem_bind;
|
|
|
|
engine->instmem.unbind = nvc0_instmem_unbind;
|
|
|
|
engine->instmem.flush = nvc0_instmem_flush;
|
|
|
|
engine->mc.init = nv50_mc_init;
|
|
|
|
engine->mc.takedown = nv50_mc_takedown;
|
|
|
|
engine->timer.init = nv04_timer_init;
|
|
|
|
engine->timer.read = nv04_timer_read;
|
|
|
|
engine->timer.takedown = nv04_timer_takedown;
|
|
|
|
engine->fb.init = nvc0_fb_init;
|
|
|
|
engine->fb.takedown = nvc0_fb_takedown;
|
|
|
|
engine->graph.grclass = NULL; //nvc0_graph_grclass;
|
|
|
|
engine->graph.init = nvc0_graph_init;
|
|
|
|
engine->graph.takedown = nvc0_graph_takedown;
|
|
|
|
engine->graph.fifo_access = nvc0_graph_fifo_access;
|
|
|
|
engine->graph.channel = nvc0_graph_channel;
|
|
|
|
engine->graph.create_context = nvc0_graph_create_context;
|
|
|
|
engine->graph.destroy_context = nvc0_graph_destroy_context;
|
|
|
|
engine->graph.load_context = nvc0_graph_load_context;
|
|
|
|
engine->graph.unload_context = nvc0_graph_unload_context;
|
|
|
|
engine->fifo.channels = 128;
|
|
|
|
engine->fifo.init = nvc0_fifo_init;
|
|
|
|
engine->fifo.takedown = nvc0_fifo_takedown;
|
|
|
|
engine->fifo.disable = nvc0_fifo_disable;
|
|
|
|
engine->fifo.enable = nvc0_fifo_enable;
|
|
|
|
engine->fifo.reassign = nvc0_fifo_reassign;
|
|
|
|
engine->fifo.channel_id = nvc0_fifo_channel_id;
|
|
|
|
engine->fifo.create_context = nvc0_fifo_create_context;
|
|
|
|
engine->fifo.destroy_context = nvc0_fifo_destroy_context;
|
|
|
|
engine->fifo.load_context = nvc0_fifo_load_context;
|
|
|
|
engine->fifo.unload_context = nvc0_fifo_unload_context;
|
|
|
|
engine->display.early_init = nv50_display_early_init;
|
|
|
|
engine->display.late_takedown = nv50_display_late_takedown;
|
|
|
|
engine->display.create = nv50_display_create;
|
|
|
|
engine->display.init = nv50_display_init;
|
|
|
|
engine->display.destroy = nv50_display_destroy;
|
|
|
|
engine->gpio.init = nv50_gpio_init;
|
|
|
|
engine->gpio.takedown = nouveau_stub_takedown;
|
|
|
|
engine->gpio.get = nv50_gpio_get;
|
|
|
|
engine->gpio.set = nv50_gpio_set;
|
|
|
|
engine->gpio.irq_enable = nv50_gpio_irq_enable;
|
|
|
|
break;
|
2009-12-11 17:24:15 +08:00
|
|
|
default:
|
|
|
|
NV_ERROR(dev, "NV%02x unsupported\n", dev_priv->chipset);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
nouveau_vga_set_decode(void *priv, bool state)
|
|
|
|
{
|
2010-02-08 08:20:17 +08:00
|
|
|
struct drm_device *dev = priv;
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
|
|
|
|
if (dev_priv->chipset >= 0x40)
|
|
|
|
nv_wr32(dev, 0x88054, state);
|
|
|
|
else
|
|
|
|
nv_wr32(dev, 0x1854, state);
|
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
if (state)
|
|
|
|
return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
|
|
|
|
VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
|
|
|
|
else
|
|
|
|
return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
|
|
|
|
}
|
|
|
|
|
2009-12-16 12:28:55 +08:00
|
|
|
static int
|
|
|
|
nouveau_card_init_channel(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
2010-09-01 13:24:31 +08:00
|
|
|
struct nouveau_gpuobj *gpuobj = NULL;
|
2009-12-16 12:28:55 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = nouveau_channel_alloc(dev, &dev_priv->channel,
|
2010-09-01 13:24:31 +08:00
|
|
|
(struct drm_file *)-2, NvDmaFB, NvDmaTT);
|
2009-12-16 12:28:55 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
|
2010-03-18 07:45:20 +08:00
|
|
|
0, dev_priv->vram_size,
|
2009-12-16 12:28:55 +08:00
|
|
|
NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM,
|
|
|
|
&gpuobj);
|
|
|
|
if (ret)
|
|
|
|
goto out_err;
|
|
|
|
|
2010-09-01 13:24:31 +08:00
|
|
|
ret = nouveau_ramht_insert(dev_priv->channel, NvDmaVRAM, gpuobj);
|
|
|
|
nouveau_gpuobj_ref(NULL, &gpuobj);
|
2009-12-16 12:28:55 +08:00
|
|
|
if (ret)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0,
|
|
|
|
dev_priv->gart_info.aper_size,
|
|
|
|
NV_DMA_ACCESS_RW, &gpuobj, NULL);
|
|
|
|
if (ret)
|
|
|
|
goto out_err;
|
|
|
|
|
2010-09-01 13:24:31 +08:00
|
|
|
ret = nouveau_ramht_insert(dev_priv->channel, NvDmaGART, gpuobj);
|
|
|
|
nouveau_gpuobj_ref(NULL, &gpuobj);
|
2009-12-16 12:28:55 +08:00
|
|
|
if (ret)
|
|
|
|
goto out_err;
|
|
|
|
|
|
|
|
return 0;
|
2010-09-01 13:24:31 +08:00
|
|
|
|
2009-12-16 12:28:55 +08:00
|
|
|
out_err:
|
|
|
|
nouveau_channel_free(dev_priv->channel);
|
|
|
|
dev_priv->channel = NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-02-01 13:38:10 +08:00
|
|
|
static void nouveau_switcheroo_set_state(struct pci_dev *pdev,
|
|
|
|
enum vga_switcheroo_state state)
|
|
|
|
{
|
2010-06-01 07:09:06 +08:00
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
2010-02-01 13:38:10 +08:00
|
|
|
pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
|
|
|
|
if (state == VGA_SWITCHEROO_ON) {
|
|
|
|
printk(KERN_ERR "VGA switcheroo: switched nouveau on\n");
|
|
|
|
nouveau_pci_resume(pdev);
|
2010-06-01 07:09:06 +08:00
|
|
|
drm_kms_helper_poll_enable(dev);
|
2010-02-01 13:38:10 +08:00
|
|
|
} else {
|
|
|
|
printk(KERN_ERR "VGA switcheroo: switched nouveau off\n");
|
2010-06-01 07:09:06 +08:00
|
|
|
drm_kms_helper_poll_disable(dev);
|
2010-02-01 13:38:10 +08:00
|
|
|
nouveau_pci_suspend(pdev, pmm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
|
|
|
bool can_switch;
|
|
|
|
|
|
|
|
spin_lock(&dev->count_lock);
|
|
|
|
can_switch = (dev->open_count == 0);
|
|
|
|
spin_unlock(&dev->count_lock);
|
|
|
|
return can_switch;
|
|
|
|
}
|
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
int
|
|
|
|
nouveau_card_init(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
struct nouveau_engine *engine;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
|
2010-02-01 13:38:10 +08:00
|
|
|
vga_switcheroo_register_client(dev->pdev, nouveau_switcheroo_set_state,
|
|
|
|
nouveau_switcheroo_can_switch);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
/* Initialise internal driver API hooks */
|
|
|
|
ret = nouveau_init_engine_ptrs(dev);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out;
|
2009-12-11 17:24:15 +08:00
|
|
|
engine = &dev_priv->engine;
|
2010-02-02 03:58:27 +08:00
|
|
|
spin_lock_init(&dev_priv->context_switch_lock);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-07-24 23:37:33 +08:00
|
|
|
/* Make the CRTCs and I2C buses accessible */
|
|
|
|
ret = engine->display.early_init(dev);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
/* Parse BIOS tables / Run init tables if card not POSTed */
|
2010-06-01 13:56:22 +08:00
|
|
|
ret = nouveau_bios_init(dev);
|
|
|
|
if (ret)
|
2010-07-24 23:37:33 +08:00
|
|
|
goto out_display_early;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-03-18 07:45:20 +08:00
|
|
|
ret = nouveau_mem_detect(dev);
|
|
|
|
if (ret)
|
|
|
|
goto out_bios;
|
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
ret = nouveau_gpuobj_early_init(dev);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out_bios;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
/* Initialise instance memory, must happen before mem_init so we
|
|
|
|
* know exactly how much VRAM we're able to use for "normal"
|
|
|
|
* purposes.
|
|
|
|
*/
|
|
|
|
ret = engine->instmem.init(dev);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out_gpuobj_early;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
/* Setup the memory manager */
|
|
|
|
ret = nouveau_mem_init(dev);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out_instmem;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
ret = nouveau_gpuobj_init(dev);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out_mem;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
/* PMC */
|
|
|
|
ret = engine->mc.init(dev);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out_gpuobj;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-07-26 07:28:25 +08:00
|
|
|
/* PGPIO */
|
|
|
|
ret = engine->gpio.init(dev);
|
|
|
|
if (ret)
|
|
|
|
goto out_mc;
|
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
/* PTIMER */
|
|
|
|
ret = engine->timer.init(dev);
|
|
|
|
if (ret)
|
2010-07-26 07:28:25 +08:00
|
|
|
goto out_gpio;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
/* PFB */
|
|
|
|
ret = engine->fb.init(dev);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out_timer;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-01-26 22:00:42 +08:00
|
|
|
if (nouveau_noaccel)
|
|
|
|
engine->graph.accel_blocked = true;
|
|
|
|
else {
|
|
|
|
/* PGRAPH */
|
|
|
|
ret = engine->graph.init(dev);
|
|
|
|
if (ret)
|
|
|
|
goto out_fb;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-01-26 22:00:42 +08:00
|
|
|
/* PFIFO */
|
|
|
|
ret = engine->fifo.init(dev);
|
|
|
|
if (ret)
|
|
|
|
goto out_graph;
|
|
|
|
}
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-07-24 23:37:33 +08:00
|
|
|
ret = engine->display.create(dev);
|
2010-07-09 08:56:08 +08:00
|
|
|
if (ret)
|
|
|
|
goto out_fifo;
|
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
/* this call irq_preinstall, register irq handler and
|
|
|
|
* call irq_postinstall
|
|
|
|
*/
|
|
|
|
ret = drm_irq_install(dev);
|
|
|
|
if (ret)
|
2010-07-09 08:56:08 +08:00
|
|
|
goto out_display;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
ret = drm_vblank_init(dev, 0);
|
|
|
|
if (ret)
|
2009-12-15 04:58:39 +08:00
|
|
|
goto out_irq;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
/* what about PVIDEO/PCRTC/PRAMDAC etc? */
|
|
|
|
|
2009-12-16 12:28:55 +08:00
|
|
|
if (!engine->graph.accel_blocked) {
|
|
|
|
ret = nouveau_card_init_channel(dev);
|
|
|
|
if (ret)
|
|
|
|
goto out_irq;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = nouveau_backlight_init(dev);
|
|
|
|
if (ret)
|
|
|
|
NV_ERROR(dev, "Error %d registering backlight\n", ret);
|
|
|
|
|
2010-06-01 13:56:22 +08:00
|
|
|
nouveau_fbcon_init(dev);
|
|
|
|
drm_kms_helper_poll_init(dev);
|
2009-12-11 17:24:15 +08:00
|
|
|
return 0;
|
2009-12-15 04:58:39 +08:00
|
|
|
|
|
|
|
out_irq:
|
|
|
|
drm_irq_uninstall(dev);
|
2010-07-09 08:56:08 +08:00
|
|
|
out_display:
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.destroy(dev);
|
2009-12-15 04:58:39 +08:00
|
|
|
out_fifo:
|
2010-01-26 22:00:42 +08:00
|
|
|
if (!nouveau_noaccel)
|
|
|
|
engine->fifo.takedown(dev);
|
2009-12-15 04:58:39 +08:00
|
|
|
out_graph:
|
2010-01-26 22:00:42 +08:00
|
|
|
if (!nouveau_noaccel)
|
|
|
|
engine->graph.takedown(dev);
|
2009-12-15 04:58:39 +08:00
|
|
|
out_fb:
|
|
|
|
engine->fb.takedown(dev);
|
|
|
|
out_timer:
|
|
|
|
engine->timer.takedown(dev);
|
2010-07-26 07:28:25 +08:00
|
|
|
out_gpio:
|
|
|
|
engine->gpio.takedown(dev);
|
2009-12-15 04:58:39 +08:00
|
|
|
out_mc:
|
|
|
|
engine->mc.takedown(dev);
|
|
|
|
out_gpuobj:
|
|
|
|
nouveau_gpuobj_takedown(dev);
|
|
|
|
out_mem:
|
2010-03-25 14:00:09 +08:00
|
|
|
nouveau_sgdma_takedown(dev);
|
2009-12-15 04:58:39 +08:00
|
|
|
nouveau_mem_close(dev);
|
|
|
|
out_instmem:
|
|
|
|
engine->instmem.takedown(dev);
|
|
|
|
out_gpuobj_early:
|
|
|
|
nouveau_gpuobj_late_takedown(dev);
|
|
|
|
out_bios:
|
|
|
|
nouveau_bios_takedown(dev);
|
2010-07-24 23:37:33 +08:00
|
|
|
out_display_early:
|
|
|
|
engine->display.late_takedown(dev);
|
2009-12-15 04:58:39 +08:00
|
|
|
out:
|
|
|
|
vga_client_register(dev->pdev, NULL, NULL, NULL);
|
|
|
|
return ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void nouveau_card_takedown(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
struct nouveau_engine *engine = &dev_priv->engine;
|
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
nouveau_backlight_exit(dev);
|
2010-03-30 13:34:13 +08:00
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
if (dev_priv->channel) {
|
|
|
|
nouveau_channel_free(dev_priv->channel);
|
|
|
|
dev_priv->channel = NULL;
|
|
|
|
}
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
if (!nouveau_noaccel) {
|
|
|
|
engine->fifo.takedown(dev);
|
|
|
|
engine->graph.takedown(dev);
|
|
|
|
}
|
|
|
|
engine->fb.takedown(dev);
|
|
|
|
engine->timer.takedown(dev);
|
2010-07-26 07:28:25 +08:00
|
|
|
engine->gpio.takedown(dev);
|
2010-06-07 13:38:27 +08:00
|
|
|
engine->mc.takedown(dev);
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.late_takedown(dev);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
mutex_lock(&dev->struct_mutex);
|
|
|
|
ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
|
|
|
|
ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT);
|
|
|
|
mutex_unlock(&dev->struct_mutex);
|
|
|
|
nouveau_sgdma_takedown(dev);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
nouveau_gpuobj_takedown(dev);
|
|
|
|
nouveau_mem_close(dev);
|
|
|
|
engine->instmem.takedown(dev);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
drm_irq_uninstall(dev);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
nouveau_gpuobj_late_takedown(dev);
|
|
|
|
nouveau_bios_takedown(dev);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-06-07 13:38:27 +08:00
|
|
|
vga_client_register(dev->pdev, NULL, NULL, NULL);
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* here a client dies, release the stuff that was allocated for its
|
|
|
|
* file_priv */
|
|
|
|
void nouveau_preclose(struct drm_device *dev, struct drm_file *file_priv)
|
|
|
|
{
|
|
|
|
nouveau_channel_cleanup(dev, file_priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first module load, setup the mmio/fb mapping */
|
|
|
|
/* KMS: we need mmio at load time, not when the first drm client opens. */
|
|
|
|
int nouveau_firstopen(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we have an OF card, copy vbios to RAMIN */
|
|
|
|
static void nouveau_OF_copy_vbios_to_ramin(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
#if defined(__powerpc__)
|
|
|
|
int size, i;
|
|
|
|
const uint32_t *bios;
|
|
|
|
struct device_node *dn = pci_device_to_OF_node(dev->pdev);
|
|
|
|
if (!dn) {
|
|
|
|
NV_INFO(dev, "Unable to get the OF node\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bios = of_get_property(dn, "NVDA,BMP", &size);
|
|
|
|
if (bios) {
|
|
|
|
for (i = 0; i < size; i += 4)
|
|
|
|
nv_wi32(dev, i, bios[i/4]);
|
|
|
|
NV_INFO(dev, "OF bios successfully copied (%d bytes)\n", size);
|
|
|
|
} else {
|
|
|
|
NV_INFO(dev, "Unable to get the OF bios\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-05-16 23:29:56 +08:00
|
|
|
static struct apertures_struct *nouveau_get_apertures(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = dev->pdev;
|
|
|
|
struct apertures_struct *aper = alloc_apertures(3);
|
|
|
|
if (!aper)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
aper->ranges[0].base = pci_resource_start(pdev, 1);
|
|
|
|
aper->ranges[0].size = pci_resource_len(pdev, 1);
|
|
|
|
aper->count = 1;
|
|
|
|
|
|
|
|
if (pci_resource_len(pdev, 2)) {
|
|
|
|
aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
|
|
|
|
aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
|
|
|
|
aper->count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pci_resource_len(pdev, 3)) {
|
|
|
|
aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
|
|
|
|
aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
|
|
|
|
aper->count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aper;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nouveau_remove_conflicting_drivers(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
2010-05-16 23:33:09 +08:00
|
|
|
bool primary = false;
|
2010-05-16 23:29:56 +08:00
|
|
|
dev_priv->apertures = nouveau_get_apertures(dev);
|
|
|
|
if (!dev_priv->apertures)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-05-16 23:33:09 +08:00
|
|
|
#ifdef CONFIG_X86
|
|
|
|
primary = dev->pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
remove_conflicting_framebuffers(dev_priv->apertures, "nouveaufb", primary);
|
2010-05-16 23:29:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
int nouveau_load(struct drm_device *dev, unsigned long flags)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv;
|
|
|
|
uint32_t reg0;
|
|
|
|
resource_size_t mmio_start_offs;
|
2010-06-01 13:56:22 +08:00
|
|
|
int ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
|
2010-07-30 23:04:32 +08:00
|
|
|
if (!dev_priv) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_out;
|
|
|
|
}
|
2009-12-11 17:24:15 +08:00
|
|
|
dev->dev_private = dev_priv;
|
|
|
|
dev_priv->dev = dev;
|
|
|
|
|
|
|
|
dev_priv->flags = flags & NOUVEAU_FLAGS;
|
|
|
|
|
|
|
|
NV_DEBUG(dev, "vendor: 0x%X device: 0x%X class: 0x%X\n",
|
|
|
|
dev->pci_vendor, dev->pci_device, dev->pdev->class);
|
|
|
|
|
|
|
|
dev_priv->wq = create_workqueue("nouveau");
|
2010-07-30 23:04:32 +08:00
|
|
|
if (!dev_priv->wq) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto err_priv;
|
|
|
|
}
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
/* resource 0 is mmio regs */
|
|
|
|
/* resource 1 is linear FB */
|
|
|
|
/* resource 2 is RAMIN (mmio regs + 0x1000000) */
|
|
|
|
/* resource 6 is bios */
|
|
|
|
|
|
|
|
/* map the mmio regs */
|
|
|
|
mmio_start_offs = pci_resource_start(dev->pdev, 0);
|
|
|
|
dev_priv->mmio = ioremap(mmio_start_offs, 0x00800000);
|
|
|
|
if (!dev_priv->mmio) {
|
|
|
|
NV_ERROR(dev, "Unable to initialize the mmio mapping. "
|
|
|
|
"Please report your setup to " DRIVER_EMAIL "\n");
|
2010-07-30 23:04:32 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto err_wq;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
NV_DEBUG(dev, "regs mapped ok at 0x%llx\n",
|
|
|
|
(unsigned long long)mmio_start_offs);
|
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN
|
|
|
|
/* Put the card in BE mode if it's not */
|
|
|
|
if (nv_rd32(dev, NV03_PMC_BOOT_1))
|
|
|
|
nv_wr32(dev, NV03_PMC_BOOT_1, 0x00000001);
|
|
|
|
|
|
|
|
DRM_MEMORYBARRIER();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Time to determine the card architecture */
|
|
|
|
reg0 = nv_rd32(dev, NV03_PMC_BOOT_0);
|
|
|
|
|
|
|
|
/* We're dealing with >=NV10 */
|
|
|
|
if ((reg0 & 0x0f000000) > 0) {
|
|
|
|
/* Bit 27-20 contain the architecture in hex */
|
|
|
|
dev_priv->chipset = (reg0 & 0xff00000) >> 20;
|
|
|
|
/* NV04 or NV05 */
|
|
|
|
} else if ((reg0 & 0xff00fff0) == 0x20004000) {
|
2010-01-07 11:47:57 +08:00
|
|
|
if (reg0 & 0x00f00000)
|
|
|
|
dev_priv->chipset = 0x05;
|
|
|
|
else
|
|
|
|
dev_priv->chipset = 0x04;
|
2009-12-11 17:24:15 +08:00
|
|
|
} else
|
|
|
|
dev_priv->chipset = 0xff;
|
|
|
|
|
|
|
|
switch (dev_priv->chipset & 0xf0) {
|
|
|
|
case 0x00:
|
|
|
|
case 0x10:
|
|
|
|
case 0x20:
|
|
|
|
case 0x30:
|
|
|
|
dev_priv->card_type = dev_priv->chipset & 0xf0;
|
|
|
|
break;
|
|
|
|
case 0x40:
|
|
|
|
case 0x60:
|
|
|
|
dev_priv->card_type = NV_40;
|
|
|
|
break;
|
|
|
|
case 0x50:
|
|
|
|
case 0x80:
|
|
|
|
case 0x90:
|
|
|
|
case 0xa0:
|
|
|
|
dev_priv->card_type = NV_50;
|
|
|
|
break;
|
2010-08-03 08:00:56 +08:00
|
|
|
case 0xc0:
|
|
|
|
dev_priv->card_type = NV_C0;
|
|
|
|
break;
|
2009-12-11 17:24:15 +08:00
|
|
|
default:
|
|
|
|
NV_INFO(dev, "Unsupported chipset 0x%08x\n", reg0);
|
2010-07-30 23:04:32 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto err_mmio;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NV_INFO(dev, "Detected an NV%2x generation card (0x%08x)\n",
|
|
|
|
dev_priv->card_type, reg0);
|
|
|
|
|
2010-06-01 13:56:22 +08:00
|
|
|
ret = nouveau_remove_conflicting_drivers(dev);
|
|
|
|
if (ret)
|
2010-07-30 23:04:32 +08:00
|
|
|
goto err_mmio;
|
2010-05-16 23:29:56 +08:00
|
|
|
|
2010-06-02 08:16:24 +08:00
|
|
|
/* Map PRAMIN BAR, or on older cards, the aperture withing BAR0 */
|
2009-12-11 17:24:15 +08:00
|
|
|
if (dev_priv->card_type >= NV_40) {
|
|
|
|
int ramin_bar = 2;
|
|
|
|
if (pci_resource_len(dev->pdev, ramin_bar) == 0)
|
|
|
|
ramin_bar = 3;
|
|
|
|
|
|
|
|
dev_priv->ramin_size = pci_resource_len(dev->pdev, ramin_bar);
|
2010-06-02 08:16:24 +08:00
|
|
|
dev_priv->ramin =
|
|
|
|
ioremap(pci_resource_start(dev->pdev, ramin_bar),
|
2009-12-11 17:24:15 +08:00
|
|
|
dev_priv->ramin_size);
|
|
|
|
if (!dev_priv->ramin) {
|
2010-06-02 08:16:24 +08:00
|
|
|
NV_ERROR(dev, "Failed to PRAMIN BAR");
|
2010-07-30 23:04:32 +08:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_mmio;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
2010-06-02 08:16:24 +08:00
|
|
|
} else {
|
2009-12-11 17:24:15 +08:00
|
|
|
dev_priv->ramin_size = 1 * 1024 * 1024;
|
|
|
|
dev_priv->ramin = ioremap(mmio_start_offs + NV_RAMIN,
|
2010-06-02 08:16:24 +08:00
|
|
|
dev_priv->ramin_size);
|
2009-12-11 17:24:15 +08:00
|
|
|
if (!dev_priv->ramin) {
|
|
|
|
NV_ERROR(dev, "Failed to map BAR0 PRAMIN.\n");
|
2010-07-30 23:04:32 +08:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_mmio;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nouveau_OF_copy_vbios_to_ramin(dev);
|
|
|
|
|
|
|
|
/* Special flags */
|
|
|
|
if (dev->pci_device == 0x01a0)
|
|
|
|
dev_priv->flags |= NV_NFORCE;
|
|
|
|
else if (dev->pci_device == 0x01f0)
|
|
|
|
dev_priv->flags |= NV_NFORCE2;
|
|
|
|
|
|
|
|
/* For kernel modesetting, init card now and bring up fbcon */
|
2010-06-01 13:56:22 +08:00
|
|
|
ret = nouveau_card_init(dev);
|
|
|
|
if (ret)
|
2010-07-30 23:04:32 +08:00
|
|
|
goto err_ramin;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
return 0;
|
2010-07-30 23:04:32 +08:00
|
|
|
|
|
|
|
err_ramin:
|
|
|
|
iounmap(dev_priv->ramin);
|
|
|
|
err_mmio:
|
|
|
|
iounmap(dev_priv->mmio);
|
|
|
|
err_wq:
|
|
|
|
destroy_workqueue(dev_priv->wq);
|
|
|
|
err_priv:
|
|
|
|
kfree(dev_priv);
|
|
|
|
dev->dev_private = NULL;
|
|
|
|
err_out:
|
|
|
|
return ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void nouveau_lastclose(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int nouveau_unload(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
2010-07-24 23:37:33 +08:00
|
|
|
struct nouveau_engine *engine = &dev_priv->engine;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-06-01 13:56:22 +08:00
|
|
|
drm_kms_helper_poll_fini(dev);
|
|
|
|
nouveau_fbcon_fini(dev);
|
2010-07-24 23:37:33 +08:00
|
|
|
engine->display.destroy(dev);
|
2010-06-01 13:56:22 +08:00
|
|
|
nouveau_card_takedown(dev);
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
iounmap(dev_priv->mmio);
|
|
|
|
iounmap(dev_priv->ramin);
|
|
|
|
|
|
|
|
kfree(dev_priv);
|
|
|
|
dev->dev_private = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nouveau_ioctl_getparam(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
struct drm_nouveau_getparam *getparam = data;
|
|
|
|
|
|
|
|
switch (getparam->param) {
|
|
|
|
case NOUVEAU_GETPARAM_CHIPSET_ID:
|
|
|
|
getparam->value = dev_priv->chipset;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_PCI_VENDOR:
|
|
|
|
getparam->value = dev->pci_vendor;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_PCI_DEVICE:
|
|
|
|
getparam->value = dev->pci_device;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_BUS_TYPE:
|
|
|
|
if (drm_device_is_agp(dev))
|
|
|
|
getparam->value = NV_AGP;
|
|
|
|
else if (drm_device_is_pcie(dev))
|
|
|
|
getparam->value = NV_PCIE;
|
|
|
|
else
|
|
|
|
getparam->value = NV_PCI;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_FB_PHYSICAL:
|
|
|
|
getparam->value = dev_priv->fb_phys;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_AGP_PHYSICAL:
|
|
|
|
getparam->value = dev_priv->gart_info.aper_base;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_PCI_PHYSICAL:
|
|
|
|
if (dev->sg) {
|
|
|
|
getparam->value = (unsigned long)dev->sg->virtual;
|
|
|
|
} else {
|
|
|
|
NV_ERROR(dev, "Requested PCIGART address, "
|
|
|
|
"while no PCIGART was created\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_FB_SIZE:
|
|
|
|
getparam->value = dev_priv->fb_available_size;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_AGP_SIZE:
|
|
|
|
getparam->value = dev_priv->gart_info.aper_size;
|
|
|
|
break;
|
|
|
|
case NOUVEAU_GETPARAM_VM_VRAM_BASE:
|
|
|
|
getparam->value = dev_priv->vm_vram_base;
|
|
|
|
break;
|
2010-05-23 19:36:04 +08:00
|
|
|
case NOUVEAU_GETPARAM_PTIMER_TIME:
|
|
|
|
getparam->value = dev_priv->engine.timer.read(dev);
|
|
|
|
break;
|
2010-01-27 02:39:20 +08:00
|
|
|
case NOUVEAU_GETPARAM_GRAPH_UNITS:
|
|
|
|
/* NV40 and NV50 versions are quite different, but register
|
|
|
|
* address is the same. User is supposed to know the card
|
|
|
|
* family anyway... */
|
|
|
|
if (dev_priv->chipset >= 0x40) {
|
|
|
|
getparam->value = nv_rd32(dev, NV40_PMC_GRAPH_UNITS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FALLTHRU */
|
2009-12-11 17:24:15 +08:00
|
|
|
default:
|
|
|
|
NV_ERROR(dev, "unknown parameter %lld\n", getparam->param);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
nouveau_ioctl_setparam(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_setparam *setparam = data;
|
|
|
|
|
|
|
|
switch (setparam->param) {
|
|
|
|
default:
|
|
|
|
NV_ERROR(dev, "unknown parameter %lld\n", setparam->param);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait until (value(reg) & mask) == val, up until timeout has hit */
|
|
|
|
bool nouveau_wait_until(struct drm_device *dev, uint64_t timeout,
|
|
|
|
uint32_t reg, uint32_t mask, uint32_t val)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
struct nouveau_timer_engine *ptimer = &dev_priv->engine.timer;
|
|
|
|
uint64_t start = ptimer->read(dev);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if ((nv_rd32(dev, reg) & mask) == val)
|
|
|
|
return true;
|
|
|
|
} while (ptimer->read(dev) - start < timeout);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Waits for PGRAPH to go completely idle */
|
|
|
|
bool nouveau_wait_for_idle(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
if (!nv_wait(NV04_PGRAPH_STATUS, 0xffffffff, 0x00000000)) {
|
|
|
|
NV_ERROR(dev, "PGRAPH idle timed out with status 0x%08x\n",
|
|
|
|
nv_rd32(dev, NV04_PGRAPH_STATUS));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|