From 2b92186106781390b9ce9a483728842856439f09 Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Tue, 16 Jun 2015 17:57:51 +0800 Subject: [PATCH] ASoC: rockchip: coding style. Signed-off-by: Sugar Zhang --- sound/soc/codecs/hdmi_i2s.c | 61 ++++++++++++++--------------- sound/soc/codecs/hdmi_spdif.c | 30 ++++---------- sound/soc/rockchip/card_info.c | 3 +- sound/soc/rockchip/card_info.h | 4 +- sound/soc/rockchip/rk_hdmi_i2s.c | 63 +++++++++++++----------------- sound/soc/rockchip/rk_hdmi_spdif.c | 44 ++++++++------------- sound/soc/rockchip/rk_spdif_card.c | 37 +++++++++--------- 7 files changed, 105 insertions(+), 137 deletions(-) mode change 100644 => 100755 sound/soc/codecs/hdmi_spdif.c diff --git a/sound/soc/codecs/hdmi_i2s.c b/sound/soc/codecs/hdmi_i2s.c index 2d790eeb7d48..c9ff99c07951 100755 --- a/sound/soc/codecs/hdmi_i2s.c +++ b/sound/soc/codecs/hdmi_i2s.c @@ -1,8 +1,17 @@ /* * hdmi_i2s.c -- HDMI i2s audio for rockchip * - * Copyright 2013 Rockship - * Author: chenjq + * 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 @@ -14,26 +23,20 @@ #include #include -#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"); diff --git a/sound/soc/codecs/hdmi_spdif.c b/sound/soc/codecs/hdmi_spdif.c old mode 100644 new mode 100755 index cc4c5429126b..a820a8e13f98 --- a/sound/soc/codecs/hdmi_spdif.c +++ b/sound/soc/codecs/hdmi_spdif.c @@ -23,16 +23,6 @@ #include #include -#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); diff --git a/sound/soc/rockchip/card_info.c b/sound/soc/rockchip/card_info.c index ddcea4e0bd9b..fced8016c66c 100755 --- a/sound/soc/rockchip/card_info.c +++ b/sound/soc/rockchip/card_info.c @@ -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); diff --git a/sound/soc/rockchip/card_info.h b/sound/soc/rockchip/card_info.h index b78d011bb91c..a3f12e3cb29d 100755 --- a/sound/soc/rockchip/card_info.h +++ b/sound/soc/rockchip/card_info.h @@ -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 */ diff --git a/sound/soc/rockchip/rk_hdmi_i2s.c b/sound/soc/rockchip/rk_hdmi_i2s.c index 2d4c63daae72..94c9ea279a4e 100755 --- a/sound/soc/rockchip/rk_hdmi_i2s.c +++ b/sound/soc/rockchip/rk_hdmi_i2s.c @@ -1,8 +1,17 @@ /* * rk_hdmi_i2s.c -- HDMI i2s audio for rockchip * - * Copyright 2013 Rockship - * Author: chenjq + * 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 @@ -18,28 +27,19 @@ #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"); diff --git a/sound/soc/rockchip/rk_hdmi_spdif.c b/sound/soc/rockchip/rk_hdmi_spdif.c index 12cdaecbcce0..cfeb7f6cb1c1 100755 --- a/sound/soc/rockchip/rk_hdmi_spdif.c +++ b/sound/soc/rockchip/rk_hdmi_spdif.c @@ -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. * */ @@ -26,12 +27,6 @@ #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, "); -MODULE_DESCRIPTION("ALSA SoC RK+S/PDIF"); +MODULE_AUTHOR("hzb "); +MODULE_DESCRIPTION("Rockchip HDMI Spdif Card"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/rockchip/rk_spdif_card.c b/sound/soc/rockchip/rk_spdif_card.c index 7bfb74c08aec..bb7a55de8954 100755 --- a/sound/soc/rockchip/rk_spdif_card.c +++ b/sound/soc/rockchip/rk_spdif_card.c @@ -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, "); +MODULE_AUTHOR("hzb "); MODULE_DESCRIPTION("ALSA SoC RK S/PDIF"); MODULE_LICENSE("GPL"); -- 2.34.1