aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ssm2602.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/ssm2602.c')
-rw-r--r--sound/soc/codecs/ssm2602.c58
1 files changed, 23 insertions, 35 deletions
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index cac373616768..87f606c76822 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -151,21 +151,6 @@ SOC_ENUM("Capture Source", ssm2602_enum[0]),
151SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]), 151SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]),
152}; 152};
153 153
154/* add non dapm controls */
155static int ssm2602_add_controls(struct snd_soc_codec *codec)
156{
157 int err, i;
158
159 for (i = 0; i < ARRAY_SIZE(ssm2602_snd_controls); i++) {
160 err = snd_ctl_add(codec->card,
161 snd_soc_cnew(&ssm2602_snd_controls[i], codec, NULL));
162 if (err < 0)
163 return err;
164 }
165
166 return 0;
167}
168
169/* Output Mixer */ 154/* Output Mixer */
170static const struct snd_kcontrol_new ssm2602_output_mixer_controls[] = { 155static const struct snd_kcontrol_new ssm2602_output_mixer_controls[] = {
171SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0), 156SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0),
@@ -291,7 +276,7 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream,
291 u16 srate; 276 u16 srate;
292 struct snd_soc_pcm_runtime *rtd = substream->private_data; 277 struct snd_soc_pcm_runtime *rtd = substream->private_data;
293 struct snd_soc_device *socdev = rtd->socdev; 278 struct snd_soc_device *socdev = rtd->socdev;
294 struct snd_soc_codec *codec = socdev->codec; 279 struct snd_soc_codec *codec = socdev->card->codec;
295 struct ssm2602_priv *ssm2602 = codec->private_data; 280 struct ssm2602_priv *ssm2602 = codec->private_data;
296 struct i2c_client *i2c = codec->control_data; 281 struct i2c_client *i2c = codec->control_data;
297 u16 iface = ssm2602_read_reg_cache(codec, SSM2602_IFACE) & 0xfff3; 282 u16 iface = ssm2602_read_reg_cache(codec, SSM2602_IFACE) & 0xfff3;
@@ -336,7 +321,7 @@ static int ssm2602_startup(struct snd_pcm_substream *substream,
336{ 321{
337 struct snd_soc_pcm_runtime *rtd = substream->private_data; 322 struct snd_soc_pcm_runtime *rtd = substream->private_data;
338 struct snd_soc_device *socdev = rtd->socdev; 323 struct snd_soc_device *socdev = rtd->socdev;
339 struct snd_soc_codec *codec = socdev->codec; 324 struct snd_soc_codec *codec = socdev->card->codec;
340 struct ssm2602_priv *ssm2602 = codec->private_data; 325 struct ssm2602_priv *ssm2602 = codec->private_data;
341 struct i2c_client *i2c = codec->control_data; 326 struct i2c_client *i2c = codec->control_data;
342 struct snd_pcm_runtime *master_runtime; 327 struct snd_pcm_runtime *master_runtime;
@@ -373,7 +358,7 @@ static int ssm2602_pcm_prepare(struct snd_pcm_substream *substream,
373{ 358{
374 struct snd_soc_pcm_runtime *rtd = substream->private_data; 359 struct snd_soc_pcm_runtime *rtd = substream->private_data;
375 struct snd_soc_device *socdev = rtd->socdev; 360 struct snd_soc_device *socdev = rtd->socdev;
376 struct snd_soc_codec *codec = socdev->codec; 361 struct snd_soc_codec *codec = socdev->card->codec;
377 /* set active */ 362 /* set active */
378 ssm2602_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC); 363 ssm2602_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC);
379 364
@@ -385,7 +370,7 @@ static void ssm2602_shutdown(struct snd_pcm_substream *substream,
385{ 370{
386 struct snd_soc_pcm_runtime *rtd = substream->private_data; 371 struct snd_soc_pcm_runtime *rtd = substream->private_data;
387 struct snd_soc_device *socdev = rtd->socdev; 372 struct snd_soc_device *socdev = rtd->socdev;
388 struct snd_soc_codec *codec = socdev->codec; 373 struct snd_soc_codec *codec = socdev->card->codec;
389 struct ssm2602_priv *ssm2602 = codec->private_data; 374 struct ssm2602_priv *ssm2602 = codec->private_data;
390 /* deactivate */ 375 /* deactivate */
391 if (!codec->active) 376 if (!codec->active)
@@ -521,6 +506,16 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec,
521#define SSM2602_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 506#define SSM2602_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
522 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 507 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
523 508
509static struct snd_soc_dai_ops ssm2602_dai_ops = {
510 .startup = ssm2602_startup,
511 .prepare = ssm2602_pcm_prepare,
512 .hw_params = ssm2602_hw_params,
513 .shutdown = ssm2602_shutdown,
514 .digital_mute = ssm2602_mute,
515 .set_sysclk = ssm2602_set_dai_sysclk,
516 .set_fmt = ssm2602_set_dai_fmt,
517};
518
524struct snd_soc_dai ssm2602_dai = { 519struct snd_soc_dai ssm2602_dai = {
525 .name = "SSM2602", 520 .name = "SSM2602",
526 .playback = { 521 .playback = {
@@ -535,22 +530,14 @@ struct snd_soc_dai ssm2602_dai = {
535 .channels_max = 2, 530 .channels_max = 2,
536 .rates = SSM2602_RATES, 531 .rates = SSM2602_RATES,
537 .formats = SSM2602_FORMATS,}, 532 .formats = SSM2602_FORMATS,},
538 .ops = { 533 .ops = &ssm2602_dai_ops,
539 .startup = ssm2602_startup,
540 .prepare = ssm2602_pcm_prepare,
541 .hw_params = ssm2602_hw_params,
542 .shutdown = ssm2602_shutdown,
543 .digital_mute = ssm2602_mute,
544 .set_sysclk = ssm2602_set_dai_sysclk,
545 .set_fmt = ssm2602_set_dai_fmt,
546 }
547}; 534};
548EXPORT_SYMBOL_GPL(ssm2602_dai); 535EXPORT_SYMBOL_GPL(ssm2602_dai);
549 536
550static int ssm2602_suspend(struct platform_device *pdev, pm_message_t state) 537static int ssm2602_suspend(struct platform_device *pdev, pm_message_t state)
551{ 538{
552 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 539 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
553 struct snd_soc_codec *codec = socdev->codec; 540 struct snd_soc_codec *codec = socdev->card->codec;
554 541
555 ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF); 542 ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF);
556 return 0; 543 return 0;
@@ -559,7 +546,7 @@ static int ssm2602_suspend(struct platform_device *pdev, pm_message_t state)
559static int ssm2602_resume(struct platform_device *pdev) 546static int ssm2602_resume(struct platform_device *pdev)
560{ 547{
561 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 548 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
562 struct snd_soc_codec *codec = socdev->codec; 549 struct snd_soc_codec *codec = socdev->card->codec;
563 int i; 550 int i;
564 u8 data[2]; 551 u8 data[2];
565 u16 *cache = codec->reg_cache; 552 u16 *cache = codec->reg_cache;
@@ -581,7 +568,7 @@ static int ssm2602_resume(struct platform_device *pdev)
581 */ 568 */
582static int ssm2602_init(struct snd_soc_device *socdev) 569static int ssm2602_init(struct snd_soc_device *socdev)
583{ 570{
584 struct snd_soc_codec *codec = socdev->codec; 571 struct snd_soc_codec *codec = socdev->card->codec;
585 int reg, ret = 0; 572 int reg, ret = 0;
586 573
587 codec->name = "SSM2602"; 574 codec->name = "SSM2602";
@@ -622,7 +609,8 @@ static int ssm2602_init(struct snd_soc_device *socdev)
622 APANA_ENABLE_MIC_BOOST); 609 APANA_ENABLE_MIC_BOOST);
623 ssm2602_write(codec, SSM2602_PWR, 0); 610 ssm2602_write(codec, SSM2602_PWR, 0);
624 611
625 ssm2602_add_controls(codec); 612 snd_soc_add_controls(codec, ssm2602_snd_controls,
613 ARRAY_SIZE(ssm2602_snd_controls));
626 ssm2602_add_widgets(codec); 614 ssm2602_add_widgets(codec);
627 ret = snd_soc_init_card(socdev); 615 ret = snd_soc_init_card(socdev);
628 if (ret < 0) { 616 if (ret < 0) {
@@ -653,7 +641,7 @@ static int ssm2602_i2c_probe(struct i2c_client *i2c,
653 const struct i2c_device_id *id) 641 const struct i2c_device_id *id)
654{ 642{
655 struct snd_soc_device *socdev = ssm2602_socdev; 643 struct snd_soc_device *socdev = ssm2602_socdev;
656 struct snd_soc_codec *codec = socdev->codec; 644 struct snd_soc_codec *codec = socdev->card->codec;
657 int ret; 645 int ret;
658 646
659 i2c_set_clientdata(i2c, codec); 647 i2c_set_clientdata(i2c, codec);
@@ -747,7 +735,7 @@ static int ssm2602_probe(struct platform_device *pdev)
747 } 735 }
748 736
749 codec->private_data = ssm2602; 737 codec->private_data = ssm2602;
750 socdev->codec = codec; 738 socdev->card->codec = codec;
751 mutex_init(&codec->mutex); 739 mutex_init(&codec->mutex);
752 INIT_LIST_HEAD(&codec->dapm_widgets); 740 INIT_LIST_HEAD(&codec->dapm_widgets);
753 INIT_LIST_HEAD(&codec->dapm_paths); 741 INIT_LIST_HEAD(&codec->dapm_paths);
@@ -768,7 +756,7 @@ static int ssm2602_probe(struct platform_device *pdev)
768static int ssm2602_remove(struct platform_device *pdev) 756static int ssm2602_remove(struct platform_device *pdev)
769{ 757{
770 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 758 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
771 struct snd_soc_codec *codec = socdev->codec; 759 struct snd_soc_codec *codec = socdev->card->codec;
772 760
773 if (codec->control_data) 761 if (codec->control_data)
774 ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF); 762 ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF);