blob: a2504cf32bf5da53c67a7b1327c04f9dc593f3c0 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2** Copyright (c) 2015-2016 by Silicon Laboratories
3**
4** $Id: demo_common.h 6594 2017-06-30 22:51:35Z mjmourni $
5**
6** Distributed by:
7** Silicon Laboratories, Inc
8**
9** This file contains proprietary information.
10** No dissemination allowed without prior written permission from
11** Silicon Laboratories, Inc.
12**
13** File Description:
14** Common functions for the various API demo programs.
15**
16**
17*/
18
19#ifndef __PROSLIC_DEMO_COMMON_HDR__
20#define __PROSLIC_DEMO_COMMON_HDR__ 1
21
22#include "proslic.h"
23
24#ifdef TSTIN_SUPPORT
25#include "proslic_tstin.h"
26#endif
27
28#define DEMO_NUM_IRQS 4
29/*****************************************************************************************************/
30typedef struct
31{
32 uInt8 irq_save[DEMO_NUM_IRQS]; /* Save/restore IRQ settings for various functions */
33 BOOLEAN isFRS_enabled; /* Is fast ring start enabled */
34} demo_chan_info_t;
35
36/*****************************************************************************************************/
37/* This data structure is to keep track a string of the same devices in 1 container. If the system
38 * has 2 different devices - say 3 Si3226x's and 1 Si3217x, you would need 2 instances of this structure -
39 * 1 to contain the 3 Si3226x's and 1 to contain the Si3217x.
40 *
41 * The initialization code at present assumes everything is on the same daisy chain. Efforts are made
42 * to note where a code change would be needed if this is not true.
43 */
44typedef struct
45{
46 int deviceType;
47 int numberOfDevice;
48 int numberOfChan;
49 int chanPerDevice;
50 int channelBaseIndex;
51
52 SiVoiceChanType_ptr channels;
53 SiVoiceChanType_ptr *channelPtrs;
54 SiVoiceDeviceType_ptr devices;
55 demo_chan_info_t *demo_info;
56#ifdef TSTIN_SUPPORT
57 proslicTestInObjType_ptr pTstin;
58#endif
59
60} demo_port_t;
61
62typedef struct
63{
64 demo_port_t *ports;
65 demo_port_t *currentPort;
66 int currentChannel;
67 int totalChannelCount;
68 SiVoiceChanType_ptr currentChanPtr;
69
70 BOOLEAN is_offhook;
71} demo_state_t;
72
73typedef enum
74{
75 DEMO_RING_PRESET,
76 DEMO_DCFEED_PRESET,
77 DEMO_IMPEDANCE_PRESET,
78 DEMO_FSK_PRESET,
79 DEMO_PM_PRESET,
80 DEMO_TONEGEN_PRESET,
81 DEMO_PCM_PRESET,
82 DEMO_VDAA_COUNTRY_PRESET,
83 DEMO_VDAA_AUDIO_GAIN_PRESET,
84 DEMO_VDAA_RING_VALIDATION_PRESET,
85 DEMO_VDAA_PCM_PRESET,
86 DEMO_VDAA_HYBRID_PRESET,
87} demo_preset_t;
88
89/*****************************************************************************************************/
90void demo_init_port_info(demo_port_t *port, unsigned int port_id);
91int demo_alloc(demo_port_t *port, int *base_channel_index,
92 controlInterfaceType *proslic_api_hwIf);
93int demo_init_devices(demo_port_t *port);
94int demo_load_presets(demo_port_t *port);
95void demo_shutdown(demo_port_t *port);
96void demo_free(demo_port_t *port);
97int demo_get_preset(demo_preset_t preset_enum);
98/* Return back the channel pointer, given a channel number */
99SiVoiceChanType_ptr demo_get_cptr(demo_state_t *demo_state, int channel_number);
100void demo_save_slic_irqens(demo_state_t *pState);
101void demo_restore_slic_irqens(demo_state_t *pState);
102int demo_set_chan_state(demo_port_t *port);
103
104#endif /* __PROSLIC_DEMO_COMMON_HDR__ */
105