xref: /linux/sound/x86/intel_hdmi_lpe_audio.h (revision da8648097497505d05d8cff6892351f99c029791)
1287599cfSJerome Anand /*
2287599cfSJerome Anand  *   intel_hdmi_lpe_audio.h - Intel HDMI LPE audio driver
3287599cfSJerome Anand  *
4287599cfSJerome Anand  *  Copyright (C) 2016 Intel Corp
5287599cfSJerome Anand  *  Authors:	Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
6287599cfSJerome Anand  *		Ramesh Babu K V <ramesh.babu@intel.com>
7287599cfSJerome Anand  *		Vaibhav Agarwal <vaibhav.agarwal@intel.com>
8287599cfSJerome Anand  *		Jerome Anand <jerome.anand@intel.com>
9287599cfSJerome Anand  *		Aravind Siddappaji <aravindx.siddappaji@intel.com>
10287599cfSJerome Anand  *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11287599cfSJerome Anand  *
12287599cfSJerome Anand  *  This program is free software; you can redistribute it and/or modify
13287599cfSJerome Anand  *  it under the terms of the GNU General Public License as published by
14287599cfSJerome Anand  *  the Free Software Foundation; version 2 of the License.
15287599cfSJerome Anand  *
16287599cfSJerome Anand  *  This program is distributed in the hope that it will be useful, but
17287599cfSJerome Anand  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18287599cfSJerome Anand  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19287599cfSJerome Anand  *  General Public License for more details.
20287599cfSJerome Anand  *
21287599cfSJerome Anand  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22287599cfSJerome Anand  */
23287599cfSJerome Anand #ifndef __INTEL_HDMI_LPE_AUDIO_H
24287599cfSJerome Anand #define __INTEL_HDMI_LPE_AUDIO_H
25287599cfSJerome Anand 
26287599cfSJerome Anand #include <linux/types.h>
27287599cfSJerome Anand #include <sound/initval.h>
28287599cfSJerome Anand #include <linux/version.h>
29287599cfSJerome Anand #include <linux/pm_runtime.h>
30*da864809STakashi Iwai #include <linux/platform_device.h>
31287599cfSJerome Anand #include <sound/asoundef.h>
32287599cfSJerome Anand #include <sound/control.h>
33287599cfSJerome Anand #include <sound/pcm.h>
34287599cfSJerome Anand 
35964ca808SPierre-Louis Bossart #define AUD_CONFIG_VALID_BIT			(1<<9)
36964ca808SPierre-Louis Bossart #define AUD_CONFIG_DP_MODE			(1<<15)
37964ca808SPierre-Louis Bossart #define AUD_CONFIG_BLOCK_BIT			(1<<7)
38964ca808SPierre-Louis Bossart 
39287599cfSJerome Anand #define HMDI_LPE_AUDIO_DRIVER_NAME		"intel-hdmi-lpe-audio"
40287599cfSJerome Anand #define HAD_MAX_DEVICES		1
41287599cfSJerome Anand #define HAD_MIN_CHANNEL		2
42287599cfSJerome Anand #define HAD_MAX_CHANNEL		8
43287599cfSJerome Anand #define HAD_NUM_OF_RING_BUFS	4
44287599cfSJerome Anand 
45287599cfSJerome Anand /* Assume 192KHz, 8channel, 25msec period */
46287599cfSJerome Anand #define HAD_MAX_BUFFER		(600*1024)
47287599cfSJerome Anand #define HAD_MIN_BUFFER		(32*1024)
48287599cfSJerome Anand #define HAD_MAX_PERIODS		4
49287599cfSJerome Anand #define HAD_MIN_PERIODS		4
50287599cfSJerome Anand #define HAD_MAX_PERIOD_BYTES	(HAD_MAX_BUFFER/HAD_MIN_PERIODS)
51287599cfSJerome Anand #define HAD_MIN_PERIOD_BYTES	256
52287599cfSJerome Anand #define HAD_FIFO_SIZE		0 /* fifo not being used */
53287599cfSJerome Anand #define MAX_SPEAKERS		8
54287599cfSJerome Anand 
55287599cfSJerome Anand #define AUD_SAMPLE_RATE_32	32000
56287599cfSJerome Anand #define AUD_SAMPLE_RATE_44_1	44100
57287599cfSJerome Anand #define AUD_SAMPLE_RATE_48	48000
58287599cfSJerome Anand #define AUD_SAMPLE_RATE_88_2	88200
59287599cfSJerome Anand #define AUD_SAMPLE_RATE_96	96000
60287599cfSJerome Anand #define AUD_SAMPLE_RATE_176_4	176400
61287599cfSJerome Anand #define AUD_SAMPLE_RATE_192	192000
62287599cfSJerome Anand 
63287599cfSJerome Anand #define HAD_MIN_RATE		AUD_SAMPLE_RATE_32
64287599cfSJerome Anand #define HAD_MAX_RATE		AUD_SAMPLE_RATE_192
65287599cfSJerome Anand 
66287599cfSJerome Anand #define DIS_SAMPLE_RATE_25_2	25200
67287599cfSJerome Anand #define DIS_SAMPLE_RATE_27	27000
68287599cfSJerome Anand #define DIS_SAMPLE_RATE_54	54000
69287599cfSJerome Anand #define DIS_SAMPLE_RATE_74_25	74250
70287599cfSJerome Anand #define DIS_SAMPLE_RATE_148_5	148500
71287599cfSJerome Anand #define HAD_REG_WIDTH		0x08
72287599cfSJerome Anand #define HAD_MAX_HW_BUFS		0x04
73287599cfSJerome Anand #define HAD_MAX_DIP_WORDS		16
74287599cfSJerome Anand #define INTEL_HAD		"IntelHdmiLpeAudio"
75287599cfSJerome Anand 
76964ca808SPierre-Louis Bossart /* DP Link Rates */
77964ca808SPierre-Louis Bossart #define DP_2_7_GHZ			270000
78964ca808SPierre-Louis Bossart #define DP_1_62_GHZ			162000
79964ca808SPierre-Louis Bossart 
80964ca808SPierre-Louis Bossart /* Maud Values */
81964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_32_DP_2_7_MAUD_VAL		1988
82964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_44_1_DP_2_7_MAUD_VAL		2740
83964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_48_DP_2_7_MAUD_VAL		2982
84964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_88_2_DP_2_7_MAUD_VAL		5480
85964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_96_DP_2_7_MAUD_VAL		5965
86964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_176_4_DP_2_7_MAUD_VAL		10961
87964ca808SPierre-Louis Bossart #define HAD_MAX_RATE_DP_2_7_MAUD_VAL			11930
88964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_32_DP_1_62_MAUD_VAL		3314
89964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_44_1_DP_1_62_MAUD_VAL		4567
90964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_48_DP_1_62_MAUD_VAL		4971
91964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_88_2_DP_1_62_MAUD_VAL		9134
92964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_96_DP_1_62_MAUD_VAL		9942
93964ca808SPierre-Louis Bossart #define AUD_SAMPLE_RATE_176_4_DP_1_62_MAUD_VAL		18268
94964ca808SPierre-Louis Bossart #define HAD_MAX_RATE_DP_1_62_MAUD_VAL			19884
95964ca808SPierre-Louis Bossart 
96964ca808SPierre-Louis Bossart /* Naud Value */
97964ca808SPierre-Louis Bossart #define DP_NAUD_VAL					32768
98964ca808SPierre-Louis Bossart 
99287599cfSJerome Anand /* _AUD_CONFIG register MASK */
100287599cfSJerome Anand #define AUD_CONFIG_MASK_UNDERRUN	0xC0000000
101287599cfSJerome Anand #define AUD_CONFIG_MASK_SRDBG		0x00000002
102287599cfSJerome Anand #define AUD_CONFIG_MASK_FUNCRST		0x00000001
103287599cfSJerome Anand 
104287599cfSJerome Anand #define MAX_CNT			0xFF
105287599cfSJerome Anand #define HAD_SUSPEND_DELAY	1000
106287599cfSJerome Anand 
107287599cfSJerome Anand #define OTM_HDMI_ELD_SIZE 128
108287599cfSJerome Anand 
109287599cfSJerome Anand union otm_hdmi_eld_t {
110287599cfSJerome Anand 	unsigned char eld_data[OTM_HDMI_ELD_SIZE];
111287599cfSJerome Anand 	struct {
112287599cfSJerome Anand 		/* Byte[0] = ELD Version Number */
113287599cfSJerome Anand 		union {
114287599cfSJerome Anand 			unsigned char   byte0;
115287599cfSJerome Anand 			struct {
116287599cfSJerome Anand 				unsigned char reserved:3; /* Reserf */
117287599cfSJerome Anand 				unsigned char eld_ver:5; /* ELD Version Number */
118287599cfSJerome Anand 				/* 00000b - reserved
119287599cfSJerome Anand 				 * 00001b - first rev, obsoleted
120287599cfSJerome Anand 				 * 00010b - version 2, supporting CEA version
121287599cfSJerome Anand 				 *			861D or below
122287599cfSJerome Anand 				 * 00011b:11111b - reserved
123287599cfSJerome Anand 				 * for future
124287599cfSJerome Anand 				 */
125287599cfSJerome Anand 			};
126287599cfSJerome Anand 		};
127287599cfSJerome Anand 
128287599cfSJerome Anand 		/* Byte[1] = Vendor Version Field */
129287599cfSJerome Anand 		union {
130287599cfSJerome Anand 			unsigned char vendor_version;
131287599cfSJerome Anand 			struct {
132287599cfSJerome Anand 				unsigned char reserved1:3;
133287599cfSJerome Anand 				unsigned char veld_ver:5; /* Version number of the ELD
134287599cfSJerome Anand 						     * extension. This value is
135287599cfSJerome Anand 						     * provisioned and unique to
136287599cfSJerome Anand 						     * each vendor.
137287599cfSJerome Anand 						     */
138287599cfSJerome Anand 			};
139287599cfSJerome Anand 		};
140287599cfSJerome Anand 
141287599cfSJerome Anand 		/* Byte[2] = Baseline Length field */
142287599cfSJerome Anand 		unsigned char baseline_eld_length; /* Length of the Baseline structure
143287599cfSJerome Anand 					      *	divided by Four.
144287599cfSJerome Anand 					      */
145287599cfSJerome Anand 
146287599cfSJerome Anand 		/* Byte [3] = Reserved for future use */
147287599cfSJerome Anand 		unsigned char byte3;
148287599cfSJerome Anand 
149287599cfSJerome Anand 		/* Starting of the BaseLine EELD structure
150287599cfSJerome Anand 		 * Byte[4] = Monitor Name Length
151287599cfSJerome Anand 		 */
152287599cfSJerome Anand 		union {
153287599cfSJerome Anand 			unsigned char byte4;
154287599cfSJerome Anand 			struct {
155287599cfSJerome Anand 				unsigned char mnl:5;
156287599cfSJerome Anand 				unsigned char cea_edid_rev_id:3;
157287599cfSJerome Anand 			};
158287599cfSJerome Anand 		};
159287599cfSJerome Anand 
160287599cfSJerome Anand 		/* Byte[5] = Capabilities */
161287599cfSJerome Anand 		union {
162287599cfSJerome Anand 			unsigned char capabilities;
163287599cfSJerome Anand 			struct {
164287599cfSJerome Anand 				unsigned char hdcp:1; /* HDCP support */
165287599cfSJerome Anand 				unsigned char ai_support:1;   /* AI support */
166287599cfSJerome Anand 				unsigned char connection_type:2; /* Connection type
167287599cfSJerome Anand 							    * 00 - HDMI
168287599cfSJerome Anand 							    * 01 - DP
169287599cfSJerome Anand 							    * 10 -11  Reserved
170287599cfSJerome Anand 							    * for future
171287599cfSJerome Anand 							    * connection types
172287599cfSJerome Anand 							    */
173287599cfSJerome Anand 				unsigned char sadc:4; /* Indicates number of 3 bytes
174287599cfSJerome Anand 						 * Short Audio Descriptors.
175287599cfSJerome Anand 						 */
176287599cfSJerome Anand 			};
177287599cfSJerome Anand 		};
178287599cfSJerome Anand 
179287599cfSJerome Anand 		/* Byte[6] = Audio Synch Delay */
180287599cfSJerome Anand 		unsigned char audio_synch_delay; /* Amount of time reported by the
181287599cfSJerome Anand 					    * sink that the video trails audio
182287599cfSJerome Anand 					    * in milliseconds.
183287599cfSJerome Anand 					    */
184287599cfSJerome Anand 
185287599cfSJerome Anand 		/* Byte[7] = Speaker Allocation Block */
186287599cfSJerome Anand 		union {
187287599cfSJerome Anand 			unsigned char speaker_allocation_block;
188287599cfSJerome Anand 			struct {
189287599cfSJerome Anand 				unsigned char flr:1; /*Front Left and Right channels*/
190287599cfSJerome Anand 				unsigned char lfe:1; /*Low Frequency Effect channel*/
191287599cfSJerome Anand 				unsigned char fc:1;  /*Center transmission channel*/
192287599cfSJerome Anand 				unsigned char rlr:1; /*Rear Left and Right channels*/
193287599cfSJerome Anand 				unsigned char rc:1; /*Rear Center channel*/
194287599cfSJerome Anand 				unsigned char flrc:1; /*Front left and Right of Center
195287599cfSJerome Anand 						 *transmission channels
196287599cfSJerome Anand 						 */
197287599cfSJerome Anand 				unsigned char rlrc:1; /*Rear left and Right of Center
198287599cfSJerome Anand 						 *transmission channels
199287599cfSJerome Anand 						 */
200287599cfSJerome Anand 				unsigned char reserved3:1; /* Reserved */
201287599cfSJerome Anand 			};
202287599cfSJerome Anand 		};
203287599cfSJerome Anand 
204287599cfSJerome Anand 		/* Byte[8 - 15] - 8 Byte port identification value */
205287599cfSJerome Anand 		unsigned char port_id_value[8];
206287599cfSJerome Anand 
207287599cfSJerome Anand 		/* Byte[16 - 17] - 2 Byte Manufacturer ID */
208287599cfSJerome Anand 		unsigned char manufacturer_id[2];
209287599cfSJerome Anand 
210287599cfSJerome Anand 		/* Byte[18 - 19] - 2 Byte Product ID */
211287599cfSJerome Anand 		unsigned char product_id[2];
212287599cfSJerome Anand 
213287599cfSJerome Anand 		/* Byte [20-83] - 64 Bytes of BaseLine Data */
214287599cfSJerome Anand 		unsigned char mn_sand_sads[64]; /* This will include
215287599cfSJerome Anand 					   * - ASCII string of Monitor name
216287599cfSJerome Anand 					   * - List of 3 byte SADs
217287599cfSJerome Anand 					   * - Zero padding
218287599cfSJerome Anand 					   */
219287599cfSJerome Anand 
220287599cfSJerome Anand 		/* Vendor ELD Block should continue here!
221287599cfSJerome Anand 		 * No Vendor ELD block defined as of now.
222287599cfSJerome Anand 		 */
223287599cfSJerome Anand 	} __packed;
224287599cfSJerome Anand };
225287599cfSJerome Anand 
226287599cfSJerome Anand /**
227287599cfSJerome Anand  * enum had_status - Audio stream states
228287599cfSJerome Anand  *
229287599cfSJerome Anand  * @STREAM_INIT: Stream initialized
230287599cfSJerome Anand  * @STREAM_RUNNING: Stream running
231287599cfSJerome Anand  * @STREAM_PAUSED: Stream paused
232287599cfSJerome Anand  * @STREAM_DROPPED: Stream dropped
233287599cfSJerome Anand  */
234287599cfSJerome Anand enum had_stream_status {
235287599cfSJerome Anand 	STREAM_INIT = 0,
236287599cfSJerome Anand 	STREAM_RUNNING = 1,
237287599cfSJerome Anand 	STREAM_PAUSED = 2,
238287599cfSJerome Anand 	STREAM_DROPPED = 3
239287599cfSJerome Anand };
240287599cfSJerome Anand 
241287599cfSJerome Anand /**
242287599cfSJerome Anand  * enum had_status_stream - HAD stream states
243287599cfSJerome Anand  */
244287599cfSJerome Anand enum had_status_stream {
245287599cfSJerome Anand 	HAD_INIT = 0,
246287599cfSJerome Anand 	HAD_RUNNING_STREAM,
247287599cfSJerome Anand };
248287599cfSJerome Anand 
249287599cfSJerome Anand enum had_drv_status {
250287599cfSJerome Anand 	HAD_DRV_CONNECTED,
251287599cfSJerome Anand 	HAD_DRV_RUNNING,
252287599cfSJerome Anand 	HAD_DRV_DISCONNECTED,
253287599cfSJerome Anand 	HAD_DRV_SUSPENDED,
254287599cfSJerome Anand 	HAD_DRV_ERR,
255287599cfSJerome Anand };
256287599cfSJerome Anand 
257287599cfSJerome Anand /* enum intel_had_aud_buf_type - HDMI controller ring buffer types */
258287599cfSJerome Anand enum intel_had_aud_buf_type {
259287599cfSJerome Anand 	HAD_BUF_TYPE_A = 0,
260287599cfSJerome Anand 	HAD_BUF_TYPE_B = 1,
261287599cfSJerome Anand 	HAD_BUF_TYPE_C = 2,
262287599cfSJerome Anand 	HAD_BUF_TYPE_D = 3,
263287599cfSJerome Anand };
264287599cfSJerome Anand 
265287599cfSJerome Anand enum num_aud_ch {
266287599cfSJerome Anand 	CH_STEREO = 0,
267287599cfSJerome Anand 	CH_THREE_FOUR = 1,
268287599cfSJerome Anand 	CH_FIVE_SIX = 2,
269287599cfSJerome Anand 	CH_SEVEN_EIGHT = 3
270287599cfSJerome Anand };
271287599cfSJerome Anand 
272287599cfSJerome Anand /* HDMI Controller register offsets - audio domain common */
273287599cfSJerome Anand /* Base address for below regs = 0x65000 */
274287599cfSJerome Anand enum hdmi_ctrl_reg_offset_common {
275287599cfSJerome Anand 	AUDIO_HDMI_CONFIG_A	= 0x000,
276287599cfSJerome Anand 	AUDIO_HDMI_CONFIG_B = 0x800,
277287599cfSJerome Anand 	AUDIO_HDMI_CONFIG_C = 0x900,
278287599cfSJerome Anand };
279287599cfSJerome Anand /* HDMI controller register offsets */
280287599cfSJerome Anand enum hdmi_ctrl_reg_offset_v1 {
281287599cfSJerome Anand 	AUD_CONFIG		= 0x0,
282287599cfSJerome Anand 	AUD_CH_STATUS_0		= 0x08,
283287599cfSJerome Anand 	AUD_CH_STATUS_1		= 0x0C,
284287599cfSJerome Anand 	AUD_HDMI_CTS		= 0x10,
285287599cfSJerome Anand 	AUD_N_ENABLE		= 0x14,
286287599cfSJerome Anand 	AUD_SAMPLE_RATE		= 0x18,
287287599cfSJerome Anand 	AUD_BUF_CONFIG		= 0x20,
288287599cfSJerome Anand 	AUD_BUF_CH_SWAP		= 0x24,
289287599cfSJerome Anand 	AUD_BUF_A_ADDR		= 0x40,
290287599cfSJerome Anand 	AUD_BUF_A_LENGTH	= 0x44,
291287599cfSJerome Anand 	AUD_BUF_B_ADDR		= 0x48,
292287599cfSJerome Anand 	AUD_BUF_B_LENGTH	= 0x4c,
293287599cfSJerome Anand 	AUD_BUF_C_ADDR		= 0x50,
294287599cfSJerome Anand 	AUD_BUF_C_LENGTH	= 0x54,
295287599cfSJerome Anand 	AUD_BUF_D_ADDR		= 0x58,
296287599cfSJerome Anand 	AUD_BUF_D_LENGTH	= 0x5c,
297287599cfSJerome Anand 	AUD_CNTL_ST		= 0x60,
298287599cfSJerome Anand 	AUD_HDMI_STATUS		= 0x68,
299287599cfSJerome Anand 	AUD_HDMIW_INFOFR	= 0x114,
300287599cfSJerome Anand };
301287599cfSJerome Anand 
302287599cfSJerome Anand /*
303287599cfSJerome Anand  * Delta changes in HDMI controller register offsets
304287599cfSJerome Anand  * compare to v1 version
305287599cfSJerome Anand  */
306287599cfSJerome Anand 
307287599cfSJerome Anand enum hdmi_ctrl_reg_offset_v2 {
308287599cfSJerome Anand 	AUD_HDMI_STATUS_v2	= 0x64,
309287599cfSJerome Anand 	AUD_HDMIW_INFOFR_v2	= 0x68,
310287599cfSJerome Anand };
311287599cfSJerome Anand 
312287599cfSJerome Anand /*
313287599cfSJerome Anand  *	CEA speaker placement:
314287599cfSJerome Anand  *
315287599cfSJerome Anand  *	FL  FLC   FC   FRC   FR
316287599cfSJerome Anand  *
317287599cfSJerome Anand  *						LFE
318287599cfSJerome Anand  *
319287599cfSJerome Anand  *	RL  RLC   RC   RRC   RR
320287599cfSJerome Anand  *
321287599cfSJerome Anand  *	The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M
322287599cfSJerome Anand  *	corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is
323287599cfSJerome Anand  *	swapped to CEA LFE/FC.
324287599cfSJerome Anand  */
325287599cfSJerome Anand enum cea_speaker_placement {
326287599cfSJerome Anand 	FL  = (1 <<  0),        /* Front Left           */
327287599cfSJerome Anand 	FC  = (1 <<  1),        /* Front Center         */
328287599cfSJerome Anand 	FR  = (1 <<  2),        /* Front Right          */
329287599cfSJerome Anand 	FLC = (1 <<  3),        /* Front Left Center    */
330287599cfSJerome Anand 	FRC = (1 <<  4),        /* Front Right Center   */
331287599cfSJerome Anand 	RL  = (1 <<  5),        /* Rear Left            */
332287599cfSJerome Anand 	RC  = (1 <<  6),        /* Rear Center          */
333287599cfSJerome Anand 	RR  = (1 <<  7),        /* Rear Right           */
334287599cfSJerome Anand 	RLC = (1 <<  8),        /* Rear Left Center     */
335287599cfSJerome Anand 	RRC = (1 <<  9),        /* Rear Right Center    */
336287599cfSJerome Anand 	LFE = (1 << 10),        /* Low Frequency Effect */
337287599cfSJerome Anand };
338287599cfSJerome Anand 
339287599cfSJerome Anand struct cea_channel_speaker_allocation {
340287599cfSJerome Anand 	int ca_index;
341287599cfSJerome Anand 	int speakers[8];
342287599cfSJerome Anand 
343287599cfSJerome Anand 	/* derived values, just for convenience */
344287599cfSJerome Anand 	int channels;
345287599cfSJerome Anand 	int spk_mask;
346287599cfSJerome Anand };
347287599cfSJerome Anand 
348287599cfSJerome Anand struct channel_map_table {
349287599cfSJerome Anand 	unsigned char map;              /* ALSA API channel map position */
350287599cfSJerome Anand 	unsigned char cea_slot;         /* CEA slot value */
351287599cfSJerome Anand 	int spk_mask;                   /* speaker position bit mask */
352287599cfSJerome Anand };
353287599cfSJerome Anand 
354287599cfSJerome Anand /**
355287599cfSJerome Anand  * union aud_cfg - Audio configuration
356287599cfSJerome Anand  *
357287599cfSJerome Anand  * @cfg_regx: individual register bits
358287599cfSJerome Anand  * @cfg_regval: full register value
359287599cfSJerome Anand  *
360287599cfSJerome Anand  */
361287599cfSJerome Anand union aud_cfg {
362287599cfSJerome Anand 	struct {
363287599cfSJerome Anand 		u32 aud_en:1;
364287599cfSJerome Anand 		u32 layout:1;
365287599cfSJerome Anand 		u32 fmt:2;
366287599cfSJerome Anand 		u32 num_ch:3;
367287599cfSJerome Anand 		u32 set:1;
368287599cfSJerome Anand 		u32 flat:1;
369287599cfSJerome Anand 		u32 val_bit:1;
370287599cfSJerome Anand 		u32 user_bit:1;
371287599cfSJerome Anand 		u32 underrun:1;
372287599cfSJerome Anand 		u32 packet_mode:1;
373287599cfSJerome Anand 		u32 left_align:1;
374287599cfSJerome Anand 		u32 bogus_sample:1;
375287599cfSJerome Anand 		u32 dp_modei:1;
376287599cfSJerome Anand 		u32 rsvd:16;
377287599cfSJerome Anand 	} cfg_regx_v2;
378287599cfSJerome Anand 	u32 cfg_regval;
379287599cfSJerome Anand };
380287599cfSJerome Anand 
381287599cfSJerome Anand /**
382287599cfSJerome Anand  * union aud_ch_status_0 - Audio Channel Status 0 Attributes
383287599cfSJerome Anand  *
384287599cfSJerome Anand  * @status_0_regx:individual register bits
385287599cfSJerome Anand  * @status_0_regval:full register value
386287599cfSJerome Anand  *
387287599cfSJerome Anand  */
388287599cfSJerome Anand union aud_ch_status_0 {
389287599cfSJerome Anand 	struct {
390287599cfSJerome Anand 		u32 ch_status:1;
391287599cfSJerome Anand 		u32 lpcm_id:1;
392287599cfSJerome Anand 		u32 cp_info:1;
393287599cfSJerome Anand 		u32 format:3;
394287599cfSJerome Anand 		u32 mode:2;
395287599cfSJerome Anand 		u32 ctg_code:8;
396287599cfSJerome Anand 		u32 src_num:4;
397287599cfSJerome Anand 		u32 ch_num:4;
398287599cfSJerome Anand 		u32 samp_freq:4;
399287599cfSJerome Anand 		u32 clk_acc:2;
400287599cfSJerome Anand 		u32 rsvd:2;
401287599cfSJerome Anand 	} status_0_regx;
402287599cfSJerome Anand 	u32 status_0_regval;
403287599cfSJerome Anand };
404287599cfSJerome Anand 
405287599cfSJerome Anand /**
406287599cfSJerome Anand  * union aud_ch_status_1 - Audio Channel Status 1 Attributes
407287599cfSJerome Anand  *
408287599cfSJerome Anand  * @status_1_regx: individual register bits
409287599cfSJerome Anand  * @status_1_regval: full register value
410287599cfSJerome Anand  *
411287599cfSJerome Anand  */
412287599cfSJerome Anand union aud_ch_status_1 {
413287599cfSJerome Anand 	struct {
414287599cfSJerome Anand 		u32 max_wrd_len:1;
415287599cfSJerome Anand 		u32 wrd_len:3;
416287599cfSJerome Anand 		u32 rsvd:28;
417287599cfSJerome Anand 		} status_1_regx;
418287599cfSJerome Anand 	u32 status_1_regval;
419287599cfSJerome Anand };
420287599cfSJerome Anand 
421287599cfSJerome Anand /**
422287599cfSJerome Anand  * union aud_hdmi_cts - CTS register
423287599cfSJerome Anand  *
424287599cfSJerome Anand  * @cts_regx: individual register bits
425287599cfSJerome Anand  * @cts_regval: full register value
426287599cfSJerome Anand  *
427287599cfSJerome Anand  */
428287599cfSJerome Anand union aud_hdmi_cts {
429287599cfSJerome Anand 	struct {
430287599cfSJerome Anand 		u32 cts_val:24;
431287599cfSJerome Anand 		u32 en_cts_prog:1;
432287599cfSJerome Anand 		u32 rsvd:7;
433287599cfSJerome Anand 	} cts_regx_v2;
434287599cfSJerome Anand 	u32 cts_regval;
435287599cfSJerome Anand };
436287599cfSJerome Anand 
437287599cfSJerome Anand /**
438287599cfSJerome Anand  * union aud_hdmi_n_enable - N register
439287599cfSJerome Anand  *
440287599cfSJerome Anand  * @n_regx: individual register bits
441287599cfSJerome Anand  * @n_regval: full register value
442287599cfSJerome Anand  *
443287599cfSJerome Anand  */
444287599cfSJerome Anand union aud_hdmi_n_enable {
445287599cfSJerome Anand 	struct {
446287599cfSJerome Anand 		u32 n_val:24;
447287599cfSJerome Anand 		u32 en_n_prog:1;
448287599cfSJerome Anand 		u32 rsvd:7;
449287599cfSJerome Anand 	} n_regx_v2;
450287599cfSJerome Anand 	u32 n_regval;
451287599cfSJerome Anand };
452287599cfSJerome Anand 
453287599cfSJerome Anand /**
454287599cfSJerome Anand  * union aud_buf_config -  Audio Buffer configurations
455287599cfSJerome Anand  *
456287599cfSJerome Anand  * @buf_cfg_regx: individual register bits
457287599cfSJerome Anand  * @buf_cfgval: full register value
458287599cfSJerome Anand  *
459287599cfSJerome Anand  */
460287599cfSJerome Anand union aud_buf_config {
461287599cfSJerome Anand 	struct {
462287599cfSJerome Anand 		u32 audio_fifo_watermark:8;
463287599cfSJerome Anand 		u32 dma_fifo_watermark:3;
464287599cfSJerome Anand 		u32 rsvd0:5;
465287599cfSJerome Anand 		u32 aud_delay:8;
466287599cfSJerome Anand 		u32 rsvd1:8;
467287599cfSJerome Anand 	} buf_cfg_regx_v2;
468287599cfSJerome Anand 	u32 buf_cfgval;
469287599cfSJerome Anand };
470287599cfSJerome Anand 
471287599cfSJerome Anand /**
472287599cfSJerome Anand  * union aud_buf_ch_swap - Audio Sample Swapping offset
473287599cfSJerome Anand  *
474287599cfSJerome Anand  * @buf_ch_swap_regx: individual register bits
475287599cfSJerome Anand  * @buf_ch_swap_val: full register value
476287599cfSJerome Anand  *
477287599cfSJerome Anand  */
478287599cfSJerome Anand union aud_buf_ch_swap {
479287599cfSJerome Anand 	struct {
480287599cfSJerome Anand 		u32 first_0:3;
481287599cfSJerome Anand 		u32 second_0:3;
482287599cfSJerome Anand 		u32 first_1:3;
483287599cfSJerome Anand 		u32 second_1:3;
484287599cfSJerome Anand 		u32 first_2:3;
485287599cfSJerome Anand 		u32 second_2:3;
486287599cfSJerome Anand 		u32 first_3:3;
487287599cfSJerome Anand 		u32 second_3:3;
488287599cfSJerome Anand 		u32 rsvd:8;
489287599cfSJerome Anand 	} buf_ch_swap_regx;
490287599cfSJerome Anand 	u32 buf_ch_swap_val;
491287599cfSJerome Anand };
492287599cfSJerome Anand 
493287599cfSJerome Anand /**
494287599cfSJerome Anand  * union aud_buf_addr - Address for Audio Buffer
495287599cfSJerome Anand  *
496287599cfSJerome Anand  * @buf_addr_regx: individual register bits
497287599cfSJerome Anand  * @buf_addr_val: full register value
498287599cfSJerome Anand  *
499287599cfSJerome Anand  */
500287599cfSJerome Anand union aud_buf_addr {
501287599cfSJerome Anand 	struct {
502287599cfSJerome Anand 		u32 valid:1;
503287599cfSJerome Anand 		u32 intr_en:1;
504287599cfSJerome Anand 		u32 rsvd:4;
505287599cfSJerome Anand 		u32 addr:26;
506287599cfSJerome Anand 	} buf_addr_regx;
507287599cfSJerome Anand 	u32 buf_addr_val;
508287599cfSJerome Anand };
509287599cfSJerome Anand 
510287599cfSJerome Anand /**
511287599cfSJerome Anand  * union aud_buf_len - Length of Audio Buffer
512287599cfSJerome Anand  *
513287599cfSJerome Anand  * @buf_len_regx: individual register bits
514287599cfSJerome Anand  * @buf_len_val: full register value
515287599cfSJerome Anand  *
516287599cfSJerome Anand  */
517287599cfSJerome Anand union aud_buf_len {
518287599cfSJerome Anand 	struct {
519287599cfSJerome Anand 		u32 buf_len:20;
520287599cfSJerome Anand 		u32 rsvd:12;
521287599cfSJerome Anand 	} buf_len_regx;
522287599cfSJerome Anand 	u32 buf_len_val;
523287599cfSJerome Anand };
524287599cfSJerome Anand 
525287599cfSJerome Anand /**
526287599cfSJerome Anand  * union aud_ctrl_st - Audio Control State Register offset
527287599cfSJerome Anand  *
528287599cfSJerome Anand  * @ctrl_regx: individual register bits
529287599cfSJerome Anand  * @ctrl_val: full register value
530287599cfSJerome Anand  *
531287599cfSJerome Anand  */
532287599cfSJerome Anand union aud_ctrl_st {
533287599cfSJerome Anand 	struct {
534287599cfSJerome Anand 		u32 ram_addr:4;
535287599cfSJerome Anand 		u32 eld_ack:1;
536287599cfSJerome Anand 		u32 eld_addr:4;
537287599cfSJerome Anand 		u32 eld_buf_size:5;
538287599cfSJerome Anand 		u32 eld_valid:1;
539287599cfSJerome Anand 		u32 cp_ready:1;
540287599cfSJerome Anand 		u32 dip_freq:2;
541287599cfSJerome Anand 		u32 dip_idx:3;
542287599cfSJerome Anand 		u32 dip_en_sta:4;
543287599cfSJerome Anand 		u32 rsvd:7;
544287599cfSJerome Anand 	} ctrl_regx;
545287599cfSJerome Anand 	u32 ctrl_val;
546287599cfSJerome Anand };
547287599cfSJerome Anand 
548287599cfSJerome Anand /**
549287599cfSJerome Anand  * union aud_info_frame1 - Audio HDMI Widget Data Island Packet offset
550287599cfSJerome Anand  *
551287599cfSJerome Anand  * @fr1_regx: individual register bits
552287599cfSJerome Anand  * @fr1_val: full register value
553287599cfSJerome Anand  *
554287599cfSJerome Anand  */
555287599cfSJerome Anand union aud_info_frame1 {
556287599cfSJerome Anand 	struct {
557287599cfSJerome Anand 		u32 pkt_type:8;
558287599cfSJerome Anand 		u32 ver_num:8;
559287599cfSJerome Anand 		u32 len:5;
560287599cfSJerome Anand 		u32 rsvd:11;
561287599cfSJerome Anand 	} fr1_regx;
562287599cfSJerome Anand 	u32 fr1_val;
563287599cfSJerome Anand };
564287599cfSJerome Anand 
565287599cfSJerome Anand /**
566287599cfSJerome Anand  * union aud_info_frame2 - DIP frame 2
567287599cfSJerome Anand  *
568287599cfSJerome Anand  * @fr2_regx: individual register bits
569287599cfSJerome Anand  * @fr2_val: full register value
570287599cfSJerome Anand  *
571287599cfSJerome Anand  */
572287599cfSJerome Anand union aud_info_frame2 {
573287599cfSJerome Anand 	struct {
574287599cfSJerome Anand 		u32 chksum:8;
575287599cfSJerome Anand 		u32 chnl_cnt:3;
576287599cfSJerome Anand 		u32 rsvd0:1;
577287599cfSJerome Anand 		u32 coding_type:4;
578287599cfSJerome Anand 		u32 smpl_size:2;
579287599cfSJerome Anand 		u32 smpl_freq:3;
580287599cfSJerome Anand 		u32 rsvd1:3;
581287599cfSJerome Anand 		u32 format:8;
582287599cfSJerome Anand 	} fr2_regx;
583287599cfSJerome Anand 	u32 fr2_val;
584287599cfSJerome Anand };
585287599cfSJerome Anand 
586287599cfSJerome Anand /**
587287599cfSJerome Anand  * union aud_info_frame3 - DIP frame 3
588287599cfSJerome Anand  *
589287599cfSJerome Anand  * @fr3_regx: individual register bits
590287599cfSJerome Anand  * @fr3_val: full register value
591287599cfSJerome Anand  *
592287599cfSJerome Anand  */
593287599cfSJerome Anand union aud_info_frame3 {
594287599cfSJerome Anand 	struct {
595287599cfSJerome Anand 		u32 chnl_alloc:8;
596287599cfSJerome Anand 		u32 rsvd0:3;
597287599cfSJerome Anand 		u32 lsv:4;
598287599cfSJerome Anand 		u32 dm_inh:1;
599287599cfSJerome Anand 		u32 rsvd1:16;
600287599cfSJerome Anand 	} fr3_regx;
601287599cfSJerome Anand 	u32 fr3_val;
602287599cfSJerome Anand };
603287599cfSJerome Anand 
604287599cfSJerome Anand enum hdmi_connector_status {
605287599cfSJerome Anand 	hdmi_connector_status_connected = 1,
606287599cfSJerome Anand 	hdmi_connector_status_disconnected = 2,
607287599cfSJerome Anand 	hdmi_connector_status_unknown = 3,
608287599cfSJerome Anand };
609287599cfSJerome Anand 
610287599cfSJerome Anand #define HDMI_AUDIO_UNDERRUN     (1UL<<31)
611287599cfSJerome Anand #define HDMI_AUDIO_BUFFER_DONE  (1UL<<29)
612287599cfSJerome Anand 
613287599cfSJerome Anand 
614287599cfSJerome Anand #define PORT_ENABLE			(1 << 31)
615287599cfSJerome Anand #define SDVO_AUDIO_ENABLE	(1 << 6)
616287599cfSJerome Anand 
617287599cfSJerome Anand enum had_caps_list {
618287599cfSJerome Anand 	HAD_GET_ELD = 1,
619287599cfSJerome Anand 	HAD_GET_DISPLAY_RATE,
620964ca808SPierre-Louis Bossart 	HAD_GET_DP_OUTPUT,
621964ca808SPierre-Louis Bossart 	HAD_GET_LINK_RATE,
622287599cfSJerome Anand 	HAD_SET_ENABLE_AUDIO,
623287599cfSJerome Anand 	HAD_SET_DISABLE_AUDIO,
624287599cfSJerome Anand 	HAD_SET_ENABLE_AUDIO_INT,
625287599cfSJerome Anand 	HAD_SET_DISABLE_AUDIO_INT,
626287599cfSJerome Anand };
627287599cfSJerome Anand 
628287599cfSJerome Anand enum had_event_type {
629287599cfSJerome Anand 	HAD_EVENT_HOT_PLUG = 1,
630287599cfSJerome Anand 	HAD_EVENT_HOT_UNPLUG,
631287599cfSJerome Anand 	HAD_EVENT_MODE_CHANGING,
632287599cfSJerome Anand 	HAD_EVENT_AUDIO_BUFFER_DONE,
633287599cfSJerome Anand 	HAD_EVENT_AUDIO_BUFFER_UNDERRUN,
634287599cfSJerome Anand 	HAD_EVENT_QUERY_IS_AUDIO_BUSY,
635287599cfSJerome Anand 	HAD_EVENT_QUERY_IS_AUDIO_SUSPENDED,
636287599cfSJerome Anand };
637287599cfSJerome Anand 
638287599cfSJerome Anand #endif
639