[media] v4l: vsp1: Add V4L2_CID_ALPHA_COMPONENT control support
The control is used to configure the fixed alpha channel value, when reading from memory in the RPF or writing to memory in the WPF. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
7a52b6dea8
commit
7578c20462
|
@ -38,6 +38,32 @@ static inline void vsp1_rpf_write(struct vsp1_rwpf *rpf, u32 reg, u32 data)
|
||||||
reg + rpf->entity.index * VI6_RPF_OFFSET, data);
|
reg + rpf->entity.index * VI6_RPF_OFFSET, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Controls
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int rpf_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
|
{
|
||||||
|
struct vsp1_rwpf *rpf =
|
||||||
|
container_of(ctrl->handler, struct vsp1_rwpf, ctrls);
|
||||||
|
|
||||||
|
if (!vsp1_entity_is_streaming(&rpf->entity))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (ctrl->id) {
|
||||||
|
case V4L2_CID_ALPHA_COMPONENT:
|
||||||
|
vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
|
||||||
|
ctrl->val << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct v4l2_ctrl_ops rpf_ctrl_ops = {
|
||||||
|
.s_ctrl = rpf_s_ctrl,
|
||||||
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* V4L2 Subdevice Core Operations
|
* V4L2 Subdevice Core Operations
|
||||||
*/
|
*/
|
||||||
|
@ -50,6 +76,11 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
|
||||||
const struct v4l2_rect *crop = &rpf->crop;
|
const struct v4l2_rect *crop = &rpf->crop;
|
||||||
u32 pstride;
|
u32 pstride;
|
||||||
u32 infmt;
|
u32 infmt;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = vsp1_entity_set_streaming(&rpf->entity, enable);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (!enable)
|
if (!enable)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -101,14 +132,13 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
|
||||||
(rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) |
|
(rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) |
|
||||||
(rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT));
|
(rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT));
|
||||||
|
|
||||||
/* Use the alpha channel (extended to 8 bits) when available or a
|
/* Use the alpha channel (extended to 8 bits) when available or an
|
||||||
* hardcoded 255 value otherwise. Disable color keying.
|
* alpha value set through the V4L2_CID_ALPHA_COMPONENT control
|
||||||
|
* otherwise. Disable color keying.
|
||||||
*/
|
*/
|
||||||
vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT |
|
vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT |
|
||||||
(fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED
|
(fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED
|
||||||
: VI6_RPF_ALPH_SEL_ASEL_FIXED));
|
: VI6_RPF_ALPH_SEL_ASEL_FIXED));
|
||||||
vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
|
|
||||||
255 << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
|
|
||||||
vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0);
|
vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0);
|
||||||
vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0);
|
vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0);
|
||||||
|
|
||||||
|
@ -198,6 +228,20 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
|
||||||
|
|
||||||
vsp1_entity_init_formats(subdev, NULL);
|
vsp1_entity_init_formats(subdev, NULL);
|
||||||
|
|
||||||
|
/* Initialize the control handler. */
|
||||||
|
v4l2_ctrl_handler_init(&rpf->ctrls, 1);
|
||||||
|
v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT,
|
||||||
|
0, 255, 1, 255);
|
||||||
|
|
||||||
|
rpf->entity.subdev.ctrl_handler = &rpf->ctrls;
|
||||||
|
|
||||||
|
if (rpf->ctrls.error) {
|
||||||
|
dev_err(vsp1->dev, "rpf%u: failed to initialize controls\n",
|
||||||
|
index);
|
||||||
|
ret = rpf->ctrls.error;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the video device. */
|
/* Initialize the video device. */
|
||||||
video = &rpf->video;
|
video = &rpf->video;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#define __VSP1_RWPF_H__
|
#define __VSP1_RWPF_H__
|
||||||
|
|
||||||
#include <media/media-entity.h>
|
#include <media/media-entity.h>
|
||||||
|
#include <media/v4l2-ctrls.h>
|
||||||
#include <media/v4l2-subdev.h>
|
#include <media/v4l2-subdev.h>
|
||||||
|
|
||||||
#include "vsp1.h"
|
#include "vsp1.h"
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
struct vsp1_rwpf {
|
struct vsp1_rwpf {
|
||||||
struct vsp1_entity entity;
|
struct vsp1_entity entity;
|
||||||
struct vsp1_video video;
|
struct vsp1_video video;
|
||||||
|
struct v4l2_ctrl_handler ctrls;
|
||||||
|
|
||||||
unsigned int max_width;
|
unsigned int max_width;
|
||||||
unsigned int max_height;
|
unsigned int max_height;
|
||||||
|
|
|
@ -38,6 +38,35 @@ static inline void vsp1_wpf_write(struct vsp1_rwpf *wpf, u32 reg, u32 data)
|
||||||
reg + wpf->entity.index * VI6_WPF_OFFSET, data);
|
reg + wpf->entity.index * VI6_WPF_OFFSET, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Controls
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int wpf_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
|
{
|
||||||
|
struct vsp1_rwpf *wpf =
|
||||||
|
container_of(ctrl->handler, struct vsp1_rwpf, ctrls);
|
||||||
|
u32 value;
|
||||||
|
|
||||||
|
if (!vsp1_entity_is_streaming(&wpf->entity))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (ctrl->id) {
|
||||||
|
case V4L2_CID_ALPHA_COMPONENT:
|
||||||
|
value = vsp1_wpf_read(wpf, VI6_WPF_OUTFMT);
|
||||||
|
value &= ~VI6_WPF_OUTFMT_PDV_MASK;
|
||||||
|
value |= ctrl->val << VI6_WPF_OUTFMT_PDV_SHIFT;
|
||||||
|
vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct v4l2_ctrl_ops wpf_ctrl_ops = {
|
||||||
|
.s_ctrl = wpf_s_ctrl,
|
||||||
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* V4L2 Subdevice Core Operations
|
* V4L2 Subdevice Core Operations
|
||||||
*/
|
*/
|
||||||
|
@ -51,6 +80,11 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
u32 srcrpf = 0;
|
u32 srcrpf = 0;
|
||||||
u32 outfmt = 0;
|
u32 outfmt = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = vsp1_entity_set_streaming(&wpf->entity, enable);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0);
|
vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0);
|
||||||
|
@ -113,7 +147,13 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
|
||||||
wpf->entity.formats[RWPF_PAD_SOURCE].code)
|
wpf->entity.formats[RWPF_PAD_SOURCE].code)
|
||||||
outfmt |= VI6_WPF_OUTFMT_CSC;
|
outfmt |= VI6_WPF_OUTFMT_CSC;
|
||||||
|
|
||||||
|
/* Take the control handler lock to ensure that the PDV value won't be
|
||||||
|
* changed behind our back by a set control operation.
|
||||||
|
*/
|
||||||
|
mutex_lock(wpf->ctrls.lock);
|
||||||
|
outfmt |= vsp1_wpf_read(wpf, VI6_WPF_OUTFMT) & VI6_WPF_OUTFMT_PDV_MASK;
|
||||||
vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt);
|
vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt);
|
||||||
|
mutex_unlock(wpf->ctrls.lock);
|
||||||
|
|
||||||
vsp1_write(vsp1, VI6_DPR_WPF_FPORCH(wpf->entity.index),
|
vsp1_write(vsp1, VI6_DPR_WPF_FPORCH(wpf->entity.index),
|
||||||
VI6_DPR_WPF_FPORCH_FP_WPFN);
|
VI6_DPR_WPF_FPORCH_FP_WPFN);
|
||||||
|
@ -209,6 +249,20 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
|
||||||
|
|
||||||
vsp1_entity_init_formats(subdev, NULL);
|
vsp1_entity_init_formats(subdev, NULL);
|
||||||
|
|
||||||
|
/* Initialize the control handler. */
|
||||||
|
v4l2_ctrl_handler_init(&wpf->ctrls, 1);
|
||||||
|
v4l2_ctrl_new_std(&wpf->ctrls, &wpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT,
|
||||||
|
0, 255, 1, 255);
|
||||||
|
|
||||||
|
wpf->entity.subdev.ctrl_handler = &wpf->ctrls;
|
||||||
|
|
||||||
|
if (wpf->ctrls.error) {
|
||||||
|
dev_err(vsp1->dev, "wpf%u: failed to initialize controls\n",
|
||||||
|
index);
|
||||||
|
ret = wpf->ctrls.error;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the video device. */
|
/* Initialize the video device. */
|
||||||
video = &wpf->video;
|
video = &wpf->video;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue