Skip to content

Commit

Permalink
Merge branch 'topic/ctxfi-fix' into topic/ctxfi
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Iwai committed Jun 2, 2009
2 parents 67fbf88 + c76157d commit bd05dbd
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 108 deletions.
1 change: 0 additions & 1 deletion sound/pci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ config SND_CS5535AUDIO

config SND_CTXFI
tristate "Creative Sound Blaster X-Fi"
depends on X86
select SND_PCM
help
If you want to use soundcards based on Creative Sound Blastr X-Fi
Expand Down
35 changes: 16 additions & 19 deletions sound/pci/ctxfi/ctatc.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ static struct {
[FRONT] = { .create = ct_alsa_pcm_create,
.destroy = NULL,
.public_name = "Front/WaveIn"},
[REAR] = { .create = ct_alsa_pcm_create,
[SURROUND] = { .create = ct_alsa_pcm_create,
.destroy = NULL,
.public_name = "Rear"},
.public_name = "Surround"},
[CLFE] = { .create = ct_alsa_pcm_create,
.destroy = NULL,
.public_name = "Center/LFE"},
[SURROUND] = { .create = ct_alsa_pcm_create,
[SIDE] = { .create = ct_alsa_pcm_create,
.destroy = NULL,
.public_name = "Surround"},
.public_name = "Side"},
[IEC958] = { .create = ct_alsa_pcm_create,
.destroy = NULL,
.public_name = "IEC958 Non-audio"},
Expand Down Expand Up @@ -119,7 +119,6 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm);

static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
{
unsigned long flags;
struct snd_pcm_runtime *runtime;
struct ct_vm *vm;

Expand All @@ -129,9 +128,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
runtime = apcm->substream->runtime;
vm = atc->vm;

spin_lock_irqsave(&atc->vm_lock, flags);
apcm->vm_block = vm->map(vm, runtime->dma_area, runtime->dma_bytes);
spin_unlock_irqrestore(&atc->vm_lock, flags);
apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes);

if (NULL == apcm->vm_block)
return -ENOENT;
Expand All @@ -141,17 +138,14 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)

static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
{
unsigned long flags;
struct ct_vm *vm;

if (NULL == apcm->vm_block)
return;

vm = atc->vm;

spin_lock_irqsave(&atc->vm_lock, flags);
vm->unmap(vm, apcm->vm_block);
spin_unlock_irqrestore(&atc->vm_lock, flags);

apcm->vm_block = NULL;
}
Expand All @@ -161,35 +155,30 @@ static unsigned long atc_get_ptp_phys(struct ct_atc *atc, int index)
struct ct_vm *vm;
void *kvirt_addr;
unsigned long phys_addr;
unsigned long flags;

spin_lock_irqsave(&atc->vm_lock, flags);
vm = atc->vm;
kvirt_addr = vm->get_ptp_virt(vm, index);
if (kvirt_addr == NULL)
phys_addr = (~0UL);
else
phys_addr = virt_to_phys(kvirt_addr);

spin_unlock_irqrestore(&atc->vm_lock, flags);

return phys_addr;
}

