* Commit a modified FS#10354 (thanks to Davide Quarta) - add support the VX747+ in scramble and configure
* Add support for the VX777
* Remove the touchscreen mode switching combo from the button driver



git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21379 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/SOURCES b/apps/SOURCES
index 4caf32d..7475826 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -234,6 +234,8 @@
 keymaps/keymap-fuze.c
 #elif CONFIG_KEYPAD == ONDAVX747_PAD
 keymaps/keymap-ondavx747.c
+#elif CONFIG_KEYPAD == ONDAVX777_PAD
+keymaps/keymap-ondavx777.c
 #elif CONFIG_KEYPAD == ONDAVX767_PAD
 keymaps/keymap-ondavx767.c
 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
diff --git a/apps/keymaps/keymap-ondavx777.c b/apps/keymaps/keymap-ondavx777.c
new file mode 100644
index 0000000..99f509b
--- /dev/null
+++ b/apps/keymaps/keymap-ondavx777.c
@@ -0,0 +1,171 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Maurus Cuelenaere
+ *
+ * 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 Onda VX747 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[]  = {
+    LAST_ITEM_IN_LIST
+}; /* button_context_standard */
+
+
+static const struct button_mapping button_context_wps[]  = {
+    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[]  = {
+    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[]  = {
+    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[]  = {
+
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_quickscreen */
+
+static const struct button_mapping button_context_pitchscreen[]  = {
+}; /* button_context_pitchcreen */
+
+/** FM Radio Screen **/
+static const struct button_mapping button_context_radio[]  = {
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
+}; /* button_context_radio */
+
+static const struct button_mapping button_context_keyboard[]  = {    
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_keyboard */
+
+#ifdef HAVE_USBSTACK
+static const struct button_mapping button_context_usb_hid[] = {
+    LAST_ITEM_IN_LIST
+}; /* button_context_usb_hid */
+#endif
+
+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;
+#ifdef HAVE_USBSTACK
+        case CONTEXT_USB_HID:
+            return button_context_usb_hid;
+#endif
+    }
+    return button_context_standard;
+}
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 7ad1261..942467a 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -41,7 +41,7 @@
 meizu_m6sp.c
 #elif defined(MEIZU_M3)
 meizu_m3.c
-#elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767)
+#elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767) || defined(ONDA_VX777)
 ondavx747.c
 #elif defined(CREATIVE_ZVx)
 creativezvm.c
diff --git a/docs/CREDITS b/docs/CREDITS
index 4989f67..14a3df6 100644
--- a/docs/CREDITS
+++ b/docs/CREDITS
@@ -474,6 +474,7 @@
 Jeffrey Goode
 Raafat Akkad
 Michaël Burtin
+Davide Quarta
 
 The libmad team
 The wavpack team
diff --git a/firmware/SOURCES b/firmware/SOURCES
index bba9ef1..742a582 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1267,13 +1267,13 @@
 drivers/nand_id.c
 #endif /* CONFIG_CPU == JZ4732 */
 
-#if defined(ONDA_VX747) || defined(ONDA_VX747P)
+#if defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX777)
 target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
 target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
 target/mips/ingenic_jz47xx/onda_vx747/power-onda_vx747.c
 target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
 target/mips/ingenic_jz47xx/onda_vx747/speaker-onda_vx747.c
-#endif /* ONDA_VX747 || ONDA_VX747P */
+#endif /* ONDA_VX747 || ONDA_VX747P || ONDA_VX777 */
 
 #ifdef ONDA_VX767
 target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h
index 9a9defc..5625635 100644
--- a/firmware/export/config-ondavx747.h
+++ b/firmware/export/config-ondavx747.h
@@ -20,7 +20,7 @@
  ****************************************************************************/
 
 /*
- * This config file is for the Onda VX747(+)
+ * This config file is for the Onda VX747(+)/VX777
  */
 
 #define TARGET_TREE /* this target is using the target tree system */
@@ -29,8 +29,11 @@
 
 #ifdef ONDA_VX747P
 #define MODEL_NAME  "Onda VX747+"
-#define MODEL_NUMBER 44
+#define MODEL_NUMBER 54
 /* Define something for camera interface... */
+#elif defined(ONDA_VX777)
+#define MODEL_NAME  "Onda VX777"
+#define MODEL_NUMBER 61
 #else
 #define MODEL_NAME  "Onda VX747"
 #define MODEL_NUMBER 45
@@ -87,7 +90,11 @@
 /* Define this if your LCD can be enabled/disabled */
 #define HAVE_LCD_ENABLE
 
+#ifdef ONDA_VX777
+#define CONFIG_KEYPAD ONDAVX777_PAD
+#else
 #define CONFIG_KEYPAD ONDAVX747_PAD
+#endif
 #define HAVE_TOUCHSCREEN
 #define HAVE_BUTTON_DATA
 
diff --git a/firmware/export/config.h b/firmware/export/config.h
index e53e19a..5148096 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -110,6 +110,7 @@
 #define SANSA_FUZE_PAD     36
 #define LYRE_PROTO1_PAD    37
 #define SAMSUNG_YH_PAD     38
+#define ONDAVX777_PAD      39
 
 /* CONFIG_REMOTE_KEYPAD */
 #define H100_REMOTE 1
@@ -351,7 +352,7 @@
 #include "config-meizu-m6sp.h"
 #elif defined(MEIZU_M3)
 #include "config-meizu-m3.h"
-#elif defined(ONDA_VX747) || defined(ONDA_VX747P)
+#elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX777)
 #include "config-ondavx747.h"
 #elif defined(ONDA_VX767)
 #include "config-ondavx767.h"
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
index ebc2f21..24caac0 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -42,6 +42,8 @@
 #define BTN_HOLD     (1 << 22)  /* on REG_GPIO_PXPIN(2) */
 #define BTN_MENU     (1 << 20)
 #define BTN_VOL_UP   (1 << 19)
+#elif defined(ONDA_VX777)
+/* TODO */
 #else
 #error No buttons defined!
 #endif
@@ -123,7 +125,7 @@
 }
 
 void button_init_device(void)
-{   
+{
 #ifdef ONDA_VX747
     __gpio_as_input(32*3 + 29);
     __gpio_as_input(32*3 + 27);
@@ -146,6 +148,8 @@
             (~REG_GPIO_PXPIN(3)) & BTN_HOLD
 #elif defined(ONDA_VX747P)
             (~REG_GPIO_PXPIN(2)) & BTN_HOLD
+#elif defined(ONDA_VX777)
+            false /* TODO */
 #endif
             ? true : false
            );
@@ -153,13 +157,14 @@
 
 int button_read_device(int *data)
 {
-    int ret = 0, tmp;
+    int ret = 0;
 
     /* Filter button events out if HOLD button is pressed at firmware/ level */
     if(button_hold())
         return 0;
 
-    tmp = (~REG_GPIO_PXPIN(3)) & BTN_MASK;
+#ifndef ONDA_VX777
+    int tmp = (~REG_GPIO_PXPIN(3)) & BTN_MASK;
 
     if(tmp & BTN_VOL_DOWN)
         ret |= BUTTON_VOL_DOWN;
@@ -169,6 +174,7 @@
         ret |= BUTTON_MENU;
     if(tmp & BTN_OFF)
         ret |= BUTTON_POWER;
+#endif
 
     if(cur_touch != 0 && pen_down)
     {
@@ -176,9 +182,6 @@
         if( UNLIKELY(!is_backlight_on(true)) )
             *data = 0;
     }
-    
-    if(ret & (BUTTON_VOL_DOWN|BUTTON_VOL_UP))
-        touchscreen_set_mode( touchscreen_get_mode() == TOUCHSCREEN_BUTTON ? TOUCHSCREEN_POINT : TOUCHSCREEN_BUTTON);
 
     return ret;
 }
diff --git a/tools/configure b/tools/configure
index 50091a5..e90a884 100755
--- a/tools/configure
+++ b/tools/configure
@@ -774,6 +774,7 @@
  120) VX747               110) M6SL
  121) VX767               111) M6SP              ==Logik==
  122) VX747+              112) M3                80) DAX 1GB MP3/DAB
