Skip to contentSkip to conversation

ALSA: hda: Move chmap helpers to core

PATCH Superseded Subhransu S. Prusty 3 participants 15 messages Mar 2, 2016 – Mar 3, 2016 Sound

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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 v2:
- Splitted patches for easier review
- Access most of chmap helpers through ops, thus reducing number of exported APIs for chmap support

Subhransu S. Prusty (7):
ALSA: hda - Create common chmap object
ALSA: hda - Register chmap obj as priv data instead of codec
ALSA: hda - Use hdmi name space for CEA spk alloc structure
ALSA: hda - Add hdmi chmap verb programming ops to chmap object
ALSA: hda - Use ops instead of directly accessing chmap helpers
ALSA: hda - Move chmap support helpers/ops to core
ALSA: hda - Use snd_hdmi namespace prefix for printing ch alloc api

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

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

chmap object represents multichannel capablity and contains chmap ops. Legacy driver is udpated 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/hdmi_chmap.h | 41 +++++++++++++++++++++++
 sound/pci/hda/patch_hdmi.c | 81 +++++++++++++++++++++++-----------------------
 2 files changed, 81 insertions(+), 41 deletions(-)
 create mode 100644 include/sound/hdmi_chmap.h
include/sound/hdmi_chmap.h new file +41 -0
new file mode 100644
index 0000000..32087f1
@@ -0,0 +1,41 @@
+/*
+ * For multichannel support
+ */
+
+#ifndef __SOUND_HDMI_CHMAP_H
+#define __SOUND_HDMI_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 hdmi_chmap;
+
+struct hdmi_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 hdmi_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 hdmi_chmap {
+	unsigned int channels_max; /* max over all cvts */
+	struct hdmi_chmap_ops ops;
+	struct hdac_device *hdac;
+};
+
+#endif /* __SOUND_HDMI_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 v2 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/hdmi_chmap.h |   6 +++
 sound/pci/hda/patch_hdmi.c | 100 ++++++++++++++++++++++++++++++---------------
 2 files changed, 72 insertions(+), 34 deletions(-)
include/sound/hdmi_chmap.h +6 -0
index 32087f1..c7702ef9 100644
@@ -30,6 +30,12 @@ struct hdmi_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_monitor_connected)(struct hdac_device *hdac, int pcm_idx);
 };
 
 struct hdmi_chmap {
sound/pci/hda/patch_hdmi.c +66 -34

184 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH v2 2/7] ALSA: hda - Register chmap obj as priv data instead of codec

Quoted 16 lines · Subhransu S. Prusty

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

---
 include/sound/hdmi_chmap.h |   6 +++
 sound/pci/hda/patch_hdmi.c | 100 ++++++++++++++++++++++++++++++---------------
 2 files changed, 72 insertions(+), 34 deletions(-)
include/sound/hdmi_chmap.h +0 -0
index 32087f1..c7702ef9 100644

include/sound/hdmi_chmap.h struct hdmi_chmap_ops { · line 38

Quoted 9 lines
include/sound/hdmi_chmap.h +6 -0
@@ -30,6 +30,12 @@ struct hdmi_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_monitor_connected)(struct hdac_device *hdac, int pcm_idx);

This name is rather confusing. Actually, this function doesn't mean the monitor connected state. It indicates rather whether any pin is assigned to the given PCM. It may return false only for devices with dynamic PCM assignment. For the rest, it's always true.

Takashi

#4 lore raw

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

In reply to Subhransu S. Prusty
---
 include/sound/hdmi_chmap.h |  6 +++---
 sound/pci/hda/patch_hdmi.c | 26 ++++++++++++++------------
 2 files changed, 17 insertions(+), 15 deletions(-)
include/sound/hdmi_chmap.h +3 -3
index c7702ef9..937ddb2 100644
@@ -7,7 +7,7 @@
 
 #include <sound/hdaudio.h>
 
