mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
Add set volume for call in codec wm8994
This commit is contained in:
@@ -39,9 +39,9 @@
|
||||
|
||||
/* Debug */
|
||||
#if 0
|
||||
#define DBG printk
|
||||
#define DBG(x...) printk(KERN_INFO x)
|
||||
#else
|
||||
#define DBG
|
||||
#define DBG(x...) do { } while (0)
|
||||
#endif
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>״̬ */
|
||||
|
||||
@@ -480,6 +480,7 @@ enum {
|
||||
#define SNDRV_PCM_IOCTL_READN_FRAMES _IOR('A', 0x53, struct snd_xfern)
|
||||
#define SNDRV_PCM_IOCTL_LINK _IOW('A', 0x60, int)
|
||||
#define SNDRV_PCM_IOCTL_UNLINK _IO('A', 0x61)
|
||||
#define SNDRV_PCM_IOCTL_VOL _IOW('A', 0x62, int)
|
||||
|
||||
/*****************************************************************************
|
||||
* *
|
||||
|
||||
2
include/sound/pcm.h
Normal file → Executable file
2
include/sound/pcm.h
Normal file → Executable file
@@ -106,6 +106,8 @@ struct snd_pcm_ops {
|
||||
#define SNDRV_PCM_TRIGGER_PAUSE_RELEASE 4
|
||||
#define SNDRV_PCM_TRIGGER_SUSPEND 5
|
||||
#define SNDRV_PCM_TRIGGER_RESUME 6
|
||||
//add by qiuen for volume
|
||||
#define SNDRV_PCM_TRIGGER_VOLUME 7
|
||||
|
||||
#define SNDRV_PCM_POS_XRUN ((snd_pcm_uframes_t)-1)
|
||||
|
||||
|
||||
3
include/sound/soc-dai.h
Normal file → Executable file
3
include/sound/soc-dai.h
Normal file → Executable file
@@ -172,6 +172,9 @@ struct snd_soc_dai_ops {
|
||||
struct snd_soc_dai *);
|
||||
int (*trigger)(struct snd_pcm_substream *, int,
|
||||
struct snd_soc_dai *);
|
||||
|
||||
/* set volume,add by qiuen*/
|
||||
void (*set_volume)(unsigned char mode,unsigned char volume);
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
2
include/sound/soc.h
Normal file → Executable file
2
include/sound/soc.h
Normal file → Executable file
@@ -363,6 +363,8 @@ struct snd_soc_ops {
|
||||
int (*hw_free)(struct snd_pcm_substream *);
|
||||
int (*prepare)(struct snd_pcm_substream *);
|
||||
int (*trigger)(struct snd_pcm_substream *, int);
|
||||
/* set volume,add by qiuen*/
|
||||
void (*set_volume)(unsigned char mode,unsigned char volume);
|
||||
};
|
||||
|
||||
/* SoC Audio Codec */
|
||||
|
||||
16
sound/core/pcm_native.c
Normal file → Executable file
16
sound/core/pcm_native.c
Normal file → Executable file
@@ -1025,6 +1025,17 @@ static int snd_pcm_pause(struct snd_pcm_substream *substream, int push)
|
||||
return snd_pcm_action(&snd_pcm_action_pause, substream, push);
|
||||
}
|
||||
|
||||
/*
|
||||
* set volume.
|
||||
* add by qiuen
|
||||
*/
|
||||
static int snd_pcm_vol(struct snd_pcm_substream *substream, int push)
|
||||
{
|
||||
substream->number = push;
|
||||
|
||||
return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_VOLUME);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
/* suspend */
|
||||
|
||||
@@ -2532,6 +2543,11 @@ static int snd_pcm_common_ioctl1(struct file *file,
|
||||
return snd_pcm_drain(substream, file);
|
||||
case SNDRV_PCM_IOCTL_DROP:
|
||||
return snd_pcm_drop(substream);
|
||||
/*add by qiuen for volume*/
|
||||
case SNDRV_PCM_IOCTL_VOL:
|
||||
snd_pcm_vol(substream, (int)(unsigned long)arg);
|
||||
return 0;
|
||||
/**********end***********/
|
||||
case SNDRV_PCM_IOCTL_PAUSE:
|
||||
{
|
||||
int res;
|
||||
|
||||
@@ -168,7 +168,6 @@ static int wm8994_read(unsigned short reg,unsigned short *value)
|
||||
if (reg_recv_data(wm8994_client,®s,&values,400000) > 0)
|
||||
{
|
||||
*value=((values>>8)& 0x00FF)|((values<<8)&0xFF00);
|
||||
printk("wm8994_read reg = 0x%x value = 0x%x \n",reg,*value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -435,7 +434,6 @@ void recorder_and_AP_to_speakers(void)
|
||||
wm8994_write(0x26, 0x017F); //Speaker Left Output Volume
|
||||
wm8994_write(0x27, 0x017F); //Speaker Right Output Volume
|
||||
wm8994_write(0x420, 0x0000);
|
||||
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x303, 0x0040); // AIF1 BCLK DIV--------AIF1CLK/4
|
||||
wm8994_write(0x304, 0x0040); // AIF1 ADCLRCK DIV-----BCLK/64
|
||||
@@ -639,6 +637,7 @@ void handsetMIC_to_baseband_to_headset(void)
|
||||
wm8994_write(0x22, 0x0000);
|
||||
wm8994_write(0x23, 0x0100);
|
||||
wm8994_write(0x28, 0x0030); //IN1LN_TO_IN1L IN1LP_TO_IN1L
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
|
||||
wm8994_write(0x02, 0x6240);
|
||||
wm8994_write(0x2B, 0x0005); //VRX_MIXINL_VOL
|
||||
@@ -663,9 +662,6 @@ void handsetMIC_to_baseband_to_headset(void)
|
||||
|
||||
wm8994_write(0x610, 0x01A0); //DAC1 Left Volume bit0~7
|
||||
wm8994_write(0x611, 0x01A0); //DAC1 Right Volume bit0~7
|
||||
wm8994_write(0x1C, 0x01FF); //HPOUT1L Volume
|
||||
wm8994_write(0x1D, 0x01FF); //HPOUT1R Volume
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x303, 0x0040); // AIF1 BCLK DIV--------AIF1CLK/4
|
||||
wm8994_write(0x304, 0x0040); // AIF1 ADCLRCK DIV-----BCLK/64
|
||||
@@ -689,8 +685,7 @@ void handsetMIC_to_baseband_to_headset_and_record(void)
|
||||
wm8994_write(0x04, 0x0303);
|
||||
wm8994_write(0x18, 0x014B); //volume
|
||||
wm8994_write(0x19, 0x014B); //volume
|
||||
wm8994_write(0x1C, 0x01FF); //LEFT OUTPUT VOLUME
|
||||
wm8994_write(0x1D, 0x01F9); //RIGHT OUTPUT VOLUME
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
wm8994_write(0x1E, 0x0006);
|
||||
wm8994_write(0x28, 0x00B0); //IN2LP_TO_IN2L
|
||||
wm8994_write(0x29, 0x0120);
|
||||
@@ -710,12 +705,7 @@ void handsetMIC_to_baseband_to_headset_and_record(void)
|
||||
|
||||
wm8994_write(0x606, 0x0002);
|
||||
wm8994_write(0x607, 0x0002);
|
||||
wm8994_write(0x620, 0x0000);
|
||||
|
||||
wm8994_write(0x1C, 0x01F9);
|
||||
wm8994_write(0x1D, 0x01F9);
|
||||
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
wm8994_write(0x620, 0x0000);
|
||||
}
|
||||
|
||||
void mainMIC_to_baseband_to_earpiece(void)
|
||||
@@ -756,6 +746,7 @@ void mainMIC_to_baseband_to_earpiece(void)
|
||||
wm8994_write(0x2B, 0x0005); //VRX_MIXINL_VOL
|
||||
wm8994_write(0x2D, 0x0041); //DAC1L_TO_MIXOUTL=1
|
||||
wm8994_write(0x2E, 0x0001); //DAC1R_TO_MIXOUTR=1
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
wm8994_write(0x33, 0x0010);
|
||||
wm8994_write(0x34, 0x0004); //MIXOUTR_TO_SPKMIXR =1 un-mute 0x0002
|
||||
|
||||
@@ -766,7 +757,7 @@ void mainMIC_to_baseband_to_earpiece(void)
|
||||
wm8994_write(0x611, 0x01C0); //DAC1_VU=1, DAC1R_VOL=1100_0000
|
||||
|
||||
wm8994_write(0x420, 0x0000);
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x303, 0x0040); // AIF1 BCLK DIV--------AIF1CLK/4
|
||||
wm8994_write(0x304, 0x0040); // AIF1 ADCLRCK DIV-----BCLK/64
|
||||
@@ -806,6 +797,7 @@ void mainMIC_to_baseband_to_earpiece_I2S(void)
|
||||
wm8994_write(0x1F, 0x0000);
|
||||
wm8994_write(0x28, 0x0030);
|
||||
wm8994_write(0x29, 0x0020); //IN1L_TO_MIXINL=1, IN1L_MIXINL_VOL=0, MIXOUTL_MIXINL_VOL=000
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
|
||||
wm8994_write(0x200, 0x0011); // sysclk = fll (bit4 =1) 0x0011 //cjq
|
||||
|
||||
@@ -836,8 +828,6 @@ void mainMIC_to_baseband_to_earpiece_I2S(void)
|
||||
|
||||
wm8994_write(0x420, 0x0000);
|
||||
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x303, 0x0040); // AIF1 BCLK DIV--------AIF1CLK/4
|
||||
wm8994_write(0x304, 0x0040); // AIF1 ADCLRCK DIV-----BCLK/64
|
||||
@@ -872,6 +862,7 @@ void mainMIC_to_baseband_to_earpiece_and_record(void)
|
||||
wm8994_write(0x200 ,0x0001);
|
||||
wm8994_write(0x208 ,0x000A);
|
||||
wm8994_write(0x300 ,0xC050);
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x302, 0x4000); // master = 0x4000 // slave= 0x0000
|
||||
@@ -881,8 +872,6 @@ void mainMIC_to_baseband_to_earpiece_and_record(void)
|
||||
wm8994_write(0x606 ,0x0002);
|
||||
wm8994_write(0x607 ,0x0002);
|
||||
wm8994_write(0x620 ,0x0000);
|
||||
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
}
|
||||
|
||||
void mainMIC_to_baseband_to_speakers(void)
|
||||
@@ -918,8 +907,7 @@ void mainMIC_to_baseband_to_speakers(void)
|
||||
wm8994_write(0x1E, 0x0006);
|
||||
wm8994_write(0x22, 0x0000);
|
||||
wm8994_write(0x23, 0x0100);
|
||||
wm8994_write(0x26, 0x017F); //Speaker Volume Left bit 0~5
|
||||
wm8994_write(0x27, 0x017F); //Speaker Volume Right bit 0~5
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
wm8994_write(0x28, 0x0003); //IN1RP_TO_IN1R IN1RN_TO_IN1R
|
||||
wm8994_write(0x2B, 0x0005); //VRX_MIXINL_VOL
|
||||
wm8994_write(0x2D, 0x0041); //bit 1 IN2LP_TO_MIXOUTL //0x0003 for info
|
||||
@@ -938,7 +926,6 @@ void mainMIC_to_baseband_to_speakers(void)
|
||||
wm8994_write(0x610, 0x01c0); //DAC1 Left Volume bit0~7
|
||||
wm8994_write(0x611, 0x01c0); //DAC1 Right Volume bit0~7
|
||||
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x303, 0x0040); // AIF1 BCLK DIV--------AIF1CLK/4
|
||||
wm8994_write(0x304, 0x0040); // AIF1 ADCLRCK DIV-----BCLK/64
|
||||
@@ -974,6 +961,7 @@ void mainMIC_to_baseband_to_speakers_and_record(void)
|
||||
wm8994_write(0x200, 0x0001);
|
||||
wm8994_write(0x208, 0x000A);
|
||||
wm8994_write(0x300, 0xC050);
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x302, 0x4000); // master = 0x4000 // slave= 0x0000
|
||||
@@ -983,8 +971,6 @@ void mainMIC_to_baseband_to_speakers_and_record(void)
|
||||
wm8994_write(0x606, 0x0002);
|
||||
wm8994_write(0x607, 0x0002);
|
||||
wm8994_write(0x620, 0x0000);
|
||||
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
}
|
||||
|
||||
void BT_baseband(void)
|
||||
@@ -1002,8 +988,7 @@ void BT_baseband(void)
|
||||
wm8994_write(0x04, 0x3303);
|
||||
wm8994_write(0x05, 0x3002);
|
||||
wm8994_write(0x06, 0x000A);
|
||||
wm8994_write(0x19, 0x014B);
|
||||
wm8994_write(0x1B, 0x014B);
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
wm8994_write(0x1E, 0x0006);
|
||||
wm8994_write(0x28, 0x00CC);
|
||||
wm8994_write(0x29, 0x0100);
|
||||
@@ -1059,7 +1044,7 @@ void BT_baseband(void)
|
||||
wm8994_write(0x708, 0x2100);
|
||||
wm8994_write(0x709, 0x2100);
|
||||
wm8994_write(0x70A, 0x2100);
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
|
||||
#ifdef CONFIG_SND_CODEC_SOC_MASTER
|
||||
wm8994_write(0x303, 0x0090);
|
||||
wm8994_write(0x313, 0x0020); // SMbus_16inx_16dat Write 0x34 * AIF2 BCLK DIV--------AIF1CLK/2
|
||||
@@ -1085,8 +1070,7 @@ void BT_baseband_and_record(void)
|
||||
wm8994_write(0x04, 0x3303);
|
||||
wm8994_write(0x05, 0x3002);
|
||||
wm8994_write(0x06, 0x000A);
|
||||
wm8994_write(0x19, 0x014B);
|
||||
wm8994_write(0x1B, 0x014B);
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
wm8994_write(0x1E, 0x0006);
|
||||
wm8994_write(0x28, 0x00CC);
|
||||
wm8994_write(0x29, 0x0100);
|
||||
@@ -1148,8 +1132,6 @@ void BT_baseband_and_record(void)
|
||||
wm8994_write(0x708, 0x2100);
|
||||
wm8994_write(0x709, 0x2100);
|
||||
wm8994_write(0x70A, 0x2100);
|
||||
|
||||
wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol);
|
||||
}
|
||||
|
||||
#else //PCM_BB
|
||||
@@ -2111,30 +2093,26 @@ static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
|
||||
|
||||
static const struct snd_kcontrol_new wm8994_snd_controls[] = {
|
||||
|
||||
/* 鍠囧彮 */
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Speaker incall Switch", SPEAKER_INCALL),
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Speaker normal Switch", SPEAKER_NORMAL),
|
||||
/* 鍚瓛 */
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Earpiece incall Switch", EARPIECE_INCALL),
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Earpiece normal Switch", EARPIECE_NORMAL),
|
||||
/* 鑰虫満 */
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Headset incall Switch", HEADSET_INCALL),
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Headset normal Switch", HEADSET_NORMAL),
|
||||
/* 钃濈墮SCO */
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Bluetooth incall Switch", BLUETOOTH_SCO_INCALL),
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Bluetooth normal Switch", BLUETOOTH_SCO_NORMAL),
|
||||
/* 钃濈墮A2DP */
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Bluetooth-A2DP incall Switch", BLUETOOTH_A2DP_INCALL),
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Bluetooth-A2DP normal Switch", BLUETOOTH_A2DP_NORMAL),
|
||||
/* 鑰抽害 */
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Capture Switch", MIC_CAPTURE),
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Earpiece ringtone Switch",EARPIECE_RINGTONE),
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Speaker ringtone Switch",SPEAKER_RINGTONE),
|
||||
|
||||
SOC_DOUBLE_SWITCH_WM8994CODEC("Headset ringtone Switch",HEADSET_RINGTONE),
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -2556,6 +2534,8 @@ static struct snd_soc_dai_ops wm8994_ops = {
|
||||
.set_fmt = wm8994_set_dai_fmt,
|
||||
.set_sysclk = wm8994_set_dai_sysclk,
|
||||
.digital_mute = wm8994_mute,
|
||||
/*add by qiuen for volume*/
|
||||
.set_volume = wm8994_codec_set_volume,
|
||||
};
|
||||
|
||||
struct snd_soc_dai wm8994_dai = {
|
||||
|
||||
18
sound/soc/rk2818/rk2818_pcm.c
Normal file → Executable file
18
sound/soc/rk2818/rk2818_pcm.c
Normal file → Executable file
@@ -365,9 +365,21 @@ static int rockchip_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||
{
|
||||
struct rockchip_runtime_data *prtd = substream->runtime->private_data;
|
||||
int ret = 0;
|
||||
|
||||
DBG("Enter::%s----%d---%d\n",__FUNCTION__,__LINE__,cmd);
|
||||
|
||||
/**************add by qiuen for volume*****/
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct snd_soc_dai *pCodec_dai = rtd->dai->codec_dai;
|
||||
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);
|
||||
pCodec_dai->ops->set_volume(streamType, vol);
|
||||
}
|
||||
/****************************************************/
|
||||
spin_lock(&prtd->lock);
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
Reference in New Issue
Block a user