I may be able to help with this, i worked with the 500d audio chip a lot last year. Is there a factory documentation for the audio chip? This is what I used when working on the 500d as it tells you exactly what registers to modify for certain features.
Here's some tips:
more here:
https://bitbucket.org/hudson/magic-lantern/src/77f7db1f8a6e/platform/500D.111/audio.c.500d_under_construction.c
Here's some tips:
Code Select
static inline void
audio_ic_set_mgain(
unsigned mgain
)
{
unsigned sig1 = audio_ic_read( AUDIO_IC_SIG1 ); // Read the value of register 'Signal Select 1', store it in sig1.
// We will use this later when we set individual bits on/off for
// different gain values.
unsigned sig2 = audio_ic_read( AUDIO_IC_SIG2 ); // Read the value of register 'Signal Select 2', store it in sig2.
// Setting the bits for each possible gain setting in the 500d, individually so it's easy to understand.
// - 24 hours ago I didn't even understand how to configure the audio chip, so I think this is pretty good
// for my first implemenation :)
//
// Basically, different gain settings use different combinations of the MGAIN0, MGAIN1, MGAIN2, and MGAIN3 bits being set/cleared.
// Here's a reference table for the settings, taken from the pdf linked from line 201 above:
//
//---------------------------------------------------------
// MGAIN3 | MGAIN2 | MGAIN1 | MGAIN0 || Gain Value
//---------------------------------------------------------
// 0 | 0 | 0 | 0 || 0 dB
// 0 | 0 | 0 | 1 || +20 dB (default setting)
// 0 | 0 | 1 | 0 || +26 dB
// 0 | 0 | 1 | 1 || +32 dB
// 0 | 1 | 0 | 0 || +10 dB
// 0 | 1 | 0 | 1 || +17 dB
// 0 | 1 | 1 | 0 || +23 dB
// 0 | 1 | 1 | 1 || +29 dB
// 1 | 0 | 0 | 0 || +3 dB
// 1 | 0 | 0 | 1 || +6 dB
//---------------------------------------------------------
//
// So my switch statement below looks at the value of the mgain variable (which is changed by the gain setting in the ML menu),
// and sets the correct combination of bits accordingly.
//
// &= ~(1 << x) means clear bit x
// |= 1 << x means set bit x
//
// That should be enough to bring anybody up to speed on things.
// -Coutts
switch (mgain)
{
case 0: // 0 dB
sig1 &= ~(1 << 0); //clear bit1 [MGAIN0] in register 'Signal Select 1'
sig1 &= ~(1 << 1); //clear bit2 [MGAIN2] "
sig1 &= ~(1 << 3); //clear bit3 [MGAIN3] "
sig2 &= ~(1 << 5); //clear bit4 [MGAIN1] in register 'Signal Select 2'
break;
case 1: // 3 dB
sig1 &= ~(1 << 0); //clear MGAIN0
sig1 &= ~(1 << 1); //clear MGAIN2
sig1 |= 1 << 3; //set MGAIN3
sig2 &= ~(1 << 5); //clear MGAIN1
break;
more here:
https://bitbucket.org/hudson/magic-lantern/src/77f7db1f8a6e/platform/500D.111/audio.c.500d_under_construction.c