Skip to content

Commit

Permalink
Enable lens
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperion70 committed Feb 14, 2019
1 parent 5f8c1a6 commit 6b28a98
Show file tree
Hide file tree
Showing 53 changed files with 9,279 additions and 6,231 deletions.
14 changes: 9 additions & 5 deletions arch/arm64/configs/N1_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,9 @@ CONFIG_LIBCRC32C=y
# CONFIG_MTK_SMARTPA_SUPPORT=y
CONFIG_MTK_I2C_EXTENSION=y

###########################################################################
# [hyperion70 add start]
###########################################################################

CONFIG_KALLSYMS_ALL=y
CONFIG_SLABINFO=y
Expand All @@ -542,11 +544,11 @@ CONFIG_MTK_NET_LOGGING=y
CONFIG_MTK_ENG_BUILD=y
CONFIG_MTK_FLASHLIGHT_PWM=y

#CONFIG_MTK_LENS_AK7371AF_SUPPORT=y
#CONFIG_MTK_LENS_BU6424AF_SUPPORT=y
#CONFIG_MTK_LENS_BU6429AF_SUPPORT=y
#CONFIG_MTK_LENS_LC898212XDAF_SUPPORT=y
#CONFIG_MTK_LENS_DW9763AF_SUPPORT=y
CONFIG_MTK_LENS_AK7371AF_SUPPORT=y
CONFIG_MTK_LENS_BU6424AF_SUPPORT=y
CONFIG_MTK_LENS_BU6429AF_SUPPORT=y
CONFIG_MTK_LENS_LC898212XDAF_SUPPORT=y
CONFIG_MTK_LENS_DW9763AF_SUPPORT=y

CONFIG_CUSTOM_KERNEL_ACCELEROMETER=y
CONFIG_MTK_LSM6DS3HG=y
Expand Down Expand Up @@ -585,4 +587,6 @@ CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
CONFIG_MTK_RCU_MONITOR=y

CONFIG_LOG_BUF_SHIFT=21
###########################################################################
# [hyperion70 add end]
###########################################################################
36 changes: 27 additions & 9 deletions drivers/misc/mediatek/lens/Kconfig
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ config MTK_LENS_AK7371AF_SUPPORT
lens driver for the camera sensor module
Set as y if the driver is used in this project

config MTK_LENS_BU24228GWLAF_SUPPORT
bool "BU24228GWLAF Lens Driver"
default n
help
BU24228GWLAF Lens Driver
This config is used to enable the corresponding
lens driver for the camera sensor module
Set as y if the driver is used in this project

config MTK_LENS_BU6424AF_SUPPORT
bool "BU6424AF Lens Driver"
default n
Expand Down Expand Up @@ -109,6 +118,24 @@ config MTK_LENS_BU64745GWZAF_SUPPORT
lens driver for the camera sensor module
Set as y if the driver is used in this project

config MTK_LENS_BU64245GWZAF_SUPPORT
bool "BU64245GWZAF Lens Driver"
default n
help
BU64245GWZAF Lens Driver
This config is used to enable the corresponding
lens driver for the camera sensor module
Set as y if the driver is used in this project

config MTK_LENS_BU64747GWZAF_SUPPORT
bool "BU64747GWZAF Lens Driver"
default n
help
BU64747GWZAF Lens Driver
This config is used to enable the corresponding
lens driver for the camera sensor module
Set as y if the driver is used in this project

config MTK_LENS_AK7345AF_SUPPORT
bool "AK7345AF Lens Driver"
default n
Expand Down Expand Up @@ -181,15 +208,6 @@ config MTK_LENS_LC898212XDAF_SUPPORT
lens driver for the camera sensor module
Set as y if the driver is used in this project

config MTK_LENS_BU64748AF_SUPPORT
bool "BU64748AF Lens Driver"
default n
help
BU64748AF Lens Driver
This config is used to enable the corresponding
lens driver for the camera sensor module
Set as y if the driver is used in this project

