Skip to content

Commit e494903

Browse files
WhatAmISupposedToPutHeremarcan
authored andcommitted
gpu: drm: adp: Add a backlight driver for the Summit LCD
This is the display panel used for the touchbar on laptops that have it. Signed-off-by: Sasha Finkelstein <[email protected]>
1 parent 1f65965 commit e494903

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

drivers/gpu/drm/adp/panel-summit.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <linux/backlight.h>
4+
#include <drm/drm_mipi_dsi.h>
5+
#include <video/mipi_display.h>
6+
7+
struct summit_data {
8+
struct mipi_dsi_device *dsi;
9+
struct backlight_device *bl;
10+
};
11+
12+
13+
static int summit_bl_update_status(struct backlight_device *dev)
14+
{
15+
struct summit_data *panel = dev_get_drvdata(&dev->dev);
16+
int level = backlight_get_brightness(dev);
17+
return mipi_dsi_dcs_write(panel->dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
18+
&level, 1);
19+
}
20+
21+
static int summit_bl_get_brightness(struct backlight_device *dev)
22+
{
23+
return backlight_get_brightness(dev);
24+
}
25+
26+
static const struct backlight_ops summit_bl_ops = {
27+
.get_brightness = summit_bl_get_brightness,
28+
.update_status = summit_bl_update_status,
29+
};
30+
31+
static int summit_probe(struct mipi_dsi_device *dsi)
32+
{
33+
struct backlight_properties props = { 0 };
34+
struct device *dev = &dsi->dev;
35+
struct summit_data *panel;
36+
panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
37+
if (!panel)
38+
return -ENOMEM;
39+
40+
mipi_dsi_set_drvdata(dsi, panel);
41+
panel->dsi = dsi;
42+
props.max_brightness = 255;
43+
props.type = BACKLIGHT_RAW;
44+
45+
panel->bl = devm_backlight_device_register(dev, dev_name(dev),
46+
dev, panel, &summit_bl_ops, &props);
47+
if (IS_ERR(panel->bl)) {
48+
return PTR_ERR(panel->bl);
49+
}
50+
51+
return mipi_dsi_attach(dsi);
52+
}
53+
54+
static void summit_remove(struct mipi_dsi_device *dsi)
55+
{
56+
mipi_dsi_detach(dsi);
57+
}
58+
59+
static const struct of_device_id summit_of_match[] = {
60+
{ .compatible = "apple,summit" },
61+
{},
62+
};
63+
64+
MODULE_DEVICE_TABLE(of, summit_of_match);
65+
66+
static struct mipi_dsi_driver summit_driver = {
67+
.probe = summit_probe,
68+
.remove = summit_remove,
69+
.driver = {
70+
.name = "panel-summit",
71+
.of_match_table = summit_of_match,
72+
},
73+
};
74+
module_mipi_dsi_driver(summit_driver);
75+
76+
MODULE_DESCRIPTION("Summit Display Panel Driver");
77+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)