summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/tatung/tpj1022/button-target.h45
-rw-r--r--firmware/target/arm/tatung/tpj1022/button-tpj1022.c56
2 files changed, 33 insertions, 68 deletions
diff --git a/firmware/target/arm/tatung/tpj1022/button-target.h b/firmware/target/arm/tatung/tpj1022/button-target.h
index c7afa59070..979cf88936 100644
--- a/firmware/target/arm/tatung/tpj1022/button-target.h
+++ b/firmware/target/arm/tatung/tpj1022/button-target.h
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2006 by Barry Wardell 10 * Copyright (C) 2006 by Robert Kukla
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -22,34 +22,33 @@
22#ifndef _BUTTON_TARGET_H_ 22#ifndef _BUTTON_TARGET_H_
23#define _BUTTON_TARGET_H_ 23#define _BUTTON_TARGET_H_
24 24
25#include <stdbool.h>
26#include "config.h"
27
28#define HAS_BUTTON_HOLD 25#define HAS_BUTTON_HOLD
29 26
27#define button_init_device()
28
30bool button_hold(void); 29bool button_hold(void);
31void button_init_device(void);
32int button_read_device(void); 30int button_read_device(void);
33 31
34/* Tatung Elio TPJ-1022 button codes */
35
36/* Main unit's buttons */ 32/* Main unit's buttons */
37#define BUTTON_POWER 0x00000001 33
38 34#define BUTTON_VOL_DOWN 0x00000001
39#define BUTTON_LEFT 0x00000002 35
40#define BUTTON_RIGHT 0x00000004 36/* bit position in GPIOA */
41#define BUTTON_UP 0x00000008 37#define BUTTON_REW 0x00000002
42#define BUTTON_DOWN 0x00000010 38#define BUTTON_FF 0x00000004
43 39#define BUTTON_POWER 0x00000008
44#define BUTTON_MENU 0x00000020 40#define BUTTON_UP 0x00000010
45#define BUTTON_FF 0x00000040 41#define BUTTON_DOWN 0x00000020
46#define BUTTON_REW 0x00000080 42#define BUTTON_AB 0x00000040
47#define BUTTON_REC 0x00000100 43#define BUTTON_RIGHT 0x00000080
48#define BUTTON_AB 0x00000200 44
49#define BUTTON_PLUS 0x00000400 45/* still unknown */
50#define BUTTON_MINUS 0x00000800 46#define BUTTON_MENU 0x00000100
51 47#define BUTTON_REC 0x00000200
52#define BUTTON_MAIN 0x00000fff 48#define BUTTON_VOL_UP 0x00000400
49#define BUTTON_LEFT 0x00000800
50
51#define BUTTON_MAIN 0x00000FFF
53 52
54/* No Remote control */ 53/* No Remote control */
55#define BUTTON_REMOTE 0 54#define BUTTON_REMOTE 0
diff --git a/firmware/target/arm/tatung/tpj1022/button-tpj1022.c b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c
index 6cdca5b35d..ce9d7ab24d 100644
--- a/firmware/target/arm/tatung/tpj1022/button-tpj1022.c
+++ b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2006 by Barry Wardell 10 * Copyright (C) 2006 by Robert Kukla
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -19,64 +19,30 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22/* Custom written for the TPJ-1022 based on analysis of the GPIO data */
23
24#include <stdlib.h>
25#include "config.h"
26#include "cpu.h"
27#include "system.h" 22#include "system.h"
28#include "button.h" 23#include "button.h"
29#include "kernel.h"
30#include "backlight.h"
31
32void button_init_device(void)
33{
34 /* No hardware initialisation required as it is done by the bootloader */
35}
36 24
37bool button_hold(void) 25bool button_hold(void)
38{ 26{
39 return false; 27 return (GPIOK_INPUT_VAL & 0x40) ? true : false;
40} 28}
41 29
42/*
43 * Get button pressed from hardware
44 */
45int button_read_device(void) 30int button_read_device(void)
46{ 31{
47 int btn = BUTTON_NONE; 32 int btn = BUTTON_NONE;
48 unsigned char state;
49 static bool hold_button = false;
50 33
51#if 0 34 if (!button_hold())
52 /* light handling */
53 if (hold_button && !button_hold())
54 { 35 {
55 backlight_on(); 36 btn = (GPIOA_INPUT_VAL & 0xfe) ^ 0xfe;
56 }
57#endif
58 37
59 hold_button = button_hold(); 38 if ((GPIOK_INPUT_VAL & 0x20) == 0) btn |= BUTTON_VOL_DOWN;
60 if (!hold_button)
61 {
62 /* Read normal buttons */
63 state = GPIOA_INPUT_VAL;
64 if ((state & 0x2) == 0) btn |= BUTTON_REW;
65 if ((state & 0x4) == 0) btn |= BUTTON_FF;
66 if ((state & 0x80) == 0) btn |= BUTTON_RIGHT;
67 39
68 /* Buttons left to figure out: 40 /* to be found
69 button_hold() 41 if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_MENU;
70 BUTTON_POWER 42 if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_REC;
71 BUTTON_LEFT 43 if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_VOL_UP;
72 BUTTON_UP 44 if ((GPIO?_INPUT_VAL & 0x??) == 0) btn |= BUTTON_LEFT;
73 BUTTON_DOWN 45 */
74 BUTTON_MENU
75 BUTTON_REC
76 BUTTON_AB
77 BUTTON_PLUS
78 BUTTON_MINUS
79 */
80 } 46 }
81 47
82 return btn; 48 return btn;