xref: /OK3568_Linux_fs/kernel/sound/x86/intel_hdmi_audio.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (C) 2016 Intel Corporation
3*4882a593Smuzhiyun  *  Authors:	Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
4*4882a593Smuzhiyun  *		Ramesh Babu K V	<ramesh.babu@intel.com>
5*4882a593Smuzhiyun  *		Vaibhav Agarwal <vaibhav.agarwal@intel.com>
6*4882a593Smuzhiyun  *		Jerome Anand <jerome.anand@intel.com>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining
9*4882a593Smuzhiyun  * a copy of this software and associated documentation files
10*4882a593Smuzhiyun  * (the "Software"), to deal in the Software without restriction,
11*4882a593Smuzhiyun  * including without limitation the rights to use, copy, modify, merge,
12*4882a593Smuzhiyun  * publish, distribute, sublicense, and/or sell copies of the Software,
13*4882a593Smuzhiyun  * and to permit persons to whom the Software is furnished to do so,
14*4882a593Smuzhiyun  * subject to the following conditions:
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  * The above copyright notice and this permission notice (including the
17*4882a593Smuzhiyun  * next paragraph) shall be included in all copies or substantial
18*4882a593Smuzhiyun  * portions of the Software.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21*4882a593Smuzhiyun  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22*4882a593Smuzhiyun  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23*4882a593Smuzhiyun  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24*4882a593Smuzhiyun  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25*4882a593Smuzhiyun  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26*4882a593Smuzhiyun  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27*4882a593Smuzhiyun  * SOFTWARE.
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #ifndef _INTEL_HDMI_AUDIO_H_
31*4882a593Smuzhiyun #define _INTEL_HDMI_AUDIO_H_
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #include "intel_hdmi_lpe_audio.h"
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #define MAX_PB_STREAMS		1
36*4882a593Smuzhiyun #define MAX_CAP_STREAMS		0
37*4882a593Smuzhiyun #define BYTES_PER_WORD		0x4
38*4882a593Smuzhiyun #define INTEL_HAD		"HdmiLpeAudio"
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun /*
41*4882a593Smuzhiyun  *	CEA speaker placement:
42*4882a593Smuzhiyun  *
43*4882a593Smuzhiyun  *	FL  FLC   FC   FRC   FR
44*4882a593Smuzhiyun  *
45*4882a593Smuzhiyun  *						LFE
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  *	RL  RLC   RC   RRC   RR
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  *	The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M
50*4882a593Smuzhiyun  *	corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is
51*4882a593Smuzhiyun  *	swapped to CEA LFE/FC.
52*4882a593Smuzhiyun  */
53*4882a593Smuzhiyun enum cea_speaker_placement {
54*4882a593Smuzhiyun 	FL  = (1 <<  0),        /* Front Left           */
55*4882a593Smuzhiyun 	FC  = (1 <<  1),        /* Front Center         */
56*4882a593Smuzhiyun 	FR  = (1 <<  2),        /* Front Right          */
57*4882a593Smuzhiyun 	FLC = (1 <<  3),        /* Front Left Center    */
58*4882a593Smuzhiyun 	FRC = (1 <<  4),        /* Front Right Center   */
59*4882a593Smuzhiyun 	RL  = (1 <<  5),        /* Rear Left            */
60*4882a593Smuzhiyun 	RC  = (1 <<  6),        /* Rear Center          */
61*4882a593Smuzhiyun 	RR  = (1 <<  7),        /* Rear Right           */
62*4882a593Smuzhiyun 	RLC = (1 <<  8),        /* Rear Left Center     */
63*4882a593Smuzhiyun 	RRC = (1 <<  9),        /* Rear Right Center    */
64*4882a593Smuzhiyun 	LFE = (1 << 10),        /* Low Frequency Effect */
65*4882a593Smuzhiyun };
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun struct cea_channel_speaker_allocation {
68*4882a593Smuzhiyun 	int ca_index;
69*4882a593Smuzhiyun 	int speakers[8];
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun 	/* derived values, just for convenience */
72*4882a593Smuzhiyun 	int channels;
73*4882a593Smuzhiyun 	int spk_mask;
74*4882a593Smuzhiyun };
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun struct channel_map_table {
77*4882a593Smuzhiyun 	unsigned char map;              /* ALSA API channel map position */
78*4882a593Smuzhiyun 	unsigned char cea_slot;         /* CEA slot value */
79*4882a593Smuzhiyun 	int spk_mask;                   /* speaker position bit mask */
80*4882a593Smuzhiyun };
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun struct pcm_stream_info {
83*4882a593Smuzhiyun 	struct snd_pcm_substream *substream;
84*4882a593Smuzhiyun 	int substream_refcount;
85*4882a593Smuzhiyun };
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun /*
88*4882a593Smuzhiyun  * struct snd_intelhad - intelhad driver structure
89*4882a593Smuzhiyun  *
90*4882a593Smuzhiyun  * @card: ptr to hold card details
91*4882a593Smuzhiyun  * @connected: the monitor connection status
92*4882a593Smuzhiyun  * @stream_info: stream information
93*4882a593Smuzhiyun  * @eld: holds ELD info
94*4882a593Smuzhiyun  * @curr_buf: pointer to hold current active ring buf
95*4882a593Smuzhiyun  * @valid_buf_cnt: ring buffer count for stream
96*4882a593Smuzhiyun  * @had_spinlock: driver lock
97*4882a593Smuzhiyun  * @aes_bits: IEC958 status bits
98*4882a593Smuzhiyun  * @buff_done: id of current buffer done intr
99*4882a593Smuzhiyun  * @dev: platoform device handle
100*4882a593Smuzhiyun  * @chmap: holds channel map info
101*4882a593Smuzhiyun  */
102*4882a593Smuzhiyun struct snd_intelhad {
103*4882a593Smuzhiyun 	struct snd_intelhad_card *card_ctx;
104*4882a593Smuzhiyun 	bool		connected;
105*4882a593Smuzhiyun 	struct		pcm_stream_info stream_info;
106*4882a593Smuzhiyun 	unsigned char	eld[HDMI_MAX_ELD_BYTES];
107*4882a593Smuzhiyun 	bool dp_output;
108*4882a593Smuzhiyun 	unsigned int	aes_bits;
109*4882a593Smuzhiyun 	spinlock_t had_spinlock;
110*4882a593Smuzhiyun 	struct device *dev;
111*4882a593Smuzhiyun 	struct snd_pcm_chmap *chmap;
112*4882a593Smuzhiyun 	int tmds_clock_speed;
113*4882a593Smuzhiyun 	int link_rate;
114*4882a593Smuzhiyun 	int port; /* fixed */
115*4882a593Smuzhiyun 	int pipe; /* can change dynamically */
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun 	/* ring buffer (BD) position index */
118*4882a593Smuzhiyun 	unsigned int bd_head;
119*4882a593Smuzhiyun 	/* PCM buffer position indices */
120*4882a593Smuzhiyun 	unsigned int pcmbuf_head;	/* being processed */
121*4882a593Smuzhiyun 	unsigned int pcmbuf_filled;	/* to be filled */
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun 	unsigned int num_bds;		/* number of BDs */
124*4882a593Smuzhiyun 	unsigned int period_bytes;	/* PCM period size in bytes */
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun 	/* internal stuff */
127*4882a593Smuzhiyun 	union aud_cfg aud_config;	/* AUD_CONFIG reg value cache */
128*4882a593Smuzhiyun 	struct work_struct hdmi_audio_wq;
129*4882a593Smuzhiyun 	struct mutex mutex; /* for protecting chmap and eld */
130*4882a593Smuzhiyun 	bool need_reset;
131*4882a593Smuzhiyun 	struct snd_jack *jack;
132*4882a593Smuzhiyun };
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun struct snd_intelhad_card {
135*4882a593Smuzhiyun 	struct snd_card	*card;
136*4882a593Smuzhiyun 	struct device *dev;
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun 	/* internal stuff */
139*4882a593Smuzhiyun 	int irq;
140*4882a593Smuzhiyun 	void __iomem *mmio_start;
141*4882a593Smuzhiyun 	int num_pipes;
142*4882a593Smuzhiyun 	int num_ports;
143*4882a593Smuzhiyun 	struct snd_intelhad pcm_ctx[3]; /* one for each port */
144*4882a593Smuzhiyun };
145*4882a593Smuzhiyun 
146*4882a593Smuzhiyun #endif /* _INTEL_HDMI_AUDIO_ */
147