drm/ast: Convert to atomic modesetting
Subsystems (3)
Thomas Zimmermann
maintainerv2 cover drm/ast: Convert to atomic modesetting
This patch set adds universal planes to ast and converts the driver to atomic modesetting.
The first patch is purely for clean-up.
Patches 2 to 5 prepare the ast modesetting code for universal planes and atomic modesetting. The size calculation for each mode has to take double buffering into account. Several functions have to be split to make them work with the separate check and update on CRTCs and planes. There are no functional changes.
Patches 6 to 8 add atomic modesetting code for planes and CRTC. Planes immediately provide atomic functions. There's no intermediate step with legacy functions for non-atomic drivers. The cursor plane HW only supports ARGB4444, so the cursor plane converts the format internally; just as the legacy implementation did.
Finally, patch 9 adds missing helpers and enables atomic modesetting. The CRTC functions now provide page_flip, which enables Weston support on ast hardware.
The patchset has been tested by running the fbdev console, X11 (Gnome) and Weston on an AST2100 chipset.
v2:
* don't set plane call-back functions to NULL explicitly
* define plane format arrays in global scope
Thomas Zimmermann (9):
drm/ast: Remove last traces of struct ast_gem_object drm/ast: Check video-mode requirements against VRAM size drm/ast: Don't clear base address and offset with default values drm/ast: Split ast_set_ext_reg() into color and threshold function drm/ast: Split ast_set_vbios_mode_info()
drm/ast: Add primary plane
drm/ast: Add CRTC helpers for atomic modesetting drm/ast: Add cursor plane
drm/ast: Enable atomic modesetting
drivers/gpu/drm/ast/ast_drv.c | 24 +- drivers/gpu/drm/ast/ast_drv.h | 9 +- drivers/gpu/drm/ast/ast_main.c | 54 +-- drivers/gpu/drm/ast/ast_mode.c | 685 ++++++++++++++++++++------------- 4 files changed, 449 insertions(+), 323 deletions(-)
--
2.23.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 1/9 drm/ast: Remove last traces of struct ast_gem_object
The ast driver has switched to struct drm_vram_gem_object a while ago. This patch removes a function and forward declaration that were forgotten before.
--- drivers/gpu/drm/ast/ast_drv.h | 6 ------ drivers/gpu/drm/ast/ast_main.c | 24 ------------------------ 2 files changed, 30 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +0 -6
@@ -137,8 +137,6 @@ struct ast_private {int ast_driver_load (struct drm_device *dev,unsigned long flags);void ast_driver_unload (struct drm_device *dev); -struct ast_gem_object ; -#define AST_IO_AR_PORT_WRITE (0x40)#define AST_IO_MISC_PORT_WRITE (0x42)#define AST_IO_VGA_ENABLE_PORT (0x43)
@@ -289,10 +287,6 @@ extern void ast_mode_fini(struct drm_device *dev);int ast_mm_init (struct ast_private *ast);void ast_mm_fini (struct ast_private *ast); -int ast_gem_create (struct drm_device *dev, -u32 size,bool iskernel, -struct drm_gem_object **obj); -/* ast post */ void ast_enable_vga (struct drm_device *dev);void ast_enable_mmio (struct drm_device *dev);
drivers/gpu/drm/ast/ast_main.c +0 -24
@@ -535,27 +535,3 @@ void ast_driver_unload(struct drm_device *dev)pci_iounmap (dev->pdev, ast->regs);kfree (ast); } - -int ast_gem_create (struct drm_device *dev, -u32 size,bool iskernel, -struct drm_gem_object **obj) -{ -struct drm_gem_vram_object *gbo; -int ret; - - *obj =NULL ; - - size =roundup (size,PAGE_SIZE ); -if (size ==0 ) -return -EINVAL ; - - gbo =drm_gem_vram_create (dev, &dev->vram_mm->bdev, size,0 , false); -if (IS_ERR (gbo)) { - ret =PTR_ERR (gbo); -if (ret != -ERESTARTSYS ) -DRM_ERROR ("failed to allocate GEM object\n" ); -return ret; - } - *obj = &gbo->bo.base; -return 0 ; -}
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 2/9 drm/ast: Check video-mode requirements against VRAM size
In reply to Thomas ZimmermannEach video mode's primary plane requires a minimum amount of video memory. For double buffering, this is at most half the available VRAM. Check this constraint.
--- drivers/gpu/drm/ast/ast_main.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_main.c +24 -1
@@ -387,8 +387,31 @@ static int ast_get_dram_info(struct drm_device *dev)return 0 ; } +enum drm_mode_status ast_mode_config_mode_valid (struct drm_device *dev, +const struct drm_display_mode *mode) +{ +static const unsigned long max_bpp =4 ;/* DRM_FORMAT_XRGBA8888 */ + +struct ast_private *ast = dev->dev_private; +unsigned long fbsize, fbpages, max_fbpages; + +/* To support double buffering, a framebuffer may not +* consume more than half of the available VRAM. +*/ + max_fbpages = (ast->vram_size /2 ) >>PAGE_SHIFT ; + + fbsize = mode->hdisplay * mode->vdisplay * max_bpp; + fbpages =DIV_ROUND_UP (fbsize,PAGE_SIZE ); + +if (fbpages > max_fbpages) +return MODE_MEM ; + +return MODE_OK ; +} +static const struct drm_mode_config_funcs ast_mode_funcs = { - .fb_create = drm_gem_fb_create + .fb_create = drm_gem_fb_create, + .mode_valid = ast_mode_config_mode_valid, };static u32 ast_get_vram_info (struct drm_device *dev)
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 3/9 drm/ast: Don't clear base address and offset with default values
In reply to Thomas ZimmermannThe content of the base-address and offset registers are state of the primary plane. Clearing it to default values will interfere with plane functions for atomic mode setting.
--- drivers/gpu/drm/ast/ast_mode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +6 -2
@@ -253,9 +253,13 @@ static void ast_set_std_reg(struct drm_crtc *crtc, struct drm_display_mode *modeast_set_index_reg (ast,AST_IO_SEQ_PORT , (i +1 ) , jreg); } -/* Set CRTC */ +/* Set CRTC; except base address and offset */ ast_set_index_reg_mask (ast,AST_IO_CRTC_PORT ,0x11 ,0x7f ,0x00 ); -for (i =0 ; i <25 ; i++) +for (i =0 ; i <12 ; i++) +ast_set_index_reg (ast,AST_IO_CRTC_PORT , i, stdtable->crtc[i]); +for (i =14 ; i <19 ; i++) +ast_set_index_reg (ast,AST_IO_CRTC_PORT , i, stdtable->crtc[i]); +for (i =20 ; i <25 ; i++)ast_set_index_reg (ast,AST_IO_CRTC_PORT , i, stdtable->crtc[i]);/* set AR */
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 4/9 drm/ast: Split ast_set_ext_reg() into color and threshold function
In reply to Thomas ZimmermannIn ast_set_ext_reg() sets several framebuffer options and CRT threshold parameters. The former is mostly state of the primary plane; the latter is constant. Hence, split the function in two and make it work with atomic modesetting.
--- drivers/gpu/drm/ast/ast_mode.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +10 -5
@@ -419,11 +419,10 @@ static void ast_set_dclk_reg(struct drm_device *dev, struct drm_display_mode *mo ((clk_info->param3 & 0x3) << 4)); } -static void ast_set_ext_reg (struct drm_crtc *crtc,struct drm_display_mode *mode, -struct ast_vbios_mode_info *vbios_mode) +static void ast_set_color_reg (struct drm_crtc *crtc, +const struct drm_framebuffer *fb) {struct ast_private *ast = crtc->dev->dev_private; -const struct drm_framebuffer *fb = crtc->primary->fb;u8 jregA0 =0 , jregA3 =0 , jregA8 =0 ;switch (fb->format->cpp[0 ] *8 ) {
@@ -448,6 +447,11 @@ static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *modeast_set_index_reg_mask (ast,AST_IO_CRTC_PORT ,0xa0 ,0x8f , jregA0);ast_set_index_reg_mask (ast,AST_IO_CRTC_PORT ,0xa3 ,0xf0 , jregA3);ast_set_index_reg_mask (ast,AST_IO_CRTC_PORT ,0xa8 ,0xfd , jregA8); +} + +static void ast_set_crtthd_reg (struct drm_crtc *crtc) +{ +struct ast_private *ast = crtc->dev->dev_private;/* Set Threshold */ if (ast->chip == AST2300 || ast->chip == AST2400 ||
@@ -467,7 +471,7 @@ static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode }static void ast_set_sync_reg (struct drm_device *dev,struct drm_display_mode *mode, -struct ast_vbios_mode_info *vbios_mode) +struct ast_vbios_mode_info *vbios_mode) {struct ast_private *ast = dev->dev_private;u8 jreg;
@@ -595,7 +599,8 @@ static int ast_crtc_mode_set(struct drm_crtc *crtc,ast_set_crtc_reg (crtc, adjusted_mode, &vbios_mode);ast_set_offset_reg (crtc);ast_set_dclk_reg (dev, adjusted_mode, &vbios_mode); -ast_set_ext_reg (crtc, adjusted_mode, &vbios_mode); +ast_set_color_reg (crtc, fb); +ast_set_crtthd_reg (crtc);ast_set_sync_reg (dev, adjusted_mode, &vbios_mode);ast_set_dac_reg (crtc, adjusted_mode, &vbios_mode);
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 5/9 drm/ast: Split ast_set_vbios_mode_info()
In reply to Thomas ZimmermannThe implementation of ast_set_vbios_mode() converts a DRM display mode and framebuffer into an adjusted mode and stores information for the video BIOS to several scratch regsiters.
Here we split the function into individual functions that do the conversion, set the VBIOS mode information and format information. This makes it compatible with support for primary planes and atomic modesetting.
--- drivers/gpu/drm/ast/ast_mode.c | 111 +++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 39 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +72 -39
@@ -82,13 +82,12 @@ static void ast_crtc_load_lut(struct drm_crtc *crtc)ast_load_palette_index (ast, i, *r++ >>8 , *g++ >>8 , *b++ >>8 ); } -static bool ast_get_vbios_mode_info (struct drm_crtc *crtc,struct drm_display_mode *mode, +static bool ast_get_vbios_mode_info (const struct drm_framebuffer *fb, +const struct drm_display_mode *mode,struct drm_display_mode *adjusted_mode,struct ast_vbios_mode_info *vbios_mode) { -struct ast_private *ast = crtc->dev->dev_private; -const struct drm_framebuffer *fb = crtc->primary->fb; -u32 refresh_rate_index =0 , mode_id, color_index, refresh_rate; +u32 refresh_rate_index =0 , refresh_rate;const struct ast_vbios_enhtable *best =NULL ;u32 hborder, vborder;bool check_sync;
@@ -96,22 +95,19 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_moswitch (fb->format->cpp[0 ] *8 ) {case 8 : vbios_mode->std_table = &vbios_stdtable[VGAModeIndex]; - color_index = VGAModeIndex -1 ;break ;case 16 : vbios_mode->std_table = &vbios_stdtable[HiCModeIndex]; - color_index = HiCModeIndex;break ;case 24 :case 32 : vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex]; - color_index = TrueCModeIndex;break ;default :return false; } -switch (crtc->mode.crtc_hdisplay) { +switch (mode->crtc_hdisplay) {case 640 : vbios_mode->enh_table = &res_640x480[refresh_rate_index];break ;
@@ -122,7 +118,7 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo vbios_mode->enh_table = &res_1024x768[refresh_rate_index];break ;case 1280 : -if (crtc->mode.crtc_vdisplay ==800 ) +if (mode->crtc_vdisplay ==800 ) vbios_mode->enh_table = &res_1280x800[refresh_rate_index];else vbios_mode->enh_table = &res_1280x1024[refresh_rate_index];
@@ -134,7 +130,7 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo vbios_mode->enh_table = &res_1440x900[refresh_rate_index];break ;case 1600 : -if (crtc->mode.crtc_vdisplay ==900 ) +if (mode->crtc_vdisplay ==900 ) vbios_mode->enh_table = &res_1600x900[refresh_rate_index];else vbios_mode->enh_table = &res_1600x1200[refresh_rate_index];
@@ -143,7 +139,7 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo vbios_mode->enh_table = &res_1680x1050[refresh_rate_index];break ;case 1920 : -if (crtc->mode.crtc_vdisplay ==1080 ) +if (mode->crtc_vdisplay ==1080 ) vbios_mode->enh_table = &res_1920x1080[refresh_rate_index];else vbios_mode->enh_table = &res_1920x1200[refresh_rate_index];
@@ -154,7 +150,8 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo refresh_rate =drm_mode_vrefresh (mode); check_sync = vbios_mode->enh_table->flags & WideScreenMode; - do { + +while (1 ) {const struct ast_vbios_enhtable *loop = vbios_mode->enh_table;while (loop->refresh_rate !=0xff ) {
@@ -178,7 +175,8 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_moif (best || !check_sync)break ; check_sync =0 ; - }while (1 ); + } +if (best) vbios_mode->enh_table = best;
@@ -203,34 +201,65 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo vbios_mode->enh_table->vfp + vbios_mode->enh_table->vsync); - refresh_rate_index = vbios_mode->enh_table->refresh_rate_index; - mode_id = vbios_mode->enh_table->mode_id; +return true; +} -if (ast->chip ==AST1180 ) { -/* TODO 1180 */ - }else { -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x8c , (u8)((color_index &0xf ) <<4 )); -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x8d , refresh_rate_index &0xff ); -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x8e , mode_id &0xff ); - -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x91 ,0x00 ); -if (vbios_mode->enh_table->flags & NewModeInfo) { -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x91 ,0xa8 ); -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x92 , - fb->format->cpp[0 ] *8 ); -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x93 , adjusted_mode->clock /1000 ); -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x94 , adjusted_mode->crtc_hdisplay); -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x95 , adjusted_mode->crtc_hdisplay >>8 ); - -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x96 , adjusted_mode->crtc_vdisplay); -ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x97 , adjusted_mode->crtc_vdisplay >>8 ); - } +static void ast_set_vbios_color_reg (struct drm_crtc *crtc, +const struct drm_framebuffer *fb, +const struct ast_vbios_mode_info *vbios_mode) +{ +struct ast_private *ast = crtc->dev->dev_private; +u32 color_index; + +switch (fb->format->cpp[0 ]) { +case 1 : + color_index = VGAModeIndex -1 ; +break ; +case 2 : + color_index = HiCModeIndex; +break ; +case 3 : +case 4 : + color_index = TrueCModeIndex; +default : +return ; } -return true; +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x8c , (u8)((color_index &0x0f ) <<4 )); + +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x91 ,0x00 ); + +if (vbios_mode->enh_table->flags & NewModeInfo) { +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x91 ,0xa8 ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x92 , fb->format->cpp[0 ] *8 ); + } +} + +static void ast_set_vbios_mode_reg (struct drm_crtc *crtc, +const struct drm_display_mode *adjusted_mode, +const struct ast_vbios_mode_info *vbios_mode) +{ +struct ast_private *ast = crtc->dev->dev_private; +u32 refresh_rate_index, mode_id; + + refresh_rate_index = vbios_mode->enh_table->refresh_rate_index; + mode_id = vbios_mode->enh_table->mode_id; + +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x8d , refresh_rate_index &0xff ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x8e , mode_id &0xff ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x91 ,0x00 ); +if (vbios_mode->enh_table->flags & NewModeInfo) { +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x91 ,0xa8 ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x93 , adjusted_mode->clock /1000 ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x94 , adjusted_mode->crtc_hdisplay); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x95 , adjusted_mode->crtc_hdisplay >>8 ); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x96 , adjusted_mode->crtc_vdisplay); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0x97 , adjusted_mode->crtc_vdisplay >>8 ); + } } +static void ast_set_std_reg (struct drm_crtc *crtc,struct drm_display_mode *mode,struct ast_vbios_mode_info *vbios_mode) {
@@ -581,20 +610,24 @@ static int ast_crtc_mode_set(struct drm_crtc *crtc, {struct drm_device *dev = crtc->dev;struct ast_private *ast = crtc->dev->dev_private; +const struct drm_framebuffer *fb = crtc->primary->fb;struct ast_vbios_mode_info vbios_mode; -bool ret; +bool succ; +if (ast->chip ==AST1180 ) {DRM_ERROR ("AST 1180 modesetting not supported\n" );return -EINVAL ; } - ret =ast_get_vbios_mode_info (crtc, mode, adjusted_mode, &vbios_mode); -if (ret == false) + succ =ast_get_vbios_mode_info (fb, mode, adjusted_mode, &vbios_mode); +if (!succ)return -EINVAL ; +ast_open_key (ast); +ast_set_vbios_color_reg (crtc, fb, &vbios_mode); +ast_set_vbios_mode_reg (crtc, adjusted_mode, &vbios_mode);ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0xa1 ,0x06 ); -ast_set_std_reg (crtc, adjusted_mode, &vbios_mode);ast_set_crtc_reg (crtc, adjusted_mode, &vbios_mode);ast_set_offset_reg (crtc);
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 6/9 drm/ast: Add primary plane
In reply to Thomas ZimmermannLike the original mode-setting code, the primary plane supports XRGB888, RGB565 and C8. The plane itself only pins BOs and sets the base address and scanline offset. The mode-setting code will be located in the CRTC's atomic helpers.
v2:
* don't set plane call-back functions to NULL explicitly
* define plane format array in global scope
--- drivers/gpu/drm/ast/ast_drv.h | 2 + drivers/gpu/drm/ast/ast_mode.c | 89 +++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +2 -0
@@ -121,6 +121,8 @@ struct ast_private {unsigned int next_index; } cursor; +struct drm_plane primary_plane; +bool support_wide_screen;enum { ast_use_p2a,
drivers/gpu/drm/ast/ast_mode.c +87 -2
138 lines not on this page · raw message
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 6/9] drm/ast: Add primary plane
Quoted 10 lines · Thomas Zimmermann
Like the original mode-setting code, the primary plane supports XRGB888, RGB565 and C8. The plane itself only pins BOs and sets the base address and scanline offset. The mode-setting code will be located in the CRTC's atomic helpers.
v2:
* don't set plane call-back functions to NULL explicitly
* define plane format array in global scopeSigned-off-by Thomas Zimmermann <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 7/9 drm/ast: Add CRTC helpers for atomic modesetting
In reply to Thomas ZimmermannAs the CRTC code has already been prepared for a split between mode setting and plane handling, most of the CRTC's atomic modesetting is build upon primitives of the non-atomic implementation.
--- drivers/gpu/drm/ast/ast_mode.c | 105 ++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_mode.c +104 -1
@@ -727,6 +727,103 @@ static void ast_crtc_commit(struct drm_crtc *crtc)ast_crtc_load_lut (crtc); } +static int ast_crtc_helper_atomic_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +struct ast_private *ast = crtc->dev->dev_private; +struct drm_plane_state *plane_state; +bool succ; +struct drm_display_mode adjusted_mode; +struct ast_vbios_mode_info vbios_mode; + +if (ast->chip ==AST1180 ) { +DRM_ERROR ("AST 1180 modesetting not supported\n" ); +return -EINVAL ; + } + + plane_state = crtc->primary->state; + +if (plane_state && plane_state->fb) { + succ =ast_get_vbios_mode_info (plane_state->fb, &state->mode, + &adjusted_mode, &vbios_mode); +if (!succ) +return -EINVAL ; + } + +return 0 ; +} + +static void ast_crtc_helper_atomic_begin (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +struct ast_private *ast = crtc->dev->dev_private; + +ast_open_key (ast); +} + +static void ast_crtc_helper_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +const struct drm_framebuffer *fb = crtc->primary->state->fb; +struct drm_display_mode adjusted_mode; +struct ast_vbios_mode_info vbios_mode; +bool succ; + + crtc->state->no_vblank = true; + +if (!fb) +return ; + +ast_set_color_reg (crtc, fb); + +memset (&adjusted_mode,0 ,sizeof (adjusted_mode)); +drm_mode_copy (&adjusted_mode, &crtc->state->adjusted_mode); + + succ =ast_get_vbios_mode_info (fb, &crtc->state->adjusted_mode, + &adjusted_mode, &vbios_mode); +if (WARN_ON_ONCE (!succ)) +return ; + +ast_set_vbios_color_reg (crtc, fb, &vbios_mode); +} + +static void +ast_crtc_helper_atomic_enable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +struct drm_device *dev = crtc->dev; +struct ast_private *ast = crtc->dev->dev_private; +const struct drm_framebuffer *fb = crtc->primary->state->fb; +struct drm_display_mode adjusted_mode; +struct ast_vbios_mode_info vbios_mode; +bool succ; + +memset (&adjusted_mode,0 ,sizeof (adjusted_mode)); +drm_mode_copy (&adjusted_mode, &crtc->state->adjusted_mode); + + succ =ast_get_vbios_mode_info (fb, &crtc->state->adjusted_mode, + &adjusted_mode, &vbios_mode); +if (WARN_ON_ONCE (!succ)) +return ; + +ast_set_vbios_mode_reg (crtc, &adjusted_mode, &vbios_mode); +ast_set_index_reg (ast,AST_IO_CRTC_PORT ,0xa1 ,0x06 ); +ast_set_std_reg (crtc, &adjusted_mode, &vbios_mode); +ast_set_crtc_reg (crtc, &adjusted_mode, &vbios_mode); +ast_set_dclk_reg (dev, &adjusted_mode, &vbios_mode); +ast_set_crtthd_reg (crtc); +ast_set_sync_reg (dev, &adjusted_mode, &vbios_mode); +ast_set_dac_reg (crtc, &adjusted_mode, &vbios_mode); + +ast_crtc_dpms (crtc,DRM_MODE_DPMS_ON ); +} + +static void +ast_crtc_helper_atomic_disable (struct drm_crtc *crtc, +struct drm_crtc_state *old_crtc_state) +{ +ast_crtc_dpms (crtc,DRM_MODE_DPMS_OFF ); +}static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = { .dpms = ast_crtc_dpms,
@@ -735,7 +832,11 @@ static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = { .disable = ast_crtc_disable, .prepare = ast_crtc_prepare, .commit = ast_crtc_commit, - + .atomic_check = ast_crtc_helper_atomic_check, + .atomic_begin = ast_crtc_helper_atomic_begin, + .atomic_flush = ast_crtc_helper_atomic_flush, + .atomic_enable = ast_crtc_helper_atomic_enable, + .atomic_disable = ast_crtc_helper_atomic_disable, };static void ast_crtc_reset (struct drm_crtc *crtc)
@@ -766,6 +867,8 @@ static const struct drm_crtc_funcs ast_crtc_funcs = { .set_config = drm_crtc_helper_set_config, .gamma_set = ast_crtc_gamma_set, .destroy = ast_crtc_destroy, + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, };static int ast_crtc_init (struct drm_device *dev)
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 8/9 drm/ast: Add cursor plane
In reply to Thomas ZimmermannThe cursor plane uses an internal format of ARGB4444. To userspace, we announce ARGB8888 and do the transformation internally.
v2:
* don't set plane call-back functions to NULL explicitly
* define plane format array in global scope
--- drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_mode.c | 155 ++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_drv.h +1 -0
@@ -122,6 +122,7 @@ struct ast_private { } cursor;struct drm_plane primary_plane; +struct drm_plane cursor_plane;bool support_wide_screen;enum {
drivers/gpu/drm/ast/ast_mode.c +154 -1
179 lines not on this page · raw message
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 8/9] drm/ast: Add cursor plane
Quoted 7 lines · Thomas Zimmermann
The cursor plane uses an internal format of ARGB4444. To userspace, we announce ARGB8888 and do the transformation internally.
v2:
* don't set plane call-back functions to NULL explicitly
* define plane format array in global scope
Quoted 5 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_mode.c | 155 ++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 1 deletion(-)#
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH v2 9/9 drm/ast: Enable atomic modesetting
In reply to Thomas ZimmermannThis commit sets the remaining atomic-modesetting helpers and the flag DRIVER_ATOMIC. Legacy cursor functions are removed in favor of the cursor plane. For power management, atomic helpers replace the indvidual operations that the driver currently runs.
Atomic modesetting is enabled with this commit.
--- drivers/gpu/drm/ast/ast_drv.c | 24 ++- drivers/gpu/drm/ast/ast_main.c | 5 + drivers/gpu/drm/ast/ast_mode.c | 290 ++------------------------------- 3 files changed, 33 insertions(+), 286 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +10 -14
@@ -99,14 +99,14 @@ ast_pci_remove(struct pci_dev *pdev)drm_put_dev (dev); } - -static int ast_drm_freeze (struct drm_device *dev) { -drm_kms_helper_poll_disable (dev); -pci_save_state (dev->pdev); -drm_fb_helper_set_suspend_unlocked (dev->fb_helper, true); +int error; + error =drm_mode_config_helper_suspend (dev); +if (error) +return error; +pci_save_state (dev->pdev);return 0 ; }
@@ -114,11 +114,7 @@ static int ast_drm_thaw(struct drm_device *dev) {ast_post_gpu (dev); -drm_mode_config_reset (dev); -drm_helper_resume_force_mode (dev); -drm_fb_helper_set_suspend_unlocked (dev->fb_helper, false); - -return 0 ; +return drm_mode_config_helper_resume (dev); }static int ast_drm_resume (struct drm_device *dev)
@@ -131,8 +127,6 @@ static int ast_drm_resume(struct drm_device *dev) ret =ast_drm_thaw (dev);if (ret)return ret; - -drm_kms_helper_poll_enable (dev);return 0 ; }
@@ -150,6 +144,7 @@ static int ast_pm_suspend(struct device *dev)pci_set_power_state (pdev, PCI_D3hot);return 0 ; } +static int ast_pm_resume (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);
@@ -165,7 +160,6 @@ static int ast_pm_freeze(struct device *dev)if (!ddev || !ddev->dev_private)return -ENODEV ;return ast_drm_freeze (ddev); - }static int ast_pm_thaw (struct device *dev)
@@ -203,7 +197,9 @@ static struct pci_driver ast_pci_driver = {DEFINE_DRM_GEM_FOPS (ast_fops);static struct drm_driver driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM , + .driver_features =DRIVER_ATOMIC | +DRIVER_GEM | +DRIVER_MODESET , .load = ast_driver_load, .unload = ast_driver_unload,
drivers/gpu/drm/ast/ast_main.c +5 -0
@@ -28,6 +28,7 @@#include <linux/pci.h> +#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_gem.h>
@@ -412,6 +413,8 @@ enum drm_mode_status ast_mode_config_mode_valid(struct drm_device *dev,static const struct drm_mode_config_funcs ast_mode_funcs = { .fb_create = drm_gem_fb_create, .mode_valid = ast_mode_config_mode_valid, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, };static u32 ast_get_vram_info (struct drm_device *dev)
@@ -529,6 +532,8 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)if (ret) goto out_free; +drm_mode_config_reset (dev); + ret =drm_fbdev_generic_setup (dev,32 );if (ret) goto out_free;
drivers/gpu/drm/ast/ast_mode.c +18 -272
381 lines not on this page · raw message
Signature · 6 lines
2.23.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel