Lines Matching full:lcd
3 * Sony ACX565AKM LCD Panel driver
75 static void acx565akm_transfer(struct acx565akm_panel *lcd, int cmd, in acx565akm_transfer() argument
118 ret = spi_sync(lcd->spi, &m); in acx565akm_transfer()
120 dev_dbg(&lcd->spi->dev, "spi_sync %d\n", ret); in acx565akm_transfer()
123 static inline void acx565akm_cmd(struct acx565akm_panel *lcd, int cmd) in acx565akm_cmd() argument
125 acx565akm_transfer(lcd, cmd, NULL, 0, NULL, 0); in acx565akm_cmd()
128 static inline void acx565akm_write(struct acx565akm_panel *lcd, in acx565akm_write() argument
131 acx565akm_transfer(lcd, reg, buf, len, NULL, 0); in acx565akm_write()
134 static inline void acx565akm_read(struct acx565akm_panel *lcd, in acx565akm_read() argument
137 acx565akm_transfer(lcd, reg, NULL, 0, buf, len); in acx565akm_read()
144 static unsigned int acx565akm_get_cabc_mode(struct acx565akm_panel *lcd) in acx565akm_get_cabc_mode() argument
146 return lcd->cabc_mode; in acx565akm_get_cabc_mode()
149 static void acx565akm_set_cabc_mode(struct acx565akm_panel *lcd, in acx565akm_set_cabc_mode() argument
154 lcd->cabc_mode = mode; in acx565akm_set_cabc_mode()
155 if (!lcd->enabled) in acx565akm_set_cabc_mode()
158 acx565akm_read(lcd, MIPID_CMD_READ_CABC, (u8 *)&cabc_ctrl, 1); in acx565akm_set_cabc_mode()
161 acx565akm_write(lcd, MIPID_CMD_WRITE_CABC, (u8 *)&cabc_ctrl, 2); in acx565akm_set_cabc_mode()
164 static unsigned int acx565akm_get_hw_cabc_mode(struct acx565akm_panel *lcd) in acx565akm_get_hw_cabc_mode() argument
168 acx565akm_read(lcd, MIPID_CMD_READ_CABC, &cabc_ctrl, 1); in acx565akm_get_hw_cabc_mode()
183 struct acx565akm_panel *lcd = dev_get_drvdata(dev); in cabc_mode_show() local
187 if (!lcd->has_cabc) in cabc_mode_show()
190 mode = acx565akm_get_cabc_mode(lcd); in cabc_mode_show()
203 struct acx565akm_panel *lcd = dev_get_drvdata(dev); in cabc_mode_store() local
222 if (!lcd->has_cabc && i != 0) in cabc_mode_store()
225 mutex_lock(&lcd->mutex); in cabc_mode_store()
226 acx565akm_set_cabc_mode(lcd, i); in cabc_mode_store()
227 mutex_unlock(&lcd->mutex); in cabc_mode_store()
236 struct acx565akm_panel *lcd = dev_get_drvdata(dev); in cabc_available_modes_show() local
240 if (!lcd->has_cabc) in cabc_available_modes_show()
269 static int acx565akm_get_actual_brightness(struct acx565akm_panel *lcd) in acx565akm_get_actual_brightness() argument
273 acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, &bv, 1); in acx565akm_get_actual_brightness()
278 static void acx565akm_set_brightness(struct acx565akm_panel *lcd, int level) in acx565akm_set_brightness() argument
284 acx565akm_write(lcd, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, (u8 *)&bv, 2); in acx565akm_set_brightness()
286 acx565akm_read(lcd, MIPI_DCS_GET_CONTROL_DISPLAY, (u8 *)&ctrl, 1); in acx565akm_set_brightness()
295 acx565akm_write(lcd, MIPI_DCS_WRITE_CONTROL_DISPLAY, (u8 *)&ctrl, 2); in acx565akm_set_brightness()
300 struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev); in acx565akm_bl_update_status_locked() local
309 acx565akm_set_brightness(lcd, level); in acx565akm_bl_update_status_locked()
316 struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev); in acx565akm_bl_update_status() local
319 mutex_lock(&lcd->mutex); in acx565akm_bl_update_status()
321 mutex_unlock(&lcd->mutex); in acx565akm_bl_update_status()
328 struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev); in acx565akm_bl_get_intensity() local
331 mutex_lock(&lcd->mutex); in acx565akm_bl_get_intensity()
335 intensity = acx565akm_get_actual_brightness(lcd); in acx565akm_bl_get_intensity()
339 mutex_unlock(&lcd->mutex); in acx565akm_bl_get_intensity()
349 static int acx565akm_backlight_init(struct acx565akm_panel *lcd) in acx565akm_backlight_init() argument
358 lcd->backlight = backlight_device_register(lcd->name, &lcd->spi->dev, in acx565akm_backlight_init()
359 lcd, &acx565akm_bl_ops, in acx565akm_backlight_init()
361 if (IS_ERR(lcd->backlight)) { in acx565akm_backlight_init()
362 ret = PTR_ERR(lcd->backlight); in acx565akm_backlight_init()
363 lcd->backlight = NULL; in acx565akm_backlight_init()
367 if (lcd->has_cabc) { in acx565akm_backlight_init()
368 ret = sysfs_create_group(&lcd->backlight->dev.kobj, in acx565akm_backlight_init()
371 dev_err(&lcd->spi->dev, in acx565akm_backlight_init()
373 backlight_device_unregister(lcd->backlight); in acx565akm_backlight_init()
377 lcd->cabc_mode = acx565akm_get_hw_cabc_mode(lcd); in acx565akm_backlight_init()
380 lcd->backlight->props.max_brightness = 255; in acx565akm_backlight_init()
381 lcd->backlight->props.brightness = acx565akm_get_actual_brightness(lcd); in acx565akm_backlight_init()
383 acx565akm_bl_update_status_locked(lcd->backlight); in acx565akm_backlight_init()
388 static void acx565akm_backlight_cleanup(struct acx565akm_panel *lcd) in acx565akm_backlight_cleanup() argument
390 if (lcd->has_cabc) in acx565akm_backlight_cleanup()
391 sysfs_remove_group(&lcd->backlight->dev.kobj, in acx565akm_backlight_cleanup()
394 backlight_device_unregister(lcd->backlight); in acx565akm_backlight_cleanup()
401 static void acx565akm_set_sleep_mode(struct acx565akm_panel *lcd, int on) in acx565akm_set_sleep_mode() argument
410 wait = lcd->hw_guard_end - jiffies; in acx565akm_set_sleep_mode()
411 if ((long)wait > 0 && wait <= lcd->hw_guard_wait) { in acx565akm_set_sleep_mode()
416 acx565akm_cmd(lcd, cmd); in acx565akm_set_sleep_mode()
418 lcd->hw_guard_wait = msecs_to_jiffies(120); in acx565akm_set_sleep_mode()
419 lcd->hw_guard_end = jiffies + lcd->hw_guard_wait; in acx565akm_set_sleep_mode()
422 static void acx565akm_set_display_state(struct acx565akm_panel *lcd, in acx565akm_set_display_state() argument
427 acx565akm_cmd(lcd, cmd); in acx565akm_set_display_state()
430 static int acx565akm_power_on(struct acx565akm_panel *lcd) in acx565akm_power_on() argument
435 gpiod_set_value(lcd->reset_gpio, 1); in acx565akm_power_on()
437 if (lcd->enabled) { in acx565akm_power_on()
438 dev_dbg(&lcd->spi->dev, "panel already enabled\n"); in acx565akm_power_on()
452 acx565akm_set_sleep_mode(lcd, 0); in acx565akm_power_on()
453 lcd->enabled = true; in acx565akm_power_on()
457 acx565akm_set_display_state(lcd, 1); in acx565akm_power_on()
458 acx565akm_set_cabc_mode(lcd, lcd->cabc_mode); in acx565akm_power_on()
460 return acx565akm_bl_update_status_locked(lcd->backlight); in acx565akm_power_on()
463 static void acx565akm_power_off(struct acx565akm_panel *lcd) in acx565akm_power_off() argument
465 if (!lcd->enabled) in acx565akm_power_off()
468 acx565akm_set_display_state(lcd, 0); in acx565akm_power_off()
469 acx565akm_set_sleep_mode(lcd, 1); in acx565akm_power_off()
470 lcd->enabled = false; in acx565akm_power_off()
479 gpiod_set_value(lcd->reset_gpio, 0); in acx565akm_power_off()
487 struct acx565akm_panel *lcd = to_acx565akm_device(panel); in acx565akm_disable() local
489 mutex_lock(&lcd->mutex); in acx565akm_disable()
490 acx565akm_power_off(lcd); in acx565akm_disable()
491 mutex_unlock(&lcd->mutex); in acx565akm_disable()
498 struct acx565akm_panel *lcd = to_acx565akm_device(panel); in acx565akm_enable() local
500 mutex_lock(&lcd->mutex); in acx565akm_enable()
501 acx565akm_power_on(lcd); in acx565akm_enable()
502 mutex_unlock(&lcd->mutex); in acx565akm_enable()
554 static int acx565akm_detect(struct acx565akm_panel *lcd) in acx565akm_detect() argument
564 gpiod_set_value(lcd->reset_gpio, 1); in acx565akm_detect()
567 acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_STATUS, (u8 *)&value, 4); in acx565akm_detect()
569 lcd->enabled = (status & (1 << 17)) && (status & (1 << 10)); in acx565akm_detect()
571 dev_dbg(&lcd->spi->dev, in acx565akm_detect()
572 "LCD panel %s by bootloader (status 0x%04x)\n", in acx565akm_detect()
573 lcd->enabled ? "enabled" : "disabled ", status); in acx565akm_detect()
575 acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_ID, lcd->display_id, 3); in acx565akm_detect()
576 dev_dbg(&lcd->spi->dev, "MIPI display ID: %02x%02x%02x\n", in acx565akm_detect()
577 lcd->display_id[0], lcd->display_id[1], lcd->display_id[2]); in acx565akm_detect()
579 switch (lcd->display_id[0]) { in acx565akm_detect()
581 lcd->model = MIPID_VER_ACX565AKM; in acx565akm_detect()
582 lcd->name = "acx565akm"; in acx565akm_detect()
583 lcd->has_bc = 1; in acx565akm_detect()
584 lcd->has_cabc = 1; in acx565akm_detect()
587 lcd->model = MIPID_VER_L4F00311; in acx565akm_detect()
588 lcd->name = "l4f00311"; in acx565akm_detect()
591 lcd->model = MIPID_VER_LPH8923; in acx565akm_detect()
592 lcd->name = "lph8923"; in acx565akm_detect()
595 lcd->model = MIPID_VER_LS041Y3; in acx565akm_detect()
596 lcd->name = "ls041y3"; in acx565akm_detect()
599 lcd->name = "unknown"; in acx565akm_detect()
600 dev_err(&lcd->spi->dev, "unknown display ID\n"); in acx565akm_detect()
605 lcd->revision = lcd->display_id[1]; in acx565akm_detect()
607 dev_info(&lcd->spi->dev, "%s rev %02x panel detected\n", in acx565akm_detect()
608 lcd->name, lcd->revision); in acx565akm_detect()
611 if (!lcd->enabled) in acx565akm_detect()
612 gpiod_set_value(lcd->reset_gpio, 0); in acx565akm_detect()
619 struct acx565akm_panel *lcd; in acx565akm_probe() local
622 lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL); in acx565akm_probe()
623 if (!lcd) in acx565akm_probe()
626 spi_set_drvdata(spi, lcd); in acx565akm_probe()
629 lcd->spi = spi; in acx565akm_probe()
630 mutex_init(&lcd->mutex); in acx565akm_probe()
632 lcd->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); in acx565akm_probe()
633 if (IS_ERR(lcd->reset_gpio)) { in acx565akm_probe()
635 return PTR_ERR(lcd->reset_gpio); in acx565akm_probe()
638 ret = acx565akm_detect(lcd); in acx565akm_probe()
644 if (lcd->has_bc) { in acx565akm_probe()
645 ret = acx565akm_backlight_init(lcd); in acx565akm_probe()
650 drm_panel_init(&lcd->panel, &lcd->spi->dev, &acx565akm_funcs, in acx565akm_probe()
653 drm_panel_add(&lcd->panel); in acx565akm_probe()
660 struct acx565akm_panel *lcd = spi_get_drvdata(spi); in acx565akm_remove() local
662 drm_panel_remove(&lcd->panel); in acx565akm_remove()
664 if (lcd->has_bc) in acx565akm_remove()
665 acx565akm_backlight_cleanup(lcd); in acx565akm_remove()
667 drm_panel_disable(&lcd->panel); in acx565akm_remove()
668 drm_panel_unprepare(&lcd->panel); in acx565akm_remove()
700 MODULE_DESCRIPTION("Sony ACX565AKM LCD Panel Driver");