[media] v4l: vsp1: Add VSP+DU support
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 2 Aug 2015 21:37:01 +0000 (18:37 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 19 Feb 2016 11:29:32 +0000 (09:29 -0200)
Implement internal control of the VSP pipeline to be used by the DU
DRM/KMS driver when using the VSP as an internal composer handled
through DRM/KMS only.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/vsp1/Makefile
drivers/media/platform/vsp1/vsp1.h
drivers/media/platform/vsp1/vsp1_drm.c [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_drm.h [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_drv.c
include/media/vsp1.h [new file with mode: 0644]

index 0ef0b5384125a33d6e392b08ef66f7d462694c8d..447e72a2ef4307e8320d3ac757beb51d65b8a3d9 100644 (file)
@@ -1,5 +1,5 @@
 vsp1-y                                 := vsp1_drv.o vsp1_entity.o vsp1_pipe.o
-vsp1-y                                 += vsp1_video.o
+vsp1-y                                 += vsp1_drm.o vsp1_video.o
 vsp1-y                                 += vsp1_rpf.o vsp1_rwpf.o vsp1_wpf.o
 vsp1-y                                 += vsp1_hsit.o vsp1_lif.o vsp1_lut.o
 vsp1-y                                 += vsp1_bru.o vsp1_sru.o vsp1_uds.o
index 454201bf59ee7c8d9864ef6978d723480426e5e0..67a026ae88cb1260e4c8c6a1a2e545b5f4047151 100644 (file)
@@ -26,6 +26,7 @@
 struct clk;
 struct device;
 
+struct vsp1_drm;
 struct vsp1_platform_data;
 struct vsp1_bru;
 struct vsp1_hsit;
@@ -78,8 +79,8 @@ struct vsp1_device {
 
        struct v4l2_device v4l2_dev;
        struct media_device media_dev;
-
        struct media_entity_operations media_ops;
+       struct vsp1_drm *drm;
 };
 
 int vsp1_device_get(struct vsp1_device *vsp1);
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
new file mode 100644 (file)
index 0000000..ac81ff1
--- /dev/null
@@ -0,0 +1,552 @@
+/*
+ * vsp1_drm.c  --  R-Car VSP1 DRM API
+ *
+ * Copyright (C) 2015 Renesas Electronics Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
+ *
+ * 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.
+ */
+
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/vsp1.h>
+
+#include <media/media-entity.h>
+#include <media/v4l2-subdev.h>
+
+#include "vsp1.h"
+#include "vsp1_bru.h"
+#include "vsp1_drm.h"
+#include "vsp1_lif.h"
+#include "vsp1_pipe.h"
+#include "vsp1_rwpf.h"
+
+/* -----------------------------------------------------------------------------
+ * Runtime Handling
+ */
+
+static int vsp1_drm_pipeline_run(struct vsp1_pipeline *pipe)
+{
+       struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
+       int ret;
+
+       if (vsp1->drm->update) {
+               struct vsp1_entity *entity;
+
+               list_for_each_entry(entity, &pipe->entities, list_pipe) {
+                       /* Skip unused RPFs. */
+                       if (entity->type == VSP1_ENTITY_RPF) {
+                               struct vsp1_rwpf *rpf =
+                                       to_rwpf(&entity->subdev);
+
+                               if (!pipe->inputs[rpf->entity.index])
+                                       continue;
+                       }
+
+                       vsp1_entity_route_setup(entity);
+
+                       ret = v4l2_subdev_call(&entity->subdev, video,
+                                              s_stream, 1);
+                       if (ret < 0) {
+                               dev_err(vsp1->dev,
+                                       "DRM pipeline start failure on entity %s\n",
+                                       entity->subdev.name);
+                               return ret;
+                       }
+               }
+
+               vsp1->drm->update = false;
+       }
+
+       vsp1_pipeline_run(pipe);
+
+       return 0;
+}
+
+static void vsp1_drm_pipeline_frame_end(struct vsp1_pipeline *pipe)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+       if (pipe->num_inputs)
+               vsp1_drm_pipeline_run(pipe);
+       spin_unlock_irqrestore(&pipe->irqlock, flags);
+}
+
+/* -----------------------------------------------------------------------------
+ * DU Driver API
+ */
+
+int vsp1_du_init(struct device *dev)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+
+       if (!vsp1)
+               return -EPROBE_DEFER;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_init);
+
+/**
+ * vsp1_du_setup_lif - Setup the output part of the VSP pipeline
+ * @dev: the VSP device
+ * @width: output frame width in pixels
+ * @height: output frame height in pixels
+ *
+ * Configure the output part of VSP DRM pipeline for the given frame @width and
+ * @height. This sets up formats on the BRU source pad, the WPF0 sink and source
+ * pads, and the LIF sink pad.
+ *
+ * As the media bus code on the BRU source pad is conditioned by the
+ * configuration of the BRU sink 0 pad, we also set up the formats on all BRU
+ * sinks, even if the configuration will be overwritten later by
+ * vsp1_du_setup_rpf(). This ensures that the BRU configuration is set to a well
+ * defined state.
+ *
+ * Return 0 on success or a negative error code on failure.
+ */
+int vsp1_du_setup_lif(struct device *dev, unsigned int width,
+                     unsigned int height)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+       struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+       struct vsp1_bru *bru = vsp1->bru;
+       struct v4l2_subdev_format format;
+       unsigned int i;
+       int ret;
+
+       dev_dbg(vsp1->dev, "%s: configuring LIF with format %ux%u\n",
+               __func__, width, height);
+
+       if (width == 0 || height == 0) {
+               /* Zero width or height means the CRTC is being disabled, stop
+                * the pipeline and turn the light off.
+                */
+               ret = vsp1_pipeline_stop(pipe);
+               if (ret == -ETIMEDOUT)
+                       dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
+
+               media_entity_pipeline_stop(&pipe->output->entity.subdev.entity);
+
+               for (i = 0; i < bru->entity.source_pad; ++i) {
+                       bru->inputs[i].rpf = NULL;
+                       pipe->inputs[i] = NULL;
+               }
+
+               pipe->num_inputs = 0;
+
+               vsp1_device_put(vsp1);
+
+               dev_dbg(vsp1->dev, "%s: pipeline disabled\n", __func__);
+
+               return 0;
+       }
+
+       /* Configure the format at the BRU sinks and propagate it through the
+        * pipeline.
+        */
+       memset(&format, 0, sizeof(format));
+       format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+
+       for (i = 0; i < bru->entity.source_pad; ++i) {
+               format.pad = i;
+
+               format.format.width = width;
+               format.format.height = height;
+               format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
+               format.format.field = V4L2_FIELD_NONE;
+
+               ret = v4l2_subdev_call(&bru->entity.subdev, pad,
+                                      set_fmt, NULL, &format);
+               if (ret < 0)
+                       return ret;
+
+               dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
+                       __func__, format.format.width, format.format.height,
+                       format.format.code, i);
+       }
+
+       format.pad = bru->entity.source_pad;
+       format.format.width = width;
+       format.format.height = height;
+       format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
+       format.format.field = V4L2_FIELD_NONE;
+
+       ret = v4l2_subdev_call(&bru->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, i);
+
+       format.pad = RWPF_PAD_SINK;
+       ret = v4l2_subdev_call(&vsp1->wpf[0]->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on WPF0 sink\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code);
+
+       format.pad = RWPF_PAD_SOURCE;
+       ret = v4l2_subdev_call(&vsp1->wpf[0]->entity.subdev, pad, get_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: got format %ux%u (%x) on WPF0 source\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code);
+
+       format.pad = LIF_PAD_SINK;
+       ret = v4l2_subdev_call(&vsp1->lif->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on LIF sink\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code);
+
+       /* Verify that the format at the output of the pipeline matches the
+        * requested frame size and media bus code.
+        */
+       if (format.format.width != width || format.format.height != height ||
+           format.format.code != MEDIA_BUS_FMT_ARGB8888_1X32) {
+               dev_dbg(vsp1->dev, "%s: format mismatch\n", __func__);
+               return -EPIPE;
+       }
+
+       /* Mark the pipeline as streaming and enable the VSP1. This will store
+        * the pipeline pointer in all entities, which the s_stream handlers
+        * will need. We don't start the entities themselves right at this point
+        * as there's no plane configured yet, so we can't start processing
+        * buffers.
+        */
+       ret = vsp1_device_get(vsp1);
+       if (ret < 0)
+               return ret;
+
+       ret = media_entity_pipeline_start(&pipe->output->entity.subdev.entity,
+                                         &pipe->pipe);
+       if (ret < 0) {
+               dev_dbg(vsp1->dev, "%s: pipeline start failed\n", __func__);
+               vsp1_device_put(vsp1);
+               return ret;
+       }
+
+       dev_dbg(vsp1->dev, "%s: pipeline enabled\n", __func__);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_setup_lif);
+
+/**
+ * vsp1_du_setup_rpf - Setup one RPF input of the VSP pipeline
+ * @dev: the VSP device
+ * @rpf_index: index of the RPF to setup (0-based)
+ * @pixelformat: V4L2 pixel format for the RPF memory input
+ * @pitch: number of bytes per line in the image stored in memory
+ * @mem: DMA addresses of the memory buffers (one per plane)
+ * @src: the source crop rectangle for the RPF
+ * @dst: the destination compose rectangle for the BRU input
+ *
+ * Configure the VSP to perform composition of the image referenced by @mem
+ * through RPF @rpf_index, using the @src crop rectangle and the @dst
+ * composition rectangle. The Z-order is fixed with RPF 0 at the bottom.
+ *
+ * Image format as stored in memory is expressed as a V4L2 @pixelformat value.
+ * As a special case, setting the pixel format to 0 will disable the RPF. The
+ * @pitch, @mem, @src and @dst parameters are ignored in that case. Calling the
+ * function on a disabled RPF is allowed.
+ *
+ * The memory pitch is configurable to allow for padding at end of lines, or
+ * simple for images that extend beyond the crop rectangle boundaries. The
+ * @pitch value is expressed in bytes and applies to all planes for multiplanar
+ * formats.
+ *
+ * The source memory buffer is referenced by the DMA address of its planes in
+ * the @mem array. Up to two planes are supported. The second plane DMA address
+ * is ignored for formats using a single plane.
+ *
+ * This function isn't reentrant, the caller needs to serialize calls.
+ *
+ * TODO: Implement Z-order control by decoupling the RPF index from the BRU
+ * input index.
+ *
+ * Return 0 on success or a negative error code on failure.
+ */
+int vsp1_du_setup_rpf(struct device *dev, unsigned int rpf_index,
+                     u32 pixelformat, unsigned int pitch,
+                     dma_addr_t mem[2], const struct v4l2_rect *src,
+                     const struct v4l2_rect *dst)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+       struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+       const struct vsp1_format_info *fmtinfo;
+       struct v4l2_subdev_selection sel;
+       struct v4l2_subdev_format format;
+       struct vsp1_rwpf_memory memory;
+       struct vsp1_rwpf *rpf;
+       unsigned long flags;
+       bool start_stop = false;
+       int ret;
+
+       if (rpf_index >= vsp1->pdata.rpf_count)
+               return -EINVAL;
+
+       rpf = vsp1->rpf[rpf_index];
+
+       if (pixelformat == 0) {
+               dev_dbg(vsp1->dev, "%s: RPF%u: disable requested\n", __func__,
+                       rpf_index);
+
+               spin_lock_irqsave(&pipe->irqlock, flags);
+
+               if (pipe->inputs[rpf_index]) {
+                       /* Remove the RPF from the pipeline if it was previously
+                        * enabled.
+                        */
+                       vsp1->bru->inputs[rpf_index].rpf = NULL;
+                       pipe->inputs[rpf_index] = NULL;
+
+                       vsp1->drm->update = true;
+                       start_stop = --pipe->num_inputs == 0;
+               }
+
+               spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+               /* Stop the pipeline if we're the last user. */
+               if (start_stop)
+                       vsp1_pipeline_stop(pipe);
+
+               return 0;
+       }
+
+       dev_dbg(vsp1->dev,
+               "%s: RPF%u: (%u,%u)/%ux%u -> (%u,%u)/%ux%u (%08x), pitch %u dma { %pad, %pad }\n",
+               __func__, rpf_index,
+               src->left, src->top, src->width, src->height,
+               dst->left, dst->top, dst->width, dst->height,
+               pixelformat, pitch, &mem[0], &mem[1]);
+
+       /* Set the stride at the RPF input. */
+       fmtinfo = vsp1_get_format_info(pixelformat);
+       if (!fmtinfo) {
+               dev_dbg(vsp1->dev, "Unsupport pixel format %08x for RPF\n",
+                       pixelformat);
+               return -EINVAL;
+       }
+
+       rpf->fmtinfo = fmtinfo;
+       rpf->format.num_planes = fmtinfo->planes;
+       rpf->format.plane_fmt[0].bytesperline = pitch;
+       rpf->format.plane_fmt[1].bytesperline = pitch;
+
+       /* Configure the format on the RPF sink pad and propagate it up to the
+        * BRU sink pad.
+        */
+       memset(&format, 0, sizeof(format));
+       format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       format.pad = RWPF_PAD_SINK;
+       format.format.width = src->width + src->left;
+       format.format.height = src->height + src->top;
+       format.format.code = fmtinfo->mbus;
+       format.format.field = V4L2_FIELD_NONE;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: set format %ux%u (%x) on RPF%u sink\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, rpf->entity.index);
+
+       memset(&sel, 0, sizeof(sel));
+       sel.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       sel.pad = RWPF_PAD_SINK;
+       sel.target = V4L2_SEL_TGT_CROP;
+       sel.r = *src;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_selection, NULL,
+                              &sel);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: set selection (%u,%u)/%ux%u on RPF%u sink\n",
+               __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
+               rpf->entity.index);
+
+       /* RPF source, hardcode the format to ARGB8888 to turn on format
+        * conversion if needed.
+        */
+       format.pad = RWPF_PAD_SOURCE;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, get_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: got format %ux%u (%x) on RPF%u source\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, rpf->entity.index);
+
+       format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       /* BRU sink, propagate the format from the RPF source. */
+       format.pad = rpf->entity.index;
+
+       ret = v4l2_subdev_call(&vsp1->bru->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, format.pad);
+
+       sel.pad = rpf->entity.index;
+       sel.target = V4L2_SEL_TGT_COMPOSE;
+       sel.r = *dst;
+
+       ret = v4l2_subdev_call(&vsp1->bru->entity.subdev, pad, set_selection,
+                              NULL, &sel);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: set selection (%u,%u)/%ux%u on BRU pad %u\n",
+               __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
+               sel.pad);
+
+       /* Store the compose rectangle coordinates in the RPF. */
+       rpf->location.left = dst->left;
+       rpf->location.top = dst->top;
+
+       /* Set the memory buffer address. */
+       memory.num_planes = fmtinfo->planes;
+       memory.addr[0] = mem[0];
+       memory.addr[1] = mem[1];
+
+       rpf->ops->set_memory(rpf, &memory);
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+
+       /* If the RPF was previously stopped set the BRU input to the RPF and
+        * store the RPF in the pipeline inputs array.
+        */
+       if (!pipe->inputs[rpf->entity.index]) {
+               vsp1->bru->inputs[rpf_index].rpf = rpf;
+               pipe->inputs[rpf->entity.index] = rpf;
+               start_stop = pipe->num_inputs++ == 0;
+       }
+
+       /* Start the pipeline if it's currently stopped. */
+       vsp1->drm->update = true;
+       if (start_stop)
+               vsp1_drm_pipeline_run(pipe);
+
+       spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_setup_rpf);
+
+/* -----------------------------------------------------------------------------
+ * Initialization
+ */
+
+int vsp1_drm_create_links(struct vsp1_device *vsp1)
+{
+       const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE;
+       unsigned int i;
+       int ret;
+
+       /* VSPD instances require a BRU to perform composition and a LIF to
+        * output to the DU.
+        */
+       if (!vsp1->bru || !vsp1->lif)
+               return -ENXIO;
+
+       for (i = 0; i < vsp1->pdata.rpf_count; ++i) {
+               struct vsp1_rwpf *rpf = vsp1->rpf[i];
+
+               ret = media_create_pad_link(&rpf->entity.subdev.entity,
+                                           RWPF_PAD_SOURCE,
+                                           &vsp1->bru->entity.subdev.entity,
+                                           i, flags);
+               if (ret < 0)
+                       return ret;
+
+               rpf->entity.sink = &vsp1->bru->entity.subdev.entity;
+               rpf->entity.sink_pad = i;
+       }
+
+       ret = media_create_pad_link(&vsp1->bru->entity.subdev.entity,
+                                   vsp1->bru->entity.source_pad,
+                                   &vsp1->wpf[0]->entity.subdev.entity,
+                                   RWPF_PAD_SINK, flags);
+       if (ret < 0)
+               return ret;
+
+       vsp1->bru->entity.sink = &vsp1->wpf[0]->entity.subdev.entity;
+       vsp1->bru->entity.sink_pad = RWPF_PAD_SINK;
+
+       ret = media_create_pad_link(&vsp1->wpf[0]->entity.subdev.entity,
+                                   RWPF_PAD_SOURCE,
+                                   &vsp1->lif->entity.subdev.entity,
+                                   LIF_PAD_SINK, flags);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+int vsp1_drm_init(struct vsp1_device *vsp1)
+{
+       struct vsp1_pipeline *pipe;
+       unsigned int i;
+
+       vsp1->drm = devm_kzalloc(vsp1->dev, sizeof(*vsp1->drm), GFP_KERNEL);
+       if (!vsp1->drm)
+               return -ENOMEM;
+
+       pipe = &vsp1->drm->pipe;
+
+       vsp1_pipeline_init(pipe);
+       pipe->frame_end = vsp1_drm_pipeline_frame_end;
+
+       /* The DRM pipeline is static, add entities manually. */
+       for (i = 0; i < vsp1->pdata.rpf_count; ++i) {
+               struct vsp1_rwpf *input = vsp1->rpf[i];
+
+               list_add_tail(&input->entity.list_pipe, &pipe->entities);
+       }
+
+       list_add_tail(&vsp1->bru->entity.list_pipe, &pipe->entities);
+       list_add_tail(&vsp1->wpf[0]->entity.list_pipe, &pipe->entities);
+       list_add_tail(&vsp1->lif->entity.list_pipe, &pipe->entities);
+
+       pipe->bru = &vsp1->bru->entity;
+       pipe->lif = &vsp1->lif->entity;
+       pipe->output = vsp1->wpf[0];
+
+       return 0;
+}
diff --git a/drivers/media/platform/vsp1/vsp1_drm.h b/drivers/media/platform/vsp1/vsp1_drm.h
new file mode 100644 (file)
index 0000000..2ad320a
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * vsp1_drm.h  --  R-Car VSP1 DRM/KMS Interface
+ *
+ * Copyright (C) 2015 Renesas Electronics Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
+ *
+ * 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 __VSP1_DRM_H__
+#define __VSP1_DRM_H__
+
+#include "vsp1_pipe.h"
+
+struct vsp1_drm {
+       struct vsp1_pipeline pipe;
+       bool update;
+};
+
+int vsp1_drm_init(struct vsp1_device *vsp1);
+int vsp1_drm_create_links(struct vsp1_device *vsp1);
+
+#endif /* __VSP1_DRM_H__ */
index 1e10fc4723c5372129d4440f894ff71d701e2ab2..74b5920e516b0f6c2dcd3b357798c62cae58695b 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "vsp1.h"
 #include "vsp1_bru.h"
+#include "vsp1_drm.h"
 #include "vsp1_hsit.h"
 #include "vsp1_lif.h"
 #include "vsp1_lut.h"
@@ -120,7 +121,7 @@ static int vsp1_create_sink_links(struct vsp1_device *vsp1,
        return 0;
 }
 
-static int vsp1_create_links(struct vsp1_device *vsp1)
+static int vsp1_uapi_create_links(struct vsp1_device *vsp1)
 {
        struct vsp1_entity *entity;
        unsigned int i;
@@ -145,9 +146,6 @@ static int vsp1_create_links(struct vsp1_device *vsp1)
                        return ret;
        }
 
-       if (!vsp1->pdata.uapi)
-               return 0;
-
        for (i = 0; i < vsp1->pdata.rpf_count; ++i) {
                struct vsp1_rwpf *rpf = vsp1->rpf[i];
 
@@ -360,15 +358,22 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
        }
 
        /* Create links. */
-       ret = vsp1_create_links(vsp1);
+       if (vsp1->pdata.uapi)
+               ret = vsp1_uapi_create_links(vsp1);
+       else
+               ret = vsp1_drm_create_links(vsp1);
        if (ret < 0)
                goto done;
 
-       if (vsp1->pdata.uapi) {
+       /* Register subdev nodes if the userspace API is enabled or initialize
+        * the DRM pipeline otherwise.
+        */
+       if (vsp1->pdata.uapi)
                ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev);
-               if (ret < 0)
-                       goto done;
-       }
+       else
+               ret = vsp1_drm_init(vsp1);
+       if (ret < 0)
+               goto done;
 
        ret = media_device_register(mdev);
 
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
new file mode 100644 (file)
index 0000000..2c1aea7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * vsp1.h  --  R-Car VSP1 API
+ *
+ * Copyright (C) 2015 Renesas Electronics Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
+ *
+ * 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 __MEDIA_VSP1_H__
+#define __MEDIA_VSP1_H__
+
+#include <linux/types.h>
+
+struct device;
+struct v4l2_rect;
+
+int vsp1_du_init(struct device *dev);
+
+int vsp1_du_setup_lif(struct device *dev, unsigned int width,
+                     unsigned int height);
+
+int vsp1_du_setup_rpf(struct device *dev, unsigned int rpf, u32 pixelformat,
+                     unsigned int pitch, dma_addr_t mem[2],
+                     const struct v4l2_rect *src, const struct v4l2_rect *dst);
+
+#endif /* __MEDIA_VSP1_H__ */