Linux Audio

Check our new training course

Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * wm8727.c
 4 *
 5 *  Created on: 15-Oct-2009
 6 *      Author: neil.jones@imgtec.com
 7 *
 8 * Copyright (C) 2009 Imagination Technologies Ltd.
 
 
 
 
 
 9 */
10
11#include <linux/init.h>
12#include <linux/slab.h>
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/device.h>
16#include <sound/core.h>
17#include <sound/pcm.h>
 
18#include <sound/initval.h>
19#include <sound/soc.h>
20
21static const struct snd_soc_dapm_widget wm8727_dapm_widgets[] = {
22SND_SOC_DAPM_OUTPUT("VOUTL"),
23SND_SOC_DAPM_OUTPUT("VOUTR"),
24};
25
26static const struct snd_soc_dapm_route wm8727_dapm_routes[] = {
27	{ "VOUTL", NULL, "Playback" },
28	{ "VOUTR", NULL, "Playback" },
29};
30
31/*
32 * Note this is a simple chip with no configuration interface, sample rate is
33 * determined automatically by examining the Master clock and Bit clock ratios
34 */
35#define WM8727_RATES  (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
36			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
37			SNDRV_PCM_RATE_192000)
38
 
39static struct snd_soc_dai_driver wm8727_dai = {
40	.name = "wm8727-hifi",
41	.playback = {
42		.stream_name = "Playback",
43		.channels_min = 2,
44		.channels_max = 2,
45		.rates = WM8727_RATES,
46		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
47		},
48};
49
50static const struct snd_soc_component_driver soc_component_dev_wm8727 = {
51	.dapm_widgets		= wm8727_dapm_widgets,
52	.num_dapm_widgets	= ARRAY_SIZE(wm8727_dapm_widgets),
53	.dapm_routes		= wm8727_dapm_routes,
54	.num_dapm_routes	= ARRAY_SIZE(wm8727_dapm_routes),
55	.idle_bias_on		= 1,
56	.use_pmdown_time	= 1,
57	.endianness		= 1,
58};
59
60static int wm8727_probe(struct platform_device *pdev)
61{
62	return devm_snd_soc_register_component(&pdev->dev,
63			&soc_component_dev_wm8727, &wm8727_dai, 1);
 
 
 
 
 
 
64}
65
66static struct platform_driver wm8727_codec_driver = {
67	.driver = {
68			.name = "wm8727",
 
69	},
70
71	.probe = wm8727_probe,
 
72};
73
74module_platform_driver(wm8727_codec_driver);
75
76MODULE_DESCRIPTION("ASoC wm8727 driver");
77MODULE_AUTHOR("Neil Jones");
78MODULE_LICENSE("GPL");
v3.15
 
 1/*
 2 * wm8727.c
 3 *
 4 *  Created on: 15-Oct-2009
 5 *      Author: neil.jones@imgtec.com
 6 *
 7 * Copyright (C) 2009 Imagination Technologies Ltd.
 8 *
 9 *  This program is free software; you can redistribute  it and/or modify it
10 *  under  the terms of  the GNU General  Public License as published by the
11 *  Free Software Foundation;  either version 2 of the  License, or (at your
12 *  option) any later version.
13 */
14
15#include <linux/init.h>
16#include <linux/slab.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/device.h>
20#include <sound/core.h>
21#include <sound/pcm.h>
22#include <sound/ac97_codec.h>
23#include <sound/initval.h>
24#include <sound/soc.h>
25
26static const struct snd_soc_dapm_widget wm8727_dapm_widgets[] = {
27SND_SOC_DAPM_OUTPUT("VOUTL"),
28SND_SOC_DAPM_OUTPUT("VOUTR"),
29};
30
31static const struct snd_soc_dapm_route wm8727_dapm_routes[] = {
32	{ "VOUTL", NULL, "Playback" },
33	{ "VOUTR", NULL, "Playback" },
34};
35
36/*
37 * Note this is a simple chip with no configuration interface, sample rate is
38 * determined automatically by examining the Master clock and Bit clock ratios
39 */
40#define WM8727_RATES  (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
41			SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
42			SNDRV_PCM_RATE_192000)
43
44
45static struct snd_soc_dai_driver wm8727_dai = {
46	.name = "wm8727-hifi",
47	.playback = {
48		.stream_name = "Playback",
49		.channels_min = 2,
50		.channels_max = 2,
51		.rates = WM8727_RATES,
52		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
53		},
54};
55
56static struct snd_soc_codec_driver soc_codec_dev_wm8727 = {
57	.dapm_widgets = wm8727_dapm_widgets,
58	.num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets),
59	.dapm_routes = wm8727_dapm_routes,
60	.num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes),
 
 
 
61};
62
63static int wm8727_probe(struct platform_device *pdev)
64{
65	return snd_soc_register_codec(&pdev->dev,
66			&soc_codec_dev_wm8727, &wm8727_dai, 1);
67}
68
69static int wm8727_remove(struct platform_device *pdev)
70{
71	snd_soc_unregister_codec(&pdev->dev);
72	return 0;
73}
74
75static struct platform_driver wm8727_codec_driver = {
76	.driver = {
77			.name = "wm8727",
78			.owner = THIS_MODULE,
79	},
80
81	.probe = wm8727_probe,
82	.remove = wm8727_remove,
83};
84
85module_platform_driver(wm8727_codec_driver);
86
87MODULE_DESCRIPTION("ASoC wm8727 driver");
88MODULE_AUTHOR("Neil Jones");
89MODULE_LICENSE("GPL");