[PATCH RFC 2/4] drm/dsi: Add API to register simulated DSI panel
From: Jessica Zhang
Date: Tue Jan 16 2024 - 17:41:16 EST
Add new APIs to register a simulated panel.
For drivers that want to support a simulated panel, they must call
mipi_dsi_host_register_sim_panel().
Signed-off-by: Jessica Zhang <quic_jesszhan@xxxxxxxxxxx>
---
drivers/gpu/drm/drm_mipi_dsi.c | 30 ++++++++++++++++++++++++++++++
include/drm/drm_mipi_dsi.h | 1 +
2 files changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 843a6dbda93a0..6996014990979 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -153,6 +153,24 @@ static int mipi_dsi_device_add(struct mipi_dsi_device *dsi)
return device_add(&dsi->dev);
}
+#if IS_ENABLED(CONFIG_DRM_PANEL_SIMULATION)
+static struct mipi_dsi_device *mipi_dsi_device_add_sim_panel(struct mipi_dsi_host *host)
+{
+ struct mipi_dsi_device_info info = { };
+
+ info.channel = 0;
+ info.node = NULL;
+ strscpy(info.type, "panel_simulation", sizeof(info.type));
+
+ return mipi_dsi_device_register_full(host, &info);
+}
+#else
+static struct mipi_dsi_device *mipi_dsi_device_add_sim_panel(struct mipi_dsi_host *host)
+{
+ return ERR_PTR(-ENODEV);
+}
+#endif
+
#if IS_ENABLED(CONFIG_OF)
static struct mipi_dsi_device *
of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
@@ -324,6 +342,18 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node)
}
EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);
+int mipi_dsi_host_register_sim_panel(struct mipi_dsi_host *host)
+{
+ mipi_dsi_device_add_sim_panel(host);
+
+ mutex_lock(&host_lock);
+ list_add_tail(&host->list, &host_list);
+ mutex_unlock(&host_lock);
+
+ return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_host_register_sim_panel);
+
int mipi_dsi_host_register(struct mipi_dsi_host *host)
{
struct device_node *node;
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index c0aec0d4d664e..4ca44b7b3efdb 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -107,6 +107,7 @@ struct mipi_dsi_host {
struct list_head list;
};
+int mipi_dsi_host_register_sim_panel(struct mipi_dsi_host *host);
int mipi_dsi_host_register(struct mipi_dsi_host *host);
void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
--
2.43.0