Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2016 Intel Corporation
0003  *  Authors:    Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
0004  *      Ramesh Babu K V <ramesh.babu@intel.com>
0005  *      Vaibhav Agarwal <vaibhav.agarwal@intel.com>
0006  *      Jerome Anand <jerome.anand@intel.com>
0007  *
0008  * Permission is hereby granted, free of charge, to any person obtaining
0009  * a copy of this software and associated documentation files
0010  * (the "Software"), to deal in the Software without restriction,
0011  * including without limitation the rights to use, copy, modify, merge,
0012  * publish, distribute, sublicense, and/or sell copies of the Software,
0013  * and to permit persons to whom the Software is furnished to do so,
0014  * subject to the following conditions:
0015  *
0016  * The above copyright notice and this permission notice (including the
0017  * next paragraph) shall be included in all copies or substantial
0018  * portions of the Software.
0019  *
0020  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0021  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0022  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0023  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0024  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0025  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0026  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0027  * SOFTWARE.
0028  */
0029 
0030 #ifndef _INTEL_HDMI_AUDIO_H_
0031 #define _INTEL_HDMI_AUDIO_H_
0032 
0033 #include "intel_hdmi_lpe_audio.h"
0034 
0035 #define MAX_PB_STREAMS      1
0036 #define MAX_CAP_STREAMS     0
0037 #define BYTES_PER_WORD      0x4
0038 #define INTEL_HAD       "HdmiLpeAudio"
0039 
0040 /*
0041  *  CEA speaker placement:
0042  *
0043  *  FL  FLC   FC   FRC   FR
0044  *
0045  *                      LFE
0046  *
0047  *  RL  RLC   RC   RRC   RR
0048  *
0049  *  The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M
0050  *  corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is
0051  *  swapped to CEA LFE/FC.
0052  */
0053 enum cea_speaker_placement {
0054     FL  = (1 <<  0),        /* Front Left           */
0055     FC  = (1 <<  1),        /* Front Center         */
0056     FR  = (1 <<  2),        /* Front Right          */
0057     FLC = (1 <<  3),        /* Front Left Center    */
0058     FRC = (1 <<  4),        /* Front Right Center   */
0059     RL  = (1 <<  5),        /* Rear Left            */
0060     RC  = (1 <<  6),        /* Rear Center          */
0061     RR  = (1 <<  7),        /* Rear Right           */
0062     RLC = (1 <<  8),        /* Rear Left Center     */
0063     RRC = (1 <<  9),        /* Rear Right Center    */
0064     LFE = (1 << 10),        /* Low Frequency Effect */
0065 };
0066 
0067 struct cea_channel_speaker_allocation {
0068     int ca_index;
0069     int speakers[8];
0070 
0071     /* derived values, just for convenience */
0072     int channels;
0073     int spk_mask;
0074 };
0075 
0076 struct channel_map_table {
0077     unsigned char map;              /* ALSA API channel map position */
0078     unsigned char cea_slot;         /* CEA slot value */
0079     int spk_mask;                   /* speaker position bit mask */
0080 };
0081 
0082 struct pcm_stream_info {
0083     struct snd_pcm_substream *substream;
0084     int substream_refcount;
0085 };
0086 
0087 /*
0088  * struct snd_intelhad - intelhad driver structure
0089  *
0090  * @card: ptr to hold card details
0091  * @connected: the monitor connection status
0092  * @stream_info: stream information
0093  * @eld: holds ELD info
0094  * @curr_buf: pointer to hold current active ring buf
0095  * @valid_buf_cnt: ring buffer count for stream
0096  * @had_spinlock: driver lock
0097  * @aes_bits: IEC958 status bits
0098  * @buff_done: id of current buffer done intr
0099  * @dev: platform device handle
0100  * @chmap: holds channel map info
0101  */
0102 struct snd_intelhad {
0103     struct snd_intelhad_card *card_ctx;
0104     bool        connected;
0105     struct      pcm_stream_info stream_info;
0106     unsigned char   eld[HDMI_MAX_ELD_BYTES];
0107     bool dp_output;
0108     unsigned int    aes_bits;
0109     spinlock_t had_spinlock;
0110     struct device *dev;
0111     struct snd_pcm_chmap *chmap;
0112     int tmds_clock_speed;
0113     int link_rate;
0114     int port; /* fixed */
0115     int pipe; /* can change dynamically */
0116 
0117     /* ring buffer (BD) position index */
0118     unsigned int bd_head;
0119     /* PCM buffer position indices */
0120     unsigned int pcmbuf_head;   /* being processed */
0121     unsigned int pcmbuf_filled; /* to be filled */
0122 
0123     unsigned int num_bds;       /* number of BDs */
0124     unsigned int period_bytes;  /* PCM period size in bytes */
0125 
0126     /* internal stuff */
0127     union aud_cfg aud_config;   /* AUD_CONFIG reg value cache */
0128     struct work_struct hdmi_audio_wq;
0129     struct mutex mutex; /* for protecting chmap and eld */
0130     struct snd_jack *jack;
0131 };
0132 
0133 struct snd_intelhad_card {
0134     struct snd_card *card;
0135     struct device *dev;
0136 
0137     /* internal stuff */
0138     int irq;
0139     void __iomem *mmio_start;
0140     int num_pipes;
0141     int num_ports;
0142     struct snd_intelhad pcm_ctx[3]; /* one for each port */
0143 };
0144 
0145 #endif /* _INTEL_HDMI_AUDIO_ */