Skip to content

Commit f900067

Browse files
swatish2-linuxcmpatel8588
authored andcommitted
UPSTREAM: drm/i915/display: Add func to compare hw/sw gamma lut
Add func intel_color_lut_equal() to compare hw/sw gamma lut values. Since hw/sw gamma lut sizes and lut entries comparison will be different for different gamma modes, add gamma mode dependent checks. v3: -Rebase v4: -Renamed intel_compare_color_lut() to intel_color_lut_equal() [Jani] -Added the default label above the correct label [Jani] -Corrected smatch warn "variable dereferenced before check" [Dan Carpenter] v5: -Added condition (!blob1 && !blob2) return true [Jani] v6: -Made patch11 as patch3 [Jani] v8: -Split patch 3 into 4 patches -Optimized blob check condition [Ville] v9: -Exclude spilt gamma mode (bdw and ivb platforms) as there is exception in way gamma values are written in hardware [Ville] -Added exception made in commit [Uma] -Dropped else, character limit and indentation [Uma] -Added multi segmented gama mode for icl+ platforms [Uma] v10: -Dropped multi segmented mode for icl+ platforms [Jani] -Removed references of sw and hw state in compare code [Jani] -Dropped inline from func [Jani] Signed-off-by: Swati Sharma <swati2.sharma@intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/1567538578-4489-4-git-send-email-swati2.sharma@intel.com (cherry picked from commit e9c8f59) Signed-off-by: Chintan Patel <chintan.m.patel@intel.com> BUG=b:146438784, b:146143855, b:145022885, b:144953588 TEST=Boot to graphics on TGL board provided Mesa Iris enabled see: b:141490430 TEST=Run WebGL benchmark with 1k+ fish should not show blue fish TEST=Font should be clear when typing on login screen Change-Id: I73b1ca521bbfe8549eb9bf95355611d6990dd010
1 parent 307dda6 commit f900067

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

drivers/gpu/drm/i915/display/intel_color.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,78 @@ int intel_color_get_gamma_bit_precision(const struct intel_crtc_state *crtc_stat
14921492
return 0;
14931493
}
14941494

1495+
static bool err_check(struct drm_color_lut *lut1,
1496+
struct drm_color_lut *lut2, u32 err)
1497+
{
1498+
return ((abs((long)lut2->red - lut1->red)) <= err) &&
1499+
((abs((long)lut2->blue - lut1->blue)) <= err) &&
1500+
((abs((long)lut2->green - lut1->green)) <= err);
1501+
}
1502+
1503+
static bool intel_color_lut_entry_equal(struct drm_color_lut *lut1,
1504+
struct drm_color_lut *lut2,
1505+
int lut_size, u32 err)
1506+
{
1507+
int i;
1508+
1509+
for (i = 0; i < lut_size; i++) {
1510+
if (!err_check(&lut1[i], &lut2[i], err))
1511+
return false;
1512+
}
1513+
1514+
return true;
1515+
}
1516+
1517+
bool intel_color_lut_equal(struct drm_property_blob *blob1,
1518+
struct drm_property_blob *blob2,
1519+
u32 gamma_mode, u32 bit_precision)
1520+
{
1521+
struct drm_color_lut *lut1, *lut2;
1522+
int lut_size1, lut_size2;
1523+
u32 err;
1524+
1525+
if (!blob1 != !blob2)
1526+
return false;
1527+
1528+
if (!blob1)
1529+
return true;
1530+
1531+
lut_size1 = drm_color_lut_size(blob1);
1532+
lut_size2 = drm_color_lut_size(blob2);
1533+
1534+
/* check sw and hw lut size */
1535+
switch (gamma_mode) {
1536+
case GAMMA_MODE_MODE_8BIT:
1537+
case GAMMA_MODE_MODE_10BIT:
1538+
if (lut_size1 != lut_size2)
1539+
return false;
1540+
break;
1541+
default:
1542+
MISSING_CASE(gamma_mode);
1543+
return false;
1544+
}
1545+
1546+
lut1 = blob1->data;
1547+
lut2 = blob2->data;
1548+
1549+
err = 0xffff >> bit_precision;
1550+
1551+
/* check sw and hw lut entry to be equal */
1552+
switch (gamma_mode) {
1553+
case GAMMA_MODE_MODE_8BIT:
1554+
case GAMMA_MODE_MODE_10BIT:
1555+
if (!intel_color_lut_entry_equal(lut1, lut2,
1556+
lut_size2, err))
1557+
return false;
1558+
break;
1559+
default:
1560+
MISSING_CASE(gamma_mode);
1561+
return false;
1562+
}
1563+
1564+
return true;
1565+
}
1566+
14951567
void intel_color_init(struct intel_crtc *crtc)
14961568
{
14971569
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);

drivers/gpu/drm/i915/display/intel_color.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@
66
#ifndef __INTEL_COLOR_H__
77
#define __INTEL_COLOR_H__
88

9+
#include <linux/types.h>
10+
911
struct intel_crtc_state;
1012
struct intel_crtc;
13+
struct drm_property_blob;
1114

1215
void intel_color_init(struct intel_crtc *crtc);
1316
int intel_color_check(struct intel_crtc_state *crtc_state);
1417
void intel_color_commit(const struct intel_crtc_state *crtc_state);
1518
void intel_color_load_luts(const struct intel_crtc_state *crtc_state);
1619
void intel_color_get_config(struct intel_crtc_state *crtc_state);
1720
int intel_color_get_gamma_bit_precision(const struct intel_crtc_state *crtc_state);
21+
bool intel_color_lut_equal(struct drm_property_blob *blob1,
22+
struct drm_property_blob *blob2,
23+
u32 gamma_mode, u32 bit_precision);
1824

1925
#endif /* __INTEL_COLOR_H__ */

0 commit comments

Comments
 (0)