From: Wu Fengguang <fengguang.wu@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, Wu Fengguang <fengguang.wu@intel.com>
Subject: [PATCH 02/11] hda - vectorize get_empty_pcm_device()
Date: Thu, 15 Oct 2009 15:03:50 +0800 [thread overview]
Message-ID: <20091015070918.058861201@intel.com> (raw)
In-Reply-To: 20091015070348.390451250@intel.com
[-- Attachment #1: hdmi-dev-array.patch --]
[-- Type: text/plain, Size: 2130 bytes --]
This unifies the code and data structure,
and makes it easy to add more HDMI devices.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
sound/pci/hda/hda_codec.c | 49 +++++++++++-------------------------
1 file changed, 16 insertions(+), 33 deletions(-)
--- sound-2.6.orig/sound/pci/hda/hda_codec.c 2009-10-15 10:16:52.000000000 +0800
+++ sound-2.6/sound/pci/hda/hda_codec.c 2009-10-15 10:17:00.000000000 +0800
@@ -2885,43 +2885,26 @@ static int get_empty_pcm_device(struct h
static const char *dev_name[HDA_PCM_NTYPES] = {
"Audio", "SPDIF", "HDMI", "Modem"
};
- /* starting device index for each PCM type */
- static int dev_idx[HDA_PCM_NTYPES] = {
- [HDA_PCM_TYPE_AUDIO] = 0,
- [HDA_PCM_TYPE_SPDIF] = 1,
- [HDA_PCM_TYPE_HDMI] = 3,
- [HDA_PCM_TYPE_MODEM] = 6
+ /* audio device indices; not linear to keep compatibility */
+ 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, -1 },
+ [HDA_PCM_TYPE_MODEM] = { 6, -1 },
};
- /* normal audio device indices; not linear to keep compatibility */
- static int audio_idx[4] = { 0, 2, 4, 5 };
- int i, dev;
-
- switch (type) {
- case HDA_PCM_TYPE_AUDIO:
- for (i = 0; i < ARRAY_SIZE(audio_idx); i++) {
- dev = audio_idx[i];
- if (!test_bit(dev, bus->pcm_dev_bits))
- goto ok;
- }
- snd_printk(KERN_WARNING "Too many audio devices\n");
- return -EAGAIN;
- case HDA_PCM_TYPE_SPDIF:
- case HDA_PCM_TYPE_HDMI:
- case HDA_PCM_TYPE_MODEM:
- dev = dev_idx[type];
- if (test_bit(dev, bus->pcm_dev_bits)) {
- snd_printk(KERN_WARNING "%s already defined\n",
- dev_name[type]);
- return -EAGAIN;
- }
- break;
- default:
+ int i;
+
+ if (type >= HDA_PCM_NTYPES) {
snd_printk(KERN_WARNING "Invalid PCM type %d\n", type);
return -EINVAL;
}
- ok:
- set_bit(dev, bus->pcm_dev_bits);
- return dev;
+
+ for (i = 0; audio_idx[type][i] >= 0 ; i++)
+ if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))
+ return audio_idx[type][i];
+
+ snd_printk(KERN_WARNING "Too many %s devices\n", dev_name[type]);
+ return -EAGAIN;
}
/*
next prev parent reply other threads:[~2009-10-15 7:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-15 7:03 [PATCH 00/11] Intel IbexPeak HDMI codec support Wu Fengguang
2009-10-15 7:03 ` [PATCH 01/11] hda - select IbexPeak handler for Calpella Wu Fengguang
2009-10-15 7:03 ` Wu Fengguang [this message]
2009-10-15 7:03 ` [PATCH 03/11] hda - allow up to 4 HDMI devices Wu Fengguang
2009-10-15 7:03 ` [PATCH 04/11] hda - convert intelhdmi global references to local parameters Wu Fengguang
2009-10-15 7:03 ` [PATCH 05/11] hda - remove intelhdmi dependency on multiout Wu Fengguang
2009-10-15 7:03 ` [PATCH 06/11] hda - use pcm prepare/cleanup callbacks for intelhdmi Wu Fengguang
2009-10-15 7:03 ` [PATCH 07/11] hda - reorder intelhdmi prepare/cleanup callbacks Wu Fengguang
2009-10-15 7:03 ` [PATCH 08/11] hda - vectorize intelhdmi Wu Fengguang
2009-10-15 7:03 ` [PATCH 09/11] hda - get intelhdmi max channels from widget caps Wu Fengguang
2009-10-15 7:03 ` [PATCH 10/11] hda - auto parse intelhdmi cvt/pin configurations Wu Fengguang
2009-10-15 7:03 ` [PATCH 11/11] hda - remove static intelhdmi configurations Wu Fengguang
2009-10-30 10:47 ` [PATCH 00/11] Intel IbexPeak HDMI codec support Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091015070918.058861201@intel.com \
--to=fengguang.wu@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox