Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2// ak4554.c
 3//
 4// Copyright (C) 2013 Renesas Solutions Corp.
 5// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
 
 
 
 
 
 6
 7#include <linux/module.h>
 8#include <sound/soc.h>
 9
10/*
11 * ak4554 is very simple DA/AD converter which has no setting register.
12 *
13 * CAUTION
14 *
15 * ak4554 playback format is SND_SOC_DAIFMT_RIGHT_J,
16 * and,   capture  format is SND_SOC_DAIFMT_LEFT_J
17 * on same bit clock, LR clock.
18 * But, this driver doesn't have snd_soc_dai_ops :: set_fmt
19 *
20 * CPU/Codec DAI image
21 *
22 * CPU-DAI1 (plaback only fmt = RIGHT_J) --+-- ak4554
23 *					   |
24 * CPU-DAI2 (capture only fmt = LEFT_J) ---+
25 */
26
27static const struct snd_soc_dapm_widget ak4554_dapm_widgets[] = {
28SND_SOC_DAPM_INPUT("AINL"),
29SND_SOC_DAPM_INPUT("AINR"),
30
31SND_SOC_DAPM_OUTPUT("AOUTL"),
32SND_SOC_DAPM_OUTPUT("AOUTR"),
33};
34
35static const struct snd_soc_dapm_route ak4554_dapm_routes[] = {
36	{ "Capture", NULL, "AINL" },
37	{ "Capture", NULL, "AINR" },
38
39	{ "AOUTL", NULL, "Playback" },
40	{ "AOUTR", NULL, "Playback" },
41};
42
43static struct snd_soc_dai_driver ak4554_dai = {
44	.name = "ak4554-hifi",
45	.playback = {
46		.stream_name = "Playback",
47		.channels_min = 2,
48		.channels_max = 2,
49		.rates = SNDRV_PCM_RATE_8000_48000,
50		.formats = SNDRV_PCM_FMTBIT_S16_LE,
51	},
52	.capture = {
53		.stream_name = "Capture",
54		.channels_min = 2,
55		.channels_max = 2,
56		.rates = SNDRV_PCM_RATE_8000_48000,
57		.formats = SNDRV_PCM_FMTBIT_S16_LE,
58	},
59	.symmetric_rate = 1,
60};
61
62static const struct snd_soc_component_driver soc_component_dev_ak4554 = {
63	.dapm_widgets		= ak4554_dapm_widgets,
64	.num_dapm_widgets	= ARRAY_SIZE(ak4554_dapm_widgets),
65	.dapm_routes		= ak4554_dapm_routes,
66	.num_dapm_routes	= ARRAY_SIZE(ak4554_dapm_routes),
67	.idle_bias_on		= 1,
68	.use_pmdown_time	= 1,
69	.endianness		= 1,
70};
71
72static int ak4554_soc_probe(struct platform_device *pdev)
73{
74	return devm_snd_soc_register_component(&pdev->dev,
75				      &soc_component_dev_ak4554,
76				      &ak4554_dai, 1);
77}
78
 
 
 
 
 
 
79static const struct of_device_id ak4554_of_match[] = {
80	{ .compatible = "asahi-kasei,ak4554" },
81	{},
82};
83MODULE_DEVICE_TABLE(of, ak4554_of_match);
84
85static struct platform_driver ak4554_driver = {
86	.driver = {
87		.name = "ak4554-adc-dac",
88		.of_match_table = ak4554_of_match,
89	},
90	.probe	= ak4554_soc_probe,
 
91};
92module_platform_driver(ak4554_driver);
93
94MODULE_LICENSE("GPL v2");
95MODULE_DESCRIPTION("SoC AK4554 driver");
96MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
v4.10.11
  1/*
  2 * ak4554.c
  3 *
  4 * Copyright (C) 2013 Renesas Solutions Corp.
  5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6 *
  7 * This program is free software; you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License version 2 as
  9 * published by the Free Software Foundation.
 10 */
 11
 12#include <linux/module.h>
 13#include <sound/soc.h>
 14
 15/*
 16 * ak4554 is very simple DA/AD converter which has no setting register.
 17 *
 18 * CAUTION
 19 *
 20 * ak4554 playback format is SND_SOC_DAIFMT_RIGHT_J,
 21 * and,   capture  format is SND_SOC_DAIFMT_LEFT_J
 22 * on same bit clock, LR clock.
 23 * But, this driver doesn't have snd_soc_dai_ops :: set_fmt
 24 *
 25 * CPU/Codec DAI image
 26 *
 27 * CPU-DAI1 (plaback only fmt = RIGHT_J) --+-- ak4554
 28 *					   |
 29 * CPU-DAI2 (capture only fmt = LEFT_J) ---+
 30 */
 31
 32static const struct snd_soc_dapm_widget ak4554_dapm_widgets[] = {
 33SND_SOC_DAPM_INPUT("AINL"),
 34SND_SOC_DAPM_INPUT("AINR"),
 35
 36SND_SOC_DAPM_OUTPUT("AOUTL"),
 37SND_SOC_DAPM_OUTPUT("AOUTR"),
 38};
 39
 40static const struct snd_soc_dapm_route ak4554_dapm_routes[] = {
 41	{ "Capture", NULL, "AINL" },
 42	{ "Capture", NULL, "AINR" },
 43
 44	{ "AOUTL", NULL, "Playback" },
 45	{ "AOUTR", NULL, "Playback" },
 46};
 47
 48static struct snd_soc_dai_driver ak4554_dai = {
 49	.name = "ak4554-hifi",
 50	.playback = {
 51		.stream_name = "Playback",
 52		.channels_min = 2,
 53		.channels_max = 2,
 54		.rates = SNDRV_PCM_RATE_8000_48000,
 55		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 56	},
 57	.capture = {
 58		.stream_name = "Capture",
 59		.channels_min = 2,
 60		.channels_max = 2,
 61		.rates = SNDRV_PCM_RATE_8000_48000,
 62		.formats = SNDRV_PCM_FMTBIT_S16_LE,
 63	},
 64	.symmetric_rates = 1,
 65};
 66
 67static struct snd_soc_codec_driver soc_codec_dev_ak4554 = {
 68	.component_driver = {
 69		.dapm_widgets		= ak4554_dapm_widgets,
 70		.num_dapm_widgets	= ARRAY_SIZE(ak4554_dapm_widgets),
 71		.dapm_routes		= ak4554_dapm_routes,
 72		.num_dapm_routes	= ARRAY_SIZE(ak4554_dapm_routes),
 73	},
 
 74};
 75
 76static int ak4554_soc_probe(struct platform_device *pdev)
 77{
 78	return snd_soc_register_codec(&pdev->dev,
 79				      &soc_codec_dev_ak4554,
 80				      &ak4554_dai, 1);
 81}
 82
 83static int ak4554_soc_remove(struct platform_device *pdev)
 84{
 85	snd_soc_unregister_codec(&pdev->dev);
 86	return 0;
 87}
 88
 89static const struct of_device_id ak4554_of_match[] = {
 90	{ .compatible = "asahi-kasei,ak4554" },
 91	{},
 92};
 93MODULE_DEVICE_TABLE(of, ak4554_of_match);
 94
 95static struct platform_driver ak4554_driver = {
 96	.driver = {
 97		.name = "ak4554-adc-dac",
 98		.of_match_table = ak4554_of_match,
 99	},
100	.probe	= ak4554_soc_probe,
101	.remove	= ak4554_soc_remove,
102};
103module_platform_driver(ak4554_driver);
104
105MODULE_LICENSE("GPL");
106MODULE_DESCRIPTION("SoC AK4554 driver");
107MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");