File Index
Files and directories
Sign in
FILE

emu10k1_synth.c

File preview with syntax highlighting.

linux-6.19.14/sound/pci/emu10k1/emu10k1_synth.c C
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 *  Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
  4 *
  5 *  Routines for control of EMU10K1 WaveTable synth
  6 */
  7
  8#include "emu10k1_synth_local.h"
  9#include <linux/init.h>
 10#include <linux/module.h>
 11
 12MODULE_AUTHOR("Takashi Iwai");
 13MODULE_DESCRIPTION("Routines for control of EMU10K1 WaveTable synth");
 14MODULE_LICENSE("GPL");
 15
 16/*
 17 * create a new hardware dependent device for Emu10k1
 18 */
 19static int snd_emu10k1_synth_probe(struct device *_dev)
 20{
 21	struct snd_seq_device *dev = to_seq_dev(_dev);
 22	struct snd_emux *emux;
 23	struct snd_emu10k1 *hw;
 24	struct snd_emu10k1_synth_arg *arg;
 25
 26	arg = SNDRV_SEQ_DEVICE_ARGPTR(dev);
 27	if (arg == NULL)
 28		return -EINVAL;
 29
 30	if (arg->seq_ports <= 0)
 31		return 0; /* nothing */
 32	if (arg->max_voices < 1)
 33		arg->max_voices = 1;
 34	else if (arg->max_voices > 64)
 35		arg->max_voices = 64;
 36
 37	if (snd_emux_new(&emux) < 0)
 38		return -ENOMEM;
 39
 40	snd_emu10k1_ops_setup(emux);
 41	hw = arg->hwptr;
 42	emux->hw = hw;
 43	emux->max_voices = arg->max_voices;
 44	emux->num_ports = arg->seq_ports;
 45	emux->memhdr = hw->memhdr;
 46	/* maximum two ports */
 47	emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2;
 48	/* audigy has two external midis */
 49	emux->midi_devidx = hw->audigy ? 2 : 1;
 50	emux->linear_panning = 0;
 51	emux->hwdep_idx = 2; /* FIXED */
 52
 53	if (snd_emux_register(emux, dev->card, arg->index, "Emu10k1") < 0) {
 54		snd_emux_free(emux);
 55		return -ENOMEM;
 56	}
 57
 58	guard(spinlock_irq)(&hw->voice_lock);
 59	hw->synth = emux;
 60	hw->get_synth_voice = snd_emu10k1_synth_get_voice;
 61
 62	dev->driver_data = emux;
 63
 64	return 0;
 65}
 66
 67static int snd_emu10k1_synth_remove(struct device *_dev)
 68{
 69	struct snd_seq_device *dev = to_seq_dev(_dev);
 70	struct snd_emux *emux;
 71	struct snd_emu10k1 *hw;
 72
 73	if (dev->driver_data == NULL)
 74		return 0; /* not registered actually */
 75
 76	emux = dev->driver_data;
 77
 78	hw = emux->hw;
 79	scoped_guard(spinlock_irq, &hw->voice_lock) {
 80		hw->synth = NULL;
 81		hw->get_synth_voice = NULL;
 82	}
 83
 84	snd_emux_free(emux);
 85	return 0;
 86}
 87
 88/*
 89 *  INIT part
 90 */
 91
 92static struct snd_seq_driver emu10k1_synth_driver = {
 93	.driver = {
 94		.name = KBUILD_MODNAME,
 95		.probe = snd_emu10k1_synth_probe,
 96		.remove = snd_emu10k1_synth_remove,
 97	},
 98	.id = SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
 99	.argsize = sizeof(struct snd_emu10k1_synth_arg),
100};
101
102module_snd_seq_driver(emu10k1_synth_driver);
~/ Read-only file preview.