config MTK_LENS_LC898214AF_SUPPORT
bool "LC898214AF Lens Driver"
default n
Expand Down
5 changes: 2 additions & 3 deletions drivers/misc/mediatek/lens/main/Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,18 @@ else
obj-y += main_lens.o
obj-$(CONFIG_MTK_LENS_FM50AF_SUPPORT) += common/fm50af/
obj-$(CONFIG_MTK_LENS_BU6424AF_SUPPORT) += common/bu6424af/
obj-$(CONFIG_MTK_LENS_BU64747GWZAF_SUPPORT) += common/bu64747gwzaf/
obj-$(CONFIG_MTK_LENS_BU6429AF_SUPPORT) += common/bu6429af/
obj-$(CONFIG_MTK_LENS_BU63165AF_SUPPORT) += common/bu63165af/
obj-$(CONFIG_MTK_LENS_DW9714AF_SUPPORT) += common/dw9714af/
obj-$(CONFIG_MTK_LENS_DW9814AF_SUPPORT) += common/dw9814af/
obj-$(CONFIG_MTK_LENS_DW9718AF_SUPPORT) += common/dw9718af/
obj-$(CONFIG_MTK_LENS_LC898212AF_SUPPORT) += common/lc898212af/
obj-$(CONFIG_MTK_LENS_LC898212XDAF_SUPPORT) += common/lc898212xdaf/
obj-$(CONFIG_MTK_LENS_LC898212XDAF_SUPPORT) += common/lc898212xdaf_tvc700/
obj-$(CONFIG_MTK_LENS_LC898214AF_SUPPORT) += common/lc898214af/
obj-$(CONFIG_MTK_LENS_LC898122AF_SUPPORT) += common/lc898122af/
obj-$(CONFIG_MTK_LENS_AD5820AF_SUPPORT) += common/ad5820af/
obj-$(CONFIG_MTK_LENS_WV511AAF_SUPPORT) += common/wv511aaf/
obj-$(CONFIG_MTK_LENS_AK7371AF_SUPPORT) += common/ak7371af/
obj-$(CONFIG_MTK_LENS_BU64748AF_SUPPORT) += common/bu64748af/

endif
endif
114 changes: 6 additions & 108 deletions drivers/misc/mediatek/lens/main/common/ak7371af/AK7371AF.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ static unsigned long g_u4AF_MACRO = 1023;
static unsigned long g_u4TargetPosition;
static unsigned long g_u4CurrPosition;

extern void AF_TARGET(u16 target);
static DEFINE_MUTEX(main_af_mutex);
#ifdef CONFIG_MEIZU_BSP
extern int camera_main_af_power(int on);
#endif

static int s4AF_ReadReg(u8 a_uAddr, u16 *a_pu2Result)
{
int i4RetValue = 0;
Expand Down Expand Up @@ -81,40 +77,6 @@ static int s4AF_ReadReg(u8 a_uAddr, u16 *a_pu2Result)
return 0;
}

/* Add by meizu BSP [email protected] */
#ifdef CONFIG_MEIZU_BSP
static int s4AF_ReadReg_w(u8 a_uAddr, u16 *a_pu2Result)
{
int i4RetValue = 0;
u8 pBuff[2];
char puSendCmd[1];

puSendCmd[0] = a_uAddr;

g_pstAF_I2Cclient->addr = AF_I2C_SLAVE_ADDR;

g_pstAF_I2Cclient->addr = g_pstAF_I2Cclient->addr >> 1;

i4RetValue = i2c_master_send(g_pstAF_I2Cclient, puSendCmd, 1);

if (i4RetValue < 0) {
LOG_INF("I2C read - send failed!!\n");
return -1;
}

i4RetValue = i2c_master_recv(g_pstAF_I2Cclient, pBuff, 2);

if (i4RetValue < 0) {
LOG_INF("I2C read - recv failed!!\n");
return -1;
}
*a_pu2Result = ((pBuff[0] & 0xFF) << 2) + ((pBuff[1] >> 6) & 0x3);

return 0;
}
#endif
/*Add end */

static int s4AF_WriteReg(u16 a_u2Addr, u16 a_u2Data)
{
int i4RetValue = 0;
Expand Down Expand Up @@ -156,55 +118,7 @@ static inline int getAFInfo(__user stAF_MotorInfo * pstMotorInfo)

return 0;
}
/* Add by meizu BSP [email protected] */
#ifdef CONFIG_MEIZU_BSP
static int ak7371_enable(struct i2c_client *i2c_client, int on)
{
g_pstAF_I2Cclient = i2c_client;
if (on) {
camera_main_af_power(1);
usleep_range(10000, 11000);
/* 00:active mode 10:Standby mode x1:Sleep mode */
s4AF_WriteReg(0x02, 0x00); /* from Standby mode to Active mode */
msleep(20);
} else {
s4AF_WriteReg(0x02, 0x20); /* from active mode to sleep mode */
camera_main_af_power(0);
}

return 0;
}

static int ak7371_pos_set(struct i2c_client *i2c_client, int position)
{
int ret = 0;

g_pstAF_I2Cclient = i2c_client;

ret = s4AF_WriteReg(0x0, (u16)((position >> 2) & 0xff));
ret += s4AF_WriteReg(0x1, (u16)((position & 0x3) << 6));

if (ret < 0) {
LOG_INF("%s: set reg failed.\n", __func__);
return -EINVAL;
}

return 0;
}

