V4L/DVB (7170): soc_camera V4L2 driver for directly-connected SoC-based cameras
[deliverable/linux.git] / include / media / soc_camera.h
1 /*
2 * camera image capture (abstract) bus driver header
3 *
4 * Copyright (C) 2006, Sascha Hauer, Pengutronix
5 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
6 *
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.
10 */
11
12 #ifndef SOC_CAMERA_H
13 #define SOC_CAMERA_H
14
15 #include <linux/videodev2.h>
16 #include <media/videobuf-dma-sg.h>
17
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 cached_datawidth; /* 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 int (*probe)(struct soc_camera_device *icd);
42 void (*remove)(struct soc_camera_device *icd);
43 struct module *owner;
44 };
45
46 struct soc_camera_file {
47 struct soc_camera_device *icd;
48 struct videobuf_queue vb_vidq;
49 };
50
51 struct soc_camera_host {
52 struct list_head list;
53 struct device dev;
54 unsigned char nr; /* Host number */
55 size_t msize;
56 struct videobuf_queue_ops *vbq_ops;
57 struct module *owner;
58 void *priv;
59 char *drv_name;
60 int (*add)(struct soc_camera_device *);
61 void (*remove)(struct soc_camera_device *);
62 int (*set_capture_format)(struct soc_camera_device *, __u32,
63 struct v4l2_rect *);
64 int (*try_fmt_cap)(struct soc_camera_host *, struct v4l2_format *);
65 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *);
66 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
67 unsigned int (*poll)(struct file *, poll_table *);
68 };
69
70 struct soc_camera_link {
71 /* Camera bus id, used to match a camera and a bus */
72 int bus_id;
73 /* GPIO number to switch between 8 and 10 bit modes */
74 unsigned int gpio;
75 };
76
77 static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev)
78 {
79 return container_of(dev, struct soc_camera_device, dev);
80 }
81
82 static inline struct soc_camera_host *to_soc_camera_host(struct device *dev)
83 {
84 return container_of(dev, struct soc_camera_host, dev);
85 }
86
87 extern int soc_camera_host_register(struct soc_camera_host *ici,
88 struct module *owner);
89 extern void soc_camera_host_unregister(struct soc_camera_host *ici);
90 extern int soc_camera_device_register(struct soc_camera_device *icd);
91 extern void soc_camera_device_unregister(struct soc_camera_device *icd);
92
93 extern int soc_camera_video_start(struct soc_camera_device *icd);
94 extern void soc_camera_video_stop(struct soc_camera_device *icd);
95
96 struct soc_camera_data_format {
97 char *name;
98 unsigned int depth;
99 __u32 fourcc;
100 enum v4l2_colorspace colorspace;
101 };
102
103 struct soc_camera_ops {
104 struct module *owner;
105 int (*init)(struct soc_camera_device *);
106 int (*release)(struct soc_camera_device *);
107 int (*start_capture)(struct soc_camera_device *);
108 int (*stop_capture)(struct soc_camera_device *);
109 int (*set_capture_format)(struct soc_camera_device *, __u32,
110 struct v4l2_rect *, unsigned int);
111 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
112 int (*get_chip_id)(struct soc_camera_device *,
113 struct v4l2_chip_ident *);
114 #ifdef CONFIG_VIDEO_ADV_DEBUG
115 int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
116 int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
117 #endif
118 const struct soc_camera_data_format *formats;
119 int num_formats;
120 int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
121 int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
122 const struct v4l2_queryctrl *controls;
123 int num_controls;
124 unsigned int(*get_datawidth)(struct soc_camera_device *icd);
125 };
126
127 static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
128 struct soc_camera_ops *ops, int id)
129 {
130 int i;
131
132 for (i = 0; i < ops->num_controls; i++)
133 if (ops->controls[i].id == id)
134 return &ops->controls[i];
135
136 return NULL;
137 }
138
139 #define IS_MASTER (1<<0)
140 #define IS_HSYNC_ACTIVE_HIGH (1<<1)
141 #define IS_VSYNC_ACTIVE_HIGH (1<<2)
142 #define IS_DATAWIDTH_8 (1<<3)
143 #define IS_DATAWIDTH_9 (1<<4)
144 #define IS_DATAWIDTH_10 (1<<5)
145 #define IS_PCLK_SAMPLE_RISING (1<<6)
146
147 #endif
This page took 0.038852 seconds and 6 git commands to generate.