procfs-guide: drop pointless   entities
[linux-2.6/sactl.git] / include / media / soc_camera.h
blob1de98f150e99e898e266c97f8de54c7c1aba0643
1 /*
2 * camera image capture (abstract) bus driver header
4 * Copyright (C) 2006, Sascha Hauer, Pengutronix
5 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #ifndef SOC_CAMERA_H
13 #define SOC_CAMERA_H
15 #include <linux/videodev2.h>
16 #include <media/videobuf-core.h>
18 struct soc_camera_device {
19 struct list_head list;
20 struct device dev;
21 struct device *control;
22 unsigned short width; /* Current window */
23 unsigned short height; /* sizes */
24 unsigned short x_min; /* Camera capabilities */
25 unsigned short y_min;
26 unsigned short x_current; /* Current window location */
27 unsigned short y_current;
28 unsigned short width_min;
29 unsigned short width_max;
30 unsigned short height_min;
31 unsigned short height_max;
32 unsigned short y_skip_top; /* Lines to skip at the top */
33 unsigned short gain;
34 unsigned short exposure;
35 unsigned char iface; /* Host number */
36 unsigned char devnum; /* Device number per host */
37 unsigned char buswidth; /* See comment in .c */
38 struct soc_camera_ops *ops;
39 struct video_device *vdev;
40 const struct soc_camera_data_format *current_fmt;
41 const struct soc_camera_data_format *formats;
42 int num_formats;
43 struct module *owner;
44 /* soc_camera.c private count. Only accessed with video_lock held */
45 int use_count;
48 struct soc_camera_file {
49 struct soc_camera_device *icd;
50 struct videobuf_queue vb_vidq;
53 struct soc_camera_host {
54 struct list_head list;
55 struct device dev;
56 unsigned char nr; /* Host number */
57 void *priv;
58 char *drv_name;
59 struct soc_camera_host_ops *ops;
62 struct soc_camera_host_ops {
63 struct module *owner;
64 int (*add)(struct soc_camera_device *);
65 void (*remove)(struct soc_camera_device *);
66 int (*set_fmt_cap)(struct soc_camera_device *, __u32,
67 struct v4l2_rect *);
68 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
69 void (*init_videobuf)(struct videobuf_queue *,
70 struct soc_camera_device *);
71 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *);
72 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
73 int (*try_bus_param)(struct soc_camera_device *, __u32);
74 int (*set_bus_param)(struct soc_camera_device *, __u32);
75 unsigned int (*poll)(struct file *, poll_table *);
78 struct soc_camera_link {
79 /* Camera bus id, used to match a camera and a bus */
80 int bus_id;
81 /* GPIO number to switch between 8 and 10 bit modes */
82 unsigned int gpio;
85 static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev)
87 return container_of(dev, struct soc_camera_device, dev);
90 static inline struct soc_camera_host *to_soc_camera_host(struct device *dev)
92 return container_of(dev, struct soc_camera_host, dev);
95 extern int soc_camera_host_register(struct soc_camera_host *ici);
96 extern void soc_camera_host_unregister(struct soc_camera_host *ici);
97 extern int soc_camera_device_register(struct soc_camera_device *icd);
98 extern void soc_camera_device_unregister(struct soc_camera_device *icd);
100 extern int soc_camera_video_start(struct soc_camera_device *icd);
101 extern void soc_camera_video_stop(struct soc_camera_device *icd);
103 struct soc_camera_data_format {
104 char *name;
105 unsigned int depth;
106 __u32 fourcc;
107 enum v4l2_colorspace colorspace;
110 struct soc_camera_ops {
111 struct module *owner;
112 int (*probe)(struct soc_camera_device *);
113 void (*remove)(struct soc_camera_device *);
114 int (*init)(struct soc_camera_device *);
115 int (*release)(struct soc_camera_device *);
116 int (*start_capture)(struct soc_camera_device *);
117 int (*stop_capture)(struct soc_camera_device *);
118 int (*set_fmt_cap)(struct soc_camera_device *, __u32,
119 struct v4l2_rect *);
120 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
121 unsigned long (*query_bus_param)(struct soc_camera_device *);
122 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
123 int (*get_chip_id)(struct soc_camera_device *,
124 struct v4l2_chip_ident *);
125 #ifdef CONFIG_VIDEO_ADV_DEBUG
126 int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
127 int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
128 #endif
129 int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
130 int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
131 const struct v4l2_queryctrl *controls;
132 int num_controls;
135 static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
136 struct soc_camera_ops *ops, int id)
138 int i;
140 for (i = 0; i < ops->num_controls; i++)
141 if (ops->controls[i].id == id)
142 return &ops->controls[i];
144 return NULL;
147 #define SOCAM_MASTER (1 << 0)
148 #define SOCAM_SLAVE (1 << 1)
149 #define SOCAM_HSYNC_ACTIVE_HIGH (1 << 2)
150 #define SOCAM_HSYNC_ACTIVE_LOW (1 << 3)
151 #define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4)
152 #define SOCAM_VSYNC_ACTIVE_LOW (1 << 5)
153 #define SOCAM_DATAWIDTH_8 (1 << 6)
154 #define SOCAM_DATAWIDTH_9 (1 << 7)
155 #define SOCAM_DATAWIDTH_10 (1 << 8)
156 #define SOCAM_DATAWIDTH_16 (1 << 9)
157 #define SOCAM_PCLK_SAMPLE_RISING (1 << 10)
158 #define SOCAM_PCLK_SAMPLE_FALLING (1 << 11)
160 #define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_9 | \
161 SOCAM_DATAWIDTH_10 | SOCAM_DATAWIDTH_16)
163 static inline unsigned long soc_camera_bus_param_compatible(
164 unsigned long camera_flags, unsigned long bus_flags)
166 unsigned long common_flags, hsync, vsync, pclk;
168 common_flags = camera_flags & bus_flags;
170 hsync = common_flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW);
171 vsync = common_flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW);
172 pclk = common_flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING);
174 return (!hsync || !vsync || !pclk) ? 0 : common_flags;
177 #endif