Skip to contentSkip to conversation

ALSA: HDA: add extended HDA

PATCH Superseded Vinod Koul 2 participants 19 messages Jun 4, 2015 – Jun 9, 2015 Sound

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

v6 cover ALSA: HDA: add extended HDA

New HDA controllers from Intel have extended HDA capabilities like multilink, pipe processing, SPIB, GTS etc In order to use them we create an extended HDA bus, controller and stream which uses the extended configuration

Vinod Koul (3):
ALSA: hdac_ext: add extended HDA bus
ALSA: hdac_ext: add hdac extended controller
ALSA: hdac_ext: add extended stream capabilities

 include/sound/hdaudio_ext.h         | 385 +++++++++++++++++++++++++++++++++
 sound/hda/Kconfig                   |   4 +
 sound/hda/Makefile                  |   3 +
 sound/hda/ext/Makefile              |   3 +
 sound/hda/ext/hdac_ext_bus.c        | 115 ++++++++++
 sound/hda/ext/hdac_ext_controller.c | 295 +++++++++++++++++++++++++
 sound/hda/ext/hdac_ext_stream.c     | 414 ++++++++++++++++++++++++++++++++++++
 7 files changed, 1219 insertions(+)
 create mode 100644 include/sound/hdaudio_ext.h
 create mode 100644 sound/hda/ext/Makefile
 create mode 100644 sound/hda/ext/hdac_ext_bus.c
 create mode 100644 sound/hda/ext/hdac_ext_controller.c
 create mode 100644 sound/hda/ext/hdac_ext_stream.c
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v6 1/3 ALSA: hdac_ext: add extended HDA bus

The new HDA controllers from Intel support new capabilities like multilink, pipe processing, SPIB, GTS etc In order to use them we create an extended HDA bus which embed the hdac bus and contains the fields for extended configurations

---
 include/sound/hdaudio_ext.h  |  93 ++++++++++++++++++++++++++++++++++
 sound/hda/Kconfig            |   4 ++
 sound/hda/Makefile           |   3 ++
 sound/hda/ext/Makefile       |   3 ++
 sound/hda/ext/hdac_ext_bus.c | 115 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 218 insertions(+)
 create mode 100644 include/sound/hdaudio_ext.h
 create mode 100644 sound/hda/ext/Makefile
 create mode 100644 sound/hda/ext/hdac_ext_bus.c
include/sound/hdaudio_ext.h new file +93 -0
new file mode 100644
index 000000000000..df1f8ae64693
@@ -0,0 +1,93 @@
+#ifndef __SOUND_HDAUDIO_EXT_H
+#define __SOUND_HDAUDIO_EXT_H
+
+#include <sound/core.h>
+#include <sound/initval.h>
+#include <sound/hda_register.h>
+#include <sound/hdaudio.h>
+
+/**
+ * hdac_ext_bus: HDAC extended bus for extended HDA caps
+ *
+ * @bus: hdac bus
+ * @num_streams: streams supported
+ * @ppcap: HDA ext post processing caps supported
+ * @spbcap: HDA ext Software Position in Buffer cap support
+ * @mlcap: HDA ext MultiLink cap support
+ * @gtscap: HDA ext Global Time Sync cap support
+ * @ppcap_addr: pp capabilities pointer
+ * @spbcap_addr: SPIB capabilities pointer
+ * @mlcap_addr: MultiLink capabilities pointer
+ * @gtscap_addr: gts capabilities pointer
+ * @hlink_list: link list of HDA links
+ */
+struct hdac_ext_bus {
+	struct hdac_bus bus;
+	int num_streams;
+
+	bool ppcap:1;
+	bool spbcap:1;
+	bool mlcap:1;
+	bool gtscap:1;
+
+	void __iomem *ppcap_addr;
+	void __iomem *spbcap_addr;
+	void __iomem *mlcap_addr;
+	void __iomem *gtscap_addr;
+
+	struct list_head hlink_list;
+};
+
+int snd_hdac_ext_bus_init(struct hdac_ext_bus *sbus, struct device *dev,
+		      const struct hdac_bus_ops *ops,
+		      const struct hdac_io_ops *io_ops);
+
+void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus);
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr);
+void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
+
+#define hdac_bus(sbus)	(&(sbus)->bus)
+#define bus_to_hdac_ext_bus(_bus) \
+	container_of(_bus, struct hdac_ext_bus, bus)
+
+int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
+void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
+void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
+
+/*
+ * macros for ppcap register read/write
+ */
+#define _snd_hdac_ext_bus_ppcap_write(type, dev, reg, value)		\
+	((dev)->bus.io_ops->reg_write ## type(value, (dev)->ppcap_addr + (reg)))
+#define _snd_hdac_ext_bus_ppcap_read(type, dev, reg)			\
+	((dev)->bus.io_ops->reg_read ## type((dev)->ppcap_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_ppcap_writel(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_writew(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_writeb(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_readl(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_ppcap_readw(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_ppcap_readb(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_ppcap_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writel(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_ppcap_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writew(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_ppcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
+				~(mask)) | (val))
+
+#endif /* __SOUND_HDAUDIO_EXT_H */
sound/hda/Kconfig +4 -0
index ac5ffac2a272..6dc3914fd28b 100644
@@ -10,3 +10,7 @@ config SND_HDA_I915
 	default y
 	depends on DRM_I915
 	depends on SND_HDA_CORE
+
+config SND_HDA_EXT_CORE
+       tristate
+       select SND_HDA_CORE
sound/hda/Makefile +3 -0
index 55dd465c7042..7e999c995cdc 100644
@@ -8,3 +8,6 @@ CFLAGS_trace.o := -I$(src)
 snd-hda-core-$(CONFIG_SND_HDA_I915) += hdac_i915.o
 
 obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
+
+#extended hda
+obj-$(CONFIG_SND_HDA_EXT_CORE) += ext/
sound/hda/ext/Makefile new file +3 -0
new file mode 100644
index 000000000000..2e583e664916
@@ -0,0 +1,3 @@
+snd-hda-ext-core-objs := hdac_ext_bus.o
+
+obj-$(CONFIG_SND_HDA_EXT_CORE) += snd-hda-ext-core.o
sound/hda/ext/hdac_ext_bus.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

At Thu, 4 Jun 2015 15:23:20 +0530,

Quoted 25 lines · Vinod Koul

The new HDA controllers from Intel support new capabilities like multilink, pipe processing, SPIB, GTS etc In order to use them we create an extended HDA bus which embed the hdac bus and contains the fields for extended configurations

---
 include/sound/hdaudio_ext.h  |  93 ++++++++++++++++++++++++++++++++++
 sound/hda/Kconfig            |   4 ++
 sound/hda/Makefile           |   3 ++
 sound/hda/ext/Makefile       |   3 ++
 sound/hda/ext/hdac_ext_bus.c | 115 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 218 insertions(+)
 create mode 100644 include/sound/hdaudio_ext.h
 create mode 100644 sound/hda/ext/Makefile
 create mode 100644 sound/hda/ext/hdac_ext_bus.c
include/sound/hdaudio_ext.h new file +0 -0
new file mode 100644
index 000000000000..df1f8ae64693

include/sound/hdaudio_ext.h line 5

Quoted 5 lines
include/sound/hdaudio_ext.h new file +5 -0
@@ -0,0 +1,93 @@
+#ifndef __SOUND_HDAUDIO_EXT_H
+#define __SOUND_HDAUDIO_EXT_H
+
+#include <sound/core.h>
+#include <sound/initval.h>

Do we need this header?