-struct cea_channel_speaker_allocation {
+struct hdmi_cea_channel_speaker_allocation {
 	int ca_index;
 	int speakers[8];
 
@@ -23,9 +23,9 @@ struct hdmi_chmap_ops {
 	 * for devices that have non-standard mapping requirements.
 	 */
 	int (*chmap_cea_alloc_validate_get_type)(struct hdmi_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap, int channels);
+		struct hdmi_cea_channel_speaker_allocation *cap, int channels);
 	void (*cea_alloc_to_tlv_chmap)
-		(struct cea_channel_speaker_allocation *cap,
+		(struct hdmi_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 ed51d0d..5219484 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 hdmi_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 hdmi_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 hdmi_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 hdmi_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap, int channels)
+		struct hdmi_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 hdmi_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 hdmi_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 hdmi_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 hdmi_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap, int channels)
+		struct hdmi_cea_channel_speaker_allocation *cap, int channels)
 {
 	if (cap->ca_index == 0x00 && channels == 2)
 		return SNDRV_CTL_TLVT_CHMAP_FIXED;
@@ -3803,7 +3804,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 hdmi_cea_channel_speaker_allocation *cap;
 	int i, j;
 
 	/* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */
@@ -3914,7 +3915,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 hdmi_chmap *chmap,
-		struct cea_channel_speaker_allocation *cap,
+		struct hdmi_cea_channel_speaker_allocation *cap,
 		int channels)
 {
 	int c;
@@ -3942,8 +3943,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 hdmi_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
#5 lore raw

Re: [PATCH v2 3/7] ALSA: hda - Use hdmi name space for CEA spk alloc structure

Quoted 3 lines · Subhransu S. Prusty

A slight concern is that the code we have is specific to HD-audio while the header and symbols don't indicate it in your patch. If it were designed for a generic purpose HDMI/DP, it's fine. But the current code appears fairly specific to HDA, so it should be a bit more uniquely prefixed, I suppose, since there are some other parallel developments regarding HDMI for other platforms.

thanks,

Takashi

#6 lore raw

PATCH v2 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/hdmi_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/hdmi_chmap.h +10 -0
index 937ddb2..1ce630d 100644
@@ -36,6 +36,14 @@ struct hdmi_chmap_ops {
 	void (*set_chmap)(struct hdac_device *hdac, int pcm_idx,
 			unsigned char *chmap, int prepared);
 	bool (*is_monitor_connected)(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 hdmi_chmap {
@@ -44,4 +52,6 @@ struct hdmi_chmap {
 	struct hdac_device *hdac;
 };
 
+void snd_hdmi_register_chmap_ops(struct hdac_device *hdac,
+				struct hdmi_chmap *chmap);
 #endif /* __SOUND_HDMI_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
#7 lore raw

PATCH v2 5/7 ALSA: hda - Use ops instead of directly accessing chmap helpers

In reply to Subhransu S. Prusty

Added more ops to the chmap object, so most of the helpers can be accessed through ops instead instead of directly calling them. With this moving the chmap helpers to core will be easy.

---
 include/sound/hdmi_chmap.h |  20 ++++++--
 sound/pci/hda/patch_hdmi.c | 121 ++++++++++++++++++++++++++++-----------------
 2 files changed, 94 insertions(+), 47 deletions(-)
include/sound/hdmi_chmap.h +17 -3
index 1ce630d..7b824b6 100644
@@ -7,6 +7,8 @@
 
 #include <sound/hdaudio.h>
 
+#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
+
 struct hdmi_cea_channel_speaker_allocation {
 	int ca_index;
 	int speakers[8];
@@ -24,12 +26,13 @@ struct hdmi_chmap_ops {
 	 */
 	int (*chmap_cea_alloc_validate_get_type)(struct hdmi_chmap *chmap,
 		struct hdmi_cea_channel_speaker_allocation *cap, int channels);
-	void (*cea_alloc_to_tlv_chmap)
-		(struct hdmi_cea_channel_speaker_allocation *cap,
+	void (*cea_alloc_to_tlv_chmap)(struct hdmi_chmap *hchmap,
+		struct hdmi_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 hdmi_chmap *hchmap, int ca,
+			int channels, unsigned char *chmap);
 
 	void (*get_chmap)(struct hdac_device *hdac, int pcm_idx,
 					unsigned char *chmap);
@@ -44,6 +47,17 @@ struct hdmi_chmap_ops {
 			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);
+	int (*get_active_channels)(int ca);
+	void (*setup_channel_mapping)(struct hdmi_chmap *chmap,
+			hda_nid_t pin_nid, bool non_pcm, int ca,
+			int channels, unsigned char *map,
+			bool chmap_set);
+	int (*channel_allocation)(struct hdac_device *hdac, int spk_alloc,
+				int channels, bool chmap_set,
+				bool non_pcm, unsigned char *map);
+	struct hdmi_cea_channel_speaker_allocation *(*get_cap_from_ca)(int ca);
+	int (*alsa_chmap_to_spk_mask)(unsigned char c);
+	int (*spk_to_alsa_chmap)(int spk);
 };
 
 struct hdmi_chmap {
sound/pci/hda/patch_hdmi.c +77 -44

285 lines not on this page · raw message

Signature · 1 line
1.9.1
#8 lore raw

Re: [PATCH v2 5/7] ALSA: hda - Use ops instead of directly accessing chmap helpers

Quoted 3 lines · Subhransu S. Prusty

Added more ops to the chmap object, so most of the helpers can be accessed through ops instead instead of directly calling them.

Too many instead :)

Quoted 1 line

With this moving the chmap helpers to core will be easy.

Well, although I asked about reduction of exported stuff, I don't think it's worth to put everything in ops. If any of them would be overridden, it's good to have as an ops. If not, it's fine to have exported symbols. These are just a few entries, not over 20.

Takashi

#9 lore raw

Re: [PATCH v2 5/7] ALSA: hda - Use ops instead of directly accessing chmap helpers

Quoted 6 lines · Takashi Iwai
Quoted 3 lines · Subhransu S. Prusty

Added more ops to the chmap object, so most of the helpers can be accessed through ops instead instead of directly calling them.

Quoted 8 lines

Too many instead :)

Quoted 1 line

With this moving the chmap helpers to core will be easy.

Well, although I asked about reduction of exported stuff, I don't think it's worth to put everything in ops. If any of them would be overridden, it's good to have as an ops. If not, it's fine to have exported symbols. These are just a few entries, not over 20.

I think the thought was that patch_hdmi and ASoC driver will use defaults whereas the patch_nvidia etc will override with their own stuff..

Signature · 1 line
~Vinod
#10 lore raw

Re: [PATCH v2 5/7] ALSA: hda - Use ops instead of directly accessing chmap helpers

Quoted 12 lines · Vinod Koul
Quoted 10 lines · Takashi Iwai
Quoted 3 lines · Subhransu S. Prusty

Added more ops to the chmap object, so most of the helpers can be accessed through ops instead instead of directly calling them.

Too many instead :)

Quoted 1 line

With this moving the chmap helpers to core will be easy.

Quoted 7 lines
Quoted 4 lines

Well, although I asked about reduction of exported stuff, I don't think it's worth to put everything in ops. If any of them would be overridden, it's good to have as an ops. If not, it's fine to have exported symbols. These are just a few entries, not over 20.

I think the thought was that patch_hdmi and ASoC driver will use defaults whereas the patch_nvidia etc will override with their own stuff..

Yes, but are these new ops overridden actually?

Takashi

#11 lore raw

Re: [PATCH v2 5/7] ALSA: hda - Use ops instead of directly accessing chmap helpers

Quoted 19 lines · Takashi Iwai
Quoted 17 lines · Vinod Koul
Quoted 14 lines · Takashi Iwai
Quoted 3 lines · Subhransu S. Prusty

Added more ops to the chmap object, so most of the helpers can be accessed through ops instead instead of directly calling them.

Too many instead :)

Quoted 1 line

With this moving the chmap helpers to core will be easy.

Well, although I asked about reduction of exported stuff, I don't think it's worth to put everything in ops. If any of them would be overridden, it's good to have as an ops. If not, it's fine to have exported symbols. These are just a few entries, not over 20.

Quoted 4 lines
Quoted 2 lines

I think the thought was that patch_hdmi and ASoC driver will use defaults whereas the patch_nvidia etc will override with their own stuff..

Yes, but are these new ops overridden actually?

I think the new ops added with this patch can be removed. They can be kept as exported APIs and not overriden.

basically these ones:
+ int (*get_active_channels)(int ca);
+ void (*setup_channel_mapping)(struct hdmi_chmap *chmap,
+ hda_nid_t pin_nid, bool non_pcm, int ca,
+ int channels, unsigned char *map,
+ bool chmap_set);
+ int (*channel_allocation)(struct hdac_device *hdac, int spk_alloc,
+ int channels, bool chmap_set,
+ bool non_pcm, unsigned char *map);
+ struct hdmi_cea_channel_speaker_allocation *(*get_cap_from_ca)(int
ca);
+ int (*alsa_chmap_to_spk_mask)(unsigned char c);
+ int (*spk_to_alsa_chmap)(int spk);

Quoted 3 lines

Takashi

#12 lore raw

Re: [PATCH v2 5/7] ALSA: hda - Use ops instead of directly accessing chmap helpers

Quoted 40 lines · Subhransu S. Prusty
Quoted 19 lines · Takashi Iwai
Quoted 17 lines · Vinod Koul
Quoted 14 lines · Takashi Iwai
Quoted 3 lines · Subhransu S. Prusty

Added more ops to the chmap object, so most of the helpers can be accessed through ops instead instead of directly calling them.

Too many instead :)

Quoted 1 line

With this moving the chmap helpers to core will be easy.

Well, although I asked about reduction of exported stuff, I don't think it's worth to put everything in ops. If any of them would be overridden, it's good to have as an ops. If not, it's fine to have exported symbols. These are just a few entries, not over 20.

Quoted 4 lines
Quoted 2 lines

I think the thought was that patch_hdmi and ASoC driver will use defaults whereas the patch_nvidia etc will override with their own stuff..

Yes, but are these new ops overridden actually?

I think the new ops added with this patch can be removed. They can be kept as exported APIs and not overriden.

basically these ones:

include/sound/hdmi_chmap.h +9 -0
+	int (*get_active_channels)(int ca);
+	void (*setup_channel_mapping)(struct hdmi_chmap *chmap,
+			hda_nid_t pin_nid, bool non_pcm, int ca,
+			int channels, unsigned char *map,
+			bool chmap_set);
+	int (*channel_allocation)(struct hdac_device *hdac, int spk_alloc,
+				int channels, bool chmap_set,
+				bool non_pcm, unsigned char *map);
+	struct hdmi_cea_channel_speaker_allocation *(*get_cap_from_ca)(int

ca);

include/sound/hdmi_chmap.h struct hdmi_chmap_ops { · line 60

Quoted 2 lines
include/sound/hdmi_chmap.h +2 -0
+	int (*alsa_chmap_to_spk_mask)(unsigned char c);
+	int (*spk_to_alsa_chmap)(int spk);

Right, I meant the comment above particularly to the ops added in this patch 5. The first few ops are reasonable.

Takashi

#13 lore raw

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

In reply to Subhransu S. Prusty

Chmap helpers, ops, channel map controls are moved to core.

---
 include/sound/hdmi_chmap.h |   4 +
 sound/hda/hdmi_chmap.c     | 742 +++++++++++++++++++++++++++++++++++++++++++++
 sound/pci/hda/hda_eld.c    |  27 +-
 sound/pci/hda/patch_hdmi.c | 693 +-----------------------------------------
 4 files changed, 748 insertions(+), 718 deletions(-)
include/sound/hdmi_chmap.h +4 -0
index 7b824b6..837c6e5 100644
@@ -5,6 +5,7 @@
 #ifndef __SOUND_HDMI_CHMAP_H
 #define __SOUND_HDMI_CHMAP_H
 
+#include <sound/pcm.h>
 #include <sound/hdaudio.h>
 
 #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
@@ -68,4 +69,7 @@ struct hdmi_chmap {
 
 void snd_hdmi_register_chmap_ops(struct hdac_device *hdac,
 				struct hdmi_chmap *chmap);
+void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
+int snd_hdmi_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
+				struct hdmi_chmap *chmap);
 #endif /* __SOUND_HDMI_CHMAP_H */
sound/hda/hdmi_chmap.c +742 -0

765 lines not on this page · raw message

sound/pci/hda/hda_eld.c +1 -26
index bc2e082..864d6fe 100644
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <sound/core.h>
 #include <asm/unaligned.h>
+#include <sound/hdmi_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 -692

750 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

PATCH v2 7/7 ALSA: hda - Use snd_hdmi namespace prefix for printing ch alloc api

In reply to Subhransu S. Prusty
---
 include/sound/hdmi_chmap.h | 2 +-
 sound/hda/hdmi_chmap.c     | 6 +++---
 sound/pci/hda/hda_eld.c    | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
include/sound/hdmi_chmap.h +1 -1
index 837c6e5..a58c204 100644
@@ -69,7 +69,7 @@ struct hdmi_chmap {
 
 void snd_hdmi_register_chmap_ops(struct hdac_device *hdac,
 				struct hdmi_chmap *chmap);
-void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
+void snd_hdmi_print_channel_allocation(int spk_alloc, char *buf, int buflen);
 int snd_hdmi_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
 				struct hdmi_chmap *chmap);
 #endif /* __SOUND_HDMI_CHMAP_H */
sound/hda/hdmi_chmap.c +3 -3
index 0685dc2..72d6989 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_hdmi_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_hdmi_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_hdmi_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);
 
sound/pci/hda/hda_eld.c +2 -2
index 864d6fe..e05b388 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_hdmi_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_hdmi_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);
Signature · 1 line
1.9.1