1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "hi3516_common_func.h"
20
InitHwParam(struct AudioPcmHwParams * hwParam)21 int32_t InitHwParam(struct AudioPcmHwParams *hwParam)
22 {
23 const uint32_t channelNum = 2;
24 const uint32_t sampleRate = 48000;
25 const uint32_t periodSize = 4096;
26 const uint32_t periodCount = 8;
27 const int format = 2;
28 const uint32_t startThreshold = 1024;
29 const uint32_t stopThreshold = 0x7fffffff;
30 const uint32_t silenceThreshold = 1024 * 16;
31
32 if (hwParam == NULL) {
33 HDF_LOGE("InitHwParam: input param is NULL.");
34 return HDF_FAILURE;
35 }
36
37 hwParam->channels = channelNum;
38 hwParam->rate = sampleRate;
39 hwParam->periodSize = periodSize;
40 hwParam->periodCount = periodCount;
41 hwParam->format = format;
42 hwParam->cardServiceName = "hdf_audio_codec_dev0";
43 hwParam->isBigEndian = false;
44 hwParam->isSignedData = true;
45 hwParam->startThreshold = startThreshold;
46 hwParam->stopThreshold = stopThreshold;
47 hwParam->silenceThreshold = silenceThreshold;
48 hwParam->streamType = 0; // AUDIO_RENDER_STREAM
49 return HDF_SUCCESS;
50 }
51
52
GetAudioCard(struct AudioCard ** card)53 int32_t GetAudioCard(struct AudioCard **card)
54 {
55 HDF_LOGI("%s: enter", __func__);
56 if (card == NULL) {
57 HDF_LOGE("input param is NULL");
58 return HDF_FAILURE;
59 }
60 *card = GetCardInstance("hdf_audio_codec_primary_dev0");
61
62 if (*card == NULL) {
63 HDF_LOGE("get card instance failed");
64 return HDF_FAILURE;
65 }
66 return HDF_SUCCESS;
67 }
68