diff --git a/src/i810_reg.h b/src/i810_reg.h index d799e77..1d4cdac 100644 --- a/src/i810_reg.h +++ b/src/i810_reg.h @@ -383,6 +383,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define DMA_FADD_S 0x20d4 #define INST_DONE_1 0x207c +#define CCID0 0x2180 +#define CCID1 0x2184 +#define CCID2 0x2188 + #define CACHE_MODE_0 0x2120 #define CACHE_MODE_1 0x2124 #define MI_MODE 0x209c diff --git a/src/i830.h b/src/i830.h index 1319c6a..f7ae8c9 100644 --- a/src/i830.h +++ b/src/i830.h @@ -424,6 +424,7 @@ typedef struct _I830Rec { CreateScreenResourcesProcPtr CreateScreenResources; i830_memory *logical_context; + i830_memory *tmp_context; #ifdef XF86DRI i830_memory *back_buffer; diff --git a/src/i830_driver.c b/src/i830_driver.c index b0bb9da..b4af39a 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -2332,6 +2332,8 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); uint32_t ctx_addr; + uint32_t *ctx = (uint32_t *)((unsigned long)pI830->FbBase + (unsigned long)pI830->tmp_context->offset); + int i; if (pI830->noAccel) return; @@ -2354,14 +2356,53 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn) ctx_addr = pI830->logical_context->offset; assert((pI830->logical_context->offset & 2047) == 0); + + ErrorF("initializing context\n"); + { + BEGIN_BATCH(2); + OUT_BATCH(MI_SET_CONTEXT); + OUT_BATCH(pI830->logical_context->offset | CTXT_NO_RESTORE | + CTXT_PALETTE_RESTORE_DISABLE); + ADVANCE_BATCH(); + } + I830Sync(pScrn); + + if (!IS_I965G(pI830)) + { + if (IS_I9XX(pI830)) + I915EmitInvarientState(pScrn); + else + I830EmitInvarientState(pScrn); + } + + ErrorF("saving to tmp context\n"); + { + BEGIN_BATCH(2); + OUT_BATCH(MI_SET_CONTEXT); + OUT_BATCH(pI830->tmp_context->offset | CTXT_NO_RESTORE | + CTXT_PALETTE_RESTORE_DISABLE); + ADVANCE_BATCH(); + } + I830Sync(pScrn); + + ErrorF("CCID0: 0x%08x\n", INREG(CCID0)); + ErrorF("CCID1: 0x%08x\n", INREG(CCID1)); + ErrorF("CCID2: 0x%08x\n", INREG(CCID2)); + + ErrorF("loading logical context\n"); { BEGIN_BATCH(2); OUT_BATCH(MI_SET_CONTEXT); OUT_BATCH(pI830->logical_context->offset | CTXT_NO_RESTORE | - CTXT_PALETTE_SAVE_DISABLE | CTXT_PALETTE_RESTORE_DISABLE); + CTXT_PALETTE_RESTORE_DISABLE); ADVANCE_BATCH(); } + I830Sync(pScrn); + + ErrorF("CCID0: 0x%08x\n", INREG(CCID0)); + ErrorF("CCID1: 0x%08x\n", INREG(CCID1)); + ErrorF("CCID2: 0x%08x\n", INREG(CCID2)); if (!IS_I965G(pI830)) { @@ -2370,6 +2411,23 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn) else I830EmitInvarientState(pScrn); } + + ErrorF("tmp context:"); + for (i = 0; i < 2048/4; i++) { + if ((i % 7) == 0) + ErrorF("\n"); + ErrorF("0x%08x ", ctx[i]); + } + ErrorF("\n"); + + ctx = pI830->FbBase + pI830->logical_context->offset; + ErrorF("logical context:"); + for (i = 0; i < 2048/4; i++) { + if ((i % 7) == 0) + ErrorF("\n"); + ErrorF("0x%08x ", ctx[i]); + } + ErrorF("\n"); } static void diff --git a/src/i830_memory.c b/src/i830_memory.c index a38ee78..be5cfd8 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -1366,6 +1366,15 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn) return FALSE; } + /* Space for the X Server's 3D context. 32k is fine for right now. */ + pI830->tmp_context = i830_allocate_memory(pScrn, "tmp 3D context", + KB(32), GTT_PAGE_SIZE, 0); + if (pI830->tmp_context == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Failed to allocate logical context space.\n"); + return FALSE; + } + /* even in XAA, 965G needs state mem buffer for rendering */ if (IS_I965G(pI830) && !pI830->noAccel && pI830->exa_965_state == NULL) { pI830->exa_965_state =