drm: kirin: Move drm driver to driver data
authorXu YiPing <xuyiping@hisilicon.com>
Tue, 20 Aug 2019 23:06:19 +0000 (23:06 +0000)
committerSam Ravnborg <sam@ravnborg.org>
Wed, 21 Aug 2019 17:15:42 +0000 (19:15 +0200)
As part of refactoring the kirin driver to better support
different hardware revisions, this patch moves the drm_driver
structure to be under device specific driver data.

This will allow us to more easily add support for kirin960
hardware with later patches.

Cc: Rongrong Zou <zourongrong@gmail.com>
Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel <dri-devel@lists.freedesktop.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Xinliang Liu <z.liuxinliang@hisilicon.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Xu YiPing <xuyiping@hisilicon.com>
[jstultz: Reworded commit message]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190820230626.23253-19-john.stultz@linaro.org
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h

index a4cf122375ea717237eec2a1767cbd7cfa31f10a..21c5d457a97dc5de428f591232142c782d4cbc4a 100644 (file)
@@ -1049,6 +1049,29 @@ static const struct drm_mode_config_funcs ade_mode_config_funcs = {
 
 };
 
+DEFINE_DRM_GEM_CMA_FOPS(ade_fops);
+
+static struct drm_driver ade_driver = {
+       .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
+       .fops = &ade_fops,
+       .gem_free_object_unlocked = drm_gem_cma_free_object,
+       .gem_vm_ops = &drm_gem_cma_vm_ops,
+       .dumb_create = drm_gem_cma_dumb_create_internal,
+       .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
+       .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
+       .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+       .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+       .gem_prime_vmap = drm_gem_cma_prime_vmap,
+       .gem_prime_vunmap = drm_gem_cma_prime_vunmap,
+       .gem_prime_mmap = drm_gem_cma_prime_mmap,
+
+       .name = "kirin",
+       .desc = "Hisilicon Kirin620 SoC DRM Driver",
+       .date = "20150718",
+       .major = 1,
+       .minor = 0,
+};
+
 struct kirin_drm_data ade_driver_data = {
        .num_planes = ADE_CH_NUM,
        .prim_plane = ADE_CH1,
@@ -1056,6 +1079,7 @@ struct kirin_drm_data ade_driver_data = {
        .channel_formats_cnt = ARRAY_SIZE(channel_formats),
        .config_max_width = 2048,
        .config_max_height = 2048,
+       .driver = &ade_driver,
        .crtc_helper_funcs = &ade_crtc_helper_funcs,
        .crtc_funcs = &ade_crtc_funcs,
        .plane_helper_funcs = &ade_plane_helper_funcs,
index 2ab32c2e3f959416af5fb894101d58add9a63512..c9faaa848cc669a5f63e4c98b40957283c16146b 100644 (file)
@@ -93,38 +93,6 @@ err_mode_config_cleanup:
        return ret;
 }
 
-DEFINE_DRM_GEM_CMA_FOPS(kirin_drm_fops);
-
-static int kirin_gem_cma_dumb_create(struct drm_file *file,
-                                    struct drm_device *dev,
-                                    struct drm_mode_create_dumb *args)
-{
-       return drm_gem_cma_dumb_create_internal(file, dev, args);
-}
-
-static struct drm_driver kirin_drm_driver = {
-       .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
-       .fops                   = &kirin_drm_fops,
-
-       .gem_free_object_unlocked = drm_gem_cma_free_object,
-       .gem_vm_ops             = &drm_gem_cma_vm_ops,
-       .dumb_create            = kirin_gem_cma_dumb_create,
-
-       .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
-       .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
-       .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
-       .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
-       .gem_prime_vmap         = drm_gem_cma_prime_vmap,
-       .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
-       .gem_prime_mmap         = drm_gem_cma_prime_mmap,
-
-       .name                   = "kirin",
-       .desc                   = "Hisilicon Kirin SoCs' DRM Driver",
-       .date                   = "20150718",
-       .major                  = 1,
-       .minor                  = 0,
-};
-
 static int compare_of(struct device *dev, void *data)
 {
        return dev->of_node == data;
@@ -132,11 +100,10 @@ static int compare_of(struct device *dev, void *data)
 
 static int kirin_drm_bind(struct device *dev)
 {
-       struct drm_driver *driver = &kirin_drm_driver;
        struct drm_device *drm_dev;
        int ret;
 
-       drm_dev = drm_dev_alloc(driver, dev);
+       drm_dev = drm_dev_alloc(driver_data->driver, dev);
        if (IS_ERR(drm_dev))
                return PTR_ERR(drm_dev);
 
index 43be65f82a03dd6f65eafba30849b0b7edeb3f9f..fdbfc4a90f22a6e965ba3c677764e2d201b485a6 100644 (file)
@@ -42,6 +42,7 @@ struct kirin_drm_data {
        u32 num_planes;
        u32 prim_plane;
 
+       struct drm_driver *driver;
        const struct drm_crtc_helper_funcs *crtc_helper_funcs;
        const struct drm_crtc_funcs *crtc_funcs;
        const struct drm_plane_helper_funcs *plane_helper_funcs;