2013-10-21 22:30:43 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 by Amaury Pouly
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "button-target.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "system-target.h"
|
|
|
|
#include "pinctrl-imx233.h"
|
|
|
|
#include "power-imx233.h"
|
2014-02-22 19:33:20 +00:00
|
|
|
#include "button-imx233.h"
|
2013-10-21 22:30:43 +00:00
|
|
|
|
2014-02-22 19:33:20 +00:00
|
|
|
#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 */
|
2014-01-05 14:20:41 +00:00
|
|
|
|
2014-02-22 19:33:20 +00:00
|
|
|
struct imx233_button_map_t imx233_button_map[] =
|
2013-10-21 22:30:43 +00:00
|
|
|
{
|
2014-02-22 19:33:20 +00:00
|
|
|
[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(), "")
|
|
|
|
};
|
2013-10-21 22:30:43 +00:00
|
|
|
#elif defined(CREATIVE_ZENXFI)
|
2014-02-22 19:33:20 +00:00
|
|
|
#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(), "")
|
2013-10-21 22:30:43 +00:00
|
|
|
};
|
2014-02-22 19:33:20 +00:00
|
|
|
#elif defined(CREATIVE_ZENMOZAIC)
|
|
|
|
#define CHAN 0
|
|
|
|
#define I_VDDIO 0 /* index in the table */
|
2013-10-21 22:30:43 +00:00
|
|
|
|
2014-02-22 19:33:20 +00:00
|
|
|
struct imx233_button_map_t imx233_button_map[] =
|
2013-10-21 22:30:43 +00:00
|
|
|
{
|
2014-02-22 19:33:20 +00:00
|
|
|
[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 */
|
2013-10-21 22:30:43 +00:00
|
|
|
|
2014-02-22 19:33:20 +00:00
|
|
|
struct imx233_button_map_t imx233_button_map[] =
|
2013-10-21 22:30:43 +00:00
|
|
|
{
|
2014-02-22 19:33:20 +00:00
|
|
|
[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
|
2014-01-05 14:20:41 +00:00
|
|
|
#endif
|
2013-10-21 22:30:43 +00:00
|
|
|
|
2014-02-22 19:33:20 +00:00
|
|
|
void button_init_device(void)
|
2013-10-21 22:30:43 +00:00
|
|
|
{
|
2014-02-22 19:33:20 +00:00
|
|
|
imx233_button_init();
|
2013-10-21 22:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int button_read_device(void)
|
|
|
|
{
|
|
|
|
int btn = 0;
|
2014-01-05 14:20:41 +00:00
|
|
|
#ifdef CREATIVE_ZENXFISTYLE
|
|
|
|
#else
|
2013-11-18 20:07:02 +00:00
|
|
|
if(imx233_power_read_pswitch() == 1)
|
2013-10-21 22:30:43 +00:00
|
|
|
btn |= BUTTON_POWER;
|
2014-01-05 14:20:41 +00:00
|
|
|
#endif
|
2014-02-22 19:33:20 +00:00
|
|
|
return imx233_button_read(btn);
|
2013-10-21 22:30:43 +00:00
|
|
|
}
|