Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/tegra: Move drm_dp_link helpers to Tegra DRM

During the discussion of patches that enhance the drm_dp_link helpers it
was concluded that these helpers aren't very useful to begin with. After
all other drivers have been converted not to use these helpers anymore,
move these helpers into the last remaining user: Tegra DRM.

If at some point these helpers are deemed more widely useful, they can
be moved out into the DRM DP helpers again.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20191021143437.1477719-14-thierry.reding@gmail.com

+162 -144
-128
drivers/gpu/drm/drm_dp_helper.c
··· 352 352 EXPORT_SYMBOL(drm_dp_dpcd_read_link_status); 353 353 354 354 /** 355 - * drm_dp_link_probe() - probe a DisplayPort link for capabilities 356 - * @aux: DisplayPort AUX channel 357 - * @link: pointer to structure in which to return link capabilities 358 - * 359 - * The structure filled in by this function can usually be passed directly 360 - * into drm_dp_link_power_up() and drm_dp_link_configure() to power up and 361 - * configure the link based on the link's capabilities. 362 - * 363 - * Returns 0 on success or a negative error code on failure. 364 - */ 365 - int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link) 366 - { 367 - u8 values[3]; 368 - int err; 369 - 370 - memset(link, 0, sizeof(*link)); 371 - 372 - err = drm_dp_dpcd_read(aux, DP_DPCD_REV, values, sizeof(values)); 373 - if (err < 0) 374 - return err; 375 - 376 - link->revision = values[0]; 377 - link->rate = drm_dp_bw_code_to_link_rate(values[1]); 378 - link->num_lanes = values[2] & DP_MAX_LANE_COUNT_MASK; 379 - 380 - if (values[2] & DP_ENHANCED_FRAME_CAP) 381 - link->capabilities |= DP_LINK_CAP_ENHANCED_FRAMING; 382 - 383 - return 0; 384 - } 385 - EXPORT_SYMBOL(drm_dp_link_probe); 386 - 387 - /** 388 - * drm_dp_link_power_up() - power up a DisplayPort link 389 - * @aux: DisplayPort AUX channel 390 - * @link: pointer to a structure containing the link configuration 391 - * 392 - * Returns 0 on success or a negative error code on failure. 393 - */ 394 - int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link) 395 - { 396 - u8 value; 397 - int err; 398 - 399 - /* DP_SET_POWER register is only available on DPCD v1.1 and later */ 400 - if (link->revision < 0x11) 401 - return 0; 402 - 403 - err = drm_dp_dpcd_readb(aux, DP_SET_POWER, &value); 404 - if (err < 0) 405 - return err; 406 - 407 - value &= ~DP_SET_POWER_MASK; 408 - value |= DP_SET_POWER_D0; 409 - 410 - err = drm_dp_dpcd_writeb(aux, DP_SET_POWER, value); 411 - if (err < 0) 412 - return err; 413 - 414 - /* 415 - * According to the DP 1.1 specification, a "Sink Device must exit the 416 - * power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink 417 - * Control Field" (register 0x600). 418 - */ 419 - usleep_range(1000, 2000); 420 - 421 - return 0; 422 - } 423 - EXPORT_SYMBOL(drm_dp_link_power_up); 424 - 425 - /** 426 - * drm_dp_link_power_down() - power down a DisplayPort link 427 - * @aux: DisplayPort AUX channel 428 - * @link: pointer to a structure containing the link configuration 429 - * 430 - * Returns 0 on success or a negative error code on failure. 431 - */ 432 - int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link) 433 - { 434 - u8 value; 435 - int err; 436 - 437 - /* DP_SET_POWER register is only available on DPCD v1.1 and later */ 438 - if (link->revision < 0x11) 439 - return 0; 440 - 441 - err = drm_dp_dpcd_readb(aux, DP_SET_POWER, &value); 442 - if (err < 0) 443 - return err; 444 - 445 - value &= ~DP_SET_POWER_MASK; 446 - value |= DP_SET_POWER_D3; 447 - 448 - err = drm_dp_dpcd_writeb(aux, DP_SET_POWER, value); 449 - if (err < 0) 450 - return err; 451 - 452 - return 0; 453 - } 454 - EXPORT_SYMBOL(drm_dp_link_power_down); 455 - 456 - /** 457 - * drm_dp_link_configure() - configure a DisplayPort link 458 - * @aux: DisplayPort AUX channel 459 - * @link: pointer to a structure containing the link configuration 460 - * 461 - * Returns 0 on success or a negative error code on failure. 462 - */ 463 - int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link) 464 - { 465 - u8 values[2]; 466 - int err; 467 - 468 - values[0] = drm_dp_link_rate_to_bw_code(link->rate); 469 - values[1] = link->num_lanes; 470 - 471 - if (link->capabilities & DP_LINK_CAP_ENHANCED_FRAMING) 472 - values[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN; 473 - 474 - err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, values, sizeof(values)); 475 - if (err < 0) 476 - return err; 477 - 478 - return 0; 479 - } 480 - EXPORT_SYMBOL(drm_dp_link_configure); 481 - 482 - /** 483 355 * drm_dp_downstream_max_clock() - extract branch device max 484 356 * pixel rate for legacy VGA 485 357 * converter or max TMDS clock
+1
drivers/gpu/drm/tegra/Makefile
··· 5 5 drm.o \ 6 6 gem.o \ 7 7 fb.o \ 8 + dp.o \ 8 9 hub.o \ 9 10 plane.o \ 10 11 dc.o \
+133
drivers/gpu/drm/tegra/dp.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* 3 + * Copyright (C) 2013-2019 NVIDIA Corporation 4 + * Copyright (C) 2015 Rob Clark 5 + */ 6 + 7 + #include <drm/drm_dp_helper.h> 8 + 9 + #include "dp.h" 10 + 11 + /** 12 + * drm_dp_link_probe() - probe a DisplayPort link for capabilities 13 + * @aux: DisplayPort AUX channel 14 + * @link: pointer to structure in which to return link capabilities 15 + * 16 + * The structure filled in by this function can usually be passed directly 17 + * into drm_dp_link_power_up() and drm_dp_link_configure() to power up and 18 + * configure the link based on the link's capabilities. 19 + * 20 + * Returns 0 on success or a negative error code on failure. 21 + */ 22 + int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link) 23 + { 24 + u8 values[3]; 25 + int err; 26 + 27 + memset(link, 0, sizeof(*link)); 28 + 29 + err = drm_dp_dpcd_read(aux, DP_DPCD_REV, values, sizeof(values)); 30 + if (err < 0) 31 + return err; 32 + 33 + link->revision = values[0]; 34 + link->rate = drm_dp_bw_code_to_link_rate(values[1]); 35 + link->num_lanes = values[2] & DP_MAX_LANE_COUNT_MASK; 36 + 37 + if (values[2] & DP_ENHANCED_FRAME_CAP) 38 + link->capabilities |= DP_LINK_CAP_ENHANCED_FRAMING; 39 + 40 + return 0; 41 + } 42 + 43 + /** 44 + * drm_dp_link_power_up() - power up a DisplayPort link 45 + * @aux: DisplayPort AUX channel 46 + * @link: pointer to a structure containing the link configuration 47 + * 48 + * Returns 0 on success or a negative error code on failure. 49 + */ 50 + int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link) 51 + { 52 + u8 value; 53 + int err; 54 + 55 + /* DP_SET_POWER register is only available on DPCD v1.1 and later */ 56 + if (link->revision < 0x11) 57 + return 0; 58 + 59 + err = drm_dp_dpcd_readb(aux, DP_SET_POWER, &value); 60 + if (err < 0) 61 + return err; 62 + 63 + value &= ~DP_SET_POWER_MASK; 64 + value |= DP_SET_POWER_D0; 65 + 66 + err = drm_dp_dpcd_writeb(aux, DP_SET_POWER, value); 67 + if (err < 0) 68 + return err; 69 + 70 + /* 71 + * According to the DP 1.1 specification, a "Sink Device must exit the 72 + * power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink 73 + * Control Field" (register 0x600). 74 + */ 75 + usleep_range(1000, 2000); 76 + 77 + return 0; 78 + } 79 + 80 + /** 81 + * drm_dp_link_power_down() - power down a DisplayPort link 82 + * @aux: DisplayPort AUX channel 83 + * @link: pointer to a structure containing the link configuration 84 + * 85 + * Returns 0 on success or a negative error code on failure. 86 + */ 87 + int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link) 88 + { 89 + u8 value; 90 + int err; 91 + 92 + /* DP_SET_POWER register is only available on DPCD v1.1 and later */ 93 + if (link->revision < 0x11) 94 + return 0; 95 + 96 + err = drm_dp_dpcd_readb(aux, DP_SET_POWER, &value); 97 + if (err < 0) 98 + return err; 99 + 100 + value &= ~DP_SET_POWER_MASK; 101 + value |= DP_SET_POWER_D3; 102 + 103 + err = drm_dp_dpcd_writeb(aux, DP_SET_POWER, value); 104 + if (err < 0) 105 + return err; 106 + 107 + return 0; 108 + } 109 + 110 + /** 111 + * drm_dp_link_configure() - configure a DisplayPort link 112 + * @aux: DisplayPort AUX channel 113 + * @link: pointer to a structure containing the link configuration 114 + * 115 + * Returns 0 on success or a negative error code on failure. 116 + */ 117 + int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link) 118 + { 119 + u8 values[2]; 120 + int err; 121 + 122 + values[0] = drm_dp_link_rate_to_bw_code(link->rate); 123 + values[1] = link->num_lanes; 124 + 125 + if (link->capabilities & DP_LINK_CAP_ENHANCED_FRAMING) 126 + values[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN; 127 + 128 + err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, values, sizeof(values)); 129 + if (err < 0) 130 + return err; 131 + 132 + return 0; 133 + }
+26
drivers/gpu/drm/tegra/dp.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright (C) 2013-2019 NVIDIA Corporation. 4 + * Copyright (C) 2015 Rob Clark 5 + */ 6 + 7 + #ifndef DRM_TEGRA_DP_H 8 + #define DRM_TEGRA_DP_H 1 9 + 10 + struct drm_dp_aux; 11 + 12 + #define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0) 13 + 14 + struct drm_dp_link { 15 + unsigned char revision; 16 + unsigned int rate; 17 + unsigned int num_lanes; 18 + unsigned long capabilities; 19 + }; 20 + 21 + int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link); 22 + int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link); 23 + int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link); 24 + int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link); 25 + 26 + #endif
+1
drivers/gpu/drm/tegra/dpaux.c
··· 22 22 #include <drm/drm_dp_helper.h> 23 23 #include <drm/drm_panel.h> 24 24 25 + #include "dp.h" 25 26 #include "dpaux.h" 26 27 #include "drm.h" 27 28 #include "trace.h"
+1
drivers/gpu/drm/tegra/sor.c
··· 25 25 #include <drm/drm_scdc_helper.h> 26 26 27 27 #include "dc.h" 28 + #include "dp.h" 28 29 #include "drm.h" 29 30 #include "hda.h" 30 31 #include "sor.h"
-16
include/drm/drm_dp_helper.h
··· 1455 1455 int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, 1456 1456 u8 status[DP_LINK_STATUS_SIZE]); 1457 1457 1458 - /* 1459 - * DisplayPort link 1460 - */ 1461 - #define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0) 1462 - 1463 - struct drm_dp_link { 1464 - unsigned char revision; 1465 - unsigned int rate; 1466 - unsigned int num_lanes; 1467 - unsigned long capabilities; 1468 - }; 1469 - 1470 - int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link); 1471 - int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link); 1472 - int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link); 1473 - int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link); 1474 1458 int drm_dp_downstream_max_clock(const u8 dpcd[DP_RECEIVER_CAP_SIZE], 1475 1459 const u8 port_cap[4]); 1476 1460 int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],