ASoC: rockchip: coding style.
authorSugar Zhang <sugar.zhang@rock-chips.com>
Tue, 16 Jun 2015 09:57:51 +0000 (17:57 +0800)
committerSugar Zhang <sugar.zhang@rock-chips.com>
Tue, 16 Jun 2015 11:11:06 +0000 (19:11 +0800)
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
sound/soc/codecs/hdmi_i2s.c
sound/soc/codecs/hdmi_spdif.c [changed mode: 0644->0755]
sound/soc/rockchip/card_info.c
sound/soc/rockchip/card_info.h
sound/soc/rockchip/rk_hdmi_i2s.c
sound/soc/rockchip/rk_hdmi_spdif.c
sound/soc/rockchip/rk_spdif_card.c

index 2d790eeb7d484a2af5d3d9175a4b952079f36ed2..c9ff99c07951bac01ff3db483069ec4e64f97543 100755 (executable)
@@ -1,8 +1,17 @@
 /*
  * hdmi_i2s.c  --  HDMI i2s audio for rockchip
  *
- * Copyright 2013 Rockship
- * Author: chenjq <chenjq@rock-chips.com>
+ * Copyright (C) 2015 Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
  */
 
 #include <linux/module.h>
 #include <sound/pcm.h>
 #include <sound/initval.h>
 
-#if 0
-#define DBG(x...) printk(KERN_INFO "hdmi i2s:"x)
-#else
-#define DBG(x...) do { } while (0)
-#endif
-
 struct snd_soc_dai_driver hdmi_i2s_dai = {
        .name = "rk-hdmi-i2s-hifi",
        .playback = {
                .stream_name = "HiFi Playback",
                .channels_min = 2,
-               .channels_max = 2,
+               .channels_max = 8,
                .rates = (SNDRV_PCM_RATE_32000 |
-                       SNDRV_PCM_RATE_44100 |
-                       SNDRV_PCM_RATE_48000 |
-                       SNDRV_PCM_RATE_96000 |
-                       SNDRV_PCM_RATE_192000),
+                         SNDRV_PCM_RATE_44100 |
+                         SNDRV_PCM_RATE_48000 |
+                         SNDRV_PCM_RATE_96000 |
+                         SNDRV_PCM_RATE_192000),
                .formats = (SNDRV_PCM_FMTBIT_S16_LE |
-                       SNDRV_PCM_FMTBIT_S20_3LE |
-                       SNDRV_PCM_FMTBIT_S24_LE),
+                           SNDRV_PCM_FMTBIT_S20_3LE |
+                           SNDRV_PCM_FMTBIT_S24_LE),
        },
 };
 
@@ -43,15 +46,12 @@ static int rockchip_hdmi_i2s_audio_probe(struct platform_device *pdev)
 {
        int ret;
 
-       //set dev name to driver->name for sound card register
-       dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name);
-
        ret = snd_soc_register_codec(&pdev->dev,
-               &soc_codec_dev_hdmi_i2s,
-               &hdmi_i2s_dai, 1);
+                                    &soc_codec_dev_hdmi_i2s,
+                                    &hdmi_i2s_dai, 1);
 
        if (ret)
-               printk("%s() register card failed:%d\n", __FUNCTION__, ret);
+               dev_err(&pdev->dev, "register card failed: %d\n", ret);
 
        return ret;
 }
