2009-12-11 12:24:15 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Stephane Marchesin.
|
|
|
|
* 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
|
|
|
|
* VA LINUX SYSTEMS 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NOUVEAU_DRV_H__
|
|
|
|
#define __NOUVEAU_DRV_H__
|
|
|
|
|
|
|
|
#define DRIVER_AUTHOR "Stephane Marchesin"
|
2012-03-16 06:44:34 +04:00
|
|
|
#define DRIVER_EMAIL "nouveau@lists.freedesktop.org"
|
2009-12-11 12:24:15 +03:00
|
|
|
|
|
|
|
#define DRIVER_NAME "nouveau"
|
|
|
|
#define DRIVER_DESC "nVidia Riva/TNT/GeForce"
|
2012-03-16 06:44:34 +04:00
|
|
|
#define DRIVER_DATE "20120316"
|
2009-12-11 12:24:15 +03:00
|
|
|
|
2012-03-16 06:44:34 +04:00
|
|
|
#define DRIVER_MAJOR 1
|
2009-12-11 12:24:15 +03:00
|
|
|
#define DRIVER_MINOR 0
|
2012-03-16 06:44:34 +04:00
|
|
|
#define DRIVER_PATCHLEVEL 0
|
2009-12-11 12:24:15 +03:00
|
|
|
|
|
|
|
#define NOUVEAU_FAMILY 0x0000FFFF
|
|
|
|
#define NOUVEAU_FLAGS 0xFFFF0000
|
|
|
|
|
|
|
|
#include "ttm/ttm_bo_api.h"
|
|
|
|
#include "ttm/ttm_bo_driver.h"
|
|
|
|
#include "ttm/ttm_placement.h"
|
|
|
|
#include "ttm/ttm_memory.h"
|
|
|
|
#include "ttm/ttm_module.h"
|
|
|
|
|
2012-07-11 13:05:01 +04:00
|
|
|
#define XXX_THIS_IS_A_HACK
|
2012-07-14 13:09:17 +04:00
|
|
|
#include <subdev/vm.h>
|
2012-07-11 13:05:01 +04:00
|
|
|
#include <subdev/fb.h>
|
2012-07-14 13:09:17 +04:00
|
|
|
#include <core/gpuobj.h>
|
2012-07-11 13:05:01 +04:00
|
|
|
|
|
|
|
enum blah {
|
|
|
|
NV_MEM_TYPE_UNKNOWN = 0,
|
|
|
|
NV_MEM_TYPE_STOLEN,
|
|
|
|
NV_MEM_TYPE_SGRAM,
|
|
|
|
NV_MEM_TYPE_SDRAM,
|
|
|
|
NV_MEM_TYPE_DDR1,
|
|
|
|
NV_MEM_TYPE_DDR2,
|
|
|
|
NV_MEM_TYPE_DDR3,
|
|
|
|
NV_MEM_TYPE_GDDR2,
|
|
|
|
NV_MEM_TYPE_GDDR3,
|
|
|
|
NV_MEM_TYPE_GDDR4,
|
|
|
|
NV_MEM_TYPE_GDDR5
|
|
|
|
};
|
|
|
|
|
2012-07-06 06:14:00 +04:00
|
|
|
#include <nouveau_drm.h>
|
2009-12-11 12:24:15 +03:00
|
|
|
#include "nouveau_reg.h"
|
2012-07-04 17:44:54 +04:00
|
|
|
#include <nouveau_bios.h>
|
2010-11-15 04:53:16 +03:00
|
|
|
|
2012-07-10 11:26:46 +04:00
|
|
|
#include <subdev/bios/pll.h>
|
|
|
|
#include "nouveau_compat.h"
|
|
|
|
|
2012-07-14 13:09:17 +04:00
|
|
|
#define nouveau_gpuobj_new(d,c,s,a,f,o) \
|
2012-07-20 02:17:34 +04:00
|
|
|
_nouveau_gpuobj_new((d), NULL, (s), (a), (f), (o))
|
2012-07-14 13:09:17 +04:00
|
|
|
|
|
|
|
#define nouveau_vm_new(d,o,l,m,v) \
|
|
|
|
_nouveau_vm_new((d), (o), (l), (m), (v))
|
|
|
|
|
|
|
|
#define nv50_vm_flush_engine(d,e) \
|
|
|
|
_nv50_vm_flush_engine((d), (e))
|
|
|
|
|
2012-07-18 11:17:09 +04:00
|
|
|
#include "nouveau_bo.h"
|
2012-07-18 16:15:33 +04:00
|
|
|
#include "nouveau_gem.h"
|
2009-12-11 12:24:15 +03:00
|
|
|
|
2010-10-21 01:35:40 +04:00
|
|
|
struct nouveau_page_flip_state {
|
|
|
|
struct list_head head;
|
|
|
|
struct drm_pending_vblank_event *event;
|
|
|
|
int crtc, bpp, pitch, x, y;
|
|
|
|
uint64_t offset;
|
|
|
|
};
|
|
|
|
|
2010-07-24 19:37:33 +04:00
|
|
|
struct nouveau_display_engine {
|
2011-02-01 03:07:32 +03:00
|
|
|
void *priv;
|
2010-07-24 19:37:33 +04:00
|
|
|
int (*early_init)(struct drm_device *);
|
|
|
|
void (*late_takedown)(struct drm_device *);
|
|
|
|
int (*create)(struct drm_device *);
|
|
|
|
void (*destroy)(struct drm_device *);
|
2011-11-09 05:36:33 +04:00
|
|
|
int (*init)(struct drm_device *);
|
|
|
|
void (*fini)(struct drm_device *);
|
2011-10-06 07:29:05 +04:00
|
|
|
|
2011-10-17 06:23:41 +04:00
|
|
|
struct drm_property *dithering_mode;
|
|
|
|
struct drm_property *dithering_depth;
|
2011-10-06 07:29:05 +04:00
|
|
|
struct drm_property *underscan_property;
|
|
|
|
struct drm_property *underscan_hborder_property;
|
|
|
|
struct drm_property *underscan_vborder_property;
|
2012-01-22 02:13:26 +04:00
|
|
|
/* not really hue and saturation: */
|
|
|
|
struct drm_property *vibrant_hue_property;
|
|
|
|
struct drm_property *color_vibrance_property;
|
2010-07-24 19:37:33 +04:00
|
|
|
};
|
|
|
|
|
2010-09-16 09:39:49 +04:00
|
|
|
struct nouveau_pm_voltage_level {
|
2011-06-09 07:45:31 +04:00
|
|
|
u32 voltage; /* microvolts */
|
|
|
|
u8 vid;
|
2010-09-16 09:39:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nouveau_pm_voltage {
|
|
|
|
bool supported;
|
2011-06-10 09:33:11 +04:00
|
|
|
u8 version;
|
2010-09-16 09:39:49 +04:00
|
|
|
u8 vid_mask;
|
|
|
|
|
|
|
|
struct nouveau_pm_voltage_level *level;
|
|
|
|
int nr_level;
|
|
|
|
};
|
|
|
|
|
2012-01-09 09:23:07 +04:00
|
|
|
/* Exclusive upper limits */
|
|
|
|
#define NV_MEM_CL_DDR2_MAX 8
|
|
|
|
#define NV_MEM_WR_DDR2_MAX 9
|
|
|
|
#define NV_MEM_CL_DDR3_MAX 17
|
|
|
|
#define NV_MEM_WR_DDR3_MAX 17
|
|
|
|
#define NV_MEM_CL_GDDR3_MAX 16
|
|
|
|
#define NV_MEM_WR_GDDR3_MAX 18
|
|
|
|
#define NV_MEM_CL_GDDR5_MAX 21
|
|
|
|
#define NV_MEM_WR_GDDR5_MAX 20
|
|
|
|
|
2011-04-14 02:46:19 +04:00
|
|
|
struct nouveau_pm_memtiming {
|
|
|
|
int id;
|
2012-01-09 09:23:07 +04:00
|
|
|
|
|
|
|
u32 reg[9];
|
|
|
|
u32 mr[4];
|
|
|
|
|
2011-11-25 18:52:22 +04:00
|
|
|
u8 tCWL;
|
|
|
|
|
2012-01-09 09:23:07 +04:00
|
|
|
u8 odt;
|
|
|
|
u8 drive_strength;
|
2011-07-09 23:18:11 +04:00
|
|
|
};
|
|
|
|
|
2011-12-17 15:24:59 +04:00
|
|
|
struct nouveau_pm_tbl_header {
|
2011-07-09 23:18:11 +04:00
|
|
|
u8 version;
|
|
|
|
u8 header_len;
|
|
|
|
u8 entry_cnt;
|
|
|
|
u8 entry_len;
|
|
|
|
};
|
|
|
|
|
2011-12-17 15:24:59 +04:00
|
|
|
struct nouveau_pm_tbl_entry {
|
2011-07-14 22:40:10 +04:00
|
|
|
u8 tWR;
|
2011-11-25 18:52:22 +04:00
|
|
|
u8 tWTR;
|
2011-07-14 22:40:10 +04:00
|
|
|
u8 tCL;
|
2011-11-25 18:52:22 +04:00
|
|
|
u8 tRC;
|
2011-07-09 23:18:11 +04:00
|
|
|
u8 empty_4;
|
2011-11-25 18:52:22 +04:00
|
|
|
u8 tRFC; /* Byte 5 */
|
2011-07-09 23:18:11 +04:00
|
|
|
u8 empty_6;
|
2011-11-25 18:52:22 +04:00
|
|
|
u8 tRAS; /* Byte 7 */
|
2011-07-09 23:18:11 +04:00
|
|
|
u8 empty_8;
|
2011-11-25 18:52:22 +04:00
|
|
|
u8 tRP; /* Byte 9 */
|
|
|
|
u8 tRCDRD;
|
|
|
|
u8 tRCDWR;
|
|
|
|
u8 tRRD;
|
|
|
|
u8 tUNK_13;
|
|
|
|
u8 RAM_FT1; /* 14, a bitmask of random RAM features */
|
|
|
|
u8 empty_15;
|
|
|
|
u8 tUNK_16;
|
|
|
|
u8 empty_17;
|
|
|
|
u8 tUNK_18;
|
|
|
|
u8 tCWL;
|
|
|
|
u8 tUNK_20, tUNK_21;
|
2011-07-09 23:18:11 +04:00
|
|
|
};
|
|
|
|
|
2012-01-24 09:59:07 +04:00
|
|
|
struct nouveau_pm_profile;
|
|
|
|
struct nouveau_pm_profile_func {
|
2012-01-24 12:03:25 +04:00
|
|
|
void (*destroy)(struct nouveau_pm_profile *);
|
|
|
|
void (*init)(struct nouveau_pm_profile *);
|
|
|
|
void (*fini)(struct nouveau_pm_profile *);
|
2012-01-24 09:59:07 +04:00
|
|
|
struct nouveau_pm_level *(*select)(struct nouveau_pm_profile *);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nouveau_pm_profile {
|
|
|
|
const struct nouveau_pm_profile_func *func;
|
|
|
|
struct list_head head;
|
|
|
|
char name[8];
|
|
|
|
};
|
|
|
|
|
2010-09-16 09:39:49 +04:00
|
|
|
#define NOUVEAU_PM_MAX_LEVEL 8
|
|
|
|
struct nouveau_pm_level {
|
2012-01-24 09:59:07 +04:00
|
|
|
struct nouveau_pm_profile profile;
|
2010-09-16 09:39:49 +04:00
|
|
|
struct device_attribute dev_attr;
|
|
|
|
char name[32];
|
|
|
|
int id;
|
|
|
|
|
2012-01-24 09:59:07 +04:00
|
|
|
struct nouveau_pm_memtiming timing;
|
2010-09-16 09:39:49 +04:00
|
|
|
u32 memory;
|
2012-01-18 03:02:28 +04:00
|
|
|
u16 memscript;
|
|
|
|
|
|
|
|
u32 core;
|
2010-09-16 09:39:49 +04:00
|
|
|
u32 shader;
|
2011-06-21 09:12:26 +04:00
|
|
|
u32 rop;
|
|
|
|
u32 copy;
|
|
|
|
u32 daemon;
|
2011-06-17 10:11:31 +04:00
|
|
|
u32 vdec;
|
2011-10-26 03:11:02 +04:00
|
|
|
u32 dom6;
|
2011-06-21 09:12:26 +04:00
|
|
|
u32 unka0; /* nva3:nvc0 */
|
|
|
|
u32 hub01; /* nvc0- */
|
|
|
|
u32 hub06; /* nvc0- */
|
|
|
|
u32 hub07; /* nvc0- */
|
2010-09-16 09:39:49 +04:00
|
|
|
|
2011-06-09 10:57:07 +04:00
|
|
|
u32 volt_min; /* microvolts */
|
|
|
|
u32 volt_max;
|
2011-06-09 07:45:31 +04:00
|
|
|
u8 fanspeed;
|
2010-09-16 09:39:49 +04:00
|
|
|
};
|
|
|
|
|
2010-09-22 22:54:22 +04:00
|
|
|
struct nouveau_pm_temp_sensor_constants {
|
|
|
|
u16 offset_constant;
|
|
|
|
s16 offset_mult;
|
2011-06-22 05:13:23 +04:00
|
|
|
s16 offset_div;
|
|
|
|
s16 slope_mult;
|
|
|
|
s16 slope_div;
|
2010-09-22 22:54:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nouveau_pm_threshold_temp {
|
|
|
|
s16 critical;
|
|
|
|
s16 down_clock;
|
|
|
|
s16 fan_boost;
|
|
|
|
};
|
|
|
|
|
2011-08-15 05:10:30 +04:00
|
|
|
struct nouveau_pm_fan {
|
2011-10-07 03:33:12 +04:00
|
|
|
u32 percent;
|
2011-08-15 05:10:30 +04:00
|
|
|
u32 min_duty;
|
|
|
|
u32 max_duty;
|
2011-08-15 10:13:34 +04:00
|
|
|
u32 pwm_freq;
|
2011-08-20 18:37:06 +04:00
|
|
|
u32 pwm_divisor;
|
2011-08-15 05:10:30 +04:00
|
|
|
};
|
|
|
|
|
2010-09-16 09:39:49 +04:00
|
|
|
struct nouveau_pm_engine {
|
|
|
|
struct nouveau_pm_voltage voltage;
|
|
|
|
struct nouveau_pm_level perflvl[NOUVEAU_PM_MAX_LEVEL];
|
|
|
|
int nr_perflvl;
|
2010-09-22 22:54:22 +04:00
|
|
|
struct nouveau_pm_temp_sensor_constants sensor_constants;
|
|
|
|
struct nouveau_pm_threshold_temp threshold_temp;
|
2011-08-15 05:10:30 +04:00
|
|
|
struct nouveau_pm_fan fan;
|
2010-09-16 09:39:49 +04:00
|
|
|
|
2012-01-24 09:59:07 +04:00
|
|
|
struct nouveau_pm_profile *profile_ac;
|
|
|
|
struct nouveau_pm_profile *profile_dc;
|
2012-01-24 12:03:25 +04:00
|
|
|
struct nouveau_pm_profile *profile;
|
2012-01-24 09:59:07 +04:00
|
|
|
struct list_head profiles;
|
|
|
|
|
2010-09-16 09:39:49 +04:00
|
|
|
struct nouveau_pm_level boot;
|
|
|
|
struct nouveau_pm_level *cur;
|
|
|
|
|
2010-09-23 22:58:38 +04:00
|
|
|
struct device *hwmon;
|
2010-10-12 06:31:32 +04:00
|
|
|
struct notifier_block acpi_nb;
|
2010-09-23 22:58:38 +04:00
|
|
|
|
2011-06-17 05:25:57 +04:00
|
|
|
int (*clocks_get)(struct drm_device *, struct nouveau_pm_level *);
|
|
|
|
void *(*clocks_pre)(struct drm_device *, struct nouveau_pm_level *);
|
2011-07-10 02:08:41 +04:00
|
|
|
int (*clocks_set)(struct drm_device *, void *);
|
2011-06-17 05:25:57 +04:00
|
|
|
|
2010-09-16 09:39:49 +04:00
|
|
|
int (*voltage_get)(struct drm_device *);
|
|
|
|
int (*voltage_set)(struct drm_device *, int voltage);
|
2011-11-21 15:28:28 +04:00
|
|
|
int (*pwm_get)(struct drm_device *, int line, u32*, u32*);
|
|
|
|
int (*pwm_set)(struct drm_device *, int line, u32, u32);
|
2010-09-23 22:58:38 +04:00
|
|
|
int (*temp_get)(struct drm_device *);
|
2010-09-16 09:39:49 +04:00
|
|
|
};
|
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
struct nouveau_engine {
|
2010-07-24 19:37:33 +04:00
|
|
|
struct nouveau_display_engine display;
|
2010-09-16 09:39:49 +04:00
|
|
|
struct nouveau_pm_engine pm;
|
2009-12-11 12:24:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum nouveau_card_type {
|
2012-03-12 09:55:43 +04:00
|
|
|
NV_04 = 0x04,
|
2009-12-11 12:24:15 +03:00
|
|
|
NV_10 = 0x10,
|
|
|
|
NV_20 = 0x20,
|
|
|
|
NV_30 = 0x30,
|
|
|
|
NV_40 = 0x40,
|
|
|
|
NV_50 = 0x50,
|
2010-08-03 04:00:56 +04:00
|
|
|
NV_C0 = 0xc0,
|
2012-03-12 09:55:43 +04:00
|
|
|
NV_D0 = 0xd0,
|
2012-03-04 08:47:55 +04:00
|
|
|
NV_E0 = 0xe0,
|
2009-12-11 12:24:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_nouveau_private {
|
|
|
|
struct drm_device *dev;
|
|
|
|
|
2012-07-06 06:14:00 +04:00
|
|
|
void *newpriv;
|
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
/* the card type, takes NV_* as values */
|
|
|
|
enum nouveau_card_type card_type;
|
|
|
|
/* exact chipset, derived from NV_PMC_BOOT_0 */
|
|
|
|
int chipset;
|
2011-07-21 09:39:06 +04:00
|
|
|
u32 crystal;
|
2009-12-11 12:24:15 +03:00
|
|
|
|
2010-10-21 08:07:03 +04:00
|
|
|
/* interrupt handling */
|
2010-11-03 02:57:28 +03:00
|
|
|
void (*irq_handler[32])(struct drm_device *);
|
2010-10-21 08:07:03 +04:00
|
|
|
bool msi_enabled;
|
2010-11-17 02:40:52 +03:00
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
struct nouveau_engine engine;
|
|
|
|
|
2010-02-01 22:58:27 +03:00
|
|
|
/* For PFIFO and PGRAPH. */
|
|
|
|
spinlock_t context_switch_lock;
|
|
|
|
|
2010-02-24 03:03:05 +03:00
|
|
|
struct nvbios vbios;
|
2009-12-11 12:24:15 +03:00
|
|
|
};
|
|
|
|
|
2010-09-21 20:57:11 +04:00
|
|
|
static inline struct drm_nouveau_private *
|
|
|
|
nouveau_private(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return dev->dev_private;
|
|
|
|
}
|
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
/* nouveau_drv.c */
|
2011-07-04 07:14:05 +04:00
|
|
|
extern int nouveau_modeset;
|
2009-12-11 12:24:15 +03:00
|
|
|
extern int nouveau_duallink;
|
|
|
|
extern int nouveau_uscript_lvds;
|
|
|
|
extern int nouveau_uscript_tmds;
|
|
|
|
extern int nouveau_vram_pushbuf;
|
|
|
|
extern int nouveau_vram_notify;
|
2011-12-10 18:30:05 +04:00
|
|
|
extern char *nouveau_vram_type;
|
2009-12-11 12:24:15 +03:00
|
|
|
extern int nouveau_fbpercrtc;
|
2010-03-15 02:43:51 +03:00
|
|
|
extern int nouveau_tv_disable;
|
2009-12-11 12:24:15 +03:00
|
|
|
extern char *nouveau_tv_norm;
|
2010-01-18 04:42:37 +03:00
|
|
|
extern int nouveau_ignorelid;
|
2010-09-29 15:15:01 +04:00
|
|
|
extern int nouveau_force_post;
|
2010-03-04 05:00:39 +03:00
|
|
|
extern int nouveau_override_conntype;
|
2010-09-16 10:47:14 +04:00
|
|
|
extern char *nouveau_perflvl;
|
|
|
|
extern int nouveau_perflvl_wr;
|
2010-10-21 08:07:03 +04:00
|
|
|
extern int nouveau_msi;
|
2011-05-25 12:32:44 +04:00
|
|
|
extern int nouveau_ctxfw;
|
2011-10-12 10:36:42 +04:00
|
|
|
extern int nouveau_mxmdcb;
|
2009-12-11 12:24:15 +03:00
|
|
|
|
2010-02-01 08:38:10 +03:00
|
|
|
extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);
|
|
|
|
extern int nouveau_pci_resume(struct pci_dev *pdev);
|
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
/* nouveau_state.c */
|
|
|
|
extern int nouveau_load(struct drm_device *, unsigned long flags);
|
|
|
|
extern int nouveau_firstopen(struct drm_device *);
|
|
|
|
extern void nouveau_lastclose(struct drm_device *);
|
|
|
|
extern int nouveau_unload(struct drm_device *);
|
|
|
|
extern int nouveau_card_init(struct drm_device *);
|
|
|
|
|
|
|
|
/* nouveau_mem.c */
|
2012-01-18 03:02:28 +04:00
|
|
|
extern int nouveau_mem_timing_calc(struct drm_device *, u32 freq,
|
|
|
|
struct nouveau_pm_memtiming *);
|
2012-01-17 15:10:58 +04:00
|
|
|
extern void nouveau_mem_timing_read(struct drm_device *,
|
|
|
|
struct nouveau_pm_memtiming *);
|
2012-07-13 11:05:35 +04:00
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
/* nouveau_irq.c */
|
2010-10-21 08:07:03 +04:00
|
|
|
extern int nouveau_irq_init(struct drm_device *);
|
|
|
|
extern void nouveau_irq_fini(struct drm_device *);
|
2009-12-11 12:24:15 +03:00
|
|
|
extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS);
|
2010-11-03 02:57:28 +03:00
|
|
|
extern void nouveau_irq_register(struct drm_device *, int status_bit,
|
|
|
|
void (*)(struct drm_device *));
|
|
|
|
extern void nouveau_irq_unregister(struct drm_device *, int status_bit);
|
2009-12-11 12:24:15 +03:00
|
|
|
extern void nouveau_irq_preinstall(struct drm_device *);
|
|
|
|
extern int nouveau_irq_postinstall(struct drm_device *);
|
|
|
|
extern void nouveau_irq_uninstall(struct drm_device *);
|
|
|
|
|
|
|
|
/* nouveau_backlight.c */
|
|
|
|
#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
|
2011-08-02 13:29:37 +04:00
|
|
|
extern int nouveau_backlight_init(struct drm_device *);
|
|
|
|
extern void nouveau_backlight_exit(struct drm_device *);
|
2009-12-11 12:24:15 +03:00
|
|
|
#else
|
2011-08-02 13:29:37 +04:00
|
|
|
static inline int nouveau_backlight_init(struct drm_device *dev)
|
2009-12-11 12:24:15 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-02 13:29:37 +04:00
|
|
|
static inline void nouveau_backlight_exit(struct drm_device *dev) { }
|
2009-12-11 12:24:15 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* nouveau_bios.c */
|
|
|
|
extern int nouveau_bios_init(struct drm_device *);
|
|
|
|
extern void nouveau_bios_takedown(struct drm_device *dev);
|
|
|
|
extern int nouveau_run_vbios_init(struct drm_device *);
|
|
|
|
extern struct dcb_connector_table_entry *
|
|
|
|
nouveau_bios_connector_entry(struct drm_device *, int index);
|
2011-07-06 15:21:42 +04:00
|
|
|
extern int nouveau_bios_run_display_table(struct drm_device *, u16 id, int clk,
|
2012-07-11 04:44:20 +04:00
|
|
|
struct dcb_output *, int crtc);
|
2009-12-11 12:24:15 +03:00
|
|
|
extern bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
|
|
|
|
extern uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
|
|
|
|
extern int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
|
|
|
|
bool *dl, bool *if_is_24bit);
|
2012-07-11 04:44:20 +04:00
|
|
|
extern int run_tmds_table(struct drm_device *, struct dcb_output *,
|
2009-12-11 12:24:15 +03:00
|
|
|
int head, int pxclk);
|
2012-07-11 04:44:20 +04:00
|
|
|
extern int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
|
2009-12-11 12:24:15 +03:00
|
|
|
enum LVDS_script, int pxclk);
|
2012-07-11 04:44:20 +04:00
|
|
|
bool bios_encoder_match(struct dcb_output *, u32 hash);
|
2009-12-11 12:24:15 +03:00
|
|
|
|
|
|
|
/* nouveau_ttm.c */
|
|
|
|
int nouveau_ttm_global_init(struct drm_nouveau_private *);
|
|
|
|
void nouveau_ttm_global_release(struct drm_nouveau_private *);
|
|
|
|
int nouveau_ttm_mmap(struct file *, struct vm_area_struct *);
|
|
|
|
|
2011-10-05 05:05:07 +04:00
|
|
|
/* nouveau_hdmi.c */
|
|
|
|
void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
|
|
|
|
|
2011-07-04 10:25:18 +04:00
|
|
|
/* nvd0_display.c */
|
|
|
|
extern int nvd0_display_create(struct drm_device *);
|
|
|
|
extern void nvd0_display_destroy(struct drm_device *);
|
2011-11-09 05:36:33 +04:00
|
|
|
extern int nvd0_display_init(struct drm_device *);
|
|
|
|
extern void nvd0_display_fini(struct drm_device *);
|
2011-11-12 08:28:12 +04:00
|
|
|
struct nouveau_bo *nvd0_display_crtc_sema(struct drm_device *, int crtc);
|
|
|
|
void nvd0_display_flip_stop(struct drm_crtc *);
|
|
|
|
int nvd0_display_flip_next(struct drm_crtc *, struct drm_framebuffer *,
|
|
|
|
struct nouveau_channel *, u32 swap_interval);
|
2011-07-04 10:25:18 +04:00
|
|
|
|
2012-04-02 14:53:06 +04:00
|
|
|
|
2010-10-21 20:19:29 +04:00
|
|
|
/* nouveau_display.c */
|
2011-10-06 06:46:40 +04:00
|
|
|
int nouveau_display_create(struct drm_device *dev);
|
|
|
|
void nouveau_display_destroy(struct drm_device *dev);
|
2011-11-09 09:18:47 +04:00
|
|
|
int nouveau_display_init(struct drm_device *dev);
|
|
|
|
void nouveau_display_fini(struct drm_device *dev);
|
2010-10-21 20:19:29 +04:00
|
|
|
int nouveau_vblank_enable(struct drm_device *dev, int crtc);
|
|
|
|
void nouveau_vblank_disable(struct drm_device *dev, int crtc);
|
2010-10-21 01:35:40 +04:00
|
|
|
int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
|
|
|
|
struct drm_pending_vblank_event *event);
|
|
|
|
int nouveau_finish_page_flip(struct nouveau_channel *,
|
|
|
|
struct nouveau_page_flip_state *);
|
2011-09-30 02:55:50 +04:00
|
|
|
int nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
|
|
|
|
struct drm_mode_create_dumb *args);
|
|
|
|
int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
|
|
|
|
uint32_t handle, uint64_t *offset);
|
|
|
|
int nouveau_display_dumb_destroy(struct drm_file *, struct drm_device *,
|
|
|
|
uint32_t handle);
|
2010-10-21 20:19:29 +04:00
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
#ifndef ioread32_native
|
|
|
|
#ifdef __BIG_ENDIAN
|
|
|
|
#define ioread16_native ioread16be
|
|
|
|
#define iowrite16_native iowrite16be
|
|
|
|
#define ioread32_native ioread32be
|
|
|
|
#define iowrite32_native iowrite32be
|
|
|
|
#else /* def __BIG_ENDIAN */
|
|
|
|
#define ioread16_native ioread16
|
|
|
|
#define iowrite16_native iowrite16
|
|
|
|
#define ioread32_native ioread32
|
|
|
|
#define iowrite32_native iowrite32
|
|
|
|
#endif /* def __BIG_ENDIAN else */
|
|
|
|
#endif /* !ioread32_native */
|
|
|
|
|
|
|
|
/* register access */
|
2012-07-09 08:14:48 +04:00
|
|
|
#define nv_rd08 _nv_rd08
|
|
|
|
#define nv_wr08 _nv_wr08
|
|
|
|
#define nv_rd32 _nv_rd32
|
|
|
|
#define nv_wr32 _nv_wr32
|
|
|
|
#define nv_mask _nv_mask
|
2009-12-11 12:24:15 +03:00
|
|
|
|
2010-09-07 19:34:44 +04:00
|
|
|
#define nv_wait(dev, reg, mask, val) \
|
2010-11-19 07:32:56 +03:00
|
|
|
nouveau_wait_eq(dev, 2000000000ULL, (reg), (mask), (val))
|
|
|
|
#define nv_wait_ne(dev, reg, mask, val) \
|
|
|
|
nouveau_wait_ne(dev, 2000000000ULL, (reg), (mask), (val))
|
2011-06-18 10:27:24 +04:00
|
|
|
#define nv_wait_cb(dev, func, data) \
|
|
|
|
nouveau_wait_cb(dev, 2000000000ULL, (func), (data))
|
2009-12-11 12:24:15 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Logging
|
|
|
|
* Argument d is (struct drm_device *).
|
|
|
|
*/
|
|
|
|
#define NV_PRINTK(level, d, fmt, arg...) \
|
|
|
|
printk(level "[" DRM_NAME "] " DRIVER_NAME " %s: " fmt, \
|
|
|
|
pci_name(d->pdev), ##arg)
|
|
|
|
#ifndef NV_DEBUG_NOTRACE
|
|
|
|
#define NV_DEBUG(d, fmt, arg...) do { \
|
2009-12-13 18:53:12 +03:00
|
|
|
if (drm_debug & DRM_UT_DRIVER) { \
|
|
|
|
NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \
|
|
|
|
__LINE__, ##arg); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#define NV_DEBUG_KMS(d, fmt, arg...) do { \
|
|
|
|
if (drm_debug & DRM_UT_KMS) { \
|
2009-12-11 12:24:15 +03:00
|
|
|
NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \
|
|
|
|
__LINE__, ##arg); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define NV_DEBUG(d, fmt, arg...) do { \
|
2009-12-13 18:53:12 +03:00
|
|
|
if (drm_debug & DRM_UT_DRIVER) \
|
|
|
|
NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \
|
|
|
|
} while (0)
|
|
|
|
#define NV_DEBUG_KMS(d, fmt, arg...) do { \
|
|
|
|
if (drm_debug & DRM_UT_KMS) \
|
2009-12-11 12:24:15 +03:00
|
|
|
NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
#define NV_ERROR(d, fmt, arg...) NV_PRINTK(KERN_ERR, d, fmt, ##arg)
|
|
|
|
#define NV_INFO(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg)
|
|
|
|
#define NV_TRACEWARN(d, fmt, arg...) NV_PRINTK(KERN_NOTICE, d, fmt, ##arg)
|
|
|
|
#define NV_TRACE(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg)
|
|
|
|
#define NV_WARN(d, fmt, arg...) NV_PRINTK(KERN_WARNING, d, fmt, ##arg)
|
2011-11-10 09:42:55 +04:00
|
|
|
#define NV_WARNONCE(d, fmt, arg...) do { \
|
|
|
|
static int _warned = 0; \
|
|
|
|
if (!_warned) { \
|
|
|
|
NV_WARN(d, fmt, ##arg); \
|
|
|
|
_warned = 1; \
|
|
|
|
} \
|
|
|
|
} while(0)
|
2009-12-11 12:24:15 +03:00
|
|
|
|
|
|
|
static inline bool
|
|
|
|
nv_two_heads(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
const int impl = dev->pci_device & 0x0ff0;
|
|
|
|
|
|
|
|
if (dev_priv->card_type >= NV_10 && impl != 0x0100 &&
|
|
|
|
impl != 0x0150 && impl != 0x01a0 && impl != 0x0200)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
nv_gf4_disp_arch(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return nv_two_heads(dev) && (dev->pci_device & 0x0ff0) != 0x0110;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
nv_two_reg_pll(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
const int impl = dev->pci_device & 0x0ff0;
|
|
|
|
|
|
|
|
if (impl == 0x0310 || impl == 0x0340 || dev_priv->card_type >= NV_40)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-15 16:31:31 +04:00
|
|
|
static inline bool
|
|
|
|
nv_match_device(struct drm_device *dev, unsigned device,
|
|
|
|
unsigned sub_vendor, unsigned sub_device)
|
|
|
|
{
|
|
|
|
return dev->pdev->device == device &&
|
|
|
|
dev->pdev->subsystem_vendor == sub_vendor &&
|
|
|
|
dev->pdev->subsystem_device == sub_device;
|
|
|
|
}
|
|
|
|
|
2012-07-26 03:12:47 +04:00
|
|
|
static inline struct nv04_display *
|
|
|
|
nv04_display(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_nouveau_private *dev_priv = dev->dev_private;
|
|
|
|
return dev_priv->engine.display.priv;
|
|
|
|
}
|
|
|
|
|
2009-12-11 12:24:15 +03:00
|
|
|
#endif /* __NOUVEAU_DRV_H__ */
|