2012-07-31 14:16:21 +08:00
|
|
|
#include <linux/vgaarb.h>
|
|
|
|
#include <linux/vga_switcheroo.h>
|
|
|
|
|
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm merge (part 1) from Dave Airlie:
"So first of all my tree and uapi stuff has a conflict mess, its my
fault as the nouveau stuff didn't hit -next as were trying to rebase
regressions out of it before we merged.
Highlights:
- SH mobile modesetting driver and associated helpers
- some DRM core documentation
- i915 modesetting rework, haswell hdmi, haswell and vlv fixes, write
combined pte writing, ilk rc6 support,
- nouveau: major driver rework into a hw core driver, makes features
like SLI a lot saner to implement,
- psb: add eDP/DP support for Cedarview
- radeon: 2 layer page tables, async VM pte updates, better PLL
selection for > 2 screens, better ACPI interactions
The rest is general grab bag of fixes.
So why part 1? well I have the exynos pull req which came in a bit
late but was waiting for me to do something they shouldn't have and it
looks fairly safe, and David Howells has some more header cleanups
he'd like me to pull, that seem like a good idea, but I'd like to get
this merge out of the way so -next dosen't get blocked."
Tons of conflicts mostly due to silly include line changes, but mostly
mindless. A few other small semantic conflicts too, noted from Dave's
pre-merged branch.
* 'drm-next' of git://people.freedesktop.org/~airlied/linux: (447 commits)
drm/nv98/crypt: fix fuc build with latest envyas
drm/nouveau/devinit: fixup various issues with subdev ctor/init ordering
drm/nv41/vm: fix and enable use of "real" pciegart
drm/nv44/vm: fix and enable use of "real" pciegart
drm/nv04/dmaobj: fixup vm target handling in preparation for nv4x pcie
drm/nouveau: store supported dma mask in vmmgr
drm/nvc0/ibus: initial implementation of subdev
drm/nouveau/therm: add support for fan-control modes
drm/nouveau/hwmon: rename pwm0* to pmw1* to follow hwmon's rules
drm/nouveau/therm: calculate the pwm divisor on nv50+
drm/nouveau/fan: rewrite the fan tachometer driver to get more precision, faster
drm/nouveau/therm: move thermal-related functions to the therm subdev
drm/nouveau/bios: parse the pwm divisor from the perf table
drm/nouveau/therm: use the EXTDEV table to detect i2c monitoring devices
drm/nouveau/therm: rework thermal table parsing
drm/nouveau/gpio: expose the PWM/TOGGLE parameter found in the gpio vbios table
drm/nouveau: fix pm initialization order
drm/nouveau/bios: check that fixed tvdac gpio data is valid before using it
drm/nouveau: log channel debug/error messages from client object rather than drm client
drm/nouveau: have drm debugging macros build on top of core macros
...
2012-10-04 14:29:23 +08:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/drm_crtc_helper.h>
|
2012-07-31 14:16:21 +08:00
|
|
|
|
|
|
|
#include "nouveau_drm.h"
|
|
|
|
#include "nouveau_acpi.h"
|
|
|
|
#include "nouveau_fbcon.h"
|
2012-08-20 05:00:00 +08:00
|
|
|
#include "nouveau_vga.h"
|
2012-07-31 14:16:21 +08:00
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
nouveau_vga_set_decode(void *priv, bool state)
|
|
|
|
{
|
2014-08-10 02:10:22 +08:00
|
|
|
struct nouveau_object *device = nouveau_drm(priv)->device;
|
2012-07-31 14:16:21 +08:00
|
|
|
|
2014-08-10 02:10:22 +08:00
|
|
|
if (nv_device(device)->card_type == NV_40 &&
|
|
|
|
nv_device(device)->chipset >= 0x4c)
|
|
|
|
nvif_wr32(device, 0x088060, state);
|
2012-07-31 14:16:21 +08:00
|
|
|
else
|
2014-08-10 02:10:22 +08:00
|
|
|
if (nv_device(device)->chipset >= 0x40)
|
|
|
|
nvif_wr32(device, 0x088054, state);
|
|
|
|
else
|
|
|
|
nvif_wr32(device, 0x001854, state);
|
2012-07-31 14:16:21 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nouveau_switcheroo_set_state(struct pci_dev *pdev,
|
|
|
|
enum vga_switcheroo_state state)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
|
|
|
|
2012-09-10 12:20:51 +08:00
|
|
|
if ((nouveau_is_optimus() || nouveau_is_v1_dsm()) && state == VGA_SWITCHEROO_OFF)
|
|
|
|
return;
|
|
|
|
|
2012-07-31 14:16:21 +08:00
|
|
|
if (state == VGA_SWITCHEROO_ON) {
|
|
|
|
printk(KERN_ERR "VGA switcheroo: switched nouveau on\n");
|
|
|
|
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
|
2012-11-02 09:04:28 +08:00
|
|
|
nouveau_pmops_resume(&pdev->dev);
|
2012-07-31 14:16:21 +08:00
|
|
|
drm_kms_helper_poll_enable(dev);
|
|
|
|
dev->switch_power_state = DRM_SWITCH_POWER_ON;
|
|
|
|
} else {
|
|
|
|
printk(KERN_ERR "VGA switcheroo: switched nouveau off\n");
|
|
|
|
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
|
|
|
|
drm_kms_helper_poll_disable(dev);
|
|
|
|
nouveau_switcheroo_optimus_dsm();
|
2012-11-02 09:04:28 +08:00
|
|
|
nouveau_pmops_suspend(&pdev->dev);
|
2012-07-31 14:16:21 +08:00
|
|
|
dev->switch_power_state = DRM_SWITCH_POWER_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nouveau_switcheroo_reprobe(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
|
|
|
nouveau_fbcon_output_poll_changed(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
nouveau_switcheroo_can_switch(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = pci_get_drvdata(pdev);
|
|
|
|
|
2013-11-04 03:46:34 +08:00
|
|
|
/*
|
|
|
|
* FIXME: open_count is protected by drm_global_mutex but that would lead to
|
|
|
|
* locking inversion with the driver load path. And the access here is
|
|
|
|
* completely racy anyway. So don't bother with locking for now.
|
|
|
|
*/
|
|
|
|
return dev->open_count == 0;
|
2012-07-31 14:16:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct vga_switcheroo_client_ops
|
|
|
|
nouveau_switcheroo_ops = {
|
|
|
|
.set_gpu_state = nouveau_switcheroo_set_state,
|
|
|
|
.reprobe = nouveau_switcheroo_reprobe,
|
|
|
|
.can_switch = nouveau_switcheroo_can_switch,
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
nouveau_vga_init(struct nouveau_drm *drm)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = drm->dev;
|
2012-09-10 12:20:51 +08:00
|
|
|
bool runtime = false;
|
2014-02-17 14:17:26 +08:00
|
|
|
|
|
|
|
/* only relevant for PCI devices */
|
|
|
|
if (!dev->pdev)
|
|
|
|
return;
|
|
|
|
|
2012-07-31 14:16:21 +08:00
|
|
|
vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
|
2012-09-10 12:20:51 +08:00
|
|
|
|
|
|
|
if (nouveau_runtime_pm == 1)
|
|
|
|
runtime = true;
|
|
|
|
if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_is_v1_dsm()))
|
|
|
|
runtime = true;
|
|
|
|
vga_switcheroo_register_client(dev->pdev, &nouveau_switcheroo_ops, runtime);
|
|
|
|
|
|
|
|
if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus())
|
|
|
|
vga_switcheroo_init_domain_pm_ops(drm->dev->dev, &drm->vga_pm_domain);
|
2012-07-31 14:16:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nouveau_vga_fini(struct nouveau_drm *drm)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = drm->dev;
|
|
|
|
vga_switcheroo_unregister_client(dev->pdev);
|
|
|
|
vga_client_register(dev->pdev, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nouveau_vga_lastclose(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
vga_switcheroo_process_delayed_switch();
|
|
|
|
}
|