@@ -65,24 +65,23 @@ static int rockchip_hdmi_i2s_audio_remove(struct platform_device *pdev)
 
 #ifdef CONFIG_OF
 static const struct of_device_id rockchip_hdmi_i2s_of_match[] = {
-        { .compatible = "hdmi-i2s", },
-        {},
+       { .compatible = "hdmi-i2s", },
+       {},
 };
 MODULE_DEVICE_TABLE(of, rockchip_hdmi_i2s_of_match);
 #endif /* CONFIG_OF */
 
 static struct platform_driver rockchip_hdmi_i2s_audio_driver = {
-        .driver         = {
-                .name   = "hdmi-i2s",
-                .owner  = THIS_MODULE,
-                .of_match_table = of_match_ptr(rockchip_hdmi_i2s_of_match),
-        },
-        .probe          = rockchip_hdmi_i2s_audio_probe,
-        .remove         = rockchip_hdmi_i2s_audio_remove,
+       .driver = {
+               .name = "hdmi-i2s",
+               .of_match_table = of_match_ptr(rockchip_hdmi_i2s_of_match),
+       },
+       .probe = rockchip_hdmi_i2s_audio_probe,
+       .remove = rockchip_hdmi_i2s_audio_remove,
 };
 
 module_platform_driver(rockchip_hdmi_i2s_audio_driver);
 
-MODULE_DESCRIPTION("HDMI I2S Controller Driver");
+MODULE_DESCRIPTION("Rockchip HDMI I2S Dummy Driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:hdmi-i2s");
old mode 100644 (file)
new mode 100755 (executable)
index cc4c542..a820a8e
 #include <sound/pcm.h>
 #include <sound/initval.h>
 
-#undef  DEBUG_HDMI_SPDIF
-#define DEBUG_HDMI_SPDIF 0
-
-#if DEBUG_HDMI_SPDIF
-#define RK_HDMISPDIF_DBG(x...) pr_info("hdmi_spdif:"x)
-#else
-#define RK_HDMISPDIF_DBG(x...) do { } while (0)
-#endif
-
-
 #define DRV_NAME "spdif-dit"
 
 #define STUB_RATES     SNDRV_PCM_RATE_8000_192000
@@ -56,15 +46,12 @@ static int hdmi_spdif_audio_probe(struct platform_device *pdev)
 {
        int ret;
 
-       /* set dev name to driver->name for sound card register. */
-       dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name);
-
-       ret = snd_soc_register_codec(&pdev->
-               dev, &soc_codec_spdif_dit, &dit_stub_dai, 1);
+       ret = snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit,
+                                    &dit_stub_dai, 1);
 
        if (ret)
-               RK_HDMISPDIF_DBG("%s register codec failed:%d\n"
-               , __func__, ret);
+               dev_err(&pdev->dev, "%s register failed: %d\n",
+                       __func__, ret);
 
        return ret;
 }
