nouveau_connector.c 34 KB

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