Skip to content

Commit

Permalink
Merge remote-tracking branches 'asoc/topic/intel', 'asoc/topic/kirkwo…
Browse files Browse the repository at this point in the history
…od', 'asoc/topic/lm49453', 'asoc/topic/max9768' and 'asoc/topic/max98088' into asoc-next
  • Loading branch information
Mark Brown committed Aug 30, 2015
6 parents 246647e + e1d46d3 + c4a4291 + 6f43979 + 04b5cbd + f102aa1 commit 373e515
Show file tree
Hide file tree
Showing 31 changed files with 5,464 additions and 350 deletions.
6 changes: 1 addition & 5 deletions sound/soc/codecs/lm49453.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ static struct reg_default lm49453_reg_defs[] = {
/* codec private data */
struct lm49453_priv {
struct regmap *regmap;
int fs_rate;
};

/* capture path controls */
Expand Down Expand Up @@ -1112,13 +1111,10 @@ static int lm49453_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct lm49453_priv *lm49453 = snd_soc_codec_get_drvdata(codec);
u16 clk_div = 0;

lm49453->fs_rate = params_rate(params);

/* Setting DAC clock dividers based on substream sample rate. */
switch (lm49453->fs_rate) {
switch (params_rate(params)) {
case 8000:
case 16000:
case 32000:
Expand Down
61 changes: 18 additions & 43 deletions sound/soc/codecs/max9768.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ static struct reg_default max9768_default_regs[] = {
static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
int val = gpio_get_value_cansleep(max9768->mute_gpio);

ucontrol->value.integer.value[0] = !val;
Expand All @@ -55,8 +55,8 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
struct max9768 *max9768 = snd_soc_component_get_drvdata(c);

gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]);

Expand Down Expand Up @@ -130,19 +130,20 @@ static const struct snd_soc_dapm_route max9768_dapm_routes[] = {
{ "OUT-", NULL, "IN" },
};

static int max9768_probe(struct snd_soc_codec *codec)
static int max9768_probe(struct snd_soc_component *component)
{
struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec);
struct max9768 *max9768 = snd_soc_component_get_drvdata(component);
int ret;

if (max9768->flags & MAX9768_FLAG_CLASSIC_PWM) {
ret = snd_soc_write(codec, MAX9768_CTRL, MAX9768_CTRL_PWM);
ret = regmap_write(max9768->regmap, MAX9768_CTRL,
MAX9768_CTRL_PWM);
if (ret)
return ret;
}

if (gpio_is_valid(max9768->mute_gpio)) {
ret = snd_soc_add_codec_controls(codec, max9768_mute,
ret = snd_soc_add_component_controls(component, max9768_mute,
ARRAY_SIZE(max9768_mute));
if (ret)
return ret;
Expand All @@ -151,7 +152,7 @@ static int max9768_probe(struct snd_soc_codec *codec)
return 0;
}

static struct snd_soc_codec_driver max9768_codec_driver = {
static struct snd_soc_component_driver max9768_component_driver = {
.probe = max9768_probe,
.controls = max9768_volume,
.num_controls = ARRAY_SIZE(max9768_volume),
Expand Down Expand Up @@ -183,11 +184,13 @@ static int max9768_i2c_probe(struct i2c_client *client,

if (pdata) {
/* Mute on powerup to avoid clicks */
err = gpio_request_one(pdata->mute_gpio, GPIOF_INIT_HIGH, "MAX9768 Mute");
err = devm_gpio_request_one(&client->dev, pdata->mute_gpio,
GPIOF_INIT_HIGH, "MAX9768 Mute");
max9768->mute_gpio = err ?: pdata->mute_gpio;

/* Activate chip by releasing shutdown, enables I2C */
err = gpio_request_one(pdata->shdn_gpio, GPIOF_INIT_HIGH, "MAX9768 Shutdown");
err = devm_gpio_request_one(&client->dev, pdata->shdn_gpio,
GPIOF_INIT_HIGH, "MAX9768 Shutdown");
max9768->shdn_gpio = err ?: pdata->shdn_gpio;

max9768->flags = pdata->flags;
Expand All @@ -199,38 +202,11 @@ static int max9768_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, max9768);

max9768->regmap = devm_regmap_init_i2c(client, &max9768_i2c_regmap_config);
if (IS_ERR(max9768->regmap)) {
err = PTR_ERR(max9768->regmap);
goto err_gpio_free;
}

err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0);
if (err)
goto err_gpio_free;

return 0;

err_gpio_free:
if (gpio_is_valid(max9768->shdn_gpio))
gpio_free(max9768->shdn_gpio);
if (gpio_is_valid(max9768->mute_gpio))
gpio_free(max9768->mute_gpio);

return err;
}

static int max9768_i2c_remove(struct i2c_client *client)
{
struct max9768 *max9768 = i2c_get_clientdata(client);
if (IS_ERR(max9768->regmap))
return PTR_ERR(max9768->regmap);

snd_soc_unregister_codec(&client->dev);

if (gpio_is_valid(max9768->shdn_gpio))
gpio_free(max9768->shdn_gpio);
if (gpio_is_valid(max9768->mute_gpio))
gpio_free(max9768->mute_gpio);

return 0;
return devm_snd_soc_register_component(&client->dev,
&max9768_component_driver, NULL, 0);
}

static const struct i2c_device_id max9768_i2c_id[] = {
Expand All @@ -244,7 +220,6 @@ static struct i2c_driver max9768_i2c_driver = {
.name = "max9768",
},
.probe = max9768_i2c_probe,
.remove = max9768_i2c_remove,
.id_table = max9768_i2c_id,
};
module_i2c_driver(max9768_i2c_driver);
Expand Down
Loading

0 comments on commit 373e515

Please sign in to comment.