Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 1 | /* |
| 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 Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 33 | #include "intel_hdmi_lpe_audio.h" |
| 34 | |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 35 | #define MAX_PB_STREAMS 1 |
| 36 | #define MAX_CAP_STREAMS 0 |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 37 | #define BYTES_PER_WORD 0x4 |
Takashi Iwai | 77531be | 2017-02-07 12:17:23 +0100 | [diff] [blame] | 38 | #define INTEL_HAD "HdmiLpeAudio" |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 39 | |
Takashi Iwai | 77531be | 2017-02-07 12:17:23 +0100 | [diff] [blame] | 40 | /* |
| 41 | * CEA speaker placement: |
| 42 | * |
| 43 | * FL FLC FC FRC FR |
| 44 | * |
| 45 | * LFE |
| 46 | * |
| 47 | * RL RLC RC RRC RR |
| 48 | * |
| 49 | * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M |
| 50 | * corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is |
| 51 | * swapped to CEA LFE/FC. |
| 52 | */ |
| 53 | enum cea_speaker_placement { |
| 54 | FL = (1 << 0), /* Front Left */ |
| 55 | FC = (1 << 1), /* Front Center */ |
| 56 | FR = (1 << 2), /* Front Right */ |
| 57 | FLC = (1 << 3), /* Front Left Center */ |
| 58 | FRC = (1 << 4), /* Front Right Center */ |
| 59 | RL = (1 << 5), /* Rear Left */ |
| 60 | RC = (1 << 6), /* Rear Center */ |
| 61 | RR = (1 << 7), /* Rear Right */ |
| 62 | RLC = (1 << 8), /* Rear Left Center */ |
| 63 | RRC = (1 << 9), /* Rear Right Center */ |
| 64 | LFE = (1 << 10), /* Low Frequency Effect */ |
| 65 | }; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 66 | |
Takashi Iwai | 77531be | 2017-02-07 12:17:23 +0100 | [diff] [blame] | 67 | struct cea_channel_speaker_allocation { |
| 68 | int ca_index; |
| 69 | int speakers[8]; |
| 70 | |
| 71 | /* derived values, just for convenience */ |
| 72 | int channels; |
| 73 | int spk_mask; |
| 74 | }; |
| 75 | |
| 76 | struct channel_map_table { |
| 77 | unsigned char map; /* ALSA API channel map position */ |
| 78 | unsigned char cea_slot; /* CEA slot value */ |
| 79 | int spk_mask; /* speaker position bit mask */ |
| 80 | }; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 81 | |
| 82 | struct pcm_stream_info { |
Takashi Iwai | 313d9f2 | 2017-02-02 13:00:12 +0100 | [diff] [blame] | 83 | struct snd_pcm_substream *substream; |
Takashi Iwai | 313d9f2 | 2017-02-02 13:00:12 +0100 | [diff] [blame] | 84 | int substream_refcount; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 85 | }; |
| 86 | |
Takashi Iwai | 03c3437 | 2017-02-02 16:19:03 +0100 | [diff] [blame] | 87 | /* |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 88 | * struct snd_intelhad - intelhad driver structure |
| 89 | * |
| 90 | * @card: ptr to hold card details |
Takashi Iwai | 91b0cb0 | 2017-02-02 17:46:49 +0100 | [diff] [blame] | 91 | * @connected: the monitor connection status |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 92 | * @stream_info: stream information |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 93 | * @eld: holds ELD info |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 94 | * @curr_buf: pointer to hold current active ring buf |
| 95 | * @valid_buf_cnt: ring buffer count for stream |
| 96 | * @had_spinlock: driver lock |
| 97 | * @aes_bits: IEC958 status bits |
| 98 | * @buff_done: id of current buffer done intr |
| 99 | * @dev: platoform device handle |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 100 | * @chmap: holds channel map info |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 101 | */ |
| 102 | struct snd_intelhad { |
Ville Syrjälä | b4eb0d5 | 2017-04-27 19:02:29 +0300 | [diff] [blame] | 103 | struct snd_intelhad_card *card_ctx; |
Takashi Iwai | 91b0cb0 | 2017-02-02 17:46:49 +0100 | [diff] [blame] | 104 | bool connected; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 105 | struct pcm_stream_info stream_info; |
Takashi Iwai | df0435d | 2017-02-02 15:37:11 +0100 | [diff] [blame] | 106 | unsigned char eld[HDMI_MAX_ELD_BYTES]; |
Pierre-Louis Bossart | 964ca80 | 2017-01-31 14:16:52 -0600 | [diff] [blame] | 107 | bool dp_output; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 108 | unsigned int aes_bits; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 109 | spinlock_t had_spinlock; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 110 | struct device *dev; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 111 | struct snd_pcm_chmap *chmap; |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 112 | int tmds_clock_speed; |
| 113 | int link_rate; |
Ville Syrjälä | 8a2d6ae | 2017-04-27 19:02:30 +0300 | [diff] [blame] | 114 | int port; /* fixed */ |
| 115 | int pipe; /* can change dynamically */ |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 116 | |
Takashi Iwai | e1b239f | 2017-02-03 00:01:18 +0100 | [diff] [blame] | 117 | /* 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 Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 126 | /* internal stuff */ |
Takashi Iwai | 40ce4b5 | 2017-02-07 16:17:06 +0100 | [diff] [blame] | 127 | union aud_cfg aud_config; /* AUD_CONFIG reg value cache */ |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 128 | struct work_struct hdmi_audio_wq; |
Takashi Iwai | 0e9c67d | 2017-02-01 17:53:19 +0100 | [diff] [blame] | 129 | struct mutex mutex; /* for protecting chmap and eld */ |
Takashi Iwai | e2acecf | 2017-02-11 08:21:56 +0100 | [diff] [blame] | 130 | bool need_reset; |
Takashi Iwai | b9bacf2 | 2017-02-14 12:29:38 +0100 | [diff] [blame] | 131 | struct snd_jack *jack; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 132 | }; |
| 133 | |
Ville Syrjälä | b4eb0d5 | 2017-04-27 19:02:29 +0300 | [diff] [blame] | 134 | struct snd_intelhad_card { |
| 135 | struct snd_card *card; |
| 136 | struct device *dev; |
| 137 | |
| 138 | /* internal stuff */ |
| 139 | int irq; |
| 140 | void __iomem *mmio_start; |
Ville Syrjälä | 8a2d6ae | 2017-04-27 19:02:30 +0300 | [diff] [blame] | 141 | int num_pipes; |
Ville Syrjälä | b4eb0d5 | 2017-04-27 19:02:29 +0300 | [diff] [blame] | 142 | int num_ports; |
Ville Syrjälä | 8a2d6ae | 2017-04-27 19:02:30 +0300 | [diff] [blame] | 143 | struct snd_intelhad pcm_ctx[3]; /* one for each port */ |
Ville Syrjälä | b4eb0d5 | 2017-04-27 19:02:29 +0300 | [diff] [blame] | 144 | }; |
| 145 | |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 146 | #endif /* _INTEL_HDMI_AUDIO_ */ |