Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1566973 > unrolled thread
| Started by | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| First post | 2017-01-25 22:40 +0100 |
| Last post | 2017-01-25 22:40 +0100 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v3 0/3] Enable R8A7790/1 DU VSPD compositor Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2017-01-25 22:40 +0100
[PATCH v3 2/3] drm: Connect live source to framebuffers Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2017-01-25 22:40 +0100
[PATCH v3 3/3] drm: rcar-du: Add VSP1 live source support Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2017-01-25 22:40 +0100
[PATCH v3 1/3] drm: Add live source object Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2017-01-25 22:40 +0100
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2017-01-25 22:40 +0100 |
| Subject | [PATCH v3 0/3] Enable R8A7790/1 DU VSPD compositor |
| Message-ID | <t3Dsm-79W-7@gated-at.bofh.it> |
Hello. Here's the set of 3 patches against the 'drm-next' branch of David Airlie's 'linux.git' repo. This is a port of Laurent's DRM/DU live source patches to the recent kernel, see [1] for the version 2 of the patchset (including a Laurent's big blurb :-)). For the patch #3 to work one absolutely needs the VSP1 patch [2] to be applied, else the kernel will just hang... [1] https://lists.freedesktop.org/archives/dri-devel/2015-March/079319.html. [2] https://patchwork.kernel.org/patch/9473265/ [1/3] drm: Add live source object [2/3] drm: Connect live source to framebuffers [3/3] drm: rcar-du: Add VSP1 live source support MBR, Sergei
[toc] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2017-01-25 22:40 +0100 |
| Subject | [PATCH v3 2/3] drm: Connect live source to framebuffers |
| Message-ID | <t3Dsm-79W-15@gated-at.bofh.it> |
| In reply to | #1566973 |
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Introduce a new live source flag for framebuffers. When a framebuffer is
created with that flag set, a live source is associated with the
framebuffer instead of buffer objects. The framebuffer can then be used
with a plane to connect it with the live source.
[Sergei: ported to the modern kernel.]
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 3:
- ported the patch to the modern kernel;
- added my signoff.
drivers/gpu/drm/drm_framebuffer.c | 134 ++++++++++++++++++++++++++++++--------
include/uapi/drm/drm_mode.h | 7 +
2 files changed, 113 insertions(+), 28 deletions(-)
Index: linux/drivers/gpu/drm/drm_framebuffer.c
===================================================================
--- linux.orig/drivers/gpu/drm/drm_framebuffer.c
+++ linux/drivers/gpu/drm/drm_framebuffer.c
@@ -126,34 +126,18 @@ int drm_mode_addfb(struct drm_device *de
return 0;
}
-static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
+static int framebuffer_check_buffers(const struct drm_mode_fb_cmd2 *r,
+ int hsub, int vsub)
{
- const struct drm_format_info *info;
- int i;
+ int num_planes, i;
+ unsigned int cpp;
- info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
- if (!info) {
- struct drm_format_name_buf format_name;
- DRM_DEBUG_KMS("bad framebuffer format %s\n",
- drm_get_format_name(r->pixel_format,
- &format_name));
- return -EINVAL;
- }
-
- if (r->width == 0 || r->width % info->hsub) {
- DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
- return -EINVAL;
- }
-
- if (r->height == 0 || r->height % info->vsub) {
- DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height);
- return -EINVAL;
- }
+ num_planes = drm_format_num_planes(r->pixel_format);
+ cpp = drm_format_plane_cpp(r->pixel_format, 0);
- for (i = 0; i < info->num_planes; i++) {
- unsigned int width = r->width / (i != 0 ? info->hsub : 1);
- unsigned int height = r->height / (i != 0 ? info->vsub : 1);
- unsigned int cpp = info->cpp[i];
+ for (i = 0; i < num_planes; i++) {
+ unsigned int width = r->width / (i != 0 ? hsub : 1);
+ unsigned int height = r->height / (i != 0 ? vsub : 1);
if (!r->handles[i]) {
DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i);
@@ -203,7 +187,7 @@ static int framebuffer_check(const struc
}
}
- for (i = info->num_planes; i < 4; i++) {
+ for (i = num_planes; i < 4; i++) {
if (r->modifier[i]) {
DRM_DEBUG_KMS("non-zero modifier for unused plane %d\n", i);
return -EINVAL;
@@ -232,6 +216,99 @@ static int framebuffer_check(const struc
return 0;
}
+static int framebuffer_check_sources(struct drm_device *dev,
+ const struct drm_mode_fb_cmd2 *r)
+{
+ struct drm_mode_object *obj;
+ struct drm_live_source *src;
+ unsigned int cpp;
+ unsigned int i;
+
+ /*
+ * Ensure that userspace has zeroed unused handles, pitches, offsets and
+ * modifiers to allow future API extensions.
+ */
+ if (r->offsets[0] || r->modifier[0])
+ return -EINVAL;
+
+ for (i = 1; i < ARRAY_SIZE(r->handles); ++i) {
+ if (r->handles[i] || r->pitches[i] ||
+ r->offsets[i] || r->modifier[i])
+ return -EINVAL;
+ }
+
+ /* Validate width, height and pitch. */
+ cpp = drm_format_plane_cpp(r->pixel_format, 0);
+
+ if ((uint64_t) r->width * cpp > UINT_MAX)
+ return -ERANGE;
+
+ if ((uint64_t) r->height * r->pitches[0] > UINT_MAX)
+ return -ERANGE;
+
+ if (r->pitches[0] != r->width * cpp) {
+ DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[0], i);
+ return -EINVAL;
+ }
+
+ /*
+ * Find the live source and check whether it supports the requested
+ * pixel format.
+ */
+
+ obj = drm_mode_object_find(dev, r->handles[0],
+ DRM_MODE_OBJECT_LIVE_SOURCE);
+ if (!obj) {
+ DRM_DEBUG_KMS("bad framebuffer source ID %u\n", r->handles[0]);
+ return -EINVAL;
+ }
+
+ src = obj_to_live_source(obj);
+
+ for (i = 0; i < src->format_count; i++) {
+ if (r->pixel_format == src->format_types[i])
+ break;
+ }
+
+ if (i == src->format_count) {
+ DRM_DEBUG_KMS("bad framebuffer pixel format 0x%08x for source %u\n",
+ r->pixel_format, r->handles[0]);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int framebuffer_check(struct drm_device *dev,
+ const struct drm_mode_fb_cmd2 *r)
+{
+ const struct drm_format_info *info;
+
+ info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
+ if (!info) {
+ struct drm_format_name_buf format_name;
+ DRM_DEBUG_KMS("bad framebuffer format %s\n",
+ drm_get_format_name(r->pixel_format,
+ &format_name));
+ return -EINVAL;
+ }
+
+ if (r->width == 0 || r->width % info->hsub) {
+ DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
+ return -EINVAL;
+ }
+
+ if (r->height == 0 || r->height % info->vsub) {
+ DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height);
+ return -EINVAL;
+ }
+
+ if (r->flags & DRM_MODE_FB_LIVE_SOURCE)
+ return framebuffer_check_sources(dev, r);
+ else
+ return framebuffer_check_buffers(r, info->hsub, info->vsub);
+}
+
struct drm_framebuffer *
drm_internal_framebuffer_create(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *r,
@@ -241,7 +318,8 @@ drm_internal_framebuffer_create(struct d
struct drm_framebuffer *fb;
int ret;
- if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) {
+ if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS |
+ DRM_MODE_FB_LIVE_SOURCE)) {
DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags);
return ERR_PTR(-EINVAL);
}
@@ -263,7 +341,7 @@ drm_internal_framebuffer_create(struct d
return ERR_PTR(-EINVAL);
}
- ret = framebuffer_check(r);
+ ret = framebuffer_check(dev, r);
if (ret)
return ERR_PTR(ret);
Index: linux/include/uapi/drm/drm_mode.h
===================================================================
--- linux.orig/include/uapi/drm/drm_mode.h
+++ linux/include/uapi/drm/drm_mode.h
@@ -405,6 +405,7 @@ struct drm_mode_fb_cmd {
#define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */
#define DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[] */
+#define DRM_MODE_FB_LIVE_SOURCE (1<<2) /* connected to a live source */
struct drm_mode_fb_cmd2 {
__u32 fb_id;
@@ -436,6 +437,12 @@ struct drm_mode_fb_cmd2 {
* Thus all combinations of different data layouts for
* multi plane formats must be enumerated as separate
* modifiers.
+ *
+ * If the DRM_MODE_FB_LIVE_SOURCE flag is set the frame buffer input
+ * comes from a live source instead of from memory. The handles[0]
+ * field contains the ID of the connected live source object. All other
+ * handles and all pitches, offsets and modifiers are then ignored by
+ * the kernel and must be set to zero by applications.
*/
__u32 handles[4];
__u32 pitches[4]; /* pitch for each plane */
[toc] | [prev] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2017-01-25 22:40 +0100 |
| Subject | [PATCH v3 3/3] drm: rcar-du: Add VSP1 live source support |
| Message-ID | <t3Dsm-79W-23@gated-at.bofh.it> |
| In reply to | #1566973 |
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Register live sources for VSPD0 and VSPD1 and configure the plane source
at plane setup time to source frames from memory or from the VSP1.
[Sergei: ported to the modern kernel.]
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 3:
- ported the patch to the modern kernel;
- reformatted rcar_du_live_fb_create_handle()/rcar_du_live_fb_create()'s
parameter lists;
- added my signoff.
drivers/gpu/drm/rcar-du/rcar_du_drv.c | 6 +-
drivers/gpu/drm/rcar-du/rcar_du_kms.c | 77 +++++++++++++++++++++++++++++++
drivers/gpu/drm/rcar-du/rcar_du_kms.h | 3 +
drivers/gpu/drm/rcar-du/rcar_du_plane.c | 79 +++++++++++++++++++++++++++++++-
drivers/gpu/drm/rcar-du/rcar_du_plane.h | 3 +
5 files changed, 164 insertions(+), 4 deletions(-)
Index: linux/drivers/gpu/drm/rcar-du/rcar_du_drv.c
===================================================================
--- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ linux/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -60,7 +60,8 @@ static const struct rcar_du_device_info
static const struct rcar_du_device_info rcar_du_r8a7790_info = {
.gen = 2,
.features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
- | RCAR_DU_FEATURE_EXT_CTRL_REGS,
+ | RCAR_DU_FEATURE_EXT_CTRL_REGS
+ | RCAR_DU_FEATURE_VSP1_SOURCE,
.quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES,
.num_crtcs = 3,
.routes = {
@@ -90,7 +91,8 @@ static const struct rcar_du_device_info
static const struct rcar_du_device_info rcar_du_r8a7791_info = {
.gen = 2,
.features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
- | RCAR_DU_FEATURE_EXT_CTRL_REGS,
+ | RCAR_DU_FEATURE_EXT_CTRL_REGS
+ | RCAR_DU_FEATURE_VSP1_SOURCE,
.num_crtcs = 2,
.routes = {
/* R8A779[13] has one RGB output, one LVDS output and one
Index: linux/drivers/gpu/drm/rcar-du/rcar_du_kms.c
===================================================================
--- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ linux/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -166,6 +166,74 @@ int rcar_du_dumb_create(struct drm_file
return drm_gem_cma_dumb_create_internal(file, dev, args);
}
+struct rcar_du_live_framebuffer {
+ struct drm_framebuffer fb;
+ struct drm_live_source *src;
+};
+
+#define to_live_fb(fb) container_of(fb, struct rcar_du_live_framebuffer, fb)
+
+struct drm_live_source *rcar_du_live_fb_source(struct drm_framebuffer *fb)
+{
+ return fb->flags & DRM_MODE_FB_LIVE_SOURCE ? to_live_fb(fb)->src : NULL;
+}
+
+static void rcar_du_live_fb_destroy(struct drm_framebuffer *fb)
+{
+ struct rcar_du_live_framebuffer *live_fb = to_live_fb(fb);
+
+ drm_framebuffer_cleanup(fb);
+ kfree(live_fb);
+}
+
+static int rcar_du_live_fb_create_handle(struct drm_framebuffer *fb,
+ struct drm_file *file_priv,
+ unsigned int *handle)
+{
+ *handle = 0;
+ return 0;
+}
+
+static struct drm_framebuffer_funcs rcar_du_live_fb_funcs = {
+ .destroy = rcar_du_live_fb_destroy,
+ .create_handle = rcar_du_live_fb_create_handle,
+};
+
+static struct drm_framebuffer *
+rcar_du_live_fb_create(struct drm_device *dev, struct drm_file *file_priv,
+ const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+ struct rcar_du_live_framebuffer *fb;
+ struct drm_mode_object *obj;
+ struct drm_live_source *src;
+ int ret;
+
+ obj = drm_mode_object_find(dev, mode_cmd->handles[0],
+ DRM_MODE_OBJECT_LIVE_SOURCE);
+ if (!obj)
+ return ERR_PTR(-EINVAL);
+
+ src = obj_to_live_source(obj);
+
+ fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+ if (!fb)
+ return ERR_PTR(-ENOMEM);
+
+ drm_helper_mode_fill_fb_struct(dev, &fb->fb, mode_cmd);
+
+ fb->src = src;
+
+ ret = drm_framebuffer_init(dev, &fb->fb, &rcar_du_live_fb_funcs);
+ if (ret) {
+ dev_err(dev->dev, "Failed to initialize framebuffer: %d\n",
+ ret);
+ kfree(fb);
+ return ERR_PTR(ret);
+ }
+
+ return &fb->fb;
+}
+
static struct drm_framebuffer *
rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -177,6 +245,9 @@ rcar_du_fb_create(struct drm_device *dev
unsigned int bpp;
unsigned int i;
+ if (mode_cmd->flags & DRM_MODE_FB_LIVE_SOURCE)
+ return rcar_du_live_fb_create(dev, file_priv, mode_cmd);
+
format = rcar_du_format_info(mode_cmd->pixel_format);
if (format == NULL) {
dev_dbg(dev->dev, "unsupported pixel format %08x\n",
@@ -659,6 +730,12 @@ int rcar_du_modeset_init(struct rcar_du_
drm_mode_config_reset(dev);
+ if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
+ ret = rcar_du_vsp1_sources_init(rcdu);
+ if (ret < 0)
+ return ret;
+ }
+
drm_kms_helper_poll_init(dev);
if (dev->mode_config.num_connector) {
Index: linux/drivers/gpu/drm/rcar-du/rcar_du_kms.h
===================================================================
--- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_kms.h
+++ linux/drivers/gpu/drm/rcar-du/rcar_du_kms.h
@@ -18,6 +18,7 @@
struct drm_file;
struct drm_device;
+struct drm_live_source;
struct drm_mode_create_dumb;
struct rcar_du_device;
@@ -36,4 +37,6 @@ int rcar_du_modeset_init(struct rcar_du_
int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args);
+struct drm_live_source *rcar_du_live_fb_source(struct drm_framebuffer *fb);
+
#endif /* __RCAR_DU_KMS_H__ */
Index: linux/drivers/gpu/drm/rcar-du/rcar_du_plane.c
===================================================================
--- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ linux/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -27,6 +27,71 @@
#include "rcar_du_regs.h"
/* -----------------------------------------------------------------------------
+ * Live Sources
+ */
+
+struct rcar_du_vsp1_source {
+ struct drm_live_source base;
+
+ enum rcar_du_plane_source source;
+};
+
+static inline struct rcar_du_vsp1_source *
+to_rcar_vsp1_source(struct drm_live_source *src)
+{
+ return container_of(src, struct rcar_du_vsp1_source, base);
+}
+
+static const struct drm_live_source_funcs rcar_du_live_source_funcs = {
+ .destroy = drm_live_source_cleanup,
+};
+
+static const uint32_t source_formats[] = {
+ DRM_FORMAT_XRGB8888,
+};
+
+int rcar_du_vsp1_sources_init(struct rcar_du_device *rcdu)
+{
+ static const struct {
+ enum rcar_du_plane_source source;
+ unsigned int planes;
+ } sources[] = {
+ { RCAR_DU_PLANE_VSPD0, BIT(RCAR_DU_NUM_KMS_PLANES - 1) },
+ { RCAR_DU_PLANE_VSPD1, BIT(RCAR_DU_NUM_KMS_PLANES - 2) |
+ BIT(2 * RCAR_DU_NUM_KMS_PLANES - 1) },
+ };
+ unsigned int planes_mask;
+ unsigned int num_planes;
+ unsigned int i;
+
+ num_planes = RCAR_DU_NUM_KMS_PLANES * DIV_ROUND_UP(rcdu->num_crtcs, 2);
+ planes_mask = (1 << num_planes) - 1;
+
+ for (i = 0; i < ARRAY_SIZE(sources); ++i) {
+ struct rcar_du_vsp1_source *src;
+ char name[6];
+ int ret;
+
+ src = devm_kzalloc(rcdu->dev, sizeof(*src), GFP_KERNEL);
+ if (src == NULL)
+ return -ENOMEM;
+
+ src->source = sources[i].source;
+
+ sprintf(name, "vspd%u", i);
+ ret = drm_live_source_init(rcdu->ddev, &src->base, name,
+ sources[i].planes & planes_mask,
+ source_formats,
+ ARRAY_SIZE(source_formats),
+ &rcar_du_live_source_funcs);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+/* -----------------------------------------------------------------------------
* Atomic hardware plane allocator
*
* The hardware plane allocator is solely based on the atomic plane states
@@ -555,6 +620,7 @@ static int rcar_du_plane_atomic_check(st
struct rcar_du_plane_state *rstate = to_rcar_plane_state(state);
struct rcar_du_plane *rplane = to_rcar_plane(plane);
struct rcar_du_device *rcdu = rplane->group->dev;
+ uint32_t pixel_format;
if (!state->fb || !state->crtc) {
rstate->format = NULL;
@@ -567,13 +633,22 @@ static int rcar_du_plane_atomic_check(st
return -EINVAL;
}
- rstate->format = rcar_du_format_info(state->fb->format->format);
+ pixel_format = state->fb->format->format;
+ rstate->format = rcar_du_format_info(pixel_format);
if (rstate->format == NULL) {
dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
- state->fb->format->format);
+ pixel_format);
return -EINVAL;
}
+ if (state->fb->flags & DRM_MODE_FB_LIVE_SOURCE) {
+ struct drm_live_source *src = rcar_du_live_fb_source(state->fb);
+
+ rstate->source = to_rcar_vsp1_source(src)->source;
+ } else {
+ rstate->source = RCAR_DU_PLANE_MEMORY;
+ }
+
return 0;
}
Index: linux/drivers/gpu/drm/rcar-du/rcar_du_plane.h
===================================================================
--- linux.orig/drivers/gpu/drm/rcar-du/rcar_du_plane.h
+++ linux/drivers/gpu/drm/rcar-du/rcar_du_plane.h
@@ -17,6 +17,7 @@
#include <drm/drmP.h>
#include <drm/drm_crtc.h>
+struct rcar_du_device;
struct rcar_du_format_info;
struct rcar_du_group;
@@ -72,6 +73,8 @@ to_rcar_plane_state(struct drm_plane_sta
int rcar_du_atomic_check_planes(struct drm_device *dev,
struct drm_atomic_state *state);
+int rcar_du_vsp1_sources_init(struct rcar_du_device *rcdu);
+
int rcar_du_planes_init(struct rcar_du_group *rgrp);
void __rcar_du_plane_setup(struct rcar_du_group *rgrp,
[toc] | [prev] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2017-01-25 22:40 +0100 |
| Subject | [PATCH v3 1/3] drm: Add live source object |
| Message-ID | <t3Dsn-79W-29@gated-at.bofh.it> |
| In reply to | #1566973 |
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Live sources represent a hardware connection between a video stream
source and a CRTC, going through a plane. The kernel API lets driver
register live sources, and the userspace API lets applications enumerate
them.
[Sergei: ported to the modern kernel.]
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 3:
- moved drm_live_source_{init|cleanup}() from drm_crtc.c to drm_plane.c and
their prototypes from <drm/drm_crtc.h> to <drm/drm_plane.h> (along with
*struct* drm_live_source[_funcs]);
- moved drm_mode_getsource[_res]() prototypes from <drm/drm_crtc.h> to
drm_crtc_internal.h;
- updated the ioctl() numbers;
- generally followed the upstream source code moves;
- added my signoff.
drivers/gpu/drm/drm_crtc.c | 93 ++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/drm_crtc_internal.h | 4 +
drivers/gpu/drm/drm_ioctl.c | 2
drivers/gpu/drm/drm_mode_config.c | 7 ++
drivers/gpu/drm/drm_plane.c | 62 ++++++++++++++++++++++++
include/drm/drm_mode_config.h | 2
include/drm/drm_plane.h | 29 +++++++++++
include/uapi/drm/drm.h | 3 +
include/uapi/drm/drm_mode.h | 17 ++++++
9 files changed, 219 insertions(+)
Index: linux/drivers/gpu/drm/drm_crtc.c
===================================================================
--- linux.orig/drivers/gpu/drm/drm_crtc.c
+++ linux/drivers/gpu/drm/drm_crtc.c
@@ -415,6 +415,99 @@ int drm_mode_getcrtc(struct drm_device *
}
/**
+ * drm_mode_getsource_res - get live source info
+ * @dev: DRM device
+ * @data: ioctl data
+ * @file_priv: DRM file info
+ *
+ * Return a live source and set of IDs.
+ */
+int drm_mode_getsource_res(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_mode_get_live_source_res *src_resp = data;
+ struct drm_mode_config *config;
+ struct drm_live_source *src;
+ uint32_t __user *src_ptr;
+ int copied = 0, ret = 0;
+
+ if (!drm_core_check_feature(dev, DRIVER_MODESET))
+ return -EINVAL;
+
+ drm_modeset_lock_all(dev);
+ config = &dev->mode_config;
+
+ /*
+ * This ioctl is called twice, once to determine how much space is
+ * needed, and the 2nd time to fill it.
+ */
+ if (config->num_live_source &&
+ (src_resp->count_sources >= config->num_live_source)) {
+ src_ptr = (uint32_t __user *)(unsigned long)src_resp->source_id_ptr;
+
+ list_for_each_entry(src, &config->live_source_list, head) {
+ if (put_user(src->base.id, src_ptr + copied)) {
+ ret = -EFAULT;
+ goto out;
+ }
+ copied++;
+ }
+ }
+ src_resp->count_sources = config->num_live_source;
+
+out:
+ drm_modeset_unlock_all(dev);
+ return ret;
+}
+
+/**
+ * drm_mode_getsource - get live source info
+ * @dev: DRM device
+ * @data: ioctl data
+ * @file_priv: DRM file info
+ *
+ * Return live source info, including formats supported, ...
+ */
+int drm_mode_getsource(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_mode_get_live_source *src_resp = data;
+ struct drm_mode_object *obj;
+ struct drm_live_source *src;
+
+ if (!drm_core_check_feature(dev, DRIVER_MODESET))
+ return -EINVAL;
+
+ obj = drm_mode_object_find(dev, src_resp->source_id,
+ DRM_MODE_OBJECT_LIVE_SOURCE);
+ if (!obj)
+ return -ENOENT;
+ src = obj_to_live_source(obj);
+
+ src_resp->source_id = src->base.id;
+ strlcpy(src_resp->name, src->name, DRM_SOURCE_NAME_LEN);
+ src_resp->possible_planes = src->possible_planes;
+
+ /*
+ * This ioctl is called twice, once to determine how much space is
+ * needed, and the 2nd time to fill it.
+ */
+ if (src->format_count &&
+ (src_resp->count_format_types >= src->format_count)) {
+ uint32_t __user *format_ptr;
+
+ format_ptr = (uint32_t __user *)(unsigned long)src_resp->format_type_ptr;
+ if (copy_to_user(format_ptr, src->format_types,
+ sizeof(uint32_t) * src->format_count)) {
+ return -EFAULT;
+ }
+ }
+ src_resp->count_format_types = src->format_count;
+
+ return 0;
+}
+
+/**
* drm_mode_set_config_internal - helper to call ->set_config
* @set: modeset config to set
*
Index: linux/drivers/gpu/drm/drm_crtc_internal.h
===================================================================
--- linux.orig/drivers/gpu/drm/drm_crtc_internal.h
+++ linux/drivers/gpu/drm/drm_crtc_internal.h
@@ -50,6 +50,10 @@ int drm_mode_getcrtc(struct drm_device *
void *data, struct drm_file *file_priv);
int drm_mode_setcrtc(struct drm_device *dev,
void *data, struct drm_file *file_priv);
+int drm_mode_getsource_res(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+int drm_mode_getsource(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
/* drm_mode_config.c */
Index: linux/drivers/gpu/drm/drm_ioctl.c
===================================================================
--- linux.orig/drivers/gpu/drm/drm_ioctl.c
+++ linux/drivers/gpu/drm/drm_ioctl.c
@@ -612,10 +612,12 @@ static const struct drm_ioctl_desc drm_i
DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETSOURCERESOURCES, drm_mode_getsource_res, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANE, drm_mode_getplane, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPLANE, drm_mode_setplane, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETSOURCE, drm_mode_getsource, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETGAMMA, drm_mode_gamma_get_ioctl, DRM_UNLOCKED),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER|DRM_UNLOCKED),
Index: linux/drivers/gpu/drm/drm_mode_config.c
===================================================================
--- linux.orig/drivers/gpu/drm/drm_mode_config.c
+++ linux/drivers/gpu/drm/drm_mode_config.c
@@ -366,6 +366,7 @@ void drm_mode_config_init(struct drm_dev
INIT_LIST_HEAD(&dev->mode_config.property_list);
INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
INIT_LIST_HEAD(&dev->mode_config.plane_list);
+ INIT_LIST_HEAD(&dev->mode_config.live_source_list);
idr_init(&dev->mode_config.crtc_idr);
idr_init(&dev->mode_config.tile_idr);
ida_init(&dev->mode_config.connector_ida);
@@ -406,6 +407,7 @@ void drm_mode_config_cleanup(struct drm_
struct drm_property *property, *pt;
struct drm_property_blob *blob, *bt;
struct drm_plane *plane, *plt;
+ struct drm_live_source *src, *psrc;
list_for_each_entry_safe(encoder, enct, &dev->mode_config.encoder_list,
head) {
@@ -433,6 +435,11 @@ void drm_mode_config_cleanup(struct drm_
plane->funcs->destroy(plane);
}
+ list_for_each_entry_safe(src, psrc, &dev->mode_config.live_source_list,
+ head) {
+ src->funcs->destroy(src);
+ }
+
list_for_each_entry_safe(crtc, ct, &dev->mode_config.crtc_list, head) {
crtc->funcs->destroy(crtc);
}
Index: linux/drivers/gpu/drm/drm_plane.c
===================================================================
--- linux.orig/drivers/gpu/drm/drm_plane.c
+++ linux/drivers/gpu/drm/drm_plane.c
@@ -248,6 +248,68 @@ void drm_plane_cleanup(struct drm_plane
}
EXPORT_SYMBOL(drm_plane_cleanup);
+int drm_live_source_init(struct drm_device *dev, struct drm_live_source *src,
+ const char *name, unsigned long possible_planes,
+ const uint32_t *formats, uint32_t format_count,
+ const struct drm_live_source_funcs *funcs)
+{
+ unsigned int i;
+ int ret;
+
+ /* Multi-planar live sources are not supported for now. */
+ for (i = 0; i < format_count; ++i) {
+ if (drm_format_num_planes(formats[i]) != 1) {
+ DRM_DEBUG_KMS("multiplanar live sources unsupported\n");
+ return -EINVAL;
+ }
+ }
+
+ drm_modeset_lock_all(dev);
+
+ ret = drm_mode_object_get(dev, &src->base, DRM_MODE_OBJECT_LIVE_SOURCE);
+ if (ret)
+ goto out;
+
+ src->dev = dev;
+ src->funcs = funcs;
+ if (name)
+ strlcpy(src->name, name, DRM_SOURCE_NAME_LEN);
+ src->possible_planes = possible_planes;
+
+ src->format_types = kmalloc_array(format_count,
+ sizeof(*src->format_types),
+ GFP_KERNEL);
+ if (!src->format_types) {
+ DRM_DEBUG_KMS("out of memory when allocating source foramts\n");
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ memcpy(src->format_types, formats,
+ format_count * sizeof(*src->format_types));
+ src->format_count = format_count;
+
+ list_add_tail(&src->head, &dev->mode_config.live_source_list);
+ dev->mode_config.num_live_source++;
+
+ out:
+ drm_modeset_unlock_all(dev);
+
+ return ret;
+}
+EXPORT_SYMBOL(drm_live_source_init);
+
+void drm_live_source_cleanup(struct drm_live_source *src)
+{
+ struct drm_device *dev = src->dev;
+
+ drm_modeset_lock_all(dev);
+ list_del(&src->head);
+ dev->mode_config.num_live_source--;
+ drm_modeset_unlock_all(dev);
+}
+EXPORT_SYMBOL(drm_live_source_cleanup);
+
/**
* drm_plane_from_index - find the registered plane at an index
* @dev: DRM device
Index: linux/include/drm/drm_mode_config.h
===================================================================
--- linux.orig/include/drm/drm_mode_config.h
+++ linux/include/drm/drm_mode_config.h
@@ -396,6 +396,8 @@ struct drm_mode_config {
int num_overlay_plane;
int num_total_plane;
struct list_head plane_list;
+ int num_live_source;
+ struct list_head live_source_list;
int num_crtc;
struct list_head crtc_list;
Index: linux/include/drm/drm_plane.h
===================================================================
--- linux.orig/include/drm/drm_plane.h
+++ linux/include/drm/drm_plane.h
@@ -29,6 +29,7 @@
struct drm_crtc;
struct drm_printer;
+struct drm_live_source;
/**
* struct drm_plane_state - mutable plane state
@@ -527,6 +528,34 @@ extern int drm_plane_init(struct drm_dev
bool is_primary);
extern void drm_plane_cleanup(struct drm_plane *plane);
+struct drm_live_source_funcs {
+ void (*destroy)(struct drm_live_source *src);
+};
+
+struct drm_live_source {
+ struct drm_device *dev;
+ struct list_head head;
+
+ struct drm_mode_object base;
+
+ char name[DRM_SOURCE_NAME_LEN];
+
+ uint32_t possible_planes;
+ uint32_t *format_types;
+ uint32_t format_count;
+
+ const struct drm_live_source_funcs *funcs;
+};
+
+#define obj_to_live_source(x) container_of(x, struct drm_live_source, base)
+
+extern int drm_live_source_init(struct drm_device *dev,
+ struct drm_live_source *src, const char *name,
+ unsigned long possible_planes,
+ const uint32_t *formats, uint32_t format_count,
+ const struct drm_live_source_funcs *funcs);
+extern void drm_live_source_cleanup(struct drm_live_source *src);
+
/**
* drm_plane_index - find the index of a registered plane
* @plane: plane to find index for
Index: linux/include/uapi/drm/drm.h
===================================================================
--- linux.orig/include/uapi/drm/drm.h
+++ linux/include/uapi/drm/drm.h
@@ -814,6 +814,9 @@ extern "C" {
#define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob)
#define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob)
+#define DRM_IOCTL_MODE_GETSOURCERESOURCES DRM_IOWR(0xBF, struct drm_mode_get_live_source_res)
+#define DRM_IOCTL_MODE_GETSOURCE DRM_IOWR(0xC0, struct drm_mode_get_live_source)
+
/**
* Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x9f.
Index: linux/include/uapi/drm/drm_mode.h
===================================================================
--- linux.orig/include/uapi/drm/drm_mode.h
+++ linux/include/uapi/drm/drm_mode.h
@@ -37,6 +37,7 @@ extern "C" {
#define DRM_CONNECTOR_NAME_LEN 32
#define DRM_DISPLAY_MODE_LEN 32
#define DRM_PROP_NAME_LEN 32
+#define DRM_SOURCE_NAME_LEN 32
#define DRM_MODE_TYPE_BUILTIN (1<<0)
#define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
@@ -214,6 +215,21 @@ struct drm_mode_get_plane_res {
__u32 count_planes;
};
+struct drm_mode_get_live_source {
+ __u32 source_id;
+ char name[DRM_SOURCE_NAME_LEN];
+
+ __u32 possible_planes;
+
+ __u32 count_format_types;
+ __u64 format_type_ptr;
+};
+
+struct drm_mode_get_live_source_res {
+ __u64 source_id_ptr;
+ __u32 count_sources;
+};
+
#define DRM_MODE_ENCODER_NONE 0
#define DRM_MODE_ENCODER_DAC 1
#define DRM_MODE_ENCODER_TMDS 2
@@ -352,6 +368,7 @@ struct drm_mode_connector_set_property {
#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
+#define DRM_MODE_OBJECT_LIVE_SOURCE 0xe1e1e1e1
#define DRM_MODE_OBJECT_ANY 0
struct drm_mode_obj_get_properties {
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web