aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2014-05-21 18:00:05 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-17 11:44:58 -0400
commit7578c204620c8e25ec6e4849cd12098f831a14d0 (patch)
tree78dfa097e02ff05ef85a1a36add415cee69f1242
parent7a52b6dea8e9559428149fbed0cddd587004006e (diff)
[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>
-rw-r--r--drivers/media/platform/vsp1/vsp1_rpf.c52
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.h2
-rw-r--r--drivers/media/platform/vsp1/vsp1_wpf.c54
3 files changed, 104 insertions, 4 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index 2824f5354f55..576779f2332b 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -39,6 +39,32 @@ static inline void vsp1_rpf_write(struct vsp1_rwpf *rpf, u32 reg, u32 data)
39} 39}
40 40
41/* ----------------------------------------------------------------------------- 41/* -----------------------------------------------------------------------------
42 * Controls
43 */
44
45static int rpf_s_ctrl(struct v4l2_ctrl *ctrl)
46{
47 struct vsp1_rwpf *rpf =
48 container_of(ctrl->handler, struct vsp1_rwpf, ctrls);
49
50 if (!vsp1_entity_is_streaming(&rpf->entity))
51 return 0;
52
53 switch (ctrl->id) {
54 case V4L2_CID_ALPHA_COMPONENT:
55 vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
56 ctrl->val << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
57 break;
58 }
59
60 return 0;
61}
62
63static const struct v4l2_ctrl_ops rpf_ctrl_ops = {
64 .s_ctrl = rpf_s_ctrl,
65};
66
67/* -----------------------------------------------------------------------------
42 * V4L2 Subdevice Core Operations 68 * V4L2 Subdevice Core Operations
43 */ 69 */
44 70
@@ -50,6 +76,11 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
50 const struct v4l2_rect *crop = &rpf->crop; 76 const struct v4l2_rect *crop = &rpf->crop;
51 u32 pstride; 77 u32 pstride;
52 u32 infmt; 78 u32 infmt;
79 int ret;
80
81 ret = vsp1_entity_set_streaming(&rpf->entity, enable);
82 if (ret < 0)
83 return ret;
53 84
54 if (!enable) 85 if (!enable)
55 return 0; 86 return 0;
@@ -101,14 +132,13 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
101 (rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) | 132 (rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) |
102 (rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT)); 133 (rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT));
103 134
104 /* Use the alpha channel (extended to 8 bits) when available or a 135 /* Use the alpha channel (extended to 8 bits) when available or an
105 * hardcoded 255 value otherwise. Disable color keying. 136 * alpha value set through the V4L2_CID_ALPHA_COMPONENT control
137 * otherwise. Disable color keying.
106 */ 138 */
107 vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT | 139 vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT |
108 (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED 140 (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED
109 : VI6_RPF_ALPH_SEL_ASEL_FIXED)); 141 : VI6_RPF_ALPH_SEL_ASEL_FIXED));
110 vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
111 255 << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
112 vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0); 142 vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0);
113 vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0); 143 vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0);
114 144
@@ -198,6 +228,20 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
198 228
199 vsp1_entity_init_formats(subdev, NULL); 229 vsp1_entity_init_formats(subdev, NULL);
200 230
231 /* Initialize the control handler. */
232 v4l2_ctrl_handler_init(&rpf->ctrls, 1);
233 v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT,
234 0, 255, 1, 255);
235
236 rpf->entity.subdev.ctrl_handler = &rpf->ctrls;
237
238 if (rpf->ctrls.error) {
239 dev_err(vsp1->dev, "rpf%u: failed to initialize controls\n",
240 index);
241 ret = rpf->ctrls.error;
242 goto error;
243 }
244
201 /* Initialize the video device. */ 245 /* Initialize the video device. */
202 video = &rpf->video; 246 video = &rpf->video;
203 247
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h
index b4fb65e58770..28dd9e7b3838 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -14,6 +14,7 @@
14#define __VSP1_RWPF_H__ 14#define __VSP1_RWPF_H__
15 15
16#include <media/media-entity.h> 16#include <media/media-entity.h>
17#include <media/v4l2-ctrls.h>
17#include <media/v4l2-subdev.h> 18#include <media/v4l2-subdev.h>
18 19
19#include "vsp1.h" 20#include "vsp1.h"
@@ -26,6 +27,7 @@
26struct vsp1_rwpf { 27struct vsp1_rwpf {
27 struct vsp1_entity entity; 28 struct vsp1_entity entity;
28 struct vsp1_video video; 29 struct vsp1_video video;
30 struct v4l2_ctrl_handler ctrls;
29 31
30 unsigned int max_width; 32 unsigned int max_width;
31 unsigned int max_height; 33 unsigned int max_height;
diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c
index a2ba10721f1b..6e057762c933 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -39,6 +39,35 @@ static inline void vsp1_wpf_write(struct vsp1_rwpf *wpf, u32 reg, u32 data)
39} 39}
40 40
41/* ----------------------------------------------------------------------------- 41/* -----------------------------------------------------------------------------
42 * Controls
43 */
44
45static int wpf_s_ctrl(struct v4l2_ctrl *ctrl)
46{
47 struct vsp1_rwpf *wpf =
48 container_of(ctrl->handler, struct vsp1_rwpf, ctrls);
49 u32 value;
50
51 if (!vsp1_entity_is_streaming(&wpf->entity))
52 return 0;
53
54 switch (ctrl->id) {
55 case V4L2_CID_ALPHA_COMPONENT:
56 value = vsp1_wpf_read(wpf, VI6_WPF_OUTFMT);
57 value &= ~VI6_WPF_OUTFMT_PDV_MASK;
58 value |= ctrl->val << VI6_WPF_OUTFMT_PDV_SHIFT;
59 vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, value);
60 break;
61 }
62
63 return 0;
64}
65
66static const struct v4l2_ctrl_ops wpf_ctrl_ops = {
67 .s_ctrl = wpf_s_ctrl,
68};
69
70/* -----------------------------------------------------------------------------
42 * V4L2 Subdevice Core Operations 71 * V4L2 Subdevice Core Operations
43 */ 72 */
44 73
@@ -51,6 +80,11 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
51 unsigned int i; 80 unsigned int i;
52 u32 srcrpf = 0; 81 u32 srcrpf = 0;
53 u32 outfmt = 0; 82 u32 outfmt = 0;
83 int ret;
84
85 ret = vsp1_entity_set_streaming(&wpf->entity, enable);
86 if (ret < 0)
87 return ret;
54 88
55 if (!enable) { 89 if (!enable) {
56 vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0); 90 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)
113 wpf->entity.formats[RWPF_PAD_SOURCE].code) 147 wpf->entity.formats[RWPF_PAD_SOURCE].code)
114 outfmt |= VI6_WPF_OUTFMT_CSC; 148 outfmt |= VI6_WPF_OUTFMT_CSC;
115 149
150 /* Take the control handler lock to ensure that the PDV value won't be
151 * changed behind our back by a set control operation.
152 */
153 mutex_lock(wpf->ctrls.lock);
154 outfmt |= vsp1_wpf_read(wpf, VI6_WPF_OUTFMT) & VI6_WPF_OUTFMT_PDV_MASK;
116 vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt); 155 vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt);
156 mutex_unlock(wpf->ctrls.lock);
117 157
118 vsp1_write(vsp1, VI6_DPR_WPF_FPORCH(wpf->entity.index), 158 vsp1_write(vsp1, VI6_DPR_WPF_FPORCH(wpf->entity.index),
119 VI6_DPR_WPF_FPORCH_FP_WPFN); 159 VI6_DPR_WPF_FPORCH_FP_WPFN);
@@ -209,6 +249,20 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
209 249
210 vsp1_entity_init_formats(subdev, NULL); 250 vsp1_entity_init_formats(subdev, NULL);
211 251
252 /* Initialize the control handler. */
253 v4l2_ctrl_handler_init(&wpf->ctrls, 1);
254 v4l2_ctrl_new_std(&wpf->ctrls, &wpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT,
255 0, 255, 1, 255);
256
257 wpf->entity.subdev.ctrl_handler = &wpf->ctrls;
258
259 if (wpf->ctrls.error) {
260 dev_err(vsp1->dev, "wpf%u: failed to initialize controls\n",
261 index);
262 ret = wpf->ctrls.error;
263 goto error;
264 }
265
212 /* Initialize the video device. */ 266 /* Initialize the video device. */
213 video = &wpf->video; 267 video = &wpf->video;
214 268