| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2005-2006 Micronas USA Inc. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License (Version 2) as |
|---|
| 6 | | - * published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | 4 | */ |
|---|
| 13 | 5 | |
|---|
| 14 | 6 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 17 | 9 | #include <linux/spinlock.h> |
|---|
| 18 | 10 | #include <linux/delay.h> |
|---|
| 19 | 11 | #include <linux/sched.h> |
|---|
| 20 | | -#include <linux/vmalloc.h> |
|---|
| 21 | 12 | #include <linux/time.h> |
|---|
| 22 | 13 | #include <linux/mm.h> |
|---|
| 23 | 14 | #include <linux/i2c.h> |
|---|
| .. | .. |
|---|
| 108 | 99 | struct snd_pcm_hw_params *hw_params) |
|---|
| 109 | 100 | { |
|---|
| 110 | 101 | struct go7007 *go = snd_pcm_substream_chip(substream); |
|---|
| 111 | | - unsigned int bytes; |
|---|
| 112 | 102 | |
|---|
| 113 | | - bytes = params_buffer_bytes(hw_params); |
|---|
| 114 | | - if (substream->runtime->dma_bytes > 0) |
|---|
| 115 | | - vfree(substream->runtime->dma_area); |
|---|
| 116 | | - substream->runtime->dma_bytes = 0; |
|---|
| 117 | | - substream->runtime->dma_area = vmalloc(bytes); |
|---|
| 118 | | - if (substream->runtime->dma_area == NULL) |
|---|
| 119 | | - return -ENOMEM; |
|---|
| 120 | | - substream->runtime->dma_bytes = bytes; |
|---|
| 121 | 103 | go->audio_deliver = parse_audio_stream_data; |
|---|
| 122 | 104 | return 0; |
|---|
| 123 | 105 | } |
|---|
| .. | .. |
|---|
| 127 | 109 | struct go7007 *go = snd_pcm_substream_chip(substream); |
|---|
| 128 | 110 | |
|---|
| 129 | 111 | go->audio_deliver = NULL; |
|---|
| 130 | | - if (substream->runtime->dma_bytes > 0) |
|---|
| 131 | | - vfree(substream->runtime->dma_area); |
|---|
| 132 | | - substream->runtime->dma_bytes = 0; |
|---|
| 133 | 112 | return 0; |
|---|
| 134 | 113 | } |
|---|
| 135 | 114 | |
|---|
| .. | .. |
|---|
| 193 | 172 | return gosnd->hw_ptr; |
|---|
| 194 | 173 | } |
|---|
| 195 | 174 | |
|---|
| 196 | | -static struct page *go7007_snd_pcm_page(struct snd_pcm_substream *substream, |
|---|
| 197 | | - unsigned long offset) |
|---|
| 198 | | -{ |
|---|
| 199 | | - return vmalloc_to_page(substream->runtime->dma_area + offset); |
|---|
| 200 | | -} |
|---|
| 201 | | - |
|---|
| 202 | 175 | static const struct snd_pcm_ops go7007_snd_capture_ops = { |
|---|
| 203 | 176 | .open = go7007_snd_capture_open, |
|---|
| 204 | 177 | .close = go7007_snd_capture_close, |
|---|
| 205 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 206 | 178 | .hw_params = go7007_snd_hw_params, |
|---|
| 207 | 179 | .hw_free = go7007_snd_hw_free, |
|---|
| 208 | 180 | .prepare = go7007_snd_pcm_prepare, |
|---|
| 209 | 181 | .trigger = go7007_snd_pcm_trigger, |
|---|
| 210 | 182 | .pointer = go7007_snd_pcm_pointer, |
|---|
| 211 | | - .page = go7007_snd_pcm_page, |
|---|
| 212 | 183 | }; |
|---|
| 213 | 184 | |
|---|
| 214 | 185 | static int go7007_snd_free(struct snd_device *device) |
|---|
| .. | .. |
|---|
| 256 | 227 | if (ret < 0) |
|---|
| 257 | 228 | goto free_card; |
|---|
| 258 | 229 | |
|---|
| 259 | | - strlcpy(gosnd->card->driver, "go7007", sizeof(gosnd->card->driver)); |
|---|
| 260 | | - strlcpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->driver)); |
|---|
| 261 | | - strlcpy(gosnd->card->longname, gosnd->card->shortname, |
|---|
| 262 | | - sizeof(gosnd->card->longname)); |
|---|
| 230 | + strscpy(gosnd->card->driver, "go7007", sizeof(gosnd->card->driver)); |
|---|
| 231 | + strscpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->shortname)); |
|---|
| 232 | + strscpy(gosnd->card->longname, gosnd->card->shortname, |
|---|
| 233 | + sizeof(gosnd->card->longname)); |
|---|
| 263 | 234 | |
|---|
| 264 | 235 | gosnd->pcm->private_data = go; |
|---|
| 265 | 236 | snd_pcm_set_ops(gosnd->pcm, SNDRV_PCM_STREAM_CAPTURE, |
|---|
| 266 | 237 | &go7007_snd_capture_ops); |
|---|
| 238 | + snd_pcm_set_managed_buffer_all(gosnd->pcm, SNDRV_DMA_TYPE_VMALLOC, |
|---|
| 239 | + NULL, 0, 0); |
|---|
| 267 | 240 | |
|---|
| 268 | 241 | ret = snd_card_register(gosnd->card); |
|---|
| 269 | 242 | if (ret < 0) |
|---|