Lines Matching +full:auto +full:- +full:sleep +full:- +full:disabled
1 // SPDX-License-Identifier: GPL-2.0
7 * Based on the omapdrm-specific panel-sony-acx565akm driver
16 * - Update backlight support to use backlight_update_status() etc.
17 * - Use prepare/unprepare for the basic power on/off of the backligt
66 * Next value of jiffies when we can issue the next sleep in/out
88 x->tx_buf = &cmd; in acx565akm_transfer()
89 x->bits_per_word = 9; in acx565akm_transfer()
90 x->len = 2; in acx565akm_transfer()
98 x->bits_per_word = 10; in acx565akm_transfer()
105 x->tx_buf = wbuf; in acx565akm_transfer()
106 x->len = wlen; in acx565akm_transfer()
107 x->bits_per_word = 9; in acx565akm_transfer()
113 x->rx_buf = rbuf; in acx565akm_transfer()
114 x->len = rlen; in acx565akm_transfer()
118 ret = spi_sync(lcd->spi, &m); in acx565akm_transfer()
120 dev_dbg(&lcd->spi->dev, "spi_sync %d\n", ret); in acx565akm_transfer()
140 /* -----------------------------------------------------------------------------
141 * Auto Brightness Control Via sysfs
146 return lcd->cabc_mode; in acx565akm_get_cabc_mode()
154 lcd->cabc_mode = mode; in acx565akm_set_cabc_mode()
155 if (!lcd->enabled) in acx565akm_set_cabc_mode()
175 "still-image",
176 "moving-image",
187 if (!lcd->has_cabc) in cabc_mode_show()
210 if (count > 0 && buf[count - 1] == '\n') in cabc_mode_store()
211 count--; in cabc_mode_store()
220 return -EINVAL; in cabc_mode_store()
222 if (!lcd->has_cabc && i != 0) in cabc_mode_store()
223 return -EINVAL; in cabc_mode_store()
225 mutex_lock(&lcd->mutex); in cabc_mode_store()
227 mutex_unlock(&lcd->mutex); in cabc_mode_store()
240 if (!lcd->has_cabc) in cabc_available_modes_show()
265 /* -----------------------------------------------------------------------------
300 struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev); in acx565akm_bl_update_status_locked()
310 struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev); in acx565akm_bl_update_status()
313 mutex_lock(&lcd->mutex); in acx565akm_bl_update_status()
315 mutex_unlock(&lcd->mutex); in acx565akm_bl_update_status()
322 struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev); in acx565akm_bl_get_intensity()
325 mutex_lock(&lcd->mutex); in acx565akm_bl_get_intensity()
332 mutex_unlock(&lcd->mutex); in acx565akm_bl_get_intensity()
350 lcd->backlight = backlight_device_register(lcd->name, &lcd->spi->dev, in acx565akm_backlight_init()
353 if (IS_ERR(lcd->backlight)) { in acx565akm_backlight_init()
354 ret = PTR_ERR(lcd->backlight); in acx565akm_backlight_init()
355 lcd->backlight = NULL; in acx565akm_backlight_init()
359 if (lcd->has_cabc) { in acx565akm_backlight_init()
360 ret = sysfs_create_group(&lcd->backlight->dev.kobj, in acx565akm_backlight_init()
363 dev_err(&lcd->spi->dev, in acx565akm_backlight_init()
365 backlight_device_unregister(lcd->backlight); in acx565akm_backlight_init()
369 lcd->cabc_mode = acx565akm_get_hw_cabc_mode(lcd); in acx565akm_backlight_init()
372 lcd->backlight->props.max_brightness = 255; in acx565akm_backlight_init()
373 lcd->backlight->props.brightness = acx565akm_get_actual_brightness(lcd); in acx565akm_backlight_init()
375 acx565akm_bl_update_status_locked(lcd->backlight); in acx565akm_backlight_init()
382 if (lcd->has_cabc) in acx565akm_backlight_cleanup()
383 sysfs_remove_group(&lcd->backlight->dev.kobj, in acx565akm_backlight_cleanup()
386 backlight_device_unregister(lcd->backlight); in acx565akm_backlight_cleanup()
389 /* -----------------------------------------------------------------------------
399 * We have to keep 120msec between sleep in/out commands. in acx565akm_set_sleep_mode()
402 wait = lcd->hw_guard_end - jiffies; in acx565akm_set_sleep_mode()
403 if ((long)wait > 0 && wait <= lcd->hw_guard_wait) { in acx565akm_set_sleep_mode()
410 lcd->hw_guard_wait = msecs_to_jiffies(120); in acx565akm_set_sleep_mode()
411 lcd->hw_guard_end = jiffies + lcd->hw_guard_wait; in acx565akm_set_sleep_mode()
427 gpiod_set_value(lcd->reset_gpio, 1); in acx565akm_power_on()
429 if (lcd->enabled) { in acx565akm_power_on()
430 dev_dbg(&lcd->spi->dev, "panel already enabled\n"); in acx565akm_power_on()
440 * 4. 120msec before the sleep out command (7.12.1) in acx565akm_power_on()
445 lcd->enabled = true; in acx565akm_power_on()
447 /* 5msec between sleep out and the next command. (8.2.16) */ in acx565akm_power_on()
450 acx565akm_set_cabc_mode(lcd, lcd->cabc_mode); in acx565akm_power_on()
452 return acx565akm_bl_update_status_locked(lcd->backlight); in acx565akm_power_on()
459 lcd->enabled = false; in acx565akm_power_off()
462 * ~50msec) after sending the sleep in command and asserting the in acx565akm_power_off()
468 gpiod_set_value(lcd->reset_gpio, 0); in acx565akm_power_off()
478 mutex_lock(&lcd->mutex); in acx565akm_disable()
480 mutex_unlock(&lcd->mutex); in acx565akm_disable()
489 mutex_lock(&lcd->mutex); in acx565akm_enable()
491 mutex_unlock(&lcd->mutex); in acx565akm_enable()
517 mode = drm_mode_duplicate(connector->dev, &acx565akm_mode); in acx565akm_get_modes()
519 return -ENOMEM; in acx565akm_get_modes()
524 connector->display_info.width_mm = acx565akm_mode.width_mm; in acx565akm_get_modes()
525 connector->display_info.height_mm = acx565akm_mode.height_mm; in acx565akm_get_modes()
526 connector->display_info.bus_flags = DRM_BUS_FLAG_DE_HIGH in acx565akm_get_modes()
539 /* -----------------------------------------------------------------------------
553 gpiod_set_value(lcd->reset_gpio, 1); in acx565akm_detect()
558 lcd->enabled = (status & (1 << 17)) && (status & (1 << 10)); in acx565akm_detect()
560 dev_dbg(&lcd->spi->dev, in acx565akm_detect()
562 lcd->enabled ? "enabled" : "disabled ", status); in acx565akm_detect()
564 acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_ID, lcd->display_id, 3); in acx565akm_detect()
565 dev_dbg(&lcd->spi->dev, "MIPI display ID: %02x%02x%02x\n", in acx565akm_detect()
566 lcd->display_id[0], lcd->display_id[1], lcd->display_id[2]); in acx565akm_detect()
568 switch (lcd->display_id[0]) { in acx565akm_detect()
570 lcd->model = MIPID_VER_ACX565AKM; in acx565akm_detect()
571 lcd->name = "acx565akm"; in acx565akm_detect()
572 lcd->has_bc = 1; in acx565akm_detect()
573 lcd->has_cabc = 1; in acx565akm_detect()
576 lcd->model = MIPID_VER_L4F00311; in acx565akm_detect()
577 lcd->name = "l4f00311"; in acx565akm_detect()
580 lcd->model = MIPID_VER_LPH8923; in acx565akm_detect()
581 lcd->name = "lph8923"; in acx565akm_detect()
584 lcd->model = MIPID_VER_LS041Y3; in acx565akm_detect()
585 lcd->name = "ls041y3"; in acx565akm_detect()
588 lcd->name = "unknown"; in acx565akm_detect()
589 dev_err(&lcd->spi->dev, "unknown display ID\n"); in acx565akm_detect()
590 ret = -ENODEV; in acx565akm_detect()
594 lcd->revision = lcd->display_id[1]; in acx565akm_detect()
596 dev_info(&lcd->spi->dev, "%s rev %02x panel detected\n", in acx565akm_detect()
597 lcd->name, lcd->revision); in acx565akm_detect()
600 if (!lcd->enabled) in acx565akm_detect()
601 gpiod_set_value(lcd->reset_gpio, 0); in acx565akm_detect()
611 lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL); in acx565akm_probe()
613 return -ENOMEM; in acx565akm_probe()
616 spi->mode = SPI_MODE_3; in acx565akm_probe()
618 lcd->spi = spi; in acx565akm_probe()
619 mutex_init(&lcd->mutex); in acx565akm_probe()
621 lcd->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); in acx565akm_probe()
622 if (IS_ERR(lcd->reset_gpio)) { in acx565akm_probe()
623 dev_err(&spi->dev, "failed to get reset GPIO\n"); in acx565akm_probe()
624 return PTR_ERR(lcd->reset_gpio); in acx565akm_probe()
629 dev_err(&spi->dev, "panel detection failed\n"); in acx565akm_probe()
633 if (lcd->has_bc) { in acx565akm_probe()
639 drm_panel_init(&lcd->panel, &lcd->spi->dev, &acx565akm_funcs, in acx565akm_probe()
642 drm_panel_add(&lcd->panel); in acx565akm_probe()
651 drm_panel_remove(&lcd->panel); in acx565akm_remove()
653 if (lcd->has_bc) in acx565akm_remove()
676 .name = "panel-sony-acx565akm",