summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-02-22 20:33:20 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2014-02-22 20:33:20 +0100
commita2bfbe9ebc9797894507e1a11bdcc372e4379509 (patch)
treec2cb75b8569ed4cd52a40955dff0dd26a3e5b2d2 /firmware/target/arm
parent82b86d4316d0e9d74c5ea086797750b0975e9023 (diff)
zen{,xfi,mozaic,xfistyle,v}: switch to the new button driver
Change-Id: I206b16f6374f536ab6d84e84fefc8370a96ef759
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/imx233/creative-zen/button-target.h17
-rw-r--r--firmware/target/arm/imx233/creative-zen/button-zen.c216
2 files changed, 105 insertions, 128 deletions
diff --git a/firmware/target/arm/imx233/creative-zen/button-target.h b/firmware/target/arm/imx233/creative-zen/button-target.h
index e9a3ac5ab7..eb4f45ccf7 100644
--- a/firmware/target/arm/imx233/creative-zen/button-target.h
+++ b/firmware/target/arm/imx233/creative-zen/button-target.h
@@ -28,23 +28,6 @@ bool button_debug_screen(void);
/* HOLD button */
#if !defined(CREATIVE_ZENXFISTYLE)
#define HAS_BUTTON_HOLD
-#define IMX233_BUTTON_LRADC_HOLD_DET BLH_ADC
-#endif
-
-/* VDDIO value */
-#if defined(CREATIVE_ZENXFISTYLE)
-#define IMX233_BUTTON_LRADC_VDDIO 3660
-#elif defined(CREATIVE_ZEN)
-#define IMX233_BUTTON_LRADC_VDDIO 3480
-#elif defined(CREATIVE_ZENXFI)
-#define IMX233_BUTTON_LRADC_VDDIO 3500
-#endif
-
-/* LRADC channel */
-#if defined(CREATIVE_ZENXFISTYLE)
-#define IMX233_BUTTON_LRADC_CHANNEL 2
-#else
-#define IMX233_BUTTON_LRADC_CHANNEL 0
#endif
/* Main unit's buttons */
diff --git a/firmware/target/arm/imx233/creative-zen/button-zen.c b/firmware/target/arm/imx233/creative-zen/button-zen.c
index fa01e9370e..ed54d42eb8 100644
--- a/firmware/target/arm/imx233/creative-zen/button-zen.c
+++ b/firmware/target/arm/imx233/creative-zen/button-zen.c
@@ -23,137 +23,131 @@
#include "system-target.h"
#include "pinctrl-imx233.h"
#include "power-imx233.h"
-#include "button-lradc-imx233.h"
+#include "button-imx233.h"
-#if defined(CREATIVE_ZENXFI) || defined(CREATIVE_ZENMOZAIC)
-#define JACK_DET_BANK 2
-#define JACK_DET_PIN 8
-#define JACK_DET_INVERTED
-#elif defined(CREATIVE_ZENXFISTYLE)
-#define JACK_DET_BANK 2
-#define JACK_DET_PIN 7
-#endif
+#if defined(CREATIVE_ZENXFISTYLE)
+#define CHAN 2
+#define I_VDDIO 0 /* index in the table */
+
+struct imx233_button_map_t imx233_button_map[] =
+{
+ [I_VDDIO] = IMX233_BUTTON_(VDDIO, VDDIO(3660), "vddio"), /* we need VDDIO for relative */
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 230, I_VDDIO), "menu"),
+ IMX233_BUTTON(SHORTCUT, LRADC_REL(CHAN, 480, I_VDDIO), "shortcut"),
+ IMX233_BUTTON(UP, LRADC_REL(CHAN, 690, I_VDDIO), "up"),
+ IMX233_BUTTON(LEFT, LRADC_REL(CHAN, 920, I_VDDIO), "left"),
+ IMX233_BUTTON(RIGHT, LRADC_REL(CHAN, 1120, I_VDDIO), "right"),
+ IMX233_BUTTON(DOWN, LRADC_REL(CHAN, 1335, I_VDDIO), "down"),
+ IMX233_BUTTON(SELECT, LRADC_REL(CHAN, 1565, I_VDDIO), "select"),
+ IMX233_BUTTON(BACK, LRADC_REL(CHAN, 2850, I_VDDIO), "back"),
+ IMX233_BUTTON(PLAYPAUSE, LRADC_REL(CHAN, 3110, I_VDDIO), "play"),
+ IMX233_BUTTON_(JACK, GPIO(2, 7), "jack"),
+ IMX233_BUTTON(POWER, GPIO(0, 11), "power", INVERTED),
+ IMX233_BUTTON_(END, END(), "")
+};
+#elif defined(CREATIVE_ZEN)
+#define CHAN 0
+#define I_VDDIO 0 /* index in the table */
-struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
+struct imx233_button_map_t imx233_button_map[] =
{
-#if defined(CREATIVE_ZEN)
- {200, IMX233_BUTTON_LRADC_HOLD},
- {250, BUTTON_MENU},
- {520, BUTTON_SHORTCUT},
- {1490, BUTTON_UP},
- {1740, BUTTON_SELECT},
- {2015, BUTTON_LEFT},
- {2255, BUTTON_RIGHT},
- {2485, BUTTON_DOWN},
- {2700, BUTTON_BACK},
- {2945, BUTTON_PLAYPAUSE},
- {3400, 0},
- {0, IMX233_BUTTON_LRADC_END},
+ [I_VDDIO] = IMX233_BUTTON_(VDDIO, VDDIO(3480), "vddio"), /* we need VDDIO for relative */
+ IMX233_BUTTON_(HOLD, LRADC_REL(CHAN, 200, I_VDDIO), "hold"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 250, I_VDDIO), "menu"),
+ IMX233_BUTTON(SHORTCUT, LRADC_REL(CHAN, 520, I_VDDIO), "shortcut"),
+ IMX233_BUTTON(UP, LRADC_REL(CHAN, 1490, I_VDDIO), "up"),
+ IMX233_BUTTON(SELECT, LRADC_REL(CHAN, 1740, I_VDDIO), "select"),
+ IMX233_BUTTON(LEFT, LRADC_REL(CHAN, 2015, I_VDDIO), "left"),
+ IMX233_BUTTON(RIGHT, LRADC_REL(CHAN, 2255, I_VDDIO), "right"),
+ IMX233_BUTTON(DOWN, LRADC_REL(CHAN, 2485, I_VDDIO), "down"),
+ IMX233_BUTTON(BACK, LRADC_REL(CHAN, 2700, I_VDDIO), "back"),
+ IMX233_BUTTON(PLAYPAUSE, LRADC_REL(CHAN, 2945, I_VDDIO), "play"),
+ IMX233_BUTTON(POWER, PSWITCH(1), "power"),
+ IMX233_BUTTON_(END, END(), "")
+};
#elif defined(CREATIVE_ZENXFI)
- {0, IMX233_BUTTON_LRADC_HOLD},
- {200, BUTTON_MENU},
- {445, BUTTON_SHORTCUT},
- {645, BUTTON_UP},
- {860, BUTTON_LEFT},
- {1060, BUTTON_RIGHT},
- {1260, BUTTON_DOWN},
- {1480, BUTTON_SELECT},
- {1700, BUTTON_TOPRIGHT},
- {1920, BUTTON_BOTTOMLEFT},
- {2145, BUTTON_TOPLEFT},
- {2460, BUTTON_BOTTOMRIGHT},
- {2700, BUTTON_BACK},
- {2945, BUTTON_PLAYPAUSE},
- {3400, 0},
- {0, IMX233_BUTTON_LRADC_END},
-#elif defined(CREATIVE_ZENV)
- {190, IMX233_BUTTON_LRADC_HOLD},
- {250, BUTTON_PLAYPAUSE},
- {530, BUTTON_BACK},
- {785, BUTTON_VOL_UP},
- {1040, BUTTON_VOL_DOWN},
- {1295, BUTTON_MENU},
- {1540, BUTTON_UP},
- {1800, BUTTON_SELECT},
- {2070, BUTTON_LEFT},
- {2315, BUTTON_RIGHT},
- {2550, BUTTON_DOWN},
- {3450, 0},
- {0, IMX233_BUTTON_LRADC_END},
-#elif defined(CREATIVE_ZENMOZAIC)
- {0, IMX233_BUTTON_LRADC_HOLD},
- {200, BUTTON_MENU},
- {445, BUTTON_SHORTCUT},
- {645, BUTTON_UP},
- {860, BUTTON_LEFT},
- {1060, BUTTON_RIGHT},
- {1260, BUTTON_DOWN},
- {1480, BUTTON_SELECT},
- {2700, BUTTON_BACK},
- {2945, BUTTON_PLAYPAUSE},
- {3400, 0},
- {0, IMX233_BUTTON_LRADC_END},
-#elif defined(CREATIVE_ZENXFISTYLE)
- {230, BUTTON_MENU},
- {480, BUTTON_SHORTCUT},
- {690, BUTTON_UP},
- {920, BUTTON_LEFT},
- {1120, BUTTON_RIGHT},
- {1335, BUTTON_DOWN},
- {1565, BUTTON_SELECT},
- {2850, BUTTON_BACK},
- {3110, BUTTON_PLAYPAUSE},
- {3620, 0},
- {0, IMX233_BUTTON_LRADC_END},
-#else
-#error wrong target
-#endif
+#define CHAN 0
+#define I_VDDIO 0 /* index in the table */
+
+struct imx233_button_map_t imx233_button_map[] =
+{
+ [I_VDDIO] = IMX233_BUTTON_(VDDIO, VDDIO(3500), "vddio"), /* we need VDDIO for relative */
+ IMX233_BUTTON_(HOLD, LRADC_REL(CHAN, 0, I_VDDIO), "hold"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 200, I_VDDIO), "menu"),
+ IMX233_BUTTON(SHORTCUT, LRADC_REL(CHAN, 445, I_VDDIO), "shortcut"),
+ IMX233_BUTTON(UP, LRADC_REL(CHAN, 645, I_VDDIO), "up"),
+ IMX233_BUTTON(LEFT, LRADC_REL(CHAN, 860, I_VDDIO), "left"),
+ IMX233_BUTTON(RIGHT, LRADC_REL(CHAN, 1060, I_VDDIO), "right"),
+ IMX233_BUTTON(DOWN, LRADC_REL(CHAN, 1260, I_VDDIO), "down"),
+ IMX233_BUTTON(SELECT, LRADC_REL(CHAN, 1480, I_VDDIO), "select"),
+ IMX233_BUTTON(TOPRIGHT, LRADC_REL(CHAN, 1700, I_VDDIO), "topright"),
+ IMX233_BUTTON(BOTTOMLEFT, LRADC_REL(CHAN, 1920, I_VDDIO), "bottomleft"),
+ IMX233_BUTTON(TOPLEFT, LRADC_REL(CHAN, 2145, I_VDDIO), "topleft"),
+ IMX233_BUTTON(BOTTOMRIGHT, LRADC_REL(CHAN, 2460, I_VDDIO), "bottomright"),
+ IMX233_BUTTON(BACK, LRADC_REL(CHAN, 2700, I_VDDIO), "back"),
+ IMX233_BUTTON(PLAYPAUSE, LRADC_REL(CHAN, 2945, I_VDDIO), "play"),
+ IMX233_BUTTON(POWER, PSWITCH(1), "power"),
+ IMX233_BUTTON_(JACK, GPIO(2, 8), "jack", INVERTED),
+ IMX233_BUTTON_(END, END(), "")
};
+#elif defined(CREATIVE_ZENMOZAIC)
+#define CHAN 0
+#define I_VDDIO 0 /* index in the table */
-void button_init_device(void)
+struct imx233_button_map_t imx233_button_map[] =
{
- imx233_button_lradc_init();
-#ifdef HAVE_HEADPHONE_DETECTION
- imx233_pinctrl_acquire(JACK_DET_BANK, JACK_DET_PIN, "jack_detect");
- imx233_pinctrl_set_function(JACK_DET_BANK, JACK_DET_PIN, PINCTRL_FUNCTION_GPIO);
- imx233_pinctrl_enable_gpio(JACK_DET_BANK, JACK_DET_PIN, false);
-#endif
-#ifdef CREATIVE_ZENXFISTYLE
- imx233_pinctrl_acquire(0, 11, "power_detect");
- imx233_pinctrl_set_function(0, 11, PINCTRL_FUNCTION_GPIO);
- imx233_pinctrl_enable_gpio(0, 11, false);
-#endif
-}
+ [I_VDDIO] = IMX233_BUTTON_(VDDIO, VDDIO(3500), "vddio"), /* we need VDDIO for relative */
+ IMX233_BUTTON_(HOLD, LRADC_REL(CHAN, 0, I_VDDIO), "hold"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 200, I_VDDIO), "menu"),
+ IMX233_BUTTON(SHORTCUT, LRADC_REL(CHAN, 445, I_VDDIO), "shortcut"),
+ IMX233_BUTTON(UP, LRADC_REL(CHAN, 645, I_VDDIO), "up"),
+ IMX233_BUTTON(LEFT, LRADC_REL(CHAN, 860, I_VDDIO), "left"),
+ IMX233_BUTTON(RIGHT, LRADC_REL(CHAN, 1060, I_VDDIO), "right"),
+ IMX233_BUTTON(DOWN, LRADC_REL(CHAN, 1260, I_VDDIO), "down"),
+ IMX233_BUTTON(SELECT, LRADC_REL(CHAN, 1480, I_VDDIO), "select"),
+ IMX233_BUTTON(BACK, LRADC_REL(CHAN, 2700, I_VDDIO), "back"),
+ IMX233_BUTTON(PLAYPAUSE, LRADC_REL(CHAN, 2945, I_VDDIO), "play"),
+ IMX233_BUTTON(POWER, PSWITCH(1), "power"),
+ IMX233_BUTTON_(JACK, GPIO(2, 8), "jack"),
+ IMX233_BUTTON_(END, END(), "")
+};
+#elif defined(CREATIVE_ZENV)
+#define CHAN 0
+#define I_VDDIO 0 /* index in the table */
-#ifdef HAS_BUTTON_HOLD
-bool button_hold(void)
+struct imx233_button_map_t imx233_button_map[] =
{
- return imx233_button_lradc_hold();
-}
+ [I_VDDIO] = IMX233_BUTTON_(VDDIO, VDDIO(3500), "vddio"), /* we need VDDIO for relative */
+ IMX233_BUTTON_(HOLD, LRADC_REL(CHAN, 190, I_VDDIO), "hold"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 250, I_VDDIO), "play"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 530, I_VDDIO), "back"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 785, I_VDDIO), "vol_up"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 1040, I_VDDIO), "vol_down"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 1295, I_VDDIO), "menu"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 1540, I_VDDIO), "up"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 1800, I_VDDIO), "select"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 2070, I_VDDIO), "left"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 2315, I_VDDIO), "right"),
+ IMX233_BUTTON(MENU, LRADC_REL(CHAN, 2550, I_VDDIO), "down"),
+ IMX233_BUTTON(POWER, PSWITCH(1), "power"),
+ IMX233_BUTTON_(END, END(), "")
+};
+#else
+#error wrong target
#endif
-#ifdef HAVE_HEADPHONE_DETECTION
-bool headphones_inserted(void)
+void button_init_device(void)
{
- bool det = imx233_pinctrl_get_gpio(JACK_DET_BANK, JACK_DET_PIN);
-#ifdef JACK_DET_INVERTED
- det = !det;
-#endif
- return det;
+ imx233_button_init();
}
-#endif
int button_read_device(void)
{
int btn = 0;
#ifdef CREATIVE_ZENXFISTYLE
- /* The ZEN X-Fi Style uses a GPIO because both select and power are wired
- * to PSWITCH resulting in slow and unreliable readings */
- if(!imx233_pinctrl_get_gpio(0, 11))
- btn |= BUTTON_POWER;
#else
if(imx233_power_read_pswitch() == 1)
btn |= BUTTON_POWER;
#endif
- return imx233_button_lradc_read(btn);
+ return imx233_button_read(btn);
}