Skip to contentSkip to conversation

Added patch file and Makefile entry for CA0132 HDA codec

PATCH In review Ian Minett 2 participants 2 messages Jun 2, 2011 – Jun 3, 2011

lore
Share & tools
lore

Ian Minett

author
#0 lore raw

PATCH 1/1 Added patch file and Makefile entry for CA0132 HDA codec

Attached is a patch that adds support for the CA0132 HDA codec, creating patch_ca0132.c in pci/hda. It also adds an entry to the pci/hda makefile that builds the codec when SND_HDA_CODEC_CA0132 is defined. However, we are not sure where to add the KConfig entry for SND_HDA_CODEC_CA0132, which is below, or if we should even create such an entry for this submission.

config SND_HDA_CODEC_CA0132
bool "Build Creative CA0132 codec support" depends on SND_HDA_INTEL
default y
help
Say Y here to include Creative CA0132 codec support in snd-hda-intel driver.

When the HD-audio driver is built as a module, the codec support code is also built as another module, snd-hda-codec-ca0132.
This module is automatically loaded at probing.

Please let us know if the Makefile entry needs to be changed or if we should include the KConfig entry somewhere particular.

Thank you,
Ian Minett

---

pci/hda/Makefile +8 -0
index e7baf44..a30437f 100644
@@ -5,6 +5,7 @@ endif
 include $(SND_TOPDIR)/toplevel.config
 include $(SND_TOPDIR)/Makefile.conf
 
+
 clean-files := hda_intel.c hda_beep.c
 
 export-objs  := hda_codec.o
@@ -13,6 +14,13 @@ EXTRA_CFLAGS += -I$(SND_TOPDIR)/alsa-kernel/pci/hda
 
 include $(SND_TOPDIR)/alsa-kernel/pci/hda/Makefile
 
+snd-hda-codec-ca0132-objs :=	patch_ca0132.o
+
+ifdef CONFIG_SND_HDA_CODEC_CA0132
+obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0132.o
+endif
+
+
 ifdef CONFIG_SND_HDA_CODEC_HDMI
 snd-hda-codec-atihdmi-objs :=	dummy.o
 snd-hda-codec-intelhdmi-objs :=	dummy.o
pci/hda/patch_ca0132.c new file +1160 -0

1,160 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw

At Thu, 2 Jun 2011 13:14:25 -0700,

Quoted 3 lines · Ian Minett

Attached is a patch that adds support for the CA0132 HDA codec, creating patch_ca0132.c in pci/hda.

Thanks for the patch!

Quoted 5 lines

It also adds an entry to the pci/hda makefile that builds the codec when SND_HDA_CODEC_CA0132 is defined. However, we are not sure where to add the KConfig entry for SND_HDA_CODEC_CA0132, which is below, or if we should even create such an entry for this submission.

Yes, at best, please include Kconfig change into the same patch.

But I see now you are patching alsa-driver code instead of kernel tree, so it's not too trivial indeed. I recommend you to patch your driver in the kernel tree first, check it works, then submit the patch, instead of modifying alsa-driver tree. We can change alsa-driver tree later for the new stuff.

About the code, see some quick reviews below.

Quoted 8 lines
pci/hda/patch_ca0132.c new file +8 -0
+/*
+ * CA0132 chip access stuffs
+ */
+static int chipio_acquire_mutex(struct hda_codec *codec)
+{
+	struct ca0132_spec *spec = codec->spec;
+
+	mutex_lock(&spec->chipio_mutex);

pci/hda/patch_ca0132.c line 357

Quoted 10 lines
pci/hda/patch_ca0132.c new file +10 -0
+	return 0;
+}
+
+static int chipio_release_mutex(struct hda_codec *codec)
+{
+	struct ca0132_spec *spec = codec->spec;
+
+	mutex_unlock(&spec->chipio_mutex);
+	return 0;
+}

Avoid to introduce such wrappers. It's more readable to get spec in the function and call mutex_lock/unlock appropriately, in general.

Quoted 6 lines
pci/hda/patch_ca0132.c new file +6 -0
+/*
+ * Write chip address through the vendor widget -- NOT protected by the Mutex!
+ */
+static int chipio_write_address(struct hda_codec *codec,
+				unsigned int chip_addx)
+{

pci/hda/patch_ca0132.c line 374

Quoted 10 lines
pci/hda/patch_ca0132.c new file +10 -0
+	unsigned int res = 0;
+	int retry = 100;
+
+	/* send low 16 bits of the address */
+	do {
+		res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0,
+				HDA_SHORT_CMD_VENDOR_CHIP_IO_ADDRESS_LOW,
+				chip_addx & 0xffff);
+		retry--;
+	} while (res != HDA_STATUS_VENDOR_CHIP_IO_OK && retry);

100 retries look fairly much. Do we really need so long access?

thanks,

Takashi