zen{,xfi,mozaic,xfistyle,v}: switch to the new button driver
Change-Id: I206b16f6374f536ab6d84e84fefc8370a96ef759
This commit is contained in:
parent
82b86d4316
commit
a2bfbe9ebc
3 changed files with 106 additions and 130 deletions
|
@ -1203,7 +1203,6 @@ target/arm/imx233/creative-zen/button-zen.c
|
|||
target/arm/imx233/creative-zen/debug-zen.c
|
||||
target/arm/imx233/creative-zen/power-zen.c
|
||||
target/arm/imx233/creative-zen/powermgmt-zen.c
|
||||
target/arm/imx233/button-lradc-imx233.c
|
||||
#endif
|
||||
|
||||
#ifdef CREATIVE_ZENXFI2
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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_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(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_map_t imx233_button_map[] =
|
||||
{
|
||||
[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},
|
||||
#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)
|
||||
{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},
|
||||
#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(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 */
|
||||
|
||||
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, 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
|
||||
};
|
||||
|
||||
void button_init_device(void)
|
||||
{
|
||||
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
|
||||
imx233_button_init();
|
||||
}
|
||||
|
||||
#ifdef HAS_BUTTON_HOLD
|
||||
bool button_hold(void)
|
||||
{
|
||||
return imx233_button_lradc_hold();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HEADPHONE_DETECTION
|
||||
bool headphones_inserted(void)
|
||||
{
|
||||
bool det = imx233_pinctrl_get_gpio(JACK_DET_BANK, JACK_DET_PIN);
|
||||
#ifdef JACK_DET_INVERTED
|
||||
det = !det;
|
||||
#endif
|
||||
return det;
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue