All of lore.kernel.org
 help / color / mirror / Atom feed
From: Connor McAdams <conmanx360@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: o-takashi@sakamocchi.jp, "Connor McAdams" <conmanx360@gmail.com>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Jérémy Lefaure" <jeremy.lefaure@lse.epita.fr>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/9] ALSA: hda/ca0132: Add PCI region2 iomap for SBZ
Date: Sat,  5 May 2018 15:03:14 -0400	[thread overview]
Message-ID: <1525547001-17588-4-git-send-email-conmanx360@gmail.com> (raw)
In-Reply-To: <1525547001-17588-1-git-send-email-conmanx360@gmail.com>

This patch adds iomapping for the region2 section of memory on the SBZ.
This memory region is used in later patches for setting inputs and
outputs. If the mapping fails, the quirk is changed back to QUIRK_NONE
to avoid attempts to write to uninitialized memory.

It also adds a new exit sequence to unmap the iomem for the SBZ.

Signed-off-by: Connor McAdams <conmanx360@gmail.com>
---
 sound/pci/hda/patch_ca0132.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 02238fe..78d2c26 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -29,6 +29,9 @@
 #include <linux/firmware.h>
 #include <linux/kernel.h>
 #include <sound/core.h>
+#include <linux/types.h>
+#include <linux/io.h>
+#include <linux/pci.h>
 #include "hda_codec.h"
 #include "hda_local.h"
 #include "hda_auto_parser.h"
@@ -760,6 +763,11 @@ struct ca0132_spec {
 #ifdef ENABLE_TUNING_CONTROLS
 	long cur_ctl_vals[TUNING_CTLS_COUNT];
 #endif
+	/*
+	 * Sound Blaster Z PCI region 2 iomem, used for input and output
+	 * switching, and other unknown commands.
+	 */
+	void __iomem *mem_base;
 };
 
 /*
@@ -4696,6 +4704,8 @@ static void ca0132_free(struct hda_codec *codec)
 	snd_hda_sequence_write(codec, spec->base_exit_verbs);
 	ca0132_exit_chip(codec);
 	snd_hda_power_down(codec);
+	if (spec->mem_base)
+		iounmap(spec->mem_base);
 	kfree(spec->spec_init_verbs);
 	kfree(codec->spec);
 }
@@ -4911,6 +4921,15 @@ static int patch_ca0132(struct hda_codec *codec)
 	else
 		spec->quirk = QUIRK_NONE;
 
+	/* Setup BAR Region 2 for Sound Blaster Z */
+	if (spec->quirk == QUIRK_SBZ) {
+		spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20);
+		if (spec->mem_base == NULL) {
+			codec_warn(codec, "pci_iomap failed!");
+			codec_info(codec, "perhaps this is not an SBZ?");
+			spec->quirk = QUIRK_NONE;
+		}
+	}
 	spec->dsp_state = DSP_DOWNLOAD_INIT;
 	spec->num_mixers = 1;
 	spec->mixers[0] = ca0132_mixer;
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Connor McAdams <conmanx360@gmail.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	"Takashi Iwai" <tiwai@suse.com>,
	"Jérémy Lefaure" <jeremy.lefaure@lse.epita.fr>,
	"Connor McAdams" <conmanx360@gmail.com>,
	o-takashi@sakamocchi.jp
Subject: [PATCH v3 3/9] ALSA: hda/ca0132: Add PCI region2 iomap for SBZ
Date: Sat,  5 May 2018 15:03:14 -0400	[thread overview]
Message-ID: <1525547001-17588-4-git-send-email-conmanx360@gmail.com> (raw)
In-Reply-To: <1525547001-17588-1-git-send-email-conmanx360@gmail.com>

This patch adds iomapping for the region2 section of memory on the SBZ.
This memory region is used in later patches for setting inputs and
outputs. If the mapping fails, the quirk is changed back to QUIRK_NONE
to avoid attempts to write to uninitialized memory.

It also adds a new exit sequence to unmap the iomem for the SBZ.

Signed-off-by: Connor McAdams <conmanx360@gmail.com>
---
 sound/pci/hda/patch_ca0132.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 02238fe..78d2c26 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -29,6 +29,9 @@
 #include <linux/firmware.h>
 #include <linux/kernel.h>
 #include <sound/core.h>
+#include <linux/types.h>
+#include <linux/io.h>
+#include <linux/pci.h>
 #include "hda_codec.h"
 #include "hda_local.h"
 #include "hda_auto_parser.h"
@@ -760,6 +763,11 @@ struct ca0132_spec {
 #ifdef ENABLE_TUNING_CONTROLS
 	long cur_ctl_vals[TUNING_CTLS_COUNT];
 #endif
+	/*
+	 * Sound Blaster Z PCI region 2 iomem, used for input and output
+	 * switching, and other unknown commands.
+	 */
+	void __iomem *mem_base;
 };
 
 /*
@@ -4696,6 +4704,8 @@ static void ca0132_free(struct hda_codec *codec)
 	snd_hda_sequence_write(codec, spec->base_exit_verbs);
 	ca0132_exit_chip(codec);
 	snd_hda_power_down(codec);
+	if (spec->mem_base)
+		iounmap(spec->mem_base);
 	kfree(spec->spec_init_verbs);
 	kfree(codec->spec);
 }
@@ -4911,6 +4921,15 @@ static int patch_ca0132(struct hda_codec *codec)
 	else
 		spec->quirk = QUIRK_NONE;
 
+	/* Setup BAR Region 2 for Sound Blaster Z */
+	if (spec->quirk == QUIRK_SBZ) {
+		spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20);
+		if (spec->mem_base == NULL) {
+			codec_warn(codec, "pci_iomap failed!");
+			codec_info(codec, "perhaps this is not an SBZ?");
+			spec->quirk = QUIRK_NONE;
+		}
+	}
 	spec->dsp_state = DSP_DOWNLOAD_INIT;
 	spec->num_mixers = 1;
 	spec->mixers[0] = ca0132_mixer;
-- 
2.7.4

  parent reply	other threads:[~2018-05-05 19:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-05 19:03 [PATCH v3 0/9] ALSA: hda/ca0132: Patch Series for Recon3Di and Sound Blaster Z Support Connor McAdams
2018-05-05 19:03 ` Connor McAdams
2018-05-05 19:03 ` [PATCH v3 1/9] ALSA: hda/ca0132: R3Di and SBZ quirk entires + alt firmware loading Connor McAdams
2018-05-05 19:03   ` Connor McAdams
2018-05-05 19:03 ` [PATCH v3 2/9] ALSA: hda/ca0132: Add pincfg for SBZ + R3Di, add fp hp auto-detect Connor McAdams
2018-05-05 19:03   ` Connor McAdams
2018-05-05 19:03 ` Connor McAdams [this message]
2018-05-05 19:03   ` [PATCH v3 3/9] ALSA: hda/ca0132: Add PCI region2 iomap for SBZ Connor McAdams
2018-05-05 19:03 ` [PATCH v3 4/9] ALSA: hda/ca0132: Add extra exit functions for R3Di and SBZ Connor McAdams
2018-05-05 19:03   ` Connor McAdams
2018-05-05 19:03 ` [PATCH v3 5/9] ALSA: hda/ca0132: add/change helper " Connor McAdams
2018-05-05 19:03   ` Connor McAdams
2018-05-07  2:29   ` Takashi Sakamoto
2018-05-07 13:55     ` Connor McAdams
2018-05-05 19:03 ` [PATCH v3 6/9] ALSA: hda/ca0132: add alt_select_in/out for R3Di + SBZ Connor McAdams
2018-05-05 19:03   ` Connor McAdams
2018-05-07  3:01   ` Takashi Sakamoto
2018-05-05 19:03 ` [PATCH v3 7/9] ALSA: hda/ca0132: Add DSP Volume set and New mixers for SBZ + R3Di Connor McAdams
2018-05-05 19:03   ` Connor McAdams
2018-05-05 19:03 ` [PATCH v3 8/9] ALSA: hda/ca0132: add ca0132_alt_set_vipsource Connor McAdams
2018-05-05 19:03   ` Connor McAdams
2018-05-05 19:03 ` [PATCH v3 9/9] ALSA: hda/ca0132: Add new control changes for SBZ + R3Di Connor McAdams
2018-05-05 19:03   ` Connor McAdams

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=1525547001-17588-4-git-send-email-conmanx360@gmail.com \
    --to=conmanx360@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=jeremy.lefaure@lse.epita.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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.