2013-06-04 14:22:30 +00:00
|
|
|
/*
|
|
|
|
* vsp1_wpf.c -- R-Car VSP1 Write Pixel Formatter
|
|
|
|
*
|
2014-02-06 17:42:31 +00:00
|
|
|
* Copyright (C) 2013-2014 Renesas Electronics Corporation
|
2013-06-04 14:22:30 +00:00
|
|
|
*
|
|
|
|
* 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 <media/v4l2-subdev.h>
|
|
|
|
|
|
|
|
#include "vsp1.h"
|
2015-11-15 00:27:52 +00:00
|
|
|
#include "vsp1_dl.h"
|
2016-01-17 21:53:56 +00:00
|
|
|
#include "vsp1_pipe.h"
|
2013-06-04 14:22:30 +00:00
|
|
|
#include "vsp1_rwpf.h"
|
|
|
|
#include "vsp1_video.h"
|
|
|
|
|
2016-03-25 09:51:06 +00:00
|
|
|
#define WPF_GEN2_MAX_WIDTH 2048U
|
|
|
|
#define WPF_GEN2_MAX_HEIGHT 2048U
|
|
|
|
#define WPF_GEN3_MAX_WIDTH 8190U
|
|
|
|
#define WPF_GEN3_MAX_HEIGHT 8190U
|
2013-06-04 14:22:30 +00:00
|
|
|
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Device Access
|
|
|
|
*/
|
|
|
|
|
2015-11-22 22:29:25 +00:00
|
|
|
static inline void vsp1_wpf_write(struct vsp1_rwpf *wpf,
|
|
|
|
struct vsp1_dl_list *dl, u32 reg, u32 data)
|
2013-06-04 14:22:30 +00:00
|
|
|
{
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_dl_list_write(dl, reg + wpf->entity.index * VI6_WPF_OFFSET, data);
|
2013-06-04 14:22:30 +00:00
|
|
|
}
|
|
|
|
|
2016-05-26 08:14:22 +00:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Controls
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum wpf_flip_ctrl {
|
|
|
|
WPF_CTRL_VFLIP = 0,
|
|
|
|
WPF_CTRL_HFLIP = 1,
|
|
|
|
WPF_CTRL_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int vsp1_wpf_s_ctrl(struct v4l2_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
struct vsp1_rwpf *wpf =
|
|
|
|
container_of(ctrl->handler, struct vsp1_rwpf, ctrls);
|
|
|
|
unsigned int i;
|
|
|
|
u32 flip = 0;
|
|
|
|
|
|
|
|
switch (ctrl->id) {
|
|
|
|
case V4L2_CID_HFLIP:
|
|
|
|
case V4L2_CID_VFLIP:
|
|
|
|
for (i = 0; i < WPF_CTRL_MAX; ++i) {
|
|
|
|
if (wpf->flip.ctrls[i])
|
|
|
|
flip |= wpf->flip.ctrls[i]->val ? BIT(i) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irq(&wpf->flip.lock);
|
|
|
|
wpf->flip.pending = flip;
|
|
|
|
spin_unlock_irq(&wpf->flip.lock);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_ops vsp1_wpf_ctrl_ops = {
|
|
|
|
.s_ctrl = vsp1_wpf_s_ctrl,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int wpf_init_controls(struct vsp1_rwpf *wpf)
|
|
|
|
{
|
|
|
|
struct vsp1_device *vsp1 = wpf->entity.vsp1;
|
|
|
|
unsigned int num_flip_ctrls;
|
|
|
|
|
|
|
|
spin_lock_init(&wpf->flip.lock);
|
|
|
|
|
|
|
|
if (wpf->entity.index != 0) {
|
|
|
|
/* Only WPF0 supports flipping. */
|
|
|
|
num_flip_ctrls = 0;
|
|
|
|
} else if (vsp1->info->features & VSP1_HAS_WPF_HFLIP) {
|
|
|
|
/* When horizontal flip is supported the WPF implements two
|
|
|
|
* controls (horizontal flip and vertical flip).
|
|
|
|
*/
|
|
|
|
num_flip_ctrls = 2;
|
|
|
|
} else if (vsp1->info->features & VSP1_HAS_WPF_VFLIP) {
|
|
|
|
/* When only vertical flip is supported the WPF implements a
|
|
|
|
* single control (vertical flip).
|
|
|
|
*/
|
|
|
|
num_flip_ctrls = 1;
|
|
|
|
} else {
|
|
|
|
/* Otherwise flipping is not supported. */
|
|
|
|
num_flip_ctrls = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
vsp1_rwpf_init_ctrls(wpf, num_flip_ctrls);
|
|
|
|
|
|
|
|
if (num_flip_ctrls >= 1) {
|
|
|
|
wpf->flip.ctrls[WPF_CTRL_VFLIP] =
|
|
|
|
v4l2_ctrl_new_std(&wpf->ctrls, &vsp1_wpf_ctrl_ops,
|
|
|
|
V4L2_CID_VFLIP, 0, 1, 1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_flip_ctrls == 2) {
|
|
|
|
wpf->flip.ctrls[WPF_CTRL_HFLIP] =
|
|
|
|
v4l2_ctrl_new_std(&wpf->ctrls, &vsp1_wpf_ctrl_ops,
|
|
|
|
V4L2_CID_HFLIP, 0, 1, 1, 0);
|
|
|
|
|
|
|
|
v4l2_ctrl_cluster(2, wpf->flip.ctrls);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wpf->ctrls.error) {
|
|
|
|
dev_err(vsp1->dev, "wpf%u: failed to initialize controls\n",
|
|
|
|
wpf->entity.index);
|
|
|
|
return wpf->ctrls.error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-04 14:22:30 +00:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* V4L2 Subdevice Core Operations
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
|
|
|
|
{
|
|
|
|
struct vsp1_rwpf *wpf = to_rwpf(subdev);
|
|
|
|
struct vsp1_device *vsp1 = wpf->entity.vsp1;
|
2014-05-21 22:00:05 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
if (enable)
|
2013-06-04 14:22:30 +00:00
|
|
|
return 0;
|
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
/* Write to registers directly when stopping the stream as there will be
|
|
|
|
* no pipeline run to apply the display list.
|
2013-07-10 21:03:46 +00:00
|
|
|
*/
|
2015-11-17 15:10:26 +00:00
|
|
|
vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0);
|
|
|
|
vsp1_write(vsp1, wpf->entity.index * VI6_WPF_OFFSET +
|
|
|
|
VI6_WPF_SRCRPF, 0);
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-08-05 19:40:31 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* V4L2 Subdevice Operations
|
|
|
|
*/
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2016-06-18 00:11:26 +00:00
|
|
|
static const struct v4l2_subdev_video_ops wpf_video_ops = {
|
2015-11-17 15:10:26 +00:00
|
|
|
.s_stream = wpf_s_stream,
|
|
|
|
};
|
2013-07-10 21:03:46 +00:00
|
|
|
|
2016-06-18 00:11:26 +00:00
|
|
|
static const struct v4l2_subdev_ops wpf_ops = {
|
2015-11-17 15:10:26 +00:00
|
|
|
.video = &wpf_video_ops,
|
2015-11-22 15:37:45 +00:00
|
|
|
.pad = &vsp1_rwpf_pad_ops,
|
2015-11-17 15:10:26 +00:00
|
|
|
};
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* VSP1 Entity Operations
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void vsp1_wpf_destroy(struct vsp1_entity *entity)
|
|
|
|
{
|
|
|
|
struct vsp1_rwpf *wpf = entity_to_rwpf(entity);
|
|
|
|
|
|
|
|
vsp1_dlm_destroy(wpf->dlm);
|
|
|
|
}
|
|
|
|
|
2016-01-14 16:17:32 +00:00
|
|
|
static void wpf_configure(struct vsp1_entity *entity,
|
|
|
|
struct vsp1_pipeline *pipe,
|
2016-09-11 22:39:30 +00:00
|
|
|
struct vsp1_dl_list *dl,
|
|
|
|
enum vsp1_entity_params params)
|
2015-11-17 15:10:26 +00:00
|
|
|
{
|
|
|
|
struct vsp1_rwpf *wpf = to_rwpf(&entity->subdev);
|
|
|
|
struct vsp1_device *vsp1 = wpf->entity.vsp1;
|
|
|
|
const struct v4l2_mbus_framefmt *source_format;
|
|
|
|
const struct v4l2_mbus_framefmt *sink_format;
|
|
|
|
unsigned int i;
|
|
|
|
u32 outfmt = 0;
|
|
|
|
u32 srcrpf = 0;
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2016-09-11 22:39:30 +00:00
|
|
|
if (params == VSP1_ENTITY_PARAMS_RUNTIME) {
|
2016-05-26 08:14:22 +00:00
|
|
|
const unsigned int mask = BIT(WPF_CTRL_VFLIP)
|
|
|
|
| BIT(WPF_CTRL_HFLIP);
|
2016-09-13 23:19:29 +00:00
|
|
|
unsigned long flags;
|
2016-05-26 08:14:22 +00:00
|
|
|
|
2016-09-13 23:19:29 +00:00
|
|
|
spin_lock_irqsave(&wpf->flip.lock, flags);
|
2016-05-26 08:14:22 +00:00
|
|
|
wpf->flip.active = (wpf->flip.active & ~mask)
|
|
|
|
| (wpf->flip.pending & mask);
|
2016-09-13 23:19:29 +00:00
|
|
|
spin_unlock_irqrestore(&wpf->flip.lock, flags);
|
2016-05-26 08:14:22 +00:00
|
|
|
|
|
|
|
outfmt = (wpf->alpha << VI6_WPF_OUTFMT_PDV_SHIFT) | wpf->outfmt;
|
|
|
|
|
|
|
|
if (wpf->flip.active & BIT(WPF_CTRL_VFLIP))
|
|
|
|
outfmt |= VI6_WPF_OUTFMT_FLP;
|
|
|
|
if (wpf->flip.active & BIT(WPF_CTRL_HFLIP))
|
|
|
|
outfmt |= VI6_WPF_OUTFMT_HFLP;
|
|
|
|
|
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_OUTFMT, outfmt);
|
2016-06-11 07:07:56 +00:00
|
|
|
return;
|
2016-06-20 08:04:38 +00:00
|
|
|
}
|
2016-06-11 07:07:56 +00:00
|
|
|
|
2015-11-15 21:14:22 +00:00
|
|
|
sink_format = vsp1_entity_get_pad_format(&wpf->entity,
|
|
|
|
wpf->entity.config,
|
|
|
|
RWPF_PAD_SINK);
|
|
|
|
source_format = vsp1_entity_get_pad_format(&wpf->entity,
|
|
|
|
wpf->entity.config,
|
|
|
|
RWPF_PAD_SOURCE);
|
|
|
|
|
2016-09-12 12:50:13 +00:00
|
|
|
if (params == VSP1_ENTITY_PARAMS_PARTITION) {
|
|
|
|
const struct v4l2_pix_format_mplane *format = &wpf->format;
|
2017-02-12 22:58:20 +00:00
|
|
|
const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;
|
2016-09-12 12:50:13 +00:00
|
|
|
struct vsp1_rwpf_memory mem = wpf->mem;
|
|
|
|
unsigned int flip = wpf->flip.active;
|
|
|
|
unsigned int width = source_format->width;
|
|
|
|
unsigned int height = source_format->height;
|
|
|
|
unsigned int offset;
|
|
|
|
|
2016-09-19 18:18:01 +00:00
|
|
|
/*
|
|
|
|
* Cropping. The partition algorithm can split the image into
|
2016-09-12 12:50:13 +00:00
|
|
|
* multiple slices.
|
|
|
|
*/
|
2016-09-12 02:26:35 +00:00
|
|
|
if (pipe->partitions > 1)
|
|
|
|
width = pipe->partition.width;
|
|
|
|
|
2016-09-12 12:50:13 +00:00
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN |
|
|
|
|
(0 << VI6_WPF_SZCLIP_OFST_SHIFT) |
|
|
|
|
(width << VI6_WPF_SZCLIP_SIZE_SHIFT));
|
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_VSZCLIP, VI6_WPF_SZCLIP_EN |
|
|
|
|
(0 << VI6_WPF_SZCLIP_OFST_SHIFT) |
|
|
|
|
(height << VI6_WPF_SZCLIP_SIZE_SHIFT));
|
|
|
|
|
|
|
|
if (pipe->lif)
|
|
|
|
return;
|
|
|
|
|
2016-09-19 18:18:01 +00:00
|
|
|
/*
|
|
|
|
* Update the memory offsets based on flipping configuration.
|
2016-09-12 12:50:13 +00:00
|
|
|
* The destination addresses point to the locations where the
|
|
|
|
* VSP starts writing to memory, which can be different corners
|
2016-09-12 02:26:35 +00:00
|
|
|
* of the image depending on vertical flipping.
|
2016-09-12 12:50:13 +00:00
|
|
|
*/
|
2016-09-12 02:26:35 +00:00
|
|
|
if (pipe->partitions > 1) {
|
|
|
|
const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;
|
|
|
|
|
2016-09-19 18:18:01 +00:00
|
|
|
/*
|
|
|
|
* Horizontal flipping is handled through a line buffer
|
2016-09-12 02:26:35 +00:00
|
|
|
* and doesn't modify the start address, but still needs
|
|
|
|
* to be handled when image partitioning is in effect to
|
|
|
|
* order the partitions correctly.
|
|
|
|
*/
|
|
|
|
if (flip & BIT(WPF_CTRL_HFLIP))
|
|
|
|
offset = format->width - pipe->partition.left
|
|
|
|
- pipe->partition.width;
|
|
|
|
else
|
|
|
|
offset = pipe->partition.left;
|
|
|
|
|
|
|
|
mem.addr[0] += offset * fmtinfo->bpp[0] / 8;
|
|
|
|
if (format->num_planes > 1) {
|
|
|
|
mem.addr[1] += offset / fmtinfo->hsub
|
|
|
|
* fmtinfo->bpp[1] / 8;
|
|
|
|
mem.addr[2] += offset / fmtinfo->hsub
|
|
|
|
* fmtinfo->bpp[2] / 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-12 12:50:13 +00:00
|
|
|
if (flip & BIT(WPF_CTRL_VFLIP)) {
|
|
|
|
mem.addr[0] += (format->height - 1)
|
|
|
|
* format->plane_fmt[0].bytesperline;
|
|
|
|
|
|
|
|
if (format->num_planes > 1) {
|
|
|
|
offset = (format->height / wpf->fmtinfo->vsub - 1)
|
|
|
|
* format->plane_fmt[1].bytesperline;
|
|
|
|
mem.addr[1] += offset;
|
|
|
|
mem.addr[2] += offset;
|
|
|
|
}
|
|
|
|
}
|
2016-09-12 01:41:06 +00:00
|
|
|
|
2017-02-12 22:58:20 +00:00
|
|
|
/*
|
|
|
|
* On Gen3 hardware the SPUVS bit has no effect on 3-planar
|
|
|
|
* formats. Swap the U and V planes manually in that case.
|
|
|
|
*/
|
|
|
|
if (vsp1->info->gen == 3 && format->num_planes == 3 &&
|
|
|
|
fmtinfo->swap_uv)
|
|
|
|
swap(mem.addr[1], mem.addr[2]);
|
|
|
|
|
2016-09-12 12:50:13 +00:00
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_Y, mem.addr[0]);
|
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C0, mem.addr[1]);
|
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_ADDR_C1, mem.addr[2]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Format */
|
2013-06-04 14:22:30 +00:00
|
|
|
if (!pipe->lif) {
|
2015-11-17 15:10:26 +00:00
|
|
|
const struct v4l2_pix_format_mplane *format = &wpf->format;
|
2015-07-28 17:00:43 +00:00
|
|
|
const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;
|
2013-06-04 14:22:30 +00:00
|
|
|
|
|
|
|
outfmt = fmtinfo->hwfmt << VI6_WPF_OUTFMT_WRFMT_SHIFT;
|
|
|
|
|
2014-05-26 23:12:53 +00:00
|
|
|
if (fmtinfo->alpha)
|
|
|
|
outfmt |= VI6_WPF_OUTFMT_PXA;
|
2013-06-04 14:22:30 +00:00
|
|
|
if (fmtinfo->swap_yc)
|
|
|
|
outfmt |= VI6_WPF_OUTFMT_SPYCS;
|
|
|
|
if (fmtinfo->swap_uv)
|
|
|
|
outfmt |= VI6_WPF_OUTFMT_SPUVS;
|
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
/* Destination stride and byte swapping. */
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_STRIDE_Y,
|
2015-11-17 15:10:26 +00:00
|
|
|
format->plane_fmt[0].bytesperline);
|
|
|
|
if (format->num_planes > 1)
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_DSTM_STRIDE_C,
|
2015-11-17 15:10:26 +00:00
|
|
|
format->plane_fmt[1].bytesperline);
|
|
|
|
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_DSWAP, fmtinfo->swap);
|
2016-05-26 08:14:22 +00:00
|
|
|
|
|
|
|
if (vsp1->info->features & VSP1_HAS_WPF_HFLIP &&
|
|
|
|
wpf->entity.index == 0)
|
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_ROT_CTRL,
|
|
|
|
VI6_WPF_ROT_CTRL_LN16 |
|
|
|
|
(256 << VI6_WPF_ROT_CTRL_LMEM_WD_SHIFT));
|
2013-06-04 14:22:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-15 21:14:22 +00:00
|
|
|
if (sink_format->code != source_format->code)
|
2013-06-04 14:22:30 +00:00
|
|
|
outfmt |= VI6_WPF_OUTFMT_CSC;
|
|
|
|
|
2016-06-20 08:04:38 +00:00
|
|
|
wpf->outfmt = outfmt;
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_dl_list_write(dl, VI6_DPR_WPF_FPORCH(wpf->entity.index),
|
|
|
|
VI6_DPR_WPF_FPORCH_FP_WPFN);
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_dl_list_write(dl, VI6_WPF_WRBCK_CTRL, 0);
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
/* Sources. If the pipeline has a single input and BRU is not used,
|
|
|
|
* configure it as the master layer. Otherwise configure all
|
|
|
|
* inputs as sub-layers and select the virtual RPF as the master
|
|
|
|
* layer.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < vsp1->info->rpf_count; ++i) {
|
|
|
|
struct vsp1_rwpf *input = pipe->inputs[i];
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
if (!input)
|
|
|
|
continue;
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
srcrpf |= (!pipe->bru && pipe->num_inputs == 1)
|
|
|
|
? VI6_WPF_SRCRPF_RPF_ACT_MST(input->entity.index)
|
|
|
|
: VI6_WPF_SRCRPF_RPF_ACT_SUB(input->entity.index);
|
|
|
|
}
|
2015-11-17 14:23:23 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
if (pipe->bru || pipe->num_inputs > 1)
|
|
|
|
srcrpf |= VI6_WPF_SRCRPF_VIRACT_MST;
|
2015-11-17 14:23:23 +00:00
|
|
|
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_wpf_write(wpf, dl, VI6_WPF_SRCRPF, srcrpf);
|
2015-11-17 14:23:23 +00:00
|
|
|
|
2015-11-17 15:10:26 +00:00
|
|
|
/* Enable interrupts */
|
2015-11-22 22:29:25 +00:00
|
|
|
vsp1_dl_list_write(dl, VI6_WPF_IRQ_STA(wpf->entity.index), 0);
|
|
|
|
vsp1_dl_list_write(dl, VI6_WPF_IRQ_ENB(wpf->entity.index),
|
2016-09-06 09:55:02 +00:00
|
|
|
VI6_WFP_IRQ_ENB_DFEE);
|
2013-06-04 14:22:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 14:23:23 +00:00
|
|
|
static const struct vsp1_entity_operations wpf_entity_ops = {
|
|
|
|
.destroy = vsp1_wpf_destroy,
|
2015-11-17 15:10:26 +00:00
|
|
|
.configure = wpf_configure,
|
2013-06-04 14:22:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
* Initialization and Cleanup
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
|
|
|
|
{
|
|
|
|
struct vsp1_rwpf *wpf;
|
2015-11-15 21:42:01 +00:00
|
|
|
char name[6];
|
2013-06-04 14:22:30 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
wpf = devm_kzalloc(vsp1->dev, sizeof(*wpf), GFP_KERNEL);
|
|
|
|
if (wpf == NULL)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
2016-03-25 09:51:06 +00:00
|
|
|
if (vsp1->info->gen == 2) {
|
|
|
|
wpf->max_width = WPF_GEN2_MAX_WIDTH;
|
|
|
|
wpf->max_height = WPF_GEN2_MAX_HEIGHT;
|
|
|
|
} else {
|
|
|
|
wpf->max_width = WPF_GEN3_MAX_WIDTH;
|
|
|
|
wpf->max_height = WPF_GEN3_MAX_HEIGHT;
|
|
|
|
}
|
2013-06-04 14:22:30 +00:00
|
|
|
|
2015-11-17 14:23:23 +00:00
|
|
|
wpf->entity.ops = &wpf_entity_ops;
|
2013-06-04 14:22:30 +00:00
|
|
|
wpf->entity.type = VSP1_ENTITY_WPF;
|
|
|
|
wpf->entity.index = index;
|
|
|
|
|
2015-11-15 21:42:01 +00:00
|
|
|
sprintf(name, "wpf.%u", index);
|
2016-02-16 00:10:26 +00:00
|
|
|
ret = vsp1_entity_init(vsp1, &wpf->entity, name, 2, &wpf_ops,
|
|
|
|
MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER);
|
2013-06-04 14:22:30 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
|
2015-11-01 17:18:56 +00:00
|
|
|
/* Initialize the display list manager. */
|
2016-07-12 16:49:46 +00:00
|
|
|
wpf->dlm = vsp1_dlm_create(vsp1, index, 64);
|
2015-11-01 17:18:56 +00:00
|
|
|
if (!wpf->dlm) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto error;
|
2015-11-15 00:27:52 +00:00
|
|
|
}
|
|
|
|
|
2014-05-21 22:00:05 +00:00
|
|
|
/* Initialize the control handler. */
|
2016-05-26 08:14:22 +00:00
|
|
|
ret = wpf_init_controls(wpf);
|
2015-11-01 14:19:42 +00:00
|
|
|
if (ret < 0) {
|
2014-05-21 22:00:05 +00:00
|
|
|
dev_err(vsp1->dev, "wpf%u: failed to initialize controls\n",
|
|
|
|
index);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2016-06-20 08:04:38 +00:00
|
|
|
v4l2_ctrl_handler_setup(&wpf->ctrls);
|
|
|
|
|
2013-06-04 14:22:30 +00:00
|
|
|
return wpf;
|
|
|
|
|
2014-05-28 15:49:13 +00:00
|
|
|
error:
|
|
|
|
vsp1_entity_destroy(&wpf->entity);
|
2013-06-04 14:22:30 +00:00
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|