Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <brent.lu@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <20231127120657.19764-2-peter.ujfalusi@linux.intel.com>

authored by

Brent Lu and committed by
Takashi Iwai
02545bc5 9f234784

+36
+10
include/sound/intel-nhlt.h
··· 143 143 u32 bus_id, u8 link_type, u8 vbps, u8 bps, 144 144 u8 num_ch, u32 rate, u8 dir, u8 dev_type); 145 145 146 + int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt, 147 + u8 virtual_bus_id); 148 + 146 149 #else 147 150 148 151 static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev) ··· 185 182 u8 num_ch, u32 rate, u8 dir, u8 dev_type) 186 183 { 187 184 return NULL; 185 + } 186 + 187 + static inline int intel_nhlt_ssp_device_type(struct device *dev, 188 + struct nhlt_acpi_table *nhlt, 189 + u8 virtual_bus_id) 190 + { 191 + return -EINVAL; 188 192 } 189 193 190 194 #endif
+26
sound/hda/intel-nhlt.c
··· 343 343 return NULL; 344 344 } 345 345 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);