Skip to content

Commit ca15a09

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-motu: add ioctl command to read cached parameters in register DSP model
This patch adds new ioctl command for userspace applications to read cached parameters of register DSP. The structured data includes model-dependent parameters. Userspace application should be carefully programmed so that what parameter is common and specific. Signed-off-by: Takashi Sakamoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 7d843c4 commit ca15a09

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

include/uapi/sound/firewire.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ union snd_firewire_event {
8282
#define SNDRV_FIREWIRE_IOCTL_TASCAM_STATE _IOR('H', 0xfb, struct snd_firewire_tascam_state)
8383
#define SNDRV_FIREWIRE_IOCTL_MOTU_REGISTER_DSP_METER _IOR('H', 0xfc, struct snd_firewire_motu_register_dsp_meter)
8484
#define SNDRV_FIREWIRE_IOCTL_MOTU_COMMAND_DSP_METER _IOR('H', 0xfd, struct snd_firewire_motu_command_dsp_meter)
85+
#define SNDRV_FIREWIRE_IOCTL_MOTU_REGISTER_DSP_PARAMETER _IOR('H', 0xfe, struct snd_firewire_motu_register_dsp_parameter)
8586

8687
#define SNDRV_FIREWIRE_TYPE_DICE 1
8788
#define SNDRV_FIREWIRE_TYPE_FIREWORKS 2

sound/firewire/motu/motu-hwdep.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,27 @@ static int hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file,
199199

200200
return 0;
201201
}
202+
case SNDRV_FIREWIRE_IOCTL_MOTU_REGISTER_DSP_PARAMETER:
203+
{
204+
struct snd_firewire_motu_register_dsp_parameter *param;
205+
int err;
206+
207+
if (!(motu->spec->flags & SND_MOTU_SPEC_REGISTER_DSP))
208+
return -ENXIO;
209+
210+
param = kzalloc(sizeof(*param), GFP_KERNEL);
211+
if (!param)
212+
return -ENOMEM;
213+
214+
snd_motu_register_dsp_message_parser_copy_parameter(motu, param);
215+
216+
err = copy_to_user((void __user *)arg, param, sizeof(*param));
217+
kfree(param);
218+
if (err)
219+
return -EFAULT;
220+
221+
return 0;
222+
}
202223
default:
203224
return -ENOIOCTLCMD;
204225
}

sound/firewire/motu/motu-register-dsp-message-parser.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,14 @@ void snd_motu_register_dsp_message_parser_copy_meter(struct snd_motu *motu,
299299
memcpy(meter, &parser->meter, sizeof(*meter));
300300
spin_unlock_irqrestore(&parser->lock, flags);
301301
}
302+
303+
void snd_motu_register_dsp_message_parser_copy_parameter(struct snd_motu *motu,
304+
struct snd_firewire_motu_register_dsp_parameter *param)
305+
{
306+
struct msg_parser *parser = motu->message_parser;
307+
unsigned long flags;
308+
309+
spin_lock_irqsave(&parser->lock, flags);
310+
memcpy(param, &parser->param, sizeof(*param));
311+
spin_unlock_irqrestore(&parser->lock, flags);
312+
}

sound/firewire/motu/motu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ void snd_motu_register_dsp_message_parser_parse(struct snd_motu *motu, const str
280280
unsigned int desc_count, unsigned int data_block_quadlets);
281281
void snd_motu_register_dsp_message_parser_copy_meter(struct snd_motu *motu,
282282
struct snd_firewire_motu_register_dsp_meter *meter);
283-
283+
void snd_motu_register_dsp_message_parser_copy_parameter(struct snd_motu *motu,
284+
struct snd_firewire_motu_register_dsp_parameter *params);
284285

285286
int snd_motu_command_dsp_message_parser_new(struct snd_motu *motu);
286287
int snd_motu_command_dsp_message_parser_init(struct snd_motu *motu, enum cip_sfc sfc);

0 commit comments

Comments
 (0)