#include "pcm.h"
#include "timer.h"
-#ifdef CONFIG_SBUS
-#define SBUS_SUPPORT
-#include <asm/sbus.h>
-#endif
-
-#if defined(CONFIG_PCI) && defined(CONFIG_SPARC64)
-#define EBUS_SUPPORT
-#include <linux/pci.h>
-#include <asm/ebus.h>
-#endif
-
-#if !defined(SBUS_SUPPORT) && !defined(EBUS_SUPPORT)
-#define LEGACY_SUPPORT
-#endif
-
/* IO ports */
#define CS4231P(x) (c_d_c_CS4231##x)
struct _snd_cs4231 {
unsigned long port; /* base i/o port */
-#ifdef LEGACY_SUPPORT
struct resource *res_port;
unsigned long cport; /* control base i/o port (CS4236) */
struct resource *res_cport;
int irq; /* IRQ line */
int dma1; /* playback DMA */
int dma2; /* record DMA */
-#endif
unsigned short version; /* version of CODEC chip */
unsigned short mode; /* see to CS4231_MODE_XXXX */
unsigned short hardware; /* see to CS4231_HW_XXXX */
unsigned short single_dma:1, /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */
ebus_flag:1; /* SPARC: EBUS present */
-#ifdef EBUS_SUPPORT
- struct ebus_dma_info eb2c;
- struct ebus_dma_info eb2p;
-#endif
-
-#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
- union {
-#ifdef SBUS_SUPPORT
- struct sbus_dev *sdev;
-#endif
-#ifdef EBUS_SUPPORT
- struct pci_dev *pdev;
-#endif
- } dev_u;
- unsigned int p_periods_sent;
- unsigned int c_periods_sent;
-#endif
-
snd_card_t *card;
snd_pcm_t *pcm;
snd_pcm_substream_t *playback_substream;
int mce_bit;
int calibrate_mute;
int sw_3d_bit;
-#ifdef LEGACY_SUPPORT
unsigned int p_dma_size;
unsigned int c_dma_size;
-#endif
spinlock_t reg_lock;
struct semaphore mce_mutex;
void (*resume) (cs4231_t *chip);
#endif
void *dma_private_data;
-#ifdef LEGACY_SUPPORT
int (*claim_dma) (cs4231_t *chip, void *dma_private_data, int dma);
int (*release_dma) (cs4231_t *chip, void *dma_private_data, int dma);
-#endif
};
/* exported functions */
* Basic I/O functions
*/
-#if !defined(EBUS_SUPPORT) && !defined(SBUS_SUPPORT)
-#define __CS4231_INLINE__ inline
-#else
-#define __CS4231_INLINE__ /* nothing */
-#endif
-
-static __CS4231_INLINE__ void cs4231_outb(cs4231_t *chip, u8 offset, u8 val)
+static inline void cs4231_outb(cs4231_t *chip, u8 offset, u8 val)
{
-#ifdef EBUS_SUPPORT
- if (chip->ebus->flag) {
- writeb(val, chip->port + (offset << 2));
- } else {
-#endif
-#ifdef SBUS_SUPPORT
- sbus_writeb(val, chip->port + (offset << 2));
-#endif
-#ifdef EBUS_SUPPORT
- }
-#endif
-#ifdef LEGACY_SUPPORT
outb(val, chip->port + offset);
-#endif
}
-static __CS4231_INLINE__ u8 cs4231_inb(cs4231_t *chip, u8 offset)
+static inline u8 cs4231_inb(cs4231_t *chip, u8 offset)
{
-#ifdef EBUS_SUPPORT
- if (chip->ebus_flag) {
- return readb(chip->port + (offset << 2));
- } else {
-#endif
-#ifdef SBUS_SUPPORT
- return sbus_readb(chip->port + (offset << 2));
-#endif
-#ifdef EBUS_SUPPORT
- }
-#endif
-#ifdef LEGACY_SUPPORT
return inb(chip->port + offset);
-#endif
}
static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg,
return snd_pcm_lib_free_pages(substream);
}
-#ifdef LEGACY_SUPPORT
static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream)
{
cs4231_t *chip = snd_pcm_substream_chip(substream);
#endif
return 0;
}
-#endif /* LEGACY_SUPPORT */
static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream,
snd_pcm_hw_params_t * hw_params)
return snd_pcm_lib_free_pages(substream);
}
-#ifdef LEGACY_SUPPORT
static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream)
{
cs4231_t *chip = snd_pcm_substream_chip(substream);
spin_unlock_irqrestore(&chip->reg_lock, flags);
return 0;
}
-#endif
static void snd_cs4231_overrange(cs4231_t *chip)
{
return IRQ_HANDLED;
}
-#ifdef LEGACY_SUPPORT
static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream)
{
cs4231_t *chip = snd_pcm_substream_chip(substream);
ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
-#endif /* LEGACY_SUPPORT */
/*
chip->hardware == CS4231_HW_CS4239)
runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE;
-#ifdef LEGACY_SUPPORT
snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max);
snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max);
if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0)
return err;
}
-#endif
if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) {
-#ifdef LEGACY_SUPPORT
if (chip->release_dma)
chip->release_dma(chip, chip->dma_private_data, chip->dma1);
-#endif
snd_free_pages(runtime->dma_area, runtime->dma_bytes);
return err;
}
chip->playback_substream = substream;
-#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
- chip->p_periods_sent = 0;
-#endif
snd_pcm_set_sync(substream);
chip->rate_constraint(runtime);
return 0;
chip->hardware == CS4231_HW_CS4239)
runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE;
-#ifdef LEGACY_SUPPORT
snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max);
snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max);
if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0)
return err;
}
-#endif
if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) {
-#ifdef LEGACY_SUPPORT
if (chip->release_dma)
chip->release_dma(chip, chip->dma_private_data, chip->dma2);
-#endif
snd_free_pages(runtime->dma_area, runtime->dma_bytes);
return err;
}
chip->capture_substream = substream;
-#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
- chip->c_periods_sent = 0;
-#endif
snd_pcm_set_sync(substream);
chip->rate_constraint(runtime);
return 0;
}
#endif /* CONFIG_PM */
-#ifdef LEGACY_SUPPORT
-
static int snd_cs4231_free(cs4231_t *chip)
{
release_and_free_resource(chip->res_port);
return snd_cs4231_free(chip);
}
-#endif /* LEGACY_SUPPORT */
-
const char *snd_cs4231_chip_id(cs4231_t *chip)
{
switch (chip->hardware) {
return 0;
}
-#ifdef LEGACY_SUPPORT
-
int snd_cs4231_create(snd_card_t * card,
unsigned long port,
unsigned long cport,
return 0;
}
-#endif /* LEGACY_SUPPORT */
-
static snd_pcm_ops_t snd_cs4231_playback_ops = {
.open = snd_cs4231_playback_open,
.close = snd_cs4231_playback_close,
pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX;
strcpy(pcm->name, snd_cs4231_chip_id(chip));
-#ifdef LEGACY_SUPPORT
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_isa_data(),
64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
-#else
-# ifdef EBUS_SUPPORT
- if (chip->ebus_flag) {
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
- chip->dev_u.pdev,
- 64*1024, 128*1024);
- } else {
-# endif
-# ifdef SBUS_SUPPORT
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS,
- chip->dev_u.sdev,
- 64*1024, 128*1024);
-# endif
-# ifdef EBUS_SUPPORT
- }
-# endif
-#endif
chip->pcm = pcm;
if (rpcm)