static int ak7371_pos_get(struct i2c_client *i2c_client, int *position)
{
u16 reg_pos = 0;
int ret = 0;
g_pstAF_I2Cclient = i2c_client;

ret = s4AF_ReadReg_w(0x84, &reg_pos);
*position = reg_pos;

return ret;
}
#endif
/*Add end */
static inline int setVCMPos(unsigned long a_u4Position)
{
int i4RetValue = 0;
Expand All @@ -222,12 +136,10 @@ static inline int setVCMPos(unsigned long a_u4Position)
static inline int moveAF(unsigned long a_u4Position)
{
int ret = 0;
LOG_INF("move main af start\n");
mutex_lock(&main_af_mutex);

if ((a_u4Position > g_u4AF_MACRO) || (a_u4Position < g_u4AF_INF)) {
LOG_INF("out of range\n");
ret = -EINVAL;
goto end;
return -EINVAL;
}

if (*g_pAF_Opened == 1) {
Expand Down Expand Up @@ -263,7 +175,7 @@ static inline int moveAF(unsigned long a_u4Position)
}

if (g_u4CurrPosition == a_u4Position)
goto end;
return 0;

spin_lock(g_pAF_SpinLock);
g_u4TargetPosition = a_u4Position;
Expand All @@ -280,9 +192,7 @@ static inline int moveAF(unsigned long a_u4Position)
} else {
LOG_INF("set I2C failed when moving the motor\n");
}
end:
mutex_unlock(&main_af_mutex);
LOG_INF("move main af end\n");

return 0;
}

Expand Down Expand Up @@ -388,21 +298,9 @@ int AK7371AF_PowerDown(void)
return 0;
}

/* Add by meizu BSP [email protected] */
#ifdef CONFIG_MEIZU_BSP
struct vcm_factory_fops ak7371_main_fops = {
.vcm_enable = ak7371_enable,
.vcm_pos_set = ak7371_pos_set,
.vcm_pos_get = ak7371_pos_get,
};
#endif
/*Add end */

int AK7371AF_SetI2Cclient(struct i2c_client *pstAF_I2Cclient, spinlock_t *pAF_SpinLock, int *pAF_Opened)
void AK7371AF_SetI2Cclient(struct i2c_client *pstAF_I2Cclient, spinlock_t *pAF_SpinLock, int *pAF_Opened)
{
g_pstAF_I2Cclient = pstAF_I2Cclient;
g_pAF_SpinLock = pAF_SpinLock;
g_pAF_Opened = pAF_Opened;

return (s4AF_WriteReg(0x02, 0x00) == 0);
}
13 changes: 0 additions & 13 deletions drivers/misc/mediatek/lens/main/common/bu63165af/OIS_func.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* Copyright (C) Rohm Co.,Ltd. All rights reserved.
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

/* /////////////////////////////////////////////////////////////////////////// */
/* File Name : OIS_func.c */
/* Function : Various function for OIS control */
Expand Down
13 changes: 0 additions & 13 deletions drivers/misc/mediatek/lens/main/common/bu63165af/OIS_main.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* Copyright (C) Rohm Co.,Ltd. All rights reserved.
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

/* /////////////////////////////////////////////////////////////////////////// */
/* File Name : OIS_main.c */
/* Function : Main control function runnning on ISP. */
Expand Down
13 changes: 0 additions & 13 deletions drivers/misc/mediatek/lens/main/common/bu63165af/OIS_user.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* Copyright (C) Rohm Co.,Ltd. All rights reserved.
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

/* /////////////////////////////////////////////////////////////////////////// */
/* File Name : OIS_user.c */
/* Function : User defined function. */
Expand Down
13 changes: 0 additions & 13 deletions drivers/misc/mediatek/lens/main/common/bu63165af/inc/OIS_coef.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* Copyright (C) Rohm Co.,Ltd. All rights reserved.
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#ifndef OIS_COEF_H
#define OIS_COEF_H

Expand Down
13 changes: 0 additions & 13 deletions drivers/misc/mediatek/lens/main/common/bu63165af/inc/OIS_defi.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* Copyright (C) Rohm Co.,Ltd. All rights reserved.
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

/* /////////////////////////////////////////////////////////////////////////// */
/* File Name : OIS_defi.h */
/* Function : Header file for OIS controller */
Expand Down
13 changes: 0 additions & 13 deletions drivers/misc/mediatek/lens/main/common/bu63165af/inc/OIS_func.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* Copyright (C) Rohm Co.,Ltd. All rights reserved.
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#ifndef OIS_FUNC_H
#define OIS_FUNC_H

Expand Down
Loading

0 comments on commit 6b28a98

Please sign in to comment.