1 /*$_FOR_ROCKCHIP_RBOX_$*/
2 /*$_rbox_$_modify_$_huangzhibao for spdif output*/
5 * smdk_spdif.c -- S/PDIF audio for SMDK
7 * Copyright 2010 Samsung Electronics Co. Ltd.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
16 #include <linux/module.h>
17 #include <linux/device.h>
19 #include <linux/of_gpio.h>
20 #include <linux/clk.h>
21 #include <sound/core.h>
22 #include <sound/pcm.h>
23 #include <sound/soc.h>
24 #include <sound/soc-dapm.h>
26 #include "card_info.h"
30 #define RK_SPDIF_DBG(x...) pr_info("rk_hdmi_spdif:"x)
32 #define RK_SPDIF_DBG(x...) do { } while (0)
35 static int rk_hw_params(struct snd_pcm_substream *substream,
36 struct snd_pcm_hw_params *params)
38 struct snd_soc_pcm_runtime *rtd = substream->private_data;
39 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
43 RK_SPDIF_DBG("spdif:Entered %s\n", __func__);
45 /* bmc: 2*32*fs*2 = 128fs */
47 switch (params_rate(params)) {
53 sclk = params_rate(params) * ratio;
56 pr_err("rk_spdif: params not support\n");
60 ret = snd_soc_dai_set_sysclk(cpu_dai, 0,
61 sclk, SND_SOC_CLOCK_IN);
68 static struct snd_soc_ops rk_spdif_ops = {
69 .hw_params = rk_hw_params,
72 static struct snd_soc_dai_link rk_dai = {
74 .stream_name = "SPDIF PCM Playback",
75 .codec_dai_name = "rk-hdmi-spdif-hifi",
79 static struct snd_soc_card rockchip_hdmi_spdif_snd_card = {
80 .name = "RK-HDMI-SPDIF",
85 static int rockchip_hdmi_spdif_audio_probe(struct platform_device *pdev)
88 struct snd_soc_card *card = &rockchip_hdmi_spdif_snd_card;
90 card->dev = &pdev->dev;
92 ret = rockchip_of_get_sound_card_info_(card, false);
94 pr_err("%s() get sound card info failed:%d\n",
99 ret = snd_soc_register_card(card);
102 pr_err("%s() register card failed:%d\n",
108 static int rockchip_hdmi_spdif_audio_remove(struct platform_device *pdev)
110 struct snd_soc_card *card = platform_get_drvdata(pdev);
112 snd_soc_unregister_card(card);
118 static const struct of_device_id rockchip_hdmi_spdif_of_match[] = {
119 { .compatible = "rockchip-hdmi-spdif"},
122 MODULE_DEVICE_TABLE(of, rockchip_hdmi_spdif_of_match);
123 #endif /* CONFIG_OF */
125 static struct platform_driver rockchip_hdmi_spdif_audio_driver = {
127 .name = "rockchip-hdmi-spdif",
128 .owner = THIS_MODULE,
129 .pm = &snd_soc_pm_ops,
130 .of_match_table = of_match_ptr(rockchip_hdmi_spdif_of_match),
132 .probe = rockchip_hdmi_spdif_audio_probe,
133 .remove = rockchip_hdmi_spdif_audio_remove,
136 module_platform_driver(rockchip_hdmi_spdif_audio_driver);
138 MODULE_AUTHOR("hzb, <hzb@rock-chips.com>");
139 MODULE_DESCRIPTION("ALSA SoC RK+S/PDIF");
140 MODULE_LICENSE("GPL");