Commit 77145f1c authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau: port remainder of drm code, and rip out compat layer

v2: Ben Skeggs <bskeggs@redhat.com>
- fill in nouveau_pm.dev to prevent oops
- fix ppc issues (build + OF shadow)
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 2094dd82
...@@ -145,47 +145,17 @@ nouveau-y += core/engine/software/nv50.o ...@@ -145,47 +145,17 @@ nouveau-y += core/engine/software/nv50.o
nouveau-y += core/engine/software/nvc0.o nouveau-y += core/engine/software/nvc0.o
nouveau-y += core/engine/vp/nv84.o nouveau-y += core/engine/vp/nv84.o
# drm/compat - will go away
nouveau-y += nouveau_compat.o nouveau_revcompat.o
# drm/core # drm/core
nouveau-y += nouveau_drm.o nouveau_chan.o nouveau_dma.o nouveau_fence.o nouveau-y += nouveau_drm.o nouveau_chan.o nouveau_dma.o nouveau_fence.o
nouveau-y += nouveau_agp.o nouveau-y += nouveau_irq.o nouveau_vga.o nouveau_agp.o
nouveau-y += nouveau_ttm.o nouveau_sgdma.o nouveau_bo.o nouveau_gem.o nouveau-y += nouveau_ttm.o nouveau_sgdma.o nouveau_bo.o nouveau_gem.o
nouveau-y += nouveau_prime.o nouveau_abi16.o
nouveau-y += nouveau_abi16.o
nouveau-y += nv04_fence.o nv10_fence.o nv50_fence.o nv84_fence.o nvc0_fence.o nouveau-y += nv04_fence.o nv10_fence.o nv50_fence.o nv84_fence.o nvc0_fence.o
# drm/kms/common # drm/kms
nouveau-y += nouveau_fbcon.o nouveau-y += nouveau_bios.o nouveau_fbcon.o nouveau_display.o
nouveau-y += nouveau_connector.o nouveau_hdmi.o nouveau_dp.o
# drm/kms/nv04:nv50 nouveau-y += nv04_fbcon.o nv50_fbcon.o nvc0_fbcon.o
nouveau-y += nv04_fbcon.o
# drm/kms/nv50:nvd9
nouveau-y += nv50_fbcon.o nvc0_fbcon.o
# drm/kms/nvd9-
# other random bits
nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
nouveau-$(CONFIG_ACPI) += nouveau_acpi.o
nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o
##
## unported bits below
##
# drm/core
nouveau-y += nouveau_drv.o nouveau_state.o nouveau_irq.o
nouveau-y += nouveau_prime.o
# drm/kms/bios
nouveau-y += nouveau_bios.o
# drm/kms/common
nouveau-y += nouveau_display.o nouveau_connector.o
nouveau-y += nouveau_hdmi.o nouveau_dp.o
# drm/kms/nv04:nv50 # drm/kms/nv04:nv50
nouveau-y += nouveau_hw.o nouveau_calc.o nouveau-y += nouveau_hw.o nouveau_calc.o
...@@ -202,4 +172,9 @@ nouveau-y += nouveau_pm.o nouveau_volt.o nouveau_perf.o nouveau_temp.o ...@@ -202,4 +172,9 @@ nouveau-y += nouveau_pm.o nouveau_volt.o nouveau_perf.o nouveau_temp.o
nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o
nouveau-y += nouveau_mem.o nouveau-y += nouveau_mem.o
# other random bits
nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
nouveau-$(CONFIG_ACPI) += nouveau_acpi.o
nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o
obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o
...@@ -20,8 +20,8 @@ void nouveau_timer_alarm(void *, u32 nsec, struct nouveau_alarm *); ...@@ -20,8 +20,8 @@ void nouveau_timer_alarm(void *, u32 nsec, struct nouveau_alarm *);
nouveau_timer_wait_eq((o), NV_WAIT_DEFAULT, (a), (m), (v)) nouveau_timer_wait_eq((o), NV_WAIT_DEFAULT, (a), (m), (v))
#define nv_wait_ne(o,a,m,v) \ #define nv_wait_ne(o,a,m,v) \
nouveau_timer_wait_ne((o), NV_WAIT_DEFAULT, (a), (m), (v)) nouveau_timer_wait_ne((o), NV_WAIT_DEFAULT, (a), (m), (v))
#define nv_wait_cb(o,a,m,v) \ #define nv_wait_cb(o,c,d) \
nouveau_timer_wait_cb((o), NV_WAIT_DEFAULT, (a), (m), (v)) nouveau_timer_wait_cb((o), NV_WAIT_DEFAULT, (c), (d))
struct nouveau_timer { struct nouveau_timer {
struct nouveau_subdev base; struct nouveau_subdev base;
......
...@@ -56,6 +56,31 @@ nvbios_findstr(const u8 *data, int size, const char *str, int len) ...@@ -56,6 +56,31 @@ nvbios_findstr(const u8 *data, int size, const char *str, int len)
return 0; return 0;
} }
#if defined(__powerpc__)
static void
nouveau_bios_shadow_of(struct nouveau_bios *bios)
{
struct pci_dev *pdev = nv_device(bios)->pdev;
struct device_node *dn;
const u32 *data;
int size, i;
dn = pci_device_to_OF_node(pdev);
if (!dn) {
nv_info(bios, "Unable to get the OF node\n");
return;
}
data = of_get_property(dn, "NVDA,BMP", &size);
if (data) {
bios->size = size;
bios->data = kmalloc(bios->size, GFP_KERNEL);
if (bios->data)
memcpy(bios->data, data, size);
}
}
#endif
static void static void
nouveau_bios_shadow_pramin(struct nouveau_bios *bios) nouveau_bios_shadow_pramin(struct nouveau_bios *bios)
{ {
...@@ -221,7 +246,7 @@ nouveau_bios_score(struct nouveau_bios *bios, const bool writeable) ...@@ -221,7 +246,7 @@ nouveau_bios_score(struct nouveau_bios *bios, const bool writeable)
} }
struct methods { struct methods {
const char desc[8]; const char desc[16];
void (*shadow)(struct nouveau_bios *); void (*shadow)(struct nouveau_bios *);
const bool rw; const bool rw;
int score; int score;
...@@ -233,6 +258,9 @@ static int ...@@ -233,6 +258,9 @@ static int
nouveau_bios_shadow(struct nouveau_bios *bios) nouveau_bios_shadow(struct nouveau_bios *bios)
{ {
struct methods shadow_methods[] = { struct methods shadow_methods[] = {
#if defined(__powerpc__)
{ "OpenFirmware", nouveau_bios_shadow_of, true, 0, 0, NULL },
#endif
{ "PRAMIN", nouveau_bios_shadow_pramin, true, 0, 0, NULL }, { "PRAMIN", nouveau_bios_shadow_pramin, true, 0, 0, NULL },
{ "PROM", nouveau_bios_shadow_prom, false, 0, 0, NULL }, { "PROM", nouveau_bios_shadow_prom, false, 0, 0, NULL },
{ "ACPI", nouveau_bios_shadow_acpi, true, 0, 0, NULL }, { "ACPI", nouveau_bios_shadow_acpi, true, 0, 0, NULL },
......
...@@ -71,7 +71,7 @@ static const struct backlight_ops nv40_bl_ops = { ...@@ -71,7 +71,7 @@ static const struct backlight_ops nv40_bl_ops = {
static int static int
nv40_backlight_init(struct drm_connector *connector) nv40_backlight_init(struct drm_connector *connector)
{ {
struct nouveau_drm *drm = nouveau_newpriv(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
struct backlight_properties props; struct backlight_properties props;
struct backlight_device *bd; struct backlight_device *bd;
...@@ -95,7 +95,7 @@ static int ...@@ -95,7 +95,7 @@ static int
nv50_get_intensity(struct backlight_device *bd) nv50_get_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div = 1025; u32 div = 1025;
...@@ -110,7 +110,7 @@ static int ...@@ -110,7 +110,7 @@ static int
nv50_set_intensity(struct backlight_device *bd) nv50_set_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div = 1025; u32 div = 1025;
...@@ -131,7 +131,7 @@ static int ...@@ -131,7 +131,7 @@ static int
nva3_get_intensity(struct backlight_device *bd) nva3_get_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div, val; u32 div, val;
...@@ -149,7 +149,7 @@ static int ...@@ -149,7 +149,7 @@ static int
nva3_set_intensity(struct backlight_device *bd) nva3_set_intensity(struct backlight_device *bd)
{ {
struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_encoder *nv_encoder = bl_get_data(bd);
struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or; int or = nv_encoder->or;
u32 div, val; u32 div, val;
...@@ -175,7 +175,7 @@ static const struct backlight_ops nva3_bl_ops = { ...@@ -175,7 +175,7 @@ static const struct backlight_ops nva3_bl_ops = {
static int static int
nv50_backlight_init(struct drm_connector *connector) nv50_backlight_init(struct drm_connector *connector)
{ {
struct nouveau_drm *drm = nouveau_newpriv(connector->dev); struct nouveau_drm *drm = nouveau_drm(connector->dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
struct nouveau_encoder *nv_encoder; struct nouveau_encoder *nv_encoder;
struct backlight_properties props; struct backlight_properties props;
...@@ -216,7 +216,7 @@ nv50_backlight_init(struct drm_connector *connector) ...@@ -216,7 +216,7 @@ nv50_backlight_init(struct drm_connector *connector)
int int
nouveau_backlight_init(struct drm_device *dev) nouveau_backlight_init(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
struct drm_connector *connector; struct drm_connector *connector;
...@@ -250,7 +250,7 @@ nouveau_backlight_init(struct drm_device *dev) ...@@ -250,7 +250,7 @@ nouveau_backlight_init(struct drm_device *dev)
void void
nouveau_backlight_exit(struct drm_device *dev) nouveau_backlight_exit(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
if (drm->backlight) { if (drm->backlight) {
backlight_device_unregister(drm->backlight); backlight_device_unregister(drm->backlight);
......
This diff is collapsed.
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifndef __NOUVEAU_BIOS_H__ #ifndef __NOUVEAU_DISPBIOS_H__
#define __NOUVEAU_BIOS_H__ #define __NOUVEAU_DISPBIOS_H__
#include "nvreg.h" #include "nvreg.h"
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
#define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); }) #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); })
#define ROM64(x) le64_to_cpu(*(u64 *)&(x)) #define ROM64(x) le64_to_cpu(*(u64 *)&(x))
#define ROMPTR(d,x) ({ \ #define ROMPTR(d,x) ({ \
struct drm_nouveau_private *dev_priv = (d)->dev_private; \ struct nouveau_drm *drm = nouveau_drm((d)); \
ROM16(x) ? &dev_priv->vbios.data[ROM16(x)] : NULL; \ ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \
}) })
struct bit_entry { struct bit_entry {
...@@ -180,4 +180,21 @@ int olddcb_outp_foreach(struct drm_device *, void *data, ...@@ -180,4 +180,21 @@ int olddcb_outp_foreach(struct drm_device *, void *data,
u8 *olddcb_conntab(struct drm_device *); u8 *olddcb_conntab(struct drm_device *);
u8 *olddcb_conn(struct drm_device *, u8 idx); u8 *olddcb_conn(struct drm_device *, u8 idx);
int nouveau_bios_init(struct drm_device *);
void nouveau_bios_takedown(struct drm_device *dev);
int nouveau_run_vbios_init(struct drm_device *);
struct dcb_connector_table_entry *
nouveau_bios_connector_entry(struct drm_device *, int index);
int nouveau_bios_run_display_table(struct drm_device *, u16 id, int clk,
struct dcb_output *, int crtc);
bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *);
uint8_t *nouveau_bios_embedded_edid(struct drm_device *);
int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk,
bool *dl, bool *if_is_24bit);
int run_tmds_table(struct drm_device *, struct dcb_output *,
int head, int pxclk);
int call_lvds_script(struct drm_device *, struct dcb_output *, int head,
enum LVDS_script, int pxclk);
bool bios_encoder_match(struct dcb_output *, u32 hash);
#endif #endif
...@@ -49,7 +49,7 @@ static void ...@@ -49,7 +49,7 @@ static void
nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg, nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg,
u32 addr, u32 size, u32 pitch, u32 flags) u32 addr, u32 size, u32 pitch, u32 flags)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
int i = reg - drm->tile.reg; int i = reg - drm->tile.reg;
struct nouveau_fb *pfb = nouveau_fb(drm->device); struct nouveau_fb *pfb = nouveau_fb(drm->device);
struct nouveau_fb_tile *tile = &pfb->tile.region[i]; struct nouveau_fb_tile *tile = &pfb->tile.region[i];
...@@ -74,7 +74,7 @@ nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg, ...@@ -74,7 +74,7 @@ nv10_bo_update_tile_region(struct drm_device *dev, struct nouveau_drm_tile *reg,
static struct nouveau_drm_tile * static struct nouveau_drm_tile *
nv10_bo_get_tile_region(struct drm_device *dev, int i) nv10_bo_get_tile_region(struct drm_device *dev, int i)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_drm_tile *tile = &drm->tile.reg[i]; struct nouveau_drm_tile *tile = &drm->tile.reg[i];
spin_lock(&drm->tile.lock); spin_lock(&drm->tile.lock);
...@@ -93,7 +93,7 @@ static void ...@@ -93,7 +93,7 @@ static void
nv10_bo_put_tile_region(struct drm_device *dev, struct nouveau_drm_tile *tile, nv10_bo_put_tile_region(struct drm_device *dev, struct nouveau_drm_tile *tile,
struct nouveau_fence *fence) struct nouveau_fence *fence)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
if (tile) { if (tile) {
spin_lock(&drm->tile.lock); spin_lock(&drm->tile.lock);
...@@ -112,7 +112,7 @@ static struct nouveau_drm_tile * ...@@ -112,7 +112,7 @@ static struct nouveau_drm_tile *
nv10_bo_set_tiling(struct drm_device *dev, u32 addr, nv10_bo_set_tiling(struct drm_device *dev, u32 addr,
u32 size, u32 pitch, u32 flags) u32 size, u32 pitch, u32 flags)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_fb *pfb = nouveau_fb(drm->device); struct nouveau_fb *pfb = nouveau_fb(drm->device);
struct nouveau_drm_tile *tile, *found = NULL; struct nouveau_drm_tile *tile, *found = NULL;
int i; int i;
...@@ -191,7 +191,7 @@ nouveau_bo_new(struct drm_device *dev, int size, int align, ...@@ -191,7 +191,7 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
struct sg_table *sg, struct sg_table *sg,
struct nouveau_bo **pnvbo) struct nouveau_bo **pnvbo)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
size_t acc_size; size_t acc_size;
int ret; int ret;
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
*/ */
#include "drmP.h" #include "drmP.h"
#include "nouveau_drv.h" #include "nouveau_drm.h"
#include "nouveau_reg.h"
#include "nouveau_hw.h" #include "nouveau_hw.h"
/****************************************************************************\ /****************************************************************************\
...@@ -195,12 +196,13 @@ static void ...@@ -195,12 +196,13 @@ static void
nv04_update_arb(struct drm_device *dev, int VClk, int bpp, nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
int *burst, int *lwm) int *burst, int *lwm)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_device *device = nouveau_dev(dev);
struct nv_fifo_info fifo_data; struct nv_fifo_info fifo_data;
struct nv_sim_state sim_data; struct nv_sim_state sim_data;
int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY); int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY);
int NVClk = nouveau_hw_get_clock(dev, PLL_CORE); int NVClk = nouveau_hw_get_clock(dev, PLL_CORE);
uint32_t cfg1 = nv_rd32(dev, NV04_PFB_CFG1); uint32_t cfg1 = nv_rd32(device, NV04_PFB_CFG1);
sim_data.pclk_khz = VClk; sim_data.pclk_khz = VClk;
sim_data.mclk_khz = MClk; sim_data.mclk_khz = MClk;
...@@ -218,13 +220,13 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp, ...@@ -218,13 +220,13 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
sim_data.mem_latency = 3; sim_data.mem_latency = 3;
sim_data.mem_page_miss = 10; sim_data.mem_page_miss = 10;
} else { } else {
sim_data.memory_type = nv_rd32(dev, NV04_PFB_CFG0) & 0x1; sim_data.memory_type = nv_rd32(device, NV04_PFB_CFG0) & 0x1;
sim_data.memory_width = (nv_rd32(dev, NV_PEXTDEV_BOOT_0) & 0x10) ? 128 : 64; sim_data.memory_width = (nv_rd32(device, NV_PEXTDEV_BOOT_0) & 0x10) ? 128 : 64;
sim_data.mem_latency = cfg1 & 0xf; sim_data.mem_latency = cfg1 & 0xf;
sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1); sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1);
} }
if (dev_priv->card_type == NV_04) if (nv_device(drm->device)->card_type == NV_04)
nv04_calc_arb(&fifo_data, &sim_data); nv04_calc_arb(&fifo_data, &sim_data);
else else
nv10_calc_arb(&fifo_data, &sim_data); nv10_calc_arb(&fifo_data, &sim_data);
...@@ -249,9 +251,9 @@ nv20_update_arb(int *burst, int *lwm) ...@@ -249,9 +251,9 @@ nv20_update_arb(int *burst, int *lwm)
void void
nouveau_calc_arb(struct drm_device *dev, int vclk, int bpp, int *burst, int *lwm) nouveau_calc_arb(struct drm_device *dev, int vclk, int bpp, int *burst, int *lwm)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_drm *drm = nouveau_drm(dev);
if (dev_priv->card_type < NV_20) if (nv_device(drm->device)->card_type < NV_20)
nv04_update_arb(dev, vclk, bpp, burst, lwm); nv04_update_arb(dev, vclk, bpp, burst, lwm);
else if ((dev->pci_device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ || else if ((dev->pci_device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ ||
(dev->pci_device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) { (dev->pci_device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) {
......
This diff is collapsed.
#ifndef __NOUVEAU_COMPAT_H__
#define __NOUVEAU_COMPAT_H__
int nvdrm_gart_init(struct drm_device *, u64 *, u64 *);
u8 _nv_rd08(struct drm_device *, u32);
void _nv_wr08(struct drm_device *, u32, u8);
u32 _nv_rd32(struct drm_device *, u32);
void _nv_wr32(struct drm_device *, u32, u32);
u32 _nv_mask(struct drm_device *, u32, u32, u32);
bool _nv_bios(struct drm_device *, u8 **, u32 *);
struct dcb_gpio_func;
void nouveau_gpio_reset(struct drm_device *);
int nouveau_gpio_find(struct drm_device *, int, u8, u8, struct dcb_gpio_func *);
bool nouveau_gpio_func_valid(struct drm_device *, u8 tag);
int nouveau_gpio_func_set(struct drm_device *, u8 tag, int state);
int nouveau_gpio_func_get(struct drm_device *, u8 tag);
int nouveau_gpio_irq(struct drm_device *, int idx, u8 tag, u8 line, bool on);
int nouveau_gpio_isr_add(struct drm_device *, int idx, u8 tag, u8 line,
void (*)(void *, int state), void *data);
void nouveau_gpio_isr_del(struct drm_device *, int idx, u8 tag, u8 line,
void (*)(void *, int state), void *data);
struct nouveau_i2c_port *nouveau_i2c_find(struct drm_device *, u8);
bool nouveau_probe_i2c_addr(struct nouveau_i2c_port *, int addr);
struct i2c_adapter *nouveau_i2c_adapter(struct nouveau_i2c_port *);
int nouveau_i2c_identify(struct drm_device *dev, const char *what,
struct i2c_board_info *info,
bool (*match)(struct nouveau_i2c_port *,
struct i2c_board_info *), int index);
int auxch_rd(struct drm_device *, struct nouveau_i2c_port *, u32, u8 *, u8);
int auxch_wr(struct drm_device *, struct nouveau_i2c_port *, u32, u8 *, u8);
struct nvbios_pll;
struct nouveau_pll_vals;
u32 get_pll_register(struct drm_device *dev, u32 type);
int get_pll_limits(struct drm_device *, u32, struct nvbios_pll *);
int setPLL(struct drm_device *, u32 reg, u32 clk);
int nouveau_calc_pll_mnp(struct drm_device *, struct nvbios_pll *,
int, struct nouveau_pll_vals *);
int nva3_calc_pll(struct drm_device *dev, struct nvbios_pll *info, u32 freq,
int *N, int *fN, int *M, int *P);
int nouveau_hw_setpll(struct drm_device *, u32, struct nouveau_pll_vals *);
struct dcb_output;
void nouveau_bios_run_init_table(struct drm_device *, u16, struct dcb_output *, int);
void nouveau_bios_init_exec(struct drm_device *, u16);
void nv_intr(struct drm_device *);
bool nouveau_wait_eq(struct drm_device *, uint64_t timeout,
uint32_t reg, uint32_t mask, uint32_t val);
bool nouveau_wait_ne(struct drm_device *, uint64_t timeout,
uint32_t reg, uint32_t mask, uint32_t val);
bool nouveau_wait_cb(struct drm_device *, u64 timeout,
bool (*cond)(void *), void *);
u64 nv_timer_read(struct drm_device *);
int nvfb_tile_nr(struct drm_device *);
void nvfb_tile_init(struct drm_device *, int, u32, u32, u32, u32);
void nvfb_tile_fini(struct drm_device *, int);
void nvfb_tile_prog(struct drm_device *, int);
struct nouveau_fb_tile *nvfb_tile(struct drm_device *, int);
struct nouveau_mem;
int nvfb_vram_get(struct drm_device *dev, u64 size, u32 align, u32 ncmin,
u32 memtype, struct nouveau_mem **pmem);
void nvfb_vram_put(struct drm_device *dev, struct nouveau_mem **pmem);
bool nvfb_flags_valid(struct drm_device *dev, u32);
u64 nvfb_vram_sys_base(struct drm_device *);
u64 nvfb_vram_size(struct drm_device *);
int nvfb_vram_type(struct drm_device *);
int nvfb_vram_rank_B(struct drm_device *);
void nv50_fb_vm_trap(struct drm_device *, int);
struct nouveau_gpuobj *nvimem_ramro(struct drm_device *);
struct nouveau_gpuobj *nvimem_ramfc(struct drm_device *);
int _nouveau_gpuobj_new(struct drm_device *dev, struct nouveau_gpuobj *par,
int size, int align, u32 flags,
struct nouveau_gpuobj **pboj);
u32 nv_ri32(struct drm_device *, u32);
void nv_wi32(struct drm_device *, u32, u32);
u32 nvimem_reserved(struct drm_device *);
void nvimem_flush(struct drm_device *);
void _nv50_vm_flush_engine(struct drm_device *dev, int engine);
int _nouveau_vm_new(struct drm_device *, u64 offset, u64 length,
u64 mm_offset, struct nouveau_vm **);
struct nouveau_vma;
int nouveau_gpuobj_map_bar(struct nouveau_gpuobj *, u32, struct nouveau_vma *);
int
nvbar_map(struct drm_device *dev, struct nouveau_mem *mem, u32 flags,
struct nouveau_vma *vma);
void
nvbar_unmap(struct drm_device *dev, struct nouveau_vma *vma);
struct nouveau_vm *
nv04vm_ref(struct drm_device *dev);
struct nouveau_gpuobj *
nv04vm_refdma(struct drm_device *dev);
void
nvvm_engref(struct nouveau_vm *, int, int);
int
nvvm_spg_shift(struct nouveau_vm *);
int
nvvm_lpg_shift(struct nouveau_vm *);
u32
nv50_display_active_crtcs(struct drm_device *dev);
u64 nvgpuobj_addr(struct nouveau_object *object);
struct drm_device *
nouveau_drv(void *drm);
struct nouveau_channel *
nvdrm_channel(struct drm_device *dev);
struct mutex *
nvchan_mutex(struct nouveau_channel *chan);
#endif
This diff is collapsed.
This diff is collapsed.
#ifndef __NOUVEAU_DISPLAY_H__
#define __NOUVEAU_DISPLAY_H__
#include <subdev/vm.h>
#include "nouveau_drm.h"
struct nouveau_framebuffer {
struct drm_framebuffer base;
struct nouveau_bo *nvbo;
struct nouveau_vma vma;
u32 r_dma;
u32 r_format;
u32 r_pitch;
};
static inline struct nouveau_framebuffer *
nouveau_framebuffer(struct drm_framebuffer *fb)
{
return container_of(fb, struct nouveau_framebuffer, base);
}
int nouveau_framebuffer_init(struct drm_device *, struct nouveau_framebuffer *,
struct drm_mode_fb_cmd2 *, struct nouveau_bo *);
struct nouveau_page_flip_state {
struct list_head head;
struct drm_pending_vblank_event *event;
int crtc, bpp, pitch, x, y;
u64 offset;
};
struct nouveau_display {
void *priv;
void (*dtor)(struct drm_device *);
int (*init)(struct drm_device *);
void (*fini)(struct drm_device *);
struct drm_property *dithering_mode;
struct drm_property *dithering_depth;
struct drm_property *underscan_property;
struct drm_property *underscan_hborder_property;
struct drm_property *underscan_vborder_property;
/* not really hue and saturation: */
struct drm_property *vibrant_hue_property;
struct drm_property *color_vibrance_property;
};
static inline struct nouveau_display *
nouveau_display(struct drm_device *dev)
{
return nouveau_drm(dev)->display;
}
int nouveau_display_create(struct drm_device *dev);
void nouveau_display_destroy(struct drm_device *dev);
int nouveau_display_init(struct drm_device *dev);
void nouveau_display_fini(struct drm_device *dev);
int nouveau_display_suspend(struct drm_device *dev);
void nouveau_display_resume(struct drm_device *dev);
int nouveau_vblank_enable(struct drm_device *dev, int crtc);
void nouveau_vblank_disable(struct drm_device *dev, int crtc);
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 *);
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 *,
u32 handle, u64 *offset);
int nouveau_display_dumb_destroy(struct drm_file *, struct drm_device *,
u32 handle);
void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
extern int nouveau_backlight_init(struct drm_device *);
extern void nouveau_backlight_exit(struct drm_device *);
#else
static inline int
nouveau_backlight_init(struct drm_device *dev)
{
return 0;
}
static inline void
nouveau_backlight_exit(struct drm_device *dev) {
}
#endif
#endif
...@@ -25,31 +25,35 @@ ...@@ -25,31 +25,35 @@
#include "drmP.h" #include "drmP.h"
#include "drm_dp_helper.h" #include "drm_dp_helper.h"
#include "nouveau_drv.h" #include "nouveau_drm.h"
#include "nouveau_connector.h" #include "nouveau_connector.h"
#include "nouveau_encoder.h" #include "nouveau_encoder.h"
#include "nouveau_crtc.h" #include "nouveau_crtc.h"
#include <subdev/gpio.h>
#include <subdev/i2c.h>
u8 * u8 *
nouveau_dp_bios_data(struct drm_device *dev, struct dcb_output *dcb, u8 **entry) nouveau_dp_bios_data(struct drm_device *dev, struct dcb_output *dcb, u8 **entry)
{ {
struct nouveau_drm *drm = nouveau_drm(dev);
struct bit_entry d; struct bit_entry d;
u8 *table; u8 *table;
int i; int i;
if (bit_table(dev, 'd', &d)) { if (bit_table(dev, 'd', &d)) {
NV_ERROR(dev, "BIT 'd' table not found\n"); NV_ERROR(drm, "BIT 'd' table not found\n");
return NULL; return NULL;
} }
if (d.version != 1) { if (d.version != 1) {
NV_ERROR(dev, "BIT 'd' table version %d unknown\n", d.version); NV_ERROR(drm, "BIT 'd' table version %d unknown\n", d.version);
return NULL; return NULL;
} }
table = ROMPTR(dev, d.data[0]); table = ROMPTR(dev, d.data[0]);
if (!table) { if (!table) {
NV_ERROR(dev, "displayport table pointer invalid\n"); NV_ERROR(drm, "displayport table pointer invalid\n");
return NULL; return NULL;
} }
...@@ -60,7 +64,7 @@ nouveau_dp_bios_data(struct drm_device *dev, struct dcb_output *dcb, u8 **entry) ...@@ -60,7 +64,7 @@ nouveau_dp_bios_data(struct drm_device *dev, struct dcb_output *dcb, u8 **entry)
case 0x40: case 0x40:
break; break;
default: default:
NV_ERROR(dev, "displayport table 0x%02x unknown\n", table[0]); NV_ERROR(drm, "displayport table 0x%02x unknown\n", table[0]);
return NULL; return NULL;
} }
...@@ -70,7 +74,7 @@ nouveau_dp_bios_data(struct drm_device *dev, struct dcb_output *dcb, u8 **entry) ...@@ -70,7 +74,7 @@ nouveau_dp_bios_data(struct drm_device *dev, struct dcb_output *dcb, u8 **entry)
return table; return table;
} }
NV_ERROR(dev, "displayport encoder table not found\n"); NV_ERROR(drm, "displayport encoder table not found\n");
return NULL; return NULL;
} }
...@@ -92,9 +96,10 @@ struct dp_state { ...@@ -92,9 +96,10 @@ struct dp_state {
static void static void
dp_set_link_config(struct drm_device *dev, struct dp_state *dp) dp_set_link_config(struct drm_device *dev, struct dp_state *dp)
{ {
struct nouveau_drm *drm = nouveau_drm(dev);
u8 sink[2]; u8 sink[2];
NV_DEBUG_KMS(dev, "%d lanes at %d KB/s\n", dp->link_nr, dp->link_bw); NV_DEBUG(drm, "%d lanes at %d KB/s\n", dp->link_nr, dp->link_bw);
/* set desired link configuration on the source */ /* set desired link configuration on the source */
dp->func->link_set(dev, dp->dcb, dp->crtc, dp->link_nr, dp->link_bw, dp->func->link_set(dev, dp->dcb, dp->crtc, dp->link_nr, dp->link_bw,
...@@ -106,27 +111,29 @@ dp_set_link_config(struct drm_device *dev, struct dp_state *dp) ...@@ -106,27 +111,29 @@ dp_set_link_config(struct drm_device *dev, struct dp_state *dp)
if (dp->dpcd[2] & DP_ENHANCED_FRAME_CAP) if (dp->dpcd[2] & DP_ENHANCED_FRAME_CAP)
sink[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN; sink[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
auxch_wr(dev, dp->auxch, DP_LINK_BW_SET, sink, 2); nv_wraux(dp->auxch, DP_LINK_BW_SET, sink, 2);
} }
static void static void
dp_set_training_pattern(struct drm_device *dev, struct dp_state *dp, u8 pattern) dp_set_training_pattern(struct drm_device *dev, struct dp_state *dp, u8 pattern)
{ {
struct nouveau_drm *drm = nouveau_drm(dev);
u8 sink_tp; u8 sink_tp;
NV_DEBUG_KMS(dev, "training pattern %d\n", pattern); NV_DEBUG(drm, "training pattern %d\n", pattern);
dp->func->train_set(dev, dp->dcb, pattern); dp->func->train_set(dev, dp->dcb, pattern);
auxch_rd(dev, dp->auxch, DP_TRAINING_PATTERN_SET, &sink_tp, 1); nv_rdaux(dp->auxch, DP_TRAINING_PATTERN_SET, &sink_tp, 1);
sink_tp &= ~DP_TRAINING_PATTERN_MASK; sink_tp &= ~DP_TRAINING_PATTERN_MASK;
sink_tp |= pattern; sink_tp |= pattern;
auxch_wr(dev, dp->auxch, DP_TRAINING_PATTERN_SET, &sink_tp, 1); nv_wraux(dp->auxch, DP_TRAINING_PATTERN_SET, &sink_tp, 1);
} }
static int static int
dp_link_train_commit(struct drm_device *dev, struct dp_state *dp) dp_link_train_commit(struct drm_device *dev, struct dp_state *dp)
{ {
struct nouveau_drm *drm = nouveau_drm(dev);
int i; int i;
for (i = 0; i < dp->link_nr; i++) { for (i = 0; i < dp->link_nr; i++) {
...@@ -140,25 +147,26 @@ dp_link_train_commit(struct drm_device *dev, struct dp_state *dp) ...@@ -140,25 +147,26 @@ dp_link_train_commit(struct drm_device *dev, struct dp_state *dp)
if ((lpre << 3) == DP_TRAIN_PRE_EMPHASIS_9_5) if ((lpre << 3) == DP_TRAIN_PRE_EMPHASIS_9_5)
dp->conf[i] |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED; dp->conf[i] |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
NV_DEBUG_KMS(dev, "config lane %d %02x\n", i, dp->conf[i]); NV_DEBUG(drm, "config lane %d %02x\n", i, dp->conf[i]);
dp->func->train_adj(dev, dp->dcb, i, lvsw, lpre); dp->func->train_adj(dev, dp->dcb, i, lvsw, lpre);
} }
return auxch_wr(dev, dp->auxch, DP_TRAINING_LANE0_SET, dp->conf, 4); return nv_wraux(dp->auxch, DP_TRAINING_LANE0_SET, dp->conf, 4);
} }
static int static int
dp_link_train_update(struct drm_device *dev, struct dp_state *dp, u32 delay) dp_link_train_update(struct drm_device *dev, struct dp_state *dp, u32 delay)
{ {
struct nouveau_drm *drm = nouveau_drm(dev);
int ret; int ret;
udelay(delay); udelay(delay);
ret = auxch_rd(dev, dp->auxch, DP_LANE0_1_STATUS, dp->stat, 6); ret = nv_rdaux(dp->auxch, DP_LANE0_1_STATUS, dp->stat, 6);
if (ret) if (ret)
return ret; return ret;
NV_DEBUG_KMS(dev, "status %02x %02x %02x %02x %02x %02x\n", NV_DEBUG(drm, "status %02x %02x %02x %02x %02x %02x\n",
dp->stat[0], dp->stat[1], dp->stat[2], dp->stat[3], dp->stat[0], dp->stat[1], dp->stat[2], dp->stat[3],
dp->stat[4], dp->stat[5]); dp->stat[4], dp->stat[5]);
return 0; return 0;
...@@ -287,11 +295,14 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate, ...@@ -287,11 +295,14 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate,
struct nouveau_connector *nv_connector = struct nouveau_connector *nv_connector =
nouveau_encoder_connector_get(nv_encoder); nouveau_encoder_connector_get(nv_encoder);
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_i2c *i2c = nouveau_i2c(drm->device);
struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
const u32 bw_list[] = { 270000, 162000, 0 }; const u32 bw_list[] = { 270000, 162000, 0 };
const u32 *link_bw = bw_list; const u32 *link_bw = bw_list;
struct dp_state dp; struct dp_state dp;
dp.auxch = nouveau_i2c_find(dev, nv_encoder->dcb->i2c_index); dp.auxch = i2c->find(i2c, nv_encoder->dcb->i2c_index);
if (!dp.auxch) if (!dp.auxch)
return false; return false;
...@@ -307,7 +318,7 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate, ...@@ -307,7 +318,7 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate,
* we take during link training (DP_SET_POWER is one), we need * we take during link training (DP_SET_POWER is one), we need
* to ignore them for the moment to avoid races. * to ignore them for the moment to avoid races.
*/ */
nouveau_gpio_irq(dev, 0, nv_connector->hpd, 0xff, false); gpio->irq(gpio, 0, nv_connector->hpd, 0xff, false);
/* enable down-spreading, if possible */ /* enable down-spreading, if possible */
dp_set_downspread(dev, &dp, nv_encoder->dp.dpcd[3] & 1); dp_set_downspread(dev, &dp, nv_encoder->dp.dpcd[3] & 1);
...@@ -350,7 +361,7 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate, ...@@ -350,7 +361,7 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate,
dp_link_train_fini(dev, &dp); dp_link_train_fini(dev, &dp);
/* re-enable hotplug detect */ /* re-enable hotplug detect */
nouveau_gpio_irq(dev, 0, nv_connector->hpd, 0xff, true); gpio->irq(gpio, 0, nv_connector->hpd, 0xff, true);
return true; return true;
} }
...@@ -359,10 +370,12 @@ nouveau_dp_dpms(struct drm_encoder *encoder, int mode, u32 datarate, ...@@ -359,10 +370,12 @@ nouveau_dp_dpms(struct drm_encoder *encoder, int mode, u32 datarate,
struct dp_train_func *func) struct dp_train_func *func)
{ {
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
struct nouveau_drm *drm = nouveau_drm(encoder->dev);
struct nouveau_i2c *i2c = nouveau_i2c(drm->device);
struct nouveau_i2c_port *auxch; struct nouveau_i2c_port *auxch;
u8 status; u8 status;
auxch = nouveau_i2c_find(encoder->dev, nv_encoder->dcb->i2c_index); auxch = i2c->find(i2c, nv_encoder->dcb->i2c_index);
if (!auxch) if (!auxch)
return; return;
...@@ -371,7 +384,7 @@ nouveau_dp_dpms(struct drm_encoder *encoder, int mode, u32 datarate, ...@@ -371,7 +384,7 @@ nouveau_dp_dpms(struct drm_encoder *encoder, int mode, u32 datarate,
else else
status = DP_SET_POWER_D3; status = DP_SET_POWER_D3;
auxch_wr(encoder->dev, auxch, DP_SET_POWER, &status, 1); nv_wraux(auxch, DP_SET_POWER, &status, 1);
if (mode == DRM_MODE_DPMS_ON) if (mode == DRM_MODE_DPMS_ON)
nouveau_dp_link_train(encoder, datarate, func); nouveau_dp_link_train(encoder, datarate, func);
...@@ -381,17 +394,18 @@ static void ...@@ -381,17 +394,18 @@ static void
nouveau_dp_probe_oui(struct drm_device *dev, struct nouveau_i2c_port *auxch, nouveau_dp_probe_oui(struct drm_device *dev, struct nouveau_i2c_port *auxch,
u8 *dpcd) u8 *dpcd)
{ {
struct nouveau_drm *drm = nouveau_drm(dev);
u8 buf[3]; u8 buf[3];
if (!(dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT)) if (!(dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT))
return; return;
if (!auxch_rd(dev, auxch, DP_SINK_OUI, buf, 3)) if (!nv_rdaux(auxch, DP_SINK_OUI, buf, 3))
NV_DEBUG_KMS(dev, "Sink OUI: %02hx%02hx%02hx\n", NV_DEBUG(drm, "Sink OUI: %02hx%02hx%02hx\n",
buf[0], buf[1], buf[2]); buf[0], buf[1], buf[2]);
if (!auxch_rd(dev, auxch, DP_BRANCH_OUI, buf, 3)) if (!nv_rdaux(auxch, DP_BRANCH_OUI, buf, 3))
NV_DEBUG_KMS(dev, "Branch OUI: %02hx%02hx%02hx\n", NV_DEBUG(drm, "Branch OUI: %02hx%02hx%02hx\n",
buf[0], buf[1], buf[2]); buf[0], buf[1], buf[2]);
} }
...@@ -401,24 +415,26 @@ nouveau_dp_detect(struct drm_encoder *encoder) ...@@ -401,24 +415,26 @@ nouveau_dp_detect(struct drm_encoder *encoder)
{ {
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_i2c *i2c = nouveau_i2c(drm->device);
struct nouveau_i2c_port *auxch; struct nouveau_i2c_port *auxch;
u8 *dpcd = nv_encoder->dp.dpcd; u8 *dpcd = nv_encoder->dp.dpcd;
int ret; int ret;
auxch = nouveau_i2c_find(dev, nv_encoder->dcb->i2c_index); auxch = i2c->find(i2c, nv_encoder->dcb->i2c_index);
if (!auxch) if (!auxch)
return false; return false;
ret = auxch_rd(dev, auxch, DP_DPCD_REV, dpcd, 8); ret = nv_rdaux(auxch, DP_DPCD_REV, dpcd, 8);
if (ret) if (ret)
return false; return false;
nv_encoder->dp.link_bw = 27000 * dpcd[1]; nv_encoder->dp.link_bw = 27000 * dpcd[1];
nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK; nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
NV_DEBUG_KMS(dev, "display: %dx%d dpcd 0x%02x\n", NV_DEBUG(drm, "display: %dx%d dpcd 0x%02x\n",
nv_encoder->dp.link_nr, nv_encoder->dp.link_bw, dpcd[0]); nv_encoder->dp.link_nr, nv_encoder->dp.link_bw, dpcd[0]);
NV_DEBUG_KMS(dev, "encoder: %dx%d\n", NV_DEBUG(drm, "encoder: %dx%d\n",
nv_encoder->dcb->dpconf.link_nr, nv_encoder->dcb->dpconf.link_nr,
nv_encoder->dcb->dpconf.link_bw); nv_encoder->dcb->dpconf.link_bw);
...@@ -427,7 +443,7 @@ nouveau_dp_detect(struct drm_encoder *encoder) ...@@ -427,7 +443,7 @@ nouveau_dp_detect(struct drm_encoder *encoder)
if (nv_encoder->dcb->dpconf.link_bw < nv_encoder->dp.link_bw) if (nv_encoder->dcb->dpconf.link_bw < nv_encoder->dp.link_bw)
nv_encoder->dp.link_bw = nv_encoder->dcb->dpconf.link_bw; nv_encoder->dp.link_bw = nv_encoder->dcb->dpconf.link_bw;
NV_DEBUG_KMS(dev, "maximum: %dx%d\n", NV_DEBUG(drm, "maximum: %dx%d\n",
nv_encoder->dp.link_nr, nv_encoder->dp.link_bw); nv_encoder->dp.link_nr, nv_encoder->dp.link_bw);
nouveau_dp_probe_oui(dev, auxch, dpcd); nouveau_dp_probe_oui(dev, auxch, dpcd);
......
This diff is collapsed.
#ifndef __NOUVEAU_DRMCLI_H__ #ifndef __NOUVEAU_DRMCLI_H__
#define __NOUVEAU_DRMCLI_H__ #define __NOUVEAU_DRMCLI_H__
#define DRIVER_AUTHOR "Nouveau Project"
#define DRIVER_EMAIL "nouveau@lists.freedesktop.org"
#define DRIVER_NAME "nouveau"
#define DRIVER_DESC "nVidia Riva/TNT/GeForce/Quadro/Tesla"
#define DRIVER_DATE "20120801"
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 1
#define DRIVER_PATCHLEVEL 0
#include <core/client.h> #include <core/client.h>
#include <subdev/vm.h> #include <subdev/vm.h>
...@@ -19,8 +30,8 @@ struct nouveau_channel; ...@@ -19,8 +30,8 @@ struct nouveau_channel;
#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
#include "nouveau_revcompat.h"
#include "nouveau_fence.h" #include "nouveau_fence.h"
#include "nouveau_bios.h"
struct nouveau_drm_tile { struct nouveau_drm_tile {
struct nouveau_fence *fence; struct nouveau_fence *fence;
...@@ -96,13 +107,25 @@ struct nouveau_drm { ...@@ -96,13 +107,25 @@ struct nouveau_drm {
spinlock_t lock; spinlock_t lock;
} tile; } tile;
/* modesetting */
struct nvbios vbios;
struct nouveau_display *display;
struct backlight_device *backlight; struct backlight_device *backlight;
/* power management */
struct nouveau_pm *pm;
}; };
static inline struct nouveau_drm * static inline struct nouveau_drm *
nouveau_drm(struct drm_device *dev) nouveau_drm(struct drm_device *dev)
{ {
return nouveau_newpriv(dev); return dev->dev_private;
}
static inline struct nouveau_device *
nouveau_dev(struct drm_device *dev)
{
return nv_device(nouveau_drm(dev)->device);
} }
int nouveau_drm_suspend(struct pci_dev *, pm_message_t); int nouveau_drm_suspend(struct pci_dev *, pm_message_t);
......
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2008 Maarten Maathuis.
* 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 THE COPYRIGHT OWNER(S) 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_FRB_H__
#define __NOUVEAU_FRB_H__
struct nouveau_framebuffer {
struct drm_framebuffer base;
struct nouveau_bo *nvbo;
struct nouveau_vma vma;
u32 r_dma;
u32 r_format;
u32 r_pitch;
};
static inline struct nouveau_framebuffer *
nouveau_framebuffer(struct drm_framebuffer *fb)
{
return container_of(fb, struct nouveau_framebuffer, base);
}
int nouveau_framebuffer_init(struct drm_device *dev, struct nouveau_framebuffer *nouveau_fb,
struct drm_mode_fb_cmd2 *mode_cmd, struct nouveau_bo *nvbo);
#endif /* __NOUVEAU_FB_H__ */
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "nouveau_drm.h" #include "nouveau_drm.h"
#include "nouveau_gem.h" #include "nouveau_gem.h"
#include "nouveau_bo.h" #include "nouveau_bo.h"
#include "nouveau_fb.h"
#include "nouveau_fbcon.h" #include "nouveau_fbcon.h"
#include "nouveau_chan.h" #include "nouveau_chan.h"
...@@ -66,7 +65,7 @@ static void ...@@ -66,7 +65,7 @@ static void
nouveau_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect) nouveau_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_newpriv(fbcon->dev); struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
int ret; int ret;
...@@ -98,7 +97,7 @@ static void ...@@ -98,7 +97,7 @@ static void
nouveau_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *image) nouveau_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *image)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_newpriv(fbcon->dev); struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
int ret; int ret;
...@@ -130,7 +129,7 @@ static void ...@@ -130,7 +129,7 @@ static void
nouveau_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) nouveau_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_newpriv(fbcon->dev); struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
int ret; int ret;
...@@ -162,7 +161,7 @@ static int ...@@ -162,7 +161,7 @@ static int
nouveau_fbcon_sync(struct fb_info *info) nouveau_fbcon_sync(struct fb_info *info)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_newpriv(fbcon->dev); struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
struct nouveau_channel *chan = drm->channel; struct nouveau_channel *chan = drm->channel;
int ret; int ret;
...@@ -257,7 +256,7 @@ nouveau_fbcon_create(struct nouveau_fbdev *fbcon, ...@@ -257,7 +256,7 @@ nouveau_fbcon_create(struct nouveau_fbdev *fbcon,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct drm_device *dev = fbcon->dev; struct drm_device *dev = fbcon->dev;
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_device *device = nv_device(drm->device); struct nouveau_device *device = nv_device(drm->device);
struct fb_info *info; struct fb_info *info;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
...@@ -410,7 +409,7 @@ nouveau_fbcon_find_or_create_single(struct drm_fb_helper *helper, ...@@ -410,7 +409,7 @@ nouveau_fbcon_find_or_create_single(struct drm_fb_helper *helper,
void void
nouveau_fbcon_output_poll_changed(struct drm_device *dev) nouveau_fbcon_output_poll_changed(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
drm_fb_helper_hotplug_event(&drm->fbcon->helper); drm_fb_helper_hotplug_event(&drm->fbcon->helper);
} }
...@@ -442,7 +441,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon) ...@@ -442,7 +441,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon)
void nouveau_fbcon_gpu_lockup(struct fb_info *info) void nouveau_fbcon_gpu_lockup(struct fb_info *info)
{ {
struct nouveau_fbdev *fbcon = info->par; struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_newpriv(fbcon->dev); struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
NV_ERROR(drm, "GPU lockup - switching to software fbcon\n"); NV_ERROR(drm, "GPU lockup - switching to software fbcon\n");
info->flags |= FBINFO_HWACCEL_DISABLED; info->flags |= FBINFO_HWACCEL_DISABLED;
...@@ -458,7 +457,7 @@ static struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = { ...@@ -458,7 +457,7 @@ static struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
int int
nouveau_fbcon_init(struct drm_device *dev) nouveau_fbcon_init(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_fb *pfb = nouveau_fb(drm->device); struct nouveau_fb *pfb = nouveau_fb(drm->device);
struct nouveau_fbdev *fbcon; struct nouveau_fbdev *fbcon;
int preferred_bpp; int preferred_bpp;
...@@ -499,7 +498,7 @@ nouveau_fbcon_init(struct drm_device *dev) ...@@ -499,7 +498,7 @@ nouveau_fbcon_init(struct drm_device *dev)
void void
nouveau_fbcon_fini(struct drm_device *dev) nouveau_fbcon_fini(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
if (!drm->fbcon) if (!drm->fbcon)
return; return;
...@@ -511,7 +510,7 @@ nouveau_fbcon_fini(struct drm_device *dev) ...@@ -511,7 +510,7 @@ nouveau_fbcon_fini(struct drm_device *dev)
void nouveau_fbcon_save_disable_accel(struct drm_device *dev) void nouveau_fbcon_save_disable_accel(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
drm->fbcon->saved_flags = drm->fbcon->helper.fbdev->flags; drm->fbcon->saved_flags = drm->fbcon->helper.fbdev->flags;
drm->fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED; drm->fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED;
...@@ -519,13 +518,13 @@ void nouveau_fbcon_save_disable_accel(struct drm_device *dev) ...@@ -519,13 +518,13 @@ void nouveau_fbcon_save_disable_accel(struct drm_device *dev)
void nouveau_fbcon_restore_accel(struct drm_device *dev) void nouveau_fbcon_restore_accel(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
drm->fbcon->helper.fbdev->flags = drm->fbcon->saved_flags; drm->fbcon->helper.fbdev->flags = drm->fbcon->saved_flags;
} }
void nouveau_fbcon_set_suspend(struct drm_device *dev, int state) void nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
console_lock(); console_lock();
if (state == 0) if (state == 0)
nouveau_fbcon_save_disable_accel(dev); nouveau_fbcon_save_disable_accel(dev);
...@@ -537,6 +536,6 @@ void nouveau_fbcon_set_suspend(struct drm_device *dev, int state) ...@@ -537,6 +536,6 @@ void nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
void nouveau_fbcon_zfill_all(struct drm_device *dev) void nouveau_fbcon_zfill_all(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
nouveau_fbcon_zfill(dev, drm->fbcon); nouveau_fbcon_zfill(dev, drm->fbcon);
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "drm_fb_helper.h" #include "drm_fb_helper.h"
#include "nouveau_fb.h" #include "nouveau_display.h"
struct nouveau_fbdev { struct nouveau_fbdev {
struct drm_fb_helper helper; struct drm_fb_helper helper;
......
...@@ -550,7 +550,7 @@ nouveau_gem_pushbuf_reloc_apply(struct drm_device *dev, ...@@ -550,7 +550,7 @@ nouveau_gem_pushbuf_reloc_apply(struct drm_device *dev,
struct drm_nouveau_gem_pushbuf *req, struct drm_nouveau_gem_pushbuf *req,
struct drm_nouveau_gem_pushbuf_bo *bo) struct drm_nouveau_gem_pushbuf_bo *bo)
{ {
struct nouveau_drm *drm = nouveau_newpriv(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct drm_nouveau_gem_pushbuf_reloc *reloc = NULL; struct drm_nouveau_gem_pushbuf_reloc *reloc = NULL;
int ret = 0; int ret = 0;
unsigned i; unsigned i;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
*/ */
#include "drmP.h" #include "drmP.h"
#include "nouveau_drv.h" #include "nouveau_drm.h"
#include "nouveau_connector.h" #include "nouveau_connector.h"
#include "nouveau_encoder.h" #include "nouveau_encoder.h"
#include "nouveau_crtc.h" #include "nouveau_crtc.h"
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
static bool static bool
hdmi_sor(struct drm_encoder *encoder) hdmi_sor(struct drm_encoder *encoder)
{ {
struct drm_nouveau_private *dev_priv = encoder->dev->dev_private; struct nouveau_drm *drm = nouveau_drm(encoder->dev);
if (dev_priv->chipset < 0xa3 || if (nv_device(drm->device)->chipset < 0xa3 ||
dev_priv->chipset == 0xaa || nv_device(drm->device)->chipset == 0xaa ||
dev_priv->chipset == 0xac) nv_device(drm->device)->chipset == 0xac)
return false; return false;
return true; return true;
} }
...@@ -52,13 +52,15 @@ hdmi_base(struct drm_encoder *encoder) ...@@ -52,13 +52,15 @@ hdmi_base(struct drm_encoder *encoder)
static void static void
hdmi_wr32(struct drm_encoder *encoder, u32 reg, u32 val) hdmi_wr32(struct drm_encoder *encoder, u32 reg, u32 val)
{ {
nv_wr32(encoder->dev, hdmi_base(encoder) + reg, val); struct nouveau_device *device = nouveau_dev(encoder->dev);
nv_wr32(device, hdmi_base(encoder) + reg, val);
} }
static u32 static u32
hdmi_rd32(struct drm_encoder *encoder, u32 reg) hdmi_rd32(struct drm_encoder *encoder, u32 reg)
{ {
return nv_rd32(encoder->dev, hdmi_base(encoder) + reg); struct nouveau_device *device = nouveau_dev(encoder->dev);
return nv_rd32(device, hdmi_base(encoder) + reg);
} }
static u32 static u32
...@@ -73,12 +75,11 @@ static void ...@@ -73,12 +75,11 @@ static void
nouveau_audio_disconnect(struct drm_encoder *encoder) nouveau_audio_disconnect(struct drm_encoder *encoder)
{ {
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
struct drm_device *dev = encoder->dev; struct nouveau_device *device = nouveau_dev(encoder->dev);
u32 or = nv_encoder->or * 0x800; u32 or = nv_encoder->or * 0x800;
if (hdmi_sor(encoder)) { if (hdmi_sor(encoder))
nv_mask(dev, 0x61c448 + or, 0x00000003, 0x00000000); nv_mask(device, 0x61c448 + or, 0x00000003, 0x00000000);
}
} }
static void static void
...@@ -86,8 +87,8 @@ nouveau_audio_mode_set(struct drm_encoder *encoder, ...@@ -86,8 +87,8 @@ nouveau_audio_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
struct nouveau_device *device = nouveau_dev(encoder->dev);
struct nouveau_connector *nv_connector; struct nouveau_connector *nv_connector;
struct drm_device *dev = encoder->dev;
u32 or = nv_encoder->or * 0x800; u32 or = nv_encoder->or * 0x800;
int i; int i;
...@@ -98,16 +99,16 @@ nouveau_audio_mode_set(struct drm_encoder *encoder, ...@@ -98,16 +99,16 @@ nouveau_audio_mode_set(struct drm_encoder *encoder,
} }
if (hdmi_sor(encoder)) { if (hdmi_sor(encoder)) {
nv_mask(dev, 0x61c448 + or, 0x00000001, 0x00000001); nv_mask(device, 0x61c448 + or, 0x00000001, 0x00000001);
drm_edid_to_eld(&nv_connector->base, nv_connector->edid); drm_edid_to_eld(&nv_connector->base, nv_connector->edid);
if (nv_connector->base.eld[0]) { if (nv_connector->base.eld[0]) {
u8 *eld = nv_connector->base.eld; u8 *eld = nv_connector->base.eld;
for (i = 0; i < eld[2] * 4; i++) for (i = 0; i < eld[2] * 4; i++)
nv_wr32(dev, 0x61c440 + or, (i << 8) | eld[i]); nv_wr32(device, 0x61c440 + or, (i << 8) | eld[i]);
for (i = eld[2] * 4; i < 0x60; i++) for (i = eld[2] * 4; i < 0x60; i++)
nv_wr32(dev, 0x61c440 + or, (i << 8) | 0x00); nv_wr32(device, 0x61c440 + or, (i << 8) | 0x00);
nv_mask(dev, 0x61c448 + or, 0x00000002, 0x00000002); nv_mask(device, 0x61c448 + or, 0x00000002, 0x00000002);
} }
} }
} }
...@@ -219,9 +220,9 @@ void ...@@ -219,9 +220,9 @@ void
nouveau_hdmi_mode_set(struct drm_encoder *encoder, nouveau_hdmi_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct nouveau_device *device = nouveau_dev(encoder->dev);
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
struct nouveau_connector *nv_connector; struct nouveau_connector *nv_connector;
struct drm_device *dev = encoder->dev;
u32 max_ac_packet, rekey; u32 max_ac_packet, rekey;
nv_connector = nouveau_encoder_connector_get(nv_encoder); nv_connector = nouveau_encoder_connector_get(nv_encoder);
...@@ -238,9 +239,9 @@ nouveau_hdmi_mode_set(struct drm_encoder *encoder, ...@@ -238,9 +239,9 @@ nouveau_hdmi_mode_set(struct drm_encoder *encoder,
hdmi_mask(encoder, 0x068, 0x00010101, 0x00000000); /* ACR_CTRL, ?? */ hdmi_mask(encoder, 0x068, 0x00010101, 0x00000000); /* ACR_CTRL, ?? */
hdmi_mask(encoder, 0x078, 0x80000000, 0x80000000); /* ACR_0441_ENABLE */ hdmi_mask(encoder, 0x078, 0x80000000, 0x80000000); /* ACR_0441_ENABLE */
nv_mask(dev, 0x61733c, 0x00100000, 0x00100000); /* RESETF */ nv_mask(device, 0x61733c, 0x00100000, 0x00100000); /* RESETF */
nv_mask(dev, 0x61733c, 0x10000000, 0x10000000); /* LOOKUP_EN */ nv_mask(device, 0x61733c, 0x10000000, 0x10000000); /* LOOKUP_EN */
nv_mask(dev, 0x61733c, 0x00100000, 0x00000000); /* !RESETF */ nv_mask(device, 0x61733c, 0x00100000, 0x00000000); /* !RESETF */
/* value matches nvidia binary driver, and tegra constant */ /* value matches nvidia binary driver, and tegra constant */
rekey = 56; rekey = 56;
......
This diff is collapsed.
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#define __NOUVEAU_HW_H__ #define __NOUVEAU_HW_H__
#include "drmP.h" #include "drmP.h"
#include "nouveau_drv.h"
#include "nv04_display.h" #include "nv04_display.h"
#include <subdev/bios/pll.h> #include <subdev/bios/pll.h>
...@@ -60,37 +59,41 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp, ...@@ -60,37 +59,41 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp,
static inline uint32_t NVReadCRTC(struct drm_device *dev, static inline uint32_t NVReadCRTC(struct drm_device *dev,
int head, uint32_t reg) int head, uint32_t reg)
{ {
struct nouveau_device *device = nouveau_dev(dev);
uint32_t val; uint32_t val;
if (head) if (head)
reg += NV_PCRTC0_SIZE; reg += NV_PCRTC0_SIZE;
val = nv_rd32(dev, reg); val = nv_rd32(device, reg);
return val; return val;
} }
static inline void NVWriteCRTC(struct drm_device *dev, static inline void NVWriteCRTC(struct drm_device *dev,
int head, uint32_t reg, uint32_t val) int head, uint32_t reg, uint32_t val)
{ {
struct nouveau_device *device = nouveau_dev(dev);
if (head) if (head)
reg += NV_PCRTC0_SIZE; reg += NV_PCRTC0_SIZE;
nv_wr32(dev, reg, val); nv_wr32(device, reg, val);
} }
static inline uint32_t NVReadRAMDAC(struct drm_device *dev, static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
int head, uint32_t reg) int head, uint32_t reg)
{ {
struct nouveau_device *device = nouveau_dev(dev);
uint32_t val; uint32_t val;
if (head) if (head)
reg += NV_PRAMDAC0_SIZE; reg += NV_PRAMDAC0_SIZE;
val = nv_rd32(dev, reg); val = nv_rd32(device, reg);
return val; return val;
} }
static inline void NVWriteRAMDAC(struct drm_device *dev, static inline void NVWriteRAMDAC(struct drm_device *dev,
int head, uint32_t reg, uint32_t val) int head, uint32_t reg, uint32_t val)
{ {
struct nouveau_device *device = nouveau_dev(dev);
if (head) if (head)
reg += NV_PRAMDAC0_SIZE; reg += NV_PRAMDAC0_SIZE;
nv_wr32(dev, reg, val); nv_wr32(device, reg, val);
} }
static inline uint8_t nv_read_tmds(struct drm_device *dev, static inline uint8_t nv_read_tmds(struct drm_device *dev,
...@@ -116,16 +119,18 @@ static inline void nv_write_tmds(struct drm_device *dev, ...@@ -116,16 +119,18 @@ static inline void nv_write_tmds(struct drm_device *dev,
static inline void NVWriteVgaCrtc(struct drm_device *dev, static inline void NVWriteVgaCrtc(struct drm_device *dev,
int head, uint8_t index, uint8_t value) int head, uint8_t index, uint8_t value)
{ {
nv_wr08(dev, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); struct nouveau_device *device = nouveau_dev(dev);
nv_wr08(dev, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value); nv_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
nv_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value);
} }
static inline uint8_t NVReadVgaCrtc(struct drm_device *dev, static inline uint8_t NVReadVgaCrtc(struct drm_device *dev,
int head, uint8_t index) int head, uint8_t index)
{ {
struct nouveau_device *device = nouveau_dev(dev);
uint8_t val; uint8_t val;
nv_wr08(dev, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); nv_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
val = nv_rd08(dev, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE); val = nv_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE);
return val; return val;
} }
...@@ -159,68 +164,74 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_ ...@@ -159,68 +164,74 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_
static inline uint8_t NVReadPRMVIO(struct drm_device *dev, static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
int head, uint32_t reg) int head, uint32_t reg)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_device *device = nouveau_dev(dev);
struct nouveau_drm *drm = nouveau_drm(dev);
uint8_t val; uint8_t val;
/* Only NV4x have two pvio ranges; other twoHeads cards MUST call /* Only NV4x have two pvio ranges; other twoHeads cards MUST call
* NVSetOwner for the relevant head to be programmed */ * NVSetOwner for the relevant head to be programmed */
if (head && dev_priv->card_type == NV_40) if (head && nv_device(drm->device)->card_type == NV_40)
reg += NV_PRMVIO_SIZE; reg += NV_PRMVIO_SIZE;
val = nv_rd08(dev, reg); val = nv_rd08(device, reg);
return val; return val;
} }
static inline void NVWritePRMVIO(struct drm_device *dev, static inline void NVWritePRMVIO(struct drm_device *dev,
int head, uint32_t reg, uint8_t value) int head, uint32_t reg, uint8_t value)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_device *device = nouveau_dev(dev);
struct nouveau_drm *drm = nouveau_drm(dev);
/* Only NV4x have two pvio ranges; other twoHeads cards MUST call /* Only NV4x have two pvio ranges; other twoHeads cards MUST call
* NVSetOwner for the relevant head to be programmed */ * NVSetOwner for the relevant head to be programmed */
if (head && dev_priv->card_type == NV_40) if (head && nv_device(drm->device)->card_type == NV_40)
reg += NV_PRMVIO_SIZE; reg += NV_PRMVIO_SIZE;
nv_wr08(dev, reg, value); nv_wr08(device, reg, value);
} }
static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable) static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable)
{ {
nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); struct nouveau_device *device = nouveau_dev(dev);
nv_wr08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20); nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20);
} }
static inline bool NVGetEnablePalette(struct drm_device *dev, int head) static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
{ {
nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); struct nouveau_device *device = nouveau_dev(dev);
return !(nv_rd08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20); nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
return !(nv_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20);
} }
static inline void NVWriteVgaAttr(struct drm_device *dev, static inline void NVWriteVgaAttr(struct drm_device *dev,
int head, uint8_t index, uint8_t value) int head, uint8_t index, uint8_t value)
{ {
struct nouveau_device *device = nouveau_dev(dev);
if (NVGetEnablePalette(dev, head)) if (NVGetEnablePalette(dev, head))
index &= ~0x20; index &= ~0x20;
else else
index |= 0x20; index |= 0x20;
nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
nv_wr08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index);
nv_wr08(dev, NV_PRMCIO_AR__WRITE + head * NV_PRMCIO_SIZE, value); nv_wr08(device, NV_PRMCIO_AR__WRITE + head * NV_PRMCIO_SIZE, value);
} }
static inline uint8_t NVReadVgaAttr(struct drm_device *dev, static inline uint8_t NVReadVgaAttr(struct drm_device *dev,
int head, uint8_t index) int head, uint8_t index)
{ {
struct nouveau_device *device = nouveau_dev(dev);
uint8_t val; uint8_t val;
if (NVGetEnablePalette(dev, head)) if (NVGetEnablePalette(dev, head))
index &= ~0x20; index &= ~0x20;
else else
index |= 0x20; index |= 0x20;
nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
nv_wr08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index);
val = nv_rd08(dev, NV_PRMCIO_AR__READ + head * NV_PRMCIO_SIZE); val = nv_rd08(device, NV_PRMCIO_AR__READ + head * NV_PRMCIO_SIZE);
return val; return val;
} }
...@@ -247,10 +258,11 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect) ...@@ -247,10 +258,11 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect)
static inline bool static inline bool
nv_heads_tied(struct drm_device *dev) nv_heads_tied(struct drm_device *dev)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_device *device = nouveau_dev(dev);
struct nouveau_drm *drm = nouveau_drm(dev);
if (dev_priv->chipset == 0x11) if (nv_device(drm->device)->chipset == 0x11)
return !!(nv_rd32(dev, NV_PBUS_DEBUG_1) & (1 << 28)); return !!(nv_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28));
return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4; return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4;
} }
...@@ -299,13 +311,13 @@ nv_lock_vga_crtc_shadow(struct drm_device *dev, int head, int lock) ...@@ -299,13 +311,13 @@ nv_lock_vga_crtc_shadow(struct drm_device *dev, int head, int lock)
static inline bool static inline bool
NVLockVgaCrtcs(struct drm_device *dev, bool lock) NVLockVgaCrtcs(struct drm_device *dev, bool lock)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_drm *drm = nouveau_drm(dev);
bool waslocked = !NVReadVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX); bool waslocked = !NVReadVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX);
NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX, NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX,
lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE); lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE);
/* NV11 has independently lockable extended crtcs, except when tied */ /* NV11 has independently lockable extended crtcs, except when tied */
if (dev_priv->chipset == 0x11 && !nv_heads_tied(dev)) if (nv_device(drm->device)->chipset == 0x11 && !nv_heads_tied(dev))
NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX, NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX,
lock ? NV_CIO_SR_LOCK_VALUE : lock ? NV_CIO_SR_LOCK_VALUE :
NV_CIO_SR_UNLOCK_RW_VALUE); NV_CIO_SR_UNLOCK_RW_VALUE);
...@@ -320,9 +332,9 @@ NVLockVgaCrtcs(struct drm_device *dev, bool lock) ...@@ -320,9 +332,9 @@ NVLockVgaCrtcs(struct drm_device *dev, bool lock)
static inline int nv_cursor_width(struct drm_device *dev) static inline int nv_cursor_width(struct drm_device *dev)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_drm *drm = nouveau_drm(dev);
return dev_priv->card_type >= NV_10 ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE; return nv_device(drm->device)->card_type >= NV_10 ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE;
} }
static inline void static inline void
...@@ -340,11 +352,11 @@ nv_fix_nv40_hw_cursor(struct drm_device *dev, int head) ...@@ -340,11 +352,11 @@ nv_fix_nv40_hw_cursor(struct drm_device *dev, int head)
static inline void static inline void
nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset) nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_drm *drm = nouveau_drm(dev);
NVWriteCRTC(dev, head, NV_PCRTC_START, offset); NVWriteCRTC(dev, head, NV_PCRTC_START, offset);
if (dev_priv->card_type == NV_04) { if (nv_device(drm->device)->card_type == NV_04) {
/* /*
* Hilarious, the 24th bit doesn't want to stick to * Hilarious, the 24th bit doesn't want to stick to
* PCRTC_START... * PCRTC_START...
...@@ -359,7 +371,7 @@ nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset) ...@@ -359,7 +371,7 @@ nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset)
static inline void static inline void
nv_show_cursor(struct drm_device *dev, int head, bool show) nv_show_cursor(struct drm_device *dev, int head, bool show)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_drm *drm = nouveau_drm(dev);
uint8_t *curctl1 = uint8_t *curctl1 =
&nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX]; &nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX];
...@@ -369,14 +381,14 @@ nv_show_cursor(struct drm_device *dev, int head, bool show) ...@@ -369,14 +381,14 @@ nv_show_cursor(struct drm_device *dev, int head, bool show)
*curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE); *curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE);
NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1); NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1);
if (dev_priv->card_type == NV_40) if (nv_device(drm->device)->card_type == NV_40)
nv_fix_nv40_hw_cursor(dev, head); nv_fix_nv40_hw_cursor(dev, head);
} }
static inline uint32_t static inline uint32_t
nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp) nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct nouveau_drm *drm = nouveau_drm(dev);
int mask; int mask;
if (bpp == 15) if (bpp == 15)
...@@ -385,7 +397,7 @@ nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp) ...@@ -385,7 +397,7 @@ nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp)
bpp = 8; bpp = 8;
/* Alignment requirements taken from the Haiku driver */ /* Alignment requirements taken from the Haiku driver */
if (dev_priv->card_type == NV_04) if (nv_device(drm->device)->card_type == NV_04)
mask = 128 / bpp - 1; mask = 128 / bpp - 1;
else else
mask = 512 / bpp - 1; mask = 512 / bpp - 1;
......
This diff is collapsed.
#ifndef __NOUVEAU_IRQ_H__
#define __NOUVEAU_IRQ_H__
extern int nouveau_irq_init(struct drm_device *);
extern void nouveau_irq_fini(struct drm_device *);
extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS);
extern void nouveau_irq_preinstall(struct drm_device *);
extern int nouveau_irq_postinstall(struct drm_device *);
extern void nouveau_irq_uninstall(struct drm_device *);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
* Authors: Dave Airlie * Authors: Dave Airlie
*/ */
#include <linux/dma-buf.h>
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
#include "nouveau_drv.h" #include "nouveau_drm.h"
#include <nouveau_drm.h> #include "nouveau_gem.h"
#include <linux/dma-buf.h>
static struct sg_table *nouveau_gem_map_dma_buf(struct dma_buf_attachment *attachment, static struct sg_table *nouveau_gem_map_dma_buf(struct dma_buf_attachment *attachment,
enum dma_data_direction dir) enum dma_data_direction dir)
......
#include "nouveau_revcompat.h"
#include "nouveau_drv.h"
#include "nv50_display.h"
struct nouveau_drm *
nouveau_newpriv(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
return dev_priv->newpriv;
}
struct nouveau_bo *
nv50sema(struct drm_device *dev, int crtc)
{
return nv50_display(dev)->crtc[crtc].sem.bo;
}
struct nouveau_bo *
nvd0sema(struct drm_device *dev, int crtc)
{
return nvd0_display_crtc_sema(dev, crtc);
}
#ifndef __NOUVEAU_REVCOMPAT_H__
#define __NOUVEAU_REVCOMPAT_H__
#include "drmP.h"
struct nouveau_drm *
nouveau_newpriv(struct drm_device *);
struct nouveau_bo *nv50sema(struct drm_device *dev, int crtc);
struct nouveau_bo *nvd0sema(struct drm_device *dev, int crtc);
#endif
This diff is collapsed.
This diff is collapsed.
...@@ -265,7 +265,7 @@ int ...@@ -265,7 +265,7 @@ int
nouveau_ttm_mmap(struct file *filp, struct vm_area_struct *vma) nouveau_ttm_mmap(struct file *filp, struct vm_area_struct *vma)
{ {
struct drm_file *file_priv = filp->private_data; struct drm_file *file_priv = filp->private_data;
struct nouveau_drm *drm = nouveau_newpriv(file_priv->minor->dev); struct nouveau_drm *drm = nouveau_drm(file_priv->minor->dev);
if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
return drm_mmap(filp, vma); return drm_mmap(filp, vma);
......
...@@ -17,5 +17,9 @@ struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_bo_device *, ...@@ -17,5 +17,9 @@ struct ttm_tt *nouveau_sgdma_create_ttm(struct ttm_bo_device *,
int nouveau_ttm_init(struct nouveau_drm *drm); int nouveau_ttm_init(struct nouveau_drm *drm);
void nouveau_ttm_fini(struct nouveau_drm *drm); void nouveau_ttm_fini(struct nouveau_drm *drm);
int nouveau_ttm_mmap(struct file *, struct vm_area_struct *);
int nouveau_ttm_global_init(struct nouveau_drm *);
void nouveau_ttm_global_release(struct nouveau_drm *);
#endif #endif
This diff is collapsed.
#ifndef __NOUVEAU_VGA_H__
#define __NOUVEAU_VGA_H__
void nouveau_vga_init(struct nouveau_drm *);
void nouveau_vga_fini(struct nouveau_drm *);
void nouveau_vga_lastclose(struct drm_device *dev);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -130,12 +130,14 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder); ...@@ -130,12 +130,14 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder);
static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg, static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg,
uint32_t val) uint32_t val)
{ {
nv_wr32(dev, reg, val); struct nouveau_device *device = nouveau_dev(dev);
nv_wr32(device, reg, val);
} }
static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg) static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg)
{ {
return nv_rd32(dev, reg); struct nouveau_device *device = nouveau_dev(dev);
return nv_rd32(device, reg);
} }
static inline void nv_write_tv_enc(struct drm_device *dev, uint8_t reg, static inline void nv_write_tv_enc(struct drm_device *dev, uint8_t reg,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment