[PATCH 06/10] drm: Define helper to set legacy gamma table size
Sean Paul
seanpaul at chromium.org
Tue Feb 27 15:35:06 UTC 2018
On Thu, Feb 15, 2018 at 12:32:56AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar at intel.com>
>
> Define a helper function to set legacy gamma table
> size for planes.
>
> (am from https://patchwork.kernel.org/patch/9971343/)
I don't see this used in the rest of the series. When it was originally
introduced, it was accompanied by drm/i915: Enable plane color features, which
seems to have been dropped.
Sean
>
> Change-Id: I3d0c3e71d92300259cdfcebed4349207f64e4083
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
> drivers/gpu/drm/drm_color_mgmt.c | 41 ++++++++++++++++++++++++++++++++
> include/drm/drm_color_mgmt.h | 3 +++
> include/drm/drm_plane.h | 4 ++++
> 3 files changed, 48 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
> index 0d002b045bd26..8f360b3ae0f24 100644
> --- a/drivers/gpu/drm/drm_color_mgmt.c
> +++ b/drivers/gpu/drm/drm_color_mgmt.c
> @@ -203,6 +203,47 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
> }
> EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size);
>
> +/**
> + * drm_mode_plane_set_gamma_size - set the gamma table size
> + * @plane: Plane to set the gamma table size for
> + * @gamma_size: size of the gamma table
> + *
> + * Drivers which support gamma tables should set this to the supported gamma
> + * table size when initializing the Plane. Currently the drm core only supports
> + * a fixed gamma table size.
> + *
> + * Returns:
> + * Zero on success, negative errno on failure.
> + */
> +int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
> + int gamma_size)
> +{
> + uint16_t *r_base, *g_base, *b_base;
> + int i;
> +
> + plane->gamma_size = gamma_size;
> +
> + plane->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3,
> + GFP_KERNEL);
> + if (!plane->gamma_store) {
> + plane->gamma_size = 0;
> + return -ENOMEM;
> + }
> +
> + r_base = plane->gamma_store;
> + g_base = r_base + gamma_size;
> + b_base = g_base + gamma_size;
> + for (i = 0; i < gamma_size; i++) {
> + r_base[i] = i << 8;
> + g_base[i] = i << 8;
> + b_base[i] = i << 8;
> + }
> +
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_plane_set_gamma_size);
> +
> /**
> * drm_mode_gamma_set_ioctl - set the gamma table
> * @dev: DRM device
> diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
> index 155a9ba38471c..2f59c820e148c 100644
> --- a/include/drm/drm_color_mgmt.h
> +++ b/include/drm/drm_color_mgmt.h
> @@ -42,4 +42,7 @@ void drm_plane_enable_color_mgmt(struct drm_plane *plane,
> bool plane_has_ctm,
> uint plane_gamma_lut_size);
>
> +int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
> + int plane_gamma_size);
> +
> #endif
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index acabb85009a14..18d09eacbcd7d 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -585,6 +585,10 @@ struct drm_plane {
>
> struct drm_property *zpos_property;
> struct drm_property *rotation_property;
> +
> + /* Legacy FB Plane gamma size for reporting to userspace */
> + uint32_t gamma_size;
> + uint16_t *gamma_store;
> };
>
> #define obj_to_plane(x) container_of(x, struct drm_plane, base)
> --
> 2.16.1.291.g4437f3f132-goog
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Sean Paul, Software Engineer, Google / Chromium OS
More information about the dri-devel
mailing list