nouveau_connector.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. /*
  2. * Copyright (C) 2008 Maarten Maathuis.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial
  15. * portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #include <acpi/button.h>
  27. #include <linux/pm_runtime.h>
  28. #include <drm/drmP.h>
  29. #include <drm/drm_edid.h>
  30. #include <drm/drm_crtc_helper.h>
  31. #include "nouveau_reg.h"
  32. #include "nouveau_drm.h"
  33. #include "dispnv04/hw.h"
  34. #include "nouveau_acpi.h"
  35. #include "nouveau_display.h"
  36. #include "nouveau_connector.h"
  37. #include "nouveau_encoder.h"
  38. #include "nouveau_crtc.h"
  39. #include <subdev/i2c.h>
  40. #include <subdev/gpio.h>
  41. MODULE_PARM_DESC(tv_disable, "Disable TV-out detection");
  42. static int nouveau_tv_disable = 0;
  43. module_param_named(tv_disable, nouveau_tv_disable, int, 0400);
  44. MODULE_PARM_DESC(ignorelid, "Ignore ACPI lid status");
  45. static int nouveau_ignorelid = 0;
  46. module_param_named(ignorelid, nouveau_ignorelid, int, 0400);
  47. MODULE_PARM_DESC(duallink, "Allow dual-link TMDS (default: enabled)");
  48. static int nouveau_duallink = 1;
  49. module_param_named(duallink, nouveau_duallink, int, 0400);
  50. struct nouveau_encoder *
  51. find_encoder(struct drm_connector *connector, int type)
  52. {
  53. struct drm_device *dev = connector->dev;
  54. struct nouveau_encoder *nv_encoder;
  55. struct drm_mode_object *obj;
  56. int i, id;
  57. for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
  58. id = connector->encoder_ids[i];
  59. if (!id)
  60. break;
  61. obj = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
  62. if (!obj)
  63. continue;
  64. nv_encoder = nouveau_encoder(obj_to_encoder(obj));
  65. if (type == DCB_OUTPUT_ANY || nv_encoder->dcb->type == type)
  66. return nv_encoder;
  67. }
  68. return NULL;
  69. }
  70. struct nouveau_connector *
  71. nouveau_encoder_connector_get(struct nouveau_encoder *encoder)
  72. {
  73. struct drm_device *dev = to_drm_encoder(encoder)->dev;
  74. struct drm_connector *drm_connector;
  75. list_for_each_entry(drm_connector, &dev->mode_config.connector_list, head) {
  76. if (drm_connector->encoder == to_drm_encoder(encoder))
  77. return nouveau_connector(drm_connector);
  78. }
  79. return NULL;
  80. }
  81. static void
  82. nouveau_connector_destroy(struct drm_connector *connector)
  83. {
  84. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  85. nouveau_event_ref(NULL, &nv_connector->hpd_func);
  86. kfree(nv_connector->edid);
  87. drm_sysfs_connector_remove(connector);
  88. drm_connector_cleanup(connector);
  89. kfree(connector);
  90. }
  91. static struct nouveau_i2c_port *
  92. nouveau_connector_ddc_detect(struct drm_connector *connector,
  93. struct nouveau_encoder **pnv_encoder)
  94. {
  95. struct drm_device *dev = connector->dev;
  96. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  97. struct nouveau_drm *drm = nouveau_drm(dev);
  98. struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
  99. struct nouveau_i2c_port *port = NULL;
  100. int i, panel = -ENODEV;
  101. /* eDP panels need powering on by us (if the VBIOS doesn't default it
  102. * to on) before doing any AUX channel transactions. LVDS panel power
  103. * is handled by the SOR itself, and not required for LVDS DDC.
  104. */
  105. if (nv_connector->type == DCB_CONNECTOR_eDP) {
  106. panel = gpio->get(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff);
  107. if (panel == 0) {
  108. gpio->set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 1);
  109. msleep(300);
  110. }
  111. }
  112. for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
  113. struct nouveau_encoder *nv_encoder;
  114. struct drm_mode_object *obj;
  115. int id;
  116. id = connector->encoder_ids[i];
  117. if (!id)
  118. break;
  119. obj = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
  120. if (!obj)
  121. continue;
  122. nv_encoder = nouveau_encoder(obj_to_encoder(obj));
  123. port = nv_encoder->i2c;
  124. if (port && nv_probe_i2c(port, 0x50)) {
  125. *pnv_encoder = nv_encoder;
  126. break;
  127. }
  128. port = NULL;
  129. }
  130. /* eDP panel not detected, restore panel power GPIO to previous
  131. * state to avoid confusing the SOR for other output types.
  132. */
  133. if (!port && panel == 0)
  134. gpio->set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, panel);
  135. return port;
  136. }
  137. static struct nouveau_encoder *
  138. nouveau_connector_of_detect(struct drm_connector *connector)
  139. {
  140. #ifdef __powerpc__
  141. struct drm_device *dev = connector->dev;
  142. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  143. struct nouveau_encoder *nv_encoder;
  144. struct device_node *cn, *dn = pci_device_to_OF_node(dev->pdev);
  145. if (!dn ||
  146. !((nv_encoder = find_encoder(connector, DCB_OUTPUT_TMDS)) ||
  147. (nv_encoder = find_encoder(connector, DCB_OUTPUT_ANALOG))))
  148. return NULL;
  149. for_each_child_of_node(dn, cn) {
  150. const char *name = of_get_property(cn, "name", NULL);
  151. const void *edid = of_get_property(cn, "EDID", NULL);
  152. int idx = name ? name[strlen(name) - 1] - 'A' : 0;
  153. if (nv_encoder->dcb->i2c_index == idx && edid) {
  154. nv_connector->edid =
  155. kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
  156. of_node_put(cn);
  157. return nv_encoder;
  158. }
  159. }
  160. #endif
  161. return NULL;
  162. }
  163. static void
  164. nouveau_connector_set_encoder(struct drm_connector *connector,
  165. struct nouveau_encoder *nv_encoder)
  166. {
  167. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  168. struct nouveau_drm *drm = nouveau_drm(connector->dev);
  169. struct drm_device *dev = connector->dev;
  170. if (nv_connector->detected_encoder == nv_encoder)
  171. return;
  172. nv_connector->detected_encoder = nv_encoder;
  173. if (nv_device(drm->device)->card_type >= NV_50) {
  174. connector->interlace_allowed = true;
  175. connector->doublescan_allowed = true;
  176. } else
  177. if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS ||
  178. nv_encoder->dcb->type == DCB_OUTPUT_TMDS) {
  179. connector->doublescan_allowed = false;
  180. connector->interlace_allowed = false;
  181. } else {
  182. connector->doublescan_allowed = true;
  183. if (nv_device(drm->device)->card_type == NV_20 ||
  184. ((nv_device(drm->device)->card_type == NV_10 ||
  185. nv_device(drm->device)->card_type == NV_11) &&
  186. (dev->pdev->device & 0x0ff0) != 0x0100 &&
  187. (dev->pdev->device & 0x0ff0) != 0x0150))
  188. /* HW is broken */
  189. connector->interlace_allowed = false;
  190. else
  191. connector->interlace_allowed = true;
  192. }
  193. if (nv_connector->type == DCB_CONNECTOR_DVI_I) {
  194. drm_object_property_set_value(&connector->base,
  195. dev->mode_config.dvi_i_subconnector_property,
  196. nv_encoder->dcb->type == DCB_OUTPUT_TMDS ?
  197. DRM_MODE_SUBCONNECTOR_DVID :
  198. DRM_MODE_SUBCONNECTOR_DVIA);
  199. }
  200. }
  201. static enum drm_connector_status
  202. nouveau_connector_detect(struct drm_connector *connector, bool force)
  203. {
  204. struct drm_device *dev = connector->dev;
  205. struct nouveau_drm *drm = nouveau_drm(dev);
  206. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  207. struct nouveau_encoder *nv_encoder = NULL;
  208. struct nouveau_encoder *nv_partner;
  209. struct nouveau_i2c_port *i2c;
  210. int type;
  211. int ret;
  212. enum drm_connector_status conn_status = connector_status_disconnected;
  213. /* Cleanup the previous EDID block. */
  214. if (nv_connector->edid) {
  215. drm_mode_connector_update_edid_property(connector, NULL);
  216. kfree(nv_connector->edid);
  217. nv_connector->edid = NULL;
  218. }
  219. ret = pm_runtime_get_sync(connector->dev->dev);
  220. if (ret < 0)
  221. return conn_status;
  222. i2c = nouveau_connector_ddc_detect(connector, &nv_encoder);
  223. if (i2c) {
  224. nv_connector->edid = drm_get_edid(connector, &i2c->adapter);
  225. drm_mode_connector_update_edid_property(connector,
  226. nv_connector->edid);
  227. if (!nv_connector->edid) {
  228. NV_ERROR(drm, "DDC responded, but no EDID for %s\n",
  229. drm_get_connector_name(connector));
  230. goto detect_analog;
  231. }
  232. if (nv_encoder->dcb->type == DCB_OUTPUT_DP &&
  233. !nouveau_dp_detect(to_drm_encoder(nv_encoder))) {
  234. NV_ERROR(drm, "Detected %s, but failed init\n",
  235. drm_get_connector_name(connector));
  236. conn_status = connector_status_disconnected;
  237. goto out;
  238. }
  239. /* Override encoder type for DVI-I based on whether EDID
  240. * says the display is digital or analog, both use the
  241. * same i2c channel so the value returned from ddc_detect
  242. * isn't necessarily correct.
  243. */
  244. nv_partner = NULL;
  245. if (nv_encoder->dcb->type == DCB_OUTPUT_TMDS)
  246. nv_partner = find_encoder(connector, DCB_OUTPUT_ANALOG);
  247. if (nv_encoder->dcb->type == DCB_OUTPUT_ANALOG)
  248. nv_partner = find_encoder(connector, DCB_OUTPUT_TMDS);
  249. if (nv_partner && ((nv_encoder->dcb->type == DCB_OUTPUT_ANALOG &&
  250. nv_partner->dcb->type == DCB_OUTPUT_TMDS) ||
  251. (nv_encoder->dcb->type == DCB_OUTPUT_TMDS &&
  252. nv_partner->dcb->type == DCB_OUTPUT_ANALOG))) {
  253. if (nv_connector->edid->input & DRM_EDID_INPUT_DIGITAL)
  254. type = DCB_OUTPUT_TMDS;
  255. else
  256. type = DCB_OUTPUT_ANALOG;
  257. nv_encoder = find_encoder(connector, type);
  258. }
  259. nouveau_connector_set_encoder(connector, nv_encoder);
  260. conn_status = connector_status_connected;
  261. goto out;
  262. }
  263. nv_encoder = nouveau_connector_of_detect(connector);
  264. if (nv_encoder) {
  265. nouveau_connector_set_encoder(connector, nv_encoder);
  266. conn_status = connector_status_connected;
  267. goto out;
  268. }
  269. detect_analog:
  270. nv_encoder = find_encoder(connector, DCB_OUTPUT_ANALOG);
  271. if (!nv_encoder && !nouveau_tv_disable)
  272. nv_encoder = find_encoder(connector, DCB_OUTPUT_TV);
  273. if (nv_encoder && force) {
  274. struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
  275. struct drm_encoder_helper_funcs *helper =
  276. encoder->helper_private;
  277. if (helper->detect(encoder, connector) ==
  278. connector_status_connected) {
  279. nouveau_connector_set_encoder(connector, nv_encoder);
  280. conn_status = connector_status_connected;
  281. goto out;
  282. }
  283. }
  284. out:
  285. pm_runtime_mark_last_busy(connector->dev->dev);
  286. pm_runtime_put_autosuspend(connector->dev->dev);
  287. return conn_status;
  288. }
  289. static enum drm_connector_status
  290. nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
  291. {
  292. struct drm_device *dev = connector->dev;
  293. struct nouveau_drm *drm = nouveau_drm(dev);
  294. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  295. struct nouveau_encoder *nv_encoder = NULL;
  296. enum drm_connector_status status = connector_status_disconnected;
  297. /* Cleanup the previous EDID block. */
  298. if (nv_connector->edid) {
  299. drm_mode_connector_update_edid_property(connector, NULL);
  300. kfree(nv_connector->edid);
  301. nv_connector->edid = NULL;
  302. }
  303. nv_encoder = find_encoder(connector, DCB_OUTPUT_LVDS);
  304. if (!nv_encoder)
  305. return connector_status_disconnected;
  306. /* Try retrieving EDID via DDC */
  307. if (!drm->vbios.fp_no_ddc) {
  308. status = nouveau_connector_detect(connector, force);
  309. if (status == connector_status_connected)
  310. goto out;
  311. }
  312. /* On some laptops (Sony, i'm looking at you) there appears to
  313. * be no direct way of accessing the panel's EDID. The only
  314. * option available to us appears to be to ask ACPI for help..
  315. *
  316. * It's important this check's before trying straps, one of the
  317. * said manufacturer's laptops are configured in such a way
  318. * the nouveau decides an entry in the VBIOS FP mode table is
  319. * valid - it's not (rh#613284)
  320. */
  321. if (nv_encoder->dcb->lvdsconf.use_acpi_for_edid) {
  322. if ((nv_connector->edid = nouveau_acpi_edid(dev, connector))) {
  323. status = connector_status_connected;
  324. goto out;
  325. }
  326. }
  327. /* If no EDID found above, and the VBIOS indicates a hardcoded
  328. * modeline is avalilable for the panel, set it as the panel's
  329. * native mode and exit.
  330. */
  331. if (nouveau_bios_fp_mode(dev, NULL) && (drm->vbios.fp_no_ddc ||
  332. nv_encoder->dcb->lvdsconf.use_straps_for_mode)) {
  333. status = connector_status_connected;
  334. goto out;
  335. }
  336. /* Still nothing, some VBIOS images have a hardcoded EDID block
  337. * stored for the panel stored in them.
  338. */
  339. if (!drm->vbios.fp_no_ddc) {
  340. struct edid *edid =
  341. (struct edid *)nouveau_bios_embedded_edid(dev);
  342. if (edid) {
  343. nv_connector->edid =
  344. kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
  345. if (nv_connector->edid)
  346. status = connector_status_connected;
  347. }
  348. }
  349. out:
  350. #if defined(CONFIG_ACPI_BUTTON) || \
  351. (defined(CONFIG_ACPI_BUTTON_MODULE) && defined(MODULE))
  352. if (status == connector_status_connected &&
  353. !nouveau_ignorelid && !acpi_lid_open())
  354. status = connector_status_unknown;
  355. #endif
  356. drm_mode_connector_update_edid_property(connector, nv_connector->edid);
  357. nouveau_connector_set_encoder(connector, nv_encoder);
  358. return status;
  359. }
  360. static void
  361. nouveau_connector_force(struct drm_connector *connector)
  362. {
  363. struct nouveau_drm *drm = nouveau_drm(connector->dev);
  364. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  365. struct nouveau_encoder *nv_encoder;
  366. int type;
  367. if (nv_connector->type == DCB_CONNECTOR_DVI_I) {
  368. if (connector->force == DRM_FORCE_ON_DIGITAL)
  369. type = DCB_OUTPUT_TMDS;
  370. else
  371. type = DCB_OUTPUT_ANALOG;
  372. } else
  373. type = DCB_OUTPUT_ANY;
  374. nv_encoder = find_encoder(connector, type);
  375. if (!nv_encoder) {
  376. NV_ERROR(drm, "can't find encoder to force %s on!\n",
  377. drm_get_connector_name(connector));
  378. connector->status = connector_status_disconnected;
  379. return;
  380. }
  381. nouveau_connector_set_encoder(connector, nv_encoder);
  382. }
  383. static int
  384. nouveau_connector_set_property(struct drm_connector *connector,
  385. struct drm_property *property, uint64_t value)
  386. {
  387. struct nouveau_display *disp = nouveau_display(connector->dev);
  388. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  389. struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
  390. struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
  391. struct drm_device *dev = connector->dev;
  392. struct nouveau_crtc *nv_crtc;
  393. int ret;
  394. nv_crtc = NULL;
  395. if (connector->encoder && connector->encoder->crtc)
  396. nv_crtc = nouveau_crtc(connector->encoder->crtc);
  397. /* Scaling mode */
  398. if (property == dev->mode_config.scaling_mode_property) {
  399. bool modeset = false;
  400. switch (value) {
  401. case DRM_MODE_SCALE_NONE:
  402. case DRM_MODE_SCALE_FULLSCREEN:
  403. case DRM_MODE_SCALE_CENTER:
  404. case DRM_MODE_SCALE_ASPECT:
  405. break;
  406. default:
  407. return -EINVAL;
  408. }
  409. /* LVDS always needs gpu scaling */
  410. if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS &&
  411. value == DRM_MODE_SCALE_NONE)
  412. return -EINVAL;
  413. /* Changing between GPU and panel scaling requires a full
  414. * modeset
  415. */
  416. if ((nv_connector->scaling_mode == DRM_MODE_SCALE_NONE) ||
  417. (value == DRM_MODE_SCALE_NONE))
  418. modeset = true;
  419. nv_connector->scaling_mode = value;
  420. if (!nv_crtc)
  421. return 0;
  422. if (modeset || !nv_crtc->set_scale) {
  423. ret = drm_crtc_helper_set_mode(&nv_crtc->base,
  424. &nv_crtc->base.mode,
  425. nv_crtc->base.x,
  426. nv_crtc->base.y, NULL);
  427. if (!ret)
  428. return -EINVAL;
  429. } else {
  430. ret = nv_crtc->set_scale(nv_crtc, true);
  431. if (ret)
  432. return ret;
  433. }
  434. return 0;
  435. }
  436. /* Underscan */
  437. if (property == disp->underscan_property) {
  438. if (nv_connector->underscan != value) {
  439. nv_connector->underscan = value;
  440. if (!nv_crtc || !nv_crtc->set_scale)
  441. return 0;
  442. return nv_crtc->set_scale(nv_crtc, true);
  443. }
  444. return 0;
  445. }
  446. if (property == disp->underscan_hborder_property) {
  447. if (nv_connector->underscan_hborder != value) {
  448. nv_connector->underscan_hborder = value;
  449. if (!nv_crtc || !nv_crtc->set_scale)
  450. return 0;
  451. return nv_crtc->set_scale(nv_crtc, true);
  452. }
  453. return 0;
  454. }
  455. if (property == disp->underscan_vborder_property) {
  456. if (nv_connector->underscan_vborder != value) {
  457. nv_connector->underscan_vborder = value;
  458. if (!nv_crtc || !nv_crtc->set_scale)
  459. return 0;
  460. return nv_crtc->set_scale(nv_crtc, true);
  461. }
  462. return 0;
  463. }
  464. /* Dithering */
  465. if (property == disp->dithering_mode) {
  466. nv_connector->dithering_mode = value;
  467. if (!nv_crtc || !nv_crtc->set_dither)
  468. return 0;
  469. return nv_crtc->set_dither(nv_crtc, true);
  470. }
  471. if (property == disp->dithering_depth) {
  472. nv_connector->dithering_depth = value;
  473. if (!nv_crtc || !nv_crtc->set_dither)
  474. return 0;
  475. return nv_crtc->set_dither(nv_crtc, true);
  476. }
  477. if (nv_crtc && nv_crtc->set_color_vibrance) {
  478. /* Hue */
  479. if (property == disp->vibrant_hue_property) {
  480. nv_crtc->vibrant_hue = value - 90;
  481. return nv_crtc->set_color_vibrance(nv_crtc, true);
  482. }
  483. /* Saturation */
  484. if (property == disp->color_vibrance_property) {
  485. nv_crtc->color_vibrance = value - 100;
  486. return nv_crtc->set_color_vibrance(nv_crtc, true);
  487. }
  488. }
  489. if (nv_encoder && nv_encoder->dcb->type == DCB_OUTPUT_TV)
  490. return get_slave_funcs(encoder)->set_property(
  491. encoder, connector, property, value);
  492. return -EINVAL;
  493. }
  494. static struct drm_display_mode *
  495. nouveau_connector_native_mode(struct drm_connector *connector)
  496. {
  497. struct drm_connector_helper_funcs *helper = connector->helper_private;
  498. struct nouveau_drm *drm = nouveau_drm(connector->dev);
  499. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  500. struct drm_device *dev = connector->dev;
  501. struct drm_display_mode *mode, *largest = NULL;
  502. int high_w = 0, high_h = 0, high_v = 0;
  503. list_for_each_entry(mode, &nv_connector->base.probed_modes, head) {
  504. mode->vrefresh = drm_mode_vrefresh(mode);
  505. if (helper->mode_valid(connector, mode) != MODE_OK ||
  506. (mode->flags & DRM_MODE_FLAG_INTERLACE))
  507. continue;
  508. /* Use preferred mode if there is one.. */
  509. if (mode->type & DRM_MODE_TYPE_PREFERRED) {
  510. NV_DEBUG(drm, "native mode from preferred\n");
  511. return drm_mode_duplicate(dev, mode);
  512. }
  513. /* Otherwise, take the resolution with the largest width, then
  514. * height, then vertical refresh
  515. */
  516. if (mode->hdisplay < high_w)
  517. continue;
  518. if (mode->hdisplay == high_w && mode->vdisplay < high_h)
  519. continue;
  520. if (mode->hdisplay == high_w && mode->vdisplay == high_h &&
  521. mode->vrefresh < high_v)
  522. continue;
  523. high_w = mode->hdisplay;
  524. high_h = mode->vdisplay;
  525. high_v = mode->vrefresh;
  526. largest = mode;
  527. }
  528. NV_DEBUG(drm, "native mode from largest: %dx%d@%d\n",
  529. high_w, high_h, high_v);
  530. return largest ? drm_mode_duplicate(dev, largest) : NULL;
  531. }
  532. struct moderec {
  533. int hdisplay;
  534. int vdisplay;
  535. };
  536. static struct moderec scaler_modes[] = {
  537. { 1920, 1200 },
  538. { 1920, 1080 },
  539. { 1680, 1050 },
  540. { 1600, 1200 },
  541. { 1400, 1050 },
  542. { 1280, 1024 },
  543. { 1280, 960 },
  544. { 1152, 864 },
  545. { 1024, 768 },
  546. { 800, 600 },
  547. { 720, 400 },
  548. { 640, 480 },
  549. { 640, 400 },
  550. { 640, 350 },
  551. {}
  552. };
  553. static int
  554. nouveau_connector_scaler_modes_add(struct drm_connector *connector)
  555. {
  556. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  557. struct drm_display_mode *native = nv_connector->native_mode, *m;
  558. struct drm_device *dev = connector->dev;
  559. struct moderec *mode = &scaler_modes[0];
  560. int modes = 0;
  561. if (!native)
  562. return 0;
  563. while (mode->hdisplay) {
  564. if (mode->hdisplay <= native->hdisplay &&
  565. mode->vdisplay <= native->vdisplay) {
  566. m = drm_cvt_mode(dev, mode->hdisplay, mode->vdisplay,
  567. drm_mode_vrefresh(native), false,
  568. false, false);
  569. if (!m)
  570. continue;
  571. m->type |= DRM_MODE_TYPE_DRIVER;
  572. drm_mode_probed_add(connector, m);
  573. modes++;
  574. }
  575. mode++;
  576. }
  577. return modes;
  578. }
  579. static void
  580. nouveau_connector_detect_depth(struct drm_connector *connector)
  581. {
  582. struct nouveau_drm *drm = nouveau_drm(connector->dev);
  583. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  584. struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
  585. struct nvbios *bios = &drm->vbios;
  586. struct drm_display_mode *mode = nv_connector->native_mode;
  587. bool duallink;
  588. /* if the edid is feeling nice enough to provide this info, use it */
  589. if (nv_connector->edid && connector->display_info.bpc)
  590. return;
  591. /* EDID 1.4 is *supposed* to be supported on eDP, but, Apple... */
  592. if (nv_connector->type == DCB_CONNECTOR_eDP) {
  593. connector->display_info.bpc = 6;
  594. return;
  595. }
  596. /* we're out of options unless we're LVDS, default to 8bpc */
  597. if (nv_encoder->dcb->type != DCB_OUTPUT_LVDS) {
  598. connector->display_info.bpc = 8;
  599. return;
  600. }
  601. connector->display_info.bpc = 6;
  602. /* LVDS: panel straps */
  603. if (bios->fp_no_ddc) {
  604. if (bios->fp.if_is_24bit)
  605. connector->display_info.bpc = 8;
  606. return;
  607. }
  608. /* LVDS: DDC panel, need to first determine the number of links to
  609. * know which if_is_24bit flag to check...
  610. */
  611. if (nv_connector->edid &&
  612. nv_connector->type == DCB_CONNECTOR_LVDS_SPWG)
  613. duallink = ((u8 *)nv_connector->edid)[121] == 2;
  614. else
  615. duallink = mode->clock >= bios->fp.duallink_transition_clk;
  616. if ((!duallink && (bios->fp.strapless_is_24bit & 1)) ||
  617. ( duallink && (bios->fp.strapless_is_24bit & 2)))
  618. connector->display_info.bpc = 8;
  619. }
  620. static int
  621. nouveau_connector_get_modes(struct drm_connector *connector)
  622. {
  623. struct drm_device *dev = connector->dev;
  624. struct nouveau_drm *drm = nouveau_drm(dev);
  625. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  626. struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
  627. struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
  628. int ret = 0;
  629. /* destroy the native mode, the attached monitor could have changed.
  630. */
  631. if (nv_connector->native_mode) {
  632. drm_mode_destroy(dev, nv_connector->native_mode);
  633. nv_connector->native_mode = NULL;
  634. }
  635. if (nv_connector->edid)
  636. ret = drm_add_edid_modes(connector, nv_connector->edid);
  637. else
  638. if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS &&
  639. (nv_encoder->dcb->lvdsconf.use_straps_for_mode ||
  640. drm->vbios.fp_no_ddc) && nouveau_bios_fp_mode(dev, NULL)) {
  641. struct drm_display_mode mode;
  642. nouveau_bios_fp_mode(dev, &mode);
  643. nv_connector->native_mode = drm_mode_duplicate(dev, &mode);
  644. }
  645. /* Determine display colour depth for everything except LVDS now,
  646. * DP requires this before mode_valid() is called.
  647. */
  648. if (connector->connector_type != DRM_MODE_CONNECTOR_LVDS)
  649. nouveau_connector_detect_depth(connector);
  650. /* Find the native mode if this is a digital panel, if we didn't
  651. * find any modes through DDC previously add the native mode to
  652. * the list of modes.
  653. */
  654. if (!nv_connector->native_mode)
  655. nv_connector->native_mode =
  656. nouveau_connector_native_mode(connector);
  657. if (ret == 0 && nv_connector->native_mode) {
  658. struct drm_display_mode *mode;
  659. mode = drm_mode_duplicate(dev, nv_connector->native_mode);
  660. drm_mode_probed_add(connector, mode);
  661. ret = 1;
  662. }
  663. /* Determine LVDS colour depth, must happen after determining
  664. * "native" mode as some VBIOS tables require us to use the
  665. * pixel clock as part of the lookup...
  666. */
  667. if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)
  668. nouveau_connector_detect_depth(connector);
  669. if (nv_encoder->dcb->type == DCB_OUTPUT_TV)
  670. ret = get_slave_funcs(encoder)->get_modes(encoder, connector);
  671. if (nv_connector->type == DCB_CONNECTOR_LVDS ||
  672. nv_connector->type == DCB_CONNECTOR_LVDS_SPWG ||
  673. nv_connector->type == DCB_CONNECTOR_eDP)
  674. ret += nouveau_connector_scaler_modes_add(connector);
  675. return ret;
  676. }
  677. static unsigned
  678. get_tmds_link_bandwidth(struct drm_connector *connector)
  679. {
  680. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  681. struct nouveau_drm *drm = nouveau_drm(connector->dev);
  682. struct dcb_output *dcb = nv_connector->detected_encoder->dcb;
  683. if (dcb->location != DCB_LOC_ON_CHIP ||
  684. nv_device(drm->device)->chipset >= 0x46)
  685. return 165000;
  686. else if (nv_device(drm->device)->chipset >= 0x40)
  687. return 155000;
  688. else if (nv_device(drm->device)->chipset >= 0x18)
  689. return 135000;
  690. else
  691. return 112000;
  692. }
  693. static int
  694. nouveau_connector_mode_valid(struct drm_connector *connector,
  695. struct drm_display_mode *mode)
  696. {
  697. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  698. struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
  699. struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
  700. unsigned min_clock = 25000, max_clock = min_clock;
  701. unsigned clock = mode->clock;
  702. switch (nv_encoder->dcb->type) {
  703. case DCB_OUTPUT_LVDS:
  704. if (nv_connector->native_mode &&
  705. (mode->hdisplay > nv_connector->native_mode->hdisplay ||
  706. mode->vdisplay > nv_connector->native_mode->vdisplay))
  707. return MODE_PANEL;
  708. min_clock = 0;
  709. max_clock = 400000;
  710. break;
  711. case DCB_OUTPUT_TMDS:
  712. max_clock = get_tmds_link_bandwidth(connector);
  713. if (nouveau_duallink && nv_encoder->dcb->duallink_possible)
  714. max_clock *= 2;
  715. break;
  716. case DCB_OUTPUT_ANALOG:
  717. max_clock = nv_encoder->dcb->crtconf.maxfreq;
  718. if (!max_clock)
  719. max_clock = 350000;
  720. break;
  721. case DCB_OUTPUT_TV:
  722. return get_slave_funcs(encoder)->mode_valid(encoder, mode);
  723. case DCB_OUTPUT_DP:
  724. max_clock = nv_encoder->dp.link_nr;
  725. max_clock *= nv_encoder->dp.link_bw;
  726. clock = clock * (connector->display_info.bpc * 3) / 10;
  727. break;
  728. default:
  729. BUG_ON(1);
  730. return MODE_BAD;
  731. }
  732. if (clock < min_clock)
  733. return MODE_CLOCK_LOW;
  734. if (clock > max_clock)
  735. return MODE_CLOCK_HIGH;
  736. return MODE_OK;
  737. }
  738. static struct drm_encoder *
  739. nouveau_connector_best_encoder(struct drm_connector *connector)
  740. {
  741. struct nouveau_connector *nv_connector = nouveau_connector(connector);
  742. if (nv_connector->detected_encoder)
  743. return to_drm_encoder(nv_connector->detected_encoder);
  744. return NULL;
  745. }
  746. static const struct drm_connector_helper_funcs
  747. nouveau_connector_helper_funcs = {
  748. .get_modes = nouveau_connector_get_modes,
  749. .mode_valid = nouveau_connector_mode_valid,
  750. .best_encoder = nouveau_connector_best_encoder,
  751. };
  752. static const struct drm_connector_funcs
  753. nouveau_connector_funcs = {
  754. .dpms = drm_helper_connector_dpms,
  755. .save = NULL,
  756. .restore = NULL,
  757. .detect = nouveau_connector_detect,
  758. .destroy = nouveau_connector_destroy,
  759. .fill_modes = drm_helper_probe_single_connector_modes,
  760. .set_property = nouveau_connector_set_property,
  761. .force = nouveau_connector_force
  762. };
  763. static const struct drm_connector_funcs
  764. nouveau_connector_funcs_lvds = {
  765. .dpms = drm_helper_connector_dpms,
  766. .save = NULL,
  767. .restore = NULL,
  768. .detect = nouveau_connector_detect_lvds,
  769. .destroy = nouveau_connector_destroy,
  770. .fill_modes = drm_helper_probe_single_connector_modes,
  771. .set_property = nouveau_connector_set_property,
  772. .force = nouveau_connector_force
  773. };
  774. static void
  775. nouveau_connector_hotplug_work(struct work_struct *work)
  776. {
  777. struct nouveau_connector *nv_connector =
  778. container_of(work, struct nouveau_connector, hpd_work);
  779. struct drm_connector *connector = &nv_connector->base;
  780. struct drm_device *dev = connector->dev;
  781. struct nouveau_drm *drm = nouveau_drm(dev);
  782. struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
  783. bool plugged = gpio->get(gpio, 0, nv_connector->hpd.func, 0xff);
  784. NV_DEBUG(drm, "%splugged %s\n", plugged ? "" : "un",
  785. drm_get_connector_name(connector));
  786. if (plugged)
  787. drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
  788. else
  789. drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
  790. drm_helper_hpd_irq_event(dev);
  791. }
  792. static int
  793. nouveau_connector_hotplug(void *data, int index)
  794. {
  795. struct nouveau_connector *nv_connector = data;
  796. schedule_work(&nv_connector->hpd_work);
  797. return NVKM_EVENT_KEEP;
  798. }
  799. static int
  800. drm_conntype_from_dcb(enum dcb_connector_type dcb)
  801. {
  802. switch (dcb) {
  803. case DCB_CONNECTOR_VGA : return DRM_MODE_CONNECTOR_VGA;
  804. case DCB_CONNECTOR_TV_0 :
  805. case DCB_CONNECTOR_TV_1 :
  806. case DCB_CONNECTOR_TV_3 : return DRM_MODE_CONNECTOR_TV;
  807. case DCB_CONNECTOR_DMS59_0 :
  808. case DCB_CONNECTOR_DMS59_1 :
  809. case DCB_CONNECTOR_DVI_I : return DRM_MODE_CONNECTOR_DVII;
  810. case DCB_CONNECTOR_DVI_D : return DRM_MODE_CONNECTOR_DVID;
  811. case DCB_CONNECTOR_LVDS :
  812. case DCB_CONNECTOR_LVDS_SPWG: return DRM_MODE_CONNECTOR_LVDS;
  813. case DCB_CONNECTOR_DMS59_DP0:
  814. case DCB_CONNECTOR_DMS59_DP1:
  815. case DCB_CONNECTOR_DP : return DRM_MODE_CONNECTOR_DisplayPort;
  816. case DCB_CONNECTOR_eDP : return DRM_MODE_CONNECTOR_eDP;
  817. case DCB_CONNECTOR_HDMI_0 :
  818. case DCB_CONNECTOR_HDMI_1 : return DRM_MODE_CONNECTOR_HDMIA;
  819. default:
  820. break;
  821. }
  822. return DRM_MODE_CONNECTOR_Unknown;
  823. }
  824. struct drm_connector *
  825. nouveau_connector_create(struct drm_device *dev, int index)
  826. {
  827. const struct drm_connector_funcs *funcs = &nouveau_connector_funcs;
  828. struct nouveau_drm *drm = nouveau_drm(dev);
  829. struct nouveau_gpio *gpio = nouveau_gpio(drm->device);
  830. struct nouveau_display *disp = nouveau_display(dev);
  831. struct nouveau_connector *nv_connector = NULL;
  832. struct drm_connector *connector;
  833. int type, ret = 0;
  834. bool dummy;
  835. list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
  836. nv_connector = nouveau_connector(connector);
  837. if (nv_connector->index == index)
  838. return connector;
  839. }
  840. nv_connector = kzalloc(sizeof(*nv_connector), GFP_KERNEL);
  841. if (!nv_connector)
  842. return ERR_PTR(-ENOMEM);
  843. connector = &nv_connector->base;
  844. INIT_WORK(&nv_connector->hpd_work, nouveau_connector_hotplug_work);
  845. nv_connector->index = index;
  846. /* attempt to parse vbios connector type and hotplug gpio */
  847. nv_connector->dcb = olddcb_conn(dev, index);
  848. if (nv_connector->dcb) {
  849. static const u8 hpd[16] = {
  850. 0xff, 0x07, 0x08, 0xff, 0xff, 0x51, 0x52, 0xff,
  851. 0xff, 0xff, 0xff, 0xff, 0xff, 0x5e, 0x5f, 0x60,
  852. };
  853. u32 entry = ROM16(nv_connector->dcb[0]);
  854. if (olddcb_conntab(dev)[3] >= 4)
  855. entry |= (u32)ROM16(nv_connector->dcb[2]) << 16;
  856. ret = gpio->find(gpio, 0, hpd[ffs((entry & 0x07033000) >> 12)],
  857. DCB_GPIO_UNUSED, &nv_connector->hpd);
  858. if (ret)
  859. nv_connector->hpd.func = DCB_GPIO_UNUSED;
  860. if (nv_connector->hpd.func != DCB_GPIO_UNUSED) {
  861. nouveau_event_new(gpio->events, nv_connector->hpd.line,
  862. nouveau_connector_hotplug,
  863. nv_connector,
  864. &nv_connector->hpd_func);
  865. }
  866. nv_connector->type = nv_connector->dcb[0];
  867. if (drm_conntype_from_dcb(nv_connector->type) ==
  868. DRM_MODE_CONNECTOR_Unknown) {
  869. NV_WARN(drm, "unknown connector type %02x\n",
  870. nv_connector->type);
  871. nv_connector->type = DCB_CONNECTOR_NONE;
  872. }
  873. /* Gigabyte NX85T */
  874. if (nv_match_device(dev, 0x0421, 0x1458, 0x344c)) {
  875. if (nv_connector->type == DCB_CONNECTOR_HDMI_1)
  876. nv_connector->type = DCB_CONNECTOR_DVI_I;
  877. }
  878. /* Gigabyte GV-NX86T512H */
  879. if (nv_match_device(dev, 0x0402, 0x1458, 0x3455)) {
  880. if (nv_connector->type == DCB_CONNECTOR_HDMI_1)
  881. nv_connector->type = DCB_CONNECTOR_DVI_I;
  882. }
  883. } else {
  884. nv_connector->type = DCB_CONNECTOR_NONE;
  885. nv_connector->hpd.func = DCB_GPIO_UNUSED;
  886. }
  887. /* no vbios data, or an unknown dcb connector type - attempt to
  888. * figure out something suitable ourselves
  889. */
  890. if (nv_connector->type == DCB_CONNECTOR_NONE) {
  891. struct nouveau_drm *drm = nouveau_drm(dev);
  892. struct dcb_table *dcbt = &drm->vbios.dcb;
  893. u32 encoders = 0;
  894. int i;
  895. for (i = 0; i < dcbt->entries; i++) {
  896. if (dcbt->entry[i].connector == nv_connector->index)
  897. encoders |= (1 << dcbt->entry[i].type);
  898. }
  899. if (encoders & (1 << DCB_OUTPUT_DP)) {
  900. if (encoders & (1 << DCB_OUTPUT_TMDS))
  901. nv_connector->type = DCB_CONNECTOR_DP;
  902. else
  903. nv_connector->type = DCB_CONNECTOR_eDP;
  904. } else
  905. if (encoders & (1 << DCB_OUTPUT_TMDS)) {
  906. if (encoders & (1 << DCB_OUTPUT_ANALOG))
  907. nv_connector->type = DCB_CONNECTOR_DVI_I;
  908. else
  909. nv_connector->type = DCB_CONNECTOR_DVI_D;
  910. } else
  911. if (encoders & (1 << DCB_OUTPUT_ANALOG)) {
  912. nv_connector->type = DCB_CONNECTOR_VGA;
  913. } else
  914. if (encoders & (1 << DCB_OUTPUT_LVDS)) {
  915. nv_connector->type = DCB_CONNECTOR_LVDS;
  916. } else
  917. if (encoders & (1 << DCB_OUTPUT_TV)) {
  918. nv_connector->type = DCB_CONNECTOR_TV_0;
  919. }
  920. }
  921. type = drm_conntype_from_dcb(nv_connector->type);
  922. if (type == DRM_MODE_CONNECTOR_LVDS) {
  923. ret = nouveau_bios_parse_lvds_table(dev, 0, &dummy, &dummy);
  924. if (ret) {
  925. NV_ERROR(drm, "Error parsing LVDS table, disabling\n");
  926. kfree(nv_connector);
  927. return ERR_PTR(ret);
  928. }
  929. funcs = &nouveau_connector_funcs_lvds;
  930. } else {
  931. funcs = &nouveau_connector_funcs;
  932. }
  933. /* defaults, will get overridden in detect() */
  934. connector->interlace_allowed = false;
  935. connector->doublescan_allowed = false;
  936. drm_connector_init(dev, connector, funcs, type);
  937. drm_connector_helper_add(connector, &nouveau_connector_helper_funcs);
  938. /* Init DVI-I specific properties */
  939. if (nv_connector->type == DCB_CONNECTOR_DVI_I)
  940. drm_object_attach_property(&connector->base, dev->mode_config.dvi_i_subconnector_property, 0);
  941. /* Add overscan compensation options to digital outputs */
  942. if (disp->underscan_property &&
  943. (type == DRM_MODE_CONNECTOR_DVID ||
  944. type == DRM_MODE_CONNECTOR_DVII ||
  945. type == DRM_MODE_CONNECTOR_HDMIA ||
  946. type == DRM_MODE_CONNECTOR_DisplayPort)) {
  947. drm_object_attach_property(&connector->base,
  948. disp->underscan_property,
  949. UNDERSCAN_OFF);
  950. drm_object_attach_property(&connector->base,
  951. disp->underscan_hborder_property,
  952. 0);
  953. drm_object_attach_property(&connector->base,
  954. disp->underscan_vborder_property,
  955. 0);
  956. }
  957. /* Add hue and saturation options */
  958. if (disp->vibrant_hue_property)
  959. drm_object_attach_property(&connector->base,
  960. disp->vibrant_hue_property,
  961. 90);
  962. if (disp->color_vibrance_property)
  963. drm_object_attach_property(&connector->base,
  964. disp->color_vibrance_property,
  965. 150);
  966. switch (nv_connector->type) {
  967. case DCB_CONNECTOR_VGA:
  968. if (nv_device(drm->device)->card_type >= NV_50) {
  969. drm_object_attach_property(&connector->base,
  970. dev->mode_config.scaling_mode_property,
  971. nv_connector->scaling_mode);
  972. }
  973. /* fall-through */
  974. case DCB_CONNECTOR_TV_0:
  975. case DCB_CONNECTOR_TV_1:
  976. case DCB_CONNECTOR_TV_3:
  977. nv_connector->scaling_mode = DRM_MODE_SCALE_NONE;
  978. break;
  979. default:
  980. nv_connector->scaling_mode = DRM_MODE_SCALE_FULLSCREEN;
  981. drm_object_attach_property(&connector->base,
  982. dev->mode_config.scaling_mode_property,
  983. nv_connector->scaling_mode);
  984. if (disp->dithering_mode) {
  985. nv_connector->dithering_mode = DITHERING_MODE_AUTO;
  986. drm_object_attach_property(&connector->base,
  987. disp->dithering_mode,
  988. nv_connector->dithering_mode);
  989. }
  990. if (disp->dithering_depth) {
  991. nv_connector->dithering_depth = DITHERING_DEPTH_AUTO;
  992. drm_object_attach_property(&connector->base,
  993. disp->dithering_depth,
  994. nv_connector->dithering_depth);
  995. }
  996. break;
  997. }
  998. connector->polled = DRM_CONNECTOR_POLL_CONNECT;
  999. if (nv_connector->hpd.func != DCB_GPIO_UNUSED)
  1000. connector->polled = DRM_CONNECTOR_POLL_HPD;
  1001. drm_sysfs_connector_add(connector);
  1002. return connector;
  1003. }