Loading sound/core/sound.c +5 −9 Original line number Original line Diff line number Diff line Loading @@ -186,7 +186,7 @@ static const struct file_operations snd_fops = }; }; #ifdef CONFIG_SND_DYNAMIC_MINORS #ifdef CONFIG_SND_DYNAMIC_MINORS static int snd_find_free_minor(int type) static int snd_find_free_minor(int type, struct snd_card *card, int dev) { { int minor; int minor; Loading @@ -209,7 +209,7 @@ static int snd_find_free_minor(int type) return -EBUSY; return -EBUSY; } } #else #else static int snd_kernel_minor(int type, struct snd_card *card, int dev) static int snd_find_free_minor(int type, struct snd_card *card, int dev) { { int minor; int minor; Loading Loading @@ -237,6 +237,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) } } if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS)) if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS)) return -EINVAL; return -EINVAL; if (snd_minors[minor]) return -EBUSY; return minor; return minor; } } #endif #endif Loading Loading @@ -276,13 +278,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, preg->private_data = private_data; preg->private_data = private_data; preg->card_ptr = card; preg->card_ptr = card; mutex_lock(&sound_mutex); mutex_lock(&sound_mutex); #ifdef CONFIG_SND_DYNAMIC_MINORS minor = snd_find_free_minor(type, card, dev); minor = snd_find_free_minor(type); #else minor = snd_kernel_minor(type, card, dev); if (minor >= 0 && snd_minors[minor]) minor = -EBUSY; #endif if (minor < 0) { if (minor < 0) { err = minor; err = minor; goto error; goto error; Loading sound/pci/rme9652/hdspm.c +35 −106 Original line number Original line Diff line number Diff line Loading @@ -6043,101 +6043,30 @@ hdspm_hw_constraints_aes32_sample_rates = { .mask = 0 .mask = 0 }; }; static int snd_hdspm_playback_open(struct snd_pcm_substream *substream) static int snd_hdspm_open(struct snd_pcm_substream *substream) { { struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime; bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); spin_lock_irq(&hdspm->lock); spin_lock_irq(&hdspm->lock); snd_pcm_set_sync(substream); snd_pcm_set_sync(substream); runtime->hw = (playback) ? snd_hdspm_playback_subinfo : snd_hdspm_capture_subinfo; if (playback) { runtime->hw = snd_hdspm_playback_subinfo; if (hdspm->capture_substream == NULL) if (hdspm->capture_substream == NULL) hdspm_stop_audio(hdspm); hdspm_stop_audio(hdspm); hdspm->playback_pid = current->pid; hdspm->playback_pid = current->pid; hdspm->playback_substream = substream; hdspm->playback_substream = substream; spin_unlock_irq(&hdspm->lock); snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); switch (hdspm->io_type) { case AIO: case RayDAT: snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32, 4096); /* RayDAT & AIO have a fixed buffer of 16384 samples per channel */ snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 16384, 16384); break; default: snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 64, 8192); snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, 2, 2); break; } if (AES32 == hdspm->io_type) { runtime->hw.rates |= SNDRV_PCM_RATE_KNOT; snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdspm_hw_constraints_aes32_sample_rates); } else { } else { snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_hdspm_hw_rule_rate_out_channels, hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); } snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_out_channels, hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_out_channels_rate, hdspm, SNDRV_PCM_HW_PARAM_RATE, -1); return 0; } static int snd_hdspm_playback_release(struct snd_pcm_substream *substream) { struct hdspm *hdspm = snd_pcm_substream_chip(substream); spin_lock_irq(&hdspm->lock); hdspm->playback_pid = -1; hdspm->playback_substream = NULL; spin_unlock_irq(&hdspm->lock); return 0; } static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) { struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irq(&hdspm->lock); snd_pcm_set_sync(substream); runtime->hw = snd_hdspm_capture_subinfo; if (hdspm->playback_substream == NULL) if (hdspm->playback_substream == NULL) hdspm_stop_audio(hdspm); hdspm_stop_audio(hdspm); hdspm->capture_pid = current->pid; hdspm->capture_pid = current->pid; hdspm->capture_substream = substream; hdspm->capture_substream = substream; } spin_unlock_irq(&hdspm->lock); spin_unlock_irq(&hdspm->lock); Loading @@ -6150,6 +6079,7 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_minmax(runtime, snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32, 4096); 32, 4096); /* RayDAT & AIO have a fixed buffer of 16384 samples per channel */ snd_pcm_hw_constraint_minmax(runtime, snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 16384, 16384); 16384, 16384); Loading @@ -6171,31 +6101,42 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) &hdspm_hw_constraints_aes32_sample_rates); &hdspm_hw_constraints_aes32_sample_rates); } else { } else { snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_hdspm_hw_rule_rate_in_channels, hdspm, (playback ? snd_hdspm_hw_rule_rate_out_channels : snd_hdspm_hw_rule_rate_in_channels), hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); SNDRV_PCM_HW_PARAM_CHANNELS, -1); } } snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_in_channels, hdspm, (playback ? snd_hdspm_hw_rule_out_channels : snd_hdspm_hw_rule_in_channels), hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); SNDRV_PCM_HW_PARAM_CHANNELS, -1); snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_in_channels_rate, hdspm, (playback ? snd_hdspm_hw_rule_out_channels_rate : snd_hdspm_hw_rule_in_channels_rate), hdspm, SNDRV_PCM_HW_PARAM_RATE, -1); SNDRV_PCM_HW_PARAM_RATE, -1); return 0; return 0; } } static int snd_hdspm_capture_release(struct snd_pcm_substream *substream) static int snd_hdspm_release(struct snd_pcm_substream *substream) { { struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct hdspm *hdspm = snd_pcm_substream_chip(substream); bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); spin_lock_irq(&hdspm->lock); spin_lock_irq(&hdspm->lock); if (playback) { hdspm->playback_pid = -1; hdspm->playback_substream = NULL; } else { hdspm->capture_pid = -1; hdspm->capture_pid = -1; hdspm->capture_substream = NULL; hdspm->capture_substream = NULL; } spin_unlock_irq(&hdspm->lock); spin_unlock_irq(&hdspm->lock); return 0; return 0; } } Loading Loading @@ -6413,21 +6354,9 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, return 0; return 0; } } static struct snd_pcm_ops snd_hdspm_playback_ops = { static struct snd_pcm_ops snd_hdspm_ops = { .open = snd_hdspm_playback_open, .open = snd_hdspm_open, .close = snd_hdspm_playback_release, .close = snd_hdspm_release, .ioctl = snd_hdspm_ioctl, .hw_params = snd_hdspm_hw_params, .hw_free = snd_hdspm_hw_free, .prepare = snd_hdspm_prepare, .trigger = snd_hdspm_trigger, .pointer = snd_hdspm_hw_pointer, .page = snd_pcm_sgbuf_ops_page, }; static struct snd_pcm_ops snd_hdspm_capture_ops = { .open = snd_hdspm_capture_open, .close = snd_hdspm_capture_release, .ioctl = snd_hdspm_ioctl, .ioctl = snd_hdspm_ioctl, .hw_params = snd_hdspm_hw_params, .hw_params = snd_hdspm_hw_params, .hw_free = snd_hdspm_hw_free, .hw_free = snd_hdspm_hw_free, Loading Loading @@ -6521,9 +6450,9 @@ static int snd_hdspm_create_pcm(struct snd_card *card, strcpy(pcm->name, hdspm->card_name); strcpy(pcm->name, hdspm->card_name); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_hdspm_playback_ops); &snd_hdspm_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_hdspm_capture_ops); &snd_hdspm_ops); pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; Loading Loading
sound/core/sound.c +5 −9 Original line number Original line Diff line number Diff line Loading @@ -186,7 +186,7 @@ static const struct file_operations snd_fops = }; }; #ifdef CONFIG_SND_DYNAMIC_MINORS #ifdef CONFIG_SND_DYNAMIC_MINORS static int snd_find_free_minor(int type) static int snd_find_free_minor(int type, struct snd_card *card, int dev) { { int minor; int minor; Loading @@ -209,7 +209,7 @@ static int snd_find_free_minor(int type) return -EBUSY; return -EBUSY; } } #else #else static int snd_kernel_minor(int type, struct snd_card *card, int dev) static int snd_find_free_minor(int type, struct snd_card *card, int dev) { { int minor; int minor; Loading Loading @@ -237,6 +237,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) } } if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS)) if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS)) return -EINVAL; return -EINVAL; if (snd_minors[minor]) return -EBUSY; return minor; return minor; } } #endif #endif Loading Loading @@ -276,13 +278,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, preg->private_data = private_data; preg->private_data = private_data; preg->card_ptr = card; preg->card_ptr = card; mutex_lock(&sound_mutex); mutex_lock(&sound_mutex); #ifdef CONFIG_SND_DYNAMIC_MINORS minor = snd_find_free_minor(type, card, dev); minor = snd_find_free_minor(type); #else minor = snd_kernel_minor(type, card, dev); if (minor >= 0 && snd_minors[minor]) minor = -EBUSY; #endif if (minor < 0) { if (minor < 0) { err = minor; err = minor; goto error; goto error; Loading
sound/pci/rme9652/hdspm.c +35 −106 Original line number Original line Diff line number Diff line Loading @@ -6043,101 +6043,30 @@ hdspm_hw_constraints_aes32_sample_rates = { .mask = 0 .mask = 0 }; }; static int snd_hdspm_playback_open(struct snd_pcm_substream *substream) static int snd_hdspm_open(struct snd_pcm_substream *substream) { { struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime; bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); spin_lock_irq(&hdspm->lock); spin_lock_irq(&hdspm->lock); snd_pcm_set_sync(substream); snd_pcm_set_sync(substream); runtime->hw = (playback) ? snd_hdspm_playback_subinfo : snd_hdspm_capture_subinfo; if (playback) { runtime->hw = snd_hdspm_playback_subinfo; if (hdspm->capture_substream == NULL) if (hdspm->capture_substream == NULL) hdspm_stop_audio(hdspm); hdspm_stop_audio(hdspm); hdspm->playback_pid = current->pid; hdspm->playback_pid = current->pid; hdspm->playback_substream = substream; hdspm->playback_substream = substream; spin_unlock_irq(&hdspm->lock); snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); switch (hdspm->io_type) { case AIO: case RayDAT: snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32, 4096); /* RayDAT & AIO have a fixed buffer of 16384 samples per channel */ snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 16384, 16384); break; default: snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 64, 8192); snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, 2, 2); break; } if (AES32 == hdspm->io_type) { runtime->hw.rates |= SNDRV_PCM_RATE_KNOT; snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdspm_hw_constraints_aes32_sample_rates); } else { } else { snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_hdspm_hw_rule_rate_out_channels, hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); } snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_out_channels, hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_out_channels_rate, hdspm, SNDRV_PCM_HW_PARAM_RATE, -1); return 0; } static int snd_hdspm_playback_release(struct snd_pcm_substream *substream) { struct hdspm *hdspm = snd_pcm_substream_chip(substream); spin_lock_irq(&hdspm->lock); hdspm->playback_pid = -1; hdspm->playback_substream = NULL; spin_unlock_irq(&hdspm->lock); return 0; } static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) { struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irq(&hdspm->lock); snd_pcm_set_sync(substream); runtime->hw = snd_hdspm_capture_subinfo; if (hdspm->playback_substream == NULL) if (hdspm->playback_substream == NULL) hdspm_stop_audio(hdspm); hdspm_stop_audio(hdspm); hdspm->capture_pid = current->pid; hdspm->capture_pid = current->pid; hdspm->capture_substream = substream; hdspm->capture_substream = substream; } spin_unlock_irq(&hdspm->lock); spin_unlock_irq(&hdspm->lock); Loading @@ -6150,6 +6079,7 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) snd_pcm_hw_constraint_minmax(runtime, snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32, 4096); 32, 4096); /* RayDAT & AIO have a fixed buffer of 16384 samples per channel */ snd_pcm_hw_constraint_minmax(runtime, snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 16384, 16384); 16384, 16384); Loading @@ -6171,31 +6101,42 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) &hdspm_hw_constraints_aes32_sample_rates); &hdspm_hw_constraints_aes32_sample_rates); } else { } else { snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_hdspm_hw_rule_rate_in_channels, hdspm, (playback ? snd_hdspm_hw_rule_rate_out_channels : snd_hdspm_hw_rule_rate_in_channels), hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); SNDRV_PCM_HW_PARAM_CHANNELS, -1); } } snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_in_channels, hdspm, (playback ? snd_hdspm_hw_rule_out_channels : snd_hdspm_hw_rule_in_channels), hdspm, SNDRV_PCM_HW_PARAM_CHANNELS, -1); SNDRV_PCM_HW_PARAM_CHANNELS, -1); snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdspm_hw_rule_in_channels_rate, hdspm, (playback ? snd_hdspm_hw_rule_out_channels_rate : snd_hdspm_hw_rule_in_channels_rate), hdspm, SNDRV_PCM_HW_PARAM_RATE, -1); SNDRV_PCM_HW_PARAM_RATE, -1); return 0; return 0; } } static int snd_hdspm_capture_release(struct snd_pcm_substream *substream) static int snd_hdspm_release(struct snd_pcm_substream *substream) { { struct hdspm *hdspm = snd_pcm_substream_chip(substream); struct hdspm *hdspm = snd_pcm_substream_chip(substream); bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); spin_lock_irq(&hdspm->lock); spin_lock_irq(&hdspm->lock); if (playback) { hdspm->playback_pid = -1; hdspm->playback_substream = NULL; } else { hdspm->capture_pid = -1; hdspm->capture_pid = -1; hdspm->capture_substream = NULL; hdspm->capture_substream = NULL; } spin_unlock_irq(&hdspm->lock); spin_unlock_irq(&hdspm->lock); return 0; return 0; } } Loading Loading @@ -6413,21 +6354,9 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, return 0; return 0; } } static struct snd_pcm_ops snd_hdspm_playback_ops = { static struct snd_pcm_ops snd_hdspm_ops = { .open = snd_hdspm_playback_open, .open = snd_hdspm_open, .close = snd_hdspm_playback_release, .close = snd_hdspm_release, .ioctl = snd_hdspm_ioctl, .hw_params = snd_hdspm_hw_params, .hw_free = snd_hdspm_hw_free, .prepare = snd_hdspm_prepare, .trigger = snd_hdspm_trigger, .pointer = snd_hdspm_hw_pointer, .page = snd_pcm_sgbuf_ops_page, }; static struct snd_pcm_ops snd_hdspm_capture_ops = { .open = snd_hdspm_capture_open, .close = snd_hdspm_capture_release, .ioctl = snd_hdspm_ioctl, .ioctl = snd_hdspm_ioctl, .hw_params = snd_hdspm_hw_params, .hw_params = snd_hdspm_hw_params, .hw_free = snd_hdspm_hw_free, .hw_free = snd_hdspm_hw_free, Loading Loading @@ -6521,9 +6450,9 @@ static int snd_hdspm_create_pcm(struct snd_card *card, strcpy(pcm->name, hdspm->card_name); strcpy(pcm->name, hdspm->card_name); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_hdspm_playback_ops); &snd_hdspm_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_hdspm_capture_ops); &snd_hdspm_ops); pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; Loading