* (C) Copyright 2004 Intracom S.A.
* Pantelis Antoniou <panto@intracom.gr>
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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 program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier: GPL-2.0+
*/
/*
#include <version.h>
#include <linux/types.h>
-#include <devices.h>
+#include <stdio_dev.h>
#include <sed156x.h>
#define ROWS 24
#define COLS 80
-#define REFRESH_HZ (CFG_HZ/50) /* refresh every 20ms */
-#define BLINK_HZ (CFG_HZ/2) /* cursor blink every 500ms */
+#define REFRESH_HZ (CONFIG_SYS_HZ/50) /* refresh every 20ms */
+#define BLINK_HZ (CONFIG_SYS_HZ/2) /* cursor blink every 500ms */
/*************************************************************************************************/
-#define DISPLAY_BACKLIT_PORT ((volatile immap_t *)CFG_IMMR)->im_ioport.iop_pcdat
-#define DISPLAY_BACKLIT_MASK 0x0010
+#define DISPLAY_BACKLIT_PORT ((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat
+#define DISPLAY_BACKLIT_MASK 0x0010
/*************************************************************************************************/
-#define KP_STABLE_HZ (CFG_HZ/100) /* stable for 10ms */
-#define KP_REPEAT_DELAY_HZ (CFG_HZ/4) /* delay before repeat 250ms */
-#define KP_REPEAT_HZ (CFG_HZ/20) /* repeat every 50ms */
-#define KP_FORCE_DELAY_HZ (CFG_HZ/2) /* key was force pressed */
-#define KP_IDLE_DELAY_HZ (CFG_HZ/2) /* key was released and idle */
+#define KP_STABLE_HZ (CONFIG_SYS_HZ/100) /* stable for 10ms */
+#define KP_REPEAT_DELAY_HZ (CONFIG_SYS_HZ/4) /* delay before repeat 250ms */
+#define KP_REPEAT_HZ (CONFIG_SYS_HZ/20) /* repeat every 50ms */
+#define KP_FORCE_DELAY_HZ (CONFIG_SYS_HZ/2) /* key was force pressed */
+#define KP_IDLE_DELAY_HZ (CONFIG_SYS_HZ/2) /* key was released and idle */
#if CONFIG_NETPHONE_VERSION == 1
-#define KP_SPI_RXD_PORT (((volatile immap_t *)CFG_IMMR)->im_ioport.iop_pcdat)
-#define KP_SPI_RXD_MASK 0x0008
+#define KP_SPI_RXD_PORT (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat)
+#define KP_SPI_RXD_MASK 0x0008
-#define KP_SPI_TXD_PORT (((volatile immap_t *)CFG_IMMR)->im_ioport.iop_pcdat)
-#define KP_SPI_TXD_MASK 0x0004
+#define KP_SPI_TXD_PORT (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat)
+#define KP_SPI_TXD_MASK 0x0004
-#define KP_SPI_CLK_PORT (((volatile immap_t *)CFG_IMMR)->im_ioport.iop_pcdat)
-#define KP_SPI_CLK_MASK 0x0001
+#define KP_SPI_CLK_PORT (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat)
+#define KP_SPI_CLK_MASK 0x0001
#elif CONFIG_NETPHONE_VERSION == 2
-#define KP_SPI_RXD_PORT (((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbdat)
-#define KP_SPI_RXD_MASK 0x00000008
+#define KP_SPI_RXD_PORT (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat)
+#define KP_SPI_RXD_MASK 0x00000008
-#define KP_SPI_TXD_PORT (((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbdat)
-#define KP_SPI_TXD_MASK 0x00000004
+#define KP_SPI_TXD_PORT (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat)
+#define KP_SPI_TXD_MASK 0x00000004
-#define KP_SPI_CLK_PORT (((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbdat)
-#define KP_SPI_CLK_MASK 0x00000002
+#define KP_SPI_CLK_PORT (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat)
+#define KP_SPI_CLK_MASK 0x00000002
#endif
-#define KP_CS_PORT (((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pedat)
+#define KP_CS_PORT (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat)
#define KP_CS_MASK 0x00000010
#define KP_SPI_RXD() (KP_SPI_RXD_PORT & KP_SPI_RXD_MASK)
KP_CS_PORT &= ~KP_CS_MASK; \
} while(0)
-#define KP_ROWS 7
-#define KP_COLS 4
+#define KP_ROWS 7
+#define KP_COLS 4
#define KP_ROWS_MASK ((1 << KP_ROWS) - 1)
#define KP_COLS_MASK ((1 << KP_COLS) - 1)
#define SCAN 0
#define SCAN_FILTER 1
#define SCAN_COL 2
-#define SCAN_COL_FILTER 3
+#define SCAN_COL_FILTER 3
#define PRESSED 4
-#define KP_F1 0 /* leftmost dot (tab) */
-#define KP_F2 1 /* middle left dot */
-#define KP_F3 2 /* up */
-#define KP_F4 3 /* middle right dot */
-#define KP_F5 4 /* rightmost dot */
-#define KP_F6 5 /* C */
-#define KP_F7 6 /* left */
-#define KP_F8 7 /* down */
-#define KP_F9 8 /* right */
-#define KP_F10 9 /* enter */
-#define KP_F11 10 /* R */
-#define KP_F12 11 /* save */
-#define KP_F13 12 /* redial */
-#define KP_F14 13 /* speaker */
-#define KP_F15 14 /* unused */
-#define KP_F16 15 /* unused */
-
-#define KP_RELEASE -1 /* key depressed */
-#define KP_FORCE -2 /* key was pressed for more than force hz */
-#define KP_IDLE -3 /* key was released and idle */
+#define KP_F1 0 /* leftmost dot (tab) */
+#define KP_F2 1 /* middle left dot */
+#define KP_F3 2 /* up */
+#define KP_F4 3 /* middle right dot */
+#define KP_F5 4 /* rightmost dot */
+#define KP_F6 5 /* C */
+#define KP_F7 6 /* left */
+#define KP_F8 7 /* down */
+#define KP_F9 8 /* right */
+#define KP_F10 9 /* enter */
+#define KP_F11 10 /* R */
+#define KP_F12 11 /* save */
+#define KP_F13 12 /* redial */
+#define KP_F14 13 /* speaker */
+#define KP_F15 14 /* unused */
+#define KP_F16 15 /* unused */
+
+#define KP_RELEASE -1 /* key depressed */
+#define KP_FORCE -2 /* key was pressed for more than force hz */
+#define KP_IDLE -3 /* key was released and idle */
#define KP_1 '1'
#define KP_2 '2'
#define KP_8 '8'
#define KP_9 '9'
#define KP_0 '0'
-#define KP_STAR '*'
-#define KP_HASH '#'
+#define KP_STAR '*'
+#define KP_HASH '#'
/*************************************************************************************************/
static int refresh_time;
static int blink_time;
static char last_fast_punct;
-static int last_tab_indicator = -1;
/*************************************************************************************************/
/* per mode character select (for 2-9) */
static const char *digits_sel[2][8] = {
{ /* small */
- "abc2", /* 2 */
+ "abc2", /* 2 */
"def3", /* 3 */
"ghi4", /* 4 */
"jkl5", /* 5 */
"pqrs7", /* 7 */
"tuv8", /* 8 */
"wxyz9", /* 9 */
- }, { /* capital */
- "ABC2", /* 2 */
+ }, { /* capital */
+ "ABC2", /* 2 */
"DEF3", /* 3 */
"GHI4", /* 4 */
"JKL5", /* 5 */
refresh_time = REFRESH_HZ;
blink_time = BLINK_HZ;
- tab_indicator = 1;
-
memset(vty_buf, ' ', sizeof(vty_buf));
memset(last_visible_buf, ' ', sizeof(last_visible_buf));
sed156x_init();
width = sed156x_text_width;
height = sed156x_text_height - 1;
+
+ tab_indicator = 0;
}
/*****************************************************************************/
int drv_phone_init(void)
{
- device_t console_dev;
- char *penv;
-
- /*
- * Force console i/o to serial ?
- */
- if ((penv = getenv("console")) != NULL && strcmp(penv, "serial") == 0)
- return 0;
+ struct stdio_dev console_dev;
console_init();
console_dev.tstc = phone_tstc; /* 'tstc' function */
console_dev.getc = phone_getc; /* 'getc' function */
- if (device_register(&console_dev) == 0)
+ if (stdio_register(&console_dev) == 0)
return 1;
return 0;
if (input_mode != last_input_mode)
sed156x_output_at(sed156x_text_width - 3, sed156x_text_height - 1, input_mode_txt[input_mode], 3);
- if (tab_indicator != last_tab_indicator)
+ if (tab_indicator == 0) {
sed156x_output_at(0, sed156x_text_height - 1, "\\t", 2);
+ tab_indicator = 1;
+ }
if (fast_punct != last_fast_punct)
sed156x_output_at(4, sed156x_text_height - 1, &fast_punct, 1);
last_input_mode = input_mode;
last_fast_punct = fast_punct;
- last_tab_indicator = tab_indicator;
}
/* ensure visibility; the trick is to minimize the screen movement */
/* move to easier to use vars */
- x1 = disp_col; y1 = disp_row;
+ x1 = disp_col; y1 = disp_row;
x2 = x1 + width; y2 = y1 + height;
- a1 = col; b1 = row;
- a2 = a1 + dx; b2 = b1 + dy;
+ a1 = col; b1 = row;
+ a2 = a1 + dx; b2 = b1 + dy;
/* printf("(%d,%d) - (%d,%d) : (%d, %d) - (%d, %d)\n", x1, y1, x2, y2, a1, b1, a2, b2); */
blink_time = BLINK_HZ;
switch (c) {
- case 13: /* ignore */
+ case '\a': /* ignore bell */
+ case '\r': /* ignore carriage return */
break;
case '\n': /* next line */
ensure_visible(curs_col, curs_row, 1, 1);
break;
- case 9: /* tab 8 */
+ case 9: /* tab 8 */
/* move to tab */
i = curs_col;
i |= 0x0008;
#if CONFIG_NETPHONE_VERSION == 1
col_mask = kp_data_transfer(val) & 0x0F;
#elif CONFIG_NETPHONE_VERSION == 2
- col_mask = ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pedat & 0x0f;
+ col_mask = ((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat & 0x0f;
/* XXX FUCK FUCK FUCK FUCK FUCK!!!! */
col_mask = ((col_mask & 0x08) >> 3) | /* BKBR1 */
((col_mask & 0x04) << 1) | /* BKBR2 */
/**************************************************************************************/
static const int kp_scancodes[KP_ROWS * KP_COLS] = {
- KP_F1, KP_F3, KP_F4, KP_F2,
- KP_F6, KP_F8, KP_F9, KP_F7,
- KP_1, KP_3, KP_F11, KP_2,
- KP_4, KP_6, KP_F12, KP_5,
- KP_7, KP_9, KP_F13, KP_8,
+ KP_F1, KP_F3, KP_F4, KP_F2,
+ KP_F6, KP_F8, KP_F9, KP_F7,
+ KP_1, KP_3, KP_F11, KP_2,
+ KP_4, KP_6, KP_F12, KP_5,
+ KP_7, KP_9, KP_F13, KP_8,
KP_STAR, KP_HASH, KP_F14, KP_0,
- KP_F5, KP_F15, KP_F16, KP_F10,
+ KP_F5, KP_F15, KP_F16, KP_F10,
};
static const int kp_repeats[KP_ROWS * KP_COLS] = {
break;
}
}
+
+/**************************************************************************************/
+
+int drv_phone_is_idle(void)
+{
+ return kp_state == SCAN;
+}