summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vc4/vc4_crtc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/vc4/vc4_crtc.c')
-rw-r--r--drivers/gpu/drm/vc4/vc4_crtc.c82
1 files changed, 17 insertions, 65 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index 1208258ad3b2..29131409a4de 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -44,26 +44,7 @@
#include "vc4_drv.h"
#include "vc4_regs.h"
-struct vc4_crtc_state {
- struct drm_crtc_state base;
- /* Dlist area for this CRTC configuration. */
- struct drm_mm_node mm;
- bool feed_txp;
- bool txp_armed;
-
- struct {
- unsigned int left;
- unsigned int right;
- unsigned int top;
- unsigned int bottom;
- } margins;
-};
-
-static inline struct vc4_crtc_state *
-to_vc4_crtc_state(struct drm_crtc_state *crtc_state)
-{
- return (struct vc4_crtc_state *)crtc_state;
-}
+#define HVS_FIFO_LATENCY_PIX 6
#define CRTC_WRITE(offset, val) writel(val, vc4_crtc->regs + (offset))
#define CRTC_READ(offset) readl(vc4_crtc->regs + (offset))
@@ -252,18 +233,17 @@ vc4_crtc_update_gamma_lut(struct drm_crtc *crtc)
static u32 vc4_get_fifo_full_level(u32 format)
{
static const u32 fifo_len_bytes = 64;
- static const u32 hvs_latency_pix = 6;
switch (format) {
case PV_CONTROL_FORMAT_DSIV_16:
case PV_CONTROL_FORMAT_DSIC_16:
- return fifo_len_bytes - 2 * hvs_latency_pix;
+ return fifo_len_bytes - 2 * HVS_FIFO_LATENCY_PIX;
case PV_CONTROL_FORMAT_DSIV_18:
return fifo_len_bytes - 14;
case PV_CONTROL_FORMAT_24:
case PV_CONTROL_FORMAT_DSIV_24:
default:
- return fifo_len_bytes - 3 * hvs_latency_pix;
+ return fifo_len_bytes - 3 * HVS_FIFO_LATENCY_PIX;
}
}
@@ -364,7 +344,8 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc)
(is_dsi ? PV_VCONTROL_DSI : 0));
}
- CRTC_WRITE(PV_HACT_ACT, mode->hdisplay * pixel_rep);
+ if (is_dsi)
+ CRTC_WRITE(PV_HACT_ACT, mode->hdisplay * pixel_rep);
CRTC_WRITE(PV_CONTROL,
VC4_SET_FIELD(format, PV_CONTROL_FORMAT) |
@@ -1044,7 +1025,7 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {
.get_scanout_position = vc4_crtc_get_scanout_position,
};
-static const struct vc4_crtc_data pv0_data = {
+static const struct vc4_crtc_data bcm2835_pv0_data = {
.hvs_channel = 0,
.debugfs_name = "crtc0_regs",
.encoder_types = {
@@ -1053,7 +1034,7 @@ static const struct vc4_crtc_data pv0_data = {
},
};
-static const struct vc4_crtc_data pv1_data = {
+static const struct vc4_crtc_data bcm2835_pv1_data = {
.hvs_channel = 2,
.debugfs_name = "crtc1_regs",
.encoder_types = {
@@ -1062,7 +1043,7 @@ static const struct vc4_crtc_data pv1_data = {
},
};
-static const struct vc4_crtc_data pv2_data = {
+static const struct vc4_crtc_data bcm2835_pv2_data = {
.hvs_channel = 1,
.debugfs_name = "crtc2_regs",
.encoder_types = {
@@ -1072,9 +1053,9 @@ static const struct vc4_crtc_data pv2_data = {
};
static const struct of_device_id vc4_crtc_dt_match[] = {
- { .compatible = "brcm,bcm2835-pixelvalve0", .data = &pv0_data },
- { .compatible = "brcm,bcm2835-pixelvalve1", .data = &pv1_data },
- { .compatible = "brcm,bcm2835-pixelvalve2", .data = &pv2_data },
+ { .compatible = "brcm,bcm2835-pixelvalve0", .data = &bcm2835_pv0_data },
+ { .compatible = "brcm,bcm2835-pixelvalve1", .data = &bcm2835_pv1_data },
+ { .compatible = "brcm,bcm2835-pixelvalve2", .data = &bcm2835_pv2_data },
{}
};
@@ -1128,10 +1109,10 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
{
struct platform_device *pdev = to_platform_device(dev);
struct drm_device *drm = dev_get_drvdata(master);
+ const struct vc4_crtc_data *pv_data;
struct vc4_crtc *vc4_crtc;
struct drm_crtc *crtc;
- struct drm_plane *primary_plane, *cursor_plane, *destroy_plane, *temp;
- const struct of_device_id *match;
+ struct drm_plane *primary_plane, *destroy_plane, *temp;
int ret, i;
vc4_crtc = devm_kzalloc(dev, sizeof(*vc4_crtc), GFP_KERNEL);
@@ -1139,10 +1120,10 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
return -ENOMEM;
crtc = &vc4_crtc->base;
- match = of_match_device(vc4_crtc_dt_match, dev);
- if (!match)
+ pv_data = of_device_get_match_data(dev);
+ if (!pv_data)
return -ENODEV;
- vc4_crtc->data = match->data;
+ vc4_crtc->data = pv_data;
vc4_crtc->pdev = pdev;
vc4_crtc->regs = vc4_ioremap_regs(pdev, 0);
@@ -1178,35 +1159,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
*/
drm_crtc_enable_color_mgmt(crtc, 0, true, crtc->gamma_size);
- /* Set up some arbitrary number of planes. We're not limited
- * by a set number of physical registers, just the space in
- * the HVS (16k) and how small an plane can be (28 bytes).
- * However, each plane we set up takes up some memory, and
- * increases the cost of looping over planes, which atomic
- * modesetting does quite a bit. As a result, we pick a
- * modest number of planes to expose, that should hopefully
- * still cover any sane usecase.
- */
- for (i = 0; i < 8; i++) {
- struct drm_plane *plane =
- vc4_plane_init(drm, DRM_PLANE_TYPE_OVERLAY);
-
- if (IS_ERR(plane))
- continue;
-
- plane->possible_crtcs = drm_crtc_mask(crtc);
- }
-
- /* Set up the legacy cursor after overlay initialization,
- * since we overlay planes on the CRTC in the order they were
- * initialized.
- */
- cursor_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_CURSOR);
- if (!IS_ERR(cursor_plane)) {
- cursor_plane->possible_crtcs = drm_crtc_mask(crtc);
- crtc->cursor = cursor_plane;
- }
-
vc4_crtc_get_cob_allocation(vc4_crtc);
CRTC_WRITE(PV_INTEN, 0);
@@ -1226,7 +1178,7 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
platform_set_drvdata(pdev, vc4_crtc);
- vc4_debugfs_add_regset32(drm, vc4_crtc->data->debugfs_name,
+ vc4_debugfs_add_regset32(drm, pv_data->debugfs_name,
&vc4_crtc->regset);
return 0;