Lines Matching +full:link +full:- +full:rate

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
22 struct dp_link *link; member
32 dp_panel = &panel->dp_panel; in dp_panel_read_psr_cap()
35 if (dp_panel->dpcd[DP_EDP_CONFIGURATION_CAP]) { in dp_panel_read_psr_cap()
36 rlen = drm_dp_dpcd_read(panel->aux, DP_PSR_SUPPORT, in dp_panel_read_psr_cap()
37 &dp_panel->psr_cap, sizeof(dp_panel->psr_cap)); in dp_panel_read_psr_cap()
38 if (rlen == sizeof(dp_panel->psr_cap)) { in dp_panel_read_psr_cap()
39 drm_dbg_dp(panel->drm_dev, in dp_panel_read_psr_cap()
41 dp_panel->psr_cap.version, in dp_panel_read_psr_cap()
42 dp_panel->psr_cap.capabilities); in dp_panel_read_psr_cap()
56 dpcd = dp_panel->dpcd; in dp_panel_read_dpcd()
57 rc = drm_dp_read_dpcd_caps(panel->aux, dpcd); in dp_panel_read_dpcd()
61 dp_panel->vsc_sdp_supported = drm_dp_vsc_sdp_supported(panel->aux, dpcd); in dp_panel_read_dpcd()
62 link_info = &dp_panel->link_info; in dp_panel_read_dpcd()
63 link_info->revision = dpcd[DP_DPCD_REV]; in dp_panel_read_dpcd()
64 major = (link_info->revision >> 4) & 0x0f; in dp_panel_read_dpcd()
65 minor = link_info->revision & 0x0f; in dp_panel_read_dpcd()
67 link_info->rate = drm_dp_max_link_rate(dpcd); in dp_panel_read_dpcd()
68 link_info->num_lanes = drm_dp_max_lane_count(dpcd); in dp_panel_read_dpcd()
70 /* Limit data lanes from data-lanes of endpoint property of dtsi */ in dp_panel_read_dpcd()
71 if (link_info->num_lanes > dp_panel->max_dp_lanes) in dp_panel_read_dpcd()
72 link_info->num_lanes = dp_panel->max_dp_lanes; in dp_panel_read_dpcd()
74 /* Limit link rate from link-frequencies of endpoint property of dtsi */ in dp_panel_read_dpcd()
75 if (link_info->rate > dp_panel->max_dp_link_rate) in dp_panel_read_dpcd()
76 link_info->rate = dp_panel->max_dp_link_rate; in dp_panel_read_dpcd()
78 drm_dbg_dp(panel->drm_dev, "version: %d.%d\n", major, minor); in dp_panel_read_dpcd()
79 drm_dbg_dp(panel->drm_dev, "link_rate=%d\n", link_info->rate); in dp_panel_read_dpcd()
80 drm_dbg_dp(panel->drm_dev, "lane_count=%d\n", link_info->num_lanes); in dp_panel_read_dpcd()
83 link_info->capabilities |= DP_LINK_CAP_ENHANCED_FRAMING; in dp_panel_read_dpcd()
99 link_info = &dp_panel->link_info; in dp_panel_get_supported_bpp()
100 data_rate_khz = link_info->num_lanes * link_info->rate * 8; in dp_panel_get_supported_bpp()
105 bpp -= 6; in dp_panel_get_supported_bpp()
120 return -EINVAL; in dp_panel_read_sink_caps()
125 drm_dbg_dp(panel->drm_dev, "max_lanes=%d max_link_rate=%d\n", in dp_panel_read_sink_caps()
126 dp_panel->max_dp_lanes, dp_panel->max_dp_link_rate); in dp_panel_read_sink_caps()
134 bw_code = drm_dp_link_rate_to_bw_code(dp_panel->link_info.rate); in dp_panel_read_sink_caps()
136 !is_lane_count_valid(dp_panel->link_info.num_lanes) || in dp_panel_read_sink_caps()
137 (bw_code > dp_panel->max_bw_code)) { in dp_panel_read_sink_caps()
138 DRM_ERROR("Illegal link rate=%d lane=%d\n", dp_panel->link_info.rate, in dp_panel_read_sink_caps()
139 dp_panel->link_info.num_lanes); in dp_panel_read_sink_caps()
140 return -EINVAL; in dp_panel_read_sink_caps()
143 if (drm_dp_is_branch(dp_panel->dpcd)) { in dp_panel_read_sink_caps()
144 count = drm_dp_read_sink_count(panel->aux); in dp_panel_read_sink_caps()
146 panel->link->sink_count = 0; in dp_panel_read_sink_caps()
147 return -ENOTCONN; in dp_panel_read_sink_caps()
151 rc = drm_dp_read_downstream_info(panel->aux, dp_panel->dpcd, in dp_panel_read_sink_caps()
152 dp_panel->downstream_ports); in dp_panel_read_sink_caps()
156 drm_edid_free(dp_panel->drm_edid); in dp_panel_read_sink_caps()
158 dp_panel->drm_edid = drm_edid_read_ddc(connector, &panel->aux->ddc); in dp_panel_read_sink_caps()
160 drm_edid_connector_update(connector, dp_panel->drm_edid); in dp_panel_read_sink_caps()
162 if (!dp_panel->drm_edid) { in dp_panel_read_sink_caps()
165 if (!dp_catalog_link_is_connected(panel->catalog)) { in dp_panel_read_sink_caps()
166 rc = -ETIMEDOUT; in dp_panel_read_sink_caps()
188 if (dp_panel->video_test) in dp_panel_get_mode_bpp()
190 panel->link->test_video.test_bit_depth); in dp_panel_get_mode_bpp()
203 return -EINVAL; in dp_panel_get_modes()
206 if (dp_panel->drm_edid) in dp_panel_get_modes()
214 edid += edid->extensions; in dp_panel_get_edid_checksum()
216 return edid->checksum; in dp_panel_get_edid_checksum()
230 if (panel->link->sink_request & DP_TEST_LINK_EDID_READ) { in dp_panel_handle_sink_request()
232 const struct edid *edid = drm_edid_raw(dp_panel->drm_edid); in dp_panel_handle_sink_request()
238 checksum = dp_panel->connector->real_edid_checksum; in dp_panel_handle_sink_request()
240 dp_link_send_edid_checksum(panel->link, checksum); in dp_panel_handle_sink_request()
241 dp_link_send_test_response(panel->link); in dp_panel_handle_sink_request()
256 catalog = panel->catalog; in dp_panel_tpg_config()
258 if (!panel->panel_on) { in dp_panel_tpg_config()
259 drm_dbg_dp(panel->drm_dev, in dp_panel_tpg_config()
269 drm_dbg_dp(panel->drm_dev, "calling catalog tpg_enable\n"); in dp_panel_tpg_config()
270 dp_catalog_panel_tpg_enable(catalog, &panel->dp_panel.dp_mode.drm_mode); in dp_panel_tpg_config()
284 return -EINVAL; in dp_panel_setup_vsc_sdp_yuv_420()
288 catalog = panel->catalog; in dp_panel_setup_vsc_sdp_yuv_420()
289 dp_mode = &dp_panel->dp_mode; in dp_panel_setup_vsc_sdp_yuv_420()
293 /* VSC SDP header as per table 2-118 of DP 1.4 specification */ in dp_panel_setup_vsc_sdp_yuv_420()
303 vsc_sdp_data.bpc = dp_mode->bpp / 3; in dp_panel_setup_vsc_sdp_yuv_420()
326 catalog = panel->catalog; in dp_panel_dump_regs()
343 catalog = panel->catalog; in dp_panel_timing_cfg()
344 drm_mode = &panel->dp_panel.dp_mode.drm_mode; in dp_panel_timing_cfg()
346 drm_dbg_dp(panel->drm_dev, "width=%d hporch= %d %d %d\n", in dp_panel_timing_cfg()
347 drm_mode->hdisplay, drm_mode->htotal - drm_mode->hsync_end, in dp_panel_timing_cfg()
348 drm_mode->hsync_start - drm_mode->hdisplay, in dp_panel_timing_cfg()
349 drm_mode->hsync_end - drm_mode->hsync_start); in dp_panel_timing_cfg()
351 drm_dbg_dp(panel->drm_dev, "height=%d vporch= %d %d %d\n", in dp_panel_timing_cfg()
352 drm_mode->vdisplay, drm_mode->vtotal - drm_mode->vsync_end, in dp_panel_timing_cfg()
353 drm_mode->vsync_start - drm_mode->vdisplay, in dp_panel_timing_cfg()
354 drm_mode->vsync_end - drm_mode->vsync_start); in dp_panel_timing_cfg()
356 total_hor = drm_mode->htotal; in dp_panel_timing_cfg()
358 total_ver = drm_mode->vtotal; in dp_panel_timing_cfg()
366 data = (drm_mode->vtotal - drm_mode->vsync_start); in dp_panel_timing_cfg()
368 data |= (drm_mode->htotal - drm_mode->hsync_start); in dp_panel_timing_cfg()
372 data = drm_mode->vsync_end - drm_mode->vsync_start; in dp_panel_timing_cfg()
374 data |= (panel->dp_panel.dp_mode.v_active_low << 31); in dp_panel_timing_cfg()
375 data |= drm_mode->hsync_end - drm_mode->hsync_start; in dp_panel_timing_cfg()
376 data |= (panel->dp_panel.dp_mode.h_active_low << 15); in dp_panel_timing_cfg()
380 data = drm_mode->vdisplay; in dp_panel_timing_cfg()
382 data |= drm_mode->hdisplay; in dp_panel_timing_cfg()
388 if (dp_panel->dp_mode.out_fmt_is_yuv_420) in dp_panel_timing_cfg()
391 panel->panel_on = true; in dp_panel_timing_cfg()
401 drm_mode = &dp_panel->dp_mode.drm_mode; in dp_panel_init_panel_info()
409 drm_dbg_dp(panel->drm_dev, "SET NEW RESOLUTION:\n"); in dp_panel_init_panel_info()
410 drm_dbg_dp(panel->drm_dev, "%dx%d@%dfps\n", in dp_panel_init_panel_info()
411 drm_mode->hdisplay, drm_mode->vdisplay, drm_mode_vrefresh(drm_mode)); in dp_panel_init_panel_info()
412 drm_dbg_dp(panel->drm_dev, in dp_panel_init_panel_info()
414 drm_mode->htotal - drm_mode->hsync_end, in dp_panel_init_panel_info()
415 drm_mode->hsync_start - drm_mode->hdisplay, in dp_panel_init_panel_info()
416 drm_mode->hsync_end - drm_mode->hsync_start); in dp_panel_init_panel_info()
417 drm_dbg_dp(panel->drm_dev, in dp_panel_init_panel_info()
419 drm_mode->vtotal - drm_mode->vsync_end, in dp_panel_init_panel_info()
420 drm_mode->vsync_start - drm_mode->vdisplay, in dp_panel_init_panel_info()
421 drm_mode->vsync_end - drm_mode->vsync_start); in dp_panel_init_panel_info()
422 drm_dbg_dp(panel->drm_dev, "pixel clock (KHz)=(%d)\n", in dp_panel_init_panel_info()
423 drm_mode->clock); in dp_panel_init_panel_info()
424 drm_dbg_dp(panel->drm_dev, "bpp = %d\n", dp_panel->dp_mode.bpp); in dp_panel_init_panel_info()
426 dp_panel->dp_mode.bpp = dp_panel_get_mode_bpp(dp_panel, dp_panel->dp_mode.bpp, in dp_panel_init_panel_info()
427 dp_panel->dp_mode.drm_mode.clock); in dp_panel_init_panel_info()
429 drm_dbg_dp(panel->drm_dev, "updated bpp = %d\n", in dp_panel_init_panel_info()
430 dp_panel->dp_mode.bpp); in dp_panel_init_panel_info()
445 cnt = of_property_count_u64_elems(endpoint, "link-frequencies"); in dp_panel_link_frequencies()
448 of_property_read_u64_index(endpoint, "link-frequencies", in dp_panel_link_frequencies()
449 cnt - 1, &frequency); in dp_panel_link_frequencies()
453 10 * /* from symbol rate to link rate */ in dp_panel_link_frequencies()
466 of_node = panel->dev->of_node; in dp_panel_parse_dt()
469 * data-lanes is the property of dp_out endpoint in dp_panel_parse_dt()
473 /* legacy code, data-lanes is the property of mdss_dp node */ in dp_panel_parse_dt()
478 dp_panel->max_dp_lanes = cnt; in dp_panel_parse_dt()
480 dp_panel->max_dp_lanes = DP_MAX_NUM_DP_LANES; /* 4 lanes */ in dp_panel_parse_dt()
482 dp_panel->max_dp_link_rate = dp_panel_link_frequencies(of_node); in dp_panel_parse_dt()
483 if (!dp_panel->max_dp_link_rate) in dp_panel_parse_dt()
484 dp_panel->max_dp_link_rate = DP_LINK_RATE_HBR2; in dp_panel_parse_dt()
495 if (!in->dev || !in->catalog || !in->aux || !in->link) { in dp_panel_get()
497 return ERR_PTR(-EINVAL); in dp_panel_get()
500 panel = devm_kzalloc(in->dev, sizeof(*panel), GFP_KERNEL); in dp_panel_get()
502 return ERR_PTR(-ENOMEM); in dp_panel_get()
504 panel->dev = in->dev; in dp_panel_get()
505 panel->aux = in->aux; in dp_panel_get()
506 panel->catalog = in->catalog; in dp_panel_get()
507 panel->link = in->link; in dp_panel_get()
509 dp_panel = &panel->dp_panel; in dp_panel_get()
510 dp_panel->max_bw_code = DP_LINK_BW_8_1; in dp_panel_get()
524 drm_edid_free(dp_panel->drm_edid); in dp_panel_put()