aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2012-12-21 06:11:48 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-01-04 22:38:02 -0500
commit25a348110078cefa99b0b079938dd930cfc3a0be (patch)
treef485653dd9a18cee7e9f037687e9b52354b58ea6 /include/media
parentdd669e907cbe1cf33f9cbbff79af2b5c271cdd89 (diff)
[media] soc-camera: split struct soc_camera_link into host and subdevice parts
struct soc_camera_link currently contains fields, used both by sensor and bridge drivers. To make subdevice driver re-use simpler, split it into a host and a subdevice parts. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/soc_camera.h102
-rw-r--r--include/media/soc_camera_platform.h10
2 files changed, 89 insertions, 23 deletions
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 5a662c981484..2cc70cf318bf 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -23,11 +23,11 @@
23#include <media/v4l2-device.h> 23#include <media/v4l2-device.h>
24 24
25struct file; 25struct file;
26struct soc_camera_link; 26struct soc_camera_desc;
27 27
28struct soc_camera_device { 28struct soc_camera_device {
29 struct list_head list; /* list of all registered devices */ 29 struct list_head list; /* list of all registered devices */
30 struct soc_camera_link *link; 30 struct soc_camera_desc *sdesc;
31 struct device *pdev; /* Platform device */ 31 struct device *pdev; /* Platform device */
32 struct device *parent; /* Camera host device */ 32 struct device *parent; /* Camera host device */
33 struct device *control; /* E.g., the i2c client */ 33 struct device *control; /* E.g., the i2c client */
@@ -116,26 +116,72 @@ struct soc_camera_host_ops {
116struct i2c_board_info; 116struct i2c_board_info;
117struct regulator_bulk_data; 117struct regulator_bulk_data;
118 118
119struct soc_camera_link { 119struct soc_camera_subdev_desc {
120 /* Camera bus id, used to match a camera and a bus */
121 int bus_id;
122 /* Per camera SOCAM_SENSOR_* bus flags */ 120 /* Per camera SOCAM_SENSOR_* bus flags */
123 unsigned long flags; 121 unsigned long flags;
124 int i2c_adapter_id; 122
125 struct i2c_board_info *board_info; 123 /* sensor driver private platform data */
126 const char *module_name; 124 void *drv_priv;
127 void *priv;
128 125
129 /* Optional regulators that have to be managed on power on/off events */ 126 /* Optional regulators that have to be managed on power on/off events */
130 struct regulator_bulk_data *regulators; 127 struct regulator_bulk_data *regulators;
131 int num_regulators; 128 int num_regulators;
132 129
130 /* Optional callbacks to power on or off and reset the sensor */
131 int (*power)(struct device *, int);
132 int (*reset)(struct device *);
133
134 /*
135 * some platforms may support different data widths than the sensors
136 * native ones due to different data line routing. Let the board code
137 * overwrite the width flags.
138 */
139 int (*set_bus_param)(struct soc_camera_subdev_desc *, unsigned long flags);
140 unsigned long (*query_bus_param)(struct soc_camera_subdev_desc *);
141 void (*free_bus)(struct soc_camera_subdev_desc *);
142};
143
144struct soc_camera_host_desc {
145 /* Camera bus id, used to match a camera and a bus */
146 int bus_id;
147 int i2c_adapter_id;
148 struct i2c_board_info *board_info;
149 const char *module_name;
150
133 /* 151 /*
134 * For non-I2C devices platform has to provide methods to add a device 152 * For non-I2C devices platform has to provide methods to add a device
135 * to the system and to remove it 153 * to the system and to remove it
136 */ 154 */
137 int (*add_device)(struct soc_camera_device *); 155 int (*add_device)(struct soc_camera_device *);
138 void (*del_device)(struct soc_camera_device *); 156 void (*del_device)(struct soc_camera_device *);
157};
158
159/*
160 * This MUST be kept binary-identical to struct soc_camera_link below, until
161 * it is completely replaced by this one, after which we can split it into its
162 * two components.
163 */
164struct soc_camera_desc {
165 struct soc_camera_subdev_desc subdev_desc;
166 struct soc_camera_host_desc host_desc;
167};
168
169/* Prepare to replace this struct: don't change its layout any more! */
170struct soc_camera_link {
171 /*
172 * Subdevice part - keep at top and compatible to
173 * struct soc_camera_subdev_desc
174 */
175
176 /* Per camera SOCAM_SENSOR_* bus flags */
177 unsigned long flags;
178
179 void *priv;
180
181 /* Optional regulators that have to be managed on power on/off events */
182 struct regulator_bulk_data *regulators;
183 int num_regulators;
184
139 /* Optional callbacks to power on or off and reset the sensor */ 185 /* Optional callbacks to power on or off and reset the sensor */
140 int (*power)(struct device *, int); 186 int (*power)(struct device *, int);
141 int (*reset)(struct device *); 187 int (*reset)(struct device *);
@@ -147,6 +193,24 @@ struct soc_camera_link {
147 int (*set_bus_param)(struct soc_camera_link *, unsigned long flags); 193 int (*set_bus_param)(struct soc_camera_link *, unsigned long flags);
148 unsigned long (*query_bus_param)(struct soc_camera_link *); 194 unsigned long (*query_bus_param)(struct soc_camera_link *);
149 void (*free_bus)(struct soc_camera_link *); 195 void (*free_bus)(struct soc_camera_link *);
196
197 /*
198 * Host part - keep at bottom and compatible to
199 * struct soc_camera_host_desc
200 */
201
202 /* Camera bus id, used to match a camera and a bus */
203 int bus_id;
204 int i2c_adapter_id;
205 struct i2c_board_info *board_info;
206 const char *module_name;
207
208 /*
209 * For non-I2C devices platform has to provide methods to add a device
210 * to the system and to remove it
211 */
212 int (*add_device)(struct soc_camera_device *);
213 void (*del_device)(struct soc_camera_device *);
150}; 214};
151 215
152static inline struct soc_camera_host *to_soc_camera_host( 216static inline struct soc_camera_host *to_soc_camera_host(
@@ -157,10 +221,10 @@ static inline struct soc_camera_host *to_soc_camera_host(
157 return container_of(v4l2_dev, struct soc_camera_host, v4l2_dev); 221 return container_of(v4l2_dev, struct soc_camera_host, v4l2_dev);
158} 222}
159 223
160static inline struct soc_camera_link *to_soc_camera_link( 224static inline struct soc_camera_desc *to_soc_camera_desc(
161 const struct soc_camera_device *icd) 225 const struct soc_camera_device *icd)
162{ 226{
163 return icd->link; 227 return icd->sdesc;
164} 228}
165 229
166static inline struct device *to_soc_camera_control( 230static inline struct device *to_soc_camera_control(
@@ -250,19 +314,17 @@ static inline void soc_camera_limit_side(int *start, int *length,
250 *start = start_min + length_max - *length; 314 *start = start_min + length_max - *length;
251} 315}
252 316
253unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl, 317unsigned long soc_camera_apply_board_flags(struct soc_camera_subdev_desc *ssdd,
254 unsigned long flags);
255unsigned long soc_camera_apply_board_flags(struct soc_camera_link *icl,
256 const struct v4l2_mbus_config *cfg); 318 const struct v4l2_mbus_config *cfg);
257 319
258int soc_camera_power_on(struct device *dev, struct soc_camera_link *icl); 320int soc_camera_power_on(struct device *dev, struct soc_camera_subdev_desc *ssdd);
259int soc_camera_power_off(struct device *dev, struct soc_camera_link *icl); 321int soc_camera_power_off(struct device *dev, struct soc_camera_subdev_desc *ssdd);
260 322
261static inline int soc_camera_set_power(struct device *dev, 323static inline int soc_camera_set_power(struct device *dev,
262 struct soc_camera_link *icl, bool on) 324 struct soc_camera_subdev_desc *ssdd, bool on)
263{ 325{
264 return on ? soc_camera_power_on(dev, icl) 326 return on ? soc_camera_power_on(dev, ssdd)
265 : soc_camera_power_off(dev, icl); 327 : soc_camera_power_off(dev, ssdd);
266} 328}
267 329
268/* This is only temporary here - until v4l2-subdev begins to link to video_device */ 330/* This is only temporary here - until v4l2-subdev begins to link to video_device */
@@ -274,7 +336,7 @@ static inline struct video_device *soc_camera_i2c_to_vdev(const struct i2c_clien
274 return icd ? icd->vdev : NULL; 336 return icd ? icd->vdev : NULL;
275} 337}
276 338
277static inline struct soc_camera_link *soc_camera_i2c_to_link(const struct i2c_client *client) 339static inline struct soc_camera_subdev_desc *soc_camera_i2c_to_desc(const struct i2c_client *client)
278{ 340{
279 return client->dev.platform_data; 341 return client->dev.platform_data;
280} 342}
diff --git a/include/media/soc_camera_platform.h b/include/media/soc_camera_platform.h
index 8aa4200a0b1d..1e5065dab430 100644
--- a/include/media/soc_camera_platform.h
+++ b/include/media/soc_camera_platform.h
@@ -38,10 +38,12 @@ static inline int soc_camera_platform_add(struct soc_camera_device *icd,
38 void (*release)(struct device *dev), 38 void (*release)(struct device *dev),
39 int id) 39 int id)
40{ 40{
41 struct soc_camera_platform_info *info = plink->priv; 41 struct soc_camera_subdev_desc *ssdd =
42 (struct soc_camera_subdev_desc *)plink;
43 struct soc_camera_platform_info *info = ssdd->drv_priv;
42 int ret; 44 int ret;
43 45
44 if (icd->link != plink) 46 if (&icd->sdesc->subdev_desc != ssdd)
45 return -ENODEV; 47 return -ENODEV;
46 48
47 if (*pdev) 49 if (*pdev)
@@ -70,7 +72,9 @@ static inline void soc_camera_platform_del(const struct soc_camera_device *icd,
70 struct platform_device *pdev, 72 struct platform_device *pdev,
71 const struct soc_camera_link *plink) 73 const struct soc_camera_link *plink)
72{ 74{
73 if (icd->link != plink || !pdev) 75 const struct soc_camera_subdev_desc *ssdd =
76 (const struct soc_camera_subdev_desc *)plink;
77 if (&icd->sdesc->subdev_desc != ssdd || !pdev)
74 return; 78 return;
75 79
76 platform_device_unregister(pdev); 80 platform_device_unregister(pdev);