From nobody Fri Dec 19 12:49:46 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B08133F38D for ; Tue, 4 Nov 2025 18:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762279842; cv=none; b=OeUZ8kQWqeBNWFuATP/SxfbjlKT9bY3rbBIMRjagCucz12NO/LoV6WvJqqA++AJutE5gy6corS5W7Kpv27obI8eoMWtXlPrVd5OTyIcAg3Ncxa10FPhsHxSpBVsxNct/NFpalLf2MCUbgt/oo7SyJkSkQsF6CvrXy/3ecaLNruo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762279842; c=relaxed/simple; bh=AwNsBEXtld8Vm9hp9BoKpLqlKkVlUZll6jhZVMKLZHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FhjYbL/z72B/ye90xmikbJtmfvwMgl87aqK1FNk4YfSpMWQjV9Dhk965rzzZugzq933ziMOl5XcqfSTBT1gr+hsam6+QcVAgLWS8WU5FhFnBLXftx01V/DPyl0AzcrjgWVZfV73FwTmXAvbQD+YwcY/l5ZwRhD6DzhE7cE4nJrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fQQoc4gK; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fQQoc4gK" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-477442b1de0so20307635e9.1 for ; Tue, 04 Nov 2025 10:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762279837; x=1762884637; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZGi+vdnTcOUyDYZpLxnZDrsIWdYfcQsWdysVijdDOkg=; b=fQQoc4gKr0robiiWcN2S4dtB1WB/7QEQos3APL9eGRXn+Kt3YZICyVC2RgRWN2Jp7M OPR7FpfZZULKDfMz7WxlwbOzklgS5fJv3VmhW/t76wdUD3IZ7/4Zab6ZVpsEcaWBMMl1 MDdkO/EF6p+N/tdSD24DqLQHrQYurY8Wy3nFBk1XHHQgjTcPDbdzDCJce0Y+O+2PO4SV zTLzCWkkxkoeTHiqGkSq8jfFDUA2Yqx7GlLJia/cWcy2Vs5NgoPws2GDD0FMVvYqPCNw PWros0OYL7BpIRavhUKeGc84gFJX/azfD2HOtEUJJiWaqoK5lT50/B1n5Jc4eByz5Lu3 1pzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279837; x=1762884637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZGi+vdnTcOUyDYZpLxnZDrsIWdYfcQsWdysVijdDOkg=; b=Tf+v5HmP/N7r7Gm7mdT96IALhMTeN/I3iPQFLlsqeWrp8+KIpVrsoOl35JeP0qgkxP cpLSS+iBZTRFHwHo4JbJNvNWm3nf2UYSutYm1drWQFf1T2nQfzgUrOgFYXQhzVwmC9WS F0W8fFBAvsy7KZywpXuSGLEVT4bFlsryO+BbSV8bmbzwGOs9/yLN5Vx/XrL/WngltmoQ 5bP+dE8iicRsH7HuO7ZYhKG4FZ1DBPqEKMDRCJ1UguWR1uydeViTwY4EA0xE6vqwojHj MSr3tTeuxdgJE4wm0h+8NGwJ383AZnFMpdvcu/TnGPqxwpoKuTDNrW6iXvRM8md2E2A6 iwLg== X-Forwarded-Encrypted: i=1; AJvYcCW1F7rI8qPCNm1CJ4p2Si4l1H7t0gVwe9k3Ms+S5mWzHyain5GcwD8ynJvvkK/ejWDTxIwPPYun8Nn5tfg=@vger.kernel.org X-Gm-Message-State: AOJu0YzC8Ljr1eTuXkx2Rdw1D9nRdMY0rGZzZUMjGe4WoDRJZ5nn7ycp gAZtoIBS3lCe0jLbteCzCcUgUAdJV4Jcoqg7ySasmHQfHlhicF33tnmqD+9wXw== X-Gm-Gg: ASbGncsA7W34MKbNxcpEip3b4Qx/EWvivf6mIpCm5pL+5gjKw4UBcBAYARNIP79Ogee tzmXiKTLOV+L5lvTqSfEka7URYtZxovRlpSKXriLkDC4dCc3LwoYchhZVAou5YSJBGE3J/m41wZ CyWAnhj5I9KffdXK11538/kRLiCarTobrK/AvOrhQ4sXfnnQZzHfQLJxiN3AeUPSuBNOhdFR7v2 UhXYU6SIZ5uC7KWpvyFzc6rmRIl5qeoa7hKRhUFahD3xZyZKdTBmFI4/PTlUXAhV7zMq1ommg7L pjer5+JgMaj2rnmrMKCpJuLzTrJqHGoJ79/XYw5V00uY6Nn0AgAeIwJ88bOSvV1qBut/W83DkUI T6zfFAVsvVihHf/ggN3JUyvwVNR+i2dkB3v8iqjXIT5MtZp6KbXH/mkHhoOchInKFJCFiSBdQgP UaeCBHa6fm7hw6j6uGhY26ZsyznmnE X-Google-Smtp-Source: AGHT+IHIwFu5ZH0/QDn36lvi+N0EaA4mwC2bsFB40ThRoEib3Q1pusV/RILcIs1eoSSs5+dZbwnBew== X-Received: by 2002:a05:600c:3f0c:b0:471:1435:b0ea with SMTP id 5b1f17b1804b1-4775cdf4413mr1867405e9.24.1762279837126; Tue, 04 Nov 2025 10:10:37 -0800 (PST) Received: from jernej-laptop ([178.79.73.218]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477558c1a03sm24688685e9.2.2025.11.04.10.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:10:36 -0800 (PST) From: Jernej Skrabec To: wens@csie.org Cc: mripard@kernel.org, maarten.lankhorst@linux.intel.com, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec , Chen-Yu Tsai , Ryan Walklin Subject: [PATCH v2 28/30] drm/sun4i: layer: replace mixer with layer struct Date: Tue, 4 Nov 2025 19:09:40 +0100 Message-ID: <20251104180942.61538-29-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251104180942.61538-1-jernej.skrabec@gmail.com> References: <20251104180942.61538-1-jernej.skrabec@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This allows to almost completely decouple layer code from mixer. This is important for DE33. Reviewed-by: Chen-Yu Tsai Tested-by: Ryan Walklin Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_csc.c | 4 ++-- drivers/gpu/drm/sun4i/sun8i_mixer.c | 6 +++-- drivers/gpu/drm/sun4i/sun8i_mixer.h | 27 ++++++++++----------- drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 24 +++++++++---------- drivers/gpu/drm/sun4i/sun8i_ui_layer.h | 3 ++- drivers/gpu/drm/sun4i/sun8i_ui_scaler.c | 16 ++++++------- drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 31 ++++++++++++------------- drivers/gpu/drm/sun4i/sun8i_vi_layer.h | 3 ++- drivers/gpu/drm/sun4i/sun8i_vi_scaler.c | 19 +++++++-------- 9 files changed, 66 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_csc.c b/drivers/gpu/drm/sun4i/sun8= i_csc.c index 30779db2f9b2..ce81c12f511d 100644 --- a/drivers/gpu/drm/sun4i/sun8i_csc.c +++ b/drivers/gpu/drm/sun4i/sun8i_csc.c @@ -233,14 +233,14 @@ void sun8i_csc_config(struct sun8i_layer *layer, u32 mode =3D sun8i_csc_get_mode(state); u32 base; =20 - if (layer->mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) { + if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) { sun8i_de3_ccsc_setup(layer->regs, layer->channel, mode, state->color_encoding, state->color_range); return; } =20 - base =3D ccsc_base[layer->mixer->cfg->lay_cfg.ccsc][layer->channel]; + base =3D ccsc_base[layer->cfg->ccsc][layer->channel]; =20 sun8i_csc_setup(layer->regs, base, mode, state->color_encoding, diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/su= n8i_mixer.c index 4559e959a32d..50fc20100c90 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -338,7 +338,8 @@ static struct drm_plane **sun8i_layers_init(struct drm_= device *drm, =20 layer =3D sun8i_vi_layer_init_one(drm, mixer, type, mixer->engine.regs, i, - phy_index, plane_cnt); + phy_index, plane_cnt, + &mixer->cfg->lay_cfg); if (IS_ERR(layer)) { dev_err(drm->dev, "Couldn't initialize overlay plane\n"); @@ -363,7 +364,8 @@ static struct drm_plane **sun8i_layers_init(struct drm_= device *drm, =20 layer =3D sun8i_ui_layer_init_one(drm, mixer, type, mixer->engine.regs, index, - phy_index, plane_cnt); + phy_index, plane_cnt, + &mixer->cfg->lay_cfg); if (IS_ERR(layer)) { dev_err(drm->dev, "Couldn't initialize %s plane\n", i ? "overlay" : "primary"); diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.h b/drivers/gpu/drm/sun4i/su= n8i_mixer.h index 5b6068755ad1..3948023e095b 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.h +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.h @@ -225,13 +225,14 @@ enum { }; =20 struct sun8i_layer { - struct drm_plane plane; - struct sun8i_mixer *mixer; - int type; - int index; - int channel; - int overlay; - struct regmap *regs; + struct drm_plane plane; + struct sun8i_mixer *mixer; + int type; + int index; + int channel; + int overlay; + struct regmap *regs; + const struct sun8i_layer_cfg *cfg; }; =20 static inline struct sun8i_layer * @@ -260,14 +261,14 @@ sun8i_blender_regmap(struct sun8i_mixer *mixer) } =20 static inline u32 -sun8i_channel_base(struct sun8i_mixer *mixer, int channel) +sun8i_channel_base(struct sun8i_layer *layer) { - if (mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) - return DE33_CH_BASE + channel * DE33_CH_SIZE; - else if (mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) - return DE3_CH_BASE + channel * DE3_CH_SIZE; + if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) + return DE33_CH_BASE + layer->channel * DE33_CH_SIZE; + else if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) + return DE3_CH_BASE + layer->channel * DE3_CH_SIZE; else - return DE2_CH_BASE + channel * DE2_CH_SIZE; + return DE2_CH_BASE + layer->channel * DE2_CH_SIZE; } =20 int sun8i_mixer_drm_format_to_hw(u32 format, u32 *hw_format); diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i= /sun8i_ui_layer.c index f71f5a8d0427..dc4298590024 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c @@ -27,10 +27,9 @@ =20 static void sun8i_ui_layer_disable(struct sun8i_layer *layer) { - struct sun8i_mixer *mixer =3D layer->mixer; - u32 ch_base =3D sun8i_channel_base(mixer, layer->channel); + u32 ch_base =3D sun8i_channel_base(layer); =20 - regmap_write(mixer->engine.regs, + regmap_write(layer->regs, SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, layer->overlay), 0); } =20 @@ -38,11 +37,10 @@ static void sun8i_ui_layer_update_attributes(struct sun= 8i_layer *layer, struct drm_plane *plane) { struct drm_plane_state *state =3D plane->state; - struct sun8i_mixer *mixer =3D layer->mixer; const struct drm_format_info *fmt; u32 val, ch_base, hw_fmt; =20 - ch_base =3D sun8i_channel_base(mixer, layer->channel); + ch_base =3D sun8i_channel_base(layer); fmt =3D state->fb->format; sun8i_mixer_drm_format_to_hw(fmt->format, &hw_fmt); =20 @@ -61,7 +59,6 @@ static void sun8i_ui_layer_update_coord(struct sun8i_laye= r *layer, struct drm_plane *plane) { struct drm_plane_state *state =3D plane->state; - struct sun8i_mixer *mixer =3D layer->mixer; u32 src_w, src_h, dst_w, dst_h; u32 outsize, insize; u32 hphase, vphase; @@ -70,7 +67,7 @@ static void sun8i_ui_layer_update_coord(struct sun8i_laye= r *layer, DRM_DEBUG_DRIVER("Updating UI channel %d overlay %d\n", layer->channel, layer->overlay); =20 - ch_base =3D sun8i_channel_base(mixer, layer->channel); + ch_base =3D sun8i_channel_base(layer); =20 src_w =3D drm_rect_width(&state->src) >> 16; src_h =3D drm_rect_height(&state->src) >> 16; @@ -102,7 +99,7 @@ static void sun8i_ui_layer_update_coord(struct sun8i_lay= er *layer, hscale =3D state->src_w / state->crtc_w; vscale =3D state->src_h / state->crtc_h; =20 - if (mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) { + if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) { sun8i_vi_scaler_setup(layer, src_w, src_h, dst_w, dst_h, hscale, vscale, hphase, vphase, state->fb->format); @@ -114,7 +111,7 @@ static void sun8i_ui_layer_update_coord(struct sun8i_la= yer *layer, } } else { DRM_DEBUG_DRIVER("HW scaling is not needed\n"); - if (mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) + if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) sun8i_vi_scaler_enable(layer, false); else sun8i_ui_scaler_enable(layer, false); @@ -125,14 +122,13 @@ static void sun8i_ui_layer_update_buffer(struct sun8i= _layer *layer, struct drm_plane *plane) { struct drm_plane_state *state =3D plane->state; - struct sun8i_mixer *mixer =3D layer->mixer; struct drm_framebuffer *fb =3D state->fb; struct drm_gem_dma_object *gem; dma_addr_t dma_addr; u32 ch_base; int bpp; =20 - ch_base =3D sun8i_channel_base(mixer, layer->channel); + ch_base =3D sun8i_channel_base(layer); =20 /* Get the physical address of the buffer in memory */ gem =3D drm_fb_dma_get_gem_obj(fb, 0); @@ -190,7 +186,7 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane= *plane, min_scale =3D DRM_PLANE_NO_SCALING; max_scale =3D DRM_PLANE_NO_SCALING; =20 - if (layer->mixer->cfg->lay_cfg.scaler_mask & BIT(layer->channel)) { + if (layer->cfg->scaler_mask & BIT(layer->channel)) { min_scale =3D SUN8I_UI_SCALER_SCALE_MIN; max_scale =3D SUN8I_UI_SCALER_SCALE_MAX; } @@ -266,7 +262,8 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_= device *drm, enum drm_plane_type type, struct regmap *regs, int index, int phy_index, - int plane_cnt) + int plane_cnt, + const struct sun8i_layer_cfg *cfg) { struct sun8i_layer *layer; int ret; @@ -281,6 +278,7 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_= device *drm, layer->channel =3D phy_index; layer->overlay =3D 0; layer->regs =3D regs; + layer->cfg =3D cfg; =20 /* possible crtcs are set later */ ret =3D drm_universal_plane_init(drm, &layer->plane, 0, diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.h b/drivers/gpu/drm/sun4i= /sun8i_ui_layer.h index 9383c3364df3..c357b39999ff 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.h +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.h @@ -54,5 +54,6 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_de= vice *drm, enum drm_plane_type type, struct regmap *regs, int index, int phy_index, - int plane_cnt); + int plane_cnt, + const struct sun8i_layer_cfg *cfg); #endif /* _SUN8I_UI_LAYER_H_ */ diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_scaler.c b/drivers/gpu/drm/sun4= i/sun8i_ui_scaler.c index 4d06c366de7f..a178da8f532a 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_scaler.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_scaler.c @@ -89,18 +89,18 @@ static const u32 lan2coefftab16[240] =3D { 0x0b1c1603, 0x0d1c1502, 0x0e1d1401, 0x0f1d1301, }; =20 -static u32 sun8i_ui_scaler_base(struct sun8i_mixer *mixer, int channel) +static u32 sun8i_ui_scaler_base(struct sun8i_layer *layer) { - int offset =3D mixer->cfg->lay_cfg.vi_scaler_num; + int offset =3D layer->cfg->vi_scaler_num; =20 - if (mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) + if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) return DE3_VI_SCALER_UNIT_BASE + DE3_VI_SCALER_UNIT_SIZE * offset + - DE3_UI_SCALER_UNIT_SIZE * (channel - offset); + DE3_UI_SCALER_UNIT_SIZE * (layer->channel - offset); else return DE2_VI_SCALER_UNIT_BASE + DE2_VI_SCALER_UNIT_SIZE * offset + - DE2_UI_SCALER_UNIT_SIZE * (channel - offset); + DE2_UI_SCALER_UNIT_SIZE * (layer->channel - offset); } =20 static int sun8i_ui_scaler_coef_index(unsigned int step) @@ -129,10 +129,9 @@ static int sun8i_ui_scaler_coef_index(unsigned int ste= p) =20 void sun8i_ui_scaler_enable(struct sun8i_layer *layer, bool enable) { - struct sun8i_mixer *mixer =3D layer->mixer; u32 val, base; =20 - base =3D sun8i_ui_scaler_base(mixer, layer->channel); + base =3D sun8i_ui_scaler_base(layer); =20 if (enable) val =3D SUN8I_SCALER_GSU_CTRL_EN | @@ -147,12 +146,11 @@ void sun8i_ui_scaler_setup(struct sun8i_layer *layer, u32 src_w, u32 src_h, u32 dst_w, u32 dst_h, u32 hscale, u32 vscale, u32 hphase, u32 vphase) { - struct sun8i_mixer *mixer =3D layer->mixer; u32 insize, outsize; int i, offset; u32 base; =20 - base =3D sun8i_ui_scaler_base(mixer, layer->channel); + base =3D sun8i_ui_scaler_base(layer); =20 hphase <<=3D SUN8I_UI_SCALER_PHASE_FRAC - 16; vphase <<=3D SUN8I_UI_SCALER_PHASE_FRAC - 16; diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i= /sun8i_vi_layer.c index 0286e7322612..afe38ea03beb 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -20,10 +20,9 @@ =20 static void sun8i_vi_layer_disable(struct sun8i_layer *layer) { - struct sun8i_mixer *mixer =3D layer->mixer; - u32 ch_base =3D sun8i_channel_base(mixer, layer->channel); + u32 ch_base =3D sun8i_channel_base(layer); =20 - regmap_write(mixer->engine.regs, + regmap_write(layer->regs, SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), 0); } =20 @@ -31,11 +30,10 @@ static void sun8i_vi_layer_update_attributes(struct sun= 8i_layer *layer, struct drm_plane *plane) { struct drm_plane_state *state =3D plane->state; - struct sun8i_mixer *mixer =3D layer->mixer; const struct drm_format_info *fmt; u32 val, ch_base, hw_fmt; =20 - ch_base =3D sun8i_channel_base(mixer, layer->channel); + ch_base =3D sun8i_channel_base(layer); fmt =3D state->fb->format; sun8i_mixer_drm_format_to_hw(fmt->format, &hw_fmt); =20 @@ -43,7 +41,7 @@ static void sun8i_vi_layer_update_attributes(struct sun8i= _layer *layer, if (!fmt->is_yuv) val |=3D SUN8I_MIXER_CHAN_VI_LAYER_ATTR_RGB_MODE; val |=3D SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN; - if (mixer->cfg->de_type >=3D SUN8I_MIXER_DE3) { + if (layer->cfg->de_type >=3D SUN8I_MIXER_DE3) { val |=3D SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA(state->alpha >> 8); val |=3D (state->alpha =3D=3D DRM_BLEND_ALPHA_OPAQUE) ? SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA_MODE_PIXEL : @@ -53,7 +51,7 @@ static void sun8i_vi_layer_update_attributes(struct sun8i= _layer *layer, regmap_write(layer->regs, SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), val); =20 - if (mixer->cfg->lay_cfg.de2_fcc_alpha) { + if (layer->cfg->de2_fcc_alpha) { regmap_write(layer->regs, SUN8I_MIXER_FCC_GLOBAL_ALPHA_REG, SUN8I_MIXER_FCC_GLOBAL_ALPHA(state->alpha >> 8)); @@ -77,7 +75,7 @@ static void sun8i_vi_layer_update_coord(struct sun8i_laye= r *layer, DRM_DEBUG_DRIVER("Updating VI channel %d overlay %d\n", layer->channel, layer->overlay); =20 - ch_base =3D sun8i_channel_base(mixer, layer->channel); + ch_base =3D sun8i_channel_base(layer); =20 src_w =3D drm_rect_width(&state->src) >> 16; src_h =3D drm_rect_height(&state->src) >> 16; @@ -152,7 +150,7 @@ static void sun8i_vi_layer_update_coord(struct sun8i_la= yer *layer, } =20 /* it seems that every RGB scaler has buffer for 2048 pixels */ - scanline =3D subsampled ? mixer->cfg->lay_cfg.scanline_yuv : 2048; + scanline =3D subsampled ? layer->cfg->scanline_yuv : 2048; =20 if (src_w > scanline) { DRM_DEBUG_DRIVER("Using horizontal coarse scaling\n"); @@ -194,7 +192,6 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_l= ayer *layer, struct drm_plane *plane) { struct drm_plane_state *state =3D plane->state; - struct sun8i_mixer *mixer =3D layer->mixer; struct drm_framebuffer *fb =3D state->fb; const struct drm_format_info *format =3D fb->format; struct drm_gem_dma_object *gem; @@ -203,7 +200,7 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_l= ayer *layer, u32 ch_base; int i; =20 - ch_base =3D sun8i_channel_base(mixer, layer->channel); + ch_base =3D sun8i_channel_base(layer); =20 /* Adjust x and y to be dividable by subsampling factor */ src_x =3D (state->src.x1 >> 16) & ~(format->hsub - 1); @@ -278,7 +275,7 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane= *plane, min_scale =3D DRM_PLANE_NO_SCALING; max_scale =3D DRM_PLANE_NO_SCALING; =20 - if (layer->mixer->cfg->lay_cfg.scaler_mask & BIT(layer->channel)) { + if (layer->cfg->scaler_mask & BIT(layer->channel)) { min_scale =3D SUN8I_VI_SCALER_SCALE_MIN; max_scale =3D SUN8I_VI_SCALER_SCALE_MAX; } @@ -414,7 +411,8 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_= device *drm, enum drm_plane_type type, struct regmap *regs, int index, int phy_index, - int plane_cnt) + int plane_cnt, + const struct sun8i_layer_cfg *cfg) { u32 supported_encodings, supported_ranges; unsigned int format_count; @@ -432,8 +430,9 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_= device *drm, layer->channel =3D phy_index; layer->overlay =3D 0; layer->regs =3D regs; + layer->cfg =3D cfg; =20 - if (mixer->cfg->de_type >=3D SUN8I_MIXER_DE3) { + if (layer->cfg->de_type >=3D SUN8I_MIXER_DE3) { formats =3D sun8i_vi_layer_de3_formats; format_count =3D ARRAY_SIZE(sun8i_vi_layer_de3_formats); } else { @@ -452,7 +451,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_= device *drm, return ERR_PTR(ret); } =20 - if (mixer->cfg->lay_cfg.de2_fcc_alpha || mixer->cfg->de_type >=3D SUN8I_M= IXER_DE3) { + if (layer->cfg->de2_fcc_alpha || layer->cfg->de_type >=3D SUN8I_MIXER_DE3= ) { ret =3D drm_plane_create_alpha_property(&layer->plane); if (ret) { dev_err(drm->dev, "Couldn't add alpha property\n"); @@ -469,7 +468,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_= device *drm, =20 supported_encodings =3D BIT(DRM_COLOR_YCBCR_BT601) | BIT(DRM_COLOR_YCBCR_BT709); - if (mixer->cfg->de_type >=3D SUN8I_MIXER_DE3) + if (layer->cfg->de_type >=3D SUN8I_MIXER_DE3) supported_encodings |=3D BIT(DRM_COLOR_YCBCR_BT2020); =20 supported_ranges =3D BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h b/drivers/gpu/drm/sun4i= /sun8i_vi_layer.h index 89d0c32e63cf..6ec68baa2409 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.h +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.h @@ -59,5 +59,6 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_de= vice *drm, enum drm_plane_type type, struct regmap *regs, int index, int phy_index, - int plane_cnt); + int plane_cnt, + const struct sun8i_layer_cfg *cfg); #endif /* _SUN8I_VI_LAYER_H_ */ diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_scaler.c b/drivers/gpu/drm/sun4= i/sun8i_vi_scaler.c index fe0bb1de6f08..3dec4eeb1ba2 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_scaler.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_scaler.c @@ -833,17 +833,17 @@ static const u32 bicubic4coefftab32[480] =3D { 0x1012110d, 0x1012110d, 0x1013110c, 0x1013110c, }; =20 -static u32 sun8i_vi_scaler_base(struct sun8i_mixer *mixer, int channel) +static u32 sun8i_vi_scaler_base(struct sun8i_layer *layer) { - if (mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) + if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE33) return DE33_VI_SCALER_UNIT_BASE + - DE33_CH_SIZE * channel; - else if (mixer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) + DE33_CH_SIZE * layer->channel; + else if (layer->cfg->de_type =3D=3D SUN8I_MIXER_DE3) return DE3_VI_SCALER_UNIT_BASE + - DE3_VI_SCALER_UNIT_SIZE * channel; + DE3_VI_SCALER_UNIT_SIZE * layer->channel; else return DE2_VI_SCALER_UNIT_BASE + - DE2_VI_SCALER_UNIT_SIZE * channel; + DE2_VI_SCALER_UNIT_SIZE * layer->channel; } =20 static int sun8i_vi_scaler_coef_index(unsigned int step) @@ -914,7 +914,7 @@ void sun8i_vi_scaler_enable(struct sun8i_layer *layer, = bool enable) { u32 val, base; =20 - base =3D sun8i_vi_scaler_base(layer->mixer, layer->channel); + base =3D sun8i_vi_scaler_base(layer); =20 if (enable) val =3D SUN8I_SCALER_VSU_CTRL_EN | @@ -931,12 +931,11 @@ void sun8i_vi_scaler_setup(struct sun8i_layer *layer, u32 hscale, u32 vscale, u32 hphase, u32 vphase, const struct drm_format_info *format) { - struct sun8i_mixer *mixer =3D layer->mixer; u32 chphase, cvphase; u32 insize, outsize; u32 base; =20 - base =3D sun8i_vi_scaler_base(mixer, layer->channel); + base =3D sun8i_vi_scaler_base(layer); =20 hphase <<=3D SUN8I_VI_SCALER_PHASE_FRAC - 16; vphase <<=3D SUN8I_VI_SCALER_PHASE_FRAC - 16; @@ -960,7 +959,7 @@ void sun8i_vi_scaler_setup(struct sun8i_layer *layer, cvphase =3D vphase; } =20 - if (mixer->cfg->de_type >=3D SUN8I_MIXER_DE3) { + if (layer->cfg->de_type >=3D SUN8I_MIXER_DE3) { u32 val; =20 if (format->hsub =3D=3D 1 && format->vsub =3D=3D 1) --=20 2.51.2