Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | /* exynos_drm_core.c * * Copyright (c) 2011 Samsung Electronics Co., Ltd. * Author: * Inki Dae <inki.dae@samsung.com> * Joonyoung Shim <jy0922.shim@samsung.com> * Seung-Woo Kim <sw0312.kim@samsung.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ #include <drm/drmP.h> #include "exynos_drm_drv.h" #include "exynos_drm_crtc.h" #include "exynos_drm_encoder.h" #include "exynos_drm_fbdev.h" static LIST_HEAD(exynos_drm_subdrv_list); int exynos_drm_create_enc_conn(struct drm_device *dev, struct exynos_drm_display *display) { struct drm_encoder *encoder; int ret; unsigned long possible_crtcs = 0; ret = exynos_drm_crtc_get_pipe_from_type(dev, display->type); if (ret < 0) return ret; possible_crtcs |= 1 << ret; /* create and initialize a encoder for this sub driver. */ encoder = exynos_drm_encoder_create(dev, display, possible_crtcs); if (!encoder) { DRM_ERROR("failed to create encoder\n"); return -EFAULT; } display->encoder = encoder; ret = display->ops->create_connector(display, encoder); if (ret) { DRM_ERROR("failed to create connector ret = %d\n", ret); goto err_destroy_encoder; } return 0; err_destroy_encoder: encoder->funcs->destroy(encoder); return ret; } int exynos_drm_subdrv_register(struct exynos_drm_subdrv *subdrv) { if (!subdrv) return -EINVAL; list_add_tail(&subdrv->list, &exynos_drm_subdrv_list); return 0; } EXPORT_SYMBOL_GPL(exynos_drm_subdrv_register); int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv *subdrv) { if (!subdrv) return -EINVAL; list_del(&subdrv->list); return 0; } EXPORT_SYMBOL_GPL(exynos_drm_subdrv_unregister); int exynos_drm_device_subdrv_probe(struct drm_device *dev) { struct exynos_drm_subdrv *subdrv, *n; int err; if (!dev) return -EINVAL; list_for_each_entry_safe(subdrv, n, &exynos_drm_subdrv_list, list) { if (subdrv->probe) { subdrv->drm_dev = dev; /* * this probe callback would be called by sub driver * after setting of all resources to this sub driver, * such as clock, irq and register map are done. */ err = subdrv->probe(dev, subdrv->dev); if (err) { DRM_DEBUG("exynos drm subdrv probe failed.\n"); list_del(&subdrv->list); continue; } } } return 0; } EXPORT_SYMBOL_GPL(exynos_drm_device_subdrv_probe); int exynos_drm_device_subdrv_remove(struct drm_device *dev) { struct exynos_drm_subdrv *subdrv; if (!dev) { WARN(1, "Unexpected drm device unregister!\n"); return -EINVAL; } list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) { if (subdrv->remove) subdrv->remove(dev, subdrv->dev); } return 0; } EXPORT_SYMBOL_GPL(exynos_drm_device_subdrv_remove); int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file) { struct exynos_drm_subdrv *subdrv; int ret; list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) { if (subdrv->open) { ret = subdrv->open(dev, subdrv->dev, file); if (ret) goto err; } } return 0; err: list_for_each_entry_continue_reverse(subdrv, &exynos_drm_subdrv_list, list) { if (subdrv->close) subdrv->close(dev, subdrv->dev, file); } return ret; } EXPORT_SYMBOL_GPL(exynos_drm_subdrv_open); void exynos_drm_subdrv_close(struct drm_device *dev, struct drm_file *file) { struct exynos_drm_subdrv *subdrv; list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) { if (subdrv->close) subdrv->close(dev, subdrv->dev, file); } } EXPORT_SYMBOL_GPL(exynos_drm_subdrv_close); |