drivers/gpu/drm/openchrome/Makefile | 2 drivers/gpu/drm/openchrome/openchrome_crtc.c | 382 +----------------------- drivers/gpu/drm/openchrome/openchrome_cursor.c | 385 +++++++++++++++++++++++++ drivers/gpu/drm/openchrome/openchrome_drv.h | 25 + drivers/gpu/drm/openchrome/openchrome_fb.c | 164 +--------- drivers/gpu/drm/openchrome/openchrome_fbdev.c | 118 +++++++ drivers/gpu/drm/openchrome/openchrome_init.c | 36 ++ drivers/gpu/drm/openchrome/openchrome_ttm.c | 4 8 files changed, 602 insertions(+), 514 deletions(-)
New commits: commit d693feb416eff609e51ebb996efacf89141e81fe Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 18:01:57 2019 -0700 drm/openchrome: Version bumped to 3.1.18 Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h index 9e3b7759ed86..c34d78f5a2b9 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.h +++ b/drivers/gpu/drm/openchrome/openchrome_drv.h @@ -52,10 +52,10 @@ #define DRIVER_MAJOR 3 #define DRIVER_MINOR 1 -#define DRIVER_PATCHLEVEL 17 +#define DRIVER_PATCHLEVEL 18 #define DRIVER_NAME "openchrome" #define DRIVER_DESC "OpenChrome DRM for VIA Technologies Chrome IGP" -#define DRIVER_DATE "20191014" +#define DRIVER_DATE "20191016" #define DRIVER_AUTHOR "OpenChrome Project" commit 139b4b70b42443af71418abfa11d3465fe4b3ddd Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 18:01:29 2019 -0700 drm/openchrome: Move openchrome_mode_config_init() inside openchrome_fb.c Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c b/drivers/gpu/drm/openchrome/openchrome_fb.c index 7f9bb6814a5e..56b1da592556 100644 --- a/drivers/gpu/drm/openchrome/openchrome_fb.c +++ b/drivers/gpu/drm/openchrome/openchrome_fb.c @@ -117,6 +117,27 @@ static const struct drm_mode_config_funcs via_mode_funcs = { .output_poll_changed = via_output_poll_changed }; +void openchrome_mode_config_init( + struct openchrome_drm_private *dev_private) +{ + struct drm_device *dev = dev_private->dev; + + DRM_DEBUG_KMS("Entered %s.\n", __func__); + + drm_mode_config_init(dev); + + dev->mode_config.min_width = 0; + dev->mode_config.min_height = 0; + dev->mode_config.max_width = 2044; + dev->mode_config.max_height = 4096; + + dev->mode_config.funcs = &via_mode_funcs; + + dev->mode_config.preferred_depth = 24; + + DRM_DEBUG_KMS("Exiting %s.\n", __func__); +} + static struct fb_ops via_fb_ops = { .owner = THIS_MODULE, .fb_check_var = drm_fb_helper_check_var, @@ -231,24 +252,3 @@ exit: struct drm_fb_helper_funcs via_drm_fb_helper_funcs = { .fb_probe = via_fb_probe, }; - -void openchrome_mode_config_init( - struct openchrome_drm_private *dev_private) -{ - struct drm_device *dev = dev_private->dev; - - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - drm_mode_config_init(dev); - - dev->mode_config.min_width = 0; - dev->mode_config.min_height = 0; - dev->mode_config.max_width = 2044; - dev->mode_config.max_height = 4096; - - dev->mode_config.funcs = &via_mode_funcs; - - dev->mode_config.preferred_depth = 24; - - DRM_DEBUG_KMS("Exiting %s.\n", __func__); -} commit c586f890100ec8d292214e54c56a893c0137c3ec Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 17:22:56 2019 -0700 drm/openchrome: Move FBDEV code into openchrome_fbdev.c Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/Makefile b/drivers/gpu/drm/openchrome/Makefile index 73f688dde579..b7fc2ff9dc8d 100644 --- a/drivers/gpu/drm/openchrome/Makefile +++ b/drivers/gpu/drm/openchrome/Makefile @@ -12,6 +12,7 @@ openchrome-y := openchrome_analog.o \ openchrome_drv.o \ openchrome_encoder.o \ openchrome_fb.o \ + openchrome_fbdev.o \ openchrome_fp.o \ openchrome_hdmi.o \ openchrome_i2c.o \ diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h index a78ee673e1b3..9e3b7759ed86 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.h +++ b/drivers/gpu/drm/openchrome/openchrome_drv.h @@ -316,4 +316,6 @@ extern const struct drm_plane_funcs openchrome_cursor_drm_plane_funcs; extern const uint32_t openchrome_cursor_formats[]; extern const unsigned int openchrome_cursor_formats_size; +extern struct drm_fb_helper_funcs via_drm_fb_helper_funcs; + #endif /* _OPENCHROME_DRV_H */ diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c b/drivers/gpu/drm/openchrome/openchrome_fb.c index 836f3ba7b40f..7f9bb6814a5e 100644 --- a/drivers/gpu/drm/openchrome/openchrome_fb.c +++ b/drivers/gpu/drm/openchrome/openchrome_fb.c @@ -228,7 +228,7 @@ exit: return ret; } -static struct drm_fb_helper_funcs via_drm_fb_helper_funcs = { +struct drm_fb_helper_funcs via_drm_fb_helper_funcs = { .fb_probe = via_fb_probe, }; @@ -252,87 +252,3 @@ void openchrome_mode_config_init( DRM_DEBUG_KMS("Exiting %s.\n", __func__); } - -int via_fbdev_init(struct drm_device *dev) -{ - struct openchrome_drm_private *dev_private = dev->dev_private; - struct via_framebuffer_device *via_fbdev; - int bpp_sel = 32; - int ret = 0; - - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - via_fbdev = kzalloc(sizeof(struct via_framebuffer_device), - GFP_KERNEL); - if (!via_fbdev) { - ret = -ENOMEM; - goto exit; - } - - dev_private->via_fbdev = via_fbdev; - - drm_fb_helper_prepare(dev, &via_fbdev->helper, - &via_drm_fb_helper_funcs); - - ret = drm_fb_helper_init(dev, &via_fbdev->helper, - dev->mode_config.num_connector); - if (ret) { - goto free_fbdev; - } - - ret = drm_fb_helper_single_add_all_connectors(&via_fbdev->helper); - if (ret) { - goto free_fb_helper; - } - - drm_helper_disable_unused_functions(dev); - ret = drm_fb_helper_initial_config(&via_fbdev->helper, bpp_sel); - if (ret) { - goto free_fb_helper; - } - - goto exit; -free_fb_helper: - drm_fb_helper_fini(&via_fbdev->helper); -free_fbdev: - kfree(via_fbdev); -exit: - DRM_DEBUG_KMS("Exiting %s.\n", __func__); - return ret; -} - -void via_fbdev_fini(struct drm_device *dev) -{ - struct openchrome_drm_private *dev_private = dev->dev_private; - struct drm_fb_helper *fb_helper = &dev_private->via_fbdev->helper; - struct via_framebuffer *via_fb = &dev_private->via_fbdev->via_fb; - struct fb_info *info; - - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - if (!fb_helper) { - goto exit; - } - - info = fb_helper->fbdev; - if (info) { - unregister_framebuffer(info); - kfree(info->apertures); - framebuffer_release(info); - fb_helper->fbdev = NULL; - } - - if (via_fb->gem) { - drm_gem_object_put_unlocked(via_fb->gem); - via_fb->gem = NULL; - } - - drm_fb_helper_fini(&dev_private->via_fbdev->helper); - drm_framebuffer_cleanup(&dev_private->via_fbdev->via_fb.fb); - if (dev_private->via_fbdev) { - kfree(dev_private->via_fbdev); - dev_private->via_fbdev = NULL; - } -exit: - DRM_DEBUG_KMS("Exiting %s.\n", __func__); -} diff --git a/drivers/gpu/drm/openchrome/openchrome_fbdev.c b/drivers/gpu/drm/openchrome/openchrome_fbdev.c new file mode 100644 index 000000000000..58fe9c0398d3 --- /dev/null +++ b/drivers/gpu/drm/openchrome/openchrome_fbdev.c @@ -0,0 +1,118 @@ +/* + * Copyright 2012 James Simmons <jsimm...@infradead.org>. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <linux/fb.h> + +#include <drm/drm_crtc_helper.h> +#include <drm/drm_drv.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem.h> + +#include "openchrome_drv.h" + + +int via_fbdev_init(struct drm_device *dev) +{ + struct openchrome_drm_private *dev_private = dev->dev_private; + struct via_framebuffer_device *via_fbdev; + int bpp_sel = 32; + int ret = 0; + + DRM_DEBUG_KMS("Entered %s.\n", __func__); + + via_fbdev = kzalloc(sizeof(struct via_framebuffer_device), + GFP_KERNEL); + if (!via_fbdev) { + ret = -ENOMEM; + goto exit; + } + + dev_private->via_fbdev = via_fbdev; + + drm_fb_helper_prepare(dev, &via_fbdev->helper, + &via_drm_fb_helper_funcs); + + ret = drm_fb_helper_init(dev, &via_fbdev->helper, + dev->mode_config.num_connector); + if (ret) { + goto free_fbdev; + } + + ret = drm_fb_helper_single_add_all_connectors(&via_fbdev->helper); + if (ret) { + goto free_fb_helper; + } + + drm_helper_disable_unused_functions(dev); + ret = drm_fb_helper_initial_config(&via_fbdev->helper, bpp_sel); + if (ret) { + goto free_fb_helper; + } + + goto exit; +free_fb_helper: + drm_fb_helper_fini(&via_fbdev->helper); +free_fbdev: + kfree(via_fbdev); +exit: + DRM_DEBUG_KMS("Exiting %s.\n", __func__); + return ret; +} + +void via_fbdev_fini(struct drm_device *dev) +{ + struct openchrome_drm_private *dev_private = dev->dev_private; + struct drm_fb_helper *fb_helper = &dev_private-> + via_fbdev->helper; + struct via_framebuffer *via_fb = &dev_private-> + via_fbdev->via_fb; + struct fb_info *info; + + DRM_DEBUG_KMS("Entered %s.\n", __func__); + + if (!fb_helper) { + goto exit; + } + + info = fb_helper->fbdev; + if (info) { + unregister_framebuffer(info); + kfree(info->apertures); + framebuffer_release(info); + fb_helper->fbdev = NULL; + } + + if (via_fb->gem) { + drm_gem_object_put_unlocked(via_fb->gem); + via_fb->gem = NULL; + } + + drm_fb_helper_fini(&dev_private->via_fbdev->helper); + drm_framebuffer_cleanup(&dev_private->via_fbdev->via_fb.fb); + if (dev_private->via_fbdev) { + kfree(dev_private->via_fbdev); + dev_private->via_fbdev = NULL; + } +exit: + DRM_DEBUG_KMS("Exiting %s.\n", __func__); +} commit a70a803174d93c0aa817fc6cf5f9abf254dd6af8 Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 17:03:18 2019 -0700 drm/openchrome: Change how drm_crtc_init_with_planes() is invoked Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c index 867a9a14d51e..4249cc9910e5 100644 --- a/drivers/gpu/drm/openchrome/openchrome_crtc.c +++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c @@ -2295,17 +2295,28 @@ int via_crtc_init(struct drm_device *dev, uint32_t index) goto free_cursor; } - if (index) { + if (iga->index) { drm_crtc_helper_add(crtc, &openchrome_iga2_drm_crtc_helper_funcs); - ret = drm_crtc_init_with_planes(dev, crtc, primary, - cursor, &openchrome_iga2_drm_crtc_funcs, + ret = drm_crtc_init_with_planes(dev, crtc, + primary, cursor, + &openchrome_iga2_drm_crtc_funcs, NULL); - if (ret) { - DRM_ERROR("Failed to initialize CRTC!\n"); - goto cleanup_cursor; - } + } else { + drm_crtc_helper_add(crtc, + &openchrome_iga1_drm_crtc_helper_funcs); + ret = drm_crtc_init_with_planes(dev, crtc, + primary, cursor, + &openchrome_iga1_drm_crtc_funcs, + NULL); + } + if (ret) { + DRM_ERROR("Failed to initialize CRTC!\n"); + goto cleanup_cursor; + } + + if (iga->index) { iga->timings.htotal.count = ARRAY_SIZE(iga2_hor_total); iga->timings.htotal.regs = iga2_hor_total; @@ -2380,16 +2391,6 @@ int via_crtc_init(struct drm_device *dev, uint32_t index) iga->offset.count = ARRAY_SIZE(iga2_offset) - 1; iga->offset.regs = iga2_offset; } else { - drm_crtc_helper_add(crtc, - &openchrome_iga1_drm_crtc_helper_funcs); - ret = drm_crtc_init_with_planes(dev, crtc, primary, - cursor, &openchrome_iga1_drm_crtc_funcs, - NULL); - if (ret) { - DRM_ERROR("Failed to initialize CRTC!\n"); - goto cleanup_cursor; - } - iga->timings.htotal.count = ARRAY_SIZE(iga1_hor_total); iga->timings.htotal.regs = iga1_hor_total; commit 12721675e2eba407bcc6c8ce95877ec3c39e5818 Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 16:46:14 2019 -0700 drm/openchrome: Move VRAM initialization code into openchrome_init.c Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h index 33eb94aa251f..a78ee673e1b3 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.h +++ b/drivers/gpu/drm/openchrome/openchrome_drv.h @@ -263,6 +263,10 @@ extern int via_hdmi_audio; extern struct ttm_bo_driver openchrome_bo_driver; int openchrome_vram_detect(struct openchrome_drm_private *dev_private); +extern int openchrome_vram_init( + struct openchrome_drm_private *dev_private); +extern void openchrome_vram_fini( + struct openchrome_drm_private *dev_private); int openchrome_mmio_init(struct openchrome_drm_private *dev_private); void openchrome_mmio_fini(struct openchrome_drm_private *dev_private); void openchrome_graphics_unlock( @@ -276,10 +280,6 @@ extern void via_engine_init(struct drm_device *dev); int openchrome_dev_pm_ops_suspend(struct device *dev); int openchrome_dev_pm_ops_resume(struct device *dev); -extern int openchrome_vram_init( - struct openchrome_drm_private *dev_private); -extern void openchrome_vram_fini( - struct openchrome_drm_private *dev_private); void openchrome_mode_config_init( struct openchrome_drm_private *dev_private); diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c b/drivers/gpu/drm/openchrome/openchrome_fb.c index 53efa28efc8f..836f3ba7b40f 100644 --- a/drivers/gpu/drm/openchrome/openchrome_fb.c +++ b/drivers/gpu/drm/openchrome/openchrome_fb.c @@ -28,42 +28,6 @@ #include "openchrome_drv.h" -int openchrome_vram_init(struct openchrome_drm_private *dev_private) -{ - int ret = 0; - - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - /* Add an MTRR for the video RAM. */ - dev_private->vram_mtrr = arch_phys_wc_add( - dev_private->vram_start, - dev_private->vram_size); - - DRM_INFO("VIA Technologies Chrome IGP VRAM " - "Physical Address: 0x%08llx\n", - dev_private->vram_start); - DRM_INFO("VIA Technologies Chrome IGP VRAM " - "Size: %llu\n", - (unsigned long long) dev_private->vram_size >> 20); - - DRM_DEBUG_KMS("Exiting %s.\n", __func__); - return ret; -} - -void openchrome_vram_fini(struct openchrome_drm_private *dev_private) -{ - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - if (dev_private->vram_mtrr) { - arch_phys_wc_del(dev_private->vram_mtrr); - arch_io_free_memtype_wc(dev_private->vram_start, - dev_private->vram_size); - dev_private->vram_mtrr = 0; - } - - DRM_DEBUG_KMS("Exiting %s.\n", __func__); -} - static int via_user_framebuffer_create_handle(struct drm_framebuffer *fb, struct drm_file *file_priv, diff --git a/drivers/gpu/drm/openchrome/openchrome_init.c b/drivers/gpu/drm/openchrome/openchrome_init.c index 2dd287d3d86e..e49fdc0c1ad9 100644 --- a/drivers/gpu/drm/openchrome/openchrome_init.c +++ b/drivers/gpu/drm/openchrome/openchrome_init.c @@ -970,6 +970,42 @@ out_err: return ret; } +int openchrome_vram_init(struct openchrome_drm_private *dev_private) +{ + int ret = 0; + + DRM_DEBUG_KMS("Entered %s.\n", __func__); + + /* Add an MTRR for the video RAM. */ + dev_private->vram_mtrr = arch_phys_wc_add( + dev_private->vram_start, + dev_private->vram_size); + + DRM_INFO("VIA Technologies Chrome IGP VRAM " + "Physical Address: 0x%08llx\n", + dev_private->vram_start); + DRM_INFO("VIA Technologies Chrome IGP VRAM " + "Size: %llu\n", + (unsigned long long) dev_private->vram_size >> 20); + + DRM_DEBUG_KMS("Exiting %s.\n", __func__); + return ret; +} + +void openchrome_vram_fini(struct openchrome_drm_private *dev_private) +{ + DRM_DEBUG_KMS("Entered %s.\n", __func__); + + if (dev_private->vram_mtrr) { + arch_phys_wc_del(dev_private->vram_mtrr); + arch_io_free_memtype_wc(dev_private->vram_start, + dev_private->vram_size); + dev_private->vram_mtrr = 0; + } + + DRM_DEBUG_KMS("Exiting %s.\n", __func__); +} + int openchrome_mmio_init( struct openchrome_drm_private *dev_private) { commit 215876a8252369c73d9a88b894aab4e1c0e1d59e Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 16:45:19 2019 -0700 drm/openchrome: Use <drm/ttm/*.h> rather than "ttm/*.h" for TTM headers Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h index 26c51025ff4c..33eb94aa251f 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.h +++ b/drivers/gpu/drm/openchrome/openchrome_drv.h @@ -40,9 +40,9 @@ #include <drm/drm_ioctl.h> #include <drm/drm_plane.h> -#include "ttm/ttm_bo_api.h" -#include "ttm/ttm_bo_driver.h" -#include "ttm/ttm_placement.h" +#include <drm/ttm/ttm_bo_api.h> +#include <drm/ttm/ttm_bo_driver.h> +#include <drm/ttm/ttm_placement.h> #include <drm/via_drm.h> commit 4668841359f0e23355893d681a68c51588fd34ad Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 16:42:26 2019 -0700 drm/openchrome: Add PCI ID and TTM headers to openchrome_ttm.c Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_ttm.c b/drivers/gpu/drm/openchrome/openchrome_ttm.c index 7ecfd15daee1..cf258d21774d 100644 --- a/drivers/gpu/drm/openchrome/openchrome_ttm.c +++ b/drivers/gpu/drm/openchrome/openchrome_ttm.c @@ -35,6 +35,10 @@ * */ +#include <linux/pci.h> + +#include <drm/ttm/ttm_bo_api.h> +#include <drm/ttm/ttm_bo_driver.h> #include "openchrome_drv.h" commit a80a0df53cf363fdcfac7f06c3f0888b8ba0f600 Author: Kevin Brace <kevinbr...@gmx.com> Date: Wed Oct 16 16:41:28 2019 -0700 drm/openchrome: Move cursor plane code into openchrome_cursor.c This happened thanks to universal plane related restructuring of DRM / KMS interface. Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/Makefile b/drivers/gpu/drm/openchrome/Makefile index 261c40f8e3eb..73f688dde579 100644 --- a/drivers/gpu/drm/openchrome/Makefile +++ b/drivers/gpu/drm/openchrome/Makefile @@ -7,6 +7,7 @@ openchrome-y := openchrome_analog.o \ openchrome_clocks.o \ openchrome_crtc.o \ openchrome_crtc_hw.o \ + openchrome_cursor.o \ openchrome_display.o \ openchrome_drv.o \ openchrome_encoder.o \ diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c index d300c862c034..867a9a14d51e 100644 --- a/drivers/gpu/drm/openchrome/openchrome_crtc.c +++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c @@ -168,135 +168,6 @@ static void via_iga2_set_color_depth( DRM_DEBUG_KMS("Exiting %s.\n", __func__); } -static void openchrome_hide_cursor(struct drm_crtc *crtc) -{ - struct drm_device *dev = crtc->dev; - struct via_crtc *iga = container_of(crtc, struct via_crtc, base); - struct openchrome_drm_private *dev_private = - crtc->dev->dev_private; - uint32_t temp; - - switch (dev->pdev->device) { - case PCI_DEVICE_ID_VIA_PM800: - case PCI_DEVICE_ID_VIA_VT3157: - case PCI_DEVICE_ID_VIA_VT3343: - case PCI_DEVICE_ID_VIA_P4M900: - case PCI_DEVICE_ID_VIA_VT1122: - case PCI_DEVICE_ID_VIA_VX875: - case PCI_DEVICE_ID_VIA_VX900_VGA: - if (iga->index) { - temp = VIA_READ(HI_CONTROL); - VIA_WRITE(HI_CONTROL, temp & 0xFFFFFFFA); - } else { - temp = VIA_READ(PRIM_HI_CTRL); - VIA_WRITE(PRIM_HI_CTRL, temp & 0xFFFFFFFA); - } - - break; - default: - temp = VIA_READ(HI_CONTROL); - VIA_WRITE(HI_CONTROL, temp & 0xFFFFFFFA); - break; - } -} - -static void openchrome_show_cursor(struct drm_crtc *crtc) -{ - struct drm_device *dev = crtc->dev; - struct via_crtc *iga = container_of(crtc, struct via_crtc, base); - struct openchrome_drm_private *dev_private = - crtc->dev->dev_private; - - switch (dev->pdev->device) { - case PCI_DEVICE_ID_VIA_PM800: - case PCI_DEVICE_ID_VIA_VT3157: - case PCI_DEVICE_ID_VIA_VT3343: - case PCI_DEVICE_ID_VIA_P4M900: - case PCI_DEVICE_ID_VIA_VT1122: - case PCI_DEVICE_ID_VIA_VX875: - case PCI_DEVICE_ID_VIA_VX900_VGA: - /* Program Hardware Icon (HI) FIFO, foreground, and - * background colors. */ - if (iga->index) { - VIA_WRITE(HI_TRANSPARENT_COLOR, 0x00000000); - VIA_WRITE(HI_INVTCOLOR, 0x00FFFFFF); - VIA_WRITE(ALPHA_V3_PREFIFO_CONTROL, 0x000E0000); - VIA_WRITE(ALPHA_V3_FIFO_CONTROL, 0x0E0F0000); - } else { - VIA_WRITE(PRIM_HI_TRANSCOLOR, 0x00000000); - VIA_WRITE(PRIM_HI_INVTCOLOR, 0x00FFFFFF); - VIA_WRITE(V327_HI_INVTCOLOR, 0x00FFFFFF); - VIA_WRITE(PRIM_HI_FIFO, 0x0D000D0F); - } - - break; - default: - VIA_WRITE(HI_TRANSPARENT_COLOR, 0x00000000); - VIA_WRITE(HI_INVTCOLOR, 0x00FFFFFF); - VIA_WRITE(ALPHA_V3_PREFIFO_CONTROL, 0x000E0000); - VIA_WRITE(ALPHA_V3_FIFO_CONTROL, 0xE0F0000); - break; - } - - switch (dev->pdev->device) { - case PCI_DEVICE_ID_VIA_PM800: - case PCI_DEVICE_ID_VIA_VT3157: - case PCI_DEVICE_ID_VIA_VT3343: - case PCI_DEVICE_ID_VIA_P4M900: - case PCI_DEVICE_ID_VIA_VT1122: - case PCI_DEVICE_ID_VIA_VX875: - case PCI_DEVICE_ID_VIA_VX900_VGA: - /* Turn on Hardware icon Cursor */ - if (iga->index) { - VIA_WRITE(HI_CONTROL, 0xB6000005); - } else { - VIA_WRITE(PRIM_HI_CTRL, 0x36000005); - } - - break; - default: - if (iga->index) { - VIA_WRITE(HI_CONTROL, 0xB6000005); - } else { - VIA_WRITE(HI_CONTROL, 0x36000005); - } - - break; - } -} - -static void openchrome_cursor_address(struct drm_crtc *crtc) -{ - struct drm_device *dev = crtc->dev; - struct via_crtc *iga = container_of(crtc, struct via_crtc, base); - struct openchrome_drm_private *dev_private = - crtc->dev->dev_private; - - if (!iga->cursor_bo->kmap.bo) { - return; - } - - switch (dev->pdev->device) { - case PCI_DEVICE_ID_VIA_PM800: - case PCI_DEVICE_ID_VIA_VT3157: - case PCI_DEVICE_ID_VIA_VT3343: - case PCI_DEVICE_ID_VIA_P4M900: - case PCI_DEVICE_ID_VIA_VT1122: - case PCI_DEVICE_ID_VIA_VX875: - case PCI_DEVICE_ID_VIA_VX900_VGA: - /* Program the HI offset. */ - if (iga->index) { - VIA_WRITE(HI_FBOFFSET, iga->cursor_bo->kmap.bo->offset); - } else { - VIA_WRITE(PRIM_HI_FBOFFSET, iga->cursor_bo->kmap.bo->offset); - } - break; - default: - VIA_WRITE(HI_FBOFFSET, iga->cursor_bo->kmap.bo->offset); - break; - } -} - static int via_iga1_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t size, @@ -2371,204 +2242,6 @@ static const uint32_t openchrome_primary_formats[] = { DRM_FORMAT_RGB332, }; -static void openchrome_set_hi_location(struct drm_crtc *crtc, - int crtc_x, - int crtc_y) -{ - struct drm_device *dev = crtc->dev; - struct via_crtc *iga = container_of(crtc, - struct via_crtc, base); - struct openchrome_drm_private *dev_private = - crtc->dev->dev_private; - uint32_t location_x = 0, location_y = 0; - uint32_t offset_x = 0, offset_y = 0; - - if (crtc_x < 0) { - offset_x = -crtc_x; - } else { - location_x = crtc_x; - } - - if (crtc_y < 0) { - offset_y = -crtc_y; - } else { - location_y = crtc_y; - } - - switch (dev->pdev->device) { - case PCI_DEVICE_ID_VIA_PM800: - case PCI_DEVICE_ID_VIA_VT3157: - case PCI_DEVICE_ID_VIA_VT3343: - case PCI_DEVICE_ID_VIA_P4M900: - case PCI_DEVICE_ID_VIA_VT1122: - case PCI_DEVICE_ID_VIA_VX875: - case PCI_DEVICE_ID_VIA_VX900_VGA: - if (iga->index) { - VIA_WRITE(HI_POSSTART, - (((location_x & 0x07ff) << 16) | - (location_y & 0x07ff))); - VIA_WRITE(HI_CENTEROFFSET, - (((offset_x & 0x07ff) << 16) | - (offset_y & 0x07ff))); - } else { - VIA_WRITE(PRIM_HI_POSSTART, - (((location_x & 0x07ff) << 16) | - (location_y & 0x07ff))); - VIA_WRITE(PRIM_HI_CENTEROFFSET, - (((offset_x & 0x07ff) << 16) | - (offset_y & 0x07ff))); - } - - break; - default: - VIA_WRITE(HI_POSSTART, - (((location_x & 0x07ff) << 16) | - (location_y & 0x07ff))); - VIA_WRITE(HI_CENTEROFFSET, - (((offset_x & 0x07ff) << 16) | - (offset_y & 0x07ff))); - break; - } -} - -static int openchrome_cursor_update_plane(struct drm_plane *plane, - struct drm_crtc *crtc, - struct drm_framebuffer *fb, - int crtc_x, int crtc_y, - unsigned int crtc_w, - unsigned int crtc_h, - uint32_t src_x, uint32_t src_y, - uint32_t src_w, uint32_t src_h, - struct drm_modeset_acquire_ctx *ctx) -{ - struct drm_device *dev = plane->dev; - struct via_crtc *iga = container_of(crtc, struct via_crtc, base); - struct via_framebuffer *via_fb; - struct openchrome_bo *user_bo; - struct drm_gem_object *gem; - uint32_t *user_bo_src, *cursor_dst; - bool is_iomem; - uint32_t i; - uint32_t width, height; - uint32_t max_width = 64, max_height = 64; - int ret = 0; - - if (!crtc) { - DRM_ERROR("Invalid CRTC!\n"); - ret = -EINVAL; - goto exit; - } - - if (!crtc->enabled) { - DRM_ERROR("CRTC is currently disabled!\n"); - ret = -EINVAL; - goto exit; - } - - if (!fb) { - DRM_ERROR("Invalid frame buffer!\n"); - ret = -EINVAL; - goto exit; - } - - if ((fb->width != 64) || (fb->height != 64)) { - DRM_ERROR("Cursor dimensions are expected to be " - "64 x 64.\n"); - ret = -EINVAL; - goto exit; - } - - if (fb->width != fb->height) { - DRM_ERROR("Hardware cursor is expected to have " - "square dimensions.\n"); - ret = -EINVAL; - goto exit; - } - - if (fb != crtc->cursor->fb) { - if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) || - (dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) { - if ((fb->width == 64) || (fb->height == 64)) { - max_width >>= 1; - max_height >>= 1; - } - } - - width = fb->width; - height = fb->height; - - via_fb = container_of(fb, struct via_framebuffer, fb); - gem = via_fb->gem; - user_bo = container_of(gem, struct openchrome_bo, gem); - ret = ttm_bo_kmap(&user_bo->ttm_bo, 0, - user_bo->ttm_bo.num_pages, - &user_bo->kmap); - if (ret) { - goto exit; - } - - user_bo_src = ttm_kmap_obj_virtual(&user_bo->kmap, - &is_iomem); - cursor_dst = - ttm_kmap_obj_virtual(&iga->cursor_bo->kmap, - &is_iomem); - memset_io(cursor_dst, 0x0, - iga->cursor_bo->kmap.bo->mem.size); - for (i = 0; i < height; i++) { - __iowrite32_copy(cursor_dst, user_bo_src, width); - user_bo_src += width; - cursor_dst += max_width; - } - - ttm_bo_kunmap(&user_bo->kmap); - - openchrome_cursor_address(crtc); - } else { - crtc->cursor_x = crtc_x; - crtc->cursor_y = crtc_y; - openchrome_set_hi_location(crtc, crtc_x, crtc_y); - } - - openchrome_show_cursor(crtc); -exit: - return ret; -} - -static int openchrome_cursor_disable_plane(struct drm_plane *plane, - struct drm_modeset_acquire_ctx *ctx) -{ - if (plane->crtc) { - openchrome_hide_cursor(plane->crtc); - } - - if (plane->fb) { - drm_framebuffer_put(plane->fb); - plane->fb = NULL; - } - - return 0; -} - -static void openchrome_cursor_destroy(struct drm_plane *plane) -{ - if (plane->crtc) { - openchrome_hide_cursor(plane->crtc); - } - - drm_plane_cleanup(plane); -} - -static const struct -drm_plane_funcs openchrome_cursor_drm_plane_funcs = { - .update_plane = openchrome_cursor_update_plane, - .disable_plane = openchrome_cursor_disable_plane, - .destroy = openchrome_cursor_destroy, -}; - -static const uint32_t openchrome_cursor_formats[] = { - DRM_FORMAT_ARGB8888 -}; - int via_crtc_init(struct drm_device *dev, uint32_t index) { struct openchrome_drm_private *dev_private = @@ -2614,7 +2287,7 @@ int via_crtc_init(struct drm_device *dev, uint32_t index) ret = drm_universal_plane_init(dev, cursor, possible_crtcs, &openchrome_cursor_drm_plane_funcs, openchrome_cursor_formats, - ARRAY_SIZE(openchrome_cursor_formats), + openchrome_cursor_formats_size, NULL, DRM_PLANE_TYPE_CURSOR, NULL); if (ret) { DRM_ERROR("Failed to initialize a cursor " diff --git a/drivers/gpu/drm/openchrome/openchrome_cursor.c b/drivers/gpu/drm/openchrome/openchrome_cursor.c new file mode 100644 index 000000000000..878274ca84fd --- /dev/null +++ b/drivers/gpu/drm/openchrome/openchrome_cursor.c @@ -0,0 +1,385 @@ +/* + * Copyright © 2019 Kevin Brace + * Copyright 2012 James Simmons <jsimm...@infradead.org>. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including + * the next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/* + * Author(s): + * + * Kevin Brace <kevinbr...@gmx.com> + * James Simmons <jsimm...@infradead.org> + */ + +#include <linux/pci_ids.h> + +#include <drm/drm_crtc.h> +#include <drm/drm_fourcc.h> +#include <drm/drm_framebuffer.h> +#include <drm/drm_mode.h> +#include <drm/drm_modeset_helper_vtables.h> +#include <drm/drm_plane.h> +#include <drm/drm_plane_helper.h> + +#include <drm/ttm/ttm_bo_api.h> +#include <drm/ttm/ttm_bo_driver.h> + +#include "openchrome_drv.h" + + +static void openchrome_hide_cursor(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct via_crtc *iga = container_of(crtc, + struct via_crtc, base); + struct openchrome_drm_private *dev_private = + crtc->dev->dev_private; + uint32_t temp; + + switch (dev->pdev->device) { + case PCI_DEVICE_ID_VIA_PM800: + case PCI_DEVICE_ID_VIA_VT3157: + case PCI_DEVICE_ID_VIA_VT3343: + case PCI_DEVICE_ID_VIA_P4M900: + case PCI_DEVICE_ID_VIA_VT1122: + case PCI_DEVICE_ID_VIA_VX875: + case PCI_DEVICE_ID_VIA_VX900_VGA: + if (iga->index) { + temp = VIA_READ(HI_CONTROL); + VIA_WRITE(HI_CONTROL, temp & 0xFFFFFFFA); + } else { + temp = VIA_READ(PRIM_HI_CTRL); + VIA_WRITE(PRIM_HI_CTRL, temp & 0xFFFFFFFA); + } + + break; + default: + temp = VIA_READ(HI_CONTROL); + VIA_WRITE(HI_CONTROL, temp & 0xFFFFFFFA); + break; + } +} + +static void openchrome_show_cursor(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct via_crtc *iga = container_of(crtc, + struct via_crtc, base); + struct openchrome_drm_private *dev_private = + crtc->dev->dev_private; + + switch (dev->pdev->device) { + case PCI_DEVICE_ID_VIA_PM800: + case PCI_DEVICE_ID_VIA_VT3157: + case PCI_DEVICE_ID_VIA_VT3343: + case PCI_DEVICE_ID_VIA_P4M900: + case PCI_DEVICE_ID_VIA_VT1122: + case PCI_DEVICE_ID_VIA_VX875: + case PCI_DEVICE_ID_VIA_VX900_VGA: + /* Program Hardware Icon (HI) FIFO, foreground, and + * background colors. */ + if (iga->index) { + VIA_WRITE(HI_TRANSPARENT_COLOR, 0x00000000); + VIA_WRITE(HI_INVTCOLOR, 0x00FFFFFF); + VIA_WRITE(ALPHA_V3_PREFIFO_CONTROL, + 0x000E0000); + VIA_WRITE(ALPHA_V3_FIFO_CONTROL, 0x0E0F0000); + } else { + VIA_WRITE(PRIM_HI_TRANSCOLOR, 0x00000000); + VIA_WRITE(PRIM_HI_INVTCOLOR, 0x00FFFFFF); + VIA_WRITE(V327_HI_INVTCOLOR, 0x00FFFFFF); + VIA_WRITE(PRIM_HI_FIFO, 0x0D000D0F); + } + + break; + default: + VIA_WRITE(HI_TRANSPARENT_COLOR, 0x00000000); + VIA_WRITE(HI_INVTCOLOR, 0x00FFFFFF); + VIA_WRITE(ALPHA_V3_PREFIFO_CONTROL, 0x000E0000); + VIA_WRITE(ALPHA_V3_FIFO_CONTROL, 0xE0F0000); + break; + } + + switch (dev->pdev->device) { + case PCI_DEVICE_ID_VIA_PM800: + case PCI_DEVICE_ID_VIA_VT3157: + case PCI_DEVICE_ID_VIA_VT3343: + case PCI_DEVICE_ID_VIA_P4M900: + case PCI_DEVICE_ID_VIA_VT1122: + case PCI_DEVICE_ID_VIA_VX875: + case PCI_DEVICE_ID_VIA_VX900_VGA: + /* Turn on Hardware icon Cursor */ + if (iga->index) { + VIA_WRITE(HI_CONTROL, 0xB6000005); + } else { + VIA_WRITE(PRIM_HI_CTRL, 0x36000005); + } + + break; + default: + if (iga->index) { + VIA_WRITE(HI_CONTROL, 0xB6000005); + } else { + VIA_WRITE(HI_CONTROL, 0x36000005); + } + + break; + } +} + +static void openchrome_cursor_address(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct via_crtc *iga = container_of(crtc, + struct via_crtc, base); + struct openchrome_drm_private *dev_private = + crtc->dev->dev_private; + + if (!iga->cursor_bo->kmap.bo) { + return; + } + + switch (dev->pdev->device) { + case PCI_DEVICE_ID_VIA_PM800: + case PCI_DEVICE_ID_VIA_VT3157: + case PCI_DEVICE_ID_VIA_VT3343: + case PCI_DEVICE_ID_VIA_P4M900: + case PCI_DEVICE_ID_VIA_VT1122: + case PCI_DEVICE_ID_VIA_VX875: + case PCI_DEVICE_ID_VIA_VX900_VGA: + /* Program the HI offset. */ + if (iga->index) { + VIA_WRITE(HI_FBOFFSET, + iga->cursor_bo->kmap.bo->offset); + } else { + VIA_WRITE(PRIM_HI_FBOFFSET, + iga->cursor_bo->kmap.bo->offset); + } + break; + default: + VIA_WRITE(HI_FBOFFSET, + iga->cursor_bo->kmap.bo->offset); + break; + } +} + +static void openchrome_set_hi_location(struct drm_crtc *crtc, + int crtc_x, + int crtc_y) +{ + struct drm_device *dev = crtc->dev; + struct via_crtc *iga = container_of(crtc, + struct via_crtc, base); + struct openchrome_drm_private *dev_private = + crtc->dev->dev_private; + uint32_t location_x = 0, location_y = 0; + uint32_t offset_x = 0, offset_y = 0; + + if (crtc_x < 0) { + offset_x = -crtc_x; + } else { + location_x = crtc_x; + } + + if (crtc_y < 0) { + offset_y = -crtc_y; + } else { + location_y = crtc_y; + } + + switch (dev->pdev->device) { + case PCI_DEVICE_ID_VIA_PM800: + case PCI_DEVICE_ID_VIA_VT3157: + case PCI_DEVICE_ID_VIA_VT3343: + case PCI_DEVICE_ID_VIA_P4M900: + case PCI_DEVICE_ID_VIA_VT1122: + case PCI_DEVICE_ID_VIA_VX875: + case PCI_DEVICE_ID_VIA_VX900_VGA: + if (iga->index) { + VIA_WRITE(HI_POSSTART, + (((location_x & 0x07ff) << 16) | + (location_y & 0x07ff))); + VIA_WRITE(HI_CENTEROFFSET, + (((offset_x & 0x07ff) << 16) | + (offset_y & 0x07ff))); + } else { + VIA_WRITE(PRIM_HI_POSSTART, + (((location_x & 0x07ff) << 16) | + (location_y & 0x07ff))); + VIA_WRITE(PRIM_HI_CENTEROFFSET, + (((offset_x & 0x07ff) << 16) | + (offset_y & 0x07ff))); + } + + break; + default: + VIA_WRITE(HI_POSSTART, + (((location_x & 0x07ff) << 16) | + (location_y & 0x07ff))); + VIA_WRITE(HI_CENTEROFFSET, + (((offset_x & 0x07ff) << 16) | + (offset_y & 0x07ff))); + break; + } +} + +static int openchrome_cursor_update_plane(struct drm_plane *plane, + struct drm_crtc *crtc, + struct drm_framebuffer *fb, + int crtc_x, int crtc_y, + unsigned int crtc_w, + unsigned int crtc_h, + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h, + struct drm_modeset_acquire_ctx *ctx) +{ + struct drm_device *dev = plane->dev; + struct via_crtc *iga = container_of(crtc, + struct via_crtc, base); + struct via_framebuffer *via_fb; + struct openchrome_bo *user_bo; + struct drm_gem_object *gem; + uint32_t *user_bo_src, *cursor_dst; + bool is_iomem; + uint32_t i; + uint32_t width, height; + uint32_t max_width = 64, max_height = 64; + int ret = 0; + + if (!crtc) { + DRM_ERROR("Invalid CRTC!\n"); + ret = -EINVAL; + goto exit; + } + + if (!crtc->enabled) { + DRM_ERROR("CRTC is currently disabled!\n"); + ret = -EINVAL; + goto exit; + } + + if (!fb) { + DRM_ERROR("Invalid frame buffer!\n"); + ret = -EINVAL; + goto exit; + } + + if ((fb->width != 64) || (fb->height != 64)) { + DRM_ERROR("Cursor dimensions are expected to be " + "64 x 64.\n"); + ret = -EINVAL; + goto exit; + } + + if (fb->width != fb->height) { + DRM_ERROR("Hardware cursor is expected to have " + "square dimensions.\n"); + ret = -EINVAL; + goto exit; + } + + if (fb != crtc->cursor->fb) { + if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) || + (dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) { + if ((fb->width == 64) || (fb->height == 64)) { + max_width >>= 1; + max_height >>= 1; + } + } + + width = fb->width; + height = fb->height; + + via_fb = container_of(fb, struct via_framebuffer, fb); + gem = via_fb->gem; + user_bo = container_of(gem, struct openchrome_bo, gem); + ret = ttm_bo_kmap(&user_bo->ttm_bo, 0, + user_bo->ttm_bo.num_pages, + &user_bo->kmap); + if (ret) { + goto exit; + } + + user_bo_src = ttm_kmap_obj_virtual(&user_bo->kmap, + &is_iomem); + cursor_dst = + ttm_kmap_obj_virtual(&iga->cursor_bo->kmap, + &is_iomem); + memset_io(cursor_dst, 0x0, + iga->cursor_bo->kmap.bo->mem.size); + for (i = 0; i < height; i++) { + __iowrite32_copy(cursor_dst, user_bo_src, + width); + user_bo_src += width; + cursor_dst += max_width; + } + + ttm_bo_kunmap(&user_bo->kmap); + + openchrome_cursor_address(crtc); + } else { + crtc->cursor_x = crtc_x; + crtc->cursor_y = crtc_y; + openchrome_set_hi_location(crtc, crtc_x, crtc_y); + } + + openchrome_show_cursor(crtc); +exit: + return ret; +} + +static int openchrome_cursor_disable_plane(struct drm_plane *plane, + struct drm_modeset_acquire_ctx *ctx) +{ + if (plane->crtc) { + openchrome_hide_cursor(plane->crtc); + } + + if (plane->fb) { + drm_framebuffer_put(plane->fb); + plane->fb = NULL; + } + + return 0; +} + +static void openchrome_cursor_destroy(struct drm_plane *plane) +{ + if (plane->crtc) { + openchrome_hide_cursor(plane->crtc); + } + + drm_plane_cleanup(plane); +} + +const struct drm_plane_funcs openchrome_cursor_drm_plane_funcs = { + .update_plane = openchrome_cursor_update_plane, + .disable_plane = openchrome_cursor_disable_plane, + .destroy = openchrome_cursor_destroy, +}; + +const uint32_t openchrome_cursor_formats[] = { + DRM_FORMAT_ARGB8888, +}; + +const unsigned int openchrome_cursor_formats_size = + ARRAY_SIZE(openchrome_cursor_formats); diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h index 349453078091..26c51025ff4c 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.h +++ b/drivers/gpu/drm/openchrome/openchrome_drv.h @@ -38,6 +38,7 @@ #include <drm/drm_gem.h> #include <drm/drm_ioctl.h> +#include <drm/drm_plane.h> #include "ttm/ttm_bo_api.h" #include "ttm/ttm_bo_driver.h" @@ -311,4 +312,8 @@ void openchrome_transmitter_display_source( struct openchrome_drm_private *dev_private, u32 di_port, int index); +extern const struct drm_plane_funcs openchrome_cursor_drm_plane_funcs; +extern const uint32_t openchrome_cursor_formats[]; +extern const unsigned int openchrome_cursor_formats_size; + #endif /* _OPENCHROME_DRV_H */ commit 1b5aca04bc5025db104f50df79f220d0f8b16422 Author: Kevin Brace <kevinbr...@gmx.com> Date: Tue Oct 15 17:19:55 2019 -0700 drm/openchrome: Rename via_cursor_address() to openchrome_cursor_address() Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c index 9e9fb0bbf3cd..d300c862c034 100644 --- a/drivers/gpu/drm/openchrome/openchrome_crtc.c +++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c @@ -265,7 +265,7 @@ static void openchrome_show_cursor(struct drm_crtc *crtc) } } -static void via_cursor_address(struct drm_crtc *crtc) +static void openchrome_cursor_address(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; struct via_crtc *iga = container_of(crtc, struct via_crtc, base); @@ -2522,7 +2522,7 @@ static int openchrome_cursor_update_plane(struct drm_plane *plane, ttm_bo_kunmap(&user_bo->kmap); - via_cursor_address(crtc); + openchrome_cursor_address(crtc); } else { crtc->cursor_x = crtc_x; crtc->cursor_y = crtc_y; commit e192035ff89293307f86d3ca98da5b4cbb7e6320 Author: Kevin Brace <kevinbr...@gmx.com> Date: Tue Oct 15 17:17:28 2019 -0700 drm/openchrome: Rename via_hide_cursor() to openchrome_hide_cursor() Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c index 8c352b49c7d4..9e9fb0bbf3cd 100644 --- a/drivers/gpu/drm/openchrome/openchrome_crtc.c +++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c @@ -168,7 +168,7 @@ static void via_iga2_set_color_depth( DRM_DEBUG_KMS("Exiting %s.\n", __func__); } -static void via_hide_cursor(struct drm_crtc *crtc) +static void openchrome_hide_cursor(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; struct via_crtc *iga = container_of(crtc, struct via_crtc, base); @@ -2538,7 +2538,7 @@ static int openchrome_cursor_disable_plane(struct drm_plane *plane, struct drm_modeset_acquire_ctx *ctx) { if (plane->crtc) { - via_hide_cursor(plane->crtc); + openchrome_hide_cursor(plane->crtc); } if (plane->fb) { @@ -2552,7 +2552,7 @@ static int openchrome_cursor_disable_plane(struct drm_plane *plane, static void openchrome_cursor_destroy(struct drm_plane *plane) { if (plane->crtc) { - via_hide_cursor(plane->crtc); + openchrome_hide_cursor(plane->crtc); } drm_plane_cleanup(plane); commit 4d8653644a65845882b0df98c193980a9b0c348d Author: Kevin Brace <kevinbr...@gmx.com> Date: Tue Oct 15 17:07:19 2019 -0700 drm/openchrome: Rename via_show_cursor() to openchrome_show_cursor() Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c index 795368e68fd6..8c352b49c7d4 100644 --- a/drivers/gpu/drm/openchrome/openchrome_crtc.c +++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c @@ -200,7 +200,7 @@ static void via_hide_cursor(struct drm_crtc *crtc) } } -static void via_show_cursor(struct drm_crtc *crtc) +static void openchrome_show_cursor(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; struct via_crtc *iga = container_of(crtc, struct via_crtc, base); @@ -2529,7 +2529,7 @@ static int openchrome_cursor_update_plane(struct drm_plane *plane, openchrome_set_hi_location(crtc, crtc_x, crtc_y); } - via_show_cursor(crtc); + openchrome_show_cursor(crtc); exit: return ret; } commit 6b39e5a08e9731f19bc92748b539b439b1a05800 Author: Kevin Brace <kevinbr...@gmx.com> Date: Tue Oct 15 17:04:00 2019 -0700 drm/openchrome: Stop accessing hardware cursor from mode setting callbacks Since cursor plane is now in use, hardware cursor should not be accessed from primary plane related mode setting callbacks. Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c index 5dbe22f9fcf0..795368e68fd6 100644 --- a/drivers/gpu/drm/openchrome/openchrome_crtc.c +++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c @@ -1750,9 +1750,6 @@ via_iga1_crtc_disable(struct drm_crtc *crtc) { DRM_DEBUG_KMS("Entered %s.\n", __func__); - /* Turn off the cursor */ - via_hide_cursor(crtc); - via_iga1_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); DRM_DEBUG_KMS("Exiting %s.\n", __func__); @@ -1957,12 +1954,6 @@ via_iga1_crtc_mode_set(struct drm_crtc *crtc, } ret = via_iga1_crtc_mode_set_base(crtc, x, y, fb); - - /* Specify the cursor pattern. */ - via_cursor_address(crtc); - - /* Turn off the cursor. */ - via_hide_cursor(crtc); exit: DRM_DEBUG_KMS("Exiting %s.\n", __func__); return ret; @@ -2057,9 +2048,6 @@ via_iga2_crtc_disable(struct drm_crtc *crtc) { DRM_DEBUG_KMS("Entered %s.\n", __func__); - /* Turn off the cursor */ - via_hide_cursor(crtc); - via_iga2_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); DRM_DEBUG_KMS("Exiting %s.\n", __func__); @@ -2295,12 +2283,6 @@ via_iga2_crtc_mode_set(struct drm_crtc *crtc, } ret = via_iga2_crtc_mode_set_base(crtc, x, y, fb); - - /* Specify the cursor pattern. */ - via_cursor_address(crtc); - - /* Turn off the cursor. */ - via_hide_cursor(crtc); exit: DRM_DEBUG_KMS("Exiting %s.\n", __func__); return ret; _______________________________________________ openchrome-devel mailing list openchrome-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/openchrome-devel