xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852be/phl/phl_sound_fsm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2019 - 2020 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __PHL_SOUND_FSM_H__
16 #define __PHL_SOUND_FSM_H__
17 
18 struct phl_sound_obj;
19 
20 enum RTW_PHL_SND_NOTIFY_EVENT {
21 	RTW_PHL_SND_START,
22 	RTW_PHL_SND_ABORT,
23 	RTW_PHL_SND_C2H_SND_DOWN /* C2H Sounding Down */
24 };
25 
26 enum SND_EV_ID {
27 	SND_FUNC_EV_INIT,
28 	SND_FUNC_EV_DEINIT,
29 	SND_FUNC_EV_SND_START,
30 	SND_FUNC_EV_NOTIFY_PENDING_REQ,
31 	SND_FUNC_EV_CHK_SND_STS,
32 	SND_FUNC_EV_PROC_GRP,
33 	SND_FUNC_EV_START_SND_PROC,
34 	SND_FUNC_EV_END_SND,
35 	SND_PROC_EV_IDLE_GET_SND_GRP,
36 	SND_PROC_EV_IDLE_FREE_PRE_RES,
37 	SND_PROC_EV_BUSY_GET_BF_RES,
38 	SND_PROC_EV_BUSY_PRE_CFG,
39 	SND_PROC_EV_BUSY_TRIG_SND,
40 	SND_PROC_EV_BUSY_REL_SND_CTRL,
41 	SND_PROC_EV_BUSY_POLLING_STS,
42 	SND_PROC_EV_BUSY_SND_DOWN,
43 	SND_PROC_EV_DOWN_POST_CFG,
44 	SND_PROC_EV_DOWN_SND_END,
45 	SND_PROC_EV_DOWN_NEXT_SND,
46 	SND_EV_TERMINATE,
47 	SND_EV_DONOTHING,
48 	SND_EV_MAX
49 };
50 
51 enum SND_STATE_ST {
52 	/* Initializae and de-initialize*/
53 	SND_ST_FUNC_INIT,
54 	SND_ST_FUNC_DEINIT,
55 	/* FUNC MAIN STATE */
56 	SND_ST_FUNC_READY,
57 	SND_ST_FUNC_LEAVE,
58 	/* SND PROC - periodic */
59 	SND_ST_PROC_IDLE,
60 	SND_ST_PROC_BUSY,
61 	SND_ST_PROC_DOWN,
62 	SND_ST_PROC_TERMINATE
63 };
64 
65 struct phl_snd_start_req {
66 	void *wrole;
67 	u8 dialog_token;
68 	u8 proc_timeout_ms;
69 	u8 proc_period;
70 	bool bypass_sts_chk;
71 	u8 test_flag;
72 };
73 
74 struct fsm_main *phl_sound_new_fsm(struct fsm_root *root,
75 	struct phl_info_t *phl_info);
76 
77 void phl_snd_destory_fsm(struct fsm_main *fsm);
78 
79 enum rtw_phl_status phl_snd_fsm_ev_c2h_snd_down(void *phl);
80 
81 void phl_snd_destory_obj(struct phl_sound_obj *snd);
82 
83 enum rtw_phl_status phl_snd_fsm_ev_abort(void *phl);
84 
85 enum rtw_phl_status
86 phl_snd_fsm_ev_start_func(void *phl, void *req);
87 
88 enum rtw_phl_status
89 phl_snd_fsm_send_msg(void *phl, enum RTW_PHL_SND_NOTIFY_EVENT notify,
90 		     void *buf, u32 buf_sz);
91 
92 u8 phl_snd_is_inprogress(void *phl);
93 
94 #endif
95