Implemented my own method of finding the currently selected buffer
instead of using vram_get_number() (it doesn't seem to want to return
anything but -1 for me, i'm stumped). I used the
get_fastrefresh_422_buf() from Alex's tree which uses the DMA pointer
address to know which buffer is currently being used. The case
statement returns the unique vram_number of whatever buffer is being
used (as it's referred to in the vram_info[] array).
I found the dma pointer a while ago, see the link below for more 500d
vram information (all of my findings are there).
/
************************************************************************
\
* *
* get_fastrefresh_422_buf() *
* *
* A way to keep track of what vram buffer is currently being used *
* by watching the DMA pointer which always points to the buffer *
* being used currently. Took this from Alex's branch of ML zebra.c *
* *
* For more vram information see: *
*
http://magiclantern.wikia.com/wiki/500d_VRAM_Info *
* *
* Replaces AJ's method of calling vram_get_number(2) - didn't work *
* for me on the 500d for some reason. *
* *
* - Coutts *
* *
\************************************************************************/
void* get_fastrefresh_422_buf()
{
//////////////////////////////////////////////////////////////////////////////////
//////////////////////// COUTTS //////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// 0x26a8 updates at roughly 10fps pointing to a new buffer. //
// Each return value is verified to make sure vram->vram_number
corresponds //
// correctly with each buffer address's "number" in which it's
referred to. //
//////////////////////////////////////////////////////////////////////////////////
switch ( (*(uint32_t*)0x26a8) )
{
// first buffer in vram_info array
case 0x41B07800:
return 0; // number = 0 in vram_info array from vram.h
// second buffer
case 0x43738800:
return 1; // number = 1 in vram_info array from vram.h
// third buffer
// maybe not used? oh well, include it anyways.
case 0x43B48800:
return 2; // number = 2 in array.
}
return 0;
} /* end of get_fastrefresh_422_buf() */
/
****************************************************************************
*
aj_update_vram_n_bmp_global_variables()
*
*
*
* Returns: 0 = FAILED to get video
variables *
* 1 =
SUCCESS *
*
*
****************************************************************************/
extern unsigned int aj_update_vram_n_bmp_global_variables(void)
{
g_vram_bank = get_fastrefresh_422_buf();
struct vram_info *vram = &vram_info[g_vram_bank]; // raw Vram
bank 0 or 1
g_bmp_base_addr = (unsigned int) bmp_vram();
if ( (g_bmp_base_addr == 0) || ( (g_bmp_base_addr & 3) > 0) )
{
return( 0 ); // Failed to define global vars -
don't use aj_lib!
}
This seems to work well - the histogram is drawing very smooth now,
and if I print the value of the vram struct:
bmp_printf( FONT_MED, 0, 180, "off_0x00 vram_addr: %x", vram->vram );
bmp_printf( FONT_MED, 0, 200, "off_0x04 vram_width: %d", vram-
>pitch );
bmp_printf( FONT_MED, 0, 220, "off_0x08 vram_pitch: %d", vram-
>width );
bmp_printf( FONT_MED, 0, 240, "off_0x0c vram_height: %d", vram-
>height );
bmp_printf( FONT_MED, 0, 260, "off_0x10 vram_number: %d", vram-
>vram_number );
I can see the vram_addr and vram_number values changing with the dma
address. This suggests that this method seems to be working well :)
I would like to implement this with the HD buffer's DMA pointer.
Homework:
- find struct location of HD vram and use HD vram dma pointer 0x48a0
in same manner as here.
AJ - what do you think? :) Please correct anything that seems to be
wrong (volatile, void, int, etc etc).