Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9913f74f authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Inki Dae
Browse files

drm/exynos: ipp: Add IPP v2 framework



This patch adds Exynos IPP v2 subsystem and userspace API.

New userspace API is focused ONLY on memory-to-memory image processing.
The two remainging operation modes of obsolete IPP v1 API (framebuffer
writeback and local-path output with image processing) can be implemented
using standard DRM features: writeback connectors and additional DRM planes
with scaling features.

V2 IPP userspace API is based on stateless approach, which much better fits
to memory-to-memory image processing model. It also provides support for
all image formats, which are both already defined in DRM API and supported
by the existing IPP hardware modules.

The API consists of the following ioctls:
- DRM_IOCTL_EXYNOS_IPP_GET_RESOURCES: to enumerate all available image
  processing modules,
- DRM_IOCTL_EXYNOS_IPP_GET_CAPS: to query capabilities and supported image
  formats of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_GET_LIMITS: to query hardware limitiations for
  selected image format of given IPP module,
- DRM_IOCTL_EXYNOS_IPP_COMMIT: to perform operation described by the
  provided structures (source and destination buffers, operation rectangle,
  transformation, etc).

The proposed userspace API is extensible. In the future more advanced image
processing operations can be defined to support for example blending.

Userspace API is fully functional also on DRM render nodes, so it is not
limited to the root/privileged client.

Internal driver API also has been completely rewritten. New IPP core
performs all possible input validation, checks and object life-time
control. The drivers can focus only on writing configuration to hardware
registers. Stateless nature of DRM_IOCTL_EXYNOS_IPP_COMMIT ioctl simplifies
the driver API. Minimal driver needs to provide a single callback for
starting processing and an array with supported image formats.

Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Tested-by: default avatarHoegeun Kwon <hoegeun.kwon@samsung.com>
Merge conflict so merged manually.
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent 5fae288d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -95,6 +95,9 @@ config DRM_EXYNOS_G2D
	help
	  Choose this option if you want to use Exynos G2D for DRM.

config DRM_EXYNOS_IPP
	bool

config DRM_EXYNOS_FIMC
	bool "FIMC"
	depends on BROKEN && MFD_SYSCON
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_MIXER) += exynos_mixer.o
exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI)	+= exynos_hdmi.o
exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+= exynos_drm_vidi.o
exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
exynosdrm-$(CONFIG_DRM_EXYNOS_GSC)	+= exynos_drm_gsc.o
+20 −2
Original line number Diff line number Diff line
@@ -27,15 +27,23 @@
#include "exynos_drm_fb.h"
#include "exynos_drm_gem.h"
#include "exynos_drm_plane.h"
#include "exynos_drm_ipp.h"
#include "exynos_drm_vidi.h"
#include "exynos_drm_g2d.h"
#include "exynos_drm_iommu.h"

#define DRIVER_NAME	"exynos"
#define DRIVER_DESC	"Samsung SoC DRM"
#define DRIVER_DATE	"20110530"
#define DRIVER_DATE	"20180330"

/*
 * Interface history:
 *
 * 1.0 - Original version
 * 1.1 - Upgrade IPP driver to version 2.0
 */
#define DRIVER_MAJOR	1
#define DRIVER_MINOR	0
#define DRIVER_MINOR	1

int exynos_atomic_check(struct drm_device *dev,
			struct drm_atomic_state *state)
@@ -108,6 +116,16 @@ static const struct drm_ioctl_desc exynos_ioctls[] = {
			DRM_AUTH | DRM_RENDER_ALLOW),
	DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC, exynos_g2d_exec_ioctl,
			DRM_AUTH | DRM_RENDER_ALLOW),
	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_RESOURCES,
			exynos_drm_ipp_get_res_ioctl,
			DRM_AUTH | DRM_RENDER_ALLOW),
	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_CAPS, exynos_drm_ipp_get_caps_ioctl,
			DRM_AUTH | DRM_RENDER_ALLOW),
	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_LIMITS,
			exynos_drm_ipp_get_limits_ioctl,
			DRM_AUTH | DRM_RENDER_ALLOW),
	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_COMMIT, exynos_drm_ipp_commit_ioctl,
			DRM_AUTH | DRM_RENDER_ALLOW),
};

