hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/gpu/drm/exynos/exynos_drm_vidi.c
....@@ -1,30 +1,25 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* exynos_drm_vidi.c
23 *
34 * Copyright (C) 2012 Samsung Electronics Co.Ltd
45 * Authors:
56 * Inki Dae <inki.dae@samsung.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
11
- *
127 */
13
-#include <drm/drmP.h>
148
9
+#include <linux/component.h>
1510 #include <linux/kernel.h>
1611 #include <linux/platform_device.h>
17
-#include <linux/component.h>
1812 #include <linux/timer.h>
1913
14
+#include <drm/drm_atomic_helper.h>
15
+#include <drm/drm_edid.h>
16
+#include <drm/drm_probe_helper.h>
17
+#include <drm/drm_simple_kms_helper.h>
18
+#include <drm/drm_vblank.h>
2019 #include <drm/exynos_drm.h>
2120
22
-#include <drm/drm_edid.h>
23
-#include <drm/drm_crtc_helper.h>
24
-#include <drm/drm_atomic_helper.h>
25
-
26
-#include "exynos_drm_drv.h"
2721 #include "exynos_drm_crtc.h"
22
+#include "exynos_drm_drv.h"
2823 #include "exynos_drm_fb.h"
2924 #include "exynos_drm_plane.h"
3025 #include "exynos_drm_vidi.h"
....@@ -40,8 +35,8 @@
4035
4136 struct vidi_context {
4237 struct drm_encoder encoder;
43
- struct platform_device *pdev;
4438 struct drm_device *drm_dev;
39
+ struct device *dev;
4540 struct exynos_drm_crtc *crtc;
4641 struct drm_connector connector;
4742 struct exynos_drm_plane planes[WINDOWS_NR];
....@@ -123,10 +118,10 @@
123118 return;
124119
125120 addr = exynos_drm_fb_dma_addr(state->fb, 0);
126
- DRM_DEBUG_KMS("dma_addr = %pad\n", &addr);
121
+ DRM_DEV_DEBUG_KMS(ctx->dev, "dma_addr = %pad\n", &addr);
127122 }
128123
129
-static void vidi_enable(struct exynos_drm_crtc *crtc)
124
+static void vidi_atomic_enable(struct exynos_drm_crtc *crtc)
130125 {
131126 struct vidi_context *ctx = crtc->ctx;
132127
....@@ -139,7 +134,7 @@
139134 drm_crtc_vblank_on(&crtc->base);
140135 }
141136
142
-static void vidi_disable(struct exynos_drm_crtc *crtc)
137
+static void vidi_atomic_disable(struct exynos_drm_crtc *crtc)
143138 {
144139 struct vidi_context *ctx = crtc->ctx;
145140
....@@ -153,8 +148,8 @@
153148 }
154149
155150 static const struct exynos_drm_crtc_ops vidi_crtc_ops = {
156
- .enable = vidi_enable,
157
- .disable = vidi_disable,
151
+ .atomic_enable = vidi_atomic_enable,
152
+ .atomic_disable = vidi_atomic_disable,
158153 .enable_vblank = vidi_enable_vblank,
159154 .disable_vblank = vidi_disable_vblank,
160155 .update_plane = vidi_update_plane,
....@@ -205,11 +200,11 @@
205200
206201 /* if raw_edid isn't same as fake data then it can't be tested. */
207202 if (ctx->raw_edid != (struct edid *)fake_edid_info) {
208
- DRM_DEBUG_KMS("edid data is not fake data.\n");
203
+ DRM_DEV_DEBUG_KMS(dev, "edid data is not fake data.\n");
209204 return -EINVAL;
210205 }
211206
212
- DRM_DEBUG_KMS("requested connection.\n");
207
+ DRM_DEV_DEBUG_KMS(dev, "requested connection.\n");
213208
214209 drm_helper_hpd_irq_event(ctx->drm_dev);
215210
....@@ -219,6 +214,12 @@
219214 static DEVICE_ATTR(connection, 0644, vidi_show_connection,
220215 vidi_store_connection);
221216
217
+static struct attribute *vidi_attrs[] = {
218
+ &dev_attr_connection.attr,
219
+ NULL,
220
+};
221
+ATTRIBUTE_GROUPS(vidi);
222
+
222223 int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
223224 struct drm_file *file_priv)
224225 {
....@@ -226,17 +227,20 @@
226227 struct drm_exynos_vidi_connection *vidi = data;
227228
228229 if (!vidi) {
229
- DRM_DEBUG_KMS("user data for vidi is null.\n");
230
+ DRM_DEV_DEBUG_KMS(ctx->dev,
231
+ "user data for vidi is null.\n");
230232 return -EINVAL;
231233 }
232234
233235 if (vidi->connection > 1) {
234
- DRM_DEBUG_KMS("connection should be 0 or 1.\n");
236
+ DRM_DEV_DEBUG_KMS(ctx->dev,
237
+ "connection should be 0 or 1.\n");
235238 return -EINVAL;
236239 }
237240
238241 if (ctx->connected == vidi->connection) {
239
- DRM_DEBUG_KMS("same connection request.\n");
242
+ DRM_DEV_DEBUG_KMS(ctx->dev,
243
+ "same connection request.\n");
240244 return -EINVAL;
241245 }
242246
....@@ -245,12 +249,14 @@
245249
246250 raw_edid = (struct edid *)(unsigned long)vidi->edid;
247251 if (!drm_edid_is_valid(raw_edid)) {
248
- DRM_DEBUG_KMS("edid data is invalid.\n");
252
+ DRM_DEV_DEBUG_KMS(ctx->dev,
253
+ "edid data is invalid.\n");
249254 return -EINVAL;
250255 }
251256 ctx->raw_edid = drm_edid_duplicate(raw_edid);
252257 if (!ctx->raw_edid) {
253
- DRM_DEBUG_KMS("failed to allocate raw_edid.\n");
258
+ DRM_DEV_DEBUG_KMS(ctx->dev,
259
+ "failed to allocate raw_edid.\n");
254260 return -ENOMEM;
255261 }
256262 } else {
....@@ -308,14 +314,14 @@
308314 * to ctx->raw_edid through specific ioctl.
309315 */
310316 if (!ctx->raw_edid) {
311
- DRM_DEBUG_KMS("raw_edid is null.\n");
317
+ DRM_DEV_DEBUG_KMS(ctx->dev, "raw_edid is null.\n");
312318 return -EFAULT;
313319 }
314320
315321 edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH;
316322 edid = kmemdup(ctx->raw_edid, edid_len, GFP_KERNEL);
317323 if (!edid) {
318
- DRM_DEBUG_KMS("failed to allocate edid\n");
324
+ DRM_DEV_DEBUG_KMS(ctx->dev, "failed to allocate edid\n");
319325 return -ENOMEM;
320326 }
321327
....@@ -339,7 +345,8 @@
339345 ret = drm_connector_init(ctx->drm_dev, connector,
340346 &vidi_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL);
341347 if (ret) {
342
- DRM_ERROR("Failed to initialize connector with drm\n");
348
+ DRM_DEV_ERROR(ctx->dev,
349
+ "Failed to initialize connector with drm\n");
343350 return ret;
344351 }
345352
....@@ -367,10 +374,6 @@
367374 .mode_set = exynos_vidi_mode_set,
368375 .enable = exynos_vidi_enable,
369376 .disable = exynos_vidi_disable,
370
-};
371
-
372
-static const struct drm_encoder_funcs exynos_vidi_encoder_funcs = {
373
- .destroy = drm_encoder_cleanup,
374377 };
375378
376379 static int vidi_bind(struct device *dev, struct device *master, void *data)
....@@ -402,12 +405,11 @@
402405 ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base,
403406 EXYNOS_DISPLAY_TYPE_VIDI, &vidi_crtc_ops, ctx);
404407 if (IS_ERR(ctx->crtc)) {
405
- DRM_ERROR("failed to create crtc.\n");
408
+ DRM_DEV_ERROR(dev, "failed to create crtc.\n");
406409 return PTR_ERR(ctx->crtc);
407410 }
408411
409
- drm_encoder_init(drm_dev, encoder, &exynos_vidi_encoder_funcs,
410
- DRM_MODE_ENCODER_TMDS, NULL);
412
+ drm_simple_encoder_init(drm_dev, encoder, DRM_MODE_ENCODER_TMDS);
411413
412414 drm_encoder_helper_add(encoder, &exynos_vidi_encoder_helper_funcs);
413415
....@@ -417,7 +419,8 @@
417419
418420 ret = vidi_create_connector(encoder);
419421 if (ret) {
420
- DRM_ERROR("failed to create connector ret = %d\n", ret);
422
+ DRM_DEV_ERROR(dev, "failed to create connector ret = %d\n",
423
+ ret);
421424 drm_encoder_cleanup(encoder);
422425 return ret;
423426 }
....@@ -441,13 +444,13 @@
441444 static int vidi_probe(struct platform_device *pdev)
442445 {
443446 struct vidi_context *ctx;
444
- int ret;
447
+ struct device *dev = &pdev->dev;
445448
446
- ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
449
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
447450 if (!ctx)
448451 return -ENOMEM;
449452
450
- ctx->pdev = pdev;
453
+ ctx->dev = dev;
451454
452455 timer_setup(&ctx->timer, vidi_fake_vblank_timer, 0);
453456
....@@ -455,22 +458,7 @@
455458
456459 platform_set_drvdata(pdev, ctx);
457460
458
- ret = device_create_file(&pdev->dev, &dev_attr_connection);
459
- if (ret < 0) {
460
- DRM_ERROR("failed to create connection sysfs.\n");
461
- return ret;
462
- }
463
-
464
- ret = component_add(&pdev->dev, &vidi_component_ops);
465
- if (ret)
466
- goto err_remove_file;
467
-
468
- return ret;
469
-
470
-err_remove_file:
471
- device_remove_file(&pdev->dev, &dev_attr_connection);
472
-
473
- return ret;
461
+ return component_add(dev, &vidi_component_ops);
474462 }
475463
476464 static int vidi_remove(struct platform_device *pdev)
....@@ -495,5 +483,6 @@
495483 .driver = {
496484 .name = "exynos-drm-vidi",
497485 .owner = THIS_MODULE,
486
+ .dev_groups = vidi_groups,
498487 },
499488 };