From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 79A633446AD for ; Tue, 4 Nov 2025 18:10:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762279827; cv=none; b=Py694picuYVSGcwHe6a0WwF7VjFCV2Wqzp8K1z7MEte8lkJYDXjL7aZ6+G6+LyWFSufNJmnUOb0ZfCNuLCLaC+9IOzA5aMc4QykSWxNUgTODlz5WVbSbTmrq6VrAht7OaLOhUmnEiAH2uTdYgtbDbQS/NuBcfAZHYw2MD4YEv7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762279827; c=relaxed/simple; bh=GiArxfeMeAL0CBeo7YtFoMvlFTq7fgoVCY+irBH9sNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oVnjiAOZerZ6mpj2o+8UOpWlSkPH3WVcGnbBhByXtXZbDhdYztwWUVXkZu3B3o+UzLi2NPgi08ksHBCotRMQj5Hu0UUTQ5OzmnE7fqsXi0seQJpzh8y1ZFasxrKAvPIeY+CF3ty+2DOsjjtg5H2dIp4w86bwnY4IpQhUDcH53nE= 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=TY1l+T/E; arc=none smtp.client-ip=209.85.128.46 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="TY1l+T/E" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-47754e9cc7fso7992745e9.2 for ; Tue, 04 Nov 2025 10:10:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762279823; x=1762884623; darn=lists.linux.dev; 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=s3EV/MxibVMeuKGvb6vWmFsIs3Yu10QpUHip3gqCW54=; b=TY1l+T/EoYoheQSj7fgq0ycot79w4YLEvPBtytjZ5fvm6r1NdDwIzCBL0JQiIB97fb QU6Fhz+hp+tCdCY1cUdJkKn2Fem3RMrBlcUNKWxcGW/Ke3F2/4m6r2rhU7uwahgn8MrR M5W8cr1/ErgXBrvuKqaotAzcuGhTHku+EWxXsBOvLS1neMAz5eeaV3tltxO03b8i3i2g WFDvdJQaQxvdiRROvpWS+YUMgKY0qNVe28oqam3OS4Kkfnlv7h+2ucJYQTB8xCG/2cfr RyPjvzeFFvq1uLMDvYSL/qBYYsKgRV5sqxNJ0yfFRC+5KtnD9Hjg/fW3ayLhBpfWh6+x B8mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762279824; x=1762884624; 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=s3EV/MxibVMeuKGvb6vWmFsIs3Yu10QpUHip3gqCW54=; b=Ic3A499Jlbv42W2145HiDp3LVP6xoCUpM19vlDgBaFyuqnP5+SLOe2QXVhQkTxJOgq u2cleIzc5OhLahQRHb2S1v6ozW7tN4TStGTdSFZp7/3BpCfMT2KONRvll3H8pkXZZZVe fzbaLb231vdUgtX46LyrhhJjuhSX2+NxJpQIwG/Y8JpHkMudqje/LgpQI+ZFNKBf62rU HtrJ5V0CT6olXXlerqAovtTr8OPS91mWGPUy3JcDVBBiU99MT/5B/AIzq0mdhG06DeA1 QnbPsYoG/o0FqfwrzXEIkyakBmXeG5OptuZwfEoXc1h1RQAgG62YOCbVjdUnXaxpcr6s 7+6g== X-Forwarded-Encrypted: i=1; AJvYcCWyQq66xPivmW9pfgEARR2bV2RjDuF+O8GW/cmqNJH7lBIg3siMfxdm7faNiGUcMV1o9O3ChRScZ+UBcg==@lists.linux.dev X-Gm-Message-State: AOJu0YygACnJJ+HWqmAlhSLtvqN1NsuBOE2jv1eTE7U7FW5bRTk3WDHr EoHSVpnQVfziSoYySSgTC9O/7Ox4EE2MlXbLbBVEIPFFebmwssUBP4yH X-Gm-Gg: ASbGncsPoQ8bq4dbHVZUEAkjO3wjt+v65RosPNS/fvY7mK68XWQ+BjwtNKk89ppDXM2 hGisK8vd0tz/AbCg3vDrVP8+J3Dj++5F3pQD2VT2pYydcERDUnqP1vOP2UWi/QInY0Ol6/c4hYp Yv1QucKS2RGHqXbxxT3WtM5hsN89ut2HCLh6W4J3Hd3RSO4SJIbpPkmCW8QNoVxvc8k0wINeESy yE/tSHP654pDChV8RpmOQzXMUyTNXc0ylemlfPkYTyyxFOwHIdHtKuje92ujtEPL4LhZxmCGf9T crVe1toFW2flqQvMJp07DvuYpAgtqcg/J7FT7dlj7/Ckmy+/vE4rIkLQPJZ1My7+jW7ET2MSuts 5fAB0Bz5m/YpHdqrRsSmxCDvZHMoeG1ZPF1qS6W26DQi/WqU9DXHIazoZIbcM1NGDo6FaJCyXE6 FQNaNgmqi9eL9lfT/9M7SSbosVFkDQ X-Google-Smtp-Source: AGHT+IG3T52xUW38yiQP+ctGCFR1rUHrIm69DPF54UH5khemOeYMj6ikOX9GGLBlfNHgLEUvN0EOGw== X-Received: by 2002:a05:600c:6286:b0:477:569c:34e9 with SMTP id 5b1f17b1804b1-4775ce61516mr2003715e9.23.1762279823483; Tue, 04 Nov 2025 10:10:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Nov 2025 10:10:23 -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 17/30] drm/sun4i: vi_layer: use layer struct instead of multiple args Date: Tue, 4 Nov 2025 19:09:29 +0100 Message-ID: <20251104180942.61538-18-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-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This change is equally a cleanup (less arguments) and preparation for DE33 separate plane driver. It will introduce additional register space. No functional changes. Reviewed-by: Chen-Yu Tsai Tested-by: Ryan Walklin Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 58 +++++++++++++------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index 805db4ea714b..ba9c03f04f03 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -18,24 +18,24 @@ #include "sun8i_vi_layer.h" #include "sun8i_vi_scaler.h" -static void sun8i_vi_layer_disable(struct sun8i_mixer *mixer, - int channel, int overlay) +static void sun8i_vi_layer_disable(struct sun8i_layer *layer) { - u32 ch_base = sun8i_channel_base(mixer, channel); + struct sun8i_mixer *mixer = layer->mixer; + u32 ch_base = sun8i_channel_base(mixer, layer->channel); regmap_write(mixer->engine.regs, - SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay), 0); + SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), 0); } -static void sun8i_vi_layer_update_attributes(struct sun8i_mixer *mixer, - int channel, int overlay, +static void sun8i_vi_layer_update_attributes(struct sun8i_layer *layer, struct drm_plane *plane) { struct drm_plane_state *state = plane->state; + struct sun8i_mixer *mixer = layer->mixer; const struct drm_format_info *fmt; u32 val, ch_base, hw_fmt; - ch_base = sun8i_channel_base(mixer, channel); + ch_base = sun8i_channel_base(mixer, layer->channel); fmt = state->fb->format; sun8i_mixer_drm_format_to_hw(fmt->format, &hw_fmt); @@ -55,14 +55,15 @@ static void sun8i_vi_layer_update_attributes(struct sun8i_mixer *mixer, } regmap_write(mixer->engine.regs, - SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay), val); + SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), val); } -static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, - int overlay, struct drm_plane *plane) +static void sun8i_vi_layer_update_coord(struct sun8i_layer *layer, + struct drm_plane *plane) { struct drm_plane_state *state = plane->state; const struct drm_format_info *format = state->fb->format; + struct sun8i_mixer *mixer = layer->mixer; u32 src_w, src_h, dst_w, dst_h; u32 outsize, insize; u32 hphase, vphase; @@ -72,9 +73,9 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, u32 ch_base; DRM_DEBUG_DRIVER("Updating VI channel %d overlay %d\n", - channel, overlay); + layer->channel, layer->overlay); - ch_base = sun8i_channel_base(mixer, channel); + ch_base = sun8i_channel_base(mixer, layer->channel); src_w = drm_rect_width(&state->src) >> 16; src_h = drm_rect_height(&state->src) >> 16; @@ -112,7 +113,7 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, (state->src.y1 >> 16) & ~(format->vsub - 1)); DRM_DEBUG_DRIVER("Layer source size W: %d H: %d\n", src_w, src_h); regmap_write(mixer->engine.regs, - SUN8I_MIXER_CHAN_VI_LAYER_SIZE(ch_base, overlay), + SUN8I_MIXER_CHAN_VI_LAYER_SIZE(ch_base, layer->overlay), insize); regmap_write(mixer->engine.regs, SUN8I_MIXER_CHAN_VI_OVL_SIZE(ch_base), @@ -161,13 +162,13 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, hscale = (src_w << 16) / dst_w; vscale = (src_h << 16) / dst_h; - sun8i_vi_scaler_setup(mixer, channel, src_w, src_h, dst_w, + sun8i_vi_scaler_setup(mixer, layer->channel, src_w, src_h, dst_w, dst_h, hscale, vscale, hphase, vphase, format); - sun8i_vi_scaler_enable(mixer, channel, true); + sun8i_vi_scaler_enable(mixer, layer->channel, true); } else { DRM_DEBUG_DRIVER("HW scaling is not needed\n"); - sun8i_vi_scaler_enable(mixer, channel, false); + sun8i_vi_scaler_enable(mixer, layer->channel, false); } regmap_write(mixer->engine.regs, @@ -188,10 +189,11 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, SUN8I_MIXER_CHAN_VI_DS_M(vm)); } -static void sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel, - int overlay, struct drm_plane *plane) +static void sun8i_vi_layer_update_buffer(struct sun8i_layer *layer, + struct drm_plane *plane) { struct drm_plane_state *state = plane->state; + struct sun8i_mixer *mixer = layer->mixer; struct drm_framebuffer *fb = state->fb; const struct drm_format_info *format = fb->format; struct drm_gem_dma_object *gem; @@ -200,7 +202,7 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel, u32 ch_base; int i; - ch_base = sun8i_channel_base(mixer, channel); + ch_base = sun8i_channel_base(mixer, layer->channel); /* Adjust x and y to be dividable by subsampling factor */ src_x = (state->src.x1 >> 16) & ~(format->hsub - 1); @@ -232,7 +234,7 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel, i + 1, fb->pitches[i]); regmap_write(mixer->engine.regs, SUN8I_MIXER_CHAN_VI_LAYER_PITCH(ch_base, - overlay, i), + layer->overlay, i), fb->pitches[i]); DRM_DEBUG_DRIVER("Setting %d. buffer address to %pad\n", @@ -240,7 +242,7 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel, regmap_write(mixer->engine.regs, SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(ch_base, - overlay, i), + layer->overlay, i), lower_32_bits(dma_addr)); } } @@ -292,20 +294,16 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane, struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); struct sun8i_layer *layer = plane_to_sun8i_layer(plane); - struct sun8i_mixer *mixer = layer->mixer; if (!new_state->crtc || !new_state->visible) { - sun8i_vi_layer_disable(mixer, layer->channel, layer->overlay); + sun8i_vi_layer_disable(layer); return; } - sun8i_vi_layer_update_attributes(mixer, layer->channel, - layer->overlay, plane); - sun8i_vi_layer_update_coord(mixer, layer->channel, - layer->overlay, plane); - sun8i_csc_config(mixer, layer->channel, new_state); - sun8i_vi_layer_update_buffer(mixer, layer->channel, - layer->overlay, plane); + sun8i_vi_layer_update_attributes(layer, plane); + sun8i_vi_layer_update_coord(layer, plane); + sun8i_csc_config(layer->mixer, layer->channel, new_state); + sun8i_vi_layer_update_buffer(layer, plane); } static const struct drm_plane_helper_funcs sun8i_vi_layer_helper_funcs = { -- 2.51.2