Lines Matching +full:short +full:- +full:key +full:- +full:debounce
1 // SPDX-License-Identifier: GPL-2.0
30 #include "line-display.h"
140 uint8_t data = REG_DISPLAY_SETUP | REG_DISPLAY_SETUP_ON | priv->blink; in ht16k33_display_on()
142 return i2c_smbus_write_byte(priv->client, data); in ht16k33_display_on()
147 return i2c_smbus_write_byte(priv->client, REG_DISPLAY_SETUP); in ht16k33_display_off()
156 priv->blink = REG_DISPLAY_SETUP_BLINK_OFF; in ht16k33_brightness_set()
164 return i2c_smbus_write_byte(priv->client, in ht16k33_brightness_set()
165 REG_BRIGHTNESS | (brightness - 1)); in ht16k33_brightness_set()
198 err = i2c_smbus_write_byte(priv->client, in ht16k33_blink_set()
204 priv->blink = blink; in ht16k33_blink_set()
211 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_fb_queue()
213 schedule_delayed_work(&priv->work, HZ / fbdev->refresh_rate); in ht16k33_fb_queue()
222 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_fb_update()
225 int len, pos = 0, first = -1; in ht16k33_fb_update()
227 p1 = fbdev->cache; in ht16k33_fb_update()
228 p2 = fbdev->buffer; in ht16k33_fb_update()
232 if (*(p1++) - *(p2++)) in ht16k33_fb_update()
241 len = HT16K33_FB_SIZE - first; in ht16k33_fb_update()
242 p1 = fbdev->cache + HT16K33_FB_SIZE - 1; in ht16k33_fb_update()
243 p2 = fbdev->buffer + HT16K33_FB_SIZE - 1; in ht16k33_fb_update()
247 if (*(p1--) - *(p2--)) in ht16k33_fb_update()
249 len--; in ht16k33_fb_update()
252 p1 = fbdev->cache + first; in ht16k33_fb_update()
253 p2 = fbdev->buffer + first; in ht16k33_fb_update()
254 if (!i2c_smbus_write_i2c_block_data(priv->client, first, len, p2)) in ht16k33_fb_update()
268 err = i2c_smbus_write_block_data(priv->client, 0, sizeof(data), data); in ht16k33_initialize()
274 err = i2c_smbus_write_byte(priv->client, byte); in ht16k33_initialize()
280 if (priv->client->irq > 0) in ht16k33_initialize()
282 return i2c_smbus_write_byte(priv->client, byte); in ht16k33_initialize()
308 struct ht16k33_priv *priv = info->par; in ht16k33_mmap()
309 struct page *pages = virt_to_page(priv->fbdev.buffer); in ht16k33_mmap()
311 vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); in ht16k33_mmap()
326 * Returns true if a key is pressed.
330 const unsigned short *keycodes = keypad->dev->keycode; in ht16k33_keypad_scan()
338 rc = i2c_smbus_read_i2c_block_data(keypad->client, 0x40, in ht16k33_keypad_scan()
341 dev_err(&keypad->client->dev, in ht16k33_keypad_scan()
342 "Failed to read key data, rc=%d\n", rc); in ht16k33_keypad_scan()
346 for (col = 0; col < keypad->cols; col++) { in ht16k33_keypad_scan()
350 bits_changed = keypad->last_key_state[col] ^ new_state[col]; in ht16k33_keypad_scan()
353 code = MATRIX_SCAN_CODE(row, col, keypad->row_shift); in ht16k33_keypad_scan()
354 input_event(keypad->dev, EV_MSC, MSC_SCAN, code); in ht16k33_keypad_scan()
355 input_report_key(keypad->dev, keycodes[code], in ht16k33_keypad_scan()
359 input_sync(keypad->dev); in ht16k33_keypad_scan()
360 memcpy(keypad->last_key_state, new_state, sizeof(u16) * keypad->cols); in ht16k33_keypad_scan()
370 wait_event_timeout(keypad->wait, keypad->stopped, in ht16k33_keypad_irq_thread()
371 msecs_to_jiffies(keypad->debounce_ms)); in ht16k33_keypad_irq_thread()
372 if (keypad->stopped) in ht16k33_keypad_irq_thread()
383 keypad->stopped = false; in ht16k33_keypad_start()
385 enable_irq(keypad->client->irq); in ht16k33_keypad_start()
394 keypad->stopped = true; in ht16k33_keypad_stop()
396 wake_up(&keypad->wait); in ht16k33_keypad_stop()
397 disable_irq(keypad->client->irq); in ht16k33_keypad_stop()
403 struct linedisp_map *map = priv->linedisp.map; in ht16k33_seg7_update()
404 char *s = priv->linedisp.buf; in ht16k33_seg7_update()
407 buf[0] = map_to_seg7(&map->map.seg7, *s++); in ht16k33_seg7_update()
409 buf[2] = map_to_seg7(&map->map.seg7, *s++); in ht16k33_seg7_update()
413 buf[6] = map_to_seg7(&map->map.seg7, *s++); in ht16k33_seg7_update()
415 buf[8] = map_to_seg7(&map->map.seg7, *s++); in ht16k33_seg7_update()
417 i2c_smbus_write_i2c_block_data(priv->client, 0, ARRAY_SIZE(buf), buf); in ht16k33_seg7_update()
423 struct linedisp_map *map = priv->linedisp.map; in ht16k33_seg14_update()
424 char *s = priv->linedisp.buf; in ht16k33_seg14_update()
427 put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 0); in ht16k33_seg14_update()
428 put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 2); in ht16k33_seg14_update()
429 put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 4); in ht16k33_seg14_update()
430 put_unaligned_le16(map_to_seg14(&map->map.seg14, *s++), buf + 6); in ht16k33_seg14_update()
432 i2c_smbus_write_i2c_block_data(priv->client, 0, ARRAY_SIZE(buf), buf); in ht16k33_seg14_update()
439 switch (priv->type) { in ht16k33_linedisp_get_map_type()
441 INIT_DELAYED_WORK(&priv->work, ht16k33_seg7_update); in ht16k33_linedisp_get_map_type()
445 INIT_DELAYED_WORK(&priv->work, ht16k33_seg14_update); in ht16k33_linedisp_get_map_type()
449 return -EINVAL; in ht16k33_linedisp_get_map_type()
457 schedule_delayed_work(&priv->work, 0); in ht16k33_linedisp_update()
479 led->brightness_set_blocking = ht16k33_brightness_set_blocking; in ht16k33_led_probe()
480 led->blink_set = ht16k33_blink_set; in ht16k33_led_probe()
481 led->flags = LED_CORE_SUSPENDRESUME; in ht16k33_led_probe()
482 led->brightness = brightness; in ht16k33_led_probe()
483 led->max_brightness = MAX_BRIGHTNESS; in ht16k33_led_probe()
496 struct device *dev = &client->dev; in ht16k33_keypad_probe()
501 keypad->client = client; in ht16k33_keypad_probe()
502 init_waitqueue_head(&keypad->wait); in ht16k33_keypad_probe()
504 keypad->dev = devm_input_allocate_device(dev); in ht16k33_keypad_probe()
505 if (!keypad->dev) in ht16k33_keypad_probe()
506 return -ENOMEM; in ht16k33_keypad_probe()
508 input_set_drvdata(keypad->dev, keypad); in ht16k33_keypad_probe()
510 keypad->dev->name = DRIVER_NAME"-keypad"; in ht16k33_keypad_probe()
511 keypad->dev->id.bustype = BUS_I2C; in ht16k33_keypad_probe()
512 keypad->dev->open = ht16k33_keypad_start; in ht16k33_keypad_probe()
513 keypad->dev->close = ht16k33_keypad_stop; in ht16k33_keypad_probe()
515 if (!device_property_read_bool(dev, "linux,no-autorepeat")) in ht16k33_keypad_probe()
516 __set_bit(EV_REP, keypad->dev->evbit); in ht16k33_keypad_probe()
518 err = device_property_read_u32(dev, "debounce-delay-ms", in ht16k33_keypad_probe()
519 &keypad->debounce_ms); in ht16k33_keypad_probe()
521 dev_err(dev, "key debounce delay not specified\n"); in ht16k33_keypad_probe()
532 return -ERANGE; in ht16k33_keypad_probe()
535 keypad->rows = rows; in ht16k33_keypad_probe()
536 keypad->cols = cols; in ht16k33_keypad_probe()
537 keypad->row_shift = get_count_order(cols); in ht16k33_keypad_probe()
540 keypad->dev); in ht16k33_keypad_probe()
546 err = devm_request_threaded_irq(dev, client->irq, NULL, in ht16k33_keypad_probe()
551 dev_err(dev, "irq request failed %d, error %d\n", client->irq, in ht16k33_keypad_probe()
556 ht16k33_keypad_stop(keypad->dev); in ht16k33_keypad_probe()
558 return input_register_device(keypad->dev); in ht16k33_keypad_probe()
564 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_fbdev_probe()
568 if (priv->led.dev) { in ht16k33_fbdev_probe()
580 bl = devm_backlight_device_register(dev, DRIVER_NAME"-bl", dev, in ht16k33_fbdev_probe()
588 bl->props.brightness = brightness; in ht16k33_fbdev_probe()
594 fbdev->buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL); in ht16k33_fbdev_probe()
595 if (!fbdev->buffer) in ht16k33_fbdev_probe()
596 return -ENOMEM; in ht16k33_fbdev_probe()
598 fbdev->cache = devm_kmalloc(dev, HT16K33_FB_SIZE, GFP_KERNEL); in ht16k33_fbdev_probe()
599 if (!fbdev->cache) { in ht16k33_fbdev_probe()
600 err = -ENOMEM; in ht16k33_fbdev_probe()
604 fbdev->info = framebuffer_alloc(0, dev); in ht16k33_fbdev_probe()
605 if (!fbdev->info) { in ht16k33_fbdev_probe()
606 err = -ENOMEM; in ht16k33_fbdev_probe()
610 err = device_property_read_u32(dev, "refresh-rate-hz", in ht16k33_fbdev_probe()
611 &fbdev->refresh_rate); in ht16k33_fbdev_probe()
616 fb_bl_default_curve(fbdev->info, 0, MIN_BRIGHTNESS, MAX_BRIGHTNESS); in ht16k33_fbdev_probe()
618 INIT_DELAYED_WORK(&priv->work, ht16k33_fb_update); in ht16k33_fbdev_probe()
619 fbdev->info->fbops = &ht16k33_fb_ops; in ht16k33_fbdev_probe()
620 fbdev->info->flags |= FBINFO_VIRTFB; in ht16k33_fbdev_probe()
621 fbdev->info->screen_buffer = fbdev->buffer; in ht16k33_fbdev_probe()
622 fbdev->info->screen_size = HT16K33_FB_SIZE; in ht16k33_fbdev_probe()
623 fbdev->info->fix = ht16k33_fb_fix; in ht16k33_fbdev_probe()
624 fbdev->info->var = ht16k33_fb_var; in ht16k33_fbdev_probe()
625 fbdev->info->bl_dev = bl; in ht16k33_fbdev_probe()
626 fbdev->info->pseudo_palette = NULL; in ht16k33_fbdev_probe()
627 fbdev->info->par = priv; in ht16k33_fbdev_probe()
629 err = register_framebuffer(fbdev->info); in ht16k33_fbdev_probe()
637 framebuffer_release(fbdev->info); in ht16k33_fbdev_probe()
639 free_page((unsigned long) fbdev->buffer); in ht16k33_fbdev_probe()
647 struct linedisp *linedisp = &priv->linedisp; in ht16k33_seg_probe()
659 struct device *dev = &client->dev; in ht16k33_probe()
665 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in ht16k33_probe()
667 return -EIO; in ht16k33_probe()
672 return -ENOMEM; in ht16k33_probe()
674 priv->client = client; in ht16k33_probe()
675 id = i2c_of_match_device(dev->driver->of_match_table, client); in ht16k33_probe()
677 priv->type = (uintptr_t)id->data; in ht16k33_probe()
684 err = device_property_read_u32(dev, "default-brightness-level", in ht16k33_probe()
696 err = ht16k33_led_probe(dev, &priv->led, dft_brightness); in ht16k33_probe()
701 if (client->irq > 0) { in ht16k33_probe()
702 err = ht16k33_keypad_probe(client, &priv->keypad); in ht16k33_probe()
707 switch (priv->type) { in ht16k33_probe()
720 return -EINVAL; in ht16k33_probe()
728 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_remove()
730 cancel_delayed_work_sync(&priv->work); in ht16k33_remove()
732 switch (priv->type) { in ht16k33_remove()
734 unregister_framebuffer(fbdev->info); in ht16k33_remove()
735 framebuffer_release(fbdev->info); in ht16k33_remove()
736 free_page((unsigned long)fbdev->buffer); in ht16k33_remove()
741 linedisp_unregister(&priv->linedisp); in ht16k33_remove()
757 /* 0.56" 4-Digit 7-Segment FeatherWing Display (Red) */
763 /* Generic, assumed Dot-Matrix Display */