/* initialize bridge */ struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi) { struct drm_bridge *bridge = NULL; struct hdmi_bridge *hdmi_bridge; int ret; hdmi_bridge = kzalloc(sizeof(*hdmi_bridge), GFP_KERNEL); if (!hdmi_bridge) { ret = -ENOMEM; goto fail; } hdmi_bridge->hdmi = hdmi_reference(hdmi); bridge = &hdmi_bridge->base; drm_bridge_init(hdmi->dev, bridge, &hdmi_bridge_funcs); return bridge; fail: if (bridge) hdmi_bridge_destroy(bridge); return ERR_PTR(ret); }
/* initialize connector */ struct drm_connector *hdmi_connector_init(struct hdmi *hdmi) { struct drm_connector *connector = NULL; struct hdmi_connector *hdmi_connector; int ret; hdmi_connector = kzalloc(sizeof(*hdmi_connector), GFP_KERNEL); if (!hdmi_connector) { ret = -ENOMEM; goto fail; } hdmi_connector->hdmi = hdmi_reference(hdmi); INIT_WORK(&hdmi_connector->hpd_work, hotplug_work); connector = &hdmi_connector->base; drm_connector_init(hdmi->dev, connector, &hdmi_connector_funcs, DRM_MODE_CONNECTOR_HDMIA); drm_connector_helper_add(connector, &hdmi_connector_helper_funcs); connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; connector->interlace_allowed = 1; connector->doublescan_allowed = 0; drm_sysfs_connector_add(connector); ret = hpd_enable(hdmi_connector); if (ret) { dev_err(hdmi->dev->dev, "failed to enable HPD: %d\n", ret); goto fail; } drm_mode_connector_attach_encoder(connector, hdmi->encoder); return connector; fail: if (connector) hdmi_connector_destroy(connector); return ERR_PTR(ret); }