@@ -85,13 +72,12 @@ MODULE_DEVICE_TABLE(of, hdmi_spdif_of_match);
 #endif /* CONFIG_OF */
 
 static struct platform_driver hdmi_spdif_audio_driver = {
-       .driver    = {
-               .name           = "hdmi-spdif",
-               .owner          = THIS_MODULE,
+       .driver = {
+               .name = "hdmi-spdif",
                .of_match_table = of_match_ptr(hdmi_spdif_of_match),
        },
-       .probe     = hdmi_spdif_audio_probe,
-       .remove    = hdmi_spdif_audio_remove,
+       .probe = hdmi_spdif_audio_probe,
+       .remove = hdmi_spdif_audio_remove,
 };
 
 module_platform_driver(hdmi_spdif_audio_driver);
index ddcea4e0bd9bdf2d252428d2a731e73778137b88..fced8016c66cf12034a46bd2d8e56edbba5cdadf 100755 (executable)
@@ -59,7 +59,7 @@
                };
  */
 int rockchip_of_get_sound_card_info_(struct snd_soc_card *card,
-       bool is_need_fmt)
+                                    bool is_need_fmt)
 {
        struct device_node *dai_node, *child_dai_node;
        int dai_num;
@@ -74,7 +74,6 @@ int rockchip_of_get_sound_card_info_(struct snd_soc_card *card,
        dai_num = 0;
 
        for_each_child_of_node(dai_node, child_dai_node) {
-
                if (is_need_fmt) {
                        card->dai_link[dai_num].dai_fmt =
                                snd_soc_of_parse_daifmt(child_dai_node, NULL);
index b78d011bb91c85669283aad5bad02d239188f456..a3f12e3cb29df9ec49c5c53317fbb8fbfcc15c20 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * card_info.h - ALSA PCM interface for the Rockchip rk28 SoC
+ * card_info.h - ALSA PCM interface for Rockchip
  *
  * 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
@@ -10,7 +10,7 @@
 #define _SND_SOC_ROCKCHIP_CARD_INFO_H
 
 int rockchip_of_get_sound_card_info_(struct snd_soc_card *card,
-       bool is_need_fmt);
+                                    bool is_need_fmt);
 int rockchip_of_get_sound_card_info(struct snd_soc_card *card);
 
 #endif /* _SND_SOC_ROCKCHIP_CARD_INFO_H */
index 2d4c63daae7266c0b284e29db4d767b901e246b8..94c9ea279a4eada6919aa21a67d2db9939f41a7d 100755 (executable)
@@ -1,8 +1,17 @@
 /*
  * rk_hdmi_i2s.c  --  HDMI i2s audio for rockchip
  *
- * Copyright 2013 Rockship
- * Author: chenjq <chenjq@rock-chips.com>
+ * Copyright (C) 2015 Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
  */
 
 #include <linux/module.h>
 #include "rk_pcm.h"
 #include "rk_i2s.h"
 
-#if 0
-#define DBG(x...) pr_info("rk_hdmi_i2s:"x)
-#else
-#define DBG(x...) do { } while (0)
-#endif
-
 static int hdmi_i2s_hifi_hw_params(struct snd_pcm_substream *substream,
-       struct snd_pcm_hw_params *params)
+                                  struct snd_pcm_hw_params *params)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        unsigned int pll_out = 0, dai_fmt = rtd->dai_link->dai_fmt;
-       int div_bclk,div_mclk;
+       int div_bclk, div_mclk;
        int ret;
 
-       DBG("Enter::%s----%d\n", __func__, __LINE__);
-
        /* set cpu DAI configuration */
        ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);
        if (ret < 0) {
-               pr_err("%s():failed to set the format for cpu side\n",
-                       __func__);
+               pr_err("%s: failed to set format for cpu dai\n", __func__);
                return ret;
        }
 
@@ -65,25 +65,20 @@ static int hdmi_i2s_hifi_hw_params(struct snd_pcm_substream *substream,
                pll_out = 12288000*2;
                break;
        default:
-               pr_err("Enter:%s, %d, Error rate=%d\n",
-                       __func__, __LINE__, params_rate(params));
+               pr_err("%s: %d: rate(%d) not support.\n",
+                      __func__, __LINE__, params_rate(params));
                return -EINVAL;
-               break;
        }
 
-       DBG("Enter:%s, %d, rate=%d\n",
-               __func__, __LINE__,
-               params_rate(params));
-
        div_bclk = 127;
        div_mclk = pll_out/(params_rate(params)*(div_bclk+1))-1;
 
        snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
-       snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk);
+       snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, div_bclk);
        snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk);
 
-       DBG("Enter:%s, %d, div_bclk: %d, div_mclk: %d\n",
-               __func__, __LINE__, div_bclk, div_mclk);
+       pr_debug("%s: %d: div_bclk: %d, div_mclk: %d\n",
+                __func__, __LINE__, div_bclk, div_mclk);
 
        return 0;
 }
@@ -116,15 +111,15 @@ static int rockchip_hdmi_i2s_audio_probe(struct platform_device *pdev)
 
        ret = rockchip_of_get_sound_card_info(card);
        if (ret) {
-               pr_err("%s() get sound card info failed:%d\n",
-                       __func__, ret);
+               pr_err("%s() get sound card info failed: %d\n",
+                      __func__, ret);
                return ret;
        }
 
        ret = snd_soc_register_card(card);
        if (ret)
