Re: [Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
On Fri, 26 Feb 2016, Lionel Landwerlinwrote: > @@ -2554,6 +2583,21 @@ static inline struct drm_property > *drm_property_find(struct drm_device *dev, > return mo ? obj_to_property(mo) : NULL; > } > > +/* > + * Extract a degamma/gamma LUT value provided by user and round it to the > + * precision supported by the hardware. > + */ > +static inline uint32_t drm_color_lut_extract(uint32_t user_input, > + uint32_t bit_precision) > +{ > + uint32_t val = user_input + (1 << (16 - bit_precision - 1)); > + uint32_t max = 0x >> (16 - bit_precision); > + > + val >>= 16 - bit_precision; > + > + return clamp_val(val, 0, max); > +} Didn't dig deeper, but sparse complains CHECK drivers/gpu/drm/i915/intel_color.c include/drm/drm_crtc.h:2603:40: warning: shift too big (4294967295) for type int include/drm/drm_crtc.h:2603:40: warning: shift too big (4294967295) for type int include/drm/drm_crtc.h:2603:40: warning: shift too big (4294967295) for type int BR, Jani. -- Jani Nikula, Intel Open Source Technology Center ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
On 26 February 2016 at 15:43, Lionel Landwerlinwrote: > On 26/02/16 00:36, Emil Velikov wrote: >> >> Hi Lionel, >> >> A bunch of suggestions - feel free to take or ignore them :-) >> >> On 25 February 2016 at 10:58, Lionel Landwerlin >> wrote: > I'm not sure it matters as the drm_crtc_state you're set properties on will > be discarded if there is an error. > The current drm_crtc_state that has been applied onto the hardware should be > untouched. > That's the thing - the current drm_crts_state (mode_blob) is being discarded, as opposed to the newly setup one. Although I could have misunderstood something. > > This is because we accept more than one size of degamma/gamma LUT (legacy -> > 256 elements, new LUT -> (de)gamma_lut_size elements). > It's up for the driver the check the size and raise an error in its > atomic_check() vfunc. > Ahh yes the legacy vs atomic difference. > > Moving the if (blob == NULL) right after the blob allocation to make it > simpler. > > What about completeness? Is there something inherently wrong here? The suggestion to reorder things is mostly to keep the setup/teardown order in reverse order - create_blob, create_state and drop_state, drop_blob. As you've noticed, I'm kind of a sucker for those :-) There are no inter-dependencies that would require it here so it's not required. >> >> >>> + state->acquire_ctx = crtc->dev->mode_config.acquire_ctx; >>> +retry: >>> + crtc_state = drm_atomic_get_crtc_state(state, crtc); >>> + if (IS_ERR(crtc_state)) { >>> + ret = PTR_ERR(crtc_state); >>> + goto fail; >>> + } >>> + >>> + /* Reset DEGAMMA_LUT and CTM properties. */ >>> + ret = drm_atomic_crtc_set_property(crtc, crtc_state, >>> + config->degamma_lut_property, 0); >>> + if (ret) >>> + goto fail; >> >> Add new blank line please. > > > Sure. >> >> >>> + ret = drm_atomic_crtc_set_property(crtc, crtc_state, >>> + config->ctm_property, 0); >>> + if (ret) >>> + goto fail; >>> + >>> + /* Set GAMMA_LUT with legacy values. */ >>> + if (blob == NULL) { >>> + ret = -ENOMEM; >>> + goto fail; >>> + } >>> + >>> + blob_data = (struct drm_color_lut *) blob->data; >>> + for (i = 0; i < size; i++) { >>> + blob_data[i].red = red[i]; >>> + blob_data[i].green = green[i]; >>> + blob_data[i].blue = blue[i]; >>> + } >>> + >> >> Move this loop after create_blob() > > Thanks, indeed no need to refill it in case of retry. > >> >>> + ret = drm_atomic_crtc_set_property(crtc, crtc_state, >>> + config->gamma_lut_property, blob->base.id); >>> + if (ret) >>> + goto fail; >>> + >>> + ret = drm_atomic_commit(state); >>> + if (ret != 0) >> >> Please check in a consistent way. Currently we have ret != 0 vs ret >> and foo == NULL vs !foo. > > > Sure. > >> >>> + goto fail; >>> + >>> + drm_property_unreference_blob(blob); >>> + >>> + /* Driver takes ownership of state on successful commit. */ >> >> Move the comment before unreference_blob(), so that it's closer to >> atomic_commit() ? > > > Sure. >> >> >>> --- a/drivers/gpu/drm/drm_crtc.c >>> +++ b/drivers/gpu/drm/drm_crtc.c >>> @@ -1554,6 +1554,41 @@ static int >>> drm_mode_create_standard_properties(struct drm_device *dev) >>> return -ENOMEM; >>> dev->mode_config.prop_mode_id = prop; >>> >>> + prop = drm_property_create(dev, >>> + DRM_MODE_PROP_BLOB, >>> + "DEGAMMA_LUT", 0); >> >> Just wondering - don't we want this and the remaining properties to >> be atomic only ? I doubt we have userspace that [will be updated to] >> handle these, yet lacks atomic. > > This was pointed out by Matt already. Here is Daniel Stone's response : > https://lists.freedesktop.org/archives/intel-gfx/2016-January/086120.html > > I think it's fine to have these properties not atomic because it's not > really something you update very often (maybe just when starting your UI). > That's actually how we would like to use them in ChromiumOS as a first step, > until eventually ChromiumOS switches to atomic. > It wasn't a question of "can it be used" but more of "would it make sense to not switch to atomics once we're here". As is, userspace will need to have two slightly different code paths. Put the question "how to deal with if compositor crashes and (re)applying gamma/etc. multiple times" by Daniel Vettel, on top of it all and things get extra messy. In both usespace in kernel. My line of thought is - if there is a high demand for non-atomic(legacy) degamma/etc. one can easily add it. On the other hand, once it lands one cannot remove the code from the kernel, ever. It's up-to you guys really. Just thought I
[Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
Patch based on a previous series by Shashank Sharma. This introduces optional properties to enable color correction at the pipe level. It relies on 3 transformations applied to every pixels displayed. First a lookup into a degamma table, then a multiplication of the rgb components by a 3x3 matrix and finally another lookup into a gamma table. The following properties can be added to a pipe : - DEGAMMA_LUT : blob containing degamma LUT - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT - CTM : transformation matrix applied after the degamma LUT - GAMMA_LUT : blob containing gamma LUT - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by the driver to tell userspace applications what sizes should be the lookup tables in DEGAMMA_LUT and GAMMA_LUT. A helper is also provided so legacy gamma correction is redirected through these new properties. v2: Register LUT size properties as range v3: Fix round in drm_color_lut_get_value() helper More docs on how degamma/gamma properties are used v4: Update contributors v5: Rename CTM_MATRIX property to CTM (Doh!) Add legacy gamma_set atomic helper Describe CTM/LUT acronyms in the kernel doc v6: Fix missing blob unref in drm_atomic_helper_crtc_reset Signed-off-by: Shashank SharmaSigned-off-by: Kumar, Kiran S Signed-off-by: Kausal Malladi Signed-off-by: Lionel Landwerlin Reviewed-by: Matt Roper --- Documentation/DocBook/gpu.tmpl | 59 ++- drivers/gpu/drm/drm_atomic.c| 88 - drivers/gpu/drm/drm_atomic_helper.c | 110 +++- drivers/gpu/drm/drm_crtc.c | 35 drivers/gpu/drm/drm_crtc_helper.c | 33 +++ include/drm/drm_atomic_helper.h | 3 + include/drm/drm_crtc.h | 46 ++- include/drm/drm_crtc_helper.h | 3 + include/uapi/drm/drm_mode.h | 15 + 9 files changed, 386 insertions(+), 6 deletions(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index fe6b36a..1692c4d 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM + DRM Generic “rotation” BITMASK @@ -2068,7 +2068,7 @@ void intel_crt_init(struct drm_device *dev) property to suggest an Y offset for a connector - Optional + Optional “scaling mode” ENUM { "None", "Full", "Center", "Full aspect" } @@ -2092,6 +2092,61 @@ void intel_crt_init(struct drm_device *dev) TBD + “DEGAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the degamma lookup table + (LUT) mapping pixel data from the framebuffer before it is + given to the transformation matrix. The data is an interpreted + as an array of struct drm_color_lut elements. Hardware might + choose not to use the full precision of the LUT elements nor + use all the elements of the LUT (for example the hardware + might choose to interpolate between LUT[0] and LUT[4]). + + + “DEGAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the DEGAMMA_LUT property (the size depends + on the underlying hardware). + + + “CTM” + BLOB + 0 + CRTC + DRM property to set the current + transformation matrix (CTM) apply to pixel data after the + lookup through the degamma LUT and before the lookup through + the gamma LUT. The data is an interpreted as a struct + drm_color_ctm. + + + “GAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the gamma lookup table + (LUT) mapping pixel data after to the transformation matrix to + data sent to the connector. The data is an interpreted as an + array of struct drm_color_lut elements. Hardware might choose + not to use the full precision of the LUT elements nor use all + the elements of the LUT (for example the hardware might choose + to interpolate between LUT[0] and LUT[4]). + + + “GAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the GAMMA_LUT property (the size depends on + the underlying hardware). + +
Re: [Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
On 26/02/16 00:36, Emil Velikov wrote: Hi Lionel, A bunch of suggestions - feel free to take or ignore them :-) On 25 February 2016 at 10:58, Lionel Landwerlinwrote: Patch based on a previous series by Shashank Sharma. This introduces optional properties to enable color correction at the pipe level. It relies on 3 transformations applied to every pixels displayed. First a lookup into a degamma table, then a multiplication of the rgb components by a 3x3 matrix and finally another lookup into a gamma table. The following properties can be added to a pipe : - DEGAMMA_LUT : blob containing degamma LUT - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT - CTM : transformation matrix applied after the degamma LUT - GAMMA_LUT : blob containing gamma LUT - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by the driver to tell userspace applications what sizes should be the lookup tables in DEGAMMA_LUT and GAMMA_LUT. A helper is also provided so legacy gamma correction is redirected through these new properties. v2: Register LUT size properties as range v3: Fix round in drm_color_lut_get_value() helper More docs on how degamma/gamma properties are used v4: Update contributors v5: Rename CTM_MATRIX property to CTM (Doh!) Add legacy gamma_set atomic helper Describe CTM/LUT acronyms in the kernel doc Signed-off-by: Shashank Sharma Signed-off-by: Lionel Landwerlin Signed-off-by: Kumar, Kiran S Signed-off-by: Kausal Malladi The above should be kept in the order of which people worked on them. Reviewed-by: Matt Roper --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -376,6 +377,57 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state, EXPORT_SYMBOL(drm_atomic_set_mode_prop_for_crtc); /** + * drm_atomic_replace_property_blob - replace a blob property + * @blob: a pointer to the member blob to be replaced + * @new_blob: the new blob to replace with + * @expected_size: the expected size of the new blob + * @replaced: whether the blob has been replaced + * + * RETURNS: + * Zero on success, error code on failure + */ +static int +drm_atomic_replace_property_blob(struct drm_property_blob **blob, +struct drm_property_blob *new_blob, +bool *replaced) "Replaced" here and though the rest of the patch is used as "changed". Worth naming it that way ? I think the former describes the action, the later the state. +{ + struct drm_property_blob *old_blob = *blob; + + if (old_blob == new_blob) + return 0; + + if (old_blob) + drm_property_unreference_blob(old_blob); + if (new_blob) + drm_property_reference_blob(new_blob); + *blob = new_blob; + *replaced = true; + + return 0; The function always succeeds - drop the return value ? Well spotted, dropping. +} + +static int +drm_atomic_replace_property_blob_from_id(struct drm_crtc *crtc, +struct drm_property_blob **blob, +uint64_t blob_id, +ssize_t expected_size, +bool *replaced) +{ + struct drm_device *dev = crtc->dev; + struct drm_property_blob *new_blob = NULL; + + if (blob_id != 0) { + new_blob = drm_property_lookup_blob(dev, blob_id); + if (new_blob == NULL) + return -EINVAL; + if (expected_size > 0 && expected_size != new_blob->length) + return -EINVAL; + } + Having a look at drm_atomic_set_mode_prop_for_crtc() I think I can spot a bug - it shouldn't drop/unref the old blob in case of an error. A case you handle nicely here. Perhaps it's worth using the drm_atomic_replace_property_blob() in there ? I'm not sure it matters as the drm_crtc_state you're set properties on will be discarded if there is an error. The current drm_crtc_state that has been applied onto the hardware should be untouched. @@ -397,6 +449,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, { struct drm_device *dev = crtc->dev; struct drm_mode_config *config = >mode_config; + bool replaced = false; int ret; if (property == config->prop_active) @@ -407,8 +460,31 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, ret = drm_atomic_set_mode_prop_for_crtc(state, mode); drm_property_unreference_blob(mode); return ret; - } - else if (crtc->funcs->atomic_set_property) + } else if (property == config->degamma_lut_property) { +
Re: [Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
On Fri, Feb 26, 2016 at 12:36:12AM +, Emil Velikov wrote: ... > > --- a/drivers/gpu/drm/drm_crtc.c > > +++ b/drivers/gpu/drm/drm_crtc.c > > @@ -1554,6 +1554,41 @@ static int > > drm_mode_create_standard_properties(struct drm_device *dev) > > return -ENOMEM; > > dev->mode_config.prop_mode_id = prop; > > > > + prop = drm_property_create(dev, > > + DRM_MODE_PROP_BLOB, > > + "DEGAMMA_LUT", 0); > > Just wondering - don't we want this and the remaining properties to > be atomic only ? I doubt we have userspace that [will be updated to] > handle these, yet lacks atomic. I asked this on a previous version of the series as well since I thought I remembered Daniel Vetter indicating that the goal was to have new capabilities going forward should require atomic (even if the properties could still technically work okay via the legacy property interface). Daniel Stone felt it was probably fine to still allow it via legacy though: https://lists.freedesktop.org/archives/intel-gfx/2016-January/086120.html I personally don't have a strong feeling either way, but we should probably just make sure everyone is on the same page. If we decide as a community that we *do* want the atomic requirement going forward, maybe we can add a note about that to the kerneldoc or something so we remember in the future. Matt -- Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
Hi Lionel, A bunch of suggestions - feel free to take or ignore them :-) On 25 February 2016 at 10:58, Lionel Landwerlinwrote: > Patch based on a previous series by Shashank Sharma. > > This introduces optional properties to enable color correction at the > pipe level. It relies on 3 transformations applied to every pixels > displayed. First a lookup into a degamma table, then a multiplication > of the rgb components by a 3x3 matrix and finally another lookup into > a gamma table. > > The following properties can be added to a pipe : > - DEGAMMA_LUT : blob containing degamma LUT > - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT > - CTM : transformation matrix applied after the degamma LUT > - GAMMA_LUT : blob containing gamma LUT > - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT > > DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by > the driver to tell userspace applications what sizes should be the > lookup tables in DEGAMMA_LUT and GAMMA_LUT. > > A helper is also provided so legacy gamma correction is redirected > through these new properties. > > v2: Register LUT size properties as range > > v3: Fix round in drm_color_lut_get_value() helper > More docs on how degamma/gamma properties are used > > v4: Update contributors > > v5: Rename CTM_MATRIX property to CTM (Doh!) > Add legacy gamma_set atomic helper > Describe CTM/LUT acronyms in the kernel doc > > Signed-off-by: Shashank Sharma > Signed-off-by: Lionel Landwerlin > Signed-off-by: Kumar, Kiran S > Signed-off-by: Kausal Malladi The above should be kept in the order of which people worked on them. > Reviewed-by: Matt Roper > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -376,6 +377,57 @@ int drm_atomic_set_mode_prop_for_crtc(struct > drm_crtc_state *state, > EXPORT_SYMBOL(drm_atomic_set_mode_prop_for_crtc); > > /** > + * drm_atomic_replace_property_blob - replace a blob property > + * @blob: a pointer to the member blob to be replaced > + * @new_blob: the new blob to replace with > + * @expected_size: the expected size of the new blob > + * @replaced: whether the blob has been replaced > + * > + * RETURNS: > + * Zero on success, error code on failure > + */ > +static int > +drm_atomic_replace_property_blob(struct drm_property_blob **blob, > +struct drm_property_blob *new_blob, > +bool *replaced) "Replaced" here and though the rest of the patch is used as "changed". Worth naming it that way ? > +{ > + struct drm_property_blob *old_blob = *blob; > + > + if (old_blob == new_blob) > + return 0; > + > + if (old_blob) > + drm_property_unreference_blob(old_blob); > + if (new_blob) > + drm_property_reference_blob(new_blob); > + *blob = new_blob; > + *replaced = true; > + > + return 0; The function always succeeds - drop the return value ? > +} > + > +static int > +drm_atomic_replace_property_blob_from_id(struct drm_crtc *crtc, > +struct drm_property_blob **blob, > +uint64_t blob_id, > +ssize_t expected_size, > +bool *replaced) > +{ > + struct drm_device *dev = crtc->dev; > + struct drm_property_blob *new_blob = NULL; > + > + if (blob_id != 0) { > + new_blob = drm_property_lookup_blob(dev, blob_id); > + if (new_blob == NULL) > + return -EINVAL; > + if (expected_size > 0 && expected_size != new_blob->length) > + return -EINVAL; > + } > + Having a look at drm_atomic_set_mode_prop_for_crtc() I think I can spot a bug - it shouldn't drop/unref the old blob in case of an error. A case you handle nicely here. Perhaps it's worth using the drm_atomic_replace_property_blob() in there ? > @@ -397,6 +449,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, > { > struct drm_device *dev = crtc->dev; > struct drm_mode_config *config = >mode_config; > + bool replaced = false; > int ret; > > if (property == config->prop_active) > @@ -407,8 +460,31 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, > ret = drm_atomic_set_mode_prop_for_crtc(state, mode); > drm_property_unreference_blob(mode); > return ret; > - } > - else if (crtc->funcs->atomic_set_property) > + } else if (property == config->degamma_lut_property) { > + ret = drm_atomic_replace_property_blob_from_id(crtc, > + >degamma_lut, > + val,
[Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
Patch based on a previous series by Shashank Sharma. This introduces optional properties to enable color correction at the pipe level. It relies on 3 transformations applied to every pixels displayed. First a lookup into a degamma table, then a multiplication of the rgb components by a 3x3 matrix and finally another lookup into a gamma table. The following properties can be added to a pipe : - DEGAMMA_LUT : blob containing degamma LUT - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT - CTM : transformation matrix applied after the degamma LUT - GAMMA_LUT : blob containing gamma LUT - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by the driver to tell userspace applications what sizes should be the lookup tables in DEGAMMA_LUT and GAMMA_LUT. A helper is also provided so legacy gamma correction is redirected through these new properties. v2: Register LUT size properties as range v3: Fix round in drm_color_lut_get_value() helper More docs on how degamma/gamma properties are used v4: Update contributors v5: Rename CTM_MATRIX property to CTM (Doh!) Add legacy gamma_set atomic helper Describe CTM/LUT acronyms in the kernel doc Signed-off-by: Shashank SharmaSigned-off-by: Lionel Landwerlin Signed-off-by: Kumar, Kiran S Signed-off-by: Kausal Malladi Reviewed-by: Matt Roper --- Documentation/DocBook/gpu.tmpl | 59 - drivers/gpu/drm/drm_atomic.c| 86 +- drivers/gpu/drm/drm_atomic_helper.c | 103 drivers/gpu/drm/drm_crtc.c | 35 drivers/gpu/drm/drm_crtc_helper.c | 33 include/drm/drm_atomic_helper.h | 3 ++ include/drm/drm_crtc.h | 46 +++- include/drm/drm_crtc_helper.h | 3 ++ include/uapi/drm/drm_mode.h | 15 ++ 9 files changed, 378 insertions(+), 5 deletions(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index fe6b36a..1692c4d 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM + DRM Generic “rotation” BITMASK @@ -2068,7 +2068,7 @@ void intel_crt_init(struct drm_device *dev) property to suggest an Y offset for a connector - Optional + Optional “scaling mode” ENUM { "None", "Full", "Center", "Full aspect" } @@ -2092,6 +2092,61 @@ void intel_crt_init(struct drm_device *dev) TBD + “DEGAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the degamma lookup table + (LUT) mapping pixel data from the framebuffer before it is + given to the transformation matrix. The data is an interpreted + as an array of struct drm_color_lut elements. Hardware might + choose not to use the full precision of the LUT elements nor + use all the elements of the LUT (for example the hardware + might choose to interpolate between LUT[0] and LUT[4]). + + + “DEGAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the DEGAMMA_LUT property (the size depends + on the underlying hardware). + + + “CTM” + BLOB + 0 + CRTC + DRM property to set the current + transformation matrix (CTM) apply to pixel data after the + lookup through the degamma LUT and before the lookup through + the gamma LUT. The data is an interpreted as a struct + drm_color_ctm. + + + “GAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the gamma lookup table + (LUT) mapping pixel data after to the transformation matrix to + data sent to the connector. The data is an interpreted as an + array of struct drm_color_lut elements. Hardware might choose + not to use the full precision of the LUT elements nor use all + the elements of the LUT (for example the hardware might choose + to interpolate between LUT[0] and LUT[4]). + + + “GAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the GAMMA_LUT property (the size depends on + the underlying hardware). + + i915 Generic "Broadcast RGB"
[Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
Patch based on a previous series by Shashank Sharma. This introduces optional properties to enable color correction at the pipe level. It relies on 3 transformations applied to every pixels displayed. First a lookup into a degamma table, then a multiplication of the rgb components by a 3x3 matrix and finally another lookup into a gamma table. The following properties can be added to a pipe : - DEGAMMA_LUT : blob containing degamma LUT - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT - CTM : transformation matrix applied after the degamma LUT - GAMMA_LUT : blob containing gamma LUT - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by the driver to tell userspace applications what sizes should be the lookup tables in DEGAMMA_LUT and GAMMA_LUT. A helper is also provided so legacy gamma correction is redirected through these new properties. v2: Register LUT size properties as range v3: Fix round in drm_color_lut_get_value() helper More docs on how degamma/gamma properties are used v4: Update contributors v5: Rename CTM_MATRIX property to CTM (Doh!) Add legacy gamma_set atomic helper Describe CTM/LUT acronyms in the kernel doc Signed-off-by: Shashank SharmaSigned-off-by: Lionel Landwerlin Signed-off-by: Kumar, Kiran S Signed-off-by: Kausal Malladi Reviewed-by: Matt Roper --- Documentation/DocBook/gpu.tmpl | 59 - drivers/gpu/drm/drm_atomic.c| 86 +- drivers/gpu/drm/drm_atomic_helper.c | 103 drivers/gpu/drm/drm_crtc.c | 35 drivers/gpu/drm/drm_crtc_helper.c | 33 include/drm/drm_atomic_helper.h | 3 ++ include/drm/drm_crtc.h | 46 +++- include/drm/drm_crtc_helper.h | 3 ++ include/uapi/drm/drm_mode.h | 15 ++ 9 files changed, 378 insertions(+), 5 deletions(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index fe6b36a..1692c4d 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM + DRM Generic “rotation” BITMASK @@ -2068,7 +2068,7 @@ void intel_crt_init(struct drm_device *dev) property to suggest an Y offset for a connector - Optional + Optional “scaling mode” ENUM { "None", "Full", "Center", "Full aspect" } @@ -2092,6 +2092,61 @@ void intel_crt_init(struct drm_device *dev) TBD + “DEGAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the degamma lookup table + (LUT) mapping pixel data from the framebuffer before it is + given to the transformation matrix. The data is an interpreted + as an array of struct drm_color_lut elements. Hardware might + choose not to use the full precision of the LUT elements nor + use all the elements of the LUT (for example the hardware + might choose to interpolate between LUT[0] and LUT[4]). + + + “DEGAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the DEGAMMA_LUT property (the size depends + on the underlying hardware). + + + “CTM” + BLOB + 0 + CRTC + DRM property to set the current + transformation matrix (CTM) apply to pixel data after the + lookup through the degamma LUT and before the lookup through + the gamma LUT. The data is an interpreted as a struct + drm_color_ctm. + + + “GAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the gamma lookup table + (LUT) mapping pixel data after to the transformation matrix to + data sent to the connector. The data is an interpreted as an + array of struct drm_color_lut elements. Hardware might choose + not to use the full precision of the LUT elements nor use all + the elements of the LUT (for example the hardware might choose + to interpolate between LUT[0] and LUT[4]). + + + “GAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the GAMMA_LUT property (the size depends on + the underlying hardware). + + i915 Generic "Broadcast RGB"
[Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
Patch based on a previous series by Shashank Sharma. This introduces optional properties to enable color correction at the pipe level. It relies on 3 transformations applied to every pixels displayed. First a lookup into a degamma table, then a multiplication of the rgb components by a 3x3 matrix and finally another lookup into a gamma table. The following properties can be added to a pipe : - DEGAMMA_LUT : blob containing degamma LUT - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT - CTM : transformation matrix applied after the degamma LUT - GAMMA_LUT : blob containing gamma LUT - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by the driver to tell userspace applications what sizes should be the lookup tables in DEGAMMA_LUT and GAMMA_LUT. A helper is also provided so legacy gamma correction is redirected through these new properties. v2: Register LUT size properties as range v3: Fix round in drm_color_lut_get_value() helper More docs on how degamma/gamma properties are used v4: Update contributors v5: Rename CTM_MATRIX property to CTM (Doh!) Add legacy gamma_set atomic helper Describe CTM/LUT acronyms in the kernel doc Signed-off-by: Shashank SharmaSigned-off-by: Lionel Landwerlin Signed-off-by: Kumar, Kiran S Signed-off-by: Kausal Malladi Reviewed-by: Matt Roper --- Documentation/DocBook/gpu.tmpl | 59 - drivers/gpu/drm/drm_atomic.c| 86 +- drivers/gpu/drm/drm_atomic_helper.c | 103 drivers/gpu/drm/drm_crtc.c | 35 drivers/gpu/drm/drm_crtc_helper.c | 33 include/drm/drm_atomic_helper.h | 3 ++ include/drm/drm_crtc.h | 46 +++- include/drm/drm_crtc_helper.h | 3 ++ include/uapi/drm/drm_mode.h | 15 ++ 9 files changed, 378 insertions(+), 5 deletions(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index fe6b36a..1692c4d 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM + DRM Generic “rotation” BITMASK @@ -2068,7 +2068,7 @@ void intel_crt_init(struct drm_device *dev) property to suggest an Y offset for a connector - Optional + Optional “scaling mode” ENUM { "None", "Full", "Center", "Full aspect" } @@ -2092,6 +2092,61 @@ void intel_crt_init(struct drm_device *dev) TBD + “DEGAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the degamma lookup table + (LUT) mapping pixel data from the framebuffer before it is + given to the transformation matrix. The data is an interpreted + as an array of struct drm_color_lut elements. Hardware might + choose not to use the full precision of the LUT elements nor + use all the elements of the LUT (for example the hardware + might choose to interpolate between LUT[0] and LUT[4]). + + + “DEGAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the DEGAMMA_LUT property (the size depends + on the underlying hardware). + + + “CTM” + BLOB + 0 + CRTC + DRM property to set the current + transformation matrix (CTM) apply to pixel data after the + lookup through the degamma LUT and before the lookup through + the gamma LUT. The data is an interpreted as a struct + drm_color_ctm. + + + “GAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the gamma lookup table + (LUT) mapping pixel data after to the transformation matrix to + data sent to the connector. The data is an interpreted as an + array of struct drm_color_lut elements. Hardware might choose + not to use the full precision of the LUT elements nor use all + the elements of the LUT (for example the hardware might choose + to interpolate between LUT[0] and LUT[4]). + + + “GAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the GAMMA_LUT property (the size depends on + the underlying hardware). + + i915 Generic "Broadcast RGB"
[Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
Patch based on a previous series by Shashank Sharma. This introduces optional properties to enable color correction at the pipe level. It relies on 3 transformations applied to every pixels displayed. First a lookup into a degamma table, then a multiplication of the rgb components by a 3x3 matrix and finally another lookup into a gamma table. The following properties can be added to a pipe : - DEGAMMA_LUT : blob containing degamma LUT - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT - CTM : transformation matrix applied after the degamma LUT - GAMMA_LUT : blob containing gamma LUT - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by the driver to tell userspace applications what sizes should be the lookup tables in DEGAMMA_LUT and GAMMA_LUT. A helper is also provided so legacy gamma correction is redirected through these new properties. v2: Register LUT size properties as range v3: Fix round in drm_color_lut_get_value() helper More docs on how degamma/gamma properties are used v4: Update contributors v5: Rename CTM_MATRIX property to CTM (Doh!) Add legacy gamma_set atomic helper Describe CTM/LUT acronyms in the kernel doc Signed-off-by: Shashank SharmaSigned-off-by: Lionel Landwerlin Signed-off-by: Kumar, Kiran S Signed-off-by: Kausal Malladi Reviewed-by: Matt Roper --- Documentation/DocBook/gpu.tmpl | 59 - drivers/gpu/drm/drm_atomic.c| 86 +- drivers/gpu/drm/drm_atomic_helper.c | 103 drivers/gpu/drm/drm_crtc.c | 35 drivers/gpu/drm/drm_crtc_helper.c | 33 include/drm/drm_atomic_helper.h | 3 ++ include/drm/drm_crtc.h | 46 +++- include/drm/drm_crtc_helper.h | 3 ++ include/uapi/drm/drm_mode.h | 15 ++ 9 files changed, 378 insertions(+), 5 deletions(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index fe6b36a..1692c4d 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM + DRM Generic “rotation” BITMASK @@ -2068,7 +2068,7 @@ void intel_crt_init(struct drm_device *dev) property to suggest an Y offset for a connector - Optional + Optional “scaling mode” ENUM { "None", "Full", "Center", "Full aspect" } @@ -2092,6 +2092,61 @@ void intel_crt_init(struct drm_device *dev) TBD + “DEGAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the degamma lookup table + (LUT) mapping pixel data from the framebuffer before it is + given to the transformation matrix. The data is an interpreted + as an array of struct drm_color_lut elements. Hardware might + choose not to use the full precision of the LUT elements nor + use all the elements of the LUT (for example the hardware + might choose to interpolate between LUT[0] and LUT[4]). + + + “DEGAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the DEGAMMA_LUT property (the size depends + on the underlying hardware). + + + “CTM” + BLOB + 0 + CRTC + DRM property to set the current + transformation matrix (CTM) apply to pixel data after the + lookup through the degamma LUT and before the lookup through + the gamma LUT. The data is an interpreted as a struct + drm_color_ctm. + + + “GAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the gamma lookup table + (LUT) mapping pixel data after to the transformation matrix to + data sent to the connector. The data is an interpreted as an + array of struct drm_color_lut elements. Hardware might choose + not to use the full precision of the LUT elements nor use all + the elements of the LUT (for example the hardware might choose + to interpolate between LUT[0] and LUT[4]). + + + “GAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the GAMMA_LUT property (the size depends on + the underlying hardware). + + i915 Generic "Broadcast RGB"
[Intel-gfx] [PATCH 3/5] drm: introduce pipe color correction properties
Patch based on a previous series by Shashank Sharma. This introduces optional properties to enable color correction at the pipe level. It relies on 3 transformations applied to every pixels displayed. First a lookup into a degamma table, then a multiplication of the rgb components by a 3x3 matrix and finally another lookup into a gamma table. The following properties can be added to a pipe : - DEGAMMA_LUT : blob containing degamma LUT - DEGAMMA_LUT_SIZE : number of elements in DEGAMMA_LUT - CTM : transformation matrix applied after the degamma LUT - GAMMA_LUT : blob containing gamma LUT - GAMMA_LUT_SIZE : number of elements in GAMMA_LUT DEGAMMA_LUT_SIZE and GAMMA_LUT_SIZE are read only properties, set by the driver to tell userspace applications what sizes should be the lookup tables in DEGAMMA_LUT and GAMMA_LUT. A helper is also provided so legacy gamma correction is redirected through these new properties. v2: Register LUT size properties as range v3: Fix round in drm_color_lut_get_value() helper More docs on how degamma/gamma properties are used v4: Update contributors v5: Rename CTM_MATRIX property to CTM (Doh!) Add legacy gamma_set atomic helper Describe CTM/LUT acronyms in the kernel doc Signed-off-by: Shashank SharmaSigned-off-by: Lionel Landwerlin Signed-off-by: Kumar, Kiran S Signed-off-by: Kausal Malladi Reviewed-by: Matt Roper --- Documentation/DocBook/gpu.tmpl | 59 - drivers/gpu/drm/drm_atomic.c| 86 +- drivers/gpu/drm/drm_atomic_helper.c | 103 drivers/gpu/drm/drm_crtc.c | 35 drivers/gpu/drm/drm_crtc_helper.c | 33 include/drm/drm_atomic_helper.h | 3 ++ include/drm/drm_crtc.h | 46 +++- include/drm/drm_crtc_helper.h | 3 ++ include/uapi/drm/drm_mode.h | 15 ++ 9 files changed, 378 insertions(+), 5 deletions(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index fe6b36a..1692c4d 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM + DRM Generic “rotation” BITMASK @@ -2068,7 +2068,7 @@ void intel_crt_init(struct drm_device *dev) property to suggest an Y offset for a connector - Optional + Optional “scaling mode” ENUM { "None", "Full", "Center", "Full aspect" } @@ -2092,6 +2092,61 @@ void intel_crt_init(struct drm_device *dev) TBD + “DEGAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the degamma lookup table + (LUT) mapping pixel data from the framebuffer before it is + given to the transformation matrix. The data is an interpreted + as an array of struct drm_color_lut elements. Hardware might + choose not to use the full precision of the LUT elements nor + use all the elements of the LUT (for example the hardware + might choose to interpolate between LUT[0] and LUT[4]). + + + “DEGAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the DEGAMMA_LUT property (the size depends + on the underlying hardware). + + + “CTM” + BLOB + 0 + CRTC + DRM property to set the current + transformation matrix (CTM) apply to pixel data after the + lookup through the degamma LUT and before the lookup through + the gamma LUT. The data is an interpreted as a struct + drm_color_ctm. + + + “GAMMA_LUT” + BLOB + 0 + CRTC + DRM property to set the gamma lookup table + (LUT) mapping pixel data after to the transformation matrix to + data sent to the connector. The data is an interpreted as an + array of struct drm_color_lut elements. Hardware might choose + not to use the full precision of the LUT elements nor use all + the elements of the LUT (for example the hardware might choose + to interpolate between LUT[0] and LUT[4]). + + + “GAMMA_LUT_SIZE” + RANGE | IMMUTABLE + Min=0, Max=UINT_MAX + CRTC + DRM property to gives the size of the lookup + table to be set on the GAMMA_LUT property (the size depends on + the underlying hardware). + + i915 Generic "Broadcast RGB"