aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx88')
-rw-r--r--drivers/media/video/cx88/cx88-core.c3
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c2
-rw-r--r--drivers/media/video/cx88/cx88-input.c149
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c11
-rw-r--r--drivers/media/video/cx88/cx88-video.c20
-rw-r--r--drivers/media/video/cx88/cx88.h8
6 files changed, 143 insertions, 50 deletions
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index b35411160f04..8b21457111b1 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -847,7 +847,8 @@ static int set_tvaudio(struct cx88_core *core)
847{ 847{
848 v4l2_std_id norm = core->tvnorm; 848 v4l2_std_id norm = core->tvnorm;
849 849
850 if (CX88_VMUX_TELEVISION != INPUT(core->input).type) 850 if (CX88_VMUX_TELEVISION != INPUT(core->input).type &&
851 CX88_VMUX_CABLE != INPUT(core->input).type)
851 return 0; 852 return 0;
852 853
853 if (V4L2_STD_PAL_BG & norm) { 854 if (V4L2_STD_PAL_BG & norm) {
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 94ab862f0219..faa8e8163a4a 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -1231,7 +1231,7 @@ static int dvb_register(struct cx8802_dev *dev)
1231 fe->ops.tuner_ops.set_config(fe, &ctl); 1231 fe->ops.tuner_ops.set_config(fe, &ctl);
1232 } 1232 }
1233 break; 1233 break;
1234 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 1234 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
1235 case CX88_BOARD_WINFAST_DTV1800H: 1235 case CX88_BOARD_WINFAST_DTV1800H:
1236 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1236 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1237 &cx88_pinnacle_hybrid_pctv, 1237 &cx88_pinnacle_hybrid_pctv,
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 6b6abf062c21..e185289e446c 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -32,12 +32,18 @@
32#include "cx88.h" 32#include "cx88.h"
33#include <media/ir-common.h> 33#include <media/ir-common.h>
34 34
35#define MODULE_NAME "cx88xx"
36
35/* ---------------------------------------------------------------------- */ 37/* ---------------------------------------------------------------------- */
36 38
37struct cx88_IR { 39struct cx88_IR {
38 struct cx88_core *core; 40 struct cx88_core *core;
39 struct input_dev *input; 41 struct input_dev *input;
40 struct ir_input_state ir; 42 struct ir_input_state ir;
43 struct ir_dev_props props;
44
45 int users;
46
41 char name[32]; 47 char name[32];
42 char phys[32]; 48 char phys[32];
43 49
@@ -159,8 +165,16 @@ static enum hrtimer_restart cx88_ir_work(struct hrtimer *timer)
159 return HRTIMER_RESTART; 165 return HRTIMER_RESTART;
160} 166}
161 167
162void cx88_ir_start(struct cx88_core *core, struct cx88_IR *ir) 168static int __cx88_ir_start(void *priv)
163{ 169{
170 struct cx88_core *core = priv;
171 struct cx88_IR *ir;
172
173 if (!core || !core->ir)
174 return -EINVAL;
175
176 ir = core->ir;
177
164 if (ir->polling) { 178 if (ir->polling) {
165 hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 179 hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
166 ir->timer.function = cx88_ir_work; 180 ir->timer.function = cx88_ir_work;
@@ -173,10 +187,18 @@ void cx88_ir_start(struct cx88_core *core, struct cx88_IR *ir)
173 cx_write(MO_DDS_IO, 0xa80a80); /* 4 kHz sample rate */ 187 cx_write(MO_DDS_IO, 0xa80a80); /* 4 kHz sample rate */
174 cx_write(MO_DDSCFG_IO, 0x5); /* enable */ 188 cx_write(MO_DDSCFG_IO, 0x5); /* enable */
175 } 189 }
190 return 0;
176} 191}
177 192
178void cx88_ir_stop(struct cx88_core *core, struct cx88_IR *ir) 193static void __cx88_ir_stop(void *priv)
179{ 194{
195 struct cx88_core *core = priv;
196 struct cx88_IR *ir;
197
198 if (!core || !core->ir)
199 return;
200
201 ir = core->ir;
180 if (ir->sampling) { 202 if (ir->sampling) {
181 cx_write(MO_DDSCFG_IO, 0x0); 203 cx_write(MO_DDSCFG_IO, 0x0);
182 core->pci_irqmask &= ~PCI_INT_IR_SMPINT; 204 core->pci_irqmask &= ~PCI_INT_IR_SMPINT;
@@ -186,15 +208,49 @@ void cx88_ir_stop(struct cx88_core *core, struct cx88_IR *ir)
186 hrtimer_cancel(&ir->timer); 208 hrtimer_cancel(&ir->timer);
187} 209}
188 210
211int cx88_ir_start(struct cx88_core *core)
212{
213 if (core->ir->users)
214 return __cx88_ir_start(core);
215
216 return 0;
217}
218
219void cx88_ir_stop(struct cx88_core *core)
220{
221 if (core->ir->users)
222 __cx88_ir_stop(core);
223}
224
225static int cx88_ir_open(void *priv)
226{
227 struct cx88_core *core = priv;
228
229 core->ir->users++;
230 return __cx88_ir_start(core);
231}
232
233static void cx88_ir_close(void *priv)
234{
235 struct cx88_core *core = priv;
236
237 core->ir->users--;
238 if (!core->ir->users)
239 __cx88_ir_stop(core);
240}
241
189/* ---------------------------------------------------------------------- */ 242/* ---------------------------------------------------------------------- */
190 243
191int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) 244int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
192{ 245{
193 struct cx88_IR *ir; 246 struct cx88_IR *ir;
194 struct input_dev *input_dev; 247 struct input_dev *input_dev;
195 struct ir_scancode_table *ir_codes = NULL; 248 char *ir_codes = NULL;
196 u64 ir_type = IR_TYPE_OTHER; 249 u64 ir_type = IR_TYPE_OTHER;
197 int err = -ENOMEM; 250 int err = -ENOMEM;
251 u32 hardware_mask = 0; /* For devices with a hardware mask, when
252 * used with a full-code IR table
253 */
198 254
199 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 255 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
200 input_dev = input_allocate_device(); 256 input_dev = input_allocate_device();
@@ -208,15 +264,15 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
208 case CX88_BOARD_DNTV_LIVE_DVB_T: 264 case CX88_BOARD_DNTV_LIVE_DVB_T:
209 case CX88_BOARD_KWORLD_DVB_T: 265 case CX88_BOARD_KWORLD_DVB_T:
210 case CX88_BOARD_KWORLD_DVB_T_CX22702: 266 case CX88_BOARD_KWORLD_DVB_T_CX22702:
211 ir_codes = &ir_codes_dntv_live_dvb_t_table; 267 ir_codes = RC_MAP_DNTV_LIVE_DVB_T;
212 ir->gpio_addr = MO_GP1_IO; 268 ir->gpio_addr = MO_GP1_IO;
213 ir->mask_keycode = 0x1f; 269 ir->mask_keycode = 0x1f;
214 ir->mask_keyup = 0x60; 270 ir->mask_keyup = 0x60;
215 ir->polling = 50; /* ms */ 271 ir->polling = 50; /* ms */
216 break; 272 break;
217 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 273 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
218 ir_codes = &ir_codes_cinergy_1400_table; 274 ir_codes = RC_MAP_CINERGY_1400;
219 ir_type = IR_TYPE_PD; 275 ir_type = IR_TYPE_NEC;
220 ir->sampling = 0xeb04; /* address */ 276 ir->sampling = 0xeb04; /* address */
221 break; 277 break;
222 case CX88_BOARD_HAUPPAUGE: 278 case CX88_BOARD_HAUPPAUGE:
@@ -230,14 +286,14 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
230 case CX88_BOARD_PCHDTV_HD3000: 286 case CX88_BOARD_PCHDTV_HD3000:
231 case CX88_BOARD_PCHDTV_HD5500: 287 case CX88_BOARD_PCHDTV_HD5500:
232 case CX88_BOARD_HAUPPAUGE_IRONLY: 288 case CX88_BOARD_HAUPPAUGE_IRONLY:
233 ir_codes = &ir_codes_hauppauge_new_table; 289 ir_codes = RC_MAP_HAUPPAUGE_NEW;
234 ir_type = IR_TYPE_RC5; 290 ir_type = IR_TYPE_RC5;
235 ir->sampling = 1; 291 ir->sampling = 1;
236 break; 292 break;
237 case CX88_BOARD_WINFAST_DTV2000H: 293 case CX88_BOARD_WINFAST_DTV2000H:
238 case CX88_BOARD_WINFAST_DTV2000H_J: 294 case CX88_BOARD_WINFAST_DTV2000H_J:
239 case CX88_BOARD_WINFAST_DTV1800H: 295 case CX88_BOARD_WINFAST_DTV1800H:
240 ir_codes = &ir_codes_winfast_table; 296 ir_codes = RC_MAP_WINFAST;
241 ir->gpio_addr = MO_GP0_IO; 297 ir->gpio_addr = MO_GP0_IO;
242 ir->mask_keycode = 0x8f8; 298 ir->mask_keycode = 0x8f8;
243 ir->mask_keyup = 0x100; 299 ir->mask_keyup = 0x100;
@@ -246,14 +302,14 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
246 case CX88_BOARD_WINFAST2000XP_EXPERT: 302 case CX88_BOARD_WINFAST2000XP_EXPERT:
247 case CX88_BOARD_WINFAST_DTV1000: 303 case CX88_BOARD_WINFAST_DTV1000:
248 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: 304 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
249 ir_codes = &ir_codes_winfast_table; 305 ir_codes = RC_MAP_WINFAST;
250 ir->gpio_addr = MO_GP0_IO; 306 ir->gpio_addr = MO_GP0_IO;
251 ir->mask_keycode = 0x8f8; 307 ir->mask_keycode = 0x8f8;
252 ir->mask_keyup = 0x100; 308 ir->mask_keyup = 0x100;
253 ir->polling = 1; /* ms */ 309 ir->polling = 1; /* ms */
254 break; 310 break;
255 case CX88_BOARD_IODATA_GVBCTV7E: 311 case CX88_BOARD_IODATA_GVBCTV7E:
256 ir_codes = &ir_codes_iodata_bctv7e_table; 312 ir_codes = RC_MAP_IODATA_BCTV7E;
257 ir->gpio_addr = MO_GP0_IO; 313 ir->gpio_addr = MO_GP0_IO;
258 ir->mask_keycode = 0xfd; 314 ir->mask_keycode = 0xfd;
259 ir->mask_keydown = 0x02; 315 ir->mask_keydown = 0x02;
@@ -261,36 +317,43 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
261 break; 317 break;
262 case CX88_BOARD_PROLINK_PLAYTVPVR: 318 case CX88_BOARD_PROLINK_PLAYTVPVR:
263 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: 319 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
264 ir_codes = &ir_codes_pixelview_table; 320 /*
321 * It seems that this hardware is paired with NEC extended
322 * address 0x866b. So, unfortunately, its usage with other
323 * IR's with different address won't work. Still, there are
324 * other IR's from the same manufacturer that works, like the
325 * 002-T mini RC, provided with newer PV hardware
326 */
327 ir_codes = RC_MAP_PIXELVIEW_MK12;
265 ir->gpio_addr = MO_GP1_IO; 328 ir->gpio_addr = MO_GP1_IO;
266 ir->mask_keycode = 0x1f;
267 ir->mask_keyup = 0x80; 329 ir->mask_keyup = 0x80;
268 ir->polling = 1; /* ms */ 330 ir->polling = 10; /* ms */
331 hardware_mask = 0x3f; /* Hardware returns only 6 bits from command part */
269 break; 332 break;
270 case CX88_BOARD_PROLINK_PV_8000GT: 333 case CX88_BOARD_PROLINK_PV_8000GT:
271 case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME: 334 case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME:
272 ir_codes = &ir_codes_pixelview_new_table; 335 ir_codes = RC_MAP_PIXELVIEW_NEW;
273 ir->gpio_addr = MO_GP1_IO; 336 ir->gpio_addr = MO_GP1_IO;
274 ir->mask_keycode = 0x3f; 337 ir->mask_keycode = 0x3f;
275 ir->mask_keyup = 0x80; 338 ir->mask_keyup = 0x80;
276 ir->polling = 1; /* ms */ 339 ir->polling = 1; /* ms */
277 break; 340 break;
278 case CX88_BOARD_KWORLD_LTV883: 341 case CX88_BOARD_KWORLD_LTV883:
279 ir_codes = &ir_codes_pixelview_table; 342 ir_codes = RC_MAP_PIXELVIEW;
280 ir->gpio_addr = MO_GP1_IO; 343 ir->gpio_addr = MO_GP1_IO;
281 ir->mask_keycode = 0x1f; 344 ir->mask_keycode = 0x1f;
282 ir->mask_keyup = 0x60; 345 ir->mask_keyup = 0x60;
283 ir->polling = 1; /* ms */ 346 ir->polling = 1; /* ms */
284 break; 347 break;
285 case CX88_BOARD_ADSTECH_DVB_T_PCI: 348 case CX88_BOARD_ADSTECH_DVB_T_PCI:
286 ir_codes = &ir_codes_adstech_dvb_t_pci_table; 349 ir_codes = RC_MAP_ADSTECH_DVB_T_PCI;
287 ir->gpio_addr = MO_GP1_IO; 350 ir->gpio_addr = MO_GP1_IO;
288 ir->mask_keycode = 0xbf; 351 ir->mask_keycode = 0xbf;
289 ir->mask_keyup = 0x40; 352 ir->mask_keyup = 0x40;
290 ir->polling = 50; /* ms */ 353 ir->polling = 50; /* ms */
291 break; 354 break;
292 case CX88_BOARD_MSI_TVANYWHERE_MASTER: 355 case CX88_BOARD_MSI_TVANYWHERE_MASTER:
293 ir_codes = &ir_codes_msi_tvanywhere_table; 356 ir_codes = RC_MAP_MSI_TVANYWHERE;
294 ir->gpio_addr = MO_GP1_IO; 357 ir->gpio_addr = MO_GP1_IO;
295 ir->mask_keycode = 0x1f; 358 ir->mask_keycode = 0x1f;
296 ir->mask_keyup = 0x40; 359 ir->mask_keyup = 0x40;
@@ -298,7 +361,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
298 break; 361 break;
299 case CX88_BOARD_AVERTV_303: 362 case CX88_BOARD_AVERTV_303:
300 case CX88_BOARD_AVERTV_STUDIO_303: 363 case CX88_BOARD_AVERTV_STUDIO_303:
301 ir_codes = &ir_codes_avertv_303_table; 364 ir_codes = RC_MAP_AVERTV_303;
302 ir->gpio_addr = MO_GP2_IO; 365 ir->gpio_addr = MO_GP2_IO;
303 ir->mask_keycode = 0xfb; 366 ir->mask_keycode = 0xfb;
304 ir->mask_keydown = 0x02; 367 ir->mask_keydown = 0x02;
@@ -311,41 +374,41 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
311 case CX88_BOARD_PROF_7300: 374 case CX88_BOARD_PROF_7300:
312 case CX88_BOARD_PROF_7301: 375 case CX88_BOARD_PROF_7301:
313 case CX88_BOARD_PROF_6200: 376 case CX88_BOARD_PROF_6200:
314 ir_codes = &ir_codes_tbs_nec_table; 377 ir_codes = RC_MAP_TBS_NEC;
315 ir_type = IR_TYPE_PD; 378 ir_type = IR_TYPE_NEC;
316 ir->sampling = 0xff00; /* address */ 379 ir->sampling = 0xff00; /* address */
317 break; 380 break;
318 case CX88_BOARD_TEVII_S460: 381 case CX88_BOARD_TEVII_S460:
319 case CX88_BOARD_TEVII_S420: 382 case CX88_BOARD_TEVII_S420:
320 ir_codes = &ir_codes_tevii_nec_table; 383 ir_codes = RC_MAP_TEVII_NEC;
321 ir_type = IR_TYPE_PD; 384 ir_type = IR_TYPE_NEC;
322 ir->sampling = 0xff00; /* address */ 385 ir->sampling = 0xff00; /* address */
323 break; 386 break;
324 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 387 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
325 ir_codes = &ir_codes_dntv_live_dvbt_pro_table; 388 ir_codes = RC_MAP_DNTV_LIVE_DVBT_PRO;
326 ir_type = IR_TYPE_PD; 389 ir_type = IR_TYPE_NEC;
327 ir->sampling = 0xff00; /* address */ 390 ir->sampling = 0xff00; /* address */
328 break; 391 break;
329 case CX88_BOARD_NORWOOD_MICRO: 392 case CX88_BOARD_NORWOOD_MICRO:
330 ir_codes = &ir_codes_norwood_table; 393 ir_codes = RC_MAP_NORWOOD;
331 ir->gpio_addr = MO_GP1_IO; 394 ir->gpio_addr = MO_GP1_IO;
332 ir->mask_keycode = 0x0e; 395 ir->mask_keycode = 0x0e;
333 ir->mask_keyup = 0x80; 396 ir->mask_keyup = 0x80;
334 ir->polling = 50; /* ms */ 397 ir->polling = 50; /* ms */
335 break; 398 break;
336 case CX88_BOARD_NPGTECH_REALTV_TOP10FM: 399 case CX88_BOARD_NPGTECH_REALTV_TOP10FM:
337 ir_codes = &ir_codes_npgtech_table; 400 ir_codes = RC_MAP_NPGTECH;
338 ir->gpio_addr = MO_GP0_IO; 401 ir->gpio_addr = MO_GP0_IO;
339 ir->mask_keycode = 0xfa; 402 ir->mask_keycode = 0xfa;
340 ir->polling = 50; /* ms */ 403 ir->polling = 50; /* ms */
341 break; 404 break;
342 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 405 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
343 ir_codes = &ir_codes_pinnacle_pctv_hd_table; 406 ir_codes = RC_MAP_PINNACLE_PCTV_HD;
344 ir_type = IR_TYPE_RC5; 407 ir_type = IR_TYPE_RC5;
345 ir->sampling = 1; 408 ir->sampling = 1;
346 break; 409 break;
347 case CX88_BOARD_POWERCOLOR_REAL_ANGEL: 410 case CX88_BOARD_POWERCOLOR_REAL_ANGEL:
348 ir_codes = &ir_codes_powercolor_real_angel_table; 411 ir_codes = RC_MAP_POWERCOLOR_REAL_ANGEL;
349 ir->gpio_addr = MO_GP2_IO; 412 ir->gpio_addr = MO_GP2_IO;
350 ir->mask_keycode = 0x7e; 413 ir->mask_keycode = 0x7e;
351 ir->polling = 100; /* ms */ 414 ir->polling = 100; /* ms */
@@ -357,6 +420,21 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
357 goto err_out_free; 420 goto err_out_free;
358 } 421 }
359 422
423 /*
424 * The usage of mask_keycode were very convenient, due to several
425 * reasons. Among others, the scancode tables were using the scancode
426 * as the index elements. So, the less bits it was used, the smaller
427 * the table were stored. After the input changes, the better is to use
428 * the full scancodes, since it allows replacing the IR remote by
429 * another one. Unfortunately, there are still some hardware, like
430 * Pixelview Ultra Pro, where only part of the scancode is sent via
431 * GPIO. So, there's no way to get the full scancode. Due to that,
432 * hardware_mask were introduced here: it represents those hardware
433 * that has such limits.
434 */
435 if (hardware_mask && !ir->mask_keycode)
436 ir->mask_keycode = hardware_mask;
437
360 /* init input device */ 438 /* init input device */
361 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name); 439 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name);
362 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); 440 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
@@ -381,19 +459,20 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
381 ir->core = core; 459 ir->core = core;
382 core->ir = ir; 460 core->ir = ir;
383 461
384 cx88_ir_start(core, ir); 462 ir->props.priv = core;
463 ir->props.open = cx88_ir_open;
464 ir->props.close = cx88_ir_close;
465 ir->props.scanmask = hardware_mask;
385 466
386 /* all done */ 467 /* all done */
387 err = ir_input_register(ir->input, ir_codes, NULL); 468 err = ir_input_register(ir->input, ir_codes, &ir->props, MODULE_NAME);
388 if (err) 469 if (err)
389 goto err_out_stop; 470 goto err_out_free;
390 471
391 return 0; 472 return 0;
392 473
393 err_out_stop:
394 cx88_ir_stop(core, ir);
395 core->ir = NULL;
396 err_out_free: 474 err_out_free:
475 core->ir = NULL;
397 kfree(ir); 476 kfree(ir);
398 return err; 477 return err;
399} 478}
@@ -406,7 +485,7 @@ int cx88_ir_fini(struct cx88_core *core)
406 if (NULL == ir) 485 if (NULL == ir)
407 return 0; 486 return 0;
408 487
409 cx88_ir_stop(core, ir); 488 cx88_ir_stop(core);
410 ir_input_unregister(ir->input); 489 ir_input_unregister(ir->input);
411 kfree(ir); 490 kfree(ir);
412 491
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 6aba7af9160a..499f8d512ad6 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -599,13 +599,22 @@ struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board
599static int cx8802_request_acquire(struct cx8802_driver *drv) 599static int cx8802_request_acquire(struct cx8802_driver *drv)
600{ 600{
601 struct cx88_core *core = drv->core; 601 struct cx88_core *core = drv->core;
602 unsigned int i;
602 603
603 /* Fail a request for hardware if the device is busy. */ 604 /* Fail a request for hardware if the device is busy. */
604 if (core->active_type_id != CX88_BOARD_NONE && 605 if (core->active_type_id != CX88_BOARD_NONE &&
605 core->active_type_id != drv->type_id) 606 core->active_type_id != drv->type_id)
606 return -EBUSY; 607 return -EBUSY;
607 608
608 core->input = CX88_VMUX_DVB; 609 core->input = 0;
610 for (i = 0;
611 i < (sizeof(core->board.input) / sizeof(struct cx88_input));
612 i++) {
613 if (core->board.input[i].type == CX88_VMUX_DVB) {
614 core->input = i;
615 break;
616 }
617 }
609 618
610 if (drv->advise_acquire) 619 if (drv->advise_acquire)
611 { 620 {
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 48c450f4a85a..0fab65c3ab39 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -426,12 +426,13 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
426 if (core->board.audio_chip && 426 if (core->board.audio_chip &&
427 core->board.audio_chip == V4L2_IDENT_WM8775) { 427 core->board.audio_chip == V4L2_IDENT_WM8775) {
428 call_all(core, audio, s_routing, 428 call_all(core, audio, s_routing,
429 INPUT(input).audioroute, 0, 0); 429 INPUT(input).audioroute, 0, 0);
430 } 430 }
431 /* cx2388's C-ADC is connected to the tuner only. 431 /* cx2388's C-ADC is connected to the tuner only.
432 When used with S-Video, that ADC is busy dealing with 432 When used with S-Video, that ADC is busy dealing with
433 chroma, so an external must be used for baseband audio */ 433 chroma, so an external must be used for baseband audio */
434 if (INPUT(input).type != CX88_VMUX_TELEVISION ) { 434 if (INPUT(input).type != CX88_VMUX_TELEVISION &&
435 INPUT(input).type != CX88_VMUX_CABLE) {
435 /* "I2S ADC mode" */ 436 /* "I2S ADC mode" */
436 core->tvaudio = WW_I2SADC; 437 core->tvaudio = WW_I2SADC;
437 cx88_set_tvaudio(core); 438 cx88_set_tvaudio(core);
@@ -561,8 +562,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
561 *size = fh->fmt->depth*fh->width*fh->height >> 3; 562 *size = fh->fmt->depth*fh->width*fh->height >> 3;
562 if (0 == *count) 563 if (0 == *count)
563 *count = 32; 564 *count = 32;
564 while (*size * *count > vid_limit * 1024 * 1024) 565 if (*size * *count > vid_limit * 1024 * 1024)
565 (*count)--; 566 *count = (vid_limit * 1024 * 1024) / *size;
566 return 0; 567 return 0;
567} 568}
568 569
@@ -1537,9 +1538,12 @@ static int radio_queryctrl (struct file *file, void *priv,
1537 c->id >= V4L2_CID_LASTP1) 1538 c->id >= V4L2_CID_LASTP1)
1538 return -EINVAL; 1539 return -EINVAL;
1539 if (c->id == V4L2_CID_AUDIO_MUTE) { 1540 if (c->id == V4L2_CID_AUDIO_MUTE) {
1540 for (i = 0; i < CX8800_CTLS; i++) 1541 for (i = 0; i < CX8800_CTLS; i++) {
1541 if (cx8800_ctls[i].v.id == c->id) 1542 if (cx8800_ctls[i].v.id == c->id)
1542 break; 1543 break;
1544 }
1545 if (i == CX8800_CTLS)
1546 return -EINVAL;
1543 *c = cx8800_ctls[i].v; 1547 *c = cx8800_ctls[i].v;
1544 } else 1548 } else
1545 *c = no_ctl; 1549 *c = no_ctl;
@@ -1977,7 +1981,7 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev)
1977 } 1981 }
1978 1982
1979 if (core->ir) 1983 if (core->ir)
1980 cx88_ir_stop(core, core->ir); 1984 cx88_ir_stop(core);
1981 1985
1982 cx88_shutdown(core); /* FIXME */ 1986 cx88_shutdown(core); /* FIXME */
1983 pci_disable_device(pci_dev); 1987 pci_disable_device(pci_dev);
@@ -2015,7 +2019,7 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
2015 spin_unlock(&dev->slock); 2019 spin_unlock(&dev->slock);
2016 2020
2017 if (core->ir) 2021 if (core->ir)
2018 cx88_ir_stop(core, core->ir); 2022 cx88_ir_stop(core);
2019 /* FIXME -- shutdown device */ 2023 /* FIXME -- shutdown device */
2020 cx88_shutdown(core); 2024 cx88_shutdown(core);
2021 2025
@@ -2056,7 +2060,7 @@ static int cx8800_resume(struct pci_dev *pci_dev)
2056 /* FIXME: re-initialize hardware */ 2060 /* FIXME: re-initialize hardware */
2057 cx88_reset(core); 2061 cx88_reset(core);
2058 if (core->ir) 2062 if (core->ir)
2059 cx88_ir_start(core, core->ir); 2063 cx88_ir_start(core);
2060 2064
2061 cx_set(MO_PCI_INTMSK, core->pci_irqmask); 2065 cx_set(MO_PCI_INTMSK, core->pci_irqmask);
2062 2066
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 48b6c04fb497..bdb03d336536 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -41,7 +41,7 @@
41 41
42#include <linux/version.h> 42#include <linux/version.h>
43#include <linux/mutex.h> 43#include <linux/mutex.h>
44#define CX88_VERSION_CODE KERNEL_VERSION(0,0,7) 44#define CX88_VERSION_CODE KERNEL_VERSION(0, 0, 8)
45 45
46#define UNSET (-1U) 46#define UNSET (-1U)
47 47
@@ -290,7 +290,7 @@ struct cx88_subid {
290#define RESOURCE_VIDEO 2 290#define RESOURCE_VIDEO 2
291#define RESOURCE_VBI 4 291#define RESOURCE_VBI 4
292 292
293#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */ 293#define BUFFER_TIMEOUT msecs_to_jiffies(2000)
294 294
295/* buffer for one video frame */ 295/* buffer for one video frame */
296struct cx88_buffer { 296struct cx88_buffer {
@@ -683,8 +683,8 @@ s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core);
683int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci); 683int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci);
684int cx88_ir_fini(struct cx88_core *core); 684int cx88_ir_fini(struct cx88_core *core);
685void cx88_ir_irq(struct cx88_core *core); 685void cx88_ir_irq(struct cx88_core *core);
686void cx88_ir_start(struct cx88_core *core, struct cx88_IR *ir); 686int cx88_ir_start(struct cx88_core *core);
687void cx88_ir_stop(struct cx88_core *core, struct cx88_IR *ir); 687void cx88_ir_stop(struct cx88_core *core);
688 688
689/* ----------------------------------------------------------- */ 689/* ----------------------------------------------------------- */
690/* cx88-mpeg.c */ 690/* cx88-mpeg.c */