1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-29 08:57:42 +02:00

purge out OSS stuff as it's obsolete, does not compile and isn't worth the time fixing it

This commit is contained in:
Mirko Vogt 2009-08-18 17:37:39 +02:00 committed by Xiangfu Liu
parent 8fc6527893
commit 0fd039053c
9 changed files with 0 additions and 10132 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,712 +0,0 @@
/*
* linux/sound/oss/ak4642en.c
*
* AKM ak4642en codec chip driver to I2S interface
*
* Copyright (c) 2005-2007 Ingenic Semiconductor Inc.
* Author: <cjfeng@ingenic.cn>
*
* 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.
*
* Because the normal application of AUDIO devices are focused on Little_endian,
* then we only perform the little endian data format in driver.
*/
#include <linux/init.h>
#include <linux/interrupt.h>
#include <sound/driver.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/sound.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <linux/proc_fs.h>
#include <linux/soundcard.h>
#include <linux/dma-mapping.h>
#include <linux/mutex.h>
#include <linux/mm.h>
#include <asm/hardirq.h>
#include <asm/jzsoc.h>
#include "sound_config.h"
extern mixer_info info;
extern _old_mixer_info old_info;
extern int abnormal_data_count;
extern void (*clear_codec_mode)(void);
extern void (*set_codec_gpio_pin)(void);
extern void (*each_time_init_codec)(void);
extern void (*set_codec_record)(void);
extern void (*set_codec_replay)(void);
extern void (*clear_codec_record)(void);
extern void (*clear_codec_replay)(void);
extern void (*set_codec_speed)(int range);
extern void (*codec_mixer_old_info_id_name)(void);
extern void (*codec_mixer_info_id_name)(void);
extern void (*set_codec_volume)(int val);
extern void (*set_codec_mic)(int val);
extern void (*i2s_resume_codec)(void);
extern void (*i2s_suspend_codec)(int wr,int rd);
extern void (*set_replay_hp_or_speaker)(void);
#define I2S_PDN 68
#define JACK_PLUG_PIN 83
#define JACK_PLUG_IRQ (IRQ_GPIO_0 + JACK_PLUG_PIN)
static int jack_plug_level, old_level;
static unsigned int i2c_addr = 0x26; //AK4642EN device address at I2C bus
static unsigned int i2c_clk = 100000;//AK4642EN 400kHz max,but 100kHz here
static unsigned int spk_hp = 0;
static int codec_volume;
void set_ak4642en_gpio_pin(void);
void each_time_init_ak4642en(void);
void set_ak4642en_replay(void);
void set_ak4642en_record(void);
void turn_on_ak4642en(void);
void turn_off_ak4642en(void);
void set_ak4642en_speed(int rate);
void reset_ak4642en(void);
void ak4642en_mixer_old_info_id_name(void);
void ak4642en_mixer_info_id_name(void);
void set_ak4642en_bass(int val);
void set_ak4642en_volume(int val);
void set_ak4642en_mic(int val);
void resume_ak4642en(void);
void suspend_ak4642en(int wr,int rd);
static void write_reg(u8 reg, u8 val)
{
i2c_open();
i2c_setclk(i2c_clk);
i2c_write((i2c_addr >> 1), &val, reg, 1);
i2c_close();
}
#if 0
static u8 read_reg(u8 reg)
{
u8 val;
i2c_open();
i2c_setclk(i2c_clk);
i2c_read((i2c_addr >> 1), &val, reg, 1);
i2c_close();
return val;
}
static u16 i2s_codec_read(u8 reg)
{
u16 value;
value = read_reg(reg);
return value;
}
#endif
static void i2s_codec_write(u8 reg, u16 data)
{
u8 val = data & 0xff;
write_reg(reg, val);
}
void set_ak4642en_gpio_pin(void)
{
//set AIC pin to I2S slave mode,only GPIO70,71,77,78
__gpio_as_output(68);
__gpio_clear_pin(68);
__gpio_as_output(69);
__gpio_clear_pin(69);
__gpio_as_output(70);
__gpio_clear_pin(70);
__gpio_as_input(71);
__gpio_clear_pin(71);
__gpio_as_input(77);
__gpio_clear_pin(77);
__gpio_as_input(78);
__gpio_clear_pin(78);
REG_GPIO_GPALR(2) &= 0xC3FF0CFF;
REG_GPIO_GPALR(2) |= 0x14005000;
//set SCC clock initialization
REG_SCC1_CR(SCC1_BASE) = 0x00000000;
udelay(2);
REG_SCC1_CR(SCC1_BASE) |= 1 << 31;
udelay(2);
__gpio_as_output(I2S_PDN);
__gpio_set_pin(I2S_PDN);
udelay(5);
__gpio_clear_pin(I2S_PDN);
ndelay(300);//>150ns
__gpio_set_pin(I2S_PDN);
mdelay(1);
//set PLL Master mode
i2s_codec_write(0x01, 0x0008);//master
i2s_codec_write(0x04, 0x006b);//ref:12MHz;BITCLK:64fs;I2S compli
i2s_codec_write(0x05, 0x000b);//sync:48KHz;
i2s_codec_write(0x00, 0x0040);//PMVCM
i2s_codec_write(0x01, 0x0009);//master,PLL enable
mdelay(40);
jack_plug_level = 10;
old_level = 100;
spk_hp = 0;
__gpio_disable_pull(JACK_PLUG_PIN);
udelay(10);
__gpio_as_input(JACK_PLUG_PIN);
jack_plug_level = __gpio_get_pin(JACK_PLUG_PIN);
//i suppose jack_plug_lvel is 1 indicate with HPO
if (jack_plug_level > 1 || jack_plug_level <0)
printk("Audio ak4642en codec Jack plug level is wrong!\n");
if (jack_plug_level)
__gpio_as_irq_fall_edge(JACK_PLUG_PIN);
else
__gpio_as_irq_rise_edge(JACK_PLUG_PIN);
}
void clear_ak4642en_mode(void)
{
spk_hp = 0;
i2s_codec_write(0x01, 0x0008);//master,PLL disable
//free_irq(JACK_PLUG_IRQ, i2s_controller);
__gpio_clear_pin(I2S_PDN);
udelay(2);
REG_SCC1_CR(SCC1_BASE) &= 0 << 31;
udelay(2);
}
void set_ak4642en_replay(void)
{
//for poll
/*jack_plug_level is H for SPK,is L for HP*/
jack_plug_level = __gpio_get_pin(JACK_PLUG_PIN);
if(old_level == jack_plug_level)
return;
old_level = jack_plug_level;
if(spk_hp == 1)
{
if(jack_plug_level == 1)
{
//now HeadPhone output,so clear SPK
i2s_codec_write(0x02, 0x0020);
i2s_codec_write(0x02, 0x0000);
i2s_codec_write(0x00, 0x0040);
}
else
{
//now Speaker output,so clear HP
i2s_codec_write(0x01, 0x0039);
i2s_codec_write(0x01, 0x0009);
i2s_codec_write(0x00, 0x0040);
i2s_codec_write(0x0e, 0x0000);
i2s_codec_write(0x0f, 0x0008);
}
}
spk_hp = 1;
if(jack_plug_level == 1)
{
//for HeadPhone output
i2s_codec_write(0x00, 0x0060); //
i2s_codec_write(0x0f, 0x0009); //5-10
i2s_codec_write(0x00, 0x0064); //
i2s_codec_write(0x09, 0x0091);// volume control 0dB
i2s_codec_write(0x0c, 0x0091);// 0dB(right)
//eq off
i2s_codec_write(0x11, 0x0000);//5-10
i2s_codec_write(0x01, 0x0039); //
i2s_codec_write(0x01, 0x0079); //
}
else
{
//for Speaker output
i2s_codec_write(0x00, 0x0040);
i2s_codec_write(0x02, 0x0020);
i2s_codec_write(0x03, 0x0018);//5-10
i2s_codec_write(0x06, 0x003c);
i2s_codec_write(0x08, 0x00A1);//5-10
i2s_codec_write(0x0b, 0x0040); //5-10
i2s_codec_write(0x07, 0x002d); //5-10
i2s_codec_write(0x09, 0x0091);
i2s_codec_write(0x0c, 0x0091);
//HP volume output value
i2s_codec_write(0x0a, codec_volume);//5-10
i2s_codec_write(0x0d, codec_volume);//5-10
i2s_codec_write(0x00, 0x0074);
i2s_codec_write(0x02, 0x00a0);
}
}
void set_ak4642en_record(void)
{
abnormal_data_count = 0;
i2s_codec_write(0x02, 0x0004);
i2s_codec_write(0x03, 0x0038);// recording volume add
i2s_codec_write(0x06, 0x0000);//for ALC short waiting time
i2s_codec_write(0x08, 0x00e1);
i2s_codec_write(0x0b, 0x0000);
i2s_codec_write(0x07, 0x0021); // ALC on
i2s_codec_write(0x10, 0x0000);//0x0001
//i2s_codec_write(0x10, 0x0001);//0x0001
i2s_codec_write(0x01, 0x0039); //for open pop noise
i2s_codec_write(0x01, 0x0079);
i2s_codec_write(0x00, 0x0065);
mdelay(300);
}
void clear_ak4642en_replay(void)
{
//for poll
old_level = 100;
spk_hp = 0;
if(jack_plug_level == 1)
{
//for HeadPhone output
i2s_codec_write(0x01, 0x0039); // for close pop noise
mdelay(300);
i2s_codec_write(0x01, 0x0009); //PLL on I2S
i2s_codec_write(0x07, 0x0001);
i2s_codec_write(0x11, 0x0000);
i2s_codec_write(0x00, 0x0040);
i2s_codec_write(0x0f, 0x0008); // for open pop noise
}
else
{
//for Speaker output
i2s_codec_write(0x02, 0x0020);
i2s_codec_write(0x07, 0x0001);
i2s_codec_write(0x11, 0x0000);
i2s_codec_write(0x02, 0x0000);
i2s_codec_write(0x00, 0x0040); // for close pop noise
}
}
void clear_ak4642en_record(void)
{
//for Mic input(Stereo)
i2s_codec_write(0x02, 0x0001);
i2s_codec_write(0x07, 0x0001);
i2s_codec_write(0x11, 0x0000);
}
void each_time_init_ak4642en(void)
{
__i2s_disable();
__i2s_as_slave();
__i2s_set_sample_size(16);
}
void set_ak4642en_speed(int rate)
{
//codec work at frequency
unsigned short speed = 0;
unsigned short val = 0;
switch (rate)
{
case 8000:
speed = 0x00;
if(jack_plug_level == 1) //speaker
{
i2s_codec_write(0x16, 0x0000);
i2s_codec_write(0x17, 0x0000);
i2s_codec_write(0x18, 0x0000);
i2s_codec_write(0x19, 0x0000);
i2s_codec_write(0x1A, 0x0000);
i2s_codec_write(0x1B, 0x0000);
i2s_codec_write(0x1C, 0x0027);//800hz
i2s_codec_write(0x1D, 0x0018);
i2s_codec_write(0x1E, 0x00b2);
i2s_codec_write(0x1F, 0x002f);
i2s_codec_write(0x11, 0x0010); //eq on
}
break;
case 12000:
speed = 0x01;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0000);
i2s_codec_write(0x17, 0x0000);
i2s_codec_write(0x18, 0x0000);
i2s_codec_write(0x19, 0x0000);
i2s_codec_write(0x1A, 0x0000);
i2s_codec_write(0x1B, 0x0000);
i2s_codec_write(0x1C, 0x0064);
i2s_codec_write(0x1D, 0x001a);
i2s_codec_write(0x1E, 0x0038);
i2s_codec_write(0x1F, 0x002b);
i2s_codec_write(0x11, 0x0010); //eq on
}
break;
case 16000:
speed = 0x02;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x00af);
i2s_codec_write(0x17, 0x0020);
i2s_codec_write(0x18, 0x0043);
i2s_codec_write(0x19, 0x001a);
i2s_codec_write(0x1A, 0x00af);
i2s_codec_write(0x1B, 0x0020);
i2s_codec_write(0x1C, 0x00a0);
i2s_codec_write(0x1D, 0x001b);
i2s_codec_write(0x1E, 0x00c0);
i2s_codec_write(0x1F, 0x0028);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
case 24000:
speed = 0x03;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0086);
i2s_codec_write(0x17, 0x0015);
i2s_codec_write(0x18, 0x005d);
i2s_codec_write(0x19, 0x0006);
i2s_codec_write(0x1A, 0x0086);
i2s_codec_write(0x1B, 0x0015);
i2s_codec_write(0x1C, 0x00f5);
i2s_codec_write(0x1D, 0x001c);
i2s_codec_write(0x1E, 0x0016);
i2s_codec_write(0x1F, 0x0026);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
case 7350:
speed = 0x04;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0000);
i2s_codec_write(0x17, 0x0000);
i2s_codec_write(0x18, 0x0000);
i2s_codec_write(0x19, 0x0000);
i2s_codec_write(0x1A, 0x0000);
i2s_codec_write(0x1B, 0x0000);
i2s_codec_write(0x1C, 0x0027);
i2s_codec_write(0x1D, 0x0018);
i2s_codec_write(0x1E, 0x00b2);
i2s_codec_write(0x1F, 0x002f);
i2s_codec_write(0x11, 0x0010); //eq on
}
break;
case 11025:
speed = 0x05;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0059);
i2s_codec_write(0x17, 0x000d);
i2s_codec_write(0x18, 0x00cb);
i2s_codec_write(0x19, 0x0037);
i2s_codec_write(0x1A, 0x0059);
i2s_codec_write(0x1B, 0x000d);
i2s_codec_write(0x1C, 0x0046);
i2s_codec_write(0x1D, 0x001e);
i2s_codec_write(0x1E, 0x0074);
i2s_codec_write(0x1F, 0x0023);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
case 14700:
speed = 0x06;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0000);
i2s_codec_write(0x17, 0x0000);
i2s_codec_write(0x18, 0x0000);
i2s_codec_write(0x19, 0x0000);
i2s_codec_write(0x1A, 0x0000);
i2s_codec_write(0x1B, 0x0000);
i2s_codec_write(0x1C, 0x004a);
i2s_codec_write(0x1D, 0x001b);
i2s_codec_write(0x1E, 0x006c);
i2s_codec_write(0x1F, 0x0029);
i2s_codec_write(0x11, 0x0010); //eq on
}
break;
case 22050:
speed = 0x07;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x002d);
i2s_codec_write(0x17, 0x0017);
i2s_codec_write(0x18, 0x0050);
i2s_codec_write(0x19, 0x0009);
i2s_codec_write(0x1A, 0x002d);
i2s_codec_write(0x1B, 0x0017);
i2s_codec_write(0x1C, 0x00d7);
i2s_codec_write(0x1D, 0x001c);
i2s_codec_write(0x1E, 0x0093);
i2s_codec_write(0x1F, 0x0026);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
case 32000:
speed = 0x0a;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0012);
i2s_codec_write(0x17, 0x0011);
i2s_codec_write(0x18, 0x006e);
i2s_codec_write(0x19, 0x003e);
i2s_codec_write(0x1A, 0x0012);
i2s_codec_write(0x1B, 0x0011);
i2s_codec_write(0x1C, 0x00aa);
i2s_codec_write(0x1D, 0x001d);
i2s_codec_write(0x1E, 0x00ab);
i2s_codec_write(0x1F, 0x0024);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
case 48000:
speed = 0x0b;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0082);
i2s_codec_write(0x17, 0x000c);
i2s_codec_write(0x18, 0x004b);
i2s_codec_write(0x19, 0x0036);
i2s_codec_write(0x1A, 0x0082);
i2s_codec_write(0x1B, 0x000c);
i2s_codec_write(0x1C, 0x0068);
i2s_codec_write(0x1D, 0x001e);
i2s_codec_write(0x1E, 0x0030);
i2s_codec_write(0x1F, 0x0023);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
case 29400:
speed = 0x0e;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x003d);
i2s_codec_write(0x17, 0x0012);
i2s_codec_write(0x18, 0x0083);
i2s_codec_write(0x19, 0x0000);
i2s_codec_write(0x1A, 0x003d);
i2s_codec_write(0x1B, 0x0012);
i2s_codec_write(0x1C, 0x0079);
i2s_codec_write(0x1D, 0x001d);
i2s_codec_write(0x1E, 0x000d);
i2s_codec_write(0x1F, 0x0025);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
case 44100:
speed = 0x0f;
if(jack_plug_level == 1)
{
i2s_codec_write(0x16, 0x0059);
i2s_codec_write(0x17, 0x000d);
i2s_codec_write(0x18, 0x00cb);
i2s_codec_write(0x19, 0x0037);
i2s_codec_write(0x1A, 0x0059);
i2s_codec_write(0x1B, 0x000d);
i2s_codec_write(0x1C, 0x0046);
i2s_codec_write(0x1D, 0x001e);
i2s_codec_write(0x1E, 0x0074);
i2s_codec_write(0x1F, 0x0023);
i2s_codec_write(0x11, 0x0018); //eq on
}
break;
default:
break;
}
val = speed & 0x08;
val = val << 2;
speed = speed & 0x07;
val = val | speed;
i2s_codec_write(0x05, val);
}
void ak4642en_mixer_old_info_id_name(void)
{
strncpy(info.id, "AK4642EN", sizeof(info.id));
strncpy(info.name,"AKM AK4642en codec", sizeof(info.name));
}
void ak4642en_mixer_info_id_name(void)
{
strncpy(old_info.id, "AK4642EN", sizeof(old_info.id));
strncpy(old_info.name,"AKM AK4642en codec", sizeof(old_info.name));
}
void set_ak4642en_volume(int val)
{
if ( val == 0 )
codec_volume = 255;
else if ( val > 1 && val <= 10)
codec_volume = 92;
else if ( val > 10 && val <= 20 )
codec_volume = 67;
else if ( val > 20 && val <= 30 )
codec_volume = 50;
else if ( val > 30 && val <= 40 )
codec_volume = 40;
else if ( val > 40 && val <= 50 )
codec_volume = 30;
else if ( val > 50 && val <= 60 )
codec_volume = 22;
else if ( val > 60&& val <= 70 )
codec_volume = 15;
else if ( val > 70 && val <= 80 )
codec_volume = 8;
else if ( val > 80 && val <= 90 )
codec_volume = 4;
else if ( val > 90 && val <= 100 )
codec_volume = 2;
i2s_codec_write(0x0a, codec_volume);
i2s_codec_write(0x0d, codec_volume);
}
void set_ak4642en_mic(int val)
{
int mic_gain;
mic_gain = 241 * val /100;
i2s_codec_write(0x09, mic_gain);
i2s_codec_write(0x0c, mic_gain);
}
void resume_ak4642en(void)
{
__gpio_as_output(17);
__gpio_set_pin(17); //enable ak4642
__gpio_as_output(68);
__gpio_clear_pin(68);
__gpio_as_output(69);
__gpio_clear_pin(69);
__gpio_as_output(70);
__gpio_clear_pin(70);
__gpio_as_input(71);
__gpio_clear_pin(71);
__gpio_as_input(77);
__gpio_clear_pin(77);
__gpio_as_input(78);
__gpio_clear_pin(78);
REG_GPIO_GPALR(2) &= 0xC3FF0CFF;
REG_GPIO_GPALR(2) |= 0x14005000;
//set SCC clock initialization
REG_SCC1_CR(SCC1_BASE) = 0x00000000;
udelay(2);
REG_SCC1_CR(SCC1_BASE) |= 1 << 31;
udelay(2);
__gpio_as_output(I2S_PDN);
__gpio_set_pin(I2S_PDN);
udelay(5);
__gpio_clear_pin(I2S_PDN);
ndelay(300);//>150ns
__gpio_set_pin(I2S_PDN);
mdelay(1);
//set PLL Master mode
i2s_codec_write(0x01, 0x0008);//master
i2s_codec_write(0x04, 0x006b);//ref:12MHz;BITCLK:64fs;I2S compli
i2s_codec_write(0x05, 0x000b);//sync:48KHz;
i2s_codec_write(0x00, 0x0040);//PMVCM
i2s_codec_write(0x01, 0x0009);//master,PLL enable
jack_plug_level = 10;
old_level = 100;
spk_hp = 0;
__gpio_as_input(JACK_PLUG_PIN);
jack_plug_level = __gpio_get_pin(JACK_PLUG_PIN);
//i suppose jack_plug_lvel is 1 indicate with HPO
if(jack_plug_level > 1 || jack_plug_level <0)
printk("Audio ak4642en codec Jack plug level is wrong!\n");
if(jack_plug_level)
__gpio_as_irq_fall_edge(JACK_PLUG_PIN);
else
__gpio_as_irq_rise_edge(JACK_PLUG_PIN);
i2s_codec_write(0x00, 0x0065); //for resume power
i2s_codec_write(0x01, 0x0039); //for open pop noise
i2s_codec_write(0x01, 0x0079);
i2s_codec_write(0x0a, codec_volume);
i2s_codec_write(0x0d, codec_volume);
}
void suspend_ak4642en(int wr,int rd)
{
if(wr) //playing
{
if(jack_plug_level == 0)
{
i2s_codec_write(0x01, 0x0039); // for close pop noise
mdelay(500);
i2s_codec_write(0x01, 0x0009); //PLL on I2S
i2s_codec_write(0x07, 0x0001);
i2s_codec_write(0x11, 0x0000);
i2s_codec_write(0x00, 0x0040);
i2s_codec_write(0x0f, 0x0008); // for open pop noise
}
else
{
//for Speaker output
i2s_codec_write(0x02, 0x0020);
i2s_codec_write(0x07, 0x0001);
i2s_codec_write(0x11, 0x0000);
i2s_codec_write(0x02, 0x0000);
i2s_codec_write(0x00, 0x0040); // for close pop noise
}
}
if(rd) // recording
{
i2s_codec_write(0x02, 0x0001); // 5-11 a1
i2s_codec_write(0x07, 0x0001);
i2s_codec_write(0x11, 0x0000);
mdelay(300);
}
__gpio_as_output(17);
__gpio_clear_pin(17);//disable ak4642
__i2s_disable();
}
static int __init init_ak4642en(void)
{
set_codec_gpio_pin = set_ak4642en_gpio_pin;
each_time_init_codec = each_time_init_ak4642en;
clear_codec_mode = clear_ak4642en_mode;
set_codec_record = set_ak4642en_record;
set_codec_replay = set_ak4642en_replay;
set_replay_hp_or_speaker = set_ak4642en_replay;
set_codec_speed = set_ak4642en_speed;
clear_codec_record = clear_ak4642en_record;
clear_codec_replay = clear_ak4642en_replay;
codec_mixer_old_info_id_name = ak4642en_mixer_old_info_id_name;
codec_mixer_info_id_name = ak4642en_mixer_info_id_name;
set_codec_volume = set_ak4642en_volume;
set_codec_mic = set_ak4642en_mic;
i2s_resume_codec = resume_ak4642en;
i2s_suspend_codec = suspend_ak4642en;
printk("---> ak4642en initialization!\n");
return 0;
}
static void __exit cleanup_ak4642en(void)
{
spk_hp = 0;
i2s_codec_write(0x01, 0x0008);//master,PLL disable
//free_irq(JACK_PLUG_IRQ, i2s_controller);
__gpio_clear_pin(I2S_PDN);
udelay(2);
REG_SCC1_CR(SCC1_BASE) &= 0 << 31;
udelay(2);
}
module_init(init_ak4642en);
module_exit(cleanup_ak4642en);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,443 +0,0 @@
/*
* linux/drivers/sound/jzcodec.c
*
* JzSOC internal audio driver.
*
*/
#include <linux/init.h>
#include <linux/interrupt.h>
#include <sound/driver.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/sound.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <linux/proc_fs.h>
#include <linux/soundcard.h>
#include <linux/dma-mapping.h>
#include <linux/mutex.h>
#include <linux/mm.h>
#include <asm/hardirq.h>
#include <asm/jzsoc.h>
#include "sound_config.h"
#define USE_NONE 1
#define USE_MIC 2
#define USE_LINEIN 3
typedef struct hpvol_shift_s
{
int hpvol;
int shift;
} hpvol_shift_t;
extern mixer_info info;
extern _old_mixer_info old_info;
extern int codec_volue_shift;
extern hpvol_shift_t hpvol_shift_table[72];
extern int abnormal_data_count;
extern void (*set_codec_mode)(void);
extern void (*each_time_init_codec)(void);
extern int (*set_codec_startup_param)(void);
extern void (*set_codec_volume_table)(void);
extern void (*set_codec_record)(int mode);
extern void (*set_codec_replay)(void);
extern void (*set_codec_replay_record)(int mode);
extern void (*turn_on_codec)(void);
extern void (*turn_off_codec)(void);
extern void (*set_codec_speed)(int rate);
extern void (*reset_codec)(void);
extern void (*codec_mixer_old_info_id_name)(void);
extern void (*codec_mixer_info_id_name)(void);
extern void (*set_codec_bass)(int val);
extern void (*set_codec_volume)(int val);
extern void (*set_codec_mic)(int val);
extern void (*set_codec_line)(int val);
extern void (*i2s_resume_codec)(void);
extern void (*i2s_suspend_codec)(void);
extern void (*set_codec_direct_mode)(void);
extern void (*clear_codec_direct_mode)(void);
static int jzcodec_reg[2];
void set_jzcodec_mode(void);
void each_time_init_jzcodec(void);
int set_jzcodec_startup_param(void);
void set_jzcodec_volume_table(void);
void set_jzcodec_replay(void);
void set_jzcodec_record(int mode);
void turn_on_jzcodec(void);
void turn_off_jzcodec(void);
void set_jzcodec_speed(int rate);
void reset_jzcodec(void);
void jzcodec_mixer_old_info_id_name(void);
void jzcodec_mixer_info_id_name(void);
void set_jzcodec_bass(int val);
void set_jzcodec_volume(int val);
void set_jzcodec_mic(int val);
void set_jzcodec_line(int val);
void in_codec_app1(void);
void in_codec_app12(void);
void HP_turn_on(void);
void HP_turn_off(void);
void resume_jzcodec(void);
void suspend_jzcodec(void);
void set_jzcodec_replay_record(int mode);
void set_jzcodec_mode(void)
{
__i2s_internal_codec();
__i2s_as_slave();
__i2s_select_i2s();
__aic_select_i2s();
REG_ICDC_CDCCR1 = 0x001b2303;
schedule_timeout(1);
REG_ICDC_CDCCR1 = 0x001b2302;
}
void each_time_init_jzcodec(void)
{
__i2s_disable();
__i2s_as_slave();
__i2s_set_oss_sample_size(16);
__i2s_set_iss_sample_size(16);
}
int set_jzcodec_startup_param(void)
{
REG_ICDC_CDCCR1 = 0x001b2300;
schedule_timeout(50);
REG_ICDC_CDCCR1 = 0x00033300;
schedule_timeout(5);
REG_ICDC_CDCCR1 = 0x17026300;
return 1;
}
void set_jzcodec_volume_table(void)
{
int errno,hpvol_step,sample_shift;
codec_volue_shift = 0;
hpvol_step = 3;
sample_shift = 0;
for(errno = 0;errno < 72;errno++) {
hpvol_shift_table[errno].hpvol = hpvol_step;
hpvol_shift_table[errno].shift = sample_shift;
hpvol_step --;
if(hpvol_step <= 0) {
hpvol_step = 3;
sample_shift ++;
}
}
}
void set_jzcodec_replay(void)
{
in_codec_app1();
}
void set_jzcodec_record(int mode)
{
switch (mode) {
case USE_NONE:
case USE_MIC:
in_codec_app12();
abnormal_data_count = 0;
break;
case USE_LINEIN:
REG_ICDC_CDCCR1 = 0x27022000;//for linein
mdelay(300);
break;
}
}
void set_jzcodec_replay_record(int mode)
{
long val = 0;
REG_ICDC_CDCCR1 = 0x00037302;
mdelay(2);
REG_ICDC_CDCCR1 = 0x03006000;
mdelay(2);
switch (mode) {
case USE_NONE:
case USE_MIC:
REG_ICDC_CDCCR1 = 0x17022000;//for mic
break;
case USE_LINEIN:
REG_ICDC_CDCCR1 = 0x27022000;//for linein
break;
}
val = REG_ICDC_CDCCR2;
val &= 0x0000ff00;
val |= 0x00170030;
REG_ICDC_CDCCR2 = val;
}
void turn_on_jzcodec(void)
{
HP_turn_on();
}
void set_jzcodec_direct_mode(void)
{
long val = 0;
REG_ICDC_CDCCR1 = 0x14000000;
val &= 0x0000ff00;
val |= 0x001f0033;
REG_ICDC_CDCCR2 = val;
mdelay(300);
}
void clear_jzcodec_direct_mode(void)
{
HP_turn_off();
}
void turn_off_jzcodec(void)
{
HP_turn_off();
}
void set_jzcodec_speed(int rate)
{
long codec_speed,speed = 0;
switch (rate) {
case 8000:
speed = 0;
break;
case 11025:
speed = 1;
break;
case 12000:
speed = 2;
break;
case 16000:
speed = 3;
break;
case 22050:
speed = 4;
break;
case 24000:
speed = 5;
break;
case 32000:
speed = 6;
break;
case 44100:
speed = 7;
break;
case 48000:
speed = 8;
break;
default:
break;
}
codec_speed = REG_ICDC_CDCCR2;
codec_speed |= 0x00000f00;
speed = speed << 8;
speed |= 0xfffff0ff;
codec_speed &= speed;
REG_ICDC_CDCCR2 = codec_speed;
}
void reset_jzcodec(void)
{
REG_ICDC_CDCCR1 |= 1;
mdelay(1);
REG_ICDC_CDCCR1 &= 0xfffffffe;
}
void jzcodec_mixer_old_info_id_name(void)
{
strncpy(info.id, "JZCODEC", sizeof(info.id));
strncpy(info.name,"Jz internal codec", sizeof(info.name));
}
void jzcodec_mixer_info_id_name(void)
{
strncpy(old_info.id, "JZCODEC", sizeof(old_info.id));
strncpy(old_info.name,"Jz internal codec", sizeof(old_info.name));
}
void set_jzcodec_bass(int val)
{
int bass_gain = 0;
if(val < 25)
bass_gain = 0;
if(val >= 25 && val < 50)
bass_gain = 1;
if(val >= 50 && val < 75)
bass_gain = 2;
if(val >= 75 && val <= 100 )
bass_gain = 3;
REG_ICDC_CDCCR2 = ((REG_ICDC_CDCCR2 & ~(0x3 << 4)) | (bass_gain << 4));
}
void set_jzcodec_volume(int val)
{
unsigned int sample_oss;
int index,shift_max,vol_scale,vol_step,codec_volume;
shift_max = 0;
sample_oss = (REG_AIC_CR & 0x00380000) >> 19;
switch(sample_oss)
{
case 0x0:
shift_max = 4; /* 8 bits */
break;
case 0x1:
shift_max = 10; /* 16 bits */
break;
case 0x2:
shift_max = 12; /* 18 bits */
break;
case 0x3:
shift_max = 15; /* 20 bits */
break;
case 0x4:
shift_max = 19; /* 24 bits */
break;
}
vol_scale = 3 * (shift_max + 1);
vol_step = 100 / vol_scale;
for(index = 0;index <= 100;index += vol_step)
if( val <= index )
break;
if(index == 0)
index = vol_step;
index = index / vol_step;
if(index > vol_scale)
index = vol_scale;
index = vol_scale - index;
codec_volume = hpvol_shift_table[index].hpvol;
codec_volue_shift = hpvol_shift_table[index].shift;
codec_volume = 3;
REG_ICDC_CDCCR2 = ((REG_ICDC_CDCCR2 & ~(0x3)) | codec_volume);
}
void set_jzcodec_mic(int val)
{
long mic_gain;
mic_gain = 31 * val /100;
REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 | (0x3 << 4));
REG_ICDC_CDCCR2 = ((REG_ICDC_CDCCR2 & ~(0x1f << 16)) | (mic_gain << 16));
}
void set_jzcodec_line(int val)
{
long line_gain;
line_gain = 31 * val /100;
REG_ICDC_CDCCR2 = ((REG_ICDC_CDCCR2 & ~(0x1f << 16)) | (line_gain << 16));
}
void HP_turn_on(void)
{
long val = 0;
/* simple and slow anti-pop */
REG_ICDC_CDCCR1 = 0x00037302;
mdelay(2);
REG_ICDC_CDCCR1 = 0x03006000;
mdelay(2);
REG_ICDC_CDCCR1 = 0x03002000;
val = REG_ICDC_CDCCR2;
val &= 0x0000ff00;
val |= 0x001f0033;
REG_ICDC_CDCCR2 = val;
}
void HP_turn_off(void)
{
mdelay(20);
REG_ICDC_CDCCR1 = 0x00033300;
}
void in_codec_app1(void)
{
/* test is OK */
HP_turn_on();
}
void in_codec_app12(void)
{
REG_ICDC_CDCCR1 = 0x14024300;
mdelay(300);
}
void resume_jzcodec(void)
{
REG_ICDC_CDCCR2 = 0x00170800;
mdelay(2);
REG_ICDC_CDCCR1 = 0x001f2102;
mdelay(5);
REG_ICDC_CDCCR1 = 0x00033302;
mdelay(550);
REG_ICDC_CDCCR1 = 0x00033300;
REG_ICDC_CDCCR1 = jzcodec_reg[0];
REG_ICDC_CDCCR2 = jzcodec_reg[1];
}
void suspend_jzcodec(void)
{
jzcodec_reg[0] = REG_ICDC_CDCCR1;
jzcodec_reg[1] = REG_ICDC_CDCCR2;
REG_ICDC_CDCCR1 = 0x001b2302;
mdelay(1);
REG_ICDC_CDCCR1 = 0x001b2102;
}
static int __init init_jzcodec(void)
{
set_codec_mode = set_jzcodec_mode;
each_time_init_codec = each_time_init_jzcodec;
set_codec_startup_param = set_jzcodec_startup_param;
set_codec_volume_table = set_jzcodec_volume_table;
set_codec_record = set_jzcodec_record;
set_codec_replay = set_jzcodec_replay;
set_codec_replay_record = set_jzcodec_replay_record;
turn_on_codec = turn_on_jzcodec;
turn_off_codec = turn_off_jzcodec;
set_codec_speed = set_jzcodec_speed;
reset_codec = reset_jzcodec;
codec_mixer_old_info_id_name = jzcodec_mixer_old_info_id_name;
codec_mixer_info_id_name = jzcodec_mixer_info_id_name;
set_codec_bass = set_jzcodec_bass;
set_codec_volume = set_jzcodec_volume;
set_codec_mic = set_jzcodec_mic;
set_codec_line = set_jzcodec_line;
i2s_resume_codec = resume_jzcodec;
i2s_suspend_codec = suspend_jzcodec;
set_codec_direct_mode = set_jzcodec_direct_mode;
clear_codec_direct_mode = clear_jzcodec_direct_mode;
return 0;
}
static void __exit cleanup_jzcodec(void)
{
REG_ICDC_CDCCR1 = 0x001b2302;
}
module_init(init_jzcodec);
module_exit(cleanup_jzcodec);

