mirror of
https://github.com/openharmony/drivers_framework.git
synced 2026-07-21 03:35:25 -04:00
!633 clean warnings when use rk3568 platform buildtools
Merge pull request !633 from xzmu/master
This commit is contained in:
@@ -26,6 +26,12 @@ uint16_t g_i2cDevAddr, g_i2cBusNumber;
|
||||
struct AudioRegCfgGroupNode **g_audioRegCfgGroupNode = NULL;
|
||||
struct AudioKcontrol *g_audioControls = NULL;
|
||||
|
||||
static const char *g_audioAccessoryControlsList[AUDIO_CTRL_LIST_MAX] = {
|
||||
"Main Playback Volume", "Main Capture Volume",
|
||||
"Playback Mute", "Capture Mute", "Mic Left Gain",
|
||||
"Mic Right Gain", "External Codec Enable",
|
||||
"Internally Codec Enable", "Render Channel Mode", "Captrue Channel Mode"
|
||||
};
|
||||
/*
|
||||
* release I2C object public function
|
||||
*/
|
||||
@@ -303,7 +309,7 @@ int32_t AccessoryDeviceCfgGet(struct AccessoryData *accessoryData,
|
||||
int32_t ret;
|
||||
int32_t index;
|
||||
int32_t audioCfgCtrlCount;
|
||||
|
||||
struct AudioControlConfig *ctlcfgItem;
|
||||
ret = (accessoryData == NULL || accessoryData->regConfig == NULL || accessoryTransferData == NULL);
|
||||
if (ret) {
|
||||
AUDIO_DRIVER_LOG_ERR("input para is NULL.");
|
||||
@@ -320,7 +326,7 @@ int32_t AccessoryDeviceCfgGet(struct AccessoryData *accessoryData,
|
||||
AUDIO_DRIVER_LOG_ERR("parsing params is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct AudioControlConfig *ctlcfgItem = g_audioRegCfgGroupNode[AUDIO_CTRL_CFG_GROUP]->ctrlCfgItem;
|
||||
ctlcfgItem = g_audioRegCfgGroupNode[AUDIO_CTRL_CFG_GROUP]->ctrlCfgItem;
|
||||
audioCfgCtrlCount = g_audioRegCfgGroupNode[AUDIO_CTRL_CFG_GROUP]->itemNum;
|
||||
g_audioControls = (struct AudioKcontrol *)OsalMemCalloc(audioCfgCtrlCount * sizeof(struct AudioKcontrol));
|
||||
accessoryTransferData->accessoryRegCfgGroupNode = g_audioRegCfgGroupNode;
|
||||
@@ -328,7 +334,7 @@ int32_t AccessoryDeviceCfgGet(struct AccessoryData *accessoryData,
|
||||
accessoryTransferData->accessoryControls = g_audioControls;
|
||||
for (index = 0; index < audioCfgCtrlCount; index++) {
|
||||
g_audioControls[index].iface = ctlcfgItem[index].iface;
|
||||
g_audioControls[index].name = g_audioControlsList[ctlcfgItem[index].arrayIndex];
|
||||
g_audioControls[index].name = g_audioAccessoryControlsList[ctlcfgItem[index].arrayIndex];
|
||||
g_audioControls[index].Info = AudioInfoCtrlOps;
|
||||
g_audioControls[index].privateValue =
|
||||
(unsigned long)(uintptr_t)(void*)(&g_audioRegCfgGroupNode[AUDIO_CTRL_PATAM_GROUP]->regCfgItem[index]);
|
||||
@@ -344,6 +350,7 @@ int32_t AccessoryDeviceCfgGet(struct AccessoryData *accessoryData,
|
||||
int32_t AccessoryDeviceCtrlRegInit(void)
|
||||
{
|
||||
int32_t ret, i;
|
||||
struct AudioAddrConfig *initCfg;
|
||||
// Set codec control register(00h-14h) default value
|
||||
ret = (g_audioRegCfgGroupNode == NULL || g_audioRegCfgGroupNode[AUDIO_INIT_GROUP] == NULL
|
||||
|| g_audioRegCfgGroupNode[AUDIO_INIT_GROUP]->addrCfgItem == NULL);
|
||||
@@ -351,7 +358,7 @@ int32_t AccessoryDeviceCtrlRegInit(void)
|
||||
AUDIO_DRIVER_LOG_ERR("g_audioRegCfgGroupNode[AUDIO_INIT_GROUP] is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct AudioAddrConfig *initCfg = g_audioRegCfgGroupNode[AUDIO_INIT_GROUP]->addrCfgItem;
|
||||
initCfg = g_audioRegCfgGroupNode[AUDIO_INIT_GROUP]->addrCfgItem;
|
||||
for (i = 0; i < g_audioRegCfgGroupNode[AUDIO_INIT_GROUP]->itemNum; i++) {
|
||||
AUDIO_DRIVER_LOG_DEBUG("i=%d, Addr = [0x%2x]", i, initCfg[i].addr);
|
||||
ret = AccessoryI2cReadWrite(&initCfg[i], 0);
|
||||
|
||||
@@ -13,6 +13,21 @@
|
||||
|
||||
#define HDF_LOG_TAG audio_codec_base
|
||||
|
||||
static char *g_audioSapmCompNameList[AUDIO_SAPM_COMP_NAME_LIST_MAX] = {
|
||||
"ADCL", "ADCR", "DACL", "DACR", "LPGA", "RPGA", "SPKL", "SPKR", "MIC"
|
||||
};
|
||||
|
||||
static char *g_audioSapmCfgNameList[AUDIO_SAPM_CFG_NAME_LIST_MAX] = {
|
||||
"LPGA MIC Switch", "RPGA MIC Switch", "Dacl enable", "Dacr enable"
|
||||
};
|
||||
|
||||
static const char *g_audioCodecControlsList[AUDIO_CTRL_LIST_MAX] = {
|
||||
"Main Playback Volume", "Main Capture Volume",
|
||||
"Playback Mute", "Capture Mute", "Mic Left Gain",
|
||||
"Mic Right Gain", "External Codec Enable",
|
||||
"Internally Codec Enable", "Render Channel Mode", "Captrue Channel Mode"
|
||||
};
|
||||
|
||||
int32_t CodecGetServiceName(const struct HdfDeviceObject *device, const char **drvCodecName)
|
||||
{
|
||||
const struct DeviceResourceNode *node = NULL;
|
||||
@@ -124,22 +139,25 @@ static int32_t SapmCtrlToSapmComp(struct AudioSapmComponent *sapmComponents,
|
||||
static int32_t CodecSetSapmConfigInfo(struct CodecData *codeData, struct AudioRegCfgGroupNode **regCfgGroup)
|
||||
{
|
||||
uint16_t index;
|
||||
|
||||
struct AudioSapmCtrlConfig *sapmCompItem;
|
||||
struct AudioControlConfig *sapmCtrlItem;
|
||||
struct AudioMixerControl *ctlSapmRegCfgItem;
|
||||
struct AudioKcontrol *audioSapmControls;
|
||||
if (codeData == NULL || regCfgGroup == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("input para is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioSapmCtrlConfig *sapmCompItem = regCfgGroup[AUDIO_SAPM_COMP_GROUP]->sapmCompItem;
|
||||
struct AudioControlConfig *sapmCtrlItem = regCfgGroup[AUDIO_SAPM_CFG_GROUP]->ctrlCfgItem;
|
||||
struct AudioMixerControl *ctlSapmRegCfgItem = regCfgGroup[AUDIO_CTRL_SAPM_PATAM_GROUP]->regCfgItem;
|
||||
sapmCompItem = regCfgGroup[AUDIO_SAPM_COMP_GROUP]->sapmCompItem;
|
||||
sapmCtrlItem = regCfgGroup[AUDIO_SAPM_CFG_GROUP]->ctrlCfgItem;
|
||||
ctlSapmRegCfgItem = regCfgGroup[AUDIO_CTRL_SAPM_PATAM_GROUP]->regCfgItem;
|
||||
|
||||
if (sapmCompItem == NULL || sapmCtrlItem == NULL || ctlSapmRegCfgItem == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("sapmCompItem, sapmCtrlItem, ctlSapmRegCfgItem is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioKcontrol *audioSapmControls = (struct AudioKcontrol *)OsalMemCalloc(
|
||||
audioSapmControls = (struct AudioKcontrol *)OsalMemCalloc(
|
||||
regCfgGroup[AUDIO_SAPM_CFG_GROUP]->itemNum * sizeof(struct AudioKcontrol));
|
||||
if (audioSapmControls == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("OsalMemCalloc failed.");
|
||||
@@ -181,14 +199,17 @@ static int32_t CodecSetSapmConfigInfo(struct CodecData *codeData, struct AudioRe
|
||||
int32_t CodecSetConfigInfo(struct CodecData *codeData, struct DaiData *daiData)
|
||||
{
|
||||
uint16_t index;
|
||||
|
||||
struct AudioIdInfo *audioIdInfo;
|
||||
struct AudioRegCfgGroupNode **regCfgGroup;
|
||||
struct AudioControlConfig *compItem;
|
||||
struct AudioMixerControl *ctlRegCfgItem;
|
||||
if (codeData == NULL || daiData == NULL || codeData->regConfig == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("input para is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioIdInfo *audioIdInfo = &(codeData->regConfig->audioIdInfo);
|
||||
struct AudioRegCfgGroupNode **regCfgGroup = codeData->regConfig->audioRegParams;
|
||||
audioIdInfo = &(codeData->regConfig->audioIdInfo);
|
||||
regCfgGroup = codeData->regConfig->audioRegParams;
|
||||
daiData->regCfgGroup = regCfgGroup;
|
||||
codeData->regCfgGroup = regCfgGroup;
|
||||
if (audioIdInfo == NULL || regCfgGroup == NULL) {
|
||||
@@ -196,8 +217,8 @@ int32_t CodecSetConfigInfo(struct CodecData *codeData, struct DaiData *daiData)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioControlConfig *compItem = regCfgGroup[AUDIO_CTRL_CFG_GROUP]->ctrlCfgItem;
|
||||
struct AudioMixerControl *ctlRegCfgItem = regCfgGroup[AUDIO_CTRL_PATAM_GROUP]->regCfgItem;
|
||||
compItem = regCfgGroup[AUDIO_CTRL_CFG_GROUP]->ctrlCfgItem;
|
||||
ctlRegCfgItem = regCfgGroup[AUDIO_CTRL_PATAM_GROUP]->regCfgItem;
|
||||
if (compItem == NULL || ctlRegCfgItem == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("compItem or ctlRegCfgItem is NULL.");
|
||||
return HDF_FAILURE;
|
||||
@@ -213,7 +234,7 @@ int32_t CodecSetConfigInfo(struct CodecData *codeData, struct DaiData *daiData)
|
||||
|
||||
for (index = 0; index < codeData->numControls; index++) {
|
||||
codeData->controls[index].iface = compItem[index].iface;
|
||||
codeData->controls[index].name = g_audioControlsList[compItem[index].arrayIndex];
|
||||
codeData->controls[index].name = g_audioCodecControlsList[compItem[index].arrayIndex];
|
||||
codeData->controls[index].Info = AudioInfoCtrlOps;
|
||||
codeData->controls[index].privateValue = (unsigned long)(uintptr_t)(void*)(&ctlRegCfgItem[index]);
|
||||
if (compItem[index].enable) {
|
||||
@@ -234,18 +255,20 @@ int32_t CodecSetConfigInfo(struct CodecData *codeData, struct DaiData *daiData)
|
||||
int32_t CodecSetCtlFunc(struct CodecData *codeData, const void *aiaoGetCtrl, const void *aiaoSetCtrl)
|
||||
{
|
||||
uint32_t index;
|
||||
struct AudioRegCfgGroupNode **regCfgGroup;
|
||||
struct AudioControlConfig *compItem;
|
||||
if (codeData == NULL || codeData->regConfig == NULL ||
|
||||
aiaoGetCtrl == NULL || aiaoSetCtrl == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("input para is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct AudioRegCfgGroupNode **regCfgGroup = codeData->regConfig->audioRegParams;
|
||||
regCfgGroup = codeData->regConfig->audioRegParams;
|
||||
if (regCfgGroup == NULL || regCfgGroup[AUDIO_CTRL_CFG_GROUP] == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("regCfgGroup or regCfgGroup[AUDIO_CTRL_CFG_GROUP] is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioControlConfig *compItem = regCfgGroup[AUDIO_CTRL_CFG_GROUP]->ctrlCfgItem;
|
||||
compItem = regCfgGroup[AUDIO_CTRL_CFG_GROUP]->ctrlCfgItem;
|
||||
if (compItem == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("compItem is NULL.");
|
||||
return HDF_FAILURE;
|
||||
|
||||
@@ -9,6 +9,13 @@
|
||||
#include "audio_core.h"
|
||||
#include "audio_driver_log.h"
|
||||
|
||||
static const char *g_audioDaiControlsList[AUDIO_CTRL_LIST_MAX] = {
|
||||
"Main Playback Volume", "Main Capture Volume",
|
||||
"Playback Mute", "Capture Mute", "Mic Left Gain",
|
||||
"Mic Right Gain", "External Codec Enable",
|
||||
"Internally Codec Enable", "Render Channel Mode", "Captrue Channel Mode"
|
||||
};
|
||||
|
||||
struct DaiData *DaiDataFromCard(const struct AudioCard *card)
|
||||
{
|
||||
if (card == NULL || card->rtd == NULL || card->rtd->cpuDai == NULL) {
|
||||
@@ -102,7 +109,7 @@ int32_t DaiSetConfigInfo(struct DaiData *data)
|
||||
AUDIO_DRIVER_LOG_ERR("Array super index.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
data->controls[index].name = g_audioControlsList[item[index].arrayIndex];
|
||||
data->controls[index].name = g_audioDaiControlsList[item[index].arrayIndex];
|
||||
data->controls[index].Info = AudioInfoCtrlOps;
|
||||
data->controls[index].privateValue = (unsigned long)(uintptr_t)(void*)(&patRegCfgItemTmp[index]);
|
||||
data->controls[index].Get = AudioCpuDaiGetCtrlOps;
|
||||
|
||||
@@ -55,14 +55,17 @@ uint32_t AudioBytesToFrames(uint32_t frameBits, uint32_t size)
|
||||
|
||||
int32_t AudioDataBigEndianChange(char *srcData, uint32_t audioLen, enum DataBitWidth bitWidth)
|
||||
{
|
||||
|
||||
uint64_t i;
|
||||
uint16_t framesize;
|
||||
char *changeData;
|
||||
uint32_t *pData;
|
||||
if (srcData == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("srcData is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
uint64_t i;
|
||||
uint16_t framesize;
|
||||
char *changeData = srcData;
|
||||
uint32_t *pData = (uint32_t *)changeData;
|
||||
changeData = srcData;
|
||||
pData = (uint32_t *)changeData;
|
||||
|
||||
switch (bitWidth) {
|
||||
case DATA_BIT_WIDTH8:
|
||||
@@ -481,6 +484,10 @@ static int32_t MmapWriteData(struct PlatformData *data, char *tmpBuf)
|
||||
static int32_t AudioMmapWriteTransfer(const struct AudioCard *card)
|
||||
{
|
||||
uint32_t timeout = 0;
|
||||
uint32_t totalSize;
|
||||
uint32_t lastBuffSize;
|
||||
uint32_t loopTimes;
|
||||
char *tmpBuf;
|
||||
struct PlatformData *data = PlatformDataFromCard(card);
|
||||
if (data == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("PlatformDataFromCard failed.");
|
||||
@@ -491,12 +498,12 @@ static int32_t AudioMmapWriteTransfer(const struct AudioCard *card)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t totalSize = (uint32_t)data->mmapData.totalBufferFrames * data->renderPcmInfo.frameSize;
|
||||
uint32_t lastBuffSize = ((totalSize % MIN_PERIOD_SIZE) == 0) ? MIN_PERIOD_SIZE : (totalSize % MIN_PERIOD_SIZE);
|
||||
uint32_t loopTimes = (lastBuffSize == MIN_PERIOD_SIZE) ?
|
||||
totalSize = (uint32_t)data->mmapData.totalBufferFrames * data->renderPcmInfo.frameSize;
|
||||
lastBuffSize = ((totalSize % MIN_PERIOD_SIZE) == 0) ? MIN_PERIOD_SIZE : (totalSize % MIN_PERIOD_SIZE);
|
||||
loopTimes = (lastBuffSize == MIN_PERIOD_SIZE) ?
|
||||
(totalSize / MIN_PERIOD_SIZE) : (totalSize / MIN_PERIOD_SIZE + 1);
|
||||
data->mmapLoopCount = 0;
|
||||
char *tmpBuf = OsalMemCalloc(MIN_PERIOD_SIZE);
|
||||
tmpBuf = OsalMemCalloc(MIN_PERIOD_SIZE);
|
||||
if (tmpBuf == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("tmpBuf is null.");
|
||||
return HDF_FAILURE;
|
||||
@@ -621,6 +628,9 @@ int32_t AudioMmapReadTransfer(const struct AudioCard *card, const struct AudioMm
|
||||
uint32_t offset = 0;
|
||||
enum CriBuffStatus status;
|
||||
uint32_t timeout = 0;
|
||||
struct PlatformData *data;
|
||||
uint32_t frameSize;
|
||||
uint32_t totalSize;
|
||||
|
||||
if (card == NULL || rxMmapData == NULL || rxMmapData->memoryAddress == NULL ||
|
||||
rxMmapData->totalBufferFrames <= 0) {
|
||||
@@ -628,14 +638,14 @@ int32_t AudioMmapReadTransfer(const struct AudioCard *card, const struct AudioMm
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
struct PlatformData *data = PlatformDataFromCard(card);
|
||||
data = PlatformDataFromCard(card);
|
||||
if (data == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("PlatformDataFromCard failed.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t frameSize = data->capturePcmInfo.frameSize;
|
||||
uint32_t totalSize = (uint32_t)rxMmapData->totalBufferFrames * frameSize;
|
||||
frameSize = data->capturePcmInfo.frameSize;
|
||||
totalSize = (uint32_t)rxMmapData->totalBufferFrames * frameSize;
|
||||
data->captureBufInfo.pointer = 0;
|
||||
data->captureBufInfo.curTrafSize = data->captureBufInfo.trafBufSize;
|
||||
if (data->captureBufInfo.virtAddr == NULL) {
|
||||
@@ -836,12 +846,13 @@ int32_t AudioRenderClose(const struct AudioCard *card)
|
||||
|
||||
int32_t AudioCaptureOpen(const struct AudioCard *card)
|
||||
{
|
||||
struct PlatformData *platformData;
|
||||
if (card == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("param card is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct PlatformData *platformData = PlatformDataFromCard(card);
|
||||
platformData = PlatformDataFromCard(card);
|
||||
if (platformData == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("PlatformDataFromCard failed.");
|
||||
return HDF_FAILURE;
|
||||
@@ -858,12 +869,13 @@ int32_t AudioCaptureOpen(const struct AudioCard *card)
|
||||
|
||||
int32_t AudioCaptureClose(const struct AudioCard *card)
|
||||
{
|
||||
struct PlatformData *platformData;
|
||||
if (card == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("param card is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct PlatformData *platformData = PlatformDataFromCard(card);
|
||||
platformData = PlatformDataFromCard(card);
|
||||
if (platformData == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("PlatformDataFromCard failed.");
|
||||
return HDF_FAILURE;
|
||||
@@ -1037,7 +1049,7 @@ int32_t AudioHwParams(const struct AudioCard *card, const struct AudioPcmHwParam
|
||||
{
|
||||
const int chnlCntMin = 1;
|
||||
const int chnlCntMax = 2;
|
||||
|
||||
struct PlatformData *platformData;
|
||||
if (card == NULL || param == NULL || param->cardServiceName == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("input param is NULL.");
|
||||
return HDF_FAILURE;
|
||||
@@ -1048,7 +1060,7 @@ int32_t AudioHwParams(const struct AudioCard *card, const struct AudioPcmHwParam
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct PlatformData *platformData = PlatformDataFromCard(card);
|
||||
platformData = PlatformDataFromCard(card);
|
||||
if (platformData == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("platformData is null.");
|
||||
return HDF_FAILURE;
|
||||
@@ -1087,12 +1099,13 @@ int32_t AudioHwParams(const struct AudioCard *card, const struct AudioPcmHwParam
|
||||
int32_t AudioRenderPrepare(const struct AudioCard *card)
|
||||
{
|
||||
int ret;
|
||||
struct PlatformData *platformData;
|
||||
if (card == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("param card is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct PlatformData *platformData = PlatformDataFromCard(card);
|
||||
platformData = PlatformDataFromCard(card);
|
||||
if (platformData == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("PlatformDataFromCard failed.");
|
||||
return HDF_FAILURE;
|
||||
@@ -1120,12 +1133,13 @@ int32_t AudioRenderPrepare(const struct AudioCard *card)
|
||||
int32_t AudioCapturePrepare(const struct AudioCard *card)
|
||||
{
|
||||
int ret;
|
||||
struct PlatformData *platformData;
|
||||
if (card == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("param card is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct PlatformData *platformData = PlatformDataFromCard(card);
|
||||
platformData = PlatformDataFromCard(card);
|
||||
if (platformData == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("PlatformDataFromCard failed.");
|
||||
return HDF_FAILURE;
|
||||
@@ -1154,12 +1168,13 @@ int32_t AudioCapturePrepare(const struct AudioCard *card)
|
||||
int32_t AudioPcmPointer(const struct AudioCard *card, uint32_t *pointer, enum AudioStreamType streamType)
|
||||
{
|
||||
int ret;
|
||||
struct PlatformData *data;
|
||||
if (card == NULL || pointer == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("param card is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct PlatformData *data = PlatformDataFromCard(card);
|
||||
data = PlatformDataFromCard(card);
|
||||
if (data == NULL) {
|
||||
AUDIO_DRIVER_LOG_ERR("PlatformDataFromCard failed.");
|
||||
return HDF_FAILURE;
|
||||
|
||||
@@ -23,21 +23,6 @@ extern "C" {
|
||||
#define AUDIO_SAPM_COMP_NAME_LIST_MAX 9
|
||||
#define AUDIO_SAPM_CFG_NAME_LIST_MAX 4
|
||||
|
||||
static const char *g_audioControlsList[AUDIO_CTRL_LIST_MAX] = {
|
||||
"Main Playback Volume", "Main Capture Volume",
|
||||
"Playback Mute", "Capture Mute", "Mic Left Gain",
|
||||
"Mic Right Gain", "External Codec Enable",
|
||||
"Internally Codec Enable", "Render Channel Mode", "Captrue Channel Mode"
|
||||
};
|
||||
|
||||
static char *g_audioSapmCompNameList[AUDIO_SAPM_COMP_NAME_LIST_MAX] = {
|
||||
"ADCL", "ADCR", "DACL", "DACR", "LPGA", "RPGA", "SPKL", "SPKR", "MIC"
|
||||
};
|
||||
|
||||
static char *g_audioSapmCfgNameList[AUDIO_SAPM_CFG_NAME_LIST_MAX] = {
|
||||
"LPGA MIC Switch", "RPGA MIC Switch", "Dacl enable", "Dacr enable"
|
||||
};
|
||||
|
||||
enum AudioRegOpsType {
|
||||
AUDIO_RSET_GROUP = 0,
|
||||
AUDIO_INIT_GROUP,
|
||||
|
||||
@@ -48,14 +48,14 @@ struct AudioCard *GetCardInstance(const char *serviceName)
|
||||
|
||||
static int32_t AudioCodecDevInit(struct AudioCard *audioCard)
|
||||
{
|
||||
struct AudioRuntimeDeivces *rtd = NULL;
|
||||
struct CodecDevice *codec = NULL;
|
||||
ADM_LOG_DEBUG("entry.");
|
||||
|
||||
if (audioCard == NULL) {
|
||||
ADM_LOG_ERR("audioCard is NULL.");
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
ADM_LOG_DEBUG("entry.");
|
||||
struct AudioRuntimeDeivces *rtd = NULL;
|
||||
struct CodecDevice *codec = NULL;
|
||||
rtd = audioCard->rtd;
|
||||
if (rtd == NULL) {
|
||||
ADM_LOG_ERR("rtd is NULL.");
|
||||
@@ -77,14 +77,16 @@ static int32_t AudioCodecDevInit(struct AudioCard *audioCard)
|
||||
|
||||
static int32_t AudioAccessoryDevInit(struct AudioCard *audioCard)
|
||||
{
|
||||
struct AudioRuntimeDeivces *rtd = NULL;
|
||||
struct AccessoryDevice *accessory = NULL;
|
||||
ADM_LOG_DEBUG("entry.");
|
||||
|
||||
if (audioCard == NULL) {
|
||||
ADM_LOG_ERR("audioCard is NULL.");
|
||||
return HDF_ERR_IO;
|
||||
}
|
||||
|
||||
ADM_LOG_DEBUG("entry.");
|
||||
struct AudioRuntimeDeivces *rtd = NULL;
|
||||
struct AccessoryDevice *accessory = NULL;
|
||||
|
||||
rtd = audioCard->rtd;
|
||||
if (rtd == NULL) {
|
||||
ADM_LOG_ERR("rtd is NULL.");
|
||||
|
||||
@@ -67,6 +67,15 @@ int32_t AudioFillConfigData(const struct HdfDeviceObject *device, struct AudioCo
|
||||
{
|
||||
const struct DeviceResourceNode *node = NULL;
|
||||
struct DeviceResourceIface *drsOps = NULL;
|
||||
int32_t serviceRet;
|
||||
int32_t codecRet;
|
||||
int32_t platformRet;
|
||||
int32_t cpuRet;
|
||||
int32_t codeDaiRet;
|
||||
int32_t dspRet;
|
||||
int32_t dspDaiRet;
|
||||
int32_t accessoryRet;
|
||||
int32_t accessoryDaiRet;
|
||||
ADM_LOG_DEBUG("Entry.");
|
||||
|
||||
if (device == NULL || configData == NULL) {
|
||||
@@ -85,15 +94,15 @@ int32_t AudioFillConfigData(const struct HdfDeviceObject *device, struct AudioCo
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t serviceRet = drsOps->GetString(node, "serviceName", &(configData->cardServiceName), 0);
|
||||
int32_t codecRet = drsOps->GetString(node, "codecName", &(configData->codecName), 0);
|
||||
int32_t platformRet = drsOps->GetString(node, "platformName", &(configData->platformName), 0);
|
||||
int32_t cpuRet = drsOps->GetString(node, "cpuDaiName", &(configData->cpuDaiName), 0);
|
||||
int32_t codeDaiRet = drsOps->GetString(node, "codecDaiName", &(configData->codecDaiName), 0);
|
||||
int32_t dspRet = drsOps->GetString(node, "dspName", &(configData->dspName), 0);
|
||||
int32_t dspDaiRet = drsOps->GetString(node, "dspDaiName", &(configData->dspDaiName), 0);
|
||||
int32_t accessoryRet = drsOps->GetString(node, "accessoryName", &(configData->accessoryName), 0);
|
||||
int32_t accessoryDaiRet = drsOps->GetString(node, "accessoryDaiName", &(configData->accessoryDaiName), 0);
|
||||
serviceRet = drsOps->GetString(node, "serviceName", &(configData->cardServiceName), 0);
|
||||
codecRet = drsOps->GetString(node, "codecName", &(configData->codecName), 0);
|
||||
platformRet = drsOps->GetString(node, "platformName", &(configData->platformName), 0);
|
||||
cpuRet = drsOps->GetString(node, "cpuDaiName", &(configData->cpuDaiName), 0);
|
||||
codeDaiRet = drsOps->GetString(node, "codecDaiName", &(configData->codecDaiName), 0);
|
||||
dspRet = drsOps->GetString(node, "dspName", &(configData->dspName), 0);
|
||||
dspDaiRet = drsOps->GetString(node, "dspDaiName", &(configData->dspDaiName), 0);
|
||||
accessoryRet = drsOps->GetString(node, "accessoryName", &(configData->accessoryName), 0);
|
||||
accessoryDaiRet = drsOps->GetString(node, "accessoryDaiName", &(configData->accessoryDaiName), 0);
|
||||
if (serviceRet || codecRet || platformRet || cpuRet || codeDaiRet ||
|
||||
dspRet || dspDaiRet || accessoryRet || accessoryDaiRet) {
|
||||
ADM_LOG_ERR("Read audioDeviceName fail: serviceRet=%d, codecRet=%d, platformRet=%d, cpuRet=%d, codeDaiRet=%d,"
|
||||
@@ -133,19 +142,21 @@ static uint32_t* GetRegArray(const struct DeviceResourceIface *parser, const str
|
||||
struct AudioRegCfgGroupNode* group, uint32_t indexMax)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
int32_t index;
|
||||
int32_t num;
|
||||
uint32_t *buf;
|
||||
if (group == NULL || parser == NULL || regNode == NULL || indexMax == 0) {
|
||||
ADM_LOG_ERR("Input para check error");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t index = group->groupIndex;
|
||||
index = group->groupIndex;
|
||||
if (index >= AUDIO_GROUP_MAX) {
|
||||
ADM_LOG_ERR("Input indexMax=%d error", index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t num = parser->GetElemNum(regNode, g_audioRegGroupName[index]);
|
||||
num = parser->GetElemNum(regNode, g_audioRegGroupName[index]);
|
||||
if (num <= 0 || num > AUDIO_CONFIG_MAX_ITEM) {
|
||||
ADM_LOG_ERR("parser %s element num failed", g_audioRegGroupName[index]);
|
||||
return NULL;
|
||||
@@ -153,7 +164,7 @@ static uint32_t* GetRegArray(const struct DeviceResourceIface *parser, const str
|
||||
|
||||
group->itemNum = num / indexMax;
|
||||
|
||||
uint32_t *buf = (uint32_t *)OsalMemCalloc(sizeof(uint32_t) * num);
|
||||
buf = (uint32_t *)OsalMemCalloc(sizeof(uint32_t) * num);
|
||||
if (buf == NULL) {
|
||||
ADM_LOG_ERR("malloc reg array buf failed!");
|
||||
return NULL;
|
||||
@@ -173,13 +184,13 @@ static int32_t ParseAudioRegItem(const struct DeviceResourceIface *parser, const
|
||||
{
|
||||
int32_t step;
|
||||
int32_t index;
|
||||
|
||||
int32_t *buf;
|
||||
if (group == NULL || parser == NULL || regNode == NULL) {
|
||||
ADM_LOG_ERR("Input para check error");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t *buf = GetRegArray(parser, regNode, group, AUDIO_REG_CFG_INDEX_MAX);
|
||||
buf = GetRegArray(parser, regNode, group, AUDIO_REG_CFG_INDEX_MAX);
|
||||
if (buf == NULL) {
|
||||
ADM_LOG_ERR("malloc reg array buf failed!");
|
||||
return HDF_FAILURE;
|
||||
@@ -216,13 +227,13 @@ static int32_t ParseAudioSapmItem(const struct DeviceResourceIface *parser, cons
|
||||
{
|
||||
int32_t step;
|
||||
int32_t index;
|
||||
|
||||
uint32_t *buf;
|
||||
if (group == NULL || parser == NULL || regNode == NULL) {
|
||||
ADM_LOG_ERR("Input para check error");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t *buf = GetRegArray(parser, regNode, group, AUDIO_SAPM_COMP_INDEX_MAX);
|
||||
buf = GetRegArray(parser, regNode, group, AUDIO_SAPM_COMP_INDEX_MAX);
|
||||
if (buf == NULL) {
|
||||
ADM_LOG_ERR("malloc reg array buf failed!");
|
||||
return HDF_FAILURE;
|
||||
@@ -258,13 +269,13 @@ static int32_t ParseAudioCtrlItem(const struct DeviceResourceIface *parser, cons
|
||||
{
|
||||
int32_t step;
|
||||
int32_t index;
|
||||
|
||||
uint32_t *buf;
|
||||
if (parser == NULL || regNode == NULL || group == NULL) {
|
||||
ADM_LOG_ERR("Input para check error");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t *buf = GetRegArray(parser, regNode, group, AUDIO_CTRL_CFG_INDEX_MAX);
|
||||
buf = GetRegArray(parser, regNode, group, AUDIO_CTRL_CFG_INDEX_MAX);
|
||||
if (buf == NULL) {
|
||||
ADM_LOG_ERR("malloc reg array buf failed!");
|
||||
return HDF_FAILURE;
|
||||
@@ -294,13 +305,14 @@ static int32_t ParseAudioAddrItem(const struct DeviceResourceIface *parser, cons
|
||||
{
|
||||
int32_t step;
|
||||
int32_t index;
|
||||
uint32_t *buf;
|
||||
|
||||
if (parser == NULL || regNode == NULL || group == NULL) {
|
||||
ADM_LOG_ERR("Input para check error.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t *buf = GetRegArray(parser, regNode, group, AUDIO_ADDR_CFG_INDEX_MAX);
|
||||
buf = GetRegArray(parser, regNode, group, AUDIO_ADDR_CFG_INDEX_MAX);
|
||||
if (buf == NULL) {
|
||||
ADM_LOG_ERR("malloc reg array buf failed!");
|
||||
return HDF_FAILURE;
|
||||
|
||||
@@ -21,18 +21,20 @@ static inline struct StreamHost *StreamHostFromDevice(const struct HdfDeviceObje
|
||||
|
||||
static int32_t HwCpuDaiDispatch(const struct AudioCard *audioCard, const struct AudioPcmHwParams *params)
|
||||
{
|
||||
struct AudioRuntimeDeivces *rtd;
|
||||
struct DaiDevice *cpuDai;
|
||||
if ((audioCard == NULL) || (params == NULL)) {
|
||||
ADM_LOG_ERR("CpuDai input param is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioRuntimeDeivces *rtd = audioCard->rtd;
|
||||
rtd = audioCard->rtd;
|
||||
if (rtd == NULL) {
|
||||
ADM_LOG_ERR("CpuDai audioCard rtd is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct DaiDevice *cpuDai = rtd->cpuDai;
|
||||
cpuDai = rtd->cpuDai;
|
||||
if (cpuDai == NULL || cpuDai->devData == NULL || cpuDai->devData->ops == NULL) {
|
||||
ADM_LOG_ERR("cpuDai param is NULL.");
|
||||
return HDF_FAILURE;
|
||||
@@ -54,17 +56,19 @@ static int32_t HwCpuDaiDispatch(const struct AudioCard *audioCard, const struct
|
||||
|
||||
static int32_t HwCodecDaiDispatch(const struct AudioCard *audioCard, const struct AudioPcmHwParams *params)
|
||||
{
|
||||
struct AudioRuntimeDeivces *rtd;
|
||||
struct DaiDevice *codecDai;
|
||||
if ((audioCard == NULL) || (params == NULL)) {
|
||||
ADM_LOG_ERR("CodecDai input param is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioRuntimeDeivces *rtd = audioCard->rtd;
|
||||
rtd = audioCard->rtd;
|
||||
if (rtd == NULL) {
|
||||
ADM_LOG_ERR("CodecDai audioCard rtd is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct DaiDevice *codecDai = rtd->codecDai;
|
||||
codecDai = rtd->codecDai;
|
||||
if (codecDai == NULL) {
|
||||
codecDai = rtd->accessoryDai;
|
||||
}
|
||||
@@ -89,16 +93,18 @@ static int32_t HwCodecDaiDispatch(const struct AudioCard *audioCard, const struc
|
||||
|
||||
static int32_t HwDspDaiDispatch(const struct AudioCard *audioCard, const struct AudioPcmHwParams *params)
|
||||
{
|
||||
struct AudioRuntimeDeivces *rtd;
|
||||
struct DaiDevice *dspDai;
|
||||
if ((audioCard == NULL) || (params == NULL)) {
|
||||
ADM_LOG_ERR("DspDai input param is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct AudioRuntimeDeivces *rtd = audioCard->rtd;
|
||||
rtd = audioCard->rtd;
|
||||
if (rtd == NULL) {
|
||||
ADM_LOG_ERR("DspDai audioCard rtd is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct DaiDevice *dspDai = rtd->dspDai;
|
||||
dspDai = rtd->dspDai;
|
||||
|
||||
if (dspDai != NULL && dspDai->devData != NULL && dspDai->devData->ops != NULL &&
|
||||
dspDai->devData->ops->HwParams != NULL) {
|
||||
@@ -113,12 +119,14 @@ static int32_t HwDspDaiDispatch(const struct AudioCard *audioCard, const struct
|
||||
|
||||
static int32_t HwPlatfromDispatch(const struct AudioCard *audioCard, const struct AudioPcmHwParams *params)
|
||||
{
|
||||
int ret = 0;
|
||||
struct AudioRuntimeDeivces *rtd;
|
||||
if ((audioCard == NULL) || (params == NULL)) {
|
||||
ADM_LOG_ERR("Platfrom input param is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
struct AudioRuntimeDeivces *rtd = audioCard->rtd;
|
||||
rtd = audioCard->rtd;
|
||||
if (rtd == NULL) {
|
||||
ADM_LOG_ERR("audioCard rtd is NULL.");
|
||||
return HDF_FAILURE;
|
||||
@@ -127,7 +135,7 @@ static int32_t HwPlatfromDispatch(const struct AudioCard *audioCard, const struc
|
||||
/* If there are HwParams function, it will be executed directly.
|
||||
* If not, skip the if statement and execute in sequence.
|
||||
*/
|
||||
int ret = AudioHwParams(audioCard, params);
|
||||
ret = AudioHwParams(audioCard, params);
|
||||
if (ret < 0) {
|
||||
ADM_LOG_ERR("platform hardware params failed ret=%d", ret);
|
||||
return HDF_ERR_IO;
|
||||
@@ -819,6 +827,7 @@ static int32_t StreamHostMmapPositionWrite(const struct HdfDeviceIoClient *clien
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
struct AudioCard *audioCard = NULL;
|
||||
struct PlatformData *platformData;
|
||||
ADM_LOG_DEBUG("entry.");
|
||||
if (client == NULL || reply == NULL) {
|
||||
ADM_LOG_ERR("input param is NULL.");
|
||||
@@ -829,7 +838,7 @@ static int32_t StreamHostMmapPositionWrite(const struct HdfDeviceIoClient *clien
|
||||
ADM_LOG_ERR("audioCard instance is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct PlatformData *platformData = PlatformDataFromCard(audioCard);
|
||||
platformData = PlatformDataFromCard(audioCard);
|
||||
if (platformData == NULL) {
|
||||
ADM_LOG_ERR("platformHost instance is NULL.");
|
||||
return HDF_FAILURE;
|
||||
@@ -897,6 +906,7 @@ static int32_t StreamHostMmapPositionRead(const struct HdfDeviceIoClient *client
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
struct AudioCard *audioCard = NULL;
|
||||
struct PlatformData *platformData;
|
||||
ADM_LOG_DEBUG("entry.");
|
||||
if (client == NULL || reply == NULL) {
|
||||
ADM_LOG_ERR("input param is NULL.");
|
||||
@@ -907,7 +917,7 @@ static int32_t StreamHostMmapPositionRead(const struct HdfDeviceIoClient *client
|
||||
ADM_LOG_ERR("audioCard is NULL.");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct PlatformData *platformData = PlatformDataFromCard(audioCard);
|
||||
platformData = PlatformDataFromCard(audioCard);
|
||||
if (platformData == NULL) {
|
||||
ADM_LOG_ERR("platformHost is NULL.");
|
||||
return HDF_FAILURE;
|
||||
@@ -1478,7 +1488,8 @@ static int32_t StreamDispatch(struct HdfDeviceIoClient *client, int cmdId,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
unsigned int count = sizeof(g_streamDispCmdHandle) / sizeof(g_streamDispCmdHandle[0]);
|
||||
for (unsigned int i = 0; i < count; ++i) {
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < count; ++i) {
|
||||
if ((cmdId == (int)(g_streamDispCmdHandle[i].cmd)) && (g_streamDispCmdHandle[i].func != NULL)) {
|
||||
return g_streamDispCmdHandle[i].func(client, data, reply);
|
||||
}
|
||||
@@ -1489,11 +1500,12 @@ static int32_t StreamDispatch(struct HdfDeviceIoClient *client, int cmdId,
|
||||
|
||||
static struct StreamHost *StreamHostCreateAndBind(struct HdfDeviceObject *device)
|
||||
{
|
||||
struct StreamHost *streamHost;
|
||||
if (device == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct StreamHost *streamHost = (struct StreamHost *)OsalMemCalloc(sizeof(*streamHost));
|
||||
streamHost = (struct StreamHost *)OsalMemCalloc(sizeof(*streamHost));
|
||||
if (streamHost == NULL) {
|
||||
ADM_LOG_ERR("malloc host failed!");
|
||||
return NULL;
|
||||
@@ -1505,12 +1517,13 @@ static struct StreamHost *StreamHostCreateAndBind(struct HdfDeviceObject *device
|
||||
|
||||
static int32_t AudioStreamBind(struct HdfDeviceObject *device)
|
||||
{
|
||||
struct StreamHost *streamHost;
|
||||
ADM_LOG_DEBUG("entry!");
|
||||
if (device == NULL) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
struct StreamHost *streamHost = StreamHostCreateAndBind(device);
|
||||
streamHost = StreamHostCreateAndBind(device);
|
||||
if (streamHost == NULL || streamHost->device == NULL) {
|
||||
ADM_LOG_ERR("StreamHostCreateAndBind failed");
|
||||
return HDF_FAILURE;
|
||||
@@ -1544,12 +1557,13 @@ static int32_t AudioStreamInit(struct HdfDeviceObject *device)
|
||||
|
||||
static void AudioStreamRelease(struct HdfDeviceObject *device)
|
||||
{
|
||||
struct StreamHost *streamHost;
|
||||
if (device == NULL) {
|
||||
ADM_LOG_ERR("device is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
struct StreamHost *streamHost = StreamHostFromDevice(device);
|
||||
streamHost = StreamHostFromDevice(device);
|
||||
if (streamHost == NULL) {
|
||||
ADM_LOG_ERR("renderHost is NULL");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user