xref: /linux/drivers/gpu/drm/i915/display/intel_quirks.c (revision 42b16d3ac371a2fac9b6f08fd75f23f34ba3955a)
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 
intel_set_quirk(struct intel_display * display,enum intel_quirk_id quirk)12 static void intel_set_quirk(struct intel_display *display, enum intel_quirk_id quirk)
13 {
14 	display->quirks.mask |= BIT(quirk);
15 }
16 
intel_set_dpcd_quirk(struct intel_dp * intel_dp,enum intel_quirk_id quirk)17 static void intel_set_dpcd_quirk(struct intel_dp *intel_dp, enum intel_quirk_id quirk)
18 {
19 	intel_dp->quirks.mask |= BIT(quirk);
20 }
21 
22 /*
23  * Some machines (Lenovo U160) do not work with SSC on LVDS for some reason
24  */
quirk_ssc_force_disable(struct intel_display * display)25 static void quirk_ssc_force_disable(struct intel_display *display)
26 {
27 	intel_set_quirk(display, QUIRK_LVDS_SSC_DISABLE);
28 	drm_info(display->drm, "applying lvds SSC disable quirk\n");
29 }
30 
31 /*
32  * A machine (e.g. Acer Aspire 5734Z) may need to invert the panel backlight
33  * brightness value
34  */
quirk_invert_brightness(struct intel_display * display)35 static void quirk_invert_brightness(struct intel_display *display)
36 {
37 	intel_set_quirk(display, QUIRK_INVERT_BRIGHTNESS);
38 	drm_info(display->drm, "applying inverted panel brightness quirk\n");
39 }
40 
41 /* Some VBT's incorrectly indicate no backlight is present */
quirk_backlight_present(struct intel_display * display)42 static void quirk_backlight_present(struct intel_display *display)
43 {
44 	intel_set_quirk(display, QUIRK_BACKLIGHT_PRESENT);
45 	drm_info(display->drm, "applying backlight present quirk\n");
46 }
47 
48 /* Toshiba Satellite P50-C-18C requires T12 delay to be min 800ms
49  * which is 300 ms greater than eDP spec T12 min.
50  */
quirk_increase_t12_delay(struct intel_display * display)51 static void quirk_increase_t12_delay(struct intel_display *display)
52 {
53 	intel_set_quirk(display, QUIRK_INCREASE_T12_DELAY);
54 	drm_info(display->drm, "Applying T12 delay quirk\n");
55 }
56 
57 /*
58  * GeminiLake NUC HDMI outputs require additional off time
59  * this allows the onboard retimer to correctly sync to signal
60  */
quirk_increase_ddi_disabled_time(struct intel_display * display)61 static void quirk_increase_ddi_disabled_time(struct intel_display *display)
62 {
63 	intel_set_quirk(display, QUIRK_INCREASE_DDI_DISABLED_TIME);
64 	drm_info(display->drm, "Applying Increase DDI Disabled quirk\n");
65 }
66 
quirk_no_pps_backlight_power_hook(struct intel_display * display)67 static void quirk_no_pps_backlight_power_hook(struct intel_display *display)
68 {
69 	intel_set_quirk(display, QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK);
70 	drm_info(display->drm, "Applying no pps backlight power quirk\n");
71 }
72 
quirk_fw_sync_len(struct intel_dp * intel_dp)73 static void quirk_fw_sync_len(struct intel_dp *intel_dp)
74 {
75 	struct intel_display *display = to_intel_display(intel_dp);
76 
77 	intel_set_dpcd_quirk(intel_dp, QUIRK_FW_SYNC_LEN);
78 	drm_info(display->drm, "Applying Fast Wake sync pulse count quirk\n");
79 }
80 
81 struct intel_quirk {
82 	int device;
83 	int subsystem_vendor;
84 	int subsystem_device;
85 	void (*hook)(struct intel_display *display);
86 };
87 
88 struct intel_dpcd_quirk {
89 	int device;
90 	int subsystem_vendor;
91 	int subsystem_device;
92 	u8 sink_oui[3];
93 	u8 sink_device_id[6];
94 	void (*hook)(struct intel_dp *intel_dp);
95 };
96 
97 #define SINK_OUI(first, second, third) { (first), (second), (third) }
98 #define SINK_DEVICE_ID(first, second, third, fourth, fifth, sixth) \
99 	{ (first), (second), (third), (fourth), (fifth), (sixth) }
100 
101 #define SINK_DEVICE_ID_ANY	SINK_DEVICE_ID(0, 0, 0, 0, 0, 0)
102 
103 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
104 struct intel_dmi_quirk {
105 	void (*hook)(struct intel_display *display);
106 	const struct dmi_system_id (*dmi_id_list)[];
107 };
108 
intel_dmi_reverse_brightness(const struct dmi_system_id * id)109 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
110 {
111 	DRM_INFO("Backlight polarity reversed on %s\n", id->ident);
112 	return 1;
113 }
114 
intel_dmi_no_pps_backlight(const struct dmi_system_id * id)115 static int intel_dmi_no_pps_backlight(const struct dmi_system_id *id)
116 {
117 	DRM_INFO("No pps backlight support on %s\n", id->ident);
118 	return 1;
119 }
120 
121 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
122 	{
123 		.dmi_id_list = &(const struct dmi_system_id[]) {
124 			{
125 				.callback = intel_dmi_reverse_brightness,
126 				.ident = "NCR Corporation",
127 				.matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
128 					    DMI_MATCH(DMI_PRODUCT_NAME, ""),
129 				},
130 			},
131 			{
132 				.callback = intel_dmi_reverse_brightness,
133 				.ident = "Thundersoft TST178 tablet",
134 				/* DMI strings are too generic, also match on BIOS date */
135 				.matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
136 					    DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
137 					    DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "To be filled by O.E.M."),
138 					    DMI_EXACT_MATCH(DMI_BIOS_DATE, "04/15/2014"),
139 				},
140 			},
141 			{ }  /* terminating entry */
142 		},
143 		.hook = quirk_invert_brightness,
144 	},
145 	{
146 		.dmi_id_list = &(const struct dmi_system_id[]) {
147 			{
148 				.callback = intel_dmi_no_pps_backlight,
149 				.ident = "Google Lillipup sku524294",
150 				.matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Google"),
151 					    DMI_EXACT_MATCH(DMI_BOARD_NAME, "Lindar"),
152 					    DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "sku524294"),
153 				},
154 			},
155 			{
156 				.callback = intel_dmi_no_pps_backlight,
157 				.ident = "Google Lillipup sku524295",
158 				.matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Google"),
159 					    DMI_EXACT_MATCH(DMI_BOARD_NAME, "Lindar"),
160 					    DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "sku524295"),
161 				},
162 			},
163 			{ }
164 		},
165 		.hook = quirk_no_pps_backlight_power_hook,
166 	},
167 };
168 
169 static struct intel_quirk intel_quirks[] = {
170 	/* Lenovo U160 cannot use SSC on LVDS */
171 	{ 0x0046, 0x17aa, 0x3920, quirk_ssc_force_disable },
172 
173 	/* Sony Vaio Y cannot use SSC on LVDS */
174 	{ 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable },
175 
176 	/* Acer Aspire 5734Z must invert backlight brightness */
177 	{ 0x2a42, 0x1025, 0x0459, quirk_invert_brightness },
178 
179 	/* Acer/eMachines G725 */
180 	{ 0x2a42, 0x1025, 0x0210, quirk_invert_brightness },
181 
182 	/* Acer/eMachines e725 */
183 	{ 0x2a42, 0x1025, 0x0212, quirk_invert_brightness },
184 
185 	/* Acer/Packard Bell NCL20 */
186 	{ 0x2a42, 0x1025, 0x034b, quirk_invert_brightness },
187 
188 	/* Acer Aspire 4736Z */
189 	{ 0x2a42, 0x1025, 0x0260, quirk_invert_brightness },
190 
191 	/* Acer Aspire 5336 */
192 	{ 0x2a42, 0x1025, 0x048a, quirk_invert_brightness },
193 
194 	/* Acer C720 and C720P Chromebooks (Celeron 2955U) have backlights */
195 	{ 0x0a06, 0x1025, 0x0a11, quirk_backlight_present },
196 
197 	/* Acer C720 Chromebook (Core i3 4005U) */
198 	{ 0x0a16, 0x1025, 0x0a11, quirk_backlight_present },
199 
200 	/* Apple Macbook 2,1 (Core 2 T7400) */
201 	{ 0x27a2, 0x8086, 0x7270, quirk_backlight_present },
202 
203 	/* Apple Macbook 4,1 */
204 	{ 0x2a02, 0x106b, 0x00a1, quirk_backlight_present },
205 
206 	/* Toshiba CB35 Chromebook (Celeron 2955U) */
207 	{ 0x0a06, 0x1179, 0x0a88, quirk_backlight_present },
208 
209 	/* HP Chromebook 14 (Celeron 2955U) */
210 	{ 0x0a06, 0x103c, 0x21ed, quirk_backlight_present },
211 
212 	/* Dell Chromebook 11 */
213 	{ 0x0a06, 0x1028, 0x0a35, quirk_backlight_present },
214 
215 	/* Dell Chromebook 11 (2015 version) */
216 	{ 0x0a16, 0x1028, 0x0a35, quirk_backlight_present },
217 
218 	/* Toshiba Satellite P50-C-18C */
219 	{ 0x191B, 0x1179, 0xF840, quirk_increase_t12_delay },
220 
221 	/* GeminiLake NUC */
222 	{ 0x3185, 0x8086, 0x2072, quirk_increase_ddi_disabled_time },
223 	{ 0x3184, 0x8086, 0x2072, quirk_increase_ddi_disabled_time },
224 	/* ASRock ITX*/
225 	{ 0x3185, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
226 	{ 0x3184, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
227 	/* ECS Liva Q2 */
228 	{ 0x3185, 0x1019, 0xa94d, quirk_increase_ddi_disabled_time },
229 	{ 0x3184, 0x1019, 0xa94d, quirk_increase_ddi_disabled_time },
230 	/* HP Notebook - 14-r206nv */
231 	{ 0x0f31, 0x103c, 0x220f, quirk_invert_brightness },
232 };
233 
234 static struct intel_dpcd_quirk intel_dpcd_quirks[] = {
235 	/* Dell Precision 5490 */
236 	{
237 		.device = 0x7d55,
238 		.subsystem_vendor = 0x1028,
239 		.subsystem_device = 0x0cc7,
240 		.sink_oui = SINK_OUI(0x38, 0xec, 0x11),
241 		.hook = quirk_fw_sync_len,
242 	},
243 
244 };
245 
intel_init_quirks(struct intel_display * display)246 void intel_init_quirks(struct intel_display *display)
247 {
248 	struct pci_dev *d = to_pci_dev(display->drm->dev);
249 	int i;
250 
251 	for (i = 0; i < ARRAY_SIZE(intel_quirks); i++) {
252 		struct intel_quirk *q = &intel_quirks[i];
253 
254 		if (d->device == q->device &&
255 		    (d->subsystem_vendor == q->subsystem_vendor ||
256 		     q->subsystem_vendor == PCI_ANY_ID) &&
257 		    (d->subsystem_device == q->subsystem_device ||
258 		     q->subsystem_device == PCI_ANY_ID))
259 			q->hook(display);
260 	}
261 	for (i = 0; i < ARRAY_SIZE(intel_dmi_quirks); i++) {
262 		if (dmi_check_system(*intel_dmi_quirks[i].dmi_id_list) != 0)
263 			intel_dmi_quirks[i].hook(display);
264 	}
265 }
266 
intel_init_dpcd_quirks(struct intel_dp * intel_dp,const struct drm_dp_dpcd_ident * ident)267 void intel_init_dpcd_quirks(struct intel_dp *intel_dp,
268 			    const struct drm_dp_dpcd_ident *ident)
269 {
270 	struct intel_display *display = to_intel_display(intel_dp);
271 	struct pci_dev *d = to_pci_dev(display->drm->dev);
272 	int i;
273 
274 	for (i = 0; i < ARRAY_SIZE(intel_dpcd_quirks); i++) {
275 		struct intel_dpcd_quirk *q = &intel_dpcd_quirks[i];
276 
277 		if (d->device == q->device &&
278 		    (d->subsystem_vendor == q->subsystem_vendor ||
279 		     q->subsystem_vendor == PCI_ANY_ID) &&
280 		    (d->subsystem_device == q->subsystem_device ||
281 		     q->subsystem_device == PCI_ANY_ID) &&
282 		    !memcmp(q->sink_oui, ident->oui, sizeof(ident->oui)) &&
283 		    (!memcmp(q->sink_device_id, ident->device_id,
284 			    sizeof(ident->device_id)) ||
285 		     mem_is_zero(q->sink_device_id, sizeof(q->sink_device_id))))
286 			q->hook(intel_dp);
287 	}
288 }
289 
intel_has_quirk(struct intel_display * display,enum intel_quirk_id quirk)290 bool intel_has_quirk(struct intel_display *display, enum intel_quirk_id quirk)
291 {
292 	return display->quirks.mask & BIT(quirk);
293 }
294 
intel_has_dpcd_quirk(struct intel_dp * intel_dp,enum intel_quirk_id quirk)295 bool intel_has_dpcd_quirk(struct intel_dp *intel_dp, enum intel_quirk_id quirk)
296 {
297 	return intel_dp->quirks.mask & BIT(quirk);
298 }
299