Lines Matching +full:display +full:- +full:rows
1 // SPDX-License-Identifier: GPL-2.0
54 uint32_t rows; member
108 return i2c_smbus_write_byte(priv->client, data); in ht16k33_display_on()
113 return i2c_smbus_write_byte(priv->client, REG_DISPLAY_SETUP); in ht16k33_display_off()
118 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_fb_queue()
120 schedule_delayed_work(&fbdev->work, HZ / fbdev->refresh_rate); in ht16k33_fb_queue()
124 * This gets the fb data from cache and copies it to ht16k33 display RAM
134 int len, pos = 0, first = -1; in ht16k33_fb_update()
136 p1 = fbdev->cache; in ht16k33_fb_update()
137 p2 = fbdev->buffer; in ht16k33_fb_update()
141 if (*(p1++) - *(p2++)) in ht16k33_fb_update()
150 len = HT16K33_FB_SIZE - first; in ht16k33_fb_update()
151 p1 = fbdev->cache + HT16K33_FB_SIZE - 1; in ht16k33_fb_update()
152 p2 = fbdev->buffer + HT16K33_FB_SIZE - 1; in ht16k33_fb_update()
156 if (*(p1--) - *(p2--)) in ht16k33_fb_update()
158 len--; in ht16k33_fb_update()
161 p1 = fbdev->cache + first; in ht16k33_fb_update()
162 p2 = fbdev->buffer + first; in ht16k33_fb_update()
163 if (!i2c_smbus_write_i2c_block_data(priv->client, first, len, p2)) in ht16k33_fb_update()
177 err = i2c_smbus_write_block_data(priv->client, 0, sizeof(data), data); in ht16k33_initialize()
183 err = i2c_smbus_write_byte(priv->client, byte); in ht16k33_initialize()
189 if (priv->client->irq > 0) in ht16k33_initialize()
191 return i2c_smbus_write_byte(priv->client, byte); in ht16k33_initialize()
196 int brightness = bl->props.brightness; in ht16k33_bl_update_status()
199 if (bl->props.power != FB_BLANK_UNBLANK || in ht16k33_bl_update_status()
200 bl->props.fb_blank != FB_BLANK_UNBLANK || in ht16k33_bl_update_status()
201 bl->props.state & BL_CORE_FBBLANK || brightness == 0) { in ht16k33_bl_update_status()
206 return i2c_smbus_write_byte(priv->client, in ht16k33_bl_update_status()
207 REG_BRIGHTNESS | (brightness - 1)); in ht16k33_bl_update_status()
214 return (fi == NULL) || (fi->par == priv); in ht16k33_bl_check_fb()
233 struct ht16k33_priv *priv = info->par; in ht16k33_mmap()
234 struct page *pages = virt_to_page(priv->fbdev.buffer); in ht16k33_mmap()
256 const unsigned short *keycodes = keypad->dev->keycode; in ht16k33_keypad_scan()
264 rc = i2c_smbus_read_i2c_block_data(keypad->client, 0x40, in ht16k33_keypad_scan()
267 dev_err(&keypad->client->dev, in ht16k33_keypad_scan()
272 for (col = 0; col < keypad->cols; col++) { in ht16k33_keypad_scan()
276 bits_changed = keypad->last_key_state[col] ^ new_state[col]; in ht16k33_keypad_scan()
279 code = MATRIX_SCAN_CODE(row, col, keypad->row_shift); in ht16k33_keypad_scan()
280 input_event(keypad->dev, EV_MSC, MSC_SCAN, code); in ht16k33_keypad_scan()
281 input_report_key(keypad->dev, keycodes[code], in ht16k33_keypad_scan()
285 input_sync(keypad->dev); in ht16k33_keypad_scan()
286 memcpy(keypad->last_key_state, new_state, sizeof(u16) * keypad->cols); in ht16k33_keypad_scan()
296 wait_event_timeout(keypad->wait, keypad->stopped, in ht16k33_keypad_irq_thread()
297 msecs_to_jiffies(keypad->debounce_ms)); in ht16k33_keypad_irq_thread()
298 if (keypad->stopped) in ht16k33_keypad_irq_thread()
309 keypad->stopped = false; in ht16k33_keypad_start()
311 enable_irq(keypad->client->irq); in ht16k33_keypad_start()
320 keypad->stopped = true; in ht16k33_keypad_stop()
322 wake_up(&keypad->wait); in ht16k33_keypad_stop()
323 disable_irq(keypad->client->irq); in ht16k33_keypad_stop()
329 struct device_node *node = client->dev.of_node; in ht16k33_keypad_probe()
330 u32 rows = HT16K33_MATRIX_KEYPAD_MAX_ROWS; in ht16k33_keypad_probe() local
334 keypad->client = client; in ht16k33_keypad_probe()
335 init_waitqueue_head(&keypad->wait); in ht16k33_keypad_probe()
337 keypad->dev = devm_input_allocate_device(&client->dev); in ht16k33_keypad_probe()
338 if (!keypad->dev) in ht16k33_keypad_probe()
339 return -ENOMEM; in ht16k33_keypad_probe()
341 input_set_drvdata(keypad->dev, keypad); in ht16k33_keypad_probe()
343 keypad->dev->name = DRIVER_NAME"-keypad"; in ht16k33_keypad_probe()
344 keypad->dev->id.bustype = BUS_I2C; in ht16k33_keypad_probe()
345 keypad->dev->open = ht16k33_keypad_start; in ht16k33_keypad_probe()
346 keypad->dev->close = ht16k33_keypad_stop; in ht16k33_keypad_probe()
348 if (!of_get_property(node, "linux,no-autorepeat", NULL)) in ht16k33_keypad_probe()
349 __set_bit(EV_REP, keypad->dev->evbit); in ht16k33_keypad_probe()
351 err = of_property_read_u32(node, "debounce-delay-ms", in ht16k33_keypad_probe()
352 &keypad->debounce_ms); in ht16k33_keypad_probe()
354 dev_err(&client->dev, "key debounce delay not specified\n"); in ht16k33_keypad_probe()
358 err = matrix_keypad_parse_of_params(&client->dev, &rows, &cols); in ht16k33_keypad_probe()
361 if (rows > HT16K33_MATRIX_KEYPAD_MAX_ROWS || in ht16k33_keypad_probe()
363 dev_err(&client->dev, "%u rows or %u cols out of range in DT\n", in ht16k33_keypad_probe()
364 rows, cols); in ht16k33_keypad_probe()
365 return -ERANGE; in ht16k33_keypad_probe()
368 keypad->rows = rows; in ht16k33_keypad_probe()
369 keypad->cols = cols; in ht16k33_keypad_probe()
370 keypad->row_shift = get_count_order(cols); in ht16k33_keypad_probe()
372 err = matrix_keypad_build_keymap(NULL, NULL, rows, cols, NULL, in ht16k33_keypad_probe()
373 keypad->dev); in ht16k33_keypad_probe()
375 dev_err(&client->dev, "failed to build keymap\n"); in ht16k33_keypad_probe()
379 err = devm_request_threaded_irq(&client->dev, client->irq, in ht16k33_keypad_probe()
384 dev_err(&client->dev, "irq request failed %d, error %d\n", in ht16k33_keypad_probe()
385 client->irq, err); in ht16k33_keypad_probe()
389 ht16k33_keypad_stop(keypad->dev); in ht16k33_keypad_probe()
391 err = input_register_device(keypad->dev); in ht16k33_keypad_probe()
407 struct device_node *node = client->dev.of_node; in ht16k33_probe()
409 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in ht16k33_probe()
410 dev_err(&client->dev, "i2c_check_functionality error\n"); in ht16k33_probe()
411 return -EIO; in ht16k33_probe()
414 if (client->irq <= 0) { in ht16k33_probe()
415 dev_err(&client->dev, "No IRQ specified\n"); in ht16k33_probe()
416 return -EINVAL; in ht16k33_probe()
419 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); in ht16k33_probe()
421 return -ENOMEM; in ht16k33_probe()
423 priv->client = client; in ht16k33_probe()
425 fbdev = &priv->fbdev; in ht16k33_probe()
436 bl = devm_backlight_device_register(&client->dev, DRIVER_NAME"-bl", in ht16k33_probe()
437 &client->dev, priv, in ht16k33_probe()
440 dev_err(&client->dev, "failed to register backlight\n"); in ht16k33_probe()
444 err = of_property_read_u32(node, "default-brightness-level", in ht16k33_probe()
449 dev_warn(&client->dev, in ht16k33_probe()
455 bl->props.brightness = dft_brightness; in ht16k33_probe()
460 fbdev->buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL); in ht16k33_probe()
461 if (!fbdev->buffer) in ht16k33_probe()
462 return -ENOMEM; in ht16k33_probe()
464 fbdev->cache = devm_kmalloc(&client->dev, HT16K33_FB_SIZE, GFP_KERNEL); in ht16k33_probe()
465 if (!fbdev->cache) { in ht16k33_probe()
466 err = -ENOMEM; in ht16k33_probe()
470 fbdev->info = framebuffer_alloc(0, &client->dev); in ht16k33_probe()
471 if (!fbdev->info) { in ht16k33_probe()
472 err = -ENOMEM; in ht16k33_probe()
476 err = of_property_read_u32(node, "refresh-rate-hz", in ht16k33_probe()
477 &fbdev->refresh_rate); in ht16k33_probe()
479 dev_err(&client->dev, "refresh rate not specified\n"); in ht16k33_probe()
482 fb_bl_default_curve(fbdev->info, 0, MIN_BRIGHTNESS, MAX_BRIGHTNESS); in ht16k33_probe()
484 INIT_DELAYED_WORK(&fbdev->work, ht16k33_fb_update); in ht16k33_probe()
485 fbdev->info->fbops = &ht16k33_fb_ops; in ht16k33_probe()
486 fbdev->info->screen_base = (char __iomem *) fbdev->buffer; in ht16k33_probe()
487 fbdev->info->screen_size = HT16K33_FB_SIZE; in ht16k33_probe()
488 fbdev->info->fix = ht16k33_fb_fix; in ht16k33_probe()
489 fbdev->info->var = ht16k33_fb_var; in ht16k33_probe()
490 fbdev->info->bl_dev = bl; in ht16k33_probe()
491 fbdev->info->pseudo_palette = NULL; in ht16k33_probe()
492 fbdev->info->flags = FBINFO_FLAG_DEFAULT; in ht16k33_probe()
493 fbdev->info->par = priv; in ht16k33_probe()
495 err = register_framebuffer(fbdev->info); in ht16k33_probe()
499 err = ht16k33_keypad_probe(client, &priv->keypad); in ht16k33_probe()
507 unregister_framebuffer(fbdev->info); in ht16k33_probe()
509 framebuffer_release(fbdev->info); in ht16k33_probe()
511 free_page((unsigned long) fbdev->buffer); in ht16k33_probe()
519 struct ht16k33_fbdev *fbdev = &priv->fbdev; in ht16k33_remove()
521 cancel_delayed_work_sync(&fbdev->work); in ht16k33_remove()
522 unregister_framebuffer(fbdev->info); in ht16k33_remove()
523 framebuffer_release(fbdev->info); in ht16k33_remove()
524 free_page((unsigned long) fbdev->buffer); in ht16k33_remove()