Loading sound/sparc/cs4231.c +230 −150 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * Copyright (C) 2002 David S. Miller <davem@redhat.com> * * Based entirely upon drivers/sbus/audio/cs4231.c which is: * Copyright (C) 1996, 1997, 1998, 1998 Derrick J Brashear (shadow@andrew.cmu.edu) * Copyright (C) 1996, 1997, 1998 Derrick J Brashear (shadow@andrew.cmu.edu) * and also sound/isa/cs423x/cs4231_lib.c which is: * Copyright (c) by Jaroslav Kysela <perex@suse.cz> */ Loading @@ -15,6 +15,9 @@ #include <linux/init.h> #include <linux/interrupt.h> #include <linux/moduleparam.h> #include <linux/irq.h> #include <linux/io.h> #include <sound/driver.h> #include <sound/core.h> Loading @@ -25,9 +28,6 @@ #include <sound/initval.h> #include <sound/pcm_params.h> #include <asm/io.h> #include <asm/irq.h> #ifdef CONFIG_SBUS #define SBUS_SUPPORT #include <asm/sbus.h> Loading @@ -41,7 +41,8 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ /* Enable this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for Sun CS4231 soundcard."); Loading @@ -56,7 +57,7 @@ MODULE_SUPPORTED_DEVICE("{{Sun,CS4231}}"); #ifdef SBUS_SUPPORT struct sbus_dma_info { spinlock_t lock; spinlock_t lock; /* DMA access lock */ int dir; void __iomem *regs; }; Loading @@ -64,11 +65,14 @@ struct sbus_dma_info { struct snd_cs4231; struct cs4231_dma_control { void (*prepare)(struct cs4231_dma_control *dma_cont, int dir); void (*prepare)(struct cs4231_dma_control *dma_cont, int dir); void (*enable)(struct cs4231_dma_control *dma_cont, int on); int (*request)(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len); int (*request)(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len); unsigned int (*address)(struct cs4231_dma_control *dma_cont); void (*preallocate)(struct snd_cs4231 *chip, struct snd_pcm *pcm); void (*preallocate)(struct snd_cs4231 *chip, struct snd_pcm *pcm); #ifdef EBUS_SUPPORT struct ebus_dma_info ebus_info; #endif Loading @@ -78,7 +82,7 @@ struct cs4231_dma_control { }; struct snd_cs4231 { spinlock_t lock; spinlock_t lock; /* registers access lock */ void __iomem *port; struct cs4231_dma_control p_dma; Loading @@ -102,13 +106,14 @@ struct snd_cs4231 { #define CS4231_MODE_PLAY 0x0001 #define CS4231_MODE_RECORD 0x0002 #define CS4231_MODE_TIMER 0x0004 #define CS4231_MODE_OPEN (CS4231_MODE_PLAY|CS4231_MODE_RECORD|CS4231_MODE_TIMER) #define CS4231_MODE_OPEN (CS4231_MODE_PLAY | CS4231_MODE_RECORD | \ CS4231_MODE_TIMER) unsigned char image[32]; /* registers image */ int mce_bit; int calibrate_mute; struct mutex mce_mutex; struct mutex open_mutex; struct mutex mce_mutex; /* mutex for mce register */ struct mutex open_mutex; /* mutex for ALSA open/close */ union { #ifdef SBUS_SUPPORT Loading Loading @@ -392,7 +397,8 @@ static u8 __cs4231_readb(struct snd_cs4231 *cp, void __iomem *reg_addr) #endif } static void __cs4231_writeb(struct snd_cs4231 *cp, u8 val, void __iomem *reg_addr) static void __cs4231_writeb(struct snd_cs4231 *cp, u8 val, void __iomem *reg_addr) { #ifdef EBUS_SUPPORT if (cp->flags & CS4231_FLAG_EBUS) Loading @@ -418,7 +424,8 @@ static void snd_cs4231_ready(struct snd_cs4231 *chip) udelay(100); } static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { snd_cs4231_ready(chip); #ifdef CONFIG_SND_DEBUG Loading Loading @@ -472,7 +479,7 @@ static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) { int timeout; /* huh.. looks like this sequence is proper for CS4231A chip (GUS MAX) */ /* looks like this sequence is proper for CS4231A chip (GUS MAX) */ for (timeout = 5; timeout > 0; timeout--) __cs4231_readb(chip, CS4231P(chip, REGSEL)); Loading @@ -497,7 +504,9 @@ static void snd_cs4231_mce_up(struct snd_cs4231 *chip) chip->mce_bit |= CS4231_MCE; timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); if (timeout == 0x80) snd_printdd("mce_up [%p]: serious init problem - codec still busy\n", chip->port); snd_printdd("mce_up [%p]: serious init problem - " "codec still busy\n", chip->port); if (!(timeout & CS4231_MCE)) __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); spin_unlock_irqrestore(&chip->lock, flags); Loading @@ -518,7 +527,9 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); if (timeout == 0x80) snd_printdd("mce_down [%p]: serious init problem - codec still busy\n", chip->port); snd_printdd("mce_down [%p]: serious init problem - " "codec still busy\n", chip->port); if ((timeout & CS4231_MCE) == 0) { spin_unlock_irqrestore(&chip->lock, flags); return; Loading @@ -529,7 +540,8 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) snd_cs4231_ready(chip); snd_cs4231_ready(chip); if ((snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) == 0) { timeout = snd_cs4231_in(chip, CS4231_TEST_INIT); if ((timeout & CS4231_CALIB_IN_PROGRESS) == 0) { snd_printd("cs4231_mce_down - auto calibration time out (1)\n"); spin_unlock_irqrestore(&chip->lock, flags); return; Loading @@ -537,10 +549,13 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) /* in 10ms increments, check condition, up to 250ms */ timeout = 25; while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) { while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) { spin_unlock_irqrestore(&chip->lock, flags); if (--timeout < 0) { snd_printk("mce_down - auto calibration time out (2)\n"); snd_printk("mce_down - " "auto calibration time out (2)\n"); return; } msleep(10); Loading @@ -552,7 +567,8 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) while (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) { spin_unlock_irqrestore(&chip->lock, flags); if (--timeout < 0) { snd_printk("mce_down - auto calibration time out (3)\n"); snd_printk("mce_down - " "auto calibration time out (3)\n"); return; } msleep(10); Loading @@ -573,7 +589,8 @@ static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont, BUG_ON(period_size >= (1 << 24)); if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size)) if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size)) return; (*periods_sent) = ((*periods_sent) + 1) % runtime->periods; } Loading Loading @@ -666,21 +683,32 @@ static unsigned char snd_cs4231_get_rate(unsigned int rate) for (i = 0; i < 14; i++) if (rate == rates[i]) return freq_bits[i]; // snd_BUG(); return freq_bits[13]; } static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, int channels) static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, int channels) { unsigned char rformat; rformat = CS4231_LINEAR_8; switch (format) { case SNDRV_PCM_FORMAT_MU_LAW: rformat = CS4231_ULAW_8; break; case SNDRV_PCM_FORMAT_A_LAW: rformat = CS4231_ALAW_8; break; case SNDRV_PCM_FORMAT_S16_LE: rformat = CS4231_LINEAR_16; break; case SNDRV_PCM_FORMAT_S16_BE: rformat = CS4231_LINEAR_16_BIG; break; case SNDRV_PCM_FORMAT_IMA_ADPCM: rformat = CS4231_ADPCM_16; break; case SNDRV_PCM_FORMAT_MU_LAW: rformat = CS4231_ULAW_8; break; case SNDRV_PCM_FORMAT_A_LAW: rformat = CS4231_ALAW_8; break; case SNDRV_PCM_FORMAT_S16_LE: rformat = CS4231_LINEAR_16; break; case SNDRV_PCM_FORMAT_S16_BE: rformat = CS4231_LINEAR_16_BIG; break; case SNDRV_PCM_FORMAT_IMA_ADPCM: rformat = CS4231_ADPCM_16; break; } if (channels > 1) rformat |= CS4231_STEREO; Loading Loading @@ -727,7 +755,8 @@ static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) spin_unlock_irqrestore(&chip->lock, flags); } static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char pdfr) { unsigned long flags; Loading @@ -750,7 +779,8 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_h mutex_unlock(&chip->mce_mutex); } static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char cdfr) { unsigned long flags; Loading Loading @@ -808,7 +838,8 @@ static int snd_cs4231_timer_start(struct snd_timer *timer) chip->image[CS4231_TIMER_LOW] = (unsigned char) ticks); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] | CS4231_TIMER_ENABLE); chip->image[CS4231_ALT_FEATURE_1] | CS4231_TIMER_ENABLE); } spin_unlock_irqrestore(&chip->lock, flags); Loading @@ -821,8 +852,9 @@ static int snd_cs4231_timer_stop(struct snd_timer *timer) struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE; snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE); chip->image[CS4231_ALT_FEATURE_1]); spin_unlock_irqrestore(&chip->lock, flags); return 0; Loading @@ -839,8 +871,10 @@ static void __init snd_cs4231_init(struct snd_cs4231 *chip) #endif snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->lock, flags); chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | CS4231_RECORD_ENABLE | CS4231_RECORD_PIO | chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | CS4231_RECORD_ENABLE | CS4231_RECORD_PIO | CS4231_CALIB_MODE); chip->image[CS4231_IFACE_CTRL] |= CS4231_AUTOCALIB; snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); Loading @@ -853,21 +887,25 @@ static void __init snd_cs4231_init(struct snd_cs4231 *chip) snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_down(chip); #ifdef SNDRV_DEBUG_MCE snd_printdd("init: (3) - afei = 0x%x\n", chip->image[CS4231_ALT_FEATURE_1]); snd_printdd("init: (3) - afei = 0x%x\n", chip->image[CS4231_ALT_FEATURE_1]); #endif spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_ALT_FEATURE_2, chip->image[CS4231_ALT_FEATURE_2]); snd_cs4231_out(chip, CS4231_ALT_FEATURE_2, chip->image[CS4231_ALT_FEATURE_2]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, chip->image[CS4231_PLAYBK_FORMAT]); snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, chip->image[CS4231_PLAYBK_FORMAT]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_down(chip); Loading Loading @@ -950,7 +988,8 @@ static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | CS4231_RECORD_ENABLE | CS4231_RECORD_PIO); snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_down(chip); spin_lock_irqsave(&chip->lock, flags); Loading Loading @@ -986,8 +1025,7 @@ static int snd_cs4231_timer_close(struct snd_timer * timer) return 0; } static struct snd_timer_hardware snd_cs4231_timer_table = { static struct snd_timer_hardware snd_cs4231_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 9945, .ticks = 65535, Loading @@ -1009,8 +1047,9 @@ static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, unsigned char new_pdfr; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | Loading Loading @@ -1046,8 +1085,9 @@ static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, unsigned char new_cdfr; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | Loading Loading @@ -1082,7 +1122,8 @@ static void snd_cs4231_overrange(struct snd_cs4231 *chip) res = snd_cs4231_in(chip, CS4231_TEST_INIT); spin_unlock_irqrestore(&chip->lock, flags); if (res & (0x08 | 0x02)) /* detect overrange only above 0dB; may be user selectable? */ /* detect overrange only above 0dB; may be user selectable? */ if (res & (0x08 | 0x02)) chip->capture_substream->runtime->overrange++; } Loading @@ -1104,7 +1145,8 @@ static void snd_cs4231_capture_callback(struct snd_cs4231 *chip) } } static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t snd_cs4231_playback_pointer( struct snd_pcm_substream *substream) { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); struct cs4231_dma_control *dma_cont = &chip->p_dma; Loading @@ -1119,7 +1161,8 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *s return bytes_to_frames(substream->runtime, ptr); } static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t snd_cs4231_capture_pointer( struct snd_pcm_substream *substream) { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); struct cs4231_dma_control *dma_cont = &chip->c_dma; Loading @@ -1137,14 +1180,15 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *su static int __init snd_cs4231_probe(struct snd_cs4231 *chip) { unsigned long flags; int i, id, vers; int i; int id = 0; int vers = 0; unsigned char *ptr; id = vers = 0; for (i = 0; i < 50; i++) { mb(); if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) udelay(2000); msleep(2); else { spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_MISC_INFO, CS4231_MODE2); Loading Loading @@ -1195,42 +1239,50 @@ static int __init snd_cs4231_probe(struct snd_cs4231 *chip) return 0; /* all things are ok.. */ } static struct snd_pcm_hardware snd_cs4231_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | static struct snd_pcm_hardware snd_cs4231_playback = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START, .formats = SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE), .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, .rate_min = 5510, .rate_max = 48000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = (32*1024), .buffer_bytes_max = 32 * 1024, .period_bytes_min = 64, .period_bytes_max = (32*1024), .period_bytes_max = 32 * 1024, .periods_min = 1, .periods_max = 1024, }; static struct snd_pcm_hardware snd_cs4231_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | static struct snd_pcm_hardware snd_cs4231_capture = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START, .formats = SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE), .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, .rate_min = 5510, .rate_max = 48000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = (32*1024), .buffer_bytes_max = 32 * 1024, .period_bytes_min = 64, .period_bytes_max = (32*1024), .period_bytes_max = 32 * 1024, .periods_min = 1, .periods_max = 1024, }; Loading @@ -1243,7 +1295,8 @@ static int snd_cs4231_playback_open(struct snd_pcm_substream *substream) runtime->hw = snd_cs4231_playback; if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { err = snd_cs4231_open(chip, CS4231_MODE_PLAY); if (err < 0) { snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } Loading @@ -1263,7 +1316,8 @@ static int snd_cs4231_capture_open(struct snd_pcm_substream *substream) runtime->hw = snd_cs4231_capture; if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { err = snd_cs4231_open(chip, CS4231_MODE_RECORD); if (err < 0) { snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } Loading Loading @@ -1331,8 +1385,10 @@ static int __init snd_cs4231_pcm(struct snd_card *card) if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs4231_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cs4231_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs4231_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cs4231_capture_ops); /* global setup */ pcm->private_data = chip; Loading Loading @@ -1386,7 +1442,8 @@ static int snd_cs4231_info_mux(struct snd_kcontrol *kcontrol, uinfo->value.enumerated.items = 4; if (uinfo->value.enumerated.item > 3) uinfo->value.enumerated.item = 3; strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); return 0; } Loading Loading @@ -1528,8 +1585,10 @@ static int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, spin_lock_irqsave(&chip->lock, flags); ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask; ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask; ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask; ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask; spin_unlock_irqrestore(&chip->lock, flags); Loading Loading @@ -1570,7 +1629,8 @@ static int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; change = val1 != chip->image[left_reg] || val2 != chip->image[right_reg]; change = val1 != chip->image[left_reg]; change |= val2 != chip->image[right_reg]; snd_cs4231_out(chip, left_reg, val1); snd_cs4231_out(chip, right_reg, val2); Loading @@ -1580,31 +1640,42 @@ static int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, } #define CS4231_SINGLE(xname, xindex, reg, shift, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .index = (xindex), \ .info = snd_cs4231_info_single, \ .get = snd_cs4231_get_single, .put = snd_cs4231_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } .private_value = (reg) | ((shift) << 8) | ((mask) << 16) | ((invert) << 24) } #define CS4231_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ #define CS4231_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, \ shift_right, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .index = (xindex), \ .info = snd_cs4231_info_double, \ .get = snd_cs4231_get_double, .put = snd_cs4231_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } .private_value = (left_reg) | ((right_reg) << 8) | ((shift_left) << 16) | \ ((shift_right) << 19) | ((mask) << 24) | ((invert) << 22) } static struct snd_kcontrol_new snd_cs4231_controls[] __initdata = { CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), CS4231_DOUBLE("Line Playback Volume", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), CS4231_DOUBLE("Line Playback Volume", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), CS4231_SINGLE("Mono Playback Switch", 0, CS4231_MONO_CTRL, 7, 1, 1), CS4231_SINGLE("Mono Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), CS4231_SINGLE("Mono Output Playback Switch", 0, CS4231_MONO_CTRL, 6, 1, 1), CS4231_SINGLE("Mono Output Playback Bypass", 0, CS4231_MONO_CTRL, 5, 1, 0), CS4231_DOUBLE("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), CS4231_DOUBLE("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Source", Loading @@ -1612,7 +1683,8 @@ CS4231_DOUBLE("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, .get = snd_cs4231_get_mux, .put = snd_cs4231_put_mux, }, CS4231_DOUBLE("Mic Boost", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), CS4231_DOUBLE("Mic Boost", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), CS4231_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1), /* SPARC specific uses of XCTL{0,1} general purpose outputs. */ Loading Loading @@ -1754,7 +1826,8 @@ static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id) * SBUS DMA routines */ static int sbus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) static int sbus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) { unsigned long flags; u32 test, csr; Loading Loading @@ -1972,14 +2045,16 @@ static int __init cs4231_sbus_attach(struct sbus_dev *sdev) #ifdef EBUS_SUPPORT static void snd_cs4231_ebus_play_callback(struct ebus_dma_info *p, int event, void *cookie) static void snd_cs4231_ebus_play_callback(struct ebus_dma_info *p, int event, void *cookie) { struct snd_cs4231 *chip = cookie; snd_cs4231_play_callback(chip); } static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, void *cookie) static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, void *cookie) { struct snd_cs4231 *chip = cookie; Loading @@ -1990,7 +2065,8 @@ static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, * EBUS DMA wrappers */ static int _ebus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) static int _ebus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) { return ebus_dma_request(&dma_cont->ebus_info, bus_addr, len); } Loading Loading @@ -2091,7 +2167,8 @@ static int __init snd_cs4231_ebus_create(struct snd_card *card, chip->port = ioremap(edev->resource[0].start, 0x10); chip->p_dma.ebus_info.regs = ioremap(edev->resource[1].start, 0x10); chip->c_dma.ebus_info.regs = ioremap(edev->resource[2].start, 0x10); if (!chip->port || !chip->p_dma.ebus_info.regs || !chip->c_dma.ebus_info.regs) { if (!chip->port || !chip->p_dma.ebus_info.regs || !chip->c_dma.ebus_info.regs) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev); return -EIO; Loading @@ -2099,18 +2176,21 @@ static int __init snd_cs4231_ebus_create(struct snd_card *card, if (ebus_dma_register(&chip->c_dma.ebus_info)) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to register EBUS capture DMA\n", dev); snd_printdd("cs4231-%d: Unable to register EBUS capture DMA\n", dev); return -EBUSY; } if (ebus_dma_irq_enable(&chip->c_dma.ebus_info, 1)) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to enable EBUS capture IRQ\n", dev); snd_printdd("cs4231-%d: Unable to enable EBUS capture IRQ\n", dev); return -EBUSY; } if (ebus_dma_register(&chip->p_dma.ebus_info)) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to register EBUS play DMA\n", dev); snd_printdd("cs4231-%d: Unable to register EBUS play DMA\n", dev); return -EBUSY; } if (ebus_dma_irq_enable(&chip->p_dma.ebus_info, 1)) { Loading Loading
sound/sparc/cs4231.c +230 −150 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * Copyright (C) 2002 David S. Miller <davem@redhat.com> * * Based entirely upon drivers/sbus/audio/cs4231.c which is: * Copyright (C) 1996, 1997, 1998, 1998 Derrick J Brashear (shadow@andrew.cmu.edu) * Copyright (C) 1996, 1997, 1998 Derrick J Brashear (shadow@andrew.cmu.edu) * and also sound/isa/cs423x/cs4231_lib.c which is: * Copyright (c) by Jaroslav Kysela <perex@suse.cz> */ Loading @@ -15,6 +15,9 @@ #include <linux/init.h> #include <linux/interrupt.h> #include <linux/moduleparam.h> #include <linux/irq.h> #include <linux/io.h> #include <sound/driver.h> #include <sound/core.h> Loading @@ -25,9 +28,6 @@ #include <sound/initval.h> #include <sound/pcm_params.h> #include <asm/io.h> #include <asm/irq.h> #ifdef CONFIG_SBUS #define SBUS_SUPPORT #include <asm/sbus.h> Loading @@ -41,7 +41,8 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ /* Enable this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for Sun CS4231 soundcard."); Loading @@ -56,7 +57,7 @@ MODULE_SUPPORTED_DEVICE("{{Sun,CS4231}}"); #ifdef SBUS_SUPPORT struct sbus_dma_info { spinlock_t lock; spinlock_t lock; /* DMA access lock */ int dir; void __iomem *regs; }; Loading @@ -64,11 +65,14 @@ struct sbus_dma_info { struct snd_cs4231; struct cs4231_dma_control { void (*prepare)(struct cs4231_dma_control *dma_cont, int dir); void (*prepare)(struct cs4231_dma_control *dma_cont, int dir); void (*enable)(struct cs4231_dma_control *dma_cont, int on); int (*request)(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len); int (*request)(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len); unsigned int (*address)(struct cs4231_dma_control *dma_cont); void (*preallocate)(struct snd_cs4231 *chip, struct snd_pcm *pcm); void (*preallocate)(struct snd_cs4231 *chip, struct snd_pcm *pcm); #ifdef EBUS_SUPPORT struct ebus_dma_info ebus_info; #endif Loading @@ -78,7 +82,7 @@ struct cs4231_dma_control { }; struct snd_cs4231 { spinlock_t lock; spinlock_t lock; /* registers access lock */ void __iomem *port; struct cs4231_dma_control p_dma; Loading @@ -102,13 +106,14 @@ struct snd_cs4231 { #define CS4231_MODE_PLAY 0x0001 #define CS4231_MODE_RECORD 0x0002 #define CS4231_MODE_TIMER 0x0004 #define CS4231_MODE_OPEN (CS4231_MODE_PLAY|CS4231_MODE_RECORD|CS4231_MODE_TIMER) #define CS4231_MODE_OPEN (CS4231_MODE_PLAY | CS4231_MODE_RECORD | \ CS4231_MODE_TIMER) unsigned char image[32]; /* registers image */ int mce_bit; int calibrate_mute; struct mutex mce_mutex; struct mutex open_mutex; struct mutex mce_mutex; /* mutex for mce register */ struct mutex open_mutex; /* mutex for ALSA open/close */ union { #ifdef SBUS_SUPPORT Loading Loading @@ -392,7 +397,8 @@ static u8 __cs4231_readb(struct snd_cs4231 *cp, void __iomem *reg_addr) #endif } static void __cs4231_writeb(struct snd_cs4231 *cp, u8 val, void __iomem *reg_addr) static void __cs4231_writeb(struct snd_cs4231 *cp, u8 val, void __iomem *reg_addr) { #ifdef EBUS_SUPPORT if (cp->flags & CS4231_FLAG_EBUS) Loading @@ -418,7 +424,8 @@ static void snd_cs4231_ready(struct snd_cs4231 *chip) udelay(100); } static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { snd_cs4231_ready(chip); #ifdef CONFIG_SND_DEBUG Loading Loading @@ -472,7 +479,7 @@ static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) { int timeout; /* huh.. looks like this sequence is proper for CS4231A chip (GUS MAX) */ /* looks like this sequence is proper for CS4231A chip (GUS MAX) */ for (timeout = 5; timeout > 0; timeout--) __cs4231_readb(chip, CS4231P(chip, REGSEL)); Loading @@ -497,7 +504,9 @@ static void snd_cs4231_mce_up(struct snd_cs4231 *chip) chip->mce_bit |= CS4231_MCE; timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); if (timeout == 0x80) snd_printdd("mce_up [%p]: serious init problem - codec still busy\n", chip->port); snd_printdd("mce_up [%p]: serious init problem - " "codec still busy\n", chip->port); if (!(timeout & CS4231_MCE)) __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); spin_unlock_irqrestore(&chip->lock, flags); Loading @@ -518,7 +527,9 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); if (timeout == 0x80) snd_printdd("mce_down [%p]: serious init problem - codec still busy\n", chip->port); snd_printdd("mce_down [%p]: serious init problem - " "codec still busy\n", chip->port); if ((timeout & CS4231_MCE) == 0) { spin_unlock_irqrestore(&chip->lock, flags); return; Loading @@ -529,7 +540,8 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) snd_cs4231_ready(chip); snd_cs4231_ready(chip); if ((snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) == 0) { timeout = snd_cs4231_in(chip, CS4231_TEST_INIT); if ((timeout & CS4231_CALIB_IN_PROGRESS) == 0) { snd_printd("cs4231_mce_down - auto calibration time out (1)\n"); spin_unlock_irqrestore(&chip->lock, flags); return; Loading @@ -537,10 +549,13 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) /* in 10ms increments, check condition, up to 250ms */ timeout = 25; while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) { while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) { spin_unlock_irqrestore(&chip->lock, flags); if (--timeout < 0) { snd_printk("mce_down - auto calibration time out (2)\n"); snd_printk("mce_down - " "auto calibration time out (2)\n"); return; } msleep(10); Loading @@ -552,7 +567,8 @@ static void snd_cs4231_mce_down(struct snd_cs4231 *chip) while (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) { spin_unlock_irqrestore(&chip->lock, flags); if (--timeout < 0) { snd_printk("mce_down - auto calibration time out (3)\n"); snd_printk("mce_down - " "auto calibration time out (3)\n"); return; } msleep(10); Loading @@ -573,7 +589,8 @@ static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont, BUG_ON(period_size >= (1 << 24)); if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size)) if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size)) return; (*periods_sent) = ((*periods_sent) + 1) % runtime->periods; } Loading Loading @@ -666,21 +683,32 @@ static unsigned char snd_cs4231_get_rate(unsigned int rate) for (i = 0; i < 14; i++) if (rate == rates[i]) return freq_bits[i]; // snd_BUG(); return freq_bits[13]; } static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, int channels) static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, int channels) { unsigned char rformat; rformat = CS4231_LINEAR_8; switch (format) { case SNDRV_PCM_FORMAT_MU_LAW: rformat = CS4231_ULAW_8; break; case SNDRV_PCM_FORMAT_A_LAW: rformat = CS4231_ALAW_8; break; case SNDRV_PCM_FORMAT_S16_LE: rformat = CS4231_LINEAR_16; break; case SNDRV_PCM_FORMAT_S16_BE: rformat = CS4231_LINEAR_16_BIG; break; case SNDRV_PCM_FORMAT_IMA_ADPCM: rformat = CS4231_ADPCM_16; break; case SNDRV_PCM_FORMAT_MU_LAW: rformat = CS4231_ULAW_8; break; case SNDRV_PCM_FORMAT_A_LAW: rformat = CS4231_ALAW_8; break; case SNDRV_PCM_FORMAT_S16_LE: rformat = CS4231_LINEAR_16; break; case SNDRV_PCM_FORMAT_S16_BE: rformat = CS4231_LINEAR_16_BIG; break; case SNDRV_PCM_FORMAT_IMA_ADPCM: rformat = CS4231_ADPCM_16; break; } if (channels > 1) rformat |= CS4231_STEREO; Loading Loading @@ -727,7 +755,8 @@ static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) spin_unlock_irqrestore(&chip->lock, flags); } static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char pdfr) { unsigned long flags; Loading @@ -750,7 +779,8 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_h mutex_unlock(&chip->mce_mutex); } static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char cdfr) { unsigned long flags; Loading Loading @@ -808,7 +838,8 @@ static int snd_cs4231_timer_start(struct snd_timer *timer) chip->image[CS4231_TIMER_LOW] = (unsigned char) ticks); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] | CS4231_TIMER_ENABLE); chip->image[CS4231_ALT_FEATURE_1] | CS4231_TIMER_ENABLE); } spin_unlock_irqrestore(&chip->lock, flags); Loading @@ -821,8 +852,9 @@ static int snd_cs4231_timer_stop(struct snd_timer *timer) struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE; snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE); chip->image[CS4231_ALT_FEATURE_1]); spin_unlock_irqrestore(&chip->lock, flags); return 0; Loading @@ -839,8 +871,10 @@ static void __init snd_cs4231_init(struct snd_cs4231 *chip) #endif snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->lock, flags); chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | CS4231_RECORD_ENABLE | CS4231_RECORD_PIO | chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | CS4231_RECORD_ENABLE | CS4231_RECORD_PIO | CS4231_CALIB_MODE); chip->image[CS4231_IFACE_CTRL] |= CS4231_AUTOCALIB; snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); Loading @@ -853,21 +887,25 @@ static void __init snd_cs4231_init(struct snd_cs4231 *chip) snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_down(chip); #ifdef SNDRV_DEBUG_MCE snd_printdd("init: (3) - afei = 0x%x\n", chip->image[CS4231_ALT_FEATURE_1]); snd_printdd("init: (3) - afei = 0x%x\n", chip->image[CS4231_ALT_FEATURE_1]); #endif spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_ALT_FEATURE_2, chip->image[CS4231_ALT_FEATURE_2]); snd_cs4231_out(chip, CS4231_ALT_FEATURE_2, chip->image[CS4231_ALT_FEATURE_2]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, chip->image[CS4231_PLAYBK_FORMAT]); snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, chip->image[CS4231_PLAYBK_FORMAT]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_down(chip); Loading Loading @@ -950,7 +988,8 @@ static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | CS4231_RECORD_ENABLE | CS4231_RECORD_PIO); snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); spin_unlock_irqrestore(&chip->lock, flags); snd_cs4231_mce_down(chip); spin_lock_irqsave(&chip->lock, flags); Loading Loading @@ -986,8 +1025,7 @@ static int snd_cs4231_timer_close(struct snd_timer * timer) return 0; } static struct snd_timer_hardware snd_cs4231_timer_table = { static struct snd_timer_hardware snd_cs4231_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 9945, .ticks = 65535, Loading @@ -1009,8 +1047,9 @@ static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, unsigned char new_pdfr; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | Loading Loading @@ -1046,8 +1085,9 @@ static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, unsigned char new_cdfr; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | Loading Loading @@ -1082,7 +1122,8 @@ static void snd_cs4231_overrange(struct snd_cs4231 *chip) res = snd_cs4231_in(chip, CS4231_TEST_INIT); spin_unlock_irqrestore(&chip->lock, flags); if (res & (0x08 | 0x02)) /* detect overrange only above 0dB; may be user selectable? */ /* detect overrange only above 0dB; may be user selectable? */ if (res & (0x08 | 0x02)) chip->capture_substream->runtime->overrange++; } Loading @@ -1104,7 +1145,8 @@ static void snd_cs4231_capture_callback(struct snd_cs4231 *chip) } } static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t snd_cs4231_playback_pointer( struct snd_pcm_substream *substream) { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); struct cs4231_dma_control *dma_cont = &chip->p_dma; Loading @@ -1119,7 +1161,8 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *s return bytes_to_frames(substream->runtime, ptr); } static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *substream) static snd_pcm_uframes_t snd_cs4231_capture_pointer( struct snd_pcm_substream *substream) { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); struct cs4231_dma_control *dma_cont = &chip->c_dma; Loading @@ -1137,14 +1180,15 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *su static int __init snd_cs4231_probe(struct snd_cs4231 *chip) { unsigned long flags; int i, id, vers; int i; int id = 0; int vers = 0; unsigned char *ptr; id = vers = 0; for (i = 0; i < 50; i++) { mb(); if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) udelay(2000); msleep(2); else { spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_MISC_INFO, CS4231_MODE2); Loading Loading @@ -1195,42 +1239,50 @@ static int __init snd_cs4231_probe(struct snd_cs4231 *chip) return 0; /* all things are ok.. */ } static struct snd_pcm_hardware snd_cs4231_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | static struct snd_pcm_hardware snd_cs4231_playback = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START, .formats = SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE), .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, .rate_min = 5510, .rate_max = 48000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = (32*1024), .buffer_bytes_max = 32 * 1024, .period_bytes_min = 64, .period_bytes_max = (32*1024), .period_bytes_max = 32 * 1024, .periods_min = 1, .periods_max = 1024, }; static struct snd_pcm_hardware snd_cs4231_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | static struct snd_pcm_hardware snd_cs4231_capture = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START, .formats = SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE), .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, .rate_min = 5510, .rate_max = 48000, .channels_min = 1, .channels_max = 2, .buffer_bytes_max = (32*1024), .buffer_bytes_max = 32 * 1024, .period_bytes_min = 64, .period_bytes_max = (32*1024), .period_bytes_max = 32 * 1024, .periods_min = 1, .periods_max = 1024, }; Loading @@ -1243,7 +1295,8 @@ static int snd_cs4231_playback_open(struct snd_pcm_substream *substream) runtime->hw = snd_cs4231_playback; if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { err = snd_cs4231_open(chip, CS4231_MODE_PLAY); if (err < 0) { snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } Loading @@ -1263,7 +1316,8 @@ static int snd_cs4231_capture_open(struct snd_pcm_substream *substream) runtime->hw = snd_cs4231_capture; if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { err = snd_cs4231_open(chip, CS4231_MODE_RECORD); if (err < 0) { snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } Loading Loading @@ -1331,8 +1385,10 @@ static int __init snd_cs4231_pcm(struct snd_card *card) if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs4231_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cs4231_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs4231_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cs4231_capture_ops); /* global setup */ pcm->private_data = chip; Loading Loading @@ -1386,7 +1442,8 @@ static int snd_cs4231_info_mux(struct snd_kcontrol *kcontrol, uinfo->value.enumerated.items = 4; if (uinfo->value.enumerated.item > 3) uinfo->value.enumerated.item = 3; strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); return 0; } Loading Loading @@ -1528,8 +1585,10 @@ static int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, spin_lock_irqsave(&chip->lock, flags); ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask; ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask; ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask; ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask; spin_unlock_irqrestore(&chip->lock, flags); Loading Loading @@ -1570,7 +1629,8 @@ static int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; change = val1 != chip->image[left_reg] || val2 != chip->image[right_reg]; change = val1 != chip->image[left_reg]; change |= val2 != chip->image[right_reg]; snd_cs4231_out(chip, left_reg, val1); snd_cs4231_out(chip, right_reg, val2); Loading @@ -1580,31 +1640,42 @@ static int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, } #define CS4231_SINGLE(xname, xindex, reg, shift, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .index = (xindex), \ .info = snd_cs4231_info_single, \ .get = snd_cs4231_get_single, .put = snd_cs4231_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } .private_value = (reg) | ((shift) << 8) | ((mask) << 16) | ((invert) << 24) } #define CS4231_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ #define CS4231_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, \ shift_right, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .index = (xindex), \ .info = snd_cs4231_info_double, \ .get = snd_cs4231_get_double, .put = snd_cs4231_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } .private_value = (left_reg) | ((right_reg) << 8) | ((shift_left) << 16) | \ ((shift_right) << 19) | ((mask) << 24) | ((invert) << 22) } static struct snd_kcontrol_new snd_cs4231_controls[] __initdata = { CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), CS4231_DOUBLE("Line Playback Volume", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), CS4231_DOUBLE("Line Playback Volume", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 0, CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), CS4231_DOUBLE("Aux Playback Switch", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Aux Playback Volume", 1, CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), CS4231_SINGLE("Mono Playback Switch", 0, CS4231_MONO_CTRL, 7, 1, 1), CS4231_SINGLE("Mono Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), CS4231_SINGLE("Mono Output Playback Switch", 0, CS4231_MONO_CTRL, 6, 1, 1), CS4231_SINGLE("Mono Output Playback Bypass", 0, CS4231_MONO_CTRL, 5, 1, 0), CS4231_DOUBLE("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), CS4231_DOUBLE("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Source", Loading @@ -1612,7 +1683,8 @@ CS4231_DOUBLE("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, .get = snd_cs4231_get_mux, .put = snd_cs4231_put_mux, }, CS4231_DOUBLE("Mic Boost", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), CS4231_DOUBLE("Mic Boost", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), CS4231_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1), /* SPARC specific uses of XCTL{0,1} general purpose outputs. */ Loading Loading @@ -1754,7 +1826,8 @@ static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id) * SBUS DMA routines */ static int sbus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) static int sbus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) { unsigned long flags; u32 test, csr; Loading Loading @@ -1972,14 +2045,16 @@ static int __init cs4231_sbus_attach(struct sbus_dev *sdev) #ifdef EBUS_SUPPORT static void snd_cs4231_ebus_play_callback(struct ebus_dma_info *p, int event, void *cookie) static void snd_cs4231_ebus_play_callback(struct ebus_dma_info *p, int event, void *cookie) { struct snd_cs4231 *chip = cookie; snd_cs4231_play_callback(chip); } static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, void *cookie) static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, void *cookie) { struct snd_cs4231 *chip = cookie; Loading @@ -1990,7 +2065,8 @@ static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, * EBUS DMA wrappers */ static int _ebus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) static int _ebus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) { return ebus_dma_request(&dma_cont->ebus_info, bus_addr, len); } Loading Loading @@ -2091,7 +2167,8 @@ static int __init snd_cs4231_ebus_create(struct snd_card *card, chip->port = ioremap(edev->resource[0].start, 0x10); chip->p_dma.ebus_info.regs = ioremap(edev->resource[1].start, 0x10); chip->c_dma.ebus_info.regs = ioremap(edev->resource[2].start, 0x10); if (!chip->port || !chip->p_dma.ebus_info.regs || !chip->c_dma.ebus_info.regs) { if (!chip->port || !chip->p_dma.ebus_info.regs || !chip->c_dma.ebus_info.regs) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev); return -EIO; Loading @@ -2099,18 +2176,21 @@ static int __init snd_cs4231_ebus_create(struct snd_card *card, if (ebus_dma_register(&chip->c_dma.ebus_info)) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to register EBUS capture DMA\n", dev); snd_printdd("cs4231-%d: Unable to register EBUS capture DMA\n", dev); return -EBUSY; } if (ebus_dma_irq_enable(&chip->c_dma.ebus_info, 1)) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to enable EBUS capture IRQ\n", dev); snd_printdd("cs4231-%d: Unable to enable EBUS capture IRQ\n", dev); return -EBUSY; } if (ebus_dma_register(&chip->p_dma.ebus_info)) { snd_cs4231_ebus_free(chip); snd_printdd("cs4231-%d: Unable to register EBUS play DMA\n", dev); snd_printdd("cs4231-%d: Unable to register EBUS play DMA\n", dev); return -EBUSY; } if (ebus_dma_irq_enable(&chip->p_dma.ebus_info, 1)) { Loading