History

[media] v4l: vsp1: lut: Expose configuration through a control

Replace the custom ioctl with a V4L2 control in order to standardize the API.

Laurent Pinchart committed 10 years ago

Commit 42e89be1 parent 02209903 files · +54 −62Browse files

Unified · Split

3 files
  1. drivers/media/platform/vsp1/vsp1_lut.c +51 −25
  2. drivers/media/platform/vsp1/vsp1_lut.h +3 −3
  3. include/uapi/linux/vsp1.h +0 −34
drivers/media/platform/vsp1/vsp1_lut.c+51−25
@@ -13,7 +13,6 @@ · 12 unmodified lines
1313
1414 #include <linux/device.h>
1515 #include <linux/gfp.h>
16−#include <linux/vsp1.h>
1716
1817 #include <media/v4l2-subdev.h>
1918
@@ -35,43 +34,60 @@ static inline void vsp1_lut_write(struct vsp1_lut *lut, struct vsp1_dl_list *dl, · 15 unmodified lines
3534 }
3635
3736 /* -----------------------------------------------------------------------------
38− * V4L2 Subdevice Core Operations
37+ * Controls
3938 */
4039
41−static int lut_set_table(struct vsp1_lut *lut, struct vsp1_lut_config *config)
40+#define V4L2_CID_VSP1_LUT_TABLE (V4L2_CID_USER_BASE | 0x1001)
41+
42+static int lut_set_table(struct vsp1_lut *lut, struct v4l2_ctrl *ctrl)
4243 {
4344 struct vsp1_dl_body *dlb;
4445 unsigned int i;
4546
46− dlb = vsp1_dl_fragment_alloc(lut->entity.vsp1, ARRAY_SIZE(config->lut));
47+ dlb = vsp1_dl_fragment_alloc(lut->entity.vsp1, 256);
4748 if (!dlb)
4849 return -ENOMEM;
4950
50− for (i = 0; i < ARRAY_SIZE(config->lut); ++i)
51+ for (i = 0; i < 256; ++i)
5152 vsp1_dl_fragment_write(dlb, VI6_LUT_TABLE + 4 * i,
52− config->lut[i]);
53+ ctrl->p_new.p_u32[i]);
5354
54− mutex_lock(&lut->lock);
5555 swap(lut->lut, dlb);
56− mutex_unlock(&lut->lock);
5756
5857 vsp1_dl_fragment_free(dlb);
5958 return 0;
6059 }
6160
62−static long lut_ioctl(struct v4l2_subdev *subdev, unsigned int cmd, void *arg)
61+static int lut_s_ctrl(struct v4l2_ctrl *ctrl)
6362 {
64− struct vsp1_lut *lut = to_lut(subdev);
65−
66− switch (cmd) {
67− case VIDIOC_VSP1_LUT_CONFIG:
68− return lut_set_table(lut, arg);
63+ struct vsp1_lut *lut =
64+ container_of(ctrl->handler, struct vsp1_lut, ctrls);
6965
70− default:
71− return -ENOIOCTLCMD;
66+ switch (ctrl->id) {
67+ case V4L2_CID_VSP1_LUT_TABLE:
68+ lut_set_table(lut, ctrl);
69+ break;
7270 }
71+
72+ return 0;
7373 }
7474
75+static const struct v4l2_ctrl_ops lut_ctrl_ops = {
76+ .s_ctrl = lut_s_ctrl,
77+};
78+
79+static const struct v4l2_ctrl_config lut_table_control = {
80+ .ops = &lut_ctrl_ops,
81+ .id = V4L2_CID_VSP1_LUT_TABLE,
82+ .name = "Look-Up Table",
83+ .type = V4L2_CTRL_TYPE_U32,
84+ .min = 0x00000000,
85+ .max = 0x00ffffff,
86+ .step = 1,
87+ .def = 0,
88+ .dims = { 256},
89+};
90+
7591 /* -----------------------------------------------------------------------------
7692 * V4L2 Subdevice Pad Operations
7793 */
@@ -147,10 +163,6 @@ static int lut_set_format(struct v4l2_subdev *subdev, · 69 unmodified lines
147163 * V4L2 Subdevice Operations
148164 */
149165
150−static const struct v4l2_subdev_core_ops lut_core_ops = {
151− .ioctl = lut_ioctl,
152−};
153−
154166 static const struct v4l2_subdev_pad_ops lut_pad_ops = {
155167 .init_cfg = vsp1_entity_init_cfg,
156168 .enum_mbus_code = lut_enum_mbus_code,
@@ -160,7 +172,6 @@ static const struct v4l2_subdev_pad_ops lut_pad_ops = { · 3 unmodified lines
160172 };
161173
162174 static const struct v4l2_subdev_ops lut_ops = {
163− .core = &lut_core_ops,
164175 .pad = &lut_pad_ops,
165176 };
166177
@@ -176,12 +187,14 @@ static void lut_configure(struct vsp1_entity *entity, · 9 unmodified lines
176187
177188 vsp1_lut_write(lut, dl, VI6_LUT_CTRL, VI6_LUT_CTRL_EN);
178189
179− mutex_lock(&lut->lock);
190+ mutex_lock(lut->ctrls.lock);
191+
180192 if (lut->lut) {
181193 vsp1_dl_list_add_fragment(dl, lut->lut);
182194 lut->lut = NULL;
183195 }
184− mutex_unlock(&lut->lock);
196+
197+ mutex_unlock(lut->ctrls.lock);
185198 }
186199
187200 static const struct vsp1_entity_operations lut_entity_ops = {
@@ -201,8 +214,6 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1) · 13 unmodified lines
201214 if (lut == NULL)
202215 return ERR_PTR(-ENOMEM);
203216
204− mutex_init(&lut->lock);
205−
206217 lut->entity.ops = &lut_entity_ops;
207218 lut->entity.type = VSP1_ENTITY_LUT;
208219
@@ -211,5 +222,20 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1) · 2 unmodified lines
211222 if (ret < 0)
212223 return ERR_PTR(ret);
213224
225+ /* Initialize the control handler. */
226+ v4l2_ctrl_handler_init(&lut->ctrls, 1);
227+ v4l2_ctrl_new_custom(&lut->ctrls, &lut_table_control, NULL);
228+
229+ lut->entity.subdev.ctrl_handler = &lut->ctrls;
230+
231+ if (lut->ctrls.error) {
232+ dev_err(vsp1->dev, "lut: failed to initialize controls\n");
233+ ret = lut->ctrls.error;
234+ vsp1_entity_destroy(&lut->entity);
235+ return ERR_PTR(ret);
236+ }
237+
238+ v4l2_ctrl_handler_setup(&lut->ctrls);
239+
214240 return lut;
215241 }
drivers/media/platform/vsp1/vsp1_lut.h+3−3
@@ -13,9 +13,8 @@ · 12 unmodified lines
1313 #ifndef __VSP1_LUT_H__
1414 #define __VSP1_LUT_H__
1515
16−#include <linux/mutex.h>
17−
1816 #include <media/media-entity.h>
17+#include <media/v4l2-ctrls.h>
1918 #include <media/v4l2-subdev.h>
2019
2120 #include "vsp1_entity.h"
@@ -28,7 +27,8 @@ struct vsp1_device; · 6 unmodified lines
2827 struct vsp1_lut {
2928 struct vsp1_entity entity;
3029
31− struct mutex lock;
30+ struct v4l2_ctrl_handler ctrls;
31+
3232 struct vsp1_dl_body *lut;
3333 };
3434
include/uapi/linux/vsp1.h+0−34
@@ -1,34 +0,0 @@
1−/*
2− * vsp1.h
3− *
4− * Renesas R-Car VSP1 - User-space API
5− *
6− * Copyright (C) 2013 Renesas Corporation
7− *
8− * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
9− *
10− * This program is free software; you can redistribute it and/or modify
11− * it under the terms of the GNU General Public License version 2 as
12− * published by the Free Software Foundation.
13− */
14−
15−#ifndef __VSP1_USER_H__
16−#define __VSP1_USER_H__
17−
18−#include <linux/types.h>
19−#include <linux/videodev2.h>
20−
21−/*
22− * Private IOCTLs
23− *
24− * VIDIOC_VSP1_LUT_CONFIG - Configure the lookup table
25− */
26−
27−#define VIDIOC_VSP1_LUT_CONFIG \
28− _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct vsp1_lut_config)
29−
30−struct vsp1_lut_config {
31− __u32 lut[256];
32−};
33−
34−#endif /* __VSP1_USER_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t