Files
android/sound/soc/mediatek/common_int/mtk-soc-pcm-dummy.c
threeeye bc1d038eac REVVL 6 Pro kernel bring-up: full working tree snapshot (2026-09-12)
Squashed backup commit (no shallow-clone history issues) of
xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream
commit 9eece662e) plus all fixes applied to get everpal_defconfig building
clean against a modern (GCC 15.2.0) toolchain -- see the previous commit
message on the lineage-23.2 branch (also in this repo history is not
available here since this is a squashed snapshot; full incremental history
lives in the local DL380 checkout and the upstream GitHub remote).

Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
2026-09-12 13:36:46 +00:00

233 lines
5.8 KiB
C

/*
* Copyright (C) 2015 MediaTek Inc.
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
/*******************************************************************************
*
* Filename:
* ---------
* mt6583.c
*
* Project:
* --------
* MT6583 Audio Driver Kernel Function
*
* Description:
* ------------
* Audio register
*
* Author:
* -------
* Chipeng Chang
*
*------------------------------------------------------------------------------
*
*
******************************************************************************
*/
/*****************************************************************************
* C O M P I L E R F L A G S
*****************************************************************************/
/*****************************************************************************
* E X T E R N A L R E F E R E N C E S
*****************************************************************************/
#include "mtk-auddrv-afe.h"
#include "mtk-auddrv-ana.h"
#include "mtk-auddrv-clk.h"
#include "mtk-auddrv-common.h"
#include "mtk-auddrv-def.h"
#include "mtk-auddrv-kernel.h"
#include "mtk-soc-afe-control.h"
#include "mtk-soc-pcm-common.h"
#include "mtk-soc-pcm-platform.h"
#include <linux/dma-mapping.h>
/*
* function implementation
*/
static int mtk_dummy_probe(struct platform_device *pdev);
static int mtk_dummypcm_close(struct snd_pcm_substream *substream);
static int mtk_afe_dummy_probe(struct snd_soc_platform *platform);
static struct snd_pcm_hardware mtk_dummy_hardware = {
.info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
.formats = SND_SOC_ADV_MT_FMTS,
.rates = SOC_HIGH_USE_RATE,
.rate_min = SOC_HIGH_USE_RATE_MIN,
.rate_max = SOC_HIGH_USE_RATE_MAX,
.channels_min = SOC_NORMAL_USE_CHANNELS_MIN,
.channels_max = SOC_NORMAL_USE_CHANNELS_MAX,
.buffer_bytes_max = SOC_NORMAL_USE_BUFFERSIZE_MAX,
.period_bytes_max = SOC_NORMAL_USE_BUFFERSIZE_MAX,
.periods_min = SOC_NORMAL_USE_PERIODS_MIN,
.periods_max = SOC_NORMAL_USE_PERIODS_MAX,
.fifo_size = 0,
};
static int mtk_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
runtime->hw = mtk_dummy_hardware;
return 0;
}
static int mtk_dummypcm_close(struct snd_pcm_substream *substream)
{
return 0;
}
static int mtk_dummypcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
break;
}
return -EINVAL;
}
static void *dummy_page[2];
static struct page *mtk_pcm_page(struct snd_pcm_substream *substream,
unsigned long offset)
{
return virt_to_page(dummy_page[substream->stream]); /* the same page */
}
static int mtk_pcm_prepare(struct snd_pcm_substream *substream)
{
return 0;
}
static int mtk_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{
int ret = 0;
return ret;
}
static int mtk_dummy_pcm_hw_free(struct snd_pcm_substream *substream)
{
return snd_pcm_lib_free_pages(substream);
}
static struct snd_pcm_ops mtk_afe_ops = {
.open = mtk_pcm_open,
.close = mtk_dummypcm_close,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = mtk_pcm_hw_params,
.hw_free = mtk_dummy_pcm_hw_free,
.prepare = mtk_pcm_prepare,
.trigger = mtk_dummypcm_trigger,
.page = mtk_pcm_page,
};
static struct snd_soc_platform_driver mtk_soc_dummy_platform = {
.ops = &mtk_afe_ops, .probe = mtk_afe_dummy_probe,
};
static int mtk_dummy_probe(struct platform_device *pdev)
{
if (pdev->dev.of_node) {
dev_set_name(&pdev->dev, "%s", MT_SOC_DUMMY_PCM);
pdev->name = pdev->dev.kobj.name;
} else {
pr_debug("%s(), pdev->dev.of_node = NULL!!!\n", __func__);
}
pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
return snd_soc_register_platform(&pdev->dev, &mtk_soc_dummy_platform);
}
static int mtk_afe_dummy_probe(struct snd_soc_platform *platform)
{
return 0;
}
static int mtk_afedummy_remove(struct platform_device *pdev)
{
snd_soc_unregister_platform(&pdev->dev);
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id mt_soc_pcm_dummy_of_ids[] = {
{
.compatible = "mediatek,mt_soc_pcm_dummy",
},
{} };
#endif
static struct platform_driver mtk_afedummy_driver = {
.driver = {
.name = MT_SOC_DUMMY_PCM,
.owner = THIS_MODULE,
#ifdef CONFIG_OF
.of_match_table = mt_soc_pcm_dummy_of_ids,
#endif
},
.probe = mtk_dummy_probe,
.remove = mtk_afedummy_remove,
};
#ifndef CONFIG_OF
static struct platform_device *soc_mtkafe_dummy_dev;
#endif
static int __init mtk_soc_dummy_platform_init(void)
{
int ret = 0;
pr_debug("%s\n", __func__);
#ifndef CONFIG_OF
soc_mtkafe_dummy_dev = platform_device_alloc(MT_SOC_DUMMY_PCM, -1);
if (!soc_mtkafe_dummy_dev)
return -ENOMEM;
ret = platform_device_add(soc_mtkafe_dummy_dev);
if (ret != 0) {
platform_device_put(soc_mtkafe_dummy_dev);
return ret;
}
#endif
ret = platform_driver_register(&mtk_afedummy_driver);
return ret;
}
module_init(mtk_soc_dummy_platform_init);
static void __exit mtk_soc_dummy_platform_exit(void)
{
platform_driver_unregister(&mtk_afedummy_driver);
}
module_exit(mtk_soc_dummy_platform_exit);
MODULE_DESCRIPTION("AFE PCM module platform driver");
MODULE_LICENSE("GPL");