mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +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 */
|
/* 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);
|
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);
|
long count);
|
||||||
int snd_soundfont_close_check(struct snd_sf_list *sflist, int client);
|
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;
|
return -EFAULT;
|
||||||
|
|
||||||
if (patch.key == GUS_PATCH)
|
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));
|
patch.len + sizeof(patch));
|
||||||
|
|
||||||
if (patch.type >= SNDRV_SFNT_LOAD_INFO &&
|
if (patch.type >= SNDRV_SFNT_LOAD_INFO &&
|
||||||
patch.type <= SNDRV_SFNT_PROBE_DATA) {
|
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)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} 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,
|
p = snd_emux_create_port(emu, tmpname, 32,
|
||||||
1, &callback);
|
1, &callback);
|
||||||
if (p == NULL) {
|
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);
|
snd_emux_dec_count(emu);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
|
|||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
if (format == GUS_PATCH)
|
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) {
|
else if (format == SNDRV_OSS_SOUNDFONT_PATCH) {
|
||||||
struct soundfont_patch_info patch;
|
struct soundfont_patch_info patch;
|
||||||
if (count < (int)sizeof(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;
|
return -EFAULT;
|
||||||
if (patch.type >= SNDRV_SFNT_LOAD_INFO &&
|
if (patch.type >= SNDRV_SFNT_LOAD_INFO &&
|
||||||
patch.type <= SNDRV_SFNT_PROBE_DATA)
|
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 {
|
else {
|
||||||
if (emu->ops.load_fx)
|
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
|
else
|
||||||
rc = -EINVAL;
|
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,
|
emu->client = snd_seq_create_kernel_client(card, index,
|
||||||
"%s WaveTable", emu->name);
|
"%s WaveTable", emu->name);
|
||||||
if (emu->client < 0) {
|
if (emu->client < 0) {
|
||||||
snd_printk(KERN_ERR "can't create client\n");
|
dev_err(card->dev, "can't create client\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emu->num_ports <= 0) {
|
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;
|
emu->num_ports = 1;
|
||||||
} else if (emu->num_ports > SNDRV_EMUX_MAX_PORTS) {
|
} else if (emu->num_ports > SNDRV_EMUX_MAX_PORTS) {
|
||||||
snd_printk(KERN_WARNING "too many ports. "
|
dev_warn(card->dev,
|
||||||
"limited max. ports %d\n", SNDRV_EMUX_MAX_PORTS);
|
"too many ports. limited max. ports %d\n",
|
||||||
|
SNDRV_EMUX_MAX_PORTS);
|
||||||
emu->num_ports = 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,
|
p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS,
|
||||||
0, &pinfo);
|
0, &pinfo);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
snd_printk(KERN_ERR "can't create port\n");
|
dev_err(card->dev, "can't create port\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,12 +377,10 @@ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card)
|
|||||||
goto __error;
|
goto __error;
|
||||||
}
|
}
|
||||||
emu->vmidi[i] = rmidi;
|
emu->vmidi[i] = rmidi;
|
||||||
/* snd_printk(KERN_DEBUG "virmidi %d ok\n", i); */
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
__error:
|
__error:
|
||||||
/* snd_printk(KERN_DEBUG "error init..\n"); */
|
|
||||||
snd_emux_delete_virmidi(emu);
|
snd_emux_delete_virmidi(emu);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -942,9 +942,9 @@ void snd_emux_lock_voice(struct snd_emux *emu, int voice)
|
|||||||
if (emu->voices[voice].state == SNDRV_EMUX_ST_OFF)
|
if (emu->voices[voice].state == SNDRV_EMUX_ST_OFF)
|
||||||
emu->voices[voice].state = SNDRV_EMUX_ST_LOCKED;
|
emu->voices[voice].state = SNDRV_EMUX_ST_LOCKED;
|
||||||
else
|
else
|
||||||
snd_printk(KERN_WARNING
|
dev_warn(emu->card->dev,
|
||||||
"invalid voice for lock %d (state = %x)\n",
|
"invalid voice for lock %d (state = %x)\n",
|
||||||
voice, emu->voices[voice].state);
|
voice, emu->voices[voice].state);
|
||||||
spin_unlock_irqrestore(&emu->voice_lock, flags);
|
spin_unlock_irqrestore(&emu->voice_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,9 +960,9 @@ void snd_emux_unlock_voice(struct snd_emux *emu, int voice)
|
|||||||
if (emu->voices[voice].state == SNDRV_EMUX_ST_LOCKED)
|
if (emu->voices[voice].state == SNDRV_EMUX_ST_LOCKED)
|
||||||
emu->voices[voice].state = SNDRV_EMUX_ST_OFF;
|
emu->voices[voice].state = SNDRV_EMUX_ST_OFF;
|
||||||
else
|
else
|
||||||
snd_printk(KERN_WARNING
|
dev_warn(emu->card->dev,
|
||||||
"invalid voice for unlock %d (state = %x)\n",
|
"invalid voice for unlock %d (state = %x)\n",
|
||||||
voice, emu->voices[voice].state);
|
voice, emu->voices[voice].state);
|
||||||
spin_unlock_irqrestore(&emu->voice_lock, flags);
|
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,
|
static void sf_sample_delete(struct snd_sf_list *sflist,
|
||||||
struct snd_soundfont *sf, struct snd_sf_sample *sp);
|
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_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,
|
static int remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf,
|
||||||
int bank, int instr);
|
int bank, int instr);
|
||||||
static void init_voice_info(struct soundfont_voice_info *avp);
|
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.
|
* it wants to do with it.
|
||||||
*/
|
*/
|
||||||
int
|
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)
|
long count, int client)
|
||||||
{
|
{
|
||||||
struct soundfont_patch_info patch;
|
struct soundfont_patch_info patch;
|
||||||
@ -121,7 +123,7 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (count < (long)sizeof(patch)) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (copy_from_user(&patch, data, sizeof(patch)))
|
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);
|
data += sizeof(patch);
|
||||||
|
|
||||||
if (patch.key != SNDRV_OSS_SOUNDFONT_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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (count < patch.len) {
|
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);
|
count, patch.len);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (patch.len < 0) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +166,7 @@ snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data,
|
|||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
switch (patch.type) {
|
switch (patch.type) {
|
||||||
case SNDRV_SFNT_LOAD_INFO:
|
case SNDRV_SFNT_LOAD_INFO:
|
||||||
rc = load_info(sflist, data, count);
|
rc = load_info(card, sflist, data, count);
|
||||||
break;
|
break;
|
||||||
case SNDRV_SFNT_LOAD_DATA:
|
case SNDRV_SFNT_LOAD_DATA:
|
||||||
rc = load_data(sflist, data, count);
|
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:
|
case SNDRV_SFNT_REMOVE_INFO:
|
||||||
/* patch must be opened */
|
/* patch must be opened */
|
||||||
if (!sflist->currsf) {
|
if (!sflist->currsf) {
|
||||||
snd_printk(KERN_ERR "soundfont: remove_info: "
|
dev_err(card->dev,
|
||||||
"patch not opened\n");
|
"soundfont: remove_info: patch not opened\n");
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
} else {
|
} else {
|
||||||
int bank, instr;
|
int bank, instr;
|
||||||
@ -509,7 +511,8 @@ remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf,
|
|||||||
* open soundfont.
|
* open soundfont.
|
||||||
*/
|
*/
|
||||||
static int
|
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_soundfont *sf;
|
||||||
struct snd_sf_zone *zone;
|
struct snd_sf_zone *zone;
|
||||||
@ -525,7 +528,7 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (count < (long)sizeof(hdr)) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (copy_from_user((char*)&hdr, data, sizeof(hdr)))
|
if (copy_from_user((char*)&hdr, data, sizeof(hdr)))
|
||||||
@ -535,15 +538,15 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)
|
|||||||
count -= sizeof(hdr);
|
count -= sizeof(hdr);
|
||||||
|
|
||||||
if (hdr.nvoices <= 0 || hdr.nvoices >= 100) {
|
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);
|
hdr.nvoices);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count < (long)sizeof(struct soundfont_voice_info) * hdr.nvoices) {
|
if (count < (long)sizeof(struct soundfont_voice_info) * hdr.nvoices) {
|
||||||
printk(KERN_ERR "Soundfont Error: "
|
dev_err(card->dev,
|
||||||
"patch length(%ld) is smaller than nvoices(%d)\n",
|
"Soundfont Error: patch length(%ld) is smaller than nvoices(%d)\n",
|
||||||
count, hdr.nvoices);
|
count, hdr.nvoices);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,7 +977,8 @@ int snd_sf_vol_table[128] = {
|
|||||||
|
|
||||||
/* load GUS patch */
|
/* load GUS patch */
|
||||||
static int
|
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 patch_info patch;
|
||||||
struct snd_soundfont *sf;
|
struct snd_soundfont *sf;
|
||||||
@ -984,7 +988,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (count < (long)sizeof(patch)) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (copy_from_user(&patch, data, sizeof(patch)))
|
if (copy_from_user(&patch, data, sizeof(patch)))
|
||||||
@ -1076,10 +1080,10 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
|||||||
/* panning position; -128 - 127 => 0-127 */
|
/* panning position; -128 - 127 => 0-127 */
|
||||||
zone->v.pan = (patch.panning + 128) / 2;
|
zone->v.pan = (patch.panning + 128) / 2;
|
||||||
#if 0
|
#if 0
|
||||||
snd_printk(KERN_DEBUG
|
pr_debug(
|
||||||
"gus: basefrq=%d (ofs=%d) root=%d,tune=%d, range:%d-%d\n",
|
"gus: basefrq=%d (ofs=%d) root=%d,tune=%d, range:%d-%d\n",
|
||||||
(int)patch.base_freq, zone->v.rate_offset,
|
(int)patch.base_freq, zone->v.rate_offset,
|
||||||
zone->v.root, zone->v.tune, zone->v.low, zone->v.high);
|
zone->v.root, zone->v.tune, zone->v.low, zone->v.high);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* detuning is ignored */
|
/* detuning is ignored */
|
||||||
@ -1111,12 +1115,12 @@ 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.parm.volrelease = 0x8000 | snd_sf_calc_parm_decay(release);
|
||||||
zone->v.attenuation = calc_gus_attenuation(patch.env_offset[0]);
|
zone->v.attenuation = calc_gus_attenuation(patch.env_offset[0]);
|
||||||
#if 0
|
#if 0
|
||||||
snd_printk(KERN_DEBUG
|
dev_dbg(card->dev,
|
||||||
"gus: atkhld=%x, dcysus=%x, volrel=%x, att=%d\n",
|
"gus: atkhld=%x, dcysus=%x, volrel=%x, att=%d\n",
|
||||||
zone->v.parm.volatkhld,
|
zone->v.parm.volatkhld,
|
||||||
zone->v.parm.voldcysus,
|
zone->v.parm.voldcysus,
|
||||||
zone->v.parm.volrelease,
|
zone->v.parm.volrelease,
|
||||||
zone->v.attenuation);
|
zone->v.attenuation);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1160,12 +1164,13 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count)
|
|||||||
|
|
||||||
/* load GUS patch */
|
/* load GUS patch */
|
||||||
int
|
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)
|
long count)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
lock_preset(sflist);
|
lock_preset(sflist);
|
||||||
rc = load_guspatch(sflist, data, count);
|
rc = load_guspatch(card, sflist, data, count);
|
||||||
unlock_preset(sflist);
|
unlock_preset(sflist);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user