提交 f739aecc 编写于 作者: T Takashi Iwai 提交者: Jaroslav Kysela

[ALSA] Clean up ISA cs4231 code

Modules: CS4231 driver

Clean up ISA cs4231 code, removing experimental EBUS/SBUS merge,
to improve readability.
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 0948e3c8
...@@ -26,21 +26,6 @@ ...@@ -26,21 +26,6 @@
#include "pcm.h" #include "pcm.h"
#include "timer.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 */ /* IO ports */
#define CS4231P(x) (c_d_c_CS4231##x) #define CS4231P(x) (c_d_c_CS4231##x)
...@@ -236,14 +221,12 @@ typedef struct _snd_cs4231 cs4231_t; ...@@ -236,14 +221,12 @@ typedef struct _snd_cs4231 cs4231_t;
struct _snd_cs4231 { struct _snd_cs4231 {
unsigned long port; /* base i/o port */ unsigned long port; /* base i/o port */
#ifdef LEGACY_SUPPORT
struct resource *res_port; struct resource *res_port;
unsigned long cport; /* control base i/o port (CS4236) */ unsigned long cport; /* control base i/o port (CS4236) */
struct resource *res_cport; struct resource *res_cport;
int irq; /* IRQ line */ int irq; /* IRQ line */
int dma1; /* playback DMA */ int dma1; /* playback DMA */
int dma2; /* record DMA */ int dma2; /* record DMA */
#endif
unsigned short version; /* version of CODEC chip */ unsigned short version; /* version of CODEC chip */
unsigned short mode; /* see to CS4231_MODE_XXXX */ unsigned short mode; /* see to CS4231_MODE_XXXX */
unsigned short hardware; /* see to CS4231_HW_XXXX */ unsigned short hardware; /* see to CS4231_HW_XXXX */
...@@ -251,24 +234,6 @@ struct _snd_cs4231 { ...@@ -251,24 +234,6 @@ struct _snd_cs4231 {
unsigned short single_dma:1, /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */ unsigned short single_dma:1, /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */
ebus_flag:1; /* SPARC: EBUS present */ 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_card_t *card;
snd_pcm_t *pcm; snd_pcm_t *pcm;
snd_pcm_substream_t *playback_substream; snd_pcm_substream_t *playback_substream;
...@@ -281,10 +246,8 @@ struct _snd_cs4231 { ...@@ -281,10 +246,8 @@ struct _snd_cs4231 {
int mce_bit; int mce_bit;
int calibrate_mute; int calibrate_mute;
int sw_3d_bit; int sw_3d_bit;
#ifdef LEGACY_SUPPORT
unsigned int p_dma_size; unsigned int p_dma_size;
unsigned int c_dma_size; unsigned int c_dma_size;
#endif
spinlock_t reg_lock; spinlock_t reg_lock;
struct semaphore mce_mutex; struct semaphore mce_mutex;
...@@ -299,10 +262,8 @@ struct _snd_cs4231 { ...@@ -299,10 +262,8 @@ struct _snd_cs4231 {
void (*resume) (cs4231_t *chip); void (*resume) (cs4231_t *chip);
#endif #endif
void *dma_private_data; void *dma_private_data;
#ifdef LEGACY_SUPPORT
int (*claim_dma) (cs4231_t *chip, void *dma_private_data, int dma); int (*claim_dma) (cs4231_t *chip, void *dma_private_data, int dma);
int (*release_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 */ /* exported functions */
......
...@@ -124,46 +124,14 @@ static unsigned char snd_cs4231_original_image[32] = ...@@ -124,46 +124,14 @@ static unsigned char snd_cs4231_original_image[32] =
* Basic I/O functions * Basic I/O functions
*/ */
#if !defined(EBUS_SUPPORT) && !defined(SBUS_SUPPORT) static inline void cs4231_outb(cs4231_t *chip, u8 offset, u8 val)
#define __CS4231_INLINE__ inline
#else
#define __CS4231_INLINE__ /* nothing */
#endif
static __CS4231_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); 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); return inb(chip->port + offset);
#endif
} }
static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg,
...@@ -874,7 +842,6 @@ static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream) ...@@ -874,7 +842,6 @@ static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream)
return snd_pcm_lib_free_pages(substream); return snd_pcm_lib_free_pages(substream);
} }
#ifdef LEGACY_SUPPORT
static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream)
{ {
cs4231_t *chip = snd_pcm_substream_chip(substream); cs4231_t *chip = snd_pcm_substream_chip(substream);
...@@ -896,7 +863,6 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) ...@@ -896,7 +863,6 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream)
#endif #endif
return 0; return 0;
} }
#endif /* LEGACY_SUPPORT */
static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream,
snd_pcm_hw_params_t * hw_params) snd_pcm_hw_params_t * hw_params)
...@@ -918,7 +884,6 @@ static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream) ...@@ -918,7 +884,6 @@ static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream)
return snd_pcm_lib_free_pages(substream); return snd_pcm_lib_free_pages(substream);
} }
#ifdef LEGACY_SUPPORT
static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream)
{ {
cs4231_t *chip = snd_pcm_substream_chip(substream); cs4231_t *chip = snd_pcm_substream_chip(substream);
...@@ -942,7 +907,6 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) ...@@ -942,7 +907,6 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream)
spin_unlock_irqrestore(&chip->reg_lock, flags); spin_unlock_irqrestore(&chip->reg_lock, flags);
return 0; return 0;
} }
#endif
static void snd_cs4231_overrange(cs4231_t *chip) static void snd_cs4231_overrange(cs4231_t *chip)
{ {
...@@ -998,7 +962,6 @@ irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -998,7 +962,6 @@ irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
#ifdef LEGACY_SUPPORT
static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream) static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream)
{ {
cs4231_t *chip = snd_pcm_substream_chip(substream); cs4231_t *chip = snd_pcm_substream_chip(substream);
...@@ -1020,7 +983,6 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr ...@@ -1020,7 +983,6 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr
ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr); return bytes_to_frames(substream->runtime, ptr);
} }
#endif /* LEGACY_SUPPORT */
/* /*
...@@ -1253,7 +1215,6 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) ...@@ -1253,7 +1215,6 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream)
chip->hardware == CS4231_HW_CS4239) chip->hardware == CS4231_HW_CS4239)
runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; 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.buffer_bytes_max);
snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max);
...@@ -1261,20 +1222,14 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) ...@@ -1261,20 +1222,14 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream)
if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0) if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0)
return err; return err;
} }
#endif
if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) {
#ifdef LEGACY_SUPPORT
if (chip->release_dma) if (chip->release_dma)
chip->release_dma(chip, chip->dma_private_data, chip->dma1); chip->release_dma(chip, chip->dma_private_data, chip->dma1);
#endif
snd_free_pages(runtime->dma_area, runtime->dma_bytes); snd_free_pages(runtime->dma_area, runtime->dma_bytes);
return err; return err;
} }
chip->playback_substream = substream; chip->playback_substream = substream;
#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
chip->p_periods_sent = 0;
#endif
snd_pcm_set_sync(substream); snd_pcm_set_sync(substream);
chip->rate_constraint(runtime); chip->rate_constraint(runtime);
return 0; return 0;
...@@ -1293,7 +1248,6 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) ...@@ -1293,7 +1248,6 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream)
chip->hardware == CS4231_HW_CS4239) chip->hardware == CS4231_HW_CS4239)
runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; 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.buffer_bytes_max);
snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max);
...@@ -1301,20 +1255,14 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) ...@@ -1301,20 +1255,14 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream)
if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0) if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0)
return err; return err;
} }
#endif
if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) {
#ifdef LEGACY_SUPPORT
if (chip->release_dma) if (chip->release_dma)
chip->release_dma(chip, chip->dma_private_data, chip->dma2); chip->release_dma(chip, chip->dma_private_data, chip->dma2);
#endif
snd_free_pages(runtime->dma_area, runtime->dma_bytes); snd_free_pages(runtime->dma_area, runtime->dma_bytes);
return err; return err;
} }
chip->capture_substream = substream; chip->capture_substream = substream;
#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT)
chip->c_periods_sent = 0;
#endif
snd_pcm_set_sync(substream); snd_pcm_set_sync(substream);
chip->rate_constraint(runtime); chip->rate_constraint(runtime);
return 0; return 0;
...@@ -1413,8 +1361,6 @@ static int snd_cs4231_pm_resume(snd_card_t *card) ...@@ -1413,8 +1361,6 @@ static int snd_cs4231_pm_resume(snd_card_t *card)
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
#ifdef LEGACY_SUPPORT
static int snd_cs4231_free(cs4231_t *chip) static int snd_cs4231_free(cs4231_t *chip)
{ {
release_and_free_resource(chip->res_port); release_and_free_resource(chip->res_port);
...@@ -1444,8 +1390,6 @@ static int snd_cs4231_dev_free(snd_device_t *device) ...@@ -1444,8 +1390,6 @@ static int snd_cs4231_dev_free(snd_device_t *device)
return snd_cs4231_free(chip); return snd_cs4231_free(chip);
} }
#endif /* LEGACY_SUPPORT */
const char *snd_cs4231_chip_id(cs4231_t *chip) const char *snd_cs4231_chip_id(cs4231_t *chip)
{ {
switch (chip->hardware) { switch (chip->hardware) {
...@@ -1493,8 +1437,6 @@ static int snd_cs4231_new(snd_card_t * card, ...@@ -1493,8 +1437,6 @@ static int snd_cs4231_new(snd_card_t * card,
return 0; return 0;
} }
#ifdef LEGACY_SUPPORT
int snd_cs4231_create(snd_card_t * card, int snd_cs4231_create(snd_card_t * card,
unsigned long port, unsigned long port,
unsigned long cport, unsigned long cport,
...@@ -1581,8 +1523,6 @@ int snd_cs4231_create(snd_card_t * card, ...@@ -1581,8 +1523,6 @@ int snd_cs4231_create(snd_card_t * card,
return 0; return 0;
} }
#endif /* LEGACY_SUPPORT */
static snd_pcm_ops_t snd_cs4231_playback_ops = { static snd_pcm_ops_t snd_cs4231_playback_ops = {
.open = snd_cs4231_playback_open, .open = snd_cs4231_playback_open,
.close = snd_cs4231_playback_close, .close = snd_cs4231_playback_close,
...@@ -1629,27 +1569,9 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) ...@@ -1629,27 +1569,9 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm)
pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX;
strcpy(pcm->name, snd_cs4231_chip_id(chip)); strcpy(pcm->name, snd_cs4231_chip_id(chip));
#ifdef LEGACY_SUPPORT
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_isa_data(), snd_dma_isa_data(),
64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); 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; chip->pcm = pcm;
if (rpcm) if (rpcm)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册