| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Linux driver for M2Tech hiFace compatible devices |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 7 | 8 | * Antonio Ospite <ao2@amarulasolutions.com> |
|---|
| 8 | 9 | * |
|---|
| 9 | 10 | * The driver is based on the work done in TerraTec DMX 6Fire USB |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 12 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 13 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 14 | | - * (at your option) any later version. |
|---|
| 15 | 11 | */ |
|---|
| 16 | 12 | |
|---|
| 17 | 13 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 160 | 156 | * This control message doesn't have any ack from the |
|---|
| 161 | 157 | * other side |
|---|
| 162 | 158 | */ |
|---|
| 163 | | - ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), |
|---|
| 164 | | - HIFACE_SET_RATE_REQUEST, |
|---|
| 165 | | - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
|---|
| 166 | | - rate_value, 0, NULL, 0, 100); |
|---|
| 167 | | - if (ret < 0) { |
|---|
| 159 | + ret = usb_control_msg_send(device, 0, |
|---|
| 160 | + HIFACE_SET_RATE_REQUEST, |
|---|
| 161 | + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
|---|
| 162 | + rate_value, 0, NULL, 0, 100, GFP_KERNEL); |
|---|
| 163 | + if (ret) |
|---|
| 168 | 164 | dev_err(&device->dev, "Error setting samplerate %d.\n", rate); |
|---|
| 169 | | - return ret; |
|---|
| 170 | | - } |
|---|
| 171 | 165 | |
|---|
| 172 | | - return 0; |
|---|
| 166 | + return ret; |
|---|
| 173 | 167 | } |
|---|
| 174 | 168 | |
|---|
| 175 | 169 | static struct pcm_substream *hiface_pcm_get_substream(struct snd_pcm_substream |
|---|
| .. | .. |
|---|
| 419 | 413 | return 0; |
|---|
| 420 | 414 | } |
|---|
| 421 | 415 | |
|---|
| 422 | | -static int hiface_pcm_hw_params(struct snd_pcm_substream *alsa_sub, |
|---|
| 423 | | - struct snd_pcm_hw_params *hw_params) |
|---|
| 424 | | -{ |
|---|
| 425 | | - return snd_pcm_lib_alloc_vmalloc_buffer(alsa_sub, |
|---|
| 426 | | - params_buffer_bytes(hw_params)); |
|---|
| 427 | | -} |
|---|
| 428 | | - |
|---|
| 429 | | -static int hiface_pcm_hw_free(struct snd_pcm_substream *alsa_sub) |
|---|
| 430 | | -{ |
|---|
| 431 | | - return snd_pcm_lib_free_vmalloc_buffer(alsa_sub); |
|---|
| 432 | | -} |
|---|
| 433 | | - |
|---|
| 434 | 416 | static int hiface_pcm_prepare(struct snd_pcm_substream *alsa_sub) |
|---|
| 435 | 417 | { |
|---|
| 436 | 418 | struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); |
|---|
| .. | .. |
|---|
| 516 | 498 | static const struct snd_pcm_ops pcm_ops = { |
|---|
| 517 | 499 | .open = hiface_pcm_open, |
|---|
| 518 | 500 | .close = hiface_pcm_close, |
|---|
| 519 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 520 | | - .hw_params = hiface_pcm_hw_params, |
|---|
| 521 | | - .hw_free = hiface_pcm_hw_free, |
|---|
| 522 | 501 | .prepare = hiface_pcm_prepare, |
|---|
| 523 | 502 | .trigger = hiface_pcm_trigger, |
|---|
| 524 | 503 | .pointer = hiface_pcm_pointer, |
|---|
| 525 | | - .page = snd_pcm_lib_get_vmalloc_page, |
|---|
| 526 | 504 | }; |
|---|
| 527 | 505 | |
|---|
| 528 | 506 | static int hiface_pcm_init_urb(struct pcm_urb *urb, |
|---|
| .. | .. |
|---|
| 618 | 596 | |
|---|
| 619 | 597 | strlcpy(pcm->name, "USB-SPDIF Audio", sizeof(pcm->name)); |
|---|
| 620 | 598 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_ops); |
|---|
| 599 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, |
|---|
| 600 | + NULL, 0, 0); |
|---|
| 621 | 601 | |
|---|
| 622 | 602 | rt->instance = pcm; |
|---|
| 623 | 603 | |
|---|