drivers/gpu/drm/mediatek/mtk_hdmi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_hdmi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_hdmi.c- Extension
.c- Size
- 33651 bytes
- Lines
- 1250
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/arm-smccc.hlinux/clk.hlinux/delay.hlinux/hdmi.hlinux/i2c.hlinux/io.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/mutex.hlinux/of_platform.hlinux/of.hlinux/of_graph.hlinux/phy/phy.hlinux/platform_device.hlinux/regmap.hsound/hdmi-codec.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_crtc.hdrm/drm_edid.hdrm/drm_print.hdrm/drm_probe_helper.hmtk_cec.hmtk_hdmi_common.hmtk_hdmi_regs.h
Detected Declarations
enum mtk_hdmi_clk_idfunction mtk_hdmi_hw_vid_blackfunction mtk_hdmi_hw_make_reg_writablefunction mtk_hdmi_hw_1p4_version_enablefunction mtk_hdmi_hw_aud_mutefunction mtk_hdmi_hw_aud_unmutefunction mtk_hdmi_hw_resetfunction mtk_hdmi_hw_enable_noticefunction mtk_hdmi_hw_write_int_maskfunction mtk_hdmi_hw_enable_dvi_modefunction mtk_hdmi_hw_send_info_framefunction mtk_hdmi_hw_send_aud_packetfunction mtk_hdmi_hw_config_sysfunction mtk_hdmi_hw_set_deep_color_modefunction mtk_hdmi_hw_send_av_mutefunction mtk_hdmi_hw_send_av_unmutefunction mtk_hdmi_hw_ncts_enablefunction mtk_hdmi_hw_ncts_auto_write_enablefunction mtk_hdmi_hw_msic_settingfunction mtk_hdmi_hw_aud_set_channel_swapfunction mtk_hdmi_hw_aud_set_bit_numfunction mtk_hdmi_hw_aud_set_i2s_fmtfunction mtk_hdmi_hw_audio_configfunction mtk_hdmi_hw_aud_set_i2s_chan_numfunction mtk_hdmi_hw_aud_set_input_typefunction mtk_hdmi_hw_aud_set_channel_statusfunction mtk_hdmi_hw_aud_src_reenablefunction mtk_hdmi_hw_aud_src_disablefunction mtk_hdmi_hw_aud_set_mclkfunction do_hdmi_hw_aud_set_nctsfunction mtk_hdmi_hw_aud_set_nctsfunction mtk_hdmi_aud_get_chnl_countfunction mtk_hdmi_video_change_vpllfunction mtk_hdmi_video_set_display_modefunction mtk_hdmi_aud_set_inputfunction mtk_hdmi_aud_set_srcfunction mtk_hdmi_aud_output_configfunction mtk_hdmi_setup_avi_infoframefunction mtk_hdmi_setup_spd_infoframefunction mtk_hdmi_setup_audio_infoframefunction mtk_hdmi_setup_vendor_specific_infoframefunction mtk_hdmi_audio_enablefunction mtk_hdmi_audio_disablefunction mtk_hdmi_output_set_display_modefunction mtk_hdmi_clk_enable_audiofunction mtk_hdmi_clk_disable_audiofunction mtk_hdmi_update_plugged_statusfunction mtk_hdmi_detect
Annotated Snippet
switch (sample_rate) {
case 32000:
case 44100:
case 48000:
case 88200:
case 96000:
break;
default:
return -EINVAL;
}
mtk_hdmi_hw_aud_set_mclk(hdmi, hdmi->aud_param.aud_mclk);
} else {
switch (sample_rate) {
case 32000:
case 44100:
case 48000:
break;
default:
return -EINVAL;
}
mtk_hdmi_hw_aud_set_mclk(hdmi, HDMI_AUD_MCLK_128FS);
}
mtk_hdmi_hw_aud_set_ncts(hdmi, sample_rate, display_mode->clock);
mtk_hdmi_hw_aud_src_reenable(hdmi);
return 0;
}
static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi,
struct drm_display_mode *display_mode)
{
mtk_hdmi_hw_aud_mute(hdmi);
mtk_hdmi_hw_send_aud_packet(hdmi, false);
mtk_hdmi_aud_set_input(hdmi);
mtk_hdmi_aud_set_src(hdmi, display_mode);
mtk_hdmi_hw_aud_set_channel_status(hdmi,
hdmi->aud_param.codec_params.iec.status);
usleep_range(50, 100);
mtk_hdmi_hw_ncts_enable(hdmi, true);
mtk_hdmi_hw_send_aud_packet(hdmi, true);
mtk_hdmi_hw_aud_unmute(hdmi);
return 0;
}
static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi,
struct drm_display_mode *mode)
{
struct hdmi_avi_infoframe frame;
u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
ssize_t err;
err = drm_hdmi_avi_infoframe_from_display_mode(&frame,
hdmi->curr_conn, mode);
if (err < 0) {
dev_err(hdmi->dev,
"Failed to get AVI infoframe from mode: %zd\n", err);
return err;
}
err = hdmi_avi_infoframe_pack(&frame, buffer, sizeof(buffer));
if (err < 0) {
dev_err(hdmi->dev, "Failed to pack AVI infoframe: %zd\n", err);
return err;
}
mtk_hdmi_hw_send_info_frame(hdmi, buffer, sizeof(buffer));
return 0;
}
static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi)
{
struct drm_bridge *bridge = &hdmi->bridge;
struct hdmi_spd_infoframe frame;
u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_SPD_INFOFRAME_SIZE];
ssize_t err;
err = hdmi_spd_infoframe_init(&frame, bridge->vendor, bridge->product);
if (err < 0) {
dev_err(hdmi->dev, "Failed to initialize SPD infoframe: %zd\n",
err);
return err;
}
err = hdmi_spd_infoframe_pack(&frame, buffer, sizeof(buffer));
if (err < 0) {
dev_err(hdmi->dev, "Failed to pack SDP infoframe: %zd\n", err);
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/clk.h`, `linux/delay.h`, `linux/hdmi.h`, `linux/i2c.h`, `linux/io.h`, `linux/kernel.h`, `linux/mfd/syscon.h`.
- Detected declarations: `enum mtk_hdmi_clk_id`, `function mtk_hdmi_hw_vid_black`, `function mtk_hdmi_hw_make_reg_writable`, `function mtk_hdmi_hw_1p4_version_enable`, `function mtk_hdmi_hw_aud_mute`, `function mtk_hdmi_hw_aud_unmute`, `function mtk_hdmi_hw_reset`, `function mtk_hdmi_hw_enable_notice`, `function mtk_hdmi_hw_write_int_mask`, `function mtk_hdmi_hw_enable_dvi_mode`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.