forked from raspberrypi/linux
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It adds a dummy codec driver (no controls) for ESS9018 and a corresponding machine driver for BCM2708. Signed-off-by: Florian Meier <[email protected]>
- Loading branch information
Showing
7 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* ASoC driver for ESS9018 codec | ||
* connected to a Raspberry Pi | ||
* | ||
* Author: Florian Meier, <[email protected]> | ||
* Copyright 2013 | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/platform_device.h> | ||
|
||
#include <sound/core.h> | ||
#include <sound/pcm.h> | ||
#include <sound/soc.h> | ||
#include <sound/jack.h> | ||
|
||
static int snd_rpi_ess9018_init(struct snd_soc_pcm_runtime *rtd) | ||
{ | ||
return 0; | ||
} | ||
|
||
static int snd_rpi_ess9018_hw_params(struct snd_pcm_substream *substream, | ||
struct snd_pcm_hw_params *params) | ||
{ | ||
return 0; | ||
} | ||
|
||
/* machine stream operations */ | ||
static struct snd_soc_ops snd_rpi_ess9018_ops = { | ||
.hw_params = snd_rpi_ess9018_hw_params, | ||
}; | ||
|
||
static struct snd_soc_dai_link snd_rpi_ess9018_dai[] = { | ||
{ | ||
.name = "ESS9018", | ||
.stream_name = "ESS9018 HiFi", | ||
.cpu_dai_name = "bcm2708-i2s.0", | ||
.codec_dai_name = "ess9018-hifi", | ||
.platform_name = "bcm2708-pcm-audio.0", | ||
.codec_name = "ess9018-codec", | ||
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
SND_SOC_DAIFMT_CBS_CFS, | ||
.ops = &snd_rpi_ess9018_ops, | ||
.init = snd_rpi_ess9018_init, | ||
}, | ||
}; | ||
|
||
/* audio machine driver */ | ||
static struct snd_soc_card snd_rpi_ess9018 = { | ||
.name = "snd_rpi_ess9018", | ||
.dai_link = snd_rpi_ess9018_dai, | ||
.num_links = ARRAY_SIZE(snd_rpi_ess9018_dai), | ||
}; | ||
|
||
static int snd_rpi_ess9018_probe(struct platform_device *pdev) | ||
{ | ||
int ret = 0; | ||
|
||
snd_rpi_ess9018.dev = &pdev->dev; | ||
ret = snd_soc_register_card(&snd_rpi_ess9018); | ||
if (ret) | ||
{ | ||
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
|
||
static int snd_rpi_ess9018_remove(struct platform_device *pdev) | ||
{ | ||
return snd_soc_unregister_card(&snd_rpi_ess9018); | ||
} | ||
|
||
static struct platform_driver snd_rpi_ess9018_driver = { | ||
.driver = { | ||
.name = "snd-rpi-ess9018", | ||
.owner = THIS_MODULE, | ||
}, | ||
.probe = snd_rpi_ess9018_probe, | ||
.remove = snd_rpi_ess9018_remove, | ||
}; | ||
|
||
module_platform_driver(snd_rpi_ess9018_driver); | ||
|
||
MODULE_AUTHOR("Florian Meier"); | ||
MODULE_DESCRIPTION("ASoC Driver for Raspberry Pi connected to a ESS9018"); | ||
MODULE_LICENSE("GPL"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Driver for the ESS9018 codec | ||
* It is a dummy driver without any controls. | ||
* | ||
* Copyright 2013 Florian Meier <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. | ||
* | ||
*/ | ||
|
||
#include <linux/init.h> | ||
#include <linux/module.h> | ||
#include <linux/platform_device.h> | ||
|
||
#include <sound/soc.h> | ||
|
||
static struct snd_soc_dai_driver ess9018_dai = { | ||
.name = "ess9018-hifi", | ||
.playback = { | ||
.channels_min = 1, | ||
.channels_max = 8, | ||
.rates = SNDRV_PCM_RATE_8000_192000, | ||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE | ||
}, | ||
}; | ||
|
||
static struct snd_soc_codec_driver soc_codec_dev_ess9018; | ||
|
||
static int ess9018_probe(struct platform_device *pdev) | ||
{ | ||
return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_ess9018, | ||
&ess9018_dai, 1); | ||
} | ||
|
||
static int ess9018_remove(struct platform_device *pdev) | ||
{ | ||
snd_soc_unregister_codec(&pdev->dev); | ||
|
||
return 0; | ||
} | ||
|
||
static struct platform_driver ess9018_driver = { | ||
.driver = { | ||
.name = "ess9018-codec", | ||
.owner = THIS_MODULE, | ||
}, | ||
.probe = ess9018_probe, | ||
.remove = ess9018_remove, | ||
}; | ||
|
||
/* | ||
* Register driver and device | ||
* | ||
* TODO This is not the best solution, but it is ok for now. | ||
* Later this should be handled by the device tree. | ||
*/ | ||
|
||
static struct platform_device *pdev; | ||
|
||
static const struct platform_device_info ess9018_dev_info = { | ||
.name = "ess9018-codec", | ||
.id = -1, | ||
}; | ||
|
||
static int ess9018_init(void) | ||
{ | ||
int rc = platform_driver_register(&ess9018_driver); | ||
|
||
if (rc == 0) { | ||
pdev = platform_device_register_full(&ess9018_dev_info); | ||
if (IS_ERR(pdev)) { | ||
platform_driver_unregister(&ess9018_driver); | ||
rc = PTR_ERR(pdev); | ||
} | ||
} | ||
return rc; | ||
} | ||
subsys_initcall(ess9018_init); | ||
|
||
static void __exit ess9018_exit(void) | ||
{ | ||
platform_device_unregister(pdev); | ||
platform_driver_unregister(&ess9018_driver); | ||
} | ||
module_exit(ess9018_exit); | ||
|
||
MODULE_AUTHOR("Florian Meier <[email protected]>"); | ||
MODULE_DESCRIPTION("ASoC ESS9018 codec driver"); | ||
MODULE_LICENSE("GPL"); | ||
|