summaryrefslogtreecommitdiff
path: root/src/i830_debug.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2006-12-06 11:59:33 -0800
committerEric Anholt <eric@anholt.net>2006-12-06 11:59:33 -0800
commitb75ecdb48309a15eb7c52b279c7f8523a95bcd48 (patch)
tree21e1079afa8dc6b907aeaa34e9e6050a105f648c /src/i830_debug.c
parent1cb6311c1182fe98d2b8d237cef42509c3178f9a (diff)
parentb3bb10e33e44c78f132d239e30931f97065a9fd6 (diff)
Merge branch 'generic-mode-set' into modesetting
Diffstat (limited to 'src/i830_debug.c')
-rw-r--r--src/i830_debug.c264
1 files changed, 221 insertions, 43 deletions
diff --git a/src/i830_debug.c b/src/i830_debug.c
index f7323891..b1902ffb 100644
--- a/src/i830_debug.c
+++ b/src/i830_debug.c
@@ -33,13 +33,163 @@
#include "i830.h"
#include "i830_debug.h"
+#define DEBUGSTRING(func) static char *func(I830Ptr pI830, int reg, CARD32 val)
+
+DEBUGSTRING(i830_debug_xyminus1)
+{
+ return XNFprintf("%d, %d", (val & 0xffff) + 1,
+ ((val & 0xffff0000) >> 16) + 1);
+}
+
+DEBUGSTRING(i830_debug_yxminus1)
+{
+ return XNFprintf("%d, %d", ((val & 0xffff0000) >> 16) + 1,
+ (val & 0xffff) + 1);
+}
+
+DEBUGSTRING(i830_debug_xy)
+{
+ return XNFprintf("%d, %d", (val & 0xffff),
+ ((val & 0xffff0000) >> 16));
+}
+
+DEBUGSTRING(i830_debug_dspstride)
+{
+ return XNFprintf("%d bytes", val);
+}
+
+DEBUGSTRING(i830_debug_dspcntr)
+{
+ char *enabled = val & DISPLAY_PLANE_ENABLE ? "enabled" : "disabled";
+ char plane = val & DISPPLANE_SEL_PIPE_B ? 'B' : 'A';
+ return XNFprintf("%s, pipe %c", enabled, plane);
+}
+
+DEBUGSTRING(i830_debug_pipeconf)
+{
+ char *enabled = val & PIPEACONF_ENABLE ? "enabled" : "disabled";
+ char *wide = val & PIPEACONF_DOUBLE_WIDE ? "double-wide" : "single-wide";
+ return XNFprintf("%s, %s", enabled, wide);
+}
+
+DEBUGSTRING(i830_debug_hvtotal)
+{
+ return XNFprintf("%d active, %d total", (val & 0xffff) + 1,
+ ((val & 0xffff0000) >> 16) + 1);
+}
+
+DEBUGSTRING(i830_debug_hvsyncblank)
+{
+ return XNFprintf("%d start, %d end", (val & 0xffff) + 1,
+ ((val & 0xffff0000) >> 16) + 1);
+}
+
+DEBUGSTRING(i830_debug_vgacntrl)
+{
+ return XNFprintf("%s", val & VGA_DISP_DISABLE ? "disabled" : "enabled");
+}
+
+DEBUGSTRING(i830_debug_fp)
+{
+ return XNFprintf("n = %d, m1 = %d, m2 = %d",
+ ((val & FP_N_DIV_MASK) >> FP_N_DIV_SHIFT),
+ ((val & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT),
+ ((val & FP_M2_DIV_MASK) >> FP_M2_DIV_SHIFT));
+}
+
+DEBUGSTRING(i830_debug_pp_status)
+{
+ char *status = val & PP_ON ? "on" : "off";
+ char *ready = val & PP_READY ? "ready" : "not ready";
+ char *seq = "unknown";
+
+ switch (val & PP_SEQUENCE_MASK) {
+ case PP_SEQUENCE_NONE:
+ seq = "idle";
+ break;
+ case PP_SEQUENCE_ON:
+ seq = "on";
+ break;
+ case PP_SEQUENCE_OFF:
+ seq = "off";
+ break;
+ }
+
+ return XNFprintf("%s, %s, sequencing %s", status, ready, seq);
+}
+
+DEBUGSTRING(i830_debug_pp_control)
+{
+ return XNFprintf("power target: %s",
+ val & POWER_TARGET_ON ? "on" : "off");
+}
+
+DEBUGSTRING(i830_debug_dpll)
+{
+ char *enabled = val & DPLL_VCO_ENABLE ? "enabled" : "disabled";
+ char *dvomode = val & DPLL_DVO_HIGH_SPEED ? "dvo" : "non-dvo";
+ char *vgamode = val & DPLL_VGA_MODE_DIS ? "" : ", VGA";
+ char *mode = "unknown";
+ char *clock = "unknown";
+ char *fpextra = val & DISPLAY_RATE_SELECT_FPA1 ? ", using FPx1!" : "";
+ char sdvoextra[3];
+ int p1, p2 = 0;
+
+ p1 = ffs((val & DPLL_FPA01_P1_POST_DIV_MASK) >>
+ DPLL_FPA01_P1_POST_DIV_SHIFT);
+ switch (val & DPLL_MODE_MASK) {
+ case DPLLB_MODE_DAC_SERIAL:
+ mode = "dac/serial";
+ p2 = val & DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 ? 5 : 10;
+ break;
+ case DPLLB_MODE_LVDS:
+ mode = "LVDS";
+ p2 = val & DPLLB_LVDS_P2_CLOCK_DIV_7 ? 7 : 14;
+ break;
+ }
+ switch (val & PLL_REF_INPUT_MASK) {
+ case PLL_REF_INPUT_DREFCLK:
+ clock = "default";
+ break;
+ case PLL_REF_INPUT_TVCLKINA:
+ clock = "TV A";
+ break;
+ case PLL_REF_INPUT_TVCLKINBC:
+ clock = "TV B/C";
+ break;
+ }
+ if (IS_I945G(pI830) || IS_I945GM(pI830)) {
+ sprintf(sdvoextra, "SDVO mult %d",
+ (int)(val & SDVO_MULTIPLIER_MASK) >>
+ SDVO_MULTIPLIER_SHIFT_HIRES);
+ } else {
+ sdvoextra[0] = '\0';
+ }
+
+ return XNFprintf("%s, %s%s, %s mode, %s clock, p1 = %d, "
+ "p2 = %d%s%s",
+ enabled, dvomode, vgamode, mode, clock, p1, p2,
+ fpextra, sdvoextra);
+}
+
+DEBUGSTRING(i830_debug_lvds)
+{
+ char pipe = val & LVDS_PIPEB_SELECT ? 'B' : 'A';
+ char *enable = val & LVDS_PORT_EN ? "enabled" : "disabled";
+
+ return XNFprintf("%s, pipe %c", enable, pipe);
+}
+
#define DEFINEREG(reg) \
- { reg, #reg, 0 }
+ { reg, #reg, NULL, 0 }
+#define DEFINEREG2(reg, func) \
+ { reg, #reg, func, 0 }
static struct i830SnapshotRec {
int reg;
char *name;
- CARD32 regval;
+ char *(*debug_output)(I830Ptr pI830, int reg, CARD32 val);
+ CARD32 val;
} i830_snapshot[] = {
DEFINEREG(VCLK_DIVISOR_VGA0),
DEFINEREG(VCLK_DIVISOR_VGA1),
@@ -61,7 +211,7 @@ static struct i830SnapshotRec {
DEFINEREG(DSPFW3),
DEFINEREG(ADPA),
- DEFINEREG(LVDS),
+ DEFINEREG2(LVDS, i830_debug_lvds),
DEFINEREG(DVOA),
DEFINEREG(DVOB),
DEFINEREG(DVOC),
@@ -69,63 +219,63 @@ static struct i830SnapshotRec {
DEFINEREG(DVOB_SRCDIM),
DEFINEREG(DVOC_SRCDIM),
- DEFINEREG(PP_CONTROL),
- DEFINEREG(PP_STATUS),
+ DEFINEREG2(PP_CONTROL, i830_debug_pp_control),
+ DEFINEREG2(PP_STATUS, i830_debug_pp_status),
DEFINEREG(PFIT_CONTROL),
DEFINEREG(PFIT_PGM_RATIOS),
DEFINEREG(PORT_HOTPLUG_EN),
DEFINEREG(PORT_HOTPLUG_STAT),
- DEFINEREG(DSPACNTR),
- DEFINEREG(DSPASTRIDE),
- DEFINEREG(DSPAPOS),
- DEFINEREG(DSPASIZE),
+ DEFINEREG2(DSPACNTR, i830_debug_dspcntr),
+ DEFINEREG2(DSPASTRIDE, i830_debug_dspstride),
+ DEFINEREG2(DSPAPOS, i830_debug_xy),
+ DEFINEREG2(DSPASIZE, i830_debug_xyminus1),
DEFINEREG(DSPABASE),
DEFINEREG(DSPASURF),
DEFINEREG(DSPATILEOFF),
- DEFINEREG(PIPEACONF),
- DEFINEREG(PIPEASRC),
+ DEFINEREG2(PIPEACONF, i830_debug_pipeconf),
+ DEFINEREG2(PIPEASRC, i830_debug_yxminus1),
- DEFINEREG(FPA0),
- DEFINEREG(FPA1),
- DEFINEREG(DPLL_A),
+ DEFINEREG2(FPA0, i830_debug_fp),
+ DEFINEREG2(FPA1, i830_debug_fp),
+ DEFINEREG2(DPLL_A, i830_debug_dpll),
DEFINEREG(DPLL_A_MD),
- DEFINEREG(HTOTAL_A),
- DEFINEREG(HBLANK_A),
- DEFINEREG(HSYNC_A),
- DEFINEREG(VTOTAL_A),
- DEFINEREG(VBLANK_A),
- DEFINEREG(VSYNC_A),
+ DEFINEREG2(HTOTAL_A, i830_debug_hvtotal),
+ DEFINEREG2(HBLANK_A, i830_debug_hvsyncblank),
+ DEFINEREG2(HSYNC_A, i830_debug_hvsyncblank),
+ DEFINEREG2(VTOTAL_A, i830_debug_hvtotal),
+ DEFINEREG2(VBLANK_A, i830_debug_hvsyncblank),
+ DEFINEREG2(VSYNC_A, i830_debug_hvsyncblank),
DEFINEREG(BCLRPAT_A),
DEFINEREG(VSYNCSHIFT_A),
- DEFINEREG(DSPBCNTR),
- DEFINEREG(DSPBSTRIDE),
- DEFINEREG(DSPBPOS),
- DEFINEREG(DSPBSIZE),
+ DEFINEREG2(DSPBCNTR, i830_debug_dspcntr),
+ DEFINEREG2(DSPBSTRIDE, i830_debug_dspstride),
+ DEFINEREG2(DSPBPOS, i830_debug_xy),
+ DEFINEREG2(DSPBSIZE, i830_debug_xyminus1),
DEFINEREG(DSPBBASE),
DEFINEREG(DSPBSURF),
DEFINEREG(DSPBTILEOFF),
- DEFINEREG(PIPEBCONF),
- DEFINEREG(PIPEBSRC),
+ DEFINEREG2(PIPEBCONF, i830_debug_pipeconf),
+ DEFINEREG2(PIPEBSRC, i830_debug_yxminus1),
- DEFINEREG(FPB0),
- DEFINEREG(FPB1),
- DEFINEREG(DPLL_B),
+ DEFINEREG2(FPB0, i830_debug_fp),
+ DEFINEREG2(FPB1, i830_debug_fp),
+ DEFINEREG2(DPLL_B, i830_debug_dpll),
DEFINEREG(DPLL_B_MD),
- DEFINEREG(HTOTAL_B),
- DEFINEREG(HBLANK_B),
- DEFINEREG(HSYNC_B),
- DEFINEREG(VTOTAL_B),
- DEFINEREG(VBLANK_B),
- DEFINEREG(VSYNC_B),
+ DEFINEREG2(HTOTAL_B, i830_debug_hvtotal),
+ DEFINEREG2(HBLANK_B, i830_debug_hvsyncblank),
+ DEFINEREG2(HSYNC_B, i830_debug_hvsyncblank),
+ DEFINEREG2(VTOTAL_B, i830_debug_hvtotal),
+ DEFINEREG2(VBLANK_B, i830_debug_hvsyncblank),
+ DEFINEREG2(VSYNC_B, i830_debug_hvsyncblank),
DEFINEREG(BCLRPAT_B),
DEFINEREG(VSYNCSHIFT_B),
DEFINEREG(VCLK_DIVISOR_VGA0),
DEFINEREG(VCLK_DIVISOR_VGA1),
DEFINEREG(VCLK_POST_DIV),
- DEFINEREG(VGACNTRL),
+ DEFINEREG2(VGACNTRL, i830_debug_vgacntrl),
DEFINEREG(TV_CTL),
DEFINEREG(TV_DAC),
@@ -171,7 +321,7 @@ void i830TakeRegSnapshot(ScrnInfoPtr pScrn)
int i;
for (i = 0; i < NUM_I830_SNAPSHOTREGS; i++) {
- i830_snapshot[i].regval = INREG(i830_snapshot[i].reg);
+ i830_snapshot[i].val = INREG(i830_snapshot[i].reg);
}
}
@@ -184,11 +334,28 @@ void i830CompareRegsToSnapshot(ScrnInfoPtr pScrn, char *where)
"Comparing regs from server start up to %s\n", where);
for (i = 0; i < NUM_I830_SNAPSHOTREGS; i++) {
CARD32 val = INREG(i830_snapshot[i].reg);
- if (i830_snapshot[i].regval != val) {
+ if (i830_snapshot[i].val == val)
+ continue;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Register 0x%x (%s) changed from 0x%08x to 0x%08x\n",
+ i830_snapshot[i].reg, i830_snapshot[i].name,
+ (int)i830_snapshot[i].val, (int)val);
+
+ if (i830_snapshot[i].debug_output != NULL) {
+ char *before, *after;
+
+ before = i830_snapshot[i].debug_output(pI830,
+ i830_snapshot[i].reg,
+ i830_snapshot[i].val);
+ after = i830_snapshot[i].debug_output(pI830,
+ i830_snapshot[i].reg,
+ val);
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Register 0x%x (%s) changed from 0x%08x to 0x%08x\n",
- i830_snapshot[i].reg, i830_snapshot[i].name,
- (int)i830_snapshot[i].regval, (int)val);
+ "%s before: %s\n", i830_snapshot[i].name, before);
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "%s after: %s\n", i830_snapshot[i].name, after);
+
}
}
}
@@ -220,8 +387,19 @@ void i830DumpRegs (ScrnInfoPtr pScrn)
xf86DrvMsg (pScrn->scrnIndex, X_INFO, "DumpRegsBegin\n");
for (i = 0; i < NUM_I830_SNAPSHOTREGS; i++) {
- xf86DrvMsg (pScrn->scrnIndex, X_INFO, "%20.20s: 0x%08x\n",
- i830_snapshot[i].name, (unsigned int) INREG(i830_snapshot[i].reg));
+ CARD32 val = INREG(i830_snapshot[i].reg);
+
+ if (i830_snapshot[i].debug_output != NULL) {
+ char *debug = i830_snapshot[i].debug_output(pI830,
+ i830_snapshot[i].reg,
+ val);
+ xf86DrvMsg (pScrn->scrnIndex, X_INFO, "%20.20s: 0x%08x (%s)\n",
+ i830_snapshot[i].name, (unsigned int)val, debug);
+ xfree(debug);
+ } else {
+ xf86DrvMsg (pScrn->scrnIndex, X_INFO, "%20.20s: 0x%08x\n",
+ i830_snapshot[i].name, (unsigned int)val);
+ }
}
i830DumpIndexed (pScrn, "SR", 0x3c4, 0x3c5, 0, 7);
msr = INREG8(0x3cc);