Quoted 34 lines
include/sound/hdaudio_ext.h new file +34 -0
+#include <sound/hda_register.h>
+#include <sound/hdaudio.h>
+
+/**
+ * hdac_ext_bus: HDAC extended bus for extended HDA caps
+ *
+ * @bus: hdac bus
+ * @num_streams: streams supported
+ * @ppcap: HDA ext post processing caps supported
+ * @spbcap: HDA ext Software Position in Buffer cap support
+ * @mlcap: HDA ext MultiLink cap support
+ * @gtscap: HDA ext Global Time Sync cap support
+ * @ppcap_addr: pp capabilities pointer
+ * @spbcap_addr: SPIB capabilities pointer
+ * @mlcap_addr: MultiLink capabilities pointer
+ * @gtscap_addr: gts capabilities pointer
+ * @hlink_list: link list of HDA links
+ */
+struct hdac_ext_bus {
+	struct hdac_bus bus;
+	int num_streams;
+
+	bool ppcap:1;
+	bool spbcap:1;
+	bool mlcap:1;
+	bool gtscap:1;
+
+	void __iomem *ppcap_addr;
+	void __iomem *spbcap_addr;
+	void __iomem *mlcap_addr;
+	void __iomem *gtscap_addr;
+
+	struct list_head hlink_list;
+};

include/sound/hdaudio_ext.h line 49

Quoted 10 lines
include/sound/hdaudio_ext.h new file +10 -0
+
+int snd_hdac_ext_bus_init(struct hdac_ext_bus *sbus, struct device *dev,
+		      const struct hdac_bus_ops *ops,
+		      const struct hdac_io_ops *io_ops);
+
+void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus);
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr);
+void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
+
+#define hdac_bus(sbus)	(&(sbus)->bus)

This macro name is a bit too ambiguous. If it were really a generic cast, I wouldn't mind. But it's specific to this type.

Quoted 32 lines
include/sound/hdaudio_ext.h new file +32 -0
+#define bus_to_hdac_ext_bus(_bus) \
+	container_of(_bus, struct hdac_ext_bus, bus)
+
+int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
+void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
+void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
+
+/*
+ * macros for ppcap register read/write
+ */
+#define _snd_hdac_ext_bus_ppcap_write(type, dev, reg, value)		\
+	((dev)->bus.io_ops->reg_write ## type(value, (dev)->ppcap_addr + (reg)))
+#define _snd_hdac_ext_bus_ppcap_read(type, dev, reg)			\
+	((dev)->bus.io_ops->reg_read ## type((dev)->ppcap_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_ppcap_writel(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_writew(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_writeb(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_readl(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_ppcap_readw(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_ppcap_readb(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_ppcap_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writel(dev, reg, \

include/sound/hdaudio_ext.h line 91

Quoted 10 lines
include/sound/hdaudio_ext.h new file +10 -0
+			       (snd_hdac_ext_bus_ppcap_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_ppcap_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writew(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_ppcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
+				~(mask)) | (val))

It's not necessarily good to wrap all with such macros.
For azx_write*(), I kept them as is for reducing the amount of useless code rewrites. But for new codes, I don't think it's always worth...

thanks,

Takashi

Quoted 157 lines
include/sound/hdaudio_ext.h new file +1 -0
+#endif /* __SOUND_HDAUDIO_EXT_H */
sound/hda/Kconfig +4 -0
index ac5ffac2a272..6dc3914fd28b 100644
@@ -10,3 +10,7 @@ config SND_HDA_I915
 	default y
 	depends on DRM_I915
 	depends on SND_HDA_CORE
+
+config SND_HDA_EXT_CORE
+       tristate
+       select SND_HDA_CORE
sound/hda/Makefile +3 -0
index 55dd465c7042..7e999c995cdc 100644
@@ -8,3 +8,6 @@ CFLAGS_trace.o := -I$(src)
 snd-hda-core-$(CONFIG_SND_HDA_I915) += hdac_i915.o
 
 obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
+
+#extended hda
+obj-$(CONFIG_SND_HDA_EXT_CORE) += ext/
sound/hda/ext/Makefile new file +3 -0
new file mode 100644
index 000000000000..2e583e664916
@@ -0,0 +1,3 @@
+snd-hda-ext-core-objs := hdac_ext_bus.o
+
+obj-$(CONFIG_SND_HDA_EXT_CORE) += snd-hda-ext-core.o
sound/hda/ext/hdac_ext_bus.c new file +115 -0
new file mode 100644
index 000000000000..b5dbf33be72d
@@ -0,0 +1,115 @@
+/*
+ *  hdac-ext-bus.c - HD-audio extended core bus functions.
+ *
+ *  Copyright (C) 2014-2015 Intel Corp
+ *  Author: Jeeja KP <[email protected]>
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/export.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include <sound/hdaudio_ext.h>
+
+/**
+ * snd_hdac_ext_bus_init - initialize a HD-audio extended bus
+ * @sbus: the pointer to extended bus object
+ * @dev: device pointer
+ * @ops: bus verb operators
+ * @io_ops: lowlevel I/O operators
+ *
+ * Returns 0 if successful, or a negative error code.
+ */
+int snd_hdac_ext_bus_init(struct hdac_ext_bus *sbus, struct device *dev,
+			const struct hdac_bus_ops *ops,
+			const struct hdac_io_ops *io_ops)
+{
+	int ret;
+
+	ret = snd_hdac_bus_init(&sbus->bus, dev, ops, io_ops);
+	if (ret < 0)
+		return ret;
+
+	INIT_LIST_HEAD(&sbus->hlink_list);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_init);
+
+/**
+ * snd_hdac_ext_bus_exit - clean up a HD-audio extended bus
+ * @sbus: the pointer to extended bus object
+ */
+void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus)
+{
+	snd_hdac_bus_exit(&sbus->bus);
+	WARN_ON(!list_empty(&sbus->hlink_list));
+}
+EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_exit);
+
+static void default_release(struct device *dev)
+{
+	snd_hdac_ext_bus_device_exit(container_of(dev, struct hdac_device, dev));
+}
+
+/**
+ * snd_hdac_ext_device_init - initialize the HDA extended codec base device
+ * @sbus: hdac extended bus to attach to
+ * @addr: codec address
+ *
+ * Returns zero for success or a negative error code.
+ */
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr)
+{
+	struct hdac_device *hdev = NULL;
+	struct hdac_bus *bus = hdac_bus(sbus);
+	char name[15];
+	int ret;
+
+	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
+	snprintf(name, sizeof(name), "hda-codec#%03x", addr);
+
+	ret  = snd_hdac_device_init(hdev, bus, name, addr);
+	if (ret < 0) {
+		dev_err(bus->dev, "device init failed for hdac device\n");
+		return ret;
+	}
+	hdev->type = HDA_DEV_ASOC;
+	hdev->dev.release = default_release;
+
+	ret = snd_hdac_device_register(hdev);
+	if (ret) {
+		dev_err(bus->dev, "failed to register hdac device\n");
+		snd_hdac_ext_bus_device_exit(hdev);
+		return ret;
+	}
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init);
+
+/**
+ * snd_hdac_ext_bus_device_exit - clean up a HD-audio extended codec base device
+ * @hdev: hdac device to clean up
+ */
+void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev)
+{
+	snd_hdac_device_exit(hdev);
+	kfree(hdev);
+}
+EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);
Signature · 1 line
1.9.1
author
#3 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

Quoted 21 lines · Takashi Iwai

At Thu, 4 Jun 2015 15:23:20 +0530,

Quoted 19 lines · Vinod Koul

The new HDA controllers from Intel support new capabilities like multilink, pipe processing, SPIB, GTS etc In order to use them we create an extended HDA bus which embed the hdac bus and contains the fields for extended configurations

