mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
ALSA: emux: Use standard print API
Use the standard print API with dev_*() instead of the old house-baked one. It gives better information and allows dynamically control of debug prints. Some functions are changed to receive snd_card object for calling dev_*() functions, too. Reviewed-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20240807133452.9424-44-tiwai@suse.de
This commit is contained in:
parent
def358f9ba
commit
fea1510719
@ -86,9 +86,11 @@ struct snd_sf_list {
|
||||
};
|
||||
|
||||
/* Prototypes for soundfont.c */
|
||||
int snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
||||
int snd_soundfont_load(struct snd_card *card,
|
||||
struct snd_sf_list *sflist, const void __user *data,
|
||||
long count, int client);
|
||||
int snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data,
|
||||
int snd_soundfont_load_guspatch(struct snd_card *card,
|
||||
struct snd_sf_list *sflist, const char __user *data,
|
||||
long count);
|
||||
int snd_soundfont_close_check(struct snd_sf_list *sflist, int client);
|
||||
|
||||
|
@ -26,12 +26,14 @@ snd_emux_hwdep_load_patch(struct snd_emux *emu, void __user *arg)
|
||||
return -EFAULT;
|
||||
|
||||
if (patch.key == GUS_PATCH)
|
||||
return snd_soundfont_load_guspatch(emu->sflist, arg,
|
||||
return snd_soundfont_load_guspatch(emu->card, emu->sflist, arg,
|
||||
patch.len + sizeof(patch));
|
||||
|
||||
if (patch.type >= SNDRV_SFNT_LOAD_INFO &&
|
||||
patch.type <= SNDRV_SFNT_PROBE_DATA) {
|
||||
err = snd_soundfont_load(emu->sflist, arg, patch.len + sizeof(patch), TMP_CLIENT_ID);
|
||||
err = snd_soundfont_load(emu->card, emu->sflist, arg,
|
||||
patch.len + sizeof(patch),
|
||||
TMP_CLIENT_ID);
|
||||
if (err < 0)
|
||||
return err;
|
||||
} else {
|
||||
|
@ -115,7 +115,7 @@ snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
|
||||
p = snd_emux_create_port(emu, tmpname, 32,
|
||||
1, &callback);
|
||||
if (p == NULL) {
|
||||
snd_printk(KERN_ERR "can't create port\n");
|
||||
dev_err(emu->card->dev, "can't create port\n");
|
||||
snd_emux_dec_count(emu);
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -205,7 +205,7 @@ snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
|
||||
return -ENXIO;
|
||||
|
||||
if (format == GUS_PATCH)
|
||||
rc = snd_soundfont_load_guspatch(emu->sflist, buf, count);
|
||||
rc = snd_soundfont_load_guspatch(emu->card, emu->sflist, buf, count);
|
||||
else if (format == SNDRV_OSS_SOUNDFONT_PATCH) {
|
||||
struct soundfont_patch_info patch;
|
||||
if (count < (int)sizeof(patch))
|
||||
@ -214,10 +214,13 @@ snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
|
||||
return -EFAULT;
|
||||
if (patch.type >= SNDRV_SFNT_LOAD_INFO &&
|
||||
patch.type <= SNDRV_SFNT_PROBE_DATA)
|
||||
rc = snd_soundfont_load(emu->sflist, buf, count, SF_CLIENT_NO(p->chset.port));
|
||||
rc = snd_soundfont_load(emu->card, emu->sflist, buf,
|
||||
count,
|
||||
SF_CLIENT_NO(p->chset.port));
|
||||
else {
|
||||
if (emu->ops.load_fx)
|
||||
rc = emu->ops.load_fx(emu, patch.type, patch.optarg, buf, count);
|
||||
rc = emu->ops.load_fx(emu, patch.type,
|
||||
patch.optarg, buf, count);
|
||||
else
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
@ -61,16 +61,17 @@ snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index)
|
||||
emu->client = snd_seq_create_kernel_client(card, index,
|
||||
"%s WaveTable", emu->name);
|
||||
if (emu->client < 0) {
|
||||
snd_printk(KERN_ERR "can't create client\n");
|
||||
dev_err(card->dev, "can't create client\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (emu->num_ports <= 0) {
|
||||
snd_printk(KERN_WARNING "seqports must be greater than zero\n");
|
||||
dev_warn(card->dev, "seqports must be greater than zero\n");
|
||||
emu->num_ports = 1;
|
||||
} else if (emu->num_ports > SNDRV_EMUX_MAX_PORTS) {
|
||||
snd_printk(KERN_WARNING "too many ports. "
|
||||
"limited max. ports %d\n", SNDRV_EMUX_MAX_PORTS);
|
||||
dev_warn(card->dev,
|
||||
"too many ports. limited max. ports %d\n",
|
||||
SNDRV_EMUX_MAX_PORTS);
|
||||
emu->num_ports = SNDRV_EMUX_MAX_PORTS;
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index)
|
||||
p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS,
|
||||
0, &pinfo);
|
||||
if (!p) {
|
||||
snd_printk(KERN_ERR "can't create port\n");
|
||||
dev_err(card->dev, "can't create port\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@ -376,12 +377,10 @@ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card)
|
||||
goto __error;
|
||||
}
|
||||
emu->vmidi[i] = rmidi;
|
||||
/* snd_printk(KERN_DEBUG "virmidi %d ok\n", i); */
|
||||
}
|
||||
return 0;
|
||||
|
||||
__error:
|
||||
/* snd_printk(KERN_DEBUG "error init..\n"); */
|
||||
snd_emux_delete_virmidi(emu);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -942,7 +942,7 @@ void snd_emux_lock_voice(struct snd_emux *emu, int voice)
|
||||
if (emu->voices[voice].state == SNDRV_EMUX_ST_OFF)
|
||||
emu->voices[voice].state = SNDRV_EMUX_ST_LOCKED;
|
||||
else
|
||||
snd_printk(KERN_WARNING
|
||||
dev_warn(emu->card->dev,
|
||||
"invalid voice for lock %d (state = %x)\n",
|
||||
voice, emu->voices[voice].state);
|
||||
spin_unlock_irqrestore(&emu->voice_lock, flags);
|
||||
@ -960,7 +960,7 @@ void snd_emux_unlock_voice(struct snd_emux *emu, int voice)
|
||||
if (emu->voices[voice].state == SNDRV_EMUX_ST_LOCKED)
|
||||
emu->voices[voice].state = SNDRV_EMUX_ST_OFF;
|
||||
else
|
||||
snd_printk(KERN_WARNING
|
||||
dev_warn(emu->card->dev,
|
||||
"invalid voice for unlock %d (state = %x)\n",
|
||||
voice, emu->voices[voice].state);
|
||||
spin_unlock_irqrestore(&emu->voice_lock, flags);
|
||||
|
@ -38,7 +38,8 @@ static struct snd_sf_sample *sf_sample_new(struct snd_sf_list *sflist,
|
||||
static void sf_sample_delete(struct snd_sf_list *sflist,
|
||||
struct snd_soundfont *sf, struct snd_sf_sample *sp);
|
||||
static int load_map(struct snd_sf_list *sflist, const void __user *data, int count);
|
||||
static int load_info(struct snd_sf_list *sflist, const void __user *data, long count);
|
||||
static int load_info(struct snd_card *card, struct snd_sf_list *sflist,
|
||||
const void __user *data, long count);
|
||||
static int remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf,
|
||||
int bank, int instr);
|
||||
static void init_voice_info(struct soundfont_voice_info *avp);
|
||||
@ -113,7 +114,8 @@ snd_soundfont_close_check(struct snd_sf_list *sflist, int client)
|
||||
* it wants to do with it.
|
||||
*/
|
||||
int
|
||||
snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
||||
snd_soundfont_load(struct snd_card *card,
|
||||
struct snd_sf_list *sflist, const void __user *data,
|
||||
long count, int client)
|
||||
{
|
||||
struct soundfont_patch_info patch;
|
||||
@ -121,7 +123,7 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
||||
int rc;
|
||||
|
||||
if (count < (long)sizeof(patch)) {
|
||||
snd_printk(KERN_ERR "patch record too small %ld\n", count);
|
||||
dev_err(card->dev, "patch record too small %ld\n", count);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (copy_from_user(&patch, data, sizeof(patch)))
|
||||
@ -131,16 +133,16 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
||||
data += sizeof(patch);
|
||||
|
||||
if (patch.key != SNDRV_OSS_SOUNDFONT_PATCH) {
|
||||
snd_printk(KERN_ERR "The wrong kind of patch %x\n", patch.key);
|
||||
dev_err(card->dev, "The wrong kind of patch %x\n", patch.key);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (count < patch.len) {
|
||||
snd_printk(KERN_ERR "Patch too short %ld, need %d\n",
|
||||
dev_err(card->dev, "Patch too short %ld, need %d\n",
|
||||
count, patch.len);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (patch.len < 0) {
|
||||
snd_printk(KERN_ERR "poor length %d\n", patch.len);
|
||||
dev_err(card->dev, "poor length %d\n", patch.len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -164,7 +166,7 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
||||
rc = -EINVAL;
|
||||
switch (patch.type) {
|
||||
case SNDRV_SFNT_LOAD_INFO:
|
||||
rc = load_info(sflist, data, count);
|
||||
rc = load_info(card, sflist, data, count);
|
||||
break;
|
||||
case SNDRV_SFNT_LOAD_DATA:
|
||||
rc = load_data(sflist, data, count);
|
||||
@ -184,8 +186,8 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
||||
case SNDRV_SFNT_REMOVE_INFO:
|
||||
/* patch must be opened */
|
||||
if (!sflist->currsf) {
|
||||
snd_printk(KERN_ERR "soundfont: remove_info: "
|
||||
"patch not opened\n");
|
||||
dev_err(card->dev,
|
||||
"soundfont: remove_info: patch not opened\n");
|
||||
rc = -EINVAL;
|
||||
} else {
|
||||
int bank, instr;
|
||||
@ -509,7 +511,8 @@ remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf,
|
||||
* open soundfont.
|
||||
*/
|
||||
static int
|
||||
load_info(struct snd_sf_list *sflist, const void __user *data, long count)
|
||||
load_info(struct snd_card *card,
|
||||
struct snd_sf_list *sflist, const void __user *data, long count)
|
||||
{
|
||||
struct snd_soundfont *sf;
|
||||
struct snd_sf_zone *zone;
|
||||
@ -525,7 +528,7 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
|
||||
return -EINVAL;
|
||||
|
||||
if (count < (long)sizeof(hdr)) {
|
||||
printk(KERN_ERR "Soundfont error: invalid patch zone length\n");
|
||||
dev_err(card->dev, "Soundfont error: invalid patch zone length\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (copy_from_user((char*)&hdr, data, sizeof(hdr)))
|
||||
@ -535,14 +538,14 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
|
||||
count -= sizeof(hdr);
|
||||
|
||||
if (hdr.nvoices <= 0 || hdr.nvoices >= 100) {
|
||||
printk(KERN_ERR "Soundfont error: Illegal voice number %d\n",
|
||||
dev_err(card->dev, "Soundfont error: Illegal voice number %d\n",
|
||||
hdr.nvoices);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (count < (long)sizeof(struct soundfont_voice_info) * hdr.nvoices) {
|
||||
printk(KERN_ERR "Soundfont Error: "
|
||||
"patch length(%ld) is smaller than nvoices(%d)\n",
|
||||
dev_err(card->dev,
|
||||
"Soundfont Error: patch length(%ld) is smaller than nvoices(%d)\n",
|
||||
count, hdr.nvoices);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -974,7 +977,8 @@ int snd_sf_vol_table[128] = {
|
||||
|
||||
/* load GUS patch */
|
||||
static int
|
||||
load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
||||
load_guspatch(struct snd_card *card,
|
||||
struct snd_sf_list *sflist, const char __user *data, long count)
|
||||
{
|
||||
struct patch_info patch;
|
||||
struct snd_soundfont *sf;
|
||||
@ -984,7 +988,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
||||
int rc;
|
||||
|
||||
if (count < (long)sizeof(patch)) {
|
||||
snd_printk(KERN_ERR "patch record too small %ld\n", count);
|
||||
dev_err(card->dev, "patch record too small %ld\n", count);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (copy_from_user(&patch, data, sizeof(patch)))
|
||||
@ -1076,7 +1080,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
||||
/* panning position; -128 - 127 => 0-127 */
|
||||
zone->v.pan = (patch.panning + 128) / 2;
|
||||
#if 0
|
||||
snd_printk(KERN_DEBUG
|
||||
pr_debug(
|
||||
"gus: basefrq=%d (ofs=%d) root=%d,tune=%d, range:%d-%d\n",
|
||||
(int)patch.base_freq, zone->v.rate_offset,
|
||||
zone->v.root, zone->v.tune, zone->v.low, zone->v.high);
|
||||
@ -1111,7 +1115,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
||||
zone->v.parm.volrelease = 0x8000 | snd_sf_calc_parm_decay(release);
|
||||
zone->v.attenuation = calc_gus_attenuation(patch.env_offset[0]);
|
||||
#if 0
|
||||
snd_printk(KERN_DEBUG
|
||||
dev_dbg(card->dev,
|
||||
"gus: atkhld=%x, dcysus=%x, volrel=%x, att=%d\n",
|
||||
zone->v.parm.volatkhld,
|
||||
zone->v.parm.voldcysus,
|
||||
@ -1160,12 +1164,13 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
||||
|
||||
/* load GUS patch */
|
||||
int
|
||||
snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data,
|
||||
snd_soundfont_load_guspatch(struct snd_card *card,
|
||||
struct snd_sf_list *sflist, const char __user *data,
|
||||
long count)
|
||||
{
|
||||
int rc;
|
||||
lock_preset(sflist);
|
||||
rc = load_guspatch(sflist, data, count);
|
||||
rc = load_guspatch(card, sflist, data, count);
|
||||
unlock_preset(sflist);
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user