Magnus Damm | 073afdd | 2008-10-16 19:51:47 -0300 | [diff] [blame] | 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 | |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 11 | #ifndef __SOC_CAMERA_H__ |
| 12 | #define __SOC_CAMERA_H__ |
| 13 | |
| 14 | #include <linux/videodev2.h> |
Guennadi Liakhovetski | c41deba | 2009-08-25 11:06:21 -0300 | [diff] [blame] | 15 | #include <media/soc_camera.h> |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 16 | |
Guennadi Liakhovetski | bc1937b | 2009-08-25 11:06:22 -0300 | [diff] [blame] | 17 | struct device; |
| 18 | |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 19 | struct soc_camera_platform_info { |
Guennadi Liakhovetski | 40e2e09 | 2009-08-25 11:28:22 -0300 | [diff] [blame] | 20 | const char *format_name; |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 21 | unsigned long format_depth; |
Guennadi Liakhovetski | 760697b | 2009-12-11 11:46:49 -0300 | [diff] [blame] | 22 | struct v4l2_mbus_framefmt format; |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 23 | unsigned long bus_param; |
Guennadi Liakhovetski | bc1937b | 2009-08-25 11:06:22 -0300 | [diff] [blame] | 24 | struct device *dev; |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 25 | int (*set_capture)(struct soc_camera_platform_info *info, int enable); |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 26 | }; |
| 27 | |
Guennadi Liakhovetski | ec0c8d5 | 2011-03-23 04:14:43 -0300 | [diff] [blame] | 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(const struct soc_camera_link *icl, |
| 34 | struct device *dev, |
| 35 | struct platform_device **pdev, |
| 36 | struct soc_camera_link *plink, |
| 37 | void (*release)(struct device *dev), |
| 38 | int id) |
| 39 | { |
| 40 | struct soc_camera_platform_info *info = plink->priv; |
| 41 | int ret; |
| 42 | |
| 43 | if (icl != plink) |
| 44 | return -ENODEV; |
| 45 | |
| 46 | if (*pdev) |
| 47 | return -EBUSY; |
| 48 | |
| 49 | *pdev = platform_device_alloc("soc_camera_platform", id); |
| 50 | if (!*pdev) |
| 51 | return -ENOMEM; |
| 52 | |
| 53 | info->dev = dev; |
| 54 | |
| 55 | (*pdev)->dev.platform_data = info; |
| 56 | (*pdev)->dev.release = release; |
| 57 | |
| 58 | ret = platform_device_add(*pdev); |
| 59 | if (ret < 0) { |
| 60 | platform_device_put(*pdev); |
| 61 | *pdev = NULL; |
| 62 | info->dev = NULL; |
| 63 | } |
| 64 | |
| 65 | return ret; |
| 66 | } |
| 67 | |
| 68 | static inline void soc_camera_platform_del(const struct soc_camera_link *icl, |
| 69 | struct platform_device *pdev, |
| 70 | const struct soc_camera_link *plink) |
| 71 | { |
| 72 | if (icl != plink || !pdev) |
| 73 | return; |
| 74 | |
| 75 | platform_device_unregister(pdev); |
| 76 | } |
| 77 | |
Magnus Damm | 326c986 | 2008-07-16 23:02:08 -0300 | [diff] [blame] | 78 | #endif /* __SOC_CAMERA_H__ */ |