mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-19 05:32:22 -05:00
drm: panel: Add a panel driver for the Summit display
This is the display panel used for the touchbar on laptops that have it. Co-developed-by: Nick Chan <towinchenmi@gmail.com> Signed-off-by: Nick Chan <towinchenmi@gmail.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Reviewed-by: Neal Gompa <neal@gompa.dev> Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com> Link: https://lore.kernel.org/r/20250217-adpdrm-v7-3-ca2e44b3c7d8@gmail.com Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20250217-adpdrm-v7-3-ca2e44b3c7d8@gmail.com
This commit is contained in:
committed by
Neil Armstrong
parent
d34bd3c7cb
commit
40115947b5
@@ -925,6 +925,15 @@ config DRM_PANEL_SIMPLE
|
||||
that it can be automatically turned off when the panel goes into a
|
||||
low power state.
|
||||
|
||||
config DRM_PANEL_SUMMIT
|
||||
tristate "Apple Summit display panel"
|
||||
depends on OF
|
||||
depends on DRM_MIPI_DSI
|
||||
depends on BACKLIGHT_CLASS_DEVICE
|
||||
help
|
||||
Say Y if you want to enable support for the "Summit" display panel
|
||||
used as a touchbar on certain Apple laptops.
|
||||
|
||||
config DRM_PANEL_SYNAPTICS_R63353
|
||||
tristate "Synaptics R63353-based panels"
|
||||
depends on OF
|
||||
|
||||
@@ -89,6 +89,7 @@ obj-$(CONFIG_DRM_PANEL_SHARP_LS060T1SX01) += panel-sharp-ls060t1sx01.o
|
||||
obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += panel-sitronix-st7701.o
|
||||
obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
|
||||
obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
|
||||
obj-$(CONFIG_DRM_PANEL_SUMMIT) += panel-summit.o
|
||||
obj-$(CONFIG_DRM_PANEL_SYNAPTICS_R63353) += panel-synaptics-r63353.o
|
||||
obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
|
||||
obj-$(CONFIG_DRM_PANEL_SONY_TD4353_JDI) += panel-sony-td4353-jdi.o
|
||||
|
||||
132
drivers/gpu/drm/panel/panel-summit.c
Normal file
132
drivers/gpu/drm/panel/panel-summit.c
Normal file
@@ -0,0 +1,132 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
#include <linux/backlight.h>
|
||||
#include <drm/drm_device.h>
|
||||
#include <drm/drm_mipi_dsi.h>
|
||||
#include <drm/drm_mode.h>
|
||||
#include <drm/drm_modes.h>
|
||||
#include <drm/drm_panel.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
#include <video/mipi_display.h>
|
||||
|
||||
struct summit_data {
|
||||
struct mipi_dsi_device *dsi;
|
||||
struct backlight_device *bl;
|
||||
struct drm_panel panel;
|
||||
};
|
||||
|
||||
static int summit_set_brightness(struct device *dev)
|
||||
{
|
||||
struct summit_data *s_data = dev_get_drvdata(dev);
|
||||
int level = backlight_get_brightness(s_data->bl);
|
||||
|
||||
return mipi_dsi_dcs_set_display_brightness(s_data->dsi, level);
|
||||
}
|
||||
|
||||
static int summit_bl_update_status(struct backlight_device *dev)
|
||||
{
|
||||
return summit_set_brightness(&dev->dev);
|
||||
}
|
||||
|
||||
static const struct backlight_ops summit_bl_ops = {
|
||||
.update_status = summit_bl_update_status,
|
||||
};
|
||||
|
||||
static struct drm_display_mode summit_mode = {
|
||||
.vdisplay = 2008,
|
||||
.hdisplay = 60,
|
||||
.hsync_start = 60 + 8,
|
||||
.hsync_end = 60 + 8 + 80,
|
||||
.htotal = 60 + 8 + 80 + 40,
|
||||
.vsync_start = 2008 + 1,
|
||||
.vsync_end = 2008 + 1 + 15,
|
||||
.vtotal = 2008 + 1 + 15 + 6,
|
||||
.clock = ((60 + 8 + 80 + 40) * (2008 + 1 + 15 + 6) * 60) / 1000,
|
||||
.type = DRM_MODE_TYPE_DRIVER,
|
||||
.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
|
||||
};
|
||||
|
||||
static int summit_get_modes(struct drm_panel *panel,
|
||||
struct drm_connector *connector)
|
||||
{
|
||||
connector->display_info.non_desktop = true;
|
||||
drm_object_property_set_value(&connector->base,
|
||||
connector->dev->mode_config.non_desktop_property,
|
||||
connector->display_info.non_desktop);
|
||||
|
||||
return drm_connector_helper_get_modes_fixed(connector, &summit_mode);
|
||||
}
|
||||
|
||||
static const struct drm_panel_funcs summit_panel_funcs = {
|
||||
.get_modes = summit_get_modes,
|
||||
};
|
||||
|
||||
static int summit_probe(struct mipi_dsi_device *dsi)
|
||||
{
|
||||
struct backlight_properties props = { 0 };
|
||||
struct device *dev = &dsi->dev;
|
||||
struct summit_data *s_data;
|
||||
int ret;
|
||||
|
||||
s_data = devm_kzalloc(dev, sizeof(*s_data), GFP_KERNEL);
|
||||
if (!s_data)
|
||||
return -ENOMEM;
|
||||
|
||||
mipi_dsi_set_drvdata(dsi, s_data);
|
||||
s_data->dsi = dsi;
|
||||
|
||||
ret = device_property_read_u32(dev, "max-brightness", &props.max_brightness);
|
||||
if (ret)
|
||||
return ret;
|
||||
props.type = BACKLIGHT_RAW;
|
||||
|
||||
s_data->bl = devm_backlight_device_register(dev, dev_name(dev),
|
||||
dev, s_data, &summit_bl_ops, &props);
|
||||
if (IS_ERR(s_data->bl))
|
||||
return PTR_ERR(s_data->bl);
|
||||
|
||||
drm_panel_init(&s_data->panel, dev, &summit_panel_funcs,
|
||||
DRM_MODE_CONNECTOR_DSI);
|
||||
drm_panel_add(&s_data->panel);
|
||||
|
||||
return mipi_dsi_attach(dsi);
|
||||
}
|
||||
|
||||
static void summit_remove(struct mipi_dsi_device *dsi)
|
||||
{
|
||||
struct summit_data *s_data = mipi_dsi_get_drvdata(dsi);
|
||||
|
||||
mipi_dsi_detach(dsi);
|
||||
drm_panel_remove(&s_data->panel);
|
||||
}
|
||||
|
||||
static int summit_suspend(struct device *dev)
|
||||
{
|
||||
struct summit_data *s_data = dev_get_drvdata(dev);
|
||||
|
||||
return mipi_dsi_dcs_set_display_brightness(s_data->dsi, 0);
|
||||
}
|
||||
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(summit_pm_ops, summit_suspend,
|
||||
summit_set_brightness);
|
||||
|
||||
static const struct of_device_id summit_of_match[] = {
|
||||
{ .compatible = "apple,summit" },
|
||||
{},
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, summit_of_match);
|
||||
|
||||
static struct mipi_dsi_driver summit_driver = {
|
||||
.probe = summit_probe,
|
||||
.remove = summit_remove,
|
||||
.driver = {
|
||||
.name = "panel-summit",
|
||||
.of_match_table = summit_of_match,
|
||||
.pm = pm_sleep_ptr(&summit_pm_ops),
|
||||
},
|
||||
};
|
||||
module_mipi_dsi_driver(summit_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Summit Display Panel Driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
Reference in New Issue
Block a user