[Intel-gfx] [RFC v1 4/7] drm/i915: Implement get set property handler for multi segment gamma
Uma Shankar
uma.shankar at intel.com
Tue Mar 19 08:30:15 UTC 2019
Implement get and set property handler for multi segment gamma
mode.
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
drivers/gpu/drm/i915/intel_display.c | 46 ++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_drv.h | 12 ++++++++++
2 files changed, 58 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 7604f16..8ac9728 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13679,6 +13679,39 @@ static int intel_atomic_commit(struct drm_device *dev,
return 0;
}
+static int
+intel_atomic_replace_property_blob_from_id(struct drm_device *dev,
+ struct drm_property_blob **blob,
+ u64 blob_id,
+ ssize_t expected_size,
+ ssize_t expected_elem_size,
+ bool *replaced)
+{
+ struct drm_property_blob *new_blob = NULL;
+
+ if (blob_id != 0) {
+ new_blob = drm_property_lookup_blob(dev, blob_id);
+ if (!new_blob)
+ return -EINVAL;
+
+ if (expected_size > 0 &&
+ new_blob->length != expected_size) {
+ drm_property_blob_put(new_blob);
+ return -EINVAL;
+ }
+ if (expected_elem_size > 0 &&
+ new_blob->length % expected_elem_size != 0) {
+ drm_property_blob_put(new_blob);
+ return -EINVAL;
+ }
+ }
+
+ *replaced |= drm_property_replace_blob(blob, new_blob);
+ drm_property_blob_put(new_blob);
+
+ return 0;
+}
+
/**
* intel_crtc_atomic_get_property - hook for crtc->atomic_get_property.
* @crtc: Crtc to get the property for.
@@ -13699,6 +13732,9 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
if (property == dev_priv->gamma_mode_property) {
*val = intel_crtc_state->gamma_mode_type;
+ } else if (property == dev_priv->multi_segment_gamma_mode_property) {
+ *val = (intel_crtc_state->multi_segment_gamma_lut) ?
+ intel_crtc_state->multi_segment_gamma_lut->base.id : 0;
} else {
DRM_DEBUG_ATOMIC("Unknown property %s\n", property->name);
return -EINVAL;
@@ -13724,11 +13760,21 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = to_i915(dev);
struct intel_crtc_state *intel_crtc_state = to_intel_crtc_state(state);
+ bool replaced = false;
+ int ret;
if (property == dev_priv->gamma_mode_property) {
intel_crtc_state->gamma_mode_type = val;
state->color_mgmt_changed |= replaced;
return 0;
+ } else if (property == dev_priv->multi_segment_gamma_mode_property) {
+ ret = intel_atomic_replace_property_blob_from_id(dev,
+ &intel_crtc_state->multi_segment_gamma_lut,
+ val, -1,
+ sizeof(struct multi_segment_gamma_lut),
+ &replaced);
+ state->color_mgmt_changed |= replaced;
+ return ret;
}
DRM_DEBUG_ATOMIC("Unknown property %s\n", property->name);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index fd84fe9..7fccd28 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1037,6 +1037,18 @@ struct intel_crtc_state {
/* Gamma mode type programmed on the pipe */
u32 gamma_mode_type;
+ /**
+ * @multi_segment_gamma_lut:
+ *
+ * Lookup table for converting pixel data after the color conversion
+ * matrix @ctm. See drm_crtc_enable_color_mgmt(). The blob (if not
+ * NULL) is an array of &struct drm_color_lut.
+ */
+ struct drm_property_blob *multi_segment_gamma_lut;
+
+ /* State to check for Gamma Mode Color Changes */
+ bool color_mgmt_changed : 1;
+
/* bitmask of planes that will be updated during the commit */
u8 update_planes;
--
1.9.1
More information about the Intel-gfx
mailing list