Skip to content

Commit 02545bc

Browse files
brentlutiwai
authored andcommitted
ALSA: hda: intel-nhlt: add intel_nhlt_ssp_device_type() function
Add a helper function intel_nhlt_ssp_device_type() to detect the type of specific SSP port. The result is nhlt_device_type enum type which could be NHLT_DEVICE_BT or NHLT_DEVICE_I2S. Signed-off-by: Brent Lu <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Bard Liao <[email protected]> Signed-off-by: Peter Ujfalusi <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Message-ID: <[email protected]>
1 parent 9f23478 commit 02545bc

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

include/sound/intel-nhlt.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
143143
u32 bus_id, u8 link_type, u8 vbps, u8 bps,
144144
u8 num_ch, u32 rate, u8 dir, u8 dev_type);
145145

146+
int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt,
147+
u8 virtual_bus_id);
148+
146149
#else
147150

148151
static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
@@ -184,6 +187,13 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
184187
return NULL;
185188
}
186189

190+
static inline int intel_nhlt_ssp_device_type(struct device *dev,
191+
struct nhlt_acpi_table *nhlt,
192+
u8 virtual_bus_id)
193+
{
194+
return -EINVAL;
195+
}
196+
187197
#endif
188198

189199
#endif

sound/hda/intel-nhlt.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,29 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
343343
return NULL;
344344
}
345345
EXPORT_SYMBOL(intel_nhlt_get_endpoint_blob);
346+
347+
int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt,
348+
u8 virtual_bus_id)
349+
{
350+
struct nhlt_endpoint *epnt;
351+
int i;
352+
353+
if (!nhlt)
354+
return -EINVAL;
355+
356+
epnt = (struct nhlt_endpoint *)nhlt->desc;
357+
for (i = 0; i < nhlt->endpoint_count; i++) {
358+
/* for SSP link the virtual bus id is the SSP port number */
359+
if (epnt->linktype == NHLT_LINK_SSP &&
360+
epnt->virtual_bus_id == virtual_bus_id) {
361+
dev_dbg(dev, "SSP%d: dev_type=%d\n", virtual_bus_id,
362+
epnt->device_type);
363+
return epnt->device_type;
364+
}
365+
366+
epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
367+
}
368+
369+
return -EINVAL;
370+
}
371+
EXPORT_SYMBOL(intel_nhlt_ssp_device_type);

0 commit comments

Comments
 (0)