History

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.

Takashi Sakamoto committed 5 years ago

Commit ca15a091 parent 7d843c44 files · +35 −1Browse files

Unified · Split

4 files
  1. include/uapi/sound/firewire.h +1 −0
  2. sound/firewire/motu/motu-hwdep.c +21 −0
  3. sound/firewire/motu/motu-register-dsp-message-parser.c +11 −0
  4. sound/firewire/motu/motu.h +2 −1
include/uapi/sound/firewire.h+1−0
@@ -82,6 +82,7 @@ union snd_firewire_event { · 81 unmodified lines
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+21−0
@@ -199,6 +199,27 @@ static int hwdep_ioctl(struct snd_hwdep *hwdep, struct file *file, · 198 unmodified lines
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+11−0
@@ -299,3 +299,14 @@ void snd_motu_register_dsp_message_parser_copy_meter(struct snd_motu *motu, · 298 unmodified lines
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+2−1
@@ -280,7 +280,8 @@ void snd_motu_register_dsp_message_parser_parse(struct snd_motu *motu, const str · 279 unmodified lines
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);