Skip to contentSkip to conversation

ALSA: hda: Move chmap helpers to core

PATCH Applied Subhransu S. Prusty 2 participants 9 messages Mar 4, 2016 – Mar 7, 2016 Sound

lore
Share & tools
lore
#0 lore raw

v3 cover ALSA: hda: Move chmap helpers to core

The HDMI channel map helper APIs and control registration can be reused by ASoC skylake HDMI drivers.

A common chmap object is created, channel map control callback handlers, helper APIs and data structures are moved to the core. Driver object store an instance of this chmap object to register chmap controls and program channel allocation for HDMI infoframe. Driver registers ops for specific operations.

changes in v3:
- Namespace managed as per hda frmwrk requirement
- Address review comments in v2

Subhransu S. Prusty (7):
ALSA: hda - Create common chmap object
ALSA: hda - Register chmap obj as priv data instead of codec
ALSA: hda - Use hdac name space for CEA spk alloc structure
ALSA: hda - Add hdmi chmap verb programming ops to chmap object
ALSA: hda - chmap helper args modified to use generic hdac objs.
ALSA: hda - Move chmap support helpers/ops to core
ALSA: hda - Use snd_hdac namespace prefix for chmap exported APIs

 include/sound/hda_chmap.h  |  76 +++++
 sound/hda/Makefile         |   2 +-
 sound/hda/hdmi_chmap.c     | 791 +++++++++++++++++++++++++++++++++++++++++++
 sound/pci/hda/hda_eld.c    |  31 +-
 sound/pci/hda/patch_hdmi.c | 824 +++++----------------------------------------
 5 files changed, 950 insertions(+), 774 deletions(-)
 create mode 100644 include/sound/hda_chmap.h
 create mode 100644 sound/hda/hdmi_chmap.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/7 ALSA: hda - Create common chmap object

chmap object represents multichannel capability and contains chmap ops. Legacy driver is updated to use this.

With next set of patches chmap object is moved to common to be reused by other drivers (ex: skylake ASoC hdmi driver).

---
 include/sound/hda_chmap.h  | 41 +++++++++++++++++++++++
 sound/pci/hda/patch_hdmi.c | 81 +++++++++++++++++++++++-----------------------
 2 files changed, 81 insertions(+), 41 deletions(-)
 create mode 100644 include/sound/hda_chmap.h
include/sound/hda_chmap.h new file +41 -0
new file mode 100644
index 0000000..9ab20f0
@@ -0,0 +1,41 @@
+/*
+ * For multichannel support
+ */
+
+#ifndef __SOUND_HDA_CHMAP_H
+#define __SOUND_HDA_CHMAP_H
+
+#include <sound/hdaudio.h>
+
+struct cea_channel_speaker_allocation {
+	int ca_index;
+	int speakers[8];
+
+	/* derived values, just for convenience */
+	int channels;
+	int spk_mask;
+};
+struct hdac_chmap;
+
+struct hdac_chmap_ops {
+	/*
+	 * Helpers for producing the channel map TLVs. These can be overridden
+	 * for devices that have non-standard mapping requirements.
+	 */
+	int (*chmap_cea_alloc_validate_get_type)(struct hdac_chmap *chmap,
+		struct cea_channel_speaker_allocation *cap, int channels);
+	void (*cea_alloc_to_tlv_chmap)
+		(struct cea_channel_speaker_allocation *cap,
+		unsigned int *chmap, int channels);
+
+	/* check that the user-given chmap is supported */
+	int (*chmap_validate)(int ca, int channels, unsigned char *chmap);
+};
+
+struct hdac_chmap {
+	unsigned int channels_max; /* max over all cvts */
+	struct hdac_chmap_ops ops;
+	struct hdac_device *hdac;
+};
+
+#endif /* __SOUND_HDA_CHMAP_H */
sound/pci/hda/patch_hdmi.c +40 -41

223 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/7 ALSA: hda - Register chmap obj as priv data instead of codec

In reply to Subhransu S. Prusty

With this chmap object is added as private data and new ops are added to access driver specific chmap.

