sound/soc/codecs/tas2781-comlib-i2c.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/tas2781-comlib-i2c.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/tas2781-comlib-i2c.c
Extension
.c
Size
9294 bytes
Lines
372
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

if (client->addr != tasdev->dev_addr) {
			client->addr = tasdev->dev_addr;
			/* All tas2781s share the same regmap, clear the page
			 * inside regmap once switching to another tas2781.
			 * Register 0 at any pages and any books inside tas2781
			 * is the same one for page-switching.
			 */
			ret = regmap_write(map, TASDEVICE_PAGE_SELECT, 0);
			if (ret < 0) {
				dev_err(tas_priv->dev, "%s, E=%d channel:%d\n",
					__func__, ret, chn);
				goto out;
			}
		}

		if (tasdev->cur_book != book) {
			ret = regmap_write(map, TASDEVICE_BOOKCTL_REG, book);
			if (ret < 0) {
				dev_err(tas_priv->dev, "%s, E=%d\n",
					__func__, ret);
				goto out;
			}
			tasdev->cur_book = book;
		}
	} else {
		ret = -EINVAL;
		dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__,
			chn);
	}

out:
	return ret;
}

int tasdev_chn_switch(struct tasdevice_priv *tas_priv,
	unsigned short chn)
{
	struct i2c_client *client = (struct i2c_client *)tas_priv->client;
	struct tasdevice *tasdev = &tas_priv->tasdevice[chn];
	struct regmap *map = tas_priv->regmap;
	int ret;

	if (client->addr != tasdev->dev_addr) {
		client->addr = tasdev->dev_addr;
		/* All devices share the same regmap, clear the page
		 * inside regmap once switching to another device.
		 * Register 0 at any pages and any books inside tas2781
		 * is the same one for page-switching.
		 */
		ret = regmap_write(map, TASDEVICE_PAGE_SELECT, 0);
		if (ret < 0) {
			dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret);
			return ret;
		}
		return 1;
	}
	return 0;
}
EXPORT_SYMBOL_GPL(tasdev_chn_switch);

int tasdevice_dev_update_bits(
	struct tasdevice_priv *tas_priv, unsigned short chn,
	unsigned int reg, unsigned int mask, unsigned int value)
{
	int ret = 0;

	if (chn < tas_priv->ndev) {
		struct regmap *map = tas_priv->regmap;

		ret = tas_priv->change_chn_book(tas_priv, chn,
			TASDEVICE_BOOK_ID(reg));
		if (ret < 0)
			goto out;

		ret = regmap_update_bits(map, TASDEVICE_PGRG(reg),
			mask, value);
		if (ret < 0)
			dev_err(tas_priv->dev, "%s, E=%d\n", __func__, ret);
	} else {
		dev_err(tas_priv->dev, "%s, no such channel(%d)\n", __func__,
			chn);
		ret = -EINVAL;
	}

out:
	return ret;
}
EXPORT_SYMBOL_GPL(tasdevice_dev_update_bits);

struct tasdevice_priv *tasdevice_kzalloc(struct i2c_client *i2c)

Annotation

Implementation Notes