From: 陈金泉 Date: Sun, 26 Jan 2014 08:28:43 +0000 (+0800) Subject: update audio platform driver, add spdif codec dts property X-Git-Tag: firefly_0821_release~6359 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7a74e7eab9081a9aed3842f7a17b87b2d57e73c6;p=firefly-linux-kernel-4.4.55.git update audio platform driver, add spdif codec dts property --- diff --git a/arch/arm/boot/dts/rk3188-pinctrl.dtsi b/arch/arm/boot/dts/rk3188-pinctrl.dtsi index 8a3579dbfb55..ec560de868c6 100755 --- a/arch/arm/boot/dts/rk3188-pinctrl.dtsi +++ b/arch/arm/boot/dts/rk3188-pinctrl.dtsi @@ -442,6 +442,17 @@ }; + gpio1_spdif { + spdif_tx: spdif-tx { + rockchip,pins = ; + rockchip,pull = ; + //rockchip,voltage = ; + rockchip,drive = ; + //rockchip,tristate = ; + + }; + }; + gpio3_pwm { pwm0_pin:pwm0 { rockchip,pins = ; diff --git a/arch/arm/boot/dts/rk3188-tb.dts b/arch/arm/boot/dts/rk3188-tb.dts index 1340e1334b9f..99ac451e2fb4 100644 --- a/arch/arm/boot/dts/rk3188-tb.dts +++ b/arch/arm/boot/dts/rk3188-tb.dts @@ -24,9 +24,27 @@ brightness-levels = <0 4 8 16 32 64 128 255>; default-brightness-level = <6>; gpios = <&gpio0 GPIO_A2 GPIO_ACTIVE_HIGH>; -}; + }; + + codec-hdmi-i2s { + compatible = "hdmi-i2s"; + }; + codec-hdmi-spdif { + compatible = "hdmi-spdif"; + }; + rockchip-rt5631 { + compatible = "rockchip-rt5631"; + }; + + rockchip-hdmi-i2s { + compatible = "rockchip-hdmi-i2s"; + }; + + rockchip-hdmi-spdif { + compatible = "rockchip-hdmi-spdif"; + }; }; &uart0 { @@ -39,6 +57,10 @@ &i2c0 { status = "okay"; + codec@1a { + compatible = "rt5631"; + reg = <0x1a>; + }; }; &i2c1 { diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index dc138a1a5017..1cb2ea0ed49c 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -14,6 +14,7 @@ snd-soc-ak4535-objs := ak4535.o snd-soc-ak4641-objs := ak4641.o snd-soc-ak4642-objs := ak4642.o snd-soc-ak4671-objs := ak4671.o +snd-soc-ak4396-objs := ak4396.o snd-soc-ak5386-objs := ak5386.o snd-soc-arizona-objs := arizona.o snd-soc-cq93vc-objs := cq93vc.o @@ -28,6 +29,7 @@ snd-soc-da7213-objs := da7213.o snd-soc-da732x-objs := da732x.o snd-soc-da9055-objs := da9055.o snd-soc-dfbmcs320-objs := dfbmcs320.o +snd-soc-jz4740-codec-objs := jz4740.o snd-soc-dmic-objs := dmic.o snd-soc-es8323-objs := es8323.o snd-soc-es8323-pcm-objs := es8323_pcm.o @@ -95,13 +97,6 @@ snd-soc-wm8776-objs := wm8776.o snd-soc-wm8782-objs := wm8782.o snd-soc-wm8804-objs := wm8804.o snd-soc-wm8900-objs := wm8900.o -snd-soc-rt5621-objs := rt5621.o -snd-soc-rt5623-objs := rt5623.o -snd-soc-rt5631-objs := rt5631.o -snd-soc-rt5616-objs := rt5616.o -snd-soc-rt5631-phone-objs := rt5631_phone.o -snd-soc-rt5625-objs := rt5625.o -snd-soc-cs42l52-objs := cs42l52.o snd-soc-wm8903-objs := wm8903.o snd-soc-wm8904-objs := wm8904.o snd-soc-wm8996-objs := wm8996.o @@ -127,26 +122,29 @@ snd-soc-wm9705-objs := wm9705.o snd-soc-wm9712-objs := wm9712.o snd-soc-wm9713-objs := wm9713.o snd-soc-wm-hubs-objs := wm_hubs.o -snd-soc-rk1000-objs := rk1000_codec.o -snd-soc-jz4740-codec-objs := jz4740.o -snd-soc-rk610-objs := rk610_codec.o -snd-soc-rk616-objs := rk616_codec.o +snd-soc-rt5621-objs := rt5621.o +snd-soc-rt5623-objs := rt5623.o +snd-soc-rt5631-objs := rt5631.o +snd-soc-rt5616-objs := rt5616.o +snd-soc-rt5631-phone-objs := rt5631_phone.o +snd-soc-rt5625-objs := rt5625.o +snd-soc-rt5639-objs := rt5639.o rt5639_ioctl.o rt56xx_ioctl.o snd-soc-rt5640-objs := rt5640.o rt5640-dsp.o rt5640_ioctl.o rt56xx_ioctl.o snd-soc-rt3261-objs := rt3261.o rt3261-dsp.o rt3261_ioctl.o rt_codec_ioctl.o snd-soc-rt3224-objs := rt3261.o rt3261_ioctl.o rt_codec_ioctl.o +snd-soc-cs42l52-objs := cs42l52.o +snd-soc-rk1000-objs := rk1000_codec.o +snd-soc-rk610-objs := rk610_codec.o +snd-soc-rk616-objs := rk616_codec.o snd-soc-rk2928-objs := rk2928_codec.o snd-soc-rk3026-objs := rk3026_codec.o snd-soc-rk3190-objs := rk3190_codec.o -snd-soc-rt5639-objs := rt5639.o rt5639_ioctl.o rt56xx_ioctl.o + # Amp snd-soc-max9877-objs := max9877.o snd-soc-tpa6130a2-objs := tpa6130a2.o -obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o -obj-$(CONFIG_SND_SOC_RT3261) += snd-soc-rt3261.o -obj-$(CONFIG_SND_SOC_RT3224) += snd-soc-rt3224.o -obj-$(CONFIG_SND_SOC_RT5639) += snd-soc-rt5639.o obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o obj-$(CONFIG_SND_SOC_AB8500_CODEC) += snd-soc-ab8500-codec.o obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o @@ -163,6 +161,7 @@ obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o +obj-$(CONFIG_SND_SOC_AK4396) += snd-soc-ak4396.o obj-$(CONFIG_SND_SOC_AK5386) += snd-soc-ak5386.o obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o @@ -196,7 +195,6 @@ obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o obj-$(CONFIG_SND_SOC_OMAP_HDMI_CODEC) += snd-soc-omap-hdmi-codec.o obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o -obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o @@ -244,14 +242,6 @@ obj-$(CONFIG_SND_SOC_WM8776) += snd-soc-wm8776.o obj-$(CONFIG_SND_SOC_WM8782) += snd-soc-wm8782.o obj-$(CONFIG_SND_SOC_WM8804) += snd-soc-wm8804.o obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o -obj-$(CONFIG_SND_SOC_RT5621) += snd-soc-rt5621.o -obj-$(CONFIG_SND_SOC_RT5623) += snd-soc-rt5623.o -obj-$(CONFIG_SND_SOC_AK4396) += snd-soc-ak4396.o -obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o -obj-$(CONFIG_SND_SOC_RT5616) += snd-soc-rt5616.o -obj-$(CONFIG_SND_SOC_RT5631_PHONE) += snd-soc-rt5631-phone.o -obj-$(CONFIG_SND_SOC_RT5625) += snd-soc-rt5625.o -obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o obj-$(CONFIG_SND_SOC_WM8904) += snd-soc-wm8904.o obj-$(CONFIG_SND_SOC_WM8996) += snd-soc-wm8996.o @@ -278,13 +268,24 @@ obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o +obj-$(CONFIG_SND_SOC_RT5512) += snd-soc-rt5512.o +obj-$(CONFIG_SND_SOC_RT5621) += snd-soc-rt5621.o +obj-$(CONFIG_SND_SOC_RT5623) += snd-soc-rt5623.o +obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o +obj-$(CONFIG_SND_SOC_RT5616) += snd-soc-rt5616.o +obj-$(CONFIG_SND_SOC_RT5631_PHONE) += snd-soc-rt5631-phone.o +obj-$(CONFIG_SND_SOC_RT5625) += snd-soc-rt5625.o +obj-$(CONFIG_SND_SOC_RT3261) += snd-soc-rt3261.o +obj-$(CONFIG_SND_SOC_RT3224) += snd-soc-rt3224.o +obj-$(CONFIG_SND_SOC_RT5639) += snd-soc-rt5639.o +obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o +obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o obj-$(CONFIG_SND_SOC_RK1000) += snd-soc-rk1000.o obj-$(CONFIG_SND_SOC_RK610) += snd-soc-rk610.o obj-$(CONFIG_SND_SOC_RK616) += snd-soc-rk616.o obj-$(CONFIG_SND_SOC_RK2928) += snd-soc-rk2928.o obj-$(CONFIG_SND_SOC_RK3026) += snd-soc-rk3026.o obj-$(CONFIG_SND_SOC_RK3190) += snd-soc-rk3190.o -obj-$(CONFIG_SND_SOC_RT5512) += snd-soc-rt5512.o # Amp obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o diff --git a/sound/soc/codecs/ak4396.c b/sound/soc/codecs/ak4396.c index da34d20c8c75..4fd5945ca777 100755 --- a/sound/soc/codecs/ak4396.c +++ b/sound/soc/codecs/ak4396.c @@ -17,7 +17,6 @@ #include #include #include -#include /* AK4396 registers addresses */ #define AK4396_REG_CONTROL1 0x00 @@ -72,7 +71,7 @@ static void on_off_ext_amp(int i) #endif } -void codec_set_spk(bool on) +void ak4396_codec_set_spk(bool on) { on_off_ext_amp(on); } @@ -340,7 +339,7 @@ static int ak4396_remove(struct snd_soc_codec *codec) return ret; } -static int ak4396_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int ak4396_suspend(struct snd_soc_codec *codec) { return 0; } @@ -438,7 +437,7 @@ static int ak4396_spi_probe(struct spi_device *spi) return ret; } -static int __devexit ak4396_spi_remove(struct spi_device *spi) +static int ak4396_spi_remove(struct spi_device *spi) { snd_soc_unregister_codec(&spi->dev); kfree(spi_get_drvdata(spi)); @@ -451,7 +450,7 @@ static struct spi_driver ak4396_spi_driver = { .owner = THIS_MODULE, }, .probe = ak4396_spi_probe, - .remove = __devexit_p(ak4396_spi_remove), + .remove = ak4396_spi_remove, }; static int __init ak4396_init(void) diff --git a/sound/soc/codecs/cx2070x.c b/sound/soc/codecs/cx2070x.c index 47e6dfd9aab1..b9edb1b21b97 100755 --- a/sound/soc/codecs/cx2070x.c +++ b/sound/soc/codecs/cx2070x.c @@ -2085,7 +2085,7 @@ static int cx2070x_remove(struct snd_soc_codec *codec) return 0; } -static int cx2070x_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int cx2070x_suspend(struct snd_soc_codec *codec) { INFO("%lu: %s() called\n",jiffies,__func__); cx2070x_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/es8323.c b/sound/soc/codecs/es8323.c index 344796e6a70a..d7529b16e830 100755 --- a/sound/soc/codecs/es8323.c +++ b/sound/soc/codecs/es8323.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -28,10 +29,6 @@ #include #include -#include -#include -#include - //#include #include "es8323.h" @@ -65,8 +62,11 @@ static bool last_is_spk = false; #ifdef CONFIG_MACH_RK_FAC int es8323_hdmi_ctrl=0; #endif -#define SPK_CON RK30_PIN2_PD7 //RK30_PIN4_PC5 -#define HP_DET RK30_PIN0_PB5 +//#define SPK_CON RK30_PIN2_PD7 //RK30_PIN4_PC5 +//#define HP_DET RK30_PIN0_PB5 +#define INVALID_GPIO -1 +int es8323_spk_con_gpio = INVALID_GPIO; +int es8323_hp_det_gpio = INVALID_GPIO; static int HP_IRQ=0; static int hp_irq_flag = 0; //#define SPK_CTL RK29_PIN6_PB6 @@ -114,12 +114,12 @@ struct es8323_priv { static void hp_detect_do_switch(struct work_struct *work) { int ret; - int irq = gpio_to_irq(HP_DET); + int irq = gpio_to_irq(es8323_hp_det_gpio); unsigned int type; //rk28_send_wakeup_key(); printk("hjc:%s,irq=%d\n",__func__,irq); - type = gpio_get_value(HP_DET) ? IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; + type = gpio_get_value(es8323_hp_det_gpio) ? IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; ret = irq_set_irq_type(irq, type); if (ret < 0) { pr_err("%s: irq_set_irq_type(%d, %d) failed\n", __func__, irq, type); @@ -127,12 +127,12 @@ static void hp_detect_do_switch(struct work_struct *work) hp_irq_flag = 1; - if(0 == gpio_get_value(HP_DET)){ + if(0 == gpio_get_value(es8323_hp_det_gpio)){ printk("hp_det = 0,insert hp\n"); - gpio_set_value(SPK_CON,0); - }else if(1 == gpio_get_value(HP_DET)){ + gpio_set_value(es8323_spk_con_gpio,0); + }else if(1 == gpio_get_value(es8323_hp_det_gpio)){ printk("hp_det = 1,deinsert hp\n"); - gpio_set_value(SPK_CON,1); + gpio_set_value(es8323_spk_con_gpio,1); } enable_irq(irq); } @@ -425,7 +425,7 @@ int es8323_dapm_pre_event(struct snd_soc_dapm_widget* widget, struct snd_kcontro // printk("fun:%s, event:%d\r\n", __FUNCTION__, event); if (event==1) { - widget->dapm->dev_power = 1; + //widget->dapm->dev_power = 1; es8323_set_bias_level(widget->codec, SND_SOC_BIAS_PREPARE); } return 0; @@ -435,7 +435,7 @@ int es8323_dapm_post_event(struct snd_soc_dapm_widget* widget, struct snd_kcontr // printk("fun:%s, event:%d\r\n", __FUNCTION__, event); if (event==8) { - widget->dapm->dev_power = 0; + //widget->dapm->dev_power = 0; es8323_set_bias_level(widget->codec, SND_SOC_BIAS_STANDBY); } return 0; @@ -548,7 +548,7 @@ static void on_off_ext_amp(int i) return; } if(hp_irq_flag == 0) - gpio_set_value(SPK_CON, i); //delete by hjc + gpio_set_value(es8323_spk_con_gpio, i); //delete by hjc DBG("*** %s() SPEAKER set SPK_CON %d\n", __FUNCTION__, i); mdelay(50); @@ -909,7 +909,7 @@ static struct snd_soc_dai_driver es8323_dai = { .symmetric_rates = 1, }; -static int es8323_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int es8323_suspend(struct snd_soc_codec *codec) { // u16 i; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); @@ -931,7 +931,7 @@ static int es8323_suspend(struct snd_soc_codec *codec, pm_message_t state) snd_soc_write(codec, 0x01, 0x58); snd_soc_write(codec, 0x2b, 0x9c); msleep(50); - gpio_set_value(SPK_CON, 0); + gpio_set_value(es8323_spk_con_gpio, 0); return 0; } @@ -949,7 +949,7 @@ static int es8323_resume(struct snd_soc_codec *codec) snd_soc_write(codec, 0x31, es8323_DEF_VOL); snd_soc_write(codec, 0x30, es8323_DEF_VOL); snd_soc_write(codec, 0x19, 0x02); - gpio_set_value(SPK_CON, 1); + gpio_set_value(es8323_spk_con_gpio, 1); return 0; } @@ -1007,25 +1007,25 @@ static int es8323_probe(struct snd_soc_codec *codec) } gpio_direction_input(RK30_PIN0_PC7); #endif - ret = gpio_request(SPK_CON, NULL); + ret = gpio_request(es8323_spk_con_gpio, NULL); if (ret != 0) { printk("%s request SPK_CON error", __func__); return ret; } //gpio_set_value(SPK_CON, 1); - gpio_direction_output(SPK_CON,0); + gpio_direction_output(es8323_spk_con_gpio,0); - ret = gpio_request(HP_DET, NULL); + ret = gpio_request(es8323_hp_det_gpio, NULL); if (ret != 0) { printk("%s request HP_DET error", __func__); return ret; } - gpio_direction_input(HP_DET); + gpio_direction_input(es8323_hp_det_gpio); - flags = gpio_get_value(HP_DET) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING; + flags = gpio_get_value(es8323_hp_det_gpio) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING; - HP_IRQ = gpio_to_irq(HP_DET); + HP_IRQ = gpio_to_irq(es8323_hp_det_gpio); if (HP_IRQ){ ret = request_irq(HP_IRQ, hp_det_irq_handler, flags, "ES8323", NULL); if(ret == 0){ @@ -1131,8 +1131,8 @@ snd_soc_write(codec, 0x04,0x2c); //pdn_ana=0,ibiasgen_pdn=0 snd_soc_dapm_new_controls(dapm, es8323_dapm_widgets, ARRAY_SIZE(es8323_dapm_widgets)); snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); - - create_proc_read_entry("es8323_suspend", 0644, NULL, entry_read, NULL); + + //create_proc_read_entry("es8323_suspend", 0644, NULL, entry_read, NULL); return 0; } @@ -1143,25 +1143,14 @@ static int es8323_remove(struct snd_soc_codec *codec) return 0; } -#ifdef CONFIG_MACH_RK_FAC void es8323_codec_set_spk(bool on) -{ - if(es8323_hdmi_ctrl) - { - set_spk = on; - gpio_set_value(SPK_CON, on); - } -} -#else -void codec_set_spk(bool on) { DBG("Enter::%s----%d--, on = %d\n",__FUNCTION__,__LINE__, on); set_spk = on; - gpio_set_value(SPK_CON, on); + gpio_set_value(es8323_spk_con_gpio, on); //return; } -#endif static struct snd_soc_codec_driver soc_codec_dev_es8323 = { .probe = es8323_probe, @@ -1306,6 +1295,17 @@ static ssize_t es8323_store(struct device *dev, static struct device *es8323_dev = NULL; static struct class *es8323_class = NULL; static DEVICE_ATTR(es8323, 0664, es8323_show, es8323_store); + +/* +dts: + codec@10 { + compatible = "es8323"; + reg = <0x10>; + spk-con-gpio = <&gpio2 GPIO_D7 GPIO_ACTIVE_HIGH>; + hp-det-gpio = <&gpio0 GPIO_B5 GPIO_ACTIVE_HIGH>; + }; +*/ + static int es8323_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -1314,7 +1314,6 @@ static int es8323_i2c_probe(struct i2c_client *i2c, int ret = -1; struct i2c_adapter *adapter = to_i2c_adapter(i2c->dev.parent); char reg; - char tmp; if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { dev_warn(&adapter->dev, @@ -1328,9 +1327,21 @@ static int es8323_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, es8323); es8323->control_type = SND_SOC_I2C; - + + es8323_spk_con_gpio = of_get_named_gpio(i2c->dev.of_node, "spk-con-gpio", 0); + if (es8323_spk_con_gpio < 0) { + DBG("%s() Can not read property codec-en-gpio\n", __FUNCTION__); + es8323_spk_con_gpio = INVALID_GPIO; + } + + es8323_hp_det_gpio = of_get_named_gpio(i2c->dev.of_node, "hp-det-gpio", 0); + if (es8323_hp_det_gpio < 0) { + DBG("%s() Can not read property codec-en-gpio\n", __FUNCTION__); + es8323_hp_det_gpio = INVALID_GPIO; + } + reg = ES8323_DACCONTROL18; - ret = i2c_master_reg8_recv(i2c, reg, &tmp, 1 ,200 * 1000); + ret = i2c_master_recv(i2c, ®, 1); //ret =i2c_master_reg8_recv(client, 0x00, buf, 2, 200*1000);//i2c_write_bytes(client, &test_data, 1); //Test I2C connection. if (ret < 0){ printk("es8323 probe error\n"); @@ -1379,7 +1390,7 @@ MODULE_DEVICE_TABLE(i2c, es8323_i2c_id); void es8323_i2c_shutdown(struct i2c_client *client) { printk("Chenzy-------hkw-------%s\n", __func__); - gpio_direction_output(SPK_CON,0); + gpio_direction_output(es8323_spk_con_gpio,0); snd_soc_write(es8323_codec, ES8323_CONTROL2, 0x58); snd_soc_write(es8323_codec, ES8323_CONTROL1, 0x32); @@ -1394,6 +1405,7 @@ void es8323_i2c_shutdown(struct i2c_client *client) mdelay(100); } +/* #define I2C_CLK_NAME GPIO0B0_I2S8CHCLK_NAME #define I2C_CLK_GPIO_MODE GPIO0B_GPIO0B0 #define I2C_GPIO_OUTPUT GPIO_LOW @@ -1405,7 +1417,8 @@ void es8323_i2c_shutdown(struct i2c_client *client) #define I2C_MGPIO_OUTPUT GPIO_LOW #define I2C_MCLK_CLK_MODE GPIO0B_I2S_8CH_SCLK #define I2C_MCLK_GPIO RK30_PIN0_PB1 -static int es8323_i2c_suspend (struct i2c_client *client, pm_message_t mesg) +*/ +static int es8323_i2c_suspend (struct i2c_client *client) { #if 0 rk30_mux_api_set(I2C_CLK_NAME,I2C_CLK_GPIO_MODE); @@ -1424,13 +1437,13 @@ static int es8323_i2c_suspend (struct i2c_client *client, pm_message_t mesg) gpio_direction_output(I2C_MCLK_GPIO,I2C_MGPIO_OUTPUT); #endif - iomux_set(GPIO1_C1); + /* iomux_set(GPIO1_C1); if (gpio_request(RK30_PIN1_PC1, NULL)) { printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__); return -1; } gpio_direction_input(RK30_PIN1_PC1); - gpio_pull_updown(RK30_PIN1_PC1, PullDisable); + gpio_pull_updown(RK30_PIN1_PC1, PullDisable);*/ #if 0 iomux_set(GPIO1_C2); @@ -1463,8 +1476,8 @@ static int es8323_i2c_resume(struct i2c_client *client) rk30_mux_api_set(I2C_CLK_NAME,I2C_CLK_CLK_MODE); #endif - gpio_free(RK30_PIN1_PC1); - iomux_set(I2S0_SCLK); + /* gpio_free(RK30_PIN1_PC1); + iomux_set(I2S0_SCLK);*/ return 0; } diff --git a/sound/soc/codecs/hdmi_i2s.c b/sound/soc/codecs/hdmi_i2s.c index c923d656a4cc..ac552780d18b 100644 --- a/sound/soc/codecs/hdmi_i2s.c +++ b/sound/soc/codecs/hdmi_i2s.c @@ -5,27 +5,14 @@ * Author: chenjq */ -#include #include -#include -#include -#include -#include -#include - -#include -#include +#include +#include +#include +#include +#include #include -#include #include -#include -#include - -#include -#include -#include -#include -#include #if 0 #define DBG(x...) printk(KERN_INFO "hdmi i2s:"x) @@ -51,50 +38,49 @@ struct snd_soc_dai_driver hdmi_i2s_dai = { static struct snd_soc_codec_driver soc_codec_dev_hdmi_i2s; -static int hdmi_i2s_platform_probe(struct platform_device *pdev) +static int rockchip_hdmi_i2s_audio_probe(struct platform_device *pdev) { - DBG("Entered %s\n", __func__); + int ret; + + //set dev name to driver->name for sound card register + dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name); - return snd_soc_register_codec(&pdev->dev, + ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_hdmi_i2s, &hdmi_i2s_dai, 1); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + + return ret; } -static int hdmi_i2s_platform_remove(struct platform_device *pdev) +static int rockchip_hdmi_i2s_audio_remove(struct platform_device *pdev) { - DBG("Entered %s\n", __func__); - snd_soc_unregister_codec(&pdev->dev); return 0; } - -static struct platform_driver hdmi_i2s_driver = { - .probe = hdmi_i2s_platform_probe, - .remove = hdmi_i2s_platform_remove, - .driver = { - .name = "hdmi-i2s", - .owner = THIS_MODULE, - }, +#ifdef CONFIG_OF +static const struct of_device_id rockchip_hdmi_i2s_of_match[] = { + { .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, }; - -static int __init hdmi_i2s_init(void) -{ - DBG("Entered %s\n", __func__); - - return platform_driver_register(&hdmi_i2s_driver); -} - -static void __exit hdmi_i2s_exit(void) -{ - DBG("Entered %s\n", __func__); - - platform_driver_unregister(&hdmi_i2s_driver); -} -module_init(hdmi_i2s_init); -module_exit(hdmi_i2s_exit); +module_platform_driver(rockchip_hdmi_i2s_audio_driver); MODULE_DESCRIPTION("HDMI I2S Controller Driver"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/hdmi_spdif.c b/sound/soc/codecs/hdmi_spdif.c index 6a1a7e705cd7..a5a1203b7a5d 100644 --- a/sound/soc/codecs/hdmi_spdif.c +++ b/sound/soc/codecs/hdmi_spdif.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -30,7 +32,7 @@ static struct snd_soc_codec_driver soc_codec_spdif_dit; static struct snd_soc_dai_driver dit_stub_dai = { - .name = "dit-hifi", + .name = "rk-hdmi-spdif-hifi", .playback = { .stream_name = "Playback", .channels_min = 1, @@ -40,39 +42,48 @@ static struct snd_soc_dai_driver dit_stub_dai = { }, }; -static int spdif_dit_probe(struct platform_device *pdev) +static int rockchip_hdmi_spdif_audio_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit, + 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); + + if (ret) + printk("%s() register codec failed:%d\n", __FUNCTION__, ret); + + return ret; } -static int spdif_dit_remove(struct platform_device *pdev) +static int rockchip_hdmi_spdif_audio_remove(struct platform_device *pdev) { snd_soc_unregister_codec(&pdev->dev); + return 0; } -static struct platform_driver spdif_dit_driver = { - .probe = spdif_dit_probe, - .remove = spdif_dit_remove, - .driver = { - .name = DRV_NAME, - .owner = THIS_MODULE, - }, +#ifdef CONFIG_OF +static const struct of_device_id rockchip_hdmi_spdif_of_match[] = { + { .compatible = "hdmi-spdif", }, + {}, }; +MODULE_DEVICE_TABLE(of, rockchip_hdmi_spdif_of_match); +#endif /* CONFIG_OF */ -static int __init dit_modinit(void) -{ - return platform_driver_register(&spdif_dit_driver); -} - -static void __exit dit_exit(void) -{ - platform_driver_unregister(&spdif_dit_driver); -} +static struct platform_driver rockchip_hdmi_spdif_audio_driver = { + .driver = { + .name = "hdmi-spdif", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_hdmi_spdif_of_match), + }, + .probe = rockchip_hdmi_spdif_audio_probe, + .remove = rockchip_hdmi_spdif_audio_remove, +}; -module_init(dit_modinit); -module_exit(dit_exit); +module_platform_driver(rockchip_hdmi_spdif_audio_driver); MODULE_AUTHOR("Steve Chen "); MODULE_DESCRIPTION("SPDIF dummy codec driver"); diff --git a/sound/soc/codecs/rk1000_codec.c b/sound/soc/codecs/rk1000_codec.c index 5ac8f15ed0c3..a3c43c4a3413 100755 --- a/sound/soc/codecs/rk1000_codec.c +++ b/sound/soc/codecs/rk1000_codec.c @@ -29,11 +29,9 @@ #include #include #include -#include -#include #include "rk1000_codec.h" -#define RK1000_CODEC_PROC +//#define RK1000_CODEC_PROC #ifdef RK1000_CODEC_PROC #include #include @@ -702,7 +700,7 @@ static struct snd_soc_dai_driver rk1000_codec_dai[] = { } }; -static int rk1000_codec_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rk1000_codec_suspend(struct snd_soc_codec *codec) { DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); rk1000_codec_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -1116,7 +1114,8 @@ static int rk1000_control_probe(struct i2c_client *client, #if 1 printk("i2c write ret = 0x%x\n",ret); memset(data,0,sizeof(data)); - ret = i2c_master_reg8_recv(client, 0, data, (int)4, 20*1000); + ret = i2c_master_recv(client, data, 4); + //ret = i2c_master_reg8_recv(client, 0, data, (int)4, 20*1000); printk("i2c read reg %x, %x, %x, %x ret=x%x\n",data[0],data[1],data[2],data[3],ret); #endif diff --git a/sound/soc/codecs/rk2928_codec.c b/sound/soc/codecs/rk2928_codec.c index 17ea4849e4c6..e67d07040dcf 100755 --- a/sound/soc/codecs/rk2928_codec.c +++ b/sound/soc/codecs/rk2928_codec.c @@ -580,7 +580,7 @@ static int rk2928_remove(struct snd_soc_codec *codec) return 0; } -static int rk2928_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rk2928_suspend(struct snd_soc_codec *codec) { DBG("%s", __FUNCTION__); rk2928_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/rk3026_codec.c b/sound/soc/codecs/rk3026_codec.c index 42cfec90f2b3..3546d33c1c62 100755 --- a/sound/soc/codecs/rk3026_codec.c +++ b/sound/soc/codecs/rk3026_codec.c @@ -1926,7 +1926,7 @@ static struct snd_soc_dai_driver rk3026_dai[] = { }; -static int rk3026_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rk3026_suspend(struct snd_soc_codec *codec) { if (rk3026_for_mid) { diff --git a/sound/soc/codecs/rk3190_codec.c b/sound/soc/codecs/rk3190_codec.c index 7ce2c6698f40..c19e086dbe98 100755 --- a/sound/soc/codecs/rk3190_codec.c +++ b/sound/soc/codecs/rk3190_codec.c @@ -23,10 +23,7 @@ #include #include #include -#include -#include -#include -#include + #include "rk3190_codec.h" #ifdef CONFIG_RK_HEADSET_DET @@ -2064,7 +2061,7 @@ static struct snd_soc_dai_driver rk3190_dai[] = { }; -static int rk3190_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rk3190_suspend(struct snd_soc_codec *codec) { if (rk3190_for_mid) { @@ -2288,7 +2285,7 @@ static int rk3190_platform_probe(struct platform_device *pdev) &soc_codec_dev_rk3190, rk3190_dai, ARRAY_SIZE(rk3190_dai)); } -static __devexit int rk3190_platform_remove(struct platform_device *pdev) +static int rk3190_platform_remove(struct platform_device *pdev) { snd_soc_unregister_codec(&pdev->dev); return 0; diff --git a/sound/soc/codecs/rk610_codec.c b/sound/soc/codecs/rk610_codec.c index 0ea4b8214d6b..deeb482f2246 100755 --- a/sound/soc/codecs/rk610_codec.c +++ b/sound/soc/codecs/rk610_codec.c @@ -743,7 +743,7 @@ static struct snd_soc_dai_driver rk610_codec_dai = { .symmetric_rates = 1, }; -static int rk610_codec_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rk610_codec_suspend(struct snd_soc_codec *codec) { DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); rk610_codec_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/rk616_codec.c b/sound/soc/codecs/rk616_codec.c index 166527baa052..455814b27a3b 100755 --- a/sound/soc/codecs/rk616_codec.c +++ b/sound/soc/codecs/rk616_codec.c @@ -550,6 +550,10 @@ static int rk616_reset(struct snd_soc_codec *codec) snd_soc_write(codec, RK616_SINGNAL_ZC_CTL1, 0x3f); snd_soc_write(codec, RK616_SINGNAL_ZC_CTL2, 0xff); + //set ADC Power for MICBIAS + snd_soc_update_bits(codec, RK616_PWR_ADD1, + RK616_ADC_PWRD, 0); + return 0; } @@ -2356,7 +2360,7 @@ static int rk616_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, RK616_PWR_ADD1, rk616_reg_defaults[RK616_PWR_ADD1]); + snd_soc_write(codec, RK616_PWR_ADD1, rk616_reg_defaults[RK616_PWR_ADD1] & ~RK616_ADC_PWRD); snd_soc_write(codec, RK616_PWR_ADD2, rk616_reg_defaults[RK616_PWR_ADD2]); snd_soc_write(codec, RK616_PWR_ADD3, rk616_reg_defaults[RK616_PWR_ADD3]); if (!rk616_for_mid) @@ -2709,7 +2713,7 @@ static struct snd_soc_dai_driver rk616_dai[] = { }; -static int rk616_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rk616_suspend(struct snd_soc_codec *codec) { if (rk616_for_mid) rk616_codec_power_down(RK616_CODEC_ALL); diff --git a/sound/soc/codecs/rt3261-dsp.c b/sound/soc/codecs/rt3261-dsp.c index c425c94e9455..42e1accb5d3f 100644 --- a/sound/soc/codecs/rt3261-dsp.c +++ b/sound/soc/codecs/rt3261-dsp.c @@ -1287,7 +1287,7 @@ EXPORT_SYMBOL_GPL(rt_codec_dsp_ioctl_common); #endif #ifdef CONFIG_PM -int rt3261_dsp_suspend(struct snd_soc_codec *codec, pm_message_t state) +int rt3261_dsp_suspend(struct snd_soc_codec *codec) { return 0; } diff --git a/sound/soc/codecs/rt3261-dsp.h b/sound/soc/codecs/rt3261-dsp.h index adf4d23fdbb2..f78151bd0359 100644 --- a/sound/soc/codecs/rt3261-dsp.h +++ b/sound/soc/codecs/rt3261-dsp.h @@ -34,7 +34,7 @@ unsigned int rt3261_dsp_read(struct snd_soc_codec *codec, unsigned int reg); int rt3261_dsp_probe(struct snd_soc_codec *codec); int rt_codec_dsp_ioctl_common(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg); #ifdef CONFIG_PM -int rt3261_dsp_suspend(struct snd_soc_codec *codec, pm_message_t state); +int rt3261_dsp_suspend(struct snd_soc_codec *codec); int rt3261_dsp_resume(struct snd_soc_codec *codec); #endif diff --git a/sound/soc/codecs/rt3261.c b/sound/soc/codecs/rt3261.c index ee38eec20ba0..3651e4559067 100755 --- a/sound/soc/codecs/rt3261.c +++ b/sound/soc/codecs/rt3261.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -24,16 +26,6 @@ #include #include #include -#include -#include -#include - -//#define RT3261_PROC -#ifdef RT3261_PROC -#include -#include -#include -#endif //#define USE_INT_CLK #define DIFFERENTIAL 1 @@ -41,9 +33,23 @@ #define TWO_SPK 2 #define ONE_SPK 1 +enum { + SPK_AMPLIFY_ZERO_POINT_FIVE_WATT=1, + SPK_AMPLIFY_ZERO_POINT_SIX_WATT, + SPK_AMPLIFY_ZERO_POINT_EIGHT_WATT, + SPK_AMPLIFY_ONE_WATT, +}; + +enum { + LR_NORMAL, + LR_SWAP, + LEFT_COPY_TO_RIGHT, + RIGHT_COPY_LEFT, +}; + static struct snd_soc_codec *rt3261_codec; -#if 0 +#if 1 #define DBG(x...) printk(KERN_DEBUG x) #else #define DBG(x...) @@ -278,6 +284,7 @@ static unsigned int rt3261_read(struct snd_soc_codec *codec, static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value, const void *data, int len) { + struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec); int ret; if (!snd_soc_codec_volatile_register(codec, reg) && @@ -293,11 +300,8 @@ static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg, return 0; } - ret = i2c_master_normal_send(codec->control_data, data, len,400*1000); - if (ret == len) + if (i2c_master_send(rt3261->i2c, data, len) == len) return 0; - if (ret < 0) - return ret; else return -EIO; } @@ -561,9 +565,8 @@ static int rt3261_readable_register( } } -void codec_set_spk(bool on) +static void rt3261_codec_set_spk(bool on) { - struct snd_soc_codec *codec = rt3261_codec; DBG("%s: %d\n", __func__, on); @@ -870,10 +873,10 @@ static int rt3261_mic2_put(struct snd_kcontrol *kcontrol, } //bard 8-9 e -void hp_amp_power(struct snd_soc_codec *codec, int on) +void rt3261_hp_amp_power(struct snd_soc_codec *codec, int on) { static int hp_amp_power_count; - printk("hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); + printk("rt3261_hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); // dump_reg(codec); if(on) { if(hp_amp_power_count <= 0) { @@ -1839,8 +1842,8 @@ static const struct snd_kcontrol_new rt3261_sdi_mux = static int rt3261_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; - unsigned int val, mask; + //struct snd_soc_codec *codec = w->codec; + //unsigned int val, mask; switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1878,7 +1881,7 @@ static int rt3261_mono_adcl_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; - unsigned int val, mask; + //unsigned int val, mask; switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1902,7 +1905,7 @@ static int rt3261_mono_adcr_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; - unsigned int val, mask; + //unsigned int val, mask; switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1998,7 +2001,7 @@ static void rt3261_pmu_depop(struct snd_soc_codec *codec) RT3261_HP_CO_EN | RT3261_HP_SG_EN); rt3261_index_update_bits(codec, RT3261_CHPUMP_INT_REG1,0x0700, 0x0400); //bard 12-6 #else - hp_amp_power(codec, 1); + rt3261_hp_amp_power(codec, 1); #endif /* headphone unmute sequence */ snd_soc_update_bits(codec, RT3261_DEPOP_M3, @@ -2071,7 +2074,7 @@ static void rt3261_pmd_depop(struct snd_soc_codec *codec) RT3261_PWR_HP_L | RT3261_PWR_HP_R | RT3261_PWR_HA, 0); #else - hp_amp_power(codec, 0); + rt3261_hp_amp_power(codec, 0); #endif } #else //one bit @@ -2195,7 +2198,7 @@ static int rt3261_lout_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power(codec,1); + rt3261_hp_amp_power(codec,1); snd_soc_update_bits(codec, RT3261_PWR_ANLG1, RT3261_PWR_LM, RT3261_PWR_LM); //bard 10-18 snd_soc_update_bits(codec, RT3261_OUTPUT, @@ -2208,7 +2211,7 @@ static int rt3261_lout_event(struct snd_soc_dapm_widget *w, RT3261_L_MUTE | RT3261_R_MUTE); snd_soc_update_bits(codec, RT3261_PWR_ANLG1, RT3261_PWR_LM, 0); //bard 10-18 - hp_amp_power(codec,0); + rt3261_hp_amp_power(codec,0); break; default: @@ -3349,9 +3352,6 @@ static int rt3261_set_bias_level(struct snd_soc_codec *codec, return 0; } - -static int rt3261_proc_init(void); - static int rt3261_probe(struct snd_soc_codec *codec) { @@ -3370,10 +3370,6 @@ static int rt3261_probe(struct snd_soc_codec *codec) return ret; } codec->write = rt3261_write; - - #ifdef RT3261_PROC - rt3261_proc_init(); - #endif #if defined (CONFIG_SND_SOC_RT5623) struct clk *iis_clk; @@ -3478,7 +3474,7 @@ static int rt3261_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt3261_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt3261_suspend(struct snd_soc_codec *codec) { #if defined (CONFIG_SND_SOC_RT3261) /* After opening LDO of DSP, then close LDO of codec. @@ -3487,7 +3483,7 @@ static int rt3261_suspend(struct snd_soc_codec *codec, pm_message_t state) * (3) DSP IIS interface power off * (4) Toggle pin of codec LDO1 to power off */ - rt3261_dsp_suspend(codec, state); + rt3261_dsp_suspend(codec); #endif rt3261_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -3581,28 +3577,112 @@ static const struct i2c_device_id rt3261_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt3261_i2c_id); +#ifdef CONFIG_OF +/* +dts: + codec@1c { + compatible = "rt3261"; + reg = <0x1c>; + codec-en-gpio = <&gpio3 GPIO_D7 GPIO_ACTIVE_HIGH>; + spk-num= <2>; + modem-input-mode = <1>; + lout-to-modem_mode = <1>; + spk-amplify = <2>; + playback-if1-data_control = <0>; + playback-if2-data_control = <0>; + }; +*/ + +static int rt3261_parse_dt_property(struct device *dev, + struct rt3261_priv *rt3261) +{ + struct device_node *node = dev->of_node; + int ret; + enum of_gpio_flags flags; + + printk("%s()\n", __FUNCTION__); + + if (!node) + return -ENODEV; + + rt3261->codec_en_gpio = of_get_named_gpio_flags(node, "codec-en-gpio", 0, &flags); + if (rt3261->codec_en_gpio < 0) { + DBG("%s() Can not read property codec-en-gpio\n", __FUNCTION__); + } else { + ret = devm_gpio_request(dev, rt3261->codec_en_gpio, "codec_en_gpio"); + if(ret){ + printk("%s() codec_en_gpio request ERROR", __FUNCTION__); + return ret; + } + ret = gpio_direction_output(rt3261->codec_en_gpio , !flags); + if(ret){ + printk("%s() codec_en_gpio set ERROR", __FUNCTION__); + return ret; + } + } + + ret = of_property_read_u32(node, "spk-num", &rt3261->spk_num); + if (ret < 0) { + DBG("%s() Can not read property spk-num\n", __FUNCTION__); + rt3261->spk_num = TWO_SPK; + } + + ret = of_property_read_u32(node, "modem-input-mode", &rt3261->modem_input_mode); + if (ret < 0) { + DBG("%s() Can not read property modem-input-mode\n", __FUNCTION__); + rt3261->modem_input_mode = DIFFERENTIAL; + } + + ret = of_property_read_u32(node, "lout-to-modem-mode", &rt3261->lout_to_modem_mode); + if (ret < 0) { + DBG("%s() Can not read property lout-to-modem-mode\n", __FUNCTION__); + rt3261->lout_to_modem_mode = DIFFERENTIAL; + } + + ret = of_property_read_u32(node, "spk-amplify", &rt3261->spk_amplify); + if (ret < 0) { + DBG("%s() Can not read property spk-amplify\n", __FUNCTION__); + rt3261->spk_amplify = SPK_AMPLIFY_ZERO_POINT_SIX_WATT; + } + + ret = of_property_read_u32(node, "playback-if1-data-control", &rt3261->playback_if1_data_control); + if (ret < 0) { + DBG("%s() Can not read property playback-if1-data-control\n", __FUNCTION__); + rt3261->playback_if1_data_control = LR_NORMAL; + } + + ret = of_property_read_u32(node, "playback-if2-data-control", &rt3261->playback_if2_data_control); + if (ret < 0) { + DBG("%s() Can not read property playback-if2-data-control\n", __FUNCTION__); + rt3261->playback_if1_data_control = LR_NORMAL; + } + return 0; +} +#else +static int rt3261_parse_dt_property(struct device *dev, + struct rt3261_priv *rt3261) +{ + return -ENOSYS; +} +#endif //#ifdef CONFIG_OF + static int rt3261_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct rt3261_priv *rt3261; int ret; - struct rt3261_platform_data *pdata = pdata = i2c->dev.platform_data; rt3261 = kzalloc(sizeof(struct rt3261_priv), GFP_KERNEL); if (NULL == rt3261) return -ENOMEM; - rt3261->codec_en_gpio = pdata->codec_en_gpio; - rt3261->io_init = pdata->io_init; - rt3261->spk_num = pdata->spk_num; - rt3261->modem_input_mode = pdata->modem_input_mode; - rt3261->lout_to_modem_mode = pdata->lout_to_modem_mode; - rt3261->spk_amplify = pdata->spk_amplify; - rt3261->playback_if1_data_control = pdata->playback_if1_data_control; - rt3261->playback_if2_data_control = pdata->playback_if2_data_control; + rt3261->i2c = i2c; - if(rt3261->io_init) - rt3261->io_init(pdata->codec_en_gpio, pdata->codec_en_gpio_info.iomux_name, pdata->codec_en_gpio_info.iomux_mode); + ret = rt3261_parse_dt_property(&i2c->dev, rt3261); + if (ret < 0) { + printk("%s() parse device tree property error %d\n", __FUNCTION__, ret); + return ret; + } #if defined (CONFIG_SND_SOC_RT5623) rt3261->modem_is_open = 0; @@ -3660,176 +3740,3 @@ module_exit(rt3261_modexit); MODULE_DESCRIPTION("ASoC RT3261 driver"); MODULE_AUTHOR("Johnny Hsu "); MODULE_LICENSE("GPL"); - - -#ifdef RT3261_PROC - -static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer, - unsigned long len, void *data) -{ - char *cookie_pot; - char *p; - int reg; - int i; - int value; - #if defined (CONFIG_SND_SOC_RT3261) - struct rt3261_dsp_param param; - #endif - - cookie_pot = (char *)vmalloc( len ); - if (!cookie_pot) - { - return -ENOMEM; - } - else - { - if (copy_from_user( cookie_pot, buffer, len )) - return -EFAULT; - } - - switch(cookie_pot[0]) - { - case 'r': - case 'R': - printk("Read reg debug\n"); - if(cookie_pot[1] ==':') - { - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,","))) - { - reg = simple_strtol(p,NULL,16); - value = rt3261_read(rt3261_codec,reg); - printk("rt3261_read:0x%04x = 0x%04x\n",reg,value); - } - printk("\n"); - } - else - { - printk("Error Read reg debug.\n"); - printk("For example: echo r:22,23,24,25>rt3261_ts\n"); - } - break; - case 'w': - case 'W': - printk("Write reg debug\n"); - if(cookie_pot[1] ==':') - { - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,"="))) - { - reg = simple_strtol(p,NULL,16); - p=strsep(&cookie_pot,","); - value = simple_strtol(p,NULL,16); - rt3261_write(rt3261_codec,reg,value); - printk("rt3261_write:0x%04x = 0x%04x\n",reg,value); - } - printk("\n"); - } - else - { - printk("Error Write reg debug.\n"); - printk("For example: w:22=0,23=0,24=0,25=0>rt3261_ts\n"); - } - break; - case 'a': - printk("Dump rt3261 index reg \n"); - - for (i = 0; i < 0xb4; i++) - { - value = rt3261_index_read(rt3261_codec, i); - printk("rt3261_index_read:0x%04x = 0x%04x\n",i,value); - } - break; - #if defined (CONFIG_SND_SOC_RT3261) - case 'b': - param.cmd_fmt = 0x00e0; - param.cmd = RT3261_DSP_CMD_MW; - printk("Write dsp reg debug\n"); - if(cookie_pot[1] ==':') - { - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,"="))) - { - param.addr = simple_strtol(p,NULL,16); - p=strsep(&cookie_pot,","); - param.data = simple_strtol(p,NULL,16); - rt3261_dsp_write(rt3261_codec,¶m); - printk("rt3261_dsp_write:0x%04x = 0x%04x\n",param.addr,param.data); - } - printk("\n"); - } - break; - case 'c': - printk("Read dsp reg debug\n"); - if(cookie_pot[1] ==':') - { - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,","))) - { - reg = simple_strtol(p,NULL,16); - value = rt3261_dsp_read(rt3261_codec,reg); - printk("rt3261_dsp_read:0x%04x = 0x%04x\n",reg,value); - } - printk("\n"); - } - break; - #endif - case 'd': - if(cookie_pot[1] ==':') - { - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,"="))) - { - reg = simple_strtol(p,NULL,16); - p=strsep(&cookie_pot,","); - value = simple_strtol(p,NULL,16); - rt3261_index_write(rt3261_codec,reg,value); - printk("rt3261_index_write:0x%04x = 0x%04x\n",reg,value); - } - printk("\n"); - } - break; - case 'e': - if(cookie_pot[1] ==':') - { - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,","))) - { - reg = simple_strtol(p,NULL,16); - value = rt3261_index_read(rt3261_codec,reg); - printk("rt3261_index_read:0x%04x = 0x%04x\n",reg,value); - } - printk("\n"); - } - break; - default: - printk("Help for rt3261_ts .\n-->The Cmd list: \n"); - printk("-->'d&&D' Open or Off the debug\n"); - printk("-->'r&&R' Read reg debug,Example: echo 'r:22,23,24,25'>rt3261_ts\n"); - printk("-->'w&&W' Write reg debug,Example: echo 'w:22=0,23=0,24=0,25=0'>rt3261_ts\n"); - break; - } - - return len; -} - -static const struct file_operations rt3261_proc_fops = { - .owner = THIS_MODULE, -}; - -static int rt3261_proc_init(void) -{ - struct proc_dir_entry *rt3261_proc_entry; - rt3261_proc_entry = create_proc_entry("driver/rt3261_ts", 0777, NULL); - if(rt3261_proc_entry != NULL) - { - rt3261_proc_entry->write_proc = rt3261_proc_write; - return 0; - } - else - { - printk("create proc error !\n"); - return -1; - } -} -#endif diff --git a/sound/soc/codecs/rt3261.h b/sound/soc/codecs/rt3261.h index 154ab17b2064..e5e12f33061c 100755 --- a/sound/soc/codecs/rt3261.h +++ b/sound/soc/codecs/rt3261.h @@ -2073,10 +2073,6 @@ enum { #define RT3261_HEADSET_DET BIT(1) #define RT3261_HEADPHO_DET BIT(2) -void codec_set_spk(bool on); - -int rt3261_headset_mic_detect(int jack_insert); - /* System Clock Source */ enum { RT3261_SCLK_S_MCLK, @@ -2134,6 +2130,7 @@ struct rt3261_pll_code { }; struct rt3261_priv { + struct i2c_client *i2c; struct snd_soc_codec *codec; struct delayed_work patch_work; @@ -2155,7 +2152,6 @@ struct rt3261_priv { bool dsp_rec_pass; unsigned int codec_en_gpio; - int (*io_init)(int gpio, char *iomux_name, int iomux_mode); unsigned int modem_is_open; unsigned int spk_num; @@ -2169,4 +2165,7 @@ struct rt3261_priv { int rt3261_conn_mux_path(struct snd_soc_codec *codec, char *widget_name, char *path_name); +int rt3261_headset_mic_detect(int jack_insert); +static void rt3261_codec_set_spk(bool on); + #endif /* __RT3261_H__ */ diff --git a/sound/soc/codecs/rt5512.c b/sound/soc/codecs/rt5512.c index fc62e50ed22f..1a339c0a4b58 100755 --- a/sound/soc/codecs/rt5512.c +++ b/sound/soc/codecs/rt5512.c @@ -1493,7 +1493,7 @@ static int rt5512_codec_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5512_codec_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt5512_codec_suspend(struct snd_soc_codec *codec) { RT_DBG("\n"); rt5512_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index 7e68ce5dcf95..dc63f4ef2b04 100755 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -641,7 +641,7 @@ static int rt5616_adc_event(struct snd_soc_dapm_widget *w, return 0; } -void hp_amp_power(struct snd_soc_codec *codec, int on) +void rt5616_hp_amp_power(struct snd_soc_codec *codec, int on) { static int hp_amp_power_count; @@ -701,7 +701,7 @@ void hp_amp_power(struct snd_soc_codec *codec, int on) static void rt5616_pmu_depop(struct snd_soc_codec *codec) { - hp_amp_power(codec, 1); + rt5616_hp_amp_power(codec, 1); /* headphone unmute sequence */ snd_soc_update_bits(codec, RT5616_DEPOP_M3, @@ -753,7 +753,7 @@ static void rt5616_pmd_depop(struct snd_soc_codec *codec) RT5616_L_MUTE | RT5616_R_MUTE, RT5616_L_MUTE | RT5616_R_MUTE); msleep(30); - hp_amp_power(codec, 0); + rt5616_hp_amp_power(codec, 0); } @@ -785,7 +785,7 @@ static int rt5616_lout_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power(codec,1); + rt5616_hp_amp_power(codec,1); snd_soc_update_bits(codec, RT5616_LOUT_CTRL1, RT5616_L_MUTE | RT5616_R_MUTE, 0); break; @@ -794,7 +794,7 @@ static int rt5616_lout_event(struct snd_soc_dapm_widget *w, snd_soc_update_bits(codec, RT5616_LOUT_CTRL1, RT5616_L_MUTE | RT5616_R_MUTE, RT5616_L_MUTE | RT5616_R_MUTE); - hp_amp_power(codec,0); + rt5616_hp_amp_power(codec,0); break; default: @@ -1480,7 +1480,7 @@ static int rt5616_set_bias_level(struct snd_soc_codec *codec, return 0; } -void codec_set_spk(bool on) +void rt5616_codec_set_spk(bool on) { struct snd_soc_codec *codec = rt5616_codec; @@ -1557,7 +1557,7 @@ static int rt5616_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5616_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt5616_suspend(struct snd_soc_codec *codec) { rt5616_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; diff --git a/sound/soc/codecs/rt5621.c b/sound/soc/codecs/rt5621.c index 9652aa7fc17d..5b9160e42279 100644 --- a/sound/soc/codecs/rt5621.c +++ b/sound/soc/codecs/rt5621.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,7 @@ #include #include -#include +//#include #include "rt5621.h" @@ -40,8 +41,13 @@ #define DBG(x...) #endif +#define GPIO_HIGH 1 +#define GPIO_LOW 0 +#define INVALID_GPIO -1 + #define RT5621_VERSION "0.01 alsa 1.0.24" +int rt5621_spk_ctl_gpio = INVALID_GPIO; static int caps_charge = 500; module_param(caps_charge, int, 0); MODULE_PARM_DESC(caps_charge, "RT5621 cap charge time (msecs)"); @@ -958,7 +964,7 @@ static int rt5621_reg_init(struct snd_soc_codec *codec) return 0; } -void codec_set_spk(bool on) +void rt5621_codec_set_spk(bool on) { struct snd_soc_codec *codec = rt5621_codec; @@ -1046,7 +1052,7 @@ static int rt5621_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5621_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt5621_suspend(struct snd_soc_codec *codec) { rt5621_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -1172,6 +1178,14 @@ static const struct i2c_device_id rt5621_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5621_i2c_id); +/* +dts: + codec@1a { + compatible = "rt5621"; + reg = <0x1a>; + spk-ctl-gpio = <&gpio6 GPIO_B6 GPIO_ACTIVE_HIGH>; + }; +*/ static int rt5621_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -1180,14 +1194,22 @@ static int rt5621_i2c_probe(struct i2c_client *i2c, printk("##################### %s ######################\n", __FUNCTION__); - ret = gpio_request(RK29_PIN6_PB6, "spk_con"); +#ifdef CONFIG_OF + rt5621_spk_ctl_gpio= of_get_named_gpio_flags(i2c->dev.of_node, "spk-ctl-gpio", 0, NULL); + if (rt5621_spk_ctl_gpio < 0) { + DBG("%s() Can not read property spk-ctl-gpio\n", __FUNCTION__); + rt5621_spk_ctl_gpio = INVALID_GPIO; + } +#endif //#ifdef CONFIG_OF + + ret = gpio_request(rt5621_spk_ctl_gpio, "spk_con"); if(ret < 0){ printk("gpio request spk_con error!\n"); } else{ printk("########################### set spk_con HIGH ##################################\n"); - gpio_direction_output(RK29_PIN6_PB6, GPIO_HIGH); - gpio_set_value(RK29_PIN6_PB6, GPIO_HIGH); + gpio_direction_output(rt5621_spk_ctl_gpio, GPIO_HIGH); + gpio_set_value(rt5621_spk_ctl_gpio, GPIO_HIGH); } rt5621 = kzalloc(sizeof(struct rt5621_priv), GFP_KERNEL); @@ -1204,7 +1226,7 @@ static int rt5621_i2c_probe(struct i2c_client *i2c, return ret; } -static __devexit int rt5621_i2c_remove(struct i2c_client *i2c) +static int rt5621_i2c_remove(struct i2c_client *i2c) { snd_soc_unregister_codec(&i2c->dev); kfree(i2c_get_clientdata(i2c)); @@ -1217,7 +1239,7 @@ struct i2c_driver rt5621_i2c_driver = { .owner = THIS_MODULE, }, .probe = rt5621_i2c_probe, - .remove = __devexit_p(rt5621_i2c_remove), + .remove = rt5621_i2c_remove, .id_table = rt5621_i2c_id, }; diff --git a/sound/soc/codecs/rt5625.c b/sound/soc/codecs/rt5625.c index 7ef6437e47e5..94d1489e6c63 100644 --- a/sound/soc/codecs/rt5625.c +++ b/sound/soc/codecs/rt5625.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -26,9 +27,10 @@ #include #include #include "rt5625.h" -#include -#define RT5625_PROC +#define INVALID_GPIO -1 + +//#define RT5625_PROC #ifdef RT5625_PROC #include #include @@ -2842,7 +2844,7 @@ static int rt5625_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5625_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt5625_suspend(struct snd_soc_codec *codec) { rt5625_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -2942,20 +2944,73 @@ static const struct i2c_device_id rt5625_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5625_i2c_id); +#ifdef CONFIG_OF +/* +dts: + codec@1e { + compatible = "rt5625"; + reg = <0x1e>; + spk-ctr-pin = <&gpio3 GPIO_D7 GPIO_ACTIVE_HIGH>; + spk-ctr-on = <1>; + spk-ctr-off = <0>; + }; +*/ + +static int rt5625_parse_dt_property(struct device *dev, + struct rt5625_priv *rt5625) +{ + struct device_node *node = dev->of_node; + int ret; + + printk("%s()\n", __FUNCTION__); + + if (!node) + return -ENODEV; + + rt5625->spk_ctr_pin= of_get_named_gpio_flags(node, "spk-ctr-pin", 0, NULL); + if (rt5625->spk_ctr_pin < 0) { + DBG("%s() Can not read property spk-ctr-pin\n", __FUNCTION__); + rt5625->spk_ctr_pin = INVALID_GPIO; + } + + ret = of_property_read_u32(node, "spk-ctr-on", &rt5625->spk_ctr_on); + if (ret < 0) { + DBG("%s() Can not read property spk-ctr-on\n", __FUNCTION__); + rt5625->spk_ctr_on = 1; + } + + ret = of_property_read_u32(node, "spk-ctr-off", &rt5625->spk_ctr_off); + if (ret < 0) { + DBG("%s() Can not read property spk-ctr-off\n", __FUNCTION__); + rt5625->spk_ctr_off = 0; + } + + return 0; +} +#else +static int rt5625_parse_dt_property(struct device *dev, + struct rt3261_priv *rt3261) +{ + return -ENOSYS; +} +#endif //#ifdef CONFIG_OF + static int rt5625_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct rt5625_priv *rt5625; int ret; - struct rt5625_platform_data *pdata = pdata = i2c->dev.platform_data; + //struct rt5625_platform_data *pdata = pdata = i2c->dev.platform_data; rt5625 = kzalloc(sizeof(struct rt5625_priv), GFP_KERNEL); if (NULL == rt5625) return -ENOMEM; - rt5625->spk_ctr_pin = pdata->spk_ctr_pin; - rt5625->spk_ctr_on = pdata->spk_ctr_on; - rt5625->spk_ctr_off = pdata->spk_ctr_off; + ret = rt5625_parse_dt_property(&i2c->dev, rt5625); + if (ret < 0) { + printk("%s() parse device tree property error %d\n", __FUNCTION__, ret); + return ret; + } if(rt5625->spk_ctr_pin != INVALID_GPIO) { @@ -2974,7 +3029,7 @@ static int rt5625_i2c_probe(struct i2c_client *i2c, return ret; } -static __devexit int rt5625_i2c_remove(struct i2c_client *i2c) +static int rt5625_i2c_remove(struct i2c_client *i2c) { snd_soc_unregister_codec(&i2c->dev); kfree(i2c_get_clientdata(i2c)); @@ -2987,7 +3042,7 @@ struct i2c_driver rt5625_i2c_driver = { .owner = THIS_MODULE, }, .probe = rt5625_i2c_probe, - .remove = __devexit_p(rt5625_i2c_remove), + .remove = rt5625_i2c_remove, .id_table = rt5625_i2c_id, }; diff --git a/sound/soc/codecs/rt5631_phone.c b/sound/soc/codecs/rt5631_phone.c index df48a5fcee6f..53a8ab856d13 100755 --- a/sound/soc/codecs/rt5631_phone.c +++ b/sound/soc/codecs/rt5631_phone.c @@ -121,7 +121,7 @@ static const u16 rt5631_reg[RT5631_VENDOR_ID2 + 1] = { [RT5631_PSEUDO_SPATL_CTRL] = 0x0553, }; -void codec_set_spk(bool on) +void rt5631_codec_set_spk(bool on) { struct snd_soc_codec *codec = rt5631_codec; @@ -2246,7 +2246,7 @@ static int rt5631_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5631_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt5631_suspend(struct snd_soc_codec *codec) { rt5631_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; diff --git a/sound/soc/codecs/rt5639.c b/sound/soc/codecs/rt5639.c index da86fb7a299b..cf17e7fcbc6c 100755 --- a/sound/soc/codecs/rt5639.c +++ b/sound/soc/codecs/rt5639.c @@ -25,15 +25,6 @@ #include #include -#define RT3261_PROC -#ifdef RT3261_PROC -#include -#include -#include -char debug_write_read = 0; -#endif -static struct snd_soc_codec *rt3261_codec; - #define RTK_IOCTL #ifdef RTK_IOCTL #if defined(CONFIG_SND_HWDEP) || defined(CONFIG_SND_HWDEP_MODULE) @@ -42,54 +33,6 @@ static struct snd_soc_codec *rt3261_codec; #endif #endif -static unsigned int rt3261_read(struct snd_soc_codec *codec, - unsigned int reg) -{ - unsigned int val; - - val = codec->hw_read(codec, reg); - return val; -} - -static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int value, const void *data, int len) -{ - int ret; - - if (!snd_soc_codec_volatile_register(codec, reg) && - reg < codec->driver->reg_cache_size && - !codec->cache_bypass) { - ret = snd_soc_cache_write(codec, reg, value); - if (ret < 0) - return -1; - } - - if (codec->cache_only) { - codec->cache_sync = 1; - return 0; - } - - ret = codec->hw_write(codec->control_data, data, len); - if (ret == len) - return 0; - if (ret < 0) - return ret; - else - return -EIO; -} - -static int rt3261_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int value) -{ - u8 data[3]; - - data[0] = reg; - data[1] = (value >> 8) & 0xff; - data[2] = value & 0xff; - - return do_hw_write(codec, reg, value, data, 3); -} - #include "rt5639.h" #define RT5639_REG_RW 0 /* for debug */ @@ -1506,10 +1449,10 @@ static int rt5639_set_dmic2_event(struct snd_soc_dapm_widget *w, } #if USE_ONEBIT_DEPOP -void hp_amp_power(struct snd_soc_codec *codec, int on) +void rt5639_hp_amp_power(struct snd_soc_codec *codec, int on) { static int hp_amp_power_count; -// printk("one bit hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); +// printk("one bit rt5639_hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); if(on) { if(hp_amp_power_count <= 0) { @@ -1567,7 +1510,7 @@ void hp_amp_power(struct snd_soc_codec *codec, int on) static void rt5639_pmu_depop(struct snd_soc_codec *codec) { - hp_amp_power(codec, 1); + rt5639_hp_amp_power(codec, 1); /* headphone unmute sequence */ msleep(5); snd_soc_update_bits(codec, RT5639_HP_VOL, @@ -1591,15 +1534,15 @@ static void rt5639_pmd_depop(struct snd_soc_codec *codec) RT5639_L_MUTE | RT5639_R_MUTE, RT5639_L_MUTE | RT5639_R_MUTE); msleep(50); - hp_amp_power(codec, 0); + rt5639_hp_amp_power(codec, 0); } #else //seq -void hp_amp_power(struct snd_soc_codec *codec, int on) +void rt5639_hp_amp_power(struct snd_soc_codec *codec, int on) { static int hp_amp_power_count; -// printk("hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); +// printk("rt5639_hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); if(on) { if(hp_amp_power_count <= 0) { @@ -1656,7 +1599,7 @@ void hp_amp_power(struct snd_soc_codec *codec, int on) static void rt5639_pmu_depop(struct snd_soc_codec *codec) { - hp_amp_power(codec, 1); + rt5639_hp_amp_power(codec, 1); /* headphone unmute sequence */ snd_soc_update_bits(codec, RT5639_DEPOP_M3, RT5639_CP_FQ1_MASK | RT5639_CP_FQ2_MASK | RT5639_CP_FQ3_MASK, @@ -1703,7 +1646,7 @@ static void rt5639_pmd_depop(struct snd_soc_codec *codec) RT5639_L_MUTE | RT5639_R_MUTE, RT5639_L_MUTE | RT5639_R_MUTE); msleep(30); - hp_amp_power(codec, 0); + rt5639_hp_amp_power(codec, 0); } #endif @@ -1761,7 +1704,7 @@ static int rt5639_lout_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power(codec,1); + rt5639_hp_amp_power(codec,1); snd_soc_update_bits(codec, RT5639_PWR_ANLG1, RT5639_PWR_LM, RT5639_PWR_LM); snd_soc_update_bits(codec, RT5639_OUTPUT, @@ -1774,7 +1717,7 @@ static int rt5639_lout_event(struct snd_soc_dapm_widget *w, RT5639_L_MUTE | RT5639_R_MUTE); snd_soc_update_bits(codec, RT5639_PWR_ANLG1, RT5639_PWR_LM, 0); - hp_amp_power(codec,0); + rt5639_hp_amp_power(codec,0); break; default: @@ -3001,8 +2944,6 @@ static int rt5639_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt3261_proc_init(void); - static int rt5639_probe(struct snd_soc_codec *codec) { struct rt5639_priv *rt5639 = snd_soc_codec_get_drvdata(codec); @@ -3015,10 +2956,6 @@ static int rt5639_probe(struct snd_soc_codec *codec) dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } - -#ifdef RT3261_PROC - rt3261_proc_init(); -#endif rt5639_reset(codec); snd_soc_update_bits(codec, RT5639_PWR_ANLG1, @@ -3072,7 +3009,7 @@ static int rt5639_probe(struct snd_soc_codec *codec) ioctl_ops->index_read = rt5639_index_read; ioctl_ops->index_update_bits = rt5639_index_update_bits; ioctl_ops->ioctl_common = rt5639_ioctl_common; - realtek_ce_init_hwdep(codec); + rt56xx_ce_init_hwdep(codec); #endif #endif @@ -3089,7 +3026,6 @@ static int rt5639_probe(struct snd_soc_codec *codec) "Failed to create codex_reg sysfs files: %d\n", ret); return ret; } - rt3261_codec = codec; return 0; } @@ -3101,7 +3037,7 @@ static int rt5639_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5639_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt5639_suspend(struct snd_soc_codec *codec) { rt5639_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -3253,125 +3189,3 @@ module_exit(rt5639_modexit); MODULE_DESCRIPTION("ASoC RT5639 driver"); MODULE_AUTHOR("Johnny Hsu "); MODULE_LICENSE("GPL"); - -#ifdef RT3261_PROC - -static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer, - unsigned long len, void *data) -{ - char *cookie_pot; - char *p; - int reg; - int i; - int value; - - cookie_pot = (char *)vmalloc( len ); - if (!cookie_pot) - { - return -ENOMEM; - } - else - { - if (copy_from_user( cookie_pot, buffer, len )) - return -EFAULT; - } - - switch(cookie_pot[0]) - { - case 'd': - case 'D': - debug_write_read ++; - debug_write_read %= 2; - if(debug_write_read != 0) - printk("Debug read and write reg on\n"); - else - printk("Debug read and write reg off\n"); - break; - case 'r': - case 'R': - printk("Read reg debug\n"); - if(cookie_pot[1] ==':') - { - debug_write_read = 1; - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,","))) - { - reg = simple_strtol(p,NULL,16); - value = rt3261_read(rt3261_codec,reg); - printk("rt3261_read:0x%04x = 0x%04x\n",reg,value); - } - debug_write_read = 0; - printk("\n"); - } - else - { - printk("Error Read reg debug.\n"); - printk("For example: echo r:22,23,24,25>rt3261_ts\n"); - } - break; - case 'w': - case 'W': - printk("Write reg debug\n"); - if(cookie_pot[1] ==':') - { - debug_write_read = 1; - strsep(&cookie_pot,":"); - while((p=strsep(&cookie_pot,"="))) - { - reg = simple_strtol(p,NULL,16); - p=strsep(&cookie_pot,","); - value = simple_strtol(p,NULL,16); - rt3261_write(rt3261_codec,reg,value); - printk("rt3261_write:0x%04x = 0x%04x\n",reg,value); - } - debug_write_read = 0; - printk("\n"); - } - else - { - printk("Error Write reg debug.\n"); - printk("For example: w:22=0,23=0,24=0,25=0>rt3261_ts\n"); - } - break; - /*case 'a': - printk("Dump rt3261 dsp reg \n"); - - for (i = 0; i < 0xb4; i++) - { - value = rt3261_index_read(rt3261_codec, i); - printk("rt3261_index_read:0x%04x = 0x%04x\n",i,value); - } - - break; */ - default: - printk("Help for rt3261_ts .\n-->The Cmd list: \n"); - printk("-->'d&&D' Open or Off the debug\n"); - printk("-->'r&&R' Read reg debug,Example: echo 'r:22,23,24,25'>rt3261_ts\n"); - printk("-->'w&&W' Write reg debug,Example: echo 'w:22=0,23=0,24=0,25=0'>rt3261_ts\n"); - break; - } - - return len; -} - -static const struct file_operations rt3261_proc_fops = { - .owner = THIS_MODULE, -}; - -static int rt3261_proc_init(void) -{ - struct proc_dir_entry *rt3261_proc_entry; - rt3261_proc_entry = create_proc_entry("driver/rt3261_ts", 0777, NULL); - if(rt3261_proc_entry != NULL) - { - rt3261_proc_entry->write_proc = rt3261_proc_write; - return 0; - } - else - { - printk("create proc error !\n"); - return -1; - } -} -#endif - diff --git a/sound/soc/codecs/rt5640-dsp.c b/sound/soc/codecs/rt5640-dsp.c index e5f2515014f0..68817b44afa5 100755 --- a/sound/soc/codecs/rt5640-dsp.c +++ b/sound/soc/codecs/rt5640-dsp.c @@ -1398,7 +1398,7 @@ EXPORT_SYMBOL_GPL(rt56xx_dsp_ioctl_common); #endif #ifdef CONFIG_PM -int rt5640_dsp_suspend(struct snd_soc_codec *codec, pm_message_t state) +int rt5640_dsp_suspend(struct snd_soc_codec *codec) { struct rt5640_dsp_param param; int ret; diff --git a/sound/soc/codecs/rt5640-dsp.h b/sound/soc/codecs/rt5640-dsp.h index 9dfde501bc33..a747c8bec2fc 100755 --- a/sound/soc/codecs/rt5640-dsp.h +++ b/sound/soc/codecs/rt5640-dsp.h @@ -32,7 +32,7 @@ struct rt5640_dsp_param { int rt5640_dsp_probe(struct snd_soc_codec *codec); int rt56xx_dsp_ioctl_common(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg); #ifdef CONFIG_PM -int rt5640_dsp_suspend(struct snd_soc_codec *codec, pm_message_t state); +int rt5640_dsp_suspend(struct snd_soc_codec *codec); int rt5640_dsp_resume(struct snd_soc_codec *codec); #endif diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 545c043d5604..929e8c7a865e 100755 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1540,10 +1540,10 @@ static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w, } #if USE_ONEBIT_DEPOP -void hp_amp_power(struct snd_soc_codec *codec, int on) +void rt5640_hp_amp_power(struct snd_soc_codec *codec, int on) { static int hp_amp_power_count; -// printk("one bit hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); +// printk("one bit rt5640_hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); if(on) { if(hp_amp_power_count <= 0) { @@ -1601,7 +1601,7 @@ void hp_amp_power(struct snd_soc_codec *codec, int on) static void rt5640_pmu_depop(struct snd_soc_codec *codec) { - hp_amp_power(codec, 1); + rt5640_hp_amp_power(codec, 1); /* headphone unmute sequence */ msleep(5); snd_soc_update_bits(codec, RT5640_HP_VOL, @@ -1625,15 +1625,15 @@ static void rt5640_pmd_depop(struct snd_soc_codec *codec) RT5640_L_MUTE | RT5640_R_MUTE, RT5640_L_MUTE | RT5640_R_MUTE); msleep(50); - hp_amp_power(codec, 0); + rt5640_hp_amp_power(codec, 0); } #else //seq -void hp_amp_power(struct snd_soc_codec *codec, int on) +void rt5640_hp_amp_power(struct snd_soc_codec *codec, int on) { static int hp_amp_power_count; -// printk("hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); +// printk("rt5640_hp_amp_power on=%d hp_amp_power_count=%d\n",on,hp_amp_power_count); if(on) { if(hp_amp_power_count <= 0) { @@ -1690,7 +1690,7 @@ void hp_amp_power(struct snd_soc_codec *codec, int on) static void rt5640_pmu_depop(struct snd_soc_codec *codec) { - hp_amp_power(codec, 1); + rt5640_hp_amp_power(codec, 1); /* headphone unmute sequence */ snd_soc_update_bits(codec, RT5640_DEPOP_M3, RT5640_CP_FQ1_MASK | RT5640_CP_FQ2_MASK | RT5640_CP_FQ3_MASK, @@ -1737,7 +1737,7 @@ static void rt5640_pmd_depop(struct snd_soc_codec *codec) RT5640_L_MUTE | RT5640_R_MUTE, RT5640_L_MUTE | RT5640_R_MUTE); msleep(30); - hp_amp_power(codec, 0); + rt5640_hp_amp_power(codec, 0); } #endif @@ -1795,7 +1795,7 @@ static int rt5640_lout_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power(codec,1); + rt5640_hp_amp_power(codec,1); snd_soc_update_bits(codec, RT5640_PWR_ANLG1, RT5640_PWR_LM, RT5640_PWR_LM); snd_soc_update_bits(codec, RT5640_OUTPUT, @@ -1808,7 +1808,7 @@ static int rt5640_lout_event(struct snd_soc_dapm_widget *w, RT5640_L_MUTE | RT5640_R_MUTE); snd_soc_update_bits(codec, RT5640_PWR_ANLG1, RT5640_PWR_LM, 0); - hp_amp_power(codec,0); + rt5640_hp_amp_power(codec,0); break; default: @@ -3132,7 +3132,7 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec, } /* add by magf for CONFIG_.._CTL_CODEC option */ -void codec_set_spk(bool on) +void rt5640_codec_set_spk(bool on) { struct snd_soc_codec *codec = rt5640_codec; @@ -3229,7 +3229,7 @@ static int rt5640_probe(struct snd_soc_codec *codec) ioctl_ops->index_read = rt5640_index_read; ioctl_ops->index_update_bits = rt5640_index_update_bits; ioctl_ops->ioctl_common = rt5640_ioctl_common; - realtek_ce_init_hwdep(codec); + rt56xx_ce_init_hwdep(codec); #endif #endif @@ -3257,7 +3257,7 @@ static int rt5640_remove(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5640_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int rt5640_suspend(struct snd_soc_codec *codec) { #if defined(CONFIG_SND_SOC_RT5642_MODULE) || defined(CONFIG_SND_SOC_RT5642) /* After opening LDO of DSP, then close LDO of codec. @@ -3266,7 +3266,7 @@ static int rt5640_suspend(struct snd_soc_codec *codec, pm_message_t state) * (3) DSP IIS interface power off * (4) Toggle pin of codec LDO1 to power off */ - rt5640_dsp_suspend(codec, state); + rt5640_dsp_suspend(codec); #endif rt5640_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; diff --git a/sound/soc/codecs/rt56xx_ioctl.c b/sound/soc/codecs/rt56xx_ioctl.c index 24d0c52aedc5..afc6dcd59846 100755 --- a/sound/soc/codecs/rt56xx_ioctl.c +++ b/sound/soc/codecs/rt56xx_ioctl.c @@ -150,7 +150,7 @@ static int rt56xx_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, return 0; } -int realtek_ce_init_hwdep(struct snd_soc_codec *codec) +int rt56xx_ce_init_hwdep(struct snd_soc_codec *codec) { struct snd_hwdep *hw; struct snd_card *card = codec->card->snd_card; @@ -169,7 +169,7 @@ int realtek_ce_init_hwdep(struct snd_soc_codec *codec) return 0; } -EXPORT_SYMBOL_GPL(realtek_ce_init_hwdep); +EXPORT_SYMBOL_GPL(rt56xx_ce_init_hwdep); #endif struct rt56xx_ops *rt56xx_get_ioctl_ops(void) diff --git a/sound/soc/codecs/rt56xx_ioctl.h b/sound/soc/codecs/rt56xx_ioctl.h index 1fdc56e451d6..c8b32116bd22 100755 --- a/sound/soc/codecs/rt56xx_ioctl.h +++ b/sound/soc/codecs/rt56xx_ioctl.h @@ -72,7 +72,7 @@ enum { RT_GET_CODEC_ID = _IOR('R', 0x30, struct rt56xx_cmd), }; -int realtek_ce_init_hwdep(struct snd_soc_codec *codec); +int rt56xx_ce_init_hwdep(struct snd_soc_codec *codec); struct rt56xx_ops *rt56xx_get_ioctl_ops(void); #endif /* __RT56XX_IOCTL_H__ */ diff --git a/sound/soc/codecs/tlv320aic3111.c b/sound/soc/codecs/tlv320aic3111.c index b065f0f446d4..a14b3b3275a7 100644 --- a/sound/soc/codecs/tlv320aic3111.c +++ b/sound/soc/codecs/tlv320aic3111.c @@ -34,9 +34,10 @@ #include #include #include - -#include +#include #include +#include +#include #include #include @@ -44,19 +45,21 @@ #include #include #include +#include -#include +//#include #include "tlv320aic3111.h" #if 0 -#define AIC3111_DEBUG #define AIC_DBG(x...) printk(KERN_INFO x) #else #define AIC_DBG(x...) do { } while (0) #endif -#define HP_DET_PIN RK29_PIN6_PA0 -//#define AIC3111_DEBUG +#define GPIO_HIGH 1 +#define GPIO_LOW 0 +#define INVALID_GPIO -1 + /* codec status */ #define AIC3110_IS_SHUTDOWN 0 #define AIC3110_IS_CAPTURE_ON 1 @@ -70,9 +73,12 @@ #define AIC3110_POWERDOWN_PLAYBACK_CAPTURE 3 #define JACK_DET_ADLOOP msecs_to_jiffies(200) -//#define AIC3111_DEBUG #define SPK 1 #define HP 0 + +int aic3111_spk_ctl_gpio = INVALID_GPIO; +int aic3111_hp_det_gpio = INVALID_GPIO; + static int aic3111_power_speaker (bool on); struct speaker_data { struct timer_list timer; @@ -357,7 +363,7 @@ static int aic3111_write (struct snd_soc_codec *codec, unsigned int reg, unsigne u8 data[2]; u8 page; //printk("enter %s!!!!!!\n",__FUNCTION__); - //printk("RK29_PIN6_PB6 =%d!!!!!!\n",gpio_get_value(RK29_PIN6_PB6)); + //printk("aic3111_hp_det_gpio =%d!!!!!!\n",gpio_get_value(aic3111_hp_det_gpio)); page = reg / 128; data[AIC3111_REG_OFFSET_INDEX] = reg % 128; @@ -425,7 +431,7 @@ static void aic3111_soft_reset (void) //aic3111_write (codec, 1, 0x01); aic3111_write (codec, 63, 0x00); - gpio_set_value(RK29_PIN6_PB5, GPIO_LOW); + gpio_set_value(aic3111_spk_ctl_gpio, GPIO_LOW); msleep(10); aic3111_write (aic3111_codec, (68), 0x01); //disable DRC aic3111_write (aic3111_codec, (128 + 31), 0xc4); @@ -1043,13 +1049,13 @@ static int aic3111_power_playback (bool on) struct snd_soc_codec *codec = aic3111_codec; AIC_DBG ("CODEC::%s>>>>>>%d\n", __FUNCTION__, on); - gpio_set_value(RK29_PIN6_PB5, GPIO_LOW); + gpio_set_value(aic3111_spk_ctl_gpio, GPIO_LOW); aic3111_power_init(); if ((on == POWER_STATE_ON) && !(aic3111_current_status & AIC3110_IS_PLAYBACK_ON)) { // if(1){ - //gpio_set_value(RK29_PIN6_PB5, GPIO_HIGH); + //gpio_set_value(aic3111_spk_ctl_gpio, GPIO_HIGH); /****open HPL and HPR*******/ //aic3111_write(codec, (63), 0xfc); @@ -1094,7 +1100,7 @@ static int aic3111_power_playback (bool on) aic3111_current_status &= ~AIC3110_IS_PLAYBACK_ON; } //mdelay(800); - gpio_set_value(RK29_PIN6_PB5, GPIO_HIGH); + gpio_set_value(aic3111_spk_ctl_gpio, GPIO_HIGH); return 0; } @@ -1331,7 +1337,7 @@ static int aic3111_trigger(struct snd_pcm_substream *substream, if(status == 0) { - gpio_set_value(RK29_PIN6_PB5, GPIO_LOW); + gpio_set_value(aic3111_spk_ctl_gpio, GPIO_LOW); mdelay(10); } @@ -1380,204 +1386,6 @@ static struct snd_soc_dai_driver aic3111_dai[] = { }, }; -#ifdef AIC3111_DEBUG -static struct class *aic3111_debug_class = NULL; -static int reg_128_39 = 12, reg_128_43 = 0; -static int i=52;j=1,k=0; -static int CheckCommand(const char __user *buffer) -{ - switch(*buffer) { - case '1': - if (*(buffer + 1) == '+') { - if (reg_128_39 < 12) { - if (reg_128_39 % 2 == 0) - printk("write reg 128 + 39 vol + : %ddB -> -%d.5dB\n", (reg_128_39 - 12) / 2, (11 - reg_128_39) / 2); - else - printk("write reg 128 + 39 vol + : -%d.5dB -> %ddB\n", (12 - reg_128_39) / 2, (reg_128_39 - 11) / 2); - reg_128_39++; - aic3111_write(aic3111_codec, (128 + 39), 0x04 + (12 - reg_128_39)); - } else { - printk("128 + 39 max vol 0dB\n"); - } - } else if (*(buffer + 1) == '-') { - if (reg_128_39 > 0) { - if (reg_128_39 % 2 == 0) - printk("write reg 128 + 39 vol - : %ddB -> -%d.5dB\n", (reg_128_39 - 12) / 2, (13 - reg_128_39) / 2); - else - printk("write reg 128 + 39 vol - : -%d.5dB -> %ddB\n", (12 - reg_128_39) / 2, (reg_128_39 - 13) / 2); - reg_128_39--; - aic3111_write(aic3111_codec, (128 + 39), 0x08 + (12 - reg_128_39)); - } else { - printk("128 + 39 min vol -6dB\n"); - } - } - break; - case '2': - if (*(buffer + 1) == '+') { - if (reg_128_43 < 2) { - printk("write reg 128 + 43 vol + : %ddB -> %ddB\n", (reg_128_43) * 6, (reg_128_43 + 1) * 6); - reg_128_43++; - aic3111_write(aic3111_codec, (128 + 43), 0x04 + ((reg_128_43 + 1) << 3)); - } else { - printk("128 + 43 max vol 12dB\n"); - } - } else if (*(buffer + 1) == '-') { - if (reg_128_43 > 0) { - printk("write reg 128 + 43 vol - : %ddB -> %ddB\n", (reg_128_43) * 6, (reg_128_43 - 1) * 6); - reg_128_43--; - aic3111_write(aic3111_codec, (128 + 43), 0x04 + ((reg_128_43 + 1) << 3)); - } else { - printk("128 + 43 min vol 0dB\n"); - } - } - break; - case 'o': - aic3111_write(aic3111_codec, (128 + 39), 0x08 + (12 - reg_128_39)); - aic3111_write(aic3111_codec, (128 + 43), 0x04 + ((reg_128_43 + 1) << 3)); - case 'l': - if (reg_128_39 % 2 == 0) - printk("reg 128 + 43 vol : %ddB reg 128 + 39 vol : %ddB\n", (reg_128_43) * 6, (reg_128_39 - 12) / 2); - else - printk("reg 128 + 43 vol : %ddB reg 128 + 39 vol : -%d.5dB\n", (reg_128_43) * 6, (12 - reg_128_39) / 2); - break; - case 's': - aic3111_power_speaker (POWER_STATE_ON); - break; - - case 'h': - aic3111_power_headphone (POWER_STATE_ON); - break; - - case 'q': - aic3111_power_speaker (POWER_STATE_OFF); - break; - - case 'w': - aic3111_power_headphone (POWER_STATE_OFF); - break; - - case 'a': - i--; - gpio_set_value(RK29_PIN6_PB5, GPIO_HIGH); - //printk("reg[128+39]=0x%x\n",aic3111_read(aic3111_codec,(128 + 39))); - printk("-db add\n"); - break; - case 'r': - i++; - gpio_set_value(RK29_PIN6_PB5, GPIO_LOW); - //printk("reg[128+39]=0x%x\n",aic3111_read(aic3111_codec,(128 + 39))); - printk("-db down\n"); - break; - case 't': - - printk("PB5 = %d\n",gpio_get_value(RK29_PIN6_PB5)); - break; - - case 'z': - j++; - aic3111_write(aic3111_codec, (66), j); - printk("DAC db add\n"); - printk("reg[66]=0x%x\n",aic3111_read(aic3111_codec,66)); - break; - case 'x': - j--; - aic3111_write(aic3111_codec, (66), j); - printk("DAC db down\n"); - printk("reg[66]=0x%x\n",aic3111_read(aic3111_codec,66)); - break; - - case 'c': - j--; - aic3111_write(aic3111_codec, (63), 0xfc); - printk("reg[63]=0x%x\n",aic3111_read(aic3111_codec,66)); - break; - - case 'n': - k++; - if(k==1) - { - aic3111_write(aic3111_codec, (128 + 40), 0x0e); - aic3111_write(aic3111_codec, (128 + 41), 0x0e); - printk("HPR and HPL 1 DB\n",k); - } - if(k==2) - { - aic3111_write(aic3111_codec, (128 + 40), 0x1e); - aic3111_write(aic3111_codec, (128 + 40), 0x1e); - printk("HPR and HPL 3 DB\n",k); - } - if(k==3) - { - aic3111_write(aic3111_codec, (128 + 40), 0x2e); - aic3111_write(aic3111_codec, (128 + 40), 0x2e); - printk("HPR and HPL 5 DB\n",k); - } - break; - - case 'm': - k--; - if(k==1) - { - aic3111_write(aic3111_codec, (128 + 40), 0x0e); - aic3111_write(aic3111_codec, (128 + 41), 0x0e); - printk("HPR and HPL 1 DB\n",k); - } - if(k==2) - { - aic3111_write(aic3111_codec, (128 + 40), 0x1e); - aic3111_write(aic3111_codec, (128 + 40), 0x1e); - printk("HPR and HPL 3 DB\n",k); - } - if(k==3) - { - aic3111_write(aic3111_codec, (128 + 40), 0x2e); - aic3111_write(aic3111_codec, (128 + 40), 0x2e); - printk("HPR and HPL 5 DB\n",k); - } - break; - - - default: - printk("Please press '1' '2' 'o' 'l' !\n"); - break; - } - return 0; -} - -static int aic3111_proc_write(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - if (CheckCommand(buffer) != 0) { - printk("Write proc error !\n"); - return -1; - } - - return sizeof(buffer); -} -static const struct file_operations aic3111_proc_fops = { - .owner = THIS_MODULE, - .write = aic3111_proc_write, -}; - -static int aic3111_proc_init(void) { - - struct proc_dir_entry *aic3111_proc_entry; - //printk("!!!!!!!!!!!!!!!!!!!!\n"); - aic3111_proc_entry = create_proc_entry("driver/aic3111_ts", 0777, NULL); - - if (aic3111_proc_entry != NULL) { - - aic3111_proc_entry->write_proc = aic3111_proc_write; - - return -1; - }else { - printk("create proc error !\n"); - } - - return 0; -} -#endif - struct delayed_work aic3111_speaker_delayed_work; int speakeronoff; @@ -1591,9 +1399,9 @@ static void aic3111_speaker_delayed_work_func(struct work_struct *work) //aic3111_write(codec, (128 + 32), 0xc6); //printk("reg 128+32 = %x\n"aic3111_read(codec, (128 + 32))); isHSin = 0; - //gpio_set_value(RK29_PIN6_PB5, GPIO_LOW); + //gpio_set_value(aic3111_spk_ctl_gpio, GPIO_LOW); aic3111_power_speaker(POWER_STATE_OFF); - gpio_set_value(RK29_PIN6_PB5, GPIO_HIGH); + gpio_set_value(aic3111_spk_ctl_gpio, GPIO_HIGH); //aic3111_power_headphone(POWER_STATE_ON); //aic3111_write(codec, (128 + 35), 0x88); printk("now hp sound\n"); @@ -1603,7 +1411,7 @@ static void aic3111_speaker_delayed_work_func(struct work_struct *work) isHSin = 1; //aic3111_power_headphone(POWER_STATE_OFF); - gpio_set_value(RK29_PIN6_PB5, GPIO_LOW); + gpio_set_value(aic3111_spk_ctl_gpio, GPIO_LOW); aic3111_power_speaker(POWER_STATE_ON); aic3111_write(codec, (128 + 35), 0x44); aic3111_write(codec, (63), 0xfc); @@ -1621,7 +1429,7 @@ static int speaker_timer(unsigned long _data) struct speaker_data *spk = (struct speaker_data *)_data; int new_status; - if (gpio_get_value(RK29_PIN6_PB6) == 0) { + if (gpio_get_value(aic3111_hp_det_gpio) == 0) { new_status = HP; isHSin = 0; //printk("hp now\n"); @@ -1637,7 +1445,7 @@ static int speaker_timer(unsigned long _data) } } - if (gpio_get_value(RK29_PIN6_PB6) == 1) { + if (gpio_get_value(aic3111_hp_det_gpio) == 1) { new_status = SPK; isHSin = 1; //printk("speak now\n"); @@ -1673,7 +1481,7 @@ static int aic3111_probe (struct snd_soc_codec *codec) aic3111_codec = codec; #if 1 - gpio_set_value(RK29_PIN6_PB6,1); + gpio_set_value(aic3111_hp_det_gpio,1); struct speaker_data *spk; spk = kzalloc(sizeof(struct speaker_data), GFP_KERNEL); @@ -1688,7 +1496,7 @@ static int aic3111_probe (struct snd_soc_codec *codec) INIT_DELAYED_WORK(&aic3111_speaker_delayed_work, aic3111_speaker_delayed_work_func); /*********************/ - //pio_set_value(RK29_PIN6_PB5, GPIO_LOW); + //pio_set_value(aic3111_spk_ctl_gpio, GPIO_LOW); //aic3111_power_speaker(POWER_STATE_OFF); //aic3111_power_headphone(POWER_STATE_ON); #endif @@ -1718,7 +1526,7 @@ static int aic3111_probe (struct snd_soc_codec *codec) */ /* Just Reset codec */ aic3111_soft_reset(); - gpio_set_value(RK29_PIN6_PB5, GPIO_LOW); + gpio_set_value(aic3111_spk_ctl_gpio, GPIO_LOW); msleep(10); aic3111_write (aic3111_codec, (68), 0x01); //disable DRC aic3111_write (aic3111_codec, (128 + 31), 0xc4); @@ -1727,10 +1535,6 @@ static int aic3111_probe (struct snd_soc_codec *codec) aic3111_write (aic3111_codec, (128 + 40), 0x4f); //HPL driver PGA aic3111_write (aic3111_codec, (128 + 41), 0x4f); //HPR driver PGA -#ifdef AIC3111_DEBUG - aic3111_proc_init(); -#endif - aic3111_set_bias_level (codec, SND_SOC_BIAS_STANDBY); return 0; @@ -1763,7 +1567,7 @@ static int aic3111_remove (struct snd_soc_codec *codec) * *---------------------------------------------------------------------------- */ -static int aic3111_suspend (struct snd_soc_codec *codec, pm_message_t state) +static int aic3111_suspend (struct snd_soc_codec *codec) { AIC_DBG ("CODEC::%s\n", __FUNCTION__); @@ -1817,6 +1621,15 @@ static const struct i2c_device_id tlv320aic3111_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, tlv320aic3111_i2c_id); +/* +dts: + codec@1a { + compatible = "aic3111"; + reg = <0x1a>; + spk-ctl-gpio = <&gpio6 GPIO_B5 GPIO_ACTIVE_HIGH>; + hp-det-pio = <&gpio6 GPIO_B6 GPIO_ACTIVE_HIGH>; + }; +*/ static int tlv320aic3111_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -1829,6 +1642,20 @@ static int tlv320aic3111_i2c_probe(struct i2c_client *i2c, aic3111_i2c = i2c; +#ifdef CONFIG_OF + aic3111_spk_ctl_gpio= of_get_named_gpio_flags(i2c->dev.of_node, "spk-ctl-gpio", 0, NULL); + if (aic3111_spk_ctl_gpio < 0) { + printk("%s() Can not read property spk-ctl-gpio\n", __FUNCTION__); + aic3111_spk_ctl_gpio = INVALID_GPIO; + } + + aic3111_hp_det_gpio = of_get_named_gpio_flags(i2c->dev.of_node, "hp-det-pio", 0, NULL); + if (aic3111_hp_det_gpio < 0) { + printk("%s() Can not read property hp-det-pio\n", __FUNCTION__); + aic3111_hp_det_gpio = INVALID_GPIO; + } +#endif //#ifdef CONFIG_OF + i2c_set_clientdata(i2c, aic3111); aic3111_privdata = aic3111; @@ -1841,7 +1668,7 @@ static int tlv320aic3111_i2c_probe(struct i2c_client *i2c, return ret; } -static __devexit int tlv320aic3111_i2c_remove(struct i2c_client *client) +static int tlv320aic3111_i2c_remove(struct i2c_client *client) { snd_soc_unregister_codec(&client->dev); kfree(i2c_get_clientdata(client)); @@ -1854,7 +1681,7 @@ struct i2c_driver tlv320aic3111_i2c_driver = { .owner = THIS_MODULE, }, .probe = tlv320aic3111_i2c_probe, - .remove = __devexit_p(tlv320aic3111_i2c_remove), + .remove = tlv320aic3111_i2c_remove, .id_table = tlv320aic3111_i2c_id, }; @@ -1871,54 +1698,6 @@ static void __exit tlv320aic3111_exit (void) module_init (tlv320aic3111_init); module_exit (tlv320aic3111_exit); -#ifdef CONFIG_PROC_FS -#include -#include -static int proc_3110_reg_show (struct seq_file *s, void *v) -{ - struct snd_soc_codec *codec = aic3111_codec; - int reg; - u8 *cache = codec->reg_cache; - - seq_printf (s, "========3110register========\n"); - for (reg = 0; reg < 256; reg++) { - if (reg == 0) seq_printf (s, "Page 0\n"); - if (reg == 128) seq_printf (s, "\nPage 1\n"); - if (reg%8 == 0 && reg != 0 && reg != 128) seq_printf (s, "\n"); - seq_printf (s, "[%d]0x%02x, ",reg,aic3111_read (codec, reg)); - } - seq_printf (s, "\n========3110cache========\n"); - for (reg = 0; reg < codec->reg_size; reg++) { - if (reg == 0) seq_printf (s, "Page 0\n"); - if (reg == 128) seq_printf (s, "\nPage 1\n"); - if (reg%16 == 0 && reg != 0 && reg != 128) seq_printf (s, "\n"); - seq_printf (s, "0x%02x, ",cache[reg]); - } - printk ("\n==========================\n"); - return 0; -} - -static int proc_3110_reg_open (struct inode *inode, struct file *file) -{ - return single_open (file, proc_3110_reg_show, NULL); -} - -static const struct file_operations proc_3110_reg_fops = { - .open = proc_3110_reg_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int __init codec_proc_init (void) -{ - proc_create ("aic3110_register", 0, NULL, &proc_3110_reg_fops); - - return 0; -} -late_initcall (codec_proc_init); -#endif /* CONFIG_PROC_FS */ - MODULE_DESCRIPTION (" ASoC TLV320AIC3111 codec driver "); MODULE_AUTHOR (" Jaz B John "); MODULE_LICENSE ("GPL"); diff --git a/sound/soc/codecs/tlv320aic326x.c b/sound/soc/codecs/tlv320aic326x.c index a6c324d4477f..f28efcc37fee 100755 --- a/sound/soc/codecs/tlv320aic326x.c +++ b/sound/soc/codecs/tlv320aic326x.c @@ -2302,7 +2302,7 @@ static int aic3262_set_bias_level(struct snd_soc_codec *codec, * *---------------------------------------------------------------------------- */ -static int aic3262_suspend(struct snd_soc_codec *codec, pm_message_t state) +static int aic3262_suspend(struct snd_soc_codec *codec) { aic3262_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; diff --git a/sound/soc/rockchip/rk2928-card.c b/sound/soc/rockchip/rk2928-card.c index 4ccd2fadef12..c8cdf02118df 100755 --- a/sound/soc/rockchip/rk2928-card.c +++ b/sound/soc/rockchip/rk2928-card.c @@ -18,6 +18,8 @@ * */ #include +#include +#include #include #include @@ -83,8 +85,8 @@ static struct snd_soc_dai_link rk2928_dai[] = { { .name = "RK2928", .stream_name = "RK2928", - .cpu_dai_name = "rk_i2s.0", - .platform_name = "rockchip-audio", + .cpu_dai_name = "rockchip-i2s.0", + .platform_name = "rockchip-pcm", .codec_name = "rk2928-codec", .codec_dai_name = "rk2928-codec", .ops = &rk2928_dai_ops, @@ -92,47 +94,55 @@ static struct snd_soc_dai_link rk2928_dai[] = { }; /* Audio machine driver */ -static struct snd_soc_card snd_soc_rk2928 = { +static struct snd_soc_card rockchip_rk2928_snd_card = { .name = "RK2928", .dai_link = rk2928_dai, .num_links = ARRAY_SIZE(rk2928_dai), }; -static struct platform_device *rk2928_snd_device; - -static int __init rk2928_soc_init(void) +static int rockchip_rk2928_audio_probe(struct platform_device *pdev) { int ret; + struct snd_soc_card *card = &rockchip_rk2928_snd_card; - printk(KERN_INFO "RK2928 SoC init\n"); - - rk2928_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk2928_snd_device) { - printk(KERN_ERR "Platform device allocation failed\n"); - return -ENOMEM; - } + card->dev = &pdev->dev; - platform_set_drvdata(rk2928_snd_device, &snd_soc_rk2928); + ret = snd_soc_register_card(card); - ret = platform_device_add(rk2928_snd_device); if (ret) - goto err1; - - return 0; - -err1: - printk(KERN_ERR "Unable to add platform device\n"); - platform_device_put(rk2928_snd_device); + printk("%s() register card failed:%d\n", __FUNCTION__, ret); return ret; } -module_init(rk2928_soc_init); -static void __exit rk2928_soc_exit(void) +static int rockchip_rk2928_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk2928_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_exit(rk2928_soc_exit); + +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rk2928_of_match[] = { + { .compatible = "rockchip-rk2928", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rk2928_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rk2928_audio_driver = { + .driver = { + .name = "rockchip-rk2928", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rk2928_of_match), + }, + .probe = rockchip_rk2928_audio_probe, + .remove = rockchip_rk2928_audio_remove, +}; + +module_platform_driver(rockchip_rk2928_audio_driver); MODULE_DESCRIPTION("ALSA SoC RK2928"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/rockchip/rk_aic3111.c b/sound/soc/rockchip/rk_aic3111.c index e6f11eb3951f..0e8a5ce0ea5e 100644 --- a/sound/soc/rockchip/rk_aic3111.c +++ b/sound/soc/rockchip/rk_aic3111.c @@ -13,14 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include -#include + #include "../codecs/tlv320aic3111.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -171,48 +170,63 @@ static struct snd_soc_dai_link rk29_dai = { .name = "AIC3111", .stream_name = "AIC3111 PCM", .codec_name = "AIC3111.0-0018", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "AIC3111 HiFi", .init = rk29_aic3111_init, .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_aic3111_snd_card = { .name = "RK_AIC3111", .dai_link = &rk29_dai, .num_links = 1, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_aic3111_audio_probe(struct platform_device *pdev) { - int ret =0; - - AIC_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - AIC_DBG("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - AIC_DBG("platform device add failed\n"); - platform_device_put(rk29_snd_device); - } + int ret; + struct snd_soc_card *card = &rockchip_aic3111_snd_card; + + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_aic3111_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_aic3111_of_match[] = { + { .compatible = "rockchip-aic3111", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_aic3111_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_aic3111_audio_driver = { + .driver = { + .name = "rockchip-aic3111", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_aic3111_of_match), + }, + .probe = rockchip_aic3111_audio_probe, + .remove = rockchip_aic3111_audio_remove, +}; + +module_platform_driver(rockchip_aic3111_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_aic3262.c b/sound/soc/rockchip/rk_aic3262.c index eb77229f0d2a..109d69d29c43 100644 --- a/sound/soc/rockchip/rk_aic3262.c +++ b/sound/soc/rockchip/rk_aic3262.c @@ -28,13 +28,13 @@ #include #include #include +#include +#include #include #include #include -#include -#include #include "../codecs/wm8994.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -443,13 +443,13 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "AIC3262 I2S1", .stream_name = "AIC3262 PCM", .codec_name = "tlv320aic3262-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "aic326x-asi1", .ops = &rk29_aif1_ops, @@ -460,13 +460,13 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "AIC3262 I2S2", .stream_name = "AIC3262 PCM", .codec_name = "tlv320aic3262-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "aic326x-asi2", .ops = &rk29_aif2_ops, @@ -477,13 +477,13 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "AIC3262 I2S3", .stream_name = "AIC3262 PCM", .codec_name = "tlv320aic3262-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "aic326x-asi3", .ops = &rk29_aif3_ops, @@ -492,45 +492,55 @@ static struct snd_soc_dai_link rk29_dai[] = { }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_aic3262_snd_card = { .name = "RK_AIC3262", .dai_link = rk29_dai, .num_links = ARRAY_SIZE(rk29_dai), }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_aic3262_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_aic3262_snd_card; - DBG_AIC3262("Enter::%s----%d\n",__FUNCTION__,__LINE__); + card->dev = &pdev->dev; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } - - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); - // snd_soc_unregister_dai(&rk29_snd_device->dev); - platform_device_put(rk29_snd_device); - return ret; - } - - return ret; + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_aic3262_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_aic3262_of_match[] = { + { .compatible = "rockchip-aic3262", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_aic3262_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_aic3262_audio_driver = { + .driver = { + .name = "rockchip-aic3262", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_aic3262_of_match), + }, + .probe = rockchip_aic3262_audio_probe, + .remove = rockchip_aic3262_audio_remove, +}; + +module_platform_driver(rockchip_aic3262_audio_driver); /* Module information */ MODULE_AUTHOR("rockchip"); diff --git a/sound/soc/rockchip/rk_ak4396.c b/sound/soc/rockchip/rk_ak4396.c index a266f5ec4cd6..adee766ed03d 100755 --- a/sound/soc/rockchip/rk_ak4396.c +++ b/sound/soc/rockchip/rk_ak4396.c @@ -13,17 +13,16 @@ #include #include +#include +#include #include #include #include #include -#include -#include + #include "rk_pcm.h" #include "rk29_i2s.h" -#include - #if 1 #define DBG(x...) printk(KERN_INFO x) #else @@ -120,57 +119,69 @@ static struct snd_soc_dai_link rk29_dai = { .name = "AK4396", .stream_name = "AK4396 PCM", .codec_name = "spi1.0", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "AK4396 HiFi", .init = rk29_ak4396_init, .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_ak4396_snd_card = { .name = "RK_AK4396", .dai_link = &rk29_dai, .num_links = 1, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_ak4396_audio_probe(struct platform_device *pdev) { - int ret =0; - - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); - platform_device_put(rk29_snd_device); - return ret; - } - + int ret; + struct snd_soc_card *card = &rockchip_ak4396_snd_card; + + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_ak4396_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device);; + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_ak4396_of_match[] = { + { .compatible = "rockchip-ak4396", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_ak4396_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_ak4396_audio_driver = { + .driver = { + .name = "rockchip-ak4396", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_ak4396_of_match), + }, + .probe = rockchip_ak4396_audio_probe, + .remove = rockchip_ak4396_audio_remove, +}; + +module_platform_driver(rockchip_ak4396_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_cs42l52.c b/sound/soc/rockchip/rk_cs42l52.c index a69b1ae3b363..a507cb87559a 100755 --- a/sound/soc/rockchip/rk_cs42l52.c +++ b/sound/soc/rockchip/rk_cs42l52.c @@ -14,13 +14,13 @@ #include #include #include +#include +#include #include #include #include #include -#include -#include -#include + #include "../codecs/cs42l52.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -49,8 +49,8 @@ static int rk29_cs42l52_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; unsigned int pll_out = 0; unsigned int lrclk = 0; int div_bclk,div_mclk; @@ -59,7 +59,7 @@ static int rk29_cs42l52_hw_params(struct snd_pcm_substream *substream, if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF)) { - ret = codec_dai->ops->hw_params(substream, params, codec_dai); //by Vincent + ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent } else { @@ -134,19 +134,18 @@ static int rk29_cs42l52_hw_params(struct snd_pcm_substream *substream, static int rk29_cs42l52_dai_init(struct snd_soc_codec *codec) { - struct snd_soc_dai *codec_dai = &codec->dai[0]; - int ret; + struct snd_soc_dapm_context *dapm = &codec->dapm; - snd_soc_dapm_nc_pin(codec, "INPUT1A"); - snd_soc_dapm_nc_pin(codec, "INPUT2A"); - snd_soc_dapm_nc_pin(codec, "INPUT3A"); - snd_soc_dapm_nc_pin(codec, "INPUT4A"); - snd_soc_dapm_nc_pin(codec, "INPUT1B"); - snd_soc_dapm_nc_pin(codec, "INPUT2B"); - snd_soc_dapm_nc_pin(codec, "INPUT3B"); - snd_soc_dapm_nc_pin(codec, "INPUT4B"); - snd_soc_dapm_nc_pin(codec, "MICB"); - snd_soc_dapm_sync(codec); + snd_soc_dapm_nc_pin(dapm, "INPUT1A"); + snd_soc_dapm_nc_pin(dapm, "INPUT2A"); + snd_soc_dapm_nc_pin(dapm, "INPUT3A"); + snd_soc_dapm_nc_pin(dapm, "INPUT4A"); + snd_soc_dapm_nc_pin(dapm, "INPUT1B"); + snd_soc_dapm_nc_pin(dapm, "INPUT2B"); + snd_soc_dapm_nc_pin(dapm, "INPUT3B"); + snd_soc_dapm_nc_pin(dapm, "INPUT4B"); + snd_soc_dapm_nc_pin(dapm, "MICB"); + snd_soc_dapm_sync(dapm); return 0; } @@ -155,76 +154,72 @@ static struct snd_soc_ops rk29_cs42l52_ops = { }; static struct snd_soc_dai_link rk29_cs42l52_dai_link = { - .name = "CS42L52", - .stream_name = "CS42L52 PCM", - .cpu_dai = &rk29_i2s_dai[0], - .codec_dai = &soc_cs42l52_dai, - .init = rk29_cs42l52_dai_init, - .ops = &rk29_cs42l52_ops, + .name = "CS42L52", + .stream_name = "CS42L52 PCM", + .codec_name = "cs42l52.0-004a", + .platform_name = "rockchip-pcm", +#if defined(CONFIG_SND_RK_SOC_I2S_8CH) + .cpu_dai_name = "rockchip-i2s.0", +#elif defined(CONFIG_SND_RK_SOC_I2S_2CH) + .cpu_dai_name = "rockchip-i2s.1", +#else + .cpu_dai_name = "rockchip-i2s.2", +#endif + .codec_dai_name = "cs42l52-hifi", + .init = rk29_cs42l52_dai_init, + .ops = &rk29_cs42l52_ops, }; -static struct snd_soc_card snd_soc_card_rk29_cs42l52 = { +static struct snd_soc_card rockchip_cs42l52_snd_card = { .name = "RK_CS42L52", - .platform = &rk29_soc_platform, .dai_link = &rk29_cs42l52_dai_link, .num_links = 1, }; +static int rockchip_cs42l52_audio_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card = &rockchip_cs42l52_snd_card; + + card->dev = &pdev->dev; -static struct snd_soc_device rk29_cs42l52_snd_devdata = { - .card = &snd_soc_card_rk29_cs42l52, - .codec_dev = &soc_codec_dev_cs42l52, -}; + ret = snd_soc_register_card(card); -static struct platform_device *rk29_cs42l52_snd_device; + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); -static int rk29_cs42l52_probe(struct platform_device *pdev) -{ - int ret =0; - printk("RK CS42L52 SoC Audio driver\n"); - rk29_cs42l52_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_cs42l52_snd_device) { - ret = -ENOMEM; - printk("%s:platform device alloc fail\n",__FUNCTION__); - return ret; - } - platform_set_drvdata(rk29_cs42l52_snd_device, &rk29_cs42l52_snd_devdata); - rk29_cs42l52_snd_devdata.dev = &rk29_cs42l52_snd_device->dev; - ret = platform_device_add(rk29_cs42l52_snd_device); - if (ret) { - platform_device_put(rk29_cs42l52_snd_device); - printk("%s:platform device add fail,ret = %d\n",__FUNCTION__,ret); - } return ret; } -static int rk29_cs42l52_remove(struct platform_device *pdev) +static int rockchip_cs42l52_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_cs42l52_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + return 0; } -static struct platform_driver rk29_cs42l52_driver = { - .probe = rk29_cs42l52_probe, - .remove = rk29_cs42l52_remove, - .driver = { - .name = "rk29_cs42l52", - .owner = THIS_MODULE, - }, +#ifdef CONFIG_OF +static const struct of_device_id rockchip_cs42l52_of_match[] = { + { .compatible = "rockchip-cs42l52", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_cs42l52_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_cs42l52_audio_driver = { + .driver = { + .name = "rockchip-cs42l52", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_cs42l52_of_match), + }, + .probe = rockchip_cs42l52_audio_probe, + .remove = rockchip_cs42l52_audio_remove, }; -static int __init rk29_cs42l52_init(void) -{ - return platform_driver_register(&rk29_cs42l52_driver); -} - -static void __exit rk29_cs42l52_exit(void) -{ - platform_driver_unregister(&rk29_cs42l52_driver); -} +module_platform_driver(rockchip_cs42l52_audio_driver); -module_init(rk29_cs42l52_init); -module_exit(rk29_cs42l52_exit); MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/rockchip/rk_cx2070x.c b/sound/soc/rockchip/rk_cx2070x.c index 254f88c175f8..f291e9500ece 100644 --- a/sound/soc/rockchip/rk_cx2070x.c +++ b/sound/soc/rockchip/rk_cx2070x.c @@ -8,12 +8,12 @@ */ #include #include +#include +#include #include #include #include #include -#include -#include #include #include #include "rk_pcm.h" @@ -113,7 +113,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN); if (ret < 0) { - DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n"); + DBG("rk29_hw_params_cx2070x:failed to set the sysclk for codec side\n"); return ret; } #endif @@ -225,16 +225,16 @@ static struct snd_soc_dai_link rk29_dai[] = { { /* Primary DAI i/f */ .name = "CX2070X AIF1", .stream_name = "CX2070X PCM", - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", .codec_dai_name = "cx2070x-hifi", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", .codec_name = "cx2070x.0-0014", .init = cx2070x_init, .ops = &rk29_ops, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_cx2070x_snd_card = { .name = "RK_CX2070X", .dai_link = rk29_dai, @@ -243,29 +243,49 @@ static struct snd_soc_card snd_soc_card_rk29 = { .num_links = ARRAY_SIZE(rk29_dai), }; -static int __init audio_card_init(void) +static int rockchip_cx2070x_audio_probe(struct platform_device *pdev) { int ret; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) - return -ENOMEM; + struct snd_soc_card *card = &rockchip_cx2070x_snd_card; - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); - ret = platform_device_add(rk29_snd_device); - printk(">>>>>>>>>>%s ret = %d",__FUNCTION__, ret); if (ret) - platform_device_put(rk29_snd_device); + printk("%s() register card failed:%d\n", __FUNCTION__, ret); return ret; } -module_init(audio_card_init); -static void __exit audio_card_exit(void) +static int rockchip_cx2070x_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_exit(audio_card_exit); + +#ifdef CONFIG_OF +static const struct of_device_id rockchip_cx2070x_of_match[] = { + { .compatible = "rockchip-cx2070x", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_cx2070x_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_cx2070x_audio_driver = { + .driver = { + .name = "rockchip-cx2070x", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_cx2070x_of_match), + }, + .probe = rockchip_cx2070x_audio_probe, + .remove = rockchip_cx2070x_audio_remove, +}; + +module_platform_driver(rockchip_cx2070x_audio_driver); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); MODULE_AUTHOR("showy.zhang "); diff --git a/sound/soc/rockchip/rk_es8323.c b/sound/soc/rockchip/rk_es8323.c index 446977bf289e..b78eedf8defd 100755 --- a/sound/soc/rockchip/rk_es8323.c +++ b/sound/soc/rockchip/rk_es8323.c @@ -13,19 +13,17 @@ #include #include +#include +#include #include #include #include #include -#include -#include -//#include -//#include + #include "../codecs/es8323.h" #include "rk_pcm.h" #include "rk29_i2s.h" -#include #ifdef CONFIG_MACH_RK_FAC #include extern int codec_type; @@ -169,76 +167,70 @@ static struct snd_soc_ops rk29_ops = { static struct snd_soc_dai_link rk29_dai = { .name = "ES8323", .stream_name = "ES8323 PCM", - .codec_name = "ES8323.4-0010", // ES8323.0-0010 - .platform_name = "rockchip-audio", + .codec_name = "ES8323.0-0010", // ES8323.0-0010 + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", //Ó²¼þÉÏÊǽӵ½IIS0ÉÏ£¬µ«ÊÇÓÉÓÚxxÔ­Òò£¬Õâ±ß¶¨ÒåΪIIS1ÉÏ + .cpu_dai_name = "rockchip-i2s.1", //Ó²¼þÉÏÊǽӵ½IIS0ÉÏ£¬µ«ÊÇÓÉÓÚxxÔ­Òò£¬Õâ±ß¶¨ÒåΪIIS1ÉÏ #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "ES8323 HiFi", .init = rk29_es8323_init, .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_es8323_snd_card = { .name = "RK_ES8323", .dai_link = &rk29_dai, .num_links = 1, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_es8323_audio_probe(struct platform_device *pdev) { - int ret =0; -#ifdef CONFIG_MACH_RK_FAC - if(codec_type!=CODEC_TYPE_ES8323) - return -1; -#endif - DBG("ES8323 audio_card_init\n"); -#if 0 - extern int get_sound_card_exist() ; - extern void set_sound_card_exist(int i) ; - extern int i2c0_prober_verify(u32 dev_addr, u16 reg, u32 reg_addr_len, u32 reg_val_len, u32 id); - if(i2c0_prober_verify(0x10, 0x35, 1, 1, 0x0000) != 0) { - printk("%s(): Ping error with 0x1a\n", __FUNCTION__); - return -ENODEV; - } - else - printk("%s(): Ping OK with 0x1a\n", __FUNCTION__); -#endif -//leaf if(0 == tcsi_get_value(TCSI_CODEC_ES8323)) -//leaf2012-7-26 return; - DBG("XXXXEnter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - DBG("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - DBG("platform device add failed\n"); - platform_device_put(rk29_snd_device); - return ret; - } - + int ret; + struct snd_soc_card *card = &rockchip_es8323_snd_card; + + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + return ret; } -static void __exit audio_card_exit(void) + +static int rockchip_es8323_audio_remove(struct platform_device *pdev) { -//leaf 2012-7-26 if(0 == tcsi_get_value(TCSI_CODEC_ES8323)) -//leaf 2012-7-26 return; - platform_device_unregister(rk29_snd_device); - //rk29_speaker_deinit(rk29_speaker); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_es8323_of_match[] = { + { .compatible = "rockchip-es8323", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_es8323_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_es8323_audio_driver = { + .driver = { + .name = "rockchip-es8323", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_es8323_of_match), + }, + .probe = rockchip_es8323_audio_probe, + .remove = rockchip_es8323_audio_remove, +}; + +module_platform_driver(rockchip_es8323_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_hdmi_i2s.c b/sound/soc/rockchip/rk_hdmi_i2s.c index d1692f6e49e6..31ce9a60cd74 100644 --- a/sound/soc/rockchip/rk_hdmi_i2s.c +++ b/sound/soc/rockchip/rk_hdmi_i2s.c @@ -5,9 +5,14 @@ * Author: chenjq */ -#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include "rk_pcm.h" #include "rk29_i2s.h" @@ -18,7 +23,6 @@ #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) { @@ -81,75 +85,67 @@ static struct snd_soc_dai_link hdmi_i2s_dai = { .name = "HDMI I2S", .stream_name = "HDMI PCM", .codec_name = "hdmi-i2s", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rk-hdmi-i2s-hifi", .ops = &hdmi_i2s_hifi_ops, }; -static struct snd_soc_card snd_soc_card_hdmi_i2s = { +static struct snd_soc_card rockchip_hdmi_i2s_snd_card = { .name = "RK-HDMI-I2S", .dai_link = &hdmi_i2s_dai, .num_links = 1, }; -static struct platform_device *hdmi_i2s_snd_device; -static struct platform_device *hdmi_i2s_device; - -static int __init audio_card_init(void) +static int rockchip_hdmi_i2s_audio_probe(struct platform_device *pdev) { - int ret =0; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - - hdmi_i2s_device = platform_device_alloc("hdmi-i2s", -1); - - if (!hdmi_i2s_device){ - printk("spdif:platform_device_alloc hdmi-i2s\n"); - return -ENOMEM; - } + int ret; + struct snd_soc_card *card = &rockchip_hdmi_i2s_snd_card; - ret = platform_device_add(hdmi_i2s_device); - if (ret) { - printk("platform device add hdmi-i2s failed\n"); + card->dev = &pdev->dev; - platform_device_put(hdmi_i2s_device); - return ret; - } + ret = snd_soc_register_card(card); - hdmi_i2s_snd_device = platform_device_alloc("soc-audio", -3); - if (!hdmi_i2s_snd_device) { - printk("platform device allocation failed\n"); + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - platform_device_put(hdmi_i2s_device); - return -ENOMEM; - } + return ret; +} - platform_set_drvdata(hdmi_i2s_snd_device, &snd_soc_card_hdmi_i2s); - ret = platform_device_add(hdmi_i2s_snd_device); - if (ret) { - printk("platform device add soc-audio failed\n"); +static int rockchip_hdmi_i2s_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); - platform_device_put(hdmi_i2s_device); - platform_device_put(hdmi_i2s_snd_device); - return ret; - } + snd_soc_unregister_card(card); - return ret; + return 0; } -static void __exit audio_card_exit(void) -{ - platform_device_unregister(hdmi_i2s_snd_device); -} +#ifdef CONFIG_OF +static const struct of_device_id rockchip_hdmi_i2s_of_match[] = { + { .compatible = "rockchip-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 = "rockchip-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, +}; + +module_platform_driver(rockchip_hdmi_i2s_audio_driver); -late_initcall(audio_card_init); -module_exit(audio_card_exit); /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP hdmi i2s ASoC Interface"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL"); \ No newline at end of file diff --git a/sound/soc/rockchip/rk_hdmi_spdif.c b/sound/soc/rockchip/rk_hdmi_spdif.c index c93a23957b4e..5aaad117ea8f 100755 --- a/sound/soc/rockchip/rk_hdmi_spdif.c +++ b/sound/soc/rockchip/rk_hdmi_spdif.c @@ -13,11 +13,15 @@ * */ +#include +#include +#include +#include #include - +#include +#include #include - -#include +#include #if 0 #define RK_SPDIF_DBG(x...) printk(KERN_INFO "rk_hdmi_spdif:"x) @@ -106,80 +110,62 @@ static struct snd_soc_ops rk_spdif_ops = { static struct snd_soc_dai_link rk_dai = { .name = "SPDIF", .stream_name = "SPDIF PCM Playback", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk-spdif", - .codec_dai_name = "dit-hifi", - .codec_name = "spdif-dit", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-spdif", + .codec_dai_name = "rk-hdmi-spdif-hifi", + .codec_name = "hdmi-spdif", .ops = &rk_spdif_ops, }; -static struct snd_soc_card rk_spdif = { +static struct snd_soc_card rockchip_hdmi_spdif_snd_card = { .name = "ROCKCHIP-SPDIF", .dai_link = &rk_dai, .num_links = 1, }; -static struct platform_device *rk_snd_spdif_dit_device; -static struct platform_device *rk_snd_spdif_device; - -static int __init rk_spdif_init(void) +static int rockchip_hdmi_spdif_audio_probe(struct platform_device *pdev) { int ret; - - RK_SPDIF_DBG("Entered %s\n", __func__); - - rk_snd_spdif_dit_device = platform_device_alloc("spdif-dit", -1); - if (!rk_snd_spdif_dit_device){ - printk("spdif:platform_device_alloc spdif-dit\n"); - return -ENOMEM; - } + struct snd_soc_card *card = &rockchip_hdmi_spdif_snd_card; - ret = platform_device_add(rk_snd_spdif_dit_device); - if (ret) - goto err1; - - rk_snd_spdif_device = platform_device_alloc("soc-audio", -3); - if (!rk_snd_spdif_device) { - printk("spdif:platform_device_alloc rk_soc-audio\n"); - ret = -ENOMEM; - goto err2; - } - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) - platform_set_drvdata(rk_snd_spdif_device, &rk_spdif); -#else - platform_set_drvdata(rk_snd_spdif_device, &rk_spdif); - rk_spdif.dev = &rk_snd_spdif_device->dev; -#endif + card->dev = &pdev->dev; - //platform_set_drvdata(rk_snd_spdif_device, &rk_spdif); + ret = snd_soc_register_card(card); - ret = platform_device_add(rk_snd_spdif_device); if (ret) - goto err3; - - RK_SPDIF_DBG("rk_spdif_init ok\n"); - return ret; -err3: - platform_device_put(rk_snd_spdif_device); -err2: - platform_device_del(rk_snd_spdif_dit_device); -err1: - platform_device_put(rk_snd_spdif_dit_device); - + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + return ret; } -static void __exit rk_spdif_exit(void) +static int rockchip_hdmi_spdif_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk_snd_spdif_device); - platform_device_unregister(rk_snd_spdif_dit_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -//using late_initcall to make sure spdif is after board codec. added by zxg. -//module_init(rk_spdif_init); -late_initcall(rk_spdif_init); -module_exit(rk_spdif_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_hdmi_spdif_of_match[] = { + { .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, + .of_match_table = of_match_ptr(rockchip_hdmi_spdif_of_match), + }, + .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"); diff --git a/sound/soc/rockchip/rk_jetta_codec.c b/sound/soc/rockchip/rk_jetta_codec.c index b120959a1b1d..9a61274f4df4 100755 --- a/sound/soc/rockchip/rk_jetta_codec.c +++ b/sound/soc/rockchip/rk_jetta_codec.c @@ -13,12 +13,12 @@ #include #include +#include +#include #include #include #include #include -#include -#include #include "../codecs/rk610_codec.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -136,56 +136,67 @@ static struct snd_soc_dai_link rk29_dai = { #else .codec_name = "RK610_CODEC.0-0060", #endif - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "rk610_codec", .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rk610_snd_card = { .name = "RK_RK610", .dai_link = &rk29_dai, .num_links = 1, }; +static int rockchip_rk610_audio_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card = &rockchip_rk610_snd_card; -static struct platform_device *rk29_snd_device; + card->dev = &pdev->dev; -static int __init audio_card_init(void) -{ - int ret =0; -#ifdef CONFIG_MACH_RK_FAC - if(codec_type!=CODEC_TYPE_RK616) - return -1; -#endif - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("[%s] platform device allocation failed\n", __FUNCTION__); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - ret = platform_device_add(rk29_snd_device); - if (ret) { - DBG("platform device add failed\n"); - platform_device_put(rk29_snd_device); - } return ret; } -static void __exit audio_card_exit(void) + +static int rockchip_rk610_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rk610_of_match[] = { + { .compatible = "rockchip-rk610", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rk610_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rk610_audio_driver = { + .driver = { + .name = "rockchip-rk610", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rk610_of_match), + }, + .probe = rockchip_rk610_audio_probe, + .remove = rockchip_rk610_audio_remove, +}; + +module_platform_driver(rockchip_rk610_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rk1000codec.c b/sound/soc/rockchip/rk_rk1000codec.c index 7825020431cd..23c277924cac 100755 --- a/sound/soc/rockchip/rk_rk1000codec.c +++ b/sound/soc/rockchip/rk_rk1000codec.c @@ -13,12 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include + #include "../codecs/rk1000_codec.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -82,58 +83,69 @@ static struct snd_soc_dai_link rk29_dai[] = { { .name = "RK1000", .stream_name = "RK1000 CODEC PCM", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", .codec_name = "RK1000_CODEC.0-0060", .codec_dai_name = "rk1000_codec", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .init = rk29_rk1000_codec_init, .ops = &rk29_ops, } }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rk1000_snd_card = { .name = "RK_RK1000", .dai_link = rk29_dai, .num_links = 1, }; +static int rockchip_rk1000_audio_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card = &rockchip_rk1000_snd_card; -static struct platform_device *rk29_snd_device; + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); -static int __init audio_card_init(void) -{ - int ret =0; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); - platform_device_put(rk29_snd_device); - } - printk("audio_card_init end....\n"); return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rk1000_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rk1000_of_match[] = { + { .compatible = "rockchip-rk1000", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rk1000_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rk1000_audio_driver = { + .driver = { + .name = "rockchip-rk1000", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rk1000_of_match), + }, + .probe = rockchip_rk1000_audio_probe, + .remove = rockchip_rk1000_audio_remove, +}; + +module_platform_driver(rockchip_rk1000_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rk3026.c b/sound/soc/rockchip/rk_rk3026.c index 191aef64269c..8e937ec9a6fb 100644 --- a/sound/soc/rockchip/rk_rk3026.c +++ b/sound/soc/rockchip/rk_rk3026.c @@ -13,12 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include + #include "../codecs/rk3026_codec.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -220,11 +221,11 @@ static struct snd_soc_dai_link rk_dai[] = { .name = "RK3026 I2S1", .stream_name = "RK3026 PCM", .codec_name = "rk3026-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rk3026-hifi", .init = rk3026_init, @@ -234,56 +235,67 @@ static struct snd_soc_dai_link rk_dai[] = { .name = "RK3026 I2S2", .stream_name = "RK3026 PCM", .codec_name = "rk3026-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rk3026-voice", .ops = &rk3026_voice_ops, }, }; -static struct snd_soc_card snd_soc_card_rk = { +static struct snd_soc_card rockchip_rk3026_snd_card = { .name = "RK_RK3026", .dai_link = rk_dai, .num_links = 2, }; -static struct platform_device *rk_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rk3026_audio_probe(struct platform_device *pdev) { - int ret =0; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + int ret; + struct snd_soc_card *card = &rockchip_rk3026_snd_card; - rk_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } + card->dev = &pdev->dev; - platform_set_drvdata(rk_snd_device, &snd_soc_card_rk); - ret = platform_device_add(rk_snd_device); - if (ret) { - printk("platform device add failed\n"); + ret = snd_soc_register_card(card); - platform_device_put(rk_snd_device); - return ret; - } + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - return ret; + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rk3026_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rk3026_of_match[] = { + { .compatible = "rockchip-rk3026", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rk3026_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rk3026_audio_driver = { + .driver = { + .name = "rockchip-rk3026", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rk3026_of_match), + }, + .probe = rockchip_rk3026_audio_probe, + .remove = rockchip_rk3026_audio_remove, +}; + +module_platform_driver(rockchip_rk3026_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rk3190.c b/sound/soc/rockchip/rk_rk3190.c index 3e6e3b989b0b..a108501c72ed 100755 --- a/sound/soc/rockchip/rk_rk3190.c +++ b/sound/soc/rockchip/rk_rk3190.c @@ -13,12 +13,12 @@ #include #include +#include +#include #include #include #include #include -#include -#include #include "../codecs/rk3190_codec.h" #include "rk29_pcm.h" #include "rk29_i2s.h" @@ -220,7 +220,7 @@ static struct snd_soc_dai_link rk_dai[] = { .name = "RK3190 I2S1", .stream_name = "RK3190 PCM", .codec_name = "rk3190-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK29_SOC_I2S_8CH) .cpu_dai_name = "rk29_i2s.0", #elif defined(CONFIG_SND_RK29_SOC_I2S_2CH) @@ -234,7 +234,7 @@ static struct snd_soc_dai_link rk_dai[] = { .name = "RK3190 I2S2", .stream_name = "RK3190 PCM", .codec_name = "rk3190-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK29_SOC_I2S_8CH) .cpu_dai_name = "rk29_i2s.0", #elif defined(CONFIG_SND_RK29_SOC_I2S_2CH) @@ -245,45 +245,56 @@ static struct snd_soc_dai_link rk_dai[] = { }, }; -static struct snd_soc_card snd_soc_card_rk = { +static struct snd_soc_card rockchip_rk3190_snd_card = { .name = "RK_RK3190", .dai_link = rk_dai, .num_links = 2, }; -static struct platform_device *rk_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rk3190_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_rk3190_snd_card; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + card->dev = &pdev->dev; - rk_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } + ret = snd_soc_register_card(card); - platform_set_drvdata(rk_snd_device, &snd_soc_card_rk); - ret = platform_device_add(rk_snd_device); - if (ret) { - printk("platform device add failed\n"); - - platform_device_put(rk_snd_device); - return ret; - } + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - return ret; + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rk3190_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rk3190_of_match[] = { + { .compatible = "rockchip-rk3190", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rk3190_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rk3190_audio_driver = { + .driver = { + .name = "rockchip-rk3190", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rk3190_of_match), + }, + .probe = rockchip_rk3190_audio_probe, + .remove = rockchip_rk3190_audio_remove, +}; + +module_platform_driver(rockchip_rk3190_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rk616.c b/sound/soc/rockchip/rk_rk616.c index a88e7284d1f0..50e949634214 100755 --- a/sound/soc/rockchip/rk_rk616.c +++ b/sound/soc/rockchip/rk_rk616.c @@ -13,12 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include + #include "../codecs/rk616_codec.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -250,11 +251,11 @@ static struct snd_soc_dai_link rk_dai[] = { .name = "RK616 I2S1", .stream_name = "RK616 PCM", .codec_name = "rk616-codec.4-0050", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rk616-hifi", .init = rk616_init, @@ -264,56 +265,67 @@ static struct snd_soc_dai_link rk_dai[] = { .name = "RK616 I2S2", .stream_name = "RK616 PCM", .codec_name = "rk616-codec.4-0050", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rk616-voice", .ops = &rk616_voice_ops, }, }; -static struct snd_soc_card snd_soc_card_rk = { +static struct snd_soc_card rockchip_rk616_snd_card = { .name = "RK_RK616", .dai_link = rk_dai, .num_links = 2, }; -static struct platform_device *rk_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rk616_audio_probe(struct platform_device *pdev) { - int ret =0; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + int ret; + struct snd_soc_card *card = &rockchip_rk616_snd_card; - rk_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } + card->dev = &pdev->dev; - platform_set_drvdata(rk_snd_device, &snd_soc_card_rk); - ret = platform_device_add(rk_snd_device); - if (ret) { - printk("platform device add failed\n"); + ret = snd_soc_register_card(card); - platform_device_put(rk_snd_device); - return ret; - } + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - return ret; + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rk616_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rk616_of_match[] = { + { .compatible = "rockchip-rk616", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rk616_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rk616_audio_driver = { + .driver = { + .name = "rockchip-rk616", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rk616_of_match), + }, + .probe = rockchip_rk616_audio_probe, + .remove = rockchip_rk616_audio_remove, +}; + +module_platform_driver(rockchip_rk616_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt3261.c b/sound/soc/rockchip/rk_rt3261.c index fd0f97f375ad..5ba4b5186cf3 100644 --- a/sound/soc/rockchip/rk_rt3261.c +++ b/sound/soc/rockchip/rk_rt3261.c @@ -18,20 +18,20 @@ #include #include #include -#include +#include +#include #include "../codecs/rt3261.h" #include "rk_pcm.h" #include "rk29_i2s.h" - #if 0 #define DBG(x...) printk(KERN_INFO x) #else #define DBG(x...) #endif -static int rk29_hw_params(struct snd_pcm_substream *substream, +static int rockchip_rt3261_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -116,7 +116,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, return 0; } -static int rt3261_voice_hw_params(struct snd_pcm_substream *substream, +static int rockchip_rt3261_voice_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -170,7 +170,7 @@ static int rt3261_voice_hw_params(struct snd_pcm_substream *substream, return 0; } -static const struct snd_soc_dapm_widget rt3261_dapm_widgets[] = { +static const struct snd_soc_dapm_widget rockchip_rt3261_dapm_widgets[] = { SND_SOC_DAPM_MIC("Mic Jack", NULL), SND_SOC_DAPM_MIC("Headset Jack", NULL), SND_SOC_DAPM_SPK("Ext Spk", NULL), @@ -196,7 +196,7 @@ static const struct snd_soc_dapm_route audio_map[]={ {"Headphone Jack", NULL, "HPOR"}, } ; -static const struct snd_kcontrol_new rk_controls[] = { +static const struct snd_kcontrol_new rockchip_rt3261_controls[] = { SOC_DAPM_PIN_SWITCH("Mic Jack"), SOC_DAPM_PIN_SWITCH("Headset Jack"), SOC_DAPM_PIN_SWITCH("Ext Spk"), @@ -206,19 +206,19 @@ static const struct snd_kcontrol_new rk_controls[] = { /* * Logic for a rt3261 as connected on a rockchip board. */ -static int rk29_rt3261_init(struct snd_soc_pcm_runtime *rtd) +static int rockchip_rt3261_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - snd_soc_add_codec_controls(codec, rk_controls, - ARRAY_SIZE(rk_controls)); + snd_soc_add_codec_controls(codec, rockchip_rt3261_controls, + ARRAY_SIZE(rockchip_rt3261_controls)); /* Add specific widgets */ - snd_soc_dapm_new_controls(dapm, rt3261_dapm_widgets, - ARRAY_SIZE(rt3261_dapm_widgets)); + snd_soc_dapm_new_controls(dapm, rockchip_rt3261_dapm_widgets, + ARRAY_SIZE(rockchip_rt3261_dapm_widgets)); /* Set up specific audio path audio_mapnects */ snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); @@ -230,13 +230,13 @@ static int rk29_rt3261_init(struct snd_soc_pcm_runtime *rtd) extern int hdmi_is_insert(void); extern void codec_set_spk(bool on); if(hdmi_is_insert()) - codec_set_spk(false); + rt3261_codec_set_spk(false); #endif #ifdef CONFIG_HDMI_RK30 extern int hdmi_get_hotplug(void); if(hdmi_get_hotplug() == 2/*HDMI_HPD_ACTIVED*/) - codec_set_spk(false); + rt3261_codec_set_spk(false); #endif snd_soc_dapm_sync(dapm); @@ -244,83 +244,99 @@ static int rk29_rt3261_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_ops rk29_ops = { - .hw_params = rk29_hw_params, +static struct snd_soc_ops rockchip_rt3261_hifi_ops = { + .hw_params = rockchip_rt3261_hifi_hw_params, }; -static struct snd_soc_ops rt3261_voice_ops = { - .hw_params = rt3261_voice_hw_params, +static struct snd_soc_ops rockchip_rt3261_voice_ops = { + .hw_params = rockchip_rt3261_voice_hw_params, }; -static struct snd_soc_dai_link rk29_dai[] = { +static struct snd_soc_dai_link rockchip_rt3261_dai[] = { { .name = "RT3261 I2S1", .stream_name = "RT3261 PCM", .codec_name = "rt3261.0-001c", - .platform_name = "rockchip-audio", - #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + #if defined(CONFIG_SND_RK_SOC_I2S_8CH) + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rt3261-aif1", - .init = rk29_rt3261_init, - .ops = &rk29_ops, + .init = rockchip_rt3261_init, + .ops = &rockchip_rt3261_hifi_ops, }, { .name = "RT3261 I2S2", .stream_name = "RT3261 PCM", .codec_name = "rt3261.0-001c", - .platform_name = "rockchip-audio", - #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + #if defined(CONFIG_SND_RK_SOC_I2S_8CH) + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rt3261-aif2", - .ops = &rt3261_voice_ops, + .ops = &rockchip_rt3261_voice_ops, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { - .name = "RK_RT3261", - .dai_link = rk29_dai, - .num_links = 2, +static struct snd_soc_card rockchip_rt3261_snd_card = { + #if defined (CONFIG_SND_SOC_RT3224) + .name = "ROCKCHIP-RT3224", + #else + .name = "ROCKCHIP-RT3261", + #endif + .owner = THIS_MODULE, + .dai_link = rockchip_rt3261_dai, + .num_links = ARRAY_SIZE(rockchip_rt3261_dai), }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt3261_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_rt3261_snd_card; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + card->dev = &pdev->dev; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } + ret = snd_soc_register_card(card); - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - platform_device_put(rk29_snd_device); - return ret; - } - - return ret; + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt3261_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt3261_of_match[] = { + { .compatible = "rockchip-rt3261", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt3261_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt3261_audio_driver = { + .driver = { + .name = "rockchip-rt3261", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt3261_of_match), + }, + .probe = rockchip_rt3261_audio_probe, + .remove = rockchip_rt3261_audio_remove, +}; + +module_platform_driver(rockchip_rt3261_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt5512.c b/sound/soc/rockchip/rk_rt5512.c index 33a6f830c45e..348247927575 100755 --- a/sound/soc/rockchip/rk_rt5512.c +++ b/sound/soc/rockchip/rk_rt5512.c @@ -8,12 +8,12 @@ */ #include #include +#include +#include #include #include #include #include -#include -#include #include #include #include "rk_pcm.h" @@ -116,7 +116,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN); if (ret < 0) { - DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n"); + DBG("rk29_hw_params_rt5512:failed to set the sysclk for codec side\n"); return ret; } @@ -288,16 +288,16 @@ static struct snd_soc_dai_link rk29_dai[] = { { /* Primary DAI i/f */ .name = "RT5512 AIF1", .stream_name = "RT5512 PCM", - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", .codec_dai_name = "RT5512-aif1", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", .codec_name = "rt5512.1-0018", .init = rt5512_init, .ops = &rk29_ops, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rt5512_snd_card = { .name = "RK_RT5512", .dai_link = rk29_dai, @@ -306,28 +306,49 @@ static struct snd_soc_card snd_soc_card_rk29 = { .num_links = ARRAY_SIZE(rk29_dai), }; -static int __init audio_card_init(void) +static int rockchip_rt5512_audio_probe(struct platform_device *pdev) { int ret; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) - return -ENOMEM; + struct snd_soc_card *card = &rockchip_rt5512_snd_card; - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); - ret = platform_device_add(rk29_snd_device); if (ret) - platform_device_put(rk29_snd_device); + printk("%s() register card failed:%d\n", __FUNCTION__, ret); return ret; } -module_init(audio_card_init); -static void __exit audio_card_exit(void) +static int rockchip_rt5512_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_exit(audio_card_exit); + +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5512_of_match[] = { + { .compatible = "rockchip-rt5512", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5512_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5512_audio_driver = { + .driver = { + .name = "rockchip-rt5512", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5512_of_match), + }, + .probe = rockchip_rt5512_audio_probe, + .remove = rockchip_rt5512_audio_remove, +}; + +module_platform_driver(rockchip_rt5512_audio_driver); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); MODULE_AUTHOR("cy_huang "); diff --git a/sound/soc/rockchip/rk_rt5616.c b/sound/soc/rockchip/rk_rt5616.c index 0a49430be7b0..525eaed467d6 100755 --- a/sound/soc/rockchip/rk_rt5616.c +++ b/sound/soc/rockchip/rk_rt5616.c @@ -1,7 +1,7 @@ /* - * rk29_rt5631.c -- SoC audio for rockchip + * rk29_rt5616.c -- SoC audio for rockchip * - * Driver for rockchip rt5631 audio + * Driver for rockchip rt5616 audio * * 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 @@ -13,13 +13,14 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include "../codecs/rt5631.h" + +#include "../codecs/rt5616.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -99,12 +100,12 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE) #if 0 //use pll from blck - /*Set the pll of rt5631,the Pll source from BITCLK on CPU is master mode*/ + /*Set the pll of rt5616,the Pll source from BITCLK on CPU is master mode*/ //bitclk is 64fs ret=snd_soc_dai_set_pll(codec_dai,0,params_rate(params)*64,pll_out); if (ret < 0) { - DBG("rk29_hw_params_rt5631:failed to set the pll for codec side\n"); + DBG("rk29_hw_params_rt5616:failed to set the pll for codec side\n"); return ret; } #endif @@ -112,7 +113,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN); if (ret < 0) { - DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n"); + DBG("rk29_hw_params_rt5616:failed to set the sysclk for codec side\n"); return ret; } #endif @@ -137,7 +138,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, return 0; } -static const struct snd_soc_dapm_widget rt5631_dapm_widgets[] = { +static const struct snd_soc_dapm_widget rt5616_dapm_widgets[] = { SND_SOC_DAPM_MIC("Mic Jack", NULL), SND_SOC_DAPM_SPK("Ext Spk", NULL), @@ -160,9 +161,9 @@ static const struct snd_soc_dapm_route audio_map[]={ } ; /* - * Logic for a rt5631 as connected on a rockchip board. + * Logic for a rt5616 as connected on a rockchip board. */ -static int rk29_rt5631_init(struct snd_soc_pcm_runtime *rtd) +static int rk29_rt5616_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; @@ -170,8 +171,8 @@ static int rk29_rt5631_init(struct snd_soc_pcm_runtime *rtd) DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); /* Add specific widgets */ - snd_soc_dapm_new_controls(dapm, rt5631_dapm_widgets, - ARRAY_SIZE(rt5631_dapm_widgets)); + snd_soc_dapm_new_controls(dapm, rt5616_dapm_widgets, + ARRAY_SIZE(rt5616_dapm_widgets)); DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); /* Set up specific audio path audio_mapnects */ snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); @@ -193,55 +194,70 @@ static struct snd_soc_ops rk29_ops = { static struct snd_soc_dai_link rk29_dai = { .name = "rt5616", .stream_name = "rt5616 PCM", - .codec_name = "rt5616.4-001b", - .platform_name = "rockchip-audio", + .codec_name = "rt5616.0-001b", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "rt5616-aif1", - .init = rk29_rt5631_init, + .init = rk29_rt5616_init, .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rt5616_snd_card = { .name = "RK_RT5616", .dai_link = &rk29_dai, .num_links = 1, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt5616_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_rt5616_snd_card; + + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); - platform_device_put(rk29_snd_device); - } return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt5616_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5616_of_match[] = { + { .compatible = "rockchip-rt5616", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5616_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5616_audio_driver = { + .driver = { + .name = "rockchip-rt5616", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5616_of_match), + }, + .probe = rockchip_rt5616_audio_probe, + .remove = rockchip_rt5616_audio_remove, +}; + +module_platform_driver(rockchip_rt5616_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt5621.c b/sound/soc/rockchip/rk_rt5621.c index 3469e085036c..d95d324e2c0d 100644 --- a/sound/soc/rockchip/rk_rt5621.c +++ b/sound/soc/rockchip/rk_rt5621.c @@ -13,13 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include + #include "../codecs/rt5621.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -178,51 +178,63 @@ static struct snd_soc_dai_link rk29_dai = { .name = "RT5621", .stream_name = "RT5621 PCM", .codec_name = "RT5621.0-001a", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "RT5621 HiFi", .init = rk29_rt5621_init, .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rt5621_snd_card = { .name = "RK_RT5621", .dai_link = &rk29_dai, .num_links = 1, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt5621_audio_probe(struct platform_device *pdev) { - int ret =0; - - //rk29_speaker = rk29_speaker_init(RK29_PIN6_PB6, GPIO_HIGH, 2, (200*1000*1000)); - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - DBG("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - DBG("platform device add failed\n"); - platform_device_put(rk29_snd_device); - return ret; - } + int ret; + struct snd_soc_card *card = &rockchip_rt5621_snd_card; + + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt5621_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5621_of_match[] = { + { .compatible = "rockchip-rt5621", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5621_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5621_audio_driver = { + .driver = { + .name = "rockchip-rt5621", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5621_of_match), + }, + .probe = rockchip_rt5621_audio_probe, + .remove = rockchip_rt5621_audio_remove, +}; + +module_platform_driver(rockchip_rt5621_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt5625.c b/sound/soc/rockchip/rk_rt5625.c index 3d46289f54ba..72dac3433ccd 100644 --- a/sound/soc/rockchip/rk_rt5625.c +++ b/sound/soc/rockchip/rk_rt5625.c @@ -13,13 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include + #include "../codecs/rt5625.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -186,8 +186,8 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "RT5625 I2S1", .stream_name = "RT5625 PCM", .codec_name = "rt5625.0-001f", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "rt5625-aif1", .ops = &rk29_ops, }, @@ -195,52 +195,63 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "RT5625 I2S2", .stream_name = "RT5625 PCM", .codec_name = "rt5625.0-001f", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "rt5625-aif2", .ops = &rt5625_voice_ops, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rt5625_snd_card = { .name = "RK_RT5625", .dai_link = rk29_dai, .num_links = 2, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt5625_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_rt5625_snd_card; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + card->dev = &pdev->dev; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } + ret = snd_soc_register_card(card); - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - platform_device_put(rk29_snd_device); - return ret; - } - - return ret; + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt5625_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5625_of_match[] = { + { .compatible = "rockchip-rt5625", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5625_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5625_audio_driver = { + .driver = { + .name = "rockchip-rt5625", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5625_of_match), + }, + .probe = rockchip_rt5625_audio_probe, + .remove = rockchip_rt5625_audio_remove, +}; + +module_platform_driver(rockchip_rt5625_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt5631.c b/sound/soc/rockchip/rk_rt5631.c index 8ddc988e1b89..5929864402fd 100755 --- a/sound/soc/rockchip/rk_rt5631.c +++ b/sound/soc/rockchip/rk_rt5631.c @@ -13,12 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include + #include "../codecs/rt5631.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -204,61 +205,72 @@ static struct snd_soc_ops rk29_ops = { }; static struct snd_soc_dai_link rk29_dai = { - .name = "RT5631", - .stream_name = "RT5631 PCM", - .codec_name = "RT5631.0-001a", - .platform_name = "rockchip-audio", + .name = "rt5631", + .stream_name = "rt5631 PCM", + .codec_name = "rt5631.0-001a", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif - .codec_dai_name = "RT5631 HiFi", + .codec_dai_name = "rt5631-hifi", .init = rk29_rt5631_init, .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { - .name = "RK_RT5631", +static struct snd_soc_card rockchip_rt5631_snd_card = { + .name = "RK_rt5631", .dai_link = &rk29_dai, .num_links = 1, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt5631_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_rt5631_snd_card; + + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); -#ifdef CONFIG_MACH_RK_FAC - if(codec_type!=CODEC_TYPE_RT5631) - return -1; -#endif - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); - platform_device_put(rk29_snd_device); - } return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt5631_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5631_of_match[] = { + { .compatible = "rockchip-rt5631", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5631_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5631_audio_driver = { + .driver = { + .name = "rockchip-rt5631", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5631_of_match), + }, + .probe = rockchip_rt5631_audio_probe, + .remove = rockchip_rt5631_audio_remove, +}; + +module_platform_driver(rockchip_rt5631_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt5631_phone.c b/sound/soc/rockchip/rk_rt5631_phone.c index cd585f8aee8f..8694fd9f01e1 100755 --- a/sound/soc/rockchip/rk_rt5631_phone.c +++ b/sound/soc/rockchip/rk_rt5631_phone.c @@ -13,12 +13,12 @@ #include #include +#include +#include #include #include #include #include -#include -#include #include "../codecs/rt5631_phone.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -249,13 +249,13 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "RT5631 hifi", .stream_name = "RT5631 hifi stream", .codec_name = "RT5631.0-001a", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "RT5631 HiFi", .init = rk29_rt5631_init, @@ -265,54 +265,69 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "RT5631 voice", .stream_name = "RT5631 voice stream", .codec_name = "RT5631.0-001a", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #else - .cpu_dai_name = "rk_i2s.2", + .cpu_dai_name = "rockchip-i2s.2", #endif .codec_dai_name = "rt5631-voice", .ops = &rk29_ops_voice, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rt5631_snd_card = { .name = "RK_RT5631", .dai_link = rk29_dai, .num_links = 2, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt5631_audio_probe(struct platform_device *pdev) { - int ret =0; - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); - platform_device_put(rk29_snd_device); - } + int ret; + struct snd_soc_card *card = &rockchip_rt5631_snd_card; + + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt5631_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5631_of_match[] = { + { .compatible = "rockchip-rt5631-phone", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5631_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5631_audio_driver = { + .driver = { + .name = "rockchip-rt5631-phone", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5631_of_match), + }, + .probe = rockchip_rt5631_audio_probe, + .remove = rockchip_rt5631_audio_remove, +}; + +module_platform_driver(rockchip_rt5631_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt5639.c b/sound/soc/rockchip/rk_rt5639.c index 91d0f49a2659..48435b5b4e89 100755 --- a/sound/soc/rockchip/rk_rt5639.c +++ b/sound/soc/rockchip/rk_rt5639.c @@ -13,14 +13,14 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include "../codecs/rt3261.h" +#include "../codecs/rt5639.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -114,7 +114,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, return 0; } -static int rt3261_voice_hw_params(struct snd_pcm_substream *substream, +static int rt5639_voice_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -178,7 +178,7 @@ static struct snd_soc_ops rk29_ops = { }; static struct snd_soc_ops rt5639_voice_ops = { - .hw_params = rt3261_voice_hw_params, + .hw_params = rt5639_voice_hw_params, }; static struct snd_soc_dai_link rk29_dai[] = { @@ -186,8 +186,8 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "RT5639 I2S1", .stream_name = "RT5639 PCM", .codec_name = "rt5639.0-001c", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "rt5639-aif1", .ops = &rk29_ops, }, @@ -195,52 +195,63 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "RT5639 I2S2", .stream_name = "RT5639 PCM", .codec_name = "rt5639.0-001c", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "rt5639-aif2", .ops = &rt5639_voice_ops, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rt5639_snd_card = { .name = "RK_RT5639", .dai_link = rk29_dai, .num_links = 2, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt5639_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_rt5639_snd_card; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + card->dev = &pdev->dev; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } + ret = snd_soc_register_card(card); - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - platform_device_put(rk29_snd_device); - return ret; - } - - return ret; + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt5639_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5639_of_match[] = { + { .compatible = "rockchip-rt5639", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5639_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5639_audio_driver = { + .driver = { + .name = "rockchip-rt5639", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5639_of_match), + }, + .probe = rockchip_rt5639_audio_probe, + .remove = rockchip_rt5639_audio_remove, +}; + +module_platform_driver(rockchip_rt5639_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_rt5640.c b/sound/soc/rockchip/rk_rt5640.c index 6756f33fb84f..d253ae38d416 100755 --- a/sound/soc/rockchip/rk_rt5640.c +++ b/sound/soc/rockchip/rk_rt5640.c @@ -1,7 +1,7 @@ /* - * rk29_rt3261.c -- SoC audio for rockchip + * rk29_rt5640.c -- SoC audio for rockchip * - * Driver for rockchip rt3261 audio + * Driver for rockchip rt5640 audio * * 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 @@ -13,14 +13,14 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include "../codecs/rt3261.h" +#include "../codecs/rt5640.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -102,7 +102,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_dai_set_sysclk(codec_dai, 0, pll_out, SND_SOC_CLOCK_IN); if (ret < 0) { - DBG("rk29_hw_params_rt3261:failed to set the sysclk for codec side\n"); + DBG("rk29_hw_params_rt5640:failed to set the sysclk for codec side\n"); return ret; } @@ -115,7 +115,7 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, return 0; } -static int rt3261_voice_hw_params(struct snd_pcm_substream *substream, +static int rt5640_voice_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -151,13 +151,13 @@ static int rt3261_voice_hw_params(struct snd_pcm_substream *substream, DBG("Enter:%s, %d, rate=%d\n", __FUNCTION__, __LINE__, params_rate(params)); /*Set the system clk for codec*/ - snd_soc_dai_set_pll(codec_dai, 0, RT3261_PLL1_S_MCLK, pll_out, 24576000); + snd_soc_dai_set_pll(codec_dai, 0, RT5640_PLL1_S_MCLK, pll_out, 24576000); - ret = snd_soc_dai_set_sysclk(codec_dai, RT3261_SCLK_S_PLL1, 24576000, SND_SOC_CLOCK_IN); + ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1, 24576000, SND_SOC_CLOCK_IN); if (ret < 0) { - printk("rk29_hw_params_rt3261:failed to set the sysclk for codec side\n"); + printk("rk29_hw_params_rt5640:failed to set the sysclk for codec side\n"); return ret; } @@ -170,7 +170,7 @@ static int rt3261_voice_hw_params(struct snd_pcm_substream *substream, return 0; } -static const struct snd_soc_dapm_widget rt3261_dapm_widgets[] = { +static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { SND_SOC_DAPM_MIC("Mic Jack", NULL), SND_SOC_DAPM_MIC("Headset Jack", NULL), SND_SOC_DAPM_SPK("Ext Spk", NULL), @@ -204,9 +204,9 @@ static const struct snd_kcontrol_new rk_controls[] = { }; /* - * Logic for a rt3261 as connected on a rockchip board. + * Logic for a rt5640 as connected on a rockchip board. */ -static int rk29_rt3261_init(struct snd_soc_pcm_runtime *rtd) +static int rk29_rt5640_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; @@ -217,8 +217,8 @@ static int rk29_rt3261_init(struct snd_soc_pcm_runtime *rtd) ARRAY_SIZE(rk_controls)); /* Add specific widgets */ - snd_soc_dapm_new_controls(dapm, rt3261_dapm_widgets, - ARRAY_SIZE(rt3261_dapm_widgets)); + snd_soc_dapm_new_controls(dapm, rt5640_dapm_widgets, + ARRAY_SIZE(rt5640_dapm_widgets)); /* Set up specific audio path audio_mapnects */ snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); @@ -248,8 +248,8 @@ static struct snd_soc_ops rk29_ops = { .hw_params = rk29_hw_params, }; -static struct snd_soc_ops rt3261_voice_ops = { - .hw_params = rt3261_voice_hw_params, +static struct snd_soc_ops rt5640_voice_ops = { + .hw_params = rt5640_voice_hw_params, }; static struct snd_soc_dai_link rk29_dai[] = { @@ -257,70 +257,81 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "RT5640 I2S1", .stream_name = "RT5640 PCM", .codec_name = "rt5640.0-001c", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rt5640-aif1", - .init = rk29_rt3261_init, + .init = rk29_rt5640_init, .ops = &rk29_ops, }, { .name = "RT5640 I2S2", .stream_name = "RT5640 PCM", .codec_name = "rt5640.0-001c", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "rt5640-aif2", - .ops = &rt3261_voice_ops, + .ops = &rt5640_voice_ops, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_rt5640_snd_card = { .name = "RK_RT5640", .dai_link = rk29_dai, .num_links = 2, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_rt5640_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_rt5640_snd_card; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + card->dev = &pdev->dev; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } + ret = snd_soc_register_card(card); - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); - platform_device_put(rk29_snd_device); - return ret; - } - - return ret; + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_rt5640_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_rt5640_of_match[] = { + { .compatible = "rockchip-rt5640", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_rt5640_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_rt5640_audio_driver = { + .driver = { + .name = "rockchip-rt5640", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_rt5640_of_match), + }, + .probe = rockchip_rt5640_audio_probe, + .remove = rockchip_rt5640_audio_remove, +}; + +module_platform_driver(rockchip_rt5640_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_wm8900.c b/sound/soc/rockchip/rk_wm8900.c index 68f60a360b2d..b825771e1795 100755 --- a/sound/soc/rockchip/rk_wm8900.c +++ b/sound/soc/rockchip/rk_wm8900.c @@ -13,13 +13,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include + #include "../codecs/wm8900.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -35,13 +35,8 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; -#else - struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; -#endif unsigned int pll_out = 0; int div_bclk,div_mclk; int ret; @@ -53,11 +48,8 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, #define HW_PARAMS_FLAG_EQVOL_OFF 0x22 if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF)) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent -#else - ret = codec_dai->ops->hw_params(substream, params, codec_dai); //by Vincent -#endif + DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); } else @@ -169,7 +161,6 @@ static const struct snd_soc_dapm_route audio_map[]= { /* * Logic for a wm8900 as connected on a rockchip board. */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) static int rk29_wm8900_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; @@ -193,108 +184,72 @@ static int rk29_wm8900_init(struct snd_soc_pcm_runtime *rtd) return 0; } -#else -static int rk29_wm8900_init(struct snd_soc_codec *codec) -{ - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - - /* Add specific widgets */ - snd_soc_dapm_new_controls(codec, wm8900_dapm_widgets, - ARRAY_SIZE(wm8900_dapm_widgets)); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - /* Set up specific audio path audio_mapnects */ - snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - snd_soc_dapm_nc_pin(codec, "HP_L"); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - snd_soc_dapm_nc_pin(codec, "HP_R"); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - snd_soc_dapm_sync(codec); - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - return 0; -} -#endif static struct snd_soc_ops rk29_ops = { .hw_params = rk29_hw_params, }; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) static struct snd_soc_dai_link rk29_dai = { .name = "WM8900", .stream_name = "WM8900 PCM", .codec_name = "WM8900.0-001a", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "WM8900 HiFi", .init = rk29_wm8900_init, .ops = &rk29_ops, }; -#else -static struct snd_soc_dai_link rk29_dai = { - .name = "WM8900", - .stream_name = "WM8900 PCM", - .cpu_dai = &rk29_i2s_dai[0], - .codec_dai = &wm8900_dai, - .init = rk29_wm8900_init, - .ops = &rk29_ops, -}; -#endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_wm8900_snd_card = { .name = "RK_WM8900", .dai_link = &rk29_dai, .num_links = 1, }; -#else -static struct snd_soc_card snd_soc_card_rk29 = { - .name = "RK_WM8900", - .platform = &rk29_soc_platform, - .dai_link = &rk29_dai, - .num_links = 1, -}; +static int rockchip_wm8900_audio_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card = &rockchip_wm8900_snd_card; -static struct snd_soc_card rk29_snd_devdata = { - .card = &snd_soc_card_rk29, - .codec_dev = &soc_codec_dev_wm8900, -}; -#endif + card->dev = &pdev->dev; -static struct platform_device *rk29_snd_device; + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); -static int __init audio_card_init(void) -{ - int ret =0; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - DBG("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); -#else - platform_set_drvdata(rk29_snd_device, &rk29_snd_devdata); - rk29_snd_devdata.dev = &rk29_snd_device->dev; -#endif - ret = platform_device_add(rk29_snd_device); - if (ret) { - DBG("platform device add failed\n"); - platform_device_put(rk29_snd_device); - } return ret; } -static void __exit audio_card_exit(void) +static int rockchip_wm8900_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_wm8900_of_match[] = { + { .compatible = "rockchip-wm8900", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_wm8900_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_wm8900_audio_driver = { + .driver = { + .name = "rockchip-wm8900", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_wm8900_of_match), + }, + .probe = rockchip_wm8900_audio_probe, + .remove = rockchip_wm8900_audio_remove, +}; + +module_platform_driver(rockchip_wm8900_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_wm8988.c b/sound/soc/rockchip/rk_wm8988.c index dadc25340a67..ad322664babc 100755 --- a/sound/soc/rockchip/rk_wm8988.c +++ b/sound/soc/rockchip/rk_wm8988.c @@ -13,19 +13,17 @@ #include #include +#include +#include #include #include #include #include -#include -#include -#include + #include "../codecs/wm8988.h" #include "rk_pcm.h" #include "rk29_i2s.h" -#include - #if 0 #define DBG(x...) printk(KERN_INFO x) #else @@ -138,52 +136,63 @@ static struct snd_soc_dai_link rk29_dai = { .name = "WM8988", .stream_name = "WM8988 PCM", .codec_name = "WM8988.0-001a", - .platform_name = "rockchip-audio", - .cpu_dai_name = "rk_i2s.0", + .platform_name = "rockchip-pcm", + .cpu_dai_name = "rockchip-i2s.0", .codec_dai_name = "WM8988 HiFi", .init = rk29_wm8988_init, .ops = &rk29_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_wm8988_snd_card = { .name = "RK_WM8988", .dai_link = &rk29_dai, .num_links = 1, }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_wm8988_audio_probe(struct platform_device *pdev) { - int ret =0; - - //rk29_speaker = rk29_speaker_init(RK29_PIN6_PB6, GPIO_HIGH, 2, (200*1000*1000)); + int ret; + struct snd_soc_card *card = &rockchip_wm8988_snd_card; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - DBG("platform device allocation failed\n"); - ret = -ENOMEM; - return ret; - } - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - DBG("platform device add failed\n"); - platform_device_put(rk29_snd_device); - return ret; - } - - return ret; + card->dev = &pdev->dev; + + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + + return ret; } -static void __exit audio_card_exit(void) + +static int rockchip_wm8988_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); - //rk29_speaker_deinit(rk29_speaker); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_wm8988_of_match[] = { + { .compatible = "rockchip-wm8988", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_wm8988_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_wm8988_audio_driver = { + .driver = { + .name = "rockchip-wm8988", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_wm8988_of_match), + }, + .probe = rockchip_wm8988_audio_probe, + .remove = rockchip_wm8988_audio_remove, +}; + +module_platform_driver(rockchip_wm8988_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); diff --git a/sound/soc/rockchip/rk_wm8994.c b/sound/soc/rockchip/rk_wm8994.c index df0a8e65c17a..ac05d9b5e23a 100755 --- a/sound/soc/rockchip/rk_wm8994.c +++ b/sound/soc/rockchip/rk_wm8994.c @@ -14,12 +14,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include + #include "../codecs/wm8994.h" #include "rk_pcm.h" #include "rk29_i2s.h" @@ -380,11 +381,11 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "WM8994 I2S1", .stream_name = "WM8994 PCM", .codec_name = "wm8994-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "wm8994-aif1", .ops = &rk29_aif1_ops, @@ -394,56 +395,67 @@ static struct snd_soc_dai_link rk29_dai[] = { .name = "WM8994 I2S2", .stream_name = "WM8994 PCM", .codec_name = "wm8994-codec", - .platform_name = "rockchip-audio", + .platform_name = "rockchip-pcm", #if defined(CONFIG_SND_RK_SOC_I2S_8CH) - .cpu_dai_name = "rk_i2s.0", + .cpu_dai_name = "rockchip-i2s.0", #elif defined(CONFIG_SND_RK_SOC_I2S_2CH) - .cpu_dai_name = "rk_i2s.1", + .cpu_dai_name = "rockchip-i2s.1", #endif .codec_dai_name = "wm8994-aif2", .ops = &rk29_aif2_ops, }, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card rockchip_wm8994_snd_card = { .name = "RK_WM8994", .dai_link = rk29_dai, .num_links = ARRAY_SIZE(rk29_dai), }; -static struct platform_device *rk29_snd_device; - -static int __init audio_card_init(void) +static int rockchip_wm8994_audio_probe(struct platform_device *pdev) { - int ret =0; + int ret; + struct snd_soc_card *card = &rockchip_wm8994_snd_card; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + card->dev = &pdev->dev; - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - printk("platform device allocation failed\n"); - return -ENOMEM; - } - - platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29); - ret = platform_device_add(rk29_snd_device); - if (ret) { - printk("platform device add failed\n"); - // snd_soc_unregister_dai(&rk29_snd_device->dev); - platform_device_put(rk29_snd_device); - return ret; - } - - return ret; + ret = snd_soc_register_card(card); + + if (ret) + printk("%s() register card failed:%d\n", __FUNCTION__, ret); + + return ret; } -static void __exit audio_card_exit(void) +static int rockchip_wm8994_audio_remove(struct platform_device *pdev) { - platform_device_unregister(rk29_snd_device); + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; } -module_init(audio_card_init); -module_exit(audio_card_exit); +#ifdef CONFIG_OF +static const struct of_device_id rockchip_wm8994_of_match[] = { + { .compatible = "rockchip-wm8994", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_wm8994_of_match); +#endif /* CONFIG_OF */ + +static struct platform_driver rockchip_wm8994_audio_driver = { + .driver = { + .name = "rockchip-wm8994", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rockchip_wm8994_of_match), + }, + .probe = rockchip_wm8994_audio_probe, + .remove = rockchip_wm8994_audio_remove, +}; + +module_platform_driver(rockchip_wm8994_audio_driver); + /* Module information */ MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");