Initial commit for the Creative ZEN X-Fi2 and X-Fi3 ports

These are really similar devices so one commit for both is ok.

Change-Id: I8bd1d3fef1eb6d00aaadfb7af56c771f62d0c9c3
This commit is contained in:
Amaury Pouly 2012-05-19 16:09:46 +02:00
parent e09c1e3d43
commit 12c64a4b79
44 changed files with 3424 additions and 26 deletions

View file

@ -236,6 +236,10 @@ keymaps/keymap-meizu-m6sp.c
keymaps/keymap-creativezvm.c keymaps/keymap-creativezvm.c
#elif CONFIG_KEYPAD == CREATIVEZV_PAD #elif CONFIG_KEYPAD == CREATIVEZV_PAD
keymaps/keymap-creativezv.c keymaps/keymap-creativezv.c
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI2_PAD
keymaps/keymap-zenxfi2.c
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD
keymaps/keymap-zenxfi3.c
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
keymaps/keymap-sa9200.c keymaps/keymap-sa9200.c
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD

View file

@ -0,0 +1,184 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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.
*
****************************************************************************/
/* Button Code Definitions for the Creative ZEN X-Fi2 target */
/* NB: Up/Down/Left/Right are not physical buttons - touchscreen emulation */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "config.h"
#include "action.h"
#include "button.h"
#include "settings.h"
/*
* The format of the list is as follows
* { Action Code, Button code, Prereq button code }
* if there's no need to check the previous button's value, use BUTTON_NONE
* Insert LAST_ITEM_IN_LIST at the end of each mapping
*/
static const struct button_mapping button_context_standard[] = {
{ ACTION_STD_OK, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
{ ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
{ ACTION_STD_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
LAST_ITEM_IN_LIST
}; /* button_context_standard */
static const struct button_mapping button_context_wps[] = {
{ ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
{ ACTION_WPS_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
LAST_ITEM_IN_LIST
}; /* button_context_wps */
static const struct button_mapping button_context_list[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_list */
static const struct button_mapping button_context_tree[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
}; /* button_context_tree */
static const struct button_mapping button_context_listtree_scroll_with_combo[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
};
static const struct button_mapping button_context_listtree_scroll_without_combo[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
};
static const struct button_mapping button_context_settings[] = {
{ ACTION_STD_OK, BUTTON_MENU, BUTTON_NONE },
{ ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_settings */
static const struct button_mapping button_context_settings_right_is_inc[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_settingsgraphical */
static const struct button_mapping button_context_yesno[] = {
{ ACTION_YESNO_ACCEPT, BUTTON_MENU, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_settings_yesno */
static const struct button_mapping button_context_colorchooser[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
}; /* button_context_colorchooser */
static const struct button_mapping button_context_eq[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
}; /* button_context_eq */
/** Bookmark Screen **/
static const struct button_mapping button_context_bmark[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
}; /* button_context_bmark */
static const struct button_mapping button_context_time[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS),
}; /* button_context_time */
static const struct button_mapping button_context_quickscreen[] = {
{ ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_NONE },
{ ACTION_STD_CANCEL, BUTTON_MENU|BUTTON_REL, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_quickscreen */
static const struct button_mapping button_context_pitchscreen[] = {
{ ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_pitchcreen */
static const struct button_mapping button_context_keyboard[] = {
{ ACTION_KBD_PAGE_FLIP, BUTTON_MENU, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_keyboard */
static const struct button_mapping button_context_radio[] = {
{ ACTION_FM_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_NONE },
{ ACTION_FM_PRESET, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_FM_STOP, BUTTON_POWER, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
}; /* button_context_radio */
const struct button_mapping* target_get_context_mapping(int context)
{
switch (context)
{
case CONTEXT_STD:
return button_context_standard;
case CONTEXT_WPS:
return button_context_wps;
case CONTEXT_LIST:
return button_context_list;
case CONTEXT_MAINMENU:
case CONTEXT_TREE:
if (global_settings.hold_lr_for_scroll_in_list)
return button_context_listtree_scroll_without_combo;
else
return button_context_listtree_scroll_with_combo;
case CONTEXT_CUSTOM|CONTEXT_TREE:
return button_context_tree;
case CONTEXT_SETTINGS:
return button_context_settings;
case CONTEXT_CUSTOM|CONTEXT_SETTINGS:
case CONTEXT_SETTINGS_RECTRIGGER:
return button_context_settings_right_is_inc;
case CONTEXT_SETTINGS_COLOURCHOOSER:
return button_context_colorchooser;
case CONTEXT_SETTINGS_EQ:
return button_context_eq;
case CONTEXT_SETTINGS_TIME:
return button_context_time;
case CONTEXT_YESNOSCREEN:
return button_context_yesno;
case CONTEXT_FM:
return button_context_radio;
case CONTEXT_BOOKMARKSCREEN:
return button_context_bmark;
case CONTEXT_QUICKSCREEN:
return button_context_quickscreen;
case CONTEXT_PITCHSCREEN:
return button_context_pitchscreen;
case CONTEXT_KEYBOARD:
return button_context_keyboard;
}
return button_context_standard;
}

View file

@ -0,0 +1,327 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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.
*
****************************************************************************/
/* Button Code Definitions for the Creative ZEN X-Fi3 target */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "config.h"
#include "action.h"
#include "button.h"
#include "settings.h"
/*
* The format of the list is as follows
* { Action Code, Button code, Prereq button code }
* if there's no need to check the previous button's value, use BUTTON_NONE
* Insert LAST_ITEM_IN_LIST at the end of each mapping
*/
static const struct button_mapping button_context_standard[] = {
{ ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
{ ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
{ ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_STD_CONTEXT, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
{ ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
{ ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
{ ACTION_STD_KEYLOCK, BUTTON_POWER, BUTTON_NONE },
LAST_ITEM_IN_LIST
}; /* button_context_standard */
static const struct button_mapping button_context_wps[] = {
{ ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_SKIPNEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
{ ACTION_WPS_SEEKFWD, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_SKIPPREV, BUTTON_UP|BUTTON_REL, BUTTON_UP },
{ ACTION_WPS_SEEKBACK, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_STOPSEEK, BUTTON_UP|BUTTON_REL, BUTTON_UP|BUTTON_REPEAT },
{ ACTION_WPS_STOPSEEK, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN|BUTTON_REPEAT },
{ ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
{ ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
{ ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_MENU, BUTTON_BACK, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_wps */
static const struct button_mapping button_context_keyboard[] = {
{ ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
{ ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
{ ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE },
{ ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE },
{ ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_SELECT, BUTTON_MENU, BUTTON_NONE },
{ ACTION_KBD_DONE, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
{ ACTION_KBD_ABORT, BUTTON_POWER, BUTTON_NONE },
{ ACTION_KBD_MORSE_INPUT, BUTTON_VOL_UP, BUTTON_NONE },
{ ACTION_KBD_MORSE_SELECT, BUTTON_VOL_DOWN|BUTTON_REL, BUTTON_NONE },
LAST_ITEM_IN_LIST
}; /* button_context_keyboard */
static const struct button_mapping button_context_quickscreen[] = {
{ ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
{ ACTION_STD_CANCEL, BUTTON_MENU, BUTTON_NONE },
{ ACTION_QS_TOP, BUTTON_UP, BUTTON_NONE },
{ ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE },
{ ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE },
{ ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
LAST_ITEM_IN_LIST
}; /* button_context_quickscreen */
static const struct button_mapping button_context_tree[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
}; /* button_context_tree */
static const struct button_mapping button_context_list[] = {
#ifdef HAVE_VOLUME_IN_LIST
{ ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
{ ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
{ ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
#endif
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_list */
#ifdef CONFIG_TUNER
static const struct button_mapping button_context_radio[] = {
{ ACTION_FM_MENU, BUTTON_MENU, BUTTON_NONE },
{ ACTION_FM_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_FM_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_FM_EXIT, BUTTON_BACK, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
}; /* button_context_radio */
#endif
#ifdef HAVE_RECORDING
static const struct button_mapping button_context_recscreen[] = {
{ ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
{ ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
{ ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_recscreen */
#endif
static const struct button_mapping button_context_settings[] = {
/* we overwrite this to avoid select from std */
{ ACTION_NONE, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
{ ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE },
{ ACTION_SETTINGS_INCREPEAT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE },
{ ACTION_SETTINGS_DECREPEAT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
{ ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
{ ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_SETTINGS_RESET, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_settings */
static const struct button_mapping button_context_time[] = {
{ ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE },
{ ACTION_STD_OK, BUTTON_PLAY, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
}; /* button_context_time */
static const struct button_mapping button_context_colorchooser[] = {
{ ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
}; /* button_context_colorchooser */
static const struct button_mapping button_context_eq[] = {
{ ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
}; /* button_context_eq */
/* Bookmark Screen */
static const struct button_mapping button_context_bmark[] = {
{ ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
}; /* button_context_bmark */
static const struct button_mapping button_context_pitchscreen[] = {
{ ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE },
{ ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE },
{ ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_PS_RESET, BUTTON_PLAY, BUTTON_NONE },
{ ACTION_PS_EXIT, BUTTON_BACK, BUTTON_NONE },
LAST_ITEM_IN_LIST
}; /* button_context_pitchcreen */
static const struct button_mapping button_context_yesno[] = {
{ ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_yesno */
#ifdef USB_ENABLE_HID
static const struct button_mapping button_context_usb_hid[] = {
{ ACTION_USB_HID_MODE_SWITCH_NEXT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
{ ACTION_USB_HID_MODE_SWITCH_PREV, BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER },
LAST_ITEM_IN_LIST
}; /* button_context_usb_hid */
static const struct button_mapping button_context_usb_hid_mode_multimedia[] = {
{ ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
{ ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_VOL_UP, BUTTON_NONE },
{ ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE, BUTTON_BACK|BUTTON_REL, BUTTON_BACK },
{ ACTION_USB_HID_MULTIMEDIA_PLAYBACK_PLAY_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_USB_HID_MULTIMEDIA_PLAYBACK_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
{ ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_PREV, BUTTON_UP|BUTTON_REL, BUTTON_UP },
{ ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_NEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
}; /* button_context_usb_hid_mode_multimedia */
static const struct button_mapping button_context_usb_hid_mode_presentation[] = {
{ ACTION_USB_HID_PRESENTATION_SLIDESHOW_START, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_USB_HID_PRESENTATION_SLIDESHOW_LEAVE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
{ ACTION_USB_HID_PRESENTATION_SLIDE_PREV, BUTTON_UP|BUTTON_REL, BUTTON_UP },
{ ACTION_USB_HID_PRESENTATION_SLIDE_NEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
}; /* button_context_usb_hid_mode_presentation */
static const struct button_mapping button_context_usb_hid_mode_browser[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
}; /* button_context_usb_hid_mode_browser */
#ifdef HAVE_USB_HID_MOUSE
static const struct button_mapping button_context_usb_hid_mode_mouse[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
}; /* button_context_usb_hid_mode_mouse */
#endif
#endif
/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
const struct button_mapping* get_context_mapping(int context)
{
switch (context)
{
case CONTEXT_STD:
return button_context_standard;
case CONTEXT_MAINMENU:
return button_context_tree;
case CONTEXT_SETTINGS:
return button_context_settings;
case CONTEXT_WPS:
return button_context_wps;
case CONTEXT_YESNOSCREEN:
return button_context_yesno;
case CONTEXT_SETTINGS_TIME:
return button_context_time;
case CONTEXT_KEYBOARD:
case CONTEXT_MORSE_INPUT:
return button_context_keyboard;
#ifdef CONFIG_TUNER
case CONTEXT_FM:
return button_context_radio;
#endif
case CONTEXT_LIST:
return button_context_list;
case CONTEXT_TREE:
return button_context_tree;
case CONTEXT_SETTINGS_EQ:
return button_context_eq;
#ifdef HAVE_RECORDING
case CONTEXT_RECSCREEN:
return button_context_recscreen;
#endif
case CONTEXT_QUICKSCREEN:
return button_context_quickscreen;
case CONTEXT_BOOKMARKSCREEN:
return button_context_bmark;
case CONTEXT_PITCHSCREEN:
return button_context_pitchscreen;
case CONTEXT_SETTINGS_COLOURCHOOSER:
return button_context_colorchooser;
case CONTEXT_SETTINGS_RECTRIGGER:
return button_context_settings;
case CONTEXT_CUSTOM|CONTEXT_SETTINGS:
return button_context_settings;
#ifdef USB_ENABLE_HID
case CONTEXT_USB_HID:
return button_context_usb_hid;
case CONTEXT_USB_HID_MODE_MULTIMEDIA:
return button_context_usb_hid_mode_multimedia;
case CONTEXT_USB_HID_MODE_PRESENTATION:
return button_context_usb_hid_mode_presentation;
case CONTEXT_USB_HID_MODE_BROWSER:
return button_context_usb_hid_mode_browser;
#ifdef HAVE_USB_HID_MOUSE
case CONTEXT_USB_HID_MODE_MOUSE:
return button_context_usb_hid_mode_mouse;
#endif
#endif
default:
return button_context_standard;
}
return button_context_standard;
}

View file

@ -12465,15 +12465,15 @@
user: core user: core
<source> <source>
*: none *: none
gigabeats,mpiohd200,mpiohd300,sansafuzeplus: "3-D Enhancement" gigabeats,mpiohd200,mpiohd300,sansafuzeplus,creativezenxfi2,creativezenxfi3: "3-D Enhancement"
</source> </source>
<dest> <dest>
*: none *: none
gigabeats,mpiohd200,mpiohd300,sansafuzeplus: "3-D Enhancement" gigabeats,mpiohd200,mpiohd300,sansafuzeplus,creativezenxfi2,creativezenxfi3: "3-D Enhancement"
</dest> </dest>
<voice> <voice>
*: none *: none
gigabeats,mpiohd200,mpiohd300,sansafuzeplus: "3-D Enhancement" gigabeats,mpiohd200,mpiohd300,sansafuzeplus,creativezenxfi2,creativezenxfi3: "3-D Enhancement"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>

View file

@ -240,10 +240,16 @@
#define BATTERY_ON_TXT "SELECT - start" #define BATTERY_ON_TXT "SELECT - start"
#define BATTERY_OFF_TXT "POWER" #define BATTERY_OFF_TXT "POWER"
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD
#define BATTERY_ON BUTTON_PLAY
#define BATTERY_OFF BUTTON_POWER
#define BATTERY_ON_TXT "PLAY - start"
#elif (CONFIG_KEYPAD == HM60X_PAD) || (CONFIG_KEYPAD == HM801_PAD) #elif (CONFIG_KEYPAD == HM60X_PAD) || (CONFIG_KEYPAD == HM801_PAD)
#define BATTERY_ON BUTTON_SELECT #define BATTERY_ON BUTTON_SELECT
#define BATTERY_OFF BUTTON_POWER #define BATTERY_OFF BUTTON_POWER
#define BATTERY_ON_TXT "SELECT - start" #define BATTERY_ON_TXT "SELECT - start"
#define BATTERY_OFF_TXT "POWER" #define BATTERY_OFF_TXT "POWER"
#else #else

View file

@ -118,6 +118,7 @@ const struct button_mapping pla_main_ctx[] =
|| (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) \ || (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) \
|| (CONFIG_KEYPAD == SANSA_CONNECT_PAD) \ || (CONFIG_KEYPAD == SANSA_CONNECT_PAD) \
|| (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD) \ || (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD) \
|| (CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD) \
|| (CONFIG_KEYPAD == HM60X_PAD) \ || (CONFIG_KEYPAD == HM60X_PAD) \
|| (CONFIG_KEYPAD == HM801_PAD)) || (CONFIG_KEYPAD == HM801_PAD))
{ PLA_UP, BUTTON_UP, BUTTON_NONE }, { PLA_UP, BUTTON_UP, BUTTON_NONE },
@ -417,6 +418,12 @@ const struct button_mapping pla_main_ctx[] =
{PLA_SELECT, BUTTON_SELECT, BUTTON_NONE}, {PLA_SELECT, BUTTON_SELECT, BUTTON_NONE},
{PLA_SELECT_REL, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT}, {PLA_SELECT_REL, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT},
{PLA_SELECT_REPEAT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE}, {PLA_SELECT_REPEAT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE},
#elif (CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD)
{PLA_CANCEL, BUTTON_VOL_DOWN, BUTTON_NONE},
{PLA_EXIT, BUTTON_POWER, BUTTON_NONE},
{PLA_SELECT, BUTTON_VOL_UP, BUTTON_NONE},
{PLA_SELECT_REL, BUTTON_VOL_UP|BUTTON_REL, BUTTON_VOL_UP},
{PLA_SELECT_REPEAT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE},
#else #else
# ifndef HAVE_TOUCHSCREEN # ifndef HAVE_TOUCHSCREEN
# error pluginlib_actions: No actions defined # error pluginlib_actions: No actions defined

View file

@ -332,6 +332,9 @@ drivers/tuner/ipod_remote_tuner.c
#if (CONFIG_TUNER & RDA5802) #if (CONFIG_TUNER & RDA5802)
drivers/tuner/rda5802.c drivers/tuner/rda5802.c
#endif /* (CONFIG_TUNER & RDA5802) */ #endif /* (CONFIG_TUNER & RDA5802) */
#if (CONFIG_TUNER & STFM1000)
drivers/tuner/stfm1000.c
#endif /* (CONFIG_TUNER & STFM1000) */
#if defined(HAVE_RDS_CAP) #if defined(HAVE_RDS_CAP)
drivers/rds.c drivers/rds.c
#endif /* HAVE_RDS_CAP */ #endif /* HAVE_RDS_CAP */
@ -504,8 +507,12 @@ target/arm/imx233/clkctrl-imx233.c
target/arm/imx233/system-imx233.c target/arm/imx233/system-imx233.c
target/arm/imx233/timrot-imx233.c target/arm/imx233/timrot-imx233.c
target/arm/imx233/kernel-imx233.c target/arm/imx233/kernel-imx233.c
# if (CONFIG_STORAGE & STORAGE_SD)
target/arm/imx233/sd-imx233.c target/arm/imx233/sd-imx233.c
# endif
# if (CONFIG_STORAGE & STORAGE_MMC)
target/arm/imx233/mmc-imx233.c target/arm/imx233/mmc-imx233.c
# endif
target/arm/imx233/partitions-imx233.c target/arm/imx233/partitions-imx233.c
target/arm/imx233/ssp-imx233.c target/arm/imx233/ssp-imx233.c
target/arm/imx233/dma-imx233.c target/arm/imx233/dma-imx233.c
@ -1124,6 +1131,33 @@ target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
target/arm/tms320dm320/creative-zvm/usb-creativezvm.c target/arm/tms320dm320/creative-zvm/usb-creativezvm.c
#endif /* CREATIVE_ZVx */ #endif /* CREATIVE_ZVx */
#ifdef CREATIVE_ZENXFI2
target/arm/imx233/creative-zenxfi2/backlight-zenxfi2.c
target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c
target/arm/imx233/creative-zenxfi2/button-zenxfi2.c
target/arm/imx233/creative-zenxfi2/debug-zenxfi2.c
target/arm/imx233/creative-zenxfi2/power-zenxfi2.c
target/arm/imx233/creative-zenxfi2/adc-zenxfi2.c
target/arm/imx233/creative-zenxfi2/powermgmt-zenxfi2.c
#ifndef BOOTLOADER
target/arm/imx233/creative-zenxfi2/audio-zenxfi2.c
#endif
#endif
#ifdef CREATIVE_ZENXFI3
drivers/mpr121.c
target/arm/imx233/creative-zenxfi3/backlight-zenxfi3.c
target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c
target/arm/imx233/creative-zenxfi3/button-zenxfi3.c
target/arm/imx233/creative-zenxfi3/debug-zenxfi3.c
target/arm/imx233/creative-zenxfi3/power-zenxfi3.c
target/arm/imx233/creative-zenxfi3/adc-zenxfi3.c
target/arm/imx233/creative-zenxfi3/powermgmt-zenxfi3.c
#ifndef BOOTLOADER
target/arm/imx233/creative-zenxfi3/audio-zenxfi3.c
#endif
#endif
#ifdef SANSA_CONNECT #ifdef SANSA_CONNECT
drivers/lcd-memframe.c drivers/lcd-memframe.c
target/arm/tms320dm320/sdmmc-dm320.c target/arm/tms320dm320/sdmmc-dm320.c

View file

@ -145,6 +145,8 @@
#define HM801_PAD 51 #define HM801_PAD 51
#define SANSA_CONNECT_PAD 52 #define SANSA_CONNECT_PAD 52
#define SAMSUNG_YPR0_PAD 53 #define SAMSUNG_YPR0_PAD 53
#define CREATIVE_ZENXFI2_PAD 54
#define CREATIVE_ZENXFI3_PAD 55
/* CONFIG_REMOTE_KEYPAD */ /* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1 #define H100_REMOTE 1
@ -244,6 +246,8 @@
#define LCD_CONNECT 45 /* as used by the Sandisk Sansa Connect */ #define LCD_CONNECT 45 /* as used by the Sandisk Sansa Connect */
#define LCD_GIGABEATS 46 #define LCD_GIGABEATS 46
#define LCD_YPR0 47 #define LCD_YPR0 47
#define LCD_CREATIVEZXFI2 48 /* as used by the Creative Zen X-Fi2 */
#define LCD_CREATIVEZXFI3 49 /* as used by the Creative Zen X-Fi3 */
/* LCD_PIXELFORMAT */ /* LCD_PIXELFORMAT */
#define HORIZONTAL_PACKING 1 #define HORIZONTAL_PACKING 1
@ -417,6 +421,10 @@ Lyre prototype 1 */
#include "config/zenvisionm60gb.h" #include "config/zenvisionm60gb.h"
#elif defined(CREATIVE_ZV) #elif defined(CREATIVE_ZV)
#include "config/zenvision.h" #include "config/zenvision.h"
#elif defined(CREATIVE_ZENXFI2)
#include "config/creativezenxfi2.h"
#elif defined(CREATIVE_ZENXFI3)
#include "config/creativezenxfi3.h"
#elif defined(PHILIPS_SA9200) #elif defined(PHILIPS_SA9200)
#include "config/gogearsa9200.h" #include "config/gogearsa9200.h"
#elif defined(PHILIPS_HDD1630) #elif defined(PHILIPS_HDD1630)

View file

@ -0,0 +1,202 @@
/*
* This config file is for the Creative Zen X-Fi2
*/
#define TARGET_TREE /* this target is using the target tree system */
/* For Rolo and boot loader */
#define MODEL_NUMBER 82
#define MODEL_NAME "Creative Zen X-Fi2"
#define HW_SAMPR_CAPS SAMPR_CAP_ALL
/* define this if you have recording possibility */
#define HAVE_RECORDING
#define REC_SAMPR_CAPS SAMPR_CAP_ALL
/* Default recording levels */
#define DEFAULT_REC_MIC_GAIN 23
#define DEFAULT_REC_LEFT_GAIN 23
#define DEFAULT_REC_RIGHT_GAIN 23
/* Define bitmask of input sources - recordable bitmask can be defined
explicitly if different */
#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO)
/* define this if you have a bitmap LCD display */
#define HAVE_LCD_BITMAP
/* define this if you have a colour LCD */
#define HAVE_LCD_COLOR
#ifndef BOOTLOADER
#define HAVE_ALBUMART
/* define this to enable bitmap scaling */
#define HAVE_BMP_SCALING
/* define this to enable JPEG decoding */
#define HAVE_JPEG
/* Define this if a programmable hotkey is mapped */
#define HAVE_HOTKEY
/* define this if you have access to the quickscreen */
#define HAVE_QUICKSCREEN
/* define this if you have access to the pitchscreen */
#define HAVE_PITCHSCREEN
/* define this if you would like tagcache to build on this target */
#define HAVE_TAGCACHE
/* define this if the target has volume keys which can be used in the lists */
#define HAVE_VOLUME_IN_LIST
/* define this if you have LCD enable function */
#define HAVE_LCD_ENABLE
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
should be defined as well.
#define HAVE_LCD_SLEEP
#define HAVE_LCD_SLEEP_SETTING
*/
/* define this if you can flip your LCD
#define HAVE_LCD_FLIP
*/
/* define this if you can invert the colours on your LCD
#define HAVE_LCD_INVERT
*/
/* define this if you have a real-time clock */
#define CONFIG_RTC RTC_IMX233
/* define this if you have a real-time clock with alarm facilities */
#define HAVE_RTC_ALARM
#endif /* !BOOTLOADER */
/* define this if you have an i.MX23 codec */
#define HAVE_IMX233_CODEC
#define CONFIG_TUNER STFM1000
/* There is no hardware tone control */
#define HAVE_SW_TONE_CONTROLS
#define CONFIG_KEYPAD CREATIVE_ZENXFI2_PAD
#define HAVE_TOUCHSCREEN
#define HAVE_BUTTON_DATA
/* Define this to enable morse code input */
#define HAVE_MORSE_INPUT
/* Define this if you do software codec */
#define CONFIG_CODEC SWCODEC
/* LCD dimensions */
#define LCD_WIDTH 240
#define LCD_HEIGHT 400
#define LCD_DEPTH 16 /* 65536 colours */
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
#define LCD_DPI 150
/* Define this if you have a software controlled poweroff */
#define HAVE_SW_POWEROFF
/* Some Sansa Fuzes seem to be FAT16 formatted */
#define HAVE_FAT16SUPPORT
/* The number of bytes reserved for loadable codecs */
#define CODEC_SIZE 0x100000
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x80000
#define AB_REPEAT_ENABLE
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults */
#define MIN_BRIGHTNESS_SETTING 0
#define MAX_BRIGHTNESS_SETTING 100
#define DEFAULT_BRIGHTNESS_SETTING 50
/* Which backlight fading type? */
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
/* define this if you have a flash memory storage */
#define HAVE_FLASH_STORAGE
/* define this if the flash memory uses the SecureDigital Memory Card protocol */
#define CONFIG_STORAGE (/*STORAGE_NAND |*/ STORAGE_SD)
#define NUM_DRIVES 1
#define HAVE_MULTIDRIVE
#define HAVE_MULTIVOLUME
#define HAVE_HOTSWAP_STORAGE_AS_MAIN
#define HAVE_HOTSWAP
#define CONFIG_NAND NAND_IMX233
/* todo */
#define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */
#define BATTERY_CAPACITY_MIN 550 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 550 /* max. capacity selectable */
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET
/* define this if the unit can be powered or charged via USB */
#define HAVE_USB_POWER
/* Define this if you have an IMX233*/
#define CONFIG_CPU IMX233
/* Define this if you want to use the IMX233 i2c interface */
#define CONFIG_I2C I2C_IMX233
/* define current usage levels (based on battery bench) */
#define CURRENT_NORMAL 35
#define CURRENT_BACKLIGHT 30
#define CURRENT_RECORD CURRENT_NORMAL
/* maximum charging current */
#define CURRENT_MAX_CHG 200
/* Define this to the CPU frequency */
#define CPU_FREQ 454000000
/* Type of LCD */
#define CONFIG_LCD LCD_CREATIVEZXFI2
/* Offset ( in the firmware file's header ) to the file CRC and data. These are
only used when loading the old format rockbox.e200 file */
#define FIRMWARE_OFFSET_FILE_CRC 0x0
#define FIRMWARE_OFFSET_FILE_DATA 0x8
/* USB On-the-go */
#define CONFIG_USBOTG USBOTG_ARC
/* enable these for the experimental usb stack */
#define HAVE_USBSTACK
//#define USB_HANDLED_BY_OF
#define USE_ROCKBOX_USB
#define USB_VENDOR_ID 0x041e
#define USB_PRODUCT_ID 0x2020
#define HAVE_USB_HID_MOUSE
#define HAVE_BOOTLOADER_USB_MODE
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
#define BOOTFILE_EXT "creative"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
#define INCLUDE_TIMEOUT_API

View file

@ -0,0 +1,208 @@
/*
* This config file is for the Creative Zen X-Fi3
*/
#define TARGET_TREE /* this target is using the target tree system */
/* For Rolo and boot loader */
#define MODEL_NUMBER 83
#define MODEL_NAME "Creative Zen X-Fi3"
#define HW_SAMPR_CAPS SAMPR_CAP_ALL
/* define this if you have recording possibility */
#define HAVE_RECORDING
#define REC_SAMPR_CAPS SAMPR_CAP_ALL
/* Default recording levels */
#define DEFAULT_REC_MIC_GAIN 23
#define DEFAULT_REC_LEFT_GAIN 23
#define DEFAULT_REC_RIGHT_GAIN 23
/* Define bitmask of input sources - recordable bitmask can be defined
explicitly if different */
#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO)
/* define this if you have a bitmap LCD display */
#define HAVE_LCD_BITMAP
/* define this if you have a colour LCD */
#define HAVE_LCD_COLOR
#ifndef BOOTLOADER
#define HAVE_ALBUMART
/* define this to enable bitmap scaling */
#define HAVE_BMP_SCALING
/* define this to enable JPEG decoding */
#define HAVE_JPEG
/* Define this if a programmable hotkey is mapped */
#define HAVE_HOTKEY
/* define this if you have access to the quickscreen */
#define HAVE_QUICKSCREEN
/* define this if you have a light associated with the buttons */
#define HAVE_BUTTON_LIGHT
#define HAVE_BUTTONLIGHT_BRIGHTNESS
/* define this if you have access to the pitchscreen */
#define HAVE_PITCHSCREEN
/* define this if you would like tagcache to build on this target */
#define HAVE_TAGCACHE
/* define this if the target has volume keys which can be used in the lists */
#define HAVE_VOLUME_IN_LIST
/* define this if you have LCD enable function */
#define HAVE_LCD_ENABLE
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
should be defined as well.
#define HAVE_LCD_SLEEP
#define HAVE_LCD_SLEEP_SETTING
*/
/* define this if you can flip your LCD
#define HAVE_LCD_FLIP
*/
/* define this if you can invert the colours on your LCD
#define HAVE_LCD_INVERT
*/
/* define this if you have a real-time clock */
#define CONFIG_RTC RTC_IMX233
/* define this if you have a real-time clock with alarm facilities */
#define HAVE_RTC_ALARM
#endif /* !BOOTLOADER */
/* define this if you have an i.MX23 codec */
#define HAVE_IMX233_CODEC
#define CONFIG_TUNER STFM1000
/* There is no hardware tone control */
#define HAVE_SW_TONE_CONTROLS
#define CONFIG_KEYPAD CREATIVE_ZENXFI3_PAD
/* Define this to enable morse code input */
#define HAVE_MORSE_INPUT
/* Define this if you do software codec */
#define CONFIG_CODEC SWCODEC
/* LCD dimensions */
#define LCD_WIDTH 176
#define LCD_HEIGHT 220
#define LCD_DEPTH 16 /* 65536 colours */
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
/* Define this if you have a software controlled poweroff */
#define HAVE_SW_POWEROFF
/* Some Sansa Fuzes seem to be FAT16 formatted */
#define HAVE_FAT16SUPPORT
/* The number of bytes reserved for loadable codecs */
#define CODEC_SIZE 0x100000
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x80000
#define AB_REPEAT_ENABLE
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults */
#define MIN_BRIGHTNESS_SETTING 0
#define MAX_BRIGHTNESS_SETTING 100
#define DEFAULT_BRIGHTNESS_SETTING 50
/* Which backlight fading type? */
#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
/* define this if you have a flash memory storage */
#define HAVE_FLASH_STORAGE
/* define this if the flash memory uses the SecureDigital Memory Card protocol */
#define CONFIG_STORAGE STORAGE_SD
#define NUM_DRIVES 2
#define HAVE_MULTIDRIVE
#define HAVE_MULTIVOLUME
#define HAVE_HOTSWAP
/* Extra threads: touchpad */
#define TARGET_EXTRA_THREADS 1
/* todo */
#define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */
#define BATTERY_CAPACITY_MIN 550 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 550 /* max. capacity selectable */
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
/* Charging implemented in a target-specific algorithm */
#define CONFIG_CHARGING CHARGING_TARGET
/* define this if the unit can be powered or charged via USB */
#define HAVE_USB_POWER
/* Define this if you have an IMX233*/
#define CONFIG_CPU IMX233
/* Define this if you want to use the IMX233 i2c interface */
#define CONFIG_I2C I2C_IMX233
/* define current usage levels (based on battery bench) */
#define CURRENT_NORMAL 35
#define CURRENT_BACKLIGHT 30
#define CURRENT_RECORD CURRENT_NORMAL
/* maximum charging current */
#define CURRENT_MAX_CHG 200
/* Define this to the CPU frequency */
#define CPU_FREQ 454000000
/* Type of LCD */
#define CONFIG_LCD LCD_CREATIVEZXFI3
/* Offset ( in the firmware file's header ) to the file CRC and data. These are
only used when loading the old format rockbox.e200 file */
#define FIRMWARE_OFFSET_FILE_CRC 0x0
#define FIRMWARE_OFFSET_FILE_DATA 0x8
/* USB On-the-go */
#define CONFIG_USBOTG USBOTG_ARC
/* enable these for the experimental usb stack */
#define HAVE_USBSTACK
//#define USB_HANDLED_BY_OF
#define USE_ROCKBOX_USB
#define USB_VENDOR_ID 0x041e
#define USB_PRODUCT_ID 0x2020
#define HAVE_USB_HID_MOUSE
#define HAVE_BOOTLOADER_USB_MODE
/* The fuze+ actually interesting partition table does not use 512-byte sector
* (usually 2048 logical sector size) */
#define MAX_LOG_SECTOR_SIZE 2048
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
#define BOOTFILE_EXT "creative"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
#define INCLUDE_TIMEOUT_API

View file

@ -0,0 +1,32 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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.
*
****************************************************************************/
#ifndef _ADC_TARGET_H_
#define _ADC_TARGET_H_
#define NUM_ADC_CHANNELS 5
#define ADC_BATTERY 0
#define ADC_DIE_TEMP 1
#define ADC_VDDIO 2
#define ADC_5V 3
#define ADC_BATT_TEMP 4
#endif

View file

@ -0,0 +1,40 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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 "adc-target.h"
#include "adc-imx233.h"
int imx233_adc_mapping[] =
{
[ADC_BATTERY] = IMX233_ADC_BATTERY,
[ADC_DIE_TEMP] = IMX233_ADC_DIE_TEMP,
[ADC_VDDIO] = IMX233_ADC_VDDIO,
[ADC_5V] = HW_LRADC_CHANNEL_5V,
[ADC_BATT_TEMP] = IMX233_ADC_BATT_TEMP,
};
const char *imx233_adc_channel_name[] =
{
"Battery(raw)",
"Die temperature(°C)",
"VddIO",
"Vdd5V",
"Battery temperature(raw)",
};

View file

@ -0,0 +1,55 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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 "config.h"
#include "system.h"
#include "audiohw.h"
#include "audio.h"
#include "audioout-imx233.h"
#include "audioin-imx233.h"
static int input_source = AUDIO_SRC_PLAYBACK;
static unsigned input_flags = 0;
static int output_source = AUDIO_SRC_PLAYBACK;
static void select_audio_path(void)
{
if(input_source == AUDIO_SRC_PLAYBACK)
imx233_audioout_select_hp_input(false);
else
imx233_audioout_select_hp_input(true);
}
void audio_input_mux(int source, unsigned flags)
{
(void) source;
(void) flags;
input_source = source;
input_flags = flags;
select_audio_path();
}
void audio_set_output_source(int source)
{
(void) source;
output_source = source;
select_audio_path();
}

View file

@ -0,0 +1,29 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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.
*
****************************************************************************/
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
bool _backlight_init(void);
void _backlight_on(void);
void _backlight_off(void);
void _backlight_set_brightness(int brightness);
#endif /* BACKLIGHT_TARGET_H */

View file

@ -0,0 +1,58 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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 "config.h"
#include "system.h"
#include "lcd.h"
#include "backlight.h"
#include "backlight-target.h"
#include "pwm-imx233.h"
void _backlight_set_brightness(int brightness)
{
imx233_pwm_setup_channel(4, 1024, HW_PWM_PERIODx__CDIV__DIV_1,
0, HW_PWM_PERIODx__STATE__HIGH,
(brightness * 1024) / 100, HW_PWM_PERIODx__STATE__LOW);
imx233_pwm_enable_channel(4, true);
}
bool _backlight_init(void)
{
_backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
return true;
}
void _backlight_on(void)
{
#ifdef HAVE_LCD_ENABLE
lcd_enable(true); /* power on lcd + visible display */
#endif
/* don't do anything special, the core will set the brightness */
}
void _backlight_off(void)
{
/* there is no real on/off but we can set to 0 brightness */
_backlight_set_brightness(0);
#ifdef HAVE_LCD_ENABLE
lcd_enable(false); /* power off visible display */
#endif
}

View file

@ -0,0 +1,59 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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.
*
****************************************************************************/
#ifndef _BUTTON_TARGET_H_
#define _BUTTON_TARGET_H_
#include <stdbool.h>
#include "config.h"
void button_init_device(void);
int button_read_device(int *data);
bool button_debug_screen(void);
/* Main unit's buttons */
#define BUTTON_POWER 0x00000001
#define BUTTON_MENU 0x00000002
/* For compatibility */
#define BUTTON_LEFT BUTTON_MIDLEFT
#define BUTTON_RIGHT BUTTON_MIDRIGHT
#define BUTTON_UP BUTTON_TOPMIDDLE
#define BUTTON_DOWN BUTTON_BOTTOMMIDDLE
/* Touch Screen Area Buttons */
#define BUTTON_TOPLEFT 0x00000010
#define BUTTON_TOPMIDDLE 0x00000020
#define BUTTON_TOPRIGHT 0x00000040
#define BUTTON_MIDLEFT 0x00000080
#define BUTTON_CENTER 0x00000100
#define BUTTON_MIDRIGHT 0x00000200
#define BUTTON_BOTTOMLEFT 0x00000400
#define BUTTON_BOTTOMMIDDLE 0x00000800
#define BUTTON_BOTTOMRIGHT 0x00001000
#define BUTTON_MAIN 0x1fff
#define BUTTON_REMOTE 0
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 10
#endif /* _BUTTON_TARGET_H_ */

View file

@ -0,0 +1,119 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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"
#include "string.h"
#include "usb.h"
#include "touchscreen.h"
#include "touchscreen-imx233.h"
struct touch_calibration_point
{
short px_x; /* known pixel value */
short px_y;
short val_x; /* touchscreen value at the known pixel */
short val_y;
};
static struct touch_calibration_point topleft, bottomright;
/* Amaury Pouly: values on my device
* Portait: (x and y are swapped)
* (0,0) = 200, 300
* (240,400) = 3900, 3800
* Landscape:
* (0,0) = 200, 3800
* (400,240) = 3900, 300
*/
void button_init_device(void)
{
#if CONFIG_ORIENTATION == SCREEN_PORTRAIT
topleft.val_x = 300;
topleft.val_y = 200;
bottomright.val_x = 3800;
bottomright.val_y = 3900;
#else
topleft.val_x = 300;
topleft.val_y = 3900;
bottomright.val_x = 3800;
bottomright.val_y = 200;
#endif
topleft.px_x = 0;
topleft.px_y = 0;
bottomright.px_x = LCD_WIDTH;
bottomright.px_y = LCD_HEIGHT;
imx233_touchscreen_init();
imx233_touchscreen_enable(true);
}
static int touch_to_pixels(int *val_x, int *val_y)
{
short x,y;
#if CONFIG_ORIENTATION == SCREEN_PORTRAIT
x = *val_y;
y = *val_x;
#else
x = *val_x;
y = *val_y;
#endif
x = (x - topleft.val_x) * (bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x;
y = (y - topleft.val_y) * (bottomright.px_y - topleft.px_y) / (bottomright.val_y - topleft.val_y) + topleft.px_y;
x = MAX(0, MIN(x, LCD_WIDTH - 1));
y = MAX(0, MIN(y, LCD_HEIGHT - 1));
*val_x = x;
*val_y = y;
return (x<<16)|y;
}
static int touchscreen_read_device(int *data)
{
int x, y;
if(!imx233_touchscreen_get_touch(&x, &y))
return 0;
if(data)
*data = touch_to_pixels(&x, &y);
return touchscreen_to_pixels(x, y, data);
}
int button_read_device(int *data)
{
int res = 0;
/* B0P11: #power
* B0P14: #select */
uint32_t mask = imx233_get_gpio_input_mask(0, 0x4800);
if(!(mask & 0x800))
res |= BUTTON_POWER;
if(!(mask & 0x4000))
res |= BUTTON_MENU;
return res | touchscreen_read_device(data);
}

View file

@ -0,0 +1,28 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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 "system.h"
#include "button-target.h"
bool dbg_hw_target_info(void)
{
return false;
}

View file

@ -0,0 +1,24 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2011 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.
*
****************************************************************************/
#ifndef LCD_TARGET_H
#define LCD_TARGET_H
#endif /* LCD_TARGET_H */

View file

@ -0,0 +1,512 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2011 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 <sys/types.h> /* off_t */
#include <string.h>
#include "cpu.h"
#include "system.h"
#include "backlight-target.h"
#include "lcd.h"
#include "lcdif-imx233.h"
#include "clkctrl-imx233.h"
#include "pinctrl-imx233.h"
#include "logf.h"
#ifdef HAVE_LCD_ENABLE
static bool lcd_on;
#endif
static unsigned lcd_yuv_options = 0;
static void setup_parameters(void)
{
imx233_lcdif_reset();
imx233_lcdif_set_lcd_databus_width(HW_LCDIF_CTRL__LCD_DATABUS_WIDTH_18_BIT);
imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_18_BIT);
imx233_lcdif_set_timings(2, 2, 3, 3);
}
static void setup_lcd_pins(bool use_lcdif)
{
if(use_lcdif)
{
imx233_set_pin_function(1, 25, PINCTRL_FUNCTION_MAIN); /* lcd_vsync */
imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_MAIN); /* lcd_cs */
imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_MAIN); /* lcd_dotclk */
imx233_set_pin_function(1, 23, PINCTRL_FUNCTION_MAIN); /* lcd_enable */
imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_MAIN); /* lcd_hsync */
imx233_set_pin_function(1, 18, PINCTRL_FUNCTION_MAIN); /* lcd_reset */
imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_MAIN); /* lcd_rs */
imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_MAIN); /* lcd_d16 */
imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_MAIN); /* lcd_d17 */
imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_MAIN); /* lcd_wr */
__REG_CLR(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} */
}
else
{
__REG_SET(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} */
imx233_enable_gpio_output_mask(1, 0x3ffffff, false); /* lcd_{d{0-17},reset,rs,wr,cs,dotclk,enable,hsync,vsync} */
imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */
imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */
imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */
imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_GPIO); /* lcd_wr */
imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_GPIO); /* lcd_cs */
imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_GPIO); /* lcd_dotclk */
imx233_set_pin_function(1, 23, PINCTRL_FUNCTION_GPIO); /* lcd_enable */
imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_GPIO); /* lcd_hsync */
imx233_set_pin_function(1, 25, PINCTRL_FUNCTION_GPIO); /* lcd_vsync */
}
}
static void common_lcd_enable(bool enable)
{
imx233_lcdif_enable(enable);
setup_lcd_pins(enable); /* use GPIO pins when disable */
}
static void setup_lcdif(void)
{
setup_parameters();
common_lcd_enable(true);
imx233_lcdif_enable_bus_master(true);
}
static inline uint32_t encode_16_to_18(uint32_t a)
{
return ((a & 0xff) << 1) | (((a >> 8) & 0xff) << 10);
}
static inline uint32_t decode_18_to_16(uint32_t a)
{
return ((a >> 1) & 0xff) | ((a >> 2) & 0xff00);
}
static void setup_lcdif_clock(void)
{
/* the LCD seems to work at 24Mhz, so use the xtal clock with no divider */
imx233_clkctrl_enable_clock(CLK_PIX, false);
imx233_clkctrl_set_clock_divisor(CLK_PIX, 1);
imx233_clkctrl_set_bypass_pll(CLK_PIX, true); /* use XTAL */
imx233_clkctrl_enable_clock(CLK_PIX, true);
}
static void lcd_write_reg(uint32_t reg, uint32_t data)
{
uint32_t old_reg = reg;
/* get back to 18-bit word length */
imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_18_BIT);
reg = encode_16_to_18(reg);
data = encode_16_to_18(data);
imx233_lcdif_pio_send(false, 2, &reg);
if(old_reg != 0 && old_reg != 0x202)
imx233_lcdif_pio_send(true, 2, &data);
}
#define REG_MDELAY 0xffffffff
struct lcd_sequence_entry_t
{
uint32_t reg, data;
};
static void lcd_send_sequence(struct lcd_sequence_entry_t *seq, unsigned count)
{
for(;count-- > 0; seq++)
{
if(seq->reg == REG_MDELAY)
mdelay(seq->data);
else
lcd_write_reg(seq->reg, seq->data);
}
}
#define _begin_seq() static struct lcd_sequence_entry_t __seq[] = {
#define _mdelay(a) {REG_MDELAY, a},
#define _lcd_write_reg(a, b) {a, b},
#define _end_seq() }; lcd_send_sequence(__seq, sizeof(__seq) / sizeof(__seq[0]));
static void lcd_init_seq(void)
{
_begin_seq()
_lcd_write_reg(0, 0)
_lcd_write_reg(0, 0)
_lcd_write_reg(0, 0)
_lcd_write_reg(0, 0)
_mdelay(100)
_lcd_write_reg(8, 0x808)
_lcd_write_reg(0x10, 0x10)
_lcd_write_reg(0x400, 0x6200)
_lcd_write_reg(0x300, 0xc0a)
_lcd_write_reg(0x301, 0x4c11)
_lcd_write_reg(0x302, 0x906)
_lcd_write_reg(0x303, 0x1417)
_lcd_write_reg(0x304, 0x3333)
_lcd_write_reg(0x305, 0x150d)
_lcd_write_reg(0x306, 0x740a)
_lcd_write_reg(0x307, 0x100c)
_lcd_write_reg(0x308, 0x60c)
_lcd_write_reg(0x309, 0)
_lcd_write_reg(0x100, 0x730)
_lcd_write_reg(0x101, 0x237)
_lcd_write_reg(0x103, 0x2b00)
_lcd_write_reg(0x280, 0x4000)
_lcd_write_reg(0x102, 0x81b0)
_mdelay(400)
_lcd_write_reg(1, 0x100)
_lcd_write_reg(2, 0x100)
_lcd_write_reg(3, 0x5028)
_lcd_write_reg(9, 1)
_lcd_write_reg(0xc, 0)
_lcd_write_reg(0x11, 0x202)
_lcd_write_reg(0x12, 0x101)
_lcd_write_reg(0x13, 1)
_lcd_write_reg(0x90, 0x8000)
_lcd_write_reg(0x210, 0)
_lcd_write_reg(0x211, 0xef)
_lcd_write_reg(0x212, 0)
_lcd_write_reg(0x213, 0x18f)
_lcd_write_reg(0x200, 0)
_lcd_write_reg(0x201, 0)
_lcd_write_reg(0x401, 1)
_lcd_write_reg(0x404, 0)
_mdelay(400)
_lcd_write_reg(7, 0x100)
_mdelay(400)
_lcd_write_reg(3, 0x1030)
_end_seq()
}
void lcd_init_device(void)
{
setup_lcdif();
setup_lcdif_clock();
// reset device
__REG_SET(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET;
mdelay(50);
__REG_CLR(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET;
mdelay(10);
__REG_SET(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET;
lcd_init_seq();
#ifdef HAVE_LCD_ENABLE
lcd_on = true;
#endif
}
#ifdef HAVE_LCD_ENABLE
bool lcd_active(void)
{
return lcd_on;
}
static void lcd_enable_seq(bool enable)
{
if(!enable)
{
_begin_seq()
_end_seq()
}
else
{
_begin_seq()
_end_seq()
}
}
void lcd_enable(bool enable)
{
if(lcd_on == enable)
return;
lcd_on = enable;
if(enable)
common_lcd_enable(true);
lcd_enable_seq(enable);
if(!enable)
common_lcd_enable(false);
}
#endif
void lcd_update(void)
{
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
void lcd_update_rect(int x, int y, int w, int h)
{
#ifdef HAVE_LCD_ENABLE
if(!lcd_on)
return;
#endif
/* make sure the rectangle is included in the screen */
x = MIN(x, LCD_WIDTH);
y = MIN(y, LCD_HEIGHT);
w = MIN(w, LCD_WIDTH - x);
h = MIN(h, LCD_HEIGHT - y);
imx233_lcdif_wait_ready();
lcd_write_reg(0x210, x);
lcd_write_reg(0x211, x + w - 1);
lcd_write_reg(0x212, y);
lcd_write_reg(0x213, y + h - 1);
lcd_write_reg(0x200, 0);
lcd_write_reg(0x201, 0);
lcd_write_reg(0x202, 0);
imx233_lcdif_wait_ready();
imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_16_BIT);
imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */
imx233_lcdif_set_data_format(false, false, false); /* RGB565, don't care, don't care */
/* there are two cases here:
* - either width = LCD_WIDTH and we can directly memcopy a part of lcd_framebuffer to FRAME
* and send it
* - either width != LCD_WIDTH and we have to build a contiguous copy of the rectangular area
* into FRAME before sending it (which is slower and doesn't use the hardware)
* In all cases, FRAME just acts as a temporary buffer.
* NOTE It's more interesting to do a copy to FRAME in all cases since in system mode
* the clock runs at 24MHz which provides barely 10MB/s bandwidth compared to >100MB/s
* for memcopy operations
*/
if(w == LCD_WIDTH)
{
memcpy((void *)FRAME, FBADDR(x,y), w * h * sizeof(fb_data));
}
else
{
for(int i = 0; i < h; i++)
memcpy((fb_data *)FRAME + i * w, FBADDR(x,y + i), w * sizeof(fb_data));
}
/* WARNING The LCDIF has a limitation on the vertical count ! In 16-bit packed mode
* (which we used, ie 16-bit per pixel, 2 pixels per 32-bit words), the v_count
* field must be a multiple of 2. Furthermore, it seems the lcd controller doesn't
* really like when both w and h are even, probably because the writes to the GRAM
* are done on several words and the controller requires dummy writes.
* The workaround is to always make sure that we send a number of pixels which is
* a multiple of 4 so that both the lcdif and the controller are happy. If any
* of w or h is odd, we will send a copy of the first pixels as dummy writes. We will
* send at most 3 bytes. We then send (w * h + 3) / 4 x 4 bytes.
*/
if(w % 2 == 1 || h % 2 == 1)
{
/* copy three pixel after the last one */
for(int i = 0; i < 3; i++)
*((fb_data *)FRAME + w * h + i) = *((fb_data *)FRAME + i);
/* WARNING we need to update w and h to reflect the pixel count BUT it
* has no relation to w * h (it can even be 2 * prime). Hopefully, w <= 240 and
* h <= 320 so w * h <= 76800 and (w * h + 3) / 4 <= 38400 which fits into
* a 16-bit integer (horizontal count). */
h = (w * h + 3) / 4;
w = 4;
}
imx233_lcdif_dma_send((void *)FRAME_PHYS_ADDR, w, h);
}
void lcd_yuv_set_options(unsigned options)
{
lcd_yuv_options = options;
}
#define YFAC (74)
#define RVFAC (101)
#define GUFAC (-24)
#define GVFAC (-51)
#define BUFAC (128)
static inline int clamp(int val, int min, int max)
{
if (val < min)
val = min;
else if (val > max)
val = max;
return val;
}
void lcd_blit_yuv(unsigned char * const src[3],
int src_x, int src_y, int stride,
int x, int y, int width, int height)
{
const unsigned char *ysrc, *usrc, *vsrc;
int linecounter;
fb_data *dst, *row_end;
long z;
/* width and height must be >= 2 and an even number */
width &= ~1;
linecounter = height >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
dst = FBADDR(x,y);
row_end = dst + width;
#else
dst = FBADDR(LCD_WIDTH - y - 1,x);
row_end = dst + LCD_WIDTH * width;
#endif
z = stride * src_y;
ysrc = src[0] + z + src_x;
usrc = src[1] + (z >> 2) + (src_x >> 1);
vsrc = src[2] + (usrc - src[1]);
/* stride => amount to jump from end of last row to start of next */
stride -= width;
/* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */
do
{
do
{
int y, cb, cr, rv, guv, bu, r, g, b;
y = YFAC*(*ysrc++ - 16);
cb = *usrc++ - 128;
cr = *vsrc++ - 128;
rv = RVFAC*cr;
guv = GUFAC*cb + GVFAC*cr;
bu = BUFAC*cb;
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
y = YFAC*(*ysrc++ - 16);
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
}
while (dst < row_end);
ysrc += stride;
usrc -= width >> 1;
vsrc -= width >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
row_end += LCD_WIDTH;
dst += LCD_WIDTH - width;
#else
row_end -= 1;
dst -= LCD_WIDTH*width + 1;
#endif
do
{
int y, cb, cr, rv, guv, bu, r, g, b;
y = YFAC*(*ysrc++ - 16);
cb = *usrc++ - 128;
cr = *vsrc++ - 128;
rv = RVFAC*cr;
guv = GUFAC*cb + GVFAC*cr;
bu = BUFAC*cb;
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
y = YFAC*(*ysrc++ - 16);
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
}
while (dst < row_end);
ysrc += stride;
usrc += stride >> 1;
vsrc += stride >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
row_end += LCD_WIDTH;
dst += LCD_WIDTH - width;
#else
row_end -= 1;
dst -= LCD_WIDTH*width + 1;
#endif
}
while (--linecounter > 0);
#if LCD_WIDTH >= LCD_HEIGHT
lcd_update_rect(x, y, width, height);
#else
lcd_update_rect(LCD_WIDTH - y - height, x, height, width);
#endif
}

View file

@ -0,0 +1,42 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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 "system.h"
#include "power.h"
#include "tuner.h"
#include "fmradio_i2c.h"
#include "pinctrl-imx233.h"
static bool tuner_enable = false;
bool tuner_power(bool enable)
{
if(enable != tuner_enable)
{
tuner_enable = enable;
}
return tuner_enable;
}
bool tuner_powered(void)
{
return tuner_enable;
}

View file

@ -0,0 +1,60 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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.
*
****************************************************************************/
#ifndef POWERMGMT_TARGET_H
#define POWERMGMT_TARGET_H
#include "config.h"
#include "powermgmt-imx233.h"
/* Creative ZEN X-Fi2 OF settings:
* - current ramp slope: 100 mA/s
* - conditioning threshold voltage: 3 V
* - conditioning max voltage: 3.1 V
* - conditioning current: 60 mA
* - conditioning timeout: 1 h
* - charging voltage: 4.2 V
* - charging current: 550 mA
* - charging threshold current: 60 mA
* - charging timeout: 4 h
* - top off period: 30 min
* - high die temperature: 74 °C
* - low die temperature: 56 °C
* - safe die temperature current: 30 mA
* - battery temperature channel: 1
* - high battery temperature: 440
* - low battery temperature: 605
* - safe battery temperature current: 0 mA
* - low DCDC battery voltage: 3.9 V
*
* FIXME is this an OF bug that low batt temp > high batt temp ?
*/
#define IMX233_CHARGE_CURRENT 550
#define IMX233_STOP_CURRENT 60
#define IMX233_TOPOFF_TIMEOUT (30 * 60 * HZ)
#define IMX233_CHARGING_TIMEOUT (4 * 3600 * HZ)
#define IMX233_DIE_TEMP_HIGH 74
#define IMX233_DIE_TEMP_LOW 56
#define IMX233_BATT_TEMP_SENSOR 1
#define IMX233_BATT_TEMP_HIGH 440
#define IMX233_BATT_TEMP_LOW 605
#endif /* POWERMGMT_TARGET_H */

View file

@ -0,0 +1,46 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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 "config.h"
#include "powermgmt-target.h"
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{
3659
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
3630
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
/* Toshiba Gigabeat S Li Ion 700mAH figured from discharge curve */
{ 3659, 3719, 3745, 3761, 3785, 3813, 3856, 3926, 3984, 4040, 4121 },
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
{
/* Toshiba Gigabeat S Li Ion 700mAH figured from charge curve */
4028, 4063, 4087, 4111, 4135, 4156, 4173, 4185, 4194, 4202, 4208
};

View file

@ -0,0 +1,32 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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.
*
****************************************************************************/
#ifndef _ADC_TARGET_H_
#define _ADC_TARGET_H_
#define NUM_ADC_CHANNELS 5
#define ADC_BATTERY 0
#define ADC_DIE_TEMP 1
#define ADC_VDDIO 2
#define ADC_5V 3
#define ADC_BATT_TEMP 4
#endif

View file

@ -0,0 +1,40 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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 "adc-target.h"
#include "adc-imx233.h"
int imx233_adc_mapping[] =
{
[ADC_BATTERY] = IMX233_ADC_BATTERY,
[ADC_DIE_TEMP] = IMX233_ADC_DIE_TEMP,
[ADC_VDDIO] = IMX233_ADC_VDDIO,
[ADC_5V] = HW_LRADC_CHANNEL_5V,
[ADC_BATT_TEMP] = IMX233_ADC_BATT_TEMP,
};
const char *imx233_adc_channel_name[] =
{
"Battery(raw)",
"Die temperature(°C)",
"VddIO",
"Vdd5V",
"Battery temperature(raw)",
};

View file

@ -0,0 +1,61 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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 "config.h"
#include "system.h"
#include "audiohw.h"
#include "audio.h"
#include "audioout-imx233.h"
#include "audioin-imx233.h"
#include "pinctrl-imx233.h"
static int input_source = AUDIO_SRC_PLAYBACK;
static unsigned input_flags = 0;
static int output_source = AUDIO_SRC_PLAYBACK;
static void select_audio_path(void)
{
/* route audio to HP */
imx233_set_pin_function(1, 30, PINCTRL_FUNCTION_GPIO);
imx233_enable_gpio_output(1, 30, true);
imx233_set_gpio_output(1, 30, true);
if(input_source == AUDIO_SRC_PLAYBACK)
imx233_audioout_select_hp_input(false);
else
imx233_audioout_select_hp_input(true);
}
void audio_input_mux(int source, unsigned flags)
{
(void) source;
(void) flags;
input_source = source;
input_flags = flags;
select_audio_path();
}
void audio_set_output_source(int source)
{
(void) source;
output_source = source;
select_audio_path();
}

View file

@ -0,0 +1,33 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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.
*
****************************************************************************/
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
bool _backlight_init(void);
void _backlight_on(void);
void _backlight_off(void);
void _backlight_set_brightness(int brightness);
void _buttonlight_on(void);
void _buttonlight_off(void);
void _buttonlight_set_brightness(int brightness);
#endif /* BACKLIGHT_TARGET_H */

View file

@ -0,0 +1,85 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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 "config.h"
#include "system.h"
#include "lcd.h"
#include "backlight.h"
#include "backlight-target.h"
#include "pwm-imx233.h"
#include "mpr121.h"
void _backlight_set_brightness(int brightness)
{
imx233_pwm_setup_channel(2, 1024, HW_PWM_PERIODx__CDIV__DIV_1,
0, HW_PWM_PERIODx__STATE__HIGH,
(brightness * 1024) / 100, HW_PWM_PERIODx__STATE__LOW);
imx233_pwm_enable_channel(2, true);
}
bool _backlight_init(void)
{
_backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
return true;
}
void _backlight_on(void)
{
#ifdef HAVE_LCD_ENABLE
lcd_enable(true); /* power on lcd + visible display */
#endif
/* don't do anything special, the core will set the brightness */
}
void _backlight_off(void)
{
/* there is no real on/off but we can set to 0 brightness */
_backlight_set_brightness(0);
#ifdef HAVE_LCD_ENABLE
lcd_enable(false); /* power off visible display */
#endif
}
/* ELE8 is the button light GPIO */
void _buttonlight_on(void)
{
/* assume mpr121 was initialized by button-zenxfi3.c */
mpr121_set_gpio_output(8, ELE_GPIO_SET);
}
void _buttonlight_off(void)
{
/* assume mpr121 was initialized by button-zenxfi3.c */
mpr121_set_gpio_output(8, ELE_GPIO_CLR);
}
void _buttonlight_set_brightness(int brightness)
{
/* assume mpr121 was initialized by button-zenxfi3.c */
/* since backlight brightness is the same for the screen and the button light,
* map [MIN_BRIGHTNESS_SETTING,MAX_BRIGHTNESS_SETTING] to
* [ELE_PWM_MIN_DUTY,ELE_PWM_MAX_DUTY] */
brightness = ELE_PWM_MIN_DUTY + (brightness - MIN_BRIGHTNESS_SETTING) *
(ELE_PWM_MAX_DUTY - ELE_PWM_MIN_DUTY + 1) /
(MAX_BRIGHTNESS_SETTING - MIN_BRIGHTNESS_SETTING + 1);
brightness = MIN(brightness, ELE_PWM_MAX_DUTY);
mpr121_set_gpio_pwm(8, brightness);
}

View file

@ -0,0 +1,54 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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.
*
****************************************************************************/
#ifndef _BUTTON_TARGET_H_
#define _BUTTON_TARGET_H_
#include <stdbool.h>
#include "config.h"
void button_init_device(void);
int button_read_device(void);
bool button_debug_screen(void);
#define HAS_BUTTON_HOLD
/* Main unit's buttons */
#define BUTTON_POWER 0x00000001
#define BUTTON_MENU 0x00000002
#define BUTTON_BACK 0x00000004
#define BUTTON_PLAY 0x00000008
#define BUTTON_UP 0x00000010
#define BUTTON_DOWN 0x00000020
#define BUTTON_VOL_UP 0x00000040
#define BUTTON_VOL_DOWN 0x00000080
/* For compatibility */
#define BUTTON_LEFT BUTTON_BACK
#define BUTTON_RIGHT BUTTON_PLAY
#define BUTTON_MAIN 0xff
#define BUTTON_REMOTE 0
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 10
#endif /* _BUTTON_TARGET_H_ */

View file

@ -0,0 +1,171 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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"
#include "string.h"
#include "usb.h"
#include "backlight.h"
#include "mpr121.h"
static struct mpr121_config_t config =
{
.ele =
{
[0] = {.tth = 5, .rth = 4 },
[1] = {.tth = 5, .rth = 4 },
[2] = {.tth = 5, .rth = 4 },
[3] = {.tth = 5, .rth = 4 },
[4] = {.tth = 4, .rth = 3 },
[5] = {.tth = 4, .rth = 3 },
[6] = {.tth = 5, .rth = 4 },
[7] = {.tth = 5, .rth = 4 },
[8] = {.gpio = ELE_GPIO_OUTPUT_OPEN_LED },
},
.filters =
{
.ele =
{
.rising = {.mhd = 1, .nhd = 1, .ncl = 1, .fdl = 1 },
.falling = {.mhd = 1, .nhd = 1, .ncl = 0xff, .fdl = 2 },
}
},
.autoconf =
{
.en = true, .ren = true, .retry = RETRY_NEVER,
.usl = 0xc4, .lsl = 0x7f, .tl = 0xb0
},
.ele_en = ELE_EN0_x(7),
.cal_lock = CL_TRACK
};
#define MPR121_INTERRUPT 1
static int touchpad_btns = 0;
static long mpr121_stack[DEFAULT_STACK_SIZE/sizeof(long)];
static const char mpr121_thread_name[] = "mpr121";
static struct event_queue mpr121_queue;
static void mpr121_irq_cb(int bank, int pin)
{
(void) bank;
(void) pin;
/* the callback will not be fired until interrupt is enabled back so
* the queue will not overflow or contain multiple MPR121_INTERRUPT events */
queue_post(&mpr121_queue, MPR121_INTERRUPT, 0);
}
static void mpr121_thread(void)
{
struct queue_event ev;
while(1)
{
queue_wait(&mpr121_queue, &ev);
/* handle usb connect and ignore all messages except rmi interrupts */
if(ev.id == SYS_USB_CONNECTED)
{
usb_acknowledge(SYS_USB_CONNECTED_ACK);
continue;
}
else if(ev.id != MPR121_INTERRUPT)
continue;
/* clear interrupt and get status */
unsigned status;
touchpad_btns = 0;
if(!mpr121_get_touch_status(&status))
{
/* ELE3: up
* ELE4: back
* ELE5: menu
* ELE6: down
* ELE7: play */
if(status & 0x8) touchpad_btns |= BUTTON_UP;
if(status & 0x10) touchpad_btns |= BUTTON_BACK;
if(status & 0x20) touchpad_btns |= BUTTON_MENU;
if(status & 0x40) touchpad_btns |= BUTTON_DOWN;
if(status & 0x80) touchpad_btns |= BUTTON_PLAY;
}
/* enable interrupt */
imx233_setup_pin_irq(0, 18, true, true, false, &mpr121_irq_cb);
}
}
/* B0P18 is #IRQ line of the touchpad */
void button_init_device(void)
{
mpr121_init(0xb4);
mpr121_soft_reset();
mpr121_set_config(&config);
queue_init(&mpr121_queue, true);
create_thread(mpr121_thread, mpr121_stack, sizeof(mpr121_stack), 0,
mpr121_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU));
/* enable interrupt */
imx233_set_pin_function(0, 18, PINCTRL_FUNCTION_GPIO);
imx233_enable_gpio_output(0, 18, false);
imx233_setup_pin_irq(0, 18, true, true, false, &mpr121_irq_cb);
}
bool button_hold(void)
{
/* B0P04: #hold */
return !imx233_get_gpio_input_mask(0, 0x10);
}
int button_read_device(void)
{
/* since sliding hold will usually trigger power, ignore power button
* for one second after hold is released */
static int power_ignore_counter = 0;
static bool old_hold;
/* light handling */
bool hold = button_hold();
if(hold != old_hold)
{
old_hold = hold;
#ifndef BOOTLOADER
backlight_hold_changed(hold);
#endif /* BOOTLOADER */
if(!hold)
power_ignore_counter = HZ;
}
if(power_ignore_counter)
power_ignore_counter--;
int res = 0;
/* B2P07: #volume-
* B2P08: #volume+
* PSWITCH: power */
uint32_t mask = imx233_get_gpio_input_mask(2, 0x180);
if(!(mask & 0x80))
res |= BUTTON_VOL_DOWN;
if(!(mask & 0x100))
res |= BUTTON_VOL_UP;
/* WARNING: it seems that the voltage on PSWITCH depends on whether
* usb is connected or not ! Thus the value of this field can be 1 or 3 */
if(__XTRACT(HW_POWER_STS, PSWITCH) != 0 && power_ignore_counter == 0)
res |= BUTTON_POWER;
return res | touchpad_btns;
}

View file

@ -0,0 +1,28 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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 "system.h"
#include "button-target.h"
bool dbg_hw_target_info(void)
{
return false;
}

View file

@ -0,0 +1,24 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2012 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.
*
****************************************************************************/
#ifndef LCD_TARGET_H
#define LCD_TARGET_H
#endif /* LCD_TARGET_H */

View file

@ -0,0 +1,490 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2012 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 <sys/types.h> /* off_t */
#include <string.h>
#include "cpu.h"
#include "system.h"
#include "backlight-target.h"
#include "lcd.h"
#include "lcdif-imx233.h"
#include "clkctrl-imx233.h"
#include "pinctrl-imx233.h"
#include "logf.h"
#ifdef HAVE_LCD_ENABLE
static bool lcd_on;
#endif
static unsigned lcd_yuv_options = 0;
static void setup_parameters(void)
{
imx233_lcdif_reset();
imx233_lcdif_set_lcd_databus_width(HW_LCDIF_CTRL__LCD_DATABUS_WIDTH_16_BIT);
imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_16_BIT);
imx233_lcdif_set_timings(2, 2, 3, 3);
}
static void setup_lcd_pins(bool use_lcdif)
{
if(use_lcdif)
{
imx233_set_pin_function(1, 25, PINCTRL_FUNCTION_MAIN); /* lcd_vsync */
imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_MAIN); /* lcd_cs */
imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_MAIN); /* lcd_dotclk */
imx233_set_pin_function(1, 23, PINCTRL_FUNCTION_MAIN); /* lcd_enable */
imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_MAIN); /* lcd_hsync */
imx233_set_pin_function(1, 18, PINCTRL_FUNCTION_MAIN); /* lcd_reset */
imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_MAIN); /* lcd_rs */
imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_MAIN); /* lcd_d16 */
imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_MAIN); /* lcd_d17 */
imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_MAIN); /* lcd_wr */
__REG_CLR(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} */
}
else
{
__REG_SET(HW_PINCTRL_MUXSEL(2)) = 0xffffffff; /* lcd_d{0-15} */
imx233_enable_gpio_output_mask(1, 0x3ffffff, false); /* lcd_{d{0-17},reset,rs,wr,cs,dotclk,enable,hsync,vsync} */
imx233_set_pin_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */
imx233_set_pin_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */
imx233_set_pin_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */
imx233_set_pin_function(1, 20, PINCTRL_FUNCTION_GPIO); /* lcd_wr */
imx233_set_pin_function(1, 21, PINCTRL_FUNCTION_GPIO); /* lcd_cs */
imx233_set_pin_function(1, 22, PINCTRL_FUNCTION_GPIO); /* lcd_dotclk */
imx233_set_pin_function(1, 23, PINCTRL_FUNCTION_GPIO); /* lcd_enable */
imx233_set_pin_function(1, 24, PINCTRL_FUNCTION_GPIO); /* lcd_hsync */
imx233_set_pin_function(1, 25, PINCTRL_FUNCTION_GPIO); /* lcd_vsync */
}
}
static void common_lcd_enable(bool enable)
{
imx233_lcdif_enable(enable);
setup_lcd_pins(enable); /* use GPIO pins when disable */
}
static void setup_lcdif(void)
{
setup_parameters();
common_lcd_enable(true);
imx233_lcdif_enable_bus_master(true);
}
static void setup_lcdif_clock(void)
{
/* the LCD seems to work at 24Mhz, so use the xtal clock with no divider */
imx233_clkctrl_enable_clock(CLK_PIX, false);
imx233_clkctrl_set_clock_divisor(CLK_PIX, 1);
imx233_clkctrl_set_bypass_pll(CLK_PIX, true); /* use XTAL */
imx233_clkctrl_enable_clock(CLK_PIX, true);
}
static void lcd_write_reg(uint32_t reg, uint32_t data)
{
imx233_lcdif_pio_send(false, 2, &reg);
if(reg != 0x22)
imx233_lcdif_pio_send(true, 2, &data);
}
#define REG_UDELAY 0xffffffff
struct lcd_sequence_entry_t
{
uint32_t reg, data;
};
static void lcd_send_sequence(struct lcd_sequence_entry_t *seq, unsigned count)
{
for(;count-- > 0; seq++)
{
if(seq->reg == REG_UDELAY)
udelay(seq->data);
else
lcd_write_reg(seq->reg, seq->data);
}
}
#define _begin_seq() static struct lcd_sequence_entry_t __seq[] = {
#define _udelay(a) {REG_UDELAY, a},
#define _lcd_write_reg(a, b) {a, b},
#define _end_seq() }; lcd_send_sequence(__seq, sizeof(__seq) / sizeof(__seq[0]));
static void lcd_init_seq(void)
{
_begin_seq()
_lcd_write_reg(1, 0x11c)
_lcd_write_reg(2, 0x100)
_lcd_write_reg(3, 0x1030)
_lcd_write_reg(8, 0x808)
_lcd_write_reg(0xc, 0)
_lcd_write_reg(0xf, 0xc01)
_lcd_write_reg(0x20, 0)
_lcd_write_reg(0x21, 0)
_udelay(30)
_lcd_write_reg(0x10, 0xa00)
_lcd_write_reg(0x11, 0x1038)
_udelay(30)
_lcd_write_reg(0x12, 0x1010)
_lcd_write_reg(0x13, 0x50)
_lcd_write_reg(0x14, 0x4f58)
_lcd_write_reg(0x30, 0)
_lcd_write_reg(0x31, 0xdb)
_lcd_write_reg(0x32, 0)
_lcd_write_reg(0x33, 0)
_lcd_write_reg(0x34, 0xdb)
_lcd_write_reg(0x35, 0)
_lcd_write_reg(0x36, 0xaf)
_lcd_write_reg(0x37, 0)
_lcd_write_reg(0x38, 0xdb)
_lcd_write_reg(0x39, 0)
_lcd_write_reg(0x50, 0)
_lcd_write_reg(0x51, 0x705)
_lcd_write_reg(0x52, 0xe0a)
_lcd_write_reg(0x53, 0x300)
_lcd_write_reg(0x54, 0xa0e)
_lcd_write_reg(0x55, 0x507)
_lcd_write_reg(0x56, 0)
_lcd_write_reg(0x57, 3)
_lcd_write_reg(0x58, 0x90a)
_lcd_write_reg(0x59, 0xa09)
_udelay(30)
_lcd_write_reg(7, 0x1017)
_udelay(40)
_end_seq()
}
void lcd_init_device(void)
{
setup_lcdif();
setup_lcdif_clock();
// reset device
__REG_SET(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET;
mdelay(50);
__REG_CLR(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET;
mdelay(10);
__REG_SET(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__RESET;
lcd_init_seq();
#ifdef HAVE_LCD_ENABLE
lcd_on = true;
#endif
}
#ifdef HAVE_LCD_ENABLE
bool lcd_active(void)
{
return lcd_on;
}
static void lcd_enable_seq(bool enable)
{
if(!enable)
{
_begin_seq()
_end_seq()
}
else
{
_begin_seq()
_end_seq()
}
}
void lcd_enable(bool enable)
{
if(lcd_on == enable)
return;
lcd_on = enable;
if(enable)
common_lcd_enable(true);
lcd_enable_seq(enable);
if(!enable)
common_lcd_enable(false);
}
#endif
void lcd_update(void)
{
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
void lcd_update_rect(int x, int y, int w, int h)
{
#ifdef HAVE_LCD_ENABLE
if(!lcd_on)
return;
#endif
/* make sure the rectangle is included in the screen */
x = MIN(x, LCD_WIDTH);
y = MIN(y, LCD_HEIGHT);
w = MIN(w, LCD_WIDTH - x);
h = MIN(h, LCD_HEIGHT - y);
imx233_lcdif_wait_ready();
lcd_write_reg(0x37, x);
lcd_write_reg(0x36, x + w - 1);
lcd_write_reg(0x39, y);
lcd_write_reg(0x38, y + h - 1);
lcd_write_reg(0x20, x);
lcd_write_reg(0x21, y);
lcd_write_reg(0x22, 0);
imx233_lcdif_wait_ready();
imx233_lcdif_set_word_length(HW_LCDIF_CTRL__WORD_LENGTH_16_BIT);
imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */
imx233_lcdif_set_data_format(false, false, false); /* RGB565, don't care, don't care */
/* there are two cases here:
* - either width = LCD_WIDTH and we can directly memcopy a part of lcd_framebuffer to FRAME
* and send it
* - either width != LCD_WIDTH and we have to build a contiguous copy of the rectangular area
* into FRAME before sending it (which is slower and doesn't use the hardware)
* In all cases, FRAME just acts as a temporary buffer.
* NOTE It's more interesting to do a copy to FRAME in all cases since in system mode
* the clock runs at 24MHz which provides barely 10MB/s bandwidth compared to >100MB/s
* for memcopy operations
*/
if(w == LCD_WIDTH)
{
memcpy((void *)FRAME, FBADDR(x,y), w * h * sizeof(fb_data));
}
else
{
for(int i = 0; i < h; i++)
memcpy((fb_data *)FRAME + i * w, FBADDR(x,y + i), w * sizeof(fb_data));
}
/* WARNING The LCDIF has a limitation on the vertical count ! In 16-bit packed mode
* (which we used, ie 16-bit per pixel, 2 pixels per 32-bit words), the v_count
* field must be a multiple of 2. Furthermore, it seems the lcd controller doesn't
* really like when both w and h are even, probably because the writes to the GRAM
* are done on several words and the controller requires dummy writes.
* The workaround is to always make sure that we send a number of pixels which is
* a multiple of 4 so that both the lcdif and the controller are happy. If any
* of w or h is odd, we will send a copy of the first pixels as dummy writes. We will
* send at most 3 bytes. We then send (w * h + 3) / 4 x 4 bytes.
*/
if(w % 2 == 1 || h % 2 == 1)
{
/* copy three pixel after the last one */
for(int i = 0; i < 3; i++)
*((fb_data *)FRAME + w * h + i) = *((fb_data *)FRAME + i);
/* WARNING we need to update w and h to reflect the pixel count BUT it
* has no relation to w * h (it can even be 2 * prime). Hopefully, w <= 240 and
* h <= 320 so w * h <= 76800 and (w * h + 3) / 4 <= 38400 which fits into
* a 16-bit integer (horizontal count). */
h = (w * h + 3) / 4;
w = 4;
}
imx233_lcdif_dma_send((void *)FRAME_PHYS_ADDR, w, h);
}
void lcd_yuv_set_options(unsigned options)
{
lcd_yuv_options = options;
}
#define YFAC (74)
#define RVFAC (101)
#define GUFAC (-24)
#define GVFAC (-51)
#define BUFAC (128)
static inline int clamp(int val, int min, int max)
{
if (val < min)
val = min;
else if (val > max)
val = max;
return val;
}
void lcd_blit_yuv(unsigned char * const src[3],
int src_x, int src_y, int stride,
int x, int y, int width, int height)
{
const unsigned char *ysrc, *usrc, *vsrc;
int linecounter;
fb_data *dst, *row_end;
long z;
/* width and height must be >= 2 and an even number */
width &= ~1;
linecounter = height >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
dst = FBADDR(x,y);
row_end = dst + width;
#else
dst = FBADDR(LCD_WIDTH - y - 1,x);
row_end = dst + LCD_WIDTH * width;
#endif
z = stride * src_y;
ysrc = src[0] + z + src_x;
usrc = src[1] + (z >> 2) + (src_x >> 1);
vsrc = src[2] + (usrc - src[1]);
/* stride => amount to jump from end of last row to start of next */
stride -= width;
/* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */
do
{
do
{
int y, cb, cr, rv, guv, bu, r, g, b;
y = YFAC*(*ysrc++ - 16);
cb = *usrc++ - 128;
cr = *vsrc++ - 128;
rv = RVFAC*cr;
guv = GUFAC*cb + GVFAC*cr;
bu = BUFAC*cb;
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
y = YFAC*(*ysrc++ - 16);
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
}
while (dst < row_end);
ysrc += stride;
usrc -= width >> 1;
vsrc -= width >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
row_end += LCD_WIDTH;
dst += LCD_WIDTH - width;
#else
row_end -= 1;
dst -= LCD_WIDTH*width + 1;
#endif
do
{
int y, cb, cr, rv, guv, bu, r, g, b;
y = YFAC*(*ysrc++ - 16);
cb = *usrc++ - 128;
cr = *vsrc++ - 128;
rv = RVFAC*cr;
guv = GUFAC*cb + GVFAC*cr;
bu = BUFAC*cb;
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
y = YFAC*(*ysrc++ - 16);
r = y + rv;
g = y + guv;
b = y + bu;
if ((unsigned)(r | g | b) > 64*256-1)
{
r = clamp(r, 0, 64*256-1);
g = clamp(g, 0, 64*256-1);
b = clamp(b, 0, 64*256-1);
}
*dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9);
#if LCD_WIDTH >= LCD_HEIGHT
dst++;
#else
dst += LCD_WIDTH;
#endif
}
while (dst < row_end);
ysrc += stride;
usrc += stride >> 1;
vsrc += stride >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
row_end += LCD_WIDTH;
dst += LCD_WIDTH - width;
#else
row_end -= 1;
dst -= LCD_WIDTH*width + 1;
#endif
}
while (--linecounter > 0);
#if LCD_WIDTH >= LCD_HEIGHT
lcd_update_rect(x, y, width, height);
#else
lcd_update_rect(LCD_WIDTH - y - height, x, height, width);
#endif
}

View file

@ -0,0 +1,42 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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 "system.h"
#include "power.h"
#include "tuner.h"
#include "fmradio_i2c.h"
#include "pinctrl-imx233.h"
static bool tuner_enable = false;
bool tuner_power(bool enable)
{
if(enable != tuner_enable)
{
tuner_enable = enable;
}
return tuner_enable;
}
bool tuner_powered(void)
{
return tuner_enable;
}

View file

@ -0,0 +1,58 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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.
*
****************************************************************************/
#ifndef POWERMGMT_TARGET_H
#define POWERMGMT_TARGET_H
#include "config.h"
#include "powermgmt-imx233.h"
/* Creative ZEN X-Fi3 OF settings:
* - current ramp slope: 10 mA/s
* - conditioning threshold voltage: 3 V
* - conditioning max voltage: 3.1 V
* - conditioning current: 60 mA
* - conditioning timeout: 1 h
* - charging voltage: 4.2 V
* - charging current: 260 mA
* - charging threshold current: 20 mA
* - charging timeout: 4 h
* - top off period: 30 min
* - high die temperature: 91 °C
* - low die temperature: 56 °C
* - safe die temperature current: 30 mA
* - battery temperature channel: 0
* - high battery temperature: 2400
* - low battery temperature: 2300
* - safe battery temperature current: 0 mA
* - low DCDC battery voltage: 3.9 V
*/
#define IMX233_CHARGE_CURRENT 260
#define IMX233_STOP_CURRENT 20
#define IMX233_TOPOFF_TIMEOUT (30 * 60 * HZ)
#define IMX233_CHARGING_TIMEOUT (4 * 3600 * HZ)
#define IMX233_DIE_TEMP_HIGH 91
#define IMX233_DIE_TEMP_LOW 56
#define IMX233_BATT_TEMP_SENSOR 0
#define IMX233_BATT_TEMP_HIGH 2400
#define IMX233_BATT_TEMP_LOW 2300
#endif /* POWERMGMT_TARGET_H */

View file

@ -0,0 +1,46 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 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 "config.h"
#include "powermgmt-target.h"
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{
3659
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
3630
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
/* Toshiba Gigabeat S Li Ion 700mAH figured from discharge curve */
{ 3659, 3719, 3745, 3761, 3785, 3813, 3856, 3926, 3984, 4040, 4121 },
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
{
/* Toshiba Gigabeat S Li Ion 700mAH figured from charge curve */
4028, 4063, 4087, 4111, 4135, 4156, 4173, 4185, 4194, 4202, 4208
};

View file

@ -62,6 +62,28 @@ struct sd_config_t sd_config[] =
.power_pin = PIN(0, 8), .power_pin = PIN(0, 8),
.ssp = 1 .ssp = 1
}, },
#elif defined(CREATIVE_ZENXFI2)
/* The Zen X-Fi2 uses pin B1P29 for power*/
{
.name = "microSD",
.flags = POWER_PIN | REMOVABLE | DETECT_INVERTED,
.power_pin = PIN(1, 29),
.ssp = 1,
},
#elif defined(CREATIVE_ZENXFI3)
{
.name = "internal/SD",
.flags = WINDOW,
.ssp = 2
},
/* The Zen X-Fi3 uses pin #B0P07 for power*/
{
.name = "microSD",
.flags = POWER_PIN | POWER_INVERTED | REMOVABLE | POWER_DELAY,
.power_pin = PIN(0, 7),
.power_delay = HZ / 10, /* extra delay, to ramp up voltage? */
.ssp = 1
},
#else #else
#error You need to write the sd config! #error You need to write the sd config!
#endif #endif

View file

@ -148,7 +148,7 @@ void NORETURN_ATTR UIE(unsigned int pc, unsigned int num)
if (!triggered) if (!triggered)
{ {
triggered = true; triggered = true;
backtrace(pc, __get_sp(), &line); //backtrace(pc, __get_sp(), &line);
} }
lcd_update(); lcd_update();

View file

@ -431,6 +431,13 @@
#define UI_LCD_POSX 68 #define UI_LCD_POSX 68
#define UI_LCD_POSY 77 #define UI_LCD_POSY 77
#elif defined(CREATIVE_ZENXFI3)
#define UI_TITLE "Creative ZEN X-Fi3"
#define UI_WIDTH 262 /* width of GUI window */
#define UI_HEIGHT 350 /* height of GUI window */
#define UI_LCD_POSX 43
#define UI_LCD_POSY 65
#elif defined(APPLICATION) #elif defined(APPLICATION)
#define UI_TITLE "Rockbox" #define UI_TITLE "Rockbox"
#define UI_LCD_POSX 0 #define UI_LCD_POSX 0

83
tools/configure vendored
View file

@ -1271,27 +1271,28 @@ cat <<EOF
90) Zen Vision:M 30GB 100) GoGear SA9200 54) Sansa c100 90) Zen Vision:M 30GB 100) GoGear SA9200 54) Sansa c100
91) Zen Vision:M 60GB 101) GoGear HDD1630/ 55) Sansa Clip 91) Zen Vision:M 60GB 101) GoGear HDD1630/ 55) Sansa Clip
92) Zen Vision HDD1830 56) Sansa e200v2 92) Zen Vision HDD1830 56) Sansa e200v2
102) GoGear HDD6330 57) Sansa m200v4 93) Zen X-Fi2 102) GoGear HDD6330 57) Sansa m200v4
==Onda== 58) Sansa Fuze 94) Zen X-Fi3 58) Sansa Fuze
120) VX747 ==Meizu== 59) Sansa c200v2 ==Meizu== 59) Sansa c200v2
121) VX767 110) M6SL 60) Sansa Clipv2 ==Onda== 110) M6SL 60) Sansa Clipv2
122) VX747+ 111) M6SP 61) Sansa View 120) VX747 111) M6SP 61) Sansa View
123) VX777 112) M3 62) Sansa Clip+ 121) VX767 112) M3 62) Sansa Clip+
63) Sansa Fuze v2 122) VX747+ 63) Sansa Fuze v2
==Samsung== ==Tatung== 64) Sansa Fuze+ 123) VX777 ==Tatung== 64) Sansa Fuze+
140) YH-820 150) Elio TPJ-1022 65) Sansa Clip Zip 150) Elio TPJ-1022 65) Sansa Clip Zip
141) YH-920 66) Sansa Connect ==Samsung== 66) Sansa Connect
142) YH-925 ==Packard Bell== 140) YH-820 ==Packard Bell==
143) YP-S3 160) Vibe 500 ==Logik== 141) YH-920 160) Vibe 500 ==Logik==
80) DAX 1GB MP3/DAB 142) YH-925 80) DAX 1GB MP3/DAB
==Application== ==MPIO== 143) YP-S3 ==MPIO==
200) SDL 170) HD200 ==Lyre project== 170) HD200 ==Lyre project==
201) Android 171) HD300 130) Lyre proto 1 ==Application== 171) HD300 130) Lyre proto 1
202) Nokia N8xx 131) Mini2440 200) SDL 131) Mini2440
203) Nokia N900 ==ROCKCHIP== ==HiFiMAN== 201) Android ==ROCKCHIP==
204) Pandora 180) rk27xx generic 190) HM-60x 202) Nokia N8xx 180) rk27xx generic ==HiFiMAN==
205) Samsung YP-R0 191) HM-801 203) Nokia N900 190) HM-60x
204) Pandora 191) HM-801
205) Samsung YP-R0
EOF EOF
buildfor=`input`; buildfor=`input`;
@ -2199,6 +2200,46 @@ fi
t_model="creative-zvm" t_model="creative-zvm"
;; ;;
93|creativezenxfi2)
target_id=80
modelname="creativezenxfi2"
target="CREATIVE_ZENXFI2"
memory=64
bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
tool="$rootdir/tools/scramble -add=zxf2"
output="rockbox.creative"
bootoutput="bootloader-zenxfi2.creative"
appextra="gui:recorder:radio"
plugins="yes"
swcodec="yes"
toolset=$scramblebitmaptools
t_cpu="arm"
t_manufacturer="imx233"
t_model="creative-zenxfi2"
arm926ejscc
;;
94|creativezenxfi3)
target_id=81
modelname="creativezenxfi3"
target="CREATIVE_ZENXFI3"
memory=64
bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
tool="$rootdir/tools/scramble -add=zxf3"
output="rockbox.creative"
bootoutput="bootloader-zenxfi3.creative"
appextra="gui:recorder:radio"
plugins="no"
swcodec="yes"
toolset=$scramblebitmaptools
t_cpu="arm"
t_manufacturer="imx233"
t_model="creative-zenxfi3"
arm926ejscc
;;
50|sansae200) 50|sansae200)
target_id=23 target_id=23
modelname="sansae200" modelname="sansae200"

