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
72 /* converts an r_str() input to an active high, bits string : 000BAOSE */
77 #define PNL_POUTPA 0x20 /* direct input, active high */
78 #define PNL_PSELECD 0x10 /* direct input, active high */
81 #define PNL_PBIDIR 0x20 /* bi-directional ports */
82 /* high to read data in or-ed with data out */
113 #define NOT_SET -1
116 #define r_ctr(x) (parport_read_control((x)->port))
117 #define r_dtr(x) (parport_read_data((x)->port))
118 #define r_str(x) (parport_read_status((x)->port))
119 #define w_ctr(x, y) (parport_write_control((x)->port, (y)))
120 #define w_dtr(x, y) (parport_write_data((x)->port, (y)))
174 * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00>
199 /* lcd-specific variables */
397 /* Device single-open policy control */
427 "LCD type: 0=none, 1=compiled-in, 2=old, 3=serial ks0074, 4=hantronix, 5=nexcom");
457 * (negative) if the signal is negated. -MAXINT is used to indicate that the
466 "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)");
471 "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)");
476 "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)");
481 "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)");
486 "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)");
491 "# of the // port pin connected to LCD backlight, with polarity (-17..17)");
493 /* Deprecated module parameters - consider not using them anymore */
565 {"a-p-e-", "Down\n", "Down\n", ""},
566 {"a-p-E-", "Ret\n", "Ret\n", ""},
567 {"a-P-E-", "Esc\n", "Esc\n", ""},
568 {"a-P-e-", "Up\n", "Up\n", ""},
618 * Converts a parallel port pin (from -25 to 25) to data and control ports
620 * unconnected if it's on pin 0 or an invalid pin (<-25 or >25).
642 pin = -pin; in pin_to_bits()
648 case PIN_STROBE: /* strobe, inverted */ in pin_to_bits()
652 case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */ in pin_to_bits()
653 d_bit = 1 << (pin - 2); in pin_to_bits()
688 * the data bit is set on D0, and the clock on STROBE. in lcd_send_serial()
689 * LCD reads D0 on STROBE's rising edge. in lcd_send_serial()
702 set_bit(LCD_BIT_CL, bits); /* CLK high */ in lcd_send_serial()
704 udelay(1); /* maintain the strobe during 1 us */ in lcd_send_serial()
753 udelay(20); /* maintain the data during 20 us before the strobe */ in lcd_write_cmd_p8()
760 udelay(40); /* maintain the strobe during 40 us */ in lcd_write_cmd_p8()
775 udelay(20); /* maintain the data during 20 us before the strobe */ in lcd_write_data_p8()
782 udelay(40); /* maintain the strobe during 40 us */ in lcd_write_data_p8()
844 hdc->hd44780 = &lcd; in lcd_init()
845 charlcd->drvdata = hdc; in lcd_init()
848 * Init lcd struct with load-time values to preserve exact in lcd_init()
851 charlcd->height = lcd_height; in lcd_init()
852 charlcd->width = lcd_width; in lcd_init()
853 hdc->bwidth = lcd_bwidth; in lcd_init()
854 hdc->hwidth = lcd_hwidth; in lcd_init()
864 charlcd->width = 40; in lcd_init()
865 hdc->bwidth = 40; in lcd_init()
866 hdc->hwidth = 64; in lcd_init()
867 charlcd->height = 2; in lcd_init()
877 charlcd->width = 16; in lcd_init()
878 hdc->bwidth = 40; in lcd_init()
879 hdc->hwidth = 16; in lcd_init()
880 charlcd->height = 2; in lcd_init()
890 charlcd->width = 16; in lcd_init()
891 hdc->bwidth = 40; in lcd_init()
892 hdc->hwidth = 64; in lcd_init()
893 charlcd->height = 2; in lcd_init()
896 /* customer-defined */ in lcd_init()
902 /* parallel mode, 8 bits, hantronix-like */ in lcd_init()
909 charlcd->width = 16; in lcd_init()
910 hdc->bwidth = 40; in lcd_init()
911 hdc->hwidth = 64; in lcd_init()
912 charlcd->height = 2; in lcd_init()
918 charlcd->height = lcd_height; in lcd_init()
920 charlcd->width = lcd_width; in lcd_init()
922 hdc->bwidth = lcd_bwidth; in lcd_init()
924 hdc->hwidth = lcd_hwidth; in lcd_init()
943 if (charlcd->width <= 0) in lcd_init()
944 charlcd->width = DEFAULT_LCD_WIDTH; in lcd_init()
945 if (hdc->bwidth <= 0) in lcd_init()
946 hdc->bwidth = DEFAULT_LCD_BWIDTH; in lcd_init()
947 if (hdc->hwidth <= 0) in lcd_init()
948 hdc->hwidth = DEFAULT_LCD_HWIDTH; in lcd_init()
949 if (charlcd->height <= 0) in lcd_init()
950 charlcd->height = DEFAULT_LCD_HEIGHT; in lcd_init()
953 charlcd->ops = &charlcd_ops; in lcd_init()
954 hdc->write_data = lcd_write_data_s; in lcd_init()
955 hdc->write_cmd = lcd_write_cmd_s; in lcd_init()
963 charlcd->ops = &charlcd_ops; in lcd_init()
964 hdc->write_data = lcd_write_data_p8; in lcd_init()
965 hdc->write_cmd = lcd_write_cmd_p8; in lcd_init()
974 charlcd->ops = &charlcd_ops; in lcd_init()
975 hdc->write_data = lcd_write_data_tilcd; in lcd_init()
976 hdc->write_cmd = lcd_write_cmd_tilcd; in lcd_init()
999 charlcd->char_conv = lcd_char_conv_ks0074; in lcd_init()
1001 charlcd->char_conv = NULL; in lcd_init()
1031 if (file->f_flags & O_NONBLOCK) in keypad_read()
1032 return -EAGAIN; in keypad_read()
1036 return -EINTR; in keypad_read()
1039 for (; count-- > 0 && (keypad_buflen > 0); in keypad_read()
1040 ++i, ++tmp, --keypad_buflen) { in keypad_read()
1046 return tmp - buf; in keypad_read()
1053 ret = -EBUSY; in keypad_open()
1057 ret = -EPERM; in keypad_open()
1058 if (file->f_mode & FMODE_WRITE) /* device is read-only */ in keypad_open()
1091 while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) { in keypad_send_key()
1137 /* grounded inputs are signals 40-44 */ in phys_scan_contacts()
1171 * transitions from single-key to multiple-key, but in input_state_high()
1172 * doesn't take into account the contacts polarity. in input_state_high()
1184 * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release. in input_state_high()
1186 if (((phys_prev & input->mask) == input->value) && in input_state_high()
1187 ((phys_curr & input->mask) > input->value)) { in input_state_high()
1188 input->state = INPUT_ST_LOW; /* invalidate */ in input_state_high()
1193 if ((phys_curr & input->mask) == input->value) { in input_state_high()
1194 if ((input->type == INPUT_TYPE_STD) && in input_state_high()
1195 (input->high_timer == 0)) { in input_state_high()
1196 input->high_timer++; in input_state_high()
1197 if (input->u.std.press_fct) in input_state_high()
1198 input->u.std.press_fct(input->u.std.press_data); in input_state_high()
1199 } else if (input->type == INPUT_TYPE_KBD) { in input_state_high()
1203 if (input->high_timer == 0) { in input_state_high()
1204 char *press_str = input->u.kbd.press_str; in input_state_high()
1207 int s = sizeof(input->u.kbd.press_str); in input_state_high()
1213 if (input->u.kbd.repeat_str[0]) { in input_state_high()
1214 char *repeat_str = input->u.kbd.repeat_str; in input_state_high()
1216 if (input->high_timer >= KEYPAD_REP_START) { in input_state_high()
1217 int s = sizeof(input->u.kbd.repeat_str); in input_state_high()
1219 input->high_timer -= KEYPAD_REP_DELAY; in input_state_high()
1226 if (input->high_timer < 255) in input_state_high()
1227 input->high_timer++; in input_state_high()
1233 input->state = INPUT_ST_FALLING; in input_state_high()
1234 input->fall_timer = 0; in input_state_high()
1243 if (((phys_prev & input->mask) == input->value) && in input_state_falling()
1244 ((phys_curr & input->mask) > input->value)) { in input_state_falling()
1245 input->state = INPUT_ST_LOW; /* invalidate */ in input_state_falling()
1250 if ((phys_curr & input->mask) == input->value) { in input_state_falling()
1251 if (input->type == INPUT_TYPE_KBD) { in input_state_falling()
1255 if (input->u.kbd.repeat_str[0]) { in input_state_falling()
1256 char *repeat_str = input->u.kbd.repeat_str; in input_state_falling()
1258 if (input->high_timer >= KEYPAD_REP_START) { in input_state_falling()
1259 int s = sizeof(input->u.kbd.repeat_str); in input_state_falling()
1261 input->high_timer -= KEYPAD_REP_DELAY; in input_state_falling()
1268 if (input->high_timer < 255) in input_state_falling()
1269 input->high_timer++; in input_state_falling()
1271 input->state = INPUT_ST_HIGH; in input_state_falling()
1272 } else if (input->fall_timer >= input->fall_time) { in input_state_falling()
1274 if (input->type == INPUT_TYPE_STD) { in input_state_falling()
1275 void (*release_fct)(int) = input->u.std.release_fct; in input_state_falling()
1278 release_fct(input->u.std.release_data); in input_state_falling()
1279 } else if (input->type == INPUT_TYPE_KBD) { in input_state_falling()
1280 char *release_str = input->u.kbd.release_str; in input_state_falling()
1283 int s = sizeof(input->u.kbd.release_str); in input_state_falling()
1289 input->state = INPUT_ST_LOW; in input_state_falling()
1291 input->fall_timer++; in input_state_falling()
1303 switch (input->state) { in panel_process_inputs()
1305 if ((phys_curr & input->mask) != input->value) in panel_process_inputs()
1311 * eg: AB -(release B)-> A -(release A)-> 0 : in panel_process_inputs()
1314 if ((phys_prev & input->mask) == input->value) in panel_process_inputs()
1316 input->rise_timer = 0; in panel_process_inputs()
1317 input->state = INPUT_ST_RISING; in panel_process_inputs()
1320 if ((phys_curr & input->mask) != input->value) { in panel_process_inputs()
1321 input->state = INPUT_ST_LOW; in panel_process_inputs()
1324 if (input->rise_timer < input->rise_time) { in panel_process_inputs()
1326 input->rise_timer++; in panel_process_inputs()
1329 input->high_timer = 0; in panel_process_inputs()
1330 input->state = INPUT_ST_HIGH; in panel_process_inputs()
1372 /* converts a name of the form "({BbAaPpSsEe}{01234567-})*" to a series of bits.
1373 * if <omask> or <imask> are non-null, they will be or'ed with the bits
1396 in = idx - sigtab; in input_name2mask()
1403 out = *name - '0'; in input_name2mask()
1405 } else if (*name == '-') { in input_name2mask()
1441 if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i, in panel_bind_key()
1447 key->type = INPUT_TYPE_KBD; in panel_bind_key()
1448 key->state = INPUT_ST_LOW; in panel_bind_key()
1449 key->rise_time = 1; in panel_bind_key()
1450 key->fall_time = 1; in panel_bind_key()
1452 strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str)); in panel_bind_key()
1453 strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str)); in panel_bind_key()
1454 strncpy(key->u.kbd.release_str, release, in panel_bind_key()
1455 sizeof(key->u.kbd.release_str)); in panel_bind_key()
1456 list_add(&key->list, &logical_inputs); in panel_bind_key()
1480 if (!input_name2mask(name, &callback->mask, &callback->value,
1484 callback->type = INPUT_TYPE_STD;
1485 callback->state = INPUT_ST_LOW;
1486 callback->rise_time = 1;
1487 callback->fall_time = 1;
1488 callback->u.std.press_fct = press_fct;
1489 callback->u.std.press_data = press_data;
1490 callback->u.std.release_fct = release_fct;
1491 callback->u.std.release_data = release_data;
1492 list_add(&callback->list, &logical_inputs);
1525 if (port->number != parport) in panel_attach()
1529 pr_err("%s: port->number=%d parport=%d, already registered!\n", in panel_attach()
1530 __func__, port->number, parport); in panel_attach()
1540 pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n", in panel_attach()
1541 __func__, port->number, parport); in panel_attach()
1581 if (port->number != parport) in panel_detach()
1585 pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n", in panel_detach()
1586 __func__, port->number, parport); in panel_detach()
1600 kfree(lcd.charlcd->drvdata); in panel_detach()
1647 /* 8 bits, 2*16 hantronix-like, no keypad */ in panel_init_module()
1683 * Init lcd struct with load-time values to preserve exact in panel_init_module()
1714 return -ENODEV; in panel_init_module()
1725 parport, pprt->port->base); in panel_init_module()