Commit 9db4a9c7 authored by Jesse Barnes's avatar Jesse Barnes Committed by Chris Wilson
Browse files

drm/i915: cleanup per-pipe reg usage


We had some conversions over to the _PIPE macros, but didn't get
everything.  So hide the per-pipe regs with an _ (still used in a few
places for legacy) and add a few _PIPE based macros, then make sure
everyone uses them.

[update: remove usage of non-existent no-op macro]
[update 2: keep modesetting suspend/resume code, update to new reg names]
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
[ickle: stylistic cleanups for checkpatch and taste]
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent 8d7e3de1
...@@ -326,21 +326,21 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data) ...@@ -326,21 +326,21 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)
struct intel_crtc *crtc; struct intel_crtc *crtc;
list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
const char *pipe = crtc->pipe ? "B" : "A"; const char pipe = pipe_name(crtc->pipe);
const char *plane = crtc->plane ? "B" : "A"; const char plane = plane_name(crtc->plane);
struct intel_unpin_work *work; struct intel_unpin_work *work;
spin_lock_irqsave(&dev->event_lock, flags); spin_lock_irqsave(&dev->event_lock, flags);
work = crtc->unpin_work; work = crtc->unpin_work;
if (work == NULL) { if (work == NULL) {
seq_printf(m, "No flip due on pipe %s (plane %s)\n", seq_printf(m, "No flip due on pipe %c (plane %c)\n",
pipe, plane); pipe, plane);
} else { } else {
if (!work->pending) { if (!work->pending) {
seq_printf(m, "Flip queued on pipe %s (plane %s)\n", seq_printf(m, "Flip queued on pipe %c (plane %c)\n",
pipe, plane); pipe, plane);
} else { } else {
seq_printf(m, "Flip pending (waiting for vsync) on pipe %s (plane %s)\n", seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
pipe, plane); pipe, plane);
} }
if (work->enable_stall_check) if (work->enable_stall_check)
...@@ -458,7 +458,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data) ...@@ -458,7 +458,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
struct drm_info_node *node = (struct drm_info_node *) m->private; struct drm_info_node *node = (struct drm_info_node *) m->private;
struct drm_device *dev = node->minor->dev; struct drm_device *dev = node->minor->dev;
drm_i915_private_t *dev_priv = dev->dev_private; drm_i915_private_t *dev_priv = dev->dev_private;
int ret, i; int ret, i, pipe;
ret = mutex_lock_interruptible(&dev->struct_mutex); ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret) if (ret)
...@@ -471,10 +471,10 @@ static int i915_interrupt_info(struct seq_file *m, void *data) ...@@ -471,10 +471,10 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
I915_READ(IIR)); I915_READ(IIR));
seq_printf(m, "Interrupt mask: %08x\n", seq_printf(m, "Interrupt mask: %08x\n",
I915_READ(IMR)); I915_READ(IMR));
seq_printf(m, "Pipe A stat: %08x\n", for_each_pipe(pipe)
I915_READ(PIPEASTAT)); seq_printf(m, "Pipe %c stat: %08x\n",
seq_printf(m, "Pipe B stat: %08x\n", pipe_name(pipe),
I915_READ(PIPEBSTAT)); I915_READ(PIPESTAT(pipe)));
} else { } else {
seq_printf(m, "North Display Interrupt enable: %08x\n", seq_printf(m, "North Display Interrupt enable: %08x\n",
I915_READ(DEIER)); I915_READ(DEIER));
......
...@@ -2005,7 +2005,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -2005,7 +2005,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
spin_lock_init(&dev_priv->irq_lock); spin_lock_init(&dev_priv->irq_lock);
spin_lock_init(&dev_priv->error_lock); spin_lock_init(&dev_priv->error_lock);
ret = drm_vblank_init(dev, I915_NUM_PIPE); if (IS_MOBILE(dev) || !IS_GEN2(dev))
dev_priv->num_pipe = 2;
else
dev_priv->num_pipe = 1;
ret = drm_vblank_init(dev, dev_priv->num_pipe);
if (ret) if (ret)
goto out_gem_unload; goto out_gem_unload;
......
...@@ -50,17 +50,22 @@ ...@@ -50,17 +50,22 @@
enum pipe { enum pipe {
PIPE_A = 0, PIPE_A = 0,
PIPE_B, PIPE_B,
PIPE_C,
I915_MAX_PIPES
}; };
#define pipe_name(p) ((p) + 'A')
enum plane { enum plane {
PLANE_A = 0, PLANE_A = 0,
PLANE_B, PLANE_B,
PLANE_C,
}; };
#define plane_name(p) ((p) + 'A')
#define I915_NUM_PIPE 2
#define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT)) #define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
#define for_each_pipe(p) for ((p) = 0; (p) < dev_priv->num_pipe; (p)++)
/* Interface history: /* Interface history:
* *
* 1.1: Original. * 1.1: Original.
...@@ -143,8 +148,7 @@ struct intel_display_error_state; ...@@ -143,8 +148,7 @@ struct intel_display_error_state;
struct drm_i915_error_state { struct drm_i915_error_state {
u32 eir; u32 eir;
u32 pgtbl_er; u32 pgtbl_er;
u32 pipeastat; u32 pipestat[I915_MAX_PIPES];
u32 pipebstat;
u32 ipeir; u32 ipeir;
u32 ipehr; u32 ipehr;
u32 instdone; u32 instdone;
......
...@@ -85,21 +85,11 @@ ironlake_disable_display_irq(drm_i915_private_t *dev_priv, u32 mask) ...@@ -85,21 +85,11 @@ ironlake_disable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
} }
} }
static inline u32
i915_pipestat(int pipe)
{
if (pipe == 0)
return PIPEASTAT;
if (pipe == 1)
return PIPEBSTAT;
BUG();
}
void void
i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask) i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
{ {
if ((dev_priv->pipestat[pipe] & mask) != mask) { if ((dev_priv->pipestat[pipe] & mask) != mask) {
u32 reg = i915_pipestat(pipe); u32 reg = PIPESTAT(pipe);
dev_priv->pipestat[pipe] |= mask; dev_priv->pipestat[pipe] |= mask;
/* Enable the interrupt, clear any pending status */ /* Enable the interrupt, clear any pending status */
...@@ -112,7 +102,7 @@ void ...@@ -112,7 +102,7 @@ void
i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask) i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
{ {
if ((dev_priv->pipestat[pipe] & mask) != 0) { if ((dev_priv->pipestat[pipe] & mask) != 0) {
u32 reg = i915_pipestat(pipe); u32 reg = PIPESTAT(pipe);
dev_priv->pipestat[pipe] &= ~mask; dev_priv->pipestat[pipe] &= ~mask;
I915_WRITE(reg, dev_priv->pipestat[pipe]); I915_WRITE(reg, dev_priv->pipestat[pipe]);
...@@ -171,12 +161,12 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) ...@@ -171,12 +161,12 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
if (!i915_pipe_enabled(dev, pipe)) { if (!i915_pipe_enabled(dev, pipe)) {
DRM_DEBUG_DRIVER("trying to get vblank count for disabled " DRM_DEBUG_DRIVER("trying to get vblank count for disabled "
"pipe %d\n", pipe); "pipe %c\n", pipe_name(pipe));
return 0; return 0;
} }
high_frame = pipe ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH; high_frame = PIPEFRAME(pipe);
low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL; low_frame = PIPEFRAMEPIXEL(pipe);
/* /*
* High & low register fields aren't synchronized, so make sure * High & low register fields aren't synchronized, so make sure
...@@ -197,11 +187,11 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) ...@@ -197,11 +187,11 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
{ {
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45; int reg = PIPE_FRMCOUNT_GM45(pipe);
if (!i915_pipe_enabled(dev, pipe)) { if (!i915_pipe_enabled(dev, pipe)) {
DRM_DEBUG_DRIVER("trying to get vblank count for disabled " DRM_DEBUG_DRIVER("trying to get vblank count for disabled "
"pipe %d\n", pipe); "pipe %c\n", pipe_name(pipe));
return 0; return 0;
} }
...@@ -219,7 +209,7 @@ int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe, ...@@ -219,7 +209,7 @@ int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
if (!i915_pipe_enabled(dev, pipe)) { if (!i915_pipe_enabled(dev, pipe)) {
DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled " DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
"pipe %d\n", pipe); "pipe %c\n", pipe_name(pipe));
return 0; return 0;
} }
...@@ -417,6 +407,7 @@ static void pch_irq_handler(struct drm_device *dev) ...@@ -417,6 +407,7 @@ static void pch_irq_handler(struct drm_device *dev)
{ {
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
u32 pch_iir; u32 pch_iir;
int pipe;
pch_iir = I915_READ(SDEIIR); pch_iir = I915_READ(SDEIIR);
...@@ -437,13 +428,11 @@ static void pch_irq_handler(struct drm_device *dev) ...@@ -437,13 +428,11 @@ static void pch_irq_handler(struct drm_device *dev)
if (pch_iir & SDE_POISON) if (pch_iir & SDE_POISON)
DRM_ERROR("PCH poison interrupt\n"); DRM_ERROR("PCH poison interrupt\n");
if (pch_iir & SDE_FDI_MASK) { if (pch_iir & SDE_FDI_MASK)
u32 fdia, fdib; for_each_pipe(pipe)
DRM_DEBUG_DRIVER(" pipe %c FDI IIR: 0x%08x\n",
fdia = I915_READ(FDI_RXA_IIR); pipe_name(pipe),
fdib = I915_READ(FDI_RXB_IIR); I915_READ(FDI_RX_IIR(pipe)));
DRM_DEBUG_DRIVER("PCH FDI RX interrupt; FDI RXA IIR: 0x%08x, FDI RXB IIR: 0x%08x\n", fdia, fdib);
}
if (pch_iir & (SDE_TRANSB_CRC_DONE | SDE_TRANSA_CRC_DONE)) if (pch_iir & (SDE_TRANSB_CRC_DONE | SDE_TRANSA_CRC_DONE))
DRM_DEBUG_DRIVER("PCH transcoder CRC done interrupt\n"); DRM_DEBUG_DRIVER("PCH transcoder CRC done interrupt\n");
...@@ -770,7 +759,7 @@ static void i915_capture_error_state(struct drm_device *dev) ...@@ -770,7 +759,7 @@ static void i915_capture_error_state(struct drm_device *dev)
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct drm_i915_error_state *error; struct drm_i915_error_state *error;
unsigned long flags; unsigned long flags;
int i; int i, pipe;
spin_lock_irqsave(&dev_priv->error_lock, flags); spin_lock_irqsave(&dev_priv->error_lock, flags);
error = dev_priv->first_error; error = dev_priv->first_error;
...@@ -778,6 +767,7 @@ static void i915_capture_error_state(struct drm_device *dev) ...@@ -778,6 +767,7 @@ static void i915_capture_error_state(struct drm_device *dev)
if (error) if (error)
return; return;
/* Account for pipe specific data like PIPE*STAT */
error = kmalloc(sizeof(*error), GFP_ATOMIC); error = kmalloc(sizeof(*error), GFP_ATOMIC);
if (!error) { if (!error) {
DRM_DEBUG_DRIVER("out of memory, not capturing error state\n"); DRM_DEBUG_DRIVER("out of memory, not capturing error state\n");
...@@ -790,8 +780,8 @@ static void i915_capture_error_state(struct drm_device *dev) ...@@ -790,8 +780,8 @@ static void i915_capture_error_state(struct drm_device *dev)
error->seqno = dev_priv->ring[RCS].get_seqno(&dev_priv->ring[RCS]); error->seqno = dev_priv->ring[RCS].get_seqno(&dev_priv->ring[RCS]);
error->eir = I915_READ(EIR); error->eir = I915_READ(EIR);
error->pgtbl_er = I915_READ(PGTBL_ER); error->pgtbl_er = I915_READ(PGTBL_ER);
error->pipeastat = I915_READ(PIPEASTAT); for_each_pipe(pipe)
error->pipebstat = I915_READ(PIPEBSTAT); error->pipestat[pipe] = I915_READ(PIPESTAT(pipe));
error->instpm = I915_READ(INSTPM); error->instpm = I915_READ(INSTPM);
error->error = 0; error->error = 0;
if (INTEL_INFO(dev)->gen >= 6) { if (INTEL_INFO(dev)->gen >= 6) {
...@@ -912,6 +902,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev) ...@@ -912,6 +902,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
u32 eir = I915_READ(EIR); u32 eir = I915_READ(EIR);
int pipe;
if (!eir) if (!eir)
return; return;
...@@ -960,14 +951,10 @@ static void i915_report_and_clear_eir(struct drm_device *dev) ...@@ -960,14 +951,10 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
} }
if (eir & I915_ERROR_MEMORY_REFRESH) { if (eir & I915_ERROR_MEMORY_REFRESH) {
u32 pipea_stats = I915_READ(PIPEASTAT); printk(KERN_ERR "memory refresh error:\n");
u32 pipeb_stats = I915_READ(PIPEBSTAT); for_each_pipe(pipe)
printk(KERN_ERR "pipe %c stat: 0x%08x\n",
printk(KERN_ERR "memory refresh error\n"); pipe_name(pipe), I915_READ(PIPESTAT(pipe)));
printk(KERN_ERR "PIPEASTAT: 0x%08x\n",
pipea_stats);
printk(KERN_ERR "PIPEBSTAT: 0x%08x\n",
pipeb_stats);
/* pipestat has already been acked */ /* pipestat has already been acked */
} }
if (eir & I915_ERROR_INSTRUCTION) { if (eir & I915_ERROR_INSTRUCTION) {
...@@ -1081,10 +1068,10 @@ static void i915_pageflip_stall_check(struct drm_device *dev, int pipe) ...@@ -1081,10 +1068,10 @@ static void i915_pageflip_stall_check(struct drm_device *dev, int pipe)
/* Potential stall - if we see that the flip has happened, assume a missed interrupt */ /* Potential stall - if we see that the flip has happened, assume a missed interrupt */
obj = work->pending_flip_obj; obj = work->pending_flip_obj;
if (INTEL_INFO(dev)->gen >= 4) { if (INTEL_INFO(dev)->gen >= 4) {
int dspsurf = intel_crtc->plane == 0 ? DSPASURF : DSPBSURF; int dspsurf = DSPSURF(intel_crtc->plane);
stall_detected = I915_READ(dspsurf) == obj->gtt_offset; stall_detected = I915_READ(dspsurf) == obj->gtt_offset;
} else { } else {
int dspaddr = intel_crtc->plane == 0 ? DSPAADDR : DSPBADDR; int dspaddr = DSPADDR(intel_crtc->plane);
stall_detected = I915_READ(dspaddr) == (obj->gtt_offset + stall_detected = I915_READ(dspaddr) == (obj->gtt_offset +
crtc->y * crtc->fb->pitch + crtc->y * crtc->fb->pitch +
crtc->x * crtc->fb->bits_per_pixel/8); crtc->x * crtc->fb->bits_per_pixel/8);
...@@ -1104,12 +1091,13 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) ...@@ -1104,12 +1091,13 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
struct drm_i915_master_private *master_priv; struct drm_i915_master_private *master_priv;
u32 iir, new_iir; u32 iir, new_iir;
u32 pipea_stats, pipeb_stats; u32 pipe_stats[I915_MAX_PIPES];
u32 vblank_status; u32 vblank_status;
int vblank = 0; int vblank = 0;
unsigned long irqflags; unsigned long irqflags;
int irq_received; int irq_received;
int ret = IRQ_NONE; int ret = IRQ_NONE, pipe;
bool blc_event = false;
atomic_inc(&dev_priv->irq_received); atomic_inc(&dev_priv->irq_received);
...@@ -1132,27 +1120,23 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) ...@@ -1132,27 +1120,23 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
* interrupts (for non-MSI). * interrupts (for non-MSI).
*/ */
spin_lock_irqsave(&dev_priv->irq_lock, irqflags); spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
pipea_stats = I915_READ(PIPEASTAT);
pipeb_stats = I915_READ(PIPEBSTAT);
if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
i915_handle_error(dev, false); i915_handle_error(dev, false);
/* for_each_pipe(pipe) {
* Clear the PIPE(A|B)STAT regs before the IIR int reg = PIPESTAT(pipe);
*/ pipe_stats[pipe] = I915_READ(reg);
if (pipea_stats & 0x8000ffff) {
if (pipea_stats & PIPE_FIFO_UNDERRUN_STATUS) /*
DRM_DEBUG_DRIVER("pipe a underrun\n"); * Clear the PIPE*STAT regs before the IIR
I915_WRITE(PIPEASTAT, pipea_stats); */
irq_received = 1; if (pipe_stats[pipe] & 0x8000ffff) {
} if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS)
DRM_DEBUG_DRIVER("pipe %c underrun\n",
if (pipeb_stats & 0x8000ffff) { pipe_name(pipe));
if (pipeb_stats & PIPE_FIFO_UNDERRUN_STATUS) I915_WRITE(reg, pipe_stats[pipe]);
DRM_DEBUG_DRIVER("pipe b underrun\n"); irq_received = 1;
I915_WRITE(PIPEBSTAT, pipeb_stats); }
irq_received = 1;
} }
spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
...@@ -1203,27 +1187,22 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) ...@@ -1203,27 +1187,22 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
intel_finish_page_flip_plane(dev, 1); intel_finish_page_flip_plane(dev, 1);
} }
if (pipea_stats & vblank_status && for_each_pipe(pipe) {
drm_handle_vblank(dev, 0)) { if (pipe_stats[pipe] & vblank_status &&
vblank++; drm_handle_vblank(dev, pipe)) {
if (!dev_priv->flip_pending_is_done) { vblank++;
i915_pageflip_stall_check(dev, 0); if (!dev_priv->flip_pending_is_done) {
intel_finish_page_flip(dev, 0); i915_pageflip_stall_check(dev, pipe);
intel_finish_page_flip(dev, pipe);
}
} }
}
if (pipeb_stats & vblank_status && if (pipe_stats[pipe] & PIPE_LEGACY_BLC_EVENT_STATUS)
drm_handle_vblank(dev, 1)) { blc_event = true;
vblank++;
if (!dev_priv->flip_pending_is_done) {
i915_pageflip_stall_check(dev, 1);
intel_finish_page_flip(dev, 1);
}
} }
if ((pipea_stats & PIPE_LEGACY_BLC_EVENT_STATUS) ||
(pipeb_stats & PIPE_LEGACY_BLC_EVENT_STATUS) || if (blc_event || (iir & I915_ASLE_INTERRUPT))
(iir & I915_ASLE_INTERRUPT))
intel_opregion_asle_intr(dev); intel_opregion_asle_intr(dev);
/* With MSI, interrupts are only generated when iir /* With MSI, interrupts are only generated when iir
...@@ -1634,6 +1613,7 @@ static int ironlake_irq_postinstall(struct drm_device *dev) ...@@ -1634,6 +1613,7 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE; DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE;
u32 render_irqs; u32 render_irqs;
u32 hotplug_mask; u32 hotplug_mask;
int pipe;
dev_priv->irq_mask = ~display_mask; dev_priv->irq_mask = ~display_mask;
...@@ -1668,8 +1648,8 @@ static int ironlake_irq_postinstall(struct drm_device *dev) ...@@ -1668,8 +1648,8 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
hotplug_mask = SDE_CRT_HOTPLUG | SDE_PORTB_HOTPLUG | hotplug_mask = SDE_CRT_HOTPLUG | SDE_PORTB_HOTPLUG |
SDE_PORTC_HOTPLUG | SDE_PORTD_HOTPLUG; SDE_PORTC_HOTPLUG | SDE_PORTD_HOTPLUG;
hotplug_mask |= SDE_AUX_MASK | SDE_FDI_MASK | SDE_TRANS_MASK; hotplug_mask |= SDE_AUX_MASK | SDE_FDI_MASK | SDE_TRANS_MASK;
I915_WRITE(FDI_RXA_IMR, 0); for_each_pipe(pipe)
I915_WRITE(FDI_RXB_IMR, 0); I915_WRITE(FDI_RX_IMR(pipe), 0);
} }
dev_priv->pch_irq_mask = ~hotplug_mask; dev_priv->pch_irq_mask = ~hotplug_mask;
...@@ -1692,6 +1672,7 @@ static int ironlake_irq_postinstall(struct drm_device *dev) ...@@ -1692,6 +1672,7 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
void i915_driver_irq_preinstall(struct drm_device * dev) void i915_driver_irq_preinstall(struct drm_device * dev)
{ {
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
int pipe;
atomic_set(&dev_priv->irq_received, 0); atomic_set(&dev_priv->irq_received, 0);
atomic_set(&dev_priv->vblank_enabled, 0); atomic_set(&dev_priv->vblank_enabled, 0);
...@@ -1711,8 +1692,8 @@ void i915_driver_irq_preinstall(struct drm_device * dev) ...@@ -1711,8 +1692,8 @@ void i915_driver_irq_preinstall(struct drm_device * dev)
} }
I915_WRITE(HWSTAM, 0xeffe); I915_WRITE(HWSTAM, 0xeffe);
I915_WRITE(PIPEASTAT, 0); for_each_pipe(pipe)
I915_WRITE(PIPEBSTAT, 0); I915_WRITE(PIPESTAT(pipe), 0);
I915_WRITE(IMR, 0xffffffff); I915_WRITE(IMR, 0xffffffff);
I915_WRITE(IER, 0x0); I915_WRITE(IER, 0x0);
POSTING_READ(IER); POSTING_READ(IER);
...@@ -1824,6 +1805,7 @@ static void ironlake_irq_uninstall(struct drm_device *dev) ...@@ -1824,6 +1805,7 @@ static void ironlake_irq_uninstall(struct drm_device *dev)
void i915_driver_irq_uninstall(struct drm_device * dev) void i915_driver_irq_uninstall(struct drm_device * dev)
{ {
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
int pipe;
if (!dev_priv) if (!dev_priv)
return; return;
...@@ -1841,12 +1823,13 @@ void i915_driver_irq_uninstall(struct drm_device * dev) ...@@ -1841,12 +1823,13 @@ void i915_driver_irq_uninstall(struct drm_device * dev)
} }
I915_WRITE(HWSTAM, 0xffffffff); I915_WRITE(HWSTAM, 0xffffffff);
I915_WRITE(PIPEASTAT, 0); for_each_pipe(pipe)
I915_WRITE(PIPEBSTAT, 0); I915_WRITE(PIPESTAT(pipe), 0);
I915_WRITE(IMR, 0xffffffff); I915_WRITE(IMR, 0xffffffff);
I915_WRITE(IER, 0x0); I915_WRITE(IER, 0x0);
I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff); for_each_pipe(pipe)
I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff); I915_WRITE(PIPESTAT(pipe),
I915_READ(PIPESTAT(pipe)) & 0x8000ffff);
I915_WRITE(IIR, I915_READ(IIR)); I915_WRITE(IIR, I915_READ(IIR));
} }
This diff is collapsed.
This diff is collapsed.
...@@ -129,10 +129,7 @@ static void intel_crt_mode_set(struct drm_encoder *encoder, ...@@ -129,10 +129,7 @@ static void intel_crt_mode_set(struct drm_encoder *encoder,
u32 adpa, dpll_md; u32 adpa, dpll_md;
u32 adpa_reg; u32 adpa_reg;
if (intel_crtc->pipe == 0) dpll_md_reg = DPLL_MD(intel_crtc->pipe);
dpll_md_reg = DPLL_A_MD;
else
dpll_md_reg = DPLL_B_MD;
if (HAS_PCH_SPLIT(dev)) if (HAS_PCH_SPLIT(dev))
adpa_reg = PCH_ADPA; adpa_reg = PCH_ADPA;
...@@ -160,17 +157,16 @@ static void intel_crt_mode_set(struct drm_encoder *encoder, ...@@ -160,17 +157,16 @@ static void intel_crt_mode_set(struct drm_encoder *encoder,
adpa |= PORT_TRANS_A_SEL_CPT; adpa |= PORT_TRANS_A_SEL_CPT;
else else
adpa |= ADPA_PIPE_A_SELECT; adpa |= ADPA_PIPE_A_SELECT;
if (!HAS_PCH_SPLIT(dev))
I915_WRITE(BCLRPAT_A, 0);
} else { } else {
if (HAS_PCH_CPT(dev)) if (HAS_PCH_CPT(dev))
adpa |= PORT_TRANS_B_SEL_CPT; adpa |= PORT_TRANS_B_SEL_CPT;
else else
adpa |= ADPA_PIPE_B_SELECT; adpa |= ADPA_PIPE_B_SELECT;
if (!HAS_PCH_SPLIT(dev))
I915_WRITE(BCLRPAT_B, 0);
} }
if (!HAS_PCH_SPLIT(dev))
I915_WRITE(BCLRPAT(intel_crtc->pipe), 0);
I915_WRITE(adpa_reg, adpa); I915_WRITE(adpa_reg, adpa);
} }
...@@ -353,21 +349,12 @@ intel_crt_load_detect(struct drm_crtc *crtc, struct intel_crt *crt) ...@@ -353,21 +349,12 @@ intel_crt_load_detect(struct drm_crtc *crtc, struct intel_crt *crt)
DRM_DEBUG_KMS("starting load-detect on CRT\n"); DRM_DEBUG_KMS("starting load-detect on CRT\n");
if (pipe == 0) { bclrpat_reg = BCLRPAT(pipe);
bclrpat_reg = BCLRPAT_A; vtotal_reg = VTOTAL(pipe);
vtotal_reg = VTOTAL_A; vblank_reg = VBLANK(pipe);
vblank_reg = VBLANK_A; vsync_reg = VSYNC(pipe);
vsync_reg = VSYNC_A; pipeconf_reg = PIPECONF(pipe);
pipeconf_reg = PIPEACONF; pipe_dsl_reg = PIPEDSL(pipe);
pipe_dsl_reg = PIPEADSL;
} else {
bclrpat_reg = BCLRPAT_B;
vtotal_reg = VTOTAL_B;
vblank_reg = VBLANK_B;
vsync_reg = VSYNC_B;
pipeconf_reg = PIPEBCONF;
pipe_dsl_reg = PIPEBDSL;
}
save_bclrpat = I915_READ(bclrpat_reg); save_bclrpat = I915_READ(bclrpat_reg);
save_vtotal = I915_READ(vtotal_reg); save_vtotal = I915_READ(vtotal_reg);
......
...@@ -989,7 +989,7 @@ intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc, ...@@ -989,7 +989,7 @@ intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc,
void intel_wait_for_vblank(struct drm_device *dev, int pipe) void intel_wait_for_vblank(struct drm_device *dev, int pipe)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
int pipestat_reg = (pipe == 0 ? PIPEASTAT : PIPEBSTAT); int pipestat_reg = PIPESTAT(pipe);
/* Clear existing vblank status. Note this will clear any other /* Clear existing vblank status. Note this will clear any other
* sticky status fields as well. * sticky status fields as well.
...@@ -1185,7 +1185,7 @@ static void assert_panel_unlocked(struct drm_i915_private *dev_priv, ...@@ -1185,7 +1185,7 @@ static void assert_panel_unlocked(struct drm_i915_private *dev_priv,
WARN(panel_pipe == pipe && locked, WARN(panel_pipe == pipe && locked,
"panel assertion failure, pipe %c regs locked\n", "panel assertion failure, pipe %c regs locked\n",
pipe ? 'B' : 'A'); pipe_name(pipe));
} }
static void assert_pipe(struct drm_i915_private *dev_priv, static void assert_pipe(struct drm_i915_private *dev_priv,
...@@ -1200,7 +1200,7 @@ static void assert_pipe(struct drm_i915_private *dev_priv, ...@@ -1200,7 +1200,7 @@ static void assert_pipe(struct drm_i915_private *dev_priv,
cur_state = !!(val & PIPECONF_ENABLE); cur_state = !!(val & PIPECONF_ENABLE);
WARN(cur_state != state, WARN(cur_state != state,
"pipe %c assertion failure (expected %s, current %s)\n", "pipe %c assertion failure (expected %s, current %s)\n",
pipe ? 'B' : 'A', state_string(state), state_string(cur_state)); pipe_name(pipe), state_string(state), state_string(cur_state));
} }
#define assert_pipe_enabled(d, p) assert_pipe(d, p, true) #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
#define assert_pipe_disabled(d, p) assert_pipe(d, p, false) #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
...@@ -1215,7 +1215,7 @@ static void assert_plane_enabled(struct drm_i915_private *dev_priv, ...@@ -1215,7 +1215,7 @@ static void assert_plane_enabled(struct drm_i915_private *dev_priv,
val = I915_READ(reg); val = I915_READ(reg);
WARN(!(val & DISPLAY_PLANE_ENABLE), WARN(!(val & DISPLAY_PLANE_ENABLE),
"plane %c assertion failure, should be active but is disabled\n", "plane %c assertion failure, should be active but is disabled\n",
plane ? 'B' : 'A'); plane_name(plane));
} }
static void assert_planes_disabled(struct drm_i915_private *dev_priv, static void assert_planes_disabled(struct drm_i915_private *dev_priv,
...@@ -1236,8 +1236,8 @@ static void assert_planes_disabled(struct drm_i915_private *dev_priv, ...@@ -1236,8 +1236,8 @@ static void assert_planes_disabled(struct drm_i915_private *dev_priv,
cur_pipe = (val & DISPPLANE_SEL_PIPE_MASK) >> cur_pipe = (val & DISPPLANE_SEL_PIPE_MASK) >>
DISPPLANE_SEL_PIPE_SHIFT; DISPPLANE_SEL_PIPE_SHIFT;
WARN((val & DISPLAY_PLANE_ENABLE) && pipe == cur_pipe, WARN((val & DISPLAY_PLANE_ENABLE) && pipe == cur_pipe,
"plane %d assertion failure, should be off on pipe %c but is still active\n", "plane %c assertion failure, should be off on pipe %c but is still active\n",
i, pipe ? 'B' : 'A'); plane_name(i), pipe_name(pipe));
} }
} }
...@@ -1262,7 +1262,9 @@ static void assert_transcoder_disabled(struct drm_i915_private *dev_priv, ...@@ -1262,7 +1262,9 @@ static void assert_transcoder_disabled(struct drm_i915_private *dev_priv,
reg = TRANSCONF(pipe); reg = TRANSCONF(pipe);
val = I915_READ(reg); val = I915_READ(reg);
enabled = !!(val & TRANS_ENABLE); enabled = !!(val & TRANS_ENABLE);
WARN(enabled, "transcoder assertion failed, should be off on pipe %c but is still active\n", pipe ? 'B' :'A'); WARN(enabled,
"transcoder assertion failed, should be off on pipe %c but is still active\n",
pipe_name(pipe));
} }
static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv, static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv,
...@@ -1275,7 +1277,7 @@ static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv, ...@@ -1275,7 +1277,7 @@ static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv,
sel_pipe = (val & DP_PIPEB_SELECT) >> 30; sel_pipe = (val & DP_PIPEB_SELECT) >> 30;
WARN((val & DP_PORT_EN) && sel_pipe == pipe, WARN((val & DP_PORT_EN) && sel_pipe == pipe,
"PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n", "PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n",
reg, pipe ? 'B' : 'A'); reg, pipe_name(pipe));
} }
static void assert_pch_hdmi_disabled(struct drm_i915_private *dev_priv, static void assert_pch_hdmi_disabled(struct drm_i915_private *dev_priv,
...@@ -1288,7 +1290,7 @@ static void assert_pch_hdmi_disabled(struct drm_i915_private *dev_priv, ...@@ -1288,7 +1290,7 @@ static void assert_pch_hdmi_disabled(struct drm_i915_private *dev_priv,
sel_pipe = (val & TRANSCODER_B) >> 30; sel_pipe = (val & TRANSCODER_B) >> 30;
WARN((val & PORT_ENABLE) && sel_pipe == pipe, WARN((val & PORT_ENABLE) && sel_pipe == pipe,
"PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n", "PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n",
reg, pipe ? 'B' : 'A'); reg, pipe_name(pipe));
} }
static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv, static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv,
...@@ -1307,14 +1309,14 @@ static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv, ...@@ -1307,14 +1309,14 @@ static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv,
sel_pipe = (val & ADPA_TRANS_B_SELECT) >> 30; sel_pipe = (val & ADPA_TRANS_B_SELECT) >> 30;
WARN(sel_pipe == pipe && (val & ADPA_DAC_ENABLE), WARN(sel_pipe == pipe && (val & ADPA_DAC_ENABLE),
"PCH VGA enabled on transcoder %c, should be disabled\n", "PCH VGA enabled on transcoder %c, should be disabled\n",
pipe ? 'B' : 'A'); pipe_name(pipe));
reg = PCH_LVDS; reg = PCH_LVDS;
val = I915_READ(reg); val = I915_READ(reg);
sel_pipe = (val & LVDS_PIPEB_SELECT) >> 30; sel_pipe = (val & LVDS_PIPEB_SELECT) >> 30;
WARN(sel_pipe == pipe && (val & LVDS_PORT_EN), WARN(sel_pipe == pipe && (val & LVDS_PORT_EN),
"PCH LVDS enabled on transcoder %c, should be disabled\n", "PCH LVDS enabled on transcoder %c, should be disabled\n",
pipe ? 'B' : 'A'); pipe_name(pipe));
assert_pch_hdmi_disabled(dev_priv, pipe, HDMIB); assert_pch_hdmi_disabled(dev_priv, pipe, HDMIB);
assert_pch_hdmi_disabled(dev_priv, pipe, HDMIC); assert_pch_hdmi_disabled(dev_priv, pipe, HDMIC);
...@@ -2816,12 +2818,9 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) ...@@ -2816,12 +2818,9 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
* as some pre-programmed values are broken, * as some pre-programmed values are broken,
* e.g. x201. * e.g. x201.
*/ */
I915_WRITE(pipe ? PFB_CTL_1 : PFA_CTL_1, I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3);
PF_ENABLE | PF_FILTER_MED_3x3); I915_WRITE(PF_WIN_POS(pipe), dev_priv->pch_pf_pos);
I915_WRITE(pipe ? PFB_WIN_POS : PFA_WIN_POS, I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size);
dev_priv->pch_pf_pos);
I915_WRITE(pipe ? PFB_WIN_SZ : PFA_WIN_SZ,
dev_priv->pch_pf_size);
} }
intel_enable_pipe(dev_priv, pipe, is_pch_port); intel_enable_pipe(dev_priv, pipe, is_pch_port);
...@@ -2860,8 +2859,8 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) ...@@ -2860,8 +2859,8 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
intel_disable_pipe(dev_priv, pipe); intel_disable_pipe(dev_priv, pipe);
/* Disable PF */ /* Disable PF */
I915_WRITE(pipe ? PFB_CTL_1 : PFA_CTL_1, 0); I915_WRITE(PF_CTL(pipe), 0);
I915_WRITE(pipe ? PFB_WIN_SZ : PFA_WIN_SZ, 0); I915_WRITE(PF_WIN_SZ(pipe), 0);
ironlake_fdi_disable(crtc); ironlake_fdi_disable(crtc);
...@@ -2886,10 +2885,20 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) ...@@ -2886,10 +2885,20 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
/* disable DPLL_SEL */ /* disable DPLL_SEL */
temp = I915_READ(PCH_DPLL_SEL); temp = I915_READ(PCH_DPLL_SEL);
if (pipe == 0) switch (pipe) {
temp &= ~(TRANSA_DPLL_ENABLE | TRANSA_DPLLB_SEL); case 0:
else temp &= ~(TRANSA_DPLL_ENABLE | TRANSA_DPLLA_SEL);
break;
case 1:
temp &= ~(TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL); temp &= ~(TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL);
break;
case 2:
/* FIXME: manage transcoder PLLs? */
temp &= ~(TRANSC_DPLL_ENABLE | TRANSC_DPLLB_SEL);
break;
default:
BUG(); /* wtf */
}
I915_WRITE(PCH_DPLL_SEL, temp); I915_WRITE(PCH_DPLL_SEL, temp);
} }
...@@ -3074,7 +3083,7 @@ static void intel_crtc_dpms(struct drm_crtc *crtc, int mode) ...@@ -3074,7 +3083,7 @@ static void intel_crtc_dpms(struct drm_crtc *crtc, int mode)
master_priv->sarea_priv->pipeB_h = enabled ? crtc->mode.vdisplay : 0; master_priv->sarea_priv->pipeB_h = enabled ? crtc->mode.vdisplay : 0;
break; break;
default: default:
DRM_ERROR("Can't update pipe %d in SAREA\n", pipe); DRM_ERROR("Can't update pipe %c in SAREA\n", pipe_name(pipe));
break; break;
} }
} }
...@@ -4923,10 +4932,20 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, ...@@ -4923,10 +4932,20 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
/* enable transcoder DPLL */ /* enable transcoder DPLL */
if (HAS_PCH_CPT(dev)) { if (HAS_PCH_CPT(dev)) {
temp = I915_READ(PCH_DPLL_SEL); temp = I915_READ(PCH_DPLL_SEL);
if (pipe == 0) switch (pipe) {
case 0:
temp |= TRANSA_DPLL_ENABLE | TRANSA_DPLLA_SEL; temp |= TRANSA_DPLL_ENABLE | TRANSA_DPLLA_SEL;
else break;
case 1:
temp |= TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL; temp |= TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL;
break;
case 2:
/* FIXME: manage transcoder PLLs? */
temp |= TRANSC_DPLL_ENABLE | TRANSC_DPLLB_SEL;
break;
default:
BUG();
}
I915_WRITE(PCH_DPLL_SEL, temp); I915_WRITE(PCH_DPLL_SEL, temp);
POSTING_READ(PCH_DPLL_SEL); POSTING_READ(PCH_DPLL_SEL);
...@@ -5009,17 +5028,10 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, ...@@ -5009,17 +5028,10 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
intel_dp_set_m_n(crtc, mode, adjusted_mode); intel_dp_set_m_n(crtc, mode, adjusted_mode);
} else if (HAS_PCH_SPLIT(dev)) { } else if (HAS_PCH_SPLIT(dev)) {
/* For non-DP output, clear any trans DP clock recovery setting.*/ /* For non-DP output, clear any trans DP clock recovery setting.*/
if (pipe == 0) { I915_WRITE(TRANSDATA_M1(pipe), 0);
I915_WRITE(TRANSA_DATA_M1, 0); I915_WRITE(TRANSDATA_N1(pipe), 0);
I915_WRITE(TRANSA_DATA_N1, 0); I915_WRITE(TRANSDPLINK_M1(pipe), 0);
I915_WRITE(TRANSA_DP_LINK_M1, 0); I915_WRITE(TRANSDPLINK_N1(pipe), 0);
I915_WRITE(TRANSA_DP_LINK_N1, 0);
} else {
I915_WRITE(TRANSB_DATA_M1, 0);
I915_WRITE(TRANSB_DATA_N1, 0);
I915_WRITE(TRANSB_DP_LINK_M1, 0);
I915_WRITE(TRANSB_DP_LINK_N1, 0);
}
} }
if (!has_edp_encoder || intel_encoder_is_pch_edp(&has_edp_encoder->base)) { if (!has_edp_encoder || intel_encoder_is_pch_edp(&has_edp_encoder->base)) {
...@@ -5153,7 +5165,7 @@ void intel_crtc_load_lut(struct drm_crtc *crtc) ...@@ -5153,7 +5165,7 @@ void intel_crtc_load_lut(struct drm_crtc *crtc)
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int palreg = (intel_crtc->pipe == 0) ? PALETTE_A : PALETTE_B; int palreg = PALETTE(intel_crtc->pipe);
int i; int i;
/* The clocks have to be on to load the palette. */ /* The clocks have to be on to load the palette. */
...@@ -5162,8 +5174,7 @@ void intel_crtc_load_lut(struct drm_crtc *crtc) ...@@ -5162,8 +5174,7 @@ void intel_crtc_load_lut(struct drm_crtc *crtc)
/* use legacy palette for Ironlake */ /* use legacy palette for Ironlake */
if (HAS_PCH_SPLIT(dev)) if (HAS_PCH_SPLIT(dev))
palreg = (intel_crtc->pipe == 0) ? LGC_PALETTE_A : palreg = LGC_PALETTE(intel_crtc->pipe);
LGC_PALETTE_B;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
I915_WRITE(palreg + 4 * i, I915_WRITE(palreg + 4 * i,
...@@ -5184,12 +5195,12 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) ...@@ -5184,12 +5195,12 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
if (intel_crtc->cursor_visible == visible) if (intel_crtc->cursor_visible == visible)
return; return;
cntl = I915_READ(CURACNTR); cntl = I915_READ(_CURACNTR);
if (visible) { if (visible) {
/* On these chipsets we can only modify the base whilst /* On these chipsets we can only modify the base whilst
* the cursor is disabled. * the cursor is disabled.
*/ */
I915_WRITE(CURABASE, base); I915_WRITE(_CURABASE, base);
cntl &= ~(CURSOR_FORMAT_MASK); cntl &= ~(CURSOR_FORMAT_MASK);
/* XXX width must be 64, stride 256 => 0x00 << 28 */ /* XXX width must be 64, stride 256 => 0x00 << 28 */
...@@ -5198,7 +5209,7 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) ...@@ -5198,7 +5209,7 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
CURSOR_FORMAT_ARGB; CURSOR_FORMAT_ARGB;
} else } else
cntl &= ~(CURSOR_ENABLE | CURSOR_GAMMA_ENABLE); cntl &= ~(CURSOR_ENABLE | CURSOR_GAMMA_ENABLE);
I915_WRITE(CURACNTR, cntl); I915_WRITE(_CURACNTR, cntl);
intel_crtc->cursor_visible = visible; intel_crtc->cursor_visible = visible;
} }
...@@ -5212,7 +5223,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) ...@@ -5212,7 +5223,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
bool visible = base != 0; bool visible = base != 0;
if (intel_crtc->cursor_visible != visible) { if (intel_crtc->cursor_visible != visible) {
uint32_t cntl = I915_READ(pipe == 0 ? CURACNTR : CURBCNTR); uint32_t cntl = CURCNTR(pipe);
if (base) { if (base) {
cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT); cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT);
cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
...@@ -5221,12 +5232,12 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) ...@@ -5221,12 +5232,12 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
cntl |= CURSOR_MODE_DISABLE; cntl |= CURSOR_MODE_DISABLE;
} }
I915_WRITE(pipe == 0 ? CURACNTR : CURBCNTR, cntl); I915_WRITE(CURCNTR(pipe), cntl);
intel_crtc->cursor_visible = visible; intel_crtc->cursor_visible = visible;
} }
/* and commit changes on next vblank */ /* and commit changes on next vblank */
I915_WRITE(pipe == 0 ? CURABASE : CURBBASE, base); I915_WRITE(CURBASE(pipe), base);
} }
/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ /* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */
...@@ -5276,7 +5287,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, ...@@ -5276,7 +5287,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
if (!visible && !intel_crtc->cursor_visible) if (!visible && !intel_crtc->cursor_visible)
return; return;
I915_WRITE(pipe == 0 ? CURAPOS : CURBPOS, pos); I915_WRITE(CURPOS(pipe), pos);
if (IS_845G(dev) || IS_I865G(dev)) if (IS_845G(dev) || IS_I865G(dev))
i845_update_cursor(crtc, base); i845_update_cursor(crtc, base);
else else
...@@ -5582,14 +5593,14 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc) ...@@ -5582,14 +5593,14 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
u32 dpll = I915_READ((pipe == 0) ? DPLL_A : DPLL_B); u32 dpll = DPLL(pipe);
u32 fp; u32 fp;
intel_clock_t clock; intel_clock_t clock;
if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
fp = I915_READ((pipe == 0) ? FPA0 : FPB0); fp = FP0(pipe);
else else
fp = I915_READ((pipe == 0) ? FPA1 : FPB1); fp = FP1(pipe);
clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT;
if (IS_PINEVIEW(dev)) { if (IS_PINEVIEW(dev)) {
...@@ -5667,14 +5678,13 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc) ...@@ -5667,14 +5678,13 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
struct drm_crtc *crtc) struct drm_crtc *crtc)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
struct drm_display_mode *mode; struct drm_display_mode *mode;
int htot = I915_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B); int htot = HTOTAL(pipe);
int hsync = I915_READ((pipe == 0) ? HSYNC_A : HSYNC_B); int hsync = HSYNC(pipe);
int vtot = I915_READ((pipe == 0) ? VTOTAL_A : VTOTAL_B); int vtot = VTOTAL(pipe);
int vsync = I915_READ((pipe == 0) ? VSYNC_A : VSYNC_B); int vsync = VSYNC(pipe);
mode = kzalloc(sizeof(*mode), GFP_KERNEL); mode = kzalloc(sizeof(*mode), GFP_KERNEL);
if (!mode) if (!mode)
...@@ -5783,7 +5793,7 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc) ...@@ -5783,7 +5793,7 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc)
drm_i915_private_t *dev_priv = dev->dev_private; drm_i915_private_t *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; int dpll_reg = DPLL(pipe);
int dpll = I915_READ(dpll_reg); int dpll = I915_READ(dpll_reg);
if (HAS_PCH_SPLIT(dev)) if (HAS_PCH_SPLIT(dev))
...@@ -6164,7 +6174,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, ...@@ -6164,7 +6174,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
* pf = I915_READ(pipe == 0 ? PFA_CTL_1 : PFB_CTL_1) & PF_ENABLE; * pf = I915_READ(pipe == 0 ? PFA_CTL_1 : PFB_CTL_1) & PF_ENABLE;
*/ */
pf = 0; pf = 0;
pipesrc = I915_READ(pipe == 0 ? PIPEASRC : PIPEBSRC) & 0x0fff0fff; pipesrc = I915_READ(PIPESRC(pipe)) & 0x0fff0fff;
OUT_RING(pf | pipesrc); OUT_RING(pf | pipesrc);
break; break;
...@@ -6174,8 +6184,8 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, ...@@ -6174,8 +6184,8 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
OUT_RING(fb->pitch | obj->tiling_mode); OUT_RING(fb->pitch | obj->tiling_mode);
OUT_RING(obj->gtt_offset); OUT_RING(obj->gtt_offset);
pf = I915_READ(pipe == 0 ? PFA_CTL_1 : PFB_CTL_1) & PF_ENABLE; pf = I915_READ(PF_CTL(pipe)) & PF_ENABLE;
pipesrc = I915_READ(pipe == 0 ? PIPEASRC : PIPEBSRC) & 0x0fff0fff; pipesrc = I915_READ(PIPESRC(pipe)) & 0x0fff0fff;
OUT_RING(pf | pipesrc); OUT_RING(pf | pipesrc);
break; break;
} }
...@@ -6945,6 +6955,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv) ...@@ -6945,6 +6955,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)
void intel_enable_clock_gating(struct drm_device *dev) void intel_enable_clock_gating(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
int pipe;
/* /*
* Disable clock gating reported to work incorrectly according to the * Disable clock gating reported to work incorrectly according to the
...@@ -7054,12 +7065,10 @@ void intel_enable_clock_gating(struct drm_device *dev) ...@@ -7054,12 +7065,10 @@ void intel_enable_clock_gating(struct drm_device *dev)
ILK_DPARB_CLK_GATE | ILK_DPARB_CLK_GATE |
ILK_DPFD_CLK_GATE); ILK_DPFD_CLK_GATE);
I915_WRITE(DSPACNTR, for_each_pipe(pipe)
I915_READ(DSPACNTR) | I915_WRITE(DSPCNTR(pipe),
DISPPLANE_TRICKLE_FEED_DISABLE); I915_READ(DSPCNTR(pipe)) |
I915_WRITE(DSPBCNTR, DISPPLANE_TRICKLE_FEED_DISABLE);
I915_READ(DSPBCNTR) |
DISPPLANE_TRICKLE_FEED_DISABLE);
} }
} else if (IS_G4X(dev)) { } else if (IS_G4X(dev)) {
uint32_t dspclk_gate; uint32_t dspclk_gate;
...@@ -7394,10 +7403,6 @@ void intel_modeset_init(struct drm_device *dev) ...@@ -7394,10 +7403,6 @@ void intel_modeset_init(struct drm_device *dev)
} }
dev->mode_config.fb_base = dev->agp->base; dev->mode_config.fb_base = dev->agp->base;
if (IS_MOBILE(dev) || !IS_GEN2(dev))
dev_priv->num_pipe = 2;
else
dev_priv->num_pipe = 1;
DRM_DEBUG_KMS("%d display pipe%s available.\n", DRM_DEBUG_KMS("%d display pipe%s available.\n",
dev_priv->num_pipe, dev_priv->num_pipe > 1 ? "s" : ""); dev_priv->num_pipe, dev_priv->num_pipe > 1 ? "s" : "");
......
...@@ -685,6 +685,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, ...@@ -685,6 +685,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int lane_count = 4, bpp = 24; int lane_count = 4, bpp = 24;
struct intel_dp_m_n m_n; struct intel_dp_m_n m_n;
int pipe = intel_crtc->pipe;
/* /*
* Find the lane count in the intel_encoder private * Find the lane count in the intel_encoder private
...@@ -715,39 +716,19 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, ...@@ -715,39 +716,19 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
mode->clock, adjusted_mode->clock, &m_n); mode->clock, adjusted_mode->clock, &m_n);
if (HAS_PCH_SPLIT(dev)) { if (HAS_PCH_SPLIT(dev)) {
if (intel_crtc->pipe == 0) { I915_WRITE(TRANSDATA_M1(pipe),
I915_WRITE(TRANSA_DATA_M1, ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) | m_n.gmch_m);
m_n.gmch_m); I915_WRITE(TRANSDATA_N1(pipe), m_n.gmch_n);
I915_WRITE(TRANSA_DATA_N1, m_n.gmch_n); I915_WRITE(TRANSDPLINK_M1(pipe), m_n.link_m);
I915_WRITE(TRANSA_DP_LINK_M1, m_n.link_m); I915_WRITE(TRANSDPLINK_N1(pipe), m_n.link_n);
I915_WRITE(TRANSA_DP_LINK_N1, m_n.link_n);
} else {
I915_WRITE(TRANSB_DATA_M1,
((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
m_n.gmch_m);
I915_WRITE(TRANSB_DATA_N1, m_n.gmch_n);
I915_WRITE(TRANSB_DP_LINK_M1, m_n.link_m);
I915_WRITE(TRANSB_DP_LINK_N1, m_n.link_n);
}
} else { } else {
if (intel_crtc->pipe == 0) { I915_WRITE(PIPE_GMCH_DATA_M(pipe),
I915_WRITE(PIPEA_GMCH_DATA_M, ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) | m_n.gmch_m);
m_n.gmch_m); I915_WRITE(PIPE_GMCH_DATA_N(pipe), m_n.gmch_n);
I915_WRITE(PIPEA_GMCH_DATA_N, I915_WRITE(PIPE_DP_LINK_M(pipe), m_n.link_m);
m_n.gmch_n); I915_WRITE(PIPE_DP_LINK_N(pipe), m_n.link_n);
I915_WRITE(PIPEA_DP_LINK_M, m_n.link_m);
I915_WRITE(PIPEA_DP_LINK_N, m_n.link_n);
} else {
I915_WRITE(PIPEB_GMCH_DATA_M,
((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
m_n.gmch_m);
I915_WRITE(PIPEB_GMCH_DATA_N,
m_n.gmch_n);
I915_WRITE(PIPEB_DP_LINK_M, m_n.link_m);
I915_WRITE(PIPEB_DP_LINK_N, m_n.link_n);
}
} }
} }
......
...@@ -178,7 +178,7 @@ static void intel_dvo_mode_set(struct drm_encoder *encoder, ...@@ -178,7 +178,7 @@ static void intel_dvo_mode_set(struct drm_encoder *encoder,
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
u32 dvo_val; u32 dvo_val;
u32 dvo_reg = intel_dvo->dev.dvo_reg, dvo_srcdim_reg; u32 dvo_reg = intel_dvo->dev.dvo_reg, dvo_srcdim_reg;
int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; int dpll_reg = DPLL(pipe);
switch (dvo_reg) { switch (dvo_reg) {
case DVOA: case DVOA:
......
...@@ -231,6 +231,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -231,6 +231,7 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
struct intel_lvds *intel_lvds = to_intel_lvds(encoder); struct intel_lvds *intel_lvds = to_intel_lvds(encoder);
struct drm_encoder *tmp_encoder; struct drm_encoder *tmp_encoder;
u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0; u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0;
int pipe;
/* Should never happen!! */ /* Should never happen!! */
if (INTEL_INFO(dev)->gen < 4 && intel_crtc->pipe == 0) { if (INTEL_INFO(dev)->gen < 4 && intel_crtc->pipe == 0) {
...@@ -283,8 +284,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, ...@@ -283,8 +284,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
* to register description and PRM. * to register description and PRM.
* Change the value here to see the borders for debugging * Change the value here to see the borders for debugging
*/ */
I915_WRITE(BCLRPAT_A, 0); for_each_pipe(pipe)
I915_WRITE(BCLRPAT_B, 0); I915_WRITE(BCLRPAT(pipe), 0);
switch (intel_lvds->fitting_mode) { switch (intel_lvds->fitting_mode) {
case DRM_MODE_SCALE_CENTER: case DRM_MODE_SCALE_CENTER:
......
...@@ -255,7 +255,7 @@ i830_activate_pipe_a(struct drm_device *dev) ...@@ -255,7 +255,7 @@ i830_activate_pipe_a(struct drm_device *dev)
return 0; return 0;
/* most i8xx have pipe a forced on, so don't trust dpms mode */ /* most i8xx have pipe a forced on, so don't trust dpms mode */
if (I915_READ(PIPEACONF) & PIPECONF_ENABLE) if (I915_READ(_PIPEACONF) & PIPECONF_ENABLE)
return 0; return 0;
crtc_funcs = crtc->base.helper_private; crtc_funcs = crtc->base.helper_private;
......
...@@ -1006,6 +1006,7 @@ intel_tv_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, ...@@ -1006,6 +1006,7 @@ intel_tv_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
const struct video_levels *video_levels; const struct video_levels *video_levels;
const struct color_conversion *color_conversion; const struct color_conversion *color_conversion;
bool burst_ena; bool burst_ena;
int pipe = intel_crtc->pipe;
if (!tv_mode) if (!tv_mode)
return; /* can't happen (mode_prepare prevents this) */ return; /* can't happen (mode_prepare prevents this) */
...@@ -1149,14 +1150,11 @@ intel_tv_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, ...@@ -1149,14 +1150,11 @@ intel_tv_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
((video_levels->black << TV_BLACK_LEVEL_SHIFT) | ((video_levels->black << TV_BLACK_LEVEL_SHIFT) |
(video_levels->blank << TV_BLANK_LEVEL_SHIFT))); (video_levels->blank << TV_BLANK_LEVEL_SHIFT)));
{ {
int pipeconf_reg = (intel_crtc->pipe == 0) ? int pipeconf_reg = PIPECONF(pipe);
PIPEACONF : PIPEBCONF; int dspcntr_reg = DSPCNTR(pipe);
int dspcntr_reg = (intel_crtc->plane == 0) ?
DSPACNTR : DSPBCNTR;
int pipeconf = I915_READ(pipeconf_reg); int pipeconf = I915_READ(pipeconf_reg);
int dspcntr = I915_READ(dspcntr_reg); int dspcntr = I915_READ(dspcntr_reg);
int dspbase_reg = (intel_crtc->plane == 0) ? int dspbase_reg = DSPADDR(pipe);
DSPAADDR : DSPBADDR;
int xpos = 0x0, ypos = 0x0; int xpos = 0x0, ypos = 0x0;
unsigned int xsize, ysize; unsigned int xsize, ysize;
/* Pipe must be off here */ /* Pipe must be off here */
......
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