drivers/gpu/drm/mediatek/mtk_hdmi_v2.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_hdmi_v2.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c
Extension
.c
Size
45060 bytes
Lines
1531
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations mtk_hdmi_debug_abist_fops = {
	.owner = THIS_MODULE,
	.open = mtk_hdmi_v2_debug_abist_open,
	.read = seq_read,
	.write = mtk_hdmi_v2_debug_abist_write,
	.llseek = seq_lseek,
	.release = single_release,
};

static void mtk_hdmi_v2_debugfs_init(struct drm_bridge *bridge, struct dentry *root)
{
	struct mtk_hdmi *dpi = hdmi_ctx_from_bridge(bridge);

	debugfs_create_file("hdmi_abist", 0640, root, dpi, &mtk_hdmi_debug_abist_fops);
}

static const struct drm_bridge_funcs mtk_v2_hdmi_bridge_funcs = {
	.attach = mtk_hdmi_v2_bridge_attach,
	.detach = mtk_hdmi_v2_bridge_detach,
	.mode_fixup = mtk_hdmi_bridge_mode_fixup,
	.mode_set = mtk_hdmi_bridge_mode_set,
	.atomic_pre_enable = mtk_hdmi_v2_bridge_pre_enable,
	.atomic_enable = mtk_hdmi_v2_bridge_enable,
	.atomic_disable = mtk_hdmi_v2_bridge_disable,
	.atomic_post_disable = mtk_hdmi_v2_bridge_post_disable,
	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
	.atomic_reset = drm_atomic_helper_bridge_reset,
	.detect = mtk_hdmi_v2_bridge_detect,
	.edid_read = mtk_hdmi_v2_bridge_edid_read,
	.hpd_enable = mtk_hdmi_v2_hpd_enable,
	.hpd_disable = mtk_hdmi_v2_hpd_disable,
	.hdmi_tmds_char_rate_valid = mtk_hdmi_v2_hdmi_tmds_char_rate_valid,
	.hdmi_clear_audio_infoframe = mtk_hdmi_v2_hdmi_clear_audio_infoframe,
	.hdmi_write_audio_infoframe = mtk_hdmi_v2_hdmi_write_audio_infoframe,
	.hdmi_clear_avi_infoframe = mtk_hdmi_v2_hdmi_clear_avi_infoframe,
	.hdmi_write_avi_infoframe = mtk_hdmi_v2_hdmi_write_avi_infoframe,
	.hdmi_clear_spd_infoframe = mtk_hdmi_v2_hdmi_clear_spd_infoframe,
	.hdmi_write_spd_infoframe = mtk_hdmi_v2_hdmi_write_spd_infoframe,
	.hdmi_clear_hdmi_infoframe = mtk_hdmi_v2_hdmi_clear_hdmi_infoframe,
	.hdmi_write_hdmi_infoframe = mtk_hdmi_v2_hdmi_write_hdmi_infoframe,
	.debugfs_init = mtk_hdmi_v2_debugfs_init,
};

/*
 * HDMI audio codec callbacks
 */
static int mtk_hdmi_v2_audio_hook_plugged_cb(struct device *dev, void *data,
					     hdmi_codec_plugged_cb fn,
					     struct device *codec_dev)
{
	struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
	bool plugged;

	if (!hdmi)
		return -ENODEV;

	mtk_hdmi_audio_set_plugged_cb(hdmi, fn, codec_dev);
	plugged = (hdmi->hpd == HDMI_PLUG_IN_AND_SINK_POWER_ON);
	mtk_hdmi_v2_handle_plugged_change(hdmi, plugged);

	return 0;
}

static int mtk_hdmi_v2_audio_hw_params(struct device *dev, void *data,
				       struct hdmi_codec_daifmt *daifmt,
				       struct hdmi_codec_params *params)
{
	struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

	if (hdmi->audio_enable) {
		mtk_hdmi_audio_params(hdmi, daifmt, params);
		mtk_hdmi_v2_aud_output_config(hdmi, &hdmi->mode);
	}
	return 0;
}

static int mtk_hdmi_v2_audio_startup(struct device *dev, void *data)
{
	struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

	mtk_hdmi_v2_hw_aud_enable(hdmi, true);
	hdmi->audio_enable = true;

	return 0;
}

static void mtk_hdmi_v2_audio_shutdown(struct device *dev, void *data)
{
	struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

Annotation

Implementation Notes