nouveau_dp.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /*
  2. * Copyright 2009 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Ben Skeggs
  23. */
  24. #include "drmP.h"
  25. #include "nouveau_drv.h"
  26. #include "nouveau_i2c.h"
  27. #include "nouveau_connector.h"
  28. #include "nouveau_encoder.h"
  29. #include "nouveau_crtc.h"
  30. #include "nouveau_gpio.h"
  31. /******************************************************************************
  32. * aux channel util functions
  33. *****************************************************************************/
  34. #define AUX_DBG(fmt, args...) do { \
  35. if (nouveau_reg_debug & NOUVEAU_REG_DEBUG_AUXCH) { \
  36. NV_PRINTK(KERN_DEBUG, dev, "AUXCH(%d): " fmt, ch, ##args); \
  37. } \
  38. } while (0)
  39. #define AUX_ERR(fmt, args...) NV_ERROR(dev, "AUXCH(%d): " fmt, ch, ##args)
  40. static void
  41. auxch_fini(struct drm_device *dev, int ch)
  42. {
  43. nv_mask(dev, 0x00e4e4 + (ch * 0x50), 0x00310000, 0x00000000);
  44. }
  45. static int
  46. auxch_init(struct drm_device *dev, int ch)
  47. {
  48. const u32 unksel = 1; /* nfi which to use, or if it matters.. */
  49. const u32 ureq = unksel ? 0x00100000 : 0x00200000;
  50. const u32 urep = unksel ? 0x01000000 : 0x02000000;
  51. u32 ctrl, timeout;
  52. /* wait up to 1ms for any previous transaction to be done... */
  53. timeout = 1000;
  54. do {
  55. ctrl = nv_rd32(dev, 0x00e4e4 + (ch * 0x50));
  56. udelay(1);
  57. if (!timeout--) {
  58. AUX_ERR("begin idle timeout 0x%08x", ctrl);
  59. return -EBUSY;
  60. }
  61. } while (ctrl & 0x03010000);
  62. /* set some magic, and wait up to 1ms for it to appear */
  63. nv_mask(dev, 0x00e4e4 + (ch * 0x50), 0x00300000, ureq);
  64. timeout = 1000;
  65. do {
  66. ctrl = nv_rd32(dev, 0x00e4e4 + (ch * 0x50));
  67. udelay(1);
  68. if (!timeout--) {
  69. AUX_ERR("magic wait 0x%08x\n", ctrl);
  70. auxch_fini(dev, ch);
  71. return -EBUSY;
  72. }
  73. } while ((ctrl & 0x03000000) != urep);
  74. return 0;
  75. }
  76. static int
  77. auxch_tx(struct drm_device *dev, int ch, u8 type, u32 addr, u8 *data, u8 size)
  78. {
  79. u32 ctrl, stat, timeout, retries;
  80. u32 xbuf[4] = {};
  81. int ret, i;
  82. AUX_DBG("%d: 0x%08x %d\n", type, addr, size);
  83. ret = auxch_init(dev, ch);
  84. if (ret)
  85. goto out;
  86. stat = nv_rd32(dev, 0x00e4e8 + (ch * 0x50));
  87. if (!(stat & 0x10000000)) {
  88. AUX_DBG("sink not detected\n");
  89. ret = -ENXIO;
  90. goto out;
  91. }
  92. if (!(type & 1)) {
  93. memcpy(xbuf, data, size);
  94. for (i = 0; i < 16; i += 4) {
  95. AUX_DBG("wr 0x%08x\n", xbuf[i / 4]);
  96. nv_wr32(dev, 0x00e4c0 + (ch * 0x50) + i, xbuf[i / 4]);
  97. }
  98. }
  99. ctrl = nv_rd32(dev, 0x00e4e4 + (ch * 0x50));
  100. ctrl &= ~0x0001f0ff;
  101. ctrl |= type << 12;
  102. ctrl |= size - 1;
  103. nv_wr32(dev, 0x00e4e0 + (ch * 0x50), addr);
  104. /* retry transaction a number of times on failure... */
  105. ret = -EREMOTEIO;
  106. for (retries = 0; retries < 32; retries++) {
  107. /* reset, and delay a while if this is a retry */
  108. nv_wr32(dev, 0x00e4e4 + (ch * 0x50), 0x80000000 | ctrl);
  109. nv_wr32(dev, 0x00e4e4 + (ch * 0x50), 0x00000000 | ctrl);
  110. if (retries)
  111. udelay(400);
  112. /* transaction request, wait up to 1ms for it to complete */
  113. nv_wr32(dev, 0x00e4e4 + (ch * 0x50), 0x00010000 | ctrl);
  114. timeout = 1000;
  115. do {
  116. ctrl = nv_rd32(dev, 0x00e4e4 + (ch * 0x50));
  117. udelay(1);
  118. if (!timeout--) {
  119. AUX_ERR("tx req timeout 0x%08x\n", ctrl);
  120. goto out;
  121. }
  122. } while (ctrl & 0x00010000);
  123. /* read status, and check if transaction completed ok */
  124. stat = nv_mask(dev, 0x00e4e8 + (ch * 0x50), 0, 0);
  125. if (!(stat & 0x000f0f00)) {
  126. ret = 0;
  127. break;
  128. }
  129. AUX_DBG("%02d 0x%08x 0x%08x\n", retries, ctrl, stat);
  130. }
  131. if (type & 1) {
  132. for (i = 0; i < 16; i += 4) {
  133. xbuf[i / 4] = nv_rd32(dev, 0x00e4d0 + (ch * 0x50) + i);
  134. AUX_DBG("rd 0x%08x\n", xbuf[i / 4]);
  135. }
  136. memcpy(data, xbuf, size);
  137. }
  138. out:
  139. auxch_fini(dev, ch);
  140. return ret;
  141. }
  142. u8 *
  143. nouveau_dp_bios_data(struct drm_device *dev, struct dcb_entry *dcb, u8 **entry)
  144. {
  145. struct bit_entry d;
  146. u8 *table;
  147. int i;
  148. if (bit_table(dev, 'd', &d)) {
  149. NV_ERROR(dev, "BIT 'd' table not found\n");
  150. return NULL;
  151. }
  152. if (d.version != 1) {
  153. NV_ERROR(dev, "BIT 'd' table version %d unknown\n", d.version);
  154. return NULL;
  155. }
  156. table = ROMPTR(dev, d.data[0]);
  157. if (!table) {
  158. NV_ERROR(dev, "displayport table pointer invalid\n");
  159. return NULL;
  160. }
  161. switch (table[0]) {
  162. case 0x20:
  163. case 0x21:
  164. case 0x30:
  165. case 0x40:
  166. break;
  167. default:
  168. NV_ERROR(dev, "displayport table 0x%02x unknown\n", table[0]);
  169. return NULL;
  170. }
  171. for (i = 0; i < table[3]; i++) {
  172. *entry = ROMPTR(dev, table[table[1] + (i * table[2])]);
  173. if (*entry && bios_encoder_match(dcb, ROM32((*entry)[0])))
  174. return table;
  175. }
  176. NV_ERROR(dev, "displayport encoder table not found\n");
  177. return NULL;
  178. }
  179. /******************************************************************************
  180. * link training
  181. *****************************************************************************/
  182. struct dp_state {
  183. struct dp_train_func *func;
  184. struct dcb_entry *dcb;
  185. int auxch;
  186. int crtc;
  187. u8 *dpcd;
  188. int link_nr;
  189. u32 link_bw;
  190. u8 stat[6];
  191. u8 conf[4];
  192. };
  193. static void
  194. dp_set_link_config(struct drm_device *dev, struct dp_state *dp)
  195. {
  196. u8 sink[2];
  197. NV_DEBUG_KMS(dev, "%d lanes at %d KB/s\n", dp->link_nr, dp->link_bw);
  198. /* set desired link configuration on the source */
  199. dp->func->link_set(dev, dp->dcb, dp->crtc, dp->link_nr, dp->link_bw,
  200. dp->dpcd[2] & DP_ENHANCED_FRAME_CAP);
  201. /* inform the sink of the new configuration */
  202. sink[0] = dp->link_bw / 27000;
  203. sink[1] = dp->link_nr;
  204. if (dp->dpcd[2] & DP_ENHANCED_FRAME_CAP)
  205. sink[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
  206. auxch_tx(dev, dp->auxch, 8, DP_LINK_BW_SET, sink, 2);
  207. }
  208. static void
  209. dp_set_training_pattern(struct drm_device *dev, struct dp_state *dp, u8 pattern)
  210. {
  211. u8 sink_tp;
  212. NV_DEBUG_KMS(dev, "training pattern %d\n", pattern);
  213. dp->func->train_set(dev, dp->dcb, pattern);
  214. auxch_tx(dev, dp->auxch, 9, DP_TRAINING_PATTERN_SET, &sink_tp, 1);
  215. sink_tp &= ~DP_TRAINING_PATTERN_MASK;
  216. sink_tp |= pattern;
  217. auxch_tx(dev, dp->auxch, 8, DP_TRAINING_PATTERN_SET, &sink_tp, 1);
  218. }
  219. static int
  220. dp_link_train_commit(struct drm_device *dev, struct dp_state *dp)
  221. {
  222. int i;
  223. for (i = 0; i < dp->link_nr; i++) {
  224. u8 lane = (dp->stat[4 + (i >> 1)] >> ((i & 1) * 4)) & 0xf;
  225. u8 lpre = (lane & 0x0c) >> 2;
  226. u8 lvsw = (lane & 0x03) >> 0;
  227. dp->conf[i] = (lpre << 3) | lvsw;
  228. if (lvsw == DP_TRAIN_VOLTAGE_SWING_1200)
  229. dp->conf[i] |= DP_TRAIN_MAX_SWING_REACHED;
  230. if ((lpre << 3) == DP_TRAIN_PRE_EMPHASIS_9_5)
  231. dp->conf[i] |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
  232. NV_DEBUG_KMS(dev, "config lane %d %02x\n", i, dp->conf[i]);
  233. dp->func->train_adj(dev, dp->dcb, i, lvsw, lpre);
  234. }
  235. return auxch_tx(dev, dp->auxch, 8, DP_TRAINING_LANE0_SET, dp->conf, 4);
  236. }
  237. static int
  238. dp_link_train_update(struct drm_device *dev, struct dp_state *dp, u32 delay)
  239. {
  240. int ret;
  241. udelay(delay);
  242. ret = auxch_tx(dev, dp->auxch, 9, DP_LANE0_1_STATUS, dp->stat, 6);
  243. if (ret)
  244. return ret;
  245. NV_DEBUG_KMS(dev, "status %02x %02x %02x %02x %02x %02x\n",
  246. dp->stat[0], dp->stat[1], dp->stat[2], dp->stat[3],
  247. dp->stat[4], dp->stat[5]);
  248. return 0;
  249. }
  250. static int
  251. dp_link_train_cr(struct drm_device *dev, struct dp_state *dp)
  252. {
  253. bool cr_done = false, abort = false;
  254. int voltage = dp->conf[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
  255. int tries = 0, i;
  256. dp_set_training_pattern(dev, dp, DP_TRAINING_PATTERN_1);
  257. do {
  258. if (dp_link_train_commit(dev, dp) ||
  259. dp_link_train_update(dev, dp, 100))
  260. break;
  261. cr_done = true;
  262. for (i = 0; i < dp->link_nr; i++) {
  263. u8 lane = (dp->stat[i >> 1] >> ((i & 1) * 4)) & 0xf;
  264. if (!(lane & DP_LANE_CR_DONE)) {
  265. cr_done = false;
  266. if (dp->conf[i] & DP_TRAIN_MAX_SWING_REACHED)
  267. abort = true;
  268. break;
  269. }
  270. }
  271. if ((dp->conf[0] & DP_TRAIN_VOLTAGE_SWING_MASK) != voltage) {
  272. voltage = dp->conf[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
  273. tries = 0;
  274. }
  275. } while (!cr_done && !abort && ++tries < 5);
  276. return cr_done ? 0 : -1;
  277. }
  278. static int
  279. dp_link_train_eq(struct drm_device *dev, struct dp_state *dp)
  280. {
  281. bool eq_done, cr_done = true;
  282. int tries = 0, i;
  283. dp_set_training_pattern(dev, dp, DP_TRAINING_PATTERN_2);
  284. do {
  285. if (dp_link_train_update(dev, dp, 400))
  286. break;
  287. eq_done = !!(dp->stat[2] & DP_INTERLANE_ALIGN_DONE);
  288. for (i = 0; i < dp->link_nr && eq_done; i++) {
  289. u8 lane = (dp->stat[i >> 1] >> ((i & 1) * 4)) & 0xf;
  290. if (!(lane & DP_LANE_CR_DONE))
  291. cr_done = false;
  292. if (!(lane & DP_LANE_CHANNEL_EQ_DONE) ||
  293. !(lane & DP_LANE_SYMBOL_LOCKED))
  294. eq_done = false;
  295. }
  296. if (dp_link_train_commit(dev, dp))
  297. break;
  298. } while (!eq_done && cr_done && ++tries <= 5);
  299. return eq_done ? 0 : -1;
  300. }
  301. static void
  302. dp_set_downspread(struct drm_device *dev, struct dp_state *dp, bool enable)
  303. {
  304. u16 script = 0x0000;
  305. u8 *entry, *table = nouveau_dp_bios_data(dev, dp->dcb, &entry);
  306. if (table) {
  307. if (table[0] >= 0x20 && table[0] <= 0x30) {
  308. if (enable) script = ROM16(entry[12]);
  309. else script = ROM16(entry[14]);
  310. } else
  311. if (table[0] == 0x40) {
  312. if (enable) script = ROM16(entry[11]);
  313. else script = ROM16(entry[13]);
  314. }
  315. }
  316. nouveau_bios_run_init_table(dev, script, dp->dcb, dp->crtc);
  317. }
  318. static void
  319. dp_link_train_init(struct drm_device *dev, struct dp_state *dp)
  320. {
  321. u16 script = 0x0000;
  322. u8 *entry, *table = nouveau_dp_bios_data(dev, dp->dcb, &entry);
  323. if (table) {
  324. if (table[0] >= 0x20 && table[0] <= 0x30)
  325. script = ROM16(entry[6]);
  326. else
  327. if (table[0] == 0x40)
  328. script = ROM16(entry[5]);
  329. }
  330. nouveau_bios_run_init_table(dev, script, dp->dcb, dp->crtc);
  331. }
  332. static void
  333. dp_link_train_fini(struct drm_device *dev, struct dp_state *dp)
  334. {
  335. u16 script = 0x0000;
  336. u8 *entry, *table = nouveau_dp_bios_data(dev, dp->dcb, &entry);
  337. if (table) {
  338. if (table[0] >= 0x20 && table[0] <= 0x30)
  339. script = ROM16(entry[8]);
  340. else
  341. if (table[0] == 0x40)
  342. script = ROM16(entry[7]);
  343. }
  344. nouveau_bios_run_init_table(dev, script, dp->dcb, dp->crtc);
  345. }
  346. bool
  347. nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate,
  348. struct dp_train_func *func)
  349. {
  350. struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
  351. struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
  352. struct nouveau_connector *nv_connector =
  353. nouveau_encoder_connector_get(nv_encoder);
  354. struct drm_device *dev = encoder->dev;
  355. struct nouveau_i2c_chan *auxch;
  356. const u32 bw_list[] = { 270000, 162000, 0 };
  357. const u32 *link_bw = bw_list;
  358. struct dp_state dp;
  359. auxch = nouveau_i2c_find(dev, nv_encoder->dcb->i2c_index);
  360. if (!auxch)
  361. return false;
  362. dp.func = func;
  363. dp.dcb = nv_encoder->dcb;
  364. dp.crtc = nv_crtc->index;
  365. dp.auxch = auxch->drive;
  366. dp.dpcd = nv_encoder->dp.dpcd;
  367. /* adjust required bandwidth for 8B/10B coding overhead */
  368. datarate = (datarate / 8) * 10;
  369. /* some sinks toggle hotplug in response to some of the actions
  370. * we take during link training (DP_SET_POWER is one), we need
  371. * to ignore them for the moment to avoid races.
  372. */
  373. nouveau_gpio_irq(dev, 0, nv_connector->hpd, 0xff, false);
  374. /* enable down-spreading, if possible */
  375. dp_set_downspread(dev, &dp, nv_encoder->dp.dpcd[3] & 1);
  376. /* execute pre-train script from vbios */
  377. dp_link_train_init(dev, &dp);
  378. /* start off at highest link rate supported by encoder and display */
  379. while (*link_bw > nv_encoder->dp.link_bw)
  380. link_bw++;
  381. while (link_bw[0]) {
  382. /* find minimum required lane count at this link rate */
  383. dp.link_nr = nv_encoder->dp.link_nr;
  384. while ((dp.link_nr >> 1) * link_bw[0] > datarate)
  385. dp.link_nr >>= 1;
  386. /* drop link rate to minimum with this lane count */
  387. while ((link_bw[1] * dp.link_nr) > datarate)
  388. link_bw++;
  389. dp.link_bw = link_bw[0];
  390. /* program selected link configuration */
  391. dp_set_link_config(dev, &dp);
  392. /* attempt to train the link at this configuration */
  393. memset(dp.stat, 0x00, sizeof(dp.stat));
  394. if (!dp_link_train_cr(dev, &dp) &&
  395. !dp_link_train_eq(dev, &dp))
  396. break;
  397. /* retry at lower rate */
  398. link_bw++;
  399. }
  400. /* finish link training */
  401. dp_set_training_pattern(dev, &dp, DP_TRAINING_PATTERN_DISABLE);
  402. /* execute post-train script from vbios */
  403. dp_link_train_fini(dev, &dp);
  404. /* re-enable hotplug detect */
  405. nouveau_gpio_irq(dev, 0, nv_connector->hpd, 0xff, true);
  406. return true;
  407. }
  408. void
  409. nouveau_dp_dpms(struct drm_encoder *encoder, int mode, u32 datarate,
  410. struct dp_train_func *func)
  411. {
  412. struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
  413. struct nouveau_i2c_chan *auxch;
  414. u8 status;
  415. auxch = nouveau_i2c_find(encoder->dev, nv_encoder->dcb->i2c_index);
  416. if (!auxch)
  417. return;
  418. if (mode == DRM_MODE_DPMS_ON)
  419. status = DP_SET_POWER_D0;
  420. else
  421. status = DP_SET_POWER_D3;
  422. nouveau_dp_auxch(auxch, 8, DP_SET_POWER, &status, 1);
  423. if (mode == DRM_MODE_DPMS_ON)
  424. nouveau_dp_link_train(encoder, datarate, func);
  425. }
  426. bool
  427. nouveau_dp_detect(struct drm_encoder *encoder)
  428. {
  429. struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
  430. struct drm_device *dev = encoder->dev;
  431. struct nouveau_i2c_chan *auxch;
  432. u8 *dpcd = nv_encoder->dp.dpcd;
  433. int ret;
  434. auxch = nouveau_i2c_find(dev, nv_encoder->dcb->i2c_index);
  435. if (!auxch)
  436. return false;
  437. ret = auxch_tx(dev, auxch->drive, 9, DP_DPCD_REV, dpcd, 8);
  438. if (ret)
  439. return false;
  440. nv_encoder->dp.link_bw = 27000 * dpcd[1];
  441. nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
  442. NV_DEBUG_KMS(dev, "display: %dx%d dpcd 0x%02x\n",
  443. nv_encoder->dp.link_nr, nv_encoder->dp.link_bw, dpcd[0]);
  444. NV_DEBUG_KMS(dev, "encoder: %dx%d\n",
  445. nv_encoder->dcb->dpconf.link_nr,
  446. nv_encoder->dcb->dpconf.link_bw);
  447. if (nv_encoder->dcb->dpconf.link_nr < nv_encoder->dp.link_nr)
  448. nv_encoder->dp.link_nr = nv_encoder->dcb->dpconf.link_nr;
  449. if (nv_encoder->dcb->dpconf.link_bw < nv_encoder->dp.link_bw)
  450. nv_encoder->dp.link_bw = nv_encoder->dcb->dpconf.link_bw;
  451. NV_DEBUG_KMS(dev, "maximum: %dx%d\n",
  452. nv_encoder->dp.link_nr, nv_encoder->dp.link_bw);
  453. return true;
  454. }
  455. int
  456. nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
  457. uint8_t *data, int data_nr)
  458. {
  459. return auxch_tx(auxch->dev, auxch->drive, cmd, addr, data, data_nr);
  460. }
  461. static int
  462. nouveau_dp_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
  463. {
  464. struct nouveau_i2c_chan *auxch = (struct nouveau_i2c_chan *)adap;
  465. struct i2c_msg *msg = msgs;
  466. int ret, mcnt = num;
  467. while (mcnt--) {
  468. u8 remaining = msg->len;
  469. u8 *ptr = msg->buf;
  470. while (remaining) {
  471. u8 cnt = (remaining > 16) ? 16 : remaining;
  472. u8 cmd;
  473. if (msg->flags & I2C_M_RD)
  474. cmd = AUX_I2C_READ;
  475. else
  476. cmd = AUX_I2C_WRITE;
  477. if (mcnt || remaining > 16)
  478. cmd |= AUX_I2C_MOT;
  479. ret = nouveau_dp_auxch(auxch, cmd, msg->addr, ptr, cnt);
  480. if (ret < 0)
  481. return ret;
  482. ptr += cnt;
  483. remaining -= cnt;
  484. }
  485. msg++;
  486. }
  487. return num;
  488. }
  489. static u32
  490. nouveau_dp_i2c_func(struct i2c_adapter *adap)
  491. {
  492. return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
  493. }
  494. const struct i2c_algorithm nouveau_dp_i2c_algo = {
  495. .master_xfer = nouveau_dp_i2c_xfer,
  496. .functionality = nouveau_dp_i2c_func
  497. };