Dear All;

Interra-3 home automation board audio system consist of PAM8620 amplifier,
and PH15 controls PA_Shutdown, and PH25 controls SPK_MUTE.

Thanks to gzamboni and Turl, I have been able to get sound from the speaker
outputs of Interra-3 board.

To achieve this, we need two modifications:

1) In the sys_config.fex, modify audio as follows:

[audio_para]
audio_used = 1
audio_pa_ctrl = port:PH15<1><default><default><0>
audio_mute_ctrl = port:PH25<1><default><default><0>

2) Apply below patch to sound/soc/sunxi-codec.c

--- sunxi-codec.c 2014-04-10 17:46:47.918544495 +0300
+++ sunxi-codec.c-CALISAN 2014-04-11 12:40:25.651389407 +0300
@@ -37,6 +37,7 @@
 #define SCRIPT_AUDIO_OK (0)
 static int has_playback, has_capture;
 static int gpio_pa_shutdown = 0;
+static int gpio_mute = 0; //[email protected] Interra-3 Board 10.4.2014
 struct clk *codec_apbclk,*codec_pll2clk,*codec_moduleclk;

 static volatile unsigned int capture_dmasrc = 0;
@@ -411,7 +412,12 @@
 static int codec_play_start(void)
 {
  if (gpio_pa_shutdown)
-  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
+  {
+  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("static int
CODEC_PLAY_START(void)\ngpio_write_one_pin_value(gpio_pa_shutdown, 0,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+   gpio_write_one_pin_value(gpio_mute, 1, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+ }
  //flush TX FIFO
  codec_wr_control(SUNXI_DAC_FIFOC ,0x1, DAC_FIFO_FLUSH, 0x1);
  //enable dac drq
@@ -423,7 +429,12 @@
 {
  //pa mute
  if (gpio_pa_shutdown)
-  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
+  {
+  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("static int
CODEC_PLAY_STOP(void)\ngpio_write_one_pin_value(gpio_pa_shutdown, 1,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+     gpio_write_one_pin_value(gpio_mute, 0, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+ }
  codec_wr_control(SUNXI_DAC_ACTL, 0x1, PA_MUTE, 0x0);
  mdelay(5);
  //disable dac drq
@@ -439,7 +450,12 @@
 {
  //enable adc drq
  if (gpio_pa_shutdown)
-  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
+  {
+  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("static int
CODEC_CAPTURE_START(void)\ngpio_write_one_pin_value(gpio_pa_shutdown, 0,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+       gpio_write_one_pin_value(gpio_mute, 1, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+ }
  codec_wr_control(SUNXI_ADC_FIFOC ,0x1, ADC_DRQ, 0x1);
  return 0;
 }
@@ -1442,10 +1458,16 @@
   codec_wr_control(SUNXI_DAC_ACTL, 0x1,  DACPAS, 0x1);
  }

- if (gpio_pa_shutdown) {
+ if (gpio_pa_shutdown)
+ {
   msleep(50);
-  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
+  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("static void CODEC_RESUME_EVENTS(struct work_struct
*work)\ngpio_write_one_pin_value(gpio_pa_shutdown, 0,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+       gpio_write_one_pin_value(gpio_mute, 1, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
  }
+
+
 }

 static int __devinit sunxi_codec_probe(struct platform_device *pdev)
@@ -1544,11 +1566,24 @@

   kfree(db);
   gpio_pa_shutdown = gpio_request_ex("audio_para", "audio_pa_ctrl");
- if (gpio_pa_shutdown)
-  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
+  gpio_mute = gpio_request_ex("audio_para", "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+ if (gpio_pa_shutdown){
+  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("static int __DEVINIT SUNXI_CODEC_PROBE(struct platform_device
*pdev)\ngpio_write_one_pin_value(gpio_pa_shutdown, 1,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+       gpio_write_one_pin_value(gpio_mute, 0, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+ }
+
+
+
+
   codec_init();
- if (gpio_pa_shutdown)
-  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
+ if (gpio_pa_shutdown){
+  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("222 static int __DEVINIT SUNXI_CODEC_PROBE(struct
platform_device *pdev)\ngpio_write_one_pin_value(gpio_pa_shutdown, 1,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+       gpio_write_one_pin_value(gpio_mute, 0, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+ }
   resume_work_queue = create_singlethread_workqueue("codec_resume");
   if (resume_work_queue == NULL) {
         printk("[su4i-codec] try to create workqueue for codec failed!\n");
@@ -1573,7 +1608,12 @@
 {
  printk("[audio codec]:suspend start5000\n");
  if (gpio_pa_shutdown) {
-  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
+  {
+  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("static int SND_SUNXI_CODEC_SUSPEND(struct platform_device
*pdev,pm_message_t state)\ngpio_write_one_pin_value(gpio_pa_shutdown, 1,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+       gpio_write_one_pin_value(gpio_mute, 0, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+  }
   mdelay(50);
  }
  codec_wr_control(SUNXI_ADC_ACTL, 0x1, PA_ENABLE, 0x0);
@@ -1628,7 +1668,12 @@
 static void sunxi_codec_shutdown(struct platform_device *devptr)
 {
  if (gpio_pa_shutdown) {
-  gpio_write_one_pin_value(gpio_pa_shutdown, 0, "audio_pa_ctrl");
+  {
+  gpio_write_one_pin_value(gpio_pa_shutdown, 1, "audio_pa_ctrl");
//[email protected] Interra-3 Board 8.4.2014
+  //printk("static void SUNXI_CODEC_SHUTDOWN(struct platform_device
*devptr)\ngpio_write_one_pin_value(gpio_pa_shutdown, 1,
\"audio_pa_ctrl\");\n"); //[email protected] Interra-3 Board 8.4.2014
+  if (gpio_mute) //[email protected] Interra-3 Board 10.4.2014
+       gpio_write_one_pin_value(gpio_mute, 0, "audio_mute_ctrl");
//[email protected] Interra-3 Board 10.4.2014
+  }
   mdelay(50);
  }
  codec_wr_control(SUNXI_ADC_ACTL, 0x1, PA_ENABLE, 0x0);


For testing, you can use: following under debian:   mpg321 some.mp3

Note: In my tests, I am now %100 sure that, gpio driver does not set
direction and values for GPIO pins, even you set them correctly in the FEX
file.

Many thanks, and Best Regards.

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to