@@ -143,6 +143,12 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
drm_property_blob_get(state->ctm);
if (state->gamma_lut)
drm_property_blob_get(state->gamma_lut);
+ if (state->histogram_caps)
+ drm_property_blob_get(state->histogram_caps);
+ if (state->histogram_enable)
+ drm_property_blob_get(state->histogram_enable);
+ if (state->histogram_data)
+ drm_property_blob_get(state->histogram_data);
state->mode_changed = false;
state->active_changed = false;
state->planes_changed = false;
@@ -156,6 +162,8 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
/* Self refresh should be canceled when a new update is available */
state->active = drm_atomic_crtc_effectively_active(state);
state->self_refresh_active = false;
+
+ state->histogram_updated = false;
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state);
@@ -215,6 +223,12 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)
drm_property_blob_put(state->degamma_lut);
drm_property_blob_put(state->ctm);
drm_property_blob_put(state->gamma_lut);
+ if (state->histogram_caps)
+ drm_property_blob_put(state->histogram_caps);
+ if (state->histogram_enable)
+ drm_property_blob_put(state->histogram_enable);
+ if (state->histogram_data)
+ drm_property_blob_put(state->histogram_data);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
@@ -415,6 +415,15 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
return -EFAULT;
set_out_fence_for_crtc(state->state, crtc, fence_ptr);
+ } else if (property == crtc->histogram_enable_property) {
+ ret = drm_property_replace_blob_from_id(dev,
+ &state->histogram_enable,
+ val,
+ -1,
+ sizeof(struct drm_histogram_config),
+ &replaced);
+ state->histogram_updated |= replaced;
+ return ret;
} else if (property == crtc->scaling_filter_property) {
state->scaling_filter = val;
} else if (crtc->funcs->atomic_set_property) {
@@ -452,6 +461,12 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
else if (property == config->prop_out_fence_ptr)
*val = 0;
+ else if (property == crtc->histogram_caps_property)
+ *val = (state->histogram_caps) ? state->histogram_caps->base.id : 0;
+ else if (property == crtc->histogram_enable_property)
+ *val = (state->histogram_enable) ? state->histogram_enable->base.id : 0;
+ else if (property == crtc->histogram_data_property)
+ *val = (state->histogram_data) ? state->histogram_data->base.id : 0;
else if (property == crtc->scaling_filter_property)
*val = state->scaling_filter;
else if (crtc->funcs->atomic_get_property)
@@ -939,3 +939,62 @@ int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
return 0;
}
EXPORT_SYMBOL(drm_crtc_create_scaling_filter_property);
+
+/**
+ * drm_crtc_create_histogram_property: create histogram properties
+ *
+ * @crtc: pointer to the struct drm_crtc.
+ *
+ * The property HISTOGRAM_CAPS exposes the hardware capability for
+ * histogram which includes the histogram mode, number of bins etc
+ * The property HISTOGRAM_ENABLE allows user to enable/disable the
+ * histogram feature and also configure the hardware.
+ * Upon KMD enabling by writing to the hardware registers, histogram
+ * is generated. Histogram is composed of 'n' bins with each bin
+ * being an integer(pixel count).
+ * An event HISTOGRAM will be sent to the user. User upon receiving this
+ * event can read the hardware generated histogram using crtc property
+ * HISTOGRAM_DATA.
+ * User can use this histogram data to enhance the image or in shaders.
+ *
+ * Property HISTOGRAM_CAPS is a blob pointing to the struct drm_histogram_caps
+ * Description of the structure is in include/uapi/drm/drm_mode.h
+ * Property HISTOGRAM_ENABLE is a blob pointing to the struct
+ * drm_histogram_config
+ * Description of the structure is in include/uapi/drm/drm_mode.h
+ * Property HISTOGRAM_DATA is a blob pointing to the struct drm_histogram
+ * Description of the structure is in include/uapi/drm/drm_mode.h
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_crtc_create_histogram_property(struct drm_crtc *crtc)
+{
+ struct drm_property *prop;
+
+ prop = drm_property_create(crtc->dev, DRM_MODE_PROP_ATOMIC |
+ DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+ "HISTOGRAM_CAPS", 0);
+ if (!prop)
+ return -ENOMEM;
+ drm_object_attach_property(&crtc->base, prop, 0);
+ crtc->histogram_caps_property = prop;
+
+ prop = drm_property_create(crtc->dev, DRM_MODE_PROP_ATOMIC |
+ DRM_MODE_PROP_BLOB, "HISTOGRAM_ENABLE", 0);
+ if (!prop)
+ return -ENOMEM;
+ drm_object_attach_property(&crtc->base, prop, 0);
+ crtc->histogram_enable_property = prop;
+
+ prop = drm_property_create(crtc->dev, DRM_MODE_PROP_ATOMIC |
+ DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+ "HISTOGRAM_DATA", 0);
+ if (!prop)
+ return -ENOMEM;
+ drm_object_attach_property(&crtc->base, prop, 0);
+ crtc->histogram_data_property = prop;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_histogram_property);
@@ -274,6 +274,32 @@ struct drm_crtc_state {
*/
struct drm_property_blob *gamma_lut;
+ /**
+ * @histogram_caps:
+ *
+ * The blob points to the structure drm_histogram_caps.
+ * For more info on the elements of the struct drm_histogram_caps
+ * see include/uapi/drm/drm_mode.h
+ */
+ struct drm_property_blob *histogram_caps;
+ /**
+ * @histogram_enable:
+ *
+ * The blob points to the structure drm_histogram_config.
+ * For more information on the elements of struct drm_histogram_config
+ * see include/uapi/drm/drm_mode.h
+ */
+ struct drm_property_blob *histogram_enable;
+ /**
+ * @histogram_data:
+ *
+ * The blob points to the structure drm_histogram.
+ * For more information on the elements of struct drm_histogram
+ * see include/uapi/drm/drm_mode.h
+ */
+ struct drm_property_blob *histogram_data;
+ bool histogram_updated;
+
/**
* @target_vblank:
*
@@ -1088,6 +1114,22 @@ struct drm_crtc {
*/
struct drm_property *scaling_filter_property;
+ /**
+ * @histogram_caps_property: Optional CRTC property for getting the
+ * histogram hardware capability.
+ */
+ struct drm_property *histogram_caps_property;
+ /**
+ * @histogram_enable_property: Optional CRTC property for enabling or
+ * disabling global histogram.
+ */
+ struct drm_property *histogram_enable_property;
+ /**
+ * @histogram_data_proeprty: Optional CRTC property for getting the
+ * histogram blob data.
+ */
+ struct drm_property *histogram_data_property;
+
/**
* @state:
*
@@ -1323,5 +1365,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
unsigned int supported_filters);
+int drm_crtc_create_histogram_property(struct drm_crtc *crtc);
#endif /* __DRM_CRTC_H__ */
Add drm-crtc property for histogram and for the properties added add the corresponding get/set_property. Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com> --- drivers/gpu/drm/drm_atomic_state_helper.c | 14 ++++++++ drivers/gpu/drm/drm_atomic_uapi.c | 15 ++++++++ drivers/gpu/drm/drm_crtc.c | 59 +++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 43 ++++++++++++++++++++++ 4 files changed, 131 insertions(+)