summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/verisilicon/Kconfig3
-rw-r--r--drivers/gpu/drm/verisilicon/vs_drv.c35
-rw-r--r--drivers/gpu/drm/verisilicon/vs_plane.c18
3 files changed, 30 insertions, 26 deletions
diff --git a/drivers/gpu/drm/verisilicon/Kconfig b/drivers/gpu/drm/verisilicon/Kconfig
index 01ec6f0fe115..20bb67fbcadf 100644
--- a/drivers/gpu/drm/verisilicon/Kconfig
+++ b/drivers/gpu/drm/verisilicon/Kconfig
@@ -4,6 +4,9 @@ config DRM_VERISILICON
tristate "DRM Support for VeriSilicon"
depends on DRM
select DRM_KMS_HELPER
+ select DRM_GEM_DMA_HELPER
+ select CMA
+ select DMA_CMA
help
Choose this option if you have a VeriSilicon soc chipset.
This driver provides VeriSilicon kernel mode
diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c
index 529b93316544..7c50b304008f 100644
--- a/drivers/gpu/drm/verisilicon/vs_drv.c
+++ b/drivers/gpu/drm/verisilicon/vs_drv.c
@@ -27,6 +27,8 @@
#endif
#include <linux/of_reserved_mem.h>
#include <drm/drm_aperture.h>
+#include <drm/drm_gem_atomic_helper.h>
+#include <drm/drm_gem_dma_helper.h>
#include "vs_drv.h"
#include "vs_fb.h"
@@ -52,17 +54,19 @@ extern struct platform_driver starfive_encoder_driver;
static bool has_iommu = true;
static struct platform_driver vs_drm_platform_driver;
-static const struct file_operations fops = {
- .owner = THIS_MODULE,
- .open = drm_open,
- .release = drm_release,
- .unlocked_ioctl = drm_ioctl,
- .compat_ioctl = drm_compat_ioctl,
- .poll = drm_poll,
- .read = drm_read,
- .llseek = noop_llseek,
- .mmap = drm_gem_mmap,
-};
+static int vs_drm_gem_dma_dumb_create(struct drm_file *file, struct drm_device *dev,
+ struct drm_mode_create_dumb *args)
+{
+ struct vs_drm_private *priv = dev->dev_private;
+
+ unsigned int pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+ args->pitch = ALIGN(pitch, priv->pitch_alignment);
+ return drm_gem_dma_dumb_create_internal(file, dev, args);
+}
+
+DEFINE_DRM_GEM_FOPS(vs_drm_fops);
+
#ifdef CONFIG_DEBUG_FS
static int vs_debugfs_planes_show(struct seq_file *s, void *data)
@@ -126,14 +130,13 @@ static int vs_debugfs_init(struct drm_minor *minor)
static struct drm_driver vs_drm_driver = {
.driver_features = DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM,
- .lastclose = drm_fb_helper_lastclose,
- .gem_prime_import = vs_gem_prime_import,
- .gem_prime_import_sg_table = vs_gem_prime_import_sg_table,
- .dumb_create = vs_gem_dumb_create,
+
#ifdef CONFIG_DEBUG_FS
.debugfs_init = vs_debugfs_init,
#endif
- .fops = &fops,
+ DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_drm_gem_dma_dumb_create),
+
+ .fops = &vs_drm_fops,
.name = DRV_NAME,
.desc = DRV_DESC,
.date = DRV_DATE,
diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c
index 73c2669ba581..89de491aef58 100644
--- a/drivers/gpu/drm/verisilicon/vs_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_plane.c
@@ -12,6 +12,7 @@
#include <drm/drm_plane_helper.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_gem_dma_helper.h>
+
#include <drm/vs_drm.h>
#include "vs_type.h"
#include "vs_crtc.h"
@@ -289,10 +290,10 @@ static void vs_plane_atomic_update(struct drm_plane *plane,
num_planes = vs_get_plane_number(fb);
for (i = 0; i < num_planes; i++) {
- struct vs_gem_object *vs_obj;
+ dma_addr_t dma_addr;
- vs_obj = vs_fb_get_gem_obj(fb, i);
- vs_plane->dma_addr[i] = vs_obj->iova + fb->offsets[i];
+ dma_addr = drm_fb_dma_get_gem_addr(new_state->fb, new_state, i);
+ vs_plane->dma_addr[i] = dma_addr;
}
plane_state->status.src = drm_plane_state_src(new_state);
@@ -318,8 +319,6 @@ static void vs_cursor_plane_atomic_update(struct drm_plane *plane,
{
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
plane);
- struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
- plane);
unsigned char i, num_planes;
struct drm_framebuffer *fb;
struct vs_plane *vs_plane = to_vs_plane(plane);
@@ -335,10 +334,10 @@ static void vs_cursor_plane_atomic_update(struct drm_plane *plane,
num_planes = vs_get_plane_number(fb);
for (i = 0; i < num_planes; i++) {
- struct vs_gem_object *vs_obj;
+ dma_addr_t dma_addr;
- vs_obj = vs_fb_get_gem_obj(fb, i);
- vs_plane->dma_addr[i] = vs_obj->iova + fb->offsets[i];
+ dma_addr = drm_fb_dma_get_gem_addr(new_state->fb, new_state, i);
+ vs_plane->dma_addr[i] = dma_addr;
}
plane_state->status.src = drm_plane_state_src(new_state);
@@ -365,12 +364,11 @@ static int vs_cursor_plane_atomic_check(struct drm_plane *plane,
{
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
plane);
- unsigned char i, num_planes;
+
struct drm_framebuffer *fb = new_plane_state->fb;
struct drm_crtc *crtc = new_plane_state->crtc;
struct vs_crtc *vs_crtc = to_vs_crtc(crtc);
struct vs_dc *dc = dev_get_drvdata(vs_crtc->dev);
- struct vs_plane_state *plane_state = to_vs_plane_state(new_plane_state);
if (!crtc || !fb)
return 0;