2 * Copyright (C) 2013, NVIDIA Corporation. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include <linux/backlight.h>
25 #include <linux/gpio/consumer.h>
26 #include <linux/module.h>
27 #include <linux/of_platform.h>
28 #include <linux/platform_device.h>
29 #include <linux/regulator/consumer.h>
32 #include <drm/drm_crtc.h>
33 #include <drm/drm_mipi_dsi.h>
34 #include <drm/drm_panel.h>
36 #include <video/display_timing.h>
37 #include <video/of_display_timing.h>
38 #include <video/videomode.h>
41 const struct drm_display_mode *modes;
42 unsigned int num_modes;
43 const struct display_timing *timings;
44 unsigned int num_timings;
54 * @prepare: the time (in milliseconds) that it takes for the panel to
55 * become ready and start receiving video data
56 * @enable: the time (in milliseconds) that it takes for the panel to
57 * display the first valid frame after starting to receive
59 * @disable: the time (in milliseconds) that it takes for the panel to
60 * turn the display off (no content is visible)
61 * @unprepare: the time (in milliseconds) that it takes for the panel
62 * to power itself down completely
68 unsigned int unprepare;
75 struct drm_panel base;
80 const struct panel_desc *desc;
82 struct backlight_device *backlight;
83 struct regulator *supply;
84 struct i2c_adapter *ddc;
86 struct gpio_desc *enable_gpio;
89 static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
91 return container_of(panel, struct panel_simple, base);
94 static int panel_simple_get_fixed_modes(struct panel_simple *panel)
96 struct drm_connector *connector = panel->base.connector;
97 struct drm_device *drm = panel->base.drm;
98 struct drm_display_mode *mode;
99 unsigned int i, num = 0;
104 for (i = 0; i < panel->desc->num_timings; i++) {
105 const struct display_timing *dt = &panel->desc->timings[i];
108 videomode_from_timing(dt, &vm);
109 mode = drm_mode_create(drm);
111 dev_err(drm->dev, "failed to add mode %ux%u\n",
112 dt->hactive.typ, dt->vactive.typ);
116 drm_display_mode_from_videomode(&vm, mode);
117 drm_mode_set_name(mode);
119 drm_mode_probed_add(connector, mode);
123 for (i = 0; i < panel->desc->num_modes; i++) {
124 const struct drm_display_mode *m = &panel->desc->modes[i];
126 mode = drm_mode_duplicate(drm, m);
128 dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
129 m->hdisplay, m->vdisplay, m->vrefresh);
133 drm_mode_set_name(mode);
135 drm_mode_probed_add(connector, mode);
139 connector->display_info.bpc = panel->desc->bpc;
140 connector->display_info.width_mm = panel->desc->size.width;
141 connector->display_info.height_mm = panel->desc->size.height;
142 if (panel->desc->bus_format)
143 drm_display_info_set_bus_formats(&connector->display_info,
144 &panel->desc->bus_format, 1);
149 static int panel_simple_of_get_native_mode(struct panel_simple *panel)
151 struct drm_connector *connector = panel->base.connector;
152 struct drm_device *drm = panel->base.drm;
153 struct drm_display_mode *mode;
154 struct device_node *timings_np;
157 timings_np = of_get_child_by_name(panel->dev->of_node,
160 dev_dbg(panel->dev, "failed to find display-timings node\n");
164 of_node_put(timings_np);
165 mode = drm_mode_create(drm);
169 ret = of_get_drm_display_mode(panel->dev->of_node, mode,
172 dev_dbg(panel->dev, "failed to find dts display timings\n");
173 drm_mode_destroy(drm, mode);
177 drm_mode_set_name(mode);
178 mode->type |= DRM_MODE_TYPE_PREFERRED;
179 drm_mode_probed_add(connector, mode);
184 static int panel_simple_disable(struct drm_panel *panel)
186 struct panel_simple *p = to_panel_simple(panel);
192 p->backlight->props.power = FB_BLANK_POWERDOWN;
193 backlight_update_status(p->backlight);
196 if (p->desc && p->desc->delay.disable)
197 msleep(p->desc->delay.disable);
204 static int panel_simple_unprepare(struct drm_panel *panel)
206 struct panel_simple *p = to_panel_simple(panel);
212 gpiod_direction_output(p->enable_gpio, 0);
214 regulator_disable(p->supply);
216 if (p->desc && p->desc->delay.unprepare)
217 msleep(p->desc->delay.unprepare);
224 static int panel_simple_prepare(struct drm_panel *panel)
226 struct panel_simple *p = to_panel_simple(panel);
232 err = regulator_enable(p->supply);
234 dev_err(panel->dev, "failed to enable supply: %d\n", err);
239 gpiod_direction_output(p->enable_gpio, 1);
241 if (p->desc && p->desc->delay.prepare)
242 msleep(p->desc->delay.prepare);
249 static int panel_simple_enable(struct drm_panel *panel)
251 struct panel_simple *p = to_panel_simple(panel);
256 if (p->desc && p->desc->delay.enable)
257 msleep(p->desc->delay.enable);
260 p->backlight->props.power = FB_BLANK_UNBLANK;
261 backlight_update_status(p->backlight);
269 static int panel_simple_get_modes(struct drm_panel *panel)
271 struct panel_simple *p = to_panel_simple(panel);
274 /* probe EDID if a DDC bus is available */
276 struct edid *edid = drm_get_edid(panel->connector, p->ddc);
277 drm_mode_connector_update_edid_property(panel->connector, edid);
279 num += drm_add_edid_modes(panel->connector, edid);
284 /* add hard-coded panel modes */
285 num += panel_simple_get_fixed_modes(p);
287 /* add device node plane modes */
288 num += panel_simple_of_get_native_mode(p);
293 static int panel_simple_get_timings(struct drm_panel *panel,
294 unsigned int num_timings,
295 struct display_timing *timings)
297 struct panel_simple *p = to_panel_simple(panel);
303 if (p->desc->num_timings < num_timings)
304 num_timings = p->desc->num_timings;
307 for (i = 0; i < num_timings; i++)
308 timings[i] = p->desc->timings[i];
310 return p->desc->num_timings;
313 static const struct drm_panel_funcs panel_simple_funcs = {
314 .disable = panel_simple_disable,
315 .unprepare = panel_simple_unprepare,
316 .prepare = panel_simple_prepare,
317 .enable = panel_simple_enable,
318 .get_modes = panel_simple_get_modes,
319 .get_timings = panel_simple_get_timings,
322 static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
324 struct device_node *backlight, *ddc;
325 struct panel_simple *panel;
328 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
332 panel->enabled = false;
333 panel->prepared = false;
337 panel->supply = devm_regulator_get(dev, "power");
338 if (IS_ERR(panel->supply))
339 return PTR_ERR(panel->supply);
341 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable", 0);
342 if (IS_ERR(panel->enable_gpio)) {
343 err = PTR_ERR(panel->enable_gpio);
344 dev_err(dev, "failed to request GPIO: %d\n", err);
348 backlight = of_parse_phandle(dev->of_node, "backlight", 0);
350 panel->backlight = of_find_backlight_by_node(backlight);
351 of_node_put(backlight);
353 if (!panel->backlight)
354 return -EPROBE_DEFER;
357 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
359 panel->ddc = of_find_i2c_adapter_by_node(ddc);
368 drm_panel_init(&panel->base);
369 panel->base.dev = dev;
370 panel->base.funcs = &panel_simple_funcs;
372 err = drm_panel_add(&panel->base);
376 dev_set_drvdata(dev, panel);
382 put_device(&panel->ddc->dev);
384 if (panel->backlight)
385 put_device(&panel->backlight->dev);
390 static int panel_simple_remove(struct device *dev)
392 struct panel_simple *panel = dev_get_drvdata(dev);
394 drm_panel_detach(&panel->base);
395 drm_panel_remove(&panel->base);
397 panel_simple_disable(&panel->base);
400 put_device(&panel->ddc->dev);
402 if (panel->backlight)
403 put_device(&panel->backlight->dev);
408 static void panel_simple_shutdown(struct device *dev)
410 struct panel_simple *panel = dev_get_drvdata(dev);
412 panel_simple_disable(&panel->base);
415 static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {
418 .hsync_start = 800 + 0,
419 .hsync_end = 800 + 0 + 255,
420 .htotal = 800 + 0 + 255 + 0,
422 .vsync_start = 480 + 2,
423 .vsync_end = 480 + 2 + 45,
424 .vtotal = 480 + 2 + 45 + 0,
426 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
429 static const struct panel_desc ampire_am800480r3tmqwa1h = {
430 .modes = &ire_am800480r3tmqwa1h_mode,
437 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
440 static const struct drm_display_mode auo_b101aw03_mode = {
443 .hsync_start = 1024 + 156,
444 .hsync_end = 1024 + 156 + 8,
445 .htotal = 1024 + 156 + 8 + 156,
447 .vsync_start = 600 + 16,
448 .vsync_end = 600 + 16 + 6,
449 .vtotal = 600 + 16 + 6 + 16,
453 static const struct panel_desc auo_b101aw03 = {
454 .modes = &auo_b101aw03_mode,
463 static const struct drm_display_mode auo_b101ean01_mode = {
466 .hsync_start = 1280 + 119,
467 .hsync_end = 1280 + 119 + 32,
468 .htotal = 1280 + 119 + 32 + 21,
470 .vsync_start = 800 + 4,
471 .vsync_end = 800 + 4 + 20,
472 .vtotal = 800 + 4 + 20 + 8,
476 static const struct panel_desc auo_b101ean01 = {
477 .modes = &auo_b101ean01_mode,
486 static const struct drm_display_mode auo_b101ew05_mode = {
489 .hsync_start = 1280 + 18,
490 .hsync_end = 1280 + 18 + 10,
491 .htotal = 1280 + 18 + 10 + 100,
493 .vsync_start = 800 + 6,
494 .vsync_end = 800 + 6 + 2,
495 .vtotal = 800 + 6 + 2 + 8,
499 static const struct panel_desc auo_b101ew05 = {
500 .modes = &auo_b101ew05_mode,
509 static const struct drm_display_mode auo_b101xtn01_mode = {
512 .hsync_start = 1366 + 20,
513 .hsync_end = 1366 + 20 + 70,
514 .htotal = 1366 + 20 + 70,
516 .vsync_start = 768 + 14,
517 .vsync_end = 768 + 14 + 42,
518 .vtotal = 768 + 14 + 42,
520 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
523 static const struct panel_desc auo_b101xtn01 = {
524 .modes = &auo_b101xtn01_mode,
533 static const struct drm_display_mode auo_b116xw03_mode = {
536 .hsync_start = 1366 + 40,
537 .hsync_end = 1366 + 40 + 40,
538 .htotal = 1366 + 40 + 40 + 32,
540 .vsync_start = 768 + 10,
541 .vsync_end = 768 + 10 + 12,
542 .vtotal = 768 + 10 + 12 + 6,
546 static const struct panel_desc auo_b116xw03 = {
547 .modes = &auo_b116xw03_mode,
556 static const struct drm_display_mode auo_b133xtn01_mode = {
559 .hsync_start = 1366 + 48,
560 .hsync_end = 1366 + 48 + 32,
561 .htotal = 1366 + 48 + 32 + 20,
563 .vsync_start = 768 + 3,
564 .vsync_end = 768 + 3 + 6,
565 .vtotal = 768 + 3 + 6 + 13,
569 static const struct panel_desc auo_b133xtn01 = {
570 .modes = &auo_b133xtn01_mode,
579 static const struct drm_display_mode auo_b133htn01_mode = {
582 .hsync_start = 1920 + 172,
583 .hsync_end = 1920 + 172 + 80,
584 .htotal = 1920 + 172 + 80 + 60,
586 .vsync_start = 1080 + 25,
587 .vsync_end = 1080 + 25 + 10,
588 .vtotal = 1080 + 25 + 10 + 10,
592 static const struct panel_desc auo_b133htn01 = {
593 .modes = &auo_b133htn01_mode,
607 static const struct drm_display_mode avic_tm070ddh03_mode = {
610 .hsync_start = 1024 + 160,
611 .hsync_end = 1024 + 160 + 4,
612 .htotal = 1024 + 160 + 4 + 156,
614 .vsync_start = 600 + 17,
615 .vsync_end = 600 + 17 + 1,
616 .vtotal = 600 + 17 + 1 + 17,
620 static const struct panel_desc avic_tm070ddh03 = {
621 .modes = &avic_tm070ddh03_mode,
635 static const struct drm_display_mode chunghwa_claa070wp03xg_mode = {
638 .hsync_start = 800 + 24,
639 .hsync_end = 800 + 24 + 16,
640 .htotal = 800 + 24 + 16 + 24,
642 .vsync_start = 1280 + 2,
643 .vsync_end = 1280 + 2 + 2,
644 .vtotal = 1280 + 2 + 2 + 4,
648 static const struct panel_desc chunghwa_claa070wp03xg = {
649 .modes = &chunghwa_claa070wp03xg_mode,
658 static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
661 .hsync_start = 1366 + 58,
662 .hsync_end = 1366 + 58 + 58,
663 .htotal = 1366 + 58 + 58 + 58,
665 .vsync_start = 768 + 4,
666 .vsync_end = 768 + 4 + 4,
667 .vtotal = 768 + 4 + 4 + 4,
671 static const struct panel_desc chunghwa_claa101wa01a = {
672 .modes = &chunghwa_claa101wa01a_mode,
681 static const struct drm_display_mode chunghwa_claa101wb01_mode = {
684 .hsync_start = 1366 + 48,
685 .hsync_end = 1366 + 48 + 32,
686 .htotal = 1366 + 48 + 32 + 20,
688 .vsync_start = 768 + 16,
689 .vsync_end = 768 + 16 + 8,
690 .vtotal = 768 + 16 + 8 + 16,
694 static const struct panel_desc chunghwa_claa101wb01 = {
695 .modes = &chunghwa_claa101wb01_mode,
704 static const struct drm_display_mode edt_et057090dhu_mode = {
707 .hsync_start = 640 + 16,
708 .hsync_end = 640 + 16 + 30,
709 .htotal = 640 + 16 + 30 + 114,
711 .vsync_start = 480 + 10,
712 .vsync_end = 480 + 10 + 3,
713 .vtotal = 480 + 10 + 3 + 32,
715 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
718 static const struct panel_desc edt_et057090dhu = {
719 .modes = &edt_et057090dhu_mode,
728 static const struct drm_display_mode edt_etm0700g0dh6_mode = {
731 .hsync_start = 800 + 40,
732 .hsync_end = 800 + 40 + 128,
733 .htotal = 800 + 40 + 128 + 88,
735 .vsync_start = 480 + 10,
736 .vsync_end = 480 + 10 + 2,
737 .vtotal = 480 + 10 + 2 + 33,
739 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
742 static const struct panel_desc edt_etm0700g0dh6 = {
743 .modes = &edt_etm0700g0dh6_mode,
752 static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
755 .hsync_start = 800 + 168,
756 .hsync_end = 800 + 168 + 64,
757 .htotal = 800 + 168 + 64 + 88,
759 .vsync_start = 480 + 37,
760 .vsync_end = 480 + 37 + 2,
761 .vtotal = 480 + 37 + 2 + 8,
765 static const struct panel_desc foxlink_fl500wvr00_a0t = {
766 .modes = &foxlink_fl500wvr00_a0t_mode,
773 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
776 static const struct drm_display_mode giantplus_gpg482739qs5_mode = {
779 .hsync_start = 480 + 5,
780 .hsync_end = 480 + 5 + 1,
781 .htotal = 480 + 5 + 1 + 40,
783 .vsync_start = 272 + 8,
784 .vsync_end = 272 + 8 + 1,
785 .vtotal = 272 + 8 + 1 + 8,
789 static const struct panel_desc giantplus_gpg482739qs5 = {
790 .modes = &giantplus_gpg482739qs5_mode,
797 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
800 static const struct display_timing hannstar_hsd070pww1_timing = {
801 .pixelclock = { 64300000, 71100000, 82000000 },
802 .hactive = { 1280, 1280, 1280 },
803 .hfront_porch = { 1, 1, 10 },
804 .hback_porch = { 1, 1, 10 },
806 * According to the data sheet, the minimum horizontal blanking interval
807 * is 54 clocks (1 + 52 + 1), but tests with a Nitrogen6X have shown the
808 * minimum working horizontal blanking interval to be 60 clocks.
810 .hsync_len = { 58, 158, 661 },
811 .vactive = { 800, 800, 800 },
812 .vfront_porch = { 1, 1, 10 },
813 .vback_porch = { 1, 1, 10 },
814 .vsync_len = { 1, 21, 203 },
815 .flags = DISPLAY_FLAGS_DE_HIGH,
818 static const struct panel_desc hannstar_hsd070pww1 = {
819 .timings = &hannstar_hsd070pww1_timing,
826 .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
829 static const struct display_timing hannstar_hsd100pxn1_timing = {
830 .pixelclock = { 55000000, 65000000, 75000000 },
831 .hactive = { 1024, 1024, 1024 },
832 .hfront_porch = { 40, 40, 40 },
833 .hback_porch = { 220, 220, 220 },
834 .hsync_len = { 20, 60, 100 },
835 .vactive = { 768, 768, 768 },
836 .vfront_porch = { 7, 7, 7 },
837 .vback_porch = { 21, 21, 21 },
838 .vsync_len = { 10, 10, 10 },
839 .flags = DISPLAY_FLAGS_DE_HIGH,
842 static const struct panel_desc hannstar_hsd100pxn1 = {
843 .timings = &hannstar_hsd100pxn1_timing,
850 .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
853 static const struct drm_display_mode hitachi_tx23d38vm0caa_mode = {
856 .hsync_start = 800 + 85,
857 .hsync_end = 800 + 85 + 86,
858 .htotal = 800 + 85 + 86 + 85,
860 .vsync_start = 480 + 16,
861 .vsync_end = 480 + 16 + 13,
862 .vtotal = 480 + 16 + 13 + 16,
866 static const struct panel_desc hitachi_tx23d38vm0caa = {
867 .modes = &hitachi_tx23d38vm0caa_mode,
876 static const struct drm_display_mode innolux_at043tn24_mode = {
879 .hsync_start = 480 + 2,
880 .hsync_end = 480 + 2 + 41,
881 .htotal = 480 + 2 + 41 + 2,
883 .vsync_start = 272 + 2,
884 .vsync_end = 272 + 2 + 11,
885 .vtotal = 272 + 2 + 11 + 2,
887 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
890 static const struct panel_desc innolux_at043tn24 = {
891 .modes = &innolux_at043tn24_mode,
898 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
901 static const struct drm_display_mode innolux_g121i1_l01_mode = {
904 .hsync_start = 1280 + 64,
905 .hsync_end = 1280 + 64 + 32,
906 .htotal = 1280 + 64 + 32 + 64,
908 .vsync_start = 800 + 9,
909 .vsync_end = 800 + 9 + 6,
910 .vtotal = 800 + 9 + 6 + 9,
914 static const struct panel_desc innolux_g121i1_l01 = {
915 .modes = &innolux_g121i1_l01_mode,
924 static const struct drm_display_mode innolux_n116bge_mode = {
927 .hsync_start = 1366 + 136,
928 .hsync_end = 1366 + 136 + 30,
929 .htotal = 1366 + 136 + 30 + 60,
931 .vsync_start = 768 + 8,
932 .vsync_end = 768 + 8 + 12,
933 .vtotal = 768 + 8 + 12 + 12,
935 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
938 static const struct panel_desc innolux_n116bge = {
939 .modes = &innolux_n116bge_mode,
948 static const struct drm_display_mode innolux_n156bge_l21_mode = {
951 .hsync_start = 1366 + 16,
952 .hsync_end = 1366 + 16 + 34,
953 .htotal = 1366 + 16 + 34 + 50,
955 .vsync_start = 768 + 2,
956 .vsync_end = 768 + 2 + 6,
957 .vtotal = 768 + 2 + 6 + 12,
961 static const struct panel_desc innolux_n156bge_l21 = {
962 .modes = &innolux_n156bge_l21_mode,
971 static const struct drm_display_mode innolux_zj070na_01p_mode = {
974 .hsync_start = 1024 + 128,
975 .hsync_end = 1024 + 128 + 64,
976 .htotal = 1024 + 128 + 64 + 128,
978 .vsync_start = 600 + 16,
979 .vsync_end = 600 + 16 + 4,
980 .vtotal = 600 + 16 + 4 + 16,
984 static const struct panel_desc innolux_zj070na_01p = {
985 .modes = &innolux_zj070na_01p_mode,
994 static const struct drm_display_mode lg_lb070wv8_mode = {
997 .hsync_start = 800 + 88,
998 .hsync_end = 800 + 88 + 80,
999 .htotal = 800 + 88 + 80 + 88,
1001 .vsync_start = 480 + 10,
1002 .vsync_end = 480 + 10 + 25,
1003 .vtotal = 480 + 10 + 25 + 10,
1007 static const struct panel_desc lg_lb070wv8 = {
1008 .modes = &lg_lb070wv8_mode,
1015 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1018 static const struct drm_display_mode lg_lp079qx1_sp0v_mode = {
1021 .hsync_start = 1536 + 12,
1022 .hsync_end = 1536 + 12 + 16,
1023 .htotal = 1536 + 12 + 16 + 48,
1025 .vsync_start = 2048 + 8,
1026 .vsync_end = 2048 + 8 + 4,
1027 .vtotal = 2048 + 8 + 4 + 8,
1029 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1032 static const struct panel_desc lg_lp079qx1_sp0v = {
1033 .modes = &lg_lp079qx1_sp0v_mode,
1041 static const struct drm_display_mode lg_lp097qx1_spa1_mode = {
1044 .hsync_start = 2048 + 150,
1045 .hsync_end = 2048 + 150 + 5,
1046 .htotal = 2048 + 150 + 5 + 5,
1048 .vsync_start = 1536 + 3,
1049 .vsync_end = 1536 + 3 + 1,
1050 .vtotal = 1536 + 3 + 1 + 9,
1054 static const struct panel_desc lg_lp097qx1_spa1 = {
1055 .modes = &lg_lp097qx1_spa1_mode,
1063 static const struct drm_display_mode lg_lp129qe_mode = {
1066 .hsync_start = 2560 + 48,
1067 .hsync_end = 2560 + 48 + 32,
1068 .htotal = 2560 + 48 + 32 + 80,
1070 .vsync_start = 1700 + 3,
1071 .vsync_end = 1700 + 3 + 10,
1072 .vtotal = 1700 + 3 + 10 + 36,
1076 static const struct panel_desc lg_lp129qe = {
1077 .modes = &lg_lp129qe_mode,
1086 static const struct drm_display_mode nec_nl4827hc19_05b_mode = {
1089 .hsync_start = 480 + 2,
1090 .hsync_end = 480 + 2 + 41,
1091 .htotal = 480 + 2 + 41 + 2,
1093 .vsync_start = 272 + 2,
1094 .vsync_end = 272 + 2 + 4,
1095 .vtotal = 272 + 2 + 4 + 2,
1099 static const struct panel_desc nec_nl4827hc19_05b = {
1100 .modes = &nec_nl4827hc19_05b_mode,
1107 .bus_format = MEDIA_BUS_FMT_RGB888_1X24
1110 static const struct display_timing okaya_rs800480t_7x0gp_timing = {
1111 .pixelclock = { 30000000, 30000000, 40000000 },
1112 .hactive = { 800, 800, 800 },
1113 .hfront_porch = { 40, 40, 40 },
1114 .hback_porch = { 40, 40, 40 },
1115 .hsync_len = { 1, 48, 48 },
1116 .vactive = { 480, 480, 480 },
1117 .vfront_porch = { 13, 13, 13 },
1118 .vback_porch = { 29, 29, 29 },
1119 .vsync_len = { 3, 3, 3 },
1120 .flags = DISPLAY_FLAGS_DE_HIGH,
1123 static const struct panel_desc okaya_rs800480t_7x0gp = {
1124 .timings = &okaya_rs800480t_7x0gp_timing,
1137 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1140 static const struct drm_display_mode ortustech_com43h4m85ulc_mode = {
1143 .hsync_start = 480 + 10,
1144 .hsync_end = 480 + 10 + 10,
1145 .htotal = 480 + 10 + 10 + 15,
1147 .vsync_start = 800 + 3,
1148 .vsync_end = 800 + 3 + 3,
1149 .vtotal = 800 + 3 + 3 + 3,
1153 static const struct panel_desc ortustech_com43h4m85ulc = {
1154 .modes = &ortustech_com43h4m85ulc_mode,
1161 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1164 static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {
1167 .hsync_start = 2560 + 48,
1168 .hsync_end = 2560 + 48 + 32,
1169 .htotal = 2560 + 48 + 32 + 80,
1171 .vsync_start = 1600 + 2,
1172 .vsync_end = 1600 + 2 + 5,
1173 .vtotal = 1600 + 2 + 5 + 57,
1177 static const struct panel_desc samsung_lsn122dl01_c01 = {
1178 .modes = &samsung_lsn122dl01_c01_mode,
1186 static const struct drm_display_mode samsung_ltn101nt05_mode = {
1189 .hsync_start = 1024 + 24,
1190 .hsync_end = 1024 + 24 + 136,
1191 .htotal = 1024 + 24 + 136 + 160,
1193 .vsync_start = 600 + 3,
1194 .vsync_end = 600 + 3 + 6,
1195 .vtotal = 600 + 3 + 6 + 61,
1199 static const struct panel_desc samsung_ltn101nt05 = {
1200 .modes = &samsung_ltn101nt05_mode,
1209 static const struct drm_display_mode samsung_ltn140at29_301_mode = {
1212 .hsync_start = 1366 + 64,
1213 .hsync_end = 1366 + 64 + 48,
1214 .htotal = 1366 + 64 + 48 + 128,
1216 .vsync_start = 768 + 2,
1217 .vsync_end = 768 + 2 + 5,
1218 .vtotal = 768 + 2 + 5 + 17,
1222 static const struct panel_desc samsung_ltn140at29_301 = {
1223 .modes = &samsung_ltn140at29_301_mode,
1232 static const struct drm_display_mode shelly_sca07010_bfn_lnn_mode = {
1235 .hsync_start = 800 + 1,
1236 .hsync_end = 800 + 1 + 64,
1237 .htotal = 800 + 1 + 64 + 64,
1239 .vsync_start = 480 + 1,
1240 .vsync_end = 480 + 1 + 23,
1241 .vtotal = 480 + 1 + 23 + 22,
1245 static const struct panel_desc shelly_sca07010_bfn_lnn = {
1246 .modes = &shelly_sca07010_bfn_lnn_mode,
1252 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1255 static const struct of_device_id platform_of_match[] = {
1257 .compatible = "simple-panel",
1260 .compatible = "ampire,am800480r3tmqwa1h",
1261 .data = &ire_am800480r3tmqwa1h,
1263 .compatible = "auo,b101aw03",
1264 .data = &auo_b101aw03,
1266 .compatible = "auo,b101ean01",
1267 .data = &auo_b101ean01,
1269 .compatible = "auo,b101ew05",
1270 .data = &auo_b101ew05,
1272 .compatible = "auo,b101xtn01",
1273 .data = &auo_b101xtn01,
1275 .compatible = "auo,b116xw03",
1276 .data = &auo_b116xw03,
1278 .compatible = "auo,b133htn01",
1279 .data = &auo_b133htn01,
1281 .compatible = "auo,b133xtn01",
1282 .data = &auo_b133xtn01,
1284 .compatible = "avic,tm070ddh03",
1285 .data = &avic_tm070ddh03,
1287 .compatible = "chunghwa,claa070wp03xg",
1288 .data = &chunghwa_claa070wp03xg,
1290 .compatible = "chunghwa,claa101wa01a",
1291 .data = &chunghwa_claa101wa01a
1293 .compatible = "chunghwa,claa101wb01",
1294 .data = &chunghwa_claa101wb01
1296 .compatible = "edt,et057090dhu",
1297 .data = &edt_et057090dhu,
1299 .compatible = "edt,et070080dh6",
1300 .data = &edt_etm0700g0dh6,
1302 .compatible = "edt,etm0700g0dh6",
1303 .data = &edt_etm0700g0dh6,
1305 .compatible = "foxlink,fl500wvr00-a0t",
1306 .data = &foxlink_fl500wvr00_a0t,
1308 .compatible = "giantplus,gpg482739qs5",
1309 .data = &giantplus_gpg482739qs5
1311 .compatible = "hannstar,hsd070pww1",
1312 .data = &hannstar_hsd070pww1,
1314 .compatible = "hannstar,hsd100pxn1",
1315 .data = &hannstar_hsd100pxn1,
1317 .compatible = "hit,tx23d38vm0caa",
1318 .data = &hitachi_tx23d38vm0caa
1320 .compatible = "innolux,at043tn24",
1321 .data = &innolux_at043tn24,
1323 .compatible ="innolux,g121i1-l01",
1324 .data = &innolux_g121i1_l01
1326 .compatible = "innolux,n116bge",
1327 .data = &innolux_n116bge,
1329 .compatible = "innolux,n156bge-l21",
1330 .data = &innolux_n156bge_l21,
1332 .compatible = "innolux,zj070na-01p",
1333 .data = &innolux_zj070na_01p,
1335 .compatible = "lg,lb070wv8",
1336 .data = &lg_lb070wv8,
1338 .compatible = "lg,lp079qx1-sp0v",
1339 .data = &lg_lp079qx1_sp0v,
1341 .compatible = "lg,lp097qx1-spa1",
1342 .data = &lg_lp097qx1_spa1,
1344 .compatible = "lg,lp129qe",
1345 .data = &lg_lp129qe,
1347 .compatible = "nec,nl4827hc19-05b",
1348 .data = &nec_nl4827hc19_05b,
1350 .compatible = "okaya,rs800480t-7x0gp",
1351 .data = &okaya_rs800480t_7x0gp,
1353 .compatible = "ortustech,com43h4m85ulc",
1354 .data = &ortustech_com43h4m85ulc,
1356 .compatible = "samsung,lsn122dl01-c01",
1357 .data = &samsung_lsn122dl01_c01,
1359 .compatible = "samsung,ltn101nt05",
1360 .data = &samsung_ltn101nt05,
1362 .compatible = "samsung,ltn140at29-301",
1363 .data = &samsung_ltn140at29_301,
1365 .compatible = "shelly,sca07010-bfn-lnn",
1366 .data = &shelly_sca07010_bfn_lnn,
1371 MODULE_DEVICE_TABLE(of, platform_of_match);
1373 static int panel_simple_platform_probe(struct platform_device *pdev)
1375 const struct of_device_id *id;
1377 id = of_match_node(platform_of_match, pdev->dev.of_node);
1381 return panel_simple_probe(&pdev->dev, id->data);
1384 static int panel_simple_platform_remove(struct platform_device *pdev)
1386 return panel_simple_remove(&pdev->dev);
1389 static void panel_simple_platform_shutdown(struct platform_device *pdev)
1391 panel_simple_shutdown(&pdev->dev);
1394 static struct platform_driver panel_simple_platform_driver = {
1396 .name = "panel-simple",
1397 .of_match_table = platform_of_match,
1399 .probe = panel_simple_platform_probe,
1400 .remove = panel_simple_platform_remove,
1401 .shutdown = panel_simple_platform_shutdown,
1404 struct panel_desc_dsi {
1405 struct panel_desc desc;
1407 unsigned long flags;
1408 enum mipi_dsi_pixel_format format;
1412 static const struct drm_display_mode auo_b080uan01_mode = {
1415 .hsync_start = 1200 + 62,
1416 .hsync_end = 1200 + 62 + 4,
1417 .htotal = 1200 + 62 + 4 + 62,
1419 .vsync_start = 1920 + 9,
1420 .vsync_end = 1920 + 9 + 2,
1421 .vtotal = 1920 + 9 + 2 + 8,
1425 static const struct panel_desc_dsi auo_b080uan01 = {
1427 .modes = &auo_b080uan01_mode,
1435 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1436 .format = MIPI_DSI_FMT_RGB888,
1440 static const struct drm_display_mode boe_tv080wum_nl0_mode = {
1443 .hsync_start = 1200 + 120,
1444 .hsync_end = 1200 + 120 + 20,
1445 .htotal = 1200 + 120 + 20 + 21,
1447 .vsync_start = 1920 + 21,
1448 .vsync_end = 1920 + 21 + 3,
1449 .vtotal = 1920 + 21 + 3 + 18,
1451 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1454 static const struct panel_desc_dsi boe_tv080wum_nl0 = {
1456 .modes = &boe_tv080wum_nl0_mode,
1463 .flags = MIPI_DSI_MODE_VIDEO |
1464 MIPI_DSI_MODE_VIDEO_BURST |
1465 MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1466 .format = MIPI_DSI_FMT_RGB888,
1470 static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
1473 .hsync_start = 800 + 32,
1474 .hsync_end = 800 + 32 + 1,
1475 .htotal = 800 + 32 + 1 + 57,
1477 .vsync_start = 1280 + 28,
1478 .vsync_end = 1280 + 28 + 1,
1479 .vtotal = 1280 + 28 + 1 + 14,
1483 static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
1485 .modes = &lg_ld070wx3_sl01_mode,
1493 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1494 .format = MIPI_DSI_FMT_RGB888,
1498 static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
1501 .hsync_start = 720 + 12,
1502 .hsync_end = 720 + 12 + 4,
1503 .htotal = 720 + 12 + 4 + 112,
1505 .vsync_start = 1280 + 8,
1506 .vsync_end = 1280 + 8 + 4,
1507 .vtotal = 1280 + 8 + 4 + 12,
1511 static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
1513 .modes = &lg_lh500wx1_sd03_mode,
1521 .flags = MIPI_DSI_MODE_VIDEO,
1522 .format = MIPI_DSI_FMT_RGB888,
1526 static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
1529 .hsync_start = 1920 + 154,
1530 .hsync_end = 1920 + 154 + 16,
1531 .htotal = 1920 + 154 + 16 + 32,
1533 .vsync_start = 1200 + 17,
1534 .vsync_end = 1200 + 17 + 2,
1535 .vtotal = 1200 + 17 + 2 + 16,
1539 static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
1541 .modes = &panasonic_vvx10f004b00_mode,
1549 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1550 MIPI_DSI_CLOCK_NON_CONTINUOUS,
1551 .format = MIPI_DSI_FMT_RGB888,
1556 static const struct of_device_id dsi_of_match[] = {
1558 .compatible = "simple-panel-dsi",
1561 .compatible = "auo,b080uan01",
1562 .data = &auo_b080uan01
1564 .compatible = "boe,tv080wum-nl0",
1565 .data = &boe_tv080wum_nl0
1567 .compatible = "lg,ld070wx3-sl01",
1568 .data = &lg_ld070wx3_sl01
1570 .compatible = "lg,lh500wx1-sd03",
1571 .data = &lg_lh500wx1_sd03
1573 .compatible = "panasonic,vvx10f004b00",
1574 .data = &panasonic_vvx10f004b00
1579 MODULE_DEVICE_TABLE(of, dsi_of_match);
1581 static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
1583 const struct panel_desc_dsi *desc;
1584 const struct of_device_id *id;
1585 const struct panel_desc *pdesc;
1589 id = of_match_node(dsi_of_match, dsi->dev.of_node);
1596 dsi->mode_flags = desc->flags;
1597 dsi->format = desc->format;
1598 dsi->lanes = desc->lanes;
1599 pdesc = &desc->desc;
1604 err = panel_simple_probe(&dsi->dev, pdesc);
1608 if (!of_property_read_u32(dsi->dev.of_node, "dsi,flags", &val))
1609 dsi->mode_flags = val;
1611 if (!of_property_read_u32(dsi->dev.of_node, "dsi,format", &val))
1614 if (!of_property_read_u32(dsi->dev.of_node, "dsi,lanes", &val))
1617 return mipi_dsi_attach(dsi);
1620 static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
1624 err = mipi_dsi_detach(dsi);
1626 dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
1628 return panel_simple_remove(&dsi->dev);
1631 static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
1633 panel_simple_shutdown(&dsi->dev);
1636 static struct mipi_dsi_driver panel_simple_dsi_driver = {
1638 .name = "panel-simple-dsi",
1639 .of_match_table = dsi_of_match,
1641 .probe = panel_simple_dsi_probe,
1642 .remove = panel_simple_dsi_remove,
1643 .shutdown = panel_simple_dsi_shutdown,
1646 static int __init panel_simple_init(void)
1650 err = platform_driver_register(&panel_simple_platform_driver);
1654 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
1655 err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
1662 module_init(panel_simple_init);
1664 static void __exit panel_simple_exit(void)
1666 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
1667 mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
1669 platform_driver_unregister(&panel_simple_platform_driver);
1671 module_exit(panel_simple_exit);
1673 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
1674 MODULE_DESCRIPTION("DRM Driver for Simple Panels");
1675 MODULE_LICENSE("GPL and additional rights");