1*18b4f1a0SMichael Strauss /*
2*18b4f1a0SMichael Strauss  * Copyright 2019 Advanced Micro Devices, Inc.
3*18b4f1a0SMichael Strauss  *
4*18b4f1a0SMichael Strauss  * Permission is hereby granted, free of charge, to any person obtaining a
5*18b4f1a0SMichael Strauss  * copy of this software and associated documentation files (the "Software"),
6*18b4f1a0SMichael Strauss  * to deal in the Software without restriction, including without limitation
7*18b4f1a0SMichael Strauss  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*18b4f1a0SMichael Strauss  * and/or sell copies of the Software, and to permit persons to whom the
9*18b4f1a0SMichael Strauss  * Software is furnished to do so, subject to the following conditions:
10*18b4f1a0SMichael Strauss  *
11*18b4f1a0SMichael Strauss  * The above copyright notice and this permission notice shall be included in
12*18b4f1a0SMichael Strauss  * all copies or substantial portions of the Software.
13*18b4f1a0SMichael Strauss  *
14*18b4f1a0SMichael Strauss  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*18b4f1a0SMichael Strauss  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*18b4f1a0SMichael Strauss  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*18b4f1a0SMichael Strauss  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*18b4f1a0SMichael Strauss  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*18b4f1a0SMichael Strauss  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*18b4f1a0SMichael Strauss  * OTHER DEALINGS IN THE SOFTWARE.
21*18b4f1a0SMichael Strauss  *
22*18b4f1a0SMichael Strauss  * Authors: AMD
23*18b4f1a0SMichael Strauss  *
24*18b4f1a0SMichael Strauss  */
25*18b4f1a0SMichael Strauss 
26*18b4f1a0SMichael Strauss #ifndef __DAL_DCN31_AFMT_H__
27*18b4f1a0SMichael Strauss #define __DAL_DCN31_AFMT_H__
28*18b4f1a0SMichael Strauss 
29*18b4f1a0SMichael Strauss 
30*18b4f1a0SMichael Strauss #define DCN31_AFMT_FROM_AFMT(afmt)\
31*18b4f1a0SMichael Strauss 	container_of(afmt, struct dcn31_afmt, base)
32*18b4f1a0SMichael Strauss 
33*18b4f1a0SMichael Strauss #define AFMT_DCN31_REG_LIST(id) \
34*18b4f1a0SMichael Strauss 	SRI(AFMT_INFOFRAME_CONTROL0, AFMT, id), \
35*18b4f1a0SMichael Strauss 	SRI(AFMT_VBI_PACKET_CONTROL, AFMT, id), \
36*18b4f1a0SMichael Strauss 	SRI(AFMT_AUDIO_PACKET_CONTROL, AFMT, id), \
37*18b4f1a0SMichael Strauss 	SRI(AFMT_AUDIO_PACKET_CONTROL2, AFMT, id), \
38*18b4f1a0SMichael Strauss 	SRI(AFMT_AUDIO_SRC_CONTROL, AFMT, id), \
39*18b4f1a0SMichael Strauss 	SRI(AFMT_60958_0, AFMT, id), \
40*18b4f1a0SMichael Strauss 	SRI(AFMT_60958_1, AFMT, id), \
41*18b4f1a0SMichael Strauss 	SRI(AFMT_60958_2, AFMT, id), \
42*18b4f1a0SMichael Strauss 	SRI(AFMT_MEM_PWR, AFMT, id)
43*18b4f1a0SMichael Strauss 
44*18b4f1a0SMichael Strauss struct dcn31_afmt_registers {
45*18b4f1a0SMichael Strauss 	uint32_t AFMT_INFOFRAME_CONTROL0;
46*18b4f1a0SMichael Strauss 	uint32_t AFMT_VBI_PACKET_CONTROL;
47*18b4f1a0SMichael Strauss 	uint32_t AFMT_AUDIO_PACKET_CONTROL;
48*18b4f1a0SMichael Strauss 	uint32_t AFMT_AUDIO_PACKET_CONTROL2;
49*18b4f1a0SMichael Strauss 	uint32_t AFMT_AUDIO_SRC_CONTROL;
50*18b4f1a0SMichael Strauss 	uint32_t AFMT_60958_0;
51*18b4f1a0SMichael Strauss 	uint32_t AFMT_60958_1;
52*18b4f1a0SMichael Strauss 	uint32_t AFMT_60958_2;
53*18b4f1a0SMichael Strauss 	uint32_t AFMT_MEM_PWR;
54*18b4f1a0SMichael Strauss };
55*18b4f1a0SMichael Strauss 
56*18b4f1a0SMichael Strauss #define DCN31_AFMT_MASK_SH_LIST(mask_sh)\
57*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_INFOFRAME_CONTROL0, AFMT_AUDIO_INFO_UPDATE, mask_sh),\
58*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_AUDIO_SRC_CONTROL, AFMT_AUDIO_SRC_SELECT, mask_sh),\
59*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL2, AFMT_AUDIO_CHANNEL_ENABLE, mask_sh),\
60*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL, AFMT_60958_CS_UPDATE, mask_sh),\
61*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL2, AFMT_AUDIO_LAYOUT_OVRD, mask_sh),\
62*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL2, AFMT_60958_OSF_OVRD, mask_sh),\
63*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_0, AFMT_60958_CS_CHANNEL_NUMBER_L, mask_sh),\
64*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_0, AFMT_60958_CS_CLOCK_ACCURACY, mask_sh),\
65*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_1, AFMT_60958_CS_CHANNEL_NUMBER_R, mask_sh),\
66*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_2, mask_sh),\
67*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_3, mask_sh),\
68*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_4, mask_sh),\
69*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_5, mask_sh),\
70*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_6, mask_sh),\
71*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_7, mask_sh),\
72*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL, AFMT_AUDIO_SAMPLE_SEND, mask_sh),\
73*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_MEM_PWR, AFMT_MEM_PWR_FORCE, mask_sh),\
74*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_MEM_PWR, AFMT_MEM_PWR_DIS, mask_sh),\
75*18b4f1a0SMichael Strauss 	SE_SF(AFMT0_AFMT_MEM_PWR, AFMT_MEM_PWR_STATE, mask_sh)
76*18b4f1a0SMichael Strauss 
77*18b4f1a0SMichael Strauss #define AFMT_DCN31_REG_FIELD_LIST(type) \
78*18b4f1a0SMichael Strauss 		type AFMT_AUDIO_INFO_UPDATE;\
79*18b4f1a0SMichael Strauss 		type AFMT_AUDIO_SRC_SELECT;\
80*18b4f1a0SMichael Strauss 		type AFMT_AUDIO_CHANNEL_ENABLE;\
81*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_UPDATE;\
82*18b4f1a0SMichael Strauss 		type AFMT_AUDIO_LAYOUT_OVRD;\
83*18b4f1a0SMichael Strauss 		type AFMT_60958_OSF_OVRD;\
84*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_L;\
85*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CLOCK_ACCURACY;\
86*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_R;\
87*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_2;\
88*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_3;\
89*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_4;\
90*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_5;\
91*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_6;\
92*18b4f1a0SMichael Strauss 		type AFMT_60958_CS_CHANNEL_NUMBER_7;\
93*18b4f1a0SMichael Strauss 		type AFMT_AUDIO_SAMPLE_SEND;\
94*18b4f1a0SMichael Strauss 		type AFMT_MEM_PWR_FORCE;\
95*18b4f1a0SMichael Strauss 		type AFMT_MEM_PWR_DIS;\
96*18b4f1a0SMichael Strauss 		type AFMT_MEM_PWR_STATE
97*18b4f1a0SMichael Strauss 
98*18b4f1a0SMichael Strauss struct dcn31_afmt_shift {
99*18b4f1a0SMichael Strauss 	AFMT_DCN31_REG_FIELD_LIST(uint8_t);
100*18b4f1a0SMichael Strauss };
101*18b4f1a0SMichael Strauss 
102*18b4f1a0SMichael Strauss struct dcn31_afmt_mask {
103*18b4f1a0SMichael Strauss 	AFMT_DCN31_REG_FIELD_LIST(uint32_t);
104*18b4f1a0SMichael Strauss };
105*18b4f1a0SMichael Strauss 
106*18b4f1a0SMichael Strauss struct dcn31_afmt {
107*18b4f1a0SMichael Strauss 	struct afmt base;
108*18b4f1a0SMichael Strauss 	const struct dcn31_afmt_registers *regs;
109*18b4f1a0SMichael Strauss 	const struct dcn31_afmt_shift *afmt_shift;
110*18b4f1a0SMichael Strauss 	const struct dcn31_afmt_mask *afmt_mask;
111*18b4f1a0SMichael Strauss };
112*18b4f1a0SMichael Strauss 
113*18b4f1a0SMichael Strauss void afmt31_poweron(
114*18b4f1a0SMichael Strauss 		struct afmt *afmt);
115*18b4f1a0SMichael Strauss 
116*18b4f1a0SMichael Strauss void afmt31_powerdown(
117*18b4f1a0SMichael Strauss 		struct afmt *afmt);
118*18b4f1a0SMichael Strauss 
119*18b4f1a0SMichael Strauss void afmt31_construct(struct dcn31_afmt *afmt31,
120*18b4f1a0SMichael Strauss 	struct dc_context *ctx,
121*18b4f1a0SMichael Strauss 	uint32_t inst,
122*18b4f1a0SMichael Strauss 	const struct dcn31_afmt_registers *afmt_regs,
123*18b4f1a0SMichael Strauss 	const struct dcn31_afmt_shift *afmt_shift,
124*18b4f1a0SMichael Strauss 	const struct dcn31_afmt_mask *afmt_mask);
125*18b4f1a0SMichael Strauss 
126*18b4f1a0SMichael Strauss #endif
127