aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-cache.c')
-rw-r--r--sound/soc/soc-cache.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 1a36b36c5baa..d97a59f6a249 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -1603,3 +1603,52 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec)
1603 return -EINVAL; 1603 return -EINVAL;
1604} 1604}
1605EXPORT_SYMBOL_GPL(snd_soc_cache_sync); 1605EXPORT_SYMBOL_GPL(snd_soc_cache_sync);
1606
1607static int snd_soc_get_reg_access_index(struct snd_soc_codec *codec,
1608 unsigned int reg)
1609{
1610 const struct snd_soc_codec_driver *codec_drv;
1611 unsigned int min, max, index;
1612
1613 codec_drv = codec->driver;
1614 min = 0;
1615 max = codec_drv->reg_access_size - 1;
1616 do {
1617 index = (min + max) / 2;
1618 if (codec_drv->reg_access_default[index].reg == reg)
1619 return index;
1620 if (codec_drv->reg_access_default[index].reg < reg)
1621 min = index + 1;
1622 else
1623 max = index;
1624 } while (min <= max);
1625 return -1;
1626}
1627
1628int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
1629 unsigned int reg)
1630{
1631 int index;
1632
1633 if (reg >= codec->driver->reg_cache_size)
1634 return 1;
1635 index = snd_soc_get_reg_access_index(codec, reg);
1636 if (index < 0)
1637 return 0;
1638 return codec->driver->reg_access_default[index].vol;
1639}
1640EXPORT_SYMBOL_GPL(snd_soc_default_volatile_register);
1641
1642int snd_soc_default_readable_register(struct snd_soc_codec *codec,
1643 unsigned int reg)
1644{
1645 int index;
1646
1647 if (reg >= codec->driver->reg_cache_size)
1648 return 1;
1649 index = snd_soc_get_reg_access_index(codec, reg);
1650 if (index < 0)
1651 return 0;
1652 return codec->driver->reg_access_default[index].read;
1653}
1654EXPORT_SYMBOL_GPL(snd_soc_default_readable_register);