Lines Matching refs:ddata

77 static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)  in dsicm_bl_power()  argument
81 if (ddata->bldev) in dsicm_bl_power()
82 backlight = ddata->bldev; in dsicm_bl_power()
83 else if (ddata->extbldev) in dsicm_bl_power()
84 backlight = ddata->extbldev; in dsicm_bl_power()
94 static void hw_guard_start(struct panel_drv_data *ddata, int guard_msec) in hw_guard_start() argument
96 ddata->hw_guard_wait = msecs_to_jiffies(guard_msec); in hw_guard_start()
97 ddata->hw_guard_end = jiffies + ddata->hw_guard_wait; in hw_guard_start()
100 static void hw_guard_wait(struct panel_drv_data *ddata) in hw_guard_wait() argument
102 unsigned long wait = ddata->hw_guard_end - jiffies; in hw_guard_wait()
104 if ((long)wait > 0 && wait <= ddata->hw_guard_wait) { in hw_guard_wait()
110 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data) in dsicm_dcs_read_1() argument
112 return mipi_dsi_dcs_read(ddata->dsi, dcs_cmd, data, 1); in dsicm_dcs_read_1()
115 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param) in dsicm_dcs_write_1() argument
117 return mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, &param, 1); in dsicm_dcs_write_1()
120 static int dsicm_sleep_in(struct panel_drv_data *ddata) in dsicm_sleep_in() argument
125 hw_guard_wait(ddata); in dsicm_sleep_in()
127 r = mipi_dsi_dcs_enter_sleep_mode(ddata->dsi); in dsicm_sleep_in()
131 hw_guard_start(ddata, 120); in dsicm_sleep_in()
138 static int dsicm_sleep_out(struct panel_drv_data *ddata) in dsicm_sleep_out() argument
142 hw_guard_wait(ddata); in dsicm_sleep_out()
144 r = mipi_dsi_dcs_exit_sleep_mode(ddata->dsi); in dsicm_sleep_out()
148 hw_guard_start(ddata, 120); in dsicm_sleep_out()
155 static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3) in dsicm_get_id() argument
159 r = dsicm_dcs_read_1(ddata, DCS_GET_ID1, id1); in dsicm_get_id()
162 r = dsicm_dcs_read_1(ddata, DCS_GET_ID2, id2); in dsicm_get_id()
165 r = dsicm_dcs_read_1(ddata, DCS_GET_ID3, id3); in dsicm_get_id()
172 static int dsicm_set_update_window(struct panel_drv_data *ddata) in dsicm_set_update_window() argument
174 struct mipi_dsi_device *dsi = ddata->dsi; in dsicm_set_update_window()
177 r = mipi_dsi_dcs_set_column_address(dsi, 0, ddata->mode.hdisplay - 1); in dsicm_set_update_window()
181 r = mipi_dsi_dcs_set_page_address(dsi, 0, ddata->mode.vdisplay - 1); in dsicm_set_update_window()
190 struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev); in dsicm_bl_update_status() local
194 dev_dbg(&ddata->dsi->dev, "update brightness to %d\n", level); in dsicm_bl_update_status()
196 mutex_lock(&ddata->lock); in dsicm_bl_update_status()
198 if (ddata->enabled) in dsicm_bl_update_status()
199 r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, in dsicm_bl_update_status()
202 mutex_unlock(&ddata->lock); in dsicm_bl_update_status()
220 struct panel_drv_data *ddata = dev_get_drvdata(dev); in num_dsi_errors_show() local
224 mutex_lock(&ddata->lock); in num_dsi_errors_show()
226 if (ddata->enabled) in num_dsi_errors_show()
227 r = dsicm_dcs_read_1(ddata, MIPI_DCS_GET_ERROR_COUNT_ON_DSI, &errors); in num_dsi_errors_show()
229 mutex_unlock(&ddata->lock); in num_dsi_errors_show()
240 struct panel_drv_data *ddata = dev_get_drvdata(dev); in hw_revision_show() local
244 mutex_lock(&ddata->lock); in hw_revision_show()
246 if (ddata->enabled) in hw_revision_show()
247 r = dsicm_get_id(ddata, &id1, &id2, &id3); in hw_revision_show()
249 mutex_unlock(&ddata->lock); in hw_revision_show()
270 static void dsicm_hw_reset(struct panel_drv_data *ddata) in dsicm_hw_reset() argument
272 gpiod_set_value(ddata->reset_gpio, 1); in dsicm_hw_reset()
275 gpiod_set_value(ddata->reset_gpio, 0); in dsicm_hw_reset()
278 gpiod_set_value(ddata->reset_gpio, 1); in dsicm_hw_reset()
283 static int dsicm_power_on(struct panel_drv_data *ddata) in dsicm_power_on() argument
288 dsicm_hw_reset(ddata); in dsicm_power_on()
290 ddata->dsi->mode_flags |= MIPI_DSI_MODE_LPM; in dsicm_power_on()
292 r = dsicm_sleep_out(ddata); in dsicm_power_on()
296 r = dsicm_get_id(ddata, &id1, &id2, &id3); in dsicm_power_on()
300 r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff); in dsicm_power_on()
304 r = dsicm_dcs_write_1(ddata, MIPI_DCS_WRITE_CONTROL_DISPLAY, in dsicm_power_on()
309 r = mipi_dsi_dcs_set_pixel_format(ddata->dsi, MIPI_DCS_PIXEL_FMT_24BIT); in dsicm_power_on()
313 r = dsicm_set_update_window(ddata); in dsicm_power_on()
317 r = mipi_dsi_dcs_set_display_on(ddata->dsi); in dsicm_power_on()
321 if (ddata->panel_data->te_support) { in dsicm_power_on()
322 r = mipi_dsi_dcs_set_tear_on(ddata->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK); in dsicm_power_on()
330 ddata->enabled = true; in dsicm_power_on()
332 if (!ddata->intro_printed) { in dsicm_power_on()
333 dev_info(&ddata->dsi->dev, "panel revision %02x.%02x.%02x\n", in dsicm_power_on()
335 ddata->intro_printed = true; in dsicm_power_on()
338 ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; in dsicm_power_on()
342 dev_err(&ddata->dsi->dev, "error while enabling panel, issuing HW reset\n"); in dsicm_power_on()
344 dsicm_hw_reset(ddata); in dsicm_power_on()
349 static int dsicm_power_off(struct panel_drv_data *ddata) in dsicm_power_off() argument
353 ddata->enabled = false; in dsicm_power_off()
355 r = mipi_dsi_dcs_set_display_off(ddata->dsi); in dsicm_power_off()
357 r = dsicm_sleep_in(ddata); in dsicm_power_off()
360 dev_err(&ddata->dsi->dev, in dsicm_power_off()
362 dsicm_hw_reset(ddata); in dsicm_power_off()
370 struct panel_drv_data *ddata = panel_to_ddata(panel); in dsicm_prepare() local
373 r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies); in dsicm_prepare()
375 dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r); in dsicm_prepare()
382 struct panel_drv_data *ddata = panel_to_ddata(panel); in dsicm_enable() local
385 mutex_lock(&ddata->lock); in dsicm_enable()
387 r = dsicm_power_on(ddata); in dsicm_enable()
391 mutex_unlock(&ddata->lock); in dsicm_enable()
393 dsicm_bl_power(ddata, true); in dsicm_enable()
397 dev_err(&ddata->dsi->dev, "enable failed (%d)\n", r); in dsicm_enable()
398 mutex_unlock(&ddata->lock); in dsicm_enable()
404 struct panel_drv_data *ddata = panel_to_ddata(panel); in dsicm_unprepare() local
407 r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies); in dsicm_unprepare()
409 dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r); in dsicm_unprepare()
416 struct panel_drv_data *ddata = panel_to_ddata(panel); in dsicm_disable() local
419 dsicm_bl_power(ddata, false); in dsicm_disable()
421 mutex_lock(&ddata->lock); in dsicm_disable()
423 r = dsicm_power_off(ddata); in dsicm_disable()
425 mutex_unlock(&ddata->lock); in dsicm_disable()
433 struct panel_drv_data *ddata = panel_to_ddata(panel); in dsicm_get_modes() local
436 mode = drm_mode_duplicate(connector->dev, &ddata->mode); in dsicm_get_modes()
438 dev_err(&ddata->dsi->dev, "failed to add mode %ux%ux@%u kHz\n", in dsicm_get_modes()
439 ddata->mode.hdisplay, ddata->mode.vdisplay, in dsicm_get_modes()
440 ddata->mode.clock); in dsicm_get_modes()
444 connector->display_info.width_mm = ddata->panel_data->width_mm; in dsicm_get_modes()
445 connector->display_info.height_mm = ddata->panel_data->height_mm; in dsicm_get_modes()
463 struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi); in dsicm_probe_of() local
465 struct drm_display_mode *mode = &ddata->mode; in dsicm_probe_of()
467 ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW); in dsicm_probe_of()
468 if (IS_ERR(ddata->reset_gpio)) { in dsicm_probe_of()
469 err = PTR_ERR(ddata->reset_gpio); in dsicm_probe_of()
475 ddata->panel_data->xres; in dsicm_probe_of()
477 ddata->panel_data->yres; in dsicm_probe_of()
478 mode->clock = ddata->panel_data->xres * ddata->panel_data->yres * in dsicm_probe_of()
479 ddata->panel_data->refresh / 1000; in dsicm_probe_of()
480 mode->width_mm = ddata->panel_data->width_mm; in dsicm_probe_of()
481 mode->height_mm = ddata->panel_data->height_mm; in dsicm_probe_of()
485 ddata->supplies[0].supply = "vpnl"; in dsicm_probe_of()
486 ddata->supplies[1].supply = "vddi"; in dsicm_probe_of()
487 err = devm_regulator_bulk_get(&dsi->dev, ARRAY_SIZE(ddata->supplies), in dsicm_probe_of()
488 ddata->supplies); in dsicm_probe_of()
498 ddata->extbldev = backlight; in dsicm_probe_of()
500 ddata->use_dsi_backlight = true; in dsicm_probe_of()
507 struct panel_drv_data *ddata; in dsicm_probe() local
514 ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); in dsicm_probe()
515 if (!ddata) in dsicm_probe()
518 mipi_dsi_set_drvdata(dsi, ddata); in dsicm_probe()
519 ddata->dsi = dsi; in dsicm_probe()
521 ddata->panel_data = of_device_get_match_data(dev); in dsicm_probe()
522 if (!ddata->panel_data) in dsicm_probe()
529 mutex_init(&ddata->lock); in dsicm_probe()
531 dsicm_hw_reset(ddata); in dsicm_probe()
533 drm_panel_init(&ddata->panel, dev, &dsicm_panel_funcs, in dsicm_probe()
536 if (ddata->use_dsi_backlight) { in dsicm_probe()
542 dev, ddata, &dsicm_bl_ops, &props); in dsicm_probe()
548 ddata->bldev = bldev; in dsicm_probe()
561 dsi->hs_rate = ddata->panel_data->max_hs_rate; in dsicm_probe()
562 dsi->lp_rate = ddata->panel_data->max_lp_rate; in dsicm_probe()
564 drm_panel_add(&ddata->panel); in dsicm_probe()
573 drm_panel_remove(&ddata->panel); in dsicm_probe()
576 if (ddata->extbldev) in dsicm_probe()
577 put_device(&ddata->extbldev->dev); in dsicm_probe()
584 struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi); in dsicm_remove() local
590 drm_panel_remove(&ddata->panel); in dsicm_remove()
594 if (ddata->extbldev) in dsicm_remove()
595 put_device(&ddata->extbldev->dev); in dsicm_remove()