nouveau_connector.c 34 KB

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