Skip to content

Commit dd0421f

Browse files
committed
drm/sun4i: Add a driver for the display frontend
The display frontend is an hardware block that can be used to implement some more advanced features like hardware scaling or colorspace conversions. It can also be used to implement the output format of the VPU. Let's create a minimal driver for it that will only enable the hardware scaling features. Reviewed-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/029cdc3478bf89d422f5e8d9e600baf5e48ce4db.1516613040.git-series.maxime.ripard@free-electrons.com
1 parent 6b8562c commit dd0421f

File tree

5 files changed

+514
-5
lines changed

5 files changed

+514
-5
lines changed

drivers/gpu/drm/sun4i/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22
sun4i-backend-y += sun4i_backend.o sun4i_layer.o
3+
sun4i-frontend-y += sun4i_frontend.o
34

45
sun4i-drm-y += sun4i_drv.o
56
sun4i-drm-y += sun4i_framebuffer.o
@@ -24,6 +25,6 @@ obj-$(CONFIG_DRM_SUN4I) += sun4i-tcon.o
2425
obj-$(CONFIG_DRM_SUN4I) += sun4i_tv.o
2526
obj-$(CONFIG_DRM_SUN4I) += sun6i_drc.o
2627

27-
obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o
28+
obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o sun4i-frontend.o
2829
obj-$(CONFIG_DRM_SUN4I_HDMI) += sun4i-drm-hdmi.o
2930
obj-$(CONFIG_DRM_SUN8I_MIXER) += sun8i-mixer.o

drivers/gpu/drm/sun4i/sun4i_drv.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <drm/drm_of.h>
2424

2525
#include "sun4i_drv.h"
26+
#include "sun4i_frontend.h"
2627
#include "sun4i_framebuffer.h"
2728
#include "sun4i_tcon.h"
2829

@@ -91,6 +92,7 @@ static int sun4i_drv_bind(struct device *dev)
9192
goto free_drm;
9293
}
9394
drm->dev_private = drv;
95+
INIT_LIST_HEAD(&drv->frontend_list);
9496
INIT_LIST_HEAD(&drv->engine_list);
9597
INIT_LIST_HEAD(&drv->tcon_list);
9698

@@ -177,6 +179,14 @@ static bool sun4i_drv_node_is_frontend(struct device_node *node)
177179
of_device_is_compatible(node, "allwinner,sun8i-a33-display-frontend");
178180
}
179181

182+
static bool sun4i_drv_node_is_supported_frontend(struct device_node *node)
183+
{
184+
if (IS_ENABLED(CONFIG_DRM_SUN4I_BACKEND))
185+
return !!of_match_node(sun4i_frontend_of_table, node);
186+
187+
return false;
188+
}
189+
180190
static bool sun4i_drv_node_is_tcon(struct device_node *node)
181191
{
182192
return !!of_match_node(sun4i_tcon_of_table, node);
@@ -225,9 +235,11 @@ static int sun4i_drv_add_endpoints(struct device *dev,
225235
int count = 0;
226236

227237
/*
228-
* We don't support the frontend for now, so we will never
229-
* have a device bound. Just skip over it, but we still want
230-
* the rest our pipeline to be added.
238+
* The frontend has been disabled in some of our old device
239+
* trees. If we find a node that is the frontend and is
240+
* disabled, we should just follow through and parse its
241+
* child, but without adding it to the component list.
242+
* Otherwise, we obviously want to add it to the list.
231243
*/
232244
if (!sun4i_drv_node_is_frontend(node) &&
233245
!of_device_is_available(node))
@@ -240,7 +252,14 @@ static int sun4i_drv_add_endpoints(struct device *dev,
240252
if (sun4i_drv_node_is_connector(node))
241253
return 0;
242254

243-
if (!sun4i_drv_node_is_frontend(node)) {
255+
/*
256+
* If the device is either just a regular device, or an
257+
* enabled frontend supported by the driver, we add it to our
258+
* component list.
259+
*/
260+
if (!sun4i_drv_node_is_frontend(node) ||
261+
(sun4i_drv_node_is_supported_frontend(node) &&
262+
of_device_is_available(node))) {
244263
/* Add current component */
245264
DRM_DEBUG_DRIVER("Adding component %pOF\n", node);
246265
drm_of_component_match_add(dev, match, compare_of, node);

drivers/gpu/drm/sun4i/sun4i_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
struct sun4i_drv {
2121
struct list_head engine_list;
22+
struct list_head frontend_list;
2223
struct list_head tcon_list;
2324
};
2425

0 commit comments

Comments
 (0)