aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/video4linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-24 13:21:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-24 13:21:51 -0400
commitab11ca34eea8fda7a1a9302d86f6ef6108ffd68f (patch)
tree987ec6c263f3dfa4a7a6f9ce4d5ece47cbc12e29 /Documentation/video4linux
parentf9369910a6225b8d4892c3f20ae740a711cd5ace (diff)
parent71006fb22b0f5a2045605b3887ee99a0e9adafe4 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - some V4L2 API updates needed by embedded devices - DVB API extensions for ATSC-MH delivery system, used in US for mobile TV - new tuners for fc0011/0012/0013 and tua9001 - a new dvb driver for af9033/9035 - a new ATSC-MH frontend (lg2160) - new remote controller keymaps - Removal of a few legacy webcam driver that got replaced by gspca on several kernel versions ago - a new driver for Exynos 4/5 webcams(s5pp fimc-lite) - a new webcam sensor driver (smiapp) - a new video input driver for embedded (sta2x1xx) - several improvements, fixes, cleanups, etc inside the drivers. Manually fix up conflicts due to err() -> dev_err() conversion in drivers/staging/media/easycap/easycap_main.c * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (484 commits) [media] saa7134-cards: Remove a PCI entry added by mistake [media] radio-sf16fmi: add support for SF16-FMD [media] rc-loopback: remove duplicate line [media] patch for Asus My Cinema PS3-100 (1043:48cd) [media] au0828: Move the Kconfig knob under V4L_USB_DRIVERS [media] em28xx: simple comment fix [media] [resend] radio-sf16fmr2: add PnP support for SF16-FMD2 [media] smiapp: Use v4l2_ctrl_new_int_menu() instead of v4l2_ctrl_new_custom() [media] smiapp: Add support for 8-bit uncompressed formats [media] smiapp: Allow generic quirk registers [media] smiapp: Use non-binning limits if the binning limit is zero [media] smiapp: Initialise rval in smiapp_read_nvm() [media] smiapp: Round minimum pre_pll up rather than down in ip_clk_freq check [media] smiapp: Use 8-bit reads only before identifying the sensor [media] smiapp: Quirk for sensors that only do 8-bit reads [media] smiapp: Pass struct sensor to register writing commands instead of i2c_client [media] smiapp: Allow using external clock from the clock framework [media] zl10353: change .read_snr() to report SNR as a 0.1 dB [media] media: add support to gspca/pac7302.c for 093a:2627 (Genius FaceCam 300) [media] m88rs2000 - only flip bit 2 on reg 0x70 on 16th try ...
Diffstat (limited to 'Documentation/video4linux')
-rw-r--r--Documentation/video4linux/4CCs.txt32
-rw-r--r--Documentation/video4linux/gspca.txt1
-rw-r--r--Documentation/video4linux/v4l2-controls.txt21
-rw-r--r--Documentation/video4linux/v4l2-framework.txt106
4 files changed, 142 insertions, 18 deletions
diff --git a/Documentation/video4linux/4CCs.txt b/Documentation/video4linux/4CCs.txt
new file mode 100644
index 000000000000..41241af1ebfe
--- /dev/null
+++ b/Documentation/video4linux/4CCs.txt
@@ -0,0 +1,32 @@
1Guidelines for Linux4Linux pixel format 4CCs
2============================================
3
4Guidelines for Video4Linux 4CC codes defined using v4l2_fourcc() are
5specified in this document. First of the characters defines the nature of
6the pixel format, compression and colour space. The interpretation of the
7other three characters depends on the first one.
8
9Existing 4CCs may not obey these guidelines.
10
11Formats
12=======
13
14Raw bayer
15---------
16
17The following first characters are used by raw bayer formats:
18
19 B: raw bayer, uncompressed
20 b: raw bayer, DPCM compressed
21 a: A-law compressed
22 u: u-law compressed
23
242nd character: pixel order
25 B: BGGR
26 G: GBRG
27 g: GRBG
28 R: RGGB
29
303rd character: uncompressed bits-per-pixel 0--9, A--
31
324th character: compressed bits-per-pixel 0--9, A--
diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt
index e6c2842407a4..1e6b6531bbcc 100644
--- a/Documentation/video4linux/gspca.txt
+++ b/Documentation/video4linux/gspca.txt
@@ -276,6 +276,7 @@ pac7302 093a:2622 Genius Eye 312
276pac7302 093a:2624 PAC7302 276pac7302 093a:2624 PAC7302
277pac7302 093a:2625 Genius iSlim 310 277pac7302 093a:2625 Genius iSlim 310
278pac7302 093a:2626 Labtec 2200 278pac7302 093a:2626 Labtec 2200
279pac7302 093a:2627 Genius FaceCam 300
279pac7302 093a:2628 Genius iLook 300 280pac7302 093a:2628 Genius iLook 300
280pac7302 093a:2629 Genious iSlim 300 281pac7302 093a:2629 Genious iSlim 300
281pac7302 093a:262a Webcam 300k 282pac7302 093a:262a Webcam 300k
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt
index e2492a9d1027..43da22b89728 100644
--- a/Documentation/video4linux/v4l2-controls.txt
+++ b/Documentation/video4linux/v4l2-controls.txt
@@ -130,8 +130,18 @@ Menu controls are added by calling v4l2_ctrl_new_std_menu:
130 const struct v4l2_ctrl_ops *ops, 130 const struct v4l2_ctrl_ops *ops,
131 u32 id, s32 max, s32 skip_mask, s32 def); 131 u32 id, s32 max, s32 skip_mask, s32 def);
132 132
133Or alternatively for integer menu controls, by calling v4l2_ctrl_new_int_menu:
134
135 struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
136 const struct v4l2_ctrl_ops *ops,
137 u32 id, s32 max, s32 def, const s64 *qmenu_int);
138
133These functions are typically called right after the v4l2_ctrl_handler_init: 139These functions are typically called right after the v4l2_ctrl_handler_init:
134 140
141 static const s64 exp_bias_qmenu[] = {
142 -2, -1, 0, 1, 2
143 };
144
135 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls); 145 v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls);
136 v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops, 146 v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops,
137 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); 147 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
@@ -141,6 +151,11 @@ These functions are typically called right after the v4l2_ctrl_handler_init:
141 V4L2_CID_POWER_LINE_FREQUENCY, 151 V4L2_CID_POWER_LINE_FREQUENCY,
142 V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0, 152 V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0,
143 V4L2_CID_POWER_LINE_FREQUENCY_DISABLED); 153 V4L2_CID_POWER_LINE_FREQUENCY_DISABLED);
154 v4l2_ctrl_new_int_menu(&foo->ctrl_handler, &foo_ctrl_ops,
155 V4L2_CID_EXPOSURE_BIAS,
156 ARRAY_SIZE(exp_bias_qmenu) - 1,
157 ARRAY_SIZE(exp_bias_qmenu) / 2 - 1,
158 exp_bias_qmenu);
144 ... 159 ...
145 if (foo->ctrl_handler.error) { 160 if (foo->ctrl_handler.error) {
146 int err = foo->ctrl_handler.error; 161 int err = foo->ctrl_handler.error;
@@ -164,6 +179,12 @@ controls. There is no min argument since that is always 0 for menu controls,
164and instead of a step there is a skip_mask argument: if bit X is 1, then menu 179and instead of a step there is a skip_mask argument: if bit X is 1, then menu
165item X is skipped. 180item X is skipped.
166 181
182The v4l2_ctrl_new_int_menu function creates a new standard integer menu
183control with driver-specific items in the menu. It differs from
184v4l2_ctrl_new_std_menu in that it doesn't have the mask argument and takes
185as the last argument an array of signed 64-bit integers that form an exact
186menu item list.
187
167Note that if something fails, the function will return NULL or an error and 188Note that if something fails, the function will return NULL or an error and
168set ctrl_handler->error to the error code. If ctrl_handler->error was already 189set ctrl_handler->error to the error code. If ctrl_handler->error was already
169set, then it will just return and do nothing. This is also true for 190set, then it will just return and do nothing. This is also true for
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 659b2ba12a4f..1f5905270050 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -182,11 +182,11 @@ static int __devinit drv_probe(struct pci_dev *pdev,
182} 182}
183 183
184If you have multiple device nodes then it can be difficult to know when it is 184If you have multiple device nodes then it can be difficult to know when it is
185safe to unregister v4l2_device. For this purpose v4l2_device has refcounting 185safe to unregister v4l2_device for hotpluggable devices. For this purpose
186support. The refcount is increased whenever video_register_device is called and 186v4l2_device has refcounting support. The refcount is increased whenever
187it is decreased whenever that device node is released. When the refcount reaches 187video_register_device is called and it is decreased whenever that device node
188zero, then the v4l2_device release() callback is called. You can do your final 188is released. When the refcount reaches zero, then the v4l2_device release()
189cleanup there. 189callback is called. You can do your final cleanup there.
190 190
191If other device nodes (e.g. ALSA) are created, then you can increase and 191If other device nodes (e.g. ALSA) are created, then you can increase and
192decrease the refcount manually as well by calling: 192decrease the refcount manually as well by calling:
@@ -197,6 +197,10 @@ or:
197 197
198int v4l2_device_put(struct v4l2_device *v4l2_dev); 198int v4l2_device_put(struct v4l2_device *v4l2_dev);
199 199
200Since the initial refcount is 1 you also need to call v4l2_device_put in the
201disconnect() callback (for USB devices) or in the remove() callback (for e.g.
202PCI devices), otherwise the refcount will never reach 0.
203
200struct v4l2_subdev 204struct v4l2_subdev
201------------------ 205------------------
202 206
@@ -262,11 +266,16 @@ struct v4l2_subdev_video_ops {
262 ... 266 ...
263}; 267};
264 268
269struct v4l2_subdev_pad_ops {
270 ...
271};
272
265struct v4l2_subdev_ops { 273struct v4l2_subdev_ops {
266 const struct v4l2_subdev_core_ops *core; 274 const struct v4l2_subdev_core_ops *core;
267 const struct v4l2_subdev_tuner_ops *tuner; 275 const struct v4l2_subdev_tuner_ops *tuner;
268 const struct v4l2_subdev_audio_ops *audio; 276 const struct v4l2_subdev_audio_ops *audio;
269 const struct v4l2_subdev_video_ops *video; 277 const struct v4l2_subdev_video_ops *video;
278 const struct v4l2_subdev_pad_ops *video;
270}; 279};
271 280
272The core ops are common to all subdevs, the other categories are implemented 281The core ops are common to all subdevs, the other categories are implemented
@@ -303,6 +312,22 @@ Don't forget to cleanup the media entity before the sub-device is destroyed:
303 312
304 media_entity_cleanup(&sd->entity); 313 media_entity_cleanup(&sd->entity);
305 314
315If the subdev driver intends to process video and integrate with the media
316framework, it must implement format related functionality using
317v4l2_subdev_pad_ops instead of v4l2_subdev_video_ops.
318
319In that case, the subdev driver may set the link_validate field to provide
320its own link validation function. The link validation function is called for
321every link in the pipeline where both of the ends of the links are V4L2
322sub-devices. The driver is still responsible for validating the correctness
323of the format configuration between sub-devices and video nodes.
324
325If link_validate op is not set, the default function
326v4l2_subdev_link_validate_default() is used instead. This function ensures
327that width, height and the media bus pixel code are equal on both source and
328sink of the link. Subdev drivers are also free to use this function to
329perform the checks mentioned above in addition to their own checks.
330
306A device (bridge) driver needs to register the v4l2_subdev with the 331A device (bridge) driver needs to register the v4l2_subdev with the
307v4l2_device: 332v4l2_device:
308 333
@@ -555,19 +580,25 @@ allocated memory.
555You should also set these fields: 580You should also set these fields:
556 581
557- v4l2_dev: set to the v4l2_device parent device. 582- v4l2_dev: set to the v4l2_device parent device.
583
558- name: set to something descriptive and unique. 584- name: set to something descriptive and unique.
585
559- fops: set to the v4l2_file_operations struct. 586- fops: set to the v4l2_file_operations struct.
587
560- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance 588- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
561 (highly recommended to use this and it might become compulsory in the 589 (highly recommended to use this and it might become compulsory in the
562 future!), then set this to your v4l2_ioctl_ops struct. 590 future!), then set this to your v4l2_ioctl_ops struct.
591
563- lock: leave to NULL if you want to do all the locking in the driver. 592- lock: leave to NULL if you want to do all the locking in the driver.
564 Otherwise you give it a pointer to a struct mutex_lock and before any 593 Otherwise you give it a pointer to a struct mutex_lock and before the
565 of the v4l2_file_operations is called this lock will be taken by the 594 unlocked_ioctl file operation is called this lock will be taken by the
566 core and released afterwards. 595 core and released afterwards. See the next section for more details.
596
567- prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY. 597- prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY.
568 If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device. 598 If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device.
569 If you want to have a separate priority state per (group of) device node(s), 599 If you want to have a separate priority state per (group of) device node(s),
570 then you can point it to your own struct v4l2_prio_state. 600 then you can point it to your own struct v4l2_prio_state.
601
571- parent: you only set this if v4l2_device was registered with NULL as 602- parent: you only set this if v4l2_device was registered with NULL as
572 the parent device struct. This only happens in cases where one hardware 603 the parent device struct. This only happens in cases where one hardware
573 device has multiple PCI devices that all share the same v4l2_device core. 604 device has multiple PCI devices that all share the same v4l2_device core.
@@ -577,6 +608,7 @@ You should also set these fields:
577 (cx8802). Since the v4l2_device cannot be associated with a particular 608 (cx8802). Since the v4l2_device cannot be associated with a particular
578 PCI device it is setup without a parent device. But when the struct 609 PCI device it is setup without a parent device. But when the struct
579 video_device is setup you do know which parent PCI device to use. 610 video_device is setup you do know which parent PCI device to use.
611
580- flags: optional. Set to V4L2_FL_USE_FH_PRIO if you want to let the framework 612- flags: optional. Set to V4L2_FL_USE_FH_PRIO if you want to let the framework
581 handle the VIDIOC_G/S_PRIORITY ioctls. This requires that you use struct 613 handle the VIDIOC_G/S_PRIORITY ioctls. This requires that you use struct
582 v4l2_fh. Eventually this flag will disappear once all drivers use the core 614 v4l2_fh. Eventually this flag will disappear once all drivers use the core
@@ -587,6 +619,16 @@ in your v4l2_file_operations struct.
587 619
588Do not use .ioctl! This is deprecated and will go away in the future. 620Do not use .ioctl! This is deprecated and will go away in the future.
589 621
622In some cases you want to tell the core that a function you had specified in
623your v4l2_ioctl_ops should be ignored. You can mark such ioctls by calling this
624function before video_device_register is called:
625
626void v4l2_disable_ioctl(struct video_device *vdev, unsigned int cmd);
627
628This tends to be needed if based on external factors (e.g. which card is
629being used) you want to turns off certain features in v4l2_ioctl_ops without
630having to make a new struct.
631
590The v4l2_file_operations struct is a subset of file_operations. The main 632The v4l2_file_operations struct is a subset of file_operations. The main
591difference is that the inode argument is omitted since it is never used. 633difference is that the inode argument is omitted since it is never used.
592 634
@@ -609,8 +651,22 @@ v4l2_file_operations and locking
609-------------------------------- 651--------------------------------
610 652
611You can set a pointer to a mutex_lock in struct video_device. Usually this 653You can set a pointer to a mutex_lock in struct video_device. Usually this
612will be either a top-level mutex or a mutex per device node. If you want 654will be either a top-level mutex or a mutex per device node. By default this
613finer-grained locking then you have to set it to NULL and do you own locking. 655lock will be used for unlocked_ioctl, but you can disable locking for
656selected ioctls by calling:
657
658 void v4l2_disable_ioctl_locking(struct video_device *vdev, unsigned int cmd);
659
660E.g.: v4l2_disable_ioctl_locking(vdev, VIDIOC_DQBUF);
661
662You have to call this before you register the video_device.
663
664Particularly with USB drivers where certain commands such as setting controls
665can take a long time you may want to do your own locking for the buffer queuing
666ioctls.
667
668If you want still finer-grained locking then you have to set mutex_lock to NULL
669and do you own locking completely.
614 670
615It is up to the driver developer to decide which method to use. However, if 671It is up to the driver developer to decide which method to use. However, if
616your driver has high-latency operations (for example, changing the exposure 672your driver has high-latency operations (for example, changing the exposure
@@ -618,7 +674,7 @@ of a USB webcam might take a long time), then you might be better off with
618doing your own locking if you want to allow the user to do other things with 674doing your own locking if you want to allow the user to do other things with
619the device while waiting for the high-latency command to finish. 675the device while waiting for the high-latency command to finish.
620 676
621If a lock is specified then all file operations will be serialized on that 677If a lock is specified then all ioctl commands will be serialized on that
622lock. If you use videobuf then you must pass the same lock to the videobuf 678lock. If you use videobuf then you must pass the same lock to the videobuf
623queue initialize function: if videobuf has to wait for a frame to arrive, then 679queue initialize function: if videobuf has to wait for a frame to arrive, then
624it will temporarily unlock the lock and relock it afterwards. If your driver 680it will temporarily unlock the lock and relock it afterwards. If your driver
@@ -941,21 +997,35 @@ fast.
941 997
942Useful functions: 998Useful functions:
943 999
944- v4l2_event_queue() 1000void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev)
945 1001
946 Queue events to video device. The driver's only responsibility is to fill 1002 Queue events to video device. The driver's only responsibility is to fill
947 in the type and the data fields. The other fields will be filled in by 1003 in the type and the data fields. The other fields will be filled in by
948 V4L2. 1004 V4L2.
949 1005
950- v4l2_event_subscribe() 1006int v4l2_event_subscribe(struct v4l2_fh *fh,
1007 struct v4l2_event_subscription *sub, unsigned elems,
1008 const struct v4l2_subscribed_event_ops *ops)
951 1009
952 The video_device->ioctl_ops->vidioc_subscribe_event must check the driver 1010 The video_device->ioctl_ops->vidioc_subscribe_event must check the driver
953 is able to produce events with specified event id. Then it calls 1011 is able to produce events with specified event id. Then it calls
954 v4l2_event_subscribe() to subscribe the event. The last argument is the 1012 v4l2_event_subscribe() to subscribe the event.
955 size of the event queue for this event. If it is 0, then the framework 1013
956 will fill in a default value (this depends on the event type). 1014 The elems argument is the size of the event queue for this event. If it is 0,
1015 then the framework will fill in a default value (this depends on the event
1016 type).
1017
1018 The ops argument allows the driver to specify a number of callbacks:
1019 * add: called when a new listener gets added (subscribing to the same
1020 event twice will only cause this callback to get called once)
1021 * del: called when a listener stops listening
1022 * replace: replace event 'old' with event 'new'.
1023 * merge: merge event 'old' into event 'new'.
1024 All 4 callbacks are optional, if you don't want to specify any callbacks
1025 the ops argument itself maybe NULL.
957 1026
958- v4l2_event_unsubscribe() 1027int v4l2_event_unsubscribe(struct v4l2_fh *fh,
1028 struct v4l2_event_subscription *sub)
959 1029
960 vidioc_unsubscribe_event in struct v4l2_ioctl_ops. A driver may use 1030 vidioc_unsubscribe_event in struct v4l2_ioctl_ops. A driver may use
961 v4l2_event_unsubscribe() directly unless it wants to be involved in 1031 v4l2_event_unsubscribe() directly unless it wants to be involved in
@@ -964,7 +1034,7 @@ Useful functions:
964 The special type V4L2_EVENT_ALL may be used to unsubscribe all events. The 1034 The special type V4L2_EVENT_ALL may be used to unsubscribe all events. The
965 drivers may want to handle this in a special way. 1035 drivers may want to handle this in a special way.
966 1036
967- v4l2_event_pending() 1037int v4l2_event_pending(struct v4l2_fh *fh)
968 1038
969 Returns the number of pending events. Useful when implementing poll. 1039 Returns the number of pending events. Useful when implementing poll.
970 1040