static unsigned int convert_format(snd_pcm_format_t snd_format)
{
switch (snd_format) {
case SNDRV_PCM_FORMAT_U8:
case SNDRV_PCM_FORMAT_S8:
return SRC_SF_U8;
case SNDRV_PCM_FORMAT_S16_LE:
case SNDRV_PCM_FORMAT_U16_LE:
return SRC_SF_S16;
case SNDRV_PCM_FORMAT_S24_3LE:
return SRC_SF_S24;
case SNDRV_PCM_FORMAT_S24_LE:
case SNDRV_PCM_FORMAT_S32_LE:
return SRC_SF_S32;
case SNDRV_PCM_FORMAT_FLOAT_LE:
return SRC_SF_F32;
default:
printk(KERN_ERR "ctxfi: not recognized snd format is %d \n",
snd_format);
Expand Down Expand Up @@ -264,6 +253,9 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
return 0;
}

/* first release old resources */
atc->pcm_release_resources(atc, apcm);

/* Get SRC resource */
desc.multi = apcm->substream->runtime->channels;
desc.msr = atc->msr;
Expand Down Expand Up @@ -506,6 +498,9 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
int n_srcimp = 0, n_amixer = 0, n_srcc = 0, n_sum = 0;
struct src_node_conf_t src_node_conf[2] = {{0} };

/* first release old resources */
atc->pcm_release_resources(atc, apcm);

/* The numbers of converting SRCs and SRCIMPs should be determined
* by pitch value. */

Expand Down Expand Up @@ -777,6 +772,9 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc,
int n_amixer = apcm->substream->runtime->channels, i = 0;
unsigned int pitch = 0, rsr = atc->pll_rate;

/* first release old resources */
atc->pcm_release_resources(atc, apcm);

/* Get SRC resource */
desc.multi = apcm->substream->runtime->channels;
desc.msr = 1;
Expand Down Expand Up @@ -1562,7 +1560,6 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
atc_set_ops(atc);

spin_lock_init(&atc->atc_lock);
spin_lock_init(&atc->vm_lock);

/* Find card model */
err = atc_identify_card(atc);
Expand Down
5 changes: 2 additions & 3 deletions sound/pci/ctxfi/ctatc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

enum CTALSADEVS { /* Types of alsa devices */
FRONT,
REAR,
CLFE,
SURROUND,
CLFE,
SIDE,
IEC958,
MIXER,
NUM_CTALSADEVS /* This should always be the last */
Expand Down Expand Up @@ -101,7 +101,6 @@ struct ct_atc {
unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);

spinlock_t atc_lock;
spinlock_t vm_lock;

int (*pcm_playback_prepare)(struct ct_atc *atc,
struct ct_atc_pcm *apcm);
Expand Down
16 changes: 6 additions & 10 deletions sound/pci/ctxfi/cthw20k1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,18 +1249,14 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
}

trnctl = 0x13; /* 32-bit, 4k-size page */
#if BITS_PER_LONG == 64
ptp_phys_low = info->vm_pgt_phys & ((1UL<<32)-1);
ptp_phys_high = (info->vm_pgt_phys>>32) & ((1UL<<32)-1);
trnctl |= (1<<2);
#elif BITS_PER_LONG == 32
ptp_phys_low = info->vm_pgt_phys & (~0UL);
ptp_phys_high = 0;
#else
# error "Unknown BITS_PER_LONG!"
#endif
ptp_phys_low = (u32)info->vm_pgt_phys;
ptp_phys_high = upper_32_bits(info->vm_pgt_phys);
if (sizeof(void *) == 8) /* 64bit address */
trnctl |= (1 << 2);
#if 0 /* Only 4k h/w pages for simplicitiy */
#if PAGE_SIZE == 8192
trnctl |= (1<<5);
#endif
#endif
hw_write_20kx(hw, PTPALX, ptp_phys_low);
hw_write_20kx(hw, PTPAHX, ptp_phys_high);
Expand Down
17 changes: 4 additions & 13 deletions sound/pci/ctxfi/cthw20k2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,19 +1203,10 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
}

