drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c
Extension
.c
Size
5180 bytes
Lines
191
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct inno_hdmi_connector_state {
	struct drm_connector_state	base;
	unsigned int			colorimetry;
};

struct rockchip_inno_hdmi {
	struct inno_hdmi *base;
	struct device *dev;
	struct regmap *grf;
	struct rockchip_encoder encoder;
};

static struct inno_hdmi_phy_config rk3036_hdmi_phy_configs[] = {
	{  74250000, 0x3f, 0xbb },
	{ 165000000, 0x6f, 0xbb },
	{      ~0UL, 0x00, 0x00 }
};

static struct inno_hdmi_phy_config rk3128_hdmi_phy_configs[] = {
	{  74250000, 0x3f, 0xaa },
	{ 165000000, 0x5f, 0xaa },
	{      ~0UL, 0x00, 0x00 }
};

static void inno_hdmi_rk3036_enable(struct device *dev, struct drm_display_mode *mode)
{
	struct rockchip_inno_hdmi *hdmi = dev_get_drvdata(dev);
	int value, psync;

	psync = mode->flags & DRM_MODE_FLAG_PHSYNC ? 1 : 0;
	value = FIELD_PREP_WM16(RK3036_HDMI_PHSYNC, psync);
	psync = mode->flags & DRM_MODE_FLAG_PVSYNC ? 1 : 0;
	value |= FIELD_PREP_WM16(RK3036_HDMI_PVSYNC, psync);
	regmap_write(hdmi->grf, RK3036_GRF_SOC_CON2, value);
}

static int inno_hdmi_encoder_atomic_check(struct drm_encoder *encoder,
					  struct drm_crtc_state *crtc_state,
					  struct drm_connector_state *conn_state)
{
	struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state);

	s->output_mode = ROCKCHIP_OUT_MODE_P888;
	s->output_type = DRM_MODE_CONNECTOR_HDMIA;

	return 0;
}

static const struct drm_encoder_helper_funcs inno_hdmi_rockchip_encoder_helper_funcs = {
	.atomic_check	= inno_hdmi_encoder_atomic_check,
};

static int inno_hdmi_rockchip_bind(struct device *dev, struct device *master, void *data)
{
	struct drm_device *drm = data;
	struct drm_connector *connector;
	struct drm_encoder *encoder;
	struct rockchip_inno_hdmi *hdmi;
	const struct inno_hdmi_plat_data *plat_data;
	int ret;

	hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL);
	if (!hdmi)
		return -ENOMEM;

	hdmi->dev = dev;

	plat_data = of_device_get_match_data(hdmi->dev);
	if (!plat_data)
		return -EINVAL;

	if (of_device_is_compatible(dev->of_node, "rockchip,rk3036-inno-hdmi")) {
		hdmi->grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,grf");
		if (IS_ERR(hdmi->grf))
			return dev_err_probe(dev,
					     PTR_ERR(hdmi->grf), "Unable to get rockchip,grf\n");
	}

	encoder = &hdmi->encoder.encoder;
	encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);

	/*
	 * If we failed to find the CRTC(s) which this encoder is
	 * supposed to be connected to, it's because the CRTC has
	 * not been registered yet.  Defer probing, and hope that
	 * the required CRTC is added later.
	 */
	if (encoder->possible_crtcs == 0)
		return -EPROBE_DEFER;

Annotation

Implementation Notes