Lines Matching +full:strobe +full:- +full:polarity +full:- +full:high

1 // SPDX-License-Identifier: GPL-2.0+
4 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
5 * Copyright (C) 2016-2017 Glider bvba
10 * The LCD module may either be an HD44780-like 8-bit parallel LCD, or a 1-bit
15 * data output pins or to the ground. The combinations have to be hard-coded
22 * - the initialization/deinitialization process is very dirty and should
26 * - document 24 keys keyboard (3 rows of 8 cols, 32 diodes + 2 inputs)
27 * - make the LCD a part of a virtual screen of Vx*Vy
28 * - make the inputs list smp-safe
29 * - change the keyboard to a double mapping : signals -> key_id -> values
71 /* converts an r_str() input to an active high, bits string : 000BAOSE */
76 #define PNL_POUTPA 0x20 /* direct input, active high */
77 #define PNL_PSELECD 0x10 /* direct input, active high */
80 #define PNL_PBIDIR 0x20 /* bi-directional ports */
81 /* high to read data in or-ed with data out */
112 #define NOT_SET -1
115 #define r_ctr(x) (parport_read_control((x)->port))
116 #define r_dtr(x) (parport_read_data((x)->port))
117 #define r_str(x) (parport_read_status((x)->port))
118 #define w_ctr(x, y) (parport_write_control((x)->port, (y)))
119 #define w_dtr(x, y) (parport_write_data((x)->port, (y)))
173 * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00>
198 /* lcd-specific variables */
398 /* Device single-open policy control */
428 "LCD type: 0=none, 1=compiled-in, 2=old, 3=serial ks0074, 4=hantronix, 5=nexcom");
458 * (negative) if the signal is negated. -MAXINT is used to indicate that the
467 "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)");
472 "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)");
477 "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)");
482 "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)");
487 "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)");
492 "# of the // port pin connected to LCD backlight, with polarity (-17..17)");
494 /* Deprecated module parameters - consider not using them anymore */
566 {"a-p-e-", "Down\n", "Down\n", ""},
567 {"a-p-E-", "Ret\n", "Ret\n", ""},
568 {"a-P-E-", "Esc\n", "Esc\n", ""},
569 {"a-P-e-", "Up\n", "Up\n", ""},
619 * Converts a parallel port pin (from -25 to 25) to data and control ports
621 * unconnected if it's on pin 0 or an invalid pin (<-25 or >25).
643 pin = -pin; in pin_to_bits()
649 case PIN_STROBE: /* strobe, inverted */ in pin_to_bits()
653 case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */ in pin_to_bits()
654 d_bit = 1 << (pin - 2); in pin_to_bits()
689 * the data bit is set on D0, and the clock on STROBE. in lcd_send_serial()
690 * LCD reads D0 on STROBE's rising edge. in lcd_send_serial()
703 set_bit(LCD_BIT_CL, bits); /* CLK high */ in lcd_send_serial()
705 udelay(1); /* maintain the strobe during 1 us */ in lcd_send_serial()
754 udelay(20); /* maintain the data during 20 us before the strobe */ in lcd_write_cmd_p8()
761 udelay(40); /* maintain the strobe during 40 us */ in lcd_write_cmd_p8()
776 udelay(20); /* maintain the data during 20 us before the strobe */ in lcd_write_data_p8()
783 udelay(40); /* maintain the strobe during 40 us */ in lcd_write_data_p8()
818 for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { in lcd_clear_fast_s()
834 for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { in lcd_clear_fast_p8()
838 /* maintain the data during 20 us before the strobe */ in lcd_clear_fast_p8()
846 /* maintain the strobe during 40 us */ in lcd_clear_fast_p8()
864 for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { in lcd_clear_fast_tilcd()
904 * Init lcd struct with load-time values to preserve exact in lcd_init()
907 charlcd->height = lcd_height; in lcd_init()
908 charlcd->width = lcd_width; in lcd_init()
909 charlcd->bwidth = lcd_bwidth; in lcd_init()
910 charlcd->hwidth = lcd_hwidth; in lcd_init()
920 charlcd->width = 40; in lcd_init()
921 charlcd->bwidth = 40; in lcd_init()
922 charlcd->hwidth = 64; in lcd_init()
923 charlcd->height = 2; in lcd_init()
933 charlcd->width = 16; in lcd_init()
934 charlcd->bwidth = 40; in lcd_init()
935 charlcd->hwidth = 16; in lcd_init()
936 charlcd->height = 2; in lcd_init()
946 charlcd->width = 16; in lcd_init()
947 charlcd->bwidth = 40; in lcd_init()
948 charlcd->hwidth = 64; in lcd_init()
949 charlcd->height = 2; in lcd_init()
952 /* customer-defined */ in lcd_init()
958 /* parallel mode, 8 bits, hantronix-like */ in lcd_init()
965 charlcd->width = 16; in lcd_init()
966 charlcd->bwidth = 40; in lcd_init()
967 charlcd->hwidth = 64; in lcd_init()
968 charlcd->height = 2; in lcd_init()
974 charlcd->height = lcd_height; in lcd_init()
976 charlcd->width = lcd_width; in lcd_init()
978 charlcd->bwidth = lcd_bwidth; in lcd_init()
980 charlcd->hwidth = lcd_hwidth; in lcd_init()
999 if (charlcd->width <= 0) in lcd_init()
1000 charlcd->width = DEFAULT_LCD_WIDTH; in lcd_init()
1001 if (charlcd->bwidth <= 0) in lcd_init()
1002 charlcd->bwidth = DEFAULT_LCD_BWIDTH; in lcd_init()
1003 if (charlcd->hwidth <= 0) in lcd_init()
1004 charlcd->hwidth = DEFAULT_LCD_HWIDTH; in lcd_init()
1005 if (charlcd->height <= 0) in lcd_init()
1006 charlcd->height = DEFAULT_LCD_HEIGHT; in lcd_init()
1009 charlcd->ops = &charlcd_serial_ops; in lcd_init()
1017 charlcd->ops = &charlcd_parallel_ops; in lcd_init()
1026 charlcd->ops = &charlcd_tilcd_ops; in lcd_init()
1049 charlcd->char_conv = lcd_char_conv_ks0074; in lcd_init()
1051 charlcd->char_conv = NULL; in lcd_init()
1081 if (file->f_flags & O_NONBLOCK) in keypad_read()
1082 return -EAGAIN; in keypad_read()
1086 return -EINTR; in keypad_read()
1089 for (; count-- > 0 && (keypad_buflen > 0); in keypad_read()
1090 ++i, ++tmp, --keypad_buflen) { in keypad_read()
1096 return tmp - buf; in keypad_read()
1103 ret = -EBUSY; in keypad_open()
1107 ret = -EPERM; in keypad_open()
1108 if (file->f_mode & FMODE_WRITE) /* device is read-only */ in keypad_open()
1141 while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) { in keypad_send_key()
1187 /* grounded inputs are signals 40-44 */ in phys_scan_contacts()
1221 * transitions from single-key to multiple-key, but in input_state_high()
1222 * doesn't take into account the contacts polarity. in input_state_high()
1234 * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release. in input_state_high()
1236 if (((phys_prev & input->mask) == input->value) && in input_state_high()
1237 ((phys_curr & input->mask) > input->value)) { in input_state_high()
1238 input->state = INPUT_ST_LOW; /* invalidate */ in input_state_high()
1243 if ((phys_curr & input->mask) == input->value) { in input_state_high()
1244 if ((input->type == INPUT_TYPE_STD) && in input_state_high()
1245 (input->high_timer == 0)) { in input_state_high()
1246 input->high_timer++; in input_state_high()
1247 if (input->u.std.press_fct) in input_state_high()
1248 input->u.std.press_fct(input->u.std.press_data); in input_state_high()
1249 } else if (input->type == INPUT_TYPE_KBD) { in input_state_high()
1253 if (input->high_timer == 0) { in input_state_high()
1254 char *press_str = input->u.kbd.press_str; in input_state_high()
1257 int s = sizeof(input->u.kbd.press_str); in input_state_high()
1263 if (input->u.kbd.repeat_str[0]) { in input_state_high()
1264 char *repeat_str = input->u.kbd.repeat_str; in input_state_high()
1266 if (input->high_timer >= KEYPAD_REP_START) { in input_state_high()
1267 int s = sizeof(input->u.kbd.repeat_str); in input_state_high()
1269 input->high_timer -= KEYPAD_REP_DELAY; in input_state_high()
1276 if (input->high_timer < 255) in input_state_high()
1277 input->high_timer++; in input_state_high()
1283 input->state = INPUT_ST_FALLING; in input_state_high()
1284 input->fall_timer = 0; in input_state_high()
1293 if (((phys_prev & input->mask) == input->value) && in input_state_falling()
1294 ((phys_curr & input->mask) > input->value)) { in input_state_falling()
1295 input->state = INPUT_ST_LOW; /* invalidate */ in input_state_falling()
1300 if ((phys_curr & input->mask) == input->value) { in input_state_falling()
1301 if (input->type == INPUT_TYPE_KBD) { in input_state_falling()
1305 if (input->u.kbd.repeat_str[0]) { in input_state_falling()
1306 char *repeat_str = input->u.kbd.repeat_str; in input_state_falling()
1308 if (input->high_timer >= KEYPAD_REP_START) { in input_state_falling()
1309 int s = sizeof(input->u.kbd.repeat_str); in input_state_falling()
1311 input->high_timer -= KEYPAD_REP_DELAY; in input_state_falling()
1318 if (input->high_timer < 255) in input_state_falling()
1319 input->high_timer++; in input_state_falling()
1321 input->state = INPUT_ST_HIGH; in input_state_falling()
1322 } else if (input->fall_timer >= input->fall_time) { in input_state_falling()
1324 if (input->type == INPUT_TYPE_STD) { in input_state_falling()
1325 void (*release_fct)(int) = input->u.std.release_fct; in input_state_falling()
1328 release_fct(input->u.std.release_data); in input_state_falling()
1329 } else if (input->type == INPUT_TYPE_KBD) { in input_state_falling()
1330 char *release_str = input->u.kbd.release_str; in input_state_falling()
1333 int s = sizeof(input->u.kbd.release_str); in input_state_falling()
1339 input->state = INPUT_ST_LOW; in input_state_falling()
1341 input->fall_timer++; in input_state_falling()
1353 switch (input->state) { in panel_process_inputs()
1355 if ((phys_curr & input->mask) != input->value) in panel_process_inputs()
1361 * eg: AB -(release B)-> A -(release A)-> 0 : in panel_process_inputs()
1364 if ((phys_prev & input->mask) == input->value) in panel_process_inputs()
1366 input->rise_timer = 0; in panel_process_inputs()
1367 input->state = INPUT_ST_RISING; in panel_process_inputs()
1370 if ((phys_curr & input->mask) != input->value) { in panel_process_inputs()
1371 input->state = INPUT_ST_LOW; in panel_process_inputs()
1374 if (input->rise_timer < input->rise_time) { in panel_process_inputs()
1376 input->rise_timer++; in panel_process_inputs()
1379 input->high_timer = 0; in panel_process_inputs()
1380 input->state = INPUT_ST_HIGH; in panel_process_inputs()
1422 /* converts a name of the form "({BbAaPpSsEe}{01234567-})*" to a series of bits.
1423 * if <omask> or <imask> are non-null, they will be or'ed with the bits
1446 in = idx - sigtab; in input_name2mask()
1453 out = *name - '0'; in input_name2mask()
1455 } else if (*name == '-') { in input_name2mask()
1491 if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i, in panel_bind_key()
1497 key->type = INPUT_TYPE_KBD; in panel_bind_key()
1498 key->state = INPUT_ST_LOW; in panel_bind_key()
1499 key->rise_time = 1; in panel_bind_key()
1500 key->fall_time = 1; in panel_bind_key()
1502 strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str)); in panel_bind_key()
1503 strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str)); in panel_bind_key()
1504 strncpy(key->u.kbd.release_str, release, in panel_bind_key()
1505 sizeof(key->u.kbd.release_str)); in panel_bind_key()
1506 list_add(&key->list, &logical_inputs); in panel_bind_key()
1530 if (!input_name2mask(name, &callback->mask, &callback->value,
1534 callback->type = INPUT_TYPE_STD;
1535 callback->state = INPUT_ST_LOW;
1536 callback->rise_time = 1;
1537 callback->fall_time = 1;
1538 callback->u.std.press_fct = press_fct;
1539 callback->u.std.press_data = press_data;
1540 callback->u.std.release_fct = release_fct;
1541 callback->u.std.release_data = release_data;
1542 list_add(&callback->list, &logical_inputs);
1575 if (port->number != parport) in panel_attach()
1579 pr_err("%s: port->number=%d parport=%d, already registered!\n", in panel_attach()
1580 __func__, port->number, parport); in panel_attach()
1590 pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n", in panel_attach()
1591 __func__, port->number, parport); in panel_attach()
1631 if (port->number != parport) in panel_detach()
1635 pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n", in panel_detach()
1636 __func__, port->number, parport); in panel_detach()
1696 /* 8 bits, 2*16 hantronix-like, no keypad */ in panel_init_module()
1732 * Init lcd struct with load-time values to preserve exact in panel_init_module()
1763 return -ENODEV; in panel_init_module()
1774 parport, pprt->port->base); in panel_init_module()
1792 * c-indent-level: 4
1793 * tab-width: 8