Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/edid: Fix EDID quirk compile error on older compilers

Apparently some compilers [1] cannot handle doing math on dereferenced
string constants at compile time. This has led to reports [2] of
compile errors like:

In file included from drivers/gpu/drm/drm_edid.c:42:0:
./include/drm/drm_edid.h:525:2: error: initializer element is not constant
((((u32)((vend)[0]) - '@') & 0x1f) << 26 | \

Go back to the syntax I used in v4 of the patch series [3] that added
this code instead of what landed (v5). This syntax is slightly uglier
but should be much more compatible with varied compilers.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960#c18
[2] https://lore.kernel.org/r/874kaabdt5.fsf@intel.com/
[3] https://lore.kernel.org/r/20210909135838.v4.4.I6103ce2b16e5e5a842b14c7022a034712b434609@changeid/

Fixes: d9f91a10c3e8 ("drm/edid: Allow querying/working with the panel ID from the EDID")
Reported-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Reported-by: Srikanth Myakam <smyakam@microsoft.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210924075317.1.I1e58d74d501613f1fe7585958f451160d11b8a98@changeid

+81 -77
+61 -60
drivers/gpu/drm/drm_edid.c
··· 100 100 #define LEVEL_GTF2 2 101 101 #define LEVEL_CVT 3 102 102 103 - #define EDID_QUIRK(vend, product_id, _quirks) \ 103 + #define EDID_QUIRK(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _quirks) \ 104 104 { \ 105 - .panel_id = drm_edid_encode_panel_id(vend, product_id), \ 105 + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ 106 + product_id), \ 106 107 .quirks = _quirks \ 107 108 } 108 109 ··· 112 111 u32 quirks; 113 112 } edid_quirk_list[] = { 114 113 /* Acer AL1706 */ 115 - EDID_QUIRK("ACR", 44358, EDID_QUIRK_PREFER_LARGE_60), 114 + EDID_QUIRK('A', 'C', 'R', 44358, EDID_QUIRK_PREFER_LARGE_60), 116 115 /* Acer F51 */ 117 - EDID_QUIRK("API", 0x7602, EDID_QUIRK_PREFER_LARGE_60), 116 + EDID_QUIRK('A', 'P', 'I', 0x7602, EDID_QUIRK_PREFER_LARGE_60), 118 117 119 118 /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ 120 - EDID_QUIRK("AEO", 0, EDID_QUIRK_FORCE_6BPC), 119 + EDID_QUIRK('A', 'E', 'O', 0, EDID_QUIRK_FORCE_6BPC), 121 120 122 121 /* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc panel */ 123 - EDID_QUIRK("BOE", 0x78b, EDID_QUIRK_FORCE_6BPC), 122 + EDID_QUIRK('B', 'O', 'E', 0x78b, EDID_QUIRK_FORCE_6BPC), 124 123 125 124 /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ 126 - EDID_QUIRK("CPT", 0x17df, EDID_QUIRK_FORCE_6BPC), 125 + EDID_QUIRK('C', 'P', 'T', 0x17df, EDID_QUIRK_FORCE_6BPC), 127 126 128 127 /* SDC panel of Lenovo B50-80 reports 8 bpc, but is a 6 bpc panel */ 129 - EDID_QUIRK("SDC", 0x3652, EDID_QUIRK_FORCE_6BPC), 128 + EDID_QUIRK('S', 'D', 'C', 0x3652, EDID_QUIRK_FORCE_6BPC), 130 129 131 130 /* BOE model 0x0771 reports 8 bpc, but is a 6 bpc panel */ 132 - EDID_QUIRK("BOE", 0x0771, EDID_QUIRK_FORCE_6BPC), 131 + EDID_QUIRK('B', 'O', 'E', 0x0771, EDID_QUIRK_FORCE_6BPC), 133 132 134 133 /* Belinea 10 15 55 */ 135 - EDID_QUIRK("MAX", 1516, EDID_QUIRK_PREFER_LARGE_60), 136 - EDID_QUIRK("MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60), 134 + EDID_QUIRK('M', 'A', 'X', 1516, EDID_QUIRK_PREFER_LARGE_60), 135 + EDID_QUIRK('M', 'A', 'X', 0x77e, EDID_QUIRK_PREFER_LARGE_60), 137 136 138 137 /* Envision Peripherals, Inc. EN-7100e */ 139 - EDID_QUIRK("EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH), 138 + EDID_QUIRK('E', 'P', 'I', 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH), 140 139 /* Envision EN2028 */ 141 - EDID_QUIRK("EPI", 8232, EDID_QUIRK_PREFER_LARGE_60), 140 + EDID_QUIRK('E', 'P', 'I', 8232, EDID_QUIRK_PREFER_LARGE_60), 142 141 143 142 /* Funai Electronics PM36B */ 144 - EDID_QUIRK("FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 | 143 + EDID_QUIRK('F', 'C', 'M', 13600, EDID_QUIRK_PREFER_LARGE_75 | 145 144 EDID_QUIRK_DETAILED_IN_CM), 146 145 147 146 /* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ 148 - EDID_QUIRK("LGD", 764, EDID_QUIRK_FORCE_10BPC), 147 + EDID_QUIRK('L', 'G', 'D', 764, EDID_QUIRK_FORCE_10BPC), 149 148 150 149 /* LG Philips LCD LP154W01-A5 */ 151 - EDID_QUIRK("LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE), 152 - EDID_QUIRK("LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE), 150 + EDID_QUIRK('L', 'P', 'L', 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE), 151 + EDID_QUIRK('L', 'P', 'L', 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE), 153 152 154 153 /* Samsung SyncMaster 205BW. Note: irony */ 155 - EDID_QUIRK("SAM", 541, EDID_QUIRK_DETAILED_SYNC_PP), 154 + EDID_QUIRK('S', 'A', 'M', 541, EDID_QUIRK_DETAILED_SYNC_PP), 156 155 /* Samsung SyncMaster 22[5-6]BW */ 157 - EDID_QUIRK("SAM", 596, EDID_QUIRK_PREFER_LARGE_60), 158 - EDID_QUIRK("SAM", 638, EDID_QUIRK_PREFER_LARGE_60), 156 + EDID_QUIRK('S', 'A', 'M', 596, EDID_QUIRK_PREFER_LARGE_60), 157 + EDID_QUIRK('S', 'A', 'M', 638, EDID_QUIRK_PREFER_LARGE_60), 159 158 160 159 /* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */ 161 - EDID_QUIRK("SNY", 0x2541, EDID_QUIRK_FORCE_12BPC), 160 + EDID_QUIRK('S', 'N', 'Y', 0x2541, EDID_QUIRK_FORCE_12BPC), 162 161 163 162 /* ViewSonic VA2026w */ 164 - EDID_QUIRK("VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING), 163 + EDID_QUIRK('V', 'S', 'C', 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING), 165 164 166 165 /* Medion MD 30217 PG */ 167 - EDID_QUIRK("MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75), 166 + EDID_QUIRK('M', 'E', 'D', 0x7b8, EDID_QUIRK_PREFER_LARGE_75), 168 167 169 168 /* Lenovo G50 */ 170 - EDID_QUIRK("SDC", 18514, EDID_QUIRK_FORCE_6BPC), 169 + EDID_QUIRK('S', 'D', 'C', 18514, EDID_QUIRK_FORCE_6BPC), 171 170 172 171 /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ 173 - EDID_QUIRK("SEC", 0xd033, EDID_QUIRK_FORCE_8BPC), 172 + EDID_QUIRK('S', 'E', 'C', 0xd033, EDID_QUIRK_FORCE_8BPC), 174 173 175 174 /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/ 176 - EDID_QUIRK("ETR", 13896, EDID_QUIRK_FORCE_8BPC), 175 + EDID_QUIRK('E', 'T', 'R', 13896, EDID_QUIRK_FORCE_8BPC), 177 176 178 177 /* Valve Index Headset */ 179 - EDID_QUIRK("VLV", 0x91a8, EDID_QUIRK_NON_DESKTOP), 180 - EDID_QUIRK("VLV", 0x91b0, EDID_QUIRK_NON_DESKTOP), 181 - EDID_QUIRK("VLV", 0x91b1, EDID_QUIRK_NON_DESKTOP), 182 - EDID_QUIRK("VLV", 0x91b2, EDID_QUIRK_NON_DESKTOP), 183 - EDID_QUIRK("VLV", 0x91b3, EDID_QUIRK_NON_DESKTOP), 184 - EDID_QUIRK("VLV", 0x91b4, EDID_QUIRK_NON_DESKTOP), 185 - EDID_QUIRK("VLV", 0x91b5, EDID_QUIRK_NON_DESKTOP), 186 - EDID_QUIRK("VLV", 0x91b6, EDID_QUIRK_NON_DESKTOP), 187 - EDID_QUIRK("VLV", 0x91b7, EDID_QUIRK_NON_DESKTOP), 188 - EDID_QUIRK("VLV", 0x91b8, EDID_QUIRK_NON_DESKTOP), 189 - EDID_QUIRK("VLV", 0x91b9, EDID_QUIRK_NON_DESKTOP), 190 - EDID_QUIRK("VLV", 0x91ba, EDID_QUIRK_NON_DESKTOP), 191 - EDID_QUIRK("VLV", 0x91bb, EDID_QUIRK_NON_DESKTOP), 192 - EDID_QUIRK("VLV", 0x91bc, EDID_QUIRK_NON_DESKTOP), 193 - EDID_QUIRK("VLV", 0x91bd, EDID_QUIRK_NON_DESKTOP), 194 - EDID_QUIRK("VLV", 0x91be, EDID_QUIRK_NON_DESKTOP), 195 - EDID_QUIRK("VLV", 0x91bf, EDID_QUIRK_NON_DESKTOP), 178 + EDID_QUIRK('V', 'L', 'V', 0x91a8, EDID_QUIRK_NON_DESKTOP), 179 + EDID_QUIRK('V', 'L', 'V', 0x91b0, EDID_QUIRK_NON_DESKTOP), 180 + EDID_QUIRK('V', 'L', 'V', 0x91b1, EDID_QUIRK_NON_DESKTOP), 181 + EDID_QUIRK('V', 'L', 'V', 0x91b2, EDID_QUIRK_NON_DESKTOP), 182 + EDID_QUIRK('V', 'L', 'V', 0x91b3, EDID_QUIRK_NON_DESKTOP), 183 + EDID_QUIRK('V', 'L', 'V', 0x91b4, EDID_QUIRK_NON_DESKTOP), 184 + EDID_QUIRK('V', 'L', 'V', 0x91b5, EDID_QUIRK_NON_DESKTOP), 185 + EDID_QUIRK('V', 'L', 'V', 0x91b6, EDID_QUIRK_NON_DESKTOP), 186 + EDID_QUIRK('V', 'L', 'V', 0x91b7, EDID_QUIRK_NON_DESKTOP), 187 + EDID_QUIRK('V', 'L', 'V', 0x91b8, EDID_QUIRK_NON_DESKTOP), 188 + EDID_QUIRK('V', 'L', 'V', 0x91b9, EDID_QUIRK_NON_DESKTOP), 189 + EDID_QUIRK('V', 'L', 'V', 0x91ba, EDID_QUIRK_NON_DESKTOP), 190 + EDID_QUIRK('V', 'L', 'V', 0x91bb, EDID_QUIRK_NON_DESKTOP), 191 + EDID_QUIRK('V', 'L', 'V', 0x91bc, EDID_QUIRK_NON_DESKTOP), 192 + EDID_QUIRK('V', 'L', 'V', 0x91bd, EDID_QUIRK_NON_DESKTOP), 193 + EDID_QUIRK('V', 'L', 'V', 0x91be, EDID_QUIRK_NON_DESKTOP), 194 + EDID_QUIRK('V', 'L', 'V', 0x91bf, EDID_QUIRK_NON_DESKTOP), 196 195 197 196 /* HTC Vive and Vive Pro VR Headsets */ 198 - EDID_QUIRK("HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP), 199 - EDID_QUIRK("HVR", 0xaa02, EDID_QUIRK_NON_DESKTOP), 197 + EDID_QUIRK('H', 'V', 'R', 0xaa01, EDID_QUIRK_NON_DESKTOP), 198 + EDID_QUIRK('H', 'V', 'R', 0xaa02, EDID_QUIRK_NON_DESKTOP), 200 199 201 200 /* Oculus Rift DK1, DK2, CV1 and Rift S VR Headsets */ 202 - EDID_QUIRK("OVR", 0x0001, EDID_QUIRK_NON_DESKTOP), 203 - EDID_QUIRK("OVR", 0x0003, EDID_QUIRK_NON_DESKTOP), 204 - EDID_QUIRK("OVR", 0x0004, EDID_QUIRK_NON_DESKTOP), 205 - EDID_QUIRK("OVR", 0x0012, EDID_QUIRK_NON_DESKTOP), 201 + EDID_QUIRK('O', 'V', 'R', 0x0001, EDID_QUIRK_NON_DESKTOP), 202 + EDID_QUIRK('O', 'V', 'R', 0x0003, EDID_QUIRK_NON_DESKTOP), 203 + EDID_QUIRK('O', 'V', 'R', 0x0004, EDID_QUIRK_NON_DESKTOP), 204 + EDID_QUIRK('O', 'V', 'R', 0x0012, EDID_QUIRK_NON_DESKTOP), 206 205 207 206 /* Windows Mixed Reality Headsets */ 208 - EDID_QUIRK("ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP), 209 - EDID_QUIRK("HPN", 0x3515, EDID_QUIRK_NON_DESKTOP), 210 - EDID_QUIRK("LEN", 0x0408, EDID_QUIRK_NON_DESKTOP), 211 - EDID_QUIRK("LEN", 0xb800, EDID_QUIRK_NON_DESKTOP), 212 - EDID_QUIRK("FUJ", 0x1970, EDID_QUIRK_NON_DESKTOP), 213 - EDID_QUIRK("DEL", 0x7fce, EDID_QUIRK_NON_DESKTOP), 214 - EDID_QUIRK("SEC", 0x144a, EDID_QUIRK_NON_DESKTOP), 215 - EDID_QUIRK("AUS", 0xc102, EDID_QUIRK_NON_DESKTOP), 207 + EDID_QUIRK('A', 'C', 'R', 0x7fce, EDID_QUIRK_NON_DESKTOP), 208 + EDID_QUIRK('H', 'P', 'N', 0x3515, EDID_QUIRK_NON_DESKTOP), 209 + EDID_QUIRK('L', 'E', 'N', 0x0408, EDID_QUIRK_NON_DESKTOP), 210 + EDID_QUIRK('L', 'E', 'N', 0xb800, EDID_QUIRK_NON_DESKTOP), 211 + EDID_QUIRK('F', 'U', 'J', 0x1970, EDID_QUIRK_NON_DESKTOP), 212 + EDID_QUIRK('D', 'E', 'L', 0x7fce, EDID_QUIRK_NON_DESKTOP), 213 + EDID_QUIRK('S', 'E', 'C', 0x144a, EDID_QUIRK_NON_DESKTOP), 214 + EDID_QUIRK('A', 'U', 'S', 0xc102, EDID_QUIRK_NON_DESKTOP), 216 215 217 216 /* Sony PlayStation VR Headset */ 218 - EDID_QUIRK("SNY", 0x0704, EDID_QUIRK_NON_DESKTOP), 217 + EDID_QUIRK('S', 'N', 'Y', 0x0704, EDID_QUIRK_NON_DESKTOP), 219 218 220 219 /* Sensics VR Headsets */ 221 - EDID_QUIRK("SEN", 0x1019, EDID_QUIRK_NON_DESKTOP), 220 + EDID_QUIRK('S', 'E', 'N', 0x1019, EDID_QUIRK_NON_DESKTOP), 222 221 223 222 /* OSVR HDK and HDK2 VR Headsets */ 224 - EDID_QUIRK("SVR", 0x1019, EDID_QUIRK_NON_DESKTOP), 223 + EDID_QUIRK('S', 'V', 'R', 0x1019, EDID_QUIRK_NON_DESKTOP), 225 224 }; 226 225 227 226 /*
+12 -11
drivers/gpu/drm/panel/panel-edp.c
··· 1745 1745 .enable = 50, 1746 1746 }; 1747 1747 1748 - #define EDP_PANEL_ENTRY(vend, product_id, _delay, _name) \ 1748 + #define EDP_PANEL_ENTRY(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name) \ 1749 1749 { \ 1750 1750 .name = _name, \ 1751 - .panel_id = drm_edid_encode_panel_id(vend, product_id), \ 1751 + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ 1752 + product_id), \ 1752 1753 .delay = _delay \ 1753 1754 } 1754 1755 ··· 1761 1760 * Sort first by vendor, then by product ID. 1762 1761 */ 1763 1762 static const struct edp_panel_entry edp_panels[] = { 1764 - EDP_PANEL_ENTRY("AUO", 0x405c, &auo_b116xak01.delay, "B116XAK01"), 1765 - EDP_PANEL_ENTRY("AUO", 0x615c, &delay_200_500_e50, "B116XAN06.1"), 1763 + EDP_PANEL_ENTRY('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAK01"), 1764 + EDP_PANEL_ENTRY('A', 'U', 'O', 0x615c, &delay_200_500_e50, "B116XAN06.1"), 1766 1765 1767 - EDP_PANEL_ENTRY("BOE", 0x0786, &delay_200_500_p2e80, "NV116WHM-T01"), 1768 - EDP_PANEL_ENTRY("BOE", 0x07d1, &boe_nv133fhm_n61.delay, "NV133FHM-N61"), 1769 - EDP_PANEL_ENTRY("BOE", 0x082d, &boe_nv133fhm_n61.delay, "NV133FHM-N62"), 1770 - EDP_PANEL_ENTRY("BOE", 0x098d, &boe_nv110wtm_n61.delay, "NV110WTM-N61"), 1766 + EDP_PANEL_ENTRY('B', 'O', 'E', 0x0786, &delay_200_500_p2e80, "NV116WHM-T01"), 1767 + EDP_PANEL_ENTRY('B', 'O', 'E', 0x07d1, &boe_nv133fhm_n61.delay, "NV133FHM-N61"), 1768 + EDP_PANEL_ENTRY('B', 'O', 'E', 0x082d, &boe_nv133fhm_n61.delay, "NV133FHM-N62"), 1769 + EDP_PANEL_ENTRY('B', 'O', 'E', 0x098d, &boe_nv110wtm_n61.delay, "NV110WTM-N61"), 1771 1770 1772 - EDP_PANEL_ENTRY("CMN", 0x114c, &innolux_n116bca_ea1.delay, "N116BCA-EA1"), 1771 + EDP_PANEL_ENTRY('C', 'M', 'N', 0x114c, &innolux_n116bca_ea1.delay, "N116BCA-EA1"), 1773 1772 1774 - EDP_PANEL_ENTRY("KDB", 0x0624, &kingdisplay_kd116n21_30nv_a010.delay, "116N21-30NV-A010"), 1773 + EDP_PANEL_ENTRY('K', 'D', 'B', 0x0624, &kingdisplay_kd116n21_30nv_a010.delay, "116N21-30NV-A010"), 1775 1774 1776 - EDP_PANEL_ENTRY("SHP", 0x154c, &delay_200_500_p2e100, "LQ116M1JW10"), 1775 + EDP_PANEL_ENTRY('S', 'H', 'P', 0x154c, &delay_200_500_p2e100, "LQ116M1JW10"), 1777 1776 1778 1777 { /* sentinal */ } 1779 1778 };
+8 -6
include/drm/drm_edid.h
··· 510 510 511 511 /** 512 512 * drm_edid_encode_panel_id - Encode an ID for matching against drm_edid_get_panel_id() 513 - * @vend: 3-character vendor string 513 + * @vend_chr_0: First character of the vendor string. 514 + * @vend_chr_2: Second character of the vendor string. 515 + * @vend_chr_3: Third character of the vendor string. 514 516 * @product_id: The 16-bit product ID. 515 517 * 516 518 * This is a macro so that it can be calculated at compile time and used 517 519 * as an initializer. 518 520 * 519 521 * For instance: 520 - * drm_edid_encode_panel_id("BOE", 0x2d08) => 0x09e52d08 522 + * drm_edid_encode_panel_id('B', 'O', 'E', 0x2d08) => 0x09e52d08 521 523 * 522 524 * Return: a 32-bit ID per panel. 523 525 */ 524 - #define drm_edid_encode_panel_id(vend, product_id) \ 525 - ((((u32)((vend)[0]) - '@') & 0x1f) << 26 | \ 526 - (((u32)((vend)[1]) - '@') & 0x1f) << 21 | \ 527 - (((u32)((vend)[2]) - '@') & 0x1f) << 16 | \ 526 + #define drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, product_id) \ 527 + ((((u32)(vend_chr_0) - '@') & 0x1f) << 26 | \ 528 + (((u32)(vend_chr_1) - '@') & 0x1f) << 21 | \ 529 + (((u32)(vend_chr_2) - '@') & 0x1f) << 16 | \ 528 530 ((product_id) & 0xffff)) 529 531 530 532 /**