From: Angelo Dureghello <angelo@kernel-space.org>
To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
kherbst@redhat.com, lyude@redhat.com, dakr@redhat.com
Cc: Angelo Dureghello <angelo@kernel-space.org>
Subject: [PATCH v2 1/2] drm/nouveau/disp: add backlight for ada lovelace
Date: Fri, 12 Apr 2024 21:49:00 +0200 [thread overview]
Message-ID: <20240412194901.1596-1-angelo@kernel-space.org> (raw)
Add working backlight for "ada lovelace" missing case.
The nvif method is actually not working for this chipset so
used the drm apis. Also, by dpcd, drm layer is calculating a
max brightness of 255, but to get a real correct max brightnes
the maximum must be multiplied by a factor of 16.
Tested to work properly in Legion Lenovo Pro 5
Lenovo Legion 5 Pro 16ARX8
Bios ver LPCN49WW
LPEC49WW
SN PF4T63AZ
Nvidia RTX4060 MaxQ/Mobile rev a1 (ADA LOVELACE AD107M)
AMD Ryzen 9 7945HX + Radeon
and wayland.
---
Changes for v2:
- add some comments
- remove x16 multiplication (hack)
- remove forgot debug printk
Signed-off-by: Angelo Dureghello <angelo@kernel-space.org>
---
drivers/gpu/drm/nouveau/nouveau_backlight.c | 54 +++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index d47442125fa1..7b7306d18ad7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -286,6 +286,56 @@ nv50_backlight_init(struct nouveau_backlight *bl,
return 0;
}
+static int
+nv19x_backlight_init(struct nouveau_backlight *bl,
+ struct nouveau_connector *nv_conn,
+ struct nouveau_encoder *nv_encoder,
+ struct backlight_properties *props,
+ const struct backlight_ops **ops)
+{
+ int ret;
+ u16 current_level;
+ u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
+ u8 current_mode;
+ struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
+
+ /*
+ * nvif functions, so also nvif_outp_bl_get, are not working with this
+ * connector (return -22), using only drm layer.
+ */
+ if (nv_conn->type == DCB_CONNECTOR_eDP) {
+
+ ret = drm_dp_dpcd_read(&nv_conn->aux, DP_EDP_DPCD_REV, edp_dpcd,
+ EDP_DISPLAY_CTL_CAP_SIZE);
+ if (ret < 0)
+ return ret;
+ if (!drm_edp_backlight_supported(edp_dpcd))
+ return -ENODEV;
+
+ ret = drm_edp_backlight_init(&nv_conn->aux, &bl->edp_info, 0, edp_dpcd,
+ ¤t_level, ¤t_mode);
+ if (ret < 0)
+ return ret;
+
+ ret = drm_edp_backlight_enable(&nv_conn->aux, &bl->edp_info, current_level);
+ if (ret < 0) {
+ NV_ERROR(drm, "Failed to enable backlight on %s: %d\n",
+ nv_conn->base.name, ret);
+ return ret;
+ }
+
+ *ops = &nv50_edp_bl_ops;
+
+ props->max_brightness = bl->edp_info.max;
+ props->brightness = current_level;
+ bl->uses_dpcd = true;
+
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
int
nouveau_backlight_init(struct drm_connector *connector)
{
@@ -332,6 +382,10 @@ nouveau_backlight_init(struct drm_connector *connector)
ret = nv50_backlight_init(bl, nouveau_connector(connector),
nv_encoder, &props, &ops);
break;
+ case NV_DEVICE_INFO_V0_ADA:
+ ret = nv19x_backlight_init(bl, nouveau_connector(connector),
+ nv_encoder, &props, &ops);
+ break;
default:
ret = 0;
goto fail_alloc;
--
2.44.0
next reply other threads:[~2024-04-12 19:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 19:49 Angelo Dureghello [this message]
2024-04-12 19:49 ` [PATCH v2 2/2] drm/dp: set pwm bit count when pwm hz is not set Angelo Dureghello
2024-04-15 16:54 ` [PATCH v2 1/2] drm/nouveau/disp: add backlight for ada lovelace Lyude Paul
2024-04-15 18:46 ` Angelo Dureghello
2024-04-16 7:11 ` Angelo Dureghello
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=20240412194901.1596-1-angelo@kernel-space.org \
--to=angelo@kernel-space.org \
--cc=dakr@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kherbst@redhat.com \
--cc=lyude@redhat.com \
--cc=nouveau@lists.freedesktop.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).