ret = device_property_read_string(dev, "format", &format_name); if (ret) { /* Old Device Trees don't have this property */
formats[0] = DRM_FORMAT_RGB565;
*bpp = 16; return 0;
}
for (i = 0; i < ARRAY_SIZE(panel_mipi_dbi_formats); i++) { conststruct panel_mipi_dbi_format *format = &panel_mipi_dbi_formats[i];
/* * The display controller configuration is stored in a firmware file. * The Device Tree 'compatible' property value with a '.bin' suffix is passed * to request_firmware() to fetch this file.
*/ struct panel_mipi_dbi_config { /* Magic string: panel_mipi_dbi_magic */
u8 magic[15];
/* Config file format version */
u8 file_format_version;
/* * MIPI commands to execute when the display pipeline is enabled. * This is used to configure the display controller. * * The commands are stored in a byte array with the format: * command, num_parameters, [ parameter, ...], command, ... * * Some commands require a pause before the next command can be received. * Inserting a delay in the command sequence is done by using the NOP command with one * parameter: delay in miliseconds (the No Operation command is part of the MIPI Display * Command Set where it has no parameters). * * Example: * command 0x11 * sleep 120ms * command 0xb1 parameters 0x01, 0x2c, 0x2d * command 0x29 * * Byte sequence: * 0x11 0x00 * 0x00 0x01 0x78 * 0xb1 0x03 0x01 0x2c 0x2d * 0x29 0x00
*/
u8 commands[];
};
ret = of_property_read_string_index(dev->of_node, "compatible", 0, &compatible); if (ret) return ERR_PTR(ret);
snprintf(fw_name, sizeof(fw_name), "%s.bin", compatible);
ret = request_firmware(&fw, fw_name, dev); if (ret) {
dev_err(dev, "No config file found for compatible '%s' (error=%d)\n",
compatible, ret);
ret = of_get_drm_panel_display_mode(dev->of_node, mode, NULL); if (ret) {
dev_err(dev, "%pOF: failed to get panel-timing (error=%d)\n", dev->of_node, ret); return ret;
}
/* * Make sure width and height are set and that only back porch and * pixelclock are set in the other timing values. Also check that * width and height don't exceed the 16-bit value specified by MIPI DCS.
*/ if (!mode->hdisplay || !mode->vdisplay || mode->flags ||
mode->hsync_end > mode->hdisplay || (hback_porch + mode->hdisplay) > 0xffff ||
mode->vsync_end > mode->vdisplay || (vback_porch + mode->vdisplay) > 0xffff) {
dev_err(dev, "%pOF: panel-timing out of bounds\n", dev->of_node); return -EINVAL;
}
/* The driver doesn't use the pixel clock but it is mandatory so fake one if not set */ if (!mode->clock)
mode->clock = mode->htotal * mode->vtotal * 60 / 1000;
ret = panel_mipi_dbi_get_mode(dbidev, &mode); if (ret) return ret;
dbidev->regulator = devm_regulator_get(dev, "power"); if (IS_ERR(dbidev->regulator)) return dev_err_probe(dev, PTR_ERR(dbidev->regulator), "Failed to get regulator 'power'\n");
dbidev->io_regulator = devm_regulator_get(dev, "io"); if (IS_ERR(dbidev->io_regulator)) return dev_err_probe(dev, PTR_ERR(dbidev->io_regulator), "Failed to get regulator 'io'\n");
dbidev->backlight = devm_of_find_backlight(dev); if (IS_ERR(dbidev->backlight)) return dev_err_probe(dev, PTR_ERR(dbidev->backlight), "Failed to get backlight\n");
dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(dbi->reset)) return dev_err_probe(dev, PTR_ERR(dbi->reset), "Failed to get GPIO 'reset'\n");
/* Multiple panels can share the "dc" GPIO, but only if they are on the same SPI bus! */
dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); if (IS_ERR(dc)) return dev_err_probe(dev, PTR_ERR(dc), "Failed to get GPIO 'dc'\n");
ret = mipi_dbi_spi_init(spi, dbi, dc); if (ret) return ret;
if (device_property_present(dev, "write-only"))
dbi->read_commands = NULL;
dbidev->driver_private = panel_mipi_dbi_commands_from_fw(dev); if (IS_ERR(dbidev->driver_private)) return PTR_ERR(dbidev->driver_private);
ret = panel_mipi_dbi_get_format(dev, formats, &bpp); if (ret) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.