How to correctly configure audio data transfer from i2s to Android apps?

@EvgenSen I have made the following modifications on my end, connecting to external codes and using the APK recording I uploaded is no problem. The following is the corresponding log information.

device/khadas$ git diff
diff --git a/kvim4/files/mixer_paths.xml b/kvim4/files/mixer_paths.xml
index 38f94cf..236adf8 100644
--- a/kvim4/files/mixer_paths.xml
+++ b/kvim4/files/mixer_paths.xml
@@ -38,7 +38,7 @@
   </path>
 
   <path name="main_mic">
-    <ctl name="TDMIN_B source select" value="acodec_adc" />
+    <ctl name="TDMIN_B source select" value="tdmin_b" />
   </path>
 
   <path name="headset-mic">
hardware/amlogic/audio$ git diff
diff --git a/utils/alsa_device_parser.c b/utils/alsa_device_parser.c
index bf0a110..c86b697 100644
--- a/utils/alsa_device_parser.c
+++ b/utils/alsa_device_parser.c
@@ -447,11 +447,12 @@ int alsa_device_update_pcm_index(int alsaPORT, int stream)
        if (pADD)
                new_port = pADD->mPcmIndex;
 
-       ALOGD("auge sound card, pAdd=%p fix alsaPORT:%d to :%d\n",pADD, alsaPORT, new_port);
+       ALOGD("hlm--00---auge sound card, pAdd=%p fix alsaPORT:%d to :%d\n",pADD, alsaPORT, new_port);
        /* dump_alsa_device_desc(p_info); */
        //Set MIC to PDM
        if(alsaPORT == PORT_BUILTINMIC){
-               new_port = 3;
+               new_port = 1;
+               ALOGD("hlm-----auge sound card, pAdd=%p fix alsaPORT:%d to :%d\n",pADD, alsaPORT, new_port);
        }
