4 * Copyright (C) 2006--2009 Nokia Corporation
5 * Copyright (C) 2007--2009 Texas Instruments
7 * Contact: Sakari Ailus <sakari.ailus@nokia.com>
8 * Tuukka Toivonen <tuukka.o.toivonen@nokia.com>
10 * Originally based on the OMAP 2 camera driver.
12 * Written by Sakari Ailus <sakari.ailus@nokia.com>
13 * Tuukka Toivonen <tuukka.o.toivonen@nokia.com>
14 * Sergio Aguirre <saaguirre@ti.com>
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * version 2 as published by the Free Software Foundation.
23 * This program is distributed in the hope that it will be useful, but
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
38 #include <media/v4l2-int-device.h>
41 #define CAM_NAME "omap34xxcam"
42 #define CAM_SHORT_NAME "omap3"
44 #define OMAP34XXCAM_XCLK_NONE -1
45 #define OMAP34XXCAM_XCLK_A 0
46 #define OMAP34XXCAM_XCLK_B 1
48 #define OMAP34XXCAM_SLAVE_SENSOR 0
49 #define OMAP34XXCAM_SLAVE_LENS 1
50 #define OMAP34XXCAM_SLAVE_FLASH 2 /* This is the last slave! */
52 /* mask for omap34xxcam_slave_power_set */
53 #define OMAP34XXCAM_SLAVE_POWER_SENSOR (1 << OMAP34XXCAM_SLAVE_SENSOR)
54 #define OMAP34XXCAM_SLAVE_POWER_LENS (1 << OMAP34XXCAM_SLAVE_LENS)
55 #define OMAP34XXCAM_SLAVE_POWER_SENSOR_LENS \
56 (OMAP34XXCAM_SLAVE_POWER_SENSOR | OMAP34XXCAM_SLAVE_POWER_LENS)
57 #define OMAP34XXCAM_SLAVE_POWER_FLASH (1 << OMAP34XXCAM_SLAVE_FLASH)
58 #define OMAP34XXCAM_SLAVE_POWER_ALL -1
60 #define OMAP34XXCAM_VIDEODEVS 4
62 /* #define OMAP34XXCAM_POWEROFF_DELAY (2 * HZ) */
64 struct omap34xxcam_device
;
65 struct omap34xxcam_videodev
;
68 * struct omap34xxcam_sensor_config - struct for vidioc_int_g_priv ioctl
69 * @sensor_isp: Is sensor smart/SOC or raw
70 * @capture_mem: Size limit to mmap buffers.
71 * @ival_default: Default frame interval for sensor.
73 struct omap34xxcam_sensor_config
{
76 struct v4l2_fract ival_default
;
79 struct omap34xxcam_lens_config
{
82 struct omap34xxcam_flash_config
{
85 struct omap34xxcam_hw_config
{
86 int dev_index
; /* Index in omap34xxcam_sensors */
87 int dev_minor
; /* Video device minor number */
88 int dev_type
; /* OMAP34XXCAM_SLAVE_* */
90 struct omap34xxcam_sensor_config sensor
;
91 struct omap34xxcam_lens_config lens
;
92 struct omap34xxcam_flash_config flash
;
98 * struct omap34xxcam_videodev - per /dev/video* structure
99 * @mutex: serialises access to this structure
100 * @cam: pointer to cam hw structure
101 * @master: we are v4l2_int_device master
102 * @sensor: sensor device
104 * @flash: flash device
105 * @slaves: how many slaves we have at the moment
106 * @vfd: our video device
107 * @index: index of this structure in cam->vdevs
108 * @users: how many users we have
109 * @power_state: Current power state
110 * @power_state_wish: New power state when poweroff_timer expires
111 * @power_state_mask: Bitmask of devices to set the new power state
112 * @poweroff_timer: Timer for dispatching poweroff_work
113 * @poweroff_work: Work for slave power state change
114 * @sensor_config: ISP-speicific sensor configuration
115 * @lens_config: ISP-speicific lens configuration
116 * @flash_config: ISP-speicific flash configuration
117 * @streaming: streaming file handle, if streaming is enabled
118 * @want_timeperframe: Desired timeperframe
119 * @want_pix: Desired pix
122 struct omap34xxcam_videodev
{
123 struct mutex mutex
; /* serialises access to this structure */
125 struct omap34xxcam_device
*cam
;
126 struct v4l2_int_device master
;
128 #define vdev_sensor slave[OMAP34XXCAM_SLAVE_SENSOR]
129 #define vdev_lens slave[OMAP34XXCAM_SLAVE_LENS]
130 #define vdev_flash slave[OMAP34XXCAM_SLAVE_FLASH]
131 struct v4l2_int_device
*slave
[OMAP34XXCAM_SLAVE_FLASH
+ 1];
133 /* number of slaves attached */
136 /*** video device parameters ***/
137 struct video_device
*vfd
;
139 /*** general driver state information ***/
142 enum v4l2_power power_state
[OMAP34XXCAM_SLAVE_FLASH
+ 1];
143 #ifdef OMAP34XXCAM_POWEROFF_DELAY
144 enum v4l2_power power_state_wish
;
145 int power_state_mask
;
146 struct timer_list poweroff_timer
;
147 struct work_struct poweroff_work
;
148 #endif /* OMAP34XXCAM_POWEROFF_DELAY */
150 #define vdev_sensor_config slave_config[OMAP34XXCAM_SLAVE_SENSOR].u.sensor
151 #define vdev_lens_config slave_config[OMAP34XXCAM_SLAVE_LENS].u.lens
152 #define vdev_flash_config slave_config[OMAP34XXCAM_SLAVE_FLASH].u.flash
153 struct omap34xxcam_hw_config slave_config
[OMAP34XXCAM_SLAVE_FLASH
+ 1];
155 #define vdev_sensor_mode slave_mode[OMAP34XXCAM_SLAVE_SENSOR]
156 #define vdev_lens_mode slave_mode[OMAP34XXCAM_SLAVE_LENS]
157 #define vdev_flash_mode slave_mode[OMAP34XXCAM_SLAVE_FLASH]
158 int slave_mode
[OMAP34XXCAM_SLAVE_FLASH
+ 1];
160 /*** capture data ***/
161 struct file
*streaming
;
162 struct v4l2_fract want_timeperframe
;
163 struct v4l2_pix_format want_pix
;
164 struct v4l2_pix_format pix
;
168 * struct omap34xxcam_device - per-device data structure
169 * @vdevs: /dev/video specific structures
171 struct omap34xxcam_device
{
172 struct omap34xxcam_videodev vdevs
[OMAP34XXCAM_VIDEODEVS
];
177 * struct omap34xxcam_fh - per-filehandle data structure
178 * @vbq_lock: spinlock for the videobuf queue
179 * @vbq: V4L2 video buffer queue structure
180 * @field_count: field counter for videobuf_buffer
181 * @vdev: our /dev/video specific structure
183 struct omap34xxcam_fh
{
184 spinlock_t vbq_lock
; /* spinlock for the videobuf queue */
185 struct videobuf_queue vbq
;
186 atomic_t field_count
;
187 struct omap34xxcam_videodev
*vdev
;
190 #endif /* ifndef OMAP34XXCAM_H */