Update source to Armbian-dev-202610.A311Y3

This commit is contained in:
2026-11-11 08:50:43 +08:00
parent 3428a94f6b
commit f459ef6a9e
12514 changed files with 2264376 additions and 468481 deletions
@@ -32,7 +32,6 @@
#include <sys/time.h>
#include <inttypes.h>
#include "aml_audio_log.h"
#include "aml_audio_output.h"
#include "audio_hw.h"
#include "aml_dtsx_dec_api.h"
@@ -44,7 +43,6 @@
#include "aml_dts_chmask_table.h"
#include "aml_audio_property.h"
#include "format.h"
#include "aml_policy.h"
#define DTSX_LIB_PATH "/vendor/lib/libHwAudio_dtsx.so"
#define DTSX_LIB64_PATH "/vendor/lib64/libHwAudio_dtsx.so"
@@ -383,7 +381,6 @@ static int _dtsx_pcm_output(dtsx_dec_t *dtsx_dec)
{
aml_dec_t *aml_dec = (aml_dec_t *)dtsx_dec;
dec_data_info_t *dec_pcm_data = &aml_dec->dec_pcm_data;
struct aml_audio_device *adev = (struct aml_audio_device *)(aml_dec->dev);
int nSampleRate =0;
int nChannel =0;
int nBitWidth =0;
@@ -393,7 +390,6 @@ static int _dtsx_pcm_output(dtsx_dec_t *dtsx_dec)
if (dtsx_dec->sink_support_multich_pcm && dtsx_dec->core2_pcm_out_info.channel_num != 2) {
cur_dtsx_output_type = DTS_DSP2_OUTPUTBUS2;
}
struct aml_stream_out *aml_out = (struct aml_stream_out *)dtsx_dec->stream;
if (_aml_dts_postprocess_get_out_info2) {
int rc = _aml_dts_postprocess_get_out_info2(dtsx_dec->p_dtsx_pp_inst, cur_dtsx_output_type, &nSampleRate, &nChannel, &nBitWidth, &nChannelMask);
if (rc != 0) {
@@ -445,26 +441,11 @@ static int _dtsx_pcm_output(dtsx_dec_t *dtsx_dec)
}
memcpy(dec_pcm_data->buf, dtsx_dec->a_dtsx_pp_output[cur_dtsx_output_type], dtsx_dec->a_dtsx_pp_output_size[cur_dtsx_output_type]);
//for tv spdif/headphone pcm, use BUS2 dts data
if (is_TV(adev) && dtsx_dec->a_dtsx_pp_output_size[DTS_DSP2_OUTPUTBUS2] > 0) {
void *dec_data = (void *)dtsx_dec->a_dtsx_pp_output[DTS_DSP2_OUTPUTBUS2];
int pcm_len = dtsx_dec->a_dtsx_pp_output_size[DTS_DSP2_OUTPUTBUS2];
//dts source multi-sink output: headphone output here.
aml_policy_type stream_policy = aml_get_stream_policy(aml_out, AML_STREAM_STEREO_PORT);
if (AML_POLICY_TYPE_NORMAL == stream_policy || AML_POLICY_TYPE_HEADPHONE == stream_policy) {
struct audio_buffer abuffer_out = {0};
abuffer_out.format = AUDIO_FORMAT_PCM_16_BIT; //todo: if output 32bit
abuffer_out.sub_format = AUDIO_FORMAT_PCM_16_BIT;
abuffer_out.channel = 2;
abuffer_out.channel_mask = AUDIO_CHANNEL_OUT_STEREO;
abuffer_out.sample_rate = 48000;
abuffer_out.buffer = dec_data;
abuffer_out.size = pcm_len;
/*for dtsx lib, adev->spdif_rbuf data process volume here*/
apply_volume(aml_out->volume_l, dec_data, sizeof(int16_t), pcm_len);
aml_audio_spdif_pcm_out(adev, &abuffer_out);
}
}
/* Do not write BUS2 2ch into adev->spdif_rbuf here.
* MS12 already mixes DTS 2ch via stereo expand; non-MS12 already mixes
* DTS multi-ch into submix, so headphone/SPDIF PCM is covered by those paths.
* Non-MS12 headphone may later need BUS2 instead of submix; revisit then.
*/
if (get_dtsx_dump_enable(AML_DTSX_PROP_DUMP_OUTPUT_PCM)) {
char name[64] = {0};
@@ -1159,7 +1140,10 @@ void *dtsx_postprocess_threadloop(void *data)
dtsx_dec->core1_pcm_out_info.sample_rate, out_buf->data_len, resample_size, in_frames,
audio_bytes_per_sample(dec_pcm_data->data_format), last_ch);
}
aml_hw_mixer_mch_in_mixing(&adev->hw_mixer, resample_buf, in_frames, dec_pcm_data->data_format, last_ch);
/* MS12 expand mixes system sound internally; hw_mixer is not created in that path. */
if (!aml_out->ms12_expand_dts_handle) {
aml_hw_mixer_mch_in_mixing(&adev->hw_mixer, resample_buf, in_frames, dec_pcm_data->data_format, last_ch);
}
if (get_dtsx_dump_enable(AML_DTSX_PROP_DUMP_MIXED_PCM)) {
char name[64] = {0};
int sample_bytes = audio_bytes_per_sample(dec_pcm_data->data_format);
@@ -1933,6 +1917,11 @@ uint32_t dtsx_get_out_chmask_internal(void)
return _dtsx_dec->core2_pcm_out_info.channel_mask;
}
bool dtsx_decoder_is_inited(void)
{
return (_dtsx_dec != NULL && _dtsx_dec->p_dtsx_pp_inst != NULL);
}
int dtsx_get_out_ch_internal(void)
{
@@ -18,6 +18,7 @@
#define _AML_DTSX_DEC_API_H_
#include <hardware/audio.h>
#include <stdbool.h>
#include "aml_ringbuffer.h"
#include "aml_audio_types_def.h"
#include "aml_dec_api.h"
@@ -229,4 +230,7 @@ extern aml_dec_func_t aml_dtsx_func;
*/
uint32_t dtsx_get_out_chmask_internal(void);
/* Equivalent of android_audio adev->dts_x.status (DTS:X decoder instance alive). */
bool dtsx_decoder_is_inited(void);
#endif
@@ -39,15 +39,6 @@ static inline short CLIP16(int r)
r;
}
static inline int CLIP32(int64_t r)
{
if (r > 2147483647)
r = 2147483647;
else if (r < -2147483648)
r = -2147483648;
return r;
}
static void upmix_1ch_to_2ch(const void *in_buf, void *out_buf, int bytes, int audio_format) {
int frames_num = 0;
if (audio_format == AUDIO_FORMAT_PCM_16_BIT) {
@@ -142,6 +133,79 @@ static void downmix_6ch_to_2ch(const void *in_buf, void *out_buf, int bytes, int
return;
}
/* 6.1 layout: L R C LFE BL BR BC */
static void downmix_7ch_to_2ch(const void *in_buf, void *out_buf, int bytes, int audio_format) {
int frames_num = 0;
int channel = 7;
int i = 0;
if (audio_format == AUDIO_FORMAT_PCM_16_BIT) {
frames_num = bytes / (channel * 2);
int16_t *src = (int16_t *)in_buf;
int16_t *dst = (int16_t *)out_buf;
for (i = 0; i < frames_num; i++) {
dst[2*i] = (int16_t)CLIP16((int)src[channel*i] * 0.5
+ (int)src[channel*i + 2] * 0.25
+ (int)src[channel*i + 3] * 0.25
+ (int)src[channel*i + 4] * 0.25
+ (int)src[channel*i + 6] * 0.25);
dst[2*i+1] = (int16_t)CLIP16((int)src[channel*i + 1] * 0.5
+ (int)src[channel*i + 2] * 0.25
+ (int)src[channel*i + 3] * 0.25
+ (int)src[channel*i + 5] * 0.25
+ (int)src[channel*i + 6] * 0.25);
}
} else if (audio_format == AUDIO_FORMAT_PCM_32_BIT) {
frames_num = bytes / (channel * 4);
int32_t *src = (int32_t *)in_buf;
int32_t *dst = (int32_t *)out_buf;
for (i = 0; i < frames_num; i++) {
dst[2*i] = (int32_t)CLIP16((int64_t)src[channel*i] * 0.5
+ (int64_t)src[channel*i + 2] * 0.25
+ (int64_t)src[channel*i + 3] * 0.25
+ (int64_t)src[channel*i + 4] * 0.25
+ (int64_t)src[channel*i + 6] * 0.25);
dst[2*i+1] = (int32_t)CLIP16((int64_t)src[channel*i + 1] * 0.5
+ (int64_t)src[channel*i + 2] * 0.25
+ (int64_t)src[channel*i + 3] * 0.25
+ (int64_t)src[channel*i + 5] * 0.25
+ (int64_t)src[channel*i + 6] * 0.25);
}
} else {
AM_LOGE("Unsupport format:%x", audio_format);
}
return;
}
static void upmix_7ch_to_8ch(const void *in_buf, void *out_buf, int bytes, int audio_format) {
int sample_size = 0;
int frames_num = 0;
int i = 0;
int src_frame_bytes = 0;
int dst_frame_bytes = 0;
const char *src = (const char *)in_buf;
char *dst = (char *)out_buf;
if (audio_format == AUDIO_FORMAT_PCM_16_BIT) {
sample_size = 2;
} else if (audio_format == AUDIO_FORMAT_PCM_32_BIT) {
sample_size = 4;
} else {
AM_LOGE("Unsupport format:%x", audio_format);
return;
}
frames_num = bytes / (7 * sample_size);
src_frame_bytes = 7 * sample_size;
dst_frame_bytes = 8 * sample_size;
for (i = 0; i < frames_num; i++) {
memcpy(dst, src, src_frame_bytes);
memset(dst + src_frame_bytes, 0, sample_size);
src += src_frame_bytes;
dst += dst_frame_bytes;
}
return;
}
static void downmix_8ch_to_2ch(const void *in_buf, void *out_buf, int bytes, int audio_format) {
int frames_num = 0;
int channel = 8;
@@ -657,7 +721,7 @@ static int pcm_decoder_process(aml_dec_t * aml_dec, struct audio_buffer *abuffer
if (true == abuffer->b_pts_valid)
{
AM_LOGI("remain_data_pts:0x%"PRIx64" -> abuffer->pts 0x%"PRIx64" ,abuffer->b_pts_valid:%d", pcm_dec->remain_data_pts, abuffer->pts, abuffer->b_pts_valid);
//AM_LOGI("remain_data_pts:0x%"PRIx64" -> abuffer->pts 0x%"PRIx64" ,abuffer->b_pts_valid:%d", pcm_dec->remain_data_pts, abuffer->pts, abuffer->b_pts_valid);
pcm_dec->remain_data_pts = abuffer->pts;
}
@@ -701,6 +765,8 @@ static int pcm_decoder_process(aml_dec_t * aml_dec, struct audio_buffer *abuffer
downmix_4ch_to_2ch(buffer, dec_pcm_data->buf, bytes, pcm_config->pcm_format);
} else if (pcm_config->channel == 6) {
downmix_6ch_to_2ch(buffer, dec_pcm_data->buf, bytes, pcm_config->pcm_format);
} else if (pcm_config->channel == 7) {
downmix_7ch_to_2ch(buffer, dec_pcm_data->buf, bytes, pcm_config->pcm_format);
} else if (pcm_config->channel == 8) {
downmix_8ch_to_2ch(buffer, dec_pcm_data->buf, bytes, pcm_config->pcm_format);
} else {
@@ -723,22 +789,34 @@ static int pcm_decoder_process(aml_dec_t * aml_dec, struct audio_buffer *abuffer
AM_LOGI_IF(debug_enable, "%s data_in=%d ch =%d out=%d ch=%d format=%x", __func__, bytes, pcm_config->channel, output_size, 2, dec_pcm_data->data_format);
if (pcm_config->channel > 2) {
if (multi_pcm_data->buf_size < bytes) {
AM_LOGI("realloc outbuf_max_len from %d to %d\n", multi_pcm_data->buf_size, bytes);
multi_pcm_data->buf = aml_audio_realloc(multi_pcm_data->buf, bytes);
int multi_bytes = bytes;
int multi_ch = pcm_config->channel;
if (pcm_config->channel == 7) {
multi_ch = 8;
multi_bytes = bytes / 7 * 8;
}
if (multi_pcm_data->buf_size < multi_bytes) {
AM_LOGI("realloc outbuf_max_len from %d to %d\n", multi_pcm_data->buf_size, multi_bytes);
multi_pcm_data->buf = aml_audio_realloc(multi_pcm_data->buf, multi_bytes);
if (multi_pcm_data->buf == NULL) {
AM_LOGE("realloc pcm buffer failed size %d\n", bytes);
AM_LOGE("realloc pcm buffer failed size %d\n", multi_bytes);
return AML_DEC_RETURN_TYPE_FAIL;
}
multi_pcm_data->buf_size = bytes;
memset(multi_pcm_data->buf, 0, bytes);
multi_pcm_data->buf_size = multi_bytes;
memset(multi_pcm_data->buf, 0, multi_bytes);
}
memcpy(multi_pcm_data->buf, buffer, bytes);
multi_pcm_data->data_len = bytes ;
if (pcm_config->channel == 7) {
upmix_7ch_to_8ch(buffer, multi_pcm_data->buf, bytes, pcm_config->pcm_format);
} else {
memcpy(multi_pcm_data->buf, buffer, bytes);
}
multi_pcm_data->data_len = multi_bytes;
multi_pcm_data->data_sr = pcm_config->samplerate;
multi_pcm_data->data_ch = pcm_config->channel;
multi_pcm_data->data_ch = multi_ch;
multi_pcm_data->data_format = pcm_config->pcm_format;
AM_LOGI("%s multi data_in=%d ch =%d out=%d ch=%d", __func__, bytes, pcm_config->channel, output_size, pcm_config->channel);
//AM_LOGI("%s multi data_in=%d ch =%d out=%d ch=%d", __func__, bytes, pcm_config->channel, multi_bytes, multi_ch);
}
if (false == abuffer->b_pts_valid)
@@ -19,7 +19,7 @@ add_definitions(-DNDEBUG -DREPLACE_OUTPUT_BUFFER_WITH_CALLBACK)
set_target_properties(ms12v2 PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 2)
SOVERSION 3)
target_include_directories(ms12v2 PRIVATE
./include
@@ -336,6 +336,12 @@ public:
ALOGI("%s() mVersion %d\n", __FUNCTION__, mVersion);
}
virtual void setPcmrEffectOut(int value)
{
mPcmrEffectOut = value;
ALOGI("%s() mPcmrEffectOut %d\n", __FUNCTION__, mPcmrEffectOut);
}
protected:
@@ -459,7 +465,8 @@ private:
bool mIsLegacyDDPOut;
bool mTVTuningFlag;
bool mFullDAPDisable;
int mFullDAPDisable; /* 0: DAP on, 1: DAP mute, 2: DAP raw (bypass) */
int mPcmrEffectOut; /* 0: off; 1: enable PCMR effect raw out on config Y */
/*
DD/DD+ output is used for
0 = Full HDMI (default)
@@ -101,6 +101,14 @@ typedef enum {
MS12_CODEC_CALLBACK_MAX,
}ms12_codec_callback_type_t;
typedef enum {
MIXER_BUFFER_STEREO = 0,
MIXER_BUFFER_DAP,
MIXER_BUFFER_MCH,
MIXER_BUFFER_ENC,
MIXER_BUFFER_MAX = 4,
} MIXER_BUFFER;
enum MS12_PROCESS_CALLBACK_PCM_TYPE {
PCM_INT16 = 0,
PCM_INT32 = 1,
@@ -153,6 +161,22 @@ typedef struct AML_MS12_CodecInfo_s
int reserved[62];
} AML_MS12_CodecInfo_t;
typedef struct ms12_buffer_s
{
unsigned channel;
ptrdiff_t n;
int type;
void **data;
} ms12_buffer_t;
typedef struct Aml_MS12_MixerInfo_s {
ms12_buffer_t *buffer[MIXER_BUFFER_MAX];
int buffer_acmod[MIXER_BUFFER_MAX];
int buffer_lfe[MIXER_BUFFER_MAX];
int process_frame;
int as32Reserved[8];
} Aml_MS12_MixerInfo_t;
struct dolby_ms12_desc {
bool dolby_ms12_enable;//After continuous graph creats, this value is set to 1
bool dolby_ms12_init_flags;//After continuous graph or dap only creats, this value is set to 1
@@ -313,6 +337,14 @@ struct dolby_ms12_desc {
void *continuous_standby_handle;
void *decoder_loudness_limiter;
void *dap_loudness_limiter;
void *ms12_expand_handle;
void *expand_sys_handle;
void *expand_post_handle;
/* DAP raw pcm output is acting as the master output (DAP bypassed / PCMR tap) */
bool dap_raw_pcm_active;
bool b_enable_pcmr_effect;
void *dap_raw_remap_buf;
size_t dap_raw_remap_buf_sz;
};
@@ -419,6 +419,7 @@ void dolby_ms12_set_dap_only(int dap_only);
void dolby_ms12_set_hal_content_process(int hal_content_process);
void dolby_ms12_set_output_bitwidth(int bit_width);
void dolby_ms12_set_version(int version);
void dolby_ms12_set_pcmr_effect(int value);
/*End*/
#ifdef __cplusplus
@@ -108,7 +108,8 @@ DolbyMS12ConfigParams::DolbyMS12ConfigParams():
, mAtmosLock(false)//off(default) if mActivateOTTSignal is true
, mIsLegacyDDPOut(false)
, mTVTuningFlag(false)
, mFullDAPDisable(false)
, mFullDAPDisable(0)
, mPcmrEffectOut(0)
, mHdmiOutputType(0)
, mDapOnly(0)
, mVersion(0)
@@ -790,6 +791,13 @@ int DolbyMS12ConfigParams::SetDAPContentSwitches(char **ConfigParams, int *row_i
(*row_index)++;
}
if (mPcmrEffectOut) {
sprintf(ConfigParams[*row_index], "%s", "-pcmr_effect_out");
(*row_index)++;
sprintf(ConfigParams[*row_index], "%d", mPcmrEffectOut);
(*row_index)++;
}
ALOGV("-%s() line %d\n", __FUNCTION__, __LINE__);
return 0;
}
@@ -1101,7 +1109,12 @@ char **DolbyMS12ConfigParams::UpdateDolbyMS12RuntimeConfigParams(int *argc, char
ALOGI("-atmos_lock: %d", mAtmosLock);
} else if (strcmp(opt, "full_dap_disable") == 0) {
val = atoi(mRuntimeConfigParams[index]);
mFullDAPDisable = val ? true : false;
/* 0: DAP enabled, 1: DAP muted, 2: DAP bypassed (raw pcm output) */
if (val < 0)
val = 0;
if (val > 2)
val = 2;
mFullDAPDisable = val;
ALOGI("-full_dap_disable: %d", mFullDAPDisable);
}
eq_error:
@@ -551,6 +551,18 @@ extern "C" void dolby_ms12_set_version(int version)
}
}
extern "C" void dolby_ms12_set_pcmr_effect(int value)
{
ALOGV("%s()\n", __FUNCTION__);
android::DolbyMS12ConfigParams *config_param = getInstance();
if (config_param) {
config_param->setPcmrEffectOut(value);
}
else {
ALOGW("Found the config_param handle illegal\n");
}
}
/*****************************************************************************************************************/
/*END*/
/*****************************************************************************************************************/