-               pr_err("%s() register card failed:%d\n",
-                       __func__, ret);
+               pr_err("%s() register card failed: %d\n",
+                      __func__, ret);
 
        return ret;
 }
@@ -147,19 +142,17 @@ MODULE_DEVICE_TABLE(of, rockchip_hdmi_i2s_of_match);
 #endif /* CONFIG_OF */
 
 static struct platform_driver rockchip_hdmi_i2s_audio_driver = {
-       .driver         = {
-               .name   = "rockchip-hdmi-i2s",
-               .owner  = THIS_MODULE,
+       .driver = {
+               .name = "rockchip-hdmi-i2s",
                .pm = &snd_soc_pm_ops,
                .of_match_table = of_match_ptr(rockchip_hdmi_i2s_of_match),
        },
-       .probe          = rockchip_hdmi_i2s_audio_probe,
-       .remove         = rockchip_hdmi_i2s_audio_remove,
+       .probe = rockchip_hdmi_i2s_audio_probe,
+       .remove = rockchip_hdmi_i2s_audio_remove,
 };
 
 module_platform_driver(rockchip_hdmi_i2s_audio_driver);
 
-/* Module information */
 MODULE_AUTHOR("rockchip");
-MODULE_DESCRIPTION("ROCKCHIP hdmi i2s ASoC Interface");
+MODULE_DESCRIPTION("Rockchip HDMI I2S Audio Card");
 MODULE_LICENSE("GPL");
index 12cdaecbcce0a95bebc0693e754e5c696c6b9eb6..cfeb7f6cb1c1228f47a7973e9a627909829719b5 100755 (executable)
@@ -1,15 +1,16 @@
-/*$_FOR_ROCKCHIP_RBOX_$*/
-/*$_rbox_$_modify_$_huangzhibao for spdif output*/
-
 /*
- * smdk_spdif.c  --  S/PDIF audio for SMDK
+ * rk_hdmi_spdif.c  -- hdmi spdif for rockchip
+ *
+ * Copyright (C) 2015 Fuzhou Rockchip Electronics Co., Ltd
  *
- * Copyright 2010 Samsung Electronics Co. Ltd.
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
  *
- * 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.
+ * 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.
  *
  */
 
 #include "card_info.h"
 #include "rk_pcm.h"
 
-#if 0
-#define RK_SPDIF_DBG(x...) pr_info("rk_hdmi_spdif:"x)
-#else
-#define RK_SPDIF_DBG(x...) do { } while (0)
-#endif
-
 static int rk_hw_params(struct snd_pcm_substream *substream,
                        struct snd_pcm_hw_params *params)
 {
@@ -40,8 +35,6 @@ static int rk_hw_params(struct snd_pcm_substream *substream,
        unsigned long sclk;
        int ret, ratio;
 
-       RK_SPDIF_DBG("spdif:Entered %s\n", __func__);
-
        /* bmc: 2*32*fs*2 = 128fs */
        ratio = 128;
        switch (params_rate(params)) {
@@ -59,8 +52,6 @@ static int rk_hw_params(struct snd_pcm_substream *substream,
 
        ret = snd_soc_dai_set_sysclk(cpu_dai, 0,
                                     sclk, SND_SOC_CLOCK_IN);
-       if (ret < 0)
-               return ret;
 
        return ret;
 }
@@ -116,25 +107,24 @@ static int rockchip_hdmi_spdif_audio_remove(struct platform_device *pdev)
 
 #ifdef CONFIG_OF
 static const struct of_device_id rockchip_hdmi_spdif_of_match[] = {
-       { .compatible = "rockchip-hdmi-spdif"},
+       { .compatible = "rockchip-hdmi-spdif"},
        {},
 };
 MODULE_DEVICE_TABLE(of, rockchip_hdmi_spdif_of_match);
 #endif /* CONFIG_OF */
 
 static struct platform_driver rockchip_hdmi_spdif_audio_driver = {
-       .driver         = {
-               .name   = "rockchip-hdmi-spdif",
-               .owner  = THIS_MODULE,
+       .driver = {
+               .name = "rockchip-hdmi-spdif",
                .pm = &snd_soc_pm_ops,
                .of_match_table = of_match_ptr(rockchip_hdmi_spdif_of_match),
        },
-       .probe          = rockchip_hdmi_spdif_audio_probe,
-       .remove         = rockchip_hdmi_spdif_audio_remove,
+       .probe = rockchip_hdmi_spdif_audio_probe,
+       .remove = rockchip_hdmi_spdif_audio_remove,
 };
 
 module_platform_driver(rockchip_hdmi_spdif_audio_driver);
 
-MODULE_AUTHOR("hzb, <hzb@rock-chips.com>");
-MODULE_DESCRIPTION("ALSA SoC RK+S/PDIF");
+MODULE_AUTHOR("hzb <hzb@rock-chips.com>");
+MODULE_DESCRIPTION("Rockchip HDMI Spdif Card");
 MODULE_LICENSE("GPL");
index 7bfb74c08aecff39f18b611b095ea9434cc307db..bb7a55de8954d089ed7f9902f4126a6f7dfe1c2c 100755 (executable)
@@ -1,12 +1,16 @@
 /*
  * rk_spdif_card.c  --  spdif card for rockchip
  *
- * Copyright 2014 rockchip Co. Ltd.
+ * Copyright (C) 2014 Fuzhou Rockchip Electronics Co., Ltd
  *
- * 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.
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
  *
  */
 
@@ -49,8 +53,6 @@ static int rk_hw_params(struct snd_pcm_substream *substream,
 
        ret = snd_soc_dai_set_sysclk(cpu_dai, 0,
                                     sclk, SND_SOC_CLOCK_IN);
-       if (ret < 0)
-               return ret;
 
        return ret;
 }
@@ -106,39 +108,38 @@ static int rockchip_spdif_card_remove(struct platform_device *pdev)
 
 #ifdef CONFIG_OF
 static const struct of_device_id rockchip_spdif_card_of_match[] = {
-       { .compatible = "rockchip-spdif-card"},
+       { .compatible = "rockchip-spdif-card"},
        {},
 };
 MODULE_DEVICE_TABLE(of, rockchip_spdif_card_of_match);
 #endif /* CONFIG_OF */
 
 static struct platform_driver rockchip_spdif_card_driver = {
-       .driver         = {
-               .name   = "rockchip-spdif-card",
-               .owner  = THIS_MODULE,
+       .driver = {
+               .name = "rockchip-spdif-card",
+               .owner = THIS_MODULE,
                .pm = &snd_soc_pm_ops,
                .of_match_table = of_match_ptr(rockchip_spdif_card_of_match),
        },
-       .probe          = rockchip_spdif_card_probe,
-       .remove         = rockchip_spdif_card_remove,
+       .probe = rockchip_spdif_card_probe,
+       .remove = rockchip_spdif_card_remove,
 };
 
-//module_platform_driver(rockchip_spdif_card_driver);
-
+/* module_platform_driver(rockchip_spdif_card_driver); */
 
 static int __init rockchip_spdif_init(void)
 {
-        return platform_driver_register(&rockchip_spdif_card_driver);
+       return platform_driver_register(&rockchip_spdif_card_driver);
 };
 late_initcall(rockchip_spdif_init);
 
 static void __exit rockchip_spdif_exit(void)
 {
-        platform_driver_unregister(&rockchip_spdif_card_driver);
+       platform_driver_unregister(&rockchip_spdif_card_driver);
 }
 module_exit(rockchip_spdif_exit);
 
 
-MODULE_AUTHOR("hzb, <hzb@rock-chips.com>");
+MODULE_AUTHOR("hzb <hzb@rock-chips.com>");
 MODULE_DESCRIPTION("ALSA SoC RK S/PDIF");
 MODULE_LICENSE("GPL");