2 * Copyright 2009 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
27 #include "nouveau_drv.h"
28 #include "nouveau_i2c.h"
29 #include "nouveau_connector.h"
30 #include "nouveau_encoder.h"
32 /******************************************************************************
33 * aux channel util functions
34 *****************************************************************************/
35 #define AUX_DBG(fmt, args...) do { \
36 if (nouveau_reg_debug & NOUVEAU_REG_DEBUG_AUXCH) { \
37 NV_PRINTK(KERN_DEBUG, dev, "AUXCH(%d): " fmt, ch, ##args); \
40 #define AUX_ERR(fmt, args...) NV_ERROR(dev, "AUXCH(%d): " fmt, ch, ##args)
43 auxch_fini(struct drm_device
*dev
, int ch
)
45 nv_mask(dev
, 0x00e4e4 + (ch
* 0x50), 0x00310000, 0x00000000);
49 auxch_init(struct drm_device
*dev
, int ch
)
51 const u32 unksel
= 1; /* nfi which to use, or if it matters.. */
52 const u32 ureq
= unksel
? 0x00100000 : 0x00200000;
53 const u32 urep
= unksel
? 0x01000000 : 0x02000000;
56 /* wait up to 1ms for any previous transaction to be done... */
59 ctrl
= nv_rd32(dev
, 0x00e4e4 + (ch
* 0x50));
62 AUX_ERR("begin idle timeout 0x%08x", ctrl
);
65 } while (ctrl
& 0x03010000);
67 /* set some magic, and wait up to 1ms for it to appear */
68 nv_mask(dev
, 0x00e4e4 + (ch
* 0x50), 0x00300000, ureq
);
71 ctrl
= nv_rd32(dev
, 0x00e4e4 + (ch
* 0x50));
74 AUX_ERR("magic wait 0x%08x\n", ctrl
);
78 } while ((ctrl
& 0x03000000) != urep
);
84 auxch_tx(struct drm_device
*dev
, int ch
, u8 type
, u32 addr
, u8
*data
, u8 size
)
86 u32 ctrl
, stat
, timeout
, retries
;
90 AUX_DBG("%d: 0x%08x %d\n", type
, addr
, size
);
92 ret
= auxch_init(dev
, ch
);
96 stat
= nv_rd32(dev
, 0x00e4e8 + (ch
* 0x50));
97 if (!(stat
& 0x10000000)) {
98 AUX_DBG("sink not detected\n");
104 memcpy(xbuf
, data
, size
);
105 for (i
= 0; i
< 16; i
+= 4) {
106 AUX_DBG("wr 0x%08x\n", xbuf
[i
/ 4]);
107 nv_wr32(dev
, 0x00e4c0 + (ch
* 0x50) + i
, xbuf
[i
/ 4]);
111 ctrl
= nv_rd32(dev
, 0x00e4e4 + (ch
* 0x50));
115 nv_wr32(dev
, 0x00e4e0 + (ch
* 0x50), addr
);
117 /* retry transaction a number of times on failure... */
119 for (retries
= 0; retries
< 32; retries
++) {
120 /* reset, and delay a while if this is a retry */
121 nv_wr32(dev
, 0x00e4e4 + (ch
* 0x50), 0x80000000 | ctrl
);
122 nv_wr32(dev
, 0x00e4e4 + (ch
* 0x50), 0x00000000 | ctrl
);
126 /* transaction request, wait up to 1ms for it to complete */
127 nv_wr32(dev
, 0x00e4e4 + (ch
* 0x50), 0x00010000 | ctrl
);
131 ctrl
= nv_rd32(dev
, 0x00e4e4 + (ch
* 0x50));
134 AUX_ERR("tx req timeout 0x%08x\n", ctrl
);
137 } while (ctrl
& 0x00010000);
139 /* read status, and check if transaction completed ok */
140 stat
= nv_mask(dev
, 0x00e4e8 + (ch
* 0x50), 0, 0);
141 if (!(stat
& 0x000f0f00)) {
146 AUX_DBG("%02d 0x%08x 0x%08x\n", retries
, ctrl
, stat
);
150 for (i
= 0; i
< 16; i
+= 4) {
151 xbuf
[i
/ 4] = nv_rd32(dev
, 0x00e4d0 + (ch
* 0x50) + i
);
152 AUX_DBG("rd 0x%08x\n", xbuf
[i
/ 4]);
154 memcpy(data
, xbuf
, size
);
163 auxch_rd(struct drm_encoder
*encoder
, int address
, uint8_t *buf
, int size
)
165 struct drm_device
*dev
= encoder
->dev
;
166 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
167 struct nouveau_i2c_chan
*auxch
;
170 auxch
= nouveau_i2c_find(dev
, nv_encoder
->dcb
->i2c_index
);
174 ret
= nouveau_dp_auxch(auxch
, 9, address
, buf
, size
);
182 auxch_wr(struct drm_encoder
*encoder
, int address
, uint8_t *buf
, int size
)
184 struct drm_device
*dev
= encoder
->dev
;
185 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
186 struct nouveau_i2c_chan
*auxch
;
189 auxch
= nouveau_i2c_find(dev
, nv_encoder
->dcb
->i2c_index
);
193 ret
= nouveau_dp_auxch(auxch
, 8, address
, buf
, size
);
198 dp_link_bw_get(struct drm_device
*dev
, int or, int link
)
200 u32 ctrl
= nv_rd32(dev
, 0x614300 + (or * 0x800));
201 if (!(ctrl
& 0x000c0000))
207 dp_lane_count_get(struct drm_device
*dev
, int or, int link
)
209 u32 ctrl
= nv_rd32(dev
, NV50_SOR_DP_CTRL(or, link
));
210 switch (ctrl
& 0x000f0000) {
211 case 0x00010000: return 1;
212 case 0x00030000: return 2;
219 nouveau_dp_tu_update(struct drm_device
*dev
, int or, int link
, u32 clk
, u32 bpp
)
221 const u32 symbol
= 100000;
222 int bestTU
= 0, bestVTUi
= 0, bestVTUf
= 0, bestVTUa
= 0;
223 int TU
, VTUi
, VTUf
, VTUa
;
224 u64 link_data_rate
, link_ratio
, unk
;
225 u32 best_diff
= 64 * symbol
;
226 u32 link_nr
, link_bw
, r
;
228 /* calculate packed data rate for each lane */
229 link_nr
= dp_lane_count_get(dev
, or, link
);
230 link_data_rate
= (clk
* bpp
/ 8) / link_nr
;
232 /* calculate ratio of packed data rate to link symbol rate */
233 link_bw
= dp_link_bw_get(dev
, or, link
);
234 link_ratio
= link_data_rate
* symbol
;
235 r
= do_div(link_ratio
, link_bw
);
237 for (TU
= 64; TU
>= 32; TU
--) {
238 /* calculate average number of valid symbols in each TU */
239 u32 tu_valid
= link_ratio
* TU
;
242 /* find a hw representation for the fraction.. */
243 VTUi
= tu_valid
/ symbol
;
244 calc
= VTUi
* symbol
;
245 diff
= tu_valid
- calc
;
247 if (diff
>= (symbol
/ 2)) {
248 VTUf
= symbol
/ (symbol
- diff
);
249 if (symbol
- (VTUf
* diff
))
254 calc
+= symbol
- (symbol
/ VTUf
);
262 VTUf
= min((int)(symbol
/ diff
), 15);
263 calc
+= symbol
/ VTUf
;
266 diff
= calc
- tu_valid
;
268 /* no remainder, but the hw doesn't like the fractional
269 * part to be zero. decrement the integer part and
270 * have the fraction add a whole symbol back
277 if (diff
< best_diff
) {
289 NV_ERROR(dev
, "DP: unable to find suitable config\n");
293 /* XXX close to vbios numbers, but not right */
294 unk
= (symbol
- link_ratio
) * bestTU
;
296 r
= do_div(unk
, symbol
);
297 r
= do_div(unk
, symbol
);
300 nv_mask(dev
, NV50_SOR_DP_CTRL(or, link
), 0x000001fc, bestTU
<< 2);
301 nv_mask(dev
, NV50_SOR_DP_SCFG(or, link
), 0x010f7f3f, bestVTUa
<< 24 |
308 nouveau_dp_lane_count_set(struct drm_encoder
*encoder
, uint8_t cmd
)
310 struct drm_device
*dev
= encoder
->dev
;
311 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
313 int or = nv_encoder
->or, link
= !(nv_encoder
->dcb
->sorconf
.link
& 1);
315 tmp
= nv_rd32(dev
, NV50_SOR_DP_CTRL(or, link
));
316 tmp
&= ~(NV50_SOR_DP_CTRL_ENHANCED_FRAME_ENABLED
|
317 NV50_SOR_DP_CTRL_LANE_MASK
);
318 tmp
|= ((1 << (cmd
& DP_LANE_COUNT_MASK
)) - 1) << 16;
319 if (cmd
& DP_LANE_COUNT_ENHANCED_FRAME_EN
)
320 tmp
|= NV50_SOR_DP_CTRL_ENHANCED_FRAME_ENABLED
;
321 nv_wr32(dev
, NV50_SOR_DP_CTRL(or, link
), tmp
);
323 return auxch_wr(encoder
, DP_LANE_COUNT_SET
, &cmd
, 1);
327 nouveau_dp_link_bw_set(struct drm_encoder
*encoder
, uint8_t cmd
)
329 struct drm_device
*dev
= encoder
->dev
;
330 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
332 int reg
= 0x614300 + (nv_encoder
->or * 0x800);
334 tmp
= nv_rd32(dev
, reg
);
336 if (cmd
== DP_LINK_BW_2_7
)
338 nv_wr32(dev
, reg
, tmp
);
340 return auxch_wr(encoder
, DP_LINK_BW_SET
, &cmd
, 1);
344 nouveau_dp_link_train_set(struct drm_encoder
*encoder
, int pattern
)
346 struct drm_device
*dev
= encoder
->dev
;
347 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
350 int or = nv_encoder
->or, link
= !(nv_encoder
->dcb
->sorconf
.link
& 1);
353 tmp
= nv_rd32(dev
, NV50_SOR_DP_CTRL(or, link
));
354 tmp
&= ~NV50_SOR_DP_CTRL_TRAINING_PATTERN
;
355 tmp
|= (pattern
<< 24);
356 nv_wr32(dev
, NV50_SOR_DP_CTRL(or, link
), tmp
);
358 ret
= auxch_rd(encoder
, DP_TRAINING_PATTERN_SET
, &cmd
, 1);
361 cmd
&= ~DP_TRAINING_PATTERN_MASK
;
362 cmd
|= (pattern
& DP_TRAINING_PATTERN_MASK
);
363 return auxch_wr(encoder
, DP_TRAINING_PATTERN_SET
, &cmd
, 1);
367 nouveau_dp_max_voltage_swing(struct drm_encoder
*encoder
)
369 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
370 struct drm_device
*dev
= encoder
->dev
;
371 struct bit_displayport_encoder_table_entry
*dpse
;
372 struct bit_displayport_encoder_table
*dpe
;
373 int i
, dpe_headerlen
, max_vs
= 0;
375 dpe
= nouveau_bios_dp_table(dev
, nv_encoder
->dcb
, &dpe_headerlen
);
378 dpse
= (void *)((char *)dpe
+ dpe_headerlen
);
380 for (i
= 0; i
< dpe_headerlen
; i
++, dpse
++) {
381 if (dpse
->vs_level
> max_vs
)
382 max_vs
= dpse
->vs_level
;
389 nouveau_dp_max_pre_emphasis(struct drm_encoder
*encoder
, int vs
)
391 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
392 struct drm_device
*dev
= encoder
->dev
;
393 struct bit_displayport_encoder_table_entry
*dpse
;
394 struct bit_displayport_encoder_table
*dpe
;
395 int i
, dpe_headerlen
, max_pre
= 0;
397 dpe
= nouveau_bios_dp_table(dev
, nv_encoder
->dcb
, &dpe_headerlen
);
400 dpse
= (void *)((char *)dpe
+ dpe_headerlen
);
402 for (i
= 0; i
< dpe_headerlen
; i
++, dpse
++) {
403 if (dpse
->vs_level
!= vs
)
406 if (dpse
->pre_level
> max_pre
)
407 max_pre
= dpse
->pre_level
;
414 nouveau_dp_link_train_adjust(struct drm_encoder
*encoder
, uint8_t *config
)
416 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
417 struct drm_device
*dev
= encoder
->dev
;
418 struct bit_displayport_encoder_table
*dpe
;
419 int ret
, i
, dpe_headerlen
, vs
= 0, pre
= 0;
422 dpe
= nouveau_bios_dp_table(dev
, nv_encoder
->dcb
, &dpe_headerlen
);
426 ret
= auxch_rd(encoder
, DP_ADJUST_REQUEST_LANE0_1
, request
, 2);
430 NV_DEBUG_KMS(dev
, "\t\tadjust 0x%02x 0x%02x\n", request
[0], request
[1]);
432 /* Keep all lanes at the same level.. */
433 for (i
= 0; i
< nv_encoder
->dp
.link_nr
; i
++) {
434 int lane_req
= (request
[i
>> 1] >> ((i
& 1) << 2)) & 0xf;
435 int lane_vs
= lane_req
& 3;
436 int lane_pre
= (lane_req
>> 2) & 3;
444 if (vs
>= nouveau_dp_max_voltage_swing(encoder
)) {
445 vs
= nouveau_dp_max_voltage_swing(encoder
);
449 if (pre
>= nouveau_dp_max_pre_emphasis(encoder
, vs
& 3)) {
450 pre
= nouveau_dp_max_pre_emphasis(encoder
, vs
& 3);
454 /* Update the configuration for all lanes.. */
455 for (i
= 0; i
< nv_encoder
->dp
.link_nr
; i
++)
456 config
[i
] = (pre
<< 3) | vs
;
462 nouveau_dp_link_train_commit(struct drm_encoder
*encoder
, uint8_t *config
)
464 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
465 struct drm_device
*dev
= encoder
->dev
;
466 struct bit_displayport_encoder_table_entry
*dpse
;
467 struct bit_displayport_encoder_table
*dpe
;
468 int or = nv_encoder
->or, link
= !(nv_encoder
->dcb
->sorconf
.link
& 1);
469 int dpe_headerlen
, ret
, i
;
471 NV_DEBUG_KMS(dev
, "\t\tconfig 0x%02x 0x%02x 0x%02x 0x%02x\n",
472 config
[0], config
[1], config
[2], config
[3]);
474 dpe
= nouveau_bios_dp_table(dev
, nv_encoder
->dcb
, &dpe_headerlen
);
477 dpse
= (void *)((char *)dpe
+ dpe_headerlen
);
479 for (i
= 0; i
< dpe
->record_nr
; i
++, dpse
++) {
480 if (dpse
->vs_level
== (config
[0] & 3) &&
481 dpse
->pre_level
== ((config
[0] >> 3) & 3))
484 BUG_ON(i
== dpe
->record_nr
);
486 for (i
= 0; i
< nv_encoder
->dp
.link_nr
; i
++) {
487 const int shift
[4] = { 16, 8, 0, 24 };
488 uint32_t mask
= 0xff << shift
[i
];
489 uint32_t reg0
, reg1
, reg2
;
491 reg0
= nv_rd32(dev
, NV50_SOR_DP_UNK118(or, link
)) & ~mask
;
492 reg0
|= (dpse
->reg0
<< shift
[i
]);
493 reg1
= nv_rd32(dev
, NV50_SOR_DP_UNK120(or, link
)) & ~mask
;
494 reg1
|= (dpse
->reg1
<< shift
[i
]);
495 reg2
= nv_rd32(dev
, NV50_SOR_DP_UNK130(or, link
)) & 0xffff00ff;
496 reg2
|= (dpse
->reg2
<< 8);
497 nv_wr32(dev
, NV50_SOR_DP_UNK118(or, link
), reg0
);
498 nv_wr32(dev
, NV50_SOR_DP_UNK120(or, link
), reg1
);
499 nv_wr32(dev
, NV50_SOR_DP_UNK130(or, link
), reg2
);
502 ret
= auxch_wr(encoder
, DP_TRAINING_LANE0_SET
, config
, 4);
510 nouveau_dp_link_train(struct drm_encoder
*encoder
, u32 datarate
)
512 struct drm_device
*dev
= encoder
->dev
;
513 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
514 struct nouveau_gpio_engine
*pgpio
= &dev_priv
->engine
.gpio
;
515 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
516 struct nouveau_connector
*nv_connector
;
517 struct bit_displayport_encoder_table
*dpe
;
519 uint8_t config
[4], status
[3];
520 bool cr_done
, cr_max_vs
, eq_done
, hpd_state
;
521 int ret
= 0, i
, tries
, voltage
;
523 NV_DEBUG_KMS(dev
, "link training!!\n");
525 nv_connector
= nouveau_encoder_connector_get(nv_encoder
);
529 dpe
= nouveau_bios_dp_table(dev
, nv_encoder
->dcb
, &dpe_headerlen
);
531 NV_ERROR(dev
, "SOR-%d: no DP encoder table!\n", nv_encoder
->or);
535 /* disable hotplug detect, this flips around on some panels during
538 hpd_state
= pgpio
->irq_enable(dev
, nv_connector
->dcb
->gpio_tag
, false);
541 NV_DEBUG_KMS(dev
, "SOR-%d: running DP script 0\n", nv_encoder
->or);
542 nouveau_bios_run_init_table(dev
, le16_to_cpu(dpe
->script0
),
543 nv_encoder
->dcb
, -1);
547 cr_done
= eq_done
= false;
549 /* set link configuration */
550 NV_DEBUG_KMS(dev
, "\tbegin train: bw %d, lanes %d\n",
551 nv_encoder
->dp
.link_bw
, nv_encoder
->dp
.link_nr
);
553 ret
= nouveau_dp_link_bw_set(encoder
, nv_encoder
->dp
.link_bw
);
557 config
[0] = nv_encoder
->dp
.link_nr
;
558 if (nv_encoder
->dp
.dpcd_version
>= 0x11 &&
559 nv_encoder
->dp
.enhanced_frame
)
560 config
[0] |= DP_LANE_COUNT_ENHANCED_FRAME_EN
;
562 ret
= nouveau_dp_lane_count_set(encoder
, config
[0]);
567 NV_DEBUG_KMS(dev
, "\tbegin cr\n");
568 ret
= nouveau_dp_link_train_set(encoder
, DP_TRAINING_PATTERN_1
);
574 memset(config
, 0x00, sizeof(config
));
576 if (!nouveau_dp_link_train_commit(encoder
, config
))
581 ret
= auxch_rd(encoder
, DP_LANE0_1_STATUS
, status
, 2);
584 NV_DEBUG_KMS(dev
, "\t\tstatus: 0x%02x 0x%02x\n",
585 status
[0], status
[1]);
589 for (i
= 0; i
< nv_encoder
->dp
.link_nr
; i
++) {
590 int lane
= (status
[i
>> 1] >> ((i
& 1) * 4)) & 0xf;
592 if (!(lane
& DP_LANE_CR_DONE
)) {
594 if (config
[i
] & DP_TRAIN_MAX_PRE_EMPHASIS_REACHED
)
600 if ((config
[0] & DP_TRAIN_VOLTAGE_SWING_MASK
) != voltage
) {
601 voltage
= config
[0] & DP_TRAIN_VOLTAGE_SWING_MASK
;
605 if (cr_done
|| cr_max_vs
|| (++tries
== 5))
608 if (!nouveau_dp_link_train_adjust(encoder
, config
))
615 /* channel equalisation */
616 NV_DEBUG_KMS(dev
, "\tbegin eq\n");
617 ret
= nouveau_dp_link_train_set(encoder
, DP_TRAINING_PATTERN_2
);
621 for (tries
= 0; tries
<= 5; tries
++) {
624 ret
= auxch_rd(encoder
, DP_LANE0_1_STATUS
, status
, 3);
627 NV_DEBUG_KMS(dev
, "\t\tstatus: 0x%02x 0x%02x\n",
628 status
[0], status
[1]);
631 if (!(status
[2] & DP_INTERLANE_ALIGN_DONE
))
634 for (i
= 0; eq_done
&& i
< nv_encoder
->dp
.link_nr
; i
++) {
635 int lane
= (status
[i
>> 1] >> ((i
& 1) * 4)) & 0xf;
637 if (!(lane
& DP_LANE_CR_DONE
)) {
642 if (!(lane
& DP_LANE_CHANNEL_EQ_DONE
) ||
643 !(lane
& DP_LANE_SYMBOL_LOCKED
)) {
649 if (eq_done
|| !cr_done
)
652 if (!nouveau_dp_link_train_adjust(encoder
, config
) ||
653 !nouveau_dp_link_train_commit(encoder
, config
))
658 /* end link training */
659 ret
= nouveau_dp_link_train_set(encoder
, DP_TRAINING_PATTERN_DISABLE
);
663 /* retry at a lower setting, if possible */
664 if (!ret
&& !(eq_done
&& cr_done
)) {
665 NV_DEBUG_KMS(dev
, "\twe failed\n");
666 if (nv_encoder
->dp
.link_bw
!= DP_LINK_BW_1_62
) {
667 NV_DEBUG_KMS(dev
, "retry link training at low rate\n");
668 nv_encoder
->dp
.link_bw
= DP_LINK_BW_1_62
;
674 NV_DEBUG_KMS(dev
, "SOR-%d: running DP script 1\n", nv_encoder
->or);
675 nouveau_bios_run_init_table(dev
, le16_to_cpu(dpe
->script1
),
676 nv_encoder
->dcb
, -1);
679 /* re-enable hotplug detect */
680 pgpio
->irq_enable(dev
, nv_connector
->dcb
->gpio_tag
, hpd_state
);
686 nouveau_dp_detect(struct drm_encoder
*encoder
)
688 struct nouveau_encoder
*nv_encoder
= nouveau_encoder(encoder
);
689 struct drm_device
*dev
= encoder
->dev
;
693 ret
= auxch_rd(encoder
, 0x0000, dpcd
, 4);
697 NV_DEBUG_KMS(dev
, "encoder: link_bw %d, link_nr %d\n"
698 "display: link_bw %d, link_nr %d version 0x%02x\n",
699 nv_encoder
->dcb
->dpconf
.link_bw
,
700 nv_encoder
->dcb
->dpconf
.link_nr
,
701 dpcd
[1], dpcd
[2] & 0x0f, dpcd
[0]);
703 nv_encoder
->dp
.dpcd_version
= dpcd
[0];
705 nv_encoder
->dp
.link_bw
= dpcd
[1];
706 if (nv_encoder
->dp
.link_bw
!= DP_LINK_BW_1_62
&&
707 !nv_encoder
->dcb
->dpconf
.link_bw
)
708 nv_encoder
->dp
.link_bw
= DP_LINK_BW_1_62
;
710 nv_encoder
->dp
.link_nr
= dpcd
[2] & DP_MAX_LANE_COUNT_MASK
;
711 if (nv_encoder
->dp
.link_nr
> nv_encoder
->dcb
->dpconf
.link_nr
)
712 nv_encoder
->dp
.link_nr
= nv_encoder
->dcb
->dpconf
.link_nr
;
714 nv_encoder
->dp
.enhanced_frame
= (dpcd
[2] & DP_ENHANCED_FRAME_CAP
);
720 nouveau_dp_auxch(struct nouveau_i2c_chan
*auxch
, int cmd
, int addr
,
721 uint8_t *data
, int data_nr
)
723 return auxch_tx(auxch
->dev
, auxch
->rd
, cmd
, addr
, data
, data_nr
);
727 nouveau_dp_i2c_xfer(struct i2c_adapter
*adap
, struct i2c_msg
*msgs
, int num
)
729 struct nouveau_i2c_chan
*auxch
= (struct nouveau_i2c_chan
*)adap
;
730 struct i2c_msg
*msg
= msgs
;
734 u8 remaining
= msg
->len
;
738 u8 cnt
= (remaining
> 16) ? 16 : remaining
;
741 if (msg
->flags
& I2C_M_RD
)
746 if (mcnt
|| remaining
> 16)
749 ret
= nouveau_dp_auxch(auxch
, cmd
, msg
->addr
, ptr
, cnt
);
764 nouveau_dp_i2c_func(struct i2c_adapter
*adap
)
766 return I2C_FUNC_I2C
| I2C_FUNC_SMBUS_EMUL
;
769 const struct i2c_algorithm nouveau_dp_i2c_algo
= {
770 .master_xfer
= nouveau_dp_i2c_xfer
,
771 .functionality
= nouveau_dp_i2c_func