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;
40 unsigned long pll_out, rclk_rate;
43 RK_SPDIF_DBG("spdif:Entered %s\n", __func__);
45 switch (params_rate(params)) {
59 pr_err("rk_spdif: params not support\n");
64 rclk_rate = params_rate(params) * ratio;
66 /* Set audio source clock rates */
67 ret = snd_soc_dai_set_sysclk(cpu_dai, 0,
68 rclk_rate, SND_SOC_CLOCK_IN);
75 static struct snd_soc_ops rk_spdif_ops = {
76 .hw_params = rk_hw_params,
79 static struct snd_soc_dai_link rk_dai = {
81 .stream_name = "SPDIF PCM Playback",
82 .codec_dai_name = "rk-hdmi-spdif-hifi",
86 static struct snd_soc_card rockchip_hdmi_spdif_snd_card = {
87 .name = "RK-HDMI-SPDIF",
92 static int rockchip_hdmi_spdif_audio_probe(struct platform_device *pdev)
95 struct snd_soc_card *card = &rockchip_hdmi_spdif_snd_card;
97 card->dev = &pdev->dev;
99 ret = rockchip_of_get_sound_card_info_(card, false);
101 pr_err("%s() get sound card info failed:%d\n",
106 ret = snd_soc_register_card(card);
109 pr_err("%s() register card failed:%d\n",
115 static int rockchip_hdmi_spdif_audio_remove(struct platform_device *pdev)
117 struct snd_soc_card *card = platform_get_drvdata(pdev);
119 snd_soc_unregister_card(card);
125 static const struct of_device_id rockchip_hdmi_spdif_of_match[] = {
126 { .compatible = "rockchip-hdmi-spdif"},
129 MODULE_DEVICE_TABLE(of, rockchip_hdmi_spdif_of_match);
130 #endif /* CONFIG_OF */
132 static struct platform_driver rockchip_hdmi_spdif_audio_driver = {
134 .name = "rockchip-hdmi-spdif",
135 .owner = THIS_MODULE,
136 .pm = &snd_soc_pm_ops,
137 .of_match_table = of_match_ptr(rockchip_hdmi_spdif_of_match),
139 .probe = rockchip_hdmi_spdif_audio_probe,
140 .remove = rockchip_hdmi_spdif_audio_remove,
143 module_platform_driver(rockchip_hdmi_spdif_audio_driver);
145 MODULE_AUTHOR("hzb, <hzb@rock-chips.com>");
146 MODULE_DESCRIPTION("ALSA SoC RK+S/PDIF");
147 MODULE_LICENSE("GPL");