Lines Matching +full:hdmi +full:- +full:connector

1 // SPDX-License-Identifier: MIT
12 * __drm_atomic_helper_connector_hdmi_reset() - Initializes all HDMI @drm_connector_state resources
13 * @connector: DRM connector
14 * @new_conn_state: connector state to reset
16 * Initializes all HDMI resources from a @drm_connector_state without
17 * actually allocating it. This is useful for HDMI drivers, in
21 void __drm_atomic_helper_connector_hdmi_reset(struct drm_connector *connector, in __drm_atomic_helper_connector_hdmi_reset() argument
24 unsigned int max_bpc = connector->max_bpc; in __drm_atomic_helper_connector_hdmi_reset()
26 new_conn_state->max_bpc = max_bpc; in __drm_atomic_helper_connector_hdmi_reset()
27 new_conn_state->max_requested_bpc = max_bpc; in __drm_atomic_helper_connector_hdmi_reset()
28 new_conn_state->hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; in __drm_atomic_helper_connector_hdmi_reset()
39 state = conn_state->state; in connector_state_get_mode()
43 crtc = conn_state->crtc; in connector_state_get_mode()
51 return &crtc_state->mode; in connector_state_get_mode()
54 static bool hdmi_is_limited_range(const struct drm_connector *connector, in hdmi_is_limited_range() argument
57 const struct drm_display_info *info = &connector->display_info; in hdmi_is_limited_range()
66 if (conn_state->hdmi.output_format != HDMI_COLORSPACE_RGB) in hdmi_is_limited_range()
69 if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_FULL) in hdmi_is_limited_range()
72 if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) in hdmi_is_limited_range()
75 if (!info->is_hdmi) in hdmi_is_limited_range()
82 sink_supports_format_bpc(const struct drm_connector *connector, in sink_supports_format_bpc() argument
87 struct drm_device *dev = connector->dev; in sink_supports_format_bpc()
91 * CTA-861-F, section 5.4 - Color Coding & Quantization states in sink_supports_format_bpc()
105 if (!info->is_hdmi && in sink_supports_format_bpc()
111 if (!(connector->hdmi.supported_formats & BIT(format))) { in sink_supports_format_bpc()
112 drm_dbg_kms(dev, "%s format unsupported by the connector.\n", in sink_supports_format_bpc()
123 * is not an HDMI compliant EDID for some reason, the in sink_supports_format_bpc()
129 if (!(info->color_formats & DRM_COLOR_FORMAT_RGB444)) in sink_supports_format_bpc()
130 drm_warn(dev, "HDMI Sink doesn't support RGB, something's wrong.\n"); in sink_supports_format_bpc()
132 if (bpc == 10 && !(info->edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_30)) { in sink_supports_format_bpc()
137 if (bpc == 12 && !(info->edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_36)) { in sink_supports_format_bpc()
154 if (!(info->color_formats & DRM_COLOR_FORMAT_YCBCR422)) { in sink_supports_format_bpc()
165 * HDMI Spec 1.3 - Section 6.5 Pixel Encodings and Color Depth in sink_supports_format_bpc()
177 if (!(info->color_formats & DRM_COLOR_FORMAT_YCBCR444)) { in sink_supports_format_bpc()
182 if (bpc == 10 && !(info->edid_hdmi_ycbcr444_dc_modes & DRM_EDID_HDMI_DC_30)) { in sink_supports_format_bpc()
187 if (bpc == 12 && !(info->edid_hdmi_ycbcr444_dc_modes & DRM_EDID_HDMI_DC_36)) { in sink_supports_format_bpc()
202 hdmi_clock_valid(const struct drm_connector *connector, in hdmi_clock_valid() argument
206 const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs; in hdmi_clock_valid()
207 const struct drm_display_info *info = &connector->display_info; in hdmi_clock_valid()
209 if (info->max_tmds_clock && clock > info->max_tmds_clock * 1000) in hdmi_clock_valid()
212 if (funcs && funcs->tmds_char_rate_valid) { in hdmi_clock_valid()
215 status = funcs->tmds_char_rate_valid(connector, mode, clock); in hdmi_clock_valid()
224 hdmi_compute_clock(const struct drm_connector *connector, in hdmi_compute_clock() argument
234 return -EINVAL; in hdmi_compute_clock()
236 status = hdmi_clock_valid(connector, mode, clock); in hdmi_compute_clock()
238 return -EINVAL; in hdmi_compute_clock()
240 conn_state->hdmi.tmds_char_rate = clock; in hdmi_compute_clock()
246 hdmi_try_format_bpc(const struct drm_connector *connector, in hdmi_try_format_bpc() argument
251 const struct drm_display_info *info = &connector->display_info; in hdmi_try_format_bpc()
252 struct drm_device *dev = connector->dev; in hdmi_try_format_bpc()
258 if (!sink_supports_format_bpc(connector, info, mode, fmt, bpc)) { in hdmi_try_format_bpc()
265 ret = hdmi_compute_clock(connector, conn_state, mode, bpc, fmt); in hdmi_try_format_bpc()
275 bpc, conn_state->hdmi.tmds_char_rate); in hdmi_try_format_bpc()
281 hdmi_compute_format(const struct drm_connector *connector, in hdmi_compute_format() argument
286 struct drm_device *dev = connector->dev; in hdmi_compute_format()
289 * TODO: Add support for YCbCr420 output for HDMI 2.0 capable in hdmi_compute_format()
292 if (hdmi_try_format_bpc(connector, conn_state, mode, bpc, HDMI_COLORSPACE_RGB)) { in hdmi_compute_format()
293 conn_state->hdmi.output_format = HDMI_COLORSPACE_RGB; in hdmi_compute_format()
299 return -EINVAL; in hdmi_compute_format()
303 hdmi_compute_config(const struct drm_connector *connector, in hdmi_compute_config() argument
307 struct drm_device *dev = connector->dev; in hdmi_compute_config()
309 conn_state->max_bpc, in hdmi_compute_config()
310 8, connector->max_bpc); in hdmi_compute_config()
314 for (bpc = max_bpc; bpc >= 8; bpc -= 2) { in hdmi_compute_config()
317 ret = hdmi_compute_format(connector, conn_state, mode, bpc); in hdmi_compute_config()
321 conn_state->hdmi.output_bpc = bpc; in hdmi_compute_config()
325 mode->hdisplay, mode->vdisplay, drm_mode_vrefresh(mode), in hdmi_compute_config()
326 conn_state->hdmi.output_bpc, in hdmi_compute_config()
327 drm_hdmi_connector_get_output_format_name(conn_state->hdmi.output_format), in hdmi_compute_config()
328 conn_state->hdmi.tmds_char_rate); in hdmi_compute_config()
333 return -EINVAL; in hdmi_compute_config()
336 static int hdmi_generate_avi_infoframe(const struct drm_connector *connector, in hdmi_generate_avi_infoframe() argument
342 &conn_state->hdmi.infoframes.avi; in hdmi_generate_avi_infoframe()
344 &infoframe->data.avi; in hdmi_generate_avi_infoframe()
345 bool is_limited_range = conn_state->hdmi.is_limited_range; in hdmi_generate_avi_infoframe()
350 ret = drm_hdmi_avi_infoframe_from_display_mode(frame, connector, mode); in hdmi_generate_avi_infoframe()
354 frame->colorspace = conn_state->hdmi.output_format; in hdmi_generate_avi_infoframe()
361 drm_hdmi_avi_infoframe_quant_range(frame, connector, mode, rgb_quant_range); in hdmi_generate_avi_infoframe()
365 infoframe->set = true; in hdmi_generate_avi_infoframe()
370 static int hdmi_generate_spd_infoframe(const struct drm_connector *connector, in hdmi_generate_spd_infoframe() argument
374 &conn_state->hdmi.infoframes.spd; in hdmi_generate_spd_infoframe()
376 &infoframe->data.spd; in hdmi_generate_spd_infoframe()
380 connector->hdmi.vendor, in hdmi_generate_spd_infoframe()
381 connector->hdmi.product); in hdmi_generate_spd_infoframe()
385 frame->sdi = HDMI_SPD_SDI_PC; in hdmi_generate_spd_infoframe()
387 infoframe->set = true; in hdmi_generate_spd_infoframe()
392 static int hdmi_generate_hdr_infoframe(const struct drm_connector *connector, in hdmi_generate_hdr_infoframe() argument
396 &conn_state->hdmi.infoframes.hdr_drm; in hdmi_generate_hdr_infoframe()
398 &infoframe->data.drm; in hdmi_generate_hdr_infoframe()
401 if (connector->max_bpc < 10) in hdmi_generate_hdr_infoframe()
404 if (!conn_state->hdr_output_metadata) in hdmi_generate_hdr_infoframe()
411 infoframe->set = true; in hdmi_generate_hdr_infoframe()
416 static int hdmi_generate_hdmi_vendor_infoframe(const struct drm_connector *connector, in hdmi_generate_hdmi_vendor_infoframe() argument
419 const struct drm_display_info *info = &connector->display_info; in hdmi_generate_hdmi_vendor_infoframe()
423 &conn_state->hdmi.infoframes.hdmi; in hdmi_generate_hdmi_vendor_infoframe()
425 &infoframe->data.vendor.hdmi; in hdmi_generate_hdmi_vendor_infoframe()
428 if (!info->has_hdmi_infoframe) in hdmi_generate_hdmi_vendor_infoframe()
431 ret = drm_hdmi_vendor_infoframe_from_display_mode(frame, connector, mode); in hdmi_generate_hdmi_vendor_infoframe()
435 infoframe->set = true; in hdmi_generate_hdmi_vendor_infoframe()
441 hdmi_generate_infoframes(const struct drm_connector *connector, in hdmi_generate_infoframes() argument
444 const struct drm_display_info *info = &connector->display_info; in hdmi_generate_infoframes()
447 if (!info->is_hdmi) in hdmi_generate_infoframes()
450 ret = hdmi_generate_avi_infoframe(connector, conn_state); in hdmi_generate_infoframes()
454 ret = hdmi_generate_spd_infoframe(connector, conn_state); in hdmi_generate_infoframes()
463 ret = hdmi_generate_hdr_infoframe(connector, conn_state); in hdmi_generate_infoframes()
467 ret = hdmi_generate_hdmi_vendor_infoframe(connector, conn_state); in hdmi_generate_infoframes()
475 * drm_atomic_helper_connector_hdmi_check() - Helper to check HDMI connector atomic state
476 * @connector: DRM Connector
479 * Provides a default connector state check handler for HDMI connectors.
480 * Checks that a desired connector update is valid, and updates various
486 int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, in drm_atomic_helper_connector_hdmi_check() argument
490 drm_atomic_get_old_connector_state(state, connector); in drm_atomic_helper_connector_hdmi_check()
492 drm_atomic_get_new_connector_state(state, connector); in drm_atomic_helper_connector_hdmi_check()
497 new_conn_state->hdmi.is_limited_range = hdmi_is_limited_range(connector, new_conn_state); in drm_atomic_helper_connector_hdmi_check()
499 ret = hdmi_compute_config(connector, new_conn_state, mode); in drm_atomic_helper_connector_hdmi_check()
503 ret = hdmi_generate_infoframes(connector, new_conn_state); in drm_atomic_helper_connector_hdmi_check()
507 if (old_conn_state->hdmi.broadcast_rgb != new_conn_state->hdmi.broadcast_rgb || in drm_atomic_helper_connector_hdmi_check()
508 old_conn_state->hdmi.output_bpc != new_conn_state->hdmi.output_bpc || in drm_atomic_helper_connector_hdmi_check()
509 old_conn_state->hdmi.output_format != new_conn_state->hdmi.output_format) { in drm_atomic_helper_connector_hdmi_check()
510 struct drm_crtc *crtc = new_conn_state->crtc; in drm_atomic_helper_connector_hdmi_check()
517 crtc_state->mode_changed = true; in drm_atomic_helper_connector_hdmi_check()
524 static int clear_device_infoframe(struct drm_connector *connector, in clear_device_infoframe() argument
527 const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs; in clear_device_infoframe()
528 struct drm_device *dev = connector->dev; in clear_device_infoframe()
533 if (!funcs || !funcs->clear_infoframe) { in clear_device_infoframe()
538 ret = funcs->clear_infoframe(connector, type); in clear_device_infoframe()
547 static int clear_infoframe(struct drm_connector *connector, in clear_infoframe() argument
552 ret = clear_device_infoframe(connector, old_frame->data.any.type); in clear_infoframe()
559 static int write_device_infoframe(struct drm_connector *connector, in write_device_infoframe() argument
562 const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs; in write_device_infoframe()
563 struct drm_device *dev = connector->dev; in write_device_infoframe()
568 drm_dbg_kms(dev, "Writing infoframe type %x\n", frame->any.type); in write_device_infoframe()
570 if (!funcs || !funcs->write_infoframe) { in write_device_infoframe()
572 return -EINVAL; in write_device_infoframe()
579 ret = funcs->write_infoframe(connector, frame->any.type, buffer, len); in write_device_infoframe()
588 static int write_infoframe(struct drm_connector *connector, in write_infoframe() argument
593 ret = write_device_infoframe(connector, &new_frame->data); in write_infoframe()
600 static int write_or_clear_infoframe(struct drm_connector *connector, in write_or_clear_infoframe() argument
604 if (new_frame->set) in write_or_clear_infoframe()
605 return write_infoframe(connector, new_frame); in write_or_clear_infoframe()
607 if (old_frame->set && !new_frame->set) in write_or_clear_infoframe()
608 return clear_infoframe(connector, old_frame); in write_or_clear_infoframe()
614 * drm_atomic_helper_connector_hdmi_update_infoframes - Update the Infoframes
615 * @connector: A pointer to the HDMI connector
616 * @state: The HDMI connector state to generate the infoframe from
618 * This function is meant for HDMI connector drivers to write their
625 int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *connector, in drm_atomic_helper_connector_hdmi_update_infoframes() argument
629 drm_atomic_get_old_connector_state(state, connector); in drm_atomic_helper_connector_hdmi_update_infoframes()
631 drm_atomic_get_new_connector_state(state, connector); in drm_atomic_helper_connector_hdmi_update_infoframes()
632 struct drm_display_info *info = &connector->display_info; in drm_atomic_helper_connector_hdmi_update_infoframes()
635 if (!info->is_hdmi) in drm_atomic_helper_connector_hdmi_update_infoframes()
638 mutex_lock(&connector->hdmi.infoframes.lock); in drm_atomic_helper_connector_hdmi_update_infoframes()
640 ret = write_or_clear_infoframe(connector, in drm_atomic_helper_connector_hdmi_update_infoframes()
641 &old_conn_state->hdmi.infoframes.avi, in drm_atomic_helper_connector_hdmi_update_infoframes()
642 &new_conn_state->hdmi.infoframes.avi); in drm_atomic_helper_connector_hdmi_update_infoframes()
646 if (connector->hdmi.infoframes.audio.set) { in drm_atomic_helper_connector_hdmi_update_infoframes()
647 ret = write_infoframe(connector, in drm_atomic_helper_connector_hdmi_update_infoframes()
648 &connector->hdmi.infoframes.audio); in drm_atomic_helper_connector_hdmi_update_infoframes()
653 ret = write_or_clear_infoframe(connector, in drm_atomic_helper_connector_hdmi_update_infoframes()
654 &old_conn_state->hdmi.infoframes.hdr_drm, in drm_atomic_helper_connector_hdmi_update_infoframes()
655 &new_conn_state->hdmi.infoframes.hdr_drm); in drm_atomic_helper_connector_hdmi_update_infoframes()
659 ret = write_or_clear_infoframe(connector, in drm_atomic_helper_connector_hdmi_update_infoframes()
660 &old_conn_state->hdmi.infoframes.spd, in drm_atomic_helper_connector_hdmi_update_infoframes()
661 &new_conn_state->hdmi.infoframes.spd); in drm_atomic_helper_connector_hdmi_update_infoframes()
665 if (info->has_hdmi_infoframe) { in drm_atomic_helper_connector_hdmi_update_infoframes()
666 ret = write_or_clear_infoframe(connector, in drm_atomic_helper_connector_hdmi_update_infoframes()
667 &old_conn_state->hdmi.infoframes.hdmi, in drm_atomic_helper_connector_hdmi_update_infoframes()
668 &new_conn_state->hdmi.infoframes.hdmi); in drm_atomic_helper_connector_hdmi_update_infoframes()
674 mutex_unlock(&connector->hdmi.infoframes.lock); in drm_atomic_helper_connector_hdmi_update_infoframes()
680 * drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe
681 * @connector: A pointer to the HDMI connector
684 * This function is meant for HDMI connector drivers to update their
692 drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *connector, in drm_atomic_helper_connector_hdmi_update_audio_infoframe() argument
696 &connector->hdmi.infoframes.audio; in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
697 struct drm_display_info *info = &connector->display_info; in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
700 if (!info->is_hdmi) in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
703 mutex_lock(&connector->hdmi.infoframes.lock); in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
705 memcpy(&infoframe->data, frame, sizeof(infoframe->data)); in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
706 infoframe->set = true; in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
708 ret = write_infoframe(connector, infoframe); in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
710 mutex_unlock(&connector->hdmi.infoframes.lock); in drm_atomic_helper_connector_hdmi_update_audio_infoframe()
717 * drm_atomic_helper_connector_hdmi_clear_audio_infoframe - Stop sending the Audio Infoframe
718 * @connector: A pointer to the HDMI connector
720 * This function is meant for HDMI connector drivers to stop sending their
728 drm_atomic_helper_connector_hdmi_clear_audio_infoframe(struct drm_connector *connector) in drm_atomic_helper_connector_hdmi_clear_audio_infoframe() argument
731 &connector->hdmi.infoframes.audio; in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()
732 struct drm_display_info *info = &connector->display_info; in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()
735 if (!info->is_hdmi) in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()
738 mutex_lock(&connector->hdmi.infoframes.lock); in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()
740 infoframe->set = false; in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()
742 ret = clear_infoframe(connector, infoframe); in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()
744 memset(&infoframe->data, 0, sizeof(infoframe->data)); in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()
746 mutex_unlock(&connector->hdmi.infoframes.lock); in drm_atomic_helper_connector_hdmi_clear_audio_infoframe()