]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - include/media/soc_camera_platform.h
tmpfs: use kmemdup for short symlinks
[mirror_ubuntu-zesty-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
17 struct device;
18
19 struct soc_camera_platform_info {
20 const char *format_name;
21 unsigned long format_depth;
22 struct v4l2_mbus_framefmt format;
23 unsigned long bus_param;
24 struct soc_camera_device *icd;
25 int (*set_capture)(struct soc_camera_platform_info *info, int enable);
26 };
27
28 static inline void soc_camera_platform_release(struct platform_device **pdev)
29 {
30 *pdev = NULL;
31 }
32
33 static inline int soc_camera_platform_add(struct soc_camera_device *icd,
34 struct platform_device **pdev,
35 struct soc_camera_link *plink,
36 void (*release)(struct device *dev),
37 int id)
38 {
39 struct soc_camera_platform_info *info = plink->priv;
40 int ret;
41
42 if (icd->link != plink)
43 return -ENODEV;
44
45 if (*pdev)
46 return -EBUSY;
47
48 *pdev = platform_device_alloc("soc_camera_platform", id);
49 if (!*pdev)
50 return -ENOMEM;
51
52 info->icd = icd;
53
54 (*pdev)->dev.platform_data = info;
55 (*pdev)->dev.release = release;
56
57 ret = platform_device_add(*pdev);
58 if (ret < 0) {
59 platform_device_put(*pdev);
60 *pdev = NULL;
61 info->icd = NULL;
62 }
63
64 return ret;
65 }
66
67 static inline void soc_camera_platform_del(const struct soc_camera_device *icd,
68 struct platform_device *pdev,
69 const struct soc_camera_link *plink)
70 {
71 if (icd->link != plink || !pdev)
72 return;
73
74 platform_device_unregister(pdev);
75 }
76
77 #endif /* __SOC_CAMERA_H__ */