---
 include/sound/hdaudio_ext.h  |  93 ++++++++++++++++++++++++++++++++++
 sound/hda/Kconfig            |   4 ++
 sound/hda/Makefile           |   3 ++
 sound/hda/ext/Makefile       |   3 ++
 sound/hda/ext/hdac_ext_bus.c | 115 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 218 insertions(+)
 create mode 100644 include/sound/hdaudio_ext.h
 create mode 100644 sound/hda/ext/Makefile
 create mode 100644 sound/hda/ext/hdac_ext_bus.c
Quoted 13 lines

include/sound/hdaudio_ext.h line 5

Quoted 11 lines
include/sound/hdaudio_ext.h new file +5 -0
new file mode 100644
index 000000000000..df1f8ae64693
@@ -0,0 +1,93 @@
+#ifndef __SOUND_HDAUDIO_EXT_H
+#define __SOUND_HDAUDIO_EXT_H
+
+#include <sound/core.h>
+#include <sound/initval.h>

Do we need this header?

I dont think so will confirm and update this

Quoted 40 lines
Quoted 40 lines
include/sound/hdaudio_ext.h new file +39 -0
+#include <sound/hda_register.h>
+#include <sound/hdaudio.h>
+
+/**
+ * hdac_ext_bus: HDAC extended bus for extended HDA caps
+ *
+ * @bus: hdac bus
+ * @num_streams: streams supported
+ * @ppcap: HDA ext post processing caps supported
+ * @spbcap: HDA ext Software Position in Buffer cap support
+ * @mlcap: HDA ext MultiLink cap support
+ * @gtscap: HDA ext Global Time Sync cap support
+ * @ppcap_addr: pp capabilities pointer
+ * @spbcap_addr: SPIB capabilities pointer
+ * @mlcap_addr: MultiLink capabilities pointer
+ * @gtscap_addr: gts capabilities pointer
+ * @hlink_list: link list of HDA links
+ */
+struct hdac_ext_bus {
+	struct hdac_bus bus;
+	int num_streams;
+
+	bool ppcap:1;
+	bool spbcap:1;
+	bool mlcap:1;
+	bool gtscap:1;
+
+	void __iomem *ppcap_addr;
+	void __iomem *spbcap_addr;
+	void __iomem *mlcap_addr;
+	void __iomem *gtscap_addr;
+
+	struct list_head hlink_list;
+};
+
+int snd_hdac_ext_bus_init(struct hdac_ext_bus *sbus, struct device *dev,
+		      const struct hdac_bus_ops *ops,
+		      const struct hdac_io_ops *io_ops);
+
Quoted 8 lines

include/sound/hdaudio_ext.h line 49

Quoted 5 lines
include/sound/hdaudio_ext.h new file +5 -0
+void snd_hdac_ext_bus_exit(struct hdac_ext_bus *sbus);
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr);
+void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
+
+#define hdac_bus(sbus)	(&(sbus)->bus)

This macro name is a bit too ambiguous. If it were really a generic cast, I wouldn't mind. But it's specific to this type.

Yes would ebus_to_hdac_bus() make it better or something else

Quoted 39 lines
Quoted 39 lines
include/sound/hdaudio_ext.h new file +38 -0
+#define bus_to_hdac_ext_bus(_bus) \
+	container_of(_bus, struct hdac_ext_bus, bus)
+
+int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus);
+void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable);
+void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
+
+/*
+ * macros for ppcap register read/write
+ */
+#define _snd_hdac_ext_bus_ppcap_write(type, dev, reg, value)		\
+	((dev)->bus.io_ops->reg_write ## type(value, (dev)->ppcap_addr + (reg)))
+#define _snd_hdac_ext_bus_ppcap_read(type, dev, reg)			\
+	((dev)->bus.io_ops->reg_read ## type((dev)->ppcap_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_ppcap_writel(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_writew(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_writeb(dev, reg, value) \
+	_snd_hdac_ext_bus_ppcap_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_ppcap_readl(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_ppcap_readw(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_ppcap_readb(dev, reg) \
+	_snd_hdac_ext_bus_ppcap_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_ppcap_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writel(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_ppcap_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writew(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readw(dev, reg) & \
+				~(mask)) | (val))
Quoted 8 lines

include/sound/hdaudio_ext.h line 91

Quoted 4 lines
include/sound/hdaudio_ext.h new file +4 -0
+#define snd_hdac_ext_bus_ppcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
+				~(mask)) | (val))

It's not necessarily good to wrap all with such macros.
For azx_write*(), I kept them as is for reducing the amount of useless code rewrites. But for new codes, I don't think it's always worth...

Actually while updating the patch for ext I was wondering about this too.

So we cna remove these and use snd_hdac_chip_writel/w/b here

let me update it here and for other caps

Signature · 1 line
~Vinod
author
#4 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

Quoted 11 lines · Vinod Koul
Quoted 8 lines

include/sound/hdaudio_ext.h line 91

Quoted 4 lines
include/sound/hdaudio_ext.h new file +4 -0
+#define snd_hdac_ext_bus_ppcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
+				~(mask)) | (val))

It's not necessarily good to wrap all with such macros.
For azx_write*(), I kept them as is for reducing the amount of useless code rewrites. But for new codes, I don't think it's always worth...

Actually while updating the patch for ext I was wondering about this too.

So we cna remove these and use snd_hdac_chip_writel/w/b here

As Jeeja pointed we can't use snd_hdac_chip_writel as we need to use a different base. So we cna move this to use plain writel only

Any other ideas?

Signature · 1 line
~Vinod
#5 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

At Mon, 8 Jun 2015 21:00:14 +0530,

Quoted 10 lines · Vinod Koul
Quoted 8 lines · Vinod Koul
Quoted 8 lines

include/sound/hdaudio_ext.h line 91

Quoted 4 lines
include/sound/hdaudio_ext.h new file +4 -0
+#define snd_hdac_ext_bus_ppcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
+				~(mask)) | (val))

It's not necessarily good to wrap all with such macros.
For azx_write*(), I kept them as is for reducing the amount of useless code rewrites. But for new codes, I don't think it's always worth...

Quoted 7 lines
Quoted 3 lines

Actually while updating the patch for ext I was wondering about this too.

So we cna remove these and use snd_hdac_chip_writel/w/b here

As Jeeja pointed we can't use snd_hdac_chip_writel as we need to use a different base. So we cna move this to use plain writel only

Any other ideas?

I don't think you need to access via io_ops redirection as these are SKL specific registers. Use plain readl()/writel() and keep things as simple as possible.

(And better to avoid w and b variants.)

Takashi

author
#6 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

Quoted 18 lines · Takashi Iwai

At Mon, 8 Jun 2015 21:00:14 +0530,

Quoted 16 lines · Vinod Koul
Quoted 11 lines · Vinod Koul
Quoted 8 lines

include/sound/hdaudio_ext.h line 91

Quoted 4 lines
include/sound/hdaudio_ext.h new file +4 -0
+#define snd_hdac_ext_bus_ppcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
+				~(mask)) | (val))

It's not necessarily good to wrap all with such macros.
For azx_write*(), I kept them as is for reducing the amount of useless code rewrites. But for new codes, I don't think it's always worth...

Actually while updating the patch for ext I was wondering about this too.

So we cna remove these and use snd_hdac_chip_writel/w/b here

As Jeeja pointed we can't use snd_hdac_chip_writel as we need to use a different base. So we cna move this to use plain writel only

Quoted 7 lines
Quoted 1 line

Any other ideas?

I don't think you need to access via io_ops redirection as these are SKL specific registers. Use plain readl()/writel() and keep things as simple as possible.

(And better to avoid w and b variants.)

Okay I have removed all these macros but ended up defining one generic update macros (most of the places we are doing read and write, so better to use update macro

/* update register macro */

#define snd_hdac_updatel(addr, reg, mask, val) \
	writel(addr, reg, (readl(addr, reg) & ~(mask)) | (val))

yes its updatel to signify that it uses writel and readl

Let me know if you are fine with this approach

Signature · 1 line
~Vinod
#7 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

At Tue, 9 Jun 2015 15:36:51 +0530,

Quoted 31 lines · Vinod Koul
Quoted 18 lines · Takashi Iwai

At Mon, 8 Jun 2015 21:00:14 +0530,

Quoted 16 lines · Vinod Koul
Quoted 11 lines · Vinod Koul
Quoted 8 lines

include/sound/hdaudio_ext.h line 91

Quoted 4 lines
include/sound/hdaudio_ext.h new file +4 -0
+#define snd_hdac_ext_bus_ppcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_ppcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
+				~(mask)) | (val))

It's not necessarily good to wrap all with such macros.
For azx_write*(), I kept them as is for reducing the amount of useless code rewrites. But for new codes, I don't think it's always worth...

Actually while updating the patch for ext I was wondering about this too.

So we cna remove these and use snd_hdac_chip_writel/w/b here

As Jeeja pointed we can't use snd_hdac_chip_writel as we need to use a different base. So we cna move this to use plain writel only

Quoted 7 lines
Quoted 1 line

Any other ideas?

I don't think you need to access via io_ops redirection as these are SKL specific registers. Use plain readl()/writel() and keep things as simple as possible.

(And better to avoid w and b variants.)

