Merge branch 'develop' of 10.10.10.29:/home/rockchip/kernel into develop

This commit is contained in:
徐建辉
2011-04-28 10:20:58 +08:00
17 changed files with 22765 additions and 799 deletions

View File

@@ -32,6 +32,7 @@
#define RK29_CAM_EIO_INVALID -1
#define RK29_CAM_EIO_REQUESTFAIL -2
#define RK29_CAM_SENSOR_OV7675 ov7675
#define RK29_CAM_SENSOR_OV9650 ov9650
#define RK29_CAM_SENSOR_OV2655 ov2655
#define RK29_CAM_SENSOR_OV2659 ov2659
@@ -44,8 +45,15 @@
#define RK29_CAM_SENSOR_MT9P111 mt9p111
#define RK29_CAM_SENSOR_GT2005 gt2005
#define RK29_CAM_SENSOR_GC0308 gc0308
#define RK29_CAM_SENSOR_GC0309 gc0309
#define RK29_CAM_SENSOR_GC2015 gc2015
#define RK29_CAM_SENSOR_SIV120B siv120b
#define RK29_CAM_SENSOR_SID130B sid130B
#define RK29_CAM_SENSOR_HI253 hi253
#define RK29_CAM_SENSOR_HI704 hi704
#define RK29_CAM_SENSOR_NT99250 nt99250
#define RK29_CAM_SENSOR_NAME_OV7675 "ov7675"
#define RK29_CAM_SENSOR_NAME_OV9650 "ov9650"
#define RK29_CAM_SENSOR_NAME_OV2655 "ov2655"
#define RK29_CAM_SENSOR_NAME_OV2659 "ov2659"
@@ -58,7 +66,13 @@
#define RK29_CAM_SENSOR_NAME_MT9P111 "mt9p111"
#define RK29_CAM_SENSOR_NAME_GT2005 "gt2005"
#define RK29_CAM_SENSOR_NAME_GC0308 "gc0308"
#define RK29_CAM_SENSOR_NAME_GC0309 "gc0309"
#define RK29_CAM_SENSOR_NAME_GC2015 "gc2015"
#define RK29_CAM_SENSOR_NAME_SIV120B "siv120b"
#define RK29_CAM_SENSOR_NAME_SID130B "sid130B"
#define RK29_CAM_SENSOR_NAME_HI253 "hi253"
#define RK29_CAM_SENSOR_NAME_HI704 "hi704"
#define RK29_CAM_SENSOR_NAME_NT99250 "nt99250"
#define RK29_CAM_POWERACTIVE_BITPOS 0x00
#define RK29_CAM_POWERACTIVE_MASK (1<<RK29_CAM_POWERACTIVE_BITPOS)

View File

