atomic modesetting for cirrus v2
Subsystems (2)
cover atomic modesetting for cirrus v2
Hello,
The v2 incorporates the feedback on v1 [1] and rebases the series to master. We no longer force 32bpp, fix incorrect error handling during plane initialization, and drom some irrelevant patches.
[1] https://lists.freedesktop.org/archives/dri-devel/2017-August/150703.html
Dominik Behr (1):
drm/cirrus: initialize start and size fields
Varad Gautam (9):
drm/cirrus: split out bo unpinning from cirrus_bo_push_sysram drm/cirrus: add drm_read to cirrus_driver_fops drm/cirrus: do not disable outputs on fbdev init for atomic. drm/cirrus: use universal plane interfaces for primary plane drm/cirrus: use atomic transition helpers for plane and crtc drm/cirrus: send vblank on crtc atomic_flush drm/cirrus: use atomic handlers for plane and crtc drm/cirrus: implement atomic hardware cursor support drm/cirrus: advertise DRIVER_ATOMIC
Zach Reizner (2):
drm/cirrus: hardcode vram size
drm/cirrus: implement PRIME export for cirrus
drivers/gpu/drm/cirrus/Makefile | 2 +- drivers/gpu/drm/cirrus/cirrus_drv.c | 13 +- drivers/gpu/drm/cirrus/cirrus_drv.h | 25 ++ drivers/gpu/drm/cirrus/cirrus_fbdev.c | 6 +- drivers/gpu/drm/cirrus/cirrus_main.c | 23 +- drivers/gpu/drm/cirrus/cirrus_mode.c | 682 ++++++++++++++++++++++++++-------- drivers/gpu/drm/cirrus/cirrus_prime.c | 63 ++++ drivers/gpu/drm/cirrus/cirrus_ttm.c | 55 ++- 8 files changed, 705 insertions(+), 164 deletions(-) create mode 100644 drivers/gpu/drm/cirrus/cirrus_prime.c
Thanks,
Varad
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/12 drm/cirrus: split out bo unpinning from cirrus_bo_push_sysram
From: Varad Gautam <[email protected]>
add a cirrus_bo_unpin call, and move bo_{reserve,unreserve} operations to bo_{pin,unpin} to ensure correct pinning/unpinning and simplify the call sequence.
--- drivers/gpu/drm/cirrus/cirrus_drv.h | 1 + drivers/gpu/drm/cirrus/cirrus_mode.c | 14 ++------- drivers/gpu/drm/cirrus/cirrus_ttm.c | 55 +++++++++++++++++++++++++++++------- 3 files changed, 48 insertions(+), 22 deletions(-)
drivers/gpu/drm/cirrus/cirrus_drv.h +1 -0
@@ -254,6 +254,7 @@ static inline void cirrus_bo_unreserve(struct cirrus_bo *bo)int cirrus_bo_push_sysram (struct cirrus_bo *bo);int cirrus_bo_pin (struct cirrus_bo *bo,u32 pl_flag,u64 *gpu_addr); +int cirrus_bo_unpin (struct cirrus_bo *bo);extern int cirrus_bpp;
drivers/gpu/drm/cirrus/cirrus_mode.c +2 -12
@@ -112,26 +112,17 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc, cirrus_fb =to_cirrus_framebuffer (fb); obj = cirrus_fb->obj; bo =gem_to_cirrus_bo (obj); - ret =cirrus_bo_reserve (bo, false); -if (ret) -return ret; +cirrus_bo_unpin (bo);cirrus_bo_push_sysram (bo); -cirrus_bo_unreserve (bo); } cirrus_fb =to_cirrus_framebuffer (crtc->primary->fb); obj = cirrus_fb->obj; bo =gem_to_cirrus_bo (obj); - ret =cirrus_bo_reserve (bo, false); -if (ret) -return ret; - ret =cirrus_bo_pin (bo,TTM_PL_FLAG_VRAM , &gpu_addr); -if (ret) { -cirrus_bo_unreserve (bo); +if (ret)return ret; - }if (&cdev->mode_info.gfbdev->gfb == cirrus_fb) {/* if pushing console in kmap it */
@@ -139,7 +130,6 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc,if (ret)DRM_ERROR ("failed to kmap fbcon\n" ); } -cirrus_bo_unreserve (bo);cirrus_set_start_address (crtc, (u32 )gpu_addr);return 0 ;
drivers/gpu/drm/cirrus/cirrus_ttm.c +45 -10
90 lines not on this page · raw message
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/12 drm/cirrus: add drm_read to cirrus_driver_fops
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
allow reading the drm file from userspace.
--- drivers/gpu/drm/cirrus/cirrus_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/cirrus/cirrus_drv.c +1 -0
@@ -122,6 +122,7 @@ static int cirrus_pm_resume(struct device *dev)static const struct file_operations cirrus_driver_fops = { .owner =THIS_MODULE , .open = drm_open, + .read = drm_read, .release = drm_release, .unlocked_ioctl = drm_ioctl, .mmap = cirrus_mmap,
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/12 drm/cirrus: do not disable outputs on fbdev init for atomic.
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
drm_helper_disable_unused_functions should not be called by atomic drivers, so disable it for later patches.
--- drivers/gpu/drm/cirrus/cirrus_fbdev.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/cirrus/cirrus_fbdev.c +0 -3
@@ -293,9 +293,6 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)if (ret)return ret; -/* disable all the possible outputs/crtcs before entering KMS mode */ -drm_helper_disable_unused_functions (cdev->dev); -return drm_fb_helper_initial_config (&gfbdev->helper, bpp_sel); }
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/12 drm/cirrus: initialize start and size fields
In reply to Varad GautamFrom: Dominik Behr <[email protected]>
initialize start and size fields in fb info so user space drivers like fbdev can map the memory
cherry-pick from 3.14 to 3.18 kernel to let VMtest pass
dmesg now shows proper size and fb start
initially reviewed for chromiumos at:
https://chromium-review.googlesource.com/167396
https://chromium-review.googlesource.com/282933
https://chromium-review.googlesource.com/339092
--- drivers/gpu/drm/cirrus/cirrus_fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/cirrus/cirrus_fbdev.c +3 -0
@@ -231,6 +231,9 @@ static int cirrusfb_create(struct drm_fb_helper *helper, info->screen_base = sysram; info->screen_size = size; + info->fix.smem_start = cdev->dev->mode_config.fb_base; + info->fix.smem_len = size; + info->fix.mmio_start =0 ; info->fix.mmio_len =0 ;
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 04/12] drm/cirrus: initialize start and size fields
Quoted 4 lines · Varad Gautam
From: Dominik Behr <[email protected]>
initialize start and size fields in fb info so user space drivers like fbdev can map the memory
Hmm? That works just fine in vanilla 4.12 ...
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/12 drm/cirrus: hardcode vram size
In reply to Varad GautamFrom: Zach Reizner <[email protected]>
There is no reliable way of detecting actual VRAM size, which is important in the case of cirrus because cursor data is always stored in the last 16K of VRAM. Because qemu effectivaly hardcodes 4MB but reports 32MB, we hardcode 4MB in the cirrus driver to ensure the cursor works properly.
initially reviewed at: https://chromium-review.googlesource.com/411344
--- drivers/gpu/drm/cirrus/cirrus_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/cirrus/cirrus_main.c +6 -1
@@ -98,7 +98,12 @@ static int cirrus_vram_init(struct cirrus_device *cdev) {/* BAR 0 is VRAM */ cdev->mc.vram_base =pci_resource_start (cdev->dev->pdev,0 ); - cdev->mc.vram_size =pci_resource_len (cdev->dev->pdev,0 ); + +/* +* While we can use the entire PCI bar for VRAM, qemu always expects to +* find the cursor data at the 4M - 16K point. +*/ + cdev->mc.vram_size =4 *1024 *1024 ;if (!request_mem_region (cdev->mc.vram_base, cdev->mc.vram_size,"cirrusdrmfb_vram" )) {
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/12] drm/cirrus: hardcode vram size
Quoted 9 lines · Varad Gautam
From: Zach Reizner <[email protected]>
There is no reliable way of detecting actual VRAM size, which is important in the case of cirrus because cursor data is always stored in
the last 16K of VRAM. Because qemu effectivaly hardcodes 4MB but reports
32MB, we hardcode 4MB in the cirrus driver to ensure the cursor works properly.
This comment is misleading. pci bar size != vram size. There is more stuff in the pci bar than just the vram, thats why it is larger than vram. It's not qemu mis-reporting something.
The actual vram size is 4MB. This is what the original hardware had, so the qemu emulation uses that too. So the fix is correct, but please adjust commit message and comment.
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/12 drm/cirrus: implement PRIME export for cirrus
In reply to Varad GautamFrom: Zach Reizner <[email protected]>
This patch implements PRIME export, but not import for cirrus.
initially reviewed at:
https://chromium-review.googlesource.com/229688
https://chromium-review.googlesource.com/339057
--- drivers/gpu/drm/cirrus/Makefile | 2 +- drivers/gpu/drm/cirrus/cirrus_drv.c | 11 +++++- drivers/gpu/drm/cirrus/cirrus_drv.h | 10 ++++++ drivers/gpu/drm/cirrus/cirrus_prime.c | 63 +++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/cirrus/cirrus_prime.c
drivers/gpu/drm/cirrus/Makefile +1 -1
@@ -1,4 +1,4 @@ cirrus-y := cirrus_main.o cirrus_mode.o \ - cirrus_drv.o cirrus_fbdev.o cirrus_ttm.o + cirrus_drv.o cirrus_fbdev.o cirrus_ttm.o cirrus_prime.o obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus.o
drivers/gpu/drm/cirrus/cirrus_drv.c +10 -1
@@ -130,7 +130,7 @@ static const struct file_operations cirrus_driver_fops = { .compat_ioctl = drm_compat_ioctl, };static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME , .load = cirrus_driver_load, .unload = cirrus_driver_unload, .fops = &cirrus_driver_fops,
@@ -143,6 +143,15 @@ static struct drm_driver driver = { .gem_free_object_unlocked = cirrus_gem_free_object, .dumb_create = cirrus_dumb_create, .dumb_map_offset = cirrus_dumb_mmap_offset, + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_pin = cirrus_gem_prime_pin, + .gem_prime_get_sg_table = cirrus_gem_prime_get_sg_table, + .gem_prime_import_sg_table = cirrus_gem_prime_import_sg_table, + .gem_prime_vmap = cirrus_gem_prime_vmap, + .gem_prime_vunmap = cirrus_gem_prime_vunmap, };static const struct dev_pm_ops cirrus_pm_ops = {
drivers/gpu/drm/cirrus/cirrus_drv.h +10 -0
@@ -163,6 +163,7 @@ struct cirrus_bo {struct ttm_buffer_object bo;struct ttm_placement placement;struct ttm_bo_kmap_obj kmap; +struct ttm_bo_kmap_obj dma_buf_vmap;struct drm_gem_object gem;struct ttm_place placements[3 ];int pin_count;
@@ -256,6 +257,15 @@ int cirrus_bo_push_sysram(struct cirrus_bo *bo);int cirrus_bo_pin (struct cirrus_bo *bo,u32 pl_flag,u64 *gpu_addr);int cirrus_bo_unpin (struct cirrus_bo *bo); +struct sg_table *cirrus_gem_prime_get_sg_table (struct drm_gem_object *obj); +void *cirrus_gem_prime_vmap (struct drm_gem_object *obj); +void cirrus_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); +struct drm_gem_object *cirrus_gem_prime_import_sg_table ( +struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sgt); +int cirrus_gem_prime_pin (struct drm_gem_object *obj); +extern int cirrus_bpp;#endif /* __CIRRUS_DRV_H__ */
drivers/gpu/drm/cirrus/cirrus_prime.c new file +63 -0
63 lines not on this page · raw message
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/12 drm/cirrus: use universal plane interfaces for primary plane
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
cirrus exposes one legacy primary plane tied to the crtc. convert this to use the universal planes interface in preparation for atomic.
v2: avoid early plane cleanup to fix faulty error handling. (krisman)
--- drivers/gpu/drm/cirrus/cirrus_mode.c | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
drivers/gpu/drm/cirrus/cirrus_mode.c +44 -1
@@ -348,11 +348,29 @@ static const struct drm_crtc_helper_funcs cirrus_helper_funcs = { .commit = cirrus_crtc_commit, }; +static const uint32_t cirrus_plane_formats[] = { +DRM_FORMAT_XRGB8888 , +DRM_FORMAT_ARGB8888 , +DRM_FORMAT_RGB888 , +DRM_FORMAT_RGB565 , +}; + +static const struct drm_plane_funcs cirrus_plane_funcs = { + .update_plane = drm_primary_helper_update, + .disable_plane = drm_primary_helper_disable, + .destroy = drm_primary_helper_destroy, +}; + +static const struct drm_plane_helper_funcs cirrus_plane_helper_funcs = { +}; +/* CRTC setup */ static void cirrus_crtc_init (struct drm_device *dev) {struct cirrus_device *cdev = dev->dev_private;struct cirrus_crtc *cirrus_crtc; +struct drm_plane *primary; +int ret; cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) + (CIRRUSFB_CONN_LIMIT * sizeof(struct drm_connector *)),
@@ -361,12 +379,37 @@ static void cirrus_crtc_init(struct drm_device *dev)if (cirrus_crtc ==NULL )return ; -drm_crtc_init (dev, &cirrus_crtc->base, &cirrus_crtc_funcs); + primary =kzalloc (sizeof (*primary),GFP_KERNEL ); +if (primary ==NULL ) + goto cleanup_crtc; +drm_plane_helper_add (primary, &cirrus_plane_helper_funcs); + ret =drm_universal_plane_init (dev, primary,1 , + &cirrus_plane_funcs, + cirrus_plane_formats, +ARRAY_SIZE (cirrus_plane_formats), +NULL ,DRM_PLANE_TYPE_PRIMARY ,NULL ); +if (ret) { +kfree (primary); + goto cleanup_crtc; + } + + ret =drm_crtc_init_with_planes (dev, &cirrus_crtc->base, primary,NULL , + &cirrus_crtc_funcs,NULL ); +if (ret) + goto cleanup;drm_mode_crtc_set_gamma_size (&cirrus_crtc->base,CIRRUS_LUT_SIZE ); cdev->mode_info.crtc = cirrus_crtc;drm_crtc_helper_add (&cirrus_crtc->base, &cirrus_helper_funcs); +return ; + +cleanup: +drm_plane_cleanup (primary); +kfree (primary); +cleanup_crtc: +kfree (cirrus_crtc); +return ; } static void cirrus_encoder_mode_set(struct drm_encoder *encoder,
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/12 drm/cirrus: use atomic transition helpers for plane and crtc
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
split the driver to fit into atomic semantics, and switch to using the atomic transition layer helpers for legacy modesetting.
--- drivers/gpu/drm/cirrus/cirrus_drv.h | 1 + drivers/gpu/drm/cirrus/cirrus_main.c | 3 + drivers/gpu/drm/cirrus/cirrus_mode.c | 350 ++++++++++++++++++++++------------- 3 files changed, 227 insertions(+), 127 deletions(-)
drivers/gpu/drm/cirrus/cirrus_drv.h +1 -0
@@ -167,6 +167,7 @@ struct cirrus_bo {struct drm_gem_object gem;struct ttm_place placements[3 ];int pin_count; +u64 gpu_addr; };#define gem_to_cirrus_bo (gobj) container_of((gobj), struct cirrus_bo, gem)
drivers/gpu/drm/cirrus/cirrus_main.c +3 -0
@@ -9,6 +9,7 @@* Dave Airlie */ #include <drm/drmP.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include "cirrus_drv.h"
@@ -82,6 +83,8 @@ cirrus_user_framebuffer_create(struct drm_device *dev,static const struct drm_mode_config_funcs cirrus_mode_funcs = { .fb_create = cirrus_user_framebuffer_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, };/* Unmap the framebuffer from the core and release the memory */
drivers/gpu/drm/cirrus/cirrus_mode.c +223 -127
418 lines not on this page · raw message
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/12 drm/cirrus: send vblank on crtc atomic_flush
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
the hardware does not provide interrupts on vblank, so we just send a fake vblank event on atomic_flush.
--- drivers/gpu/drm/cirrus/cirrus_mode.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/cirrus/cirrus_mode.c +18 -0
@@ -217,6 +217,23 @@ static void cirrus_crtc_destroy(struct drm_crtc *crtc)kfree (cirrus_crtc); } +static void cirrus_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +struct drm_device *dev = crtc->dev; +struct drm_pending_vblank_event *event; +unsigned long flags; + +if (crtc->state && crtc->state->event) { + event = crtc->state->event; + crtc->state->event =NULL ; + +spin_lock_irqsave (&dev->event_lock, flags); +drm_crtc_send_vblank_event (crtc, event); +spin_unlock_irqrestore (&dev->event_lock, flags); + } +} +/* These provide the minimum set of functions required to handle a CRTC */ static const struct drm_crtc_funcs cirrus_crtc_funcs = { .gamma_set = cirrus_crtc_gamma_set,
@@ -234,6 +251,7 @@ static const struct drm_crtc_helper_funcs cirrus_helper_funcs = { .mode_set_nofb = cirrus_mode_set_nofb, .prepare = cirrus_crtc_prepare, .commit = cirrus_crtc_commit, + .atomic_flush = cirrus_crtc_atomic_flush, }; static int cirrus_plane_update(struct drm_plane *plane,
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/12 drm/cirrus: use atomic handlers for plane and crtc
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
move from transition helpers to actual atomic handlers.
--- drivers/gpu/drm/cirrus/cirrus_mode.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)
drivers/gpu/drm/cirrus/cirrus_mode.c +3 -27
@@ -160,15 +160,6 @@ static void cirrus_mode_set_nofb(struct drm_crtc *crtc) }/* -* This is called before a mode is programmed. A typical use might be to -* enable DPMS during the programming to avoid seeing intermediate stages, -* but that's not relevant to us -*/ -static void cirrus_crtc_prepare (struct drm_crtc *crtc) -{ -} - -/* * This is called after a mode is programmed. It should reverse anything done * by the prepare function */
@@ -237,8 +228,9 @@ static void cirrus_crtc_atomic_flush(struct drm_crtc *crtc,/* These provide the minimum set of functions required to handle a CRTC */ static const struct drm_crtc_funcs cirrus_crtc_funcs = { .gamma_set = cirrus_crtc_gamma_set, - .set_config = drm_crtc_helper_set_config, + .set_config = drm_atomic_helper_set_config, .destroy = cirrus_crtc_destroy, + .page_flip = drm_atomic_helper_page_flip, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
@@ -246,27 +238,11 @@ static const struct drm_crtc_funcs cirrus_crtc_funcs = {static const struct drm_crtc_helper_funcs cirrus_helper_funcs = { .dpms = cirrus_crtc_dpms, - .mode_set = drm_helper_crtc_mode_set, - .mode_set_base = drm_helper_crtc_mode_set_base, .mode_set_nofb = cirrus_mode_set_nofb, - .prepare = cirrus_crtc_prepare, .commit = cirrus_crtc_commit, .atomic_flush = cirrus_crtc_atomic_flush, }; -static int cirrus_plane_update (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) -{ -return drm_plane_helper_update (plane, crtc, fb, - crtc_x, crtc_y, crtc_w, - crtc_h, src_x, src_y, src_w, src_h); -} -static const uint32_t cirrus_plane_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_ARGB8888 ,
@@ -275,7 +251,7 @@ static const uint32_t cirrus_plane_formats[] = { };static const struct drm_plane_funcs cirrus_plane_funcs = { - .update_plane = cirrus_plane_update, + .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_primary_helper_disable, .destroy = drm_primary_helper_destroy, .reset = drm_atomic_helper_plane_reset,
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 11/12 drm/cirrus: implement atomic hardware cursor support
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
This enables cursor plane on cirrus. It only supports ARGB 8-bit cursors from userspace, and downconverts them to 1-bit black and white with masking, which is all cirrus hardware can support. Only cursors with size 32x32 or 64x64 will work.
initial non-atomic version:
Reviewed-at:
https://chromium-review.googlesource.com/335579
https://chromium-review.googlesource.com/339091
v2: rework faulty error handling (krisman <[email protected]>)
--- drivers/gpu/drm/cirrus/cirrus_drv.h | 13 ++ drivers/gpu/drm/cirrus/cirrus_main.c | 13 ++ drivers/gpu/drm/cirrus/cirrus_mode.c | 273 ++++++++++++++++++++++++++++++++++- 3 files changed, 294 insertions(+), 5 deletions(-)
drivers/gpu/drm/cirrus/cirrus_drv.h +13 -0
@@ -50,6 +50,17 @@WREG8 (SEQ_DATA , v); \ } while (0) \ +#define PAL_ADDR 8 +#define PAL_DATA 9 + +#define WREG_PAL (addr, r, g, b) \ + do { \ + WREG8(PAL_ADDR, addr); \ + WREG8(PAL_DATA, r); \ + WREG8(PAL_DATA, g); \ + WREG8(PAL_DATA, b); \ + } while (0) \ +#define CRT_INDEX 0x14#define CRT_DATA 0x15
@@ -136,6 +147,8 @@ struct cirrus_device {void __iomem *rmmio;struct cirrus_mc mc; +resource_size_t cursor_ram_size; +void __iomem *cursor_iomem;struct cirrus_mode_info mode_info;int num_crtc;
drivers/gpu/drm/cirrus/cirrus_main.c +13 -0
@@ -94,6 +94,8 @@ static void cirrus_vram_fini(struct cirrus_device *cdev) cdev->rmmio =NULL ;if (cdev->mc.vram_base)release_mem_region (cdev->mc.vram_base, cdev->mc.vram_size); +if (cdev->cursor_iomem) +iounmap (cdev->cursor_iomem); }/* Map the framebuffer from the card and configure the core */
@@ -107,12 +109,23 @@ static int cirrus_vram_init(struct cirrus_device *cdev)* find the cursor data at the 4M - 16K point. */ cdev->mc.vram_size =4 *1024 *1024 ; +/* The last 16K of VRAM is for cursor */ + cdev->cursor_ram_size =16 *1024 ;if (!request_mem_region (cdev->mc.vram_base, cdev->mc.vram_size,"cirrusdrmfb_vram" )) {DRM_ERROR ("can't reserve VRAM\n" );return -ENXIO ; } + cdev->cursor_iomem =ioremap_nocache (cdev->mc.vram_base + + cdev->mc.vram_size - + cdev->cursor_ram_size, + cdev->cursor_ram_size); +if (!cdev->cursor_iomem) { +release_mem_region (cdev->mc.vram_base, cdev->mc.vram_size); +DRM_ERROR ("can't ioremap cursor VRAM\n" ); +return -ENXIO ; + }return 0 ; }
drivers/gpu/drm/cirrus/cirrus_mode.c +268 -5
304 lines not on this page · raw message
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 11/12] drm/cirrus: implement atomic hardware cursor support
Quoted 7 lines · Varad Gautam
From: Varad Gautam <[email protected]>
This enables cursor plane on cirrus. It only supports ARGB 8-bit cursors
from userspace, and downconverts them to 1-bit black and white with masking, which is all cirrus hardware can support. Only cursors with size 32x32 or 64x64 will work.
Isn't it better to just not implement hardware cursor then, so userspace can fallback to software cursor instead? Advertising ARGB cursor support to userspace, but then crippling those cursors to black'n'white doesn't look sensible to me ...
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 12/12 drm/cirrus: advertise DRIVER_ATOMIC
In reply to Varad GautamFrom: Varad Gautam <[email protected]>
allow userspace to use atomic ioctls.
we now pass the following tests when running with cirrus.bpp=32:
igt/kms_atomic_transition:
plane-all-transition plane-use-after-nonblocking-unbind plane-all-modeset-transition plane-toggle-modeset-transition 1x-modeset-transitions 1x-modeset-transitions-nonblocking
igt/kms_atomic:
plane_primary_legacy
test_only
plane_cursor_legacy
plane_invalid_params
crtc_invalid_params
igt/kms_setmode
igt/kms_rmfb
drm-tests/atomictest:
disable_primary
fullscreen_video
overlay_pageflip
primary_pageflip
video_overlay
--- drivers/gpu/drm/cirrus/cirrus_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/cirrus/cirrus_drv.c +2 -1
@@ -130,7 +130,8 @@ static const struct file_operations cirrus_driver_fops = { .compat_ioctl = drm_compat_ioctl, };static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME | +DRIVER_ATOMIC , .load = cirrus_driver_load, .unload = cirrus_driver_unload, .fops = &cirrus_driver_fops,
Signature · 6 lines
2.13.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel