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 | |
| 33 | #include <linux/types.h> |
| 34 | #include <sound/initval.h> |
| 35 | #include <linux/version.h> |
| 36 | #include <linux/pm_runtime.h> |
| 37 | #include <sound/asoundef.h> |
| 38 | #include <sound/control.h> |
| 39 | #include <sound/pcm.h> |
| 40 | #include "intel_hdmi_lpe_audio.h" |
| 41 | |
| 42 | #define PCM_INDEX 0 |
| 43 | #define MAX_PB_STREAMS 1 |
| 44 | #define MAX_CAP_STREAMS 0 |
| 45 | #define HDMI_AUDIO_DRIVER "hdmi-audio" |
| 46 | |
Pierre-Louis Bossart | 964ca80 | 2017-01-31 14:16:52 -0600 | [diff] [blame] | 47 | #define HDMI_INFO_FRAME_WORD1 0x000a0184 |
| 48 | #define DP_INFO_FRAME_WORD1 0x00441b84 |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 49 | #define FIFO_THRESHOLD 0xFE |
| 50 | #define DMA_FIFO_THRESHOLD 0x7 |
| 51 | #define BYTES_PER_WORD 0x4 |
| 52 | |
| 53 | /* Sampling rate as per IEC60958 Ver 3 */ |
| 54 | #define CH_STATUS_MAP_32KHZ 0x3 |
| 55 | #define CH_STATUS_MAP_44KHZ 0x0 |
| 56 | #define CH_STATUS_MAP_48KHZ 0x2 |
| 57 | #define CH_STATUS_MAP_88KHZ 0x8 |
| 58 | #define CH_STATUS_MAP_96KHZ 0xA |
| 59 | #define CH_STATUS_MAP_176KHZ 0xC |
| 60 | #define CH_STATUS_MAP_192KHZ 0xE |
| 61 | |
| 62 | #define MAX_SMPL_WIDTH_20 0x0 |
| 63 | #define MAX_SMPL_WIDTH_24 0x1 |
| 64 | #define SMPL_WIDTH_16BITS 0x1 |
| 65 | #define SMPL_WIDTH_24BITS 0x5 |
| 66 | #define CHANNEL_ALLOCATION 0x1F |
| 67 | #define MASK_BYTE0 0x000000FF |
| 68 | #define VALID_DIP_WORDS 3 |
| 69 | #define LAYOUT0 0 |
| 70 | #define LAYOUT1 1 |
| 71 | #define SWAP_LFE_CENTER 0x00fac4c8 |
Takashi Iwai | 4151ee8 | 2017-01-31 18:14:15 +0100 | [diff] [blame] | 72 | #define AUD_CONFIG_CH_MASK 0x70 |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 73 | |
| 74 | struct pcm_stream_info { |
| 75 | int str_id; |
Takashi Iwai | df76df1 | 2017-01-31 16:04:10 +0100 | [diff] [blame] | 76 | struct snd_pcm_substream *had_substream; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 77 | u32 buffer_ptr; |
| 78 | u64 buffer_rendered; |
| 79 | u32 ring_buf_size; |
| 80 | int sfreq; |
| 81 | }; |
| 82 | |
| 83 | struct ring_buf_info { |
| 84 | u32 buf_addr; |
| 85 | u32 buf_size; |
| 86 | u8 is_valid; |
| 87 | }; |
| 88 | |
| 89 | struct had_stream_pvt { |
| 90 | enum had_stream_status stream_status; |
| 91 | int stream_ops; |
| 92 | ssize_t dbg_cum_bytes; |
| 93 | }; |
| 94 | |
Takashi Iwai | 5647aec | 2017-01-31 08:14:34 +0100 | [diff] [blame] | 95 | struct had_stream_data { |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 96 | enum had_status_stream stream_type; |
| 97 | }; |
| 98 | |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 99 | /** |
| 100 | * struct snd_intelhad - intelhad driver structure |
| 101 | * |
| 102 | * @card: ptr to hold card details |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 103 | * @drv_status: driver status |
| 104 | * @buf_info: ring buffer info |
| 105 | * @stream_info: stream information |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 106 | * @eld: holds ELD info |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 107 | * @curr_buf: pointer to hold current active ring buf |
| 108 | * @valid_buf_cnt: ring buffer count for stream |
| 109 | * @had_spinlock: driver lock |
| 110 | * @aes_bits: IEC958 status bits |
| 111 | * @buff_done: id of current buffer done intr |
| 112 | * @dev: platoform device handle |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 113 | * @chmap: holds channel map info |
Takashi Iwai | 6ddb3ab | 2017-01-30 18:17:44 +0100 | [diff] [blame] | 114 | * @underrun_count: PCM stream underrun counter |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 115 | */ |
| 116 | struct snd_intelhad { |
| 117 | struct snd_card *card; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 118 | enum had_drv_status drv_status; |
| 119 | struct ring_buf_info buf_info[HAD_NUM_OF_RING_BUFS]; |
| 120 | struct pcm_stream_info stream_info; |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 121 | union otm_hdmi_eld_t eld; |
Pierre-Louis Bossart | 964ca80 | 2017-01-31 14:16:52 -0600 | [diff] [blame] | 122 | bool dp_output; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 123 | enum intel_had_aud_buf_type curr_buf; |
| 124 | int valid_buf_cnt; |
| 125 | unsigned int aes_bits; |
Takashi Iwai | 5647aec | 2017-01-31 08:14:34 +0100 | [diff] [blame] | 126 | struct had_stream_data stream_data; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 127 | spinlock_t had_spinlock; |
| 128 | enum intel_had_aud_buf_type buff_done; |
| 129 | struct device *dev; |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 130 | struct snd_pcm_chmap *chmap; |
Takashi Iwai | 6ddb3ab | 2017-01-30 18:17:44 +0100 | [diff] [blame] | 131 | int underrun_count; |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 132 | int tmds_clock_speed; |
| 133 | int link_rate; |
| 134 | |
| 135 | /* internal stuff */ |
| 136 | int irq; |
| 137 | void __iomem *mmio_start; |
| 138 | unsigned int had_config_offset; |
Takashi Iwai | da86480 | 2017-01-31 13:52:22 +0100 | [diff] [blame] | 139 | struct work_struct hdmi_audio_wq; |
Takashi Iwai | 0e9c67d | 2017-02-01 17:53:19 +0100 | [diff] [blame^] | 140 | struct mutex mutex; /* for protecting chmap and eld */ |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 141 | }; |
| 142 | |
Jerome Anand | 5dab11d | 2017-01-25 04:27:52 +0530 | [diff] [blame] | 143 | #endif /* _INTEL_HDMI_AUDIO_ */ |