06-20 07:45:10.279   397   474 I audio_hw_primary: ++[adev_set_audio_port_config:9539] audio_port id:2, role:SINK, type:DEVICE
06-20 07:45:10.279   397   474 I audio_hw_primary: patch found mix->dev patch id:1, sink id:2, patchset:0xf2700010
06-20 07:45:10.279   397   474 I audio_hw_primary:  - set sink device[0x2](outport:SPEAKER): volume_Mb[-3200], gain[0.025119]
06-20 07:45:10.279   397   474 I audio_hw_primary:  - now the sink gains are:
06-20 07:45:10.279   397   474 I audio_hw_primary:      - OUTPORT_SPEAKER->gain[0.025119]
06-20 07:45:10.279   397   474 I audio_hw_primary:      - OUTPORT_HDMI_ARC->gain[1.000000]
06-20 07:45:10.279   397   474 I audio_hw_primary:      - OUTPORT_HEADPHONE->gain[1.000000]
06-20 07:45:10.279   397   474 I audio_hw_primary:      - OUTPORT_HDMI->gain[1.000000]
06-20 07:45:10.279   397   474 I audio_hw_primary:      - OUTPORT_ANLG_DOCK_HEADSET->gain[1.000000]
06-20 07:45:10.279   397   474 I audio_hw_primary:      - active outport is: SPEAKER
06-20 07:45:10.281   397  2317 I audio_hw_primary: ++++[usecase_change_validate_l:7666],continuous:0 dev masks:0,out masks:0,out usecase:PCM_NORMAL,aml_out:0xf4740fa0
06-20 07:45:10.281   397  2317 I audio_hw_primary: [usecase_change_validate_l:7712],1 process_buffer_write
06-20 07:45:10.281   397  2317 I audio_hw_primary: ----[usecase_change_validate_l:7741], continuous:0 dev masks:0x1, out masks:0x1, out usecase:PCM_NORMAL
06-20 07:45:10.281   397  2317 I audio_hw_primary: process_buffer_write(), standby to unstandby
06-20 07:45:10.281   397  2317 D audio_hw_utils: aml_audio_data_handle remaining_size:8192,  out->audio_data_handle_status:1
06-20 07:45:10.281   397  2317 D audio_hw_utils: aml_audio_data_handle  detected the nonzero data, remaining_size:8192  detected_size:0
06-20 07:45:10.281   397  2317 D audio_hw_utils: aml_audio_data_handle remaining_size:8192,  out->audio_data_handle_status:3
06-20 07:45:10.281   397  2317 D audio_hw_utils: aml_audio_data_handle remaining_size:8192,  out->audio_data_handle_status:4
06-20 07:45:10.281   677  2903 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
06-20 07:45:10.281   397  2317 D audio_hw_utils: aml_audio_data_handle remaining_size:8192,  out->audio_data_handle_status:5
06-20 07:45:10.281   397   474 D audio_hw_primary: adev_get_input_buffer_size: enter: channel_mask(0x10) rate(44100) format(0x1)
06-20 07:45:10.281   397   474 D audio_hw_primary: check_input_parameters(sample_rate=44100, format=1, channel_count=1, devices = 0)
06-20 07:45:10.282   397   474 D audio_hw_primary: adev_get_input_buffer_size: exit: buffer_size = 1881
06-20 07:45:10.282   397  2317 D audio_hw_utils: aml_audio_data_handle  easing_time:42, audio_stream_ease->ease_time:40
06-20 07:45:10.282   677  2903 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
06-20 07:45:10.284   397  2317 I audio_hw_primary: hw_write, aml_out 0xf4740fa0 alsa open output_format 0x1
06-20 07:45:10.284   397  2317 I audio_hw_primary:
06-20 07:45:10.284   397  2317 I audio_hw_primary: +aml_alsa_output_open stream 0xf4740fa0,device 0
06-20 07:45:10.284   397  2317 I audio_hw_primary: aml_alsa_output_open pcm 0x0
06-20 07:45:10.284   397  2317 D AudioALSADeviceParser: hlm--00---auge sound card, pAdd=0xf2541410 fix alsaPORT:0 to :1
06-20 07:45:10.284   397  2317 I audio_hw_primary: aml_alsa_output_open, audio open card(0), device(1)
06-20 07:45:10.284   397  2317 I audio_hw_primary: ALSA open configs: channels 8 format 1 period_count 6 period_size 512 rate 48000
06-20 07:45:10.284   397  2317 I audio_hw_primary: ALSA open configs: threshold start 0 stop 0 silence 0 silence_size 0 avail_min 0
06-20 07:45:10.284   397  2317 I audio_hw_primary: pcm_open: flag = 0, card = 0, device = 1
06-20 07:45:10.287     0     0 I [  280.596106@6]  audio_ddr_mngr: frddrs[0] registered by device fe330000.audiobus:tdm@1
06-20 07:45:10.287   425   524 W ServiceManager: Permission failure: android.permission.CAPTURE_AUDIO_OUTPUT from uid=10062 pid=4790
06-20 07:45:10.287   425   524 D PermissionCache: checking android.permission.CAPTURE_AUDIO_OUTPUT for uid=10062 => denied (527 us)
06-20 07:45:10.289   425   524 W ServiceManager: Permission failure: android.permission.CAPTURE_AUDIO_HOTWORD from uid=10062 pid=4790
06-20 07:45:10.289   425   524 D PermissionCache: checking android.permission.CAPTURE_AUDIO_HOTWORD for uid=10062 => denied (385 us)
06-20 07:45:10.290   397   474 D audio_hw_primary: adev_open_input_stream: enter: devices(0x80000004) channel_mask(0x10) rate(48000) format(0x3) source(1)
06-20 07:45:10.290   397   474 D audio_hw_primary: check_input_parameters(sample_rate=48000, format=3, channel_count=1, devices = 80000004)
06-20 07:45:10.290   397   474 D audio_hw_primary: adev_open_input_stream: exit
06-20 07:45:10.291   397   474 D audio_hw_primary: in_get_buffer_size: enter: channel_mask(0x10) rate(48000) format(0x3)
06-20 07:45:10.291   397   474 D audio_hw_primary: in_get_buffer_size: exit: buffer_size = 4096
06-20 07:45:10.292   397   474 D audio_hw_primary: in_get_buffer_size: enter: channel_mask(0x10) rate(48000) format(0x3)
06-20 07:45:10.292   397   474 D audio_hw_primary: in_get_buffer_size: exit: buffer_size = 4096
06-20 07:45:10.292   425  4901 I AudioFlinger: AudioFlinger's thread 0xb4000074f72a1040 tid=4901 ready to run
06-20 07:45:10.292   397   474 D audio_hw_primary: in_standby: enter: stream(0xf1344a50)
06-20 07:45:10.292   397   474 D audio_hw_primary: do_input_standby(0xf1344a50) in->standby = 1
06-20 07:45:10.292   397   474 D audio_hw_primary: in_standby: exit
06-20 07:45:10.296   397   474 D audio_hw_primary: in_standby: enter: stream(0xf1344a50)
06-20 07:45:10.296   397   474 D audio_hw_primary: do_input_standby(0xf1344a50) in->standby = 1
06-20 07:45:10.296   397   474 D audio_hw_primary: in_standby: exit
06-20 07:45:10.296   677  2903 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
06-20 07:45:10.296   677  2903 I chatty  : uid=1000(system) Binder:677_E identical 1 line
06-20 07:45:10.297   677  2903 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
06-20 07:45:10.310   397   474 I audio_hw_primary: [adev_create_audio_patch:8912] sources:1 sinks:1 DEVICE->MIX new id:2 patch_src:INVAL
06-20 07:45:10.310   397   474 I audio_hw_primary: aml_audio_input_routing: switch from TUNER to BUILTIN_MIC
06-20 07:45:10.310   397   474 D audio_route: Apply path: main_mic
06-20 07:45:10.311   397   474 I audio_hw_primary: [adev_create_audio_patch:9103] dev(BUILTIN_MIC) -> mix(38) patch, patch_src:INVAL, in dev:0x80000004
06-20 07:45:10.311  1601  1802 D UEventObserver: change@/devices/platform/auge_sound/sound/card0/controlC0纮ACTION=change纮DEVPATH=/devices/platform/auge_sound/sound/card0/controlC0纮SUBSYSTEM=sound纮AUDIO_FORMAT=0纮MAJOR=116纮MINOR=15纮DEVNAME=snd/controlC0纮SEQNUM=3720纮
06-20 07:45:10.311   677  4412 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
06-20 07:45:10.312     0     0 I         : [  280.621219@5]  update audio atmos flag! audio_type = 0
06-20 07:45:10.312   677  4412 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
06-20 07:45:10.318   677  2192 I SoundTriggerMiddlewareLogging: setCaptureState[this=com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl@665d3ac, caller=1041/425](true)
06-20 07:45:10.319   397   474 E FMQ     : grantorIdx must be less than 3
06-20 07:45:10.319   397   474 E FMQ     : grantorIdx must be less than 3
06-20 07:45:10.320   425  4901 E FMQ     : grantorIdx must be less than 3
06-20 07:45:10.320   425  4901 E FMQ     : grantorIdx must be less than 3
06-20 07:45:10.320   397  4904 D AudioALSADeviceParser: hlm--00---auge sound card, pAdd=0xf2540970 fix alsaPORT:11 to :3
06-20 07:45:10.320   397  4904 D AudioALSADeviceParser: hlm-----auge sound card, pAdd=0xf2540970 fix alsaPORT:11 to :1
06-20 07:45:10.320   397  4904 D audio_hw_primary: *start_input_stream, open alsa_card(0 11) alsa_device(1), in_device:0x4
06-20 07:45:10.320   397  4904 I audio_hw_primary: pcm_open: flag = 10000018, card = 0, device = 1
06-20 07:45:10.352     0     0 D [  280.661176@4]  audio_ddr_mngr: toddrs[0] registered by device fe330000.audiobus:tdm@1
06-20 07:45:10.354   397  2317 I audio_hw_primary: -aml_alsa_output_open, audio out(0xf4740fa0) device(0) refs(1) is_normal_pcm 1, handle 0xf4602860
06-20 07:45:10.354   397  2317 I audio_hw_primary:
06-20 07:45:10.354   397  2317 I audio_hw_primary: +aml_alsa_output_open, adev->pcm_handle[0] 0xf4602860
06-20 07:45:10.357     0     0 I [  280.662916@6]  aml_set_tdm_mclk: set mpll_freq: 491520000
06-20 07:45:10.357     0     0 D         : [  280.662960@6]  set mclk:12288000, mpll:491520000, get mclk:12287939, mpll:491517535
06-20 07:45:10.357     0     0 D         : [  280.662969@6]  aml_tdm_set_fmt...0x4011, id(1), clksel(1)
06-20 07:45:10.357     0     0 I         : [  280.662984@6]  master_mode(1), binv(1), finv(1) out_skew(2), in_skew(3)
06-20 07:45:10.357     0     0 D         : [  280.663740@6]  dump_pcm_setting...(0000000000000000)
06-20 07:45:10.357     0     0 D         : [  280.663747@6]     pcm_mode(1)
06-20 07:45:10.357     0     0 D         : [  280.663753@6]     sysclk(12288000)
06-20 07:45:10.357     0     0 D         : [  280.663758@6]     sysclk_bclk_ratio(4)
06-20 07:45:10.357     0     0 D         : [  280.663764@6]     bclk(3072000)
06-20 07:45:10.357     0     0 D         : [  280.663770@6]     bclk_lrclk_ratio(64)
06-20 07:45:10.358     0     0 D         : [  280.663775@6]     lrclk(48000)
06-20 07:45:10.358     0     0 D         : [  280.663781@6]     tx_mask(0x3)
06-20 07:45:10.358     0     0 D         : [  280.663787@6]     rx_mask(0x3)
06-20 07:45:10.358     0     0 D         : [  280.663792@6]     slots(2)
06-20 07:45:10.358     0     0 D         : [  280.663798@6]     slot_width(32)
06-20 07:45:10.358     0     0 D         : [  280.663804@6]     lane_mask_in(0xf)
06-20 07:45:10.358     0     0 D         : [  280.663809@6]     lane_mask_out(0xf)
06-20 07:45:10.358     0     0 I [  280.663815@6]  aml_set_tdm_mclk: set mpll_freq: 491520000
06-20 07:45:10.358     0     0 D         : [  280.664374@6]  set mclk:12288000, mpll:491520000, get mclk:12287939, mpll:491517535
06-20 07:45:10.358     0     0 D         : [  280.664381@6]  aml_tdm_set_clkdiv, div 4, clksel(1)
06-20 07:45:10.358     0     0 D         : [  280.664388@6]  aml_set_bclk_ratio, select I2S mode
06-20 07:45:10.358     0     0 I [  280.664434@4]  aml_set_tdm_mclk: set mpll_freq: 491520000
06-20 07:45:10.358     0     0 D         : [  280.665439@4]  set mclk:12288000, mpll:491520000, get mclk:12287939, mpll:491517535
06-20 07:45:10.358     0     0 D         : [  280.665448@4]  aml_tdm_set_fmt...0x4011, id(1), clksel(1)
06-20 07:45:10.358     0     0 I         : [  280.665460@4]  master_mode(1), binv(1), finv(1) out_skew(2), in_skew(3)
06-20 07:45:10.358     0     0 D         : [  280.666209@4]  dump_pcm_setting...(0000000000000000)
06-20 07:45:10.358     0     0 D         : [  280.666216@4]     pcm_mode(1)
06-20 07:45:10.358     0     0 D         : [  280.666278@4]     sysclk(12288000)
06-20 07:45:10.358     0     0 D         : [  280.666285@4]     sysclk_bclk_ratio(4)
06-20 07:45:10.358     0     0 D         : [  280.666290@4]     bclk(3072000)
06-20 07:45:10.358     0     0 D         : [  280.666296@4]     bclk_lrclk_ratio(64)
06-20 07:45:10.358     0     0 D         : [  280.666301@4]     lrclk(48000)
06-20 07:45:10.358     0     0 D         : [  280.666307@4]     tx_mask(0x3)
06-20 07:45:10.358     0     0 D         : [  280.666312@4]     rx_mask(0x3)
06-20 07:45:10.358     0     0 D         : [  280.666317@4]     slots(2)
06-20 07:45:10.356   397  4904 D audio_hw_primary: pcm_open in: card(0), port(11)
06-20 07:45:10.356   397  4904 D audio_hw_primary: start_input_stream: device(4) channels=1 period_size=1024 rate=48000 requested_rate=48000 mode= 0
06-20 07:45:10.358     0     0 D         : [  280.666323@4]     slot_width(32)
06-20 07:45:10.358     0     0 D         : [  280.666328@4]     lane_mask_in(0xf)
06-20 07:45:10.358     0     0 D         : [  280.666334@4]     lane_mask_out(0xf)
06-20 07:45:10.358     0     0 I [  280.666341@4]  aml_set_tdm_mclk: set mpll_freq: 491520000
06-20 07:45:10.358     0     0 D         : [  280.666520@4]  set mclk:12288000, mpll:491520000, get mclk:12287939, mpll:491517535
06-20 07:45:10.358     0     0 D         : [  280.666526@4]  aml_tdm_set_clkdiv, div 4, clksel(1)
06-20 07:45:10.358     0     0 D         : [  280.666534@4]  aml_set_bclk_ratio, select I2S mode
06-20 07:45:10.358     0     0 D         : [  280.666570@6]  aml_tdm_prepare(), reset fddr
06-20 07:45:10.358     0     0 D         : [  280.666593@6]  dump_pcm_setting...(0000000000000000)
06-20 07:45:10.358     0     0 D         : [  280.666599@6]     pcm_mode(1)
06-20 07:45:10.358     0     0 D         : [  280.666604@6]     sysclk(12288000)
06-20 07:45:10.358     0     0 D         : [  280.666610@6]     sysclk_bclk_ratio(4)
06-20 07:45:10.358     0     0 D         : [  280.666615@6]     bclk(3072000)
06-20 07:45:10.358     0     0 D         : [  280.666621@6]     bclk_lrclk_ratio(64)
06-20 07:45:10.358     0     0 D         : [  280.666626@6]     lrclk(48000)
06-20 07:45:10.358     0     0 D         : [  280.666631@6]     tx_mask(0x3)
06-20 07:45:10.358     0     0 D         : [  280.666637@6]     rx_mask(0x3)
06-20 07:45:10.358     0     0 D         : [  280.666673@6]     slots(2)
06-20 07:45:10.358     0     0 D         : [  280.666679@6]     slot_width(32)
06-20 07:45:10.359     0     0 D         : [  280.666685@6]     lane_mask_in(0xf)
06-20 07:45:10.359     0     0 D         : [  280.666690@6]     lane_mask_out(0xf)
06-20 07:45:10.359     0     0 I [  280.666697@6]  aml_set_tdm_mclk: set mpll_freq: 491520000
06-20 07:45:10.359     0     0 D         : [  280.667181@6]  set mclk:12288000, mpll:491520000, get mclk:12287939, mpll:491517535
06-20 07:45:10.359     0     0 D         : [  280.667187@6]  aml_tdm_set_clkdiv, div 4, clksel(1)
06-20 07:45:10.359     0     0 D         : [  280.667194@6]  aml_set_bclk_ratio, select I2S mode
06-20 07:45:10.359     0     0 D         : [  280.667207@6]  ss_prepare() 245, lvl 1
06-20 07:45:10.359     0     0 D         : [  280.667217@6]  spdif_a fifo ctrl, frddr:0 type:3, 32 bits, chmask 0xff, swap 0x10
06-20 07:45:10.359     0     0 D [  280.667229@6]  iec_info: rate: 48000, codec_type:0x0, channel status L:0x2000100, R:0x2000100
06-20 07:45:10.359     0     0 D [  280.667244@6]  audio_ddr_mngr: frddr_set_sharebuffer_enable share lvl: 1, dst_src: 3
06-20 07:45:10.359     0     0 D         : [  280.667252@6]  ss_prepare() 245, lvl 2
06-20 07:45:10.359     0     0 D         : [  280.667260@6]  spdif_b fifo ctrl, frddr:0 type:3, 32 bits, chmask 0xff, swap 0x10
06-20 07:45:10.359     0     0 D [  280.667270@6]  iec_info: rate: 48000, codec_type:0x0, channel status L:0x2000100, R:0x2000100
06-20 07:45:10.359     0     0 D [  280.667278@6]  audio_ddr_mngr: frddr_set_sharebuffer_enable share lvl: 2, dst_src: 4
06-20 07:45:10.499   397  2317 I audio_hw_primary: aml_alsa_output_write alsa_running_status[0xf4740fa0] change from 0 to 1
06-20 07:45:10.499     0     0 D         : [  280.806676@6]  tdm playback mute: 0, lane_cnt = 4
06-20 07:45:10.499     0     0 D         : [  280.806718@4]  dump_pcm_setting...(0000000000000000)
06-20 07:45:10.499     0     0 D         : [  280.806724@4]     pcm_mode(1)
06-20 07:45:10.499     0     0 D         : [  280.806728@4]     sysclk(12288000)
06-20 07:45:10.499     0     0 D         : [  280.806733@4]     sysclk_bclk_ratio(4)
06-20 07:45:10.500     0     0 D         : [  280.806737@4]     bclk(3072000)
06-20 07:45:10.500     0     0 D         : [  280.806741@4]     bclk_lrclk_ratio(64)
06-20 07:45:10.500     0     0 D         : [  280.806745@4]     lrclk(48000)
06-20 07:45:10.500     0     0 D         : [  280.806749@4]     tx_mask(0x3)
06-20 07:45:10.500     0     0 D         : [  280.806753@4]     rx_mask(0x3)
06-20 07:45:10.500     0     0 D         : [  280.806757@4]     slots(2)
06-20 07:45:10.500     0     0 D         : [  280.806762@6]  asoc-aml-card auge_sound: TDM[1] Playback enable
06-20 07:45:10.500     0     0 D         : [  280.806767@4]     slot_width(32)
06-20 07:45:10.500     0     0 D         : [  280.806771@4]     lane_mask_in(0xf)
06-20 07:45:10.500     0     0 D         : [  280.806775@4]     lane_mask_out(0xf)
06-20 07:45:10.500     0     0 D         : [  280.806780@6]  ss_trigger() ss 3
06-20 07:45:10.500     0     0 I [  280.806784@4]  aml_set_tdm_mclk: set mpll_freq: 491520000
06-20 07:45:10.500     0     0 D         : [  280.806793@4]  set mclk:12288000, mpll:491520000, get mclk:12287939, mpll:491517535
06-20 07:45:10.500     0     0 D         : [  280.806812@4]  aml_tdm_set_clkdiv, div 4, clksel(1)
06-20 07:45:10.500     0     0 D         : [  280.806815@6]  spdif_a is set to enable
06-20 07:45:10.500     0     0 D         : [  280.806821@4]  aml_set_bclk_ratio, select I2S mode
06-20 07:45:10.500     0     0 D         : [  280.806824@6]  ss_trigger() ss 4
06-20 07:45:10.500     0     0 D         : [  280.806828@6]  spdif_b is set to enable
06-20 07:45:10.500     0     0 I         : [  280.806835@4]  asoc-aml-card auge_sound: tdm prepare capture
06-20 07:45:10.500     0     0 D         : [  280.806942@6]  ss_mute() 363, mute 0, id 0
06-20 07:45:10.500     0     0 D         : [  280.807473@6]  ss_mute() 363, mute 0, id 1
06-20 07:45:10.500     0     0 D         : [  280.807487@4]  tdm capture mute: 0
06-20 07:45:10.500     0     0 I         : [  280.807509@4]  asoc-aml-card auge_sound: TDM[1] Capture enable
06-20 07:45:10.735   677  4412 I system_server: oneway function results will be dropped but finished with status OK and parcel size 4
06-20 07:45:10.735   425   520 W APM::AudioPolicyEngine: getDevicesForStrategy() unknown strategy: -1
1 Like