* [PATCH] ALSA: hda: Fix assign invalid fixed slots pcm numbers to HDA_PCM_TYPE_HDMI in get_empty_pcm_device
@ 2017-09-03 13:52 Wang YanQing
2017-09-03 14:35 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Wang YanQing @ 2017-09-03 13:52 UTC (permalink / raw)
To: tiwai; +Cc: alsa-devel, linux-kernel, fengguang.wu
The length of pcm_dev_bits in hda_bus is SNDRV_PCM_DEVICES,
and the definiton of SNDRV_PCM_DEVICES is:
"
#if defined(CONFIG_SND_DYNAMIC_MINORS)
#define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
#else
#define SNDRV_PCM_DEVICES 8
#endif
"
So the max valid fixed slots pcm number is 7, and the first
non-fixed slot is 8.
Signed-off-by: Wang YanQing <udknight@gmail.com>
---
sound/pci/hda/hda_codec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 3db26c4..df6b57e 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -3118,7 +3118,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
static int audio_idx[HDA_PCM_NTYPES][5] = {
[HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 },
[HDA_PCM_TYPE_SPDIF] = { 1, -1 },
- [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 },
+ [HDA_PCM_TYPE_HDMI] = { 3, 7, -1 },
[HDA_PCM_TYPE_MODEM] = { 6, -1 },
};
int i;
@@ -3139,7 +3139,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
#ifdef CONFIG_SND_DYNAMIC_MINORS
/* non-fixed slots starting from 10 */
- for (i = 10; i < 32; i++) {
+ for (i = 8; i < 32; i++) {
if (!test_and_set_bit(i, bus->pcm_dev_bits))
return i;
}
--
1.8.5.6.2.g3d8a54e.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: hda: Fix assign invalid fixed slots pcm numbers to HDA_PCM_TYPE_HDMI in get_empty_pcm_device
2017-09-03 13:52 [PATCH] ALSA: hda: Fix assign invalid fixed slots pcm numbers to HDA_PCM_TYPE_HDMI in get_empty_pcm_device Wang YanQing
@ 2017-09-03 14:35 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2017-09-03 14:35 UTC (permalink / raw)
To: Wang YanQing; +Cc: alsa-devel, linux-kernel, fengguang.wu
On Sun, 03 Sep 2017 15:52:31 +0200,
Wang YanQing wrote:
>
> The length of pcm_dev_bits in hda_bus is SNDRV_PCM_DEVICES,
> and the definiton of SNDRV_PCM_DEVICES is:
> "
> #if defined(CONFIG_SND_DYNAMIC_MINORS)
> #define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
> #else
> #define SNDRV_PCM_DEVICES 8
> #endif
> "
>
> So the max valid fixed slots pcm number is 7, and the first
> non-fixed slot is 8.
It's only when CONFIG_SND_DYNAMIC_MINORS=n, and that's already covered
in the code in get_empty_pcm_device().
#ifndef CONFIG_SND_DYNAMIC_MINORS
if (audio_idx[type][i] >= 8)
break;
#endif
For CONFIG_SND_DYNAMIC_MINORS=y, there is no such restriction, thus
the non-fixed slot begins from 10 as in the current code.
thanks,
Takashi
>
> Signed-off-by: Wang YanQing <udknight@gmail.com>
> ---
> sound/pci/hda/hda_codec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index 3db26c4..df6b57e 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -3118,7 +3118,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
> static int audio_idx[HDA_PCM_NTYPES][5] = {
> [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 },
> [HDA_PCM_TYPE_SPDIF] = { 1, -1 },
> - [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 },
> + [HDA_PCM_TYPE_HDMI] = { 3, 7, -1 },
> [HDA_PCM_TYPE_MODEM] = { 6, -1 },
> };
> int i;
> @@ -3139,7 +3139,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
>
> #ifdef CONFIG_SND_DYNAMIC_MINORS
> /* non-fixed slots starting from 10 */
> - for (i = 10; i < 32; i++) {
> + for (i = 8; i < 32; i++) {
> if (!test_and_set_bit(i, bus->pcm_dev_bits))
> return i;
> }
> --
> 1.8.5.6.2.g3d8a54e.dirty
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: hda: Fix assign invalid fixed slots pcm numbers to HDA_PCM_TYPE_HDMI in get_empty_pcm_device
@ 2017-09-03 14:35 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2017-09-03 14:35 UTC (permalink / raw)
To: Wang YanQing; +Cc: alsa-devel, fengguang.wu, linux-kernel
On Sun, 03 Sep 2017 15:52:31 +0200,
Wang YanQing wrote:
>
> The length of pcm_dev_bits in hda_bus is SNDRV_PCM_DEVICES,
> and the definiton of SNDRV_PCM_DEVICES is:
> "
> #if defined(CONFIG_SND_DYNAMIC_MINORS)
> #define SNDRV_PCM_DEVICES (SNDRV_OS_MINORS-2)
> #else
> #define SNDRV_PCM_DEVICES 8
> #endif
> "
>
> So the max valid fixed slots pcm number is 7, and the first
> non-fixed slot is 8.
It's only when CONFIG_SND_DYNAMIC_MINORS=n, and that's already covered
in the code in get_empty_pcm_device().
#ifndef CONFIG_SND_DYNAMIC_MINORS
if (audio_idx[type][i] >= 8)
break;
#endif
For CONFIG_SND_DYNAMIC_MINORS=y, there is no such restriction, thus
the non-fixed slot begins from 10 as in the current code.
thanks,
Takashi
>
> Signed-off-by: Wang YanQing <udknight@gmail.com>
> ---
> sound/pci/hda/hda_codec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index 3db26c4..df6b57e 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -3118,7 +3118,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
> static int audio_idx[HDA_PCM_NTYPES][5] = {
> [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 },
> [HDA_PCM_TYPE_SPDIF] = { 1, -1 },
> - [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 },
> + [HDA_PCM_TYPE_HDMI] = { 3, 7, -1 },
> [HDA_PCM_TYPE_MODEM] = { 6, -1 },
> };
> int i;
> @@ -3139,7 +3139,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
>
> #ifdef CONFIG_SND_DYNAMIC_MINORS
> /* non-fixed slots starting from 10 */
> - for (i = 10; i < 32; i++) {
> + for (i = 8; i < 32; i++) {
> if (!test_and_set_bit(i, bus->pcm_dev_bits))
> return i;
> }
> --
> 1.8.5.6.2.g3d8a54e.dirty
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-03 14:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-03 13:52 [PATCH] ALSA: hda: Fix assign invalid fixed slots pcm numbers to HDA_PCM_TYPE_HDMI in get_empty_pcm_device Wang YanQing
2017-09-03 14:35 ` Takashi Iwai
2017-09-03 14:35 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.