Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *     and (c) 1999 Steve Ratcliffe <steve@parabola.demon.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Emu8000 synth plug-in routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "emu8000_local.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <sound/initval.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) MODULE_AUTHOR("Takashi Iwai, Steve Ratcliffe");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) MODULE_DESCRIPTION("Emu8000 synth plug-in routine");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /*----------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * create a new hardware dependent device for Emu8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static int snd_emu8000_probe(struct device *_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct snd_seq_device *dev = to_seq_dev(_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct snd_emu8000 *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	struct snd_emux *emu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	hw = *(struct snd_emu8000**)SNDRV_SEQ_DEVICE_ARGPTR(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	if (hw == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	if (hw->emu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		return -EBUSY; /* already exists..? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	if (snd_emux_new(&emu) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	hw->emu = emu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	snd_emu8000_ops_setup(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	emu->hw = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	emu->max_voices = EMU8000_DRAM_VOICES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	emu->num_ports = hw->seq_ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (hw->memhdr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		snd_printk(KERN_ERR "memhdr is already initialized!?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		snd_util_memhdr_free(hw->memhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	hw->memhdr = snd_util_memhdr_new(hw->mem_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	if (hw->memhdr == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		snd_emux_free(emu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		hw->emu = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	emu->memhdr = hw->memhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	emu->midi_ports = hw->seq_ports < 2 ? hw->seq_ports : 2; /* number of virmidi ports */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	emu->midi_devidx = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	emu->linear_panning = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	emu->hwdep_idx = 2; /* FIXED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (snd_emux_register(emu, dev->card, hw->index, "Emu8000") < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		snd_emux_free(emu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		snd_util_memhdr_free(hw->memhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		hw->emu = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		hw->memhdr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if (hw->mem_size > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		snd_emu8000_pcm_new(dev->card, hw, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	dev->driver_data = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * free all resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static int snd_emu8000_remove(struct device *_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct snd_seq_device *dev = to_seq_dev(_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct snd_emu8000 *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (dev->driver_data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		return 0; /* no synth was allocated actually */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	hw = dev->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	if (hw->pcm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		snd_device_free(dev->card, hw->pcm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	snd_emux_free(hw->emu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	snd_util_memhdr_free(hw->memhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	hw->emu = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	hw->memhdr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *  INIT part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static struct snd_seq_driver emu8000_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		.name = KBUILD_MODNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		.probe = snd_emu8000_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		.remove = snd_emu8000_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	.id = SNDRV_SEQ_DEV_ID_EMU8000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	.argsize = sizeof(struct snd_emu8000 *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) module_snd_seq_driver(emu8000_driver);