ckfwq/linux-3.0.4/sound/soc/blx/gsc3280_lb.c

130 lines
2.9 KiB
C
Raw Permalink Normal View History

2024-12-30 10:53:50 +08:00
/*
*
* Copyright (C) 2012 BLX Corporation
*
* 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/moduleparam.h>
#include <linux/timer.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
static const struct snd_soc_dapm_widget lb_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_SPK("Speaker", NULL),
SND_SOC_DAPM_MIC("LineIn", NULL),
};
static const struct snd_soc_dapm_route lb_routes[] = {
// {"Mic", NULL, "MIC"},
// {"Speaker", NULL, "LOUT"},
// {"Speaker", NULL, "ROUT"},
{"Headphone", NULL, "HPL"},
{"Headphone", NULL, "HPR"},
{"Speaker", NULL, "SPKOUT"},
{"Speaker", NULL, "SPKOUTN"},
{"LINEINL", NULL, "LineIn"},
{"LINEINR", NULL, "LineIn"},
};
#define LB_DAIFMT (SND_SOC_DAIFMT_I2S | \
SND_SOC_DAIFMT_NB_NF | \
SND_SOC_DAIFMT_CBM_CFM)
static int lb_codec_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dapm_context *dapm = &codec->dapm;
int ret;
#if 0
snd_soc_dapm_nc_pin(dapm, "LIN");
snd_soc_dapm_nc_pin(dapm, "RIN");
#endif
snd_soc_dapm_nc_pin(dapm, "LineIn");
snd_soc_dapm_nc_pin(dapm, "Headphone");
snd_soc_dapm_nc_pin(dapm, "Speaker");
ret = snd_soc_dai_set_fmt(cpu_dai, LB_DAIFMT);
if (ret < 0) {
dev_err(codec->dev, "Failed to set cpu dai format: %d\n", ret);
return ret;
}
//return snd_soc_dai_set_sysclk(codec_dai, 0, 12288000, 0);
return snd_soc_dai_set_sysclk(codec_dai, 0, 11289600, 0);
// return 0;
}
static struct snd_soc_dai_link lb_dai = {
.name = "blx_lb",
.stream_name = "blx_lb",
.cpu_dai_name = "gsc3280-i2s",
.platform_name = "gsc3280-pcm-audio",
.codec_dai_name = "alc5623-hifi",
.codec_name = "alc562x-codec.0-001a",
.init = lb_codec_init,
};
static struct snd_soc_card lb = {
.name = "LB",
.dai_link = &lb_dai,
.num_links = 1,
.dapm_widgets = lb_widgets,
.num_dapm_widgets = ARRAY_SIZE(lb_widgets),
.dapm_routes = lb_routes,
.num_dapm_routes = ARRAY_SIZE(lb_routes),
};
static struct platform_device *lb_snd_device;
static int __init lb_init(void)
{
int ret;
lb_snd_device = platform_device_alloc("soc-audio", -1);
if (!lb_snd_device)
return -ENOMEM;
platform_set_drvdata(lb_snd_device, &lb);
ret = platform_device_add(lb_snd_device);
if (ret) {
pr_err("lb60 snd: Failed to add snd soc device: %d\n", ret);
goto err_unset_pdata;
}
return 0;
err_unset_pdata:
platform_set_drvdata(lb_snd_device, NULL);
platform_device_put(lb_snd_device);
return ret;
}
module_init(lb_init);
static void __exit lb_exit(void)
{
platform_device_unregister(lb_snd_device);
}
module_exit(lb_exit);
MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support");
MODULE_LICENSE("GPL v2");