Skip to contentSkip to conversation

HDA: add extended HDA

PATCH Superseded Vinod Koul 2 participants 7 messages Jun 10, 2015 – Jun 11, 2015 Sound

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

v8 cover 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

Changes in v8:
- fixed some dead codec crept in
- checkpatch cleanup

Changes in v7:
- Feedback from Takashi
- removed the macros for register read/writes
- add new macros for reg update
- fix bus pointer macro
- header cleanup on c/h files
- new device name ehdaudioiDn
- removed flags for ext caps, use pointer only
- moved module info to patch 1
- sparse check on series
- remove codec name in link

Jeeja KP (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         | 129 ++++++++++++
 sound/hda/Kconfig                   |   4 +
 sound/hda/Makefile                  |   3 +
 sound/hda/ext/Makefile              |   3 +
 sound/hda/ext/hdac_ext_bus.c        | 116 +++++++++++
 sound/hda/ext/hdac_ext_controller.c | 290 ++++++++++++++++++++++++++
 sound/hda/ext/hdac_ext_stream.c     | 402 ++++++++++++++++++++++++++++++++++++
 7 files changed, 947 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 v8 1/3 ALSA: hdac_ext: add extended HDA bus

From: Jeeja KP <[email protected]>

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  |  45 +++++++++++++++++
 sound/hda/Kconfig            |   4 ++
 sound/hda/Makefile           |   3 ++
 sound/hda/ext/Makefile       |   3 ++
 sound/hda/ext/hdac_ext_bus.c | 116 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 171 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 +45 -0
new file mode 100644
index 000000000000..5b67b367367d
@@ -0,0 +1,45 @@
+#ifndef __SOUND_HDAUDIO_EXT_H
+#define __SOUND_HDAUDIO_EXT_H
+
+#include <sound/hdaudio.h>
+
+/**
+ * hdac_ext_bus: HDAC extended bus for extended HDA caps
+ *
+ * @bus: hdac bus
+ * @num_streams: streams supported
+ * @ppcap: pp capabilities pointer
+ * @spbcap: SPIB capabilities pointer
+ * @mlcap: MultiLink capabilities pointer
+ * @gtscap: gts capabilities pointer
+ * @hlink_list: link list of HDA links
+ */
+struct hdac_ext_bus {
+	struct hdac_bus bus;
+	int num_streams;
+
+	void __iomem *ppcap;
+	void __iomem *spbcap;
+	void __iomem *mlcap;
+	void __iomem *gtscap;
+
+	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 ebus_to_hbus(ebus)	(&(ebus)->bus)
+#define hbus_to_ebus(_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);
+
+#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 +116 -0

116 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#2 lore raw

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

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

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         |  36 +++++
 sound/hda/ext/Makefile              |   2 +-
 sound/hda/ext/hdac_ext_controller.c | 290 ++++++++++++++++++++++++++++++++++++
 3 files changed, 327 insertions(+), 1 deletion(-)
 create mode 100644 sound/hda/ext/hdac_ext_controller.c
include/sound/hdaudio_ext.h +36 -0
index 5b67b367367d..5031df7cfe60 100644
@@ -42,4 +42,40 @@ 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);
 
+void snd_hdac_ext_stream_spbcap_enable(struct hdac_ext_bus *chip,
+				 bool enable, int index);
+
+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);
+
+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 */
+	u16 codec[HDA_MAX_CODECS]; /* 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);
+
+/* update register macro */
+#define snd_hdac_updatel(addr, reg, mask, val)		\
+	writel(((readl(addr + reg) & ~(mask)) | (val)), \
+		addr + reg)
+
 #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 +290 -0

290 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

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

At Wed, 10 Jun 2015 18:36:01 +0530,

Quoted 8 lines · Vinod Koul
sound/hda/ext/hdac_ext_controller.c new file +7 -0
+/**
+ * snd_hdac_ext_bus_get_link_index - get link based on codec name
+ * @ebus: HD-audio extended core bus
+ * @codec_name: codec name
+ */
+struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *ebus,
+						 const char *codec_name)

sound/hda/ext/hdac_ext_controller.c line 237

