2015-10-29 09:36:23 +01:00
/*
* Copyright ( C ) 2015 Free Electrons
* Copyright ( C ) 2015 NextThing Co
*
* Maxime Ripard < maxime . ripard @ free - electrons . com >
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation ; either version 2 of
* the License , or ( at your option ) any later version .
*/
# include <drm/drm_atomic_helper.h>
# include <drm/drm_fb_cma_helper.h>
2017-09-24 14:26:23 +02:00
# include <drm/drm_gem_framebuffer_helper.h>
2015-10-29 09:36:23 +01:00
# include <drm/drmP.h>
# include "sun4i_drv.h"
2016-09-08 18:59:22 +08:00
# include "sun4i_framebuffer.h"
2015-10-29 09:36:23 +01:00
static void sun4i_de_output_poll_changed ( struct drm_device * drm )
{
struct sun4i_drv * drv = drm - > dev_private ;
2016-07-20 18:32:34 +02:00
drm_fbdev_cma_hotplug_event ( drv - > fbdev ) ;
2015-10-29 09:36:23 +01:00
}
static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {
. output_poll_changed = sun4i_de_output_poll_changed ,
. atomic_check = drm_atomic_helper_check ,
. atomic_commit = drm_atomic_helper_commit ,
2017-09-24 14:26:23 +02:00
. fb_create = drm_gem_fb_create ,
2015-10-29 09:36:23 +01:00
} ;
struct drm_fbdev_cma * sun4i_framebuffer_init ( struct drm_device * drm )
{
drm_mode_config_reset ( drm ) ;
drm - > mode_config . max_width = 8192 ;
drm - > mode_config . max_height = 8192 ;
drm - > mode_config . funcs = & sun4i_de_mode_config_funcs ;
drm: Rely on mode_config data for fb_helper initialization
Instead of receiving the num_crts as a parameter, we can read it
directly from the mode_config structure. I audited the drivers that
invoke this helper and I believe all of them initialize the mode_config
struct accordingly, prior to calling the fb_helper.
I used the following coccinelle hack to make this transformation, except
for the function headers and comment updates. The first and second
rules are split because I couldn't find a way to remove the unused
temporary variables at the same time I removed the parameter.
// <smpl>
@r@
expression A,B,D,E;
identifier C;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
@@
identifier r.C;
type T;
expression V;
@@
- T C;
<...
when != C
- C = V;
...>
// </smpl>
Changes since v1:
- Rebased on top of the tip of drm-misc-next.
- Remove mention to sti since a proper fix got merged.
Suggested-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170202162640.27261-1-krisman@collabora.co.uk
2017-02-02 14:26:40 -02:00
return drm_fbdev_cma_init ( drm , 32 , drm - > mode_config . num_connector ) ;
2015-10-29 09:36:23 +01:00
}
void sun4i_framebuffer_free ( struct drm_device * drm )
{
struct sun4i_drv * drv = drm - > dev_private ;
drm_fbdev_cma_fini ( drv - > fbdev ) ;
}