---
 include/sound/hda_chmap.h  |  6 +++
 sound/pci/hda/patch_hdmi.c | 93 +++++++++++++++++++++++++++++-----------------
 2 files changed, 65 insertions(+), 34 deletions(-)
include/sound/hda_chmap.h +6 -0
index 9ab20f0..713b2452 100644
@@ -30,6 +30,12 @@ struct hdac_chmap_ops {
 
 	/* check that the user-given chmap is supported */
 	int (*chmap_validate)(int ca, int channels, unsigned char *chmap);
+
+	void (*get_chmap)(struct hdac_device *hdac, int pcm_idx,
+					unsigned char *chmap);
+	void (*set_chmap)(struct hdac_device *hdac, int pcm_idx,
+			unsigned char *chmap, int prepared);
+	bool (*is_pcm_attached)(struct hdac_device *hdac, int pcm_idx);
 };
 
 struct hdac_chmap {
sound/pci/hda/patch_hdmi.c +59 -34

165 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH v3 3/7 ALSA: hda - Use hdac name space for CEA spk alloc structure

In reply to Subhransu S. Prusty
---
 include/sound/hda_chmap.h  |  6 +++---
 sound/pci/hda/patch_hdmi.c | 26 ++++++++++++++------------
 2 files changed, 17 insertions(+), 15 deletions(-)
include/sound/hda_chmap.h +3 -3
index 713b2452..d3f80e7 100644
@@ -7,7 +7,7 @@
 
 #include <sound/hdaudio.h>
 
-struct cea_channel_speaker_allocation {
+struct hdac_cea_channel_speaker_allocation {
 	int ca_index;
 	int speakers[8];
 
@@ -23,9 +23,9 @@ struct hdac_chmap_ops {
 	 * for devices that have non-standard mapping requirements.
 	 */
 	int (*chmap_cea_alloc_validate_get_type)(struct hdac_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap, int channels);
+		struct hdac_cea_channel_speaker_allocation *cap, int channels);
 	void (*cea_alloc_to_tlv_chmap)
-		(struct cea_channel_speaker_allocation *cap,
+		(struct hdac_cea_channel_speaker_allocation *cap,
 		unsigned int *chmap, int channels);
 
 	/* check that the user-given chmap is supported */
sound/pci/hda/patch_hdmi.c +14 -12
index 04333ec..d73f54e 100644
@@ -297,7 +297,7 @@ static int hdmi_channel_mapping[0x32][8] = {
  * The preceding ones have better chances to be selected by
  * hdmi_channel_allocation().
  */
-static struct cea_channel_speaker_allocation channel_allocations[] = {
+static struct hdac_cea_channel_speaker_allocation channel_allocations[] = {
 /*			  channel:   7     6    5    4    3     2    1    0  */
 { .ca_index = 0x00,  .speakers = {   0,    0,   0,   0,   0,    0,  FR,  FL } },
 				 /* 2.1 */
@@ -683,7 +683,7 @@ static inline void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
 static void init_channel_allocations(void)
 {
 	int i, j;
-	struct cea_channel_speaker_allocation *p;
+	struct hdac_cea_channel_speaker_allocation *p;
 
 	for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
 		p = channel_allocations + i;
@@ -791,7 +791,7 @@ static void hdmi_std_setup_channel_mapping(struct hda_codec *codec,
 				       int ca)
 {
 	struct hdmi_spec *spec = codec->spec;
-	struct cea_channel_speaker_allocation *ch_alloc;
+	struct hdac_cea_channel_speaker_allocation *ch_alloc;
 	int i;
 	int err;
 	int order;
@@ -2358,7 +2358,7 @@ static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol,
 }
 
 static int hdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap, int channels)
+		struct hdac_cea_channel_speaker_allocation *cap, int channels)
 {
 	/* If the speaker allocation matches the channel count, it is OK.*/
 	if (cap->channels != channels)
@@ -2368,8 +2368,9 @@ static int hdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
 	return SNDRV_CTL_TLVT_CHMAP_VAR;
 }
 
-static void hdmi_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap,
-					unsigned int *chmap, int channels)
+static void hdmi_cea_alloc_to_tlv_chmap(
+		struct hdac_cea_channel_speaker_allocation *cap,
+		unsigned int *chmap, int channels)
 {
 	int count = 0;
 	int c;
@@ -2439,7 +2440,7 @@ static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
 	dst = tlv + 2;
 	for (chs = 2; chs <= chmap->channels_max; chs++) {
 		int i;
-		struct cea_channel_speaker_allocation *cap;
+		struct hdac_cea_channel_speaker_allocation *cap;
 		cap = channel_allocations;
 		for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) {
 			int chs_bytes = chs * 4;
@@ -3519,7 +3520,7 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
  * - 0x10de0040
  */
 static int nvhdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap, int channels)
+		struct hdac_cea_channel_speaker_allocation *cap, int channels)
 {
 	if (cap->ca_index == 0x00 && channels == 2)
 		return SNDRV_CTL_TLVT_CHMAP_FIXED;
@@ -3800,7 +3801,7 @@ static int atihdmi_paired_swap_fc_lfe(int pos)
 
 static int atihdmi_paired_chmap_validate(int ca, int chs, unsigned char *map)
 {
-	struct cea_channel_speaker_allocation *cap;
+	struct hdac_cea_channel_speaker_allocation *cap;
 	int i, j;
 
 	/* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */
@@ -3911,7 +3912,7 @@ static int atihdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_n
 
 static int atihdmi_paired_chmap_cea_alloc_validate_get_type(
 		struct hdac_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap,
+		struct hdac_cea_channel_speaker_allocation *cap,
 		int channels)
 {
 	int c;
@@ -3939,8 +3940,9 @@ static int atihdmi_paired_chmap_cea_alloc_validate_get_type(
 	return SNDRV_CTL_TLVT_CHMAP_PAIRED;
 }
 
-static void atihdmi_paired_cea_alloc_to_tlv_chmap(struct cea_channel_speaker_allocation *cap,
-						  unsigned int *chmap, int channels)
+static void atihdmi_paired_cea_alloc_to_tlv_chmap(
+		struct hdac_cea_channel_speaker_allocation *cap,
+		unsigned int *chmap, int channels)
 {
 	/* produce paired maps for pre-rev3 ATI/AMD codecs */
 	int count = 0;
Signature · 1 line
1.9.1
#4 lore raw

PATCH v3 4/7 ALSA: hda - Add hdmi chmap verb programming ops to chmap object

In reply to Subhransu S. Prusty

Add slot and channel count programming to hdmi_chmap object and move the chmap_ops to core. Use register_chmap_ops API to register for default ops. Override specific chmap ops in the driver.

---
 include/sound/hda_chmap.h  | 10 ++++++
 sound/hda/Makefile         |  2 +-
 sound/hda/hdmi_chmap.c     | 49 ++++++++++++++++++++++++++
 sound/pci/hda/patch_hdmi.c | 87 +++++++++++++++-------------------------------
 4 files changed, 88 insertions(+), 60 deletions(-)
 create mode 100644 sound/hda/hdmi_chmap.c
include/sound/hda_chmap.h +10 -0
index d3f80e7..7afffb9 100644
@@ -36,6 +36,14 @@ struct hdac_chmap_ops {
 	void (*set_chmap)(struct hdac_device *hdac, int pcm_idx,
 			unsigned char *chmap, int prepared);
 	bool (*is_pcm_attached)(struct hdac_device *hdac, int pcm_idx);
+
+	/* get and set channel assigned to each HDMI ASP (audio sample packet) slot */
+	int (*pin_get_slot_channel)(struct hdac_device *codec,
+			hda_nid_t pin_nid, int asp_slot);
+	int (*pin_set_slot_channel)(struct hdac_device *codec,
+			hda_nid_t pin_nid, int asp_slot, int channel);
+	void (*set_channel_count)(struct hdac_device *codec,
+				hda_nid_t cvt_nid, int chs);
 };
 
 struct hdac_chmap {
@@ -44,4 +52,6 @@ struct hdac_chmap {
 	struct hdac_device *hdac;
 };
 
+void snd_hdac_register_chmap_ops(struct hdac_device *hdac,
+				struct hdac_chmap *chmap);
 #endif /* __SOUND_HDA_CHMAP_H */
sound/hda/Makefile +1 -1
index 7e999c9..3b9bede 100644
@@ -1,5 +1,5 @@
 snd-hda-core-objs := hda_bus_type.o hdac_bus.o hdac_device.o hdac_sysfs.o \
-	hdac_regmap.o hdac_controller.o hdac_stream.o array.o
+	hdac_regmap.o hdac_controller.o hdac_stream.o array.o hdmi_chmap.o
 
 snd-hda-core-objs += trace.o
 CFLAGS_trace.o := -I$(src)
sound/hda/hdmi_chmap.c new file +49 -0

49 lines not on this page · raw message

sound/pci/hda/patch_hdmi.c +28 -59

178 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

PATCH v3 5/7 ALSA: hda - chmap helper args modified to use generic hdac objs.

In reply to Subhransu S. Prusty

Chmap helper arguments are modified to use either hdac_device object or hdac_chmap object instead of codec specific object. With this moving these APIs to core will be easier.

Helper added to access a specific channel_allocation object instead of directly accessing.

---
 include/sound/hda_chmap.h  |  10 +++--
 sound/pci/hda/patch_hdmi.c | 108 ++++++++++++++++++++++++++++-----------------
 2 files changed, 74 insertions(+), 44 deletions(-)
include/sound/hda_chmap.h +7 -3
index 7afffb9..f7fd752 100644
@@ -7,6 +7,9 @@
 
 #include <sound/hdaudio.h>
 
+
+#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
+
 struct hdac_cea_channel_speaker_allocation {
 	int ca_index;
 	int speakers[8];
@@ -24,12 +27,13 @@ struct hdac_chmap_ops {
 	 */
 	int (*chmap_cea_alloc_validate_get_type)(struct hdac_chmap *chmap,
 		struct hdac_cea_channel_speaker_allocation *cap, int channels);
-	void (*cea_alloc_to_tlv_chmap)
-		(struct hdac_cea_channel_speaker_allocation *cap,
+	void (*cea_alloc_to_tlv_chmap)(struct hdac_chmap *hchmap,
+		struct hdac_cea_channel_speaker_allocation *cap,
 		unsigned int *chmap, int channels);
 
 	/* check that the user-given chmap is supported */
-	int (*chmap_validate)(int ca, int channels, unsigned char *chmap);
+	int (*chmap_validate)(struct hdac_chmap *hchmap, int ca,
+			int channels, unsigned char *chmap);
 
 	void (*get_chmap)(struct hdac_device *hdac, int pcm_idx,
 					unsigned char *chmap);
sound/pci/hda/patch_hdmi.c +67 -41

253 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

PATCH v3 6/7 ALSA: hda - Move chmap support helpers/ops to core

In reply to Subhransu S. Prusty

Chmap helpers, ops, controls are moved to core.

---
 include/sound/hda_chmap.h  |  15 +
 sound/hda/hdmi_chmap.c     | 742 +++++++++++++++++++++++++++++++++++++++++++++
 sound/pci/hda/hda_eld.c    |  27 +-
 sound/pci/hda/patch_hdmi.c | 689 +----------------------------------------
 4 files changed, 759 insertions(+), 714 deletions(-)
include/sound/hda_chmap.h +15 -0
index f7fd752..5a85b31 100644
@@ -5,6 +5,7 @@
 #ifndef __SOUND_HDA_CHMAP_H
 #define __SOUND_HDA_CHMAP_H
 
+#include <sound/pcm.h>
 #include <sound/hdaudio.h>
 
 
@@ -58,4 +59,18 @@ struct hdac_chmap {
 
 void snd_hdac_register_chmap_ops(struct hdac_device *hdac,
 				struct hdac_chmap *chmap);
+int hdmi_channel_allocation(struct hdac_device *hdac, int spk_alloc,
+			int channels, bool chmap_set,
+			bool non_pcm, unsigned char *map);
+int hdmi_get_active_channels(int ca);
+void hdmi_setup_channel_mapping(struct hdac_chmap *chmap,
+		       hda_nid_t pin_nid, bool non_pcm, int ca,
+		       int channels, unsigned char *map,
+		       bool chmap_set);
+void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
+struct hdac_cea_channel_speaker_allocation *hdmi_get_ch_alloc_from_ca(int ca);
+int to_spk_mask(unsigned char c);
+int spk_to_chmap(int spk);
+int snd_hdac_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
+				struct hdac_chmap *chmap);
 #endif /* __SOUND_HDA_CHMAP_H */
sound/hda/hdmi_chmap.c +742 -0

762 lines not on this page · raw message

sound/pci/hda/hda_eld.c +1 -26
index bc2e082..7c6a973 100644
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <sound/core.h>
 #include <asm/unaligned.h>
+#include <sound/hda_chmap.h>
 #include "hda_codec.h"
 #include "hda_local.h"
 
@@ -42,20 +43,6 @@ enum cea_edid_versions {
 	CEA_EDID_VER_RESERVED	= 4,
 };
 
-static const char * const cea_speaker_allocation_names[] = {
-	/*  0 */ "FL/FR",
-	/*  1 */ "LFE",
-	/*  2 */ "FC",
-	/*  3 */ "RL/RR",
-	/*  4 */ "RC",
-	/*  5 */ "FLC/FRC",
-	/*  6 */ "RLC/RRC",
-	/*  7 */ "FLW/FRW",
-	/*  8 */ "FLH/FRH",
-	/*  9 */ "TC",
-	/* 10 */ "FCH",
-};
-
 static const char * const eld_connection_type_names[4] = {
 	"HDMI",
 	"DisplayPort",
@@ -419,18 +406,6 @@ static void hdmi_show_short_audio_desc(struct hda_codec *codec,
 		  a->channels, buf, buf2);
 }
 
-void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen)
-{
-	int i, j;
-
-	for (i = 0, j = 0; i < ARRAY_SIZE(cea_speaker_allocation_names); i++) {
-		if (spk_alloc & (1 << i))
-			j += snprintf(buf + j, buflen - j,  " %s",
-					cea_speaker_allocation_names[i]);
-	}
-	buf[j] = '\0';	/* necessary when j == 0 */
-}
-
 void snd_hdmi_show_eld(struct hda_codec *codec, struct parsed_hdmi_eld *e)
 {
 	int i;
sound/pci/hda/patch_hdmi.c +1 -688

743 lines not on this page · raw message

Signature · 1 line
1.9.1
#7 lore raw

PATCH v3 7/7 ALSA: hda - Use snd_hdac namespace prefix for chmap exported APIs

In reply to Subhransu S. Prusty
---
 include/sound/hda_chmap.h  | 14 +++++++-------
 sound/hda/hdmi_chmap.c     | 38 +++++++++++++++++++-------------------
 sound/pci/hda/hda_eld.c    |  4 ++--
 sound/pci/hda/patch_hdmi.c | 14 +++++++-------
 4 files changed, 35 insertions(+), 35 deletions(-)
include/sound/hda_chmap.h +7 -7
index 5a85b31..e20d219 100644
@@ -59,18 +59,18 @@ struct hdac_chmap {
 
 void snd_hdac_register_chmap_ops(struct hdac_device *hdac,
 				struct hdac_chmap *chmap);
-int hdmi_channel_allocation(struct hdac_device *hdac, int spk_alloc,
+int snd_hdac_channel_allocation(struct hdac_device *hdac, int spk_alloc,
 			int channels, bool chmap_set,
 			bool non_pcm, unsigned char *map);
-int hdmi_get_active_channels(int ca);
-void hdmi_setup_channel_mapping(struct hdac_chmap *chmap,
+int snd_hdac_get_active_channels(int ca);
+void snd_hdac_setup_channel_mapping(struct hdac_chmap *chmap,
 		       hda_nid_t pin_nid, bool non_pcm, int ca,
 		       int channels, unsigned char *map,
 		       bool chmap_set);
-void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
-struct hdac_cea_channel_speaker_allocation *hdmi_get_ch_alloc_from_ca(int ca);
-int to_spk_mask(unsigned char c);
-int spk_to_chmap(int spk);
+void snd_hdac_print_channel_allocation(int spk_alloc, char *buf, int buflen);
+struct hdac_cea_channel_speaker_allocation *snd_hdac_get_ch_alloc_from_ca(int ca);
+int snd_hdac_chmap_to_spk_mask(unsigned char c);
+int snd_hdac_spk_to_chmap(int spk);
 int snd_hdac_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
 				struct hdac_chmap *chmap);
 #endif /* __SOUND_HDA_CHMAP_H */
sound/hda/hdmi_chmap.c +19 -19
index 880666a..d7ec862 100644
@@ -243,7 +243,7 @@ static int get_channel_allocation_order(int ca)
 	return i;
 }
 
-void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen)
+void snd_hdac_print_channel_allocation(int spk_alloc, char *buf, int buflen)
 {
 	int i, j;
 
@@ -254,7 +254,7 @@ void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen)
 	}
 	buf[j] = '\0';	/* necessary when j == 0 */
 }
-EXPORT_SYMBOL_GPL(snd_print_channel_allocation);
+EXPORT_SYMBOL_GPL(snd_hdac_print_channel_allocation);
 
 /*
  * The transformation takes two steps:
@@ -312,7 +312,7 @@ static int hdmi_channel_allocation_spk_alloc_blk(struct hdac_device *codec,
 		}
 	}
 
-	snd_print_channel_allocation(spk_alloc, buf, sizeof(buf));
+	snd_hdac_print_channel_allocation(spk_alloc, buf, sizeof(buf));
 	dev_dbg(&codec->dev, "HDMI: select CA 0x%x for %d-channel allocation: %s\n",
 		    ca, channels, buf);
 
@@ -412,7 +412,7 @@ static struct channel_map_table map_tables[] = {
 };
 
 /* from ALSA API channel position to speaker bit mask */
-int to_spk_mask(unsigned char c)
+int snd_hdac_chmap_to_spk_mask(unsigned char c)
 {
 	struct channel_map_table *t = map_tables;
 
@@ -422,12 +422,12 @@ int to_spk_mask(unsigned char c)
 	}
 	return 0;
 }
-EXPORT_SYMBOL_GPL(to_spk_mask);
+EXPORT_SYMBOL_GPL(snd_hdac_chmap_to_spk_mask);
 
 /* from ALSA API channel position to CEA slot */
 static int to_cea_slot(int ordered_ca, unsigned char pos)
 {
-	int mask = to_spk_mask(pos);
+	int mask = snd_hdac_chmap_to_spk_mask(pos);
 	int i;
 
 	if (mask) {
@@ -441,7 +441,7 @@ static int to_cea_slot(int ordered_ca, unsigned char pos)
 }
 
 /* from speaker bit mask to ALSA API channel position */
-int spk_to_chmap(int spk)
+int snd_hdac_spk_to_chmap(int spk)
 {
 	struct channel_map_table *t = map_tables;
 
@@ -451,14 +451,14 @@ int spk_to_chmap(int spk)
 	}
 	return 0;
 }
-EXPORT_SYMBOL_GPL(spk_to_chmap);
+EXPORT_SYMBOL_GPL(snd_hdac_spk_to_chmap);
 
 /* from CEA slot to ALSA API channel position */
 static int from_cea_slot(int ordered_ca, unsigned char slot)
 {
 	int mask = channel_allocations[ordered_ca].speakers[7 - slot];
 
-	return spk_to_chmap(mask);
+	return snd_hdac_spk_to_chmap(mask);
 }
 
 /* get the CA index corresponding to the given ALSA API channel map */
@@ -467,7 +467,7 @@ static int hdmi_manual_channel_allocation(int chs, unsigned char *map)
 	int i, spks = 0, spk_mask = 0;
 
 	for (i = 0; i < chs; i++) {
-		int mask = to_spk_mask(map[i]);
+		int mask = snd_hdac_chmap_to_spk_mask(map[i]);
 
 		if (mask) {
 			spk_mask |= mask;
@@ -530,7 +530,7 @@ static void hdmi_setup_fake_chmap(unsigned char *map, int ca)
 	}
 }
 
-void hdmi_setup_channel_mapping(struct hdac_chmap *chmap,
+void snd_hdac_setup_channel_mapping(struct hdac_chmap *chmap,
 				       hda_nid_t pin_nid, bool non_pcm, int ca,
 				       int channels, unsigned char *map,
 				       bool chmap_set)
@@ -545,23 +545,23 @@ void hdmi_setup_channel_mapping(struct hdac_chmap *chmap,
 
 	hdmi_debug_channel_mapping(chmap, pin_nid);
 }
-EXPORT_SYMBOL_GPL(hdmi_setup_channel_mapping);
+EXPORT_SYMBOL_GPL(snd_hdac_setup_channel_mapping);
 
-int hdmi_get_active_channels(int ca)
+int snd_hdac_get_active_channels(int ca)
 {
 	int ordered_ca = get_channel_allocation_order(ca);
 
 	return channel_allocations[ordered_ca].channels;
 }
-EXPORT_SYMBOL_GPL(hdmi_get_active_channels);
+EXPORT_SYMBOL_GPL(snd_hdac_get_active_channels);
 
-struct hdac_cea_channel_speaker_allocation *hdmi_get_ch_alloc_from_ca(int ca)
+struct hdac_cea_channel_speaker_allocation *snd_hdac_get_ch_alloc_from_ca(int ca)
 {
 	return &channel_allocations[get_channel_allocation_order(ca)];
 }
-EXPORT_SYMBOL_GPL(hdmi_get_ch_alloc_from_ca);
+EXPORT_SYMBOL_GPL(snd_hdac_get_ch_alloc_from_ca);
 
-int hdmi_channel_allocation(struct hdac_device *hdac, int spk_alloc,
+int snd_hdac_channel_allocation(struct hdac_device *hdac, int spk_alloc,
 		int channels, bool chmap_set, bool non_pcm, unsigned char *map)
 {
 	int ca;
@@ -577,7 +577,7 @@ int hdmi_channel_allocation(struct hdac_device *hdac, int spk_alloc,
 
 	return ca;
 }
-EXPORT_SYMBOL_GPL(hdmi_channel_allocation);
+EXPORT_SYMBOL_GPL(snd_hdac_channel_allocation);
 
 /*
  * ALSA API channel-map control callbacks
@@ -619,7 +619,7 @@ static void hdmi_cea_alloc_to_tlv_chmap(struct hdac_chmap *hchmap,
 		if (!spk)
 			continue;
 
-		chmap[count++] = spk_to_chmap(spk);
+		chmap[count++] = snd_hdac_spk_to_chmap(spk);
 	}
 
 	WARN_ON(count != channels);
sound/pci/hda/hda_eld.c +2 -2
index 7c6a973..ba7fe9b 100644
@@ -416,7 +416,7 @@ void snd_hdmi_show_eld(struct hda_codec *codec, struct parsed_hdmi_eld *e)
 
 	if (e->spk_alloc) {
 		char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
-		snd_print_channel_allocation(e->spk_alloc, buf, sizeof(buf));
+		snd_hdac_print_channel_allocation(e->spk_alloc, buf, sizeof(buf));
 		codec_dbg(codec, "HDMI: available speakers:%s\n", buf);
 	}
 
@@ -491,7 +491,7 @@ void snd_hdmi_print_eld_info(struct hdmi_eld *eld,
 	snd_iprintf(buffer, "support_ai\t\t%d\n", e->support_ai);
 	snd_iprintf(buffer, "audio_sync_delay\t%d\n", e->aud_synch_delay);
 
-	snd_print_channel_allocation(e->spk_alloc, buf, sizeof(buf));
+	snd_hdac_print_channel_allocation(e->spk_alloc, buf, sizeof(buf));
 	snd_iprintf(buffer, "speakers\t\t[0x%x]%s\n", e->spk_alloc, buf);
 
 	snd_iprintf(buffer, "sad_count\t\t%d\n", e->sad_count);
sound/pci/hda/patch_hdmi.c +7 -7
index ecc5abb..f59e87b 100644
@@ -687,11 +687,11 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
 
 	eld = &per_pin->sink_eld;
 
-	ca = hdmi_channel_allocation(&codec->core,
+	ca = snd_hdac_channel_allocation(&codec->core,
 			eld->info.spk_alloc, channels,
 			per_pin->chmap_set, non_pcm, per_pin->chmap);
 
-	active_channels = hdmi_get_active_channels(ca);
+	active_channels = snd_hdac_get_active_channels(ca);
 
 	chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid,
 						active_channels);
@@ -700,7 +700,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
 	 * always configure channel mapping, it may have been changed by the
 	 * user in the meantime
 	 */
-	hdmi_setup_channel_mapping(&spec->chmap,
+	snd_hdac_setup_channel_mapping(&spec->chmap,
 				pin_nid, non_pcm, ca, channels,
 				per_pin->chmap, per_pin->chmap_set);
 
@@ -3110,9 +3110,9 @@ static int atihdmi_paired_chmap_validate(struct hdac_chmap *chmap,
 
 	/* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */
 
-	cap = hdmi_get_ch_alloc_from_ca(ca);
+	cap = snd_hdac_get_ch_alloc_from_ca(ca);
 	for (i = 0; i < chs; ++i) {
-		int mask = to_spk_mask(map[i]);
+		int mask = snd_hdac_chmap_to_spk_mask(map[i]);
 		bool ok = false;
 		bool companion_ok = false;
 
@@ -3128,7 +3128,7 @@ static int atihdmi_paired_chmap_validate(struct hdac_chmap *chmap,
 				if (i % 2 == 0 && i + 1 < chs) {
 					/* even channel, check the odd companion */
 					int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1);
-					int comp_mask_req = to_spk_mask(map[i+1]);
+					int comp_mask_req = snd_hdac_chmap_to_spk_mask(map[i+1]);
 					int comp_mask_act = cap->speakers[comp_chan_idx];
 
 					if (comp_mask_req == comp_mask_act)
@@ -3265,7 +3265,7 @@ static void atihdmi_paired_cea_alloc_to_tlv_chmap(struct hdac_chmap *hchmap,
 			continue;
 		}
 
-		chmap[count++] = spk_to_chmap(spk);
+		chmap[count++] = snd_hdac_spk_to_chmap(spk);
 	}
 
 	WARN_ON(count != channels);
Signature · 1 line
1.9.1
Applied
#8 lore raw
In reply to Subhransu S. Prusty
Quoted 14 lines · Subhransu S. Prusty

The HDMI channel map helper APIs and control registration can be reused by ASoC skylake HDMI drivers.

A common chmap object is created, channel map control callback handlers, helper APIs and data structures are moved to the core. Driver object store an instance of this chmap object to register chmap controls and program channel allocation for HDMI infoframe. Driver registers ops for specific operations.

changes in v3:
- Namespace managed as per hda frmwrk requirement
- Address review comments in v2

Quoted 8 lines

Subhransu S. Prusty (7):
ALSA: hda - Create common chmap object
ALSA: hda - Register chmap obj as priv data instead of codec
ALSA: hda - Use hdac name space for CEA spk alloc structure
ALSA: hda - Add hdmi chmap verb programming ops to chmap object
ALSA: hda - chmap helper args modified to use generic hdac objs.
ALSA: hda - Move chmap support helpers/ops to core
ALSA: hda - Use snd_hdac namespace prefix for chmap exported APIs

Applied all patches. Thanks.

Takashi