diff options
-rw-r--r-- | sound/soc/codecs/tpa6130a2.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 958d49c969ac..0cf3e3862e7b 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
@@ -53,6 +53,7 @@ struct tpa6130a2_data { | |||
53 | struct regulator_bulk_data supplies[TPA6130A2_NUM_SUPPLIES]; | 53 | struct regulator_bulk_data supplies[TPA6130A2_NUM_SUPPLIES]; |
54 | int power_gpio; | 54 | int power_gpio; |
55 | unsigned char power_state; | 55 | unsigned char power_state; |
56 | enum tpa_model id; | ||
56 | }; | 57 | }; |
57 | 58 | ||
58 | static int tpa6130a2_i2c_read(int reg) | 59 | static int tpa6130a2_i2c_read(int reg) |
@@ -263,6 +264,20 @@ static const struct snd_kcontrol_new tpa6130a2_controls[] = { | |||
263 | tpa6130_tlv), | 264 | tpa6130_tlv), |
264 | }; | 265 | }; |
265 | 266 | ||
267 | static const unsigned int tpa6140_tlv[] = { | ||
268 | TLV_DB_RANGE_HEAD(3), | ||
269 | 0, 8, TLV_DB_SCALE_ITEM(-5900, 400, 0), | ||
270 | 9, 16, TLV_DB_SCALE_ITEM(-2500, 200, 0), | ||
271 | 17, 31, TLV_DB_SCALE_ITEM(-1000, 100, 0), | ||
272 | }; | ||
273 | |||
274 | static const struct snd_kcontrol_new tpa6140a2_controls[] = { | ||
275 | SOC_SINGLE_EXT_TLV("TPA6140A2 Headphone Playback Volume", | ||
276 | TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0, | ||
277 | tpa6130a2_get_reg, tpa6130a2_set_reg, | ||
278 | tpa6140_tlv), | ||
279 | }; | ||
280 | |||
266 | /* | 281 | /* |
267 | * Enable or disable channel (left or right) | 282 | * Enable or disable channel (left or right) |
268 | * The bit number for mute and amplifier are the same per channel: | 283 | * The bit number for mute and amplifier are the same per channel: |
@@ -368,13 +383,22 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
368 | 383 | ||
369 | int tpa6130a2_add_controls(struct snd_soc_codec *codec) | 384 | int tpa6130a2_add_controls(struct snd_soc_codec *codec) |
370 | { | 385 | { |
386 | struct tpa6130a2_data *data; | ||
387 | |||
388 | BUG_ON(tpa6130a2_client == NULL); | ||
389 | data = i2c_get_clientdata(tpa6130a2_client); | ||
390 | |||
371 | snd_soc_dapm_new_controls(codec, tpa6130a2_dapm_widgets, | 391 | snd_soc_dapm_new_controls(codec, tpa6130a2_dapm_widgets, |
372 | ARRAY_SIZE(tpa6130a2_dapm_widgets)); | 392 | ARRAY_SIZE(tpa6130a2_dapm_widgets)); |
373 | 393 | ||
374 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | 394 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); |
375 | 395 | ||
376 | return snd_soc_add_controls(codec, tpa6130a2_controls, | 396 | if (data->id == TPA6140A2) |
377 | ARRAY_SIZE(tpa6130a2_controls)); | 397 | return snd_soc_add_controls(codec, tpa6140a2_controls, |
398 | ARRAY_SIZE(tpa6140a2_controls)); | ||
399 | else | ||
400 | return snd_soc_add_controls(codec, tpa6130a2_controls, | ||
401 | ARRAY_SIZE(tpa6130a2_controls)); | ||
378 | 402 | ||
379 | } | 403 | } |
380 | EXPORT_SYMBOL_GPL(tpa6130a2_add_controls); | 404 | EXPORT_SYMBOL_GPL(tpa6130a2_add_controls); |
@@ -407,6 +431,7 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, | |||
407 | 431 | ||
408 | pdata = client->dev.platform_data; | 432 | pdata = client->dev.platform_data; |
409 | data->power_gpio = pdata->power_gpio; | 433 | data->power_gpio = pdata->power_gpio; |
434 | data->id = pdata->id; | ||
410 | 435 | ||
411 | mutex_init(&data->mutex); | 436 | mutex_init(&data->mutex); |
412 | 437 | ||
@@ -425,7 +450,7 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, | |||
425 | gpio_direction_output(data->power_gpio, 0); | 450 | gpio_direction_output(data->power_gpio, 0); |
426 | } | 451 | } |
427 | 452 | ||
428 | switch (pdata->id) { | 453 | switch (data->id) { |
429 | case TPA6130A2: | 454 | case TPA6130A2: |
430 | for (i = 0; i < ARRAY_SIZE(data->supplies); i++) | 455 | for (i = 0; i < ARRAY_SIZE(data->supplies); i++) |
431 | data->supplies[i].supply = tpa6130a2_supply_names[i]; | 456 | data->supplies[i].supply = tpa6130a2_supply_names[i]; |