Okay I have removed all these macros but ended up defining one generic update macros (most of the places we are doing read and write, so better to use update macro

Quoted 7 lines

/* update register macro */

#define snd_hdac_updatel(addr, reg, mask, val) \
	writel(addr, reg, (readl(addr, reg) & ~(mask)) | (val))

yes its updatel to signify that it uses writel and readl

Let me know if you are fine with this approach

This looks good to me.

thanks,

Takashi

#8 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

In reply to Vinod Koul

One thing forgot...

At Thu, 4 Jun 2015 15:23:20 +0530,

Quoted 12 lines · Vinod Koul
sound/hda/ext/hdac_ext_bus.c new file +11 -0
+/**
+ * snd_hdac_ext_device_init - initialize the HDA extended codec base device
+ * @sbus: hdac extended bus to attach to
+ * @addr: codec address
+ *
+ * Returns zero for success or a negative error code.
+ */
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr)
+{
+	struct hdac_device *hdev = NULL;
+	struct hdac_bus *bus = hdac_bus(sbus);

sound/hda/ext/hdac_ext_bus.c line 88

Quoted 10 lines
sound/hda/ext/hdac_ext_bus.c new file +10 -0
+	char name[15];
+	int ret;
+
+	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
+	snprintf(name, sizeof(name), "hda-codec#%03x", addr);
+
+	ret  = snd_hdac_device_init(hdev, bus, name, addr);

The device name must be unique to the whole system. Using only the codec address as an id would conflict if there are multiple cards. The legacy HDA device consists of "hdaudioC%dD%d" indicating both the card number and the codec address, for example.

Takashi

author
#9 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

Quoted 23 lines · Takashi Iwai

One thing forgot...

At Thu, 4 Jun 2015 15:23:20 +0530,

Quoted 19 lines · Vinod Koul
sound/hda/ext/hdac_ext_bus.c new file +18 -0
+/**
+ * snd_hdac_ext_device_init - initialize the HDA extended codec base device
+ * @sbus: hdac extended bus to attach to
+ * @addr: codec address
+ *
+ * Returns zero for success or a negative error code.
+ */
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr)
+{
+	struct hdac_device *hdev = NULL;
+	struct hdac_bus *bus = hdac_bus(sbus);
+	char name[15];
+	int ret;
+
+	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
Quoted 8 lines

sound/hda/ext/hdac_ext_bus.c line 88

Quoted 3 lines
sound/hda/ext/hdac_ext_bus.c new file +3 -0
+	snprintf(name, sizeof(name), "hda-codec#%03x", addr);
+
+	ret  = snd_hdac_device_init(hdev, bus, name, addr);

The device name must be unique to the whole system. Using only the codec address as an id would conflict if there are multiple cards. The legacy HDA device consists of "hdaudioC%dD%d" indicating both the card number and the codec address, for example.

Sorry my bad, you did comment on it before as well. I will fix it now, by adding card name here.

Signature · 1 line
~Vinod
author
#10 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

Quoted 32 lines · Vinod Koul
Quoted 23 lines · Takashi Iwai

One thing forgot...

At Thu, 4 Jun 2015 15:23:20 +0530,

Quoted 19 lines · Vinod Koul
sound/hda/ext/hdac_ext_bus.c new file +18 -0
+/**
+ * snd_hdac_ext_device_init - initialize the HDA extended codec base device
+ * @sbus: hdac extended bus to attach to
+ * @addr: codec address
+ *
+ * Returns zero for success or a negative error code.
+ */
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr)
+{
+	struct hdac_device *hdev = NULL;
+	struct hdac_bus *bus = hdac_bus(sbus);
+	char name[15];
+	int ret;
+
+	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
Quoted 8 lines

sound/hda/ext/hdac_ext_bus.c line 88

Quoted 3 lines
sound/hda/ext/hdac_ext_bus.c new file +3 -0
+	snprintf(name, sizeof(name), "hda-codec#%03x", addr);
+
+	ret  = snd_hdac_device_init(hdev, bus, name, addr);

The device name must be unique to the whole system. Using only the codec address as an id would conflict if there are multiple cards. The legacy HDA device consists of "hdaudioC%dD%d" indicating both the card number and the codec address, for example.

Quoted 2 lines

Sorry my bad, you did comment on it before as well. I will fix it now, by adding card name here.

Okay and we have an issue here :(, We actually dont know the card number here and card number will be created after this enumeration is complete and we register the DAI with ASoC and then ASoC would create card later.

So how do we solve this?

Signature · 1 line
~Vinod
#11 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

At Mon, 8 Jun 2015 20:54:23 +0530,

Quoted 34 lines · Vinod Koul
Quoted 32 lines · Vinod Koul
Quoted 31 lines · Takashi Iwai

One thing forgot...

At Thu, 4 Jun 2015 15:23:20 +0530,

Quoted 12 lines · Vinod Koul
sound/hda/ext/hdac_ext_bus.c new file +11 -0
+/**
+ * snd_hdac_ext_device_init - initialize the HDA extended codec base device
+ * @sbus: hdac extended bus to attach to
+ * @addr: codec address
+ *
+ * Returns zero for success or a negative error code.
+ */
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr)
+{
+	struct hdac_device *hdev = NULL;
+	struct hdac_bus *bus = hdac_bus(sbus);

sound/hda/ext/hdac_ext_bus.c line 88

Quoted 10 lines
sound/hda/ext/hdac_ext_bus.c new file +10 -0
+	char name[15];
+	int ret;
+
+	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
+	snprintf(name, sizeof(name), "hda-codec#%03x", addr);
+
+	ret  = snd_hdac_device_init(hdev, bus, name, addr);

The device name must be unique to the whole system. Using only the codec address as an id would conflict if there are multiple cards. The legacy HDA device consists of "hdaudioC%dD%d" indicating both the card number and the codec address, for example.

Quoted 7 lines
Quoted 2 lines

Sorry my bad, you did comment on it before as well. I will fix it now, by adding card name here.

Okay and we have an issue here :(, We actually dont know the card number here and card number will be created after this enumeration is complete and we register the DAI with ASoC and then ASoC would create card later.

So how do we solve this?

Instead of the card number, assign some unique index (either a simple static counter or use idr) to each bus object and use it instead of the card number. After all, we just need a unique mapping.

Alternatively, you may rename via dev_set_name() just before registration. But, of course, this is inconsistent in some areas, e.g. dev_err() shows differently before and after registration.

Takashi

author
#12 lore raw

Re: [PATCH v6 1/3] ALSA: hdac_ext: add extended HDA bus

Quoted 42 lines · Takashi Iwai

At Mon, 8 Jun 2015 20:54:23 +0530,

Quoted 40 lines · Vinod Koul
Quoted 32 lines · Vinod Koul
Quoted 23 lines · Takashi Iwai

One thing forgot...

At Thu, 4 Jun 2015 15:23:20 +0530,

Quoted 19 lines · Vinod Koul
sound/hda/ext/hdac_ext_bus.c new file +18 -0
+/**
+ * snd_hdac_ext_device_init - initialize the HDA extended codec base device
+ * @sbus: hdac extended bus to attach to
+ * @addr: codec address
+ *
+ * Returns zero for success or a negative error code.
+ */
+int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *sbus, int addr)
+{
+	struct hdac_device *hdev = NULL;
+	struct hdac_bus *bus = hdac_bus(sbus);
+	char name[15];
+	int ret;
+
+	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
Quoted 8 lines

sound/hda/ext/hdac_ext_bus.c line 88

Quoted 3 lines
sound/hda/ext/hdac_ext_bus.c new file +3 -0
+	snprintf(name, sizeof(name), "hda-codec#%03x", addr);
+
+	ret  = snd_hdac_device_init(hdev, bus, name, addr);

The device name must be unique to the whole system. Using only the codec address as an id would conflict if there are multiple cards. The legacy HDA device consists of "hdaudioC%dD%d" indicating both the card number and the codec address, for example.

Quoted 2 lines

Sorry my bad, you did comment on it before as well. I will fix it now, by adding card name here.

Okay and we have an issue here :(, We actually dont know the card number here and card number will be created after this enumeration is complete and we register the DAI with ASoC and then ASoC would create card later.

Quoted 5 lines
Quoted 1 line

So how do we solve this?

Instead of the card number, assign some unique index (either a simple static counter or use idr) to each bus object and use it instead of the card number. After all, we just need a unique mapping.

That is doable, lets maintain a counter then :) Also we are thinking of using "hdaudio%dD%d" or "ehdaudio%dD%d" dropping Card charcter

Quoted 4 lines

Alternatively, you may rename via dev_set_name() just before registration. But, of course, this is inconsistent in some areas, e.g. dev_err() shows differently before and after registration.

Yes lets avoid it

Signature · 1 line
~Vinod
author
#13 lore raw

PATCH v6 2/3 ALSA: hdac_ext: add hdac extended controller

In reply to Vinod Koul

The controller needs to support the new capabilities and allow reading, parsing and initializing of these capabilities, so this patch does it

---
 include/sound/hdaudio_ext.h         | 174 +++++++++++++++++++++
 sound/hda/ext/Makefile              |   2 +-
 sound/hda/ext/hdac_ext_controller.c | 295 ++++++++++++++++++++++++++++++++++++
 3 files changed, 470 insertions(+), 1 deletion(-)
 create mode 100644 sound/hda/ext/hdac_ext_controller.c
include/sound/hdaudio_ext.h +174 -0
index df1f8ae64693..b17d7f91f6ac 100644
@@ -90,4 +90,178 @@ void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
 			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
 				~(mask)) | (val))
 
+void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
+				 bool enable, int index);
+/*
+ * macros for spcap register read/write
+ */
+#define _snd_hdac_ext_bus_spbcap_write(type, dev, reg, value)	\
+	((dev)->bus.io_ops->reg_write ## type(value,		\
+	(dev)->spbcap_addr + (reg)))
+#define _snd_hdac_ext_bus_spbcap_read(type, dev, reg)		\
+	((dev)->bus.io_ops->reg_read ## type((dev)->spbcap_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_spbcap_writel(dev, reg, value) \
+	_snd_hdac_ext_bus_spbcap_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_spbcap_writew(dev, reg, value) \
+	_snd_hdac_ext_bus_spbcap_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_spbcap_writeb(dev, reg, value) \
+	_snd_hdac_ext_bus_spbcap_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_spbcap_readl(dev, reg) \
+	_snd_hdac_ext_bus_spbcap_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_spbcap_readw(dev, reg) \
+	_snd_hdac_ext_bus_spbcap_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_spbcap_readb(dev, reg) \
+	_snd_hdac_ext_bus_spbcap_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_spbcap_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_bus_spbcap_writel(dev, reg, \
+			       (snd_hdac_ext_bus_spbcap_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_spbcap_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_bus_spbcap_writew(dev, reg, \
+			       (snd_hdac_ext_bus_spbcap_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_spbcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_spbcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_spbcap_readb(dev, reg) & \
+				~(mask)) | (val))
+
+int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_ext_bus *bus);
+int snd_hdac_ext_bus_map_codec_to_link(struct hdac_ext_bus *bus, int addr);
+struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *bus,
+						const char *codec_name);
+
+/*
+ * macros for mlcap register read/write
+ */
+#define _snd_hdac_ext_bus_mlcap_write(type, dev, reg, value)		\
+	((dev)->bus.io_ops->reg_write ## type(value, (dev)->mlcap_addr + (reg)))
+#define _snd_hdac_ext_bus_mlcap_read(type, dev, reg)			\
+	((dev)->bus.io_ops->reg_read ## type((dev)->mlcap_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_mlcap_writel(dev, reg, value) \
+	_snd_hdac_ext_bus_mlcap_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_mlcap_writew(dev, reg, value) \
+	_snd_hdac_ext_bus_mlcap_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_mlcap_writeb(dev, reg, value) \
+	_snd_hdac_ext_bus_mlcap_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_mlcap_readl(dev, reg) \
+	_snd_hdac_ext_bus_mlcap_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_mlcap_readw(dev, reg) \
+	_snd_hdac_ext_bus_mlcap_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_mlcap_readb(dev, reg) \
+	_snd_hdac_ext_bus_mlcap_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_mlcap_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_bus_mlcap_writel(dev, reg, \
+			       (snd_hdac_ext_bus_mlcap_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_mlcap_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_bus_mlcap_writew(dev, reg, \
+			       (snd_hdac_ext_bus_mlcap_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_mlcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_mlcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_mlcap_readb(dev, reg) & \
+				~(mask)) | (val))
+
+/*
+ * macros for gtscap register read/write
+ */
+#define _snd_hdac_ext_bus_gtscap_write(type, dev, reg, value)	\
+	((dev)->bus.io_ops->reg_write ## type(value,		\
+	(dev)->gtscap_addr + (reg)))
+#define _snd_hdac_ext_bus_gtscap_read(type, dev, reg)		\
+	((dev)->bus.io_ops->reg_read ## type((dev)->gtscap_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_gtscap_writel(dev, reg, value) \
+	_snd_hdac_ext_bus_gtscap_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_gtscap_writew(dev, reg, value) \
+	_snd_hdac_ext_bus_gtscap_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_gtscap_writeb(dev, reg, value) \
+	_snd_hdac_ext_bus_gtscap_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_gtscap_readl(dev, reg) \
+	_snd_hdac_ext_bus_gtscap_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_gtscap_readw(dev, reg) \
+	_snd_hdac_ext_bus_gtscap_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_gtscap_readb(dev, reg) \
+	_snd_hdac_ext_bus_gtscap_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_gtscap_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_bus_gtscap_writel(dev, reg, \
+			       (snd_hdac_ext_bus_gtscap_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_gtscap_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_bus_gtscap_writew(dev, reg, \
+			       (snd_hdac_ext_bus_gtscap_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_gtscap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_gtscap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_gtscap_readb(dev, reg) & \
+				~(mask)) | (val))
+enum hdac_ext_stream_type {
+	HDAC_EXT_STREAM_TYPE_COUPLED = 0,
+	HDAC_EXT_STREAM_TYPE_HOST,
+	HDAC_EXT_STREAM_TYPE_LINK
+};
+
+struct hdac_ext_link {
+	struct hdac_bus *bus;
+	int index;
+	void __iomem *ml_addr; /* link output stream reg pointer */
+	u32 lcaps;   /* link capablities */
+	u16 lsdiid;  /* link sdi identifier */
+	char codec[HDA_MAX_CODECS][32]; /* codecs connectes to the link */
+	struct list_head list;
+};
+
+int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
+int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
+void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
+				 int stream);
+void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
+				 int stream);
+
+/*
+ * macros for mutilink register read/ write
+ */
+#define _snd_hdac_ext_link_write(type, dev, reg, value)			\
+	((dev)->bus->io_ops->reg_write ## type(value, (dev)->ml_addr + (reg)))
+#define _snd_hdac_ext_link_read(type, dev, reg)				\
+	((dev)->bus->io_ops->reg_read ## type((dev)->ml_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_link_writel(dev, reg, value) \
+	_snd_hdac_ext_link_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_link_writew(dev, reg, value) \
+	_snd_hdac_ext_link_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_link_writeb(dev, reg, value) \
+	_snd_hdac_ext_link_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_link_readl(dev, reg) \
+	_snd_hdac_ext_link_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_link_readw(dev, reg) \
+	_snd_hdac_ext_link_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_link_readb(dev, reg) \
+	_snd_hdac_ext_link_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_link_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_link_writel(dev, reg, \
+			       (snd_hdac_ext_link_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_link_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_link_writew(dev, reg, \
+			       (snd_hdac_ext_link_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_link_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_link_writeb(dev, reg, \
+			       (snd_hdac_ext_link_readb(dev, reg) & \
+				~(mask)) | (val))
 #endif /* __SOUND_HDAUDIO_EXT_H */
sound/hda/ext/Makefile +1 -1
index 2e583e664916..934b7bf5d87f 100644
@@ -1,3 +1,3 @@
-snd-hda-ext-core-objs := hdac_ext_bus.o
+snd-hda-ext-core-objs := hdac_ext_bus.o hdac_ext_controller.o
 
 obj-$(CONFIG_SND_HDA_EXT_CORE) += snd-hda-ext-core.o
sound/hda/ext/hdac_ext_controller.c new file +295 -0

295 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

Re: [PATCH v6 2/3] ALSA: hdac_ext: add hdac extended controller

At Thu, 4 Jun 2015 15:23:21 +0530,

Quoted 49 lines · Vinod Koul

The controller needs to support the new capabilities and allow reading, parsing and initializing of these capabilities, so this patch does it

---
 include/sound/hdaudio_ext.h         | 174 +++++++++++++++++++++
 sound/hda/ext/Makefile              |   2 +-
 sound/hda/ext/hdac_ext_controller.c | 295 ++++++++++++++++++++++++++++++++++++
 3 files changed, 470 insertions(+), 1 deletion(-)
 create mode 100644 sound/hda/ext/hdac_ext_controller.c
include/sound/hdaudio_ext.h +28 -0
index df1f8ae64693..b17d7f91f6ac 100644
@@ -90,4 +90,178 @@ void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable);
 			       (snd_hdac_ext_bus_ppcap_readb(dev, reg) & \
 				~(mask)) | (val))
 
+void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
+				 bool enable, int index);
+/*
+ * macros for spcap register read/write
+ */
+#define _snd_hdac_ext_bus_spbcap_write(type, dev, reg, value)	\
+	((dev)->bus.io_ops->reg_write ## type(value,		\
+	(dev)->spbcap_addr + (reg)))
+#define _snd_hdac_ext_bus_spbcap_read(type, dev, reg)		\
+	((dev)->bus.io_ops->reg_read ## type((dev)->spbcap_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_spbcap_writel(dev, reg, value) \
+	_snd_hdac_ext_bus_spbcap_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_spbcap_writew(dev, reg, value) \
+	_snd_hdac_ext_bus_spbcap_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_spbcap_writeb(dev, reg, value) \
+	_snd_hdac_ext_bus_spbcap_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_bus_spbcap_readl(dev, reg) \
+	_snd_hdac_ext_bus_spbcap_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_spbcap_readw(dev, reg) \
+	_snd_hdac_ext_bus_spbcap_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_bus_spbcap_readb(dev, reg) \
+	_snd_hdac_ext_bus_spbcap_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_bus_spbcap_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_bus_spbcap_writel(dev, reg, \

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 130

Quoted 10 lines
include/sound/hdaudio_ext.h +10 -0
+			       (snd_hdac_ext_bus_spbcap_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_spbcap_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_bus_spbcap_writew(dev, reg, \
+			       (snd_hdac_ext_bus_spbcap_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_bus_spbcap_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_bus_spbcap_writeb(dev, reg, \
+			       (snd_hdac_ext_bus_spbcap_readb(dev, reg) & \
+				~(mask)) | (val))

The same question for these macros: whether we really want to wrap all. (Ditto for mlcap, and others.)

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 221

Quoted 7 lines
include/sound/hdaudio_ext.h +7 -0
+struct hdac_ext_link {
+	struct hdac_bus *bus;
+	int index;
+	void __iomem *ml_addr; /* link output stream reg pointer */
+	u32 lcaps;   /* link capablities */
+	u16 lsdiid;  /* link sdi identifier */
+	char codec[HDA_MAX_CODECS][32]; /* codecs connectes to the link */

Do we need to keep the codec name string? Isn't it just codec address we'd like to check the match...? If so, we may use bitmasks instead, too.

Quoted 30 lines
include/sound/hdaudio_ext.h +30 -0
+/**
+ * snd_hdac_ext_bus_parse_capabilities - parse capablity structure
+ * @sbus: the pointer to extended bus object
+ *
+ * Returns 0 if successful, or a negative error code.
+ */
+int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus)
+{
+	unsigned int cur_cap;
+	unsigned int offset;
+	struct hdac_bus *bus = &sbus->bus;
+
+	offset = snd_hdac_chip_readl(bus, LLCH);
+
+	if (offset < 0)
+		return -EIO;
+
+	sbus->ppcap = false;
+	sbus->mlcap = false;
+	sbus->spbcap = false;
+	sbus->gtscap = false;
+
+	/* Lets walk the linked capabilities list */
+	do {
+		cur_cap = _snd_hdac_chip_read(l, bus, offset);
+
+		if (cur_cap < 0)
+			return -EIO;
+
+		dev_dbg(bus->dev, "Capability version: 0x%x\n",

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 177

Quoted 10 lines
include/sound/hdaudio_ext.h +10 -0
+				((cur_cap & AZX_CAP_HDR_VER_MASK) >> AZX_CAP_HDR_VER_OFF));
+
+		dev_dbg(bus->dev, "HDA capability ID: 0x%x\n",
+				(cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF);
+
+		switch ((cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF) {
+		case AZX_ML_CAP_ID:
+			dev_dbg(bus->dev, "Found ML capability\n");
+			sbus->mlcap = true;
+			sbus->mlcap_addr = bus->remap_addr + offset;

Can be flags (mlcap, gtscap, etc) removed by just NULL-checking the corresponding address?

Quoted 20 lines
include/sound/hdaudio_ext.h +20 -0
+			break;
+
+		case AZX_GTS_CAP_ID:
+			dev_dbg(bus->dev, "Found GTS capability offset=%x\n", offset);
+			sbus->gtscap = true;
+			sbus->gtscap_addr = bus->remap_addr + offset;
+			break;
+
+		case AZX_PP_CAP_ID:
+			/* PP capability found, the Audio DSP is present */
+			dev_dbg(bus->dev, "Found PP capability offset=%x\n", offset);
+			sbus->ppcap = true;
+			sbus->ppcap_addr = bus->remap_addr + offset;
+			break;
+
+		case AZX_SPB_CAP_ID:
+			/* SPIB capability found, handler function */
+			dev_dbg(bus->dev, "Found SPB capability\n");
+			sbus->spbcap = true;
+			sbus->spbcap_addr = bus->remap_addr + offset;

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 207

Quoted 10 lines
include/sound/hdaudio_ext.h +10 -0
+			break;
+
+		default:
+			dev_dbg(bus->dev, "Unknown capability %d\n", cur_cap);
+			break;
+		}
+
+		/* read the offset of next capabiity */
+		offset = cur_cap & AZX_CAP_HDR_NXT_PTR_MASK;
+	} while (offset);

Better to have a loop counter for avoiding the endless loop. You should never trust the hardware.

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 209

Quoted 2 lines
include/sound/hdaudio_ext.h +2 -0
+MODULE_DESCRIPTION("HDA extended core");
+MODULE_LICENSE("GPL v2");

These should have been added in the first patch.

thanks,

Takashi

author
#15 lore raw

Re: [PATCH v6 2/3] ALSA: hdac_ext: add hdac extended controller

Quoted 11 lines · Takashi Iwai

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 221

Quoted 7 lines
include/sound/hdaudio_ext.h +7 -0
+struct hdac_ext_link {
+	struct hdac_bus *bus;
+	int index;
+	void __iomem *ml_addr; /* link output stream reg pointer */
+	u32 lcaps;   /* link capablities */
+	u16 lsdiid;  /* link sdi identifier */
+	char codec[HDA_MAX_CODECS][32]; /* codecs connectes to the link */

Do we need to keep the codec name string? Isn't it just codec address we'd like to check the match...? If so, we may use bitmasks instead, too.

This is not for matching stuff (this is link structure and not codec) So we keep name of codec found on this link. When ASoC BE triggers we use codec name to find the link and use

Quoted 35 lines
Quoted 35 lines
sound/hda/ext/hdac_ext_controller.c new file +35 -0
+/**
+ * snd_hdac_ext_bus_parse_capabilities - parse capablity structure
+ * @sbus: the pointer to extended bus object
+ *
+ * Returns 0 if successful, or a negative error code.
+ */
+int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus)
+{
+	unsigned int cur_cap;
+	unsigned int offset;
+	struct hdac_bus *bus = &sbus->bus;
+
+	offset = snd_hdac_chip_readl(bus, LLCH);
+
+	if (offset < 0)
+		return -EIO;
+
+	sbus->ppcap = false;
+	sbus->mlcap = false;
+	sbus->spbcap = false;
+	sbus->gtscap = false;
+
+	/* Lets walk the linked capabilities list */
+	do {
+		cur_cap = _snd_hdac_chip_read(l, bus, offset);
+
+		if (cur_cap < 0)
+			return -EIO;
+
+		dev_dbg(bus->dev, "Capability version: 0x%x\n",
+				((cur_cap & AZX_CAP_HDR_VER_MASK) >> AZX_CAP_HDR_VER_OFF));
+
+		dev_dbg(bus->dev, "HDA capability ID: 0x%x\n",
+				(cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF);
+
Quoted 8 lines

sound/hda/ext/hdac_ext_controller.c line 68

Quoted 5 lines
sound/hda/ext/hdac_ext_controller.c new file +5 -0
+		switch ((cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF) {
+		case AZX_ML_CAP_ID:
+			dev_dbg(bus->dev, "Found ML capability\n");
+			sbus->mlcap = true;
+			sbus->mlcap_addr = bus->remap_addr + offset;

Can be flags (mlcap, gtscap, etc) removed by just NULL-checking the corresponding address?

Yes, removed these

Quoted 25 lines
Quoted 25 lines
sound/hda/ext/hdac_ext_controller.c new file +25 -0
+			break;
+
+		case AZX_GTS_CAP_ID:
+			dev_dbg(bus->dev, "Found GTS capability offset=%x\n", offset);
+			sbus->gtscap = true;
+			sbus->gtscap_addr = bus->remap_addr + offset;
+			break;
+
+		case AZX_PP_CAP_ID:
+			/* PP capability found, the Audio DSP is present */
+			dev_dbg(bus->dev, "Found PP capability offset=%x\n", offset);
+			sbus->ppcap = true;
+			sbus->ppcap_addr = bus->remap_addr + offset;
+			break;
+
+		case AZX_SPB_CAP_ID:
+			/* SPIB capability found, handler function */
+			dev_dbg(bus->dev, "Found SPB capability\n");
+			sbus->spbcap = true;
+			sbus->spbcap_addr = bus->remap_addr + offset;
+			break;
+
+		default:
+			dev_dbg(bus->dev, "Unknown capability %d\n", cur_cap);
+			break;
Quoted 8 lines

sound/hda/ext/hdac_ext_controller.c line 98

Quoted 5 lines
sound/hda/ext/hdac_ext_controller.c new file +5 -0
+		}
+
+		/* read the offset of next capabiity */
+		offset = cur_cap & AZX_CAP_HDR_NXT_PTR_MASK;
+	} while (offset);

Better to have a loop counter for avoiding the endless loop. You should never trust the hardware.

So we have 4 caps, so am going to put 10 as count for now and bail out on 10th one...

Quoted 5 lines

sound/hda/ext/hdac_ext_controller.c line 295

Quoted 3 lines
sound/hda/ext/hdac_ext_controller.c new file +2 -0
+MODULE_DESCRIPTION("HDA extended core");
+MODULE_LICENSE("GPL v2");

These should have been added in the first patch.

Yes will move

Signature · 1 line
~Vinod
#16 lore raw

Re: [PATCH v6 2/3] ALSA: hdac_ext: add hdac extended controller

At Mon, 8 Jun 2015 21:02:59 +0530,

Quoted 13 lines · Vinod Koul
Quoted 11 lines · Takashi Iwai

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 221

Quoted 7 lines
include/sound/hdaudio_ext.h +7 -0
+struct hdac_ext_link {
+	struct hdac_bus *bus;
+	int index;
+	void __iomem *ml_addr; /* link output stream reg pointer */
+	u32 lcaps;   /* link capablities */
+	u16 lsdiid;  /* link sdi identifier */
+	char codec[HDA_MAX_CODECS][32]; /* codecs connectes to the link */

Do we need to keep the codec name string? Isn't it just codec address we'd like to check the match...? If so, we may use bitmasks instead, too.

Quoted 3 lines

This is not for matching stuff (this is link structure and not codec) So we keep name of codec found on this link. When ASoC BE triggers we use codec name to find the link and use

But each codec name consists of just a few bits. Why do you need to keep each codec name string?

Takashi

author
#17 lore raw

Re: [PATCH v6 2/3] ALSA: hdac_ext: add hdac extended controller

Quoted 15 lines · Takashi Iwai

At Mon, 8 Jun 2015 21:02:59 +0530,

Quoted 13 lines · Vinod Koul
Quoted 11 lines · Takashi Iwai

include/sound/hdaudio_ext.h void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); · line 221

Quoted 7 lines
include/sound/hdaudio_ext.h +7 -0
+struct hdac_ext_link {
+	struct hdac_bus *bus;
+	int index;
+	void __iomem *ml_addr; /* link output stream reg pointer */
+	u32 lcaps;   /* link capablities */
+	u16 lsdiid;  /* link sdi identifier */
+	char codec[HDA_MAX_CODECS][32]; /* codecs connectes to the link */

Do we need to keep the codec name string? Isn't it just codec address we'd like to check the match...? If so, we may use bitmasks instead, too.

Quoted 6 lines
Quoted 3 lines

This is not for matching stuff (this is link structure and not codec) So we keep name of codec found on this link. When ASoC BE triggers we use codec name to find the link and use

But each codec name consists of just a few bits. Why do you need to keep each codec name string?

Yes got your point now, we can indeed generate the codec name and avoid char array

Signature · 1 line
~Vinod
author
#18 lore raw

PATCH v6 3/3 ALSA: hdac_ext: add extended stream capabilities

In reply to Vinod Koul

Now we have the bus and controller code added to find and initialize the extended capabilities. Now we need to use them in stream code to decouple stream, manage links etc

So this patch adds the stream handling code for extended capabilities introduced in preceding patches

---
 include/sound/hdaudio_ext.h     | 118 ++++++++++++
 sound/hda/ext/Makefile          |   2 +-
 sound/hda/ext/hdac_ext_stream.c | 414 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 533 insertions(+), 1 deletion(-)
 create mode 100644 sound/hda/ext/hdac_ext_stream.c
include/sound/hdaudio_ext.h +118 -0
index b17d7f91f6ac..05982dc7e3cc 100644
@@ -212,6 +212,124 @@ enum hdac_ext_stream_type {
 	HDAC_EXT_STREAM_TYPE_LINK
 };
 
+/**
+ * hdac_ext_stream: HDAC extended stream for extended HDA caps
+ *
+ * @hstream: hdac_stream
+ * @pphc_addr: processing pipe host stream pointer
+ * @pplc_addr: processing pipe link stream pointer
+ * @decoupled: stream host and link is decoupled
+ * @link_locked: link is locked
+ * @link_prepared: link is prepared
+ * link_substream: link substream
+ */
+struct hdac_ext_stream {
+	struct hdac_stream hstream;
+
+	void __iomem *pphc_addr;
+	void __iomem *pplc_addr;
+
+	bool decoupled:1;
+	bool link_locked:1;
+	bool link_prepared;
+
+	struct snd_pcm_substream *link_substream;
+};
+
+#define hdac_stream(s)		(&(s)->hstream)
+#define stream_to_hdac_ext_stream(s) \
+	container_of(s, struct hdac_ext_stream, hstream)
+
+void snd_hdac_ext_stream_init(struct hdac_ext_bus *bus,
+				struct hdac_ext_stream *stream, int idx,
+				int direction, int tag);
+struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_ext_bus *bus,
+					   struct snd_pcm_substream *substream,
+					   int type);
+void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type);
+void snd_hdac_ext_stream_decouple(struct hdac_ext_bus *bus,
+				struct hdac_ext_stream *azx_dev, bool decouple);
+void snd_hdac_ext_stop_streams(struct hdac_ext_bus *sbus);
+
+/*
+ * macros for host stream register read/write
+ */
+#define _snd_hdac_ext_host_stream_write(type, dev, reg, value)	\
+	((dev)->hstream.bus->io_ops->reg_write ## type(value,	\
+	(dev)->pphc_addr + (reg)))
+#define _snd_hdac_ext_host_stream_read(type, dev, reg)		\
+	((dev)->hstream.bus->io_ops->reg_read ## type(		\
+	(dev)->pphc_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_host_stream_writel(dev, reg, value) \
+	_snd_hdac_ext_host_stream_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_host_stream_writew(dev, reg, value) \
+	_snd_hdac_ext_host_stream_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_host_stream_writeb(dev, reg, value) \
+	_snd_hdac_ext_host_stream_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_host_stream_readl(dev, reg) \
+	_snd_hdac_ext_host_stream_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_host_stream_readw(dev, reg) \
+	_snd_hdac_ext_host_stream_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_host_stream_readb(dev, reg) \
+	_snd_hdac_ext_host_stream_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_host_stream_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_host_stream_writel(dev, reg, \
+			       (snd_hdac_ext_host_stream_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_host_stream_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_host_stream_writew(dev, reg, \
+			       (snd_hdac_ext_host_stream_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_host_stream_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_host_stream_writeb(dev, reg, \
+			       (snd_hdac_ext_host_stream_readb(dev, reg) & \
+				~(mask)) | (val))
+
+void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hstream);
+void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hstream);
+void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hstream);
+int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *stream, int fmt);
+
+/*
+ * macros for link stream register read/write
+ */
+#define _snd_hdac_ext_link_stream_write(type, dev, reg, value)	\
+	((dev)->hstream.bus->io_ops->reg_write ## type(value,	\
+	(dev)->pplc_addr + (reg)))
+#define _snd_hdac_ext_link_stream_read(type, dev, reg)		\
+	((dev)->hstream.bus->io_ops->reg_read ## type((dev)->pplc_addr + (reg)))
+
+/* read/write a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_link_stream_writel(dev, reg, value) \
+	_snd_hdac_ext_link_stream_write(l, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_link_stream_writew(dev, reg, value) \
+	_snd_hdac_ext_link_stream_write(w, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_link_stream_writeb(dev, reg, value) \
+	_snd_hdac_ext_link_stream_write(b, dev, AZX_REG_ ## reg, value)
+#define snd_hdac_ext_link_stream_readl(dev, reg) \
+	_snd_hdac_ext_link_stream_read(l, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_link_stream_readw(dev, reg) \
+	_snd_hdac_ext_link_stream_read(w, dev, AZX_REG_ ## reg)
+#define snd_hdac_ext_link_stream_readb(dev, reg) \
+	_snd_hdac_ext_link_stream_read(b, dev, AZX_REG_ ## reg)
+
+/* update a register, pass without AZX_REG_ prefix */
+#define snd_hdac_ext_link_stream_updatel(dev, reg, mask, val) \
+	snd_hdac_ext_link_stream_writel(dev, reg, \
+			       (snd_hdac_ext_link_stream_readl(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_link_stream_updatew(dev, reg, mask, val) \
+	snd_hdac_ext_link_stream_writew(dev, reg, \
+			       (snd_hdac_ext_link_stream_readw(dev, reg) & \
+				~(mask)) | (val))
+#define snd_hdac_ext_link_stream_updateb(dev, reg, mask, val) \
+	snd_hdac_ext_link_stream_writeb(dev, reg, \
+			       (snd_hdac_ext_link_stream_readb(dev, reg) & \
+				~(mask)) | (val))
 struct hdac_ext_link {
 	struct hdac_bus *bus;
 	int index;
sound/hda/ext/Makefile +1 -1
index 934b7bf5d87f..9b6f641c7777 100644
@@ -1,3 +1,3 @@
-snd-hda-ext-core-objs := hdac_ext_bus.o hdac_ext_controller.o
+snd-hda-ext-core-objs := hdac_ext_bus.o hdac_ext_controller.o hdac_ext_stream.o
 
 obj-$(CONFIG_SND_HDA_EXT_CORE) += snd-hda-ext-core.o
sound/hda/ext/hdac_ext_stream.c new file +414 -0

414 lines not on this page · raw message

Signature · 1 line
1.9.1