ASoC: SDCA: add quirk function for RT712_VB match

Add a generic match function for quirks, chances are we are going to
have lots of those...

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://patch.msgid.link/20241016102333.294448-6-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Pierre-Louis Bossart 2024-10-16 18:23:27 +08:00 committed by Mark Brown
parent 0c673d2862
commit fdb2203991
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 52 additions and 1 deletions

View File

@ -39,16 +39,24 @@ struct sdca_device_data {
struct sdca_function_desc sdca_func[SDCA_MAX_FUNCTION_COUNT]; struct sdca_function_desc sdca_func[SDCA_MAX_FUNCTION_COUNT];
}; };
enum sdca_quirk {
SDCA_QUIRKS_RT712_VB,
};
#if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SDCA) #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SDCA)
void sdca_lookup_functions(struct sdw_slave *slave); void sdca_lookup_functions(struct sdw_slave *slave);
void sdca_lookup_interface_revision(struct sdw_slave *slave); void sdca_lookup_interface_revision(struct sdw_slave *slave);
bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk);
#else #else
static inline void sdca_lookup_functions(struct sdw_slave *slave) {} static inline void sdca_lookup_functions(struct sdw_slave *slave) {}
static inline void sdca_lookup_interface_revision(struct sdw_slave *slave) {} static inline void sdca_lookup_interface_revision(struct sdw_slave *slave) {}
static inline bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk)
{
return false;
}
#endif #endif
#endif #endif

View File

@ -9,6 +9,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/soundwire/sdw.h> #include <linux/soundwire/sdw.h>
#include <sound/sdca.h> #include <sound/sdca.h>
#include <sound/sdca_function.h>
void sdca_lookup_interface_revision(struct sdw_slave *slave) void sdca_lookup_interface_revision(struct sdw_slave *slave)
{ {
@ -22,3 +23,45 @@ void sdca_lookup_interface_revision(struct sdw_slave *slave)
&slave->sdca_data.interface_revision); &slave->sdca_data.interface_revision);
} }
EXPORT_SYMBOL_NS(sdca_lookup_interface_revision, SND_SOC_SDCA); EXPORT_SYMBOL_NS(sdca_lookup_interface_revision, SND_SOC_SDCA);
static bool sdca_device_quirk_rt712_vb(struct sdw_slave *slave)
{
struct sdw_slave_id *id = &slave->id;
int i;
/*
* The RT712_VA relies on the v06r04 draft, and the
* RT712_VB on a more recent v08r01 draft.
*/
if (slave->sdca_data.interface_revision < 0x0801)
return false;
if (id->mfg_id != 0x025d)
return false;
if (id->part_id != 0x712 &&
id->part_id != 0x713 &&
id->part_id != 0x716 &&
id->part_id != 0x717)
return false;
for (i = 0; i < slave->sdca_data.num_functions; i++) {
if (slave->sdca_data.sdca_func[i].type ==
SDCA_FUNCTION_TYPE_SMART_MIC)
return true;
}
return false;
}
bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk)
{
switch (quirk) {
case SDCA_QUIRKS_RT712_VB:
return sdca_device_quirk_rt712_vb(slave);
default:
break;
}
return false;
}
EXPORT_SYMBOL_NS(sdca_device_quirk_match, SND_SOC_SDCA);