summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/logicvc/logicvc_mode.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <paul.kocialkowski@bootlin.com>2022-05-20 17:15:55 +0300
committerPaul Kocialkowski <paul.kocialkowski@bootlin.com>2022-06-09 17:49:56 +0300
commitefeeaefe9be56e8ae5e5b4e9ff6d2275ec977ec5 (patch)
treefd6f9768de34219c02f0186f5c188d663fc19bb6 /drivers/gpu/drm/logicvc/logicvc_mode.c
parentbdde97ac4bea26d48f60e353396b2b4fb0234ac4 (diff)
downloadlinux-efeeaefe9be56e8ae5e5b4e9ff6d2275ec977ec5.tar.xz
drm: Add support for the LogiCVC display controller
Introduces a driver for the LogiCVC display controller, a programmable logic controller optimized for use in Xilinx Zynq-7000 SoCs and other Xilinx FPGAs. The controller is mostly configured at logic synthesis time so only a subset of configuration is left for the driver to handle. The following features are implemented and tested: - LVDS 4-bit interface; - RGB565 pixel formats; - Multiple layers and hardware composition; - Layer-wide alpha mode; The following features are implemented but untested: - Other RGB pixel formats; - Layer framebuffer configuration for version 4; - Lowest-layer used as background color; - Per-pixel alpha mode. The following features are not implemented: - YUV pixel formats; - DVI, LVDS 3-bit, ITU656 and camera link interfaces; - External parallel input for layer; - Color-keying; - LUT-based alpha modes. Additional implementation-specific notes: - Panels are only enabled after the first page flip to avoid flashing a white screen. - Depth used in context of the LogiCVC driver only counts color components to match the definition of the synthesis parameters. Support is implemented for both version 3 and 4 of the controller. With version 3, framebuffers are stored in a dedicated contiguous memory area, with a base address hardcoded for each layer. This requires using a dedicated CMA pool registered at the base address and tweaking a few offset-related registers to try to use any buffer allocated from the pool. This is done on a best-effort basis to have the hardware cope with the DRM framebuffer allocation model and there is no guarantee that each buffer allocated by GEM CMA can be used for any layer. In particular, buffers allocated below the base address for a layer are guaranteed not to be configurable for that layer. See the implementation of logicvc_layer_buffer_find_setup for specifics. Version 4 allows configuring each buffer address directly, which guarantees that any buffer can be configured. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20220520141555.1429041-2-paul.kocialkowski@bootlin.com
Diffstat (limited to 'drivers/gpu/drm/logicvc/logicvc_mode.c')
-rw-r--r--drivers/gpu/drm/logicvc/logicvc_mode.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/drivers/gpu/drm/logicvc/logicvc_mode.c b/drivers/gpu/drm/logicvc/logicvc_mode.c
new file mode 100644
index 000000000000..11940704f644
--- /dev/null
+++ b/drivers/gpu/drm/logicvc/logicvc_mode.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019-2022 Bootlin
+ * Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
+ */
+
+#include <linux/types.h>
+
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_mode_config.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+#include <drm/drm_probe_helper.h>
+#include <drm/drm_vblank.h>
+
+#include "logicvc_drm.h"
+#include "logicvc_interface.h"
+#include "logicvc_layer.h"
+#include "logicvc_mode.h"
+
+static const struct drm_mode_config_funcs logicvc_mode_config_funcs = {
+ .fb_create = drm_gem_fb_create,
+ .output_poll_changed = drm_fb_helper_output_poll_changed,
+ .atomic_check = drm_atomic_helper_check,
+ .atomic_commit = drm_atomic_helper_commit,
+};
+
+int logicvc_mode_init(struct logicvc_drm *logicvc)
+{
+ struct drm_device *drm_dev = &logicvc->drm_dev;
+ struct drm_mode_config *mode_config = &drm_dev->mode_config;
+ struct logicvc_layer *layer_primary;
+ uint32_t preferred_depth;
+ int ret;
+
+ ret = drm_vblank_init(drm_dev, mode_config->num_crtc);
+ if (ret) {
+ drm_err(drm_dev, "Failed to initialize vblank\n");
+ return ret;
+ }
+
+ layer_primary = logicvc_layer_get_primary(logicvc);
+ if (!layer_primary) {
+ drm_err(drm_dev, "Failed to get primary layer\n");
+ return -EINVAL;
+ }
+
+ preferred_depth = layer_primary->formats->depth;
+
+ /* DRM counts alpha in depth, our driver doesn't. */
+ if (layer_primary->formats->alpha)
+ preferred_depth += 8;
+
+ mode_config->min_width = 64;
+ mode_config->max_width = 2048;
+ mode_config->min_height = 1;
+ mode_config->max_height = 2048;
+ mode_config->preferred_depth = preferred_depth;
+ mode_config->funcs = &logicvc_mode_config_funcs;
+
+ drm_mode_config_reset(drm_dev);
+
+ drm_kms_helper_poll_init(drm_dev);
+
+ return 0;
+}
+
+void logicvc_mode_fini(struct logicvc_drm *logicvc)
+{
+ struct drm_device *drm_dev = &logicvc->drm_dev;
+
+ drm_kms_helper_poll_fini(drm_dev);
+}