vmctl = 0x80000C0F; /* 32-bit, 4k-size page */
#if BITS_PER_LONG == 64
ptp_phys_low = info->vm_pgt_phys & ((1UL<<32)-1);
ptp_phys_high = (info->vm_pgt_phys>>32) & ((1UL<<32)-1);
vmctl |= (3<<8);
#elif BITS_PER_LONG == 32
ptp_phys_low = info->vm_pgt_phys & (~0UL);
ptp_phys_high = 0;
#else
# error "Unknown BITS_PER_LONG!"
#endif
#if PAGE_SIZE == 8192
# error "Don't support 8k-page!"
#endif
ptp_phys_low = (u32)info->vm_pgt_phys;
ptp_phys_high = upper_32_bits(info->vm_pgt_phys);
if (sizeof(void *) == 8) /* 64bit address */
vmctl |= (3 << 8);
/* Write page table physical address to all PTPAL registers */
for (i = 0; i < 64; i++) {
hw_write_20kx(hw, VMEM_PTPAL+(16*i), ptp_phys_low);
Expand Down
8 changes: 4 additions & 4 deletions sound/pci/ctxfi/ctmixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ ct_kcontrol_init_table[NUM_CTALSA_MIXERS] = {
},
[MIXER_WAVES_P] = {
.ctl = 1,
.name = "Surround Playback Volume",
.name = "Side Playback Volume",
},
[MIXER_WAVEC_P] = {
.ctl = 1,
.name = "Center/LFE Playback Volume",
},
[MIXER_WAVER_P] = {
.ctl = 1,
.name = "Rear Playback Volume",
.name = "Surround Playback Volume",
},

[MIXER_PCM_C_S] = {
Expand Down Expand Up @@ -213,15 +213,15 @@ ct_kcontrol_init_table[NUM_CTALSA_MIXERS] = {
},
[MIXER_WAVES_P_S] = {
.ctl = 1,
.name = "Surround Playback Switch",
.name = "Side Playback Switch",
},
[MIXER_WAVEC_P_S] = {
.ctl = 1,
.name = "Center/LFE Playback Switch",
},
[MIXER_WAVER_P_S] = {
.ctl = 1,
.name = "Rear Playback Switch",
.name = "Surround Playback Switch",
},
[MIXER_DIGITAL_IO_S] = {
.ctl = 0,
Expand Down
25 changes: 10 additions & 15 deletions sound/pci/ctxfi/ctpcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ static struct snd_pcm_hardware ct_pcm_playback_hw = {
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_PAUSE),
.formats = (SNDRV_PCM_FMTBIT_U8 |
SNDRV_PCM_FMTBIT_S8 |
SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_U16_LE |
SNDRV_PCM_FMTBIT_S24_3LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE),
SNDRV_PCM_FMTBIT_S32_LE |
SNDRV_PCM_FMTBIT_FLOAT_LE),
.rates = (SNDRV_PCM_RATE_CONTINUOUS |
SNDRV_PCM_RATE_8000_192000),
.rate_min = 8000,
Expand All @@ -52,8 +50,7 @@ static struct snd_pcm_hardware ct_spdif_passthru_playback_hw = {
SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_PAUSE),
.formats = (SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_U16_LE),
.formats = SNDRV_PCM_FMTBIT_S16_LE,
.rates = (SNDRV_PCM_RATE_48000 |
SNDRV_PCM_RATE_44100 |
SNDRV_PCM_RATE_32000),
Expand All @@ -77,12 +74,10 @@ static struct snd_pcm_hardware ct_pcm_capture_hw = {
SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_MMAP_VALID),
.formats = (SNDRV_PCM_FMTBIT_U8 |
SNDRV_PCM_FMTBIT_S8 |
SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_U16_LE |
SNDRV_PCM_FMTBIT_S24_3LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE),
SNDRV_PCM_FMTBIT_S32_LE |
SNDRV_PCM_FMTBIT_FLOAT_LE),
.rates = (SNDRV_PCM_RATE_CONTINUOUS |
SNDRV_PCM_RATE_8000_96000),
.rate_min = 8000,
Expand Down Expand Up @@ -447,6 +442,7 @@ static struct snd_pcm_ops ct_pcm_playback_ops = {
.prepare = ct_pcm_playback_prepare,
.trigger = ct_pcm_playback_trigger,
.pointer = ct_pcm_playback_pointer,
.page = snd_pcm_sgbuf_ops_page,
};

/* PCM operators for capture */
Expand All @@ -459,6 +455,7 @@ static struct snd_pcm_ops ct_pcm_capture_ops = {
.prepare = ct_pcm_capture_prepare,
.trigger = ct_pcm_capture_trigger,
.pointer = ct_pcm_capture_pointer,
.page = snd_pcm_sgbuf_ops_page,
};

/* Create ALSA pcm device */
Expand All @@ -469,12 +466,10 @@ int ct_alsa_pcm_create(struct ct_atc *atc,
struct snd_pcm *pcm;
int err;
int playback_count, capture_count;
char name[128];

strncpy(name, device_name, sizeof(name));
playback_count = (IEC958 == device) ? 1 : 8;
capture_count = (FRONT == device) ? 1 : 0;
err = snd_pcm_new(atc->card, name, device,
err = snd_pcm_new(atc->card, "ctxfi", device,
playback_count, capture_count, &pcm);
if (err < 0) {
printk(KERN_ERR "ctxfi: snd_pcm_new failed!! Err=%d\n", err);
Expand All @@ -484,15 +479,15 @@ int ct_alsa_pcm_create(struct ct_atc *atc,
pcm->private_data = atc;
pcm->info_flags = 0;
pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
strcpy(pcm->name, device_name);
strlcpy(pcm->name, device_name, sizeof(pcm->name));

snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &ct_pcm_playback_ops);

if (FRONT == device)
snd_pcm_set_ops(pcm,
SNDRV_PCM_STREAM_CAPTURE, &ct_pcm_capture_ops);

snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(atc->pci), 128*1024, 128*1024);

return 0;
Expand Down
Loading

0 comments on commit bd05dbd

Please sign in to comment.