Skip to contentSkip to conversation

HDA: add extended HDA

PATCH In review Vinod Koul 2 participants 7 messages Jun 11, 2015 Sound

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

v9 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 v9:
- removed snd_hdac_ext_bus_map_codec_to_link
- updated snd_hdac_ext_bus_get_link per Takahsi comment and drop the array
- add index in bus instance

Changes in v8:
- fixed some dead code 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        | 117 +++++++++++
 sound/hda/ext/hdac_ext_controller.c | 270 ++++++++++++++++++++++++
 sound/hda/ext/hdac_ext_stream.c     | 402 ++++++++++++++++++++++++++++++++++++
 7 files changed, 928 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 v9 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  |  46 +++++++++++++++++
 sound/hda/Kconfig            |   4 ++
 sound/hda/Makefile           |   3 ++
 sound/hda/ext/Makefile       |   3 ++
 sound/hda/ext/hdac_ext_bus.c | 117 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 173 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 +46 -0
new file mode 100644
index 000000000000..083f68a980d2
@@ -0,0 +1,46 @@
+#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;
+	int idx;
+
+	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 +117 -0

117 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v9 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         |  35 +++++
 sound/hda/ext/Makefile              |   2 +-
 sound/hda/ext/hdac_ext_controller.c | 270 ++++++++++++++++++++++++++++++++++++
 3 files changed, 306 insertions(+), 1 deletion(-)
 create mode 100644 sound/hda/ext/hdac_ext_controller.c
include/sound/hdaudio_ext.h +35 -0
index 083f68a980d2..89683a8fff5b 100644
@@ -43,4 +43,39 @@ 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 */
+	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 +270 -0

270 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

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

At Thu, 11 Jun 2015 14:11:48 +0530,

Quoted 6 lines · Vinod Koul
sound/hda/ext/hdac_ext_controller.c new file +5 -0
+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;

sound/hda/ext/hdac_ext_controller.c line 215

Quoted 10 lines
sound/hda/ext/hdac_ext_controller.c new file +10 -0
+	int bus_idx, addr;
+
+	if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
+		return NULL;
+	if (ebus->idx != bus_idx)
+		return NULL;
+
+	list_for_each_entry(hlink, &ebus->hlink_list, list) {
+		for (i = 0; i < HDA_MAX_CODECS; i++) {
+			if (hlink->lsdiid && (0x1 << addr))

This should be single '&'.

But I can correct it by myself at applying, so no need for resend if no other problem is seen.

Takashi

author
#4 lore raw

PATCH v9 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 89683a8fff5b..0044caa19155 100644
@@ -57,6 +57,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
#5 lore raw
In reply to Vinod Koul

At Thu, 11 Jun 2015 14:11:46 +0530,

Quoted 28 lines · Vinod Koul

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 v9:
- removed snd_hdac_ext_bus_map_codec_to_link
- updated snd_hdac_ext_bus_get_link per Takahsi comment and drop the array
- add index in bus instance

Changes in v8:
- fixed some dead code 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

Quoted 4 lines

Jeeja KP (3):
ALSA: hdac_ext: add extended HDA bus
ALSA: hdac_ext: add hdac extended controller
ALSA: hdac_ext: add extended stream capabilities

I took all three patches (with a fix I mentioned in the early post) to for-next branch now.

thanks,

Takashi

Quoted 18 lines
 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        | 117 +++++++++++
 sound/hda/ext/hdac_ext_controller.c | 270 ++++++++++++++++++++++++
 sound/hda/ext/hdac_ext_stream.c     | 402 ++++++++++++++++++++++++++++++++++++
 7 files changed, 928 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
#6 lore raw
Quoted 2 lines · Takashi Iwai

I took all three patches (with a fix I mentioned in the early post) to for-next branch now.

Thank You Takashi,

While generating the patch series, I did the removal of snd_hdac_ext_bus_map_codec_to_link last and missed removing the function declartion. Sorry about that. I have sent you a patch for this, please apply that or fold it, either way is fine

Thanks

Signature · 1 line
~Vinod