/*1* Copyright (C) 2016 Intel Corporation2* Authors: Sailaja Bandarupalli <[email protected]>3* Ramesh Babu K V <[email protected]>4* Vaibhav Agarwal <[email protected]>5* Jerome Anand <[email protected]>6*7* Permission is hereby granted, free of charge, to any person obtaining8* a copy of this software and associated documentation files9* (the "Software"), to deal in the Software without restriction,10* including without limitation the rights to use, copy, modify, merge,11* publish, distribute, sublicense, and/or sell copies of the Software,12* and to permit persons to whom the Software is furnished to do so,13* subject to the following conditions:14*15* The above copyright notice and this permission notice (including the16* next paragraph) shall be included in all copies or substantial17* portions of the Software.18*19* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,20* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF21* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND22* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS23* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN24* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN25* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE26* SOFTWARE.27*/2829#ifndef _INTEL_HDMI_AUDIO_H_30#define _INTEL_HDMI_AUDIO_H_3132#include "intel_hdmi_lpe_audio.h"3334#define MAX_PB_STREAMS 135#define MAX_CAP_STREAMS 036#define BYTES_PER_WORD 0x437#define INTEL_HAD "HdmiLpeAudio"3839/*40* CEA speaker placement:41*42* FL FLC FC FRC FR43*44* LFE45*46* RL RLC RC RRC RR47*48* The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M49* corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is50* swapped to CEA LFE/FC.51*/52enum cea_speaker_placement {53FL = (1 << 0), /* Front Left */54FC = (1 << 1), /* Front Center */55FR = (1 << 2), /* Front Right */56FLC = (1 << 3), /* Front Left Center */57FRC = (1 << 4), /* Front Right Center */58RL = (1 << 5), /* Rear Left */59RC = (1 << 6), /* Rear Center */60RR = (1 << 7), /* Rear Right */61RLC = (1 << 8), /* Rear Left Center */62RRC = (1 << 9), /* Rear Right Center */63LFE = (1 << 10), /* Low Frequency Effect */64};6566struct cea_channel_speaker_allocation {67int ca_index;68int speakers[8];6970/* derived values, just for convenience */71int channels;72int spk_mask;73};7475struct channel_map_table {76unsigned char map; /* ALSA API channel map position */77unsigned char cea_slot; /* CEA slot value */78int spk_mask; /* speaker position bit mask */79};8081struct pcm_stream_info {82struct snd_pcm_substream *substream;83int substream_refcount;84};8586/*87* struct snd_intelhad - intelhad driver structure88*89* @card: ptr to hold card details90* @connected: the monitor connection status91* @stream_info: stream information92* @eld: holds ELD info93* @curr_buf: pointer to hold current active ring buf94* @valid_buf_cnt: ring buffer count for stream95* @had_spinlock: driver lock96* @aes_bits: IEC958 status bits97* @buff_done: id of current buffer done intr98* @dev: platform device handle99* @chmap: holds channel map info100*/101struct snd_intelhad {102struct snd_intelhad_card *card_ctx;103bool connected;104struct pcm_stream_info stream_info;105unsigned char eld[HDMI_MAX_ELD_BYTES];106bool dp_output;107unsigned int aes_bits;108spinlock_t had_spinlock;109struct device *dev;110struct snd_pcm_chmap *chmap;111int tmds_clock_speed;112int link_rate;113int port; /* fixed */114int pipe; /* can change dynamically */115116/* ring buffer (BD) position index */117unsigned int bd_head;118/* PCM buffer position indices */119unsigned int pcmbuf_head; /* being processed */120unsigned int pcmbuf_filled; /* to be filled */121122unsigned int num_bds; /* number of BDs */123unsigned int period_bytes; /* PCM period size in bytes */124125/* internal stuff */126union aud_cfg aud_config; /* AUD_CONFIG reg value cache */127struct work_struct hdmi_audio_wq;128struct mutex mutex; /* for protecting chmap and eld */129struct snd_jack *jack;130};131132struct snd_intelhad_card {133struct snd_card *card;134struct device *dev;135136/* internal stuff */137int irq;138void __iomem *mmio_start;139int num_pipes;140int num_ports;141struct snd_intelhad pcm_ctx[3]; /* one for each port */142};143144#endif /* _INTEL_HDMI_AUDIO_ */145146147