On Sun, 3 Mar 2013 14:01:35 +0100 Denis 'GNUtoo' Carikli GNUtoo@no-log.org wrote:
So here's the code: int dspbase = (plane == 0 ? DSPABASE : DSPBBASE); [...] int dspstride = (plane == 0) ? DSPASTRIDE : DSPBSTRIDE; [...] Stride = pScrn->displayWidth * pI830->cpp; [...] OUTREG(dspstride, Stride); [...] OUTREG(dspbase, Start + Offset);
The problem is how to replace Start + Offset, the code is quite complicated and I can't probably run it since it probably requires an old userspace.
So I followed a bit the code but gave up yesterday night(very late) here: /* Allocate aperture space for the given size and alignment, and returns the * memory allocation. * * Allocations are a minimum of a page, and will be at least page-aligned. */ static i830_memory * i830_allocate_aperture(ScrnInfoPtr pScrn, const char *name, unsigned long size, unsigned long pitch, unsigned long alignment, int flags, enum tile_format tile_format) { [...] for (scan = pI830->memory_list; scan->next != NULL; scan = scan->next) { mem->offset = ROUND_TO(scan->end, alignment); if ((flags & NEED_PHYSICAL_ADDR) && mem->offset < pI830->stolen_size) { /* If the allocation is entirely within stolen memory, and we're * able to get the physical addresses out of the GTT and check that * it's contiguous (it ought to be), then we can do our physical * allocations there and not bother the kernel about it. This * helps avoid aperture fragmentation from our physical * allocations. */ mem->bus_addr = i830_get_stolen_physical(pScrn, mem->offset, mem->size);
if (mem->bus_addr == ((uint64_t)-1)) { /* Move the start of the allocation to just past the end of * stolen memory. */ mem->offset = ROUND_TO(pI830->stolen_size, alignment); } } if ((flags & NEED_NON_STOLEN) && mem->offset < pI830->stolen_size) { mem->offset = ROUND_TO(pI830->stolen_size, alignment); }
mem->end = mem->offset + size; if (flags & ALIGN_BOTH_ENDS) mem->end = ROUND_TO(mem->end, alignment); if (mem->end <= scan->next->offset) break; }
which is called by i830_allocate_memory(in i830_memory.c) which is called by(in i830_allocate_2d_memory in i830_memory.c) :
pI830->front_buffer = i830_allocate_framebuffer(pScrn, pI830, &pI830->FbMemBox, FALSE);
Then we have in i830PipeSetBase(in i830_display.c): Start = pI830->front_buffer->offset;
For the offset we have in the same file, same function: Offset = ((y * pScrn->displayWidth + x) * pI830->cpp); I don't know what does x and y represents, maybe they are 0?
Denis. So I followed a bit the code but gave up yesterday night(very late) here: /* Allocate aperture space for the given size and alignment, and returns the * memory allocation. * * Allocations are a minimum of a page, and will be at least page-aligned. */ static i830_memory * i830_allocate_aperture(ScrnInfoPtr pScrn, const char *name, unsigned long size, unsigned long pitch, unsigned long alignment, int flags, enum tile_format tile_format) { [...] for (scan = pI830->memory_list; scan->next != NULL; scan = scan->next) { mem->offset = ROUND_TO(scan->end, alignment); if ((flags & NEED_PHYSICAL_ADDR) && mem->offset < pI830->stolen_size) { /* If the allocation is entirely within stolen memory, and we're * able to get the physical addresses out of the GTT and check that * it's contiguous (it ought to be), then we can do our physical * allocations there and not bother the kernel about it. This * helps avoid aperture fragmentation from our physical * allocations. */ mem->bus_addr = i830_get_stolen_physical(pScrn, mem->offset, mem->size);
if (mem->bus_addr == ((uint64_t)-1)) { /* Move the start of the allocation to just past the end of * stolen memory. */ mem->offset = ROUND_TO(pI830->stolen_size, alignment); } } if ((flags & NEED_NON_STOLEN) && mem->offset < pI830->stolen_size) { mem->offset = ROUND_TO(pI830->stolen_size, alignment); }
mem->end = mem->offset + size; if (flags & ALIGN_BOTH_ENDS) mem->end = ROUND_TO(mem->end, alignment); if (mem->end <= scan->next->offset) break; }
which is called by i830_allocate_memory(in i830_memory.c) which is called by(in i830_allocate_2d_memory in i830_memory.c) :
pI830->front_buffer = i830_allocate_framebuffer(pScrn, pI830, &pI830->FbMemBox, FALSE);
Then we have in i830PipeSetBase(in i830_display.c): Start = pI830->front_buffer->offset;
For the offset we have in the same file, same function: Offset = ((y * pScrn->displayWidth + x) * pI830->cpp); I don't know what does x and y represents, maybe they are 0?
Denis.