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
303 acx565akm_set_brightness(lcd, level); in acx565akm_bl_update_status_locked()
310 struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev); in acx565akm_bl_update_status() local
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() local
325 mutex_lock(&lcd->mutex); in acx565akm_bl_get_intensity()
328 intensity = acx565akm_get_actual_brightness(lcd); in acx565akm_bl_get_intensity()
332 mutex_unlock(&lcd->mutex); in acx565akm_bl_get_intensity()
342 static int acx565akm_backlight_init(struct acx565akm_panel *lcd) in acx565akm_backlight_init() argument
350 lcd->backlight = backlight_device_register(lcd->name, &lcd->spi->dev, in acx565akm_backlight_init()
351 lcd, &acx565akm_bl_ops, 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()
380 static void acx565akm_backlight_cleanup(struct acx565akm_panel *lcd) in acx565akm_backlight_cleanup() argument
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()
393 static void acx565akm_set_sleep_mode(struct acx565akm_panel *lcd, int on) in acx565akm_set_sleep_mode() argument
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()
408 acx565akm_cmd(lcd, cmd); 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()
414 static void acx565akm_set_display_state(struct acx565akm_panel *lcd, in acx565akm_set_display_state() argument
419 acx565akm_cmd(lcd, cmd); in acx565akm_set_display_state()
422 static int acx565akm_power_on(struct acx565akm_panel *lcd) in acx565akm_power_on() argument
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()
444 acx565akm_set_sleep_mode(lcd, 0); in acx565akm_power_on()
445 lcd->enabled = true; in acx565akm_power_on()
449 acx565akm_set_display_state(lcd, 1); 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()
455 static void acx565akm_power_off(struct acx565akm_panel *lcd) in acx565akm_power_off() argument
457 if (!lcd->enabled) in acx565akm_power_off()
460 acx565akm_set_display_state(lcd, 0); in acx565akm_power_off()
461 acx565akm_set_sleep_mode(lcd, 1); in acx565akm_power_off()
462 lcd->enabled = false; in acx565akm_power_off()
471 gpiod_set_value(lcd->reset_gpio, 0); in acx565akm_power_off()
479 struct acx565akm_panel *lcd = to_acx565akm_device(panel); in acx565akm_disable() local
481 mutex_lock(&lcd->mutex); in acx565akm_disable()
482 acx565akm_power_off(lcd); in acx565akm_disable()
483 mutex_unlock(&lcd->mutex); in acx565akm_disable()
490 struct acx565akm_panel *lcd = to_acx565akm_device(panel); in acx565akm_enable() local
492 mutex_lock(&lcd->mutex); in acx565akm_enable()
493 acx565akm_power_on(lcd); in acx565akm_enable()
494 mutex_unlock(&lcd->mutex); in acx565akm_enable()
546 static int acx565akm_detect(struct acx565akm_panel *lcd) in acx565akm_detect() argument
556 gpiod_set_value(lcd->reset_gpio, 1); in acx565akm_detect()
559 acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_STATUS, (u8 *)&value, 4); in acx565akm_detect()
561 lcd->enabled = (status & (1 << 17)) && (status & (1 << 10)); in acx565akm_detect()
563 dev_dbg(&lcd->spi->dev, in acx565akm_detect()
564 "LCD panel %s by bootloader (status 0x%04x)\n", in acx565akm_detect()
565 lcd->enabled ? "enabled" : "disabled ", status); in acx565akm_detect()
567 acx565akm_read(lcd, MIPI_DCS_GET_DISPLAY_ID, lcd->display_id, 3); in acx565akm_detect()
568 dev_dbg(&lcd->spi->dev, "MIPI display ID: %02x%02x%02x\n", in acx565akm_detect()
569 lcd->display_id[0], lcd->display_id[1], lcd->display_id[2]); in acx565akm_detect()
571 switch (lcd->display_id[0]) { in acx565akm_detect()
573 lcd->model = MIPID_VER_ACX565AKM; in acx565akm_detect()
574 lcd->name = "acx565akm"; in acx565akm_detect()
575 lcd->has_bc = 1; in acx565akm_detect()
576 lcd->has_cabc = 1; in acx565akm_detect()
579 lcd->model = MIPID_VER_L4F00311; in acx565akm_detect()
580 lcd->name = "l4f00311"; in acx565akm_detect()
583 lcd->model = MIPID_VER_LPH8923; in acx565akm_detect()
584 lcd->name = "lph8923"; in acx565akm_detect()
587 lcd->model = MIPID_VER_LS041Y3; in acx565akm_detect()
588 lcd->name = "ls041y3"; in acx565akm_detect()
591 lcd->name = "unknown"; in acx565akm_detect()
592 dev_err(&lcd->spi->dev, "unknown display ID\n"); in acx565akm_detect()
597 lcd->revision = lcd->display_id[1]; in acx565akm_detect()
599 dev_info(&lcd->spi->dev, "%s rev %02x panel detected\n", in acx565akm_detect()
600 lcd->name, lcd->revision); in acx565akm_detect()
603 if (!lcd->enabled) in acx565akm_detect()
604 gpiod_set_value(lcd->reset_gpio, 0); in acx565akm_detect()
611 struct acx565akm_panel *lcd; in acx565akm_probe() local
614 lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL); in acx565akm_probe()
615 if (!lcd) in acx565akm_probe()
618 spi_set_drvdata(spi, lcd); in acx565akm_probe()
621 lcd->spi = spi; in acx565akm_probe()
622 mutex_init(&lcd->mutex); in acx565akm_probe()
624 lcd->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); in acx565akm_probe()
625 if (IS_ERR(lcd->reset_gpio)) { in acx565akm_probe()
627 return PTR_ERR(lcd->reset_gpio); in acx565akm_probe()
630 ret = acx565akm_detect(lcd); in acx565akm_probe()
636 if (lcd->has_bc) { in acx565akm_probe()
637 ret = acx565akm_backlight_init(lcd); in acx565akm_probe()
642 drm_panel_init(&lcd->panel, &lcd->spi->dev, &acx565akm_funcs, in acx565akm_probe()
645 drm_panel_add(&lcd->panel); in acx565akm_probe()
652 struct acx565akm_panel *lcd = spi_get_drvdata(spi); in acx565akm_remove() local
654 drm_panel_remove(&lcd->panel); in acx565akm_remove()
656 if (lcd->has_bc) in acx565akm_remove()
657 acx565akm_backlight_cleanup(lcd); in acx565akm_remove()
659 drm_panel_disable(&lcd->panel); in acx565akm_remove()
660 drm_panel_unprepare(&lcd->panel); in acx565akm_remove()
690 MODULE_DESCRIPTION("Sony ACX565AKM LCD Panel Driver");