Panels usually call drm_connector_set_panel_orientation(), which is later than drm/kms driver calling drm_dev_register(). This leads to a WARN()[1].
The orientation property is known earlier. For example, some panels parse the property through device tree during probe.
The series add a panel API drm_connector_set_orientation_from_panel() for drm/kms drivers. The drivers can call the API to set panel's orientation before drm_dev_register().
Panel needs to implement .get_orientation callback to return the property.
[1] https://patchwork.kernel.org/project/linux-mediatek/patch/20220530081910.394...
Hsin-Yi Wang (8): drm/panel: Add an API to allow drm to set orientation from panel drm/panel: boe-tv101wum-nl6: Implement .get_orientation callback drm/panel: panel-edp: Implement .get_orientation callback drm/panel: lvds: Implement .get_orientation callback drm/panel: panel-simple: Implement .get_orientation callback drm/panel: ili9881c: Implement .get_orientation callback drm/panel: elida-kd35t133: Implement .get_orientation callback drm: Config orientation property if panel provides it
drivers/gpu/drm/bridge/panel.c | 36 +++++++++++++++++++ drivers/gpu/drm/drm_bridge_connector.c | 8 ++++- drivers/gpu/drm/drm_connector.c | 32 +++++++++++++++++ .../gpu/drm/panel/panel-boe-tv101wum-nl6.c | 12 +++++++ drivers/gpu/drm/panel/panel-edp.c | 13 ++++++- drivers/gpu/drm/panel/panel-elida-kd35t133.c | 12 +++++++ drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 12 +++++++ drivers/gpu/drm/panel/panel-lvds.c | 13 +++++++ drivers/gpu/drm/panel/panel-simple.c | 14 +++++++- include/drm/drm_bridge.h | 3 ++ include/drm/drm_connector.h | 4 +++ include/drm/drm_panel.h | 9 +++++ 12 files changed, 165 insertions(+), 3 deletions(-)
Panels usually call drm_connector_set_panel_orientation(), which is later than drm/kms driver calling drm_dev_register(). This leads to a WARN().
The orientation property is known earlier. For example, some panels parse the property through device tree during probe.
Add an API to return the property from panel to drm/kms driver, so the drivers are able to call drm_connector_set_orientation_from_panel() before drm_dev_register().
Suggested-by: Hans de Goede hdegoede@redhat.com Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org --- drivers/gpu/drm/drm_connector.c | 32 ++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 4 ++++ include/drm/drm_panel.h | 9 +++++++++ 3 files changed, 45 insertions(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e..859165a1c8f1 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -24,6 +24,7 @@ #include <drm/drm_connector.h> #include <drm/drm_edid.h> #include <drm/drm_encoder.h> +#include <drm/drm_panel.h> #include <drm/drm_utils.h> #include <drm/drm_print.h> #include <drm/drm_drv.h> @@ -2320,6 +2321,9 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property); * It is allowed to call this function with a panel_orientation of * DRM_MODE_PANEL_ORIENTATION_UNKNOWN, in which case it is a no-op. * + * The function shouldn't be called in panel after drm is registered (i.e. + * drm_dev_register() is called in drm). + * * Returns: * Zero on success, negative errno on failure. */ @@ -2389,6 +2393,34 @@ int drm_connector_set_panel_orientation_with_quirk( } EXPORT_SYMBOL(drm_connector_set_panel_orientation_with_quirk);
+/** + * drm_connector_set_orientation_from_panel - + * set the connector's panel_orientation from panel's callback. + * @connector: connector for which to init the panel-orientation property. + * @panel: panel that can provide orientation information. + * + * Drm drivers should call this function before drm_dev_register(). + * Orientation is obtained from panel's .get_orientation() callback. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_connector_set_orientation_from_panel( + struct drm_connector *connector, + struct drm_panel *panel) +{ + enum drm_panel_orientation panel_orientation; + + if (panel && panel->funcs && panel->funcs->get_orientation) + panel_orientation = panel->funcs->get_orientation(panel); + else + panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + + return drm_connector_set_panel_orientation(connector, + panel_orientation); +} +EXPORT_SYMBOL(drm_connector_set_orientation_from_panel); + static const struct drm_prop_enum_list privacy_screen_enum[] = { { PRIVACY_SCREEN_DISABLED, "Disabled" }, { PRIVACY_SCREEN_ENABLED, "Enabled" }, diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 3ac4bf87f257..94b422b55cc1 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -38,6 +38,7 @@ struct drm_modeset_acquire_ctx; struct drm_device; struct drm_crtc; struct drm_encoder; +struct drm_panel; struct drm_property; struct drm_property_blob; struct drm_printer; @@ -1802,6 +1803,9 @@ int drm_connector_set_panel_orientation_with_quirk( struct drm_connector *connector, enum drm_panel_orientation panel_orientation, int width, int height); +int drm_connector_set_orientation_from_panel( + struct drm_connector *connector, + struct drm_panel *panel); int drm_connector_attach_max_bpc_property(struct drm_connector *connector, int min, int max); void drm_connector_create_privacy_screen_properties(struct drm_connector *conn); diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index d279ee455f01..3a271128c078 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -116,6 +116,15 @@ struct drm_panel_funcs { int (*get_modes)(struct drm_panel *panel, struct drm_connector *connector);
+ /** + * @get_orientation: + * + * Return the panel orientation set by device tree or EDID. + * + * This function is optional. + */ + enum drm_panel_orientation (*get_orientation)(struct drm_panel *panel); + /** * @get_timings: *
Quoting Hsin-Yi Wang (2022-06-08 02:48:09)
index 1c48d162c77e..859165a1c8f1 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -2389,6 +2393,34 @@ int drm_connector_set_panel_orientation_with_quirk( } EXPORT_SYMBOL(drm_connector_set_panel_orientation_with_quirk);
+/**
- drm_connector_set_orientation_from_panel -
set the connector's panel_orientation from panel's callback.
- @connector: connector for which to init the panel-orientation property.
- @panel: panel that can provide orientation information.
- Drm drivers should call this function before drm_dev_register().
- Orientation is obtained from panel's .get_orientation() callback.
- Returns:
- Zero on success, negative errno on failure.
- */
+int drm_connector_set_orientation_from_panel(
struct drm_connector *connector,
struct drm_panel *panel)
+{
enum drm_panel_orientation panel_orientation;
s/panel_orientation/orientation/
if (panel && panel->funcs && panel->funcs->get_orientation)
panel_orientation = panel->funcs->get_orientation(panel);
else
panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
return drm_connector_set_panel_orientation(connector,
panel_orientation);
Then this fits on one line:
return drm_connector_set_panel_orientation(connector, orientation);
+} +EXPORT_SYMBOL(drm_connector_set_orientation_from_panel);
Otherwise
Reviewed-by: Stephen Boyd swboyd@chromium.org
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org --- drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c index 1be150ac758f..07f722f33fc5 100644 --- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c +++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c @@ -1511,16 +1511,28 @@ static int boe_panel_get_modes(struct drm_panel *panel, connector->display_info.width_mm = boe->desc->size.width_mm; connector->display_info.height_mm = boe->desc->size.height_mm; connector->display_info.bpc = boe->desc->bpc; + /* + * TODO: Remove once all drm drivers call + * drm_connector_set_orientation_from_panel() + */ drm_connector_set_panel_orientation(connector, boe->orientation);
return 1; }
+static enum drm_panel_orientation boe_panel_get_orientation(struct drm_panel *panel) +{ + struct boe_panel *boe = to_boe_panel(panel); + + return boe->orientation; +} + static const struct drm_panel_funcs boe_panel_funcs = { .unprepare = boe_panel_unprepare, .prepare = boe_panel_prepare, .enable = boe_panel_enable, .get_modes = boe_panel_get_modes, + .get_orientation = boe_panel_get_orientation, };
static int boe_panel_add(struct boe_panel *boe)
Quoting Hsin-Yi Wang (2022-06-08 02:48:10)
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Stephen Boyd swboyd@chromium.org
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org --- drivers/gpu/drm/panel/panel-edp.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index c96014464355..ee622c1dd532 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -586,7 +586,10 @@ static int panel_edp_get_modes(struct drm_panel *panel, else if (!num) dev_warn(p->base.dev, "No display modes\n");
- /* set up connector's "panel orientation" property */ + /* + * TODO: Remove once all drm drivers call + * drm_connector_set_orientation_from_panel() + */ drm_connector_set_panel_orientation(connector, p->orientation);
return num; @@ -609,6 +612,13 @@ static int panel_edp_get_timings(struct drm_panel *panel, return p->desc->num_timings; }
+static enum drm_panel_orientation panel_edp_get_orientation(struct drm_panel *panel) +{ + struct panel_edp *p = to_panel_edp(panel); + + return p->orientation; +} + static int detected_panel_show(struct seq_file *s, void *data) { struct drm_panel *panel = s->private; @@ -637,6 +647,7 @@ static const struct drm_panel_funcs panel_edp_funcs = { .prepare = panel_edp_prepare, .enable = panel_edp_enable, .get_modes = panel_edp_get_modes, + .get_orientation = panel_edp_get_orientation, .get_timings = panel_edp_get_timings, .debugfs_init = panel_edp_debugfs_init, };
Quoting Hsin-Yi Wang (2022-06-08 02:48:11)
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Stephen Boyd swboyd@chromium.org
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org --- drivers/gpu/drm/panel/panel-lvds.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c index f11252fb00fe..7a4fedc63e8e 100644 --- a/drivers/gpu/drm/panel/panel-lvds.c +++ b/drivers/gpu/drm/panel/panel-lvds.c @@ -99,15 +99,28 @@ static int panel_lvds_get_modes(struct drm_panel *panel, drm_display_info_set_bus_formats(&connector->display_info, &lvds->bus_format, 1); connector->display_info.bus_flags = lvds->bus_flags; + + /* + * TODO: Remove once all drm drivers call + * drm_connector_set_orientation_from_panel() + */ drm_connector_set_panel_orientation(connector, lvds->orientation);
return 1; }
+static enum drm_panel_orientation panel_lvds_get_orientation(struct drm_panel *panel) +{ + struct panel_lvds *lvds = to_panel_lvds(panel); + + return lvds->orientation; +} + static const struct drm_panel_funcs panel_lvds_funcs = { .unprepare = panel_lvds_unprepare, .prepare = panel_lvds_prepare, .get_modes = panel_lvds_get_modes, + .get_orientation = panel_lvds_get_orientation, };
static int panel_lvds_parse_dt(struct panel_lvds *lvds)
Quoting Hsin-Yi Wang (2022-06-08 02:48:12)
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Stephen Boyd swboyd@chromium.org
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org Reviewed-by: Sam Ravnborg sam@ravnborg.org --- drivers/gpu/drm/panel/panel-simple.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 4a2e580a2f7b..b4b919525189 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -411,7 +411,10 @@ static int panel_simple_get_modes(struct drm_panel *panel, /* add hard-coded panel modes */ num += panel_simple_get_non_edid_modes(p, connector);
- /* set up connector's "panel orientation" property */ + /* + * TODO: Remove once all drm drivers call + * drm_connector_set_orientation_from_panel() + */ drm_connector_set_panel_orientation(connector, p->orientation);
return num; @@ -434,12 +437,21 @@ static int panel_simple_get_timings(struct drm_panel *panel, return p->desc->num_timings; }
+static enum drm_panel_orientation panel_simple_get_orientation(struct drm_panel *panel) +{ + struct panel_simple *p = to_panel_simple(panel); + + return p->orientation; +} + + static const struct drm_panel_funcs panel_simple_funcs = { .disable = panel_simple_disable, .unprepare = panel_simple_unprepare, .prepare = panel_simple_prepare, .enable = panel_simple_enable, .get_modes = panel_simple_get_modes, + .get_orientation = panel_simple_get_orientation, .get_timings = panel_simple_get_timings, };
Quoting Hsin-Yi Wang (2022-06-08 02:48:13)
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org Reviewed-by: Sam Ravnborg sam@ravnborg.org
Reviewed-by: Stephen Boyd swboyd@chromium.org
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org --- drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c index ba30d11547ad..58d6798c25ed 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c @@ -853,17 +853,29 @@ static int ili9881c_get_modes(struct drm_panel *panel, connector->display_info.width_mm = mode->width_mm; connector->display_info.height_mm = mode->height_mm;
+ /* + * TODO: Remove once all drm drivers call + * drm_connector_set_orientation_from_panel() + */ drm_connector_set_panel_orientation(connector, ctx->orientation);
return 1; }
+static enum drm_panel_orientation ili9881c_get_orientation(struct drm_panel *panel) +{ + struct ili9881c *ctx = panel_to_ili9881c(panel); + + return ctx->orientation; +} + static const struct drm_panel_funcs ili9881c_funcs = { .prepare = ili9881c_prepare, .unprepare = ili9881c_unprepare, .enable = ili9881c_enable, .disable = ili9881c_disable, .get_modes = ili9881c_get_modes, + .get_orientation = ili9881c_get_orientation, };
static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
Quoting Hsin-Yi Wang (2022-06-08 02:48:14)
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Stephen Boyd swboyd@chromium.org
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org --- drivers/gpu/drm/panel/panel-elida-kd35t133.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-elida-kd35t133.c b/drivers/gpu/drm/panel/panel-elida-kd35t133.c index 80227617a4d6..fa613d1d7a8f 100644 --- a/drivers/gpu/drm/panel/panel-elida-kd35t133.c +++ b/drivers/gpu/drm/panel/panel-elida-kd35t133.c @@ -217,15 +217,27 @@ static int kd35t133_get_modes(struct drm_panel *panel, connector->display_info.width_mm = mode->width_mm; connector->display_info.height_mm = mode->height_mm; drm_mode_probed_add(connector, mode); + /* + * TODO: Remove once all drm drivers call + * drm_connector_set_orientation_from_panel() + */ drm_connector_set_panel_orientation(connector, ctx->orientation);
return 1; }
+static enum drm_panel_orientation kd35t133_get_orientation(struct drm_panel *panel) +{ + struct kd35t133 *ctx = panel_to_kd35t133(panel); + + return ctx->orientation; +} + static const struct drm_panel_funcs kd35t133_funcs = { .unprepare = kd35t133_unprepare, .prepare = kd35t133_prepare, .get_modes = kd35t133_get_modes, + .get_orientation = kd35t133_get_orientation, };
static int kd35t133_probe(struct mipi_dsi_device *dsi)
Quoting Hsin-Yi Wang (2022-06-08 02:48:15)
To return the orientation property to drm/kms driver.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Hans de Goede hdegoede@redhat.com Reviewed-by: Douglas Anderson dianders@chromium.org
Reviewed-by: Stephen Boyd swboyd@chromium.org
Panel orientation property should be set before drm_dev_register(). Some drm driver calls drm_dev_register() in .bind(). However, most panels sets orientation property relatively late, mostly in .get_modes() callback, since this is when they are able to get the connector and binds the orientation property to it, though the value should be known when the panel is probed.
In drm_bridge_connector_init(), if a bridge is a panel bridge, use it to set the connector's panel orientation property.
Suggested-by: Doug Anderson dianders@chromium.org Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org --- v5->v6: mtk_dsi is using panel bridge, we don't need to obtain the panel in mtk_dsi. Instead, drm_connector_set_orientation_from_panel() can be called from drm_bridge_connector_init(). --- drivers/gpu/drm/bridge/panel.c | 36 ++++++++++++++++++++++++++ drivers/gpu/drm/drm_bridge_connector.c | 8 +++++- include/drm/drm_bridge.h | 3 +++ 3 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index 0ee563eb2b6f..53c98cba719b 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -170,6 +170,17 @@ static const struct drm_bridge_funcs panel_bridge_bridge_funcs = { .debugfs_init = panel_bridge_debugfs_init, };
+/** + * drm_bridge_is_panel - Checks if a drm_bridge is a panel_bridge. + * + * @bridge: The drm_bridge to be checked. + */ +bool drm_bridge_is_panel(const struct drm_bridge *bridge) +{ + return bridge->funcs == &panel_bridge_bridge_funcs; +} +EXPORT_SYMBOL(drm_bridge_is_panel); + /** * drm_panel_bridge_add - Creates a &drm_bridge and &drm_connector that * just calls the appropriate functions from &drm_panel. @@ -269,6 +280,31 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge) } EXPORT_SYMBOL(drm_panel_bridge_remove);
+/** + * drm_panel_bridge_set_orientation - Set the connector's panel orientation + * if the bridge is a panel bridge. + * + * @connector: The connector to be set panel orientation. + * @bridge: The drm_bridge to be transformed to panel bridge. + */ +int drm_panel_bridge_set_orientation(struct drm_connector *connector, + struct drm_bridge *bridge) +{ + struct panel_bridge *panel_bridge; + + if (!bridge) + return 0; + + if (bridge->funcs != &panel_bridge_bridge_funcs) + return 0; + + panel_bridge = drm_bridge_to_panel_bridge(bridge); + + return drm_connector_set_orientation_from_panel(connector, + panel_bridge->panel); +} +EXPORT_SYMBOL(drm_panel_bridge_set_orientation); + static void devm_drm_panel_bridge_release(struct device *dev, void *res) { struct drm_bridge **bridge = res; diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 6b3dad03d77d..1c7d936523df 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -331,7 +331,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, struct drm_bridge_connector *bridge_connector; struct drm_connector *connector; struct i2c_adapter *ddc = NULL; - struct drm_bridge *bridge; + struct drm_bridge *bridge, *panel_bridge = NULL; int connector_type;
bridge_connector = kzalloc(sizeof(*bridge_connector), GFP_KERNEL); @@ -373,6 +373,9 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
if (bridge->ddc) ddc = bridge->ddc; + + if (drm_bridge_is_panel(bridge)) + panel_bridge = bridge; }
if (connector_type == DRM_MODE_CONNECTOR_Unknown) { @@ -392,6 +395,9 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
+ if (panel_bridge) + drm_panel_bridge_set_orientation(connector, panel_bridge); + return connector; } EXPORT_SYMBOL_GPL(drm_bridge_connector_init); diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index f27b4060faa2..b0691d728139 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -917,10 +917,13 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge, enum drm_connector_status status);
#ifdef CONFIG_DRM_PANEL_BRIDGE +bool drm_bridge_is_panel(const struct drm_bridge *bridge); struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, u32 connector_type); void drm_panel_bridge_remove(struct drm_bridge *bridge); +int drm_panel_bridge_set_orientation(struct drm_connector *connector, + struct drm_bridge *bridge); struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, struct drm_panel *panel); struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev,
Hi,
On Wed, Jun 8, 2022 at 2:48 AM Hsin-Yi Wang hsinyi@chromium.org wrote:
@@ -269,6 +280,31 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge) } EXPORT_SYMBOL(drm_panel_bridge_remove);
+/**
- drm_panel_bridge_set_orientation - Set the connector's panel orientation
- if the bridge is a panel bridge.
- @connector: The connector to be set panel orientation.
- @bridge: The drm_bridge to be transformed to panel bridge.
Ideally you should have a kernel doc to describe what you're returning.
- */
+int drm_panel_bridge_set_orientation(struct drm_connector *connector,
struct drm_bridge *bridge)
+{
struct panel_bridge *panel_bridge;
if (!bridge)
return 0;
if (bridge->funcs != &panel_bridge_bridge_funcs)
return 0;
nit: Why do you need to handle NULL bridge and the case that someone calls you with something other than a panel-bridge? I'm not convinced that's useful. In general kernel style doesn't do massive validation of parameters unless there's a reason for it. ...if we do need to handle them then it feels like they should be returning -EINVAL or something, not 0.
@@ -917,10 +917,13 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge, enum drm_connector_status status);
#ifdef CONFIG_DRM_PANEL_BRIDGE +bool drm_bridge_is_panel(const struct drm_bridge *bridge); struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, u32 connector_type); void drm_panel_bridge_remove(struct drm_bridge *bridge); +int drm_panel_bridge_set_orientation(struct drm_connector *connector,
struct drm_bridge *bridge);
I suspect that you need some dummy versions of your new functions defined if "CONFIG_DRM_PANEL_BRIDGE" is not defined. Otherwise we're going to be yelled at by the kernel robot eventually.
-Doug
On Wed, Jun 8, 2022 at 10:17 PM Doug Anderson dianders@chromium.org wrote:
Hi,
On Wed, Jun 8, 2022 at 2:48 AM Hsin-Yi Wang hsinyi@chromium.org wrote:
@@ -269,6 +280,31 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge) } EXPORT_SYMBOL(drm_panel_bridge_remove);
+/**
- drm_panel_bridge_set_orientation - Set the connector's panel orientation
- if the bridge is a panel bridge.
- @connector: The connector to be set panel orientation.
- @bridge: The drm_bridge to be transformed to panel bridge.
Ideally you should have a kernel doc to describe what you're returning.
- */
+int drm_panel_bridge_set_orientation(struct drm_connector *connector,
struct drm_bridge *bridge)
+{
struct panel_bridge *panel_bridge;
if (!bridge)
return 0;
if (bridge->funcs != &panel_bridge_bridge_funcs)
return 0;
nit: Why do you need to handle NULL bridge and the case that someone calls you with something other than a panel-bridge? I'm not convinced that's useful. In general kernel style doesn't do massive validation of parameters unless there's a reason for it. ...if we do need to handle them then it feels like they should be returning -EINVAL or something, not 0.
The only caller had checked it. I can remove the check here.
@@ -917,10 +917,13 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge, enum drm_connector_status status);
#ifdef CONFIG_DRM_PANEL_BRIDGE +bool drm_bridge_is_panel(const struct drm_bridge *bridge); struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, u32 connector_type); void drm_panel_bridge_remove(struct drm_bridge *bridge); +int drm_panel_bridge_set_orientation(struct drm_connector *connector,
struct drm_bridge *bridge);
I suspect that you need some dummy versions of your new functions defined if "CONFIG_DRM_PANEL_BRIDGE" is not defined. Otherwise we're going to be yelled at by the kernel robot eventually.
-Doug
dri-devel@lists.freedesktop.org