• Home
  • Raw
  • Download

Lines Matching +full:display +full:- +full:rows

1 // SPDX-License-Identifier: GPL-2.0
29 #include "line-display.h"
72 uint32_t rows; member
146 memcpy(buf, &priv->seg.map, priv->seg.map_size); in map_seg_show()
147 return priv->seg.map_size; in map_seg_show()
155 if (cnt != priv->seg.map_size) in map_seg_store()
156 return -EINVAL; in map_seg_store()
158 memcpy(&priv->seg.map, buf, cnt); in map_seg_store()
167 uint8_t data = REG_DISPLAY_SETUP | REG_DISPLAY_SETUP_ON | priv->blink; in ht16k33_display_on()
169 return i2c_smbus_write_byte(priv->client, data); in ht16k33_display_on()
174 return i2c_smbus_write_byte(priv->client, REG_DISPLAY_SETUP); in ht16k33_display_off()
183 priv->blink = REG_DISPLAY_SETUP_BLINK_OFF; in ht16k33_brightness_set()
191 return i2c_smbus_write_byte(priv->client, in ht16k33_brightness_set()
192 REG_BRIGHTNESS | (brightness - 1)); in ht16k33_brightness_set()
227 err = i2c_smbus_write_byte(priv->client, in ht16k33_blink_set()
233 priv->blink = blink; in ht16k33_blink_set()
240 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_fb_queue()
242 schedule_delayed_work(&priv->work, HZ / fbdev->refresh_rate); in ht16k33_fb_queue()
246 * This gets the fb data from cache and copies it to ht16k33 display RAM
252 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_fb_update()
255 int len, pos = 0, first = -1; in ht16k33_fb_update()
257 p1 = fbdev->cache; in ht16k33_fb_update()
258 p2 = fbdev->buffer; in ht16k33_fb_update()
262 if (*(p1++) - *(p2++)) in ht16k33_fb_update()
271 len = HT16K33_FB_SIZE - first; in ht16k33_fb_update()
272 p1 = fbdev->cache + HT16K33_FB_SIZE - 1; in ht16k33_fb_update()
273 p2 = fbdev->buffer + HT16K33_FB_SIZE - 1; in ht16k33_fb_update()
277 if (*(p1--) - *(p2--)) in ht16k33_fb_update()
279 len--; in ht16k33_fb_update()
282 p1 = fbdev->cache + first; in ht16k33_fb_update()
283 p2 = fbdev->buffer + first; in ht16k33_fb_update()
284 if (!i2c_smbus_write_i2c_block_data(priv->client, first, len, p2)) in ht16k33_fb_update()
298 err = i2c_smbus_write_block_data(priv->client, 0, sizeof(data), data); in ht16k33_initialize()
304 err = i2c_smbus_write_byte(priv->client, byte); in ht16k33_initialize()
310 if (priv->client->irq > 0) in ht16k33_initialize()
312 return i2c_smbus_write_byte(priv->client, byte); in ht16k33_initialize()
317 int brightness = bl->props.brightness; in ht16k33_bl_update_status()
320 if (bl->props.power != FB_BLANK_UNBLANK || in ht16k33_bl_update_status()
321 bl->props.fb_blank != FB_BLANK_UNBLANK || in ht16k33_bl_update_status()
322 bl->props.state & BL_CORE_FBBLANK) in ht16k33_bl_update_status()
332 return (fi == NULL) || (fi->par == priv); in ht16k33_bl_check_fb()
351 struct ht16k33_priv *priv = info->par; in ht16k33_mmap()
352 struct page *pages = virt_to_page(priv->fbdev.buffer); in ht16k33_mmap()
374 const unsigned short *keycodes = keypad->dev->keycode; in ht16k33_keypad_scan()
382 rc = i2c_smbus_read_i2c_block_data(keypad->client, 0x40, in ht16k33_keypad_scan()
385 dev_err(&keypad->client->dev, in ht16k33_keypad_scan()
390 for (col = 0; col < keypad->cols; col++) { in ht16k33_keypad_scan()
394 bits_changed = keypad->last_key_state[col] ^ new_state[col]; in ht16k33_keypad_scan()
397 code = MATRIX_SCAN_CODE(row, col, keypad->row_shift); in ht16k33_keypad_scan()
398 input_event(keypad->dev, EV_MSC, MSC_SCAN, code); in ht16k33_keypad_scan()
399 input_report_key(keypad->dev, keycodes[code], in ht16k33_keypad_scan()
403 input_sync(keypad->dev); in ht16k33_keypad_scan()
404 memcpy(keypad->last_key_state, new_state, sizeof(u16) * keypad->cols); in ht16k33_keypad_scan()
414 wait_event_timeout(keypad->wait, keypad->stopped, in ht16k33_keypad_irq_thread()
415 msecs_to_jiffies(keypad->debounce_ms)); in ht16k33_keypad_irq_thread()
416 if (keypad->stopped) in ht16k33_keypad_irq_thread()
427 keypad->stopped = false; in ht16k33_keypad_start()
429 enable_irq(keypad->client->irq); in ht16k33_keypad_start()
438 keypad->stopped = true; in ht16k33_keypad_stop()
440 wake_up(&keypad->wait); in ht16k33_keypad_stop()
441 disable_irq(keypad->client->irq); in ht16k33_keypad_stop()
449 schedule_delayed_work(&priv->work, 0); in ht16k33_linedisp_update()
456 struct ht16k33_seg *seg = &priv->seg; in ht16k33_seg7_update()
457 char *s = seg->curr; in ht16k33_seg7_update()
460 buf[0] = map_to_seg7(&seg->map.seg7, *s++); in ht16k33_seg7_update()
462 buf[2] = map_to_seg7(&seg->map.seg7, *s++); in ht16k33_seg7_update()
466 buf[6] = map_to_seg7(&seg->map.seg7, *s++); in ht16k33_seg7_update()
468 buf[8] = map_to_seg7(&seg->map.seg7, *s++); in ht16k33_seg7_update()
470 i2c_smbus_write_i2c_block_data(priv->client, 0, ARRAY_SIZE(buf), buf); in ht16k33_seg7_update()
477 struct ht16k33_seg *seg = &priv->seg; in ht16k33_seg14_update()
478 char *s = seg->curr; in ht16k33_seg14_update()
481 put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf); in ht16k33_seg14_update()
482 put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf + 2); in ht16k33_seg14_update()
483 put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf + 4); in ht16k33_seg14_update()
484 put_unaligned_le16(map_to_seg14(&seg->map.seg14, *s++), buf + 6); in ht16k33_seg14_update()
486 i2c_smbus_write_i2c_block_data(priv->client, 0, ARRAY_SIZE(buf), buf); in ht16k33_seg14_update()
503 led->brightness_set_blocking = ht16k33_brightness_set_blocking; in ht16k33_led_probe()
504 led->blink_set = ht16k33_blink_set; in ht16k33_led_probe()
505 led->flags = LED_CORE_SUSPENDRESUME; in ht16k33_led_probe()
506 led->brightness = brightness; in ht16k33_led_probe()
507 led->max_brightness = MAX_BRIGHTNESS; in ht16k33_led_probe()
519 struct device *dev = &client->dev; in ht16k33_keypad_probe()
520 u32 rows = HT16K33_MATRIX_KEYPAD_MAX_ROWS; in ht16k33_keypad_probe() local
524 keypad->client = client; in ht16k33_keypad_probe()
525 init_waitqueue_head(&keypad->wait); in ht16k33_keypad_probe()
527 keypad->dev = devm_input_allocate_device(dev); in ht16k33_keypad_probe()
528 if (!keypad->dev) in ht16k33_keypad_probe()
529 return -ENOMEM; in ht16k33_keypad_probe()
531 input_set_drvdata(keypad->dev, keypad); in ht16k33_keypad_probe()
533 keypad->dev->name = DRIVER_NAME"-keypad"; in ht16k33_keypad_probe()
534 keypad->dev->id.bustype = BUS_I2C; in ht16k33_keypad_probe()
535 keypad->dev->open = ht16k33_keypad_start; in ht16k33_keypad_probe()
536 keypad->dev->close = ht16k33_keypad_stop; in ht16k33_keypad_probe()
538 if (!device_property_read_bool(dev, "linux,no-autorepeat")) in ht16k33_keypad_probe()
539 __set_bit(EV_REP, keypad->dev->evbit); in ht16k33_keypad_probe()
541 err = device_property_read_u32(dev, "debounce-delay-ms", in ht16k33_keypad_probe()
542 &keypad->debounce_ms); in ht16k33_keypad_probe()
548 err = matrix_keypad_parse_properties(dev, &rows, &cols); in ht16k33_keypad_probe()
551 if (rows > HT16K33_MATRIX_KEYPAD_MAX_ROWS || in ht16k33_keypad_probe()
553 dev_err(dev, "%u rows or %u cols out of range in DT\n", rows, in ht16k33_keypad_probe()
555 return -ERANGE; in ht16k33_keypad_probe()
558 keypad->rows = rows; in ht16k33_keypad_probe()
559 keypad->cols = cols; in ht16k33_keypad_probe()
560 keypad->row_shift = get_count_order(cols); in ht16k33_keypad_probe()
562 err = matrix_keypad_build_keymap(NULL, NULL, rows, cols, NULL, in ht16k33_keypad_probe()
563 keypad->dev); in ht16k33_keypad_probe()
569 err = devm_request_threaded_irq(dev, client->irq, NULL, in ht16k33_keypad_probe()
574 dev_err(dev, "irq request failed %d, error %d\n", client->irq, in ht16k33_keypad_probe()
579 ht16k33_keypad_stop(keypad->dev); in ht16k33_keypad_probe()
581 return input_register_device(keypad->dev); in ht16k33_keypad_probe()
587 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_fbdev_probe()
591 if (priv->led.dev) { in ht16k33_fbdev_probe()
603 bl = devm_backlight_device_register(dev, DRIVER_NAME"-bl", dev, in ht16k33_fbdev_probe()
611 bl->props.brightness = brightness; in ht16k33_fbdev_probe()
617 fbdev->buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL); in ht16k33_fbdev_probe()
618 if (!fbdev->buffer) in ht16k33_fbdev_probe()
619 return -ENOMEM; in ht16k33_fbdev_probe()
621 fbdev->cache = devm_kmalloc(dev, HT16K33_FB_SIZE, GFP_KERNEL); in ht16k33_fbdev_probe()
622 if (!fbdev->cache) { in ht16k33_fbdev_probe()
623 err = -ENOMEM; in ht16k33_fbdev_probe()
627 fbdev->info = framebuffer_alloc(0, dev); in ht16k33_fbdev_probe()
628 if (!fbdev->info) { in ht16k33_fbdev_probe()
629 err = -ENOMEM; in ht16k33_fbdev_probe()
633 err = device_property_read_u32(dev, "refresh-rate-hz", in ht16k33_fbdev_probe()
634 &fbdev->refresh_rate); in ht16k33_fbdev_probe()
639 fb_bl_default_curve(fbdev->info, 0, MIN_BRIGHTNESS, MAX_BRIGHTNESS); in ht16k33_fbdev_probe()
641 INIT_DELAYED_WORK(&priv->work, ht16k33_fb_update); in ht16k33_fbdev_probe()
642 fbdev->info->fbops = &ht16k33_fb_ops; in ht16k33_fbdev_probe()
643 fbdev->info->screen_buffer = fbdev->buffer; in ht16k33_fbdev_probe()
644 fbdev->info->screen_size = HT16K33_FB_SIZE; in ht16k33_fbdev_probe()
645 fbdev->info->fix = ht16k33_fb_fix; in ht16k33_fbdev_probe()
646 fbdev->info->var = ht16k33_fb_var; in ht16k33_fbdev_probe()
647 fbdev->info->bl_dev = bl; in ht16k33_fbdev_probe()
648 fbdev->info->pseudo_palette = NULL; in ht16k33_fbdev_probe()
649 fbdev->info->par = priv; in ht16k33_fbdev_probe()
651 err = register_framebuffer(fbdev->info); in ht16k33_fbdev_probe()
659 framebuffer_release(fbdev->info); in ht16k33_fbdev_probe()
661 free_page((unsigned long) fbdev->buffer); in ht16k33_fbdev_probe()
669 struct ht16k33_seg *seg = &priv->seg; in ht16k33_seg_probe()
676 switch (priv->type) { in ht16k33_seg_probe()
679 err = -EINVAL; in ht16k33_seg_probe()
683 INIT_DELAYED_WORK(&priv->work, ht16k33_seg7_update); in ht16k33_seg_probe()
684 seg->map.seg7 = initial_map_seg7; in ht16k33_seg_probe()
685 seg->map_size = sizeof(seg->map.seg7); in ht16k33_seg_probe()
690 INIT_DELAYED_WORK(&priv->work, ht16k33_seg14_update); in ht16k33_seg_probe()
691 seg->map.seg14 = initial_map_seg14; in ht16k33_seg_probe()
692 seg->map_size = sizeof(seg->map.seg14); in ht16k33_seg_probe()
699 err = linedisp_register(&seg->linedisp, dev, 4, seg->curr, in ht16k33_seg_probe()
714 struct device *dev = &client->dev; in ht16k33_probe()
720 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in ht16k33_probe()
722 return -EIO; in ht16k33_probe()
727 return -ENOMEM; in ht16k33_probe()
729 priv->client = client; in ht16k33_probe()
730 id = i2c_of_match_device(dev->driver->of_match_table, client); in ht16k33_probe()
732 priv->type = (uintptr_t)id->data; in ht16k33_probe()
739 err = device_property_read_u32(dev, "default-brightness-level", in ht16k33_probe()
751 err = ht16k33_led_probe(dev, &priv->led, dft_brightness); in ht16k33_probe()
756 if (client->irq > 0) { in ht16k33_probe()
757 err = ht16k33_keypad_probe(client, &priv->keypad); in ht16k33_probe()
762 switch (priv->type) { in ht16k33_probe()
764 /* Frame Buffer Display */ in ht16k33_probe()
770 /* Segment Display */ in ht16k33_probe()
780 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_remove()
782 cancel_delayed_work_sync(&priv->work); in ht16k33_remove()
784 switch (priv->type) { in ht16k33_remove()
786 unregister_framebuffer(fbdev->info); in ht16k33_remove()
787 framebuffer_release(fbdev->info); in ht16k33_remove()
788 free_page((unsigned long)fbdev->buffer); in ht16k33_remove()
793 linedisp_unregister(&priv->seg.linedisp); in ht16k33_remove()
794 device_remove_file(&client->dev, &dev_attr_map_seg7); in ht16k33_remove()
795 device_remove_file(&client->dev, &dev_attr_map_seg14); in ht16k33_remove()
808 /* 0.56" 4-Digit 7-Segment FeatherWing Display (Red) */
811 /* 0.54" Quad Alphanumeric FeatherWing Display (Red) */
814 /* Generic, assumed Dot-Matrix Display */