diff options
Diffstat (limited to 'sound/soc/codecs/lm49453.c')
-rw-r--r-- | sound/soc/codecs/lm49453.c | 124 |
1 files changed, 46 insertions, 78 deletions
diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c index 99b0a9dcff34..e19490cfb3a8 100644 --- a/sound/soc/codecs/lm49453.c +++ b/sound/soc/codecs/lm49453.c | |||
@@ -111,9 +111,9 @@ static struct reg_default lm49453_reg_defs[] = { | |||
111 | { 101, 0x00 }, | 111 | { 101, 0x00 }, |
112 | { 102, 0x00 }, | 112 | { 102, 0x00 }, |
113 | { 103, 0x01 }, | 113 | { 103, 0x01 }, |
114 | { 105, 0x01 }, | 114 | { 104, 0x01 }, |
115 | { 106, 0x00 }, | 115 | { 105, 0x00 }, |
116 | { 107, 0x01 }, | 116 | { 106, 0x01 }, |
117 | { 107, 0x00 }, | 117 | { 107, 0x00 }, |
118 | { 108, 0x00 }, | 118 | { 108, 0x00 }, |
119 | { 109, 0x00 }, | 119 | { 109, 0x00 }, |
@@ -163,56 +163,25 @@ static struct reg_default lm49453_reg_defs[] = { | |||
163 | { 184, 0x00 }, | 163 | { 184, 0x00 }, |
164 | { 185, 0x00 }, | 164 | { 185, 0x00 }, |
165 | { 186, 0x00 }, | 165 | { 186, 0x00 }, |
166 | { 189, 0x00 }, | 166 | { 187, 0x00 }, |
167 | { 188, 0x00 }, | 167 | { 188, 0x00 }, |
168 | { 194, 0x00 }, | 168 | { 189, 0x00 }, |
169 | { 195, 0x00 }, | 169 | { 208, 0x06 }, |
170 | { 196, 0x00 }, | ||
171 | { 197, 0x00 }, | ||
172 | { 200, 0x00 }, | ||
173 | { 201, 0x00 }, | ||
174 | { 202, 0x00 }, | ||
175 | { 203, 0x00 }, | ||
176 | { 204, 0x00 }, | ||
177 | { 205, 0x00 }, | ||
178 | { 208, 0x00 }, | ||
179 | { 209, 0x00 }, | 170 | { 209, 0x00 }, |
180 | { 210, 0x00 }, | 171 | { 210, 0x08 }, |
181 | { 211, 0x00 }, | 172 | { 211, 0x54 }, |
182 | { 213, 0x00 }, | 173 | { 212, 0x14 }, |
183 | { 214, 0x00 }, | 174 | { 213, 0x0d }, |
184 | { 215, 0x00 }, | 175 | { 214, 0x0d }, |
185 | { 216, 0x00 }, | 176 | { 215, 0x14 }, |
186 | { 217, 0x00 }, | 177 | { 216, 0x60 }, |
187 | { 218, 0x00 }, | ||
188 | { 219, 0x00 }, | ||
189 | { 221, 0x00 }, | 178 | { 221, 0x00 }, |
190 | { 222, 0x00 }, | 179 | { 222, 0x00 }, |
180 | { 223, 0x00 }, | ||
191 | { 224, 0x00 }, | 181 | { 224, 0x00 }, |
192 | { 225, 0x00 }, | ||
193 | { 226, 0x00 }, | ||
194 | { 227, 0x00 }, | ||
195 | { 228, 0x00 }, | ||
196 | { 229, 0x00 }, | ||
197 | { 230, 0x13 }, | ||
198 | { 231, 0x00 }, | ||
199 | { 232, 0x80 }, | ||
200 | { 233, 0x0C }, | ||
201 | { 234, 0xDD }, | ||
202 | { 235, 0x00 }, | ||
203 | { 236, 0x04 }, | ||
204 | { 237, 0x00 }, | ||
205 | { 238, 0x00 }, | ||
206 | { 239, 0x00 }, | ||
207 | { 240, 0x00 }, | ||
208 | { 241, 0x00 }, | ||
209 | { 242, 0x00 }, | ||
210 | { 243, 0x00 }, | ||
211 | { 244, 0x00 }, | ||
212 | { 245, 0x00 }, | ||
213 | { 248, 0x00 }, | 182 | { 248, 0x00 }, |
214 | { 249, 0x00 }, | 183 | { 249, 0x00 }, |
215 | { 254, 0x00 }, | 184 | { 250, 0x00 }, |
216 | { 255, 0x00 }, | 185 | { 255, 0x00 }, |
217 | }; | 186 | }; |
218 | 187 | ||
@@ -525,36 +494,41 @@ SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_PORT2_TX2_REG, 7, 1, 0), | |||
525 | }; | 494 | }; |
526 | 495 | ||
527 | /* TLV Declarations */ | 496 | /* TLV Declarations */ |
528 | static const DECLARE_TLV_DB_SCALE(digital_tlv, -7650, 150, 1); | 497 | static const DECLARE_TLV_DB_SCALE(adc_dac_tlv, -7650, 150, 1); |
529 | static const DECLARE_TLV_DB_SCALE(port_tlv, 0, 600, 0); | 498 | static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 200, 1); |
499 | static const DECLARE_TLV_DB_SCALE(port_tlv, -1800, 600, 0); | ||
500 | static const DECLARE_TLV_DB_SCALE(stn_tlv, -7200, 150, 0); | ||
530 | 501 | ||
531 | static const struct snd_kcontrol_new lm49453_sidetone_mixer_controls[] = { | 502 | static const struct snd_kcontrol_new lm49453_sidetone_mixer_controls[] = { |
532 | /* Sidetone supports mono only */ | 503 | /* Sidetone supports mono only */ |
533 | SOC_DAPM_SINGLE_TLV("Sidetone ADCL Volume", LM49453_P0_STN_VOL_ADCL_REG, | 504 | SOC_DAPM_SINGLE_TLV("Sidetone ADCL Volume", LM49453_P0_STN_VOL_ADCL_REG, |
534 | 0, 0x3F, 0, digital_tlv), | 505 | 0, 0x3F, 0, stn_tlv), |
535 | SOC_DAPM_SINGLE_TLV("Sidetone ADCR Volume", LM49453_P0_STN_VOL_ADCR_REG, | 506 | SOC_DAPM_SINGLE_TLV("Sidetone ADCR Volume", LM49453_P0_STN_VOL_ADCR_REG, |
536 | 0, 0x3F, 0, digital_tlv), | 507 | 0, 0x3F, 0, stn_tlv), |
537 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC1L Volume", LM49453_P0_STN_VOL_DMIC1L_REG, | 508 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC1L Volume", LM49453_P0_STN_VOL_DMIC1L_REG, |
538 | 0, 0x3F, 0, digital_tlv), | 509 | 0, 0x3F, 0, stn_tlv), |
539 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC1R Volume", LM49453_P0_STN_VOL_DMIC1R_REG, | 510 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC1R Volume", LM49453_P0_STN_VOL_DMIC1R_REG, |
540 | 0, 0x3F, 0, digital_tlv), | 511 | 0, 0x3F, 0, stn_tlv), |
541 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC2L Volume", LM49453_P0_STN_VOL_DMIC2L_REG, | 512 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC2L Volume", LM49453_P0_STN_VOL_DMIC2L_REG, |
542 | 0, 0x3F, 0, digital_tlv), | 513 | 0, 0x3F, 0, stn_tlv), |
543 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC2R Volume", LM49453_P0_STN_VOL_DMIC2R_REG, | 514 | SOC_DAPM_SINGLE_TLV("Sidetone DMIC2R Volume", LM49453_P0_STN_VOL_DMIC2R_REG, |
544 | 0, 0x3F, 0, digital_tlv), | 515 | 0, 0x3F, 0, stn_tlv), |
545 | }; | 516 | }; |
546 | 517 | ||
547 | static const struct snd_kcontrol_new lm49453_snd_controls[] = { | 518 | static const struct snd_kcontrol_new lm49453_snd_controls[] = { |
548 | /* mic1 and mic2 supports mono only */ | 519 | /* mic1 and mic2 supports mono only */ |
549 | SOC_SINGLE_TLV("Mic1 Volume", LM49453_P0_ADC_LEVELL_REG, 0, 6, | 520 | SOC_SINGLE_TLV("Mic1 Volume", LM49453_P0_MICL_REG, 0, 15, 0, mic_tlv), |
550 | 0, digital_tlv), | 521 | SOC_SINGLE_TLV("Mic2 Volume", LM49453_P0_MICR_REG, 0, 15, 0, mic_tlv), |
551 | SOC_SINGLE_TLV("Mic2 Volume", LM49453_P0_ADC_LEVELR_REG, 0, 6, | 522 | |
552 | 0, digital_tlv), | 523 | SOC_SINGLE_TLV("ADCL Volume", LM49453_P0_ADC_LEVELL_REG, 0, 63, |
524 | 0, adc_dac_tlv), | ||
525 | SOC_SINGLE_TLV("ADCR Volume", LM49453_P0_ADC_LEVELR_REG, 0, 63, | ||
526 | 0, adc_dac_tlv), | ||
553 | 527 | ||
554 | SOC_DOUBLE_R_TLV("DMIC1 Volume", LM49453_P0_DMIC1_LEVELL_REG, | 528 | SOC_DOUBLE_R_TLV("DMIC1 Volume", LM49453_P0_DMIC1_LEVELL_REG, |
555 | LM49453_P0_DMIC1_LEVELR_REG, 0, 6, 0, digital_tlv), | 529 | LM49453_P0_DMIC1_LEVELR_REG, 0, 63, 0, adc_dac_tlv), |
556 | SOC_DOUBLE_R_TLV("DMIC2 Volume", LM49453_P0_DMIC2_LEVELL_REG, | 530 | SOC_DOUBLE_R_TLV("DMIC2 Volume", LM49453_P0_DMIC2_LEVELL_REG, |
557 | LM49453_P0_DMIC2_LEVELR_REG, 0, 6, 0, digital_tlv), | 531 | LM49453_P0_DMIC2_LEVELR_REG, 0, 63, 0, adc_dac_tlv), |
558 | 532 | ||
559 | SOC_DAPM_ENUM("Mic2Mode", lm49453_mic2mode_enum), | 533 | SOC_DAPM_ENUM("Mic2Mode", lm49453_mic2mode_enum), |
560 | SOC_DAPM_ENUM("DMIC12 SRC", lm49453_dmic12_cfg_enum), | 534 | SOC_DAPM_ENUM("DMIC12 SRC", lm49453_dmic12_cfg_enum), |
@@ -569,16 +543,16 @@ static const struct snd_kcontrol_new lm49453_snd_controls[] = { | |||
569 | 2, 1, 0), | 543 | 2, 1, 0), |
570 | 544 | ||
571 | SOC_DOUBLE_R_TLV("DAC HP Volume", LM49453_P0_DAC_HP_LEVELL_REG, | 545 | SOC_DOUBLE_R_TLV("DAC HP Volume", LM49453_P0_DAC_HP_LEVELL_REG, |
572 | LM49453_P0_DAC_HP_LEVELR_REG, 0, 6, 0, digital_tlv), | 546 | LM49453_P0_DAC_HP_LEVELR_REG, 0, 63, 0, adc_dac_tlv), |
573 | SOC_DOUBLE_R_TLV("DAC LO Volume", LM49453_P0_DAC_LO_LEVELL_REG, | 547 | SOC_DOUBLE_R_TLV("DAC LO Volume", LM49453_P0_DAC_LO_LEVELL_REG, |
574 | LM49453_P0_DAC_LO_LEVELR_REG, 0, 6, 0, digital_tlv), | 548 | LM49453_P0_DAC_LO_LEVELR_REG, 0, 63, 0, adc_dac_tlv), |
575 | SOC_DOUBLE_R_TLV("DAC LS Volume", LM49453_P0_DAC_LS_LEVELL_REG, | 549 | SOC_DOUBLE_R_TLV("DAC LS Volume", LM49453_P0_DAC_LS_LEVELL_REG, |
576 | LM49453_P0_DAC_LS_LEVELR_REG, 0, 6, 0, digital_tlv), | 550 | LM49453_P0_DAC_LS_LEVELR_REG, 0, 63, 0, adc_dac_tlv), |
577 | SOC_DOUBLE_R_TLV("DAC HA Volume", LM49453_P0_DAC_HA_LEVELL_REG, | 551 | SOC_DOUBLE_R_TLV("DAC HA Volume", LM49453_P0_DAC_HA_LEVELL_REG, |
578 | LM49453_P0_DAC_HA_LEVELR_REG, 0, 6, 0, digital_tlv), | 552 | LM49453_P0_DAC_HA_LEVELR_REG, 0, 63, 0, adc_dac_tlv), |
579 | 553 | ||
580 | SOC_SINGLE_TLV("EP Volume", LM49453_P0_DAC_LS_LEVELL_REG, | 554 | SOC_SINGLE_TLV("EP Volume", LM49453_P0_DAC_LS_LEVELL_REG, |
581 | 0, 6, 0, digital_tlv), | 555 | 0, 63, 0, adc_dac_tlv), |
582 | 556 | ||
583 | SOC_SINGLE_TLV("PORT1_1_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL1_REG, | 557 | SOC_SINGLE_TLV("PORT1_1_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL1_REG, |
584 | 0, 3, 0, port_tlv), | 558 | 0, 3, 0, port_tlv), |
@@ -1218,7 +1192,7 @@ static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
1218 | } | 1192 | } |
1219 | 1193 | ||
1220 | snd_soc_update_bits(codec, LM49453_P0_AUDIO_PORT1_BASIC_REG, | 1194 | snd_soc_update_bits(codec, LM49453_P0_AUDIO_PORT1_BASIC_REG, |
1221 | LM49453_AUDIO_PORT1_BASIC_FMT_MASK|BIT(1)|BIT(5), | 1195 | LM49453_AUDIO_PORT1_BASIC_FMT_MASK|BIT(0)|BIT(5), |
1222 | (aif_val | mode | clk_phase)); | 1196 | (aif_val | mode | clk_phase)); |
1223 | 1197 | ||
1224 | snd_soc_write(codec, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift); | 1198 | snd_soc_write(codec, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift); |
@@ -1483,8 +1457,8 @@ static const struct regmap_config lm49453_regmap_config = { | |||
1483 | .cache_type = REGCACHE_RBTREE, | 1457 | .cache_type = REGCACHE_RBTREE, |
1484 | }; | 1458 | }; |
1485 | 1459 | ||
1486 | static __devinit int lm49453_i2c_probe(struct i2c_client *i2c, | 1460 | static int lm49453_i2c_probe(struct i2c_client *i2c, |
1487 | const struct i2c_device_id *id) | 1461 | const struct i2c_device_id *id) |
1488 | { | 1462 | { |
1489 | struct lm49453_priv *lm49453; | 1463 | struct lm49453_priv *lm49453; |
1490 | int ret = 0; | 1464 | int ret = 0; |
@@ -1497,7 +1471,7 @@ static __devinit int lm49453_i2c_probe(struct i2c_client *i2c, | |||
1497 | 1471 | ||
1498 | i2c_set_clientdata(i2c, lm49453); | 1472 | i2c_set_clientdata(i2c, lm49453); |
1499 | 1473 | ||
1500 | lm49453->regmap = regmap_init_i2c(i2c, &lm49453_regmap_config); | 1474 | lm49453->regmap = devm_regmap_init_i2c(i2c, &lm49453_regmap_config); |
1501 | if (IS_ERR(lm49453->regmap)) { | 1475 | if (IS_ERR(lm49453->regmap)) { |
1502 | ret = PTR_ERR(lm49453->regmap); | 1476 | ret = PTR_ERR(lm49453->regmap); |
1503 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | 1477 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", |
@@ -1508,21 +1482,15 @@ static __devinit int lm49453_i2c_probe(struct i2c_client *i2c, | |||
1508 | ret = snd_soc_register_codec(&i2c->dev, | 1482 | ret = snd_soc_register_codec(&i2c->dev, |
1509 | &soc_codec_dev_lm49453, | 1483 | &soc_codec_dev_lm49453, |
1510 | lm49453_dai, ARRAY_SIZE(lm49453_dai)); | 1484 | lm49453_dai, ARRAY_SIZE(lm49453_dai)); |
1511 | if (ret < 0) { | 1485 | if (ret < 0) |
1512 | dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); | 1486 | dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); |
1513 | regmap_exit(lm49453->regmap); | ||
1514 | return ret; | ||
1515 | } | ||
1516 | 1487 | ||
1517 | return ret; | 1488 | return ret; |
1518 | } | 1489 | } |
1519 | 1490 | ||
1520 | static int __devexit lm49453_i2c_remove(struct i2c_client *client) | 1491 | static int lm49453_i2c_remove(struct i2c_client *client) |
1521 | { | 1492 | { |
1522 | struct lm49453_priv *lm49453 = i2c_get_clientdata(client); | ||
1523 | |||
1524 | snd_soc_unregister_codec(&client->dev); | 1493 | snd_soc_unregister_codec(&client->dev); |
1525 | regmap_exit(lm49453->regmap); | ||
1526 | return 0; | 1494 | return 0; |
1527 | } | 1495 | } |
1528 | 1496 | ||
@@ -1538,7 +1506,7 @@ static struct i2c_driver lm49453_i2c_driver = { | |||
1538 | .owner = THIS_MODULE, | 1506 | .owner = THIS_MODULE, |
1539 | }, | 1507 | }, |
1540 | .probe = lm49453_i2c_probe, | 1508 | .probe = lm49453_i2c_probe, |
1541 | .remove = __devexit_p(lm49453_i2c_remove), | 1509 | .remove = lm49453_i2c_remove, |
1542 | .id_table = lm49453_i2c_id, | 1510 | .id_table = lm49453_i2c_id, |
1543 | }; | 1511 | }; |
1544 | 1512 | ||