[PATCH v2 1/2] drm: Add color management LUT validation helper (v2)

Matt Roper matthew.d.roper at intel.com
Fri Dec 14 18:24:00 UTC 2018


On Fri, Dec 14, 2018 at 09:43:08AM +0000, Alexandru-Cosmin Gheorghe wrote:
...
> > +int drm_color_lut_check(struct drm_property_blob *lut,
> > +			 uint32_t tests)
> > +{
> > +	struct drm_color_lut *entry;
> > +	int i;
> > +
> > +	if (!lut)
> > +		return 0;
> > +
> > +	if (lut->length % sizeof(struct drm_color_lut)) {
> > +		DRM_DEBUG_KMS("LUT size (%lu) is not a multiple of LUT entry size (%lu)\n",
> > +			      lut->length, sizeof(struct drm_color_lut));
> > +		return -EINVAL;
> > +	}
> > +
> 
> Isn't this already covered by drm_atomic_replace_property_blob_from_id ?
> Other than that feel free to add:
> 
> Reviewed-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe at arm.com>

Ah, you're right.  I thought there was a test somewhere but couldn't
find where we did it when I looked earlier.  I'll drop this extra test;
thanks for pointing that out.


Matt

> 
> > +	if (!tests)
> > +		return 0;
> > +
> > +	entry = lut->data;
> > +	for (i = 0; i < drm_color_lut_size(lut); i++) {
> > +		if (tests & DRM_COLOR_LUT_EQUAL_CHANNELS) {
> > +			if (entry[i].red != entry[i].blue ||
> > +			    entry[i].red != entry[i].green) {
> > +				DRM_DEBUG_KMS("All LUT entries must have equal r/g/b\n");
> > +				return -EINVAL;
> > +			}
> > +		}
> > +
> > +		if (i > 0 && tests & DRM_COLOR_LUT_INCREASING) {
> > +			if (entry[i].red < entry[i - 1].red ||
> > +			    entry[i].green < entry[i - 1].green ||
> > +			    entry[i].blue < entry[i - 1].blue) {
> > +				DRM_DEBUG_KMS("LUT entries must never decrease.\n");
> > +				return -EINVAL;
> > +			}
> > +		}
> > +	}
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(drm_color_lut_check);
> > diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
> > index 90ef9996d9a4..7de16f70bcc3 100644
> > --- a/include/drm/drm_color_mgmt.h
> > +++ b/include/drm/drm_color_mgmt.h
> > @@ -69,4 +69,9 @@ int drm_plane_create_color_properties(struct drm_plane *plane,
> >  				      u32 supported_ranges,
> >  				      enum drm_color_encoding default_encoding,
> >  				      enum drm_color_range default_range);
> > +
> > +#define DRM_COLOR_LUT_EQUAL_CHANNELS BIT(0)
> > +#define DRM_COLOR_LUT_INCREASING     BIT(1)
> > +int drm_color_lut_check(struct drm_property_blob *lut,
> > +			uint32_t tests);
> >  #endif
> > -- 
> > 2.14.4
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Cheers,
> Alex G

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795


More information about the dri-devel mailing list