/* * Insert the UIF in the pipeline between the prev and next entities. If no UIF * is available connect the two entities directly.
*/ staticint vsp1_du_insert_uif(struct vsp1_device *vsp1, struct vsp1_pipeline *pipe, struct vsp1_entity *uif, struct vsp1_entity *prev, unsignedint prev_pad, struct vsp1_entity *next, unsignedint next_pad)
{ struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
}; int ret;
if (!uif) { /* * If there's no UIF to be inserted, connect the previous and * next entities directly.
*/
prev->sink = next;
prev->sink_pad = next_pad; return 0;
}
prev->sink = uif;
prev->sink_pad = UIF_PAD_SINK;
format.pad = prev_pad;
ret = v4l2_subdev_call(&prev->subdev, pad, get_fmt, NULL, &format); if (ret < 0) return ret;
format.pad = UIF_PAD_SINK;
ret = v4l2_subdev_call(&uif->subdev, pad, set_fmt, NULL, &format); if (ret < 0) return ret;
dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on UIF sink\n",
__func__, format.format.width, format.format.height,
format.format.code);
/* * The UIF doesn't mangle the format between its sink and source pads, * so there is no need to retrieve the format on its source pad.
*/
uif->sink = next;
uif->sink_pad = next_pad;
return 0;
}
/* Setup one RPF and the connected BRx sink pad. */ staticint vsp1_du_pipeline_setup_rpf(struct vsp1_device *vsp1, struct vsp1_pipeline *pipe, struct vsp1_rwpf *rpf, struct vsp1_entity *uif, unsignedint brx_input)
{ conststruct vsp1_drm_input *input = &vsp1->drm->inputs[rpf->entity.index]; struct v4l2_subdev_selection sel = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
}; struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
}; int ret;
/* * Configure the format on the RPF sink pad and propagate it up to the * BRx sink pad.
*/
format.pad = RWPF_PAD_SINK;
format.format.width = input->crop.width + input->crop.left;
format.format.height = input->crop.height + input->crop.top;
format.format.code = rpf->fmtinfo->mbus;
format.format.field = V4L2_FIELD_NONE;
format.format.ycbcr_enc = input->ycbcr_enc;
format.format.quantization = input->quantization;
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);
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;
/* Insert and configure the UIF if available. */
ret = vsp1_du_insert_uif(vsp1, pipe, uif, &rpf->entity, RWPF_PAD_SOURCE,
pipe->brx, brx_input); if (ret < 0) return ret;
/* BRx sink, propagate the format from the RPF source. */
format.pad = brx_input;
ret = v4l2_subdev_call(&pipe->brx->subdev, pad, set_fmt, NULL,
&format); if (ret < 0) return ret;
dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on %s pad %u\n",
__func__, format.format.width, format.format.height,
format.format.code, BRX_NAME(pipe->brx), format.pad);
/* * Pick a BRx: * - If we need more than two inputs, use the BRU. * - Otherwise, if we are not forced to release our BRx, keep it. * - Else, use any free BRx (randomly starting with the BRU).
*/ if (pipe->num_inputs > 2)
brx = &vsp1->bru->entity; elseif (pipe->brx && !drm_pipe->force_brx_release)
brx = pipe->brx; elseif (vsp1_feature(vsp1, VSP1_HAS_BRU) && !vsp1->bru->entity.pipe)
brx = &vsp1->bru->entity; else
brx = &vsp1->brs->entity;
/* Switch BRx if needed. */ if (brx != pipe->brx) { struct vsp1_entity *released_brx = NULL;
/* Release our BRx if we have one. */ if (pipe->brx) {
dev_dbg(vsp1->dev, "%s: pipe %u: releasing %s\n",
__func__, pipe->lif->index,
BRX_NAME(pipe->brx));
/* * The BRx might be acquired by the other pipeline in * the next step. We must thus remove it from the list * of entities for this pipeline. The other pipeline's * hardware configuration will reconfigure the BRx * routing. * * However, if the other pipeline doesn't acquire our * BRx, we need to keep it in the list, otherwise the * hardware configuration step won't disconnect it from * the pipeline. To solve this, store the released BRx * pointer to add it back to the list of entities later * if it isn't acquired by the other pipeline.
*/
released_brx = pipe->brx;
/* * If the BRx we need is in use, force the owner pipeline to * switch to the other BRx and wait until the switch completes.
*/ if (brx->pipe) { struct vsp1_drm_pipeline *owner_pipe;
dev_dbg(vsp1->dev, "%s: pipe %u: waiting for %s\n",
__func__, pipe->lif->index, BRX_NAME(brx));
ret = wait_event_timeout(owner_pipe->wait_queue,
!owner_pipe->force_brx_release,
msecs_to_jiffies(500)); if (ret == 0)
dev_warn(vsp1->dev, "DRM pipeline %u reconfiguration timeout\n",
owner_pipe->pipe.lif->index);
}
/* * If the BRx we have released previously hasn't been acquired * by the other pipeline, add it back to the entities list (with * the pipe pointer NULL) to let vsp1_du_pipeline_configure() * disconnect it from the hardware pipeline.
*/ if (released_brx && !released_brx->pipe)
list_add_tail(&released_brx->list_pipe,
&pipe->entities);
/* * Add the BRx to the pipeline, inserting it just before the * WPF.
*/
dev_dbg(vsp1->dev, "%s: pipe %u: acquired %s\n",
__func__, pipe->lif->index, BRX_NAME(brx));
/* * Configure the format on the BRx source and verify that it matches the * requested format. We don't set the media bus code as it is configured * on the BRx sink pad 0 and propagated inside the entity, not on the * source pad.
*/
format.pad = brx->source_pad;
format.format.width = drm_pipe->width;
format.format.height = drm_pipe->height;
format.format.field = V4L2_FIELD_NONE;
ret = v4l2_subdev_call(&brx->subdev, pad, set_fmt, NULL,
&format); if (ret < 0) return ret;
dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on %s pad %u\n",
__func__, format.format.width, format.format.height,
format.format.code, BRX_NAME(brx), brx->source_pad);
if (format.format.width != drm_pipe->width ||
format.format.height != drm_pipe->height) {
dev_dbg(vsp1->dev, "%s: format mismatch\n", __func__); return -EPIPE;
}
/* Setup the input side of the pipeline (RPFs and BRx). */ staticint vsp1_du_pipeline_setup_inputs(struct vsp1_device *vsp1, struct vsp1_pipeline *pipe)
{ struct vsp1_drm_pipeline *drm_pipe = to_vsp1_drm_pipeline(pipe); struct vsp1_rwpf *inputs[VSP1_MAX_RPF] = { NULL, }; struct vsp1_entity *uif; bool use_uif = false; struct vsp1_brx *brx; unsignedint i; int ret;
/* Count the number of enabled inputs and sort them by Z-order. */
pipe->num_inputs = 0;
for (i = 0; i < vsp1->info->rpf_count; ++i) { struct vsp1_rwpf *rpf = vsp1->rpf[i]; unsignedint j;
if (!pipe->inputs[i]) continue;
/* Insert the RPF in the sorted RPFs array. */ for (j = pipe->num_inputs++; j > 0; --j) { if (rpf_zpos(vsp1, inputs[j-1]) <= rpf_zpos(vsp1, rpf)) break;
inputs[j] = inputs[j-1];
}
inputs[j] = rpf;
}
/* * Setup the BRx. This must be done before setting up the RPF input * pipelines as the BRx sink compose rectangles depend on the BRx source * format.
*/
ret = vsp1_du_pipeline_setup_brx(vsp1, pipe); if (ret < 0) {
dev_err(vsp1->dev, "%s: failed to setup %s source\n", __func__,
BRX_NAME(pipe->brx)); return ret;
}
brx = to_brx(&pipe->brx->subdev);
/* Setup the RPF input pipeline for every enabled input. */ for (i = 0; i < pipe->brx->source_pad; ++i) { struct vsp1_rwpf *rpf = inputs[i];
if (!rpf) {
brx->inputs[i].rpf = NULL; continue;
}
if (!rpf->entity.pipe) {
rpf->entity.pipe = pipe;
list_add(&rpf->entity.list_pipe, &pipe->entities);
}
dev_dbg(vsp1->dev, "%s: connecting RPF.%u to %s:%u\n",
__func__, rpf->entity.index, BRX_NAME(pipe->brx), i);
uif = drm_pipe->crc.source == VSP1_DU_CRC_PLANE &&
drm_pipe->crc.index == i ? drm_pipe->uif : NULL; if (uif)
use_uif = true;
ret = vsp1_du_pipeline_setup_rpf(vsp1, pipe, rpf, uif, i); if (ret < 0) {
dev_err(vsp1->dev, "%s: failed to setup RPF.%u\n",
__func__, rpf->entity.index); return ret;
}
}
/* Insert and configure the UIF at the BRx output if available. */
uif = drm_pipe->crc.source == VSP1_DU_CRC_OUTPUT ? drm_pipe->uif : NULL; if (uif)
use_uif = true;
ret = vsp1_du_insert_uif(vsp1, pipe, uif,
pipe->brx, pipe->brx->source_pad,
&pipe->output->entity, 0); if (ret < 0)
dev_err(vsp1->dev, "%s: failed to setup UIF after %s\n",
__func__, BRX_NAME(pipe->brx));
/* If the DRM pipe does not have a UIF there is nothing we can update. */ if (!drm_pipe->uif) return 0;
/* * If the UIF is not in use schedule it for removal by setting its pipe * pointer to NULL, vsp1_du_pipeline_configure() will remove it from the * hardware pipeline and from the pipeline's list of entities. Otherwise * make sure it is present in the pipeline's list of entities if it * wasn't already.
*/ if (!use_uif) {
drm_pipe->uif->pipe = NULL;
} elseif (!drm_pipe->uif->pipe) {
drm_pipe->uif->pipe = pipe;
list_add_tail(&drm_pipe->uif->list_pipe, &pipe->entities);
}
return 0;
}
/* Setup the output side of the pipeline (WPF and LIF). */ staticint vsp1_du_pipeline_setup_output(struct vsp1_device *vsp1, struct vsp1_pipeline *pipe)
{ struct vsp1_drm_pipeline *drm_pipe = to_vsp1_drm_pipeline(pipe); struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
}; int ret;
ret = v4l2_subdev_call(&pipe->output->entity.subdev, pad, set_fmt, NULL,
&format); if (ret < 0) return ret;
dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on WPF%u sink\n",
__func__, format.format.width, format.format.height,
format.format.code, pipe->output->entity.index);
format.pad = RWPF_PAD_SOURCE;
ret = v4l2_subdev_call(&pipe->output->entity.subdev, pad, get_fmt, NULL,
&format); if (ret < 0) return ret;
dev_dbg(vsp1->dev, "%s: got format %ux%u (%x) on WPF%u source\n",
__func__, format.format.width, format.format.height,
format.format.code, pipe->output->entity.index);
format.pad = LIF_PAD_SINK;
ret = v4l2_subdev_call(&pipe->lif->subdev, pad, set_fmt, NULL,
&format); if (ret < 0) return ret;
dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on LIF%u sink\n",
__func__, format.format.width, format.format.height,
format.format.code, pipe->lif->index);
/* * Verify that the format at the output of the pipeline matches the * requested frame size and media bus code.
*/ if (format.format.width != drm_pipe->width ||
format.format.height != drm_pipe->height ||
format.format.code != MEDIA_BUS_FMT_ARGB8888_1X32) {
dev_dbg(vsp1->dev, "%s: format mismatch on LIF%u\n", __func__,
pipe->lif->index); return -EPIPE;
}
fmtinfo = vsp1_get_format_info(vsp1, pixelformat); if (!fmtinfo) {
dev_dbg(vsp1->dev, "Unsupported pixel format %p4cc\n",
&pixelformat); return -EINVAL;
}
/* * Only formats with three planes can affect the chroma planes pitch. * All formats with two planes have a horizontal subsampling value of 2, * but combine U and V in a single chroma plane, which thus results in * the luma plane and chroma plane having the same pitch.
*/
chroma_hsub = (fmtinfo->planes == 3) ? fmtinfo->hsub : 1;
/* ----------------------------------------------------------------------------- * 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 * @pipe_index: the DRM pipeline index * @cfg: the LIF configuration * * Configure the output part of VSP DRM pipeline for the given frame @cfg.width * and @cfg.height. This sets up formats on the BRx source pad, the WPF sink and * source pads, and the LIF sink pad. * * The @pipe_index argument selects which DRM pipeline to setup. The number of * available pipelines depend on the VSP instance. * * As the media bus code on the blend unit source pad is conditioned by the * configuration of its sink 0 pad, we also set up the formats on all blend unit * sinks, even if the configuration will be overwritten later by * vsp1_du_setup_rpf(). This ensures that the blend unit 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, unsignedint pipe_index, conststruct vsp1_du_lif_config *cfg)
{ struct vsp1_device *vsp1 = dev_get_drvdata(dev); struct vsp1_drm_pipeline *drm_pipe; struct vsp1_pipeline *pipe; unsignedlong flags; unsignedint i; int ret;
if (pipe_index >= vsp1->info->lif_count) return -EINVAL;
/* * NULL configuration 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");
for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) { struct vsp1_rwpf *rpf = pipe->inputs[i];
if (!rpf) continue;
/* * Remove the RPF from the pipe and the list of BRx * inputs.
*/
WARN_ON(!rpf->entity.pipe);
rpf->entity.pipe = NULL;
list_del(&rpf->entity.list_pipe);
pipe->inputs[i] = NULL;
dev_dbg(vsp1->dev, "%s: configuring LIF%u with format %ux%u%s\n",
__func__, pipe_index, cfg->width, cfg->height,
pipe->interlaced ? "i" : "");
mutex_lock(&vsp1->drm->lock);
/* Setup formats through the pipeline. */
ret = vsp1_du_pipeline_setup_inputs(vsp1, pipe); if (ret < 0) goto unlock;
ret = vsp1_du_pipeline_setup_output(vsp1, pipe); if (ret < 0) goto unlock;
vsp1_pipeline_dump(pipe, "LIF setup");
/* Enable the VSP1. */
ret = vsp1_device_get(vsp1); if (ret < 0) goto unlock;
/* * Register a callback to allow us to notify the DRM driver of frame * completion events.
*/
drm_pipe->du_complete = cfg->callback;
drm_pipe->du_private = cfg->callback_data;
/** * vsp1_du_atomic_begin - Prepare for an atomic update * @dev: the VSP device * @pipe_index: the DRM pipeline index
*/ void vsp1_du_atomic_begin(struct device *dev, unsignedint pipe_index)
{
}
EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin);
/** * vsp1_du_atomic_update - Setup one RPF input of the VSP pipeline * @dev: the VSP device * @pipe_index: the DRM pipeline index * @rpf_index: index of the RPF to setup (0-based) * @cfg: the RPF configuration * * Configure the VSP to perform image composition through RPF @rpf_index as * described by the @cfg configuration. The image to compose is referenced by * @cfg.mem and composed using the @cfg.src crop rectangle and the @cfg.dst * composition rectangle. The Z-order is configurable with higher @zpos values * displayed on top. * * If the @cfg configuration is NULL, the RPF will be disabled. Calling the * function on a disabled RPF is allowed. * * Image format as stored in memory is expressed as a V4L2 @cfg.pixelformat * value. The memory pitch is configurable to allow for padding at end of lines, * or simply for images that extend beyond the crop rectangle boundaries. The * @cfg.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 @cfg.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. * * Return 0 on success or a negative error code on failure.
*/ int vsp1_du_atomic_update(struct device *dev, unsignedint pipe_index, unsignedint rpf_index, conststruct vsp1_du_atomic_config *cfg)
{ struct vsp1_device *vsp1 = dev_get_drvdata(dev); struct vsp1_drm_pipeline *drm_pipe = &vsp1->drm->pipe[pipe_index]; struct vsp1_drm_input *input; struct vsp1_rwpf *rpf; int ret;
if (rpf_index >= vsp1->info->rpf_count) return -EINVAL;
if (!cfg) {
dev_dbg(vsp1->dev, "%s: RPF%u: disable requested\n", __func__,
rpf_index);
/* * Remove the RPF from the pipeline's inputs. Keep it in the * pipeline's entity list to let vsp1_du_pipeline_configure() * remove it from the hardware pipeline.
*/
rpf->entity.pipe = NULL;
drm_pipe->pipe.inputs[rpf_index] = NULL; return 0;
}
/* * Store the format, stride, memory buffer address, crop and compose * rectangles and Z-order position and for the input.
*/
ret = vsp1_du_pipeline_set_rwpf_format(vsp1, rpf, cfg->pixelformat,
cfg->pitch); if (ret < 0) return ret;
/* * As all the buffers allocated by the DU driver are coherent, we can * skip cache sync. This will need to be revisited when support for * non-coherent buffers will be added to the DU driver.
*/ return dma_map_sgtable(vsp1->bus_master, sgt, DMA_TO_DEVICE,
DMA_ATTR_SKIP_CPU_SYNC);
}
EXPORT_SYMBOL_GPL(vsp1_du_map_sg);
/* * The output side of the DRM pipeline is static, add the * corresponding entities manually.
*/
pipe->output = vsp1->wpf[i];
pipe->lif = &vsp1->lif[i]->entity;
/* * CRC computation is initially disabled, don't add the UIF to * the pipeline.
*/ if (i < vsp1->info->uif_count)
drm_pipe->uif = &vsp1->uif[i]->entity;
}
/* Disable all RPFs initially. */ for (i = 0; i < vsp1->info->rpf_count; ++i) { struct vsp1_rwpf *input = vsp1->rpf[i];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.