Lines Matching +full:panel +full:- +full:height +full:- +full:mm
1 // SPDX-License-Identifier: GPL-2.0+
3 * Generic LVDS panel driver
26 struct drm_panel panel; member
31 unsigned int height; member
44 static inline struct panel_lvds *to_panel_lvds(struct drm_panel *panel) in to_panel_lvds() argument
46 return container_of(panel, struct panel_lvds, panel); in to_panel_lvds()
49 static int panel_lvds_unprepare(struct drm_panel *panel) in panel_lvds_unprepare() argument
51 struct panel_lvds *lvds = to_panel_lvds(panel); in panel_lvds_unprepare()
53 if (lvds->enable_gpio) in panel_lvds_unprepare()
54 gpiod_set_value_cansleep(lvds->enable_gpio, 0); in panel_lvds_unprepare()
56 if (lvds->supply) in panel_lvds_unprepare()
57 regulator_disable(lvds->supply); in panel_lvds_unprepare()
62 static int panel_lvds_prepare(struct drm_panel *panel) in panel_lvds_prepare() argument
64 struct panel_lvds *lvds = to_panel_lvds(panel); in panel_lvds_prepare()
66 if (lvds->supply) { in panel_lvds_prepare()
69 err = regulator_enable(lvds->supply); in panel_lvds_prepare()
71 dev_err(lvds->dev, "failed to enable supply: %d\n", in panel_lvds_prepare()
77 if (lvds->enable_gpio) in panel_lvds_prepare()
78 gpiod_set_value_cansleep(lvds->enable_gpio, 1); in panel_lvds_prepare()
83 static int panel_lvds_get_modes(struct drm_panel *panel, in panel_lvds_get_modes() argument
86 struct panel_lvds *lvds = to_panel_lvds(panel); in panel_lvds_get_modes()
89 mode = drm_mode_create(connector->dev); in panel_lvds_get_modes()
93 drm_display_mode_from_videomode(&lvds->video_mode, mode); in panel_lvds_get_modes()
94 mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in panel_lvds_get_modes()
97 connector->display_info.width_mm = lvds->width; in panel_lvds_get_modes()
98 connector->display_info.height_mm = lvds->height; in panel_lvds_get_modes()
99 drm_display_info_set_bus_formats(&connector->display_info, in panel_lvds_get_modes()
100 &lvds->bus_format, 1); in panel_lvds_get_modes()
101 connector->display_info.bus_flags = lvds->data_mirror in panel_lvds_get_modes()
104 drm_connector_set_panel_orientation(connector, lvds->orientation); in panel_lvds_get_modes()
117 struct device_node *np = lvds->dev->of_node; in panel_lvds_parse_dt()
122 ret = of_drm_get_panel_orientation(np, &lvds->orientation); in panel_lvds_parse_dt()
124 dev_err(lvds->dev, "%pOF: failed to get orientation %d\n", np, ret); in panel_lvds_parse_dt()
128 ret = of_get_display_timing(np, "panel-timing", &timing); in panel_lvds_parse_dt()
130 dev_err(lvds->dev, "%pOF: problems parsing panel-timing (%d)\n", in panel_lvds_parse_dt()
135 videomode_from_timing(&timing, &lvds->video_mode); in panel_lvds_parse_dt()
137 ret = of_property_read_u32(np, "width-mm", &lvds->width); in panel_lvds_parse_dt()
139 dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n", in panel_lvds_parse_dt()
140 np, "width-mm"); in panel_lvds_parse_dt()
141 return -ENODEV; in panel_lvds_parse_dt()
143 ret = of_property_read_u32(np, "height-mm", &lvds->height); in panel_lvds_parse_dt()
145 dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n", in panel_lvds_parse_dt()
146 np, "height-mm"); in panel_lvds_parse_dt()
147 return -ENODEV; in panel_lvds_parse_dt()
150 of_property_read_string(np, "label", &lvds->label); in panel_lvds_parse_dt()
152 ret = of_property_read_string(np, "data-mapping", &mapping); in panel_lvds_parse_dt()
154 dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n", in panel_lvds_parse_dt()
155 np, "data-mapping"); in panel_lvds_parse_dt()
156 return -ENODEV; in panel_lvds_parse_dt()
159 if (!strcmp(mapping, "jeida-18")) { in panel_lvds_parse_dt()
160 lvds->bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG; in panel_lvds_parse_dt()
161 } else if (!strcmp(mapping, "jeida-24")) { in panel_lvds_parse_dt()
162 lvds->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA; in panel_lvds_parse_dt()
163 } else if (!strcmp(mapping, "vesa-24")) { in panel_lvds_parse_dt()
164 lvds->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG; in panel_lvds_parse_dt()
166 dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n", in panel_lvds_parse_dt()
167 np, "data-mapping"); in panel_lvds_parse_dt()
168 return -EINVAL; in panel_lvds_parse_dt()
171 lvds->data_mirror = of_property_read_bool(np, "data-mirror"); in panel_lvds_parse_dt()
181 lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL); in panel_lvds_probe()
183 return -ENOMEM; in panel_lvds_probe()
185 lvds->dev = &pdev->dev; in panel_lvds_probe()
191 lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); in panel_lvds_probe()
192 if (IS_ERR(lvds->supply)) { in panel_lvds_probe()
193 ret = PTR_ERR(lvds->supply); in panel_lvds_probe()
195 if (ret != -ENODEV) { in panel_lvds_probe()
196 if (ret != -EPROBE_DEFER) in panel_lvds_probe()
197 dev_err(lvds->dev, "failed to request regulator: %d\n", in panel_lvds_probe()
202 lvds->supply = NULL; in panel_lvds_probe()
206 lvds->enable_gpio = devm_gpiod_get_optional(lvds->dev, "enable", in panel_lvds_probe()
208 if (IS_ERR(lvds->enable_gpio)) { in panel_lvds_probe()
209 ret = PTR_ERR(lvds->enable_gpio); in panel_lvds_probe()
210 dev_err(lvds->dev, "failed to request %s GPIO: %d\n", in panel_lvds_probe()
215 lvds->reset_gpio = devm_gpiod_get_optional(lvds->dev, "reset", in panel_lvds_probe()
217 if (IS_ERR(lvds->reset_gpio)) { in panel_lvds_probe()
218 ret = PTR_ERR(lvds->reset_gpio); in panel_lvds_probe()
219 dev_err(lvds->dev, "failed to request %s GPIO: %d\n", in panel_lvds_probe()
231 /* Register the panel. */ in panel_lvds_probe()
232 drm_panel_init(&lvds->panel, lvds->dev, &panel_lvds_funcs, in panel_lvds_probe()
235 ret = drm_panel_of_backlight(&lvds->panel); in panel_lvds_probe()
239 drm_panel_add(&lvds->panel); in panel_lvds_probe()
241 dev_set_drvdata(lvds->dev, lvds); in panel_lvds_probe()
247 struct panel_lvds *lvds = dev_get_drvdata(&pdev->dev); in panel_lvds_remove()
249 drm_panel_remove(&lvds->panel); in panel_lvds_remove()
251 drm_panel_disable(&lvds->panel); in panel_lvds_remove()
257 { .compatible = "panel-lvds", },
267 .name = "panel-lvds",
275 MODULE_DESCRIPTION("LVDS Panel Driver");