1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright © 2018 Intel Corporation 4 */ 5 6 #include <linux/dmi.h> 7 8 #include "i915_drv.h" 9 #include "intel_display_types.h" 10 #include "intel_quirks.h" 11 12 static void intel_set_quirk(struct drm_i915_private *i915, enum intel_quirk_id quirk) 13 { 14 i915->display.quirks.mask |= BIT(quirk); 15 } 16 17 /* 18 * Some machines (Lenovo U160) do not work with SSC on LVDS for some reason 19 */ 20 static void quirk_ssc_force_disable(struct drm_i915_private *i915) 21 { 22 intel_set_quirk(i915, QUIRK_LVDS_SSC_DISABLE); 23 drm_info(&i915->drm, "applying lvds SSC disable quirk\n"); 24 } 25 26 /* 27 * A machine (e.g. Acer Aspire 5734Z) may need to invert the panel backlight 28 * brightness value 29 */ 30 static void quirk_invert_brightness(struct drm_i915_private *i915) 31 { 32 intel_set_quirk(i915, QUIRK_INVERT_BRIGHTNESS); 33 drm_info(&i915->drm, "applying inverted panel brightness quirk\n"); 34 } 35 36 /* Some VBT's incorrectly indicate no backlight is present */ 37 static void quirk_backlight_present(struct drm_i915_private *i915) 38 { 39 intel_set_quirk(i915, QUIRK_BACKLIGHT_PRESENT); 40 drm_info(&i915->drm, "applying backlight present quirk\n"); 41 } 42 43 /* Toshiba Satellite P50-C-18C requires T12 delay to be min 800ms 44 * which is 300 ms greater than eDP spec T12 min. 45 */ 46 static void quirk_increase_t12_delay(struct drm_i915_private *i915) 47 { 48 intel_set_quirk(i915, QUIRK_INCREASE_T12_DELAY); 49 drm_info(&i915->drm, "Applying T12 delay quirk\n"); 50 } 51 52 /* 53 * GeminiLake NUC HDMI outputs require additional off time 54 * this allows the onboard retimer to correctly sync to signal 55 */ 56 static void quirk_increase_ddi_disabled_time(struct drm_i915_private *i915) 57 { 58 intel_set_quirk(i915, QUIRK_INCREASE_DDI_DISABLED_TIME); 59 drm_info(&i915->drm, "Applying Increase DDI Disabled quirk\n"); 60 } 61 62 static void quirk_no_pps_backlight_power_hook(struct drm_i915_private *i915) 63 { 64 intel_set_quirk(i915, QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK); 65 drm_info(&i915->drm, "Applying no pps backlight power quirk\n"); 66 } 67 68 struct intel_quirk { 69 int device; 70 int subsystem_vendor; 71 int subsystem_device; 72 void (*hook)(struct drm_i915_private *i915); 73 }; 74 75 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */ 76 struct intel_dmi_quirk { 77 void (*hook)(struct drm_i915_private *i915); 78 const struct dmi_system_id (*dmi_id_list)[]; 79 }; 80 81 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id) 82 { 83 DRM_INFO("Backlight polarity reversed on %s\n", id->ident); 84 return 1; 85 } 86 87 static int intel_dmi_no_pps_backlight(const struct dmi_system_id *id) 88 { 89 DRM_INFO("No pps backlight support on %s\n", id->ident); 90 return 1; 91 } 92 93 static const struct intel_dmi_quirk intel_dmi_quirks[] = { 94 { 95 .dmi_id_list = &(const struct dmi_system_id[]) { 96 { 97 .callback = intel_dmi_reverse_brightness, 98 .ident = "NCR Corporation", 99 .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"), 100 DMI_MATCH(DMI_PRODUCT_NAME, ""), 101 }, 102 }, 103 { 104 .callback = intel_dmi_reverse_brightness, 105 .ident = "Thundersoft TST178 tablet", 106 /* DMI strings are too generic, also match on BIOS date */ 107 .matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 108 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), 109 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "To be filled by O.E.M."), 110 DMI_EXACT_MATCH(DMI_BIOS_DATE, "04/15/2014"), 111 }, 112 }, 113 { } /* terminating entry */ 114 }, 115 .hook = quirk_invert_brightness, 116 }, 117 { 118 .dmi_id_list = &(const struct dmi_system_id[]) { 119 { 120 .callback = intel_dmi_no_pps_backlight, 121 .ident = "Google Lillipup sku524294", 122 .matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Google"), 123 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Lindar"), 124 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "sku524294"), 125 }, 126 }, 127 { 128 .callback = intel_dmi_no_pps_backlight, 129 .ident = "Google Lillipup sku524295", 130 .matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Google"), 131 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Lindar"), 132 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "sku524295"), 133 }, 134 }, 135 { } 136 }, 137 .hook = quirk_no_pps_backlight_power_hook, 138 }, 139 }; 140 141 static struct intel_quirk intel_quirks[] = { 142 /* Lenovo U160 cannot use SSC on LVDS */ 143 { 0x0046, 0x17aa, 0x3920, quirk_ssc_force_disable }, 144 145 /* Sony Vaio Y cannot use SSC on LVDS */ 146 { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable }, 147 148 /* Acer Aspire 5734Z must invert backlight brightness */ 149 { 0x2a42, 0x1025, 0x0459, quirk_invert_brightness }, 150 151 /* Acer/eMachines G725 */ 152 { 0x2a42, 0x1025, 0x0210, quirk_invert_brightness }, 153 154 /* Acer/eMachines e725 */ 155 { 0x2a42, 0x1025, 0x0212, quirk_invert_brightness }, 156 157 /* Acer/Packard Bell NCL20 */ 158 { 0x2a42, 0x1025, 0x034b, quirk_invert_brightness }, 159 160 /* Acer Aspire 4736Z */ 161 { 0x2a42, 0x1025, 0x0260, quirk_invert_brightness }, 162 163 /* Acer Aspire 5336 */ 164 { 0x2a42, 0x1025, 0x048a, quirk_invert_brightness }, 165 166 /* Acer C720 and C720P Chromebooks (Celeron 2955U) have backlights */ 167 { 0x0a06, 0x1025, 0x0a11, quirk_backlight_present }, 168 169 /* Acer C720 Chromebook (Core i3 4005U) */ 170 { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present }, 171 172 /* Apple Macbook 2,1 (Core 2 T7400) */ 173 { 0x27a2, 0x8086, 0x7270, quirk_backlight_present }, 174 175 /* Apple Macbook 4,1 */ 176 { 0x2a02, 0x106b, 0x00a1, quirk_backlight_present }, 177 178 /* Toshiba CB35 Chromebook (Celeron 2955U) */ 179 { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present }, 180 181 /* HP Chromebook 14 (Celeron 2955U) */ 182 { 0x0a06, 0x103c, 0x21ed, quirk_backlight_present }, 183 184 /* Dell Chromebook 11 */ 185 { 0x0a06, 0x1028, 0x0a35, quirk_backlight_present }, 186 187 /* Dell Chromebook 11 (2015 version) */ 188 { 0x0a16, 0x1028, 0x0a35, quirk_backlight_present }, 189 190 /* Toshiba Satellite P50-C-18C */ 191 { 0x191B, 0x1179, 0xF840, quirk_increase_t12_delay }, 192 193 /* GeminiLake NUC */ 194 { 0x3185, 0x8086, 0x2072, quirk_increase_ddi_disabled_time }, 195 { 0x3184, 0x8086, 0x2072, quirk_increase_ddi_disabled_time }, 196 /* ASRock ITX*/ 197 { 0x3185, 0x1849, 0x2212, quirk_increase_ddi_disabled_time }, 198 { 0x3184, 0x1849, 0x2212, quirk_increase_ddi_disabled_time }, 199 /* ECS Liva Q2 */ 200 { 0x3185, 0x1019, 0xa94d, quirk_increase_ddi_disabled_time }, 201 { 0x3184, 0x1019, 0xa94d, quirk_increase_ddi_disabled_time }, 202 }; 203 204 void intel_init_quirks(struct drm_i915_private *i915) 205 { 206 struct pci_dev *d = to_pci_dev(i915->drm.dev); 207 int i; 208 209 for (i = 0; i < ARRAY_SIZE(intel_quirks); i++) { 210 struct intel_quirk *q = &intel_quirks[i]; 211 212 if (d->device == q->device && 213 (d->subsystem_vendor == q->subsystem_vendor || 214 q->subsystem_vendor == PCI_ANY_ID) && 215 (d->subsystem_device == q->subsystem_device || 216 q->subsystem_device == PCI_ANY_ID)) 217 q->hook(i915); 218 } 219 for (i = 0; i < ARRAY_SIZE(intel_dmi_quirks); i++) { 220 if (dmi_check_system(*intel_dmi_quirks[i].dmi_id_list) != 0) 221 intel_dmi_quirks[i].hook(i915); 222 } 223 } 224 225 bool intel_has_quirk(struct drm_i915_private *i915, enum intel_quirk_id quirk) 226 { 227 return i915->display.quirks.mask & BIT(quirk); 228 } 229