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;
156 mode = drm_mode_create(drm);
160 ret = of_get_drm_display_mode(panel->dev->of_node, mode,
163 dev_dbg(panel->dev, "failed to find dts display timings\n");
164 drm_mode_destroy(drm, mode);
168 drm_mode_set_name(mode);
169 mode->type |= DRM_MODE_TYPE_PREFERRED;
170 drm_mode_probed_add(connector, mode);
175 static int panel_simple_disable(struct drm_panel *panel)
177 struct panel_simple *p = to_panel_simple(panel);
183 p->backlight->props.power = FB_BLANK_POWERDOWN;
184 backlight_update_status(p->backlight);
187 if (p->desc && p->desc->delay.disable)
188 msleep(p->desc->delay.disable);
195 static int panel_simple_unprepare(struct drm_panel *panel)
197 struct panel_simple *p = to_panel_simple(panel);
203 gpiod_set_value_cansleep(p->enable_gpio, 0);
205 regulator_disable(p->supply);
207 if (p->desc && p->desc->delay.unprepare)
208 msleep(p->desc->delay.unprepare);
215 static int panel_simple_prepare(struct drm_panel *panel)
217 struct panel_simple *p = to_panel_simple(panel);
223 err = regulator_enable(p->supply);
225 dev_err(panel->dev, "failed to enable supply: %d\n", err);
230 gpiod_set_value_cansleep(p->enable_gpio, 1);
232 if (p->desc && p->desc->delay.prepare)
233 msleep(p->desc->delay.prepare);
240 static int panel_simple_enable(struct drm_panel *panel)
242 struct panel_simple *p = to_panel_simple(panel);
247 if (p->desc && p->desc->delay.enable)
248 msleep(p->desc->delay.enable);
251 p->backlight->props.power = FB_BLANK_UNBLANK;
252 backlight_update_status(p->backlight);
260 static int panel_simple_get_modes(struct drm_panel *panel)
262 struct panel_simple *p = to_panel_simple(panel);
265 /* probe EDID if a DDC bus is available */
267 struct edid *edid = drm_get_edid(panel->connector, p->ddc);
268 drm_mode_connector_update_edid_property(panel->connector, edid);
270 num += drm_add_edid_modes(panel->connector, edid);
275 /* add hard-coded panel modes */
276 num += panel_simple_get_fixed_modes(p);
278 /* add device node plane modes */
279 num += panel_simple_of_get_native_mode(p);
284 static int panel_simple_get_timings(struct drm_panel *panel,
285 unsigned int num_timings,
286 struct display_timing *timings)
288 struct panel_simple *p = to_panel_simple(panel);
294 if (p->desc->num_timings < num_timings)
295 num_timings = p->desc->num_timings;
298 for (i = 0; i < num_timings; i++)
299 timings[i] = p->desc->timings[i];
301 return p->desc->num_timings;
304 static const struct drm_panel_funcs panel_simple_funcs = {
305 .disable = panel_simple_disable,
306 .unprepare = panel_simple_unprepare,
307 .prepare = panel_simple_prepare,
308 .enable = panel_simple_enable,
309 .get_modes = panel_simple_get_modes,
310 .get_timings = panel_simple_get_timings,
313 static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
315 struct device_node *backlight, *ddc;
316 struct panel_simple *panel;
319 panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
323 panel->enabled = false;
324 panel->prepared = false;
328 panel->supply = devm_regulator_get(dev, "power");
329 if (IS_ERR(panel->supply))
330 return PTR_ERR(panel->supply);
332 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
334 if (IS_ERR(panel->enable_gpio)) {
335 err = PTR_ERR(panel->enable_gpio);
336 dev_err(dev, "failed to request GPIO: %d\n", err);
340 backlight = of_parse_phandle(dev->of_node, "backlight", 0);
342 panel->backlight = of_find_backlight_by_node(backlight);
343 of_node_put(backlight);
345 if (!panel->backlight)
346 return -EPROBE_DEFER;
349 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
351 panel->ddc = of_find_i2c_adapter_by_node(ddc);
360 drm_panel_init(&panel->base);
361 panel->base.dev = dev;
362 panel->base.funcs = &panel_simple_funcs;
364 err = drm_panel_add(&panel->base);
368 dev_set_drvdata(dev, panel);
374 put_device(&panel->ddc->dev);
376 if (panel->backlight)
377 put_device(&panel->backlight->dev);
382 static int panel_simple_remove(struct device *dev)
384 struct panel_simple *panel = dev_get_drvdata(dev);
386 drm_panel_detach(&panel->base);
387 drm_panel_remove(&panel->base);
389 panel_simple_disable(&panel->base);
392 put_device(&panel->ddc->dev);
394 if (panel->backlight)
395 put_device(&panel->backlight->dev);
400 static void panel_simple_shutdown(struct device *dev)
402 struct panel_simple *panel = dev_get_drvdata(dev);
404 panel_simple_disable(&panel->base);
407 static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {
410 .hsync_start = 800 + 0,
411 .hsync_end = 800 + 0 + 255,
412 .htotal = 800 + 0 + 255 + 0,
414 .vsync_start = 480 + 2,
415 .vsync_end = 480 + 2 + 45,
416 .vtotal = 480 + 2 + 45 + 0,
418 .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
421 static const struct panel_desc ampire_am800480r3tmqwa1h = {
422 .modes = &ire_am800480r3tmqwa1h_mode,
429 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
432 static const struct drm_display_mode auo_b101aw03_mode = {
435 .hsync_start = 1024 + 156,
436 .hsync_end = 1024 + 156 + 8,
437 .htotal = 1024 + 156 + 8 + 156,
439 .vsync_start = 600 + 16,
440 .vsync_end = 600 + 16 + 6,
441 .vtotal = 600 + 16 + 6 + 16,
445 static const struct panel_desc auo_b101aw03 = {
446 .modes = &auo_b101aw03_mode,
455 static const struct drm_display_mode auo_b101ean01_mode = {
458 .hsync_start = 1280 + 119,
459 .hsync_end = 1280 + 119 + 32,
460 .htotal = 1280 + 119 + 32 + 21,
462 .vsync_start = 800 + 4,
463 .vsync_end = 800 + 4 + 20,
464 .vtotal = 800 + 4 + 20 + 8,
468 static const struct panel_desc auo_b101ean01 = {
469 .modes = &auo_b101ean01_mode,
478 static const struct drm_display_mode auo_b101ew05_mode = {
481 .hsync_start = 1280 + 18,
482 .hsync_end = 1280 + 18 + 10,
483 .htotal = 1280 + 18 + 10 + 100,
485 .vsync_start = 800 + 6,
486 .vsync_end = 800 + 6 + 2,
487 .vtotal = 800 + 6 + 2 + 8,
491 static const struct panel_desc auo_b101ew05 = {
492 .modes = &auo_b101ew05_mode,
501 static const struct drm_display_mode auo_b101xtn01_mode = {
504 .hsync_start = 1366 + 20,
505 .hsync_end = 1366 + 20 + 70,
506 .htotal = 1366 + 20 + 70,
508 .vsync_start = 768 + 14,
509 .vsync_end = 768 + 14 + 42,
510 .vtotal = 768 + 14 + 42,
512 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
515 static const struct panel_desc auo_b101xtn01 = {
516 .modes = &auo_b101xtn01_mode,
525 static const struct drm_display_mode auo_b116xw03_mode = {
528 .hsync_start = 1366 + 40,
529 .hsync_end = 1366 + 40 + 40,
530 .htotal = 1366 + 40 + 40 + 32,
532 .vsync_start = 768 + 10,
533 .vsync_end = 768 + 10 + 12,
534 .vtotal = 768 + 10 + 12 + 6,
538 static const struct panel_desc auo_b116xw03 = {
539 .modes = &auo_b116xw03_mode,
548 static const struct drm_display_mode auo_b133xtn01_mode = {
551 .hsync_start = 1366 + 48,
552 .hsync_end = 1366 + 48 + 32,
553 .htotal = 1366 + 48 + 32 + 20,
555 .vsync_start = 768 + 3,
556 .vsync_end = 768 + 3 + 6,
557 .vtotal = 768 + 3 + 6 + 13,
561 static const struct panel_desc auo_b133xtn01 = {
562 .modes = &auo_b133xtn01_mode,
571 static const struct drm_display_mode auo_b133htn01_mode = {
574 .hsync_start = 1920 + 172,
575 .hsync_end = 1920 + 172 + 80,
576 .htotal = 1920 + 172 + 80 + 60,
578 .vsync_start = 1080 + 25,
579 .vsync_end = 1080 + 25 + 10,
580 .vtotal = 1080 + 25 + 10 + 10,
584 static const struct panel_desc auo_b133htn01 = {
585 .modes = &auo_b133htn01_mode,
599 static const struct drm_display_mode avic_tm070ddh03_mode = {
602 .hsync_start = 1024 + 160,
603 .hsync_end = 1024 + 160 + 4,
604 .htotal = 1024 + 160 + 4 + 156,
606 .vsync_start = 600 + 17,
607 .vsync_end = 600 + 17 + 1,
608 .vtotal = 600 + 17 + 1 + 17,
612 static const struct panel_desc avic_tm070ddh03 = {
613 .modes = &avic_tm070ddh03_mode,
627 static const struct drm_display_mode chunghwa_claa070wp03xg_mode = {
630 .hsync_start = 800 + 24,
631 .hsync_end = 800 + 24 + 16,
632 .htotal = 800 + 24 + 16 + 24,
634 .vsync_start = 1280 + 2,
635 .vsync_end = 1280 + 2 + 2,
636 .vtotal = 1280 + 2 + 2 + 4,
640 static const struct panel_desc chunghwa_claa070wp03xg = {
641 .modes = &chunghwa_claa070wp03xg_mode,
650 static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
653 .hsync_start = 1366 + 58,
654 .hsync_end = 1366 + 58 + 58,
655 .htotal = 1366 + 58 + 58 + 58,
657 .vsync_start = 768 + 4,
658 .vsync_end = 768 + 4 + 4,
659 .vtotal = 768 + 4 + 4 + 4,
663 static const struct panel_desc chunghwa_claa101wa01a = {
664 .modes = &chunghwa_claa101wa01a_mode,
673 static const struct drm_display_mode chunghwa_claa101wb01_mode = {
676 .hsync_start = 1366 + 48,
677 .hsync_end = 1366 + 48 + 32,
678 .htotal = 1366 + 48 + 32 + 20,
680 .vsync_start = 768 + 16,
681 .vsync_end = 768 + 16 + 8,
682 .vtotal = 768 + 16 + 8 + 16,
686 static const struct panel_desc chunghwa_claa101wb01 = {
687 .modes = &chunghwa_claa101wb01_mode,
696 static const struct drm_display_mode edt_et057090dhu_mode = {
699 .hsync_start = 640 + 16,
700 .hsync_end = 640 + 16 + 30,
701 .htotal = 640 + 16 + 30 + 114,
703 .vsync_start = 480 + 10,
704 .vsync_end = 480 + 10 + 3,
705 .vtotal = 480 + 10 + 3 + 32,
707 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
710 static const struct panel_desc edt_et057090dhu = {
711 .modes = &edt_et057090dhu_mode,
720 static const struct drm_display_mode edt_etm0700g0dh6_mode = {
723 .hsync_start = 800 + 40,
724 .hsync_end = 800 + 40 + 128,
725 .htotal = 800 + 40 + 128 + 88,
727 .vsync_start = 480 + 10,
728 .vsync_end = 480 + 10 + 2,
729 .vtotal = 480 + 10 + 2 + 33,
731 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
734 static const struct panel_desc edt_etm0700g0dh6 = {
735 .modes = &edt_etm0700g0dh6_mode,
744 static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
747 .hsync_start = 800 + 168,
748 .hsync_end = 800 + 168 + 64,
749 .htotal = 800 + 168 + 64 + 88,
751 .vsync_start = 480 + 37,
752 .vsync_end = 480 + 37 + 2,
753 .vtotal = 480 + 37 + 2 + 8,
757 static const struct panel_desc foxlink_fl500wvr00_a0t = {
758 .modes = &foxlink_fl500wvr00_a0t_mode,
765 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
768 static const struct drm_display_mode giantplus_gpg482739qs5_mode = {
771 .hsync_start = 480 + 5,
772 .hsync_end = 480 + 5 + 1,
773 .htotal = 480 + 5 + 1 + 40,
775 .vsync_start = 272 + 8,
776 .vsync_end = 272 + 8 + 1,
777 .vtotal = 272 + 8 + 1 + 8,
781 static const struct panel_desc giantplus_gpg482739qs5 = {
782 .modes = &giantplus_gpg482739qs5_mode,
789 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
792 static const struct display_timing hannstar_hsd070pww1_timing = {
793 .pixelclock = { 64300000, 71100000, 82000000 },
794 .hactive = { 1280, 1280, 1280 },
795 .hfront_porch = { 1, 1, 10 },
796 .hback_porch = { 1, 1, 10 },
798 * According to the data sheet, the minimum horizontal blanking interval
799 * is 54 clocks (1 + 52 + 1), but tests with a Nitrogen6X have shown the
800 * minimum working horizontal blanking interval to be 60 clocks.
802 .hsync_len = { 58, 158, 661 },
803 .vactive = { 800, 800, 800 },
804 .vfront_porch = { 1, 1, 10 },
805 .vback_porch = { 1, 1, 10 },
806 .vsync_len = { 1, 21, 203 },
807 .flags = DISPLAY_FLAGS_DE_HIGH,
810 static const struct panel_desc hannstar_hsd070pww1 = {
811 .timings = &hannstar_hsd070pww1_timing,
818 .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
821 static const struct display_timing hannstar_hsd100pxn1_timing = {
822 .pixelclock = { 55000000, 65000000, 75000000 },
823 .hactive = { 1024, 1024, 1024 },
824 .hfront_porch = { 40, 40, 40 },
825 .hback_porch = { 220, 220, 220 },
826 .hsync_len = { 20, 60, 100 },
827 .vactive = { 768, 768, 768 },
828 .vfront_porch = { 7, 7, 7 },
829 .vback_porch = { 21, 21, 21 },
830 .vsync_len = { 10, 10, 10 },
831 .flags = DISPLAY_FLAGS_DE_HIGH,
834 static const struct panel_desc hannstar_hsd100pxn1 = {
835 .timings = &hannstar_hsd100pxn1_timing,
842 .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
845 static const struct drm_display_mode hitachi_tx23d38vm0caa_mode = {
848 .hsync_start = 800 + 85,
849 .hsync_end = 800 + 85 + 86,
850 .htotal = 800 + 85 + 86 + 85,
852 .vsync_start = 480 + 16,
853 .vsync_end = 480 + 16 + 13,
854 .vtotal = 480 + 16 + 13 + 16,
858 static const struct panel_desc hitachi_tx23d38vm0caa = {
859 .modes = &hitachi_tx23d38vm0caa_mode,
868 static const struct drm_display_mode innolux_at043tn24_mode = {
871 .hsync_start = 480 + 2,
872 .hsync_end = 480 + 2 + 41,
873 .htotal = 480 + 2 + 41 + 2,
875 .vsync_start = 272 + 2,
876 .vsync_end = 272 + 2 + 11,
877 .vtotal = 272 + 2 + 11 + 2,
879 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
882 static const struct panel_desc innolux_at043tn24 = {
883 .modes = &innolux_at043tn24_mode,
890 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
893 static const struct drm_display_mode innolux_g121i1_l01_mode = {
896 .hsync_start = 1280 + 64,
897 .hsync_end = 1280 + 64 + 32,
898 .htotal = 1280 + 64 + 32 + 64,
900 .vsync_start = 800 + 9,
901 .vsync_end = 800 + 9 + 6,
902 .vtotal = 800 + 9 + 6 + 9,
906 static const struct panel_desc innolux_g121i1_l01 = {
907 .modes = &innolux_g121i1_l01_mode,
916 static const struct drm_display_mode innolux_n116bge_mode = {
919 .hsync_start = 1366 + 136,
920 .hsync_end = 1366 + 136 + 30,
921 .htotal = 1366 + 136 + 30 + 60,
923 .vsync_start = 768 + 8,
924 .vsync_end = 768 + 8 + 12,
925 .vtotal = 768 + 8 + 12 + 12,
927 .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
930 static const struct panel_desc innolux_n116bge = {
931 .modes = &innolux_n116bge_mode,
940 static const struct drm_display_mode innolux_n156bge_l21_mode = {
943 .hsync_start = 1366 + 16,
944 .hsync_end = 1366 + 16 + 34,
945 .htotal = 1366 + 16 + 34 + 50,
947 .vsync_start = 768 + 2,
948 .vsync_end = 768 + 2 + 6,
949 .vtotal = 768 + 2 + 6 + 12,
953 static const struct panel_desc innolux_n156bge_l21 = {
954 .modes = &innolux_n156bge_l21_mode,
963 static const struct drm_display_mode innolux_zj070na_01p_mode = {
966 .hsync_start = 1024 + 128,
967 .hsync_end = 1024 + 128 + 64,
968 .htotal = 1024 + 128 + 64 + 128,
970 .vsync_start = 600 + 16,
971 .vsync_end = 600 + 16 + 4,
972 .vtotal = 600 + 16 + 4 + 16,
976 static const struct panel_desc innolux_zj070na_01p = {
977 .modes = &innolux_zj070na_01p_mode,
986 static const struct drm_display_mode lg_lb070wv8_mode = {
989 .hsync_start = 800 + 88,
990 .hsync_end = 800 + 88 + 80,
991 .htotal = 800 + 88 + 80 + 88,
993 .vsync_start = 480 + 10,
994 .vsync_end = 480 + 10 + 25,
995 .vtotal = 480 + 10 + 25 + 10,
999 static const struct panel_desc lg_lb070wv8 = {
1000 .modes = &lg_lb070wv8_mode,
1007 .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
1010 static const struct drm_display_mode lg_lp079qx1_sp0v_mode = {
1013 .hsync_start = 1536 + 12,
1014 .hsync_end = 1536 + 12 + 16,
1015 .htotal = 1536 + 12 + 16 + 48,
1017 .vsync_start = 2048 + 8,
1018 .vsync_end = 2048 + 8 + 4,
1019 .vtotal = 2048 + 8 + 4 + 8,
1021 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1024 static const struct panel_desc lg_lp079qx1_sp0v = {
1025 .modes = &lg_lp079qx1_sp0v_mode,
1033 static const struct drm_display_mode lg_lp097qx1_spa1_mode = {
1036 .hsync_start = 2048 + 150,
1037 .hsync_end = 2048 + 150 + 5,
1038 .htotal = 2048 + 150 + 5 + 5,
1040 .vsync_start = 1536 + 3,
1041 .vsync_end = 1536 + 3 + 1,
1042 .vtotal = 1536 + 3 + 1 + 9,
1046 static const struct panel_desc lg_lp097qx1_spa1 = {
1047 .modes = &lg_lp097qx1_spa1_mode,
1055 static const struct drm_display_mode lg_lp129qe_mode = {
1058 .hsync_start = 2560 + 48,
1059 .hsync_end = 2560 + 48 + 32,
1060 .htotal = 2560 + 48 + 32 + 80,
1062 .vsync_start = 1700 + 3,
1063 .vsync_end = 1700 + 3 + 10,
1064 .vtotal = 1700 + 3 + 10 + 36,
1068 static const struct panel_desc lg_lp129qe = {
1069 .modes = &lg_lp129qe_mode,
1078 static const struct drm_display_mode nec_nl4827hc19_05b_mode = {
1081 .hsync_start = 480 + 2,
1082 .hsync_end = 480 + 2 + 41,
1083 .htotal = 480 + 2 + 41 + 2,
1085 .vsync_start = 272 + 2,
1086 .vsync_end = 272 + 2 + 4,
1087 .vtotal = 272 + 2 + 4 + 2,
1091 static const struct panel_desc nec_nl4827hc19_05b = {
1092 .modes = &nec_nl4827hc19_05b_mode,
1099 .bus_format = MEDIA_BUS_FMT_RGB888_1X24
1102 static const struct display_timing okaya_rs800480t_7x0gp_timing = {
1103 .pixelclock = { 30000000, 30000000, 40000000 },
1104 .hactive = { 800, 800, 800 },
1105 .hfront_porch = { 40, 40, 40 },
1106 .hback_porch = { 40, 40, 40 },
1107 .hsync_len = { 1, 48, 48 },
1108 .vactive = { 480, 480, 480 },
1109 .vfront_porch = { 13, 13, 13 },
1110 .vback_porch = { 29, 29, 29 },
1111 .vsync_len = { 3, 3, 3 },
1112 .flags = DISPLAY_FLAGS_DE_HIGH,
1115 static const struct panel_desc okaya_rs800480t_7x0gp = {
1116 .timings = &okaya_rs800480t_7x0gp_timing,
1129 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1132 static const struct drm_display_mode ortustech_com43h4m85ulc_mode = {
1135 .hsync_start = 480 + 10,
1136 .hsync_end = 480 + 10 + 10,
1137 .htotal = 480 + 10 + 10 + 15,
1139 .vsync_start = 800 + 3,
1140 .vsync_end = 800 + 3 + 3,
1141 .vtotal = 800 + 3 + 3 + 3,
1145 static const struct panel_desc ortustech_com43h4m85ulc = {
1146 .modes = &ortustech_com43h4m85ulc_mode,
1153 .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
1156 static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {
1159 .hsync_start = 2560 + 48,
1160 .hsync_end = 2560 + 48 + 32,
1161 .htotal = 2560 + 48 + 32 + 80,
1163 .vsync_start = 1600 + 2,
1164 .vsync_end = 1600 + 2 + 5,
1165 .vtotal = 1600 + 2 + 5 + 57,
1169 static const struct panel_desc samsung_lsn122dl01_c01 = {
1170 .modes = &samsung_lsn122dl01_c01_mode,
1178 static const struct drm_display_mode samsung_ltn101nt05_mode = {
1181 .hsync_start = 1024 + 24,
1182 .hsync_end = 1024 + 24 + 136,
1183 .htotal = 1024 + 24 + 136 + 160,
1185 .vsync_start = 600 + 3,
1186 .vsync_end = 600 + 3 + 6,
1187 .vtotal = 600 + 3 + 6 + 61,
1191 static const struct panel_desc samsung_ltn101nt05 = {
1192 .modes = &samsung_ltn101nt05_mode,
1201 static const struct drm_display_mode samsung_ltn140at29_301_mode = {
1204 .hsync_start = 1366 + 64,
1205 .hsync_end = 1366 + 64 + 48,
1206 .htotal = 1366 + 64 + 48 + 128,
1208 .vsync_start = 768 + 2,
1209 .vsync_end = 768 + 2 + 5,
1210 .vtotal = 768 + 2 + 5 + 17,
1214 static const struct panel_desc samsung_ltn140at29_301 = {
1215 .modes = &samsung_ltn140at29_301_mode,
1224 static const struct drm_display_mode shelly_sca07010_bfn_lnn_mode = {
1227 .hsync_start = 800 + 1,
1228 .hsync_end = 800 + 1 + 64,
1229 .htotal = 800 + 1 + 64 + 64,
1231 .vsync_start = 480 + 1,
1232 .vsync_end = 480 + 1 + 23,
1233 .vtotal = 480 + 1 + 23 + 22,
1237 static const struct panel_desc shelly_sca07010_bfn_lnn = {
1238 .modes = &shelly_sca07010_bfn_lnn_mode,
1244 .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
1247 static const struct of_device_id platform_of_match[] = {
1249 .compatible = "simple-panel",
1252 .compatible = "ampire,am800480r3tmqwa1h",
1253 .data = &ire_am800480r3tmqwa1h,
1255 .compatible = "auo,b101aw03",
1256 .data = &auo_b101aw03,
1258 .compatible = "auo,b101ean01",
1259 .data = &auo_b101ean01,
1261 .compatible = "auo,b101ew05",
1262 .data = &auo_b101ew05,
1264 .compatible = "auo,b101xtn01",
1265 .data = &auo_b101xtn01,
1267 .compatible = "auo,b116xw03",
1268 .data = &auo_b116xw03,
1270 .compatible = "auo,b133htn01",
1271 .data = &auo_b133htn01,
1273 .compatible = "auo,b133xtn01",
1274 .data = &auo_b133xtn01,
1276 .compatible = "avic,tm070ddh03",
1277 .data = &avic_tm070ddh03,
1279 .compatible = "chunghwa,claa070wp03xg",
1280 .data = &chunghwa_claa070wp03xg,
1282 .compatible = "chunghwa,claa101wa01a",
1283 .data = &chunghwa_claa101wa01a
1285 .compatible = "chunghwa,claa101wb01",
1286 .data = &chunghwa_claa101wb01
1288 .compatible = "edt,et057090dhu",
1289 .data = &edt_et057090dhu,
1291 .compatible = "edt,et070080dh6",
1292 .data = &edt_etm0700g0dh6,
1294 .compatible = "edt,etm0700g0dh6",
1295 .data = &edt_etm0700g0dh6,
1297 .compatible = "foxlink,fl500wvr00-a0t",
1298 .data = &foxlink_fl500wvr00_a0t,
1300 .compatible = "giantplus,gpg482739qs5",
1301 .data = &giantplus_gpg482739qs5
1303 .compatible = "hannstar,hsd070pww1",
1304 .data = &hannstar_hsd070pww1,
1306 .compatible = "hannstar,hsd100pxn1",
1307 .data = &hannstar_hsd100pxn1,
1309 .compatible = "hit,tx23d38vm0caa",
1310 .data = &hitachi_tx23d38vm0caa
1312 .compatible = "innolux,at043tn24",
1313 .data = &innolux_at043tn24,
1315 .compatible ="innolux,g121i1-l01",
1316 .data = &innolux_g121i1_l01
1318 .compatible = "innolux,n116bge",
1319 .data = &innolux_n116bge,
1321 .compatible = "innolux,n156bge-l21",
1322 .data = &innolux_n156bge_l21,
1324 .compatible = "innolux,zj070na-01p",
1325 .data = &innolux_zj070na_01p,
1327 .compatible = "lg,lb070wv8",
1328 .data = &lg_lb070wv8,
1330 .compatible = "lg,lp079qx1-sp0v",
1331 .data = &lg_lp079qx1_sp0v,
1333 .compatible = "lg,lp097qx1-spa1",
1334 .data = &lg_lp097qx1_spa1,
1336 .compatible = "lg,lp129qe",
1337 .data = &lg_lp129qe,
1339 .compatible = "nec,nl4827hc19-05b",
1340 .data = &nec_nl4827hc19_05b,
1342 .compatible = "okaya,rs800480t-7x0gp",
1343 .data = &okaya_rs800480t_7x0gp,
1345 .compatible = "ortustech,com43h4m85ulc",
1346 .data = &ortustech_com43h4m85ulc,
1348 .compatible = "samsung,lsn122dl01-c01",
1349 .data = &samsung_lsn122dl01_c01,
1351 .compatible = "samsung,ltn101nt05",
1352 .data = &samsung_ltn101nt05,
1354 .compatible = "samsung,ltn140at29-301",
1355 .data = &samsung_ltn140at29_301,
1357 .compatible = "shelly,sca07010-bfn-lnn",
1358 .data = &shelly_sca07010_bfn_lnn,
1363 MODULE_DEVICE_TABLE(of, platform_of_match);
1365 static int panel_simple_platform_probe(struct platform_device *pdev)
1367 const struct of_device_id *id;
1369 id = of_match_node(platform_of_match, pdev->dev.of_node);
1373 return panel_simple_probe(&pdev->dev, id->data);
1376 static int panel_simple_platform_remove(struct platform_device *pdev)
1378 return panel_simple_remove(&pdev->dev);
1381 static void panel_simple_platform_shutdown(struct platform_device *pdev)
1383 panel_simple_shutdown(&pdev->dev);
1386 static struct platform_driver panel_simple_platform_driver = {
1388 .name = "panel-simple",
1389 .of_match_table = platform_of_match,
1391 .probe = panel_simple_platform_probe,
1392 .remove = panel_simple_platform_remove,
1393 .shutdown = panel_simple_platform_shutdown,
1396 struct panel_desc_dsi {
1397 struct panel_desc desc;
1399 unsigned long flags;
1400 enum mipi_dsi_pixel_format format;
1404 static const struct drm_display_mode auo_b080uan01_mode = {
1407 .hsync_start = 1200 + 62,
1408 .hsync_end = 1200 + 62 + 4,
1409 .htotal = 1200 + 62 + 4 + 62,
1411 .vsync_start = 1920 + 9,
1412 .vsync_end = 1920 + 9 + 2,
1413 .vtotal = 1920 + 9 + 2 + 8,
1417 static const struct panel_desc_dsi auo_b080uan01 = {
1419 .modes = &auo_b080uan01_mode,
1427 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1428 .format = MIPI_DSI_FMT_RGB888,
1432 static const struct drm_display_mode boe_tv080wum_nl0_mode = {
1435 .hsync_start = 1200 + 120,
1436 .hsync_end = 1200 + 120 + 20,
1437 .htotal = 1200 + 120 + 20 + 21,
1439 .vsync_start = 1920 + 21,
1440 .vsync_end = 1920 + 21 + 3,
1441 .vtotal = 1920 + 21 + 3 + 18,
1443 .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
1446 static const struct panel_desc_dsi boe_tv080wum_nl0 = {
1448 .modes = &boe_tv080wum_nl0_mode,
1455 .flags = MIPI_DSI_MODE_VIDEO |
1456 MIPI_DSI_MODE_VIDEO_BURST |
1457 MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1458 .format = MIPI_DSI_FMT_RGB888,
1462 static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
1465 .hsync_start = 800 + 32,
1466 .hsync_end = 800 + 32 + 1,
1467 .htotal = 800 + 32 + 1 + 57,
1469 .vsync_start = 1280 + 28,
1470 .vsync_end = 1280 + 28 + 1,
1471 .vtotal = 1280 + 28 + 1 + 14,
1475 static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
1477 .modes = &lg_ld070wx3_sl01_mode,
1485 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
1486 .format = MIPI_DSI_FMT_RGB888,
1490 static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
1493 .hsync_start = 720 + 12,
1494 .hsync_end = 720 + 12 + 4,
1495 .htotal = 720 + 12 + 4 + 112,
1497 .vsync_start = 1280 + 8,
1498 .vsync_end = 1280 + 8 + 4,
1499 .vtotal = 1280 + 8 + 4 + 12,
1503 static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
1505 .modes = &lg_lh500wx1_sd03_mode,
1513 .flags = MIPI_DSI_MODE_VIDEO,
1514 .format = MIPI_DSI_FMT_RGB888,
1518 static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
1521 .hsync_start = 1920 + 154,
1522 .hsync_end = 1920 + 154 + 16,
1523 .htotal = 1920 + 154 + 16 + 32,
1525 .vsync_start = 1200 + 17,
1526 .vsync_end = 1200 + 17 + 2,
1527 .vtotal = 1200 + 17 + 2 + 16,
1531 static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
1533 .modes = &panasonic_vvx10f004b00_mode,
1541 .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1542 MIPI_DSI_CLOCK_NON_CONTINUOUS,
1543 .format = MIPI_DSI_FMT_RGB888,
1548 static const struct of_device_id dsi_of_match[] = {
1550 .compatible = "simple-panel-dsi",
1553 .compatible = "auo,b080uan01",
1554 .data = &auo_b080uan01
1556 .compatible = "boe,tv080wum-nl0",
1557 .data = &boe_tv080wum_nl0
1559 .compatible = "lg,ld070wx3-sl01",
1560 .data = &lg_ld070wx3_sl01
1562 .compatible = "lg,lh500wx1-sd03",
1563 .data = &lg_lh500wx1_sd03
1565 .compatible = "panasonic,vvx10f004b00",
1566 .data = &panasonic_vvx10f004b00
1571 MODULE_DEVICE_TABLE(of, dsi_of_match);
1573 static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
1575 const struct panel_desc_dsi *desc;
1576 const struct of_device_id *id;
1577 const struct panel_desc *pdesc;
1581 id = of_match_node(dsi_of_match, dsi->dev.of_node);
1588 dsi->mode_flags = desc->flags;
1589 dsi->format = desc->format;
1590 dsi->lanes = desc->lanes;
1591 pdesc = &desc->desc;
1596 err = panel_simple_probe(&dsi->dev, pdesc);
1600 if (!of_property_read_u32(dsi->dev.of_node, "dsi,flags", &val))
1601 dsi->mode_flags = val;
1603 if (!of_property_read_u32(dsi->dev.of_node, "dsi,format", &val))
1606 if (!of_property_read_u32(dsi->dev.of_node, "dsi,lanes", &val))
1609 return mipi_dsi_attach(dsi);
1612 static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
1616 err = mipi_dsi_detach(dsi);
1618 dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
1620 return panel_simple_remove(&dsi->dev);
1623 static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
1625 panel_simple_shutdown(&dsi->dev);
1628 static struct mipi_dsi_driver panel_simple_dsi_driver = {
1630 .name = "panel-simple-dsi",
1631 .of_match_table = dsi_of_match,
1633 .probe = panel_simple_dsi_probe,
1634 .remove = panel_simple_dsi_remove,
1635 .shutdown = panel_simple_dsi_shutdown,
1638 static int __init panel_simple_init(void)
1642 err = platform_driver_register(&panel_simple_platform_driver);
1646 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
1647 err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
1654 module_init(panel_simple_init);
1656 static void __exit panel_simple_exit(void)
1658 if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
1659 mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
1661 platform_driver_unregister(&panel_simple_platform_driver);
1663 module_exit(panel_simple_exit);
1665 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
1666 MODULE_DESCRIPTION("DRM Driver for Simple Panels");
1667 MODULE_LICENSE("GPL and additional rights");