View File

@ -1,644 +0,0 @@
/*
* linux/drivers/sound/jzcodec.c
*
* JzSOC internal audio driver.
*
*/
#include <linux/init.h>
#include <linux/interrupt.h>
#include <sound/driver.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/sound.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <linux/proc_fs.h>
#include <linux/soundcard.h>
#include <linux/dma-mapping.h>
#include <linux/mutex.h>
#include <linux/mm.h>
#include <asm/hardirq.h>
#include <asm/jzsoc.h>
#include "sound_config.h"
#include "jzdlv.h"
#define USE_NONE 1
#define USE_MIC 2
#define USE_LINEIN 3
extern mixer_info info;
extern _old_mixer_info old_info;
extern int codec_volue_shift;
extern void (*set_codec_mode)(void);
extern void (*each_time_init_codec)(void);
extern int (*set_codec_startup_param)(void);
extern void (*set_codec_record)(void);
extern void (*set_codec_replay)(void);
extern void (*set_codec_replay_record)(void);
extern void (*turn_on_codec)(void);
extern void (*turn_off_codec)(void);
extern void (*set_codec_speed)(int rate);
extern void (*reset_codec)(void);
extern void (*codec_mixer_old_info_id_name)(void);
extern void (*codec_mixer_info_id_name)(void);
extern void (*set_codec_bass)(int val);
extern void (*set_codec_volume)(int val);
extern void (*set_codec_mic)(int val);
extern void (*set_codec_line)(int val);
extern void (*i2s_resume_codec)(void);
extern void (*i2s_suspend_codec)(void);
extern void (*set_codec_direct_mode)(void);
extern void (*clear_codec_direct_mode)(void);
void set_dlv_mode(void);
void each_time_init_jzcodec(void);
int set_dlv_startup_param(void);
void set_dlvjzcodec_volume_table(void);
void set_dlv_replay(void);
void set_dlv_record(void);
void set_dlv_speed(int rate);
void reset_dlv(void);
void jzcodec_mixer_old_info_id_name(void);
void jzcodec_mixer_info_id_name(void);
void set_dlv_volume(int val);
void set_dlv_mic(int val);
extern int jz_mic_only;
int read_codec_file(int addr)
{
while (__icdc_rgwr_ready());
__icdc_set_addr(addr);
mdelay(1);
return(__icdc_get_value());
}
#if 0
void printk_codec_files(void)
{
int cnt;
printk("\n");
printk("REG_CPM_I2SCDR=0x%08x\n",REG_CPM_I2SCDR);
printk("REG_CPM_CLKGR=0x%08x\n",REG_CPM_CLKGR);
printk("REG_CPM_CPCCR=0x%08x\n",REG_CPM_CPCCR);
printk("REG_AIC_FR=0x%08x\n",REG_AIC_FR);
printk("REG_AIC_CR=0x%08x\n",REG_AIC_CR);
printk("REG_AIC_I2SCR=0x%08x\n",REG_AIC_I2SCR);
printk("REG_AIC_SR=0x%08x\n",REG_AIC_SR);
printk("REG_ICDC_RGDATA=0x%08x\n",REG_ICDC_RGDATA);
for (cnt = 0; cnt <= 27 ; cnt++) {
printk(" ( %d : 0x%x ) ",cnt ,read_codec_file(cnt));
}
printk("\n");
}
#endif
void write_codec_file(int addr, int val)
{
while (__icdc_rgwr_ready());
__icdc_set_addr(addr);
__icdc_set_cmd(val); /* write */
mdelay(1);
__icdc_set_rgwr();
mdelay(1);
}
int write_codec_file_bit(int addr, int bitval, int mask_bit)
{
int val;
while (__icdc_rgwr_ready());
__icdc_set_addr(addr);
mdelay(1);
val = __icdc_get_value(); /* read */
while (__icdc_rgwr_ready());
__icdc_set_addr(addr);
val &= ~(1 << mask_bit);
if (bitval == 1)
val |= 1 << mask_bit;
__icdc_set_cmd(val); /* write */
mdelay(1);
__icdc_set_rgwr();
mdelay(1);
while (__icdc_rgwr_ready());
__icdc_set_addr(addr);
val = __icdc_get_value(); /* read */
if (((val >> mask_bit) & bitval) == bitval)
return 1;
else
return 0;
}
void set_dlv_mode(void)
{
/*REG_CPM_CPCCR &= ~(1 << 31);
REG_CPM_CPCCR &= ~(1 << 30);*/
write_codec_file(0, 0xf);
REG_AIC_I2SCR = 0x10;
__i2s_internal_codec();
__i2s_as_slave();
__i2s_select_i2s();
__aic_select_i2s();
__aic_reset();
mdelay(10);
REG_AIC_I2SCR = 0x10;
mdelay(20);
/* power on DLV */
write_codec_file(9, 0xff);
write_codec_file(8, 0x3f);
mdelay(10);
}
void reset_dlv_codec(void)
{
/* reset DLV codec. from hibernate mode to sleep mode */
write_codec_file(0, 0xf);
write_codec_file_bit(6, 0, 0);
write_codec_file_bit(6, 0, 1);
mdelay(200);
//write_codec_file(0, 0xf);
write_codec_file_bit(5, 0, 7);//PMR1.SB_DAC->0
write_codec_file_bit(5, 0, 4);//PMR1.SB_ADC->0
mdelay(10);//wait for stability
}
void each_time_init_dlv(void)
{
__i2s_disable();
__i2s_as_slave();
__aic_internal_codec();
__i2s_set_oss_sample_size(16);
__i2s_set_iss_sample_size(16);
}
int set_dlv_startup_param(void)
{
__i2s_disable_transmit_intr();
__i2s_disable_receive_intr();
return 1;
}
/* set Audio data replay */
void set_audio_data_replay(void)
{
/* DAC path */
write_codec_file(9, 0xff);
//write_codec_file(8, 0x30);
write_codec_file(8, 0x20);
mdelay(10);
write_codec_file_bit(1, 0, 4);//CR1.HP_DIS->0
write_codec_file_bit(5, 1, 3);//PMR1.SB_LIN->1
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(1, 0, 2);//CR1.BYPASS->0
write_codec_file_bit(1, 1, 3);//CR1.DACSEL->1
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
//mdelay(100);
//write_codec_file_bit(5, 0, 6);//PMR1.SB_OUT->0
write_codec_file_bit(1, 1, 7);//CR1.SB_MICBIAS->1
//mdelay(300);
}
#if 1 /* mask warning */
/* set Record MIC input audio without playback */
void set_record_mic_input_audio_without_playback(void)
{
/* ADC path for MIC IN */
jz_mic_only = 1;
write_codec_file(9, 0xff);
write_codec_file(8, 0x3f);
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
mdelay(10);
write_codec_file_bit(1, 1, 2);
//write_codec_file_bit(1, 1, 6);//CR1.MONO->1
write_codec_file(22, 0x40);//mic 1
write_codec_file_bit(3, 1, 7);//CR1.HP_DIS->1
write_codec_file_bit(5, 1, 3);//PMR1.SB_LIN->1
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(1, 0, 2);//CR1.BYPASS->0
write_codec_file_bit(1, 0, 3);//CR1.DACSEL->0
//write_codec_file_bit(6, 1, 3);// gain set
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
mdelay(100);
write_codec_file_bit(5, 0, 6);//PMR1.SB_OUT->0
write_codec_file(1, 0x4);
}
#endif
#if 1 /* mask warning */
/* unset Record MIC input audio without playback */
void unset_record_mic_input_audio_without_playback(void)
{
/* ADC path for MIC IN */
jz_mic_only = 0;
write_codec_file_bit(5, 1, 4);//SB_ADC->1
write_codec_file_bit(1, 1, 7);//CR1.SB_MICBIAS->1
write_codec_file(22, 0xc0);//CR3.SB_MIC1
write_codec_file_bit(5, 1, 6);//PMR1.SB_OUT->1
write_codec_file_bit(1, 1, 5);//DAC_MUTE->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
#if 0 /* mask warning */
/* set Record LINE input audio without playback */
void set_record_line_input_audio_without_playback(void)
{
/* ADC path for LINE IN */
jz_mic_only = 1;
write_codec_file(9, 0xff);
write_codec_file(8, 0x3f);
mdelay(10);
write_codec_file(22, 0xf6);//line in 1
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
write_codec_file_bit(3, 1, 7);//CR1.HP_DIS->1
write_codec_file_bit(5, 0, 3);//PMR1.SB_LIN->0
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(1, 0, 2);//CR1.BYPASS->0
write_codec_file_bit(1, 0, 3);//CR1.DACSEL->0
mdelay(10);
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
mdelay(100);
write_codec_file_bit(5, 0, 6);//PMR1.SB_OUT->0
write_codec_file(1, 0x4);
}
#endif
#if 0 /* mask warning */
/* unset Record LINE input audio without playback */
void unset_record_line_input_audio_without_playback(void)
{
/* ADC path for LINE IN */
write_codec_file_bit(5, 1, 4);//SB_ADC->1
write_codec_file_bit(5, 1, 3);//ONR1.SB_LIN->1
write_codec_file(22, 0xc0);//CR3.SB_MIC1
write_codec_file_bit(5, 1, 6);//PMR1.SB_OUT->1
write_codec_file_bit(1, 1, 5);//DAC_MUTE->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
#if 0 /* mask warning */
/* set Playback LINE input audio direct only */
void set_playback_line_input_audio_direct_only(void)
{
jz_audio_reset();//or init_codec()
REG_AIC_I2SCR = 0x10;
write_codec_file(9, 0xff);
write_codec_file(8, 0x3f);
mdelay(10);
write_codec_file(22, 0xf6);//line in 1
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
mdelay(10);
write_codec_file_bit(1, 1, 2);//CR1.HP_BYPASS->1
write_codec_file_bit(1, 0, 4);//CR1.HP_DIS->0
write_codec_file_bit(1, 0, 3);//CR1.DACSEL->0
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(5, 0, 3);//PMR1.SB_LIN->0
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
mdelay(100);
write_codec_file_bit(5, 0, 6);//PMR1.SB_OUT->0
//write_codec_file_bit(5, 1, 7);//PMR1.SB_DAC->1
//write_codec_file_bit(5, 1, 4);//PMR1.SB_ADC->1
}
#endif
#if 0 /* mask warning */
/* unset Playback LINE input audio direct only */
void unset_playback_line_input_audio_direct_only(void)
{
write_codec_file_bit(6, 0, 3);//GIM->0
write_codec_file_bit(1, 0, 2);//PMR1.BYPASS->0
write_codec_file_bit(5, 1, 3);//PMR1.SB_LINE->1
write_codec_file_bit(5, 1, 6);//PMR1.SB_OUT->1
mdelay(100);
write_codec_file_bit(5, 1, 5);//PMR1.SB_MIX->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
#if 0 /* mask warning */
/* set Record MIC input audio with direct playback */
void set_record_mic_input_audio_with_direct_playback(void)
{
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
jz_mic_only = 0;
write_codec_file(9, 0xff);
write_codec_file(8, 0x3f);
mdelay(10);
write_codec_file(22, 0x60);//mic 1
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
write_codec_file_bit(5, 1, 3);//PMR1.SB_LIN->1
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(1, 0, 7);//CR1.SB_MICBIAS->0
write_codec_file_bit(1, 0, 4);//CR1.HP_DIS->0
write_codec_file_bit(1, 0, 2);//CR1.BYPASS->0
write_codec_file_bit(1, 0, 3);//CR1.DACSEL->0
write_codec_file_bit(6, 1, 3);// gain set
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
mdelay(100);
write_codec_file_bit(5, 0, 6);//PMR1.SB_OUT->0
//write_codec_file(1, 0x4);
}
#endif
#if 0 /* mask warning */
/* unset Record MIC input audio with direct playback */
void unset_record_mic_input_audio_with_direct_playback(void)
{
/* ADC path for MIC IN */
jz_mic_only = 0;
write_codec_file_bit(5, 1, 4);//SB_ADC->1
write_codec_file_bit(1, 1, 7);//CR1.SB_MICBIAS->1
write_codec_file(22, 0xc0);//CR3.SB_MIC1
write_codec_file_bit(5, 1, 6);//PMR1.SB_OUT->1
write_codec_file_bit(1, 1, 5);//DAC_MUTE->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
#if 0 /* mask warning */
/* set Record playing audio mixed with MIC input audio */
void set_record_playing_audio_mixed_with_mic_input_audio(void)
{
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
write_codec_file(9, 0xff);
//write_codec_file(8, 0x30);
write_codec_file(8, 0x20);
mdelay(10);
write_codec_file(22, 0x63);//mic 1
write_codec_file_bit(1, 0, 2);//CR1.BYPASS->0
write_codec_file_bit(6, 1, 3);// gain set
write_codec_file_bit(1, 0, 4);//CR1.HP_DIS->0
write_codec_file_bit(5, 1, 3);//PMR1.SB_LIN->1
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(1, 0, 7);//CR1.SB_MICBIAS->0
write_codec_file_bit(22, 0, 7);//CR3.SB_MIC->0
write_codec_file_bit(1, 1, 3);//CR1.DACSEL->1
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
write_codec_file_bit(5, 0, 4);//PMR1.SB_MIX->0
}
#endif
#if 0 /* mask warning */
/* unset Record playing audio mixed with MIC input audio */
void unset_record_playing_audio_mixed_with_mic_input_audio(void)
{
/* ADC path */
write_codec_file_bit(5, 1, 4);//SB_ADC->1
write_codec_file_bit(1, 1, 7);//CR1.SB_MICBIAS->1
//write_codec_file_bit(1, 1, 6);//CR1.MONO->1
write_codec_file(22, 0xc0);//CR3.SB_MIC1->1
//write_codec_file_bit(1, 1, 5);//DAC_MUTE->1
//write_codec_file_bit(5, 1, 6);//SB_OUT->1
write_codec_file_bit(5, 1, 7);//SB_DAC->1
write_codec_file_bit(5, 1, 5);//SB_MIX->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
#if 1 /* mask warning */
/* set Record MIC input audio with Audio data replay (full duplex) */
void set_record_mic_input_audio_with_audio_data_replay(void)
{
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
write_codec_file(9, 0xff);
//write_codec_file(8, 0x30);
write_codec_file(8, 0x20);
write_codec_file_bit(1, 0, 4);//CR1.HP_DIS->0
write_codec_file_bit(5, 1, 3);//PMR1.SB_LIN->1
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(22, 0, 7);//CR3.SB_MIC->0
write_codec_file_bit(1, 0, 7);//CR1.SB_MICBIAS->0
write_codec_file_bit(1, 1, 3);//CR1.DACSEL->1
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
}
#endif
#if 1 /* mask warning */
/* unset Record MIC input audio with Audio data replay (full duplex) */
void unset_record_mic_input_audio_with_audio_data_replay(void)
{
/* ADC path */
write_codec_file_bit(5, 1, 4);//SB_ADC->1
write_codec_file_bit(1, 1, 7);//CR1.SB_MICBIAS->1
//write_codec_file_bit(1, 1, 6);//CR1.MONO->1
write_codec_file(22, 0xc0);//CR3.SB_MIC1->1
write_codec_file_bit(5, 1, 7);//SB_DAC->1
write_codec_file_bit(5, 1, 5);//SB_MIX->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
#if 1 /* mask warning */
/* set Record LINE input audio with Audio data replay (full duplex for linein) */
void set_record_line_input_audio_with_audio_data_replay(void)
{
write_codec_file(9, 0xff);
//write_codec_file(8, 0x30);
write_codec_file(8, 0x20);
write_codec_file_bit(1, 0, 4);//CR1.HP_DIS->0
write_codec_file_bit(5, 0, 3);//PMR1.SB_LIN->0
write_codec_file_bit(5, 1, 0);//PMR1.SB_IND->1
write_codec_file_bit(1, 1, 7);//CR1.SB_MICBIAS->1
//write_codec_file_bit(22, 1, 7);//CR3.SB_MIC->1
write_codec_file_bit(1, 1, 3);//CR1.DACSEL->1
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
//jz_mic_only = 1;
write_codec_file(22, 0xc6);//line in 1
write_codec_file_bit(23, 0, 7);//AGC1.AGC_EN->0
write_codec_file_bit(1, 0, 2);//CR1.BYPASS->0
write_codec_file_bit(5, 0, 5);//PMR1.SB_MIX->0
}
#endif
#if 1 /* mask warning */
/* unset Record LINE input audio with Audio data replay (full duplex for linein) */
void unset_record_line_input_audio_with_audio_data_replay(void)
{
/* ADC path */
write_codec_file_bit(5, 1, 4);//SB_ADC->1
write_codec_file_bit(1, 1, 7);//CR1.SB_MICBIAS->1
//write_codec_file_bit(1, 1, 6);//CR1.MONO->1
write_codec_file(22, 0xc0);//CR3.SB_MIC1->1
write_codec_file_bit(5, 1, 7);//SB_DAC->1
write_codec_file_bit(5, 1, 5);//SB_MIX->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
#if 1
/* unset Audio data replay */
void unset_audio_data_replay(void)
{
//write_codec_file_bit(1, 1, 5);//DAC_MUTE->1
//mdelay(800);
//write_codec_file_bit(5, 1, 6);//SB_OUT->1
//mdelay(800);
write_codec_file_bit(5, 1, 7);//SB_DAC->1
write_codec_file_bit(5, 1, 4);//SB_MIX->1
write_codec_file_bit(6, 1, 0);//SB_SLEEP->1
write_codec_file_bit(6, 1, 1);//SB->1
}
#endif
void set_dlv_replay(void)
{
set_audio_data_replay();
}
void set_dlv_speed(int rate)
{
int speed = 0, val;
speed = 0;
switch (rate) {
case 8000:
speed = 10;
break;
case 9600:
speed = 9;
break;
case 11025:
speed = 8;
break;
case 12000:
speed = 7;
break;
case 16000:
speed = 6;
break;
case 22050:
speed = 5;
break;
case 24000:
speed = 4;
break;
case 32000:
speed = 3;
break;
case 44100:
speed = 2;
break;
case 48000:
speed = 1;
break;
case 96000:
speed = 0;
break;
default:
break;
}
val = read_codec_file(4);
val = (speed << 4) | speed;
write_codec_file(4, val);
}
void reset_jzcodec(void)
{
}
void dlv_mixer_old_info_id_name(void)
{
strncpy(info.id, "JZDLV", sizeof(info.id));
strncpy(info.name,"Jz internal codec dlv on jz4750", sizeof(info.name));
}
void dlv_mixer_info_id_name(void)
{
strncpy(old_info.id, "JZDLV", sizeof(old_info.id));
strncpy(old_info.name,"Jz internal codec dlv on jz4750", sizeof(old_info.name));
}
void set_dlv_mic(int val)
{
int cur_vol ;
/* set gain */
//write_codec_file_bit(6, 1, 3);//GIM
cur_vol = 31 * val / 100;
cur_vol |= cur_vol << 4;
write_codec_file(19, cur_vol);//GIL,GIR
}
void set_dlv_line(int val)
{
int cur_vol;
/* set gain */
cur_vol = 31 * val / 100;
cur_vol &= 0x1f;
write_codec_file(11, cur_vol);//GO1L
write_codec_file(12, cur_vol);//GO1R
}
void set_dlv_volume(int val)
{
unsigned long cur_vol;
cur_vol = 31 * (100 - val) / 100;
write_codec_file(17, cur_vol | 0xc0);
write_codec_file(18, cur_vol);
}
static int __init init_dlv(void)
{
set_codec_mode = set_dlv_mode;
each_time_init_codec = each_time_init_dlv;
reset_codec = reset_dlv_codec;
set_codec_startup_param = set_dlv_startup_param;
set_codec_replay = set_dlv_replay;
set_codec_speed = set_dlv_speed;
codec_mixer_old_info_id_name = dlv_mixer_old_info_id_name;
codec_mixer_info_id_name = dlv_mixer_info_id_name;
set_codec_volume = set_dlv_volume;
set_codec_mic = set_dlv_mic;
set_codec_line = set_dlv_line;
return 0;
}
static void __exit cleanup_dlv(void)
{
}
module_init(init_dlv);
module_exit(cleanup_dlv);

View File

@ -1,21 +0,0 @@
/* header file for dlv */
void write_codec_file(int addr, int val);
int read_codec_file(int addr);
void printk_codec_files(void);
int write_codec_file_bit(int addr, int bitval, int mask_bit);
void set_audio_data_replay(void);
void unset_audio_data_replay(void);
void set_record_mic_input_audio_without_playback(void);
void unset_record_mic_input_audio_without_playback(void);
void set_record_line_input_audio_without_playback(void);
void unset_record_line_input_audio_without_playback(void);
void set_playback_line_input_audio_direct_only(void);
void unset_playback_line_input_audio_direct_only(void);
void set_record_mic_input_audio_with_direct_playback(void);
void unset_record_mic_input_audio_with_direct_playback(void);
void set_record_playing_audio_mixed_with_mic_input_audio(void);
void unset_record_playing_audio_mixed_with_mic_input_audio(void);
void set_record_mic_input_audio_with_audio_data_replay(void);
void unset_record_mic_input_audio_with_audio_data_replay(void);
void set_record_line_input_audio_with_audio_data_replay(void);
void unset_record_line_input_audio_with_audio_data_replay(void);

View File

@ -5777,113 +5777,6 @@ diff -ru linux-2.6/sound/core/pcm_native.c /plain/src/qi/linux-2.6.27.git.svn/so
}
static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params,
diff -ru linux-2.6/sound/oss/Kconfig /plain/src/qi/linux-2.6.27.git.svn/sound/oss/Kconfig
--- linux-2.6/sound/oss/Kconfig 2009-08-17 23:58:04.000000000 +0200
+++ /plain/src/qi/linux-2.6.27.git.svn/sound/oss/Kconfig 2009-08-12 10:39:09.000000000 +0200
@@ -5,6 +5,75 @@
#
# Prompt user for primary drivers.
+config OSS_OBSOLETE
+ bool "Obsolete OSS drivers"
+ depends on SOUND_PRIME
+ help
+ This option enables support for obsolete OSS drivers that
+ are scheduled for removal in the near future.
+
+ Please contact Adrian Bunk <bunk@stusta.de> if you had to
+ say Y here because your hardware is not properly supported
+ by ALSA.
+
+ If unsure, say N.
+
+config SOUND_JZ_AC97
+ bool "Jz On-Chip AC97 driver"
+ depends on OSS_OBSOLETE
+ help
+ Say Y here if you have want to select the on-chip AC97 driver
+ on Jz4730/Jz4740/Jz5730.
+
+config SOUND_JZ_I2S
+ bool "Jz On-Chip I2S driver"
+ depends on OSS_OBSOLETE
+ help
+ Say Y here if you have want to select the on-chip I2S driver
+ on Jz4730/Jz4740/Jz5730.
+
+config SOUND_JZ_PCM
+ bool "Jz On-Chip PCM driver"
+ depends on SOC_JZ4750
+ help
+ Say Y here if you have want to select the on-chip PCM driver
+ on Jz4750.
+
+choice
+ prompt "I2S codec type"
+ depends on SOUND_JZ_I2S
+
+config I2S_AK4642EN
+ bool "AK4642EN"
+ depends on SOC_JZ4730
+ help
+ Answer Y if you have an external AK4642EN codec.
+
+config I2S_ICODEC
+ bool "Internal On-Chip codec"
+ depends on SOC_JZ4740
+ help
+ Answer Y if you have an internal I2S codec.
+
+config I2S_DLV
+ bool "Internal On-Chip codec on Jz4750 or Jz4750d"
+ depends on SOC_JZ4750 || SOC_JZ4750D
+ help
+ Answer Y if you have an internal I2S codec on Jz4750 or Jz4750d.
+
+endchoice
+
+choice
+ prompt "PCM codec type"
+ depends on SOUND_JZ_PCM
+
+config PCM_TLV320AIC1106
+ bool "TLV320AIC1106"
+ help
+ Answer Y if you have an TI tlv320aic 1106 codec.
+
+endchoice
+
config SOUND_BCM_CS4297A
tristate "Crystal Sound CS4297a (for Swarm)"
depends on SIBYTE_SWARM
diff -ru linux-2.6/sound/oss/Makefile /plain/src/qi/linux-2.6.27.git.svn/sound/oss/Makefile
--- linux-2.6/sound/oss/Makefile 2009-08-17 23:58:04.000000000 +0200
+++ /plain/src/qi/linux-2.6.27.git.svn/sound/oss/Makefile 2009-08-12 10:39:09.000000000 +0200
@@ -9,6 +9,12 @@
# Please leave it as is, cause the link order is significant !
+obj-$(CONFIG_SOUND_JZ_AC97) += jz_ac97.o ac97_codec.o
+obj-$(CONFIG_I2S_AK4642EN) += ak4642en.o
+obj-$(CONFIG_I2S_ICODEC) += jzcodec.o jz_i2s.o
+obj-$(CONFIG_I2S_DLV) += jzdlv.o jz_i2s.o
+obj-$(CONFIG_SOUND_JZ_PCM) += jz_pcm_tlv320aic1106_dma.o
+
obj-$(CONFIG_SOUND_SH_DAC_AUDIO) += sh_dac_audio.o
obj-$(CONFIG_SOUND_HAL2) += hal2.o
obj-$(CONFIG_SOUND_AEDSP16) += aedsp16.o
diff -ru linux-2.6/sound/oss/os.h /plain/src/qi/linux-2.6.27.git.svn/sound/oss/os.h
--- linux-2.6/sound/oss/os.h 2009-08-17 23:57:37.000000000 +0200
+++ /plain/src/qi/linux-2.6.27.git.svn/sound/oss/os.h 2009-08-12 10:39:09.000000000 +0200
@@ -9,7 +9,7 @@
#ifdef __KERNEL__
#include <linux/string.h>
#include <linux/fs.h>
-#include <asm/dma.h>
+//#include <asm/dma.h>
#include <asm/io.h>
#include <asm/param.h>
#include <linux/sched.h>
diff -ru linux-2.6/sound/soc/codecs/Kconfig /plain/src/qi/linux-2.6.27.git.svn/sound/soc/codecs/Kconfig
--- linux-2.6/sound/soc/codecs/Kconfig 2009-08-17 23:58:04.000000000 +0200
+++ /plain/src/qi/linux-2.6.27.git.svn/sound/soc/codecs/Kconfig 2009-08-12 10:39:09.000000000 +0200