1 /*
2  * Copyright 2018, NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #include <string.h>
10 
11 #include "srtm_wm8524_adapter.h"
12 #include "srtm_heap.h"
13 
14 /*******************************************************************************
15  * Definitions
16  ******************************************************************************/
17 /* WM8524 adapter */
18 typedef struct _srtm_wm8524_adapter
19 {
20     struct _srtm_codec_adapter adapter;
21     srtm_wm8524_config_t config;
22     codec_handle_t *driver;
23 } * srtm_wm8524_adapter_t;
24 
25 /*******************************************************************************
26  * Prototypes
27  ******************************************************************************/
28 
29 /*******************************************************************************
30  * Variables
31  ******************************************************************************/
32 
33 /*******************************************************************************
34  * Code
35  ******************************************************************************/
36 /* Currently only 1 audio instance is adequate, so index is just ignored */
SRTM_CodecAdapter_SetParam(srtm_codec_adapter_t adapter,uint8_t index,uint8_t format,uint32_t srate)37 static srtm_status_t SRTM_CodecAdapter_SetParam(srtm_codec_adapter_t adapter,
38                                                 uint8_t index,
39                                                 uint8_t format,
40                                                 uint32_t srate)
41 {
42     return SRTM_Status_Success;
43 }
SRTM_CodecAdapter_SetReg(srtm_codec_adapter_t adapter,uint32_t reg,uint32_t regVal)44 static srtm_status_t SRTM_CodecAdapter_SetReg(srtm_codec_adapter_t adapter, uint32_t reg, uint32_t regVal)
45 {
46     return SRTM_Status_Success;
47 }
48 
SRTM_CodecAdapter_GetReg(srtm_codec_adapter_t adapter,uint32_t reg,uint32_t * pRegVal)49 static srtm_status_t SRTM_CodecAdapter_GetReg(srtm_codec_adapter_t adapter, uint32_t reg, uint32_t *pRegVal)
50 {
51     return SRTM_Status_Success;
52 }
SRTM_Wm8524Adapter_Create(codec_handle_t * driver,srtm_wm8524_config_t * config)53 srtm_codec_adapter_t SRTM_Wm8524Adapter_Create(codec_handle_t *driver, srtm_wm8524_config_t *config)
54 {
55     srtm_wm8524_adapter_t handle;
56 
57     assert((driver != NULL) && (config != NULL));
58 
59     SRTM_DEBUG_MESSAGE(SRTM_DEBUG_VERBOSE_INFO, "%s\r\n", __func__);
60 
61     handle = (srtm_wm8524_adapter_t)SRTM_Heap_Malloc(sizeof(struct _srtm_wm8524_adapter));
62     assert(handle != NULL);
63 
64     handle->driver = driver;
65     (void)memcpy(&handle->config, config, sizeof(struct _srtm_wm8524_config));
66 
67     /* Adapter interfaces. */
68     handle->adapter.setParam = SRTM_CodecAdapter_SetParam;
69     handle->adapter.setReg   = SRTM_CodecAdapter_SetReg;
70     handle->adapter.getReg   = SRTM_CodecAdapter_GetReg;
71 
72     return &handle->adapter;
73 }
74 
SRTM_Wm8524Adapter_Destroy(srtm_codec_adapter_t adapter)75 void SRTM_Wm8524Adapter_Destroy(srtm_codec_adapter_t adapter)
76 {
77     srtm_wm8524_adapter_t handle = (srtm_wm8524_adapter_t)(void *)adapter;
78 
79     assert(adapter != NULL);
80 
81     SRTM_DEBUG_MESSAGE(SRTM_DEBUG_VERBOSE_INFO, "%s\r\n", __func__);
82 
83     SRTM_Heap_Free(handle);
84 }
85