drm/vc4: Add KMS support for Raspberry Pi.
This is enough for fbcon and bringing up X using xf86-video-modesetting. It doesn't support the 3D accelerator or power management yet. v2: Drop FB_HELPER select thanks to Archit's patches. Do manual init ordering instead of using the .load hook. Structure registration more like tegra's, but still using the typical "component" code. Drop no-op hooks for atomic_begin and mode_fixup() now that they're optional. Drop sentinel in Makefile. Fix minor style nits I noticed on another reread. v3: Use the new bcm2835 clk driver to manage pixel/HSM clocks instead of having a fixed video mode. Use exynos-style component driver matching instead of devicetree nodes to list the component driver instances. Rename compatibility strings to say bcm2835, and distinguish pv0/1/2. Clean up some h/vsync code, and add in interlaced mode setup. Fix up probe/bind error paths. Use bitops.h macros for vc4_regs.h v4: Include i2c.h, allow building under COMPILE_TEST, drop msleep now that other bugs have been fixed, add timeouts to cpu_relax() loops, rename hpd-gpio to hpd-gpios. Signed-off-by: Eric Anholt <eric@anholt.net> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
143
drivers/gpu/drm/vc4/vc4_drv.h
Normal file
143
drivers/gpu/drm/vc4/vc4_drv.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Broadcom
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "drmP.h"
|
||||
#include "drm_gem_cma_helper.h"
|
||||
|
||||
struct vc4_dev {
|
||||
struct drm_device *dev;
|
||||
|
||||
struct vc4_hdmi *hdmi;
|
||||
struct vc4_hvs *hvs;
|
||||
struct vc4_crtc *crtc[3];
|
||||
};
|
||||
|
||||
static inline struct vc4_dev *
|
||||
to_vc4_dev(struct drm_device *dev)
|
||||
{
|
||||
return (struct vc4_dev *)dev->dev_private;
|
||||
}
|
||||
|
||||
struct vc4_bo {
|
||||
struct drm_gem_cma_object base;
|
||||
};
|
||||
|
||||
static inline struct vc4_bo *
|
||||
to_vc4_bo(struct drm_gem_object *bo)
|
||||
{
|
||||
return (struct vc4_bo *)bo;
|
||||
}
|
||||
|
||||
struct vc4_hvs {
|
||||
struct platform_device *pdev;
|
||||
void __iomem *regs;
|
||||
void __iomem *dlist;
|
||||
};
|
||||
|
||||
struct vc4_plane {
|
||||
struct drm_plane base;
|
||||
};
|
||||
|
||||
static inline struct vc4_plane *
|
||||
to_vc4_plane(struct drm_plane *plane)
|
||||
{
|
||||
return (struct vc4_plane *)plane;
|
||||
}
|
||||
|
||||
enum vc4_encoder_type {
|
||||
VC4_ENCODER_TYPE_HDMI,
|
||||
VC4_ENCODER_TYPE_VEC,
|
||||
VC4_ENCODER_TYPE_DSI0,
|
||||
VC4_ENCODER_TYPE_DSI1,
|
||||
VC4_ENCODER_TYPE_SMI,
|
||||
VC4_ENCODER_TYPE_DPI,
|
||||
};
|
||||
|
||||
struct vc4_encoder {
|
||||
struct drm_encoder base;
|
||||
enum vc4_encoder_type type;
|
||||
u32 clock_select;
|
||||
};
|
||||
|
||||
static inline struct vc4_encoder *
|
||||
to_vc4_encoder(struct drm_encoder *encoder)
|
||||
{
|
||||
return container_of(encoder, struct vc4_encoder, base);
|
||||
}
|
||||
|
||||
#define HVS_READ(offset) readl(vc4->hvs->regs + offset)
|
||||
#define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
|
||||
|
||||
/**
|
||||
* _wait_for - magic (register) wait macro
|
||||
*
|
||||
* Does the right thing for modeset paths when run under kdgb or similar atomic
|
||||
* contexts. Note that it's important that we check the condition again after
|
||||
* having timed out, since the timeout could be due to preemption or similar and
|
||||
* we've never had a chance to check the condition before the timeout.
|
||||
*/
|
||||
#define _wait_for(COND, MS, W) ({ \
|
||||
unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
|
||||
int ret__ = 0; \
|
||||
while (!(COND)) { \
|
||||
if (time_after(jiffies, timeout__)) { \
|
||||
if (!(COND)) \
|
||||
ret__ = -ETIMEDOUT; \
|
||||
break; \
|
||||
} \
|
||||
if (W && drm_can_sleep()) { \
|
||||
msleep(W); \
|
||||
} else { \
|
||||
cpu_relax(); \
|
||||
} \
|
||||
} \
|
||||
ret__; \
|
||||
})
|
||||
|
||||
#define wait_for(COND, MS) _wait_for(COND, MS, 1)
|
||||
|
||||
/* vc4_bo.c */
|
||||
void vc4_free_object(struct drm_gem_object *gem_obj);
|
||||
struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size);
|
||||
int vc4_dumb_create(struct drm_file *file_priv,
|
||||
struct drm_device *dev,
|
||||
struct drm_mode_create_dumb *args);
|
||||
struct dma_buf *vc4_prime_export(struct drm_device *dev,
|
||||
struct drm_gem_object *obj, int flags);
|
||||
|
||||
/* vc4_crtc.c */
|
||||
extern struct platform_driver vc4_crtc_driver;
|
||||
int vc4_enable_vblank(struct drm_device *dev, int crtc_id);
|
||||
void vc4_disable_vblank(struct drm_device *dev, int crtc_id);
|
||||
void vc4_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
|
||||
int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
|
||||
|
||||
/* vc4_debugfs.c */
|
||||
int vc4_debugfs_init(struct drm_minor *minor);
|
||||
void vc4_debugfs_cleanup(struct drm_minor *minor);
|
||||
|
||||
/* vc4_drv.c */
|
||||
void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
|
||||
|
||||
/* vc4_hdmi.c */
|
||||
extern struct platform_driver vc4_hdmi_driver;
|
||||
int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);
|
||||
|
||||
/* vc4_hvs.c */
|
||||
extern struct platform_driver vc4_hvs_driver;
|
||||
void vc4_hvs_dump_state(struct drm_device *dev);
|
||||
int vc4_hvs_debugfs_regs(struct seq_file *m, void *unused);
|
||||
|
||||
/* vc4_kms.c */
|
||||
int vc4_kms_load(struct drm_device *dev);
|
||||
|
||||
/* vc4_plane.c */
|
||||
struct drm_plane *vc4_plane_init(struct drm_device *dev,
|
||||
enum drm_plane_type type);
|
||||
u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
|
||||
u32 vc4_plane_dlist_size(struct drm_plane_state *state);
|
Reference in New Issue
Block a user