MT6573 YuSu Keypad Customer Document [0.3 ed.]

  • Commentary
  • https://github.com/luckasfb/Development_Documents
  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

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 Keypad Customer Document

Version: Release date:

0.3 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 YuSu 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

0.1

2010-04-27

Terry Chang

Initial Draft

0.2

2010-06-18

Terry Chang

Add one note in section 1.4

0.3

2011-01-26

Wenjun Gao

Update customization configuration related with MT6573

FO

Revision

MediaTek Confidential

Description

© 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 11

LY

MT65XX YuSu 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............................................................................................................................................ 6 2.1 2.2

3

Data Structures..................................................................................................................... 8 Functions .............................................................................................................................. 8 3.2.1 kpd_backlight_handler ......................................................................................... 8 3.2.2 kpd_dev_ioctl ....................................................................................................... 8

Customization............................................................................................................................... 9 4.1 4.2

5

Architecture........................................................................................................................... 6 Procedure & Flow ................................................................................................................. 6

Interface......................................................................................................................................... 8 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

DCT (Driver Customization Tool) ......................................................................................... 9 Other Compile Options ....................................................................................................... 10

Build............................................................................................................................................. 11

FO

5.1 5.2

Source Code Structure & File Description.......................................................................... 11 Build Option ........................................................................................................................ 11

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 11

LY

MT65XX YuSu 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: Keypad driver discussed in this document is designed based on Linux Kernel 2.6.29 and Android 2.1. For MT6573 Platform: Keypad driver discussed in this document is designed based on Linux Linux Kernel 2.6.35 and Android 2.3.

1.1.2

Hardware Environment

Keypad driver discussed in this document can run on the devices with MT6516 or MT6573.

1.2

Functionality

Keypad driver’s main functionality: (1) Report the key event based on a key mapping table when the key is pressed or released. (2) Report the key event when Power key is pressed or released. (3) Report the switch event when Slide QWERTY keypad is slid in or out.

1.3

Hardware Background

When the key is pressed or released, there is a keypad interrupt issued. When Power key is pressed /released or Slide QWERTY keypad is slid in/out, there is a EINT (External Interrupt) issued.

1.4

Hardware Component Used in This Driver

FO

Keypad matrix shown in Figure 1 has 8 rows and (8 + 1) columns (HW keycode are 0 to 71). Column 8 (HW keycode are 8, 17, 26, 35, 44, 53, 62, 71) is dedicated for Power key, so we can have 8 * 8 = 64 keys detected through Keypad matrix. Each time the key is pressed or released, i.e., when something is different in Keypad matrix, the key detection block in Keypad Scanner senses the change and recognizes if a key has been pressed or released. Whenever the key status changes and is stable, a keypad interrupt is issued.

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 11

LY

MT65XX YuSu 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

Note: Due to HW limitation, simultaneously pressing more than two keys may not function correctly. For example, there are four keys: key1 (row6, col0), key2 (row6, col1), key3 (row7, col0), key4 (row7, col1). If we press key1, key2 and key4 at the same time, key3 may be detected as pressed.

Figure 1: Keypad Matrix

FO

Figure 2: HW Keycode Table

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 11

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 YuSu Confidential B

The architecture of Keypad driver is shown in Figure 3. There are four main tasks in Keypad driver: 1. If the key is pressed or released, recognize which key and report the key event based on a key mapping table to Input subsystem through Keypad input device. 2. Use PWR_KEY EINT to detect whether Power key is pressed or released and report the key event to Input subsystem through Keypad input device. 3. If the device has Slide QWERTY keypad, use SLIDE EINT to detect whether QWERTY keypad is slid in or out and report the switch event to Input subsystem through Keypad input device. 4. For META tool, use PMIC KPLED to show the backlight effect.

Figure 3: Keypad Driver Architecture

2.2

Procedure & Flow

FO

When the key is pressed or released, Keypad Scanner will issue a interrupt, then Keypad driver recognizes this key’s keycode and state from Keypad Scanner registers. This kind of keycode is called HW keycode (0 to 71). The responsibility of Keypad driver is to translate HW keycode to Linux keycode based on a pre-defined key mapping table. After Keypad driver gets the Linux keycode, it will report this Linux keycode to upper layer Input subsystem. And then, Android EventHub can get this Linux keycode from Input subsystem and translates it to Android keycode. So from this layer Android EventHub, the key pressing or releasing is represented as a key event with Android keycode. The keycode translation flow is shown in Figure 4.

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 11

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 YuSu Confidential B

Figure 4: Keycode Translation Flow

Note-1: The detection of Power key may use PWR_KEY EINT not through Keypad Scanner, so in this case, we are not going to get Power key’s HW keycode from Keypad Scanner registers.

FO

