From: Andy Yan <andyshrk@163.com>
To: heiko@sntech.de
Cc: hjc@rock-chips.com, krzk+dt@kernel.org,
devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
derek.foreman@collabora.com, detlev.casanova@collabora.com,
daniel@fooishbar.org, robh@kernel.org,
sebastian.reichel@collabora.com,
Andy Yan <andy.yan@rock-chips.com>
Subject: [PATCH v15 01/13] drm/rockchip: vop2: use devm_regmap_field_alloc for cluster-regs
Date: Tue, 18 Feb 2025 19:27:28 +0800 [thread overview]
Message-ID: <20250218112744.34433-2-andyshrk@163.com> (raw)
In-Reply-To: <20250218112744.34433-1-andyshrk@163.com>
From: Heiko Stuebner <heiko@sntech.de>
Right now vop2_cluster_init() copies the base vop2_cluster_regs
and adapts the reg value with the current window's offset before
adding the fields to the regmap.
This conflicts with the notion of reg_fields being const, see
https://lore.kernel.org/all/20240706-regmap-const-structs-v1-1-d08c776da787@weissschuh.net/
for reference, which now causes checkpatch to actually warn about that.
So instead of creating one big copy and changing it afterwards,
add the reg_fields individually using devm_regmap_field_alloc().
Functional it is the same, just that the reg_field we're handling
can stay const.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 66 +++++++++-----------
1 file changed, 31 insertions(+), 35 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index afc946ead870..ebc9cb93073c 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -3400,7 +3400,7 @@ static int vop2_find_rgb_encoder(struct vop2 *vop2)
return -ENOENT;
}
-static struct reg_field vop2_cluster_regs[VOP2_WIN_MAX_REG] = {
+static const struct reg_field vop2_cluster_regs[VOP2_WIN_MAX_REG] = {
[VOP2_WIN_ENABLE] = REG_FIELD(RK3568_CLUSTER_WIN_CTRL0, 0, 0),
[VOP2_WIN_FORMAT] = REG_FIELD(RK3568_CLUSTER_WIN_CTRL0, 1, 5),
[VOP2_WIN_RB_SWAP] = REG_FIELD(RK3568_CLUSTER_WIN_CTRL0, 14, 14),
@@ -3471,28 +3471,26 @@ static struct reg_field vop2_cluster_regs[VOP2_WIN_MAX_REG] = {
static int vop2_cluster_init(struct vop2_win *win)
{
struct vop2 *vop2 = win->vop2;
- struct reg_field *cluster_regs;
- int ret, i;
-
- cluster_regs = kmemdup(vop2_cluster_regs, sizeof(vop2_cluster_regs),
- GFP_KERNEL);
- if (!cluster_regs)
- return -ENOMEM;
-
- for (i = 0; i < ARRAY_SIZE(vop2_cluster_regs); i++)
- if (cluster_regs[i].reg != 0xffffffff)
- cluster_regs[i].reg += win->offset;
+ int i;
- ret = devm_regmap_field_bulk_alloc(vop2->dev, vop2->map, win->reg,
- cluster_regs,
- ARRAY_SIZE(vop2_cluster_regs));
+ for (i = 0; i < ARRAY_SIZE(vop2_cluster_regs); i++) {
+ const struct reg_field field = {
+ .reg = (vop2_cluster_regs[i].reg != 0xffffffff) ?
+ vop2_cluster_regs[i].reg + win->offset :
+ vop2_cluster_regs[i].reg,
+ .lsb = vop2_cluster_regs[i].lsb,
+ .msb = vop2_cluster_regs[i].msb
+ };
- kfree(cluster_regs);
+ win->reg[i] = devm_regmap_field_alloc(vop2->dev, vop2->map, field);
+ if (IS_ERR(win->reg[i]))
+ return PTR_ERR(win->reg[i]);
+ }
- return ret;
+ return 0;
};
-static struct reg_field vop2_esmart_regs[VOP2_WIN_MAX_REG] = {
+static const struct reg_field vop2_esmart_regs[VOP2_WIN_MAX_REG] = {
[VOP2_WIN_ENABLE] = REG_FIELD(RK3568_SMART_REGION0_CTRL, 0, 0),
[VOP2_WIN_FORMAT] = REG_FIELD(RK3568_SMART_REGION0_CTRL, 1, 5),
[VOP2_WIN_DITHER_UP] = REG_FIELD(RK3568_SMART_REGION0_CTRL, 12, 12),
@@ -3559,26 +3557,24 @@ static struct reg_field vop2_esmart_regs[VOP2_WIN_MAX_REG] = {
static int vop2_esmart_init(struct vop2_win *win)
{
struct vop2 *vop2 = win->vop2;
- struct reg_field *esmart_regs;
- int ret, i;
-
- esmart_regs = kmemdup(vop2_esmart_regs, sizeof(vop2_esmart_regs),
- GFP_KERNEL);
- if (!esmart_regs)
- return -ENOMEM;
-
- for (i = 0; i < ARRAY_SIZE(vop2_esmart_regs); i++)
- if (esmart_regs[i].reg != 0xffffffff)
- esmart_regs[i].reg += win->offset;
+ int i;
- ret = devm_regmap_field_bulk_alloc(vop2->dev, vop2->map, win->reg,
- esmart_regs,
- ARRAY_SIZE(vop2_esmart_regs));
+ for (i = 0; i < ARRAY_SIZE(vop2_esmart_regs); i++) {
+ const struct reg_field field = {
+ .reg = (vop2_esmart_regs[i].reg != 0xffffffff) ?
+ vop2_esmart_regs[i].reg + win->offset :
+ vop2_esmart_regs[i].reg,
+ .lsb = vop2_esmart_regs[i].lsb,
+ .msb = vop2_esmart_regs[i].msb
+ };
- kfree(esmart_regs);
+ win->reg[i] = devm_regmap_field_alloc(vop2->dev, vop2->map, field);
+ if (IS_ERR(win->reg[i]))
+ return PTR_ERR(win->reg[i]);
+ }
- return ret;
-};
+ return 0;
+}
static int vop2_win_init(struct vop2 *vop2)
{
--
2.34.1
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2025-02-18 11:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 11:27 [PATCH v15 00/13] VOP Support for rk3576 Andy Yan
2025-02-18 11:27 ` Andy Yan [this message]
2025-02-18 11:27 ` [PATCH v15 02/13] drm/rockchip: vop2: Remove AFBC from TRANSFORM_OFFSET register macro Andy Yan
2025-02-18 11:27 ` [PATCH v15 03/13] drm/rockchip: vop2: Add platform specific callback Andy Yan
2025-02-18 11:27 ` [PATCH v15 04/13] drm/rockchip: vop2: Merge vop2_cluster/esmart_init function Andy Yan
2025-02-18 11:27 ` [PATCH v15 05/13] drm/rockchip: vop2: Support for different layer select configuration between VPs Andy Yan
2025-02-18 11:27 ` [PATCH v15 06/13] drm/rockchip: vop2: Introduce vop hardware version Andy Yan
2025-02-18 11:27 ` [PATCH v15 07/13] drm/rockchip: vop2: Register the primary plane and overlay plane separately Andy Yan
2025-03-02 18:57 ` Heiko Stübner
2025-03-03 6:17 ` Andy Yan
2025-02-18 11:27 ` [PATCH v15 08/13] drm/rockchip: vop2: Set plane possible crtcs by possible vp mask Andy Yan
2025-02-18 11:27 ` [PATCH v15 09/13] drm/rockchip: vop2: Add uv swap for cluster window Andy Yan
2025-02-18 11:27 ` [PATCH v15 10/13] dt-bindings: display: vop2: describe constraint SoC by SoC Andy Yan
2025-02-18 11:28 ` [PATCH v15 11/13] dt-bindings: display: vop2: Add missing rockchip,grf property for rk3566/8 Andy Yan
2025-02-18 11:28 ` [PATCH v15 12/13] dt-bindings: display: vop2: Add rk3576 support Andy Yan
2025-02-18 11:28 ` [PATCH v15 13/13] drm/rockchip: vop2: Add support for rk3576 Andy Yan
2025-03-02 19:09 ` Heiko Stübner
2025-03-02 12:01 ` Re:[PATCH v15 00/13] VOP Support " Andy Yan
2025-03-02 18:34 ` (subset) [PATCH " Heiko Stuebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250218112744.34433-2-andyshrk@163.com \
--to=andyshrk@163.com \
--cc=andy.yan@rock-chips.com \
--cc=daniel@fooishbar.org \
--cc=derek.foreman@collabora.com \
--cc=detlev.casanova@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=hjc@rock-chips.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=robh@kernel.org \
--cc=sebastian.reichel@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox