| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 1 | /* |
| 2 | * include/media/v4l2-int-device.h |
| 3 | * |
| 4 | * V4L2 internal ioctl interface. |
| 5 | * |
| 6 | * Copyright (C) 2007 Nokia Corporation. |
| 7 | * |
| 8 | * Contact: Sakari Ailus <sakari.ailus@nokia.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License |
| 12 | * version 2 as published by the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 22 | * 02110-1301 USA |
| 23 | */ |
| 24 | |
| 25 | #ifndef V4L2_INT_DEVICE_H |
| 26 | #define V4L2_INT_DEVICE_H |
| 27 | |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 28 | #include <linux/module.h> |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 29 | #include <media/v4l2-common.h> |
| 30 | |
| 31 | #define V4L2NAMESIZE 32 |
| 32 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 33 | |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 34 | enum v4l2_int_type { |
| 35 | v4l2_int_type_master = 1, |
| 36 | v4l2_int_type_slave |
| 37 | }; |
| 38 | |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 39 | struct v4l2_int_device; |
| 40 | |
| 41 | struct v4l2_int_master { |
| Sakari Ailus | 2c94a67 | 2007-10-30 05:52:52 -0300 | [diff] [blame] | 42 | int (*attach)(struct v4l2_int_device *slave); |
| 43 | void (*detach)(struct v4l2_int_device *slave); |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *); |
| 47 | typedef int (v4l2_int_ioctl_func_0)(struct v4l2_int_device *); |
| 48 | typedef int (v4l2_int_ioctl_func_1)(struct v4l2_int_device *, void *); |
| 49 | |
| 50 | struct v4l2_int_ioctl_desc { |
| 51 | int num; |
| 52 | v4l2_int_ioctl_func *func; |
| 53 | }; |
| 54 | |
| 55 | struct v4l2_int_slave { |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 56 | |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 57 | struct v4l2_int_device *master; |
| 58 | |
| 59 | char attach_to[V4L2NAMESIZE]; |
| 60 | |
| 61 | int num_ioctls; |
| 62 | struct v4l2_int_ioctl_desc *ioctls; |
| 63 | }; |
| 64 | |
| 65 | struct v4l2_int_device { |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 66 | |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 67 | struct list_head head; |
| 68 | |
| 69 | struct module *module; |
| 70 | |
| 71 | char name[V4L2NAMESIZE]; |
| 72 | |
| 73 | enum v4l2_int_type type; |
| 74 | union { |
| 75 | struct v4l2_int_master *master; |
| 76 | struct v4l2_int_slave *slave; |
| 77 | } u; |
| 78 | |
| 79 | void *priv; |
| 80 | }; |
| 81 | |
| Sakari Ailus | 36499e5 | 2008-10-18 12:28:36 -0300 | [diff] [blame] | 82 | void v4l2_int_device_try_attach_all(void); |
| 83 | |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 84 | int v4l2_int_device_register(struct v4l2_int_device *d); |
| 85 | void v4l2_int_device_unregister(struct v4l2_int_device *d); |
| 86 | |
| 87 | int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd); |
| 88 | int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg); |
| 89 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 90 | |
| Sakari Ailus | 8438991 | 2008-10-18 12:27:50 -0300 | [diff] [blame] | 91 | enum v4l2_power { |
| 92 | V4L2_POWER_OFF = 0, |
| 93 | V4L2_POWER_ON, |
| 94 | V4L2_POWER_STANDBY, |
| 95 | }; |
| 96 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 97 | enum v4l2_if_type { |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 98 | V4L2_IF_TYPE_BT656, |
| 99 | }; |
| 100 | |
| 101 | enum v4l2_if_type_bt656_mode { |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 102 | V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT, |
| 103 | V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT, |
| 104 | V4L2_IF_TYPE_BT656_MODE_NOBT_12BIT, |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 105 | V4L2_IF_TYPE_BT656_MODE_BT_8BIT, |
| 106 | V4L2_IF_TYPE_BT656_MODE_BT_10BIT, |
| 107 | }; |
| 108 | |
| 109 | struct v4l2_if_type_bt656 { |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 110 | unsigned frame_start_on_rising_vs:1; |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 111 | |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 112 | unsigned bt_sync_correct:1; |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 113 | |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 114 | unsigned swap:1; |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 115 | |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 116 | unsigned latch_clk_inv:1; |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 117 | |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 118 | unsigned nobt_hs_inv:1; |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 119 | |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 120 | unsigned nobt_vs_inv:1; |
| 121 | enum v4l2_if_type_bt656_mode mode; |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 122 | |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 123 | u32 clock_min; |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 124 | |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 125 | u32 clock_max; |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 126 | u32 clock_curr; |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | struct v4l2_ifparm { |
| 130 | enum v4l2_if_type if_type; |
| 131 | union { |
| Sakari Ailus | 08256ea | 2007-08-30 09:20:39 -0300 | [diff] [blame] | 132 | struct v4l2_if_type_bt656 bt656; |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 133 | } u; |
| 134 | }; |
| 135 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 136 | enum v4l2_int_ioctl_num { |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 137 | vidioc_int_enum_fmt_cap_num = 1, |
| 138 | vidioc_int_g_fmt_cap_num, |
| 139 | vidioc_int_s_fmt_cap_num, |
| 140 | vidioc_int_try_fmt_cap_num, |
| 141 | vidioc_int_queryctrl_num, |
| 142 | vidioc_int_g_ctrl_num, |
| 143 | vidioc_int_s_ctrl_num, |
| Sameer Venkatraman | 621a373 | 2008-10-18 12:25:28 -0300 | [diff] [blame] | 144 | vidioc_int_cropcap_num, |
| 145 | vidioc_int_g_crop_num, |
| 146 | vidioc_int_s_crop_num, |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 147 | vidioc_int_g_parm_num, |
| 148 | vidioc_int_s_parm_num, |
| Vaibhav Hiremath | 67bc04d | 2008-12-05 10:13:40 -0300 | [diff] [blame] | 149 | vidioc_int_querystd_num, |
| 150 | vidioc_int_s_std_num, |
| 151 | vidioc_int_s_video_routing_num, |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 152 | |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 153 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 154 | vidioc_int_dev_init_num = 1000, |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 155 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 156 | vidioc_int_dev_exit_num, |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 157 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 158 | vidioc_int_s_power_num, |
| Sakari Ailus | 96014a9 | 2008-10-18 12:23:45 -0300 | [diff] [blame] | 159 | vidioc_int_g_priv_num, |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 160 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 161 | vidioc_int_g_ifparm_num, |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 162 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 163 | vidioc_int_g_needs_reset_num, |
| Sakari Ailus | f496bc7 | 2008-10-18 12:29:15 -0300 | [diff] [blame] | 164 | vidioc_int_enum_framesizes_num, |
| 165 | vidioc_int_enum_frameintervals_num, |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 166 | |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 167 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 168 | vidioc_int_reset_num, |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 169 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 170 | vidioc_int_init_num, |
| Flemmard | 0a7467c | 2013-05-20 14:23:09 -0700 | [diff] [blame] | 171 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 172 | vidioc_int_g_chip_ident_num, |
| 173 | |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 174 | vidioc_int_priv_start_num = 2000, |
| 175 | }; |
| 176 | |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 177 | |
| 178 | #define V4L2_INT_WRAPPER_0(name) \ |
| 179 | static inline int vidioc_int_##name(struct v4l2_int_device *d) \ |
| 180 | { \ |
| 181 | return v4l2_int_ioctl_0(d, vidioc_int_##name##_num); \ |
| 182 | } \ |
| 183 | \ |
| 184 | static inline struct v4l2_int_ioctl_desc \ |
| 185 | vidioc_int_##name##_cb(int (*func) \ |
| 186 | (struct v4l2_int_device *)) \ |
| 187 | { \ |
| 188 | struct v4l2_int_ioctl_desc desc; \ |
| 189 | \ |
| 190 | desc.num = vidioc_int_##name##_num; \ |
| 191 | desc.func = (v4l2_int_ioctl_func *)func; \ |
| 192 | \ |
| 193 | return desc; \ |
| 194 | } |
| 195 | |
| 196 | #define V4L2_INT_WRAPPER_1(name, arg_type, asterisk) \ |
| 197 | static inline int vidioc_int_##name(struct v4l2_int_device *d, \ |
| 198 | arg_type asterisk arg) \ |
| 199 | { \ |
| 200 | return v4l2_int_ioctl_1(d, vidioc_int_##name##_num, \ |
| Sakari Ailus | 63116fe | 2007-07-20 13:12:51 -0300 | [diff] [blame] | 201 | (void *)(unsigned long)arg); \ |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 202 | } \ |
| 203 | \ |
| 204 | static inline struct v4l2_int_ioctl_desc \ |
| 205 | vidioc_int_##name##_cb(int (*func) \ |
| 206 | (struct v4l2_int_device *, \ |
| 207 | arg_type asterisk)) \ |
| 208 | { \ |
| 209 | struct v4l2_int_ioctl_desc desc; \ |
| 210 | \ |
| 211 | desc.num = vidioc_int_##name##_num; \ |
| 212 | desc.func = (v4l2_int_ioctl_func *)func; \ |
| 213 | \ |
| 214 | return desc; \ |
| 215 | } |
| 216 | |
| 217 | V4L2_INT_WRAPPER_1(enum_fmt_cap, struct v4l2_fmtdesc, *); |
| 218 | V4L2_INT_WRAPPER_1(g_fmt_cap, struct v4l2_format, *); |
| 219 | V4L2_INT_WRAPPER_1(s_fmt_cap, struct v4l2_format, *); |
| 220 | V4L2_INT_WRAPPER_1(try_fmt_cap, struct v4l2_format, *); |
| 221 | V4L2_INT_WRAPPER_1(queryctrl, struct v4l2_queryctrl, *); |
| 222 | V4L2_INT_WRAPPER_1(g_ctrl, struct v4l2_control, *); |
| 223 | V4L2_INT_WRAPPER_1(s_ctrl, struct v4l2_control, *); |
| Sameer Venkatraman | 621a373 | 2008-10-18 12:25:28 -0300 | [diff] [blame] | 224 | V4L2_INT_WRAPPER_1(cropcap, struct v4l2_cropcap, *); |
| 225 | V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *); |
| 226 | V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *); |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 227 | V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *); |
| 228 | V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *); |
| Vaibhav Hiremath | 67bc04d | 2008-12-05 10:13:40 -0300 | [diff] [blame] | 229 | V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *); |
| 230 | V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *); |
| 231 | V4L2_INT_WRAPPER_1(s_video_routing, struct v4l2_routing, *); |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 232 | |
| 233 | V4L2_INT_WRAPPER_0(dev_init); |
| 234 | V4L2_INT_WRAPPER_0(dev_exit); |
| Sakari Ailus | 8438991 | 2008-10-18 12:27:50 -0300 | [diff] [blame] | 235 | V4L2_INT_WRAPPER_1(s_power, enum v4l2_power, ); |
| Sakari Ailus | 96014a9 | 2008-10-18 12:23:45 -0300 | [diff] [blame] | 236 | V4L2_INT_WRAPPER_1(g_priv, void, *); |
| Sakari Ailus | 098c645 | 2007-08-30 09:20:38 -0300 | [diff] [blame] | 237 | V4L2_INT_WRAPPER_1(g_ifparm, struct v4l2_ifparm, *); |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 238 | V4L2_INT_WRAPPER_1(g_needs_reset, void, *); |
| Sakari Ailus | f496bc7 | 2008-10-18 12:29:15 -0300 | [diff] [blame] | 239 | V4L2_INT_WRAPPER_1(enum_framesizes, struct v4l2_frmsizeenum, *); |
| 240 | V4L2_INT_WRAPPER_1(enum_frameintervals, struct v4l2_frmivalenum, *); |
| Sakari Ailus | 9b5d0f1 | 2007-07-18 17:59:15 -0300 | [diff] [blame] | 241 | |
| 242 | V4L2_INT_WRAPPER_0(reset); |
| 243 | V4L2_INT_WRAPPER_0(init); |
| 244 | V4L2_INT_WRAPPER_1(g_chip_ident, int, *); |
| 245 | |
| 246 | #endif |