Quoted 10 lines
sound/hda/ext/hdac_ext_controller.c new file +10 -0
+{
+	int i;
+	struct hdac_ext_link *hlink = NULL;
+	char name[32];
+
+	list_for_each_entry(hlink, &ebus->hlink_list, list) {
+		for (i = 0; i < HDA_MAX_CODECS; i++) {
+			snprintf(name, sizeof(name), "codec#%03x", hlink->codec[i]);
+			if (!strncmp(name, codec_name, strlen(codec_name)))
+				return hlink;

Is this name supposed to be identical with the string the patch 1 sets? If so, this looks incompatible.

Also, it'd be easier to parse the string only once like:

	int bus_idx, addr;

	if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
		return NULL;
	if (ebus->index != bus_idx)
		return NULL;
	list_for_each_entry(hlink, &ebus->hlink_list, list)
		if (hlink->lsdiid && (0x1 << addr))
			return hlink;

	return NULL;

Takashi

author
#4 lore raw

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

Quoted 15 lines · Takashi Iwai

At Wed, 10 Jun 2015 18:36:01 +0530,

Quoted 13 lines · Vinod Koul
sound/hda/ext/hdac_ext_controller.c new file +12 -0
+/**
+ * snd_hdac_ext_bus_get_link_index - get link based on codec name
+ * @ebus: HD-audio extended core bus
+ * @codec_name: codec name
+ */
+struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *ebus,
+						 const char *codec_name)
+{
+	int i;
+	struct hdac_ext_link *hlink = NULL;
+	char name[32];
+
Quoted 8 lines

sound/hda/ext/hdac_ext_controller.c line 237

Quoted 5 lines
sound/hda/ext/hdac_ext_controller.c new file +5 -0
+	list_for_each_entry(hlink, &ebus->hlink_list, list) {
+		for (i = 0; i < HDA_MAX_CODECS; i++) {
+			snprintf(name, sizeof(name), "codec#%03x", hlink->codec[i]);
+			if (!strncmp(name, codec_name, strlen(codec_name)))
+				return hlink;

Is this name supposed to be identical with the string the patch 1 sets? If so, this looks incompatible.

Yes my miss :(

This also means that I would be required to save the idx number, so I am thinking of returning the idx value in snd_hdac_ext_bus_device_init() and then pass on snd_hdac_ext_bus_map_codec_to_link() API which can save this in the array and then use idx here as well and use I like below so will add this

Quoted 14 lines

Also, it'd be easier to parse the string only once like:

	int bus_idx, addr;

	if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
		return NULL;
	if (ebus->index != bus_idx)
		return NULL;
	list_for_each_entry(hlink, &ebus->hlink_list, list)
		if (hlink->lsdiid && (0x1 << addr))
			return hlink;

	return NULL;

Thanks

Signature · 1 line
~Vinod
author
#5 lore raw

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

Quoted 24 lines · Vinod Koul
Quoted 15 lines · Takashi Iwai

At Wed, 10 Jun 2015 18:36:01 +0530,

Quoted 13 lines · Vinod Koul
sound/hda/ext/hdac_ext_controller.c new file +12 -0
+/**
+ * snd_hdac_ext_bus_get_link_index - get link based on codec name
+ * @ebus: HD-audio extended core bus
+ * @codec_name: codec name
+ */
+struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *ebus,
+						 const char *codec_name)
+{
+	int i;
+	struct hdac_ext_link *hlink = NULL;
+	char name[32];
+
Quoted 8 lines

sound/hda/ext/hdac_ext_controller.c line 237

Quoted 5 lines
sound/hda/ext/hdac_ext_controller.c new file +5 -0
+	list_for_each_entry(hlink, &ebus->hlink_list, list) {
+		for (i = 0; i < HDA_MAX_CODECS; i++) {
+			snprintf(name, sizeof(name), "codec#%03x", hlink->codec[i]);
+			if (!strncmp(name, codec_name, strlen(codec_name)))
+				return hlink;

Is this name supposed to be identical with the string the patch 1 sets? If so, this looks incompatible.

Quoted 7 lines

Yes my miss :(

This also means that I would be required to save the idx number, so I am thinking of returning the idx value in snd_hdac_ext_bus_device_init() and then pass on snd_hdac_ext_bus_map_codec_to_link() API which can save this in the array and then use idx here as well and use I like below so will add this

and i overlooked ebus->index below, so yes this makes much better so saved it there and also removed snd_hdac_ext_bus_map_codec_to_link() we dont need that and array anymore :)

Signature · 1 line
~Vinod
Quoted 21 lines
Quoted 4 lines

Also, it'd be easier to parse the string only once like:

Quoted 11 lines
	int bus_idx, addr;

	if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
		return NULL;
	if (ebus->index != bus_idx)
		return NULL;
	list_for_each_entry(hlink, &ebus->hlink_list, list)
		if (hlink->lsdiid && (0x1 << addr))
			return hlink;

	return NULL;

Thanks

Signature · 1 line
~Vinod
author
#6 lore raw

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

In reply to Vinod Koul

From: Jeeja KP <[email protected]>

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     |  48 +++++
 sound/hda/ext/Makefile          |   2 +-
 sound/hda/ext/hdac_ext_stream.c | 402 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 451 insertions(+), 1 deletion(-)
 create mode 100644 sound/hda/ext/hdac_ext_stream.c
include/sound/hdaudio_ext.h +48 -0
index 5031df7cfe60..b5341ca50e4e 100644
@@ -56,6 +56,50 @@ 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);
+
+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);
+
 struct hdac_ext_link {
 	struct hdac_bus *bus;
 	int index;
@@ -78,4 +122,8 @@ void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
 	writel(((readl(addr + reg) & ~(mask)) | (val)), \
 		addr + reg)
 
+#define snd_hdac_updatew(addr, reg, mask, val)		\
+	writew(((readw(addr + reg) & ~(mask)) | (val)), \
+		addr + reg)
+
 #endif /* __SOUND_HDAUDIO_EXT_H */
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 +402 -0

402 lines not on this page · raw message

Signature · 1 line
1.9.1