【Audio】更新Audio code

Signed-off-by: vb6174 <zhangyunhu@huawei.com>
This commit is contained in:
vb6174 2021-11-05 18:21:07 +08:00
parent 09061d23f5
commit 544176a835
57 changed files with 3284 additions and 1311 deletions

View File

@ -56,8 +56,7 @@ struct CodecData {
struct CodecHost {
struct IDeviceIoService service;
struct HdfDeviceObject *device;
unsigned long priv;
unsigned long aiaoPriv;
void *priv;
};
enum AudioRegParams {

View File

@ -45,7 +45,7 @@ struct DaiData {
struct AudioKcontrol *controls;
int numControls;
bool daiInitFlag;
uint32_t regDaiBase;
unsigned long regVirtualAddr;
struct AudioRegCfgData *regConfig;
struct AudioRegCfgGroupNode **regCfgGroup;
struct OsalMutex mutex;

View File

@ -75,6 +75,7 @@ int32_t AccessoryDeviceCfgGet(struct AccessoryData *data, struct AccessoryTransf
int32_t AccessoryDeviceCtrlRegInit(void);
int32_t AccessoryDeviceRegRead(const struct AccessoryDevice *codec, uint32_t reg, uint32_t *value);
int32_t AccessoryDeviceRegWrite(const struct AccessoryDevice *codec, uint32_t reg, uint32_t value);
int32_t AccessoryGetConfigInfo(const struct HdfDeviceObject *device, struct AccessoryData *accessoryData);
#ifdef __cplusplus
#if __cplusplus

View File

@ -19,17 +19,12 @@ extern "C" {
#endif
#endif /* __cplusplus */
int32_t CodecDeviceReadReg(unsigned long virtualAddress, uint32_t reg, uint32_t *value);
int32_t CodecDeviceWriteReg(unsigned long virtualAddress, uint32_t reg, uint32_t value);
int32_t CodecGetServiceName(const struct HdfDeviceObject *device, const char **drvCodecName);
int32_t CodecGetDaiName(const struct HdfDeviceObject *device, const char **drvDaiName);
int32_t CodecGetConfigInfo(const struct HdfDeviceObject *device, struct CodecData *codecData);
int32_t CodecSetConfigInfo(struct CodecData *codeData, struct DaiData *daiData);
int32_t CodecSetCtlFunc(struct CodecData *codeData, void *aiaoGetCtrl, void *aiaoSetCtrl);
int32_t AccessoryGetConfigInfo(const struct HdfDeviceObject *device, struct AccessoryData *codecData);
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -19,15 +19,6 @@ extern "C" {
int32_t DspGetServiceName(const struct HdfDeviceObject *device, const char **drvDspName);
int32_t DspGetDaiName(const struct HdfDeviceObject *device, const char **drvDaiName);
int32_t DspLinkDeviceInit(struct AudioCard *card, const struct DaiDevice *device);
int32_t DspDeviceInit(const struct DspDevice *device);
int32_t DspDeviceReadReg(const struct DspDevice *device, uint8_t *buf, uint32_t len);
int32_t DspDeviceWriteReg(const struct DspDevice *device, uint8_t *buf, uint32_t len);
int32_t DspLinkStartup(const struct AudioCard *card, const struct DaiDevice *device);
int32_t DspLinkHwParams(const struct AudioCard *card, const struct AudioPcmHwParams *param);
int32_t DspDecodeAudioStream(const struct AudioCard *card, const uint8_t *buf, const struct DspDevice *device);
int32_t DspEncodeAudioStream(const struct AudioCard *card, const uint8_t *buf, const struct DspDevice *device);
int32_t DspEqualizerActive(const struct AudioCard *card, const uint8_t *buf, const struct DspDevice *device);
#ifdef __cplusplus
#if __cplusplus

View File

@ -399,3 +399,29 @@ int32_t AccessoryDeviceRegWrite(const struct AccessoryDevice *codec, uint32_t re
AUDIO_DRIVER_LOG_DEBUG("success");
return HDF_SUCCESS;
}
int32_t AccessoryGetConfigInfo(const struct HdfDeviceObject *device, struct AccessoryData *accessoryData)
{
if (device == NULL) {
AUDIO_DRIVER_LOG_ERR("param is null!");
return HDF_FAILURE;
}
if (accessoryData->regConfig != NULL) {
ADM_LOG_ERR("g_codecData regConfig fail!");
return HDF_FAILURE;
}
accessoryData->regConfig = (struct AudioRegCfgData *)OsalMemCalloc(sizeof(*(accessoryData->regConfig)));
if (accessoryData->regConfig == NULL) {
ADM_LOG_ERR("malloc AudioRegCfgData fail!");
return HDF_FAILURE;
}
if (CodecGetRegConfig(device, accessoryData->regConfig) != HDF_SUCCESS) {
ADM_LOG_ERR("CodecGetRegConfig fail!");
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -13,23 +13,6 @@
#define HDF_LOG_TAG audio_codec_base
int32_t CodecDeviceReadReg(unsigned long virtualAddress, uint32_t reg, uint32_t *val)
{
if (val == NULL) {
AUDIO_DRIVER_LOG_ERR("param val is null.");
return HDF_FAILURE;
}
*val = OSAL_READL((void *)((uintptr_t)(virtualAddress + reg)));
return HDF_SUCCESS;
}
int32_t CodecDeviceWriteReg(unsigned long virtualAddress, uint32_t reg, uint32_t value)
{
OSAL_WRITEL(value, (void *)((uintptr_t)(virtualAddress + reg)));
return HDF_SUCCESS;
}
int32_t CodecGetServiceName(const struct HdfDeviceObject *device, const char **drvCodecName)
{
const struct DeviceResourceNode *node = NULL;
@ -272,29 +255,3 @@ int32_t CodecSetCtlFunc(struct CodecData *codeData, void *aiaoGetCtrl, void *aia
return HDF_SUCCESS;
}
int32_t AccessoryGetConfigInfo(const struct HdfDeviceObject *device, struct AccessoryData *codecData)
{
if (device == NULL) {
AUDIO_DRIVER_LOG_ERR("param is null!");
return HDF_FAILURE;
}
if (codecData->regConfig != NULL) {
ADM_LOG_ERR("g_codecData regConfig fail!");
return HDF_FAILURE;
}
codecData->regConfig = (struct AudioRegCfgData *)OsalMemCalloc(sizeof(*(codecData->regConfig)));
if (codecData->regConfig == NULL) {
ADM_LOG_ERR("malloc AudioRegCfgData fail!");
return HDF_FAILURE;
}
if (CodecGetRegConfig(device, codecData->regConfig) != HDF_SUCCESS) {
ADM_LOG_ERR("CodecGetRegConfig fail!");
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -6,290 +6,11 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_accessory_base.h"
#include "audio_dsp_if.h"
#include "audio_dsp_base.h"
#include "osal_io.h"
#include "spi_if.h"
#include "audio_driver_log.h"
#define DEFAULT_SPEED 2000000
#define BITS_PER_WORD_EIGHT 8
#define DSP_CS_NUM 1
#define DSP_SPI_BUS_NUM 1
enum DspI2sFormatRegVal {
I2S_SAMPLE_FORMAT_REG_VAL_MSB_24 = 0x2, /* MSB-justified data up to 24 bits */
I2S_SAMPLE_FORMAT_REG_VAL_24 = 0x3, /* I2S data up to 24 bits */
I2S_SAMPLE_FORMAT_REG_VAL_LSB_16 = 0x4, /* LSB-justified 16-bit data */
I2S_SAMPLE_FORMAT_REG_VAL_LSB_18 = 0x5, /* LSB-justified 18-bit data */
I2S_SAMPLE_FORMAT_REG_VAL_LSB_20 = 0x6, /* LSB-justified 20-bit data */
I2S_SAMPLE_FORMAT_REG_VAL_LSB_24 = 0x7, /* LSB-justified 24-bit data */
};
struct SpiDevInfo g_devInfo = {
.busNum = DSP_SPI_BUS_NUM,
.csNum = DSP_CS_NUM,
};
int32_t DspLinkStartup(const struct AudioCard *card, const struct DaiDevice *device)
{
(void)card;
(void)device;
return HDF_SUCCESS;
}
static int32_t DspCfgI2sFrequency(uint32_t rate, uint16_t *frequency)
{
switch (rate) {
case I2S_SAMPLE_FREQUENCY_8000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_8000;
break;
case I2S_SAMPLE_FREQUENCY_11025:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_11025;
break;
case I2S_SAMPLE_FREQUENCY_12000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_12000;
break;
case I2S_SAMPLE_FREQUENCY_16000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_16000;
break;
case I2S_SAMPLE_FREQUENCY_22050:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_22050;
break;
case I2S_SAMPLE_FREQUENCY_24000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_24000;
break;
case I2S_SAMPLE_FREQUENCY_32000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_32000;
break;
case I2S_SAMPLE_FREQUENCY_44100:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_44100;
break;
case I2S_SAMPLE_FREQUENCY_48000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_48000;
break;
case I2S_SAMPLE_FREQUENCY_64000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_64000;
break;
case I2S_SAMPLE_FREQUENCY_88200:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_88200;
break;
case I2S_SAMPLE_FREQUENCY_96000:
*frequency = I2S_SAMPLE_FREQUENCY_REG_VAL_96000;
break;
default:
AUDIO_DRIVER_LOG_ERR("rate: %d is not support.", rate);
return HDF_ERR_NOT_SUPPORT;
}
return HDF_SUCCESS;
}
static int32_t DspSetI2sBitWidth(enum AudioFormat format, uint16_t *bitWidth)
{
switch (format) {
case AUDIO_FORMAT_PCM_8_BIT:
*bitWidth = I2S_SAMPLE_FORMAT_REG_VAL_24;
break;
case AUDIO_FORMAT_PCM_16_BIT:
*bitWidth = I2S_SAMPLE_FORMAT_REG_VAL_24;
break;
case AUDIO_FORMAT_PCM_24_BIT:
*bitWidth = I2S_SAMPLE_FORMAT_REG_VAL_24;
break;
default:
AUDIO_DRIVER_LOG_ERR("format: %d is not support.", format);
return HDF_ERR_NOT_SUPPORT;
}
return HDF_SUCCESS;
}
static int DspSetI2sFrequency(uint16_t frequencyVal)
{
return HDF_SUCCESS;
}
static int DspSetI2sFormat(uint16_t formatVal)
{
return HDF_SUCCESS;
}
int32_t DspLinkHwParams(const struct AudioCard *card, const struct AudioPcmHwParams *param)
{
int ret;
uint16_t frequency, bitWidth;
(void)card;
AUDIO_DRIVER_LOG_DEBUG("entry.");
if (param == NULL || param->cardServiceName == NULL) {
AUDIO_DRIVER_LOG_ERR("input param is nullptr.");
return HDF_ERR_INVALID_PARAM;
}
ret = DspCfgI2sFrequency(param->rate, &frequency);
if (ret != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("RateToFrequency fail.");
return HDF_ERR_NOT_SUPPORT;
}
ret = DspSetI2sBitWidth(param->format, &bitWidth);
if (ret != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("FormatToBitWidth fail.");
return HDF_ERR_NOT_SUPPORT;
}
ret = DspSetI2sFrequency(frequency);
if (ret != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("SetDspI2sFs fail.");
return HDF_FAILURE;
}
ret = DspSetI2sFormat(bitWidth);
if (ret != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("SetDspI2sFormat fail.");
return HDF_FAILURE;
}
AUDIO_DRIVER_LOG_DEBUG("DspLinkHwParams: channels = %d, rate = %d, periodSize = %d, \
periodCount = %d, format = %d, cardServiceName = %s \n",
param->channels, param->rate, param->periodSize,
param->periodCount, (uint32_t)param->format, param->cardServiceName);
AUDIO_DRIVER_LOG_DEBUG("success.");
return HDF_SUCCESS;
}
static int DspPowerEnable(void)
{
return HDF_SUCCESS;
}
static int DspGpioPinInit(void)
{
return HDF_SUCCESS;
}
static int DspI2cPinInit(void)
{
return HDF_SUCCESS;
}
static int DspI2sInit(void)
{
return HDF_SUCCESS;
}
static int DspI2cInit(void)
{
return HDF_SUCCESS;
}
/* not init dsp gpio */
static int DspSpiPinInit(void)
{
return HDF_FAILURE;
}
int32_t DspDeviceInit(const struct DspDevice *device)
{
DevHandle devHandle;
struct SpiCfg devCfg = {
.maxSpeedHz = DEFAULT_SPEED,
.mode = SPI_CLK_POLARITY,
.transferMode = SPI_DMA_TRANSFER,
.bitsPerWord = BITS_PER_WORD_EIGHT,
};
if (DspPowerEnable() != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DspPowerEnable: return Error!");
return HDF_FAILURE;
}
if (DspGpioPinInit() != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DspGpioPinInit: return Error!");
return HDF_FAILURE;
}
if (DspI2cPinInit() != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DspI2cPinInit: return Error!");
return HDF_FAILURE;
}
if (DspSpiPinInit() == HDF_SUCCESS) {
devHandle = SpiOpen(&g_devInfo);
if (devHandle == NULL) {
AUDIO_DRIVER_LOG_ERR("DspDeviceOpen: Spi failed!");
return HDF_FAILURE;
}
if (SpiSetCfg(devHandle, &devCfg) != HDF_SUCCESS) {
SpiClose(devHandle);
AUDIO_DRIVER_LOG_ERR("DspDeviceCfg: spi failed!");
return HDF_FAILURE;
}
SpiClose(devHandle);
} else {
AUDIO_DRIVER_LOG_ERR("Dsp Gpio Pin: not init!");
}
if (DspI2cInit() != HDF_SUCCESS) {
return HDF_FAILURE;
}
if (DspI2sInit() != HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t DspDeviceReadReg(const struct DspDevice *device, uint8_t *buf, uint32_t len)
{
int32_t ret;
DevHandle devHandle = SpiOpen(&g_devInfo);
if (devHandle == NULL) {
AUDIO_DRIVER_LOG_ERR("DspDeviceOpen: Spi failed!");
return HDF_FAILURE;
}
ret = SpiRead(devHandle, buf, len);
if (ret != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DspDeviceRead: spi failed!");
SpiClose(devHandle);
return HDF_FAILURE;
}
SpiClose(devHandle);
return HDF_SUCCESS;
}
int32_t DspDeviceWriteReg(const struct DspDevice *device, uint8_t *buf, uint32_t len)
{
int32_t ret;
DevHandle devHandle = SpiOpen(&g_devInfo);
if (devHandle == NULL) {
AUDIO_DRIVER_LOG_ERR("DspDeviceOpen: Spi failed!");
return HDF_FAILURE;
}
ret = SpiWrite(devHandle, buf, len);
if (ret != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DspDeviceRead: spi failed!");
SpiClose(devHandle);
return HDF_FAILURE;
}
SpiClose(devHandle);
return HDF_SUCCESS;
}
int32_t DspLinkDeviceInit(struct AudioCard *card, const struct DaiDevice *device)
{
if (device == NULL || device->devDaiName == NULL) {
AUDIO_DRIVER_LOG_ERR("input para is nullptr.");
return HDF_FAILURE;
}
AUDIO_DRIVER_LOG_DEBUG("dsp Link device name: %s\n", device->devDaiName);
(void)card;
return HDF_SUCCESS;
}
#define HDF_LOG_TAG audio_dsp_base
int32_t DspGetServiceName(const struct HdfDeviceObject *device, const char **drvDspName)
{
@ -297,7 +18,7 @@ int32_t DspGetServiceName(const struct HdfDeviceObject *device, const char **drv
struct DeviceResourceIface *drsOps = NULL;
int32_t ret;
if (device == NULL) {
if (device == NULL || drvDspName == NULL) {
AUDIO_DRIVER_LOG_ERR("device is NULL.");
return HDF_FAILURE;
}
@ -328,7 +49,7 @@ int32_t DspGetDaiName(const struct HdfDeviceObject *device, const char **drvDaiN
struct DeviceResourceIface *drsOps = NULL;
int32_t ret;
if (device == NULL) {
if (device == NULL || drvDaiName == NULL) {
AUDIO_DRIVER_LOG_ERR("input para is null pointer.");
return HDF_FAILURE;
}
@ -352,32 +73,3 @@ int32_t DspGetDaiName(const struct HdfDeviceObject *device, const char **drvDaiN
return HDF_SUCCESS;
}
int32_t DspDecodeAudioStream(const struct AudioCard *card, const uint8_t *buf, const struct DspDevice *device)
{
(void)card;
(void)buf;
(void)device;
AUDIO_DRIVER_LOG_DEBUG("decode run!!!");
return HDF_SUCCESS;
}
int32_t DspEncodeAudioStream(const struct AudioCard *card, const uint8_t *buf, const struct DspDevice *device)
{
(void)card;
(void)buf;
(void)device;
AUDIO_DRIVER_LOG_DEBUG("encode run!!!");
return HDF_SUCCESS;
}
int32_t DspEqualizerActive(const struct AudioCard *card, const uint8_t *buf, const struct DspDevice *device)
{
(void)card;
(void)buf;
(void)device;
AUDIO_DRIVER_LOG_DEBUG("equalizer run!!!");
return HDF_SUCCESS;
}

View File

@ -426,7 +426,6 @@ static int32_t MmapWriteData(struct PlatformData *data, char *tmpBuf)
if (data->renderBufInfo.trafBufSize > data->renderBufInfo.cirBufSize) {
AUDIO_DRIVER_LOG_ERR("transferFrameSize is tool big.");
OsalMemFree(tmpBuf);
return HDF_FAILURE;
}
@ -435,7 +434,6 @@ static int32_t MmapWriteData(struct PlatformData *data, char *tmpBuf)
data->renderBufInfo.trafBufSize);
if (ret != EOK) {
AUDIO_DRIVER_LOG_ERR("CopyFromUser failed.");
OsalMemFree(tmpBuf);
return HDF_FAILURE;
}
@ -443,10 +441,9 @@ static int32_t MmapWriteData(struct PlatformData *data, char *tmpBuf)
tmpBuf, data->renderBufInfo.trafBufSize);
if (ret != 0) {
AUDIO_DRIVER_LOG_ERR("memcpy_s failed.");
OsalMemFree(tmpBuf);
return HDF_FAILURE;
}
data->renderBufInfo.wptrOffSet = wPtr + data->renderBufInfo.trafBufSize;
data->renderBufInfo.wbufOffSet += data->renderBufInfo.trafBufSize;
data->renderBufInfo.framesPosition += data->renderBufInfo.trafBufSize / data->pcmInfo.frameSize;
@ -864,7 +861,7 @@ int32_t AudioRenderTrigger(struct AudioCard *card, int cmd)
}
switch (cmd) {
case AUDIO_DRV_PCM_IOCTRL_RENDER_START:
case AUDIO_DRV_PCM_IOCTL_RENDER_START:
if (AudioDmaSubmit(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPending fail.");
return HDF_FAILURE;
@ -881,7 +878,7 @@ int32_t AudioRenderTrigger(struct AudioCard *card, int cmd)
data->renderBufInfo.runStatus = PCM_START;
break;
case AUDIO_DRV_PCM_IOCTRL_RENDER_STOP:
case AUDIO_DRV_PCM_IOCTL_RENDER_STOP:
if (AudioDmaPause(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPause fail.");
return HDF_FAILURE;
@ -893,7 +890,7 @@ int32_t AudioRenderTrigger(struct AudioCard *card, int cmd)
data->renderBufInfo.runStatus = PCM_STOP;
break;
case AUDIO_DRV_PCM_IOCTRL_RENDER_PAUSE:
case AUDIO_DRV_PCM_IOCTL_RENDER_PAUSE:
if (AudioDmaPause(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPause fail.");
return HDF_FAILURE;
@ -905,7 +902,7 @@ int32_t AudioRenderTrigger(struct AudioCard *card, int cmd)
data->renderBufInfo.runStatus = PCM_PAUSE;
break;
case AUDIO_DRV_PCM_IOCTRL_RENDER_RESUME:
case AUDIO_DRV_PCM_IOCTL_RENDER_RESUME:
if (AudioDmaResume(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPause fail.");
return HDF_FAILURE;
@ -941,7 +938,7 @@ int32_t AudioCaptureTrigger(struct AudioCard *card, int cmd)
}
switch (cmd) {
case AUDIO_DRV_PCM_IOCTRL_CAPTURE_START:
case AUDIO_DRV_PCM_IOCTL_CAPTURE_START:
if (AudioDmaSubmit(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPending fail.");
return HDF_FAILURE;
@ -957,7 +954,7 @@ int32_t AudioCaptureTrigger(struct AudioCard *card, int cmd)
data->captureBufInfo.runStatus = PCM_START;
break;
case AUDIO_DRV_PCM_IOCTRL_CAPTURE_STOP:
case AUDIO_DRV_PCM_IOCTL_CAPTURE_STOP:
if (AudioDmaPause(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPause fail.");
return HDF_FAILURE;
@ -968,7 +965,7 @@ int32_t AudioCaptureTrigger(struct AudioCard *card, int cmd)
}
data->captureBufInfo.runStatus = PCM_STOP;
break;
case AUDIO_DRV_PCM_IOCTRL_CAPTURE_PAUSE:
case AUDIO_DRV_PCM_IOCTL_CAPTURE_PAUSE:
if (AudioDmaPause(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPause fail.");
return HDF_FAILURE;
@ -980,7 +977,7 @@ int32_t AudioCaptureTrigger(struct AudioCard *card, int cmd)
data->captureBufInfo.runStatus = PCM_PAUSE;
break;
case AUDIO_DRV_PCM_IOCTRL_CAPTURE_RESUME:
case AUDIO_DRV_PCM_IOCTL_CAPTURE_RESUME:
if (AudioDmaResume(data) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("DmaPause fail.");
return HDF_FAILURE;
@ -1022,11 +1019,6 @@ int32_t AudioHwParams(const struct AudioCard *card, const struct AudioPcmHwParam
return HDF_FAILURE;
}
if (AudioDmaRequestChannel(platformData) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("Dma Request Channel fail.");
return HDF_FAILURE;
}
if (AudioFramatToBitWidth(param->format, &platformData->pcmInfo.bitWidth) != HDF_SUCCESS) {
return HDF_FAILURE;
}
@ -1034,6 +1026,11 @@ int32_t AudioHwParams(const struct AudioCard *card, const struct AudioPcmHwParam
return HDF_FAILURE;
}
if (AudioDmaRequestChannel(platformData) != HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("Dma Request Channel fail.");
return HDF_FAILURE;
}
if (param->streamType == AUDIO_RENDER_STREAM) {
if (AudioSetRenderBufInfo(platformData, param) != HDF_SUCCESS) {
return HDF_FAILURE;

View File

@ -0,0 +1,100 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_common_test.h"
#include <gtest/gtest.h>
#include "hdf_uhdf_test.h"
using namespace testing::ext;
namespace {
class AudioAccessoryBaseTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void AudioAccessoryBaseTest::SetUpTestCase()
{
HdfTestOpenService();
}
void AudioAccessoryBaseTest::TearDownTestCase()
{
HdfTestCloseService();
}
void AudioAccessoryBaseTest::SetUp()
{
}
void AudioAccessoryBaseTest::TearDown()
{
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_I2cReadWrite, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTI2CREADWRITE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_RegBitsRead, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREGBITSREAD, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_RegBitsUpdate, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREGBITSUPDATE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_DeviceFrequencyParse, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDEVICEFREQUENCYPARSE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_DaiParamsUpdate, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDAIPARAMSUPDATE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_DeviceCfgGet, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDEVICECFGGET, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_DeviceCtrlRegInit, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDEVICECTRLREGINIT, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_DeviceRegRead, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDEVICEREGREAD, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_DeviceRegWrite, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDEVICEREGWRITE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioAccessoryBaseTest, AudioAccessoryBaseTest_AccessoryGetConfigInfo, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTAGETCONFIGINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_common_test.h"
#include <gtest/gtest.h>
#include "hdf_uhdf_test.h"
using namespace testing::ext;
namespace {
class AudioCodecBaseTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void AudioCodecBaseTest::SetUpTestCase()
{
HdfTestOpenService();
}
void AudioCodecBaseTest::TearDownTestCase()
{
HdfTestCloseService();
}
void AudioCodecBaseTest::SetUp()
{
}
void AudioCodecBaseTest::TearDown()
{
}
HWTEST_F(AudioCodecBaseTest, AudioCodecBaseTest_GetServiceName, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTGETSERVICENAME, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCodecBaseTest, AudioCodecBaseTest_GetDaiName, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTGETDAINAME, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCodecBaseTest, AudioCodecBaseTest_GetConfigInfo, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTGETCONFIGINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCodecBaseTest, AudioCodecBaseTest_SetConfigInfo, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTSETCONFIGINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCodecBaseTest, AudioCodecBaseTest_SetCtlFunc, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTSETCTLFUNC, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_COMMON_TEST_H
#define AUDIO_COMMON_TEST_H
#include "hdf_types.h"
const int32_t g_testAudioType = 701; // 701 is TEST_AUDIO_TYPE
enum {
TESTI2CREADWRITE = 48,
TESTREGBITSREAD,
TESTREGBITSUPDATE,
TESTDEVICEFREQUENCYPARSE,
TESTDAIPARAMSUPDATE,
TESTDEVICECFGGET,
TESTDEVICECTRLREGINIT,
TESTDEVICEREGREAD,
TESTDEVICEREGWRITE,
TESTAGETCONFIGINFO,
TESTGETSERVICENAME,
TESTGETDAINAME,
TESTGETCONFIGINFO,
TESTSETCONFIGINFO,
TESTSETCTLFUNC,
TESTDAIDATAFROMCARD,
TESTDAIGETCONFIGINFO,
TESTDAICHECKSAMPLERATE,
TESTDAISETCONFIGINFO,
TESTDMABUFALLOC,
TESTDMABUFFREE,
TESTDMAREQUESTCHANNEL,
TESTDMACONFIGCHANNEL,
TESTDMAPREP,
TESTDMASUBMIT,
TESTDMAPENDING,
TESTDMAPAUSE,
TESTDMARESUME,
TESTDMAPOINTER,
TESTDSPGETSERVICENAME,
TESTDSPGETDAINAME,
TESTDATAFROMCARD,
TESTBYTESTOFRAMES,
TESTDATABIGENDIANCHANGE,
TESTFRAMATTOBITWIDTH,
TESTSETPCMINFO,
TESTSETRENDERBUFINFO,
TESTSETCAPTUREBUFINFO,
TESTPCMWRITE,
TESTPCMREAD,
TESTPCMMMAPWRITE,
TESTPCMMMAPREAD,
TESTRENDEROPEN,
TESTCAPTUREOPEN,
TESTRENDERCLOSE,
TESTPCMPOINTER,
TESTCAPTURECLOSE,
TESTHWPARAMS,
TESTRENDERPREPARE,
TESTCAPTUREPREPARE,
TESTRENDERTRIGGER,
TESTCAPTURETRIGGER,
};
#endif /* AUDIO_COMMON_TEST_H */

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_common_test.h"
#include <gtest/gtest.h>
#include "hdf_uhdf_test.h"
using namespace testing::ext;
namespace {
class AudioDaiBaseTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void AudioDaiBaseTest::SetUpTestCase()
{
HdfTestOpenService();
}
void AudioDaiBaseTest::TearDownTestCase()
{
HdfTestCloseService();
}
void AudioDaiBaseTest::SetUp()
{
}
void AudioDaiBaseTest::TearDown()
{
}
HWTEST_F(AudioDaiBaseTest, AudioDaiBaseTest_DataFromCard, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDAIDATAFROMCARD, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDaiBaseTest, AudioDaiBaseTest_GetConfigInfo, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDAIGETCONFIGINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDaiBaseTest, AudioDaiBaseTest_CheckSampleRate, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDAICHECKSAMPLERATE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDaiBaseTest, AudioDaiBaseTest_SetConfigInfo, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDAISETCONFIGINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -0,0 +1,101 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_common_test.h"
#include <gtest/gtest.h>
#include "hdf_uhdf_test.h"
using namespace testing::ext;
namespace {
class AudioDmaBaseTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void AudioDmaBaseTest::SetUpTestCase()
{
HdfTestOpenService();
}
void AudioDmaBaseTest::TearDownTestCase()
{
HdfTestCloseService();
}
void AudioDmaBaseTest::SetUp()
{
}
void AudioDmaBaseTest::TearDown()
{
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaBufAlloc, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMABUFALLOC, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaBufFree, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMABUFFREE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaRequestChannel, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMAREQUESTCHANNEL, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaConfigChannel, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMACONFIGCHANNEL, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaPrep, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMAPREP, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaSubmit, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMASUBMIT, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaPending, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMAPENDING, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaPause, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMAPAUSE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaResume, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMARESUME, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDmaBaseTest, AudioDmaBaseTest_DmaPointer, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDMAPOINTER, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -11,8 +11,9 @@
#include "hdf_uhdf_test.h"
using namespace testing::ext;
namespace {
class AudioStreamDispatchTest : public testing::Test {
class AudioDspBaseTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
@ -20,27 +21,33 @@ public:
void TearDown();
};
void AudioStreamDispatchTest::SetUpTestCase()
void AudioDspBaseTest::SetUpTestCase()
{
HdfTestOpenService();
}
void AudioStreamDispatchTest::TearDownTestCase()
void AudioDspBaseTest::TearDownTestCase()
{
HdfTestCloseService();
}
void AudioStreamDispatchTest::SetUp()
void AudioDspBaseTest::SetUp()
{
}
void AudioStreamDispatchTest::TearDown()
void AudioDspBaseTest::TearDown()
{
}
HWTEST_F(AudioStreamDispatchTest, AudioStreamDispatchTest001, TestSize.Level1)
HWTEST_F(AudioDspBaseTest, AudioDspBaseTest_DspGetServiceName, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTSTREAMDISPATCH, -1};
struct HdfTestMsg msg = {g_testAudioType, TESTDSPGETSERVICENAME, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioDspBaseTest, AudioDspBaseTest_DspGetDaiName, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDSPGETDAINAME, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -0,0 +1,167 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_common_test.h"
#include <gtest/gtest.h>
#include "hdf_uhdf_test.h"
using namespace testing::ext;
namespace {
class AudioPlatformBaseTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
};
void AudioPlatformBaseTest::SetUpTestCase()
{
HdfTestOpenService();
}
void AudioPlatformBaseTest::TearDownTestCase()
{
HdfTestCloseService();
}
void AudioPlatformBaseTest::SetUp()
{
}
void AudioPlatformBaseTest::TearDown()
{
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_PlatformDataFromCardTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDATAFROMCARD, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioBytesToFramesTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTBYTESTOFRAMES, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioDataBigEndianChangeTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTDATABIGENDIANCHANGE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioFramatToBitWidthTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTFRAMATTOBITWIDTH, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioSetPcmInfoTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTSETPCMINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioSetRenderBufInfoTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTSETRENDERBUFINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioSetCaptureBufInfoTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTSETCAPTUREBUFINFO, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioPcmWriteTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTPCMWRITE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioPcmReadTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTPCMREAD, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioPcmMmapWriteTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTPCMMMAPWRITE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioPcmMmapReadTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTPCMMMAPREAD, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioRenderOpenTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTRENDEROPEN, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioCaptureOpenTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCAPTUREOPEN, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioRenderCloseTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTRENDERCLOSE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioPcmPointerTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTPCMPOINTER, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioCaptureCloseTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCAPTURECLOSE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioHwParamsTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTHWPARAMS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioRenderPrepareTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTRENDERPREPARE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioCapturePrepareTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCAPTUREPREPARE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioRenderTriggerTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTRENDERTRIGGER, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioPlatformBaseTest, AudioPlatformBaseTest_AudioCaptureTriggerTest, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCAPTURETRIGGER, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -36,11 +36,6 @@ struct AudioCtrlElemValue {
uint32_t value[2];
};
struct AudioKcontrol;
typedef int32_t (*KconfigInfo_t)(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemInfo *elemInfo);
typedef int32_t (*KconfigGet_t)(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemValue *elemValue);
typedef int32_t (*KconfigSet_t)(const struct AudioKcontrol *kcontrol, const struct AudioCtrlElemValue *elemValue);
/* mixer control */
struct AudioMixerControl {
int32_t min;
@ -58,9 +53,9 @@ struct AudioMixerControl {
struct AudioKcontrol {
const char *name; /* ASCII name of item */
int32_t iface;
KconfigInfo_t Info;
KconfigGet_t Get;
KconfigSet_t Set;
int32_t (*Info)(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemInfo *elemInfo);
int32_t (*Get)(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemValue *elemValue);
int32_t (*Set)(const struct AudioKcontrol *kcontrol, const struct AudioCtrlElemValue *elemValue);
void *privateData;
void *pri;
unsigned long privateValue;

View File

@ -23,44 +23,28 @@ extern "C" {
#endif
#endif /* __cplusplus */
#define CHANNEL_MAX_NUM 2
#define CHANNEL_MIN_NUM 1
int32_t AudioDeviceReadReg(unsigned long virtualAddress, uint32_t reg, uint32_t *value);
int32_t AudioDeviceWriteReg(unsigned long virtualAddress, uint32_t reg, uint32_t value);
#define AUDIO_DAI_LINK_COMPLETE 1
#define AUDIO_DAI_LINK_UNCOMPLETE 0
enum AudioDeviceType {
AUDIO_DAI_DEVICE,
AUDIO_DSP_DEVICE,
AUDIO_PLATFORM_DEVICE,
AUDIO_CODEC_DEVICE,
AUDIO_ACCESSORY_DEVICE,
AUDIO_DEVICE_BUTT,
};
enum PlayStatus {
STREAM_START = 4,
STREAM_STOP,
};
/* Dai registration interface */
int32_t AudioSocRegisterDai(struct HdfDeviceObject *device, struct DaiData *data);
/* Platform registration interface */
int32_t AudioSocRegisterPlatform(struct HdfDeviceObject *device, struct PlatformData *data);
/* Codec registration interface */
int32_t AudioSocRegisterPlatform(struct HdfDeviceObject *device, struct PlatformData *platformData);
int32_t AudioSocRegisterDai(struct HdfDeviceObject *device, struct DaiData *daiData);
int32_t AudioRegisterDsp(struct HdfDeviceObject *device, struct DspData *dspData, struct DaiData *DaiData);
int32_t AudioRegisterCodec(struct HdfDeviceObject *device, struct CodecData *codecData, struct DaiData *daiData);
int32_t AudioRegisterAccessory(struct HdfDeviceObject *device,
struct AccessoryData *accessoryData, struct DaiData *daiData);
int32_t AudioBindDaiLink(struct AudioCard *audioCard, const struct AudioConfigData *configData);
int32_t AudioSocDeviceRegister(struct HdfDeviceObject *device, void *data, enum AudioDeviceType deviceType);
int32_t AudioSocRegisterDsp(struct HdfDeviceObject *device, struct DaiData *data);
int32_t AudioRegisterAccessory(struct HdfDeviceObject *device, struct AccessoryData *data, struct DaiData *daiData);
int32_t AudioUpdateCodecRegBits(struct CodecDevice *codec,
const struct AudioMixerControl *mixerControl, uint32_t value);
int32_t AudioUpdateAccessoryRegBits(struct AccessoryDevice *accessory,
const struct AudioMixerControl *mixerControl, uint32_t value);
int32_t AudioUpdateDaiRegBits(const struct DaiDevice *dai, struct AudioMixerControl *mixerControl, uint32_t value);
struct DaiDevice *AudioKcontrolGetCpuDai(const struct AudioKcontrol *kcontrol);
struct CodecDevice *AudioKcontrolGetCodec(const struct AudioKcontrol *kcontrol);
struct AccessoryDevice *AudioKcontrolGetAccessory(const struct AudioKcontrol *kcontrol);
struct DaiDevice *AudioKcontrolGetCpuDai(const struct AudioKcontrol *kcontrol);
int32_t AudioAddControls(struct AudioCard *audioCard,
const struct AudioKcontrol *controls, int32_t controlMaxNum);
struct AudioKcontrol *AudioAddControl(const struct AudioCard *audioCard, const struct AudioKcontrol *ctl);
@ -86,7 +70,7 @@ int32_t AudioCodecGetCtrlOps(const struct AudioKcontrol *kcontrol, struct AudioC
int32_t AudioCodecSetCtrlOps(const struct AudioKcontrol *kcontrol, const struct AudioCtrlElemValue *elemValue);
int32_t AudioAccessoryGetCtrlOps(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemValue *elemValue);
int32_t AudioAccessorySetCtrlOps(const struct AudioKcontrol *kcontrol, const struct AudioCtrlElemValue *elemValue);
int32_t AudioRegisterDsp(struct HdfDeviceObject *device, struct DspData *dspData, struct DaiData *DaiData);
int32_t AudioCpuDaiSetCtrlOps(const struct AudioKcontrol *kcontrol, const struct AudioCtrlElemValue *elemValue);
int32_t AudioCpuDaiGetCtrlOps(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemValue *elemValue);

View File

@ -24,8 +24,6 @@ extern "C" {
#endif
#endif /* __cplusplus */
#define BUFF_SIZE_MAX 64
#define AUDIO_LIST_HEAD_INIT(name) { &(name), &(name) }
#define AUDIO_LIST_HEAD(name) \
@ -207,16 +205,6 @@ struct AudioRuntimeDeivces {
struct AudioHost *AudioHostCreateAndBind(struct HdfDeviceObject *device);
static inline struct HdfDeviceObject *AudioHostToDevice(struct AudioHost *host)
{
return (host == NULL) ? NULL : host->device;
}
static inline struct AudioHost *AudioHostFromDevice(struct HdfDeviceObject *device)
{
return (device == NULL) ? NULL : (struct AudioHost *)device->service;
}
/* Get a sound card instance */
struct AudioCard *GetCardInstance(const char *serviceName);

View File

@ -42,6 +42,7 @@ enum AudioRegOpsType {
AUDIO_CTRL_SAPM_PATAM_GROUP,
AUDIO_DAI_STARTUP_PATAM_GROUP,
AUDIO_DAI_PATAM_GROUP,
AUDIO_DAI_TRIGGER_GROUP,
AUDIO_CTRL_CFG_GROUP,
AUDIO_SAPM_COMP_GROUP,
AUDIO_SAPM_CFG_GROUP,

View File

@ -12,12 +12,34 @@
#define HDF_LOG_TAG audio_core
#define CHANNEL_MAX_NUM 2
#define CHANNEL_MIN_NUM 1
#define AUDIO_DAI_LINK_COMPLETE 1
#define AUDIO_DAI_LINK_UNCOMPLETE 0
AUDIO_LIST_HEAD(daiController);
AUDIO_LIST_HEAD(platformController);
AUDIO_LIST_HEAD(codecController);
AUDIO_LIST_HEAD(dspController);
AUDIO_LIST_HEAD(accessoryController);
int32_t AudioDeviceReadReg(unsigned long virtualAddress, uint32_t reg, uint32_t *val)
{
if (val == NULL) {
AUDIO_DRIVER_LOG_ERR("param val is null.");
return HDF_FAILURE;
}
*val = OSAL_READL((void *)((uintptr_t)(virtualAddress + reg)));
return HDF_SUCCESS;
}
int32_t AudioDeviceWriteReg(unsigned long virtualAddress, uint32_t reg, uint32_t value)
{
OSAL_WRITEL(value, (void *)((uintptr_t)(virtualAddress + reg)));
return HDF_SUCCESS;
}
int32_t AudioSocRegisterPlatform(struct HdfDeviceObject *device, struct PlatformData *platformData)
{
struct PlatformDevice *platformDevice = NULL;
@ -42,12 +64,12 @@ int32_t AudioSocRegisterPlatform(struct HdfDeviceObject *device, struct Platform
return HDF_SUCCESS;
}
int32_t AudioSocRegisterDai(struct HdfDeviceObject *device, struct DaiData *data)
int32_t AudioSocRegisterDai(struct HdfDeviceObject *device, struct DaiData *daiData)
{
struct DaiDevice *dai = NULL;
if ((device == NULL) || (data == NULL)) {
ADM_LOG_ERR("Input params check error: device=%p, data=%p.", device, data);
if ((device == NULL) || (daiData == NULL)) {
ADM_LOG_ERR("Input params check error: device=%p, daiData=%p.", device, daiData);
return HDF_ERR_INVALID_OBJECT;
}
@ -57,8 +79,8 @@ int32_t AudioSocRegisterDai(struct HdfDeviceObject *device, struct DaiData *data
return HDF_ERR_MALLOC_FAIL;
}
dai->devDaiName = data->drvDaiName;
dai->devData = data;
dai->devDaiName = daiData->drvDaiName;
dai->devData = daiData;
dai->device = device;
DListInsertHead(&dai->list, &daiController);
ADM_LOG_INFO("Register [%s] success.", dai->devDaiName);
@ -66,13 +88,14 @@ int32_t AudioSocRegisterDai(struct HdfDeviceObject *device, struct DaiData *data
return HDF_SUCCESS;
}
int32_t AudioRegisterAccessory(struct HdfDeviceObject *device, struct AccessoryData *data, struct DaiData *daiData)
int32_t AudioRegisterAccessory(struct HdfDeviceObject *device,
struct AccessoryData *accessoryData, struct DaiData *daiData)
{
struct AccessoryDevice *accessory = NULL;
int32_t ret;
if (device == NULL || data == NULL || daiData == NULL) {
ADM_LOG_ERR("Input params check error: device=%p, data=%p, daiData=%p.", device, data, daiData);
if (device == NULL || accessoryData == NULL || daiData == NULL) {
ADM_LOG_ERR("Input params check error: device=%p, accessoryData=%p, daiData=%p.", device, accessoryData, daiData);
return HDF_ERR_INVALID_OBJECT;
}
@ -83,11 +106,11 @@ int32_t AudioRegisterAccessory(struct HdfDeviceObject *device, struct AccessoryD
}
OsalMutexInit(&accessory->mutex);
accessory->devAccessoryName = data->drvAccessoryName;
accessory->devData = data;
accessory->devAccessoryName = accessoryData->drvAccessoryName;
accessory->devData = accessoryData;
accessory->device = device;
ret = AudioSocDeviceRegister(device, (void *)daiData, AUDIO_DAI_DEVICE);
ret = AudioSocRegisterDai(device, daiData);
if (ret != HDF_SUCCESS) {
OsalMemFree(accessory);
ADM_LOG_ERR("Register accessory device fail ret=%d", ret);
@ -121,7 +144,7 @@ int32_t AudioRegisterCodec(struct HdfDeviceObject *device, struct CodecData *cod
codec->devData = codecData;
codec->device = device;
ret = AudioSocDeviceRegister(device, (void *)daiData, AUDIO_DAI_DEVICE);
ret = AudioSocRegisterDai(device, daiData);
if (ret != HDF_SUCCESS) {
OsalIoUnmap((void *)((uintptr_t)(void*)&(codec->devData->virtualAddress)));
OsalMemFree(codec);
@ -155,7 +178,7 @@ int32_t AudioRegisterDsp(struct HdfDeviceObject *device, struct DspData *dspData
dspDev->devData = dspData;
dspDev->device = device;
ret = AudioSocDeviceRegister(device, (void *)DaiData, AUDIO_DAI_DEVICE);
ret = AudioSocRegisterDai(device, DaiData );
if (ret != HDF_SUCCESS) {
OsalMemFree(dspDev);
ADM_LOG_ERR("Register dai device fail ret=%d", ret);
@ -167,47 +190,7 @@ int32_t AudioRegisterDsp(struct HdfDeviceObject *device, struct DspData *dspData
return HDF_SUCCESS;
}
int32_t AudioSocDeviceRegister(struct HdfDeviceObject *device, void *data, enum AudioDeviceType deviceType)
{
struct PlatformData *platformData = NULL;
struct DaiData *daiData = NULL;
int32_t ret;
if ((device == NULL) || (data == NULL) || (deviceType >= AUDIO_DEVICE_BUTT) || (deviceType < 0)) {
ADM_LOG_ERR("Input params check error: device=%p, data=%p, deviceType=%d.",
device, data, deviceType);
return HDF_ERR_INVALID_OBJECT;
}
switch (deviceType) {
case AUDIO_DAI_DEVICE: {
daiData = (struct DaiData *)data;
ret = AudioSocRegisterDai(device, daiData);
if (ret != HDF_SUCCESS) {
ADM_LOG_ERR("Register dai device fail ret=%d", ret);
return HDF_FAILURE;
}
break;
}
case AUDIO_PLATFORM_DEVICE: {
platformData = (struct PlatformData *)data;
ret = AudioSocRegisterPlatform(device, platformData);
if (ret != HDF_SUCCESS) {
ADM_LOG_ERR("Register dma device fail ret=%d", ret);
return HDF_FAILURE;
}
break;
}
default: {
ADM_LOG_ERR("Invalid device type.");
return HDF_FAILURE;
}
}
return HDF_SUCCESS;
}
int32_t AudioSeekPlatformDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
static int32_t AudioSeekPlatformDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
{
struct PlatformDevice *platform = NULL;
if (rtd == NULL || configData == NULL) {
@ -230,7 +213,7 @@ int32_t AudioSeekPlatformDevice(struct AudioRuntimeDeivces *rtd, const struct Au
return HDF_SUCCESS;
}
int32_t AudioSeekCpuDaiDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
static int32_t AudioSeekCpuDaiDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
{
struct DaiDevice *cpuDai = NULL;
if (rtd == NULL || configData == NULL) {
@ -257,7 +240,7 @@ int32_t AudioSeekCpuDaiDevice(struct AudioRuntimeDeivces *rtd, const struct Audi
return HDF_SUCCESS;
}
int32_t AudioSeekCodecDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
static int32_t AudioSeekCodecDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
{
struct CodecDevice *codec = NULL;
struct DaiDevice *codecDai = NULL;
@ -288,7 +271,7 @@ int32_t AudioSeekCodecDevice(struct AudioRuntimeDeivces *rtd, const struct Audio
return HDF_SUCCESS;
}
int32_t AudioSeekAccessoryDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
static int32_t AudioSeekAccessoryDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
{
struct AccessoryDevice *accessory = NULL;
struct DaiDevice *accessoryDai = NULL;
@ -321,7 +304,7 @@ int32_t AudioSeekAccessoryDevice(struct AudioRuntimeDeivces *rtd, const struct A
return HDF_SUCCESS;
}
int32_t AudioSeekDspDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
static int32_t AudioSeekDspDevice(struct AudioRuntimeDeivces *rtd, const struct AudioConfigData *configData)
{
struct DspDevice *dsp = NULL;
struct DaiDevice *dspDai = NULL;
@ -608,7 +591,7 @@ int32_t AudioDaiReadReg(const struct DaiDevice *dai, uint32_t reg, uint32_t *val
ADM_LOG_ERR("Input param is NULL.");
return HDF_FAILURE;
}
virtualAddress = dai->devData->regDaiBase;
virtualAddress = dai->devData->regVirtualAddr;
ret = dai->devData->Read(virtualAddress, reg, val);
if (ret != HDF_SUCCESS) {
ADM_LOG_ERR("dai device read fail.");
@ -625,7 +608,7 @@ int32_t AudioDaiWriteReg(const struct DaiDevice *dai, uint32_t reg, uint32_t val
ADM_LOG_ERR("Input param codec is NULL.");
return HDF_FAILURE;
}
virtualAddress = dai->devData->regDaiBase;
virtualAddress = dai->devData->regVirtualAddr;
ret = dai->devData->Write(virtualAddress, reg, val);
if (ret != HDF_SUCCESS) {
ADM_LOG_ERR("dai device write fail.");

View File

@ -365,7 +365,7 @@ static int32_t AudioDriverInit(struct HdfDeviceObject *device)
ADM_LOG_ERR("device is NULL.");
return HDF_ERR_INVALID_OBJECT;
}
audioHost = AudioHostFromDevice(device);
audioHost = (struct AudioHost *)device->service;
if (audioHost == NULL) {
ADM_LOG_ERR("audioHost is NULL.");
return HDF_FAILURE;
@ -432,7 +432,7 @@ static void AudioDriverRelease(struct HdfDeviceObject *device)
ADM_LOG_ERR("device is NULL.");
return;
}
audioHost = AudioHostFromDevice(device);
audioHost = (struct AudioHost *)device->service;
if (audioHost == NULL) {
ADM_LOG_ERR("audioHost is NULL.");
return;

View File

@ -57,6 +57,7 @@ static char *g_audioRegGroupName[AUDIO_GROUP_MAX] = {
"ctrlSapmParamsSeqConfig",
"daiStartupSeqConfig",
"daiParamsSeqConfig",
"daiTriggerSeqConfig",
"controlsConfig",
"sapmComponent",
"sapmConfig"
@ -364,6 +365,7 @@ static int32_t ParseAudioRegGroup(struct DeviceResourceIface *parser,
ret = ParseAudioAddrItem(parser, regCfgNode, group);
break;
case AUDIO_DAI_PATAM_GROUP:
case AUDIO_DAI_TRIGGER_GROUP:
case AUDIO_CTRL_PATAM_GROUP:
case AUDIO_CTRL_SAPM_PATAM_GROUP:
case AUDIO_DAI_STARTUP_PATAM_GROUP:

View File

@ -14,39 +14,56 @@
const int32_t g_testAudioType = 701; // 701 is TEST_AUDIO_TYPE
enum {
TESTGETCODEC,
TESTGETCARDINSTANCE,
TESTGETCCNFIGDATA,
TEST_AUDIOHOSTCREATEANDBIND = 1, // audio ADM audio_host
TEST_GETCARDINSTANCE = 2, // audio ADM audio_host
TESTREGISTERPLATFORM,
TESTREGISTERDAI,
TESTREGISTERACCESSORY,
TESTREGISTERCODEC,
TESTREGISTERDSP,
TESTSOCDEVICEREGISTER,
TESTBINDDAILINK,
TESTUPDATECODECREGBITS,
TESTUPDATEACCESSORYREGBITS,
TESTKCONTROLGETCODEC,
TESTKCONTROLGETACCESSORY,
TESTADDCONTROL,
TESTADDCONTROLS,
TESTCODECREADREG,
TESTACCESSORYREADREG,
TESTCODECWRITEREG,
TESTACCESSORYWRITEREG,
TESTINFOCTRLOPS,
TESTCODECGETCTRLOPS,
TESTACCESSORYGETCTRLOPS,
TESTCODECSETCTRLOPS,
TESTACCESSORYSETCTRLOPS,
TEST_AUDIOFILLCONFIGDATA = 3, // audio ADM audio_parse
TEST_CODECGETREGCONFIG = 4, // audio ADM audio_parse
TESTNEWCOMPONENT,
TESTADDROUTES,
TESTNEWCONTROLS,
TESTPOWERCOMPONET,
TESTREFRESHTIME,
TESTSTREAMDISPATCH,
TEST_AUDIODEVICEREADREG = 5, // audio ADM audio_core
TEST_AUDIODEVICEWRITEREG, // audio ADM audio_core
TEST_AUDIOSOCREGISTERPLATFORM, // audio ADM audio_core
TEST_AUDIOSOCREGISTERDAI, // audio ADM audio_core
TEST_AUDIOREGISTERDSP, // audio ADM audio_core
TEST_AUDIOREGISTERCODEC, // audio ADM audio_core
TEST_AUDIOREGISTERACCESSORY, // audio ADM audio_core
TEST_AUDIOBINDDAILINK, // audio ADM audio_core
TEST_AUDIOUPDATECODECREGBITS, // audio ADM audio_core
TEST_AUDIOUPDATEACCESSORYREGBITS, // audio ADM audio_core
TEST_AUDIOUPDATEDAIREGBITS, // audio ADM audio_core
TEST_AUDIOKCONTROLGETCPUDAI, // audio ADM audio_core
TEST_AUDIOKCONTROLGETCODEC, // audio ADM audio_core
TEST_AUDIOKCONTROLGETACCESSORY, // audio ADM audio_core
TEST_AUDIOADDCONTROLS, // audio ADM audio_core
TEST_AUDIOADDCONTROL, // audio ADM audio_core
TEST_AUDIOGETCTRLOPSRREG, // audio ADM audio_core
TEST_AUDIOGETCTRLOPSREG, // audio ADM audio_core
TEST_AUDIOSETCTRLOPSREG, // audio ADM audio_core
TEST_AUDIOSETCTRLOPSRREG, // audio ADM audio_core
TEST_AUDIODAIREADREG, // audio ADM audio_core
TEST_AUDIODAIWRITEREG, // audio ADM audio_core
TEST_AUDIOCODECREADREG, // audio ADM audio_core
TEST_AUDIOCODECWRITEREG, // audio ADM audio_core
TEST_AUDIOACCESSORYREADREG, // audio ADM audio_core
TEST_AUDIOACCESSORYWRITEREG, // audio ADM audio_core
TEST_AUDIOINFOCTRLOPS, // audio ADM audio_core
TEST_AUDIOCODECGETCTRLOPS, // audio ADM audio_core
TEST_AUDIOCODECSETCTRLOPS, // audio ADM audio_core
TEST_AUDIOACCESSORYGETCTRLOPS, // audio ADM audio_core
TEST_AUDIOACCESSORYSETCTRLOPS, // audio ADM audio_core
TEST_AUDIOCPUDAISETCTRLOPS, // audio ADM audio_core
TEST_AUDIOCPUDAIGETCTRLOPS = 37, // audio ADM audio_core
TEST_AUDIOSAPMNEWCOMPONENTS = 38, // audio ADM audio_sapm
TEST_AUDIOSAPMADDROUTES, // audio ADM audio_sapm
TEST_AUDIOSAPMNEWCONTROLS, // audio ADM audio_sapm
TEST_AUDIOSAPMSLEEP, // audio ADM audio_sapm
TEST_AUDIOSAMPPOWERUP, // audio ADM audio_sapm
TEST_AUDIOSAMPSETPOWERMONITOR, // audio ADM audio_sapm
TEST_AUDIOCODECSAPMSETCTRLOPS, // audio ADM audio_sapm
TEST_AUDIOCODECSAPMGETCTRLOPS, // audio ADM audio_sapm
TEST_AUDIOACCESSORYSAPMSETCTRLOPS, // audio ADM audio_sapm
TEST_AUDIOACCESSORYSAPMGETCTRLOPS = 47, // audio ADM audio_sapm
};
#endif /* AUDIO_COMMON_TEST_H */

View File

@ -38,135 +38,201 @@ void AudioCoreTest::TearDown()
{
}
HWTEST_F(AudioCoreTest, AudioCoreTest_RegisterPlatform, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioDeviceReadReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREGISTERPLATFORM, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIODEVICEREADREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_RegisterDai, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioDeviceWriteReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREGISTERDAI, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIODEVICEWRITEREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_RegisterAccessory, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioSocRegisterPlatform, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREGISTERACCESSORY, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSOCREGISTERPLATFORM, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_RegisterCodec, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioSocRegisterDai, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREGISTERCODEC, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSOCREGISTERDAI, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_SocRegisterDsp, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioRegisterDsp, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREGISTERDSP, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOREGISTERDSP, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_SocDeviceRegister, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioRegisterCodec, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTSOCDEVICEREGISTER, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOREGISTERCODEC, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_BindDaiLink, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioRegisterAccessory, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTBINDDAILINK, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOREGISTERACCESSORY, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_UpdateCodecRegBits, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioBindDaiLink, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTUPDATECODECREGBITS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOBINDDAILINK, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_UpdateAccessoryRegBits, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioUpdateCodecRegBits, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTUPDATEACCESSORYREGBITS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOUPDATECODECREGBITS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_KcontrolGetCodec, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioUpdateAccessoryRegBits, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTKCONTROLGETCODEC, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOUPDATEACCESSORYREGBITS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_KcontrolGetAccessory, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioUpdateDaiRegBits, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTKCONTROLGETACCESSORY, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOUPDATEDAIREGBITS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AddControl, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioKcontrolGetCpuDai, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTADDCONTROL, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOKCONTROLGETCPUDAI, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AddControls, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioKcontrolGetCodec, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTADDCONTROLS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOKCONTROLGETCODEC, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_CodecReadReg, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioKcontrolGetAccessory, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCODECREADREG, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOKCONTROLGETACCESSORY, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AccessoryReadReg, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioAddControls, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTACCESSORYREADREG, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOADDCONTROLS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_CodecWriteReg, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioAddControl, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCODECWRITEREG, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOADDCONTROL, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AccessoryWriteReg, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioGetCtrlOpsRReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTACCESSORYWRITEREG, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOGETCTRLOPSRREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_InfoCtrlOps, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioGetCtrlOpsReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTINFOCTRLOPS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOGETCTRLOPSREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_CodecGetCtrlOps, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioSetCtrlOpsReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCODECGETCTRLOPS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSETCTRLOPSREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AccessoryGetCtrlOps, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioSetCtrlOpsRReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTACCESSORYGETCTRLOPS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSETCTRLOPSRREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_CodecSetCtrlOps, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioDaiReadReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTCODECSETCTRLOPS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIODAIREADREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AccessorySetCtrlOps, TestSize.Level1)
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioDaiWriteReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTACCESSORYSETCTRLOPS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIODAIWRITEREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioCodecReadReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCODECREADREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioCodecWriteReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCODECWRITEREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioAccessoryReadReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOACCESSORYREADREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioAccessoryWriteReg, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOACCESSORYWRITEREG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioInfoCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOINFOCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioCodecGetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCODECGETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioCodecSetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCODECSETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioAccessoryGetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOACCESSORYGETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioAccessorySetCtrlOpsTset, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOACCESSORYSETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioCpuDaiSetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCPUDAISETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioCoreTest, AudioCoreTest_AudioCpuDaiGetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCPUDAIGETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -39,15 +39,15 @@ void AudioHostTest::TearDown()
{
}
HWTEST_F(AudioHostTest, AudioHostTest_GetCodec, TestSize.Level1)
HWTEST_F(AudioHostTest, AudioHostTest_AudioHostCreateAndBind, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTGETCODEC, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOHOSTCREATEANDBIND, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioHostTest, AudioHostTest_GetAudioServiceName, TestSize.Level1)
HWTEST_F(AudioHostTest, AudioHostTest_GetCardInstance, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTGETCARDINSTANCE, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_GETCARDINSTANCE, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -39,9 +39,15 @@ void AudioParseTest::TearDown()
{
}
HWTEST_F(AudioParseTest, AudioParseTest_GetConfigData, TestSize.Level1)
HWTEST_F(AudioParseTest, AudioParseTest_AudioFillConfigData, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTGETCCNFIGDATA, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOFILLCONFIGDATA, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioParseTest, AudioParseTest_CodecGetRegConfig, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_CODECGETREGCONFIG, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -17,9 +17,6 @@ extern "C" {
#endif
#endif /* __cplusplus */
#define AUDIODRV_CTRL_ELEM_TYPE_INTEGER 2 /* integer type */
enum ControlDispMethodCmd {
AUDIODRV_CTRL_IOCTRL_ELEM_INFO,
AUDIODRV_CTRL_IOCTRL_ELEM_READ,
@ -27,12 +24,9 @@ enum ControlDispMethodCmd {
AUDIODRV_CTRL_IOCTRL_ELEM_BUTT,
};
typedef int32_t (*ControlDispCmdHandle)(const struct HdfDeviceIoClient *client,
struct HdfSBuf *data, struct HdfSBuf *reply);
struct ControlDispCmdHandleList {
enum ControlDispMethodCmd cmd;
ControlDispCmdHandle func;
int32_t (*func)(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply);
};
struct ControlHost {
@ -41,11 +35,6 @@ struct ControlHost {
void *priv;
};
static inline struct ControlHost *ControlHostFromDevice(struct HdfDeviceObject *device)
{
return (device == NULL) ? NULL : (struct ControlHost *)device->service;
}
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -21,39 +21,37 @@ extern "C" {
#endif
#endif /* __cplusplus */
#define AUDIO_SERVICE_NAME_MAX_LEN 32
enum StreamDispMethodCmd {
AUDIO_DRV_PCM_IOCTRL_HW_PARAMS,
AUDIO_DRV_PCM_IOCTRL_RENDER_PREPARE,
AUDIO_DRV_PCM_IOCTRL_CAPTURE_PREPARE,
AUDIO_DRV_PCM_IOCTRL_WRITE,
AUDIO_DRV_PCM_IOCTRL_READ,
AUDIO_DRV_PCM_IOCTRL_RENDER_START,
AUDIO_DRV_PCM_IOCTRL_RENDER_STOP,
AUDIO_DRV_PCM_IOCTRL_CAPTURE_START,
AUDIO_DRV_PCM_IOCTRL_CAPTURE_STOP,
AUDIO_DRV_PCM_IOCTRL_RENDER_PAUSE,
AUDIO_DRV_PCM_IOCTRL_CAPTURE_PAUSE,
AUDIO_DRV_PCM_IOCTRL_RENDER_RESUME,
AUDIO_DRV_PCM_IOCTRL_CAPTURE_RESUME,
AUDIO_DRV_PCM_IOCTL_HW_PARAMS,
AUDIO_DRV_PCM_IOCTL_RENDER_PREPARE,
AUDIO_DRV_PCM_IOCTL_CAPTURE_PREPARE,
AUDIO_DRV_PCM_IOCTL_WRITE,
AUDIO_DRV_PCM_IOCTL_READ,
AUDIO_DRV_PCM_IOCTL_RENDER_START,
AUDIO_DRV_PCM_IOCTL_RENDER_STOP,
AUDIO_DRV_PCM_IOCTL_CAPTURE_START,
AUDIO_DRV_PCM_IOCTL_CAPTURE_STOP,
AUDIO_DRV_PCM_IOCTL_RENDER_PAUSE,
AUDIO_DRV_PCM_IOCTL_CAPTURE_PAUSE,
AUDIO_DRV_PCM_IOCTL_RENDER_RESUME,
AUDIO_DRV_PCM_IOCTL_CAPTURE_RESUME,
AUDIO_DRV_PCM_IOCTL_MMAP_BUFFER,
AUDIO_DRV_PCM_IOCTL_MMAP_BUFFER_CAPTURE,
AUDIO_DRV_PCM_IOCTL_MMAP_POSITION,
AUDIO_DRV_PCM_IOCTL_MMAP_POSITION_CAPTURE,
AUDIO_DRV_PCM_IOCTRL_RENDER_OPEN,
AUDIO_DRV_PCM_IOCTRL_RENDER_CLOSE,
AUDIO_DRV_PCM_IOCTRL_CAPTURE_OPEN,
AUDIO_DRV_PCM_IOCTRL_CAPTURE_CLOSE,
AUDIO_DRV_PCM_IOCTRL_BUTT,
AUDIO_DRV_PCM_IOCTL_RENDER_OPEN,
AUDIO_DRV_PCM_IOCTL_RENDER_CLOSE,
AUDIO_DRV_PCM_IOCTL_CAPTURE_OPEN,
AUDIO_DRV_PCM_IOCTL_CAPTURE_CLOSE,
AUDIO_DRV_PCM_IOCTL_DSPDECODE,
AUDIO_DRV_PCM_IOCTL_DSPENCODE,
AUDIO_DRV_PCM_IOCTL_DSPEQUALIZER,
AUDIO_DRV_PCM_IOCTL_BUTT,
};
typedef int32_t (*StreamDispCmdHandle)(const struct HdfDeviceIoClient *client,
struct HdfSBuf *data, struct HdfSBuf *reply);
struct StreamDispCmdHandleList {
enum StreamDispMethodCmd cmd;
StreamDispCmdHandle func;
int32_t (*func)(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply);
};
struct StreamHost {
@ -62,14 +60,6 @@ struct StreamHost {
void *priv;
};
static inline struct StreamHost *StreamHostFromDevice(struct HdfDeviceObject *device)
{
return (device == NULL) ? NULL : (struct StreamHost *)device->service;
}
int32_t StreamDispatch(struct HdfDeviceIoClient *client, int cmdId,
struct HdfSBuf *data, struct HdfSBuf *reply);
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -312,7 +312,7 @@ static void AudioControlRelease(struct HdfDeviceObject *device)
return;
}
controlHost = ControlHostFromDevice(device);
controlHost = (struct ControlHost *)device->service;
if (controlHost == NULL) {
ADM_LOG_ERR("controlHost is NULL.");
return;

File diff suppressed because it is too large Load Diff

View File

@ -17,23 +17,6 @@ extern "C" {
#endif
#endif /* __cplusplus */
#define SAPM_POLL_TIME 10000 /* 10s */
#define SAPM_SLEEP_TIME (3 * 60000) /* 3min */
#define MIXER_REG_ADDR 10 /* mixer address -- Temporarily defined as this value */
#define SAPM_POWER_DOWN 0
#define SAPM_POWER_UP 1
#define CONNECT_CODEC_PIN 1
#define UNCONNECT_CODEC_PIN 0
#define EXIST_EXTERNAL_WIDGET 1
#define UNEXIST_EXTERNAL_WIDGET 1
#define CONNECT_SINK_AND_SOURCE 1
#define UNCONNECT_SINK_AND_SOURCE 0
/* sapm widget types */
enum AudioSapmType {
AUDIO_SAPM_INPUT = 0, /* input pin */
@ -66,27 +49,6 @@ enum AudioSapmType {
AUDIO_SAPM_SINK,
};
/* component has no PM register bit */
#define AUDIO_SAPM_NOPM (-1)
/* dapm stream operations */
#define AUDIO_SAPM_STREAM_NOP 0x0
#define AUDIO_SAPM_STREAM_START 0x1
#define AUDIO_SAPM_STREAM_STOP 0x2
#define AUDIO_SAPM_STREAM_SUSPEND 0x4
#define AUDIO_SAPM_STREAM_RESUME 0x8
#define AUDIO_SAPM_STREAM_PAUSE_PUSH 0x10
#define AUDIO_SAPM_STREAM_PAUSE_RELEASE 0x20
/* sapm event types */
#define AUDIO_SAPM_PRE_PMU 0x1 /* before component power up */
#define AUDIO_SAPM_POST_PMU 0x2 /* after component power up */
#define AUDIO_SAPM_PRE_PMD 0x4 /* before component power down */
#define AUDIO_SAPM_POST_PMD 0x8 /* after component power down */
#define AUDIO_SAPM_PRE_REG 0x10 /* before audio path setup */
#define AUDIO_SAPM_POST_REG 0x20 /* after audio path setup */
#define AUDIO_SAPM_PRE_POST_PMD (AUDIO_SAPM_PRE_PMD | AUDIO_SAPM_POST_PMD)
enum AudioBiasLevel {
AUDIO_BIAS_OFF = 0,
AUDIO_BIAS_STANDBY = 1,
@ -206,9 +168,7 @@ int32_t AudioSapmNewComponents(struct AudioCard *audioCard,
int32_t AudioSapmAddRoutes(struct AudioCard *audioCard,
const struct AudioSapmRoute *route, int32_t routeMaxNum);
int32_t AudioSapmNewControls(struct AudioCard *audioCard);
int AudioSapmPowerComponents(struct AudioCard *audioCard);
int32_t AudioSapmSleep(const struct AudioCard *audioCard);
uint64_t AudioSapmRefreshTime(bool bRefresh);
int32_t AudioSampPowerUp(const struct AudioCard *card);
int32_t AudioSampSetPowerMonitor(struct AudioCard *card, bool powerMonitorState);

View File

@ -14,7 +14,23 @@
#define HDF_LOG_TAG audio_sapm
#define SAPM_POLL_TIME 10000 /* 10s */
#define SAPM_SLEEP_TIME (3 * 60000) /* 3min */
#define SAPM_POWER_DOWN 0
#define SAPM_POWER_UP 1
#define CONNECT_CODEC_PIN 1
#define UNCONNECT_CODEC_PIN 0
#define EXIST_EXTERNAL_WIDGET 1
#define UNEXIST_EXTERNAL_WIDGET 1
#define CONNECT_SINK_AND_SOURCE 1
#define UNCONNECT_SINK_AND_SOURCE 0
static void AudioSapmEnterSleep(uintptr_t para);
static uint64_t AudioSapmRefreshTime(bool bRefresh);
/* power up sequences */
static int32_t g_audioSapmPowerUpSeq[] = {
@ -940,7 +956,7 @@ static void AudioSapmPowerDownSeqRun(const struct DListHead *list)
return;
}
int AudioSapmPowerComponents(struct AudioCard *audioCard)
static int AudioSapmPowerComponents(struct AudioCard *audioCard)
{
struct AudioSapmComponent *sapmComponent = NULL;
struct DListHead upList;
@ -1254,13 +1270,14 @@ int32_t AudioAccessorySapmSetCtrlOps(const struct AudioKcontrol *kcontrol, const
return HDF_SUCCESS;
}
uint64_t AudioSapmRefreshTime(bool bRefresh)
static uint64_t AudioSapmRefreshTime(bool bRefresh)
{
static uint64_t time = 0;
if (bRefresh) {
time = OsalGetSysTimeMs();
g_audioSapmIsSleep = false;
g_audioSapmIsStandby = false;
}
return time;
}

View File

@ -38,33 +38,64 @@ void AudioSapmTest::TearDown()
{
}
HWTEST_F(AudioSapmTest, AudioSapmTest001, TestSize.Level1)
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioSapmNewComponents, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTNEWCOMPONENT, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSAPMNEWCOMPONENTS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest002, TestSize.Level1)
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioSapmAddRoutes, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTADDROUTES, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSAPMADDROUTES, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest003, TestSize.Level1)
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioSapmNewControls, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTNEWCONTROLS, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSAPMNEWCONTROLS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest004, TestSize.Level1)
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioSapmSleep, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTPOWERCOMPONET, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSAPMSLEEP, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest005, TestSize.Level1)
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioSampPowerUp, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TESTREFRESHTIME, -1};
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSAMPPOWERUP, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioSampSetPowerMonitor, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOSAMPSETPOWERMONITOR, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioCodecSapmSetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCODECSAPMSETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioCodecSapmGetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOCODECSAPMGETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioAccessorySapmSetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOACCESSORYSAPMSETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
HWTEST_F(AudioSapmTest, AudioSapmTest_AudioAccessorySapmGetCtrlOps, TestSize.Level1)
{
struct HdfTestMsg msg = {g_testAudioType, TEST_AUDIOACCESSORYSAPMGETCTRLOPS, -1};
EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
}
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_ACCESSORY_BASE_TEST_H
#define AUDIO_ACCESSORY_BASE_TEST_H
#include "hdf_types.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
int32_t AccessoryI2cReadWriteTest(void);
int32_t AccessoryRegBitsReadTest(void);
int32_t AccessoryRegBitsUpdateTest(void);
int32_t AcessoryDeviceFrequencyParseTest(void);
int32_t AccessoryDaiParamsUpdateTest(void);
int32_t AccessoryDeviceCfgGetTest(void);
int32_t AccessoryDeviceCtrlRegInitTest(void);
int32_t AccessoryDeviceRegReadTest(void);
int32_t AccessoryDeviceRegWriteTest(void);
int32_t AccessoryGetConfigInfoTest(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* AUDIO_ACCESSORY_BASE_TEST_H */

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_CODEC_BASE_TEST_H
#define AUDIO_CODEC_BASE_TEST_H
#include "hdf_types.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
int32_t CodecGetServiceNameTest(void);
int32_t CodecGetDaiNameTest(void);
int32_t CodecGetConfigInfoTest(void);
int32_t CodecSetConfigInfoTest(void);
int32_t CodecSetCtlFuncTest(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* AUDIO_CODEC_BASE_TEST_H */

View File

@ -17,28 +17,39 @@ extern "C" {
#endif
#endif /* __cplusplus */
int32_t AudioSocTestRegisterPlatform(void);
int32_t AudioSocTestRegisterDai(void);
int32_t AudioTestRegisterAccessory(void);
int32_t AudioTestRegisterCodec(void);
int32_t AudioTestRegisterDsp(void);
int32_t AudioTestSocDeviceRegister(void);
int32_t AudioTestBindDaiLink(void);
int32_t AudioTestUpdateCodecRegBits(void);
int32_t AudioTestUpdateAccessoryRegBits(void);
int32_t AudioTestKcontrolGetCodec(void);
int32_t AudioTestKcontrolGetAccessory(void);
int32_t AudioTestAddControl(void);
int32_t AudioTestAddControls(void);
int32_t AudioTestCodecReadReg(void);
int32_t AudioTestAccessoryReadReg(void);
int32_t AudioTestCodecWriteReg(void);
int32_t AudioTestAccessoryWriteReg(void);
int32_t AudioTestInfoCtrlOps(void);
int32_t AudioTestCodecGetCtrlOps(void);
int32_t AudioTestAccessoryGetCtrlOps(void);
int32_t AudioTestCodecSetCtrlOps(void);
int32_t AudioTestAccessorySetCtrlOps(void);
int32_t AudioDeviceReadRegTest(void);
int32_t AudioDeviceWriteRegTest(void);
int32_t AudioSocRegisterPlatformTest(void);
int32_t AudioSocRegisterDaiTest(void);
int32_t AudioRegisterDspTest(void);
int32_t AudioRegisterCodecTest(void);
int32_t AudioRegisterAccessoryTest(void);
int32_t AudioBindDaiLinkTest(void);
int32_t AudioUpdateCodecRegBitsTest(void);
int32_t AudioUpdateAccessoryRegBitsTest(void);
int32_t AudioUpdateDaiRegBitsTest(void);
int32_t AudioKcontrolGetCpuDaiTest(void);
int32_t AudioKcontrolGetCodecTest(void);
int32_t AudioKcontrolGetAccessoryTest(void);
int32_t AudioAddControlsTest(void);
int32_t AudioAddControlTest(void);
int32_t AudioGetCtrlOpsRRegTest(void);
int32_t AudioGetCtrlOpsRegTest(void);
int32_t AudioSetCtrlOpsRegTest(void);
int32_t AudioSetCtrlOpsRRegTest(void);
int32_t AudioDaiReadRegTest(void);
int32_t AudioDaiWriteRegTest(void);
int32_t AudioCodecReadRegTest(void);
int32_t AudioCodecWriteRegTest(void);
int32_t AudioAccessoryReadRegTest(void);
int32_t AudioAccessoryWriteRegTest(void);
int32_t AudioInfoCtrlOpsTest(void);
int32_t AudioCodecGetCtrlOpsTest(void);
int32_t AudioCodecSetCtrlOpsTest(void);
int32_t AudioAccessoryGetCtrlOpsTest(void);
int32_t AudioAccessorySetCtrlOpsTset(void);
int32_t AudioCpuDaiSetCtrlOpsTest(void);
int32_t AudioCpuDaiGetCtrlOpsTest(void);
#ifdef __cplusplus
#if __cplusplus

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_DAI_BASE_TEST_H
#define AUDIO_DAI_BASE_TEST_H
#include "hdf_types.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
int32_t DaiDataFromCardTest(void);
int32_t DaiGetConfigInfoTest(void);
int32_t DaiCheckSampleRateTest(void);
int32_t DaiSetConfigInfoTest(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* AUDIO_DAI_BASE_TEST_H */

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_DMA_BASE_TEST_H
#define AUDIO_DMA_BASE_TEST_H
#include "hdf_types.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
int32_t AudioDmaBufAllocTest(void);
int32_t AudioDmaBufFreeTest(void);
int32_t AudioDmaRequestChannelTest(void);
int32_t AudioDmaConfigChannelTest(void);
int32_t AudioDmaPrepTest(void);
int32_t AudioDmaSubmitTest(void);
int32_t AudioDmaPendingTest(void);
int32_t AudioDmaPauseTest(void);
int32_t AudioDmaResumeTest(void);
int32_t AudioDmaPointerTest(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* AUDIO_DMA_BASE_TEST_H */

View File

@ -6,24 +6,24 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_STREAM_DISPATCH_TEST_H
#define AUDIO_STREAM_DISPATCH_TEST_H
#ifndef AUDIO_DSP_BASE_TEST_H
#define AUDIO_DSP_BASE_TEST_H
#include "hdf_types.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"
{
extern "C" {
#endif
#endif
int32_t AudioControlDispatchTestStreamDispatch(void);
int32_t AudioControlDispatchTestStreamHostDestroy(void);
#endif /* __cplusplus */
int32_t DspGetServiceNameTest(void);
int32_t DspGetDaiNameTest(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif /* __cplusplus */
#endif
#endif /* AUDIO_DSP_BASE_TEST_H */

View File

@ -17,8 +17,8 @@ extern "C" {
#endif
#endif /* __cplusplus */
int32_t AudioKcontrolTestGetCodec(void);
int32_t GetCardTestInstance(void);
int32_t AudioHostCreateAndBindTest(void);
int32_t GetCardInstanceTest(void);
#ifdef __cplusplus
#if __cplusplus

View File

@ -17,7 +17,8 @@ extern "C" {
#endif
#endif /* __cplusplus */
int32_t AudioFillTestConfigData(void);
int32_t AudioFillConfigDataTest(void);
int32_t CodecGetRegConfigTest(void);
#ifdef __cplusplus
#if __cplusplus

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#ifndef AUDIO_PLATFORM_BASE_TEST_H
#define AUDIO_PLATFORM_BASE_TEST_H
#include "hdf_types.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
int32_t PlatformDataFromCardTest(void);
int32_t AudioBytesToFramesTest(void);
int32_t AudioDataBigEndianChangeTest(void);
int32_t AudioFramatToBitWidthTest(void);
int32_t AudioSetPcmInfoTest(void);
int32_t AudioSetRenderBufInfoTest(void);
int32_t AudioSetCaptureBufInfoTest(void);
int32_t AudioPcmWriteTest(void);
int32_t AudioPcmReadTest(void);
int32_t AudioPcmMmapWriteTest(void);
int32_t AudioPcmMmapReadTest(void);
int32_t AudioRenderOpenTest(void);
int32_t AudioCaptureOpenTest(void);
int32_t AudioRenderCloseTest(void);
int32_t AudioPcmPointerTest(void);
int32_t AudioCaptureCloseTest(void);
int32_t AudioHwParamsTest(void);
int32_t AudioRenderPrepareTest(void);
int32_t AudioCapturePrepareTest(void);
int32_t AudioRenderTriggerTest(void);
int32_t AudioCaptureTriggerTest(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* AUDIO_PLATFORM_BASE_TEST_H */

View File

@ -17,11 +17,17 @@ extern "C"
{
#endif
#endif
int32_t AudioSapmTestNewComponents(void);
int32_t AudioSapmTestAddRoutes(void);
int32_t AudioSapmTestNewControls(void);
int32_t AudioSapmTestPowerComponents(void);
int32_t AudioSapmTestRefreshTime(void);
int32_t AudioSapmNewComponentsTest(void);
int32_t AudioSapmAddRoutesTest(void);
int32_t AudioSapmNewControlsTest(void);
int32_t AudioSapmSleepTest(void);
int32_t AudioSampPowerUpTest(void);
int32_t AudioSampSetPowerMonitorTest(void);
int32_t AudioCodecSapmSetCtrlOpsTest(void);
int32_t AudioCodecSapmGetCtrlOpsTest(void);
int32_t AudioAccessorySapmSetCtrlOpsTest(void);
int32_t AudioAccessorySapmGetCtrlOpsTest(void);
#ifdef __cplusplus
#if __cplusplus

View File

@ -18,47 +18,114 @@ extern "C" {
#endif /* __cplusplus */
typedef enum {
AUDIO_DRIVER_TESTGETCODEC,
AUDIO_DRIVER_TESTGETCARDINSTANCE,
AUDIO_DRIVER_TESTGETCCNFIGDATA,
AUDIO_DRIVER_TESTREGISTERPLATFORM,
AUDIO_DRIVER_TESTREGISTERDAI,
AUDIO_DRIVER_TESTREGISTERACCESSORY,
AUDIO_DRIVER_TESTREGISTERCODEC,
AUDIO_DRIVER_TESTREGISTERDSP,
AUDIO_DRIVER_TESTSOCDEVICEREGISTER,
AUDIO_DRIVER_TESTBINDDAILINK,
AUDIO_DRIVER_TESTUPDATECODECREGBITS,
AUDIO_DRIVER_TESTUPDATEACCESSORYREGBITS,
AUDIO_DRIVER_TESTUPDATECODECAIAOREGBITS,
AUDIO_DRIVER_TESTUPDATEACCESSORYAIAOREGBITS,
AUDIO_DRIVER_TESTKCONTROLGETCODEC,
AUDIO_DRIVER_TESTKCONTROLGETACCESSORY,
AUDIO_DRIVER_TESTADDCONTROL,
AUDIO_DRIVER_TESTADDCONTROLS,
AUDIO_DRIVER_TESTCODECREADREG,
AUDIO_DRIVER_TESTACCESSORYREADREG,
AUDIO_DRIVER_TESTCODECAIAOREADREG,
AUDIO_DRIVER_TESTACCESSORYAIAOREADREG,
AUDIO_DRIVER_TESTCODECWRITEREG,
AUDIO_DRIVER_TESTACCESSORYWRITEREG,
AUDIO_DRIVER_TESTCODECAIAOWRITEREG,
AUDIO_DRIVER_TESTACCESSORYAIAOWRITEREG,
AUDIO_DRIVER_TESTINFOCTRLOPS,
AUDIO_DRIVER_TESTCODECGETCTRLOPS,
AUDIO_DRIVER_TESTACCESSORYGETCTRLOPS,
AUDIO_DRIVER_TESTCODECAIAOGETCTRLOPS,
AUDIO_DRIVER_TESTACCESSORYAIAOGETCTRLOPS,
AUDIO_DRIVER_TESTCODECSETCTRLOPS,
AUDIO_DRIVER_TESTACCESSORYSETCTRLOPS,
AUDIO_DRIVER_TESTCODECAIAOSETCTRLOPS,
AUDIO_DRIVER_TESTACCESSORYAIAOSETCTRLOPS,
AUDIO_DRIVER_TESTNEWCOMPONENT,
AUDIO_DRIVER_TESTADDROUTES,
AUDIO_DRIVER_TESTNEWCONTROLS,
AUDIO_DRIVER_TESTPOWERCOMPONET,
AUDIO_DRIVER_TESTREFRESHTIME,
AUDIO_DRIVER_TESTSTREAMDISPATCH,
AUDIO_ADM_TEST_AUDIOHOSTCREATEANDBIND = 1, // audio ADM audio_host
AUDIO_ADM_TEST_GETCARDINSTANCE = 2, // audio ADM audio_host
AUDIO_ADM_TEST_AUDIOFILLCONFIGDATA = 3, // audio ADM audio_parse
AUDIO_ADM_TEST_CODECGETREGCONFIG = 4, // audio ADM audio_parse
AUDIO_ADM_TEST_AUDIODEVICEREADREG = 5, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIODEVICEWRITEREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOSOCREGISTERPLATFORM, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOSOCREGISTERDAI, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOREGISTERDSP, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOREGISTERCODEC, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOREGISTERACCESSORY, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOBINDDAILINK, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOUPDATECODECREGBITS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOUPDATEACCESSORYREGBITS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOUPDATEDAIREGBITS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOKCONTROLGETCPUDAI, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOKCONTROLGETCODEC, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOKCONTROLGETACCESSORY, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOADDCONTROLS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOADDCONTROL, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOGETCTRLOPSRREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOGETCTRLOPSREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOSETCTRLOPSREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOSETCTRLOPSRREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIODAIREADREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIODAIWRITEREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOCODECREADREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOCODECWRITEREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOACCESSORYREADREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOACCESSORYWRITEREG, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOINFOCTRLOPS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOCODECGETCTRLOPS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOCODECSETCTRLOPS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOACCESSORYGETCTRLOPS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOACCESSORYSETCTRLOPS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOCPUDAISETCTRLOPS, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOCPUDAIGETCTRLOPS = 37, // audio ADM audio_core
AUDIO_ADM_TEST_AUDIOSAPMNEWCOMPONENTS = 38, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOSAPMADDROUTES, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOSAPMNEWCONTROLS, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOSAPMSLEEP, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOSAMPPOWERUP, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOSAMPSETPOWERMONITOR, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOCODECSAPMSETCTRLOPS, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOCODECSAPMGETCTRLOPS, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOACCESSORYSAPMSETCTRLOPS, // audio ADM audio_sapm
AUDIO_ADM_TEST_AUDIOACCESSORYSAPMGETCTRLOPS = 47, // audio ADM audio_sapm
AUDIO_ADM_TEST_I2CREADWRITE, // audio ADM audio_accessory_base
AUDIO_ADM_TEST_REGBITSREAD,
AUDIO_ADM_TEST_REGBITSUPDATE,
AUDIO_ADM_TEST_DEVICEFREQUENCYPARSE,
AUDIO_ADM_TEST_DAIPARAMSUPDATE,
AUDIO_ADM_TEST_DEVICECFGGET,
AUDIO_ADM_TEST_DEVICECTRLREGINIT,
AUDIO_ADM_TEST_DEVICEREGREAD,
AUDIO_ADM_TEST_DEVICEREGWRITE,
AUDIO_ADM_TEST_AGETCONFIGINFO,
AUDIO_ADM_TEST_GETSERVICENAME, // audio ADM audio_codec_base
AUDIO_ADM_TEST_GETDAINAME,
AUDIO_ADM_TEST_GETCONFIGINFO,
AUDIO_ADM_TEST_SETCONFIGINFO,
AUDIO_ADM_TEST_SETCTLFUNC,
AUDIO_ADM_TEST_DAIDATAFROMCARD, // audio ADM audio_dai_base
AUDIO_ADM_TEST_DAIGETCONFIGINFO,
AUDIO_ADM_TEST_DAICHECKSAMPLERATE,
AUDIO_ADM_TEST_DAISETCONFIGINFO,
AUDIO_ADM_TEST_DMABUFALLOC, // audio ADM audio_dma_base
AUDIO_ADM_TEST_DMABUFFREE,
AUDIO_ADM_TEST_DMAREQUESTCHANNEL,
AUDIO_ADM_TEST_DMACONFIGCHANNEL,
AUDIO_ADM_TEST_DMAPREP,
AUDIO_ADM_TEST_DMASUBMIT,
AUDIO_ADM_TEST_DMAPENDING,
AUDIO_ADM_TEST_DMAPAUSE,
AUDIO_ADM_TEST_DMARESUME,
AUDIO_ADM_TEST_DMAPOINTER,
AUDIO_ADM_TEST_DSPGETSERVICENAME, // audio ADM audio_dsp_base
AUDIO_ADM_TEST_DSPGETDAINAME,
AUDIO_ADM_TEST_DATAFROMCARD, // audio ADM audio_platform_base
AUDIO_ADM_TEST_BYTESTOFRAMES,
AUDIO_ADM_TEST_DATABIGENDIANCHANGE,
AUDIO_ADM_TEST_FRAMATTOBITWIDTH,
AUDIO_ADM_TEST_SETPCMINFO,
AUDIO_ADM_TEST_SETRENDERBUFINFO,
AUDIO_ADM_TEST_SETCAPTUREBUFINFO,
AUDIO_ADM_TEST_PCMWRITE,
AUDIO_ADM_TEST_PCMREAD,
AUDIO_ADM_TEST_PCMMMAPWRITE,
AUDIO_ADM_TEST_PCMMMAPREAD,
AUDIO_ADM_TEST_RENDEROPEN,
AUDIO_ADM_TEST_CAPTUREOPEN,
AUDIO_ADM_TEST_RENDERCLOSE,
AUDIO_ADM_TEST_PCMPOINTER,
AUDIO_ADM_TEST_CAPTURECLOSE,
AUDIO_ADM_TEST_HWPARAMS,
AUDIO_ADM_TEST_RENDERPREPARE,
AUDIO_ADM_TEST_CAPTUREPREPARE,
AUDIO_ADM_TEST_RENDERTRIGGER,
AUDIO_ADM_TEST_CAPTURETRIGGER,
} HdfAudioTestCaseCmd;
int32_t HdfAudioEntry(HdfTestMsg *msg);

View File

@ -0,0 +1,161 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_accessory_base_test.h"
#include "audio_accessory_base.h"
#include "audio_driver_log.h"
#define HDF_LOG_TAG audio_accessory_base_test
static struct AudioMixerControl g_TestReg = {
.min = 0,
.max = 0,
.platformMax = 0,
.mask = 0,
.reg = 0,
.rreg = 0,
.shift= 0,
.rshift = 0,
.invert = 0,
.value = 0,
};
int32_t AccessoryI2cReadWriteTest(void)
{
struct AudioAddrConfig addrConfig;
if (AccessoryI2cReadWrite(NULL, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AccessoryI2cReadWrite(&addrConfig, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryRegBitsReadTest(void)
{
uint32_t regValue = 0;
if (AccessoryRegBitsRead(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AccessoryRegBitsRead(&g_TestReg, &regValue) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryRegBitsUpdateTest(void)
{
if (AccessoryRegBitsUpdate(g_TestReg) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AcessoryDeviceFrequencyParseTest(void)
{
uint16_t freq = 0;
if (AcessoryDeviceFrequencyParse(0, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AcessoryDeviceFrequencyParse(0, &freq) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryDaiParamsUpdateTest(void)
{
struct DaiParamsVal value;
value.channelVal = 1; // 1 is dma channel
if (AccessoryDaiParamsUpdate(value) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryDeviceCfgGetTest(void)
{
struct AccessoryData accessoryData;
struct AccessoryTransferData accessoryTransferData;
if (AccessoryDeviceCfgGet(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
memset(&accessoryData, 0, sizeof(struct AccessoryData));
memset(&accessoryTransferData, 0, sizeof(struct AccessoryTransferData));
if (AccessoryDeviceCfgGet(&accessoryData, &accessoryTransferData) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryDeviceCtrlRegInitTest(void)
{
if (AccessoryDeviceCtrlRegInit() == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryDeviceRegReadTest(void)
{
uint32_t val;
struct AccessoryDevice codec;
if (AccessoryDeviceRegRead(NULL, 0, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AccessoryDeviceRegRead(&codec, 0, &val) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryDeviceRegWriteTest(void)
{
struct AccessoryDevice codec;
if (AccessoryDeviceRegWrite(NULL, 0, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AccessoryDeviceRegWrite(&codec, 0, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AccessoryGetConfigInfoTest(void)
{
struct HdfDeviceObject device;
struct AccessoryData codecData;
if (AccessoryGetConfigInfo(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AccessoryGetConfigInfo(&device, &codecData) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -0,0 +1,94 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_codec_base_test.h"
#include "audio_codec_base.h"
#include "audio_driver_log.h"
#define HDF_LOG_TAG audio_codec_base_test
int32_t CodecGetServiceNameTest(void)
{
struct HdfDeviceObject device;
const char *drvCodecName = "";
if (CodecGetServiceName(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (CodecGetServiceName(&device, &drvCodecName) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t CodecGetDaiNameTest(void)
{
struct HdfDeviceObject device;
const char *drvCodecName = "";
if (CodecGetDaiName(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (CodecGetDaiName(&device, &drvCodecName) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t CodecGetConfigInfoTest(void)
{
struct HdfDeviceObject device;
struct CodecData codecData;
if (CodecGetConfigInfo(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (CodecGetConfigInfo(&device, &codecData) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t CodecSetConfigInfoTest(void)
{
struct DaiData device;
struct CodecData codecData;
memset(&device, 0, sizeof(struct DaiData));
memset(&codecData, 0, sizeof(struct CodecData));
if (CodecSetConfigInfo(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (CodecSetConfigInfo(&codecData, &device) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t CodecSetCtlFuncTest(void)
{
struct CodecData codeData;
if (CodecSetCtlFunc(NULL, NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (CodecSetCtlFunc(&codeData, NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -12,13 +12,8 @@
#include "devsvc_manager_clnt.h"
#define HDF_LOG_TAG audio_core_test
#define AUDIO_CORE_SERVICE_TEST_NAME "hdf_audio_codec_dev0"
#define PLATFORM_TEST_NAME "codec_service_1"
#define PLATFORM_CODEC_TEST_NAME "codec_service_0"
#define ACCESSORY_DAI_TEST_NAME "accessory_dai"
#define DSP_TEST_NAME "dsp_service_0"
const struct AudioMixerControl g_audioMixerRegParams = {
static struct AudioMixerControl g_audioTestReg = {
.reg = 0x2004, /* [0] output volume */
.rreg = 0x2004, /* register value */
.shift = 8, /* offset */
@ -29,8 +24,35 @@ const struct AudioMixerControl g_audioMixerRegParams = {
.invert = 0, /* invert */
};
int32_t AudioSocTestRegisterPlatform(void)
static int32_t AudioDeviceReadRegMock(unsigned long virtualAddress, uint32_t reg, uint32_t *value)
{
return HDF_SUCCESS;
}
static int32_t AudioDeviceWriteRegMock(unsigned long virtualAddress, uint32_t reg, uint32_t value)
{
return HDF_SUCCESS;
}
int32_t AudioDeviceReadRegTest(void)
{
int value;
HDF_LOGI("%s: enter", __func__);
return AudioDeviceReadRegMock(0 ,0, &value);
HDF_LOGI("%s: success", __func__);
}
int32_t AudioDeviceWriteRegTest(void)
{
HDF_LOGI("%s: enter", __func__);
return AudioDeviceWriteRegMock(0 ,0, 0);;
HDF_LOGI("%s: success", __func__);
}
int32_t AudioSocRegisterPlatformTest(void)
{
struct HdfDeviceObject *device = NULL;
struct PlatformData platformData;
HDF_LOGI("%s: enter", __func__);
if (AudioSocRegisterPlatform(NULL, NULL) == HDF_SUCCESS) {
@ -38,20 +60,20 @@ int32_t AudioSocTestRegisterPlatform(void)
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(AUDIO_CORE_SERVICE_TEST_NAME);
struct PlatformData data = {
.drvPlatformName = PLATFORM_TEST_NAME,
};
if (AudioSocRegisterPlatform(device, &data) != HDF_SUCCESS) {
device = DevSvcManagerClntGetDeviceObject("hdf_audio_codec_dev0");
(void)memset_s(&platformData, sizeof(struct PlatformData), 0, sizeof(struct PlatformData));
platformData.drvPlatformName = "dma_service_0";
if (AudioSocRegisterPlatform(device, &platformData) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioSocRegisterPlatform fail", __func__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioSocTestRegisterDai(void)
int32_t AudioSocRegisterDaiTest(void)
{
struct HdfDeviceObject *device = NULL;
struct DaiData data;
HDF_LOGI("%s: enter", __func__);
if (AudioSocRegisterDai(NULL, NULL) == HDF_SUCCESS) {
@ -59,10 +81,9 @@ int32_t AudioSocTestRegisterDai(void)
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(AUDIO_CORE_SERVICE_TEST_NAME);
struct DaiData data = {
.drvDaiName = ACCESSORY_DAI_TEST_NAME,
};
device = DevSvcManagerClntGetDeviceObject("hdf_audio_codec_dev0");
(void)memset_s(&data, sizeof(struct DaiData), 0, sizeof(struct DaiData));
data.drvDaiName = "dai_service";
if (AudioSocRegisterDai(device, &data) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioSocRegisterDai fail", __func__, __LINE__);
return HDF_FAILURE;
@ -72,58 +93,11 @@ int32_t AudioSocTestRegisterDai(void)
return HDF_SUCCESS;
}
int32_t AudioTestRegisterAccessory(void)
{
HDF_LOGI("%s: enter", __func__);
if (AudioRegisterAccessory(NULL, NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterAccessory fail", __func__, __LINE__);
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(AUDIO_CORE_SERVICE_TEST_NAME);
struct AccessoryData data = {
.drvAccessoryName = ACCESSORY_DAI_TEST_NAME,
};
struct DaiData daiData = {
.drvDaiName = ACCESSORY_DAI_TEST_NAME,
};
if (AudioRegisterAccessory(device, &data, &daiData) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterAccessory fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestRegisterCodec(void)
{
HDF_LOGI("%s: enter", __func__);
if (AudioRegisterCodec(NULL, NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterCodec fail", __func__, __LINE__);
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(AUDIO_CORE_SERVICE_TEST_NAME);
struct CodecData codecData = {
.drvCodecName = ACCESSORY_DAI_TEST_NAME,
};
struct DaiData daiData = {
.drvDaiName = ACCESSORY_DAI_TEST_NAME,
};
if (AudioRegisterCodec(device, &codecData, &daiData) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterCodec fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestRegisterDsp(void)
int32_t AudioRegisterDspTest(void)
{
struct HdfDeviceObject *device = NULL;
struct DaiData daiData;
struct DspData dspData;
HDF_LOGI("%s: enter", __func__);
if (AudioRegisterDsp(NULL, NULL, NULL) == HDF_SUCCESS) {
@ -131,14 +105,11 @@ int32_t AudioTestRegisterDsp(void)
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(AUDIO_CORE_SERVICE_TEST_NAME);
struct DaiData daiData = {
.drvDaiName = ACCESSORY_DAI_TEST_NAME,
};
struct DspData dspData = {
.drvDspName = DSP_TEST_NAME,
};
device = DevSvcManagerClntGetDeviceObject("hdf_audio_codec_dev0");
(void)memset_s(&daiData, sizeof(struct DspData), 0, sizeof(struct DspData));
(void)memset_s(&daiData, sizeof(struct DaiData), 0, sizeof(struct DaiData));
dspData.drvDspName = "dsp_service_0",
daiData.drvDaiName = "dai_service";
if (AudioRegisterDsp(device, &dspData, &daiData) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioSocRegisterDsp fail", __func__, __LINE__);
return HDF_FAILURE;
@ -148,38 +119,59 @@ int32_t AudioTestRegisterDsp(void)
return HDF_SUCCESS;
}
int32_t AudioTestSocDeviceRegister(void)
int32_t AudioRegisterCodecTest(void)
{
struct {
char *name;
} data;
enum AudioDeviceType deviceType = AUDIO_DAI_DEVICE;
struct HdfDeviceObject *device = NULL;
struct DaiData daiData;
struct CodecData codecData;
HDF_LOGI("%s: enter", __func__);
if (AudioSocDeviceRegister(NULL, NULL, deviceType) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioSocDeviceRegister fail", __func__, __LINE__);
if (AudioRegisterCodec(NULL, NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterCodec fail", __func__, __LINE__);
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(AUDIO_CORE_SERVICE_TEST_NAME);
data.name = ACCESSORY_DAI_TEST_NAME;
if (AudioSocDeviceRegister(device, &data, deviceType) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioSocDeviceRegister fail", __func__, __LINE__);
device = DevSvcManagerClntGetDeviceObject("hdf_audio_codec_dev0");
(void)memset_s(&codecData, sizeof(struct CodecData), 0, sizeof(struct CodecData));
(void)memset_s(&daiData, sizeof(struct DaiData), 0, sizeof(struct DaiData));
codecData.drvCodecName = "codec_dai";
daiData.drvDaiName = "dai_service";
if (AudioRegisterCodec(device, &codecData, &daiData) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterCodec fail", __func__, __LINE__);
return HDF_FAILURE;
}
deviceType = AUDIO_PLATFORM_DEVICE;
data.name = PLATFORM_TEST_NAME;
if (AudioSocDeviceRegister(device, &data, deviceType) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioSocDeviceRegister fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestBindDaiLink(void)
int32_t AudioRegisterAccessoryTest(void)
{
struct HdfDeviceObject *device = NULL;
struct DaiData daiData;
struct AccessoryData accessoryData;
HDF_LOGI("%s: enter", __func__);
if (AudioRegisterAccessory(NULL, NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterAccessory fail", __func__, __LINE__);
return HDF_FAILURE;
}
device = DevSvcManagerClntGetDeviceObject("hdf_audio_codec_dev0");
(void)memset_s(&accessoryData, sizeof(struct AccessoryData), 0, sizeof(struct AccessoryData));
(void)memset_s(&daiData, sizeof(struct DaiData), 0, sizeof(struct DaiData));
accessoryData.drvAccessoryName = "accessory_dai";
daiData.drvDaiName = "dai_service";
if (AudioRegisterAccessory(device, &accessoryData, &daiData) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioRegisterAccessory fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioBindDaiLinkTest(void)
{
HDF_LOGI("%s: enter", __func__);
@ -188,60 +180,29 @@ int32_t AudioTestBindDaiLink(void)
return HDF_FAILURE;
}
struct AudioCard *card = (struct AudioCard *)OsalMemCalloc(sizeof(struct AudioCard));
if (card == NULL) {
ADM_LOG_ERR("%s_[%d] Malloc audioCard fail!", __func__, __LINE__);
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(AUDIO_CORE_SERVICE_TEST_NAME);
if (AudioFillConfigData(device, &(card->configData)) != HDF_SUCCESS) {
ADM_LOG_ERR("%s_[%d] AudioFillConfigData fail", __func__, __LINE__);
OsalMemFree(card);
card = NULL;
return HDF_FAILURE;
}
if (AudioBindDaiLink(card, &(card->configData)) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioBindDaiLink fail", __func__, __LINE__);
OsalMemFree(card);
card = NULL;
return HDF_FAILURE;
}
OsalMemFree(card->rtd);
card->rtd = NULL;
OsalMemFree(card);
card = NULL;
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t ReadCodecReg(unsigned long virtualAddress, uint32_t reg, uint32_t *val)
int32_t AudioUpdateCodecRegBitsTest(void)
{
return HDF_SUCCESS;
}
struct CodecData codecData;
struct CodecDevice codec;
HDF_LOGI("%s: enter", __func__);
int32_t WriteCodecReg(unsigned long virtualAddress, uint32_t reg, uint32_t val)
{
return HDF_SUCCESS;
}
int32_t AudioTestUpdateCodecRegBits(void)
{
int32_t value = 0;
if (AudioUpdateCodecRegBits(NULL, NULL, value) == HDF_SUCCESS) {
if (AudioUpdateCodecRegBits(NULL, NULL, 0) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioUpdateCodecRegBits fail", __func__, __LINE__);
return HDF_FAILURE;
}
struct CodecData codecData = {
.Read = ReadCodecReg,
.Write = WriteCodecReg,
};
struct CodecDevice codec;
codec.devCodecName = PLATFORM_CODEC_TEST_NAME;
(void)memset_s(&codecData, sizeof(struct CodecData), 0, sizeof(struct CodecData));
(void)memset_s(&codec, sizeof(struct CodecDevice), 0, sizeof(struct CodecDevice));
codecData.Read = AudioDeviceReadRegMock;
codecData.Write = AudioDeviceWriteRegMock,
codec.devCodecName = "codec_service_0";
OsalMutexInit(&codec.mutex);
codec.devData = &codecData;
value = g_audioMixerRegParams.min + 1;
if (AudioUpdateCodecRegBits(&codec, &g_audioMixerRegParams, value) != HDF_SUCCESS) {
if (AudioUpdateCodecRegBits(&codec, &g_audioTestReg, g_audioTestReg.min + 1) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioUpdateCodecRegBits fail", __func__, __LINE__);
OsalMutexDestroy(&codec.mutex);
return HDF_FAILURE;
@ -252,29 +213,68 @@ int32_t AudioTestUpdateCodecRegBits(void)
return HDF_SUCCESS;
}
int32_t AudioTestUpdateAccessoryRegBits(void)
int32_t AudioUpdateAccessoryRegBitsTest(void)
{
struct AccessoryDevice *accessory = NULL;
struct AudioMixerControl *mixerControl = NULL;
int32_t value = 0;
struct AccessoryDevice accessory;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioUpdateAccessoryRegBits(accessory, mixerControl, value);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioTestUpdateAccessoryRegBits fail", __func__, __LINE__);
if (AudioUpdateAccessoryRegBits(NULL, NULL, 0) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioUpdateAccessoryRegBits fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&accessory, sizeof(struct AccessoryDevice), 0, sizeof(struct AccessoryDevice));
accessory.devAccessoryName = "codec_service_1";
OsalMutexInit(&accessory.mutex);
if (AudioUpdateAccessoryRegBits(&accessory, &g_audioTestReg, g_audioTestReg.min + 1) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioUpdateAccessoryRegBits fail", __func__, __LINE__);
OsalMutexDestroy(&accessory.mutex);
}
OsalMutexDestroy(&accessory.mutex);
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioUpdateDaiRegBitsTest(void)
{
struct DaiDevice dai;
HDF_LOGI("%s: enter", __func__);
if (AudioUpdateDaiRegBits(NULL, NULL, 0) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioUpdateDaiRegBits fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&dai, sizeof(struct DaiDevice), 0, sizeof(struct DaiDevice));
dai.devDaiName = "dai_service";
if (AudioUpdateDaiRegBits(&dai, &g_audioTestReg, g_audioTestReg.min + 1) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioUpdateAccessoryRegBits fail", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestKcontrolGetCodec(void)
int32_t AudioKcontrolGetCpuDaiTest(void)
{
struct CodecDevice *codecDevice = NULL;
const struct AudioKcontrol *kcontrol = NULL;
struct AudioKcontrol *kcontrol = NULL;
HDF_LOGI("%s: enter", __func__);
codecDevice = AudioKcontrolGetCodec(kcontrol);
if (codecDevice == NULL) {
if (AudioKcontrolGetCpuDai(kcontrol) == NULL) {
HDF_LOGE("%s_[%d] AudioKcontrolGetCpuDai fail!", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioKcontrolGetCodecTest(void)
{
struct AudioKcontrol *kcontrol = NULL;
HDF_LOGI("%s: enter", __func__);
if (AudioKcontrolGetCodec(kcontrol) == NULL) {
HDF_LOGE("%s_[%d] AudioKcontrolGetCodec fail!", __func__, __LINE__);
}
@ -282,11 +282,12 @@ int32_t AudioTestKcontrolGetCodec(void)
return HDF_SUCCESS;
}
int32_t AudioTestKcontrolGetAccessory(void)
int32_t AudioKcontrolGetAccessoryTest(void)
{
struct AudioKcontrol *kcontrol = NULL;
struct AccessoryDevice *accessory = AudioKcontrolGetAccessory(kcontrol);
if (accessory == NULL) {
HDF_LOGI("%s: enter", __func__);
if (AudioKcontrolGetAccessory(kcontrol) == NULL) {
HDF_LOGE("%s_[%d] AudioKcontrolGetAccessory fail!", __func__, __LINE__);
}
@ -294,106 +295,201 @@ int32_t AudioTestKcontrolGetAccessory(void)
return HDF_SUCCESS;
}
int32_t AudioTestAddControl(void)
int32_t AudioAddControlsTest(void)
{
struct AudioCard *audioCard = NULL;
const struct AudioKcontrol *control = NULL;
struct AudioKcontrol *audioKcontrol = NULL;
HDF_LOGI("%s: enter", __func__);
audioKcontrol = AudioAddControl(audioCard, control);
if (audioKcontrol == NULL) {
if (AudioAddControls(NULL, NULL, 0) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioUpdateDaiRegBits fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioAddControlTest(void)
{
struct AudioCard *audioCard = NULL;
struct AudioKcontrol control;
HDF_LOGI("%s: enter", __func__);
audioCard = GetCardInstance("hdf_audio_codec_dev0");
(void)memset_s(&control, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
if (AudioAddControl(audioCard, &control) == NULL) {
HDF_LOGE("%s_[%d] AudioAddControl fail!", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestAddControls(void)
int32_t AudioGetCtrlOpsRRegTest(void)
{
struct AudioCard *audioCard = NULL;
const struct AudioKcontrol *controls = NULL;
int32_t controlMaxNum = 0x03;
int32_t ret;
struct AudioCtrlElemValue elemValue;
struct AudioMixerControl mixerCtrl;
HDF_LOGI("%s: enter", __func__);
ret = AudioAddControls(audioCard, controls, controlMaxNum);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAddControls fail", __func__, __LINE__);
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
(void)memset_s(&mixerCtrl, sizeof(struct AudioMixerControl), 0, sizeof(struct AudioMixerControl));
AudioGetCtrlOpsRReg(&elemValue, &mixerCtrl, 0);
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioGetCtrlOpsRegTest(void)
{
struct AudioCtrlElemValue elemValue;
struct AudioMixerControl mixerCtrl;
HDF_LOGI("%s: enter", __func__);
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
(void)memset_s(&mixerCtrl, sizeof(struct AudioMixerControl), 0, sizeof(struct AudioMixerControl));
AudioGetCtrlOpsReg(&elemValue, &mixerCtrl, 0);
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioSetCtrlOpsRegTest(void)
{
uint32_t value;
struct AudioKcontrol kcontrol;
struct AudioCtrlElemValue elemValue;
struct AudioMixerControl mixerCtrl;
HDF_LOGI("%s: enter", __func__);
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
(void)memset_s(&mixerCtrl, sizeof(struct AudioMixerControl), 0, sizeof(struct AudioMixerControl));
AudioSetCtrlOpsReg(&kcontrol, &elemValue, &mixerCtrl, &value);
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioSetCtrlOpsRRegTest(void)
{
uint32_t value;
bool updateRReg;
struct AudioCtrlElemValue elemValue;
struct AudioMixerControl mixerCtrl;
HDF_LOGI("%s: enter", __func__);
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
(void)memset_s(&mixerCtrl, sizeof(struct AudioMixerControl), 0, sizeof(struct AudioMixerControl));
AudioSetCtrlOpsRReg(&elemValue, &mixerCtrl, &value, &updateRReg);
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioDaiReadRegTest(void)
{
uint32_t val;
struct DaiDevice dai;
HDF_LOGI("%s: enter", __func__);
(void)memset_s(&dai, sizeof(struct DaiDevice), 0, sizeof(struct DaiDevice));
if (AudioDaiReadReg(&dai, 0, &val) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioDaiReadReg fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestCodecReadReg(void)
int32_t AudioDaiWriteRegTest(void)
{
struct CodecDevice *codec = NULL;
uint32_t reg = 0;
uint32_t val = 0;
struct DaiDevice dai;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioCodecReadReg(codec, reg, &val);
if (ret != HDF_SUCCESS) {
(void)memset_s(&dai, sizeof(struct DaiDevice), 0, sizeof(struct DaiDevice));
if (AudioDaiWriteReg(&dai, 0, 0) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioDaiWriteReg fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioCodecReadRegTest(void)
{
uint32_t val;
struct CodecDevice codec;
HDF_LOGI("%s: enter", __func__);
(void)memset_s(&codec, sizeof(struct CodecDevice), 0, sizeof(struct CodecDevice));
if (AudioCodecReadReg(&codec, 0, &val) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCodecReadReg fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestAccessoryReadReg(void)
int32_t AudioCodecWriteRegTest(void)
{
struct AccessoryDevice *accessory = NULL;
uint32_t reg = 0;
uint32_t val = 0;
struct CodecDevice codec;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioAccessoryReadReg(accessory, reg, &val);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessoryReadReg fail", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestCodecWriteReg(void)
{
struct CodecDevice *codec = NULL;
uint32_t reg = 0;
uint32_t val = 0;
int32_t ret = AudioCodecWriteReg(codec, reg, val);
if (ret != HDF_SUCCESS) {
(void)memset_s(&codec, sizeof(struct CodecDevice), 0, sizeof(struct CodecDevice));
if (AudioCodecWriteReg(&codec, 0, 0) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCodecWriteReg fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestAccessoryWriteReg(void)
int32_t AudioAccessoryReadRegTest(void)
{
struct AccessoryDevice *accessory = NULL;
uint32_t reg = 0;
uint32_t val = 0;
uint32_t val;
struct AccessoryDevice accessory;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioAccessoryWriteReg(accessory, reg, val);
if (ret != HDF_SUCCESS) {
(void)memset_s(&accessory, sizeof(struct AccessoryDevice), 0, sizeof(struct AccessoryDevice));
if (AudioAccessoryReadReg(&accessory, 0, &val) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessoryReadReg fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioAccessoryWriteRegTest(void)
{
struct AccessoryDevice accessory;
HDF_LOGI("%s: enter", __func__);
(void)memset_s(&accessory, sizeof(struct AccessoryDevice), 0, sizeof(struct AccessoryDevice));
if (AudioAccessoryWriteReg(&accessory, 0, 0) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessoryWriteReg fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestInfoCtrlOps(void)
int32_t AudioInfoCtrlOpsTest(void)
{
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemInfo *elemInfo = NULL;
struct AudioKcontrol kcontrol;
struct AudioCtrlElemInfo elemInfo;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioInfoCtrlOps(kcontrol, elemInfo);
if (ret != HDF_SUCCESS) {
if (AudioInfoCtrlOps(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioInfoCtrlOps fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemInfo, sizeof(struct AudioCtrlElemInfo), 0, sizeof(struct AudioCtrlElemInfo));
if (AudioInfoCtrlOps(&kcontrol, &elemInfo) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioInfoCtrlOps fail", __func__, __LINE__);
}
@ -401,13 +497,19 @@ int32_t AudioTestInfoCtrlOps(void)
return HDF_SUCCESS;
}
int32_t AudioTestCodecGetCtrlOps(void)
int32_t AudioCodecGetCtrlOpsTest(void)
{
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
struct AudioKcontrol kcontrol;
struct AudioCtrlElemValue elemValue;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioCodecGetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
if (AudioCodecGetCtrlOps(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCodecGetCtrlOps fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
if (AudioCodecGetCtrlOps(&kcontrol, &elemValue) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCodecGetCtrlOps fail", __func__, __LINE__);
}
@ -415,27 +517,19 @@ int32_t AudioTestCodecGetCtrlOps(void)
return HDF_SUCCESS;
}
int32_t AudioTestAccessoryGetCtrlOps(void)
int32_t AudioCodecSetCtrlOpsTest(void)
{
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
struct AudioKcontrol kcontrol;
struct AudioCtrlElemValue elemValue;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioAccessoryGetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessoryGetCtrlOps fail", __func__, __LINE__);
if (AudioCodecSetCtrlOps(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCodecSetCtrlOps fail", __func__, __LINE__);
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioTestCodecSetCtrlOps(void)
{
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
int32_t ret = AudioCodecSetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
if (AudioCodecSetCtrlOps(&kcontrol, &elemValue) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCodecSetCtrlOps fail", __func__, __LINE__);
}
@ -443,16 +537,82 @@ int32_t AudioTestCodecSetCtrlOps(void)
return HDF_SUCCESS;
}
int32_t AudioTestAccessorySetCtrlOps(void)
int32_t AudioAccessoryGetCtrlOpsTest(void)
{
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
struct AudioKcontrol kcontrol;
struct AudioCtrlElemValue elemValue;
HDF_LOGI("%s: enter", __func__);
int32_t ret = AudioAccessorySetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
if (AudioAccessoryGetCtrlOps(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessoryGetCtrlOps fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
if (AudioAccessoryGetCtrlOps(&kcontrol, &elemValue) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessoryGetCtrlOps fail", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioAccessorySetCtrlOpsTset(void)
{
struct AudioKcontrol kcontrol;
struct AudioCtrlElemValue elemValue;
HDF_LOGI("%s: enter", __func__);
if (AudioAccessorySetCtrlOps(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessorySetCtrlOps fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
if (AudioAccessorySetCtrlOps(&kcontrol, &elemValue) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioAccessorySetCtrlOps fail", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioCpuDaiSetCtrlOpsTest(void)
{
struct AudioKcontrol kcontrol;
struct AudioCtrlElemValue elemValue;
HDF_LOGI("%s: enter", __func__);
if (AudioCpuDaiSetCtrlOps(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCpuDaiSetCtrlOps fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
if (AudioCpuDaiSetCtrlOps(&kcontrol, &elemValue) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCpuDaiSetCtrlOps fail", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioCpuDaiGetCtrlOpsTest(void)
{
struct AudioKcontrol kcontrol;
struct AudioCtrlElemValue elemValue;
HDF_LOGI("%s: enter", __func__);
if (AudioCpuDaiGetCtrlOps(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCpuDaiGetCtrlOps fail", __func__, __LINE__);
return HDF_FAILURE;
}
(void)memset_s(&kcontrol, sizeof(struct AudioKcontrol), 0, sizeof(struct AudioKcontrol));
(void)memset_s(&elemValue, sizeof(struct AudioCtrlElemValue), 0, sizeof(struct AudioCtrlElemValue));
if (AudioCpuDaiGetCtrlOps(&kcontrol, &elemValue) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d] AudioCpuDaiGetCtrlOps fail", __func__, __LINE__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_dai_base_test.h"
#include "audio_dai_base.h"
#include "audio_driver_log.h"
#define HDF_LOG_TAG audio_dai_base_test
int32_t DaiDataFromCardTest(void)
{
struct AudioCard card;
if (DaiDataFromCard(NULL) != NULL) {
return HDF_FAILURE;
}
memset(&card, 0, sizeof(struct AudioCard));
if (DaiDataFromCard(&card) != NULL) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t DaiGetConfigInfoTest(void)
{
struct HdfDeviceObject device;
struct DaiData data;
if (DaiGetConfigInfo(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (DaiGetConfigInfo(&device, &data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t DaiCheckSampleRateTest(void)
{
if (DaiCheckSampleRate(0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (DaiCheckSampleRate(AUDIO_SAMPLE_RATE_8000) != HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t DaiSetConfigInfoTest(void)
{
struct DaiData data;
if (DaiSetConfigInfo(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
memset(&data, 0, sizeof(struct DaiData));
if (DaiSetConfigInfo(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -0,0 +1,169 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_dma_base_test.h"
#include "audio_platform_if.h"
#include "audio_dma_base.h"
#include "audio_driver_log.h"
#define HDF_LOG_TAG audio_dma_base_test
int32_t AudioDmaBufAllocTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaBufAlloc(NULL, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaBufAlloc(&data, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaBufFreeTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaBufFree(NULL, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaBufFree(&data, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaRequestChannelTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaRequestChannel(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaRequestChannel(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaConfigChannelTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaConfigChannel(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaConfigChannel(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaPrepTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaPrep(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaPrep(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaSubmitTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaSubmit(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaSubmit(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaPendingTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaPending(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaPending(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaPauseTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaPause(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaPause(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaResumeTest(void)
{
struct PlatformData data;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaResume(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaResume(&data) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDmaPointerTest(void)
{
struct PlatformData data;
uint32_t pointer = 0;
memset(&data, 0, sizeof(struct PlatformData));
if (AudioDmaPointer(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDmaPointer(&data, &pointer) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_dsp_base_test.h"
#include "audio_dsp_base.h"
#include "audio_driver_log.h"
#define HDF_LOG_TAG audio_dsp_base_test
#define KCONTROL_TEST_SERVICE_NAME "dsp_service_0"
int32_t DspGetServiceNameTest(void)
{
struct DeviceResourceAttr attr;
struct DeviceResourceNode node;
struct HdfDeviceObject device;
if (DspGetServiceName(NULL, NULL) == HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("TestDspGetServiceName fail");
return HDF_FAILURE;
}
attr.value = KCONTROL_TEST_SERVICE_NAME;
attr.name = "serviceName";
node.attrData = &attr;
device.property = &node;
if (DspGetServiceName(&device, NULL) == HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("TestDspGetServiceName fail");
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t DspGetDaiNameTest(void)
{
struct DeviceResourceNode node;
struct HdfDeviceObject device;
struct DeviceResourceAttr attr;
if (DspGetDaiName(NULL, NULL) == HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("TestDspGetDaiName fail");
return HDF_FAILURE;
}
attr.value = KCONTROL_TEST_SERVICE_NAME;
attr.name = "dspDaiName";
node.attrData = &attr;
device.property = &node;
if (DspGetDaiName(&device, NULL) == HDF_SUCCESS) {
AUDIO_DRIVER_LOG_ERR("TestDspGetDaiName fail");
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -11,10 +11,23 @@
#include "devsvc_manager_clnt.h"
#define HDF_LOG_TAG audio_host_test
#define KCONTROL_TEST_SERVICE_NAME "dsp_service_0"
int32_t AudioKcontrolTestGetCodec(void)
const static char *g_audioServiceName[] = {
"codec_service_0",
"codec_service_1",
"dma_service_0",
"dai_service",
"audio_service_0",
"audio_service_1",
"render_service",
"capture_service",
"control_service",
};
int32_t AudioHostCreateAndBindTest(void)
{
int i;
struct HdfDeviceObject *device = NULL;
HDF_LOGI("%s: enter", __func__);
if (AudioHostCreateAndBind(NULL) != NULL) {
@ -22,37 +35,25 @@ int32_t AudioKcontrolTestGetCodec(void)
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(KCONTROL_TEST_SERVICE_NAME);
struct AudioHost *audioHost = AudioHostCreateAndBind(device);
if (audioHost == NULL) {
HDF_LOGE("%s_[%d] codecDevice is NULL", __func__, __LINE__);
return HDF_FAILURE;
}
OsalMemFree(audioHost);
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t GetCardTestInstance(void)
{
int i;
const char *audioServiceName[] = {
"codec_service_0",
"codec_service_1",
"dma_service_0",
"dai_service",
"audio_service_0",
"audio_service_1",
"render_service",
"capture_service",
"control_service",
};
HDF_LOGI("%s: enter", __func__);
for (i = 0; i < sizeof(audioServiceName) / sizeof(audioServiceName[0]); ++i) {
if (GetCardInstance(audioServiceName[i]) == NULL) {
HDF_LOGE("%s: get %s fail!", __func__, audioServiceName[i]);
for (i = 0; i < sizeof(g_audioServiceName) / sizeof(g_audioServiceName[0]); ++i) {
device = DevSvcManagerClntGetDeviceObject(g_audioServiceName[i]);
if (AudioHostCreateAndBind(device) == NULL) {
HDF_LOGE("audiohost:%s create and bind fail!", g_audioServiceName[i]);
}
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t GetCardInstanceTest(void)
{
int i;
HDF_LOGI("%s: enter", __func__);
for (i = 0; i < sizeof(g_audioServiceName) / sizeof(g_audioServiceName[0]); ++i) {
if (GetCardInstance(g_audioServiceName[i]) == NULL) {
HDF_LOGE("%s: get %s fail!", __func__, g_audioServiceName[i]);
}
}

View File

@ -10,24 +10,44 @@
#include "devsvc_manager_clnt.h"
#define HDF_LOG_TAG audio_parse_test
#define TEST_PARSE_SERVICE_NAME "hdf_audio_codec_dev0"
int32_t AudioFillTestConfigData(void)
int32_t AudioFillConfigDataTest(void)
{
HDF_LOGI("%s: enter", __func__);
struct HdfDeviceObject *device = NULL;
struct AudioConfigData configData;
HDF_LOGI("enter");
if (AudioFillConfigData(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("%s_[%d]: AudioFillConfigData fail", __func__, __LINE__);
HDF_LOGE("AudioFillConfigData fail");
return HDF_FAILURE;
}
struct HdfDeviceObject *device = DevSvcManagerClntGetDeviceObject(TEST_PARSE_SERVICE_NAME);
struct AudioConfigData configData;
device = DevSvcManagerClntGetDeviceObject("hdf_audio_codec_dev0");
if (AudioFillConfigData(device, &configData) != HDF_SUCCESS) {
HDF_LOGE("%s_[%d]: AudioFillConfigData fail", __func__, __LINE__);
HDF_LOGE("AudioFillConfigData fail");
return HDF_FAILURE;
}
HDF_LOGI("%s: success", __func__);
HDF_LOGI("success");
return HDF_SUCCESS;
}
int32_t CodecGetRegConfigTest(void)
{
struct HdfDeviceObject *device = NULL;
struct AudioRegCfgData regCfgData;
HDF_LOGI("enter");
if (CodecGetRegConfig(NULL, NULL) == HDF_SUCCESS) {
HDF_LOGE("AudioFillConfigData fail");
return HDF_FAILURE;
}
device = DevSvcManagerClntGetDeviceObject("hdf_audio_codec_dev0");
if (CodecGetRegConfig(device, &regCfgData) != HDF_SUCCESS) {
HDF_LOGE("AudioFillConfigData fail");
}
HDF_LOGI("success");
return HDF_SUCCESS;
}

View File

@ -0,0 +1,403 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_platform_base_test.h"
#include "audio_stream_dispatch.h"
#include "audio_platform_base.h"
#include "audio_driver_log.h"
#define HDF_LOG_TAG audio_dsp_base_test
int32_t PlatformDataFromCardTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (PlatformDataFromCard(NULL) != NULL) {
return HDF_FAILURE;
}
if (PlatformDataFromCard(&card) != NULL) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioBytesToFramesTest(void)
{
if (AudioBytesToFrames(0, 0) != 0) {
return HDF_FAILURE;
}
if (AudioBytesToFrames(1, 1) != 1) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioDataBigEndianChangeTest(void)
{
char test[32];
memset(&test, 1, 32);
if (AudioDataBigEndianChange(NULL, 0, 0) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDataBigEndianChange(test, 32, DATA_BIT_WIDTH8) != HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDataBigEndianChange(test, 32, DATA_BIT_WIDTH24) != HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioDataBigEndianChange(test, 32, DATA_BIT_WIDTH16) != HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioFramatToBitWidthTest(void)
{
unsigned int bitWidth = 0;
if (AudioFramatToBitWidth(1, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioFramatToBitWidth(AUDIO_FORMAT_PCM_16_BIT, &bitWidth) != HDF_SUCCESS) {
return HDF_FAILURE;
}
if (bitWidth != DATA_BIT_WIDTH16) {
return HDF_FAILURE;
}
bitWidth = 0;
if (AudioFramatToBitWidth(AUDIO_FORMAT_PCM_24_BIT, &bitWidth) != HDF_SUCCESS) {
return HDF_FAILURE;
}
if (bitWidth != DATA_BIT_WIDTH24) {
return HDF_FAILURE;
}
if (AudioFramatToBitWidth(AUDIO_FORMAT_AAC_HE_V1, &bitWidth) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioSetPcmInfoTest(void)
{
struct PlatformData platformData;
struct AudioPcmHwParams param;
memset(&platformData, 0, sizeof(struct PlatformData));
memset(&param, 0, sizeof(struct AudioPcmHwParams));
if (AudioSetPcmInfo(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioSetPcmInfo(&platformData, &param) != HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioSetRenderBufInfoTest(void)
{
struct PlatformData data;
struct AudioPcmHwParams param;
memset(&data, 0, sizeof(struct PlatformData));
memset(&param, 0, sizeof(struct AudioPcmHwParams));
if (AudioSetRenderBufInfo(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioSetRenderBufInfo(&data, &param) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioSetCaptureBufInfoTest(void)
{
struct PlatformData data;
struct AudioPcmHwParams param;
memset(&data, 0, sizeof(struct PlatformData));
memset(&param, 0, sizeof(struct AudioPcmHwParams));
if (AudioSetCaptureBufInfo(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioSetCaptureBufInfo(&data, &param) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioPcmWriteTest(void)
{
struct AudioCard card;
struct AudioTxData txData;
memset(&card, 0, sizeof(struct AudioCard));
memset(&txData, 0, sizeof(struct AudioTxData));
if (AudioPcmWrite(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioPcmWrite(&card, &txData) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioPcmReadTest(void)
{
struct AudioCard card;
struct AudioRxData rxData;
memset(&card, 0, sizeof(struct AudioCard));
memset(&rxData, 0, sizeof(struct AudioRxData));
if (AudioPcmRead(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioPcmRead(&card, &rxData) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioPcmMmapWriteTest(void)
{
struct AudioCard card;
struct AudioMmapData txMmapData;
memset(&card, 0, sizeof(struct AudioCard));
memset(&txMmapData, 0, sizeof(struct AudioMmapData));
if (AudioPcmMmapWrite(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioPcmMmapWrite(&card, &txMmapData) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioPcmMmapReadTest(void)
{
struct AudioCard card;
struct AudioMmapData rxMmapData;
memset(&card, 0, sizeof(struct AudioCard));
memset(&rxMmapData, 0, sizeof(struct AudioMmapData));
if (AudioPcmMmapRead(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioPcmMmapRead(&card, &rxMmapData) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioRenderOpenTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioRenderOpen(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioRenderOpen(&card) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioCaptureOpenTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioCaptureOpen(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioCaptureOpen(&card) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioRenderCloseTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioRenderClose(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioRenderClose(&card) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioPcmPointerTest(void)
{
uint32_t pointer = 0;
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioPcmPointer(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioPcmPointer(&card, &pointer) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioCaptureCloseTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioCaptureClose(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioCaptureClose(&card) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioHwParamsTest(void)
{
struct AudioCard card;
struct AudioPcmHwParams param;
memset(&card, 0, sizeof(struct AudioCard));
memset(&param, 0, sizeof(struct AudioPcmHwParams));
if (AudioHwParams(NULL, NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioHwParams(&card, &param) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioRenderPrepareTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioRenderPrepare(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioRenderPrepare(&card) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioCapturePrepareTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioCapturePrepare(NULL) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioCapturePrepare(&card) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioRenderTriggerTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioRenderTrigger(NULL, AUDIO_DRV_PCM_IOCTL_RENDER_START) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioRenderTrigger(&card, AUDIO_DRV_PCM_IOCTL_RENDER_START) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioRenderTrigger(&card, AUDIO_DRV_PCM_IOCTL_RENDER_STOP) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioRenderTrigger(&card, AUDIO_DRV_PCM_IOCTL_RENDER_PAUSE) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioRenderTrigger(&card, AUDIO_DRV_PCM_IOCTL_RENDER_RESUME) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
int32_t AudioCaptureTriggerTest(void)
{
struct AudioCard card;
memset(&card, 0, sizeof(struct AudioCard));
if (AudioCaptureTrigger(NULL, AUDIO_DRV_PCM_IOCTL_CAPTURE_START) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioCaptureTrigger(&card, AUDIO_DRV_PCM_IOCTL_CAPTURE_START) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioCaptureTrigger(&card, AUDIO_DRV_PCM_IOCTL_CAPTURE_STOP) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioCaptureTrigger(&card, AUDIO_DRV_PCM_IOCTL_CAPTURE_PAUSE) == HDF_SUCCESS) {
return HDF_FAILURE;
}
if (AudioCaptureTrigger(&card, AUDIO_DRV_PCM_IOCTL_CAPTURE_RESUME) == HDF_SUCCESS) {
return HDF_FAILURE;
}
return HDF_SUCCESS;
}

View File

@ -10,7 +10,7 @@
#define HDF_LOG_TAG audio_host_test
int32_t AudioSapmTestNewComponents(void)
int32_t AudioSapmNewComponentsTest(void)
{
struct AudioCard *audioCard = NULL;
struct AudioSapmComponent *component = NULL;
@ -27,7 +27,7 @@ int32_t AudioSapmTestNewComponents(void)
return HDF_SUCCESS;
}
int32_t AudioSapmTestAddRoutes(void)
int32_t AudioSapmAddRoutesTest(void)
{
struct AudioCard *audioCard = NULL;
struct AudioSapmRoute *route = NULL;
@ -44,7 +44,7 @@ int32_t AudioSapmTestAddRoutes(void)
return HDF_SUCCESS;
}
int32_t AudioSapmTestNewControls(void)
int32_t AudioSapmNewControlsTest(void)
{
struct AudioCard *audioCard = NULL;
int32_t ret;
@ -58,35 +58,111 @@ int32_t AudioSapmTestNewControls(void)
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioSapmTestPowerComponents(void)
int32_t AudioSapmSleepTest(void)
{
struct AudioCard *audioCard = NULL;
int32_t ret;
HDF_LOGI("%s: enter", __func__);
ret = AudioSapmPowerComponents(audioCard);
ret = AudioSapmSleep(audioCard);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: audioCard is NULL", __func__);
HDF_LOGE("%s: AudioSapmSleep is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioSapmTestRefreshTime(void)
int32_t AudioSampPowerUpTest(void)
{
bool bRefresh = true;
u64 time;
struct AudioCard *audioCard = NULL;
int32_t ret;
HDF_LOGI("%s: enter", __func__);
time = AudioSapmRefreshTime(bRefresh);
if (time == 0) {
HDF_LOGE("%s: error", __func__);
ret = AudioSampPowerUp(audioCard);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: AudioSampPowerUp is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioSampSetPowerMonitorTest(void)
{
struct AudioCard *audioCard = NULL;
int32_t ret;
HDF_LOGI("%s: enter", __func__);
ret = AudioSampSetPowerMonitor(audioCard, 0);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: AudioSampSetPowerMonitor is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioCodecSapmSetCtrlOpsTest(void)
{
int32_t ret;
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
HDF_LOGI("%s: enter", __func__);
ret = AudioCodecSapmSetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: AudioCodecSapmSetCtrlOps is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioCodecSapmGetCtrlOpsTest(void)
{
int32_t ret;
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
HDF_LOGI("%s: enter", __func__);
ret = AudioCodecSapmGetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: AudioCodecSapmGetCtrlOps is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioAccessorySapmSetCtrlOpsTest(void)
{
int32_t ret;
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
HDF_LOGI("%s: enter", __func__);
ret = AudioAccessorySapmSetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: AudioAccessorySapmSetCtrlOps is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}
int32_t AudioAccessorySapmGetCtrlOpsTest(void)
{
int32_t ret;
struct AudioKcontrol *kcontrol = NULL;
struct AudioCtrlElemValue *elemValue = NULL;
HDF_LOGI("%s: enter", __func__);
ret = AudioAccessorySapmGetCtrlOps(kcontrol, elemValue);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: AudioAccessorySapmGetCtrlOps is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}

View File

@ -1,29 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
* See the LICENSE file in the root of this repository for complete details.
*/
#include "audio_stream_dispatch_test.h"
#include "audio_stream_dispatch.h"
#define HDF_LOG_TAG audio_host_test
int32_t AudioControlDispatchTestStreamDispatch(void)
{
struct HdfDeviceIoClient *client = NULL;
struct HdfSBuf *data = NULL;
struct HdfSBuf *reply = NULL;
int32_t cmdId = 0;
int32_t ret;
HDF_LOGI("%s: enter", __func__);
ret = StreamDispatch(client, cmdId, data, reply);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: (client || cmdId || data ||reply) is NULL", __func__);
}
HDF_LOGI("%s: success", __func__);
return HDF_SUCCESS;
}

View File

@ -12,45 +12,126 @@
#include "audio_core_test.h"
#include "audio_parse_test.h"
#include "audio_sapm_test.h"
#include "audio_stream_dispatch_test.h"
#include "audio_dai_base_test.h"
#include "audio_dma_base_test.h"
#include "audio_dsp_base_test.h"
#include "audio_codec_base_test.h"
#include "audio_platform_base_test.h"
#include "audio_accessory_base_test.h"
#define HDF_LOG_TAG hdf_audio_test
// add test case entry
static HdfTestCaseList g_hdfAudioTestCaseList[] = {
{AUDIO_DRIVER_TESTGETCODEC, AudioKcontrolTestGetCodec},
{AUDIO_DRIVER_TESTGETCARDINSTANCE, GetCardTestInstance},
{AUDIO_DRIVER_TESTGETCCNFIGDATA, AudioFillTestConfigData},
{AUDIO_DRIVER_TESTREGISTERPLATFORM, AudioSocTestRegisterPlatform},
{AUDIO_DRIVER_TESTREGISTERDAI, AudioSocTestRegisterDai},
{AUDIO_DRIVER_TESTREGISTERACCESSORY, AudioTestRegisterAccessory},
{AUDIO_DRIVER_TESTREGISTERCODEC, AudioTestRegisterCodec},
{AUDIO_DRIVER_TESTREGISTERDSP, AudioTestRegisterDsp},
{AUDIO_DRIVER_TESTSOCDEVICEREGISTER, AudioTestSocDeviceRegister},
{AUDIO_DRIVER_TESTBINDDAILINK, AudioTestBindDaiLink},
{AUDIO_DRIVER_TESTUPDATECODECREGBITS, AudioTestUpdateCodecRegBits},
{AUDIO_DRIVER_TESTUPDATEACCESSORYREGBITS, AudioTestUpdateAccessoryRegBits},
{AUDIO_DRIVER_TESTKCONTROLGETCODEC, AudioTestKcontrolGetCodec},
{AUDIO_DRIVER_TESTKCONTROLGETACCESSORY, AudioTestKcontrolGetAccessory},
{AUDIO_DRIVER_TESTADDCONTROL, AudioTestAddControl},
{AUDIO_DRIVER_TESTADDCONTROLS, AudioTestAddControls},
{AUDIO_DRIVER_TESTCODECREADREG, AudioTestCodecReadReg},
{AUDIO_DRIVER_TESTACCESSORYREADREG, AudioTestAccessoryReadReg},
{AUDIO_DRIVER_TESTCODECWRITEREG, AudioTestCodecWriteReg},
{AUDIO_DRIVER_TESTACCESSORYWRITEREG, AudioTestAccessoryWriteReg},
{AUDIO_DRIVER_TESTINFOCTRLOPS, AudioTestInfoCtrlOps},
{AUDIO_DRIVER_TESTCODECGETCTRLOPS, AudioTestCodecGetCtrlOps},
{AUDIO_DRIVER_TESTACCESSORYGETCTRLOPS, AudioTestAccessoryGetCtrlOps},
{AUDIO_DRIVER_TESTCODECSETCTRLOPS, AudioTestCodecSetCtrlOps},
{AUDIO_DRIVER_TESTACCESSORYSETCTRLOPS, AudioTestAccessorySetCtrlOps},
{AUDIO_ADM_TEST_AUDIOHOSTCREATEANDBIND, AudioHostCreateAndBindTest}, // audio ADM audio_host
{AUDIO_ADM_TEST_GETCARDINSTANCE, GetCardInstanceTest}, // audio ADM audio_host
{AUDIO_DRIVER_TESTNEWCOMPONENT, AudioSapmTestNewComponents},
{AUDIO_DRIVER_TESTADDROUTES, AudioSapmTestAddRoutes},
{AUDIO_DRIVER_TESTNEWCONTROLS, AudioSapmTestNewControls},
{AUDIO_DRIVER_TESTPOWERCOMPONET, AudioSapmTestPowerComponents},
{AUDIO_DRIVER_TESTREFRESHTIME, AudioSapmTestRefreshTime},
{AUDIO_DRIVER_TESTSTREAMDISPATCH, AudioControlDispatchTestStreamDispatch},
{AUDIO_ADM_TEST_AUDIOFILLCONFIGDATA, AudioFillConfigDataTest}, // audio ADM audio_parse
{AUDIO_ADM_TEST_CODECGETREGCONFIG , CodecGetRegConfigTest}, // audio ADM audio_parse
{AUDIO_ADM_TEST_AUDIODEVICEREADREG, AudioDeviceReadRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIODEVICEWRITEREG, AudioDeviceWriteRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOSOCREGISTERPLATFORM, AudioSocRegisterPlatformTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOSOCREGISTERDAI, AudioSocRegisterDaiTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOREGISTERDSP, AudioRegisterDspTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOREGISTERCODEC, AudioRegisterCodecTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOREGISTERACCESSORY, AudioRegisterAccessoryTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOBINDDAILINK, AudioBindDaiLinkTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOUPDATECODECREGBITS, AudioUpdateCodecRegBitsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOUPDATEACCESSORYREGBITS, AudioUpdateAccessoryRegBitsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOUPDATEDAIREGBITS, AudioUpdateDaiRegBitsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOKCONTROLGETCPUDAI, AudioKcontrolGetCpuDaiTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOKCONTROLGETCODEC, AudioKcontrolGetCodecTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOKCONTROLGETACCESSORY, AudioKcontrolGetAccessoryTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOADDCONTROLS, AudioAddControlsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOADDCONTROL, AudioAddControlTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOGETCTRLOPSRREG, AudioGetCtrlOpsRRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOGETCTRLOPSREG, AudioGetCtrlOpsRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOSETCTRLOPSREG, AudioSetCtrlOpsRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOSETCTRLOPSRREG, AudioSetCtrlOpsRRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIODAIREADREG, AudioDaiReadRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIODAIWRITEREG, AudioDaiWriteRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOCODECREADREG, AudioCodecReadRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOCODECWRITEREG, AudioCodecWriteRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOACCESSORYREADREG, AudioAccessoryReadRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOACCESSORYWRITEREG, AudioAccessoryWriteRegTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOINFOCTRLOPS, AudioInfoCtrlOpsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOCODECGETCTRLOPS, AudioCodecGetCtrlOpsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOCODECSETCTRLOPS, AudioCodecSetCtrlOpsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOACCESSORYGETCTRLOPS, AudioAccessoryGetCtrlOpsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOACCESSORYSETCTRLOPS, AudioAccessorySetCtrlOpsTset}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOCPUDAISETCTRLOPS, AudioCpuDaiSetCtrlOpsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOCPUDAIGETCTRLOPS, AudioCpuDaiGetCtrlOpsTest}, // audio ADM audio_core
{AUDIO_ADM_TEST_AUDIOSAPMNEWCOMPONENTS, AudioSapmNewComponentsTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOSAPMADDROUTES, AudioSapmAddRoutesTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOSAPMNEWCONTROLS, AudioSapmNewControlsTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOSAPMSLEEP, AudioSapmSleepTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOSAMPPOWERUP, AudioSampPowerUpTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOSAMPSETPOWERMONITOR, AudioSampSetPowerMonitorTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOCODECSAPMSETCTRLOPS, AudioCodecSapmSetCtrlOpsTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOCODECSAPMGETCTRLOPS, AudioCodecSapmGetCtrlOpsTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOACCESSORYSAPMSETCTRLOPS, AudioAccessorySapmSetCtrlOpsTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_AUDIOACCESSORYSAPMGETCTRLOPS, AudioAccessorySapmGetCtrlOpsTest}, // audio ADM audio_sapm
{AUDIO_ADM_TEST_I2CREADWRITE, AccessoryI2cReadWriteTest},
{AUDIO_ADM_TEST_REGBITSREAD, AccessoryRegBitsReadTest},
{AUDIO_ADM_TEST_REGBITSUPDATE, AccessoryRegBitsUpdateTest},
{AUDIO_ADM_TEST_DEVICEFREQUENCYPARSE, AcessoryDeviceFrequencyParseTest},
{AUDIO_ADM_TEST_DAIPARAMSUPDATE, AccessoryDaiParamsUpdateTest},
{AUDIO_ADM_TEST_DEVICECFGGET, AccessoryDeviceCfgGetTest},
{AUDIO_ADM_TEST_DEVICECTRLREGINIT, AccessoryDeviceCtrlRegInitTest},
{AUDIO_ADM_TEST_DEVICEREGREAD, AccessoryDeviceRegReadTest},
{AUDIO_ADM_TEST_DEVICEREGWRITE, AccessoryDeviceRegWriteTest},
{AUDIO_ADM_TEST_AGETCONFIGINFO, AccessoryGetConfigInfoTest},
{AUDIO_ADM_TEST_GETSERVICENAME, CodecGetServiceNameTest},
{AUDIO_ADM_TEST_GETDAINAME, CodecGetDaiNameTest},
{AUDIO_ADM_TEST_GETCONFIGINFO, CodecGetConfigInfoTest},
{AUDIO_ADM_TEST_SETCONFIGINFO, CodecSetConfigInfoTest},
{AUDIO_ADM_TEST_SETCTLFUNC, CodecSetCtlFuncTest},
{AUDIO_ADM_TEST_DAIDATAFROMCARD, DaiDataFromCardTest},
{AUDIO_ADM_TEST_DAIGETCONFIGINFO, DaiGetConfigInfoTest},
{AUDIO_ADM_TEST_DAICHECKSAMPLERATE, DaiCheckSampleRateTest},
{AUDIO_ADM_TEST_DAISETCONFIGINFO, DaiSetConfigInfoTest},
{AUDIO_ADM_TEST_DMABUFALLOC, AudioDmaBufAllocTest},
{AUDIO_ADM_TEST_DMABUFFREE, AudioDmaBufFreeTest},
{AUDIO_ADM_TEST_DMAREQUESTCHANNEL, AudioDmaRequestChannelTest},
{AUDIO_ADM_TEST_DMACONFIGCHANNEL, AudioDmaConfigChannelTest},
{AUDIO_ADM_TEST_DMAPREP, AudioDmaPrepTest},
{AUDIO_ADM_TEST_DMASUBMIT, AudioDmaSubmitTest},
{AUDIO_ADM_TEST_DMAPENDING, AudioDmaPendingTest},
{AUDIO_ADM_TEST_DMAPAUSE, AudioDmaPauseTest},
{AUDIO_ADM_TEST_DMARESUME, AudioDmaResumeTest},
{AUDIO_ADM_TEST_DMAPOINTER, AudioDmaPointerTest},
{AUDIO_ADM_TEST_DSPGETSERVICENAME, DspGetServiceNameTest},
{AUDIO_ADM_TEST_DSPGETDAINAME, DspGetDaiNameTest},
{AUDIO_ADM_TEST_DATAFROMCARD, PlatformDataFromCardTest},
{AUDIO_ADM_TEST_BYTESTOFRAMES, AudioBytesToFramesTest},
{AUDIO_ADM_TEST_DATABIGENDIANCHANGE, AudioDataBigEndianChangeTest},
{AUDIO_ADM_TEST_FRAMATTOBITWIDTH, AudioFramatToBitWidthTest},
{AUDIO_ADM_TEST_SETPCMINFO, AudioSetPcmInfoTest},
{AUDIO_ADM_TEST_SETRENDERBUFINFO, AudioSetRenderBufInfoTest},
{AUDIO_ADM_TEST_SETCAPTUREBUFINFO, AudioSetCaptureBufInfoTest},
{AUDIO_ADM_TEST_PCMWRITE, AudioPcmWriteTest},
{AUDIO_ADM_TEST_PCMREAD, AudioPcmReadTest},
{AUDIO_ADM_TEST_PCMMMAPWRITE, AudioPcmMmapWriteTest},
{AUDIO_ADM_TEST_PCMMMAPREAD, AudioPcmMmapReadTest},
{AUDIO_ADM_TEST_RENDEROPEN, AudioRenderOpenTest},
{AUDIO_ADM_TEST_CAPTUREOPEN, AudioCaptureOpenTest},
{AUDIO_ADM_TEST_RENDERCLOSE, AudioRenderCloseTest},
{AUDIO_ADM_TEST_PCMPOINTER, AudioPcmPointerTest},
{AUDIO_ADM_TEST_CAPTURECLOSE, AudioCaptureCloseTest},
{AUDIO_ADM_TEST_HWPARAMS, AudioHwParamsTest},
{AUDIO_ADM_TEST_RENDERPREPARE, AudioRenderPrepareTest},
{AUDIO_ADM_TEST_CAPTUREPREPARE, AudioCapturePrepareTest},
{AUDIO_ADM_TEST_RENDERTRIGGER, AudioRenderTriggerTest},
{AUDIO_ADM_TEST_CAPTURETRIGGER, AudioCaptureTriggerTest}
};
int32_t HdfAudioEntry(HdfTestMsg *msg)