2 * camera image capture (abstract) bus driver header
4 * Copyright (C) 2006, Sascha Hauer, Pengutronix
5 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
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.
15 #include <linux/videodev2.h>
16 #include <media/videobuf-dma-sg.h>
18 struct soc_camera_device
{
19 struct list_head list
;
21 struct device
*control
;
22 unsigned short width
; /* Current window */
23 unsigned short height
; /* sizes */
24 unsigned short x_min
; /* Camera capabilities */
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 */
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
);
46 struct soc_camera_file
{
47 struct soc_camera_device
*icd
;
48 struct videobuf_queue vb_vidq
;
51 struct soc_camera_host
{
52 struct list_head list
;
54 unsigned char nr
; /* Host number */
56 struct videobuf_queue_ops
*vbq_ops
;
60 int (*add
)(struct soc_camera_device
*);
61 void (*remove
)(struct soc_camera_device
*);
62 int (*set_capture_format
)(struct soc_camera_device
*, __u32
,
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
*);
70 struct soc_camera_link
{
71 /* Camera bus id, used to match a camera and a bus */
73 /* GPIO number to switch between 8 and 10 bit modes */
77 static inline struct soc_camera_device
*to_soc_camera_dev(struct device
*dev
)
79 return container_of(dev
, struct soc_camera_device
, dev
);
82 static inline struct soc_camera_host
*to_soc_camera_host(struct device
*dev
)
84 return container_of(dev
, struct soc_camera_host
, dev
);
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
);
93 extern int soc_camera_video_start(struct soc_camera_device
*icd
);
94 extern void soc_camera_video_stop(struct soc_camera_device
*icd
);
96 struct soc_camera_data_format
{
100 enum v4l2_colorspace colorspace
;
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
*);
118 const struct soc_camera_data_format
*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
;
124 unsigned int(*get_datawidth
)(struct soc_camera_device
*icd
);
127 static inline struct v4l2_queryctrl
const *soc_camera_find_qctrl(
128 struct soc_camera_ops
*ops
, int id
)
132 for (i
= 0; i
< ops
->num_controls
; i
++)
133 if (ops
->controls
[i
].id
== id
)
134 return &ops
->controls
[i
];
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)