Note-2: The language support needs to rely on IME (Input Method Engine) not Keypad driver. Keypad driver’s main task is to report the key event with the correct “Linux keycode” and state to upper layer when the key is pressed or released.

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 11

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 YuSu Confidential B

This section discusses the data structures and functions used by other kernel modules.

3.1

Data Structures

This structure is used for SET_KPD_BACKLIGHT command in kpd_dev_ioctl(). struct kpd_ledctl { u8 onoff; u8 div; /* 0 ~ 15 */ u8 duty; /* 0 ~ 31 */ };

3.2

Functions

3.2.1

kpd_backlight_handler

Prototype

void kpd_backlight_handler(bool pressed, u16 linux_keycode) Parameters in

pressed

The key is pressed or released

in

linux_keycode

The key’s Linux keycode

Return Value None

3.2.2

kpd_dev_ioctl

Prototype

long kpd_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) Parameters in

file

File pointer

in

cmd

IOCTL command

in/out

arg

The command’s argument and it could be input or output

Return Value

The return value depends on IOCTL command The supported IOCTL commands are: SET_KPD_BACKLIGHT

ARG

The address of kpd_ledctl structure passed by the caller

Return

0: the operation succeeds; otherwise: the operation fails

FO

CMD

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 11

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 YuSu Confidential B

This section discusses how to customize Keypad driver.

4.1

DCT (Driver Customization Tool)

DCT is used to customize the key mapping, de-bounce time and Power key setting in Keypad driver. The screen snapshot is shown in Figure 5 (“2 Step Key” options are unused).

Figure 5: Keypad Setting in DCT

1. Key Mapping This is corresponding to Keypad matrix. If you want to map MENU key in (row1, column1) (HW keycode is 10) in Keypad matrix, you can choose “MENU” in [Row1, Column1]. DCT will generate “[10] = KEY_MENU,” in cust_kpd.h so that Keypad driver can use this mapping to report the key event when (row1, column1) is pressed or released. Note: DCT will skip “NONE” in [RowX, ColumnX] when generating cust_kpd.h.

FO

2. De-Bounce Time The number in “Keypress_Period” divided by 32 means the Keypad’s de-bounce time (millisecond). For example, the number 1024 in “Keypress_Period” means the de-bounce time is 1024 / 32 = 32 ms.

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 11

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 YuSu Confidential B

3. Power Key Setting If you want to use EINT to detect Power key’s pressing and releasing, you can check the box “PowerKey use EINT” and choose “POWER” or “ENDCALL” in “Power Key definition” so that Keypad driver can use this mapping to report the key event when EINT is issued. Note-1: Although there is a dedicated column8 in Keypad matrix for Power key, we usually use EINT4 to detect Power key’s pressing and releasing. Note-2: If you want to use EINT to detect Power key’s pressing and releasing, you have to configure EINT related setting by using DCT.

4.2

Other Compile Options

In addition to cust_kpd.h generated by DCT, there is mt6516_kpd.h or mt6573_kpd.h in Keypad driver to centralize other compile options. We can use this header file to enable/disable some functionality of Keypad driver. 1. KPD_DRV_CTRL_BACKLIGHT This compile option is used to enable the backlight control function in Keypad driver. However, this compile option will retire soon because the keypad backlight related implementation will move into LED driver and the keypad backlight will be controlled by Android Framework through LED driver. Sub-Options: #define KPD_BACKLIGHT_TIME 8 /* sec */ /* the keys can wake up the system and we should enable backlight */ #define KPD_BACKLIGHT_WAKE_KEY \ { \ KEY_ENDCALL, KEY_POWER,\ } 2. KPD_HAS_SLIDE_QWERTY If the device has Slide QWERTY keypad, you can turn on this compile option to enable the sliding support function in Keypad driver.

FO

Note: We use EINT to detect QWERTY keypad’s sliding in and sliding out, so you have to configure EINT related setting by using DCT.

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 11

LY

MT65XX YuSu 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

For MT6516 Platform: File

Description

mtk/src/custom/{project name}/kernel/dct/dct/ cust_kpd.h

The header file generated by DCT

mtk/src/custom/{project name}/kernel/kpd/kpd/ mt6516_kpd.h

The header file used to enable/disable some functionality of Keypad driver

mt6516_kpd_bkl.c

Keypad backlight related implementation

kernel/drivers/input/keyboard/ mt6516_kpd.c

The core of Keypad driver

For MT6573 Platform: File

Description

mediatek/custom//kernel/dct/dct/ cust_kpd.h

The header file generated by DCT

mediatek/custom//kernel/kpd/kpd/ mt6573_kpd.h

The header file used to enable/disable some functionality of Keypad driver

mt6573_kpd_bkl.c

Keypad backlight related implementation

mediatek/platform//kernel/drivers/keypad/ kpd.c

5.2

The core of Keypad driver

Build Option

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 11 of 11