Lines Matching +full:40 +full:- +full:bit

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
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 */
224 * Bit masks to convert LCD signals to parallel port outputs.
233 * one entry for each bit on the LCD
244 * each bit can be either connected to a DATA or CTRL port
301 #define DEFAULT_LCD_WIDTH 40
397 /* Device single-open policy control */
417 "4=16x2 nexcom; default=40x2, old kp");
427 "LCD type: 0=none, 1=compiled-in, 2=old, 3=serial ks0074, 4=hantronix, 5=nexcom");
437 static int lcd_bwidth = NOT_SET; /* internal buffer width (usually 40) */
439 MODULE_PARM_DESC(lcd_bwidth, "Internal LCD line width (40)");
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", ""},
579 unsigned int bit, state; in lcd_get_bits() local
581 for (bit = 0; bit < LCD_BITS; bit++) { in lcd_get_bits()
582 state = test_bit(bit, bits) ? BIT_SET : BIT_CLR; in lcd_get_bits()
583 *val &= lcd_bits[port][bit][BIT_MSK]; in lcd_get_bits()
584 *val |= lcd_bits[port][bit][state]; in lcd_get_bits()
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()
652 case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */ in pin_to_bits()
653 d_bit = 1 << (pin - 2); in pin_to_bits()
685 int bit; in lcd_send_serial() local
688 * the data bit is set on D0, and the clock on STROBE. in lcd_send_serial()
691 for (bit = 0; bit < 8; bit++) { in lcd_send_serial()
732 udelay(40); /* the shortest command takes at least 40 us */ in lcd_write_cmd_s()
743 udelay(40); /* the shortest data takes at least 40 us */ in lcd_write_data_s()
760 udelay(40); /* maintain the strobe during 40 us */ in lcd_write_cmd_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()
1100 * and puts the results in the bitfield "phys_read" (one bit per established
1111 int bit, bitval; in phys_scan_contacts() local
1125 /* will have a 1 for each bit set to gnd */ in phys_scan_contacts()
1137 /* grounded inputs are signals 40-44 */ in phys_scan_contacts()
1138 phys_read |= (__u64)gndmask << 40; in phys_scan_contacts()
1146 for (bit = 0; bit < 8; bit++) { in phys_scan_contacts()
1147 bitval = BIT(bit); in phys_scan_contacts()
1154 phys_read |= (__u64)bitmask << (5 * bit); in phys_scan_contacts()
1171 * transitions from single-key to multiple-key, but in input_state_high()
1180 * someone adds a bit, so this signal was a false 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
1389 int in, out, bit, neg; in input_name2mask() local
1396 in = idx - sigtab; in input_name2mask()
1399 im |= BIT(in); in input_name2mask()
1403 out = *name - '0'; in input_name2mask()
1404 om |= BIT(out); in input_name2mask()
1405 } else if (*name == '-') { in input_name2mask()
1408 return 0; /* unknown bit name */ in input_name2mask()
1411 bit = (out * 5) + in; in input_name2mask()
1413 m |= 1ULL << bit; in input_name2mask()
1415 v |= 1ULL << bit; 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 strtomem_pad(key->u.kbd.press_str, press, '\0'); in panel_bind_key()
1453 strtomem_pad(key->u.kbd.repeat_str, repeat, '\0'); in panel_bind_key()
1454 strtomem_pad(key->u.kbd.release_str, release, '\0'); in panel_bind_key()
1455 list_add(&key->list, &logical_inputs); in panel_bind_key()
1479 if (!input_name2mask(name, &callback->mask, &callback->value,
1483 callback->type = INPUT_TYPE_STD;
1484 callback->state = INPUT_ST_LOW;
1485 callback->rise_time = 1;
1486 callback->fall_time = 1;
1487 callback->u.std.press_fct = press_fct;
1488 callback->u.std.press_data = press_data;
1489 callback->u.std.release_fct = release_fct;
1490 callback->u.std.release_data = release_data;
1491 list_add(&callback->list, &logical_inputs);
1549 /* 8 bits, 2*16 hantronix-like, no keypad */ in panel_attach()
1559 /* 8 bits, 2*40, old keypad */ in panel_attach()
1585 * Init lcd struct with load-time values to preserve exact in panel_attach()
1619 if (port->number != parport) in panel_attach()
1623 pr_err("%s: port->number=%d parport=%d, already registered!\n", in panel_attach()
1624 __func__, port->number, parport); in panel_attach()
1634 pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n", in panel_attach()
1635 __func__, port->number, parport); in panel_attach()
1675 if (port->number != parport) in panel_detach()
1679 pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n", in panel_detach()
1680 __func__, port->number, parport); in panel_detach()
1694 kfree(lcd.charlcd->drvdata); in panel_detach()