aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/most/sound/sound.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-09 10:32:39 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-09 10:32:39 -0700
commiteafdca4d7010a0e019aaaace3dd71b432a69b54c (patch)
tree0206168276ece10426dbbef7b3de7e8d84c8674d /drivers/staging/most/sound/sound.c
parentMerge tag 'libnvdimm-for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm (diff)
parentstaging: ipx: delete it from the tree (diff)
downloadlinux-dev-eafdca4d7010a0e019aaaace3dd71b432a69b54c.tar.xz
linux-dev-eafdca4d7010a0e019aaaace3dd71b432a69b54c.zip
Merge tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO updates from Greg KH: "Here is the big staging and IIO driver update for 4.18-rc1. It was delayed as I wanted to make sure the final driver deletions did not cause any major merge issues, and all now looks good. There are a lot of patches here, just over 1000. The diffstat summary shows the major changes here: 1007 files changed, 16828 insertions(+), 227770 deletions(-) Because of this, we might be close to shrinking the overall kernel source code size for two releases in a row. There was loads of work in this release cycle, primarily: - tons of ks7010 driver cleanups - lots of mt7621 driver fixes and cleanups - most driver cleanups - wilc1000 fixes and cleanups - lots and lots of IIO driver cleanups and new additions - debugfs cleanups for all staging drivers - lots of other staging driver cleanups and fixes, the shortlog has the full details. but the big user-visable things here are the removal of 3 chunks of code: - ncpfs and ipx were removed on schedule, no one has cared about this code since it moved to staging last year, and if it needs to come back, it can be reverted. - lustre file system is removed. I've ranted at the lustre developers about once a year for the past 5 years, with no real forward progress at all to clean things up and get the code into the "real" part of the kernel. Given that the lustre developers continue to work on an external tree and try to port those changes to the in-kernel tree every once in a while, this whole thing really really is not working out at all. So I'm deleting it so that the developers can spend the time working in their out-of-tree location and get things cleaned up properly to get merged into the tree correctly at a later date. Because of these file removals, you will have merge issues on some of these files (2 in the ipx code, 1 in the ncpfs code, and 1 in the atomisp driver). Just delete those files, it's a simple merge :) All of this has been in linux-next for a while with no reported problems" * tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1011 commits) staging: ipx: delete it from the tree ncpfs: remove uapi .h files ncpfs: remove Documentation ncpfs: remove compat functionality staging: ncpfs: delete it staging: lustre: delete the filesystem from the tree. staging: vc04_services: no need to save the log debufs dentries staging: vc04_services: vchiq_debugfs_log_entry can be a void * staging: vc04_services: remove struct vchiq_debugfs_info staging: vc04_services: move client dbg directory into static variable staging: vc04_services: remove odd vchiq_debugfs_top() wrapper staging: vc04_services: no need to check debugfs return values staging: mt7621-gpio: reorder includes alphabetically staging: mt7621-gpio: change gc_map to don't use pointers staging: mt7621-gpio: use GPIOF_DIR_OUT and GPIOF_DIR_IN macros instead of custom values staging: mt7621-gpio: change 'to_mediatek_gpio' to make just a one line return staging: mt7621-gpio: dt-bindings: update documentation for #interrupt-cells property staging: mt7621-gpio: update #interrupt-cells for the gpio node staging: mt7621-gpio: dt-bindings: complete documentation for the gpio staging: mt7621-dts: add missing properties to gpio node ...
Diffstat (limited to 'drivers/staging/most/sound/sound.c')
-rw-r--r--drivers/staging/most/sound/sound.c123
1 files changed, 63 insertions, 60 deletions
diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c
index 83cec21c85b8..04c18323c2ea 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/staging/most/sound/sound.c
@@ -460,21 +460,68 @@ static const struct snd_pcm_ops pcm_ops = {
.mmap = snd_pcm_lib_mmap_vmalloc,
};
-static int split_arg_list(char *buf, char **card_name, char **pcm_format)
+static int split_arg_list(char *buf, char **card_name, u16 *ch_num,
+ char **sample_res)
{
+ char *num;
+ int ret;
+
*card_name = strsep(&buf, ".");
- if (!*card_name)
- return -EIO;
- *pcm_format = strsep(&buf, ".\n");
- if (!*pcm_format)
+ if (!*card_name) {
+ pr_err("Missing sound card name\n");
return -EIO;
+ }
+ num = strsep(&buf, "x");
+ if (!num)
+ goto err;
+ ret = kstrtou16(num, 0, ch_num);
+ if (ret)
+ goto err;
+ *sample_res = strsep(&buf, ".\n");
+ if (!*sample_res)
+ goto err;
return 0;
+
+err:
+ pr_err("Bad PCM format\n");
+ return -EIO;
}
+static const struct sample_resolution_info {
+ const char *sample_res;
+ int bytes;
+ u64 formats;
+} sinfo[] = {
+ { "8", 1, SNDRV_PCM_FMTBIT_S8 },
+ { "16", 2, SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE },
+ { "24", 3, SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE },
+ { "32", 4, SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE },
+};
+
static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw,
- char *pcm_format,
+ u16 ch_num, char *sample_res,
struct most_channel_config *cfg)
{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(sinfo); i++) {
+ if (!strcmp(sample_res, sinfo[i].sample_res))
+ goto found;
+ }
+ pr_err("Unsupported PCM format\n");
+ return -EIO;
+
+found:
+ if (!ch_num) {
+ pr_err("Bad number of channels\n");
+ return -EINVAL;
+ }
+
+ if (cfg->subbuffer_size != ch_num * sinfo[i].bytes) {
+ pr_err("Audio resolution doesn't fit subbuffer size\n");
+ return -EINVAL;
+ }
+
pcm_hw->info = MOST_PCM_INFO;
pcm_hw->rates = SNDRV_PCM_RATE_48000;
pcm_hw->rate_min = 48000;
@@ -484,54 +531,10 @@ static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw,
pcm_hw->period_bytes_max = cfg->buffer_size;
pcm_hw->periods_min = 1;
pcm_hw->periods_max = cfg->num_buffers;
-
- if (!strcmp(pcm_format, "1x8")) {
- if (cfg->subbuffer_size != 1)
- goto error;
- pr_info("PCM format is 8-bit mono\n");
- pcm_hw->channels_min = 1;
- pcm_hw->channels_max = 1;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S8;
- } else if (!strcmp(pcm_format, "2x16")) {
- if (cfg->subbuffer_size != 4)
- goto error;
- pr_info("PCM format is 16-bit stereo\n");
- pcm_hw->channels_min = 2;
- pcm_hw->channels_max = 2;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S16_LE |
- SNDRV_PCM_FMTBIT_S16_BE;
- } else if (!strcmp(pcm_format, "2x24")) {
- if (cfg->subbuffer_size != 6)
- goto error;
- pr_info("PCM format is 24-bit stereo\n");
- pcm_hw->channels_min = 2;
- pcm_hw->channels_max = 2;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S24_3LE |
- SNDRV_PCM_FMTBIT_S24_3BE;
- } else if (!strcmp(pcm_format, "2x32")) {
- if (cfg->subbuffer_size != 8)
- goto error;
- pr_info("PCM format is 32-bit stereo\n");
- pcm_hw->channels_min = 2;
- pcm_hw->channels_max = 2;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S32_LE |
- SNDRV_PCM_FMTBIT_S32_BE;
- } else if (!strcmp(pcm_format, "6x16")) {
- if (cfg->subbuffer_size != 12)
- goto error;
- pr_info("PCM format is 16-bit 5.1 multi channel\n");
- pcm_hw->channels_min = 6;
- pcm_hw->channels_max = 6;
- pcm_hw->formats = SNDRV_PCM_FMTBIT_S16_LE |
- SNDRV_PCM_FMTBIT_S16_BE;
- } else {
- pr_err("PCM format %s not supported\n", pcm_format);
- return -EIO;
- }
+ pcm_hw->channels_min = ch_num;
+ pcm_hw->channels_max = ch_num;
+ pcm_hw->formats = sinfo[i].formats;
return 0;
-error:
- pr_err("Audio resolution doesn't fit subbuffer size\n");
- return -EINVAL;
}
/**
@@ -558,7 +561,8 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
int ret;
int direction;
char *card_name;
- char *pcm_format;
+ u16 ch_num;
+ char *sample_res;
if (!iface)
return -EINVAL;
@@ -582,13 +586,11 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
direction = SNDRV_PCM_STREAM_CAPTURE;
}
- ret = split_arg_list(arg_list, &card_name, &pcm_format);
- if (ret < 0) {
- pr_info("PCM format missing\n");
+ ret = split_arg_list(arg_list, &card_name, &ch_num, &sample_res);
+ if (ret < 0)
return ret;
- }
- ret = snd_card_new(NULL, -1, card_name, THIS_MODULE,
+ ret = snd_card_new(&iface->dev, -1, card_name, THIS_MODULE,
sizeof(*channel), &card);
if (ret < 0)
return ret;
@@ -600,7 +602,8 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id,
channel->id = channel_id;
init_waitqueue_head(&channel->playback_waitq);
- ret = audio_set_hw_params(&channel->pcm_hardware, pcm_format, cfg);
+ ret = audio_set_hw_params(&channel->pcm_hardware, ch_num, sample_res,
+ cfg);
if (ret)
goto err_free_card;