15 #include <linux/kernel.h>
16 #include <linux/module.h>
19 #include <drm/exynos_drm.h>
31 #define get_vidi_context(dev) platform_get_drvdata(to_platform_device(dev))
64 static const char fake_edid_info[] = {
65 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x4c, 0x2d, 0x05, 0x05,
66 0x00, 0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78,
67 0x0a, 0xee, 0x91, 0xa3, 0x54, 0x4c, 0x99, 0x26, 0x0f, 0x50, 0x54, 0xbd,
68 0xee, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
69 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x66, 0x21, 0x50, 0xb0, 0x51, 0x00,
70 0x1b, 0x30, 0x40, 0x70, 0x36, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e,
71 0x01, 0x1d, 0x00, 0x72, 0x51, 0xd0, 0x1e, 0x20, 0x6e, 0x28, 0x55, 0x00,
72 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x18,
73 0x4b, 0x1a, 0x44, 0x17, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
74 0x00, 0x00, 0x00, 0xfc, 0x00, 0x53, 0x41, 0x4d, 0x53, 0x55, 0x4e, 0x47,
75 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0xbc, 0x02, 0x03, 0x1e, 0xf1,
76 0x46, 0x84, 0x05, 0x03, 0x10, 0x20, 0x22, 0x23, 0x09, 0x07, 0x07, 0x83,
77 0x01, 0x00, 0x00, 0xe2, 0x00, 0x0f, 0x67, 0x03, 0x0c, 0x00, 0x10, 0x00,
78 0xb8, 0x2d, 0x01, 0x1d, 0x80, 0x18, 0x71, 0x1c, 0x16, 0x20, 0x58, 0x2c,
79 0x25, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x9e, 0x8c, 0x0a, 0xd0, 0x8a,
80 0x20, 0xe0, 0x2d, 0x10, 0x10, 0x3e, 0x96, 0x00, 0xa0, 0x5a, 0x00, 0x00,
81 0x00, 0x18, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, 0x58, 0x2c,
82 0x45, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
86 0x00, 0x00, 0x00, 0x06
89 static bool vidi_display_is_connected(
struct device *
dev)
93 DRM_DEBUG_KMS(
"%s\n", __FILE__);
107 DRM_DEBUG_KMS(
"%s\n", __FILE__);
114 DRM_DEBUG_KMS(
"raw_edid is null.\n");
124 static void *vidi_get_panel(
struct device *dev)
126 DRM_DEBUG_KMS(
"%s\n", __FILE__);
133 static int vidi_check_timing(
struct device *dev,
void *
timing)
135 DRM_DEBUG_KMS(
"%s\n", __FILE__);
142 static int vidi_display_power_on(
struct device *dev,
int mode)
144 DRM_DEBUG_KMS(
"%s\n", __FILE__);
153 .is_connected = vidi_display_is_connected,
154 .get_edid = vidi_get_edid,
155 .get_panel = vidi_get_panel,
156 .check_timing = vidi_check_timing,
157 .power_on = vidi_display_power_on,
160 static void vidi_dpms(
struct device *subdrv_dev,
int mode)
164 DRM_DEBUG_KMS(
"%s, %d\n", __FILE__, mode);
178 DRM_DEBUG_KMS(
"unspecified mode %d\n", mode);
185 static void vidi_apply(
struct device *subdrv_dev)
194 DRM_DEBUG_KMS(
"%s\n", __FILE__);
199 ovl_ops->
commit(subdrv_dev, i);
202 if (mgr_ops && mgr_ops->
commit)
203 mgr_ops->
commit(subdrv_dev);
206 static void vidi_commit(
struct device *dev)
210 DRM_DEBUG_KMS(
"%s\n", __FILE__);
216 static int vidi_enable_vblank(
struct device *dev)
220 DRM_DEBUG_KMS(
"%s\n", __FILE__);
240 static void vidi_disable_vblank(
struct device *dev)
244 DRM_DEBUG_KMS(
"%s\n", __FILE__);
256 .commit = vidi_commit,
257 .enable_vblank = vidi_enable_vblank,
258 .disable_vblank = vidi_disable_vblank,
261 static void vidi_win_mode_set(
struct device *dev,
269 DRM_DEBUG_KMS(
"%s\n", __FILE__);
272 dev_err(dev,
"overlay is NULL\n");
280 if (win < 0 || win > WINDOWS_NR)
283 offset = overlay->
fb_x * (overlay->
bpp >> 3);
284 offset += overlay->
fb_y * overlay->
pitch;
286 DRM_DEBUG_KMS(
"offset = 0x%lx, pitch = %x\n", offset, overlay->
pitch);
298 win_data->
bpp = overlay->
bpp;
308 DRM_DEBUG_KMS(
"offset_x = %d, offset_y = %d\n",
310 DRM_DEBUG_KMS(
"ovl_width = %d, ovl_height = %d\n",
312 DRM_DEBUG_KMS(
"paddr = 0x%lx, vaddr = 0x%lx\n",
314 (
unsigned long)win_data->
vaddr);
315 DRM_DEBUG_KMS(
"fb_width = %d, crtc_width = %d\n",
319 static void vidi_win_commit(
struct device *dev,
int zpos)
325 DRM_DEBUG_KMS(
"%s\n", __FILE__);
333 if (win < 0 || win > WINDOWS_NR)
340 DRM_DEBUG_KMS(
"dma_addr = 0x%x\n", win_data->
dma_addr);
346 static void vidi_win_disable(
struct device *dev,
int zpos)
352 DRM_DEBUG_KMS(
"%s\n", __FILE__);
357 if (win < 0 || win > WINDOWS_NR)
367 .mode_set = vidi_win_mode_set,
368 .commit = vidi_win_commit,
369 .disable = vidi_win_disable,
374 .ops = &vidi_manager_ops,
375 .overlay_ops = &vidi_overlay_ops,
376 .display_ops = &vidi_display_ops,
379 static void vidi_finish_pageflip(
struct drm_device *drm_dev,
int crtc)
382 struct drm_pending_vblank_event *
e, *
t;
385 bool is_checked =
false;
398 e->event.sequence = 0;
399 e->event.tv_sec = now.tv_sec;
400 e->event.tv_usec = now.tv_usec;
402 list_move_tail(&e->base.link, &e->base.file_priv->event_list);
411 if (
atomic_read(&drm_dev->vblank_refcount[crtc]) > 0)
418 if (!drm_dev->vblank_disable_allowed)
422 spin_unlock_irqrestore(&drm_dev->event_lock, flags);
432 if (manager->
pipe < 0)
449 vidi_finish_pageflip(subdrv->
drm_dev, manager->
pipe);
452 static int vidi_subdrv_probe(
struct drm_device *drm_dev,
struct device *dev)
454 DRM_DEBUG_KMS(
"%s\n", __FILE__);
464 drm_dev->irq_enabled = 1;
471 drm_dev->vblank_disable_allowed = 1;
476 static void vidi_subdrv_remove(
struct drm_device *drm_dev,
struct device *dev)
478 DRM_DEBUG_KMS(
"%s\n", __FILE__);
488 DRM_DEBUG_KMS(
"%s\n", __FILE__);
490 if (enable !=
false && enable !=
true)
498 vidi_enable_vblank(dev);
508 static int vidi_show_connection(
struct device *dev,
523 static int vidi_store_connection(
struct device *dev,
525 const char *
buf,
size_t len)
530 DRM_DEBUG_KMS(
"%s\n", __FILE__);
541 ctx->
raw_edid = (
struct edid *)fake_edid_info;
544 if (ctx->
raw_edid != (
struct edid *)fake_edid_info) {
545 DRM_DEBUG_KMS(
"edid data is not fake data.\n");
549 DRM_DEBUG_KMS(
"requested connection.\n");
557 vidi_store_connection);
560 struct drm_file *file_priv)
567 struct edid *raw_edid;
570 DRM_DEBUG_KMS(
"%s\n", __FILE__);
573 DRM_DEBUG_KMS(
"user data for vidi is null.\n");
578 DRM_DEBUG_KMS(
"connection should be 0 or 1.\n");
594 DRM_DEBUG_KMS(
"not found virtual device type encoder.\n");
599 DRM_DEBUG_KMS(
"same connection request.\n");
605 DRM_DEBUG_KMS(
"edid data is null.\n");
612 DRM_DEBUG_KMS(
"failed to allocate raw_edid.\n");
622 (
struct edid *)fake_edid_info) {
641 DRM_DEBUG_KMS(
"%s\n", __FILE__);
653 subdrv->
manager = &vidi_manager;
654 subdrv->
probe = vidi_subdrv_probe;
655 subdrv->
remove = vidi_subdrv_remove;
659 platform_set_drvdata(pdev, ctx);
663 DRM_INFO(
"failed to create connection sysfs.\n");
674 DRM_DEBUG_KMS(
"%s\n", __FILE__);
678 if (ctx->
raw_edid != (
struct edid *)fake_edid_info) {
686 #ifdef CONFIG_PM_SLEEP
687 static int vidi_suspend(
struct device *dev)
691 return vidi_power_on(ctx,
false);
694 static int vidi_resume(
struct device *dev)
698 return vidi_power_on(ctx,
true);
702 static const struct dev_pm_ops vidi_pm_ops = {
710 .name =
"exynos-drm-vidi",