[media] V4L: soc_camera_platform: support the new mbus-config subdev ops
[pandora-kernel.git] / include / media / soc_camera_platform.h
1 /*
2  * Generic Platform Camera Driver Header
3  *
4  * Copyright (C) 2008 Magnus Damm
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #ifndef __SOC_CAMERA_H__
12 #define __SOC_CAMERA_H__
13
14 #include <linux/videodev2.h>
15 #include <media/soc_camera.h>
16 #include <media/v4l2-mediabus.h>
17
18 struct device;
19
20 struct soc_camera_platform_info {
21         const char *format_name;
22         unsigned long format_depth;
23         struct v4l2_mbus_framefmt format;
24         unsigned long bus_param;
25         unsigned long mbus_param;
26         enum v4l2_mbus_type mbus_type;
27         struct soc_camera_device *icd;
28         int (*set_capture)(struct soc_camera_platform_info *info, int enable);
29 };
30
31 static inline void soc_camera_platform_release(struct platform_device **pdev)
32 {
33         *pdev = NULL;
34 }
35
36 static inline int soc_camera_platform_add(struct soc_camera_device *icd,
37                                           struct platform_device **pdev,
38                                           struct soc_camera_link *plink,
39                                           void (*release)(struct device *dev),
40                                           int id)
41 {
42         struct soc_camera_platform_info *info = plink->priv;
43         int ret;
44
45         if (icd->link != plink)
46                 return -ENODEV;
47
48         if (*pdev)
49                 return -EBUSY;
50
51         *pdev = platform_device_alloc("soc_camera_platform", id);
52         if (!*pdev)
53                 return -ENOMEM;
54
55         info->icd = icd;
56
57         (*pdev)->dev.platform_data = info;
58         (*pdev)->dev.release = release;
59
60         ret = platform_device_add(*pdev);
61         if (ret < 0) {
62                 platform_device_put(*pdev);
63                 *pdev = NULL;
64                 info->icd = NULL;
65         }
66
67         return ret;
68 }
69
70 static inline void soc_camera_platform_del(const struct soc_camera_device *icd,
71                                            struct platform_device *pdev,
72                                            const struct soc_camera_link *plink)
73 {
74         if (icd->link != plink || !pdev)
75                 return;
76
77         platform_device_unregister(pdev);
78 }
79
80 #endif /* __SOC_CAMERA_H__ */