static int snd_trident_pcm_mixer_build(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream);
static int snd_trident_pcm_mixer_free(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream);
static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs);
static int snd_trident_pcm_mixer_build(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream);
static int snd_trident_pcm_mixer_free(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream);
static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs);
unsigned int data = 0, treg;
unsigned short count = 0xffff;
unsigned long flags;
unsigned int data = 0, treg;
unsigned short count = 0xffff;
unsigned long flags;
spin_lock_irqsave(&trident->reg_lock, flags);
if (trident->device == TRIDENT_DEVICE_ID_DX) {
spin_lock_irqsave(&trident->reg_lock, flags);
if (trident->device == TRIDENT_DEVICE_ID_DX) {
unsigned int address, data;
unsigned short count = 0xffff;
unsigned long flags;
unsigned int address, data;
unsigned short count = 0xffff;
unsigned long flags;
snd_trident_voice_t *evoice = voice->extra;
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[substream->number];
snd_trident_voice_t *evoice = voice->extra;
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[substream->number];
snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data;
unsigned int val, ESO_bytes;
snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data;
unsigned int val, ESO_bytes;
// Initilize the channel and set channel Mode
outb(0, TRID_REG(trident, LEGACY_DMAR15));
// Initilize the channel and set channel Mode
outb(0, TRID_REG(trident, LEGACY_DMAR15));
snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data;
snd_trident_voice_t *evoice = voice->extra;
snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data;
snd_trident_voice_t *evoice = voice->extra;
snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data;
snd_trident_voice_t *evoice = voice->extra;
snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data;
snd_trident_voice_t *evoice = voice->extra;
val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff;
snd_pcm_group_for_each(pos, substream) {
s = snd_pcm_group_substream_entry(pos);
val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff;
snd_pcm_group_for_each(pos, substream) {
s = snd_pcm_group_substream_entry(pos);
---------------------------------------------------------------------------*/
static void snd_trident_pcm_free(snd_pcm_t *pcm)
{
---------------------------------------------------------------------------*/
static void snd_trident_pcm_free(snd_pcm_t *pcm)
{
trident->foldback = NULL;
snd_pcm_lib_preallocate_free_for_all(pcm);
}
static void snd_trident_spdif_pcm_free(snd_pcm_t *pcm)
{
trident->foldback = NULL;
snd_pcm_lib_preallocate_free_for_all(pcm);
}
static void snd_trident_spdif_pcm_free(snd_pcm_t *pcm)
{
/* S/PDIF C Channel bits 0-31 : 48khz, SCMS disabled */
change = trident->spdif_ctrl != val;
trident->spdif_ctrl = val;
/* S/PDIF C Channel bits 0-31 : 48khz, SCMS disabled */
change = trident->spdif_ctrl != val;
trident->spdif_ctrl = val;
ucontrol->value.iec958.status[0] = (trident->spdif_bits >> 0) & 0xff;
ucontrol->value.iec958.status[1] = (trident->spdif_bits >> 8) & 0xff;
ucontrol->value.iec958.status[2] = (trident->spdif_bits >> 16) & 0xff;
ucontrol->value.iec958.status[3] = (trident->spdif_bits >> 24) & 0xff;
ucontrol->value.iec958.status[0] = (trident->spdif_bits >> 0) & 0xff;
ucontrol->value.iec958.status[1] = (trident->spdif_bits >> 8) & 0xff;
ucontrol->value.iec958.status[2] = (trident->spdif_bits >> 16) & 0xff;
ucontrol->value.iec958.status[3] = (trident->spdif_bits >> 24) & 0xff;
(ucontrol->value.iec958.status[1] << 8) |
(ucontrol->value.iec958.status[2] << 16) |
(ucontrol->value.iec958.status[3] << 24);
(ucontrol->value.iec958.status[1] << 8) |
(ucontrol->value.iec958.status[2] << 16) |
(ucontrol->value.iec958.status[3] << 24);
change = trident->spdif_bits != val;
trident->spdif_bits = val;
if (trident->device != TRIDENT_DEVICE_ID_SI7018) {
change = trident->spdif_bits != val;
trident->spdif_bits = val;
if (trident->device != TRIDENT_DEVICE_ID_SI7018) {
if (trident->spdif == NULL)
outl(trident->spdif_bits, TRID_REG(trident, SI_SPDIF_CS));
}
if (trident->spdif == NULL)
outl(trident->spdif_bits, TRID_REG(trident, SI_SPDIF_CS));
}
ucontrol->value.iec958.status[0] = (trident->spdif_pcm_bits >> 0) & 0xff;
ucontrol->value.iec958.status[1] = (trident->spdif_pcm_bits >> 8) & 0xff;
ucontrol->value.iec958.status[2] = (trident->spdif_pcm_bits >> 16) & 0xff;
ucontrol->value.iec958.status[3] = (trident->spdif_pcm_bits >> 24) & 0xff;
ucontrol->value.iec958.status[0] = (trident->spdif_pcm_bits >> 0) & 0xff;
ucontrol->value.iec958.status[1] = (trident->spdif_pcm_bits >> 8) & 0xff;
ucontrol->value.iec958.status[2] = (trident->spdif_pcm_bits >> 16) & 0xff;
ucontrol->value.iec958.status[3] = (trident->spdif_pcm_bits >> 24) & 0xff;
(ucontrol->value.iec958.status[1] << 8) |
(ucontrol->value.iec958.status[2] << 16) |
(ucontrol->value.iec958.status[3] << 24);
(ucontrol->value.iec958.status[1] << 8) |
(ucontrol->value.iec958.status[2] << 16) |
(ucontrol->value.iec958.status[3] << 24);
change = trident->spdif_pcm_bits != val;
trident->spdif_pcm_bits = val;
if (trident->spdif != NULL) {
change = trident->spdif_pcm_bits != val;
trident->spdif_pcm_bits = val;
if (trident->spdif != NULL) {
val = trident->ac97_ctrl = inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT));
ucontrol->value.integer.value[0] = (val & (1 << kcontrol->private_value)) ? 1 : 0;
val = trident->ac97_ctrl = inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT));
ucontrol->value.integer.value[0] = (val & (1 << kcontrol->private_value)) ? 1 : 0;
val = trident->ac97_ctrl = inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT));
val &= ~(1 << kcontrol->private_value);
if (ucontrol->value.integer.value[0])
val = trident->ac97_ctrl = inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT));
val &= ~(1 << kcontrol->private_value);
if (ucontrol->value.integer.value[0])
change = val != trident->ac97_ctrl;
trident->ac97_ctrl = val;
outl(trident->ac97_ctrl = val, TRID_REG(trident, NX_ACR0_AC97_COM_STAT));
change = val != trident->ac97_ctrl;
trident->ac97_ctrl = val;
outl(trident->ac97_ctrl = val, TRID_REG(trident, NX_ACR0_AC97_COM_STAT));
static int snd_trident_vol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
static int snd_trident_vol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
val = trident->musicvol_wavevol;
val &= ~(0xffff << kcontrol->private_value);
val |= ((255 - (ucontrol->value.integer.value[0] & 0xff)) |
((255 - (ucontrol->value.integer.value[1] & 0xff)) << 8)) << kcontrol->private_value;
change = val != trident->musicvol_wavevol;
outl(trident->musicvol_wavevol = val, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL));
val = trident->musicvol_wavevol;
val &= ~(0xffff << kcontrol->private_value);
val |= ((255 - (ucontrol->value.integer.value[0] & 0xff)) |
((255 - (ucontrol->value.integer.value[1] & 0xff)) << 8)) << kcontrol->private_value;
change = val != trident->musicvol_wavevol;
outl(trident->musicvol_wavevol = val, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL));
static int snd_trident_pcm_vol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
static int snd_trident_pcm_vol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned int val;
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned int val;
change = val != mix->vol;
mix->vol = val;
if (mix->voice != NULL)
snd_trident_write_vol_reg(trident, mix->voice, val);
change = val != mix->vol;
mix->vol = val;
if (mix->voice != NULL)
snd_trident_write_vol_reg(trident, mix->voice, val);
static int snd_trident_pcm_pan_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
static int snd_trident_pcm_pan_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned char val;
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned char val;
val = ucontrol->value.integer.value[0] & 0x3f;
else
val = (0x3f - (ucontrol->value.integer.value[0] & 0x3f)) | 0x40;
val = ucontrol->value.integer.value[0] & 0x3f;
else
val = (0x3f - (ucontrol->value.integer.value[0] & 0x3f)) | 0x40;
change = val != mix->pan;
mix->pan = val;
if (mix->voice != NULL)
snd_trident_write_pan_reg(trident, mix->voice, val);
change = val != mix->pan;
mix->pan = val;
if (mix->voice != NULL)
snd_trident_write_pan_reg(trident, mix->voice, val);
static int snd_trident_pcm_rvol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
static int snd_trident_pcm_rvol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned short val;
int change = 0;
val = 0x7f - (ucontrol->value.integer.value[0] & 0x7f);
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned short val;
int change = 0;
val = 0x7f - (ucontrol->value.integer.value[0] & 0x7f);
change = val != mix->rvol;
mix->rvol = val;
if (mix->voice != NULL)
snd_trident_write_rvol_reg(trident, mix->voice, val);
change = val != mix->rvol;
mix->rvol = val;
if (mix->voice != NULL)
snd_trident_write_rvol_reg(trident, mix->voice, val);
static int snd_trident_pcm_cvol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
static int snd_trident_pcm_cvol_control_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned short val;
int change = 0;
val = 0x7f - (ucontrol->value.integer.value[0] & 0x7f);
trident_t *trident = snd_kcontrol_chip(kcontrol);
snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)];
unsigned short val;
int change = 0;
val = 0x7f - (ucontrol->value.integer.value[0] & 0x7f);
change = val != mix->cvol;
mix->cvol = val;
if (mix->voice != NULL)
snd_trident_write_cvol_reg(trident, mix->voice, val);
change = val != mix->cvol;
mix->cvol = val;
if (mix->voice != NULL)
snd_trident_write_cvol_reg(trident, mix->voice, val);
snd_card_t * card = trident->card;
snd_kcontrol_t *kctl;
snd_ctl_elem_value_t *uctl;
int idx, err, retries = 2;
snd_card_t * card = trident->card;
snd_kcontrol_t *kctl;
snd_ctl_elem_value_t *uctl;
int idx, err, retries = 2;
- memset(&_bus, 0, sizeof(_bus));
- _bus.write = snd_trident_codec_write;
- _bus.read = snd_trident_codec_read;
- if ((err = snd_ac97_bus(trident->card, &_bus, &trident->ac97_bus)) < 0)
+ if ((err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus)) < 0)
trident_gameport_t *gp = (trident_gameport_t *)gameport;
trident_t *chip;
snd_assert(gp, return 0);
trident_gameport_t *gp = (trident_gameport_t *)gameport;
trident_t *chip;
snd_assert(gp, return 0);
trident_gameport_t *gp = (trident_gameport_t *)gameport;
trident_t *chip;
snd_assert(gp, return -1);
trident_gameport_t *gp = (trident_gameport_t *)gameport;
trident_t *chip;
snd_assert(gp, return -1);
static void snd_trident_proc_read(snd_info_entry_t *entry,
snd_info_buffer_t * buffer)
{
static void snd_trident_proc_read(snd_info_entry_t *entry,
snd_info_buffer_t * buffer)
{
/* TLB array must be aligned to 16kB !!! so we allocate
32kB region and correct offset when necessary */
/* TLB array must be aligned to 16kB !!! so we allocate
32kB region and correct offset when necessary */
- if (snd_dma_alloc_pages(&trident->dma_dev, 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) {
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
+ 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) {
- if (snd_dma_alloc_pages(&trident->dma_dev, SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) {
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
+ SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) {
- if ((trident->res_port = request_region(trident->port, 0x100, "Trident Audio")) == NULL) {
- snd_printk("unable to grab I/O region 0x%lx-0x%lx\n", trident->port, trident->port + 0x100 - 1);
- snd_trident_free(trident);
- return -EBUSY;
+ if ((err = pci_request_regions(pci, "Trident Audio")) < 0) {
+ kfree(trident);
+ return err;
if (request_irq(pci->irq, snd_trident_interrupt, SA_INTERRUPT|SA_SHIRQ, "Trident Audio", (void *) trident)) {
snd_printk("unable to grab IRQ %d\n", pci->irq);
snd_trident_free(trident);
if (request_irq(pci->irq, snd_trident_interrupt, SA_INTERRUPT|SA_SHIRQ, "Trident Audio", (void *) trident)) {
snd_printk("unable to grab IRQ %d\n", pci->irq);
snd_trident_free(trident);
/* allocate 16k-aligned TLB for NX cards */
trident->tlb.entries = NULL;
trident->tlb.buffer.area = NULL;
/* allocate 16k-aligned TLB for NX cards */
trident->tlb.entries = NULL;
trident->tlb.buffer.area = NULL;
- if (trident->res_port) {
- release_resource(trident->res_port);
- kfree_nocheck(trident->res_port);
- }
- snd_magic_kfree(trident);
+ pci_release_regions(trident->pci);
+ kfree(trident);
unsigned int audio_int, chn_int, stimer, channel, mask, tmp;
int delta;
snd_trident_voice_t *voice;
unsigned int audio_int, chn_int, stimer, channel, mask, tmp;
int delta;
snd_trident_voice_t *voice;
pci_enable_device(trident->pci);
if (pci_set_dma_mask(trident->pci, 0x3fffffff) < 0 ||
pci_enable_device(trident->pci);
if (pci_set_dma_mask(trident->pci, 0x3fffffff) < 0 ||