2017-01-24 22:57:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Intel Corporation
|
|
|
|
* Authors: Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
|
|
|
|
* Ramesh Babu K V <ramesh.babu@intel.com>
|
|
|
|
* Vaibhav Agarwal <vaibhav.agarwal@intel.com>
|
|
|
|
* Jerome Anand <jerome.anand@intel.com>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files
|
|
|
|
* (the "Software"), to deal in the Software without restriction,
|
|
|
|
* including without limitation the rights to use, copy, modify, merge,
|
|
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
* and to permit persons to whom the Software is furnished to do so,
|
|
|
|
* subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INTEL_HDMI_AUDIO_H_
|
|
|
|
#define _INTEL_HDMI_AUDIO_H_
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
#include <linux/version.h>
|
|
|
|
#include <linux/pm_runtime.h>
|
|
|
|
#include <sound/asoundef.h>
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include "intel_hdmi_lpe_audio.h"
|
|
|
|
|
|
|
|
#define PCM_INDEX 0
|
|
|
|
#define MAX_PB_STREAMS 1
|
|
|
|
#define MAX_CAP_STREAMS 0
|
|
|
|
#define HDMI_AUDIO_DRIVER "hdmi-audio"
|
|
|
|
|
2017-01-31 20:16:52 +00:00
|
|
|
#define HDMI_INFO_FRAME_WORD1 0x000a0184
|
|
|
|
#define DP_INFO_FRAME_WORD1 0x00441b84
|
2017-01-24 22:57:52 +00:00
|
|
|
#define FIFO_THRESHOLD 0xFE
|
|
|
|
#define DMA_FIFO_THRESHOLD 0x7
|
|
|
|
#define BYTES_PER_WORD 0x4
|
|
|
|
|
|
|
|
/* Sampling rate as per IEC60958 Ver 3 */
|
|
|
|
#define CH_STATUS_MAP_32KHZ 0x3
|
|
|
|
#define CH_STATUS_MAP_44KHZ 0x0
|
|
|
|
#define CH_STATUS_MAP_48KHZ 0x2
|
|
|
|
#define CH_STATUS_MAP_88KHZ 0x8
|
|
|
|
#define CH_STATUS_MAP_96KHZ 0xA
|
|
|
|
#define CH_STATUS_MAP_176KHZ 0xC
|
|
|
|
#define CH_STATUS_MAP_192KHZ 0xE
|
|
|
|
|
|
|
|
#define MAX_SMPL_WIDTH_20 0x0
|
|
|
|
#define MAX_SMPL_WIDTH_24 0x1
|
|
|
|
#define SMPL_WIDTH_16BITS 0x1
|
|
|
|
#define SMPL_WIDTH_24BITS 0x5
|
|
|
|
#define CHANNEL_ALLOCATION 0x1F
|
|
|
|
#define MASK_BYTE0 0x000000FF
|
|
|
|
#define VALID_DIP_WORDS 3
|
|
|
|
#define LAYOUT0 0
|
|
|
|
#define LAYOUT1 1
|
|
|
|
#define SWAP_LFE_CENTER 0x00fac4c8
|
2017-01-31 17:14:15 +00:00
|
|
|
#define AUD_CONFIG_CH_MASK 0x70
|
2017-01-24 22:57:52 +00:00
|
|
|
|
|
|
|
struct pcm_stream_info {
|
2017-02-02 12:00:12 +00:00
|
|
|
struct snd_pcm_substream *substream;
|
2017-01-24 22:57:52 +00:00
|
|
|
u64 buffer_rendered;
|
|
|
|
u32 ring_buf_size;
|
2017-02-02 12:00:12 +00:00
|
|
|
int substream_refcount;
|
2017-01-24 22:57:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ring_buf_info {
|
|
|
|
u32 buf_addr;
|
|
|
|
u32 buf_size;
|
|
|
|
u8 is_valid;
|
|
|
|
};
|
|
|
|
|
2017-01-31 07:14:34 +00:00
|
|
|
struct had_stream_data {
|
2017-01-24 22:57:52 +00:00
|
|
|
enum had_status_stream stream_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct snd_intelhad - intelhad driver structure
|
|
|
|
*
|
|
|
|
* @card: ptr to hold card details
|
|
|
|
* @drv_status: driver status
|
|
|
|
* @buf_info: ring buffer info
|
|
|
|
* @stream_info: stream information
|
2017-01-31 12:52:22 +00:00
|
|
|
* @eld: holds ELD info
|
2017-01-24 22:57:52 +00:00
|
|
|
* @curr_buf: pointer to hold current active ring buf
|
|
|
|
* @valid_buf_cnt: ring buffer count for stream
|
|
|
|
* @had_spinlock: driver lock
|
|
|
|
* @aes_bits: IEC958 status bits
|
|
|
|
* @buff_done: id of current buffer done intr
|
|
|
|
* @dev: platoform device handle
|
|
|
|
* @chmap: holds channel map info
|
2017-01-30 17:17:44 +00:00
|
|
|
* @underrun_count: PCM stream underrun counter
|
2017-01-24 22:57:52 +00:00
|
|
|
*/
|
|
|
|
struct snd_intelhad {
|
|
|
|
struct snd_card *card;
|
|
|
|
enum had_drv_status drv_status;
|
|
|
|
struct ring_buf_info buf_info[HAD_NUM_OF_RING_BUFS];
|
|
|
|
struct pcm_stream_info stream_info;
|
2017-01-31 12:52:22 +00:00
|
|
|
union otm_hdmi_eld_t eld;
|
2017-01-31 20:16:52 +00:00
|
|
|
bool dp_output;
|
2017-01-24 22:57:52 +00:00
|
|
|
enum intel_had_aud_buf_type curr_buf;
|
|
|
|
int valid_buf_cnt;
|
|
|
|
unsigned int aes_bits;
|
2017-01-31 07:14:34 +00:00
|
|
|
struct had_stream_data stream_data;
|
2017-01-24 22:57:52 +00:00
|
|
|
spinlock_t had_spinlock;
|
|
|
|
enum intel_had_aud_buf_type buff_done;
|
|
|
|
struct device *dev;
|
|
|
|
struct snd_pcm_chmap *chmap;
|
2017-01-30 17:17:44 +00:00
|
|
|
int underrun_count;
|
2017-01-31 12:52:22 +00:00
|
|
|
int tmds_clock_speed;
|
|
|
|
int link_rate;
|
|
|
|
|
|
|
|
/* internal stuff */
|
|
|
|
int irq;
|
|
|
|
void __iomem *mmio_start;
|
|
|
|
unsigned int had_config_offset;
|
|
|
|
struct work_struct hdmi_audio_wq;
|
2017-02-01 16:53:19 +00:00
|
|
|
struct mutex mutex; /* for protecting chmap and eld */
|
2017-01-24 22:57:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _INTEL_HDMI_AUDIO_ */
|