media: v4l2: import HTC v4l2 stack
HTC kernel version: villeu-jb-crc-3.4.10-ae8b65e
Change-Id: Ib3cf788a9931b4efa68380ff6adf6ea6359a9ef9
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 7395c81..51a1c2d 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -24,27 +24,23 @@
#ifndef V4L2_CHIP_IDENT_H_
#define V4L2_CHIP_IDENT_H_
-/* VIDIOC_DBG_G_CHIP_IDENT: identifies the actual chip installed on the board */
-/* KEEP THIS LIST ORDERED BY ID!
- Otherwise it will be hard to see which ranges are already in use when
- adding support to a new chip family. */
enum {
- /* general idents: reserved range 0-49 */
- V4L2_IDENT_NONE = 0, /* No chip matched */
- V4L2_IDENT_AMBIGUOUS = 1, /* Match too general, multiple chips matched */
- V4L2_IDENT_UNKNOWN = 2, /* Chip found, but cannot identify */
+
+ V4L2_IDENT_NONE = 0,
+ V4L2_IDENT_AMBIGUOUS = 1,
+ V4L2_IDENT_UNKNOWN = 2,
- /* module tvaudio: reserved range 50-99 */
- V4L2_IDENT_TVAUDIO = 50, /* A tvaudio chip, unknown which it is exactly */
+
+ V4L2_IDENT_TVAUDIO = 50,
- /* Sony IMX074 */
+
V4L2_IDENT_IMX074 = 74,
- /* module saa7110: just ident 100 */
+
V4L2_IDENT_SAA7110 = 100,
- /* module saa7115: reserved range 101-149 */
+
V4L2_IDENT_SAA7111 = 101,
V4L2_IDENT_SAA7111A = 102,
V4L2_IDENT_SAA7113 = 103,
@@ -52,11 +48,11 @@
V4L2_IDENT_SAA7115 = 105,
V4L2_IDENT_SAA7118 = 108,
- /* module saa7127: reserved range 150-199 */
+
V4L2_IDENT_SAA7127 = 157,
V4L2_IDENT_SAA7129 = 159,
- /* module cx25840: reserved range 200-249 */
+
V4L2_IDENT_CX25836 = 236,
V4L2_IDENT_CX25837 = 237,
V4L2_IDENT_CX25840 = 240,
@@ -64,7 +60,7 @@
V4L2_IDENT_CX25842 = 242,
V4L2_IDENT_CX25843 = 243,
- /* OmniVision sensors: reserved range 250-299 */
+
V4L2_IDENT_OV7670 = 250,
V4L2_IDENT_OV7720 = 251,
V4L2_IDENT_OV7725 = 252,
@@ -76,157 +72,151 @@
V4L2_IDENT_OV6650 = 258,
V4L2_IDENT_OV2640 = 259,
V4L2_IDENT_OV9740 = 260,
- V4L2_IDENT_OV5642 = 261,
- /* module saa7146: reserved range 300-309 */
+
V4L2_IDENT_SAA7146 = 300,
- /* Conexant MPEG encoder/decoders: reserved range 400-420 */
- V4L2_IDENT_CX23418_843 = 403, /* Integrated A/V Decoder on the '418 */
+
+ V4L2_IDENT_CX23418_843 = 403,
V4L2_IDENT_CX23415 = 415,
V4L2_IDENT_CX23416 = 416,
V4L2_IDENT_CX23417 = 417,
V4L2_IDENT_CX23418 = 418,
- /* module bt819: reserved range 810-819 */
+
V4L2_IDENT_BT815A = 815,
V4L2_IDENT_BT817A = 817,
V4L2_IDENT_BT819A = 819,
- /* module au0828 */
+
V4L2_IDENT_AU0828 = 828,
- /* module bt856: just ident 856 */
+
V4L2_IDENT_BT856 = 856,
- /* module bt866: just ident 866 */
+
V4L2_IDENT_BT866 = 866,
- /* module ks0127: reserved range 1120-1129 */
+
V4L2_IDENT_KS0122S = 1122,
V4L2_IDENT_KS0127 = 1127,
V4L2_IDENT_KS0127B = 1128,
- /* module indycam: just ident 2000 */
+
V4L2_IDENT_INDYCAM = 2000,
- /* module vp27smpx: just ident 2700 */
+
V4L2_IDENT_VP27SMPX = 2700,
- /* module vpx3220: reserved range: 3210-3229 */
+
V4L2_IDENT_VPX3214C = 3214,
V4L2_IDENT_VPX3216B = 3216,
V4L2_IDENT_VPX3220A = 3220,
- /* VX855 just ident 3409 */
- /* Other via devs could use 3314, 3324, 3327, 3336, 3364, 3353 */
+
+
V4L2_IDENT_VIA_VX855 = 3409,
- /* module tvp5150 */
+
V4L2_IDENT_TVP5150 = 5150,
- /* module saa5246a: just ident 5246 */
+
V4L2_IDENT_SAA5246A = 5246,
- /* module saa5249: just ident 5249 */
+
V4L2_IDENT_SAA5249 = 5249,
- /* module cs5345: just ident 5345 */
+
V4L2_IDENT_CS5345 = 5345,
- /* module tea6415c: just ident 6415 */
+
V4L2_IDENT_TEA6415C = 6415,
- /* module tea6420: just ident 6420 */
+
V4L2_IDENT_TEA6420 = 6420,
- /* module saa6588: just ident 6588 */
+
V4L2_IDENT_SAA6588 = 6588,
- /* module vs6624: just ident 6624 */
- V4L2_IDENT_VS6624 = 6624,
-
- /* module saa6752hs: reserved range 6750-6759 */
+
V4L2_IDENT_SAA6752HS = 6752,
V4L2_IDENT_SAA6752HS_AC3 = 6753,
- /* modules tef6862: just ident 6862 */
+
V4L2_IDENT_TEF6862 = 6862,
- /* module tvp7002: just ident 7002 */
+
V4L2_IDENT_TVP7002 = 7002,
- /* module adv7170: just ident 7170 */
+
V4L2_IDENT_ADV7170 = 7170,
- /* module adv7175: just ident 7175 */
+
V4L2_IDENT_ADV7175 = 7175,
- /* module adv7180: just ident 7180 */
+
V4L2_IDENT_ADV7180 = 7180,
- /* module adv7183: just ident 7183 */
- V4L2_IDENT_ADV7183 = 7183,
-
- /* module saa7185: just ident 7185 */
+
V4L2_IDENT_SAA7185 = 7185,
- /* module saa7191: just ident 7191 */
+
V4L2_IDENT_SAA7191 = 7191,
- /* module ths7303: just ident 7303 */
+
V4L2_IDENT_THS7303 = 7303,
- /* module adv7343: just ident 7343 */
+
V4L2_IDENT_ADV7343 = 7343,
- /* module saa7706h: just ident 7706 */
+
V4L2_IDENT_SAA7706H = 7706,
- /* module mt9v011, just ident 8243 */
+
V4L2_IDENT_MT9V011 = 8243,
- /* module wm8739: just ident 8739 */
+
V4L2_IDENT_WM8739 = 8739,
- /* module wm8775: just ident 8775 */
+
V4L2_IDENT_WM8775 = 8775,
- /* Marvell controllers starting at 8801 */
+
V4L2_IDENT_CAFE = 8801,
- V4L2_IDENT_ARMADA610 = 8802,
- /* AKM AK8813/AK8814 */
+
V4L2_IDENT_AK8813 = 8813,
V4L2_IDENT_AK8814 = 8814,
- /* module cx23885 and cx25840 */
+
V4L2_IDENT_CX23885 = 8850,
- V4L2_IDENT_CX23885_AV = 8851, /* Integrated A/V decoder */
+ V4L2_IDENT_CX23885_AV = 8851,
V4L2_IDENT_CX23887 = 8870,
- V4L2_IDENT_CX23887_AV = 8871, /* Integrated A/V decoder */
+ V4L2_IDENT_CX23887_AV = 8871,
V4L2_IDENT_CX23888 = 8880,
- V4L2_IDENT_CX23888_AV = 8881, /* Integrated A/V decoder */
- V4L2_IDENT_CX23888_IR = 8882, /* Integrated infrared controller */
+ V4L2_IDENT_CX23888_AV = 8881,
+ V4L2_IDENT_CX23888_IR = 8882,
- /* module tda9840: just ident 9840 */
+
V4L2_IDENT_TDA9840 = 9840,
- /* module tw9910: just ident 9910 */
+
V4L2_IDENT_TW9910 = 9910,
- /* module sn9c20x: just ident 10000 */
+
V4L2_IDENT_SN9C20X = 10000,
- /* module cx231xx and cx25840 */
- V4L2_IDENT_CX2310X_AV = 23099, /* Integrated A/V decoder; not in '100 */
+
+ V4L2_IDENT_NOON010PC30 = 10100,
+
+
+ V4L2_IDENT_CX2310X_AV = 23099,
V4L2_IDENT_CX23100 = 23100,
V4L2_IDENT_CX23101 = 23101,
V4L2_IDENT_CX23102 = 23102,
- /* module msp3400: reserved range 34000-34999 for msp34xx */
- V4L2_IDENT_MSPX4XX = 34000, /* generic MSPX4XX identifier, only
- use internally (tveeprom.c). */
+
+ V4L2_IDENT_MSPX4XX = 34000,
V4L2_IDENT_MSP3400B = 34002,
V4L2_IDENT_MSP3400C = 34003,
@@ -278,7 +268,7 @@
V4L2_IDENT_MSP3465G = 34657,
V4L2_IDENT_MSP3467G = 34677,
- /* module msp3400: reserved range 44000-44999 for msp44xx */
+
V4L2_IDENT_MSP4400G = 44007,
V4L2_IDENT_MSP4408G = 44087,
V4L2_IDENT_MSP4410G = 44107,
@@ -290,43 +280,43 @@
V4L2_IDENT_MSP4450G = 44507,
V4L2_IDENT_MSP4458G = 44587,
- /* Micron CMOS sensor chips: 45000-45099 */
+
V4L2_IDENT_MT9M001C12ST = 45000,
V4L2_IDENT_MT9M001C12STM = 45005,
V4L2_IDENT_MT9M111 = 45007,
V4L2_IDENT_MT9M112 = 45008,
- V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */
- V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */
+ V4L2_IDENT_MT9V022IX7ATC = 45010,
+ V4L2_IDENT_MT9V022IX7ATM = 45015,
V4L2_IDENT_MT9T031 = 45020,
V4L2_IDENT_MT9T111 = 45021,
V4L2_IDENT_MT9T112 = 45022,
V4L2_IDENT_MT9V111 = 45031,
V4L2_IDENT_MT9V112 = 45032,
- /* HV7131R CMOS sensor: just ident 46000 */
+
V4L2_IDENT_HV7131R = 46000,
- /* Sharp RJ54N1CB0C, 0xCB0C = 51980 */
+
V4L2_IDENT_RJ54N1CB0C = 51980,
- /* module m52790: just ident 52790 */
+
V4L2_IDENT_M52790 = 52790,
- /* module cs53132a: just ident 53132 */
+
V4L2_IDENT_CS53l32A = 53132,
- /* modules upd61151 MPEG2 encoder: just ident 54000 */
+
V4L2_IDENT_UPD61161 = 54000,
- /* modules upd61152 MPEG2 encoder with AC3: just ident 54001 */
+
V4L2_IDENT_UPD61162 = 54001,
- /* module upd64031a: just ident 64031 */
+
V4L2_IDENT_UPD64031A = 64031,
- /* module upd64083: just ident 64083 */
+
V4L2_IDENT_UPD64083 = 64083,
- /* Don't just add new IDs at the end: KEEP THIS LIST ORDERED BY ID! */
+
};
#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index a298ec4..24bca98 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -28,9 +28,6 @@
#include <media/v4l2-dev.h>
-/* Common printk constucts for v4l-i2c drivers. These macros create a unique
- prefix consisting of the driver name, the adapter number and the i2c
- address. */
#define v4l_printk(level, name, adapter, addr, fmt, arg...) \
printk(level "%s %d-%04x: " fmt, name, i2c_adapter_id(adapter), addr , ## arg)
@@ -47,17 +44,13 @@
#define v4l_info(client, fmt, arg...) \
v4l_client_printk(KERN_INFO, client, fmt , ## arg)
-/* These three macros assume that the debug level is set with a module
- parameter called 'debug'. */
#define v4l_dbg(level, debug, client, fmt, arg...) \
do { \
if (debug >= (level)) \
v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \
} while (0)
-/* ------------------------------------------------------------------------- */
-/* These printk constructs can be used with v4l2_device and v4l2_subdev */
#define v4l2_printk(level, dev, fmt, arg...) \
printk(level "%s: " fmt, (dev)->name , ## arg)
@@ -70,17 +63,13 @@
#define v4l2_info(dev, fmt, arg...) \
v4l2_printk(KERN_INFO, dev, fmt , ## arg)
-/* These three macros assume that the debug level is set with a module
- parameter called 'debug'. */
#define v4l2_dbg(level, debug, dev, fmt, arg...) \
do { \
if (debug >= (level)) \
v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \
} while (0)
-/* ------------------------------------------------------------------------- */
-/* Control helper functions */
int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
const char * const *menu_items);
@@ -92,25 +81,17 @@
#define V4L2_CTRL_MENU_IDS_END (0xffffffff)
int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids);
-/* Note: ctrl_classes points to an array of u32 pointers. Each u32 array is a
- 0-terminated array of control IDs. Each array must be sorted low to high
- and belong to the same control class. The array of u32 pointers must also
- be sorted, from low class IDs to high class IDs. */
u32 v4l2_ctrl_next(const u32 * const *ctrl_classes, u32 id);
-/* ------------------------------------------------------------------------- */
-/* Register/chip ident helper function */
-struct i2c_client; /* forward reference */
+struct i2c_client;
int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match);
int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip,
u32 ident, u32 revision);
int v4l2_chip_match_host(const struct v4l2_dbg_match *match);
-/* ------------------------------------------------------------------------- */
-/* I2C Helper functions */
struct i2c_driver;
struct i2c_adapter;
@@ -121,8 +102,6 @@
struct v4l2_subdev_ops;
-/* Load an i2c module and return an initialized v4l2_subdev struct.
- The client_type argument is the name of the chip that's on the adapter. */
struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
struct i2c_adapter *adapter, const char *client_type,
u8 addr, const unsigned short *probe_addrs);
@@ -133,52 +112,34 @@
struct i2c_adapter *adapter, struct i2c_board_info *info,
const unsigned short *probe_addrs);
-/* Initialize an v4l2_subdev with data from an i2c_client struct */
void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
const struct v4l2_subdev_ops *ops);
-/* Return i2c client address of v4l2_subdev. */
unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd);
enum v4l2_i2c_tuner_type {
- ADDRS_RADIO, /* Radio tuner addresses */
- ADDRS_DEMOD, /* Demod tuner addresses */
- ADDRS_TV, /* TV tuner addresses */
- /* TV tuner addresses if demod is present, this excludes
- addresses used by the demodulator from the list of
- candidates. */
+ ADDRS_RADIO,
+ ADDRS_DEMOD,
+ ADDRS_TV,
ADDRS_TV_WITH_DEMOD,
};
-/* Return a list of I2C tuner addresses to probe. Use only if the tuner
- addresses are unknown. */
const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type);
-/* ------------------------------------------------------------------------- */
-/* SPI Helper functions */
#if defined(CONFIG_SPI)
#include <linux/spi/spi.h>
struct spi_device;
-/* Load an spi module and return an initialized v4l2_subdev struct.
- The client_type argument is the name of the chip that's on the adapter. */
struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
struct spi_master *master, struct spi_board_info *info);
-/* Initialize an v4l2_subdev with data from an spi_device struct */
void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
const struct v4l2_subdev_ops *ops);
#endif
-/* ------------------------------------------------------------------------- */
-/* Note: these remaining ioctls/structs should be removed as well, but they are
- still used in tuner-simple.c (TUNER_SET_CONFIG), cx18/ivtv (RESET) and
- v4l2-int-device.h (v4l2_routing). To remove these ioctls some more cleanup
- is needed in those modules. */
-/* s_config */
struct v4l2_priv_tun_config {
int tuner;
void *priv;
@@ -192,9 +153,7 @@
u32 output;
};
-/* ------------------------------------------------------------------------- */
-/* Miscellaneous helper functions */
void v4l_bound_align_image(unsigned int *w, unsigned int wmin,
unsigned int wmax, unsigned int walign,
@@ -212,4 +171,4 @@
const struct v4l2_discrete_probe *probe,
s32 width, s32 height);
-#endif /* V4L2_COMMON_H_ */
+#endif
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 3a44b62..166f624 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -22,94 +22,23 @@
#define _V4L2_CTRLS_H
#include <linux/list.h>
+#include <linux/device.h>
#include <linux/videodev2.h>
-/* forward references */
struct v4l2_ctrl_handler;
-struct v4l2_ctrl_helper;
struct v4l2_ctrl;
struct video_device;
struct v4l2_subdev;
-struct v4l2_subscribed_event;
-struct v4l2_fh;
-struct poll_table_struct;
-struct file;
-/** struct v4l2_ctrl_ops - The control operations that the driver has to provide.
- * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
- * for volatile (and usually read-only) controls such as a control
- * that returns the current signal strength which changes
- * continuously.
- * If not set, then the currently cached value will be returned.
- * @try_ctrl: Test whether the control's value is valid. Only relevant when
- * the usual min/max/step checks are not sufficient.
- * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
- * ctrl->handler->lock is held when these ops are called, so no
- * one else can access controls owned by that handler.
- */
struct v4l2_ctrl_ops {
int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
int (*try_ctrl)(struct v4l2_ctrl *ctrl);
int (*s_ctrl)(struct v4l2_ctrl *ctrl);
};
-/** struct v4l2_ctrl - The control structure.
- * @node: The list node.
- * @ev_subs: The list of control event subscriptions.
- * @handler: The handler that owns the control.
- * @cluster: Point to start of cluster array.
- * @ncontrols: Number of controls in cluster array.
- * @done: Internal flag: set for each processed control.
- * @is_new: Set when the user specified a new value for this control. It
- * is also set when called from v4l2_ctrl_handler_setup. Drivers
- * should never set this flag.
- * @is_private: If set, then this control is private to its handler and it
- * will not be added to any other handlers. Drivers can set
- * this flag.
- * @is_auto: If set, then this control selects whether the other cluster
- * members are in 'automatic' mode or 'manual' mode. This is
- * used for autogain/gain type clusters. Drivers should never
- * set this flag directly.
- * @has_volatiles: If set, then one or more members of the cluster are volatile.
- * Drivers should never touch this flag.
- * @manual_mode_value: If the is_auto flag is set, then this is the value
- * of the auto control that determines if that control is in
- * manual mode. So if the value of the auto control equals this
- * value, then the whole cluster is in manual mode. Drivers should
- * never set this flag directly.
- * @ops: The control ops.
- * @id: The control ID.
- * @name: The control name.
- * @type: The control type.
- * @minimum: The control's minimum value.
- * @maximum: The control's maximum value.
- * @default_value: The control's default value.
- * @step: The control's step value for non-menu controls.
- * @menu_skip_mask: The control's skip mask for menu controls. This makes it
- * easy to skip menu items that are not valid. If bit X is set,
- * then menu item X is skipped. Of course, this only works for
- * menus with <= 32 menu items. There are no menus that come
- * close to that number, so this is OK. Should we ever need more,
- * then this will have to be extended to a u64 or a bit array.
- * @qmenu: A const char * array for all menu items. Array entries that are
- * empty strings ("") correspond to non-existing menu items (this
- * is in addition to the menu_skip_mask above). The last entry
- * must be NULL.
- * @flags: The control's flags.
- * @cur: The control's current value.
- * @val: The control's new s32 value.
- * @val64: The control's new s64 value.
- * @string: The control's new string value.
- * @priv: The control's private pointer. For use by the driver. It is
- * untouched by the control framework. Note that this pointer is
- * not freed when the control is deleted. Should this be needed
- * then a new internal bitfield can be added to tell the framework
- * to free this pointer.
- */
struct v4l2_ctrl {
- /* Administrative fields */
+
struct list_head node;
- struct list_head ev_subs;
struct v4l2_ctrl_handler *handler;
struct v4l2_ctrl **cluster;
unsigned ncontrols;
@@ -117,9 +46,7 @@
unsigned int is_new:1;
unsigned int is_private:1;
- unsigned int is_auto:1;
- unsigned int has_volatiles:1;
- unsigned int manual_mode_value:8;
+ unsigned int is_volatile:1;
const struct v4l2_ctrl_ops *ops;
u32 id;
@@ -145,36 +72,12 @@
void *priv;
};
-/** struct v4l2_ctrl_ref - The control reference.
- * @node: List node for the sorted list.
- * @next: Single-link list node for the hash.
- * @ctrl: The actual control information.
- * @helper: Pointer to helper struct. Used internally in prepare_ext_ctrls().
- *
- * Each control handler has a list of these refs. The list_head is used to
- * keep a sorted-by-control-ID list of all controls, while the next pointer
- * is used to link the control in the hash's bucket.
- */
struct v4l2_ctrl_ref {
struct list_head node;
struct v4l2_ctrl_ref *next;
struct v4l2_ctrl *ctrl;
- struct v4l2_ctrl_helper *helper;
};
-/** struct v4l2_ctrl_handler - The control handler keeps track of all the
- * controls: both the controls owned by the handler and those inherited
- * from other handlers.
- * @lock: Lock to control access to this handler and its controls.
- * @ctrls: The list of controls owned by this handler.
- * @ctrl_refs: The list of control references.
- * @cached: The last found control reference. It is common that the same
- * control is needed multiple times, so this is a simple
- * optimization.
- * @buckets: Buckets for the hashing. Allows for quick control lookup.
- * @nr_of_buckets: Total number of buckets in the array.
- * @error: The error code of the first failed control addition.
- */
struct v4l2_ctrl_handler {
struct mutex lock;
struct list_head ctrls;
@@ -185,29 +88,6 @@
int error;
};
-/** struct v4l2_ctrl_config - Control configuration structure.
- * @ops: The control ops.
- * @id: The control ID.
- * @name: The control name.
- * @type: The control type.
- * @min: The control's minimum value.
- * @max: The control's maximum value.
- * @step: The control's step value for non-menu controls.
- * @def: The control's default value.
- * @flags: The control's flags.
- * @menu_skip_mask: The control's skip mask for menu controls. This makes it
- * easy to skip menu items that are not valid. If bit X is set,
- * then menu item X is skipped. Of course, this only works for
- * menus with <= 32 menu items. There are no menus that come
- * close to that number, so this is OK. Should we ever need more,
- * then this will have to be extended to a u64 or a bit array.
- * @qmenu: A const char * array for all menu items. Array entries that are
- * empty strings ("") correspond to non-existing menu items (this
- * is in addition to the menu_skip_mask above). The last entry
- * must be NULL.
- * @is_private: If set, then this control is private to its handler and it
- * will not be added to any other handlers.
- */
struct v4l2_ctrl_config {
const struct v4l2_ctrl_ops *ops;
u32 id;
@@ -221,303 +101,73 @@
u32 menu_skip_mask;
const char * const *qmenu;
unsigned int is_private:1;
+ unsigned int is_volatile:1;
};
-/** v4l2_ctrl_fill() - Fill in the control fields based on the control ID.
- *
- * This works for all standard V4L2 controls.
- * For non-standard controls it will only fill in the given arguments
- * and @name will be NULL.
- *
- * This function will overwrite the contents of @name, @type and @flags.
- * The contents of @min, @max, @step and @def may be modified depending on
- * the type.
- *
- * Do not use in drivers! It is used internally for backwards compatibility
- * control handling only. Once all drivers are converted to use the new
- * control framework this function will no longer be exported.
- */
void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags);
-/** v4l2_ctrl_handler_init() - Initialize the control handler.
- * @hdl: The control handler.
- * @nr_of_controls_hint: A hint of how many controls this handler is
- * expected to refer to. This is the total number, so including
- * any inherited controls. It doesn't have to be precise, but if
- * it is way off, then you either waste memory (too many buckets
- * are allocated) or the control lookup becomes slower (not enough
- * buckets are allocated, so there are more slow list lookups).
- * It will always work, though.
- *
- * Returns an error if the buckets could not be allocated. This error will
- * also be stored in @hdl->error.
- */
int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl,
unsigned nr_of_controls_hint);
-/** v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
- * the control list.
- * @hdl: The control handler.
- *
- * Does nothing if @hdl == NULL.
- */
void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
-/** v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
- * to the handler to initialize the hardware to the current control values.
- * @hdl: The control handler.
- *
- * Button controls will be skipped, as are read-only controls.
- *
- * If @hdl == NULL, then this just returns 0.
- */
int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
-/** v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
- * @hdl: The control handler.
- * @prefix: The prefix to use when logging the control values. If the
- * prefix does not end with a space, then ": " will be added
- * after the prefix. If @prefix == NULL, then no prefix will be
- * used.
- *
- * For use with VIDIOC_LOG_STATUS.
- *
- * Does nothing if @hdl == NULL.
- */
void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
const char *prefix);
-/** v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
- * control.
- * @hdl: The control handler.
- * @cfg: The control's configuration data.
- * @priv: The control's driver-specific private data.
- *
- * If the &v4l2_ctrl struct could not be allocated then NULL is returned
- * and @hdl->error is set to the error code (if it wasn't set already).
- */
struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_config *cfg, void *priv);
-/** v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu control.
- * @hdl: The control handler.
- * @ops: The control ops.
- * @id: The control ID.
- * @min: The control's minimum value.
- * @max: The control's maximum value.
- * @step: The control's step value
- * @def: The control's default value.
- *
- * If the &v4l2_ctrl struct could not be allocated, or the control
- * ID is not known, then NULL is returned and @hdl->error is set to the
- * appropriate error code (if it wasn't set already).
- *
- * If @id refers to a menu control, then this function will return NULL.
- *
- * Use v4l2_ctrl_new_std_menu() when adding menu controls.
- */
struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 min, s32 max, u32 step, s32 def);
-/** v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control.
- * @hdl: The control handler.
- * @ops: The control ops.
- * @id: The control ID.
- * @max: The control's maximum value.
- * @mask: The control's skip mask for menu controls. This makes it
- * easy to skip menu items that are not valid. If bit X is set,
- * then menu item X is skipped. Of course, this only works for
- * menus with <= 32 menu items. There are no menus that come
- * close to that number, so this is OK. Should we ever need more,
- * then this will have to be extended to a u64 or a bit array.
- * @def: The control's default value.
- *
- * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
- * determines which menu items are to be skipped.
- *
- * If @id refers to a non-menu control, then this function will return NULL.
- */
struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, s32 max, s32 mask, s32 def);
-/** v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler.
- * @hdl: The control handler.
- * @ctrl: The control to add.
- *
- * It will return NULL if it was unable to add the control reference.
- * If the control already belonged to the handler, then it will do
- * nothing and just return @ctrl.
- */
struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
struct v4l2_ctrl *ctrl);
-/** v4l2_ctrl_add_handler() - Add all controls from handler @add to
- * handler @hdl.
- * @hdl: The control handler.
- * @add: The control handler whose controls you want to add to
- * the @hdl control handler.
- *
- * Does nothing if either of the two is a NULL pointer.
- * In case of an error @hdl->error will be set to the error code (if it
- * wasn't set already).
- */
int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
struct v4l2_ctrl_handler *add);
-/** v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging to that cluster.
- * @ncontrols: The number of controls in this cluster.
- * @controls: The cluster control array of size @ncontrols.
- */
void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls);
-/** v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging to
- * that cluster and set it up for autofoo/foo-type handling.
- * @ncontrols: The number of controls in this cluster.
- * @controls: The cluster control array of size @ncontrols. The first control
- * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
- * @manual_val: The value for the first control in the cluster that equals the
- * manual setting.
- * @set_volatile: If true, then all controls except the first auto control will
- * be volatile.
- *
- * Use for control groups where one control selects some automatic feature and
- * the other controls are only active whenever the automatic feature is turned
- * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
- * red and blue balance, etc.
- *
- * The behavior of such controls is as follows:
- *
- * When the autofoo control is set to automatic, then any manual controls
- * are set to inactive and any reads will call g_volatile_ctrl (if the control
- * was marked volatile).
- *
- * When the autofoo control is set to manual, then any manual controls will
- * be marked active, and any reads will just return the current value without
- * going through g_volatile_ctrl.
- *
- * In addition, this function will set the V4L2_CTRL_FLAG_UPDATE flag
- * on the autofoo control and V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
- * if autofoo is in auto mode.
- */
-void v4l2_ctrl_auto_cluster(unsigned ncontrols, struct v4l2_ctrl **controls,
- u8 manual_val, bool set_volatile);
-
-
-/** v4l2_ctrl_find() - Find a control with the given ID.
- * @hdl: The control handler.
- * @id: The control ID to find.
- *
- * If @hdl == NULL this will return NULL as well. Will lock the handler so
- * do not use from inside &v4l2_ctrl_ops.
- */
struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
-/** v4l2_ctrl_activate() - Make the control active or inactive.
- * @ctrl: The control to (de)activate.
- * @active: True if the control should become active.
- *
- * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
- * Does nothing if @ctrl == NULL.
- * This will usually be called from within the s_ctrl op.
- * The V4L2_EVENT_CTRL event will be generated afterwards.
- *
- * This function assumes that the control handler is locked.
- */
void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
-/** v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
- * @ctrl: The control to (de)activate.
- * @grabbed: True if the control should become grabbed.
- *
- * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
- * Does nothing if @ctrl == NULL.
- * The V4L2_EVENT_CTRL event will be generated afterwards.
- * This will usually be called when starting or stopping streaming in the
- * driver.
- *
- * This function assumes that the control handler is not locked and will
- * take the lock itself.
- */
void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
-/** v4l2_ctrl_lock() - Helper function to lock the handler
- * associated with the control.
- * @ctrl: The control to lock.
- */
static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
{
mutex_lock(&ctrl->handler->lock);
}
-/** v4l2_ctrl_lock() - Helper function to unlock the handler
- * associated with the control.
- * @ctrl: The control to unlock.
- */
static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
{
mutex_unlock(&ctrl->handler->lock);
}
-/** v4l2_ctrl_g_ctrl() - Helper function to get the control's value from within a driver.
- * @ctrl: The control.
- *
- * This returns the control's value safely by going through the control
- * framework. This function will lock the control's handler, so it cannot be
- * used from within the &v4l2_ctrl_ops functions.
- *
- * This function is for integer type controls only.
- */
s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
-/** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver.
- * @ctrl: The control.
- * @val: The new value.
- *
- * This set the control's new value safely by going through the control
- * framework. This function will lock the control's handler, so it cannot be
- * used from within the &v4l2_ctrl_ops functions.
- *
- * This function is for integer type controls only.
- */
int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
-/* Internal helper functions that deal with control events. */
-void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl,
- struct v4l2_subscribed_event *sev);
-void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl,
- struct v4l2_subscribed_event *sev);
-/* Can be used as a vidioc_log_status function that just dumps all controls
- associated with the filehandle. */
-int v4l2_ctrl_log_status(struct file *file, void *fh);
-
-/* Can be used as a vidioc_subscribe_event function that just subscribes
- control events. */
-int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub);
-
-/* Can be used as a poll function that just polls for control events. */
-unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
-
-/* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
-int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
- struct v4l2_control *ctrl);
+int v4l2_s_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
-int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
- struct v4l2_ext_controls *c);
+int v4l2_s_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *c);
-/* Helpers for subdevices. If the associated ctrl_handler == NULL then they
- will all return -EINVAL. */
int v4l2_subdev_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
int v4l2_subdev_querymenu(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
int v4l2_subdev_g_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs);
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 96d2221..b7bee3f 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -1,11 +1,3 @@
-/*
- *
- * V 4 L 2 D R I V E R H E L P E R A P I
- *
- * Moved from videodev2.h
- *
- * Some commonly needed functions for drivers (v4l2-common.o module)
- */
#ifndef _V4L2_DEV_H
#define _V4L2_DEV_H
@@ -31,16 +23,10 @@
struct v4l2_device;
struct v4l2_ctrl_handler;
-/* Flag to mark the video_device struct as registered.
- Drivers can clear this flag if they want to block all future
- device access. It is cleared by video_unregister_device. */
#define V4L2_FL_REGISTERED (0)
-/* file->private_data points to struct v4l2_fh */
#define V4L2_FL_USES_V4L2_FH (1)
-/* Use the prio field of v4l2_fh for core priority checking */
#define V4L2_FL_USE_FH_PRIO (2)
-/* Priority helper functions */
struct v4l2_prio_state {
atomic_t prios[4];
@@ -62,9 +48,6 @@
unsigned int (*poll) (struct file *, struct poll_table_struct *);
long (*ioctl) (struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
-#ifdef CONFIG_COMPAT
- long (*compat_ioctl32) (struct file *, unsigned int, unsigned long);
-#endif
unsigned long (*get_unmapped_area) (struct file *, unsigned long,
unsigned long, unsigned long, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -72,108 +55,87 @@
int (*release) (struct file *);
};
-/*
- * Newer version of video_device, handled by videodev2.c
- * This version moves redundant code from video device code to
- * the common handler
- */
struct video_device
{
#if defined(CONFIG_MEDIA_CONTROLLER)
struct media_entity entity;
#endif
- /* device ops */
+
const struct v4l2_file_operations *fops;
- /* sysfs */
- struct device dev; /* v4l device */
- struct cdev *cdev; /* character device */
+
+ struct device dev;
+ struct cdev *cdev;
- /* Set either parent or v4l2_dev if your driver uses v4l2_device */
- struct device *parent; /* device parent */
- struct v4l2_device *v4l2_dev; /* v4l2_device parent */
+
+ struct device *parent;
+ struct v4l2_device *v4l2_dev;
- /* Control handler associated with this device node. May be NULL. */
+
struct v4l2_ctrl_handler *ctrl_handler;
- /* Priority state. If NULL, then v4l2_dev->prio will be used. */
+
struct v4l2_prio_state *prio;
- /* device info */
+
char name[32];
int vfl_type;
- /* 'minor' is set to -1 if the registration failed */
+
int minor;
u16 num;
- /* use bitops to set/clear/test flags */
+
unsigned long flags;
- /* attribute to differentiate multiple indices on one physical device */
+
int index;
- /* V4L2 file handles */
- spinlock_t fh_lock; /* Lock for all v4l2_fhs */
- struct list_head fh_list; /* List of struct v4l2_fh */
+
+ spinlock_t fh_lock;
+ struct list_head fh_list;
- int debug; /* Activates debug level*/
+ int debug;
- /* Video standard vars */
- v4l2_std_id tvnorms; /* Supported tv norms */
- v4l2_std_id current_norm; /* Current tvnorm */
+
+ v4l2_std_id tvnorms;
+ v4l2_std_id current_norm;
- /* callbacks */
+
void (*release)(struct video_device *vdev);
- /* ioctl callbacks */
+
const struct v4l2_ioctl_ops *ioctl_ops;
- /* serialization lock */
+
struct mutex *lock;
};
#define media_entity_to_video_device(__e) \
container_of(__e, struct video_device, entity)
-/* dev to video-device */
#define to_video_device(cd) container_of(cd, struct video_device, dev)
int __must_check __video_register_device(struct video_device *vdev, int type,
int nr, int warn_if_nr_in_use, struct module *owner);
-/* Register video devices. Note that if video_register_device fails,
- the release() callback of the video_device structure is *not* called, so
- the caller is responsible for freeing any data. Usually that means that
- you call video_device_release() on failure. */
static inline int __must_check video_register_device(struct video_device *vdev,
int type, int nr)
{
return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
}
-/* Same as video_register_device, but no warning is issued if the desired
- device node number was already in use. */
static inline int __must_check video_register_device_no_warn(
struct video_device *vdev, int type, int nr)
{
return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
}
-/* Unregister video devices. Will do nothing if vdev == NULL or
- video_is_registered() returns false. */
void video_unregister_device(struct video_device *vdev);
-/* helper functions to alloc/release struct video_device, the
- latter can also be used for video_device->release(). */
struct video_device * __must_check video_device_alloc(void);
-/* this release function frees the vdev pointer */
void video_device_release(struct video_device *vdev);
-/* this release function does nothing, use when the video_device is a
- static global struct. Note that having a static video_device is
- a dubious construction at best. */
void video_device_release_empty(struct video_device *vdev);
-/* helper functions to access driver private data. */
static inline void *video_get_drvdata(struct video_device *vdev)
{
return dev_get_drvdata(&vdev->dev);
@@ -186,8 +148,6 @@
struct video_device *video_devdata(struct file *file);
-/* Combine video_get_drvdata and video_devdata as this is
- used very often. */
static inline void *video_drvdata(struct file *file)
{
return video_get_drvdata(video_devdata(file));
@@ -203,4 +163,4 @@
return test_bit(V4L2_FL_REGISTERED, &vdev->flags);
}
-#endif /* _V4L2_DEV_H */
+#endif
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index d61febf..a69738e 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -25,44 +25,33 @@
#include <media/v4l2-subdev.h>
#include <media/v4l2-dev.h>
-/* Each instance of a V4L2 device should create the v4l2_device struct,
- either stand-alone or embedded in a larger struct.
-
- It allows easy access to sub-devices (see v4l2-subdev.h) and provides
- basic V4L2 device-level support.
- */
#define V4L2_DEVICE_NAME_SIZE (20 + 16)
struct v4l2_ctrl_handler;
struct v4l2_device {
- /* dev->driver_data points to this struct.
- Note: dev might be NULL if there is no parent device
- as is the case with e.g. ISA devices. */
struct device *dev;
#if defined(CONFIG_MEDIA_CONTROLLER)
struct media_device *mdev;
#endif
- /* used to keep track of the registered subdevs */
+
struct list_head subdevs;
- /* lock this struct; can be used by the driver as well if this
- struct is embedded into a larger struct. */
spinlock_t lock;
- /* unique device name, by default the driver name + bus ID */
+
char name[V4L2_DEVICE_NAME_SIZE];
- /* notify callback called by some sub-devices. */
+
void (*notify)(struct v4l2_subdev *sd,
unsigned int notification, void *arg);
- /* The control handler. May be NULL. */
+
struct v4l2_ctrl_handler *ctrl_handler;
- /* Device's priority state */
+
struct v4l2_prio_state prio;
- /* BKL replacement mutex. Temporary solution only. */
+
struct mutex ioctl_lock;
- /* Keep track of the references to this struct. */
+
struct kref ref;
- /* Release function that is called when the ref count goes to 0. */
+
void (*release)(struct v4l2_device *v4l2_dev);
};
@@ -73,60 +62,25 @@
int v4l2_device_put(struct v4l2_device *v4l2_dev);
-/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
- dev may be NULL in rare cases (ISA devices). In that case you
- must fill in the v4l2_dev->name field before calling this function. */
int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev);
-/* Optional function to initialize the name field of struct v4l2_device using
- the driver name and a driver-global atomic_t instance.
- This function will increment the instance counter and returns the instance
- value used in the name.
-
- Example:
-
- static atomic_t drv_instance = ATOMIC_INIT(0);
-
- ...
-
- instance = v4l2_device_set_name(&v4l2_dev, "foo", &drv_instance);
-
- The first time this is called the name field will be set to foo0 and
- this function returns 0. If the name ends with a digit (e.g. cx18),
- then the name will be set to cx18-0 since cx180 looks really odd. */
int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
atomic_t *instance);
-/* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
- Since the parent disappears this ensures that v4l2_dev doesn't have an
- invalid parent pointer. */
void v4l2_device_disconnect(struct v4l2_device *v4l2_dev);
-/* Unregister all sub-devices and any other resources related to v4l2_dev. */
void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
-/* Register a subdev with a v4l2 device. While registered the subdev module
- is marked as in-use. An error is returned if the module is no longer
- loaded when you attempt to register it. */
int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
struct v4l2_subdev *sd);
-/* Unregister a subdev with a v4l2 device. Can also be called if the subdev
- wasn't registered. In that case it will do nothing. */
void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
-/* Register device nodes for all subdev of the v4l2 device that are marked with
- * the V4L2_SUBDEV_FL_HAS_DEVNODE flag.
- */
int __must_check
v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
-/* Iterate over all subdevs. */
#define v4l2_device_for_each_subdev(sd, v4l2_dev) \
list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
-/* Call the specified callback for all subdevs matching the condition.
- Ignore any errors. Note that you cannot add or delete a subdev
- while walking the subdevs list. */
#define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \
do { \
list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
@@ -142,10 +96,6 @@
f , ##args); \
} while (0)
-/* Call the specified callback for all subdevs matching the condition.
- If the callback returns an error other than 0 or -ENOIOCTLCMD, then
- return with that error code. Note that you cannot add or delete a
- subdev while walking the subdevs list. */
#define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \
({ \
long __err = 0; \
@@ -166,9 +116,6 @@
f , ##args); \
})
-/* Call the specified callback for all subdevs matching grp_id (if 0, then
- match them all). Ignore any errors. Note that you cannot add or delete
- a subdev while walking the subdevs list. */
#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \
do { \
struct v4l2_subdev *__sd; \
@@ -178,10 +125,6 @@
##args); \
} while (0)
-/* Call the specified callback for all subdevs matching grp_id (if 0, then
- match them all). If the callback returns an error other than 0 or
- -ENOIOCTLCMD, then return with that error code. Note that you cannot
- add or delete a subdev while walking the subdevs list. */
#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \
({ \
struct v4l2_subdev *__sd; \
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index 5f14e88..fb1841e 100644
--- a/include/media/v4l2-event.h
+++ b/include/media/v4l2-event.h
@@ -29,95 +29,39 @@
#include <linux/videodev2.h>
#include <linux/wait.h>
-/*
- * Overview:
- *
- * Events are subscribed per-filehandle. An event specification consists of a
- * type and is optionally associated with an object identified through the
- * 'id' field. So an event is uniquely identified by the (type, id) tuple.
- *
- * The v4l2-fh struct has a list of subscribed events. The v4l2_subscribed_event
- * struct is added to that list, one for every subscribed event.
- *
- * Each v4l2_subscribed_event struct ends with an array of v4l2_kevent structs.
- * This array (ringbuffer, really) is used to store any events raised by the
- * driver. The v4l2_kevent struct links into the 'available' list of the
- * v4l2_fh struct so VIDIOC_DQEVENT will know which event to dequeue first.
- *
- * Finally, if the event subscription is associated with a particular object
- * such as a V4L2 control, then that object needs to know about that as well
- * so that an event can be raised by that object. So the 'node' field can
- * be used to link the v4l2_subscribed_event struct into a list of that
- * object.
- *
- * So to summarize:
- *
- * struct v4l2_fh has two lists: one of the subscribed events, and one of the
- * pending events.
- *
- * struct v4l2_subscribed_event has a ringbuffer of raised (pending) events of
- * that particular type.
- *
- * If struct v4l2_subscribed_event is associated with a specific object, then
- * that object will have an internal list of struct v4l2_subscribed_event so
- * it knows who subscribed an event to that object.
- */
-
struct v4l2_fh;
-struct v4l2_subscribed_event;
struct video_device;
-/** struct v4l2_kevent - Internal kernel event struct.
- * @list: List node for the v4l2_fh->available list.
- * @sev: Pointer to parent v4l2_subscribed_event.
- * @event: The event itself.
- */
struct v4l2_kevent {
struct list_head list;
- struct v4l2_subscribed_event *sev;
struct v4l2_event event;
};
-/** struct v4l2_subscribed_event - Internal struct representing a subscribed event.
- * @list: List node for the v4l2_fh->subscribed list.
- * @type: Event type.
- * @id: Associated object ID (e.g. control ID). 0 if there isn't any.
- * @flags: Copy of v4l2_event_subscription->flags.
- * @fh: Filehandle that subscribed to this event.
- * @node: List node that hooks into the object's event list (if there is one).
- * @replace: Optional callback that can replace event 'old' with event 'new'.
- * @merge: Optional callback that can merge event 'old' into event 'new'.
- * @elems: The number of elements in the events array.
- * @first: The index of the events containing the oldest available event.
- * @in_use: The number of queued events.
- * @events: An array of @elems events.
- */
struct v4l2_subscribed_event {
struct list_head list;
u32 type;
- u32 id;
- u32 flags;
- struct v4l2_fh *fh;
- struct list_head node;
- void (*replace)(struct v4l2_event *old,
- const struct v4l2_event *new);
- void (*merge)(const struct v4l2_event *old,
- struct v4l2_event *new);
- unsigned elems;
- unsigned first;
- unsigned in_use;
- struct v4l2_kevent events[];
};
+struct v4l2_events {
+ wait_queue_head_t wait;
+ struct list_head subscribed;
+ struct list_head free;
+ struct list_head available;
+ unsigned int navailable;
+ unsigned int nallocated;
+ u32 sequence;
+};
+
+int v4l2_event_init(struct v4l2_fh *fh);
+int v4l2_event_alloc(struct v4l2_fh *fh, unsigned int n);
+void v4l2_event_free(struct v4l2_fh *fh);
int v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event,
int nonblocking);
void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev);
-void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev);
int v4l2_event_pending(struct v4l2_fh *fh);
int v4l2_event_subscribe(struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub, unsigned elems);
+ struct v4l2_event_subscription *sub);
int v4l2_event_unsubscribe(struct v4l2_fh *fh,
struct v4l2_event_subscription *sub);
-void v4l2_event_unsubscribe_all(struct v4l2_fh *fh);
-#endif /* V4L2_EVENT_H */
+#endif
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index 52513c2..9509e9d 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -29,73 +29,25 @@
#include <linux/list.h>
struct video_device;
-struct v4l2_ctrl_handler;
+struct v4l2_events;
struct v4l2_fh {
struct list_head list;
struct video_device *vdev;
- struct v4l2_ctrl_handler *ctrl_handler;
+ struct v4l2_events *events;
enum v4l2_priority prio;
-
- /* Events */
- wait_queue_head_t wait;
- struct list_head subscribed; /* Subscribed events */
- struct list_head available; /* Dequeueable event */
- unsigned int navailable;
- u32 sequence;
};
-/*
- * Initialise the file handle. Parts of the V4L2 framework using the
- * file handles should be initialised in this function. Must be called
- * from driver's v4l2_file_operations->open() handler if the driver
- * uses v4l2_fh.
- */
-void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev);
-/*
- * Add the fh to the list of file handles on a video_device. The file
- * handle must be initialised first.
- */
+int v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev);
void v4l2_fh_add(struct v4l2_fh *fh);
-/*
- * Can be used as the open() op of v4l2_file_operations.
- * It allocates a v4l2_fh and inits and adds it to the video_device associated
- * with the file pointer.
- */
int v4l2_fh_open(struct file *filp);
-/*
- * Remove file handle from the list of file handles. Must be called in
- * v4l2_file_operations->release() handler if the driver uses v4l2_fh.
- * On error filp->private_data will be NULL, otherwise it will point to
- * the v4l2_fh struct.
- */
void v4l2_fh_del(struct v4l2_fh *fh);
-/*
- * Release resources related to a file handle. Parts of the V4L2
- * framework using the v4l2_fh must release their resources here, too.
- * Must be called in v4l2_file_operations->release() handler if the
- * driver uses v4l2_fh.
- */
void v4l2_fh_exit(struct v4l2_fh *fh);
-/*
- * Can be used as the release() op of v4l2_file_operations.
- * It deletes and exits the v4l2_fh associated with the file pointer and
- * frees it. It will do nothing if filp->private_data (the pointer to the
- * v4l2_fh struct) is NULL. This function always returns 0.
- */
int v4l2_fh_release(struct file *filp);
-/*
- * Returns 1 if this filehandle is the only filehandle opened for the
- * associated video_device. If fh is NULL, then it returns 0.
- */
int v4l2_fh_is_singular(struct v4l2_fh *fh);
-/*
- * Helper function with struct file as argument. If filp->private_data is
- * NULL, then it will return 0.
- */
static inline int v4l2_fh_is_singular_file(struct file *filp)
{
return v4l2_fh_is_singular(filp->private_data);
}
-#endif /* V4L2_EVENT_H */
+#endif
diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h
index e6aa231..e52ddc9 100644
--- a/include/media/v4l2-int-device.h
+++ b/include/media/v4l2-int-device.h
@@ -25,23 +25,17 @@
#ifndef V4L2_INT_DEVICE_H
#define V4L2_INT_DEVICE_H
+#include <linux/module.h>
#include <media/v4l2-common.h>
#define V4L2NAMESIZE 32
-/*
- *
- * The internal V4L2 device interface core.
- *
- */
enum v4l2_int_type {
v4l2_int_type_master = 1,
v4l2_int_type_slave
};
-struct module;
-
struct v4l2_int_device;
struct v4l2_int_master {
@@ -59,7 +53,7 @@
};
struct v4l2_int_slave {
- /* Don't touch master. */
+
struct v4l2_int_device *master;
char attach_to[V4L2NAMESIZE];
@@ -69,7 +63,7 @@
};
struct v4l2_int_device {
- /* Don't touch head. */
+
struct list_head head;
struct module *module;
@@ -93,11 +87,6 @@
int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd);
int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg);
-/*
- *
- * Types and definitions for IOCTL commands.
- *
- */
enum v4l2_power {
V4L2_POWER_OFF = 0,
@@ -105,56 +94,35 @@
V4L2_POWER_STANDBY,
};
-/* Slave interface type. */
enum v4l2_if_type {
- /*
- * Parallel 8-, 10- or 12-bit interface, used by for example
- * on certain image sensors.
- */
V4L2_IF_TYPE_BT656,
};
enum v4l2_if_type_bt656_mode {
- /*
- * Modes without Bt synchronisation codes. Separate
- * synchronisation signal lines are used.
- */
V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT,
V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT,
V4L2_IF_TYPE_BT656_MODE_NOBT_12BIT,
- /*
- * Use Bt synchronisation codes. The vertical and horizontal
- * synchronisation is done based on synchronisation codes.
- */
V4L2_IF_TYPE_BT656_MODE_BT_8BIT,
V4L2_IF_TYPE_BT656_MODE_BT_10BIT,
};
struct v4l2_if_type_bt656 {
- /*
- * 0: Frame begins when vsync is high.
- * 1: Frame begins when vsync changes from low to high.
- */
unsigned frame_start_on_rising_vs:1;
- /* Use Bt synchronisation codes for sync correction. */
+
unsigned bt_sync_correct:1;
- /* Swap every two adjacent image data elements. */
+
unsigned swap:1;
- /* Inverted latch clock polarity from slave. */
+
unsigned latch_clk_inv:1;
- /* Hs polarity. 0 is active high, 1 active low. */
+
unsigned nobt_hs_inv:1;
- /* Vs polarity. 0 is active high, 1 active low. */
+
unsigned nobt_vs_inv:1;
enum v4l2_if_type_bt656_mode mode;
- /* Minimum accepted bus clock for slave (in Hz). */
+
u32 clock_min;
- /* Maximum accepted bus clock for slave. */
+
u32 clock_max;
- /*
- * Current wish of the slave. May only change in response to
- * ioctls that affect image capture.
- */
u32 clock_curr;
};
@@ -165,13 +133,7 @@
} u;
};
-/* IOCTL command numbers. */
enum v4l2_int_ioctl_num {
- /*
- *
- * "Proper" V4L ioctls, as in struct video_device.
- *
- */
vidioc_int_enum_fmt_cap_num = 1,
vidioc_int_g_fmt_cap_num,
vidioc_int_s_fmt_cap_num,
@@ -188,54 +150,30 @@
vidioc_int_s_std_num,
vidioc_int_s_video_routing_num,
- /*
- *
- * Strictly internal ioctls.
- *
- */
- /* Initialise the device when slave attaches to the master. */
+
vidioc_int_dev_init_num = 1000,
- /* Delinitialise the device at slave detach. */
+
vidioc_int_dev_exit_num,
- /* Set device power state. */
+
vidioc_int_s_power_num,
- /*
- * Get slave private data, e.g. platform-specific slave
- * configuration used by the master.
- */
vidioc_int_g_priv_num,
- /* Get slave interface parameters. */
+
vidioc_int_g_ifparm_num,
- /* Does the slave need to be reset after VIDIOC_DQBUF? */
+
vidioc_int_g_needs_reset_num,
vidioc_int_enum_framesizes_num,
vidioc_int_enum_frameintervals_num,
- /*
- *
- * VIDIOC_INT_* ioctls.
- *
- */
- /* VIDIOC_INT_RESET */
+
vidioc_int_reset_num,
- /* VIDIOC_INT_INIT */
+
vidioc_int_init_num,
- /* VIDIOC_DBG_G_CHIP_IDENT */
+
vidioc_int_g_chip_ident_num,
- /*
- *
- * Start of private ioctls.
- *
- */
vidioc_int_priv_start_num = 2000,
};
-/*
- *
- * IOCTL wrapper functions for better type checking.
- *
- */
#define V4L2_INT_WRAPPER_0(name) \
static inline int vidioc_int_##name(struct v4l2_int_device *d) \
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 3cb939c..7209cda 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -1,35 +1,28 @@
-/*
- *
- * V 4 L 2 D R I V E R H E L P E R A P I
- *
- * Moved from videodev2.h
- *
- * Some commonly needed functions for drivers (v4l2-common.o module)
- */
#ifndef _V4L2_IOCTL_H
#define _V4L2_IOCTL_H
#include <linux/poll.h>
#include <linux/fs.h>
+#include <linux/device.h>
#include <linux/mutex.h>
-#include <linux/compiler.h> /* need __user */
+#include <linux/compiler.h>
#include <linux/videodev2.h>
struct v4l2_fh;
struct v4l2_ioctl_ops {
- /* ioctl callbacks */
+
- /* VIDIOC_QUERYCAP handler */
+
int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
- /* Priority handling */
+
int (*vidioc_g_priority) (struct file *file, void *fh,
enum v4l2_priority *p);
int (*vidioc_s_priority) (struct file *file, void *fh,
enum v4l2_priority p);
- /* VIDIOC_ENUM_FMT handlers */
+
int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
struct v4l2_fmtdesc *f);
int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
@@ -43,7 +36,7 @@
int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
struct v4l2_fmtdesc *f);
- /* VIDIOC_G_FMT handlers */
+
int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
struct v4l2_format *f);
int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
@@ -67,7 +60,7 @@
int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
struct v4l2_format *f);
- /* VIDIOC_S_FMT handlers */
+
int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
struct v4l2_format *f);
int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
@@ -91,7 +84,7 @@
int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
struct v4l2_format *f);
- /* VIDIOC_TRY_FMT handlers */
+
int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
struct v4l2_format *f);
int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
@@ -115,14 +108,12 @@
int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
struct v4l2_format *f);
- /* Buffer handlers */
+
int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
- int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b);
- int (*vidioc_prepare_buf)(struct file *file, void *fh, struct v4l2_buffer *b);
int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
int (*vidioc_g_fbuf) (struct file *file, void *fh,
@@ -130,30 +121,27 @@
int (*vidioc_s_fbuf) (struct file *file, void *fh,
struct v4l2_framebuffer *a);
- /* Stream on/off */
+
int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
- /* Standard handling
- ENUMSTD is handled by videodev.c
- */
int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
- /* Input handling */
+
int (*vidioc_enum_input)(struct file *file, void *fh,
struct v4l2_input *inp);
int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
- /* Output handling */
+
int (*vidioc_enum_output) (struct file *file, void *fh,
struct v4l2_output *a);
int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
- /* Control handling */
+
int (*vidioc_queryctrl) (struct file *file, void *fh,
struct v4l2_queryctrl *a);
int (*vidioc_g_ctrl) (struct file *file, void *fh,
@@ -169,7 +157,7 @@
int (*vidioc_querymenu) (struct file *file, void *fh,
struct v4l2_querymenu *a);
- /* Audio ioctls */
+
int (*vidioc_enumaudio) (struct file *file, void *fh,
struct v4l2_audio *a);
int (*vidioc_g_audio) (struct file *file, void *fh,
@@ -177,7 +165,7 @@
int (*vidioc_s_audio) (struct file *file, void *fh,
struct v4l2_audio *a);
- /* Audio out ioctls */
+
int (*vidioc_enumaudout) (struct file *file, void *fh,
struct v4l2_audioout *a);
int (*vidioc_g_audout) (struct file *file, void *fh,
@@ -188,18 +176,14 @@
struct v4l2_modulator *a);
int (*vidioc_s_modulator) (struct file *file, void *fh,
struct v4l2_modulator *a);
- /* Crop ioctls */
+
int (*vidioc_cropcap) (struct file *file, void *fh,
struct v4l2_cropcap *a);
int (*vidioc_g_crop) (struct file *file, void *fh,
struct v4l2_crop *a);
int (*vidioc_s_crop) (struct file *file, void *fh,
struct v4l2_crop *a);
- int (*vidioc_g_selection) (struct file *file, void *fh,
- struct v4l2_selection *s);
- int (*vidioc_s_selection) (struct file *file, void *fh,
- struct v4l2_selection *s);
- /* Compression ioctls */
+
int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
struct v4l2_jpegcompression *a);
int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
@@ -210,18 +194,14 @@
struct v4l2_encoder_cmd *a);
int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
struct v4l2_encoder_cmd *a);
- int (*vidioc_decoder_cmd) (struct file *file, void *fh,
- struct v4l2_decoder_cmd *a);
- int (*vidioc_try_decoder_cmd) (struct file *file, void *fh,
- struct v4l2_decoder_cmd *a);
- /* Stream type-dependent parameter ioctls */
+
int (*vidioc_g_parm) (struct file *file, void *fh,
struct v4l2_streamparm *a);
int (*vidioc_s_parm) (struct file *file, void *fh,
struct v4l2_streamparm *a);
- /* Tuner ioctls */
+
int (*vidioc_g_tuner) (struct file *file, void *fh,
struct v4l2_tuner *a);
int (*vidioc_s_tuner) (struct file *file, void *fh,
@@ -231,17 +211,17 @@
int (*vidioc_s_frequency) (struct file *file, void *fh,
struct v4l2_frequency *a);
- /* Sliced VBI cap */
+
int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
struct v4l2_sliced_vbi_cap *a);
- /* Log status ioctl */
+
int (*vidioc_log_status) (struct file *file, void *fh);
int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
struct v4l2_hw_freq_seek *a);
- /* Debugging ioctls */
+
#ifdef CONFIG_VIDEO_ADV_DEBUG
int (*vidioc_g_register) (struct file *file, void *fh,
struct v4l2_dbg_register *reg);
@@ -257,7 +237,7 @@
int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
struct v4l2_frmivalenum *fival);
- /* DV Timings IOCTLs */
+
int (*vidioc_enum_dv_presets) (struct file *file, void *fh,
struct v4l2_dv_enum_preset *preset);
@@ -277,47 +257,38 @@
int (*vidioc_unsubscribe_event)(struct v4l2_fh *fh,
struct v4l2_event_subscription *sub);
- /* For other private ioctls */
+
long (*vidioc_default) (struct file *file, void *fh,
bool valid_prio, int cmd, void *arg);
};
-/* v4l debugging and diagnostics */
-/* Debug bitmask flags to be used on V4L2 */
#define V4L2_DEBUG_IOCTL 0x01
#define V4L2_DEBUG_IOCTL_ARG 0x02
-/* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */
#define v4l_print_ioctl(name, cmd) \
do { \
printk(KERN_DEBUG "%s: ", name); \
v4l_printk_ioctl(cmd); \
} while (0)
-/* Use this macro in I2C drivers where 'client' is the struct i2c_client
- pointer */
#define v4l_i2c_print_ioctl(client, cmd) \
do { \
v4l_client_printk(KERN_DEBUG, client, ""); \
v4l_printk_ioctl(cmd); \
} while (0)
-/* Video standard functions */
extern const char *v4l2_norm_to_name(v4l2_std_id id);
extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
extern int v4l2_video_std_construct(struct v4l2_standard *vs,
int id, const char *name);
-/* Prints the ioctl in a human-readable format */
extern void v4l_printk_ioctl(unsigned int cmd);
-/* names for fancy debug output */
extern const char *v4l2_field_names[];
extern const char *v4l2_type_names[];
#ifdef CONFIG_COMPAT
-/* 32 Bits compatibility layer for 64 bits processors */
extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
unsigned long arg);
#endif
@@ -325,12 +296,10 @@
typedef long (*v4l2_kioctl)(struct file *file,
unsigned int cmd, void *arg);
-/* Include support for obsoleted stuff */
extern long video_usercopy(struct file *file, unsigned int cmd,
unsigned long arg, v4l2_kioctl func);
-/* Standard handlers for V4L ioctl's */
extern long video_ioctl2(struct file *file,
unsigned int cmd, unsigned long arg);
-#endif /* _V4L2_IOCTL_H */
+#endif
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 83ae07e..971c7fa 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -13,77 +13,6 @@
#include <linux/v4l2-mediabus.h>
-/* Parallel flags */
-/*
- * Can the client run in master or in slave mode. By "Master mode" an operation
- * mode is meant, when the client (e.g., a camera sensor) is producing
- * horizontal and vertical synchronisation. In "Slave mode" the host is
- * providing these signals to the slave.
- */
-#define V4L2_MBUS_MASTER (1 << 0)
-#define V4L2_MBUS_SLAVE (1 << 1)
-/*
- * Signal polarity flags
- * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused
- * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying
- * configuration of hardware that uses [HV]REF signals
- */
-#define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2)
-#define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3)
-#define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4)
-#define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5)
-#define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6)
-#define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7)
-#define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8)
-#define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9)
-/* FIELD = 0/1 - Field1 (odd)/Field2 (even) */
-#define V4L2_MBUS_FIELD_EVEN_HIGH (1 << 10)
-/* FIELD = 1/0 - Field1 (odd)/Field2 (even) */
-#define V4L2_MBUS_FIELD_EVEN_LOW (1 << 11)
-
-/* Serial flags */
-/* How many lanes the client can use */
-#define V4L2_MBUS_CSI2_1_LANE (1 << 0)
-#define V4L2_MBUS_CSI2_2_LANE (1 << 1)
-#define V4L2_MBUS_CSI2_3_LANE (1 << 2)
-#define V4L2_MBUS_CSI2_4_LANE (1 << 3)
-/* On which channels it can send video data */
-#define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4)
-#define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5)
-#define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6)
-#define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7)
-/* Does it support only continuous or also non-continuous clock mode */
-#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8)
-#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9)
-
-#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
- V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
-#define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
- V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3)
-
-/**
- * v4l2_mbus_type - media bus type
- * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
- * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can
- * also be used for BT.1120
- * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
- */
-enum v4l2_mbus_type {
- V4L2_MBUS_PARALLEL,
- V4L2_MBUS_BT656,
- V4L2_MBUS_CSI2,
-};
-
-/**
- * v4l2_mbus_config - media bus configuration
- * @type: in: interface type
- * @flags: in / out: configuration flags, depending on @type
- */
-struct v4l2_mbus_config {
- enum v4l2_mbus_type type;
- unsigned int flags;
-};
-
static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
const struct v4l2_mbus_framefmt *mbus_fmt)
{
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index f0f3358..defd4bc 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -28,7 +28,6 @@
#include <media/v4l2-fh.h>
#include <media/v4l2-mediabus.h>
-/* generic v4l2_device notify callback notification values */
#define V4L2_SUBDEV_IR_RX_NOTIFY _IOW('v', 0, u32)
#define V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ 0x00000001
#define V4L2_SUBDEV_IR_RX_END_OF_RX_DETECTED 0x00000002
@@ -46,102 +45,29 @@
struct v4l2_subdev_fh;
struct tuner_setup;
-/* decode_vbi_line */
struct v4l2_decode_vbi_line {
- u32 is_second_field; /* Set to 0 for the first (odd) field,
- set to 1 for the second (even) field. */
- u8 *p; /* Pointer to the sliced VBI data from the decoder.
- On exit points to the start of the payload. */
- u32 line; /* Line number of the sliced VBI data (1-23) */
- u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */
+ u32 is_second_field;
+ u8 *p;
+ u32 line;
+ u32 type;
};
-/* Sub-devices are devices that are connected somehow to the main bridge
- device. These devices are usually audio/video muxers/encoders/decoders or
- sensors and webcam controllers.
- Usually these devices are controlled through an i2c bus, but other busses
- may also be used.
- The v4l2_subdev struct provides a way of accessing these devices in a
- generic manner. Most operations that these sub-devices support fall in
- a few categories: core ops, audio ops, video ops and tuner ops.
-
- More categories can be added if needed, although this should remain a
- limited set (no more than approx. 8 categories).
-
- Each category has its own set of ops that subdev drivers can implement.
-
- A subdev driver can leave the pointer to the category ops NULL if
- it does not implement them (e.g. an audio subdev will generally not
- implement the video category ops). The exception is the core category:
- this must always be present.
-
- These ops are all used internally so it is no problem to change, remove
- or add ops or move ops from one to another category. Currently these
- ops are based on the original ioctls, but since ops are not limited to
- one argument there is room for improvement here once all i2c subdev
- drivers are converted to use these ops.
- */
-
-/* Core ops: it is highly recommended to implement at least these ops:
-
- g_chip_ident
- log_status
- g_register
- s_register
-
- This provides basic debugging support.
-
- The ioctl ops is meant for generic ioctl-like commands. Depending on
- the use-case it might be better to use subdev-specific ops (currently
- not yet implemented) since ops provide proper type-checking.
- */
-
-/* Subdevice external IO pin configuration */
-#define V4L2_SUBDEV_IO_PIN_DISABLE (1 << 0) /* ENABLE assumed */
+#define V4L2_SUBDEV_IO_PIN_DISABLE (1 << 0)
#define V4L2_SUBDEV_IO_PIN_OUTPUT (1 << 1)
#define V4L2_SUBDEV_IO_PIN_INPUT (1 << 2)
-#define V4L2_SUBDEV_IO_PIN_SET_VALUE (1 << 3) /* Set output value */
-#define V4L2_SUBDEV_IO_PIN_ACTIVE_LOW (1 << 4) /* ACTIVE HIGH assumed */
+#define V4L2_SUBDEV_IO_PIN_SET_VALUE (1 << 3)
+#define V4L2_SUBDEV_IO_PIN_ACTIVE_LOW (1 << 4)
struct v4l2_subdev_io_pin_config {
- u32 flags; /* V4L2_SUBDEV_IO_PIN_* flags for this pin's config */
- u8 pin; /* Chip external IO pin to configure */
- u8 function; /* Internal signal pad/function to route to IO pin */
- u8 value; /* Initial value for pin - e.g. GPIO output value */
- u8 strength; /* Pin drive strength */
+ u32 flags;
+ u8 pin;
+ u8 function;
+ u8 value;
+ u8 strength;
};
-/*
- s_io_pin_config: configure one or more chip I/O pins for chips that
- multiplex different internal signal pads out to IO pins. This function
- takes a pointer to an array of 'n' pin configuration entries, one for
- each pin being configured. This function could be called at times
- other than just subdevice initialization.
-
- init: initialize the sensor registors to some sort of reasonable default
- values. Do not use for new drivers and should be removed in existing
- drivers.
-
- load_fw: load firmware.
-
- reset: generic reset command. The argument selects which subsystems to
- reset. Passing 0 will always reset the whole chip. Do not use for new
- drivers without discussing this first on the linux-media mailinglist.
- There should be no reason normally to reset a device.
-
- s_gpio: set GPIO pins. Very simple right now, might need to be extended with
- a direction argument if needed.
-
- s_power: puts subdevice in power saving mode (on == 0) or normal operation
- mode (on == 1).
-
- interrupt_service_routine: Called by the bridge chip's interrupt service
- handler, when an interrupt status has be raised due to this subdev,
- so that this subdev can handle the details. It may schedule work to be
- performed later. It must not sleep. *Called from an IRQ context*.
- */
struct v4l2_subdev_core_ops {
int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
int (*log_status)(struct v4l2_subdev *sd);
@@ -158,7 +84,6 @@
int (*s_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls);
int (*try_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls);
int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
- int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm);
int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
#ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -174,19 +99,6 @@
struct v4l2_event_subscription *sub);
};
-/* s_radio: v4l device was opened in radio mode.
-
- g_frequency: freq->type must be filled in. Normally done by video_ioctl2
- or the bridge driver.
-
- g_tuner:
- s_tuner: vt->type must be filled in. Normally done by video_ioctl2 or the
- bridge driver.
-
- s_type_addr: sets tuner type and its I2C addr.
-
- s_config: sets tda9887 specific stuff, like port1, port2 and qss
- */
struct v4l2_subdev_tuner_ops {
int (*s_radio)(struct v4l2_subdev *sd);
int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
@@ -199,26 +111,6 @@
int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
};
-/* s_clock_freq: set the frequency (in Hz) of the audio clock output.
- Used to slave an audio processor to the video decoder, ensuring that
- audio and video remain synchronized. Usual values for the frequency
- are 48000, 44100 or 32000 Hz. If the frequency is not supported, then
- -EINVAL is returned.
-
- s_i2s_clock_freq: sets I2S speed in bps. This is used to provide a standard
- way to select I2S clock used by driving digital audio streams at some
- board designs. Usual values for the frequency are 1024000 and 2048000.
- If the frequency is not supported, then -EINVAL is returned.
-
- s_routing: used to define the input and/or output pins of an audio chip,
- and any additional configuration data.
- Never attempt to use user-level input IDs (e.g. Composite, S-Video,
- Tuner) at this level. An i2c device shouldn't know about whether an
- input pin is connected to a Composite connector, become on another
- board or platform it might be connected to something else entirely.
- The calling driver is responsible for mapping a user-level input to
- the right pins on the i2c device.
- */
struct v4l2_subdev_audio_ops {
int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
@@ -226,62 +118,11 @@
int (*s_stream)(struct v4l2_subdev *sd, int enable);
};
-/*
- s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
- video input devices.
-
- g_std_output: get current standard for video OUTPUT devices. This is ignored
- by video input devices.
-
- g_tvnorms_output: get v4l2_std_id with all standards supported by video
- OUTPUT device. This is ignored by video input devices.
-
- s_crystal_freq: sets the frequency of the crystal used to generate the
- clocks in Hz. An extra flags field allows device specific configuration
- regarding clock frequency dividers, etc. If not used, then set flags
- to 0. If the frequency is not supported, then -EINVAL is returned.
-
- g_input_status: get input status. Same as the status field in the v4l2_input
- struct.
-
- s_routing: see s_routing in audio_ops, except this version is for video
- devices.
-
- s_dv_preset: set dv (Digital Video) preset in the sub device. Similar to
- s_std()
-
- g_dv_preset: get current dv (Digital Video) preset in the sub device.
-
- query_dv_preset: query dv preset in the sub device. This is similar to
- querystd()
-
- s_dv_timings(): Set custom dv timings in the sub device. This is used
- when sub device is capable of setting detailed timing information
- in the hardware to generate/detect the video signal.
-
- g_dv_timings(): Get custom dv timings in the sub device.
-
- enum_mbus_fmt: enumerate pixel formats, provided by a video data source
-
- g_mbus_fmt: get the current pixel format, provided by a video data source
-
- try_mbus_fmt: try to set a pixel format on a video data source
-
- s_mbus_fmt: set a pixel format on a video data source
-
- g_mbus_config: get supported mediabus configurations
-
- s_mbus_config: set a certain mediabus configuration. This operation is added
- for compatibility with soc-camera drivers and should not be used by new
- software.
- */
struct v4l2_subdev_video_ops {
int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags);
int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
- int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
- int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std);
int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
int (*s_stream)(struct v4l2_subdev *sd, int enable);
int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc);
@@ -299,8 +140,6 @@
struct v4l2_dv_enum_preset *preset);
int (*s_dv_preset)(struct v4l2_subdev *sd,
struct v4l2_dv_preset *preset);
- int (*g_dv_preset)(struct v4l2_subdev *sd,
- struct v4l2_dv_preset *preset);
int (*query_dv_preset)(struct v4l2_subdev *sd,
struct v4l2_dv_preset *preset);
int (*s_dv_timings)(struct v4l2_subdev *sd,
@@ -317,41 +156,8 @@
struct v4l2_mbus_framefmt *fmt);
int (*s_mbus_fmt)(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *fmt);
- int (*g_mbus_config)(struct v4l2_subdev *sd,
- struct v4l2_mbus_config *cfg);
- int (*s_mbus_config)(struct v4l2_subdev *sd,
- const struct v4l2_mbus_config *cfg);
};
-/*
- decode_vbi_line: video decoders that support sliced VBI need to implement
- this ioctl. Field p of the v4l2_sliced_vbi_line struct is set to the
- start of the VBI data that was generated by the decoder. The driver
- then parses the sliced VBI data and sets the other fields in the
- struct accordingly. The pointer p is updated to point to the start of
- the payload which can be copied verbatim into the data field of the
- v4l2_sliced_vbi_data struct. If no valid VBI data was found, then the
- type field is set to 0 on return.
-
- s_vbi_data: used to generate VBI signals on a video signal.
- v4l2_sliced_vbi_data is filled with the data packets that should be
- output. Note that if you set the line field to 0, then that VBI signal
- is disabled. If no valid VBI data was found, then the type field is
- set to 0 on return.
-
- g_vbi_data: used to obtain the sliced VBI packet from a readback register.
- Not all video decoders support this. If no data is available because
- the readback register contains invalid or erroneous data -EIO is
- returned. Note that you must fill in the 'id' member and the 'field'
- member (to determine whether CC data from the first or second field
- should be obtained).
-
- s_raw_fmt: setup the video encoder/decoder for raw VBI.
-
- g_sliced_fmt: retrieve the current sliced VBI settings.
-
- s_sliced_fmt: setup the sliced VBI settings.
- */
struct v4l2_subdev_vbi_ops {
int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
@@ -362,75 +168,43 @@
int (*s_sliced_fmt)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
};
-/**
- * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations
- * @g_skip_top_lines: number of lines at the top of the image to be skipped.
- * This is needed for some sensors, which always corrupt
- * several top lines of the output image, or which send their
- * metadata in them.
- * @g_skip_frames: number of frames to skip at stream start. This is needed for
- * buggy sensors that generate faulty frames when they are
- * turned on.
- */
struct v4l2_subdev_sensor_ops {
int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
};
-/*
- [rt]x_g_parameters: Get the current operating parameters and state of the
- the IR receiver or transmitter.
-
- [rt]x_s_parameters: Set the current operating parameters and state of the
- the IR receiver or transmitter. It is recommended to call
- [rt]x_g_parameters first to fill out the current state, and only change
- the fields that need to be changed. Upon return, the actual device
- operating parameters and state will be returned. Note that hardware
- limitations may prevent the actual settings from matching the requested
- settings - e.g. an actual carrier setting of 35,904 Hz when 36,000 Hz
- was requested. An exception is when the shutdown parameter is true.
- The last used operational parameters will be returned, but the actual
- state of the hardware be different to minimize power consumption and
- processing when shutdown is true.
-
- rx_read: Reads received codes or pulse width data.
- The semantics are similar to a non-blocking read() call.
-
- tx_write: Writes codes or pulse width data for transmission.
- The semantics are similar to a non-blocking write() call.
- */
enum v4l2_subdev_ir_mode {
- V4L2_SUBDEV_IR_MODE_PULSE_WIDTH, /* uses struct ir_raw_event records */
+ V4L2_SUBDEV_IR_MODE_PULSE_WIDTH,
};
struct v4l2_subdev_ir_parameters {
- /* Either Rx or Tx */
- unsigned int bytes_per_data_element; /* of data in read or write call */
+
+ unsigned int bytes_per_data_element;
enum v4l2_subdev_ir_mode mode;
bool enable;
bool interrupt_enable;
- bool shutdown; /* true: set hardware to low/no power, false: normal */
+ bool shutdown;
- bool modulation; /* true: uses carrier, false: baseband */
- u32 max_pulse_width; /* ns, valid only for baseband signal */
- unsigned int carrier_freq; /* Hz, valid only for modulated signal*/
- unsigned int duty_cycle; /* percent, valid only for modulated signal*/
- bool invert_level; /* invert signal level */
+ bool modulation;
+ u32 max_pulse_width;
+ unsigned int carrier_freq;
+ unsigned int duty_cycle;
+ bool invert_level;
- /* Tx only */
- bool invert_carrier_sense; /* Send 0/space as a carrier burst */
+
+ bool invert_carrier_sense;
- /* Rx only */
- u32 noise_filter_min_width; /* ns, min time of a valid pulse */
- unsigned int carrier_range_lower; /* Hz, valid only for modulated sig */
- unsigned int carrier_range_upper; /* Hz, valid only for modulated sig */
- u32 resolution; /* ns */
+
+ u32 noise_filter_min_width;
+ unsigned int carrier_range_lower;
+ unsigned int carrier_range_upper;
+ u32 resolution;
};
struct v4l2_subdev_ir_ops {
- /* Receiver */
+
int (*rx_read)(struct v4l2_subdev *sd, u8 *buf, size_t count,
ssize_t *num);
@@ -439,7 +213,7 @@
int (*rx_s_parameters)(struct v4l2_subdev *sd,
struct v4l2_subdev_ir_parameters *params);
- /* Transmitter */
+
int (*tx_write)(struct v4l2_subdev *sd, u8 *buf, size_t count,
ssize_t *num);
@@ -479,20 +253,6 @@
const struct v4l2_subdev_pad_ops *pad;
};
-/*
- * Internal ops. Never call this from drivers, only the v4l2 framework can call
- * these ops.
- *
- * registered: called when this subdev is registered. When called the v4l2_dev
- * field is set to the correct v4l2_device.
- *
- * unregistered: called when this subdev is unregistered. When called the
- * v4l2_dev field is still set to the correct v4l2_device.
- *
- * open: called when the subdev device node is opened by an application.
- *
- * close: called when the subdev device node is closed.
- */
struct v4l2_subdev_internal_ops {
int (*registered)(struct v4l2_subdev *sd);
void (*unregistered)(struct v4l2_subdev *sd);
@@ -502,18 +262,11 @@
#define V4L2_SUBDEV_NAME_SIZE 32
-/* Set this flag if this subdev is a i2c device. */
#define V4L2_SUBDEV_FL_IS_I2C (1U << 0)
-/* Set this flag if this subdev is a spi device. */
#define V4L2_SUBDEV_FL_IS_SPI (1U << 1)
-/* Set this flag if this subdev needs a device node. */
#define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2)
-/* Set this flag if this subdev generates events. */
#define V4L2_SUBDEV_FL_HAS_EVENTS (1U << 3)
-/* Each instance of a subdev driver should create this struct, either
- stand-alone or embedded in a larger struct.
- */
struct v4l2_subdev {
#if defined(CONFIG_MEDIA_CONTROLLER)
struct media_entity entity;
@@ -523,29 +276,28 @@
u32 flags;
struct v4l2_device *v4l2_dev;
const struct v4l2_subdev_ops *ops;
- /* Never call these internal ops from within a driver! */
+
const struct v4l2_subdev_internal_ops *internal_ops;
- /* The control handler of this subdev. May be NULL. */
+
struct v4l2_ctrl_handler *ctrl_handler;
- /* name must be unique */
+
char name[V4L2_SUBDEV_NAME_SIZE];
- /* can be used to group similar subdevs, value is driver-specific */
+
u32 grp_id;
- /* pointer to private data */
+
void *dev_priv;
void *host_priv;
- /* subdev device node */
- struct video_device *devnode;
+
+ struct video_device devnode;
+
+ unsigned int nevents;
};
#define media_entity_to_v4l2_subdev(ent) \
container_of(ent, struct v4l2_subdev, entity)
#define vdev_to_v4l2_subdev(vdev) \
- video_get_drvdata(vdev)
+ container_of(vdev, struct v4l2_subdev, devnode)
-/*
- * Used for storing subdev information per file handle
- */
struct v4l2_subdev_fh {
struct v4l2_fh vfh;
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
@@ -596,16 +348,10 @@
void v4l2_subdev_init(struct v4l2_subdev *sd,
const struct v4l2_subdev_ops *ops);
-/* Call an ops of a v4l2_subdev, doing the right checks against
- NULL pointers.
-
- Example: err = v4l2_subdev_call(sd, core, g_chip_ident, &chip);
- */
#define v4l2_subdev_call(sd, o, f, args...) \
- (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \
+ (!(sd) ? -ENODEV : (((sd)->ops && (sd)->ops->o && (sd)->ops->o->f) ? \
(sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD))
-/* Send a notification to v4l2_device. */
#define v4l2_subdev_notify(sd, notification, arg) \
((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
(sd)->v4l2_dev->notify((sd), (notification), (arg)))