Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * device driver for Conexant 2388x based TV cards |
| 4 | * video4linux video interface |
| 5 | * |
| 6 | * (c) 2003-04 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] |
| 7 | * |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 8 | * (c) 2005-2006 Mauro Carvalho Chehab <mchehab@infradead.org> |
| 9 | * - Multituner support |
| 10 | * - video_ioctl2 conversion |
| 11 | * - PAL/M fixes |
| 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 26 | */ |
| 27 | |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/list.h> |
| 30 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <linux/kmod.h> |
| 32 | #include <linux/kernel.h> |
| 33 | #include <linux/slab.h> |
Alexey Dobriyan | 405f557 | 2009-07-11 22:08:37 +0400 | [diff] [blame] | 34 | #include <linux/smp_lock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/interrupt.h> |
Andrew Morton | c24228d | 2007-05-06 14:51:55 -0700 | [diff] [blame] | 36 | #include <linux/dma-mapping.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <linux/delay.h> |
| 38 | #include <linux/kthread.h> |
| 39 | #include <asm/div64.h> |
| 40 | |
| 41 | #include "cx88.h" |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 42 | #include <media/v4l2-common.h> |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 43 | #include <media/v4l2-ioctl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); |
| 46 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 47 | MODULE_LICENSE("GPL"); |
| 48 | |
| 49 | /* ------------------------------------------------------------------ */ |
| 50 | |
| 51 | static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; |
| 52 | static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; |
| 53 | static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; |
| 54 | |
| 55 | module_param_array(video_nr, int, NULL, 0444); |
| 56 | module_param_array(vbi_nr, int, NULL, 0444); |
| 57 | module_param_array(radio_nr, int, NULL, 0444); |
| 58 | |
| 59 | MODULE_PARM_DESC(video_nr,"video device numbers"); |
| 60 | MODULE_PARM_DESC(vbi_nr,"vbi device numbers"); |
| 61 | MODULE_PARM_DESC(radio_nr,"radio device numbers"); |
| 62 | |
Douglas Schilling Landgraf | ff699e6 | 2008-04-22 14:41:48 -0300 | [diff] [blame] | 63 | static unsigned int video_debug; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | module_param(video_debug,int,0644); |
| 65 | MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); |
| 66 | |
Douglas Schilling Landgraf | ff699e6 | 2008-04-22 14:41:48 -0300 | [diff] [blame] | 67 | static unsigned int irq_debug; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | module_param(irq_debug,int,0644); |
| 69 | MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); |
| 70 | |
| 71 | static unsigned int vid_limit = 16; |
| 72 | module_param(vid_limit,int,0644); |
| 73 | MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); |
| 74 | |
| 75 | #define dprintk(level,fmt, arg...) if (video_debug >= level) \ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 76 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | /* ------------------------------------------------------------------- */ |
| 79 | /* static data */ |
| 80 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 81 | static const struct cx8800_fmt formats[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | { |
| 83 | .name = "8 bpp, gray", |
| 84 | .fourcc = V4L2_PIX_FMT_GREY, |
| 85 | .cxformat = ColorFormatY8, |
| 86 | .depth = 8, |
| 87 | .flags = FORMAT_FLAGS_PACKED, |
| 88 | },{ |
| 89 | .name = "15 bpp RGB, le", |
| 90 | .fourcc = V4L2_PIX_FMT_RGB555, |
| 91 | .cxformat = ColorFormatRGB15, |
| 92 | .depth = 16, |
| 93 | .flags = FORMAT_FLAGS_PACKED, |
| 94 | },{ |
| 95 | .name = "15 bpp RGB, be", |
| 96 | .fourcc = V4L2_PIX_FMT_RGB555X, |
| 97 | .cxformat = ColorFormatRGB15 | ColorFormatBSWAP, |
| 98 | .depth = 16, |
| 99 | .flags = FORMAT_FLAGS_PACKED, |
| 100 | },{ |
| 101 | .name = "16 bpp RGB, le", |
| 102 | .fourcc = V4L2_PIX_FMT_RGB565, |
| 103 | .cxformat = ColorFormatRGB16, |
| 104 | .depth = 16, |
| 105 | .flags = FORMAT_FLAGS_PACKED, |
| 106 | },{ |
| 107 | .name = "16 bpp RGB, be", |
| 108 | .fourcc = V4L2_PIX_FMT_RGB565X, |
| 109 | .cxformat = ColorFormatRGB16 | ColorFormatBSWAP, |
| 110 | .depth = 16, |
| 111 | .flags = FORMAT_FLAGS_PACKED, |
| 112 | },{ |
| 113 | .name = "24 bpp RGB, le", |
| 114 | .fourcc = V4L2_PIX_FMT_BGR24, |
| 115 | .cxformat = ColorFormatRGB24, |
| 116 | .depth = 24, |
| 117 | .flags = FORMAT_FLAGS_PACKED, |
| 118 | },{ |
| 119 | .name = "32 bpp RGB, le", |
| 120 | .fourcc = V4L2_PIX_FMT_BGR32, |
| 121 | .cxformat = ColorFormatRGB32, |
| 122 | .depth = 32, |
| 123 | .flags = FORMAT_FLAGS_PACKED, |
| 124 | },{ |
| 125 | .name = "32 bpp RGB, be", |
| 126 | .fourcc = V4L2_PIX_FMT_RGB32, |
| 127 | .cxformat = ColorFormatRGB32 | ColorFormatBSWAP | ColorFormatWSWAP, |
| 128 | .depth = 32, |
| 129 | .flags = FORMAT_FLAGS_PACKED, |
| 130 | },{ |
| 131 | .name = "4:2:2, packed, YUYV", |
| 132 | .fourcc = V4L2_PIX_FMT_YUYV, |
| 133 | .cxformat = ColorFormatYUY2, |
| 134 | .depth = 16, |
| 135 | .flags = FORMAT_FLAGS_PACKED, |
| 136 | },{ |
| 137 | .name = "4:2:2, packed, UYVY", |
| 138 | .fourcc = V4L2_PIX_FMT_UYVY, |
| 139 | .cxformat = ColorFormatYUY2 | ColorFormatBSWAP, |
| 140 | .depth = 16, |
| 141 | .flags = FORMAT_FLAGS_PACKED, |
| 142 | }, |
| 143 | }; |
| 144 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 145 | static const struct cx8800_fmt* format_by_fourcc(unsigned int fourcc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
| 147 | unsigned int i; |
| 148 | |
| 149 | for (i = 0; i < ARRAY_SIZE(formats); i++) |
| 150 | if (formats[i].fourcc == fourcc) |
| 151 | return formats+i; |
| 152 | return NULL; |
| 153 | } |
| 154 | |
| 155 | /* ------------------------------------------------------------------- */ |
| 156 | |
| 157 | static const struct v4l2_queryctrl no_ctl = { |
| 158 | .name = "42", |
| 159 | .flags = V4L2_CTRL_FLAG_DISABLED, |
| 160 | }; |
| 161 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 162 | static const struct cx88_ctrl cx8800_ctls[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | /* --- video --- */ |
| 164 | { |
| 165 | .v = { |
| 166 | .id = V4L2_CID_BRIGHTNESS, |
| 167 | .name = "Brightness", |
| 168 | .minimum = 0x00, |
| 169 | .maximum = 0xff, |
| 170 | .step = 1, |
Marcin Rudowski | 9f9c907 | 2006-03-12 00:03:47 -0300 | [diff] [blame] | 171 | .default_value = 0x7f, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 173 | }, |
| 174 | .off = 128, |
| 175 | .reg = MO_CONTR_BRIGHT, |
| 176 | .mask = 0x00ff, |
| 177 | .shift = 0, |
| 178 | },{ |
| 179 | .v = { |
| 180 | .id = V4L2_CID_CONTRAST, |
| 181 | .name = "Contrast", |
| 182 | .minimum = 0, |
| 183 | .maximum = 0xff, |
| 184 | .step = 1, |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 185 | .default_value = 0x3f, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 187 | }, |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 188 | .off = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | .reg = MO_CONTR_BRIGHT, |
| 190 | .mask = 0xff00, |
| 191 | .shift = 8, |
| 192 | },{ |
| 193 | .v = { |
| 194 | .id = V4L2_CID_HUE, |
| 195 | .name = "Hue", |
| 196 | .minimum = 0, |
| 197 | .maximum = 0xff, |
| 198 | .step = 1, |
Marcin Rudowski | 9f9c907 | 2006-03-12 00:03:47 -0300 | [diff] [blame] | 199 | .default_value = 0x7f, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 201 | }, |
Michael Krufky | 9ac4c158 | 2005-07-07 17:58:38 -0700 | [diff] [blame] | 202 | .off = 128, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | .reg = MO_HUE, |
| 204 | .mask = 0x00ff, |
| 205 | .shift = 0, |
| 206 | },{ |
| 207 | /* strictly, this only describes only U saturation. |
| 208 | * V saturation is handled specially through code. |
| 209 | */ |
| 210 | .v = { |
| 211 | .id = V4L2_CID_SATURATION, |
| 212 | .name = "Saturation", |
| 213 | .minimum = 0, |
| 214 | .maximum = 0xff, |
| 215 | .step = 1, |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 216 | .default_value = 0x7f, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 218 | }, |
| 219 | .off = 0, |
| 220 | .reg = MO_UV_SATURATION, |
| 221 | .mask = 0x00ff, |
| 222 | .shift = 0, |
| 223 | },{ |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 224 | .v = { |
| 225 | .id = V4L2_CID_CHROMA_AGC, |
| 226 | .name = "Chroma AGC", |
| 227 | .minimum = 0, |
| 228 | .maximum = 1, |
Frej Drejhammar | 87a1738 | 2008-03-23 22:43:22 -0300 | [diff] [blame] | 229 | .default_value = 0x1, |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 230 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 231 | }, |
| 232 | .reg = MO_INPUT_FORMAT, |
| 233 | .mask = 1 << 10, |
| 234 | .shift = 10, |
| 235 | }, { |
Frej Drejhammar | 1b879c4 | 2008-03-23 22:43:24 -0300 | [diff] [blame] | 236 | .v = { |
| 237 | .id = V4L2_CID_COLOR_KILLER, |
| 238 | .name = "Color killer", |
| 239 | .minimum = 0, |
| 240 | .maximum = 1, |
Frej Drejhammar | 0b5afdd | 2008-03-23 22:43:25 -0300 | [diff] [blame] | 241 | .default_value = 0x1, |
Frej Drejhammar | 1b879c4 | 2008-03-23 22:43:24 -0300 | [diff] [blame] | 242 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 243 | }, |
| 244 | .reg = MO_INPUT_FORMAT, |
| 245 | .mask = 1 << 9, |
| 246 | .shift = 9, |
| 247 | }, { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | /* --- audio --- */ |
| 249 | .v = { |
| 250 | .id = V4L2_CID_AUDIO_MUTE, |
| 251 | .name = "Mute", |
| 252 | .minimum = 0, |
| 253 | .maximum = 1, |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 254 | .default_value = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 256 | }, |
| 257 | .reg = AUD_VOL_CTL, |
| 258 | .sreg = SHADOW_AUD_VOL_CTL, |
| 259 | .mask = (1 << 6), |
| 260 | .shift = 6, |
| 261 | },{ |
| 262 | .v = { |
| 263 | .id = V4L2_CID_AUDIO_VOLUME, |
| 264 | .name = "Volume", |
| 265 | .minimum = 0, |
| 266 | .maximum = 0x3f, |
| 267 | .step = 1, |
Marcin Rudowski | 9f9c907 | 2006-03-12 00:03:47 -0300 | [diff] [blame] | 268 | .default_value = 0x3f, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 270 | }, |
| 271 | .reg = AUD_VOL_CTL, |
| 272 | .sreg = SHADOW_AUD_VOL_CTL, |
| 273 | .mask = 0x3f, |
| 274 | .shift = 0, |
| 275 | },{ |
| 276 | .v = { |
| 277 | .id = V4L2_CID_AUDIO_BALANCE, |
| 278 | .name = "Balance", |
| 279 | .minimum = 0, |
| 280 | .maximum = 0x7f, |
| 281 | .step = 1, |
| 282 | .default_value = 0x40, |
| 283 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 284 | }, |
| 285 | .reg = AUD_BAL_CTL, |
| 286 | .sreg = SHADOW_AUD_BAL_CTL, |
| 287 | .mask = 0x7f, |
| 288 | .shift = 0, |
| 289 | } |
| 290 | }; |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 291 | enum { CX8800_CTLS = ARRAY_SIZE(cx8800_ctls) }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
Hans Verkuil | 2ba5889 | 2009-02-13 10:57:48 -0300 | [diff] [blame] | 293 | /* Must be sorted from low to high control ID! */ |
Michael Krufky | 38a2713 | 2006-06-26 23:42:39 -0300 | [diff] [blame] | 294 | const u32 cx88_user_ctrls[] = { |
| 295 | V4L2_CID_USER_CLASS, |
| 296 | V4L2_CID_BRIGHTNESS, |
| 297 | V4L2_CID_CONTRAST, |
| 298 | V4L2_CID_SATURATION, |
| 299 | V4L2_CID_HUE, |
| 300 | V4L2_CID_AUDIO_VOLUME, |
| 301 | V4L2_CID_AUDIO_BALANCE, |
| 302 | V4L2_CID_AUDIO_MUTE, |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 303 | V4L2_CID_CHROMA_AGC, |
Frej Drejhammar | 1b879c4 | 2008-03-23 22:43:24 -0300 | [diff] [blame] | 304 | V4L2_CID_COLOR_KILLER, |
Michael Krufky | 38a2713 | 2006-06-26 23:42:39 -0300 | [diff] [blame] | 305 | 0 |
| 306 | }; |
| 307 | EXPORT_SYMBOL(cx88_user_ctrls); |
| 308 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 309 | static const u32 * const ctrl_classes[] = { |
Michael Krufky | 38a2713 | 2006-06-26 23:42:39 -0300 | [diff] [blame] | 310 | cx88_user_ctrls, |
| 311 | NULL |
| 312 | }; |
| 313 | |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 314 | int cx8800_ctrl_query(struct cx88_core *core, struct v4l2_queryctrl *qctrl) |
Michael Krufky | 38a2713 | 2006-06-26 23:42:39 -0300 | [diff] [blame] | 315 | { |
| 316 | int i; |
| 317 | |
| 318 | if (qctrl->id < V4L2_CID_BASE || |
| 319 | qctrl->id >= V4L2_CID_LASTP1) |
| 320 | return -EINVAL; |
| 321 | for (i = 0; i < CX8800_CTLS; i++) |
| 322 | if (cx8800_ctls[i].v.id == qctrl->id) |
| 323 | break; |
| 324 | if (i == CX8800_CTLS) { |
| 325 | *qctrl = no_ctl; |
| 326 | return 0; |
| 327 | } |
| 328 | *qctrl = cx8800_ctls[i].v; |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 329 | /* Report chroma AGC as inactive when SECAM is selected */ |
| 330 | if (cx8800_ctls[i].v.id == V4L2_CID_CHROMA_AGC && |
| 331 | core->tvnorm & V4L2_STD_SECAM) |
| 332 | qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; |
| 333 | |
Michael Krufky | 38a2713 | 2006-06-26 23:42:39 -0300 | [diff] [blame] | 334 | return 0; |
| 335 | } |
| 336 | EXPORT_SYMBOL(cx8800_ctrl_query); |
| 337 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | /* ------------------------------------------------------------------- */ |
| 339 | /* resource management */ |
| 340 | |
| 341 | static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bit) |
| 342 | { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 343 | struct cx88_core *core = dev->core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | if (fh->resources & bit) |
| 345 | /* have it already allocated */ |
| 346 | return 1; |
| 347 | |
| 348 | /* is it free? */ |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 349 | mutex_lock(&core->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | if (dev->resources & bit) { |
| 351 | /* no, someone else uses it */ |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 352 | mutex_unlock(&core->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | return 0; |
| 354 | } |
| 355 | /* it's free, grab it */ |
| 356 | fh->resources |= bit; |
| 357 | dev->resources |= bit; |
| 358 | dprintk(1,"res: get %d\n",bit); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 359 | mutex_unlock(&core->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | return 1; |
| 361 | } |
| 362 | |
| 363 | static |
| 364 | int res_check(struct cx8800_fh *fh, unsigned int bit) |
| 365 | { |
| 366 | return (fh->resources & bit); |
| 367 | } |
| 368 | |
| 369 | static |
| 370 | int res_locked(struct cx8800_dev *dev, unsigned int bit) |
| 371 | { |
| 372 | return (dev->resources & bit); |
| 373 | } |
| 374 | |
| 375 | static |
| 376 | void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits) |
| 377 | { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 378 | struct cx88_core *core = dev->core; |
Eric Sesterhenn | ae24601 | 2006-03-13 13:17:11 -0300 | [diff] [blame] | 379 | BUG_ON((fh->resources & bits) != bits); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 381 | mutex_lock(&core->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | fh->resources &= ~bits; |
| 383 | dev->resources &= ~bits; |
| 384 | dprintk(1,"res: put %d\n",bits); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 385 | mutex_unlock(&core->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /* ------------------------------------------------------------------ */ |
| 389 | |
Mauro Carvalho Chehab | e90311a | 2007-01-20 13:58:29 -0300 | [diff] [blame] | 390 | int cx88_video_mux(struct cx88_core *core, unsigned int input) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 392 | /* struct cx88_core *core = dev->core; */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
| 394 | dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n", |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 395 | input, INPUT(input).vmux, |
| 396 | INPUT(input).gpio0,INPUT(input).gpio1, |
| 397 | INPUT(input).gpio2,INPUT(input).gpio3); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 398 | core->input = input; |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 399 | cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input).vmux << 14); |
| 400 | cx_write(MO_GP3_IO, INPUT(input).gpio3); |
| 401 | cx_write(MO_GP0_IO, INPUT(input).gpio0); |
| 402 | cx_write(MO_GP1_IO, INPUT(input).gpio1); |
| 403 | cx_write(MO_GP2_IO, INPUT(input).gpio2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 405 | switch (INPUT(input).type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | case CX88_VMUX_SVIDEO: |
| 407 | cx_set(MO_AFECFG_IO, 0x00000001); |
| 408 | cx_set(MO_INPUT_FORMAT, 0x00010010); |
| 409 | cx_set(MO_FILTER_EVEN, 0x00002020); |
| 410 | cx_set(MO_FILTER_ODD, 0x00002020); |
| 411 | break; |
| 412 | default: |
| 413 | cx_clear(MO_AFECFG_IO, 0x00000001); |
| 414 | cx_clear(MO_INPUT_FORMAT, 0x00010010); |
| 415 | cx_clear(MO_FILTER_EVEN, 0x00002020); |
| 416 | cx_clear(MO_FILTER_ODD, 0x00002020); |
| 417 | break; |
| 418 | } |
Michael Krufky | f24546a | 2006-10-16 16:51:11 -0300 | [diff] [blame] | 419 | |
Ricardo Cerqueira | 66e6fbd | 2007-10-16 20:52:08 -0300 | [diff] [blame] | 420 | /* if there are audioroutes defined, we have an external |
| 421 | ADC to deal with audio */ |
Ricardo Cerqueira | 66e6fbd | 2007-10-16 20:52:08 -0300 | [diff] [blame] | 422 | if (INPUT(input).audioroute) { |
Ricardo Cerqueira | 66e6fbd | 2007-10-16 20:52:08 -0300 | [diff] [blame] | 423 | /* The wm8775 module has the "2" route hardwired into |
| 424 | the initialization. Some boards may use different |
| 425 | routes for different inputs. HVR-1300 surely does */ |
| 426 | if (core->board.audio_chip && |
Hans Verkuil | 38f9d30 | 2008-07-23 05:09:15 -0300 | [diff] [blame] | 427 | core->board.audio_chip == V4L2_IDENT_WM8775) { |
Hans Verkuil | 5325b42 | 2009-04-02 11:26:22 -0300 | [diff] [blame] | 428 | call_all(core, audio, s_routing, |
istvan_v@mailbox.hu | 6e1f4df | 2010-03-27 09:31:32 -0300 | [diff] [blame] | 429 | INPUT(input).audioroute, 0, 0); |
Ricardo Cerqueira | 66e6fbd | 2007-10-16 20:52:08 -0300 | [diff] [blame] | 430 | } |
Darron Broad | 430189d | 2008-10-15 14:18:42 -0300 | [diff] [blame] | 431 | /* cx2388's C-ADC is connected to the tuner only. |
| 432 | When used with S-Video, that ADC is busy dealing with |
| 433 | chroma, so an external must be used for baseband audio */ |
istvan_v@mailbox.hu | 6e1f4df | 2010-03-27 09:31:32 -0300 | [diff] [blame] | 434 | if (INPUT(input).type != CX88_VMUX_TELEVISION && |
| 435 | INPUT(input).type != CX88_VMUX_CABLE) { |
Darron Broad | 430189d | 2008-10-15 14:18:42 -0300 | [diff] [blame] | 436 | /* "I2S ADC mode" */ |
| 437 | core->tvaudio = WW_I2SADC; |
| 438 | cx88_set_tvaudio(core); |
| 439 | } else { |
| 440 | /* Normal mode */ |
| 441 | cx_write(AUD_I2SCNTL, 0x0); |
| 442 | cx_clear(AUD_CTL, EN_I2SIN_ENABLE); |
| 443 | } |
Michael Krufky | f24546a | 2006-10-16 16:51:11 -0300 | [diff] [blame] | 444 | } |
Ricardo Cerqueira | 66e6fbd | 2007-10-16 20:52:08 -0300 | [diff] [blame] | 445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | return 0; |
| 447 | } |
Mauro Carvalho Chehab | e90311a | 2007-01-20 13:58:29 -0300 | [diff] [blame] | 448 | EXPORT_SYMBOL(cx88_video_mux); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | |
| 450 | /* ------------------------------------------------------------------ */ |
| 451 | |
| 452 | static int start_video_dma(struct cx8800_dev *dev, |
| 453 | struct cx88_dmaqueue *q, |
| 454 | struct cx88_buffer *buf) |
| 455 | { |
| 456 | struct cx88_core *core = dev->core; |
| 457 | |
| 458 | /* setup fifo + format */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 459 | cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | buf->bpl, buf->risc.dma); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 461 | cx88_set_scale(core, buf->vb.width, buf->vb.height, buf->vb.field); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma); |
| 463 | |
| 464 | /* reset counter */ |
| 465 | cx_write(MO_VIDY_GPCNTRL,GP_COUNT_CONTROL_RESET); |
| 466 | q->count = 1; |
| 467 | |
| 468 | /* enable irqs */ |
Trent Piepho | 8ddac9e | 2007-08-18 06:57:55 -0300 | [diff] [blame] | 469 | cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_VIDINT); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 470 | |
| 471 | /* Enables corresponding bits at PCI_INT_STAT: |
| 472 | bits 0 to 4: video, audio, transport stream, VIP, Host |
| 473 | bit 7: timer |
| 474 | bits 8 and 9: DMA complete for: SRC, DST |
| 475 | bits 10 and 11: BERR signal asserted for RISC: RD, WR |
| 476 | bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB |
| 477 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | cx_set(MO_VID_INTMSK, 0x0f0011); |
| 479 | |
| 480 | /* enable capture */ |
| 481 | cx_set(VID_CAPTURE_CONTROL,0x06); |
| 482 | |
| 483 | /* start dma */ |
| 484 | cx_set(MO_DEV_CNTRL2, (1<<5)); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 485 | cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
| 487 | return 0; |
| 488 | } |
| 489 | |
Alexey Dobriyan | 17bc98a | 2006-08-12 22:01:27 -0300 | [diff] [blame] | 490 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | static int stop_video_dma(struct cx8800_dev *dev) |
| 492 | { |
| 493 | struct cx88_core *core = dev->core; |
| 494 | |
| 495 | /* stop dma */ |
| 496 | cx_clear(MO_VID_DMACNTRL, 0x11); |
| 497 | |
| 498 | /* disable capture */ |
| 499 | cx_clear(VID_CAPTURE_CONTROL,0x06); |
| 500 | |
| 501 | /* disable irqs */ |
Trent Piepho | 8ddac9e | 2007-08-18 06:57:55 -0300 | [diff] [blame] | 502 | cx_clear(MO_PCI_INTMSK, PCI_INT_VIDINT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | cx_clear(MO_VID_INTMSK, 0x0f0011); |
| 504 | return 0; |
| 505 | } |
Alexey Dobriyan | 17bc98a | 2006-08-12 22:01:27 -0300 | [diff] [blame] | 506 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | |
| 508 | static int restart_video_queue(struct cx8800_dev *dev, |
| 509 | struct cx88_dmaqueue *q) |
| 510 | { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 511 | struct cx88_core *core = dev->core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | struct cx88_buffer *buf, *prev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
| 514 | if (!list_empty(&q->active)) { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 515 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", |
| 517 | buf, buf->vb.i); |
| 518 | start_video_dma(dev, q, buf); |
Trent Piepho | 8bb629e2 | 2007-10-10 05:37:40 -0300 | [diff] [blame] | 519 | list_for_each_entry(buf, &q->active, vb.queue) |
| 520 | buf->count = q->count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
| 522 | return 0; |
| 523 | } |
| 524 | |
| 525 | prev = NULL; |
| 526 | for (;;) { |
| 527 | if (list_empty(&q->queued)) |
| 528 | return 0; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 529 | buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | if (NULL == prev) { |
Akinobu Mita | 179e091 | 2006-06-26 00:24:41 -0700 | [diff] [blame] | 531 | list_move_tail(&buf->vb.queue, &q->active); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | start_video_dma(dev, q, buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 533 | buf->vb.state = VIDEOBUF_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | buf->count = q->count++; |
| 535 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
| 536 | dprintk(2,"[%p/%d] restart_queue - first active\n", |
| 537 | buf,buf->vb.i); |
| 538 | |
| 539 | } else if (prev->vb.width == buf->vb.width && |
| 540 | prev->vb.height == buf->vb.height && |
| 541 | prev->fmt == buf->fmt) { |
Akinobu Mita | 179e091 | 2006-06-26 00:24:41 -0700 | [diff] [blame] | 542 | list_move_tail(&buf->vb.queue, &q->active); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 543 | buf->vb.state = VIDEOBUF_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | buf->count = q->count++; |
| 545 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
| 546 | dprintk(2,"[%p/%d] restart_queue - move to active\n", |
| 547 | buf,buf->vb.i); |
| 548 | } else { |
| 549 | return 0; |
| 550 | } |
| 551 | prev = buf; |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | /* ------------------------------------------------------------------ */ |
| 556 | |
| 557 | static int |
| 558 | buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) |
| 559 | { |
| 560 | struct cx8800_fh *fh = q->priv_data; |
| 561 | |
| 562 | *size = fh->fmt->depth*fh->width*fh->height >> 3; |
| 563 | if (0 == *count) |
| 564 | *count = 32; |
Andreas Bombe | dab7e31 | 2010-03-21 16:02:45 -0300 | [diff] [blame] | 565 | if (*size * *count > vid_limit * 1024 * 1024) |
| 566 | *count = (vid_limit * 1024 * 1024) / *size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | return 0; |
| 568 | } |
| 569 | |
| 570 | static int |
| 571 | buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, |
| 572 | enum v4l2_field field) |
| 573 | { |
| 574 | struct cx8800_fh *fh = q->priv_data; |
| 575 | struct cx8800_dev *dev = fh->dev; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 576 | struct cx88_core *core = dev->core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 578 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | int rc, init_buffer = 0; |
| 580 | |
| 581 | BUG_ON(NULL == fh->fmt); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 582 | if (fh->width < 48 || fh->width > norm_maxw(core->tvnorm) || |
| 583 | fh->height < 32 || fh->height > norm_maxh(core->tvnorm)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | return -EINVAL; |
| 585 | buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; |
| 586 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) |
| 587 | return -EINVAL; |
| 588 | |
| 589 | if (buf->fmt != fh->fmt || |
| 590 | buf->vb.width != fh->width || |
| 591 | buf->vb.height != fh->height || |
| 592 | buf->vb.field != field) { |
| 593 | buf->fmt = fh->fmt; |
| 594 | buf->vb.width = fh->width; |
| 595 | buf->vb.height = fh->height; |
| 596 | buf->vb.field = field; |
| 597 | init_buffer = 1; |
| 598 | } |
| 599 | |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 600 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | init_buffer = 1; |
Mauro Carvalho Chehab | c7b0ac0 | 2006-03-10 12:29:15 -0300 | [diff] [blame] | 602 | if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | goto fail; |
| 604 | } |
| 605 | |
| 606 | if (init_buffer) { |
| 607 | buf->bpl = buf->vb.width * buf->fmt->depth >> 3; |
| 608 | switch (buf->vb.field) { |
| 609 | case V4L2_FIELD_TOP: |
| 610 | cx88_risc_buffer(dev->pci, &buf->risc, |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 611 | dma->sglist, 0, UNSET, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | buf->bpl, 0, buf->vb.height); |
| 613 | break; |
| 614 | case V4L2_FIELD_BOTTOM: |
| 615 | cx88_risc_buffer(dev->pci, &buf->risc, |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 616 | dma->sglist, UNSET, 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | buf->bpl, 0, buf->vb.height); |
| 618 | break; |
| 619 | case V4L2_FIELD_INTERLACED: |
| 620 | cx88_risc_buffer(dev->pci, &buf->risc, |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 621 | dma->sglist, 0, buf->bpl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | buf->bpl, buf->bpl, |
| 623 | buf->vb.height >> 1); |
| 624 | break; |
| 625 | case V4L2_FIELD_SEQ_TB: |
| 626 | cx88_risc_buffer(dev->pci, &buf->risc, |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 627 | dma->sglist, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | 0, buf->bpl * (buf->vb.height >> 1), |
| 629 | buf->bpl, 0, |
| 630 | buf->vb.height >> 1); |
| 631 | break; |
| 632 | case V4L2_FIELD_SEQ_BT: |
| 633 | cx88_risc_buffer(dev->pci, &buf->risc, |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 634 | dma->sglist, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | buf->bpl * (buf->vb.height >> 1), 0, |
| 636 | buf->bpl, 0, |
| 637 | buf->vb.height >> 1); |
| 638 | break; |
| 639 | default: |
| 640 | BUG(); |
| 641 | } |
| 642 | } |
| 643 | dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", |
| 644 | buf, buf->vb.i, |
| 645 | fh->width, fh->height, fh->fmt->depth, fh->fmt->name, |
| 646 | (unsigned long)buf->risc.dma); |
| 647 | |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 648 | buf->vb.state = VIDEOBUF_PREPARED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | return 0; |
| 650 | |
| 651 | fail: |
Mauro Carvalho Chehab | c7b0ac0 | 2006-03-10 12:29:15 -0300 | [diff] [blame] | 652 | cx88_free_buffer(q,buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | return rc; |
| 654 | } |
| 655 | |
| 656 | static void |
| 657 | buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) |
| 658 | { |
| 659 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); |
| 660 | struct cx88_buffer *prev; |
| 661 | struct cx8800_fh *fh = vq->priv_data; |
| 662 | struct cx8800_dev *dev = fh->dev; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 663 | struct cx88_core *core = dev->core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | struct cx88_dmaqueue *q = &dev->vidq; |
| 665 | |
| 666 | /* add jump to stopper */ |
| 667 | buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); |
| 668 | buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); |
| 669 | |
| 670 | if (!list_empty(&q->queued)) { |
| 671 | list_add_tail(&buf->vb.queue,&q->queued); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 672 | buf->vb.state = VIDEOBUF_QUEUED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | dprintk(2,"[%p/%d] buffer_queue - append to queued\n", |
| 674 | buf, buf->vb.i); |
| 675 | |
| 676 | } else if (list_empty(&q->active)) { |
| 677 | list_add_tail(&buf->vb.queue,&q->active); |
| 678 | start_video_dma(dev, q, buf); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 679 | buf->vb.state = VIDEOBUF_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | buf->count = q->count++; |
| 681 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
| 682 | dprintk(2,"[%p/%d] buffer_queue - first active\n", |
| 683 | buf, buf->vb.i); |
| 684 | |
| 685 | } else { |
| 686 | prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue); |
| 687 | if (prev->vb.width == buf->vb.width && |
| 688 | prev->vb.height == buf->vb.height && |
| 689 | prev->fmt == buf->fmt) { |
| 690 | list_add_tail(&buf->vb.queue,&q->active); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 691 | buf->vb.state = VIDEOBUF_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | buf->count = q->count++; |
| 693 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
| 694 | dprintk(2,"[%p/%d] buffer_queue - append to active\n", |
| 695 | buf, buf->vb.i); |
| 696 | |
| 697 | } else { |
| 698 | list_add_tail(&buf->vb.queue,&q->queued); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 699 | buf->vb.state = VIDEOBUF_QUEUED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | dprintk(2,"[%p/%d] buffer_queue - first queued\n", |
| 701 | buf, buf->vb.i); |
| 702 | } |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) |
| 707 | { |
| 708 | struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Mauro Carvalho Chehab | c7b0ac0 | 2006-03-10 12:29:15 -0300 | [diff] [blame] | 710 | cx88_free_buffer(q,buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | } |
| 712 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 713 | static const struct videobuf_queue_ops cx8800_video_qops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | .buf_setup = buffer_setup, |
| 715 | .buf_prepare = buffer_prepare, |
| 716 | .buf_queue = buffer_queue, |
| 717 | .buf_release = buffer_release, |
| 718 | }; |
| 719 | |
| 720 | /* ------------------------------------------------------------------ */ |
| 721 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | |
| 723 | /* ------------------------------------------------------------------ */ |
| 724 | |
| 725 | static struct videobuf_queue* get_queue(struct cx8800_fh *fh) |
| 726 | { |
| 727 | switch (fh->type) { |
| 728 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| 729 | return &fh->vidq; |
| 730 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
| 731 | return &fh->vbiq; |
| 732 | default: |
| 733 | BUG(); |
| 734 | return NULL; |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | static int get_ressource(struct cx8800_fh *fh) |
| 739 | { |
| 740 | switch (fh->type) { |
| 741 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| 742 | return RESOURCE_VIDEO; |
| 743 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
| 744 | return RESOURCE_VBI; |
| 745 | default: |
| 746 | BUG(); |
| 747 | return 0; |
| 748 | } |
| 749 | } |
| 750 | |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 751 | static int video_open(struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | { |
Laurent Pinchart | 63b0d5a | 2009-12-10 11:44:04 -0200 | [diff] [blame] | 753 | struct video_device *vdev = video_devdata(file); |
| 754 | struct cx8800_dev *dev = video_drvdata(file); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 755 | struct cx88_core *core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | struct cx8800_fh *fh; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | enum v4l2_buf_type type = 0; |
| 758 | int radio = 0; |
| 759 | |
Laurent Pinchart | 63b0d5a | 2009-12-10 11:44:04 -0200 | [diff] [blame] | 760 | switch (vdev->vfl_type) { |
| 761 | case VFL_TYPE_GRABBER: |
| 762 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 763 | break; |
| 764 | case VFL_TYPE_VBI: |
| 765 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
| 766 | break; |
| 767 | case VFL_TYPE_RADIO: |
| 768 | radio = 1; |
| 769 | break; |
| 770 | } |
| 771 | |
Laurent Pinchart | 50462eb | 2009-12-10 11:47:13 -0200 | [diff] [blame] | 772 | dprintk(1, "open dev=%s radio=%d type=%s\n", |
| 773 | video_device_node_name(vdev), radio, v4l2_type_names[type]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | |
| 775 | /* allocate + initialize per filehandle data */ |
Panagiotis Issaris | 7408187 | 2006-01-11 19:40:56 -0200 | [diff] [blame] | 776 | fh = kzalloc(sizeof(*fh),GFP_KERNEL); |
Mauro Carvalho Chehab | da497e3 | 2010-09-15 09:23:20 -0300 | [diff] [blame^] | 777 | if (unlikely(!fh)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | return -ENOMEM; |
Mauro Carvalho Chehab | da497e3 | 2010-09-15 09:23:20 -0300 | [diff] [blame^] | 779 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | file->private_data = fh; |
| 781 | fh->dev = dev; |
| 782 | fh->radio = radio; |
| 783 | fh->type = type; |
| 784 | fh->width = 320; |
| 785 | fh->height = 240; |
| 786 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); |
| 787 | |
Mauro Carvalho Chehab | da497e3 | 2010-09-15 09:23:20 -0300 | [diff] [blame^] | 788 | mutex_lock(&core->lock); |
| 789 | core = dev->core; |
| 790 | |
Guennadi Liakhovetski | 0705135 | 2008-04-22 14:42:13 -0300 | [diff] [blame] | 791 | videobuf_queue_sg_init(&fh->vidq, &cx8800_video_qops, |
| 792 | &dev->pci->dev, &dev->slock, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 794 | V4L2_FIELD_INTERLACED, |
| 795 | sizeof(struct cx88_buffer), |
| 796 | fh); |
Guennadi Liakhovetski | 0705135 | 2008-04-22 14:42:13 -0300 | [diff] [blame] | 797 | videobuf_queue_sg_init(&fh->vbiq, &cx8800_vbi_qops, |
| 798 | &dev->pci->dev, &dev->slock, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | V4L2_BUF_TYPE_VBI_CAPTURE, |
| 800 | V4L2_FIELD_SEQ_TB, |
| 801 | sizeof(struct cx88_buffer), |
| 802 | fh); |
| 803 | |
| 804 | if (fh->radio) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | dprintk(1,"video_open: setting radio device\n"); |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 806 | cx_write(MO_GP3_IO, core->board.radio.gpio3); |
| 807 | cx_write(MO_GP0_IO, core->board.radio.gpio0); |
| 808 | cx_write(MO_GP1_IO, core->board.radio.gpio1); |
| 809 | cx_write(MO_GP2_IO, core->board.radio.gpio2); |
Darron Broad | 430189d | 2008-10-15 14:18:42 -0300 | [diff] [blame] | 810 | if (core->board.radio.audioroute) { |
| 811 | if(core->board.audio_chip && |
| 812 | core->board.audio_chip == V4L2_IDENT_WM8775) { |
Hans Verkuil | 5325b42 | 2009-04-02 11:26:22 -0300 | [diff] [blame] | 813 | call_all(core, audio, s_routing, |
| 814 | core->board.radio.audioroute, 0, 0); |
Darron Broad | 430189d | 2008-10-15 14:18:42 -0300 | [diff] [blame] | 815 | } |
| 816 | /* "I2S ADC mode" */ |
| 817 | core->tvaudio = WW_I2SADC; |
| 818 | cx88_set_tvaudio(core); |
| 819 | } else { |
| 820 | /* FM Mode */ |
| 821 | core->tvaudio = WW_FM; |
| 822 | cx88_set_tvaudio(core); |
| 823 | cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); |
| 824 | } |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 825 | call_all(core, tuner, s_radio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | } |
| 827 | |
Darron Broad | 3e01084 | 2008-09-25 16:51:11 -0300 | [diff] [blame] | 828 | atomic_inc(&core->users); |
Mauro Carvalho Chehab | da497e3 | 2010-09-15 09:23:20 -0300 | [diff] [blame^] | 829 | mutex_unlock(&core->lock); |
Darron Broad | 3e01084 | 2008-09-25 16:51:11 -0300 | [diff] [blame] | 830 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 831 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | static ssize_t |
Peter Hagervall | f9e7a02 | 2005-11-08 21:36:29 -0800 | [diff] [blame] | 835 | video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | { |
| 837 | struct cx8800_fh *fh = file->private_data; |
| 838 | |
| 839 | switch (fh->type) { |
| 840 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| 841 | if (res_locked(fh->dev,RESOURCE_VIDEO)) |
| 842 | return -EBUSY; |
| 843 | return videobuf_read_one(&fh->vidq, data, count, ppos, |
| 844 | file->f_flags & O_NONBLOCK); |
| 845 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
| 846 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) |
| 847 | return -EBUSY; |
| 848 | return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1, |
| 849 | file->f_flags & O_NONBLOCK); |
| 850 | default: |
| 851 | BUG(); |
| 852 | return 0; |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | static unsigned int |
| 857 | video_poll(struct file *file, struct poll_table_struct *wait) |
| 858 | { |
| 859 | struct cx8800_fh *fh = file->private_data; |
| 860 | struct cx88_buffer *buf; |
Figo.zhang | 9fd6418 | 2009-06-16 13:31:29 -0300 | [diff] [blame] | 861 | unsigned int rc = POLLERR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | |
| 863 | if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { |
| 864 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) |
| 865 | return POLLERR; |
| 866 | return videobuf_poll_stream(file, &fh->vbiq, wait); |
| 867 | } |
| 868 | |
Figo.zhang | 9fd6418 | 2009-06-16 13:31:29 -0300 | [diff] [blame] | 869 | mutex_lock(&fh->vidq.vb_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | if (res_check(fh,RESOURCE_VIDEO)) { |
| 871 | /* streaming capture */ |
| 872 | if (list_empty(&fh->vidq.stream)) |
Figo.zhang | 9fd6418 | 2009-06-16 13:31:29 -0300 | [diff] [blame] | 873 | goto done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | buf = list_entry(fh->vidq.stream.next,struct cx88_buffer,vb.stream); |
| 875 | } else { |
| 876 | /* read() capture */ |
| 877 | buf = (struct cx88_buffer*)fh->vidq.read_buf; |
| 878 | if (NULL == buf) |
Figo.zhang | 9fd6418 | 2009-06-16 13:31:29 -0300 | [diff] [blame] | 879 | goto done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | } |
| 881 | poll_wait(file, &buf->vb.done, wait); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 882 | if (buf->vb.state == VIDEOBUF_DONE || |
| 883 | buf->vb.state == VIDEOBUF_ERROR) |
Figo.zhang | 9fd6418 | 2009-06-16 13:31:29 -0300 | [diff] [blame] | 884 | rc = POLLIN|POLLRDNORM; |
| 885 | else |
| 886 | rc = 0; |
| 887 | done: |
| 888 | mutex_unlock(&fh->vidq.vb_lock); |
| 889 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | } |
| 891 | |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 892 | static int video_release(struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | { |
| 894 | struct cx8800_fh *fh = file->private_data; |
| 895 | struct cx8800_dev *dev = fh->dev; |
| 896 | |
| 897 | /* turn off overlay */ |
| 898 | if (res_check(fh, RESOURCE_OVERLAY)) { |
| 899 | /* FIXME */ |
| 900 | res_free(dev,fh,RESOURCE_OVERLAY); |
| 901 | } |
| 902 | |
| 903 | /* stop video capture */ |
| 904 | if (res_check(fh, RESOURCE_VIDEO)) { |
| 905 | videobuf_queue_cancel(&fh->vidq); |
| 906 | res_free(dev,fh,RESOURCE_VIDEO); |
| 907 | } |
| 908 | if (fh->vidq.read_buf) { |
| 909 | buffer_release(&fh->vidq,fh->vidq.read_buf); |
| 910 | kfree(fh->vidq.read_buf); |
| 911 | } |
| 912 | |
| 913 | /* stop vbi capture */ |
| 914 | if (res_check(fh, RESOURCE_VBI)) { |
Brandon Philips | 053fcb6 | 2007-11-13 20:11:26 -0300 | [diff] [blame] | 915 | videobuf_stop(&fh->vbiq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | res_free(dev,fh,RESOURCE_VBI); |
| 917 | } |
| 918 | |
| 919 | videobuf_mmap_free(&fh->vidq); |
| 920 | videobuf_mmap_free(&fh->vbiq); |
Mauro Carvalho Chehab | da497e3 | 2010-09-15 09:23:20 -0300 | [diff] [blame^] | 921 | |
| 922 | mutex_lock(&dev->core->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | file->private_data = NULL; |
| 924 | kfree(fh); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 925 | |
Darron Broad | 3e01084 | 2008-09-25 16:51:11 -0300 | [diff] [blame] | 926 | if(atomic_dec_and_test(&dev->core->users)) |
Laurent Pinchart | 622b828 | 2009-10-05 10:48:17 -0300 | [diff] [blame] | 927 | call_all(dev->core, core, s_power, 0); |
Devin Heitmueller | 06f837c | 2009-04-28 14:35:27 -0300 | [diff] [blame] | 928 | mutex_unlock(&dev->core->lock); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 929 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | return 0; |
| 931 | } |
| 932 | |
| 933 | static int |
| 934 | video_mmap(struct file *file, struct vm_area_struct * vma) |
| 935 | { |
| 936 | struct cx8800_fh *fh = file->private_data; |
| 937 | |
| 938 | return videobuf_mmap_mapper(get_queue(fh), vma); |
| 939 | } |
| 940 | |
| 941 | /* ------------------------------------------------------------------ */ |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 942 | /* VIDEO CTRL IOCTLS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 944 | int cx88_get_control (struct cx88_core *core, struct v4l2_control *ctl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | { |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 946 | const struct cx88_ctrl *c = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | u32 value; |
| 948 | int i; |
| 949 | |
| 950 | for (i = 0; i < CX8800_CTLS; i++) |
| 951 | if (cx8800_ctls[i].v.id == ctl->id) |
| 952 | c = &cx8800_ctls[i]; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 953 | if (unlikely(NULL == c)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | return -EINVAL; |
| 955 | |
| 956 | value = c->sreg ? cx_sread(c->sreg) : cx_read(c->reg); |
| 957 | switch (ctl->id) { |
| 958 | case V4L2_CID_AUDIO_BALANCE: |
Marcin Rudowski | 9f9c907 | 2006-03-12 00:03:47 -0300 | [diff] [blame] | 959 | ctl->value = ((value & 0x7f) < 0x40) ? ((value & 0x7f) + 0x40) |
| 960 | : (0x7f - (value & 0x7f)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | break; |
| 962 | case V4L2_CID_AUDIO_VOLUME: |
| 963 | ctl->value = 0x3f - (value & 0x3f); |
| 964 | break; |
| 965 | default: |
| 966 | ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift; |
| 967 | break; |
| 968 | } |
Ian Pickworth | 6457af5 | 2006-02-27 00:09:45 -0300 | [diff] [blame] | 969 | dprintk(1,"get_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", |
| 970 | ctl->id, c->v.name, ctl->value, c->reg, |
| 971 | value,c->mask, c->sreg ? " [shadowed]" : ""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | return 0; |
| 973 | } |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 974 | EXPORT_SYMBOL(cx88_get_control); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 976 | int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | { |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 978 | const struct cx88_ctrl *c = NULL; |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 979 | u32 value,mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | int i; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 981 | |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 982 | for (i = 0; i < CX8800_CTLS; i++) { |
| 983 | if (cx8800_ctls[i].v.id == ctl->id) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | c = &cx8800_ctls[i]; |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 985 | } |
| 986 | } |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 987 | if (unlikely(NULL == c)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | return -EINVAL; |
| 989 | |
| 990 | if (ctl->value < c->v.minimum) |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 991 | ctl->value = c->v.minimum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | if (ctl->value > c->v.maximum) |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 993 | ctl->value = c->v.maximum; |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 994 | mask=c->mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | switch (ctl->id) { |
| 996 | case V4L2_CID_AUDIO_BALANCE: |
Marcin Rudowski | 9f9c907 | 2006-03-12 00:03:47 -0300 | [diff] [blame] | 997 | value = (ctl->value < 0x40) ? (0x7f - ctl->value) : (ctl->value - 0x40); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | break; |
| 999 | case V4L2_CID_AUDIO_VOLUME: |
| 1000 | value = 0x3f - (ctl->value & 0x3f); |
| 1001 | break; |
| 1002 | case V4L2_CID_SATURATION: |
| 1003 | /* special v_sat handling */ |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1004 | |
| 1005 | value = ((ctl->value - c->off) << c->shift) & c->mask; |
| 1006 | |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1007 | if (core->tvnorm & V4L2_STD_SECAM) { |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1008 | /* For SECAM, both U and V sat should be equal */ |
| 1009 | value=value<<8|value; |
| 1010 | } else { |
| 1011 | /* Keeps U Saturation proportional to V Sat */ |
| 1012 | value=(value*0x5a)/0x7f<<8|value; |
| 1013 | } |
| 1014 | mask=0xffff; |
| 1015 | break; |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 1016 | case V4L2_CID_CHROMA_AGC: |
| 1017 | /* Do not allow chroma AGC to be enabled for SECAM */ |
| 1018 | value = ((ctl->value - c->off) << c->shift) & c->mask; |
| 1019 | if (core->tvnorm & V4L2_STD_SECAM && value) |
| 1020 | return -EINVAL; |
| 1021 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | default: |
| 1023 | value = ((ctl->value - c->off) << c->shift) & c->mask; |
| 1024 | break; |
| 1025 | } |
Ian Pickworth | 6457af5 | 2006-02-27 00:09:45 -0300 | [diff] [blame] | 1026 | dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", |
| 1027 | ctl->id, c->v.name, ctl->value, c->reg, value, |
| 1028 | mask, c->sreg ? " [shadowed]" : ""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | if (c->sreg) { |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1030 | cx_sandor(c->sreg, c->reg, mask, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | } else { |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1032 | cx_andor(c->reg, mask, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | } |
| 1034 | return 0; |
| 1035 | } |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1036 | EXPORT_SYMBOL(cx88_set_control); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1038 | static void init_controls(struct cx88_core *core) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | { |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1040 | struct v4l2_control ctrl; |
| 1041 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1043 | for (i = 0; i < CX8800_CTLS; i++) { |
| 1044 | ctrl.id=cx8800_ctls[i].v.id; |
Marcin Rudowski | 9f9c907 | 2006-03-12 00:03:47 -0300 | [diff] [blame] | 1045 | ctrl.value=cx8800_ctls[i].v.default_value; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1046 | |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1047 | cx88_set_control(core, &ctrl); |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1048 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | /* ------------------------------------------------------------------ */ |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1052 | /* VIDEO IOCTLS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | |
Hans Verkuil | 78b526a | 2008-05-28 12:16:41 -0300 | [diff] [blame] | 1054 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1055 | struct v4l2_format *f) |
| 1056 | { |
| 1057 | struct cx8800_fh *fh = priv; |
| 1058 | |
| 1059 | f->fmt.pix.width = fh->width; |
| 1060 | f->fmt.pix.height = fh->height; |
| 1061 | f->fmt.pix.field = fh->vidq.field; |
| 1062 | f->fmt.pix.pixelformat = fh->fmt->fourcc; |
| 1063 | f->fmt.pix.bytesperline = |
| 1064 | (f->fmt.pix.width * fh->fmt->depth) >> 3; |
| 1065 | f->fmt.pix.sizeimage = |
| 1066 | f->fmt.pix.height * f->fmt.pix.bytesperline; |
| 1067 | return 0; |
| 1068 | } |
| 1069 | |
Hans Verkuil | 78b526a | 2008-05-28 12:16:41 -0300 | [diff] [blame] | 1070 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | struct v4l2_format *f) |
| 1072 | { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1073 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 1074 | const struct cx8800_fmt *fmt; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1075 | enum v4l2_field field; |
| 1076 | unsigned int maxw, maxh; |
| 1077 | |
| 1078 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
| 1079 | if (NULL == fmt) |
| 1080 | return -EINVAL; |
| 1081 | |
| 1082 | field = f->fmt.pix.field; |
| 1083 | maxw = norm_maxw(core->tvnorm); |
| 1084 | maxh = norm_maxh(core->tvnorm); |
| 1085 | |
| 1086 | if (V4L2_FIELD_ANY == field) { |
| 1087 | field = (f->fmt.pix.height > maxh/2) |
| 1088 | ? V4L2_FIELD_INTERLACED |
| 1089 | : V4L2_FIELD_BOTTOM; |
| 1090 | } |
| 1091 | |
| 1092 | switch (field) { |
| 1093 | case V4L2_FIELD_TOP: |
| 1094 | case V4L2_FIELD_BOTTOM: |
| 1095 | maxh = maxh / 2; |
| 1096 | break; |
| 1097 | case V4L2_FIELD_INTERLACED: |
| 1098 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | default: |
| 1100 | return -EINVAL; |
| 1101 | } |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1102 | |
| 1103 | f->fmt.pix.field = field; |
Trent Piepho | 4b89945 | 2009-05-30 21:45:46 -0300 | [diff] [blame] | 1104 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, |
| 1105 | &f->fmt.pix.height, 32, maxh, 0, 0); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1106 | f->fmt.pix.bytesperline = |
| 1107 | (f->fmt.pix.width * fmt->depth) >> 3; |
| 1108 | f->fmt.pix.sizeimage = |
| 1109 | f->fmt.pix.height * f->fmt.pix.bytesperline; |
| 1110 | |
| 1111 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | } |
| 1113 | |
Hans Verkuil | 78b526a | 2008-05-28 12:16:41 -0300 | [diff] [blame] | 1114 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1115 | struct v4l2_format *f) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1117 | struct cx8800_fh *fh = priv; |
Hans Verkuil | 78b526a | 2008-05-28 12:16:41 -0300 | [diff] [blame] | 1118 | int err = vidioc_try_fmt_vid_cap (file,priv,f); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1119 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1120 | if (0 != err) |
| 1121 | return err; |
| 1122 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
| 1123 | fh->width = f->fmt.pix.width; |
| 1124 | fh->height = f->fmt.pix.height; |
| 1125 | fh->vidq.field = f->fmt.pix.field; |
| 1126 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | } |
| 1128 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1129 | static int vidioc_querycap (struct file *file, void *priv, |
| 1130 | struct v4l2_capability *cap) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1131 | { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1132 | struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | struct cx88_core *core = dev->core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1135 | strcpy(cap->driver, "cx8800"); |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1136 | strlcpy(cap->card, core->board.name, sizeof(cap->card)); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1137 | sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); |
| 1138 | cap->version = CX88_VERSION_CODE; |
| 1139 | cap->capabilities = |
| 1140 | V4L2_CAP_VIDEO_CAPTURE | |
| 1141 | V4L2_CAP_READWRITE | |
| 1142 | V4L2_CAP_STREAMING | |
| 1143 | V4L2_CAP_VBI_CAPTURE; |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1144 | if (UNSET != core->board.tuner_type) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1145 | cap->capabilities |= V4L2_CAP_TUNER; |
| 1146 | return 0; |
| 1147 | } |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1148 | |
Hans Verkuil | 78b526a | 2008-05-28 12:16:41 -0300 | [diff] [blame] | 1149 | static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1150 | struct v4l2_fmtdesc *f) |
| 1151 | { |
| 1152 | if (unlikely(f->index >= ARRAY_SIZE(formats))) |
| 1153 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1155 | strlcpy(f->description,formats[f->index].name,sizeof(f->description)); |
| 1156 | f->pixelformat = formats[f->index].fourcc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1158 | return 0; |
| 1159 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | |
Mauro Carvalho Chehab | 0dfa9ab | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 1161 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1162 | static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf) |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1163 | { |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 1164 | struct cx8800_fh *fh = priv; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1165 | |
Mauro Carvalho Chehab | c1accaa | 2007-08-23 16:37:49 -0300 | [diff] [blame] | 1166 | return videobuf_cgmbuf (get_queue(fh), mbuf, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | } |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1168 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1170 | static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1172 | struct cx8800_fh *fh = priv; |
| 1173 | return (videobuf_reqbufs(get_queue(fh), p)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | } |
| 1175 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1176 | static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p) |
| 1177 | { |
| 1178 | struct cx8800_fh *fh = priv; |
| 1179 | return (videobuf_querybuf(get_queue(fh), p)); |
| 1180 | } |
| 1181 | |
| 1182 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p) |
| 1183 | { |
| 1184 | struct cx8800_fh *fh = priv; |
| 1185 | return (videobuf_qbuf(get_queue(fh), p)); |
| 1186 | } |
| 1187 | |
| 1188 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) |
| 1189 | { |
| 1190 | struct cx8800_fh *fh = priv; |
| 1191 | return (videobuf_dqbuf(get_queue(fh), p, |
| 1192 | file->f_flags & O_NONBLOCK)); |
| 1193 | } |
| 1194 | |
| 1195 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) |
| 1196 | { |
| 1197 | struct cx8800_fh *fh = priv; |
| 1198 | struct cx8800_dev *dev = fh->dev; |
| 1199 | |
Rafael Diniz | b058e3f | 2008-10-24 23:07:57 -0300 | [diff] [blame] | 1200 | /* We should remember that this driver also supports teletext, */ |
| 1201 | /* so we have to test if the v4l2_buf_type is VBI capture data. */ |
| 1202 | if (unlikely((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && |
| 1203 | (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE))) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1204 | return -EINVAL; |
Rafael Diniz | b058e3f | 2008-10-24 23:07:57 -0300 | [diff] [blame] | 1205 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1206 | if (unlikely(i != fh->type)) |
| 1207 | return -EINVAL; |
| 1208 | |
| 1209 | if (unlikely(!res_get(dev,fh,get_ressource(fh)))) |
| 1210 | return -EBUSY; |
| 1211 | return videobuf_streamon(get_queue(fh)); |
| 1212 | } |
| 1213 | |
| 1214 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) |
| 1215 | { |
| 1216 | struct cx8800_fh *fh = priv; |
| 1217 | struct cx8800_dev *dev = fh->dev; |
| 1218 | int err, res; |
| 1219 | |
Rafael Diniz | b058e3f | 2008-10-24 23:07:57 -0300 | [diff] [blame] | 1220 | if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && |
| 1221 | (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1222 | return -EINVAL; |
Rafael Diniz | b058e3f | 2008-10-24 23:07:57 -0300 | [diff] [blame] | 1223 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1224 | if (i != fh->type) |
| 1225 | return -EINVAL; |
| 1226 | |
| 1227 | res = get_ressource(fh); |
| 1228 | err = videobuf_streamoff(get_queue(fh)); |
| 1229 | if (err < 0) |
| 1230 | return err; |
| 1231 | res_free(dev,fh,res); |
| 1232 | return 0; |
| 1233 | } |
| 1234 | |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1235 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *tvnorms) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1236 | { |
| 1237 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1238 | |
| 1239 | mutex_lock(&core->lock); |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1240 | cx88_set_tvnorm(core,*tvnorms); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1241 | mutex_unlock(&core->lock); |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1242 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1243 | return 0; |
| 1244 | } |
| 1245 | |
| 1246 | /* only one input in this sample driver */ |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1247 | int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1248 | { |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 1249 | static const char * const iname[] = { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1250 | [ CX88_VMUX_COMPOSITE1 ] = "Composite1", |
| 1251 | [ CX88_VMUX_COMPOSITE2 ] = "Composite2", |
| 1252 | [ CX88_VMUX_COMPOSITE3 ] = "Composite3", |
| 1253 | [ CX88_VMUX_COMPOSITE4 ] = "Composite4", |
| 1254 | [ CX88_VMUX_SVIDEO ] = "S-Video", |
| 1255 | [ CX88_VMUX_TELEVISION ] = "Television", |
| 1256 | [ CX88_VMUX_CABLE ] = "Cable TV", |
| 1257 | [ CX88_VMUX_DVB ] = "DVB", |
| 1258 | [ CX88_VMUX_DEBUG ] = "for debug only", |
| 1259 | }; |
Trent Piepho | f3334bc | 2009-03-04 01:21:03 -0300 | [diff] [blame] | 1260 | unsigned int n = i->index; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1261 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1262 | if (n >= 4) |
| 1263 | return -EINVAL; |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1264 | if (0 == INPUT(n).type) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1265 | return -EINVAL; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1266 | i->type = V4L2_INPUT_TYPE_CAMERA; |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1267 | strcpy(i->name,iname[INPUT(n).type]); |
| 1268 | if ((CX88_VMUX_TELEVISION == INPUT(n).type) || |
Julia Lawall | 473d802 | 2010-08-05 17:22:44 -0300 | [diff] [blame] | 1269 | (CX88_VMUX_CABLE == INPUT(n).type)) { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1270 | i->type = V4L2_INPUT_TYPE_TUNER; |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1271 | i->std = CX88_NORMS; |
Julia Lawall | 473d802 | 2010-08-05 17:22:44 -0300 | [diff] [blame] | 1272 | } |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1273 | return 0; |
| 1274 | } |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1275 | EXPORT_SYMBOL(cx88_enum_input); |
| 1276 | |
| 1277 | static int vidioc_enum_input (struct file *file, void *priv, |
| 1278 | struct v4l2_input *i) |
| 1279 | { |
| 1280 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1281 | return cx88_enum_input (core,i); |
| 1282 | } |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1283 | |
| 1284 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) |
| 1285 | { |
| 1286 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1287 | |
| 1288 | *i = core->input; |
| 1289 | return 0; |
| 1290 | } |
| 1291 | |
| 1292 | static int vidioc_s_input (struct file *file, void *priv, unsigned int i) |
| 1293 | { |
| 1294 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1295 | |
| 1296 | if (i >= 4) |
| 1297 | return -EINVAL; |
| 1298 | |
| 1299 | mutex_lock(&core->lock); |
| 1300 | cx88_newstation(core); |
Mauro Carvalho Chehab | e90311a | 2007-01-20 13:58:29 -0300 | [diff] [blame] | 1301 | cx88_video_mux(core,i); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1302 | mutex_unlock(&core->lock); |
| 1303 | return 0; |
| 1304 | } |
| 1305 | |
| 1306 | |
| 1307 | |
| 1308 | static int vidioc_queryctrl (struct file *file, void *priv, |
| 1309 | struct v4l2_queryctrl *qctrl) |
| 1310 | { |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 1311 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1312 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1313 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); |
| 1314 | if (unlikely(qctrl->id == 0)) |
| 1315 | return -EINVAL; |
Frej Drejhammar | 6d04203 | 2008-03-23 22:43:21 -0300 | [diff] [blame] | 1316 | return cx8800_ctrl_query(core, qctrl); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1317 | } |
| 1318 | |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1319 | static int vidioc_g_ctrl (struct file *file, void *priv, |
| 1320 | struct v4l2_control *ctl) |
| 1321 | { |
| 1322 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1323 | return |
| 1324 | cx88_get_control(core,ctl); |
| 1325 | } |
| 1326 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1327 | static int vidioc_s_ctrl (struct file *file, void *priv, |
| 1328 | struct v4l2_control *ctl) |
| 1329 | { |
| 1330 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1331 | return |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1332 | cx88_set_control(core,ctl); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | static int vidioc_g_tuner (struct file *file, void *priv, |
| 1336 | struct v4l2_tuner *t) |
| 1337 | { |
| 1338 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1339 | u32 reg; |
| 1340 | |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1341 | if (unlikely(UNSET == core->board.tuner_type)) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1342 | return -EINVAL; |
Mauro Carvalho Chehab | 243d8c0 | 2007-01-20 13:58:36 -0300 | [diff] [blame] | 1343 | if (0 != t->index) |
| 1344 | return -EINVAL; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1345 | |
| 1346 | strcpy(t->name, "Television"); |
| 1347 | t->type = V4L2_TUNER_ANALOG_TV; |
| 1348 | t->capability = V4L2_TUNER_CAP_NORM; |
| 1349 | t->rangehigh = 0xffffffffUL; |
| 1350 | |
| 1351 | cx88_get_stereo(core ,t); |
| 1352 | reg = cx_read(MO_DEVICE_STATUS); |
| 1353 | t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; |
| 1354 | return 0; |
| 1355 | } |
| 1356 | |
| 1357 | static int vidioc_s_tuner (struct file *file, void *priv, |
| 1358 | struct v4l2_tuner *t) |
| 1359 | { |
| 1360 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1361 | |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1362 | if (UNSET == core->board.tuner_type) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1363 | return -EINVAL; |
| 1364 | if (0 != t->index) |
| 1365 | return -EINVAL; |
| 1366 | |
| 1367 | cx88_set_stereo(core, t->audmode, 1); |
| 1368 | return 0; |
| 1369 | } |
| 1370 | |
| 1371 | static int vidioc_g_frequency (struct file *file, void *priv, |
| 1372 | struct v4l2_frequency *f) |
| 1373 | { |
| 1374 | struct cx8800_fh *fh = priv; |
| 1375 | struct cx88_core *core = fh->dev->core; |
| 1376 | |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1377 | if (unlikely(UNSET == core->board.tuner_type)) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1378 | return -EINVAL; |
| 1379 | |
| 1380 | /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ |
| 1381 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
| 1382 | f->frequency = core->freq; |
| 1383 | |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1384 | call_all(core, tuner, g_frequency, f); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1385 | |
| 1386 | return 0; |
| 1387 | } |
| 1388 | |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1389 | int cx88_set_freq (struct cx88_core *core, |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1390 | struct v4l2_frequency *f) |
| 1391 | { |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1392 | if (unlikely(UNSET == core->board.tuner_type)) |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1393 | return -EINVAL; |
| 1394 | if (unlikely(f->tuner != 0)) |
| 1395 | return -EINVAL; |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1396 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1397 | mutex_lock(&core->lock); |
| 1398 | core->freq = f->frequency; |
| 1399 | cx88_newstation(core); |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1400 | call_all(core, tuner, s_frequency, f); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1401 | |
| 1402 | /* When changing channels it is required to reset TVAUDIO */ |
| 1403 | msleep (10); |
| 1404 | cx88_set_tvaudio(core); |
| 1405 | |
| 1406 | mutex_unlock(&core->lock); |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1407 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1408 | return 0; |
| 1409 | } |
Mauro Carvalho Chehab | 54da49f | 2007-01-20 13:58:26 -0300 | [diff] [blame] | 1410 | EXPORT_SYMBOL(cx88_set_freq); |
| 1411 | |
| 1412 | static int vidioc_s_frequency (struct file *file, void *priv, |
| 1413 | struct v4l2_frequency *f) |
| 1414 | { |
| 1415 | struct cx8800_fh *fh = priv; |
| 1416 | struct cx88_core *core = fh->dev->core; |
| 1417 | |
| 1418 | if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)) |
| 1419 | return -EINVAL; |
| 1420 | if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO)) |
| 1421 | return -EINVAL; |
| 1422 | |
| 1423 | return |
| 1424 | cx88_set_freq (core,f); |
| 1425 | } |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1426 | |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1427 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
| 1428 | static int vidioc_g_register (struct file *file, void *fh, |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 1429 | struct v4l2_dbg_register *reg) |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1430 | { |
| 1431 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; |
| 1432 | |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 1433 | if (!v4l2_chip_match_host(®->match)) |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1434 | return -EINVAL; |
| 1435 | /* cx2388x has a 24-bit register space */ |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 1436 | reg->val = cx_read(reg->reg & 0xffffff); |
| 1437 | reg->size = 4; |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1438 | return 0; |
| 1439 | } |
| 1440 | |
| 1441 | static int vidioc_s_register (struct file *file, void *fh, |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 1442 | struct v4l2_dbg_register *reg) |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1443 | { |
| 1444 | struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; |
| 1445 | |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 1446 | if (!v4l2_chip_match_host(®->match)) |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1447 | return -EINVAL; |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 1448 | cx_write(reg->reg & 0xffffff, reg->val); |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1449 | return 0; |
| 1450 | } |
| 1451 | #endif |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | /* ----------------------------------------------------------- */ |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1454 | /* RADIO ESPECIFIC IOCTLS */ |
| 1455 | /* ----------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1457 | static int radio_querycap (struct file *file, void *priv, |
| 1458 | struct v4l2_capability *cap) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1460 | struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1461 | struct cx88_core *core = dev->core; |
| 1462 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1463 | strcpy(cap->driver, "cx8800"); |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1464 | strlcpy(cap->card, core->board.name, sizeof(cap->card)); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1465 | sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci)); |
| 1466 | cap->version = CX88_VERSION_CODE; |
| 1467 | cap->capabilities = V4L2_CAP_TUNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | return 0; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1469 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1470 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1471 | static int radio_g_tuner (struct file *file, void *priv, |
| 1472 | struct v4l2_tuner *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1474 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1475 | |
| 1476 | if (unlikely(t->index > 0)) |
| 1477 | return -EINVAL; |
| 1478 | |
| 1479 | strcpy(t->name, "Radio"); |
| 1480 | t->type = V4L2_TUNER_RADIO; |
| 1481 | |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1482 | call_all(core, tuner, g_tuner, t); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1483 | return 0; |
| 1484 | } |
| 1485 | |
| 1486 | static int radio_enum_input (struct file *file, void *priv, |
| 1487 | struct v4l2_input *i) |
| 1488 | { |
| 1489 | if (i->index != 0) |
| 1490 | return -EINVAL; |
| 1491 | strcpy(i->name,"Radio"); |
| 1492 | i->type = V4L2_INPUT_TYPE_TUNER; |
| 1493 | |
| 1494 | return 0; |
| 1495 | } |
| 1496 | |
| 1497 | static int radio_g_audio (struct file *file, void *priv, struct v4l2_audio *a) |
| 1498 | { |
| 1499 | if (unlikely(a->index)) |
| 1500 | return -EINVAL; |
| 1501 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1502 | strcpy(a->name,"Radio"); |
| 1503 | return 0; |
| 1504 | } |
| 1505 | |
| 1506 | /* FIXME: Should add a standard for radio */ |
| 1507 | |
| 1508 | static int radio_s_tuner (struct file *file, void *priv, |
| 1509 | struct v4l2_tuner *t) |
| 1510 | { |
| 1511 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
| 1512 | |
| 1513 | if (0 != t->index) |
| 1514 | return -EINVAL; |
| 1515 | |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1516 | call_all(core, tuner, s_tuner, t); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1517 | |
| 1518 | return 0; |
| 1519 | } |
| 1520 | |
| 1521 | static int radio_s_audio (struct file *file, void *fh, |
| 1522 | struct v4l2_audio *a) |
| 1523 | { |
| 1524 | return 0; |
| 1525 | } |
| 1526 | |
| 1527 | static int radio_s_input (struct file *file, void *fh, unsigned int i) |
| 1528 | { |
| 1529 | return 0; |
| 1530 | } |
| 1531 | |
| 1532 | static int radio_queryctrl (struct file *file, void *priv, |
| 1533 | struct v4l2_queryctrl *c) |
| 1534 | { |
| 1535 | int i; |
| 1536 | |
| 1537 | if (c->id < V4L2_CID_BASE || |
| 1538 | c->id >= V4L2_CID_LASTP1) |
| 1539 | return -EINVAL; |
| 1540 | if (c->id == V4L2_CID_AUDIO_MUTE) { |
Dan Carpenter | a41b2ea | 2010-04-02 08:31:50 -0300 | [diff] [blame] | 1541 | for (i = 0; i < CX8800_CTLS; i++) { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1542 | if (cx8800_ctls[i].v.id == c->id) |
| 1543 | break; |
Dan Carpenter | a41b2ea | 2010-04-02 08:31:50 -0300 | [diff] [blame] | 1544 | } |
| 1545 | if (i == CX8800_CTLS) |
| 1546 | return -EINVAL; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1547 | *c = cx8800_ctls[i].v; |
| 1548 | } else |
| 1549 | *c = no_ctl; |
| 1550 | return 0; |
| 1551 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | |
| 1553 | /* ----------------------------------------------------------- */ |
| 1554 | |
| 1555 | static void cx8800_vid_timeout(unsigned long data) |
| 1556 | { |
| 1557 | struct cx8800_dev *dev = (struct cx8800_dev*)data; |
| 1558 | struct cx88_core *core = dev->core; |
| 1559 | struct cx88_dmaqueue *q = &dev->vidq; |
| 1560 | struct cx88_buffer *buf; |
| 1561 | unsigned long flags; |
| 1562 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1563 | cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1564 | |
| 1565 | cx_clear(MO_VID_DMACNTRL, 0x11); |
| 1566 | cx_clear(VID_CAPTURE_CONTROL, 0x06); |
| 1567 | |
| 1568 | spin_lock_irqsave(&dev->slock,flags); |
| 1569 | while (!list_empty(&q->active)) { |
| 1570 | buf = list_entry(q->active.next, struct cx88_buffer, vb.queue); |
| 1571 | list_del(&buf->vb.queue); |
Brandon Philips | 0fc0686 | 2007-11-06 20:02:36 -0300 | [diff] [blame] | 1572 | buf->vb.state = VIDEOBUF_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1573 | wake_up(&buf->vb.done); |
| 1574 | printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core->name, |
| 1575 | buf, buf->vb.i, (unsigned long)buf->risc.dma); |
| 1576 | } |
| 1577 | restart_video_queue(dev,q); |
| 1578 | spin_unlock_irqrestore(&dev->slock,flags); |
| 1579 | } |
| 1580 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 1581 | static const char *cx88_vid_irqs[32] = { |
Mauro Carvalho Chehab | 41ef7c1 | 2005-07-12 13:58:44 -0700 | [diff] [blame] | 1582 | "y_risci1", "u_risci1", "v_risci1", "vbi_risc1", |
| 1583 | "y_risci2", "u_risci2", "v_risci2", "vbi_risc2", |
| 1584 | "y_oflow", "u_oflow", "v_oflow", "vbi_oflow", |
| 1585 | "y_sync", "u_sync", "v_sync", "vbi_sync", |
| 1586 | "opc_err", "par_err", "rip_err", "pci_abort", |
| 1587 | }; |
| 1588 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | static void cx8800_vid_irq(struct cx8800_dev *dev) |
| 1590 | { |
| 1591 | struct cx88_core *core = dev->core; |
| 1592 | u32 status, mask, count; |
| 1593 | |
| 1594 | status = cx_read(MO_VID_INTSTAT); |
| 1595 | mask = cx_read(MO_VID_INTMSK); |
| 1596 | if (0 == (status & mask)) |
| 1597 | return; |
| 1598 | cx_write(MO_VID_INTSTAT, status); |
| 1599 | if (irq_debug || (status & mask & ~0xff)) |
| 1600 | cx88_print_irqbits(core->name, "irq vid", |
Mauro Carvalho Chehab | 66623a0 | 2007-03-29 08:47:04 -0300 | [diff] [blame] | 1601 | cx88_vid_irqs, ARRAY_SIZE(cx88_vid_irqs), |
| 1602 | status, mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | |
| 1604 | /* risc op code error */ |
| 1605 | if (status & (1 << 16)) { |
| 1606 | printk(KERN_WARNING "%s/0: video risc op code error\n",core->name); |
| 1607 | cx_clear(MO_VID_DMACNTRL, 0x11); |
| 1608 | cx_clear(VID_CAPTURE_CONTROL, 0x06); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1609 | cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1610 | } |
| 1611 | |
| 1612 | /* risc1 y */ |
| 1613 | if (status & 0x01) { |
| 1614 | spin_lock(&dev->slock); |
| 1615 | count = cx_read(MO_VIDY_GPCNT); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1616 | cx88_wakeup(core, &dev->vidq, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | spin_unlock(&dev->slock); |
| 1618 | } |
| 1619 | |
| 1620 | /* risc1 vbi */ |
| 1621 | if (status & 0x08) { |
| 1622 | spin_lock(&dev->slock); |
| 1623 | count = cx_read(MO_VBI_GPCNT); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1624 | cx88_wakeup(core, &dev->vbiq, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | spin_unlock(&dev->slock); |
| 1626 | } |
| 1627 | |
| 1628 | /* risc2 y */ |
| 1629 | if (status & 0x10) { |
| 1630 | dprintk(2,"stopper video\n"); |
| 1631 | spin_lock(&dev->slock); |
| 1632 | restart_video_queue(dev,&dev->vidq); |
| 1633 | spin_unlock(&dev->slock); |
| 1634 | } |
| 1635 | |
| 1636 | /* risc2 vbi */ |
| 1637 | if (status & 0x80) { |
| 1638 | dprintk(2,"stopper vbi\n"); |
| 1639 | spin_lock(&dev->slock); |
| 1640 | cx8800_restart_vbi_queue(dev,&dev->vbiq); |
| 1641 | spin_unlock(&dev->slock); |
| 1642 | } |
| 1643 | } |
| 1644 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 1645 | static irqreturn_t cx8800_irq(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | { |
| 1647 | struct cx8800_dev *dev = dev_id; |
| 1648 | struct cx88_core *core = dev->core; |
| 1649 | u32 status; |
| 1650 | int loop, handled = 0; |
| 1651 | |
| 1652 | for (loop = 0; loop < 10; loop++) { |
Trent Piepho | 8ddac9e | 2007-08-18 06:57:55 -0300 | [diff] [blame] | 1653 | status = cx_read(MO_PCI_INTSTAT) & |
| 1654 | (core->pci_irqmask | PCI_INT_VIDINT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | if (0 == status) |
| 1656 | goto out; |
| 1657 | cx_write(MO_PCI_INTSTAT, status); |
| 1658 | handled = 1; |
| 1659 | |
| 1660 | if (status & core->pci_irqmask) |
| 1661 | cx88_core_irq(core,status); |
Trent Piepho | 8ddac9e | 2007-08-18 06:57:55 -0300 | [diff] [blame] | 1662 | if (status & PCI_INT_VIDINT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1663 | cx8800_vid_irq(dev); |
| 1664 | }; |
| 1665 | if (10 == loop) { |
| 1666 | printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n", |
| 1667 | core->name); |
| 1668 | cx_write(MO_PCI_INTMSK,0); |
| 1669 | } |
| 1670 | |
| 1671 | out: |
| 1672 | return IRQ_RETVAL(handled); |
| 1673 | } |
| 1674 | |
| 1675 | /* ----------------------------------------------------------- */ |
| 1676 | /* exported stuff */ |
| 1677 | |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 1678 | static const struct v4l2_file_operations video_fops = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | { |
| 1680 | .owner = THIS_MODULE, |
| 1681 | .open = video_open, |
| 1682 | .release = video_release, |
| 1683 | .read = video_read, |
| 1684 | .poll = video_poll, |
| 1685 | .mmap = video_mmap, |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1686 | .ioctl = video_ioctl2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | }; |
| 1688 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1689 | static const struct v4l2_ioctl_ops video_ioctl_ops = { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1690 | .vidioc_querycap = vidioc_querycap, |
Hans Verkuil | 78b526a | 2008-05-28 12:16:41 -0300 | [diff] [blame] | 1691 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, |
| 1692 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
| 1693 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
| 1694 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, |
| 1695 | .vidioc_g_fmt_vbi_cap = cx8800_vbi_fmt, |
| 1696 | .vidioc_try_fmt_vbi_cap = cx8800_vbi_fmt, |
| 1697 | .vidioc_s_fmt_vbi_cap = cx8800_vbi_fmt, |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1698 | .vidioc_reqbufs = vidioc_reqbufs, |
| 1699 | .vidioc_querybuf = vidioc_querybuf, |
| 1700 | .vidioc_qbuf = vidioc_qbuf, |
| 1701 | .vidioc_dqbuf = vidioc_dqbuf, |
| 1702 | .vidioc_s_std = vidioc_s_std, |
| 1703 | .vidioc_enum_input = vidioc_enum_input, |
| 1704 | .vidioc_g_input = vidioc_g_input, |
| 1705 | .vidioc_s_input = vidioc_s_input, |
| 1706 | .vidioc_queryctrl = vidioc_queryctrl, |
| 1707 | .vidioc_g_ctrl = vidioc_g_ctrl, |
| 1708 | .vidioc_s_ctrl = vidioc_s_ctrl, |
| 1709 | .vidioc_streamon = vidioc_streamon, |
| 1710 | .vidioc_streamoff = vidioc_streamoff, |
| 1711 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 1712 | .vidiocgmbuf = vidiocgmbuf, |
| 1713 | #endif |
| 1714 | .vidioc_g_tuner = vidioc_g_tuner, |
| 1715 | .vidioc_s_tuner = vidioc_s_tuner, |
| 1716 | .vidioc_g_frequency = vidioc_g_frequency, |
| 1717 | .vidioc_s_frequency = vidioc_s_frequency, |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1718 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
| 1719 | .vidioc_g_register = vidioc_g_register, |
| 1720 | .vidioc_s_register = vidioc_s_register, |
| 1721 | #endif |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1722 | }; |
| 1723 | |
| 1724 | static struct video_device cx8800_vbi_template; |
| 1725 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 1726 | static const struct video_device cx8800_video_template = { |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1727 | .name = "cx8800-video", |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1728 | .fops = &video_fops, |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1729 | .ioctl_ops = &video_ioctl_ops, |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1730 | .tvnorms = CX88_NORMS, |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 1731 | .current_norm = V4L2_STD_NTSC_M, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1732 | }; |
| 1733 | |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 1734 | static const struct v4l2_file_operations radio_fops = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | { |
| 1736 | .owner = THIS_MODULE, |
| 1737 | .open = video_open, |
| 1738 | .release = video_release, |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1739 | .ioctl = video_ioctl2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | }; |
| 1741 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1742 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1743 | .vidioc_querycap = radio_querycap, |
| 1744 | .vidioc_g_tuner = radio_g_tuner, |
| 1745 | .vidioc_enum_input = radio_enum_input, |
| 1746 | .vidioc_g_audio = radio_g_audio, |
| 1747 | .vidioc_s_tuner = radio_s_tuner, |
| 1748 | .vidioc_s_audio = radio_s_audio, |
| 1749 | .vidioc_s_input = radio_s_input, |
| 1750 | .vidioc_queryctrl = radio_queryctrl, |
| 1751 | .vidioc_g_ctrl = vidioc_g_ctrl, |
| 1752 | .vidioc_s_ctrl = vidioc_s_ctrl, |
| 1753 | .vidioc_g_frequency = vidioc_g_frequency, |
| 1754 | .vidioc_s_frequency = vidioc_s_frequency, |
Trent Piepho | a75d204 | 2007-08-01 00:13:28 -0300 | [diff] [blame] | 1755 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
| 1756 | .vidioc_g_register = vidioc_g_register, |
| 1757 | .vidioc_s_register = vidioc_s_register, |
| 1758 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1759 | }; |
| 1760 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 1761 | static const struct video_device cx8800_radio_template = { |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1762 | .name = "cx8800-radio", |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1763 | .fops = &radio_fops, |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 1764 | .ioctl_ops = &radio_ioctl_ops, |
| 1765 | }; |
| 1766 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | /* ----------------------------------------------------------- */ |
| 1768 | |
| 1769 | static void cx8800_unregister_video(struct cx8800_dev *dev) |
| 1770 | { |
| 1771 | if (dev->radio_dev) { |
Laurent Pinchart | f0813b4 | 2009-11-27 13:57:30 -0300 | [diff] [blame] | 1772 | if (video_is_registered(dev->radio_dev)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | video_unregister_device(dev->radio_dev); |
| 1774 | else |
| 1775 | video_device_release(dev->radio_dev); |
| 1776 | dev->radio_dev = NULL; |
| 1777 | } |
| 1778 | if (dev->vbi_dev) { |
Laurent Pinchart | f0813b4 | 2009-11-27 13:57:30 -0300 | [diff] [blame] | 1779 | if (video_is_registered(dev->vbi_dev)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | video_unregister_device(dev->vbi_dev); |
| 1781 | else |
| 1782 | video_device_release(dev->vbi_dev); |
| 1783 | dev->vbi_dev = NULL; |
| 1784 | } |
| 1785 | if (dev->video_dev) { |
Laurent Pinchart | f0813b4 | 2009-11-27 13:57:30 -0300 | [diff] [blame] | 1786 | if (video_is_registered(dev->video_dev)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | video_unregister_device(dev->video_dev); |
| 1788 | else |
| 1789 | video_device_release(dev->video_dev); |
| 1790 | dev->video_dev = NULL; |
| 1791 | } |
| 1792 | } |
| 1793 | |
| 1794 | static int __devinit cx8800_initdev(struct pci_dev *pci_dev, |
| 1795 | const struct pci_device_id *pci_id) |
| 1796 | { |
| 1797 | struct cx8800_dev *dev; |
| 1798 | struct cx88_core *core; |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1799 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | int err; |
| 1801 | |
Panagiotis Issaris | 7408187 | 2006-01-11 19:40:56 -0200 | [diff] [blame] | 1802 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | if (NULL == dev) |
| 1804 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | |
| 1806 | /* pci init */ |
| 1807 | dev->pci = pci_dev; |
| 1808 | if (pci_enable_device(pci_dev)) { |
| 1809 | err = -EIO; |
| 1810 | goto fail_free; |
| 1811 | } |
| 1812 | core = cx88_core_get(dev->pci); |
| 1813 | if (NULL == core) { |
| 1814 | err = -EINVAL; |
| 1815 | goto fail_free; |
| 1816 | } |
| 1817 | dev->core = core; |
| 1818 | |
| 1819 | /* print pci info */ |
| 1820 | pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev); |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 1821 | pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); |
| 1822 | printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " |
Greg Kroah-Hartman | 228aef6 | 2006-06-12 15:16:52 -0700 | [diff] [blame] | 1823 | "latency: %d, mmio: 0x%llx\n", core->name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | pci_name(pci_dev), dev->pci_rev, pci_dev->irq, |
Greg Kroah-Hartman | 228aef6 | 2006-06-12 15:16:52 -0700 | [diff] [blame] | 1825 | dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | |
| 1827 | pci_set_master(pci_dev); |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1828 | if (!pci_dma_supported(pci_dev,DMA_BIT_MASK(32))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name); |
| 1830 | err = -EIO; |
| 1831 | goto fail_core; |
| 1832 | } |
| 1833 | |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1834 | /* Initialize VBI template */ |
| 1835 | memcpy( &cx8800_vbi_template, &cx8800_video_template, |
| 1836 | sizeof(cx8800_vbi_template) ); |
| 1837 | strcpy(cx8800_vbi_template.name,"cx8800-vbi"); |
Mauro Carvalho Chehab | 8d87cb9 | 2007-01-20 13:58:17 -0300 | [diff] [blame] | 1838 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1839 | /* initialize driver struct */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | spin_lock_init(&dev->slock); |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1841 | core->tvnorm = cx8800_video_template.current_norm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1842 | |
| 1843 | /* init video dma queues */ |
| 1844 | INIT_LIST_HEAD(&dev->vidq.active); |
| 1845 | INIT_LIST_HEAD(&dev->vidq.queued); |
| 1846 | dev->vidq.timeout.function = cx8800_vid_timeout; |
| 1847 | dev->vidq.timeout.data = (unsigned long)dev; |
| 1848 | init_timer(&dev->vidq.timeout); |
| 1849 | cx88_risc_stopper(dev->pci,&dev->vidq.stopper, |
| 1850 | MO_VID_DMACNTRL,0x11,0x00); |
| 1851 | |
| 1852 | /* init vbi dma queues */ |
| 1853 | INIT_LIST_HEAD(&dev->vbiq.active); |
| 1854 | INIT_LIST_HEAD(&dev->vbiq.queued); |
| 1855 | dev->vbiq.timeout.function = cx8800_vbi_timeout; |
| 1856 | dev->vbiq.timeout.data = (unsigned long)dev; |
| 1857 | init_timer(&dev->vbiq.timeout); |
| 1858 | cx88_risc_stopper(dev->pci,&dev->vbiq.stopper, |
| 1859 | MO_VID_DMACNTRL,0x88,0x00); |
| 1860 | |
| 1861 | /* get irq */ |
| 1862 | err = request_irq(pci_dev->irq, cx8800_irq, |
Thomas Gleixner | 8076fe3 | 2006-07-01 19:29:37 -0700 | [diff] [blame] | 1863 | IRQF_SHARED | IRQF_DISABLED, core->name, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1864 | if (err < 0) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 1865 | printk(KERN_ERR "%s/0: can't get IRQ %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | core->name,pci_dev->irq); |
| 1867 | goto fail_core; |
| 1868 | } |
| 1869 | cx_set(MO_PCI_INTMSK, core->pci_irqmask); |
| 1870 | |
| 1871 | /* load and configure helper modules */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1872 | |
Hans Verkuil | 38f9d30 | 2008-07-23 05:09:15 -0300 | [diff] [blame] | 1873 | if (core->board.audio_chip == V4L2_IDENT_WM8775) |
Hans Verkuil | e6574f2 | 2009-04-01 03:57:53 -0300 | [diff] [blame] | 1874 | v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, |
Hans Verkuil | 53dacb1 | 2009-08-10 02:49:08 -0300 | [diff] [blame] | 1875 | "wm8775", "wm8775", 0x36 >> 1, NULL); |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1876 | |
| 1877 | if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { |
| 1878 | /* This probes for a tda9874 as is used on some |
| 1879 | Pixelview Ultra boards. */ |
Hans Verkuil | 53dacb1 | 2009-08-10 02:49:08 -0300 | [diff] [blame] | 1880 | v4l2_i2c_new_subdev(&core->v4l2_dev, |
Hans Verkuil | 1792f68 | 2009-03-30 11:47:55 -0300 | [diff] [blame] | 1881 | &core->i2c_adap, |
Hans Verkuil | 53dacb1 | 2009-08-10 02:49:08 -0300 | [diff] [blame] | 1882 | "tvaudio", "tvaudio", 0, I2C_ADDRS(0xb0 >> 1)); |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1883 | } |
Steven Toth | 3057906 | 2006-09-25 12:43:42 -0300 | [diff] [blame] | 1884 | |
Michael Krufky | 6fcecce | 2007-08-24 01:32:31 -0300 | [diff] [blame] | 1885 | switch (core->boardnr) { |
| 1886 | case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1887 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: { |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 1888 | static const struct i2c_board_info rtc_info = { |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1889 | I2C_BOARD_INFO("isl1208", 0x6f) |
| 1890 | }; |
| 1891 | |
Michael Krufky | 6fcecce | 2007-08-24 01:32:31 -0300 | [diff] [blame] | 1892 | request_module("rtc-isl1208"); |
Hans Verkuil | b8341e1 | 2009-03-29 08:26:01 -0300 | [diff] [blame] | 1893 | core->i2c_rtc = i2c_new_device(&core->i2c_adap, &rtc_info); |
| 1894 | } |
Michael Krufky | 8efd2e2 | 2008-04-22 14:45:14 -0300 | [diff] [blame] | 1895 | /* break intentionally omitted */ |
| 1896 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: |
| 1897 | request_module("ir-kbd-i2c"); |
Michael Krufky | 6fcecce | 2007-08-24 01:32:31 -0300 | [diff] [blame] | 1898 | } |
| 1899 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1900 | /* register v4l devices */ |
| 1901 | dev->video_dev = cx88_vdev_init(core,dev->pci, |
| 1902 | &cx8800_video_template,"video"); |
Laurent Pinchart | 63b0d5a | 2009-12-10 11:44:04 -0200 | [diff] [blame] | 1903 | video_set_drvdata(dev->video_dev, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1904 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, |
| 1905 | video_nr[core->nr]); |
| 1906 | if (err < 0) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 1907 | printk(KERN_ERR "%s/0: can't register video device\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1908 | core->name); |
| 1909 | goto fail_unreg; |
| 1910 | } |
Laurent Pinchart | 38c7c03 | 2009-11-27 13:57:15 -0300 | [diff] [blame] | 1911 | printk(KERN_INFO "%s/0: registered device %s [v4l2]\n", |
| 1912 | core->name, video_device_node_name(dev->video_dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1913 | |
| 1914 | dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); |
Laurent Pinchart | 63b0d5a | 2009-12-10 11:44:04 -0200 | [diff] [blame] | 1915 | video_set_drvdata(dev->vbi_dev, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1916 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, |
| 1917 | vbi_nr[core->nr]); |
| 1918 | if (err < 0) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 1919 | printk(KERN_ERR "%s/0: can't register vbi device\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1920 | core->name); |
| 1921 | goto fail_unreg; |
| 1922 | } |
Laurent Pinchart | 38c7c03 | 2009-11-27 13:57:15 -0300 | [diff] [blame] | 1923 | printk(KERN_INFO "%s/0: registered device %s\n", |
| 1924 | core->name, video_device_node_name(dev->vbi_dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1926 | if (core->board.radio.type == CX88_RADIO) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1927 | dev->radio_dev = cx88_vdev_init(core,dev->pci, |
| 1928 | &cx8800_radio_template,"radio"); |
Laurent Pinchart | 63b0d5a | 2009-12-10 11:44:04 -0200 | [diff] [blame] | 1929 | video_set_drvdata(dev->radio_dev, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1930 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, |
| 1931 | radio_nr[core->nr]); |
| 1932 | if (err < 0) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 1933 | printk(KERN_ERR "%s/0: can't register radio device\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1934 | core->name); |
| 1935 | goto fail_unreg; |
| 1936 | } |
Laurent Pinchart | 38c7c03 | 2009-11-27 13:57:15 -0300 | [diff] [blame] | 1937 | printk(KERN_INFO "%s/0: registered device %s\n", |
| 1938 | core->name, video_device_node_name(dev->radio_dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1939 | } |
| 1940 | |
| 1941 | /* everything worked */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1942 | pci_set_drvdata(pci_dev,dev); |
| 1943 | |
| 1944 | /* initial device configuration */ |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 1945 | mutex_lock(&core->lock); |
Mauro Carvalho Chehab | 63ab1bd | 2007-01-20 13:58:33 -0300 | [diff] [blame] | 1946 | cx88_set_tvnorm(core,core->tvnorm); |
Mauro Carvalho Chehab | 70f0004 | 2006-01-09 15:25:26 -0200 | [diff] [blame] | 1947 | init_controls(core); |
Mauro Carvalho Chehab | e90311a | 2007-01-20 13:58:29 -0300 | [diff] [blame] | 1948 | cx88_video_mux(core,0); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 1949 | mutex_unlock(&core->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1950 | |
| 1951 | /* start tvaudio thread */ |
Trent Piepho | 6a59d64 | 2007-08-15 14:41:57 -0300 | [diff] [blame] | 1952 | if (core->board.tuner_type != TUNER_ABSENT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1953 | core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio"); |
Cyrill Gorcunov | 32b78de | 2007-07-19 11:44:11 -0300 | [diff] [blame] | 1954 | if (IS_ERR(core->kthread)) { |
| 1955 | err = PTR_ERR(core->kthread); |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 1956 | printk(KERN_ERR "%s/0: failed to create cx88 audio thread, err=%d\n", |
| 1957 | core->name, err); |
Cyrill Gorcunov | 32b78de | 2007-07-19 11:44:11 -0300 | [diff] [blame] | 1958 | } |
| 1959 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1960 | return 0; |
| 1961 | |
| 1962 | fail_unreg: |
| 1963 | cx8800_unregister_video(dev); |
| 1964 | free_irq(pci_dev->irq, dev); |
| 1965 | fail_core: |
| 1966 | cx88_core_put(core,dev->pci); |
| 1967 | fail_free: |
| 1968 | kfree(dev); |
| 1969 | return err; |
| 1970 | } |
| 1971 | |
| 1972 | static void __devexit cx8800_finidev(struct pci_dev *pci_dev) |
| 1973 | { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 1974 | struct cx8800_dev *dev = pci_get_drvdata(pci_dev); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1975 | struct cx88_core *core = dev->core; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | |
| 1977 | /* stop thread */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1978 | if (core->kthread) { |
| 1979 | kthread_stop(core->kthread); |
| 1980 | core->kthread = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1981 | } |
| 1982 | |
Marton Balint | b12203d | 2008-03-26 02:07:35 -0300 | [diff] [blame] | 1983 | if (core->ir) |
Mauro Carvalho Chehab | 92f4fc1 | 2010-03-31 16:07:49 -0300 | [diff] [blame] | 1984 | cx88_ir_stop(core); |
Marton Balint | b12203d | 2008-03-26 02:07:35 -0300 | [diff] [blame] | 1985 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1986 | cx88_shutdown(core); /* FIXME */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1987 | pci_disable_device(pci_dev); |
| 1988 | |
| 1989 | /* unregister stuff */ |
| 1990 | |
| 1991 | free_irq(pci_dev->irq, dev); |
| 1992 | cx8800_unregister_video(dev); |
| 1993 | pci_set_drvdata(pci_dev, NULL); |
| 1994 | |
| 1995 | /* free memory */ |
| 1996 | btcx_riscmem_free(dev->pci,&dev->vidq.stopper); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 1997 | cx88_core_put(core,dev->pci); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | kfree(dev); |
| 1999 | } |
| 2000 | |
Alexey Dobriyan | 17bc98a | 2006-08-12 22:01:27 -0300 | [diff] [blame] | 2001 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2002 | static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state) |
| 2003 | { |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 2004 | struct cx8800_dev *dev = pci_get_drvdata(pci_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2005 | struct cx88_core *core = dev->core; |
| 2006 | |
| 2007 | /* stop video+vbi capture */ |
| 2008 | spin_lock(&dev->slock); |
| 2009 | if (!list_empty(&dev->vidq.active)) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 2010 | printk("%s/0: suspend video\n", core->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2011 | stop_video_dma(dev); |
| 2012 | del_timer(&dev->vidq.timeout); |
| 2013 | } |
| 2014 | if (!list_empty(&dev->vbiq.active)) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 2015 | printk("%s/0: suspend vbi\n", core->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2016 | cx8800_stop_vbi_dma(dev); |
| 2017 | del_timer(&dev->vbiq.timeout); |
| 2018 | } |
| 2019 | spin_unlock(&dev->slock); |
| 2020 | |
Mauro Carvalho Chehab | 13595a5 | 2007-10-01 08:51:39 -0300 | [diff] [blame] | 2021 | if (core->ir) |
Mauro Carvalho Chehab | 92f4fc1 | 2010-03-31 16:07:49 -0300 | [diff] [blame] | 2022 | cx88_ir_stop(core); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2023 | /* FIXME -- shutdown device */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 2024 | cx88_shutdown(core); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | |
| 2026 | pci_save_state(pci_dev); |
| 2027 | if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { |
| 2028 | pci_disable_device(pci_dev); |
| 2029 | dev->state.disabled = 1; |
| 2030 | } |
| 2031 | return 0; |
| 2032 | } |
| 2033 | |
| 2034 | static int cx8800_resume(struct pci_dev *pci_dev) |
| 2035 | { |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 2036 | struct cx8800_dev *dev = pci_get_drvdata(pci_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | struct cx88_core *core = dev->core; |
Mauro Carvalho Chehab | 08adb9e | 2005-09-09 13:03:55 -0700 | [diff] [blame] | 2038 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | |
| 2040 | if (dev->state.disabled) { |
Mauro Carvalho Chehab | 08adb9e | 2005-09-09 13:03:55 -0700 | [diff] [blame] | 2041 | err=pci_enable_device(pci_dev); |
| 2042 | if (err) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 2043 | printk(KERN_ERR "%s/0: can't enable device\n", |
| 2044 | core->name); |
Mauro Carvalho Chehab | 08adb9e | 2005-09-09 13:03:55 -0700 | [diff] [blame] | 2045 | return err; |
| 2046 | } |
| 2047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2048 | dev->state.disabled = 0; |
| 2049 | } |
Mauro Carvalho Chehab | 08adb9e | 2005-09-09 13:03:55 -0700 | [diff] [blame] | 2050 | err= pci_set_power_state(pci_dev, PCI_D0); |
| 2051 | if (err) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 2052 | printk(KERN_ERR "%s/0: can't set power state\n", core->name); |
Mauro Carvalho Chehab | 08adb9e | 2005-09-09 13:03:55 -0700 | [diff] [blame] | 2053 | pci_disable_device(pci_dev); |
| 2054 | dev->state.disabled = 1; |
| 2055 | |
| 2056 | return err; |
| 2057 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | pci_restore_state(pci_dev); |
| 2059 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2060 | /* FIXME: re-initialize hardware */ |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 2061 | cx88_reset(core); |
Mauro Carvalho Chehab | 13595a5 | 2007-10-01 08:51:39 -0300 | [diff] [blame] | 2062 | if (core->ir) |
Mauro Carvalho Chehab | 92f4fc1 | 2010-03-31 16:07:49 -0300 | [diff] [blame] | 2063 | cx88_ir_start(core); |
Mauro Carvalho Chehab | 13595a5 | 2007-10-01 08:51:39 -0300 | [diff] [blame] | 2064 | |
| 2065 | cx_set(MO_PCI_INTMSK, core->pci_irqmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | |
| 2067 | /* restart video+vbi capture */ |
| 2068 | spin_lock(&dev->slock); |
| 2069 | if (!list_empty(&dev->vidq.active)) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 2070 | printk("%s/0: resume video\n", core->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | restart_video_queue(dev,&dev->vidq); |
| 2072 | } |
| 2073 | if (!list_empty(&dev->vbiq.active)) { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 2074 | printk("%s/0: resume vbi\n", core->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | cx8800_restart_vbi_queue(dev,&dev->vbiq); |
| 2076 | } |
| 2077 | spin_unlock(&dev->slock); |
| 2078 | |
| 2079 | return 0; |
| 2080 | } |
Alexey Dobriyan | 17bc98a | 2006-08-12 22:01:27 -0300 | [diff] [blame] | 2081 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2082 | |
| 2083 | /* ----------------------------------------------------------- */ |
| 2084 | |
lawrence rust | 2e4e98e | 2010-08-25 09:50:20 -0300 | [diff] [blame] | 2085 | static const struct pci_device_id cx8800_pci_tbl[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | { |
| 2087 | .vendor = 0x14f1, |
| 2088 | .device = 0x8800, |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 2089 | .subvendor = PCI_ANY_ID, |
| 2090 | .subdevice = PCI_ANY_ID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | },{ |
| 2092 | /* --- end of list --- */ |
| 2093 | } |
| 2094 | }; |
| 2095 | MODULE_DEVICE_TABLE(pci, cx8800_pci_tbl); |
| 2096 | |
| 2097 | static struct pci_driver cx8800_pci_driver = { |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 2098 | .name = "cx8800", |
| 2099 | .id_table = cx8800_pci_tbl, |
| 2100 | .probe = cx8800_initdev, |
| 2101 | .remove = __devexit_p(cx8800_finidev), |
Alexey Dobriyan | 17bc98a | 2006-08-12 22:01:27 -0300 | [diff] [blame] | 2102 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | .suspend = cx8800_suspend, |
| 2104 | .resume = cx8800_resume, |
Alexey Dobriyan | 17bc98a | 2006-08-12 22:01:27 -0300 | [diff] [blame] | 2105 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 | }; |
| 2107 | |
Peter Huewe | 31d0f84 | 2009-07-17 01:00:01 +0200 | [diff] [blame] | 2108 | static int __init cx8800_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | { |
Trent Piepho | 5772f81 | 2007-08-15 14:41:59 -0300 | [diff] [blame] | 2110 | printk(KERN_INFO "cx88/0: cx2388x v4l2 driver version %d.%d.%d loaded\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | (CX88_VERSION_CODE >> 16) & 0xff, |
| 2112 | (CX88_VERSION_CODE >> 8) & 0xff, |
| 2113 | CX88_VERSION_CODE & 0xff); |
| 2114 | #ifdef SNAPSHOT |
| 2115 | printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n", |
| 2116 | SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); |
| 2117 | #endif |
| 2118 | return pci_register_driver(&cx8800_pci_driver); |
| 2119 | } |
| 2120 | |
Peter Huewe | 31d0f84 | 2009-07-17 01:00:01 +0200 | [diff] [blame] | 2121 | static void __exit cx8800_fini(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | { |
| 2123 | pci_unregister_driver(&cx8800_pci_driver); |
| 2124 | } |
| 2125 | |
| 2126 | module_init(cx8800_init); |
| 2127 | module_exit(cx8800_fini); |
| 2128 | |
| 2129 | /* ----------------------------------------------------------- */ |
| 2130 | /* |
| 2131 | * Local variables: |
| 2132 | * c-basic-offset: 8 |
| 2133 | * End: |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 2134 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2135 | */ |