@@ -18,14 +18,21 @@
#include <linux/delay.h>
#include <linux/string.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include <mach/rk29_lightsensor.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
static struct early_suspend cm3202_early_suspend;
#endif
struct rk29_lsr_platform_data *lightsensor;
static void lsr_report_value(struct input_dev *input_dev, int value)
{
input_report_abs(input_dev, ABS_X, value);
//input_sync(input_dev);
input_report_abs(input_dev, ABS_MISC/*ABS_X*/, value);
input_sync(input_dev);
}
@@ -219,7 +226,7 @@ static void rk29_lsr_input_init(struct platform_device *dev)
pdata->input_dev->name = "lsensor";
pdata->input_dev->dev.parent = &dev->dev;
pdata->input_dev->evbit[0] = BIT(EV_ABS);
input_set_abs_params(pdata->input_dev,ABS_X,0,0x3ff,0,0);
input_set_abs_params(pdata->input_dev,ABS_MISC/*ABS_X*/,0,9/*0x3ff*/,0,0);
ret = input_register_device(pdata->input_dev);
return ;
init_input_register_device_failed:
@@ -232,7 +239,19 @@ static void rk29_lsr_input_deinit(struct platform_device *dev)
input_unregister_device(pdata->input_dev);
input_free_device(pdata->input_dev);
}
static int lsr_suspend(struct platform_device *pdev, pm_message_t state)
{
set_lsr_timer(0);
set_lsr_value(LSR_OFF);
return 0;
}
static int lsr_resume(struct platform_device *pdev)
{
set_lsr_timer(1);
set_lsr_value(LSR_ON);
return 0;
}
static int __devinit lsr_probe(struct platform_device *pdev)
{
lightsensor = kzalloc(sizeof(struct rk29_lsr_platform_data), GFP_KERNEL);
@@ -253,6 +272,12 @@ static int __devinit lsr_probe(struct platform_device *pdev)
rk29_lsr_adc_init(pdev);
rk29_lsr_timer_init(pdev);
rk29_lsr_input_init(pdev);
#ifdef CONFIG_HAS_EARLYSUSPEND
cm3202_early_suspend.suspend = lsr_suspend;
cm3202_early_suspend.resume = lsr_resume;
register_early_suspend(&cm3202_early_suspend);
#endif
return 0;
err_kzalloc_lightsensor:
@@ -271,27 +296,11 @@ static int __devexit lsr_remove(struct platform_device *pdev)
return 0;
}
static int lsr_suspend(struct platform_device *pdev, pm_message_t state)
{
set_lsr_timer(0);
set_lsr_value(LSR_OFF);
return 0;
}
static int lsr_resume(struct platform_device *pdev)
{
set_lsr_timer(1);
set_lsr_value(LSR_ON);
return 0;
}
static struct platform_driver lsr_device_driver = {
.probe = lsr_probe,
.remove = __devexit_p(lsr_remove),
.suspend = lsr_suspend,
.resume = lsr_resume,
// .suspend = lsr_suspend,
// .resume = lsr_resume,
.driver = {
.name = LSR_NAME,
.owner = THIS_MODULE,

View File

@@ -906,11 +906,24 @@ config SOC_CAMERA_OV9650
depends on SOC_CAMERA && I2C
help
This is a ov2655 camera driver
config SOC_CAMERA_OV3640
tristate "ov3640 camera support"
depends on SOC_CAMERA && I2C
help
This is a ov3640 camera driver
This is a ov3640 camera driver
choice
prompt "OV3640 Module Focus select"
depends on SOC_CAMERA_OV3640
default OV3640_AUTOFOCUS
---help---
config OV3640_AUTOFOCUS
bool "OV3640 auto focus"
config OV3640_FIXEDFOCUS
bool "OV3640 fixed focus"
endchoice
config SOC_CAMERA_OV5642
tristate "ov5642 camera support"
@@ -964,11 +977,43 @@ config SOC_CAMERA_GC0308
depends on SOC_CAMERA && I2C
help
This is a GC0308 camera driver
config SOC_CAMERA_GC0309
tristate "GC0309 support"
depends on SOC_CAMERA && I2C
help
This is a GC0309 camera driver
config SOC_CAMERA_GC2015
tristate "GC2015 support"
depends on SOC_CAMERA && I2C
help
This is a GC2015 camera driver
config SOC_CAMERA_HI253
tristate "HI253 support"
depends on SOC_CAMERA && I2C
help
This is a HI253 camera driver
config SOC_CAMERA_HI704
tristate "HI704 support"
depends on SOC_CAMERA && I2C
help
This is a HI704 camera driver
config SOC_CAMERA_SIV120B
tristate "siv120b support"
depends on SOC_CAMERA && I2C
help
This is a SIV120B camera driver
config SOC_CAMERA_SID130B
tristate "sid130b support"
depends on SOC_CAMERA && I2C
help
This is a SID130B camera driver
config SOC_CAMERA_NT99250
tristate "NT99250 support"
depends on SOC_CAMERA && I2C
help
This is a NT99250 camera driver
config MX1_VIDEO
bool

View File

@@ -92,7 +92,13 @@ obj-$(CONFIG_SOC_CAMERA_OV5642) += ov5642.o
obj-$(CONFIG_SOC_CAMERA_S5K6AA) += s5k6aa.o
obj-$(CONFIG_SOC_CAMERA_GT2005) += gt2005.o
obj-$(CONFIG_SOC_CAMERA_GC0308) += gc0308.o
obj-$(CONFIG_SOC_CAMERA_GC0309) += gc0309.o
obj-$(CONFIG_SOC_CAMERA_GC2015) += gc2015.o
obj-$(CONFIG_SOC_CAMERA_SIV120B) += siv120b.o
obj-$(CONFIG_SOC_CAMERA_SID130B) += sid130B.o
obj-$(CONFIG_SOC_CAMERA_HI253) += hi253.o
obj-$(CONFIG_SOC_CAMERA_HI704) += hi704.o
obj-$(CONFIG_SOC_CAMERA_NT99250) += nt99250.o
# And now the v4l2 drivers:
obj-$(CONFIG_VIDEO_BT848) += bt8xx/

2449
drivers/media/video/gc0309.c Executable file

File diff suppressed because it is too large Load Diff

2655
drivers/media/video/gc2015.c Executable file

File diff suppressed because it is too large Load Diff

3504
drivers/media/video/hi253.c Executable file

File diff suppressed because it is too large Load Diff

2957
drivers/media/video/hi704.c Executable file

File diff suppressed because it is too large Load Diff

2842
drivers/media/video/nt99250.c Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

26
drivers/media/video/ov3640.h Executable file
View File

@@ -0,0 +1,26 @@
/*
* Driver for OV5642 CMOS Image Sensor from OmniVision
*
* Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
*
* 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.
*/
#ifndef __OV3640_H__
#define __OV3640_H__
struct reginfo
{
u16 reg;
u8 val;
};
#define SEQUENCE_INIT 0x00
#define SEQUENCE_NORMAL 0x01
#define SEQUENCE_PROPERTY 0xFFFD
#define SEQUENCE_WAIT_MS 0xFFFE
#define SEQUENCE_END 0xFFFF
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,17 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
#include <media/soc_camera.h>
#include <mach/rk29_camera.h>
static int debug;
module_param(debug, int, S_IRUGO|S_IWUSR);
#define dprintk(level, fmt, arg...) do { \
if (debug >= level) \
printk(KERN_WARNING fmt , ## arg); } while (0)
#define SENSOR_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__)
#define SENSOR_DG(format, ...) dprintk(0, format, ## __VA_ARGS__)
#define _CONS(a,b) a##b
#define CONS(a,b) _CONS(a,b)
@@ -29,8 +40,11 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
#define _STR(x) __STR(x)
#define STR(x) _STR(x)
#define MIN(x,y) ((x<y) ? x: y)
#define MAX(x,y) ((x>y) ? x: y)
/* Sensor Driver Configuration */
#define SENSOR_NAME ov7675
#define SENSOR_NAME RK29_CAM_SENSOR_OV7675
#define SENSOR_V4L2_IDENT V4L2_IDENT_OV7675
#define SENSOR_ID 0x76
#define SENSOR_MIN_WIDTH 640//176
@@ -55,27 +69,10 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
#define CONFIG_SENSOR_Mirror 0
#define CONFIG_SENSOR_Flip 0
#define CONFIG_SENSOR_I2C_SPEED 100000 /* Hz */
#define CONFIG_SENSOR_TR 1
#define CONFIG_SENSOR_DEBUG 1
#define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
#define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
#define MIN(x,y) ((x<y) ? x: y)
#define MAX(x,y) ((x>y) ? x: y)
#if (CONFIG_SENSOR_TR)
#define SENSOR_TR(format, ...) printk(format, ## __VA_ARGS__)
#if (CONFIG_SENSOR_DEBUG)
#define SENSOR_DG(format, ...) printk(format, ## __VA_ARGS__)
#else
#define SENSOR_DG(format, ...)
#endif
#else
#define SENSOR_TR(format, ...)
#endif
#define CONFIG_SENSOR_I2C_SPEED 250000 /* Hz */
/* Sensor write register continues by preempt_disable/preempt_enable for current process not be scheduled */
#define CONFIG_SENSOR_I2C_NOSCHED 0
#define CONFIG_SENSOR_I2C_RDWRCHK 0
#define SENSOR_BUS_PARAM (SOCAM_MASTER | SOCAM_PCLK_SAMPLE_RISING |\
SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |\
@@ -90,6 +87,9 @@ o* Driver for MT9M001 CMOS Image Sensor from Micron
#define COLOR_TEMPERATURE_HOME_DN 2500
#define COLOR_TEMPERATURE_HOME_UP 3500
#define SENSOR_NAME_STRING(a) STR(CONS(SENSOR_NAME, a))
#define SENSOR_NAME_VARFUN(a) CONS(SENSOR_NAME, a)
struct reginfo
{
u8 reg;
@@ -144,7 +144,7 @@ static struct reginfo sensor_init_data[] =
{0x0e, 0x61},
{0x0f, 0x4b},
{0x16, 0x02},
{0x1e, 0x07},
{0x1e, 0x07}, //0x27
{0x21, 0x02},
{0x22, 0x91},
{0x29, 0x07},
@@ -1082,6 +1082,14 @@ static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg);
static int sensor_resume(struct soc_camera_device *icd);
static int sensor_set_bus_param(struct soc_camera_device *icd,unsigned long flags);
static unsigned long sensor_query_bus_param(struct soc_camera_device *icd);
#if CONFIG_SENSOR_Effect
static int sensor_set_effect(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
#endif
#if CONFIG_SENSOR_WhiteBalance
static int sensor_set_whiteBalance(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value);
#endif
static int sensor_deactivate(struct i2c_client *client);
static struct soc_camera_ops sensor_ops =
{
@@ -1119,6 +1127,8 @@ typedef struct sensor_info_priv_s
int focus;
int flash;
int exposure;
bool snap2preview;
bool video2preview;
unsigned char mirror; /* HFLIP */
unsigned char flip; /* VFLIP */
unsigned int winseqe_cur_addr;
@@ -1132,6 +1142,11 @@ struct sensor
struct i2c_client *client;
sensor_info_priv_t info_priv;
int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
#if CONFIG_SENSOR_I2C_NOSCHED
atomic_t tasklock_cnt;
#endif
struct rk29camera_platform_data *sensor_io_request;
struct rk29camera_gpio_res *sensor_gpio_res;
};
static struct sensor* to_sensor(const struct i2c_client *client)
@@ -1139,6 +1154,44 @@ static struct sensor* to_sensor(const struct i2c_client *client)
return container_of(i2c_get_clientdata(client), struct sensor, subdev);
}
static int sensor_task_lock(struct i2c_client *client, int lock)
{
#if CONFIG_SENSOR_I2C_NOSCHED
int cnt = 3;
struct sensor *sensor = to_sensor(client);
if (lock) {
if (atomic_read(&sensor->tasklock_cnt) == 0) {
while ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt>0)) {
SENSOR_TR("\n %s will obtain i2c in atomic, but i2c bus is locked! Wait...\n",SENSOR_NAME_STRING());
msleep(35);
cnt--;
}
if ((atomic_read(&client->adapter->bus_lock.count) < 1) && (cnt<=0)) {
SENSOR_TR("\n %s obtain i2c fail in atomic!!\n",SENSOR_NAME_STRING());
goto sensor_task_lock_err;
}
preempt_disable();
}
atomic_add(1, &sensor->tasklock_cnt);
} else {
if (atomic_read(&sensor->tasklock_cnt) > 0) {
atomic_sub(1, &sensor->tasklock_cnt);
if (atomic_read(&sensor->tasklock_cnt) == 0)
preempt_enable();
}
}
return 0;
sensor_task_lock_err:
return -1;
#else
return 0;
#endif
}
/* sensor register write */
static int sensor_write(struct i2c_client *client, u8 reg, u8 val)
{
@@ -1159,14 +1212,14 @@ static int sensor_write(struct i2c_client *client, u8 reg, u8 val)
cnt = 3;
err = -EAGAIN;
while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
err = i2c_transfer(client->adapter, msg, 1);
if (err >= 0) {
return 0;
} else {
SENSOR_TR("\n %s write reg failed, try to write again!\n",SENSOR_NAME_STRING());
udelay(10);
SENSOR_TR("\n %s write reg(0x%x, val:0x%x) failed, try to write again!\n",SENSOR_NAME_STRING(),reg, val);
udelay(10);
}
}
@@ -1201,14 +1254,14 @@ static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
cnt = 1;
err = -EAGAIN;
while ((cnt--) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
while ((cnt-- > 0) && (err < 0)) { /* ddl@rock-chips.com : Transfer again if transent is failed */
err = i2c_transfer(client->adapter, msg, 2);
if (err >= 0) {
*val = buf[0];
return 0;
} else {
SENSOR_TR("\n %s read reg failed, try to read again! reg:0x%x \n",SENSOR_NAME_STRING(),(unsigned int)val);
SENSOR_TR("\n %s read reg(0x%x val:0x%x) failed, try to read again! \n",SENSOR_NAME_STRING(),reg, *val);
udelay(10);
}
}
@@ -1220,20 +1273,43 @@ static int sensor_read(struct i2c_client *client, u8 reg, u8 *val)
#if 1
static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
{
int err;
int err = 0, cnt;
int i = 0;
#if CONFIG_SENSOR_I2C_RDWRCHK
char valchk;
#endif
cnt = 0;
if (sensor_task_lock(client, 1) < 0)
goto sensor_write_array_end;
while (regarray[i].reg != 0)
{
err = sensor_write(client, regarray[i].reg, regarray[i].val);
if (err != 0)
if (err < 0)
{
SENSOR_TR("%s..write failed current i = %d\n", SENSOR_NAME_STRING(),i);
return err;
if (cnt-- > 0) {
SENSOR_TR("%s..write failed current reg:0x%x, Write array again !\n", SENSOR_NAME_STRING(),regarray[i].reg);
i = 0;
continue;
} else {
SENSOR_TR("%s..write array failed!!!\n", SENSOR_NAME_STRING());
err = -EPERM;
goto sensor_write_array_end;
}
} else {
#if CONFIG_SENSOR_I2C_RDWRCHK
sensor_read(client, regarray[i].reg, &valchk);
if (valchk != regarray[i].val)
SENSOR_TR("%s Reg:0x%x write(0x%x, 0x%x) fail\n",SENSOR_NAME_STRING(), regarray[i].reg, regarray[i].val, valchk);
#endif
}
i++;
}
return 0;
sensor_write_array_end:
sensor_task_lock(client,0);
return err;
}
#else
static int sensor_write_array(struct i2c_client *client, struct reginfo *regarray)
@@ -1256,7 +1332,50 @@ static int sensor_write_array(struct i2c_client *client, struct reginfo *regarra
return 0;
}
#endif
static int sensor_ioctrl(struct soc_camera_device *icd,enum rk29sensor_power_cmd cmd, int on)
{
struct soc_camera_link *icl = to_soc_camera_link(icd);
int ret = 0;
SENSOR_DG("%s %s cmd(%d) on(%d)\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd,on);
switch (cmd)
{
case Sensor_PowerDown:
{
if (icl->powerdown) {
ret = icl->powerdown(icd->pdev, on);
if (ret == RK29_CAM_IO_SUCCESS) {
if (on == 0) {
mdelay(2);
if (icl->reset)
icl->reset(icd->pdev);
}
} else if (ret == RK29_CAM_EIO_REQUESTFAIL) {
ret = -ENODEV;
goto sensor_power_end;
}
}
break;
}
case Sensor_Flash:
{
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
struct sensor *sensor = to_sensor(client);
if (sensor->sensor_io_request && sensor->sensor_io_request->sensor_ioctrl) {
sensor->sensor_io_request->sensor_ioctrl(icd->pdev,Cam_Flash, on);
}
break;
}
default:
{
SENSOR_TR("%s %s cmd(0x%x) is unknown!",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
break;
}
}
sensor_power_end:
return ret;
}
static int sensor_init(struct v4l2_subdev *sd, u32 val)
{
struct i2c_client *client = sd->priv;
@@ -1267,7 +1386,14 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
ret = -ENODEV;
goto sensor_INIT_ERR;
}
/* soft reset */
if (sensor_task_lock(client,1)<0)
goto sensor_INIT_ERR;
ret = sensor_write(client, 0x12, 0x80);
if (ret != 0)
{
@@ -1284,9 +1410,9 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
SENSOR_TR("error: %s initial failed\n",SENSOR_NAME_STRING());
goto sensor_INIT_ERR;
}
icd->user_width = SENSOR_INIT_WIDTH;
icd->user_height = SENSOR_INIT_HEIGHT;
sensor_task_lock(client,0);
//icd->user_width = SENSOR_INIT_WIDTH;
//icd->user_height = SENSOR_INIT_HEIGHT;
sensor->info_priv.winseqe_cur_addr = (int)SENSOR_INIT_WINSEQADR;
sensor->info_priv.pixfmt = SENSOR_INIT_PIXFMT;
@@ -1331,30 +1457,35 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
sensor->info_priv.focus = qctrl->default_value;
#endif
#if CONFIG_SENSOR_Flash
sensor_set_flash();
#if CONFIG_SENSOR_Flash
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_FLASH);
if (qctrl)
sensor->info_priv.flash = qctrl->default_value;
#endif
SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,icd->user_width,icd->user_height);
SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),((val == 0)?__FUNCTION__:"sensor_reinit"),icd->user_width,icd->user_height);
return 0;
sensor_INIT_ERR:
sensor_task_lock(client,0);
sensor_deactivate(client);
return ret;
}
static int sensor_deactivate(struct v4l2_subdev *sd)
static int sensor_deactivate(struct i2c_client *client)
{
//struct i2c_client *client = sd->priv;
struct soc_camera_device *icd = client->dev.platform_data;
//u8 reg_val;
SENSOR_DG("\n%s..%s.. \n",SENSOR_NAME_STRING(),__FUNCTION__);
SENSOR_DG("\n%s..%s.. Enter\n",SENSOR_NAME_STRING(),__FUNCTION__);
/* ddl@rock-chips.com : all sensor output pin must change to input for other sensor */
sensor_ioctrl(icd, Sensor_PowerDown, 1);
/* ddl@rock-chips.com : sensor config init width , because next open sensor quickly(soc_camera_open -> Try to configure with default parameters) */
icd->user_width = SENSOR_INIT_WIDTH;
icd->user_height = SENSOR_INIT_HEIGHT;
msleep(100);
return 0;
}
static struct reginfo sensor_power_down_sequence[]=
@@ -1365,32 +1496,21 @@ static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
{
int ret;
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
struct soc_camera_link *icl;
if (pm_msg.event == PM_EVENT_SUSPEND)
{
if (pm_msg.event == PM_EVENT_SUSPEND) {
SENSOR_DG("\n %s Enter Suspend.. \n", SENSOR_NAME_STRING());
ret = sensor_write_array(client, sensor_power_down_sequence) ;
if (ret != 0)
{
if (ret != 0) {
SENSOR_TR("\n %s..%s WriteReg Fail.. \n", SENSOR_NAME_STRING(),__FUNCTION__);
return ret;
}
else
{
icl = to_soc_camera_link(icd);
if (icl->power) {
ret = icl->power(icd->pdev, 0);
if (ret < 0) {
SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
return -EINVAL;
}
} else {
ret = sensor_ioctrl(icd, Sensor_PowerDown, 1);
if (ret < 0) {
SENSOR_TR("\n %s suspend fail for turn on power!\n", SENSOR_NAME_STRING());
return -EINVAL;
}
}
}
else
{
} else {
SENSOR_TR("\n %s cann't suppout Suspend..\n",SENSOR_NAME_STRING());
return -EINVAL;
}
@@ -1399,16 +1519,12 @@ static int sensor_suspend(struct soc_camera_device *icd, pm_message_t pm_msg)
static int sensor_resume(struct soc_camera_device *icd)
{
struct soc_camera_link *icl;
int ret;
int ret;
icl = to_soc_camera_link(icd);
if (icl->power) {
ret = icl->power(icd->pdev, 1);
if (ret < 0) {
SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
return -EINVAL;
}
ret = sensor_ioctrl(icd, Sensor_PowerDown, 0);
if (ret < 0) {
SENSOR_TR("\n %s resume fail for turn on power!\n", SENSOR_NAME_STRING());
return -EINVAL;
}
SENSOR_DG("\n %s Enter Resume.. \n", SENSOR_NAME_STRING());
@@ -1447,11 +1563,48 @@ static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
return 0;
}
static bool sensor_fmt_capturechk(struct v4l2_subdev *sd, struct v4l2_format *f)
{
bool ret = false;
if ((f->fmt.pix.width == 1024) && (f->fmt.pix.height == 768)) {
ret = true;
} else if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 1024)) {
ret = true;
} else if ((f->fmt.pix.width == 1600) && (f->fmt.pix.height == 1200)) {
ret = true;
} else if ((f->fmt.pix.width == 2048) && (f->fmt.pix.height == 1536)) {
ret = true;
} else if ((f->fmt.pix.width == 2592) && (f->fmt.pix.height == 1944)) {
ret = true;
}
if (ret == true)
SENSOR_DG("%s %dx%d is capture format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
return ret;
}
static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_format *f)
{
bool ret = false;
if ((f->fmt.pix.width == 1280) && (f->fmt.pix.height == 720)) {
ret = true;
} else if ((f->fmt.pix.width == 1920) && (f->fmt.pix.height == 1080)) {
ret = true;
}
if (ret == true)
SENSOR_DG("%s %dx%d is video format\n", __FUNCTION__, f->fmt.pix.width, f->fmt.pix.height);
return ret;
}
static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
{
struct i2c_client *client = sd->priv;
struct sensor *sensor = to_sensor(client);
struct v4l2_pix_format *pix = &f->fmt.pix;
const struct v4l2_queryctrl *qctrl;
struct soc_camera_device *icd = client->dev.platform_data;
struct reginfo *winseqe_set_addr=NULL;
char readval;
int ret=0, set_w,set_h;
@@ -1538,22 +1691,76 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
SENSOR_TR("\n %s..%s Format is Invalidate. pix->width = %d.. pix->height = %d\n",SENSOR_NAME_STRING(),__FUNCTION__,pix->width,pix->height);
}
if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr)
{
if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr) {
#if CONFIG_SENSOR_Flash
if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */
if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
sensor_ioctrl(icd, Sensor_Flash, Flash_On);
SENSOR_DG("%s flash on in capture!\n", SENSOR_NAME_STRING());
}
} else { /* ddl@rock-chips.com : Video */
if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
SENSOR_DG("%s flash off in preivew!\n", SENSOR_NAME_STRING());
}
}
#endif
ret |= sensor_write_array(client, winseqe_set_addr);
if (ret != 0) {
SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
#if CONFIG_SENSOR_Flash
if (sensor_fmt_capturechk(sd,f) == true) {
if ((sensor->info_priv.flash == 1) || (sensor->info_priv.flash == 2)) {
sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
SENSOR_TR("%s Capture format set fail, flash off !\n", SENSOR_NAME_STRING());
}
}
#endif
goto sensor_s_fmt_end;
}
sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
if (sensor_fmt_capturechk(sd,f) == true) { /* ddl@rock-chips.com : Capture */
#if CONFIG_SENSOR_Effect
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
#endif
#if CONFIG_SENSOR_WhiteBalance
if (sensor->info_priv.whiteBalance != 0) {
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
}
#endif
sensor->info_priv.snap2preview = true;
} else if (sensor_fmt_videochk(sd,f) == true) { /* ddl@rock-chips.com : Video */
#if CONFIG_SENSOR_Effect
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
#endif
#if CONFIG_SENSOR_WhiteBalance
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
#endif
sensor->info_priv.video2preview = true;
} else if ((sensor->info_priv.snap2preview == true) || (sensor->info_priv.video2preview == true)) {
#if CONFIG_SENSOR_Effect
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_EFFECT);
sensor_set_effect(icd, qctrl,sensor->info_priv.effect);
#endif
#if CONFIG_SENSOR_WhiteBalance
qctrl = soc_camera_find_qctrl(&sensor_ops, V4L2_CID_DO_WHITE_BALANCE);
sensor_set_whiteBalance(icd, qctrl,sensor->info_priv.whiteBalance);
#endif
sensor->info_priv.video2preview = false;
sensor->info_priv.snap2preview = false;
}
SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
}
else
{
SENSOR_TR("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
SENSOR_DG("\n %s .. Current Format is validate. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),set_w,set_h);
}
pix->width = set_w;
@@ -1857,6 +2064,24 @@ static int sensor_set_digitalzoom(struct soc_camera_device *icd, const struct v4
return -EINVAL;
}
#endif
#if CONFIG_SENSOR_Flash
static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_queryctrl *qctrl, int value)
{
if ((value >= qctrl->minimum) && (value <= qctrl->maximum)) {
if (value == 3) { /* ddl@rock-chips.com: torch */
sensor_ioctrl(icd, Sensor_Flash, Flash_Torch); /* Flash On */
} else {
sensor_ioctrl(icd, Sensor_Flash, Flash_Off);
}
SENSOR_DG("%s..%s : %x\n",SENSOR_NAME_STRING(),__FUNCTION__, value);
return 0;
}
SENSOR_TR("\n %s..%s valure = %d is invalidate.. \n",SENSOR_NAME_STRING(),__FUNCTION__,value);
return -EINVAL;
}
#endif
static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
{
struct i2c_client *client = sd->priv;
@@ -2191,6 +2416,8 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
#if CONFIG_SENSOR_Flash
case V4L2_CID_FLASH:
{
if (sensor_set_flash(icd, qctrl,ext_ctrl->value) != 0)
return -EINVAL;
sensor->info_priv.flash = ext_ctrl->value;
SENSOR_DG("%s flash is %x\n",SENSOR_NAME_STRING(), sensor->info_priv.flash);
@@ -2269,6 +2496,10 @@ static int sensor_video_probe(struct soc_camera_device *icd,
to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
return -ENODEV;
if (sensor_ioctrl(icd, Sensor_PowerDown, 0) < 0) {
ret = -ENODEV;
goto sensor_video_probe_err;
}
/* soft reset */
ret = sensor_write(client, 0x12, 0x80);
if (ret != 0)
@@ -2307,19 +2538,64 @@ sensor_video_probe_err:
static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{
struct i2c_client *client = sd->priv;
struct soc_camera_device *icd = client->dev.platform_data;
struct sensor *sensor = to_sensor(client);
int ret = 0;
#if CONFIG_SENSOR_Flash
int i;
#endif
SENSOR_DG("\n%s..%s..cmd:%x \n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
switch (cmd)
{
case RK29_CAM_SUBDEV_DEACTIVATE:
{
sensor_deactivate(sd);
sensor_deactivate(client);
break;
}
case RK29_CAM_SUBDEV_IOREQUEST:
{
sensor->sensor_io_request = (struct rk29camera_platform_data*)arg;
if (sensor->sensor_io_request != NULL) {
if (sensor->sensor_io_request->gpio_res[0].dev_name &&
(strcmp(sensor->sensor_io_request->gpio_res[0].dev_name, dev_name(icd->pdev)) == 0)) {
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[0];
} else if (sensor->sensor_io_request->gpio_res[1].dev_name &&
(strcmp(sensor->sensor_io_request->gpio_res[1].dev_name, dev_name(icd->pdev)) == 0)) {
sensor->sensor_gpio_res = (struct rk29camera_gpio_res*)&sensor->sensor_io_request->gpio_res[1];
}
} else {
SENSOR_TR("%s %s RK29_CAM_SUBDEV_IOREQUEST fail\n",SENSOR_NAME_STRING(),__FUNCTION__);
ret = -EINVAL;
goto sensor_ioctl_end;
}
/* ddl@rock-chips.com : if gpio_flash havn't been set in board-xxx.c, sensor driver must notify is not support flash control
for this project */
#if CONFIG_SENSOR_Flash
if (sensor->sensor_gpio_res) {
if (sensor->sensor_gpio_res->gpio_flash == INVALID_GPIO) {
for (i = 0; i < icd->ops->num_controls; i++) {
if (V4L2_CID_FLASH == icd->ops->controls[i].id) {
memset((char*)&icd->ops->controls[i],0x00,sizeof(struct v4l2_queryctrl));
}
}
sensor->info_priv.flash = 0xff;
SENSOR_DG("%s flash gpio is invalidate!\n",SENSOR_NAME_STRING());
}
}
#endif
break;
}
default:
{
SENSOR_TR("%s %s cmd(0x%x) is unknown !\n",SENSOR_NAME_STRING(),__FUNCTION__,cmd);
break;
}
}
return 0;
sensor_ioctl_end:
return ret;
}
static struct v4l2_subdev_core_ops sensor_subdev_core_ops = {
@@ -2379,12 +2655,16 @@ static int sensor_probe(struct i2c_client *client,
/* Second stage probe - when a capture adapter is there */
icd->ops = &sensor_ops;
icd->y_skip_top = 0;
#if CONFIG_SENSOR_I2C_NOSCHED
atomic_set(&sensor->tasklock_cnt,0);
#endif
ret = sensor_video_probe(icd, client);
if (ret) {
if (ret < 0) {
icd->ops = NULL;
i2c_set_clientdata(client, NULL);
kfree(sensor);
sensor = NULL;
}
SENSOR_DG("\n%s..%s..%d ret = %x \n",__FUNCTION__,__FILE__,__LINE__,ret);
return ret;
@@ -2399,7 +2679,7 @@ static int sensor_remove(struct i2c_client *client)
i2c_set_clientdata(client, NULL);
client->driver = NULL;
kfree(sensor);
sensor = NULL;
return 0;
}

3052
drivers/media/video/sid130B.c Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,7 @@
#define _GC_OBJ_ZONE gcvZONE_OS
#define PAGE_ALLOC_LIMIT 1 // <20><><EFBFBD><EFBFBD>Page<67><65><EFBFBD><EFBFBD>
#define PAGE_ALLOC_LIMIT 0 // <20><><EFBFBD><EFBFBD>Page<67><65><EFBFBD><EFBFBD>
#define PAGE_ALLOC_LIMIT_SIZE 0 // <20><><EFBFBD><EFBFBD>Page<67><65><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С,<2C><>λΪM
#if PAGE_ALLOC_LIMIT

View File

@@ -281,7 +281,15 @@ enum {
V4L2_IDENT_GT2005 = 64100, /* ddl@rock-chips.com : GT2005 support */
V4L2_IDENT_GC0308 = 64101, /* ddl@rock-chips.com : GC0308 support */
V4L2_IDENT_SIV120B = 64102, /* ddl@rock-chips.com : siv120b support */
V4L2_IDENT_GC0309 = 64102, /* ddl@rock-chips.com : GC0309 support */
V4L2_IDENT_SIV120B = 64103, /* ddl@rock-chips.com : siv120b support */
V4L2_IDENT_GC2015 = 64105, /* ddl@rock-chips.com : gc2015 support */
V4L2_IDENT_HI253 = 64106, /* ddl@rock-chips.com : hi253 support */
V4L2_IDENT_HI704 = 64107, /* ddl@rock-chips.com : hi704 support */
V4L2_IDENT_NT99250 = 64108, /* ddl@rock-chips.com : nt99250 support */
V4L2_IDENT_SID130B = 64109, /* ddl@rock-chips.com : sid130B support */
};
#endif

View File

@@ -147,8 +147,8 @@
#define WM8900_LRC_MASK 0xfc00
#define SPK_CON RK29_PIN6_PB6
#define WM8900_IS_SHUTDOWN 0
#define WM8900_IS_STARTUP 1
#define WM8900_IS_SHUTDOWN 2
static void wm8900_work(struct work_struct *work);
@@ -225,454 +225,36 @@ static void wm8900_reset(struct snd_soc_codec *codec)
sizeof(codec->reg_cache));
}
static int wm8900_hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
static void wm8900_powerdown(void)
{
struct snd_soc_codec *codec = w->codec;
u16 hpctl1 = snd_soc_read(codec, WM8900_REG_HPCTL1);
WM8900_DBG("Enter:%s, %d \n", __FUNCTION__, __LINE__);
printk("Power down wm8900\n");
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
/* Clamp headphone outputs */
hpctl1 = WM8900_REG_HPCTL1_HP_CLAMP_IP |
WM8900_REG_HPCTL1_HP_CLAMP_OP;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
WM8900_DBG("Enter:%s, %d, HPCTL=0x%04X \n", __FUNCTION__, __LINE__, hpctl1);
break;
case SND_SOC_DAPM_POST_PMU:
/* Enable the input stage */
hpctl1 &= ~WM8900_REG_HPCTL1_HP_CLAMP_IP;
hpctl1 |= WM8900_REG_HPCTL1_HP_SHORT |
WM8900_REG_HPCTL1_HP_SHORT2 |
WM8900_REG_HPCTL1_HP_IPSTAGE_ENA;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
msleep(400);
/* Enable the output stage */
hpctl1 &= ~WM8900_REG_HPCTL1_HP_CLAMP_OP;
hpctl1 |= WM8900_REG_HPCTL1_HP_OPSTAGE_ENA;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
/* Remove the shorts */
hpctl1 &= ~WM8900_REG_HPCTL1_HP_SHORT2;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
hpctl1 &= ~WM8900_REG_HPCTL1_HP_SHORT;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
WM8900_DBG("Enter:%s, %d, HPCTL=0x%04X \n", __FUNCTION__, __LINE__, hpctl1);
break;
case SND_SOC_DAPM_PRE_PMD:
/* Short the output */
hpctl1 |= WM8900_REG_HPCTL1_HP_SHORT;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
/* Disable the output stage */
hpctl1 &= ~WM8900_REG_HPCTL1_HP_OPSTAGE_ENA;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
/* Clamp the outputs and power down input */
hpctl1 |= WM8900_REG_HPCTL1_HP_CLAMP_IP |
WM8900_REG_HPCTL1_HP_CLAMP_OP;
hpctl1 &= ~WM8900_REG_HPCTL1_HP_IPSTAGE_ENA;
snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1);
WM8900_DBG("Enter:%s, %d, HPCTL=0x%04X \n", __FUNCTION__, __LINE__, hpctl1);
break;
case SND_SOC_DAPM_POST_PMD:
/* Disable everything */
snd_soc_write(codec, WM8900_REG_HPCTL1, 0);
WM8900_DBG("Enter:%s, %d, HPCTL=0x%04X \n", __FUNCTION__, __LINE__, hpctl1);
break;
default:
BUG();
if (wm8900_current_status != WM8900_IS_SHUTDOWN) {
#ifdef SPK_CON
gpio_set_value(SPK_CON, GPIO_LOW);
#endif
msleep(20);
snd_soc_write(wm8900_codec, WM8900_REG_RESET, 0);
wm8900_current_status = WM8900_IS_SHUTDOWN;
}
return 0;
}
static const DECLARE_TLV_DB_SCALE(out_pga_tlv, -5700, 100, 0);
static const DECLARE_TLV_DB_SCALE(out_mix_tlv, -1500, 300, 0);
static const DECLARE_TLV_DB_SCALE(in_boost_tlv, -1200, 600, 0);
static const DECLARE_TLV_DB_SCALE(in_pga_tlv, -1200, 100, 0);
static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0);
static const DECLARE_TLV_DB_SCALE(dac_tlv, -7200, 75, 1);
static const DECLARE_TLV_DB_SCALE(adc_svol_tlv, -3600, 300, 0);
static const DECLARE_TLV_DB_SCALE(adc_tlv, -7200, 75, 1);
static const char *mic_bias_level_txt[] = { "0.9*AVDD", "0.65*AVDD" };
static const struct soc_enum mic_bias_level =
SOC_ENUM_SINGLE(WM8900_REG_INCTL, 8, 2, mic_bias_level_txt);
static const char *dac_mute_rate_txt[] = { "Fast", "Slow" };
static const struct soc_enum dac_mute_rate =
SOC_ENUM_SINGLE(WM8900_REG_DACCTRL, 7, 2, dac_mute_rate_txt);
static const char *dac_deemphasis_txt[] = {
"Disabled", "32kHz", "44.1kHz", "48kHz"
};
static const struct soc_enum dac_deemphasis =
SOC_ENUM_SINGLE(WM8900_REG_DACCTRL, 4, 4, dac_deemphasis_txt);
static const char *adc_hpf_cut_txt[] = {
"Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3"
};
static const struct soc_enum adc_hpf_cut =
SOC_ENUM_SINGLE(WM8900_REG_ADCCTRL, 5, 4, adc_hpf_cut_txt);
static const char *lr_txt[] = {
"Left", "Right"
};
static const struct soc_enum aifl_src =
SOC_ENUM_SINGLE(WM8900_REG_AUDIO1, 15, 2, lr_txt);
static const struct soc_enum aifr_src =
SOC_ENUM_SINGLE(WM8900_REG_AUDIO1, 14, 2, lr_txt);
static const struct soc_enum dacl_src =
SOC_ENUM_SINGLE(WM8900_REG_AUDIO2, 15, 2, lr_txt);
static const struct soc_enum dacr_src =
SOC_ENUM_SINGLE(WM8900_REG_AUDIO2, 14, 2, lr_txt);
static const char *sidetone_txt[] = {
"Disabled", "Left ADC", "Right ADC"
};
static const struct soc_enum dacl_sidetone =
SOC_ENUM_SINGLE(WM8900_REG_SIDETONE, 2, 3, sidetone_txt);
static const struct soc_enum dacr_sidetone =
SOC_ENUM_SINGLE(WM8900_REG_SIDETONE, 0, 3, sidetone_txt);
static const struct snd_kcontrol_new wm8900_snd_controls[] = {
SOC_ENUM("Mic Bias Level", mic_bias_level),
SOC_SINGLE_TLV("Left Input PGA Volume", WM8900_REG_LINVOL, 0, 31, 0,
in_pga_tlv),
SOC_SINGLE("Left Input PGA Switch", WM8900_REG_LINVOL, 6, 1, 1),
SOC_SINGLE("Left Input PGA ZC Switch", WM8900_REG_LINVOL, 7, 1, 0),
SOC_SINGLE_TLV("Right Input PGA Volume", WM8900_REG_RINVOL, 0, 31, 0,
in_pga_tlv),
SOC_SINGLE("Right Input PGA Switch", WM8900_REG_RINVOL, 6, 1, 1),
SOC_SINGLE("Right Input PGA ZC Switch", WM8900_REG_RINVOL, 7, 1, 0),
SOC_SINGLE("DAC Soft Mute Switch", WM8900_REG_DACCTRL, 6, 1, 1),
SOC_ENUM("DAC Mute Rate", dac_mute_rate),
SOC_SINGLE("DAC Mono Switch", WM8900_REG_DACCTRL, 9, 1, 0),
SOC_ENUM("DAC Deemphasis", dac_deemphasis),
SOC_SINGLE("DAC Sigma-Delta Modulator Clock Switch", WM8900_REG_DACCTRL,
12, 1, 0),
SOC_SINGLE("ADC HPF Switch", WM8900_REG_ADCCTRL, 8, 1, 0),
SOC_ENUM("ADC HPF Cut-Off", adc_hpf_cut),
SOC_DOUBLE("ADC Invert Switch", WM8900_REG_ADCCTRL, 1, 0, 1, 0),
SOC_SINGLE_TLV("Left ADC Sidetone Volume", WM8900_REG_SIDETONE, 9, 12, 0,
adc_svol_tlv),
SOC_SINGLE_TLV("Right ADC Sidetone Volume", WM8900_REG_SIDETONE, 5, 12, 0,
adc_svol_tlv),
SOC_ENUM("Left Digital Audio Source", aifl_src),
SOC_ENUM("Right Digital Audio Source", aifr_src),
SOC_SINGLE_TLV("DAC Input Boost Volume", WM8900_REG_AUDIO2, 10, 4, 0,
dac_boost_tlv),
SOC_ENUM("Left DAC Source", dacl_src),
SOC_ENUM("Right DAC Source", dacr_src),
SOC_ENUM("Left DAC Sidetone", dacl_sidetone),
SOC_ENUM("Right DAC Sidetone", dacr_sidetone),
SOC_DOUBLE("DAC Invert Switch", WM8900_REG_DACCTRL, 1, 0, 1, 0),
SOC_DOUBLE_R_TLV("Digital Playback Volume",
WM8900_REG_LDAC_DV, WM8900_REG_RDAC_DV,
1, 96, 0, dac_tlv),
SOC_DOUBLE_R_TLV("Digital Capture Volume",
WM8900_REG_LADC_DV, WM8900_REG_RADC_DV, 1, 119, 0, adc_tlv),
SOC_SINGLE_TLV("LINPUT3 Bypass Volume", WM8900_REG_LOUTMIXCTL1, 4, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("RINPUT3 Bypass Volume", WM8900_REG_ROUTMIXCTL1, 4, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("Left AUX Bypass Volume", WM8900_REG_AUXOUT_CTL, 4, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("Right AUX Bypass Volume", WM8900_REG_AUXOUT_CTL, 0, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("LeftIn to RightOut Mixer Volume", WM8900_REG_BYPASS1, 0, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("LeftIn to LeftOut Mixer Volume", WM8900_REG_BYPASS1, 4, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("RightIn to LeftOut Mixer Volume", WM8900_REG_BYPASS2, 0, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("RightIn to RightOut Mixer Volume", WM8900_REG_BYPASS2, 4, 7, 0,
out_mix_tlv),
SOC_SINGLE_TLV("IN2L Boost Volume", WM8900_REG_INBOOSTMIX1, 0, 3, 0,
in_boost_tlv),
SOC_SINGLE_TLV("IN3L Boost Volume", WM8900_REG_INBOOSTMIX1, 4, 3, 0,
in_boost_tlv),
SOC_SINGLE_TLV("IN2R Boost Volume", WM8900_REG_INBOOSTMIX2, 0, 3, 0,
in_boost_tlv),
SOC_SINGLE_TLV("IN3R Boost Volume", WM8900_REG_INBOOSTMIX2, 4, 3, 0,
in_boost_tlv),
SOC_SINGLE_TLV("Left AUX Boost Volume", WM8900_REG_AUXBOOST, 4, 3, 0,
in_boost_tlv),
SOC_SINGLE_TLV("Right AUX Boost Volume", WM8900_REG_AUXBOOST, 0, 3, 0,
in_boost_tlv),
SOC_DOUBLE_R_TLV("LINEOUT1 Volume", WM8900_REG_LOUT1CTL, WM8900_REG_ROUT1CTL,
0, 63, 0, out_pga_tlv),
SOC_DOUBLE_R("LINEOUT1 Switch", WM8900_REG_LOUT1CTL, WM8900_REG_ROUT1CTL,
6, 1, 1),
SOC_DOUBLE_R("LINEOUT1 ZC Switch", WM8900_REG_LOUT1CTL, WM8900_REG_ROUT1CTL,
7, 1, 0),
SOC_DOUBLE_R_TLV("LINEOUT2 Volume",
WM8900_REG_LOUT2CTL, WM8900_REG_ROUT2CTL,
0, 63, 0, out_pga_tlv),
SOC_DOUBLE_R("LINEOUT2 Switch",
WM8900_REG_LOUT2CTL, WM8900_REG_ROUT2CTL, 6, 1, 1),
SOC_DOUBLE_R("LINEOUT2 ZC Switch",
WM8900_REG_LOUT2CTL, WM8900_REG_ROUT2CTL, 7, 1, 0),
SOC_SINGLE("LINEOUT2 LP -12dB", WM8900_REG_LOUTMIXCTL1,
0, 1, 1),
};
static const struct snd_kcontrol_new wm8900_dapm_loutput2_control[] = {
SOC_DAPM_SINGLE("LINEOUT2L Switch", WM8900_REG_POWER3, 6, 1, 0),};
static const struct snd_kcontrol_new wm8900_dapm_routput2_control[] = {
SOC_DAPM_SINGLE("LINEOUT2R Switch", WM8900_REG_POWER3, 5, 1, 0),};
static const struct snd_kcontrol_new wm8900_loutmix_controls[] = {
SOC_DAPM_SINGLE("LINPUT3 Bypass Switch", WM8900_REG_LOUTMIXCTL1, 7, 1, 0),
SOC_DAPM_SINGLE("AUX Bypass Switch", WM8900_REG_AUXOUT_CTL, 7, 1, 0),
SOC_DAPM_SINGLE("Left Input Mixer Switch", WM8900_REG_BYPASS1, 7, 1, 0),
SOC_DAPM_SINGLE("Right Input Mixer Switch", WM8900_REG_BYPASS2, 3, 1, 0),
SOC_DAPM_SINGLE("DACL Switch", WM8900_REG_LOUTMIXCTL1, 8, 1, 0),
};
static const struct snd_kcontrol_new wm8900_routmix_controls[] = {
SOC_DAPM_SINGLE("RINPUT3 Bypass Switch", WM8900_REG_ROUTMIXCTL1, 7, 1, 0),
SOC_DAPM_SINGLE("AUX Bypass Switch", WM8900_REG_AUXOUT_CTL, 3, 1, 0),
SOC_DAPM_SINGLE("Left Input Mixer Switch", WM8900_REG_BYPASS1, 3, 1, 0),
SOC_DAPM_SINGLE("Right Input Mixer Switch", WM8900_REG_BYPASS2, 7, 1, 0),
SOC_DAPM_SINGLE("DACR Switch", WM8900_REG_ROUTMIXCTL1, 8, 1, 0),
};
static const struct snd_kcontrol_new wm8900_linmix_controls[] = {
SOC_DAPM_SINGLE("LINPUT2 Switch", WM8900_REG_INBOOSTMIX1, 2, 1, 1),
SOC_DAPM_SINGLE("LINPUT3 Switch", WM8900_REG_INBOOSTMIX1, 6, 1, 1),
SOC_DAPM_SINGLE("AUX Switch", WM8900_REG_AUXBOOST, 6, 1, 1),
SOC_DAPM_SINGLE("Input PGA Switch", WM8900_REG_ADCPATH, 6, 1, 0),
};
static const struct snd_kcontrol_new wm8900_rinmix_controls[] = {
SOC_DAPM_SINGLE("RINPUT2 Switch", WM8900_REG_INBOOSTMIX2, 2, 1, 1),
SOC_DAPM_SINGLE("RINPUT3 Switch", WM8900_REG_INBOOSTMIX2, 6, 1, 1),
SOC_DAPM_SINGLE("AUX Switch", WM8900_REG_AUXBOOST, 2, 1, 1),
SOC_DAPM_SINGLE("Input PGA Switch", WM8900_REG_ADCPATH, 2, 1, 0),
};
static const struct snd_kcontrol_new wm8900_linpga_controls[] = {
SOC_SINGLE("MIC LINPUT1 Switch", WM8900_REG_INCTL, 6, 1, 0),
SOC_SINGLE("MIC LINPUT2 Switch", WM8900_REG_INCTL, 5, 1, 0),
SOC_SINGLE("MIC LINPUT3 Switch", WM8900_REG_INCTL, 4, 1, 0),
};
static const struct snd_kcontrol_new wm8900_rinpga_controls[] = {
SOC_SINGLE("MIC RINPUT1 Switch", WM8900_REG_INCTL, 2, 1, 0),
SOC_SINGLE("MIC RINPUT2 Switch", WM8900_REG_INCTL, 1, 1, 0),
SOC_SINGLE("MIC RINPUT3 Switch", WM8900_REG_INCTL, 0, 1, 0),
};
static const struct snd_kcontrol_new wm8900_inmix_controls[] = {
SOC_SINGLE("LINPUT PGA Switch", WM8900_REG_ADCPATH, 6, 1, 0),
SOC_SINGLE("RINPUT PGA Switch", WM8900_REG_ADCPATH, 2, 1, 0),
};
static const char *wm9700_lp_mux[] = { "Disabled", "Enabled" };
static const struct soc_enum wm8900_lineout2_lp_mux =
SOC_ENUM_SINGLE(WM8900_REG_LOUTMIXCTL1, 1, 2, wm9700_lp_mux);
static const struct snd_kcontrol_new wm8900_lineout2_lp =
SOC_DAPM_ENUM("Route", wm8900_lineout2_lp_mux);
static const struct snd_soc_dapm_widget wm8900_dapm_widgets[] = {
/* Externally visible pins */
SND_SOC_DAPM_OUTPUT("LINEOUT1L"),
SND_SOC_DAPM_OUTPUT("LINEOUT1R"),
SND_SOC_DAPM_OUTPUT("LINEOUT2L"),
SND_SOC_DAPM_OUTPUT("LINEOUT2R"),
SND_SOC_DAPM_OUTPUT("HP_L"),
SND_SOC_DAPM_OUTPUT("HP_R"),
SND_SOC_DAPM_INPUT("RINPUT1"),
SND_SOC_DAPM_INPUT("LINPUT1"),
SND_SOC_DAPM_INPUT("RINPUT2"),
SND_SOC_DAPM_INPUT("LINPUT2"),
SND_SOC_DAPM_INPUT("RINPUT3"),
SND_SOC_DAPM_INPUT("LINPUT3"),
SND_SOC_DAPM_INPUT("AUX"),
SND_SOC_DAPM_VMID("VMID"),
/* Input */
SND_SOC_DAPM_MIXER("Left Input PGA", WM8900_REG_POWER2, 3, 0,
wm8900_linpga_controls,
ARRAY_SIZE(wm8900_linpga_controls)),
SND_SOC_DAPM_MIXER("Right Input PGA", WM8900_REG_POWER2, 2, 0,
wm8900_rinpga_controls,
ARRAY_SIZE(wm8900_rinpga_controls)),
SND_SOC_DAPM_MIXER("Left Input Mixer", WM8900_REG_POWER2, 5, 0,
wm8900_linmix_controls,
ARRAY_SIZE(wm8900_linmix_controls)),
SND_SOC_DAPM_MIXER("Right Input Mixer", WM8900_REG_POWER2, 4, 0,
wm8900_rinmix_controls,
ARRAY_SIZE(wm8900_rinmix_controls)),
SND_SOC_DAPM_MICBIAS("Mic Bias", WM8900_REG_POWER1, 4, 0),
SND_SOC_DAPM_ADC("ADCL", "Left HiFi Capture", WM8900_REG_POWER2, 1, 0),
SND_SOC_DAPM_ADC("ADCR", "Right HiFi Capture", WM8900_REG_POWER2, 0, 0),
/* Output */
SND_SOC_DAPM_DAC("DACL", "Left HiFi Playback", WM8900_REG_POWER3, 1, 0),
SND_SOC_DAPM_DAC("DACR", "Right HiFi Playback", WM8900_REG_POWER3, 0, 0),
/*SND_SOC_DAPM_PGA_E("Headphone Amplifier", WM8900_REG_POWER3, 7, 0, NULL, 0,
wm8900_hp_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),*/
SND_SOC_DAPM_PGA("LINEOUT1L PGA", WM8900_REG_POWER2, 8, 0, NULL, 0),
SND_SOC_DAPM_PGA("LINEOUT1R PGA", WM8900_REG_POWER2, 7, 0, NULL, 0),
SND_SOC_DAPM_MUX("LINEOUT2 LP", SND_SOC_NOPM, 0, 0, &wm8900_lineout2_lp),
SND_SOC_DAPM_PGA("LINEOUT2L PGA", WM8900_REG_POWER3, 6, 0, NULL, 0),
SND_SOC_DAPM_PGA("LINEOUT2R PGA", WM8900_REG_POWER3, 5, 0, NULL, 0),
SND_SOC_DAPM_MIXER("Left Output Mixer", WM8900_REG_POWER3, 3, 0,
wm8900_loutmix_controls,
ARRAY_SIZE(wm8900_loutmix_controls)),
SND_SOC_DAPM_MIXER("Right Output Mixer", WM8900_REG_POWER3, 2, 0,
wm8900_routmix_controls,
ARRAY_SIZE(wm8900_routmix_controls)),
};
/* Target, Path, Source */
static const struct snd_soc_dapm_route audio_map[] = {
/* Inputs */
{"Left Input PGA", "LINPUT1 Switch", "LINPUT1"},
{"Left Input PGA", "LINPUT2 Switch", "LINPUT2"},
{"Left Input PGA", "LINPUT3 Switch", "LINPUT3"},
{"Right Input PGA", "RINPUT1 Switch", "RINPUT1"},
{"Right Input PGA", "RINPUT2 Switch", "RINPUT2"},
{"Right Input PGA", "RINPUT3 Switch", "RINPUT3"},
{"Left Input Mixer", "LINPUT2 Switch", "LINPUT2"},
{"Left Input Mixer", "LINPUT3 Switch", "LINPUT3"},
{"Left Input Mixer", "AUX Switch", "AUX"},
{"Left Input Mixer", "Input PGA Switch", "Left Input PGA"},
{"Right Input Mixer", "RINPUT2 Switch", "RINPUT2"},
{"Right Input Mixer", "RINPUT3 Switch", "RINPUT3"},
{"Right Input Mixer", "AUX Switch", "AUX"},
{"Right Input Mixer", "Input PGA Switch", "Right Input PGA"},
{"ADCL", NULL, "Left Input Mixer"},
{"ADCR", NULL, "Right Input Mixer"},
/* Outputs */
{"LINEOUT1L", NULL, "LINEOUT1L PGA"},
{"LINEOUT1L PGA", NULL, "Left Output Mixer"},
{"LINEOUT1R", NULL, "LINEOUT1R PGA"},
{"LINEOUT1R PGA", NULL, "Right Output Mixer"},
{"LINEOUT2L PGA", NULL, "Left Output Mixer"},
{"LINEOUT2 LP", "Disabled", "LINEOUT2L PGA"},
{"LINEOUT2 LP", "Enabled", "Left Output Mixer"},
{"LINEOUT2L", NULL, "LINEOUT2 LP"},
{"LINEOUT2R PGA", NULL, "Right Output Mixer"},
{"LINEOUT2 LP", "Disabled", "LINEOUT2R PGA"},
{"LINEOUT2 LP", "Enabled", "Right Output Mixer"},
{"LINEOUT2R", NULL, "LINEOUT2 LP"},
{"Left Output Mixer", "LINPUT3 Bypass Switch", "LINPUT3"},
{"Left Output Mixer", "AUX Bypass Switch", "AUX"},
{"Left Output Mixer", "Left Input Mixer Switch", "Left Input Mixer"},
{"Left Output Mixer", "Right Input Mixer Switch", "Right Input Mixer"},
{"Left Output Mixer", "DACL Switch", "DACL"},
{"Right Output Mixer", "RINPUT3 Bypass Switch", "RINPUT3"},
{"Right Output Mixer", "AUX Bypass Switch", "AUX"},
{"Right Output Mixer", "Left Input Mixer Switch", "Left Input Mixer"},
{"Right Output Mixer", "Right Input Mixer Switch", "Right Input Mixer"},
{"Right Output Mixer", "DACR Switch", "DACR"},
/* Note that the headphone output stage needs to be connected
* externally to LINEOUT2 via DC blocking capacitors. Other
* configurations are not supported.
*
* Note also that left and right headphone paths are treated as a
* mono path.
*/
{"Headphone Amplifier", NULL, "LINEOUT2 LP"},
{"Headphone Amplifier", NULL, "LINEOUT2 LP"},
{"HP_L", NULL, "Headphone Amplifier"},
{"HP_R", NULL, "Headphone Amplifier"},
};
static int wm8900_add_widgets(struct snd_soc_codec *codec)
{
WM8900_DBG("Enter:%s, %d \n", __FUNCTION__, __LINE__);
snd_soc_dapm_new_controls(codec, wm8900_dapm_widgets,
ARRAY_SIZE(wm8900_dapm_widgets));
snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
snd_soc_dapm_new_widgets(codec);
return 0;
}
static void wm8900_work(struct work_struct *work)
{
WM8900_DBG("Enter::wm8900 work, power down wm8900\n");
WM8900_DBG("Enter::wm8900_work\n");
#ifdef SPK_CON
gpio_set_value(SPK_CON, GPIO_LOW);
#endif
snd_soc_write(wm8900_codec, WM8900_REG_RESET, 0);
wm8900_current_status = WM8900_IS_SHUTDOWN;
wm8900_powerdown();
}
static void wm8900_set_hw(struct snd_soc_codec *codec)
{
u16 reg;
WM8900_DBG("Enter:%s, %d \n", __FUNCTION__, __LINE__);
//snd_soc_write(codec, WM8900_REG_LOUT2CTL, 0x140);
//snd_soc_write(codec, WM8900_REG_ROUT2CTL, 0x140);
snd_soc_write(codec, WM8900_REG_HPCTL1, 0x30);
snd_soc_write(codec, WM8900_REG_POWER1, 0x0100);
snd_soc_write(codec, WM8900_REG_POWER3, 0x60);
@@ -682,7 +264,7 @@ static void wm8900_set_hw(struct snd_soc_codec *codec)
snd_soc_write(codec, WM8900_REG_ADDCTL, 0x02);
snd_soc_write(codec, WM8900_REG_POWER1, 0x09);
snd_soc_write(codec, WM8900_REG_POWER3, 0xEF);
snd_soc_write(codec, WM8900_REG_DACCTRL, 0x00);
snd_soc_write(codec, WM8900_REG_DACCTRL, WM8900_REG_DACCTRL_MUTE);
snd_soc_write(codec, WM8900_REG_LOUTMIXCTL1, 0x150);
snd_soc_write(codec, WM8900_REG_ROUTMIXCTL1, 0x150);
@@ -705,6 +287,26 @@ static void wm8900_set_hw(struct snd_soc_codec *codec)
snd_soc_write(codec, WM8900_REG_INBOOSTMIX2, 0x0042);
snd_soc_write(codec, WM8900_REG_ADCPATH, 0x0055);
reg = snd_soc_read(codec, WM8900_REG_DACCTRL);
reg &= ~WM8900_REG_DACCTRL_MUTE;
snd_soc_write(codec, WM8900_REG_DACCTRL, reg);
snd_soc_write(codec, WM8900_REG_LOUT1CTL, 0x130);
snd_soc_write(codec, WM8900_REG_ROUT1CTL, 0x130);
/* Turn up vol slowly, for HP out pop noise */
for (reg = 0; reg <= 0x33; reg += 0x10) {
snd_soc_write(codec, WM8900_REG_LOUT2CTL, 0x100 + reg);
snd_soc_write(codec, WM8900_REG_ROUT2CTL, 0x100 + reg);
msleep(5);
}
snd_soc_write(codec, WM8900_REG_LOUT2CTL, 0x133);
snd_soc_write(codec, WM8900_REG_ROUT2CTL, 0x133);
msleep(20);
#ifdef SPK_CON
gpio_set_value(SPK_CON, GPIO_HIGH);
#endif
@@ -1074,41 +676,8 @@ static int wm8900_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int wm8900_digital_mute(struct snd_soc_dai *codec_dai, int mute)
{
struct snd_soc_codec *codec = codec_dai->codec;
u16 reg;
WM8900_DBG("Enter:%s, %d , mute = %d \n", __FUNCTION__, __LINE__, mute);
if (mute)
return 0;
reg = snd_soc_read(codec, WM8900_REG_DACCTRL);
reg &= ~WM8900_REG_DACCTRL_MUTE;
snd_soc_write(codec, WM8900_REG_DACCTRL, reg);
/* Turn up vol slowly, for SPK out pop */
for (reg = 0; reg <= 0x30; reg += 0x10) {
if (snd_soc_read(codec, WM8900_REG_LOUT1CTL) < 0x30)
snd_soc_write(codec, WM8900_REG_LOUT1CTL, 0x100 + reg);
if (snd_soc_read(codec, WM8900_REG_ROUT1CTL) < 0x30)
snd_soc_write(codec, WM8900_REG_ROUT1CTL, 0x100 + reg);
}
snd_soc_write(codec, WM8900_REG_LOUT1CTL, 0x130);
snd_soc_write(codec, WM8900_REG_ROUT1CTL, 0x130);
/* Turn up vol slowly, for HP out pop */
for (reg = 0; reg <= 0x33; reg += 0x10) {
if (snd_soc_read(codec, WM8900_REG_LOUT2CTL) < 0x33)
snd_soc_write(codec, WM8900_REG_LOUT2CTL, 0x100 + reg);
if (snd_soc_read(codec, WM8900_REG_ROUT2CTL) < 0x33)
snd_soc_write(codec, WM8900_REG_ROUT2CTL, 0x100 + reg);
}
snd_soc_write(codec, WM8900_REG_LOUT2CTL, 0x133);
snd_soc_write(codec, WM8900_REG_ROUT2CTL, 0x133);
return 0;
}
@@ -1117,21 +686,16 @@ static int wm8900_startup(struct snd_pcm_substream *substream,
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
struct snd_soc_dai_link *machine = rtd->dai;
struct snd_soc_dai *codec_dai = machine->codec_dai;
struct snd_soc_codec *codec = socdev->card->codec;
WM8900_DBG("Enter::%s----%d substream->stream:%s \n",__FUNCTION__,__LINE__,
substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? "PLAYBACK":"CAPTURE");
if (!(codec_dai->playback.active || codec_dai->capture.active)) {
cancel_delayed_work_sync(&delayed_work);
cancel_delayed_work_sync(&delayed_work);
if (wm8900_current_status == WM8900_IS_SHUTDOWN) {
if (wm8900_current_status & WM8900_IS_STARTUP)
return 0;
WM8900_DBG("Power up wm8900\n");
printk("Power up wm8900\n");
wm8900_set_hw(codec);
wm8900_current_status |= WM8900_IS_STARTUP;
@@ -1140,7 +704,7 @@ static int wm8900_startup(struct snd_pcm_substream *substream,
}
static void wm8900_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai_link *machine = rtd->dai;
@@ -1159,8 +723,14 @@ static void wm8900_shutdown(struct snd_pcm_substream *substream,
WM8900_DBG("Is going to power down wm8900\n");
queue_delayed_work(wm8900_workq, &delayed_work,
msecs_to_jiffies(3000));
/* If codec is useless, queue work to close it */
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
queue_delayed_work(wm8900_workq, &delayed_work,
msecs_to_jiffies(1000));
} else {
queue_delayed_work(wm8900_workq, &delayed_work,
msecs_to_jiffies(3000));
}
}
}
@@ -1320,7 +890,6 @@ static int wm8900_set_bias_level(struct snd_soc_codec *codec,
break;
}
codec->bias_level = level;
return 0;
}
@@ -1337,7 +906,9 @@ static int wm8900_suspend(struct platform_device *pdev, pm_message_t state)
WM8900_DBG("Enter:%s, %d \n", __FUNCTION__, __LINE__);
snd_soc_write(codec, WM8900_REG_RESET, 0);
cancel_delayed_work_sync(&delayed_work);
wm8900_powerdown();
/* Stop the FLL in an orderly fashion */
ret = wm8900_set_fll(codec, 0, 0, 0);
@@ -1481,7 +1052,7 @@ static __devexit int wm8900_i2c_remove(struct i2c_client *client)
void wm8900_i2c_shutdown(struct i2c_client *client)
{
WM8900_DBG("Enter:%s, %d \n", __FUNCTION__, __LINE__);
snd_soc_write(wm8900_codec, WM8900_REG_RESET, 0);
wm8900_powerdown();
}
#ifdef CONFIG_PM
@@ -1531,6 +1102,7 @@ static int wm8900_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "I2C client not yet instantiated\n");
return -ENODEV;
}
#if defined(SPK_CON)
gpio_request(SPK_CON,NULL);
gpio_direction_output(SPK_CON, GPIO_LOW);
@@ -1546,17 +1118,6 @@ static int wm8900_probe(struct platform_device *pdev)
goto pcm_err;
}
snd_soc_add_controls(codec, wm8900_snd_controls,
ARRAY_SIZE(wm8900_snd_controls));
snd_soc_add_controls(codec, wm8900_linpga_controls,
ARRAY_SIZE(wm8900_linpga_controls));
snd_soc_add_controls(codec, wm8900_rinpga_controls,
ARRAY_SIZE(wm8900_rinpga_controls));
snd_soc_add_controls(codec, wm8900_inmix_controls,
ARRAY_SIZE(wm8900_inmix_controls));
wm8900_add_widgets(codec);
ret = snd_soc_init_card(socdev);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to register card\n");