From nobody Thu Nov 28 07:43:58 2024 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 BC5AE13D245 for ; Thu, 3 Oct 2024 12:07:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727957225; cv=none; b=JEsBPgx75BQVNds0Xm4tun6O/YIH5avObOePUZ0RVMheyy6j2OQ2lTNz9OD79rLgppUT3NSah2cP84jJvb2YgHP0gQQFaJzdIhewwRte54eDY29u2j2vXDhJM+BG7klMeV1qHrLWcq29GFPMcrcQCW0a+2gcG8jMj1A64Zszkjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727957225; c=relaxed/simple; bh=nHw/Cgh/A45jVuav0wZXD/senHY2VZ6AM5LdzHqNegY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=aGSnzEtec0zRL9nzZfBrgh0l0FVVOscZdKvzNxyCgdJugNxUgKo9qd0U2LpkiL3oTuURnJVEzaMOMYHzKBYWSS/Ij5tNuK0DDbUZy8akmd83zSzbsIILEAibduLSLjWsvCCgA1DExy/3QUI9Q3Dsk+EnNpM1rctNsCIltpXEFwk= 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=NTi2trF3; arc=none smtp.client-ip=209.85.210.169 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="NTi2trF3" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-71788bfe60eso713833b3a.1 for ; Thu, 03 Oct 2024 05:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727957223; x=1728562023; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tENLZuUZDqCKRHgFd+nN+o31lrR5w79lUzAqq4taxj4=; b=NTi2trF33dE0nHylzPhjZO1OBHj/BuT5EOtY/LFySbvRcBsXgWVNgxwh5ZTVXxrPIH buzlO8Bdg6K5MHbffqn+VyeqgqLU7OUxt4ZdqQ/FRlfy83bGEiD09bsTU1pCEwcYkqCZ 1DQ93DrQoY05UEWr0zXySk29DLy60z6Fm2ZB6/vHh3qKuQ64aUtJDktAiHor5JPzvVfY IhZxSO6KTO0tzUnLWFBTCkOSrYV21M8wlelGEyYKAQd+plCSWjig6QwNKh0O/cPXhmmq sHs2j8kSzkEQU66j0Dtt7IkX1XxkkWJWl43ozsFiQC7kGHJyyiw9sqTb9jihDZUeFT4Q CkJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727957223; x=1728562023; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tENLZuUZDqCKRHgFd+nN+o31lrR5w79lUzAqq4taxj4=; b=StNgMIeFjiGg9HL+tZcydb2b1BLBFOIxiBkC3rqruxGVLXWjKEAEx2kclWgi6Hr52u Z5fMe20H8Uj3DutThdNznyWIVN/o8eAVdLXrFMkFouXEbNoZJGeWMps78LmwsTuIfVug dKZvmvscnR7+FkSPxzhjWqHJXC6hmT1pOw973LMY8cRA5Od3dm5AJr7B/LiSUVMWXj1m QeJ5ewJxJn9q0nUFuO3xE1CYvM8j7gAGF7QdiSW0uuvf3rnjSCQrRD2IBsW92Xtdf8Rx HyON3ih901PR7HAftu4LwI1k7pHY5Nc67XGpmkzwnE9k/PXq0TEH9i4GyddVgAr+POjv Z17A== X-Forwarded-Encrypted: i=1; AJvYcCU1iqiZHSBT47rVmc0ffOvKL4EHnJajp4E630pHHlrU9tRyHlEWDUMpfrbXSADwZeMQPuAS20tLazEV/L8=@vger.kernel.org X-Gm-Message-State: AOJu0YykRGpckye968gFksBbWEbdkCekGsYYDYTHKfA/YTaPIB5OsW/G PJQ4wJ5E4FzveO6k5m18kM1L7773H4J7+EHdXlbYOehnKYa2wHpy X-Google-Smtp-Source: AGHT+IFxqoj5fyUph4UhadmHB8SVnCU8LR0L/apgVycs4/k3ghkiqeSJseoHUadhnddg+9TcHN3m2w== X-Received: by 2002:a05:6a21:9cca:b0:1d4:e4a9:c126 with SMTP id adf61e73a8af0-1d5e2d9e0a5mr10236329637.32.1727957222574; Thu, 03 Oct 2024 05:07:02 -0700 (PDT) Received: from fedora.. ([2405:201:d007:50c2:4888:86b4:6f32:9ae]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e9dcb138f3sm601150a12.40.2024.10.03.05.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 05:07:01 -0700 (PDT) From: Vamsi Krishna Brahmajosyula 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 Message-ID: <20241003120655.53663-1-vamsikrishna.brahmajosyula@gmail.com> X-Mailer: git-send-email 2.46.2 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" 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 --- 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_helpe= r.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, struc= t fb_info *info) return ret; } =20 -static struct drm_property_blob *setcmap_new_gamma_lut(struct drm_crtc *cr= tc, +static struct drm_property_blob *setcmap_new_blob_lut(struct drm_crtc *crt= c, struct fb_cmap *cmap) { struct drm_device *dev =3D crtc->dev; - struct drm_property_blob *gamma_lut; + struct drm_property_blob *blob; struct drm_color_lut *lut; int size =3D crtc->gamma_size; int i; @@ -883,11 +883,11 @@ static struct drm_property_blob *setcmap_new_gamma_lu= t(struct drm_crtc *crtc, if (!size || cmap->start + cmap->len > size) return ERR_PTR(-EINVAL); =20 - gamma_lut =3D drm_property_create_blob(dev, sizeof(*lut) * size, NULL); - if (IS_ERR(gamma_lut)) - return gamma_lut; + blob =3D drm_property_create_blob(dev, sizeof(*lut) * size, NULL); + if (IS_ERR(blob)) + return blob; =20 - lut =3D gamma_lut->data; + lut =3D blob->data; if (cmap->start || cmap->len !=3D size) { u16 *r =3D crtc->gamma_store; u16 *g =3D r + crtc->gamma_size; @@ -911,14 +911,14 @@ static struct drm_property_blob *setcmap_new_gamma_lu= t(struct drm_crtc *crtc, lut[cmap->start + i].blue =3D cmap->blue[i]; } =20 - return gamma_lut; + return blob; } =20 static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info) { struct drm_fb_helper *fb_helper =3D info->par; struct drm_device *dev =3D fb_helper->dev; - struct drm_property_blob *gamma_lut =3D NULL; + struct drm_property_blob *blob =3D 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 =3D dev->mode_config.gamma_lut_property->base.id; + u32 degamma_id =3D dev->mode_config.degamma_lut_property->base.id; + bool use_gamma_lut; int ret =3D 0; =20 drm_modeset_acquire_init(&ctx, 0); @@ -941,11 +944,21 @@ static int setcmap_atomic(struct fb_cmap *cmap, struc= t fb_info *info) drm_client_for_each_modeset(modeset, &fb_helper->client) { crtc =3D modeset->crtc; =20 - if (!gamma_lut) - gamma_lut =3D setcmap_new_gamma_lut(crtc, cmap); - if (IS_ERR(gamma_lut)) { - ret =3D PTR_ERR(gamma_lut); - gamma_lut =3D NULL; + if (drm_mode_obj_find_prop_id(&crtc->base, gamma_id)) + use_gamma_lut =3D true; + else if (drm_mode_obj_find_prop_id(&crtc->base, degamma_id)) + use_gamma_lut =3D false; + else { + ret =3D -ENODEV; + blob =3D NULL; + goto out_state; + } + + if (!blob) + blob =3D setcmap_new_blob_lut(crtc, cmap); + if (IS_ERR(blob)) { + ret =3D PTR_ERR(blob); + blob =3D NULL; goto out_state; } =20 @@ -956,15 +969,14 @@ static int setcmap_atomic(struct fb_cmap *cmap, struc= t fb_info *info) } =20 /* - * 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 =3D drm_property_replace_blob(&crtc_state->degamma_lut, - NULL); + use_gamma_lut ? NULL : blob); replaced |=3D drm_property_replace_blob(&crtc_state->ctm, NULL); replaced |=3D drm_property_replace_blob(&crtc_state->gamma_lut, - gamma_lut); + use_gamma_lut ? blob : NULL); crtc_state->color_mgmt_changed |=3D replaced; } =20 @@ -988,7 +1000,7 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct= fb_info *info) if (ret =3D=3D -EDEADLK) goto backoff; =20 - 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 --=20 2.46.2