drm/cirrus: convert cirrus to atomic mode-setting
Subsystems (2)
cover drm/cirrus: convert cirrus to atomic mode-setting
From: Zhao Junwang <[email protected]>
This patch series aim to convert DRM_CIRRUS to atomic mode-setting. This mostly reference my previous patch series on DRM_BOCHS and Gustavo Padovan;s patch series on drm/exynos.
Zhao Junwang (7):
drm/cirrus: phase 1 - use the transitional helpers drm/cirrus: phase 2: wire up state reset, duplicate and destroy drm/cirrus: phase 3: atomic updates of planes drm/cirrus: add return 0 to make sure if (bo->pin_count) early_exit drm/cirrus: phase 3: use atomic .set_config helper drm/cirrus: atomic dpms support
drm/cirrus: add DRIVER_ATOMIC to .driver_features
drivers/gpu/drm/cirrus/cirrus_drv.c | 3 +- drivers/gpu/drm/cirrus/cirrus_drv.h | 3 +- drivers/gpu/drm/cirrus/cirrus_main.c | 5 +- drivers/gpu/drm/cirrus/cirrus_mode.c | 299 ++++++++++++++++++++-------------- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 + 5 files changed, 187 insertions(+), 125 deletions(-)
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/7 drm/cirrus: phase 1 - use the transitional helpers
From: Zhao Junwang <[email protected]>
-register driver's own primary plane
-use drm_crtc_init_with_planes instead drm_crtc_init
-the new atomic_infrastructure needs ->mode_set_nofb callback
--- drivers/gpu/drm/cirrus/cirrus_drv.c | 1 - drivers/gpu/drm/cirrus/cirrus_drv.h | 3 +- drivers/gpu/drm/cirrus/cirrus_main.c | 2 +- drivers/gpu/drm/cirrus/cirrus_mode.c | 201 +++++++++++++++++++++------------- 4 files changed, 129 insertions(+), 78 deletions(-)
drivers/gpu/drm/cirrus/cirrus_drv.c +0 -1
@@ -40,7 +40,6 @@ static const struct pci_device_id pciidlist[] = { {0,} }; -static int cirrus_kick_out_firmware_fb (struct pci_dev *pdev) {struct apertures_struct *ap;
drivers/gpu/drm/cirrus/cirrus_drv.h +2 -1
@@ -135,8 +135,9 @@ struct cirrus_device {resource_size_t rmmio_size;void __iomem *rmmio; -struct cirrus_mc mc; +struct cirrus_mc mc;struct cirrus_mode_info mode_info; +struct drm_plane primary;int num_crtc;int fb_mtrr;
drivers/gpu/drm/cirrus/cirrus_main.c +1 -1
@@ -308,10 +308,10 @@ cirrus_dumb_mmap_offset(struct drm_file *file,drm_gem_object_unreference (obj); ret =0 ; + out_unlock:mutex_unlock (&dev->struct_mutex);return ret; - } bool cirrus_check_framebuffer(struct cirrus_device *cdev, int width, int height,
drivers/gpu/drm/cirrus/cirrus_mode.c +126 -75
261 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/7 drm/cirrus: phase 2: wire up state reset, duplicate and destroy
In reply to John HunterFrom: Zhao Junwang <[email protected]>
Set CRTC, planes and connectors to use the default implementations from the atomic helper library.
--- drivers/gpu/drm/cirrus/cirrus_mode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/cirrus/cirrus_mode.c +12 -0
@@ -17,6 +17,7 @@#include <drm/drmP.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_plane_helper.h> +#include <drm/drm_atomic_helper.h> #include <video/cirrus.h>
@@ -304,6 +305,9 @@ static const struct drm_crtc_funcs cirrus_crtc_funcs = { .gamma_set = cirrus_crtc_gamma_set, .set_config = drm_crtc_helper_set_config, .destroy = cirrus_crtc_destroy, + .reset = drm_atomic_helper_crtc_reset, + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, };static const struct drm_crtc_helper_funcs cirrus_helper_funcs = {
@@ -429,6 +433,9 @@ static void cirrus_plane_atomic_disable(struct drm_plane *plane,static const struct drm_plane_funcs cirrus_plane_funcs = { .update_plane = drm_plane_helper_update, .disable_plane = drm_plane_helper_disable, + .reset = drm_atomic_helper_plane_reset, + .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, };static const struct drm_plane_helper_funcs cirrus_plane_helper_funcs = {
@@ -593,6 +600,9 @@ struct drm_connector_funcs cirrus_vga_connector_funcs = { .detect = cirrus_vga_detect, .fill_modes = drm_helper_probe_single_connector_modes, .destroy = cirrus_connector_destroy, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, };static struct drm_connector *cirrus_vga_init (struct drm_device *dev)
@@ -648,6 +658,8 @@ int cirrus_modeset_init(struct cirrus_device *cdev)return -1 ; } +drm_mode_config_reset (cdev->dev); +drm_mode_connector_attach_encoder (connector, encoder); ret =cirrus_fbdev_init (cdev);
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/7 drm/cirrus: phase 3: atomic updates of planes
In reply to John HunterFrom: Zhao Junwang <[email protected]>
Now that phase 1 and 2 are complete we can switch the update/disable_plane callbacks to their atomic version
--- drivers/gpu/drm/cirrus/cirrus_main.c | 3 +++ drivers/gpu/drm/cirrus/cirrus_mode.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/cirrus/cirrus_main.c +3 -0
@@ -10,6 +10,7 @@*/ #include <drm/drmP.h> #include <drm/drm_crtc_helper.h> +#include <drm/drm_atomic_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 +2 -2
@@ -431,8 +431,8 @@ static void cirrus_plane_atomic_disable(struct drm_plane *plane, }static const struct drm_plane_funcs cirrus_plane_funcs = { - .update_plane = drm_plane_helper_update, - .disable_plane = drm_plane_helper_disable, + .update_plane = drm_atomic_helper_update_plane, + .disable_plane = drm_atomic_helper_disable_plane, .reset = drm_atomic_helper_plane_reset, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/7 drm/cirrus: add return 0 to make sure if (bo->pin_count) early_exit
In reply to John HunterFrom: Zhao Junwang <[email protected]>
when the first modeset calls prepare_fb, bo->pin_count change from 0 to 1, then the second modeset with the same fb, that should set bo->pin_count to 2, and then when cleanup_fb was called, bo->pin_count should be 2 to 1.
But in the cirrus_bo_pin, it will set bo->pin_count = 1 at the end of the function, this results that bo->bin_count will never be larger than 1 no matter how many times cirrus_bo_pin was called.
So we need to add a condition before bo->pin_count = 1
V2: if (bo->pin_count) early_exit; do_the_real_pinning work
--- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/cirrus/cirrus_ttm.c +2 -0
@@ -364,6 +364,8 @@ int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr) bo->pin_count++;if (gpu_addr) *gpu_addr =cirrus_bo_gpu_offset (bo); + +return 0 ; }cirrus_ttm_placement (bo, pl_flag);
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/7 drm/cirrus: phase 3: use atomic .set_config helper
In reply to John HunterFrom: Zhao Junwang <[email protected]>
Now that phase 1 and phase 2 are completed, switch .set_config helper to use the atomic one.
-stop looking legacy crtc->primary->fb, instead we should use crtc->primary->state->fb
.prepare() calls are no more needed, remove them .mode_set() and .mode_set_base are no longer needed, remove
--- drivers/gpu/drm/cirrus/cirrus_mode.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)
drivers/gpu/drm/cirrus/cirrus_mode.c +6 -22
@@ -208,7 +208,8 @@ static void cirrus_crtc_mode_set_nofb(struct drm_crtc *crtc) sr07 =RREG8 (SEQ_DATA ); sr07 &=0xe0 ; hdr =0 ; -switch (crtc->primary->fb->bits_per_pixel) { + +switch (crtc->primary->state->fb->bits_per_pixel) {case 8 : sr07 |=0x11 ;break ;
@@ -231,13 +232,13 @@ static void cirrus_crtc_mode_set_nofb(struct drm_crtc *crtc)WREG_SEQ (0x7 , sr07);/* Program the pitch */ - tmp = crtc->primary->fb->pitches[0 ] /8 ; + tmp = crtc->primary->state->fb->pitches[0 ] /8 ;WREG_CRT (VGA_CRTC_OFFSET , tmp);/* Enable extended blanking and pitch bits, and enable full memory */ tmp =0x22 ; - tmp |= (crtc->primary->fb->pitches[0 ] >>7 ) &0x10 ; - tmp |= (crtc->primary->fb->pitches[0 ] >>6 ) &0x40 ; + tmp |= (crtc->primary->state->fb->pitches[0 ] >>7 ) &0x10 ; + tmp |= (crtc->primary->state->fb->pitches[0 ] >>6 ) &0x40 ;WREG_CRT (0x1b , tmp);/* Enable high-colour modes */
@@ -253,15 +254,6 @@ static void cirrus_crtc_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 */
@@ -303,7 +295,7 @@ static void cirrus_crtc_destroy(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, .reset = drm_atomic_helper_crtc_reset, .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
@@ -313,10 +305,7 @@ static const struct drm_crtc_funcs cirrus_crtc_funcs = {static const struct drm_crtc_helper_funcs cirrus_helper_funcs = { .dpms = cirrus_crtc_dpms, .mode_fixup = cirrus_crtc_mode_fixup, - .mode_set = drm_helper_crtc_mode_set, - .mode_set_base = drm_helper_crtc_mode_set_base, .mode_set_nofb = cirrus_crtc_mode_set_nofb, - .prepare = cirrus_crtc_prepare, .commit = cirrus_crtc_commit, .load_lut = cirrus_crtc_load_lut, };
@@ -506,10 +495,6 @@ static void cirrus_encoder_dpms(struct drm_encoder *encoder, int state)return ; } -static void cirrus_encoder_prepare (struct drm_encoder *encoder) -{ -} -static void cirrus_encoder_commit (struct drm_encoder *encoder) { }
@@ -525,7 +510,6 @@ static const struct drm_encoder_helper_funcs cirrus_encoder_helper_funcs = { .dpms = cirrus_encoder_dpms, .mode_fixup = cirrus_encoder_mode_fixup, .mode_set = cirrus_encoder_mode_set, - .prepare = cirrus_encoder_prepare, .commit = cirrus_encoder_commit, };
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/7 drm/cirrus: atomic dpms support
In reply to John HunterFrom: Zhao Junwang <[email protected]>
Run dpms operations through the atomic interfaces. This basically removes the .dpms() callback from encoders and crtcs and use .disable and .enable to turn the crtc on and off.
use drm_atomic_helper_connector_dpms for connector
--- drivers/gpu/drm/cirrus/cirrus_mode.c | 68 +++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 29 deletions(-)
drivers/gpu/drm/cirrus/cirrus_mode.c +39 -29
@@ -55,37 +55,40 @@ static void cirrus_crtc_load_lut(struct drm_crtc *crtc) } } -/* -* The DRM core requires DPMS functions, but they make little sense in our -* case and so are just stubs -*/ +static void cirrus_crtc_enable (struct drm_crtc *crtc) +{ +struct drm_device *dev = crtc->dev; +struct cirrus_device *cdev = dev->dev_private; +u8 sr01, gr0e; + +if (crtc->enabled) +return ; -static void cirrus_crtc_dpms (struct drm_crtc *crtc,int mode) + sr01 =0x00 ; + gr0e =0x00 ; + +WREG8 (SEQ_INDEX ,0x1 ); + sr01 |=RREG8 (SEQ_DATA ) & ~0x20 ; +WREG_SEQ (0x1 , sr01); + +WREG8 (GFX_INDEX ,0xe ); + gr0e |=RREG8 (GFX_DATA ) & ~0x06 ; +WREG_GFX (0xe , gr0e); + + crtc->enabled = true; +} + +static void cirrus_crtc_disable (struct drm_crtc *crtc) {struct drm_device *dev = crtc->dev;struct cirrus_device *cdev = dev->dev_private;u8 sr01, gr0e; -switch (mode) { -case DRM_MODE_DPMS_ON : - sr01 =0x00 ; - gr0e =0x00 ; -break ; -case DRM_MODE_DPMS_STANDBY : - sr01 =0x20 ; - gr0e =0x02 ; -break ; -case DRM_MODE_DPMS_SUSPEND : - sr01 =0x20 ; - gr0e =0x04 ; -break ; -case DRM_MODE_DPMS_OFF : - sr01 =0x20 ; - gr0e =0x06 ; -break ; -default : +if (!crtc->enabled)return ; - } + + sr01 =0x20 ; + gr0e =0x06 ;WREG8 (SEQ_INDEX ,0x1 ); sr01 |=RREG8 (SEQ_DATA ) & ~0x20 ;
@@ -94,6 +97,8 @@ static void cirrus_crtc_dpms(struct drm_crtc *crtc, int mode)WREG8 (GFX_INDEX ,0xe ); gr0e |=RREG8 (GFX_DATA ) & ~0x06 ;WREG_GFX (0xe , gr0e); + + crtc->enabled = false; }/*
@@ -303,7 +308,8 @@ static const struct drm_crtc_funcs cirrus_crtc_funcs = { };static const struct drm_crtc_helper_funcs cirrus_helper_funcs = { - .dpms = cirrus_crtc_dpms, + .disable = cirrus_crtc_disable, + .enable = cirrus_crtc_enable, .mode_fixup = cirrus_crtc_mode_fixup, .mode_set_nofb = cirrus_crtc_mode_set_nofb, .commit = cirrus_crtc_commit,
@@ -490,9 +496,12 @@ static void cirrus_encoder_mode_set(struct drm_encoder *encoder, { } -static void cirrus_encoder_dpms (struct drm_encoder *encoder,int state) +static void cirrus_encoder_enable (struct drm_encoder *encoder) +{ +} + +static void cirrus_encoder_disable (struct drm_encoder *encoder) { -return ; }static void cirrus_encoder_commit (struct drm_encoder *encoder)
@@ -507,7 +516,8 @@ static void cirrus_encoder_destroy(struct drm_encoder *encoder) }static const struct drm_encoder_helper_funcs cirrus_encoder_helper_funcs = { - .dpms = cirrus_encoder_dpms, + .enable = cirrus_encoder_enable, + .disable = cirrus_encoder_disable, .mode_fixup = cirrus_encoder_mode_fixup, .mode_set = cirrus_encoder_mode_set, .commit = cirrus_encoder_commit,
@@ -580,7 +590,7 @@ struct drm_connector_helper_funcs cirrus_vga_connector_helper_funcs = { };struct drm_connector_funcs cirrus_vga_connector_funcs = { - .dpms = drm_helper_connector_dpms, + .dpms = drm_atomic_helper_connector_dpms, .detect = cirrus_vga_detect, .fill_modes = drm_helper_probe_single_connector_modes, .destroy = cirrus_connector_destroy,
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/7 drm/cirrus: add DRIVER_ATOMIC to .driver_features
In reply to John HunterFrom: Zhao Junwang <[email protected]>
Since driver is now fully atomic, we should add DRIVER_ATOMIC to .driver_features
--- drivers/gpu/drm/cirrus/cirrus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/cirrus/cirrus_drv.c +1 -1
@@ -130,7 +130,7 @@ static const struct file_operations cirrus_driver_fops = {#endif };static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC , .load = cirrus_driver_load, .unload = cirrus_driver_unload, .set_busid = drm_pci_set_busid,
Signature · 7 lines
1.7.10.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
[+Dave]
Hi all,
Another necro bump - second part of John's work from GSOC 2015 that did not land :-(
Quoted 6 lines · John Hunter
From: Zhao Junwang <[email protected]>
This patch series aim to convert
DRM_CIRRUSto atomic mode-setting. This mostly reference my previous patch series onDRM_BOCHSand Gustavo Padovan;s patch series on drm/exynos.
Dave, I realise that you wrote the driver a long time ago, although you're still one of the people best familiar with it. Can you spare some time and check/ack it ?
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel