Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: sound/soc/codecs/cs42l51.c

Issue 6577007: CHROMIUM: ASoC: Import entire upstream ASoC tree (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sound/soc/codecs/cs4271.c ('k') | sound/soc/codecs/cx20442.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * cs42l51.c 2 * cs42l51.c
3 * 3 *
4 * ASoC Driver for Cirrus Logic CS42L51 codecs 4 * ASoC Driver for Cirrus Logic CS42L51 codecs
5 * 5 *
6 * Copyright (c) 2010 Arnaud Patard <apatard@mandriva.com> 6 * Copyright (c) 2010 Arnaud Patard <apatard@mandriva.com>
7 * 7 *
8 * Based on cs4270.c - Copyright (c) Freescale Semiconductor 8 * Based on cs4270.c - Copyright (c) Freescale Semiconductor
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * For now: 19 * For now:
20 * - Only I2C is support. Not SPI 20 * - Only I2C is support. Not SPI
21 * - master mode *NOT* supported 21 * - master mode *NOT* supported
22 */ 22 */
23 23
24 #include <linux/module.h> 24 #include <linux/module.h>
25 #include <linux/platform_device.h> 25 #include <linux/platform_device.h>
26 #include <linux/slab.h> 26 #include <linux/slab.h>
27 #include <sound/core.h> 27 #include <sound/core.h>
28 #include <sound/soc.h> 28 #include <sound/soc.h>
29 #include <sound/soc-dapm.h>
30 #include <sound/tlv.h> 29 #include <sound/tlv.h>
31 #include <sound/initval.h> 30 #include <sound/initval.h>
32 #include <sound/pcm_params.h> 31 #include <sound/pcm_params.h>
33 #include <sound/pcm.h> 32 #include <sound/pcm.h>
34 #include <linux/i2c.h> 33 #include <linux/i2c.h>
35 34
36 #include "cs42l51.h" 35 #include "cs42l51.h"
37 36
38 enum master_slave_mode { 37 enum master_slave_mode {
39 MODE_SLAVE, 38 MODE_SLAVE,
40 MODE_SLAVE_AUTO, 39 MODE_SLAVE_AUTO,
41 MODE_MASTER, 40 MODE_MASTER,
42 }; 41 };
43 42
44 struct cs42l51_private { 43 struct cs42l51_private {
45 enum snd_soc_control_type control_type; 44 enum snd_soc_control_type control_type;
46 void *control_data; 45 void *control_data;
47 unsigned int mclk; 46 unsigned int mclk;
48 unsigned int audio_mode; /* The mode (I2S or left-justified) */ 47 unsigned int audio_mode; /* The mode (I2S or left-justified) */
49 enum master_slave_mode func; 48 enum master_slave_mode func;
50 u8 reg_cache[CS42L51_NUMREGS];
51 }; 49 };
52 50
53 #define CS42L51_FORMATS ( \ 51 #define CS42L51_FORMATS ( \
54 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \ 52 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \
55 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \ 53 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \
56 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \ 54 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \
57 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE) 55 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE)
58 56
59 static int cs42l51_fill_cache(struct snd_soc_codec *codec) 57 static int cs42l51_fill_cache(struct snd_soc_codec *codec)
60 { 58 {
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 .channels_max = 2, 510 .channels_max = 2,
513 .rates = SNDRV_PCM_RATE_8000_96000, 511 .rates = SNDRV_PCM_RATE_8000_96000,
514 .formats = CS42L51_FORMATS, 512 .formats = CS42L51_FORMATS,
515 }, 513 },
516 .ops = &cs42l51_dai_ops, 514 .ops = &cs42l51_dai_ops,
517 }; 515 };
518 516
519 static int cs42l51_probe(struct snd_soc_codec *codec) 517 static int cs42l51_probe(struct snd_soc_codec *codec)
520 { 518 {
521 struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec); 519 struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec);
520 struct snd_soc_dapm_context *dapm = &codec->dapm;
522 int ret, reg; 521 int ret, reg;
523 522
524 codec->control_data = cs42l51->control_data; 523 codec->control_data = cs42l51->control_data;
525 524
526 ret = cs42l51_fill_cache(codec); 525 ret = cs42l51_fill_cache(codec);
527 if (ret < 0) { 526 if (ret < 0) {
528 dev_err(codec->dev, "failed to fill register cache\n"); 527 dev_err(codec->dev, "failed to fill register cache\n");
529 return ret; 528 return ret;
530 } 529 }
531 530
(...skipping 11 matching lines...) Expand all
543 * - no de-emphasize 542 * - no de-emphasize
544 */ 543 */
545 reg = CS42L51_DAC_CTL_DATA_SEL(1) 544 reg = CS42L51_DAC_CTL_DATA_SEL(1)
546 | CS42L51_DAC_CTL_AMUTE | CS42L51_DAC_CTL_DACSZ(0); 545 | CS42L51_DAC_CTL_AMUTE | CS42L51_DAC_CTL_DACSZ(0);
547 ret = snd_soc_write(codec, CS42L51_DAC_CTL, reg); 546 ret = snd_soc_write(codec, CS42L51_DAC_CTL, reg);
548 if (ret < 0) 547 if (ret < 0)
549 return ret; 548 return ret;
550 549
551 snd_soc_add_controls(codec, cs42l51_snd_controls, 550 snd_soc_add_controls(codec, cs42l51_snd_controls,
552 ARRAY_SIZE(cs42l51_snd_controls)); 551 ARRAY_SIZE(cs42l51_snd_controls));
553 » snd_soc_dapm_new_controls(codec, cs42l51_dapm_widgets, 552 » snd_soc_dapm_new_controls(dapm, cs42l51_dapm_widgets,
554 ARRAY_SIZE(cs42l51_dapm_widgets)); 553 ARRAY_SIZE(cs42l51_dapm_widgets));
555 » snd_soc_dapm_add_routes(codec, cs42l51_routes, 554 » snd_soc_dapm_add_routes(dapm, cs42l51_routes,
556 ARRAY_SIZE(cs42l51_routes)); 555 ARRAY_SIZE(cs42l51_routes));
557 556
558 return 0; 557 return 0;
559 } 558 }
560 559
561 static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { 560 static struct snd_soc_codec_driver soc_codec_device_cs42l51 = {
562 .probe = cs42l51_probe, 561 .probe = cs42l51_probe,
563 .reg_cache_size = CS42L51_NUMREGS, 562 .reg_cache_size = CS42L51_NUMREGS,
564 .reg_word_size = sizeof(u8), 563 .reg_word_size = sizeof(u8),
565 }; 564 };
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 644
646 static void __exit cs42l51_exit(void) 645 static void __exit cs42l51_exit(void)
647 { 646 {
648 i2c_del_driver(&cs42l51_i2c_driver); 647 i2c_del_driver(&cs42l51_i2c_driver);
649 } 648 }
650 module_exit(cs42l51_exit); 649 module_exit(cs42l51_exit);
651 650
652 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); 651 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
653 MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver"); 652 MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver");
654 MODULE_LICENSE("GPL"); 653 MODULE_LICENSE("GPL");
OLDNEW
« no previous file with comments | « sound/soc/codecs/cs4271.c ('k') | sound/soc/codecs/cx20442.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698