+ 123) VX777
 
  ==Samsung==              ==Tatung==             ==Lyre project==
  140) YH-820              150) Elio TPJ-1022     130) Lyre proto 1
@@ -2055,14 +2056,14 @@
     target_id=54
     modelname="ondavx747p"
     target="-DONDA_VX747P"
-    memory=16 #FIXME
+    memory=16
     mipselcc
-    tool="cp"
+    tool="$rootdir/tools/scramble -add=747p"
     bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
     bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
     output="rockbox.vx747p"
     appextra="recorder:gui"
-    plugins="" #FIXME
+    plugins="yes"
     swcodec="yes"
     toolset=$genericbitmaptools
     boottool="cp"
@@ -2073,6 +2074,28 @@
     t_model="onda_vx747"
     ;;
     
+    123|ondavx777)
+    target_id=61
+    modelname="ondavx777"
+    target="-DONDA_VX777"
+    memory=16
+    mipselcc
+    tool="$rootdir/tools/scramble -add=x777"
+    bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
+    bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
+    output="rockbox.vx777"
+    appextra="recorder:gui"
+    plugins="" #TODO
+    swcodec="yes"
+    toolset=$genericbitmaptools
+    boottool="cp"
+    bootoutput="rockboot.vx777"
+    # architecture, manufacturer and model for the target-tree build
+    t_cpu="mips"
+    t_manufacturer="ingenic_jz47xx"
+    t_model="onda_vx747"
+    ;;
+    
     130|lyre_proto1)
     target_id=56
     modelname="lyre_proto1"
diff --git a/tools/scramble.c b/tools/scramble.c
index 8bf8d3d..cabe15f 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -123,7 +123,8 @@
            "\t                   ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n"
            "\t                   tpj2, c200, e200, giga, gigs, m100, m500, d2,\n");
     printf("\t                   9200, 1630, ldax, m200, c100, clip, e2v2, m2v4,\n"
-           "\t                   fuze, c2v2, clv2, y820, y920, y925)\n");
+           "\t                   fuze, c2v2, clv2, y820, y920, y925, x747, 747p, \n"
+           "\t                   x777)\n");
     printf("\nNo option results in Archos standard player/recorder format.\n");
 
     exit(1);
@@ -300,6 +301,10 @@
             modelnum = 44;
         else if (!strcmp(&argv[1][5], "x747"))
             modelnum = 45;
+        else if (!strcmp(&argv[1][5], "747p"))
+            modelnum = 54;
+        else if (!strcmp(&argv[1][5], "x777"))
+            modelnum = 61;
         else if (!strcmp(&argv[1][5], "y820")) /* Samsung YH-820 */
             modelnum = 57;
         else if (!strcmp(&argv[1][5], "y920")) /* Samsung YH-920 */