2626#include "sun8i_ui_scaler.h"
2727#include "sun8i_vi_scaler.h"
2828
29- static void sun8i_ui_layer_disable (struct sun8i_mixer * mixer ,
30- int channel , int overlay )
29+ static void sun8i_ui_layer_disable (struct sun8i_layer * layer )
3130{
32- u32 ch_base = sun8i_channel_base (mixer , channel );
31+ struct sun8i_mixer * mixer = layer -> mixer ;
32+ u32 ch_base = sun8i_channel_base (mixer , layer -> channel );
3333
3434 regmap_write (mixer -> engine .regs ,
35- SUN8I_MIXER_CHAN_UI_LAYER_ATTR (ch_base , overlay ), 0 );
35+ SUN8I_MIXER_CHAN_UI_LAYER_ATTR (ch_base , layer -> overlay ), 0 );
3636}
3737
38- static void sun8i_ui_layer_update_attributes (struct sun8i_mixer * mixer ,
39- int channel , int overlay ,
38+ static void sun8i_ui_layer_update_attributes (struct sun8i_layer * layer ,
4039 struct drm_plane * plane )
4140{
4241 struct drm_plane_state * state = plane -> state ;
42+ struct sun8i_mixer * mixer = layer -> mixer ;
4343 const struct drm_format_info * fmt ;
4444 u32 val , ch_base , hw_fmt ;
4545
46- ch_base = sun8i_channel_base (mixer , channel );
46+ ch_base = sun8i_channel_base (mixer , layer -> channel );
4747 fmt = state -> fb -> format ;
4848 sun8i_mixer_drm_format_to_hw (fmt -> format , & hw_fmt );
4949
@@ -55,22 +55,23 @@ static void sun8i_ui_layer_update_attributes(struct sun8i_mixer *mixer,
5555 val |= SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN ;
5656
5757 regmap_write (mixer -> engine .regs ,
58- SUN8I_MIXER_CHAN_UI_LAYER_ATTR (ch_base , overlay ), val );
58+ SUN8I_MIXER_CHAN_UI_LAYER_ATTR (ch_base , layer -> overlay ), val );
5959}
6060
61- static void sun8i_ui_layer_update_coord (struct sun8i_mixer * mixer , int channel ,
62- int overlay , struct drm_plane * plane )
61+ static void sun8i_ui_layer_update_coord (struct sun8i_layer * layer ,
62+ struct drm_plane * plane )
6363{
6464 struct drm_plane_state * state = plane -> state ;
65+ struct sun8i_mixer * mixer = layer -> mixer ;
6566 u32 src_w , src_h , dst_w , dst_h ;
6667 u32 outsize , insize ;
6768 u32 hphase , vphase ;
6869 u32 ch_base ;
6970
7071 DRM_DEBUG_DRIVER ("Updating UI channel %d overlay %d\n" ,
71- channel , overlay );
72+ layer -> channel , layer -> overlay );
7273
73- ch_base = sun8i_channel_base (mixer , channel );
74+ ch_base = sun8i_channel_base (mixer , layer -> channel );
7475
7576 src_w = drm_rect_width (& state -> src ) >> 16 ;
7677 src_h = drm_rect_height (& state -> src ) >> 16 ;
@@ -88,7 +89,7 @@ static void sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
8889 state -> src .x1 >> 16 , state -> src .y1 >> 16 );
8990 DRM_DEBUG_DRIVER ("Layer source size W: %d H: %d\n" , src_w , src_h );
9091 regmap_write (mixer -> engine .regs ,
91- SUN8I_MIXER_CHAN_UI_LAYER_SIZE (ch_base , overlay ),
92+ SUN8I_MIXER_CHAN_UI_LAYER_SIZE (ch_base , layer -> overlay ),
9293 insize );
9394 regmap_write (mixer -> engine .regs ,
9495 SUN8I_MIXER_CHAN_UI_OVL_SIZE (ch_base ),
@@ -103,37 +104,38 @@ static void sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
103104 vscale = state -> src_h / state -> crtc_h ;
104105
105106 if (mixer -> cfg -> de_type == SUN8I_MIXER_DE33 ) {
106- sun8i_vi_scaler_setup (mixer , channel , src_w , src_h ,
107+ sun8i_vi_scaler_setup (mixer , layer -> channel , src_w , src_h ,
107108 dst_w , dst_h , hscale , vscale ,
108109 hphase , vphase ,
109110 state -> fb -> format );
110- sun8i_vi_scaler_enable (mixer , channel , true);
111+ sun8i_vi_scaler_enable (mixer , layer -> channel , true);
111112 } else {
112- sun8i_ui_scaler_setup (mixer , channel , src_w , src_h ,
113+ sun8i_ui_scaler_setup (mixer , layer -> channel , src_w , src_h ,
113114 dst_w , dst_h , hscale , vscale ,
114115 hphase , vphase );
115- sun8i_ui_scaler_enable (mixer , channel , true);
116+ sun8i_ui_scaler_enable (mixer , layer -> channel , true);
116117 }
117118 } else {
118119 DRM_DEBUG_DRIVER ("HW scaling is not needed\n" );
119120 if (mixer -> cfg -> de_type == SUN8I_MIXER_DE33 )
120- sun8i_vi_scaler_enable (mixer , channel , false);
121+ sun8i_vi_scaler_enable (mixer , layer -> channel , false);
121122 else
122- sun8i_ui_scaler_enable (mixer , channel , false);
123+ sun8i_ui_scaler_enable (mixer , layer -> channel , false);
123124 }
124125}
125126
126- static void sun8i_ui_layer_update_buffer (struct sun8i_mixer * mixer , int channel ,
127- int overlay , struct drm_plane * plane )
127+ static void sun8i_ui_layer_update_buffer (struct sun8i_layer * layer ,
128+ struct drm_plane * plane )
128129{
129130 struct drm_plane_state * state = plane -> state ;
131+ struct sun8i_mixer * mixer = layer -> mixer ;
130132 struct drm_framebuffer * fb = state -> fb ;
131133 struct drm_gem_dma_object * gem ;
132134 dma_addr_t dma_addr ;
133135 u32 ch_base ;
134136 int bpp ;
135137
136- ch_base = sun8i_channel_base (mixer , channel );
138+ ch_base = sun8i_channel_base (mixer , layer -> channel );
137139
138140 /* Get the physical address of the buffer in memory */
139141 gem = drm_fb_dma_get_gem_obj (fb , 0 );
@@ -151,13 +153,13 @@ static void sun8i_ui_layer_update_buffer(struct sun8i_mixer *mixer, int channel,
151153 /* Set the line width */
152154 DRM_DEBUG_DRIVER ("Layer line width: %d bytes\n" , fb -> pitches [0 ]);
153155 regmap_write (mixer -> engine .regs ,
154- SUN8I_MIXER_CHAN_UI_LAYER_PITCH (ch_base , overlay ),
156+ SUN8I_MIXER_CHAN_UI_LAYER_PITCH (ch_base , layer -> overlay ),
155157 fb -> pitches [0 ]);
156158
157159 DRM_DEBUG_DRIVER ("Setting buffer address to %pad\n" , & dma_addr );
158160
159161 regmap_write (mixer -> engine .regs ,
160- SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR (ch_base , overlay ),
162+ SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR (ch_base , layer -> overlay ),
161163 lower_32_bits (dma_addr ));
162164}
163165
@@ -208,19 +210,15 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane,
208210 struct drm_plane_state * new_state = drm_atomic_get_new_plane_state (state ,
209211 plane );
210212 struct sun8i_layer * layer = plane_to_sun8i_layer (plane );
211- struct sun8i_mixer * mixer = layer -> mixer ;
212213
213214 if (!new_state -> crtc || !new_state -> visible ) {
214- sun8i_ui_layer_disable (mixer , layer -> channel , layer -> overlay );
215+ sun8i_ui_layer_disable (layer );
215216 return ;
216217 }
217218
218- sun8i_ui_layer_update_attributes (mixer , layer -> channel ,
219- layer -> overlay , plane );
220- sun8i_ui_layer_update_coord (mixer , layer -> channel ,
221- layer -> overlay , plane );
222- sun8i_ui_layer_update_buffer (mixer , layer -> channel ,
223- layer -> overlay , plane );
219+ sun8i_ui_layer_update_attributes (layer , plane );
220+ sun8i_ui_layer_update_coord (layer , plane );
221+ sun8i_ui_layer_update_buffer (layer , plane );
224222}
225223
226224static const struct drm_plane_helper_funcs sun8i_ui_layer_helper_funcs = {
0 commit comments