forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/exynos/exynos_drm_rotator.c
....@@ -1,30 +1,28 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2012 Samsung Electronics Co.Ltd
34 * Authors:
45 * YoungJun Cho <yj44.cho@samsung.com>
56 * Eunchul Kim <chulspro.kim@samsung.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundationr
107 */
118
12
-#include <linux/kernel.h>
9
+#include <linux/clk.h>
1310 #include <linux/component.h>
1411 #include <linux/err.h>
1512 #include <linux/interrupt.h>
1613 #include <linux/io.h>
17
-#include <linux/platform_device.h>
18
-#include <linux/clk.h>
14
+#include <linux/kernel.h>
1915 #include <linux/of_device.h>
16
+#include <linux/platform_device.h>
2017 #include <linux/pm_runtime.h>
18
+#include <linux/sizes.h>
2119
22
-#include <drm/drmP.h>
20
+#include <drm/drm_fourcc.h>
2321 #include <drm/exynos_drm.h>
24
-#include "regs-rotator.h"
22
+
2523 #include "exynos_drm_drv.h"
26
-#include "exynos_drm_iommu.h"
2724 #include "exynos_drm_ipp.h"
25
+#include "regs-rotator.h"
2826
2927 /*
3028 * Rotator supports image crop/rotator and input/output DMA operations.
....@@ -58,6 +56,7 @@
5856 struct rot_context {
5957 struct exynos_drm_ipp ipp;
6058 struct drm_device *drm_dev;
59
+ void *dma_priv;
6160 struct device *dev;
6261 void __iomem *regs;
6362 struct clk *clock;
....@@ -244,9 +243,10 @@
244243 struct exynos_drm_ipp *ipp = &rot->ipp;
245244
246245 rot->drm_dev = drm_dev;
247
- drm_iommu_attach_device(drm_dev, dev);
246
+ ipp->drm_dev = drm_dev;
247
+ exynos_drm_register_dma(drm_dev, dev, &rot->dma_priv);
248248
249
- exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs,
249
+ exynos_drm_ipp_register(dev, ipp, &ipp_funcs,
250250 DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE,
251251 rot->formats, rot->num_formats, "rotator");
252252
....@@ -259,11 +259,10 @@
259259 void *data)
260260 {
261261 struct rot_context *rot = dev_get_drvdata(dev);
262
- struct drm_device *drm_dev = data;
263262 struct exynos_drm_ipp *ipp = &rot->ipp;
264263
265
- exynos_drm_ipp_unregister(drm_dev, ipp);
266
- drm_iommu_detach_device(rot->drm_dev, rot->dev);
264
+ exynos_drm_ipp_unregister(dev, ipp);
265
+ exynos_drm_unregister_dma(rot->drm_dev, rot->dev, &rot->dma_priv);
267266 }
268267
269268 static const struct component_ops rotator_component_ops = {
....@@ -294,10 +293,8 @@
294293 return PTR_ERR(rot->regs);
295294
296295 irq = platform_get_irq(pdev, 0);
297
- if (irq < 0) {
298
- dev_err(dev, "failed to get irq\n");
296
+ if (irq < 0)
299297 return irq;
300
- }
301298
302299 ret = devm_request_irq(dev, irq, rotator_irq_handler, 0, dev_name(dev),
303300 rot);
....@@ -357,6 +354,11 @@
357354 }
358355 #endif
359356
357
+static const struct drm_exynos_ipp_limit rotator_s5pv210_rbg888_limits[] = {
358
+ { IPP_SIZE_LIMIT(BUFFER, .h = { 8, SZ_16K }, .v = { 8, SZ_16K }) },
359
+ { IPP_SIZE_LIMIT(AREA, .h.align = 2, .v.align = 2) },
360
+};
361
+
360362 static const struct drm_exynos_ipp_limit rotator_4210_rbg888_limits[] = {
361363 { IPP_SIZE_LIMIT(BUFFER, .h = { 8, SZ_16K }, .v = { 8, SZ_16K }) },
362364 { IPP_SIZE_LIMIT(AREA, .h.align = 4, .v.align = 4) },
....@@ -372,6 +374,11 @@
372374 { IPP_SIZE_LIMIT(AREA, .h.align = 2, .v.align = 2) },
373375 };
374376
377
+static const struct drm_exynos_ipp_limit rotator_s5pv210_yuv_limits[] = {
378
+ { IPP_SIZE_LIMIT(BUFFER, .h = { 32, SZ_64K }, .v = { 32, SZ_64K }) },
379
+ { IPP_SIZE_LIMIT(AREA, .h.align = 8, .v.align = 8) },
380
+};
381
+
375382 static const struct drm_exynos_ipp_limit rotator_4210_yuv_limits[] = {
376383 { IPP_SIZE_LIMIT(BUFFER, .h = { 32, SZ_64K }, .v = { 32, SZ_64K }) },
377384 { IPP_SIZE_LIMIT(AREA, .h.align = 8, .v.align = 8) },
....@@ -380,6 +387,11 @@
380387 static const struct drm_exynos_ipp_limit rotator_4412_yuv_limits[] = {
381388 { IPP_SIZE_LIMIT(BUFFER, .h = { 32, SZ_32K }, .v = { 32, SZ_32K }) },
382389 { IPP_SIZE_LIMIT(AREA, .h.align = 8, .v.align = 8) },
390
+};
391
+
392
+static const struct exynos_drm_ipp_formats rotator_s5pv210_formats[] = {
393
+ { IPP_SRCDST_FORMAT(XRGB8888, rotator_s5pv210_rbg888_limits) },
394
+ { IPP_SRCDST_FORMAT(NV12, rotator_s5pv210_yuv_limits) },
383395 };
384396
385397 static const struct exynos_drm_ipp_formats rotator_4210_formats[] = {
....@@ -395,6 +407,11 @@
395407 static const struct exynos_drm_ipp_formats rotator_5250_formats[] = {
396408 { IPP_SRCDST_FORMAT(XRGB8888, rotator_5250_rbg888_limits) },
397409 { IPP_SRCDST_FORMAT(NV12, rotator_4412_yuv_limits) },
410
+};
411
+
412
+static const struct rot_variant rotator_s5pv210_data = {
413
+ .formats = rotator_s5pv210_formats,
414
+ .num_formats = ARRAY_SIZE(rotator_s5pv210_formats),
398415 };
399416
400417 static const struct rot_variant rotator_4210_data = {
....@@ -414,6 +431,9 @@
414431
415432 static const struct of_device_id exynos_rotator_match[] = {
416433 {
434
+ .compatible = "samsung,s5pv210-rotator",
435
+ .data = &rotator_s5pv210_data,
436
+ }, {
417437 .compatible = "samsung,exynos4210-rotator",
418438 .data = &rotator_4210_data,
419439 }, {