[PATCH v3 06/11] drm/sun4i: add support for Allwinner DE2 mixers
Allwinner have a new "Display Engine 2.0" in their new SoCs, which comes with mixers to do graphic processing and feed data to TCON, like the old backends and frontends. Add support for the mixer on Allwinner V3s SoC; it's the simplest one. Currently a lot of functions are still missing -- more investigations are needed to gain enough information for them. Signed-off-by: Icenowy Zheng --- Refactored patch in v3. drivers/gpu/drm/sun4i/Kconfig | 10 + drivers/gpu/drm/sun4i/Makefile | 4 + drivers/gpu/drm/sun4i/sun8i_layer.c | 156 +++ drivers/gpu/drm/sun4i/sun8i_layer.h | 35 drivers/gpu/drm/sun4i/sun8i_mixer.c | 386 drivers/gpu/drm/sun4i/sun8i_mixer.h | 131 6 files changed, 722 insertions(+) create mode 100644 drivers/gpu/drm/sun4i/sun8i_layer.c create mode 100644 drivers/gpu/drm/sun4i/sun8i_layer.h create mode 100644 drivers/gpu/drm/sun4i/sun8i_mixer.c create mode 100644 drivers/gpu/drm/sun4i/sun8i_mixer.h diff --git a/drivers/gpu/drm/sun4i/Kconfig b/drivers/gpu/drm/sun4i/Kconfig index 5a8227f37cc4..15557484520d 100644 --- a/drivers/gpu/drm/sun4i/Kconfig +++ b/drivers/gpu/drm/sun4i/Kconfig @@ -22,3 +22,13 @@ config DRM_SUN4I_BACKEND original Allwinner Display Engine, which has a backend to do some alpha blending and feed graphics to TCON. If M is selected the module will be called sun4i-backend. + +config DRM_SUN4I_SUN8I_MIXER + tristate "Support for Allwinner Display Engine 2.0 Mixer" + depends on DRM_SUN4I + default MACH_SUN8I + help + Choose this option if you have an Allwinner SoC with the + Allwinner Display Engine 2.0, which has a mixer to do some + graphics mixture and feed graphics to TCON, If M is + selected the module will be called sun8i-mixer. diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile index 1db1068b9be1..7625c2dad1bb 100644 --- a/drivers/gpu/drm/sun4i/Makefile +++ b/drivers/gpu/drm/sun4i/Makefile @@ -9,7 +9,11 @@ sun4i-tcon-y += sun4i_crtc.o sun4i-backend-y += sun4i_layer.o sun4i-backend-y += sun4i_backend.o +sun8i-mixer-y += sun8i_layer.o +sun8i-mixer-y += sun8i_mixer.o + obj-$(CONFIG_DRM_SUN4I)+= sun4i-drm.o sun4i-tcon.o obj-$(CONFIG_DRM_SUN4I_BACKEND)+= sun4i-backend.o +obj-$(CONFIG_DRM_SUN4I_SUN8I_MIXER) += sun8i-mixer.o obj-$(CONFIG_DRM_SUN4I)+= sun6i_drc.o obj-$(CONFIG_DRM_SUN4I)+= sun4i_tv.o diff --git a/drivers/gpu/drm/sun4i/sun8i_layer.c b/drivers/gpu/drm/sun4i/sun8i_layer.c new file mode 100644 index ..5cc4a7f8a7ae --- /dev/null +++ b/drivers/gpu/drm/sun4i/sun8i_layer.c @@ -0,0 +1,156 @@ +/* + * Copyright (C) Icenowy Zheng + * + * Based on sun4i_layer.h, which is: + * Copyright (C) 2015 Free Electrons + * Copyright (C) 2015 NextThing Co + * + * Maxime Ripard + * + * 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 +#include +#include +#include + +#include "sun4i_crtc.h" +#include "sun8i_layer.h" +#include "sun8i_mixer.h" +#include "sunxi_layer.h" + +struct sun8i_plane_desc { + enum drm_plane_type type; + const uint32_t *formats; + uint32_tnformats; +}; + +static int sun8i_mixer_layer_atomic_check(struct drm_plane *plane, + struct drm_plane_state *state) +{ + return 0; +} + +static void sun8i_mixer_layer_atomic_disable(struct drm_plane *plane, + struct drm_plane_state *old_state) +{ + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); + struct sun8i_mixer *mixer = layer->mixer; + + sun8i_mixer_layer_enable(mixer, layer->id, false); +} + +static void sun8i_mixer_layer_atomic_update(struct drm_plane *plane, + struct drm_plane_state *old_state) +{ + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); + struct sun8i_mixer *mixer = layer->mixer; + + sun8i_mixer_update_layer_coord(mixer, layer->id, plane); + sun8i_mixer_update_layer_formats(mixer, layer->id, plane); + sun8i_mixer_update_layer_buffer(mixer, layer->id, plane); + sun8i_mixer_layer_enable(mixer, layer->id, true); +} + +static struct drm_plane_helper_funcs sun8i_mixer_layer_helper_funcs = { + .atomic_check = sun8i_mixer_layer_atomic_check, + .atomic_disable = sun8i_mixer_layer_atomic_disable, + .atomic_update = sun8i_mixer_layer_atomic_update, +}; + +static const struct drm_plane_funcs sun8i_mixer_layer_funcs = { + .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, + .atomic_duplicate_state = drm_atomic
Re: [linux-sunxi] [PATCH v3 06/11] drm/sun4i: add support for Allwinner DE2 mixers
Hi, Dne sreda, 29. marec 2017 ob 21:46:08 CEST je Icenowy Zheng napisal(a): > Allwinner have a new "Display Engine 2.0" in their new SoCs, which comes > with mixers to do graphic processing and feed data to TCON, like the old > backends and frontends. > > Add support for the mixer on Allwinner V3s SoC; it's the simplest one. > > Currently a lot of functions are still missing -- more investigations > are needed to gain enough information for them. > > Signed-off-by: Icenowy Zheng > --- > Refactored patch in v3. > > drivers/gpu/drm/sun4i/Kconfig | 10 + > drivers/gpu/drm/sun4i/Makefile | 4 + > drivers/gpu/drm/sun4i/sun8i_layer.c | 156 +++ > drivers/gpu/drm/sun4i/sun8i_layer.h | 35 > drivers/gpu/drm/sun4i/sun8i_mixer.c | 386 > drivers/gpu/drm/sun4i/sun8i_mixer.h | > 131 > 6 files changed, 722 insertions(+) > create mode 100644 drivers/gpu/drm/sun4i/sun8i_layer.c > create mode 100644 drivers/gpu/drm/sun4i/sun8i_layer.h > create mode 100644 drivers/gpu/drm/sun4i/sun8i_mixer.c > create mode 100644 drivers/gpu/drm/sun4i/sun8i_mixer.h > > diff --git a/drivers/gpu/drm/sun4i/Kconfig b/drivers/gpu/drm/sun4i/Kconfig > index 5a8227f37cc4..15557484520d 100644 > --- a/drivers/gpu/drm/sun4i/Kconfig > +++ b/drivers/gpu/drm/sun4i/Kconfig > @@ -22,3 +22,13 @@ config DRM_SUN4I_BACKEND > original Allwinner Display Engine, which has a backend to > do some alpha blending and feed graphics to TCON. If M is > selected the module will be called sun4i-backend. > + > +config DRM_SUN4I_SUN8I_MIXER > + tristate "Support for Allwinner Display Engine 2.0 Mixer" > + depends on DRM_SUN4I > + default MACH_SUN8I > + help > + Choose this option if you have an Allwinner SoC with the > + Allwinner Display Engine 2.0, which has a mixer to do some > + graphics mixture and feed graphics to TCON, If M is > + selected the module will be called sun8i-mixer. > diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile > index 1db1068b9be1..7625c2dad1bb 100644 > --- a/drivers/gpu/drm/sun4i/Makefile > +++ b/drivers/gpu/drm/sun4i/Makefile > @@ -9,7 +9,11 @@ sun4i-tcon-y += sun4i_crtc.o > sun4i-backend-y += sun4i_layer.o > sun4i-backend-y += sun4i_backend.o > > +sun8i-mixer-y += sun8i_layer.o > +sun8i-mixer-y += sun8i_mixer.o > + > obj-$(CONFIG_DRM_SUN4I) += sun4i-drm.o sun4i-tcon.o > obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o > +obj-$(CONFIG_DRM_SUN4I_SUN8I_MIXER) += sun8i-mixer.o > obj-$(CONFIG_DRM_SUN4I) += sun6i_drc.o > obj-$(CONFIG_DRM_SUN4I) += sun4i_tv.o > diff --git a/drivers/gpu/drm/sun4i/sun8i_layer.c > b/drivers/gpu/drm/sun4i/sun8i_layer.c new file mode 100644 > index ..5cc4a7f8a7ae > --- /dev/null > +++ b/drivers/gpu/drm/sun4i/sun8i_layer.c > @@ -0,0 +1,156 @@ > +/* > + * Copyright (C) Icenowy Zheng > + * > + * Based on sun4i_layer.h, which is: > + * Copyright (C) 2015 Free Electrons > + * Copyright (C) 2015 NextThing Co > + * > + * Maxime Ripard > + * > + * 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 > +#include > +#include > +#include > + > +#include "sun4i_crtc.h" > +#include "sun8i_layer.h" > +#include "sun8i_mixer.h" > +#include "sunxi_layer.h" > + > +struct sun8i_plane_desc { > +enum drm_plane_type type; > +const uint32_t *formats; > +uint32_tnformats; > +}; > + > +static int sun8i_mixer_layer_atomic_check(struct drm_plane *plane, > + struct drm_plane_state *state) > +{ > + return 0; > +} > + > +static void sun8i_mixer_layer_atomic_disable(struct drm_plane *plane, > +struct drm_plane_state > *old_state) > +{ > + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); > + struct sun8i_mixer *mixer = layer->mixer; > + > + sun8i_mixer_layer_enable(mixer, layer->id, false); > +} > + > +static void sun8i_mixer_layer_atomic_update(struct drm_plane *plane, > + struct drm_plane_state *old_state) > +{ > + struct sun8i_layer *layer = plane_to_sun8i_layer(plane); > + struct sun8i_mixer *mixer = layer->mixer; > + > + sun8i_mixer_update_layer_coord(mixer, layer->id, plane); > + sun8i_mixer_update_layer_formats(mixer, layer->id, plane); > + sun8i_mixer_update_layer_buffer(mixer, layer->id, plane); > + sun8i_mixer_layer_enable(mixer, layer->id, true); > +} > + > +static struct drm_plane_helper_funcs sun8i_mixer_layer_helper_funcs = { > + .atomic_check = sun8i_mixer_layer_atomic_check, > + .atomic_disable = sun8i_mixer_layer