All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@nvidia.com>
To: tiwai@suse.de, perex@perex.cz, wfg@linux.intel.com
Cc: wni@nvidia.com, Stephen Warren <swarren@nvidia.com>,
	ndaga@nvidia.com, alsa-devel@alsa-project.org
Subject: [PATCH 4/6] ALSA: hda: Separate generic and non-generic implementations
Date: Wed,  1 Jun 2011 11:14:19 -0600	[thread overview]
Message-ID: <1306948461-2402-5-git-send-email-swarren@nvidia.com> (raw)
In-Reply-To: <1306948461-2402-1-git-send-email-swarren@nvidia.com>

A future change will significantly rework the generic implementation
in order to support codecs with a different number of pins and
converters. Isolate the more custom codec variants from this change by
duplicating the small portions of generic code they share. This
simplifies the later rework of that previously shared code, since we
don't have to consider the more custom codecs, and also prevents
support for those codecs from regressing.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 sound/pci/hda/patch_hdmi.c |   75 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 13ee444..92fb105 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1164,6 +1164,63 @@ static int patch_generic_hdmi(struct hda_codec *codec)
 }
 
 /*
+ * Shared non-generic implementations
+ */
+
+static int simple_playback_build_pcms(struct hda_codec *codec)
+{
+	struct hdmi_spec *spec = codec->spec;
+	struct hda_pcm *info = spec->pcm_rec;
+	int i;
+
+	codec->num_pcms = spec->num_cvts;
+	codec->pcm_info = info;
+
+	for (i = 0; i < codec->num_pcms; i++, info++) {
+		unsigned int chans;
+		struct hda_pcm_stream *pstr;
+
+		chans = get_wcaps(codec, spec->cvt[i]);
+		chans = get_wcaps_channels(chans);
+
+		info->name = generic_hdmi_pcm_names[i];
+		info->pcm_type = HDA_PCM_TYPE_HDMI;
+		pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
+		snd_BUG_ON(!spec->pcm_playback);
+		*pstr = *spec->pcm_playback;
+		pstr->nid = spec->cvt[i];
+		if (pstr->channels_max <= 2 && chans && chans <= 16)
+			pstr->channels_max = chans;
+	}
+
+	return 0;
+}
+
+static int simple_playback_build_controls(struct hda_codec *codec)
+{
+	struct hdmi_spec *spec = codec->spec;
+	int err;
+	int i;
+
+	for (i = 0; i < codec->num_pcms; i++) {
+		err = snd_hda_create_spdif_out_ctls(codec,
+						    spec->cvt[i],
+						    spec->cvt[i]);
+		if (err < 0)
+			return err;
+	}
+
+	return 0;
+}
+
+static void simple_playback_free(struct hda_codec *codec)
+{
+	struct hdmi_spec *spec = codec->spec;
+
+	kfree(spec);
+}
+
+/*
  * Nvidia specific implementations
  */
 
@@ -1475,17 +1532,17 @@ static const struct hda_pcm_stream nvhdmi_pcm_playback_2ch = {
 };
 
 static const struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = {
-	.build_controls = generic_hdmi_build_controls,
-	.build_pcms = generic_hdmi_build_pcms,
+	.build_controls = simple_playback_build_controls,
+	.build_pcms = simple_playback_build_pcms,
 	.init = nvhdmi_7x_init,
-	.free = generic_hdmi_free,
+	.free = simple_playback_free,
 };
 
 static const struct hda_codec_ops nvhdmi_patch_ops_2ch = {
-	.build_controls = generic_hdmi_build_controls,
-	.build_pcms = generic_hdmi_build_pcms,
+	.build_controls = simple_playback_build_controls,
+	.build_pcms = simple_playback_build_pcms,
 	.init = nvhdmi_7x_init,
-	.free = generic_hdmi_free,
+	.free = simple_playback_free,
 };
 
 static int patch_nvhdmi_2ch(struct hda_codec *codec)
@@ -1596,10 +1653,10 @@ static int atihdmi_init(struct hda_codec *codec)
 }
 
 static const struct hda_codec_ops atihdmi_patch_ops = {
-	.build_controls = generic_hdmi_build_controls,
-	.build_pcms = generic_hdmi_build_pcms,
+	.build_controls = simple_playback_build_controls,
+	.build_pcms = simple_playback_build_pcms,
 	.init = atihdmi_init,
-	.free = generic_hdmi_free,
+	.free = simple_playback_free,
 };
 
 
-- 
1.7.0.4

  parent reply	other threads:[~2011-06-01 17:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-01 17:14 [PATCH 0/6] HDMI: Implement pcm-per-pin Stephen Warren
2011-06-01 17:14 ` [PATCH 1/6] ALSA: hda: Gate ELD usage only by whether ELD is valid Stephen Warren
2011-06-01 17:14 ` [PATCH 2/6] ALSA: hda: Allow multple SPDIF controls per codec Stephen Warren
2011-06-01 17:14 ` [PATCH 3/6] ALSA: hda: Virtualize SPDIF out controls Stephen Warren
2011-06-01 17:14 ` Stephen Warren [this message]
2011-06-01 17:14 ` [PATCH 5/6] ALSA: hda: hdmi_eld_update_pcm_info: update a stream in place Stephen Warren
2011-06-01 17:14 ` [PATCH 6/6] ALSA: hda: HDMI: Support codecs with fewer cvts than pins Stephen Warren
2011-06-03 16:11 ` [PATCH 0/6] HDMI: Implement pcm-per-pin Takashi Iwai
2011-06-06 14:21   ` Takashi Iwai
2011-06-08  0:06   ` [PATCH 1/1] Added patch file and Makefile entry for CA0132 HDA codec Ian Minett
2011-06-08  6:04     ` 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=1306948461-2402-5-git-send-email-swarren@nvidia.com \
    --to=swarren@nvidia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=ndaga@nvidia.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    --cc=wfg@linux.intel.com \
    --cc=wni@nvidia.com \
    /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 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.