author | Lawrence Mok <lawrence.mok@amlogic.com> | 2013-12-03 22:45:24 (GMT) |
---|---|---|
committer | Lawrence Mok <lawrence.mok@amlogic.com> | 2013-12-03 22:45:24 (GMT) |
commit | 1cf2edd8b5692546d2c2a5fdea7308cd2137fadf (patch) | |
tree | c10ea2411a102dd205b6ecfc3dd9caa80e6833b8 | |
parent | 3f350c3aa5847cb7f2c1cd6e32c254eff4eb40ed (diff) | |
parent | c6acdf726b11e8c7447ec4505f6320f49c606aba (diff) | |
download | audio-1cf2edd8b5692546d2c2a5fdea7308cd2137fadf.zip audio-1cf2edd8b5692546d2c2a5fdea7308cd2137fadf.tar.gz audio-1cf2edd8b5692546d2c2a5fdea7308cd2137fadf.tar.bz2 |
Merge remote-tracking branch 'amlogic/jb-mr2-amlogic' into kk-amlogic
-rwxr-xr-x | audio_hw.c | 1 | ||||
-rwxr-xr-x | hdmi_audio_hw.c | 97 | ||||
-rwxr-xr-x | m8codec_mixer_paths.xml | 16 |
3 files changed, 100 insertions, 14 deletions
@@ -672,6 +672,7 @@ static int do_output_standby(struct aml_stream_out *out) /* FIXME: only works if only one output can be active at a time */ reset_mixer_state(adev->ar); + update_mixer_state(adev->ar); } /* stop writing to echo reference */ diff --git a/hdmi_audio_hw.c b/hdmi_audio_hw.c index 7c9cb40..e5b2e5b 100755 --- a/hdmi_audio_hw.c +++ b/hdmi_audio_hw.c @@ -331,13 +331,80 @@ static int check_output_stream(struct aml_stream_out *out) return 0; } +static int get_aml_card(){ + int card = -1, err = 0; + int fd = -1; + unsigned fileSize = 512; + char *read_buf = NULL, *pd = NULL; + static const char *const SOUND_CARDS_PATH = "/proc/asound/cards"; + fd = open(SOUND_CARDS_PATH, O_RDONLY); + if (fd < 0) { + ALOGE("ERROR: failed to open config file %s error: %d\n", SOUND_CARDS_PATH, errno); + close(fd); + return -EINVAL; + } + + read_buf = (char *)malloc(fileSize); + if (!read_buf) { + ALOGE("Failed to malloc read_buf"); + close(fd); + return -ENOMEM; + } + memset(read_buf, 0x0, fileSize); + err = read(fd, read_buf, fileSize); + if (fd < 0) { + ALOGE("ERROR: failed to read config file %s error: %d\n", SOUND_CARDS_PATH, errno); + close(fd); + return -EINVAL; + } + pd = strstr(read_buf, "AML"); + card = *(pd - 3) - '0'; + +OUT: + free(read_buf); + close(fd); + return card; +} +static int get_spdif_port(){ + int port = -1, err = 0; + int fd = -1; + unsigned fileSize = 512; + char *read_buf = NULL, *pd = NULL; + static const char *const SOUND_PCM_PATH = "/proc/asound/pcm"; + fd = open(SOUND_PCM_PATH, O_RDONLY); + if (fd < 0) { + ALOGE("ERROR: failed to open config file %s error: %d\n", SOUND_PCM_PATH, errno); + close(fd); + return -EINVAL; + } + read_buf = (char *)malloc(fileSize); + if (!read_buf) { + ALOGE("Failed to malloc read_buf"); + close(fd); + return -ENOMEM; + } + memset(read_buf, 0x0, fileSize); + err = read(fd, read_buf, fileSize); + if (fd < 0) { + ALOGE("ERROR: failed to read config file %s error: %d\n", SOUND_PCM_PATH, errno); + close(fd); + return -EINVAL; + } + pd = strstr(read_buf, "SPDIF"); + port = *(pd -3) - '0'; + +OUT: + free(read_buf); + close(fd); + return port; +} /* must be called with hw device and output stream mutexes locked */ static int start_output_stream(struct aml_stream_out *out) { struct aml_audio_device *adev = out->dev; - unsigned int card = CARD_AMLOGIC_DEFAULT; - unsigned int port = PORT_MM; + int card = CARD_AMLOGIC_DEFAULT; + int port = PORT_MM; int ret=0; adev->active_output = out; @@ -348,19 +415,21 @@ static int start_output_stream(struct aml_stream_out *out) } LOGFUNC("%s(adev->out_device=%#x, adev->mode=%d)", __FUNCTION__, adev->out_device, adev->mode); - card = CARD_AMLOGIC_BOARD; - port = PORT_MM; - LOGFUNC("------------open on board audio-------"); + card = get_aml_card(); + if(card < 0 ){ + ALOGE("hdmi get aml card id failed \n"); + card = CARD_AMLOGIC_DEFAULT; + } + port = get_spdif_port(); + if(port < 0 ){ + ALOGE("hdmi get aml card port failed \n"); + card = PORT_MM; + } + ALOGI("hdmi sound card id %d,device id %d \n",card,port); + LOGFUNC("------------open on board audio-------"); if(getprop_bool("media.libplayer.wfd")){ - // PERIOD_SIZE = DEFAULT_PERIOD_SIZE/2; - out->config.period_size = PERIOD_SIZE; - // - // } - // else{ - // PERIOD_SIZE = DEFAULT_PERIOD_SIZE; - // out->config.period_size = PERIOD_SIZE; - } - out->config.rate = MM_FULL_POWER_SAMPLING_RATE; + out->config.period_size = PERIOD_SIZE; + } /* default to low power: will be corrected in out_write if necessary before first write to * tinyalsa. */ diff --git a/m8codec_mixer_paths.xml b/m8codec_mixer_paths.xml new file mode 100755 index 0000000..2ece7c9 --- a/dev/null +++ b/m8codec_mixer_paths.xml @@ -0,0 +1,16 @@ +<mixer> + <ctl name="Amp Spk enable" value="0" /> + <path name="speaker"> + <ctl name="Amp Spk enable" value="1" /> + </path> + + <path name="headphone"> + <ctl name="Amp Spk enable" value="0" /> + </path> + + <path name="main_mic"> + </path> + + <path name="headset-mic"> + </path> +</mixer> |