blob: fe8d99cb839f0fbc5b56f6454b18e7d7145e4dd9 [file] [log] [blame]
Jerome Anand5dab11d2017-01-25 04:27:52 +05301/*
2 * Copyright (C) 2016 Intel Corporation
3 * Authors: Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
4 * Ramesh Babu K V <ramesh.babu@intel.com>
5 * Vaibhav Agarwal <vaibhav.agarwal@intel.com>
6 * Jerome Anand <jerome.anand@intel.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files
10 * (the "Software"), to deal in the Software without restriction,
11 * including without limitation the rights to use, copy, modify, merge,
12 * publish, distribute, sublicense, and/or sell copies of the Software,
13 * and to permit persons to whom the Software is furnished to do so,
14 * subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial
18 * portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28 */
29
30#ifndef _INTEL_HDMI_AUDIO_H_
31#define _INTEL_HDMI_AUDIO_H_
32
Jerome Anand5dab11d2017-01-25 04:27:52 +053033#include "intel_hdmi_lpe_audio.h"
34
35#define PCM_INDEX 0
36#define MAX_PB_STREAMS 1
37#define MAX_CAP_STREAMS 0
Jerome Anand5dab11d2017-01-25 04:27:52 +053038#define BYTES_PER_WORD 0x4
Takashi Iwai77531be2017-02-07 12:17:23 +010039#define INTEL_HAD "HdmiLpeAudio"
Jerome Anand5dab11d2017-01-25 04:27:52 +053040
Takashi Iwai77531be2017-02-07 12:17:23 +010041/*
42 * CEA speaker placement:
43 *
44 * FL FLC FC FRC FR
45 *
46 * LFE
47 *
48 * RL RLC RC RRC RR
49 *
50 * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M
51 * corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is
52 * swapped to CEA LFE/FC.
53 */
54enum cea_speaker_placement {
55 FL = (1 << 0), /* Front Left */
56 FC = (1 << 1), /* Front Center */
57 FR = (1 << 2), /* Front Right */
58 FLC = (1 << 3), /* Front Left Center */
59 FRC = (1 << 4), /* Front Right Center */
60 RL = (1 << 5), /* Rear Left */
61 RC = (1 << 6), /* Rear Center */
62 RR = (1 << 7), /* Rear Right */
63 RLC = (1 << 8), /* Rear Left Center */
64 RRC = (1 << 9), /* Rear Right Center */
65 LFE = (1 << 10), /* Low Frequency Effect */
66};
Jerome Anand5dab11d2017-01-25 04:27:52 +053067
Takashi Iwai77531be2017-02-07 12:17:23 +010068struct cea_channel_speaker_allocation {
69 int ca_index;
70 int speakers[8];
71
72 /* derived values, just for convenience */
73 int channels;
74 int spk_mask;
75};
76
77struct channel_map_table {
78 unsigned char map; /* ALSA API channel map position */
79 unsigned char cea_slot; /* CEA slot value */
80 int spk_mask; /* speaker position bit mask */
81};
Jerome Anand5dab11d2017-01-25 04:27:52 +053082
83struct pcm_stream_info {
Takashi Iwai313d9f282017-02-02 13:00:12 +010084 struct snd_pcm_substream *substream;
Takashi Iwai313d9f282017-02-02 13:00:12 +010085 int substream_refcount;
Takashi Iwaif69bd102017-02-02 14:57:22 +010086 bool running;
Jerome Anand5dab11d2017-01-25 04:27:52 +053087};
88
Takashi Iwai03c34372017-02-02 16:19:03 +010089/*
Jerome Anand5dab11d2017-01-25 04:27:52 +053090 * struct snd_intelhad - intelhad driver structure
91 *
92 * @card: ptr to hold card details
Takashi Iwai91b0cb02017-02-02 17:46:49 +010093 * @connected: the monitor connection status
Jerome Anand5dab11d2017-01-25 04:27:52 +053094 * @stream_info: stream information
Takashi Iwaida864802017-01-31 13:52:22 +010095 * @eld: holds ELD info
Jerome Anand5dab11d2017-01-25 04:27:52 +053096 * @curr_buf: pointer to hold current active ring buf
97 * @valid_buf_cnt: ring buffer count for stream
98 * @had_spinlock: driver lock
99 * @aes_bits: IEC958 status bits
100 * @buff_done: id of current buffer done intr
101 * @dev: platoform device handle
Jerome Anand5dab11d2017-01-25 04:27:52 +0530102 * @chmap: holds channel map info
Jerome Anand5dab11d2017-01-25 04:27:52 +0530103 */
104struct snd_intelhad {
105 struct snd_card *card;
Takashi Iwai91b0cb02017-02-02 17:46:49 +0100106 bool connected;
Jerome Anand5dab11d2017-01-25 04:27:52 +0530107 struct pcm_stream_info stream_info;
Takashi Iwaidf0435d2017-02-02 15:37:11 +0100108 unsigned char eld[HDMI_MAX_ELD_BYTES];
Pierre-Louis Bossart964ca802017-01-31 14:16:52 -0600109 bool dp_output;
Jerome Anand5dab11d2017-01-25 04:27:52 +0530110 unsigned int aes_bits;
Jerome Anand5dab11d2017-01-25 04:27:52 +0530111 spinlock_t had_spinlock;
Jerome Anand5dab11d2017-01-25 04:27:52 +0530112 struct device *dev;
Jerome Anand5dab11d2017-01-25 04:27:52 +0530113 struct snd_pcm_chmap *chmap;
Takashi Iwaida864802017-01-31 13:52:22 +0100114 int tmds_clock_speed;
115 int link_rate;
116
Takashi Iwaie1b239f32017-02-03 00:01:18 +0100117 /* ring buffer (BD) position index */
118 unsigned int bd_head;
119 /* PCM buffer position indices */
120 unsigned int pcmbuf_head; /* being processed */
121 unsigned int pcmbuf_filled; /* to be filled */
122
123 unsigned int num_bds; /* number of BDs */
124 unsigned int period_bytes; /* PCM period size in bytes */
125
Takashi Iwaida864802017-01-31 13:52:22 +0100126 /* internal stuff */
127 int irq;
128 void __iomem *mmio_start;
129 unsigned int had_config_offset;
Takashi Iwaida864802017-01-31 13:52:22 +0100130 struct work_struct hdmi_audio_wq;
Takashi Iwai0e9c67d2017-02-01 17:53:19 +0100131 struct mutex mutex; /* for protecting chmap and eld */
Jerome Anand5dab11d2017-01-25 04:27:52 +0530132};
133
Jerome Anand5dab11d2017-01-25 04:27:52 +0530134#endif /* _INTEL_HDMI_AUDIO_ */