xref: /linux/sound/x86/intel_hdmi_audio.h (revision a8e7ef3cec99ba2487110e01d77a8a278593b3e9)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright (C) 2016 Intel Corporation
4  *  Authors:	Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
5  *		Ramesh Babu K V	<ramesh.babu@intel.com>
6  *		Vaibhav Agarwal <vaibhav.agarwal@intel.com>
7  *		Jerome Anand <jerome.anand@intel.com>
8  */
9 
10 #ifndef _INTEL_HDMI_AUDIO_H_
11 #define _INTEL_HDMI_AUDIO_H_
12 
13 #include "intel_hdmi_lpe_audio.h"
14 
15 #define MAX_PB_STREAMS		1
16 #define MAX_CAP_STREAMS		0
17 #define BYTES_PER_WORD		0x4
18 #define INTEL_HAD		"HdmiLpeAudio"
19 
20 /*
21  *	CEA speaker placement:
22  *
23  *	FL  FLC   FC   FRC   FR
24  *
25  *						LFE
26  *
27  *	RL  RLC   RC   RRC   RR
28  *
29  *	The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M
30  *	corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is
31  *	swapped to CEA LFE/FC.
32  */
33 enum cea_speaker_placement {
34 	FL  = (1 <<  0),        /* Front Left           */
35 	FC  = (1 <<  1),        /* Front Center         */
36 	FR  = (1 <<  2),        /* Front Right          */
37 	FLC = (1 <<  3),        /* Front Left Center    */
38 	FRC = (1 <<  4),        /* Front Right Center   */
39 	RL  = (1 <<  5),        /* Rear Left            */
40 	RC  = (1 <<  6),        /* Rear Center          */
41 	RR  = (1 <<  7),        /* Rear Right           */
42 	RLC = (1 <<  8),        /* Rear Left Center     */
43 	RRC = (1 <<  9),        /* Rear Right Center    */
44 	LFE = (1 << 10),        /* Low Frequency Effect */
45 };
46 
47 struct cea_channel_speaker_allocation {
48 	int ca_index;
49 	int speakers[8];
50 
51 	/* derived values, just for convenience */
52 	int channels;
53 	int spk_mask;
54 };
55 
56 struct channel_map_table {
57 	unsigned char map;              /* ALSA API channel map position */
58 	unsigned char cea_slot;         /* CEA slot value */
59 	int spk_mask;                   /* speaker position bit mask */
60 };
61 
62 struct pcm_stream_info {
63 	struct snd_pcm_substream *substream;
64 	int substream_refcount;
65 };
66 
67 /*
68  * struct snd_intelhad - intelhad driver structure
69  *
70  * @card: ptr to hold card details
71  * @connected: the monitor connection status
72  * @stream_info: stream information
73  * @eld: holds ELD info
74  * @curr_buf: pointer to hold current active ring buf
75  * @valid_buf_cnt: ring buffer count for stream
76  * @had_spinlock: driver lock
77  * @aes_bits: IEC958 status bits
78  * @buff_done: id of current buffer done intr
79  * @dev: platform device handle
80  * @chmap: holds channel map info
81  */
82 struct snd_intelhad {
83 	struct snd_intelhad_card *card_ctx;
84 	bool		connected;
85 	struct		pcm_stream_info stream_info;
86 	unsigned char	eld[HDMI_MAX_ELD_BYTES];
87 	bool dp_output;
88 	unsigned int	aes_bits;
89 	spinlock_t had_spinlock;
90 	struct device *dev;
91 	struct snd_pcm_chmap *chmap;
92 	int tmds_clock_speed;
93 	int link_rate;
94 	int port; /* fixed */
95 	int pipe; /* can change dynamically */
96 
97 	/* ring buffer (BD) position index */
98 	unsigned int bd_head;
99 	/* PCM buffer position indices */
100 	unsigned int pcmbuf_head;	/* being processed */
101 	unsigned int pcmbuf_filled;	/* to be filled */
102 
103 	unsigned int num_bds;		/* number of BDs */
104 	unsigned int period_bytes;	/* PCM period size in bytes */
105 
106 	/* internal stuff */
107 	union aud_cfg aud_config;	/* AUD_CONFIG reg value cache */
108 	struct work_struct hdmi_audio_wq;
109 	struct mutex mutex; /* for protecting chmap and eld */
110 	struct snd_jack *jack;
111 };
112 
113 struct snd_intelhad_card {
114 	struct snd_card	*card;
115 	struct device *dev;
116 
117 	/* internal stuff */
118 	int irq;
119 	void __iomem *mmio_start;
120 	int num_pipes;
121 	int num_ports;
122 	struct snd_intelhad pcm_ctx[3]; /* one for each port */
123 };
124 
125 #endif /* _INTEL_HDMI_AUDIO_ */
126