Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 1 | /* |
| 2 | ioctl control functions |
| 3 | Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com> |
| 4 | Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl> |
| 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 as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
Roel Kluin | ed18d0c | 2009-07-23 21:46:57 -0300 | [diff] [blame] | 20 | #include <linux/kernel.h> |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 21 | |
| 22 | #include "ivtv-driver.h" |
| 23 | #include "ivtv-cards.h" |
| 24 | #include "ivtv-ioctl.h" |
Hans Verkuil | 33c0fca | 2007-08-23 06:32:46 -0300 | [diff] [blame] | 25 | #include "ivtv-routing.h" |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 26 | #include "ivtv-i2c.h" |
| 27 | #include "ivtv-mailbox.h" |
| 28 | #include "ivtv-controls.h" |
| 29 | |
Hans Verkuil | 2ba5889 | 2009-02-13 10:57:48 -0300 | [diff] [blame] | 30 | /* Must be sorted from low to high control ID! */ |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 31 | static const u32 user_ctrls[] = { |
| 32 | V4L2_CID_USER_CLASS, |
| 33 | V4L2_CID_BRIGHTNESS, |
| 34 | V4L2_CID_CONTRAST, |
| 35 | V4L2_CID_SATURATION, |
| 36 | V4L2_CID_HUE, |
| 37 | V4L2_CID_AUDIO_VOLUME, |
| 38 | V4L2_CID_AUDIO_BALANCE, |
| 39 | V4L2_CID_AUDIO_BASS, |
| 40 | V4L2_CID_AUDIO_TREBLE, |
| 41 | V4L2_CID_AUDIO_MUTE, |
| 42 | V4L2_CID_AUDIO_LOUDNESS, |
| 43 | 0 |
| 44 | }; |
| 45 | |
| 46 | static const u32 *ctrl_classes[] = { |
| 47 | user_ctrls, |
| 48 | cx2341x_mpeg_ctrls, |
| 49 | NULL |
| 50 | }; |
| 51 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 52 | |
| 53 | int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 54 | { |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 55 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 56 | const char *name; |
| 57 | |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 58 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); |
| 59 | if (qctrl->id == 0) |
| 60 | return -EINVAL; |
| 61 | |
| 62 | switch (qctrl->id) { |
| 63 | /* Standard V4L2 controls */ |
Hans Verkuil | c6711c3 | 2009-06-14 05:20:21 -0300 | [diff] [blame] | 64 | case V4L2_CID_USER_CLASS: |
| 65 | return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 66 | case V4L2_CID_BRIGHTNESS: |
| 67 | case V4L2_CID_HUE: |
| 68 | case V4L2_CID_SATURATION: |
| 69 | case V4L2_CID_CONTRAST: |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 70 | if (v4l2_subdev_call(itv->sd_video, core, queryctrl, qctrl)) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 71 | qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; |
| 72 | return 0; |
| 73 | |
| 74 | case V4L2_CID_AUDIO_VOLUME: |
| 75 | case V4L2_CID_AUDIO_MUTE: |
| 76 | case V4L2_CID_AUDIO_BALANCE: |
| 77 | case V4L2_CID_AUDIO_BASS: |
| 78 | case V4L2_CID_AUDIO_TREBLE: |
| 79 | case V4L2_CID_AUDIO_LOUDNESS: |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 80 | if (v4l2_subdev_call(itv->sd_audio, core, queryctrl, qctrl)) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 81 | qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; |
| 82 | return 0; |
| 83 | |
| 84 | default: |
| 85 | if (cx2341x_ctrl_query(&itv->params, qctrl)) |
| 86 | qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; |
| 87 | return 0; |
| 88 | } |
| 89 | strncpy(qctrl->name, name, sizeof(qctrl->name) - 1); |
| 90 | qctrl->name[sizeof(qctrl->name) - 1] = 0; |
| 91 | return 0; |
| 92 | } |
| 93 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 94 | int ivtv_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qmenu) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 95 | { |
Hans Verkuil | e0e31cd | 2008-06-22 12:03:28 -0300 | [diff] [blame] | 96 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 97 | struct v4l2_queryctrl qctrl; |
| 98 | |
| 99 | qctrl.id = qmenu->id; |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 100 | ivtv_queryctrl(file, fh, &qctrl); |
Hans Verkuil | e0e31cd | 2008-06-22 12:03:28 -0300 | [diff] [blame] | 101 | return v4l2_ctrl_query_menu(qmenu, &qctrl, |
| 102 | cx2341x_ctrl_get_menu(&itv->params, qmenu->id)); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 103 | } |
| 104 | |
Hans Verkuil | adb65bc | 2008-06-25 06:32:44 -0300 | [diff] [blame] | 105 | static int ivtv_try_ctrl(struct file *file, void *fh, |
| 106 | struct v4l2_ext_control *vctrl) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 107 | { |
Hans Verkuil | adb65bc | 2008-06-25 06:32:44 -0300 | [diff] [blame] | 108 | struct v4l2_queryctrl qctrl; |
| 109 | const char **menu_items = NULL; |
| 110 | int err; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 111 | |
Hans Verkuil | adb65bc | 2008-06-25 06:32:44 -0300 | [diff] [blame] | 112 | qctrl.id = vctrl->id; |
| 113 | err = ivtv_queryctrl(file, fh, &qctrl); |
| 114 | if (err) |
| 115 | return err; |
| 116 | if (qctrl.type == V4L2_CTRL_TYPE_MENU) |
| 117 | menu_items = v4l2_ctrl_get_menu(qctrl.id); |
| 118 | return v4l2_ctrl_check(vctrl, &qctrl, menu_items); |
| 119 | } |
| 120 | |
| 121 | static int ivtv_s_ctrl(struct ivtv *itv, struct v4l2_control *vctrl) |
| 122 | { |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 123 | switch (vctrl->id) { |
| 124 | /* Standard V4L2 controls */ |
| 125 | case V4L2_CID_BRIGHTNESS: |
| 126 | case V4L2_CID_HUE: |
| 127 | case V4L2_CID_SATURATION: |
| 128 | case V4L2_CID_CONTRAST: |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 129 | return v4l2_subdev_call(itv->sd_video, core, s_ctrl, vctrl); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 130 | |
| 131 | case V4L2_CID_AUDIO_VOLUME: |
| 132 | case V4L2_CID_AUDIO_MUTE: |
| 133 | case V4L2_CID_AUDIO_BALANCE: |
| 134 | case V4L2_CID_AUDIO_BASS: |
| 135 | case V4L2_CID_AUDIO_TREBLE: |
| 136 | case V4L2_CID_AUDIO_LOUDNESS: |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 137 | return v4l2_subdev_call(itv->sd_audio, core, s_ctrl, vctrl); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 138 | |
| 139 | default: |
Hans Verkuil | 37f89f9 | 2008-06-22 11:57:31 -0300 | [diff] [blame] | 140 | IVTV_DEBUG_IOCTL("invalid control 0x%x\n", vctrl->id); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 141 | return -EINVAL; |
| 142 | } |
| 143 | return 0; |
| 144 | } |
| 145 | |
Hans Verkuil | adb65bc | 2008-06-25 06:32:44 -0300 | [diff] [blame] | 146 | static int ivtv_g_ctrl(struct ivtv *itv, struct v4l2_control *vctrl) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 147 | { |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 148 | switch (vctrl->id) { |
| 149 | /* Standard V4L2 controls */ |
| 150 | case V4L2_CID_BRIGHTNESS: |
| 151 | case V4L2_CID_HUE: |
| 152 | case V4L2_CID_SATURATION: |
| 153 | case V4L2_CID_CONTRAST: |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 154 | return v4l2_subdev_call(itv->sd_video, core, g_ctrl, vctrl); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 155 | |
| 156 | case V4L2_CID_AUDIO_VOLUME: |
| 157 | case V4L2_CID_AUDIO_MUTE: |
| 158 | case V4L2_CID_AUDIO_BALANCE: |
| 159 | case V4L2_CID_AUDIO_BASS: |
| 160 | case V4L2_CID_AUDIO_TREBLE: |
| 161 | case V4L2_CID_AUDIO_LOUDNESS: |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 162 | return v4l2_subdev_call(itv->sd_audio, core, g_ctrl, vctrl); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 163 | default: |
Hans Verkuil | 37f89f9 | 2008-06-22 11:57:31 -0300 | [diff] [blame] | 164 | IVTV_DEBUG_IOCTL("invalid control 0x%x\n", vctrl->id); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 165 | return -EINVAL; |
| 166 | } |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | static int ivtv_setup_vbi_fmt(struct ivtv *itv, enum v4l2_mpeg_stream_vbi_fmt fmt) |
| 171 | { |
| 172 | if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) |
| 173 | return -EINVAL; |
| 174 | if (atomic_read(&itv->capturing) > 0) |
| 175 | return -EBUSY; |
| 176 | |
| 177 | /* First try to allocate sliced VBI buffers if needed. */ |
| 178 | if (fmt && itv->vbi.sliced_mpeg_data[0] == NULL) { |
| 179 | int i; |
| 180 | |
| 181 | for (i = 0; i < IVTV_VBI_FRAMES; i++) { |
| 182 | /* Yuck, hardcoded. Needs to be a define */ |
| 183 | itv->vbi.sliced_mpeg_data[i] = kmalloc(2049, GFP_KERNEL); |
| 184 | if (itv->vbi.sliced_mpeg_data[i] == NULL) { |
| 185 | while (--i >= 0) { |
| 186 | kfree(itv->vbi.sliced_mpeg_data[i]); |
| 187 | itv->vbi.sliced_mpeg_data[i] = NULL; |
| 188 | } |
| 189 | return -ENOMEM; |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | itv->vbi.insert_mpeg = fmt; |
| 195 | |
| 196 | if (itv->vbi.insert_mpeg == 0) { |
| 197 | return 0; |
| 198 | } |
| 199 | /* Need sliced data for mpeg insertion */ |
Hans Verkuil | feb5bce | 2008-05-01 09:22:13 -0300 | [diff] [blame] | 200 | if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) { |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 201 | if (itv->is_60hz) |
| 202 | itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; |
| 203 | else |
| 204 | itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; |
Hans Verkuil | feb5bce | 2008-05-01 09:22:13 -0300 | [diff] [blame] | 205 | ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 206 | } |
| 207 | return 0; |
| 208 | } |
| 209 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 210 | int ivtv_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 211 | { |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 212 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 213 | struct v4l2_control ctrl; |
| 214 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 215 | if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { |
| 216 | int i; |
| 217 | int err = 0; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 218 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 219 | for (i = 0; i < c->count; i++) { |
| 220 | ctrl.id = c->controls[i].id; |
| 221 | ctrl.value = c->controls[i].value; |
Hans Verkuil | adb65bc | 2008-06-25 06:32:44 -0300 | [diff] [blame] | 222 | err = ivtv_g_ctrl(itv, &ctrl); |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 223 | c->controls[i].value = ctrl.value; |
| 224 | if (err) { |
| 225 | c->error_idx = i; |
| 226 | break; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 227 | } |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 228 | } |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 229 | return err; |
| 230 | } |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 231 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) |
| 232 | return cx2341x_ext_ctrls(&itv->params, 0, c, VIDIOC_G_EXT_CTRLS); |
| 233 | return -EINVAL; |
| 234 | } |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 235 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 236 | int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) |
| 237 | { |
| 238 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
| 239 | struct v4l2_control ctrl; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 240 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 241 | if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { |
| 242 | int i; |
| 243 | int err = 0; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 244 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 245 | for (i = 0; i < c->count; i++) { |
| 246 | ctrl.id = c->controls[i].id; |
| 247 | ctrl.value = c->controls[i].value; |
Hans Verkuil | adb65bc | 2008-06-25 06:32:44 -0300 | [diff] [blame] | 248 | err = ivtv_s_ctrl(itv, &ctrl); |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 249 | c->controls[i].value = ctrl.value; |
| 250 | if (err) { |
| 251 | c->error_idx = i; |
| 252 | break; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 253 | } |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 254 | } |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 255 | return err; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 256 | } |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 257 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { |
| 258 | static u32 freqs[3] = { 44100, 48000, 32000 }; |
| 259 | struct cx2341x_mpeg_params p = itv->params; |
| 260 | int err = cx2341x_ext_ctrls(&p, atomic_read(&itv->capturing), c, VIDIOC_S_EXT_CTRLS); |
| 261 | unsigned idx; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 262 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 263 | if (err) |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 264 | return err; |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 265 | |
| 266 | if (p.video_encoding != itv->params.video_encoding) { |
| 267 | int is_mpeg1 = p.video_encoding == |
| 268 | V4L2_MPEG_VIDEO_ENCODING_MPEG_1; |
| 269 | struct v4l2_format fmt; |
| 270 | |
| 271 | /* fix videodecoder resolution */ |
| 272 | fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 273 | fmt.fmt.pix.width = itv->params.width / (is_mpeg1 ? 2 : 1); |
| 274 | fmt.fmt.pix.height = itv->params.height; |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 275 | v4l2_subdev_call(itv->sd_video, video, s_fmt, &fmt); |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 276 | } |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 277 | err = cx2341x_update(itv, ivtv_api_func, &itv->params, &p); |
| 278 | if (!err && itv->params.stream_vbi_fmt != p.stream_vbi_fmt) |
| 279 | err = ivtv_setup_vbi_fmt(itv, p.stream_vbi_fmt); |
| 280 | itv->params = p; |
| 281 | itv->dualwatch_stereo_mode = p.audio_properties & 0x0300; |
| 282 | idx = p.audio_properties & 0x03; |
| 283 | /* The audio clock of the digitizer must match the codec sample |
| 284 | rate otherwise you get some very strange effects. */ |
Roel Kluin | ed18d0c | 2009-07-23 21:46:57 -0300 | [diff] [blame] | 285 | if (idx < ARRAY_SIZE(freqs)) |
Hans Verkuil | 67ec09f | 2008-11-29 19:38:23 -0300 | [diff] [blame] | 286 | ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]); |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 287 | return err; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 288 | } |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 289 | return -EINVAL; |
| 290 | } |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 291 | |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 292 | int ivtv_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) |
| 293 | { |
| 294 | struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 295 | |
Hans Verkuil | adb65bc | 2008-06-25 06:32:44 -0300 | [diff] [blame] | 296 | if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { |
| 297 | int i; |
| 298 | int err = 0; |
| 299 | |
| 300 | for (i = 0; i < c->count; i++) { |
| 301 | err = ivtv_try_ctrl(file, fh, &c->controls[i]); |
| 302 | if (err) { |
| 303 | c->error_idx = i; |
| 304 | break; |
| 305 | } |
| 306 | } |
| 307 | return err; |
| 308 | } |
Hans Verkuil | 3f038d8 | 2008-05-29 16:43:54 -0300 | [diff] [blame] | 309 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) |
| 310 | return cx2341x_ext_ctrls(&itv->params, atomic_read(&itv->capturing), c, VIDIOC_TRY_EXT_CTRLS); |
| 311 | return -EINVAL; |
Hans Verkuil | 1a0adaf | 2007-04-27 12:31:25 -0300 | [diff] [blame] | 312 | } |