600D Audio Controls?

Started by testaevisual, June 17, 2012, 06:16:10 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

miyake

added override menu. incl prev. diff

And sometime get stack ML when I override audio config at startup.
Need more tune.



diff -r 4fdf51b053f0 src/audioki.c
--- a/src/audioki.c     Sat Jul 28 02:37:01 2012 +0200
+++ b/src/audioki.c     Sat Jul 28 13:52:53 2012 +0900
@@ -56,6 +56,7 @@


// Set defaults
+CONFIG_INT( "audio.override_audio",      cfg_override_audio,          0 );
CONFIG_INT( "audio.mgain",      mgain,          4 );
CONFIG_INT( "audio.dgain.l",    dgain_l,        0 );
CONFIG_INT( "audio.dgain.r",    dgain_r,        0 );
@@ -1169,45 +1170,36 @@
}

void
-reset_audio_setting(int phase){
+override_audio_setting(int phase){
+
+    if(cfg_override_audio == 0) return;

        //These audio_ic_write are setting back to startup time.
        //Because, the canon firmware will switching off the audio switchs I guess,it's for power save
     switch(phase){
-               case 0:
-                       //for startup
-                       audio_ic_write(ML_PW_ZCCMP_PW_MNG | 0x02);
-                       audio_ic_write(ML_MIC_TIM | 0x12);
-                       audio_ic_write(ML_EQ_GAIN_BRAND0 | 0xdd);
-                       audio_ic_write(ML_EQ_GAIN_BRAND1 | 0xdd);
-                       audio_ic_write(ML_HPF2_CUTOFF | 0x04);
-                       audio_ic_write(ML_EQBRAND0_F0L | 0x0d);
-                       audio_ic_write(ML_EQBRAND0_F0H | 0xdb);
-                       audio_ic_write(ML_EQBRAND0_F1L | 0x0c);
-                       audio_ic_write(ML_EQBRAND0_F1H | 0x1b);
-                       audio_ic_write(ML_EQBRAND1_F0L | 0x6d);
-                       audio_ic_write(ML_EQBRAND1_F0H | 0x08);
-                       audio_ic_write(ML_EQBRAND1_F1L | 0x41);
-                       audio_ic_write(ML_EQBRAND1_F1H | 0xed);
-                       audio_ic_write(ML_NODOC_E5 | 0x06);
-
-               case 1:
-
-                       audio_ic_write(ML_REC_PLYBAK_RUN | 0x11); //
-                       audio_ic_write(ML_PW_IN_PW_MNG | 0x0a);   //DAC(0010) and PGA(1000) power on
-
-                       audio_ic_write(ML_DVOL_CTL | 0x2E);        //All(Play,Capture,DigitalVolFade,DigitalVol) switched on
-                       audio_ic_write(ML_PW_MIC_IN_VOL | 0x3f);
-                       audio_ic_write(ML_PW_MIC_BOST_VOL | 0x10);
-                       audio_ic_write(ML_PW_AMP_VOL_FUNC | 0x01);
-                       audio_ic_write(ML_FILTER_EN | 0x0f);       //All filter on
-                       audio_ic_write(ML_MIXER_VOL_CTL | 0x10);
-                       break;
+    case 0:   //Phase 0 for camera powerON->standby
+        audio_ic_write(ML_NODOC_E5 | 0x02); //Duplicate L to R
+
+    case 1: //Phase 1 for finish recording->standy & change vol setting->standby
+        audio_ic_write(ML_REC_PLYBAK_RUN | 0x11); //
+        audio_ic_write(ML_PW_IN_PW_MNG | 0x0a);   //DAC(0010) and PGA(1000) power on
+        audio_ic_write(ML_DVOL_CTL | 0x2E);        //All(Play,Capture,DigitalVolFade,DigitalVol) switched on
+        audio_ic_write(ML_PW_MIC_IN_VOL | 0x3f);
+        audio_ic_write(ML_FILTER_EN | 0x0f);       //All filter on
+
+        int inputsource = get_input_source();
+        if(inputsource == 0){ //int/int
+            audio_ic_write(ML_MIC_SELECT | 0x01);
+            audio_ic_write(ML_NODOC_E5 | 0x02); //Duplicate L to R
+        }else if(inputsource == 2){
+            audio_ic_write(ML_MIC_SELECT | 0x02);
+            audio_ic_write(ML_NODOC_E5 | 0x00);
+        }
     }
}


-struct msg_queue * reset_audio_q = NULL;
+struct msg_queue * override_audio_q = NULL;
short gIs_UnInitialized = 0;
//#endif

@@ -1229,15 +1221,14 @@
         #else*/
//miyake code #ifdef CONFIG_600D
        int msg;
-       int err = msg_queue_receive(reset_audio_q, (struct event**)&msg, 500);
+       int err = msg_queue_receive(override_audio_q, (struct event**)&msg, 500);
        if (!err){
-               reset_audio_setting(1);
+               override_audio_setting(1);
        }

        if(gIs_UnInitialized < 3){
-               msleep(500);
-               reset_audio_setting(0);
-               //              disp_logoutput("reset audio");
+               msleep(700);
+        if(gIs_UnInitialized == 2) override_audio_setting(0);
                gIs_UnInitialized++;
        }

@@ -1670,6 +1661,26 @@
  }
  */