View file

@ -128,7 +128,7 @@ void usage(void)
"\t 9200, 1630, 6330, ldax, m200, c100, clip, e2v2,\n" "\t 9200, 1630, 6330, ldax, m200, c100, clip, e2v2,\n"
"\t m2v4, fuze, c2v2, clv2, y820, y920, y925, x747,\n" "\t m2v4, fuze, c2v2, clv2, y820, y920, y925, x747,\n"
"\t 747p, x777, nn2g, m244, cli+, fuz2, hd20, hd30,\n" "\t 747p, x777, nn2g, m244, cli+, fuz2, hd20, hd30,\n"
"\t ip6g, rk27, clzp)\n"); "\t ip6g, rk27, clzp, zxf2, zxf3)\n");
printf("\nNo option results in Archos standard player/recorder format.\n"); printf("\nNo option results in Archos standard player/recorder format.\n");
exit(1); exit(1);
@ -361,6 +361,10 @@ int main (int argc, char** argv)
modelnum = 79; modelnum = 79;
else if (!strcmp(&argv[1][5], "conn")) /* Sansa Connect */ else if (!strcmp(&argv[1][5], "conn")) /* Sansa Connect */
modelnum = 81; modelnum = 81;
else if (!strcmp(&argv[1][5], "zxf2")) /* Creative Zen X-Fi2 */
modelnum = 82;
else if (!strcmp(&argv[1][5], "zxf3")) /* Creative Zen X-Fi3 */
modelnum = 83;
else { else {
fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
return 2; return 2;

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

View file

@ -67,6 +67,8 @@ mpio-hd200.c
mpio-hd300.c mpio-hd300.c
#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD #elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
sansa-fuzeplus.c sansa-fuzeplus.c
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD
creative-zenxfi3.c
#elif CONFIG_KEYPAD == SANSA_CONNECT_PAD #elif CONFIG_KEYPAD == SANSA_CONNECT_PAD
sansa-connect.c sansa-connect.c
#endif #endif

View file

@ -0,0 +1,74 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2011 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 <SDL.h>
#include "button.h"
#include "buttonmap.h"
int key_to_button(int keyboard_button)
{
int new_btn = BUTTON_NONE;
switch (keyboard_button)
{
case SDLK_KP4:
case SDLK_LEFT:
new_btn = BUTTON_LEFT;
break;
case SDLK_KP6:
case SDLK_RIGHT:
new_btn = BUTTON_RIGHT;
break;
case SDLK_KP8:
case SDLK_UP:
new_btn = BUTTON_UP;
break;
case SDLK_KP2:
case SDLK_DOWN:
new_btn = BUTTON_DOWN;
break;
case SDLK_PAGEDOWN:
case SDLK_KP3:
new_btn = BUTTON_MENU;
break;
case SDLK_KP_PLUS:
new_btn = BUTTON_VOL_UP;
break;
case SDLK_KP_MINUS:
new_btn = BUTTON_VOL_DOWN;
break;
case SDLK_HOME:
new_btn = BUTTON_POWER;
break;
}
return new_btn;
}
struct button_map bm[] = {
{ SDLK_LEFT, 69, 303, 10, "Left" },
{ SDLK_RIGHT, 241, 172, 10, "Right" },
{ SDLK_UP, 240, 87, 10, "Up" },
{ SDLK_DOWN, 239, 264, 10, "Down" },
{ SDLK_PAGEDOWN, 191, 303, 10, "Menu" },
{ SDLK_KP_MINUS, 270, 150, 0, "Volume -" },
{ SDLK_KP_PLUS, 270, 180, 0, "Volume +" },
{ 0, 0, 0, 0, "None" }
};