diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2012-10-05 11:33:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-12-20 11:25:34 -0500 |
commit | 454547fb8217ac82de82fdffe0c2a41d8cd47bf4 (patch) | |
tree | f80b99e707c31d310b1c8212f0d6a4c27d653bbc /Documentation/video4linux | |
parent | 57f1b1c8fd705f48eb9fcd87d054e1dc46b1cedc (diff) |
[media] media: soc-camera: update documentation
Update soc-camera documentation to reflect the current camera host API and
the use of the common V4L2 subdev API.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation/video4linux')
-rw-r--r-- | Documentation/video4linux/soc-camera.txt | 146 |
1 files changed, 75 insertions, 71 deletions
diff --git a/Documentation/video4linux/soc-camera.txt b/Documentation/video4linux/soc-camera.txt index 3f87c7da4ca2..f62fcdbc8b9f 100644 --- a/Documentation/video4linux/soc-camera.txt +++ b/Documentation/video4linux/soc-camera.txt | |||
@@ -9,32 +9,36 @@ The following terms are used in this document: | |||
9 | of connecting to a variety of systems and interfaces, typically uses i2c for | 9 | of connecting to a variety of systems and interfaces, typically uses i2c for |
10 | control and configuration, and a parallel or a serial bus for data. | 10 | control and configuration, and a parallel or a serial bus for data. |
11 | - camera host - an interface, to which a camera is connected. Typically a | 11 | - camera host - an interface, to which a camera is connected. Typically a |
12 | specialised interface, present on many SoCs, e.g., PXA27x and PXA3xx, SuperH, | 12 | specialised interface, present on many SoCs, e.g. PXA27x and PXA3xx, SuperH, |
13 | AVR32, i.MX27, i.MX31. | 13 | AVR32, i.MX27, i.MX31. |
14 | - camera host bus - a connection between a camera host and a camera. Can be | 14 | - camera host bus - a connection between a camera host and a camera. Can be |
15 | parallel or serial, consists of data and control lines, e.g., clock, vertical | 15 | parallel or serial, consists of data and control lines, e.g. clock, vertical |
16 | and horizontal synchronization signals. | 16 | and horizontal synchronization signals. |
17 | 17 | ||
18 | Purpose of the soc-camera subsystem | 18 | Purpose of the soc-camera subsystem |
19 | ----------------------------------- | 19 | ----------------------------------- |
20 | 20 | ||
21 | The soc-camera subsystem provides a unified API between camera host drivers and | 21 | The soc-camera subsystem initially provided a unified API between camera host |
22 | camera sensor drivers. It implements a V4L2 interface to the user, currently | 22 | drivers and camera sensor drivers. Later the soc-camera sensor API has been |
23 | only the mmap method is supported. | 23 | replaced with the V4L2 standard subdev API. This also made camera driver re-use |
24 | with non-soc-camera hosts possible. The camera host API to the soc-camera core | ||
25 | has been preserved. | ||
24 | 26 | ||
25 | This subsystem has been written to connect drivers for System-on-Chip (SoC) | 27 | Soc-camera implements a V4L2 interface to the user, currently only the "mmap" |
26 | video capture interfaces with drivers for CMOS camera sensor chips to enable | 28 | method is supported by host drivers. However, the soc-camera core also provides |
27 | the reuse of sensor drivers with various hosts. The subsystem has been designed | 29 | support for the "read" method. |
28 | to support multiple camera host interfaces and multiple cameras per interface, | 30 | |
29 | although most applications have only one camera sensor. | 31 | The subsystem has been designed to support multiple camera host interfaces and |
32 | multiple cameras per interface, although most applications have only one camera | ||
33 | sensor. | ||
30 | 34 | ||
31 | Existing drivers | 35 | Existing drivers |
32 | ---------------- | 36 | ---------------- |
33 | 37 | ||
34 | As of 2.6.27-rc4 there are two host drivers in the mainline: pxa_camera.c for | 38 | As of 3.7 there are seven host drivers in the mainline: atmel-isi.c, |
35 | PXA27x SoCs and sh_mobile_ceu_camera.c for SuperH SoCs, and four sensor drivers: | 39 | mx1_camera.c (broken, scheduled for removal), mx2_camera.c, mx3_camera.c, |
36 | mt9m001.c, mt9m111.c, mt9v022.c and a generic soc_camera_platform.c driver. This | 40 | omap1_camera.c, pxa_camera.c, sh_mobile_ceu_camera.c, and multiple sensor |
37 | list is not supposed to be updated, look for more examples in your tree. | 41 | drivers under drivers/media/i2c/soc_camera/. |
38 | 42 | ||
39 | Camera host API | 43 | Camera host API |
40 | --------------- | 44 | --------------- |
@@ -45,38 +49,37 @@ soc_camera_host_register(struct soc_camera_host *); | |||
45 | 49 | ||
46 | function. The host object can be initialized as follows: | 50 | function. The host object can be initialized as follows: |
47 | 51 | ||
48 | static struct soc_camera_host pxa_soc_camera_host = { | 52 | struct soc_camera_host *ici; |
49 | .drv_name = PXA_CAM_DRV_NAME, | 53 | ici->drv_name = DRV_NAME; |
50 | .ops = &pxa_soc_camera_host_ops, | 54 | ici->ops = &camera_host_ops; |
51 | }; | 55 | ici->priv = pcdev; |
56 | ici->v4l2_dev.dev = &pdev->dev; | ||
57 | ici->nr = pdev->id; | ||
52 | 58 | ||
53 | All camera host methods are passed in a struct soc_camera_host_ops: | 59 | All camera host methods are passed in a struct soc_camera_host_ops: |
54 | 60 | ||
55 | static struct soc_camera_host_ops pxa_soc_camera_host_ops = { | 61 | static struct soc_camera_host_ops camera_host_ops = { |
56 | .owner = THIS_MODULE, | 62 | .owner = THIS_MODULE, |
57 | .add = pxa_camera_add_device, | 63 | .add = camera_add_device, |
58 | .remove = pxa_camera_remove_device, | 64 | .remove = camera_remove_device, |
59 | .suspend = pxa_camera_suspend, | 65 | .set_fmt = camera_set_fmt_cap, |
60 | .resume = pxa_camera_resume, | 66 | .try_fmt = camera_try_fmt_cap, |
61 | .set_fmt_cap = pxa_camera_set_fmt_cap, | 67 | .init_videobuf2 = camera_init_videobuf2, |
62 | .try_fmt_cap = pxa_camera_try_fmt_cap, | 68 | .poll = camera_poll, |
63 | .init_videobuf = pxa_camera_init_videobuf, | 69 | .querycap = camera_querycap, |
64 | .reqbufs = pxa_camera_reqbufs, | 70 | .set_bus_param = camera_set_bus_param, |
65 | .poll = pxa_camera_poll, | 71 | /* The rest of host operations are optional */ |
66 | .querycap = pxa_camera_querycap, | ||
67 | .try_bus_param = pxa_camera_try_bus_param, | ||
68 | .set_bus_param = pxa_camera_set_bus_param, | ||
69 | }; | 72 | }; |
70 | 73 | ||
71 | .add and .remove methods are called when a sensor is attached to or detached | 74 | .add and .remove methods are called when a sensor is attached to or detached |
72 | from the host, apart from performing host-internal tasks they shall also call | 75 | from the host. .set_bus_param is used to configure physical connection |
73 | sensor driver's .init and .release methods respectively. .suspend and .resume | 76 | parameters between the host and the sensor. .init_videobuf2 is called by |
74 | methods implement host's power-management functionality and its their | 77 | soc-camera core when a video-device is opened, the host driver would typically |
75 | responsibility to call respective sensor's methods. .try_bus_param and | 78 | call vb2_queue_init() in this method. Further video-buffer management is |
76 | .set_bus_param are used to negotiate physical connection parameters between the | 79 | implemented completely by the specific camera host driver. If the host driver |
77 | host and the sensor. .init_videobuf is called by soc-camera core when a | 80 | supports non-standard pixel format conversion, it should implement a |
78 | video-device is opened, further video-buffer management is implemented completely | 81 | .get_formats and, possibly, a .put_formats operations. See below for more |
79 | by the specific camera host driver. The rest of the methods are called from | 82 | details about format conversion. The rest of the methods are called from |
80 | respective V4L2 operations. | 83 | respective V4L2 operations. |
81 | 84 | ||
82 | Camera API | 85 | Camera API |
@@ -84,37 +87,21 @@ Camera API | |||
84 | 87 | ||
85 | Sensor drivers can use struct soc_camera_link, typically provided by the | 88 | Sensor drivers can use struct soc_camera_link, typically provided by the |
86 | platform, and used to specify to which camera host bus the sensor is connected, | 89 | platform, and used to specify to which camera host bus the sensor is connected, |
87 | and arbitrarily provide platform .power and .reset methods for the camera. | 90 | and optionally provide platform .power and .reset methods for the camera. This |
88 | soc_camera_device_register() and soc_camera_device_unregister() functions are | 91 | struct is provided to the camera driver via the I2C client device platform data |
89 | used to add a sensor driver to or remove one from the system. The registration | 92 | and can be obtained, using the soc_camera_i2c_to_link() macro. Care should be |
90 | function takes a pointer to struct soc_camera_device as the only parameter. | 93 | taken, when using soc_camera_vdev_to_subdev() and when accessing struct |
91 | This struct can be initialized as follows: | 94 | soc_camera_device, using v4l2_get_subdev_hostdata(): both only work, when |
92 | 95 | running on an soc-camera host. The actual camera driver operation is implemented | |
93 | /* link to driver operations */ | 96 | using the V4L2 subdev API. Additionally soc-camera camera drivers can use |
94 | icd->ops = &mt9m001_ops; | 97 | auxiliary soc-camera helper functions like soc_camera_power_on() and |
95 | /* link to the underlying physical (e.g., i2c) device */ | 98 | soc_camera_power_off(), which switch regulators, provided by the platform and call |
96 | icd->control = &client->dev; | 99 | board-specific power switching methods. soc_camera_apply_board_flags() takes |
97 | /* window geometry */ | 100 | camera bus configuration capability flags and applies any board transformations, |
98 | icd->x_min = 20; | 101 | e.g. signal polarity inversion. soc_mbus_get_fmtdesc() can be used to obtain a |
99 | icd->y_min = 12; | 102 | pixel format descriptor, corresponding to a certain media-bus pixel format code. |
100 | icd->x_current = 20; | 103 | soc_camera_limit_side() can be used to restrict beginning and length of a frame |
101 | icd->y_current = 12; | 104 | side, based on camera capabilities. |
102 | icd->width_min = 48; | ||
103 | icd->width_max = 1280; | ||
104 | icd->height_min = 32; | ||
105 | icd->height_max = 1024; | ||
106 | icd->y_skip_top = 1; | ||
107 | /* camera bus ID, typically obtained from platform data */ | ||
108 | icd->iface = icl->bus_id; | ||
109 | |||
110 | struct soc_camera_ops provides .probe and .remove methods, which are called by | ||
111 | the soc-camera core, when a camera is matched against or removed from a camera | ||
112 | host bus, .init, .release, .suspend, and .resume are called from the camera host | ||
113 | driver as discussed above. Other members of this struct provide respective V4L2 | ||
114 | functionality. | ||
115 | |||
116 | struct soc_camera_device also links to an array of struct soc_camera_data_format, | ||
117 | listing pixel formats, supported by the camera. | ||
118 | 105 | ||
119 | VIDIOC_S_CROP and VIDIOC_S_FMT behaviour | 106 | VIDIOC_S_CROP and VIDIOC_S_FMT behaviour |
120 | ---------------------------------------- | 107 | ---------------------------------------- |
@@ -153,8 +140,25 @@ implemented. | |||
153 | User window geometry is kept in .user_width and .user_height fields in struct | 140 | User window geometry is kept in .user_width and .user_height fields in struct |
154 | soc_camera_device and used by the soc-camera core and host drivers. The core | 141 | soc_camera_device and used by the soc-camera core and host drivers. The core |
155 | updates these fields upon successful completion of a .s_fmt() call, but if these | 142 | updates these fields upon successful completion of a .s_fmt() call, but if these |
156 | fields change elsewhere, e.g., during .s_crop() processing, the host driver is | 143 | fields change elsewhere, e.g. during .s_crop() processing, the host driver is |
157 | responsible for updating them. | 144 | responsible for updating them. |
158 | 145 | ||
146 | Format conversion | ||
147 | ----------------- | ||
148 | |||
149 | V4L2 distinguishes between pixel formats, as they are stored in memory, and as | ||
150 | they are transferred over a media bus. Soc-camera provides support to | ||
151 | conveniently manage these formats. A table of standard transformations is | ||
152 | maintained by soc-camera core, which describes, what FOURCC pixel format will | ||
153 | be obtained, if a media-bus pixel format is stored in memory according to | ||
154 | certain rules. E.g. if V4L2_MBUS_FMT_YUYV8_2X8 data is sampled with 8 bits per | ||
155 | sample and stored in memory in the little-endian order with no gaps between | ||
156 | bytes, data in memory will represent the V4L2_PIX_FMT_YUYV FOURCC format. These | ||
157 | standard transformations will be used by soc-camera or by camera host drivers to | ||
158 | configure camera drivers to produce the FOURCC format, requested by the user, | ||
159 | using the VIDIOC_S_FMT ioctl(). Apart from those standard format conversions, | ||
160 | host drivers can also provide their own conversion rules by implementing a | ||
161 | .get_formats and, if required, a .put_formats methods. | ||
162 | |||
159 | -- | 163 | -- |
160 | Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 164 | Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de> |