static const struct file_operations exynos_drm_driver_fops = {
+916 −0

File added.

Preview size limit exceeded, changes collapsed.

+175 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
 *
 * 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.
 */

#ifndef _EXYNOS_DRM_IPP_H_
#define _EXYNOS_DRM_IPP_H_

#include <drm/drmP.h>

struct exynos_drm_ipp;
struct exynos_drm_ipp_task;

/**
 * struct exynos_drm_ipp_funcs - exynos_drm_ipp control functions
 */
struct exynos_drm_ipp_funcs {
	/**
	 * @commit:
	 *
	 * This is the main entry point to start framebuffer processing
	 * in the hardware. The exynos_drm_ipp_task has been already validated.
	 * This function must not wait until the device finishes processing.
	 * When the driver finishes processing, it has to call
	 * exynos_exynos_drm_ipp_task_done() function.
	 *
	 * RETURNS:
	 *
	 * 0 on success or negative error codes in case of failure.
	 */
	int (*commit)(struct exynos_drm_ipp *ipp,
		      struct exynos_drm_ipp_task *task);

	/**
	 * @abort:
	 *
	 * Informs the driver that it has to abort the currently running
	 * task as soon as possible (i.e. as soon as it can stop the device
	 * safely), even if the task would not have been finished by then.
	 * After the driver performs the necessary steps, it has to call
	 * exynos_drm_ipp_task_done() (as if the task ended normally).
	 * This function does not have to (and will usually not) wait
	 * until the device enters a state when it can be stopped.
	 */
	void (*abort)(struct exynos_drm_ipp *ipp,
		      struct exynos_drm_ipp_task *task);
};

/**
 * struct exynos_drm_ipp - central picture processor module structure
 */
struct exynos_drm_ipp {
	struct drm_device *dev;
	struct list_head head;
	unsigned int id;

	const char *name;
	const struct exynos_drm_ipp_funcs *funcs;
	unsigned int capabilities;
	const struct exynos_drm_ipp_formats *formats;
	unsigned int num_formats;
	atomic_t sequence;

	spinlock_t lock;
	struct exynos_drm_ipp_task *task;
	struct list_head todo_list;
	wait_queue_head_t done_wq;
};

struct exynos_drm_ipp_buffer {
	struct drm_exynos_ipp_task_buffer buf;
	struct drm_exynos_ipp_task_rect rect;

	struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
	const struct drm_format_info *format;
	dma_addr_t dma_addr[MAX_FB_BUFFER];
};

/**
 * struct exynos_drm_ipp_task - a structure describing transformation that
 * has to be performed by the picture processor hardware module
 */
struct exynos_drm_ipp_task {
	struct drm_device *dev;
	struct exynos_drm_ipp *ipp;
	struct list_head head;

	struct exynos_drm_ipp_buffer src;
	struct exynos_drm_ipp_buffer dst;

	struct drm_exynos_ipp_task_transform transform;
	struct drm_exynos_ipp_task_alpha alpha;

	struct work_struct cleanup_work;
	unsigned int flags;
	int ret;

	struct drm_pending_exynos_ipp_event *event;
};

#define DRM_EXYNOS_IPP_TASK_DONE	(1 << 0)
#define DRM_EXYNOS_IPP_TASK_ASYNC	(1 << 1)

struct exynos_drm_ipp_formats {
	uint32_t fourcc;
	uint32_t type;
	uint64_t modifier;
	const struct drm_exynos_ipp_limit *limits;
	unsigned int num_limits;
};

/* helper macros to set exynos_drm_ipp_formats structure and limits*/
#define IPP_SRCDST_MFORMAT(f, m, l) \
	.fourcc = DRM_FORMAT_##f, .modifier = m, .limits = l, \
	.num_limits = ARRAY_SIZE(l), \
	.type = (DRM_EXYNOS_IPP_FORMAT_SOURCE | \
		 DRM_EXYNOS_IPP_FORMAT_DESTINATION)

#define IPP_SRCDST_FORMAT(f, l) IPP_SRCDST_MFORMAT(f, 0, l)

#define IPP_SIZE_LIMIT(l, val...)	\
	.type = (DRM_EXYNOS_IPP_LIMIT_TYPE_SIZE | \
		 DRM_EXYNOS_IPP_LIMIT_SIZE_##l), val

#define IPP_SCALE_LIMIT(val...)		\
	.type = (DRM_EXYNOS_IPP_LIMIT_TYPE_SCALE), val

int exynos_drm_ipp_register(struct drm_device *dev, struct exynos_drm_ipp *ipp,
		const struct exynos_drm_ipp_funcs *funcs, unsigned int caps,
		const struct exynos_drm_ipp_formats *formats,
		unsigned int num_formats, const char *name);
void exynos_drm_ipp_unregister(struct drm_device *dev,
			       struct exynos_drm_ipp *ipp);

void exynos_drm_ipp_task_done(struct exynos_drm_ipp_task *task, int ret);

#ifdef CONFIG_DRM_EXYNOS_IPP
int exynos_drm_ipp_get_res_ioctl(struct drm_device *dev, void *data,
				 struct drm_file *file_priv);
int exynos_drm_ipp_get_caps_ioctl(struct drm_device *dev, void *data,
				  struct drm_file *file_priv);
int exynos_drm_ipp_get_limits_ioctl(struct drm_device *dev, void *data,
				    struct drm_file *file_priv);
int exynos_drm_ipp_commit_ioctl(struct drm_device *dev,
				void *data, struct drm_file *file_priv);
#else
static inline int exynos_drm_ipp_get_res_ioctl(struct drm_device *dev,
	 void *data, struct drm_file *file_priv)
{
	struct drm_exynos_ioctl_ipp_get_res *resp = data;

	resp->count_ipps = 0;
	return 0;
}
static inline int exynos_drm_ipp_get_caps_ioctl(struct drm_device *dev,
	 void *data, struct drm_file *file_priv)
{
	return -ENODEV;
}
static inline int exynos_drm_ipp_get_limits_ioctl(struct drm_device *dev,
	 void *data, struct drm_file *file_priv)
{
	return -ENODEV;
}
static inline int exynos_drm_ipp_commit_ioctl(struct drm_device *dev,
	 void *data, struct drm_file *file_priv)
{
	return -ENODEV;
}
#endif
#endif
Loading