Lines Matching +full:mipi +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
3 * DRM driver for MIPI DBI compatible display panels
59 if (strcmp(format_name, format->name)) in panel_mipi_dbi_get_format()
62 formats[0] = format->fourcc; in panel_mipi_dbi_get_format()
63 *bpp = format->bpp; in panel_mipi_dbi_get_format()
69 return -EINVAL; in panel_mipi_dbi_get_format()
88 * MIPI commands to execute when the display pipeline is enabled.
96 * parameter: delay in miliseconds (the No Operation command is part of the MIPI Display
122 const struct panel_mipi_dbi_config *config = (struct panel_mipi_dbi_config *)fw->data; in panel_mipi_dbi_check_commands()
124 size_t size = fw->size, commands_len; in panel_mipi_dbi_check_commands()
129 return ERR_PTR(-EINVAL); in panel_mipi_dbi_check_commands()
132 if (memcmp(config->magic, panel_mipi_dbi_magic, sizeof(config->magic))) { in panel_mipi_dbi_check_commands()
133 dev_err(dev, "config: Bad magic: %15ph\n", config->magic); in panel_mipi_dbi_check_commands()
134 return ERR_PTR(-EINVAL); in panel_mipi_dbi_check_commands()
137 if (config->file_format_version != 1) { in panel_mipi_dbi_check_commands()
138 dev_err(dev, "config: version=%u is not supported\n", config->file_format_version); in panel_mipi_dbi_check_commands()
139 return ERR_PTR(-EINVAL); in panel_mipi_dbi_check_commands()
142 drm_dev_dbg(dev, DRM_UT_DRIVER, "size=%zu version=%u\n", size, config->file_format_version); in panel_mipi_dbi_check_commands()
144 commands_len = size - sizeof(*config); in panel_mipi_dbi_check_commands()
147 u8 command = config->commands[i++]; in panel_mipi_dbi_check_commands()
148 u8 num_parameters = config->commands[i++]; in panel_mipi_dbi_check_commands()
149 const u8 *parameters = &config->commands[i]; in panel_mipi_dbi_check_commands()
155 return ERR_PTR(-EINVAL); in panel_mipi_dbi_check_commands()
167 return ERR_PTR(-EINVAL); in panel_mipi_dbi_check_commands()
172 return ERR_PTR(-ENOMEM); in panel_mipi_dbi_check_commands()
174 commands->len = commands_len; in panel_mipi_dbi_check_commands()
175 commands->buf = devm_kmemdup(dev, config->commands, commands->len, GFP_KERNEL); in panel_mipi_dbi_check_commands()
176 if (!commands->buf) in panel_mipi_dbi_check_commands()
177 return ERR_PTR(-ENOMEM); in panel_mipi_dbi_check_commands()
190 ret = of_property_read_string_index(dev->of_node, "compatible", 0, &compatible); in panel_mipi_dbi_commands_from_fw()
217 while (i < commands->len) { in panel_mipi_dbi_commands_execute()
218 u8 command = commands->buf[i++]; in panel_mipi_dbi_commands_execute()
219 u8 num_parameters = commands->buf[i++]; in panel_mipi_dbi_commands_execute()
220 const u8 *parameters = &commands->buf[i]; in panel_mipi_dbi_commands_execute()
237 struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); in panel_mipi_dbi_enable()
238 struct mipi_dbi *dbi = &dbidev->dbi; in panel_mipi_dbi_enable()
241 if (!drm_dev_enter(pipe->crtc.dev, &idx)) in panel_mipi_dbi_enable()
244 drm_dbg(pipe->crtc.dev, "\n"); in panel_mipi_dbi_enable()
250 panel_mipi_dbi_commands_execute(dbi, dbidev->driver_private); in panel_mipi_dbi_enable()
268 .name = "panel-mipi-dbi",
269 .desc = "MIPI DBI compatible display panel",
275 static int panel_mipi_dbi_get_mode(struct mipi_dbi_dev *dbidev, struct drm_display_mode *mode) in panel_mipi_dbi_get_mode() argument
277 struct device *dev = dbidev->drm.dev; in panel_mipi_dbi_get_mode()
281 ret = of_get_drm_panel_display_mode(dev->of_node, mode, NULL); in panel_mipi_dbi_get_mode()
283 dev_err(dev, "%pOF: failed to get panel-timing (error=%d)\n", dev->of_node, ret); in panel_mipi_dbi_get_mode()
287 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in panel_mipi_dbi_get_mode()
289 hback_porch = mode->htotal - mode->hsync_end; in panel_mipi_dbi_get_mode()
290 vback_porch = mode->vtotal - mode->vsync_end; in panel_mipi_dbi_get_mode()
295 * width and height don't exceed the 16-bit value specified by MIPI DCS. in panel_mipi_dbi_get_mode()
297 if (!mode->hdisplay || !mode->vdisplay || mode->flags || in panel_mipi_dbi_get_mode()
298 mode->hsync_end > mode->hdisplay || (hback_porch + mode->hdisplay) > 0xffff || in panel_mipi_dbi_get_mode()
299 mode->vsync_end > mode->vdisplay || (vback_porch + mode->vdisplay) > 0xffff) { in panel_mipi_dbi_get_mode()
300 dev_err(dev, "%pOF: panel-timing out of bounds\n", dev->of_node); in panel_mipi_dbi_get_mode()
301 return -EINVAL; in panel_mipi_dbi_get_mode()
305 if (!mode->clock) in panel_mipi_dbi_get_mode()
306 mode->clock = mode->htotal * mode->vtotal * 60 / 1000; in panel_mipi_dbi_get_mode()
308 dbidev->top_offset = vback_porch; in panel_mipi_dbi_get_mode()
309 dbidev->left_offset = hback_porch; in panel_mipi_dbi_get_mode()
316 struct device *dev = &spi->dev; in panel_mipi_dbi_spi_probe()
317 struct drm_display_mode mode; in panel_mipi_dbi_spi_probe() local
331 dbi = &dbidev->dbi; in panel_mipi_dbi_spi_probe()
332 drm = &dbidev->drm; in panel_mipi_dbi_spi_probe()
334 ret = panel_mipi_dbi_get_mode(dbidev, &mode); in panel_mipi_dbi_spi_probe()
338 dbidev->regulator = devm_regulator_get(dev, "power"); in panel_mipi_dbi_spi_probe()
339 if (IS_ERR(dbidev->regulator)) in panel_mipi_dbi_spi_probe()
340 return dev_err_probe(dev, PTR_ERR(dbidev->regulator), in panel_mipi_dbi_spi_probe()
343 dbidev->io_regulator = devm_regulator_get(dev, "io"); in panel_mipi_dbi_spi_probe()
344 if (IS_ERR(dbidev->io_regulator)) in panel_mipi_dbi_spi_probe()
345 return dev_err_probe(dev, PTR_ERR(dbidev->io_regulator), in panel_mipi_dbi_spi_probe()
348 dbidev->backlight = devm_of_find_backlight(dev); in panel_mipi_dbi_spi_probe()
349 if (IS_ERR(dbidev->backlight)) in panel_mipi_dbi_spi_probe()
350 return dev_err_probe(dev, PTR_ERR(dbidev->backlight), "Failed to get backlight\n"); in panel_mipi_dbi_spi_probe()
352 dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in panel_mipi_dbi_spi_probe()
353 if (IS_ERR(dbi->reset)) in panel_mipi_dbi_spi_probe()
354 return dev_err_probe(dev, PTR_ERR(dbi->reset), "Failed to get GPIO 'reset'\n"); in panel_mipi_dbi_spi_probe()
365 if (device_property_present(dev, "write-only")) in panel_mipi_dbi_spi_probe()
366 dbi->read_commands = NULL; in panel_mipi_dbi_spi_probe()
368 dbidev->driver_private = panel_mipi_dbi_commands_from_fw(dev); in panel_mipi_dbi_spi_probe()
369 if (IS_ERR(dbidev->driver_private)) in panel_mipi_dbi_spi_probe()
370 return PTR_ERR(dbidev->driver_private); in panel_mipi_dbi_spi_probe()
376 buf_size = DIV_ROUND_UP(mode.hdisplay * mode.vdisplay * bpp, 8); in panel_mipi_dbi_spi_probe()
379 &mode, 0, buf_size); in panel_mipi_dbi_spi_probe()
426 { .compatible = "panel-mipi-dbi-spi" },
432 { "panel-mipi-dbi-spi", 0 },
439 .name = "panel-mipi-dbi-spi",
450 MODULE_DESCRIPTION("MIPI DBI compatible display panel driver");