From: Vamsi Krishna Brahmajosyula <vamsikrishna.brahmajosyula@gmail.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch
Cc: skhan@linuxfoundation.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] gpu/drm: set gamma_lut or degamma_lut based on HW in setcmap_atomic
Date: Thu, 3 Oct 2024 17:36:55 +0530 [thread overview]
Message-ID: <20241003120655.53663-1-vamsikrishna.brahmajosyula@gmail.com> (raw)
setcmap_atomic always sets gamma_lut in setcmap_atomic
Address the following FIXME to set gamma or degamma lut
FIXME: This always uses gamma_lut. Some HW have only
degamma_lut, in which case we should reset gamma_lut and set
degamma_lut. See drm_crtc_legacy_gamma_set().
Tested by calling setcmap_atomic in drm_fb_helper_setcmap with out
the condition check.
Signed-off-by: Vamsi Krishna Brahmajosyula <vamsikrishna.brahmajosyula@gmail.com>
---
drivers/gpu/drm/drm_fb_helper.c | 50 ++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 29c53f9f449c..48f053f7ac89 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -871,11 +871,11 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
return ret;
}
-static struct drm_property_blob *setcmap_new_gamma_lut(struct drm_crtc *crtc,
+static struct drm_property_blob *setcmap_new_blob_lut(struct drm_crtc *crtc,
struct fb_cmap *cmap)
{
struct drm_device *dev = crtc->dev;
- struct drm_property_blob *gamma_lut;
+ struct drm_property_blob *blob;
struct drm_color_lut *lut;
int size = crtc->gamma_size;
int i;
@@ -883,11 +883,11 @@ static struct drm_property_blob *setcmap_new_gamma_lut(struct drm_crtc *crtc,
if (!size || cmap->start + cmap->len > size)
return ERR_PTR(-EINVAL);
- gamma_lut = drm_property_create_blob(dev, sizeof(*lut) * size, NULL);
- if (IS_ERR(gamma_lut))
- return gamma_lut;
+ blob = drm_property_create_blob(dev, sizeof(*lut) * size, NULL);
+ if (IS_ERR(blob))
+ return blob;
- lut = gamma_lut->data;
+ lut = blob->data;
if (cmap->start || cmap->len != size) {
u16 *r = crtc->gamma_store;
u16 *g = r + crtc->gamma_size;
@@ -911,14 +911,14 @@ static struct drm_property_blob *setcmap_new_gamma_lut(struct drm_crtc *crtc,
lut[cmap->start + i].blue = cmap->blue[i];
}
- return gamma_lut;
+ return blob;
}
static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
{
struct drm_fb_helper *fb_helper = info->par;
struct drm_device *dev = fb_helper->dev;
- struct drm_property_blob *gamma_lut = NULL;
+ struct drm_property_blob *blob = NULL;
struct drm_modeset_acquire_ctx ctx;
struct drm_crtc_state *crtc_state;
struct drm_atomic_state *state;
@@ -926,6 +926,9 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
struct drm_crtc *crtc;
u16 *r, *g, *b;
bool replaced;
+ u32 gamma_id = dev->mode_config.gamma_lut_property->base.id;
+ u32 degamma_id = dev->mode_config.degamma_lut_property->base.id;
+ bool use_gamma_lut;
int ret = 0;
drm_modeset_acquire_init(&ctx, 0);
@@ -941,11 +944,21 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
drm_client_for_each_modeset(modeset, &fb_helper->client) {
crtc = modeset->crtc;
- if (!gamma_lut)
- gamma_lut = setcmap_new_gamma_lut(crtc, cmap);
- if (IS_ERR(gamma_lut)) {
- ret = PTR_ERR(gamma_lut);
- gamma_lut = NULL;
+ if (drm_mode_obj_find_prop_id(&crtc->base, gamma_id))
+ use_gamma_lut = true;
+ else if (drm_mode_obj_find_prop_id(&crtc->base, degamma_id))
+ use_gamma_lut = false;
+ else {
+ ret = -ENODEV;
+ blob = NULL;
+ goto out_state;
+ }
+
+ if (!blob)
+ blob = setcmap_new_blob_lut(crtc, cmap);
+ if (IS_ERR(blob)) {
+ ret = PTR_ERR(blob);
+ blob = NULL;
goto out_state;
}
@@ -956,15 +969,14 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
}
/*
- * FIXME: This always uses gamma_lut. Some HW have only
- * degamma_lut, in which case we should reset gamma_lut and set
- * degamma_lut. See drm_crtc_legacy_gamma_set().
+ * Some HW have only degamma_lut, in which case we should
+ * reset gamma_lut and set degamma_lut.
*/
replaced = drm_property_replace_blob(&crtc_state->degamma_lut,
- NULL);
+ use_gamma_lut ? NULL : blob);
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
- gamma_lut);
+ use_gamma_lut ? blob : NULL);
crtc_state->color_mgmt_changed |= replaced;
}
@@ -988,7 +1000,7 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info)
if (ret == -EDEADLK)
goto backoff;
- drm_property_blob_put(gamma_lut);
+ drm_property_blob_put(blob);
drm_atomic_state_put(state);
out_ctx:
drm_modeset_drop_locks(&ctx);
base-commit: 7ec462100ef9142344ddbf86f2c3008b97acddbe
--
2.46.2
next reply other threads:[~2024-10-03 12:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 12:06 Vamsi Krishna Brahmajosyula [this message]
2024-10-06 1:01 ` kernel test robot
2024-10-07 16:23 ` Vamsi Krishna Brahmajosyula
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=20241003120655.53663-1-vamsikrishna.brahmajosyula@gmail.com \
--to=vamsikrishna.brahmajosyula@gmail.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®