In order to use HDMI connector extensions from the bridge drivers, carve out the drm_connector_hdmi_setup() from drmm_connector_hdmi_init(). This way the drm_bridge drivers can call new function from their setup_connector callbacks. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx> --- drivers/gpu/drm/drm_connector.c | 67 ++++++++++++++++++++++++++++++----------- include/drm/drm_connector.h | 5 +++ 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 427816239038..ba953eb45557 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -454,15 +454,11 @@ int drmm_connector_init(struct drm_device *dev, EXPORT_SYMBOL(drmm_connector_init); /** - * drmm_connector_hdmi_init - Init a preallocated HDMI connector - * @dev: DRM device + * drm_connector_hdmi_setup - Init a preallocated HDMI connector * @connector: A pointer to the HDMI connector to init * @vendor: HDMI Controller Vendor name * @product: HDMI Controller Product name - * @funcs: callbacks for this connector * @hdmi_funcs: HDMI-related callbacks for this connector - * @connector_type: user visible type of the connector - * @ddc: optional pointer to the associated ddc adapter * @supported_formats: Bitmask of @hdmi_colorspace listing supported output formats * @max_bpc: Maximum bits per char the HDMI connector supports * @@ -477,18 +473,12 @@ EXPORT_SYMBOL(drmm_connector_init); * Returns: * Zero on success, error code on failure. */ -int drmm_connector_hdmi_init(struct drm_device *dev, - struct drm_connector *connector, +int drm_connector_hdmi_setup(struct drm_connector *connector, const char *vendor, const char *product, - const struct drm_connector_funcs *funcs, const struct drm_connector_hdmi_funcs *hdmi_funcs, - int connector_type, - struct i2c_adapter *ddc, unsigned long supported_formats, unsigned int max_bpc) { - int ret; - if (!vendor || !product) return -EINVAL; @@ -496,8 +486,8 @@ int drmm_connector_hdmi_init(struct drm_device *dev, (strlen(product) > DRM_CONNECTOR_HDMI_PRODUCT_LEN)) return -EINVAL; - if (!(connector_type == DRM_MODE_CONNECTOR_HDMIA || - connector_type == DRM_MODE_CONNECTOR_HDMIB)) + if (connector->connector_type != DRM_MODE_CONNECTOR_HDMIA && + connector->connector_type != DRM_MODE_CONNECTOR_HDMIB) return -EINVAL; if (!supported_formats || !(supported_formats & BIT(HDMI_COLORSPACE_RGB))) @@ -506,10 +496,6 @@ int drmm_connector_hdmi_init(struct drm_device *dev, if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12)) return -EINVAL; - ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); - if (ret) - return ret; - connector->hdmi.supported_formats = supported_formats; strtomem_pad(connector->hdmi.vendor, vendor, 0); strtomem_pad(connector->hdmi.product, product, 0); @@ -531,6 +517,51 @@ int drmm_connector_hdmi_init(struct drm_device *dev, return 0; } +EXPORT_SYMBOL(drm_connector_hdmi_setup); + +/** + * drmm_connector_hdmi_init - Init a preallocated HDMI connector + * @dev: DRM device + * @connector: A pointer to the HDMI connector to init + * @vendor: HDMI Controller Vendor name + * @product: HDMI Controller Product name + * @funcs: callbacks for this connector + * @hdmi_funcs: HDMI-related callbacks for this connector + * @connector_type: user visible type of the connector + * @ddc: optional pointer to the associated ddc adapter + * @supported_formats: Bitmask of @hdmi_colorspace listing supported output formats + * @max_bpc: Maximum bits per char the HDMI connector supports + * + * Initialises a preallocated HDMI connector. Connectors can be + * subclassed as part of driver connector objects. + * + * Cleanup is automatically handled with a call to + * drm_connector_cleanup() in a DRM-managed action. + * + * The connector structure should be allocated with drmm_kzalloc(). + * + * Returns: + * Zero on success, error code on failure. + */ +int drmm_connector_hdmi_init(struct drm_device *dev, + struct drm_connector *connector, + const char *vendor, const char *product, + const struct drm_connector_funcs *funcs, + const struct drm_connector_hdmi_funcs *hdmi_funcs, + int connector_type, + struct i2c_adapter *ddc, + unsigned long supported_formats, + unsigned int max_bpc) +{ + int ret; + + ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); + if (ret) + return ret; + + return drm_connector_hdmi_setup(connector, vendor, product, hdmi_funcs, + supported_formats, max_bpc); +} EXPORT_SYMBOL(drmm_connector_hdmi_init); /** diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 5964ef283022..37d54d5ff0d6 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -2156,6 +2156,11 @@ int drmm_connector_hdmi_init(struct drm_device *dev, struct i2c_adapter *ddc, unsigned long supported_formats, unsigned int max_bpc); +int drm_connector_hdmi_setup(struct drm_connector *connector, + const char *vendor, const char *product, + const struct drm_connector_hdmi_funcs *hdmi_funcs, + unsigned long supported_formats, + unsigned int max_bpc); void drm_connector_attach_edid_property(struct drm_connector *connector); int drm_connector_register(struct drm_connector *connector); void drm_connector_unregister(struct drm_connector *connector); -- 2.39.2