Commit 134155a5 authored by Ondrej Jirman's avatar Ondrej Jirman Committed by Maxime Ripard

drm/sun4i: Unify sun8i_*_layer structs

These structs are identical, use a single struct to represent private
data for the DRM plane. This is a preparation for configuring layer
routing from the CRTC (mixer) instead of current approach of setting
up routing from individual layer's atomic_update callback.
Signed-off-by: default avatarOndrej Jirman <megi@xff.cz>
Reviewed-by: default avatarMaxime Ripard <mripard@kernel.org>
Reviewed-by: default avatarJernej Skrabec <jernej.skrabec@gmail.com>
Link: https://lore.kernel.org/r/20240224150604.3855534-2-megi@xff.czSigned-off-by: default avatarMaxime Ripard <mripard@kernel.org>
parent 66541509
...@@ -271,7 +271,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm, ...@@ -271,7 +271,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
for (i = 0; i < mixer->cfg->vi_num; i++) { for (i = 0; i < mixer->cfg->vi_num; i++) {
struct sun8i_vi_layer *layer; struct sun8i_layer *layer;
layer = sun8i_vi_layer_init_one(drm, mixer, i); layer = sun8i_vi_layer_init_one(drm, mixer, i);
if (IS_ERR(layer)) { if (IS_ERR(layer)) {
...@@ -284,7 +284,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm, ...@@ -284,7 +284,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
} }
for (i = 0; i < mixer->cfg->ui_num; i++) { for (i = 0; i < mixer->cfg->ui_num; i++) {
struct sun8i_ui_layer *layer; struct sun8i_layer *layer;
layer = sun8i_ui_layer_init_one(drm, mixer, i); layer = sun8i_ui_layer_init_one(drm, mixer, i);
if (IS_ERR(layer)) { if (IS_ERR(layer)) {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <drm/drm_plane.h>
#include "sunxi_engine.h" #include "sunxi_engine.h"
...@@ -185,6 +186,19 @@ struct sun8i_mixer { ...@@ -185,6 +186,19 @@ struct sun8i_mixer {
struct clk *mod_clk; struct clk *mod_clk;
}; };
struct sun8i_layer {
struct drm_plane plane;
struct sun8i_mixer *mixer;
int channel;
int overlay;
};
static inline struct sun8i_layer *
plane_to_sun8i_layer(struct drm_plane *plane)
{
return container_of(plane, struct sun8i_layer, plane);
}
static inline struct sun8i_mixer * static inline struct sun8i_mixer *
engine_to_sun8i_mixer(struct sunxi_engine *engine) engine_to_sun8i_mixer(struct sunxi_engine *engine)
{ {
......
...@@ -232,7 +232,7 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane *plane, ...@@ -232,7 +232,7 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane *plane,
{ {
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
plane); plane);
struct sun8i_ui_layer *layer = plane_to_sun8i_ui_layer(plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
struct drm_crtc *crtc = new_plane_state->crtc; struct drm_crtc *crtc = new_plane_state->crtc;
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
int min_scale, max_scale; int min_scale, max_scale;
...@@ -264,7 +264,7 @@ static void sun8i_ui_layer_atomic_disable(struct drm_plane *plane, ...@@ -264,7 +264,7 @@ static void sun8i_ui_layer_atomic_disable(struct drm_plane *plane,
{ {
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane); plane);
struct sun8i_ui_layer *layer = plane_to_sun8i_ui_layer(plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
unsigned int old_zpos = old_state->normalized_zpos; unsigned int old_zpos = old_state->normalized_zpos;
struct sun8i_mixer *mixer = layer->mixer; struct sun8i_mixer *mixer = layer->mixer;
...@@ -279,7 +279,7 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane, ...@@ -279,7 +279,7 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane,
plane); plane);
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
plane); plane);
struct sun8i_ui_layer *layer = plane_to_sun8i_ui_layer(plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
unsigned int zpos = new_state->normalized_zpos; unsigned int zpos = new_state->normalized_zpos;
unsigned int old_zpos = old_state->normalized_zpos; unsigned int old_zpos = old_state->normalized_zpos;
struct sun8i_mixer *mixer = layer->mixer; struct sun8i_mixer *mixer = layer->mixer;
...@@ -345,13 +345,13 @@ static const uint64_t sun8i_layer_modifiers[] = { ...@@ -345,13 +345,13 @@ static const uint64_t sun8i_layer_modifiers[] = {
DRM_FORMAT_MOD_INVALID DRM_FORMAT_MOD_INVALID
}; };
struct sun8i_ui_layer *sun8i_ui_layer_init_one(struct drm_device *drm, struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer, struct sun8i_mixer *mixer,
int index) int index)
{ {
enum drm_plane_type type = DRM_PLANE_TYPE_OVERLAY; enum drm_plane_type type = DRM_PLANE_TYPE_OVERLAY;
int channel = mixer->cfg->vi_num + index; int channel = mixer->cfg->vi_num + index;
struct sun8i_ui_layer *layer; struct sun8i_layer *layer;
unsigned int plane_cnt; unsigned int plane_cnt;
int ret; int ret;
......
...@@ -47,21 +47,9 @@ ...@@ -47,21 +47,9 @@
#define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_COMBINED ((2) << 1) #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_COMBINED ((2) << 1)
struct sun8i_mixer; struct sun8i_mixer;
struct sun8i_layer;
struct sun8i_ui_layer { struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
struct drm_plane plane;
struct sun8i_mixer *mixer;
int channel;
int overlay;
};
static inline struct sun8i_ui_layer *
plane_to_sun8i_ui_layer(struct drm_plane *plane)
{
return container_of(plane, struct sun8i_ui_layer, plane);
}
struct sun8i_ui_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer, struct sun8i_mixer *mixer,
int index); int index);
#endif /* _SUN8I_UI_LAYER_H_ */ #endif /* _SUN8I_UI_LAYER_H_ */
...@@ -366,7 +366,7 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane, ...@@ -366,7 +366,7 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane,
{ {
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
plane); plane);
struct sun8i_vi_layer *layer = plane_to_sun8i_vi_layer(plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
struct drm_crtc *crtc = new_plane_state->crtc; struct drm_crtc *crtc = new_plane_state->crtc;
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
int min_scale, max_scale; int min_scale, max_scale;
...@@ -398,7 +398,7 @@ static void sun8i_vi_layer_atomic_disable(struct drm_plane *plane, ...@@ -398,7 +398,7 @@ static void sun8i_vi_layer_atomic_disable(struct drm_plane *plane,
{ {
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane); plane);
struct sun8i_vi_layer *layer = plane_to_sun8i_vi_layer(plane); struct sun8i_layer *layer = plane_to_sun8i_vi_layer(plane);
unsigned int old_zpos = old_state->normalized_zpos; unsigned int old_zpos = old_state->normalized_zpos;
struct sun8i_mixer *mixer = layer->mixer; struct sun8i_mixer *mixer = layer->mixer;
...@@ -413,7 +413,7 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane, ...@@ -413,7 +413,7 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane,
plane); plane);
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
plane); plane);
struct sun8i_vi_layer *layer = plane_to_sun8i_vi_layer(plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
unsigned int zpos = new_state->normalized_zpos; unsigned int zpos = new_state->normalized_zpos;
unsigned int old_zpos = old_state->normalized_zpos; unsigned int old_zpos = old_state->normalized_zpos;
struct sun8i_mixer *mixer = layer->mixer; struct sun8i_mixer *mixer = layer->mixer;
...@@ -539,14 +539,14 @@ static const uint64_t sun8i_layer_modifiers[] = { ...@@ -539,14 +539,14 @@ static const uint64_t sun8i_layer_modifiers[] = {
DRM_FORMAT_MOD_INVALID DRM_FORMAT_MOD_INVALID
}; };
struct sun8i_vi_layer *sun8i_vi_layer_init_one(struct drm_device *drm, struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer, struct sun8i_mixer *mixer,
int index) int index)
{ {
enum drm_plane_type type = DRM_PLANE_TYPE_OVERLAY; enum drm_plane_type type = DRM_PLANE_TYPE_OVERLAY;
u32 supported_encodings, supported_ranges; u32 supported_encodings, supported_ranges;
unsigned int plane_cnt, format_count; unsigned int plane_cnt, format_count;
struct sun8i_vi_layer *layer; struct sun8i_layer *layer;
const u32 *formats; const u32 *formats;
int ret; int ret;
......
...@@ -52,21 +52,9 @@ ...@@ -52,21 +52,9 @@
#define SUN8I_MIXER_CHAN_VI_DS_M(x) ((x) << 0) #define SUN8I_MIXER_CHAN_VI_DS_M(x) ((x) << 0)
struct sun8i_mixer; struct sun8i_mixer;
struct sun8i_layer;
struct sun8i_vi_layer { struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
struct drm_plane plane;
struct sun8i_mixer *mixer;
int channel;
int overlay;
};
static inline struct sun8i_vi_layer *
plane_to_sun8i_vi_layer(struct drm_plane *plane)
{
return container_of(plane, struct sun8i_vi_layer, plane);
}
struct sun8i_vi_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer, struct sun8i_mixer *mixer,
int index); int index);
#endif /* _SUN8I_VI_LAYER_H_ */ #endif /* _SUN8I_VI_LAYER_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment