|
|
@@ -13,17 +13,17 @@
|
|
|
//Mute State
|
|
|
#define MUTE_OFF 0
|
|
|
#define MUTE_ON 1
|
|
|
-extern int mute_status;
|
|
|
+extern int audio_codec_mode;
|
|
|
|
|
|
-#define ARKDAC_RATES \
|
|
|
+#define ARKADAC_RATES \
|
|
|
(SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
|
|
|
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | \
|
|
|
SNDRV_PCM_RATE_64000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \
|
|
|
SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000 |SNDRV_PCM_RATE_8000)
|
|
|
|
|
|
-#define ARKDAC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
|
|
|
+#define ARKADAC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
|
|
|
|
|
|
-struct ark_sddac {
|
|
|
+struct ark_adac {
|
|
|
struct device *dev;
|
|
|
void __iomem *sys_base;//sys_base
|
|
|
unsigned int vol_l;
|
|
|
@@ -44,25 +44,25 @@ static const struct soc_enum mute_switch_enum =
|
|
|
* Mute setting
|
|
|
*
|
|
|
***************************************************************************************************/
|
|
|
-static int get_lineout_mute_status(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
+static int get_adac_mute_status(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
{
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
- struct ark_sddac *adac = snd_soc_component_get_drvdata(component);
|
|
|
- printk("get:lineout_pa_mute_status= %d\n",adac->mute_status);
|
|
|
+ struct ark_adac *adac = snd_soc_component_get_drvdata(component);
|
|
|
+ printk("get:dac_pa_mute_status= %d\n",adac->mute_status);
|
|
|
ucontrol->value.integer.value[0] = adac->mute_status;
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int set_lineout_mute_status (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
+static int set_adac_mute_status (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
{
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
- struct ark_sddac *adac = snd_soc_component_get_drvdata(component);
|
|
|
+ struct ark_adac *adac = snd_soc_component_get_drvdata(component);
|
|
|
unsigned int mute;
|
|
|
int ret = -1;
|
|
|
|
|
|
unsigned int val = readl(adac->sys_base + rSYS_AUDIO_CFG_2);
|
|
|
|
|
|
- printk("set:lineout_pa_mute_status= %ld\n",ucontrol->value.integer.value[0]);
|
|
|
+ printk("set:dac_pa_mute_status= %ld\n",ucontrol->value.integer.value[0]);
|
|
|
mute = ucontrol->value.integer.value[0];
|
|
|
|
|
|
switch (mute)
|
|
|
@@ -92,7 +92,7 @@ static int set_lineout_mute_status (struct snd_kcontrol * kcontrol, struct snd_c
|
|
|
static int ark_adac_get_l_playback_volume (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
{
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
- struct ark_sddac *adac = snd_soc_component_get_drvdata(component);
|
|
|
+ struct ark_adac *adac = snd_soc_component_get_drvdata(component);
|
|
|
|
|
|
ucontrol->value.integer.value[0] = adac->vol_l & 0x3f;
|
|
|
//printk("get_l_playback_volume = %ld\n",ucontrol->value.integer.value[0]);
|
|
|
@@ -102,7 +102,7 @@ static int ark_adac_get_l_playback_volume (struct snd_kcontrol * kcontrol, struc
|
|
|
static int ark_adac_set_l_playback_volume (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
{
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
- struct ark_sddac *adac = snd_soc_component_get_drvdata(component);
|
|
|
+ struct ark_adac *adac = snd_soc_component_get_drvdata(component);
|
|
|
{
|
|
|
//lineout
|
|
|
unsigned int val = readl(adac->sys_base + rSYS_AUDIO_CFG_3);
|
|
|
@@ -132,7 +132,7 @@ static int ark_adac_set_l_playback_volume (struct snd_kcontrol * kcontrol, struc
|
|
|
static int ark_adac_get_r_playback_volume (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
{
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
- struct ark_sddac *adac = snd_soc_component_get_drvdata(component);
|
|
|
+ struct ark_adac *adac = snd_soc_component_get_drvdata(component);
|
|
|
|
|
|
ucontrol->value.integer.value[0] = adac->vol_r & 0x3f;
|
|
|
//printk("get_r_playback_volume = %ld\n",ucontrol->value.integer.value[0]);
|
|
|
@@ -142,14 +142,15 @@ static int ark_adac_get_r_playback_volume (struct snd_kcontrol * kcontrol, struc
|
|
|
static int ark_adac_set_r_playback_volume (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol)
|
|
|
{
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
- struct ark_sddac *adac = snd_soc_component_get_drvdata(component);
|
|
|
+ struct ark_adac *adac = snd_soc_component_get_drvdata(component);
|
|
|
//unsigned int val = readl(dac->sys_base + rSYS_AUDIO_CFG_3);
|
|
|
//dac->vol_r = ucontrol->value.integer.value[0];
|
|
|
//printk("set_r_playback_volume = %d\n",dac->vol_r);
|
|
|
{
|
|
|
//lineout
|
|
|
- unsigned int val = readl(adac->sys_base + rSYS_AUDIO_CFG_3);
|
|
|
adac->vol_r = ucontrol->value.integer.value[0];
|
|
|
+ unsigned int val = readl(adac->sys_base + rSYS_AUDIO_CFG_3);
|
|
|
+ //adac->vol_r = ucontrol->value.integer.value[0];
|
|
|
val &= ~DACR0_RVOL_MASK;
|
|
|
val |= DACR0_RVOL(adac->vol_r);
|
|
|
//printk("new_r_playback_volume = 0x%x\n",DACR0_RVOL(dac->vol_r));
|
|
|
@@ -175,8 +176,8 @@ static const struct snd_kcontrol_new ark_adac_snd_controls[] = {
|
|
|
ark_adac_get_l_playback_volume, ark_adac_set_l_playback_volume),
|
|
|
SOC_SINGLE_EXT("DAC Right Playback Volume", 0, 0, 63, 0,
|
|
|
ark_adac_get_r_playback_volume, ark_adac_set_r_playback_volume),
|
|
|
- SOC_ENUM_EXT("DAC PA Mute Control", mute_switch_enum,
|
|
|
- get_lineout_mute_status, set_lineout_mute_status),
|
|
|
+ SOC_ENUM_EXT("LINEOUT PA Mute", mute_switch_enum,
|
|
|
+ get_adac_mute_status, set_adac_mute_status),
|
|
|
};
|
|
|
|
|
|
static const struct snd_soc_dapm_widget ark_adac_dapm_widgets[] = {
|
|
|
@@ -200,7 +201,7 @@ static int ark_adac_hw_params(struct snd_pcm_substream *substream,
|
|
|
struct snd_soc_dai *dai)
|
|
|
{
|
|
|
unsigned int val;
|
|
|
- struct ark_sddac *adac = snd_soc_dai_get_drvdata(dai);
|
|
|
+ struct ark_adac *adac = snd_soc_dai_get_drvdata(dai);
|
|
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
|
|
//printk(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>PLAYBACK\n");
|
|
|
@@ -262,21 +263,32 @@ static int ark_adac_hw_params(struct snd_pcm_substream *substream,
|
|
|
val &= ~(1<<0);//Slave
|
|
|
|
|
|
//val &= ~(0x3<<13);
|
|
|
+#if 1
|
|
|
val &= ~(1<<13);//0:RMICIN 1: RLINEIN
|
|
|
val &= ~(1<<14);//0:LMICIN 1:LLINEIN
|
|
|
+#else
|
|
|
+ val |= (1<<13)|(1<<14);//0:RMICIN //0:RMICIN and LMICIN 1: RLINEIN and LLINEIN
|
|
|
+#endif
|
|
|
//val &= ~(1<<15);//
|
|
|
//val &= ~(1<<16);//
|
|
|
val &= ~(1<<21);
|
|
|
val &= ~(1<<22);
|
|
|
//val |=(0x3<<13)|(0x1<<9)|(0xf<<1);
|
|
|
val |=(0x1<<9)|(0xf<<1);
|
|
|
+
|
|
|
+ //val &= ~(0x3f<<23));//line-in volume gain right control
|
|
|
+ //val |= (0x1b<<23);//default:0dB
|
|
|
writel(val, adac->sys_base + rSYS_AUDIO_CFG_0);
|
|
|
|
|
|
val = readl(adac->sys_base + rSYS_AUDIO_CFG_1);
|
|
|
val &= ~(0xf<<6);
|
|
|
//val |= ((0x1<<7)|(0x1<<9));//L: Power-down mode R:Normal mode //for ksw only
|
|
|
//val |= ((0x1<<6)|(0x1<<8));//L:Normal mode R: Power-down mode
|
|
|
- val |= (0x5f<<19)|(0x5f<<12);//volume gain control
|
|
|
+ val &= ~((0x7f<<19)|(0x7f<<12));
|
|
|
+ val |= (0x5f<<19)|(0x5f<<12);//adc:digital volume gain control
|
|
|
+
|
|
|
+ //val &= ~(0x3f<<0));//line-in volume gain left control
|
|
|
+ //val |= (0x1b<<0);//default:0dB
|
|
|
writel(val, adac->sys_base + rSYS_AUDIO_CFG_1);
|
|
|
|
|
|
val = readl(adac->sys_base + rSYS_AUDIO_CFG_5);
|
|
|
@@ -301,7 +313,7 @@ static int ark_adac_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
|
|
static int ark_adac_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
|
|
unsigned int fmt)
|
|
|
{
|
|
|
- struct ark_sddac *i2s = snd_soc_dai_get_drvdata(codec_dai);
|
|
|
+ struct ark_adac *i2s = snd_soc_dai_get_drvdata(codec_dai);
|
|
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
|
|
case SND_SOC_DAIFMT_CBM_CFM:
|
|
|
@@ -334,15 +346,15 @@ static struct snd_soc_dai_driver ark_adac_dai = {
|
|
|
.stream_name = "Playback",
|
|
|
.channels_min = 1,
|
|
|
.channels_max = 2,
|
|
|
- .rates = ARKDAC_RATES,
|
|
|
- .formats = ARKDAC_FORMATS,
|
|
|
+ .rates = ARKADAC_RATES,
|
|
|
+ .formats = ARKADAC_FORMATS,
|
|
|
},
|
|
|
.capture = {
|
|
|
.stream_name = "Capture",
|
|
|
.channels_min = 1,
|
|
|
.channels_max = 2,
|
|
|
- .rates = ARKDAC_RATES,
|
|
|
- .formats = ARKDAC_FORMATS,
|
|
|
+ .rates = ARKADAC_RATES,
|
|
|
+ .formats = ARKADAC_FORMATS,
|
|
|
},
|
|
|
.ops = &ark_adac_dai_ops,
|
|
|
};
|
|
|
@@ -363,7 +375,7 @@ static const struct snd_soc_component_driver ark_adac_component_driver = {
|
|
|
|
|
|
static int ark_adac_probe(struct platform_device *pdev)
|
|
|
{
|
|
|
- struct ark_sddac *adac;
|
|
|
+ struct ark_adac *adac;
|
|
|
struct device *dev = &pdev->dev;
|
|
|
struct resource *res;
|
|
|
int ret;
|
|
|
@@ -406,7 +418,7 @@ err:
|
|
|
|
|
|
static int ark_adac_remove(struct platform_device *pdev)
|
|
|
{
|
|
|
- struct ark_sddac *adac = dev_get_drvdata(&pdev->dev);
|
|
|
+ struct ark_adac *adac = dev_get_drvdata(&pdev->dev);
|
|
|
|
|
|
if (adac->sys_base)
|
|
|
iounmap(adac->sys_base);
|