226 27 764KB
English Pages 15 Year 2011
LY M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
Yusu OFN Customer Document
Version: Release date:
1.2 2011-01-26
© 2008 - 2011 MediaTek Inc. This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
FO
Specifications are subject to change without notice.
LY
MT65XX Chip Name Confidential B
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
Document Revision History
Date
Author
1.0
2010-06-16
MingHsien Hsieh
Initial Draft
1.1
2010-07-03
MingHsien Hsieh
Modify customization item
1.2
2011-01-26
Wenjun Gao
FO
Revision
MediaTek Confidential
Description
Update customization configuration related with MT6573
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 2 of 15
LY
MT65XX Chip Name Confidential B
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
Table of Contents
Document Revision History .................................................................................................................. 2 Table of Contents................................................................................................................................... 3 1
Introduction................................................................................................................................... 4 1.1
1.2 1.3 1.4
2
Design............................................................................................................................................ 7 2.1 2.2
3
Data Structure....................................................................................................................... 9 Kernel API Of Input Device................................................................................................... 9 3.2.1 input_allocate_device........................................................................................... 9 3.2.2 input_free_device ................................................................................................. 9 3.2.3 input_set_capability.............................................................................................. 9 3.2.4 input_register_device ......................................................................................... 10 3.2.5 input_unregister_device ..................................................................................... 10
Customization............................................................................................................................. 11 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8
5
Architecture........................................................................................................................... 7 Procedure & Flow ................................................................................................................. 7
Interface......................................................................................................................................... 9 3.1 3.2
4
Software/Hardware Environment.......................................................................................... 4 1.1.1 Software Environment .......................................................................................... 4 1.1.2 Hardware Environment......................................................................................... 4 Functionality.......................................................................................................................... 4 Hardware background .......................................................................................................... 4 Hardware Component used in this driver ............................................................................. 4
power_id & power_vol ........................................................................................................ 12 report_cls ............................................................................................................................ 12 chip_id ................................................................................................................................ 12 slave_addr .......................................................................................................................... 12 i2c_num .............................................................................................................................. 12 layout .................................................................................................................................. 12 quan_x / quan_y / accu_max.............................................................................................. 13 DCT Integration .................................................................................................................. 13
Build............................................................................................................................................. 14
FO
5.1 5.2
Source Code Structure & File Description.......................................................................... 14 Build Option ........................................................................................................................ 14
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 3 of 15
LY
MT65XX Chip Name Confidential B
Introduction
1.1
Software/Hardware Environment
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
1
1.1.1
Platform
Software Environment
Hardware Environment
MT6516
Linux Kernel 2.6.29 and Android 2.1
MT6516
MT6573
Linux Kernel 2.6.35 and Android 2.3
MT6573
Software Environment
For MT6516 Platform: Driver discussed in this document is designed based on Linux Kernel 2.6.29 and Android 2.1. For MT6573 Platform: Driver discussed in this document is designed based on Linux Kernel 2.6.35 and Android 2.3.
1.1.2
Hardware Environment
Driver discussed in this document can run on the devices with MT6516 or MT6573.
1.2
Functionality
The OFN acts as an input device. It could be used as either keyboard or trackball. For keyboard class, it will report four direction key codes to upper layer. For trackball class, it will report delta movement in x and y axes.
1.3
Hardware background
OFN stands for Optical Finger Navigation. This technology measures changes in position by optically acquiring sequential surface images (frames) and mathematically determining the direction and magnitude of movement.
1.4
Hardware Component used in this driver
The device, ADBS-A320, is provided by Avago. The basic idea is as follows:
FO
(1) Movement of finger activates the illumination of IR source. The IR source locates the microscopic pattern of the finger surface. (2) The shadow of this pattern is reflected onto the optical CMOS sensor. (3) Microcontroller translates the motion information to the computer
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 4 of 15
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
LY
MT65XX Chip Name Confidential B
The structure of ADBS-A320 is as follows:
FO
The sensor is programmed via registers through either a serial peripheral interface or two wire interface port (I2C). MTK chooses the I2C interface as the communication channel. The schematic of OFN is as follows:
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 5 of 15
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
LY
MT65XX Chip Name Confidential B
Hence, MT6516 or MT6573 will communicate with OFN devices using the third I2C interface. Besides the I2C interface, three pins are required: reset (OFN_RST), shutdown (OFN_DWN) and interrupt (OFN_INT).
FO
(1) Reset pin: hardware reset pin. The device will be reset when the pin changes from low to high (2) Shutdown pin: hardware shutdown pin. Push it to high will put device to sleep mode. Hence, it should be set low in working mode (3) Interrupt pin: motion interrupt pin. It’s low active. Hence, when movement is detected by OFN device, its value changes from high to low.
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 6 of 15
Design
2.1
Architecture
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
2
LY
MT65XX Chip Name Confidential B
Android designed a simple framework for accessing input devices, such as keypad, mouse, touch panel. The behavior of jogball device in Android is similar to a keyboard device. However, the behavior is simulated by Android Framework. Actually, jogball device driver should be implemented as a trackball class. Android Framework will check trackball device in EventHub if the following conditions are satisfied: (1) The input device registers the key event: BTN_MOUSE (2) The input device registers relative control: REL_X & REL_Y.
2.2
Procedure & Flow
FO
The flow is described as follows: (1) WindowManager will create an instance of KeyInputQueue. When the instance is created, a thread inside the instance will continuously get input event from EventHub. (2) During the first call of getEvent, all the input devices under /dev/input will be opened and checked. According to frameworks\base\include\ui\EventHub.h, six devices are detected: keyboard, alpha MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 7 of 15
LY
MT65XX Chip Name Confidential B
FO
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
key, touch screen, trackball, multi-touch, DPAD. The handle of detected device will be opened and use poll function call to wait the input event. (3) Once the input event is reported from the polled file handle, the getEvent function will handle those events. (4) The events handled by getEvent will be return to WindowManagerService. The instance of WindowManagerService will dispatch the key event to applications.
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 8 of 15
Interface
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
3
LY
MT65XX Chip Name Confidential B
Since the interface between Linux kernel and Android platform is input device. Several interface of input device will be briefly introduced in the chapter.
3.1
Data Structure
The most important structure of kernel\include\linux\input.h for detail.
3.2
input
device
is
struct
input_dev.
Please
see
Kernel API Of Input Device
3.2.1
input_allocate_device
Allocate input device Prototype
struct input_dev *input_allocate_device(void) Return Value
The pointer of allocated input device. NULL is returned if no memory.
3.2.2
input_free_device
Free memory occupied by input_dev structure Prototype
void input_free_device(struct input_dev *dev) Parameters In
dev
input device to free
Return Value NONE
3.2.3
input_set_capability
Mark device as capable of a certain event Prototype
void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code) Parameters In
dev
device that is capable of emitting or accepting event
In
type
type of the event (EV_KEY, EV_REL, etc...)
In
code
event code
Return Value
FO
None
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 9 of 15
input_register_device
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
3.2.4
LY
MT65XX Chip Name Confidential B
Register device with input core Prototype
int input_register_device(struct input_dev *dev) Parameters In
dev
input device to free
Return Value
0: successful Otherwise: error code
3.2.5
input_unregister_device
Unregister previously registered device Prototype
void input_unregister_device(struct input_dev *dev) Parameters In
dev
input device to free
Return Value
FO
NONE
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 10 of 15
Customization
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
4
LY
MT65XX Chip Name Confidential B
The corresponding structure is defined in : For MT6516 Platform: mtk\src\custom\common\kernel\ofn\inc\cust_ofn.h: For MT6573 Platform: mediatek\custom\common\kernel\ofn\inc\cust_ofn.h:
/*----------------------------------------------------------------------------*/ typedef enum { OFN1026 = 1026, OFN1086 = 1086, OFN1090 = 1090, }OFN_ID; /*----------------------------------------------------------------------------*/ typedef enum { OFN_DETECT_POLL = 0, OFN_DETECT_EINT = 1, } OFN_DETECT; /*----------------------------------------------------------------------------*/ typedef enum { OFN_CLASS_KEYBOARD, OFN_CLASS_TRACKBALL, } OFN_CLASS; /*----------------------------------------------------------------------------*/ struct ofn_hw { int power_id; int power_vol; int OFN_ID int int unsigned int
report_cls; chip_id; slave_addr; i2c_num; layout;
/*trackball class*/ int quan_x; int quan_y; int accu_max;
/*keyboard class*/ int detect; int gpt_num; int gpt_period;
FO
int int int
acc_cnt; inact_cnt; act_cnt;
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 11 of 15
sup_cnt; step;
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
int int
LY
MT65XX Chip Name Confidential B
}; /*----------------------------------------------------------------------------*/
Since the reported class is always defined as OFN_CLASS_TRACKBALL, only the customization items related to trackball class is described.
4.1
power_id & power_vol
The two configuration items relate to power source. If the power source is LDO, the power could be turned off when system enter suspend. Please refer to mt6516_pll.h or mt6573_pll.h for the enumeration of power_id and power_vol. If there’s no LDO source for MT6516, please set power_id as MT6516_POWER_NONE. If for MT6573, please set power_id as MT65XX_POWER_NONE.This is also default value.
4.2
report_cls
For trackball class implementation please set the field as OFN_CLASS_TRACKBALL. This is also default value.
4.3
chip_id
Avago provides many similar chips for the same functionality. The initialization flow will be slightly different in different models. Please fill the correct chip ID. Currently, only three chips are supported. Please refer to OFN_ID.
4.4
slave_addr
According to Avago’s data sheet, the slave address of device could be chosen according to layout. Hence, the slave address should be customized according to layout.
4.5
i2c_num
The OFN device could be bound in different i2c bus. Hence, the item is the i2c bus ID that OFN resides. The default value is 2.
4.6
layout
BIT
Field
Description
BIT 2
XY_SWAP
BIT 1
Y_INV
FO
According to Avago’s data sheet, the data reported from register will vary depends on device layout. The field is a three bit binary. Please see the following definition:
X_INV
0 = Normal sensor reporting of DX, DY (default) 1 = Swap data of DX to DY and DY to DX 0 = Normal sensor reporting of DY. (default) 1 = Invert data of DY only 0 = Normal sensor reporting of DX. (default) 1 = Invert data of DX only
BIT 0
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 12 of 15
quan_x / quan_y / accu_max
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
4.7
LY
MT65XX Chip Name Confidential B
The three parameters are used adjust sensitivity. When user moves his finger over the OFN, the delta movement will be reported. However, those raw data must be processed before reporting to the Android. In the driver, the delta movement will be accumulated until the accumulated value exceeds some threshold. The items, quan_x & quan_y are the threshold. Sometimes, the delta movement reported by sensor will be very large if user moves his finger very fast. The large value will be suppressed by accu_max. Hence, the flow for reporting input event is summarized as follows: (1) Initially, reset the counter in x & y axis. Assume the counters are named as accu_x and accu_y respectively. (2) Once receiving a motion interrupt, read the x & y movement from register. Add delta movement to accu_x and accu_y. If the movement is larger than accu_max, only accu_max is accumulated to accu_x/accu_y. (3) If accu_x or accu_y exceeds quan_x and quan_y respectively, the following event will be reported: (a) input_report_rel(obj->dev, REL_X, accu_x/quan_x) (b) input_report_rel(obj->dev, REL_X, accu_y/quan_y)
4.8
DCT Integration
According to data sheet, there are two GPIO pins and one external interrupt pin. The corresponding definitions in DCT are list as follows: Description
GPIO_OFN_DWN_PIN GPIO_OFN_RST_PIN GPIO_OFN_EINT_PIN CUST_EINT_OFN_NUM CUST_EINT_OFN_DEBOUNCE_CN CUST_EINT_OFN_POLARITY CUST_EINT_OFN_SENSITIVE CUST_EINT_OFN_DEBOUNCE_EN
Shutdown pin. It’s important in power on / shutdown sequence Reset pin. It’s important for power on sequence The external interrupt pin for detecting motion The ID of external interrupt used for OFN The debounce count of EINT pin. It's set as zero by default. The polarity of EINT pin. It’s set as low by default. The sensitivity of EINT pin. It’s set as level sensitive by default The debounce enable of EINT pin. It’s set as disable by default
FO
DCT definition
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 13 of 15
LY
MT65XX Chip Name Confidential B
Build
5.1
Source Code Structure & File Description
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
5
Describe your source code structure along with its file description as follows: For MT6516 Platform: File
Description
alps/kernel/drivers/input/mouse/ a320.c
The OFN device driver
a320.h
The header file of OFN device driver
alps/mtk/src/custom/common/kernel/ofn/inc cust_ofn.h
The header file of OFN customization
alps/mtk/src/custom//kernel/ofn// cust_ofn.c
The content of OFN customization
For MT6573 Platform: File
Description
alps/mediate/platform//kernel/drivers/mouse/ a320.c
The OFN device driver
alps/mediate/source/kernel/drivers/mouse/ a320.h
The header file of OFN device driver
alps/mediate/custom/common/kernel/ofn/inc/ cust_ofn.h
The header file of OFN customization
alps/mediatek/custom//kernel/ofn// cust_ofn.c
5.2
The content of OFN customization
Build Option
FO
For MT6516 Platform: The kernel configuration of jogball is CONFIG_MT6516_ADBS_A320. User could turn on/off the option by “make menuconfig”: (1) Enter Device Drivers > Misc devices. (2) Enable Jogball driver by pressing space until:
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 14 of 15
M R ED yu IA .li@ T E tin K C no O mo NF bil ID e.c EN om T I US AL EO N
LY
MT65XX Chip Name Confidential B
(3) Disable Jogball driver by pressing space until:
(4) Please remember to commit the change to board specific kernel configuration file.
FO
For MT6573 Platform: Enable OFN: 1. Check the configuration file (usually mediatek/config//autoconfig/kconfig/project) 2. Search for CONFIG_INPUT_MOUSE. 3. Set it as “CONFIG_INPUT_MOUSE=y”. 4. Search for CONFIG_MOUSE_AVAGOTECH_A320. 5. Set it as “CONFIG_MOUSE_AVAGOTECH_A320=y”. 6. Check the ProjectConfig.mk under /mediatek/config//. 7. Search for CUSTOM_KERNEL_OFN. 8. Set it as “CUSTOM_KERNEL_OFN = xxx”. (xxx is the specific module name) Disable OFN: 1. Check the configuration file (usually mediatek/config//autoconfig/kconfig/project) 2. Search for CONFIG_MOUSE_AVAGOTECH_A320. 3. Set it as “CONFIG_MOUSE_AVAGOTECH_A320 is not set”.
MediaTek Confidential
© 2010 - 2011 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
Page 15 of 15