aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-08-09 14:10:22 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-08-09 15:13:11 -0400
commitdb2bec187dd68e79d512112df1f6e7a849e7f0ce (patch)
tree1a43c57fcea7915c837d5338d2bdf103259bc7be
parentfa2bade99a6fb24c3847d48ba3cad9a70dbb5364 (diff)
drm/nouveau: kill nouveau_dev() + wrap register macros
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/arb.c8
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/dac.c46
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/dfp.c6
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/disp.h4
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/hw.c46
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/hw.h68
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/overlay.c110
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/tvnv17.h8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_agp.c14
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_backlight.c48
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c26
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.h22
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_vga.c14
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c12
17 files changed, 228 insertions, 219 deletions
diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c b/drivers/gpu/drm/nouveau/dispnv04/arb.c
index 2a15b98b4d2b..c64db854cc26 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/arb.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c
@@ -198,12 +198,12 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
198 int *burst, int *lwm) 198 int *burst, int *lwm)
199{ 199{
200 struct nouveau_drm *drm = nouveau_drm(dev); 200 struct nouveau_drm *drm = nouveau_drm(dev);
201 struct nouveau_device *device = nouveau_dev(dev); 201 struct nouveau_object *device = nouveau_drm(dev)->device;
202 struct nv_fifo_info fifo_data; 202 struct nv_fifo_info fifo_data;
203 struct nv_sim_state sim_data; 203 struct nv_sim_state sim_data;
204 int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY); 204 int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY);
205 int NVClk = nouveau_hw_get_clock(dev, PLL_CORE); 205 int NVClk = nouveau_hw_get_clock(dev, PLL_CORE);
206 uint32_t cfg1 = nv_rd32(device, NV04_PFB_CFG1); 206 uint32_t cfg1 = nvif_rd32(device, NV04_PFB_CFG1);
207 207
208 sim_data.pclk_khz = VClk; 208 sim_data.pclk_khz = VClk;
209 sim_data.mclk_khz = MClk; 209 sim_data.mclk_khz = MClk;
@@ -221,8 +221,8 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
221 sim_data.mem_latency = 3; 221 sim_data.mem_latency = 3;
222 sim_data.mem_page_miss = 10; 222 sim_data.mem_page_miss = 10;
223 } else { 223 } else {
224 sim_data.memory_type = nv_rd32(device, NV04_PFB_CFG0) & 0x1; 224 sim_data.memory_type = nvif_rd32(device, NV04_PFB_CFG0) & 0x1;
225 sim_data.memory_width = (nv_rd32(device, NV_PEXTDEV_BOOT_0) & 0x10) ? 128 : 64; 225 sim_data.memory_width = (nvif_rd32(device, NV_PEXTDEV_BOOT_0) & 0x10) ? 128 : 64;
226 sim_data.mem_latency = cfg1 & 0xf; 226 sim_data.mem_latency = cfg1 & 0xf;
227 sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1); 227 sim_data.mem_page_miss = ((cfg1 >> 4) & 0xf) + ((cfg1 >> 31) & 0x1);
228 } 228 }
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dac.c b/drivers/gpu/drm/nouveau/dispnv04/dac.c
index a96dda48718e..3fec5e6b66b1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dac.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dac.c
@@ -65,7 +65,7 @@ int nv04_dac_output_offset(struct drm_encoder *encoder)
65 65
66static int sample_load_twice(struct drm_device *dev, bool sense[2]) 66static int sample_load_twice(struct drm_device *dev, bool sense[2])
67{ 67{
68 struct nouveau_device *device = nouveau_dev(dev); 68 struct nouveau_object *device = nouveau_drm(dev)->device;
69 struct nouveau_timer *ptimer = nouveau_timer(device); 69 struct nouveau_timer *ptimer = nouveau_timer(device);
70 int i; 70 int i;
71 71
@@ -95,15 +95,15 @@ static int sample_load_twice(struct drm_device *dev, bool sense[2])
95 95
96 udelay(100); 96 udelay(100);
97 /* when level triggers, sense is _LO_ */ 97 /* when level triggers, sense is _LO_ */
98 sense_a = nv_rd08(device, NV_PRMCIO_INP0) & 0x10; 98 sense_a = nvif_rd08(device, NV_PRMCIO_INP0) & 0x10;
99 99
100 /* take another reading until it agrees with sense_a... */ 100 /* take another reading until it agrees with sense_a... */
101 do { 101 do {
102 udelay(100); 102 udelay(100);
103 sense_b = nv_rd08(device, NV_PRMCIO_INP0) & 0x10; 103 sense_b = nvif_rd08(device, NV_PRMCIO_INP0) & 0x10;
104 if (sense_a != sense_b) { 104 if (sense_a != sense_b) {
105 sense_b_prime = 105 sense_b_prime =
106 nv_rd08(device, NV_PRMCIO_INP0) & 0x10; 106 nvif_rd08(device, NV_PRMCIO_INP0) & 0x10;
107 if (sense_b == sense_b_prime) { 107 if (sense_b == sense_b_prime) {
108 /* ... unless two consecutive subsequent 108 /* ... unless two consecutive subsequent
109 * samples agree; sense_a is replaced */ 109 * samples agree; sense_a is replaced */
@@ -128,7 +128,7 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder,
128 struct drm_connector *connector) 128 struct drm_connector *connector)
129{ 129{
130 struct drm_device *dev = encoder->dev; 130 struct drm_device *dev = encoder->dev;
131 struct nouveau_device *device = nouveau_dev(dev); 131 struct nouveau_object *device = nouveau_drm(dev)->device;
132 struct nouveau_drm *drm = nouveau_drm(dev); 132 struct nouveau_drm *drm = nouveau_drm(dev);
133 uint8_t saved_seq1, saved_pi, saved_rpc1, saved_cr_mode; 133 uint8_t saved_seq1, saved_pi, saved_rpc1, saved_cr_mode;
134 uint8_t saved_palette0[3], saved_palette_mask; 134 uint8_t saved_palette0[3], saved_palette_mask;
@@ -164,11 +164,11 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder,
164 saved_rpc1 = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_RPC1_INDEX); 164 saved_rpc1 = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_RPC1_INDEX);
165 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_RPC1_INDEX, saved_rpc1 & ~0xc0); 165 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_RPC1_INDEX, saved_rpc1 & ~0xc0);
166 166
167 nv_wr08(device, NV_PRMDIO_READ_MODE_ADDRESS, 0x0); 167 nvif_wr08(device, NV_PRMDIO_READ_MODE_ADDRESS, 0x0);
168 for (i = 0; i < 3; i++) 168 for (i = 0; i < 3; i++)
169 saved_palette0[i] = nv_rd08(device, NV_PRMDIO_PALETTE_DATA); 169 saved_palette0[i] = nvif_rd08(device, NV_PRMDIO_PALETTE_DATA);
170 saved_palette_mask = nv_rd08(device, NV_PRMDIO_PIXEL_MASK); 170 saved_palette_mask = nvif_rd08(device, NV_PRMDIO_PIXEL_MASK);
171 nv_wr08(device, NV_PRMDIO_PIXEL_MASK, 0); 171 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK, 0);
172 172
173 saved_rgen_ctrl = NVReadRAMDAC(dev, 0, NV_PRAMDAC_GENERAL_CONTROL); 173 saved_rgen_ctrl = NVReadRAMDAC(dev, 0, NV_PRAMDAC_GENERAL_CONTROL);
174 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_GENERAL_CONTROL, 174 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_GENERAL_CONTROL,
@@ -181,11 +181,11 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder,
181 do { 181 do {
182 bool sense_pair[2]; 182 bool sense_pair[2];
183 183
184 nv_wr08(device, NV_PRMDIO_WRITE_MODE_ADDRESS, 0); 184 nvif_wr08(device, NV_PRMDIO_WRITE_MODE_ADDRESS, 0);
185 nv_wr08(device, NV_PRMDIO_PALETTE_DATA, 0); 185 nvif_wr08(device, NV_PRMDIO_PALETTE_DATA, 0);
186 nv_wr08(device, NV_PRMDIO_PALETTE_DATA, 0); 186 nvif_wr08(device, NV_PRMDIO_PALETTE_DATA, 0);
187 /* testing blue won't find monochrome monitors. I don't care */ 187 /* testing blue won't find monochrome monitors. I don't care */
188 nv_wr08(device, NV_PRMDIO_PALETTE_DATA, blue); 188 nvif_wr08(device, NV_PRMDIO_PALETTE_DATA, blue);
189 189
190 i = 0; 190 i = 0;
191 /* take sample pairs until both samples in the pair agree */ 191 /* take sample pairs until both samples in the pair agree */
@@ -208,11 +208,11 @@ static enum drm_connector_status nv04_dac_detect(struct drm_encoder *encoder,
208 } while (++blue < 0x18 && sense); 208 } while (++blue < 0x18 && sense);
209 209
210out: 210out:
211 nv_wr08(device, NV_PRMDIO_PIXEL_MASK, saved_palette_mask); 211 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK, saved_palette_mask);
212 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_GENERAL_CONTROL, saved_rgen_ctrl); 212 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_GENERAL_CONTROL, saved_rgen_ctrl);
213 nv_wr08(device, NV_PRMDIO_WRITE_MODE_ADDRESS, 0); 213 nvif_wr08(device, NV_PRMDIO_WRITE_MODE_ADDRESS, 0);
214 for (i = 0; i < 3; i++) 214 for (i = 0; i < 3; i++)
215 nv_wr08(device, NV_PRMDIO_PALETTE_DATA, saved_palette0[i]); 215 nvif_wr08(device, NV_PRMDIO_PALETTE_DATA, saved_palette0[i]);
216 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL, saved_rtest_ctrl); 216 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL, saved_rtest_ctrl);
217 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_PIXEL_INDEX, saved_pi); 217 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_PIXEL_INDEX, saved_pi);
218 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_RPC1_INDEX, saved_rpc1); 218 NVWriteVgaCrtc(dev, 0, NV_CIO_CRE_RPC1_INDEX, saved_rpc1);
@@ -231,7 +231,7 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
231{ 231{
232 struct drm_device *dev = encoder->dev; 232 struct drm_device *dev = encoder->dev;
233 struct nouveau_drm *drm = nouveau_drm(dev); 233 struct nouveau_drm *drm = nouveau_drm(dev);
234 struct nouveau_device *device = nouveau_dev(dev); 234 struct nouveau_object *device = nouveau_drm(dev)->device;
235 struct nouveau_gpio *gpio = nouveau_gpio(device); 235 struct nouveau_gpio *gpio = nouveau_gpio(device);
236 struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; 236 struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
237 uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder); 237 uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder);
@@ -256,12 +256,12 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
256 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + regoffset, 256 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + regoffset,
257 saved_rtest_ctrl & ~NV_PRAMDAC_TEST_CONTROL_PWRDWN_DAC_OFF); 257 saved_rtest_ctrl & ~NV_PRAMDAC_TEST_CONTROL_PWRDWN_DAC_OFF);
258 258
259 saved_powerctrl_2 = nv_rd32(device, NV_PBUS_POWERCTRL_2); 259 saved_powerctrl_2 = nvif_rd32(device, NV_PBUS_POWERCTRL_2);
260 260
261 nv_wr32(device, NV_PBUS_POWERCTRL_2, saved_powerctrl_2 & 0xd7ffffff); 261 nvif_wr32(device, NV_PBUS_POWERCTRL_2, saved_powerctrl_2 & 0xd7ffffff);
262 if (regoffset == 0x68) { 262 if (regoffset == 0x68) {
263 saved_powerctrl_4 = nv_rd32(device, NV_PBUS_POWERCTRL_4); 263 saved_powerctrl_4 = nvif_rd32(device, NV_PBUS_POWERCTRL_4);
264 nv_wr32(device, NV_PBUS_POWERCTRL_4, saved_powerctrl_4 & 0xffffffcf); 264 nvif_wr32(device, NV_PBUS_POWERCTRL_4, saved_powerctrl_4 & 0xffffffcf);
265 } 265 }
266 266
267 if (gpio) { 267 if (gpio) {
@@ -316,8 +316,8 @@ uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
316 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_DACCLK + regoffset, saved_routput); 316 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_DACCLK + regoffset, saved_routput);
317 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + regoffset, saved_rtest_ctrl); 317 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + regoffset, saved_rtest_ctrl);
318 if (regoffset == 0x68) 318 if (regoffset == 0x68)
319 nv_wr32(device, NV_PBUS_POWERCTRL_4, saved_powerctrl_4); 319 nvif_wr32(device, NV_PBUS_POWERCTRL_4, saved_powerctrl_4);
320 nv_wr32(device, NV_PBUS_POWERCTRL_2, saved_powerctrl_2); 320 nvif_wr32(device, NV_PBUS_POWERCTRL_2, saved_powerctrl_2);
321 321
322 if (gpio) { 322 if (gpio) {
323 gpio->set(gpio, 0, DCB_GPIO_TVDAC1, 0xff, saved_gpio1); 323 gpio->set(gpio, 0, DCB_GPIO_TVDAC1, 0xff, saved_gpio1);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index e57babb206d3..a9f510e01c2f 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -281,7 +281,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
281 struct drm_display_mode *adjusted_mode) 281 struct drm_display_mode *adjusted_mode)
282{ 282{
283 struct drm_device *dev = encoder->dev; 283 struct drm_device *dev = encoder->dev;
284 struct nouveau_device *device = nouveau_dev(dev); 284 struct nouveau_object *device = nouveau_drm(dev)->device;
285 struct nouveau_drm *drm = nouveau_drm(dev); 285 struct nouveau_drm *drm = nouveau_drm(dev);
286 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 286 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
287 struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; 287 struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
@@ -335,7 +335,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
335 regp->fp_control |= NV_PRAMDAC_FP_TG_CONTROL_MODE_NATIVE; 335 regp->fp_control |= NV_PRAMDAC_FP_TG_CONTROL_MODE_NATIVE;
336 else /* gpu needs to scale */ 336 else /* gpu needs to scale */
337 regp->fp_control |= NV_PRAMDAC_FP_TG_CONTROL_MODE_SCALE; 337 regp->fp_control |= NV_PRAMDAC_FP_TG_CONTROL_MODE_SCALE;
338 if (nv_rd32(device, NV_PEXTDEV_BOOT_0) & NV_PEXTDEV_BOOT_0_STRAP_FP_IFACE_12BIT) 338 if (nvif_rd32(device, NV_PEXTDEV_BOOT_0) & NV_PEXTDEV_BOOT_0_STRAP_FP_IFACE_12BIT)
339 regp->fp_control |= NV_PRAMDAC_FP_TG_CONTROL_WIDTH_12; 339 regp->fp_control |= NV_PRAMDAC_FP_TG_CONTROL_WIDTH_12;
340 if (nv_encoder->dcb->location != DCB_LOC_ON_CHIP && 340 if (nv_encoder->dcb->location != DCB_LOC_ON_CHIP &&
341 output_mode->clock > 165000) 341 output_mode->clock > 165000)
@@ -485,7 +485,7 @@ static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode)
485{ 485{
486#ifdef __powerpc__ 486#ifdef __powerpc__
487 struct drm_device *dev = encoder->dev; 487 struct drm_device *dev = encoder->dev;
488 struct nouveau_device *device = nouveau_dev(dev); 488 struct nouveau_object *device = nouveau_drm(dev)->device;
489 489
490 /* BIOS scripts usually take care of the backlight, thanks 490 /* BIOS scripts usually take care of the backlight, thanks
491 * Apple for your consistency. 491 * Apple for your consistency.
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.h b/drivers/gpu/drm/nouveau/dispnv04/disp.h
index 4245fc3dab70..99408cf03af0 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.h
@@ -171,8 +171,8 @@ static inline void
171nouveau_bios_run_init_table(struct drm_device *dev, u16 table, 171nouveau_bios_run_init_table(struct drm_device *dev, u16 table,
172 struct dcb_output *outp, int crtc) 172 struct dcb_output *outp, int crtc)
173{ 173{
174 struct nouveau_device *device = nouveau_dev(dev); 174 struct nouveau_drm *drm = nouveau_drm(dev);
175 struct nouveau_bios *bios = nouveau_bios(device); 175 struct nouveau_bios *bios = nouveau_bios(drm->device);
176 struct nvbios_init init = { 176 struct nvbios_init init = {
177 .subdev = nv_subdev(bios), 177 .subdev = nv_subdev(bios),
178 .bios = bios, 178 .bios = bios,
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c
index aca76af115b3..e09c35a948ca 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c
@@ -168,7 +168,7 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
168 struct nouveau_pll_vals *pllvals) 168 struct nouveau_pll_vals *pllvals)
169{ 169{
170 struct nouveau_drm *drm = nouveau_drm(dev); 170 struct nouveau_drm *drm = nouveau_drm(dev);
171 struct nouveau_device *device = nv_device(drm->device); 171 struct nouveau_object *device = drm->device;
172 struct nouveau_bios *bios = nouveau_bios(device); 172 struct nouveau_bios *bios = nouveau_bios(device);
173 uint32_t reg1, pll1, pll2 = 0; 173 uint32_t reg1, pll1, pll2 = 0;
174 struct nvbios_pll pll_lim; 174 struct nvbios_pll pll_lim;
@@ -178,13 +178,13 @@ nouveau_hw_get_pllvals(struct drm_device *dev, enum nvbios_pll_type plltype,
178 if (ret || !(reg1 = pll_lim.reg)) 178 if (ret || !(reg1 = pll_lim.reg))
179 return -ENOENT; 179 return -ENOENT;
180 180
181 pll1 = nv_rd32(device, reg1); 181 pll1 = nvif_rd32(device, reg1);
182 if (reg1 <= 0x405c) 182 if (reg1 <= 0x405c)
183 pll2 = nv_rd32(device, reg1 + 4); 183 pll2 = nvif_rd32(device, reg1 + 4);
184 else if (nv_two_reg_pll(dev)) { 184 else if (nv_two_reg_pll(dev)) {
185 uint32_t reg2 = reg1 + (reg1 == NV_RAMDAC_VPLL2 ? 0x5c : 0x70); 185 uint32_t reg2 = reg1 + (reg1 == NV_RAMDAC_VPLL2 ? 0x5c : 0x70);
186 186
187 pll2 = nv_rd32(device, reg2); 187 pll2 = nvif_rd32(device, reg2);
188 } 188 }
189 189
190 if (nv_device(drm->device)->card_type == 0x40 && reg1 >= NV_PRAMDAC_VPLL_COEFF) { 190 if (nv_device(drm->device)->card_type == 0x40 && reg1 >= NV_PRAMDAC_VPLL_COEFF) {
@@ -255,7 +255,7 @@ nouveau_hw_fix_bad_vpll(struct drm_device *dev, int head)
255 */ 255 */
256 256
257 struct nouveau_drm *drm = nouveau_drm(dev); 257 struct nouveau_drm *drm = nouveau_drm(dev);
258 struct nouveau_device *device = nv_device(drm->device); 258 struct nouveau_object *device = drm->device;
259 struct nouveau_clock *clk = nouveau_clock(device); 259 struct nouveau_clock *clk = nouveau_clock(device);
260 struct nouveau_bios *bios = nouveau_bios(device); 260 struct nouveau_bios *bios = nouveau_bios(device);
261 struct nvbios_pll pll_lim; 261 struct nvbios_pll pll_lim;
@@ -663,7 +663,7 @@ nv_load_state_ext(struct drm_device *dev, int head,
663 struct nv04_mode_state *state) 663 struct nv04_mode_state *state)
664{ 664{
665 struct nouveau_drm *drm = nouveau_drm(dev); 665 struct nouveau_drm *drm = nouveau_drm(dev);
666 struct nouveau_device *device = nv_device(drm->device); 666 struct nouveau_object *device = drm->device;
667 struct nouveau_timer *ptimer = nouveau_timer(device); 667 struct nouveau_timer *ptimer = nouveau_timer(device);
668 struct nouveau_fb *pfb = nouveau_fb(device); 668 struct nouveau_fb *pfb = nouveau_fb(device);
669 struct nv04_crtc_reg *regp = &state->crtc_reg[head]; 669 struct nv04_crtc_reg *regp = &state->crtc_reg[head];
@@ -678,15 +678,15 @@ nv_load_state_ext(struct drm_device *dev, int head,
678 */ 678 */
679 NVWriteCRTC(dev, head, NV_PCRTC_ENGINE_CTRL, regp->crtc_eng_ctrl); 679 NVWriteCRTC(dev, head, NV_PCRTC_ENGINE_CTRL, regp->crtc_eng_ctrl);
680 680
681 nv_wr32(device, NV_PVIDEO_STOP, 1); 681 nvif_wr32(device, NV_PVIDEO_STOP, 1);
682 nv_wr32(device, NV_PVIDEO_INTR_EN, 0); 682 nvif_wr32(device, NV_PVIDEO_INTR_EN, 0);
683 nv_wr32(device, NV_PVIDEO_OFFSET_BUFF(0), 0); 683 nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(0), 0);
684 nv_wr32(device, NV_PVIDEO_OFFSET_BUFF(1), 0); 684 nvif_wr32(device, NV_PVIDEO_OFFSET_BUFF(1), 0);
685 nv_wr32(device, NV_PVIDEO_LIMIT(0), pfb->ram->size - 1); 685 nvif_wr32(device, NV_PVIDEO_LIMIT(0), pfb->ram->size - 1);
686 nv_wr32(device, NV_PVIDEO_LIMIT(1), pfb->ram->size - 1); 686 nvif_wr32(device, NV_PVIDEO_LIMIT(1), pfb->ram->size - 1);
687 nv_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(0), pfb->ram->size - 1); 687 nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(0), pfb->ram->size - 1);
688 nv_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(1), pfb->ram->size - 1); 688 nvif_wr32(device, NV_PVIDEO_UVPLANE_LIMIT(1), pfb->ram->size - 1);
689 nv_wr32(device, NV_PBUS_POWERCTRL_2, 0); 689 nvif_wr32(device, NV_PBUS_POWERCTRL_2, 0);
690 690
691 NVWriteCRTC(dev, head, NV_PCRTC_CURSOR_CONFIG, regp->cursor_cfg); 691 NVWriteCRTC(dev, head, NV_PCRTC_CURSOR_CONFIG, regp->cursor_cfg);
692 NVWriteCRTC(dev, head, NV_PCRTC_830, regp->crtc_830); 692 NVWriteCRTC(dev, head, NV_PCRTC_830, regp->crtc_830);
@@ -769,15 +769,15 @@ static void
769nv_save_state_palette(struct drm_device *dev, int head, 769nv_save_state_palette(struct drm_device *dev, int head,
770 struct nv04_mode_state *state) 770 struct nv04_mode_state *state)
771{ 771{
772 struct nouveau_device *device = nouveau_dev(dev); 772 struct nouveau_object *device = nouveau_drm(dev)->device;
773 int head_offset = head * NV_PRMDIO_SIZE, i; 773 int head_offset = head * NV_PRMDIO_SIZE, i;
774 774
775 nv_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset, 775 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset,
776 NV_PRMDIO_PIXEL_MASK_MASK); 776 NV_PRMDIO_PIXEL_MASK_MASK);
777 nv_wr08(device, NV_PRMDIO_READ_MODE_ADDRESS + head_offset, 0x0); 777 nvif_wr08(device, NV_PRMDIO_READ_MODE_ADDRESS + head_offset, 0x0);
778 778
779 for (i = 0; i < 768; i++) { 779 for (i = 0; i < 768; i++) {
780 state->crtc_reg[head].DAC[i] = nv_rd08(device, 780 state->crtc_reg[head].DAC[i] = nvif_rd08(device,
781 NV_PRMDIO_PALETTE_DATA + head_offset); 781 NV_PRMDIO_PALETTE_DATA + head_offset);
782 } 782 }
783 783
@@ -788,15 +788,15 @@ void
788nouveau_hw_load_state_palette(struct drm_device *dev, int head, 788nouveau_hw_load_state_palette(struct drm_device *dev, int head,
789 struct nv04_mode_state *state) 789 struct nv04_mode_state *state)
790{ 790{
791 struct nouveau_device *device = nouveau_dev(dev); 791 struct nouveau_object *device = nouveau_drm(dev)->device;
792 int head_offset = head * NV_PRMDIO_SIZE, i; 792 int head_offset = head * NV_PRMDIO_SIZE, i;
793 793
794 nv_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset, 794 nvif_wr08(device, NV_PRMDIO_PIXEL_MASK + head_offset,
795 NV_PRMDIO_PIXEL_MASK_MASK); 795 NV_PRMDIO_PIXEL_MASK_MASK);
796 nv_wr08(device, NV_PRMDIO_WRITE_MODE_ADDRESS + head_offset, 0x0); 796 nvif_wr08(device, NV_PRMDIO_WRITE_MODE_ADDRESS + head_offset, 0x0);
797 797
798 for (i = 0; i < 768; i++) { 798 for (i = 0; i < 768; i++) {
799 nv_wr08(device, NV_PRMDIO_PALETTE_DATA + head_offset, 799 nvif_wr08(device, NV_PRMDIO_PALETTE_DATA + head_offset,
800 state->crtc_reg[head].DAC[i]); 800 state->crtc_reg[head].DAC[i]);
801 } 801 }
802 802
diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.h b/drivers/gpu/drm/nouveau/dispnv04/hw.h
index eeb70d912d99..ebaf33dbc1a1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/hw.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/hw.h
@@ -60,41 +60,41 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp,
60static inline uint32_t NVReadCRTC(struct drm_device *dev, 60static inline uint32_t NVReadCRTC(struct drm_device *dev,
61 int head, uint32_t reg) 61 int head, uint32_t reg)
62{ 62{
63 struct nouveau_device *device = nouveau_dev(dev); 63 struct nouveau_object *device = nouveau_drm(dev)->device;
64 uint32_t val; 64 uint32_t val;
65 if (head) 65 if (head)
66 reg += NV_PCRTC0_SIZE; 66 reg += NV_PCRTC0_SIZE;
67 val = nv_rd32(device, reg); 67 val = nvif_rd32(device, reg);
68 return val; 68 return val;
69} 69}
70 70
71static inline void NVWriteCRTC(struct drm_device *dev, 71static inline void NVWriteCRTC(struct drm_device *dev,
72 int head, uint32_t reg, uint32_t val) 72 int head, uint32_t reg, uint32_t val)
73{ 73{
74 struct nouveau_device *device = nouveau_dev(dev); 74 struct nouveau_object *device = nouveau_drm(dev)->device;
75 if (head) 75 if (head)
76 reg += NV_PCRTC0_SIZE; 76 reg += NV_PCRTC0_SIZE;
77 nv_wr32(device, reg, val); 77 nvif_wr32(device, reg, val);
78} 78}
79 79
80static inline uint32_t NVReadRAMDAC(struct drm_device *dev, 80static inline uint32_t NVReadRAMDAC(struct drm_device *dev,
81 int head, uint32_t reg) 81 int head, uint32_t reg)
82{ 82{
83 struct nouveau_device *device = nouveau_dev(dev); 83 struct nouveau_object *device = nouveau_drm(dev)->device;
84 uint32_t val; 84 uint32_t val;
85 if (head) 85 if (head)
86 reg += NV_PRAMDAC0_SIZE; 86 reg += NV_PRAMDAC0_SIZE;
87 val = nv_rd32(device, reg); 87 val = nvif_rd32(device, reg);
88 return val; 88 return val;
89} 89}
90 90
91static inline void NVWriteRAMDAC(struct drm_device *dev, 91static inline void NVWriteRAMDAC(struct drm_device *dev,
92 int head, uint32_t reg, uint32_t val) 92 int head, uint32_t reg, uint32_t val)
93{ 93{
94 struct nouveau_device *device = nouveau_dev(dev); 94 struct nouveau_object *device = nouveau_drm(dev)->device;
95 if (head) 95 if (head)
96 reg += NV_PRAMDAC0_SIZE; 96 reg += NV_PRAMDAC0_SIZE;
97 nv_wr32(device, reg, val); 97 nvif_wr32(device, reg, val);
98} 98}
99 99
100static inline uint8_t nv_read_tmds(struct drm_device *dev, 100static inline uint8_t nv_read_tmds(struct drm_device *dev,
@@ -120,18 +120,18 @@ static inline void nv_write_tmds(struct drm_device *dev,
120static inline void NVWriteVgaCrtc(struct drm_device *dev, 120static inline void NVWriteVgaCrtc(struct drm_device *dev,
121 int head, uint8_t index, uint8_t value) 121 int head, uint8_t index, uint8_t value)
122{ 122{
123 struct nouveau_device *device = nouveau_dev(dev); 123 struct nouveau_object *device = nouveau_drm(dev)->device;
124 nv_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); 124 nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
125 nv_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value); 125 nvif_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value);
126} 126}
127 127
128static inline uint8_t NVReadVgaCrtc(struct drm_device *dev, 128static inline uint8_t NVReadVgaCrtc(struct drm_device *dev,
129 int head, uint8_t index) 129 int head, uint8_t index)
130{ 130{
131 struct nouveau_device *device = nouveau_dev(dev); 131 struct nouveau_object *device = nouveau_drm(dev)->device;
132 uint8_t val; 132 uint8_t val;
133 nv_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); 133 nvif_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index);
134 val = nv_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE); 134 val = nvif_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE);
135 return val; 135 return val;
136} 136}
137 137
@@ -165,7 +165,7 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_
165static inline uint8_t NVReadPRMVIO(struct drm_device *dev, 165static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
166 int head, uint32_t reg) 166 int head, uint32_t reg)
167{ 167{
168 struct nouveau_device *device = nouveau_dev(dev); 168 struct nouveau_object *device = nouveau_drm(dev)->device;
169 struct nouveau_drm *drm = nouveau_drm(dev); 169 struct nouveau_drm *drm = nouveau_drm(dev);
170 uint8_t val; 170 uint8_t val;
171 171
@@ -174,14 +174,14 @@ static inline uint8_t NVReadPRMVIO(struct drm_device *dev,
174 if (head && nv_device(drm->device)->card_type == NV_40) 174 if (head && nv_device(drm->device)->card_type == NV_40)
175 reg += NV_PRMVIO_SIZE; 175 reg += NV_PRMVIO_SIZE;
176 176
177 val = nv_rd08(device, reg); 177 val = nvif_rd08(device, reg);
178 return val; 178 return val;
179} 179}
180 180
181static inline void NVWritePRMVIO(struct drm_device *dev, 181static inline void NVWritePRMVIO(struct drm_device *dev,
182 int head, uint32_t reg, uint8_t value) 182 int head, uint32_t reg, uint8_t value)
183{ 183{
184 struct nouveau_device *device = nouveau_dev(dev); 184 struct nouveau_object *device = nouveau_drm(dev)->device;
185 struct nouveau_drm *drm = nouveau_drm(dev); 185 struct nouveau_drm *drm = nouveau_drm(dev);
186 186
187 /* Only NV4x have two pvio ranges; other twoHeads cards MUST call 187 /* Only NV4x have two pvio ranges; other twoHeads cards MUST call
@@ -189,50 +189,50 @@ static inline void NVWritePRMVIO(struct drm_device *dev,
189 if (head && nv_device(drm->device)->card_type == NV_40) 189 if (head && nv_device(drm->device)->card_type == NV_40)
190 reg += NV_PRMVIO_SIZE; 190 reg += NV_PRMVIO_SIZE;
191 191
192 nv_wr08(device, reg, value); 192 nvif_wr08(device, reg, value);
193} 193}
194 194
195static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable) 195static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable)
196{ 196{
197 struct nouveau_device *device = nouveau_dev(dev); 197 struct nouveau_object *device = nouveau_drm(dev)->device;
198 nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); 198 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
199 nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20); 199 nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20);
200} 200}
201 201
202static inline bool NVGetEnablePalette(struct drm_device *dev, int head) 202static inline bool NVGetEnablePalette(struct drm_device *dev, int head)
203{ 203{
204 struct nouveau_device *device = nouveau_dev(dev); 204 struct nouveau_object *device = nouveau_drm(dev)->device;
205 nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); 205 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
206 return !(nv_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20); 206 return !(nvif_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20);
207} 207}
208 208
209static inline void NVWriteVgaAttr(struct drm_device *dev, 209static inline void NVWriteVgaAttr(struct drm_device *dev,
210 int head, uint8_t index, uint8_t value) 210 int head, uint8_t index, uint8_t value)
211{ 211{
212 struct nouveau_device *device = nouveau_dev(dev); 212 struct nouveau_object *device = nouveau_drm(dev)->device;
213 if (NVGetEnablePalette(dev, head)) 213 if (NVGetEnablePalette(dev, head))
214 index &= ~0x20; 214 index &= ~0x20;
215 else 215 else
216 index |= 0x20; 216 index |= 0x20;
217 217
218 nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); 218 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
219 nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); 219 nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index);
220 nv_wr08(device, NV_PRMCIO_AR__WRITE + head * NV_PRMCIO_SIZE, value); 220 nvif_wr08(device, NV_PRMCIO_AR__WRITE + head * NV_PRMCIO_SIZE, value);
221} 221}
222 222
223static inline uint8_t NVReadVgaAttr(struct drm_device *dev, 223static inline uint8_t NVReadVgaAttr(struct drm_device *dev,
224 int head, uint8_t index) 224 int head, uint8_t index)
225{ 225{
226 struct nouveau_device *device = nouveau_dev(dev); 226 struct nouveau_object *device = nouveau_drm(dev)->device;
227 uint8_t val; 227 uint8_t val;
228 if (NVGetEnablePalette(dev, head)) 228 if (NVGetEnablePalette(dev, head))
229 index &= ~0x20; 229 index &= ~0x20;
230 else 230 else
231 index |= 0x20; 231 index |= 0x20;
232 232
233 nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); 233 nvif_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE);
234 nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); 234 nvif_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index);
235 val = nv_rd08(device, NV_PRMCIO_AR__READ + head * NV_PRMCIO_SIZE); 235 val = nvif_rd08(device, NV_PRMCIO_AR__READ + head * NV_PRMCIO_SIZE);
236 return val; 236 return val;
237} 237}
238 238
@@ -259,11 +259,11 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect)
259static inline bool 259static inline bool
260nv_heads_tied(struct drm_device *dev) 260nv_heads_tied(struct drm_device *dev)
261{ 261{
262 struct nouveau_device *device = nouveau_dev(dev); 262 struct nouveau_object *device = nouveau_drm(dev)->device;
263 struct nouveau_drm *drm = nouveau_drm(dev); 263 struct nouveau_drm *drm = nouveau_drm(dev);
264 264
265 if (nv_device(drm->device)->chipset == 0x11) 265 if (nv_device(drm->device)->chipset == 0x11)
266 return !!(nv_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28)); 266 return !!(nvif_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28));
267 267
268 return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4; 268 return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4;
269} 269}
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index fa69ef011992..bae8068b897f 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -96,7 +96,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
96 uint32_t src_x, uint32_t src_y, 96 uint32_t src_x, uint32_t src_y,
97 uint32_t src_w, uint32_t src_h) 97 uint32_t src_w, uint32_t src_h)
98{ 98{
99 struct nouveau_device *dev = nouveau_dev(plane->dev); 99 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
100 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 100 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
101 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 101 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
102 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 102 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
@@ -117,7 +117,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
117 if (format > 0xffff) 117 if (format > 0xffff)
118 return -ERANGE; 118 return -ERANGE;
119 119
120 if (dev->chipset >= 0x30) { 120 if (nv_device(dev)->chipset >= 0x30) {
121 if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1)) 121 if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1))
122 return -ERANGE; 122 return -ERANGE;
123 } else { 123 } else {
@@ -131,17 +131,17 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
131 131
132 nv_plane->cur = nv_fb->nvbo; 132 nv_plane->cur = nv_fb->nvbo;
133 133
134 nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY); 134 nvif_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY);
135 nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0); 135 nvif_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0);
136 136
137 nv_wr32(dev, NV_PVIDEO_BASE(flip), 0); 137 nvif_wr32(dev, NV_PVIDEO_BASE(flip), 0);
138 nv_wr32(dev, NV_PVIDEO_OFFSET_BUFF(flip), nv_fb->nvbo->bo.offset); 138 nvif_wr32(dev, NV_PVIDEO_OFFSET_BUFF(flip), nv_fb->nvbo->bo.offset);
139 nv_wr32(dev, NV_PVIDEO_SIZE_IN(flip), src_h << 16 | src_w); 139 nvif_wr32(dev, NV_PVIDEO_SIZE_IN(flip), src_h << 16 | src_w);
140 nv_wr32(dev, NV_PVIDEO_POINT_IN(flip), src_y << 16 | src_x); 140 nvif_wr32(dev, NV_PVIDEO_POINT_IN(flip), src_y << 16 | src_x);
141 nv_wr32(dev, NV_PVIDEO_DS_DX(flip), (src_w << 20) / crtc_w); 141 nvif_wr32(dev, NV_PVIDEO_DS_DX(flip), (src_w << 20) / crtc_w);
142 nv_wr32(dev, NV_PVIDEO_DT_DY(flip), (src_h << 20) / crtc_h); 142 nvif_wr32(dev, NV_PVIDEO_DT_DY(flip), (src_h << 20) / crtc_h);
143 nv_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x); 143 nvif_wr32(dev, NV_PVIDEO_POINT_OUT(flip), crtc_y << 16 | crtc_x);
144 nv_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w); 144 nvif_wr32(dev, NV_PVIDEO_SIZE_OUT(flip), crtc_h << 16 | crtc_w);
145 145
146 if (fb->pixel_format != DRM_FORMAT_UYVY) 146 if (fb->pixel_format != DRM_FORMAT_UYVY)
147 format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8; 147 format |= NV_PVIDEO_FORMAT_COLOR_LE_CR8YB8CB8YA8;
@@ -153,14 +153,14 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
153 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; 153 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
154 154
155 if (fb->pixel_format == DRM_FORMAT_NV12) { 155 if (fb->pixel_format == DRM_FORMAT_NV12) {
156 nv_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0); 156 nvif_wr32(dev, NV_PVIDEO_UVPLANE_BASE(flip), 0);
157 nv_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip), 157 nvif_wr32(dev, NV_PVIDEO_UVPLANE_OFFSET_BUFF(flip),
158 nv_fb->nvbo->bo.offset + fb->offsets[1]); 158 nv_fb->nvbo->bo.offset + fb->offsets[1]);
159 } 159 }
160 nv_wr32(dev, NV_PVIDEO_FORMAT(flip), format); 160 nvif_wr32(dev, NV_PVIDEO_FORMAT(flip), format);
161 nv_wr32(dev, NV_PVIDEO_STOP, 0); 161 nvif_wr32(dev, NV_PVIDEO_STOP, 0);
162 /* TODO: wait for vblank? */ 162 /* TODO: wait for vblank? */
163 nv_wr32(dev, NV_PVIDEO_BUFFER, flip ? 0x10 : 0x1); 163 nvif_wr32(dev, NV_PVIDEO_BUFFER, flip ? 0x10 : 0x1);
164 nv_plane->flip = !flip; 164 nv_plane->flip = !flip;
165 165
166 if (cur) 166 if (cur)
@@ -172,10 +172,10 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
172static int 172static int
173nv10_disable_plane(struct drm_plane *plane) 173nv10_disable_plane(struct drm_plane *plane)
174{ 174{
175 struct nouveau_device *dev = nouveau_dev(plane->dev); 175 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
176 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 176 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
177 177
178 nv_wr32(dev, NV_PVIDEO_STOP, 1); 178 nvif_wr32(dev, NV_PVIDEO_STOP, 1);
179 if (nv_plane->cur) { 179 if (nv_plane->cur) {
180 nouveau_bo_unpin(nv_plane->cur); 180 nouveau_bo_unpin(nv_plane->cur);
181 nv_plane->cur = NULL; 181 nv_plane->cur = NULL;
@@ -195,24 +195,24 @@ nv_destroy_plane(struct drm_plane *plane)
195static void 195static void
196nv10_set_params(struct nouveau_plane *plane) 196nv10_set_params(struct nouveau_plane *plane)
197{ 197{
198 struct nouveau_device *dev = nouveau_dev(plane->base.dev); 198 struct nouveau_object *dev = nouveau_drm(plane->base.dev)->device;
199 u32 luma = (plane->brightness - 512) << 16 | plane->contrast; 199 u32 luma = (plane->brightness - 512) << 16 | plane->contrast;
200 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) | 200 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) |
201 (cos_mul(plane->hue, plane->saturation) & 0xffff); 201 (cos_mul(plane->hue, plane->saturation) & 0xffff);
202 u32 format = 0; 202 u32 format = 0;
203 203
204 nv_wr32(dev, NV_PVIDEO_LUMINANCE(0), luma); 204 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(0), luma);
205 nv_wr32(dev, NV_PVIDEO_LUMINANCE(1), luma); 205 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(1), luma);
206 nv_wr32(dev, NV_PVIDEO_CHROMINANCE(0), chroma); 206 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(0), chroma);
207 nv_wr32(dev, NV_PVIDEO_CHROMINANCE(1), chroma); 207 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(1), chroma);
208 nv_wr32(dev, NV_PVIDEO_COLOR_KEY, plane->colorkey & 0xffffff); 208 nvif_wr32(dev, NV_PVIDEO_COLOR_KEY, plane->colorkey & 0xffffff);
209 209
210 if (plane->cur) { 210 if (plane->cur) {
211 if (plane->iturbt_709) 211 if (plane->iturbt_709)
212 format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709; 212 format |= NV_PVIDEO_FORMAT_MATRIX_ITURBT709;
213 if (plane->colorkey & (1 << 24)) 213 if (plane->colorkey & (1 << 24))
214 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY; 214 format |= NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY;
215 nv_mask(dev, NV_PVIDEO_FORMAT(plane->flip), 215 nvif_mask(dev, NV_PVIDEO_FORMAT(plane->flip),
216 NV_PVIDEO_FORMAT_MATRIX_ITURBT709 | 216 NV_PVIDEO_FORMAT_MATRIX_ITURBT709 |
217 NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY, 217 NV_PVIDEO_FORMAT_DISPLAY_COLOR_KEY,
218 format); 218 format);
@@ -343,7 +343,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
343 uint32_t src_x, uint32_t src_y, 343 uint32_t src_x, uint32_t src_y,
344 uint32_t src_w, uint32_t src_h) 344 uint32_t src_w, uint32_t src_h)
345{ 345{
346 struct nouveau_device *dev = nouveau_dev(plane->dev); 346 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
347 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 347 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
348 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 348 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
349 struct nouveau_bo *cur = nv_plane->cur; 349 struct nouveau_bo *cur = nv_plane->cur;
@@ -375,43 +375,43 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
375 375
376 nv_plane->cur = nv_fb->nvbo; 376 nv_plane->cur = nv_fb->nvbo;
377 377
378 nv_wr32(dev, NV_PVIDEO_OE_STATE, 0); 378 nvif_wr32(dev, NV_PVIDEO_OE_STATE, 0);
379 nv_wr32(dev, NV_PVIDEO_SU_STATE, 0); 379 nvif_wr32(dev, NV_PVIDEO_SU_STATE, 0);
380 nv_wr32(dev, NV_PVIDEO_RM_STATE, 0); 380 nvif_wr32(dev, NV_PVIDEO_RM_STATE, 0);
381 381
382 for (i = 0; i < 2; i++) { 382 for (i = 0; i < 2; i++) {
383 nv_wr32(dev, NV_PVIDEO_BUFF0_START_ADDRESS + 4 * i, 383 nvif_wr32(dev, NV_PVIDEO_BUFF0_START_ADDRESS + 4 * i,
384 nv_fb->nvbo->bo.offset); 384 nv_fb->nvbo->bo.offset);
385 nv_wr32(dev, NV_PVIDEO_BUFF0_PITCH_LENGTH + 4 * i, pitch); 385 nvif_wr32(dev, NV_PVIDEO_BUFF0_PITCH_LENGTH + 4 * i, pitch);
386 nv_wr32(dev, NV_PVIDEO_BUFF0_OFFSET + 4 * i, 0); 386 nvif_wr32(dev, NV_PVIDEO_BUFF0_OFFSET + 4 * i, 0);
387 } 387 }
388 nv_wr32(dev, NV_PVIDEO_WINDOW_START, crtc_y << 16 | crtc_x); 388 nvif_wr32(dev, NV_PVIDEO_WINDOW_START, crtc_y << 16 | crtc_x);
389 nv_wr32(dev, NV_PVIDEO_WINDOW_SIZE, crtc_h << 16 | crtc_w); 389 nvif_wr32(dev, NV_PVIDEO_WINDOW_SIZE, crtc_h << 16 | crtc_w);
390 nv_wr32(dev, NV_PVIDEO_STEP_SIZE, 390 nvif_wr32(dev, NV_PVIDEO_STEP_SIZE,
391 (uint32_t)(((src_h - 1) << 11) / (crtc_h - 1)) << 16 | (uint32_t)(((src_w - 1) << 11) / (crtc_w - 1))); 391 (uint32_t)(((src_h - 1) << 11) / (crtc_h - 1)) << 16 | (uint32_t)(((src_w - 1) << 11) / (crtc_w - 1)));
392 392
393 /* It should be possible to convert hue/contrast to this */ 393 /* It should be possible to convert hue/contrast to this */
394 nv_wr32(dev, NV_PVIDEO_RED_CSC_OFFSET, 0x69 - brightness); 394 nvif_wr32(dev, NV_PVIDEO_RED_CSC_OFFSET, 0x69 - brightness);
395 nv_wr32(dev, NV_PVIDEO_GREEN_CSC_OFFSET, 0x3e + brightness); 395 nvif_wr32(dev, NV_PVIDEO_GREEN_CSC_OFFSET, 0x3e + brightness);
396 nv_wr32(dev, NV_PVIDEO_BLUE_CSC_OFFSET, 0x89 - brightness); 396 nvif_wr32(dev, NV_PVIDEO_BLUE_CSC_OFFSET, 0x89 - brightness);
397 nv_wr32(dev, NV_PVIDEO_CSC_ADJUST, 0); 397 nvif_wr32(dev, NV_PVIDEO_CSC_ADJUST, 0);
398 398
399 nv_wr32(dev, NV_PVIDEO_CONTROL_Y, 0x001); /* (BLUR_ON, LINE_HALF) */ 399 nvif_wr32(dev, NV_PVIDEO_CONTROL_Y, 0x001); /* (BLUR_ON, LINE_HALF) */
400 nv_wr32(dev, NV_PVIDEO_CONTROL_X, 0x111); /* (WEIGHT_HEAVY, SHARPENING_ON, SMOOTHING_ON) */ 400 nvif_wr32(dev, NV_PVIDEO_CONTROL_X, 0x111); /* (WEIGHT_HEAVY, SHARPENING_ON, SMOOTHING_ON) */
401 401
402 nv_wr32(dev, NV_PVIDEO_FIFO_BURST_LENGTH, 0x03); 402 nvif_wr32(dev, NV_PVIDEO_FIFO_BURST_LENGTH, 0x03);
403 nv_wr32(dev, NV_PVIDEO_FIFO_THRES_SIZE, 0x38); 403 nvif_wr32(dev, NV_PVIDEO_FIFO_THRES_SIZE, 0x38);
404 404
405 nv_wr32(dev, NV_PVIDEO_KEY, nv_plane->colorkey); 405 nvif_wr32(dev, NV_PVIDEO_KEY, nv_plane->colorkey);
406 406
407 if (nv_plane->colorkey & (1 << 24)) 407 if (nv_plane->colorkey & (1 << 24))
408 overlay |= 0x10; 408 overlay |= 0x10;
409 if (fb->pixel_format == DRM_FORMAT_YUYV) 409 if (fb->pixel_format == DRM_FORMAT_YUYV)
410 overlay |= 0x100; 410 overlay |= 0x100;
411 411
412 nv_wr32(dev, NV_PVIDEO_OVERLAY, overlay); 412 nvif_wr32(dev, NV_PVIDEO_OVERLAY, overlay);
413 413
414 nv_wr32(dev, NV_PVIDEO_SU_STATE, nv_rd32(dev, NV_PVIDEO_SU_STATE) ^ (1 << 16)); 414 nvif_wr32(dev, NV_PVIDEO_SU_STATE, nvif_rd32(dev, NV_PVIDEO_SU_STATE) ^ (1 << 16));
415 415
416 if (cur) 416 if (cur)
417 nouveau_bo_unpin(cur); 417 nouveau_bo_unpin(cur);
@@ -422,13 +422,13 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
422static int 422static int
423nv04_disable_plane(struct drm_plane *plane) 423nv04_disable_plane(struct drm_plane *plane)
424{ 424{
425 struct nouveau_device *dev = nouveau_dev(plane->dev); 425 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
426 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane; 426 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
427 427
428 nv_mask(dev, NV_PVIDEO_OVERLAY, 1, 0); 428 nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0);
429 nv_wr32(dev, NV_PVIDEO_OE_STATE, 0); 429 nvif_wr32(dev, NV_PVIDEO_OE_STATE, 0);
430 nv_wr32(dev, NV_PVIDEO_SU_STATE, 0); 430 nvif_wr32(dev, NV_PVIDEO_SU_STATE, 0);
431 nv_wr32(dev, NV_PVIDEO_RM_STATE, 0); 431 nvif_wr32(dev, NV_PVIDEO_RM_STATE, 0);
432 if (nv_plane->cur) { 432 if (nv_plane->cur) {
433 nouveau_bo_unpin(nv_plane->cur); 433 nouveau_bo_unpin(nv_plane->cur);
434 nv_plane->cur = NULL; 434 nv_plane->cur = NULL;
@@ -489,9 +489,9 @@ err:
489void 489void
490nouveau_overlay_init(struct drm_device *device) 490nouveau_overlay_init(struct drm_device *device)
491{ 491{
492 struct nouveau_device *dev = nouveau_dev(device); 492 struct nouveau_object *dev = nouveau_drm(device)->device;
493 if (dev->chipset < 0x10) 493 if (nv_device(dev)->chipset < 0x10)
494 nv04_overlay_init(device); 494 nv04_overlay_init(device);
495 else if (dev->chipset <= 0x40) 495 else if (nv_device(dev)->chipset <= 0x40)
496 nv10_overlay_init(device); 496 nv10_overlay_init(device);
497} 497}
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
index 7b331543a41b..ce40e398f895 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.h
@@ -130,14 +130,14 @@ void nv17_ctv_update_rescaler(struct drm_encoder *encoder);
130static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg, 130static inline void nv_write_ptv(struct drm_device *dev, uint32_t reg,
131 uint32_t val) 131 uint32_t val)
132{ 132{
133 struct nouveau_device *device = nouveau_dev(dev); 133 struct nouveau_object *device = nouveau_drm(dev)->device;
134 nv_wr32(device, reg, val); 134 nvif_wr32(device, reg, val);
135} 135}
136 136
137static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg) 137static inline uint32_t nv_read_ptv(struct drm_device *dev, uint32_t reg)
138{ 138{
139 struct nouveau_device *device = nouveau_dev(dev); 139 struct nouveau_object *device = nouveau_drm(dev)->device;
140 return nv_rd32(device, reg); 140 return nvif_rd32(device, reg);
141} 141}
142 142
143static inline void nv_write_tv_enc(struct drm_device *dev, uint8_t reg, 143static inline void nv_write_tv_enc(struct drm_device *dev, uint8_t reg,
diff --git a/drivers/gpu/drm/nouveau/nouveau_agp.c b/drivers/gpu/drm/nouveau/nouveau_agp.c
index bf6f7fb1b5a2..1f56becbbf36 100644
--- a/drivers/gpu/drm/nouveau/nouveau_agp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_agp.c
@@ -104,7 +104,7 @@ void
104nouveau_agp_reset(struct nouveau_drm *drm) 104nouveau_agp_reset(struct nouveau_drm *drm)
105{ 105{
106#if __OS_HAS_AGP 106#if __OS_HAS_AGP
107 struct nouveau_device *device = nv_device(drm->device); 107 struct nouveau_object *device = drm->device;
108 struct drm_device *dev = drm->dev; 108 struct drm_device *dev = drm->dev;
109 u32 save[2]; 109 u32 save[2];
110 int ret; 110 int ret;
@@ -115,7 +115,7 @@ nouveau_agp_reset(struct nouveau_drm *drm)
115 /* First of all, disable fast writes, otherwise if it's 115 /* First of all, disable fast writes, otherwise if it's
116 * already enabled in the AGP bridge and we disable the card's 116 * already enabled in the AGP bridge and we disable the card's
117 * AGP controller we might be locking ourselves out of it. */ 117 * AGP controller we might be locking ourselves out of it. */
118 if ((nv_rd32(device, NV04_PBUS_PCI_NV_19) | 118 if ((nvif_rd32(device, NV04_PBUS_PCI_NV_19) |
119 dev->agp->mode) & PCI_AGP_COMMAND_FW) { 119 dev->agp->mode) & PCI_AGP_COMMAND_FW) {
120 struct drm_agp_info info; 120 struct drm_agp_info info;
121 struct drm_agp_mode mode; 121 struct drm_agp_mode mode;
@@ -134,15 +134,15 @@ nouveau_agp_reset(struct nouveau_drm *drm)
134 134
135 135
136 /* clear busmaster bit, and disable AGP */ 136 /* clear busmaster bit, and disable AGP */
137 save[0] = nv_mask(device, NV04_PBUS_PCI_NV_1, 0x00000004, 0x00000000); 137 save[0] = nvif_mask(device, NV04_PBUS_PCI_NV_1, 0x00000004, 0x00000000);
138 nv_wr32(device, NV04_PBUS_PCI_NV_19, 0); 138 nvif_wr32(device, NV04_PBUS_PCI_NV_19, 0);
139 139
140 /* reset PGRAPH, PFIFO and PTIMER */ 140 /* reset PGRAPH, PFIFO and PTIMER */
141 save[1] = nv_mask(device, 0x000200, 0x00011100, 0x00000000); 141 save[1] = nvif_mask(device, 0x000200, 0x00011100, 0x00000000);
142 nv_mask(device, 0x000200, 0x00011100, save[1]); 142 nvif_mask(device, 0x000200, 0x00011100, save[1]);
143 143
144 /* and restore bustmaster bit (gives effect of resetting AGP) */ 144 /* and restore bustmaster bit (gives effect of resetting AGP) */
145 nv_wr32(device, NV04_PBUS_PCI_NV_1, save[0]); 145 nvif_wr32(device, NV04_PBUS_PCI_NV_1, save[0]);
146#endif 146#endif
147} 147}
148 148
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 3986d198eff3..dd2accd69f65 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -40,8 +40,8 @@ static int
40nv40_get_intensity(struct backlight_device *bd) 40nv40_get_intensity(struct backlight_device *bd)
41{ 41{
42 struct nouveau_drm *drm = bl_get_data(bd); 42 struct nouveau_drm *drm = bl_get_data(bd);
43 struct nouveau_device *device = nv_device(drm->device); 43 struct nouveau_object *device = drm->device;
44 int val = (nv_rd32(device, NV40_PMC_BACKLIGHT) & 44 int val = (nvif_rd32(device, NV40_PMC_BACKLIGHT) &
45 NV40_PMC_BACKLIGHT_MASK) >> 16; 45 NV40_PMC_BACKLIGHT_MASK) >> 16;
46 46
47 return val; 47 return val;
@@ -51,11 +51,11 @@ static int
51nv40_set_intensity(struct backlight_device *bd) 51nv40_set_intensity(struct backlight_device *bd)
52{ 52{
53 struct nouveau_drm *drm = bl_get_data(bd); 53 struct nouveau_drm *drm = bl_get_data(bd);
54 struct nouveau_device *device = nv_device(drm->device); 54 struct nouveau_object *device = drm->device;
55 int val = bd->props.brightness; 55 int val = bd->props.brightness;
56 int reg = nv_rd32(device, NV40_PMC_BACKLIGHT); 56 int reg = nvif_rd32(device, NV40_PMC_BACKLIGHT);
57 57
58 nv_wr32(device, NV40_PMC_BACKLIGHT, 58 nvif_wr32(device, NV40_PMC_BACKLIGHT,
59 (val << 16) | (reg & ~NV40_PMC_BACKLIGHT_MASK)); 59 (val << 16) | (reg & ~NV40_PMC_BACKLIGHT_MASK));
60 60
61 return 0; 61 return 0;
@@ -71,11 +71,11 @@ static int
71nv40_backlight_init(struct drm_connector *connector) 71nv40_backlight_init(struct drm_connector *connector)
72{ 72{
73 struct nouveau_drm *drm = nouveau_drm(connector->dev); 73 struct nouveau_drm *drm = nouveau_drm(connector->dev);
74 struct nouveau_device *device = nv_device(drm->device); 74 struct nouveau_object *device = drm->device;
75 struct backlight_properties props; 75 struct backlight_properties props;
76 struct backlight_device *bd; 76 struct backlight_device *bd;
77 77
78 if (!(nv_rd32(device, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK)) 78 if (!(nvif_rd32(device, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
79 return 0; 79 return 0;
80 80
81 memset(&props, 0, sizeof(struct backlight_properties)); 81 memset(&props, 0, sizeof(struct backlight_properties));
@@ -97,12 +97,12 @@ nv50_get_intensity(struct backlight_device *bd)
97{ 97{
98 struct nouveau_encoder *nv_encoder = bl_get_data(bd); 98 struct nouveau_encoder *nv_encoder = bl_get_data(bd);
99 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); 99 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
100 struct nouveau_device *device = nv_device(drm->device); 100 struct nouveau_object *device = drm->device;
101 int or = nv_encoder->or; 101 int or = nv_encoder->or;
102 u32 div = 1025; 102 u32 div = 1025;
103 u32 val; 103 u32 val;
104 104
105 val = nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(or)); 105 val = nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(or));
106 val &= NV50_PDISP_SOR_PWM_CTL_VAL; 106 val &= NV50_PDISP_SOR_PWM_CTL_VAL;
107 return ((val * 100) + (div / 2)) / div; 107 return ((val * 100) + (div / 2)) / div;
108} 108}
@@ -112,12 +112,12 @@ nv50_set_intensity(struct backlight_device *bd)
112{ 112{
113 struct nouveau_encoder *nv_encoder = bl_get_data(bd); 113 struct nouveau_encoder *nv_encoder = bl_get_data(bd);
114 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); 114 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
115 struct nouveau_device *device = nv_device(drm->device); 115 struct nouveau_object *device = drm->device;
116 int or = nv_encoder->or; 116 int or = nv_encoder->or;
117 u32 div = 1025; 117 u32 div = 1025;
118 u32 val = (bd->props.brightness * div) / 100; 118 u32 val = (bd->props.brightness * div) / 100;
119 119
120 nv_wr32(device, NV50_PDISP_SOR_PWM_CTL(or), 120 nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or),
121 NV50_PDISP_SOR_PWM_CTL_NEW | val); 121 NV50_PDISP_SOR_PWM_CTL_NEW | val);
122 return 0; 122 return 0;
123} 123}
@@ -133,12 +133,12 @@ nva3_get_intensity(struct backlight_device *bd)
133{ 133{
134 struct nouveau_encoder *nv_encoder = bl_get_data(bd); 134 struct nouveau_encoder *nv_encoder = bl_get_data(bd);
135 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); 135 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
136 struct nouveau_device *device = nv_device(drm->device); 136 struct nouveau_object *device = drm->device;
137 int or = nv_encoder->or; 137 int or = nv_encoder->or;
138 u32 div, val; 138 u32 div, val;
139 139
140 div = nv_rd32(device, NV50_PDISP_SOR_PWM_DIV(or)); 140 div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
141 val = nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(or)); 141 val = nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(or));
142 val &= NVA3_PDISP_SOR_PWM_CTL_VAL; 142 val &= NVA3_PDISP_SOR_PWM_CTL_VAL;
143 if (div && div >= val) 143 if (div && div >= val)
144 return ((val * 100) + (div / 2)) / div; 144 return ((val * 100) + (div / 2)) / div;
@@ -151,14 +151,14 @@ nva3_set_intensity(struct backlight_device *bd)
151{ 151{
152 struct nouveau_encoder *nv_encoder = bl_get_data(bd); 152 struct nouveau_encoder *nv_encoder = bl_get_data(bd);
153 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); 153 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
154 struct nouveau_device *device = nv_device(drm->device); 154 struct nouveau_object *device = drm->device;
155 int or = nv_encoder->or; 155 int or = nv_encoder->or;
156 u32 div, val; 156 u32 div, val;
157 157
158 div = nv_rd32(device, NV50_PDISP_SOR_PWM_DIV(or)); 158 div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
159 val = (bd->props.brightness * div) / 100; 159 val = (bd->props.brightness * div) / 100;
160 if (div) { 160 if (div) {
161 nv_wr32(device, NV50_PDISP_SOR_PWM_CTL(or), val | 161 nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or), val |
162 NV50_PDISP_SOR_PWM_CTL_NEW | 162 NV50_PDISP_SOR_PWM_CTL_NEW |
163 NVA3_PDISP_SOR_PWM_CTL_UNK); 163 NVA3_PDISP_SOR_PWM_CTL_UNK);
164 return 0; 164 return 0;
@@ -177,7 +177,7 @@ static int
177nv50_backlight_init(struct drm_connector *connector) 177nv50_backlight_init(struct drm_connector *connector)
178{ 178{
179 struct nouveau_drm *drm = nouveau_drm(connector->dev); 179 struct nouveau_drm *drm = nouveau_drm(connector->dev);
180 struct nouveau_device *device = nv_device(drm->device); 180 struct nouveau_object *device = drm->device;
181 struct nouveau_encoder *nv_encoder; 181 struct nouveau_encoder *nv_encoder;
182 struct backlight_properties props; 182 struct backlight_properties props;
183 struct backlight_device *bd; 183 struct backlight_device *bd;
@@ -190,12 +190,12 @@ nv50_backlight_init(struct drm_connector *connector)
190 return -ENODEV; 190 return -ENODEV;
191 } 191 }
192 192
193 if (!nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or))) 193 if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or)))
194 return 0; 194 return 0;
195 195
196 if (device->chipset <= 0xa0 || 196 if (nv_device(device)->chipset <= 0xa0 ||
197 device->chipset == 0xaa || 197 nv_device(device)->chipset == 0xaa ||
198 device->chipset == 0xac) 198 nv_device(device)->chipset == 0xac)
199 ops = &nv50_bl_ops; 199 ops = &nv50_bl_ops;
200 else 200 else
201 ops = &nva3_bl_ops; 201 ops = &nva3_bl_ops;
@@ -218,7 +218,7 @@ int
218nouveau_backlight_init(struct drm_device *dev) 218nouveau_backlight_init(struct drm_device *dev)
219{ 219{
220 struct nouveau_drm *drm = nouveau_drm(dev); 220 struct nouveau_drm *drm = nouveau_drm(dev);
221 struct nouveau_device *device = nv_device(drm->device); 221 struct nouveau_object *device = drm->device;
222 struct drm_connector *connector; 222 struct drm_connector *connector;
223 223
224 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 224 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
@@ -226,7 +226,7 @@ nouveau_backlight_init(struct drm_device *dev)
226 connector->connector_type != DRM_MODE_CONNECTOR_eDP) 226 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
227 continue; 227 continue;
228 228
229 switch (device->card_type) { 229 switch (nv_device(device)->card_type) {
230 case NV_40: 230 case NV_40:
231 return nv40_backlight_init(connector); 231 return nv40_backlight_init(connector);
232 case NV_50: 232 case NV_50:
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 8268a4ccac15..676a03fc0b51 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -217,7 +217,7 @@ int call_lvds_script(struct drm_device *dev, struct dcb_output *dcbent, int head
217 */ 217 */
218 218
219 struct nouveau_drm *drm = nouveau_drm(dev); 219 struct nouveau_drm *drm = nouveau_drm(dev);
220 struct nouveau_device *device = nv_device(drm->device); 220 struct nouveau_object *device = drm->device;
221 struct nvbios *bios = &drm->vbios; 221 struct nvbios *bios = &drm->vbios;
222 uint8_t lvds_ver = bios->data[bios->fp.lvdsmanufacturerpointer]; 222 uint8_t lvds_ver = bios->data[bios->fp.lvdsmanufacturerpointer];
223 uint32_t sel_clk_binding, sel_clk; 223 uint32_t sel_clk_binding, sel_clk;
@@ -240,7 +240,7 @@ int call_lvds_script(struct drm_device *dev, struct dcb_output *dcbent, int head
240 NV_INFO(drm, "Calling LVDS script %d:\n", script); 240 NV_INFO(drm, "Calling LVDS script %d:\n", script);
241 241
242 /* don't let script change pll->head binding */ 242 /* don't let script change pll->head binding */
243 sel_clk_binding = nv_rd32(device, NV_PRAMDAC_SEL_CLK) & 0x50000; 243 sel_clk_binding = nvif_rd32(device, NV_PRAMDAC_SEL_CLK) & 0x50000;
244 244
245 if (lvds_ver < 0x30) 245 if (lvds_ver < 0x30)
246 ret = call_lvds_manufacturer_script(dev, dcbent, head, script); 246 ret = call_lvds_manufacturer_script(dev, dcbent, head, script);
@@ -252,7 +252,7 @@ int call_lvds_script(struct drm_device *dev, struct dcb_output *dcbent, int head
252 sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK) & ~0x50000; 252 sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK) & ~0x50000;
253 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, sel_clk | sel_clk_binding); 253 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, sel_clk | sel_clk_binding);
254 /* some scripts set a value in NV_PBUS_POWERCTRL_2 and break video overlay */ 254 /* some scripts set a value in NV_PBUS_POWERCTRL_2 and break video overlay */
255 nv_wr32(device, NV_PBUS_POWERCTRL_2, 0); 255 nvif_wr32(device, NV_PBUS_POWERCTRL_2, 0);
256 256
257 return ret; 257 return ret;
258} 258}
@@ -320,7 +320,7 @@ static int parse_lvds_manufacturer_table_header(struct drm_device *dev, struct n
320static int 320static int
321get_fp_strap(struct drm_device *dev, struct nvbios *bios) 321get_fp_strap(struct drm_device *dev, struct nvbios *bios)
322{ 322{
323 struct nouveau_device *device = nouveau_dev(dev); 323 struct nouveau_object *device = nouveau_drm(dev)->device;
324 324
325 /* 325 /*
326 * The fp strap is normally dictated by the "User Strap" in 326 * The fp strap is normally dictated by the "User Strap" in
@@ -334,10 +334,10 @@ get_fp_strap(struct drm_device *dev, struct nvbios *bios)
334 if (bios->major_version < 5 && bios->data[0x48] & 0x4) 334 if (bios->major_version < 5 && bios->data[0x48] & 0x4)
335 return NVReadVgaCrtc5758(dev, 0, 0xf) & 0xf; 335 return NVReadVgaCrtc5758(dev, 0, 0xf) & 0xf;
336 336
337 if (device->card_type >= NV_50) 337 if (nv_device(device)->card_type >= NV_50)
338 return (nv_rd32(device, NV_PEXTDEV_BOOT_0) >> 24) & 0xf; 338 return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 24) & 0xf;
339 else 339 else
340 return (nv_rd32(device, NV_PEXTDEV_BOOT_0) >> 16) & 0xf; 340 return (nvif_rd32(device, NV_PEXTDEV_BOOT_0) >> 16) & 0xf;
341} 341}
342 342
343static int parse_fp_mode_table(struct drm_device *dev, struct nvbios *bios) 343static int parse_fp_mode_table(struct drm_device *dev, struct nvbios *bios)
@@ -636,7 +636,7 @@ int run_tmds_table(struct drm_device *dev, struct dcb_output *dcbent, int head,
636 */ 636 */
637 637
638 struct nouveau_drm *drm = nouveau_drm(dev); 638 struct nouveau_drm *drm = nouveau_drm(dev);
639 struct nouveau_device *device = nv_device(drm->device); 639 struct nouveau_object *device = drm->device;
640 struct nvbios *bios = &drm->vbios; 640 struct nvbios *bios = &drm->vbios;
641 int cv = bios->chip_version; 641 int cv = bios->chip_version;
642 uint16_t clktable = 0, scriptptr; 642 uint16_t clktable = 0, scriptptr;
@@ -670,7 +670,7 @@ int run_tmds_table(struct drm_device *dev, struct dcb_output *dcbent, int head,
670 } 670 }
671 671
672 /* don't let script change pll->head binding */ 672 /* don't let script change pll->head binding */
673 sel_clk_binding = nv_rd32(device, NV_PRAMDAC_SEL_CLK) & 0x50000; 673 sel_clk_binding = nvif_rd32(device, NV_PRAMDAC_SEL_CLK) & 0x50000;
674 run_digital_op_script(dev, scriptptr, dcbent, head, pxclk >= 165000); 674 run_digital_op_script(dev, scriptptr, dcbent, head, pxclk >= 165000);
675 sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK) & ~0x50000; 675 sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK) & ~0x50000;
676 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, sel_clk | sel_clk_binding); 676 NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, sel_clk | sel_clk_binding);
@@ -1908,7 +1908,7 @@ static int load_nv17_hwsq_ucode_entry(struct drm_device *dev, struct nvbios *bio
1908 */ 1908 */
1909 1909
1910 struct nouveau_drm *drm = nouveau_drm(dev); 1910 struct nouveau_drm *drm = nouveau_drm(dev);
1911 struct nouveau_device *device = nv_device(drm->device); 1911 struct nouveau_object *device = drm->device;
1912 uint8_t bytes_to_write; 1912 uint8_t bytes_to_write;
1913 uint16_t hwsq_entry_offset; 1913 uint16_t hwsq_entry_offset;
1914 int i; 1914 int i;
@@ -1931,15 +1931,15 @@ static int load_nv17_hwsq_ucode_entry(struct drm_device *dev, struct nvbios *bio
1931 hwsq_entry_offset = hwsq_offset + 2 + entry * bytes_to_write; 1931 hwsq_entry_offset = hwsq_offset + 2 + entry * bytes_to_write;
1932 1932
1933 /* set sequencer control */ 1933 /* set sequencer control */
1934 nv_wr32(device, 0x00001304, ROM32(bios->data[hwsq_entry_offset])); 1934 nvif_wr32(device, 0x00001304, ROM32(bios->data[hwsq_entry_offset]));
1935 bytes_to_write -= 4; 1935 bytes_to_write -= 4;
1936 1936
1937 /* write ucode */ 1937 /* write ucode */
1938 for (i = 0; i < bytes_to_write; i += 4) 1938 for (i = 0; i < bytes_to_write; i += 4)
1939 nv_wr32(device, 0x00001400 + i, ROM32(bios->data[hwsq_entry_offset + i + 4])); 1939 nvif_wr32(device, 0x00001400 + i, ROM32(bios->data[hwsq_entry_offset + i + 4]));
1940 1940
1941 /* twiddle NV_PBUS_DEBUG_4 */ 1941 /* twiddle NV_PBUS_DEBUG_4 */
1942 nv_wr32(device, NV_PBUS_DEBUG_4, nv_rd32(device, NV_PBUS_DEBUG_4) | 0x18); 1942 nvif_wr32(device, NV_PBUS_DEBUG_4, nvif_rd32(device, NV_PBUS_DEBUG_4) | 0x18);
1943 1943
1944 return 0; 1944 return 0;
1945} 1945}
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 51db52f10ad1..cfece9d603d9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1262,7 +1262,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
1262 /* fallthrough, tiled memory */ 1262 /* fallthrough, tiled memory */
1263 case TTM_PL_VRAM: 1263 case TTM_PL_VRAM:
1264 mem->bus.offset = mem->start << PAGE_SHIFT; 1264 mem->bus.offset = mem->start << PAGE_SHIFT;
1265 mem->bus.base = nv_device_resource_start(nouveau_dev(dev), 1); 1265 mem->bus.base = nv_device_resource_start(nv_device(drm->device), 1);
1266 mem->bus.is_iomem = true; 1266 mem->bus.is_iomem = true;
1267 if (nv_device(drm->device)->card_type >= NV_50) { 1267 if (nv_device(drm->device)->card_type >= NV_50) {
1268 struct nouveau_bar *bar = nouveau_bar(drm->device); 1268 struct nouveau_bar *bar = nouveau_bar(drm->device);
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 6e9892c9f811..eebcdd36ff46 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -433,7 +433,6 @@ int
433nouveau_display_create(struct drm_device *dev) 433nouveau_display_create(struct drm_device *dev)
434{ 434{
435 struct nouveau_drm *drm = nouveau_drm(dev); 435 struct nouveau_drm *drm = nouveau_drm(dev);
436 struct nouveau_device *device = nouveau_dev(dev);
437 struct nouveau_display *disp; 436 struct nouveau_display *disp;
438 int ret; 437 int ret;
439 438
@@ -446,7 +445,7 @@ nouveau_display_create(struct drm_device *dev)
446 drm_mode_create_dvi_i_properties(dev); 445 drm_mode_create_dvi_i_properties(dev);
447 446
448 dev->mode_config.funcs = &nouveau_mode_config_funcs; 447 dev->mode_config.funcs = &nouveau_mode_config_funcs;
449 dev->mode_config.fb_base = nv_device_resource_start(device, 1); 448 dev->mode_config.fb_base = nv_device_resource_start(nv_device(drm->device), 1);
450 449
451 dev->mode_config.min_width = 0; 450 dev->mode_config.min_width = 0;
452 dev->mode_config.min_height = 0; 451 dev->mode_config.min_height = 0;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index fe99765d9fa0..7c758b2f8d0e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -348,7 +348,6 @@ static int
348nouveau_drm_load(struct drm_device *dev, unsigned long flags) 348nouveau_drm_load(struct drm_device *dev, unsigned long flags)
349{ 349{
350 struct pci_dev *pdev = dev->pdev; 350 struct pci_dev *pdev = dev->pdev;
351 struct nouveau_device *device;
352 struct nouveau_drm *drm; 351 struct nouveau_drm *drm;
353 int ret; 352 int ret;
354 353
@@ -406,14 +405,13 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
406 * nosnoop capability. hopefully won't cause issues until a 405 * nosnoop capability. hopefully won't cause issues until a
407 * better fix is found - assuming there is one... 406 * better fix is found - assuming there is one...
408 */ 407 */
409 device = nv_device(drm->device);
410 if (nv_device(drm->device)->chipset == 0xc1) 408 if (nv_device(drm->device)->chipset == 0xc1)
411 nv_mask(device, 0x00088080, 0x00000800, 0x00000000); 409 nvif_mask(drm->device, 0x00088080, 0x00000800, 0x00000000);
412 410
413 nouveau_vga_init(drm); 411 nouveau_vga_init(drm);
414 nouveau_agp_init(drm); 412 nouveau_agp_init(drm);
415 413
416 if (device->card_type >= NV_50) { 414 if (nv_device(drm->device)->card_type >= NV_50) {
417 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40), 415 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40),
418 0x1000, &drm->client.vm); 416 0x1000, &drm->client.vm);
419 if (ret) 417 if (ret)
@@ -932,7 +930,7 @@ static int nouveau_pmops_runtime_resume(struct device *dev)
932{ 930{
933 struct pci_dev *pdev = to_pci_dev(dev); 931 struct pci_dev *pdev = to_pci_dev(dev);
934 struct drm_device *drm_dev = pci_get_drvdata(pdev); 932 struct drm_device *drm_dev = pci_get_drvdata(pdev);
935 struct nouveau_device *device = nouveau_dev(drm_dev); 933 struct nouveau_object *device = nouveau_drm(drm_dev)->device;
936 int ret; 934 int ret;
937 935
938 if (nouveau_runtime_pm == 0) 936 if (nouveau_runtime_pm == 0)
@@ -948,7 +946,7 @@ static int nouveau_pmops_runtime_resume(struct device *dev)
948 ret = nouveau_do_resume(drm_dev); 946 ret = nouveau_do_resume(drm_dev);
949 drm_kms_helper_poll_enable(drm_dev); 947 drm_kms_helper_poll_enable(drm_dev);
950 /* do magic */ 948 /* do magic */
951 nv_mask(device, 0x88488, (1 << 25), (1 << 25)); 949 nvif_mask(device, 0x88488, (1 << 25), (1 << 25));
952 vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON); 950 vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
953 drm_dev->switch_power_state = DRM_SWITCH_POWER_ON; 951 drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
954 nv_debug_level(NORMAL); 952 nv_debug_level(NORMAL);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
index de8055220266..e4f0196fc406 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
@@ -77,6 +77,22 @@ nouveau_cli(struct drm_file *fpriv)
77 return fpriv ? fpriv->driver_priv : NULL; 77 return fpriv ? fpriv->driver_priv : NULL;
78} 78}
79 79
80#define nvif_object(a) ({ \
81 struct nouveau_object *_object = (a); \
82 _object; \
83})
84#define nvif_rd08(a,b) nv_ro08(nvif_object(a), (b))
85#define nvif_rd16(a,b) nv_ro16(nvif_object(a), (b))
86#define nvif_rd32(a,b) nv_ro32(nvif_object(a), (b))
87#define nvif_wr08(a,b,c) nv_wo08(nvif_object(a), (b), (c))
88#define nvif_wr16(a,b,c) nv_wo16(nvif_object(a), (b), (c))
89#define nvif_wr32(a,b,c) nv_wo32(nvif_object(a), (b), (c))
90#define nvif_mask(a,b,c,d) nv_mo32(nvif_object(a), (b), (c), (d))
91
92/*XXX*/
93#include <core/object.h>
94#define nvkm_object(a) nvif_object(a)
95
80extern int nouveau_runtime_pm; 96extern int nouveau_runtime_pm;
81 97
82struct nouveau_drm { 98struct nouveau_drm {
@@ -152,12 +168,6 @@ nouveau_drm(struct drm_device *dev)
152 return dev->dev_private; 168 return dev->dev_private;
153} 169}
154 170
155static inline struct nouveau_device *
156nouveau_dev(struct drm_device *dev)
157{
158 return nv_device(nouveau_drm(dev)->device);
159}
160
161int nouveau_pmops_suspend(struct device *); 171int nouveau_pmops_suspend(struct device *);
162int nouveau_pmops_resume(struct device *); 172int nouveau_pmops_resume(struct device *);
163 173
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 4f4c3fec6916..0f0bafb4fe02 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -12,14 +12,16 @@
12static unsigned int 12static unsigned int
13nouveau_vga_set_decode(void *priv, bool state) 13nouveau_vga_set_decode(void *priv, bool state)
14{ 14{
15 struct nouveau_device *device = nouveau_dev(priv); 15 struct nouveau_object *device = nouveau_drm(priv)->device;
16 16
17 if (device->card_type == NV_40 && device->chipset >= 0x4c) 17 if (nv_device(device)->card_type == NV_40 &&
18 nv_wr32(device, 0x088060, state); 18 nv_device(device)->chipset >= 0x4c)
19 else if (device->chipset >= 0x40) 19 nvif_wr32(device, 0x088060, state);
20 nv_wr32(device, 0x088054, state);
21 else 20 else
22 nv_wr32(device, 0x001854, state); 21 if (nv_device(device)->chipset >= 0x40)
22 nvif_wr32(device, 0x088054, state);
23 else
24 nvif_wr32(device, 0x001854, state);
23 25
24 if (state) 26 if (state)
25 return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM | 27 return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 03152add9baa..165ad49d3f31 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -317,7 +317,7 @@ evo_sync_wait(void *data)
317static int 317static int
318evo_sync(struct drm_device *dev) 318evo_sync(struct drm_device *dev)
319{ 319{
320 struct nouveau_device *device = nouveau_dev(dev); 320 struct nouveau_object *device = nouveau_drm(dev)->device;
321 struct nv50_disp *disp = nv50_disp(dev); 321 struct nv50_disp *disp = nv50_disp(dev);
322 struct nv50_mast *mast = nv50_mast(dev); 322 struct nv50_mast *mast = nv50_mast(dev);
323 u32 *push = evo_wait(mast, 8); 323 u32 *push = evo_wait(mast, 8);
@@ -329,7 +329,7 @@ evo_sync(struct drm_device *dev)
329 evo_data(push, 0x00000000); 329 evo_data(push, 0x00000000);
330 evo_data(push, 0x00000000); 330 evo_data(push, 0x00000000);
331 evo_kick(push, mast); 331 evo_kick(push, mast);
332 if (nv_wait_cb(device, evo_sync_wait, disp->sync)) 332 if (nv_wait_cb(nv_device(device), evo_sync_wait, disp->sync))
333 return 0; 333 return 0;
334 } 334 }
335 335
@@ -364,7 +364,7 @@ nv50_display_flip_wait(void *data)
364void 364void
365nv50_display_flip_stop(struct drm_crtc *crtc) 365nv50_display_flip_stop(struct drm_crtc *crtc)
366{ 366{
367 struct nouveau_device *device = nouveau_dev(crtc->dev); 367 struct nouveau_object *device = nouveau_drm(crtc->dev)->device;
368 struct nv50_display_flip flip = { 368 struct nv50_display_flip flip = {
369 .disp = nv50_disp(crtc->dev), 369 .disp = nv50_disp(crtc->dev),
370 .chan = nv50_sync(crtc), 370 .chan = nv50_sync(crtc),
@@ -384,7 +384,7 @@ nv50_display_flip_stop(struct drm_crtc *crtc)
384 evo_kick(push, flip.chan); 384 evo_kick(push, flip.chan);
385 } 385 }
386 386
387 nv_wait_cb(device, nv50_display_flip_wait, &flip); 387 nv_wait_cb(nv_device(device), nv50_display_flip_wait, &flip);
388} 388}
389 389
390int 390int
@@ -2245,7 +2245,7 @@ nv50_display_destroy(struct drm_device *dev)
2245int 2245int
2246nv50_display_create(struct drm_device *dev) 2246nv50_display_create(struct drm_device *dev)
2247{ 2247{
2248 struct nouveau_device *device = nouveau_dev(dev); 2248 struct nouveau_object *device = nouveau_drm(dev)->device;
2249 struct nouveau_drm *drm = nouveau_drm(dev); 2249 struct nouveau_drm *drm = nouveau_drm(dev);
2250 struct dcb_table *dcb = &drm->vbios.dcb; 2250 struct dcb_table *dcb = &drm->vbios.dcb;
2251 struct drm_connector *connector, *tmp; 2251 struct drm_connector *connector, *tmp;
@@ -2294,7 +2294,7 @@ nv50_display_create(struct drm_device *dev)
2294 2294
2295 /* create crtc objects to represent the hw heads */ 2295 /* create crtc objects to represent the hw heads */
2296 if (nv_mclass(disp->core) >= NVD0_DISP_CLASS) 2296 if (nv_mclass(disp->core) >= NVD0_DISP_CLASS)
2297 crtcs = nv_rd32(device, 0x022448); 2297 crtcs = nvif_rd32(device, 0x022448);
2298 else 2298 else
2299 crtcs = 2; 2299 crtcs = 2;
2300 2300