Greg Kroah-Hartman | 1a79f22 | 2017-11-07 14:58:50 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 2 | /* |
Christian Gromm | 1f95cf0 | 2017-11-21 15:05:06 +0100 | [diff] [blame] | 3 | * sound.c - Sound component for Mostcore |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/printk.h> |
| 12 | #include <linux/kernel.h> |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 13 | #include <linux/slab.h> |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 14 | #include <linux/init.h> |
| 15 | #include <sound/core.h> |
| 16 | #include <sound/pcm.h> |
Christian Gromm | 8e4a0ef | 2015-09-28 17:18:47 +0200 | [diff] [blame] | 17 | #include <sound/pcm_params.h> |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 18 | #include <linux/sched.h> |
| 19 | #include <linux/kthread.h> |
Christian Gromm | b276527 | 2020-03-10 14:02:40 +0100 | [diff] [blame] | 20 | #include <linux/most.h> |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 21 | |
| 22 | #define DRIVER_NAME "sound" |
Christian Gromm | acdbb89 | 2019-04-03 15:19:52 +0200 | [diff] [blame] | 23 | #define STRING_SIZE 80 |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 24 | |
Christian Gromm | 45917e7 | 2019-12-13 13:04:15 +0100 | [diff] [blame] | 25 | static struct most_component comp; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * struct channel - private structure to keep channel specific data |
| 29 | * @substream: stores the substream structure |
| 30 | * @iface: interface for which the channel belongs to |
| 31 | * @cfg: channel configuration |
| 32 | * @card: registered sound card |
| 33 | * @list: list for private use |
| 34 | * @id: channel index |
| 35 | * @period_pos: current period position (ring buffer) |
| 36 | * @buffer_pos: current buffer position (ring buffer) |
| 37 | * @is_stream_running: identifies whether a stream is running or not |
| 38 | * @opened: set when the stream is opened |
| 39 | * @playback_task: playback thread |
| 40 | * @playback_waitq: waitq used by playback thread |
| 41 | */ |
| 42 | struct channel { |
| 43 | struct snd_pcm_substream *substream; |
Christian Gromm | d801887 | 2015-09-28 17:18:49 +0200 | [diff] [blame] | 44 | struct snd_pcm_hardware pcm_hardware; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 45 | struct most_interface *iface; |
| 46 | struct most_channel_config *cfg; |
| 47 | struct snd_card *card; |
| 48 | struct list_head list; |
| 49 | int id; |
| 50 | unsigned int period_pos; |
| 51 | unsigned int buffer_pos; |
| 52 | bool is_stream_running; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 53 | struct task_struct *playback_task; |
| 54 | wait_queue_head_t playback_waitq; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 55 | void (*copy_fn)(void *alsa, void *most, unsigned int bytes); |
| 56 | }; |
| 57 | |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 58 | struct sound_adapter { |
| 59 | struct list_head dev_list; |
| 60 | struct most_interface *iface; |
| 61 | struct snd_card *card; |
| 62 | struct list_head list; |
| 63 | bool registered; |
| 64 | int pcm_dev_idx; |
| 65 | }; |
| 66 | |
| 67 | static struct list_head adpt_list; |
| 68 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 69 | #define MOST_PCM_INFO (SNDRV_PCM_INFO_MMAP | \ |
| 70 | SNDRV_PCM_INFO_MMAP_VALID | \ |
| 71 | SNDRV_PCM_INFO_BATCH | \ |
| 72 | SNDRV_PCM_INFO_INTERLEAVED | \ |
| 73 | SNDRV_PCM_INFO_BLOCK_TRANSFER) |
| 74 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 75 | static void swap_copy16(u16 *dest, const u16 *source, unsigned int bytes) |
| 76 | { |
| 77 | unsigned int i = 0; |
| 78 | |
| 79 | while (i < (bytes / 2)) { |
Christian Gromm | eb27cf0 | 2020-11-04 13:50:42 +0100 | [diff] [blame] | 80 | dest[i] = swab16(source[i]); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 81 | i++; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes) |
| 86 | { |
| 87 | unsigned int i = 0; |
| 88 | |
Christian Gromm | 45b754a | 2021-02-02 17:21:05 +0100 | [diff] [blame] | 89 | if (bytes < 2) |
| 90 | return; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 91 | while (i < bytes - 2) { |
| 92 | dest[i] = source[i + 2]; |
| 93 | dest[i + 1] = source[i + 1]; |
| 94 | dest[i + 2] = source[i]; |
| 95 | i += 3; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | static void swap_copy32(u32 *dest, const u32 *source, unsigned int bytes) |
| 100 | { |
| 101 | unsigned int i = 0; |
| 102 | |
| 103 | while (i < bytes / 4) { |
Christian Gromm | eb27cf0 | 2020-11-04 13:50:42 +0100 | [diff] [blame] | 104 | dest[i] = swab32(source[i]); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 105 | i++; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | static void alsa_to_most_memcpy(void *alsa, void *most, unsigned int bytes) |
| 110 | { |
| 111 | memcpy(most, alsa, bytes); |
| 112 | } |
| 113 | |
| 114 | static void alsa_to_most_copy16(void *alsa, void *most, unsigned int bytes) |
| 115 | { |
| 116 | swap_copy16(most, alsa, bytes); |
| 117 | } |
| 118 | |
| 119 | static void alsa_to_most_copy24(void *alsa, void *most, unsigned int bytes) |
| 120 | { |
| 121 | swap_copy24(most, alsa, bytes); |
| 122 | } |
| 123 | |
| 124 | static void alsa_to_most_copy32(void *alsa, void *most, unsigned int bytes) |
| 125 | { |
| 126 | swap_copy32(most, alsa, bytes); |
| 127 | } |
| 128 | |
| 129 | static void most_to_alsa_memcpy(void *alsa, void *most, unsigned int bytes) |
| 130 | { |
| 131 | memcpy(alsa, most, bytes); |
| 132 | } |
| 133 | |
| 134 | static void most_to_alsa_copy16(void *alsa, void *most, unsigned int bytes) |
| 135 | { |
| 136 | swap_copy16(alsa, most, bytes); |
| 137 | } |
| 138 | |
| 139 | static void most_to_alsa_copy24(void *alsa, void *most, unsigned int bytes) |
| 140 | { |
| 141 | swap_copy24(alsa, most, bytes); |
| 142 | } |
| 143 | |
| 144 | static void most_to_alsa_copy32(void *alsa, void *most, unsigned int bytes) |
| 145 | { |
| 146 | swap_copy32(alsa, most, bytes); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * get_channel - get pointer to channel |
| 151 | * @iface: interface structure |
| 152 | * @channel_id: channel ID |
| 153 | * |
| 154 | * This traverses the channel list and returns the channel matching the |
| 155 | * ID and interface. |
| 156 | * |
| 157 | * Returns pointer to channel on success or NULL otherwise. |
| 158 | */ |
| 159 | static struct channel *get_channel(struct most_interface *iface, |
| 160 | int channel_id) |
| 161 | { |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 162 | struct sound_adapter *adpt = iface->priv; |
Christian Gromm | 9810cad | 2021-02-02 12:38:10 +0100 | [diff] [blame] | 163 | struct channel *channel; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 164 | |
Christian Gromm | 9810cad | 2021-02-02 12:38:10 +0100 | [diff] [blame] | 165 | list_for_each_entry(channel, &adpt->dev_list, list) { |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 166 | if ((channel->iface == iface) && (channel->id == channel_id)) |
| 167 | return channel; |
| 168 | } |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 169 | return NULL; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * copy_data - implements data copying function |
| 174 | * @channel: channel |
| 175 | * @mbo: MBO from core |
| 176 | * |
| 177 | * Copy data from/to ring buffer to/from MBO and update the buffer position |
| 178 | */ |
| 179 | static bool copy_data(struct channel *channel, struct mbo *mbo) |
| 180 | { |
| 181 | struct snd_pcm_runtime *const runtime = channel->substream->runtime; |
| 182 | unsigned int const frame_bytes = channel->cfg->subbuffer_size; |
| 183 | unsigned int const buffer_size = runtime->buffer_size; |
| 184 | unsigned int frames; |
| 185 | unsigned int fr0; |
| 186 | |
| 187 | if (channel->cfg->direction & MOST_CH_RX) |
| 188 | frames = mbo->processed_length / frame_bytes; |
| 189 | else |
| 190 | frames = mbo->buffer_length / frame_bytes; |
| 191 | fr0 = min(buffer_size - channel->buffer_pos, frames); |
| 192 | |
| 193 | channel->copy_fn(runtime->dma_area + channel->buffer_pos * frame_bytes, |
| 194 | mbo->virt_address, |
| 195 | fr0 * frame_bytes); |
| 196 | |
| 197 | if (frames > fr0) { |
| 198 | /* wrap around at end of ring buffer */ |
| 199 | channel->copy_fn(runtime->dma_area, |
| 200 | mbo->virt_address + fr0 * frame_bytes, |
| 201 | (frames - fr0) * frame_bytes); |
| 202 | } |
| 203 | |
| 204 | channel->buffer_pos += frames; |
| 205 | if (channel->buffer_pos >= buffer_size) |
| 206 | channel->buffer_pos -= buffer_size; |
| 207 | channel->period_pos += frames; |
| 208 | if (channel->period_pos >= runtime->period_size) { |
| 209 | channel->period_pos -= runtime->period_size; |
| 210 | return true; |
| 211 | } |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 212 | return false; |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * playback_thread - function implements the playback thread |
| 217 | * @data: private data |
| 218 | * |
| 219 | * Thread which does the playback functionality in a loop. It waits for a free |
| 220 | * MBO from mostcore for a particular channel and copy the data from ring buffer |
| 221 | * to MBO. Submit the MBO back to mostcore, after copying the data. |
| 222 | * |
| 223 | * Returns 0 on success or error code otherwise. |
| 224 | */ |
| 225 | static int playback_thread(void *data) |
| 226 | { |
| 227 | struct channel *const channel = data; |
| 228 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 229 | while (!kthread_should_stop()) { |
| 230 | struct mbo *mbo = NULL; |
| 231 | bool period_elapsed = false; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 232 | |
| 233 | wait_event_interruptible( |
| 234 | channel->playback_waitq, |
| 235 | kthread_should_stop() || |
Christian Gromm | 5e8aa94 | 2015-09-28 17:18:58 +0200 | [diff] [blame] | 236 | (channel->is_stream_running && |
| 237 | (mbo = most_get_mbo(channel->iface, channel->id, |
Christian Gromm | 1f95cf0 | 2017-11-21 15:05:06 +0100 | [diff] [blame] | 238 | &comp)))); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 239 | if (!mbo) |
| 240 | continue; |
| 241 | |
| 242 | if (channel->is_stream_running) |
| 243 | period_elapsed = copy_data(channel, mbo); |
| 244 | else |
| 245 | memset(mbo->virt_address, 0, mbo->buffer_length); |
| 246 | |
Christian Gromm | a6f9d84 | 2016-09-21 14:49:05 +0200 | [diff] [blame] | 247 | most_submit_mbo(mbo); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 248 | if (period_elapsed) |
| 249 | snd_pcm_period_elapsed(channel->substream); |
| 250 | } |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 251 | return 0; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * pcm_open - implements open callback function for PCM middle layer |
| 256 | * @substream: pointer to ALSA PCM substream |
| 257 | * |
| 258 | * This is called when a PCM substream is opened. At least, the function should |
| 259 | * initialize the runtime->hw record. |
| 260 | * |
| 261 | * Returns 0 on success or error code otherwise. |
| 262 | */ |
| 263 | static int pcm_open(struct snd_pcm_substream *substream) |
| 264 | { |
| 265 | struct channel *channel = substream->private_data; |
| 266 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 267 | struct most_channel_config *cfg = channel->cfg; |
Christian Gromm | b1abd84 | 2020-06-23 17:07:33 +0200 | [diff] [blame] | 268 | int ret; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 269 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 270 | channel->substream = substream; |
| 271 | |
| 272 | if (cfg->direction == MOST_CH_TX) { |
Shraddha Barke | 246ed51 | 2015-10-13 21:07:49 +0530 | [diff] [blame] | 273 | channel->playback_task = kthread_run(playback_thread, channel, |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 274 | "most_audio_playback"); |
Christian Gromm | 5e8aa94 | 2015-09-28 17:18:58 +0200 | [diff] [blame] | 275 | if (IS_ERR(channel->playback_task)) { |
| 276 | pr_err("Couldn't start thread\n"); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 277 | return PTR_ERR(channel->playback_task); |
Christian Gromm | 5e8aa94 | 2015-09-28 17:18:58 +0200 | [diff] [blame] | 278 | } |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 279 | } |
| 280 | |
Christian Gromm | b1abd84 | 2020-06-23 17:07:33 +0200 | [diff] [blame] | 281 | ret = most_start_channel(channel->iface, channel->id, &comp); |
| 282 | if (ret) { |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 283 | pr_err("most_start_channel() failed!\n"); |
| 284 | if (cfg->direction == MOST_CH_TX) |
| 285 | kthread_stop(channel->playback_task); |
Christian Gromm | b1abd84 | 2020-06-23 17:07:33 +0200 | [diff] [blame] | 286 | return ret; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 287 | } |
| 288 | |
Christian Gromm | d801887 | 2015-09-28 17:18:49 +0200 | [diff] [blame] | 289 | runtime->hw = channel->pcm_hardware; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * pcm_close - implements close callback function for PCM middle layer |
| 295 | * @substream: sub-stream pointer |
| 296 | * |
| 297 | * Obviously, this is called when a PCM substream is closed. Any private |
| 298 | * instance for a PCM substream allocated in the open callback will be |
| 299 | * released here. |
| 300 | * |
| 301 | * Returns 0 on success or error code otherwise. |
| 302 | */ |
| 303 | static int pcm_close(struct snd_pcm_substream *substream) |
| 304 | { |
| 305 | struct channel *channel = substream->private_data; |
| 306 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 307 | if (channel->cfg->direction == MOST_CH_TX) |
| 308 | kthread_stop(channel->playback_task); |
Christian Gromm | 1f95cf0 | 2017-11-21 15:05:06 +0100 | [diff] [blame] | 309 | most_stop_channel(channel->iface, channel->id, &comp); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | /** |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 314 | * pcm_prepare - implements prepare callback function for PCM middle layer |
| 315 | * @substream: substream pointer |
| 316 | * |
| 317 | * This callback is called when the PCM is "prepared". Format rate, sample rate, |
| 318 | * etc., can be set here. This callback can be called many times at each setup. |
| 319 | * |
| 320 | * Returns 0 on success or error code otherwise. |
| 321 | */ |
| 322 | static int pcm_prepare(struct snd_pcm_substream *substream) |
| 323 | { |
| 324 | struct channel *channel = substream->private_data; |
| 325 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 326 | struct most_channel_config *cfg = channel->cfg; |
| 327 | int width = snd_pcm_format_physical_width(runtime->format); |
| 328 | |
| 329 | channel->copy_fn = NULL; |
| 330 | |
| 331 | if (cfg->direction == MOST_CH_TX) { |
| 332 | if (snd_pcm_format_big_endian(runtime->format) || width == 8) |
| 333 | channel->copy_fn = alsa_to_most_memcpy; |
| 334 | else if (width == 16) |
| 335 | channel->copy_fn = alsa_to_most_copy16; |
| 336 | else if (width == 24) |
| 337 | channel->copy_fn = alsa_to_most_copy24; |
| 338 | else if (width == 32) |
| 339 | channel->copy_fn = alsa_to_most_copy32; |
| 340 | } else { |
| 341 | if (snd_pcm_format_big_endian(runtime->format) || width == 8) |
| 342 | channel->copy_fn = most_to_alsa_memcpy; |
| 343 | else if (width == 16) |
| 344 | channel->copy_fn = most_to_alsa_copy16; |
| 345 | else if (width == 24) |
| 346 | channel->copy_fn = most_to_alsa_copy24; |
| 347 | else if (width == 32) |
| 348 | channel->copy_fn = most_to_alsa_copy32; |
| 349 | } |
| 350 | |
Christian Gromm | c0b122a0 | 2020-06-23 17:07:31 +0200 | [diff] [blame] | 351 | if (!channel->copy_fn) |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 352 | return -EINVAL; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 353 | channel->period_pos = 0; |
| 354 | channel->buffer_pos = 0; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 355 | return 0; |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * pcm_trigger - implements trigger callback function for PCM middle layer |
| 360 | * @substream: substream pointer |
| 361 | * @cmd: action to perform |
| 362 | * |
| 363 | * This is called when the PCM is started, stopped or paused. The action will be |
| 364 | * specified in the second argument, SNDRV_PCM_TRIGGER_XXX |
| 365 | * |
| 366 | * Returns 0 on success or error code otherwise. |
| 367 | */ |
| 368 | static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
| 369 | { |
| 370 | struct channel *channel = substream->private_data; |
| 371 | |
| 372 | switch (cmd) { |
| 373 | case SNDRV_PCM_TRIGGER_START: |
| 374 | channel->is_stream_running = true; |
Christian Gromm | 5e8aa94 | 2015-09-28 17:18:58 +0200 | [diff] [blame] | 375 | wake_up_interruptible(&channel->playback_waitq); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 376 | return 0; |
| 377 | |
| 378 | case SNDRV_PCM_TRIGGER_STOP: |
| 379 | channel->is_stream_running = false; |
| 380 | return 0; |
| 381 | |
| 382 | default: |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 383 | return -EINVAL; |
| 384 | } |
| 385 | return 0; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * pcm_pointer - implements pointer callback function for PCM middle layer |
| 390 | * @substream: substream pointer |
| 391 | * |
| 392 | * This callback is called when the PCM middle layer inquires the current |
| 393 | * hardware position on the buffer. The position must be returned in frames, |
| 394 | * ranging from 0 to buffer_size-1. |
| 395 | */ |
| 396 | static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream) |
| 397 | { |
| 398 | struct channel *channel = substream->private_data; |
| 399 | |
| 400 | return channel->buffer_pos; |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Initialization of struct snd_pcm_ops |
| 405 | */ |
Bhumika Goyal | cfb459e | 2016-09-26 23:09:03 +0530 | [diff] [blame] | 406 | static const struct snd_pcm_ops pcm_ops = { |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 407 | .open = pcm_open, |
| 408 | .close = pcm_close, |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 409 | .prepare = pcm_prepare, |
| 410 | .trigger = pcm_trigger, |
| 411 | .pointer = pcm_pointer, |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 412 | }; |
| 413 | |
Christian Gromm | 9640bac | 2019-04-03 15:19:47 +0200 | [diff] [blame] | 414 | static int split_arg_list(char *buf, u16 *ch_num, char **sample_res) |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 415 | { |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 416 | char *num; |
| 417 | int ret; |
| 418 | |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 419 | num = strsep(&buf, "x"); |
| 420 | if (!num) |
| 421 | goto err; |
| 422 | ret = kstrtou16(num, 0, ch_num); |
| 423 | if (ret) |
| 424 | goto err; |
| 425 | *sample_res = strsep(&buf, ".\n"); |
| 426 | if (!*sample_res) |
| 427 | goto err; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 428 | return 0; |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 429 | |
| 430 | err: |
| 431 | pr_err("Bad PCM format\n"); |
Christian Gromm | b1abd84 | 2020-06-23 17:07:33 +0200 | [diff] [blame] | 432 | return -EINVAL; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 433 | } |
| 434 | |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 435 | static const struct sample_resolution_info { |
| 436 | const char *sample_res; |
| 437 | int bytes; |
| 438 | u64 formats; |
| 439 | } sinfo[] = { |
| 440 | { "8", 1, SNDRV_PCM_FMTBIT_S8 }, |
| 441 | { "16", 2, SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE }, |
| 442 | { "24", 3, SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE }, |
| 443 | { "32", 4, SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE }, |
| 444 | }; |
| 445 | |
Christian Gromm | fb0056a | 2015-09-28 17:18:53 +0200 | [diff] [blame] | 446 | static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw, |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 447 | u16 ch_num, char *sample_res, |
Christian Gromm | 35c3372 | 2015-09-28 17:18:55 +0200 | [diff] [blame] | 448 | struct most_channel_config *cfg) |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 449 | { |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 450 | int i; |
| 451 | |
| 452 | for (i = 0; i < ARRAY_SIZE(sinfo); i++) { |
| 453 | if (!strcmp(sample_res, sinfo[i].sample_res)) |
| 454 | goto found; |
| 455 | } |
| 456 | pr_err("Unsupported PCM format\n"); |
Christian Gromm | b1abd84 | 2020-06-23 17:07:33 +0200 | [diff] [blame] | 457 | return -EINVAL; |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 458 | |
| 459 | found: |
| 460 | if (!ch_num) { |
| 461 | pr_err("Bad number of channels\n"); |
| 462 | return -EINVAL; |
| 463 | } |
| 464 | |
| 465 | if (cfg->subbuffer_size != ch_num * sinfo[i].bytes) { |
| 466 | pr_err("Audio resolution doesn't fit subbuffer size\n"); |
| 467 | return -EINVAL; |
| 468 | } |
| 469 | |
Christian Gromm | e569da2 | 2015-09-28 17:18:54 +0200 | [diff] [blame] | 470 | pcm_hw->info = MOST_PCM_INFO; |
| 471 | pcm_hw->rates = SNDRV_PCM_RATE_48000; |
| 472 | pcm_hw->rate_min = 48000; |
| 473 | pcm_hw->rate_max = 48000; |
| 474 | pcm_hw->buffer_bytes_max = cfg->num_buffers * cfg->buffer_size; |
| 475 | pcm_hw->period_bytes_min = cfg->buffer_size; |
| 476 | pcm_hw->period_bytes_max = cfg->buffer_size; |
| 477 | pcm_hw->periods_min = 1; |
| 478 | pcm_hw->periods_max = cfg->num_buffers; |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 479 | pcm_hw->channels_min = ch_num; |
| 480 | pcm_hw->channels_max = ch_num; |
| 481 | pcm_hw->formats = sinfo[i].formats; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 482 | return 0; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 483 | } |
| 484 | |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 485 | static void release_adapter(struct sound_adapter *adpt) |
| 486 | { |
| 487 | struct channel *channel, *tmp; |
| 488 | |
| 489 | list_for_each_entry_safe(channel, tmp, &adpt->dev_list, list) { |
| 490 | list_del(&channel->list); |
| 491 | kfree(channel); |
| 492 | } |
| 493 | if (adpt->card) |
| 494 | snd_card_free(adpt->card); |
| 495 | list_del(&adpt->list); |
| 496 | kfree(adpt); |
| 497 | } |
| 498 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 499 | /** |
| 500 | * audio_probe_channel - probe function of the driver module |
| 501 | * @iface: pointer to interface instance |
| 502 | * @channel_id: channel index/ID |
| 503 | * @cfg: pointer to actual channel configuration |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 504 | * @arg_list: string that provides the name of the device to be created in /dev |
| 505 | * plus the desired audio resolution |
| 506 | * |
| 507 | * Creates sound card, pcm device, sets pcm ops and registers sound card. |
| 508 | * |
| 509 | * Returns 0 on success or error code otherwise. |
| 510 | */ |
| 511 | static int audio_probe_channel(struct most_interface *iface, int channel_id, |
| 512 | struct most_channel_config *cfg, |
Christian Gromm | dfee92d | 2019-04-03 15:19:45 +0200 | [diff] [blame] | 513 | char *device_name, char *arg_list) |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 514 | { |
| 515 | struct channel *channel; |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 516 | struct sound_adapter *adpt; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 517 | struct snd_pcm *pcm; |
| 518 | int playback_count = 0; |
| 519 | int capture_count = 0; |
| 520 | int ret; |
| 521 | int direction; |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 522 | u16 ch_num; |
| 523 | char *sample_res; |
Christian Gromm | acdbb89 | 2019-04-03 15:19:52 +0200 | [diff] [blame] | 524 | char arg_list_cpy[STRING_SIZE]; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 525 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 526 | if (cfg->data_type != MOST_CH_SYNC) { |
| 527 | pr_err("Incompatible channel type\n"); |
| 528 | return -EINVAL; |
| 529 | } |
Kumar Kartikeya Dwivedi | 6367dee | 2021-01-31 22:58:25 +0530 | [diff] [blame] | 530 | strscpy(arg_list_cpy, arg_list, STRING_SIZE); |
Christian Gromm | acdbb89 | 2019-04-03 15:19:52 +0200 | [diff] [blame] | 531 | ret = split_arg_list(arg_list_cpy, &ch_num, &sample_res); |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 532 | if (ret < 0) |
| 533 | return ret; |
| 534 | |
| 535 | list_for_each_entry(adpt, &adpt_list, list) { |
| 536 | if (adpt->iface != iface) |
| 537 | continue; |
| 538 | if (adpt->registered) |
| 539 | return -ENOSPC; |
| 540 | adpt->pcm_dev_idx++; |
| 541 | goto skip_adpt_alloc; |
| 542 | } |
| 543 | adpt = kzalloc(sizeof(*adpt), GFP_KERNEL); |
| 544 | if (!adpt) |
| 545 | return -ENOMEM; |
| 546 | |
| 547 | adpt->iface = iface; |
| 548 | INIT_LIST_HEAD(&adpt->dev_list); |
| 549 | iface->priv = adpt; |
| 550 | list_add_tail(&adpt->list, &adpt_list); |
Christian Gromm | 98592c1 | 2019-04-30 14:07:48 +0200 | [diff] [blame] | 551 | ret = snd_card_new(iface->driver_dev, -1, "INIC", THIS_MODULE, |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 552 | sizeof(*channel), &adpt->card); |
| 553 | if (ret < 0) |
Christian Gromm | ba99c63 | 2018-12-17 15:10:13 +0100 | [diff] [blame] | 554 | goto err_free_adpt; |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 555 | snprintf(adpt->card->driver, sizeof(adpt->card->driver), |
| 556 | "%s", DRIVER_NAME); |
| 557 | snprintf(adpt->card->shortname, sizeof(adpt->card->shortname), |
Christian Gromm | 6cebb201 | 2018-12-17 15:10:15 +0100 | [diff] [blame] | 558 | "Microchip INIC"); |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 559 | snprintf(adpt->card->longname, sizeof(adpt->card->longname), |
Christian Gromm | e6861b9 | 2018-12-17 15:10:16 +0100 | [diff] [blame] | 560 | "%s at %s", adpt->card->shortname, iface->description); |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 561 | skip_adpt_alloc: |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 562 | if (get_channel(iface, channel_id)) { |
| 563 | pr_err("channel (%s:%d) is already linked\n", |
| 564 | iface->description, channel_id); |
Christian Gromm | b1abd84 | 2020-06-23 17:07:33 +0200 | [diff] [blame] | 565 | return -EEXIST; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | if (cfg->direction == MOST_CH_TX) { |
| 569 | playback_count = 1; |
| 570 | direction = SNDRV_PCM_STREAM_PLAYBACK; |
| 571 | } else { |
| 572 | capture_count = 1; |
| 573 | direction = SNDRV_PCM_STREAM_CAPTURE; |
| 574 | } |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 575 | channel = kzalloc(sizeof(*channel), GFP_KERNEL); |
| 576 | if (!channel) { |
| 577 | ret = -ENOMEM; |
Christian Gromm | ba99c63 | 2018-12-17 15:10:13 +0100 | [diff] [blame] | 578 | goto err_free_adpt; |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 579 | } |
| 580 | channel->card = adpt->card; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 581 | channel->cfg = cfg; |
| 582 | channel->iface = iface; |
| 583 | channel->id = channel_id; |
Christian Gromm | 5e8aa94 | 2015-09-28 17:18:58 +0200 | [diff] [blame] | 584 | init_waitqueue_head(&channel->playback_waitq); |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 585 | list_add_tail(&channel->list, &adpt->dev_list); |
Christian Gromm | d801887 | 2015-09-28 17:18:49 +0200 | [diff] [blame] | 586 | |
Christian Gromm | ed856eb | 2018-05-08 11:44:54 +0200 | [diff] [blame] | 587 | ret = audio_set_hw_params(&channel->pcm_hardware, ch_num, sample_res, |
| 588 | cfg); |
Wei Yongjun | ca8b3fa | 2016-09-25 15:41:11 +0000 | [diff] [blame] | 589 | if (ret) |
Christian Gromm | ba99c63 | 2018-12-17 15:10:13 +0100 | [diff] [blame] | 590 | goto err_free_adpt; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 591 | |
Christian Gromm | 4c6375d | 2018-12-17 15:10:14 +0100 | [diff] [blame] | 592 | ret = snd_pcm_new(adpt->card, device_name, adpt->pcm_dev_idx, |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 593 | playback_count, capture_count, &pcm); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 594 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 595 | if (ret < 0) |
Christian Gromm | ba99c63 | 2018-12-17 15:10:13 +0100 | [diff] [blame] | 596 | goto err_free_adpt; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 597 | |
| 598 | pcm->private_data = channel; |
Colin Ian King | a86028f | 2018-12-18 11:35:52 +0000 | [diff] [blame] | 599 | strscpy(pcm->name, device_name, sizeof(pcm->name)); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 600 | snd_pcm_set_ops(pcm, direction, &pcm_ops); |
Takashi Iwai | 7e6d24d | 2019-12-10 15:13:53 +0100 | [diff] [blame] | 601 | snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 602 | return 0; |
| 603 | |
Christian Gromm | ba99c63 | 2018-12-17 15:10:13 +0100 | [diff] [blame] | 604 | err_free_adpt: |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 605 | release_adapter(adpt); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 606 | return ret; |
| 607 | } |
| 608 | |
Christian Gromm | 9640bac | 2019-04-03 15:19:47 +0200 | [diff] [blame] | 609 | static int audio_create_sound_card(void) |
| 610 | { |
| 611 | int ret; |
| 612 | struct sound_adapter *adpt; |
| 613 | |
| 614 | list_for_each_entry(adpt, &adpt_list, list) { |
| 615 | if (!adpt->registered) |
| 616 | goto adpt_alloc; |
| 617 | } |
| 618 | return -ENODEV; |
| 619 | adpt_alloc: |
| 620 | ret = snd_card_register(adpt->card); |
| 621 | if (ret < 0) { |
| 622 | release_adapter(adpt); |
| 623 | return ret; |
| 624 | } |
| 625 | adpt->registered = true; |
| 626 | return 0; |
| 627 | } |
| 628 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 629 | /** |
| 630 | * audio_disconnect_channel - function to disconnect a channel |
| 631 | * @iface: pointer to interface instance |
| 632 | * @channel_id: channel index |
| 633 | * |
| 634 | * This frees allocated memory and removes the sound card from ALSA |
| 635 | * |
| 636 | * Returns 0 on success or error code otherwise. |
| 637 | */ |
| 638 | static int audio_disconnect_channel(struct most_interface *iface, |
| 639 | int channel_id) |
| 640 | { |
| 641 | struct channel *channel; |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 642 | struct sound_adapter *adpt = iface->priv; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 643 | |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 644 | channel = get_channel(iface, channel_id); |
Christian Gromm | c0b122a0 | 2020-06-23 17:07:31 +0200 | [diff] [blame] | 645 | if (!channel) |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 646 | return -EINVAL; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 647 | |
| 648 | list_del(&channel->list); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 649 | |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 650 | kfree(channel); |
| 651 | if (list_empty(&adpt->dev_list)) |
| 652 | release_adapter(adpt); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 653 | return 0; |
| 654 | } |
| 655 | |
| 656 | /** |
| 657 | * audio_rx_completion - completion handler for rx channels |
| 658 | * @mbo: pointer to buffer object that has completed |
| 659 | * |
| 660 | * This searches for the channel this MBO belongs to and copy the data from MBO |
| 661 | * to ring buffer |
| 662 | * |
| 663 | * Returns 0 on success or error code otherwise. |
| 664 | */ |
| 665 | static int audio_rx_completion(struct mbo *mbo) |
| 666 | { |
| 667 | struct channel *channel = get_channel(mbo->ifp, mbo->hdm_channel_id); |
| 668 | bool period_elapsed = false; |
| 669 | |
Christian Gromm | c0b122a0 | 2020-06-23 17:07:31 +0200 | [diff] [blame] | 670 | if (!channel) |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 671 | return -EINVAL; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 672 | if (channel->is_stream_running) |
| 673 | period_elapsed = copy_data(channel, mbo); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 674 | most_put_mbo(mbo); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 675 | if (period_elapsed) |
| 676 | snd_pcm_period_elapsed(channel->substream); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | /** |
| 681 | * audio_tx_completion - completion handler for tx channels |
| 682 | * @iface: pointer to interface instance |
| 683 | * @channel_id: channel index/ID |
| 684 | * |
| 685 | * This searches the channel that belongs to this combination of interface |
| 686 | * pointer and channel ID and wakes a process sitting in the wait queue of |
| 687 | * this channel. |
| 688 | * |
| 689 | * Returns 0 on success or error code otherwise. |
| 690 | */ |
| 691 | static int audio_tx_completion(struct most_interface *iface, int channel_id) |
| 692 | { |
| 693 | struct channel *channel = get_channel(iface, channel_id); |
| 694 | |
Christian Gromm | c0b122a0 | 2020-06-23 17:07:31 +0200 | [diff] [blame] | 695 | if (!channel) |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 696 | return -EINVAL; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 697 | |
| 698 | wake_up_interruptible(&channel->playback_waitq); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 699 | return 0; |
| 700 | } |
| 701 | |
| 702 | /** |
Christian Gromm | 45917e7 | 2019-12-13 13:04:15 +0100 | [diff] [blame] | 703 | * Initialization of the struct most_component |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 704 | */ |
Christian Gromm | 45917e7 | 2019-12-13 13:04:15 +0100 | [diff] [blame] | 705 | static struct most_component comp = { |
Christian Gromm | 08283d3 | 2019-11-08 17:21:08 +0100 | [diff] [blame] | 706 | .mod = THIS_MODULE, |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 707 | .name = DRIVER_NAME, |
| 708 | .probe_channel = audio_probe_channel, |
| 709 | .disconnect_channel = audio_disconnect_channel, |
| 710 | .rx_completion = audio_rx_completion, |
| 711 | .tx_completion = audio_tx_completion, |
Christian Gromm | 9640bac | 2019-04-03 15:19:47 +0200 | [diff] [blame] | 712 | .cfg_complete = audio_create_sound_card, |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 713 | }; |
| 714 | |
| 715 | static int __init audio_init(void) |
| 716 | { |
Christian Gromm | 919c03a | 2019-04-03 15:19:48 +0200 | [diff] [blame] | 717 | int ret; |
| 718 | |
Christian Gromm | 15600ae | 2018-12-17 15:10:12 +0100 | [diff] [blame] | 719 | INIT_LIST_HEAD(&adpt_list); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 720 | |
Christian Gromm | 919c03a | 2019-04-03 15:19:48 +0200 | [diff] [blame] | 721 | ret = most_register_component(&comp); |
Christian Gromm | 36b67ef | 2020-06-23 17:07:32 +0200 | [diff] [blame] | 722 | if (ret) { |
Christian Gromm | 919c03a | 2019-04-03 15:19:48 +0200 | [diff] [blame] | 723 | pr_err("Failed to register %s\n", comp.name); |
Christian Gromm | 36b67ef | 2020-06-23 17:07:32 +0200 | [diff] [blame] | 724 | return ret; |
| 725 | } |
Christian Gromm | 919c03a | 2019-04-03 15:19:48 +0200 | [diff] [blame] | 726 | ret = most_register_configfs_subsys(&comp); |
YueHaibing | 3982f1d | 2019-08-27 21:13:46 +0800 | [diff] [blame] | 727 | if (ret) { |
Christian Gromm | 919c03a | 2019-04-03 15:19:48 +0200 | [diff] [blame] | 728 | pr_err("Failed to register %s configfs subsys\n", comp.name); |
YueHaibing | 3982f1d | 2019-08-27 21:13:46 +0800 | [diff] [blame] | 729 | most_deregister_component(&comp); |
| 730 | } |
Christian Gromm | 919c03a | 2019-04-03 15:19:48 +0200 | [diff] [blame] | 731 | return ret; |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | static void __exit audio_exit(void) |
| 735 | { |
Christian Gromm | 919c03a | 2019-04-03 15:19:48 +0200 | [diff] [blame] | 736 | most_deregister_configfs_subsys(&comp); |
Christian Gromm | 1f95cf0 | 2017-11-21 15:05:06 +0100 | [diff] [blame] | 737 | most_deregister_component(&comp); |
Christian Gromm | 54b4856 | 2015-07-24 16:11:51 +0200 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | module_init(audio_init); |
| 741 | module_exit(audio_exit); |
| 742 | |
| 743 | MODULE_LICENSE("GPL"); |
| 744 | MODULE_AUTHOR("Christian Gromm <christian.gromm@microchip.com>"); |
Christian Gromm | b7937dc | 2017-11-21 15:05:12 +0100 | [diff] [blame] | 745 | MODULE_DESCRIPTION("Sound Component Module for Mostcore"); |