};
+ i2s0_gpio: i2s0-gpio {
+ rockchip,pins = <FUNC_TO_GPIO(I2S0_MCLK)>,
+ <FUNC_TO_GPIO(I2S0_SCLK)>,
+ <FUNC_TO_GPIO(I2S0_LRCKRX)>,
+ <FUNC_TO_GPIO(I2S0_LRCKTX)>,
+ <FUNC_TO_GPIO(I2S0_SDO)>,
+ <FUNC_TO_GPIO(I2S0_SDI)>;
+ rockchip,drive = <VALUE_DRV_DEFAULT>;
+ };
};
gpio2_lcdc1 {
status = "disabled";
};
+ spdif: rockchip-spdif@0x1011e000 {
+ compatible = "rockchip-spdif";
+ reg = <0x1011e000 0x2000>;
+ clocks = <&clk_spdif>;
+ interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+ dmas = <&pdma0 8>;
+ #dma-cells = <1>;
+ dma-names = "tx";
+ pinctrl-names = "default";
+ pinctrl-0 = <&spdif_tx>;
+ };
+
+ i2s1: rockchip-i2s@0x1011a000 {
+ compatible = "rockchip-i2s";
+ reg = <0x1011a000 0x2000>;
+ i2s-id = <1>;
+ clocks = <&clk_i2s>;
+ interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+ dmas = <&pdma0 6>,
+ <&pdma0 7>;
+ #dma-cells = <2>;
+ dma-names = "tx", "rx";
+ pinctrl-names = "default", "sleep";
+ pinctrl-0 = <&i2s0_mclk &i2s0_sclk &i2s0_lrckrx &i2s0_lrcktx &i2s0_sdi &i2s0_sdo>;
+ pinctrl-1 = <&i2s0_gpio>;
+ };
+
pwm0: pwm@20030000{
compatible = "rockchip,pwm";
reg = <0x20030000 0x10>;
CONFIG_SND=y
CONFIG_SND_USB_AUDIO=y
CONFIG_SND_SOC=y
+CONFIG_SND_RK_SOC=y
+# CONFIG_SND_RK_SOC_I2S_8CH is not set
+CONFIG_SND_RK_SOC_I2S_2CH=y
+CONFIG_SND_I2S_DMA_EVENT_STATIC=y
+CONFIG_SND_RK_SOC_RT5631=y
+CONFIG_SND_RK_CODEC_SOC_SLAVE=y
CONFIG_HID_BATTERY_STRENGTH=y
CONFIG_HIDRAW=y
CONFIG_UHID=y
}
#if 0
-static void es8323_codec_set_spk(bool on)
+void es8323_codec_set_spk(bool on)
{
on_off_ext_amp(on);
}
mdelay(100);
}
-/*
-#define I2C_CLK_NAME GPIO0B0_I2S8CHCLK_NAME
-#define I2C_CLK_GPIO_MODE GPIO0B_GPIO0B0
-#define I2C_GPIO_OUTPUT GPIO_LOW
-#define I2C_CLK_CLK_MODE GPIO0B_I2S_8CH_CLK
-#define I2C_CLK_GPIO RK30_PIN0_PB0
-
-#define I2C_MCLK_NAME GPIO0B1_I2S8CHSCLK_NAME
-#define I2C_MCLK_GPIO_MODE GPIO0B_GPIO0B1
-#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)
{
-#if 0
- rk30_mux_api_set(I2C_CLK_NAME,I2C_CLK_GPIO_MODE);
- if (gpio_request(I2C_CLK_GPIO, NULL)) {
- printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
- return -1;
- }
-
- gpio_direction_output(I2C_CLK_GPIO,I2C_GPIO_OUTPUT);
-
- rk30_mux_api_set(I2C_MCLK_NAME,I2C_MCLK_GPIO_MODE);
- if (gpio_request(I2C_MCLK_GPIO, NULL)) {
- printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
- return -1;
- }
-
- gpio_direction_output(I2C_MCLK_GPIO,I2C_MGPIO_OUTPUT);
-#endif
- /* 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);*/
-
-#if 0
- iomux_set(GPIO1_C2);
- gpio_direction_input(RK30_PIN1_PC2);
- gpio_pull_updown(RK30_PIN1_PC2, PullDisable);
-
- iomux_set(GPIO1_C3);
- gpio_direction_input(RK30_PIN1_PC3);
- gpio_pull_updown(RK30_PIN1_PC3, PullDisable);
-
- iomux_set(GPIO1_C4);
- gpio_direction_input(RK30_PIN1_PC4);
- gpio_pull_updown(RK30_PIN1_PC4, PullDisable);
-
- iomux_set(GPIO1_C5);
- gpio_direction_input(RK30_PIN1_PC5);
- gpio_pull_updown(RK30_PIN1_PC5, PullDisable);
-#endif
-
return 0;
}
static int es8323_i2c_resume(struct i2c_client *client)
{
-#if 0
- gpio_free(I2C_MCLK_GPIO);
- gpio_free(I2C_CLK_GPIO);
-
- rk30_mux_api_set(I2C_MCLK_NAME,I2C_MCLK_CLK_MODE);
- rk30_mux_api_set(I2C_CLK_NAME,I2C_CLK_CLK_MODE);
-#endif
-
- /* gpio_free(RK30_PIN1_PC1);
- iomux_set(I2S0_SCLK);*/
-
return 0;
}
static void __exit es8323_exit(void)
{
-
-// if(0 == tcsi_get_value(TCSI_CODEC_ES8323))
-// return;
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
i2c_del_driver(&es8323_i2c_driver);
#endif
{0x84c, 0x3c}, //MIXINL from MIXMUX volume 0dB(bit 3-5)
{0x848, 0x1f}, //MIXINL power down and mute, MININL No selecting, MICMUX from BST_L
{0x840, 0x99}, //BST_L power down, mute, and Single-Ended(bit 6), volume 0(bit 5)
- {0x83c, 0x7c}, //power down
+ {0x83c, 0x3c}, //power down
};
#define RK616_CODEC_CAPTURE_POWER_DOWN_LIST_LEN ARRAY_SIZE(capture_power_down_list)
}
}
-static void rt3261_codec_set_spk(bool on)
+void rt3261_codec_set_spk(bool on)
{
struct snd_soc_codec *codec = rt3261_codec;
DBG("%s: %d\n", __func__, on);
char *widget_name, char *path_name);
int rt3261_headset_mic_detect(int jack_insert);
-static void rt3261_codec_set_spk(bool on);
+void rt3261_codec_set_spk(bool on);
#endif /* __RT3261_H__ */
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = w->codec;
- unsigned int val, mask;
switch (event) {
case SND_SOC_DAPM_POST_PMU:
+++ /dev/null
-/*
- * ALSA SoC SPDIF DIR (Digital Interface Reciever) driver
- *
- * Based on ALSA SoC SPDIF DIT driver
- *
- * This driver is used by controllers which can operate in DIR (SPDI/F) where
- * no codec is needed. This file provides stub codec that can be used
- * in these configurations. SPEAr SPDIF IN Audio controller uses this driver.
- *
- * Author: Vipin Kumar, <vipin.kumar@st.com>
- * Copyright: (C) 2012 ST Microelectronics
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/slab.h>
-#include <sound/soc.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-
-#define STUB_RATES SNDRV_PCM_RATE_8000_192000
-#define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
- SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
-
-static struct snd_soc_codec_driver soc_codec_spdif_dir;
-
-static struct snd_soc_dai_driver dir_stub_dai = {
- .name = "dir-hifi",
- .capture = {
- .stream_name = "Capture",
- .channels_min = 1,
- .channels_max = 384,
- .rates = STUB_RATES,
- .formats = STUB_FORMATS,
- },
-};
-
-static int spdif_dir_probe(struct platform_device *pdev)
-{
- return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dir,
- &dir_stub_dai, 1);
-}
-
-static int spdif_dir_remove(struct platform_device *pdev)
-{
- snd_soc_unregister_codec(&pdev->dev);
- return 0;
-}
-
-static struct platform_driver spdif_dir_driver = {
- .probe = spdif_dir_probe,
- .remove = spdif_dir_remove,
- .driver = {
- .name = "spdif-dir",
- .owner = THIS_MODULE,
- },
-};
-
-module_platform_driver(spdif_dir_driver);
-
-MODULE_DESCRIPTION("ASoC SPDIF DIR driver");
-MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>");
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * ALSA SoC SPDIF DIT driver
- *
- * This driver is used by controllers which can operate in DIT (SPDI/F) where
- * no codec is needed. This file provides stub codec that can be used
- * in these configurations. TI DaVinci Audio controller uses this driver.
- *
- * Author: Steve Chen, <schen@mvista.com>
- * Copyright: (C) 2009 MontaVista Software, Inc., <source@mvista.com>
- * Copyright: (C) 2009 Texas Instruments, India
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/slab.h>
-#include <sound/soc.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-
-#define DRV_NAME "spdif-dit"
-
-#define STUB_RATES SNDRV_PCM_RATE_8000_96000
-#define STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE
-
-
-static struct snd_soc_codec_driver soc_codec_spdif_dit;
-
-static struct snd_soc_dai_driver dit_stub_dai = {
- .name = "dit-hifi",
- .playback = {
- .stream_name = "Playback",
- .channels_min = 1,
- .channels_max = 384,
- .rates = STUB_RATES,
- .formats = STUB_FORMATS,
- },
-};
-
-static int spdif_dit_probe(struct platform_device *pdev)
-{
- return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit,
- &dit_stub_dai, 1);
-}
-
-static int spdif_dit_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,
- },
-};
-
-module_platform_driver(spdif_dit_driver);
-
-MODULE_AUTHOR("Steve Chen <schen@mvista.com>");
-MODULE_DESCRIPTION("SPDIF dummy codec driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:" DRV_NAME);
config SND_RK_SOC
tristate "SoC Audio for the Rockchip System-on-Chip"
depends on SND_SOC
+ select SND_SOC_GENERIC_DMAENGINE_PCM
help
Say Y or M if you want to add support for codecs attached to
the ROCKCHIP IIS interface. You will also need
#include <sound/soc.h>
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#ifdef DEBUG
#define DBG(format, ...) \
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- DBG("Set cpu_dai master\n");
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- DBG("Set cpu_dai slave\n");
- #endif
- if (ret < 0)
- return ret;
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
pll_out = 256 * params_rate(params);
.name = "RK2928",
.stream_name = "RK2928",
.cpu_dai_name = "rockchip-i2s.0",
- .platform_name = "rockchip-pcm",
.codec_name = "rk2928-codec",
.codec_dai_name = "rk2928-codec",
.ops = &rk2928_dai_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
};
#include <mach/cru.h>
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
+++ /dev/null
-/*
- * rockchip-iis.h - ALSA IIS interface for the Rockchip rk28 SoC
- *
- * Driver for rockchip iis audio
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/version.h>
-
-#ifndef _ROCKCHIP_IIS_H
-#define _ROCKCHIP_IIS_H
-
-//I2S_TXCR
-
-#define PCM_2DATA (0<<18)
-#define PCM_4DATA (1<<18)
-#define PCM_6DATA (2<<18)
-#define PCM_8DATA (3<<18)
-
-#define CHANNEL_1_EN (0<<15)
-#define CHANNEL_2_EN (1<<15)
-#define CHANNEL_3_EN (2<<15)
-#define CHANNLE_4_EN (3<<15)
-#define TX_MODE_MASTER (0<<13)
-#define TX_MODE_SLAVE (1<<13)
-#define RESET_TX (1<<17)
-#define RESET_RX (1<<16)
-#define I2S_DMA_REQ1_DISABLE (1<<6)
-#define I2S_DMA_REQ1_ENABLE (0)
-#define I2S_DMA_REQ2_DISABLE (1<<5)
-#define I2S_DMA_REQ2_ENABLE (0)
-#define I2S_DMA_REQ1_TX_ENABLE (0)
-#define I2S_DMA_REQ1_RX_ENABLE (1<<4)
-#define I2S_DMA_REQ2_TX_ENABLE (0)
-#define I2S_DMA_REQ2_RX_ENABLE (1<<3)
-#define TX_START (1<<1)
-#define RX_START (1)
-
-
-
-//I2S_TXCTL I2S_RXCTL
-#define CLEAR_RXFIFO (1<<24)
-#define TRAN_DEVICES0 (0)
-#define TRAN_DEVICES1 (1<<18)
-#define TRAN_DEVICES2 (2<<18)
-#define TRAN_DEVICES3 (3<<18)
-#define OVERSAMPLING_RATE_32FS (0)
-#define OVERSAMPLING_RATE_64FS (1<<16)
-#define OVERSAMPLING_RATE_128FS (2<<16)
-#define SCK_RATE2 (0x02<<8)
-#define SCK_RATE4 (0x04<<8)
-#define SCK_RATE8 (0x08<<8)
-#define SAMPLE_DATA_8bit (0)
-#define SAMPLE_DATA_16bit (1<<4)
-#define SAMPLE_DATA_MASK (3<<4)
-#define MONO_MODE (1<<3)
-#define STEREO_MODE (0)
-#define I2S_MODE (0)
-#define LEFT_JUSTIFIED (1<<1)
-#define RIGHT_JUSTIFIED (2<<1)
-#define IISMOD_SDF_MASK (3<<1)
-#define MASTER_MODE (1)
-#define SLAVE_MODE (0)
-
-//I2S_FIFOSTS
-#define TX_HALF_FULL (1<<18)
-#define RX_HALF_FULL (1<<16)
-
-/* Clock dividers */
-#define ROCKCHIP_DIV_MCLK 0
-#define ROCKCHIP_DIV_BCLK 1
-#define ROCKCHIP_DIV_PRESCALER 2
-
-
-/* I2S_TXCR */
-#define I2S_RSTL_SCLK(c) ((c&0x3F)<<26)
-#define I2S_RSTR_SCLK(c) ((c&0x3F)<<20)
-
-#define I2S_PCM_2DATA (0<<18)
-#define I2S_PCM_4DATA (1<<18)
-#define I2S_PCM_6DATA (2<<18)
-#define I2S_PCM_8DATA (3<<18)
-#define I2S_PCM_DATA_MASK (3<<18)
-
-#define I2S_CSR_CH2 (0<<15)
-#define I2S_CSR_CH4 (1<<15)
-#define I2S_CRS_CH6 (2<<15)
-#define I2S_CRS_CH8 (3<<15)
-#define I2S_CRS_CH_MASK (3<<15)
-
-#define I2S_HWT_16BIT (0<<14)
-#define I2S_HWT_32BIT (1<<14)
-
-#ifdef CONFIG_ARCH_RK29
- #define I2S_MASTER_MODE (0<<13)
- #define I2S_SLAVE_MODE (1<<13)
- #define I2S_MODE_MASK (1<<13)
-#endif
-
-#define I2S_JUSTIFIED_RIGHT (0<<12)
-#define I2S_JUSTIFIED_LEFT (1<<12)
-
-#define I2S_FIRST_BIT_MSB (0<<11)
-#define I2S_FIRST_BIT_LSB (1<<11)
-
-#define I2S_BUS_MODE_NOR (0<<9)
-#define I2S_BUS_MODE_LSJM (1<<9)
-#define I2S_BUS_MODE_RSJM (2<<9)
-#define I2S_BUS_MODE_MASK (3<<9)
-
-#define I2S_PCM_NO_DELAY (0<<7)
-#define I2S_PCM_DELAY_1MODE (1<<7)
-#define I2S_PCM_DELAY_2MODE (2<<7)
-#define I2S_PCM_DELAY_3MODE (3<<7)
-#define I2S_PCM_DELAY_MASK (3<<7)
-
-#define I2S_TX_LRCK_OUT_BT_DISABLE (0<<6)
-#define I2S_TX_LRCK_OUT_BT_ENABLE (1<<6)
-
-#define I2S_TX_LRCK_OUT_I2S (0<<5)
-#define I2S_TX_LRCK_OUT_PCM (1<<5)
-
-#define I2S_DATA_WIDTH(w) ((w&0x1F)<<0)
-
-/* */
-
-
-/* I2S_TXCKR */
-#ifdef CONFIG_ARCH_RK29
- #define I2S_TSP_POSEDGE (0<<25)
- #define I2S_TSP_NEGEDGE (1<<25)
- #define I2S_TLP_NORMAL (0<<24)
- #define I2S_TLP_OPPSITE (1<<24)
-
- #define I2S_MCLK_DIV(x) ((0xFF&x)<<16)
- #define I2S_MCLK_DIV_MASK ((0xFF)<<16)
-
- #define I2S_TSD_FIXED (0<<12)
- #define I2S_TSD_CHANGED (1<<12)
-
- #define I2S_TX_LRCK_NO_DELAY (0<<10)
- #define I2S_TX_LRCK_DELAY_ONE (1<<10)
- #define I2S_TX_LRCK_DELAY_TWO (2<<10)
- #define I2S_TX_LRCK_DELAY_THREE (3<<10)
- #define I2S_TX_LRCK_DELAY_MASK (3<<10)
-
- #define I2S_TX_SCLK_DIV(x) (x&0x3FF)
- #define I2S_TX_SCLK_DIV_MASK (0x3FF);
-#else
-//I2S_CKR
- #define I2S_MASTER_MODE (0<<27)
- #define I2S_SLAVE_MODE (1<<27)
- #define I2S_MODE_MASK (1<<27)
-
- #define I2S_BCLK_POSEDGE (0<<26)//sclk polarity invert??
- #define I2S_BCLK_NEGEDGE (1<<26)
-
- #define I2S_RX_LRCK_POSEDGE (0<<25)//LRCK polarity invert??
- #define I2S_RX_LRCK_NEGEDGE (1<<25)
-
- #define I2S_TX_LRCK_POSEDGE (0<<24)
- #define I2S_TX_LRCK_NEGEDGE (1<<24)
-
- #define I2S_MCLK_DIV(x) ((0xFF&x)<<16)
- #define I2S_MCLK_DIV_MASK ((0xFF)<<16)
-
- #define I2S_RX_SCLK_DIV(x) ((x&0xFF)<<8)
- #define I2S_RX_SCLK_DIV_MASK ((0xFF)<<8)
-
- #define I2S_TX_SCLK_DIV(x) (x&0xFF)
- #define I2S_TX_SCLK_DIV_MASK (0xFF)
-#endif
-
-/* I2S_DMACR */
-#define I2S_RECE_DMA_DISABLE (0<<24)
-#define I2S_RECE_DMA_ENABLE (1<<24)
-#define I2S_DMARDL(x) ((x&0x1f)<<16)
-
-#define I2S_TRAN_DMA_DISABLE (0<<8)
-#define I2S_TRAN_DMA_ENABLE (1<<8)
-#define I2S_DMATDL(x) ((x&0x1f)<<0)
-
-/* I2S_INTCR */
-#define I2S_RXOV_INT_DISABLE (0<<17)
-#define I2S_RXOV_INT_ENABLE (1<<17)
-#define I2S_RXFU_INT_DISABLE (0<<16)
-#define I2S_RXFU_INT_ENABLE (1<<16)
-
-#define I2S_TXUND_INT_DISABLE (0<<1)
-#define I2S_TXUND_INT_ENABLE (1<<1)
-#define I2S_TXEMP_INT_DISABLE (0<<0)
-#define I2S_TXEMP_INT_ENABLE (1<<0)
-
-/* I2S_XFER */
-#define I2S_RX_TRAN_STOP (0<<1)
-#define I2S_RX_TRAN_START (1<<1)
-#define I2S_TX_TRAN_STOP (0<<0)
-#define I2S_TX_TRAN_START (1<<0)
-
-//I2S_CLR
-#define I2S_RX_CLEAR (1<<1)
-#define I2S_TX_CLEAR 1
-
-
-#ifdef CONFIG_ARCH_RK29
-#define I2S_TXR_BUFF 0x20
-#define I2S_RXR_BUFF 0x24
-//I2S Registers
-typedef volatile struct tagIIS_STRUCT
-{
- unsigned int I2S_TXCR;
- unsigned int I2S_RXCR;
- unsigned int I2S_TXCKR;
- unsigned int I2S_RXCKR;
- unsigned int I2S_FIFOLR;
- unsigned int I2S_DMACR;
- unsigned int I2S_INTCR;
- unsigned int I2S_INTSR;
- unsigned int I2S_TXDR;
- unsigned int I2S_RXDR;
- unsigned int I2S_XFER;
- unsigned int I2S_TXRST;
- unsigned int I2S_RXRST;
-}I2S_REG,*pI2S_REG;
-#else
-#define I2S_TXR_BUFF 0x24
-#define I2S_RXR_BUFF 0x28
-typedef volatile struct tagIIS_STRUCT
-{
- unsigned int I2S_TXCR;//0xF 0
- unsigned int I2S_RXCR;//0xF 4
- unsigned int I2S_CKR;//0x3F 8
- unsigned int I2S_FIFOLR;//c
- unsigned int I2S_DMACR;//0x001F0110 10
- unsigned int I2S_INTCR;//0x01F00000 14
- unsigned int I2S_INTSR;//0x00 18
- unsigned int I2S_XFER;//0x00000003 1c
- unsigned int I2S_CLR;//20
- unsigned int I2S_TXDR;//24
- unsigned int I2S_RXDR;
-}I2S_REG,*pI2S_REG;
-#endif
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
-extern struct snd_soc_dai_driver rk29_i2s_dai[];
-#else
-extern struct snd_soc_dai rk29_i2s_dai[];
-#endif
-
-#ifdef CONFIG_SND_SOC_RT5631
-extern struct delayed_work rt5631_delay_cap; //bard 7-16
-#endif
-
-#endif /* _ROCKCHIP_IIS_H */
-
/*
- * rk29_i2s.c -- ALSA SoC ROCKCHIP IIS Audio Layer Platform driver
+ * rk30_i2s.c -- ALSA SoC ROCKCHIP IIS Audio Layer Platform driver
*
* Driver for rockchip iis audio
*
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/version.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
#include <asm/dma.h>
#include <sound/core.h>
#include <sound/pcm_params.h>
#include <sound/initval.h>
#include <sound/soc.h>
+#include <sound/dmaengine_pcm.h>
#include <asm/io.h>
-#include <mach/board.h>
-#include <mach/hardware.h>
-#include <mach/io.h>
-#include <mach/gpio.h>
-#include <mach/iomux.h>
-#include <mach/dma-pl330.h>
#include <linux/spinlock.h>
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
-#define ANDROID_REC
#if 0
#define I2S_DBG(x...) printk(KERN_INFO x)
#else
#define pheadi2s ((pI2S_REG)(i2s->regs))
-#define MAX_I2S 3
+#define MAX_I2S 3
-struct rk29_i2s_info {
- struct device *dev;
+struct rk30_i2s_info {
void __iomem *regs;
-
- u32 feature;
- struct clk *iis_clk;
- struct clk *iis_pclk;
+ struct clk *i2s_clk;
- unsigned char master;
+ struct snd_dmaengine_dai_dma_data capture_dma_data;
+ struct snd_dmaengine_dai_dma_data playback_dma_data;
- struct rockchip_pcm_dma_params *dma_playback;
- struct rockchip_pcm_dma_params *dma_capture;
+ bool i2s_tx_status;//active = true;
+ bool i2s_rx_status;
- u32 suspend_iismod;
- u32 suspend_iiscon;
- u32 suspend_iispsr;
-
- bool i2s_tx_status;//active = true;
- bool i2s_rx_status;
spinlock_t spinlock_wr;//write read reg spin_lock
};
-static struct snd_soc_dai *rk_cpu_dai=NULL;
-static struct rk29_dma_client rk29_dma_client_out = {
- .name = "I2S PCM Stereo Out"
-};
-
-static struct rk29_dma_client rk29_dma_client_in = {
- .name = "I2S PCM Stereo In"
-};
+#if defined (CONFIG_RK_HDMI) && defined (CONFIG_SND_RK_SOC_HDMI_I2S)
+extern int hdmi_get_hotplug(void);
+#endif
-static inline struct rk29_i2s_info *to_info(struct snd_soc_dai *cpu_dai)
+static inline struct rk30_i2s_info *to_info(struct snd_soc_dai *dai)
{
- return snd_soc_dai_get_drvdata(cpu_dai);
+ return snd_soc_dai_get_drvdata(dai);
}
-static struct rockchip_pcm_dma_params rk29_i2s_pcm_stereo_out[MAX_I2S];
-static struct rockchip_pcm_dma_params rk29_i2s_pcm_stereo_in[MAX_I2S];
-static struct rk29_i2s_info rk29_i2s[MAX_I2S];
-
-struct snd_soc_dai_driver rk29_i2s_dai[MAX_I2S];
-EXPORT_SYMBOL_GPL(rk29_i2s_dai);
-#if defined (CONFIG_RK_HDMI) && defined (CONFIG_SND_RK_SOC_HDMI_I2S)
-extern int hdmi_get_hotplug(void);
-#endif
/*
*Turn on or off the transmission path.
*/
-static void rockchip_snd_txctrl(struct rk29_i2s_info *i2s, int on)
+static void rockchip_snd_txctrl(struct rk30_i2s_info *i2s, int on)
{
- u32 opr,xfer,clr;
+ u32 opr, xfer, clr;
+
spin_lock(&i2s->spinlock_wr);
+
opr = readl(&(pheadi2s->I2S_DMACR));
xfer = readl(&(pheadi2s->I2S_XFER));
clr = readl(&(pheadi2s->I2S_CLR));
- if (on)
- {
- I2S_DBG("rockchip_snd_txctrl: on\n");
- if ((opr & I2S_TRAN_DMA_ENABLE) == 0)
- {
+
+ I2S_DBG("rockchip_snd_txctrl: %s\n", on ? "on" : "off");
+
+ if (on) {
+ if ((opr & I2S_TRAN_DMA_ENABLE) == 0) {
opr |= I2S_TRAN_DMA_ENABLE;
- writel(opr, &(pheadi2s->I2S_DMACR));
- }
- if ((xfer&I2S_TX_TRAN_START)==0 || (xfer&I2S_RX_TRAN_START)==0)
- {
+ writel(opr, &(pheadi2s->I2S_DMACR));
+ }
+
+ if ((xfer & I2S_TX_TRAN_START) == 0 || (xfer & I2S_RX_TRAN_START) == 0) {
xfer |= I2S_TX_TRAN_START;
xfer |= I2S_RX_TRAN_START;
writel(xfer, &(pheadi2s->I2S_XFER));
}
- i2s->i2s_tx_status = true;
+
+ i2s->i2s_tx_status = 1;
spin_unlock(&i2s->spinlock_wr);
- }
- else
- {
- //stop tx
- i2s->i2s_tx_status = false;
- I2S_DBG("rockchip_snd_txctrl: off\n");
- opr &= ~I2S_TRAN_DMA_ENABLE;
- writel(opr, &(pheadi2s->I2S_DMACR));
- if(!i2s->i2s_tx_status && !i2s->i2s_rx_status//sync stop i2s rx tx lcrk
+ } else { //stop tx
+ i2s->i2s_tx_status = 0;
+ opr &= ~I2S_TRAN_DMA_ENABLE;
+ writel(opr, &(pheadi2s->I2S_DMACR));
+
+ if (i2s->i2s_rx_status == 0//sync stop i2s rx tx lcrk
#if defined (CONFIG_RK_HDMI) && defined (CONFIG_SND_RK_SOC_HDMI_I2S)
- && hdmi_get_hotplug() == 0 //HDMI_HPD_REMOVED
-#endif
- )
- {
+ && hdmi_get_hotplug() == 0 //HDMI_HPD_REMOVED
+#endif
+ ) {
xfer &= ~I2S_TX_TRAN_START;
- xfer &= ~I2S_RX_TRAN_START;
+ xfer &= ~I2S_RX_TRAN_START;
writel(xfer, &(pheadi2s->I2S_XFER));
clr |= I2S_TX_CLEAR;
clr |= I2S_RX_CLEAR;
writel(clr, &(pheadi2s->I2S_CLR));
spin_unlock(&i2s->spinlock_wr);
udelay(1);
- I2S_DBG("rockchip_snd_txctrl: stop xfer\n");
- }
- else
+ I2S_DBG("rockchip_snd_txctrl: stop xfer\n");
+ } else
spin_unlock(&i2s->spinlock_wr);
}
}
-static void rockchip_snd_rxctrl(struct rk29_i2s_info *i2s, int on)
+static void rockchip_snd_rxctrl(struct rk30_i2s_info *i2s, int on)
{
- u32 opr,xfer,clr;
+ u32 opr, xfer, clr;
+
spin_lock(&i2s->spinlock_wr);
+
opr = readl(&(pheadi2s->I2S_DMACR));
xfer = readl(&(pheadi2s->I2S_XFER));
clr = readl(&(pheadi2s->I2S_CLR));
- if (on)
- {
- I2S_DBG("rockchip_snd_rxctrl: on\n");
- if ((opr & I2S_RECE_DMA_ENABLE) == 0)
- {
+
+ I2S_DBG("rockchip_snd_rxctrl: %s\n", on ? "on" : "off");
+
+ if (on) {
+ if ((opr & I2S_RECE_DMA_ENABLE) == 0) {
opr |= I2S_RECE_DMA_ENABLE;
- writel(opr, &(pheadi2s->I2S_DMACR));
+ writel(opr, &(pheadi2s->I2S_DMACR));
}
- if ((xfer&I2S_TX_TRAN_START)==0 || (xfer&I2S_RX_TRAN_START)==0)
- {
+
+ if ((xfer & I2S_TX_TRAN_START)==0 || (xfer & I2S_RX_TRAN_START) == 0) {
xfer |= I2S_RX_TRAN_START;
xfer |= I2S_TX_TRAN_START;
writel(xfer, &(pheadi2s->I2S_XFER));
}
- i2s->i2s_rx_status = true;
+
+ i2s->i2s_rx_status = 1;
spin_unlock(&i2s->spinlock_wr);
-#ifdef CONFIG_SND_SOC_RT5631
-//bard 7-16 s
- schedule_delayed_work(&rt5631_delay_cap,HZ/4);
-//bard 7-16 e
-#endif
- }
- else
- {
- i2s->i2s_rx_status = false;
- I2S_DBG("rockchip_snd_rxctrl: off\n");
+ } else {
+ i2s->i2s_rx_status = 0;
+
opr &= ~I2S_RECE_DMA_ENABLE;
- writel(opr, &(pheadi2s->I2S_DMACR));
- if(!i2s->i2s_tx_status && !i2s->i2s_rx_status //sync stop i2s rx tx lcrk
+ writel(opr, &(pheadi2s->I2S_DMACR));
+
+ if (i2s->i2s_tx_status == 0//sync stop i2s rx tx lcrk
#if defined (CONFIG_RK_HDMI) && defined (CONFIG_SND_RK_SOC_HDMI_I2S)
- && hdmi_get_hotplug() == 0 //HDMI_HPD_REMOVED
-#endif
- )
- {
+ && hdmi_get_hotplug() == 0 //HDMI_HPD_REMOVED
+#endif
+ ) {
xfer &= ~I2S_RX_TRAN_START;
- xfer &= ~I2S_TX_TRAN_START;
- writel(xfer, &(pheadi2s->I2S_XFER));
+ xfer &= ~I2S_TX_TRAN_START;
+ writel(xfer, &(pheadi2s->I2S_XFER));
clr |= I2S_RX_CLEAR;
clr |= I2S_TX_CLEAR;
writel(clr, &(pheadi2s->I2S_CLR));
spin_unlock(&i2s->spinlock_wr);
udelay(1);
- I2S_DBG("rockchip_snd_rxctrl: stop xfer\n");
- }
- else
+ I2S_DBG("rockchip_snd_rxctrl: stop xfer\n");
+ } else
spin_unlock(&i2s->spinlock_wr);
}
}
static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
unsigned int fmt)
{
- struct rk29_i2s_info *i2s = to_info(cpu_dai);
+ struct rk30_i2s_info *i2s = to_info(cpu_dai);
u32 tx_ctl,rx_ctl;
u32 iis_ckr_value;//clock generation register
-
+
I2S_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- spin_lock(&i2s->spinlock_wr);
+
+ spin_lock(&i2s->spinlock_wr);
+
tx_ctl = readl(&(pheadi2s->I2S_TXCR));
iis_ckr_value = readl(&(pheadi2s->I2S_CKR));
-
+
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
- case SND_SOC_DAIFMT_CBM_CFM:
- iis_ckr_value &= ~I2S_MODE_MASK;
- iis_ckr_value |= I2S_MASTER_MODE;
- break;
- case SND_SOC_DAIFMT_CBS_CFS:
- iis_ckr_value &= ~I2S_MODE_MASK;
- iis_ckr_value |= I2S_SLAVE_MODE;
- break;
- default:
- I2S_DBG("unknwon master/slave format\n");
- return -EINVAL;
- }
+ case SND_SOC_DAIFMT_CBM_CFM:
+ iis_ckr_value &= ~I2S_MODE_MASK;
+ iis_ckr_value |= I2S_SLAVE_MODE;
+ break;
+ case SND_SOC_DAIFMT_CBS_CFS:
+ iis_ckr_value &= ~I2S_MODE_MASK;
+ iis_ckr_value |= I2S_MASTER_MODE;
+ break;
+ default:
+ I2S_DBG("unknwon master/slave format\n");
+ return -EINVAL;
+ }
+
writel(iis_ckr_value, &(pheadi2s->I2S_CKR));
+
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
- case SND_SOC_DAIFMT_RIGHT_J:
- tx_ctl &= ~I2S_BUS_MODE_MASK; //I2S Bus Mode
- tx_ctl |= I2S_BUS_MODE_RSJM;
- break;
- case SND_SOC_DAIFMT_LEFT_J:
- tx_ctl &= ~I2S_BUS_MODE_MASK; //I2S Bus Mode
- tx_ctl |= I2S_BUS_MODE_LSJM;
- break;
- case SND_SOC_DAIFMT_I2S:
- tx_ctl &= ~I2S_BUS_MODE_MASK; //I2S Bus Mode
- tx_ctl |= I2S_BUS_MODE_NOR;
- break;
- default:
- I2S_DBG("Unknown data format\n");
- return -EINVAL;
+ case SND_SOC_DAIFMT_RIGHT_J:
+ tx_ctl &= ~I2S_BUS_MODE_MASK; //I2S Bus Mode
+ tx_ctl |= I2S_BUS_MODE_RSJM;
+ break;
+ case SND_SOC_DAIFMT_LEFT_J:
+ tx_ctl &= ~I2S_BUS_MODE_MASK; //I2S Bus Mode
+ tx_ctl |= I2S_BUS_MODE_LSJM;
+ break;
+ case SND_SOC_DAIFMT_I2S:
+ tx_ctl &= ~I2S_BUS_MODE_MASK; //I2S Bus Mode
+ tx_ctl |= I2S_BUS_MODE_NOR;
+ break;
+ default:
+ I2S_DBG("Unknown data format\n");
+ return -EINVAL;
}
+
I2S_DBG("Enter::%s----%d, I2S_TXCR=0x%X\n",__FUNCTION__,__LINE__,tx_ctl);
writel(tx_ctl, &(pheadi2s->I2S_TXCR));
rx_ctl = tx_ctl & 0x00007FFF;
writel(rx_ctl, &(pheadi2s->I2S_RXCR));
- spin_unlock(&i2s->spinlock_wr);
+
+ spin_unlock(&i2s->spinlock_wr);
return 0;
}
static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params, struct snd_soc_dai *socdai)
+ struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
- struct rk29_i2s_info *i2s = to_info(socdai);
+ struct rk30_i2s_info *i2s = to_info(dai);
u32 iismod;
u32 dmarc;
u32 iis_ckr_value;//clock generation register
- I2S_DBG("Enter %s, %d >>>>>>>>>>>\n", __func__, __LINE__);
+ I2S_DBG("Enter %s, %d \n", __func__, __LINE__);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- snd_soc_dai_set_dma_data(socdai, substream, i2s->dma_playback);
+ dai->playback_dma_data = &i2s->playback_dma_data;
else
- snd_soc_dai_set_dma_data(socdai, substream, i2s->dma_capture);
+ dai->capture_dma_data = &i2s->capture_dma_data;
+
+ spin_lock(&i2s->spinlock_wr);
/* Working copies of register */
- spin_lock(&i2s->spinlock_wr);
iismod = readl(&(pheadi2s->I2S_TXCR));
-
+
iismod &= (~((1<<5)-1));
switch (params_format(params)) {
- case SNDRV_PCM_FORMAT_S8:
- iismod |= SAMPLE_DATA_8bit;
- break;
- case SNDRV_PCM_FORMAT_S16_LE:
- iismod |= I2S_DATA_WIDTH(15);
- break;
- case SNDRV_PCM_FORMAT_S20_3LE:
- iismod |= I2S_DATA_WIDTH(19);
- break;
- case SNDRV_PCM_FORMAT_S24_LE:
- iismod |= I2S_DATA_WIDTH(23);
- break;
- case SNDRV_PCM_FORMAT_S32_LE:
- iismod |= I2S_DATA_WIDTH(31);
- break;
+ case SNDRV_PCM_FORMAT_S8:
+ iismod |= SAMPLE_DATA_8bit;
+ break;
+ case SNDRV_PCM_FORMAT_S16_LE:
+ iismod |= I2S_DATA_WIDTH(15);
+ break;
+ case SNDRV_PCM_FORMAT_S20_3LE:
+ iismod |= I2S_DATA_WIDTH(19);
+ break;
+ case SNDRV_PCM_FORMAT_S24_LE:
+ iismod |= I2S_DATA_WIDTH(23);
+ break;
+ case SNDRV_PCM_FORMAT_S32_LE:
+ iismod |= I2S_DATA_WIDTH(31);
+ break;
}
-
+
iis_ckr_value = readl(&(pheadi2s->I2S_CKR));
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+ #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
iis_ckr_value &= ~I2S_SLAVE_MODE;
#endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
iis_ckr_value |= I2S_SLAVE_MODE;
#endif
writel(iis_ckr_value, &(pheadi2s->I2S_CKR));
-
-// writel((16<<24) |(16<<18)|(16<<12)|(16<<6)|16, &(pheadi2s->I2S_FIFOLR));
+
dmarc = readl(&(pheadi2s->I2S_DMACR));
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
dmarc = ((dmarc & 0xFE00FFFF) | 16<<16);
writel(dmarc, &(pheadi2s->I2S_DMACR));
- I2S_DBG("Enter %s, %d I2S_TXCR=0x%08X\n", __func__, __LINE__, iismod);
+
+ I2S_DBG("Enter %s, %d I2S_TXCR=0x%08X\n", __func__, __LINE__, iismod);
writel(iismod, &(pheadi2s->I2S_TXCR));
iismod = iismod & 0x00007FFF;
- writel(iismod, &(pheadi2s->I2S_RXCR));
- spin_unlock(&i2s->spinlock_wr);
+ writel(iismod, &(pheadi2s->I2S_RXCR));
+
+ spin_unlock(&i2s->spinlock_wr);
+
return 0;
}
static int rockchip_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai)
-{
+{
+ struct rk30_i2s_info *i2s = to_info(dai);
int ret = 0;
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct rk29_i2s_info *i2s = to_info(rtd->cpu_dai);
I2S_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
switch (cmd) {
- case SNDRV_PCM_TRIGGER_START:
- case SNDRV_PCM_TRIGGER_RESUME:
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- rockchip_snd_rxctrl(i2s, 1);
- else
- rockchip_snd_txctrl(i2s, 1);
- break;
-
- case SNDRV_PCM_TRIGGER_SUSPEND:
- case SNDRV_PCM_TRIGGER_STOP:
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- rockchip_snd_rxctrl(i2s, 0);
- else
- rockchip_snd_txctrl(i2s, 0);
- break;
- default:
- ret = -EINVAL;
- break;
+ case SNDRV_PCM_TRIGGER_START:
+ case SNDRV_PCM_TRIGGER_RESUME:
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+ rockchip_snd_rxctrl(i2s, 1);
+ else
+ rockchip_snd_txctrl(i2s, 1);
+ break;
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+ case SNDRV_PCM_TRIGGER_STOP:
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+ rockchip_snd_rxctrl(i2s, 0);
+ else
+ rockchip_snd_txctrl(i2s, 0);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
}
return ret;
static int rockchip_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
int clk_id, unsigned int freq, int dir)
{
- struct rk29_i2s_info *i2s;
+ struct rk30_i2s_info *i2s = to_info(cpu_dai);
- i2s = to_info(cpu_dai);
-
I2S_DBG("Enter:%s, %d, i2s=0x%p, freq=%d\n", __FUNCTION__, __LINE__, i2s, freq);
+
/*add scu clk source and enable clk*/
- clk_set_rate(i2s->iis_clk, freq);
+ clk_set_rate(i2s->i2s_clk, freq);
return 0;
}
static int rockchip_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai,
int div_id, int div)
{
- struct rk29_i2s_info *i2s;
+ struct rk30_i2s_info *i2s;
u32 reg;
i2s = to_info(cpu_dai);
-
+
+ spin_lock(&i2s->spinlock_wr);
+
//stereo mode MCLK/SCK=4
- spin_lock(&i2s->spinlock_wr);
reg = readl(&(pheadi2s->I2S_CKR));
I2S_DBG("Enter:%s, %d, div_id=0x%08X, div=0x%08X\n", __FUNCTION__, __LINE__, div_id, div);
//when i2s in master mode ,must set codec pll div
switch (div_id) {
- case ROCKCHIP_DIV_BCLK:
- reg &= ~I2S_TX_SCLK_DIV_MASK;
- reg |= I2S_TX_SCLK_DIV(div);
- reg &= ~I2S_RX_SCLK_DIV_MASK;
- reg |= I2S_RX_SCLK_DIV(div);
- break;
- case ROCKCHIP_DIV_MCLK:
- reg &= ~I2S_MCLK_DIV_MASK;
- reg |= I2S_MCLK_DIV(div);
- break;
- case ROCKCHIP_DIV_PRESCALER:
- break;
- default:
- return -EINVAL;
+ case ROCKCHIP_DIV_BCLK:
+ reg &= ~I2S_TX_SCLK_DIV_MASK;
+ reg |= I2S_TX_SCLK_DIV(div);
+ reg &= ~I2S_RX_SCLK_DIV_MASK;
+ reg |= I2S_RX_SCLK_DIV(div);
+ break;
+ case ROCKCHIP_DIV_MCLK:
+ reg &= ~I2S_MCLK_DIV_MASK;
+ reg |= I2S_MCLK_DIV(div);
+ break;
+ case ROCKCHIP_DIV_PRESCALER:
+ break;
+ default:
+ return -EINVAL;
}
writel(reg, &(pheadi2s->I2S_CKR));
- spin_unlock(&i2s->spinlock_wr);
- return 0;
-}
-
-static int i2s_set_gpio_mode(struct snd_soc_dai *dai)
-{
- I2S_DBG("Enter %s, %d >>>>>>>>>>>\n", __func__, __LINE__);
- switch(dai->id) {
-#if defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188)
- case 1:
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_MCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_LRCKRX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_LRCKTX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDI));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDO));
- break;
-#elif defined(CONFIG_ARCH_RK30)
- case 0:
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_MCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_LRCKRX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_LRCKTX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDI));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDO0));
- #ifdef CONFIG_SND_I2SO_USE_EIGHT_CHANNELS
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDO1));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDO2));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDO3));
- #endif
- break;
- case 1:
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S1_MCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S1_SCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S1_LRCKRX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S1_LRCKTX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S1_SDI));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S1_SDO));
- break;
- case 2:
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S2_MCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S2_SCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S2_LRCKRX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S2_LRCKTX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S2_SDI));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S2_SDO));
- break;
-#endif
-#if defined(CONFIG_ARCH_RK2928) || defined(CONFIG_ARCH_RK3026)
- case 0:
- #if 0 //iomux --> gps(.ko)
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_MCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SCLK));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_LRCKRX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_LRCKTX));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDI));
- iomux_set_gpio_mode(iomux_mode_to_gpio(I2S0_SDO));
- #endif
- break;
-#endif
- default:
- I2S_DBG("Enter:%s, %d, Error For DevId!!!", __FUNCTION__, __LINE__);
- return -EINVAL;
- }
- return 0;
-}
-
-static int rockchip_i2s_dai_probe(struct snd_soc_dai *dai)
-{
- I2S_DBG("Enter %s, %d >>>>>>>>>>>\n", __func__, __LINE__);
- if(rk_cpu_dai == NULL)
- rk_cpu_dai = dai;
- switch(dai->id) {
-#if defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188)
- case 1:
- iomux_set(I2S0_MCLK);
- iomux_set(I2S0_SCLK);
- iomux_set(I2S0_LRCKRX);
- iomux_set(I2S0_LRCKTX);
- iomux_set(I2S0_SDI);
- iomux_set(I2S0_SDO);
- break;
-#elif defined(CONFIG_ARCH_RK30)
- case 0:
- rk30_mux_api_set(GPIO0A7_I2S8CHSDI_NAME, GPIO0A_I2S_8CH_SDI);
- rk30_mux_api_set(GPIO0B0_I2S8CHCLK_NAME, GPIO0B_I2S_8CH_CLK);
- rk30_mux_api_set(GPIO0B1_I2S8CHSCLK_NAME, GPIO0B_I2S_8CH_SCLK);
- rk30_mux_api_set(GPIO0B2_I2S8CHLRCKRX_NAME, GPIO0B_I2S_8CH_LRCK_RX);
- rk30_mux_api_set(GPIO0B3_I2S8CHLRCKTX_NAME, GPIO0B_I2S_8CH_LRCK_TX);
- rk30_mux_api_set(GPIO0B4_I2S8CHSDO0_NAME, GPIO0B_I2S_8CH_SDO0);
- #ifdef CONFIG_SND_I2SO_USE_EIGHT_CHANNELS
- rk30_mux_api_set(GPIO0B5_I2S8CHSDO1_NAME, GPIO0B_I2S_8CH_SDO1);
- rk30_mux_api_set(GPIO0B6_I2S8CHSDO2_NAME, GPIO0B_I2S_8CH_SDO2);
- rk30_mux_api_set(GPIO0B7_I2S8CHSDO3_NAME, GPIO0B_I2S_8CH_SDO3);
- #endif
- break;
- case 1:
- rk30_mux_api_set(GPIO0C0_I2S12CHCLK_NAME, GPIO0C_I2S1_2CH_CLK);
- rk30_mux_api_set(GPIO0C1_I2S12CHSCLK_NAME, GPIO0C_I2S1_2CH_SCLK);
- rk30_mux_api_set(GPIO0C2_I2S12CHLRCKRX_NAME, GPIO0C_I2S1_2CH_LRCK_RX);
- rk30_mux_api_set(GPIO0C3_I2S12CHLRCKTX_NAME, GPIO0C_I2S1_2CH_LRCK_TX);
- rk30_mux_api_set(GPIO0C4_I2S12CHSDI_NAME, GPIO0C_I2S1_2CH_SDI);
- rk30_mux_api_set(GPIO0C5_I2S12CHSDO_NAME, GPIO0C_I2S1_2CH_SDO);
- break;
- case 2:
- rk30_mux_api_set(GPIO0D0_I2S22CHCLK_SMCCSN0_NAME, GPIO0D_I2S2_2CH_CLK);
- rk30_mux_api_set(GPIO0D1_I2S22CHSCLK_SMCWEN_NAME, GPIO0D_I2S2_2CH_SCLK);
- rk30_mux_api_set(GPIO0D2_I2S22CHLRCKRX_SMCOEN_NAME, GPIO0D_I2S2_2CH_LRCK_RX);
- rk30_mux_api_set(GPIO0D3_I2S22CHLRCKTX_SMCADVN_NAME, GPIO0D_I2S2_2CH_LRCK_TX);
- rk30_mux_api_set(GPIO0D4_I2S22CHSDI_SMCADDR0_NAME, GPIO0D_I2S2_2CH_SDI);
- rk30_mux_api_set(GPIO0D5_I2S22CHSDO_SMCADDR1_NAME, GPIO0D_I2S2_2CH_SDO);
- break;
-#endif
-#if defined(CONFIG_ARCH_RK2928) || defined(CONFIG_ARCH_RK3026)
- case 0:
- #if 0 //iomux --> gps(.ko)
- rk30_mux_api_set(GPIO1A0_I2S_MCLK_NAME, GPIO1A_I2S_MCLK);
- rk30_mux_api_set(GPIO1A1_I2S_SCLK_NAME, GPIO1A_I2S_SCLK);
- rk30_mux_api_set(GPIO1A2_I2S_LRCKRX_GPS_CLK_NAME, GPIO1A_I2S_LRCKRX);
- rk30_mux_api_set(GPIO1A3_I2S_LRCKTX_NAME, GPIO1A_I2S_LRCKTX);
- rk30_mux_api_set(GPIO1A4_I2S_SDO_GPS_MAG_NAME, GPIO1A_I2S_SDO);
- rk30_mux_api_set(GPIO1A5_I2S_SDI_GPS_SIGN_NAME, GPIO1A_I2S_SDI);
- #endif
- break;
-#endif
- default:
- I2S_DBG("Enter:%s, %d, Error For DevId!!!", __FUNCTION__, __LINE__);
- return -EINVAL;
- }
- return 0;
-}
-
-#ifdef CONFIG_PM
-int rockchip_i2s_suspend(struct snd_soc_dai *cpu_dai)
-{
- I2S_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-// clk_disable(clk);
- return 0;
-}
+ spin_unlock(&i2s->spinlock_wr);
-int rockchip_i2s_resume(struct snd_soc_dai *cpu_dai)
-{
- I2S_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-// clk_enable(clk);
return 0;
}
-#else
-#define rockchip_i2s_suspend NULL
-#define rockchip_i2s_resume NULL
-#endif
-
-#ifdef ANDROID_REC
-#define ROCKCHIP_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
-#else
-#define ROCKCHIP_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
- SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
- SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
-#endif
static struct snd_soc_dai_ops rockchip_i2s_dai_ops = {
.trigger = rockchip_i2s_trigger,
.set_sysclk = rockchip_i2s_set_sysclk,
};
-static int rk29_i2s_probe(struct platform_device *pdev,
- struct snd_soc_dai_driver *dai,
- struct rk29_i2s_info *i2s,
- unsigned long base)
-{
- struct device *dev = &pdev->dev;
- struct resource *res;
+#define ROCKCHIP_I2S_STEREO_RATES SNDRV_PCM_RATE_8000_96000
+#define ROCKCHIP_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
+ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
- I2S_DBG("Enter %s, %d >>>>>>>>>>>\n", __func__, __LINE__);
+struct snd_soc_dai_driver rockchip_i2s_dai[] = {
+ {
+ .name = "rockchip-i2s.0",
+ .id = 0,
+ .playback = {
+ .channels_min = 2,
+ .channels_max = 8,
+ .rates = ROCKCHIP_I2S_STEREO_RATES,
+ .formats = ROCKCHIP_I2S_FORMATS,
+ },
+ .capture = {
+ .channels_min = 2,
+ .channels_max = 2,
+ .rates = ROCKCHIP_I2S_STEREO_RATES,
+ .formats = ROCKCHIP_I2S_FORMATS,
+ },
+ .ops = &rockchip_i2s_dai_ops,
+ .symmetric_rates = 1,
+ },
+ {
+ .name = "rockchip-i2s.1",
+ .id = 1,
+ .playback = {
+ .channels_min = 2,
+ .channels_max = 2,
+ .rates = ROCKCHIP_I2S_STEREO_RATES,
+ .formats = ROCKCHIP_I2S_FORMATS,
+ },
+ .capture = {
+ .channels_min = 2,
+ .channels_max = 2,
+ .rates = ROCKCHIP_I2S_STEREO_RATES,
+ .formats = ROCKCHIP_I2S_FORMATS,
+ },
+ .ops = &rockchip_i2s_dai_ops,
+ .symmetric_rates = 1,
+ },
+};
- i2s->dev = dev;
+static const struct snd_soc_component_driver rockchip_i2s_component = {
+ .name = "rockchip-i2s",
+};
- /* record our i2s structure for later use in the callbacks */
- dev_set_drvdata(&pdev->dev, i2s);
+#ifdef CONFIG_PM
+static int rockchip_i2s_suspend_noirq(struct device *dev)
+{
+ I2S_DBG("Enter %s, %d\n", __func__, __LINE__);
- if (!base) {
- res = platform_get_resource(pdev,
- IORESOURCE_MEM,
- 0);
- if (!res) {
- dev_err(dev, "Unable to get register resource\n");
- return -ENXIO;
- }
+ return pinctrl_select_state(dev->pins->p, dev->pins->sleep_state);
+}
- if (!request_mem_region(res->start, resource_size(res),
- "rk29_i2s")) {
- dev_err(dev, "Unable to request register region\n");
- return -EBUSY;
- }
+static int rockchip_i2s_resume_noirq(struct device *dev)
+{
+ I2S_DBG("Enter %s, %d\n", __func__, __LINE__);
- base = res->start;
- }
+ return pinctrl_select_state(dev->pins->p, dev->pins->default_state);
+}
+#else
+#define rockchip_i2s_suspend_noirq NULL
+#define rockchip_i2s_resume_noirq NULL
+#endif
- i2s->regs = ioremap(base, (res->end - res->start) + 1); ////res));
- if (i2s->regs == NULL) {
- dev_err(dev, "cannot ioremap registers\n");
- return -ENXIO;
+static int rockchip_i2s_probe(struct platform_device *pdev)
+{
+ struct device_node *node = pdev->dev.of_node;
+ struct rk30_i2s_info *i2s;
+ struct resource *mem, *memregion;
+ u32 regs_base;
+ int ret;
+
+ I2S_DBG("%s()\n", __FUNCTION__);
+
+ ret = of_property_read_u32(node, "i2s-id", &pdev->id);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "%s() Can not read property: id\n", __FUNCTION__);
+ ret = -ENOMEM;
+ goto err;
}
- i2s->iis_pclk = clk_get(dev, "hclk_i2s");
- if (IS_ERR(i2s->iis_pclk)) {
- dev_err(dev, "failed to get iis_clock\n");
- iounmap(i2s->regs);
- return -ENOENT;
+ if(pdev->id >= MAX_I2S) {
+ dev_err(&pdev->dev, "id %d out of range\n", pdev->id);
+ ret = -ENOMEM;
+ goto err;
}
- clk_enable(i2s->iis_pclk);
+ i2s = devm_kzalloc(&pdev->dev, sizeof(struct rk30_i2s_info), GFP_KERNEL);
+ if (!i2s) {
+ dev_err(&pdev->dev, "Can't allocate i2s info\n");
+ ret = -ENOMEM;
+ goto err;
+ }
- /* Mark ourselves as in TXRX mode so we can run through our cleanup
- * process without warnings. */
- rockchip_snd_txctrl(i2s, 0);
- rockchip_snd_rxctrl(i2s, 0);
+ spin_lock_init(&i2s->spinlock_wr);
- return 0;
-}
+ i2s->i2s_clk= clk_get(&pdev->dev, NULL);
+ if (IS_ERR(i2s->i2s_clk)) {
+ dev_err(&pdev->dev, "Can't retrieve i2s clock\n");
+ ret = PTR_ERR(i2s->i2s_clk);
+ goto err;
+ }
+ clk_prepare_enable(i2s->i2s_clk);
+ clk_set_rate(i2s->i2s_clk, 11289600);
+
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!mem) {
+ dev_err(&pdev->dev, "No memory resource\n");
+ ret = -ENODEV;
+ goto err_clk_put;
+ }
-static int __devinit rockchip_i2s_probe(struct platform_device *pdev)
-{
- struct rk29_i2s_info *i2s;
- struct snd_soc_dai_driver *dai;
- int ret;
-
-#if defined(CONFIG_SND_I2S_USE_18V)
- writel_relaxed(0x2000200,RK30_GRF_BASE + GRF_IO_CON4);//bit9: 1,1.8v;0,3.3v
-#elif defined(CONFIG_SND_I2S_USE_33V)
- writel_relaxed(0x2000000,RK30_GRF_BASE + GRF_IO_CON4);
-#endif
+ memregion = devm_request_mem_region(&pdev->dev, mem->start,
+ resource_size(mem), "rockchip-i2s");
+ if (!memregion) {
+ dev_err(&pdev->dev, "Memory region already claimed\n");
+ ret = -EBUSY;
+ goto err_clk_put;
+ }
-#if defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188)
- //default 8ma 0xF000F = 12ma 0xF0005=4ma 0xF0000=2ma
- writel_relaxed(0xF000A,RK30_GRF_BASE + GRF_IO_CON1);
-#endif
- I2S_DBG("Enter %s, %d pdev->id = %d >>>>>>>>>>>\n", __func__, __LINE__, pdev->id);
-
- if(pdev->id >= MAX_I2S) {
- dev_err(&pdev->dev, "id %d out of range\n", pdev->id);
- return -EINVAL;
+ i2s->regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
+ if (!i2s->regs) {
+ dev_err(&pdev->dev, "ioremap failed\n");
+ ret = -ENOMEM;
+ goto err_clk_put;
}
- i2s = &rk29_i2s[pdev->id];
- dai = &rk29_i2s_dai[pdev->id];
- dai->id = pdev->id;
- dai->symmetric_rates = 1;
-
- switch(pdev->id)
- {
- case 0:
- dai->name = "rk_i2s.0";
- dai->playback.channels_min = 2;
- dai->playback.channels_max = 8;
- break;
- case 1:
- dai->name = "rk_i2s.1";
- dai->playback.channels_min = 2;
- dai->playback.channels_max = 2;
- break;
- case 2:
- dai->name = "rk_i2s.2";
- dai->playback.channels_min = 2;
- dai->playback.channels_max = 2;
- break;
- }
+ regs_base = mem->start;
- spin_lock_init(&i2s->spinlock_wr);
- dai->playback.rates = SNDRV_PCM_RATE_8000_192000;
- dai->playback.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |
- SNDRV_PCM_FMTBIT_S24_LE| SNDRV_PCM_FMTBIT_S32_LE;
- dai->capture.channels_min = 2;
- dai->capture.channels_max = 2;
- dai->capture.rates = ROCKCHIP_I2S_RATES;
- dai->capture.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE;
- dai->probe = rockchip_i2s_dai_probe;
- dai->ops = &rockchip_i2s_dai_ops;
- dai->suspend = rockchip_i2s_suspend;
- dai->resume = rockchip_i2s_resume;
-
- i2s->dma_capture = &rk29_i2s_pcm_stereo_in[pdev->id];
- i2s->dma_playback = &rk29_i2s_pcm_stereo_out[pdev->id];
-
- switch(pdev->id)
- {
-#ifdef CONFIG_ARCH_RK30
- case 0:
- i2s->dma_capture->channel = DMACH_I2S0_8CH_RX;
- i2s->dma_capture->dma_addr = RK30_I2S0_8CH_PHYS + I2S_RXR_BUFF;
- i2s->dma_playback->channel = DMACH_I2S0_8CH_TX;
- i2s->dma_playback->dma_addr = RK30_I2S0_8CH_PHYS + I2S_TXR_BUFF;
- break;
- case 1:
- i2s->dma_capture->channel = DMACH_I2S1_2CH_RX;
- i2s->dma_capture->dma_addr = RK30_I2S1_2CH_PHYS + I2S_RXR_BUFF;
- i2s->dma_playback->channel = DMACH_I2S1_2CH_TX;
- i2s->dma_playback->dma_addr = RK30_I2S1_2CH_PHYS + I2S_TXR_BUFF;
- break;
- case 2:
- i2s->dma_capture->channel = DMACH_I2S2_2CH_RX;
- i2s->dma_capture->dma_addr = RK30_I2S2_2CH_PHYS + I2S_RXR_BUFF;
- i2s->dma_playback->channel = DMACH_I2S2_2CH_TX;
- i2s->dma_playback->dma_addr = RK30_I2S2_2CH_PHYS + I2S_TXR_BUFF;
- break;
-#endif
-#if defined(CONFIG_ARCH_RK3188)
- case 1:
- i2s->dma_capture->channel = DMACH_I2S1_2CH_RX;
- i2s->dma_capture->dma_addr = RK30_I2S1_2CH_PHYS + I2S_RXR_BUFF;
- i2s->dma_playback->channel = DMACH_I2S1_2CH_TX;
- i2s->dma_playback->dma_addr = RK30_I2S1_2CH_PHYS + I2S_TXR_BUFF;
- break;
-#endif
-#if defined(CONFIG_ARCH_RK2928) || defined(CONFIG_ARCH_RK3026)
- case 0:
- i2s->dma_capture->channel = DMACH_I2S0_8CH_RX;
- i2s->dma_capture->dma_addr = RK2928_I2S_PHYS + I2S_RXR_BUFF;
- i2s->dma_playback->channel = DMACH_I2S0_8CH_TX;
- i2s->dma_playback->dma_addr = RK2928_I2S_PHYS + I2S_TXR_BUFF;
- break;
-#endif
+ i2s->playback_dma_data.addr = regs_base + I2S_TXR_BUFF;
+ i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+ i2s->playback_dma_data.maxburst = 4;
+
+ i2s->capture_dma_data.addr = regs_base + I2S_RXR_BUFF;
+ i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+ i2s->capture_dma_data.maxburst = 4;
+
+ i2s->i2s_tx_status = false;
+ i2s->i2s_rx_status = false;
+
+ pm_runtime_enable(&pdev->dev);
+ if (!pm_runtime_enabled(&pdev->dev)) {
+ ret = rockchip_i2s_resume_noirq(&pdev->dev);
+ if (ret)
+ goto err_pm_disable;
}
- i2s->dma_capture->client = &rk29_dma_client_in;
- i2s->dma_capture->dma_size = 4;
- i2s->dma_capture->flag = 0; //add by sxj, used for burst change
- i2s->dma_playback->client = &rk29_dma_client_out;
- i2s->dma_playback->dma_size = 4;
- i2s->dma_playback->flag = 0; //add by sxj, used for burst change
- i2s->i2s_tx_status = false;
- i2s->i2s_rx_status = false;
-#ifdef CONFIG_SND_I2S_DMA_EVENT_STATIC
- WARN_ON(rk29_dma_request(i2s->dma_playback->channel, i2s->dma_playback->client, NULL));
- WARN_ON(rk29_dma_request(i2s->dma_capture->channel, i2s->dma_capture->client, NULL));
-#endif
+ //set dev name to driver->name.id for sound card register
+ dev_set_name(&pdev->dev, "%s.%d", pdev->dev.driver->name, pdev->id);
- i2s->iis_clk = clk_get(&pdev->dev, "i2s");
- I2S_DBG("Enter:%s, %d, iis_clk=%p\n", __FUNCTION__, __LINE__, i2s->iis_clk);
- if (IS_ERR(i2s->iis_clk)) {
- dev_err(&pdev->dev, "failed to get i2s clk\n");
- ret = PTR_ERR(i2s->iis_clk);
- goto err;
+ ret = snd_soc_register_component(&pdev->dev, &rockchip_i2s_component,
+ &rockchip_i2s_dai[pdev->id], 1);
+
+ if (ret) {
+ dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
+ ret = -ENOMEM;
+ goto err_suspend;
}
- clk_enable(i2s->iis_clk);
- clk_set_rate(i2s->iis_clk, 11289600);
+ ret = rockchip_pcm_platform_register(&pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
+ goto err_unregister_component;
+ }
- ret = rk29_i2s_probe(pdev, dai, i2s, 0);
- if (ret)
- goto err_clk;
+ /* Mark ourselves as in TXRX mode so we can run through our cleanup
+ * process without warnings. */
+ rockchip_snd_txctrl(i2s, 0);
+ rockchip_snd_rxctrl(i2s, 0);
- ret = snd_soc_register_dai(&pdev->dev, dai);
- if (ret != 0)
- goto err_i2sv2;
+ dev_set_drvdata(&pdev->dev, i2s);
return 0;
-err_i2sv2:
- /* Not implemented for I2Sv2 core yet */
-err_clk:
- clk_put(i2s->iis_clk);
+err_unregister_component:
+ snd_soc_unregister_component(&pdev->dev);
+err_suspend:
+ if (!pm_runtime_status_suspended(&pdev->dev))
+ rockchip_i2s_suspend_noirq(&pdev->dev);
+err_pm_disable:
+ pm_runtime_disable(&pdev->dev);
+err_clk_put:
+ clk_put(i2s->i2s_clk);
err:
return ret;
-}
-static int rockchip_i2s_suspend_noirq(struct device *dev)
-{
- struct snd_soc_dai *dai = rk_cpu_dai;
- I2S_DBG("Enter %s, %d\n", __func__, __LINE__);
-
- return i2s_set_gpio_mode(dai);
}
-static int rockchip_i2s_resume_noirq(struct device *dev)
+static int rockchip_i2s_remove(struct platform_device *pdev)
{
- struct snd_soc_dai *dai = rk_cpu_dai;
- I2S_DBG("Enter %s, %d\n", __func__, __LINE__);
+ rockchip_pcm_platform_unregister(&pdev->dev);
+ snd_soc_unregister_component(&pdev->dev);
- return rockchip_i2s_dai_probe(dai);
+ return 0;
}
-static const struct dev_pm_ops rockchip_i2s_pm_ops = {
- .suspend_noirq = rockchip_i2s_suspend_noirq,
- .resume_noirq = rockchip_i2s_resume_noirq,
+#ifdef CONFIG_OF
+static const struct of_device_id exynos_i2s_match[] = {
+ { .compatible = "rockchip-i2s"},
+ {},
};
+MODULE_DEVICE_TABLE(of, exynos_i2s_match);
+#endif
-static int __devexit rockchip_i2s_remove(struct platform_device *pdev)
-{
- snd_soc_unregister_dai(&pdev->dev);
- return 0;
-}
+static const struct dev_pm_ops rockchip_i2s_pm_ops = {
+ SET_RUNTIME_PM_OPS(rockchip_i2s_suspend_noirq,
+ rockchip_i2s_resume_noirq, NULL)
+};
static struct platform_driver rockchip_i2s_driver = {
.probe = rockchip_i2s_probe,
- .remove = __devexit_p(rockchip_i2s_remove),
+ .remove = rockchip_i2s_remove,
.driver = {
- .name = "rk29_i2s",
+ .name = "rockchip-i2s",
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(exynos_i2s_match),
.pm = &rockchip_i2s_pm_ops,
},
};
-
-static int __init rockchip_i2s_init(void)
-{
- I2S_DBG("Enter %s, %d >>>>>>>>>>>\n", __func__, __LINE__);
-
- return platform_driver_register(&rockchip_i2s_driver);
-}
-module_init(rockchip_i2s_init);
-
-static void __exit rockchip_i2s_exit(void)
-{
- platform_driver_unregister(&rockchip_i2s_driver);
-}
-module_exit(rockchip_i2s_exit);
+module_platform_driver(rockchip_i2s_driver);
/* Module information */
MODULE_AUTHOR("rockchip");
MODULE_DESCRIPTION("ROCKCHIP IIS ASoC Interface");
MODULE_LICENSE("GPL");
-
-
-#ifdef CONFIG_PROC_FS
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-static int proc_i2s_show(struct seq_file *s, void *v)
-{
-#ifdef CONFIG_SND_RK_SOC_I2S_8CH
- struct rk29_i2s_info *i2s=&rk29_i2s[0];
-#else
-#ifdef CONFIG_SND_RK_SOC_I2S_2CH
- struct rk29_i2s_info *i2s=&rk29_i2s[1];
-#else
- struct rk29_i2s_info *i2s=&rk29_i2s[2];
-#endif
-#endif
- printk("========Show I2S reg========\n");
-
- printk("I2S_TXCR = 0x%08X\n", readl(&(pheadi2s->I2S_TXCR)));
- printk("I2S_RXCR = 0x%08X\n", readl(&(pheadi2s->I2S_RXCR)));
- printk("I2S_CKR = 0x%08X\n", readl(&(pheadi2s->I2S_CKR)));
- printk("I2S_DMACR = 0x%08X\n", readl(&(pheadi2s->I2S_DMACR)));
- printk("I2S_INTCR = 0x%08X\n", readl(&(pheadi2s->I2S_INTCR)));
- printk("I2S_INTSR = 0x%08X\n", readl(&(pheadi2s->I2S_INTSR)));
- printk("I2S_XFER = 0x%08X\n", readl(&(pheadi2s->I2S_XFER)));
-
- printk("========Show I2S reg========\n");
-#if 0
- writel(0x0000000F, &(pheadi2s->I2S_TXCR));
- writel(0x0000000F, &(pheadi2s->I2S_RXCR));
- writel(0x00071f1F, &(pheadi2s->I2S_CKR));
- writel(0x001F0110, &(pheadi2s->I2S_DMACR));
- writel(0x00000003, &(pheadi2s->I2S_XFER));
- while(1)
- {
- writel(0x5555aaaa, &(pheadi2s->I2S_TXDR));
- }
-#endif
- return 0;
-}
-
-static ssize_t i2s_reg_write(struct file *file,
- const char __user *user_buf, size_t count, loff_t *ppos)
-{
-#ifdef CONFIG_SND_RK_SOC_I2S_8CH
- struct rk29_i2s_info *i2s=&rk29_i2s[0];
-#else
-#ifdef CONFIG_SND_RK_SOC_I2S_2CH
- struct rk29_i2s_info *i2s=&rk29_i2s[1];
-#else
- struct rk29_i2s_info *i2s=&rk29_i2s[2];
-#endif
-#endif
- char buf[32];
- size_t buf_size;
- char *start = buf;
- unsigned long value;
-
- buf_size = min(count, (sizeof(buf)-1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
- buf[buf_size] = 0;
-
- while (*start == ' ')
- start++;
- value = simple_strtoul(start, &start, 10);
-
- printk("test --- freq = %ld ret=%d\n",value,clk_set_rate(i2s->iis_clk, value));
- return buf_size;
-}
-
-static int proc_i2s_open(struct inode *inode, struct file *file)
-{
- return single_open(file, proc_i2s_show, NULL);
-}
-
-static const struct file_operations proc_i2s_fops = {
- .open = proc_i2s_open,
- .read = seq_read,
- .write = i2s_reg_write,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static int __init i2s_proc_init(void)
-{
- proc_create("i2s_reg", 0, NULL, &proc_i2s_fops);
- return 0;
-}
-late_initcall(i2s_proc_init);
-#endif /* CONFIG_PROC_FS */
-
#include "../codecs/tlv320aic3111.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
#define AIC_DBG(x...) printk(KERN_INFO x)
AIC_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai);
- AIC_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- }
- else
- {
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai,
- SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS);
- #endif
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai,
- SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM );
- #endif
-
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai,
- SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM);
- #endif
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai,
- SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS);
- #endif
-
- if (ret < 0)
- return ret;
- }
-
switch(params_rate(params)) {
case 8000:
case 16000:
.name = "AIC3111",
.stream_name = "AIC3111 PCM",
.codec_name = "AIC3111.0-0018",
- .platform_name = "rockchip-pcm",
.cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "AIC3111 HiFi",
.init = rk29_aic3111_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_aic3111_snd_card = {
#include "../codecs/wm8994.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#include <linux/clk.h>
#include <linux/mfd/tlv320aic3262-registers.h>
#include "../codecs/tlv320aic326x.h"
printk("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set codec DAI configuration */
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- DBG_AIC3262("Set codec_dai slave\n");
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-#endif
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- DBG_AIC3262("Set codec_dai master\n");
-#endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- DBG_AIC3262("Set cpu_dai master\n");
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-#endif
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- DBG_AIC3262("Set cpu_dai slave\n");
-#endif
- if (ret < 0)
- return ret;
-
switch(params_rate(params)) {
case 8000:
case 16000:
.name = "AIC3262 I2S1",
.stream_name = "AIC3262 PCM",
.codec_name = "tlv320aic3262-codec",
- .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)
.codec_dai_name = "aic326x-asi1",
.ops = &rk29_aif1_ops,
.init = rk29_aic3262_init,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "AIC3262 I2S2",
.stream_name = "AIC3262 PCM",
.codec_name = "tlv320aic3262-codec",
- .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)
.name = "AIC3262 I2S3",
.stream_name = "AIC3262 PCM",
.codec_name = "tlv320aic3262-codec",
- .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)
#include <sound/soc-dapm.h>
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 1
#define DBG(x...) printk(KERN_INFO x)
unsigned int pll_out = 0;
int ret=-1;
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_RIGHT_J |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- if (ret < 0) return ret;
- /* set cpu DAI configuration */
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_RIGHT_J |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- if (ret < 0) return ret;
- #endif
+ DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
switch(params_rate(params)) {
case 8000:
.name = "AK4396",
.stream_name = "AK4396 PCM",
.codec_name = "spi1.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)
.codec_dai_name = "AK4396 HiFi",
.init = rk29_ak4396_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_ak4396_snd_card = {
.probe = rockchip_ak4396_audio_probe,
.remove = rockchip_ak4396_audio_remove,
};
-
module_platform_driver(rockchip_ak4396_audio_driver);
/* Module information */
#include "../codecs/cs42l52.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#define HW_PARAMS_FLAG_EQVOL_ON 0x21
int div_bclk,div_mclk;
struct clk *general_pll;
int ret;
-
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- }
- else
- {
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
- }
switch(params_rate(params)) {
case 8000:
.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)
.codec_dai_name = "cs42l52-hifi",
.init = rk29_cs42l52_dai_init,
.ops = &rk29_cs42l52_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_cs42l52_snd_card = {
#include <sound/jack.h>
#include <linux/delay.h>
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 1
#define DBG(x...) printk(KERN_INFO x)
#else
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
switch(params_rate(params)) {
case 8000:
.stream_name = "CX2070X PCM",
.cpu_dai_name = "rockchip-i2s.1",
.codec_dai_name = "cx2070x-hifi",
- .platform_name = "rockchip-pcm",
.codec_name = "cx2070x.0-0014",
.init = cx2070x_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
};
#include "../codecs/es8323.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#ifdef CONFIG_MACH_RK_FAC
#include <plat/config.h>
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- }
- else
- {
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
- }
+
switch(params_rate(params)) {
case 8000:
case 16000:
.name = "ES8323",
.stream_name = "ES8323 PCM",
.codec_name = "ES8323.0-0010", // ES8323.0-0010
- .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)
.codec_dai_name = "ES8323 HiFi",
.init = rk29_es8323_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_es8323_snd_card = {
#include <sound/soc-dapm.h>
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
#define DBG(x...) printk(KERN_INFO "rk_hdmi_i2s:"x)
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
switch(params_rate(params)) {
case 8000:
case 16000:
.name = "HDMI I2S",
.stream_name = "HDMI PCM",
.codec_name = "hdmi-i2s",
- .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)
#endif
.codec_dai_name = "rk-hdmi-i2s-hifi",
.ops = &hdmi_i2s_hifi_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_hdmi_i2s_snd_card = {
/* Module information */
MODULE_AUTHOR("rockchip");
MODULE_DESCRIPTION("ROCKCHIP hdmi i2s ASoC Interface");
-MODULE_LICENSE("GPL");
\ No newline at end of file
+MODULE_LICENSE("GPL");
unsigned long pll_out, rclk_rate;
int ret, ratio;
- RK_SPDIF_DBG("spdif:Entered %s\n", __func__);
+ RK_SPDIF_DBG("spdif:Entered %s\n", __func__);
switch (params_rate(params)) {
case 44100:
static struct snd_soc_dai_link rk_dai = {
.name = "SPDIF",
.stream_name = "SPDIF PCM Playback",
- .platform_name = "rockchip-pcm",
.cpu_dai_name = "rockchip-spdif",
.codec_dai_name = "rk-hdmi-spdif-hifi",
.codec_name = "hdmi-spdif",
};
static struct snd_soc_card rockchip_hdmi_spdif_snd_card = {
- .name = "ROCKCHIP-SPDIF",
+ .name = "RK-HDMI-SPDIF",
.dai_link = &rk_dai,
.num_links = 1,
};
--- /dev/null
+/*
+ * rockchip-iis.h - ALSA IIS interface for the Rockchip rk28 SoC
+ *
+ * Driver for rockchip iis audio
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/version.h>
+
+#ifndef _ROCKCHIP_IIS_H
+#define _ROCKCHIP_IIS_H
+
+//I2S_TXCR
+
+#define PCM_2DATA (0<<18)
+#define PCM_4DATA (1<<18)
+#define PCM_6DATA (2<<18)
+#define PCM_8DATA (3<<18)
+
+#define CHANNEL_1_EN (0<<15)
+#define CHANNEL_2_EN (1<<15)
+#define CHANNEL_3_EN (2<<15)
+#define CHANNLE_4_EN (3<<15)
+#define TX_MODE_MASTER (0<<13)
+#define TX_MODE_SLAVE (1<<13)
+#define RESET_TX (1<<17)
+#define RESET_RX (1<<16)
+#define I2S_DMA_REQ1_DISABLE (1<<6)
+#define I2S_DMA_REQ1_ENABLE (0)
+#define I2S_DMA_REQ2_DISABLE (1<<5)
+#define I2S_DMA_REQ2_ENABLE (0)
+#define I2S_DMA_REQ1_TX_ENABLE (0)
+#define I2S_DMA_REQ1_RX_ENABLE (1<<4)
+#define I2S_DMA_REQ2_TX_ENABLE (0)
+#define I2S_DMA_REQ2_RX_ENABLE (1<<3)
+#define TX_START (1<<1)
+#define RX_START (1)
+
+
+
+//I2S_TXCTL I2S_RXCTL
+#define CLEAR_RXFIFO (1<<24)
+#define TRAN_DEVICES0 (0)
+#define TRAN_DEVICES1 (1<<18)
+#define TRAN_DEVICES2 (2<<18)
+#define TRAN_DEVICES3 (3<<18)
+#define OVERSAMPLING_RATE_32FS (0)
+#define OVERSAMPLING_RATE_64FS (1<<16)
+#define OVERSAMPLING_RATE_128FS (2<<16)
+#define SCK_RATE2 (0x02<<8)
+#define SCK_RATE4 (0x04<<8)
+#define SCK_RATE8 (0x08<<8)
+#define SAMPLE_DATA_8bit (0)
+#define SAMPLE_DATA_16bit (1<<4)
+#define SAMPLE_DATA_MASK (3<<4)
+#define MONO_MODE (1<<3)
+#define STEREO_MODE (0)
+#define I2S_MODE (0)
+#define LEFT_JUSTIFIED (1<<1)
+#define RIGHT_JUSTIFIED (2<<1)
+#define IISMOD_SDF_MASK (3<<1)
+#define MASTER_MODE (1)
+#define SLAVE_MODE (0)
+
+//I2S_FIFOSTS
+#define TX_HALF_FULL (1<<18)
+#define RX_HALF_FULL (1<<16)
+
+/* Clock dividers */
+#define ROCKCHIP_DIV_MCLK 0
+#define ROCKCHIP_DIV_BCLK 1
+#define ROCKCHIP_DIV_PRESCALER 2
+
+
+/* I2S_TXCR */
+#define I2S_RSTL_SCLK(c) ((c&0x3F)<<26)
+#define I2S_RSTR_SCLK(c) ((c&0x3F)<<20)
+
+#define I2S_PCM_2DATA (0<<18)
+#define I2S_PCM_4DATA (1<<18)
+#define I2S_PCM_6DATA (2<<18)
+#define I2S_PCM_8DATA (3<<18)
+#define I2S_PCM_DATA_MASK (3<<18)
+
+#define I2S_CSR_CH2 (0<<15)
+#define I2S_CSR_CH4 (1<<15)
+#define I2S_CRS_CH6 (2<<15)
+#define I2S_CRS_CH8 (3<<15)
+#define I2S_CRS_CH_MASK (3<<15)
+
+#define I2S_HWT_16BIT (0<<14)
+#define I2S_HWT_32BIT (1<<14)
+
+#ifdef CONFIG_ARCH_RK29
+ #define I2S_MASTER_MODE (0<<13)
+ #define I2S_SLAVE_MODE (1<<13)
+ #define I2S_MODE_MASK (1<<13)
+#endif
+
+#define I2S_JUSTIFIED_RIGHT (0<<12)
+#define I2S_JUSTIFIED_LEFT (1<<12)
+
+#define I2S_FIRST_BIT_MSB (0<<11)
+#define I2S_FIRST_BIT_LSB (1<<11)
+
+#define I2S_BUS_MODE_NOR (0<<9)
+#define I2S_BUS_MODE_LSJM (1<<9)
+#define I2S_BUS_MODE_RSJM (2<<9)
+#define I2S_BUS_MODE_MASK (3<<9)
+
+#define I2S_PCM_NO_DELAY (0<<7)
+#define I2S_PCM_DELAY_1MODE (1<<7)
+#define I2S_PCM_DELAY_2MODE (2<<7)
+#define I2S_PCM_DELAY_3MODE (3<<7)
+#define I2S_PCM_DELAY_MASK (3<<7)
+
+#define I2S_TX_LRCK_OUT_BT_DISABLE (0<<6)
+#define I2S_TX_LRCK_OUT_BT_ENABLE (1<<6)
+
+#define I2S_TX_LRCK_OUT_I2S (0<<5)
+#define I2S_TX_LRCK_OUT_PCM (1<<5)
+
+#define I2S_DATA_WIDTH(w) ((w&0x1F)<<0)
+
+/* */
+
+
+/* I2S_TXCKR */
+#ifdef CONFIG_ARCH_RK29
+ #define I2S_TSP_POSEDGE (0<<25)
+ #define I2S_TSP_NEGEDGE (1<<25)
+ #define I2S_TLP_NORMAL (0<<24)
+ #define I2S_TLP_OPPSITE (1<<24)
+
+ #define I2S_MCLK_DIV(x) ((0xFF&x)<<16)
+ #define I2S_MCLK_DIV_MASK ((0xFF)<<16)
+
+ #define I2S_TSD_FIXED (0<<12)
+ #define I2S_TSD_CHANGED (1<<12)
+
+ #define I2S_TX_LRCK_NO_DELAY (0<<10)
+ #define I2S_TX_LRCK_DELAY_ONE (1<<10)
+ #define I2S_TX_LRCK_DELAY_TWO (2<<10)
+ #define I2S_TX_LRCK_DELAY_THREE (3<<10)
+ #define I2S_TX_LRCK_DELAY_MASK (3<<10)
+
+ #define I2S_TX_SCLK_DIV(x) (x&0x3FF)
+ #define I2S_TX_SCLK_DIV_MASK (0x3FF);
+#else
+//I2S_CKR
+ #define I2S_MASTER_MODE (0<<27)
+ #define I2S_SLAVE_MODE (1<<27)
+ #define I2S_MODE_MASK (1<<27)
+
+ #define I2S_BCLK_POSEDGE (0<<26)//sclk polarity invert??
+ #define I2S_BCLK_NEGEDGE (1<<26)
+
+ #define I2S_RX_LRCK_POSEDGE (0<<25)//LRCK polarity invert??
+ #define I2S_RX_LRCK_NEGEDGE (1<<25)
+
+ #define I2S_TX_LRCK_POSEDGE (0<<24)
+ #define I2S_TX_LRCK_NEGEDGE (1<<24)
+
+ #define I2S_MCLK_DIV(x) ((0xFF&x)<<16)
+ #define I2S_MCLK_DIV_MASK ((0xFF)<<16)
+
+ #define I2S_RX_SCLK_DIV(x) ((x&0xFF)<<8)
+ #define I2S_RX_SCLK_DIV_MASK ((0xFF)<<8)
+
+ #define I2S_TX_SCLK_DIV(x) (x&0xFF)
+ #define I2S_TX_SCLK_DIV_MASK (0xFF)
+#endif
+
+/* I2S_DMACR */
+#define I2S_RECE_DMA_DISABLE (0<<24)
+#define I2S_RECE_DMA_ENABLE (1<<24)
+#define I2S_DMARDL(x) ((x&0x1f)<<16)
+
+#define I2S_TRAN_DMA_DISABLE (0<<8)
+#define I2S_TRAN_DMA_ENABLE (1<<8)
+#define I2S_DMATDL(x) ((x&0x1f)<<0)
+
+/* I2S_INTCR */
+#define I2S_RXOV_INT_DISABLE (0<<17)
+#define I2S_RXOV_INT_ENABLE (1<<17)
+#define I2S_RXFU_INT_DISABLE (0<<16)
+#define I2S_RXFU_INT_ENABLE (1<<16)
+
+#define I2S_TXUND_INT_DISABLE (0<<1)
+#define I2S_TXUND_INT_ENABLE (1<<1)
+#define I2S_TXEMP_INT_DISABLE (0<<0)
+#define I2S_TXEMP_INT_ENABLE (1<<0)
+
+/* I2S_XFER */
+#define I2S_RX_TRAN_STOP (0<<1)
+#define I2S_RX_TRAN_START (1<<1)
+#define I2S_TX_TRAN_STOP (0<<0)
+#define I2S_TX_TRAN_START (1<<0)
+
+//I2S_CLR
+#define I2S_RX_CLEAR (1<<1)
+#define I2S_TX_CLEAR 1
+
+#ifdef CONFIG_ARCH_RK29
+#define I2S_TXR_BUFF 0x20
+#define I2S_RXR_BUFF 0x24
+//I2S Registers
+typedef volatile struct tagIIS_STRUCT
+{
+ unsigned int I2S_TXCR;
+ unsigned int I2S_RXCR;
+ unsigned int I2S_TXCKR;
+ unsigned int I2S_RXCKR;
+ unsigned int I2S_FIFOLR;
+ unsigned int I2S_DMACR;
+ unsigned int I2S_INTCR;
+ unsigned int I2S_INTSR;
+ unsigned int I2S_TXDR;
+ unsigned int I2S_RXDR;
+ unsigned int I2S_XFER;
+ unsigned int I2S_TXRST;
+ unsigned int I2S_RXRST;
+}I2S_REG,*pI2S_REG;
+#else
+#define I2S_TXR_BUFF 0x24
+#define I2S_RXR_BUFF 0x28
+typedef volatile struct tagIIS_STRUCT
+{
+ unsigned int I2S_TXCR;//0xF 0
+ unsigned int I2S_RXCR;//0xF 4
+ unsigned int I2S_CKR;//0x3F 8
+ unsigned int I2S_FIFOLR;//c
+ unsigned int I2S_DMACR;//0x001F0110 10
+ unsigned int I2S_INTCR;//0x01F00000 14
+ unsigned int I2S_INTSR;//0x00 18
+ unsigned int I2S_XFER;//0x00000003 1c
+ unsigned int I2S_CLR;//20
+ unsigned int I2S_TXDR;//24
+ unsigned int I2S_RXDR;
+}I2S_REG,*pI2S_REG;
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
+extern struct snd_soc_dai_driver rk29_i2s_dai[];
+#else
+extern struct snd_soc_dai rk29_i2s_dai[];
+#endif
+
+#ifdef CONFIG_SND_SOC_RT5631
+extern struct delayed_work rt5631_delay_cap; //bard 7-16
+#endif
+
+#endif /* _ROCKCHIP_IIS_H */
#include <sound/soc-dapm.h>
#include "../codecs/rk610_codec.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#ifdef CONFIG_MACH_RK_FAC
#include <plat/config.h>
extern int codec_type;
// struct clk *general_pll;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- }
- else
- {
- /* set codec DAI configuration */
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #elif defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
- /* set cpu DAI configuration */
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #elif defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
- }
switch(params_rate(params)) {
case 8000:
#else
.codec_name = "RK610_CODEC.0-0060",
#endif
- .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)
#endif
.codec_dai_name = "rk610_codec",
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_rk610_snd_card = {
.name = "RK_RK610",
* option) any later version.
*
*/
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
-
-#include <asm/dma.h>
-#include <mach/hardware.h>
-#include <mach/dma-pl330.h>
+#include <sound/dmaengine_pcm.h>
#include "rk_pcm.h"
-#define PCM_DMA_DEBUG 0
-
-#if 0
-#define DBG(x...) printk(KERN_INFO x)
-#else
-#define DBG(x...) do { } while (0)
-#endif
-
-//#define INFIN_LOOP
-#ifdef INFIN_LOOP
-#define DMA_INFIN_LOOP() rk29_dma_has_infiniteloop()
-#else
-#define DMA_INFIN_LOOP() 0
-#endif
-
static const struct snd_pcm_hardware rockchip_pcm_hardware = {
.info = SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_BLOCK_TRANSFER |
.fifo_size = 16,
};
-
-struct rockchip_dma_buf_set {
- struct rockchip_dma_buf_set *next;
- struct scatterlist sg;
-};
-
-struct rockchip_runtime_data {
- spinlock_t lock;
- int state;
- int transfer_first;
- unsigned int dma_loaded;
- unsigned int dma_limit;
- unsigned int dma_period;
- dma_addr_t dma_start;
- dma_addr_t dma_pos;
- dma_addr_t dma_end;
- struct rockchip_pcm_dma_params *params;
- struct rockchip_dma_buf_set *curr; /* current dma buffer set */
- struct rockchip_dma_buf_set *next; /* next buffer set to load */
- struct rockchip_dma_buf_set *end; /* end of queue set*/
+static const struct snd_dmaengine_pcm_config rockchip_dmaengine_pcm_config = {
+ .pcm_hardware = &rockchip_pcm_hardware,
+ .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
+ .compat_filter_fn = NULL,
+ .prealloc_buffer_size = PAGE_SIZE * 8,
};
-
-/* rockchip_pcm_enqueue
- *
- * place a dma buffer onto the queue for the dma system
- * to handle.
-*/
-static void rockchip_pcm_enqueue(struct snd_pcm_substream *substream)
-{
- struct rockchip_runtime_data *prtd = substream->runtime->private_data;
- dma_addr_t pos = prtd->dma_pos;
- unsigned int limit;
- int ret;
-
- DBG("Enter::%s----%d prtd->dma_period = %d prtd->dma_limit = %d\n",__FUNCTION__,__LINE__,prtd->dma_period,prtd->dma_limit);
-
- if (rk29_dma_has_circular())
- limit = (prtd->dma_end - prtd->dma_start) / prtd->dma_period;
- else
- limit = prtd->dma_limit;
-
- if (DMA_INFIN_LOOP()) {
- if(prtd->dma_period % (prtd->params->dma_size*16)){
- printk("dma_period(%d) is not an integer multiple of dma_size(%d)",prtd->dma_period,prtd->params->dma_size*16);
- rk29_dma_config(prtd->params->channel,
- prtd->params->dma_size, 1);
- }
- else
- rk29_dma_config(prtd->params->channel,
- prtd->params->dma_size, 16);
- ret = rk29_dma_enqueue_ring(prtd->params->channel,
- substream, pos, prtd->dma_period, limit ,true);
- if (ret == 0)
- pos = prtd->dma_start;
- } else {
- while (prtd->dma_loaded < prtd->dma_limit) {
- unsigned long len = prtd->dma_period;
- // DBG("dma_loaded: %d\n", prtd->dma_loaded);
- if ((pos + len) > prtd->dma_end) {
- len = prtd->dma_end - pos;
- }
-
- if((len%(prtd->params->dma_size*16) == 0) && (prtd->params->flag == 1))
- {
- ret = rk29_dma_config(prtd->params->channel,
- prtd->params->dma_size, 16);
- prtd->params->flag = 0;
- DBG("size = 16, channel = %d, flag = %d\n",prtd->params->channel,prtd->params->flag);
- }
- else if((len%(prtd->params->dma_size*16) != 0) && (prtd->params->flag == 0))
- {
- ret = rk29_dma_config(prtd->params->channel,
- prtd->params->dma_size, 1);
- prtd->params->flag = 1;
- DBG("size = 1, channel = %d, flag = %d\n",prtd->params->channel,prtd->params->flag);
- }
-
- ret = rk29_dma_enqueue(prtd->params->channel,substream, pos, len);
- // if(prtd->params->channel == 2)
- DBG("Enter::%s, %d, ret=%d, Channel=%d, Addr=0x%X, Len=%lu\n",
- __FUNCTION__,__LINE__, ret, prtd->params->channel, pos, len);
- if (ret == 0) {
- prtd->dma_loaded++;
- pos += prtd->dma_period;
- if (pos >= prtd->dma_end)
- pos = prtd->dma_start;
- } else
- break;
- }
- }
- prtd->dma_pos = pos;
-}
-
-void rk29_audio_buffdone(void *dev_id, int size,
- enum rk29_dma_buffresult result)
-{
- struct snd_pcm_substream *substream = dev_id;
- struct rockchip_runtime_data *prtd;
-#if PCM_DMA_DEBUG
- static ktime_t before = {0},after = {0};
- s64 t;
- before = after;
- after = ktime_get();
- t = ktime_to_us(ktime_sub(after, before));
- if(result == RK29_RES_OK)
- {
- if(t > prtd->dma_period/4/44100 +73 && t != ktime_to_us(after)) // (23220)4096/4/44100 + 32/44100
- {
- printk(KERN_DEBUG "Time out:: Audio DMA buffdone time out!!! the time = %lld!\n", t);
- }
- printk(KERN_DEBUG "audio DMA callback time = %lld\n", t);
- }
-// printk(KERN_DEBUG "a %d %d\n", size, result);
-#endif
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- if (!substream){
- DBG("substream is free\n");
- return;
- }
- if (!substream->runtime){
- DBG("substream->runtime is free\n");
- return;
- }
- switch(result)
- {
- case RK29_RES_OK:
- break;
- case RK29_RES_ERR:
- case RK29_RES_ABORT:
- DBG("Enter::%s dma about or error result = %d \n",__FUNCTION__,result);
- return;
- }
-
- prtd = substream->runtime->private_data;
-
-// if(prtd->params->channel == 2)
- DBG("Enter::%s----%d channel =%d \n",__FUNCTION__,__LINE__,prtd->params->channel);
- if(!(prtd->state & ST_RUNNING))
- return;
- if (substream){
- snd_pcm_period_elapsed(substream);
- }
- spin_lock(&prtd->lock);
- if (!DMA_INFIN_LOOP() && prtd->state & ST_RUNNING) {
- prtd->dma_loaded--;
- rockchip_pcm_enqueue(substream);
- }
- spin_unlock(&prtd->lock);
-}
-
-static int rockchip_pcm_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
-{
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct rockchip_runtime_data *prtd = runtime->private_data;
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
- struct rockchip_pcm_dma_params *dma = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
- struct rockchip_pcm_dma_params *dma = snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
-#else
- struct rockchip_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data;
-#endif
- unsigned long totbytes = params_buffer_bytes(params);
- int ret = 0;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* return if this is a bufferless transfer e.g.
- * codec <--> BT codec or GSM modem -- lg FIXME */
- if (!dma)
- return 0;
-
- /* this may get called several times by oss emulation
- * with different params -HW */
- if (prtd->params == NULL) {
- /* prepare DMA */
- prtd->params = dma;
-#ifdef CONFIG_SND_I2S_DMA_EVENT_DYNAMIC
- DBG("params %p, client %p, channel %d\n", prtd->params,prtd->params->client, prtd->params->channel);
- ret = rk29_dma_request(prtd->params->channel, prtd->params->client, NULL);
- DBG("Enter::%s, %d, ret=%d, Channel=%d\n", __FUNCTION__, __LINE__, ret, prtd->params->channel);
- if (ret) {
- DBG(KERN_ERR "failed to get dma channel\n");
- return ret;
- }
-#endif
- }
-
- ret = rk29_dma_set_buffdone_fn(prtd->params->channel, rk29_audio_buffdone);
- if(ret < 0){
- DBG(KERN_ERR "failed to rk29_dma_set_buffdone_fn\n");
- return ret;
- }
- snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
-
- runtime->dma_bytes = totbytes;
-
- spin_lock_irq(&prtd->lock);
- prtd->dma_loaded = 0;
- prtd->dma_limit = params_periods(params);//runtime->hw.periods_min;
- prtd->dma_period = params_period_bytes(params);
- prtd->dma_start = runtime->dma_addr;
- prtd->dma_pos = prtd->dma_start;
- prtd->dma_end = prtd->dma_start + prtd->dma_limit*prtd->dma_period;
- prtd->transfer_first = 1;
- prtd->curr = NULL;
- prtd->next = NULL;
- prtd->end = NULL;
- spin_unlock_irq(&prtd->lock);
- printk(KERN_DEBUG "i2s dma info:periodsize(%ld),limit(%d),buffersize(%d),over(%d)\n",
- prtd->dma_period,prtd->dma_limit,totbytes,totbytes-(prtd->dma_period*prtd->dma_limit));
- return ret;
-}
-
-static int rockchip_pcm_hw_free(struct snd_pcm_substream *substream)
-{
- struct rockchip_runtime_data *prtd = substream->runtime->private_data;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* TODO - do we need to ensure DMA flushed */
- snd_pcm_set_runtime_buffer(substream, NULL);
-
- if (prtd->params) {
-#ifdef CONFIG_SND_I2S_DMA_EVENT_DYNAMIC
- rk29_dma_free(prtd->params->channel, prtd->params->client);
- prtd->params = NULL;
-#endif
- }
-
- return 0;
-}
-
-static int rockchip_pcm_prepare(struct snd_pcm_substream *substream)
-{
- struct rockchip_runtime_data *prtd = substream->runtime->private_data;
- int ret = 0;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- /* return if this is a bufferless transfer e.g.
- * codec <--> BT codec or GSM modem -- lg FIXME */
- if (!prtd->params)
- return 0;
-
- if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- ret = rk29_dma_devconfig(prtd->params->channel,
- RK29_DMASRC_MEM,
- prtd->params->dma_addr);
- }else{
- ret = rk29_dma_devconfig(prtd->params->channel,
- RK29_DMASRC_HW,
- prtd->params->dma_addr);
- }
- DBG("Enter::%s, %d, ret=%d, Channel=%d, Addr=0x%X\n", __FUNCTION__, __LINE__, ret, prtd->params->channel, prtd->params->dma_addr);
- ret = rk29_dma_config(prtd->params->channel,
- prtd->params->dma_size, 1);
- prtd->params->flag = 1;
-
- DBG("Enter:%s, %d, ret = %d, Channel=%d, Size=%d\n",
- __FUNCTION__, __LINE__, ret, prtd->params->channel,
- prtd->params->dma_size);
-
- ret= rk29_dma_ctrl(prtd->params->channel, RK29_DMAOP_FLUSH);
- DBG("Enter:%s, %d, ret = %d, Channel=%d\n",
- __FUNCTION__, __LINE__, ret, prtd->params->channel);
-
- prtd->dma_loaded = 0;
- prtd->dma_pos = prtd->dma_start;
-
- /* enqueue dma buffers */
- rockchip_pcm_enqueue(substream);
- return ret;
-}
-
-static int rockchip_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
- struct rockchip_runtime_data *prtd = substream->runtime->private_data;
- int ret = 0;
- /**************add by qiuen for volume*****/
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
- struct snd_soc_dai *pCodec_dai = rtd->codec_dai;
-#else
- struct snd_soc_dai *pCodec_dai = rtd->dai->codec_dai;
-#endif
- int vol = 0;
- int streamType = 0;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- if(cmd==SNDRV_PCM_TRIGGER_VOLUME){
- vol = substream->number % 100;
- streamType = (substream->number / 100) % 100;
- DBG("enter:vol=%d,streamType=%d\n",vol,streamType);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
- if(pCodec_dai->driver->ops->set_volume)
- pCodec_dai->driver->ops->set_volume(streamType, vol);
-#else
- if(pCodec_dai->ops->set_volume)
- pCodec_dai->ops->set_volume(streamType, vol);
-#endif
- }
- /****************************************************/
- spin_lock(&prtd->lock);
-
- switch (cmd) {
- case SNDRV_PCM_TRIGGER_START:
- DBG(" START \n");
- prtd->state |= ST_RUNNING;
- rk29_dma_ctrl(prtd->params->channel, RK29_DMAOP_START);
- break;
- case SNDRV_PCM_TRIGGER_RESUME:
- DBG(" RESUME \n");
- break;
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- DBG(" RESTART \n");
- break;
-
- case SNDRV_PCM_TRIGGER_STOP:
- case SNDRV_PCM_TRIGGER_SUSPEND:
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- DBG(" STOPS \n");
- prtd->state &= ~ST_RUNNING;
- rk29_dma_ctrl(prtd->params->channel, RK29_DMAOP_STOP);
- break;
- default:
- ret = -EINVAL;
- break;
- }
-
- spin_unlock(&prtd->lock);
- return ret;
-}
-
-
-static snd_pcm_uframes_t
-rockchip_pcm_pointer(struct snd_pcm_substream *substream)
+int rockchip_pcm_platform_register(struct device *dev)
{
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct rockchip_runtime_data *prtd = runtime->private_data;
- unsigned long res;
- dma_addr_t src, dst;
- snd_pcm_uframes_t ret;
-
-
- spin_lock(&prtd->lock);
-
- rk29_dma_getposition(prtd->params->channel, &src, &dst);
-
- if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
- res = dst - prtd->dma_start;
- else
- res = src - prtd->dma_start;
-
- spin_unlock(&prtd->lock);
-
- ret = bytes_to_frames(runtime, res);
- if (ret == runtime->buffer_size)
- ret = 0;
-
- if(prtd->params->channel == 2)
- DBG("Enter:%s src = %x res = %x ret = %d\n",__FUNCTION__,src,res,ret);
-
- return ret;
+ return snd_dmaengine_pcm_register(dev, &rockchip_dmaengine_pcm_config,
+ SND_DMAENGINE_PCM_FLAG_COMPAT);
}
+EXPORT_SYMBOL_GPL(rockchip_pcm_platform_register);
-
-static int rockchip_pcm_open(struct snd_pcm_substream *substream)
+int rockchip_pcm_platform_unregister(struct device *dev)
{
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct rockchip_runtime_data *prtd;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- snd_soc_set_runtime_hwparams(substream, &rockchip_pcm_hardware);
-
- prtd = kzalloc(sizeof(struct rockchip_runtime_data), GFP_KERNEL);
- if (prtd == NULL)
- return -ENOMEM;
-
- spin_lock_init(&prtd->lock);
-
- runtime->private_data = prtd;
+ snd_dmaengine_pcm_unregister(dev);
return 0;
}
-
-static int rockchip_pcm_close(struct snd_pcm_substream *substream)
-{
- struct snd_pcm_runtime *runtime = substream->runtime;
- struct rockchip_runtime_data *prtd = runtime->private_data;
- struct rockchip_dma_buf_set *sg_buf = NULL;
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- if (!prtd) {
- DBG("rockchip_pcm_close called with prtd == NULL\n");
- return 0;
- }
-
- if (prtd->params)
- rk29_dma_set_buffdone_fn(prtd->params->channel, NULL);
- sg_buf = prtd->curr;
-
- while (sg_buf != NULL) {
- prtd->curr = sg_buf->next;
- prtd->next = sg_buf->next;
- sg_buf->next = NULL;
- kfree(sg_buf);
- sg_buf = NULL;
- sg_buf = prtd->curr;
- }
- kfree(prtd);
-
- return 0;
-}
-
-static int rockchip_pcm_mmap(struct snd_pcm_substream *substream,
- struct vm_area_struct *vma)
-{
- struct snd_pcm_runtime *runtime = substream->runtime;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
-#ifdef CONFIG_RK_SRAM_DMA
- vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
- return remap_pfn_range(vma, vma->vm_start,
- substream->dma_buffer.addr >> PAGE_SHIFT,
- vma->vm_end - vma->vm_start, vma->vm_page_prot);
-#else
- return dma_mmap_writecombine(substream->pcm->card->dev, vma,
- runtime->dma_area,
- runtime->dma_addr,
- runtime->dma_bytes);
-#endif
-}
-
-static struct snd_pcm_ops rockchip_pcm_ops = {
- .open = rockchip_pcm_open,
- .close = rockchip_pcm_close,
- .ioctl = snd_pcm_lib_ioctl,
- .hw_params = rockchip_pcm_hw_params,
- .hw_free = rockchip_pcm_hw_free,
- .prepare = rockchip_pcm_prepare,
- .trigger = rockchip_pcm_trigger,
- .pointer = rockchip_pcm_pointer,
- .mmap = rockchip_pcm_mmap,
-};
-
-#if defined(CONFIG_ARCH_RK3066B)
-#elif defined(CONFIG_ARCH_RK30)
-#define SRAM_DMA_PHYS_PLAYBACK (dma_addr_t)(RK30_IMEM_PHYS + 16*1024)
-#define SRAM_DMA_START_PLAYBACK (RK30_IMEM_NONCACHED + 16*1024)
-#define SRAM_DMA_PHYS_CAPTURE (dma_addr_t)(SRAM_DMA_PHYS_PLAYBACK + 24*1024)
-#define SRAM_DMA_START_CAPTURE (SRAM_DMA_START_PLAYBACK + 24*1024)
-#endif
-
-static int rockchip_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
-{
- struct snd_pcm_substream *substream = pcm->streams[stream].substream;
- struct snd_dma_buffer *buf = &substream->dma_buffer;
- size_t size = rockchip_pcm_hardware.buffer_bytes_max;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- buf->dev.type = SNDRV_DMA_TYPE_DEV;
- buf->dev.dev = pcm->card->dev;
- buf->private_data = NULL;
-#ifdef CONFIG_RK_SRAM_DMA
- if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
- buf->area = SRAM_DMA_START_PLAYBACK;
- buf->addr = SRAM_DMA_PHYS_PLAYBACK;
- } else{
- buf->area = SRAM_DMA_START_CAPTURE;
- buf->addr = SRAM_DMA_PHYS_CAPTURE;
- }
-#else
- buf->area = dma_alloc_writecombine(pcm->card->dev, size,
- &buf->addr, GFP_KERNEL);
-#endif
- if (!buf->area)
- return -ENOMEM;
- buf->bytes = size;
- DBG("%s: size %d\n",__FUNCTION__, size);
- return 0;
-}
-
-static void rockchip_pcm_free_dma_buffers(struct snd_pcm *pcm)
-{
- struct snd_pcm_substream *substream;
- struct snd_dma_buffer *buf;
- int stream;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- for (stream = 0; stream < 2; stream++) {
- substream = pcm->streams[stream].substream;
- if (!substream)
- continue;
-
- buf = &substream->dma_buffer;
- if (!buf->area)
- continue;
-
- dma_free_writecombine(pcm->card->dev, buf->bytes,
- buf->area, buf->addr);
- buf->area = NULL;
- }
-}
-
-static u64 rockchip_pcm_dmamask = DMA_BIT_MASK(32);
-
-static int rockchip_pcm_new(struct snd_card *card,
- struct snd_soc_dai *dai, struct snd_pcm *pcm)
-{
- int ret = 0;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- if (!card->dev->dma_mask)
- card->dev->dma_mask = &rockchip_pcm_dmamask;
- if (!card->dev->coherent_dma_mask)
- card->dev->coherent_dma_mask = 0xffffffff;
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
- if (dai->driver->playback.channels_min) {
-#else
- if (dai->playback.channels_min) {
-#endif
- ret = rockchip_pcm_preallocate_dma_buffer(pcm,
- SNDRV_PCM_STREAM_PLAYBACK);
- if (ret)
- goto out;
- }
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
- if (dai->driver->capture.channels_min) {
-#else
- if (dai->capture.channels_min) {
-#endif
- ret = rockchip_pcm_preallocate_dma_buffer(pcm,
- SNDRV_PCM_STREAM_CAPTURE);
- if (ret)
- goto out;
- }
- out:
- return ret;
-}
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
-static struct snd_soc_platform_driver rockchip_pcm_platform = {
- .ops = &rockchip_pcm_ops,
- .pcm_new = rockchip_pcm_new,
- .pcm_free = rockchip_pcm_free_dma_buffers,
-};
-
-static int __devinit rockchip_pcm_platform_probe(struct platform_device *pdev)
-{
- DBG("Enter::%s, %d\n", __FUNCTION__, __LINE__);
- return snd_soc_register_platform(&pdev->dev, &rockchip_pcm_platform);
-}
-
-static int __devexit rockchip_pcm_platform_remove(struct platform_device *pdev)
-{
- snd_soc_unregister_platform(&pdev->dev);
- return 0;
-}
-
-static struct platform_driver rockchip_pcm_driver = {
- .driver = {
- .name = "rockchip-audio",
- .owner = THIS_MODULE,
- },
- .probe = rockchip_pcm_platform_probe,
- .remove = __devexit_p(rockchip_pcm_platform_remove),
-};
-
-static int __init snd_rockchip_pcm_init(void)
-{
- DBG("Enter::%s, %d\n", __FUNCTION__, __LINE__);
- return platform_driver_register(&rockchip_pcm_driver);
-}
-module_init(snd_rockchip_pcm_init);
-
-static void __exit snd_rockchip_pcm_exit(void)
-{
- platform_driver_unregister(&rockchip_pcm_driver);
-}
-module_exit(snd_rockchip_pcm_exit);
-#else
-struct snd_soc_platform rk29_soc_platform = {
- .name = "rockchip-audio",
- .pcm_ops = &rockchip_pcm_ops,
- .pcm_new = rockchip_pcm_new,
- .pcm_free = rockchip_pcm_free_dma_buffers,
-};
-EXPORT_SYMBOL_GPL(rk29_soc_platform);
-
-static int __init rockchip_soc_platform_init(void)
-{
- DBG("Enter::%s, %d\n", __FUNCTION__, __LINE__);
- return snd_soc_register_platform(&rk29_soc_platform);
-}
-module_init(rockchip_soc_platform_init);
-
-static void __exit rockchip_soc_platform_exit(void)
-{
- snd_soc_unregister_platform(&rk29_soc_platform);
-}
-module_exit(rockchip_soc_platform_exit);
-#endif
+EXPORT_SYMBOL_GPL(rockchip_pcm_platform_unregister);
/* Module information */
MODULE_AUTHOR("rockchip");
MODULE_DESCRIPTION("ROCKCHIP PCM ASoC Interface");
MODULE_LICENSE("GPL");
-
#ifndef _ROCKCHIP_PCM_H
#define _ROCKCHIP_PCM_H
-#include <mach/hardware.h>
-
-#define ST_RUNNING (1<<0)
-#define ST_OPENED (1<<1)
-
-struct rockchip_pcm_dma_params {
- struct rk29_dma_client *client; /* stream identifier */
- int channel; /* Channel ID */
- dma_addr_t dma_addr;
- int dma_size; /* Size of the DMA transfer */
- int flag; /*burst change flag*/
-};
-
-extern struct snd_soc_platform rk29_soc_platform;
+int rockchip_pcm_platform_register(struct device *dev);
+int rockchip_pcm_platform_unregister(struct device *dev);
#endif /* _ROCKCHIP_PCM_H */
#include "../codecs/rk1000_codec.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 1
#define DBG(x...) printk(KERN_INFO x)
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
-//ÉèÖ÷ÖƵ²¿·Ö£¬ÔÝʱδÉèÖÃ
return 0;
}
static struct snd_soc_dai_link rk29_dai[] = {
{
- .name = "RK1000",
- .stream_name = "RK1000 CODEC PCM",
- .platform_name = "rockchip-pcm",
- .codec_name = "RK1000_CODEC.0-0060",
- .codec_dai_name = "rk1000_codec",
+ .name = "RK1000",
+ .stream_name = "RK1000 CODEC PCM",
+ .codec_name = "RK1000_CODEC.0-0060",
+ .codec_dai_name = "rk1000_codec",
#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
+ .cpu_dai_name = "rockchip-i2s.0",
#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
+ .cpu_dai_name = "rockchip-i2s.1",
+#endif
+ .init = rk29_rk1000_codec_init,
+ .ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
#endif
- .init = rk29_rk1000_codec_init,
- .ops = &rk29_ops,
}
};
#include "../codecs/rk3026_codec.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
#define DBG(x...) printk(KERN_INFO x)
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
if (ret < 0)
return ret;
.name = "RK3026 I2S1",
.stream_name = "RK3026 PCM",
.codec_name = "rk3026-codec",
- .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)
.codec_dai_name = "rk3026-hifi",
.init = rk3026_init,
.ops = &rk3026_hifi_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "RK3026 I2S2",
.stream_name = "RK3026 PCM",
.codec_name = "rk3026-codec",
- .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)
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include "../codecs/rk3190_codec.h"
-#include "rk29_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_pcm.h"
+#include "rk_i2s.h"
#if 0
#define DBG(x...) printk(KERN_INFO x)
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
switch(params_rate(params)) {
case 8000:
case 16000:
.name = "RK3190 I2S1",
.stream_name = "RK3190 PCM",
.codec_name = "rk3190-codec",
- .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)
- .cpu_dai_name = "rk29_i2s.1",
+#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",
#endif
.codec_dai_name = "rk3190-hifi",
.init = rk3190_init,
.ops = &rk3190_hifi_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "RK3190 I2S2",
.stream_name = "RK3190 PCM",
.codec_name = "rk3190-codec",
- .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)
- .cpu_dai_name = "rk29_i2s.1",
+#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",
#endif
.codec_dai_name = "rk3190-voice",
.ops = &rk3190_voice_ops,
#include "../codecs/rk616_codec.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 1
#define DBG(x...) printk(KERN_INFO x)
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
switch(params_rate(params)) {
case 16000:
case 24000:
.name = "RK616 I2S1",
.stream_name = "RK616 PCM",
.codec_name = "rk616-codec.4-0050",
- .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)
.codec_dai_name = "rk616-hifi",
.init = rk616_init,
.ops = &rk616_hifi_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "RK616 I2S2",
.stream_name = "RK616 PCM",
.codec_name = "rk616-codec.4-0050",
- .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)
#endif
.codec_dai_name = "rk616-voice",
.ops = &rk616_voice_ops,
+ .no_pcm = 1;
},
};
#include "../codecs/rt3261.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
#define DBG(x...) printk(KERN_INFO x)
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if (codec_dai->driver->ops->hw_params && ((params->flags == HW_PARAMS_FLAG_EQVOL_ON) || (params->flags == HW_PARAMS_FLAG_EQVOL_OFF)))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- } else {
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
- }
switch(params_rate(params)) {
case 8000:
.name = "RT3261 I2S1",
.stream_name = "RT3261 PCM",
.codec_name = "rt3261.0-001c",
- .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)
.codec_dai_name = "rt3261-aif1",
.init = rockchip_rt3261_init,
.ops = &rockchip_rt3261_hifi_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "RT3261 I2S2",
.stream_name = "RT3261 PCM",
.codec_name = "rt3261.0-001c",
- .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)
#endif
.codec_dai_name = "rt3261-aif2",
.ops = &rockchip_rt3261_voice_ops,
+ .no_pcm = 1;
},
};
static struct snd_soc_card rockchip_rt3261_snd_card = {
#if defined (CONFIG_SND_SOC_RT3224)
- .name = "ROCKCHIP-RT3224",
+ .name = "RK_RT3224",
#else
- .name = "ROCKCHIP-RT3261",
+ .name = "RK_RT3261",
#endif
.owner = THIS_MODULE,
.dai_link = rockchip_rt3261_dai,
#include <sound/jack.h>
#include <linux/delay.h>
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 1
#define DBG(x...) printk(KERN_INFO x)
#else
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
-
-
switch(params_rate(params)) {
case 8000:
return ret;
#endif
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
//snd_soc_dai_set_pll(codec_dai,0,pll_out, 22579200);
snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
#endif
.stream_name = "RT5512 PCM",
.cpu_dai_name = "rockchip-i2s.1",
.codec_dai_name = "RT5512-aif1",
- .platform_name = "rockchip-pcm",
.codec_name = "rt5512.1-0018",
.init = rt5512_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
};
#include "../codecs/rt5616.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
:#define DBG(x...) printk(KERN_INFO x)
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- }
- else
- {
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
- }
-
switch(params_rate(params)) {
case 8000:
.name = "rt5616",
.stream_name = "rt5616 PCM",
.codec_name = "rt5616.0-001b",
- .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)
.codec_dai_name = "rt5616-aif1",
.init = rk29_rt5616_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_rt5616_snd_card = {
#include "../codecs/rt5621.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
#define DBG(x...) printk(KERN_INFO x)
unsigned int lrclk = 0;
int ret;
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- } else {
- /* set codec DAI configuration */
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-#endif
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
-#endif
- if (ret < 0)
- return ret;
- /* set cpu DAI configuration */
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-#endif
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-#endif
- if (ret < 0)
- return ret;
- }
+ DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
switch(params_rate(params)) {
case 8000:
.name = "RT5621",
.stream_name = "RT5621 PCM",
.codec_name = "RT5621.0-001a",
- .platform_name = "rockchip-pcm",
.cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "RT5621 HiFi",
.init = rk29_rt5621_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_rt5621_snd_card = {
\r
#include "../codecs/rt5625.h"\r
#include "rk_pcm.h"\r
-#include "rk29_i2s.h"\r
+#include "rk_i2s.h"\r
\r
#if 1\r
#define DBG(x...) printk(KERN_INFO x)\r
int ret;\r
\r
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); \r
- /*by Vincent Hsiung for EQ Vol Change*/\r
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21\r
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22\r
- if (codec_dai->driver->ops->hw_params && ((params->flags == HW_PARAMS_FLAG_EQVOL_ON) || (params->flags == HW_PARAMS_FLAG_EQVOL_OFF)))\r
- {\r
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent\r
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);\r
- } else {\r
- \r
- /* set codec DAI configuration */\r
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE) \r
-\r
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);\r
- #endif \r
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER) \r
-\r
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); \r
- #endif\r
- if (ret < 0)\r
- return ret; \r
-\r
- /* set cpu DAI configuration */\r
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE) \r
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);\r
- #endif \r
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER) \r
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); \r
- #endif \r
- if (ret < 0)\r
- return ret;\r
- }\r
\r
switch(params_rate(params)) {\r
case 8000:\r
.name = "RT5625 I2S1",\r
.stream_name = "RT5625 PCM",\r
.codec_name = "rt5625.0-001f",\r
- .platform_name = "rockchip-pcm",\r
.cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5625-aif1",\r
.ops = &rk29_ops,\r
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)\r
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
+ SND_SOC_DAIFMT_CBM_CFM,\r
+#else\r
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
+ SND_SOC_DAIFMT_CBS_CFS,\r
+#endif\r
},\r
{\r
.name = "RT5625 I2S2",\r
.stream_name = "RT5625 PCM",\r
.codec_name = "rt5625.0-001f",\r
- .platform_name = "rockchip-pcm",\r
.cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5625-aif2",\r
.ops = &rt5625_voice_ops,\r
#include "../codecs/rt5631.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#ifdef CONFIG_MACH_RK_FAC
#include <plat/config.h>
unsigned int pll_out = 0;
int ret;
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- }
- else
- {
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
- }
-
+ DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
switch(params_rate(params)) {
case 8000:
.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 = "rockchip-i2s.0",
#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
.codec_dai_name = "rt5631-hifi",
.init = rk29_rt5631_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_rt5631_snd_card = {
- .name = "RK_rt5631",
+ .name = "RK_RT5631",
.dai_link = &rk29_dai,
.num_links = 1,
};
#include <sound/soc-dapm.h>
#include "../codecs/rt5631_phone.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 1
#define DBG(x...) printk(KERN_INFO x)
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
-
switch(params_rate(params)) {
case 8000:
case 16000:
//change to 8Khz
params->intervals[SNDRV_PCM_HW_PARAM_RATE - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL].min = 8000;
/* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
switch(params_rate(params)) {
case 8000:
.name = "RT5631 hifi",
.stream_name = "RT5631 hifi stream",
.codec_name = "RT5631.0-001a",
- .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)
.codec_dai_name = "RT5631 HiFi",
.init = rk29_rt5631_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "RT5631 voice",
.stream_name = "RT5631 voice stream",
.codec_name = "RT5631.0-001a",
- .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)
\r
#include "../codecs/rt5639.h"\r
#include "rk_pcm.h"\r
-#include "rk29_i2s.h"\r
+#include "rk_i2s.h"\r
\r
#if 1\r
#define DBG(x...) printk(KERN_INFO x)\r
int ret;\r
\r
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); \r
- /*by Vincent Hsiung for EQ Vol Change*/\r
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21\r
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22\r
- if (codec_dai->driver->ops->hw_params && ((params->flags == HW_PARAMS_FLAG_EQVOL_ON) || (params->flags == HW_PARAMS_FLAG_EQVOL_OFF)))\r
- {\r
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent\r
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);\r
- } else {\r
- \r
- /* set codec DAI configuration */\r
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE) \r
-\r
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);\r
- #endif \r
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER) \r
-\r
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); \r
- #endif\r
- if (ret < 0)\r
- return ret; \r
-\r
- /* set cpu DAI configuration */\r
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE) \r
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);\r
- #endif \r
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER) \r
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |\r
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); \r
- #endif \r
- if (ret < 0)\r
- return ret;\r
- }\r
\r
switch(params_rate(params)) {\r
case 8000:\r
int ret;\r
\r
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); \r
- \r
- /* set codec DAI configuration */\r
- //#if defined (CONFIG_SND_CODEC_SOC_SLAVE) \r
- DBG("Enter::%s----codec slave\n",__FUNCTION__);\r
\r
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |\r
SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS);\r
- /*#endif\r
- //#if defined (CONFIG_SND_CODEC_SOC_MASTER) \r
- DBG("Enter::%s----codec master\n",__FUNCTION__);\r
-\r
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |\r
- SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBM_CFM ); \r
- #endif*/\r
\r
switch(params_rate(params)) {\r
case 8000:\r
.name = "RT5639 I2S1",\r
.stream_name = "RT5639 PCM",\r
.codec_name = "rt5639.0-001c",\r
- .platform_name = "rockchip-pcm",\r
.cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5639-aif1",\r
.ops = &rk29_ops,\r
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)\r
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
+ SND_SOC_DAIFMT_CBM_CFM,\r
+#else\r
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
+ SND_SOC_DAIFMT_CBS_CFS,\r
+#endif\r
},\r
{\r
.name = "RT5639 I2S2",\r
.stream_name = "RT5639 PCM",\r
.codec_name = "rt5639.0-001c",\r
- .platform_name = "rockchip-pcm",\r
.cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5639-aif2",\r
.ops = &rt5639_voice_ops,\r
#include "../codecs/rt5640.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if (codec_dai->driver->ops->hw_params && ((params->flags == HW_PARAMS_FLAG_EQVOL_ON) || (params->flags == HW_PARAMS_FLAG_EQVOL_OFF)))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- } else {
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
- }
switch(params_rate(params)) {
case 8000:
.name = "RT5640 I2S1",
.stream_name = "RT5640 PCM",
.codec_name = "rt5640.0-001c",
- .platform_name = "rockchip-pcm",
#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
.cpu_dai_name = "rockchip-i2s.1",
#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
.codec_dai_name = "rt5640-aif1",
.init = rk29_rt5640_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "RT5640 I2S2",
.stream_name = "RT5640 PCM",
.codec_name = "rt5640.0-001c",
- .platform_name = "rockchip-pcm",
#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
.cpu_dai_name = "rockchip-i2s.1",
#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
/*$_FOR_ROCKCHIP_RBOX_$*/
/*$_rbox_$_modify_$_huangzhibao for spdif output*/
-/* sound/soc/rockchip/spdif.c
+/* sound/soc/rockchip/rk_spdif.c
*
* ALSA SoC Audio Layer - rockchip S/PDIF Controller driver
*
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/version.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
#include <asm/dma.h>
#include <sound/core.h>
#include <sound/pcm_params.h>
#include <sound/initval.h>
#include <sound/soc.h>
+#include <sound/dmaengine_pcm.h>
#include <asm/io.h>
-#include <mach/board.h>
-#include <mach/hardware.h>
-#include <mach/io.h>
-#include <mach/gpio.h>
-#include <mach/iomux.h>
-
-#if defined (CONFIG_ARCH_RK29)
-#include <mach/rk29-dma-pl330.h>
-#endif
-
-#if defined (CONFIG_ARCH_RK30)
-#include <mach/dma-pl330.h>
-#endif
-
-#if defined (CONFIG_ARCH_RK3188)
-#include <mach/dma-pl330.h>
-#endif
+#include <linux/spinlock.h>
#include "rk_pcm.h"
struct rockchip_spdif_info {
spinlock_t lock;
- struct device *dev;
void __iomem *regs;
unsigned long clk_rate;
- struct clk *hclk;
struct clk *clk;
- u32 saved_clkcon;
- u32 saved_con;
- u32 saved_cstas;
- struct rockchip_pcm_dma_params *dma_playback;
-};
-
-static struct rk29_dma_client spdif_dma_client_out = {
- .name = "SPDIF Stereo out"
+ struct snd_dmaengine_dai_dma_data dma_playback;
};
-static struct rockchip_pcm_dma_params spdif_stereo_out;
-
-static struct rockchip_spdif_info spdif_info;
-
static inline struct rockchip_spdif_info *to_info(struct snd_soc_dai *cpu_dai)
{
return snd_soc_dai_get_drvdata(cpu_dai);
int clk_id, unsigned int freq, int dir)
{
struct rockchip_spdif_info *spdif = to_info(cpu_dai);
- u32 clkcon;
RK_SPDIF_DBG("Entered %s\n", __func__);
static int spdif_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
- struct snd_soc_dai *socdai)
+ struct snd_soc_dai *dai)
{
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct rockchip_spdif_info *spdif = to_info(rtd->cpu_dai);
+ struct rockchip_spdif_info *spdif = to_info(dai);
void __iomem *regs = spdif->regs;
- struct rockchip_pcm_dma_params *dma_data;
unsigned long flags;
- int i, cfgr, dmac;
+ int cfgr, dmac;
RK_SPDIF_DBG("Entered %s\n", __func__);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- dma_data = spdif->dma_playback;
+ dai->playback_dma_data = &spdif->dma_playback;
else {
printk("spdif:Capture is not supported\n");
return -EINVAL;
}
- snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data);
spin_lock_irqsave(&spdif->lock, flags);
cfgr = readl(regs + CFGR) & CFGR_VALID_DATA_MASK;
- cfgr &= ~CFGR_VALID_DATA_MASK;
+ cfgr &= ~CFGR_VALID_DATA_MASK;
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
cfgr |= CFGR_VALID_DATA_16bit;
break;
- case SNDRV_PCM_FMTBIT_S20_3LE :
+ case SNDRV_PCM_FORMAT_S20_3LE :
cfgr |= CFGR_VALID_DATA_20bit;
break;
case SNDRV_PCM_FORMAT_S24_LE:
writel(cfgr, regs + CFGR);
- dmac = readl(regs + DMACR) & DMACR_TRAN_DMA_MASK & (~DMACR_TRAN_DATA_LEVEL_MASK);
- dmac |= 0x10;
- writel(dmac, regs + DMACR);
+ dmac = readl(regs + DMACR) & DMACR_TRAN_DMA_MASK & (~DMACR_TRAN_DATA_LEVEL_MASK);
+ dmac |= 0x10;
+ writel(dmac, regs + DMACR);
spin_unlock_irqrestore(&spdif->lock, flags);
return -EINVAL;
}
-static void spdif_shutdown(struct snd_pcm_substream *substream,
- struct snd_soc_dai *dai)
-{
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct rockchip_spdif_info *spdif = to_info(rtd->cpu_dai);
- void __iomem *regs = spdif->regs;
- u32 con, clkcon;
-
- RK_SPDIF_DBG( "spdif:Entered %s\n", __func__);
-
-}
-
#ifdef CONFIG_PM
static int spdif_suspend(struct snd_soc_dai *cpu_dai)
{
- struct rockchip_spdif_info *spdif = to_info(cpu_dai);
- u32 con = spdif->saved_con;
-
RK_SPDIF_DBG( "spdif:Entered %s\n", __func__);
return 0;
static int spdif_resume(struct snd_soc_dai *cpu_dai)
{
- struct rockchip_spdif_info *spdif = to_info(cpu_dai);
-
RK_SPDIF_DBG( "spdif:Entered %s\n", __func__);
return 0;
.set_sysclk = spdif_set_syclk,
.trigger = spdif_trigger,
.hw_params = spdif_hw_params,
- .shutdown = spdif_shutdown,
};
struct snd_soc_dai_driver rockchip_spdif_dai = {
- .name = "rk-spdif",
+ .name = "rockchip-spdif",
.playback = {
.stream_name = "SPDIF Playback",
.channels_min = 2,
.resume = spdif_resume,
};
+static const struct snd_soc_component_driver rockchip_spdif_component = {
+ .name = "rockchip-spdif",
+};
-static __devinit int spdif_probe(struct platform_device *pdev)
+static int spdif_probe(struct platform_device *pdev)
{
- struct s3c_audio_pdata *spdif_pdata;
- struct resource *mem_res, *dma_res;
+ struct resource *mem_res;
struct rockchip_spdif_info *spdif;
int ret;
-
- spdif_pdata = pdev->dev.platform_data;
RK_SPDIF_DBG("Entered %s\n", __func__);
-
-#if defined (CONFIG_ARCH_RK29)
- rk29_mux_api_set(GPIO4A7_SPDIFTX_NAME, GPIO4L_SPDIF_TX);
-#endif
-
-#if defined (CONFIG_ARCH_RK30)
- #if defined (CONFIG_ARCH_RK3066B)
- iomux_set(SPDIF_TX);
- #else
- rk30_mux_api_set(GPIO1B2_SPDIFTX_NAME, GPIO1B_SPDIF_TX);
- #endif
-#elif defined (CONFIG_ARCH_RK3188)
- iomux_set(SPDIF_TX);
-#endif
- dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "spdif_dma");
- if (!dma_res) {
- printk("spdif:Unable to get dma resource.\n");
- return -ENXIO;
+ spdif = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_spdif_info), GFP_KERNEL);
+ if (!spdif) {
+ dev_err(&pdev->dev, "Can't allocate spdif info\n");
+ return -ENOMEM;
}
- mem_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "spdif_base");
+ spin_lock_init(&spdif->lock);
+
+ mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem_res) {
printk("spdif:Unable to get register resource.\n");
return -ENXIO;
}
- spdif = &spdif_info;
- spdif->dev = &pdev->dev;
-
- spin_lock_init(&spdif->lock);
-
- spdif->clk = clk_get(&pdev->dev, "spdif");
+ spdif->clk= clk_get(&pdev->dev, NULL);
if (IS_ERR(spdif->clk)) {
- printk("spdif:failed to get internal source clock\n");
- ret = -ENOENT;
- goto err1;
+ dev_err(&pdev->dev, "Can't retrieve spdif clock\n");
+ return PTR_ERR(spdif->clk);
}
- clk_enable(spdif->clk);
+ clk_prepare_enable(spdif->clk);
clk_set_rate(spdif->clk, 11289600);
-
- spdif->hclk = clk_get(&pdev->dev, "hclk_spdif");
- if (IS_ERR(spdif->hclk)) {
- printk("spdif:failed to get spdif hclk\n");
- ret = -ENOENT;
- goto err0;
- }
- clk_enable(spdif->hclk);
- clk_set_rate(spdif->hclk, 11289600);
/* Request S/PDIF Register's memory region */
if (!request_mem_region(mem_res->start,
resource_size(mem_res), "rockchip-spdif")) {
printk("spdif:Unable to request register region\n");
ret = -EBUSY;
- goto err2;
+ goto err_clk_put;
}
- spdif->regs = ioremap(mem_res->start, mem_res->end - mem_res->start + 1);
- if (spdif->regs == NULL) {
- printk("spdif:Cannot ioremap registers\n");
- ret = -ENXIO;
- goto err3;
+ spdif->regs = devm_ioremap(&pdev->dev, mem_res->start, resource_size(mem_res));
+ if (!spdif->regs) {
+ dev_err(&pdev->dev, "ioremap failed\n");
+ ret = -ENOMEM;
+ goto err_clk_put;
}
- dev_set_drvdata(&pdev->dev, spdif);
-
- ret = snd_soc_register_dai(&pdev->dev, &rockchip_spdif_dai);
- if (ret != 0) {
- printk("spdif:fail to register dai\n");
- goto err4;
+ spdif->dma_playback.addr = mem_res->start + DATA_OUTBUF;
+ spdif->dma_playback.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+ spdif->dma_playback.maxburst = 4;
+
+ //set dev name to driver->name for sound card register
+ dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name);
+
+ ret = snd_soc_register_component(&pdev->dev, &rockchip_spdif_component,
+ &rockchip_spdif_dai, 1);
+ if (ret) {
+ dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
+ ret = -ENOMEM;
+ goto err_clk_put;
}
- spdif_stereo_out.dma_size = 4;
- spdif_stereo_out.client = &spdif_dma_client_out;
- spdif_stereo_out.dma_addr = mem_res->start + DATA_OUTBUF;
- spdif_stereo_out.channel = dma_res->start;
+ ret = rockchip_pcm_platform_register(&pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
+ goto err_unregister_component;
+ }
- spdif->dma_playback = &spdif_stereo_out;
-#ifdef CONFIG_SND_I2S_DMA_EVENT_STATIC
- WARN_ON(rk29_dma_request(spdif_stereo_out.channel, spdif_stereo_out.client, NULL));
-#endif
+ dev_set_drvdata(&pdev->dev, spdif);
RK_SPDIF_DBG("spdif:spdif probe ok!\n");
-
+
return 0;
-err4:
- iounmap(spdif->regs);
-err3:
- release_mem_region(mem_res->start, resource_size(mem_res));
-err2:
- clk_disable(spdif->clk);
+err_unregister_component:
+ snd_soc_unregister_component(&pdev->dev);
+err_clk_put:
clk_put(spdif->clk);
-err1:
- clk_disable(spdif->hclk);
- clk_put(spdif->hclk);
-err0:
return ret;
}
-static __devexit int spdif_remove(struct platform_device *pdev)
+static int spdif_remove(struct platform_device *pdev)
{
- struct rockchip_spdif_info *spdif = &spdif_info;
- struct resource *mem_res;
-
RK_SPDIF_DBG("Entered %s\n", __func__);
- snd_soc_unregister_dai(&pdev->dev);
-
- iounmap(spdif->regs);
-
- mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (mem_res)
- release_mem_region(mem_res->start, resource_size(mem_res));
-
- clk_disable(spdif->clk);
- clk_put(spdif->clk);
- clk_disable(spdif->hclk);
- clk_put(spdif->hclk);
+ rockchip_pcm_platform_unregister(&pdev->dev);
+ snd_soc_unregister_component(&pdev->dev);
return 0;
}
+#ifdef CONFIG_OF
+static const struct of_device_id exynos_spdif_match[] = {
+ { .compatible = "rockchip-spdif"},
+ {},
+};
+MODULE_DEVICE_TABLE(of, exynos_spdif_match);
+#endif
static struct platform_driver rockchip_spdif_driver = {
.probe = spdif_probe,
.remove = spdif_remove,
.driver = {
- .name = "rk-spdif",
+ .name = "rockchip-spdif",
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(exynos_spdif_match),
},
};
-
-
-static int __init spdif_init(void)
-{
- RK_SPDIF_DBG("Entered %s\n", __func__);
- return platform_driver_register(&rockchip_spdif_driver);
-}
-module_init(spdif_init);
-
-static void __exit spdif_exit(void)
-{
- RK_SPDIF_DBG("Entered %s\n", __func__);
- platform_driver_unregister(&rockchip_spdif_driver);
-}
-module_exit(spdif_exit);
+module_platform_driver(rockchip_spdif_driver);
MODULE_AUTHOR("Seungwhan Youn, <sw.youn@rockchip.com>");
MODULE_DESCRIPTION("rockchip S/PDIF Controller Driver");
#include "../codecs/wm8900.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#include <linux/clk.h>
#if 0
struct clk *general_pll;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- }
- else
- {
-
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
-
- }
-
switch(params_rate(params)) {
case 8000:
.name = "WM8900",
.stream_name = "WM8900 PCM",
.codec_name = "WM8900.0-001a",
- .platform_name = "rockchip-pcm",
.cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "WM8900 HiFi",
.init = rk29_wm8900_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_wm8900_snd_card = {
#include "../codecs/wm8988.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#if 0
#define DBG(x...) printk(KERN_INFO x)
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;
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret;
-
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /*by Vincent Hsiung for EQ Vol Change*/
- #define HW_PARAMS_FLAG_EQVOL_ON 0x21
- #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
- if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
- {
- ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
- DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- }
- else
- {
- /* set codec DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM );
- #endif
- if (ret < 0)
- return ret;
- /* set cpu DAI configuration */
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- #endif
- if (ret < 0)
- return ret;
- }
+ DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- return 0;
+ return 0;
}
static const struct snd_soc_dapm_widget rk29_dapm_widgets[] = {
.name = "WM8988",
.stream_name = "WM8988 PCM",
.codec_name = "WM8988.0-001a",
- .platform_name = "rockchip-pcm",
.cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "WM8988 HiFi",
.init = rk29_wm8988_init,
.ops = &rk29_ops,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
};
static struct snd_soc_card rockchip_wm8988_snd_card = {
#include "../codecs/wm8994.h"
#include "rk_pcm.h"
-#include "rk29_i2s.h"
+#include "rk_i2s.h"
#include <linux/clk.h>
#if 0
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- /* set codec DAI configuration */
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- DBG("Set codec_dai slave\n");
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-#endif
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
- DBG("Set codec_dai master\n");
-#endif
- if (ret < 0)
- return ret;
-
- /* set cpu DAI configuration */
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- DBG("Set cpu_dai master\n");
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-#endif
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- DBG("Set cpu_dai slave\n");
-#endif
- if (ret < 0)
- return ret;
-
switch(params_rate(params)) {
case 8000:
case 16000:
.name = "WM8994 I2S1",
.stream_name = "WM8994 PCM",
.codec_name = "wm8994-codec",
- .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)
.codec_dai_name = "wm8994-aif1",
.ops = &rk29_aif1_ops,
.init = rk29_wm8994_init,
+#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBM_CFM,
+#else
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+#endif
},
{
.name = "WM8994 I2S2",
.stream_name = "WM8994 PCM",
.codec_name = "wm8994-codec",
- .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)