Commit 0996517c authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB: v4l2: Add new control handling framework

Add a new framework to handle controls which makes life for driver
developers much easier.

Note that this patch moves some of the control support that used to be in
v4l2-common.c to v4l2-ctrls.c. The tables were copied unchanged. The body
of v4l2_ctrl_query_fill() was copied to a new v4l2_ctrl_fill() function
in v4l2-ctrls.c. This new function doesn't use the v4l2_queryctrl
struct anymore, which makes it more general.

The remainder of v4l2-ctrls.c is all new. Highlights include:

- No need to implement VIDIOC_QUERYCTRL, QUERYMENU, S_CTRL, G_CTRL,
  S_EXT_CTRLS, G_EXT_CTRLS or TRY_EXT_CTRLS in either bridge drivers
  or subdevs. New wrapper functions are provided that can just be plugged in.
  Once everything has been converted these wrapper functions can be removed as well.

- When subdevices are added their controls can be automatically merged
  with the bridge driver's controls.

- Most drivers just need to implement s_ctrl to set the controls.
  The framework handles the locking and tries to be as 'atomic' as possible.

- Ready for the subdev device nodes: the same mechanism applies to subdevs
  and their device nodes as well. Sub-device drivers can make controls
  local, preventing them from being merged with bridge drivers.

- Takes care of backwards compatibility handling of VIDIOC_S_CTRL and
  VIDIOC_G_CTRL. Handling of V4L2_CID_PRIVATE_BASE is fully transparent.
  CTRL_CLASS controls are automatically added.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 03e30ca5
...@@ -11,7 +11,7 @@ stkwebcam-objs := stk-webcam.o stk-sensor.o ...@@ -11,7 +11,7 @@ stkwebcam-objs := stk-webcam.o stk-sensor.o
omap2cam-objs := omap24xxcam.o omap24xxcam-dma.o omap2cam-objs := omap24xxcam.o omap24xxcam-dma.o
videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \ videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
v4l2-event.o v4l2-event.o v4l2-ctrls.o
# V4L2 core modules # V4L2 core modules
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
struct v4l2_ioctl_callbacks; struct v4l2_ioctl_callbacks;
struct video_device; struct video_device;
struct v4l2_device; struct v4l2_device;
struct v4l2_ctrl_handler;
/* Flag to mark the video_device struct as registered. /* Flag to mark the video_device struct as registered.
Drivers can clear this flag if they want to block all future Drivers can clear this flag if they want to block all future
...@@ -67,6 +68,9 @@ struct video_device ...@@ -67,6 +68,9 @@ struct video_device
struct device *parent; /* device parent */ struct device *parent; /* device parent */
struct v4l2_device *v4l2_dev; /* v4l2_device parent */ struct v4l2_device *v4l2_dev; /* v4l2_device parent */
/* Control handler associated with this device node. May be NULL. */
struct v4l2_ctrl_handler *ctrl_handler;
/* device info */ /* device info */
char name[32]; char name[32];
int vfl_type; int vfl_type;
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#define V4L2_DEVICE_NAME_SIZE (20 + 16) #define V4L2_DEVICE_NAME_SIZE (20 + 16)
struct v4l2_ctrl_handler;
struct v4l2_device { struct v4l2_device {
/* dev->driver_data points to this struct. /* dev->driver_data points to this struct.
Note: dev might be NULL if there is no parent device Note: dev might be NULL if there is no parent device
...@@ -47,6 +49,8 @@ struct v4l2_device { ...@@ -47,6 +49,8 @@ struct v4l2_device {
/* notify callback called by some sub-devices. */ /* notify callback called by some sub-devices. */
void (*notify)(struct v4l2_subdev *sd, void (*notify)(struct v4l2_subdev *sd,
unsigned int notification, void *arg); unsigned int notification, void *arg);
/* The control handler. May be NULL. */
struct v4l2_ctrl_handler *ctrl_handler;
}; };
/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev. /* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x00000001 #define V4L2_SUBDEV_IR_TX_FIFO_SERVICE_REQ 0x00000001
struct v4l2_device; struct v4l2_device;
struct v4l2_ctrl_handler;
struct v4l2_subdev; struct v4l2_subdev;
struct tuner_setup; struct tuner_setup;
...@@ -434,6 +435,8 @@ struct v4l2_subdev { ...@@ -434,6 +435,8 @@ struct v4l2_subdev {
u32 flags; u32 flags;
struct v4l2_device *v4l2_dev; struct v4l2_device *v4l2_dev;
const struct v4l2_subdev_ops *ops; const struct v4l2_subdev_ops *ops;
/* The control handler of this subdev. May be NULL. */
struct v4l2_ctrl_handler *ctrl_handler;
/* name must be unique */ /* name must be unique */
char name[V4L2_SUBDEV_NAME_SIZE]; char name[V4L2_SUBDEV_NAME_SIZE];
/* can be used to group similar subdevs, value is driver-specific */ /* can be used to group similar subdevs, value is driver-specific */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment