Example #1
0
/*
 * read and transfer the firmware binary
 */
static int load_firmware(snd_hwdep_t *hw, const char *id, unsigned int idx, int is_pcmcia)
{
	int err;
	char fname[MAX_PATH];
	int is_xilinx = 0;
	snd_hwdep_dsp_image_t *dsp;

	if (get_file_name(id, idx, fname) < 0)
		return -EINVAL;
	if (is_pcmcia) {
		if (idx == 1)
			is_xilinx = 1;
	} else {
		if (idx == 0)
			is_xilinx = 1;
	}

	snd_hwdep_dsp_image_alloca(&dsp);
	snd_hwdep_dsp_image_set_index(dsp, idx);
	if (is_xilinx)
		err = read_xilinx_image(dsp, fname);
	else
		err = read_boot_image(dsp, fname);
	if (err < 0)
		return err;

	err = snd_hwdep_dsp_load(hw, dsp);
	if (err < 0)
		error("error in loading %s\n", fname);
	return err;
}
Example #2
0
static long snd_hwdep_ioctl(struct file * file, unsigned int cmd, unsigned long arg)
{
	snd_hwdep_t *hw = file->private_data;
	void __user *argp = (void __user *)arg;
	switch (cmd) {
	case SNDRV_HWDEP_IOCTL_PVERSION:
		return put_user(SNDRV_HWDEP_VERSION, (int __user *)argp);
	case SNDRV_HWDEP_IOCTL_INFO:
		return snd_hwdep_info(hw, argp);
	case SNDRV_HWDEP_IOCTL_DSP_STATUS:
		return snd_hwdep_dsp_status(hw, argp);
	case SNDRV_HWDEP_IOCTL_DSP_LOAD:
		return snd_hwdep_dsp_load(hw, argp);
	}
	if (hw->ops.ioctl)
		return hw->ops.ioctl(hw, file, cmd, arg);
	return -ENOTTY;
}
static int snd_hwdep_dsp_load_compat(struct snd_hwdep *hw,
                                     struct snd_hwdep_dsp_image32 __user *src)
{
    struct snd_hwdep_dsp_image __user *dst;
    compat_caddr_t ptr;
    u32 val;

    dst = compat_alloc_user_space(sizeof(*dst));


    if (copy_in_user(dst, src, 4 + 64))
        return -EFAULT;
    if (get_user(ptr, &src->image) ||
            put_user(compat_ptr(ptr), &dst->image))
        return -EFAULT;
    if (get_user(val, &src->length) ||
            put_user(val, &dst->length))
        return -EFAULT;
    if (get_user(val, &src->driver_data) ||
            put_user(val, &dst->driver_data))
        return -EFAULT;

    return snd_hwdep_dsp_load(hw, dst);
}