Skip to content

Instantly share code, notes, and snippets.

@checko
Created February 16, 2015 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save checko/296ad4d53eadd3b52548 to your computer and use it in GitHub Desktop.
Save checko/296ad4d53eadd3b52548 to your computer and use it in GitHub Desktop.
rt5625 mic_ctrl sysfs
static ssize_t rt5625_mic_ctrl_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct rt5625_priv *rt5625 = i2c_get_clientdata(client);
struct snd_soc_codec *codec = rt5625->codec;
int data = snd_soc_read(codec, RT5625_MIC_CTRL);
return sprintf(buf, "%x",data);
}
static ssize_t rt5625_mic_ctrl_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct rt5625_priv *rt5625 = i2c_get_clientdata(client);
struct snd_soc_codec *codec = rt5625->codec;
long regvalue;
int status;
status = strict_strtol(buf,16,&regvalue);
if (status != 0) {
printk("rt5625 invalid parameter format %s\n",buf);
return -EINVAL;
}
snd_soc_write(codec, RT5625_MIC_CTRL, (int)regvalue&0xFFFF);
return count;
}
static DEVICE_ATTR(mic_ctrl, S_IRUGO | S_IWUSR | S_IWGRP,
rt5625_mic_ctrl_show, rt5625_mic_ctrl_store);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment