#define TEA575X_RADIO 1
#endif
-#define chip_t fm801_t
-
MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
MODULE_DESCRIPTION("ForteMedia FM801");
MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DEVICES("{{ForteMedia,FM801},"
+MODULE_SUPPORTED_DEVICE("{{ForteMedia,FM801},"
"{Genius,SoundMaker Live 5.1}}");
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
module_param_array(index, int, boot_devs, 0444);
MODULE_PARM_DESC(index, "Index value for the FM801 soundcard.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
module_param_array(id, charp, boot_devs, 0444);
MODULE_PARM_DESC(id, "ID string for the FM801 soundcard.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
module_param_array(enable, bool, boot_devs, 0444);
MODULE_PARM_DESC(enable, "Enable FM801 soundcard.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
module_param_array(tea575x_tuner, bool, boot_devs, 0444);
MODULE_PARM_DESC(tea575x_tuner, "Enable TEA575x tuner.");
-MODULE_PARM_SYNTAX(tea575x_tuner, SNDRV_ENABLE_DESC);
/*
* Direct registers
int irq;
unsigned long port; /* I/O port number */
- struct resource *res_port;
unsigned int multichannel: 1, /* multichannel support */
secondary: 1; /* secondary codec */
unsigned char secondary_addr; /* address of the secondary codec */
unsigned short reg,
unsigned short val)
{
- fm801_t *chip = snd_magic_cast(fm801_t, ac97->private_data, return);
+ fm801_t *chip = ac97->private_data;
int idx;
/*
static unsigned short snd_fm801_codec_read(ac97_t *ac97, unsigned short reg)
{
- fm801_t *chip = snd_magic_cast(fm801_t, ac97->private_data, return -ENXIO);
+ fm801_t *chip = ac97->private_data;
int idx;
/*
38400, 44100, 48000
};
-#define RATES sizeof(rates) / sizeof(rates[0])
-
static snd_pcm_hw_constraint_list_t hw_constraints_rates = {
- .count = RATES,
+ .count = ARRAY_SIZE(rates),
.list = rates,
.mask = 0,
};
{
unsigned int idx;
- for (idx = 0; idx < 11; idx++)
+ for (idx = 0; idx < ARRAY_SIZE(rates); idx++)
if (rates[idx] == rate)
return idx;
snd_BUG();
- return RATES - 1;
+ return ARRAY_SIZE(rates) - 1;
}
/*
static snd_pcm_uframes_t snd_fm801_playback_pointer(snd_pcm_substream_t * substream)
{
fm801_t *chip = snd_pcm_substream_chip(substream);
- unsigned long flags;
size_t ptr;
if (!(chip->ply_ctrl & FM801_START))
return 0;
- spin_lock_irqsave(&chip->reg_lock, flags);
+ spin_lock(&chip->reg_lock);
ptr = chip->ply_pos + (chip->ply_count - 1) - inw(FM801_REG(chip, PLY_COUNT));
if (inw(FM801_REG(chip, IRQ_STATUS)) & FM801_IRQ_PLAYBACK) {
ptr += chip->ply_count;
ptr %= chip->ply_size;
}
- spin_unlock_irqrestore(&chip->reg_lock, flags);
+ spin_unlock(&chip->reg_lock);
return bytes_to_frames(substream->runtime, ptr);
}
static snd_pcm_uframes_t snd_fm801_capture_pointer(snd_pcm_substream_t * substream)
{
fm801_t *chip = snd_pcm_substream_chip(substream);
- unsigned long flags;
size_t ptr;
if (!(chip->cap_ctrl & FM801_START))
return 0;
- spin_lock_irqsave(&chip->reg_lock, flags);
+ spin_lock(&chip->reg_lock);
ptr = chip->cap_pos + (chip->cap_count - 1) - inw(FM801_REG(chip, CAP_COUNT));
if (inw(FM801_REG(chip, IRQ_STATUS)) & FM801_IRQ_CAPTURE) {
ptr += chip->cap_count;
ptr %= chip->cap_size;
}
- spin_unlock_irqrestore(&chip->reg_lock, flags);
+ spin_unlock(&chip->reg_lock);
return bytes_to_frames(substream->runtime, ptr);
}
static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
- fm801_t *chip = snd_magic_cast(fm801_t, dev_id, return IRQ_NONE);
+ fm801_t *chip = dev_id;
unsigned short status;
unsigned int tmp;
static void snd_fm801_pcm_free(snd_pcm_t *pcm)
{
- fm801_t *chip = snd_magic_cast(fm801_t, pcm->private_data, return);
+ fm801_t *chip = pcm->private_data;
chip->pcm = NULL;
snd_pcm_lib_preallocate_free_for_all(pcm);
}
int mask = (kcontrol->private_value >> 16) & 0xff;
int invert = (kcontrol->private_value >> 24) & 0xff;
- spin_lock(&chip->reg_lock);
+ spin_lock_irq(&chip->reg_lock);
ucontrol->value.integer.value[0] = (inw(chip->port + reg) >> shift_left) & mask;
ucontrol->value.integer.value[1] = (inw(chip->port + reg) >> shift_right) & mask;
- spin_unlock(&chip->reg_lock);
+ spin_unlock_irq(&chip->reg_lock);
if (invert) {
ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
static void snd_fm801_mixer_free_ac97_bus(ac97_bus_t *bus)
{
- fm801_t *chip = snd_magic_cast(fm801_t, bus->private_data, return);
+ fm801_t *chip = bus->private_data;
chip->ac97_bus = NULL;
}
static void snd_fm801_mixer_free_ac97(ac97_t *ac97)
{
- fm801_t *chip = snd_magic_cast(fm801_t, ac97->private_data, return);
+ fm801_t *chip = ac97->private_data;
if (ac97->num == 0) {
chip->ac97 = NULL;
} else {
static int __devinit snd_fm801_mixer(fm801_t *chip)
{
- ac97_bus_t bus;
- ac97_t ac97;
+ ac97_template_t ac97;
unsigned int i;
int err;
+ static ac97_bus_ops_t ops = {
+ .write = snd_fm801_codec_write,
+ .read = snd_fm801_codec_read,
+ };
- memset(&bus, 0, sizeof(bus));
- bus.write = snd_fm801_codec_write;
- bus.read = snd_fm801_codec_read;
- bus.private_data = chip;
- bus.private_free = snd_fm801_mixer_free_ac97_bus;
- if ((err = snd_ac97_bus(chip->card, &bus, &chip->ac97_bus)) < 0)
+ if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0)
return err;
+ chip->ac97_bus->private_free = snd_fm801_mixer_free_ac97_bus;
memset(&ac97, 0, sizeof(ac97));
ac97.private_data = chip;
#ifdef TEA575X_RADIO
snd_tea575x_exit(&chip->tea);
#endif
- if (chip->res_port) {
- release_resource(chip->res_port);
- kfree_nocheck(chip->res_port);
- }
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
+ pci_release_regions(chip->pci);
- snd_magic_kfree(chip);
+ kfree(chip);
return 0;
}
static int snd_fm801_dev_free(snd_device_t *device)
{
- fm801_t *chip = snd_magic_cast(fm801_t, device->device_data, return -ENXIO);
+ fm801_t *chip = device->device_data;
return snd_fm801_free(chip);
}
*rchip = NULL;
if ((err = pci_enable_device(pci)) < 0)
return err;
- chip = snd_magic_kcalloc(fm801_t, 0, GFP_KERNEL);
+ chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
spin_lock_init(&chip->reg_lock);
chip->card = card;
chip->pci = pci;
chip->irq = -1;
- chip->port = pci_resource_start(pci, 0);
- if ((chip->res_port = request_region(chip->port, 0x80, "FM801")) == NULL) {
- snd_printk("unable to grab region 0x%lx-0x%lx\n", chip->port, chip->port + 0x80 - 1);
- snd_fm801_free(chip);
- return -EBUSY;
+ if ((err = pci_request_regions(pci, "FM801")) < 0) {
+ kfree(chip);
+ return err;
}
+ chip->port = pci_resource_start(pci, 0);
if (request_irq(pci->irq, snd_fm801_interrupt, SA_INTERRUPT|SA_SHIRQ, "FM801", (void *)chip)) {
snd_printk("unable to grab IRQ %d\n", chip->irq);
snd_fm801_free(chip);