blob: 0e83d5a9f28fb4670515f6a750d9ea54b7a4f75e [file] [log] [blame]
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2018 Synaptics Incorporated */
#ifndef __BERLIN_PCM_H__
#define __BERLIN_PCM_H__
#include <linux/platform_device.h>
#include <linux/atomic.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
enum berlin_xrun_t {
PCM_OVERRUN,
FIFO_OVERRUN,
PCM_UNDERRUN,
FIFO_UNDERRUN,
IRQ_DISABLE,
XRUN_T_MAX
};
/* Each capture substream support either I2S OR PDM, not BOTH! */
#define I2SI_MODE (1)
#define PDMI_MODE (I2SI_MODE << 1)
/*
* Playback substream may masked to I2S AND SPDIF at the sametime
* The reason is we need to consider the customer use case, currently
* they only feed one output stream but want playback to i2s and spdif.
* Can split into I2S and SPDIF dai in further if customer use case allow
*/
#define I2SO_MODE (I2SI_MODE << 2)
#define SPDIFO_MODE (I2SI_MODE << 3)
#define PCMMONO_MODE (I2SI_MODE << 4)
#define MAX_PCMS 5
#define MIN_CHANNELS 2
#define MAX_CHANNELS 8
// Support up to 8 audio channels, 4 dhub channels
#define MAX_CHID (MAX_CHANNELS >> 1)
struct berlin_chip {
struct snd_card *card;
struct platform_device *pdev;
struct snd_hwdep *hwdep;
void __iomem *pll_base;
atomic_long_t xruns[XRUN_T_MAX];
};
void berlin_report_xrun(struct berlin_chip *chip, enum berlin_xrun_t xrun_type);
int berlin_pcm_request_dma_irq(struct snd_pcm_substream *substream,
u32 chid_num,
u32 irq_num,
unsigned int *irq,
const char *dev_name,
u32 mode);
void berlin_pcm_free_dma_irq(struct snd_pcm_substream *substream,
u32 chid_num,
u32 irq_num,
unsigned int *irq);
void berlin_pcm_max_ch_inuse(struct snd_pcm_substream *ss,
u32 ch_num);
#endif