1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 #ifndef _EXYNOS_DRM_IPP_H_
7 #define _EXYNOS_DRM_IPP_H_
10 struct exynos_drm_ipp_task
;
13 * struct exynos_drm_ipp_funcs - exynos_drm_ipp control functions
15 struct exynos_drm_ipp_funcs
{
19 * This is the main entry point to start framebuffer processing
20 * in the hardware. The exynos_drm_ipp_task has been already validated.
21 * This function must not wait until the device finishes processing.
22 * When the driver finishes processing, it has to call
23 * exynos_exynos_drm_ipp_task_done() function.
27 * 0 on success or negative error codes in case of failure.
29 int (*commit
)(struct exynos_drm_ipp
*ipp
,
30 struct exynos_drm_ipp_task
*task
);
35 * Informs the driver that it has to abort the currently running
36 * task as soon as possible (i.e. as soon as it can stop the device
37 * safely), even if the task would not have been finished by then.
38 * After the driver performs the necessary steps, it has to call
39 * exynos_drm_ipp_task_done() (as if the task ended normally).
40 * This function does not have to (and will usually not) wait
41 * until the device enters a state when it can be stopped.
43 void (*abort
)(struct exynos_drm_ipp
*ipp
,
44 struct exynos_drm_ipp_task
*task
);
48 * struct exynos_drm_ipp - central picture processor module structure
50 struct exynos_drm_ipp
{
51 struct drm_device
*drm_dev
;
53 struct list_head head
;
57 const struct exynos_drm_ipp_funcs
*funcs
;
58 unsigned int capabilities
;
59 const struct exynos_drm_ipp_formats
*formats
;
60 unsigned int num_formats
;
64 struct exynos_drm_ipp_task
*task
;
65 struct list_head todo_list
;
66 wait_queue_head_t done_wq
;
69 struct exynos_drm_ipp_buffer
{
70 struct drm_exynos_ipp_task_buffer buf
;
71 struct drm_exynos_ipp_task_rect rect
;
73 struct exynos_drm_gem
*exynos_gem
[MAX_FB_BUFFER
];
74 const struct drm_format_info
*format
;
75 dma_addr_t dma_addr
[MAX_FB_BUFFER
];
79 * struct exynos_drm_ipp_task - a structure describing transformation that
80 * has to be performed by the picture processor hardware module
82 struct exynos_drm_ipp_task
{
84 struct exynos_drm_ipp
*ipp
;
85 struct list_head head
;
87 struct exynos_drm_ipp_buffer src
;
88 struct exynos_drm_ipp_buffer dst
;
90 struct drm_exynos_ipp_task_transform transform
;
91 struct drm_exynos_ipp_task_alpha alpha
;
93 struct work_struct cleanup_work
;
97 struct drm_pending_exynos_ipp_event
*event
;
100 #define DRM_EXYNOS_IPP_TASK_DONE (1 << 0)
101 #define DRM_EXYNOS_IPP_TASK_ASYNC (1 << 1)
103 struct exynos_drm_ipp_formats
{
107 const struct drm_exynos_ipp_limit
*limits
;
108 unsigned int num_limits
;
111 /* helper macros to set exynos_drm_ipp_formats structure and limits*/
112 #define IPP_SRCDST_MFORMAT(f, m, l) \
113 .fourcc = DRM_FORMAT_##f, .modifier = m, .limits = l, \
114 .num_limits = ARRAY_SIZE(l), \
115 .type = (DRM_EXYNOS_IPP_FORMAT_SOURCE | \
116 DRM_EXYNOS_IPP_FORMAT_DESTINATION)
118 #define IPP_SRCDST_FORMAT(f, l) IPP_SRCDST_MFORMAT(f, 0, l)
120 #define IPP_SIZE_LIMIT(l, val...) \
121 .type = (DRM_EXYNOS_IPP_LIMIT_TYPE_SIZE | \
122 DRM_EXYNOS_IPP_LIMIT_SIZE_##l), val
124 #define IPP_SCALE_LIMIT(val...) \
125 .type = (DRM_EXYNOS_IPP_LIMIT_TYPE_SCALE), val
127 int exynos_drm_ipp_register(struct device
*dev
, struct exynos_drm_ipp
*ipp
,
128 const struct exynos_drm_ipp_funcs
*funcs
, unsigned int caps
,
129 const struct exynos_drm_ipp_formats
*formats
,
130 unsigned int num_formats
, const char *name
);
131 void exynos_drm_ipp_unregister(struct device
*dev
,
132 struct exynos_drm_ipp
*ipp
);
134 void exynos_drm_ipp_task_done(struct exynos_drm_ipp_task
*task
, int ret
);
136 #ifdef CONFIG_DRM_EXYNOS_IPP
137 int exynos_drm_ipp_get_res_ioctl(struct drm_device
*dev
, void *data
,
138 struct drm_file
*file_priv
);
139 int exynos_drm_ipp_get_caps_ioctl(struct drm_device
*dev
, void *data
,
140 struct drm_file
*file_priv
);
141 int exynos_drm_ipp_get_limits_ioctl(struct drm_device
*dev
, void *data
,
142 struct drm_file
*file_priv
);
143 int exynos_drm_ipp_commit_ioctl(struct drm_device
*dev
,
144 void *data
, struct drm_file
*file_priv
);
146 static inline int exynos_drm_ipp_get_res_ioctl(struct drm_device
*dev
,
147 void *data
, struct drm_file
*file_priv
)
149 struct drm_exynos_ioctl_ipp_get_res
*resp
= data
;
151 resp
->count_ipps
= 0;
154 static inline int exynos_drm_ipp_get_caps_ioctl(struct drm_device
*dev
,
155 void *data
, struct drm_file
*file_priv
)
159 static inline int exynos_drm_ipp_get_limits_ioctl(struct drm_device
*dev
,
160 void *data
, struct drm_file
*file_priv
)
164 static inline int exynos_drm_ipp_commit_ioctl(struct drm_device
*dev
,
165 void *data
, struct drm_file
*file_priv
)