sound/soc/codecs/cs35l56-test.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs35l56-test.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/cs35l56-test.c
Extension
.c
Size
23643 bytes
Lines
729
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct cs35l56_test_priv {
	struct faux_device *amp_dev;
	struct cs35l56_private *cs35l56_priv;

	const char *ssidexv2;

	bool read_onchip_spkid_called;
	bool configure_onchip_spkid_pads_called;
};

struct cs35l56_test_param {
	u8 type;
	u8 rev;

	s32 spkid_gpios[4];
	s32 spkid_pulls[4];
};

static const struct software_node cs35l56_test_dev_sw_node =
	SOFTWARE_NODE("SWD1", NULL, NULL);

static const struct software_node cs35l56_test_af01_sw_node =
	SOFTWARE_NODE("AF01", NULL, &cs35l56_test_dev_sw_node);

static const struct software_node *cs35l56_test_dev_and_af01_node_group[] = {
	&cs35l56_test_dev_sw_node,
	&cs35l56_test_af01_sw_node,
	NULL
};

static const char *cs35l56_test_devm_get_vendor_specific_variant_id_none(struct device *dev,
									 int ssid_vendor,
									 int ssid_device)
{
	return ERR_PTR(-ENOENT);
}

static void cs35l56_test_system_name_from_ssid(struct kunit *test)
{
	struct cs35l56_test_priv *priv = test->priv;
	struct cs35l56_private *cs35l56 = priv->cs35l56_priv;

	cs35l56->speaker_id = -1;
	snd_soc_card_set_pci_ssid(cs35l56->component->card, 0x12b4, 0xa7c8);

	KUNIT_EXPECT_EQ(test, cs35l56_get_firmware_uid(cs35l56), 0);
	KUNIT_EXPECT_EQ(test, cs35l56_set_fw_name(cs35l56->component), 0);
	KUNIT_EXPECT_STREQ(test, cs35l56->dsp.system_name, "12b4a7c8");
}

static void cs35l56_test_system_name_from_ssid_and_spkid(struct kunit *test)
{
	struct cs35l56_test_priv *priv = test->priv;
	struct cs35l56_private *cs35l56 = priv->cs35l56_priv;

	cs35l56->speaker_id = 1;
	snd_soc_card_set_pci_ssid(cs35l56->component->card, 0x12b4, 0xa7c8);

	KUNIT_EXPECT_EQ(test, cs35l56_get_firmware_uid(cs35l56), 0);
	KUNIT_EXPECT_EQ(test, cs35l56_set_fw_name(cs35l56->component), 0);
	KUNIT_EXPECT_STREQ(test, cs35l56->dsp.system_name, "12b4a7c8-spkid1");
}

static void cs35l56_test_system_name_from_property(struct kunit *test)
{
	struct cs35l56_test_priv *priv = test->priv;
	struct cs35l56_private *cs35l56 = priv->cs35l56_priv;
	const struct property_entry dev_props[] = {
		PROPERTY_ENTRY_STRING("cirrus,firmware-uid", "acme"),
		{ }
	};
	const struct software_node dev_node = SOFTWARE_NODE("SPK1", dev_props, NULL);

	cs35l56->speaker_id = -1;

	KUNIT_ASSERT_EQ(test, device_add_software_node(cs35l56->base.dev, &dev_node), 0);
	KUNIT_ASSERT_EQ(test, 0,
			kunit_add_action_or_reset(test,
						  device_remove_software_node_wrapper,
						  cs35l56->base.dev));

	KUNIT_EXPECT_EQ(test, cs35l56_get_firmware_uid(cs35l56), 0);
	KUNIT_EXPECT_EQ(test, cs35l56_set_fw_name(cs35l56->component), 0);
	KUNIT_EXPECT_STREQ(test, cs35l56->dsp.system_name, "acme");
}

static void cs35l56_test_system_name_from_property_and_spkid(struct kunit *test)
{
	struct cs35l56_test_priv *priv = test->priv;
	struct cs35l56_private *cs35l56 = priv->cs35l56_priv;

Annotation

Implementation Notes