+char onoff[2][4];
+static void override_audio_display( void * priv, int x, int y, int selected )
+{
+    memset(&onoff[0],'\0',4);
+    strcpy(&onoff[0],"OFF");
+    memset(&onoff[1],'\0',4);
+    strcpy(&onoff[1],"ON");
+    bmp_printf(
+               selected ? MENU_FONT_SEL : MENU_FONT,
+               x, y,
+               "Override Setting : %s",
+               onoff[cfg_override_audio]
+               );
+}
+static void override_audio_toggle( void * priv, int delta )
+{
+    menu_numeric_toggle(priv, 1, 0, 1);
+    override_audio_setting(0);
+}
+
int get_mic_type()
{
     int type_source;
@@ -1758,6 +1769,7 @@

                   "error"))))))))))))));
}
+
static void mic_in_display( void * priv, int x, int y, int selected )
{
     bmp_printf(
@@ -1937,6 +1949,14 @@
static struct menu_entry audio_menus[] = {

        {
+        .name        = "Override audio",
+        .priv           = &cfg_override_audio,
+        .select         = override_audio_toggle,
+        .select_reverse = override_audio_toggle,
+        .display        = override_audio_display,
+        .help = "override ",
+    },
+       {
         .name        = "Analog Gains",
         .select        = menu_open_submenu,
         .help = "Volumes for Mic and Amp.",
@@ -2283,11 +2303,14 @@
         case 0:
             // Movie recording stopped;  (fallthrough)
#ifdef CONFIG_600D
-                       reset_audio_setting(1);
+                       override_audio_setting(1);
#endif
                case 2:
             // Movie recording started
             give_semaphore( gain.sem );
+#ifdef CONFIG_600D
+            override_audio_setting(1);
+#endif
             break;
         case 1:
             // Movie recording about to start?
@@ -2815,10 +2838,14 @@

PROP_HANDLER( PROP_AUDIO_VOL_CHANGE_600D )
{
-    /* Cannot overwrite audio config here!
-        Cannon firmware is overwrite after finishing here.
-
+    /* Cannot override audio config here!
+        Cannon firmware is override after finishing here.
         */
+    if(!override_audio_q)
+    override_audio_q = (struct msg_queue *) msg_queue_create("override_audio_q", 1);
+
+    msg_queue_post(override_audio_q, 1);
+
}

PROP_HANDLER( PROP_PLAYMODE_LAUNCH_600D )
@@ -2831,4 +2858,4 @@



-#endif
\ No newline at end of file
+#endif

vk2

I would be happy to test anything that you come with related to 600D, and thank you for your hard work

miyake

scrax, I send a pull request to you.

This patch is solved stacking on startup issue maybe. Please test it.

And mic_in is sometime confusing, So I cleanup variable names. and function name.

--
TODO:
-add each audio configration (vol,boost,amp vol,and so on), in final part in audio_configure()
Then we can perfectly override audio configs.

miyake

scrax:
Just added overwrite mic_vol/mic_boost/amp_vol.
and working fine!!!
pull it.


1%:
your code has mic_type. What is it? I guess it means mic_input_select. right?

scrax

working Will try tonigh
Added it on my fork, looks like it's working so far. Now time for more test...
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

1%

Per the ALSA driver there are 3 types of mics. In practice this moved L or R around.

I.e. if you have R only on the external selected, you can move it to L with mic type.

miyake

Just remember it!
Thank you.

/* Input mux */
static const char * const ml26124_input_select[] = {"Analog MIC in",
     "Digital MIC in"};

static const struct soc_enum ml26124_insel_enum +   SOC_ENUM_SINGLE(ML26124_MIC_IF_CTL, 0, 1, ml26124_inpu\
t_select);


Alsa has only 2 entry which is "Analog MIC in" and "Digital MIC in".
Can you understand what mean is these mics?

1%

There are a few different registers for mic select and mic type.


static const char * const ml26124_input_select[] = {"Analog MIC SingleEnded in",
            "Digital MIC in", "Analog MIC Differential in"};

static const struct soc_enum ml26124_insel_enum =
   SOC_ENUM_SINGLE(ML26124_MIC_IF_CTL, 0, 3, ml26124_input_select);


I think one analog is internal, one is external and one is "digital" so output from the mixer maybe?

Do you have an older version of the driver?

miyake

Just mearged analog gains to single menu.

----

1%
I saw a alsa driver website which is you let me konw.

miyake

Quote from: 1% on July 28, 2012, 10:19:34 PM
Per the ALSA driver there are 3 types of mics. In practice this moved L or R around.

I.e. if you have R only on the external selected, you can move it to L with mic type.


hmmm, I'm tested 6entry of mic type, but it's not move LR around.

I found LR or only  L,R is
/* Undocumented Canon Registers */
#define ML_NODOC_E5  0xe500 /* While playing? Val:'06' '07' */
#define ML_NODOC_E5_INLR 0x0002
#define ML_NODOC_E5_INL  0x0003
#define ML_NODOC_E5_INR  0x0004

But these are not routing , just ON/OFF for LR. I guess

1%

http://git.alsa-project.org/?p=alsa-kernel.git;a=blob_plain;f=sound/soc/codecs/ml26124.c;hb=HEAD
http://git.alsa-project.org/?p=alsa-kernel.git;a=blob_plain;f=sound/soc/codecs/ml26124.h;hb=HEAD


Those are the latest. I probably sent the wrong version. Try both with internal and external plugged in. Sometimes a mic type doesn't work for internal but then works when external is plugged in an vice versa.

Everything works in combination.

Also you're putting stuff through the EQ and setting stereo by default. That changes things too. If you put internal mic on L/R you can't move it around anymore because its on both channels. We should make a chart of input/type and whether external is plugged in.

Also

#define ML_MIC_TIM         0x1500 /* Mic Input/Output control */

says input/OUTPUT for mic but its always 12 for us so I wonder what other settings do.


miyake

Quote from: 1% on July 29, 2012, 02:47:19 AM
http://git.alsa-project.org/?p=alsa-kernel.git;a=blob_plain;f=sound/soc/codecs/ml26124.c;hb=HEAD
http://git.alsa-project.org/?p=alsa-kernel.git;a=blob_plain;f=sound/soc/codecs/ml26124.h;hb=HEAD


Those are the latest. I probably sent the wrong version. Try both with internal and external plugged in. Sometimes a mic type doesn't work for internal but then works when external is plugged in an vice versa.

Everything works in combination.

Also you're putting stuff through the EQ and setting stereo by default. That changes things too. If you put internal mic on L/R you can't move it around anymore because its on both channels. We should make a chart of input/type and whether external is plugged in.

Also

#define ML_MIC_TIM         0x1500 /* Mic Input/Output control */

says input/OUTPUT for mic but its always 12 for us so I wonder what other settings do.


Thankyou, I just added mic differential in. and tried to ML_MIC_TIM by PTP .But I cant find any difference from 00-3f..
You said , stereo/mono things, I'm still not clearly understand it. How to change stereo/mono setting? Do you already know it?

1%


scrax

I have something strange, when setting volumes value ML will start to keep changing value like if arrow button is still pressed when it's not.
To stop it pressing q will go to ML menu and it will change quickly each menu still thinking that an arrow is pressed, pressing arrow in other direction once stops it.


EDIT: update to miyake latest, in Mic Type option I need to press twice SET for changing from Analog Mic differential to the next type.

EDIT2: Found the problem and fixed, how many mic type are we supposed to have? from what I understand we have 7 mictype:
int mictype[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x06, 0x07 }; 
and we can chose 4 of them from the menu:
static void mic_type_toggle( void * priv, int delta )
{
    //   menu_quinternary_toggle(priv, 1);
    menu_numeric_toggle(priv, 1, 0, 3);
    audio_configure( 1 );
}


I've changed this to have a name for each type:

static void mic_type_display( void * priv, int x, int y, int selected )
{
    bmp_printf(
               selected ? MENU_FONT_SEL : MENU_FONT,
               x, y,
               "Mic Type  : %s",
               (cfg_mic_type == 0 ? "Analog Mic SingleEmb" :
                (cfg_mic_type == 1 ? "Digital Mic" :
(cfg_mic_type == 2 ? "Analog Mic Differential" :
  "Another Type?")))
               );
    check_sound_recording_warning(x, y);
    //        menu_draw_icon(x, y, input_choice == 4 ? MNI_AUTO : MNI_ON, 0);
}


Digital Mic and "Another Type?" are not working with internal mic

EDIT3: Just found out that after a beep audio meter are not working. I was making screenshot to the audio menu with meter on and the beep killed audio.
switching override off and on worked to restart all.

here the screenshot:


EDIT4: I've added all the mictype selectable and so far: Digital Mic, mictype 03 and mictype 07 are not showing audio bar moving, other type (00, 02, 04, 06) show stereo audiobars.
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

Alia5

 tested with the source of scrax

when i tried to change my input source the camera went crazy... magic lantern menu scrolled from left to right extremely fast and camera didn't respond to any button...

anyone else expirienced this? o.O

scrax

Quote from: Alia5 on July 29, 2012, 02:42:05 PM
tested with the source of scrax

when i tried to change my input source the camera went crazy... magic lantern menu scrolled from left to right extremely fast and camera didn't respond to any button...

anyone else expirienced this? o.O
yes I had it before last changes, try again.
I stopped it going to the opposite direction, not sure what is
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

miyake

Actually mic type is only 3. It's described in alsa driver(ml26124.c).
see this.
static const char * const ml26124_input_select[]

But we need to discover which register value is those types.


Also, Input select is not working fine. When I discover this reg, I can actually select inputs. So I think more combination register needed.


miyake


scrax

added it right now, I can't use it so far..
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

miyake

Thanks!
It's very easy, I'm start using PTP from 4days ago.

1%

Just call audio IC write by address with PTP thats the easiest.


Quote
Also, Input select is not working fine. When I discover this reg, I can actually select inputs. So I think more combination register needed.



Yea, can't isolate internal mic when external is plugged in. So there is definitely more that goes into it.

Also take a register dump after the beep and we'll see what got flipped.

miyake

Yhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!!!!!!!
Now I just facing Lint Rext on 600D!


But I don't know how to do this.
Anyway, current commited my repo and manually config by hand will take effect.
It's biggest hint for this!



dump when Lint/Rext
ML_SMPLING_RATE 08
ML_PLLNL 96
ML_PLLNH 00
ML_PLLML 00
ML_PLLMH 03
ML_PLLDIV 05
ML_CLK_EN 0f
ML_CLK_CTL 04
ML_SW_RST 00
ML_REC_PLYBAK_RUN 11
ML_MIC_TIM 12
ML_PW_REF_PW_MNG 06
ML_PW_IN_PW_MNG 0a
ML_PW_DAC_PW_MNG 00
ML_PW_SPAMP_PW_MNG 00
ML_PW_LOUT_PW_MNG 00
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N 70
ML_PLYBAK_BOST_VOL 10
ML_PL_0CROSS_TIMOUT 00
ML_NODOC_E1 01
ML_NODOC_E3 00
ML_NODOC_E5 07

scrax

merged in your last commits, now need to go to work, good job! :)
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

miyake

now need to sleep. Already finished Sunday. hmmm.
Good night.

1%

Yea, I could get Lint/Rext a while ago. And ext L/R and Ext/R but never int L/R while external is plugged in.


You have problems moving the mic because of E1/E5 and setting that on startup.  I got external and internal on 1 channel together and external separate and intL ExtR plus ext R. I should make a better video but you can see a little in this one.