aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-09-30 12:39:15 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-30 12:39:15 -0400
commit5ffd1a6aaacc25be8cd0770a51ec6d46add3a276 (patch)
tree5b076c44f8b7ff88dba9a554d7748c6f083c9071 /drivers/media
parent0cd43f83d381c4246a08cd775834833d6fd64805 (diff)
parent8dd86eebc5315910ebfd9f30f1674254308be4b3 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
* master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (180 commits) V4L/DVB (4641): Trivial: use lowercase letters in hex subsystem ids V4L/DVB (4639): Cx88: add autodetection for alternate revision of Leadtek PVR V4L/DVB (4638): Basic DVB-T and analog TV support for the HVR1300. V4L/DVB (4637): Add a default method for VIDIOC_G_PARM V4L/DVB (4635): Extend bttv and saa7134 to check for both AGP and PCI PCI failure case V4L/DVB (4634): Zr36120: implement pcipci checks V4L/DVB (4632): Zoran: Implement pcipci failure check V4L/DVB (4631): Av7110: remove V4L2_CAP_VBI_CAPTURE flag V4L/DVB (4630): Av7110: FW_LOADER depemdency fixed V4L/DVB (4629): Saa7134: add card support for Proteus Pro 2309 V4L/DVB (4628): Fix VIDIOC_ENUMSTD ioctl in videodev.c V4L/DVB (4627): Vivi crashes with mplayer V4L/DVB (4626): On saa7111/7113, LUMA_CTRL need a different value V4L/DVB (4624): Tvaudio: Replaced kernel_thread() with kthread_run() V4L/DVB (4622): Copy-paste bug in videodev.c V4L/DVB (4620): Fix AGC configuration for MOD3000P-based boards V4L/DVB (4619): Fixes some I2C dependencies on V4L devices V4L/DVB (4617): Problem with dibusb-mb.c USB IDs V4L/DVB (4616): [PATCH] Nebula DigiTV USB RC support V4L/DVB (4614): Export symbol saa7134_tvaudio_setmute from saa7134 for saa7134-alsa ...
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/Kconfig1
-rw-r--r--drivers/media/common/ir-keymaps.c79
-rw-r--r--drivers/media/common/saa7146_fops.c1
-rw-r--r--drivers/media/dvb/b2c2/Kconfig14
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c24
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig14
-rw-r--r--drivers/media/dvb/bt8xx/dst.c9
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c11
-rw-r--r--drivers/media/dvb/bt8xx/dst_common.h3
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c37
-rw-r--r--drivers/media/dvb/dvb-core/Kconfig13
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c42
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h7
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h22
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig17
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c8
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c11
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c200
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mb.c18
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c41
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb.h3
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c86
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c50
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c20
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h124
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c5
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c2
-rw-r--r--drivers/media/dvb/dvb-usb/umt-010.c2
-rw-r--r--drivers/media/dvb/frontends/Kconfig71
-rw-r--r--drivers/media/dvb/frontends/Makefile8
-rw-r--r--drivers/media/dvb/frontends/bcm3510.h9
-rw-r--r--drivers/media/dvb/frontends/cx22700.h9
-rw-r--r--drivers/media/dvb/frontends/cx22702.c4
-rw-r--r--drivers/media/dvb/frontends/cx22702.h9
-rw-r--r--drivers/media/dvb/frontends/cx24110.c17
-rw-r--r--drivers/media/dvb/frontends/cx24110.h19
-rw-r--r--drivers/media/dvb/frontends/cx24123.c98
-rw-r--r--drivers/media/dvb/frontends/cx24123.h12
-rw-r--r--drivers/media/dvb/frontends/dib3000-common.c83
-rw-r--r--drivers/media/dvb/frontends/dib3000-common.h135
-rw-r--r--drivers/media/dvb/frontends/dib3000.h11
-rw-r--r--drivers/media/dvb/frontends/dib3000mb.c76
-rw-r--r--drivers/media/dvb/frontends/dib3000mb_priv.h93
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c1432
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.h58
-rw-r--r--drivers/media/dvb/frontends/dib3000mc_priv.h428
-rw-r--r--drivers/media/dvb/frontends/dibx000_common.c152
-rw-r--r--drivers/media/dvb/frontends/dibx000_common.h166
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c11
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h4
-rw-r--r--drivers/media/dvb/frontends/isl6421.c30
-rw-r--r--drivers/media/dvb/frontends/isl6421.h11
-rw-r--r--drivers/media/dvb/frontends/l64781.h10
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.h9
-rw-r--r--drivers/media/dvb/frontends/lnbp21.c30
-rw-r--r--drivers/media/dvb/frontends/lnbp21.h12
-rw-r--r--drivers/media/dvb/frontends/mt2060.c367
-rw-r--r--drivers/media/dvb/frontends/mt2060.h35
-rw-r--r--drivers/media/dvb/frontends/mt2060_priv.h105
-rw-r--r--drivers/media/dvb/frontends/mt312.h10
-rw-r--r--drivers/media/dvb/frontends/mt352.c16
-rw-r--r--drivers/media/dvb/frontends/mt352.h16
-rw-r--r--drivers/media/dvb/frontends/nxt200x.h9
-rw-r--r--drivers/media/dvb/frontends/nxt6000.h9
-rw-r--r--drivers/media/dvb/frontends/or51132.h9
-rw-r--r--drivers/media/dvb/frontends/or51211.h9
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h9
-rw-r--r--drivers/media/dvb/frontends/sp8870.h9
-rw-r--r--drivers/media/dvb/frontends/sp887x.h9
-rw-r--r--drivers/media/dvb/frontends/stv0297.h9
-rw-r--r--drivers/media/dvb/frontends/stv0299.c9
-rw-r--r--drivers/media/dvb/frontends/stv0299.h19
-rw-r--r--drivers/media/dvb/frontends/tda10021.c63
-rw-r--r--drivers/media/dvb/frontends/tda10021.h19
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c10
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h25
-rw-r--r--drivers/media/dvb/frontends/tda10086.c740
-rw-r--r--drivers/media/dvb/frontends/tda10086.h41
-rw-r--r--drivers/media/dvb/frontends/tda8083.h9
-rw-r--r--drivers/media/dvb/frontends/tda826x.c173
-rw-r--r--drivers/media/dvb/frontends/tda826x.h40
-rw-r--r--drivers/media/dvb/frontends/tua6100.c205
-rw-r--r--drivers/media/dvb/frontends/tua6100.h47
-rw-r--r--drivers/media/dvb/frontends/ves1820.h9
-rw-r--r--drivers/media/dvb/frontends/ves1x93.h9
-rw-r--r--drivers/media/dvb/frontends/zl10353.c11
-rw-r--r--drivers/media/dvb/frontends/zl10353.h14
-rw-r--r--drivers/media/dvb/ttpci/Kconfig57
-rw-r--r--drivers/media/dvb/ttpci/av7110.c58
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c3
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c184
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c32
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c17
-rw-r--r--drivers/media/dvb/ttpci/budget.c53
-rw-r--r--drivers/media/dvb/ttusb-budget/Kconfig14
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c28
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c6
-rw-r--r--drivers/media/radio/Kconfig30
-rw-r--r--drivers/media/radio/dsbr100.c198
-rw-r--r--drivers/media/radio/radio-aimslab.c151
-rw-r--r--drivers/media/radio/radio-aztech.c166
-rw-r--r--drivers/media/radio/radio-cadet.c250
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c170
-rw-r--r--drivers/media/radio/radio-gemtek.c165
-rw-r--r--drivers/media/radio/radio-maestro.c197
-rw-r--r--drivers/media/radio/radio-maxiradio.c166
-rw-r--r--drivers/media/radio/radio-rtrack2.c163
-rw-r--r--drivers/media/radio/radio-sf16fmi.c158
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c223
-rw-r--r--drivers/media/radio/radio-terratec.c154
-rw-r--r--drivers/media/radio/radio-trust.c188
-rw-r--r--drivers/media/radio/radio-typhoon.c171
-rw-r--r--drivers/media/radio/radio-zoltrix.c183
-rw-r--r--drivers/media/video/Kconfig476
-rw-r--r--drivers/media/video/Makefile45
-rw-r--r--drivers/media/video/bt866.c2
-rw-r--r--drivers/media/video/bt8xx/Kconfig5
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c12
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c16
-rw-r--r--drivers/media/video/compat_ioctl32.c59
-rw-r--r--drivers/media/video/cx2341x.c25
-rw-r--r--drivers/media/video/cx25840/Kconfig2
-rw-r--r--drivers/media/video/cx25840/cx25840-vbi.c4
-rw-r--r--drivers/media/video/cx88/Kconfig109
-rw-r--r--drivers/media/video/cx88/Makefile7
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c2
-rw-r--r--drivers/media/video/cx88/cx88-cards.c161
-rw-r--r--drivers/media/video/cx88/cx88-core.c13
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c330
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c13
-rw-r--r--drivers/media/video/cx88/cx88-input.c19
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c5
-rw-r--r--drivers/media/video/cx88/cx88-video.c7
-rw-r--r--drivers/media/video/cx88/cx88.h5
-rw-r--r--drivers/media/video/em28xx/Kconfig3
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/video/ks0127.c3
-rw-r--r--drivers/media/video/pvrusb2/Kconfig18
-rw-r--r--drivers/media/video/pvrusb2/Makefile6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.c21
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h31
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c84
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-main.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c36
-rw-r--r--drivers/media/video/saa5246a.c1
-rw-r--r--drivers/media/video/saa5249.c1
-rw-r--r--drivers/media/video/saa7115.c1250
-rw-r--r--drivers/media/video/saa711x_regs.h549
-rw-r--r--drivers/media/video/saa7134/Kconfig50
-rw-r--r--drivers/media/video/saa7134/Makefile3
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c127
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c197
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c1
-rw-r--r--drivers/media/video/saa7134/saa7134.h3
-rw-r--r--drivers/media/video/tda9887.c2
-rw-r--r--drivers/media/video/tuner-simple.c6
-rw-r--r--drivers/media/video/tuner-types.c1
-rw-r--r--drivers/media/video/tvaudio.c42
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/media/video/tvp5150.c7
-rw-r--r--drivers/media/video/usbvideo/konicawc.c9
-rw-r--r--drivers/media/video/usbvideo/vicam.c4
-rw-r--r--drivers/media/video/v4l1-compat.c12
-rw-r--r--drivers/media/video/v4l2-common.c1
-rw-r--r--drivers/media/video/video-buf-dvb.c2
-rw-r--r--drivers/media/video/videodev.c32
-rw-r--r--drivers/media/video/vino.c1
-rw-r--r--drivers/media/video/vivi.c5
-rw-r--r--drivers/media/video/vpx3220.c2
-rw-r--r--drivers/media/video/zoran_card.c6
-rw-r--r--drivers/media/video/zoran_driver.c7
-rw-r--r--drivers/media/video/zr36120.c6
185 files changed, 8816 insertions, 4197 deletions
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig
index 1a04db4552da..f33e5d973413 100644
--- a/drivers/media/common/Kconfig
+++ b/drivers/media/common/Kconfig
@@ -4,7 +4,6 @@ config VIDEO_SAA7146
4 4
5config VIDEO_SAA7146_VV 5config VIDEO_SAA7146_VV
6 tristate 6 tristate
7 select VIDEO_V4L2
8 select VIDEO_BUF 7 select VIDEO_BUF
9 select VIDEO_VIDEOBUF 8 select VIDEO_VIDEOBUF
10 select VIDEO_SAA7146 9 select VIDEO_SAA7146
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c
index ca98d9478947..db753443587a 100644
--- a/drivers/media/common/ir-keymaps.c
+++ b/drivers/media/common/ir-keymaps.c
@@ -32,6 +32,37 @@ IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
32 32
33EXPORT_SYMBOL_GPL(ir_codes_empty); 33EXPORT_SYMBOL_GPL(ir_codes_empty);
34 34
35/* Michal Majchrowicz <mmajchrowicz@gmail.com> */
36IR_KEYTAB_TYPE ir_codes_proteus_2309[IR_KEYTAB_SIZE] = {
37 /* numeric */
38 [ 0x00 ] = KEY_0,
39 [ 0x01 ] = KEY_1,
40 [ 0x02 ] = KEY_2,
41 [ 0x03 ] = KEY_3,
42 [ 0x04 ] = KEY_4,
43 [ 0x05 ] = KEY_5,
44 [ 0x06 ] = KEY_6,
45 [ 0x07 ] = KEY_7,
46 [ 0x08 ] = KEY_8,
47 [ 0x09 ] = KEY_9,
48
49 [ 0x5c ] = KEY_POWER, /* power */
50 [ 0x20 ] = KEY_F, /* full screen */
51 [ 0x0f ] = KEY_BACKSPACE, /* recall */
52 [ 0x1b ] = KEY_ENTER, /* mute */
53 [ 0x41 ] = KEY_RECORD, /* record */
54 [ 0x43 ] = KEY_STOP, /* stop */
55 [ 0x16 ] = KEY_S,
56 [ 0x1a ] = KEY_Q, /* off */
57 [ 0x2e ] = KEY_RED,
58 [ 0x1f ] = KEY_DOWN, /* channel - */
59 [ 0x1c ] = KEY_UP, /* channel + */
60 [ 0x10 ] = KEY_LEFT, /* volume - */
61 [ 0x1e ] = KEY_RIGHT, /* volume + */
62 [ 0x14 ] = KEY_F1,
63};
64
65EXPORT_SYMBOL_GPL(ir_codes_proteus_2309);
35/* Matt Jesson <dvb@jesson.eclipse.co.uk */ 66/* Matt Jesson <dvb@jesson.eclipse.co.uk */
36IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE] = { 67IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE] = {
37 [ 0x28 ] = KEY_0, //'0' / 'enter' 68 [ 0x28 ] = KEY_0, //'0' / 'enter'
@@ -1473,3 +1504,51 @@ IR_KEYTAB_TYPE ir_codes_npgtech[IR_KEYTAB_SIZE] = {
1473}; 1504};
1474 1505
1475EXPORT_SYMBOL_GPL(ir_codes_npgtech); 1506EXPORT_SYMBOL_GPL(ir_codes_npgtech);
1507
1508/* Norwood Micro (non-Pro) TV Tuner
1509 By Peter Naulls <peter@chocky.org>
1510 Key comments are the functions given in the manual */
1511IR_KEYTAB_TYPE ir_codes_norwood[IR_KEYTAB_SIZE] = {
1512 /* Keys 0 to 9 */
1513 [ 0x20 ] = KEY_0,
1514 [ 0x21 ] = KEY_1,
1515 [ 0x22 ] = KEY_2,
1516 [ 0x23 ] = KEY_3,
1517 [ 0x24 ] = KEY_4,
1518 [ 0x25 ] = KEY_5,
1519 [ 0x26 ] = KEY_6,
1520 [ 0x27 ] = KEY_7,
1521 [ 0x28 ] = KEY_8,
1522 [ 0x29 ] = KEY_9,
1523
1524 [ 0x78 ] = KEY_TUNER, /* Video Source */
1525 [ 0x2c ] = KEY_EXIT, /* Open/Close software */
1526 [ 0x2a ] = KEY_SELECT, /* 2 Digit Select */
1527 [ 0x69 ] = KEY_AGAIN, /* Recall */
1528
1529 [ 0x32 ] = KEY_BRIGHTNESSUP, /* Brightness increase */
1530 [ 0x33 ] = KEY_BRIGHTNESSDOWN, /* Brightness decrease */
1531 [ 0x6b ] = KEY_KPPLUS, /* (not named >>>>>) */
1532 [ 0x6c ] = KEY_KPMINUS, /* (not named <<<<<) */
1533
1534 [ 0x2d ] = KEY_MUTE, /* Mute */
1535 [ 0x30 ] = KEY_VOLUMEUP, /* Volume up */
1536 [ 0x31 ] = KEY_VOLUMEDOWN, /* Volume down */
1537 [ 0x60 ] = KEY_CHANNELUP, /* Channel up */
1538 [ 0x61 ] = KEY_CHANNELDOWN, /* Channel down */
1539
1540 [ 0x3f ] = KEY_RECORD, /* Record */
1541 [ 0x37 ] = KEY_PLAY, /* Play */
1542 [ 0x36 ] = KEY_PAUSE, /* Pause */
1543 [ 0x2b ] = KEY_STOP, /* Stop */
1544 [ 0x67 ] = KEY_FASTFORWARD, /* Foward */
1545 [ 0x66 ] = KEY_REWIND, /* Rewind */
1546 [ 0x3e ] = KEY_SEARCH, /* Auto Scan */
1547 [ 0x2e ] = KEY_CAMERA, /* Capture Video */
1548 [ 0x6d ] = KEY_MENU, /* Show/Hide Control */
1549 [ 0x2f ] = KEY_ZOOM, /* Full Screen */
1550 [ 0x34 ] = KEY_RADIO, /* FM */
1551 [ 0x65 ] = KEY_POWER, /* Computer power */
1552};
1553
1554EXPORT_SYMBOL_GPL(ir_codes_norwood);
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 0027acc5b8e9..d867a6a9e430 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -455,7 +455,6 @@ static void vv_callback(struct saa7146_dev *dev, unsigned long status)
455 455
456static struct video_device device_template = 456static struct video_device device_template =
457{ 457{
458 .hardware = VID_HARDWARE_SAA7146,
459 .fops = &video_fops, 458 .fops = &video_fops,
460 .minor = -1, 459 .minor = -1,
461}; 460};
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
index 49a06fc54c51..a0dcd59da76e 100644
--- a/drivers/media/dvb/b2c2/Kconfig
+++ b/drivers/media/dvb/b2c2/Kconfig
@@ -2,13 +2,13 @@ config DVB_B2C2_FLEXCOP
2 tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters" 2 tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters"
3 depends on DVB_CORE && I2C 3 depends on DVB_CORE && I2C
4 select DVB_PLL 4 select DVB_PLL
5 select DVB_STV0299 5 select DVB_STV0299 if !DVB_FE_CUSTOMISE
6 select DVB_MT352 6 select DVB_MT352 if !DVB_FE_CUSTOMISE
7 select DVB_MT312 7 select DVB_MT312 if !DVB_FE_CUSTOMISE
8 select DVB_NXT200X 8 select DVB_NXT200X if !DVB_FE_CUSTOMISE
9 select DVB_STV0297 9 select DVB_STV0297 if !DVB_FE_CUSTOMISE
10 select DVB_BCM3510 10 select DVB_BCM3510 if !DVB_FE_CUSTOMISE
11 select DVB_LGDT330X 11 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
12 help 12 help
13 Support for the digital TV receiver chip made by B2C2 Inc. included in 13 Support for the digital TV receiver chip made by B2C2 Inc. included in
14 Technisats PCI cards and USB boxes. 14 Technisats PCI cards and USB boxes.
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 3be87c72e37b..b8ba87863457 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -505,7 +505,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
505 struct dvb_frontend_ops *ops; 505 struct dvb_frontend_ops *ops;
506 506
507 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ 507 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */
508 if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { 508 if ((fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) {
509 ops = &fc->fe->ops; 509 ops = &fc->fe->ops;
510 510
511 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; 511 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params;
@@ -519,36 +519,36 @@ int flexcop_frontend_init(struct flexcop_device *fc)
519 info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address); 519 info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address);
520 } else 520 } else
521 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ 521 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
522 if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) { 522 if ((fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) {
523 fc->dev_type = FC_AIR_DVB; 523 fc->dev_type = FC_AIR_DVB;
524 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; 524 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
525 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); 525 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address);
526 } else 526 } else
527 /* try the air atsc 2nd generation (nxt2002) */ 527 /* try the air atsc 2nd generation (nxt2002) */
528 if ((fc->fe = nxt200x_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) { 528 if ((fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, &fc->i2c_adap)) != NULL) {
529 fc->dev_type = FC_AIR_ATSC2; 529 fc->dev_type = FC_AIR_ATSC2;
530 dvb_pll_attach(fc->fe, 0x61, &fc->i2c_adap, &dvb_pll_samsung_tbmv); 530 dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, &dvb_pll_samsung_tbmv);
531 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address); 531 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address);
532 } else 532 } else
533 /* try the air atsc 3nd generation (lgdt3303) */ 533 /* try the air atsc 3nd generation (lgdt3303) */
534 if ((fc->fe = lgdt330x_attach(&air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) { 534 if ((fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) {
535 fc->dev_type = FC_AIR_ATSC3; 535 fc->dev_type = FC_AIR_ATSC3;
536 fc->fe->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; 536 fc->fe->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
537 info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address); 537 info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address);
538 } else 538 } else
539 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ 539 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */
540 if ((fc->fe = bcm3510_attach(&air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) { 540 if ((fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) {
541 fc->dev_type = FC_AIR_ATSC1; 541 fc->dev_type = FC_AIR_ATSC1;
542 info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); 542 info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address);
543 } else 543 } else
544 /* try the cable dvb (stv0297) */ 544 /* try the cable dvb (stv0297) */
545 if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { 545 if ((fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) {
546 fc->dev_type = FC_CABLE; 546 fc->dev_type = FC_CABLE;
547 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; 547 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
548 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); 548 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
549 } else 549 } else
550 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 550 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
551 if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { 551 if ((fc->fe = dvb_attach(vp310_mt312_attach, &skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
552 ops = &fc->fe->ops; 552 ops = &fc->fe->ops;
553 553
554 ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; 554 ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params;
@@ -571,9 +571,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
571 } else { 571 } else {
572 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { 572 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) {
573 err("frontend registration failed!"); 573 err("frontend registration failed!");
574 ops = &fc->fe->ops; 574 dvb_frontend_detach(fc->fe);
575 if (ops->release != NULL)
576 ops->release(fc->fe);
577 fc->fe = NULL; 575 fc->fe = NULL;
578 return -EINVAL; 576 return -EINVAL;
579 } 577 }
@@ -584,8 +582,10 @@ int flexcop_frontend_init(struct flexcop_device *fc)
584 582
585void flexcop_frontend_exit(struct flexcop_device *fc) 583void flexcop_frontend_exit(struct flexcop_device *fc)
586{ 584{
587 if (fc->init_state & FC_STATE_FE_INIT) 585 if (fc->init_state & FC_STATE_FE_INIT) {
588 dvb_unregister_frontend(fc->fe); 586 dvb_unregister_frontend(fc->fe);
587 dvb_frontend_detach(fc->fe);
588 }
589 589
590 fc->init_state &= ~FC_STATE_FE_INIT; 590 fc->init_state &= ~FC_STATE_FE_INIT;
591} 591}
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index 7d0ee1ab2903..ae2ff5dc238d 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -2,13 +2,13 @@ config DVB_BT8XX
2 tristate "BT8xx based PCI cards" 2 tristate "BT8xx based PCI cards"
3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848 3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848
4 select DVB_PLL 4 select DVB_PLL
5 select DVB_MT352 5 select DVB_MT352 if !DVB_FE_CUSTOMISE
6 select DVB_SP887X 6 select DVB_SP887X if !DVB_FE_CUSTOMISE
7 select DVB_NXT6000 7 select DVB_NXT6000 if !DVB_FE_CUSTOMISE
8 select DVB_CX24110 8 select DVB_CX24110 if !DVB_FE_CUSTOMISE
9 select DVB_OR51211 9 select DVB_OR51211 if !DVB_FE_CUSTOMISE
10 select DVB_LGDT330X 10 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
11 select DVB_ZL10353 11 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
12 select FW_LOADER 12 select FW_LOADER
13 help 13 help
14 Support for PCI cards based on the Bt8xx PCI bridge. Examples are 14 Support for PCI cards based on the Bt8xx PCI bridge. Examples are
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 06ac899a9a26..9f72b7000c08 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1715,6 +1715,15 @@ static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_paramet
1715static void dst_release(struct dvb_frontend *fe) 1715static void dst_release(struct dvb_frontend *fe)
1716{ 1716{
1717 struct dst_state *state = fe->demodulator_priv; 1717 struct dst_state *state = fe->demodulator_priv;
1718 if (state->dst_ca) {
1719 dvb_unregister_device(state->dst_ca);
1720#ifdef CONFIG_DVB_CORE_ATTACH
1721 symbol_put(dst_ca_attach);
1722#endif
1723 }
1724#ifdef CONFIG_DVB_CORE_ATTACH
1725 symbol_put(dst_attach);
1726#endif
1718 kfree(state); 1727 kfree(state);
1719} 1728}
1720 1729
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index fa923b9b346e..240ad084fa78 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -699,12 +699,17 @@ static struct dvb_device dvbdev_ca = {
699 .fops = &dst_ca_fops 699 .fops = &dst_ca_fops
700}; 700};
701 701
702int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) 702struct dvb_device *dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter)
703{ 703{
704 struct dvb_device *dvbdev; 704 struct dvb_device *dvbdev;
705
705 dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); 706 dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device");
706 dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); 707 if (dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA) == 0) {
707 return 0; 708 dst->dst_ca = dvbdev;
709 return dst->dst_ca;
710 }
711
712 return NULL;
708} 713}
709 714
710EXPORT_SYMBOL(dst_ca_attach); 715EXPORT_SYMBOL(dst_ca_attach);
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
index 0677b047b3a7..3bf084f2e522 100644
--- a/drivers/media/dvb/bt8xx/dst_common.h
+++ b/drivers/media/dvb/bt8xx/dst_common.h
@@ -140,6 +140,7 @@ struct dst_state {
140 char *tuner_name; 140 char *tuner_name;
141 struct mutex dst_mutex; 141 struct mutex dst_mutex;
142 u8 fw_name[8]; 142 u8 fw_name[8];
143 struct dvb_device *dst_ca;
143}; 144};
144 145
145struct tuner_types { 146struct tuner_types {
@@ -178,7 +179,7 @@ int write_dst(struct dst_state *state, u8 * data, u8 len);
178int read_dst(struct dst_state *state, u8 * ret, u8 len); 179int read_dst(struct dst_state *state, u8 * ret, u8 len);
179u8 dst_check_sum(u8 * buf, u32 len); 180u8 dst_check_sum(u8 * buf, u32 len);
180struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter); 181struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
181int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter); 182struct dvb_device *dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
182int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay); 183int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
183 184
184int dst_command(struct dst_state* state, u8 * data, u8 len); 185int dst_command(struct dst_state* state, u8 * data, u8 len);
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index b715b972d2fc..fb6c4cc8477d 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -67,7 +67,7 @@ static void dvb_bt8xx_task(unsigned long data)
67 67
68static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed) 68static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed)
69{ 69{
70 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 70 struct dvb_demux*dvbdmx = dvbdmxfeed->demux;
71 struct dvb_bt8xx_card *card = dvbdmx->priv; 71 struct dvb_bt8xx_card *card = dvbdmx->priv;
72 int rc; 72 int rc;
73 73
@@ -595,15 +595,14 @@ static void lgdt330x_reset(struct dvb_bt8xx_card *bt)
595 595
596static void frontend_init(struct dvb_bt8xx_card *card, u32 type) 596static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
597{ 597{
598 int ret;
599 struct dst_state* state = NULL; 598 struct dst_state* state = NULL;
600 599
601 switch(type) { 600 switch(type) {
602 case BTTV_BOARD_DVICO_DVBT_LITE: 601 case BTTV_BOARD_DVICO_DVBT_LITE:
603 card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); 602 card->fe = dvb_attach(mt352_attach, &thomson_dtt7579_config, card->i2c_adapter);
604 603
605 if (card->fe == NULL) 604 if (card->fe == NULL)
606 card->fe = zl10353_attach(&thomson_dtt7579_zl10353_config, 605 card->fe = dvb_attach(zl10353_attach, &thomson_dtt7579_zl10353_config,
607 card->i2c_adapter); 606 card->i2c_adapter);
608 607
609 if (card->fe != NULL) { 608 if (card->fe != NULL) {
@@ -615,7 +614,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
615 614
616 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE: 615 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:
617 lgdt330x_reset(card); 616 lgdt330x_reset(card);
618 card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter); 617 card->fe = dvb_attach(lgdt330x_attach, &tdvs_tua6034_config, card->i2c_adapter);
619 if (card->fe != NULL) { 618 if (card->fe != NULL) {
620 card->fe->ops.tuner_ops.set_params = tdvs_tua6034_tuner_set_params; 619 card->fe->ops.tuner_ops.set_params = tdvs_tua6034_tuner_set_params;
621 dprintk ("dvb_bt8xx: lgdt330x detected\n"); 620 dprintk ("dvb_bt8xx: lgdt330x detected\n");
@@ -630,7 +629,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
630 629
631 /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ 630 /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
632 digitv_alps_tded4_reset(card); 631 digitv_alps_tded4_reset(card);
633 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); 632 card->fe = dvb_attach(nxt6000_attach, &vp3021_alps_tded4_config, card->i2c_adapter);
634 if (card->fe != NULL) { 633 if (card->fe != NULL) {
635 card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params; 634 card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
636 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); 635 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
@@ -639,7 +638,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
639 638
640 /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ 639 /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
641 digitv_alps_tded4_reset(card); 640 digitv_alps_tded4_reset(card);
642 card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter); 641 card->fe = dvb_attach(mt352_attach, &digitv_alps_tded4_config, card->i2c_adapter);
643 642
644 if (card->fe != NULL) { 643 if (card->fe != NULL) {
645 card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs; 644 card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs;
@@ -648,14 +647,14 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
648 break; 647 break;
649 648
650 case BTTV_BOARD_AVDVBT_761: 649 case BTTV_BOARD_AVDVBT_761:
651 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter); 650 card->fe = dvb_attach(sp887x_attach, &microtune_mt7202dtf_config, card->i2c_adapter);
652 if (card->fe) { 651 if (card->fe) {
653 card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params; 652 card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params;
654 } 653 }
655 break; 654 break;
656 655
657 case BTTV_BOARD_AVDVBT_771: 656 case BTTV_BOARD_AVDVBT_771:
658 card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); 657 card->fe = dvb_attach(mt352_attach, &advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
659 if (card->fe != NULL) { 658 if (card->fe != NULL) {
660 card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs; 659 card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs;
661 card->fe->ops.info.frequency_min = 174000000; 660 card->fe->ops.info.frequency_min = 174000000;
@@ -670,22 +669,21 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
670 state->config = &dst_config; 669 state->config = &dst_config;
671 state->i2c = card->i2c_adapter; 670 state->i2c = card->i2c_adapter;
672 state->bt = card->bt; 671 state->bt = card->bt;
673 672 state->dst_ca = NULL;
674 /* DST is not a frontend, attaching the ASIC */ 673 /* DST is not a frontend, attaching the ASIC */
675 if ((dst_attach(state, &card->dvb_adapter)) == NULL) { 674 if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) {
676 printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__); 675 printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__);
677 break; 676 break;
678 } 677 }
679 card->fe = &state->frontend;
680
681 /* Attach other DST peripherals if any */ 678 /* Attach other DST peripherals if any */
682 /* Conditional Access device */ 679 /* Conditional Access device */
680 card->fe = &state->frontend;
683 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 681 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
684 ret = dst_ca_attach(state, &card->dvb_adapter); 682 dvb_attach(dst_ca_attach, state, &card->dvb_adapter);
685 break; 683 break;
686 684
687 case BTTV_BOARD_PINNACLESAT: 685 case BTTV_BOARD_PINNACLESAT:
688 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); 686 card->fe = dvb_attach(cx24110_attach, &pctvsat_config, card->i2c_adapter);
689 if (card->fe) { 687 if (card->fe) {
690 card->fe->ops.tuner_ops.init = pinnsat_tuner_init; 688 card->fe->ops.tuner_ops.init = pinnsat_tuner_init;
691 card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep; 689 card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep;
@@ -694,7 +692,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
694 break; 692 break;
695 693
696 case BTTV_BOARD_PC_HDTV: 694 case BTTV_BOARD_PC_HDTV:
697 card->fe = or51211_attach(&or51211_config, card->i2c_adapter); 695 card->fe = dvb_attach(or51211_attach, &or51211_config, card->i2c_adapter);
698 break; 696 break;
699 } 697 }
700 698
@@ -707,8 +705,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
707 else 705 else
708 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { 706 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
709 printk("dvb-bt8xx: Frontend registration failed!\n"); 707 printk("dvb-bt8xx: Frontend registration failed!\n");
710 if (card->fe->ops.release) 708 dvb_frontend_detach(card->fe);
711 card->fe->ops.release(card->fe);
712 card->fe = NULL; 709 card->fe = NULL;
713 } 710 }
714} 711}
@@ -925,8 +922,10 @@ static void dvb_bt8xx_remove(struct bttv_sub_device *sub)
925 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); 922 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
926 dvb_dmxdev_release(&card->dmxdev); 923 dvb_dmxdev_release(&card->dmxdev);
927 dvb_dmx_release(&card->demux); 924 dvb_dmx_release(&card->demux);
928 if (card->fe) 925 if (card->fe) {
929 dvb_unregister_frontend(card->fe); 926 dvb_unregister_frontend(card->fe);
927 dvb_frontend_detach(card->fe);
928 }
930 dvb_unregister_adapter(&card->dvb_adapter); 929 dvb_unregister_adapter(&card->dvb_adapter);
931 930
932 kfree(card); 931 kfree(card);
diff --git a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig
index 12ee912a5705..e46eae3b9be2 100644
--- a/drivers/media/dvb/dvb-core/Kconfig
+++ b/drivers/media/dvb/dvb-core/Kconfig
@@ -9,3 +9,16 @@ config DVB_CORE
9 in-kernel drivers will select this automatically if needed. 9 in-kernel drivers will select this automatically if needed.
10 If unsure say N. 10 If unsure say N.
11 11
12config DVB_CORE_ATTACH
13 bool "Load and attach frontend modules as needed"
14 depends on DVB_CORE
15 depends on MODULES
16 help
17 Remove the static dependency of DVB card drivers on all
18 frontend modules for all possible card variants. Instead,
19 allow the card drivers to only load the frontend modules
20 they require. This saves several KBytes of memory.
21
22 Note: You will need moudule-init-tools v3.2 or later for this feature.
23
24 If unsure say Y.
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 57b34cda99f5..3dd5dbafb330 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -1105,18 +1105,42 @@ int dvb_unregister_frontend(struct dvb_frontend* fe)
1105 mutex_lock(&frontend_mutex); 1105 mutex_lock(&frontend_mutex);
1106 dvb_unregister_device (fepriv->dvbdev); 1106 dvb_unregister_device (fepriv->dvbdev);
1107 dvb_frontend_stop (fe); 1107 dvb_frontend_stop (fe);
1108 if (fe->ops.tuner_ops.release) { 1108
1109 fe->ops.tuner_ops.release(fe);
1110 if (fe->ops.i2c_gate_ctrl)
1111 fe->ops.i2c_gate_ctrl(fe, 0);
1112 }
1113 if (fe->ops.release)
1114 fe->ops.release(fe);
1115 else
1116 printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops.info.name);
1117 /* fe is invalid now */ 1109 /* fe is invalid now */
1118 kfree(fepriv); 1110 kfree(fepriv);
1119 mutex_unlock(&frontend_mutex); 1111 mutex_unlock(&frontend_mutex);
1120 return 0; 1112 return 0;
1121} 1113}
1122EXPORT_SYMBOL(dvb_unregister_frontend); 1114EXPORT_SYMBOL(dvb_unregister_frontend);
1115
1116#ifdef CONFIG_DVB_CORE_ATTACH
1117void dvb_frontend_detach(struct dvb_frontend* fe)
1118{
1119 void *ptr;
1120
1121 if (fe->ops.release_sec) {
1122 fe->ops.release_sec(fe);
1123 symbol_put_addr(fe->ops.release_sec);
1124 }
1125 if (fe->ops.tuner_ops.release) {
1126 fe->ops.tuner_ops.release(fe);
1127 symbol_put_addr(fe->ops.tuner_ops.release);
1128 }
1129 ptr = (void*)fe->ops.release;
1130 if (ptr) {
1131 fe->ops.release(fe);
1132 symbol_put_addr(ptr);
1133 }
1134}
1135#else
1136void dvb_frontend_detach(struct dvb_frontend* fe)
1137{
1138 if (fe->ops.release_sec)
1139 fe->ops.release_sec(fe);
1140 if (fe->ops.tuner_ops.release)
1141 fe->ops.tuner_ops.release(fe);
1142 if (fe->ops.release)
1143 fe->ops.release(fe);
1144}
1145#endif
1146EXPORT_SYMBOL(dvb_frontend_detach);
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index 2887e2b862a4..e5d5028b3694 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -92,10 +92,13 @@ struct dvb_frontend_ops {
92 struct dvb_frontend_info info; 92 struct dvb_frontend_info info;
93 93
94 void (*release)(struct dvb_frontend* fe); 94 void (*release)(struct dvb_frontend* fe);
95 void (*release_sec)(struct dvb_frontend* fe);
95 96
96 int (*init)(struct dvb_frontend* fe); 97 int (*init)(struct dvb_frontend* fe);
97 int (*sleep)(struct dvb_frontend* fe); 98 int (*sleep)(struct dvb_frontend* fe);
98 99
100 int (*write)(struct dvb_frontend* fe, u8* buf, int len);
101
99 /* if this is set, it overrides the default swzigzag */ 102 /* if this is set, it overrides the default swzigzag */
100 int (*tune)(struct dvb_frontend* fe, 103 int (*tune)(struct dvb_frontend* fe,
101 struct dvb_frontend_parameters* params, 104 struct dvb_frontend_parameters* params,
@@ -147,7 +150,7 @@ struct dvb_frontend {
147 void* demodulator_priv; 150 void* demodulator_priv;
148 void* tuner_priv; 151 void* tuner_priv;
149 void* frontend_priv; 152 void* frontend_priv;
150 void* misc_priv; 153 void* sec_priv;
151}; 154};
152 155
153extern int dvb_register_frontend(struct dvb_adapter* dvb, 156extern int dvb_register_frontend(struct dvb_adapter* dvb,
@@ -155,6 +158,8 @@ extern int dvb_register_frontend(struct dvb_adapter* dvb,
155 158
156extern int dvb_unregister_frontend(struct dvb_frontend* fe); 159extern int dvb_unregister_frontend(struct dvb_frontend* fe);
157 160
161extern void dvb_frontend_detach(struct dvb_frontend* fe);
162
158extern void dvb_frontend_reinitialise(struct dvb_frontend *fe); 163extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
159 164
160extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec); 165extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index 7a7f75fd168c..620e7887b3d3 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -102,4 +102,26 @@ extern int dvb_usercopy(struct inode *inode, struct file *file,
102 int (*func)(struct inode *inode, struct file *file, 102 int (*func)(struct inode *inode, struct file *file,
103 unsigned int cmd, void *arg)); 103 unsigned int cmd, void *arg));
104 104
105/** generic DVB attach function. */
106#ifdef CONFIG_DVB_CORE_ATTACH
107#define dvb_attach(FUNCTION, ARGS...) ({ \
108 void *__r = NULL; \
109 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
110 if (__a) { \
111 __r = (void *) __a(ARGS); \
112 if (__r == NULL) \
113 symbol_put(FUNCTION); \
114 } else { \
115 printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
116 } \
117 __r; \
118})
119
120#else
121#define dvb_attach(FUNCTION, ARGS...) ({ \
122 FUNCTION(ARGS); \
123})
124
125#endif
126
105#endif /* #ifndef _DVBDEV_H_ */ 127#endif /* #ifndef _DVBDEV_H_ */
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 75824b77198a..0a3c35399bea 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -26,6 +26,7 @@ config DVB_USB_A800
26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)" 26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)"
27 depends on DVB_USB 27 depends on DVB_USB
28 select DVB_DIB3000MC 28 select DVB_DIB3000MC
29 select DVB_TUNER_MT2060
29 help 30 help
30 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver. 31 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver.
31 32
@@ -33,6 +34,7 @@ config DVB_USB_DIBUSB_MB
33 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)" 34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)"
34 depends on DVB_USB 35 depends on DVB_USB
35 select DVB_DIB3000MB 36 select DVB_DIB3000MB
37 select DVB_TUNER_MT2060
36 help 38 help
37 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by 39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
38 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
@@ -65,6 +67,7 @@ config DVB_USB_DIBUSB_MC
65 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" 67 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"
66 depends on DVB_USB 68 depends on DVB_USB
67 select DVB_DIB3000MC 69 select DVB_DIB3000MC
70 select DVB_TUNER_MT2060
68 help 71 help
69 Support for 2.0 DVB-T receivers based on reference designs made by 72 Support for 2.0 DVB-T receivers based on reference designs made by
70 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 73 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
@@ -80,16 +83,17 @@ config DVB_USB_UMT_010
80 tristate "HanfTek UMT-010 DVB-T USB2.0 support" 83 tristate "HanfTek UMT-010 DVB-T USB2.0 support"
81 depends on DVB_USB 84 depends on DVB_USB
82 select DVB_DIB3000MC 85 select DVB_DIB3000MC
86 select DVB_TUNER_MT2060
83 help 87 help
84 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. 88 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
85 89
86config DVB_USB_CXUSB 90config DVB_USB_CXUSB
87 tristate "Conexant USB2.0 hybrid reference design support" 91 tristate "Conexant USB2.0 hybrid reference design support"
88 depends on DVB_USB 92 depends on DVB_USB
89 select DVB_CX22702 93 select DVB_CX22702 if !DVB_FE_CUSTOMISE
90 select DVB_LGDT330X 94 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
91 select DVB_MT352 95 select DVB_MT352 if !DVB_FE_CUSTOMISE
92 select DVB_ZL10353 96 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
93 help 97 help
94 Say Y here to support the Conexant USB2.0 hybrid reference design. 98 Say Y here to support the Conexant USB2.0 hybrid reference design.
95 Currently, only DVB and ATSC modes are supported, analog mode 99 Currently, only DVB and ATSC modes are supported, analog mode
@@ -101,8 +105,8 @@ config DVB_USB_CXUSB
101config DVB_USB_DIGITV 105config DVB_USB_DIGITV
102 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support" 106 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support"
103 depends on DVB_USB 107 depends on DVB_USB
104 select DVB_NXT6000 108 select DVB_NXT6000 if !DVB_FE_CUSTOMISE
105 select DVB_MT352 109 select DVB_MT352 if !DVB_FE_CUSTOMISE
106 help 110 help
107 Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver. 111 Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver.
108 112
@@ -145,6 +149,7 @@ config DVB_USB_NOVA_T_USB2
145 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" 149 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
146 depends on DVB_USB 150 depends on DVB_USB
147 select DVB_DIB3000MC 151 select DVB_DIB3000MC
152 select DVB_TUNER_MT2060
148 help 153 help
149 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver. 154 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver.
150 155
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index ce44aa6bbb83..df0c384bd4ca 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -26,6 +26,13 @@ static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
26 return 0; 26 return 0;
27} 27}
28 28
29/* assure to put cold to 0 for iManufacturer == 1 */
30static int a800_identify_state(struct usb_device *udev, struct dvb_usb_properties *props,struct dvb_usb_device_description **desc, int *cold)
31{
32 *cold = udev->descriptor.iManufacturer != 1;
33 return 0;
34}
35
29static struct dvb_usb_rc_key a800_rc_keys[] = { 36static struct dvb_usb_rc_key a800_rc_keys[] = {
30 { 0x02, 0x01, KEY_PROG1 }, /* SOURCE */ 37 { 0x02, 0x01, KEY_PROG1 }, /* SOURCE */
31 { 0x02, 0x00, KEY_POWER }, /* POWER */ 38 { 0x02, 0x00, KEY_POWER }, /* POWER */
@@ -113,6 +120,7 @@ static struct dvb_usb_properties a800_properties = {
113 .power_ctrl = a800_power_ctrl, 120 .power_ctrl = a800_power_ctrl,
114 .frontend_attach = dibusb_dib3000mc_frontend_attach, 121 .frontend_attach = dibusb_dib3000mc_frontend_attach,
115 .tuner_attach = dibusb_dib3000mc_tuner_attach, 122 .tuner_attach = dibusb_dib3000mc_tuner_attach,
123 .identify_state = a800_identify_state,
116 124
117 .rc_interval = DEFAULT_RC_INTERVAL, 125 .rc_interval = DEFAULT_RC_INTERVAL,
118 .rc_key_map = a800_rc_keys, 126 .rc_key_map = a800_rc_keys,
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index ae23bdde42a8..c710c0176e07 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -349,6 +349,7 @@ static struct mt352_config cxusb_dee1601_config = {
349 349
350static struct zl10353_config cxusb_zl10353_dee1601_config = { 350static struct zl10353_config cxusb_zl10353_dee1601_config = {
351 .demod_address = 0x0f, 351 .demod_address = 0x0f,
352 .parallel_ts = 1,
352}; 353};
353 354
354static struct mt352_config cxusb_mt352_config = { 355static struct mt352_config cxusb_mt352_config = {
@@ -409,7 +410,7 @@ static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d)
409 410
410 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); 411 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1);
411 412
412 if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL) 413 if ((d->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, &d->i2c_adap)) != NULL)
413 return 0; 414 return 0;
414 415
415 return -EIO; 416 return -EIO;
@@ -422,7 +423,7 @@ static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_device *d)
422 423
423 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 424 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
424 425
425 if ((d->fe = lgdt330x_attach(&cxusb_lgdt3303_config, &d->i2c_adap)) != NULL) 426 if ((d->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config, &d->i2c_adap)) != NULL)
426 return 0; 427 return 0;
427 428
428 return -EIO; 429 return -EIO;
@@ -435,7 +436,7 @@ static int cxusb_mt352_frontend_attach(struct dvb_usb_device *d)
435 436
436 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 437 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
437 438
438 if ((d->fe = mt352_attach(&cxusb_mt352_config, &d->i2c_adap)) != NULL) 439 if ((d->fe = dvb_attach(mt352_attach, &cxusb_mt352_config, &d->i2c_adap)) != NULL)
439 return 0; 440 return 0;
440 441
441 return -EIO; 442 return -EIO;
@@ -448,8 +449,8 @@ static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d)
448 449
449 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 450 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
450 451
451 if (((d->fe = mt352_attach(&cxusb_dee1601_config, &d->i2c_adap)) != NULL) || 452 if (((d->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, &d->i2c_adap)) != NULL) ||
452 ((d->fe = zl10353_attach(&cxusb_zl10353_dee1601_config, &d->i2c_adap)) != NULL)) 453 ((d->fe = dvb_attach(zl10353_attach, &cxusb_zl10353_dee1601_config, &d->i2c_adap)) != NULL))
453 return 0; 454 return 0;
454 455
455 return -EIO; 456 return -EIO;
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index abd75b4a350d..124e25ac53b3 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -131,9 +131,6 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
131 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 131 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
132 return -EAGAIN; 132 return -EAGAIN;
133 133
134 if (num > 2)
135 warn("more than 2 i2c messages at a time is not handled yet. TODO.");
136
137 for (i = 0; i < num; i++) { 134 for (i = 0; i < num; i++) {
138 /* write/read request */ 135 /* write/read request */
139 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { 136 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
@@ -168,31 +165,137 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
168} 165}
169EXPORT_SYMBOL(dibusb_read_eeprom_byte); 166EXPORT_SYMBOL(dibusb_read_eeprom_byte);
170 167
168/* 3000MC/P stuff */
169// Config Adjacent channels Perf -cal22
170static struct dibx000_agc_config dib3000p_mt2060_agc_config = {
171 .band_caps = BAND_VHF | BAND_UHF,
172 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0),
173
174 .agc1_max = 48497,
175 .agc1_min = 23593,
176 .agc2_max = 46531,
177 .agc2_min = 24904,
178
179 .agc1_pt1 = 0x65,
180 .agc1_pt2 = 0x69,
181
182 .agc1_slope1 = 0x51,
183 .agc1_slope2 = 0x27,
184
185 .agc2_pt1 = 0,
186 .agc2_pt2 = 0x33,
187
188 .agc2_slope1 = 0x35,
189 .agc2_slope2 = 0x37,
190};
191
192static struct dib3000mc_config stk3000p_dib3000p_config = {
193 &dib3000p_mt2060_agc_config,
194
195 .max_time = 0x196,
196 .ln_adc_level = 0x1cc7,
197
198 .output_mpeg2_in_188_bytes = 1,
199};
200
201static struct dibx000_agc_config dib3000p_panasonic_agc_config = {
202 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0),
203
204 .agc1_max = 56361,
205 .agc1_min = 22282,
206 .agc2_max = 47841,
207 .agc2_min = 36045,
208
209 .agc1_pt1 = 0x3b,
210 .agc1_pt2 = 0x6b,
211
212 .agc1_slope1 = 0x55,
213 .agc1_slope2 = 0x1d,
214
215 .agc2_pt1 = 0,
216 .agc2_pt2 = 0x0a,
217
218 .agc2_slope1 = 0x95,
219 .agc2_slope2 = 0x1e,
220};
221
222static struct dib3000mc_config mod3000p_dib3000p_config = {
223 &dib3000p_panasonic_agc_config,
224
225 .max_time = 0x51,
226 .ln_adc_level = 0x1cc7,
227
228 .output_mpeg2_in_188_bytes = 1,
229};
230
171int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d) 231int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d)
172{ 232{
173 struct dib3000_config demod_cfg; 233 if (dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000P_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0 ||
174 struct dibusb_state *st = d->priv; 234 dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000MC_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0) {
175 235 if (d->priv != NULL) {
176 for (demod_cfg.demod_address = 0x8; demod_cfg.demod_address < 0xd; demod_cfg.demod_address++) 236 struct dibusb_state *st = d->priv;
177 if ((d->fe = dib3000mc_attach(&demod_cfg,&d->i2c_adap,&st->ops)) != NULL) { 237 st->ops.pid_parse = dib3000mc_pid_parse;
178 d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; 238 st->ops.pid_ctrl = dib3000mc_pid_control;
179 d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
180 d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
181 return 0;
182 } 239 }
183 240 return 0;
241 }
184 return -ENODEV; 242 return -ENODEV;
185} 243}
186EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach); 244EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach);
187 245
246static struct mt2060_config stk3000p_mt2060_config = {
247 0x60
248};
249
188int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d) 250int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
189{ 251{
190 d->pll_addr = 0x60; 252 struct dibusb_state *st = d->priv;
191 d->pll_desc = &dvb_pll_env57h1xd5; 253 int ret;
192 254 u8 a,b;
193 d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; 255 u16 if1 = 1220;
194 d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; 256 struct i2c_adapter *tun_i2c;
257
258 // First IF calibration for Liteon Sticks
259 if (d->udev->descriptor.idVendor == USB_VID_LITEON &&
260 d->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) {
261
262 dibusb_read_eeprom_byte(d,0x7E,&a);
263 dibusb_read_eeprom_byte(d,0x7F,&b);
264
265 if (a == 0x00)
266 if1 += b;
267 else if (a == 0x80)
268 if1 -= b;
269 else
270 warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b);
271
272 } else if (d->udev->descriptor.idVendor == USB_VID_DIBCOM &&
273 d->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) {
274 u8 desc;
275 dibusb_read_eeprom_byte(d, 7, &desc);
276 if (desc == 2) {
277 a = 127;
278 do {
279 dibusb_read_eeprom_byte(d, a, &desc);
280 a--;
281 } while (a > 7 && (desc == 0xff || desc == 0x00));
282 if (desc & 0x80)
283 if1 -= (0xff - desc);
284 else
285 if1 += desc;
286 }
287 }
195 288
289 tun_i2c = dib3000mc_get_tuner_i2c_master(d->fe, 1);
290 if ((ret = mt2060_attach(d->fe, tun_i2c, &stk3000p_mt2060_config, if1)) != 0) {
291 /* not found - use panasonic pll parameters */
292 if (dvb_pll_attach(d->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL)
293 return -ENOMEM;
294 } else {
295 st->mt2060_present = 1;
296 /* set the correct parameters for the dib3000p */
297 dib3000mc_set_config(d->fe, &stk3000p_dib3000p_config);
298 }
196 return 0; 299 return 0;
197} 300}
198EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach); 301EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);
@@ -267,6 +370,67 @@ struct dvb_usb_rc_key dibusb_rc_keys[] = {
267 { 0x86, 0x1e, KEY_DOWN }, 370 { 0x86, 0x1e, KEY_DOWN },
268 { 0x86, 0x1f, KEY_LEFT }, 371 { 0x86, 0x1f, KEY_LEFT },
269 { 0x86, 0x1b, KEY_RIGHT }, 372 { 0x86, 0x1b, KEY_RIGHT },
373
374 /* Key codes for the DiBcom MOD3000 remote. */
375 { 0x80, 0x00, KEY_MUTE },
376 { 0x80, 0x01, KEY_TEXT },
377 { 0x80, 0x02, KEY_HOME },
378 { 0x80, 0x03, KEY_POWER },
379
380 { 0x80, 0x04, KEY_RED },
381 { 0x80, 0x05, KEY_GREEN },
382 { 0x80, 0x06, KEY_YELLOW },
383 { 0x80, 0x07, KEY_BLUE },
384
385 { 0x80, 0x08, KEY_DVD },
386 { 0x80, 0x09, KEY_AUDIO },
387 { 0x80, 0x0a, KEY_MEDIA }, /* Pictures */
388 { 0x80, 0x0b, KEY_VIDEO },
389
390 { 0x80, 0x0c, KEY_BACK },
391 { 0x80, 0x0d, KEY_UP },
392 { 0x80, 0x0e, KEY_RADIO },
393 { 0x80, 0x0f, KEY_EPG },
394
395 { 0x80, 0x10, KEY_LEFT },
396 { 0x80, 0x11, KEY_OK },
397 { 0x80, 0x12, KEY_RIGHT },
398 { 0x80, 0x13, KEY_UNKNOWN }, /* SAP */
399
400 { 0x80, 0x14, KEY_TV },
401 { 0x80, 0x15, KEY_DOWN },
402 { 0x80, 0x16, KEY_MENU }, /* DVD Menu */
403 { 0x80, 0x17, KEY_LAST },
404
405 { 0x80, 0x18, KEY_RECORD },
406 { 0x80, 0x19, KEY_STOP },
407 { 0x80, 0x1a, KEY_PAUSE },
408 { 0x80, 0x1b, KEY_PLAY },
409
410 { 0x80, 0x1c, KEY_PREVIOUS },
411 { 0x80, 0x1d, KEY_REWIND },
412 { 0x80, 0x1e, KEY_FASTFORWARD },
413 { 0x80, 0x1f, KEY_NEXT},
414
415 { 0x80, 0x40, KEY_1 },
416 { 0x80, 0x41, KEY_2 },
417 { 0x80, 0x42, KEY_3 },
418 { 0x80, 0x43, KEY_CHANNELUP },
419
420 { 0x80, 0x44, KEY_4 },
421 { 0x80, 0x45, KEY_5 },
422 { 0x80, 0x46, KEY_6 },
423 { 0x80, 0x47, KEY_CHANNELDOWN },
424
425 { 0x80, 0x48, KEY_7 },
426 { 0x80, 0x49, KEY_8 },
427 { 0x80, 0x4a, KEY_9 },
428 { 0x80, 0x4b, KEY_VOLUMEUP },
429
430 { 0x80, 0x4c, KEY_CLEAR },
431 { 0x80, 0x4d, KEY_0 },
432 { 0x80, 0x4e, KEY_ENTER },
433 { 0x80, 0x4f, KEY_VOLUMEDOWN },
270}; 434};
271EXPORT_SYMBOL(dibusb_rc_keys); 435EXPORT_SYMBOL(dibusb_rc_keys);
272 436
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c
index f4c45f386ebc..effd34cc4b02 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mb.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c
@@ -21,11 +21,11 @@ static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_device *d)
21 21
22 demod_cfg.demod_address = 0x8; 22 demod_cfg.demod_address = 0x8;
23 23
24 if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) { 24 if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL)
25 d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
26 d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
27 return -ENODEV; 25 return -ENODEV;
28 } 26
27 d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
28 d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
29 29
30 d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl; 30 d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
31 31
@@ -169,7 +169,7 @@ static struct dvb_usb_properties dibusb1_1_properties = {
169 169
170 .rc_interval = DEFAULT_RC_INTERVAL, 170 .rc_interval = DEFAULT_RC_INTERVAL,
171 .rc_key_map = dibusb_rc_keys, 171 .rc_key_map = dibusb_rc_keys,
172 .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */ 172 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
173 .rc_query = dibusb_rc_query, 173 .rc_query = dibusb_rc_query,
174 174
175 .i2c_algo = &dibusb_i2c_algo, 175 .i2c_algo = &dibusb_i2c_algo,
@@ -247,7 +247,7 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = {
247 247
248 .rc_interval = DEFAULT_RC_INTERVAL, 248 .rc_interval = DEFAULT_RC_INTERVAL,
249 .rc_key_map = dibusb_rc_keys, 249 .rc_key_map = dibusb_rc_keys,
250 .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */ 250 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
251 .rc_query = dibusb_rc_query, 251 .rc_query = dibusb_rc_query,
252 252
253 .i2c_algo = &dibusb_i2c_algo, 253 .i2c_algo = &dibusb_i2c_algo,
@@ -272,8 +272,8 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = {
272#endif 272#endif
273 .devices = { 273 .devices = {
274 { "Artec T1 USB1.1 TVBOX with AN2235", 274 { "Artec T1 USB1.1 TVBOX with AN2235",
275 { &dibusb_dib3000mb_table[20], NULL },
276 { &dibusb_dib3000mb_table[21], NULL }, 275 { &dibusb_dib3000mb_table[21], NULL },
276 { &dibusb_dib3000mb_table[22], NULL },
277 }, 277 },
278#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY 278#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY
279 { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)", 279 { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)",
@@ -304,7 +304,7 @@ static struct dvb_usb_properties dibusb2_0b_properties = {
304 304
305 .rc_interval = DEFAULT_RC_INTERVAL, 305 .rc_interval = DEFAULT_RC_INTERVAL,
306 .rc_key_map = dibusb_rc_keys, 306 .rc_key_map = dibusb_rc_keys,
307 .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */ 307 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
308 .rc_query = dibusb_rc_query, 308 .rc_query = dibusb_rc_query,
309 309
310 .i2c_algo = &dibusb_i2c_algo, 310 .i2c_algo = &dibusb_i2c_algo,
@@ -355,7 +355,7 @@ static struct dvb_usb_properties artec_t1_usb2_properties = {
355 355
356 .rc_interval = DEFAULT_RC_INTERVAL, 356 .rc_interval = DEFAULT_RC_INTERVAL,
357 .rc_key_map = dibusb_rc_keys, 357 .rc_key_map = dibusb_rc_keys,
358 .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */ 358 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
359 .rc_query = dibusb_rc_query, 359 .rc_query = dibusb_rc_query,
360 360
361 .i2c_algo = &dibusb_i2c_algo, 361 .i2c_algo = &dibusb_i2c_algo,
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
index 55802fba3c29..eca4082a61ae 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
@@ -28,6 +28,17 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
28/* 00 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_COLD) }, 28/* 00 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_COLD) },
29/* 01 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_WARM) }, 29/* 01 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_WARM) },
30/* 02 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) }, 30/* 02 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) },
31/* 03 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_WARM) }, // ( ? )
32/* 04 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_COLD) },
33/* 05 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_WARM) },
34/* 06 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_COLD) },
35/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_WARM) },
36/* 08 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB2_COLD) },
37/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB2_WARM) },
38/* 10 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_COLD) },
39/* 11 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_WARM) },
40/* 12 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_COLD) },
41/* 13 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_WARM) },
31 { } /* Terminating entry */ 42 { } /* Terminating entry */
32}; 43};
33MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table); 44MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
@@ -50,7 +61,7 @@ static struct dvb_usb_properties dibusb_mc_properties = {
50 61
51 .rc_interval = DEFAULT_RC_INTERVAL, 62 .rc_interval = DEFAULT_RC_INTERVAL,
52 .rc_key_map = dibusb_rc_keys, 63 .rc_key_map = dibusb_rc_keys,
53 .rc_key_map_size = 63, /* FIXME */ 64 .rc_key_map_size = 111, /* FIXME */
54 .rc_query = dibusb_rc_query, 65 .rc_query = dibusb_rc_query,
55 66
56 .i2c_algo = &dibusb_i2c_algo, 67 .i2c_algo = &dibusb_i2c_algo,
@@ -68,16 +79,38 @@ static struct dvb_usb_properties dibusb_mc_properties = {
68 } 79 }
69 }, 80 },
70 81
71 .num_device_descs = 2, 82 .num_device_descs = 7,
72 .devices = { 83 .devices = {
73 { "DiBcom USB2.0 DVB-T reference design (MOD3000P)", 84 { "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
74 { &dibusb_dib3000mc_table[0], NULL }, 85 { &dibusb_dib3000mc_table[0], NULL },
75 { &dibusb_dib3000mc_table[1], NULL }, 86 { &dibusb_dib3000mc_table[1], NULL },
76 }, 87 },
77 { "Artec T1 USB2.0 TVBOX (please report the warm ID)", 88 { "Artec T1 USB2.0 TVBOX (please check the warm ID)",
78 { &dibusb_dib3000mc_table[2], NULL }, 89 { &dibusb_dib3000mc_table[2], NULL },
79 { NULL }, 90 { &dibusb_dib3000mc_table[3], NULL },
80 }, 91 },
92 { "LITE-ON USB2.0 DVB-T Tuner",
93 /* Also rebranded as Intuix S800, Toshiba */
94 { &dibusb_dib3000mc_table[4], NULL },
95 { &dibusb_dib3000mc_table[5], NULL },
96 },
97 { "MSI Digivox Mini SL",
98 { &dibusb_dib3000mc_table[6], NULL },
99 { &dibusb_dib3000mc_table[7], NULL },
100 },
101 { "GRAND - USB2.0 DVB-T adapter",
102 { &dibusb_dib3000mc_table[8], NULL },
103 { &dibusb_dib3000mc_table[9], NULL },
104 },
105 { "Artec T14 - USB2.0 DVB-T",
106 { &dibusb_dib3000mc_table[10], NULL },
107 { &dibusb_dib3000mc_table[11], NULL },
108 },
109 { "Leadtek - USB2.0 Winfast DTV dongle",
110 { &dibusb_dib3000mc_table[12], NULL },
111 { &dibusb_dib3000mc_table[13], NULL },
112 },
113 { NULL },
81 } 114 }
82}; 115};
83 116
diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h
index 2d99d05c7eab..a43f87480cf6 100644
--- a/drivers/media/dvb/dvb-usb/dibusb.h
+++ b/drivers/media/dvb/dvb-usb/dibusb.h
@@ -17,6 +17,8 @@
17#include "dvb-usb.h" 17#include "dvb-usb.h"
18 18
19#include "dib3000.h" 19#include "dib3000.h"
20#include "dib3000mc.h"
21#include "mt2060.h"
20 22
21/* 23/*
22 * protocol of all dibusb related devices 24 * protocol of all dibusb related devices
@@ -96,6 +98,7 @@
96 98
97struct dibusb_state { 99struct dibusb_state {
98 struct dib_fe_xfer_ops ops; 100 struct dib_fe_xfer_ops ops;
101 int mt2060_present;
99 102
100 /* for RC5 remote control */ 103 /* for RC5 remote control */
101 int old_toggle; 104 int old_toggle;
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index c14d9efb48fd..015854487308 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -128,11 +128,11 @@ static struct nxt6000_config digitv_nxt6000_config = {
128 128
129static int digitv_frontend_attach(struct dvb_usb_device *d) 129static int digitv_frontend_attach(struct dvb_usb_device *d)
130{ 130{
131 if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) { 131 if ((d->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &d->i2c_adap)) != NULL) {
132 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; 132 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
133 return 0; 133 return 0;
134 } 134 }
135 if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { 135 if ((d->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &d->i2c_adap)) != NULL) {
136 d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; 136 d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params;
137 return 0; 137 return 0;
138 } 138 }
@@ -147,21 +147,91 @@ static int digitv_tuner_attach(struct dvb_usb_device *d)
147} 147}
148 148
149static struct dvb_usb_rc_key digitv_rc_keys[] = { 149static struct dvb_usb_rc_key digitv_rc_keys[] = {
150 { 0x00, 0x16, KEY_POWER }, /* dummy key */ 150 { 0x5f, 0x55, KEY_0 },
151 { 0x6f, 0x55, KEY_1 },
152 { 0x9f, 0x55, KEY_2 },
153 { 0xaf, 0x55, KEY_3 },
154 { 0x5f, 0x56, KEY_4 },
155 { 0x6f, 0x56, KEY_5 },
156 { 0x9f, 0x56, KEY_6 },
157 { 0xaf, 0x56, KEY_7 },
158 { 0x5f, 0x59, KEY_8 },
159 { 0x6f, 0x59, KEY_9 },
160 { 0x9f, 0x59, KEY_TV },
161 { 0xaf, 0x59, KEY_AUX },
162 { 0x5f, 0x5a, KEY_DVD },
163 { 0x6f, 0x5a, KEY_POWER },
164 { 0x9f, 0x5a, KEY_MHP }, /* labelled 'Picture' */
165 { 0xaf, 0x5a, KEY_AUDIO },
166 { 0x5f, 0x65, KEY_INFO },
167 { 0x6f, 0x65, KEY_F13 }, /* 16:9 */
168 { 0x9f, 0x65, KEY_F14 }, /* 14:9 */
169 { 0xaf, 0x65, KEY_EPG },
170 { 0x5f, 0x66, KEY_EXIT },
171 { 0x6f, 0x66, KEY_MENU },
172 { 0x9f, 0x66, KEY_UP },
173 { 0xaf, 0x66, KEY_DOWN },
174 { 0x5f, 0x69, KEY_LEFT },
175 { 0x6f, 0x69, KEY_RIGHT },
176 { 0x9f, 0x69, KEY_ENTER },
177 { 0xaf, 0x69, KEY_CHANNELUP },
178 { 0x5f, 0x6a, KEY_CHANNELDOWN },
179 { 0x6f, 0x6a, KEY_VOLUMEUP },
180 { 0x9f, 0x6a, KEY_VOLUMEDOWN },
181 { 0xaf, 0x6a, KEY_RED },
182 { 0x5f, 0x95, KEY_GREEN },
183 { 0x6f, 0x95, KEY_YELLOW },
184 { 0x9f, 0x95, KEY_BLUE },
185 { 0xaf, 0x95, KEY_SUBTITLE },
186 { 0x5f, 0x96, KEY_F15 }, /* AD */
187 { 0x6f, 0x96, KEY_TEXT },
188 { 0x9f, 0x96, KEY_MUTE },
189 { 0xaf, 0x96, KEY_REWIND },
190 { 0x5f, 0x99, KEY_STOP },
191 { 0x6f, 0x99, KEY_PLAY },
192 { 0x9f, 0x99, KEY_FASTFORWARD },
193 { 0xaf, 0x99, KEY_F16 }, /* chapter */
194 { 0x5f, 0x9a, KEY_PAUSE },
195 { 0x6f, 0x9a, KEY_PLAY },
196 { 0x9f, 0x9a, KEY_RECORD },
197 { 0xaf, 0x9a, KEY_F17 }, /* picture in picture */
198 { 0x5f, 0xa5, KEY_KPPLUS }, /* zoom in */
199 { 0x6f, 0xa5, KEY_KPMINUS }, /* zoom out */
200 { 0x9f, 0xa5, KEY_F18 }, /* capture */
201 { 0xaf, 0xa5, KEY_F19 }, /* web */
202 { 0x5f, 0xa6, KEY_EMAIL },
203 { 0x6f, 0xa6, KEY_PHONE },
204 { 0x9f, 0xa6, KEY_PC },
151}; 205};
152 206
153/* TODO is it really the NEC protocol ? */
154static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 207static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
155{ 208{
209 int i;
156 u8 key[5]; 210 u8 key[5];
211 u8 b[4] = { 0 };
212
213 *event = 0;
214 *state = REMOTE_NO_KEY_PRESSED;
157 215
158 digitv_ctrl_msg(d,USB_READ_REMOTE,0,NULL,0,&key[1],4); 216 digitv_ctrl_msg(d,USB_READ_REMOTE,0,NULL,0,&key[1],4);
159 /* TODO state, maybe it is VV ? */ 217
218 /* Tell the device we've read the remote. Not sure how necessary
219 this is, but the Nebula SDK does it. */
220 digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0);
221
222 /* if something is inside the buffer, simulate key press */
160 if (key[1] != 0) 223 if (key[1] != 0)
161 key[0] = 0x01; /* if something is inside the buffer, simulate key press */ 224 {
225 for (i = 0; i < d->props.rc_key_map_size; i++) {
226 if (d->props.rc_key_map[i].custom == key[1] &&
227 d->props.rc_key_map[i].data == key[2]) {
228 *event = d->props.rc_key_map[i].event;
229 *state = REMOTE_KEY_PRESSED;
230 return 0;
231 }
232 }
233 }
162 234
163 /* call the universal NEC remote processor, to find out the key's state and event */
164 dvb_usb_nec_rc_key_to_event(d,key,event,state);
165 if (key[0] != 0) 235 if (key[0] != 0)
166 deb_rc("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]); 236 deb_rc("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
167 return 0; 237 return 0;
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
index 70afcfd141ca..27af4e436479 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -93,6 +93,7 @@ static int dtt200u_frontend_attach(struct dvb_usb_device *d)
93} 93}
94 94
95static struct dvb_usb_properties dtt200u_properties; 95static struct dvb_usb_properties dtt200u_properties;
96static struct dvb_usb_properties wt220u_fc_properties;
96static struct dvb_usb_properties wt220u_properties; 97static struct dvb_usb_properties wt220u_properties;
97static struct dvb_usb_properties wt220u_zl0353_properties; 98static struct dvb_usb_properties wt220u_zl0353_properties;
98 99
@@ -101,6 +102,7 @@ static int dtt200u_usb_probe(struct usb_interface *intf,
101{ 102{
102 if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 || 103 if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 ||
103 dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0 || 104 dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0 ||
105 dvb_usb_device_init(intf,&wt220u_fc_properties,THIS_MODULE,NULL) == 0 ||
104 dvb_usb_device_init(intf,&wt220u_zl0353_properties,THIS_MODULE,NULL) == 0) 106 dvb_usb_device_init(intf,&wt220u_zl0353_properties,THIS_MODULE,NULL) == 0)
105 return 0; 107 return 0;
106 108
@@ -114,6 +116,9 @@ static struct usb_device_id dtt200u_usb_table [] = {
114 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, 116 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) },
115 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_COLD) }, 117 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_COLD) },
116 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_WARM) }, 118 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_WARM) },
119 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_FC_COLD) },
120 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_FC_WARM) },
121 { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZAP250_COLD) },
117 { 0 }, 122 { 0 },
118}; 123};
119MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); 124MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
@@ -193,13 +198,54 @@ static struct dvb_usb_properties wt220u_properties = {
193 .num_device_descs = 1, 198 .num_device_descs = 1,
194 .devices = { 199 .devices = {
195 { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)", 200 { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
196 .cold_ids = { &dtt200u_usb_table[2], NULL }, 201 .cold_ids = { &dtt200u_usb_table[2], &dtt200u_usb_table[8], NULL },
197 .warm_ids = { &dtt200u_usb_table[3], NULL }, 202 .warm_ids = { &dtt200u_usb_table[3], NULL },
198 }, 203 },
199 { NULL }, 204 { NULL },
200 } 205 }
201}; 206};
202 207
208static struct dvb_usb_properties wt220u_fc_properties = {
209 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
210 .pid_filter_count = 15,
211
212 .usb_ctrl = CYPRESS_FX2,
213 .firmware = "dvb-usb-wt220u-fc03.fw",
214
215 .power_ctrl = dtt200u_power_ctrl,
216 .streaming_ctrl = dtt200u_streaming_ctrl,
217 .pid_filter = dtt200u_pid_filter,
218 .frontend_attach = dtt200u_frontend_attach,
219
220 .rc_interval = 300,
221 .rc_key_map = dtt200u_rc_keys,
222 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
223 .rc_query = dtt200u_rc_query,
224
225 .generic_bulk_ctrl_endpoint = 0x01,
226
227 /* parameter for the MPEG2-data transfer */
228 .urb = {
229 .type = DVB_USB_BULK,
230 .count = 7,
231 .endpoint = 0x86,
232 .u = {
233 .bulk = {
234 .buffersize = 4096,
235 }
236 }
237 },
238
239 .num_device_descs = 1,
240 .devices = {
241 { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
242 .cold_ids = { &dtt200u_usb_table[6], NULL },
243 .warm_ids = { &dtt200u_usb_table[7], NULL },
244 },
245 { NULL },
246 }
247};
248
203static struct dvb_usb_properties wt220u_zl0353_properties = { 249static struct dvb_usb_properties wt220u_zl0353_properties = {
204 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, 250 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
205 .pid_filter_count = 15, 251 .pid_filter_count = 15,
@@ -271,6 +317,6 @@ module_init(dtt200u_usb_module_init);
271module_exit(dtt200u_usb_module_exit); 317module_exit(dtt200u_usb_module_exit);
272 318
273MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 319MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
274MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon DVB-T USB2.0 devices"); 320MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon/Club3D DVB-T USB2.0 devices");
275MODULE_VERSION("1.0"); 321MODULE_VERSION("1.0");
276MODULE_LICENSE("GPL"); 322MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
index ec631708c394..fe6208ada903 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
@@ -175,36 +175,36 @@ static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
175int dvb_usb_fe_init(struct dvb_usb_device* d) 175int dvb_usb_fe_init(struct dvb_usb_device* d)
176{ 176{
177 if (d->props.frontend_attach == NULL) { 177 if (d->props.frontend_attach == NULL) {
178 err("strange '%s' doesn't want to attach a frontend.",d->desc->name); 178 err("strange: '%s' doesn't want to attach a frontend.",d->desc->name);
179 return 0; 179 return 0;
180 } 180 }
181 181
182 d->props.frontend_attach(d);
183
184 /* re-assign sleep and wakeup functions */ 182 /* re-assign sleep and wakeup functions */
185 if (d->fe != NULL) { 183 if (d->props.frontend_attach(d) == 0 && d->fe != NULL) {
186 d->fe_init = d->fe->ops.init; d->fe->ops.init = dvb_usb_fe_wakeup; 184 d->fe_init = d->fe->ops.init; d->fe->ops.init = dvb_usb_fe_wakeup;
187 d->fe_sleep = d->fe->ops.sleep; d->fe->ops.sleep = dvb_usb_fe_sleep; 185 d->fe_sleep = d->fe->ops.sleep; d->fe->ops.sleep = dvb_usb_fe_sleep;
188 186
189 if (dvb_register_frontend(&d->dvb_adap, d->fe)) { 187 if (dvb_register_frontend(&d->dvb_adap, d->fe)) {
190 err("Frontend registration failed."); 188 err("Frontend registration failed.");
191 if (d->fe->ops.release) 189 dvb_frontend_detach(d->fe);
192 d->fe->ops.release(d->fe);
193 d->fe = NULL; 190 d->fe = NULL;
194 return -ENODEV; 191 return -ENODEV;
195 } 192 }
193
194 /* only attach the tuner if the demod is there */
195 if (d->props.tuner_attach != NULL)
196 d->props.tuner_attach(d);
196 } else 197 } else
197 err("no frontend was attached by '%s'",d->desc->name); 198 err("no frontend was attached by '%s'",d->desc->name);
198 199
199 if (d->props.tuner_attach != NULL)
200 d->props.tuner_attach(d);
201
202 return 0; 200 return 0;
203} 201}
204 202
205int dvb_usb_fe_exit(struct dvb_usb_device *d) 203int dvb_usb_fe_exit(struct dvb_usb_device *d)
206{ 204{
207 if (d->fe != NULL) 205 if (d->fe != NULL) {
208 dvb_unregister_frontend(d->fe); 206 dvb_unregister_frontend(d->fe);
207 dvb_frontend_detach(d->fe);
208 }
209 return 0; 209 return 0;
210} 210}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 95698918bc11..57a10de1d3dd 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -10,51 +10,53 @@
10#define _DVB_USB_IDS_H_ 10#define _DVB_USB_IDS_H_
11 11
12/* Vendor IDs */ 12/* Vendor IDs */
13#define USB_VID_ADSTECH 0x06e1 13#define USB_VID_ADSTECH 0x06e1
14#define USB_VID_ANCHOR 0x0547 14#define USB_VID_ANCHOR 0x0547
15#define USB_VID_WIDEVIEW 0x14aa 15#define USB_VID_AVERMEDIA 0x07ca
16#define USB_VID_AVERMEDIA 0x07ca 16#define USB_VID_COMPRO 0x185b
17#define USB_VID_COMPRO 0x185b 17#define USB_VID_COMPRO_UNK 0x145f
18#define USB_VID_COMPRO_UNK 0x145f 18#define USB_VID_CYPRESS 0x04b4
19#define USB_VID_CYPRESS 0x04b4 19#define USB_VID_DIBCOM 0x10b8
20#define USB_VID_DIBCOM 0x10b8 20#define USB_VID_DVICO 0x0fe9
21#define USB_VID_DVICO 0x0fe9 21#define USB_VID_EMPIA 0xeb1a
22#define USB_VID_EMPIA 0xeb1a 22#define USB_VID_GENPIX 0x09c0
23#define USB_VID_GRANDTEC 0x5032 23#define USB_VID_GRANDTEC 0x5032
24#define USB_VID_HANFTEK 0x15f4 24#define USB_VID_HANFTEK 0x15f4
25#define USB_VID_HAUPPAUGE 0x2040 25#define USB_VID_HAUPPAUGE 0x2040
26#define USB_VID_HYPER_PALTEK 0x1025 26#define USB_VID_HYPER_PALTEK 0x1025
27#define USB_VID_KWORLD 0xeb2a 27#define USB_VID_KWORLD 0xeb2a
28#define USB_VID_KYE 0x0458 28#define USB_VID_KYE 0x0458
29#define USB_VID_MEDION 0x1660 29#define USB_VID_LEADTEK 0x0413
30#define USB_VID_PINNACLE 0x2304 30#define USB_VID_LITEON 0x04ca
31#define USB_VID_VISIONPLUS 0x13d3 31#define USB_VID_MEDION 0x1660
32#define USB_VID_TWINHAN 0x1822 32#define USB_VID_PINNACLE 0x2304
33#define USB_VID_ULTIMA_ELECTRONIC 0x05d8 33#define USB_VID_VISIONPLUS 0x13d3
34#define USB_VID_GENPIX 0x09c0 34#define USB_VID_TWINHAN 0x1822
35#define USB_VID_ULTIMA_ELECTRONIC 0x05d8
36#define USB_VID_WIDEVIEW 0x14aa
35 37
36/* Product IDs */ 38/* Product IDs */
37#define USB_PID_ADSTECH_USB2_COLD 0xa333 39#define USB_PID_ADSTECH_USB2_COLD 0xa333
38#define USB_PID_ADSTECH_USB2_WARM 0xa334 40#define USB_PID_ADSTECH_USB2_WARM 0xa334
39#define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001 41#define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001
40#define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002 42#define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002
41#define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800 43#define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800
42#define USB_PID_AVERMEDIA_DVBT_USB2_WARM 0xa801 44#define USB_PID_AVERMEDIA_DVBT_USB2_WARM 0xa801
43#define USB_PID_COMPRO_DVBU2000_COLD 0xd000 45#define USB_PID_COMPRO_DVBU2000_COLD 0xd000
44#define USB_PID_COMPRO_DVBU2000_WARM 0xd001 46#define USB_PID_COMPRO_DVBU2000_WARM 0xd001
45#define USB_PID_COMPRO_DVBU2000_UNK_COLD 0x010c 47#define USB_PID_COMPRO_DVBU2000_UNK_COLD 0x010c
46#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d 48#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d
47#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064 49#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064
48#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 50#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065
49#define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8 51#define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8
50#define USB_PID_DIBCOM_MOD3000_WARM 0x0bb9 52#define USB_PID_DIBCOM_MOD3000_WARM 0x0bb9
51#define USB_PID_DIBCOM_MOD3001_COLD 0x0bc6 53#define USB_PID_DIBCOM_MOD3001_COLD 0x0bc6
52#define USB_PID_DIBCOM_MOD3001_WARM 0x0bc7 54#define USB_PID_DIBCOM_MOD3001_WARM 0x0bc7
53#define USB_PID_DIBCOM_STK7700 0x1e14 55#define USB_PID_DIBCOM_STK7700 0x1e14
54#define USB_PID_DIBCOM_STK7700_REENUM 0x1e15 56#define USB_PID_DIBCOM_STK7700_REENUM 0x1e15
55#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 57#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131
56#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 58#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
57#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 59#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
58#define USB_PID_KWORLD_VSTREAM_COLD 0x17de 60#define USB_PID_KWORLD_VSTREAM_COLD 0x17de
59#define USB_PID_KWORLD_VSTREAM_WARM 0x17df 61#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
60#define USB_PID_TWINHAN_VP7041_COLD 0x3201 62#define USB_PID_TWINHAN_VP7041_COLD 0x3201
@@ -69,25 +71,30 @@
69#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 71#define USB_PID_DNTV_TINYUSB2_WARM 0x3224
70#define USB_PID_ULTIMA_TVBOX_COLD 0x8105 72#define USB_PID_ULTIMA_TVBOX_COLD 0x8105
71#define USB_PID_ULTIMA_TVBOX_WARM 0x8106 73#define USB_PID_ULTIMA_TVBOX_WARM 0x8106
72#define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107 74#define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107
73#define USB_PID_ULTIMA_TVBOX_AN2235_WARM 0x8108 75#define USB_PID_ULTIMA_TVBOX_AN2235_WARM 0x8108
74#define USB_PID_ULTIMA_TVBOX_ANCHOR_COLD 0x2235 76#define USB_PID_ULTIMA_TVBOX_ANCHOR_COLD 0x2235
75#define USB_PID_ULTIMA_TVBOX_USB2_COLD 0x8109 77#define USB_PID_ULTIMA_TVBOX_USB2_COLD 0x8109
76#define USB_PID_ULTIMA_TVBOX_USB2_WARM 0x810a 78#define USB_PID_ULTIMA_TVBOX_USB2_WARM 0x810a
77#define USB_PID_ULTIMA_TVBOX_USB2_FX_COLD 0x8613 79#define USB_PID_ARTEC_T14_COLD 0x810b
78#define USB_PID_ULTIMA_TVBOX_USB2_FX_WARM 0x1002 80#define USB_PID_ARTEC_T14_WARM 0x810c
79#define USB_PID_UNK_HYPER_PALTEK_COLD 0x005e 81#define USB_PID_ULTIMA_TVBOX_USB2_FX_COLD 0x8613
80#define USB_PID_UNK_HYPER_PALTEK_WARM 0x005f 82#define USB_PID_ULTIMA_TVBOX_USB2_FX_WARM 0x1002
81#define USB_PID_HANFTEK_UMT_010_COLD 0x0001 83#define USB_PID_UNK_HYPER_PALTEK_COLD 0x005e
82#define USB_PID_HANFTEK_UMT_010_WARM 0x0015 84#define USB_PID_UNK_HYPER_PALTEK_WARM 0x005f
85#define USB_PID_HANFTEK_UMT_010_COLD 0x0001
86#define USB_PID_HANFTEK_UMT_010_WARM 0x0015
83#define USB_PID_DTT200U_COLD 0x0201 87#define USB_PID_DTT200U_COLD 0x0201
84#define USB_PID_DTT200U_WARM 0x0301 88#define USB_PID_DTT200U_WARM 0x0301
85#define USB_PID_WT220U_COLD 0x0222 89#define USB_PID_WT220U_ZAP250_COLD 0x0220
86#define USB_PID_WT220U_WARM 0x0221 90#define USB_PID_WT220U_COLD 0x0222
91#define USB_PID_WT220U_WARM 0x0221
92#define USB_PID_WT220U_FC_COLD 0x0225
93#define USB_PID_WT220U_FC_WARM 0x0226
87#define USB_PID_WT220U_ZL0353_COLD 0x022a 94#define USB_PID_WT220U_ZL0353_COLD 0x022a
88#define USB_PID_WT220U_ZL0353_WARM 0x022b 95#define USB_PID_WT220U_ZL0353_WARM 0x022b
89#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300 96#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300
90#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 97#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301
91#define USB_PID_NEBULA_DIGITV 0x0201 98#define USB_PID_NEBULA_DIGITV 0x0201
92#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 99#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820
93#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 100#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500
@@ -103,8 +110,17 @@
103#define USB_PID_MEDION_MD95700 0x0932 110#define USB_PID_MEDION_MD95700 0x0932
104#define USB_PID_KYE_DVB_T_COLD 0x701e 111#define USB_PID_KYE_DVB_T_COLD 0x701e
105#define USB_PID_KYE_DVB_T_WARM 0x701f 112#define USB_PID_KYE_DVB_T_WARM 0x701f
106#define USB_PID_PCTV_200E 0x020e 113#define USB_PID_PCTV_200E 0x020e
107#define USB_PID_PCTV_400E 0x020f 114#define USB_PID_PCTV_400E 0x020f
108#define USB_PID_GENPIX_8PSK_COLD 0x0200 115#define USB_PID_LITEON_DVB_T_COLD 0xf000
109#define USB_PID_GENPIX_8PSK_WARM 0x0201 116#define USB_PID_LITEON_DVB_T_WARM 0xf001
117#define USB_PID_DIGIVOX_MINI_SL_COLD 0xe360
118#define USB_PID_DIGIVOX_MINI_SL_WARM 0xe361
119#define USB_PID_GRANDTEC_DVBT_USB2_COLD 0x0bc6
120#define USB_PID_GRANDTEC_DVBT_USB2_WARM 0x0bc7
121#define USB_PID_WINFAST_DTV_DONGLE_COLD 0x6025
122#define USB_PID_WINFAST_DTV_DONGLE_WARM 0x6026
123#define USB_PID_GENPIX_8PSK_COLD 0x0200
124#define USB_PID_GENPIX_8PSK_WARM 0x0201
125
110#endif 126#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index e5c6d9835e06..380b2a45ee4c 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -6,6 +6,7 @@
6 * This file contains functions for initializing the the input-device and for handling remote-control-queries. 6 * This file contains functions for initializing the the input-device and for handling remote-control-queries.
7 */ 7 */
8#include "dvb-usb-common.h" 8#include "dvb-usb-common.h"
9#include <linux/usb/input.h>
9 10
10/* Remote-control poll function - called every dib->rc_query_interval ms to see 11/* Remote-control poll function - called every dib->rc_query_interval ms to see
11 * whether the remote control has received anything. 12 * whether the remote control has received anything.
@@ -96,7 +97,7 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
96 return 0; 97 return 0;
97 98
98 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); 99 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
99 strlcpy(d->rc_phys, "/ir0", sizeof(d->rc_phys)); 100 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
100 101
101 d->rc_input_dev = input_allocate_device(); 102 d->rc_input_dev = input_allocate_device();
102 if (!d->rc_input_dev) 103 if (!d->rc_input_dev)
@@ -107,6 +108,8 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
107 d->rc_input_dev->keycodemax = KEY_MAX; 108 d->rc_input_dev->keycodemax = KEY_MAX;
108 d->rc_input_dev->name = "IR-receiver inside an USB DVB receiver"; 109 d->rc_input_dev->name = "IR-receiver inside an USB DVB receiver";
109 d->rc_input_dev->phys = d->rc_phys; 110 d->rc_input_dev->phys = d->rc_phys;
111 usb_to_input_id(d->udev, &d->rc_input_dev->id);
112 d->rc_input_dev->cdev.dev = &d->udev->dev;
110 113
111 /* set the bits for the keys */ 114 /* set the bits for the keys */
112 deb_rc("key map size: %d\n", d->props.rc_key_map_size); 115 deb_rc("key map size: %d\n", d->props.rc_key_map_size);
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index 412039d8dbae..79f0a02ce987 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -156,7 +156,7 @@ static struct dvb_usb_properties nova_t_properties = {
156 .pid_filter_count = 32, 156 .pid_filter_count = 32,
157 157
158 .usb_ctrl = CYPRESS_FX2, 158 .usb_ctrl = CYPRESS_FX2,
159 .firmware = "dvb-usb-nova-t-usb2-01.fw", 159 .firmware = "dvb-usb-nova-t-usb2-02.fw",
160 160
161 .size_of_priv = sizeof(struct dibusb_state), 161 .size_of_priv = sizeof(struct dibusb_state),
162 162
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c
index 97d74da0dad8..418a0b707151 100644
--- a/drivers/media/dvb/dvb-usb/umt-010.c
+++ b/drivers/media/dvb/dvb-usb/umt-010.c
@@ -58,7 +58,7 @@ static int umt_mt352_frontend_attach(struct dvb_usb_device *d)
58 umt_config.demod_init = umt_mt352_demod_init; 58 umt_config.demod_init = umt_mt352_demod_init;
59 umt_config.demod_address = 0xf; 59 umt_config.demod_address = 0xf;
60 60
61 d->fe = mt352_attach(&umt_config, &d->i2c_adap); 61 d->fe = dvb_attach(mt352_attach, &umt_config, &d->i2c_adap);
62 62
63 return 0; 63 return 0;
64} 64}
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index db978555b1eb..080fa257a0bc 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -1,48 +1,73 @@
1menu "Customise DVB Frontends" 1menu "Customise DVB Frontends"
2 depends on DVB_CORE 2 depends on DVB_CORE
3 3
4config DVB_FE_CUSTOMISE
5 bool "Customise the frontend modules to build"
6 default N
7 help
8 This allows the user to deselect frontend drivers unnecessary
9 for their hardware from the build. Use this option with care
10 as deselecting frontends which are in fact necessary will result
11 in DVB devices which cannot be tuned due to lack of driver support.
12
13 If unsure say N.
14
4comment "DVB-S (satellite) frontends" 15comment "DVB-S (satellite) frontends"
5 depends on DVB_CORE 16 depends on DVB_CORE
6 17
7config DVB_STV0299 18config DVB_STV0299
8 tristate "ST STV0299 based" 19 tristate "ST STV0299 based"
9 depends on DVB_CORE && I2C 20 depends on DVB_CORE && I2C
21 default m if DVB_FE_CUSTOMISE
10 help 22 help
11 A DVB-S tuner module. Say Y when you want to support this frontend. 23 A DVB-S tuner module. Say Y when you want to support this frontend.
12 24
13config DVB_CX24110 25config DVB_CX24110
14 tristate "Conexant CX24110 based" 26 tristate "Conexant CX24110 based"
15 depends on DVB_CORE && I2C 27 depends on DVB_CORE && I2C
28 default m if DVB_FE_CUSTOMISE
16 help 29 help
17 A DVB-S tuner module. Say Y when you want to support this frontend. 30 A DVB-S tuner module. Say Y when you want to support this frontend.
18 31
19config DVB_CX24123 32config DVB_CX24123
20 tristate "Conexant CX24123 based" 33 tristate "Conexant CX24123 based"
21 depends on DVB_CORE && I2C 34 depends on DVB_CORE && I2C
35 default m if DVB_FE_CUSTOMISE
22 help 36 help
23 A DVB-S tuner module. Say Y when you want to support this frontend. 37 A DVB-S tuner module. Say Y when you want to support this frontend.
24 38
25config DVB_TDA8083 39config DVB_TDA8083
26 tristate "Philips TDA8083 based" 40 tristate "Philips TDA8083 based"
27 depends on DVB_CORE && I2C 41 depends on DVB_CORE && I2C
42 default m if DVB_FE_CUSTOMISE
28 help 43 help
29 A DVB-S tuner module. Say Y when you want to support this frontend. 44 A DVB-S tuner module. Say Y when you want to support this frontend.
30 45
31config DVB_MT312 46config DVB_MT312
32 tristate "Zarlink VP310/MT312 based" 47 tristate "Zarlink VP310/MT312 based"
33 depends on DVB_CORE && I2C 48 depends on DVB_CORE && I2C
49 default m if DVB_FE_CUSTOMISE
34 help 50 help
35 A DVB-S tuner module. Say Y when you want to support this frontend. 51 A DVB-S tuner module. Say Y when you want to support this frontend.
36 52
37config DVB_VES1X93 53config DVB_VES1X93
38 tristate "VLSI VES1893 or VES1993 based" 54 tristate "VLSI VES1893 or VES1993 based"
39 depends on DVB_CORE && I2C 55 depends on DVB_CORE && I2C
56 default m if DVB_FE_CUSTOMISE
40 help 57 help
41 A DVB-S tuner module. Say Y when you want to support this frontend. 58 A DVB-S tuner module. Say Y when you want to support this frontend.
42 59
43config DVB_S5H1420 60config DVB_S5H1420
44 tristate "Samsung S5H1420 based" 61 tristate "Samsung S5H1420 based"
45 depends on DVB_CORE && I2C 62 depends on DVB_CORE && I2C
63 default m if DVB_FE_CUSTOMISE
64 help
65 A DVB-S tuner module. Say Y when you want to support this frontend.
66
67config DVB_TDA10086
68 tristate "Philips TDA10086 based"
69 depends on DVB_CORE && I2C
70 default m if DVB_FE_CUSTOMISE
46 help 71 help
47 A DVB-S tuner module. Say Y when you want to support this frontend. 72 A DVB-S tuner module. Say Y when you want to support this frontend.
48 73
@@ -52,6 +77,7 @@ comment "DVB-T (terrestrial) frontends"
52config DVB_SP8870 77config DVB_SP8870
53 tristate "Spase sp8870 based" 78 tristate "Spase sp8870 based"
54 depends on DVB_CORE && I2C 79 depends on DVB_CORE && I2C
80 default m if DVB_FE_CUSTOMISE
55 select FW_LOADER 81 select FW_LOADER
56 help 82 help
57 A DVB-T tuner module. Say Y when you want to support this frontend. 83 A DVB-T tuner module. Say Y when you want to support this frontend.
@@ -64,6 +90,7 @@ config DVB_SP8870
64config DVB_SP887X 90config DVB_SP887X
65 tristate "Spase sp887x based" 91 tristate "Spase sp887x based"
66 depends on DVB_CORE && I2C 92 depends on DVB_CORE && I2C
93 default m if DVB_FE_CUSTOMISE
67 select FW_LOADER 94 select FW_LOADER
68 help 95 help
69 A DVB-T tuner module. Say Y when you want to support this frontend. 96 A DVB-T tuner module. Say Y when you want to support this frontend.
@@ -76,24 +103,28 @@ config DVB_SP887X
76config DVB_CX22700 103config DVB_CX22700
77 tristate "Conexant CX22700 based" 104 tristate "Conexant CX22700 based"
78 depends on DVB_CORE && I2C 105 depends on DVB_CORE && I2C
106 default m if DVB_FE_CUSTOMISE
79 help 107 help
80 A DVB-T tuner module. Say Y when you want to support this frontend. 108 A DVB-T tuner module. Say Y when you want to support this frontend.
81 109
82config DVB_CX22702 110config DVB_CX22702
83 tristate "Conexant cx22702 demodulator (OFDM)" 111 tristate "Conexant cx22702 demodulator (OFDM)"
84 depends on DVB_CORE && I2C 112 depends on DVB_CORE && I2C
113 default m if DVB_FE_CUSTOMISE
85 help 114 help
86 A DVB-T tuner module. Say Y when you want to support this frontend. 115 A DVB-T tuner module. Say Y when you want to support this frontend.
87 116
88config DVB_L64781 117config DVB_L64781
89 tristate "LSI L64781" 118 tristate "LSI L64781"
90 depends on DVB_CORE && I2C 119 depends on DVB_CORE && I2C
120 default m if DVB_FE_CUSTOMISE
91 help 121 help
92 A DVB-T tuner module. Say Y when you want to support this frontend. 122 A DVB-T tuner module. Say Y when you want to support this frontend.
93 123
94config DVB_TDA1004X 124config DVB_TDA1004X
95 tristate "Philips TDA10045H/TDA10046H based" 125 tristate "Philips TDA10045H/TDA10046H based"
96 depends on DVB_CORE && I2C 126 depends on DVB_CORE && I2C
127 default m if DVB_FE_CUSTOMISE
97 select FW_LOADER 128 select FW_LOADER
98 help 129 help
99 A DVB-T tuner module. Say Y when you want to support this frontend. 130 A DVB-T tuner module. Say Y when you want to support this frontend.
@@ -107,24 +138,28 @@ config DVB_TDA1004X
107config DVB_NXT6000 138config DVB_NXT6000
108 tristate "NxtWave Communications NXT6000 based" 139 tristate "NxtWave Communications NXT6000 based"
109 depends on DVB_CORE && I2C 140 depends on DVB_CORE && I2C
141 default m if DVB_FE_CUSTOMISE
110 help 142 help
111 A DVB-T tuner module. Say Y when you want to support this frontend. 143 A DVB-T tuner module. Say Y when you want to support this frontend.
112 144
113config DVB_MT352 145config DVB_MT352
114 tristate "Zarlink MT352 based" 146 tristate "Zarlink MT352 based"
115 depends on DVB_CORE && I2C 147 depends on DVB_CORE && I2C
148 default m if DVB_FE_CUSTOMISE
116 help 149 help
117 A DVB-T tuner module. Say Y when you want to support this frontend. 150 A DVB-T tuner module. Say Y when you want to support this frontend.
118 151
119config DVB_ZL10353 152config DVB_ZL10353
120 tristate "Zarlink ZL10353 based" 153 tristate "Zarlink ZL10353 based"
121 depends on DVB_CORE && I2C 154 depends on DVB_CORE && I2C
155 default m if DVB_FE_CUSTOMISE
122 help 156 help
123 A DVB-T tuner module. Say Y when you want to support this frontend. 157 A DVB-T tuner module. Say Y when you want to support this frontend.
124 158
125config DVB_DIB3000MB 159config DVB_DIB3000MB
126 tristate "DiBcom 3000M-B" 160 tristate "DiBcom 3000M-B"
127 depends on DVB_CORE && I2C 161 depends on DVB_CORE && I2C
162 default m if DVB_FE_CUSTOMISE
128 help 163 help
129 A DVB-T tuner module. Designed for mobile usage. Say Y when you want 164 A DVB-T tuner module. Designed for mobile usage. Say Y when you want
130 to support this frontend. 165 to support this frontend.
@@ -132,6 +167,7 @@ config DVB_DIB3000MB
132config DVB_DIB3000MC 167config DVB_DIB3000MC
133 tristate "DiBcom 3000P/M-C" 168 tristate "DiBcom 3000P/M-C"
134 depends on DVB_CORE && I2C 169 depends on DVB_CORE && I2C
170 default m if DVB_FE_CUSTOMISE
135 help 171 help
136 A DVB-T tuner module. Designed for mobile usage. Say Y when you want 172 A DVB-T tuner module. Designed for mobile usage. Say Y when you want
137 to support this frontend. 173 to support this frontend.
@@ -142,18 +178,21 @@ comment "DVB-C (cable) frontends"
142config DVB_VES1820 178config DVB_VES1820
143 tristate "VLSI VES1820 based" 179 tristate "VLSI VES1820 based"
144 depends on DVB_CORE && I2C 180 depends on DVB_CORE && I2C
181 default m if DVB_FE_CUSTOMISE
145 help 182 help
146 A DVB-C tuner module. Say Y when you want to support this frontend. 183 A DVB-C tuner module. Say Y when you want to support this frontend.
147 184
148config DVB_TDA10021 185config DVB_TDA10021
149 tristate "Philips TDA10021 based" 186 tristate "Philips TDA10021 based"
150 depends on DVB_CORE && I2C 187 depends on DVB_CORE && I2C
188 default m if DVB_FE_CUSTOMISE
151 help 189 help
152 A DVB-C tuner module. Say Y when you want to support this frontend. 190 A DVB-C tuner module. Say Y when you want to support this frontend.
153 191
154config DVB_STV0297 192config DVB_STV0297
155 tristate "ST STV0297 based" 193 tristate "ST STV0297 based"
156 depends on DVB_CORE && I2C 194 depends on DVB_CORE && I2C
195 default m if DVB_FE_CUSTOMISE
157 help 196 help
158 A DVB-C tuner module. Say Y when you want to support this frontend. 197 A DVB-C tuner module. Say Y when you want to support this frontend.
159 198
@@ -163,6 +202,7 @@ comment "ATSC (North American/Korean Terrestrial/Cable DTV) frontends"
163config DVB_NXT200X 202config DVB_NXT200X
164 tristate "NxtWave Communications NXT2002/NXT2004 based" 203 tristate "NxtWave Communications NXT2002/NXT2004 based"
165 depends on DVB_CORE && I2C 204 depends on DVB_CORE && I2C
205 default m if DVB_FE_CUSTOMISE
166 select FW_LOADER 206 select FW_LOADER
167 help 207 help
168 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 208 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
@@ -177,6 +217,7 @@ config DVB_NXT200X
177config DVB_OR51211 217config DVB_OR51211
178 tristate "Oren OR51211 based" 218 tristate "Oren OR51211 based"
179 depends on DVB_CORE && I2C 219 depends on DVB_CORE && I2C
220 default m if DVB_FE_CUSTOMISE
180 select FW_LOADER 221 select FW_LOADER
181 help 222 help
182 An ATSC 8VSB tuner module. Say Y when you want to support this frontend. 223 An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
@@ -189,6 +230,7 @@ config DVB_OR51211
189config DVB_OR51132 230config DVB_OR51132
190 tristate "Oren OR51132 based" 231 tristate "Oren OR51132 based"
191 depends on DVB_CORE && I2C 232 depends on DVB_CORE && I2C
233 default m if DVB_FE_CUSTOMISE
192 select FW_LOADER 234 select FW_LOADER
193 help 235 help
194 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 236 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
@@ -204,6 +246,7 @@ config DVB_OR51132
204config DVB_BCM3510 246config DVB_BCM3510
205 tristate "Broadcom BCM3510" 247 tristate "Broadcom BCM3510"
206 depends on DVB_CORE && I2C 248 depends on DVB_CORE && I2C
249 default m if DVB_FE_CUSTOMISE
207 select FW_LOADER 250 select FW_LOADER
208 help 251 help
209 An ATSC 8VSB/16VSB and QAM64/256 tuner module. Say Y when you want to 252 An ATSC 8VSB/16VSB and QAM64/256 tuner module. Say Y when you want to
@@ -212,28 +255,52 @@ config DVB_BCM3510
212config DVB_LGDT330X 255config DVB_LGDT330X
213 tristate "LG Electronics LGDT3302/LGDT3303 based" 256 tristate "LG Electronics LGDT3302/LGDT3303 based"
214 depends on DVB_CORE && I2C 257 depends on DVB_CORE && I2C
258 default m if DVB_FE_CUSTOMISE
215 help 259 help
216 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 260 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
217 to support this frontend. 261 to support this frontend.
218 262
219 263comment "Tuners/PLL support"
220comment "Miscellaneous devices"
221 depends on DVB_CORE 264 depends on DVB_CORE
222 265
223config DVB_PLL 266config DVB_PLL
224 tristate 267 tristate
225 depends on DVB_CORE && I2C 268 depends on DVB_CORE && I2C
226 269
270config DVB_TDA826X
271 tristate "Philips TDA826X silicon tuner"
272 depends on DVB_CORE && I2C
273 default m if DVB_FE_CUSTOMISE
274 help
275 A DVB-S silicon tuner module. Say Y when you want to support this tuner.
276
277config DVB_TUNER_MT2060
278 tristate "Microtune MT2060 silicon IF tuner"
279 help
280 A driver for the silicon IF tuner MT2060 from Microtune.
281
282comment "Miscellaneous devices"
283 depends on DVB_CORE
284
227config DVB_LNBP21 285config DVB_LNBP21
228 tristate "LNBP21 SEC controller" 286 tristate "LNBP21 SEC controller"
229 depends on DVB_CORE && I2C 287 depends on DVB_CORE && I2C
288 default m if DVB_FE_CUSTOMISE
230 help 289 help
231 An SEC control chip. 290 An SEC control chip.
232 291
233config DVB_ISL6421 292config DVB_ISL6421
234 tristate "ISL6421 SEC controller" 293 tristate "ISL6421 SEC controller"
235 depends on DVB_CORE && I2C 294 depends on DVB_CORE && I2C
295 default m if DVB_FE_CUSTOMISE
236 help 296 help
237 An SEC control chip. 297 An SEC control chip.
238 298
299config DVB_TUA6100
300 tristate "TUA6100 PLL"
301 depends on DVB_CORE && I2C
302 default m if DVB_FE_CUSTOMISE
303 help
304 A DVBS PLL chip.
305
239endmenu 306endmenu
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index 0e4880b6db14..dce9cf0c75c0 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -11,8 +11,8 @@ obj-$(CONFIG_DVB_CX22700) += cx22700.o
11obj-$(CONFIG_DVB_CX24110) += cx24110.o 11obj-$(CONFIG_DVB_CX24110) += cx24110.o
12obj-$(CONFIG_DVB_TDA8083) += tda8083.o 12obj-$(CONFIG_DVB_TDA8083) += tda8083.o
13obj-$(CONFIG_DVB_L64781) += l64781.o 13obj-$(CONFIG_DVB_L64781) += l64781.o
14obj-$(CONFIG_DVB_DIB3000MB) += dib3000mb.o dib3000-common.o 14obj-$(CONFIG_DVB_DIB3000MB) += dib3000mb.o
15obj-$(CONFIG_DVB_DIB3000MC) += dib3000mc.o dib3000-common.o 15obj-$(CONFIG_DVB_DIB3000MC) += dib3000mc.o dibx000_common.o
16obj-$(CONFIG_DVB_MT312) += mt312.o 16obj-$(CONFIG_DVB_MT312) += mt312.o
17obj-$(CONFIG_DVB_VES1820) += ves1820.o 17obj-$(CONFIG_DVB_VES1820) += ves1820.o
18obj-$(CONFIG_DVB_VES1X93) += ves1x93.o 18obj-$(CONFIG_DVB_VES1X93) += ves1x93.o
@@ -33,3 +33,7 @@ obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o
33obj-$(CONFIG_DVB_CX24123) += cx24123.o 33obj-$(CONFIG_DVB_CX24123) += cx24123.o
34obj-$(CONFIG_DVB_LNBP21) += lnbp21.o 34obj-$(CONFIG_DVB_LNBP21) += lnbp21.o
35obj-$(CONFIG_DVB_ISL6421) += isl6421.o 35obj-$(CONFIG_DVB_ISL6421) += isl6421.o
36obj-$(CONFIG_DVB_TDA10086) += tda10086.o
37obj-$(CONFIG_DVB_TDA826X) += tda826x.o
38obj-$(CONFIG_DVB_TUNER_MT2060) += mt2060.o
39obj-$(CONFIG_DVB_TUA6100) += tua6100.o
diff --git a/drivers/media/dvb/frontends/bcm3510.h b/drivers/media/dvb/frontends/bcm3510.h
index 80f5d0953d02..6dfa839a7022 100644
--- a/drivers/media/dvb/frontends/bcm3510.h
+++ b/drivers/media/dvb/frontends/bcm3510.h
@@ -34,7 +34,16 @@ struct bcm3510_config
34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
35}; 35};
36 36
37#if defined(CONFIG_DVB_BCM3510) || defined(CONFIG_DVB_BCM3510_MODULE)
37extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config, 38extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config,
38 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else
41static inline struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config,
42 struct i2c_adapter* i2c)
43{
44 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
45 return NULL;
46}
47#endif // CONFIG_DVB_BCM3510
39 48
40#endif 49#endif
diff --git a/drivers/media/dvb/frontends/cx22700.h b/drivers/media/dvb/frontends/cx22700.h
index dcd8979c1a15..10286cc29fb4 100644
--- a/drivers/media/dvb/frontends/cx22700.h
+++ b/drivers/media/dvb/frontends/cx22700.h
@@ -31,7 +31,16 @@ struct cx22700_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34#if defined(CONFIG_DVB_CX22700) || defined(CONFIG_DVB_CX22700_MODULE)
34extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, 35extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
35 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else
38static inline struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
39 struct i2c_adapter* i2c)
40{
41 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
42 return NULL;
43}
44#endif // CONFIG_DVB_CX22700
36 45
37#endif // CX22700_H 46#endif // CX22700_H
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 4106d46c957f..335219ebce2d 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -399,7 +399,9 @@ static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
399{ 399{
400 struct cx22702_state* state = fe->demodulator_priv; 400 struct cx22702_state* state = fe->demodulator_priv;
401 401
402 *signal_strength = cx22702_readreg (state, 0x23); 402 u16 rs_ber = 0;
403 rs_ber = cx22702_readreg (state, 0x23);
404 *signal_strength = (rs_ber << 8) | rs_ber;
403 405
404 return 0; 406 return 0;
405} 407}
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 7f2f241e5d44..bc217ddf02c0 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -41,7 +41,16 @@ struct cx22702_config
41 u8 output_mode; 41 u8 output_mode;
42}; 42};
43 43
44#if defined(CONFIG_DVB_CX22702) || defined(CONFIG_DVB_CX22702_MODULE)
44extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 45extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
45 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
47#else
48static inline struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
49 struct i2c_adapter* i2c)
50{
51 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
52 return NULL;
53}
54#endif // CONFIG_DVB_CX22702
46 55
47#endif // CX22702_H 56#endif // CX22702_H
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
index ce3c7398bac9..ae96395217a2 100644
--- a/drivers/media/dvb/frontends/cx24110.c
+++ b/drivers/media/dvb/frontends/cx24110.c
@@ -1,4 +1,4 @@
1/* 1 /*
2 cx24110 - Single Chip Satellite Channel Receiver driver module 2 cx24110 - Single Chip Satellite Channel Receiver driver module
3 3
4 Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on 4 Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on
@@ -311,16 +311,17 @@ static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate)
311 311
312} 312}
313 313
314int cx24110_pll_write (struct dvb_frontend* fe, u32 data) 314static int _cx24110_pll_write (struct dvb_frontend* fe, u8 *buf, int len)
315{ 315{
316 struct cx24110_state *state = fe->demodulator_priv; 316 struct cx24110_state *state = fe->demodulator_priv;
317 317
318 if (len != 3)
319 return -EINVAL;
320
318/* tuner data is 21 bits long, must be left-aligned in data */ 321/* tuner data is 21 bits long, must be left-aligned in data */
319/* tuner cx24108 is written through a dedicated 3wire interface on the demod chip */ 322/* tuner cx24108 is written through a dedicated 3wire interface on the demod chip */
320/* FIXME (low): add error handling, avoid infinite loops if HW fails... */ 323/* FIXME (low): add error handling, avoid infinite loops if HW fails... */
321 324
322 dprintk("cx24110 debug: cx24108_write(%8.8x)\n",data);
323
324 cx24110_writereg(state,0x6d,0x30); /* auto mode at 62kHz */ 325 cx24110_writereg(state,0x6d,0x30); /* auto mode at 62kHz */
325 cx24110_writereg(state,0x70,0x15); /* auto mode 21 bits */ 326 cx24110_writereg(state,0x70,0x15); /* auto mode 21 bits */
326 327
@@ -329,19 +330,19 @@ int cx24110_pll_write (struct dvb_frontend* fe, u32 data)
329 cx24110_writereg(state,0x72,0); 330 cx24110_writereg(state,0x72,0);
330 331
331 /* write the topmost 8 bits */ 332 /* write the topmost 8 bits */
332 cx24110_writereg(state,0x72,(data>>24)&0xff); 333 cx24110_writereg(state,0x72,buf[0]);
333 334
334 /* wait for the send to be completed */ 335 /* wait for the send to be completed */
335 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) 336 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
336 ; 337 ;
337 338
338 /* send another 8 bytes */ 339 /* send another 8 bytes */
339 cx24110_writereg(state,0x72,(data>>16)&0xff); 340 cx24110_writereg(state,0x72,buf[1]);
340 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) 341 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
341 ; 342 ;
342 343
343 /* and the topmost 5 bits of this byte */ 344 /* and the topmost 5 bits of this byte */
344 cx24110_writereg(state,0x72,(data>>8)&0xff); 345 cx24110_writereg(state,0x72,buf[2]);
345 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) 346 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
346 ; 347 ;
347 348
@@ -642,6 +643,7 @@ static struct dvb_frontend_ops cx24110_ops = {
642 .release = cx24110_release, 643 .release = cx24110_release,
643 644
644 .init = cx24110_initfe, 645 .init = cx24110_initfe,
646 .write = _cx24110_pll_write,
645 .set_frontend = cx24110_set_frontend, 647 .set_frontend = cx24110_set_frontend,
646 .get_frontend = cx24110_get_frontend, 648 .get_frontend = cx24110_get_frontend,
647 .read_status = cx24110_read_status, 649 .read_status = cx24110_read_status,
@@ -664,4 +666,3 @@ MODULE_AUTHOR("Peter Hettkamp");
664MODULE_LICENSE("GPL"); 666MODULE_LICENSE("GPL");
665 667
666EXPORT_SYMBOL(cx24110_attach); 668EXPORT_SYMBOL(cx24110_attach);
667EXPORT_SYMBOL(cx24110_pll_write);
diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h
index b354a64e0e74..c9d5ae250ebb 100644
--- a/drivers/media/dvb/frontends/cx24110.h
+++ b/drivers/media/dvb/frontends/cx24110.h
@@ -33,9 +33,24 @@ struct cx24110_config
33 u8 demod_address; 33 u8 demod_address;
34}; 34};
35 35
36static inline int cx24110_pll_write(struct dvb_frontend *fe, u32 val) {
37 int r = 0;
38 u8 buf[] = {(u8) (val>>24), (u8) (val>>16), (u8) (val>>8)};
39 if (fe->ops.write)
40 r = fe->ops.write(fe, buf, 3);
41 return r;
42}
43
44#if defined(CONFIG_DVB_CX24110) || defined(CONFIG_DVB_CX24110_MODULE)
36extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, 45extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
37 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
38 47#else
39extern int cx24110_pll_write(struct dvb_frontend* fe, u32 data); 48static inline struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
49 struct i2c_adapter* i2c)
50{
51 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
52 return NULL;
53}
54#endif // CONFIG_DVB_CX24110
40 55
41#endif // CX24110_H 56#endif // CX24110_H
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index 274a87b7a5d5..62d69a6ea699 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -45,9 +45,6 @@ struct cx24123_state
45 45
46 struct dvb_frontend frontend; 46 struct dvb_frontend frontend;
47 47
48 u32 lastber;
49 u16 snr;
50
51 /* Some PLL specifics for tuning */ 48 /* Some PLL specifics for tuning */
52 u32 VCAarg; 49 u32 VCAarg;
53 u32 VGAarg; 50 u32 VGAarg;
@@ -194,7 +191,7 @@ static struct {
194 {0x06, 0x31}, /* MPEG (default) */ 191 {0x06, 0x31}, /* MPEG (default) */
195 {0x0b, 0x00}, /* Freq search start point (default) */ 192 {0x0b, 0x00}, /* Freq search start point (default) */
196 {0x0c, 0x00}, /* Demodulator sample gain (default) */ 193 {0x0c, 0x00}, /* Demodulator sample gain (default) */
197 {0x0d, 0x02}, /* Frequency search range = Fsymbol / 4 (default) */ 194 {0x0d, 0x7f}, /* Force driver to shift until the maximum (+-10 MHz) */
198 {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */ 195 {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */
199 {0x0f, 0xfe}, /* FEC search mask (all supported codes) */ 196 {0x0f, 0xfe}, /* FEC search mask (all supported codes) */
200 {0x10, 0x01}, /* Default search inversion, no repeat (default) */ 197 {0x10, 0x01}, /* Default search inversion, no repeat (default) */
@@ -223,8 +220,9 @@ static struct {
223 {0x44, 0x00}, /* Constellation (default) */ 220 {0x44, 0x00}, /* Constellation (default) */
224 {0x45, 0x00}, /* Symbol count (default) */ 221 {0x45, 0x00}, /* Symbol count (default) */
225 {0x46, 0x0d}, /* Symbol rate estimator on (default) */ 222 {0x46, 0x0d}, /* Symbol rate estimator on (default) */
226 {0x56, 0x41}, /* Various (default) */ 223 {0x56, 0xc1}, /* Error Counter = Viterbi BER */
227 {0x57, 0xff}, /* Error Counter Window (default) */ 224 {0x57, 0xff}, /* Error Counter Window (default) */
225 {0x5c, 0x20}, /* Acquisition AFC Expiration window (default is 0x10) */
228 {0x67, 0x83}, /* Non-DCII symbol clock */ 226 {0x67, 0x83}, /* Non-DCII symbol clock */
229}; 227};
230 228
@@ -321,6 +319,12 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)
321 if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) 319 if ( (fec < FEC_NONE) || (fec > FEC_AUTO) )
322 fec = FEC_AUTO; 320 fec = FEC_AUTO;
323 321
322 /* Set the soft decision threshold */
323 if(fec == FEC_1_2)
324 cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01);
325 else
326 cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01);
327
324 switch (fec) { 328 switch (fec) {
325 case FEC_1_2: 329 case FEC_1_2:
326 dprintk("%s: set FEC to 1/2\n",__FUNCTION__); 330 dprintk("%s: set FEC to 1/2\n",__FUNCTION__);
@@ -657,6 +661,10 @@ static int cx24123_initfe(struct dvb_frontend* fe)
657 for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++) 661 for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++)
658 cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); 662 cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data);
659 663
664 /* Set the LNB polarity */
665 if(state->config->lnb_polarity)
666 cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02);
667
660 return 0; 668 return 0;
661} 669}
662 670
@@ -674,6 +682,9 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage
674 case SEC_VOLTAGE_18: 682 case SEC_VOLTAGE_18:
675 dprintk("%s: setting voltage 18V\n", __FUNCTION__); 683 dprintk("%s: setting voltage 18V\n", __FUNCTION__);
676 return cx24123_writereg(state, 0x29, val | 0x80); 684 return cx24123_writereg(state, 0x29, val | 0x80);
685 case SEC_VOLTAGE_OFF:
686 /* already handled in cx88-dvb */
687 return 0;
677 default: 688 default:
678 return -EINVAL; 689 return -EINVAL;
679 }; 690 };
@@ -776,13 +787,15 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)
776 if (lock & 0x01) 787 if (lock & 0x01)
777 *status |= FE_HAS_SIGNAL; 788 *status |= FE_HAS_SIGNAL;
778 if (sync & 0x02) 789 if (sync & 0x02)
779 *status |= FE_HAS_CARRIER; 790 *status |= FE_HAS_CARRIER; /* Phase locked */
780 if (sync & 0x04) 791 if (sync & 0x04)
781 *status |= FE_HAS_VITERBI; 792 *status |= FE_HAS_VITERBI;
793
794 /* Reed-Solomon Status */
782 if (sync & 0x08) 795 if (sync & 0x08)
783 *status |= FE_HAS_SYNC; 796 *status |= FE_HAS_SYNC;
784 if (sync & 0x80) 797 if (sync & 0x80)
785 *status |= FE_HAS_LOCK; 798 *status |= FE_HAS_LOCK; /*Full Sync */
786 799
787 return 0; 800 return 0;
788} 801}
@@ -795,29 +808,13 @@ static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber)
795{ 808{
796 struct cx24123_state *state = fe->demodulator_priv; 809 struct cx24123_state *state = fe->demodulator_priv;
797 810
798 state->lastber = 811 /* The true bit error rate is this value divided by
799 ((cx24123_readreg(state, 0x1c) & 0x3f) << 16) | 812 the window size (set as 256 * 255) */
813 *ber = ((cx24123_readreg(state, 0x1c) & 0x3f) << 16) |
800 (cx24123_readreg(state, 0x1d) << 8 | 814 (cx24123_readreg(state, 0x1d) << 8 |
801 cx24123_readreg(state, 0x1e)); 815 cx24123_readreg(state, 0x1e));
802
803 /* Do the signal quality processing here, it's derived from the BER. */
804 /* Scale the BER from a 24bit to a SNR 16 bit where higher = better */
805 if (state->lastber < 5000)
806 state->snr = 655*100;
807 else if ( (state->lastber >= 5000) && (state->lastber < 55000) )
808 state->snr = 655*90;
809 else if ( (state->lastber >= 55000) && (state->lastber < 150000) )
810 state->snr = 655*80;
811 else if ( (state->lastber >= 150000) && (state->lastber < 250000) )
812 state->snr = 655*70;
813 else if ( (state->lastber >= 250000) && (state->lastber < 450000) )
814 state->snr = 655*65;
815 else
816 state->snr = 0;
817
818 dprintk("%s: BER = %d, S/N index = %d\n",__FUNCTION__,state->lastber, state->snr);
819 816
820 *ber = state->lastber; 817 dprintk("%s: BER = %d\n",__FUNCTION__,*ber);
821 818
822 return 0; 819 return 0;
823} 820}
@@ -825,6 +822,7 @@ static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber)
825static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 822static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
826{ 823{
827 struct cx24123_state *state = fe->demodulator_priv; 824 struct cx24123_state *state = fe->demodulator_priv;
825
828 *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ 826 *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */
829 827
830 dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength); 828 dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength);
@@ -835,19 +833,13 @@ static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
835static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr) 833static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr)
836{ 834{
837 struct cx24123_state *state = fe->demodulator_priv; 835 struct cx24123_state *state = fe->demodulator_priv;
838 *snr = state->snr;
839
840 dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr);
841 836
842 return 0; 837 /* Inverted raw Es/N0 count, totally bogus but better than the
843} 838 BER threshold. */
839 *snr = 65535 - (((u16)cx24123_readreg(state, 0x18) << 8) |
840 (u16)cx24123_readreg(state, 0x19));
844 841
845static int cx24123_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 842 dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr);
846{
847 struct cx24123_state *state = fe->demodulator_priv;
848 *ucblocks = state->lastber;
849
850 dprintk("%s: ucblocks (ber) = %d\n",__FUNCTION__,*ucblocks);
851 843
852 return 0; 844 return 0;
853} 845}
@@ -922,6 +914,29 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
922 return 0; 914 return 0;
923} 915}
924 916
917static int cx24123_tune(struct dvb_frontend* fe,
918 struct dvb_frontend_parameters* params,
919 unsigned int mode_flags,
920 int *delay,
921 fe_status_t *status)
922{
923 int retval = 0;
924
925 if (params != NULL)
926 retval = cx24123_set_frontend(fe, params);
927
928 if (!(mode_flags & FE_TUNE_MODE_ONESHOT))
929 cx24123_read_status(fe, status);
930 *delay = HZ/10;
931
932 return retval;
933}
934
935static int cx24123_get_algo(struct dvb_frontend *fe)
936{
937 return 1; //FE_ALGO_HW
938}
939
925static void cx24123_release(struct dvb_frontend* fe) 940static void cx24123_release(struct dvb_frontend* fe)
926{ 941{
927 struct cx24123_state* state = fe->demodulator_priv; 942 struct cx24123_state* state = fe->demodulator_priv;
@@ -949,8 +964,6 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
949 /* setup the state */ 964 /* setup the state */
950 state->config = config; 965 state->config = config;
951 state->i2c = i2c; 966 state->i2c = i2c;
952 state->lastber = 0;
953 state->snr = 0;
954 state->VCAarg = 0; 967 state->VCAarg = 0;
955 state->VGAarg = 0; 968 state->VGAarg = 0;
956 state->bandselectarg = 0; 969 state->bandselectarg = 0;
@@ -1003,11 +1016,12 @@ static struct dvb_frontend_ops cx24123_ops = {
1003 .read_ber = cx24123_read_ber, 1016 .read_ber = cx24123_read_ber,
1004 .read_signal_strength = cx24123_read_signal_strength, 1017 .read_signal_strength = cx24123_read_signal_strength,
1005 .read_snr = cx24123_read_snr, 1018 .read_snr = cx24123_read_snr,
1006 .read_ucblocks = cx24123_read_ucblocks,
1007 .diseqc_send_master_cmd = cx24123_send_diseqc_msg, 1019 .diseqc_send_master_cmd = cx24123_send_diseqc_msg,
1008 .diseqc_send_burst = cx24123_diseqc_send_burst, 1020 .diseqc_send_burst = cx24123_diseqc_send_burst,
1009 .set_tone = cx24123_set_tone, 1021 .set_tone = cx24123_set_tone,
1010 .set_voltage = cx24123_set_voltage, 1022 .set_voltage = cx24123_set_voltage,
1023 .tune = cx24123_tune,
1024 .get_frontend_algo = cx24123_get_algo,
1011}; 1025};
1012 1026
1013module_param(debug, int, 0644); 1027module_param(debug, int, 0644);
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h
index 9606f825935c..57a1dae1dc40 100644
--- a/drivers/media/dvb/frontends/cx24123.h
+++ b/drivers/media/dvb/frontends/cx24123.h
@@ -30,9 +30,21 @@ struct cx24123_config
30 30
31 /* Need to set device param for start_dma */ 31 /* Need to set device param for start_dma */
32 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 32 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
33
34 /* 0 = LNB voltage normal, 1 = LNB voltage inverted */
35 int lnb_polarity;
33}; 36};
34 37
38#if defined(CONFIG_DVB_CX24123) || defined(CONFIG_DVB_CX24123_MODULE)
35extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 39extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
36 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else
42static inline struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
43 struct i2c_adapter* i2c)
44{
45 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
46 return NULL;
47}
48#endif // CONFIG_DVB_CX24123
37 49
38#endif /* CX24123_H */ 50#endif /* CX24123_H */
diff --git a/drivers/media/dvb/frontends/dib3000-common.c b/drivers/media/dvb/frontends/dib3000-common.c
deleted file mode 100644
index 1a4f1f7c228a..000000000000
--- a/drivers/media/dvb/frontends/dib3000-common.c
+++ /dev/null
@@ -1,83 +0,0 @@
1#include "dib3000-common.h"
2
3#ifdef CONFIG_DVB_DIBCOM_DEBUG
4static int debug;
5module_param(debug, int, 0644);
6MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c,4=srch (|-able)).");
7#endif
8#define deb_info(args...) dprintk(0x01,args)
9#define deb_i2c(args...) dprintk(0x02,args)
10#define deb_srch(args...) dprintk(0x04,args)
11
12
13int dib3000_read_reg(struct dib3000_state *state, u16 reg)
14{
15 u8 wb[] = { ((reg >> 8) | 0x80) & 0xff, reg & 0xff };
16 u8 rb[2];
17 struct i2c_msg msg[] = {
18 { .addr = state->config.demod_address, .flags = 0, .buf = wb, .len = 2 },
19 { .addr = state->config.demod_address, .flags = I2C_M_RD, .buf = rb, .len = 2 },
20 };
21
22 if (i2c_transfer(state->i2c, msg, 2) != 2)
23 deb_i2c("i2c read error\n");
24
25 deb_i2c("reading i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,
26 (rb[0] << 8) | rb[1],(rb[0] << 8) | rb[1]);
27
28 return (rb[0] << 8) | rb[1];
29}
30
31int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val)
32{
33 u8 b[] = {
34 (reg >> 8) & 0xff, reg & 0xff,
35 (val >> 8) & 0xff, val & 0xff,
36 };
37 struct i2c_msg msg[] = {
38 { .addr = state->config.demod_address, .flags = 0, .buf = b, .len = 4 }
39 };
40 deb_i2c("writing i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,val,val);
41
42 return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0;
43}
44
45int dib3000_search_status(u16 irq,u16 lock)
46{
47 if (irq & 0x02) {
48 if (lock & 0x01) {
49 deb_srch("auto search succeeded\n");
50 return 1; // auto search succeeded
51 } else {
52 deb_srch("auto search not successful\n");
53 return 0; // auto search failed
54 }
55 } else if (irq & 0x01) {
56 deb_srch("auto search failed\n");
57 return 0; // auto search failed
58 }
59 return -1; // try again
60}
61
62/* for auto search */
63u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
64 { /* fft */
65 { /* gua */
66 { 0, 1 }, /* 0 0 { 0,1 } */
67 { 3, 9 }, /* 0 1 { 0,1 } */
68 },
69 {
70 { 2, 5 }, /* 1 0 { 0,1 } */
71 { 6, 11 }, /* 1 1 { 0,1 } */
72 }
73 };
74
75MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de");
76MODULE_DESCRIPTION("Common functions for the dib3000mb/dib3000mc dvb frontend drivers");
77MODULE_LICENSE("GPL");
78
79EXPORT_SYMBOL(dib3000_seq);
80
81EXPORT_SYMBOL(dib3000_read_reg);
82EXPORT_SYMBOL(dib3000_write_reg);
83EXPORT_SYMBOL(dib3000_search_status);
diff --git a/drivers/media/dvb/frontends/dib3000-common.h b/drivers/media/dvb/frontends/dib3000-common.h
deleted file mode 100644
index be1c0d3e1389..000000000000
--- a/drivers/media/dvb/frontends/dib3000-common.h
+++ /dev/null
@@ -1,135 +0,0 @@
1/*
2 * .h-files for the common use of the frontend drivers made by DiBcom
3 * DiBcom 3000M-B/C, 3000P
4 *
5 * DiBcom (http://www.dibcom.fr/)
6 *
7 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
8 *
9 * based on GPL code from DibCom, which has
10 *
11 * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation, version 2.
16 *
17 * Acknowledgements
18 *
19 * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
20 * sources, on which this driver (and the dvb-dibusb) are based.
21 *
22 * see Documentation/dvb/README.dibusb for more information
23 *
24 */
25
26#ifndef DIB3000_COMMON_H
27#define DIB3000_COMMON_H
28
29#include "dvb_frontend.h"
30#include "dib3000.h"
31
32/* info and err, taken from usb.h, if there is anything available like by default. */
33#define err(format, arg...) printk(KERN_ERR "dib3000: " format "\n" , ## arg)
34#define info(format, arg...) printk(KERN_INFO "dib3000: " format "\n" , ## arg)
35#define warn(format, arg...) printk(KERN_WARNING "dib3000: " format "\n" , ## arg)
36
37/* frontend state */
38struct dib3000_state {
39 struct i2c_adapter* i2c;
40
41/* configuration settings */
42 struct dib3000_config config;
43
44 struct dvb_frontend frontend;
45 int timing_offset;
46 int timing_offset_comp_done;
47
48 fe_bandwidth_t last_tuned_bw;
49 u32 last_tuned_freq;
50};
51
52/* commonly used methods by the dib3000mb/mc/p frontend */
53extern int dib3000_read_reg(struct dib3000_state *state, u16 reg);
54extern int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val);
55
56extern int dib3000_search_status(u16 irq,u16 lock);
57
58/* handy shortcuts */
59#define rd(reg) dib3000_read_reg(state,reg)
60
61#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
62 { err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; }
63
64#define wr_foreach(a,v) { int i; \
65 if (sizeof(a) != sizeof(v)) \
66 err("sizeof: %zu %zu is different",sizeof(a),sizeof(v));\
67 for (i=0; i < sizeof(a)/sizeof(u16); i++) \
68 wr(a[i],v[i]); \
69 }
70
71#define set_or(reg,val) wr(reg,rd(reg) | val)
72
73#define set_and(reg,val) wr(reg,rd(reg) & val)
74
75
76/* debug */
77
78#ifdef CONFIG_DVB_DIBCOM_DEBUG
79#define dprintk(level,args...) \
80 do { if ((debug & level)) { printk(args); } } while (0)
81#else
82#define dprintk(args...) do { } while (0)
83#endif
84
85/* mask for enabling a specific pid for the pid_filter */
86#define DIB3000_ACTIVATE_PID_FILTERING (0x2000)
87
88/* common values for tuning */
89#define DIB3000_ALPHA_0 ( 0)
90#define DIB3000_ALPHA_1 ( 1)
91#define DIB3000_ALPHA_2 ( 2)
92#define DIB3000_ALPHA_4 ( 4)
93
94#define DIB3000_CONSTELLATION_QPSK ( 0)
95#define DIB3000_CONSTELLATION_16QAM ( 1)
96#define DIB3000_CONSTELLATION_64QAM ( 2)
97
98#define DIB3000_GUARD_TIME_1_32 ( 0)
99#define DIB3000_GUARD_TIME_1_16 ( 1)
100#define DIB3000_GUARD_TIME_1_8 ( 2)
101#define DIB3000_GUARD_TIME_1_4 ( 3)
102
103#define DIB3000_TRANSMISSION_MODE_2K ( 0)
104#define DIB3000_TRANSMISSION_MODE_8K ( 1)
105
106#define DIB3000_SELECT_LP ( 0)
107#define DIB3000_SELECT_HP ( 1)
108
109#define DIB3000_FEC_1_2 ( 1)
110#define DIB3000_FEC_2_3 ( 2)
111#define DIB3000_FEC_3_4 ( 3)
112#define DIB3000_FEC_5_6 ( 5)
113#define DIB3000_FEC_7_8 ( 7)
114
115#define DIB3000_HRCH_OFF ( 0)
116#define DIB3000_HRCH_ON ( 1)
117
118#define DIB3000_DDS_INVERSION_OFF ( 0)
119#define DIB3000_DDS_INVERSION_ON ( 1)
120
121#define DIB3000_TUNER_WRITE_ENABLE(a) (0xffff & (a << 8))
122#define DIB3000_TUNER_WRITE_DISABLE(a) (0xffff & ((a << 8) | (1 << 7)))
123
124/* for auto search */
125extern u16 dib3000_seq[2][2][2];
126
127#define DIB3000_REG_MANUFACTOR_ID ( 1025)
128#define DIB3000_I2C_ID_DIBCOM (0x01b3)
129
130#define DIB3000_REG_DEVICE_ID ( 1026)
131#define DIB3000MB_DEVICE_ID (0x3000)
132#define DIB3000MC_DEVICE_ID (0x3001)
133#define DIB3000P_DEVICE_ID (0x3002)
134
135#endif // DIB3000_COMMON_H
diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
index ec927628d273..0caac3f0f279 100644
--- a/drivers/media/dvb/frontends/dib3000.h
+++ b/drivers/media/dvb/frontends/dib3000.h
@@ -41,9 +41,16 @@ struct dib_fe_xfer_ops
41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl); 41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42}; 42};
43 43
44#if defined(CONFIG_DVB_DIB3000MB) || defined(CONFIG_DVB_DIB3000MB_MODULE)
44extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, 45extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
45 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops); 46 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
47#else
48static inline struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
49 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
50{
51 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
52 return NULL;
53}
54#endif // CONFIG_DVB_DIB3000MB
46 55
47extern struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
48 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
49#endif // DIB3000_H 56#endif // DIB3000_H
diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c
index 5302e11883a2..adbabfdb04a9 100644
--- a/drivers/media/dvb/frontends/dib3000mb.c
+++ b/drivers/media/dvb/frontends/dib3000mb.c
@@ -29,9 +29,10 @@
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31 31
32#include "dib3000-common.h" 32#include "dvb_frontend.h"
33#include "dib3000mb_priv.h" 33
34#include "dib3000.h" 34#include "dib3000.h"
35#include "dib3000mb_priv.h"
35 36
36/* Version information */ 37/* Version information */
37#define DRIVER_VERSION "0.1" 38#define DRIVER_VERSION "0.1"
@@ -44,10 +45,81 @@ module_param(debug, int, 0644);
44MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able))."); 45MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able)).");
45#endif 46#endif
46#define deb_info(args...) dprintk(0x01,args) 47#define deb_info(args...) dprintk(0x01,args)
48#define deb_i2c(args...) dprintk(0x02,args)
49#define deb_srch(args...) dprintk(0x04,args)
50#define deb_info(args...) dprintk(0x01,args)
47#define deb_xfer(args...) dprintk(0x02,args) 51#define deb_xfer(args...) dprintk(0x02,args)
48#define deb_setf(args...) dprintk(0x04,args) 52#define deb_setf(args...) dprintk(0x04,args)
49#define deb_getf(args...) dprintk(0x08,args) 53#define deb_getf(args...) dprintk(0x08,args)
50 54
55#ifdef CONFIG_DVB_DIBCOM_DEBUG
56static int debug;
57module_param(debug, int, 0644);
58MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c,4=srch (|-able)).");
59#endif
60
61static int dib3000_read_reg(struct dib3000_state *state, u16 reg)
62{
63 u8 wb[] = { ((reg >> 8) | 0x80) & 0xff, reg & 0xff };
64 u8 rb[2];
65 struct i2c_msg msg[] = {
66 { .addr = state->config.demod_address, .flags = 0, .buf = wb, .len = 2 },
67 { .addr = state->config.demod_address, .flags = I2C_M_RD, .buf = rb, .len = 2 },
68 };
69
70 if (i2c_transfer(state->i2c, msg, 2) != 2)
71 deb_i2c("i2c read error\n");
72
73 deb_i2c("reading i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,
74 (rb[0] << 8) | rb[1],(rb[0] << 8) | rb[1]);
75
76 return (rb[0] << 8) | rb[1];
77}
78
79static int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val)
80{
81 u8 b[] = {
82 (reg >> 8) & 0xff, reg & 0xff,
83 (val >> 8) & 0xff, val & 0xff,
84 };
85 struct i2c_msg msg[] = {
86 { .addr = state->config.demod_address, .flags = 0, .buf = b, .len = 4 }
87 };
88 deb_i2c("writing i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,val,val);
89
90 return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0;
91}
92
93static int dib3000_search_status(u16 irq,u16 lock)
94{
95 if (irq & 0x02) {
96 if (lock & 0x01) {
97 deb_srch("auto search succeeded\n");
98 return 1; // auto search succeeded
99 } else {
100 deb_srch("auto search not successful\n");
101 return 0; // auto search failed
102 }
103 } else if (irq & 0x01) {
104 deb_srch("auto search failed\n");
105 return 0; // auto search failed
106 }
107 return -1; // try again
108}
109
110/* for auto search */
111static u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
112 { /* fft */
113 { /* gua */
114 { 0, 1 }, /* 0 0 { 0,1 } */
115 { 3, 9 }, /* 0 1 { 0,1 } */
116 },
117 {
118 { 2, 5 }, /* 1 0 { 0,1 } */
119 { 6, 11 }, /* 1 1 { 0,1 } */
120 }
121 };
122
51static int dib3000mb_get_frontend(struct dvb_frontend* fe, 123static int dib3000mb_get_frontend(struct dvb_frontend* fe,
52 struct dvb_frontend_parameters *fep); 124 struct dvb_frontend_parameters *fep);
53 125
diff --git a/drivers/media/dvb/frontends/dib3000mb_priv.h b/drivers/media/dvb/frontends/dib3000mb_priv.h
index 999b19047816..1a12747fdc91 100644
--- a/drivers/media/dvb/frontends/dib3000mb_priv.h
+++ b/drivers/media/dvb/frontends/dib3000mb_priv.h
@@ -13,6 +13,99 @@
13#ifndef __DIB3000MB_PRIV_H_INCLUDED__ 13#ifndef __DIB3000MB_PRIV_H_INCLUDED__
14#define __DIB3000MB_PRIV_H_INCLUDED__ 14#define __DIB3000MB_PRIV_H_INCLUDED__
15 15
16/* info and err, taken from usb.h, if there is anything available like by default. */
17#define err(format, arg...) printk(KERN_ERR "dib3000: " format "\n" , ## arg)
18#define info(format, arg...) printk(KERN_INFO "dib3000: " format "\n" , ## arg)
19#define warn(format, arg...) printk(KERN_WARNING "dib3000: " format "\n" , ## arg)
20
21/* handy shortcuts */
22#define rd(reg) dib3000_read_reg(state,reg)
23
24#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
25 { err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; }
26
27#define wr_foreach(a,v) { int i; \
28 if (sizeof(a) != sizeof(v)) \
29 err("sizeof: %zu %zu is different",sizeof(a),sizeof(v));\
30 for (i=0; i < sizeof(a)/sizeof(u16); i++) \
31 wr(a[i],v[i]); \
32 }
33
34#define set_or(reg,val) wr(reg,rd(reg) | val)
35
36#define set_and(reg,val) wr(reg,rd(reg) & val)
37
38/* debug */
39
40#ifdef CONFIG_DVB_DIBCOM_DEBUG
41#define dprintk(level,args...) \
42 do { if ((debug & level)) { printk(args); } } while (0)
43#else
44#define dprintk(args...) do { } while (0)
45#endif
46
47/* mask for enabling a specific pid for the pid_filter */
48#define DIB3000_ACTIVATE_PID_FILTERING (0x2000)
49
50/* common values for tuning */
51#define DIB3000_ALPHA_0 ( 0)
52#define DIB3000_ALPHA_1 ( 1)
53#define DIB3000_ALPHA_2 ( 2)
54#define DIB3000_ALPHA_4 ( 4)
55
56#define DIB3000_CONSTELLATION_QPSK ( 0)
57#define DIB3000_CONSTELLATION_16QAM ( 1)
58#define DIB3000_CONSTELLATION_64QAM ( 2)
59
60#define DIB3000_GUARD_TIME_1_32 ( 0)
61#define DIB3000_GUARD_TIME_1_16 ( 1)
62#define DIB3000_GUARD_TIME_1_8 ( 2)
63#define DIB3000_GUARD_TIME_1_4 ( 3)
64
65#define DIB3000_TRANSMISSION_MODE_2K ( 0)
66#define DIB3000_TRANSMISSION_MODE_8K ( 1)
67
68#define DIB3000_SELECT_LP ( 0)
69#define DIB3000_SELECT_HP ( 1)
70
71#define DIB3000_FEC_1_2 ( 1)
72#define DIB3000_FEC_2_3 ( 2)
73#define DIB3000_FEC_3_4 ( 3)
74#define DIB3000_FEC_5_6 ( 5)
75#define DIB3000_FEC_7_8 ( 7)
76
77#define DIB3000_HRCH_OFF ( 0)
78#define DIB3000_HRCH_ON ( 1)
79
80#define DIB3000_DDS_INVERSION_OFF ( 0)
81#define DIB3000_DDS_INVERSION_ON ( 1)
82
83#define DIB3000_TUNER_WRITE_ENABLE(a) (0xffff & (a << 8))
84#define DIB3000_TUNER_WRITE_DISABLE(a) (0xffff & ((a << 8) | (1 << 7)))
85
86#define DIB3000_REG_MANUFACTOR_ID ( 1025)
87#define DIB3000_I2C_ID_DIBCOM (0x01b3)
88
89#define DIB3000_REG_DEVICE_ID ( 1026)
90#define DIB3000MB_DEVICE_ID (0x3000)
91#define DIB3000MC_DEVICE_ID (0x3001)
92#define DIB3000P_DEVICE_ID (0x3002)
93
94/* frontend state */
95struct dib3000_state {
96 struct i2c_adapter* i2c;
97
98/* configuration settings */
99 struct dib3000_config config;
100
101 struct dvb_frontend frontend;
102 int timing_offset;
103 int timing_offset_comp_done;
104
105 fe_bandwidth_t last_tuned_bw;
106 u32 last_tuned_freq;
107};
108
16/* register addresses and some of their default values */ 109/* register addresses and some of their default values */
17 110
18/* restart subsystems */ 111/* restart subsystems */
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index 98673474a140..cc28417fa33a 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -1,913 +1,921 @@
1/* 1/*
2 * Frontend driver for mobile DVB-T demodulator DiBcom 3000P/M-C 2 * Driver for DiBcom DiB3000MC/P-demodulator.
3 * DiBcom (http://www.dibcom.fr/)
4 * 3 *
4 * Copyright (C) 2004-6 DiBcom (http://www.dibcom.fr/)
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
6 * 6 *
7 * based on GPL code from DiBCom, which has 7 * This code is partially based on the previous dib3000mc.c .
8 * 8 *
9 * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr) 9 * This program is free software; you can redistribute it and/or
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation, version 2. 11 * published by the Free Software Foundation, version 2.
14 *
15 * Acknowledgements
16 *
17 * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
18 * sources, on which this driver (and the dvb-dibusb) are based.
19 *
20 * see Documentation/dvb/README.dibusb for more information
21 *
22 */ 12 */
13
23#include <linux/kernel.h> 14#include <linux/kernel.h>
24#include <linux/module.h> 15#include <linux/i2c.h>
25#include <linux/moduleparam.h> 16//#include <linux/init.h>
26#include <linux/init.h> 17//#include <linux/delay.h>
27#include <linux/delay.h> 18//#include <linux/string.h>
28#include <linux/string.h> 19//#include <linux/slab.h>
29#include <linux/slab.h> 20
30 21#include "dvb_frontend.h"
31#include "dib3000-common.h" 22
32#include "dib3000mc_priv.h" 23#include "dib3000mc.h"
33#include "dib3000.h" 24
34
35/* Version information */
36#define DRIVER_VERSION "0.1"
37#define DRIVER_DESC "DiBcom 3000M-C DVB-T demodulator"
38#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
39
40#ifdef CONFIG_DVB_DIBCOM_DEBUG
41static int debug; 25static int debug;
42module_param(debug, int, 0644); 26module_param(debug, int, 0644);
43MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe,16=stat (|-able))."); 27MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
44#endif
45#define deb_info(args...) dprintk(0x01,args)
46#define deb_xfer(args...) dprintk(0x02,args)
47#define deb_setf(args...) dprintk(0x04,args)
48#define deb_getf(args...) dprintk(0x08,args)
49#define deb_stat(args...) dprintk(0x10,args)
50
51static int dib3000mc_set_impulse_noise(struct dib3000_state * state, int mode,
52 fe_transmit_mode_t transmission_mode, fe_bandwidth_t bandwidth)
53{
54 switch (transmission_mode) {
55 case TRANSMISSION_MODE_2K:
56 wr_foreach(dib3000mc_reg_fft,dib3000mc_fft_modes[0]);
57 break;
58 case TRANSMISSION_MODE_8K:
59 wr_foreach(dib3000mc_reg_fft,dib3000mc_fft_modes[1]);
60 break;
61 default:
62 break;
63 }
64 28
65 switch (bandwidth) { 29#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB3000MC/P:"); printk(args); } } while (0)
66/* case BANDWIDTH_5_MHZ: 30
67 wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[0]); 31struct dib3000mc_state {
68 break; */ 32 struct dvb_frontend demod;
69 case BANDWIDTH_6_MHZ: 33 struct dib3000mc_config *cfg;
70 wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[1]); 34
71 break; 35 u8 i2c_addr;
72 case BANDWIDTH_7_MHZ: 36 struct i2c_adapter *i2c_adap;
73 wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[2]); 37
74 break; 38 struct dibx000_i2c_master i2c_master;
75 case BANDWIDTH_8_MHZ: 39
76 wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[3]); 40 fe_bandwidth_t current_bandwidth;
77 break; 41
78 default: 42 u16 dev_id;
79 break; 43};
44
45static u16 dib3000mc_read_word(struct dib3000mc_state *state, u16 reg)
46{
47 u8 wb[2] = { (reg >> 8) | 0x80, reg & 0xff };
48 u8 rb[2];
49 struct i2c_msg msg[2] = {
50 { .addr = state->i2c_addr >> 1, .flags = 0, .buf = wb, .len = 2 },
51 { .addr = state->i2c_addr >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2 },
52 };
53
54 if (i2c_transfer(state->i2c_adap, msg, 2) != 2)
55 dprintk("i2c read error on %d\n",reg);
56
57 return (rb[0] << 8) | rb[1];
58}
59
60static int dib3000mc_write_word(struct dib3000mc_state *state, u16 reg, u16 val)
61{
62 u8 b[4] = {
63 (reg >> 8) & 0xff, reg & 0xff,
64 (val >> 8) & 0xff, val & 0xff,
65 };
66 struct i2c_msg msg = {
67 .addr = state->i2c_addr >> 1, .flags = 0, .buf = b, .len = 4
68 };
69 return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0;
70}
71
72
73static int dib3000mc_identify(struct dib3000mc_state *state)
74{
75 u16 value;
76 if ((value = dib3000mc_read_word(state, 1025)) != 0x01b3) {
77 dprintk("-E- DiB3000MC/P: wrong Vendor ID (read=0x%x)\n",value);
78 return -EREMOTEIO;
80 } 79 }
81 80
82 switch (mode) { 81 value = dib3000mc_read_word(state, 1026);
83 case 0: /* no impulse */ /* fall through */ 82 if (value != 0x3001 && value != 0x3002) {
84 wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[0]); 83 dprintk("-E- DiB3000MC/P: wrong Device ID (%x)\n",value);
85 break; 84 return -EREMOTEIO;
86 case 1: /* new algo */
87 wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[1]);
88 set_or(DIB3000MC_REG_IMP_NOISE_55,DIB3000MC_IMP_NEW_ALGO(0)); /* gives 1<<10 */
89 break;
90 default: /* old algo */
91 wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[3]);
92 break;
93 } 85 }
86 state->dev_id = value;
87
88 dprintk("-I- found DiB3000MC/P: %x\n",state->dev_id);
89
94 return 0; 90 return 0;
95} 91}
96 92
97static int dib3000mc_set_timing(struct dib3000_state *state, int upd_offset, 93static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, u8 update_offset)
98 fe_transmit_mode_t fft, fe_bandwidth_t bw)
99{ 94{
100 u16 timf_msb,timf_lsb; 95/*
101 s32 tim_offset,tim_sgn; 96 u32 timf_msb, timf_lsb, i;
102 u64 comp1,comp2,comp=0; 97 int tim_sgn ;
103 98 LUInt comp1, comp2, comp ;
104 switch (bw) { 99// u32 tim_offset ;
105 case BANDWIDTH_8_MHZ: comp = DIB3000MC_CLOCK_REF*8; break; 100 comp = 27700 * BW_INDEX_TO_KHZ(bw) / 1000;
106 case BANDWIDTH_7_MHZ: comp = DIB3000MC_CLOCK_REF*7; break; 101 timf_msb = (comp >> 16) & 0x00FF;
107 case BANDWIDTH_6_MHZ: comp = DIB3000MC_CLOCK_REF*6; break; 102 timf_lsb = comp & 0xFFFF;
108 default: err("unknown bandwidth (%d)",bw); break;
109 }
110 timf_msb = (comp >> 16) & 0xff;
111 timf_lsb = (comp & 0xffff);
112 103
113 // Update the timing offset ; 104 // Update the timing offset ;
114 if (upd_offset > 0) { 105 if (update_offset) {
115 if (!state->timing_offset_comp_done) { 106 if (state->timing_offset_comp_done == 0) {
116 msleep(200); 107 usleep(200000);
117 state->timing_offset_comp_done = 1; 108 state->timing_offset_comp_done = 1;
118 } 109 }
119 tim_offset = rd(DIB3000MC_REG_TIMING_OFFS_MSB); 110 tim_offset = dib3000mc_read_word(state, 416);
120 if ((tim_offset & 0x2000) == 0x2000) 111 if ((tim_offset & 0x2000) == 0x2000)
121 tim_offset |= 0xC000; 112 tim_offset |= 0xC000; // PB: This only works if tim_offset is s16 - weird
122 if (fft == TRANSMISSION_MODE_2K) 113
123 tim_offset <<= 2; 114 if (nfft == 0)
115 tim_offset = tim_offset << 2; // PB: Do not store the offset for different things in one variable
124 state->timing_offset += tim_offset; 116 state->timing_offset += tim_offset;
125 } 117 }
126
127 tim_offset = state->timing_offset; 118 tim_offset = state->timing_offset;
119
128 if (tim_offset < 0) { 120 if (tim_offset < 0) {
129 tim_sgn = 1; 121 tim_sgn = 1;
130 tim_offset = -tim_offset; 122 tim_offset = -tim_offset;
131 } else 123 } else
132 tim_sgn = 0; 124 tim_sgn = 0;
133 125
134 comp1 = (u32)tim_offset * (u32)timf_lsb ; 126 comp1 = tim_offset * timf_lsb;
135 comp2 = (u32)tim_offset * (u32)timf_msb ; 127 comp2 = tim_offset * timf_msb;
136 comp = ((comp1 >> 16) + comp2) >> 7; 128 comp = ((comp1 >> 16) + comp2) >> 7;
137 129
138 if (tim_sgn == 0) 130 if (tim_sgn == 0)
139 comp = (u32)(timf_msb << 16) + (u32) timf_lsb + comp; 131 comp = timf_msb * (1<<16) + timf_lsb + comp;
140 else 132 else
141 comp = (u32)(timf_msb << 16) + (u32) timf_lsb - comp ; 133 comp = timf_msb * (1<<16) + timf_lsb - comp;
134
135 timf_msb = (comp>>16)&0xFF ;
136 timf_lsb = comp&0xFFFF;
137*/
138 u32 timf = 1384402 * (BW_INDEX_TO_KHZ(bw) / 1000);
142 139
143 timf_msb = (comp >> 16) & 0xff; 140 dib3000mc_write_word(state, 23, timf >> 16);
144 timf_lsb = comp & 0xffff; 141 dib3000mc_write_word(state, 24, timf & 0xffff);
145 142
146 wr(DIB3000MC_REG_TIMING_FREQ_MSB,timf_msb);
147 wr(DIB3000MC_REG_TIMING_FREQ_LSB,timf_lsb);
148 return 0; 143 return 0;
149} 144}
150 145
151static int dib3000mc_init_auto_scan(struct dib3000_state *state, fe_bandwidth_t bw, int boost) 146static int dib3000mc_setup_pwm3_state(struct dib3000mc_state *state)
152{ 147{
153 if (boost) { 148 if (state->cfg->pwm3_inversion) {
154 wr(DIB3000MC_REG_SCAN_BOOST,DIB3000MC_SCAN_BOOST_ON); 149 dib3000mc_write_word(state, 51, (2 << 14) | (0 << 10) | (7 << 6) | (2 << 2) | (2 << 0));
150 dib3000mc_write_word(state, 52, (0 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (2 << 0));
155 } else { 151 } else {
156 wr(DIB3000MC_REG_SCAN_BOOST,DIB3000MC_SCAN_BOOST_OFF); 152 dib3000mc_write_word(state, 51, (2 << 14) | (4 << 10) | (7 << 6) | (2 << 2) | (2 << 0));
157 } 153 dib3000mc_write_word(state, 52, (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0));
158 switch (bw) {
159 case BANDWIDTH_8_MHZ:
160 wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_8mhz);
161 break;
162 case BANDWIDTH_7_MHZ:
163 wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_7mhz);
164 break;
165 case BANDWIDTH_6_MHZ:
166 wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_6mhz);
167 break;
168/* case BANDWIDTH_5_MHZ:
169 wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_5mhz);
170 break;*/
171 case BANDWIDTH_AUTO:
172 return -EOPNOTSUPP;
173 default:
174 err("unknown bandwidth value (%d).",bw);
175 return -EINVAL;
176 }
177 if (boost) {
178 u32 timeout = (rd(DIB3000MC_REG_BW_TIMOUT_MSB) << 16) +
179 rd(DIB3000MC_REG_BW_TIMOUT_LSB);
180 timeout *= 85; timeout >>= 7;
181 wr(DIB3000MC_REG_BW_TIMOUT_MSB,(timeout >> 16) & 0xffff);
182 wr(DIB3000MC_REG_BW_TIMOUT_LSB,timeout & 0xffff);
183 } 154 }
155
156 if (state->cfg->use_pwm3)
157 dib3000mc_write_word(state, 245, (1 << 3) | (1 << 0));
158 else
159 dib3000mc_write_word(state, 245, 0);
160
161 dib3000mc_write_word(state, 1040, 0x3);
184 return 0; 162 return 0;
185} 163}
186 164
187static int dib3000mc_set_adp_cfg(struct dib3000_state *state, fe_modulation_t con) 165static int dib3000mc_set_output_mode(struct dib3000mc_state *state, int mode)
188{ 166{
189 switch (con) { 167 int ret = 0;
190 case QAM_64: 168 u16 fifo_threshold = 1792;
191 wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[2]); 169 u16 outreg = 0;
192 break; 170 u16 outmode = 0;
193 case QAM_16: 171 u16 elecout = 1;
194 wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[1]); 172 u16 smo_reg = dib3000mc_read_word(state, 206) & 0x0010; /* keep the pid_parse bit */
195 break; 173
196 case QPSK: 174 dprintk("-I- Setting output mode for demod %p to %d\n",
197 wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[0]); 175 &state->demod, mode);
198 break; 176
199 case QAM_AUTO: 177 switch (mode) {
178 case OUTMODE_HIGH_Z: // disable
179 elecout = 0;
180 break;
181 case OUTMODE_MPEG2_PAR_GATED_CLK: // STBs with parallel gated clock
182 outmode = 0;
183 break;
184 case OUTMODE_MPEG2_PAR_CONT_CLK: // STBs with parallel continues clock
185 outmode = 1;
186 break;
187 case OUTMODE_MPEG2_SERIAL: // STBs with serial input
188 outmode = 2;
189 break;
190 case OUTMODE_MPEG2_FIFO: // e.g. USB feeding
191 elecout = 3;
192 /*ADDR @ 206 :
193 P_smo_error_discard [1;6:6] = 0
194 P_smo_rs_discard [1;5:5] = 0
195 P_smo_pid_parse [1;4:4] = 0
196 P_smo_fifo_flush [1;3:3] = 0
197 P_smo_mode [2;2:1] = 11
198 P_smo_ovf_prot [1;0:0] = 0
199 */
200 smo_reg |= 3 << 1;
201 fifo_threshold = 512;
202 outmode = 5;
203 break;
204 case OUTMODE_DIVERSITY:
205 outmode = 4;
206 elecout = 1;
200 break; 207 break;
201 default: 208 default:
202 warn("unkown constellation."); 209 dprintk("Unhandled output_mode passed to be set for demod %p\n",&state->demod);
210 outmode = 0;
203 break; 211 break;
204 } 212 }
205 return 0; 213
214 if ((state->cfg->output_mpeg2_in_188_bytes))
215 smo_reg |= (1 << 5); // P_smo_rs_discard [1;5:5] = 1
216
217 outreg = dib3000mc_read_word(state, 244) & 0x07FF;
218 outreg |= (outmode << 11);
219 ret |= dib3000mc_write_word(state, 244, outreg);
220 ret |= dib3000mc_write_word(state, 206, smo_reg); /*smo_ mode*/
221 ret |= dib3000mc_write_word(state, 207, fifo_threshold); /* synchronous fread */
222 ret |= dib3000mc_write_word(state, 1040, elecout); /* P_out_cfg */
223 return ret;
206} 224}
207 225
208static int dib3000mc_set_general_cfg(struct dib3000_state *state, struct dvb_frontend_parameters *fep, int *auto_val) 226static int dib3000mc_set_bandwidth(struct dvb_frontend *demod, u8 bw)
209{ 227{
210 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm; 228 struct dib3000mc_state *state = demod->demodulator_priv;
211 fe_code_rate_t fe_cr = FEC_NONE; 229 u16 bw_cfg[6] = { 0 };
212 u8 fft=0, guard=0, qam=0, alpha=0, sel_hp=0, cr=0, hrch=0; 230 u16 imp_bw_cfg[3] = { 0 };
213 int seq; 231 u16 reg;
214 232
215 switch (ofdm->transmission_mode) { 233/* settings here are for 27.7MHz */
216 case TRANSMISSION_MODE_2K: fft = DIB3000_TRANSMISSION_MODE_2K; break; 234 switch (bw) {
217 case TRANSMISSION_MODE_8K: fft = DIB3000_TRANSMISSION_MODE_8K; break; 235 case BANDWIDTH_8_MHZ:
218 case TRANSMISSION_MODE_AUTO: break; 236 bw_cfg[0] = 0x0019; bw_cfg[1] = 0x5c30; bw_cfg[2] = 0x0054; bw_cfg[3] = 0x88a0; bw_cfg[4] = 0x01a6; bw_cfg[5] = 0xab20;
219 default: return -EINVAL; 237 imp_bw_cfg[0] = 0x04db; imp_bw_cfg[1] = 0x00db; imp_bw_cfg[2] = 0x00b7;
220 } 238 break;
221 switch (ofdm->guard_interval) {
222 case GUARD_INTERVAL_1_32: guard = DIB3000_GUARD_TIME_1_32; break;
223 case GUARD_INTERVAL_1_16: guard = DIB3000_GUARD_TIME_1_16; break;
224 case GUARD_INTERVAL_1_8: guard = DIB3000_GUARD_TIME_1_8; break;
225 case GUARD_INTERVAL_1_4: guard = DIB3000_GUARD_TIME_1_4; break;
226 case GUARD_INTERVAL_AUTO: break;
227 default: return -EINVAL;
228 }
229 switch (ofdm->constellation) {
230 case QPSK: qam = DIB3000_CONSTELLATION_QPSK; break;
231 case QAM_16: qam = DIB3000_CONSTELLATION_16QAM; break;
232 case QAM_64: qam = DIB3000_CONSTELLATION_64QAM; break;
233 case QAM_AUTO: break;
234 default: return -EINVAL;
235 }
236 switch (ofdm->hierarchy_information) {
237 case HIERARCHY_NONE: /* fall through */
238 case HIERARCHY_1: alpha = DIB3000_ALPHA_1; break;
239 case HIERARCHY_2: alpha = DIB3000_ALPHA_2; break;
240 case HIERARCHY_4: alpha = DIB3000_ALPHA_4; break;
241 case HIERARCHY_AUTO: break;
242 default: return -EINVAL;
243 }
244 if (ofdm->hierarchy_information == HIERARCHY_NONE) {
245 hrch = DIB3000_HRCH_OFF;
246 sel_hp = DIB3000_SELECT_HP;
247 fe_cr = ofdm->code_rate_HP;
248 } else if (ofdm->hierarchy_information != HIERARCHY_AUTO) {
249 hrch = DIB3000_HRCH_ON;
250 sel_hp = DIB3000_SELECT_LP;
251 fe_cr = ofdm->code_rate_LP;
252 }
253 switch (fe_cr) {
254 case FEC_1_2: cr = DIB3000_FEC_1_2; break;
255 case FEC_2_3: cr = DIB3000_FEC_2_3; break;
256 case FEC_3_4: cr = DIB3000_FEC_3_4; break;
257 case FEC_5_6: cr = DIB3000_FEC_5_6; break;
258 case FEC_7_8: cr = DIB3000_FEC_7_8; break;
259 case FEC_NONE: break;
260 case FEC_AUTO: break;
261 default: return -EINVAL;
262 }
263 239
264 wr(DIB3000MC_REG_DEMOD_PARM,DIB3000MC_DEMOD_PARM(alpha,qam,guard,fft)); 240 case BANDWIDTH_7_MHZ:
265 wr(DIB3000MC_REG_HRCH_PARM,DIB3000MC_HRCH_PARM(sel_hp,cr,hrch)); 241 bw_cfg[0] = 0x001c; bw_cfg[1] = 0xfba5; bw_cfg[2] = 0x0060; bw_cfg[3] = 0x9c25; bw_cfg[4] = 0x01e3; bw_cfg[5] = 0x0cb7;
242 imp_bw_cfg[0] = 0x04c0; imp_bw_cfg[1] = 0x00c0; imp_bw_cfg[2] = 0x00a0;
243 break;
266 244
267 switch (fep->inversion) { 245 case BANDWIDTH_6_MHZ:
268 case INVERSION_OFF: 246 bw_cfg[0] = 0x0021; bw_cfg[1] = 0xd040; bw_cfg[2] = 0x0070; bw_cfg[3] = 0xb62b; bw_cfg[4] = 0x0233; bw_cfg[5] = 0x8ed5;
269 wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_OFF); 247 imp_bw_cfg[0] = 0x04a5; imp_bw_cfg[1] = 0x00a5; imp_bw_cfg[2] = 0x0089;
270 break; 248 break;
271 case INVERSION_AUTO: /* fall through */ 249
272 case INVERSION_ON: 250 case 255 /* BANDWIDTH_5_MHZ */:
273 wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_ON); 251 bw_cfg[0] = 0x0028; bw_cfg[1] = 0x9380; bw_cfg[2] = 0x0087; bw_cfg[3] = 0x4100; bw_cfg[4] = 0x02a4; bw_cfg[5] = 0x4500;
252 imp_bw_cfg[0] = 0x0489; imp_bw_cfg[1] = 0x0089; imp_bw_cfg[2] = 0x0072;
274 break; 253 break;
275 default: 254
276 return -EINVAL; 255 default: return -EINVAL;
277 } 256 }
278 257
279 seq = dib3000_seq 258 for (reg = 6; reg < 12; reg++)
280 [ofdm->transmission_mode == TRANSMISSION_MODE_AUTO] 259 dib3000mc_write_word(state, reg, bw_cfg[reg - 6]);
281 [ofdm->guard_interval == GUARD_INTERVAL_AUTO] 260 dib3000mc_write_word(state, 12, 0x0000);
282 [fep->inversion == INVERSION_AUTO]; 261 dib3000mc_write_word(state, 13, 0x03e8);
283 262 dib3000mc_write_word(state, 14, 0x0000);
284 deb_setf("seq? %d\n", seq); 263 dib3000mc_write_word(state, 15, 0x03f2);
285 wr(DIB3000MC_REG_SEQ_TPS,DIB3000MC_SEQ_TPS(seq,1)); 264 dib3000mc_write_word(state, 16, 0x0001);
286 *auto_val = ofdm->constellation == QAM_AUTO || 265 dib3000mc_write_word(state, 17, 0xb0d0);
287 ofdm->hierarchy_information == HIERARCHY_AUTO || 266 // P_sec_len
288 ofdm->guard_interval == GUARD_INTERVAL_AUTO || 267 dib3000mc_write_word(state, 18, 0x0393);
289 ofdm->transmission_mode == TRANSMISSION_MODE_AUTO || 268 dib3000mc_write_word(state, 19, 0x8700);
290 fe_cr == FEC_AUTO ||
291 fep->inversion == INVERSION_AUTO;
292 return 0;
293}
294 269
295static int dib3000mc_get_frontend(struct dvb_frontend* fe, 270 for (reg = 55; reg < 58; reg++)
296 struct dvb_frontend_parameters *fep) 271 dib3000mc_write_word(state, reg, imp_bw_cfg[reg - 55]);
297{
298 struct dib3000_state* state = fe->demodulator_priv;
299 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
300 fe_code_rate_t *cr;
301 u16 tps_val,cr_val;
302 int inv_test1,inv_test2;
303 u32 dds_val, threshold = 0x1000000;
304
305 if (!(rd(DIB3000MC_REG_LOCK_507) & DIB3000MC_LOCK_507))
306 return 0;
307
308 dds_val = (rd(DIB3000MC_REG_DDS_FREQ_MSB) << 16) + rd(DIB3000MC_REG_DDS_FREQ_LSB);
309 deb_getf("DDS_FREQ: %6x\n",dds_val);
310 if (dds_val < threshold)
311 inv_test1 = 0;
312 else if (dds_val == threshold)
313 inv_test1 = 1;
314 else
315 inv_test1 = 2;
316
317 dds_val = (rd(DIB3000MC_REG_SET_DDS_FREQ_MSB) << 16) + rd(DIB3000MC_REG_SET_DDS_FREQ_LSB);
318 deb_getf("DDS_SET_FREQ: %6x\n",dds_val);
319 if (dds_val < threshold)
320 inv_test2 = 0;
321 else if (dds_val == threshold)
322 inv_test2 = 1;
323 else
324 inv_test2 = 2;
325 272
326 fep->inversion = 273 // Timing configuration
327 ((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) || 274 dib3000mc_set_timing(state, 0, bw, 0);
328 ((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
329 INVERSION_ON : INVERSION_OFF;
330 275
331 deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion); 276 return 0;
277}
332 278
333 fep->frequency = state->last_tuned_freq; 279static u16 impulse_noise_val[29] =
334 fep->u.ofdm.bandwidth= state->last_tuned_bw;
335 280
336 tps_val = rd(DIB3000MC_REG_TUNING_PARM); 281{
282 0x38, 0x6d9, 0x3f28, 0x7a7, 0x3a74, 0x196, 0x32a, 0x48c, 0x3ffe, 0x7f3,
283 0x2d94, 0x76, 0x53d, 0x3ff8, 0x7e3, 0x3320, 0x76, 0x5b3, 0x3feb, 0x7d2,
284 0x365e, 0x76, 0x48c, 0x3ffe, 0x5b3, 0x3feb, 0x76, 0x0000, 0xd
285};
337 286
338 switch (DIB3000MC_TP_QAM(tps_val)) { 287static void dib3000mc_set_impulse_noise(struct dib3000mc_state *state, u8 mode, s16 nfft)
339 case DIB3000_CONSTELLATION_QPSK: 288{
340 deb_getf("QPSK "); 289 u16 i;
341 ofdm->constellation = QPSK; 290 for (i = 58; i < 87; i++)
342 break; 291 dib3000mc_write_word(state, i, impulse_noise_val[i-58]);
343 case DIB3000_CONSTELLATION_16QAM: 292
344 deb_getf("QAM16 "); 293 if (nfft == 1) {
345 ofdm->constellation = QAM_16; 294 dib3000mc_write_word(state, 58, 0x3b);
346 break; 295 dib3000mc_write_word(state, 84, 0x00);
347 case DIB3000_CONSTELLATION_64QAM: 296 dib3000mc_write_word(state, 85, 0x8200);
348 deb_getf("QAM64 ");
349 ofdm->constellation = QAM_64;
350 break;
351 default:
352 err("Unexpected constellation returned by TPS (%d)", tps_val);
353 break;
354 } 297 }
355 298
356 if (DIB3000MC_TP_HRCH(tps_val)) { 299 dib3000mc_write_word(state, 34, 0x1294);
357 deb_getf("HRCH ON "); 300 dib3000mc_write_word(state, 35, 0x1ff8);
358 cr = &ofdm->code_rate_LP; 301 if (mode == 1)
359 ofdm->code_rate_HP = FEC_NONE; 302 dib3000mc_write_word(state, 55, dib3000mc_read_word(state, 55) | (1 << 10));
360 switch (DIB3000MC_TP_ALPHA(tps_val)) { 303}
361 case DIB3000_ALPHA_0: 304
362 deb_getf("HIERARCHY_NONE "); 305static int dib3000mc_init(struct dvb_frontend *demod)
363 ofdm->hierarchy_information = HIERARCHY_NONE; 306{
364 break; 307 struct dib3000mc_state *state = demod->demodulator_priv;
365 case DIB3000_ALPHA_1: 308 struct dibx000_agc_config *agc = state->cfg->agc;
366 deb_getf("HIERARCHY_1 "); 309
367 ofdm->hierarchy_information = HIERARCHY_1; 310 // Restart Configuration
368 break; 311 dib3000mc_write_word(state, 1027, 0x8000);
369 case DIB3000_ALPHA_2: 312 dib3000mc_write_word(state, 1027, 0x0000);
370 deb_getf("HIERARCHY_2 "); 313
371 ofdm->hierarchy_information = HIERARCHY_2; 314 // power up the demod + mobility configuration
372 break; 315 dib3000mc_write_word(state, 140, 0x0000);
373 case DIB3000_ALPHA_4: 316 dib3000mc_write_word(state, 1031, 0);
374 deb_getf("HIERARCHY_4 "); 317
375 ofdm->hierarchy_information = HIERARCHY_4; 318 if (state->cfg->mobile_mode) {
376 break; 319 dib3000mc_write_word(state, 139, 0x0000);
377 default: 320 dib3000mc_write_word(state, 141, 0x0000);
378 err("Unexpected ALPHA value returned by TPS (%d)", tps_val); 321 dib3000mc_write_word(state, 175, 0x0002);
379 break; 322 dib3000mc_write_word(state, 1032, 0x0000);
380 }
381 cr_val = DIB3000MC_TP_FEC_CR_LP(tps_val);
382 } else { 323 } else {
383 deb_getf("HRCH OFF "); 324 dib3000mc_write_word(state, 139, 0x0001);
384 cr = &ofdm->code_rate_HP; 325 dib3000mc_write_word(state, 141, 0x0000);
385 ofdm->code_rate_LP = FEC_NONE; 326 dib3000mc_write_word(state, 175, 0x0000);
386 ofdm->hierarchy_information = HIERARCHY_NONE; 327 dib3000mc_write_word(state, 1032, 0x012C);
387 cr_val = DIB3000MC_TP_FEC_CR_HP(tps_val);
388 } 328 }
329 dib3000mc_write_word(state, 1033, 0);
389 330
390 switch (cr_val) { 331 // P_clk_cfg
391 case DIB3000_FEC_1_2: 332 dib3000mc_write_word(state, 1037, 12592);
392 deb_getf("FEC_1_2 ");
393 *cr = FEC_1_2;
394 break;
395 case DIB3000_FEC_2_3:
396 deb_getf("FEC_2_3 ");
397 *cr = FEC_2_3;
398 break;
399 case DIB3000_FEC_3_4:
400 deb_getf("FEC_3_4 ");
401 *cr = FEC_3_4;
402 break;
403 case DIB3000_FEC_5_6:
404 deb_getf("FEC_5_6 ");
405 *cr = FEC_4_5;
406 break;
407 case DIB3000_FEC_7_8:
408 deb_getf("FEC_7_8 ");
409 *cr = FEC_7_8;
410 break;
411 default:
412 err("Unexpected FEC returned by TPS (%d)", tps_val);
413 break;
414 }
415 333
416 switch (DIB3000MC_TP_GUARD(tps_val)) { 334 // other configurations
417 case DIB3000_GUARD_TIME_1_32:
418 deb_getf("GUARD_INTERVAL_1_32 ");
419 ofdm->guard_interval = GUARD_INTERVAL_1_32;
420 break;
421 case DIB3000_GUARD_TIME_1_16:
422 deb_getf("GUARD_INTERVAL_1_16 ");
423 ofdm->guard_interval = GUARD_INTERVAL_1_16;
424 break;
425 case DIB3000_GUARD_TIME_1_8:
426 deb_getf("GUARD_INTERVAL_1_8 ");
427 ofdm->guard_interval = GUARD_INTERVAL_1_8;
428 break;
429 case DIB3000_GUARD_TIME_1_4:
430 deb_getf("GUARD_INTERVAL_1_4 ");
431 ofdm->guard_interval = GUARD_INTERVAL_1_4;
432 break;
433 default:
434 err("Unexpected Guard Time returned by TPS (%d)", tps_val);
435 break;
436 }
437 335
438 switch (DIB3000MC_TP_FFT(tps_val)) { 336 // P_ctrl_sfreq
439 case DIB3000_TRANSMISSION_MODE_2K: 337 dib3000mc_write_word(state, 33, (5 << 0));
440 deb_getf("TRANSMISSION_MODE_2K "); 338 dib3000mc_write_word(state, 88, (1 << 10) | (0x10 << 0));
441 ofdm->transmission_mode = TRANSMISSION_MODE_2K; 339
442 break; 340 // Phase noise control
443 case DIB3000_TRANSMISSION_MODE_8K: 341 // P_fft_phacor_inh, P_fft_phacor_cpe, P_fft_powrange
444 deb_getf("TRANSMISSION_MODE_8K "); 342 dib3000mc_write_word(state, 99, (1 << 9) | (0x20 << 0));
445 ofdm->transmission_mode = TRANSMISSION_MODE_8K; 343
446 break; 344 if (state->cfg->phase_noise_mode == 0)
447 default: 345 dib3000mc_write_word(state, 111, 0x00);
448 err("unexpected transmission mode return by TPS (%d)", tps_val); 346 else
449 break; 347 dib3000mc_write_word(state, 111, 0x02);
450 } 348
451 deb_getf("\n"); 349 // P_agc_global
350 dib3000mc_write_word(state, 50, 0x8000);
351
352 // agc setup misc
353 dib3000mc_setup_pwm3_state(state);
354
355 // P_agc_counter_lock
356 dib3000mc_write_word(state, 53, 0x87);
357 // P_agc_counter_unlock
358 dib3000mc_write_word(state, 54, 0x87);
359
360 /* agc */
361 dib3000mc_write_word(state, 36, state->cfg->max_time);
362 dib3000mc_write_word(state, 37, agc->setup);
363 dib3000mc_write_word(state, 38, state->cfg->pwm3_value);
364 dib3000mc_write_word(state, 39, state->cfg->ln_adc_level);
365
366 // set_agc_loop_Bw
367 dib3000mc_write_word(state, 40, 0x0179);
368 dib3000mc_write_word(state, 41, 0x03f0);
369
370 dib3000mc_write_word(state, 42, agc->agc1_max);
371 dib3000mc_write_word(state, 43, agc->agc1_min);
372 dib3000mc_write_word(state, 44, agc->agc2_max);
373 dib3000mc_write_word(state, 45, agc->agc2_min);
374 dib3000mc_write_word(state, 46, (agc->agc1_pt1 << 8) | agc->agc1_pt2);
375 dib3000mc_write_word(state, 47, (agc->agc1_slope1 << 8) | agc->agc1_slope2);
376 dib3000mc_write_word(state, 48, (agc->agc2_pt1 << 8) | agc->agc2_pt2);
377 dib3000mc_write_word(state, 49, (agc->agc2_slope1 << 8) | agc->agc2_slope2);
378
379// Begin: TimeOut registers
380 // P_pha3_thres
381 dib3000mc_write_word(state, 110, 3277);
382 // P_timf_alpha = 6, P_corm_alpha = 6, P_corm_thres = 0x80
383 dib3000mc_write_word(state, 26, 0x6680);
384 // lock_mask0
385 dib3000mc_write_word(state, 1, 4);
386 // lock_mask1
387 dib3000mc_write_word(state, 2, 4);
388 // lock_mask2
389 dib3000mc_write_word(state, 3, 0x1000);
390 // P_search_maxtrial=1
391 dib3000mc_write_word(state, 5, 1);
392
393 dib3000mc_set_bandwidth(&state->demod, BANDWIDTH_8_MHZ);
394
395 // div_lock_mask
396 dib3000mc_write_word(state, 4, 0x814);
397
398 dib3000mc_write_word(state, 21, (1 << 9) | 0x164);
399 dib3000mc_write_word(state, 22, 0x463d);
400
401 // Spurious rm cfg
402 // P_cspu_regul, P_cspu_win_cut
403 dib3000mc_write_word(state, 120, 0x200f);
404 // P_adp_selec_monit
405 dib3000mc_write_word(state, 134, 0);
406
407 // Fec cfg
408 dib3000mc_write_word(state, 195, 0x10);
409
410 // diversity register: P_dvsy_sync_wait..
411 dib3000mc_write_word(state, 180, 0x2FF0);
412
413 // Impulse noise configuration
414 dib3000mc_set_impulse_noise(state, 0, 1);
415
416 // output mode set-up
417 dib3000mc_set_output_mode(state, OUTMODE_HIGH_Z);
418
419 /* close the i2c-gate */
420 dib3000mc_write_word(state, 769, (1 << 7) );
452 421
453 return 0; 422 return 0;
454} 423}
455 424
456static int dib3000mc_set_frontend(struct dvb_frontend* fe, 425static int dib3000mc_sleep(struct dvb_frontend *demod)
457 struct dvb_frontend_parameters *fep, int tuner)
458{ 426{
459 struct dib3000_state* state = fe->demodulator_priv; 427 struct dib3000mc_state *state = demod->demodulator_priv;
460 struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
461 int search_state,auto_val;
462 u16 val;
463 428
464 if (tuner && fe->ops.tuner_ops.set_params) { /* initial call from dvb */ 429 dib3000mc_write_word(state, 1037, dib3000mc_read_word(state, 1037) | 0x0003);
465 fe->ops.tuner_ops.set_params(fe, fep); 430 dib3000mc_write_word(state, 1031, 0xFFFF);
466 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); 431 dib3000mc_write_word(state, 1032, 0xFFFF);
467 432 dib3000mc_write_word(state, 1033, 0xFFF4); // **** Bin2
468 state->last_tuned_freq = fep->frequency;
469 // if (!scanboost) {
470 dib3000mc_set_timing(state,0,ofdm->transmission_mode,ofdm->bandwidth);
471 dib3000mc_init_auto_scan(state, ofdm->bandwidth, 0);
472 state->last_tuned_bw = ofdm->bandwidth;
473
474 wr_foreach(dib3000mc_reg_agc_bandwidth,dib3000mc_agc_bandwidth);
475 wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_AGC);
476 wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_OFF);
477
478 /* Default cfg isi offset adp */
479 wr_foreach(dib3000mc_reg_offset,dib3000mc_offset[0]);
480
481 wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT | DIB3000MC_ISI_INHIBIT);
482 dib3000mc_set_adp_cfg(state,ofdm->constellation);
483 wr(DIB3000MC_REG_UNK_133,DIB3000MC_UNK_133);
484
485 wr_foreach(dib3000mc_reg_bandwidth_general,dib3000mc_bandwidth_general);
486 /* power smoothing */
487 if (ofdm->bandwidth != BANDWIDTH_8_MHZ) {
488 wr_foreach(dib3000mc_reg_bw,dib3000mc_bw[0]);
489 } else {
490 wr_foreach(dib3000mc_reg_bw,dib3000mc_bw[3]);
491 }
492 auto_val = 0;
493 dib3000mc_set_general_cfg(state,fep,&auto_val);
494 dib3000mc_set_impulse_noise(state,0,ofdm->constellation,ofdm->bandwidth);
495
496 val = rd(DIB3000MC_REG_DEMOD_PARM);
497 wr(DIB3000MC_REG_DEMOD_PARM,val|DIB3000MC_DEMOD_RST_DEMOD_ON);
498 wr(DIB3000MC_REG_DEMOD_PARM,val);
499 // }
500 msleep(70);
501
502 /* something has to be auto searched */
503 if (auto_val) {
504 int as_count=0;
505
506 deb_setf("autosearch enabled.\n");
507
508 val = rd(DIB3000MC_REG_DEMOD_PARM);
509 wr(DIB3000MC_REG_DEMOD_PARM,val | DIB3000MC_DEMOD_RST_AUTO_SRCH_ON);
510 wr(DIB3000MC_REG_DEMOD_PARM,val);
511
512 while ((search_state = dib3000_search_status(
513 rd(DIB3000MC_REG_AS_IRQ),1)) < 0 && as_count++ < 100)
514 msleep(10);
515
516 deb_info("search_state after autosearch %d after %d checks\n",search_state,as_count);
517
518 if (search_state == 1) {
519 struct dvb_frontend_parameters feps;
520 if (dib3000mc_get_frontend(fe, &feps) == 0) {
521 deb_setf("reading tuning data from frontend succeeded.\n");
522 return dib3000mc_set_frontend(fe, &feps, 0);
523 }
524 }
525 } else {
526 dib3000mc_set_impulse_noise(state,0,ofdm->transmission_mode,ofdm->bandwidth);
527 wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT|DIB3000MC_ISI_ACTIVATE);
528 dib3000mc_set_adp_cfg(state,ofdm->constellation);
529
530 /* set_offset_cfg */
531 wr_foreach(dib3000mc_reg_offset,
532 dib3000mc_offset[(ofdm->transmission_mode == TRANSMISSION_MODE_8K)+1]);
533 }
534 } else { /* second call, after autosearch (fka: set_WithKnownParams) */
535// dib3000mc_set_timing(state,1,ofdm->transmission_mode,ofdm->bandwidth);
536
537 auto_val = 0;
538 dib3000mc_set_general_cfg(state,fep,&auto_val);
539 if (auto_val)
540 deb_info("auto_val is true, even though an auto search was already performed.\n");
541
542 dib3000mc_set_impulse_noise(state,0,ofdm->constellation,ofdm->bandwidth);
543
544 val = rd(DIB3000MC_REG_DEMOD_PARM);
545 wr(DIB3000MC_REG_DEMOD_PARM,val | DIB3000MC_DEMOD_RST_AUTO_SRCH_ON);
546 wr(DIB3000MC_REG_DEMOD_PARM,val);
547 433
548 msleep(30); 434 return 0;
435}
549 436
550 wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT|DIB3000MC_ISI_ACTIVATE); 437static void dib3000mc_set_adp_cfg(struct dib3000mc_state *state, s16 qam)
551 dib3000mc_set_adp_cfg(state,ofdm->constellation); 438{
552 wr_foreach(dib3000mc_reg_offset, 439 u16 cfg[4] = { 0 },reg;
553 dib3000mc_offset[(ofdm->transmission_mode == TRANSMISSION_MODE_8K)+1]); 440 switch (qam) {
441 case 0:
442 cfg[0] = 0x099a; cfg[1] = 0x7fae; cfg[2] = 0x0333; cfg[3] = 0x7ff0;
443 break;
444 case 1:
445 cfg[0] = 0x023d; cfg[1] = 0x7fdf; cfg[2] = 0x00a4; cfg[3] = 0x7ff0;
446 break;
447 case 2:
448 cfg[0] = 0x0148; cfg[1] = 0x7ff0; cfg[2] = 0x00a4; cfg[3] = 0x7ff8;
449 break;
554 } 450 }
555 return 0; 451 for (reg = 129; reg < 133; reg++)
452 dib3000mc_write_word(state, reg, cfg[reg - 129]);
556} 453}
557 454
558static int dib3000mc_fe_init(struct dvb_frontend* fe, int mobile_mode) 455static void dib3000mc_set_channel_cfg(struct dib3000mc_state *state, struct dibx000_ofdm_channel *chan, u16 seq)
559{ 456{
560 struct dib3000_state *state = fe->demodulator_priv; 457 u16 tmp;
561 deb_info("init start\n");
562
563 state->timing_offset = 0;
564 state->timing_offset_comp_done = 0;
565 458
566 wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_CONFIG); 459 dib3000mc_set_timing(state, chan->nfft, chan->Bw, 0);
567 wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_OFF);
568 wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_UP);
569 wr(DIB3000MC_REG_CLK_CFG_2,DIB3000MC_CLK_CFG_2_PUP_MOBILE);
570 wr(DIB3000MC_REG_CLK_CFG_3,DIB3000MC_CLK_CFG_3_POWER_UP);
571 wr(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_INIT);
572 460
573 wr(DIB3000MC_REG_RST_UNC,DIB3000MC_RST_UNC_OFF); 461// if (boost)
574 wr(DIB3000MC_REG_UNK_19,DIB3000MC_UNK_19); 462// dib3000mc_write_word(state, 100, (11 << 6) + 6);
463// else
464 dib3000mc_write_word(state, 100, (16 << 6) + 9);
575 465
576 wr(33,5); 466 dib3000mc_write_word(state, 1027, 0x0800);
577 wr(36,81); 467 dib3000mc_write_word(state, 1027, 0x0000);
578 wr(DIB3000MC_REG_UNK_88,DIB3000MC_UNK_88);
579 468
580 wr(DIB3000MC_REG_UNK_99,DIB3000MC_UNK_99); 469 //Default cfg isi offset adp
581 wr(DIB3000MC_REG_UNK_111,DIB3000MC_UNK_111_PH_N_MODE_0); /* phase noise algo off */ 470 dib3000mc_write_word(state, 26, 0x6680);
471 dib3000mc_write_word(state, 29, 0x1273);
472 dib3000mc_write_word(state, 33, 5);
473 dib3000mc_set_adp_cfg(state, 1);
474 dib3000mc_write_word(state, 133, 15564);
582 475
583 /* mobile mode - portable reception */ 476 dib3000mc_write_word(state, 12 , 0x0);
584 wr_foreach(dib3000mc_reg_mobile_mode,dib3000mc_mobile_mode[1]); 477 dib3000mc_write_word(state, 13 , 0x3e8);
478 dib3000mc_write_word(state, 14 , 0x0);
479 dib3000mc_write_word(state, 15 , 0x3f2);
585 480
586/* TUNER_PANASONIC_ENV57H12D5: */ 481 dib3000mc_write_word(state, 93,0);
587 wr_foreach(dib3000mc_reg_agc_bandwidth,dib3000mc_agc_bandwidth); 482 dib3000mc_write_word(state, 94,0);
588 wr_foreach(dib3000mc_reg_agc_bandwidth_general,dib3000mc_agc_bandwidth_general); 483 dib3000mc_write_word(state, 95,0);
589 wr_foreach(dib3000mc_reg_agc,dib3000mc_agc_tuner[1]); 484 dib3000mc_write_word(state, 96,0);
485 dib3000mc_write_word(state, 97,0);
486 dib3000mc_write_word(state, 98,0);
590 487
591 wr(DIB3000MC_REG_UNK_110,DIB3000MC_UNK_110); 488 dib3000mc_set_impulse_noise(state, 0, chan->nfft);
592 wr(26,0x6680);
593 wr(DIB3000MC_REG_UNK_1,DIB3000MC_UNK_1);
594 wr(DIB3000MC_REG_UNK_2,DIB3000MC_UNK_2);
595 wr(DIB3000MC_REG_UNK_3,DIB3000MC_UNK_3);
596 wr(DIB3000MC_REG_SEQ_TPS,DIB3000MC_SEQ_TPS_DEFAULT);
597 489
598 wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_8mhz); 490 tmp = ((chan->nfft & 0x1) << 7) | (chan->guard << 5) | (chan->nqam << 3) | chan->vit_alpha;
599 wr_foreach(dib3000mc_reg_bandwidth_general,dib3000mc_bandwidth_general); 491 dib3000mc_write_word(state, 0, tmp);
600 492
601 wr(DIB3000MC_REG_UNK_4,DIB3000MC_UNK_4); 493 dib3000mc_write_word(state, 5, seq);
602 494
603 wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_OFF); 495 tmp = (chan->vit_hrch << 4) | (chan->vit_select_hp);
604 wr(DIB3000MC_REG_SET_DDS_FREQ_LSB,DIB3000MC_DDS_FREQ_LSB); 496 if (!chan->vit_hrch || (chan->vit_hrch && chan->vit_select_hp))
497 tmp |= chan->vit_code_rate_hp << 1;
498 else
499 tmp |= chan->vit_code_rate_lp << 1;
500 dib3000mc_write_word(state, 181, tmp);
605 501
606 dib3000mc_set_timing(state,0,TRANSMISSION_MODE_8K,BANDWIDTH_8_MHZ); 502 // diversity synchro delay
607// wr_foreach(dib3000mc_reg_timing_freq,dib3000mc_timing_freq[3]); 503 tmp = dib3000mc_read_word(state, 180) & 0x000f;
504 tmp |= ((chan->nfft == 0) ? 64 : 256) * ((1 << (chan->guard)) * 3 / 2) << 4; // add 50% SFN margin
505 dib3000mc_write_word(state, 180, tmp);
608 506
609 wr(DIB3000MC_REG_UNK_120,DIB3000MC_UNK_120); 507 // restart demod
610 wr(DIB3000MC_REG_UNK_134,DIB3000MC_UNK_134); 508 tmp = dib3000mc_read_word(state, 0);
611 wr(DIB3000MC_REG_FEC_CFG,DIB3000MC_FEC_CFG); 509 dib3000mc_write_word(state, 0, tmp | (1 << 9));
510 dib3000mc_write_word(state, 0, tmp);
612 511
613 wr(DIB3000MC_REG_DIVERSITY3,DIB3000MC_DIVERSITY3_IN_OFF); 512 msleep(30);
614 513
615 dib3000mc_set_impulse_noise(state,0,TRANSMISSION_MODE_8K,BANDWIDTH_8_MHZ); 514 dib3000mc_set_impulse_noise(state, state->cfg->impulse_noise_mode, chan->nfft);
515}
616 516
617/* output mode control, just the MPEG2_SLAVE */ 517static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dibx000_ofdm_channel *chan)
618// set_or(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_SLAVE); 518{
619 wr(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_SLAVE); 519 struct dib3000mc_state *state = demod->demodulator_priv;
620 wr(DIB3000MC_REG_SMO_MODE,DIB3000MC_SMO_MODE_SLAVE); 520 u16 reg;
621 wr(DIB3000MC_REG_FIFO_THRESHOLD,DIB3000MC_FIFO_THRESHOLD_SLAVE); 521// u32 val;
622 wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_SLAVE); 522 struct dibx000_ofdm_channel fchan;
623 523
624/* MPEG2_PARALLEL_CONTINUOUS_CLOCK 524 INIT_OFDM_CHANNEL(&fchan);
625 wr(DIB3000MC_REG_OUTMODE, 525 fchan = *chan;
626 DIB3000MC_SET_OUTMODE(DIB3000MC_OM_PAR_CONT_CLK,
627 rd(DIB3000MC_REG_OUTMODE)));
628 526
629 wr(DIB3000MC_REG_SMO_MODE,
630 DIB3000MC_SMO_MODE_DEFAULT |
631 DIB3000MC_SMO_MODE_188);
632 527
633 wr(DIB3000MC_REG_FIFO_THRESHOLD,DIB3000MC_FIFO_THRESHOLD_DEFAULT); 528 /* a channel for autosearch */
634 wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_DIV_OUT_ON); 529 reg = 0;
635*/ 530 if (chan->nfft == -1 && chan->guard == -1) reg = 7;
531 if (chan->nfft == -1 && chan->guard != -1) reg = 2;
532 if (chan->nfft != -1 && chan->guard == -1) reg = 3;
636 533
637/* diversity */ 534 fchan.nfft = 1; fchan.guard = 0; fchan.nqam = 2;
638 wr(DIB3000MC_REG_DIVERSITY1,DIB3000MC_DIVERSITY1_DEFAULT); 535 fchan.vit_alpha = 1; fchan.vit_code_rate_hp = 2; fchan.vit_code_rate_lp = 2;
639 wr(DIB3000MC_REG_DIVERSITY2,DIB3000MC_DIVERSITY2_DEFAULT); 536 fchan.vit_hrch = 0; fchan.vit_select_hp = 1;
640 537
641 set_and(DIB3000MC_REG_DIVERSITY3,DIB3000MC_DIVERSITY3_IN_OFF); 538 dib3000mc_set_channel_cfg(state, &fchan, reg);
642 539
643 set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_DIV_IN_OFF); 540 reg = dib3000mc_read_word(state, 0);
541 dib3000mc_write_word(state, 0, reg | (1 << 8));
542 dib3000mc_write_word(state, 0, reg);
644 543
645 deb_info("init end\n");
646 return 0; 544 return 0;
647} 545}
648static int dib3000mc_read_status(struct dvb_frontend* fe, fe_status_t *stat) 546
547static int dib3000mc_autosearch_is_irq(struct dvb_frontend *demod)
649{ 548{
650 struct dib3000_state* state = fe->demodulator_priv; 549 struct dib3000mc_state *state = demod->demodulator_priv;
651 u16 lock = rd(DIB3000MC_REG_LOCKING); 550 u16 irq_pending = dib3000mc_read_word(state, 511);
652 551
653 *stat = 0; 552 if (irq_pending & 0x1) // failed
654 if (DIB3000MC_AGC_LOCK(lock)) 553 return 1;
655 *stat |= FE_HAS_SIGNAL;
656 if (DIB3000MC_CARRIER_LOCK(lock))
657 *stat |= FE_HAS_CARRIER;
658 if (DIB3000MC_TPS_LOCK(lock))
659 *stat |= FE_HAS_VITERBI;
660 if (DIB3000MC_MPEG_SYNC_LOCK(lock))
661 *stat |= (FE_HAS_SYNC | FE_HAS_LOCK);
662 554
663 deb_stat("actual status is %2x fifo_level: %x,244: %x, 206: %x, 207: %x, 1040: %x\n",*stat,rd(510),rd(244),rd(206),rd(207),rd(1040)); 555 if (irq_pending & 0x2) // succeeded
556 return 2;
664 557
665 return 0; 558 return 0; // still pending
666} 559}
667 560
668static int dib3000mc_read_ber(struct dvb_frontend* fe, u32 *ber) 561static int dib3000mc_tune(struct dvb_frontend *demod, struct dibx000_ofdm_channel *ch)
669{ 562{
670 struct dib3000_state* state = fe->demodulator_priv; 563 struct dib3000mc_state *state = demod->demodulator_priv;
671 *ber = ((rd(DIB3000MC_REG_BER_MSB) << 16) | rd(DIB3000MC_REG_BER_LSB)); 564
565 // ** configure demod **
566 dib3000mc_set_channel_cfg(state, ch, 0);
567
568 // activates isi
569 dib3000mc_write_word(state, 29, 0x1073);
570
571 dib3000mc_set_adp_cfg(state, (u8)ch->nqam);
572
573 if (ch->nfft == 1) {
574 dib3000mc_write_word(state, 26, 38528);
575 dib3000mc_write_word(state, 33, 8);
576 } else {
577 dib3000mc_write_word(state, 26, 30336);
578 dib3000mc_write_word(state, 33, 6);
579 }
580
581 // if (lock)
582 // dib3000mc_set_timing(state, ch->nfft, ch->Bw, 1);
583
672 return 0; 584 return 0;
673} 585}
674 586
675static int dib3000mc_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) 587static int dib3000mc_demod_output_mode(struct dvb_frontend *demod, int mode)
676{ 588{
677 struct dib3000_state* state = fe->demodulator_priv; 589 struct dib3000mc_state *state = demod->demodulator_priv;
678 590 return dib3000mc_set_output_mode(state, mode);
679 *unc = rd(DIB3000MC_REG_PACKET_ERRORS);
680 return 0;
681} 591}
682 592
683/* see dib3000mb.c for calculation comments */ 593static int dib3000mc_i2c_enumeration(struct dvb_frontend *demod[], int no_of_demods, u8 default_addr)
684static int dib3000mc_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
685{ 594{
686 struct dib3000_state* state = fe->demodulator_priv; 595 struct dib3000mc_state *st;
687 u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB); 596 int k,ret=0;
688 *strength = (((val >> 6) & 0xff) << 8) + (val & 0x3f); 597 u8 new_addr;
598
599 static u8 DIB3000MC_I2C_ADDRESS[] = {20,22,24,26};
600
601 for (k = no_of_demods-1; k >= 0; k--) {
602 st = demod[k]->demodulator_priv;
603
604 /* designated i2c address */
605 new_addr = DIB3000MC_I2C_ADDRESS[k];
606
607 st->i2c_addr = new_addr;
608 if (dib3000mc_identify(st) != 0) {
609 st->i2c_addr = default_addr;
610 if (dib3000mc_identify(st) != 0) {
611 dprintk("-E- DiB3000P/MC #%d: not identified\n", k);
612 return -EINVAL;
613 }
614 }
615
616 /* turn on div_out */
617 dib3000mc_demod_output_mode(demod[k], OUTMODE_MPEG2_PAR_CONT_CLK);
618
619 // set new i2c address and force divstr (Bit 1) to value 0 (Bit 0)
620 ret |= dib3000mc_write_word(st, 1024, (new_addr << 3) | 0x1);
621 st->i2c_addr = new_addr;
622 }
623
624 for (k = 0; k < no_of_demods; k++) {
625 st = demod[k]->demodulator_priv;
626
627 ret |= dib3000mc_write_word(st, 1024, st->i2c_addr << 3);
689 628
690 deb_stat("signal: mantisse = %d, exponent = %d\n",(*strength >> 8) & 0xff, *strength & 0xff); 629 /* turn off data output */
630 dib3000mc_demod_output_mode(demod[k],OUTMODE_HIGH_Z);
631 dib3000mc_write_word(st, 769, (1 << 7) );
632
633 }
691 return 0; 634 return 0;
692} 635}
693 636
694/* see dib3000mb.c for calculation comments */ 637struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating)
695static int dib3000mc_read_snr(struct dvb_frontend* fe, u16 *snr)
696{ 638{
697 struct dib3000_state* state = fe->demodulator_priv; 639 struct dib3000mc_state *st = demod->demodulator_priv;
698 u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB), 640 return dibx000_get_i2c_adapter(&st->i2c_master, DIBX000_I2C_INTERFACE_TUNER, gating);
699 val2 = rd(DIB3000MC_REG_SIGNAL_NOISE_MSB); 641}
700 u16 sig,noise;
701 642
702 sig = (((val >> 6) & 0xff) << 8) + (val & 0x3f); 643EXPORT_SYMBOL(dib3000mc_get_tuner_i2c_master);
703 noise = (((val >> 4) & 0xff) << 8) + ((val & 0xf) << 2) + ((val2 >> 14) & 0x3); 644
704 if (noise == 0) 645static int dib3000mc_get_frontend(struct dvb_frontend* fe,
705 *snr = 0xffff; 646 struct dvb_frontend_parameters *fep)
706 else 647{
707 *snr = (u16) sig/noise; 648 struct dib3000mc_state *state = fe->demodulator_priv;
649 u16 tps = dib3000mc_read_word(state,458);
650
651 fep->inversion = INVERSION_AUTO;
652
653 fep->u.ofdm.bandwidth = state->current_bandwidth;
654
655 switch ((tps >> 8) & 0x1) {
656 case 0: fep->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K; break;
657 case 1: fep->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K; break;
658 }
659
660 switch (tps & 0x3) {
661 case 0: fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_32; break;
662 case 1: fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_16; break;
663 case 2: fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_8; break;
664 case 3: fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_4; break;
665 }
666
667 switch ((tps >> 13) & 0x3) {
668 case 0: fep->u.ofdm.constellation = QPSK; break;
669 case 1: fep->u.ofdm.constellation = QAM_16; break;
670 case 2:
671 default: fep->u.ofdm.constellation = QAM_64; break;
672 }
673
674 /* as long as the frontend_param structure is fixed for hierarchical transmission I refuse to use it */
675 /* (tps >> 12) & 0x1 == hrch is used, (tps >> 9) & 0x7 == alpha */
676
677 fep->u.ofdm.hierarchy_information = HIERARCHY_NONE;
678 switch ((tps >> 5) & 0x7) {
679 case 1: fep->u.ofdm.code_rate_HP = FEC_1_2; break;
680 case 2: fep->u.ofdm.code_rate_HP = FEC_2_3; break;
681 case 3: fep->u.ofdm.code_rate_HP = FEC_3_4; break;
682 case 5: fep->u.ofdm.code_rate_HP = FEC_5_6; break;
683 case 7:
684 default: fep->u.ofdm.code_rate_HP = FEC_7_8; break;
685
686 }
687
688 switch ((tps >> 2) & 0x7) {
689 case 1: fep->u.ofdm.code_rate_LP = FEC_1_2; break;
690 case 2: fep->u.ofdm.code_rate_LP = FEC_2_3; break;
691 case 3: fep->u.ofdm.code_rate_LP = FEC_3_4; break;
692 case 5: fep->u.ofdm.code_rate_LP = FEC_5_6; break;
693 case 7:
694 default: fep->u.ofdm.code_rate_LP = FEC_7_8; break;
695 }
708 696
709 deb_stat("signal: mantisse = %d, exponent = %d\n",(sig >> 8) & 0xff, sig & 0xff);
710 deb_stat("noise: mantisse = %d, exponent = %d\n",(noise >> 8) & 0xff, noise & 0xff);
711 deb_stat("snr: %d\n",*snr);
712 return 0; 697 return 0;
713} 698}
714 699
715static int dib3000mc_sleep(struct dvb_frontend* fe) 700static int dib3000mc_set_frontend(struct dvb_frontend* fe,
701 struct dvb_frontend_parameters *fep)
716{ 702{
717 struct dib3000_state* state = fe->demodulator_priv; 703 struct dib3000mc_state *state = fe->demodulator_priv;
704 struct dibx000_ofdm_channel ch;
718 705
719 set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_PWR_DOWN); 706 INIT_OFDM_CHANNEL(&ch);
720 wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_DOWN); 707 FEP2DIB(fep,&ch);
721 wr(DIB3000MC_REG_CLK_CFG_2,DIB3000MC_CLK_CFG_2_POWER_DOWN); 708
722 wr(DIB3000MC_REG_CLK_CFG_3,DIB3000MC_CLK_CFG_3_POWER_DOWN); 709 state->current_bandwidth = fep->u.ofdm.bandwidth;
723 return 0; 710 dib3000mc_set_bandwidth(fe, fep->u.ofdm.bandwidth);
711
712 if (fe->ops.tuner_ops.set_params) {
713 fe->ops.tuner_ops.set_params(fe, fep);
714 msleep(100);
715 }
716
717 if (fep->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO ||
718 fep->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO ||
719 fep->u.ofdm.constellation == QAM_AUTO ||
720 fep->u.ofdm.code_rate_HP == FEC_AUTO) {
721 int i = 100, found;
722
723 dib3000mc_autosearch_start(fe, &ch);
724 do {
725 msleep(1);
726 found = dib3000mc_autosearch_is_irq(fe);
727 } while (found == 0 && i--);
728
729 dprintk("autosearch returns: %d\n",found);
730 if (found == 0 || found == 1)
731 return 0; // no channel found
732
733 dib3000mc_get_frontend(fe, fep);
734 FEP2DIB(fep,&ch);
735 }
736
737 /* make this a config parameter */
738 dib3000mc_set_output_mode(state, OUTMODE_MPEG2_FIFO);
739
740 return dib3000mc_tune(fe, &ch);
724} 741}
725 742
726static int dib3000mc_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) 743static int dib3000mc_read_status(struct dvb_frontend *fe, fe_status_t *stat)
727{ 744{
728 tune->min_delay_ms = 1000; 745 struct dib3000mc_state *state = fe->demodulator_priv;
746 u16 lock = dib3000mc_read_word(state, 509);
747
748 *stat = 0;
749
750 if (lock & 0x8000)
751 *stat |= FE_HAS_SIGNAL;
752 if (lock & 0x3000)
753 *stat |= FE_HAS_CARRIER;
754 if (lock & 0x0100)
755 *stat |= FE_HAS_VITERBI;
756 if (lock & 0x0010)
757 *stat |= FE_HAS_SYNC;
758 if (lock & 0x0008)
759 *stat |= FE_HAS_LOCK;
760
729 return 0; 761 return 0;
730} 762}
731 763
732static int dib3000mc_fe_init_nonmobile(struct dvb_frontend* fe) 764static int dib3000mc_read_ber(struct dvb_frontend *fe, u32 *ber)
733{ 765{
734 return dib3000mc_fe_init(fe, 0); 766 struct dib3000mc_state *state = fe->demodulator_priv;
767 *ber = (dib3000mc_read_word(state, 500) << 16) | dib3000mc_read_word(state, 501);
768 return 0;
735} 769}
736 770
737static int dib3000mc_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep) 771static int dib3000mc_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
738{ 772{
739 return dib3000mc_set_frontend(fe, fep, 1); 773 struct dib3000mc_state *state = fe->demodulator_priv;
774 *unc = dib3000mc_read_word(state, 508);
775 return 0;
740} 776}
741 777
742static void dib3000mc_release(struct dvb_frontend* fe) 778static int dib3000mc_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
743{ 779{
744 struct dib3000_state *state = fe->demodulator_priv; 780 struct dib3000mc_state *state = fe->demodulator_priv;
745 kfree(state); 781 u16 val = dib3000mc_read_word(state, 392);
782 *strength = 65535 - val;
783 return 0;
746} 784}
747 785
748/* pid filter and transfer stuff */ 786static int dib3000mc_read_snr(struct dvb_frontend* fe, u16 *snr)
749static int dib3000mc_pid_control(struct dvb_frontend *fe,int index, int pid,int onoff)
750{ 787{
751 struct dib3000_state *state = fe->demodulator_priv; 788 *snr = 0x0000;
752 pid = (onoff ? pid | DIB3000_ACTIVATE_PID_FILTERING : 0);
753 wr(index+DIB3000MC_REG_FIRST_PID,pid);
754 return 0; 789 return 0;
755} 790}
756 791
757static int dib3000mc_fifo_control(struct dvb_frontend *fe, int onoff) 792static int dib3000mc_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
758{ 793{
759 struct dib3000_state *state = fe->demodulator_priv; 794 tune->min_delay_ms = 1000;
760 u16 tmp = rd(DIB3000MC_REG_SMO_MODE);
761
762 deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling");
763
764 if (onoff) {
765 deb_xfer("%d %x\n",tmp & DIB3000MC_SMO_MODE_FIFO_UNFLUSH,tmp & DIB3000MC_SMO_MODE_FIFO_UNFLUSH);
766 wr(DIB3000MC_REG_SMO_MODE,tmp & DIB3000MC_SMO_MODE_FIFO_UNFLUSH);
767 } else {
768 deb_xfer("%d %x\n",tmp | DIB3000MC_SMO_MODE_FIFO_FLUSH,tmp | DIB3000MC_SMO_MODE_FIFO_FLUSH);
769 wr(DIB3000MC_REG_SMO_MODE,tmp | DIB3000MC_SMO_MODE_FIFO_FLUSH);
770 }
771 return 0; 795 return 0;
772} 796}
773 797
774static int dib3000mc_pid_parse(struct dvb_frontend *fe, int onoff) 798static void dib3000mc_release(struct dvb_frontend *fe)
775{ 799{
776 struct dib3000_state *state = fe->demodulator_priv; 800 struct dib3000mc_state *state = fe->demodulator_priv;
777 u16 tmp = rd(DIB3000MC_REG_SMO_MODE); 801 dibx000_exit_i2c_master(&state->i2c_master);
778 802 kfree(state);
779 deb_xfer("%s pid parsing\n",onoff ? "enabling" : "disabling");
780
781 if (onoff) {
782 wr(DIB3000MC_REG_SMO_MODE,tmp | DIB3000MC_SMO_MODE_PID_PARSE);
783 } else {
784 wr(DIB3000MC_REG_SMO_MODE,tmp & DIB3000MC_SMO_MODE_NO_PID_PARSE);
785 }
786 return 0;
787} 803}
788 804
789static int dib3000mc_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr) 805int dib3000mc_pid_control(struct dvb_frontend *fe, int index, int pid,int onoff)
790{ 806{
791 struct dib3000_state *state = fe->demodulator_priv; 807 struct dib3000mc_state *state = fe->demodulator_priv;
792 if (onoff) { 808 dib3000mc_write_word(state, 212 + index, onoff ? (1 << 13) | pid : 0);
793 wr(DIB3000MC_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr));
794 } else {
795 wr(DIB3000MC_REG_TUNER, DIB3000_TUNER_WRITE_DISABLE(pll_addr));
796 }
797 return 0; 809 return 0;
798} 810}
811EXPORT_SYMBOL(dib3000mc_pid_control);
799 812
800static int dib3000mc_demod_init(struct dib3000_state *state) 813int dib3000mc_pid_parse(struct dvb_frontend *fe, int onoff)
801{ 814{
802 u16 default_addr = 0x0a; 815 struct dib3000mc_state *state = fe->demodulator_priv;
803 /* first init */ 816 u16 tmp = dib3000mc_read_word(state, 206) & ~(1 << 4);
804 if (state->config.demod_address != default_addr) { 817 tmp |= (onoff << 4);
805 deb_info("initializing the demod the first time. Setting demod addr to 0x%x\n",default_addr); 818 return dib3000mc_write_word(state, 206, tmp);
806 wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_DIV_OUT_ON);
807 wr(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_PAR_CONT_CLK);
808
809 wr(DIB3000MC_REG_RST_I2C_ADDR,
810 DIB3000MC_DEMOD_ADDR(default_addr) |
811 DIB3000MC_DEMOD_ADDR_ON);
812
813 state->config.demod_address = default_addr;
814
815 wr(DIB3000MC_REG_RST_I2C_ADDR,
816 DIB3000MC_DEMOD_ADDR(default_addr));
817 } else
818 deb_info("demod is already initialized. Demod addr: 0x%x\n",state->config.demod_address);
819 return 0;
820} 819}
820EXPORT_SYMBOL(dib3000mc_pid_parse);
821 821
822void dib3000mc_set_config(struct dvb_frontend *fe, struct dib3000mc_config *cfg)
823{
824 struct dib3000mc_state *state = fe->demodulator_priv;
825 state->cfg = cfg;
826}
827EXPORT_SYMBOL(dib3000mc_set_config);
822 828
823static struct dvb_frontend_ops dib3000mc_ops; 829static struct dvb_frontend_ops dib3000mc_ops;
824 830
825struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config, 831int dib3000mc_attach(struct i2c_adapter *i2c_adap, int no_of_demods, u8 default_addr, u8 do_i2c_enum, struct dib3000mc_config cfg[], struct dvb_frontend *demod[])
826 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
827{ 832{
828 struct dib3000_state* state = NULL; 833 struct dib3000mc_state *st;
829 u16 devid; 834 int k, num=0;
830 835
831 /* allocate memory for the internal state */ 836 if (no_of_demods < 1)
832 state = kzalloc(sizeof(struct dib3000_state), GFP_KERNEL); 837 return -EINVAL;
833 if (state == NULL)
834 goto error;
835 838
836 /* setup the state */ 839 for (k = 0; k < no_of_demods; k++) {
837 state->i2c = i2c; 840 st = kzalloc(sizeof(struct dib3000mc_state), GFP_KERNEL);
838 memcpy(&state->config,config,sizeof(struct dib3000_config)); 841 if (st == NULL)
842 goto error;
839 843
840 /* check for the correct demod */ 844 num++;
841 if (rd(DIB3000_REG_MANUFACTOR_ID) != DIB3000_I2C_ID_DIBCOM)
842 goto error;
843 845
844 devid = rd(DIB3000_REG_DEVICE_ID); 846 st->cfg = &cfg[k];
845 if (devid != DIB3000MC_DEVICE_ID && devid != DIB3000P_DEVICE_ID) 847 // st->gpio_val = cfg[k].gpio_val;
846 goto error; 848 // st->gpio_dir = cfg[k].gpio_dir;
849 st->i2c_adap = i2c_adap;
847 850
848 switch (devid) { 851 demod[k] = &st->demod;
849 case DIB3000MC_DEVICE_ID: 852 demod[k]->demodulator_priv = st;
850 info("Found a DiBcom 3000M-C, interesting..."); 853 memcpy(&st->demod.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops));
851 break;
852 case DIB3000P_DEVICE_ID:
853 info("Found a DiBcom 3000P.");
854 break;
855 }
856 854
857 /* create dvb_frontend */ 855// INIT_COMPONENT_REGISTER_ACCESS(&st->register_access, 12, 16, dib7000p_register_read, dib7000p_register_write, st);
858 memcpy(&state->frontend.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops)); 856// demod[k]->register_access = &st->register_access;
859 state->frontend.demodulator_priv = state; 857 }
860 858
861 /* set the xfer operations */ 859 if (do_i2c_enum) {
862 xfer_ops->pid_parse = dib3000mc_pid_parse; 860 if (dib3000mc_i2c_enumeration(demod,no_of_demods,default_addr) != 0)
863 xfer_ops->fifo_ctrl = dib3000mc_fifo_control; 861 goto error;
864 xfer_ops->pid_ctrl = dib3000mc_pid_control; 862 } else {
865 xfer_ops->tuner_pass_ctrl = dib3000mc_tuner_pass_ctrl; 863 st = demod[0]->demodulator_priv;
864 st->i2c_addr = default_addr;
865 if (dib3000mc_identify(st) != 0)
866 goto error;
867 }
866 868
867 dib3000mc_demod_init(state); 869 for (k = 0; k < num; k++) {
870 st = demod[k]->demodulator_priv;
871 dibx000_init_i2c_master(&st->i2c_master, DIB3000MC, st->i2c_adap, st->i2c_addr);
872 }
868 873
869 return &state->frontend; 874 return 0;
870 875
871error: 876error:
872 kfree(state); 877 for (k = 0; k < num; k++) {
873 return NULL; 878 kfree(demod[k]->demodulator_priv);
879 demod[k] = NULL;
880 }
881 return -EINVAL;
874} 882}
883
875EXPORT_SYMBOL(dib3000mc_attach); 884EXPORT_SYMBOL(dib3000mc_attach);
876 885
877static struct dvb_frontend_ops dib3000mc_ops = { 886static struct dvb_frontend_ops dib3000mc_ops = {
878
879 .info = { 887 .info = {
880 .name = "DiBcom 3000P/M-C DVB-T", 888 .name = "DiBcom 3000MC/P",
881 .type = FE_OFDM, 889 .type = FE_OFDM,
882 .frequency_min = 44250000, 890 .frequency_min = 44250000,
883 .frequency_max = 867250000, 891 .frequency_max = 867250000,
884 .frequency_stepsize = 62500, 892 .frequency_stepsize = 62500,
885 .caps = FE_CAN_INVERSION_AUTO | 893 .caps = FE_CAN_INVERSION_AUTO |
886 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 894 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
887 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 895 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
888 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | 896 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
889 FE_CAN_TRANSMISSION_MODE_AUTO | 897 FE_CAN_TRANSMISSION_MODE_AUTO |
890 FE_CAN_GUARD_INTERVAL_AUTO | 898 FE_CAN_GUARD_INTERVAL_AUTO |
891 FE_CAN_RECOVER | 899 FE_CAN_RECOVER |
892 FE_CAN_HIERARCHY_AUTO, 900 FE_CAN_HIERARCHY_AUTO,
893 }, 901 },
894 902
895 .release = dib3000mc_release, 903 .release = dib3000mc_release,
896 904
897 .init = dib3000mc_fe_init_nonmobile, 905 .init = dib3000mc_init,
898 .sleep = dib3000mc_sleep, 906 .sleep = dib3000mc_sleep,
899 907
900 .set_frontend = dib3000mc_set_frontend_and_tuner, 908 .set_frontend = dib3000mc_set_frontend,
901 .get_frontend = dib3000mc_get_frontend, 909 .get_tune_settings = dib3000mc_fe_get_tune_settings,
902 .get_tune_settings = dib3000mc_fe_get_tune_settings, 910 .get_frontend = dib3000mc_get_frontend,
903 911
904 .read_status = dib3000mc_read_status, 912 .read_status = dib3000mc_read_status,
905 .read_ber = dib3000mc_read_ber, 913 .read_ber = dib3000mc_read_ber,
906 .read_signal_strength = dib3000mc_read_signal_strength, 914 .read_signal_strength = dib3000mc_read_signal_strength,
907 .read_snr = dib3000mc_read_snr, 915 .read_snr = dib3000mc_read_snr,
908 .read_ucblocks = dib3000mc_read_unc_blocks, 916 .read_ucblocks = dib3000mc_read_unc_blocks,
909}; 917};
910 918
911MODULE_AUTHOR(DRIVER_AUTHOR); 919MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
912MODULE_DESCRIPTION(DRIVER_DESC); 920MODULE_DESCRIPTION("Driver for the DiBcom 3000MC/P COFDM demodulator");
913MODULE_LICENSE("GPL"); 921MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h
new file mode 100644
index 000000000000..fd0b2e755993
--- /dev/null
+++ b/drivers/media/dvb/frontends/dib3000mc.h
@@ -0,0 +1,58 @@
1/*
2 * Driver for DiBcom DiB3000MC/P-demodulator.
3 *
4 * Copyright (C) 2004-6 DiBcom (http://www.dibcom.fr/)
5 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher\@desy.de)
6 *
7 * This code is partially based on the previous dib3000mc.c .
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation, version 2.
12 */
13#ifndef DIB3000MC_H
14#define DIB3000MC_H
15
16#include "dibx000_common.h"
17
18struct dib3000mc_config {
19 struct dibx000_agc_config *agc;
20
21 u8 phase_noise_mode;
22 u8 impulse_noise_mode;
23
24 u8 pwm3_inversion;
25 u8 use_pwm3;
26 u16 pwm3_value;
27
28 u16 max_time;
29 u16 ln_adc_level;
30
31 u8 mobile_mode;
32
33 u8 output_mpeg2_in_188_bytes;
34};
35
36#define DEFAULT_DIB3000MC_I2C_ADDRESS 16
37#define DEFAULT_DIB3000P_I2C_ADDRESS 24
38
39#if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE)
40extern int dib3000mc_attach(struct i2c_adapter *i2c_adap, int no_of_demods, u8 default_addr,
41 u8 do_i2c_enum, struct dib3000mc_config cfg[], struct dvb_frontend *demod[]);
42#else
43static inline struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
44 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
45{
46 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
47 return NULL;
48}
49#endif // CONFIG_DVB_DIB3000MC
50
51extern struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating);
52
53extern int dib3000mc_pid_control(struct dvb_frontend *fe, int index, int pid,int onoff);
54extern int dib3000mc_pid_parse(struct dvb_frontend *fe, int onoff);
55
56extern void dib3000mc_set_config(struct dvb_frontend *, struct dib3000mc_config *);
57
58#endif
diff --git a/drivers/media/dvb/frontends/dib3000mc_priv.h b/drivers/media/dvb/frontends/dib3000mc_priv.h
deleted file mode 100644
index 2930aac7591b..000000000000
--- a/drivers/media/dvb/frontends/dib3000mc_priv.h
+++ /dev/null
@@ -1,428 +0,0 @@
1/*
2 * dib3000mc_priv.h
3 *
4 * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 * for more information see dib3000mc.c .
11 */
12
13#ifndef __DIB3000MC_PRIV_H__
14#define __DIB3000MC_PRIV_H__
15
16/*
17 * Demodulator parameters
18 * reg: 0 1 1 1 11 11 111
19 * | | | | | |
20 * | | | | | +-- alpha (000=0, 001=1, 010=2, 100=4)
21 * | | | | +----- constellation (00=QPSK, 01=16QAM, 10=64QAM)
22 * | | | +-------- guard (00=1/32, 01=1/16, 10=1/8, 11=1/4)
23 * | | +----------- transmission mode (0=2k, 1=8k)
24 * | |
25 * | +-------------- restart autosearch for parameters
26 * +---------------- restart the demodulator
27 * reg: 181 1 111 1
28 * | | |
29 * | | +- FEC applies for HP or LP (0=LP, 1=HP)
30 * | +---- FEC rate (001=1/2, 010=2/3, 011=3/4, 101=5/6, 111=7/8)
31 * +------- hierarchy on (0=no, 1=yes)
32 */
33
34/* demodulator tuning parameter and restart options */
35#define DIB3000MC_REG_DEMOD_PARM ( 0)
36#define DIB3000MC_DEMOD_PARM(a,c,g,t) ( \
37 (0x7 & a) | \
38 ((0x3 & c) << 3) | \
39 ((0x3 & g) << 5) | \
40 ((0x1 & t) << 7) )
41#define DIB3000MC_DEMOD_RST_AUTO_SRCH_ON (1 << 8)
42#define DIB3000MC_DEMOD_RST_AUTO_SRCH_OFF (0 << 8)
43#define DIB3000MC_DEMOD_RST_DEMOD_ON (1 << 9)
44#define DIB3000MC_DEMOD_RST_DEMOD_OFF (0 << 9)
45
46/* register for hierarchy parameters */
47#define DIB3000MC_REG_HRCH_PARM ( 181)
48#define DIB3000MC_HRCH_PARM(s,f,h) ( \
49 (0x1 & s) | \
50 ((0x7 & f) << 1) | \
51 ((0x1 & h) << 4) )
52
53/* timeout ??? */
54#define DIB3000MC_REG_UNK_1 ( 1)
55#define DIB3000MC_UNK_1 ( 0x04)
56
57/* timeout ??? */
58#define DIB3000MC_REG_UNK_2 ( 2)
59#define DIB3000MC_UNK_2 ( 0x04)
60
61/* timeout ??? */
62#define DIB3000MC_REG_UNK_3 ( 3)
63#define DIB3000MC_UNK_3 (0x1000)
64
65#define DIB3000MC_REG_UNK_4 ( 4)
66#define DIB3000MC_UNK_4 (0x0814)
67
68/* timeout ??? */
69#define DIB3000MC_REG_SEQ_TPS ( 5)
70#define DIB3000MC_SEQ_TPS_DEFAULT ( 1)
71#define DIB3000MC_SEQ_TPS(s,t) ( \
72 ((s & 0x0f) << 4) | \
73 ((t & 0x01) << 8) )
74#define DIB3000MC_IS_TPS(v) ((v << 8) & 0x1)
75#define DIB3000MC_IS_AS(v) ((v >> 4) & 0xf)
76
77/* parameters for the bandwidth */
78#define DIB3000MC_REG_BW_TIMOUT_MSB ( 6)
79#define DIB3000MC_REG_BW_TIMOUT_LSB ( 7)
80
81static u16 dib3000mc_reg_bandwidth[] = { 6,7,8,9,10,11,16,17 };
82
83/*static u16 dib3000mc_bandwidth_5mhz[] =
84 { 0x28, 0x9380, 0x87, 0x4100, 0x2a4, 0x4500, 0x1, 0xb0d0 };*/
85
86static u16 dib3000mc_bandwidth_6mhz[] =
87 { 0x21, 0xd040, 0x70, 0xb62b, 0x233, 0x8ed5, 0x1, 0xb0d0 };
88
89static u16 dib3000mc_bandwidth_7mhz[] =
90 { 0x1c, 0xfba5, 0x60, 0x9c25, 0x1e3, 0x0cb7, 0x1, 0xb0d0 };
91
92static u16 dib3000mc_bandwidth_8mhz[] =
93 { 0x19, 0x5c30, 0x54, 0x88a0, 0x1a6, 0xab20, 0x1, 0xb0d0 };
94
95static u16 dib3000mc_reg_bandwidth_general[] = { 12,13,14,15 };
96static u16 dib3000mc_bandwidth_general[] = { 0x0000, 0x03e8, 0x0000, 0x03f2 };
97
98/* lock mask */
99#define DIB3000MC_REG_LOCK_MASK ( 15)
100#define DIB3000MC_ACTIVATE_LOCK_MASK (0x0800)
101
102/* reset the uncorrected packet count (??? do it 5 times) */
103#define DIB3000MC_REG_RST_UNC ( 18)
104#define DIB3000MC_RST_UNC_ON ( 1)
105#define DIB3000MC_RST_UNC_OFF ( 0)
106
107#define DIB3000MC_REG_UNK_19 ( 19)
108#define DIB3000MC_UNK_19 ( 0)
109
110/* DDS frequency value (IF position) and inversion bit */
111#define DIB3000MC_REG_INVERSION ( 21)
112#define DIB3000MC_REG_SET_DDS_FREQ_MSB ( 21)
113#define DIB3000MC_DDS_FREQ_MSB_INV_OFF (0x0164)
114#define DIB3000MC_DDS_FREQ_MSB_INV_ON (0x0364)
115
116#define DIB3000MC_REG_SET_DDS_FREQ_LSB ( 22)
117#define DIB3000MC_DDS_FREQ_LSB (0x463d)
118
119/* timing frequencies setting */
120#define DIB3000MC_REG_TIMING_FREQ_MSB ( 23)
121#define DIB3000MC_REG_TIMING_FREQ_LSB ( 24)
122#define DIB3000MC_CLOCK_REF (0x151fd1)
123
124//static u16 dib3000mc_reg_timing_freq[] = { 23,24 };
125
126//static u16 dib3000mc_timing_freq[][2] = {
127// { 0x69, 0x9f18 }, /* 5 MHz */
128// { 0x7e ,0xbee9 }, /* 6 MHz */
129// { 0x93 ,0xdebb }, /* 7 MHz */
130// { 0xa8 ,0xfe8c }, /* 8 MHz */
131//};
132
133/* timeout ??? */
134static u16 dib3000mc_reg_offset[] = { 26,33 };
135
136static u16 dib3000mc_offset[][2] = {
137 { 26240, 5 }, /* default */
138 { 30336, 6 }, /* 8K */
139 { 38528, 8 }, /* 2K */
140};
141
142#define DIB3000MC_REG_ISI ( 29)
143#define DIB3000MC_ISI_DEFAULT (0x1073)
144#define DIB3000MC_ISI_ACTIVATE (0x0000)
145#define DIB3000MC_ISI_INHIBIT (0x0200)
146
147/* impulse noise control */
148static u16 dib3000mc_reg_imp_noise_ctl[] = { 34,35 };
149
150static u16 dib3000mc_imp_noise_ctl[][2] = {
151 { 0x1294, 0x1ff8 }, /* mode 0 */
152 { 0x1294, 0x1ff8 }, /* mode 1 */
153 { 0x1294, 0x1ff8 }, /* mode 2 */
154 { 0x1294, 0x1ff8 }, /* mode 3 */
155 { 0x1294, 0x1ff8 }, /* mode 4 */
156};
157
158/* AGC registers */
159static u16 dib3000mc_reg_agc[] = {
160 36,37,38,39,42,43,44,45,46,47,48,49
161};
162
163static u16 dib3000mc_agc_tuner[][12] = {
164 { 0x0051, 0x301d, 0x0000, 0x1cc7, 0xcf5c, 0x6666,
165 0xbae1, 0xa148, 0x3b5e, 0x3c1c, 0x001a, 0x2019
166 }, /* TUNER_PANASONIC_ENV77H04D5, */
167
168 { 0x0051, 0x301d, 0x0000, 0x1cc7, 0xdc29, 0x570a,
169 0xbae1, 0x8ccd, 0x3b6d, 0x551d, 0x000a, 0x951e
170 }, /* TUNER_PANASONIC_ENV57H13D5, TUNER_PANASONIC_ENV57H12D5 */
171
172 { 0x0051, 0x301d, 0x0000, 0x1cc7, 0xffff, 0xffff,
173 0xffff, 0x0000, 0xfdfd, 0x4040, 0x00fd, 0x4040
174 }, /* TUNER_SAMSUNG_DTOS333IH102, TUNER_RFAGCIN_UNKNOWN */
175
176 { 0x0196, 0x301d, 0x0000, 0x1cc7, 0xbd71, 0x5c29,
177 0xb5c3, 0x6148, 0x6569, 0x5127, 0x0033, 0x3537
178 }, /* TUNER_PROVIDER_X */
179 /* TODO TUNER_PANASONIC_ENV57H10D8, TUNER_PANASONIC_ENV57H11D8 */
180};
181
182/* AGC loop bandwidth */
183static u16 dib3000mc_reg_agc_bandwidth[] = { 40,41 };
184static u16 dib3000mc_agc_bandwidth[] = { 0x119,0x330 };
185
186static u16 dib3000mc_reg_agc_bandwidth_general[] = { 50,51,52,53,54 };
187static u16 dib3000mc_agc_bandwidth_general[] =
188 { 0x8000, 0x91ca, 0x01ba, 0x0087, 0x0087 };
189
190#define DIB3000MC_REG_IMP_NOISE_55 ( 55)
191#define DIB3000MC_IMP_NEW_ALGO(w) (w | (1<<10))
192
193/* Impulse noise params */
194static u16 dib3000mc_reg_impulse_noise[] = { 55,56,57 };
195static u16 dib3000mc_impluse_noise[][3] = {
196 { 0x489, 0x89, 0x72 }, /* 5 MHz */
197 { 0x4a5, 0xa5, 0x89 }, /* 6 MHz */
198 { 0x4c0, 0xc0, 0xa0 }, /* 7 MHz */
199 { 0x4db, 0xdb, 0xb7 }, /* 8 Mhz */
200};
201
202static u16 dib3000mc_reg_fft[] = {
203 58,59,60,61,62,63,64,65,66,67,68,69,
204 70,71,72,73,74,75,76,77,78,79,80,81,
205 82,83,84,85,86
206};
207
208static u16 dib3000mc_fft_modes[][29] = {
209 { 0x38, 0x6d9, 0x3f28, 0x7a7, 0x3a74, 0x196, 0x32a, 0x48c,
210 0x3ffe, 0x7f3, 0x2d94, 0x76, 0x53d,
211 0x3ff8, 0x7e3, 0x3320, 0x76, 0x5b3,
212 0x3feb, 0x7d2, 0x365e, 0x76, 0x48c,
213 0x3ffe, 0x5b3, 0x3feb, 0x76, 0x0, 0xd
214 }, /* fft mode 0 */
215 { 0x3b, 0x6d9, 0x3f28, 0x7a7, 0x3a74, 0x196, 0x32a, 0x48c,
216 0x3ffe, 0x7f3, 0x2d94, 0x76, 0x53d,
217 0x3ff8, 0x7e3, 0x3320, 0x76, 0x5b3,
218 0x3feb, 0x7d2, 0x365e, 0x76, 0x48c,
219 0x3ffe, 0x5b3, 0x3feb, 0x0, 0x8200, 0xd
220 }, /* fft mode 1 */
221};
222
223#define DIB3000MC_REG_UNK_88 ( 88)
224#define DIB3000MC_UNK_88 (0x0410)
225
226static u16 dib3000mc_reg_bw[] = { 93,94,95,96,97,98 };
227static u16 dib3000mc_bw[][6] = {
228 { 0,0,0,0,0,0 }, /* 5 MHz */
229 { 0,0,0,0,0,0 }, /* 6 MHz */
230 { 0,0,0,0,0,0 }, /* 7 MHz */
231 { 0x20, 0x21, 0x20, 0x23, 0x20, 0x27 }, /* 8 MHz */
232};
233
234
235/* phase noise control */
236#define DIB3000MC_REG_UNK_99 ( 99)
237#define DIB3000MC_UNK_99 (0x0220)
238
239#define DIB3000MC_REG_SCAN_BOOST ( 100)
240#define DIB3000MC_SCAN_BOOST_ON ((11 << 6) + 6)
241#define DIB3000MC_SCAN_BOOST_OFF ((16 << 6) + 9)
242
243/* timeout ??? */
244#define DIB3000MC_REG_UNK_110 ( 110)
245#define DIB3000MC_UNK_110 ( 3277)
246
247#define DIB3000MC_REG_UNK_111 ( 111)
248#define DIB3000MC_UNK_111_PH_N_MODE_0 ( 0)
249#define DIB3000MC_UNK_111_PH_N_MODE_1 (1 << 1)
250
251/* superious rm config */
252#define DIB3000MC_REG_UNK_120 ( 120)
253#define DIB3000MC_UNK_120 ( 8207)
254
255#define DIB3000MC_REG_UNK_133 ( 133)
256#define DIB3000MC_UNK_133 ( 15564)
257
258#define DIB3000MC_REG_UNK_134 ( 134)
259#define DIB3000MC_UNK_134 ( 0)
260
261/* adapter config for constellation */
262static u16 dib3000mc_reg_adp_cfg[] = { 129, 130, 131, 132 };
263
264static u16 dib3000mc_adp_cfg[][4] = {
265 { 0x99a, 0x7fae, 0x333, 0x7ff0 }, /* QPSK */
266 { 0x23d, 0x7fdf, 0x0a4, 0x7ff0 }, /* 16-QAM */
267 { 0x148, 0x7ff0, 0x0a4, 0x7ff8 }, /* 64-QAM */
268};
269
270static u16 dib3000mc_reg_mobile_mode[] = { 139, 140, 141, 175, 1032 };
271
272static u16 dib3000mc_mobile_mode[][5] = {
273 { 0x01, 0x0, 0x0, 0x00, 0x12c }, /* fixed */
274 { 0x01, 0x0, 0x0, 0x00, 0x12c }, /* portable */
275 { 0x00, 0x0, 0x0, 0x02, 0x000 }, /* mobile */
276 { 0x00, 0x0, 0x0, 0x02, 0x000 }, /* auto */
277};
278
279#define DIB3000MC_REG_DIVERSITY1 ( 177)
280#define DIB3000MC_DIVERSITY1_DEFAULT ( 1)
281
282#define DIB3000MC_REG_DIVERSITY2 ( 178)
283#define DIB3000MC_DIVERSITY2_DEFAULT ( 1)
284
285#define DIB3000MC_REG_DIVERSITY3 ( 180)
286#define DIB3000MC_DIVERSITY3_IN_OFF (0xfff0)
287#define DIB3000MC_DIVERSITY3_IN_ON (0xfff6)
288
289#define DIB3000MC_REG_FEC_CFG ( 195)
290#define DIB3000MC_FEC_CFG ( 0x10)
291
292/*
293 * reg 206, output mode
294 * 1111 1111
295 * |||| ||||
296 * |||| |||+- unk
297 * |||| ||+-- unk
298 * |||| |+--- unk (on by default)
299 * |||| +---- fifo_ctrl (1 = inhibit (flushed), 0 = active (unflushed))
300 * |||+------ pid_parse (1 = enabled, 0 = disabled)
301 * ||+------- outp_188 (1 = TS packet size 188, 0 = packet size 204)
302 * |+-------- unk
303 * +--------- unk
304 */
305
306#define DIB3000MC_REG_SMO_MODE ( 206)
307#define DIB3000MC_SMO_MODE_DEFAULT (1 << 2)
308#define DIB3000MC_SMO_MODE_FIFO_FLUSH (1 << 3)
309#define DIB3000MC_SMO_MODE_FIFO_UNFLUSH (0xfff7)
310#define DIB3000MC_SMO_MODE_PID_PARSE (1 << 4)
311#define DIB3000MC_SMO_MODE_NO_PID_PARSE (0xffef)
312#define DIB3000MC_SMO_MODE_188 (1 << 5)
313#define DIB3000MC_SMO_MODE_SLAVE (DIB3000MC_SMO_MODE_DEFAULT | \
314 DIB3000MC_SMO_MODE_188 | DIB3000MC_SMO_MODE_PID_PARSE | (1<<1))
315
316#define DIB3000MC_REG_FIFO_THRESHOLD ( 207)
317#define DIB3000MC_FIFO_THRESHOLD_DEFAULT ( 1792)
318#define DIB3000MC_FIFO_THRESHOLD_SLAVE ( 512)
319/*
320 * pidfilter
321 * it is not a hardware pidfilter but a filter which drops all pids
322 * except the ones set. When connected to USB1.1 bandwidth this is important.
323 * DiB3000P/M-C can filter up to 32 PIDs
324 */
325#define DIB3000MC_REG_FIRST_PID ( 212)
326#define DIB3000MC_NUM_PIDS ( 32)
327
328#define DIB3000MC_REG_OUTMODE ( 244)
329#define DIB3000MC_OM_PARALLEL_GATED_CLK ( 0)
330#define DIB3000MC_OM_PAR_CONT_CLK (1 << 11)
331#define DIB3000MC_OM_SERIAL (2 << 11)
332#define DIB3000MC_OM_DIVOUT_ON (4 << 11)
333#define DIB3000MC_OM_SLAVE (DIB3000MC_OM_DIVOUT_ON | DIB3000MC_OM_PAR_CONT_CLK)
334
335#define DIB3000MC_REG_RF_POWER ( 392)
336
337#define DIB3000MC_REG_FFT_POSITION ( 407)
338
339#define DIB3000MC_REG_DDS_FREQ_MSB ( 414)
340#define DIB3000MC_REG_DDS_FREQ_LSB ( 415)
341
342#define DIB3000MC_REG_TIMING_OFFS_MSB ( 416)
343#define DIB3000MC_REG_TIMING_OFFS_LSB ( 417)
344
345#define DIB3000MC_REG_TUNING_PARM ( 458)
346#define DIB3000MC_TP_QAM(v) ((v >> 13) & 0x03)
347#define DIB3000MC_TP_HRCH(v) ((v >> 12) & 0x01)
348#define DIB3000MC_TP_ALPHA(v) ((v >> 9) & 0x07)
349#define DIB3000MC_TP_FFT(v) ((v >> 8) & 0x01)
350#define DIB3000MC_TP_FEC_CR_HP(v) ((v >> 5) & 0x07)
351#define DIB3000MC_TP_FEC_CR_LP(v) ((v >> 2) & 0x07)
352#define DIB3000MC_TP_GUARD(v) (v & 0x03)
353
354#define DIB3000MC_REG_SIGNAL_NOISE_MSB ( 483)
355#define DIB3000MC_REG_SIGNAL_NOISE_LSB ( 484)
356
357#define DIB3000MC_REG_MER ( 485)
358
359#define DIB3000MC_REG_BER_MSB ( 500)
360#define DIB3000MC_REG_BER_LSB ( 501)
361
362#define DIB3000MC_REG_PACKET_ERRORS ( 503)
363
364#define DIB3000MC_REG_PACKET_ERROR_COUNT ( 506)
365
366#define DIB3000MC_REG_LOCK_507 ( 507)
367#define DIB3000MC_LOCK_507 (0x0002) // ? name correct ?
368
369#define DIB3000MC_REG_LOCKING ( 509)
370#define DIB3000MC_AGC_LOCK(v) (v & 0x8000)
371#define DIB3000MC_CARRIER_LOCK(v) (v & 0x2000)
372#define DIB3000MC_MPEG_SYNC_LOCK(v) (v & 0x0080)
373#define DIB3000MC_MPEG_DATA_LOCK(v) (v & 0x0040)
374#define DIB3000MC_TPS_LOCK(v) (v & 0x0004)
375
376#define DIB3000MC_REG_AS_IRQ ( 511)
377#define DIB3000MC_AS_IRQ_SUCCESS (1 << 1)
378#define DIB3000MC_AS_IRQ_FAIL ( 1)
379
380#define DIB3000MC_REG_TUNER ( 769)
381
382#define DIB3000MC_REG_RST_I2C_ADDR ( 1024)
383#define DIB3000MC_DEMOD_ADDR_ON ( 1)
384#define DIB3000MC_DEMOD_ADDR(a) ((a << 4) & 0x03F0)
385
386#define DIB3000MC_REG_RESTART ( 1027)
387#define DIB3000MC_RESTART_OFF (0x0000)
388#define DIB3000MC_RESTART_AGC (0x0800)
389#define DIB3000MC_RESTART_CONFIG (0x8000)
390
391#define DIB3000MC_REG_RESTART_VIT ( 1028)
392#define DIB3000MC_RESTART_VIT_OFF ( 0)
393#define DIB3000MC_RESTART_VIT_ON ( 1)
394
395#define DIB3000MC_REG_CLK_CFG_1 ( 1031)
396#define DIB3000MC_CLK_CFG_1_POWER_UP ( 0)
397#define DIB3000MC_CLK_CFG_1_POWER_DOWN (0xffff)
398
399#define DIB3000MC_REG_CLK_CFG_2 ( 1032)
400#define DIB3000MC_CLK_CFG_2_PUP_FIXED (0x012c)
401#define DIB3000MC_CLK_CFG_2_PUP_PORT (0x0104)
402#define DIB3000MC_CLK_CFG_2_PUP_MOBILE (0x0000)
403#define DIB3000MC_CLK_CFG_2_POWER_DOWN (0xffff)
404
405#define DIB3000MC_REG_CLK_CFG_3 ( 1033)
406#define DIB3000MC_CLK_CFG_3_POWER_UP ( 0)
407#define DIB3000MC_CLK_CFG_3_POWER_DOWN (0xfff5)
408
409#define DIB3000MC_REG_CLK_CFG_7 ( 1037)
410#define DIB3000MC_CLK_CFG_7_INIT ( 12592)
411#define DIB3000MC_CLK_CFG_7_POWER_UP (~0x0003)
412#define DIB3000MC_CLK_CFG_7_PWR_DOWN (0x0003)
413#define DIB3000MC_CLK_CFG_7_DIV_IN_OFF (1 << 8)
414
415/* was commented out ??? */
416#define DIB3000MC_REG_CLK_CFG_8 ( 1038)
417#define DIB3000MC_CLK_CFG_8_POWER_UP (0x160c)
418
419#define DIB3000MC_REG_CLK_CFG_9 ( 1039)
420#define DIB3000MC_CLK_CFG_9_POWER_UP ( 0)
421
422/* also clock ??? */
423#define DIB3000MC_REG_ELEC_OUT ( 1040)
424#define DIB3000MC_ELEC_OUT_HIGH_Z ( 0)
425#define DIB3000MC_ELEC_OUT_DIV_OUT_ON ( 1)
426#define DIB3000MC_ELEC_OUT_SLAVE ( 3)
427
428#endif
diff --git a/drivers/media/dvb/frontends/dibx000_common.c b/drivers/media/dvb/frontends/dibx000_common.c
new file mode 100644
index 000000000000..a18c8f45a2ee
--- /dev/null
+++ b/drivers/media/dvb/frontends/dibx000_common.c
@@ -0,0 +1,152 @@
1#include <linux/i2c.h>
2
3#include "dibx000_common.h"
4
5static int debug;
6module_param(debug, int, 0644);
7MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
8
9#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiBX000: "); printk(args); } } while (0)
10
11static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
12{
13 u8 b[4] = {
14 (reg >> 8) & 0xff, reg & 0xff,
15 (val >> 8) & 0xff, val & 0xff,
16 };
17 struct i2c_msg msg = {
18 .addr = mst->i2c_addr, .flags = 0, .buf = b, .len = 4
19 };
20 return i2c_transfer(mst->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0;
21}
22
23
24static int dibx000_i2c_select_interface(struct dibx000_i2c_master *mst, enum dibx000_i2c_interface intf)
25{
26 if (mst->device_rev > DIB3000MC && mst->selected_interface != intf) {
27 dprintk("selecting interface: %d\n",intf);
28 mst->selected_interface = intf;
29 return dibx000_write_word(mst, mst->base_reg + 4, intf);
30 }
31 return 0;
32}
33
34static int dibx000_i2c_gate_ctrl(struct dibx000_i2c_master *mst, u8 tx[4], u8 addr, int onoff)
35{
36 u16 val;
37
38
39 if (onoff)
40 val = addr << 8; // bit 7 = use master or not, if 0, the gate is open
41 else
42 val = 1 << 7;
43
44 if (mst->device_rev > DIB7000)
45 val <<= 1;
46
47 tx[0] = (((mst->base_reg + 1) >> 8) & 0xff);
48 tx[1] = ( (mst->base_reg + 1) & 0xff);
49 tx[2] = val >> 8;
50 tx[3] = val & 0xff;
51
52 return 0;
53}
54
55static u32 dibx000_i2c_func(struct i2c_adapter *adapter)
56{
57 return I2C_FUNC_I2C;
58}
59
60static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num)
61{
62 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
63 struct i2c_msg m[2 + num];
64 u8 tx_open[4], tx_close[4];
65
66 memset(m,0, sizeof(struct i2c_msg) * (2 + num));
67
68 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
69
70 dibx000_i2c_gate_ctrl(mst, tx_open, msg[0].addr, 1);
71 m[0].addr = mst->i2c_addr;
72 m[0].buf = tx_open;
73 m[0].len = 4;
74
75 memcpy(&m[1], msg, sizeof(struct i2c_msg) * num);
76
77 dibx000_i2c_gate_ctrl(mst, tx_close, 0, 0);
78 m[num+1].addr = mst->i2c_addr;
79 m[num+1].buf = tx_close;
80 m[num+1].len = 4;
81
82 return i2c_transfer(mst->i2c_adap, m, 2+num) == 2 + num ? num : -EIO;
83}
84
85static struct i2c_algorithm dibx000_i2c_gated_tuner_algo = {
86 .master_xfer = dibx000_i2c_gated_tuner_xfer,
87 .functionality = dibx000_i2c_func,
88};
89
90struct i2c_adapter * dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst, enum dibx000_i2c_interface intf, int gating)
91{
92 struct i2c_adapter *i2c = NULL;
93
94 switch (intf) {
95 case DIBX000_I2C_INTERFACE_TUNER:
96 if (gating)
97 i2c = &mst->gated_tuner_i2c_adap;
98 break;
99 default:
100 printk(KERN_ERR "DiBX000: incorrect I2C interface selected\n");
101 break;
102 }
103
104 return i2c;
105}
106EXPORT_SYMBOL(dibx000_get_i2c_adapter);
107
108static int i2c_adapter_init(struct i2c_adapter *i2c_adap, struct i2c_algorithm *algo, const char name[I2C_NAME_SIZE], struct dibx000_i2c_master *mst)
109{
110 strncpy(i2c_adap->name, name, I2C_NAME_SIZE);
111 i2c_adap->class = I2C_CLASS_TV_DIGITAL,
112 i2c_adap->algo = algo;
113 i2c_adap->algo_data = NULL;
114 i2c_set_adapdata(i2c_adap, mst);
115 if (i2c_add_adapter(i2c_adap) < 0)
116 return -ENODEV;
117 return 0;
118}
119
120int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev, struct i2c_adapter *i2c_adap, u8 i2c_addr)
121{
122 u8 tx[4];
123 struct i2c_msg m = { .addr = i2c_addr >> 1, .buf = tx, .len = 4 };
124
125 mst->device_rev = device_rev;
126 mst->i2c_adap = i2c_adap;
127 mst->i2c_addr = i2c_addr >> 1;
128
129 if (device_rev == DIB7000P)
130 mst->base_reg = 1024;
131 else
132 mst->base_reg = 768;
133
134 if (i2c_adapter_init(&mst->gated_tuner_i2c_adap, &dibx000_i2c_gated_tuner_algo, "DiBX000 tuner I2C bus", mst) != 0)
135 printk(KERN_ERR "DiBX000: could not initialize the tuner i2c_adapter\n");
136
137 /* initialize the i2c-master by closing the gate */
138 dibx000_i2c_gate_ctrl(mst, tx, 0, 0);
139
140 return i2c_transfer(i2c_adap, &m, 1) == 1;
141}
142EXPORT_SYMBOL(dibx000_init_i2c_master);
143
144void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst)
145{
146 i2c_del_adapter(&mst->gated_tuner_i2c_adap);
147}
148EXPORT_SYMBOL(dibx000_exit_i2c_master);
149
150MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
151MODULE_DESCRIPTION("Common function the DiBcom demodulator family");
152MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/dibx000_common.h b/drivers/media/dvb/frontends/dibx000_common.h
new file mode 100644
index 000000000000..bb0c65f8aee8
--- /dev/null
+++ b/drivers/media/dvb/frontends/dibx000_common.h
@@ -0,0 +1,166 @@
1#ifndef DIBX000_COMMON_H
2#define DIBX000_COMMON_H
3
4enum dibx000_i2c_interface {
5 DIBX000_I2C_INTERFACE_TUNER = 0,
6 DIBX000_I2C_INTERFACE_GPIO_1_2 = 1,
7 DIBX000_I2C_INTERFACE_GPIO_3_4 = 2
8};
9
10struct dibx000_i2c_master {
11#define DIB3000MC 1
12#define DIB7000 2
13#define DIB7000P 11
14#define DIB7000MC 12
15 u16 device_rev;
16
17 enum dibx000_i2c_interface selected_interface;
18
19// struct i2c_adapter tuner_i2c_adap;
20 struct i2c_adapter gated_tuner_i2c_adap;
21
22 struct i2c_adapter *i2c_adap;
23 u8 i2c_addr;
24
25 u16 base_reg;
26};
27
28extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev, struct i2c_adapter *i2c_adap, u8 i2c_addr);
29extern struct i2c_adapter * dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst, enum dibx000_i2c_interface intf, int gating);
30extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
31
32#define BAND_LBAND 0x01
33#define BAND_UHF 0x02
34#define BAND_VHF 0x04
35
36struct dibx000_agc_config {
37 /* defines the capabilities of this AGC-setting - using the BAND_-defines*/
38 u8 band_caps;
39
40 u16 setup;
41
42 u16 inv_gain;
43 u16 time_stabiliz;
44
45 u8 alpha_level;
46 u16 thlock;
47
48 u8 wbd_inv;
49 u16 wbd_ref;
50 u8 wbd_sel;
51 u8 wbd_alpha;
52
53 u16 agc1_max;
54 u16 agc1_min;
55 u16 agc2_max;
56 u16 agc2_min;
57
58 u8 agc1_pt1;
59 u8 agc1_pt2;
60 u8 agc1_pt3;
61
62 u8 agc1_slope1;
63 u8 agc1_slope2;
64
65 u8 agc2_pt1;
66 u8 agc2_pt2;
67
68 u8 agc2_slope1;
69 u8 agc2_slope2;
70
71 u8 alpha_mant;
72 u8 alpha_exp;
73
74 u8 beta_mant;
75 u8 beta_exp;
76
77 u8 perform_agc_softsplit;
78
79 struct {
80 u16 min;
81 u16 max;
82 u16 min_thres;
83 u16 max_thres;
84 } split;
85};
86
87struct dibx000_bandwidth_config {
88 u32 internal;
89 u32 sampling;
90
91 u8 pll_prediv;
92 u8 pll_ratio;
93 u8 pll_range;
94 u8 pll_reset;
95 u8 pll_bypass;
96
97 u8 enable_refdiv;
98 u8 bypclk_div;
99 u8 IO_CLK_en_core;
100 u8 ADClkSrc;
101 u8 modulo;
102
103 u16 sad_cfg;
104
105 u32 ifreq;
106 u32 timf;
107};
108
109enum dibx000_adc_states {
110 DIBX000_SLOW_ADC_ON = 0,
111 DIBX000_SLOW_ADC_OFF,
112 DIBX000_ADC_ON,
113 DIBX000_ADC_OFF,
114 DIBX000_VBG_ENABLE,
115 DIBX000_VBG_DISABLE,
116};
117
118#define BW_INDEX_TO_KHZ(v) ( (v) == BANDWIDTH_8_MHZ ? 8000 : \
119 (v) == BANDWIDTH_7_MHZ ? 7000 : \
120 (v) == BANDWIDTH_6_MHZ ? 6000 : 8000 )
121
122/* Chip output mode. */
123#define OUTMODE_HIGH_Z 0
124#define OUTMODE_MPEG2_PAR_GATED_CLK 1
125#define OUTMODE_MPEG2_PAR_CONT_CLK 2
126#define OUTMODE_MPEG2_SERIAL 7
127#define OUTMODE_DIVERSITY 4
128#define OUTMODE_MPEG2_FIFO 5
129
130/* I hope I can get rid of the following kludge in the near future */
131struct dibx000_ofdm_channel {
132 u8 Bw;
133 s16 nfft;
134 s16 guard;
135 s16 nqam;
136 s16 vit_hrch;
137 s16 vit_select_hp;
138 s16 vit_alpha;
139 s16 vit_code_rate_hp;
140 s16 vit_code_rate_lp;
141};
142
143#define FEP2DIB(fep,ch) \
144 (ch)->Bw = (fep)->u.ofdm.bandwidth; \
145 (ch)->nfft = (fep)->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO ? -1 : (fep)->u.ofdm.transmission_mode; \
146 (ch)->guard = (fep)->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO ? -1 : (fep)->u.ofdm.guard_interval; \
147 (ch)->nqam = (fep)->u.ofdm.constellation == QAM_AUTO ? -1 : (fep)->u.ofdm.constellation == QAM_64 ? 2 : (fep)->u.ofdm.constellation; \
148 (ch)->vit_hrch = 0; /* linux-dvb is not prepared for HIERARCHICAL TRANSMISSION */ \
149 (ch)->vit_select_hp = 1; \
150 (ch)->vit_alpha = 1; \
151 (ch)->vit_code_rate_hp = (fep)->u.ofdm.code_rate_HP == FEC_AUTO ? -1 : (fep)->u.ofdm.code_rate_HP; \
152 (ch)->vit_code_rate_lp = (fep)->u.ofdm.code_rate_LP == FEC_AUTO ? -1 : (fep)->u.ofdm.code_rate_LP;
153
154#define INIT_OFDM_CHANNEL(ch) do {\
155 (ch)->Bw = 0; \
156 (ch)->nfft = -1; \
157 (ch)->guard = -1; \
158 (ch)->nqam = -1; \
159 (ch)->vit_hrch = -1; \
160 (ch)->vit_select_hp = -1; \
161 (ch)->vit_alpha = -1; \
162 (ch)->vit_code_rate_hp = -1; \
163 (ch)->vit_code_rate_lp = -1; \
164} while (0)
165
166#endif
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 2be33f27c69f..b7e7108ee5b3 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -493,6 +493,9 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
493 int i; 493 int i;
494 int result; 494 int result;
495 495
496 if (priv->i2c == NULL)
497 return -EINVAL;
498
496 for (i = 0; i < priv->pll_desc->count; i++) { 499 for (i = 0; i < priv->pll_desc->count; i++) {
497 if (priv->pll_desc->entries[i].limit == 0) 500 if (priv->pll_desc->entries[i].limit == 0)
498 break; 501 break;
@@ -611,7 +614,7 @@ static struct dvb_tuner_ops dvb_pll_tuner_ops = {
611 .get_bandwidth = dvb_pll_get_bandwidth, 614 .get_bandwidth = dvb_pll_get_bandwidth,
612}; 615};
613 616
614int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc) 617struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc)
615{ 618{
616 u8 b1 [] = { 0 }; 619 u8 b1 [] = { 0 };
617 struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 }; 620 struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 };
@@ -624,14 +627,14 @@ int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2
624 627
625 ret = i2c_transfer (i2c, &msg, 1); 628 ret = i2c_transfer (i2c, &msg, 1);
626 if (ret != 1) 629 if (ret != 1)
627 return -1; 630 return NULL;
628 if (fe->ops.i2c_gate_ctrl) 631 if (fe->ops.i2c_gate_ctrl)
629 fe->ops.i2c_gate_ctrl(fe, 0); 632 fe->ops.i2c_gate_ctrl(fe, 0);
630 } 633 }
631 634
632 priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL); 635 priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL);
633 if (priv == NULL) 636 if (priv == NULL)
634 return -ENOMEM; 637 return NULL;
635 638
636 priv->pll_i2c_address = pll_addr; 639 priv->pll_i2c_address = pll_addr;
637 priv->i2c = i2c; 640 priv->i2c = i2c;
@@ -643,7 +646,7 @@ int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2
643 fe->ops.tuner_ops.info.frequency_min = desc->max; 646 fe->ops.tuner_ops.info.frequency_min = desc->max;
644 647
645 fe->tuner_priv = priv; 648 fe->tuner_priv = priv;
646 return 0; 649 return fe;
647} 650}
648EXPORT_SYMBOL(dvb_pll_attach); 651EXPORT_SYMBOL(dvb_pll_attach);
649 652
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index 66361cd18807..ed5ac5a361ae 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -57,8 +57,8 @@ extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
57 * @param pll_addr i2c address of the PLL (if used). 57 * @param pll_addr i2c address of the PLL (if used).
58 * @param i2c i2c adapter to use (set to NULL if not used). 58 * @param i2c i2c adapter to use (set to NULL if not used).
59 * @param desc dvb_pll_desc to use. 59 * @param desc dvb_pll_desc to use.
60 * @return 0 on success, nonzero on failure. 60 * @return Frontend pointer on success, NULL on failure
61 */ 61 */
62extern int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc); 62extern struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc);
63 63
64#endif 64#endif
diff --git a/drivers/media/dvb/frontends/isl6421.c b/drivers/media/dvb/frontends/isl6421.c
index 58c34db31071..ef319369ec26 100644
--- a/drivers/media/dvb/frontends/isl6421.c
+++ b/drivers/media/dvb/frontends/isl6421.c
@@ -42,12 +42,11 @@ struct isl6421 {
42 u8 override_and; 42 u8 override_and;
43 struct i2c_adapter *i2c; 43 struct i2c_adapter *i2c;
44 u8 i2c_addr; 44 u8 i2c_addr;
45 void (*release_chain)(struct dvb_frontend* fe);
46}; 45};
47 46
48static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 47static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
49{ 48{
50 struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv; 49 struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
51 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, 50 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0,
52 .buf = &isl6421->config, 51 .buf = &isl6421->config,
53 .len = sizeof(isl6421->config) }; 52 .len = sizeof(isl6421->config) };
@@ -75,7 +74,7 @@ static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage
75 74
76static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) 75static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
77{ 76{
78 struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv; 77 struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
79 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, 78 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0,
80 .buf = &isl6421->config, 79 .buf = &isl6421->config,
81 .len = sizeof(isl6421->config) }; 80 .len = sizeof(isl6421->config) };
@@ -93,31 +92,26 @@ static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
93 92
94static void isl6421_release(struct dvb_frontend *fe) 93static void isl6421_release(struct dvb_frontend *fe)
95{ 94{
96 struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv;
97
98 /* power off */ 95 /* power off */
99 isl6421_set_voltage(fe, SEC_VOLTAGE_OFF); 96 isl6421_set_voltage(fe, SEC_VOLTAGE_OFF);
100 97
101 /* free data & call next release routine */ 98 /* free */
102 fe->ops.release = isl6421->release_chain; 99 kfree(fe->sec_priv);
103 kfree(fe->misc_priv); 100 fe->sec_priv = NULL;
104 fe->misc_priv = NULL;
105 if (fe->ops.release)
106 fe->ops.release(fe);
107} 101}
108 102
109int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, 103struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
110 u8 override_set, u8 override_clear) 104 u8 override_set, u8 override_clear)
111{ 105{
112 struct isl6421 *isl6421 = kmalloc(sizeof(struct isl6421), GFP_KERNEL); 106 struct isl6421 *isl6421 = kmalloc(sizeof(struct isl6421), GFP_KERNEL);
113 if (!isl6421) 107 if (!isl6421)
114 return -ENOMEM; 108 return NULL;
115 109
116 /* default configuration */ 110 /* default configuration */
117 isl6421->config = ISL6421_ISEL1; 111 isl6421->config = ISL6421_ISEL1;
118 isl6421->i2c = i2c; 112 isl6421->i2c = i2c;
119 isl6421->i2c_addr = i2c_addr; 113 isl6421->i2c_addr = i2c_addr;
120 fe->misc_priv = isl6421; 114 fe->sec_priv = isl6421;
121 115
122 /* bits which should be forced to '1' */ 116 /* bits which should be forced to '1' */
123 isl6421->override_or = override_set; 117 isl6421->override_or = override_set;
@@ -128,19 +122,17 @@ int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr
128 /* detect if it is present or not */ 122 /* detect if it is present or not */
129 if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) { 123 if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) {
130 kfree(isl6421); 124 kfree(isl6421);
131 fe->misc_priv = NULL; 125 return NULL;
132 return -EIO;
133 } 126 }
134 127
135 /* install release callback */ 128 /* install release callback */
136 isl6421->release_chain = fe->ops.release; 129 fe->ops.release_sec = isl6421_release;
137 fe->ops.release = isl6421_release;
138 130
139 /* override frontend ops */ 131 /* override frontend ops */
140 fe->ops.set_voltage = isl6421_set_voltage; 132 fe->ops.set_voltage = isl6421_set_voltage;
141 fe->ops.enable_high_lnb_voltage = isl6421_enable_high_lnb_voltage; 133 fe->ops.enable_high_lnb_voltage = isl6421_enable_high_lnb_voltage;
142 134
143 return 0; 135 return fe;
144} 136}
145EXPORT_SYMBOL(isl6421_attach); 137EXPORT_SYMBOL(isl6421_attach);
146 138
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h
index 675f80a19b99..1916e3eb2df3 100644
--- a/drivers/media/dvb/frontends/isl6421.h
+++ b/drivers/media/dvb/frontends/isl6421.h
@@ -39,8 +39,17 @@
39#define ISL6421_ISEL1 0x20 39#define ISL6421_ISEL1 0x20
40#define ISL6421_DCL 0x40 40#define ISL6421_DCL 0x40
41 41
42#if defined(CONFIG_DVB_ISL6421) || defined(CONFIG_DVB_ISL6421_MODULE)
42/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
43extern int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, 44extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
44 u8 override_set, u8 override_clear); 45 u8 override_set, u8 override_clear);
46#else
47static inline struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
48 u8 override_set, u8 override_clear)
49{
50 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
51 return NULL;
52}
53#endif // CONFIG_DVB_ISL6421
45 54
46#endif 55#endif
diff --git a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h
index 83b8bc210274..21ba4a230760 100644
--- a/drivers/media/dvb/frontends/l64781.h
+++ b/drivers/media/dvb/frontends/l64781.h
@@ -31,8 +31,16 @@ struct l64781_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34 34#if defined(CONFIG_DVB_L64781) || defined(CONFIG_DVB_L64781_MODULE)
35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config, 35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config,
36 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else
38static inline struct dvb_frontend* l64781_attach(const struct l64781_config* config,
39 struct i2c_adapter* i2c)
40{
41 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
42 return NULL;
43}
44#endif // CONFIG_DVB_L64781
37 45
38#endif // L64781_H 46#endif // L64781_H
diff --git a/drivers/media/dvb/frontends/lgdt330x.h b/drivers/media/dvb/frontends/lgdt330x.h
index bad903c6f0f8..3f96b485584c 100644
--- a/drivers/media/dvb/frontends/lgdt330x.h
+++ b/drivers/media/dvb/frontends/lgdt330x.h
@@ -52,8 +52,17 @@ struct lgdt330x_config
52 int clock_polarity_flip; 52 int clock_polarity_flip;
53}; 53};
54 54
55#if defined(CONFIG_DVB_LGDT330X) || defined(CONFIG_DVB_LGDT330X_MODULE)
55extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, 56extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
56 struct i2c_adapter* i2c); 57 struct i2c_adapter* i2c);
58#else
59static inline struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
60 struct i2c_adapter* i2c)
61{
62 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
63 return NULL;
64}
65#endif // CONFIG_DVB_LGDT330X
57 66
58#endif /* LGDT330X_H */ 67#endif /* LGDT330X_H */
59 68
diff --git a/drivers/media/dvb/frontends/lnbp21.c b/drivers/media/dvb/frontends/lnbp21.c
index e933edc8dd29..2d2f58c26226 100644
--- a/drivers/media/dvb/frontends/lnbp21.c
+++ b/drivers/media/dvb/frontends/lnbp21.c
@@ -40,12 +40,11 @@ struct lnbp21 {
40 u8 override_or; 40 u8 override_or;
41 u8 override_and; 41 u8 override_and;
42 struct i2c_adapter *i2c; 42 struct i2c_adapter *i2c;
43 void (*release_chain)(struct dvb_frontend* fe);
44}; 43};
45 44
46static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 45static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
47{ 46{
48 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv; 47 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->sec_priv;
49 struct i2c_msg msg = { .addr = 0x08, .flags = 0, 48 struct i2c_msg msg = { .addr = 0x08, .flags = 0,
50 .buf = &lnbp21->config, 49 .buf = &lnbp21->config,
51 .len = sizeof(lnbp21->config) }; 50 .len = sizeof(lnbp21->config) };
@@ -73,7 +72,7 @@ static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
73 72
74static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) 73static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
75{ 74{
76 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv; 75 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->sec_priv;
77 struct i2c_msg msg = { .addr = 0x08, .flags = 0, 76 struct i2c_msg msg = { .addr = 0x08, .flags = 0,
78 .buf = &lnbp21->config, 77 .buf = &lnbp21->config,
79 .len = sizeof(lnbp21->config) }; 78 .len = sizeof(lnbp21->config) };
@@ -91,29 +90,24 @@ static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
91 90
92static void lnbp21_release(struct dvb_frontend *fe) 91static void lnbp21_release(struct dvb_frontend *fe)
93{ 92{
94 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
95
96 /* LNBP power off */ 93 /* LNBP power off */
97 lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF); 94 lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF);
98 95
99 /* free data & call next release routine */ 96 /* free data */
100 fe->ops.release = lnbp21->release_chain; 97 kfree(fe->sec_priv);
101 kfree(fe->misc_priv); 98 fe->sec_priv = NULL;
102 fe->misc_priv = NULL;
103 if (fe->ops.release)
104 fe->ops.release(fe);
105} 99}
106 100
107int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear) 101struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear)
108{ 102{
109 struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL); 103 struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL);
110 if (!lnbp21) 104 if (!lnbp21)
111 return -ENOMEM; 105 return NULL;
112 106
113 /* default configuration */ 107 /* default configuration */
114 lnbp21->config = LNBP21_ISEL; 108 lnbp21->config = LNBP21_ISEL;
115 lnbp21->i2c = i2c; 109 lnbp21->i2c = i2c;
116 fe->misc_priv = lnbp21; 110 fe->sec_priv = lnbp21;
117 111
118 /* bits which should be forced to '1' */ 112 /* bits which should be forced to '1' */
119 lnbp21->override_or = override_set; 113 lnbp21->override_or = override_set;
@@ -124,19 +118,17 @@ int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_
124 /* detect if it is present or not */ 118 /* detect if it is present or not */
125 if (lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF)) { 119 if (lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF)) {
126 kfree(lnbp21); 120 kfree(lnbp21);
127 fe->misc_priv = NULL; 121 return NULL;
128 return -EIO;
129 } 122 }
130 123
131 /* install release callback */ 124 /* install release callback */
132 lnbp21->release_chain = fe->ops.release; 125 fe->ops.release_sec = lnbp21_release;
133 fe->ops.release = lnbp21_release;
134 126
135 /* override frontend ops */ 127 /* override frontend ops */
136 fe->ops.set_voltage = lnbp21_set_voltage; 128 fe->ops.set_voltage = lnbp21_set_voltage;
137 fe->ops.enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage; 129 fe->ops.enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
138 130
139 return 0; 131 return fe;
140} 132}
141EXPORT_SYMBOL(lnbp21_attach); 133EXPORT_SYMBOL(lnbp21_attach);
142 134
diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h
index 047a4ab68c01..1fe1dd179312 100644
--- a/drivers/media/dvb/frontends/lnbp21.h
+++ b/drivers/media/dvb/frontends/lnbp21.h
@@ -39,7 +39,15 @@
39 39
40#include <linux/dvb/frontend.h> 40#include <linux/dvb/frontend.h>
41 41
42#if defined(CONFIG_DVB_LNBP21) || defined(CONFIG_DVB_LNBP21_MODULE)
42/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
43extern int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear); 44extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear);
45#else
46static inline struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear)
47{
48 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
49 return NULL;
50}
51#endif // CONFIG_DVB_LNBP21
44 52
45#endif 53#endif // _LNBP21_H
diff --git a/drivers/media/dvb/frontends/mt2060.c b/drivers/media/dvb/frontends/mt2060.c
new file mode 100644
index 000000000000..508ec1b6d1fb
--- /dev/null
+++ b/drivers/media/dvb/frontends/mt2060.c
@@ -0,0 +1,367 @@
1/*
2 * Driver for Microtune MT2060 "Single chip dual conversion broadband tuner"
3 *
4 * Copyright (c) 2006 Olivier DANET <odanet@caramail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22/* In that file, frequencies are expressed in kiloHertz to avoid 32 bits overflows */
23
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/delay.h>
27#include <linux/dvb/frontend.h>
28#include <linux/i2c.h>
29
30#include "dvb_frontend.h"
31
32#include "mt2060.h"
33#include "mt2060_priv.h"
34
35static int debug;
36module_param(debug, int, 0644);
37MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
38
39#define dprintk(args...) do { if (debug) {printk(KERN_DEBUG "MT2060: " args); printk("\n"); }} while (0)
40
41// Reads a single register
42static int mt2060_readreg(struct mt2060_priv *priv, u8 reg, u8 *val)
43{
44 struct i2c_msg msg[2] = {
45 { .addr = priv->cfg->i2c_address, .flags = 0, .buf = &reg, .len = 1 },
46 { .addr = priv->cfg->i2c_address, .flags = I2C_M_RD, .buf = val, .len = 1 },
47 };
48
49 if (i2c_transfer(priv->i2c, msg, 2) != 2) {
50 printk(KERN_WARNING "mt2060 I2C read failed\n");
51 return -EREMOTEIO;
52 }
53 return 0;
54}
55
56// Writes a single register
57static int mt2060_writereg(struct mt2060_priv *priv, u8 reg, u8 val)
58{
59 u8 buf[2] = { reg, val };
60 struct i2c_msg msg = {
61 .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = 2
62 };
63
64 if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
65 printk(KERN_WARNING "mt2060 I2C write failed\n");
66 return -EREMOTEIO;
67 }
68 return 0;
69}
70
71// Writes a set of consecutive registers
72static int mt2060_writeregs(struct mt2060_priv *priv,u8 *buf, u8 len)
73{
74 struct i2c_msg msg = {
75 .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = len
76 };
77 if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
78 printk(KERN_WARNING "mt2060 I2C write failed (len=%i)\n",(int)len);
79 return -EREMOTEIO;
80 }
81 return 0;
82}
83
84// Initialisation sequences
85// LNABAND=3, NUM1=0x3C, DIV1=0x74, NUM2=0x1080, DIV2=0x49
86static u8 mt2060_config1[] = {
87 REG_LO1C1,
88 0x3F, 0x74, 0x00, 0x08, 0x93
89};
90
91// FMCG=2, GP2=0, GP1=0
92static u8 mt2060_config2[] = {
93 REG_MISC_CTRL,
94 0x20, 0x1E, 0x30, 0xff, 0x80, 0xff, 0x00, 0x2c, 0x42
95};
96
97// VGAG=3, V1CSE=1
98
99#ifdef MT2060_SPURCHECK
100/* The function below calculates the frequency offset between the output frequency if2
101 and the closer cross modulation subcarrier between lo1 and lo2 up to the tenth harmonic */
102static int mt2060_spurcalc(u32 lo1,u32 lo2,u32 if2)
103{
104 int I,J;
105 int dia,diamin,diff;
106 diamin=1000000;
107 for (I = 1; I < 10; I++) {
108 J = ((2*I*lo1)/lo2+1)/2;
109 diff = I*(int)lo1-J*(int)lo2;
110 if (diff < 0) diff=-diff;
111 dia = (diff-(int)if2);
112 if (dia < 0) dia=-dia;
113 if (diamin > dia) diamin=dia;
114 }
115 return diamin;
116}
117
118#define BANDWIDTH 4000 // kHz
119
120/* Calculates the frequency offset to add to avoid spurs. Returns 0 if no offset is needed */
121static int mt2060_spurcheck(u32 lo1,u32 lo2,u32 if2)
122{
123 u32 Spur,Sp1,Sp2;
124 int I,J;
125 I=0;
126 J=1000;
127
128 Spur=mt2060_spurcalc(lo1,lo2,if2);
129 if (Spur < BANDWIDTH) {
130 /* Potential spurs detected */
131 dprintk("Spurs before : f_lo1: %d f_lo2: %d (kHz)",
132 (int)lo1,(int)lo2);
133 I=1000;
134 Sp1 = mt2060_spurcalc(lo1+I,lo2+I,if2);
135 Sp2 = mt2060_spurcalc(lo1-I,lo2-I,if2);
136
137 if (Sp1 < Sp2) {
138 J=-J; I=-I; Spur=Sp2;
139 } else
140 Spur=Sp1;
141
142 while (Spur < BANDWIDTH) {
143 I += J;
144 Spur = mt2060_spurcalc(lo1+I,lo2+I,if2);
145 }
146 dprintk("Spurs after : f_lo1: %d f_lo2: %d (kHz)",
147 (int)(lo1+I),(int)(lo2+I));
148 }
149 return I;
150}
151#endif
152
153#define IF2 36150 // IF2 frequency = 36.150 MHz
154#define FREF 16000 // Quartz oscillator 16 MHz
155
156static int mt2060_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
157{
158 struct mt2060_priv *priv;
159 int ret=0;
160 int i=0;
161 u32 freq;
162 u8 lnaband;
163 u32 f_lo1,f_lo2;
164 u32 div1,num1,div2,num2;
165 u8 b[8];
166 u32 if1;
167
168 priv = fe->tuner_priv;
169
170 if1 = priv->if1_freq;
171 b[0] = REG_LO1B1;
172 b[1] = 0xFF;
173
174 mt2060_writeregs(priv,b,2);
175
176 freq = params->frequency / 1000; // Hz -> kHz
177 priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0;
178
179 f_lo1 = freq + if1 * 1000;
180 f_lo1 = (f_lo1 / 250) * 250;
181 f_lo2 = f_lo1 - freq - IF2;
182 // From the Comtech datasheet, the step used is 50kHz. The tuner chip could be more precise
183 f_lo2 = ((f_lo2 + 25) / 50) * 50;
184 priv->frequency = (f_lo1 - f_lo2 - IF2) * 1000,
185
186#ifdef MT2060_SPURCHECK
187 // LO-related spurs detection and correction
188 num1 = mt2060_spurcheck(f_lo1,f_lo2,IF2);
189 f_lo1 += num1;
190 f_lo2 += num1;
191#endif
192 //Frequency LO1 = 16MHz * (DIV1 + NUM1/64 )
193 num1 = f_lo1 / (FREF / 64);
194 div1 = num1 / 64;
195 num1 &= 0x3f;
196
197 // Frequency LO2 = 16MHz * (DIV2 + NUM2/8192 )
198 num2 = f_lo2 * 64 / (FREF / 128);
199 div2 = num2 / 8192;
200 num2 &= 0x1fff;
201
202 if (freq <= 95000) lnaband = 0xB0; else
203 if (freq <= 180000) lnaband = 0xA0; else
204 if (freq <= 260000) lnaband = 0x90; else
205 if (freq <= 335000) lnaband = 0x80; else
206 if (freq <= 425000) lnaband = 0x70; else
207 if (freq <= 480000) lnaband = 0x60; else
208 if (freq <= 570000) lnaband = 0x50; else
209 if (freq <= 645000) lnaband = 0x40; else
210 if (freq <= 730000) lnaband = 0x30; else
211 if (freq <= 810000) lnaband = 0x20; else lnaband = 0x10;
212
213 b[0] = REG_LO1C1;
214 b[1] = lnaband | ((num1 >>2) & 0x0F);
215 b[2] = div1;
216 b[3] = (num2 & 0x0F) | ((num1 & 3) << 4);
217 b[4] = num2 >> 4;
218 b[5] = ((num2 >>12) & 1) | (div2 << 1);
219
220 dprintk("IF1: %dMHz",(int)if1);
221 dprintk("PLL freq=%dkHz f_lo1=%dkHz f_lo2=%dkHz",(int)freq,(int)f_lo1,(int)f_lo2);
222 dprintk("PLL div1=%d num1=%d div2=%d num2=%d",(int)div1,(int)num1,(int)div2,(int)num2);
223 dprintk("PLL [1..5]: %2x %2x %2x %2x %2x",(int)b[1],(int)b[2],(int)b[3],(int)b[4],(int)b[5]);
224
225 mt2060_writeregs(priv,b,6);
226
227 //Waits for pll lock or timeout
228 i = 0;
229 do {
230 mt2060_readreg(priv,REG_LO_STATUS,b);
231 if ((b[0] & 0x88)==0x88)
232 break;
233 msleep(4);
234 i++;
235 } while (i<10);
236
237 return ret;
238}
239
240static void mt2060_calibrate(struct mt2060_priv *priv)
241{
242 u8 b = 0;
243 int i = 0;
244
245 if (mt2060_writeregs(priv,mt2060_config1,sizeof(mt2060_config1)))
246 return;
247 if (mt2060_writeregs(priv,mt2060_config2,sizeof(mt2060_config2)))
248 return;
249
250 do {
251 b |= (1 << 6); // FM1SS;
252 mt2060_writereg(priv, REG_LO2C1,b);
253 msleep(20);
254
255 if (i == 0) {
256 b |= (1 << 7); // FM1CA;
257 mt2060_writereg(priv, REG_LO2C1,b);
258 b &= ~(1 << 7); // FM1CA;
259 msleep(20);
260 }
261
262 b &= ~(1 << 6); // FM1SS
263 mt2060_writereg(priv, REG_LO2C1,b);
264
265 msleep(20);
266 i++;
267 } while (i < 9);
268
269 i = 0;
270 while (i++ < 10 && mt2060_readreg(priv, REG_MISC_STAT, &b) == 0 && (b & (1 << 6)) == 0)
271 msleep(20);
272
273 if (i < 10) {
274 mt2060_readreg(priv, REG_FM_FREQ, &priv->fmfreq); // now find out, what is fmreq used for :)
275 dprintk("calibration was successful: %d", (int)priv->fmfreq);
276 } else
277 dprintk("FMCAL timed out");
278}
279
280static int mt2060_get_frequency(struct dvb_frontend *fe, u32 *frequency)
281{
282 struct mt2060_priv *priv = fe->tuner_priv;
283 *frequency = priv->frequency;
284 return 0;
285}
286
287static int mt2060_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
288{
289 struct mt2060_priv *priv = fe->tuner_priv;
290 *bandwidth = priv->bandwidth;
291 return 0;
292}
293
294static int mt2060_init(struct dvb_frontend *fe)
295{
296 struct mt2060_priv *priv = fe->tuner_priv;
297 return mt2060_writereg(priv, REG_VGAG,0x33);
298}
299
300static int mt2060_sleep(struct dvb_frontend *fe)
301{
302 struct mt2060_priv *priv = fe->tuner_priv;
303 return mt2060_writereg(priv, REG_VGAG,0x30);
304}
305
306static int mt2060_release(struct dvb_frontend *fe)
307{
308 kfree(fe->tuner_priv);
309 fe->tuner_priv = NULL;
310 return 0;
311}
312
313static const struct dvb_tuner_ops mt2060_tuner_ops = {
314 .info = {
315 .name = "Microtune MT2060",
316 .frequency_min = 48000000,
317 .frequency_max = 860000000,
318 .frequency_step = 50000,
319 },
320
321 .release = mt2060_release,
322
323 .init = mt2060_init,
324 .sleep = mt2060_sleep,
325
326 .set_params = mt2060_set_params,
327 .get_frequency = mt2060_get_frequency,
328 .get_bandwidth = mt2060_get_bandwidth
329};
330
331/* This functions tries to identify a MT2060 tuner by reading the PART/REV register. This is hasty. */
332int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
333{
334 struct mt2060_priv *priv = NULL;
335 u8 id = 0;
336
337 priv = kzalloc(sizeof(struct mt2060_priv), GFP_KERNEL);
338 if (priv == NULL)
339 return -ENOMEM;
340
341 priv->cfg = cfg;
342 priv->i2c = i2c;
343 priv->if1_freq = if1;
344
345 if (mt2060_readreg(priv,REG_PART_REV,&id) != 0) {
346 kfree(priv);
347 return -ENODEV;
348 }
349
350 if (id != PART_REV) {
351 kfree(priv);
352 return -ENODEV;
353 }
354 printk(KERN_INFO "MT2060: successfully identified (IF1 = %d)\n", if1);
355 memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(struct dvb_tuner_ops));
356
357 fe->tuner_priv = priv;
358
359 mt2060_calibrate(priv);
360
361 return 0;
362}
363EXPORT_SYMBOL(mt2060_attach);
364
365MODULE_AUTHOR("Olivier DANET");
366MODULE_DESCRIPTION("Microtune MT2060 silicon tuner driver");
367MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/mt2060.h b/drivers/media/dvb/frontends/mt2060.h
new file mode 100644
index 000000000000..c58b03e82345
--- /dev/null
+++ b/drivers/media/dvb/frontends/mt2060.h
@@ -0,0 +1,35 @@
1/*
2 * Driver for Microtune MT2060 "Single chip dual conversion broadband tuner"
3 *
4 * Copyright (c) 2006 Olivier DANET <odanet@caramail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22#ifndef MT2060_H
23#define MT2060_H
24
25struct dvb_frontend;
26struct i2c_adapter;
27
28struct mt2060_config {
29 u8 i2c_address;
30 /* Shall we add settings for the discrete outputs ? */
31};
32
33extern int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1);
34
35#endif
diff --git a/drivers/media/dvb/frontends/mt2060_priv.h b/drivers/media/dvb/frontends/mt2060_priv.h
new file mode 100644
index 000000000000..5eaccdefd0b0
--- /dev/null
+++ b/drivers/media/dvb/frontends/mt2060_priv.h
@@ -0,0 +1,105 @@
1/*
2 * Driver for Microtune MT2060 "Single chip dual conversion broadband tuner"
3 *
4 * Copyright (c) 2006 Olivier DANET <odanet@caramail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22#ifndef MT2060_PRIV_H
23#define MT2060_PRIV_H
24
25// Uncomment the #define below to enable spurs checking. The results where quite unconvincing.
26// #define MT2060_SPURCHECK
27
28/* This driver is based on the information available in the datasheet of the
29 "Comtech SDVBT-3K6M" tuner ( K1000737843.pdf ) which features the MT2060 register map :
30
31 I2C Address : 0x60
32
33 Reg.No | B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 | ( defaults )
34 --------------------------------------------------------------------------------
35 00 | [ PART ] | [ REV ] | R = 0x63
36 01 | [ LNABAND ] | [ NUM1(5:2) ] | RW = 0x3F
37 02 | [ DIV1 ] | RW = 0x74
38 03 | FM1CA | FM1SS | [ NUM1(1:0) ] | [ NUM2(3:0) ] | RW = 0x00
39 04 | NUM2(11:4) ] | RW = 0x08
40 05 | [ DIV2 ] |NUM2(12)| RW = 0x93
41 06 | L1LK | [ TAD1 ] | L2LK | [ TAD2 ] | R
42 07 | [ FMF ] | R
43 08 | ? | FMCAL | ? | ? | ? | ? | ? | TEMP | R
44 09 | 0 | 0 | [ FMGC ] | 0 | GP02 | GP01 | 0 | RW = 0x20
45 0A | ??
46 0B | 0 | 0 | 1 | 1 | 0 | 0 | [ VGAG ] | RW = 0x30
47 0C | V1CSE | 1 | 1 | 1 | 1 | 1 | 1 | 1 | RW = 0xFF
48 0D | 1 | 0 | [ V1CS ] | RW = 0xB0
49 0E | ??
50 0F | ??
51 10 | ??
52 11 | [ LOTO ] | 0 | 0 | 1 | 0 | RW = 0x42
53
54 PART : Part code : 6 for MT2060
55 REV : Revision code : 3 for current revision
56 LNABAND : Input frequency range : ( See code for details )
57 NUM1 / DIV1 / NUM2 / DIV2 : Frequencies programming ( See code for details )
58 FM1CA : Calibration Start Bit
59 FM1SS : Calibration Single Step bit
60 L1LK : LO1 Lock Detect
61 TAD1 : Tune Line ADC ( ? )
62 L2LK : LO2 Lock Detect
63 TAD2 : Tune Line ADC ( ? )
64 FMF : Estimated first IF Center frequency Offset ( ? )
65 FM1CAL : Calibration done bit
66 TEMP : On chip temperature sensor
67 FMCG : Mixer 1 Cap Gain ( ? )
68 GP01 / GP02 : Programmable digital outputs. Unconnected pins ?
69 V1CSE : LO1 VCO Automatic Capacitor Select Enable ( ? )
70 V1CS : LO1 Capacitor Selection Value ( ? )
71 LOTO : LO Timeout ( ? )
72 VGAG : Tuner Output gain
73*/
74
75#define I2C_ADDRESS 0x60
76
77#define REG_PART_REV 0
78#define REG_LO1C1 1
79#define REG_LO1C2 2
80#define REG_LO2C1 3
81#define REG_LO2C2 4
82#define REG_LO2C3 5
83#define REG_LO_STATUS 6
84#define REG_FM_FREQ 7
85#define REG_MISC_STAT 8
86#define REG_MISC_CTRL 9
87#define REG_RESERVED_A 0x0A
88#define REG_VGAG 0x0B
89#define REG_LO1B1 0x0C
90#define REG_LO1B2 0x0D
91#define REG_LOTO 0x11
92
93#define PART_REV 0x63 // The current driver works only with PART=6 and REV=3 chips
94
95struct mt2060_priv {
96 struct mt2060_config *cfg;
97 struct i2c_adapter *i2c;
98
99 u32 frequency;
100 u32 bandwidth;
101 u16 if1_freq;
102 u8 fmfreq;
103};
104
105#endif
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index 666a1bd1c244..7112fb4d58ac 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -34,8 +34,16 @@ struct mt312_config
34 u8 demod_address; 34 u8 demod_address;
35}; 35};
36 36
37#if defined(CONFIG_DVB_MT312) || defined(CONFIG_DVB_MT312_MODULE)
37struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, 38struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
38 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
39 40#else
41static inline struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
42 struct i2c_adapter* i2c)
43{
44 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
45 return NULL;
46}
47#endif // CONFIG_DVB_MT312
40 48
41#endif // MT312_H 49#endif // MT312_H
diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c
index 5de7376c94ce..87e31ca7e108 100644
--- a/drivers/media/dvb/frontends/mt352.c
+++ b/drivers/media/dvb/frontends/mt352.c
@@ -70,7 +70,7 @@ static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
70 return 0; 70 return 0;
71} 71}
72 72
73int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen) 73static int _mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
74{ 74{
75 int err,i; 75 int err,i;
76 for (i=0; i < ilen-1; i++) 76 for (i=0; i < ilen-1; i++)
@@ -107,7 +107,7 @@ static int mt352_sleep(struct dvb_frontend* fe)
107{ 107{
108 static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 }; 108 static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
109 109
110 mt352_write(fe, mt352_softdown, sizeof(mt352_softdown)); 110 _mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
111 return 0; 111 return 0;
112} 112}
113 113
@@ -293,14 +293,14 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
293 fe->ops.i2c_gate_ctrl(fe, 0); 293 fe->ops.i2c_gate_ctrl(fe, 0);
294 } 294 }
295 295
296 mt352_write(fe, buf, 8); 296 _mt352_write(fe, buf, 8);
297 mt352_write(fe, fsm_go, 2); 297 _mt352_write(fe, fsm_go, 2);
298 } else { 298 } else {
299 if (fe->ops.tuner_ops.calc_regs) { 299 if (fe->ops.tuner_ops.calc_regs) {
300 fe->ops.tuner_ops.calc_regs(fe, param, buf+8, 5); 300 fe->ops.tuner_ops.calc_regs(fe, param, buf+8, 5);
301 buf[8] <<= 1; 301 buf[8] <<= 1;
302 mt352_write(fe, buf, sizeof(buf)); 302 _mt352_write(fe, buf, sizeof(buf));
303 mt352_write(fe, tuner_go, 2); 303 _mt352_write(fe, tuner_go, 2);
304 } 304 }
305 } 305 }
306 306
@@ -522,7 +522,7 @@ static int mt352_init(struct dvb_frontend* fe)
522 (mt352_read_register(state, CONFIG) & 0x20) == 0) { 522 (mt352_read_register(state, CONFIG) & 0x20) == 0) {
523 523
524 /* Do a "hard" reset */ 524 /* Do a "hard" reset */
525 mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach)); 525 _mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
526 return state->config.demod_init(fe); 526 return state->config.demod_init(fe);
527 } 527 }
528 528
@@ -585,6 +585,7 @@ static struct dvb_frontend_ops mt352_ops = {
585 585
586 .init = mt352_init, 586 .init = mt352_init,
587 .sleep = mt352_sleep, 587 .sleep = mt352_sleep,
588 .write = _mt352_write,
588 589
589 .set_frontend = mt352_set_parameters, 590 .set_frontend = mt352_set_parameters,
590 .get_frontend = mt352_get_parameters, 591 .get_frontend = mt352_get_parameters,
@@ -605,4 +606,3 @@ MODULE_AUTHOR("Holger Waechtler, Daniel Mack, Antonio Mancuso");
605MODULE_LICENSE("GPL"); 606MODULE_LICENSE("GPL");
606 607
607EXPORT_SYMBOL(mt352_attach); 608EXPORT_SYMBOL(mt352_attach);
608EXPORT_SYMBOL(mt352_write);
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
index 9e7ff4b8fe5f..0035c2e2d7c2 100644
--- a/drivers/media/dvb/frontends/mt352.h
+++ b/drivers/media/dvb/frontends/mt352.h
@@ -51,9 +51,23 @@ struct mt352_config
51 int (*demod_init)(struct dvb_frontend* fe); 51 int (*demod_init)(struct dvb_frontend* fe);
52}; 52};
53 53
54#if defined(CONFIG_DVB_MT352) || defined(CONFIG_DVB_MT352_MODULE)
54extern struct dvb_frontend* mt352_attach(const struct mt352_config* config, 55extern struct dvb_frontend* mt352_attach(const struct mt352_config* config,
55 struct i2c_adapter* i2c); 56 struct i2c_adapter* i2c);
57#else
58static inline struct dvb_frontend* mt352_attach(const struct mt352_config* config,
59 struct i2c_adapter* i2c)
60{
61 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
62 return NULL;
63}
64#endif // CONFIG_DVB_MT352
56 65
57extern int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen); 66static inline int mt352_write(struct dvb_frontend *fe, u8 *buf, int len) {
67 int r = 0;
68 if (fe->ops.write)
69 r = fe->ops.write(fe, buf, len);
70 return r;
71}
58 72
59#endif // MT352_H 73#endif // MT352_H
diff --git a/drivers/media/dvb/frontends/nxt200x.h b/drivers/media/dvb/frontends/nxt200x.h
index 34d61735845b..2eb220e98062 100644
--- a/drivers/media/dvb/frontends/nxt200x.h
+++ b/drivers/media/dvb/frontends/nxt200x.h
@@ -45,8 +45,17 @@ struct nxt200x_config
45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
46}; 46};
47 47
48#if defined(CONFIG_DVB_NXT200X) || defined(CONFIG_DVB_NXT200X_MODULE)
48extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, 49extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
49 struct i2c_adapter* i2c); 50 struct i2c_adapter* i2c);
51#else
52static inline struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
53 struct i2c_adapter* i2c)
54{
55 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
56 return NULL;
57}
58#endif // CONFIG_DVB_NXT200X
50 59
51#endif /* NXT200X_H */ 60#endif /* NXT200X_H */
52 61
diff --git a/drivers/media/dvb/frontends/nxt6000.h b/drivers/media/dvb/frontends/nxt6000.h
index 117031d11708..9397393a6bd1 100644
--- a/drivers/media/dvb/frontends/nxt6000.h
+++ b/drivers/media/dvb/frontends/nxt6000.h
@@ -33,7 +33,16 @@ struct nxt6000_config
33 u8 clock_inversion:1; 33 u8 clock_inversion:1;
34}; 34};
35 35
36#if defined(CONFIG_DVB_NXT6000) || defined(CONFIG_DVB_NXT6000_MODULE)
36extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, 37extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
37 struct i2c_adapter* i2c); 38 struct i2c_adapter* i2c);
39#else
40static inline struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
41 struct i2c_adapter* i2c)
42{
43 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
44 return NULL;
45}
46#endif // CONFIG_DVB_NXT6000
38 47
39#endif // NXT6000_H 48#endif // NXT6000_H
diff --git a/drivers/media/dvb/frontends/or51132.h b/drivers/media/dvb/frontends/or51132.h
index 89658883abf5..9718be4fb835 100644
--- a/drivers/media/dvb/frontends/or51132.h
+++ b/drivers/media/dvb/frontends/or51132.h
@@ -34,8 +34,17 @@ struct or51132_config
34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
35}; 35};
36 36
37#if defined(CONFIG_DVB_OR51132) || defined(CONFIG_DVB_OR51132_MODULE)
37extern struct dvb_frontend* or51132_attach(const struct or51132_config* config, 38extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,
38 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else
41static inline struct dvb_frontend* or51132_attach(const struct or51132_config* config,
42 struct i2c_adapter* i2c)
43{
44 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
45 return NULL;
46}
47#endif // CONFIG_DVB_OR51132
39 48
40#endif // OR51132_H 49#endif // OR51132_H
41 50
diff --git a/drivers/media/dvb/frontends/or51211.h b/drivers/media/dvb/frontends/or51211.h
index 13a5a3afbf8b..10a5419f9e00 100644
--- a/drivers/media/dvb/frontends/or51211.h
+++ b/drivers/media/dvb/frontends/or51211.h
@@ -37,8 +37,17 @@ struct or51211_config
37 void (*sleep)(struct dvb_frontend * fe); 37 void (*sleep)(struct dvb_frontend * fe);
38}; 38};
39 39
40#if defined(CONFIG_DVB_OR51211) || defined(CONFIG_DVB_OR51211_MODULE)
40extern struct dvb_frontend* or51211_attach(const struct or51211_config* config, 41extern struct dvb_frontend* or51211_attach(const struct or51211_config* config,
41 struct i2c_adapter* i2c); 42 struct i2c_adapter* i2c);
43#else
44static inline struct dvb_frontend* or51211_attach(const struct or51211_config* config,
45 struct i2c_adapter* i2c)
46{
47 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
48 return NULL;
49}
50#endif // CONFIG_DVB_OR51211
42 51
43#endif // OR51211_H 52#endif // OR51211_H
44 53
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
index 4e39015fa67e..efc54d7f3c55 100644
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -34,7 +34,16 @@ struct s5h1420_config
34 u8 invert:1; 34 u8 invert:1;
35}; 35};
36 36
37#if defined(CONFIG_DVB_S5H1420) || defined(CONFIG_DVB_S5H1420_MODULE)
37extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, 38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
38 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else
41static inline struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
42 struct i2c_adapter* i2c)
43{
44 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
45 return NULL;
46}
47#endif // CONFIG_DVB_S5H1420
39 48
40#endif // S5H1420_H 49#endif // S5H1420_H
diff --git a/drivers/media/dvb/frontends/sp8870.h b/drivers/media/dvb/frontends/sp8870.h
index 93afbb969d6b..4cf27d3b10f2 100644
--- a/drivers/media/dvb/frontends/sp8870.h
+++ b/drivers/media/dvb/frontends/sp8870.h
@@ -35,7 +35,16 @@ struct sp8870_config
35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
36}; 36};
37 37
38#if defined(CONFIG_DVB_SP8870) || defined(CONFIG_DVB_SP8870_MODULE)
38extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, 39extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
39 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else
42static inline struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
43 struct i2c_adapter* i2c)
44{
45 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
46 return NULL;
47}
48#endif // CONFIG_DVB_SP8870
40 49
41#endif // SP8870_H 50#endif // SP8870_H
diff --git a/drivers/media/dvb/frontends/sp887x.h b/drivers/media/dvb/frontends/sp887x.h
index c44b0ebdf1e2..cab7ea644dfa 100644
--- a/drivers/media/dvb/frontends/sp887x.h
+++ b/drivers/media/dvb/frontends/sp887x.h
@@ -17,7 +17,16 @@ struct sp887x_config
17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
18}; 18};
19 19
20#if defined(CONFIG_DVB_SP887X) || defined(CONFIG_DVB_SP887X_MODULE)
20extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, 21extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
21 struct i2c_adapter* i2c); 22 struct i2c_adapter* i2c);
23#else
24static inline struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
25 struct i2c_adapter* i2c)
26{
27 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
28 return NULL;
29}
30#endif // CONFIG_DVB_SP887X
22 31
23#endif // SP887X_H 32#endif // SP887X_H
diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h
index 1da5384fb985..760b80db43a5 100644
--- a/drivers/media/dvb/frontends/stv0297.h
+++ b/drivers/media/dvb/frontends/stv0297.h
@@ -42,7 +42,16 @@ struct stv0297_config
42 u8 stop_during_read:1; 42 u8 stop_during_read:1;
43}; 43};
44 44
45#if defined(CONFIG_DVB_STV0297) || defined(CONFIG_DVB_STV0297_MODULE)
45extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, 46extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
46 struct i2c_adapter* i2c); 47 struct i2c_adapter* i2c);
48#else
49static inline struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
50 struct i2c_adapter* i2c)
51{
52 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
53 return NULL;
54}
55#endif // CONFIG_DVB_STV0297
47 56
48#endif // STV0297_H 57#endif // STV0297_H
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
index 96648a75440d..93483769eca8 100644
--- a/drivers/media/dvb/frontends/stv0299.c
+++ b/drivers/media/dvb/frontends/stv0299.c
@@ -92,11 +92,14 @@ static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
92 return (ret != 1) ? -EREMOTEIO : 0; 92 return (ret != 1) ? -EREMOTEIO : 0;
93} 93}
94 94
95int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data) 95int stv0299_write(struct dvb_frontend* fe, u8 *buf, int len)
96{ 96{
97 struct stv0299_state* state = fe->demodulator_priv; 97 struct stv0299_state* state = fe->demodulator_priv;
98 98
99 return stv0299_writeregI(state, reg, data); 99 if (len != 2)
100 return -EINVAL;
101
102 return stv0299_writeregI(state, buf[0], buf[1]);
100} 103}
101 104
102static u8 stv0299_readreg (struct stv0299_state* state, u8 reg) 105static u8 stv0299_readreg (struct stv0299_state* state, u8 reg)
@@ -694,6 +697,7 @@ static struct dvb_frontend_ops stv0299_ops = {
694 697
695 .init = stv0299_init, 698 .init = stv0299_init,
696 .sleep = stv0299_sleep, 699 .sleep = stv0299_sleep,
700 .write = stv0299_write,
697 .i2c_gate_ctrl = stv0299_i2c_gate_ctrl, 701 .i2c_gate_ctrl = stv0299_i2c_gate_ctrl,
698 702
699 .set_frontend = stv0299_set_frontend, 703 .set_frontend = stv0299_set_frontend,
@@ -724,5 +728,4 @@ MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, "
724 "Andreas Oberritter, Andrew de Quincey, Kenneth Aafly"); 728 "Andreas Oberritter, Andrew de Quincey, Kenneth Aafly");
725MODULE_LICENSE("GPL"); 729MODULE_LICENSE("GPL");
726 730
727EXPORT_SYMBOL(stv0299_writereg);
728EXPORT_SYMBOL(stv0299_attach); 731EXPORT_SYMBOL(stv0299_attach);
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h
index 1504828e4232..7ef25207081d 100644
--- a/drivers/media/dvb/frontends/stv0299.h
+++ b/drivers/media/dvb/frontends/stv0299.h
@@ -89,9 +89,24 @@ struct stv0299_config
89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); 89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio);
90}; 90};
91 91
92extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data); 92#if defined(CONFIG_DVB_STV0299) || defined(CONFIG_DVB_STV0299_MODULE)
93
94extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, 93extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
95 struct i2c_adapter* i2c); 94 struct i2c_adapter* i2c);
95#else
96static inline struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
97 struct i2c_adapter* i2c)
98{
99 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
100 return NULL;
101}
102#endif // CONFIG_DVB_STV0299
103
104static inline int stv0299_writereg(struct dvb_frontend *fe, u8 reg, u8 val) {
105 int r = 0;
106 u8 buf[] = {reg, val};
107 if (fe->ops.write)
108 r = fe->ops.write(fe, buf, 2);
109 return r;
110}
96 111
97#endif // STV0299_H 112#endif // STV0299_H
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index 9cbd164aa281..dca89171be1f 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -72,7 +72,7 @@ static u8 tda10021_inittab[0x40]=
72 0x04, 0x2d, 0x2f, 0xff, 0x00, 0x00, 0x00, 0x00, 72 0x04, 0x2d, 0x2f, 0xff, 0x00, 0x00, 0x00, 0x00,
73}; 73};
74 74
75static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data) 75static int _tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
76{ 76{
77 u8 buf[] = { reg, data }; 77 u8 buf[] = { reg, data };
78 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 78 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
@@ -88,14 +88,6 @@ static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
88 return (ret != 1) ? -EREMOTEIO : 0; 88 return (ret != 1) ? -EREMOTEIO : 0;
89} 89}
90 90
91int tda10021_write_byte(struct dvb_frontend* fe, int reg, int data)
92{
93 struct tda10021_state* state = fe->demodulator_priv;
94
95 return tda10021_writereg(state, reg, data);
96}
97EXPORT_SYMBOL(tda10021_write_byte);
98
99static u8 tda10021_readreg (struct tda10021_state* state, u8 reg) 91static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
100{ 92{
101 u8 b0 [] = { reg }; 93 u8 b0 [] = { reg };
@@ -149,8 +141,8 @@ static int tda10021_setup_reg0 (struct tda10021_state* state, u8 reg0,
149 else if (INVERSION_OFF == inversion) 141 else if (INVERSION_OFF == inversion)
150 DISABLE_INVERSION(reg0); 142 DISABLE_INVERSION(reg0);
151 143
152 tda10021_writereg (state, 0x00, reg0 & 0xfe); 144 _tda10021_writereg (state, 0x00, reg0 & 0xfe);
153 tda10021_writereg (state, 0x00, reg0 | 0x01); 145 _tda10021_writereg (state, 0x00, reg0 | 0x01);
154 146
155 state->reg0 = reg0; 147 state->reg0 = reg0;
156 return 0; 148 return 0;
@@ -198,17 +190,27 @@ static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate
198 190
199 NDEC = (NDEC << 6) | tda10021_inittab[0x03]; 191 NDEC = (NDEC << 6) | tda10021_inittab[0x03];
200 192
201 tda10021_writereg (state, 0x03, NDEC); 193 _tda10021_writereg (state, 0x03, NDEC);
202 tda10021_writereg (state, 0x0a, BDR&0xff); 194 _tda10021_writereg (state, 0x0a, BDR&0xff);
203 tda10021_writereg (state, 0x0b, (BDR>> 8)&0xff); 195 _tda10021_writereg (state, 0x0b, (BDR>> 8)&0xff);
204 tda10021_writereg (state, 0x0c, (BDR>>16)&0x3f); 196 _tda10021_writereg (state, 0x0c, (BDR>>16)&0x3f);
205 197
206 tda10021_writereg (state, 0x0d, BDRI); 198 _tda10021_writereg (state, 0x0d, BDRI);
207 tda10021_writereg (state, 0x0e, SFIL); 199 _tda10021_writereg (state, 0x0e, SFIL);
208 200
209 return 0; 201 return 0;
210} 202}
211 203
204int tda10021_write(struct dvb_frontend* fe, u8 *buf, int len)
205{
206 struct tda10021_state* state = fe->demodulator_priv;
207
208 if (len != 2)
209 return -EINVAL;
210
211 return _tda10021_writereg(state, buf[0], buf[1]);
212}
213
212static int tda10021_init (struct dvb_frontend *fe) 214static int tda10021_init (struct dvb_frontend *fe)
213{ 215{
214 struct tda10021_state* state = fe->demodulator_priv; 216 struct tda10021_state* state = fe->demodulator_priv;
@@ -216,12 +218,12 @@ static int tda10021_init (struct dvb_frontend *fe)
216 218
217 dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num); 219 dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num);
218 220
219 //tda10021_writereg (fe, 0, 0); 221 //_tda10021_writereg (fe, 0, 0);
220 222
221 for (i=0; i<tda10021_inittab_size; i++) 223 for (i=0; i<tda10021_inittab_size; i++)
222 tda10021_writereg (state, i, tda10021_inittab[i]); 224 _tda10021_writereg (state, i, tda10021_inittab[i]);
223 225
224 tda10021_writereg (state, 0x34, state->pwm); 226 _tda10021_writereg (state, 0x34, state->pwm);
225 227
226 //Comment by markus 228 //Comment by markus
227 //0x2A[3-0] == PDIV -> P multiplaying factor (P=PDIV+1)(default 0) 229 //0x2A[3-0] == PDIV -> P multiplaying factor (P=PDIV+1)(default 0)
@@ -230,7 +232,7 @@ static int tda10021_init (struct dvb_frontend *fe)
230 //0x2A[6] == POLAXIN -> Polarity of the input reference clock (default 0) 232 //0x2A[6] == POLAXIN -> Polarity of the input reference clock (default 0)
231 233
232 //Activate PLL 234 //Activate PLL
233 tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef); 235 _tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef);
234 return 0; 236 return 0;
235} 237}
236 238
@@ -264,12 +266,12 @@ static int tda10021_set_parameters (struct dvb_frontend *fe,
264 } 266 }
265 267
266 tda10021_set_symbolrate (state, p->u.qam.symbol_rate); 268 tda10021_set_symbolrate (state, p->u.qam.symbol_rate);
267 tda10021_writereg (state, 0x34, state->pwm); 269 _tda10021_writereg (state, 0x34, state->pwm);
268 270
269 tda10021_writereg (state, 0x01, reg0x01[qam]); 271 _tda10021_writereg (state, 0x01, reg0x01[qam]);
270 tda10021_writereg (state, 0x05, reg0x05[qam]); 272 _tda10021_writereg (state, 0x05, reg0x05[qam]);
271 tda10021_writereg (state, 0x08, reg0x08[qam]); 273 _tda10021_writereg (state, 0x08, reg0x08[qam]);
272 tda10021_writereg (state, 0x09, reg0x09[qam]); 274 _tda10021_writereg (state, 0x09, reg0x09[qam]);
273 275
274 tda10021_setup_reg0 (state, reg0x00[qam], p->inversion); 276 tda10021_setup_reg0 (state, reg0x00[qam], p->inversion);
275 277
@@ -342,8 +344,8 @@ static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
342 *ucblocks = 0xffffffff; 344 *ucblocks = 0xffffffff;
343 345
344 /* reset uncorrected block counter */ 346 /* reset uncorrected block counter */
345 tda10021_writereg (state, 0x10, tda10021_inittab[0x10] & 0xdf); 347 _tda10021_writereg (state, 0x10, tda10021_inittab[0x10] & 0xdf);
346 tda10021_writereg (state, 0x10, tda10021_inittab[0x10]); 348 _tda10021_writereg (state, 0x10, tda10021_inittab[0x10]);
347 349
348 return 0; 350 return 0;
349} 351}
@@ -392,8 +394,8 @@ static int tda10021_sleep(struct dvb_frontend* fe)
392{ 394{
393 struct tda10021_state* state = fe->demodulator_priv; 395 struct tda10021_state* state = fe->demodulator_priv;
394 396
395 tda10021_writereg (state, 0x1b, 0x02); /* pdown ADC */ 397 _tda10021_writereg (state, 0x1b, 0x02); /* pdown ADC */
396 tda10021_writereg (state, 0x00, 0x80); /* standby */ 398 _tda10021_writereg (state, 0x00, 0x80); /* standby */
397 399
398 return 0; 400 return 0;
399} 401}
@@ -459,6 +461,7 @@ static struct dvb_frontend_ops tda10021_ops = {
459 461
460 .init = tda10021_init, 462 .init = tda10021_init,
461 .sleep = tda10021_sleep, 463 .sleep = tda10021_sleep,
464 .write = tda10021_write,
462 .i2c_gate_ctrl = tda10021_i2c_gate_ctrl, 465 .i2c_gate_ctrl = tda10021_i2c_gate_ctrl,
463 466
464 .set_frontend = tda10021_set_parameters, 467 .set_frontend = tda10021_set_parameters,
diff --git a/drivers/media/dvb/frontends/tda10021.h b/drivers/media/dvb/frontends/tda10021.h
index b1df4259bee9..d68ae20c8412 100644
--- a/drivers/media/dvb/frontends/tda10021.h
+++ b/drivers/media/dvb/frontends/tda10021.h
@@ -32,9 +32,24 @@ struct tda10021_config
32 u8 demod_address; 32 u8 demod_address;
33}; 33};
34 34
35#if defined(CONFIG_DVB_TDA10021) || defined(CONFIG_DVB_TDA10021_MODULE)
35extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config, 36extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
36 struct i2c_adapter* i2c, u8 pwm); 37 struct i2c_adapter* i2c, u8 pwm);
37 38#else
38extern int tda10021_write_byte(struct dvb_frontend* fe, int reg, int data); 39static inline struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
40 struct i2c_adapter* i2c, u8 pwm)
41{
42 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
43 return NULL;
44}
45#endif // CONFIG_DVB_TDA10021
46
47static inline int tda10021_writereg(struct dvb_frontend *fe, u8 reg, u8 val) {
48 int r = 0;
49 u8 buf[] = {reg, val};
50 if (fe->ops.write)
51 r = fe->ops.write(fe, buf, 2);
52 return r;
53}
39 54
40#endif // TDA10021_H 55#endif // TDA10021_H
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index 59a2ed614fca..11e0dca9a2d7 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -579,11 +579,14 @@ static int tda1004x_decode_fec(int tdafec)
579 return -1; 579 return -1;
580} 580}
581 581
582int tda1004x_write_byte(struct dvb_frontend* fe, int reg, int data) 582int tda1004x_write(struct dvb_frontend* fe, u8 *buf, int len)
583{ 583{
584 struct tda1004x_state* state = fe->demodulator_priv; 584 struct tda1004x_state* state = fe->demodulator_priv;
585 585
586 return tda1004x_write_byteI(state, reg, data); 586 if (len != 2)
587 return -EINVAL;
588
589 return tda1004x_write_byteI(state, buf[0], buf[1]);
587} 590}
588 591
589static int tda10045_init(struct dvb_frontend* fe) 592static int tda10045_init(struct dvb_frontend* fe)
@@ -1216,6 +1219,7 @@ static struct dvb_frontend_ops tda10045_ops = {
1216 1219
1217 .init = tda10045_init, 1220 .init = tda10045_init,
1218 .sleep = tda1004x_sleep, 1221 .sleep = tda1004x_sleep,
1222 .write = tda1004x_write,
1219 .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl, 1223 .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl,
1220 1224
1221 .set_frontend = tda1004x_set_fe, 1225 .set_frontend = tda1004x_set_fe,
@@ -1274,6 +1278,7 @@ static struct dvb_frontend_ops tda10046_ops = {
1274 1278
1275 .init = tda10046_init, 1279 .init = tda10046_init,
1276 .sleep = tda1004x_sleep, 1280 .sleep = tda1004x_sleep,
1281 .write = tda1004x_write,
1277 .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl, 1282 .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl,
1278 1283
1279 .set_frontend = tda1004x_set_fe, 1284 .set_frontend = tda1004x_set_fe,
@@ -1323,4 +1328,3 @@ MODULE_LICENSE("GPL");
1323 1328
1324EXPORT_SYMBOL(tda10045_attach); 1329EXPORT_SYMBOL(tda10045_attach);
1325EXPORT_SYMBOL(tda10046_attach); 1330EXPORT_SYMBOL(tda10046_attach);
1326EXPORT_SYMBOL(tda1004x_write_byte);
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
index b877b23ed734..e28fca05734c 100644
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ b/drivers/media/dvb/frontends/tda1004x.h
@@ -71,12 +71,33 @@ struct tda1004x_config
71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
72}; 72};
73 73
74#if defined(CONFIG_DVB_TDA1004X) || defined(CONFIG_DVB_TDA1004X_MODULE)
74extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, 75extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
75 struct i2c_adapter* i2c); 76 struct i2c_adapter* i2c);
76 77
77extern struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config, 78extern struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
78 struct i2c_adapter* i2c); 79 struct i2c_adapter* i2c);
79 80#else
80extern int tda1004x_write_byte(struct dvb_frontend* fe, int reg, int data); 81static inline struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
82 struct i2c_adapter* i2c)
83{
84 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
85 return NULL;
86}
87static inline struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
88 struct i2c_adapter* i2c)
89{
90 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
91 return NULL;
92}
93#endif // CONFIG_DVB_TDA1004X
94
95static inline int tda1004x_writereg(struct dvb_frontend *fe, u8 reg, u8 val) {
96 int r = 0;
97 u8 buf[] = {reg, val};
98 if (fe->ops.write)
99 r = fe->ops.write(fe, buf, 2);
100 return r;
101}
81 102
82#endif // TDA1004X_H 103#endif // TDA1004X_H
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
new file mode 100644
index 000000000000..7456b0b9976b
--- /dev/null
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -0,0 +1,740 @@
1 /*
2 Driver for Philips tda10086 DVBS Demodulator
3
4 (c) 2006 Andrew de Quincey
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 */
22
23#include <linux/init.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/device.h>
27#include <linux/jiffies.h>
28#include <linux/string.h>
29#include <linux/slab.h>
30
31#include "dvb_frontend.h"
32#include "tda10086.h"
33
34#define SACLK 96000000
35
36struct tda10086_state {
37 struct i2c_adapter* i2c;
38 const struct tda10086_config* config;
39 struct dvb_frontend frontend;
40
41 /* private demod data */
42 u32 frequency;
43 u32 symbol_rate;
44};
45
46static int debug = 0;
47#define dprintk(args...) \
48 do { \
49 if (debug) printk(KERN_DEBUG "tda10086: " args); \
50 } while (0)
51
52static int tda10086_write_byte(struct tda10086_state *state, int reg, int data)
53{
54 int ret;
55 u8 b0[] = { reg, data };
56 struct i2c_msg msg = { .flags = 0, .buf = b0, .len = 2 };
57
58 msg.addr = state->config->demod_address;
59 ret = i2c_transfer(state->i2c, &msg, 1);
60
61 if (ret != 1)
62 dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n",
63 __FUNCTION__, reg, data, ret);
64
65 return (ret != 1) ? ret : 0;
66}
67
68static int tda10086_read_byte(struct tda10086_state *state, int reg)
69{
70 int ret;
71 u8 b0[] = { reg };
72 u8 b1[] = { 0 };
73 struct i2c_msg msg[] = {{ .flags = 0, .buf = b0, .len = 1 },
74 { .flags = I2C_M_RD, .buf = b1, .len = 1 }};
75
76 msg[0].addr = state->config->demod_address;
77 msg[1].addr = state->config->demod_address;
78 ret = i2c_transfer(state->i2c, msg, 2);
79
80 if (ret != 2) {
81 dprintk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__, reg,
82 ret);
83 return ret;
84 }
85
86 return b1[0];
87}
88
89static int tda10086_write_mask(struct tda10086_state *state, int reg, int mask, int data)
90{
91 int val;
92
93 // read a byte and check
94 val = tda10086_read_byte(state, reg);
95 if (val < 0)
96 return val;
97
98 // mask if off
99 val = val & ~mask;
100 val |= data & 0xff;
101
102 // write it out again
103 return tda10086_write_byte(state, reg, val);
104}
105
106static int tda10086_init(struct dvb_frontend* fe)
107{
108 struct tda10086_state* state = fe->demodulator_priv;
109
110 dprintk ("%s\n", __FUNCTION__);
111
112 // reset
113 tda10086_write_byte(state, 0x00, 0x00);
114 msleep(10);
115
116 // misc setup
117 tda10086_write_byte(state, 0x01, 0x94);
118 tda10086_write_byte(state, 0x02, 0x35); // NOTE: TT drivers appear to disable CSWP
119 tda10086_write_byte(state, 0x03, 0x64);
120 tda10086_write_byte(state, 0x04, 0x43);
121 tda10086_write_byte(state, 0x0c, 0x0c);
122 tda10086_write_byte(state, 0x1b, 0xb0); // noise threshold
123 tda10086_write_byte(state, 0x20, 0x89); // misc
124 tda10086_write_byte(state, 0x30, 0x04); // acquisition period length
125 tda10086_write_byte(state, 0x32, 0x00); // irq off
126 tda10086_write_byte(state, 0x31, 0x56); // setup AFC
127
128 // setup PLL (assumes 16Mhz XIN)
129 tda10086_write_byte(state, 0x55, 0x2c); // misc PLL setup
130 tda10086_write_byte(state, 0x3a, 0x0b); // M=12
131 tda10086_write_byte(state, 0x3b, 0x01); // P=2
132 tda10086_write_mask(state, 0x55, 0x20, 0x00); // powerup PLL
133
134 // setup TS interface
135 tda10086_write_byte(state, 0x11, 0x81);
136 tda10086_write_byte(state, 0x12, 0x81);
137 tda10086_write_byte(state, 0x19, 0x40); // parallel mode A + MSBFIRST
138 tda10086_write_byte(state, 0x56, 0x80); // powerdown WPLL - unused in the mode we use
139 tda10086_write_byte(state, 0x57, 0x08); // bypass WPLL - unused in the mode we use
140 tda10086_write_byte(state, 0x10, 0x2a);
141
142 // setup ADC
143 tda10086_write_byte(state, 0x58, 0x61); // ADC setup
144 tda10086_write_mask(state, 0x58, 0x01, 0x00); // powerup ADC
145
146 // setup AGC
147 tda10086_write_byte(state, 0x05, 0x0B);
148 tda10086_write_byte(state, 0x37, 0x63);
149 tda10086_write_byte(state, 0x3f, 0x03); // NOTE: flydvb uses 0x0a and varies it
150 tda10086_write_byte(state, 0x40, 0x64);
151 tda10086_write_byte(state, 0x41, 0x4f);
152 tda10086_write_byte(state, 0x42, 0x43);
153
154 // setup viterbi
155 tda10086_write_byte(state, 0x1a, 0x11); // VBER 10^6, DVB, QPSK
156
157 // setup carrier recovery
158 tda10086_write_byte(state, 0x3d, 0x80);
159
160 // setup SEC
161 tda10086_write_byte(state, 0x36, 0x00); // all SEC off
162 tda10086_write_byte(state, 0x34, (((1<<19) * (22000/1000)) / (SACLK/1000))); // } tone frequency
163 tda10086_write_byte(state, 0x35, (((1<<19) * (22000/1000)) / (SACLK/1000)) >> 8); // }
164
165 return 0;
166}
167
168static void tda10086_diseqc_wait(struct tda10086_state *state)
169{
170 unsigned long timeout = jiffies + msecs_to_jiffies(200);
171 while (!(tda10086_read_byte(state, 0x50) & 0x01)) {
172 if(time_after(jiffies, timeout)) {
173 printk("%s: diseqc queue not ready, command may be lost.\n", __FUNCTION__);
174 break;
175 }
176 msleep(10);
177 }
178}
179
180static int tda10086_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
181{
182 struct tda10086_state* state = fe->demodulator_priv;
183
184 dprintk ("%s\n", __FUNCTION__);
185
186 switch(tone) {
187 case SEC_TONE_OFF:
188 tda10086_write_byte(state, 0x36, 0x00);
189 break;
190
191 case SEC_TONE_ON:
192 tda10086_write_byte(state, 0x36, 0x01);
193 break;
194 }
195
196 return 0;
197}
198
199static int tda10086_send_master_cmd (struct dvb_frontend* fe,
200 struct dvb_diseqc_master_cmd* cmd)
201{
202 struct tda10086_state* state = fe->demodulator_priv;
203 int i;
204 u8 oldval;
205
206 dprintk ("%s\n", __FUNCTION__);
207
208 if (cmd->msg_len > 6)
209 return -EINVAL;
210 oldval = tda10086_read_byte(state, 0x36);
211
212 for(i=0; i< cmd->msg_len; i++) {
213 tda10086_write_byte(state, 0x48+i, cmd->msg[i]);
214 }
215 tda10086_write_byte(state, 0x36, 0x08 | ((cmd->msg_len + 1) << 4));
216
217 tda10086_diseqc_wait(state);
218
219 tda10086_write_byte(state, 0x36, oldval);
220
221 return 0;
222}
223
224static int tda10086_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
225{
226 struct tda10086_state* state = fe->demodulator_priv;
227 u8 oldval = tda10086_read_byte(state, 0x36);
228
229 dprintk ("%s\n", __FUNCTION__);
230
231 switch(minicmd) {
232 case SEC_MINI_A:
233 tda10086_write_byte(state, 0x36, 0x04);
234 break;
235
236 case SEC_MINI_B:
237 tda10086_write_byte(state, 0x36, 0x06);
238 break;
239 }
240
241 tda10086_diseqc_wait(state);
242
243 tda10086_write_byte(state, 0x36, oldval);
244
245 return 0;
246}
247
248static int tda10086_set_inversion(struct tda10086_state *state,
249 struct dvb_frontend_parameters *fe_params)
250{
251 u8 invval = 0x80;
252
253 dprintk ("%s %i %i\n", __FUNCTION__, fe_params->inversion, state->config->invert);
254
255 switch(fe_params->inversion) {
256 case INVERSION_OFF:
257 if (state->config->invert)
258 invval = 0x40;
259 break;
260 case INVERSION_ON:
261 if (!state->config->invert)
262 invval = 0x40;
263 break;
264 case INVERSION_AUTO:
265 invval = 0x00;
266 break;
267 }
268 tda10086_write_mask(state, 0x0c, 0xc0, invval);
269
270 return 0;
271}
272
273static int tda10086_set_symbol_rate(struct tda10086_state *state,
274 struct dvb_frontend_parameters *fe_params)
275{
276 u8 dfn = 0;
277 u8 afs = 0;
278 u8 byp = 0;
279 u8 reg37 = 0x43;
280 u8 reg42 = 0x43;
281 u64 big;
282 u32 tmp;
283 u32 bdr;
284 u32 bdri;
285 u32 symbol_rate = fe_params->u.qpsk.symbol_rate;
286
287 dprintk ("%s %i\n", __FUNCTION__, symbol_rate);
288
289 // setup the decimation and anti-aliasing filters..
290 if (symbol_rate < (u32) (SACLK * 0.0137)) {
291 dfn=4;
292 afs=1;
293 } else if (symbol_rate < (u32) (SACLK * 0.0208)) {
294 dfn=4;
295 afs=0;
296 } else if (symbol_rate < (u32) (SACLK * 0.0270)) {
297 dfn=3;
298 afs=1;
299 } else if (symbol_rate < (u32) (SACLK * 0.0416)) {
300 dfn=3;
301 afs=0;
302 } else if (symbol_rate < (u32) (SACLK * 0.0550)) {
303 dfn=2;
304 afs=1;
305 } else if (symbol_rate < (u32) (SACLK * 0.0833)) {
306 dfn=2;
307 afs=0;
308 } else if (symbol_rate < (u32) (SACLK * 0.1100)) {
309 dfn=1;
310 afs=1;
311 } else if (symbol_rate < (u32) (SACLK * 0.1666)) {
312 dfn=1;
313 afs=0;
314 } else if (symbol_rate < (u32) (SACLK * 0.2200)) {
315 dfn=0;
316 afs=1;
317 } else if (symbol_rate < (u32) (SACLK * 0.3333)) {
318 dfn=0;
319 afs=0;
320 } else {
321 reg37 = 0x63;
322 reg42 = 0x4f;
323 byp=1;
324 }
325
326 // calculate BDR
327 big = (1ULL<<21) * ((u64) symbol_rate/1000ULL) * (1ULL<<dfn);
328 big += ((SACLK/1000ULL)-1ULL);
329 do_div(big, (SACLK/1000ULL));
330 bdr = big & 0xfffff;
331
332 // calculate BDRI
333 tmp = (1<<dfn)*(symbol_rate/1000);
334 bdri = ((32 * (SACLK/1000)) + (tmp-1)) / tmp;
335
336 tda10086_write_byte(state, 0x21, (afs << 7) | dfn);
337 tda10086_write_mask(state, 0x20, 0x08, byp << 3);
338 tda10086_write_byte(state, 0x06, bdr);
339 tda10086_write_byte(state, 0x07, bdr >> 8);
340 tda10086_write_byte(state, 0x08, bdr >> 16);
341 tda10086_write_byte(state, 0x09, bdri);
342 tda10086_write_byte(state, 0x37, reg37);
343 tda10086_write_byte(state, 0x42, reg42);
344
345 return 0;
346}
347
348static int tda10086_set_fec(struct tda10086_state *state,
349 struct dvb_frontend_parameters *fe_params)
350{
351 u8 fecval;
352
353 dprintk ("%s %i\n", __FUNCTION__, fe_params->u.qpsk.fec_inner);
354
355 switch(fe_params->u.qpsk.fec_inner) {
356 case FEC_1_2:
357 fecval = 0x00;
358 break;
359 case FEC_2_3:
360 fecval = 0x01;
361 break;
362 case FEC_3_4:
363 fecval = 0x02;
364 break;
365 case FEC_4_5:
366 fecval = 0x03;
367 break;
368 case FEC_5_6:
369 fecval = 0x04;
370 break;
371 case FEC_6_7:
372 fecval = 0x05;
373 break;
374 case FEC_7_8:
375 fecval = 0x06;
376 break;
377 case FEC_8_9:
378 fecval = 0x07;
379 break;
380 case FEC_AUTO:
381 fecval = 0x08;
382 break;
383 default:
384 return -1;
385 }
386 tda10086_write_byte(state, 0x0d, fecval);
387
388 return 0;
389}
390
391static int tda10086_set_frontend(struct dvb_frontend* fe,
392 struct dvb_frontend_parameters *fe_params)
393{
394 struct tda10086_state *state = fe->demodulator_priv;
395 int ret;
396 u32 freq = 0;
397 int freqoff;
398
399 dprintk ("%s\n", __FUNCTION__);
400
401 // set params
402 if (fe->ops.tuner_ops.set_params) {
403 fe->ops.tuner_ops.set_params(fe, fe_params);
404 if (fe->ops.i2c_gate_ctrl)
405 fe->ops.i2c_gate_ctrl(fe, 0);
406
407 if (fe->ops.tuner_ops.get_frequency)
408 fe->ops.tuner_ops.get_frequency(fe, &freq);
409 if (fe->ops.i2c_gate_ctrl)
410 fe->ops.i2c_gate_ctrl(fe, 0);
411 }
412
413 // calcluate the frequency offset (in *Hz* not kHz)
414 freqoff = fe_params->frequency - freq;
415 freqoff = ((1<<16) * freqoff) / (SACLK/1000);
416 tda10086_write_byte(state, 0x3d, 0x80 | ((freqoff >> 8) & 0x7f));
417 tda10086_write_byte(state, 0x3e, freqoff);
418
419 if ((ret = tda10086_set_inversion(state, fe_params)) < 0)
420 return ret;
421 if ((ret = tda10086_set_symbol_rate(state, fe_params)) < 0)
422 return ret;
423 if ((ret = tda10086_set_fec(state, fe_params)) < 0)
424 return ret;
425
426 // soft reset + disable TS output until lock
427 tda10086_write_mask(state, 0x10, 0x40, 0x40);
428 tda10086_write_mask(state, 0x00, 0x01, 0x00);
429
430 state->symbol_rate = fe_params->u.qpsk.symbol_rate;
431 state->frequency = fe_params->frequency;
432 return 0;
433}
434
435static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *fe_params)
436{
437 struct tda10086_state* state = fe->demodulator_priv;
438 u8 val;
439 int tmp;
440 u64 tmp64;
441
442 dprintk ("%s\n", __FUNCTION__);
443
444 // calculate the updated frequency (note: we convert from Hz->kHz)
445 tmp64 = tda10086_read_byte(state, 0x52);
446 tmp64 |= (tda10086_read_byte(state, 0x51) << 8);
447 if (tmp64 & 0x8000)
448 tmp64 |= 0xffffffffffff0000ULL;
449 tmp64 = (tmp64 * (SACLK/1000ULL));
450 do_div(tmp64, (1ULL<<15) * (1ULL<<1));
451 fe_params->frequency = (int) state->frequency + (int) tmp64;
452
453 // the inversion
454 val = tda10086_read_byte(state, 0x0c);
455 if (val & 0x80) {
456 switch(val & 0x40) {
457 case 0x00:
458 fe_params->inversion = INVERSION_OFF;
459 if (state->config->invert)
460 fe_params->inversion = INVERSION_ON;
461 break;
462 default:
463 fe_params->inversion = INVERSION_ON;
464 if (state->config->invert)
465 fe_params->inversion = INVERSION_OFF;
466 break;
467 }
468 } else {
469 tda10086_read_byte(state, 0x0f);
470 switch(val & 0x02) {
471 case 0x00:
472 fe_params->inversion = INVERSION_OFF;
473 if (state->config->invert)
474 fe_params->inversion = INVERSION_ON;
475 break;
476 default:
477 fe_params->inversion = INVERSION_ON;
478 if (state->config->invert)
479 fe_params->inversion = INVERSION_OFF;
480 break;
481 }
482 }
483
484 // calculate the updated symbol rate
485 tmp = tda10086_read_byte(state, 0x1d);
486 if (tmp & 0x80)
487 tmp |= 0xffffff00;
488 tmp = (tmp * 480 * (1<<1)) / 128;
489 tmp = ((state->symbol_rate/1000) * tmp) / (1000000/1000);
490 fe_params->u.qpsk.symbol_rate = state->symbol_rate + tmp;
491
492 // the FEC
493 val = (tda10086_read_byte(state, 0x0d) & 0x70) >> 4;
494 switch(val) {
495 case 0x00:
496 fe_params->u.qpsk.fec_inner = FEC_1_2;
497 break;
498 case 0x01:
499 fe_params->u.qpsk.fec_inner = FEC_2_3;
500 break;
501 case 0x02:
502 fe_params->u.qpsk.fec_inner = FEC_3_4;
503 break;
504 case 0x03:
505 fe_params->u.qpsk.fec_inner = FEC_4_5;
506 break;
507 case 0x04:
508 fe_params->u.qpsk.fec_inner = FEC_5_6;
509 break;
510 case 0x05:
511 fe_params->u.qpsk.fec_inner = FEC_6_7;
512 break;
513 case 0x06:
514 fe_params->u.qpsk.fec_inner = FEC_7_8;
515 break;
516 case 0x07:
517 fe_params->u.qpsk.fec_inner = FEC_8_9;
518 break;
519 }
520
521 return 0;
522}
523
524static int tda10086_read_status(struct dvb_frontend* fe, fe_status_t *fe_status)
525{
526 struct tda10086_state* state = fe->demodulator_priv;
527 u8 val;
528
529 dprintk ("%s\n", __FUNCTION__);
530
531 val = tda10086_read_byte(state, 0x0e);
532 *fe_status = 0;
533 if (val & 0x01)
534 *fe_status |= FE_HAS_SIGNAL;
535 if (val & 0x02)
536 *fe_status |= FE_HAS_CARRIER;
537 if (val & 0x04)
538 *fe_status |= FE_HAS_VITERBI;
539 if (val & 0x08)
540 *fe_status |= FE_HAS_SYNC;
541 if (val & 0x10)
542 *fe_status |= FE_HAS_LOCK;
543
544 return 0;
545}
546
547static int tda10086_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
548{
549 struct tda10086_state* state = fe->demodulator_priv;
550 u8 _str;
551
552 dprintk ("%s\n", __FUNCTION__);
553
554 _str = tda10086_read_byte(state, 0x43);
555 *signal = (_str << 8) | _str;
556
557 return 0;
558}
559
560static int tda10086_read_snr(struct dvb_frontend* fe, u16 * snr)
561{
562 struct tda10086_state* state = fe->demodulator_priv;
563 u8 _snr;
564
565 dprintk ("%s\n", __FUNCTION__);
566
567 _snr = tda10086_read_byte(state, 0x1c);
568 *snr = (_snr << 8) | _snr;
569
570 return 0;
571}
572
573static int tda10086_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
574{
575 struct tda10086_state* state = fe->demodulator_priv;
576
577 dprintk ("%s\n", __FUNCTION__);
578
579 // read it
580 *ucblocks = tda10086_read_byte(state, 0x18) & 0x7f;
581
582 // reset counter
583 tda10086_write_byte(state, 0x18, 0x00);
584 tda10086_write_byte(state, 0x18, 0x80);
585
586 return 0;
587}
588
589static int tda10086_read_ber(struct dvb_frontend* fe, u32* ber)
590{
591 struct tda10086_state* state = fe->demodulator_priv;
592
593 dprintk ("%s\n", __FUNCTION__);
594
595 // read it
596 *ber = 0;
597 *ber |= tda10086_read_byte(state, 0x15);
598 *ber |= tda10086_read_byte(state, 0x16) << 8;
599 *ber |= (tda10086_read_byte(state, 0x17) & 0xf) << 16;
600
601 return 0;
602}
603
604static int tda10086_sleep(struct dvb_frontend* fe)
605{
606 struct tda10086_state* state = fe->demodulator_priv;
607
608 dprintk ("%s\n", __FUNCTION__);
609
610 tda10086_write_mask(state, 0x00, 0x08, 0x08);
611
612 return 0;
613}
614
615static int tda10086_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
616{
617 struct tda10086_state* state = fe->demodulator_priv;
618
619 dprintk ("%s\n", __FUNCTION__);
620
621 if (enable) {
622 tda10086_write_mask(state, 0x00, 0x10, 0x10);
623 } else {
624 tda10086_write_mask(state, 0x00, 0x10, 0x00);
625 }
626
627 return 0;
628}
629
630static int tda10086_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
631{
632 if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) {
633 fesettings->min_delay_ms = 50;
634 fesettings->step_size = 2000;
635 fesettings->max_drift = 8000;
636 } else if (fesettings->parameters.u.qpsk.symbol_rate > 12000000) {
637 fesettings->min_delay_ms = 100;
638 fesettings->step_size = 1500;
639 fesettings->max_drift = 9000;
640 } else if (fesettings->parameters.u.qpsk.symbol_rate > 8000000) {
641 fesettings->min_delay_ms = 100;
642 fesettings->step_size = 1000;
643 fesettings->max_drift = 8000;
644 } else if (fesettings->parameters.u.qpsk.symbol_rate > 4000000) {
645 fesettings->min_delay_ms = 100;
646 fesettings->step_size = 500;
647 fesettings->max_drift = 7000;
648 } else if (fesettings->parameters.u.qpsk.symbol_rate > 2000000) {
649 fesettings->min_delay_ms = 200;
650 fesettings->step_size = (fesettings->parameters.u.qpsk.symbol_rate / 8000);
651 fesettings->max_drift = 14 * fesettings->step_size;
652 } else {
653 fesettings->min_delay_ms = 200;
654 fesettings->step_size = (fesettings->parameters.u.qpsk.symbol_rate / 8000);
655 fesettings->max_drift = 18 * fesettings->step_size;
656 }
657
658 return 0;
659}
660
661static void tda10086_release(struct dvb_frontend* fe)
662{
663 struct tda10086_state *state = fe->demodulator_priv;
664 tda10086_sleep(fe);
665 kfree(state);
666}
667
668static struct dvb_frontend_ops tda10086_ops = {
669
670 .info = {
671 .name = "Philips TDA10086 DVB-S",
672 .type = FE_QPSK,
673 .frequency_min = 950000,
674 .frequency_max = 2150000,
675 .frequency_stepsize = 125, /* kHz for QPSK frontends */
676 .symbol_rate_min = 1000000,
677 .symbol_rate_max = 45000000,
678 .caps = FE_CAN_INVERSION_AUTO |
679 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
680 FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
681 FE_CAN_QPSK
682 },
683
684 .release = tda10086_release,
685
686 .init = tda10086_init,
687 .sleep = tda10086_sleep,
688 .i2c_gate_ctrl = tda10086_i2c_gate_ctrl,
689
690 .set_frontend = tda10086_set_frontend,
691 .get_frontend = tda10086_get_frontend,
692 .get_tune_settings = tda10086_get_tune_settings,
693
694 .read_status = tda10086_read_status,
695 .read_ber = tda10086_read_ber,
696 .read_signal_strength = tda10086_read_signal_strength,
697 .read_snr = tda10086_read_snr,
698 .read_ucblocks = tda10086_read_ucblocks,
699
700 .diseqc_send_master_cmd = tda10086_send_master_cmd,
701 .diseqc_send_burst = tda10086_send_burst,
702 .set_tone = tda10086_set_tone,
703};
704
705struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
706 struct i2c_adapter* i2c)
707{
708 struct tda10086_state *state;
709
710 dprintk ("%s\n", __FUNCTION__);
711
712 /* allocate memory for the internal state */
713 state = kmalloc(sizeof(struct tda10086_state), GFP_KERNEL);
714 if (!state)
715 return NULL;
716
717 /* setup the state */
718 state->config = config;
719 state->i2c = i2c;
720
721 /* check if the demod is there */
722 if (tda10086_read_byte(state, 0x1e) != 0xe1) {
723 kfree(state);
724 return NULL;
725 }
726
727 /* create dvb_frontend */
728 memcpy(&state->frontend.ops, &tda10086_ops, sizeof(struct dvb_frontend_ops));
729 state->frontend.demodulator_priv = state;
730 return &state->frontend;
731}
732
733module_param(debug, int, 0644);
734MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
735
736MODULE_DESCRIPTION("Philips TDA10086 DVB-S Demodulator");
737MODULE_AUTHOR("Andrew de Quincey");
738MODULE_LICENSE("GPL");
739
740EXPORT_SYMBOL(tda10086_attach);
diff --git a/drivers/media/dvb/frontends/tda10086.h b/drivers/media/dvb/frontends/tda10086.h
new file mode 100644
index 000000000000..e8061db11123
--- /dev/null
+++ b/drivers/media/dvb/frontends/tda10086.h
@@ -0,0 +1,41 @@
1 /*
2 Driver for Philips tda10086 DVBS Frontend
3
4 (c) 2006 Andrew de Quincey
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 */
22
23#ifndef TDA10086_H
24#define TDA10086_H
25
26#include <linux/dvb/frontend.h>
27#include <linux/firmware.h>
28
29struct tda10086_config
30{
31 /* the demodulator's i2c address */
32 u8 demod_address;
33
34 /* does the "inversion" need inverted? */
35 u8 invert;
36};
37
38extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
39 struct i2c_adapter* i2c);
40
41#endif // TDA10086_H
diff --git a/drivers/media/dvb/frontends/tda8083.h b/drivers/media/dvb/frontends/tda8083.h
index e7a48f61ea2c..aae15bdce6eb 100644
--- a/drivers/media/dvb/frontends/tda8083.h
+++ b/drivers/media/dvb/frontends/tda8083.h
@@ -35,7 +35,16 @@ struct tda8083_config
35 u8 demod_address; 35 u8 demod_address;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA8083) || defined(CONFIG_DVB_TDA8083_MODULE)
38extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, 39extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
39 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else
42static inline struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
43 struct i2c_adapter* i2c)
44{
45 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
46 return NULL;
47}
48#endif // CONFIG_DVB_TDA8083
40 49
41#endif // TDA8083_H 50#endif // TDA8083_H
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
new file mode 100644
index 000000000000..eeab26bd36ed
--- /dev/null
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -0,0 +1,173 @@
1 /*
2 Driver for Philips tda8262/tda8263 DVBS Silicon tuners
3
4 (c) 2006 Andrew de Quincey
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 */
22
23#include <linux/module.h>
24#include <linux/dvb/frontend.h>
25#include <asm/types.h>
26
27#include "tda826x.h"
28
29static int debug = 0;
30#define dprintk(args...) \
31 do { \
32 if (debug) printk(KERN_DEBUG "tda826x: " args); \
33 } while (0)
34
35struct tda826x_priv {
36 /* i2c details */
37 int i2c_address;
38 struct i2c_adapter *i2c;
39 u8 has_loopthrough:1;
40 u32 frequency;
41};
42
43static int tda826x_release(struct dvb_frontend *fe)
44{
45 if (fe->tuner_priv)
46 kfree(fe->tuner_priv);
47 fe->tuner_priv = NULL;
48 return 0;
49}
50
51static int tda826x_sleep(struct dvb_frontend *fe)
52{
53 struct tda826x_priv *priv = fe->tuner_priv;
54 int ret;
55 u8 buf [] = { 0x00, 0x8d };
56 struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 2 };
57
58 dprintk("%s:\n", __FUNCTION__);
59
60 if (!priv->has_loopthrough)
61 buf[1] = 0xad;
62
63 if (fe->ops.i2c_gate_ctrl)
64 fe->ops.i2c_gate_ctrl(fe, 1);
65 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) {
66 dprintk("%s: i2c error\n", __FUNCTION__);
67 }
68 if (fe->ops.i2c_gate_ctrl)
69 fe->ops.i2c_gate_ctrl(fe, 0);
70
71 return (ret == 1) ? 0 : ret;
72}
73
74static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
75{
76 struct tda826x_priv *priv = fe->tuner_priv;
77 int ret;
78 u32 div;
79 u8 buf [11];
80 struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 11 };
81
82 dprintk("%s:\n", __FUNCTION__);
83
84 div = (params->frequency + (1000-1)) / 1000;
85
86 buf[0] = 0x00; // subaddress
87 buf[1] = 0x09; // powerdown RSSI + the magic value 1
88 if (!priv->has_loopthrough)
89 buf[1] |= 0x20; // power down loopthrough if not needed
90 buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO
91 buf[3] = div >> 7;
92 buf[4] = div << 1;
93 buf[5] = 0xff; // basedband filter to max
94 buf[6] = 0xfe; // gains at max + no RF attenuation
95 buf[7] = 0x83; // charge pumps at high, tests off
96 buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports.
97 buf[9] = 0x1a; // normal caltime + recommended values for SELTH + SELVTL
98 buf[10] = 0xd4; // recommended value 13 for BBIAS + unknown bit set on
99
100 if (fe->ops.i2c_gate_ctrl)
101 fe->ops.i2c_gate_ctrl(fe, 1);
102 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) {
103 dprintk("%s: i2c error\n", __FUNCTION__);
104 }
105 if (fe->ops.i2c_gate_ctrl)
106 fe->ops.i2c_gate_ctrl(fe, 0);
107
108 priv->frequency = div * 1000;
109
110 return (ret == 1) ? 0 : ret;
111}
112
113static int tda826x_get_frequency(struct dvb_frontend *fe, u32 *frequency)
114{
115 struct tda826x_priv *priv = fe->tuner_priv;
116 *frequency = priv->frequency;
117 return 0;
118}
119
120static struct dvb_tuner_ops tda826x_tuner_ops = {
121 .info = {
122 .name = "Philips TDA826X",
123 .frequency_min = 950000,
124 .frequency_min = 2175000
125 },
126 .release = tda826x_release,
127 .sleep = tda826x_sleep,
128 .set_params = tda826x_set_params,
129 .get_frequency = tda826x_get_frequency,
130};
131
132struct dvb_frontend *tda826x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, int has_loopthrough)
133{
134 struct tda826x_priv *priv = NULL;
135 u8 b1 [] = { 0, 0 };
136 struct i2c_msg msg = { .addr = addr, .flags = I2C_M_RD, .buf = b1, .len = 2 };
137 int ret;
138
139 dprintk("%s:\n", __FUNCTION__);
140
141 if (fe->ops.i2c_gate_ctrl)
142 fe->ops.i2c_gate_ctrl(fe, 1);
143 ret = i2c_transfer (i2c, &msg, 1);
144 if (fe->ops.i2c_gate_ctrl)
145 fe->ops.i2c_gate_ctrl(fe, 0);
146
147 if (ret != 1)
148 return NULL;
149 if (!(b1[1] & 0x80))
150 return NULL;
151
152 priv = kzalloc(sizeof(struct tda826x_priv), GFP_KERNEL);
153 if (priv == NULL)
154 return NULL;
155
156 priv->i2c_address = addr;
157 priv->i2c = i2c;
158 priv->has_loopthrough = has_loopthrough;
159
160 memcpy(&fe->ops.tuner_ops, &tda826x_tuner_ops, sizeof(struct dvb_tuner_ops));
161
162 fe->tuner_priv = priv;
163
164 return fe;
165}
166EXPORT_SYMBOL(tda826x_attach);
167
168module_param(debug, int, 0644);
169MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
170
171MODULE_DESCRIPTION("DVB TDA826x driver");
172MODULE_AUTHOR("Andrew de Quincey");
173MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/tda826x.h b/drivers/media/dvb/frontends/tda826x.h
new file mode 100644
index 000000000000..3307607632b0
--- /dev/null
+++ b/drivers/media/dvb/frontends/tda826x.h
@@ -0,0 +1,40 @@
1 /*
2 Driver for Philips tda8262/tda8263 DVBS Silicon tuners
3
4 (c) 2006 Andrew de Quincey
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 */
22
23#ifndef __DVB_TDA826X_H__
24#define __DVB_TDA826X_H__
25
26#include <linux/i2c.h>
27#include "dvb_frontend.h"
28
29/**
30 * Attach a tda826x tuner to the supplied frontend structure.
31 *
32 * @param fe Frontend to attach to.
33 * @param addr i2c address of the tuner.
34 * @param i2c i2c adapter to use.
35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector.
36 * @return FE pointer on success, NULL on failure.
37 */
38extern struct dvb_frontend *tda826x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, int has_loopthrough);
39
40#endif
diff --git a/drivers/media/dvb/frontends/tua6100.c b/drivers/media/dvb/frontends/tua6100.c
new file mode 100644
index 000000000000..88554393a9bf
--- /dev/null
+++ b/drivers/media/dvb/frontends/tua6100.c
@@ -0,0 +1,205 @@
1/**
2 * Driver for Infineon tua6100 pll.
3 *
4 * (c) 2006 Andrew de Quincey
5 *
6 * Based on code found in budget-av.c, which has the following:
7 * Compiled from various sources by Michael Hunold <michael@mihu.de>
8 *
9 * CI interface support (c) 2004 Olivier Gournet <ogournet@anevia.com> &
10 * Andrew de Quincey <adq_dvb@lidskialf.net>
11 *
12 * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
13 *
14 * Copyright (C) 1999-2002 Ralph Metzler
15 * & Marcus Metzler for convergence integrated media GmbH
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */
30
31#include <linux/module.h>
32#include <linux/dvb/frontend.h>
33#include <asm/types.h>
34
35#include "tua6100.h"
36
37struct tua6100_priv {
38 /* i2c details */
39 int i2c_address;
40 struct i2c_adapter *i2c;
41 u32 frequency;
42};
43
44static int tua6100_release(struct dvb_frontend *fe)
45{
46 if (fe->tuner_priv)
47 kfree(fe->tuner_priv);
48 fe->tuner_priv = NULL;
49 return 0;
50}
51
52static int tua6100_sleep(struct dvb_frontend *fe)
53{
54 struct tua6100_priv *priv = fe->tuner_priv;
55 int ret;
56 u8 reg0[] = { 0x00, 0x00 };
57 struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = reg0, .len = 2 };
58
59 if (fe->ops.i2c_gate_ctrl)
60 fe->ops.i2c_gate_ctrl(fe, 1);
61 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) {
62 printk("%s: i2c error\n", __FUNCTION__);
63 }
64 if (fe->ops.i2c_gate_ctrl)
65 fe->ops.i2c_gate_ctrl(fe, 0);
66
67 return (ret == 1) ? 0 : ret;
68}
69
70static int tua6100_set_params(struct dvb_frontend *fe,
71 struct dvb_frontend_parameters *params)
72{
73 struct tua6100_priv *priv = fe->tuner_priv;
74 u32 div;
75 u32 prediv;
76 u8 reg0[] = { 0x00, 0x00 };
77 u8 reg1[] = { 0x01, 0x00, 0x00, 0x00 };
78 u8 reg2[] = { 0x02, 0x00, 0x00 };
79 struct i2c_msg msg0 = { .addr = priv->i2c_address, .flags = 0, .buf = reg0, .len = 2 };
80 struct i2c_msg msg1 = { .addr = priv->i2c_address, .flags = 0, .buf = reg1, .len = 4 };
81 struct i2c_msg msg2 = { .addr = priv->i2c_address, .flags = 0, .buf = reg2, .len = 3 };
82
83#define _R 4
84#define _P 32
85#define _ri 4000000
86
87 // setup register 0
88 if (params->frequency < 2000000) {
89 reg0[1] = 0x03;
90 } else {
91 reg0[1] = 0x07;
92 }
93
94 // setup register 1
95 if (params->frequency < 1630000) {
96 reg1[1] = 0x2c;
97 } else {
98 reg1[1] = 0x0c;
99 }
100 if (_P == 64)
101 reg1[1] |= 0x40;
102 if (params->frequency >= 1525000)
103 reg1[1] |= 0x80;
104
105 // register 2
106 reg2[1] = (_R >> 8) & 0x03;
107 reg2[2] = _R;
108 if (params->frequency < 1455000) {
109 reg2[1] |= 0x1c;
110 } else if (params->frequency < 1630000) {
111 reg2[1] |= 0x0c;
112 } else {
113 reg2[1] |= 0x1c;
114 }
115
116 // The N divisor ratio (note: params->frequency is in kHz, but we need it in Hz)
117 prediv = (params->frequency * _R) / (_ri / 1000);
118 div = prediv / _P;
119 reg1[1] |= (div >> 9) & 0x03;
120 reg1[2] = div >> 1;
121 reg1[3] = (div << 7);
122 priv->frequency = ((div * _P) * (_ri / 1000)) / _R;
123
124 // Finally, calculate and store the value for A
125 reg1[3] |= (prediv - (div*_P)) & 0x7f;
126
127#undef _R
128#undef _P
129#undef _ri
130
131 if (fe->ops.i2c_gate_ctrl)
132 fe->ops.i2c_gate_ctrl(fe, 1);
133 if (i2c_transfer(priv->i2c, &msg0, 1) != 1)
134 return -EIO;
135
136 if (fe->ops.i2c_gate_ctrl)
137 fe->ops.i2c_gate_ctrl(fe, 1);
138 if (i2c_transfer(priv->i2c, &msg2, 1) != 1)
139 return -EIO;
140
141 if (fe->ops.i2c_gate_ctrl)
142 fe->ops.i2c_gate_ctrl(fe, 1);
143 if (i2c_transfer(priv->i2c, &msg1, 1) != 1)
144 return -EIO;
145
146 if (fe->ops.i2c_gate_ctrl)
147 fe->ops.i2c_gate_ctrl(fe, 0);
148
149 return 0;
150}
151
152static int tua6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
153{
154 struct tua6100_priv *priv = fe->tuner_priv;
155 *frequency = priv->frequency;
156 return 0;
157}
158
159static struct dvb_tuner_ops tua6100_tuner_ops = {
160 .info = {
161 .name = "Infineon TUA6100",
162 .frequency_min = 950000,
163 .frequency_max = 2150000,
164 .frequency_step = 1000,
165 },
166 .release = tua6100_release,
167 .sleep = tua6100_sleep,
168 .set_params = tua6100_set_params,
169 .get_frequency = tua6100_get_frequency,
170};
171
172struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c)
173{
174 struct tua6100_priv *priv = NULL;
175 u8 b1 [] = { 0x80 };
176 u8 b2 [] = { 0x00 };
177 struct i2c_msg msg [] = { { .addr = addr, .flags = 0, .buf = b1, .len = 1 },
178 { .addr = addr, .flags = I2C_M_RD, .buf = b2, .len = 1 } };
179 int ret;
180
181 if (fe->ops.i2c_gate_ctrl)
182 fe->ops.i2c_gate_ctrl(fe, 1);
183 ret = i2c_transfer (i2c, msg, 2);
184 if (fe->ops.i2c_gate_ctrl)
185 fe->ops.i2c_gate_ctrl(fe, 0);
186
187 if (ret != 2)
188 return NULL;
189
190 priv = kzalloc(sizeof(struct tua6100_priv), GFP_KERNEL);
191 if (priv == NULL)
192 return NULL;
193
194 priv->i2c_address = addr;
195 priv->i2c = i2c;
196
197 memcpy(&fe->ops.tuner_ops, &tua6100_tuner_ops, sizeof(struct dvb_tuner_ops));
198 fe->tuner_priv = priv;
199 return fe;
200}
201EXPORT_SYMBOL(tua6100_attach);
202
203MODULE_DESCRIPTION("DVB tua6100 driver");
204MODULE_AUTHOR("Andrew de Quincey");
205MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/tua6100.h b/drivers/media/dvb/frontends/tua6100.h
new file mode 100644
index 000000000000..8f98033ffa7b
--- /dev/null
+++ b/drivers/media/dvb/frontends/tua6100.h
@@ -0,0 +1,47 @@
1/**
2 * Driver for Infineon tua6100 PLL.
3 *
4 * (c) 2006 Andrew de Quincey
5 *
6 * Based on code found in budget-av.c, which has the following:
7 * Compiled from various sources by Michael Hunold <michael@mihu.de>
8 *
9 * CI interface support (c) 2004 Olivier Gournet <ogournet@anevia.com> &
10 * Andrew de Quincey <adq_dvb@lidskialf.net>
11 *
12 * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
13 *
14 * Copyright (C) 1999-2002 Ralph Metzler
15 * & Marcus Metzler for convergence integrated media GmbH
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */
30
31#ifndef __DVB_TUA6100_H__
32#define __DVB_TUA6100_H__
33
34#include <linux/i2c.h>
35#include "dvb_frontend.h"
36
37#if defined(CONFIG_DVB_TUA6100) || defined(CONFIG_DVB_TUA6100_MODULE)
38extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c);
39#else
40static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c)
41{
42 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
43 return NULL;
44}
45#endif // CONFIG_DVB_TUA6100
46
47#endif
diff --git a/drivers/media/dvb/frontends/ves1820.h b/drivers/media/dvb/frontends/ves1820.h
index 520f09522fbb..f0c9dded39d7 100644
--- a/drivers/media/dvb/frontends/ves1820.h
+++ b/drivers/media/dvb/frontends/ves1820.h
@@ -41,7 +41,16 @@ struct ves1820_config
41 u8 selagc:1; 41 u8 selagc:1;
42}; 42};
43 43
44#if defined(CONFIG_DVB_VES1820) || defined(CONFIG_DVB_VES1820_MODULE)
44extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, 45extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
45 struct i2c_adapter* i2c, u8 pwm); 46 struct i2c_adapter* i2c, u8 pwm);
47#else
48static inline struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
49 struct i2c_adapter* i2c, u8 pwm)
50{
51 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
52 return NULL;
53}
54#endif // CONFIG_DVB_VES1820
46 55
47#endif // VES1820_H 56#endif // VES1820_H
diff --git a/drivers/media/dvb/frontends/ves1x93.h b/drivers/media/dvb/frontends/ves1x93.h
index ba88ae0855c9..395fed39b286 100644
--- a/drivers/media/dvb/frontends/ves1x93.h
+++ b/drivers/media/dvb/frontends/ves1x93.h
@@ -40,7 +40,16 @@ struct ves1x93_config
40 u8 invert_pwm:1; 40 u8 invert_pwm:1;
41}; 41};
42 42
43#if defined(CONFIG_DVB_VES1X93) || defined(CONFIG_DVB_VES1X93_MODULE)
43extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, 44extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
44 struct i2c_adapter* i2c); 45 struct i2c_adapter* i2c);
46#else
47static inline struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
48 struct i2c_adapter* i2c)
49{
50 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
51 return NULL;
52}
53#endif // CONFIG_DVB_VES1X93
45 54
46#endif // VES1X93_H 55#endif // VES1X93_H
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index 2b95e8b6cd39..0e9b59af271e 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -140,6 +140,8 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
140 zl10353_single_write(fe, 0x5E, 0x00); 140 zl10353_single_write(fe, 0x5E, 0x00);
141 zl10353_single_write(fe, 0x65, 0x5A); 141 zl10353_single_write(fe, 0x65, 0x5A);
142 zl10353_single_write(fe, 0x66, 0xE9); 142 zl10353_single_write(fe, 0x66, 0xE9);
143 zl10353_single_write(fe, 0x6C, 0xCD);
144 zl10353_single_write(fe, 0x6D, 0x7E);
143 zl10353_single_write(fe, 0x62, 0x0A); 145 zl10353_single_write(fe, 0x62, 0x0A);
144 146
145 // if there is no attached secondary tuner, we call set_params to program 147 // if there is no attached secondary tuner, we call set_params to program
@@ -168,6 +170,7 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
168 // even if there isn't a PLL attached to the secondary bus 170 // even if there isn't a PLL attached to the secondary bus
169 zl10353_write(fe, pllbuf, sizeof(pllbuf)); 171 zl10353_write(fe, pllbuf, sizeof(pllbuf));
170 172
173 zl10353_single_write(fe, 0x5F, 0x13);
171 zl10353_single_write(fe, 0x70, 0x01); 174 zl10353_single_write(fe, 0x70, 0x01);
172 udelay(250); 175 udelay(250);
173 zl10353_single_write(fe, 0xE4, 0x00); 176 zl10353_single_write(fe, 0xE4, 0x00);
@@ -243,9 +246,12 @@ static int zl10353_init(struct dvb_frontend *fe)
243 246
244 if (debug_regs) 247 if (debug_regs)
245 zl10353_dump_regs(fe); 248 zl10353_dump_regs(fe);
249 if (state->config.parallel_ts)
250 zl10353_reset_attach[2] &= ~0x20;
246 251
247 /* Do a "hard" reset if not already done */ 252 /* Do a "hard" reset if not already done */
248 if (zl10353_read_register(state, 0x50) != 0x03) { 253 if (zl10353_read_register(state, 0x50) != zl10353_reset_attach[1] ||
254 zl10353_read_register(state, 0x51) != zl10353_reset_attach[2]) {
249 rc = zl10353_write(fe, zl10353_reset_attach, 255 rc = zl10353_write(fe, zl10353_reset_attach,
250 sizeof(zl10353_reset_attach)); 256 sizeof(zl10353_reset_attach));
251 if (debug_regs) 257 if (debug_regs)
@@ -258,7 +264,6 @@ static int zl10353_init(struct dvb_frontend *fe)
258static void zl10353_release(struct dvb_frontend *fe) 264static void zl10353_release(struct dvb_frontend *fe)
259{ 265{
260 struct zl10353_state *state = fe->demodulator_priv; 266 struct zl10353_state *state = fe->demodulator_priv;
261
262 kfree(state); 267 kfree(state);
263} 268}
264 269
@@ -314,6 +319,7 @@ static struct dvb_frontend_ops zl10353_ops = {
314 319
315 .init = zl10353_init, 320 .init = zl10353_init,
316 .sleep = zl10353_sleep, 321 .sleep = zl10353_sleep,
322 .write = zl10353_write,
317 323
318 .set_frontend = zl10353_set_parameters, 324 .set_frontend = zl10353_set_parameters,
319 .get_tune_settings = zl10353_get_tune_settings, 325 .get_tune_settings = zl10353_get_tune_settings,
@@ -330,4 +336,3 @@ MODULE_AUTHOR("Chris Pascoe");
330MODULE_LICENSE("GPL"); 336MODULE_LICENSE("GPL");
331 337
332EXPORT_SYMBOL(zl10353_attach); 338EXPORT_SYMBOL(zl10353_attach);
333EXPORT_SYMBOL(zl10353_write);
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
index 9770cb840cfc..79a947215c4d 100644
--- a/drivers/media/dvb/frontends/zl10353.h
+++ b/drivers/media/dvb/frontends/zl10353.h
@@ -31,11 +31,21 @@ struct zl10353_config
31 31
32 /* set if no pll is connected to the secondary i2c bus */ 32 /* set if no pll is connected to the secondary i2c bus */
33 int no_tuner; 33 int no_tuner;
34
35 /* set if parallel ts output is required */
36 int parallel_ts;
34}; 37};
35 38
39#if defined(CONFIG_DVB_ZL10353) || defined(CONFIG_DVB_ZL10353_MODULE)
36extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, 40extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
37 struct i2c_adapter *i2c); 41 struct i2c_adapter *i2c);
38 42#else
39extern int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen); 43static inline struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
44 struct i2c_adapter *i2c)
45{
46 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
47 return NULL;
48}
49#endif // CONFIG_DVB_ZL10353
40 50
41#endif /* ZL10353_H */ 51#endif /* ZL10353_H */
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index 5fb097595cfb..95531a624991 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -1,17 +1,17 @@
1config DVB_AV7110 1config DVB_AV7110
2 tristate "AV7110 cards" 2 tristate "AV7110 cards"
3 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 3 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
4 select FW_LOADER 4 select FW_LOADER if !DVB_AV7110_FIRMWARE
5 select VIDEO_SAA7146_VV 5 select VIDEO_SAA7146_VV
6 select DVB_PLL 6 select DVB_PLL
7 select DVB_VES1820 7 select DVB_VES1820 if !DVB_FE_CUSTOMISE
8 select DVB_VES1X93 8 select DVB_VES1X93 if !DVB_FE_CUSTOMISE
9 select DVB_STV0299 9 select DVB_STV0299 if !DVB_FE_CUSTOMISE
10 select DVB_TDA8083 10 select DVB_TDA8083 if !DVB_FE_CUSTOMISE
11 select DVB_SP8870 11 select DVB_SP8870 if !DVB_FE_CUSTOMISE
12 select DVB_STV0297 12 select DVB_STV0297 if !DVB_FE_CUSTOMISE
13 select DVB_L64781 13 select DVB_L64781 if !DVB_FE_CUSTOMISE
14 select DVB_LNBP21 14 select DVB_LNBP21 if !DVB_FE_CUSTOMISE
15 help 15 help
16 Support for SAA7146 and AV7110 based DVB cards as produced 16 Support for SAA7146 and AV7110 based DVB cards as produced
17 by Fujitsu-Siemens, Technotrend, Hauppauge and others. 17 by Fujitsu-Siemens, Technotrend, Hauppauge and others.
@@ -63,14 +63,16 @@ config DVB_BUDGET
63 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 63 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
64 select VIDEO_SAA7146 64 select VIDEO_SAA7146
65 select DVB_PLL 65 select DVB_PLL
66 select DVB_STV0299 66 select DVB_STV0299 if !DVB_FE_CUSTOMISE
67 select DVB_VES1X93 67 select DVB_VES1X93 if !DVB_FE_CUSTOMISE
68 select DVB_VES1820 68 select DVB_VES1820 if !DVB_FE_CUSTOMISE
69 select DVB_L64781 69 select DVB_L64781 if !DVB_FE_CUSTOMISE
70 select DVB_TDA8083 70 select DVB_TDA8083 if !DVB_FE_CUSTOMISE
71 select DVB_TDA10021 71 select DVB_TDA10021 if !DVB_FE_CUSTOMISE
72 select DVB_S5H1420 72 select DVB_S5H1420 if !DVB_FE_CUSTOMISE
73 select DVB_LNBP21 73 select DVB_TDA10086 if !DVB_FE_CUSTOMISE
74 select DVB_TDA826X if !DVB_FE_CUSTOMISE
75 select DVB_LNBP21 if !DVB_FE_CUSTOMISE
74 help 76 help
75 Support for simple SAA7146 based DVB cards 77 Support for simple SAA7146 based DVB cards
76 (so called Budget- or Nova-PCI cards) without onboard 78 (so called Budget- or Nova-PCI cards) without onboard
@@ -86,10 +88,10 @@ config DVB_BUDGET_CI
86 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 88 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
87 select VIDEO_SAA7146 89 select VIDEO_SAA7146
88 select DVB_PLL 90 select DVB_PLL
89 select DVB_STV0297 91 select DVB_STV0297 if !DVB_FE_CUSTOMISE
90 select DVB_STV0299 92 select DVB_STV0299 if !DVB_FE_CUSTOMISE
91 select DVB_TDA1004X 93 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
92 select DVB_LNBP21 94 select DVB_LNBP21 if !DVB_FE_CUSTOMISE
93 help 95 help
94 Support for simple SAA7146 based DVB cards 96 Support for simple SAA7146 based DVB cards
95 (so called Budget- or Nova-PCI cards) without onboard 97 (so called Budget- or Nova-PCI cards) without onboard
@@ -108,9 +110,10 @@ config DVB_BUDGET_AV
108 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1 110 depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
109 select VIDEO_SAA7146_VV 111 select VIDEO_SAA7146_VV
110 select DVB_PLL 112 select DVB_PLL
111 select DVB_STV0299 113 select DVB_STV0299 if !DVB_FE_CUSTOMISE
112 select DVB_TDA1004X 114 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
113 select DVB_TDA10021 115 select DVB_TDA10021 if !DVB_FE_CUSTOMISE
116 select DVB_TUA6100 if !DVB_FE_CUSTOMISE
114 select FW_LOADER 117 select FW_LOADER
115 help 118 help
116 Support for simple SAA7146 based DVB cards 119 Support for simple SAA7146 based DVB cards
@@ -127,9 +130,9 @@ config DVB_BUDGET_PATCH
127 depends on DVB_CORE && DVB_BUDGET && VIDEO_V4L1 130 depends on DVB_CORE && DVB_BUDGET && VIDEO_V4L1
128 select DVB_AV7110 131 select DVB_AV7110
129 select DVB_PLL 132 select DVB_PLL
130 select DVB_STV0299 133 select DVB_STV0299 if !DVB_FE_CUSTOMISE
131 select DVB_VES1X93 134 select DVB_VES1X93 if !DVB_FE_CUSTOMISE
132 select DVB_TDA8083 135 select DVB_TDA8083 if !DVB_FE_CUSTOMISE
133 help 136 help
134 Support for Budget Patch (full TS) modification on 137 Support for Budget Patch (full TS) modification on
135 SAA7146+AV7110 based cards (DVB-S cards). This 138 SAA7146+AV7110 based cards (DVB-S cards). This
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 4506165c5de2..bba23bcd1b11 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -1383,8 +1383,10 @@ static void dvb_unregister(struct av7110 *av7110)
1383 dvb_dmxdev_release(&av7110->dmxdev); 1383 dvb_dmxdev_release(&av7110->dmxdev);
1384 dvb_dmx_release(&av7110->demux); 1384 dvb_dmx_release(&av7110->demux);
1385 1385
1386 if (av7110->fe != NULL) 1386 if (av7110->fe != NULL) {
1387 dvb_unregister_frontend(av7110->fe); 1387 dvb_unregister_frontend(av7110->fe);
1388 dvb_frontend_detach(av7110->fe);
1389 }
1388 dvb_unregister_device(av7110->osd_dev); 1390 dvb_unregister_device(av7110->osd_dev);
1389 av7110_av_unregister(av7110); 1391 av7110_av_unregister(av7110);
1390 av7110_ca_unregister(av7110); 1392 av7110_ca_unregister(av7110);
@@ -1699,9 +1701,13 @@ static int alps_tdlb7_tuner_set_params(struct dvb_frontend* fe, struct dvb_front
1699 1701
1700static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) 1702static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
1701{ 1703{
1704#if defined(CONFIG_DVB_SP8870) || defined(CONFIG_DVB_SP8870_MODULE)
1702 struct av7110* av7110 = (struct av7110*) fe->dvb->priv; 1705 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1703 1706
1704 return request_firmware(fw, name, &av7110->dev->pci->dev); 1707 return request_firmware(fw, name, &av7110->dev->pci->dev);
1708#else
1709 return -EINVAL;
1710#endif
1705} 1711}
1706 1712
1707static struct sp8870_config alps_tdlb7_config = { 1713static struct sp8870_config alps_tdlb7_config = {
@@ -2077,7 +2083,7 @@ static int frontend_init(struct av7110 *av7110)
2077 if (av7110->dev->pci->subsystem_vendor == 0x110a) { 2083 if (av7110->dev->pci->subsystem_vendor == 0x110a) {
2078 switch(av7110->dev->pci->subsystem_device) { 2084 switch(av7110->dev->pci->subsystem_device) {
2079 case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??)) 2085 case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??))
2080 av7110->fe = ves1820_attach(&philips_cd1516_config, 2086 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config,
2081 &av7110->i2c_adap, read_pwm(av7110)); 2087 &av7110->i2c_adap, read_pwm(av7110));
2082 if (av7110->fe) { 2088 if (av7110->fe) {
2083 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params; 2089 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
@@ -2092,7 +2098,7 @@ static int frontend_init(struct av7110 *av7110)
2092 case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE 2098 case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE
2093 2099
2094 // try the ALPS BSRV2 first of all 2100 // try the ALPS BSRV2 first of all
2095 av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap); 2101 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2096 if (av7110->fe) { 2102 if (av7110->fe) {
2097 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 2103 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2098 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2104 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2103,7 +2109,7 @@ static int frontend_init(struct av7110 *av7110)
2103 } 2109 }
2104 2110
2105 // try the ALPS BSRU6 now 2111 // try the ALPS BSRU6 now
2106 av7110->fe = stv0299_attach(&alps_bsru6_config, &av7110->i2c_adap); 2112 av7110->fe = dvb_attach(stv0299_attach, &alps_bsru6_config, &av7110->i2c_adap);
2107 if (av7110->fe) { 2113 if (av7110->fe) {
2108 av7110->fe->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 2114 av7110->fe->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
2109 av7110->fe->tuner_priv = &av7110->i2c_adap; 2115 av7110->fe->tuner_priv = &av7110->i2c_adap;
@@ -2116,7 +2122,7 @@ static int frontend_init(struct av7110 *av7110)
2116 } 2122 }
2117 2123
2118 // Try the grundig 29504-451 2124 // Try the grundig 29504-451
2119 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2125 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2120 if (av7110->fe) { 2126 if (av7110->fe) {
2121 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 2127 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2122 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2128 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2130,7 +2136,7 @@ static int frontend_init(struct av7110 *av7110)
2130 switch(av7110->dev->pci->subsystem_device) { 2136 switch(av7110->dev->pci->subsystem_device) {
2131 case 0x0000: 2137 case 0x0000:
2132 /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */ 2138 /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */
2133 av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap, 2139 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config, &av7110->i2c_adap,
2134 read_pwm(av7110)); 2140 read_pwm(av7110));
2135 if (av7110->fe) { 2141 if (av7110->fe) {
2136 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params; 2142 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
@@ -2138,7 +2144,7 @@ static int frontend_init(struct av7110 *av7110)
2138 break; 2144 break;
2139 case 0x0003: 2145 case 0x0003:
2140 /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */ 2146 /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */
2141 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, 2147 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap,
2142 read_pwm(av7110)); 2148 read_pwm(av7110));
2143 if (av7110->fe) { 2149 if (av7110->fe) {
2144 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 2150 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
@@ -2148,17 +2154,24 @@ static int frontend_init(struct av7110 *av7110)
2148 break; 2154 break;
2149 2155
2150 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X 2156 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
2151 2157 // try ALPS TDLB7 first, then Grundig 29504-401
2152 // ALPS TDLB7 2158 av7110->fe = dvb_attach(sp8870_attach, &alps_tdlb7_config, &av7110->i2c_adap);
2153 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap);
2154 if (av7110->fe) { 2159 if (av7110->fe) {
2155 av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params; 2160 av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params;
2161 break;
2156 } 2162 }
2163 /* fall-thru */
2164
2165 case 0x0008: // Hauppauge/TT DVB-T
2166 // Grundig 29504-401
2167 av7110->fe = dvb_attach(l64781_attach, &grundig_29504_401_config, &av7110->i2c_adap);
2168 if (av7110->fe)
2169 av7110->fe->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
2157 break; 2170 break;
2158 2171
2159 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X 2172 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
2160 2173
2161 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); 2174 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2162 if (av7110->fe) { 2175 if (av7110->fe) {
2163 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 2176 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
2164 } 2177 }
@@ -2166,7 +2179,7 @@ static int frontend_init(struct av7110 *av7110)
2166 2179
2167 case 0x0004: // Galaxis DVB-S rev1.3 2180 case 0x0004: // Galaxis DVB-S rev1.3
2168 /* ALPS BSRV2 */ 2181 /* ALPS BSRV2 */
2169 av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap); 2182 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2170 if (av7110->fe) { 2183 if (av7110->fe) {
2171 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 2184 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2172 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2185 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2178,7 +2191,7 @@ static int frontend_init(struct av7110 *av7110)
2178 2191
2179 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */ 2192 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
2180 /* Grundig 29504-451 */ 2193 /* Grundig 29504-451 */
2181 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2194 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2182 if (av7110->fe) { 2195 if (av7110->fe) {
2183 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 2196 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2184 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2197 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2188,17 +2201,9 @@ static int frontend_init(struct av7110 *av7110)
2188 } 2201 }
2189 break; 2202 break;
2190 2203
2191 case 0x0008: // Hauppauge/TT DVB-T
2192
2193 av7110->fe = l64781_attach(&grundig_29504_401_config, &av7110->i2c_adap);
2194 if (av7110->fe) {
2195 av7110->fe->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
2196 }
2197 break;
2198
2199 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X 2204 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
2200 2205
2201 av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap); 2206 av7110->fe = dvb_attach(stv0297_attach, &nexusca_stv0297_config, &av7110->i2c_adap);
2202 if (av7110->fe) { 2207 if (av7110->fe) {
2203 av7110->fe->ops.tuner_ops.set_params = nexusca_stv0297_tuner_set_params; 2208 av7110->fe->ops.tuner_ops.set_params = nexusca_stv0297_tuner_set_params;
2204 2209
@@ -2214,12 +2219,12 @@ static int frontend_init(struct av7110 *av7110)
2214 2219
2215 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */ 2220 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
2216 /* ALPS BSBE1 */ 2221 /* ALPS BSBE1 */
2217 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap); 2222 av7110->fe = dvb_attach(stv0299_attach, &alps_bsbe1_config, &av7110->i2c_adap);
2218 if (av7110->fe) { 2223 if (av7110->fe) {
2219 av7110->fe->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params; 2224 av7110->fe->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
2220 av7110->fe->tuner_priv = &av7110->i2c_adap; 2225 av7110->fe->tuner_priv = &av7110->i2c_adap;
2221 2226
2222 if (lnbp21_attach(av7110->fe, &av7110->i2c_adap, 0, 0)) { 2227 if (dvb_attach(lnbp21_attach, av7110->fe, &av7110->i2c_adap, 0, 0) == NULL) {
2223 printk("dvb-ttpci: LNBP21 not found!\n"); 2228 printk("dvb-ttpci: LNBP21 not found!\n");
2224 if (av7110->fe->ops.release) 2229 if (av7110->fe->ops.release)
2225 av7110->fe->ops.release(av7110->fe); 2230 av7110->fe->ops.release(av7110->fe);
@@ -2255,8 +2260,7 @@ static int frontend_init(struct av7110 *av7110)
2255 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe); 2260 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
2256 if (ret < 0) { 2261 if (ret < 0) {
2257 printk("av7110: Frontend registration failed!\n"); 2262 printk("av7110: Frontend registration failed!\n");
2258 if (av7110->fe->ops.release) 2263 dvb_frontend_detach(av7110->fe);
2259 av7110->fe->ops.release(av7110->fe);
2260 av7110->fe = NULL; 2264 av7110->fe = NULL;
2261 } 2265 }
2262 } 2266 }
@@ -2823,7 +2827,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
2823 2827
2824 2828
2825static struct saa7146_extension av7110_extension = { 2829static struct saa7146_extension av7110_extension = {
2826 .name = "dvb\0", 2830 .name = "dvb",
2827 .flags = SAA7146_I2C_SHORT_DELAY, 2831 .flags = SAA7146_I2C_SHORT_DELAY,
2828 2832
2829 .module = THIS_MODULE, 2833 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 0f3a044aeb17..8c577cf30fb3 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -33,7 +33,6 @@
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/byteorder/swabb.h>
37#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
38#include <linux/fs.h> 37#include <linux/fs.h>
39 38
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index 6079e8865d5b..dd9aee314e0a 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -35,7 +35,6 @@
35#include <linux/fs.h> 35#include <linux/fs.h>
36#include <linux/timer.h> 36#include <linux/timer.h>
37#include <linux/poll.h> 37#include <linux/poll.h>
38#include <linux/byteorder/swabb.h>
39#include <linux/smp_lock.h> 38#include <linux/smp_lock.h>
40 39
41#include "av7110.h" 40#include "av7110.h"
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index 75736f2fe838..37de2e88a273 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -34,7 +34,6 @@
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/byteorder/swabb.h>
38#include <linux/smp_lock.h> 37#include <linux/smp_lock.h>
39#include <linux/fs.h> 38#include <linux/fs.h>
40 39
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index 6ffe53fdcf57..10cfe3131e72 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -32,7 +32,6 @@
32#include <linux/fs.h> 32#include <linux/fs.h>
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/poll.h> 34#include <linux/poll.h>
35#include <linux/byteorder/swabb.h>
36#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
37 36
38#include "av7110.h" 37#include "av7110.h"
@@ -922,7 +921,7 @@ static struct saa7146_ext_vv av7110_vv_data_st = {
922static struct saa7146_ext_vv av7110_vv_data_c = { 921static struct saa7146_ext_vv av7110_vv_data_c = {
923 .inputs = 1, 922 .inputs = 1,
924 .audios = 1, 923 .audios = 1,
925 .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT, 924 .capabilities = V4L2_CAP_TUNER | V4L2_CAP_SLICED_VBI_OUTPUT,
926 .flags = SAA7146_USE_PORT_B_FOR_VBI, 925 .flags = SAA7146_USE_PORT_B_FOR_VBI,
927 926
928 .stds = &standard[0], 927 .stds = &standard[0],
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 2d21fec23b4d..2235ff8b8a1d 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -37,6 +37,7 @@
37#include "stv0299.h" 37#include "stv0299.h"
38#include "tda10021.h" 38#include "tda10021.h"
39#include "tda1004x.h" 39#include "tda1004x.h"
40#include "tua6100.h"
40#include "dvb-pll.h" 41#include "dvb-pll.h"
41#include <media/saa7146_vv.h> 42#include <media/saa7146_vv.h>
42#include <linux/module.h> 43#include <linux/module.h>
@@ -235,7 +236,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
235 236
236 /* set tda10021 back to original clock configuration on reset */ 237 /* set tda10021 back to original clock configuration on reset */
237 if (budget_av->tda10021_poclkp) { 238 if (budget_av->tda10021_poclkp) {
238 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 239 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
239 budget_av->tda10021_ts_enabled = 0; 240 budget_av->tda10021_ts_enabled = 0;
240 } 241 }
241 242
@@ -257,7 +258,7 @@ static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
257 258
258 /* set tda10021 back to original clock configuration when cam removed */ 259 /* set tda10021 back to original clock configuration when cam removed */
259 if (budget_av->tda10021_poclkp) { 260 if (budget_av->tda10021_poclkp) {
260 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 261 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
261 budget_av->tda10021_ts_enabled = 0; 262 budget_av->tda10021_ts_enabled = 0;
262 } 263 }
263 return 0; 264 return 0;
@@ -277,7 +278,7 @@ static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
277 278
278 /* tda10021 seems to need a different TS clock config when data is routed to the CAM */ 279 /* tda10021 seems to need a different TS clock config when data is routed to the CAM */
279 if (budget_av->tda10021_poclkp) { 280 if (budget_av->tda10021_poclkp) {
280 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1); 281 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa1);
281 budget_av->tda10021_ts_enabled = 1; 282 budget_av->tda10021_ts_enabled = 1;
282 } 283 }
283 284
@@ -548,144 +549,6 @@ static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
548 return 0; 549 return 0;
549} 550}
550 551
551#define MIN2(a,b) ((a) < (b) ? (a) : (b))
552#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
553
554static int philips_su1278sh2_tua6100_tuner_set_params(struct dvb_frontend *fe,
555 struct dvb_frontend_parameters *params)
556{
557 u8 reg0 [2] = { 0x00, 0x00 };
558 u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 };
559 u8 reg2 [3] = { 0x02, 0x00, 0x00 };
560 int _fband;
561 int first_ZF;
562 int R, A, N, P, M;
563 struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 };
564 int freq = params->frequency;
565 struct budget *budget = (struct budget *) fe->dvb->priv;
566
567 first_ZF = (freq) / 1000;
568
569 if (abs(MIN2(abs(first_ZF-1190),abs(first_ZF-1790))) <
570 abs(MIN3(abs(first_ZF-1202),abs(first_ZF-1542),abs(first_ZF-1890))))
571 _fband = 2;
572 else
573 _fband = 3;
574
575 if (_fband == 2) {
576 if (((first_ZF >= 950) && (first_ZF < 1350)) ||
577 ((first_ZF >= 1430) && (first_ZF < 1950)))
578 reg0[1] = 0x07;
579 else if (((first_ZF >= 1350) && (first_ZF < 1430)) ||
580 ((first_ZF >= 1950) && (first_ZF < 2150)))
581 reg0[1] = 0x0B;
582 }
583
584 if(_fband == 3) {
585 if (((first_ZF >= 950) && (first_ZF < 1350)) ||
586 ((first_ZF >= 1455) && (first_ZF < 1950)))
587 reg0[1] = 0x07;
588 else if (((first_ZF >= 1350) && (first_ZF < 1420)) ||
589 ((first_ZF >= 1950) && (first_ZF < 2150)))
590 reg0[1] = 0x0B;
591 else if ((first_ZF >= 1420) && (first_ZF < 1455))
592 reg0[1] = 0x0F;
593 }
594
595 if (first_ZF > 1525)
596 reg1[1] |= 0x80;
597 else
598 reg1[1] &= 0x7F;
599
600 if (_fband == 2) {
601 if (first_ZF > 1430) { /* 1430MHZ */
602 reg1[1] &= 0xCF; /* N2 */
603 reg2[1] &= 0xCF; /* R2 */
604 reg2[1] |= 0x10;
605 } else {
606 reg1[1] &= 0xCF; /* N2 */
607 reg1[1] |= 0x20;
608 reg2[1] &= 0xCF; /* R2 */
609 reg2[1] |= 0x10;
610 }
611 }
612
613 if (_fband == 3) {
614 if ((first_ZF >= 1455) &&
615 (first_ZF < 1630)) {
616 reg1[1] &= 0xCF; /* N2 */
617 reg1[1] |= 0x20;
618 reg2[1] &= 0xCF; /* R2 */
619 } else {
620 if (first_ZF < 1455) {
621 reg1[1] &= 0xCF; /* N2 */
622 reg1[1] |= 0x20;
623 reg2[1] &= 0xCF; /* R2 */
624 reg2[1] |= 0x10;
625 } else {
626 if (first_ZF >= 1630) {
627 reg1[1] &= 0xCF; /* N2 */
628 reg2[1] &= 0xCF; /* R2 */
629 reg2[1] |= 0x10;
630 }
631 }
632 }
633 }
634
635 /* set ports, enable P0 for symbol rates > 4Ms/s */
636 if (params->u.qpsk.symbol_rate >= 4000000)
637 reg1[1] |= 0x0c;
638 else
639 reg1[1] |= 0x04;
640
641 reg2[1] |= 0x0c;
642
643 R = 64;
644 A = 64;
645 P = 64; //32
646
647 M = (freq * R) / 4; /* in Mhz */
648 N = (M - A * 1000) / (P * 1000);
649
650 reg1[1] |= (N >> 9) & 0x03;
651 reg1[2] = (N >> 1) & 0xff;
652 reg1[3] = (N << 7) & 0x80;
653
654 reg2[1] |= (R >> 8) & 0x03;
655 reg2[2] = R & 0xFF; /* R */
656
657 reg1[3] |= A & 0x7f; /* A */
658
659 if (P == 64)
660 reg1[1] |= 0x40; /* Prescaler 64/65 */
661
662 reg0[1] |= 0x03;
663
664 /* already enabled - do not reenable i2c repeater or TX fails */
665 if (fe->ops.i2c_gate_ctrl)
666 fe->ops.i2c_gate_ctrl(fe, 1);
667 msg.buf = reg0;
668 msg.len = sizeof(reg0);
669 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
670 return -EIO;
671
672 if (fe->ops.i2c_gate_ctrl)
673 fe->ops.i2c_gate_ctrl(fe, 1);
674 msg.buf = reg1;
675 msg.len = sizeof(reg1);
676 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
677 return -EIO;
678
679 if (fe->ops.i2c_gate_ctrl)
680 fe->ops.i2c_gate_ctrl(fe, 1);
681 msg.buf = reg2;
682 msg.len = sizeof(reg2);
683 if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
684 return -EIO;
685
686 return 0;
687}
688
689static u8 typhoon_cinergy1200s_inittab[] = { 552static u8 typhoon_cinergy1200s_inittab[] = {
690 0x01, 0x15, 553 0x01, 0x15,
691 0x02, 0x30, 554 0x02, 0x30,
@@ -1068,9 +931,9 @@ static int tda10021_set_frontend(struct dvb_frontend *fe,
1068 931
1069 result = budget_av->tda10021_set_frontend(fe, p); 932 result = budget_av->tda10021_set_frontend(fe, p);
1070 if (budget_av->tda10021_ts_enabled) { 933 if (budget_av->tda10021_ts_enabled) {
1071 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1); 934 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa1);
1072 } else { 935 } else {
1073 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 936 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
1074 } 937 }
1075 938
1076 return result; 939 return result;
@@ -1096,15 +959,16 @@ static void frontend_init(struct budget_av *budget_av)
1096 switch (saa->pci->subsystem_device) { 959 switch (saa->pci->subsystem_device) {
1097 960
1098 case SUBID_DVBS_KNC1: 961 case SUBID_DVBS_KNC1:
962 case SUBID_DVBS_KNC1_PLUS:
1099 case SUBID_DVBS_EASYWATCH_1: 963 case SUBID_DVBS_EASYWATCH_1:
1100 if (saa->pci->subsystem_vendor == 0x1894) { 964 if (saa->pci->subsystem_vendor == 0x1894) {
1101 fe = stv0299_attach(&cinergy_1200s_1894_0010_config, 965 fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config,
1102 &budget_av->budget.i2c_adap); 966 &budget_av->budget.i2c_adap);
1103 if (fe) { 967 if (fe) {
1104 fe->ops.tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params; 968 dvb_attach(tua6100_attach, fe, 0x60, &budget_av->budget.i2c_adap);
1105 } 969 }
1106 } else { 970 } else {
1107 fe = stv0299_attach(&typhoon_config, 971 fe = dvb_attach(stv0299_attach, &typhoon_config,
1108 &budget_av->budget.i2c_adap); 972 &budget_av->budget.i2c_adap);
1109 if (fe) { 973 if (fe) {
1110 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 974 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1116,16 +980,15 @@ static void frontend_init(struct budget_av *budget_av)
1116 case SUBID_DVBS_TV_STAR_CI: 980 case SUBID_DVBS_TV_STAR_CI:
1117 case SUBID_DVBS_CYNERGY1200N: 981 case SUBID_DVBS_CYNERGY1200N:
1118 case SUBID_DVBS_EASYWATCH: 982 case SUBID_DVBS_EASYWATCH:
1119 fe = stv0299_attach(&philips_sd1878_config, 983 fe = dvb_attach(stv0299_attach, &philips_sd1878_config,
1120 &budget_av->budget.i2c_adap); 984 &budget_av->budget.i2c_adap);
1121 if (fe) { 985 if (fe) {
1122 fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params; 986 fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params;
1123 } 987 }
1124 break; 988 break;
1125 989
1126 case SUBID_DVBS_KNC1_PLUS:
1127 case SUBID_DVBS_TYPHOON: 990 case SUBID_DVBS_TYPHOON:
1128 fe = stv0299_attach(&typhoon_config, 991 fe = dvb_attach(stv0299_attach, &typhoon_config,
1129 &budget_av->budget.i2c_adap); 992 &budget_av->budget.i2c_adap);
1130 if (fe) { 993 if (fe) {
1131 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 994 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1133,7 +996,7 @@ static void frontend_init(struct budget_av *budget_av)
1133 break; 996 break;
1134 997
1135 case SUBID_DVBS_CINERGY1200: 998 case SUBID_DVBS_CINERGY1200:
1136 fe = stv0299_attach(&cinergy_1200s_config, 999 fe = dvb_attach(stv0299_attach, &cinergy_1200s_config,
1137 &budget_av->budget.i2c_adap); 1000 &budget_av->budget.i2c_adap);
1138 if (fe) { 1001 if (fe) {
1139 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 1002 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1141,19 +1004,10 @@ static void frontend_init(struct budget_av *budget_av)
1141 break; 1004 break;
1142 1005
1143 case SUBID_DVBC_KNC1: 1006 case SUBID_DVBC_KNC1:
1144 budget_av->reinitialise_demod = 1;
1145 fe = tda10021_attach(&philips_cu1216_config,
1146 &budget_av->budget.i2c_adap,
1147 read_pwm(budget_av));
1148 if (fe) {
1149 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
1150 }
1151 break;
1152
1153 case SUBID_DVBC_KNC1_PLUS: 1007 case SUBID_DVBC_KNC1_PLUS:
1154 case SUBID_DVBC_CINERGY1200: 1008 case SUBID_DVBC_CINERGY1200:
1155 budget_av->reinitialise_demod = 1; 1009 budget_av->reinitialise_demod = 1;
1156 fe = tda10021_attach(&philips_cu1216_config, 1010 fe = dvb_attach(tda10021_attach, &philips_cu1216_config,
1157 &budget_av->budget.i2c_adap, 1011 &budget_av->budget.i2c_adap,
1158 read_pwm(budget_av)); 1012 read_pwm(budget_av));
1159 if (fe) { 1013 if (fe) {
@@ -1168,7 +1022,7 @@ static void frontend_init(struct budget_av *budget_av)
1168 case SUBID_DVBT_KNC1_PLUS: 1022 case SUBID_DVBT_KNC1_PLUS:
1169 case SUBID_DVBT_CINERGY1200: 1023 case SUBID_DVBT_CINERGY1200:
1170 budget_av->reinitialise_demod = 1; 1024 budget_av->reinitialise_demod = 1;
1171 fe = tda10046_attach(&philips_tu1216_config, 1025 fe = dvb_attach(tda10046_attach, &philips_tu1216_config,
1172 &budget_av->budget.i2c_adap); 1026 &budget_av->budget.i2c_adap);
1173 if (fe) { 1027 if (fe) {
1174 fe->ops.tuner_ops.init = philips_tu1216_tuner_init; 1028 fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
@@ -1192,8 +1046,7 @@ static void frontend_init(struct budget_av *budget_av)
1192 if (dvb_register_frontend(&budget_av->budget.dvb_adapter, 1046 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
1193 budget_av->budget.dvb_frontend)) { 1047 budget_av->budget.dvb_frontend)) {
1194 printk(KERN_ERR "budget-av: Frontend registration failed!\n"); 1048 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
1195 if (budget_av->budget.dvb_frontend->ops.release) 1049 dvb_frontend_detach(budget_av->budget.dvb_frontend);
1196 budget_av->budget.dvb_frontend->ops.release(budget_av->budget.dvb_frontend);
1197 budget_av->budget.dvb_frontend = NULL; 1050 budget_av->budget.dvb_frontend = NULL;
1198 } 1051 }
1199} 1052}
@@ -1227,8 +1080,10 @@ static int budget_av_detach(struct saa7146_dev *dev)
1227 if (budget_av->budget.ci_present) 1080 if (budget_av->budget.ci_present)
1228 ciintf_deinit(budget_av); 1081 ciintf_deinit(budget_av);
1229 1082
1230 if (budget_av->budget.dvb_frontend != NULL) 1083 if (budget_av->budget.dvb_frontend != NULL) {
1231 dvb_unregister_frontend(budget_av->budget.dvb_frontend); 1084 dvb_unregister_frontend(budget_av->budget.dvb_frontend);
1085 dvb_frontend_detach(budget_av->budget.dvb_frontend);
1086 }
1232 err = ttpci_budget_deinit(&budget_av->budget); 1087 err = ttpci_budget_deinit(&budget_av->budget);
1233 1088
1234 kfree(budget_av); 1089 kfree(budget_av);
@@ -1400,6 +1255,7 @@ static struct pci_device_id pci_tbl[] = {
1400 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010), 1255 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
1401 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010), 1256 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
1402 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011), 1257 MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
1258 MAKE_EXTENSION_PCI(knc1sp, 0x1894, 0x0011),
1403 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014), 1259 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
1404 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016), 1260 MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
1405 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e), 1261 MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index ffbbb3e34be4..2a2e9b400613 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -749,17 +749,17 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb
749 // setup PLL filter and TDA9889 749 // setup PLL filter and TDA9889
750 switch (params->u.ofdm.bandwidth) { 750 switch (params->u.ofdm.bandwidth) {
751 case BANDWIDTH_6_MHZ: 751 case BANDWIDTH_6_MHZ:
752 tda1004x_write_byte(fe, 0x0C, 0x14); 752 tda1004x_writereg(fe, 0x0C, 0x14);
753 filter = 0; 753 filter = 0;
754 break; 754 break;
755 755
756 case BANDWIDTH_7_MHZ: 756 case BANDWIDTH_7_MHZ:
757 tda1004x_write_byte(fe, 0x0C, 0x80); 757 tda1004x_writereg(fe, 0x0C, 0x80);
758 filter = 0; 758 filter = 0;
759 break; 759 break;
760 760
761 case BANDWIDTH_8_MHZ: 761 case BANDWIDTH_8_MHZ:
762 tda1004x_write_byte(fe, 0x0C, 0x14); 762 tda1004x_writereg(fe, 0x0C, 0x14);
763 filter = 1; 763 filter = 1;
764 break; 764 break;
765 765
@@ -988,7 +988,7 @@ static void frontend_init(struct budget_ci *budget_ci)
988 switch (budget_ci->budget.dev->pci->subsystem_device) { 988 switch (budget_ci->budget.dev->pci->subsystem_device) {
989 case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059)) 989 case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059))
990 budget_ci->budget.dvb_frontend = 990 budget_ci->budget.dvb_frontend =
991 stv0299_attach(&alps_bsru6_config, &budget_ci->budget.i2c_adap); 991 dvb_attach(stv0299_attach, &alps_bsru6_config, &budget_ci->budget.i2c_adap);
992 if (budget_ci->budget.dvb_frontend) { 992 if (budget_ci->budget.dvb_frontend) {
993 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 993 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
994 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap; 994 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
@@ -998,7 +998,7 @@ static void frontend_init(struct budget_ci *budget_ci)
998 998
999 case 0x100f: // Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059)) 999 case 0x100f: // Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059))
1000 budget_ci->budget.dvb_frontend = 1000 budget_ci->budget.dvb_frontend =
1001 stv0299_attach(&philips_su1278_tt_config, &budget_ci->budget.i2c_adap); 1001 dvb_attach(stv0299_attach, &philips_su1278_tt_config, &budget_ci->budget.i2c_adap);
1002 if (budget_ci->budget.dvb_frontend) { 1002 if (budget_ci->budget.dvb_frontend) {
1003 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_su1278_tt_tuner_set_params; 1003 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_su1278_tt_tuner_set_params;
1004 break; 1004 break;
@@ -1008,7 +1008,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1008 case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt)) 1008 case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt))
1009 budget_ci->tuner_pll_address = 0x61; 1009 budget_ci->tuner_pll_address = 0x61;
1010 budget_ci->budget.dvb_frontend = 1010 budget_ci->budget.dvb_frontend =
1011 stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1011 dvb_attach(stv0297_attach, &dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1012 if (budget_ci->budget.dvb_frontend) { 1012 if (budget_ci->budget.dvb_frontend) {
1013 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params; 1013 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
1014 break; 1014 break;
@@ -1018,7 +1018,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1018 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) 1018 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
1019 budget_ci->tuner_pll_address = 0x63; 1019 budget_ci->tuner_pll_address = 0x63;
1020 budget_ci->budget.dvb_frontend = 1020 budget_ci->budget.dvb_frontend =
1021 tda10045_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1021 dvb_attach(tda10045_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1022 if (budget_ci->budget.dvb_frontend) { 1022 if (budget_ci->budget.dvb_frontend) {
1023 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 1023 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
1024 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 1024 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
@@ -1029,7 +1029,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1029 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) 1029 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
1030 budget_ci->tuner_pll_address = 0x60; 1030 budget_ci->tuner_pll_address = 0x60;
1031 budget_ci->budget.dvb_frontend = 1031 budget_ci->budget.dvb_frontend =
1032 tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1032 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1033 if (budget_ci->budget.dvb_frontend) { 1033 if (budget_ci->budget.dvb_frontend) {
1034 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 1034 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
1035 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 1035 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
@@ -1038,16 +1038,15 @@ static void frontend_init(struct budget_ci *budget_ci)
1038 break; 1038 break;
1039 1039
1040 case 0x1017: // TT S-1500 PCI 1040 case 0x1017: // TT S-1500 PCI
1041 budget_ci->budget.dvb_frontend = stv0299_attach(&alps_bsbe1_config, &budget_ci->budget.i2c_adap); 1041 budget_ci->budget.dvb_frontend = dvb_attach(stv0299_attach, &alps_bsbe1_config, &budget_ci->budget.i2c_adap);
1042 if (budget_ci->budget.dvb_frontend) { 1042 if (budget_ci->budget.dvb_frontend) {
1043 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params; 1043 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
1044 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap; 1044 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
1045 1045
1046 budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; 1046 budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
1047 if (lnbp21_attach(budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0)) { 1047 if (dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0) == NULL) {
1048 printk("%s: No LNBP21 found!\n", __FUNCTION__); 1048 printk("%s: No LNBP21 found!\n", __FUNCTION__);
1049 if (budget_ci->budget.dvb_frontend->ops.release) 1049 dvb_frontend_detach(budget_ci->budget.dvb_frontend);
1050 budget_ci->budget.dvb_frontend->ops.release(budget_ci->budget.dvb_frontend);
1051 budget_ci->budget.dvb_frontend = NULL; 1050 budget_ci->budget.dvb_frontend = NULL;
1052 } 1051 }
1053 } 1052 }
@@ -1065,8 +1064,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1065 if (dvb_register_frontend 1064 if (dvb_register_frontend
1066 (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) { 1065 (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) {
1067 printk("budget-ci: Frontend registration failed!\n"); 1066 printk("budget-ci: Frontend registration failed!\n");
1068 if (budget_ci->budget.dvb_frontend->ops.release) 1067 dvb_frontend_detach(budget_ci->budget.dvb_frontend);
1069 budget_ci->budget.dvb_frontend->ops.release(budget_ci->budget.dvb_frontend);
1070 budget_ci->budget.dvb_frontend = NULL; 1068 budget_ci->budget.dvb_frontend = NULL;
1071 } 1069 }
1072 } 1070 }
@@ -1114,8 +1112,10 @@ static int budget_ci_detach(struct saa7146_dev *dev)
1114 1112
1115 if (budget_ci->budget.ci_present) 1113 if (budget_ci->budget.ci_present)
1116 ciintf_deinit(budget_ci); 1114 ciintf_deinit(budget_ci);
1117 if (budget_ci->budget.dvb_frontend) 1115 if (budget_ci->budget.dvb_frontend) {
1118 dvb_unregister_frontend(budget_ci->budget.dvb_frontend); 1116 dvb_unregister_frontend(budget_ci->budget.dvb_frontend);
1117 dvb_frontend_detach(budget_ci->budget.dvb_frontend);
1118 }
1119 err = ttpci_budget_deinit(&budget_ci->budget); 1119 err = ttpci_budget_deinit(&budget_ci->budget);
1120 1120
1121 tasklet_kill(&budget_ci->msp430_irq_tasklet); 1121 tasklet_kill(&budget_ci->msp430_irq_tasklet);
@@ -1153,7 +1153,7 @@ static struct pci_device_id pci_tbl[] = {
1153MODULE_DEVICE_TABLE(pci, pci_tbl); 1153MODULE_DEVICE_TABLE(pci, pci_tbl);
1154 1154
1155static struct saa7146_extension budget_extension = { 1155static struct saa7146_extension budget_extension = {
1156 .name = "budget_ci dvb\0", 1156 .name = "budget_ci dvb",
1157 .flags = SAA7146_I2C_SHORT_DELAY, 1157 .flags = SAA7146_I2C_SHORT_DELAY,
1158 1158
1159 .module = THIS_MODULE, 1159 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index 57227441891e..fc1267b8c892 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -325,7 +325,7 @@ static void frontend_init(struct budget_patch* budget)
325 case 0x1013: // SATELCO Multimedia PCI 325 case 0x1013: // SATELCO Multimedia PCI
326 326
327 // try the ALPS BSRV2 first of all 327 // try the ALPS BSRV2 first of all
328 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); 328 budget->dvb_frontend = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &budget->i2c_adap);
329 if (budget->dvb_frontend) { 329 if (budget->dvb_frontend) {
330 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 330 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
331 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd; 331 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
@@ -335,7 +335,7 @@ static void frontend_init(struct budget_patch* budget)
335 } 335 }
336 336
337 // try the ALPS BSRU6 now 337 // try the ALPS BSRU6 now
338 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); 338 budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
339 if (budget->dvb_frontend) { 339 if (budget->dvb_frontend) {
340 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 340 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
341 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 341 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
@@ -347,7 +347,7 @@ static void frontend_init(struct budget_patch* budget)
347 } 347 }
348 348
349 // Try the grundig 29504-451 349 // Try the grundig 29504-451
350 budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); 350 budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap);
351 if (budget->dvb_frontend) { 351 if (budget->dvb_frontend) {
352 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 352 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
353 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd; 353 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
@@ -367,8 +367,7 @@ static void frontend_init(struct budget_patch* budget)
367 } else { 367 } else {
368 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) { 368 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
369 printk("budget-av: Frontend registration failed!\n"); 369 printk("budget-av: Frontend registration failed!\n");
370 if (budget->dvb_frontend->ops.release) 370 dvb_frontend_detach(budget->dvb_frontend);
371 budget->dvb_frontend->ops.release(budget->dvb_frontend);
372 budget->dvb_frontend = NULL; 371 budget->dvb_frontend = NULL;
373 } 372 }
374 } 373 }
@@ -627,8 +626,10 @@ static int budget_patch_detach (struct saa7146_dev* dev)
627 struct budget_patch *budget = (struct budget_patch*) dev->ext_priv; 626 struct budget_patch *budget = (struct budget_patch*) dev->ext_priv;
628 int err; 627 int err;
629 628
630 if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend); 629 if (budget->dvb_frontend) {
631 630 dvb_unregister_frontend(budget->dvb_frontend);
631 dvb_frontend_detach(budget->dvb_frontend);
632 }
632 err = ttpci_budget_deinit (budget); 633 err = ttpci_budget_deinit (budget);
633 634
634 kfree (budget); 635 kfree (budget);
@@ -647,7 +648,7 @@ static void __exit budget_patch_exit(void)
647} 648}
648 649
649static struct saa7146_extension budget_extension = { 650static struct saa7146_extension budget_extension = {
650 .name = "budget_patch dvb\0", 651 .name = "budget_patch dvb",
651 .flags = 0, 652 .flags = 0,
652 653
653 .module = THIS_MODULE, 654 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 863dffb4ed8e..e58f0391e9d1 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -41,6 +41,8 @@
41#include "l64781.h" 41#include "l64781.h"
42#include "tda8083.h" 42#include "tda8083.h"
43#include "s5h1420.h" 43#include "s5h1420.h"
44#include "tda10086.h"
45#include "tda826x.h"
44#include "lnbp21.h" 46#include "lnbp21.h"
45#include "bsru6.h" 47#include "bsru6.h"
46 48
@@ -342,6 +344,11 @@ static struct s5h1420_config s5h1420_config = {
342 .invert = 1, 344 .invert = 1,
343}; 345};
344 346
347static struct tda10086_config tda10086_config = {
348 .demod_address = 0x0e,
349 .invert = 0,
350};
351
345static u8 read_pwm(struct budget* budget) 352static u8 read_pwm(struct budget* budget)
346{ 353{
347 u8 b = 0xff; 354 u8 b = 0xff;
@@ -361,7 +368,7 @@ static void frontend_init(struct budget *budget)
361 case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659)) 368 case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659))
362 case 0x1013: 369 case 0x1013:
363 // try the ALPS BSRV2 first of all 370 // try the ALPS BSRV2 first of all
364 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); 371 budget->dvb_frontend = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &budget->i2c_adap);
365 if (budget->dvb_frontend) { 372 if (budget->dvb_frontend) {
366 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 373 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
367 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd; 374 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
@@ -371,7 +378,7 @@ static void frontend_init(struct budget *budget)
371 } 378 }
372 379
373 // try the ALPS BSRU6 now 380 // try the ALPS BSRU6 now
374 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); 381 budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
375 if (budget->dvb_frontend) { 382 if (budget->dvb_frontend) {
376 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 383 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
377 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 384 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
@@ -381,7 +388,7 @@ static void frontend_init(struct budget *budget)
381 388
382 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) 389 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
383 390
384 budget->dvb_frontend = ves1820_attach(&alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget)); 391 budget->dvb_frontend = dvb_attach(ves1820_attach, &alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget));
385 if (budget->dvb_frontend) { 392 if (budget->dvb_frontend) {
386 budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 393 budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
387 break; 394 break;
@@ -390,7 +397,7 @@ static void frontend_init(struct budget *budget)
390 397
391 case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060)) 398 case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060))
392 399
393 budget->dvb_frontend = l64781_attach(&grundig_29504_401_config, &budget->i2c_adap); 400 budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config, &budget->i2c_adap);
394 if (budget->dvb_frontend) { 401 if (budget->dvb_frontend) {
395 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; 402 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
396 break; 403 break;
@@ -398,7 +405,7 @@ static void frontend_init(struct budget *budget)
398 break; 405 break;
399 406
400 case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059)) 407 case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059))
401 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); 408 budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
402 if (budget->dvb_frontend) { 409 if (budget->dvb_frontend) {
403 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 410 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
404 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 411 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
@@ -408,7 +415,7 @@ static void frontend_init(struct budget *budget)
408 break; 415 break;
409 416
410 case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522)) 417 case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522))
411 budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); 418 budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap);
412 if (budget->dvb_frontend) { 419 if (budget->dvb_frontend) {
413 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 420 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
414 budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage; 421 budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage;
@@ -417,10 +424,28 @@ static void frontend_init(struct budget *budget)
417 break; 424 break;
418 425
419 case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260)) 426 case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
420 budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap); 427 budget->dvb_frontend = dvb_attach(s5h1420_attach, &s5h1420_config, &budget->i2c_adap);
421 if (budget->dvb_frontend) { 428 if (budget->dvb_frontend) {
422 budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params; 429 budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params;
423 if (lnbp21_attach(budget->dvb_frontend, &budget->i2c_adap, 0, 0)) { 430 if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) {
431 printk("%s: No LNBP21 found!\n", __FUNCTION__);
432 goto error_out;
433 }
434 break;
435 }
436
437 case 0x1018: // TT Budget-S-1401 (philips tda10086/philips tda8262)
438 // gpio2 is connected to CLB - reset it + leave it high
439 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
440 msleep(1);
441 saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
442 msleep(1);
443
444 budget->dvb_frontend = dvb_attach(tda10086_attach, &tda10086_config, &budget->i2c_adap);
445 if (budget->dvb_frontend) {
446 if (dvb_attach(tda826x_attach, budget->dvb_frontend, 0x60, &budget->i2c_adap, 0) == NULL)
447 printk("%s: No tda826x found!\n", __FUNCTION__);
448 if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) {
424 printk("%s: No LNBP21 found!\n", __FUNCTION__); 449 printk("%s: No LNBP21 found!\n", __FUNCTION__);
425 goto error_out; 450 goto error_out;
426 } 451 }
@@ -442,8 +467,7 @@ static void frontend_init(struct budget *budget)
442 467
443error_out: 468error_out:
444 printk("budget: Frontend registration failed!\n"); 469 printk("budget: Frontend registration failed!\n");
445 if (budget->dvb_frontend->ops.release) 470 dvb_frontend_detach(budget->dvb_frontend);
446 budget->dvb_frontend->ops.release(budget->dvb_frontend);
447 budget->dvb_frontend = NULL; 471 budget->dvb_frontend = NULL;
448 return; 472 return;
449} 473}
@@ -481,7 +505,10 @@ static int budget_detach (struct saa7146_dev* dev)
481 struct budget *budget = (struct budget*) dev->ext_priv; 505 struct budget *budget = (struct budget*) dev->ext_priv;
482 int err; 506 int err;
483 507
484 if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend); 508 if (budget->dvb_frontend) {
509 dvb_unregister_frontend(budget->dvb_frontend);
510 dvb_frontend_detach(budget->dvb_frontend);
511 }
485 512
486 err = ttpci_budget_deinit (budget); 513 err = ttpci_budget_deinit (budget);
487 514
@@ -497,6 +524,7 @@ MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT);
497MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT); 524MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT);
498MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); 525MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
499MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC); 526MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC);
527MAKE_BUDGET_INFO(ttbs1401, "TT-Budget-S-1401 PCI", BUDGET_TT);
500MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY); 528MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY);
501MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY); 529MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY);
502 530
@@ -506,6 +534,7 @@ static struct pci_device_id pci_tbl[] = {
506 MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005), 534 MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
507 MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), 535 MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
508 MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016), 536 MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016),
537 MAKE_EXTENSION_PCI(ttbs1401, 0x13c2, 0x1018),
509 MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60), 538 MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60),
510 MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61), 539 MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61),
511 { 540 {
@@ -516,7 +545,7 @@ static struct pci_device_id pci_tbl[] = {
516MODULE_DEVICE_TABLE(pci, pci_tbl); 545MODULE_DEVICE_TABLE(pci, pci_tbl);
517 546
518static struct saa7146_extension budget_extension = { 547static struct saa7146_extension budget_extension = {
519 .name = "budget dvb\0", 548 .name = "budget dvb",
520 .flags = SAA7146_I2C_SHORT_DELAY, 549 .flags = SAA7146_I2C_SHORT_DELAY,
521 550
522 .module = THIS_MODULE, 551 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttusb-budget/Kconfig b/drivers/media/dvb/ttusb-budget/Kconfig
index 46a6a60d2ab9..e78ea9227b0e 100644
--- a/drivers/media/dvb/ttusb-budget/Kconfig
+++ b/drivers/media/dvb/ttusb-budget/Kconfig
@@ -2,13 +2,13 @@ config DVB_TTUSB_BUDGET
2 tristate "Technotrend/Hauppauge Nova-USB devices" 2 tristate "Technotrend/Hauppauge Nova-USB devices"
3 depends on DVB_CORE && USB && I2C 3 depends on DVB_CORE && USB && I2C
4 select DVB_PLL 4 select DVB_PLL
5 select DVB_CX22700 5 select DVB_CX22700 if !DVB_FE_CUSTOMISE
6 select DVB_TDA1004X 6 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
7 select DVB_VES1820 7 select DVB_VES1820 if !DVB_FE_CUSTOMISE
8 select DVB_TDA8083 8 select DVB_TDA8083 if !DVB_FE_CUSTOMISE
9 select DVB_STV0299 9 select DVB_STV0299 if !DVB_FE_CUSTOMISE
10 select DVB_STV0297 10 select DVB_STV0297 if !DVB_FE_CUSTOMISE
11 select DVB_LNBP21 11 select DVB_LNBP21 if !DVB_FE_CUSTOMISE
12 help 12 help
13 Support for external USB adapters designed by Technotrend and 13 Support for external USB adapters designed by Technotrend and
14 produced by Hauppauge, shipped under the brand name 'Nova-USB'. 14 produced by Hauppauge, shipped under the brand name 'Nova-USB'.
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 04cef3023457..234199875f53 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1107,17 +1107,17 @@ static int philips_tdm1316l_tuner_set_params(struct dvb_frontend* fe, struct dvb
1107 // setup PLL filter 1107 // setup PLL filter
1108 switch (params->u.ofdm.bandwidth) { 1108 switch (params->u.ofdm.bandwidth) {
1109 case BANDWIDTH_6_MHZ: 1109 case BANDWIDTH_6_MHZ:
1110 tda1004x_write_byte(fe, 0x0C, 0); 1110 tda1004x_writereg(fe, 0x0C, 0);
1111 filter = 0; 1111 filter = 0;
1112 break; 1112 break;
1113 1113
1114 case BANDWIDTH_7_MHZ: 1114 case BANDWIDTH_7_MHZ:
1115 tda1004x_write_byte(fe, 0x0C, 0); 1115 tda1004x_writereg(fe, 0x0C, 0);
1116 filter = 0; 1116 filter = 0;
1117 break; 1117 break;
1118 1118
1119 case BANDWIDTH_8_MHZ: 1119 case BANDWIDTH_8_MHZ:
1120 tda1004x_write_byte(fe, 0x0C, 0xFF); 1120 tda1004x_writereg(fe, 0x0C, 0xFF);
1121 filter = 1; 1121 filter = 1;
1122 break; 1122 break;
1123 1123
@@ -1564,13 +1564,13 @@ static void frontend_init(struct ttusb* ttusb)
1564 switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) { 1564 switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) {
1565 case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6|BSBE1(tsa5059)) 1565 case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6|BSBE1(tsa5059))
1566 // try the stv0299 based first 1566 // try the stv0299 based first
1567 ttusb->fe = stv0299_attach(&alps_stv0299_config, &ttusb->i2c_adap); 1567 ttusb->fe = dvb_attach(stv0299_attach, &alps_stv0299_config, &ttusb->i2c_adap);
1568 if (ttusb->fe != NULL) { 1568 if (ttusb->fe != NULL) {
1569 ttusb->fe->ops.tuner_ops.set_params = philips_tsa5059_tuner_set_params; 1569 ttusb->fe->ops.tuner_ops.set_params = philips_tsa5059_tuner_set_params;
1570 1570
1571 if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1 1571 if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1
1572 alps_stv0299_config.inittab = alps_bsbe1_inittab; 1572 alps_stv0299_config.inittab = alps_bsbe1_inittab;
1573 lnbp21_attach(ttusb->fe, &ttusb->i2c_adap, 0, 0); 1573 dvb_attach(lnbp21_attach, ttusb->fe, &ttusb->i2c_adap, 0, 0);
1574 } else { // ALPS BSRU6 1574 } else { // ALPS BSRU6
1575 ttusb->fe->ops.set_voltage = ttusb_set_voltage; 1575 ttusb->fe->ops.set_voltage = ttusb_set_voltage;
1576 } 1576 }
@@ -1578,7 +1578,7 @@ static void frontend_init(struct ttusb* ttusb)
1578 } 1578 }
1579 1579
1580 // Grundig 29504-491 1580 // Grundig 29504-491
1581 ttusb->fe = tda8083_attach(&ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap); 1581 ttusb->fe = dvb_attach(tda8083_attach, &ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap);
1582 if (ttusb->fe != NULL) { 1582 if (ttusb->fe != NULL) {
1583 ttusb->fe->ops.tuner_ops.set_params = ttusb_novas_grundig_29504_491_tuner_set_params; 1583 ttusb->fe->ops.tuner_ops.set_params = ttusb_novas_grundig_29504_491_tuner_set_params;
1584 ttusb->fe->ops.set_voltage = ttusb_set_voltage; 1584 ttusb->fe->ops.set_voltage = ttusb_set_voltage;
@@ -1587,13 +1587,13 @@ static void frontend_init(struct ttusb* ttusb)
1587 break; 1587 break;
1588 1588
1589 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) 1589 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
1590 ttusb->fe = ves1820_attach(&alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb)); 1590 ttusb->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb));
1591 if (ttusb->fe != NULL) { 1591 if (ttusb->fe != NULL) {
1592 ttusb->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 1592 ttusb->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
1593 break; 1593 break;
1594 } 1594 }
1595 1595
1596 ttusb->fe = stv0297_attach(&dvbc_philips_tdm1316l_config, &ttusb->i2c_adap); 1596 ttusb->fe = dvb_attach(stv0297_attach, &dvbc_philips_tdm1316l_config, &ttusb->i2c_adap);
1597 if (ttusb->fe != NULL) { 1597 if (ttusb->fe != NULL) {
1598 ttusb->fe->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params; 1598 ttusb->fe->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
1599 break; 1599 break;
@@ -1602,14 +1602,14 @@ static void frontend_init(struct ttusb* ttusb)
1602 1602
1603 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??)) 1603 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??))
1604 // try the ALPS TDMB7 first 1604 // try the ALPS TDMB7 first
1605 ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap); 1605 ttusb->fe = dvb_attach(cx22700_attach, &alps_tdmb7_config, &ttusb->i2c_adap);
1606 if (ttusb->fe != NULL) { 1606 if (ttusb->fe != NULL) {
1607 ttusb->fe->ops.tuner_ops.set_params = alps_tdmb7_tuner_set_params; 1607 ttusb->fe->ops.tuner_ops.set_params = alps_tdmb7_tuner_set_params;
1608 break; 1608 break;
1609 } 1609 }
1610 1610
1611 // Philips td1316 1611 // Philips td1316
1612 ttusb->fe = tda10046_attach(&philips_tdm1316l_config, &ttusb->i2c_adap); 1612 ttusb->fe = dvb_attach(tda10046_attach, &philips_tdm1316l_config, &ttusb->i2c_adap);
1613 if (ttusb->fe != NULL) { 1613 if (ttusb->fe != NULL) {
1614 ttusb->fe->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 1614 ttusb->fe->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
1615 ttusb->fe->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 1615 ttusb->fe->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
@@ -1625,8 +1625,7 @@ static void frontend_init(struct ttusb* ttusb)
1625 } else { 1625 } else {
1626 if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) { 1626 if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) {
1627 printk("dvb-ttusb-budget: Frontend registration failed!\n"); 1627 printk("dvb-ttusb-budget: Frontend registration failed!\n");
1628 if (ttusb->fe->ops.release) 1628 dvb_frontend_detach(ttusb->fe);
1629 ttusb->fe->ops.release(ttusb->fe);
1630 ttusb->fe = NULL; 1629 ttusb->fe = NULL;
1631 } 1630 }
1632 } 1631 }
@@ -1763,7 +1762,10 @@ static void ttusb_disconnect(struct usb_interface *intf)
1763 dvb_net_release(&ttusb->dvbnet); 1762 dvb_net_release(&ttusb->dvbnet);
1764 dvb_dmxdev_release(&ttusb->dmxdev); 1763 dvb_dmxdev_release(&ttusb->dmxdev);
1765 dvb_dmx_release(&ttusb->dvb_demux); 1764 dvb_dmx_release(&ttusb->dvb_demux);
1766 if (ttusb->fe != NULL) dvb_unregister_frontend(ttusb->fe); 1765 if (ttusb->fe != NULL) {
1766 dvb_unregister_frontend(ttusb->fe);
1767 dvb_frontend_detach(ttusb->fe);
1768 }
1767 i2c_del_adapter(&ttusb->i2c_adap); 1769 i2c_del_adapter(&ttusb->i2c_adap);
1768 dvb_unregister_adapter(&ttusb->adapter); 1770 dvb_unregister_adapter(&ttusb->adapter);
1769 1771
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index c9d663549dff..de077a757192 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1512,7 +1512,11 @@ static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)
1512 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); 1512 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend);
1513 dvb_dmxdev_release(&dec->dmxdev); 1513 dvb_dmxdev_release(&dec->dmxdev);
1514 dvb_dmx_release(&dec->demux); 1514 dvb_dmx_release(&dec->demux);
1515 if (dec->fe) dvb_unregister_frontend(dec->fe); 1515 if (dec->fe) {
1516 dvb_unregister_frontend(dec->fe);
1517 if (dec->fe->ops.release)
1518 dec->fe->ops.release(dec->fe);
1519 }
1516 dvb_unregister_adapter(&dec->adapter); 1520 dvb_unregister_adapter(&dec->adapter);
1517} 1521}
1518 1522
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 220076b1b956..7015517e2c1b 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -7,7 +7,7 @@ menu "Radio Adapters"
7 7
8config RADIO_CADET 8config RADIO_CADET
9 tristate "ADS Cadet AM/FM Tuner" 9 tristate "ADS Cadet AM/FM Tuner"
10 depends on ISA && VIDEO_V4L1 10 depends on ISA && VIDEO_V4L2
11 ---help--- 11 ---help---
12 Choose Y here if you have one of these AM/FM radio cards, and then 12 Choose Y here if you have one of these AM/FM radio cards, and then
13 fill in the port address below. 13 fill in the port address below.
@@ -25,7 +25,7 @@ config RADIO_CADET
25 25
26config RADIO_RTRACK 26config RADIO_RTRACK
27 tristate "AIMSlab RadioTrack (aka RadioReveal) support" 27 tristate "AIMSlab RadioTrack (aka RadioReveal) support"
28 depends on ISA && VIDEO_V4L1 28 depends on ISA && VIDEO_V4L2
29 ---help--- 29 ---help---
30 Choose Y here if you have one of these FM radio cards, and then fill 30 Choose Y here if you have one of these FM radio cards, and then fill
31 in the port address below. 31 in the port address below.
@@ -59,7 +59,7 @@ config RADIO_RTRACK_PORT
59 59
60config RADIO_RTRACK2 60config RADIO_RTRACK2
61 tristate "AIMSlab RadioTrack II support" 61 tristate "AIMSlab RadioTrack II support"
62 depends on ISA && VIDEO_V4L1 62 depends on ISA && VIDEO_V4L2
63 ---help--- 63 ---help---
64 Choose Y here if you have this FM radio card, and then fill in the 64 Choose Y here if you have this FM radio card, and then fill in the
65 port address below. 65 port address below.
@@ -82,7 +82,7 @@ config RADIO_RTRACK2_PORT
82 82
83config RADIO_AZTECH 83config RADIO_AZTECH
84 tristate "Aztech/Packard Bell Radio" 84 tristate "Aztech/Packard Bell Radio"
85 depends on ISA && VIDEO_V4L1 85 depends on ISA && VIDEO_V4L2
86 ---help--- 86 ---help---
87 Choose Y here if you have one of these FM radio cards, and then fill 87 Choose Y here if you have one of these FM radio cards, and then fill
88 in the port address below. 88 in the port address below.
@@ -106,7 +106,7 @@ config RADIO_AZTECH_PORT
106 106
107config RADIO_GEMTEK 107config RADIO_GEMTEK
108 tristate "GemTek Radio Card support" 108 tristate "GemTek Radio Card support"
109 depends on ISA && VIDEO_V4L1 109 depends on ISA && VIDEO_V4L2
110 ---help--- 110 ---help---
111 Choose Y here if you have this FM radio card, and then fill in the 111 Choose Y here if you have this FM radio card, and then fill in the
112 port address below. 112 port address below.
@@ -131,7 +131,7 @@ config RADIO_GEMTEK_PORT
131 131
132config RADIO_GEMTEK_PCI 132config RADIO_GEMTEK_PCI
133 tristate "GemTek PCI Radio Card support" 133 tristate "GemTek PCI Radio Card support"
134 depends on VIDEO_V4L1 && PCI 134 depends on VIDEO_V4L2 && PCI
135 ---help--- 135 ---help---
136 Choose Y here if you have this PCI FM radio card. 136 Choose Y here if you have this PCI FM radio card.
137 137
@@ -145,7 +145,7 @@ config RADIO_GEMTEK_PCI
145 145
146config RADIO_MAXIRADIO 146config RADIO_MAXIRADIO
147 tristate "Guillemot MAXI Radio FM 2000 radio" 147 tristate "Guillemot MAXI Radio FM 2000 radio"
148 depends on VIDEO_V4L1 && PCI 148 depends on VIDEO_V4L2 && PCI
149 ---help--- 149 ---help---
150 Choose Y here if you have this radio card. This card may also be 150 Choose Y here if you have this radio card. This card may also be
151 found as Gemtek PCI FM. 151 found as Gemtek PCI FM.
@@ -160,7 +160,7 @@ config RADIO_MAXIRADIO
160 160
161config RADIO_MAESTRO 161config RADIO_MAESTRO
162 tristate "Maestro on board radio" 162 tristate "Maestro on board radio"
163 depends on VIDEO_V4L1 163 depends on VIDEO_V4L2 && PCI
164 ---help--- 164 ---help---
165 Say Y here to directly support the on-board radio tuner on the 165 Say Y here to directly support the on-board radio tuner on the
166 Maestro 2 or 2E sound card. 166 Maestro 2 or 2E sound card.
@@ -208,7 +208,7 @@ config RADIO_MIROPCM20_RDS
208 208
209config RADIO_SF16FMI 209config RADIO_SF16FMI
210 tristate "SF16FMI Radio" 210 tristate "SF16FMI Radio"
211 depends on ISA && VIDEO_V4L1 211 depends on ISA && VIDEO_V4L2
212 ---help--- 212 ---help---
213 Choose Y here if you have one of these FM radio cards. If you 213 Choose Y here if you have one of these FM radio cards. If you
214 compile the driver into the kernel and your card is not PnP one, you 214 compile the driver into the kernel and your card is not PnP one, you
@@ -225,7 +225,7 @@ config RADIO_SF16FMI
225 225
226config RADIO_SF16FMR2 226config RADIO_SF16FMR2
227 tristate "SF16FMR2 Radio" 227 tristate "SF16FMR2 Radio"
228 depends on ISA && VIDEO_V4L1 228 depends on ISA && VIDEO_V4L2
229 ---help--- 229 ---help---
230 Choose Y here if you have one of these FM radio cards. 230 Choose Y here if you have one of these FM radio cards.
231 231
@@ -239,7 +239,7 @@ config RADIO_SF16FMR2
239 239
240config RADIO_TERRATEC 240config RADIO_TERRATEC
241 tristate "TerraTec ActiveRadio ISA Standalone" 241 tristate "TerraTec ActiveRadio ISA Standalone"
242 depends on ISA && VIDEO_V4L1 242 depends on ISA && VIDEO_V4L2
243 ---help--- 243 ---help---
244 Choose Y here if you have this FM radio card, and then fill in the 244 Choose Y here if you have this FM radio card, and then fill in the
245 port address below. (TODO) 245 port address below. (TODO)
@@ -268,7 +268,7 @@ config RADIO_TERRATEC_PORT
268 268
269config RADIO_TRUST 269config RADIO_TRUST
270 tristate "Trust FM radio card" 270 tristate "Trust FM radio card"
271 depends on ISA && VIDEO_V4L1 271 depends on ISA && VIDEO_V4L2
272 help 272 help
273 This is a driver for the Trust FM radio cards. Say Y if you have 273 This is a driver for the Trust FM radio cards. Say Y if you have
274 such a card and want to use it under Linux. 274 such a card and want to use it under Linux.
@@ -286,7 +286,7 @@ config RADIO_TRUST_PORT
286 286
287config RADIO_TYPHOON 287config RADIO_TYPHOON
288 tristate "Typhoon Radio (a.k.a. EcoRadio)" 288 tristate "Typhoon Radio (a.k.a. EcoRadio)"
289 depends on ISA && VIDEO_V4L1 289 depends on ISA && VIDEO_V4L2
290 ---help--- 290 ---help---
291 Choose Y here if you have one of these FM radio cards, and then fill 291 Choose Y here if you have one of these FM radio cards, and then fill
292 in the port address and the frequency used for muting below. 292 in the port address and the frequency used for muting below.
@@ -330,7 +330,7 @@ config RADIO_TYPHOON_MUTEFREQ
330 330
331config RADIO_ZOLTRIX 331config RADIO_ZOLTRIX
332 tristate "Zoltrix Radio" 332 tristate "Zoltrix Radio"
333 depends on ISA && VIDEO_V4L1 333 depends on ISA && VIDEO_V4L2
334 ---help--- 334 ---help---
335 Choose Y here if you have one of these FM radio cards, and then fill 335 Choose Y here if you have one of these FM radio cards, and then fill
336 in the port address below. 336 in the port address below.
@@ -352,7 +352,7 @@ config RADIO_ZOLTRIX_PORT
352 352
353config USB_DSBR 353config USB_DSBR
354 tristate "D-Link USB FM radio support (EXPERIMENTAL)" 354 tristate "D-Link USB FM radio support (EXPERIMENTAL)"
355 depends on USB && VIDEO_V4L1 && EXPERIMENTAL 355 depends on USB && VIDEO_V4L2 && EXPERIMENTAL
356 ---help--- 356 ---help---
357 Say Y here if you want to connect this type of radio to your 357 Say Y here if you want to connect this type of radio to your
358 computer's USB port. Note that the audio is not digital, and 358 computer's USB port. Note that the audio is not digital, and
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index f7e33f9ee8e9..db865a0667e5 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -33,8 +33,14 @@
33 33
34 History: 34 History:
35 35
36 Version 0.41-ac1:
37 Alan Cox: Some cleanups and fixes
38
39 Version 0.41:
40 Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
41
36 Version 0.40: 42 Version 0.40:
37 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing 43 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing
38 44
39 Version 0.30: 45 Version 0.30:
40 Markus: Updates for 2.5.x kernel and more ISO compliant source 46 Markus: Updates for 2.5.x kernel and more ISO compliant source
@@ -65,13 +71,12 @@
65 71
66*/ 72*/
67 73
68
69#include <linux/kernel.h> 74#include <linux/kernel.h>
70#include <linux/module.h> 75#include <linux/module.h>
71#include <linux/init.h> 76#include <linux/init.h>
72#include <linux/slab.h> 77#include <linux/slab.h>
73#include <linux/input.h> 78#include <linux/input.h>
74#include <linux/videodev.h> 79#include <linux/videodev2.h>
75#include <media/v4l2-common.h> 80#include <media/v4l2-common.h>
76#include <linux/usb.h> 81#include <linux/usb.h>
77#include <linux/smp_lock.h> 82#include <linux/smp_lock.h>
@@ -79,7 +84,22 @@
79/* 84/*
80 * Version Information 85 * Version Information
81 */ 86 */
82#define DRIVER_VERSION "v0.40" 87#include <linux/version.h> /* for KERNEL_VERSION MACRO */
88
89#define DRIVER_VERSION "v0.41"
90#define RADIO_VERSION KERNEL_VERSION(0,4,1)
91
92static struct v4l2_queryctrl radio_qctrl[] = {
93 {
94 .id = V4L2_CID_AUDIO_MUTE,
95 .name = "Mute",
96 .minimum = 0,
97 .maximum = 1,
98 .default_value = 1,
99 .type = V4L2_CTRL_TYPE_BOOLEAN,
100 }
101};
102
83#define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" 103#define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>"
84#define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" 104#define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver"
85 105
@@ -111,7 +131,7 @@ static int radio_nr = -1;
111module_param(radio_nr, int, 0); 131module_param(radio_nr, int, 0);
112 132
113/* Data for one (physical) device */ 133/* Data for one (physical) device */
114typedef struct { 134struct dsbr100_device {
115 struct usb_device *usbdev; 135 struct usb_device *usbdev;
116 struct video_device *videodev; 136 struct video_device *videodev;
117 unsigned char transfer_buffer[TB_LEN]; 137 unsigned char transfer_buffer[TB_LEN];
@@ -119,7 +139,8 @@ typedef struct {
119 int stereo; 139 int stereo;
120 int users; 140 int users;
121 int removed; 141 int removed;
122} dsbr100_device; 142 int muted;
143};
123 144
124 145
125/* File system interface */ 146/* File system interface */
@@ -138,7 +159,6 @@ static struct video_device dsbr100_videodev_template=
138 .owner = THIS_MODULE, 159 .owner = THIS_MODULE,
139 .name = "D-Link DSB-R 100", 160 .name = "D-Link DSB-R 100",
140 .type = VID_TYPE_TUNER, 161 .type = VID_TYPE_TUNER,
141 .hardware = VID_HARDWARE_AZTECH,
142 .fops = &usb_dsbr100_fops, 162 .fops = &usb_dsbr100_fops,
143 .release = video_device_release, 163 .release = video_device_release,
144}; 164};
@@ -161,7 +181,7 @@ static struct usb_driver usb_dsbr100_driver = {
161/* Low-level device interface begins here */ 181/* Low-level device interface begins here */
162 182
163/* switch on radio */ 183/* switch on radio */
164static int dsbr100_start(dsbr100_device *radio) 184static int dsbr100_start(struct dsbr100_device *radio)
165{ 185{
166 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 186 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
167 USB_REQ_GET_STATUS, 187 USB_REQ_GET_STATUS,
@@ -172,12 +192,13 @@ static int dsbr100_start(dsbr100_device *radio)
172 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 192 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
173 0x01, 0x00, radio->transfer_buffer, 8, 300)<0) 193 0x01, 0x00, radio->transfer_buffer, 8, 300)<0)
174 return -1; 194 return -1;
195 radio->muted=0;
175 return (radio->transfer_buffer)[0]; 196 return (radio->transfer_buffer)[0];
176} 197}
177 198
178 199
179/* switch off radio */ 200/* switch off radio */
180static int dsbr100_stop(dsbr100_device *radio) 201static int dsbr100_stop(struct dsbr100_device *radio)
181{ 202{
182 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 203 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
183 USB_REQ_GET_STATUS, 204 USB_REQ_GET_STATUS,
@@ -188,11 +209,12 @@ static int dsbr100_stop(dsbr100_device *radio)
188 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 209 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
189 0x00, 0x00, radio->transfer_buffer, 8, 300)<0) 210 0x00, 0x00, radio->transfer_buffer, 8, 300)<0)
190 return -1; 211 return -1;
212 radio->muted=1;
191 return (radio->transfer_buffer)[0]; 213 return (radio->transfer_buffer)[0];
192} 214}
193 215
194/* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */ 216/* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */
195static int dsbr100_setfreq(dsbr100_device *radio, int freq) 217static int dsbr100_setfreq(struct dsbr100_device *radio, int freq)
196{ 218{
197 freq = (freq/16*80)/1000+856; 219 freq = (freq/16*80)/1000+856;
198 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 220 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
@@ -217,7 +239,7 @@ static int dsbr100_setfreq(dsbr100_device *radio, int freq)
217 239
218/* return the device status. This is, in effect, just whether it 240/* return the device status. This is, in effect, just whether it
219sees a stereo signal or not. Pity. */ 241sees a stereo signal or not. Pity. */
220static void dsbr100_getstat(dsbr100_device *radio) 242static void dsbr100_getstat(struct dsbr100_device *radio)
221{ 243{
222 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 244 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
223 USB_REQ_GET_STATUS, 245 USB_REQ_GET_STATUS,
@@ -236,9 +258,9 @@ usb if it is */
236static int usb_dsbr100_probe(struct usb_interface *intf, 258static int usb_dsbr100_probe(struct usb_interface *intf,
237 const struct usb_device_id *id) 259 const struct usb_device_id *id)
238{ 260{
239 dsbr100_device *radio; 261 struct dsbr100_device *radio;
240 262
241 if (!(radio = kmalloc(sizeof(dsbr100_device), GFP_KERNEL))) 263 if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL)))
242 return -ENOMEM; 264 return -ENOMEM;
243 if (!(radio->videodev = video_device_alloc())) { 265 if (!(radio->videodev = video_device_alloc())) {
244 kfree(radio); 266 kfree(radio);
@@ -271,7 +293,7 @@ code I'd expect I better did that, but if there's a memory
271leak here it's tiny (~50 bytes per disconnect) */ 293leak here it's tiny (~50 bytes per disconnect) */
272static void usb_dsbr100_disconnect(struct usb_interface *intf) 294static void usb_dsbr100_disconnect(struct usb_interface *intf)
273{ 295{
274 dsbr100_device *radio = usb_get_intfdata(intf); 296 struct dsbr100_device *radio = usb_get_intfdata(intf);
275 297
276 usb_set_intfdata (intf, NULL); 298 usb_set_intfdata (intf, NULL);
277 if (radio) { 299 if (radio) {
@@ -291,89 +313,121 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf)
291static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file, 313static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
292 unsigned int cmd, void *arg) 314 unsigned int cmd, void *arg)
293{ 315{
294 dsbr100_device *radio=video_get_drvdata(video_devdata(file)); 316 struct dsbr100_device *radio=video_get_drvdata(video_devdata(file));
295 317
296 if (!radio) 318 if (!radio)
297 return -EIO; 319 return -EIO;
298 320
299 switch(cmd) { 321 switch(cmd) {
300 case VIDIOCGCAP: { 322 case VIDIOC_QUERYCAP:
301 struct video_capability *v = arg; 323 {
302 324 struct v4l2_capability *v = arg;
303 memset(v, 0, sizeof(*v)); 325 memset(v,0,sizeof(*v));
304 v->type = VID_TYPE_TUNER; 326 strlcpy(v->driver, "dsbr100", sizeof (v->driver));
305 v->channels = 1; 327 strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof (v->card));
306 v->audios = 1; 328 sprintf(v->bus_info,"ISA");
307 strcpy(v->name, "D-Link R-100 USB FM Radio"); 329 v->version = RADIO_VERSION;
330 v->capabilities = V4L2_CAP_TUNER;
331
308 return 0; 332 return 0;
309 } 333 }
310 case VIDIOCGTUNER: { 334 case VIDIOC_G_TUNER:
311 struct video_tuner *v = arg; 335 {
336 struct v4l2_tuner *v = arg;
312 337
313 dsbr100_getstat(radio); 338 if (v->index > 0)
314 if(v->tuner) /* Only 1 tuner */
315 return -EINVAL; 339 return -EINVAL;
340
341 dsbr100_getstat(radio);
342
343 memset(v,0,sizeof(*v));
344 strcpy(v->name, "FM");
345 v->type = V4L2_TUNER_RADIO;
346
316 v->rangelow = FREQ_MIN*FREQ_MUL; 347 v->rangelow = FREQ_MIN*FREQ_MUL;
317 v->rangehigh = FREQ_MAX*FREQ_MUL; 348 v->rangehigh = FREQ_MAX*FREQ_MUL;
318 v->flags = VIDEO_TUNER_LOW; 349 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
319 v->mode = VIDEO_MODE_AUTO; 350 v->capability=V4L2_TUNER_CAP_LOW;
320 v->signal = radio->stereo*0x7000; 351 if(radio->stereo)
321 /* Don't know how to get signal strength */ 352 v->audmode = V4L2_TUNER_MODE_STEREO;
322 v->flags |= VIDEO_TUNER_STEREO_ON*radio->stereo; 353 else
323 strcpy(v->name, "DSB R-100"); 354 v->audmode = V4L2_TUNER_MODE_MONO;
324 return 0; 355 v->signal = 0xFFFF; /* We can't get the signal strength */
325 }
326 case VIDIOCSTUNER: {
327 struct video_tuner *v = arg;
328 356
329 if(v->tuner!=0)
330 return -EINVAL;
331 /* Only 1 tuner so no setting needed ! */
332 return 0; 357 return 0;
333 } 358 }
334 case VIDIOCGFREQ: { 359 case VIDIOC_S_TUNER:
335 int *freq = arg; 360 {
361 struct v4l2_tuner *v = arg;
336 362
337 if (radio->curfreq==-1) 363 if (v->index > 0)
338 return -EINVAL; 364 return -EINVAL;
339 *freq = radio->curfreq; 365
340 return 0; 366 return 0;
341 } 367 }
342 case VIDIOCSFREQ: { 368 case VIDIOC_S_FREQUENCY:
343 int *freq = arg; 369 {
370 struct v4l2_frequency *f = arg;
344 371
345 radio->curfreq = *freq; 372 radio->curfreq = f->frequency;
346 if (dsbr100_setfreq(radio, radio->curfreq)==-1) 373 if (dsbr100_setfreq(radio, radio->curfreq)==-1)
347 warn("Set frequency failed"); 374 warn("Set frequency failed");
348 return 0; 375 return 0;
349 } 376 }
350 case VIDIOCGAUDIO: { 377 case VIDIOC_G_FREQUENCY:
351 struct video_audio *v = arg; 378 {
352 379 struct v4l2_frequency *f = arg;
353 memset(v, 0, sizeof(*v)); 380
354 v->flags |= VIDEO_AUDIO_MUTABLE; 381 f->type = V4L2_TUNER_RADIO;
355 v->mode = VIDEO_SOUND_STEREO; 382 f->frequency = radio->curfreq;
356 v->volume = 1; 383
357 v->step = 1;
358 strcpy(v->name, "Radio");
359 return 0; 384 return 0;
360 } 385 }
361 case VIDIOCSAUDIO: { 386 case VIDIOC_QUERYCTRL:
362 struct video_audio *v = arg; 387 {
363 388 struct v4l2_queryctrl *qc = arg;
364 if (v->audio) 389 int i;
365 return -EINVAL; 390
366 if (v->flags&VIDEO_AUDIO_MUTE) { 391 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
367 if (dsbr100_stop(radio)==-1) 392 if (qc->id && qc->id == radio_qctrl[i].id) {
368 warn("Radio did not respond properly"); 393 memcpy(qc, &(radio_qctrl[i]),
394 sizeof(*qc));
395 return 0;
396 }
369 } 397 }
370 else 398 return -EINVAL;
371 if (dsbr100_start(radio)==-1) 399 }
372 warn("Radio did not respond properly"); 400 case VIDIOC_G_CTRL:
373 return 0; 401 {
402 struct v4l2_control *ctrl= arg;
403
404 switch (ctrl->id) {
405 case V4L2_CID_AUDIO_MUTE:
406 ctrl->value=radio->muted;
407 return 0;
408 }
409 return -EINVAL;
410 }
411 case VIDIOC_S_CTRL:
412 {
413 struct v4l2_control *ctrl= arg;
414
415 switch (ctrl->id) {
416 case V4L2_CID_AUDIO_MUTE:
417 if (ctrl->value) {
418 if (dsbr100_stop(radio)==-1)
419 warn("Radio did not respond properly");
420 } else {
421 if (dsbr100_start(radio)==-1)
422 warn("Radio did not respond properly");
423 }
424 return 0;
425 }
426 return -EINVAL;
374 } 427 }
375 default: 428 default:
376 return -ENOIOCTLCMD; 429 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
430 usb_dsbr100_do_ioctl);
377 } 431 }
378} 432}
379 433
@@ -385,9 +439,11 @@ static int usb_dsbr100_ioctl(struct inode *inode, struct file *file,
385 439
386static int usb_dsbr100_open(struct inode *inode, struct file *file) 440static int usb_dsbr100_open(struct inode *inode, struct file *file)
387{ 441{
388 dsbr100_device *radio=video_get_drvdata(video_devdata(file)); 442 struct dsbr100_device *radio=video_get_drvdata(video_devdata(file));
389 443
390 radio->users = 1; 444 radio->users = 1;
445 radio->muted = 1;
446
391 if (dsbr100_start(radio)<0) { 447 if (dsbr100_start(radio)<0) {
392 warn("Radio did not start up properly"); 448 warn("Radio did not start up properly");
393 radio->users = 0; 449 radio->users = 0;
@@ -399,7 +455,7 @@ static int usb_dsbr100_open(struct inode *inode, struct file *file)
399 455
400static int usb_dsbr100_close(struct inode *inode, struct file *file) 456static int usb_dsbr100_close(struct inode *inode, struct file *file)
401{ 457{
402 dsbr100_device *radio=video_get_drvdata(video_devdata(file)); 458 struct dsbr100_device *radio=video_get_drvdata(video_devdata(file));
403 459
404 if (!radio) 460 if (!radio)
405 return -ENODEV; 461 return -ENODEV;
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index df22a582e7a2..3368a89bfadb 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -1,5 +1,6 @@
1/* radiotrack (radioreveal) driver for Linux radio support 1/* radiotrack (radioreveal) driver for Linux radio support
2 * (c) 1997 M. Kirkwood 2 * (c) 1997 M. Kirkwood
3 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
3 * Converted to new API by Alan Cox <Alan.Cox@linux.org> 4 * Converted to new API by Alan Cox <Alan.Cox@linux.org>
4 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org> 5 * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org>
5 * 6 *
@@ -33,11 +34,13 @@
33#include <linux/delay.h> /* udelay */ 34#include <linux/delay.h> /* udelay */
34#include <asm/io.h> /* outb, outb_p */ 35#include <asm/io.h> /* outb, outb_p */
35#include <asm/uaccess.h> /* copy to/from user */ 36#include <asm/uaccess.h> /* copy to/from user */
36#include <linux/videodev.h> /* kernel radio structs */ 37#include <linux/videodev2.h> /* kernel radio structs */
37#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
38#include <linux/config.h> /* CONFIG_RADIO_RTRACK_PORT */
39#include <asm/semaphore.h> /* Lock for the I/O */ 39#include <asm/semaphore.h> /* Lock for the I/O */
40 40
41#include <linux/version.h> /* for KERNEL_VERSION MACRO */
42#define RADIO_VERSION KERNEL_VERSION(0,0,2)
43
41#ifndef CONFIG_RADIO_RTRACK_PORT 44#ifndef CONFIG_RADIO_RTRACK_PORT
42#define CONFIG_RADIO_RTRACK_PORT -1 45#define CONFIG_RADIO_RTRACK_PORT -1
43#endif 46#endif
@@ -209,6 +212,25 @@ static int rt_getsigstr(struct rt_device *dev)
209 return 1; /* signal present */ 212 return 1; /* signal present */
210} 213}
211 214
215static struct v4l2_queryctrl radio_qctrl[] = {
216 {
217 .id = V4L2_CID_AUDIO_MUTE,
218 .name = "Mute",
219 .minimum = 0,
220 .maximum = 1,
221 .default_value = 1,
222 .type = V4L2_CTRL_TYPE_BOOLEAN,
223 },{
224 .id = V4L2_CID_AUDIO_VOLUME,
225 .name = "Volume",
226 .minimum = 0,
227 .maximum = 0xff,
228 .step = 1,
229 .default_value = 0xff,
230 .type = V4L2_CTRL_TYPE_INTEGER,
231 }
232};
233
212static int rt_do_ioctl(struct inode *inode, struct file *file, 234static int rt_do_ioctl(struct inode *inode, struct file *file,
213 unsigned int cmd, void *arg) 235 unsigned int cmd, void *arg)
214{ 236{
@@ -217,73 +239,114 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
217 239
218 switch(cmd) 240 switch(cmd)
219 { 241 {
220 case VIDIOCGCAP: 242 case VIDIOC_QUERYCAP:
221 { 243 {
222 struct video_capability *v = arg; 244 struct v4l2_capability *v = arg;
223 memset(v,0,sizeof(*v)); 245 memset(v,0,sizeof(*v));
224 v->type=VID_TYPE_TUNER; 246 strlcpy(v->driver, "radio-aimslab", sizeof (v->driver));
225 v->channels=1; 247 strlcpy(v->card, "RadioTrack", sizeof (v->card));
226 v->audios=1; 248 sprintf(v->bus_info,"ISA");
227 strcpy(v->name, "RadioTrack"); 249 v->version = RADIO_VERSION;
250 v->capabilities = V4L2_CAP_TUNER;
251
228 return 0; 252 return 0;
229 } 253 }
230 case VIDIOCGTUNER: 254 case VIDIOC_G_TUNER:
231 { 255 {
232 struct video_tuner *v = arg; 256 struct v4l2_tuner *v = arg;
233 if(v->tuner) /* Only 1 tuner */ 257
258 if (v->index > 0)
234 return -EINVAL; 259 return -EINVAL;
260
261 memset(v,0,sizeof(*v));
262 strcpy(v->name, "FM");
263 v->type = V4L2_TUNER_RADIO;
264
235 v->rangelow=(87*16000); 265 v->rangelow=(87*16000);
236 v->rangehigh=(108*16000); 266 v->rangehigh=(108*16000);
237 v->flags=VIDEO_TUNER_LOW; 267 v->rxsubchans =V4L2_TUNER_SUB_MONO;
238 v->mode=VIDEO_MODE_AUTO; 268 v->capability=V4L2_TUNER_CAP_LOW;
239 strcpy(v->name, "FM"); 269 v->audmode = V4L2_TUNER_MODE_MONO;
240 v->signal=0xFFFF*rt_getsigstr(rt); 270 v->signal=0xFFFF*rt_getsigstr(rt);
271
241 return 0; 272 return 0;
242 } 273 }
243 case VIDIOCSTUNER: 274 case VIDIOC_S_TUNER:
244 { 275 {
245 struct video_tuner *v = arg; 276 struct v4l2_tuner *v = arg;
246 if(v->tuner!=0) 277
278 if (v->index > 0)
247 return -EINVAL; 279 return -EINVAL;
248 /* Only 1 tuner so no setting needed ! */ 280
249 return 0; 281 return 0;
250 } 282 }
251 case VIDIOCGFREQ: 283 case VIDIOC_S_FREQUENCY:
252 { 284 {
253 unsigned long *freq = arg; 285 struct v4l2_frequency *f = arg;
254 *freq = rt->curfreq; 286
287 rt->curfreq = f->frequency;
288 rt_setfreq(rt, rt->curfreq);
255 return 0; 289 return 0;
256 } 290 }
257 case VIDIOCSFREQ: 291 case VIDIOC_G_FREQUENCY:
258 { 292 {
259 unsigned long *freq = arg; 293 struct v4l2_frequency *f = arg;
260 rt->curfreq = *freq; 294
261 rt_setfreq(rt, rt->curfreq); 295 f->type = V4L2_TUNER_RADIO;
296 f->frequency = rt->curfreq;
297
262 return 0; 298 return 0;
263 } 299 }
264 case VIDIOCGAUDIO: 300 case VIDIOC_QUERYCTRL:
265 { 301 {
266 struct video_audio *v = arg; 302 struct v4l2_queryctrl *qc = arg;
267 memset(v,0, sizeof(*v)); 303 int i;
268 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 304
269 v->volume=rt->curvol * 6554; 305 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
270 v->step=6554; 306 if (qc->id && qc->id == radio_qctrl[i].id) {
271 strcpy(v->name, "Radio"); 307 memcpy(qc, &(radio_qctrl[i]),
272 return 0; 308 sizeof(*qc));
309 return (0);
310 }
311 }
312 return -EINVAL;
273 } 313 }
274 case VIDIOCSAUDIO: 314 case VIDIOC_G_CTRL:
275 { 315 {
276 struct video_audio *v = arg; 316 struct v4l2_control *ctrl= arg;
277 if(v->audio) 317
278 return -EINVAL; 318 switch (ctrl->id) {
279 if(v->flags&VIDEO_AUDIO_MUTE) 319 case V4L2_CID_AUDIO_MUTE:
280 rt_mute(rt); 320 ctrl->value=rt->muted;
281 else 321 return (0);
282 rt_setvol(rt,v->volume/6554); 322 case V4L2_CID_AUDIO_VOLUME:
283 return 0; 323 ctrl->value=rt->curvol * 6554;
324 return (0);
325 }
326 return -EINVAL;
284 } 327 }
328 case VIDIOC_S_CTRL:
329 {
330 struct v4l2_control *ctrl= arg;
331
332 switch (ctrl->id) {
333 case V4L2_CID_AUDIO_MUTE:
334 if (ctrl->value) {
335 rt_mute(rt);
336 } else {
337 rt_setvol(rt,rt->curvol);
338 }
339 return (0);
340 case V4L2_CID_AUDIO_VOLUME:
341 rt_setvol(rt,ctrl->value);
342 return (0);
343 }
344 return -EINVAL;
345 }
346
285 default: 347 default:
286 return -ENOIOCTLCMD; 348 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
349 rt_do_ioctl);
287 } 350 }
288} 351}
289 352
@@ -309,7 +372,7 @@ static struct video_device rtrack_radio=
309 .owner = THIS_MODULE, 372 .owner = THIS_MODULE,
310 .name = "RadioTrack radio", 373 .name = "RadioTrack radio",
311 .type = VID_TYPE_TUNER, 374 .type = VID_TYPE_TUNER,
312 .hardware = VID_HARDWARE_RTRACK, 375 .hardware = 0,
313 .fops = &rtrack_fops, 376 .fops = &rtrack_fops,
314}; 377};
315 378
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 95e6322133ee..3ba5fa8cf7e6 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -1,5 +1,6 @@
1/* radio-aztech.c - Aztech radio card driver for Linux 2.2 1/* radio-aztech.c - Aztech radio card driver for Linux 2.2
2 * 2 *
3 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
3 * Adapted to support the Video for Linux API by 4 * Adapted to support the Video for Linux API by
4 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by: 5 * Russell Kroll <rkroll@exploits.org>. Based on original tuner code by:
5 * 6 *
@@ -30,9 +31,30 @@
30#include <linux/delay.h> /* udelay */ 31#include <linux/delay.h> /* udelay */
31#include <asm/io.h> /* outb, outb_p */ 32#include <asm/io.h> /* outb, outb_p */
32#include <asm/uaccess.h> /* copy to/from user */ 33#include <asm/uaccess.h> /* copy to/from user */
33#include <linux/videodev.h> /* kernel radio structs */ 34#include <linux/videodev2.h> /* kernel radio structs */
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
35#include <linux/config.h> /* CONFIG_RADIO_AZTECH_PORT */ 36
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */
38#define RADIO_VERSION KERNEL_VERSION(0,0,2)
39
40static struct v4l2_queryctrl radio_qctrl[] = {
41 {
42 .id = V4L2_CID_AUDIO_MUTE,
43 .name = "Mute",
44 .minimum = 0,
45 .maximum = 1,
46 .default_value = 1,
47 .type = V4L2_CTRL_TYPE_BOOLEAN,
48 },{
49 .id = V4L2_CID_AUDIO_VOLUME,
50 .name = "Volume",
51 .minimum = 0,
52 .maximum = 0xff,
53 .step = 1,
54 .default_value = 0xff,
55 .type = V4L2_CTRL_TYPE_INTEGER,
56 }
57};
36 58
37/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ 59/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
38 60
@@ -166,81 +188,121 @@ static int az_do_ioctl(struct inode *inode, struct file *file,
166 188
167 switch(cmd) 189 switch(cmd)
168 { 190 {
169 case VIDIOCGCAP: 191 case VIDIOC_QUERYCAP:
170 { 192 {
171 struct video_capability *v = arg; 193 struct v4l2_capability *v = arg;
172 memset(v,0,sizeof(*v)); 194 memset(v,0,sizeof(*v));
173 v->type=VID_TYPE_TUNER; 195 strlcpy(v->driver, "radio-aztech", sizeof (v->driver));
174 v->channels=1; 196 strlcpy(v->card, "Aztech Radio", sizeof (v->card));
175 v->audios=1; 197 sprintf(v->bus_info,"ISA");
176 strcpy(v->name, "Aztech Radio"); 198 v->version = RADIO_VERSION;
199 v->capabilities = V4L2_CAP_TUNER;
200
177 return 0; 201 return 0;
178 } 202 }
179 case VIDIOCGTUNER: 203 case VIDIOC_G_TUNER:
180 { 204 {
181 struct video_tuner *v = arg; 205 struct v4l2_tuner *v = arg;
182 if(v->tuner) /* Only 1 tuner */ 206
207 if (v->index > 0)
183 return -EINVAL; 208 return -EINVAL;
209
210 memset(v,0,sizeof(*v));
211 strcpy(v->name, "FM");
212 v->type = V4L2_TUNER_RADIO;
213
184 v->rangelow=(87*16000); 214 v->rangelow=(87*16000);
185 v->rangehigh=(108*16000); 215 v->rangehigh=(108*16000);
186 v->flags=VIDEO_TUNER_LOW; 216 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
187 v->mode=VIDEO_MODE_AUTO; 217 v->capability=V4L2_TUNER_CAP_LOW;
188 v->signal=0xFFFF*az_getsigstr(az);
189 if(az_getstereo(az)) 218 if(az_getstereo(az))
190 v->flags|=VIDEO_TUNER_STEREO_ON; 219 v->audmode = V4L2_TUNER_MODE_STEREO;
191 strcpy(v->name, "FM"); 220 else
221 v->audmode = V4L2_TUNER_MODE_MONO;
222 v->signal=0xFFFF*az_getsigstr(az);
223
192 return 0; 224 return 0;
193 } 225 }
194 case VIDIOCSTUNER: 226 case VIDIOC_S_TUNER:
195 { 227 {
196 struct video_tuner *v = arg; 228 struct v4l2_tuner *v = arg;
197 if(v->tuner!=0) 229
230 if (v->index > 0)
198 return -EINVAL; 231 return -EINVAL;
232
199 return 0; 233 return 0;
200 } 234 }
201 case VIDIOCGFREQ: 235 case VIDIOC_S_FREQUENCY:
202 { 236 {
203 unsigned long *freq = arg; 237 struct v4l2_frequency *f = arg;
204 *freq = az->curfreq; 238
239 az->curfreq = f->frequency;
240 az_setfreq(az, az->curfreq);
205 return 0; 241 return 0;
206 } 242 }
207 case VIDIOCSFREQ: 243 case VIDIOC_G_FREQUENCY:
208 { 244 {
209 unsigned long *freq = arg; 245 struct v4l2_frequency *f = arg;
210 az->curfreq = *freq; 246
211 az_setfreq(az, az->curfreq); 247 f->type = V4L2_TUNER_RADIO;
248 f->frequency = az->curfreq;
249
212 return 0; 250 return 0;
213 } 251 }
214 case VIDIOCGAUDIO: 252
253 case VIDIOC_QUERYCTRL:
215 { 254 {
216 struct video_audio *v = arg; 255 struct v4l2_queryctrl *qc = arg;
217 memset(v,0, sizeof(*v)); 256 int i;
218 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 257
219 if(az->stereo) 258 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
220 v->mode=VIDEO_SOUND_STEREO; 259 if (qc->id && qc->id == radio_qctrl[i].id) {
221 else 260 memcpy(qc, &(radio_qctrl[i]),
222 v->mode=VIDEO_SOUND_MONO; 261 sizeof(*qc));
223 v->volume=az->curvol; 262 return (0);
224 v->step=16384; 263 }
225 strcpy(v->name, "Radio"); 264 }
226 return 0; 265 return -EINVAL;
227 } 266 }
228 case VIDIOCSAUDIO: 267 case VIDIOC_G_CTRL:
229 { 268 {
230 struct video_audio *v = arg; 269 struct v4l2_control *ctrl= arg;
231 if(v->audio) 270
232 return -EINVAL; 271 switch (ctrl->id) {
233 az->curvol=v->volume; 272 case V4L2_CID_AUDIO_MUTE:
234 273 if (az->curvol==0)
235 az->stereo=(v->mode&VIDEO_SOUND_STEREO)?1:0; 274 ctrl->value=1;
236 if(v->flags&VIDEO_AUDIO_MUTE) 275 else
237 az_setvol(az,0); 276 ctrl->value=0;
238 else 277 return (0);
239 az_setvol(az,az->curvol); 278 case V4L2_CID_AUDIO_VOLUME:
240 return 0; 279 ctrl->value=az->curvol * 6554;
280 return (0);
281 }
282 return -EINVAL;
283 }
284 case VIDIOC_S_CTRL:
285 {
286 struct v4l2_control *ctrl= arg;
287
288 switch (ctrl->id) {
289 case V4L2_CID_AUDIO_MUTE:
290 if (ctrl->value) {
291 az_setvol(az,0);
292 } else {
293 az_setvol(az,az->curvol);
294 }
295 return (0);
296 case V4L2_CID_AUDIO_VOLUME:
297 az_setvol(az,ctrl->value);
298 return (0);
299 }
300 return -EINVAL;
241 } 301 }
302
242 default: 303 default:
243 return -ENOIOCTLCMD; 304 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
305 az_do_ioctl);
244 } 306 }
245} 307}
246 308
@@ -266,7 +328,7 @@ static struct video_device aztech_radio=
266 .owner = THIS_MODULE, 328 .owner = THIS_MODULE,
267 .name = "Aztech radio", 329 .name = "Aztech radio",
268 .type = VID_TYPE_TUNER, 330 .type = VID_TYPE_TUNER,
269 .hardware = VID_HARDWARE_AZTECH, 331 .hardware = 0,
270 .fops = &aztech_fops, 332 .fops = &aztech_fops,
271}; 333};
272 334
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 8641aec7baf8..69d4b7919c5a 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -25,20 +25,28 @@
25 * 25 *
26 * 2003-01-31 Alan Cox <alan@redhat.com> 26 * 2003-01-31 Alan Cox <alan@redhat.com>
27 * Cleaned up locking, delay code, general odds and ends 27 * Cleaned up locking, delay code, general odds and ends
28 *
29 * 2006-07-30 Hans J. Koch <koch@hjk-az.de>
30 * Changed API to V4L2
28 */ 31 */
29 32
33#include <linux/version.h>
30#include <linux/module.h> /* Modules */ 34#include <linux/module.h> /* Modules */
31#include <linux/init.h> /* Initdata */ 35#include <linux/init.h> /* Initdata */
32#include <linux/ioport.h> /* request_region */ 36#include <linux/ioport.h> /* request_region */
33#include <linux/delay.h> /* udelay */ 37#include <linux/delay.h> /* udelay */
34#include <asm/io.h> /* outb, outb_p */ 38#include <asm/io.h> /* outb, outb_p */
35#include <asm/uaccess.h> /* copy to/from user */ 39#include <asm/uaccess.h> /* copy to/from user */
36#include <linux/videodev.h> /* kernel radio structs */ 40#include <linux/videodev2.h> /* V4L2 API defs */
37#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
38#include <linux/param.h> 42#include <linux/param.h>
39#include <linux/pnp.h> 43#include <linux/pnp.h>
40 44
41#define RDS_BUFFER 256 45#define RDS_BUFFER 256
46#define RDS_RX_FLAG 1
47#define MBS_RX_FLAG 2
48
49#define CADET_VERSION KERNEL_VERSION(0,3,3)
42 50
43static int io=-1; /* default to isapnp activation */ 51static int io=-1; /* default to isapnp activation */
44static int radio_nr = -1; 52static int radio_nr = -1;
@@ -61,44 +69,24 @@ static int cadet_probe(void);
61 */ 69 */
62static __u16 sigtable[2][4]={{5,10,30,150},{28,40,63,1000}}; 70static __u16 sigtable[2][4]={{5,10,30,150},{28,40,63,1000}};
63 71
64static int cadet_getrds(void)
65{
66 int rdsstat=0;
67
68 spin_lock(&cadet_io_lock);
69 outb(3,io); /* Select Decoder Control/Status */
70 outb(inb(io+1)&0x7f,io+1); /* Reset RDS detection */
71 spin_unlock(&cadet_io_lock);
72
73 msleep(100);
74
75 spin_lock(&cadet_io_lock);
76 outb(3,io); /* Select Decoder Control/Status */
77 if((inb(io+1)&0x80)!=0) {
78 rdsstat|=VIDEO_TUNER_RDS_ON;
79 }
80 if((inb(io+1)&0x10)!=0) {
81 rdsstat|=VIDEO_TUNER_MBS_ON;
82 }
83 spin_unlock(&cadet_io_lock);
84 return rdsstat;
85}
86 72
87static int cadet_getstereo(void) 73static int
74cadet_getstereo(void)
88{ 75{
89 int ret = 0; 76 int ret = V4L2_TUNER_SUB_MONO;
90 if(curtuner != 0) /* Only FM has stereo capability! */ 77 if(curtuner != 0) /* Only FM has stereo capability! */
91 return 0; 78 return V4L2_TUNER_SUB_MONO;
92 79
93 spin_lock(&cadet_io_lock); 80 spin_lock(&cadet_io_lock);
94 outb(7,io); /* Select tuner control */ 81 outb(7,io); /* Select tuner control */
95 if( (inb(io+1) & 0x40) == 0) 82 if( (inb(io+1) & 0x40) == 0)
96 ret = 1; 83 ret = V4L2_TUNER_SUB_STEREO;
97 spin_unlock(&cadet_io_lock); 84 spin_unlock(&cadet_io_lock);
98 return ret; 85 return ret;
99} 86}
100 87
101static unsigned cadet_gettune(void) 88static unsigned
89cadet_gettune(void)
102{ 90{
103 int curvol,i; 91 int curvol,i;
104 unsigned fifo=0; 92 unsigned fifo=0;
@@ -135,7 +123,8 @@ static unsigned cadet_gettune(void)
135 return fifo; 123 return fifo;
136} 124}
137 125
138static unsigned cadet_getfreq(void) 126static unsigned
127cadet_getfreq(void)
139{ 128{
140 int i; 129 int i;
141 unsigned freq=0,test,fifo=0; 130 unsigned freq=0,test,fifo=0;
@@ -167,7 +156,8 @@ static unsigned cadet_getfreq(void)
167 return freq; 156 return freq;
168} 157}
169 158
170static void cadet_settune(unsigned fifo) 159static void
160cadet_settune(unsigned fifo)
171{ 161{
172 int i; 162 int i;
173 unsigned test; 163 unsigned test;
@@ -195,7 +185,8 @@ static void cadet_settune(unsigned fifo)
195 spin_unlock(&cadet_io_lock); 185 spin_unlock(&cadet_io_lock);
196} 186}
197 187
198static void cadet_setfreq(unsigned freq) 188static void
189cadet_setfreq(unsigned freq)
199{ 190{
200 unsigned fifo; 191 unsigned fifo;
201 int i,j,test; 192 int i,j,test;
@@ -255,7 +246,8 @@ static void cadet_setfreq(unsigned freq)
255} 246}
256 247
257 248
258static int cadet_getvol(void) 249static int
250cadet_getvol(void)
259{ 251{
260 int ret = 0; 252 int ret = 0;
261 253
@@ -270,7 +262,8 @@ static int cadet_getvol(void)
270} 262}
271 263
272 264
273static void cadet_setvol(int vol) 265static void
266cadet_setvol(int vol)
274{ 267{
275 spin_lock(&cadet_io_lock); 268 spin_lock(&cadet_io_lock);
276 outb(7,io); /* Select tuner control */ 269 outb(7,io); /* Select tuner control */
@@ -281,7 +274,8 @@ static void cadet_setvol(int vol)
281 spin_unlock(&cadet_io_lock); 274 spin_unlock(&cadet_io_lock);
282} 275}
283 276
284static void cadet_handler(unsigned long data) 277static void
278cadet_handler(unsigned long data)
285{ 279{
286 /* 280 /*
287 * Service the RDS fifo 281 * Service the RDS fifo
@@ -322,8 +316,8 @@ static void cadet_handler(unsigned long data)
322 316
323 317
324 318
325static ssize_t cadet_read(struct file *file, char __user *data, 319static ssize_t
326 size_t count, loff_t *ppos) 320cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
327{ 321{
328 int i=0; 322 int i=0;
329 unsigned char readbuf[RDS_BUFFER]; 323 unsigned char readbuf[RDS_BUFFER];
@@ -359,128 +353,156 @@ static int cadet_do_ioctl(struct inode *inode, struct file *file,
359{ 353{
360 switch(cmd) 354 switch(cmd)
361 { 355 {
362 case VIDIOCGCAP: 356 case VIDIOC_QUERYCAP:
363 { 357 {
364 struct video_capability *v = arg; 358 struct v4l2_capability *cap = arg;
365 memset(v,0,sizeof(*v)); 359 memset(cap,0,sizeof(*cap));
366 v->type=VID_TYPE_TUNER; 360 cap->capabilities =
367 v->channels=2; 361 V4L2_CAP_TUNER |
368 v->audios=1; 362 V4L2_CAP_READWRITE;
369 strcpy(v->name, "ADS Cadet"); 363 cap->version = CADET_VERSION;
364 strcpy(cap->driver, "ADS Cadet");
365 strcpy(cap->card, "ADS Cadet");
370 return 0; 366 return 0;
371 } 367 }
372 case VIDIOCGTUNER: 368 case VIDIOC_G_TUNER:
373 { 369 {
374 struct video_tuner *v = arg; 370 struct v4l2_tuner *t = arg;
375 if((v->tuner<0)||(v->tuner>1)) { 371 memset(t,0,sizeof(*t));
376 return -EINVAL; 372 t->type = V4L2_TUNER_RADIO;
377 } 373 switch (t->index)
378 switch(v->tuner) { 374 {
379 case 0: 375 case 0: strcpy(t->name, "FM");
380 strcpy(v->name,"FM"); 376 t->capability = V4L2_TUNER_CAP_STEREO;
381 v->rangelow=1400; /* 87.5 MHz */ 377 t->rangelow = 1400; /* 87.5 MHz */
382 v->rangehigh=1728; /* 108.0 MHz */ 378 t->rangehigh = 1728; /* 108.0 MHz */
383 v->flags=0; 379 t->rxsubchans=cadet_getstereo();
384 v->mode=0; 380 switch (t->rxsubchans){
385 v->mode|=VIDEO_MODE_AUTO; 381 case V4L2_TUNER_SUB_MONO:
386 v->signal=sigstrength; 382 t->audmode = V4L2_TUNER_MODE_MONO;
387 if(cadet_getstereo()==1) { 383 break;
388 v->flags|=VIDEO_TUNER_STEREO_ON; 384 case V4L2_TUNER_SUB_STEREO:
389 } 385 t->audmode = V4L2_TUNER_MODE_STEREO;
390 v->flags|=cadet_getrds(); 386 break;
391 break; 387 default: ;
392 case 1: 388 }
393 strcpy(v->name,"AM"); 389 break;
394 v->rangelow=8320; /* 520 kHz */ 390 case 1: strcpy(t->name, "AM");
395 v->rangehigh=26400; /* 1650 kHz */ 391 t->capability = V4L2_TUNER_CAP_LOW;
396 v->flags=0; 392 t->rangelow = 8320; /* 520 kHz */
397 v->flags|=VIDEO_TUNER_LOW; 393 t->rangehigh = 26400; /* 1650 kHz */
398 v->mode=0; 394 t->rxsubchans = V4L2_TUNER_SUB_MONO;
399 v->mode|=VIDEO_MODE_AUTO; 395 t->audmode = V4L2_TUNER_MODE_MONO;
400 v->signal=sigstrength; 396 break;
401 break; 397 default:
398 return -EINVAL;
402 } 399 }
400
401 t->signal = sigstrength; /* We might need to modify scaling of this */
403 return 0; 402 return 0;
404 } 403 }
405 case VIDIOCSTUNER: 404 case VIDIOC_S_TUNER:
406 { 405 {
407 struct video_tuner *v = arg; 406 struct v4l2_tuner *t = arg;
408 if((v->tuner<0)||(v->tuner>1)) { 407 if((t->index != 0)&&(t->index != 1))
409 return -EINVAL; 408 return -EINVAL;
410 } 409
411 curtuner=v->tuner; 410 curtuner = t->index;
412 return 0; 411 return 0;
413 } 412 }
414 case VIDIOCGFREQ: 413 case VIDIOC_G_FREQUENCY:
415 { 414 {
416 unsigned long *freq = arg; 415 struct v4l2_frequency *f = arg;
417 *freq = cadet_getfreq(); 416 memset(f,0,sizeof(*f));
417 f->tuner = curtuner;
418 f->type = V4L2_TUNER_RADIO;
419 f->frequency = cadet_getfreq();
418 return 0; 420 return 0;
419 } 421 }
420 case VIDIOCSFREQ: 422 case VIDIOC_S_FREQUENCY:
421 { 423 {
422 unsigned long *freq = arg; 424 struct v4l2_frequency *f = arg;
423 if((curtuner==0)&&((*freq<1400)||(*freq>1728))) { 425 if (f->type != V4L2_TUNER_RADIO){
426 return -EINVAL;
427 }
428 if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) {
424 return -EINVAL; 429 return -EINVAL;
425 } 430 }
426 if((curtuner==1)&&((*freq<8320)||(*freq>26400))) { 431 if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) {
427 return -EINVAL; 432 return -EINVAL;
428 } 433 }
429 cadet_setfreq(*freq); 434 cadet_setfreq(f->frequency);
430 return 0; 435 return 0;
431 } 436 }
432 case VIDIOCGAUDIO: 437 case VIDIOC_G_CTRL:
433 { 438 {
434 struct video_audio *v = arg; 439 struct v4l2_control *c = arg;
435 memset(v,0, sizeof(*v)); 440 switch (c->id){
436 v->flags=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 441 case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
437 if(cadet_getstereo()==0) { 442 c->value = (cadet_getvol() == 0);
438 v->mode=VIDEO_SOUND_MONO; 443 break;
439 } else { 444 case V4L2_CID_AUDIO_VOLUME:
440 v->mode=VIDEO_SOUND_STEREO; 445 c->value = cadet_getvol();
446 break;
447 default:
448 return -EINVAL;
441 } 449 }
442 v->volume=cadet_getvol();
443 v->step=0xffff;
444 strcpy(v->name, "Radio");
445 return 0; 450 return 0;
446 } 451 }
447 case VIDIOCSAUDIO: 452 case VIDIOC_S_CTRL:
448 { 453 {
449 struct video_audio *v = arg; 454 struct v4l2_control *c = arg;
450 if(v->audio) 455 switch (c->id){
451 return -EINVAL; 456 case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
452 cadet_setvol(v->volume); 457 if (c->value) cadet_setvol(0);
453 if(v->flags&VIDEO_AUDIO_MUTE) 458 else cadet_setvol(0xffff);
454 cadet_setvol(0); 459 break;
455 else 460 case V4L2_CID_AUDIO_VOLUME:
456 cadet_setvol(0xffff); 461 cadet_setvol(c->value);
462 break;
463 default:
464 return -EINVAL;
465 }
457 return 0; 466 return 0;
458 } 467 }
468
459 default: 469 default:
460 return -ENOIOCTLCMD; 470 return -ENOIOCTLCMD;
461 } 471 }
462} 472}
463 473
464static int cadet_ioctl(struct inode *inode, struct file *file, 474static int
475cadet_ioctl(struct inode *inode, struct file *file,
465 unsigned int cmd, unsigned long arg) 476 unsigned int cmd, unsigned long arg)
466{ 477{
467 return video_usercopy(inode, file, cmd, arg, cadet_do_ioctl); 478 return video_usercopy(inode, file, cmd, arg, cadet_do_ioctl);
468} 479}
469 480
470static int cadet_open(struct inode *inode, struct file *file) 481static int
482cadet_open(struct inode *inode, struct file *file)
471{ 483{
472 if(users)
473 return -EBUSY;
474 users++; 484 users++;
475 init_waitqueue_head(&read_queue); 485 if (1 == users) init_waitqueue_head(&read_queue);
476 return 0; 486 return 0;
477} 487}
478 488
479static int cadet_release(struct inode *inode, struct file *file) 489static int
490cadet_release(struct inode *inode, struct file *file)
480{ 491{
481 del_timer_sync(&readtimer);
482 rdsstat=0;
483 users--; 492 users--;
493 if (0 == users){
494 del_timer_sync(&readtimer);
495 rdsstat=0;
496 }
497 return 0;
498}
499
500static unsigned int
501cadet_poll(struct file *file, struct poll_table_struct *wait)
502{
503 poll_wait(file,&read_queue,wait);
504 if(rdsin != rdsout)
505 return POLLIN | POLLRDNORM;
484 return 0; 506 return 0;
485} 507}
486 508
@@ -491,6 +513,7 @@ static struct file_operations cadet_fops = {
491 .release = cadet_release, 513 .release = cadet_release,
492 .read = cadet_read, 514 .read = cadet_read,
493 .ioctl = cadet_ioctl, 515 .ioctl = cadet_ioctl,
516 .poll = cadet_poll,
494 .compat_ioctl = v4l_compat_ioctl32, 517 .compat_ioctl = v4l_compat_ioctl32,
495 .llseek = no_llseek, 518 .llseek = no_llseek,
496}; 519};
@@ -500,7 +523,6 @@ static struct video_device cadet_radio=
500 .owner = THIS_MODULE, 523 .owner = THIS_MODULE,
501 .name = "Cadet radio", 524 .name = "Cadet radio",
502 .type = VID_TYPE_TUNER, 525 .type = VID_TYPE_TUNER,
503 .hardware = VID_HARDWARE_CADET,
504 .fops = &cadet_fops, 526 .fops = &cadet_fops,
505}; 527};
506 528
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 4c82956390c1..cfab57d6bc4a 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -34,6 +34,8 @@
34 * 34 *
35 * TODO: multiple device support and portability were not tested 35 * TODO: multiple device support and portability were not tested
36 * 36 *
37 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
38 *
37 *************************************************************************** 39 ***************************************************************************
38 */ 40 */
39 41
@@ -42,10 +44,32 @@
42#include <linux/module.h> 44#include <linux/module.h>
43#include <linux/init.h> 45#include <linux/init.h>
44#include <linux/pci.h> 46#include <linux/pci.h>
45#include <linux/videodev.h> 47#include <linux/videodev2.h>
46#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
47#include <linux/errno.h> 49#include <linux/errno.h>
48 50
51#include <linux/version.h> /* for KERNEL_VERSION MACRO */
52#define RADIO_VERSION KERNEL_VERSION(0,0,2)
53
54static struct v4l2_queryctrl radio_qctrl[] = {
55 {
56 .id = V4L2_CID_AUDIO_MUTE,
57 .name = "Mute",
58 .minimum = 0,
59 .maximum = 1,
60 .default_value = 1,
61 .type = V4L2_CTRL_TYPE_BOOLEAN,
62 },{
63 .id = V4L2_CID_AUDIO_VOLUME,
64 .name = "Volume",
65 .minimum = 0,
66 .maximum = 65535,
67 .step = 65535,
68 .default_value = 0xff,
69 .type = V4L2_CTRL_TYPE_INTEGER,
70 }
71};
72
49#include <asm/io.h> 73#include <asm/io.h>
50#include <asm/uaccess.h> 74#include <asm/uaccess.h>
51 75
@@ -183,91 +207,117 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file,
183 struct gemtek_pci_card *card = dev->priv; 207 struct gemtek_pci_card *card = dev->priv;
184 208
185 switch ( cmd ) { 209 switch ( cmd ) {
186 case VIDIOCGCAP: 210 case VIDIOC_QUERYCAP:
187 { 211 {
188 struct video_capability *c = arg; 212 struct v4l2_capability *v = arg;
213 memset(v,0,sizeof(*v));
214 strlcpy(v->driver, "radio-gemtek-pci", sizeof (v->driver));
215 strlcpy(v->card, "GemTek PCI Radio", sizeof (v->card));
216 sprintf(v->bus_info,"ISA");
217 v->version = RADIO_VERSION;
218 v->capabilities = V4L2_CAP_TUNER;
189 219
190 memset(c,0,sizeof(*c));
191 c->type = VID_TYPE_TUNER;
192 c->channels = 1;
193 c->audios = 1;
194 strcpy( c->name, "Gemtek PCI Radio" );
195 return 0; 220 return 0;
196 } 221 }
197 222 case VIDIOC_G_TUNER:
198 case VIDIOCGTUNER:
199 { 223 {
200 struct video_tuner *t = arg; 224 struct v4l2_tuner *v = arg;
201 225
202 if ( t->tuner ) 226 if (v->index > 0)
203 return -EINVAL; 227 return -EINVAL;
204 228
205 t->rangelow = GEMTEK_PCI_RANGE_LOW; 229 memset(v,0,sizeof(*v));
206 t->rangehigh = GEMTEK_PCI_RANGE_HIGH; 230 strcpy(v->name, "FM");
207 t->flags = VIDEO_TUNER_LOW; 231 v->type = V4L2_TUNER_RADIO;
208 t->mode = VIDEO_MODE_AUTO; 232
209 t->signal = 0xFFFF * gemtek_pci_getsignal( card ); 233 v->rangelow = GEMTEK_PCI_RANGE_LOW;
210 strcpy( t->name, "FM" ); 234 v->rangehigh = GEMTEK_PCI_RANGE_HIGH;
235 v->rxsubchans =V4L2_TUNER_SUB_MONO;
236 v->capability=V4L2_TUNER_CAP_LOW;
237 v->audmode = V4L2_TUNER_MODE_MONO;
238 v->signal=0xFFFF*gemtek_pci_getsignal( card );
239
211 return 0; 240 return 0;
212 } 241 }
213 242 case VIDIOC_S_TUNER:
214 case VIDIOCSTUNER:
215 { 243 {
216 struct video_tuner *t = arg; 244 struct v4l2_tuner *v = arg;
217 if ( t->tuner ) 245
246 if (v->index > 0)
218 return -EINVAL; 247 return -EINVAL;
219 return 0;
220 }
221 248
222 case VIDIOCGFREQ:
223 {
224 unsigned long *freq = arg;
225 *freq = card->current_frequency;
226 return 0; 249 return 0;
227 } 250 }
228 case VIDIOCSFREQ: 251 case VIDIOC_S_FREQUENCY:
229 { 252 {
230 unsigned long *freq = arg; 253 struct v4l2_frequency *f = arg;
231 254
232 if ( (*freq < GEMTEK_PCI_RANGE_LOW) || 255 if ( (f->frequency < GEMTEK_PCI_RANGE_LOW) ||
233 (*freq > GEMTEK_PCI_RANGE_HIGH) ) 256 (f->frequency > GEMTEK_PCI_RANGE_HIGH) )
234 return -EINVAL; 257 return -EINVAL;
235 258
236 gemtek_pci_setfrequency( card, *freq );
237 card->current_frequency = *freq;
238 card->mute = FALSE;
239 259
260 gemtek_pci_setfrequency( card, f->frequency );
261 card->current_frequency = f->frequency;
262 card->mute = FALSE;
240 return 0; 263 return 0;
241 } 264 }
242 265 case VIDIOC_QUERYCTRL:
243 case VIDIOCGAUDIO:
244 { 266 {
245 struct video_audio *a = arg; 267 struct v4l2_queryctrl *qc = arg;
246 268 int i;
247 memset( a, 0, sizeof( *a ) ); 269
248 a->flags |= VIDEO_AUDIO_MUTABLE; 270 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
249 a->volume = 1; 271 if (qc->id && qc->id == radio_qctrl[i].id) {
250 a->step = 65535; 272 memcpy(qc, &(radio_qctrl[i]),
251 strcpy( a->name, "Radio" ); 273 sizeof(*qc));
252 return 0; 274 return (0);
275 }
276 }
277 return -EINVAL;
253 } 278 }
254 279 case VIDIOC_G_CTRL:
255 case VIDIOCSAUDIO:
256 { 280 {
257 struct video_audio *a = arg; 281 struct v4l2_control *ctrl= arg;
258 282
259 if ( a->audio ) 283 switch (ctrl->id) {
260 return -EINVAL; 284 case V4L2_CID_AUDIO_MUTE:
261 285 ctrl->value=card->mute;
262 if ( a->flags & VIDEO_AUDIO_MUTE ) 286 return (0);
263 gemtek_pci_mute( card ); 287 case V4L2_CID_AUDIO_VOLUME:
264 else 288 if (card->mute)
265 gemtek_pci_unmute( card ); 289 ctrl->value=0;
266 return 0; 290 else
291 ctrl->value=65535;
292 return (0);
293 }
294 return -EINVAL;
295 }
296 case VIDIOC_S_CTRL:
297 {
298 struct v4l2_control *ctrl= arg;
299
300 switch (ctrl->id) {
301 case V4L2_CID_AUDIO_MUTE:
302 if (ctrl->value) {
303 gemtek_pci_mute(card);
304 } else {
305 gemtek_pci_unmute(card);
306 }
307 return (0);
308 case V4L2_CID_AUDIO_VOLUME:
309 if (ctrl->value) {
310 gemtek_pci_unmute(card);
311 } else {
312 gemtek_pci_mute(card);
313 }
314 return (0);
315 }
316 return -EINVAL;
267 } 317 }
268
269 default: 318 default:
270 return -ENOIOCTLCMD; 319 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
320 gemtek_pci_do_ioctl);
271 } 321 }
272} 322}
273 323
@@ -309,7 +359,7 @@ static struct video_device vdev_template = {
309 .owner = THIS_MODULE, 359 .owner = THIS_MODULE,
310 .name = "Gemtek PCI Radio", 360 .name = "Gemtek PCI Radio",
311 .type = VID_TYPE_TUNER, 361 .type = VID_TYPE_TUNER,
312 .hardware = VID_HARDWARE_GEMTEK, 362 .hardware = 0,
313 .fops = &gemtek_pci_fops, 363 .fops = &gemtek_pci_fops,
314}; 364};
315 365
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 162f37d8bf96..730fe16126cb 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -13,6 +13,7 @@
13 * 13 *
14 * TODO: Allow for more than one of these foolish entities :-) 14 * TODO: Allow for more than one of these foolish entities :-)
15 * 15 *
16 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
16 */ 17 */
17 18
18#include <linux/module.h> /* Modules */ 19#include <linux/module.h> /* Modules */
@@ -21,11 +22,32 @@
21#include <linux/delay.h> /* udelay */ 22#include <linux/delay.h> /* udelay */
22#include <asm/io.h> /* outb, outb_p */ 23#include <asm/io.h> /* outb, outb_p */
23#include <asm/uaccess.h> /* copy to/from user */ 24#include <asm/uaccess.h> /* copy to/from user */
24#include <linux/videodev.h> /* kernel radio structs */ 25#include <linux/videodev2.h> /* kernel radio structs */
25#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
26#include <linux/config.h> /* CONFIG_RADIO_GEMTEK_PORT */
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28 28
29#include <linux/version.h> /* for KERNEL_VERSION MACRO */
30#define RADIO_VERSION KERNEL_VERSION(0,0,2)
31
32static struct v4l2_queryctrl radio_qctrl[] = {
33 {
34 .id = V4L2_CID_AUDIO_MUTE,
35 .name = "Mute",
36 .minimum = 0,
37 .maximum = 1,
38 .default_value = 1,
39 .type = V4L2_CTRL_TYPE_BOOLEAN,
40 },{
41 .id = V4L2_CID_AUDIO_VOLUME,
42 .name = "Volume",
43 .minimum = 0,
44 .maximum = 65535,
45 .step = 65535,
46 .default_value = 0xff,
47 .type = V4L2_CTRL_TYPE_INTEGER,
48 }
49};
50
29#ifndef CONFIG_RADIO_GEMTEK_PORT 51#ifndef CONFIG_RADIO_GEMTEK_PORT
30#define CONFIG_RADIO_GEMTEK_PORT -1 52#define CONFIG_RADIO_GEMTEK_PORT -1
31#endif 53#endif
@@ -147,77 +169,122 @@ static int gemtek_do_ioctl(struct inode *inode, struct file *file,
147 169
148 switch(cmd) 170 switch(cmd)
149 { 171 {
150 case VIDIOCGCAP: 172 case VIDIOC_QUERYCAP:
151 { 173 {
152 struct video_capability *v = arg; 174 struct v4l2_capability *v = arg;
153 memset(v,0,sizeof(*v)); 175 memset(v,0,sizeof(*v));
154 v->type=VID_TYPE_TUNER; 176 strlcpy(v->driver, "radio-gemtek", sizeof (v->driver));
155 v->channels=1; 177 strlcpy(v->card, "GemTek", sizeof (v->card));
156 v->audios=1; 178 sprintf(v->bus_info,"ISA");
157 strcpy(v->name, "GemTek"); 179 v->version = RADIO_VERSION;
180 v->capabilities = V4L2_CAP_TUNER;
181
158 return 0; 182 return 0;
159 } 183 }
160 case VIDIOCGTUNER: 184 case VIDIOC_G_TUNER:
161 { 185 {
162 struct video_tuner *v = arg; 186 struct v4l2_tuner *v = arg;
163 if(v->tuner) /* Only 1 tuner */ 187
188 if (v->index > 0)
164 return -EINVAL; 189 return -EINVAL;
165 v->rangelow=87*16000; 190
166 v->rangehigh=108*16000; 191 memset(v,0,sizeof(*v));
167 v->flags=VIDEO_TUNER_LOW;
168 v->mode=VIDEO_MODE_AUTO;
169 v->signal=0xFFFF*gemtek_getsigstr(rt);
170 strcpy(v->name, "FM"); 192 strcpy(v->name, "FM");
193 v->type = V4L2_TUNER_RADIO;
194
195 v->rangelow=(87*16000);
196 v->rangehigh=(108*16000);
197 v->rxsubchans =V4L2_TUNER_SUB_MONO;
198 v->capability=V4L2_TUNER_CAP_LOW;
199 v->audmode = V4L2_TUNER_MODE_MONO;
200 v->signal=0xFFFF*gemtek_getsigstr(rt);
201
171 return 0; 202 return 0;
172 } 203 }
173 case VIDIOCSTUNER: 204 case VIDIOC_S_TUNER:
174 { 205 {
175 struct video_tuner *v = arg; 206 struct v4l2_tuner *v = arg;
176 if(v->tuner!=0) 207
208 if (v->index > 0)
177 return -EINVAL; 209 return -EINVAL;
178 /* Only 1 tuner so no setting needed ! */ 210
179 return 0;
180 }
181 case VIDIOCGFREQ:
182 {
183 unsigned long *freq = arg;
184 *freq = rt->curfreq;
185 return 0; 211 return 0;
186 } 212 }
187 case VIDIOCSFREQ: 213 case VIDIOC_S_FREQUENCY:
188 { 214 {
189 unsigned long *freq = arg; 215 struct v4l2_frequency *f = arg;
190 rt->curfreq = *freq; 216
217 rt->curfreq = f->frequency;
191 /* needs to be called twice in order for getsigstr to work */ 218 /* needs to be called twice in order for getsigstr to work */
192 gemtek_setfreq(rt, rt->curfreq); 219 gemtek_setfreq(rt, rt->curfreq);
193 gemtek_setfreq(rt, rt->curfreq); 220 gemtek_setfreq(rt, rt->curfreq);
194 return 0; 221 return 0;
195 } 222 }
196 case VIDIOCGAUDIO: 223 case VIDIOC_G_FREQUENCY:
197 {
198 struct video_audio *v = arg;
199 memset(v,0, sizeof(*v));
200 v->flags|=VIDEO_AUDIO_MUTABLE;
201 v->volume=1;
202 v->step=65535;
203 strcpy(v->name, "Radio");
204 return 0;
205 }
206 case VIDIOCSAUDIO:
207 { 224 {
208 struct video_audio *v = arg; 225 struct v4l2_frequency *f = arg;
209 if(v->audio)
210 return -EINVAL;
211 226
212 if(v->flags&VIDEO_AUDIO_MUTE) 227 f->type = V4L2_TUNER_RADIO;
213 gemtek_mute(rt); 228 f->frequency = rt->curfreq;
214 else
215 gemtek_unmute(rt);
216 229
217 return 0; 230 return 0;
218 } 231 }
232 case VIDIOC_QUERYCTRL:
233 {
234 struct v4l2_queryctrl *qc = arg;
235 int i;
236
237 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
238 if (qc->id && qc->id == radio_qctrl[i].id) {
239 memcpy(qc, &(radio_qctrl[i]),
240 sizeof(*qc));
241 return (0);
242 }
243 }
244 return -EINVAL;
245 }
246 case VIDIOC_G_CTRL:
247 {
248 struct v4l2_control *ctrl= arg;
249
250 switch (ctrl->id) {
251 case V4L2_CID_AUDIO_MUTE:
252 ctrl->value=rt->muted;
253 return (0);
254 case V4L2_CID_AUDIO_VOLUME:
255 if (rt->muted)
256 ctrl->value=0;
257 else
258 ctrl->value=65535;
259 return (0);
260 }
261 return -EINVAL;
262 }
263 case VIDIOC_S_CTRL:
264 {
265 struct v4l2_control *ctrl= arg;
266
267 switch (ctrl->id) {
268 case V4L2_CID_AUDIO_MUTE:
269 if (ctrl->value) {
270 gemtek_mute(rt);
271 } else {
272 gemtek_unmute(rt);
273 }
274 return (0);
275 case V4L2_CID_AUDIO_VOLUME:
276 if (ctrl->value) {
277 gemtek_unmute(rt);
278 } else {
279 gemtek_mute(rt);
280 }
281 return (0);
282 }
283 return -EINVAL;
284 }
219 default: 285 default:
220 return -ENOIOCTLCMD; 286 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
287 gemtek_do_ioctl);
221 } 288 }
222} 289}
223 290
@@ -243,7 +310,7 @@ static struct video_device gemtek_radio=
243 .owner = THIS_MODULE, 310 .owner = THIS_MODULE,
244 .name = "GemTek radio", 311 .name = "GemTek radio",
245 .type = VID_TYPE_TUNER, 312 .type = VID_TYPE_TUNER,
246 .hardware = VID_HARDWARE_GEMTEK, 313 .hardware = 0,
247 .fops = &gemtek_fops, 314 .fops = &gemtek_fops,
248}; 315};
249 316
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index fcfa6c9fe225..e8ce5f75cf12 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -14,6 +14,8 @@
14 * version 0.04 14 * version 0.04
15 * + code improvements 15 * + code improvements
16 * + VIDEO_TUNER_LOW is permanent 16 * + VIDEO_TUNER_LOW is permanent
17 *
18 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
17 */ 19 */
18 20
19#include <linux/module.h> 21#include <linux/module.h>
@@ -25,10 +27,23 @@
25#include <asm/uaccess.h> 27#include <asm/uaccess.h>
26#include <linux/mutex.h> 28#include <linux/mutex.h>
27#include <linux/pci.h> 29#include <linux/pci.h>
28#include <linux/videodev.h> 30#include <linux/videodev2.h>
29#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
30 32
31#define DRIVER_VERSION "0.05" 33#include <linux/version.h> /* for KERNEL_VERSION MACRO */
34#define RADIO_VERSION KERNEL_VERSION(0,0,6)
35#define DRIVER_VERSION "0.06"
36
37static struct v4l2_queryctrl radio_qctrl[] = {
38 {
39 .id = V4L2_CID_AUDIO_MUTE,
40 .name = "Mute",
41 .minimum = 0,
42 .maximum = 1,
43 .default_value = 1,
44 .type = V4L2_CTRL_TYPE_BOOLEAN,
45 }
46};
32 47
33#define GPIO_DATA 0x60 /* port offset from ESS_IO_BASE */ 48#define GPIO_DATA 0x60 /* port offset from ESS_IO_BASE */
34 49
@@ -96,7 +111,7 @@ static struct file_operations maestro_fops = {
96static struct video_device maestro_radio = { 111static struct video_device maestro_radio = {
97 .name = "Maestro radio", 112 .name = "Maestro radio",
98 .type = VID_TYPE_TUNER, 113 .type = VID_TYPE_TUNER,
99 .hardware = VID_HARDWARE_SF16MI, 114 .hardware = 0,
100 .fops = &maestro_fops, 115 .fops = &maestro_fops,
101}; 116};
102 117
@@ -130,7 +145,7 @@ static u32 radio_bits_get(struct radio_device *dev)
130 rdata = inw(io); 145 rdata = inw(io);
131 if(!l) 146 if(!l)
132 dev->stereo = rdata & STR_MOST ? 147 dev->stereo = rdata & STR_MOST ?
133 0 : VIDEO_TUNER_STEREO_ON; 148 0 : 1;
134 else 149 else
135 if(rdata & STR_DATA) 150 if(rdata & STR_DATA)
136 data++; 151 data++;
@@ -183,72 +198,120 @@ static inline int radio_function(struct inode *inode, struct file *file,
183 struct radio_device *card = video_get_drvdata(dev); 198 struct radio_device *card = video_get_drvdata(dev);
184 199
185 switch (cmd) { 200 switch (cmd) {
186 case VIDIOCGCAP: { 201 case VIDIOC_QUERYCAP:
187 struct video_capability *v = arg; 202 {
188 memset(v, 0, sizeof(*v)); 203 struct v4l2_capability *v = arg;
189 strcpy(v->name, "Maestro radio"); 204 memset(v,0,sizeof(*v));
190 v->type = VID_TYPE_TUNER; 205 strlcpy(v->driver, "radio-maestro", sizeof (v->driver));
191 v->channels = v->audios = 1; 206 strlcpy(v->card, "Maestro Radio", sizeof (v->card));
192 return 0; 207 sprintf(v->bus_info,"PCI");
193 } case VIDIOCGTUNER: { 208 v->version = RADIO_VERSION;
194 struct video_tuner *v = arg; 209 v->capabilities = V4L2_CAP_TUNER;
195 if (v->tuner) 210
196 return -EINVAL; 211 return 0;
197 (void)radio_bits_get(card); 212 }
198 v->flags = VIDEO_TUNER_LOW | card->stereo; 213 case VIDIOC_G_TUNER:
199 v->signal = card->tuned; 214 {
200 strcpy(v->name, "FM"); 215 struct v4l2_tuner *v = arg;
201 v->rangelow = FREQ_LO; 216
202 v->rangehigh = FREQ_HI; 217 if (v->index > 0)
203 v->mode = VIDEO_MODE_AUTO; 218 return -EINVAL;
204 return 0; 219
205 } case VIDIOCSTUNER: { 220 (void)radio_bits_get(card);
206 struct video_tuner *v = arg; 221
207 if (v->tuner != 0) 222 memset(v,0,sizeof(*v));
208 return -EINVAL; 223 strcpy(v->name, "FM");
209 return 0; 224 v->type = V4L2_TUNER_RADIO;
210 } case VIDIOCGFREQ: { 225
211 unsigned long *freq = arg; 226 v->rangelow = FREQ_LO;
212 *freq = BITS2FREQ(radio_bits_get(card)); 227 v->rangehigh = FREQ_HI;
213 return 0; 228 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
214 } case VIDIOCSFREQ: { 229 v->capability=V4L2_TUNER_CAP_LOW;
215 unsigned long *freq = arg; 230 if(card->stereo)
216 if (*freq < FREQ_LO || *freq > FREQ_HI) 231 v->audmode = V4L2_TUNER_MODE_STEREO;
232 else
233 v->audmode = V4L2_TUNER_MODE_MONO;
234 v->signal=card->tuned;
235
236 return 0;
237 }
238 case VIDIOC_S_TUNER:
239 {
240 struct v4l2_tuner *v = arg;
241
242 if (v->index > 0)
243 return -EINVAL;
244
245 return 0;
246 }
247 case VIDIOC_S_FREQUENCY:
248 {
249 struct v4l2_frequency *f = arg;
250
251 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
252 return -EINVAL;
253 radio_bits_set(card, FREQ2BITS(f->frequency));
254
255 return 0;
256 }
257 case VIDIOC_G_FREQUENCY:
258 {
259 struct v4l2_frequency *f = arg;
260
261 f->type = V4L2_TUNER_RADIO;
262 f->frequency = BITS2FREQ(radio_bits_get(card));
263
264 return 0;
265 }
266 case VIDIOC_QUERYCTRL:
267 {
268 struct v4l2_queryctrl *qc = arg;
269 int i;
270
271 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
272 if (qc->id && qc->id == radio_qctrl[i].id) {
273 memcpy(qc, &(radio_qctrl[i]),
274 sizeof(*qc));
275 return (0);
276 }
277 }
217 return -EINVAL; 278 return -EINVAL;
218 radio_bits_set(card, FREQ2BITS(*freq)); 279 }
219 return 0; 280 case VIDIOC_G_CTRL:
220 } case VIDIOCGAUDIO: { 281 {
221 struct video_audio *v = arg; 282 struct v4l2_control *ctrl= arg;
222 memset(v, 0, sizeof(*v)); 283
223 strcpy(v->name, "Radio"); 284 switch (ctrl->id) {
224 v->flags = VIDEO_AUDIO_MUTABLE | card->muted; 285 case V4L2_CID_AUDIO_MUTE:
225 v->mode = VIDEO_SOUND_STEREO; 286 ctrl->value=card->muted;
226 return 0; 287 return (0);
227 } case VIDIOCSAUDIO: { 288 }
228 struct video_audio *v = arg;
229 if (v->audio)
230 return -EINVAL; 289 return -EINVAL;
290 }
291 case VIDIOC_S_CTRL:
231 { 292 {
232 register u16 io = card->io; 293 struct v4l2_control *ctrl= arg;
233 register u16 omask = inw(io + IO_MASK); 294
234 outw(~STR_WREN, io + IO_MASK); 295 switch (ctrl->id) {
235 outw((card->muted = v->flags & VIDEO_AUDIO_MUTE) ? 296 case V4L2_CID_AUDIO_MUTE:
236 STR_WREN : 0, io); 297 {
237 udelay(4); 298 register u16 io = card->io;
238 outw(omask, io + IO_MASK); 299 register u16 omask = inw(io + IO_MASK);
239 msleep(125); 300 outw(~STR_WREN, io + IO_MASK);
240 return 0; 301 outw((card->muted = ctrl->value ) ?
302 STR_WREN : 0, io);
303 udelay(4);
304 outw(omask, io + IO_MASK);
305 msleep(125);
306
307 return (0);
308 }
309 }
310 return -EINVAL;
241 } 311 }
242 } case VIDIOCGUNIT: { 312 default:
243 struct video_unit *v = arg; 313 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
244 v->video = VIDEO_NO_UNIT; 314 radio_function);
245 v->vbi = VIDEO_NO_UNIT;
246 v->radio = dev->minor;
247 v->audio = 0;
248 v->teletext = VIDEO_NO_UNIT;
249 return 0;
250 } default:
251 return -ENOIOCTLCMD;
252 } 315 }
253} 316}
254 317
@@ -275,7 +338,7 @@ static u16 __devinit radio_power_on(struct radio_device *dev)
275 omask = inw(io + IO_MASK); 338 omask = inw(io + IO_MASK);
276 odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN); 339 odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN);
277 outw(odir & ~STR_WREN, io + IO_DIR); 340 outw(odir & ~STR_WREN, io + IO_DIR);
278 dev->muted = inw(io) & STR_WREN ? 0 : VIDEO_AUDIO_MUTE; 341 dev->muted = inw(io) & STR_WREN ? 0 : 1;
279 outw(odir, io + IO_DIR); 342 outw(odir, io + IO_DIR);
280 outw(~(STR_WREN | STR_CLK), io + IO_MASK); 343 outw(~(STR_WREN | STR_CLK), io + IO_MASK);
281 outw(dev->muted ? 0 : STR_WREN, io); 344 outw(dev->muted ? 0 : STR_WREN, io);
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index f93d7afe7304..c2eeae7a10d0 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -20,13 +20,14 @@
20 * 0.75b 20 * 0.75b
21 * - better pci interface thanks to Francois Romieu <romieu@cogenit.fr> 21 * - better pci interface thanks to Francois Romieu <romieu@cogenit.fr>
22 * 22 *
23 * 0.75 23 * 0.75 Sun Feb 4 22:51:27 EET 2001
24 * - tiding up 24 * - tiding up
25 * - removed support for multiple devices as it didn't work anyway 25 * - removed support for multiple devices as it didn't work anyway
26 * 26 *
27 * BUGS: 27 * BUGS:
28 * - card unmutes if you change frequency 28 * - card unmutes if you change frequency
29 * 29 *
30 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
30 */ 31 */
31 32
32 33
@@ -40,11 +41,24 @@
40#include <linux/mutex.h> 41#include <linux/mutex.h>
41 42
42#include <linux/pci.h> 43#include <linux/pci.h>
43#include <linux/videodev.h> 44#include <linux/videodev2.h>
44#include <media/v4l2-common.h> 45#include <media/v4l2-common.h>
45 46
46/* version 0.75 Sun Feb 4 22:51:27 EET 2001 */ 47#define DRIVER_VERSION "0.76"
47#define DRIVER_VERSION "0.75" 48
49#include <linux/version.h> /* for KERNEL_VERSION MACRO */
50#define RADIO_VERSION KERNEL_VERSION(0,7,6)
51
52static struct v4l2_queryctrl radio_qctrl[] = {
53 {
54 .id = V4L2_CID_AUDIO_MUTE,
55 .name = "Mute",
56 .minimum = 0,
57 .maximum = 1,
58 .default_value = 1,
59 .type = V4L2_CTRL_TYPE_BOOLEAN,
60 }
61};
48 62
49#ifndef PCI_VENDOR_ID_GUILLEMOT 63#ifndef PCI_VENDOR_ID_GUILLEMOT
50#define PCI_VENDOR_ID_GUILLEMOT 0x5046 64#define PCI_VENDOR_ID_GUILLEMOT 0x5046
@@ -90,7 +104,6 @@ static struct video_device maxiradio_radio =
90 .owner = THIS_MODULE, 104 .owner = THIS_MODULE,
91 .name = "Maxi Radio FM2000 radio", 105 .name = "Maxi Radio FM2000 radio",
92 .type = VID_TYPE_TUNER, 106 .type = VID_TYPE_TUNER,
93 .hardware = VID_HARDWARE_SF16MI,
94 .fops = &maxiradio_fops, 107 .fops = &maxiradio_fops,
95}; 108};
96 109
@@ -176,89 +189,116 @@ static inline int radio_function(struct inode *inode, struct file *file,
176 struct radio_device *card=dev->priv; 189 struct radio_device *card=dev->priv;
177 190
178 switch(cmd) { 191 switch(cmd) {
179 case VIDIOCGCAP: { 192 case VIDIOC_QUERYCAP:
180 struct video_capability *v = arg; 193 {
181 194 struct v4l2_capability *v = arg;
182 memset(v,0,sizeof(*v)); 195 memset(v,0,sizeof(*v));
183 strcpy(v->name, "Maxi Radio FM2000 radio"); 196 strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver));
184 v->type=VID_TYPE_TUNER; 197 strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card));
185 v->channels=v->audios=1; 198 sprintf(v->bus_info,"ISA");
199 v->version = RADIO_VERSION;
200 v->capabilities = V4L2_CAP_TUNER;
201
186 return 0; 202 return 0;
187 } 203 }
188 case VIDIOCGTUNER: { 204 case VIDIOC_G_TUNER:
189 struct video_tuner *v = arg; 205 {
206 struct v4l2_tuner *v = arg;
190 207
191 if(v->tuner) 208 if (v->index > 0)
192 return -EINVAL; 209 return -EINVAL;
193 210
194 card->stereo = 0xffff * get_stereo(card->io); 211 memset(v,0,sizeof(*v));
195 card->tuned = 0xffff * get_tune(card->io);
196
197 v->flags = VIDEO_TUNER_LOW | card->stereo;
198 v->signal = card->tuned;
199
200 strcpy(v->name, "FM"); 212 strcpy(v->name, "FM");
201 213 v->type = V4L2_TUNER_RADIO;
202 v->rangelow = FREQ_LO; 214
203 v->rangehigh = FREQ_HI; 215 v->rangelow=FREQ_LO;
204 v->mode = VIDEO_MODE_AUTO; 216 v->rangehigh=FREQ_HI;
217 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
218 v->capability=V4L2_TUNER_CAP_LOW;
219 if(get_stereo(card->io))
220 v->audmode = V4L2_TUNER_MODE_STEREO;
221 else
222 v->audmode = V4L2_TUNER_MODE_MONO;
223 v->signal=0xffff*get_tune(card->io);
205 224
206 return 0; 225 return 0;
207 } 226 }
208 case VIDIOCSTUNER: { 227 case VIDIOC_S_TUNER:
209 struct video_tuner *v = arg; 228 {
210 if(v->tuner!=0) 229 struct v4l2_tuner *v = arg;
230
231 if (v->index > 0)
211 return -EINVAL; 232 return -EINVAL;
212 return 0;
213 }
214 case VIDIOCGFREQ: {
215 unsigned long *freq = arg;
216 233
217 *freq = card->freq;
218 return 0; 234 return 0;
219 } 235 }
220 case VIDIOCSFREQ: { 236 case VIDIOC_S_FREQUENCY:
221 unsigned long *freq = arg; 237 {
238 struct v4l2_frequency *f = arg;
222 239
223 if (*freq < FREQ_LO || *freq > FREQ_HI) 240 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
224 return -EINVAL; 241 return -EINVAL;
225 card->freq = *freq; 242
243 card->freq = f->frequency;
226 set_freq(card->io, FREQ2BITS(card->freq)); 244 set_freq(card->io, FREQ2BITS(card->freq));
227 msleep(125); 245 msleep(125);
228 return 0; 246 return 0;
229 } 247 }
230 case VIDIOCGAUDIO: { 248 case VIDIOC_G_FREQUENCY:
231 struct video_audio *v = arg; 249 {
232 memset(v,0,sizeof(*v)); 250 struct v4l2_frequency *f = arg;
233 strcpy(v->name, "Radio");
234 v->flags=VIDEO_AUDIO_MUTABLE | card->muted;
235 v->mode=VIDEO_SOUND_STEREO;
236 return 0;
237 }
238 251
239 case VIDIOCSAUDIO: { 252 f->type = V4L2_TUNER_RADIO;
240 struct video_audio *v = arg; 253 f->frequency = card->freq;
241 254
242 if(v->audio)
243 return -EINVAL;
244 card->muted = v->flags & VIDEO_AUDIO_MUTE;
245 if(card->muted)
246 turn_power(card->io, 0);
247 else
248 set_freq(card->io, FREQ2BITS(card->freq));
249 return 0; 255 return 0;
250 } 256 }
251 case VIDIOCGUNIT: { 257 case VIDIOC_QUERYCTRL:
252 struct video_unit *v = arg; 258 {
253 259 struct v4l2_queryctrl *qc = arg;
254 v->video=VIDEO_NO_UNIT; 260 int i;
255 v->vbi=VIDEO_NO_UNIT; 261
256 v->radio=dev->minor; 262 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
257 v->audio=0; 263 if (qc->id && qc->id == radio_qctrl[i].id) {
258 v->teletext=VIDEO_NO_UNIT; 264 memcpy(qc, &(radio_qctrl[i]),
259 return 0; 265 sizeof(*qc));
266 return (0);
267 }
268 }
269 return -EINVAL;
270 }
271 case VIDIOC_G_CTRL:
272 {
273 struct v4l2_control *ctrl= arg;
274
275 switch (ctrl->id) {
276 case V4L2_CID_AUDIO_MUTE:
277 ctrl->value=card->muted;
278 return (0);
279 }
280 return -EINVAL;
260 } 281 }
261 default: return -ENOIOCTLCMD; 282 case VIDIOC_S_CTRL:
283 {
284 struct v4l2_control *ctrl= arg;
285
286 switch (ctrl->id) {
287 case V4L2_CID_AUDIO_MUTE:
288 card->muted = ctrl->value;
289 if(card->muted)
290 turn_power(card->io, 0);
291 else
292 set_freq(card->io, FREQ2BITS(card->freq));
293 return 0;
294 }
295 return -EINVAL;
296 }
297
298 default:
299 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
300 radio_function);
301
262 } 302 }
263} 303}
264 304
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index 5b68ac4c7322..b9e98483e58d 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -6,6 +6,7 @@
6 * 6 *
7 * TODO: Allow for more than one of these foolish entities :-) 7 * TODO: Allow for more than one of these foolish entities :-)
8 * 8 *
9 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
9 */ 10 */
10 11
11#include <linux/module.h> /* Modules */ 12#include <linux/module.h> /* Modules */
@@ -14,11 +15,32 @@
14#include <linux/delay.h> /* udelay */ 15#include <linux/delay.h> /* udelay */
15#include <asm/io.h> /* outb, outb_p */ 16#include <asm/io.h> /* outb, outb_p */
16#include <asm/uaccess.h> /* copy to/from user */ 17#include <asm/uaccess.h> /* copy to/from user */
17#include <linux/videodev.h> /* kernel radio structs */ 18#include <linux/videodev2.h> /* kernel radio structs */
18#include <media/v4l2-common.h> 19#include <media/v4l2-common.h>
19#include <linux/config.h> /* CONFIG_RADIO_RTRACK2_PORT */
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21 21
22#include <linux/version.h> /* for KERNEL_VERSION MACRO */
23#define RADIO_VERSION KERNEL_VERSION(0,0,2)
24
25static struct v4l2_queryctrl radio_qctrl[] = {
26 {
27 .id = V4L2_CID_AUDIO_MUTE,
28 .name = "Mute",
29 .minimum = 0,
30 .maximum = 1,
31 .default_value = 1,
32 .type = V4L2_CTRL_TYPE_BOOLEAN,
33 },{
34 .id = V4L2_CID_AUDIO_VOLUME,
35 .name = "Volume",
36 .minimum = 0,
37 .maximum = 65535,
38 .step = 65535,
39 .default_value = 0xff,
40 .type = V4L2_CTRL_TYPE_INTEGER,
41 }
42};
43
22#ifndef CONFIG_RADIO_RTRACK2_PORT 44#ifndef CONFIG_RADIO_RTRACK2_PORT
23#define CONFIG_RADIO_RTRACK2_PORT -1 45#define CONFIG_RADIO_RTRACK2_PORT -1
24#endif 46#endif
@@ -115,75 +137,120 @@ static int rt_do_ioctl(struct inode *inode, struct file *file,
115 137
116 switch(cmd) 138 switch(cmd)
117 { 139 {
118 case VIDIOCGCAP: 140 case VIDIOC_QUERYCAP:
119 { 141 {
120 struct video_capability *v = arg; 142 struct v4l2_capability *v = arg;
121 memset(v,0,sizeof(*v)); 143 memset(v,0,sizeof(*v));
122 v->type=VID_TYPE_TUNER; 144 strlcpy(v->driver, "radio-rtrack2", sizeof (v->driver));
123 v->channels=1; 145 strlcpy(v->card, "RadioTrack II", sizeof (v->card));
124 v->audios=1; 146 sprintf(v->bus_info,"ISA");
125 strcpy(v->name, "RadioTrack II"); 147 v->version = RADIO_VERSION;
148 v->capabilities = V4L2_CAP_TUNER;
149
126 return 0; 150 return 0;
127 } 151 }
128 case VIDIOCGTUNER: 152 case VIDIOC_G_TUNER:
129 { 153 {
130 struct video_tuner *v = arg; 154 struct v4l2_tuner *v = arg;
131 if(v->tuner) /* Only 1 tuner */ 155
156 if (v->index > 0)
132 return -EINVAL; 157 return -EINVAL;
133 v->rangelow=88*16000; 158
134 v->rangehigh=108*16000; 159 memset(v,0,sizeof(*v));
135 v->flags=VIDEO_TUNER_LOW;
136 v->mode=VIDEO_MODE_AUTO;
137 v->signal=0xFFFF*rt_getsigstr(rt);
138 strcpy(v->name, "FM"); 160 strcpy(v->name, "FM");
161 v->type = V4L2_TUNER_RADIO;
162
163 v->rangelow=(88*16000);
164 v->rangehigh=(108*16000);
165 v->rxsubchans =V4L2_TUNER_SUB_MONO;
166 v->capability=V4L2_TUNER_CAP_LOW;
167 v->audmode = V4L2_TUNER_MODE_MONO;
168 v->signal=0xFFFF*rt_getsigstr(rt);
169
139 return 0; 170 return 0;
140 } 171 }
141 case VIDIOCSTUNER: 172 case VIDIOC_S_TUNER:
142 { 173 {
143 struct video_tuner *v = arg; 174 struct v4l2_tuner *v = arg;
144 if(v->tuner!=0) 175
176 if (v->index > 0)
145 return -EINVAL; 177 return -EINVAL;
146 /* Only 1 tuner so no setting needed ! */ 178
147 return 0; 179 return 0;
148 } 180 }
149 case VIDIOCGFREQ: 181 case VIDIOC_S_FREQUENCY:
150 { 182 {
151 unsigned long *freq = arg; 183 struct v4l2_frequency *f = arg;
152 *freq = rt->curfreq; 184
185 rt->curfreq = f->frequency;
186 rt_setfreq(rt, rt->curfreq);
153 return 0; 187 return 0;
154 } 188 }
155 case VIDIOCSFREQ: 189 case VIDIOC_G_FREQUENCY:
156 { 190 {
157 unsigned long *freq = arg; 191 struct v4l2_frequency *f = arg;
158 rt->curfreq = *freq; 192
159 rt_setfreq(rt, rt->curfreq); 193 f->type = V4L2_TUNER_RADIO;
194 f->frequency = rt->curfreq;
195
160 return 0; 196 return 0;
161 } 197 }
162 case VIDIOCGAUDIO: 198 case VIDIOC_QUERYCTRL:
163 { 199 {
164 struct video_audio *v = arg; 200 struct v4l2_queryctrl *qc = arg;
165 memset(v,0, sizeof(*v)); 201 int i;
166 v->flags|=VIDEO_AUDIO_MUTABLE; 202
167 v->volume=1; 203 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
168 v->step=65535; 204 if (qc->id && qc->id == radio_qctrl[i].id) {
169 strcpy(v->name, "Radio"); 205 memcpy(qc, &(radio_qctrl[i]),
170 return 0; 206 sizeof(*qc));
207 return (0);
208 }
209 }
210 return -EINVAL;
171 } 211 }
172 case VIDIOCSAUDIO: 212 case VIDIOC_G_CTRL:
173 { 213 {
174 struct video_audio *v = arg; 214 struct v4l2_control *ctrl= arg;
175 if(v->audio) 215
176 return -EINVAL; 216 switch (ctrl->id) {
177 217 case V4L2_CID_AUDIO_MUTE:
178 if(v->flags&VIDEO_AUDIO_MUTE) 218 ctrl->value=rt->muted;
179 rt_mute(rt); 219 return (0);
180 else 220 case V4L2_CID_AUDIO_VOLUME:
181 rt_unmute(rt); 221 if (rt->muted)
182 222 ctrl->value=0;
183 return 0; 223 else
224 ctrl->value=65535;
225 return (0);
226 }
227 return -EINVAL;
228 }
229 case VIDIOC_S_CTRL:
230 {
231 struct v4l2_control *ctrl= arg;
232
233 switch (ctrl->id) {
234 case V4L2_CID_AUDIO_MUTE:
235 if (ctrl->value) {
236 rt_mute(rt);
237 } else {
238 rt_unmute(rt);
239 }
240 return (0);
241 case V4L2_CID_AUDIO_VOLUME:
242 if (ctrl->value) {
243 rt_unmute(rt);
244 } else {
245 rt_mute(rt);
246 }
247 return (0);
248 }
249 return -EINVAL;
184 } 250 }
185 default: 251 default:
186 return -ENOIOCTLCMD; 252 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
253 rt_do_ioctl);
187 } 254 }
188} 255}
189 256
@@ -209,7 +276,7 @@ static struct video_device rtrack2_radio=
209 .owner = THIS_MODULE, 276 .owner = THIS_MODULE,
210 .name = "RadioTrack II radio", 277 .name = "RadioTrack II radio",
211 .type = VID_TYPE_TUNER, 278 .type = VID_TYPE_TUNER,
212 .hardware = VID_HARDWARE_RTRACK2, 279 .hardware = 0,
213 .fops = &rtrack2_fops, 280 .fops = &rtrack2_fops,
214}; 281};
215 282
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index efee6e339d15..ecc854b4ba38 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -13,20 +13,35 @@
13 * No volume control - only mute/unmute - you have to use line volume 13 * No volume control - only mute/unmute - you have to use line volume
14 * control on SB-part of SF16FMI 14 * control on SB-part of SF16FMI
15 * 15 *
16 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
16 */ 17 */
17 18
19#include <linux/version.h>
18#include <linux/kernel.h> /* __setup */ 20#include <linux/kernel.h> /* __setup */
19#include <linux/module.h> /* Modules */ 21#include <linux/module.h> /* Modules */
20#include <linux/init.h> /* Initdata */ 22#include <linux/init.h> /* Initdata */
21#include <linux/ioport.h> /* request_region */ 23#include <linux/ioport.h> /* request_region */
22#include <linux/delay.h> /* udelay */ 24#include <linux/delay.h> /* udelay */
23#include <linux/videodev.h> /* kernel radio structs */ 25#include <linux/videodev2.h> /* kernel radio structs */
24#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
25#include <linux/isapnp.h> 27#include <linux/isapnp.h>
26#include <asm/io.h> /* outb, outb_p */ 28#include <asm/io.h> /* outb, outb_p */
27#include <asm/uaccess.h> /* copy to/from user */ 29#include <asm/uaccess.h> /* copy to/from user */
28#include <linux/mutex.h> 30#include <linux/mutex.h>
29 31
32#define RADIO_VERSION KERNEL_VERSION(0,0,2)
33
34static struct v4l2_queryctrl radio_qctrl[] = {
35 {
36 .id = V4L2_CID_AUDIO_MUTE,
37 .name = "Mute",
38 .minimum = 0,
39 .maximum = 1,
40 .default_value = 1,
41 .type = V4L2_CTRL_TYPE_BOOLEAN,
42 }
43};
44
30struct fmi_device 45struct fmi_device
31{ 46{
32 int port; 47 int port;
@@ -123,93 +138,122 @@ static int fmi_do_ioctl(struct inode *inode, struct file *file,
123 138
124 switch(cmd) 139 switch(cmd)
125 { 140 {
126 case VIDIOCGCAP: 141 case VIDIOC_QUERYCAP:
127 { 142 {
128 struct video_capability *v = arg; 143 struct v4l2_capability *v = arg;
129 memset(v,0,sizeof(*v)); 144 memset(v,0,sizeof(*v));
130 strcpy(v->name, "SF16-FMx radio"); 145 strlcpy(v->driver, "radio-sf16fmi", sizeof (v->driver));
131 v->type=VID_TYPE_TUNER; 146 strlcpy(v->card, "SF16-FMx radio", sizeof (v->card));
132 v->channels=1; 147 sprintf(v->bus_info,"ISA");
133 v->audios=1; 148 v->version = RADIO_VERSION;
149 v->capabilities = V4L2_CAP_TUNER;
150
134 return 0; 151 return 0;
135 } 152 }
136 case VIDIOCGTUNER: 153 case VIDIOC_G_TUNER:
137 { 154 {
138 struct video_tuner *v = arg; 155 struct v4l2_tuner *v = arg;
139 int mult; 156 int mult;
140 157
141 if(v->tuner) /* Only 1 tuner */ 158 if (v->index > 0)
142 return -EINVAL; 159 return -EINVAL;
160
161 memset(v,0,sizeof(*v));
143 strcpy(v->name, "FM"); 162 strcpy(v->name, "FM");
144 mult = (fmi->flags & VIDEO_TUNER_LOW) ? 1 : 1000; 163 v->type = V4L2_TUNER_RADIO;
164
165 mult = (fmi->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
145 v->rangelow = RSF16_MINFREQ/mult; 166 v->rangelow = RSF16_MINFREQ/mult;
146 v->rangehigh = RSF16_MAXFREQ/mult; 167 v->rangehigh = RSF16_MAXFREQ/mult;
147 v->flags=fmi->flags; 168 v->rxsubchans =V4L2_TUNER_SUB_MONO | V4L2_TUNER_MODE_STEREO;
148 v->mode=VIDEO_MODE_AUTO; 169 v->capability=fmi->flags&V4L2_TUNER_CAP_LOW;
170 v->audmode = V4L2_TUNER_MODE_STEREO;
149 v->signal = fmi_getsigstr(fmi); 171 v->signal = fmi_getsigstr(fmi);
172
150 return 0; 173 return 0;
151 } 174 }
152 case VIDIOCSTUNER: 175 case VIDIOC_S_TUNER:
153 { 176 {
154 struct video_tuner *v = arg; 177 struct v4l2_tuner *v = arg;
155 if(v->tuner!=0) 178
179 if (v->index > 0)
156 return -EINVAL; 180 return -EINVAL;
157 fmi->flags = v->flags & VIDEO_TUNER_LOW; 181
158 /* Only 1 tuner so no setting needed ! */
159 return 0;
160 }
161 case VIDIOCGFREQ:
162 {
163 unsigned long *freq = arg;
164 *freq = fmi->curfreq;
165 if (!(fmi->flags & VIDEO_TUNER_LOW))
166 *freq /= 1000;
167 return 0; 182 return 0;
168 } 183 }
169 case VIDIOCSFREQ: 184 case VIDIOC_S_FREQUENCY:
170 { 185 {
171 unsigned long *freq = arg; 186 struct v4l2_frequency *f = arg;
172 if (!(fmi->flags & VIDEO_TUNER_LOW)) 187
173 *freq *= 1000; 188 if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
174 if (*freq < RSF16_MINFREQ || *freq > RSF16_MAXFREQ ) 189 f->frequency *= 1000;
190 if (f->frequency < RSF16_MINFREQ ||
191 f->frequency > RSF16_MAXFREQ )
175 return -EINVAL; 192 return -EINVAL;
176 /*rounding in steps of 800 to match th freq 193 /*rounding in steps of 800 to match th freq
177 that will be used */ 194 that will be used */
178 fmi->curfreq = (*freq/800)*800; 195 fmi->curfreq = (f->frequency/800)*800;
179 fmi_setfreq(fmi); 196 fmi_setfreq(fmi);
197
180 return 0; 198 return 0;
181 } 199 }
182 case VIDIOCGAUDIO: 200 case VIDIOC_G_FREQUENCY:
183 { 201 {
184 struct video_audio *v = arg; 202 struct v4l2_frequency *f = arg;
185 memset(v,0,sizeof(*v)); 203
186 v->flags=( (!fmi->curvol)*VIDEO_AUDIO_MUTE | VIDEO_AUDIO_MUTABLE); 204 f->type = V4L2_TUNER_RADIO;
187 strcpy(v->name, "Radio"); 205 f->frequency = fmi->curfreq;
188 v->mode=VIDEO_SOUND_STEREO; 206 if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
207 f->frequency /= 1000;
208
189 return 0; 209 return 0;
190 } 210 }
191 case VIDIOCSAUDIO: 211 case VIDIOC_QUERYCTRL:
192 { 212 {
193 struct video_audio *v = arg; 213 struct v4l2_queryctrl *qc = arg;
194 if(v->audio) 214 int i;
195 return -EINVAL; 215
196 fmi->curvol= v->flags&VIDEO_AUDIO_MUTE ? 0 : 1; 216 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
197 fmi->curvol ? 217 if (qc->id && qc->id == radio_qctrl[i].id) {
198 fmi_unmute(fmi->port) : fmi_mute(fmi->port); 218 memcpy(qc, &(radio_qctrl[i]),
199 return 0; 219 sizeof(*qc));
220 return (0);
221 }
222 }
223 return -EINVAL;
200 } 224 }
201 case VIDIOCGUNIT: 225 case VIDIOC_G_CTRL:
202 { 226 {
203 struct video_unit *v = arg; 227 struct v4l2_control *ctrl= arg;
204 v->video=VIDEO_NO_UNIT; 228
205 v->vbi=VIDEO_NO_UNIT; 229 switch (ctrl->id) {
206 v->radio=dev->minor; 230 case V4L2_CID_AUDIO_MUTE:
207 v->audio=0; /* How do we find out this??? */ 231 ctrl->value=fmi->curvol;
208 v->teletext=VIDEO_NO_UNIT; 232 return (0);
209 return 0; 233 }
234 return -EINVAL;
235 }
236 case VIDIOC_S_CTRL:
237 {
238 struct v4l2_control *ctrl= arg;
239
240 switch (ctrl->id) {
241 case V4L2_CID_AUDIO_MUTE:
242 {
243 if (ctrl->value)
244 fmi_mute(fmi->port);
245 else
246 fmi_unmute(fmi->port);
247
248 fmi->curvol=ctrl->value;
249 return (0);
250 }
251 }
252 return -EINVAL;
210 } 253 }
211 default: 254 default:
212 return -ENOIOCTLCMD; 255 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
256 fmi_do_ioctl);
213 } 257 }
214} 258}
215 259
@@ -235,7 +279,7 @@ static struct video_device fmi_radio=
235 .owner = THIS_MODULE, 279 .owner = THIS_MODULE,
236 .name = "SF16FMx radio", 280 .name = "SF16FMx radio",
237 .type = VID_TYPE_TUNER, 281 .type = VID_TYPE_TUNER,
238 .hardware = VID_HARDWARE_SF16MI, 282 .hardware = 0,
239 .fops = &fmi_fops, 283 .fops = &fmi_fops,
240}; 284};
241 285
@@ -294,7 +338,7 @@ static int __init fmi_init(void)
294 fmi_unit.port = io; 338 fmi_unit.port = io;
295 fmi_unit.curvol = 0; 339 fmi_unit.curvol = 0;
296 fmi_unit.curfreq = 0; 340 fmi_unit.curfreq = 0;
297 fmi_unit.flags = VIDEO_TUNER_LOW; 341 fmi_unit.flags = V4L2_TUNER_CAP_LOW;
298 fmi_radio.priv = &fmi_unit; 342 fmi_radio.priv = &fmi_unit;
299 343
300 mutex_init(&lock); 344 mutex_init(&lock);
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 3483b2c7bc9d..4444dce864a9 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -10,6 +10,8 @@
10 * For read stereo/mono you must wait 0.1 sec after set frequency and 10 * For read stereo/mono you must wait 0.1 sec after set frequency and
11 * card unmuted so I set frequency on unmute 11 * card unmuted so I set frequency on unmute
12 * Signal handling seem to work only on autoscanning (not implemented) 12 * Signal handling seem to work only on autoscanning (not implemented)
13 *
14 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
13 */ 15 */
14 16
15#include <linux/module.h> /* Modules */ 17#include <linux/module.h> /* Modules */
@@ -18,12 +20,34 @@
18#include <linux/delay.h> /* udelay */ 20#include <linux/delay.h> /* udelay */
19#include <asm/io.h> /* outb, outb_p */ 21#include <asm/io.h> /* outb, outb_p */
20#include <asm/uaccess.h> /* copy to/from user */ 22#include <asm/uaccess.h> /* copy to/from user */
21#include <linux/videodev.h> /* kernel radio structs */ 23#include <linux/videodev2.h> /* kernel radio structs */
22#include <media/v4l2-common.h> 24#include <media/v4l2-common.h>
23#include <linux/mutex.h> 25#include <linux/mutex.h>
24 26
25static struct mutex lock; 27static struct mutex lock;
26 28
29#include <linux/version.h> /* for KERNEL_VERSION MACRO */
30#define RADIO_VERSION KERNEL_VERSION(0,0,2)
31
32static struct v4l2_queryctrl radio_qctrl[] = {
33 {
34 .id = V4L2_CID_AUDIO_MUTE,
35 .name = "Mute",
36 .minimum = 0,
37 .maximum = 1,
38 .default_value = 1,
39 .type = V4L2_CTRL_TYPE_BOOLEAN,
40 },{
41 .id = V4L2_CID_AUDIO_VOLUME,
42 .name = "Volume",
43 .minimum = 0,
44 .maximum = 65535,
45 .step = 1<<12,
46 .default_value = 0xff,
47 .type = V4L2_CTRL_TYPE_INTEGER,
48 }
49};
50
27#undef DEBUG 51#undef DEBUG
28//#define DEBUG 1 52//#define DEBUG 1
29 53
@@ -214,63 +238,65 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
214 238
215 switch(cmd) 239 switch(cmd)
216 { 240 {
217 case VIDIOCGCAP: 241 case VIDIOC_QUERYCAP:
218 { 242 {
219 struct video_capability *v = arg; 243 struct v4l2_capability *v = arg;
220 memset(v,0,sizeof(*v)); 244 memset(v,0,sizeof(*v));
221 strcpy(v->name, "SF16-FMR2 radio"); 245 strlcpy(v->driver, "radio-sf16fmr2", sizeof (v->driver));
222 v->type=VID_TYPE_TUNER; 246 strlcpy(v->card, "SF16-FMR2 radio", sizeof (v->card));
223 v->channels=1; 247 sprintf(v->bus_info,"ISA");
224 v->audios=1; 248 v->version = RADIO_VERSION;
249 v->capabilities = V4L2_CAP_TUNER;
250
225 return 0; 251 return 0;
226 } 252 }
227 case VIDIOCGTUNER: 253 case VIDIOC_G_TUNER:
228 { 254 {
229 struct video_tuner *v = arg; 255 struct v4l2_tuner *v = arg;
230 int mult; 256 int mult;
231 257
232 if(v->tuner) /* Only 1 tuner */ 258 if (v->index > 0)
233 return -EINVAL; 259 return -EINVAL;
260
261 memset(v,0,sizeof(*v));
234 strcpy(v->name, "FM"); 262 strcpy(v->name, "FM");
235 mult = (fmr2->flags & VIDEO_TUNER_LOW) ? 1 : 1000; 263 v->type = V4L2_TUNER_RADIO;
264
265 mult = (fmr2->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
236 v->rangelow = RSF16_MINFREQ/mult; 266 v->rangelow = RSF16_MINFREQ/mult;
237 v->rangehigh = RSF16_MAXFREQ/mult; 267 v->rangehigh = RSF16_MAXFREQ/mult;
238 v->flags = fmr2->flags | VIDEO_AUDIO_MUTABLE; 268 v->rxsubchans =V4L2_TUNER_SUB_MONO | V4L2_TUNER_MODE_STEREO;
239 if (fmr2->mute) 269 v->capability=fmr2->flags&V4L2_TUNER_CAP_LOW;
240 v->flags |= VIDEO_AUDIO_MUTE; 270
241 v->mode=VIDEO_MODE_AUTO; 271 v->audmode = fmr2->stereo ? V4L2_TUNER_MODE_STEREO:
272 V4L2_TUNER_MODE_MONO;
242 mutex_lock(&lock); 273 mutex_lock(&lock);
243 v->signal = fmr2_getsigstr(fmr2); 274 v->signal = fmr2_getsigstr(fmr2);
244 mutex_unlock(&lock); 275 mutex_unlock(&lock);
276
245 return 0; 277 return 0;
246 } 278 }
247 case VIDIOCSTUNER: 279 case VIDIOC_S_TUNER:
248 { 280 {
249 struct video_tuner *v = arg; 281 struct v4l2_tuner *v = arg;
250 if (v->tuner!=0) 282
283 if (v->index > 0)
251 return -EINVAL; 284 return -EINVAL;
252 fmr2->flags = v->flags & VIDEO_TUNER_LOW; 285
253 return 0;
254 }
255 case VIDIOCGFREQ:
256 {
257 unsigned long *freq = arg;
258 *freq = fmr2->curfreq;
259 if (!(fmr2->flags & VIDEO_TUNER_LOW))
260 *freq /= 1000;
261 return 0; 286 return 0;
262 } 287 }
263 case VIDIOCSFREQ: 288 case VIDIOC_S_FREQUENCY:
264 { 289 {
265 unsigned long *freq = arg; 290 struct v4l2_frequency *f = arg;
266 if (!(fmr2->flags & VIDEO_TUNER_LOW)) 291
267 *freq *= 1000; 292 if (!(fmr2->flags & V4L2_TUNER_CAP_LOW))
268 if ( *freq < RSF16_MINFREQ || *freq > RSF16_MAXFREQ ) 293 f->frequency *= 1000;
294 if (f->frequency < RSF16_MINFREQ ||
295 f->frequency > RSF16_MAXFREQ )
269 return -EINVAL; 296 return -EINVAL;
270 /* rounding in steps of 200 to match th freq 297 /*rounding in steps of 200 to match th freq
271 * that will be used 298 that will be used */
272 */ 299 fmr2->curfreq = (f->frequency/200)*200;
273 fmr2->curfreq = (*freq/200)*200;
274 300
275 /* set card freq (if not muted) */ 301 /* set card freq (if not muted) */
276 if (fmr2->curvol && !fmr2->mute) 302 if (fmr2->curvol && !fmr2->mute)
@@ -279,40 +305,81 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
279 fmr2_setfreq(fmr2); 305 fmr2_setfreq(fmr2);
280 mutex_unlock(&lock); 306 mutex_unlock(&lock);
281 } 307 }
308
282 return 0; 309 return 0;
283 } 310 }
284 case VIDIOCGAUDIO: 311 case VIDIOC_G_FREQUENCY:
285 { 312 {
286 struct video_audio *v = arg; 313 struct v4l2_frequency *f = arg;
287 memset(v,0,sizeof(*v)); 314
288 /* !!! do not return VIDEO_AUDIO_MUTE */ 315 f->type = V4L2_TUNER_RADIO;
289 v->flags = VIDEO_AUDIO_MUTABLE; 316 f->frequency = fmr2->curfreq;
290 strcpy(v->name, "Radio"); 317 if (!(fmr2->flags & V4L2_TUNER_CAP_LOW))
291 /* get current stereo mode */ 318 f->frequency /= 1000;
292 v->mode = fmr2->stereo ? VIDEO_SOUND_STEREO: VIDEO_SOUND_MONO; 319
293 /* volume supported ? */
294 if (fmr2->card_type == 11)
295 {
296 v->flags |= VIDEO_AUDIO_VOLUME;
297 v->step = 1 << 12;
298 v->volume = fmr2->curvol;
299 }
300 debug_print((KERN_DEBUG "Get flags %d vol %d\n", v->flags, v->volume));
301 return 0; 320 return 0;
302 } 321 }
303 case VIDIOCSAUDIO: 322 case VIDIOC_QUERYCTRL:
304 { 323 {
305 struct video_audio *v = arg; 324 struct v4l2_queryctrl *qc = arg;
306 if(v->audio) 325 int i;
307 return -EINVAL; 326
308 debug_print((KERN_DEBUG "Set flags %d vol %d\n", v->flags, v->volume)); 327 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
309 /* set volume */ 328 if ((fmr2->card_type != 11)
310 if (v->flags & VIDEO_AUDIO_VOLUME) 329 && V4L2_CID_AUDIO_VOLUME)
311 fmr2->curvol = v->volume; /* !!! set with precision */ 330 radio_qctrl[i].step=65535;
312 if (fmr2->card_type != 11) fmr2->curvol = 65535; 331 if (qc->id && qc->id == radio_qctrl[i].id) {
313 fmr2->mute = 0; 332 memcpy(qc, &(radio_qctrl[i]),
314 if (v->flags & VIDEO_AUDIO_MUTE) 333 sizeof(*qc));
315 fmr2->mute = 1; 334 return (0);
335 }
336 }
337 return -EINVAL;
338 }
339 case VIDIOC_G_CTRL:
340 {
341 struct v4l2_control *ctrl= arg;
342
343 switch (ctrl->id) {
344 case V4L2_CID_AUDIO_MUTE:
345 ctrl->value=fmr2->mute;
346 return (0);
347 case V4L2_CID_AUDIO_VOLUME:
348 ctrl->value=fmr2->curvol;
349 return (0);
350 }
351 return -EINVAL;
352 }
353 case VIDIOC_S_CTRL:
354 {
355 struct v4l2_control *ctrl= arg;
356
357 switch (ctrl->id) {
358 case V4L2_CID_AUDIO_MUTE:
359 fmr2->mute=ctrl->value;
360 if (fmr2->card_type != 11) {
361 if (!fmr2->mute) {
362 fmr2->curvol = 65535;
363 } else {
364 fmr2->curvol = 0;
365 }
366 }
367 break;
368 case V4L2_CID_AUDIO_VOLUME:
369 fmr2->curvol = ctrl->value;
370 if (fmr2->card_type != 11) {
371 if (fmr2->curvol) {
372 fmr2->curvol = 65535;
373 fmr2->mute = 0;
374 } else {
375 fmr2->curvol = 0;
376 fmr2->mute = 1;
377 }
378 }
379 break;
380 default:
381 return -EINVAL;
382 }
316#ifdef DEBUG 383#ifdef DEBUG
317 if (fmr2->curvol && !fmr2->mute) 384 if (fmr2->curvol && !fmr2->mute)
318 printk(KERN_DEBUG "unmute\n"); 385 printk(KERN_DEBUG "unmute\n");
@@ -320,27 +387,18 @@ static int fmr2_do_ioctl(struct inode *inode, struct file *file,
320 printk(KERN_DEBUG "mute\n"); 387 printk(KERN_DEBUG "mute\n");
321#endif 388#endif
322 mutex_lock(&lock); 389 mutex_lock(&lock);
323 if (fmr2->curvol && !fmr2->mute) 390 if (fmr2->curvol && !fmr2->mute) {
324 {
325 fmr2_setvolume(fmr2); 391 fmr2_setvolume(fmr2);
326 fmr2_setfreq(fmr2); 392 fmr2_setfreq(fmr2);
327 } 393 } else
328 else fmr2_mute(fmr2->port); 394 fmr2_mute(fmr2->port);
329 mutex_unlock(&lock); 395 mutex_unlock(&lock);
330 return 0; 396 return (0);
331 }
332 case VIDIOCGUNIT:
333 {
334 struct video_unit *v = arg;
335 v->video=VIDEO_NO_UNIT;
336 v->vbi=VIDEO_NO_UNIT;
337 v->radio=dev->minor;
338 v->audio=0; /* How do we find out this??? */
339 v->teletext=VIDEO_NO_UNIT;
340 return 0;
341 } 397 }
342 default: 398 default:
343 return -ENOIOCTLCMD; 399 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
400 fmr2_do_ioctl);
401
344 } 402 }
345} 403}
346 404
@@ -366,7 +424,7 @@ static struct video_device fmr2_radio=
366 .owner = THIS_MODULE, 424 .owner = THIS_MODULE,
367 .name = "SF16FMR2 radio", 425 .name = "SF16FMR2 radio",
368 . type = VID_TYPE_TUNER, 426 . type = VID_TYPE_TUNER,
369 .hardware = VID_HARDWARE_SF16FMR2, 427 .hardware = 0,
370 .fops = &fmr2_fops, 428 .fops = &fmr2_fops,
371}; 429};
372 430
@@ -377,7 +435,7 @@ static int __init fmr2_init(void)
377 fmr2_unit.mute = 0; 435 fmr2_unit.mute = 0;
378 fmr2_unit.curfreq = 0; 436 fmr2_unit.curfreq = 0;
379 fmr2_unit.stereo = 1; 437 fmr2_unit.stereo = 1;
380 fmr2_unit.flags = VIDEO_TUNER_LOW; 438 fmr2_unit.flags = V4L2_TUNER_CAP_LOW;
381 fmr2_unit.card_type = 0; 439 fmr2_unit.card_type = 0;
382 fmr2_radio.priv = &fmr2_unit; 440 fmr2_radio.priv = &fmr2_unit;
383 441
@@ -396,7 +454,6 @@ static int __init fmr2_init(void)
396 } 454 }
397 455
398 printk(KERN_INFO "SF16FMR2 radio card driver at 0x%x.\n", io); 456 printk(KERN_INFO "SF16FMR2 radio card driver at 0x%x.\n", io);
399 debug_print((KERN_DEBUG "Mute %d Low %d\n",VIDEO_AUDIO_MUTE,VIDEO_TUNER_LOW));
400 /* mute card - prevents noisy bootups */ 457 /* mute card - prevents noisy bootups */
401 mutex_lock(&lock); 458 mutex_lock(&lock);
402 fmr2_mute(io); 459 fmr2_mute(io);
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index dfba4ae596cd..f539491a0d76 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -21,6 +21,7 @@
21 * If you can help me out with that, please contact me!! 21 * If you can help me out with that, please contact me!!
22 * 22 *
23 * 23 *
24 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
24 */ 25 */
25 26
26#include <linux/module.h> /* Modules */ 27#include <linux/module.h> /* Modules */
@@ -29,11 +30,32 @@
29#include <linux/delay.h> /* udelay */ 30#include <linux/delay.h> /* udelay */
30#include <asm/io.h> /* outb, outb_p */ 31#include <asm/io.h> /* outb, outb_p */
31#include <asm/uaccess.h> /* copy to/from user */ 32#include <asm/uaccess.h> /* copy to/from user */
32#include <linux/videodev.h> /* kernel radio structs */ 33#include <linux/videodev2.h> /* kernel radio structs */
33#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
34#include <linux/config.h> /* CONFIG_RADIO_TERRATEC_PORT */
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36 36
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */
38#define RADIO_VERSION KERNEL_VERSION(0,0,2)
39
40static struct v4l2_queryctrl radio_qctrl[] = {
41 {
42 .id = V4L2_CID_AUDIO_MUTE,
43 .name = "Mute",
44 .minimum = 0,
45 .maximum = 1,
46 .default_value = 1,
47 .type = V4L2_CTRL_TYPE_BOOLEAN,
48 },{
49 .id = V4L2_CID_AUDIO_VOLUME,
50 .name = "Volume",
51 .minimum = 0,
52 .maximum = 0xff,
53 .step = 1,
54 .default_value = 0xff,
55 .type = V4L2_CTRL_TYPE_INTEGER,
56 }
57};
58
37#ifndef CONFIG_RADIO_TERRATEC_PORT 59#ifndef CONFIG_RADIO_TERRATEC_PORT
38#define CONFIG_RADIO_TERRATEC_PORT 0x590 60#define CONFIG_RADIO_TERRATEC_PORT 0x590
39#endif 61#endif
@@ -194,73 +216,117 @@ static int tt_do_ioctl(struct inode *inode, struct file *file,
194 216
195 switch(cmd) 217 switch(cmd)
196 { 218 {
197 case VIDIOCGCAP: 219 case VIDIOC_QUERYCAP:
198 { 220 {
199 struct video_capability *v = arg; 221 struct v4l2_capability *v = arg;
200 memset(v,0,sizeof(*v)); 222 memset(v,0,sizeof(*v));
201 v->type=VID_TYPE_TUNER; 223 strlcpy(v->driver, "radio-terratec", sizeof (v->driver));
202 v->channels=1; 224 strlcpy(v->card, "ActiveRadio", sizeof (v->card));
203 v->audios=1; 225 sprintf(v->bus_info,"ISA");
204 strcpy(v->name, "ActiveRadio"); 226 v->version = RADIO_VERSION;
227 v->capabilities = V4L2_CAP_TUNER;
228
205 return 0; 229 return 0;
206 } 230 }
207 case VIDIOCGTUNER: 231 case VIDIOC_G_TUNER:
208 { 232 {
209 struct video_tuner *v = arg; 233 struct v4l2_tuner *v = arg;
210 if(v->tuner) /* Only 1 tuner */ 234
235 if (v->index > 0)
211 return -EINVAL; 236 return -EINVAL;
237
238 memset(v,0,sizeof(*v));
239 strcpy(v->name, "FM");
240 v->type = V4L2_TUNER_RADIO;
241
212 v->rangelow=(87*16000); 242 v->rangelow=(87*16000);
213 v->rangehigh=(108*16000); 243 v->rangehigh=(108*16000);
214 v->flags=VIDEO_TUNER_LOW; 244 v->rxsubchans =V4L2_TUNER_SUB_MONO;
215 v->mode=VIDEO_MODE_AUTO; 245 v->capability=V4L2_TUNER_CAP_LOW;
216 strcpy(v->name, "FM"); 246 v->audmode = V4L2_TUNER_MODE_MONO;
217 v->signal=0xFFFF*tt_getsigstr(tt); 247 v->signal=0xFFFF*tt_getsigstr(tt);
248
218 return 0; 249 return 0;
219 } 250 }
220 case VIDIOCSTUNER: 251 case VIDIOC_S_TUNER:
221 { 252 {
222 struct video_tuner *v = arg; 253 struct v4l2_tuner *v = arg;
223 if(v->tuner!=0) 254
255 if (v->index > 0)
224 return -EINVAL; 256 return -EINVAL;
225 /* Only 1 tuner so no setting needed ! */ 257
226 return 0; 258 return 0;
227 } 259 }
228 case VIDIOCGFREQ: 260 case VIDIOC_S_FREQUENCY:
229 { 261 {
230 unsigned long *freq = arg; 262 struct v4l2_frequency *f = arg;
231 *freq = tt->curfreq; 263
264 tt->curfreq = f->frequency;
265 tt_setfreq(tt, tt->curfreq);
232 return 0; 266 return 0;
233 } 267 }
234 case VIDIOCSFREQ: 268 case VIDIOC_G_FREQUENCY:
235 { 269 {
236 unsigned long *freq = arg; 270 struct v4l2_frequency *f = arg;
237 tt->curfreq = *freq; 271
238 tt_setfreq(tt, tt->curfreq); 272 f->type = V4L2_TUNER_RADIO;
273 f->frequency = tt->curfreq;
274
239 return 0; 275 return 0;
240 } 276 }
241 case VIDIOCGAUDIO: 277 case VIDIOC_QUERYCTRL:
242 { 278 {
243 struct video_audio *v = arg; 279 struct v4l2_queryctrl *qc = arg;
244 memset(v,0, sizeof(*v)); 280 int i;
245 v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; 281
246 v->volume=tt->curvol * 6554; 282 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
247 v->step=6554; 283 if (qc->id && qc->id == radio_qctrl[i].id) {
248 strcpy(v->name, "Radio"); 284 memcpy(qc, &(radio_qctrl[i]),
249 return 0; 285 sizeof(*qc));
286 return (0);
287 }
288 }
289 return -EINVAL;
250 } 290 }
251 case VIDIOCSAUDIO: 291 case VIDIOC_G_CTRL:
252 { 292 {
253 struct video_audio *v = arg; 293 struct v4l2_control *ctrl= arg;
254 if(v->audio) 294
255 return -EINVAL; 295 switch (ctrl->id) {
256 if(v->flags&VIDEO_AUDIO_MUTE) 296 case V4L2_CID_AUDIO_MUTE:
257 tt_mute(tt); 297 if (tt->muted)
258 else 298 ctrl->value=1;
259 tt_setvol(tt,v->volume/6554); 299 else
260 return 0; 300 ctrl->value=0;
301 return (0);
302 case V4L2_CID_AUDIO_VOLUME:
303 ctrl->value=tt->curvol * 6554;
304 return (0);
305 }
306 return -EINVAL;
261 } 307 }
308 case VIDIOC_S_CTRL:
309 {
310 struct v4l2_control *ctrl= arg;
311
312 switch (ctrl->id) {
313 case V4L2_CID_AUDIO_MUTE:
314 if (ctrl->value) {
315 tt_mute(tt);
316 } else {
317 tt_setvol(tt,tt->curvol);
318 }
319 return (0);
320 case V4L2_CID_AUDIO_VOLUME:
321 tt_setvol(tt,ctrl->value);
322 return (0);
323 }
324 return -EINVAL;
325 }
326
262 default: 327 default:
263 return -ENOIOCTLCMD; 328 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
329 tt_do_ioctl);
264 } 330 }
265} 331}
266 332
@@ -286,7 +352,7 @@ static struct video_device terratec_radio=
286 .owner = THIS_MODULE, 352 .owner = THIS_MODULE,
287 .name = "TerraTec ActiveRadio", 353 .name = "TerraTec ActiveRadio",
288 .type = VID_TYPE_TUNER, 354 .type = VID_TYPE_TUNER,
289 .hardware = VID_HARDWARE_TERRATEC, 355 .hardware = 0,
290 .fops = &terratec_fops, 356 .fops = &terratec_fops,
291}; 357};
292 358
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 8da4badc22b4..bb03ad5a2033 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -12,7 +12,7 @@
12 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu) 12 * Scott McGrath (smcgrath@twilight.vtc.vsc.edu)
13 * William McGrath (wmcgrath@twilight.vtc.vsc.edu) 13 * William McGrath (wmcgrath@twilight.vtc.vsc.edu)
14 * 14 *
15 * The basis for this code may be found at http://bigbang.vtc.vsc.edu/fmradio/ 15 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
16 */ 16 */
17 17
18#include <stdarg.h> 18#include <stdarg.h>
@@ -21,9 +21,46 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <linux/videodev.h> 24#include <linux/videodev2.h>
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <linux/config.h> /* CONFIG_RADIO_TRUST_PORT */ 26
27#include <linux/version.h> /* for KERNEL_VERSION MACRO */
28#define RADIO_VERSION KERNEL_VERSION(0,0,2)
29
30static struct v4l2_queryctrl radio_qctrl[] = {
31 {
32 .id = V4L2_CID_AUDIO_MUTE,
33 .name = "Mute",
34 .minimum = 0,
35 .maximum = 1,
36 .default_value = 1,
37 .type = V4L2_CTRL_TYPE_BOOLEAN,
38 },{
39 .id = V4L2_CID_AUDIO_VOLUME,
40 .name = "Volume",
41 .minimum = 0,
42 .maximum = 65535,
43 .step = 2048,
44 .default_value = 65535,
45 .type = V4L2_CTRL_TYPE_INTEGER,
46 },{
47 .id = V4L2_CID_AUDIO_BASS,
48 .name = "Bass",
49 .minimum = 0,
50 .maximum = 65535,
51 .step = 4370,
52 .default_value = 32768,
53 .type = V4L2_CTRL_TYPE_INTEGER,
54 },{
55 .id = V4L2_CID_AUDIO_TREBLE,
56 .name = "Treble",
57 .minimum = 0,
58 .maximum = 65535,
59 .step = 4370,
60 .default_value = 32768,
61 .type = V4L2_CTRL_TYPE_INTEGER,
62 },
63};
27 64
28/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */ 65/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
29 66
@@ -160,88 +197,125 @@ static int tr_do_ioctl(struct inode *inode, struct file *file,
160{ 197{
161 switch(cmd) 198 switch(cmd)
162 { 199 {
163 case VIDIOCGCAP: 200 case VIDIOC_QUERYCAP:
164 { 201 {
165 struct video_capability *v = arg; 202 struct v4l2_capability *v = arg;
166
167 memset(v,0,sizeof(*v)); 203 memset(v,0,sizeof(*v));
168 v->type=VID_TYPE_TUNER; 204 strlcpy(v->driver, "radio-trust", sizeof (v->driver));
169 v->channels=1; 205 strlcpy(v->card, "Trust FM Radio", sizeof (v->card));
170 v->audios=1; 206 sprintf(v->bus_info,"ISA");
171 strcpy(v->name, "Trust FM Radio"); 207 v->version = RADIO_VERSION;
208 v->capabilities = V4L2_CAP_TUNER;
172 209
173 return 0; 210 return 0;
174 } 211 }
175 case VIDIOCGTUNER: 212 case VIDIOC_G_TUNER:
176 { 213 {
177 struct video_tuner *v = arg; 214 struct v4l2_tuner *v = arg;
178 215
179 if(v->tuner) /* Only 1 tuner */ 216 if (v->index > 0)
180 return -EINVAL; 217 return -EINVAL;
181 218
182 v->rangelow = 87500 * 16; 219 memset(v,0,sizeof(*v));
183 v->rangehigh = 108000 * 16; 220 strcpy(v->name, "FM");
184 v->flags = VIDEO_TUNER_LOW; 221 v->type = V4L2_TUNER_RADIO;
185 v->mode = VIDEO_MODE_AUTO;
186 222
187 v->signal = tr_getsigstr(); 223 v->rangelow=(87.5*16000);
224 v->rangehigh=(108*16000);
225 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
226 v->capability=V4L2_TUNER_CAP_LOW;
188 if(tr_getstereo()) 227 if(tr_getstereo())
189 v->flags |= VIDEO_TUNER_STEREO_ON; 228 v->audmode = V4L2_TUNER_MODE_STEREO;
190 229 else
191 strcpy(v->name, "FM"); 230 v->audmode = V4L2_TUNER_MODE_MONO;
231 v->signal=tr_getsigstr();
192 232
193 return 0; 233 return 0;
194 } 234 }
195 case VIDIOCSTUNER: 235 case VIDIOC_S_TUNER:
196 { 236 {
197 struct video_tuner *v = arg; 237 struct v4l2_tuner *v = arg;
198 if(v->tuner != 0) 238
239 if (v->index > 0)
199 return -EINVAL; 240 return -EINVAL;
241
200 return 0; 242 return 0;
201 } 243 }
202 case VIDIOCGFREQ: 244 case VIDIOC_S_FREQUENCY:
203 { 245 {
204 unsigned long *freq = arg; 246 struct v4l2_frequency *f = arg;
205 *freq = curfreq; 247
248 curfreq = f->frequency;
249 tr_setfreq(curfreq);
206 return 0; 250 return 0;
207 } 251 }
208 case VIDIOCSFREQ: 252 case VIDIOC_G_FREQUENCY:
209 { 253 {
210 unsigned long *freq = arg; 254 struct v4l2_frequency *f = arg;
211 tr_setfreq(*freq); 255
256 f->type = V4L2_TUNER_RADIO;
257 f->frequency = curfreq;
258
212 return 0; 259 return 0;
213 } 260 }
214 case VIDIOCGAUDIO: 261 case VIDIOC_QUERYCTRL:
215 { 262 {
216 struct video_audio *v = arg; 263 struct v4l2_queryctrl *qc = arg;
217 264 int i;
218 memset(v,0, sizeof(*v)); 265
219 v->flags = VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME | 266 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
220 VIDEO_AUDIO_BASS | VIDEO_AUDIO_TREBLE; 267 if (qc->id && qc->id == radio_qctrl[i].id) {
221 v->mode = curstereo? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; 268 memcpy(qc, &(radio_qctrl[i]),
222 v->volume = curvol * 2048; 269 sizeof(*qc));
223 v->step = 2048; 270 return (0);
224 v->bass = curbass * 4370; 271 }
225 v->treble = curtreble * 4370; 272 }
226 273 return -EINVAL;
227 strcpy(v->name, "Trust FM Radio");
228 return 0;
229 } 274 }
230 case VIDIOCSAUDIO: 275 case VIDIOC_G_CTRL:
231 { 276 {
232 struct video_audio *v = arg; 277 struct v4l2_control *ctrl= arg;
233 278
234 if(v->audio) 279 switch (ctrl->id) {
235 return -EINVAL; 280 case V4L2_CID_AUDIO_MUTE:
236 tr_setvol(v->volume); 281 ctrl->value=curmute;
237 tr_setbass(v->bass); 282 return (0);
238 tr_settreble(v->treble); 283 case V4L2_CID_AUDIO_VOLUME:
239 tr_setstereo(v->mode & VIDEO_SOUND_STEREO); 284 ctrl->value= curvol * 2048;
240 tr_setmute(v->flags & VIDEO_AUDIO_MUTE); 285 return (0);
241 return 0; 286 case V4L2_CID_AUDIO_BASS:
287 ctrl->value= curbass * 4370;
288 return (0);
289 case V4L2_CID_AUDIO_TREBLE:
290 ctrl->value= curtreble * 4370;
291 return (0);
292 }
293 return -EINVAL;
242 } 294 }
295 case VIDIOC_S_CTRL:
296 {
297 struct v4l2_control *ctrl= arg;
298
299 switch (ctrl->id) {
300 case V4L2_CID_AUDIO_MUTE:
301 tr_setmute(ctrl->value);
302 return 0;
303 case V4L2_CID_AUDIO_VOLUME:
304 tr_setvol(ctrl->value);
305 return 0;
306 case V4L2_CID_AUDIO_BASS:
307 tr_setbass(ctrl->value);
308 return 0;
309 case V4L2_CID_AUDIO_TREBLE:
310 tr_settreble(ctrl->value);
311 return (0);
312 }
313 return -EINVAL;
314 }
315
243 default: 316 default:
244 return -ENOIOCTLCMD; 317 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
318 tr_do_ioctl);
245 } 319 }
246} 320}
247 321
@@ -265,7 +339,7 @@ static struct video_device trust_radio=
265 .owner = THIS_MODULE, 339 .owner = THIS_MODULE,
266 .name = "Trust FM Radio", 340 .name = "Trust FM Radio",
267 .type = VID_TYPE_TUNER, 341 .type = VID_TYPE_TUNER,
268 .hardware = VID_HARDWARE_TRUST, 342 .hardware = 0,
269 .fops = &trust_fops, 343 .fops = &trust_fops,
270}; 344};
271 345
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index edd012288669..4a72b4d4e62a 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -27,6 +27,8 @@
27 * value where I do expect just noise and turn the speaker volume down. 27 * value where I do expect just noise and turn the speaker volume down.
28 * The frequency change is necessary since the card never seems to be 28 * The frequency change is necessary since the card never seems to be
29 * completely silent. 29 * completely silent.
30 *
31 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
30 */ 32 */
31 33
32#include <linux/module.h> /* Modules */ 34#include <linux/module.h> /* Modules */
@@ -35,11 +37,32 @@
35#include <linux/proc_fs.h> /* radio card status report */ 37#include <linux/proc_fs.h> /* radio card status report */
36#include <asm/io.h> /* outb, outb_p */ 38#include <asm/io.h> /* outb, outb_p */
37#include <asm/uaccess.h> /* copy to/from user */ 39#include <asm/uaccess.h> /* copy to/from user */
38#include <linux/videodev.h> /* kernel radio structs */ 40#include <linux/videodev2.h> /* kernel radio structs */
39#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
40#include <linux/config.h> /* CONFIG_RADIO_TYPHOON_* */
41 42
42#define BANNER "Typhoon Radio Card driver v0.1\n" 43#include <linux/version.h> /* for KERNEL_VERSION MACRO */
44#define RADIO_VERSION KERNEL_VERSION(0,1,1)
45#define BANNER "Typhoon Radio Card driver v0.1.1\n"
46
47static struct v4l2_queryctrl radio_qctrl[] = {
48 {
49 .id = V4L2_CID_AUDIO_MUTE,
50 .name = "Mute",
51 .minimum = 0,
52 .maximum = 1,
53 .default_value = 1,
54 .type = V4L2_CTRL_TYPE_BOOLEAN,
55 },{
56 .id = V4L2_CID_AUDIO_VOLUME,
57 .name = "Volume",
58 .minimum = 0,
59 .maximum = 65535,
60 .step = 1<<14,
61 .default_value = 0xff,
62 .type = V4L2_CTRL_TYPE_INTEGER,
63 }
64};
65
43 66
44#ifndef CONFIG_RADIO_TYPHOON_PORT 67#ifndef CONFIG_RADIO_TYPHOON_PORT
45#define CONFIG_RADIO_TYPHOON_PORT -1 68#define CONFIG_RADIO_TYPHOON_PORT -1
@@ -171,76 +194,114 @@ static int typhoon_do_ioctl(struct inode *inode, struct file *file,
171 struct typhoon_device *typhoon = dev->priv; 194 struct typhoon_device *typhoon = dev->priv;
172 195
173 switch (cmd) { 196 switch (cmd) {
174 case VIDIOCGCAP: 197 case VIDIOC_QUERYCAP:
175 { 198 {
176 struct video_capability *v = arg; 199 struct v4l2_capability *v = arg;
177 memset(v,0,sizeof(*v)); 200 memset(v,0,sizeof(*v));
178 v->type = VID_TYPE_TUNER; 201 strlcpy(v->driver, "radio-typhoon", sizeof (v->driver));
179 v->channels = 1; 202 strlcpy(v->card, "Typhoon Radio", sizeof (v->card));
180 v->audios = 1; 203 sprintf(v->bus_info,"ISA");
181 strcpy(v->name, "Typhoon Radio"); 204 v->version = RADIO_VERSION;
205 v->capabilities = V4L2_CAP_TUNER;
206
182 return 0; 207 return 0;
183 } 208 }
184 case VIDIOCGTUNER: 209 case VIDIOC_G_TUNER:
185 { 210 {
186 struct video_tuner *v = arg; 211 struct v4l2_tuner *v = arg;
187 if (v->tuner) /* Only 1 tuner */ 212
213 if (v->index > 0)
188 return -EINVAL; 214 return -EINVAL;
189 v->rangelow = 875 * 1600; 215
190 v->rangehigh = 1080 * 1600; 216 memset(v,0,sizeof(*v));
191 v->flags = VIDEO_TUNER_LOW;
192 v->mode = VIDEO_MODE_AUTO;
193 v->signal = 0xFFFF; /* We can't get the signal strength */
194 strcpy(v->name, "FM"); 217 strcpy(v->name, "FM");
218 v->type = V4L2_TUNER_RADIO;
219
220 v->rangelow=(87.5*16000);
221 v->rangehigh=(108*16000);
222 v->rxsubchans =V4L2_TUNER_SUB_MONO;
223 v->capability=V4L2_TUNER_CAP_LOW;
224 v->audmode = V4L2_TUNER_MODE_MONO;
225 v->signal = 0xFFFF; /* We can't get the signal strength */
226
195 return 0; 227 return 0;
196 } 228 }
197 case VIDIOCSTUNER: 229 case VIDIOC_S_TUNER:
198 { 230 {
199 struct video_tuner *v = arg; 231 struct v4l2_tuner *v = arg;
200 if (v->tuner != 0) 232
233 if (v->index > 0)
201 return -EINVAL; 234 return -EINVAL;
202 /* Only 1 tuner so no setting needed ! */ 235
203 return 0; 236 return 0;
204 } 237 }
205 case VIDIOCGFREQ: 238 case VIDIOC_S_FREQUENCY:
206 {
207 unsigned long *freq = arg;
208 *freq = typhoon->curfreq;
209 return 0;
210 }
211 case VIDIOCSFREQ:
212 {
213 unsigned long *freq = arg;
214 typhoon->curfreq = *freq;
215 typhoon_setfreq(typhoon, typhoon->curfreq);
216 return 0;
217 }
218 case VIDIOCGAUDIO:
219 { 239 {
220 struct video_audio *v = arg; 240 struct v4l2_frequency *f = arg;
221 memset(v, 0, sizeof(*v)); 241
222 v->flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME; 242 typhoon->curfreq = f->frequency;
223 v->mode |= VIDEO_SOUND_MONO; 243 typhoon_setfreq(typhoon, typhoon->curfreq);
224 v->volume = typhoon->curvol;
225 v->step = 1 << 14;
226 strcpy(v->name, "Typhoon Radio");
227 return 0; 244 return 0;
228 } 245 }
229 case VIDIOCSAUDIO: 246 case VIDIOC_G_FREQUENCY:
230 { 247 {
231 struct video_audio *v = arg; 248 struct v4l2_frequency *f = arg;
232 if (v->audio) 249
233 return -EINVAL; 250 f->type = V4L2_TUNER_RADIO;
234 if (v->flags & VIDEO_AUDIO_MUTE) 251 f->frequency = typhoon->curfreq;
235 typhoon_mute(typhoon); 252
236 else
237 typhoon_unmute(typhoon);
238 if (v->flags & VIDEO_AUDIO_VOLUME)
239 typhoon_setvol(typhoon, v->volume);
240 return 0; 253 return 0;
241 } 254 }
242 default: 255 case VIDIOC_QUERYCTRL:
243 return -ENOIOCTLCMD; 256 {
257 struct v4l2_queryctrl *qc = arg;
258 int i;
259
260 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
261 if (qc->id && qc->id == radio_qctrl[i].id) {
262 memcpy(qc, &(radio_qctrl[i]),
263 sizeof(*qc));
264 return (0);
265 }
266 }
267 return -EINVAL;
268 }
269 case VIDIOC_G_CTRL:
270 {
271 struct v4l2_control *ctrl= arg;
272
273 switch (ctrl->id) {
274 case V4L2_CID_AUDIO_MUTE:
275 ctrl->value=typhoon->muted;
276 return (0);
277 case V4L2_CID_AUDIO_VOLUME:
278 ctrl->value=typhoon->curvol;
279 return (0);
280 }
281 return -EINVAL;
282 }
283 case VIDIOC_S_CTRL:
284 {
285 struct v4l2_control *ctrl= arg;
286
287 switch (ctrl->id) {
288 case V4L2_CID_AUDIO_MUTE:
289 if (ctrl->value) {
290 typhoon_mute(typhoon);
291 } else {
292 typhoon_unmute(typhoon);
293 }
294 return (0);
295 case V4L2_CID_AUDIO_VOLUME:
296 typhoon_setvol(typhoon, ctrl->value);
297 return (0);
298 }
299 return -EINVAL;
300 }
301
302 default:
303 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
304 typhoon_do_ioctl);
244 } 305 }
245} 306}
246 307
@@ -271,7 +332,7 @@ static struct video_device typhoon_radio =
271 .owner = THIS_MODULE, 332 .owner = THIS_MODULE,
272 .name = "Typhoon Radio", 333 .name = "Typhoon Radio",
273 .type = VID_TYPE_TUNER, 334 .type = VID_TYPE_TUNER,
274 .hardware = VID_HARDWARE_TYPHOON, 335 .hardware = 0,
275 .fops = &typhoon_fops, 336 .fops = &typhoon_fops,
276}; 337};
277 338
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index 59b86a6b4b0e..671fe1b1e5bc 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -24,6 +24,9 @@
24 * - Added unmute function 24 * - Added unmute function
25 * - Reworked ioctl functions 25 * - Reworked ioctl functions
26 * 2002-07-15 - Fix Stereo typo 26 * 2002-07-15 - Fix Stereo typo
27 *
28 * 2006-07-24 - Converted to V4L2 API
29 * by Mauro Carvalho Chehab <mchehab@infradead.org>
27 */ 30 */
28 31
29#include <linux/module.h> /* Modules */ 32#include <linux/module.h> /* Modules */
@@ -32,9 +35,30 @@
32#include <linux/delay.h> /* udelay, msleep */ 35#include <linux/delay.h> /* udelay, msleep */
33#include <asm/io.h> /* outb, outb_p */ 36#include <asm/io.h> /* outb, outb_p */
34#include <asm/uaccess.h> /* copy to/from user */ 37#include <asm/uaccess.h> /* copy to/from user */
35#include <linux/videodev.h> /* kernel radio structs */ 38#include <linux/videodev2.h> /* kernel radio structs */
36#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
37#include <linux/config.h> /* CONFIG_RADIO_ZOLTRIX_PORT */ 40
41#include <linux/version.h> /* for KERNEL_VERSION MACRO */
42#define RADIO_VERSION KERNEL_VERSION(0,0,2)
43
44static struct v4l2_queryctrl radio_qctrl[] = {
45 {
46 .id = V4L2_CID_AUDIO_MUTE,
47 .name = "Mute",
48 .minimum = 0,
49 .maximum = 1,
50 .default_value = 1,
51 .type = V4L2_CTRL_TYPE_BOOLEAN,
52 },{
53 .id = V4L2_CID_AUDIO_VOLUME,
54 .name = "Volume",
55 .minimum = 0,
56 .maximum = 65535,
57 .step = 4096,
58 .default_value = 0xff,
59 .type = V4L2_CTRL_TYPE_INTEGER,
60 }
61};
38 62
39#ifndef CONFIG_RADIO_ZOLTRIX_PORT 63#ifndef CONFIG_RADIO_ZOLTRIX_PORT
40#define CONFIG_RADIO_ZOLTRIX_PORT -1 64#define CONFIG_RADIO_ZOLTRIX_PORT -1
@@ -213,78 +237,116 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
213 struct zol_device *zol = dev->priv; 237 struct zol_device *zol = dev->priv;
214 238
215 switch (cmd) { 239 switch (cmd) {
216 case VIDIOCGCAP: 240 case VIDIOC_QUERYCAP:
217 { 241 {
218 struct video_capability *v = arg; 242 struct v4l2_capability *v = arg;
219
220 memset(v,0,sizeof(*v)); 243 memset(v,0,sizeof(*v));
221 v->type = VID_TYPE_TUNER; 244 strlcpy(v->driver, "radio-zoltrix", sizeof (v->driver));
222 v->channels = 1 + zol->stereo; 245 strlcpy(v->card, "Zoltrix Radio", sizeof (v->card));
223 v->audios = 1; 246 sprintf(v->bus_info,"ISA");
224 strcpy(v->name, "Zoltrix Radio"); 247 v->version = RADIO_VERSION;
248 v->capabilities = V4L2_CAP_TUNER;
249
225 return 0; 250 return 0;
226 } 251 }
227 case VIDIOCGTUNER: 252 case VIDIOC_G_TUNER:
228 { 253 {
229 struct video_tuner *v = arg; 254 struct v4l2_tuner *v = arg;
230 if (v->tuner) 255
256 if (v->index > 0)
231 return -EINVAL; 257 return -EINVAL;
258
259 memset(v,0,sizeof(*v));
232 strcpy(v->name, "FM"); 260 strcpy(v->name, "FM");
233 v->rangelow = (int) (88.0 * 16000); 261 v->type = V4L2_TUNER_RADIO;
234 v->rangehigh = (int) (108.0 * 16000); 262
235 v->flags = zol_is_stereo(zol) 263 v->rangelow=(88*16000);
236 ? VIDEO_TUNER_STEREO_ON : 0; 264 v->rangehigh=(108*16000);
237 v->flags |= VIDEO_TUNER_LOW; 265 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
238 v->mode = VIDEO_MODE_AUTO; 266 v->capability=V4L2_TUNER_CAP_LOW;
239 v->signal = 0xFFFF * zol_getsigstr(zol); 267 if(zol_is_stereo(zol))
268 v->audmode = V4L2_TUNER_MODE_STEREO;
269 else
270 v->audmode = V4L2_TUNER_MODE_MONO;
271 v->signal=0xFFFF*zol_getsigstr(zol);
272
240 return 0; 273 return 0;
241 } 274 }
242 case VIDIOCSTUNER: 275 case VIDIOC_S_TUNER:
243 { 276 {
244 struct video_tuner *v = arg; 277 struct v4l2_tuner *v = arg;
245 if (v->tuner != 0) 278
279 if (v->index > 0)
246 return -EINVAL; 280 return -EINVAL;
247 /* Only 1 tuner so no setting needed ! */ 281
248 return 0; 282 return 0;
249 } 283 }
250 case VIDIOCGFREQ: 284 case VIDIOC_S_FREQUENCY:
251 {
252 unsigned long *freq = arg;
253 *freq = zol->curfreq;
254 return 0;
255 }
256 case VIDIOCSFREQ:
257 {
258 unsigned long *freq = arg;
259 zol->curfreq = *freq;
260 zol_setfreq(zol, zol->curfreq);
261 return 0;
262 }
263 case VIDIOCGAUDIO:
264 { 285 {
265 struct video_audio *v = arg; 286 struct v4l2_frequency *f = arg;
266 memset(v, 0, sizeof(*v)); 287
267 v->flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME; 288 zol->curfreq = f->frequency;
268 v->mode |= zol_is_stereo(zol) 289 zol_setfreq(zol, zol->curfreq);
269 ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
270 v->volume = zol->curvol * 4096;
271 v->step = 4096;
272 strcpy(v->name, "Zoltrix Radio");
273 return 0; 290 return 0;
274 } 291 }
275 case VIDIOCSAUDIO: 292 case VIDIOC_G_FREQUENCY:
276 { 293 {
277 struct video_audio *v = arg; 294 struct v4l2_frequency *f = arg;
278 if (v->audio)
279 return -EINVAL;
280 295
281 if (v->flags & VIDEO_AUDIO_MUTE) 296 f->type = V4L2_TUNER_RADIO;
282 zol_mute(zol); 297 f->frequency = zol->curfreq;
283 else {
284 zol_unmute(zol);
285 zol_setvol(zol, v->volume / 4096);
286 }
287 298
299 return 0;
300 }
301 case VIDIOC_QUERYCTRL:
302 {
303 struct v4l2_queryctrl *qc = arg;
304 int i;
305
306 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
307 if (qc->id && qc->id == radio_qctrl[i].id) {
308 memcpy(qc, &(radio_qctrl[i]),
309 sizeof(*qc));
310 return (0);
311 }
312 }
313 return -EINVAL;
314 }
315 case VIDIOC_G_CTRL:
316 {
317 struct v4l2_control *ctrl= arg;
318
319 switch (ctrl->id) {
320 case V4L2_CID_AUDIO_MUTE:
321 ctrl->value=zol->muted;
322 return (0);
323 case V4L2_CID_AUDIO_VOLUME:
324 ctrl->value=zol->curvol * 4096;
325 return (0);
326 }
327 return -EINVAL;
328 }
329 case VIDIOC_S_CTRL:
330 {
331 struct v4l2_control *ctrl= arg;
332
333 switch (ctrl->id) {
334 case V4L2_CID_AUDIO_MUTE:
335 if (ctrl->value) {
336 zol_mute(zol);
337 } else {
338 zol_unmute(zol);
339 zol_setvol(zol,zol->curvol);
340 }
341 return (0);
342 case V4L2_CID_AUDIO_VOLUME:
343 zol_setvol(zol,ctrl->value/4096);
344 return (0);
345 }
346 zol->stereo = 1;
347 zol_setfreq(zol, zol->curfreq);
348#if 0
349/* FIXME: Implement stereo/mono switch on V4L2 */
288 if (v->mode & VIDEO_SOUND_STEREO) { 350 if (v->mode & VIDEO_SOUND_STEREO) {
289 zol->stereo = 1; 351 zol->stereo = 1;
290 zol_setfreq(zol, zol->curfreq); 352 zol_setfreq(zol, zol->curfreq);
@@ -293,10 +355,13 @@ static int zol_do_ioctl(struct inode *inode, struct file *file,
293 zol->stereo = 0; 355 zol->stereo = 0;
294 zol_setfreq(zol, zol->curfreq); 356 zol_setfreq(zol, zol->curfreq);
295 } 357 }
296 return 0; 358#endif
359 return -EINVAL;
297 } 360 }
298 default: 361
299 return -ENOIOCTLCMD; 362 default:
363 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
364 zol_do_ioctl);
300 } 365 }
301} 366}
302 367
@@ -323,7 +388,7 @@ static struct video_device zoltrix_radio =
323 .owner = THIS_MODULE, 388 .owner = THIS_MODULE,
324 .name = "Zoltrix Radio Plus", 389 .name = "Zoltrix Radio Plus",
325 .type = VID_TYPE_TUNER, 390 .type = VID_TYPE_TUNER,
326 .hardware = VID_HARDWARE_ZOLTRIX, 391 .hardware = 0,
327 .fops = &zoltrix_fops, 392 .fops = &zoltrix_fops,
328}; 393};
329 394
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 94d078b77bab..d1183c939221 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -16,6 +16,320 @@ config VIDEO_ADV_DEBUG
16 V4L devices. 16 V4L devices.
17 In doubt, say N. 17 In doubt, say N.
18 18
19config VIDEO_HELPER_CHIPS_AUTO
20 bool "Autoselect pertinent encoders/decoders and other helper chips"
21 default y
22 ---help---
23 Most video cards may require additional modules to encode or
24 decode audio/video standards. This option will autoselect
25 all pertinent modules to each selected video module.
26
27 Unselect this only if you know exaclty what you are doing, since
28 it may break support on some boards.
29
30 In doubt, say Y.
31
32#
33# Encoder / Decoder module configuration
34#
35
36menu "Encoders/decoders and other helper chips"
37 depends on VIDEO_DEV && !VIDEO_HELPER_CHIPS_AUTO
38
39comment "Audio Decoders"
40
41config VIDEO_TVAUDIO
42 tristate "Simple audio decoder chips"
43 depends on VIDEO_V4L1 && I2C
44 ---help---
45 Support for several audio decoder chips found on some bt8xx boards:
46 Philips: tda9840, tda9873h, tda9874h/a, tda9850, tda985x, tea6300,
47 tea6320, tea6420, tda8425, ta8874z.
48 Microchip: pic16c54 based design on ProVideo PV951 board.
49
50 To compile this driver as a module, choose M here: the
51 module will be called tvaudio.
52
53config VIDEO_TDA7432
54 tristate "Philips TDA7432 audio processor chip"
55 depends on VIDEO_V4L1 && I2C
56 ---help---
57 Support for tda7432 audio decoder chip found on some bt8xx boards.
58
59 To compile this driver as a module, choose M here: the
60 module will be called tda7432.
61
62config VIDEO_TDA9840
63 tristate "Philips TDA9840 audio processor chip"
64 depends on VIDEO_DEV && I2C
65 ---help---
66 Support for tda9840 audio decoder chip found on some Zoran boards.
67
68 To compile this driver as a module, choose M here: the
69 module will be called tda9840.
70
71config VIDEO_TDA9875
72 tristate "Philips TDA9875 audio processor chip"
73 depends on VIDEO_V4L1 && I2C
74 ---help---
75 Support for tda9875 audio decoder chip found on some bt8xx boards.
76
77 To compile this driver as a module, choose M here: the
78 module will be called tda9875.
79
80config VIDEO_TEA6415C
81 tristate "Philips TEA6415C audio processor chip"
82 depends on VIDEO_DEV && I2C
83 ---help---
84 Support for tea6415c audio decoder chip found on some bt8xx boards.
85
86 To compile this driver as a module, choose M here: the
87 module will be called tea6415c.
88
89config VIDEO_TEA6420
90 tristate "Philips TEA6420 audio processor chip"
91 depends on VIDEO_DEV && I2C
92 ---help---
93 Support for tea6420 audio decoder chip found on some bt8xx boards.
94
95 To compile this driver as a module, choose M here: the
96 module will be called tea6420.
97
98config VIDEO_MSP3400
99 tristate "Micronas MSP34xx audio decoders"
100 depends on VIDEO_V4L2 && I2C
101 ---help---
102 Support for the Micronas MSP34xx series of audio decoders.
103
104 To compile this driver as a module, choose M here: the
105 module will be called msp3400.
106
107config VIDEO_CS53L32A
108 tristate "Cirrus Logic CS53L32A audio ADC"
109 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
110 ---help---
111 Support for the Cirrus Logic CS53L32A low voltage
112 stereo A/D converter.
113
114 To compile this driver as a module, choose M here: the
115 module will be called cs53l32a.
116
117config VIDEO_TLV320AIC23B
118 tristate "Texas Instruments TLV320AIC23B audio codec"
119 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
120 ---help---
121 Support for the Texas Instruments TLV320AIC23B audio codec.
122
123 To compile this driver as a module, choose M here: the
124 module will be called tlv320aic23b.
125
126config VIDEO_WM8775
127 tristate "Wolfson Microelectronics WM8775 audio ADC with input mixer"
128 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
129 ---help---
130 Support for the Wolfson Microelectronics WM8775 high
131 performance stereo A/D Converter with a 4 channel input mixer.
132
133 To compile this driver as a module, choose M here: the
134 module will be called wm8775.
135
136config VIDEO_WM8739
137 tristate "Wolfson Microelectronics WM8739 stereo audio ADC"
138 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
139 ---help---
140 Support for the Wolfson Microelectronics WM8739
141 stereo A/D Converter.
142
143 To compile this driver as a module, choose M here: the
144 module will be called wm8739.
145
146comment "MPEG video encoders"
147
148config VIDEO_CX2341X
149 tristate "Conexant CX2341x MPEG encoders"
150 depends on VIDEO_V4L2 && EXPERIMENTAL
151 ---help---
152 Support for the Conexant CX23416 MPEG encoders
153 and CX23415 MPEG encoder/decoders.
154
155 This module currently supports the encoding functions only.
156
157 To compile this driver as a module, choose M here: the
158 module will be called cx2341x.
159
160source "drivers/media/video/cx25840/Kconfig"
161
162comment "Video encoders"
163
164config VIDEO_SAA7127
165 tristate "Philips SAA7127/9 digital video encoders"
166 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
167 ---help---
168 Support for the Philips SAA7127/9 digital video encoders.
169
170 To compile this driver as a module, choose M here: the
171 module will be called saa7127.
172
173config VIDEO_SAA7185
174 tristate "Philips SAA7185 video encoder"
175 depends on VIDEO_V4L1 && I2C
176 ---help---
177 Support for the Philips SAA7185 video encoder.
178
179 To compile this driver as a module, choose M here: the
180 module will be called saa7185.
181
182config VIDEO_ADV7170
183 tristate "Analog Devices ADV7170 video encoder driver"
184 depends on VIDEO_V4L1 && I2C
185 ---help---
186 Support for the Analog Devices ADV7170 video encoder driver
187
188 To compile this driver as a module, choose M here: the
189 module will be called adv7170.
190
191config VIDEO_ADV7175
192 tristate "Analog Devices ADV7175 video encoder driver"
193 depends on VIDEO_V4L1 && I2C
194 ---help---
195 Support for the Analog Devices ADV7175 video encoder driver
196
197 To compile this driver as a module, choose M here: the
198 module will be called adv7175.
199
200comment "Video decoders"
201
202config VIDEO_BT819
203 tristate "BT819A VideoStream Decoder"
204 depends on VIDEO_V4L1 && I2C
205 ---help---
206 Support for BT819A video decoder.
207
208 To compile this driver as a module, choose M here: the
209 module will be called bt819.
210
211config VIDEO_BT856
212 tristate "BT856 VideoStream Decoder"
213 depends on VIDEO_V4L1 && I2C
214 ---help---
215 Support for BT856 video decoder.
216
217 To compile this driver as a module, choose M here: the
218 module will be called bt856.
219
220config VIDEO_BT866
221 tristate "BT866 VideoStream Decoder"
222 depends on VIDEO_V4L1 && I2C
223 ---help---
224 Support for BT866 video decoder.
225
226 To compile this driver as a module, choose M here: the
227 module will be called bt866.
228
229config VIDEO_KS0127
230 tristate "KS0127 video decoder"
231 depends on VIDEO_V4L1 && I2C
232 ---help---
233 Support for KS0127 video decoder.
234
235 This chip is used on AverMedia AVS6EYES Zoran-based MJPEG
236 cards.
237
238 To compile this driver as a module, choose M here: the
239 module will be called ks0127.
240
241config VIDEO_SAA7110
242 tristate "Philips SAA7110 video decoder"
243 depends on VIDEO_V4L1
244 ---help---
245 Support for the Philips SAA7110 video decoders.
246
247 To compile this driver as a module, choose M here: the
248 module will be called saa7110.
249
250config VIDEO_SAA7111
251 tristate "Philips SAA7111 video decoder"
252 depends on VIDEO_V4L1 && I2C
253 ---help---
254 Support for the Philips SAA711 video decoder.
255
256 To compile this driver as a module, choose M here: the
257 module will be called saa7111.
258
259config VIDEO_SAA7114
260 tristate "Philips SAA7114 video decoder"
261 depends on VIDEO_V4L1 && I2C
262 ---help---
263 Support for the Philips SAA7114 video decoder. This driver
264 is used only on Zoran driver and should be moved soon to
265 SAA711x module.
266
267 To compile this driver as a module, choose M here: the
268 module will be called saa7114.
269
270config VIDEO_SAA711X
271 tristate "Philips SAA7113/4/5 video decoders"
272 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
273 ---help---
274 Support for the Philips SAA7113/4/5 video decoders.
275
276 To compile this driver as a module, choose M here: the
277 module will be called saa7115.
278
279config VIDEO_SAA7191
280 tristate "Philips SAA7191 video decoder"
281 depends on VIDEO_V4L1 && I2C
282 ---help---
283 Support for the Philips SAA7191 video decoder.
284
285 To compile this driver as a module, choose M here: the
286 module will be called saa7191.
287
288config VIDEO_TVP5150
289 tristate "Texas Instruments TVP5150 video decoder"
290 depends on VIDEO_V4L2 && I2C
291 ---help---
292 Support for the Texas Instruments TVP5150 video decoder.
293
294 To compile this driver as a module, choose M here: the
295 module will be called tvp5150.
296
297config VIDEO_VPX3220
298 tristate "vpx3220a, vpx3216b & vpx3214c video decoder driver"
299 depends on VIDEO_V4L1 && I2C
300 ---help---
301 Support for VPX322x video decoders.
302
303 To compile this driver as a module, choose M here: the
304 module will be called vpx3220.
305
306comment "Video improvement chips"
307
308config VIDEO_UPD64031A
309 tristate "NEC Electronics uPD64031A Ghost Reduction"
310 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
311 ---help---
312 Support for the NEC Electronics uPD64031A Ghost Reduction
313 video chip. It is most often found in NTSC TV cards made for
314 Japan and is used to reduce the 'ghosting' effect that can
315 be present in analog TV broadcasts.
316
317 To compile this driver as a module, choose M here: the
318 module will be called upd64031a.
319
320config VIDEO_UPD64083
321 tristate "NEC Electronics uPD64083 3-Dimensional Y/C separation"
322 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
323 ---help---
324 Support for the NEC Electronics uPD64083 3-Dimensional Y/C
325 separation video chip. It is used to improve the quality of
326 the colors of a composite signal.
327
328 To compile this driver as a module, choose M here: the
329 module will be called upd64083.
330
331endmenu # encoder / decoder chips
332
19config VIDEO_VIVI 333config VIDEO_VIVI
20 tristate "Virtual Video Driver" 334 tristate "Virtual Video Driver"
21 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 335 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64
@@ -135,7 +449,7 @@ source "drivers/media/video/cpia2/Kconfig"
135 449
136config VIDEO_SAA5246A 450config VIDEO_SAA5246A
137 tristate "SAA5246A, SAA5281 Teletext processor" 451 tristate "SAA5246A, SAA5281 Teletext processor"
138 depends on I2C && VIDEO_V4L1 452 depends on I2C && VIDEO_V4L2
139 help 453 help
140 Support for I2C bus based teletext using the SAA5246A or SAA5281 454 Support for I2C bus based teletext using the SAA5246A or SAA5281
141 chip. Useful only if you live in Europe. 455 chip. Useful only if you live in Europe.
@@ -145,7 +459,7 @@ config VIDEO_SAA5246A
145 459
146config VIDEO_SAA5249 460config VIDEO_SAA5249
147 tristate "SAA5249 Teletext processor" 461 tristate "SAA5249 Teletext processor"
148 depends on VIDEO_DEV && I2C && VIDEO_V4L1 462 depends on VIDEO_DEV && I2C && VIDEO_V4L2
149 help 463 help
150 Support for I2C bus based teletext using the SAA5249 chip. At the 464 Support for I2C bus based teletext using the SAA5249 chip. At the
151 moment this is only useful on some European WinTV cards. 465 moment this is only useful on some European WinTV cards.
@@ -162,8 +476,9 @@ config TUNER_3036
162 476
163config VIDEO_VINO 477config VIDEO_VINO
164 tristate "SGI Vino Video For Linux (EXPERIMENTAL)" 478 tristate "SGI Vino Video For Linux (EXPERIMENTAL)"
165 depends on I2C && SGI_IP22 && EXPERIMENTAL && VIDEO_V4L1 479 depends on I2C && SGI_IP22 && EXPERIMENTAL && VIDEO_V4L2
166 select I2C_ALGO_SGI 480 select I2C_ALGO_SGI
481 select VIDEO_SAA7191 if VIDEO_HELPER_CHIPS_AUTO
167 help 482 help
168 Say Y here to build in support for the Vino video input system found 483 Say Y here to build in support for the Vino video input system found
169 on SGI Indy machines. 484 on SGI Indy machines.
@@ -176,6 +491,9 @@ config VIDEO_STRADIS
176 driver for PCI. There is a product page at 491 driver for PCI. There is a product page at
177 <http://www.stradis.com/>. 492 <http://www.stradis.com/>.
178 493
494config VIDEO_ZORAN_ZR36060
495 tristate
496
179config VIDEO_ZORAN 497config VIDEO_ZORAN
180 tristate "Zoran ZR36057/36067 Video For Linux" 498 tristate "Zoran ZR36057/36067 Video For Linux"
181 depends on PCI && I2C_ALGOBIT && VIDEO_V4L1 && !PPC64 499 depends on PCI && I2C_ALGOBIT && VIDEO_V4L1 && !PPC64
@@ -192,12 +510,18 @@ config VIDEO_ZORAN
192config VIDEO_ZORAN_BUZ 510config VIDEO_ZORAN_BUZ
193 tristate "Iomega Buz support" 511 tristate "Iomega Buz support"
194 depends on VIDEO_ZORAN 512 depends on VIDEO_ZORAN
513 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO
514 select VIDEO_SAA7185 if VIDEO_HELPER_CHIPS_AUTO
515 select VIDEO_ZORAN_ZR36060
195 help 516 help
196 Support for the Iomega Buz MJPEG capture/playback card. 517 Support for the Iomega Buz MJPEG capture/playback card.
197 518
198config VIDEO_ZORAN_DC10 519config VIDEO_ZORAN_DC10
199 tristate "Pinnacle/Miro DC10(+) support" 520 tristate "Pinnacle/Miro DC10(+) support"
200 depends on VIDEO_ZORAN 521 depends on VIDEO_ZORAN
522 select VIDEO_SAA7110
523 select VIDEO_ADV7175 if VIDEO_HELPER_CHIPS_AUTO
524 select VIDEO_ZORAN_ZR36060
201 help 525 help
202 Support for the Pinnacle/Miro DC10(+) MJPEG capture/playback 526 Support for the Pinnacle/Miro DC10(+) MJPEG capture/playback
203 card. 527 card.
@@ -205,6 +529,8 @@ config VIDEO_ZORAN_DC10
205config VIDEO_ZORAN_DC30 529config VIDEO_ZORAN_DC30
206 tristate "Pinnacle/Miro DC30(+) support" 530 tristate "Pinnacle/Miro DC30(+) support"
207 depends on VIDEO_ZORAN 531 depends on VIDEO_ZORAN
532 select VIDEO_ADV7175 if VIDEO_HELPER_CHIPS_AUTO
533 select VIDEO_VPX3220 if VIDEO_HELPER_CHIPS_AUTO
208 help 534 help
209 Support for the Pinnacle/Miro DC30(+) MJPEG capture/playback 535 Support for the Pinnacle/Miro DC30(+) MJPEG capture/playback
210 card. This also supports really old DC10 cards based on the 536 card. This also supports really old DC10 cards based on the
@@ -213,6 +539,9 @@ config VIDEO_ZORAN_DC30
213config VIDEO_ZORAN_LML33 539config VIDEO_ZORAN_LML33
214 tristate "Linux Media Labs LML33 support" 540 tristate "Linux Media Labs LML33 support"
215 depends on VIDEO_ZORAN 541 depends on VIDEO_ZORAN
542 select VIDEO_BT819 if VIDEO_HELPER_CHIPS_AUTO
543 select VIDEO_BT856 if VIDEO_HELPER_CHIPS_AUTO
544 select VIDEO_ZORAN_ZR36060
216 help 545 help
217 Support for the Linux Media Labs LML33 MJPEG capture/playback 546 Support for the Linux Media Labs LML33 MJPEG capture/playback
218 card. 547 card.
@@ -220,6 +549,9 @@ config VIDEO_ZORAN_LML33
220config VIDEO_ZORAN_LML33R10 549config VIDEO_ZORAN_LML33R10
221 tristate "Linux Media Labs LML33R10 support" 550 tristate "Linux Media Labs LML33R10 support"
222 depends on VIDEO_ZORAN 551 depends on VIDEO_ZORAN
552 select VIDEO_SAA7114 if VIDEO_HELPER_CHIPS_AUTO
553 select VIDEO_ADV7170 if VIDEO_HELPER_CHIPS_AUTO
554 select VIDEO_ZORAN_ZR36060
223 help 555 help
224 support for the Linux Media Labs LML33R10 MJPEG capture/playback 556 support for the Linux Media Labs LML33R10 MJPEG capture/playback
225 card. 557 card.
@@ -227,6 +559,9 @@ config VIDEO_ZORAN_LML33R10
227config VIDEO_ZORAN_AVS6EYES 559config VIDEO_ZORAN_AVS6EYES
228 tristate "AverMedia 6 Eyes support (EXPERIMENTAL)" 560 tristate "AverMedia 6 Eyes support (EXPERIMENTAL)"
229 depends on VIDEO_ZORAN && EXPERIMENTAL && VIDEO_V4L1 561 depends on VIDEO_ZORAN && EXPERIMENTAL && VIDEO_V4L1
562 select VIDEO_BT856 if VIDEO_HELPER_CHIPS_AUTO
563 select VIDEO_KS0127 if VIDEO_HELPER_CHIPS_AUTO
564 select VIDEO_ZORAN_ZR36060
230 help 565 help
231 Support for the AverMedia 6 Eyes video surveillance card. 566 Support for the AverMedia 6 Eyes video surveillance card.
232 567
@@ -263,6 +598,10 @@ config VIDEO_MXB
263 depends on PCI && VIDEO_V4L1 && I2C 598 depends on PCI && VIDEO_V4L1 && I2C
264 select VIDEO_SAA7146_VV 599 select VIDEO_SAA7146_VV
265 select VIDEO_TUNER 600 select VIDEO_TUNER
601 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO
602 select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO
603 select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO
604 select VIDEO_TEA6420 if VIDEO_HELPER_CHIPS_AUTO
266 ---help--- 605 ---help---
267 This is a video4linux driver for the 'Multimedia eXtension Board' 606 This is a video4linux driver for the 'Multimedia eXtension Board'
268 TV card by Siemens-Nixdorf. 607 TV card by Siemens-Nixdorf.
@@ -274,7 +613,7 @@ config VIDEO_DPC
274 tristate "Philips-Semiconductors 'dpc7146 demonstration board'" 613 tristate "Philips-Semiconductors 'dpc7146 demonstration board'"
275 depends on PCI && VIDEO_V4L1 && I2C 614 depends on PCI && VIDEO_V4L1 && I2C
276 select VIDEO_SAA7146_VV 615 select VIDEO_SAA7146_VV
277 select VIDEO_V4L2 616 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO
278 ---help--- 617 ---help---
279 This is a video4linux driver for the 'dpc7146 demonstration 618 This is a video4linux driver for the 'dpc7146 demonstration
280 board' by Philips-Semiconductors. It's the reference design 619 board' by Philips-Semiconductors. It's the reference design
@@ -287,9 +626,8 @@ config VIDEO_DPC
287 626
288config VIDEO_HEXIUM_ORION 627config VIDEO_HEXIUM_ORION
289 tristate "Hexium HV-PCI6 and Orion frame grabber" 628 tristate "Hexium HV-PCI6 and Orion frame grabber"
290 depends on PCI && VIDEO_V4L1 && I2C 629 depends on PCI && VIDEO_V4L2 && I2C
291 select VIDEO_SAA7146_VV 630 select VIDEO_SAA7146_VV
292 select VIDEO_V4L2
293 ---help--- 631 ---help---
294 This is a video4linux driver for the Hexium HV-PCI6 and 632 This is a video4linux driver for the Hexium HV-PCI6 and
295 Orion frame grabber cards by Hexium. 633 Orion frame grabber cards by Hexium.
@@ -299,9 +637,8 @@ config VIDEO_HEXIUM_ORION
299 637
300config VIDEO_HEXIUM_GEMINI 638config VIDEO_HEXIUM_GEMINI
301 tristate "Hexium Gemini frame grabber" 639 tristate "Hexium Gemini frame grabber"
302 depends on PCI && VIDEO_V4L1 && I2C 640 depends on PCI && VIDEO_V4L2 && I2C
303 select VIDEO_SAA7146_VV 641 select VIDEO_SAA7146_VV
304 select VIDEO_V4L2
305 ---help--- 642 ---help---
306 This is a video4linux driver for the Hexium Gemini frame 643 This is a video4linux driver for the Hexium Gemini frame
307 grabber card by Hexium. Please note that the Gemini Dual 644 grabber card by Hexium. Please note that the Gemini Dual
@@ -320,123 +657,16 @@ config VIDEO_M32R_AR
320 camera module. 657 camera module.
321 658
322config VIDEO_M32R_AR_M64278 659config VIDEO_M32R_AR_M64278
323 tristate "Use Colour AR module M64278(VGA)" 660 tristate "AR device with color module M64278(VGA)"
324 depends on VIDEO_M32R_AR && PLAT_M32700UT 661 depends on PLAT_M32700UT
325 ---help--- 662 select VIDEO_M32R_AR
326 Say Y here to use the Renesas M64278E-800 camera module,
327 which supports VGA(640x480 pixcels) size of images.
328
329#
330# Encoder / Decoder module configuration
331#
332
333menu "Encoders and Decoders"
334 depends on VIDEO_DEV
335
336config VIDEO_MSP3400
337 tristate "Micronas MSP34xx audio decoders"
338 depends on VIDEO_DEV && I2C
339 ---help---
340 Support for the Micronas MSP34xx series of audio decoders.
341
342 To compile this driver as a module, choose M here: the
343 module will be called msp3400.
344
345config VIDEO_CS53L32A
346 tristate "Cirrus Logic CS53L32A audio ADC"
347 depends on VIDEO_DEV && I2C && EXPERIMENTAL
348 ---help---
349 Support for the Cirrus Logic CS53L32A low voltage
350 stereo A/D converter.
351
352 To compile this driver as a module, choose M here: the
353 module will be called cs53l32a.
354
355config VIDEO_TLV320AIC23B
356 tristate "Texas Instruments TLV320AIC23B audio codec"
357 depends on VIDEO_DEV && I2C && EXPERIMENTAL
358 ---help--- 663 ---help---
359 Support for the Texas Instruments TLV320AIC23B audio codec. 664 This is a video4linux driver for the Renesas AR (Artificial
360 665 Retina) with M64278E-800 camera module.
361 To compile this driver as a module, choose M here: the 666 This module supports VGA(640x480 pixels) resolutions.
362 module will be called tlv320aic23b.
363
364config VIDEO_WM8775
365 tristate "Wolfson Microelectronics WM8775 audio ADC with input mixer"
366 depends on VIDEO_DEV && I2C && EXPERIMENTAL
367 ---help---
368 Support for the Wolfson Microelectronics WM8775 high
369 performance stereo A/D Converter with a 4 channel input mixer.
370 667
371 To compile this driver as a module, choose M here: the 668 To compile this driver as a module, choose M here: the
372 module will be called wm8775. 669 module will be called arv.
373
374config VIDEO_WM8739
375 tristate "Wolfson Microelectronics WM8739 stereo audio ADC"
376 depends on VIDEO_DEV && I2C && EXPERIMENTAL
377 ---help---
378 Support for the Wolfson Microelectronics WM8739
379 stereo A/D Converter.
380
381 To compile this driver as a module, choose M here: the
382 module will be called wm8739.
383
384config VIDEO_CX2341X
385 tristate "Conexant CX2341x MPEG encoders"
386 depends on VIDEO_V4L2 && EXPERIMENTAL
387 ---help---
388 Support for the Conexant CX23416 MPEG encoders
389 and CX23415 MPEG encoder/decoders.
390
391 This module currently supports the encoding functions only.
392
393 To compile this driver as a module, choose M here: the
394 module will be called cx2341x.
395
396source "drivers/media/video/cx25840/Kconfig"
397
398config VIDEO_SAA711X
399 tristate "Philips SAA7113/4/5 video decoders"
400 depends on VIDEO_DEV && I2C && EXPERIMENTAL
401 ---help---
402 Support for the Philips SAA7113/4/5 video decoders.
403
404 To compile this driver as a module, choose M here: the
405 module will be called saa7115.
406
407config VIDEO_SAA7127
408 tristate "Philips SAA7127/9 digital video encoders"
409 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
410 ---help---
411 Support for the Philips SAA7127/9 digital video encoders.
412
413 To compile this driver as a module, choose M here: the
414 module will be called saa7127.
415
416config VIDEO_UPD64031A
417 tristate "NEC Electronics uPD64031A Ghost Reduction"
418 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
419 ---help---
420 Support for the NEC Electronics uPD64031A Ghost Reduction
421 video chip. It is most often found in NTSC TV cards made for
422 Japan and is used to reduce the 'ghosting' effect that can
423 be present in analog TV broadcasts.
424
425 To compile this driver as a module, choose M here: the
426 module will be called upd64031a.
427
428config VIDEO_UPD64083
429 tristate "NEC Electronics uPD64083 3-Dimensional Y/C separation"
430 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
431 ---help---
432 Support for the NEC Electronics uPD64083 3-Dimensional Y/C
433 separation video chip. It is used to improve the quality of
434 the colors of a composite signal.
435
436 To compile this driver as a module, choose M here: the
437 module will be called upd64083.
438
439endmenu # encoder / decoder chips
440 670
441# 671#
442# USB Multimedia device configuration 672# USB Multimedia device configuration
@@ -445,8 +675,6 @@ endmenu # encoder / decoder chips
445menu "V4L USB devices" 675menu "V4L USB devices"
446 depends on USB && VIDEO_DEV 676 depends on USB && VIDEO_DEV
447 677
448source "drivers/media/video/pvrusb2/Kconfig"
449
450source "drivers/media/video/em28xx/Kconfig" 678source "drivers/media/video/em28xx/Kconfig"
451 679
452source "drivers/media/video/usbvideo/Kconfig" 680source "drivers/media/video/usbvideo/Kconfig"
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index e82e511f2a72..af57abce8a6e 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -17,7 +17,10 @@ ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y)
17endif 17endif
18 18
19obj-$(CONFIG_VIDEO_BT848) += bt8xx/ 19obj-$(CONFIG_VIDEO_BT848) += bt8xx/
20obj-$(CONFIG_VIDEO_BT848) += tvaudio.o tda7432.o tda9875.o ir-kbd-i2c.o 20obj-$(CONFIG_VIDEO_BT848) += ir-kbd-i2c.o
21obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
22obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o
23obj-$(CONFIG_VIDEO_TDA9875) += tda9875.o
21obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o 24obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o
22 25
23obj-$(CONFIG_VIDEO_ZR36120) += zoran.o 26obj-$(CONFIG_VIDEO_ZR36120) += zoran.o
@@ -27,17 +30,32 @@ obj-$(CONFIG_VIDEO_SAA5249) += saa5249.o
27obj-$(CONFIG_VIDEO_CQCAM) += c-qcam.o 30obj-$(CONFIG_VIDEO_CQCAM) += c-qcam.o
28obj-$(CONFIG_VIDEO_BWQCAM) += bw-qcam.o 31obj-$(CONFIG_VIDEO_BWQCAM) += bw-qcam.o
29obj-$(CONFIG_VIDEO_W9966) += w9966.o 32obj-$(CONFIG_VIDEO_W9966) += w9966.o
30obj-$(CONFIG_VIDEO_ZORAN_BUZ) += saa7111.o saa7185.o zr36060.o 33
31obj-$(CONFIG_VIDEO_ZORAN_DC10) += saa7110.o adv7175.o zr36060.o 34obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
32obj-$(CONFIG_VIDEO_ZORAN_DC30) += adv7175.o vpx3220.o zr36050.o \ 35obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
33 zr36016.o 36obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o
34obj-$(CONFIG_VIDEO_ZORAN_LML33) += bt819.o bt856.o zr36060.o 37obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o
35obj-$(CONFIG_VIDEO_ZORAN_LML33R10) += saa7114.o adv7170.o zr36060.o 38obj-$(CONFIG_VIDEO_SAA7111) += saa7111.o
36obj-$(CONFIG_VIDEO_ZORAN_AVS6EYES) += bt866.o ks0127.o zr36060.o 39obj-$(CONFIG_VIDEO_SAA7114) += saa7114.o
40obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
41obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
42obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
43obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o
44obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
45obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
46obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o
47obj-$(CONFIG_VIDEO_BT819) += bt819.o
48obj-$(CONFIG_VIDEO_BT856) += bt856.o
49obj-$(CONFIG_VIDEO_BT866) += bt866.o
50obj-$(CONFIG_VIDEO_KS0127) += ks0127.o
51
37obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o videocodec.o 52obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o videocodec.o
53obj-$(CONFIG_VIDEO_ZORAN_DC30) += zr36050.o zr36016.o
54obj-$(CONFIG_VIDEO_ZORAN_ZR36060) += zr36060.o
55
38obj-$(CONFIG_VIDEO_PMS) += pms.o 56obj-$(CONFIG_VIDEO_PMS) += pms.o
39obj-$(CONFIG_VIDEO_PLANB) += planb.o 57obj-$(CONFIG_VIDEO_PLANB) += planb.o
40obj-$(CONFIG_VIDEO_VINO) += vino.o saa7191.o indycam.o 58obj-$(CONFIG_VIDEO_VINO) += vino.o indycam.o
41obj-$(CONFIG_VIDEO_STRADIS) += stradis.o 59obj-$(CONFIG_VIDEO_STRADIS) += stradis.o
42obj-$(CONFIG_VIDEO_CPIA) += cpia.o 60obj-$(CONFIG_VIDEO_CPIA) += cpia.o
43obj-$(CONFIG_VIDEO_CPIA_PP) += cpia_pp.o 61obj-$(CONFIG_VIDEO_CPIA_PP) += cpia_pp.o
@@ -46,7 +64,7 @@ obj-$(CONFIG_VIDEO_MEYE) += meye.o
46obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2c.o saa7134/ 64obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2c.o saa7134/
47obj-$(CONFIG_VIDEO_CX88) += cx88/ 65obj-$(CONFIG_VIDEO_CX88) += cx88/
48obj-$(CONFIG_VIDEO_EM28XX) += em28xx/ 66obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
49obj-$(CONFIG_VIDEO_EM28XX) += tvp5150.o 67obj-$(CONFIG_VIDEO_TVP5150) += tvp5150.o
50obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/ 68obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2/
51obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o 69obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
52obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o 70obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
@@ -55,10 +73,10 @@ obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
55obj-$(CONFIG_VIDEO_WM8739) += wm8739.o 73obj-$(CONFIG_VIDEO_WM8739) += wm8739.o
56obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/ 74obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
57obj-$(CONFIG_VIDEO_CPIA2) += cpia2/ 75obj-$(CONFIG_VIDEO_CPIA2) += cpia2/
58obj-$(CONFIG_VIDEO_MXB) += saa7111.o tda9840.o tea6415c.o tea6420.o mxb.o 76obj-$(CONFIG_VIDEO_MXB) += mxb.o
59obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o 77obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o
60obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o 78obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o
61obj-$(CONFIG_VIDEO_DPC) += saa7111.o dpc7146.o 79obj-$(CONFIG_VIDEO_DPC) += dpc7146.o
62obj-$(CONFIG_TUNER_3036) += tuner-3036.o 80obj-$(CONFIG_TUNER_3036) += tuner-3036.o
63 81
64obj-$(CONFIG_VIDEO_TUNER) += tuner.o 82obj-$(CONFIG_VIDEO_TUNER) += tuner.o
@@ -70,8 +88,6 @@ obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
70obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o 88obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
71 89
72obj-$(CONFIG_VIDEO_CX25840) += cx25840/ 90obj-$(CONFIG_VIDEO_CX25840) += cx25840/
73obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
74obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
75obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o 91obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
76obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o 92obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
77obj-$(CONFIG_VIDEO_CX2341X) += cx2341x.o 93obj-$(CONFIG_VIDEO_CX2341X) += cx2341x.o
@@ -96,4 +112,3 @@ obj-$(CONFIG_VIDEO_VIVI) += vivi.o
96 112
97EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core 113EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
98extra-cflags-$(CONFIG_VIDEO_V4L1_COMPAT) += -DCONFIG_VIDEO_V4L1_COMPAT 114extra-cflags-$(CONFIG_VIDEO_V4L1_COMPAT) += -DCONFIG_VIDEO_V4L1_COMPAT
99
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c
index 05e42bbcfc3d..772fd52d551a 100644
--- a/drivers/media/video/bt866.c
+++ b/drivers/media/video/bt866.c
@@ -65,7 +65,7 @@ MODULE_LICENSE("GPL");
65struct bt866 { 65struct bt866 {
66 struct i2c_client *i2c; 66 struct i2c_client *i2c;
67 int addr; 67 int addr;
68 unsigned char reg[128]; 68 unsigned char reg[256];
69 69
70 int norm; 70 int norm;
71 int enable; 71 int enable;
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index cdcf55650714..58eae887a629 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -8,7 +8,10 @@ config VIDEO_BT848
8 select VIDEO_IR 8 select VIDEO_IR
9 select VIDEO_TUNER 9 select VIDEO_TUNER
10 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
11 select VIDEO_MSP3400 11 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO
12 select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO
13 select VIDEO_TDA7432 if VIDEO_HELPER_CHIPS_AUTO
14 select VIDEO_TDA9875 if VIDEO_HELPER_CHIPS_AUTO
12 ---help--- 15 ---help---
13 Support for BT848 based frame grabber/overlay boards. This includes 16 Support for BT848 based frame grabber/overlay boards. This includes
14 the Miro, Hauppauge and STB boards. Please read the material in 17 the Miro, Hauppauge and STB boards. Please read the material in
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index de14818d5cc4..d23a42b1504f 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -4991,7 +4991,7 @@ void __devinit bttv_check_chipset(void)
4991 int pcipci_fail = 0; 4991 int pcipci_fail = 0;
4992 struct pci_dev *dev = NULL; 4992 struct pci_dev *dev = NULL;
4993 4993
4994 if (pci_pci_problems & PCIPCI_FAIL) 4994 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL)) /* should check if target is AGP */
4995 pcipci_fail = 1; 4995 pcipci_fail = 1;
4996 if (pci_pci_problems & (PCIPCI_TRITON|PCIPCI_NATOMA|PCIPCI_VIAETBF)) 4996 if (pci_pci_problems & (PCIPCI_TRITON|PCIPCI_NATOMA|PCIPCI_VIAETBF))
4997 triton1 = 1; 4997 triton1 = 1;
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 20dff7c316eb..50dde82844ec 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2431,6 +2431,14 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2431 fbuf->bytesperline = btv->fbuf.fmt.bytesperline; 2431 fbuf->bytesperline = btv->fbuf.fmt.bytesperline;
2432 if (fh->ovfmt) 2432 if (fh->ovfmt)
2433 fbuf->depth = fh->ovfmt->depth; 2433 fbuf->depth = fh->ovfmt->depth;
2434 else {
2435 if (fbuf->width)
2436 fbuf->depth = ((fbuf->bytesperline<<3)
2437 + (fbuf->width-1) )
2438 /fbuf->width;
2439 else
2440 fbuf->depth = 0;
2441 }
2434 return 0; 2442 return 0;
2435 } 2443 }
2436 case VIDIOCSFBUF: 2444 case VIDIOCSFBUF:
@@ -4186,6 +4194,7 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev)
4186 return; 4194 return;
4187} 4195}
4188 4196
4197#ifdef CONFIG_PM
4189static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state) 4198static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
4190{ 4199{
4191 struct bttv *btv = pci_get_drvdata(pci_dev); 4200 struct bttv *btv = pci_get_drvdata(pci_dev);
@@ -4266,6 +4275,7 @@ static int bttv_resume(struct pci_dev *pci_dev)
4266 spin_unlock_irqrestore(&btv->s_lock,flags); 4275 spin_unlock_irqrestore(&btv->s_lock,flags);
4267 return 0; 4276 return 0;
4268} 4277}
4278#endif
4269 4279
4270static struct pci_device_id bttv_pci_tbl[] = { 4280static struct pci_device_id bttv_pci_tbl[] = {
4271 {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848, 4281 {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848,
@@ -4286,8 +4296,10 @@ static struct pci_driver bttv_pci_driver = {
4286 .id_table = bttv_pci_tbl, 4296 .id_table = bttv_pci_tbl,
4287 .probe = bttv_probe, 4297 .probe = bttv_probe,
4288 .remove = __devexit_p(bttv_remove), 4298 .remove = __devexit_p(bttv_remove),
4299#ifdef CONFIG_PM
4289 .suspend = bttv_suspend, 4300 .suspend = bttv_suspend,
4290 .resume = bttv_resume, 4301 .resume = bttv_resume,
4302#endif
4291}; 4303};
4292 4304
4293static int bttv_init_module(void) 4305static int bttv_init_module(void)
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 0dfbcc85ebb9..70de6c96e201 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -8,6 +8,9 @@
8 & Marcus Metzler (mocm@thp.uni-koeln.de) 8 & Marcus Metzler (mocm@thp.uni-koeln.de)
9 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org> 9 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
10 10
11 (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
12 - Multituner support and i2c address binding
13
11 This program is free software; you can redistribute it and/or modify 14 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by 15 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or 16 the Free Software Foundation; either version 2 of the License, or
@@ -45,10 +48,18 @@ static int i2c_debug;
45static int i2c_hw; 48static int i2c_hw;
46static int i2c_scan; 49static int i2c_scan;
47module_param(i2c_debug, int, 0644); 50module_param(i2c_debug, int, 0644);
51MODULE_PARM_DESC(i2c_hw,"configure i2c debug level");
48module_param(i2c_hw, int, 0444); 52module_param(i2c_hw, int, 0444);
53MODULE_PARM_DESC(i2c_hw,"force use of hardware i2c support, "
54 "instead of software bitbang");
49module_param(i2c_scan, int, 0444); 55module_param(i2c_scan, int, 0444);
50MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 56MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
51 57
58static unsigned int i2c_udelay = 5;
59module_param(i2c_udelay, int, 0444);
60MODULE_PARM_DESC(i2c_udelay,"soft i2c delay at insmod time, in usecs "
61 "(should be 5 or higher). Lower value means higher bus speed.");
62
52/* ----------------------------------------------------------------------- */ 63/* ----------------------------------------------------------------------- */
53/* I2C functions - bitbanging adapter (software i2c) */ 64/* I2C functions - bitbanging adapter (software i2c) */
54 65
@@ -425,6 +436,11 @@ int __devinit init_bttv_i2c(struct bttv *btv)
425 sizeof(bttv_i2c_adap_hw_template)); 436 sizeof(bttv_i2c_adap_hw_template));
426 } else { 437 } else {
427 /* bt848 */ 438 /* bt848 */
439 /* Prevents usage of invalid delay values */
440 if (i2c_udelay<5)
441 i2c_udelay=5;
442 bttv_i2c_algo_bit_template.udelay=i2c_udelay;
443
428 memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template, 444 memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template,
429 sizeof(bttv_i2c_adap_sw_template)); 445 sizeof(bttv_i2c_adap_sw_template));
430 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template, 446 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
diff --git a/drivers/media/video/compat_ioctl32.c b/drivers/media/video/compat_ioctl32.c
index b69ee1194815..d82a488f12a6 100644
--- a/drivers/media/video/compat_ioctl32.c
+++ b/drivers/media/video/compat_ioctl32.c
@@ -58,6 +58,7 @@ static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user
58 return 0; 58 return 0;
59} 59}
60 60
61
61struct video_buffer32 { 62struct video_buffer32 {
62 compat_caddr_t base; 63 compat_caddr_t base;
63 compat_int_t height, width, depth, bytesperline; 64 compat_int_t height, width, depth, bytesperline;
@@ -618,6 +619,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
618 struct video_buffer vb; 619 struct video_buffer vb;
619 struct video_window vw; 620 struct video_window vw;
620 struct video_code vc; 621 struct video_code vc;
622 struct video_audio va;
621#endif 623#endif
622 struct v4l2_format v2f; 624 struct v4l2_format v2f;
623 struct v4l2_buffer v2b; 625 struct v4l2_buffer v2b;
@@ -635,31 +637,31 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
635 /* First, convert the command. */ 637 /* First, convert the command. */
636 switch(cmd) { 638 switch(cmd) {
637#ifdef CONFIG_VIDEO_V4L1_COMPAT 639#ifdef CONFIG_VIDEO_V4L1_COMPAT
638 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break; 640 case VIDIOCGTUNER32: realcmd = cmd = VIDIOCGTUNER; break;
639 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break; 641 case VIDIOCSTUNER32: realcmd = cmd = VIDIOCSTUNER; break;
640 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break; 642 case VIDIOCGWIN32: realcmd = cmd = VIDIOCGWIN; break;
641 case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break; 643 case VIDIOCGFBUF32: realcmd = cmd = VIDIOCGFBUF; break;
642 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break; 644 case VIDIOCSFBUF32: realcmd = cmd = VIDIOCSFBUF; break;
643 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break; 645 case VIDIOCGFREQ32: realcmd = cmd = VIDIOCGFREQ; break;
644 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break; 646 case VIDIOCSFREQ32: realcmd = cmd = VIDIOCSFREQ; break;
645 case VIDIOCSMICROCODE32: cmd = VIDIOCSMICROCODE; break; 647 case VIDIOCSMICROCODE32: realcmd = cmd = VIDIOCSMICROCODE; break;
646#endif 648#endif
647 case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break; 649 case VIDIOC_G_FMT32: realcmd = cmd = VIDIOC_G_FMT; break;
648 case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break; 650 case VIDIOC_S_FMT32: realcmd = cmd = VIDIOC_S_FMT; break;
649 case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break; 651 case VIDIOC_QUERYBUF32: realcmd = cmd = VIDIOC_QUERYBUF; break;
650 case VIDIOC_QBUF32: cmd = VIDIOC_QBUF; break; 652 case VIDIOC_QBUF32: realcmd = cmd = VIDIOC_QBUF; break;
651 case VIDIOC_DQBUF32: cmd = VIDIOC_DQBUF; break; 653 case VIDIOC_DQBUF32: realcmd = cmd = VIDIOC_DQBUF; break;
652 case VIDIOC_STREAMON32: cmd = VIDIOC_STREAMON; break; 654 case VIDIOC_STREAMON32: realcmd = cmd = VIDIOC_STREAMON; break;
653 case VIDIOC_STREAMOFF32: cmd = VIDIOC_STREAMOFF; break; 655 case VIDIOC_STREAMOFF32: realcmd = cmd = VIDIOC_STREAMOFF; break;
654 case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break; 656 case VIDIOC_G_FBUF32: realcmd = cmd = VIDIOC_G_FBUF; break;
655 case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break; 657 case VIDIOC_S_FBUF32: realcmd = cmd = VIDIOC_S_FBUF; break;
656 case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break; 658 case VIDIOC_OVERLAY32: realcmd = cmd = VIDIOC_OVERLAY; break;
657 case VIDIOC_ENUMSTD32: realcmd = VIDIOC_ENUMSTD; break; 659 case VIDIOC_ENUMSTD32: realcmd = VIDIOC_ENUMSTD; break;
658 case VIDIOC_ENUMINPUT32: realcmd = VIDIOC_ENUMINPUT; break; 660 case VIDIOC_ENUMINPUT32: realcmd = VIDIOC_ENUMINPUT; break;
659 case VIDIOC_S_CTRL32: cmd = VIDIOC_S_CTRL; break; 661 case VIDIOC_S_CTRL32: realcmd = cmd = VIDIOC_S_CTRL; break;
660 case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break; 662 case VIDIOC_G_INPUT32: realcmd = cmd = VIDIOC_G_INPUT; break;
661 case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break; 663 case VIDIOC_S_INPUT32: realcmd = cmd = VIDIOC_S_INPUT; break;
662 case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break; 664 case VIDIOC_TRY_FMT32: realcmd = cmd = VIDIOC_TRY_FMT; break;
663 }; 665 };
664 666
665 switch(cmd) { 667 switch(cmd) {
@@ -676,6 +678,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
676 compatible_arg = 0; 678 compatible_arg = 0;
677 break; 679 break;
678 680
681
679 case VIDIOCSFREQ: 682 case VIDIOCSFREQ:
680#endif 683#endif
681 case VIDIOC_S_INPUT: 684 case VIDIOC_S_INPUT:
@@ -683,7 +686,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
683 case VIDIOC_STREAMON: 686 case VIDIOC_STREAMON:
684 case VIDIOC_STREAMOFF: 687 case VIDIOC_STREAMOFF:
685 err = get_user(karg.vx, (u32 __user *)up); 688 err = get_user(karg.vx, (u32 __user *)up);
686 compatible_arg = 0; 689 compatible_arg = 1;
687 break; 690 break;
688 691
689 case VIDIOC_S_FBUF: 692 case VIDIOC_S_FBUF:
@@ -739,6 +742,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
739 case VIDIOC_G_FBUF: 742 case VIDIOC_G_FBUF:
740 case VIDIOC_G_INPUT: 743 case VIDIOC_G_INPUT:
741 compatible_arg = 0; 744 compatible_arg = 0;
745 break;
742#ifdef CONFIG_VIDEO_V4L1_COMPAT 746#ifdef CONFIG_VIDEO_V4L1_COMPAT
743 case VIDIOCSMICROCODE: 747 case VIDIOCSMICROCODE:
744 err = microcode32(&karg.vc, up); 748 err = microcode32(&karg.vc, up);
@@ -755,7 +759,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
755 mm_segment_t old_fs = get_fs(); 759 mm_segment_t old_fs = get_fs();
756 760
757 set_fs(KERNEL_DS); 761 set_fs(KERNEL_DS);
758 err = native_ioctl(file, realcmd, (unsigned long)&karg); 762 err = native_ioctl(file, realcmd, (unsigned long) &karg);
759 set_fs(old_fs); 763 set_fs(old_fs);
760 } 764 }
761 if(err == 0) { 765 if(err == 0) {
@@ -772,6 +776,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
772 case VIDIOCGFBUF: 776 case VIDIOCGFBUF:
773 err = put_video_buffer32(&karg.vb, up); 777 err = put_video_buffer32(&karg.vb, up);
774 break; 778 break;
779
775#endif 780#endif
776 case VIDIOC_G_FBUF: 781 case VIDIOC_G_FBUF:
777 err = put_v4l2_framebuffer32(&karg.v2fb, up); 782 err = put_v4l2_framebuffer32(&karg.v2fb, up);
@@ -841,10 +846,14 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
841 case VIDIOCSFBUF32: 846 case VIDIOCSFBUF32:
842 case VIDIOCGFREQ32: 847 case VIDIOCGFREQ32:
843 case VIDIOCSFREQ32: 848 case VIDIOCSFREQ32:
849 case VIDIOCGAUDIO:
850 case VIDIOCSAUDIO:
844#endif 851#endif
845 case VIDIOC_QUERYCAP: 852 case VIDIOC_QUERYCAP:
846 case VIDIOC_ENUM_FMT: 853 case VIDIOC_ENUM_FMT:
847 case VIDIOC_G_FMT32: 854 case VIDIOC_G_FMT32:
855 case VIDIOC_CROPCAP:
856 case VIDIOC_S_CROP:
848 case VIDIOC_S_FMT32: 857 case VIDIOC_S_FMT32:
849 case VIDIOC_REQBUFS: 858 case VIDIOC_REQBUFS:
850 case VIDIOC_QUERYBUF32: 859 case VIDIOC_QUERYBUF32:
@@ -882,8 +891,6 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
882 case VIDIOCSPICT: 891 case VIDIOCSPICT:
883 case VIDIOCCAPTURE: 892 case VIDIOCCAPTURE:
884 case VIDIOCKEY: 893 case VIDIOCKEY:
885 case VIDIOCGAUDIO:
886 case VIDIOCSAUDIO:
887 case VIDIOCSYNC: 894 case VIDIOCSYNC:
888 case VIDIOCMCAPTURE: 895 case VIDIOCMCAPTURE:
889 case VIDIOCGMBUF: 896 case VIDIOCGMBUF:
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 65f00fc08fa9..657e0b969145 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -691,7 +691,7 @@ void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p)
691 .video_luma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR, 691 .video_luma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR,
692 .video_chroma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR, 692 .video_chroma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR,
693 .video_temporal_filter_mode = V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL, 693 .video_temporal_filter_mode = V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL,
694 .video_temporal_filter = 0, 694 .video_temporal_filter = 8,
695 .video_median_filter_type = V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF, 695 .video_median_filter_type = V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF,
696 .video_luma_median_filter_top = 255, 696 .video_luma_median_filter_top = 255,
697 .video_luma_median_filter_bottom = 0, 697 .video_luma_median_filter_bottom = 0,
@@ -731,6 +731,7 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
731 }; 731 };
732 732
733 int err = 0; 733 int err = 0;
734 u16 temporal = new->video_temporal_filter;
734 735
735 cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0); 736 cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0);
736 737
@@ -741,6 +742,7 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
741 742
742 if (old == NULL || old->width != new->width || old->height != new->height || 743 if (old == NULL || old->width != new->width || old->height != new->height ||
743 old->video_encoding != new->video_encoding) { 744 old->video_encoding != new->video_encoding) {
745 int is_scaling;
744 u16 w = new->width; 746 u16 w = new->width;
745 u16 h = new->height; 747 u16 h = new->height;
746 748
@@ -750,6 +752,20 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
750 } 752 }
751 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, h, w); 753 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, h, w);
752 if (err) return err; 754 if (err) return err;
755
756 /* Adjust temporal filter if necessary. The problem with the temporal
757 filter is that it works well with full resolution capturing, but
758 not when the capture window is scaled (the filter introduces
759 a ghosting effect). So if the capture window changed, and there is
760 no updated filter value, then the filter is set depending on whether
761 the new window is full resolution or not.
762
763 For full resolution a setting of 8 really improves the video
764 quality, especially if the original video quality is suboptimal. */
765 is_scaling = new->width != 720 || new->height != (new->is_50hz ? 576 : 480);
766 if (old && old->video_temporal_filter == temporal) {
767 temporal = is_scaling ? 0 : 8;
768 }
753 } 769 }
754 770
755 if (old == NULL || old->stream_type != new->stream_type) { 771 if (old == NULL || old->stream_type != new->stream_type) {
@@ -815,9 +831,9 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
815 } 831 }
816 if (old == NULL || 832 if (old == NULL ||
817 old->video_spatial_filter != new->video_spatial_filter || 833 old->video_spatial_filter != new->video_spatial_filter ||
818 old->video_temporal_filter != new->video_temporal_filter) { 834 old->video_temporal_filter != temporal) {
819 err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS, 2, 835 err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS, 2,
820 new->video_spatial_filter, new->video_temporal_filter); 836 new->video_spatial_filter, temporal);
821 if (err) return err; 837 if (err) return err;
822 } 838 }
823 if (old == NULL || old->video_temporal_decimation != new->video_temporal_decimation) { 839 if (old == NULL || old->video_temporal_decimation != new->video_temporal_decimation) {
@@ -855,6 +871,9 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
855 printk(KERN_INFO "%s: Stream: %s\n", 871 printk(KERN_INFO "%s: Stream: %s\n",
856 prefix, 872 prefix,
857 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE)); 873 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE));
874 printk(KERN_INFO "%s: VBI Format: %s\n",
875 prefix,
876 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_VBI_FMT));
858 877
859 /* Video */ 878 /* Video */
860 printk(KERN_INFO "%s: Video: %dx%d, %d fps\n", 879 printk(KERN_INFO "%s: Video: %dx%d, %d fps\n",
diff --git a/drivers/media/video/cx25840/Kconfig b/drivers/media/video/cx25840/Kconfig
index 854264e42ec0..7cf29a03ed63 100644
--- a/drivers/media/video/cx25840/Kconfig
+++ b/drivers/media/video/cx25840/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_CX25840 1config VIDEO_CX25840
2 tristate "Conexant CX2584x audio/video decoders" 2 tristate "Conexant CX2584x audio/video decoders"
3 depends on VIDEO_DEV && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
4 select FW_LOADER 4 select FW_LOADER
5 ---help--- 5 ---help---
6 Support for the Conexant CX2584x audio/video decoders. 6 Support for the Conexant CX2584x audio/video decoders.
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c
index 6cc8bf215e85..48014a254e15 100644
--- a/drivers/media/video/cx25840/cx25840-vbi.c
+++ b/drivers/media/video/cx25840/cx25840-vbi.c
@@ -111,6 +111,10 @@ void cx25840_vbi_setup(struct i2c_client *client)
111 uv_lpf=0; 111 uv_lpf=0;
112 comb=0; 112 comb=0;
113 sc=0x0a425f; 113 sc=0x0a425f;
114 } else if (std == V4L2_STD_PAL_Nc) {
115 uv_lpf=1;
116 comb=0x20;
117 sc=556453;
114 } else { 118 } else {
115 uv_lpf=1; 119 uv_lpf=1;
116 comb=0x20; 120 comb=0x20;
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 7a94e6a11927..51d68f32aa06 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -1,7 +1,3 @@
1config VIDEO_CX88_VP3054
2 tristate
3 depends on VIDEO_CX88_DVB && DVB_MT352
4
5config VIDEO_CX88 1config VIDEO_CX88
6 tristate "Conexant 2388x (bt878 successor) support" 2 tristate "Conexant 2388x (bt878 successor) support"
7 depends on VIDEO_DEV && PCI && I2C 3 depends on VIDEO_DEV && PCI && I2C
@@ -52,6 +48,14 @@ config VIDEO_CX88_DVB
52 depends on VIDEO_CX88 && DVB_CORE 48 depends on VIDEO_CX88 && DVB_CORE
53 select VIDEO_BUF_DVB 49 select VIDEO_BUF_DVB
54 select DVB_PLL 50 select DVB_PLL
51 select DVB_MT352 if !DVB_FE_CUSTOMISE
52 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
53 select DVB_OR51132 if !DVB_FE_CUSTOMISE
54 select DVB_CX22702 if !DVB_FE_CUSTOMISE
55 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
56 select DVB_NXT200X if !DVB_FE_CUSTOMISE
57 select DVB_CX24123 if !DVB_FE_CUSTOMISE
58 select DVB_ISL6421 if !DVB_FE_CUSTOMISE
55 ---help--- 59 ---help---
56 This adds support for DVB/ATSC cards based on the 60 This adds support for DVB/ATSC cards based on the
57 Conexant 2388x chip. 61 Conexant 2388x chip.
@@ -59,101 +63,12 @@ config VIDEO_CX88_DVB
59 To compile this driver as a module, choose M here: the 63 To compile this driver as a module, choose M here: the
60 module will be called cx88-dvb. 64 module will be called cx88-dvb.
61 65
62 You must also select one or more DVB/ATSC demodulators. 66config VIDEO_CX88_VP3054
63 If you are unsure which you need, choose all of them. 67 tristate "VP-3054 Secondary I2C Bus Support"
64 68 default m
65config VIDEO_CX88_DVB_ALL_FRONTENDS 69 depends on VIDEO_CX88_DVB && DVB_MT352
66 bool "Build all supported frontends for cx2388x based TV cards"
67 default y
68 depends on VIDEO_CX88_DVB
69 select DVB_MT352
70 select VIDEO_CX88_VP3054
71 select DVB_ZL10353
72 select DVB_OR51132
73 select DVB_CX22702
74 select DVB_LGDT330X
75 select DVB_NXT200X
76 select DVB_CX24123
77 select DVB_ISL6421
78 ---help---
79 This builds cx88-dvb with all currently supported frontend
80 demodulators. If you wish to tweak your configuration, and
81 only include support for the hardware that you need, choose N here.
82
83 If you are unsure, choose Y.
84
85config VIDEO_CX88_DVB_MT352
86 bool "Zarlink MT352 DVB-T Support"
87 default y
88 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
89 select DVB_MT352
90 ---help---
91 This adds DVB-T support for cards based on the
92 Connexant 2388x chip and the MT352 demodulator.
93
94config VIDEO_CX88_DVB_VP3054
95 bool "VP-3054 Secondary I2C Bus Support"
96 default y
97 depends on VIDEO_CX88_DVB_MT352
98 select VIDEO_CX88_VP3054
99 ---help--- 70 ---help---
100 This adds DVB-T support for cards based on the 71 This adds DVB-T support for cards based on the
101 Connexant 2388x chip and the MT352 demodulator, 72 Connexant 2388x chip and the MT352 demodulator,
102 which also require support for the VP-3054 73 which also require support for the VP-3054
103 Secondary I2C bus, such at DNTV Live! DVB-T Pro. 74 Secondary I2C bus, such at DNTV Live! DVB-T Pro.
104
105config VIDEO_CX88_DVB_ZL10353
106 bool "Zarlink ZL10353 DVB-T Support"
107 default y
108 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
109 select DVB_ZL10353
110 ---help---
111 This adds DVB-T support for cards based on the
112 Connexant 2388x chip and the ZL10353 demodulator,
113 successor to the Zarlink MT352.
114
115config VIDEO_CX88_DVB_OR51132
116 bool "OR51132 ATSC Support"
117 default y
118 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
119 select DVB_OR51132
120 ---help---
121 This adds ATSC 8VSB and QAM64/256 support for cards based on the
122 Connexant 2388x chip and the OR51132 demodulator.
123
124config VIDEO_CX88_DVB_CX22702
125 bool "Conexant CX22702 DVB-T Support"
126 default y
127 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
128 select DVB_CX22702
129 ---help---
130 This adds DVB-T support for cards based on the
131 Connexant 2388x chip and the CX22702 demodulator.
132
133config VIDEO_CX88_DVB_LGDT330X
134 bool "LG Electronics DT3302/DT3303 ATSC Support"
135 default y
136 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
137 select DVB_LGDT330X
138 ---help---
139 This adds ATSC 8VSB and QAM64/256 support for cards based on the
140 Connexant 2388x chip and the LGDT3302/LGDT3303 demodulator.
141
142config VIDEO_CX88_DVB_NXT200X
143 bool "NXT2002/NXT2004 ATSC Support"
144 default y
145 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
146 select DVB_NXT200X
147 ---help---
148 This adds ATSC 8VSB and QAM64/256 support for cards based on the
149 Connexant 2388x chip and the NXT2002/NXT2004 demodulator.
150
151config VIDEO_CX88_DVB_CX24123
152 bool "Conexant CX24123 DVB-S Support"
153 default y
154 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
155 select DVB_CX24123
156 select DVB_ISL6421
157 ---help---
158 This adds DVB-S support for cards based on the
159 Connexant 2388x chip and the CX24123 demodulator.
diff --git a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
index 352b919f30c4..639c3b659d0e 100644
--- a/drivers/media/video/cx88/Makefile
+++ b/drivers/media/video/cx88/Makefile
@@ -14,13 +14,6 @@ EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
14EXTRA_CFLAGS += -Idrivers/media/dvb/frontends 14EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
15 15
16extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1 16extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
17extra-cflags-$(CONFIG_DVB_CX22702) += -DHAVE_CX22702=1
18extra-cflags-$(CONFIG_DVB_OR51132) += -DHAVE_OR51132=1
19extra-cflags-$(CONFIG_DVB_LGDT330X) += -DHAVE_LGDT330X=1
20extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
21extra-cflags-$(CONFIG_DVB_ZL10353) += -DHAVE_ZL10353=1
22extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
23extra-cflags-$(CONFIG_DVB_CX24123) += -DHAVE_CX24123=1
24extra-cflags-$(CONFIG_VIDEO_CX88_VP3054)+= -DHAVE_VP3054_I2C=1 17extra-cflags-$(CONFIG_VIDEO_CX88_VP3054)+= -DHAVE_VP3054_I2C=1
25 18
26EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m) 19EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index b60177f173c3..a7921f9d45d8 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1160,8 +1160,10 @@ static struct pci_driver blackbird_pci_driver = {
1160 .id_table = cx8802_pci_tbl, 1160 .id_table = cx8802_pci_tbl,
1161 .probe = blackbird_probe, 1161 .probe = blackbird_probe,
1162 .remove = __devexit_p(blackbird_remove), 1162 .remove = __devexit_p(blackbird_remove),
1163#ifdef CONFIG_PM
1163 .suspend = cx8802_suspend_common, 1164 .suspend = cx8802_suspend_common,
1164 .resume = cx8802_resume_common, 1165 .resume = cx8802_resume_common,
1166#endif
1165}; 1167};
1166 1168
1167static int blackbird_init(void) 1169static int blackbird_init(void)
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index 14bd4863d157..6214eb823b29 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1041,11 +1041,11 @@ struct cx88_board cx88_boards[] = {
1041 .input = {{ 1041 .input = {{
1042 .type = CX88_VMUX_COMPOSITE1, 1042 .type = CX88_VMUX_COMPOSITE1,
1043 .vmux = 1, 1043 .vmux = 1,
1044 .gpio0 = 0x000027df, 1044 .gpio0 = 0x000067df,
1045 },{ 1045 },{
1046 .type = CX88_VMUX_SVIDEO, 1046 .type = CX88_VMUX_SVIDEO,
1047 .vmux = 2, 1047 .vmux = 2,
1048 .gpio0 = 0x000027df, 1048 .gpio0 = 0x000067df,
1049 }}, 1049 }},
1050 .dvb = 1, 1050 .dvb = 1,
1051 }, 1051 },
@@ -1209,6 +1209,100 @@ struct cx88_board cx88_boards[] = {
1209 }}, 1209 }},
1210 .dvb = 1, 1210 .dvb = 1,
1211 }, 1211 },
1212 [CX88_BOARD_HAUPPAUGE_HVR3000] = {
1213 /* FIXME: Add dvb & radio support */
1214 .name = "Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T",
1215 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3,
1216 .radio_type = UNSET,
1217 .tuner_addr = ADDR_UNSET,
1218 .radio_addr = ADDR_UNSET,
1219 .tda9887_conf = TDA9887_PRESENT,
1220 .input = {{
1221 .type = CX88_VMUX_TELEVISION,
1222 .vmux = 0,
1223 .gpio0 = 0x84bf,
1224 },{
1225 .type = CX88_VMUX_COMPOSITE1,
1226 .vmux = 1,
1227 .gpio0 = 0x84bf,
1228 },{
1229 .type = CX88_VMUX_SVIDEO,
1230 .vmux = 2,
1231 .gpio0 = 0x84bf,
1232 }},
1233 },
1234 [CX88_BOARD_NORWOOD_MICRO] = {
1235 .name = "Norwood Micro TV Tuner",
1236 .tuner_type = TUNER_TNF_5335MF,
1237 .radio_type = UNSET,
1238 .tuner_addr = ADDR_UNSET,
1239 .radio_addr = ADDR_UNSET,
1240 .input = {{
1241 .type = CX88_VMUX_TELEVISION,
1242 .vmux = 0,
1243 .gpio0 = 0x0709,
1244 },{
1245 .type = CX88_VMUX_COMPOSITE1,
1246 .vmux = 1,
1247 .gpio0 = 0x070b,
1248 },{
1249 .type = CX88_VMUX_SVIDEO,
1250 .vmux = 2,
1251 .gpio0 = 0x070b,
1252 }},
1253 },
1254 [CX88_BOARD_TE_DTV_250_OEM_SWANN] = {
1255 .name = "Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM",
1256 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
1257 .radio_type = UNSET,
1258 .tuner_addr = ADDR_UNSET,
1259 .radio_addr = ADDR_UNSET,
1260 .input = {{
1261 .type = CX88_VMUX_TELEVISION,
1262 .vmux = 0,
1263 .gpio0 = 0x003fffff,
1264 .gpio1 = 0x00e00000,
1265 .gpio2 = 0x003fffff,
1266 .gpio3 = 0x02000000,
1267 },{
1268 .type = CX88_VMUX_COMPOSITE1,
1269 .vmux = 1,
1270 .gpio0 = 0x003fffff,
1271 .gpio1 = 0x00e00000,
1272 .gpio2 = 0x003fffff,
1273 .gpio3 = 0x02000000,
1274 },{
1275 .type = CX88_VMUX_SVIDEO,
1276 .vmux = 2,
1277 .gpio0 = 0x003fffff,
1278 .gpio1 = 0x00e00000,
1279 .gpio2 = 0x003fffff,
1280 .gpio3 = 0x02000000,
1281 }},
1282 },
1283 [CX88_BOARD_HAUPPAUGE_HVR1300] = {
1284 .name = "Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder",
1285 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3,
1286 .radio_type = UNSET,
1287 .tuner_addr = ADDR_UNSET,
1288 .radio_addr = ADDR_UNSET,
1289 .tda9887_conf = TDA9887_PRESENT,
1290 .input = {{
1291 .type = CX88_VMUX_TELEVISION,
1292 .vmux = 0,
1293 .gpio0 = 0xe780,
1294 },{
1295 .type = CX88_VMUX_COMPOSITE1,
1296 .vmux = 1,
1297 .gpio0 = 0xe780,
1298 },{
1299 .type = CX88_VMUX_SVIDEO,
1300 .vmux = 2,
1301 .gpio0 = 0xe780,
1302 }},
1303 /* fixme: Add radio support */
1304 .dvb = 1,
1305 },
1212}; 1306};
1213const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); 1307const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
1214 1308
@@ -1254,7 +1348,7 @@ struct cx88_subid cx88_subids[] = {
1254 .card = CX88_BOARD_LEADTEK_PVR2000, 1348 .card = CX88_BOARD_LEADTEK_PVR2000,
1255 },{ 1349 },{
1256 .subvendor = 0x107d, 1350 .subvendor = 0x107d,
1257 .subdevice = 0x663C, 1351 .subdevice = 0x663c,
1258 .card = CX88_BOARD_LEADTEK_PVR2000, 1352 .card = CX88_BOARD_LEADTEK_PVR2000,
1259 },{ 1353 },{
1260 .subvendor = 0x1461, 1354 .subvendor = 0x1461,
@@ -1458,6 +1552,35 @@ struct cx88_subid cx88_subids[] = {
1458 .subvendor = 0x14f1, 1552 .subvendor = 0x14f1,
1459 .subdevice = 0x0084, 1553 .subdevice = 0x0084,
1460 .card = CX88_BOARD_GENIATECH_DVBS, 1554 .card = CX88_BOARD_GENIATECH_DVBS,
1555 },{
1556 .subvendor = 0x0070,
1557 .subdevice = 0x1404,
1558 .card = CX88_BOARD_HAUPPAUGE_HVR3000,
1559 },{
1560 .subvendor = 0x1461,
1561 .subdevice = 0xc111, /* AverMedia M150-D */
1562 /* This board is known to work with the ASUS PVR416 config */
1563 .card = CX88_BOARD_ASUS_PVR_416,
1564 },{
1565 .subvendor = 0xc180,
1566 .subdevice = 0xc980,
1567 .card = CX88_BOARD_TE_DTV_250_OEM_SWANN,
1568 },{
1569 .subvendor = 0x0070,
1570 .subdevice = 0x9600,
1571 .card = CX88_BOARD_HAUPPAUGE_HVR1300,
1572 },{
1573 .subvendor = 0x0070,
1574 .subdevice = 0x9601,
1575 .card = CX88_BOARD_HAUPPAUGE_HVR1300,
1576 },{
1577 .subvendor = 0x0070,
1578 .subdevice = 0x9602,
1579 .card = CX88_BOARD_HAUPPAUGE_HVR1300,
1580 },{
1581 .subvendor = 0x107d,
1582 .subdevice = 0x6632,
1583 .card = CX88_BOARD_LEADTEK_PVR2000,
1461 }, 1584 },
1462}; 1585};
1463const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 1586const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
@@ -1501,6 +1624,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1501 /* Make sure we support the board model */ 1624 /* Make sure we support the board model */
1502 switch (tv.model) 1625 switch (tv.model)
1503 { 1626 {
1627 case 14569: /* WinTV-HVR3000 (OEM, no IR, no back panel video) */
1504 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */ 1628 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */
1505 case 34519: /* WinTV-PCI-FM */ 1629 case 34519: /* WinTV-PCI-FM */
1506 case 90002: /* Nova-T-PCI (9002) */ 1630 case 90002: /* Nova-T-PCI (9002) */
@@ -1512,6 +1636,11 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1512 case 92000: /* Nova-SE2 (OEM, No Video or IR) */ 1636 case 92000: /* Nova-SE2 (OEM, No Video or IR) */
1513 case 94009: /* WinTV-HVR1100 (Video and IR Retail) */ 1637 case 94009: /* WinTV-HVR1100 (Video and IR Retail) */
1514 case 94501: /* WinTV-HVR1100 (Video and IR OEM) */ 1638 case 94501: /* WinTV-HVR1100 (Video and IR OEM) */
1639 case 96009: /* WinTV-HVR1300 (PAL Video, MPEG Video and IR RX) */
1640 case 96019: /* WinTV-HVR1300 (PAL Video, MPEG Video and IR RX/TX) */
1641 case 96559: /* WinTV-HVR1300 (PAL Video, MPEG Video no IR) */
1642 case 96569: /* WinTV-HVR1300 () */
1643 case 96659: /* WinTV-HVR1300 () */
1515 case 98559: /* WinTV-HVR1100LP (Video no IR, Retail - Low Profile) */ 1644 case 98559: /* WinTV-HVR1100LP (Video no IR, Retail - Low Profile) */
1516 /* known */ 1645 /* known */
1517 break; 1646 break;
@@ -1638,6 +1767,22 @@ void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
1638 core->name, i, cx88_boards[i].name); 1767 core->name, i, cx88_boards[i].name);
1639} 1768}
1640 1769
1770void cx88_card_setup_pre_i2c(struct cx88_core *core)
1771{
1772 switch (core->board) {
1773 case CX88_BOARD_HAUPPAUGE_HVR1300:
1774 /* Bring the 702 demod up before i2c scanning/attach or devices are hidden */
1775 /* We leave here with the 702 on the bus */
1776 cx_write(MO_GP0_IO, 0x0000e780);
1777 udelay(1000);
1778 cx_clear(MO_GP0_IO, 0x00000080);
1779 udelay(50);
1780 cx_set(MO_GP0_IO, 0x00000080); /* 702 out of reset */
1781 udelay(1000);
1782 break;
1783 }
1784}
1785
1641void cx88_card_setup(struct cx88_core *core) 1786void cx88_card_setup(struct cx88_core *core)
1642{ 1787{
1643 static u8 eeprom[256]; 1788 static u8 eeprom[256];
@@ -1666,6 +1811,8 @@ void cx88_card_setup(struct cx88_core *core)
1666 case CX88_BOARD_HAUPPAUGE_DVB_T1: 1811 case CX88_BOARD_HAUPPAUGE_DVB_T1:
1667 case CX88_BOARD_HAUPPAUGE_HVR1100: 1812 case CX88_BOARD_HAUPPAUGE_HVR1100:
1668 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 1813 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
1814 case CX88_BOARD_HAUPPAUGE_HVR3000:
1815 case CX88_BOARD_HAUPPAUGE_HVR1300:
1669 if (0 == core->i2c_rc) 1816 if (0 == core->i2c_rc)
1670 hauppauge_eeprom(core,eeprom); 1817 hauppauge_eeprom(core,eeprom);
1671 break; 1818 break;
@@ -1673,9 +1820,15 @@ void cx88_card_setup(struct cx88_core *core)
1673 cx_write(MO_GP0_IO, 0x000007f8); 1820 cx_write(MO_GP0_IO, 0x000007f8);
1674 cx_write(MO_GP1_IO, 0x00000001); 1821 cx_write(MO_GP1_IO, 0x00000001);
1675 break; 1822 break;
1823 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
1824 /* GPIO0:6 is hooked to FX2 reset pin */
1825 cx_set(MO_GP0_IO, 0x00004040);
1826 cx_clear(MO_GP0_IO, 0x00000040);
1827 msleep(1000);
1828 cx_set(MO_GP0_IO, 0x00004040);
1829 /* FALLTHROUGH */
1676 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 1830 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
1677 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 1831 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
1678 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
1679 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 1832 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
1680 /* GPIO0:0 is hooked to mt352 reset pin */ 1833 /* GPIO0:0 is hooked to mt352 reset pin */
1681 cx_set(MO_GP0_IO, 0x00000101); 1834 cx_set(MO_GP0_IO, 0x00000101);
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 973d3f39b2d5..f379ede3049a 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -105,7 +105,7 @@ static u32* cx88_risc_field(u32 *rp, struct scatterlist *sglist,
105 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); 105 *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
106 offset+=bpl; 106 offset+=bpl;
107 } else { 107 } else {
108 /* scanline needs to be splitted */ 108 /* scanline needs to be split */
109 todo = bpl; 109 todo = bpl;
110 *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL| 110 *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL|
111 (sg_dma_len(sg)-offset)); 111 (sg_dma_len(sg)-offset));
@@ -792,6 +792,11 @@ int cx88_start_audio_dma(struct cx88_core *core)
792{ 792{
793 /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */ 793 /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */
794 int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4; 794 int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4;
795
796 /* If downstream RISC is enabled, bail out; ALSA is managing DMA */
797 if (cx_read(MO_AUD_DMACNTRL) & 0x10)
798 return 0;
799
795 /* setup fifo + format */ 800 /* setup fifo + format */
796 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], bpl, 0); 801 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], bpl, 0);
797 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], bpl, 0); 802 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], bpl, 0);
@@ -801,11 +806,16 @@ int cx88_start_audio_dma(struct cx88_core *core)
801 806
802 /* start dma */ 807 /* start dma */
803 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */ 808 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */
809
804 return 0; 810 return 0;
805} 811}
806 812
807int cx88_stop_audio_dma(struct cx88_core *core) 813int cx88_stop_audio_dma(struct cx88_core *core)
808{ 814{
815 /* If downstream RISC is enabled, bail out; ALSA is managing DMA */
816 if (cx_read(MO_AUD_DMACNTRL) & 0x10)
817 return 0;
818
809 /* stop dma */ 819 /* stop dma */
810 cx_write(MO_AUD_DMACNTRL, 0x0000); 820 cx_write(MO_AUD_DMACNTRL, 0x0000);
811 821
@@ -1123,6 +1133,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1123 1133
1124 /* init hardware */ 1134 /* init hardware */
1125 cx88_reset(core); 1135 cx88_reset(core);
1136 cx88_card_setup_pre_i2c(core);
1126 cx88_i2c_init(core,pci); 1137 cx88_i2c_init(core,pci);
1127 cx88_call_i2c_clients (core, TUNER_SET_STANDBY, NULL); 1138 cx88_call_i2c_clients (core, TUNER_SET_STANDBY, NULL);
1128 cx88_card_setup(core); 1139 cx88_card_setup(core);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index afde3789d702..c87041dee21e 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -33,32 +33,18 @@
33#include "dvb-pll.h" 33#include "dvb-pll.h"
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35 35
36#ifdef HAVE_MT352 36#include "mt352.h"
37# include "mt352.h" 37#include "mt352_priv.h"
38# include "mt352_priv.h" 38#ifdef HAVE_VP3054_I2C
39# ifdef HAVE_VP3054_I2C 39# include "cx88-vp3054-i2c.h"
40# include "cx88-vp3054-i2c.h"
41# endif
42#endif
43#ifdef HAVE_ZL10353
44# include "zl10353.h"
45#endif
46#ifdef HAVE_CX22702
47# include "cx22702.h"
48#endif
49#ifdef HAVE_OR51132
50# include "or51132.h"
51#endif
52#ifdef HAVE_LGDT330X
53# include "lgdt330x.h"
54# include "lg_h06xf.h"
55#endif
56#ifdef HAVE_NXT200X
57# include "nxt200x.h"
58#endif
59#ifdef HAVE_CX24123
60# include "cx24123.h"
61#endif 40#endif
41#include "zl10353.h"
42#include "cx22702.h"
43#include "or51132.h"
44#include "lgdt330x.h"
45#include "lg_h06xf.h"
46#include "nxt200x.h"
47#include "cx24123.h"
62#include "isl6421.h" 48#include "isl6421.h"
63 49
64MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); 50MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
@@ -114,8 +100,6 @@ static struct videobuf_queue_ops dvb_qops = {
114}; 100};
115 101
116/* ------------------------------------------------------------------ */ 102/* ------------------------------------------------------------------ */
117
118#ifdef HAVE_MT352
119static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) 103static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
120{ 104{
121 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; 105 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
@@ -181,7 +165,7 @@ static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
181} 165}
182 166
183static struct mt352_config dvico_fusionhdtv = { 167static struct mt352_config dvico_fusionhdtv = {
184 .demod_address = 0x0F, 168 .demod_address = 0x0f,
185 .demod_init = dvico_fusionhdtv_demod_init, 169 .demod_init = dvico_fusionhdtv_demod_init,
186}; 170};
187 171
@@ -191,7 +175,7 @@ static struct mt352_config dntv_live_dvbt_config = {
191}; 175};
192 176
193static struct mt352_config dvico_fusionhdtv_dual = { 177static struct mt352_config dvico_fusionhdtv_dual = {
194 .demod_address = 0x0F, 178 .demod_address = 0x0f,
195 .demod_init = dvico_dual_demod_init, 179 .demod_init = dvico_dual_demod_init,
196}; 180};
197 181
@@ -266,8 +250,8 @@ static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
266 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 250 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
267 251
268 printk(KERN_WARNING "cx88-dvb: %s error " 252 printk(KERN_WARNING "cx88-dvb: %s error "
269 "(addr %02x <- %02x, err = %i)\n", 253 "(addr %02x <- %02x, err = %i)\n",
270 __FUNCTION__, dev->core->pll_addr, buf[0], err); 254 __FUNCTION__, dev->core->pll_addr, buf[0], err);
271 if (err < 0) 255 if (err < 0)
272 return err; 256 return err;
273 else 257 else
@@ -283,9 +267,7 @@ static struct mt352_config dntv_live_dvbt_pro_config = {
283 .demod_init = dntv_live_dvbt_pro_demod_init, 267 .demod_init = dntv_live_dvbt_pro_demod_init,
284}; 268};
285#endif 269#endif
286#endif
287 270
288#ifdef HAVE_ZL10353
289static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe, 271static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe,
290 struct dvb_frontend_parameters *params) 272 struct dvb_frontend_parameters *params)
291{ 273{
@@ -304,8 +286,8 @@ static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe,
304 fe->ops.i2c_gate_ctrl(fe, 1); 286 fe->ops.i2c_gate_ctrl(fe, 1);
305 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) { 287 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
306 printk(KERN_WARNING "cx88-dvb: %s error " 288 printk(KERN_WARNING "cx88-dvb: %s error "
307 "(addr %02x <- %02x, err = %i)\n", 289 "(addr %02x <- %02x, err = %i)\n",
308 __FUNCTION__, pllbuf[0], pllbuf[1], err); 290 __FUNCTION__, pllbuf[0], pllbuf[1], err);
309 if (err < 0) 291 if (err < 0)
310 return err; 292 return err;
311 else 293 else
@@ -316,16 +298,14 @@ static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe,
316} 298}
317 299
318static struct zl10353_config dvico_fusionhdtv_hybrid = { 300static struct zl10353_config dvico_fusionhdtv_hybrid = {
319 .demod_address = 0x0F, 301 .demod_address = 0x0f,
320 .no_tuner = 1, 302 .no_tuner = 1,
321}; 303};
322 304
323static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = { 305static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
324 .demod_address = 0x0F, 306 .demod_address = 0x0f,
325}; 307};
326#endif
327 308
328#ifdef HAVE_CX22702
329static struct cx22702_config connexant_refboard_config = { 309static struct cx22702_config connexant_refboard_config = {
330 .demod_address = 0x43, 310 .demod_address = 0x43,
331 .output_mode = CX22702_SERIAL_OUTPUT, 311 .output_mode = CX22702_SERIAL_OUTPUT,
@@ -339,9 +319,11 @@ static struct cx22702_config hauppauge_hvr1100_config = {
339 .demod_address = 0x63, 319 .demod_address = 0x63,
340 .output_mode = CX22702_SERIAL_OUTPUT, 320 .output_mode = CX22702_SERIAL_OUTPUT,
341}; 321};
342#endif 322static struct cx22702_config hauppauge_hvr1300_config = {
323 .demod_address = 0x63,
324 .output_mode = CX22702_SERIAL_OUTPUT,
325};
343 326
344#ifdef HAVE_OR51132
345static int or51132_set_ts_param(struct dvb_frontend* fe, 327static int or51132_set_ts_param(struct dvb_frontend* fe,
346 int is_punctured) 328 int is_punctured)
347{ 329{
@@ -351,12 +333,10 @@ static int or51132_set_ts_param(struct dvb_frontend* fe,
351} 333}
352 334
353static struct or51132_config pchdtv_hd3000 = { 335static struct or51132_config pchdtv_hd3000 = {
354 .demod_address = 0x15, 336 .demod_address = 0x15,
355 .set_ts_params = or51132_set_ts_param, 337 .set_ts_params = or51132_set_ts_param,
356}; 338};
357#endif
358 339
359#ifdef HAVE_LGDT330X
360static int lgdt3302_tuner_set_params(struct dvb_frontend* fe, 340static int lgdt3302_tuner_set_params(struct dvb_frontend* fe,
361 struct dvb_frontend_parameters* params) 341 struct dvb_frontend_parameters* params)
362{ 342{
@@ -373,14 +353,14 @@ static int lgdt3302_tuner_set_params(struct dvb_frontend* fe,
373 353
374 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0); 354 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0);
375 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", 355 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
376 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); 356 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]);
377 357
378 if (fe->ops.i2c_gate_ctrl) 358 if (fe->ops.i2c_gate_ctrl)
379 fe->ops.i2c_gate_ctrl(fe, 1); 359 fe->ops.i2c_gate_ctrl(fe, 1);
380 if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) { 360 if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) {
381 printk(KERN_WARNING "cx88-dvb: %s error " 361 printk(KERN_WARNING "cx88-dvb: %s error "
382 "(addr %02x <- %02x, err = %i)\n", 362 "(addr %02x <- %02x, err = %i)\n",
383 __FUNCTION__, buf[0], buf[1], err); 363 __FUNCTION__, buf[0], buf[1], err);
384 if (err < 0) 364 if (err < 0)
385 return err; 365 return err;
386 else 366 else
@@ -425,28 +405,26 @@ static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
425} 405}
426 406
427static struct lgdt330x_config fusionhdtv_3_gold = { 407static struct lgdt330x_config fusionhdtv_3_gold = {
428 .demod_address = 0x0e, 408 .demod_address = 0x0e,
429 .demod_chip = LGDT3302, 409 .demod_chip = LGDT3302,
430 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */ 410 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
431 .set_ts_params = lgdt330x_set_ts_param, 411 .set_ts_params = lgdt330x_set_ts_param,
432}; 412};
433 413
434static struct lgdt330x_config fusionhdtv_5_gold = { 414static struct lgdt330x_config fusionhdtv_5_gold = {
435 .demod_address = 0x0e, 415 .demod_address = 0x0e,
436 .demod_chip = LGDT3303, 416 .demod_chip = LGDT3303,
437 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ 417 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
438 .set_ts_params = lgdt330x_set_ts_param, 418 .set_ts_params = lgdt330x_set_ts_param,
439}; 419};
440 420
441static struct lgdt330x_config pchdtv_hd5500 = { 421static struct lgdt330x_config pchdtv_hd5500 = {
442 .demod_address = 0x59, 422 .demod_address = 0x59,
443 .demod_chip = LGDT3303, 423 .demod_chip = LGDT3303,
444 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */ 424 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
445 .set_ts_params = lgdt330x_set_ts_param, 425 .set_ts_params = lgdt330x_set_ts_param,
446}; 426};
447#endif
448 427
449#ifdef HAVE_NXT200X
450static int nxt200x_set_ts_param(struct dvb_frontend* fe, 428static int nxt200x_set_ts_param(struct dvb_frontend* fe,
451 int is_punctured) 429 int is_punctured)
452{ 430{
@@ -465,28 +443,27 @@ static int nxt200x_set_pll_input(u8* buf, int input)
465} 443}
466 444
467static struct nxt200x_config ati_hdtvwonder = { 445static struct nxt200x_config ati_hdtvwonder = {
468 .demod_address = 0x0a, 446 .demod_address = 0x0a,
469 .set_pll_input = nxt200x_set_pll_input, 447 .set_pll_input = nxt200x_set_pll_input,
470 .set_ts_params = nxt200x_set_ts_param, 448 .set_ts_params = nxt200x_set_ts_param,
471}; 449};
472#endif
473 450
474#ifdef HAVE_CX24123
475static int cx24123_set_ts_param(struct dvb_frontend* fe, 451static int cx24123_set_ts_param(struct dvb_frontend* fe,
476 int is_punctured) 452 int is_punctured)
477{ 453{
478 struct cx8802_dev *dev= fe->dvb->priv; 454 struct cx8802_dev *dev= fe->dvb->priv;
479 dev->ts_gen_cntrl = 0x2; 455 dev->ts_gen_cntrl = 0x02;
480 return 0; 456 return 0;
481} 457}
482 458
483static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 459static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
460 fe_sec_voltage_t voltage)
484{ 461{
485 struct cx8802_dev *dev= fe->dvb->priv; 462 struct cx8802_dev *dev= fe->dvb->priv;
486 struct cx88_core *core = dev->core; 463 struct cx88_core *core = dev->core;
487 464
488 if (voltage == SEC_VOLTAGE_OFF) { 465 if (voltage == SEC_VOLTAGE_OFF) {
489 cx_write(MO_GP0_IO, 0x000006fB); 466 cx_write(MO_GP0_IO, 0x000006fb);
490 } else { 467 } else {
491 cx_write(MO_GP0_IO, 0x000006f9); 468 cx_write(MO_GP0_IO, 0x000006f9);
492 } 469 }
@@ -496,7 +473,8 @@ static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t
496 return 0; 473 return 0;
497} 474}
498 475
499static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 476static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
477 fe_sec_voltage_t voltage)
500{ 478{
501 struct cx8802_dev *dev= fe->dvb->priv; 479 struct cx8802_dev *dev= fe->dvb->priv;
502 struct cx88_core *core = dev->core; 480 struct cx88_core *core = dev->core;
@@ -512,20 +490,20 @@ static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t
512} 490}
513 491
514static struct cx24123_config geniatech_dvbs_config = { 492static struct cx24123_config geniatech_dvbs_config = {
515 .demod_address = 0x55, 493 .demod_address = 0x55,
516 .set_ts_params = cx24123_set_ts_param, 494 .set_ts_params = cx24123_set_ts_param,
517}; 495};
518 496
519static struct cx24123_config hauppauge_novas_config = { 497static struct cx24123_config hauppauge_novas_config = {
520 .demod_address = 0x55, 498 .demod_address = 0x55,
521 .set_ts_params = cx24123_set_ts_param, 499 .set_ts_params = cx24123_set_ts_param,
522}; 500};
523 501
524static struct cx24123_config kworld_dvbs_100_config = { 502static struct cx24123_config kworld_dvbs_100_config = {
525 .demod_address = 0x15, 503 .demod_address = 0x15,
526 .set_ts_params = cx24123_set_ts_param, 504 .set_ts_params = cx24123_set_ts_param,
505 .lnb_polarity = 1,
527}; 506};
528#endif
529 507
530static int dvb_register(struct cx8802_dev *dev) 508static int dvb_register(struct cx8802_dev *dev)
531{ 509{
@@ -535,114 +513,114 @@ static int dvb_register(struct cx8802_dev *dev)
535 513
536 /* init frontend */ 514 /* init frontend */
537 switch (dev->core->board) { 515 switch (dev->core->board) {
538#ifdef HAVE_CX22702
539 case CX88_BOARD_HAUPPAUGE_DVB_T1: 516 case CX88_BOARD_HAUPPAUGE_DVB_T1:
540 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config, 517 dev->dvb.frontend = dvb_attach(cx22702_attach,
541 &dev->core->i2c_adap); 518 &hauppauge_novat_config,
519 &dev->core->i2c_adap);
542 if (dev->dvb.frontend != NULL) { 520 if (dev->dvb.frontend != NULL) {
543 dvb_pll_attach(dev->dvb.frontend, 0x61, 521 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
544 &dev->core->i2c_adap, 522 &dev->core->i2c_adap,
545 &dvb_pll_thomson_dtt759x); 523 &dvb_pll_thomson_dtt759x);
546 } 524 }
547 break; 525 break;
548 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 526 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
549 case CX88_BOARD_CONEXANT_DVB_T1: 527 case CX88_BOARD_CONEXANT_DVB_T1:
550 case CX88_BOARD_KWORLD_DVB_T_CX22702: 528 case CX88_BOARD_KWORLD_DVB_T_CX22702:
551 case CX88_BOARD_WINFAST_DTV1000: 529 case CX88_BOARD_WINFAST_DTV1000:
552 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config, 530 dev->dvb.frontend = dvb_attach(cx22702_attach,
553 &dev->core->i2c_adap); 531 &connexant_refboard_config,
532 &dev->core->i2c_adap);
554 if (dev->dvb.frontend != NULL) { 533 if (dev->dvb.frontend != NULL) {
555 dvb_pll_attach(dev->dvb.frontend, 0x60, 534 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
556 &dev->core->i2c_adap, 535 &dev->core->i2c_adap,
557 &dvb_pll_thomson_dtt7579); 536 &dvb_pll_thomson_dtt7579);
558 } 537 }
559 break; 538 break;
560 case CX88_BOARD_WINFAST_DTV2000H: 539 case CX88_BOARD_WINFAST_DTV2000H:
561 case CX88_BOARD_HAUPPAUGE_HVR1100: 540 case CX88_BOARD_HAUPPAUGE_HVR1100:
562 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 541 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
563 dev->dvb.frontend = cx22702_attach(&hauppauge_hvr1100_config, 542 dev->dvb.frontend = dvb_attach(cx22702_attach,
564 &dev->core->i2c_adap); 543 &hauppauge_hvr1100_config,
544 &dev->core->i2c_adap);
565 if (dev->dvb.frontend != NULL) { 545 if (dev->dvb.frontend != NULL) {
566 dvb_pll_attach(dev->dvb.frontend, 0x61, 546 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
567 &dev->core->i2c_adap, 547 &dev->core->i2c_adap,
568 &dvb_pll_fmd1216me); 548 &dvb_pll_fmd1216me);
549 }
550 break;
551 case CX88_BOARD_HAUPPAUGE_HVR1300:
552 dev->dvb.frontend = dvb_attach(cx22702_attach,
553 &hauppauge_hvr1300_config,
554 &dev->core->i2c_adap);
555 if (dev->dvb.frontend != NULL) {
556 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
557 &dev->core->i2c_adap,
558 &dvb_pll_fmd1216me);
569 } 559 }
570 break; 560 break;
571#endif
572#if defined(HAVE_MT352) || defined(HAVE_ZL10353)
573 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 561 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
574#ifdef HAVE_MT352 562 dev->dvb.frontend = dvb_attach(mt352_attach,
575 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, 563 &dvico_fusionhdtv,
576 &dev->core->i2c_adap); 564 &dev->core->i2c_adap);
577 if (dev->dvb.frontend != NULL) { 565 if (dev->dvb.frontend != NULL) {
578 dvb_pll_attach(dev->dvb.frontend, 0x60, 566 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
579 &dev->core->i2c_adap, 567 NULL, &dvb_pll_thomson_dtt7579);
580 &dvb_pll_thomson_dtt7579);
581 break; 568 break;
582 } 569 }
583#endif
584#ifdef HAVE_ZL10353
585 /* ZL10353 replaces MT352 on later cards */ 570 /* ZL10353 replaces MT352 on later cards */
586 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1, 571 dev->dvb.frontend = dvb_attach(zl10353_attach,
587 &dev->core->i2c_adap); 572 &dvico_fusionhdtv_plus_v1_1,
573 &dev->core->i2c_adap);
588 if (dev->dvb.frontend != NULL) { 574 if (dev->dvb.frontend != NULL) {
589 dvb_pll_attach(dev->dvb.frontend, 0x60, 575 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
590 &dev->core->i2c_adap, 576 NULL, &dvb_pll_thomson_dtt7579);
591 &dvb_pll_thomson_dtt7579);
592 } 577 }
593#endif
594 break; 578 break;
595 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 579 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
596#ifdef HAVE_MT352
597 /* The tin box says DEE1601, but it seems to be DTT7579 580 /* The tin box says DEE1601, but it seems to be DTT7579
598 * compatible, with a slightly different MT352 AGC gain. */ 581 * compatible, with a slightly different MT352 AGC gain. */
599 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dual, 582 dev->dvb.frontend = dvb_attach(mt352_attach,
600 &dev->core->i2c_adap); 583 &dvico_fusionhdtv_dual,
584 &dev->core->i2c_adap);
601 if (dev->dvb.frontend != NULL) { 585 if (dev->dvb.frontend != NULL) {
602 dvb_pll_attach(dev->dvb.frontend, 0x61, 586 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
603 &dev->core->i2c_adap, 587 NULL, &dvb_pll_thomson_dtt7579);
604 &dvb_pll_thomson_dtt7579);
605 break; 588 break;
606 } 589 }
607#endif
608#ifdef HAVE_ZL10353
609 /* ZL10353 replaces MT352 on later cards */ 590 /* ZL10353 replaces MT352 on later cards */
610 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1, 591 dev->dvb.frontend = dvb_attach(zl10353_attach,
611 &dev->core->i2c_adap); 592 &dvico_fusionhdtv_plus_v1_1,
593 &dev->core->i2c_adap);
612 if (dev->dvb.frontend != NULL) { 594 if (dev->dvb.frontend != NULL) {
613 dvb_pll_attach(dev->dvb.frontend, 0x61, 595 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
614 &dev->core->i2c_adap, 596 NULL, &dvb_pll_thomson_dtt7579);
615 &dvb_pll_thomson_dtt7579);
616 } 597 }
617#endif
618 break; 598 break;
619#endif /* HAVE_MT352 || HAVE_ZL10353 */
620#ifdef HAVE_MT352
621 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 599 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
622 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, 600 dev->dvb.frontend = dvb_attach(mt352_attach,
623 &dev->core->i2c_adap); 601 &dvico_fusionhdtv,
602 &dev->core->i2c_adap);
624 if (dev->dvb.frontend != NULL) { 603 if (dev->dvb.frontend != NULL) {
625 dvb_pll_attach(dev->dvb.frontend, 0x61, 604 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
626 &dev->core->i2c_adap, 605 NULL, &dvb_pll_lg_z201);
627 &dvb_pll_lg_z201);
628 } 606 }
629 break; 607 break;
630 case CX88_BOARD_KWORLD_DVB_T: 608 case CX88_BOARD_KWORLD_DVB_T:
631 case CX88_BOARD_DNTV_LIVE_DVB_T: 609 case CX88_BOARD_DNTV_LIVE_DVB_T:
632 case CX88_BOARD_ADSTECH_DVB_T_PCI: 610 case CX88_BOARD_ADSTECH_DVB_T_PCI:
633 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, 611 dev->dvb.frontend = dvb_attach(mt352_attach,
634 &dev->core->i2c_adap); 612 &dntv_live_dvbt_config,
613 &dev->core->i2c_adap);
635 if (dev->dvb.frontend != NULL) { 614 if (dev->dvb.frontend != NULL) {
636 dvb_pll_attach(dev->dvb.frontend, 0x61, 615 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
637 &dev->core->i2c_adap, 616 NULL, &dvb_pll_unknown_1);
638 &dvb_pll_unknown_1);
639 } 617 }
640 break; 618 break;
641 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 619 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
642#ifdef HAVE_VP3054_I2C 620#ifdef HAVE_VP3054_I2C
643 dev->core->pll_addr = 0x61; 621 dev->core->pll_addr = 0x61;
644 dev->core->pll_desc = &dvb_pll_fmd1216me; 622 dev->core->pll_desc = &dvb_pll_fmd1216me;
645 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_pro_config, 623 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
646 &((struct vp3054_i2c_state *)dev->card_priv)->adap); 624 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
647 if (dev->dvb.frontend != NULL) { 625 if (dev->dvb.frontend != NULL) {
648 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params; 626 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
@@ -651,30 +629,26 @@ static int dvb_register(struct cx8802_dev *dev)
651 printk("%s: built without vp3054 support\n", dev->core->name); 629 printk("%s: built without vp3054 support\n", dev->core->name);
652#endif 630#endif
653 break; 631 break;
654#endif
655#ifdef HAVE_ZL10353
656 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 632 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
657 dev->core->pll_addr = 0x61; 633 dev->core->pll_addr = 0x61;
658 dev->core->pll_desc = &dvb_pll_thomson_fe6600; 634 dev->core->pll_desc = &dvb_pll_thomson_fe6600;
659 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_hybrid, 635 dev->dvb.frontend = dvb_attach(zl10353_attach,
660 &dev->core->i2c_adap); 636 &dvico_fusionhdtv_hybrid,
637 &dev->core->i2c_adap);
661 if (dev->dvb.frontend != NULL) { 638 if (dev->dvb.frontend != NULL) {
662 dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params; 639 dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params;
663 } 640 }
664 break; 641 break;
665#endif
666#ifdef HAVE_OR51132
667 case CX88_BOARD_PCHDTV_HD3000: 642 case CX88_BOARD_PCHDTV_HD3000:
668 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000, 643 dev->dvb.frontend = dvb_attach(or51132_attach,
669 &dev->core->i2c_adap); 644 &pchdtv_hd3000,
645 &dev->core->i2c_adap);
670 if (dev->dvb.frontend != NULL) { 646 if (dev->dvb.frontend != NULL) {
671 dvb_pll_attach(dev->dvb.frontend, 0x61, 647 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
672 &dev->core->i2c_adap, 648 &dev->core->i2c_adap,
673 &dvb_pll_thomson_dtt761x); 649 &dvb_pll_thomson_dtt761x);
674 } 650 }
675 break; 651 break;
676#endif
677#ifdef HAVE_LGDT330X
678 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: 652 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
679 dev->ts_gen_cntrl = 0x08; 653 dev->ts_gen_cntrl = 0x08;
680 { 654 {
@@ -690,8 +664,9 @@ static int dvb_register(struct cx8802_dev *dev)
690 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 664 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
691 dev->core->pll_addr = 0x61; 665 dev->core->pll_addr = 0x61;
692 dev->core->pll_desc = &dvb_pll_microtune_4042; 666 dev->core->pll_desc = &dvb_pll_microtune_4042;
693 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, 667 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
694 &dev->core->i2c_adap); 668 &fusionhdtv_3_gold,
669 &dev->core->i2c_adap);
695 if (dev->dvb.frontend != NULL) { 670 if (dev->dvb.frontend != NULL) {
696 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params; 671 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
697 } 672 }
@@ -709,8 +684,9 @@ static int dvb_register(struct cx8802_dev *dev)
709 mdelay(200); 684 mdelay(200);
710 dev->core->pll_addr = 0x61; 685 dev->core->pll_addr = 0x61;
711 dev->core->pll_desc = &dvb_pll_thomson_dtt761x; 686 dev->core->pll_desc = &dvb_pll_thomson_dtt761x;
712 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, 687 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
713 &dev->core->i2c_adap); 688 &fusionhdtv_3_gold,
689 &dev->core->i2c_adap);
714 if (dev->dvb.frontend != NULL) { 690 if (dev->dvb.frontend != NULL) {
715 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params; 691 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
716 } 692 }
@@ -726,8 +702,9 @@ static int dvb_register(struct cx8802_dev *dev)
726 mdelay(100); 702 mdelay(100);
727 cx_set(MO_GP0_IO, 1); 703 cx_set(MO_GP0_IO, 1);
728 mdelay(200); 704 mdelay(200);
729 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold, 705 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
730 &dev->core->i2c_adap); 706 &fusionhdtv_5_gold,
707 &dev->core->i2c_adap);
731 if (dev->dvb.frontend != NULL) { 708 if (dev->dvb.frontend != NULL) {
732 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; 709 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
733 } 710 }
@@ -743,52 +720,51 @@ static int dvb_register(struct cx8802_dev *dev)
743 mdelay(100); 720 mdelay(100);
744 cx_set(MO_GP0_IO, 1); 721 cx_set(MO_GP0_IO, 1);
745 mdelay(200); 722 mdelay(200);
746 dev->dvb.frontend = lgdt330x_attach(&pchdtv_hd5500, 723 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
747 &dev->core->i2c_adap); 724 &pchdtv_hd5500,
725 &dev->core->i2c_adap);
748 if (dev->dvb.frontend != NULL) { 726 if (dev->dvb.frontend != NULL) {
749 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; 727 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
750 } 728 }
751 } 729 }
752 break; 730 break;
753#endif
754#ifdef HAVE_NXT200X
755 case CX88_BOARD_ATI_HDTVWONDER: 731 case CX88_BOARD_ATI_HDTVWONDER:
756 dev->dvb.frontend = nxt200x_attach(&ati_hdtvwonder, 732 dev->dvb.frontend = dvb_attach(nxt200x_attach,
757 &dev->core->i2c_adap); 733 &ati_hdtvwonder,
734 &dev->core->i2c_adap);
758 if (dev->dvb.frontend != NULL) { 735 if (dev->dvb.frontend != NULL) {
759 dvb_pll_attach(dev->dvb.frontend, 0x61, 736 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
760 &dev->core->i2c_adap, 737 NULL, &dvb_pll_tuv1236d);
761 &dvb_pll_tuv1236d);
762 } 738 }
763 break; 739 break;
764#endif
765#ifdef HAVE_CX24123
766 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 740 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
767 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 741 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
768 dev->dvb.frontend = cx24123_attach(&hauppauge_novas_config, 742 dev->dvb.frontend = dvb_attach(cx24123_attach,
769 &dev->core->i2c_adap); 743 &hauppauge_novas_config,
744 &dev->core->i2c_adap);
770 if (dev->dvb.frontend) { 745 if (dev->dvb.frontend) {
771 isl6421_attach(dev->dvb.frontend, &dev->core->i2c_adap, 746 dvb_attach(isl6421_attach, dev->dvb.frontend,
772 0x08, 0x00, 0x00); 747 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
773 } 748 }
774 break; 749 break;
775 case CX88_BOARD_KWORLD_DVBS_100: 750 case CX88_BOARD_KWORLD_DVBS_100:
776 dev->dvb.frontend = cx24123_attach(&kworld_dvbs_100_config, 751 dev->dvb.frontend = dvb_attach(cx24123_attach,
777 &dev->core->i2c_adap); 752 &kworld_dvbs_100_config,
753 &dev->core->i2c_adap);
778 if (dev->dvb.frontend) { 754 if (dev->dvb.frontend) {
779 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 755 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
780 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 756 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
781 } 757 }
782 break; 758 break;
783 case CX88_BOARD_GENIATECH_DVBS: 759 case CX88_BOARD_GENIATECH_DVBS:
784 dev->dvb.frontend = cx24123_attach(&geniatech_dvbs_config, 760 dev->dvb.frontend = dvb_attach(cx24123_attach,
785 &dev->core->i2c_adap); 761 &geniatech_dvbs_config,
762 &dev->core->i2c_adap);
786 if (dev->dvb.frontend) { 763 if (dev->dvb.frontend) {
787 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 764 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
788 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; 765 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
789 } 766 }
790 break; 767 break;
791#endif
792 default: 768 default:
793 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", 769 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
794 dev->core->name); 770 dev->core->name);
@@ -908,8 +884,10 @@ static struct pci_driver dvb_pci_driver = {
908 .id_table = cx8802_pci_tbl, 884 .id_table = cx8802_pci_tbl,
909 .probe = dvb_probe, 885 .probe = dvb_probe,
910 .remove = __devexit_p(dvb_remove), 886 .remove = __devexit_p(dvb_remove),
887#ifdef CONFIG_PM
911 .suspend = cx8802_suspend_common, 888 .suspend = cx8802_suspend_common,
912 .resume = cx8802_resume_common, 889 .resume = cx8802_resume_common,
890#endif
913}; 891};
914 892
915static int dvb_init(void) 893static int dvb_init(void)
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 7bea34714861..27b5dbb2ca1a 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -7,6 +7,9 @@
7 (c) 2002 Yurij Sysoev <yurij@naturesoft.net> 7 (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
8 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org> 8 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
9 9
10 (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
11 - Multituner support and i2c address binding
12
10 This program is free software; you can redistribute it and/or modify 13 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by 14 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or 15 the Free Software Foundation; either version 2 of the License, or
@@ -40,6 +43,11 @@ static unsigned int i2c_scan = 0;
40module_param(i2c_scan, int, 0444); 43module_param(i2c_scan, int, 0444);
41MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 44MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
42 45
46static unsigned int i2c_udelay = 5;
47module_param(i2c_udelay, int, 0644);
48MODULE_PARM_DESC(i2c_udelay,"i2c delay at insmod time, in usecs "
49 "(should be 5 or higher). Lower value means higher bus speed.");
50
43#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \ 51#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \
44 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg) 52 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
45 53
@@ -198,6 +206,11 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
198/* init + register i2c algo-bit adapter */ 206/* init + register i2c algo-bit adapter */
199int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) 207int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
200{ 208{
209 /* Prevents usage of invalid delay values */
210 if (i2c_udelay<5)
211 i2c_udelay=5;
212 cx8800_i2c_algo_template.udelay=i2c_udelay;
213
201 memcpy(&core->i2c_adap, &cx8800_i2c_adap_template, 214 memcpy(&core->i2c_adap, &cx8800_i2c_adap_template,
202 sizeof(core->i2c_adap)); 215 sizeof(core->i2c_adap));
203 memcpy(&core->i2c_algo, &cx8800_i2c_algo_template, 216 memcpy(&core->i2c_algo, &cx8800_i2c_algo_template,
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index c25564648993..83ebf7a3c054 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -107,7 +107,15 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
107 (gpio & ir->mask_keydown) ? " down" : "", 107 (gpio & ir->mask_keydown) ? " down" : "",
108 (gpio & ir->mask_keyup) ? " up" : ""); 108 (gpio & ir->mask_keyup) ? " up" : "");
109 109
110 if (ir->mask_keydown) { 110 if (ir->core->board == CX88_BOARD_NORWOOD_MICRO) {
111 u32 gpio_key = cx_read(MO_GP0_IO);
112
113 data = (data << 4) | ((gpio_key & 0xf0) >> 4);
114
115 ir_input_keydown(ir->input, &ir->ir, data, data);
116 ir_input_nokey(ir->input, &ir->ir);
117
118 } else if (ir->mask_keydown) {
111 /* bit set on keydown */ 119 /* bit set on keydown */
112 if (gpio & ir->mask_keydown) { 120 if (gpio & ir->mask_keydown) {
113 ir_input_keydown(ir->input, &ir->ir, data, data); 121 ir_input_keydown(ir->input, &ir->ir, data, data);
@@ -187,6 +195,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
187 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 195 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
188 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 196 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
189 case CX88_BOARD_HAUPPAUGE_HVR1100: 197 case CX88_BOARD_HAUPPAUGE_HVR1100:
198 case CX88_BOARD_HAUPPAUGE_HVR1300:
190 ir_codes = ir_codes_hauppauge_new; 199 ir_codes = ir_codes_hauppauge_new;
191 ir_type = IR_TYPE_RC5; 200 ir_type = IR_TYPE_RC5;
192 ir->sampling = 1; 201 ir->sampling = 1;
@@ -248,6 +257,13 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
248 ir_type = IR_TYPE_PD; 257 ir_type = IR_TYPE_PD;
249 ir->sampling = 0xff00; /* address */ 258 ir->sampling = 0xff00; /* address */
250 break; 259 break;
260 case CX88_BOARD_NORWOOD_MICRO:
261 ir_codes = ir_codes_norwood;
262 ir->gpio_addr = MO_GP1_IO;
263 ir->mask_keycode = 0x0e;
264 ir->mask_keyup = 0x80;
265 ir->polling = 50; /* ms */
266 break;
251 case CX88_BOARD_NPGTECH_REALTV_TOP10FM: 267 case CX88_BOARD_NPGTECH_REALTV_TOP10FM:
252 ir_codes = ir_codes_npgtech; 268 ir_codes = ir_codes_npgtech;
253 ir->gpio_addr = MO_GP0_IO; 269 ir->gpio_addr = MO_GP0_IO;
@@ -402,6 +418,7 @@ void cx88_ir_irq(struct cx88_core *core)
402 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 418 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
403 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 419 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
404 case CX88_BOARD_HAUPPAUGE_HVR1100: 420 case CX88_BOARD_HAUPPAUGE_HVR1100:
421 case CX88_BOARD_HAUPPAUGE_HVR1300:
405 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); 422 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
406 ir_dprintk("biphase decoded: %x\n", ircode); 423 ir_dprintk("biphase decoded: %x\n", ircode);
407 if ((ircode & 0xfffff000) != 0x3000) 424 if ((ircode & 0xfffff000) != 0x3000)
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 5785c3481579..741e7c5e69ec 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -52,7 +52,6 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/smp_lock.h> 53#include <linux/smp_lock.h>
54#include <linux/delay.h> 54#include <linux/delay.h>
55#include <linux/config.h>
56#include <linux/kthread.h> 55#include <linux/kthread.h>
57 56
58#include "cx88.h" 57#include "cx88.h"
@@ -138,14 +137,10 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
138{ 137{
139 u32 volume; 138 u32 volume;
140 139
141#ifndef CONFIG_VIDEO_CX88_ALSA
142 /* restart dma; This avoids buzz in NICAM and is good in others */ 140 /* restart dma; This avoids buzz in NICAM and is good in others */
143 cx88_stop_audio_dma(core); 141 cx88_stop_audio_dma(core);
144#endif
145 cx_write(AUD_RATE_THRES_DMD, 0x000000C0); 142 cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
146#ifndef CONFIG_VIDEO_CX88_ALSA
147 cx88_start_audio_dma(core); 143 cx88_start_audio_dma(core);
148#endif
149 144
150 if (cx88_boards[core->board].blackbird) { 145 if (cx88_boards[core->board].blackbird) {
151 /* sets sound input from external adc */ 146 /* sets sound input from external adc */
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 94c92bacc342..fbc79e9842aa 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -497,6 +497,7 @@ static int start_video_dma(struct cx8800_dev *dev,
497 return 0; 497 return 0;
498} 498}
499 499
500#ifdef CONFIG_PM
500static int stop_video_dma(struct cx8800_dev *dev) 501static int stop_video_dma(struct cx8800_dev *dev)
501{ 502{
502 struct cx88_core *core = dev->core; 503 struct cx88_core *core = dev->core;
@@ -512,6 +513,7 @@ static int stop_video_dma(struct cx8800_dev *dev)
512 cx_clear(MO_VID_INTMSK, 0x0f0011); 513 cx_clear(MO_VID_INTMSK, 0x0f0011);
513 return 0; 514 return 0;
514} 515}
516#endif
515 517
516static int restart_video_queue(struct cx8800_dev *dev, 518static int restart_video_queue(struct cx8800_dev *dev,
517 struct cx88_dmaqueue *q) 519 struct cx88_dmaqueue *q)
@@ -2017,6 +2019,7 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev)
2017 kfree(dev); 2019 kfree(dev);
2018} 2020}
2019 2021
2022#ifdef CONFIG_PM
2020static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state) 2023static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
2021{ 2024{
2022 struct cx8800_dev *dev = pci_get_drvdata(pci_dev); 2025 struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
@@ -2092,6 +2095,7 @@ static int cx8800_resume(struct pci_dev *pci_dev)
2092 2095
2093 return 0; 2096 return 0;
2094} 2097}
2098#endif
2095 2099
2096/* ----------------------------------------------------------- */ 2100/* ----------------------------------------------------------- */
2097 2101
@@ -2112,9 +2116,10 @@ static struct pci_driver cx8800_pci_driver = {
2112 .id_table = cx8800_pci_tbl, 2116 .id_table = cx8800_pci_tbl,
2113 .probe = cx8800_initdev, 2117 .probe = cx8800_initdev,
2114 .remove = __devexit_p(cx8800_finidev), 2118 .remove = __devexit_p(cx8800_finidev),
2115 2119#ifdef CONFIG_PM
2116 .suspend = cx8800_suspend, 2120 .suspend = cx8800_suspend,
2117 .resume = cx8800_resume, 2121 .resume = cx8800_resume,
2122#endif
2118}; 2123};
2119 2124
2120static int cx8800_init(void) 2125static int cx8800_init(void)
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index e7810955dd4f..89f12e273b7f 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -197,6 +197,10 @@ extern struct sram_channel cx88_sram_channels[];
197#define CX88_BOARD_NPGTECH_REALTV_TOP10FM 50 197#define CX88_BOARD_NPGTECH_REALTV_TOP10FM 50
198#define CX88_BOARD_WINFAST_DTV2000H 51 198#define CX88_BOARD_WINFAST_DTV2000H 51
199#define CX88_BOARD_GENIATECH_DVBS 52 199#define CX88_BOARD_GENIATECH_DVBS 52
200#define CX88_BOARD_HAUPPAUGE_HVR3000 53
201#define CX88_BOARD_NORWOOD_MICRO 54
202#define CX88_BOARD_TE_DTV_250_OEM_SWANN 55
203#define CX88_BOARD_HAUPPAUGE_HVR1300 56
200 204
201enum cx88_itype { 205enum cx88_itype {
202 CX88_VMUX_COMPOSITE1 = 1, 206 CX88_VMUX_COMPOSITE1 = 1,
@@ -545,6 +549,7 @@ extern const unsigned int cx88_idcount;
545 549
546extern void cx88_card_list(struct cx88_core *core, struct pci_dev *pci); 550extern void cx88_card_list(struct cx88_core *core, struct pci_dev *pci);
547extern void cx88_card_setup(struct cx88_core *core); 551extern void cx88_card_setup(struct cx88_core *core);
552extern void cx88_card_setup_pre_i2c(struct cx88_core *core);
548 553
549/* ----------------------------------------------------------- */ 554/* ----------------------------------------------------------- */
550/* cx88-tvaudio.c */ 555/* cx88-tvaudio.c */
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index dfb15bfb83dc..9285a58e47aa 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -5,7 +5,8 @@ config VIDEO_EM28XX
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
7 select VIDEO_IR 7 select VIDEO_IR
8 select VIDEO_SAA711X 8 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
9 select VIDEO_TVP5150 if VIDEO_HELPER_CHIPS_AUTO
9 ---help--- 10 ---help---
10 This is a video4linux driver for Empia 28xx based TV cards. 11 This is a video4linux driver for Empia 28xx based TV cards.
11 12
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 2a461dde480c..20df657b70c8 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -174,7 +174,7 @@ static void em28xx_config_i2c(struct em28xx *dev)
174 174
175 route.input = INPUT(dev->ctl_input)->vmux; 175 route.input = INPUT(dev->ctl_input)->vmux;
176 route.output = 0; 176 route.output = 0;
177 em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, NULL); 177 em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, 0);
178 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); 178 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
179 em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL); 179 em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL);
180 180
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c
index 3bf7ac4f5288..c1a377f797d9 100644
--- a/drivers/media/video/ks0127.c
+++ b/drivers/media/video/ks0127.c
@@ -832,8 +832,7 @@ static int ks0127_detach(struct i2c_client *client)
832static int __devinit ks0127_init_module(void) 832static int __devinit ks0127_init_module(void)
833{ 833{
834 init_reg_defaults(); 834 init_reg_defaults();
835 i2c_add_driver(&i2c_driver_ks0127); 835 return i2c_add_driver(&i2c_driver_ks0127);
836 return 0;
837} 836}
838 837
839static void __devexit ks0127_cleanup_module(void) 838static void __devexit ks0127_cleanup_module(void)
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 7e727fe14b32..a52171ef6134 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -5,8 +5,6 @@ config VIDEO_PVRUSB2
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
7 select VIDEO_CX2341X 7 select VIDEO_CX2341X
8 select VIDEO_SAA711X
9 select VIDEO_MSP3400
10 ---help--- 8 ---help---
11 This is a video4linux driver for Conexant 23416 based 9 This is a video4linux driver for Conexant 23416 based
12 usb2 personal video recorder devices. 10 usb2 personal video recorder devices.
@@ -14,6 +12,20 @@ config VIDEO_PVRUSB2
14 To compile this driver as a module, choose M here: the 12 To compile this driver as a module, choose M here: the
15 module will be called pvrusb2 13 module will be called pvrusb2
16 14
15config VIDEO_PVRUSB2_29XXX
16 bool "Hauppauge WinTV-PVR USB2 support for 29xxx model series"
17 depends on VIDEO_PVRUSB2 && EXPERIMENTAL
18 select VIDEO_SAA711X
19 select VIDEO_MSP3400
20 ---help---
21 This option enables support for WinTV-PVR USB2 devices whose
22 model number is of the form "29xxx" (leading prefix of "29"
23 followed by 3 digits).
24 To see if you may need this option, examine the white
25 sticker on the underside of your device.
26
27 If you are in doubt, say Y.
28
17config VIDEO_PVRUSB2_24XXX 29config VIDEO_PVRUSB2_24XXX
18 bool "Hauppauge WinTV-PVR USB2 support for 24xxx model series" 30 bool "Hauppauge WinTV-PVR USB2 support for 24xxx model series"
19 depends on VIDEO_PVRUSB2 && EXPERIMENTAL 31 depends on VIDEO_PVRUSB2 && EXPERIMENTAL
@@ -60,3 +72,5 @@ config VIDEO_PVRUSB2_DEBUGIFC
60 You do not need to select this option unless you plan 72 You do not need to select this option unless you plan
61 on debugging the driver or performing a manual firmware 73 on debugging the driver or performing a manual firmware
62 extraction. 74 extraction.
75
76 If you are in doubt, say N.
diff --git a/drivers/media/video/pvrusb2/Makefile b/drivers/media/video/pvrusb2/Makefile
index 02e414210dac..69b3e43cd0eb 100644
--- a/drivers/media/video/pvrusb2/Makefile
+++ b/drivers/media/video/pvrusb2/Makefile
@@ -1,10 +1,6 @@
1obj-pvrusb2-sysfs-$(CONFIG_VIDEO_PVRUSB2_SYSFS) := pvrusb2-sysfs.o 1obj-pvrusb2-sysfs-$(CONFIG_VIDEO_PVRUSB2_SYSFS) := pvrusb2-sysfs.o
2obj-pvrusb2-debugifc-$(CONFIG_VIDEO_PVRUSB2_DEBUGIFC) := pvrusb2-debugifc.o 2obj-pvrusb2-debugifc-$(CONFIG_VIDEO_PVRUSB2_DEBUGIFC) := pvrusb2-debugifc.o
3 3
4obj-pvrusb2-24xxx-$(CONFIG_VIDEO_PVRUSB2_24XXX) := \
5 pvrusb2-cx2584x-v4l.o \
6 pvrusb2-wm8775.o
7
8pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \ 4pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \
9 pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \ 5 pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \
10 pvrusb2-encoder.o pvrusb2-video-v4l.o \ 6 pvrusb2-encoder.o pvrusb2-video-v4l.o \
@@ -12,7 +8,7 @@ pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \
12 pvrusb2-main.o pvrusb2-hdw.o pvrusb2-v4l2.o \ 8 pvrusb2-main.o pvrusb2-hdw.o pvrusb2-v4l2.o \
13 pvrusb2-ctrl.o pvrusb2-std.o \ 9 pvrusb2-ctrl.o pvrusb2-std.o \
14 pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \ 10 pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \
15 $(obj-pvrusb2-24xxx-y) \ 11 pvrusb2-cx2584x-v4l.o pvrusb2-wm8775.o \
16 $(obj-pvrusb2-sysfs-y) $(obj-pvrusb2-debugifc-y) 12 $(obj-pvrusb2-sysfs-y) $(obj-pvrusb2-debugifc-y)
17 13
18obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2.o 14obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2.o
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index fb6198f1df98..c77de859cc8e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -43,12 +43,17 @@ int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
43 if (cptr->info->type == pvr2_ctl_bitmask) { 43 if (cptr->info->type == pvr2_ctl_bitmask) {
44 mask &= cptr->info->def.type_bitmask.valid_bits; 44 mask &= cptr->info->def.type_bitmask.valid_bits;
45 } else if (cptr->info->type == pvr2_ctl_int) { 45 } else if (cptr->info->type == pvr2_ctl_int) {
46 if (val < cptr->info->def.type_int.min_value) { 46 int lim;
47 break; 47 lim = cptr->info->def.type_int.min_value;
48 if (cptr->info->get_min_value) {
49 cptr->info->get_min_value(cptr,&lim);
48 } 50 }
49 if (val > cptr->info->def.type_int.max_value) { 51 if (val < lim) break;
50 break; 52 lim = cptr->info->def.type_int.max_value;
53 if (cptr->info->get_max_value) {
54 cptr->info->get_max_value(cptr,&lim);
51 } 55 }
56 if (val > lim) break;
52 } else if (cptr->info->type == pvr2_ctl_enum) { 57 } else if (cptr->info->type == pvr2_ctl_enum) {
53 if (val >= cptr->info->def.type_enum.count) { 58 if (val >= cptr->info->def.type_enum.count) {
54 break; 59 break;
@@ -91,7 +96,9 @@ int pvr2_ctrl_get_max(struct pvr2_ctrl *cptr)
91 int ret = 0; 96 int ret = 0;
92 if (!cptr) return 0; 97 if (!cptr) return 0;
93 LOCK_TAKE(cptr->hdw->big_lock); do { 98 LOCK_TAKE(cptr->hdw->big_lock); do {
94 if (cptr->info->type == pvr2_ctl_int) { 99 if (cptr->info->get_max_value) {
100 cptr->info->get_max_value(cptr,&ret);
101 } else if (cptr->info->type == pvr2_ctl_int) {
95 ret = cptr->info->def.type_int.max_value; 102 ret = cptr->info->def.type_int.max_value;
96 } 103 }
97 } while(0); LOCK_GIVE(cptr->hdw->big_lock); 104 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
@@ -105,7 +112,9 @@ int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr)
105 int ret = 0; 112 int ret = 0;
106 if (!cptr) return 0; 113 if (!cptr) return 0;
107 LOCK_TAKE(cptr->hdw->big_lock); do { 114 LOCK_TAKE(cptr->hdw->big_lock); do {
108 if (cptr->info->type == pvr2_ctl_int) { 115 if (cptr->info->get_min_value) {
116 cptr->info->get_min_value(cptr,&ret);
117 } else if (cptr->info->type == pvr2_ctl_int) {
109 ret = cptr->info->def.type_int.min_value; 118 ret = cptr->info->def.type_int.min_value;
110 } 119 }
111 } while(0); LOCK_GIVE(cptr->hdw->big_lock); 120 } while(0); LOCK_GIVE(cptr->hdw->big_lock);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index c80c26be6e4d..df8feac16aee 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -221,7 +221,7 @@ static unsigned int decoder_describe(struct pvr2_v4l_cx2584x *ctxt,
221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt) 221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt)
222{ 222{
223 int ret; 223 int ret;
224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,NULL); 224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,0);
225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret); 225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret);
226} 226}
227 227
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index 18a7073501c6..c94f97b79392 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -317,7 +317,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
317 317
318 if (ret) { 318 if (ret) {
319 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 319 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
320 "Failed to configure cx32416"); 320 "Failed to configure cx23416");
321 return ret; 321 return ret;
322 } 322 }
323 323
@@ -337,7 +337,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
337 337
338 if (ret) { 338 if (ret) {
339 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 339 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
340 "Failed to initialize cx32416 video input"); 340 "Failed to initialize cx23416 video input");
341 return ret; 341 return ret;
342 } 342 }
343 343
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 0d6dc33ca320..34b08fbcc6ea 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -33,7 +33,6 @@
33 33
34*/ 34*/
35 35
36#include <linux/config.h>
37#include <linux/videodev2.h> 36#include <linux/videodev2.h>
38#include <linux/i2c.h> 37#include <linux/i2c.h>
39#include <linux/mutex.h> 38#include <linux/mutex.h>
@@ -41,32 +40,6 @@
41#include "pvrusb2-io.h" 40#include "pvrusb2-io.h"
42#include <media/cx2341x.h> 41#include <media/cx2341x.h>
43 42
44/* Legal values for the SRATE state variable */
45#define PVR2_CVAL_SRATE_48 0
46#define PVR2_CVAL_SRATE_44_1 1
47
48/* Legal values for the AUDIOBITRATE state variable */
49#define PVR2_CVAL_AUDIOBITRATE_384 0
50#define PVR2_CVAL_AUDIOBITRATE_320 1
51#define PVR2_CVAL_AUDIOBITRATE_256 2
52#define PVR2_CVAL_AUDIOBITRATE_224 3
53#define PVR2_CVAL_AUDIOBITRATE_192 4
54#define PVR2_CVAL_AUDIOBITRATE_160 5
55#define PVR2_CVAL_AUDIOBITRATE_128 6
56#define PVR2_CVAL_AUDIOBITRATE_112 7
57#define PVR2_CVAL_AUDIOBITRATE_96 8
58#define PVR2_CVAL_AUDIOBITRATE_80 9
59#define PVR2_CVAL_AUDIOBITRATE_64 10
60#define PVR2_CVAL_AUDIOBITRATE_56 11
61#define PVR2_CVAL_AUDIOBITRATE_48 12
62#define PVR2_CVAL_AUDIOBITRATE_32 13
63#define PVR2_CVAL_AUDIOBITRATE_VBR 14
64
65/* Legal values for the AUDIOEMPHASIS state variable */
66#define PVR2_CVAL_AUDIOEMPHASIS_NONE 0
67#define PVR2_CVAL_AUDIOEMPHASIS_50_15 1
68#define PVR2_CVAL_AUDIOEMPHASIS_CCITT 2
69
70/* Legal values for PVR2_CID_HSM */ 43/* Legal values for PVR2_CID_HSM */
71#define PVR2_CVAL_HSM_FAIL 0 44#define PVR2_CVAL_HSM_FAIL 0
72#define PVR2_CVAL_HSM_FULL 1 45#define PVR2_CVAL_HSM_FULL 1
@@ -107,6 +80,8 @@ struct pvr2_ctl_info {
107 80
108 /* Control's implementation */ 81 /* Control's implementation */
109 pvr2_ctlf_get_value get_value; /* Get its value */ 82 pvr2_ctlf_get_value get_value; /* Get its value */
83 pvr2_ctlf_get_value get_min_value; /* Get minimum allowed value */
84 pvr2_ctlf_get_value get_max_value; /* Get maximum allowed value */
110 pvr2_ctlf_set_value set_value; /* Set its value */ 85 pvr2_ctlf_set_value set_value; /* Set its value */
111 pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */ 86 pvr2_ctlf_val_to_sym val_to_sym; /* Custom convert value->symbol */
112 pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */ 87 pvr2_ctlf_sym_to_val sym_to_val; /* Custom convert symbol->value */
@@ -193,9 +168,7 @@ struct pvr2_decoder_ctrl {
193 168
194/* Known major hardware variants, keyed from device ID */ 169/* Known major hardware variants, keyed from device ID */
195#define PVR2_HDW_TYPE_29XXX 0 170#define PVR2_HDW_TYPE_29XXX 0
196#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
197#define PVR2_HDW_TYPE_24XXX 1 171#define PVR2_HDW_TYPE_24XXX 1
198#endif
199 172
200typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16); 173typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16);
201#define PVR2_I2C_FUNC_CNT 128 174#define PVR2_I2C_FUNC_CNT 128
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index be1e5cc78081..88604365777c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -38,9 +38,7 @@
38 38
39struct usb_device_id pvr2_device_table[] = { 39struct usb_device_id pvr2_device_table[] = {
40 [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) }, 40 [PVR2_HDW_TYPE_29XXX] = { USB_DEVICE(0x2040, 0x2900) },
41#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
42 [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) }, 41 [PVR2_HDW_TYPE_24XXX] = { USB_DEVICE(0x2040, 0x2400) },
43#endif
44 { } 42 { }
45}; 43};
46 44
@@ -48,9 +46,7 @@ MODULE_DEVICE_TABLE(usb, pvr2_device_table);
48 46
49static const char *pvr2_device_names[] = { 47static const char *pvr2_device_names[] = {
50 [PVR2_HDW_TYPE_29XXX] = "WinTV PVR USB2 Model Category 29xxxx", 48 [PVR2_HDW_TYPE_29XXX] = "WinTV PVR USB2 Model Category 29xxxx",
51#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
52 [PVR2_HDW_TYPE_24XXX] = "WinTV PVR USB2 Model Category 24xxxx", 49 [PVR2_HDW_TYPE_24XXX] = "WinTV PVR USB2 Model Category 24xxxx",
53#endif
54}; 50};
55 51
56struct pvr2_string_table { 52struct pvr2_string_table {
@@ -58,14 +54,12 @@ struct pvr2_string_table {
58 unsigned int cnt; 54 unsigned int cnt;
59}; 55};
60 56
61#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
62// Names of other client modules to request for 24xxx model hardware 57// Names of other client modules to request for 24xxx model hardware
63static const char *pvr2_client_24xxx[] = { 58static const char *pvr2_client_24xxx[] = {
64 "cx25840", 59 "cx25840",
65 "tuner", 60 "tuner",
66 "wm8775", 61 "wm8775",
67}; 62};
68#endif
69 63
70// Names of other client modules to request for 29xxx model hardware 64// Names of other client modules to request for 29xxx model hardware
71static const char *pvr2_client_29xxx[] = { 65static const char *pvr2_client_29xxx[] = {
@@ -79,12 +73,10 @@ static struct pvr2_string_table pvr2_client_lists[] = {
79 pvr2_client_29xxx, 73 pvr2_client_29xxx,
80 sizeof(pvr2_client_29xxx)/sizeof(pvr2_client_29xxx[0]), 74 sizeof(pvr2_client_29xxx)/sizeof(pvr2_client_29xxx[0]),
81 }, 75 },
82#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
83 [PVR2_HDW_TYPE_24XXX] = { 76 [PVR2_HDW_TYPE_24XXX] = {
84 pvr2_client_24xxx, 77 pvr2_client_24xxx,
85 sizeof(pvr2_client_24xxx)/sizeof(pvr2_client_24xxx[0]), 78 sizeof(pvr2_client_24xxx)/sizeof(pvr2_client_24xxx[0]),
86 }, 79 },
87#endif
88}; 80};
89 81
90static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; 82static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
@@ -221,14 +213,15 @@ static const struct pvr2_mpeg_ids mpeg_ids[] = {
221}; 213};
222#define MPEGDEF_COUNT (sizeof(mpeg_ids)/sizeof(mpeg_ids[0])) 214#define MPEGDEF_COUNT (sizeof(mpeg_ids)/sizeof(mpeg_ids[0]))
223 215
216
224static const char *control_values_srate[] = { 217static const char *control_values_srate[] = {
225 [PVR2_CVAL_SRATE_48] = "48KHz", 218 [V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100] = "44.1 kHz",
226 [PVR2_CVAL_SRATE_44_1] = "44.1KHz", 219 [V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000] = "48 kHz",
220 [V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000] = "32 kHz",
227}; 221};
228 222
229 223
230 224
231
232static const char *control_values_input[] = { 225static const char *control_values_input[] = {
233 [PVR2_CVAL_INPUT_TV] = "television", /*xawtv needs this name*/ 226 [PVR2_CVAL_INPUT_TV] = "television", /*xawtv needs this name*/
234 [PVR2_CVAL_INPUT_RADIO] = "radio", 227 [PVR2_CVAL_INPUT_RADIO] = "radio",
@@ -362,6 +355,50 @@ static int ctrl_freq_set(struct pvr2_ctrl *cptr,int m,int v)
362 return 0; 355 return 0;
363} 356}
364 357
358static int ctrl_hres_max_get(struct pvr2_ctrl *cptr,int *vp)
359{
360 /* If we're dealing with a 24xxx device, force the horizontal
361 maximum to be 720 no matter what, since we can't get the device
362 to work properly with any other value. Otherwise just return
363 the normal value. */
364 *vp = cptr->info->def.type_int.max_value;
365 if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) *vp = 720;
366 return 0;
367}
368
369static int ctrl_hres_min_get(struct pvr2_ctrl *cptr,int *vp)
370{
371 /* If we're dealing with a 24xxx device, force the horizontal
372 minimum to be 720 no matter what, since we can't get the device
373 to work properly with any other value. Otherwise just return
374 the normal value. */
375 *vp = cptr->info->def.type_int.min_value;
376 if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) *vp = 720;
377 return 0;
378}
379
380static int ctrl_vres_max_get(struct pvr2_ctrl *cptr,int *vp)
381{
382 /* Actual maximum depends on the video standard in effect. */
383 if (cptr->hdw->std_mask_cur & V4L2_STD_525_60) {
384 *vp = 480;
385 } else {
386 *vp = 576;
387 }
388 return 0;
389}
390
391static int ctrl_vres_min_get(struct pvr2_ctrl *cptr,int *vp)
392{
393 /* Actual minimum depends on device type. */
394 if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
395 *vp = 75;
396 } else {
397 *vp = 17;
398 }
399 return 0;
400}
401
365static int ctrl_cx2341x_is_dirty(struct pvr2_ctrl *cptr) 402static int ctrl_cx2341x_is_dirty(struct pvr2_ctrl *cptr)
366{ 403{
367 return cptr->hdw->enc_stale != 0; 404 return cptr->hdw->enc_stale != 0;
@@ -719,19 +756,27 @@ static const struct pvr2_ctl_info control_defs[] = {
719 .internal_id = PVR2_CID_HRES, 756 .internal_id = PVR2_CID_HRES,
720 .default_value = 720, 757 .default_value = 720,
721 DEFREF(res_hor), 758 DEFREF(res_hor),
722 DEFINT(320,720), 759 DEFINT(19,720),
760 /* Hook in check for clamp on horizontal resolution in
761 order to avoid unsolved problem involving cx25840. */
762 .get_max_value = ctrl_hres_max_get,
763 .get_min_value = ctrl_hres_min_get,
723 },{ 764 },{
724 .desc = "Vertical capture resolution", 765 .desc = "Vertical capture resolution",
725 .name = "resolution_ver", 766 .name = "resolution_ver",
726 .internal_id = PVR2_CID_VRES, 767 .internal_id = PVR2_CID_VRES,
727 .default_value = 480, 768 .default_value = 480,
728 DEFREF(res_ver), 769 DEFREF(res_ver),
729 DEFINT(200,625), 770 DEFINT(17,576),
771 /* Hook in check for video standard and adjust maximum
772 depending on the standard. */
773 .get_max_value = ctrl_vres_max_get,
774 .get_min_value = ctrl_vres_min_get,
730 },{ 775 },{
731 .v4l_id = V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ, 776 .v4l_id = V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ,
732 .desc = "Sample rate", 777 .default_value = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000,
778 .desc = "Audio Sampling Frequency",
733 .name = "srate", 779 .name = "srate",
734 .default_value = PVR2_CVAL_SRATE_48,
735 DEFREF(srate), 780 DEFREF(srate),
736 DEFENUM(control_values_srate), 781 DEFENUM(control_values_srate),
737 },{ 782 },{
@@ -935,22 +980,18 @@ static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
935 static const char *fw_files_29xxx[] = { 980 static const char *fw_files_29xxx[] = {
936 "v4l-pvrusb2-29xxx-01.fw", 981 "v4l-pvrusb2-29xxx-01.fw",
937 }; 982 };
938#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
939 static const char *fw_files_24xxx[] = { 983 static const char *fw_files_24xxx[] = {
940 "v4l-pvrusb2-24xxx-01.fw", 984 "v4l-pvrusb2-24xxx-01.fw",
941 }; 985 };
942#endif
943 static const struct pvr2_string_table fw_file_defs[] = { 986 static const struct pvr2_string_table fw_file_defs[] = {
944 [PVR2_HDW_TYPE_29XXX] = { 987 [PVR2_HDW_TYPE_29XXX] = {
945 fw_files_29xxx, 988 fw_files_29xxx,
946 sizeof(fw_files_29xxx)/sizeof(fw_files_29xxx[0]), 989 sizeof(fw_files_29xxx)/sizeof(fw_files_29xxx[0]),
947 }, 990 },
948#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
949 [PVR2_HDW_TYPE_24XXX] = { 991 [PVR2_HDW_TYPE_24XXX] = {
950 fw_files_24xxx, 992 fw_files_24xxx,
951 sizeof(fw_files_24xxx)/sizeof(fw_files_24xxx[0]), 993 sizeof(fw_files_24xxx)/sizeof(fw_files_24xxx[0]),
952 }, 994 },
953#endif
954 }; 995 };
955 hdw->fw1_state = FW1_STATE_FAILED; // default result 996 hdw->fw1_state = FW1_STATE_FAILED; // default result
956 997
@@ -2237,11 +2278,14 @@ static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
2237 } 2278 }
2238 2279
2239 if (hdw->std_dirty || 2280 if (hdw->std_dirty ||
2281 hdw->enc_stale ||
2282 hdw->srate_dirty ||
2283 hdw->res_ver_dirty ||
2284 hdw->res_hor_dirty ||
2240 0) { 2285 0) {
2241 /* If any of this changes, then the encoder needs to be 2286 /* If any of this changes, then the encoder needs to be
2242 reconfigured, and we need to reset the stream. */ 2287 reconfigured, and we need to reset the stream. */
2243 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG); 2288 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
2244 stale_subsys_mask |= hdw->subsys_stream_mask;
2245 } 2289 }
2246 2290
2247 if (hdw->srate_dirty) { 2291 if (hdw->srate_dirty) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
index fbe6039aeb6a..ed3e8105292a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
@@ -26,10 +26,8 @@
26#include "pvrusb2-audio.h" 26#include "pvrusb2-audio.h"
27#include "pvrusb2-tuner.h" 27#include "pvrusb2-tuner.h"
28#include "pvrusb2-video-v4l.h" 28#include "pvrusb2-video-v4l.h"
29#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
30#include "pvrusb2-cx2584x-v4l.h" 29#include "pvrusb2-cx2584x-v4l.h"
31#include "pvrusb2-wm8775.h" 30#include "pvrusb2-wm8775.h"
32#endif
33 31
34#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) 32#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
35 33
@@ -71,7 +69,6 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
71 return; 69 return;
72 } 70 }
73 } 71 }
74#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
75 if (id == I2C_DRIVERID_CX25840) { 72 if (id == I2C_DRIVERID_CX25840) {
76 if (pvr2_i2c_cx2584x_v4l_setup(hdw,cp)) { 73 if (pvr2_i2c_cx2584x_v4l_setup(hdw,cp)) {
77 return; 74 return;
@@ -82,7 +79,6 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
82 return; 79 return;
83 } 80 }
84 } 81 }
85#endif
86 if (id == I2C_DRIVERID_SAA711X) { 82 if (id == I2C_DRIVERID_SAA711X) {
87 if (pvr2_i2c_decoder_v4l_setup(hdw,cp)) { 83 if (pvr2_i2c_decoder_v4l_setup(hdw,cp)) {
88 return; 84 return;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
index 8a9933dec912..05ea17afe903 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
@@ -31,7 +31,7 @@ static void set_standard(struct pvr2_hdw *hdw)
31 v4l2_std_id vs; 31 v4l2_std_id vs;
32 vs = hdw->std_mask_cur; 32 vs = hdw->std_mask_cur;
33 pvr2_trace(PVR2_TRACE_CHIPS, 33 pvr2_trace(PVR2_TRACE_CHIPS,
34 "i2c v4l2 set_standard(0x%llx)",(__u64)vs); 34 "i2c v4l2 set_standard(0x%llx)",(long long unsigned)vs);
35 35
36 pvr2_i2c_core_cmd(hdw,VIDIOC_S_STD,&vs); 36 pvr2_i2c_core_cmd(hdw,VIDIOC_S_STD,&vs);
37} 37}
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 7fca47982277..3b9012f8e380 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -185,8 +185,6 @@ static int pvr2_i2c_basic_op(struct pvr2_hdw *hdw,
185 } 185 }
186} 186}
187 187
188#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
189
190/* This is a special entry point that is entered if an I2C operation is 188/* This is a special entry point that is entered if an I2C operation is
191 attempted to a wm8775 chip on model 24xxx hardware. Autodetect of this 189 attempted to a wm8775 chip on model 24xxx hardware. Autodetect of this
192 part doesn't work, but we know it is really there. So let's look for 190 part doesn't work, but we know it is really there. So let's look for
@@ -289,8 +287,6 @@ static int i2c_hack_cx25840(struct pvr2_hdw *hdw,
289 return -EIO; 287 return -EIO;
290} 288}
291 289
292#endif /* CONFIG_VIDEO_PVRUSB2_24XXX */
293
294/* This is a very, very limited I2C adapter implementation. We can only 290/* This is a very, very limited I2C adapter implementation. We can only
295 support what we actually know will work on the device... */ 291 support what we actually know will work on the device... */
296static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap, 292static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
@@ -897,14 +893,12 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
897 hdw->i2c_func[idx] = pvr2_i2c_basic_op; 893 hdw->i2c_func[idx] = pvr2_i2c_basic_op;
898 } 894 }
899 895
900#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
901 // If however we're dealing with new hardware, insert some hacks in 896 // If however we're dealing with new hardware, insert some hacks in
902 // the I2C transfer stack to let things work better. 897 // the I2C transfer stack to let things work better.
903 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { 898 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
904 hdw->i2c_func[0x1b] = i2c_hack_wm8775; 899 hdw->i2c_func[0x1b] = i2c_hack_wm8775;
905 hdw->i2c_func[0x44] = i2c_hack_cx25840; 900 hdw->i2c_func[0x44] = i2c_hack_cx25840;
906 } 901 }
907#endif
908 902
909 // Configure the adapter and set up everything else related to it. 903 // Configure the adapter and set up everything else related to it.
910 memcpy(&hdw->i2c_adap,&pvr2_i2c_adap_template,sizeof(hdw->i2c_adap)); 904 memcpy(&hdw->i2c_adap,&pvr2_i2c_adap_template,sizeof(hdw->i2c_adap));
diff --git a/drivers/media/video/pvrusb2/pvrusb2-main.c b/drivers/media/video/pvrusb2/pvrusb2-main.c
index 8f1a5afdd34e..e976c484c058 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-main.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-main.c
@@ -20,7 +20,6 @@
20 * 20 *
21 */ 21 */
22 22
23#include <linux/config.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
25#include <linux/errno.h> 24#include <linux/errno.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index d1dda5caf406..c294f46db9b9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -19,7 +19,6 @@
19 * 19 *
20 */ 20 */
21 21
22#include <linux/config.h>
23#include <linux/string.h> 22#include <linux/string.h>
24#include <linux/slab.h> 23#include <linux/slab.h>
25#include <asm/semaphore.h> 24#include <asm/semaphore.h>
@@ -40,8 +39,6 @@ struct pvr2_sysfs {
40#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */ 39#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
41 struct pvr2_sysfs_ctl_item *item_first; 40 struct pvr2_sysfs_ctl_item *item_first;
42 struct pvr2_sysfs_ctl_item *item_last; 41 struct pvr2_sysfs_ctl_item *item_last;
43 struct sysfs_ops kops;
44 struct kobj_type ktype;
45 struct class_device_attribute attr_v4l_minor_number; 42 struct class_device_attribute attr_v4l_minor_number;
46 struct class_device_attribute attr_unit_number; 43 struct class_device_attribute attr_unit_number;
47 int v4l_minor_number_created_ok; 44 int v4l_minor_number_created_ok;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 0caf70b8c0de..3608c2f81df9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -459,18 +459,26 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
459 ret = 0; 459 ret = 0;
460 switch(vf->type) { 460 switch(vf->type) {
461 case V4L2_BUF_TYPE_VIDEO_CAPTURE: { 461 case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
462 int lmin,lmax;
463 struct pvr2_ctrl *hcp,*vcp;
462 int h = vf->fmt.pix.height; 464 int h = vf->fmt.pix.height;
463 int w = vf->fmt.pix.width; 465 int w = vf->fmt.pix.width;
464 466 hcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_HRES);
465 if (h < 200) { 467 vcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_VRES);
466 h = 200; 468
467 } else if (h > 625) { 469 lmin = pvr2_ctrl_get_min(hcp);
468 h = 625; 470 lmax = pvr2_ctrl_get_max(hcp);
471 if (w < lmin) {
472 w = lmin;
473 } else if (w > lmax) {
474 w = lmax;
469 } 475 }
470 if (w < 320) { 476 lmin = pvr2_ctrl_get_min(vcp);
471 w = 320; 477 lmax = pvr2_ctrl_get_max(vcp);
472 } else if (w > 720) { 478 if (h < lmin) {
473 w = 720; 479 h = lmin;
480 } else if (h > lmax) {
481 h = lmax;
474 } 482 }
475 483
476 memcpy(vf, &pvr_format[PVR_FORMAT_PIX], 484 memcpy(vf, &pvr_format[PVR_FORMAT_PIX],
@@ -479,14 +487,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
479 vf->fmt.pix.height = h; 487 vf->fmt.pix.height = h;
480 488
481 if (cmd == VIDIOC_S_FMT) { 489 if (cmd == VIDIOC_S_FMT) {
482 pvr2_ctrl_set_value( 490 pvr2_ctrl_set_value(hcp,vf->fmt.pix.width);
483 pvr2_hdw_get_ctrl_by_id(hdw, 491 pvr2_ctrl_set_value(vcp,vf->fmt.pix.height);
484 PVR2_CID_HRES),
485 vf->fmt.pix.width);
486 pvr2_ctrl_set_value(
487 pvr2_hdw_get_ctrl_by_id(hdw,
488 PVR2_CID_VRES),
489 vf->fmt.pix.height);
490 } 492 }
491 } break; 493 } break;
492 case V4L2_BUF_TYPE_VBI_CAPTURE: 494 case V4L2_BUF_TYPE_VBI_CAPTURE:
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 59a187272c83..77bb940a1a4f 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -830,7 +830,6 @@ static struct video_device saa_template =
830 .owner = THIS_MODULE, 830 .owner = THIS_MODULE,
831 .name = IF_NAME, 831 .name = IF_NAME,
832 .type = VID_TYPE_TELETEXT, 832 .type = VID_TYPE_TELETEXT,
833 .hardware = VID_HARDWARE_SAA5249,
834 .fops = &saa_fops, 833 .fops = &saa_fops,
835 .release = video_device_release, 834 .release = video_device_release,
836 .minor = -1, 835 .minor = -1,
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 19a8d65699f8..bb3fb4387f65 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -713,7 +713,6 @@ static struct video_device saa_template =
713 .owner = THIS_MODULE, 713 .owner = THIS_MODULE,
714 .name = IF_NAME, 714 .name = IF_NAME,
715 .type = VID_TYPE_TELETEXT, /*| VID_TYPE_TUNER ?? */ 715 .type = VID_TYPE_TELETEXT, /*| VID_TYPE_TUNER ?? */
716 .hardware = VID_HARDWARE_SAA5249,
717 .fops = &saa_fops, 716 .fops = &saa_fops,
718}; 717};
719 718
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index b59c11717273..974179d4d389 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1,4 +1,6 @@
1/* saa7115 - Philips SAA7113/SAA7114/SAA7115 video decoder driver 1/* saa711x - Philips SAA711x video decoder driver
2 * This driver can work with saa7111, saa7111a, saa7113, saa7114,
3 * saa7115 and saa7118.
2 * 4 *
3 * Based on saa7114 driver by Maxim Yevtyushkin, which is based on 5 * Based on saa7114 driver by Maxim Yevtyushkin, which is based on
4 * the saa7111 driver by Dave Perks. 6 * the saa7111 driver by Dave Perks.
@@ -16,7 +18,9 @@
16 * (2/17/2003) 18 * (2/17/2003)
17 * 19 *
18 * VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl> 20 * VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl>
19 * SAA7113 support by Mauro Carvalho Chehab <mchehab@infradead.org> 21 *
22 * Copyright (c) 2005-2006 Mauro Carvalho Chehab <mchehab@infradead.org>
23 * SAA7111, SAA7113 and SAA7118 support
20 * 24 *
21 * This program is free software; you can redistribute it and/or 25 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License 26 * modify it under the terms of the GNU General Public License
@@ -33,6 +37,7 @@
33 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 37 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34 */ 38 */
35 39
40#include "saa711x_regs.h"
36 41
37#include <linux/kernel.h> 42#include <linux/kernel.h>
38#include <linux/module.h> 43#include <linux/module.h>
@@ -43,7 +48,9 @@
43#include <media/saa7115.h> 48#include <media/saa7115.h>
44#include <asm/div64.h> 49#include <asm/div64.h>
45 50
46MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver"); 51#define VRES_60HZ (480+16)
52
53MODULE_DESCRIPTION("Philips SAA7111/SAA7113/SAA7114/SAA7115/SAA7118 video decoder driver");
47MODULE_AUTHOR( "Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, " 54MODULE_AUTHOR( "Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, "
48 "Hans Verkuil, Mauro Carvalho Chehab"); 55 "Hans Verkuil, Mauro Carvalho Chehab");
49MODULE_LICENSE("GPL"); 56MODULE_LICENSE("GPL");
@@ -54,14 +61,14 @@ module_param(debug, bool, 0644);
54MODULE_PARM_DESC(debug, "Debug level (0-1)"); 61MODULE_PARM_DESC(debug, "Debug level (0-1)");
55 62
56static unsigned short normal_i2c[] = { 63static unsigned short normal_i2c[] = {
57 0x4a >> 1, 0x48 >> 1, /* SAA7113 */ 64 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */
58 0x42 >> 1, 0x40 >> 1, /* SAA7114 and SAA7115 */ 65 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */
59 I2C_CLIENT_END }; 66 I2C_CLIENT_END };
60 67
61 68
62I2C_CLIENT_INSMOD; 69I2C_CLIENT_INSMOD;
63 70
64struct saa7115_state { 71struct saa711x_state {
65 v4l2_std_id std; 72 v4l2_std_id std;
66 int input; 73 int input;
67 int enable; 74 int enable;
@@ -70,6 +77,8 @@ struct saa7115_state {
70 int contrast; 77 int contrast;
71 int hue; 78 int hue;
72 int sat; 79 int sat;
80 int width;
81 int height;
73 enum v4l2_chip_ident ident; 82 enum v4l2_chip_ident ident;
74 u32 audclk_freq; 83 u32 audclk_freq;
75 u32 crystal_freq; 84 u32 crystal_freq;
@@ -80,420 +89,508 @@ struct saa7115_state {
80 89
81/* ----------------------------------------------------------------------- */ 90/* ----------------------------------------------------------------------- */
82 91
83static inline int saa7115_write(struct i2c_client *client, u8 reg, u8 value) 92static inline int saa711x_write(struct i2c_client *client, u8 reg, u8 value)
84{ 93{
85 return i2c_smbus_write_byte_data(client, reg, value); 94 return i2c_smbus_write_byte_data(client, reg, value);
86} 95}
87 96
88static int saa7115_writeregs(struct i2c_client *client, const unsigned char *regs) 97/* Sanity routine to check if a register is present */
98static int saa711x_has_reg(const int id, const u8 reg)
89{ 99{
100 if (id == V4L2_IDENT_SAA7111)
101 return reg < 0x20 && reg != 0x01 && reg != 0x0f &&
102 (reg < 0x13 || reg > 0x19) && reg != 0x1d && reg != 0x1e;
103
104 /* common for saa7113/4/5/8 */
105 if (unlikely((reg >= 0x3b && reg <= 0x3f) || reg == 0x5c || reg == 0x5f ||
106 reg == 0xa3 || reg == 0xa7 || reg == 0xab || reg == 0xaf || (reg >= 0xb5 && reg <= 0xb7) ||
107 reg == 0xd3 || reg == 0xd7 || reg == 0xdb || reg == 0xdf || (reg >= 0xe5 && reg <= 0xe7) ||
108 reg == 0x82 || (reg >= 0x89 && reg <= 0x8e)))
109 return 0;
110
111 switch (id) {
112 case V4L2_IDENT_SAA7113:
113 return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && (reg < 0x20 || reg > 0x3f) &&
114 reg != 0x5d && reg < 0x63;
115 case V4L2_IDENT_SAA7114:
116 return (reg < 0x1a || reg > 0x1e) && (reg < 0x20 || reg > 0x2f) &&
117 (reg < 0x63 || reg > 0x7f) && reg != 0x33 && reg != 0x37 &&
118 reg != 0x81 && reg < 0xf0;
119 case V4L2_IDENT_SAA7115:
120 return (reg < 0x20 || reg > 0x2f) && reg != 0x65 && (reg < 0xfc || reg > 0xfe);
121 case V4L2_IDENT_SAA7118:
122 return (reg < 0x1a || reg > 0x1d) && (reg < 0x20 || reg > 0x22) &&
123 (reg < 0x26 || reg > 0x28) && reg != 0x33 && reg != 0x37 &&
124 (reg < 0x63 || reg > 0x7f) && reg != 0x81 && reg < 0xf0;
125 }
126 return 1;
127}
128
129static int saa711x_writeregs(struct i2c_client *client, const unsigned char *regs)
130{
131 struct saa711x_state *state = i2c_get_clientdata(client);
90 unsigned char reg, data; 132 unsigned char reg, data;
91 133
92 while (*regs != 0x00) { 134 while (*regs != 0x00) {
93 reg = *(regs++); 135 reg = *(regs++);
94 data = *(regs++); 136 data = *(regs++);
95 if (saa7115_write(client, reg, data) < 0) 137
96 return -1; 138 /* According with datasheets, reserved regs should be
139 filled with 0 - seems better not to touch on they */
140 if (saa711x_has_reg(state->ident,reg)) {
141 if (saa711x_write(client, reg, data) < 0)
142 return -1;
143 } else {
144 v4l_dbg(1, debug, client, "tried to access reserved reg 0x%02x\n", reg);
145 }
97 } 146 }
98 return 0; 147 return 0;
99} 148}
100 149
101static inline int saa7115_read(struct i2c_client *client, u8 reg) 150static inline int saa711x_read(struct i2c_client *client, u8 reg)
102{ 151{
103 return i2c_smbus_read_byte_data(client, reg); 152 return i2c_smbus_read_byte_data(client, reg);
104} 153}
105 154
106/* ----------------------------------------------------------------------- */ 155/* ----------------------------------------------------------------------- */
107 156
157/* SAA7111 initialization table */
158static const unsigned char saa7111_init[] = {
159 R_01_INC_DELAY, 0x00, /* reserved */
160
161 /*front end */
162 R_02_INPUT_CNTL_1, 0xd0, /* FUSE=3, GUDL=2, MODE=0 */
163 R_03_INPUT_CNTL_2, 0x23, /* HLNRS=0, VBSL=1, WPOFF=0, HOLDG=0,
164 * GAFIX=0, GAI1=256, GAI2=256 */
165 R_04_INPUT_CNTL_3, 0x00, /* GAI1=256 */
166 R_05_INPUT_CNTL_4, 0x00, /* GAI2=256 */
167
168 /* decoder */
169 R_06_H_SYNC_START, 0xf3, /* HSB at 13(50Hz) / 17(60Hz)
170 * pixels after end of last line */
171 R_07_H_SYNC_STOP, 0xe8, /* HSS seems to be needed to
172 * work with NTSC, too */
173 R_08_SYNC_CNTL, 0xc8, /* AUFD=1, FSEL=1, EXFIL=0,
174 * VTRC=1, HPLL=0, VNOI=0 */
175 R_09_LUMA_CNTL, 0x01, /* BYPS=0, PREF=0, BPSS=0,
176 * VBLB=0, UPTCV=0, APER=1 */
177 R_0A_LUMA_BRIGHT_CNTL, 0x80,
178 R_0B_LUMA_CONTRAST_CNTL, 0x47, /* 0b - CONT=1.109 */
179 R_0C_CHROMA_SAT_CNTL, 0x40,
180 R_0D_CHROMA_HUE_CNTL, 0x00,
181 R_0E_CHROMA_CNTL_1, 0x01, /* 0e - CDTO=0, CSTD=0, DCCF=0,
182 * FCTC=0, CHBW=1 */
183 R_0F_CHROMA_GAIN_CNTL, 0x00, /* reserved */
184 R_10_CHROMA_CNTL_2, 0x48, /* 10 - OFTS=1, HDEL=0, VRLN=1, YDEL=0 */
185 R_11_MODE_DELAY_CNTL, 0x1c, /* 11 - GPSW=0, CM99=0, FECO=0, COMPO=1,
186 * OEYC=1, OEHV=1, VIPB=0, COLO=0 */
187 R_12_RT_SIGNAL_CNTL, 0x00, /* 12 - output control 2 */
188 R_13_RT_X_PORT_OUT_CNTL, 0x00, /* 13 - output control 3 */
189 R_14_ANAL_ADC_COMPAT_CNTL, 0x00,
190 R_15_VGATE_START_FID_CHG, 0x00,
191 R_16_VGATE_STOP, 0x00,
192 R_17_MISC_VGATE_CONF_AND_MSB, 0x00,
193
194 0x00, 0x00
195};
196
197/* SAA7113 init codes */
198static const unsigned char saa7113_init[] = {
199 R_01_INC_DELAY, 0x08,
200 R_02_INPUT_CNTL_1, 0xc2,
201 R_03_INPUT_CNTL_2, 0x30,
202 R_04_INPUT_CNTL_3, 0x00,
203 R_05_INPUT_CNTL_4, 0x00,
204 R_06_H_SYNC_START, 0x89,
205 R_07_H_SYNC_STOP, 0x0d,
206 R_08_SYNC_CNTL, 0x88,
207 R_09_LUMA_CNTL, 0x01,
208 R_0A_LUMA_BRIGHT_CNTL, 0x80,
209 R_0B_LUMA_CONTRAST_CNTL, 0x47,
210 R_0C_CHROMA_SAT_CNTL, 0x40,
211 R_0D_CHROMA_HUE_CNTL, 0x00,
212 R_0E_CHROMA_CNTL_1, 0x01,
213 R_0F_CHROMA_GAIN_CNTL, 0x2a,
214 R_10_CHROMA_CNTL_2, 0x08,
215 R_11_MODE_DELAY_CNTL, 0x0c,
216 R_12_RT_SIGNAL_CNTL, 0x07,
217 R_13_RT_X_PORT_OUT_CNTL, 0x00,
218 R_14_ANAL_ADC_COMPAT_CNTL, 0x00,
219 R_15_VGATE_START_FID_CHG, 0x00,
220 R_16_VGATE_STOP, 0x00,
221 R_17_MISC_VGATE_CONF_AND_MSB, 0x00,
222
223 0x00, 0x00
224};
225
108/* If a value differs from the Hauppauge driver values, then the comment starts with 226/* If a value differs from the Hauppauge driver values, then the comment starts with
109 'was 0xXX' to denote the Hauppauge value. Otherwise the value is identical to what the 227 'was 0xXX' to denote the Hauppauge value. Otherwise the value is identical to what the
110 Hauppauge driver sets. */ 228 Hauppauge driver sets. */
111 229
230/* SAA7114 and SAA7115 initialization table */
112static const unsigned char saa7115_init_auto_input[] = { 231static const unsigned char saa7115_init_auto_input[] = {
113 /* Front-End Part */ 232 /* Front-End Part */
114 0x01, 0x48, /* white peak control disabled */ 233 R_01_INC_DELAY, 0x48, /* white peak control disabled */
115 0x03, 0x20, /* was 0x30. 0x20: long vertical blanking */ 234 R_03_INPUT_CNTL_2, 0x20, /* was 0x30. 0x20: long vertical blanking */
116 0x04, 0x90, /* analog gain set to 0 */ 235 R_04_INPUT_CNTL_3, 0x90, /* analog gain set to 0 */
117 0x05, 0x90, /* analog gain set to 0 */ 236 R_05_INPUT_CNTL_4, 0x90, /* analog gain set to 0 */
118 /* Decoder Part */ 237 /* Decoder Part */
119 0x06, 0xeb, /* horiz sync begin = -21 */ 238 R_06_H_SYNC_START, 0xeb, /* horiz sync begin = -21 */
120 0x07, 0xe0, /* horiz sync stop = -17 */ 239 R_07_H_SYNC_STOP, 0xe0, /* horiz sync stop = -17 */
121 0x0a, 0x80, /* was 0x88. decoder brightness, 0x80 is itu standard */ 240 R_09_LUMA_CNTL, 0x53, /* 0x53, was 0x56 for 60hz. luminance control */
122 0x0b, 0x44, /* was 0x48. decoder contrast, 0x44 is itu standard */ 241 R_0A_LUMA_BRIGHT_CNTL, 0x80, /* was 0x88. decoder brightness, 0x80 is itu standard */
123 0x0c, 0x40, /* was 0x47. decoder saturation, 0x40 is itu standard */ 242 R_0B_LUMA_CONTRAST_CNTL, 0x44, /* was 0x48. decoder contrast, 0x44 is itu standard */
124 0x0d, 0x00, /* chrominance hue control */ 243 R_0C_CHROMA_SAT_CNTL, 0x40, /* was 0x47. decoder saturation, 0x40 is itu standard */
125 0x0f, 0x00, /* chrominance gain control: use automicatic mode */ 244 R_0D_CHROMA_HUE_CNTL, 0x00,
126 0x10, 0x06, /* chrominance/luminance control: active adaptive combfilter */ 245 R_0F_CHROMA_GAIN_CNTL, 0x00, /* use automatic gain */
127 0x11, 0x00, /* delay control */ 246 R_10_CHROMA_CNTL_2, 0x06, /* chroma: active adaptive combfilter */
128 0x12, 0x9d, /* RTS0 output control: VGATE */ 247 R_11_MODE_DELAY_CNTL, 0x00,
129 0x13, 0x80, /* X-port output control: ITU656 standard mode, RTCO output enable RTCE */ 248 R_12_RT_SIGNAL_CNTL, 0x9d, /* RTS0 output control: VGATE */
130 0x14, 0x00, /* analog/ADC/auto compatibility control */ 249 R_13_RT_X_PORT_OUT_CNTL, 0x80, /* ITU656 standard mode, RTCO output enable RTCE */
131 0x18, 0x40, /* raw data gain 0x00 = nominal */ 250 R_14_ANAL_ADC_COMPAT_CNTL, 0x00,
132 0x19, 0x80, /* raw data offset 0x80 = 0 LSB */ 251 R_18_RAW_DATA_GAIN_CNTL, 0x40, /* gain 0x00 = nominal */
133 0x1a, 0x77, /* color killer level control 0x77 = recommended */ 252 R_19_RAW_DATA_OFF_CNTL, 0x80,
134 0x1b, 0x42, /* misc chroma control 0x42 = recommended */ 253 R_1A_COLOR_KILL_LVL_CNTL, 0x77, /* recommended value */
135 0x1c, 0xa9, /* combfilter control 0xA9 = recommended */ 254 R_1B_MISC_TVVCRDET, 0x42, /* recommended value */
136 0x1d, 0x01, /* combfilter control 0x01 = recommended */ 255 R_1C_ENHAN_COMB_CTRL1, 0xa9, /* recommended value */
256 R_1D_ENHAN_COMB_CTRL2, 0x01, /* recommended value */
257
258
259 R_80_GLOBAL_CNTL_1, 0x0, /* No tasks enabled at init */
137 260
138 /* Power Device Control */ 261 /* Power Device Control */
139 0x88, 0xd0, /* reset device */ 262 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset device */
140 0x88, 0xf0, /* set device programmed, all in operational mode */ 263 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xf0, /* set device programmed, all in operational mode */
141 0x00, 0x00 264 0x00, 0x00
142}; 265};
143 266
267/* Used to reset saa7113, saa7114 and saa7115 */
144static const unsigned char saa7115_cfg_reset_scaler[] = { 268static const unsigned char saa7115_cfg_reset_scaler[] = {
145 0x87, 0x00, /* disable I-port output */ 269 R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED, 0x00, /* disable I-port output */
146 0x88, 0xd0, /* reset scaler */ 270 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset scaler */
147 0x88, 0xf0, /* activate scaler */ 271 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xf0, /* activate scaler */
148 0x87, 0x01, /* enable I-port output */ 272 R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED, 0x01, /* enable I-port output */
149 0x00, 0x00 273 0x00, 0x00
150}; 274};
151 275
152/* ============== SAA7715 VIDEO templates ============= */ 276/* ============== SAA7715 VIDEO templates ============= */
153 277
154static const unsigned char saa7115_cfg_60hz_fullres_x[] = { 278static const unsigned char saa7115_cfg_60hz_video[] = {
155 0xcc, 0xd0, /* hsize low (output), hor. output window size = 0x2d0 = 720 */ 279 R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */
156 0xcd, 0x02, /* hsize hi (output) */ 280 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset scaler */
157 281
158 /* Why not in 60hz-Land, too? */ 282 R_15_VGATE_START_FID_CHG, 0x03,
159 0xd0, 0x01, /* downscale = 1 */ 283 R_16_VGATE_STOP, 0x11,
160 0xd8, 0x00, /* hor lum scaling 0x0400 = 1 */ 284 R_17_MISC_VGATE_CONF_AND_MSB, 0x9c,
161 0xd9, 0x04,
162 0xdc, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
163 0xdd, 0x02, /* H-scaling incr chroma */
164 285
165 0x00, 0x00 286 R_08_SYNC_CNTL, 0x68, /* 0xBO: auto detection, 0x68 = NTSC */
166}; 287 R_0E_CHROMA_CNTL_1, 0x07, /* video autodetection is on */
167static const unsigned char saa7115_cfg_60hz_fullres_y[] = {
168 0xce, 0xf8, /* vsize low (output), ver. output window size = 248 (but 60hz is 240?) */
169 0xcf, 0x00, /* vsize hi (output) */
170 288
171 /* Why not in 60hz-Land, too? */ 289 R_5A_V_OFF_FOR_SLICER, 0x06, /* standard 60hz value for ITU656 line counting */
172 0xd5, 0x40, /* Lum contrast, nominal value = 0x40 */
173 0xd6, 0x40, /* Chroma satur. nominal value = 0x80 */
174 290
175 0xe0, 0x00, /* V-scaling incr luma low */ 291 /* Task A */
176 0xe1, 0x04, /* " hi */ 292 R_90_A_TASK_HANDLING_CNTL, 0x80,
177 0xe2, 0x00, /* V-scaling incr chroma low */ 293 R_91_A_X_PORT_FORMATS_AND_CONF, 0x48,
178 0xe3, 0x04, /* " hi */ 294 R_92_A_X_PORT_INPUT_REFERENCE_SIGNAL, 0x40,
295 R_93_A_I_PORT_OUTPUT_FORMATS_AND_CONF, 0x84,
179 296
180 0x00, 0x00 297 /* hoffset low (input), 0x0002 is minimum */
181}; 298 R_94_A_HORIZ_INPUT_WINDOW_START, 0x01,
299 R_95_A_HORIZ_INPUT_WINDOW_START_MSB, 0x00,
182 300
183static const unsigned char saa7115_cfg_60hz_video[] = { 301 /* hsize low (input), 0x02d0 = 720 */
184 0x80, 0x00, /* reset tasks */ 302 R_96_A_HORIZ_INPUT_WINDOW_LENGTH, 0xd0,
185 0x88, 0xd0, /* reset scaler */ 303 R_97_A_HORIZ_INPUT_WINDOW_LENGTH_MSB, 0x02,
186 304
187 0x15, 0x03, /* VGATE pulse start */ 305 R_98_A_VERT_INPUT_WINDOW_START, 0x05,
188 0x16, 0x11, /* VGATE pulse stop */ 306 R_99_A_VERT_INPUT_WINDOW_START_MSB, 0x00,
189 0x17, 0x9c, /* VGATE MSB and other values */
190 307
191 0x08, 0x68, /* 0xBO: auto detection, 0x68 = NTSC */ 308 R_9A_A_VERT_INPUT_WINDOW_LENGTH, 0x0c,
192 0x0e, 0x07, /* lots of different stuff... video autodetection is on */ 309 R_9B_A_VERT_INPUT_WINDOW_LENGTH_MSB, 0x00,
193 310
194 0x5a, 0x06, /* Vertical offset, standard 60hz value for ITU656 line counting */ 311 R_9C_A_HORIZ_OUTPUT_WINDOW_LENGTH, 0xa0,
312 R_9D_A_HORIZ_OUTPUT_WINDOW_LENGTH_MSB, 0x05,
195 313
196 /* Task A */ 314 R_9E_A_VERT_OUTPUT_WINDOW_LENGTH, 0x0c,
197 0x90, 0x80, /* Task Handling Control */ 315 R_9F_A_VERT_OUTPUT_WINDOW_LENGTH_MSB, 0x00,
198 0x91, 0x48, /* X-port formats/config */
199 0x92, 0x40, /* Input Ref. signal Def. */
200 0x93, 0x84, /* I-port config */
201 0x94, 0x01, /* hoffset low (input), 0x0002 is minimum */
202 0x95, 0x00, /* hoffset hi (input) */
203 0x96, 0xd0, /* hsize low (input), 0x02d0 = 720 */
204 0x97, 0x02, /* hsize hi (input) */
205 0x98, 0x05, /* voffset low (input) */
206 0x99, 0x00, /* voffset hi (input) */
207 0x9a, 0x0c, /* vsize low (input), 0x0c = 12 */
208 0x9b, 0x00, /* vsize hi (input) */
209 0x9c, 0xa0, /* hsize low (output), 0x05a0 = 1440 */
210 0x9d, 0x05, /* hsize hi (output) */
211 0x9e, 0x0c, /* vsize low (output), 0x0c = 12 */
212 0x9f, 0x00, /* vsize hi (output) */
213 316
214 /* Task B */ 317 /* Task B */
215 0xc0, 0x00, /* Task Handling Control */ 318 R_C0_B_TASK_HANDLING_CNTL, 0x00,
216 0xc1, 0x08, /* X-port formats/config */ 319 R_C1_B_X_PORT_FORMATS_AND_CONF, 0x08,
217 0xc2, 0x00, /* Input Ref. signal Def. */ 320 R_C2_B_INPUT_REFERENCE_SIGNAL_DEFINITION, 0x00,
218 0xc3, 0x80, /* I-port config */ 321 R_C3_B_I_PORT_FORMATS_AND_CONF, 0x80,
219 0xc4, 0x02, /* hoffset low (input), 0x0002 is minimum */
220 0xc5, 0x00, /* hoffset hi (input) */
221 0xc6, 0xd0, /* hsize low (input), 0x02d0 = 720 */
222 0xc7, 0x02, /* hsize hi (input) */
223 0xc8, 0x12, /* voffset low (input), 0x12 = 18 */
224 0xc9, 0x00, /* voffset hi (input) */
225 0xca, 0xf8, /* vsize low (input), 0xf8 = 248 */
226 0xcb, 0x00, /* vsize hi (input) */
227 0xcc, 0xd0, /* hsize low (output), 0x02d0 = 720 */
228 0xcd, 0x02, /* hsize hi (output) */
229
230 0xf0, 0xad, /* Set PLL Register. 60hz 525 lines per frame, 27 MHz */
231 0xf1, 0x05, /* low bit with 0xF0 */
232 0xf5, 0xad, /* Set pulse generator register */
233 0xf6, 0x01,
234
235 0x87, 0x00, /* Disable I-port output */
236 0x88, 0xd0, /* reset scaler */
237 0x80, 0x20, /* Activate only task "B", continuous mode (was 0xA0) */
238 0x88, 0xf0, /* activate scaler */
239 0x87, 0x01, /* Enable I-port output */
240 0x00, 0x00
241};
242 322
243static const unsigned char saa7115_cfg_50hz_fullres_x[] = { 323 /* 0x0002 is minimum */
244 0xcc, 0xd0, /* hsize low (output), 720 same as 60hz */ 324 R_C4_B_HORIZ_INPUT_WINDOW_START, 0x02,
245 0xcd, 0x02, /* hsize hi (output) */ 325 R_C5_B_HORIZ_INPUT_WINDOW_START_MSB, 0x00,
246 326
247 0xd0, 0x01, /* down scale = 1 */ 327 /* 0x02d0 = 720 */
248 0xd8, 0x00, /* hor lum scaling 0x0400 = 1 */ 328 R_C6_B_HORIZ_INPUT_WINDOW_LENGTH, 0xd0,
249 0xd9, 0x04, 329 R_C7_B_HORIZ_INPUT_WINDOW_LENGTH_MSB, 0x02,
250 0xdc, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
251 0xdd, 0x02, /* H-scaling incr chroma */
252 330
253 0x00, 0x00 331 /* vwindow start 0x12 = 18 */
254}; 332 R_C8_B_VERT_INPUT_WINDOW_START, 0x12,
255static const unsigned char saa7115_cfg_50hz_fullres_y[] = { 333 R_C9_B_VERT_INPUT_WINDOW_START_MSB, 0x00,
256 0xce, 0x20, /* vsize low (output), 0x0120 = 288 */ 334
257 0xcf, 0x01, /* vsize hi (output) */ 335 /* vwindow length 0xf8 = 248 */
336 R_CA_B_VERT_INPUT_WINDOW_LENGTH, VRES_60HZ>>1,
337 R_CB_B_VERT_INPUT_WINDOW_LENGTH_MSB, VRES_60HZ>>9,
258 338
259 0xd5, 0x40, /* Lum contrast, nominal value = 0x40 */ 339 /* hwindow 0x02d0 = 720 */
260 0xd6, 0x40, /* Chroma satur. nominal value = 0x80 */ 340 R_CC_B_HORIZ_OUTPUT_WINDOW_LENGTH, 0xd0,
341 R_CD_B_HORIZ_OUTPUT_WINDOW_LENGTH_MSB, 0x02,
261 342
262 0xe0, 0x00, /* V-scaling incr luma low */ 343 R_F0_LFCO_PER_LINE, 0xad, /* Set PLL Register. 60hz 525 lines per frame, 27 MHz */
263 0xe1, 0x04, /* " hi */ 344 R_F1_P_I_PARAM_SELECT, 0x05, /* low bit with 0xF0 */
264 0xe2, 0x00, /* V-scaling incr chroma low */ 345 R_F5_PULSGEN_LINE_LENGTH, 0xad,
265 0xe3, 0x04, /* " hi */ 346 R_F6_PULSE_A_POS_LSB_AND_PULSEGEN_CONFIG, 0x01,
266 347
267 0x00, 0x00 348 0x00, 0x00
268}; 349};
269 350
270static const unsigned char saa7115_cfg_50hz_video[] = { 351static const unsigned char saa7115_cfg_50hz_video[] = {
271 0x80, 0x00, /* reset tasks */ 352 R_80_GLOBAL_CNTL_1, 0x00,
272 0x88, 0xd0, /* reset scaler */ 353 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset scaler */
273 354
274 0x15, 0x37, /* VGATE start */ 355 R_15_VGATE_START_FID_CHG, 0x37, /* VGATE start */
275 0x16, 0x16, /* VGATE stop */ 356 R_16_VGATE_STOP, 0x16,
276 0x17, 0x99, /* VGATE MSB and other values */ 357 R_17_MISC_VGATE_CONF_AND_MSB, 0x99,
277 358
278 0x08, 0x28, /* 0x28 = PAL */ 359 R_08_SYNC_CNTL, 0x28, /* 0x28 = PAL */
279 0x0e, 0x07, /* chrominance control 1 */ 360 R_0E_CHROMA_CNTL_1, 0x07,
280 361
281 0x5a, 0x03, /* Vertical offset, standard 50hz value */ 362 R_5A_V_OFF_FOR_SLICER, 0x03, /* standard 50hz value */
282 363
283 /* Task A */ 364 /* Task A */
284 0x90, 0x81, /* Task Handling Control */ 365 R_90_A_TASK_HANDLING_CNTL, 0x81,
285 0x91, 0x48, /* X-port formats/config */ 366 R_91_A_X_PORT_FORMATS_AND_CONF, 0x48,
286 0x92, 0x40, /* Input Ref. signal Def. */ 367 R_92_A_X_PORT_INPUT_REFERENCE_SIGNAL, 0x40,
287 0x93, 0x84, /* I-port config */ 368 R_93_A_I_PORT_OUTPUT_FORMATS_AND_CONF, 0x84,
369
288 /* This is weird: the datasheet says that you should use 2 as the minimum value, */ 370 /* This is weird: the datasheet says that you should use 2 as the minimum value, */
289 /* but Hauppauge uses 0, and changing that to 2 causes indeed problems (for 50hz) */ 371 /* but Hauppauge uses 0, and changing that to 2 causes indeed problems (for 50hz) */
290 0x94, 0x00, /* hoffset low (input), 0x0002 is minimum */ 372 /* hoffset low (input), 0x0002 is minimum */
291 0x95, 0x00, /* hoffset hi (input) */ 373 R_94_A_HORIZ_INPUT_WINDOW_START, 0x00,
292 0x96, 0xd0, /* hsize low (input), 0x02d0 = 720 */ 374 R_95_A_HORIZ_INPUT_WINDOW_START_MSB, 0x00,
293 0x97, 0x02, /* hsize hi (input) */ 375
294 0x98, 0x03, /* voffset low (input) */ 376 /* hsize low (input), 0x02d0 = 720 */
295 0x99, 0x00, /* voffset hi (input) */ 377 R_96_A_HORIZ_INPUT_WINDOW_LENGTH, 0xd0,
296 0x9a, 0x12, /* vsize low (input), 0x12 = 18 */ 378 R_97_A_HORIZ_INPUT_WINDOW_LENGTH_MSB, 0x02,
297 0x9b, 0x00, /* vsize hi (input) */ 379
298 0x9c, 0xa0, /* hsize low (output), 0x05a0 = 1440 */ 380 R_98_A_VERT_INPUT_WINDOW_START, 0x03,
299 0x9d, 0x05, /* hsize hi (output) */ 381 R_99_A_VERT_INPUT_WINDOW_START_MSB, 0x00,
300 0x9e, 0x12, /* vsize low (output), 0x12 = 18 */ 382
301 0x9f, 0x00, /* vsize hi (output) */ 383 /* vsize 0x12 = 18 */
384 R_9A_A_VERT_INPUT_WINDOW_LENGTH, 0x12,
385 R_9B_A_VERT_INPUT_WINDOW_LENGTH_MSB, 0x00,
386
387 /* hsize 0x05a0 = 1440 */
388 R_9C_A_HORIZ_OUTPUT_WINDOW_LENGTH, 0xa0,
389 R_9D_A_HORIZ_OUTPUT_WINDOW_LENGTH_MSB, 0x05, /* hsize hi (output) */
390 R_9E_A_VERT_OUTPUT_WINDOW_LENGTH, 0x12, /* vsize low (output), 0x12 = 18 */
391 R_9F_A_VERT_OUTPUT_WINDOW_LENGTH_MSB, 0x00, /* vsize hi (output) */
302 392
303 /* Task B */ 393 /* Task B */
304 0xc0, 0x00, /* Task Handling Control */ 394 R_C0_B_TASK_HANDLING_CNTL, 0x00,
305 0xc1, 0x08, /* X-port formats/config */ 395 R_C1_B_X_PORT_FORMATS_AND_CONF, 0x08,
306 0xc2, 0x00, /* Input Ref. signal Def. */ 396 R_C2_B_INPUT_REFERENCE_SIGNAL_DEFINITION, 0x00,
307 0xc3, 0x80, /* I-port config */ 397 R_C3_B_I_PORT_FORMATS_AND_CONF, 0x80,
308 0xc4, 0x00, /* hoffset low (input), 0x0002 is minimum. See comment at 0x94 above. */ 398
309 0xc5, 0x00, /* hoffset hi (input) */ 399 /* This is weird: the datasheet says that you should use 2 as the minimum value, */
310 0xc6, 0xd0, /* hsize low (input), 0x02d0 = 720 */ 400 /* but Hauppauge uses 0, and changing that to 2 causes indeed problems (for 50hz) */
311 0xc7, 0x02, /* hsize hi (input) */ 401 /* hoffset low (input), 0x0002 is minimum. See comment above. */
312 0xc8, 0x16, /* voffset low (input), 0x16 = 22 */ 402 R_C4_B_HORIZ_INPUT_WINDOW_START, 0x00,
313 0xc9, 0x00, /* voffset hi (input) */ 403 R_C5_B_HORIZ_INPUT_WINDOW_START_MSB, 0x00,
314 0xca, 0x20, /* vsize low (input), 0x0120 = 288 */ 404
315 0xcb, 0x01, /* vsize hi (input) */ 405 /* hsize 0x02d0 = 720 */
316 0xcc, 0xd0, /* hsize low (output), 0x02d0 = 720 */ 406 R_C6_B_HORIZ_INPUT_WINDOW_LENGTH, 0xd0,
317 0xcd, 0x02, /* hsize hi (output) */ 407 R_C7_B_HORIZ_INPUT_WINDOW_LENGTH_MSB, 0x02,
318 0xce, 0x20, /* vsize low (output), 0x0120 = 288 */ 408
319 0xcf, 0x01, /* vsize hi (output) */ 409 /* voffset 0x16 = 22 */
320 410 R_C8_B_VERT_INPUT_WINDOW_START, 0x16,
321 0xf0, 0xb0, /* Set PLL Register. 50hz 625 lines per frame, 27 MHz */ 411 R_C9_B_VERT_INPUT_WINDOW_START_MSB, 0x00,
322 0xf1, 0x05, /* low bit with 0xF0, (was 0x05) */ 412
323 0xf5, 0xb0, /* Set pulse generator register */ 413 /* vsize 0x0120 = 288 */
324 0xf6, 0x01, 414 R_CA_B_VERT_INPUT_WINDOW_LENGTH, 0x20,
325 415 R_CB_B_VERT_INPUT_WINDOW_LENGTH_MSB, 0x01,
326 0x87, 0x00, /* Disable I-port output */ 416
327 0x88, 0xd0, /* reset scaler (was 0xD0) */ 417 /* hsize 0x02d0 = 720 */
328 0x80, 0x20, /* Activate only task "B" */ 418 R_CC_B_HORIZ_OUTPUT_WINDOW_LENGTH, 0xd0,
329 0x88, 0xf0, /* activate scaler */ 419 R_CD_B_HORIZ_OUTPUT_WINDOW_LENGTH_MSB, 0x02,
330 0x87, 0x01, /* Enable I-port output */ 420
421 R_F0_LFCO_PER_LINE, 0xb0, /* Set PLL Register. 50hz 625 lines per frame, 27 MHz */
422 R_F1_P_I_PARAM_SELECT, 0x05, /* low bit with 0xF0, (was 0x05) */
423 R_F5_PULSGEN_LINE_LENGTH, 0xb0,
424 R_F6_PULSE_A_POS_LSB_AND_PULSEGEN_CONFIG, 0x01,
425
331 0x00, 0x00 426 0x00, 0x00
332}; 427};
333 428
334/* ============== SAA7715 VIDEO templates (end) ======= */ 429/* ============== SAA7715 VIDEO templates (end) ======= */
335 430
336static const unsigned char saa7115_cfg_vbi_on[] = { 431static const unsigned char saa7115_cfg_vbi_on[] = {
337 0x80, 0x00, /* reset tasks */ 432 R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */
338 0x88, 0xd0, /* reset scaler */ 433 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset scaler */
339 0x80, 0x30, /* Activate both tasks */ 434 R_80_GLOBAL_CNTL_1, 0x30, /* Activate both tasks */
340 0x88, 0xf0, /* activate scaler */ 435 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xf0, /* activate scaler */
341 0x87, 0x01, /* Enable I-port output */ 436 R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED, 0x01, /* Enable I-port output */
437
342 0x00, 0x00 438 0x00, 0x00
343}; 439};
344 440
345static const unsigned char saa7115_cfg_vbi_off[] = { 441static const unsigned char saa7115_cfg_vbi_off[] = {
346 0x80, 0x00, /* reset tasks */ 442 R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */
347 0x88, 0xd0, /* reset scaler */ 443 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0, /* reset scaler */
348 0x80, 0x20, /* Activate only task "B" */ 444 R_80_GLOBAL_CNTL_1, 0x20, /* Activate only task "B" */
349 0x88, 0xf0, /* activate scaler */ 445 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xf0, /* activate scaler */
350 0x87, 0x01, /* Enable I-port output */ 446 R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED, 0x01, /* Enable I-port output */
351 0x00, 0x00
352};
353 447
354static const unsigned char saa7113_init_auto_input[] = {
355 0x01, 0x08, /* PH7113_INCREMENT_DELAY - (1) (1) (1) (1) IDEL3 IDEL2 IDELL1 IDEL0 */
356 0x02, 0xc2, /* PH7113_ANALOG_INPUT_CONTR_1 - FUSE1 FUSE0 GUDL1 GUDL0 MODE3 MODE2 MODE1 MODE0 */
357 0x03, 0x30, /* PH7113_ANALOG_INPUT_CONTR_2 - (1) HLNRS VBSL WPOFF HOLDG GAFIX GAI28 GAI18 */
358 0x04, 0x00, /* PH7113_ANALOG_INPUT_CONTR_3 - GAI17 GAI16 GAI15 GAI14 GAI13 GAI12 GAI11 GAI10 */
359 0x05, 0x00, /* PH7113_ANALOG_INPUT_CONTR_4 - GAI27 GAI26 GAI25 GAI24 GAI23 GAI22 GAI21 GAI20 */
360 0x06, 0x89, /* PH7113_HORIZONTAL_SYNC_START - HSB7 HSB6 HSB5 HSB4 HSB3 HSB2 HSB1 HSB0 */
361 0x07, 0x0d, /* PH7113_HORIZONTAL_SYNC_STOP - HSS7 HSS6 HSS5 HSS4 HSS3 HSS2 HSS1 HSS0 */
362 0x08, 0x88, /* PH7113_SYNC_CONTROL - AUFD FSEL FOET HTC1 HTC0 HPLL VNOI1 VNOI0 */
363 0x09, 0x01, /* PH7113_LUMINANCE_CONTROL - BYPS PREF BPSS1 BPSS0 VBLB UPTCV APER1 APER0 */
364 0x0a, 0x80, /* PH7113_LUMINANCE_BRIGHTNESS - BRIG7 BRIG6 BRIG5 BRIG4 BRIG3 BRIG2 BRIG1 BRIG0 */
365 0x0b, 0x47, /* PH7113_LUMINANCE_CONTRAST - CONT7 CONT6 CONT5 CONT4 CONT3 CONT2 CONT1 CONT0 */
366 0x0c, 0x40, /* PH7113_CHROMA_SATURATION - SATN7 SATN6 SATN5 SATN4 SATN3 SATN2 SATN1 SATN0 */
367 0x0d, 0x00, /* PH7113_CHROMA_HUE_CONTROL - HUEC7 HUEC6 HUEC5 HUEC4 HUEC3 HUEC2 HUEC1 HUEC0 */
368 0x0e, 0x01, /* PH7113_CHROMA_CONTROL - CDTO CSTD2 CSTD1 CSTD0 DCCF FCTC CHBW1 CHBW0 */
369 0x0f, 0x2a, /* PH7113_CHROMA_GAIN_CONTROL - ACGC CGAIN6 CGAIN5 CGAIN4 CGAIN3 CGAIN2 CGAIN1 CGAIN0 */
370 0x10, 0x08, /* PH7113_FORMAT_DELAY_CONTROL - OFTS1 OFTS0 HDEL1 HDEL0 VRLN YDEL2 YDEL1 YDEL0 */
371 0x11, 0x0c, /* PH7113_OUTPUT_CONTROL_1 - GPSW1 CM99 GPSW0 HLSEL OEYC OERT VIPB COLO */
372 0x12, 0x07, /* PH7113_OUTPUT_CONTROL_2 - RTSE13 RTSE12 RTSE11 RTSE10 RTSE03 RTSE02 RTSE01 RTSE00 */
373 0x13, 0x00, /* PH7113_OUTPUT_CONTROL_3 - ADLSB (1) (1) OLDSB FIDP (1) AOSL1 AOSL0 */
374 0x14, 0x00, /* RESERVED 14 - (1) (1) (1) (1) (1) (1) (1) (1) */
375 0x15, 0x00, /* PH7113_V_GATE1_START - VSTA7 VSTA6 VSTA5 VSTA4 VSTA3 VSTA2 VSTA1 VSTA0 */
376 0x16, 0x00, /* PH7113_V_GATE1_STOP - VSTO7 VSTO6 VSTO5 VSTO4 VSTO3 VSTO2 VSTO1 VSTO0 */
377 0x17, 0x00, /* PH7113_V_GATE1_MSB - (1) (1) (1) (1) (1) (1) VSTO8 VSTA8 */
378 0x00, 0x00 448 0x00, 0x00
379}; 449};
380 450
451
381static const unsigned char saa7115_init_misc[] = { 452static const unsigned char saa7115_init_misc[] = {
382 0x81, 0x01, /* reg 0x15,0x16 define blanking window */ 453 R_81_V_SYNC_FLD_ID_SRC_SEL_AND_RETIMED_V_F, 0x01,
383 0x82, 0x00, 454 R_83_X_PORT_I_O_ENA_AND_OUT_CLK, 0x01,
384 0x83, 0x01, /* I port settings */ 455 R_84_I_PORT_SIGNAL_DEF, 0x20,
385 0x84, 0x20, 456 R_85_I_PORT_SIGNAL_POLAR, 0x21,
386 0x85, 0x21, 457 R_86_I_PORT_FIFO_FLAG_CNTL_AND_ARBIT, 0xc5,
387 0x86, 0xc5, 458 R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED, 0x01,
388 0x87, 0x01,
389 459
390 /* Task A */ 460 /* Task A */
391 0xa0, 0x01, /* down scale = 1 */ 461 R_A0_A_HORIZ_PRESCALING, 0x01,
392 0xa1, 0x00, /* prescale accumulation length = 1 */ 462 R_A1_A_ACCUMULATION_LENGTH, 0x00,
393 0xa2, 0x00, /* dc gain and fir prefilter control */ 463 R_A2_A_PRESCALER_DC_GAIN_AND_FIR_PREFILTER, 0x00,
394 0xa4, 0x80, /* Lum Brightness, nominal value = 0x80 */ 464
395 0xa5, 0x40, /* Lum contrast, nominal value = 0x40 */ 465 /* Configure controls at nominal value*/
396 0xa6, 0x40, /* Chroma satur. nominal value = 0x80 */ 466 R_A4_A_LUMA_BRIGHTNESS_CNTL, 0x80,
397 0xa8, 0x00, /* hor lum scaling 0x0200 = 2 zoom */ 467 R_A5_A_LUMA_CONTRAST_CNTL, 0x40,
398 0xa9, 0x02, /* note: 2 x zoom ensures that VBI lines have same length as video lines. */ 468 R_A6_A_CHROMA_SATURATION_CNTL, 0x40,
399 0xaa, 0x00, /* H-phase offset Luma = 0 */ 469
400 0xac, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */ 470 /* note: 2 x zoom ensures that VBI lines have same length as video lines. */
401 0xad, 0x01, /* H-scaling incr chroma */ 471 R_A8_A_HORIZ_LUMA_SCALING_INC, 0x00,
402 0xae, 0x00, /* H-phase offset chroma. must be offset luma / 2 */ 472 R_A9_A_HORIZ_LUMA_SCALING_INC_MSB, 0x02,
403 473
404 0xb0, 0x00, /* V-scaling incr luma low */ 474 R_AA_A_HORIZ_LUMA_PHASE_OFF, 0x00,
405 0xb1, 0x04, /* " hi */ 475
406 0xb2, 0x00, /* V-scaling incr chroma low */ 476 /* must be horiz lum scaling / 2 */
407 0xb3, 0x04, /* " hi */ 477 R_AC_A_HORIZ_CHROMA_SCALING_INC, 0x00,
408 0xb4, 0x01, /* V-scaling mode control */ 478 R_AD_A_HORIZ_CHROMA_SCALING_INC_MSB, 0x01,
409 0xb8, 0x00, /* V-phase offset chroma 00 */ 479
410 0xb9, 0x00, /* V-phase offset chroma 01 */ 480 /* must be offset luma / 2 */
411 0xba, 0x00, /* V-phase offset chroma 10 */ 481 R_AE_A_HORIZ_CHROMA_PHASE_OFF, 0x00,
412 0xbb, 0x00, /* V-phase offset chroma 11 */ 482
413 0xbc, 0x00, /* V-phase offset luma 00 */ 483 R_B0_A_VERT_LUMA_SCALING_INC, 0x00,
414 0xbd, 0x00, /* V-phase offset luma 01 */ 484 R_B1_A_VERT_LUMA_SCALING_INC_MSB, 0x04,
415 0xbe, 0x00, /* V-phase offset luma 10 */ 485
416 0xbf, 0x00, /* V-phase offset luma 11 */ 486 R_B2_A_VERT_CHROMA_SCALING_INC, 0x00,
487 R_B3_A_VERT_CHROMA_SCALING_INC_MSB, 0x04,
488
489 R_B4_A_VERT_SCALING_MODE_CNTL, 0x01,
490
491 R_B8_A_VERT_CHROMA_PHASE_OFF_00, 0x00,
492 R_B9_A_VERT_CHROMA_PHASE_OFF_01, 0x00,
493 R_BA_A_VERT_CHROMA_PHASE_OFF_10, 0x00,
494 R_BB_A_VERT_CHROMA_PHASE_OFF_11, 0x00,
495
496 R_BC_A_VERT_LUMA_PHASE_OFF_00, 0x00,
497 R_BD_A_VERT_LUMA_PHASE_OFF_01, 0x00,
498 R_BE_A_VERT_LUMA_PHASE_OFF_10, 0x00,
499 R_BF_A_VERT_LUMA_PHASE_OFF_11, 0x00,
417 500
418 /* Task B */ 501 /* Task B */
419 0xd0, 0x01, /* down scale = 1 */ 502 R_D0_B_HORIZ_PRESCALING, 0x01,
420 0xd1, 0x00, /* prescale accumulation length = 1 */ 503 R_D1_B_ACCUMULATION_LENGTH, 0x00,
421 0xd2, 0x00, /* dc gain and fir prefilter control */ 504 R_D2_B_PRESCALER_DC_GAIN_AND_FIR_PREFILTER, 0x00,
422 0xd4, 0x80, /* Lum Brightness, nominal value = 0x80 */ 505
423 0xd5, 0x40, /* Lum contrast, nominal value = 0x40 */ 506 /* Configure controls at nominal value*/
424 0xd6, 0x40, /* Chroma satur. nominal value = 0x80 */ 507 R_D4_B_LUMA_BRIGHTNESS_CNTL, 0x80,
425 0xd8, 0x00, /* hor lum scaling 0x0400 = 1 */ 508 R_D5_B_LUMA_CONTRAST_CNTL, 0x40,
426 0xd9, 0x04, 509 R_D6_B_CHROMA_SATURATION_CNTL, 0x40,
427 0xda, 0x00, /* H-phase offset Luma = 0 */ 510
428 0xdc, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */ 511 /* hor lum scaling 0x0400 = 1 */
429 0xdd, 0x02, /* H-scaling incr chroma */ 512 R_D8_B_HORIZ_LUMA_SCALING_INC, 0x00,
430 0xde, 0x00, /* H-phase offset chroma. must be offset luma / 2 */ 513 R_D9_B_HORIZ_LUMA_SCALING_INC_MSB, 0x04,
431 514
432 0xe0, 0x00, /* V-scaling incr luma low */ 515 R_DA_B_HORIZ_LUMA_PHASE_OFF, 0x00,
433 0xe1, 0x04, /* " hi */ 516
434 0xe2, 0x00, /* V-scaling incr chroma low */ 517 /* must be hor lum scaling / 2 */
435 0xe3, 0x04, /* " hi */ 518 R_DC_B_HORIZ_CHROMA_SCALING, 0x00,
436 0xe4, 0x01, /* V-scaling mode control */ 519 R_DD_B_HORIZ_CHROMA_SCALING_MSB, 0x02,
437 0xe8, 0x00, /* V-phase offset chroma 00 */ 520
438 0xe9, 0x00, /* V-phase offset chroma 01 */ 521 /* must be offset luma / 2 */
439 0xea, 0x00, /* V-phase offset chroma 10 */ 522 R_DE_B_HORIZ_PHASE_OFFSET_CRHOMA, 0x00,
440 0xeb, 0x00, /* V-phase offset chroma 11 */ 523
441 0xec, 0x00, /* V-phase offset luma 00 */ 524 R_E0_B_VERT_LUMA_SCALING_INC, 0x00,
442 0xed, 0x00, /* V-phase offset luma 01 */ 525 R_E1_B_VERT_LUMA_SCALING_INC_MSB, 0x04,
443 0xee, 0x00, /* V-phase offset luma 10 */ 526
444 0xef, 0x00, /* V-phase offset luma 11 */ 527 R_E2_B_VERT_CHROMA_SCALING_INC, 0x00,
445 528 R_E3_B_VERT_CHROMA_SCALING_INC_MSB, 0x04,
446 0xf2, 0x50, /* crystal clock = 24.576 MHz, target = 27MHz */ 529
447 0xf3, 0x46, 530 R_E4_B_VERT_SCALING_MODE_CNTL, 0x01,
448 0xf4, 0x00, 531
449 0xf7, 0x4b, /* not the recommended settings! */ 532 R_E8_B_VERT_CHROMA_PHASE_OFF_00, 0x00,
450 0xf8, 0x00, 533 R_E9_B_VERT_CHROMA_PHASE_OFF_01, 0x00,
451 0xf9, 0x4b, 534 R_EA_B_VERT_CHROMA_PHASE_OFF_10, 0x00,
452 0xfa, 0x00, 535 R_EB_B_VERT_CHROMA_PHASE_OFF_11, 0x00,
453 0xfb, 0x4b, 536
454 0xff, 0x88, /* PLL2 lock detection settings: 71 lines 50% phase error */ 537 R_EC_B_VERT_LUMA_PHASE_OFF_00, 0x00,
538 R_ED_B_VERT_LUMA_PHASE_OFF_01, 0x00,
539 R_EE_B_VERT_LUMA_PHASE_OFF_10, 0x00,
540 R_EF_B_VERT_LUMA_PHASE_OFF_11, 0x00,
541
542 R_F2_NOMINAL_PLL2_DTO, 0x50, /* crystal clock = 24.576 MHz, target = 27MHz */
543 R_F3_PLL_INCREMENT, 0x46,
544 R_F4_PLL2_STATUS, 0x00,
545 R_F7_PULSE_A_POS_MSB, 0x4b, /* not the recommended settings! */
546 R_F8_PULSE_B_POS, 0x00,
547 R_F9_PULSE_B_POS_MSB, 0x4b,
548 R_FA_PULSE_C_POS, 0x00,
549 R_FB_PULSE_C_POS_MSB, 0x4b,
550
551 /* PLL2 lock detection settings: 71 lines 50% phase error */
552 R_FF_S_PLL_MAX_PHASE_ERR_THRESH_NUM_LINES, 0x88,
455 553
456 /* Turn off VBI */ 554 /* Turn off VBI */
457 0x40, 0x20, /* No framing code errors allowed. */ 555 R_40_SLICER_CNTL_1, 0x20, /* No framing code errors allowed. */
458 0x41, 0xff, 556 R_41_LCR_BASE, 0xff,
459 0x42, 0xff, 557 R_41_LCR_BASE+1, 0xff,
460 0x43, 0xff, 558 R_41_LCR_BASE+2, 0xff,
461 0x44, 0xff, 559 R_41_LCR_BASE+3, 0xff,
462 0x45, 0xff, 560 R_41_LCR_BASE+4, 0xff,
463 0x46, 0xff, 561 R_41_LCR_BASE+5, 0xff,
464 0x47, 0xff, 562 R_41_LCR_BASE+6, 0xff,
465 0x48, 0xff, 563 R_41_LCR_BASE+7, 0xff,
466 0x49, 0xff, 564 R_41_LCR_BASE+8, 0xff,
467 0x4a, 0xff, 565 R_41_LCR_BASE+9, 0xff,
468 0x4b, 0xff, 566 R_41_LCR_BASE+10, 0xff,
469 0x4c, 0xff, 567 R_41_LCR_BASE+11, 0xff,
470 0x4d, 0xff, 568 R_41_LCR_BASE+12, 0xff,
471 0x4e, 0xff, 569 R_41_LCR_BASE+13, 0xff,
472 0x4f, 0xff, 570 R_41_LCR_BASE+14, 0xff,
473 0x50, 0xff, 571 R_41_LCR_BASE+15, 0xff,
474 0x51, 0xff, 572 R_41_LCR_BASE+16, 0xff,
475 0x52, 0xff, 573 R_41_LCR_BASE+17, 0xff,
476 0x53, 0xff, 574 R_41_LCR_BASE+18, 0xff,
477 0x54, 0xff, 575 R_41_LCR_BASE+19, 0xff,
478 0x55, 0xff, 576 R_41_LCR_BASE+20, 0xff,
479 0x56, 0xff, 577 R_41_LCR_BASE+21, 0xff,
480 0x57, 0xff, 578 R_41_LCR_BASE+22, 0xff,
481 0x58, 0x40, 579 R_58_PROGRAM_FRAMING_CODE, 0x40,
482 0x59, 0x47, 580 R_59_H_OFF_FOR_SLICER, 0x47,
483 0x5b, 0x83, 581 R_5B_FLD_OFF_AND_MSB_FOR_H_AND_V_OFF, 0x83,
484 0x5d, 0xbd, 582 R_5D_DID, 0xbd,
485 0x5e, 0x35, 583 R_5E_SDID, 0x35,
486 584
487 0x02, 0x84, /* input tuner -> input 4, amplifier active */ 585 R_02_INPUT_CNTL_1, 0x84, /* input tuner -> input 4, amplifier active */
488 0x09, 0x53, /* 0x53, was 0x56 for 60hz. luminance control */ 586
489 587 R_80_GLOBAL_CNTL_1, 0x20, /* enable task B */
490 0x80, 0x20, /* enable task B */ 588 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xd0,
491 0x88, 0xd0, 589 R_88_POWER_SAVE_ADC_PORT_CNTL, 0xf0,
492 0x88, 0xf0,
493 0x00, 0x00 590 0x00, 0x00
494}; 591};
495 592
496static int saa7115_odd_parity(u8 c) 593static int saa711x_odd_parity(u8 c)
497{ 594{
498 c ^= (c >> 4); 595 c ^= (c >> 4);
499 c ^= (c >> 2); 596 c ^= (c >> 2);
@@ -502,7 +599,7 @@ static int saa7115_odd_parity(u8 c)
502 return c & 1; 599 return c & 1;
503} 600}
504 601
505static int saa7115_decode_vps(u8 * dst, u8 * p) 602static int saa711x_decode_vps(u8 * dst, u8 * p)
506{ 603{
507 static const u8 biphase_tbl[] = { 604 static const u8 biphase_tbl[] = {
508 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, 605 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
@@ -549,7 +646,7 @@ static int saa7115_decode_vps(u8 * dst, u8 * p)
549 return err & 0xf0; 646 return err & 0xf0;
550} 647}
551 648
552static int saa7115_decode_wss(u8 * p) 649static int saa711x_decode_wss(u8 * p)
553{ 650{
554 static const int wss_bits[8] = { 651 static const int wss_bits[8] = {
555 0, 0, 0, 1, 0, 1, 1, 1 652 0, 0, 0, 1, 0, 1, 1, 1
@@ -576,26 +673,25 @@ static int saa7115_decode_wss(u8 * p)
576 return wss; 673 return wss;
577} 674}
578 675
579 676static int saa711x_set_audio_clock_freq(struct i2c_client *client, u32 freq)
580static int saa7115_set_audio_clock_freq(struct i2c_client *client, u32 freq)
581{ 677{
582 struct saa7115_state *state = i2c_get_clientdata(client); 678 struct saa711x_state *state = i2c_get_clientdata(client);
583 u32 acpf; 679 u32 acpf;
584 u32 acni; 680 u32 acni;
585 u32 hz; 681 u32 hz;
586 u64 f; 682 u64 f;
587 u8 acc = 0; /* reg 0x3a, audio clock control */ 683 u8 acc = 0; /* reg 0x3a, audio clock control */
588 684
685 /* Checks for chips that don't have audio clock (saa7111, saa7113) */
686 if (!saa711x_has_reg(state->ident,R_30_AUD_MAST_CLK_CYCLES_PER_FIELD))
687 return 0;
688
589 v4l_dbg(1, debug, client, "set audio clock freq: %d\n", freq); 689 v4l_dbg(1, debug, client, "set audio clock freq: %d\n", freq);
590 690
591 /* sanity check */ 691 /* sanity check */
592 if (freq < 32000 || freq > 48000) 692 if (freq < 32000 || freq > 48000)
593 return -EINVAL; 693 return -EINVAL;
594 694
595 /* The saa7113 has no audio clock */
596 if (state->ident == V4L2_IDENT_SAA7113)
597 return 0;
598
599 /* hz is the refresh rate times 100 */ 695 /* hz is the refresh rate times 100 */
600 hz = (state->std & V4L2_STD_525_60) ? 5994 : 5000; 696 hz = (state->std & V4L2_STD_525_60) ? 5994 : 5000;
601 /* acpf = (256 * freq) / field_frequency == (256 * 100 * freq) / hz */ 697 /* acpf = (256 * freq) / field_frequency == (256 * 100 * freq) / hz */
@@ -617,22 +713,26 @@ static int saa7115_set_audio_clock_freq(struct i2c_client *client, u32 freq)
617 if (state->apll) 713 if (state->apll)
618 acc |= 0x08; 714 acc |= 0x08;
619 715
620 saa7115_write(client, 0x38, 0x03); 716 saa711x_write(client, R_38_CLK_RATIO_AMXCLK_TO_ASCLK, 0x03);
621 saa7115_write(client, 0x39, 0x10); 717 saa711x_write(client, R_39_CLK_RATIO_ASCLK_TO_ALRCLK, 0x10);
622 saa7115_write(client, 0x3a, acc); 718 saa711x_write(client, R_3A_AUD_CLK_GEN_BASIC_SETUP, acc);
623 saa7115_write(client, 0x30, acpf & 0xff); 719
624 saa7115_write(client, 0x31, (acpf >> 8) & 0xff); 720 saa711x_write(client, R_30_AUD_MAST_CLK_CYCLES_PER_FIELD, acpf & 0xff);
625 saa7115_write(client, 0x32, (acpf >> 16) & 0x03); 721 saa711x_write(client, R_30_AUD_MAST_CLK_CYCLES_PER_FIELD+1,
626 saa7115_write(client, 0x34, acni & 0xff); 722 (acpf >> 8) & 0xff);
627 saa7115_write(client, 0x35, (acni >> 8) & 0xff); 723 saa711x_write(client, R_30_AUD_MAST_CLK_CYCLES_PER_FIELD+2,
628 saa7115_write(client, 0x36, (acni >> 16) & 0x3f); 724 (acpf >> 16) & 0x03);
725
726 saa711x_write(client, R_34_AUD_MAST_CLK_NOMINAL_INC, acni & 0xff);
727 saa711x_write(client, R_34_AUD_MAST_CLK_NOMINAL_INC+1, (acni >> 8) & 0xff);
728 saa711x_write(client, R_34_AUD_MAST_CLK_NOMINAL_INC+2, (acni >> 16) & 0x3f);
629 state->audclk_freq = freq; 729 state->audclk_freq = freq;
630 return 0; 730 return 0;
631} 731}
632 732
633static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl) 733static int saa711x_set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
634{ 734{
635 struct saa7115_state *state = i2c_get_clientdata(client); 735 struct saa711x_state *state = i2c_get_clientdata(client);
636 736
637 switch (ctrl->id) { 737 switch (ctrl->id) {
638 case V4L2_CID_BRIGHTNESS: 738 case V4L2_CID_BRIGHTNESS:
@@ -642,7 +742,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c
642 } 742 }
643 743
644 state->bright = ctrl->value; 744 state->bright = ctrl->value;
645 saa7115_write(client, 0x0a, state->bright); 745 saa711x_write(client, R_0A_LUMA_BRIGHT_CNTL, state->bright);
646 break; 746 break;
647 747
648 case V4L2_CID_CONTRAST: 748 case V4L2_CID_CONTRAST:
@@ -652,7 +752,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c
652 } 752 }
653 753
654 state->contrast = ctrl->value; 754 state->contrast = ctrl->value;
655 saa7115_write(client, 0x0b, state->contrast); 755 saa711x_write(client, R_0B_LUMA_CONTRAST_CNTL, state->contrast);
656 break; 756 break;
657 757
658 case V4L2_CID_SATURATION: 758 case V4L2_CID_SATURATION:
@@ -662,7 +762,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c
662 } 762 }
663 763
664 state->sat = ctrl->value; 764 state->sat = ctrl->value;
665 saa7115_write(client, 0x0c, state->sat); 765 saa711x_write(client, R_0C_CHROMA_SAT_CNTL, state->sat);
666 break; 766 break;
667 767
668 case V4L2_CID_HUE: 768 case V4L2_CID_HUE:
@@ -672,7 +772,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c
672 } 772 }
673 773
674 state->hue = ctrl->value; 774 state->hue = ctrl->value;
675 saa7115_write(client, 0x0d, state->hue); 775 saa711x_write(client, R_0D_CHROMA_HUE_CNTL, state->hue);
676 break; 776 break;
677 777
678 default: 778 default:
@@ -682,9 +782,9 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c
682 return 0; 782 return 0;
683} 783}
684 784
685static int saa7115_get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl) 785static int saa711x_get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
686{ 786{
687 struct saa7115_state *state = i2c_get_clientdata(client); 787 struct saa711x_state *state = i2c_get_clientdata(client);
688 788
689 switch (ctrl->id) { 789 switch (ctrl->id) {
690 case V4L2_CID_BRIGHTNESS: 790 case V4L2_CID_BRIGHTNESS:
@@ -706,10 +806,115 @@ static int saa7115_get_v4lctrl(struct i2c_client *client, struct v4l2_control *c
706 return 0; 806 return 0;
707} 807}
708 808
709static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std) 809static int saa711x_set_size(struct i2c_client *client, int width, int height)
810{
811 struct saa711x_state *state = i2c_get_clientdata(client);
812 int HPSC, HFSC;
813 int VSCY;
814 int res;
815 int is_50hz = state->std & V4L2_STD_625_50;
816 int Vsrc = is_50hz ? 576 : 480;
817
818 v4l_dbg(1, debug, client, "decoder set size to %ix%i\n",width,height);
819
820 /* FIXME need better bounds checking here */
821 if ((width < 1) || (width > 1440))
822 return -EINVAL;
823 if ((height < 1) || (height > Vsrc))
824 return -EINVAL;
825
826 if (!saa711x_has_reg(state->ident,R_D0_B_HORIZ_PRESCALING)) {
827 /* Decoder only supports 720 columns and 480 or 576 lines */
828 if (width != 720)
829 return -EINVAL;
830 if (height != Vsrc)
831 return -EINVAL;
832 }
833
834 state->width = width;
835 state->height = height;
836
837 if (!saa711x_has_reg(state->ident, R_CC_B_HORIZ_OUTPUT_WINDOW_LENGTH))
838 return 0;
839
840 /* probably have a valid size, let's set it */
841 /* Set output width/height */
842 /* width */
843
844 saa711x_write(client, R_CC_B_HORIZ_OUTPUT_WINDOW_LENGTH,
845 (u8) (width & 0xff));
846 saa711x_write(client, R_CD_B_HORIZ_OUTPUT_WINDOW_LENGTH_MSB,
847 (u8) ((width >> 8) & 0xff));
848
849 /* Vertical Scaling uses height/2 */
850 res=height/2;
851
852 /* On 60Hz, it is using a higher Vertical Output Size */
853 if (!is_50hz)
854 res+=(VRES_60HZ-480)>>1;
855
856 /* height */
857 saa711x_write(client, R_CE_B_VERT_OUTPUT_WINDOW_LENGTH,
858 (u8) (res & 0xff));
859 saa711x_write(client, R_CF_B_VERT_OUTPUT_WINDOW_LENGTH_MSB,
860 (u8) ((res >> 8) & 0xff));
861
862 /* Scaling settings */
863 /* Hprescaler is floor(inres/outres) */
864 HPSC = (int)(720 / width);
865 /* 0 is not allowed (div. by zero) */
866 HPSC = HPSC ? HPSC : 1;
867 HFSC = (int)((1024 * 720) / (HPSC * width));
868 /* FIXME hardcodes to "Task B"
869 * write H prescaler integer */
870 saa711x_write(client, R_D0_B_HORIZ_PRESCALING,
871 (u8) (HPSC & 0x3f));
872
873 v4l_dbg(1, debug, client, "Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC);
874 /* write H fine-scaling (luminance) */
875 saa711x_write(client, R_D8_B_HORIZ_LUMA_SCALING_INC,
876 (u8) (HFSC & 0xff));
877 saa711x_write(client, R_D9_B_HORIZ_LUMA_SCALING_INC_MSB,
878 (u8) ((HFSC >> 8) & 0xff));
879 /* write H fine-scaling (chrominance)
880 * must be lum/2, so i'll just bitshift :) */
881 saa711x_write(client, R_DC_B_HORIZ_CHROMA_SCALING,
882 (u8) ((HFSC >> 1) & 0xff));
883 saa711x_write(client, R_DD_B_HORIZ_CHROMA_SCALING_MSB,
884 (u8) ((HFSC >> 9) & 0xff));
885
886 VSCY = (int)((1024 * Vsrc) / height);
887 v4l_dbg(1, debug, client, "Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY);
888
889 /* Correct Contrast and Luminance */
890 saa711x_write(client, R_D5_B_LUMA_CONTRAST_CNTL,
891 (u8) (64 * 1024 / VSCY));
892 saa711x_write(client, R_D6_B_CHROMA_SATURATION_CNTL,
893 (u8) (64 * 1024 / VSCY));
894
895 /* write V fine-scaling (luminance) */
896 saa711x_write(client, R_E0_B_VERT_LUMA_SCALING_INC,
897 (u8) (VSCY & 0xff));
898 saa711x_write(client, R_E1_B_VERT_LUMA_SCALING_INC_MSB,
899 (u8) ((VSCY >> 8) & 0xff));
900 /* write V fine-scaling (chrominance) */
901 saa711x_write(client, R_E2_B_VERT_CHROMA_SCALING_INC,
902 (u8) (VSCY & 0xff));
903 saa711x_write(client, R_E3_B_VERT_CHROMA_SCALING_INC_MSB,
904 (u8) ((VSCY >> 8) & 0xff));
905
906 saa711x_writeregs(client, saa7115_cfg_reset_scaler);
907
908 /* Activates task "B" */
909 saa711x_write(client, R_80_GLOBAL_CNTL_1,
910 saa711x_read(client,R_80_GLOBAL_CNTL_1)|0x20);
911
912 return 0;
913}
914
915static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
710{ 916{
711 struct saa7115_state *state = i2c_get_clientdata(client); 917 struct saa711x_state *state = i2c_get_clientdata(client);
712 int taskb = saa7115_read(client, 0x80) & 0x10;
713 918
714 /* Prevent unnecessary standard changes. During a standard 919 /* Prevent unnecessary standard changes. During a standard
715 change the I-Port is temporarily disabled. Any devices 920 change the I-Port is temporarily disabled. Any devices
@@ -721,17 +926,21 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
721 if (std == state->std) 926 if (std == state->std)
722 return; 927 return;
723 928
929 state->std = std;
930
724 // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. 931 // This works for NTSC-M, SECAM-L and the 50Hz PAL variants.
725 if (std & V4L2_STD_525_60) { 932 if (std & V4L2_STD_525_60) {
726 v4l_dbg(1, debug, client, "decoder set standard 60 Hz\n"); 933 v4l_dbg(1, debug, client, "decoder set standard 60 Hz\n");
727 saa7115_writeregs(client, saa7115_cfg_60hz_video); 934 saa711x_writeregs(client, saa7115_cfg_60hz_video);
935 saa711x_set_size(client,720,480);
728 } else { 936 } else {
729 v4l_dbg(1, debug, client, "decoder set standard 50 Hz\n"); 937 v4l_dbg(1, debug, client, "decoder set standard 50 Hz\n");
730 saa7115_writeregs(client, saa7115_cfg_50hz_video); 938 saa711x_writeregs(client, saa7115_cfg_50hz_video);
939 saa711x_set_size(client,720,576);
731 } 940 }
732 941
733 /* Register 0E - Bits D6-D4 on NO-AUTO mode 942 /* Register 0E - Bits D6-D4 on NO-AUTO mode
734 (SAA7113 doesn't have auto mode) 943 (SAA7111 and SAA7113 doesn't have auto mode)
735 50 Hz / 625 lines 60 Hz / 525 lines 944 50 Hz / 625 lines 60 Hz / 525 lines
736 000 PAL BGDHI (4.43Mhz) NTSC M (3.58MHz) 945 000 PAL BGDHI (4.43Mhz) NTSC M (3.58MHz)
737 001 NTSC 4.43 (50 Hz) PAL 4.43 (60 Hz) 946 001 NTSC 4.43 (50 Hz) PAL 4.43 (60 Hz)
@@ -739,8 +948,9 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
739 011 NTSC N (3.58MHz) PAL M (3.58MHz) 948 011 NTSC N (3.58MHz) PAL M (3.58MHz)
740 100 reserved NTSC-Japan (3.58MHz) 949 100 reserved NTSC-Japan (3.58MHz)
741 */ 950 */
742 if (state->ident == V4L2_IDENT_SAA7113) { 951 if (state->ident == V4L2_IDENT_SAA7111 ||
743 u8 reg = saa7115_read(client, 0x0e) & 0x8f; 952 state->ident == V4L2_IDENT_SAA7113) {
953 u8 reg = saa711x_read(client, R_0E_CHROMA_CNTL_1) & 0x8f;
744 954
745 if (std == V4L2_STD_PAL_M) { 955 if (std == V4L2_STD_PAL_M) {
746 reg |= 0x30; 956 reg |= 0x30;
@@ -751,31 +961,30 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
751 } else if (std == V4L2_STD_NTSC_M_JP) { 961 } else if (std == V4L2_STD_NTSC_M_JP) {
752 reg |= 0x40; 962 reg |= 0x40;
753 } 963 }
754 saa7115_write(client, 0x0e, reg); 964 saa711x_write(client, R_0E_CHROMA_CNTL_1, reg);
755 } 965 } else {
756 966 /* restart task B if needed */
967 int taskb = saa711x_read(client, R_80_GLOBAL_CNTL_1) & 0x10;
757 968
758 state->std = std; 969 if (taskb && state->ident == V4L2_IDENT_SAA7114) {
970 saa711x_writeregs(client, saa7115_cfg_vbi_on);
971 }
759 972
760 /* restart task B if needed */ 973 /* switch audio mode too! */
761 if (taskb && state->ident != V4L2_IDENT_SAA7115) { 974 saa711x_set_audio_clock_freq(client, state->audclk_freq);
762 saa7115_writeregs(client, saa7115_cfg_vbi_on);
763 } 975 }
764
765 /* switch audio mode too! */
766 saa7115_set_audio_clock_freq(client, state->audclk_freq);
767} 976}
768 977
769static v4l2_std_id saa7115_get_v4lstd(struct i2c_client *client) 978static v4l2_std_id saa711x_get_v4lstd(struct i2c_client *client)
770{ 979{
771 struct saa7115_state *state = i2c_get_clientdata(client); 980 struct saa711x_state *state = i2c_get_clientdata(client);
772 981
773 return state->std; 982 return state->std;
774} 983}
775 984
776static void saa7115_log_status(struct i2c_client *client) 985static void saa711x_log_status(struct i2c_client *client)
777{ 986{
778 struct saa7115_state *state = i2c_get_clientdata(client); 987 struct saa711x_state *state = i2c_get_clientdata(client);
779 int reg1e, reg1f; 988 int reg1e, reg1f;
780 int signalOk; 989 int signalOk;
781 int vcr; 990 int vcr;
@@ -783,7 +992,7 @@ static void saa7115_log_status(struct i2c_client *client)
783 v4l_info(client, "Audio frequency: %d Hz\n", state->audclk_freq); 992 v4l_info(client, "Audio frequency: %d Hz\n", state->audclk_freq);
784 if (state->ident != V4L2_IDENT_SAA7115) { 993 if (state->ident != V4L2_IDENT_SAA7115) {
785 /* status for the saa7114 */ 994 /* status for the saa7114 */
786 reg1f = saa7115_read(client, 0x1f); 995 reg1f = saa711x_read(client, R_1F_STATUS_BYTE_2_VD_DEC);
787 signalOk = (reg1f & 0xc1) == 0x81; 996 signalOk = (reg1f & 0xc1) == 0x81;
788 v4l_info(client, "Video signal: %s\n", signalOk ? "ok" : "bad"); 997 v4l_info(client, "Video signal: %s\n", signalOk ? "ok" : "bad");
789 v4l_info(client, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); 998 v4l_info(client, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz");
@@ -791,8 +1000,8 @@ static void saa7115_log_status(struct i2c_client *client)
791 } 1000 }
792 1001
793 /* status for the saa7115 */ 1002 /* status for the saa7115 */
794 reg1e = saa7115_read(client, 0x1e); 1003 reg1e = saa711x_read(client, R_1E_STATUS_BYTE_1_VD_DEC);
795 reg1f = saa7115_read(client, 0x1f); 1004 reg1f = saa711x_read(client, R_1F_STATUS_BYTE_2_VD_DEC);
796 1005
797 signalOk = (reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80; 1006 signalOk = (reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80;
798 vcr = !(reg1f & 0x10); 1007 vcr = !(reg1f & 0x10);
@@ -819,19 +1028,27 @@ static void saa7115_log_status(struct i2c_client *client)
819 v4l_info(client, "Detected format: BW/No color\n"); 1028 v4l_info(client, "Detected format: BW/No color\n");
820 break; 1029 break;
821 } 1030 }
1031 v4l_info(client, "Width, Height: %d, %d\n", state->width, state->height);
822} 1032}
823 1033
824/* setup the sliced VBI lcr registers according to the sliced VBI format */ 1034/* setup the sliced VBI lcr registers according to the sliced VBI format */
825static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_format *fmt) 1035static void saa711x_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_format *fmt)
826{ 1036{
827 struct saa7115_state *state = i2c_get_clientdata(client); 1037 struct saa711x_state *state = i2c_get_clientdata(client);
828 int is_50hz = (state->std & V4L2_STD_625_50); 1038 int is_50hz = (state->std & V4L2_STD_625_50);
829 u8 lcr[24]; 1039 u8 lcr[24];
830 int i, x; 1040 int i, x;
831 1041
832 /* saa7113/7114 doesn't yet support VBI */ 1042#if 1
1043 /* saa7113/7114/7118 VBI support are experimental */
1044 if (!saa711x_has_reg(state->ident,R_41_LCR_BASE))
1045 return;
1046
1047#else
1048 /* SAA7113 and SAA7118 also should support VBI - Need testing */
833 if (state->ident != V4L2_IDENT_SAA7115) 1049 if (state->ident != V4L2_IDENT_SAA7115)
834 return; 1050 return;
1051#endif
835 1052
836 for (i = 0; i <= 23; i++) 1053 for (i = 0; i <= 23; i++)
837 lcr[i] = 0xff; 1054 lcr[i] = 0xff;
@@ -888,14 +1105,16 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
888 1105
889 /* write the lcr registers */ 1106 /* write the lcr registers */
890 for (i = 2; i <= 23; i++) { 1107 for (i = 2; i <= 23; i++) {
891 saa7115_write(client, i - 2 + 0x41, lcr[i]); 1108 saa711x_write(client, i - 2 + R_41_LCR_BASE, lcr[i]);
892 } 1109 }
893 1110
894 /* enable/disable raw VBI capturing */ 1111 /* enable/disable raw VBI capturing */
895 saa7115_writeregs(client, fmt->service_set == 0 ? saa7115_cfg_vbi_on : saa7115_cfg_vbi_off); 1112 saa711x_writeregs(client, fmt->service_set == 0 ?
1113 saa7115_cfg_vbi_on :
1114 saa7115_cfg_vbi_off);
896} 1115}
897 1116
898static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) 1117static int saa711x_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
899{ 1118{
900 static u16 lcr2vbi[] = { 1119 static u16 lcr2vbi[] = {
901 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */ 1120 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
@@ -911,10 +1130,10 @@ static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt
911 return -EINVAL; 1130 return -EINVAL;
912 memset(sliced, 0, sizeof(*sliced)); 1131 memset(sliced, 0, sizeof(*sliced));
913 /* done if using raw VBI */ 1132 /* done if using raw VBI */
914 if (saa7115_read(client, 0x80) & 0x10) 1133 if (saa711x_read(client, R_80_GLOBAL_CNTL_1) & 0x10)
915 return 0; 1134 return 0;
916 for (i = 2; i <= 23; i++) { 1135 for (i = 2; i <= 23; i++) {
917 u8 v = saa7115_read(client, i - 2 + 0x41); 1136 u8 v = saa711x_read(client, i - 2 + R_41_LCR_BASE);
918 1137
919 sliced->service_lines[0][i] = lcr2vbi[v >> 4]; 1138 sliced->service_lines[0][i] = lcr2vbi[v >> 4];
920 sliced->service_lines[1][i] = lcr2vbi[v & 0xf]; 1139 sliced->service_lines[1][i] = lcr2vbi[v & 0xf];
@@ -924,114 +1143,31 @@ static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt
924 return 0; 1143 return 0;
925} 1144}
926 1145
927static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) 1146static int saa711x_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
928{ 1147{
929 struct saa7115_state *state = i2c_get_clientdata(client);
930 struct v4l2_pix_format *pix;
931 int HPSC, HFSC;
932 int VSCY, Vsrc;
933 int is_50hz = state->std & V4L2_STD_625_50;
934
935 if (fmt->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { 1148 if (fmt->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
936 saa7115_set_lcr(client, &fmt->fmt.sliced); 1149 saa711x_set_lcr(client, &fmt->fmt.sliced);
937 return 0; 1150 return 0;
938 } 1151 }
939 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1152 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
940 return -EINVAL; 1153 return -EINVAL;
941 1154
942 pix = &(fmt->fmt.pix); 1155 return saa711x_set_size(client,fmt->fmt.pix.width,fmt->fmt.pix.height);
943
944 v4l_dbg(1, debug, client, "decoder set size\n");
945
946 /* FIXME need better bounds checking here */
947 if ((pix->width < 1) || (pix->width > 1440))
948 return -EINVAL;
949 if ((pix->height < 1) || (pix->height > 960))
950 return -EINVAL;
951
952 /* probably have a valid size, let's set it */
953 /* Set output width/height */
954 /* width */
955 saa7115_write(client, 0xcc, (u8) (pix->width & 0xff));
956 saa7115_write(client, 0xcd, (u8) ((pix->width >> 8) & 0xff));
957 /* height */
958 saa7115_write(client, 0xce, (u8) (pix->height & 0xff));
959 saa7115_write(client, 0xcf, (u8) ((pix->height >> 8) & 0xff));
960
961 /* Scaling settings */
962 /* Hprescaler is floor(inres/outres) */
963 /* FIXME hardcoding input res */
964 if (pix->width != 720) {
965 HPSC = (int)(720 / pix->width);
966 /* 0 is not allowed (div. by zero) */
967 HPSC = HPSC ? HPSC : 1;
968 HFSC = (int)((1024 * 720) / (HPSC * pix->width));
969
970 v4l_dbg(1, debug, client, "Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC);
971 /* FIXME hardcodes to "Task B"
972 * write H prescaler integer */
973 saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f));
974
975 /* write H fine-scaling (luminance) */
976 saa7115_write(client, 0xd8, (u8) (HFSC & 0xff));
977 saa7115_write(client, 0xd9, (u8) ((HFSC >> 8) & 0xff));
978 /* write H fine-scaling (chrominance)
979 * must be lum/2, so i'll just bitshift :) */
980 saa7115_write(client, 0xDC, (u8) ((HFSC >> 1) & 0xff));
981 saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff));
982 } else {
983 if (is_50hz) {
984 v4l_dbg(1, debug, client, "Setting full 50hz width\n");
985 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x);
986 } else {
987 v4l_dbg(1, debug, client, "Setting full 60hz width\n");
988 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
989 }
990 }
991
992 Vsrc = is_50hz ? 576 : 480;
993
994 if (pix->height != Vsrc) {
995 VSCY = (int)((1024 * Vsrc) / pix->height);
996 v4l_dbg(1, debug, client, "Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY);
997
998 /* Correct Contrast and Luminance */
999 saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY));
1000 saa7115_write(client, 0xd6, (u8) (64 * 1024 / VSCY));
1001
1002 /* write V fine-scaling (luminance) */
1003 saa7115_write(client, 0xe0, (u8) (VSCY & 0xff));
1004 saa7115_write(client, 0xe1, (u8) ((VSCY >> 8) & 0xff));
1005 /* write V fine-scaling (chrominance) */
1006 saa7115_write(client, 0xe2, (u8) (VSCY & 0xff));
1007 saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff));
1008 } else {
1009 if (is_50hz) {
1010 v4l_dbg(1, debug, client, "Setting full 50Hz height\n");
1011 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y);
1012 } else {
1013 v4l_dbg(1, debug, client, "Setting full 60hz height\n");
1014 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
1015 }
1016 }
1017
1018 saa7115_writeregs(client, saa7115_cfg_reset_scaler);
1019 return 0;
1020} 1156}
1021 1157
1022/* Decode the sliced VBI data stream as created by the saa7115. 1158/* Decode the sliced VBI data stream as created by the saa7115.
1023 The format is described in the saa7115 datasheet in Tables 25 and 26 1159 The format is described in the saa7115 datasheet in Tables 25 and 26
1024 and in Figure 33. 1160 and in Figure 33.
1025 The current implementation uses SAV/EAV codes and not the ancillary data 1161 The current implementation uses SAV/EAV codes and not the ancillary data
1026 headers. The vbi->p pointer points to the SDID byte right after the SAV 1162 headers. The vbi->p pointer points to the R_5E_SDID byte right after the SAV
1027 code. */ 1163 code. */
1028static void saa7115_decode_vbi_line(struct i2c_client *client, 1164static void saa711x_decode_vbi_line(struct i2c_client *client,
1029 struct v4l2_decode_vbi_line *vbi) 1165 struct v4l2_decode_vbi_line *vbi)
1030{ 1166{
1031 static const char vbi_no_data_pattern[] = { 1167 static const char vbi_no_data_pattern[] = {
1032 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0 1168 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0
1033 }; 1169 };
1034 struct saa7115_state *state = i2c_get_clientdata(client); 1170 struct saa711x_state *state = i2c_get_clientdata(client);
1035 u8 *p = vbi->p; 1171 u8 *p = vbi->p;
1036 u32 wss; 1172 u32 wss;
1037 int id1, id2; /* the ID1 and ID2 bytes from the internal header */ 1173 int id1, id2; /* the ID1 and ID2 bytes from the internal header */
@@ -1066,12 +1202,12 @@ static void saa7115_decode_vbi_line(struct i2c_client *client,
1066 vbi->type = V4L2_SLICED_TELETEXT_B; 1202 vbi->type = V4L2_SLICED_TELETEXT_B;
1067 break; 1203 break;
1068 case 4: 1204 case 4:
1069 if (!saa7115_odd_parity(p[0]) || !saa7115_odd_parity(p[1])) 1205 if (!saa711x_odd_parity(p[0]) || !saa711x_odd_parity(p[1]))
1070 return; 1206 return;
1071 vbi->type = V4L2_SLICED_CAPTION_525; 1207 vbi->type = V4L2_SLICED_CAPTION_525;
1072 break; 1208 break;
1073 case 5: 1209 case 5:
1074 wss = saa7115_decode_wss(p); 1210 wss = saa711x_decode_wss(p);
1075 if (wss == -1) 1211 if (wss == -1)
1076 return; 1212 return;
1077 p[0] = wss & 0xff; 1213 p[0] = wss & 0xff;
@@ -1079,7 +1215,7 @@ static void saa7115_decode_vbi_line(struct i2c_client *client,
1079 vbi->type = V4L2_SLICED_WSS_625; 1215 vbi->type = V4L2_SLICED_WSS_625;
1080 break; 1216 break;
1081 case 7: 1217 case 7:
1082 if (saa7115_decode_vps(p, p) != 0) 1218 if (saa711x_decode_vps(p, p) != 0)
1083 return; 1219 return;
1084 vbi->type = V4L2_SLICED_VPS; 1220 vbi->type = V4L2_SLICED_VPS;
1085 break; 1221 break;
@@ -1090,21 +1226,21 @@ static void saa7115_decode_vbi_line(struct i2c_client *client,
1090 1226
1091/* ============ SAA7115 AUDIO settings (end) ============= */ 1227/* ============ SAA7115 AUDIO settings (end) ============= */
1092 1228
1093static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *arg) 1229static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *arg)
1094{ 1230{
1095 struct saa7115_state *state = i2c_get_clientdata(client); 1231 struct saa711x_state *state = i2c_get_clientdata(client);
1096 int *iarg = arg; 1232 int *iarg = arg;
1097 1233
1098 /* ioctls to allow direct access to the saa7115 registers for testing */ 1234 /* ioctls to allow direct access to the saa7115 registers for testing */
1099 switch (cmd) { 1235 switch (cmd) {
1100 case VIDIOC_S_FMT: 1236 case VIDIOC_S_FMT:
1101 return saa7115_set_v4lfmt(client, (struct v4l2_format *)arg); 1237 return saa711x_set_v4lfmt(client, (struct v4l2_format *)arg);
1102 1238
1103 case VIDIOC_G_FMT: 1239 case VIDIOC_G_FMT:
1104 return saa7115_get_v4lfmt(client, (struct v4l2_format *)arg); 1240 return saa711x_get_v4lfmt(client, (struct v4l2_format *)arg);
1105 1241
1106 case VIDIOC_INT_AUDIO_CLOCK_FREQ: 1242 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
1107 return saa7115_set_audio_clock_freq(client, *(u32 *)arg); 1243 return saa711x_set_audio_clock_freq(client, *(u32 *)arg);
1108 1244
1109 case VIDIOC_G_TUNER: 1245 case VIDIOC_G_TUNER:
1110 { 1246 {
@@ -1113,7 +1249,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1113 1249
1114 if (state->radio) 1250 if (state->radio)
1115 break; 1251 break;
1116 status = saa7115_read(client, 0x1f); 1252 status = saa711x_read(client, R_1F_STATUS_BYTE_2_VD_DEC);
1117 1253
1118 v4l_dbg(1, debug, client, "status: 0x%02x\n", status); 1254 v4l_dbg(1, debug, client, "status: 0x%02x\n", status);
1119 vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0; 1255 vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0;
@@ -1121,14 +1257,14 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1121 } 1257 }
1122 1258
1123 case VIDIOC_LOG_STATUS: 1259 case VIDIOC_LOG_STATUS:
1124 saa7115_log_status(client); 1260 saa711x_log_status(client);
1125 break; 1261 break;
1126 1262
1127 case VIDIOC_G_CTRL: 1263 case VIDIOC_G_CTRL:
1128 return saa7115_get_v4lctrl(client, (struct v4l2_control *)arg); 1264 return saa711x_get_v4lctrl(client, (struct v4l2_control *)arg);
1129 1265
1130 case VIDIOC_S_CTRL: 1266 case VIDIOC_S_CTRL:
1131 return saa7115_set_v4lctrl(client, (struct v4l2_control *)arg); 1267 return saa711x_set_v4lctrl(client, (struct v4l2_control *)arg);
1132 1268
1133 case VIDIOC_QUERYCTRL: 1269 case VIDIOC_QUERYCTRL:
1134 { 1270 {
@@ -1146,12 +1282,12 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1146 } 1282 }
1147 1283
1148 case VIDIOC_G_STD: 1284 case VIDIOC_G_STD:
1149 *(v4l2_std_id *)arg = saa7115_get_v4lstd(client); 1285 *(v4l2_std_id *)arg = saa711x_get_v4lstd(client);
1150 break; 1286 break;
1151 1287
1152 case VIDIOC_S_STD: 1288 case VIDIOC_S_STD:
1153 state->radio = 0; 1289 state->radio = 0;
1154 saa7115_set_v4lstd(client, *(v4l2_std_id *)arg); 1290 saa711x_set_v4lstd(client, *(v4l2_std_id *)arg);
1155 break; 1291 break;
1156 1292
1157 case AUDC_SET_RADIO: 1293 case AUDC_SET_RADIO:
@@ -1187,13 +1323,13 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1187 state->input = route->input; 1323 state->input = route->input;
1188 1324
1189 /* select mode */ 1325 /* select mode */
1190 saa7115_write(client, 0x02, 1326 saa711x_write(client, R_02_INPUT_CNTL_1,
1191 (saa7115_read(client, 0x02) & 0xf0) | 1327 (saa711x_read(client, R_02_INPUT_CNTL_1) & 0xf0) |
1192 state->input); 1328 state->input);
1193 1329
1194 /* bypass chrominance trap for S-Video modes */ 1330 /* bypass chrominance trap for S-Video modes */
1195 saa7115_write(client, 0x09, 1331 saa711x_write(client, R_09_LUMA_CNTL,
1196 (saa7115_read(client, 0x09) & 0x7f) | 1332 (saa711x_read(client, R_09_LUMA_CNTL) & 0x7f) |
1197 (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0)); 1333 (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0));
1198 break; 1334 break;
1199 } 1335 }
@@ -1205,7 +1341,9 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1205 1341
1206 if (state->enable != (cmd == VIDIOC_STREAMON)) { 1342 if (state->enable != (cmd == VIDIOC_STREAMON)) {
1207 state->enable = (cmd == VIDIOC_STREAMON); 1343 state->enable = (cmd == VIDIOC_STREAMON);
1208 saa7115_write(client, 0x87, state->enable); 1344 saa711x_write(client,
1345 R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED,
1346 state->enable);
1209 } 1347 }
1210 break; 1348 break;
1211 1349
@@ -1220,17 +1358,17 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1220 state->cgcdiv = (freq->flags & SAA7115_FREQ_FL_CGCDIV) ? 3 : 4; 1358 state->cgcdiv = (freq->flags & SAA7115_FREQ_FL_CGCDIV) ? 3 : 4;
1221 state->ucgc = (freq->flags & SAA7115_FREQ_FL_UCGC) ? 1 : 0; 1359 state->ucgc = (freq->flags & SAA7115_FREQ_FL_UCGC) ? 1 : 0;
1222 state->apll = (freq->flags & SAA7115_FREQ_FL_APLL) ? 1 : 0; 1360 state->apll = (freq->flags & SAA7115_FREQ_FL_APLL) ? 1 : 0;
1223 saa7115_set_audio_clock_freq(client, state->audclk_freq); 1361 saa711x_set_audio_clock_freq(client, state->audclk_freq);
1224 break; 1362 break;
1225 } 1363 }
1226 1364
1227 case VIDIOC_INT_DECODE_VBI_LINE: 1365 case VIDIOC_INT_DECODE_VBI_LINE:
1228 saa7115_decode_vbi_line(client, arg); 1366 saa711x_decode_vbi_line(client, arg);
1229 break; 1367 break;
1230 1368
1231 case VIDIOC_INT_RESET: 1369 case VIDIOC_INT_RESET:
1232 v4l_dbg(1, debug, client, "decoder RESET\n"); 1370 v4l_dbg(1, debug, client, "decoder RESET\n");
1233 saa7115_writeregs(client, saa7115_cfg_reset_scaler); 1371 saa711x_writeregs(client, saa7115_cfg_reset_scaler);
1234 break; 1372 break;
1235 1373
1236 case VIDIOC_INT_G_VBI_DATA: 1374 case VIDIOC_INT_G_VBI_DATA:
@@ -1239,25 +1377,25 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1239 1377
1240 switch (data->id) { 1378 switch (data->id) {
1241 case V4L2_SLICED_WSS_625: 1379 case V4L2_SLICED_WSS_625:
1242 if (saa7115_read(client, 0x6b) & 0xc0) 1380 if (saa711x_read(client, 0x6b) & 0xc0)
1243 return -EIO; 1381 return -EIO;
1244 data->data[0] = saa7115_read(client, 0x6c); 1382 data->data[0] = saa711x_read(client, 0x6c);
1245 data->data[1] = saa7115_read(client, 0x6d); 1383 data->data[1] = saa711x_read(client, 0x6d);
1246 return 0; 1384 return 0;
1247 case V4L2_SLICED_CAPTION_525: 1385 case V4L2_SLICED_CAPTION_525:
1248 if (data->field == 0) { 1386 if (data->field == 0) {
1249 /* CC */ 1387 /* CC */
1250 if (saa7115_read(client, 0x66) & 0xc0) 1388 if (saa711x_read(client, 0x66) & 0xc0)
1251 return -EIO; 1389 return -EIO;
1252 data->data[0] = saa7115_read(client, 0x67); 1390 data->data[0] = saa711x_read(client, 0x67);
1253 data->data[1] = saa7115_read(client, 0x68); 1391 data->data[1] = saa711x_read(client, 0x68);
1254 return 0; 1392 return 0;
1255 } 1393 }
1256 /* XDS */ 1394 /* XDS */
1257 if (saa7115_read(client, 0x66) & 0x30) 1395 if (saa711x_read(client, 0x66) & 0x30)
1258 return -EIO; 1396 return -EIO;
1259 data->data[0] = saa7115_read(client, 0x69); 1397 data->data[0] = saa711x_read(client, 0x69);
1260 data->data[1] = saa7115_read(client, 0x6a); 1398 data->data[1] = saa711x_read(client, 0x6a);
1261 return 0; 1399 return 0;
1262 default: 1400 default:
1263 return -EINVAL; 1401 return -EINVAL;
@@ -1272,7 +1410,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1272 1410
1273 if (reg->i2c_id != I2C_DRIVERID_SAA711X) 1411 if (reg->i2c_id != I2C_DRIVERID_SAA711X)
1274 return -EINVAL; 1412 return -EINVAL;
1275 reg->val = saa7115_read(client, reg->reg & 0xff); 1413 reg->val = saa711x_read(client, reg->reg & 0xff);
1276 break; 1414 break;
1277 } 1415 }
1278 1416
@@ -1284,7 +1422,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1284 return -EINVAL; 1422 return -EINVAL;
1285 if (!capable(CAP_SYS_ADMIN)) 1423 if (!capable(CAP_SYS_ADMIN))
1286 return -EPERM; 1424 return -EPERM;
1287 saa7115_write(client, reg->reg & 0xff, reg->val & 0xff); 1425 saa711x_write(client, reg->reg & 0xff, reg->val & 0xff);
1288 break; 1426 break;
1289 } 1427 }
1290#endif 1428#endif
@@ -1302,12 +1440,14 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1302 1440
1303/* ----------------------------------------------------------------------- */ 1441/* ----------------------------------------------------------------------- */
1304 1442
1305static struct i2c_driver i2c_driver_saa7115; 1443static struct i2c_driver i2c_driver_saa711x;
1306 1444
1307static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind) 1445static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
1308{ 1446{
1309 struct i2c_client *client; 1447 struct i2c_client *client;
1310 struct saa7115_state *state; 1448 struct saa711x_state *state;
1449 int i;
1450 char name[17];
1311 u8 chip_id; 1451 u8 chip_id;
1312 1452
1313 /* Check if the adapter supports the needed features */ 1453 /* Check if the adapter supports the needed features */
@@ -1319,28 +1459,31 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1319 return -ENOMEM; 1459 return -ENOMEM;
1320 client->addr = address; 1460 client->addr = address;
1321 client->adapter = adapter; 1461 client->adapter = adapter;
1322 client->driver = &i2c_driver_saa7115; 1462 client->driver = &i2c_driver_saa711x;
1323 snprintf(client->name, sizeof(client->name) - 1, "saa7115"); 1463 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1324 1464
1325 v4l_dbg(1, debug, client, "detecting saa7115 client on address 0x%x\n", address << 1); 1465 v4l_dbg(1, debug, client, "detecting saa7115 client on address 0x%x\n", address << 1);
1326 1466
1327 saa7115_write(client, 0, 5); 1467 for (i=0;i<0x0f;i++) {
1328 chip_id = saa7115_read(client, 0) & 0x0f; 1468 saa711x_write(client, 0, i);
1329 if (chip_id < 3 && chip_id > 5) { 1469 name[i] = (saa711x_read(client, 0) &0x0f) +'0';
1330 v4l_dbg(1, debug, client, "saa7115 not found\n"); 1470 if (name[i]>'9')
1331 kfree(client); 1471 name[i]+='a'-'9'-1;
1332 return 0;
1333 } 1472 }
1473 name[i]='\0';
1474
1475 saa711x_write(client, 0, 5);
1476 chip_id = saa711x_read(client, 0) & 0x0f;
1477
1334 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id); 1478 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id);
1335 v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name); 1479 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name);
1336 1480
1337 state = kzalloc(sizeof(struct saa7115_state), GFP_KERNEL); 1481 state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL);
1338 i2c_set_clientdata(client, state); 1482 i2c_set_clientdata(client, state);
1339 if (state == NULL) { 1483 if (state == NULL) {
1340 kfree(client); 1484 kfree(client);
1341 return -ENOMEM; 1485 return -ENOMEM;
1342 } 1486 }
1343 state->std = V4L2_STD_NTSC;
1344 state->input = -1; 1487 state->input = -1;
1345 state->enable = 1; 1488 state->enable = 1;
1346 state->radio = 0; 1489 state->radio = 0;
@@ -1349,15 +1492,25 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1349 state->hue = 0; 1492 state->hue = 0;
1350 state->sat = 64; 1493 state->sat = 64;
1351 switch (chip_id) { 1494 switch (chip_id) {
1495 case 1:
1496 state->ident = V4L2_IDENT_SAA7111;
1497 break;
1352 case 3: 1498 case 3:
1353 state->ident = V4L2_IDENT_SAA7113; 1499 state->ident = V4L2_IDENT_SAA7113;
1354 break; 1500 break;
1355 case 4: 1501 case 4:
1356 state->ident = V4L2_IDENT_SAA7114; 1502 state->ident = V4L2_IDENT_SAA7114;
1357 break; 1503 break;
1358 default: 1504 case 5:
1359 state->ident = V4L2_IDENT_SAA7115; 1505 state->ident = V4L2_IDENT_SAA7115;
1360 break; 1506 break;
1507 case 8:
1508 state->ident = V4L2_IDENT_SAA7118;
1509 break;
1510 default:
1511 state->ident = V4L2_IDENT_SAA7111;
1512 v4l_info(client, "WARNING: Chip is not known - Falling back to saa7111\n");
1513
1361 } 1514 }
1362 1515
1363 state->audclk_freq = 48000; 1516 state->audclk_freq = 48000;
@@ -1365,38 +1518,39 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1365 v4l_dbg(1, debug, client, "writing init values\n"); 1518 v4l_dbg(1, debug, client, "writing init values\n");
1366 1519
1367 /* init to 60hz/48khz */ 1520 /* init to 60hz/48khz */
1368 if (state->ident == V4L2_IDENT_SAA7113) { 1521 state->crystal_freq = SAA7115_FREQ_24_576_MHZ;
1369 state->crystal_freq = SAA7115_FREQ_24_576_MHZ; 1522 switch (state->ident) {
1370 saa7115_writeregs(client, saa7113_init_auto_input); 1523 case V4L2_IDENT_SAA7111:
1371 } else { 1524 saa711x_writeregs(client, saa7111_init);
1525 break;
1526 case V4L2_IDENT_SAA7113:
1527 saa711x_writeregs(client, saa7113_init);
1528 break;
1529 default:
1372 state->crystal_freq = SAA7115_FREQ_32_11_MHZ; 1530 state->crystal_freq = SAA7115_FREQ_32_11_MHZ;
1373 saa7115_writeregs(client, saa7115_init_auto_input); 1531 saa711x_writeregs(client, saa7115_init_auto_input);
1374 } 1532 }
1375 saa7115_writeregs(client, saa7115_init_misc); 1533 saa711x_writeregs(client, saa7115_init_misc);
1376 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x); 1534 saa711x_set_v4lstd(client, V4L2_STD_NTSC);
1377 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
1378 saa7115_writeregs(client, saa7115_cfg_60hz_video);
1379 saa7115_set_audio_clock_freq(client, state->audclk_freq);
1380 saa7115_writeregs(client, saa7115_cfg_reset_scaler);
1381 1535
1382 i2c_attach_client(client); 1536 i2c_attach_client(client);
1383 1537
1384 v4l_dbg(1, debug, client, "status: (1E) 0x%02x, (1F) 0x%02x\n", 1538 v4l_dbg(1, debug, client, "status: (1E) 0x%02x, (1F) 0x%02x\n",
1385 saa7115_read(client, 0x1e), saa7115_read(client, 0x1f)); 1539 saa711x_read(client, R_1E_STATUS_BYTE_1_VD_DEC), saa711x_read(client, R_1F_STATUS_BYTE_2_VD_DEC));
1386 1540
1387 return 0; 1541 return 0;
1388} 1542}
1389 1543
1390static int saa7115_probe(struct i2c_adapter *adapter) 1544static int saa711x_probe(struct i2c_adapter *adapter)
1391{ 1545{
1392 if (adapter->class & I2C_CLASS_TV_ANALOG) 1546 if (adapter->class & I2C_CLASS_TV_ANALOG)
1393 return i2c_probe(adapter, &addr_data, &saa7115_attach); 1547 return i2c_probe(adapter, &addr_data, &saa711x_attach);
1394 return 0; 1548 return 0;
1395} 1549}
1396 1550
1397static int saa7115_detach(struct i2c_client *client) 1551static int saa711x_detach(struct i2c_client *client)
1398{ 1552{
1399 struct saa7115_state *state = i2c_get_clientdata(client); 1553 struct saa711x_state *state = i2c_get_clientdata(client);
1400 int err; 1554 int err;
1401 1555
1402 err = i2c_detach_client(client); 1556 err = i2c_detach_client(client);
@@ -1412,26 +1566,26 @@ static int saa7115_detach(struct i2c_client *client)
1412/* ----------------------------------------------------------------------- */ 1566/* ----------------------------------------------------------------------- */
1413 1567
1414/* i2c implementation */ 1568/* i2c implementation */
1415static struct i2c_driver i2c_driver_saa7115 = { 1569static struct i2c_driver i2c_driver_saa711x = {
1416 .driver = { 1570 .driver = {
1417 .name = "saa7115", 1571 .name = "saa7115",
1418 }, 1572 },
1419 .id = I2C_DRIVERID_SAA711X, 1573 .id = I2C_DRIVERID_SAA711X,
1420 .attach_adapter = saa7115_probe, 1574 .attach_adapter = saa711x_probe,
1421 .detach_client = saa7115_detach, 1575 .detach_client = saa711x_detach,
1422 .command = saa7115_command, 1576 .command = saa711x_command,
1423}; 1577};
1424 1578
1425 1579
1426static int __init saa7115_init_module(void) 1580static int __init saa711x_init_module(void)
1427{ 1581{
1428 return i2c_add_driver(&i2c_driver_saa7115); 1582 return i2c_add_driver(&i2c_driver_saa711x);
1429} 1583}
1430 1584
1431static void __exit saa7115_cleanup_module(void) 1585static void __exit saa711x_cleanup_module(void)
1432{ 1586{
1433 i2c_del_driver(&i2c_driver_saa7115); 1587 i2c_del_driver(&i2c_driver_saa711x);
1434} 1588}
1435 1589
1436module_init(saa7115_init_module); 1590module_init(saa711x_init_module);
1437module_exit(saa7115_cleanup_module); 1591module_exit(saa711x_cleanup_module);
diff --git a/drivers/media/video/saa711x_regs.h b/drivers/media/video/saa711x_regs.h
new file mode 100644
index 000000000000..4e5f2eb0a2c1
--- /dev/null
+++ b/drivers/media/video/saa711x_regs.h
@@ -0,0 +1,549 @@
1/* saa711x - Philips SAA711x video decoder register specifications
2 *
3 * Copyright (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#define R_00_CHIP_VERSION 0x00
17/* Video Decoder */
18 /* Video Decoder - Frontend part */
19#define R_01_INC_DELAY 0x01
20#define R_02_INPUT_CNTL_1 0x02
21#define R_03_INPUT_CNTL_2 0x03
22#define R_04_INPUT_CNTL_3 0x04
23#define R_05_INPUT_CNTL_4 0x05
24 /* Video Decoder - Decoder part */
25#define R_06_H_SYNC_START 0x06
26#define R_07_H_SYNC_STOP 0x07
27#define R_08_SYNC_CNTL 0x08
28#define R_09_LUMA_CNTL 0x09
29#define R_0A_LUMA_BRIGHT_CNTL 0x0a
30#define R_0B_LUMA_CONTRAST_CNTL 0x0b
31#define R_0C_CHROMA_SAT_CNTL 0x0c
32#define R_0D_CHROMA_HUE_CNTL 0x0d
33#define R_0E_CHROMA_CNTL_1 0x0e
34#define R_0F_CHROMA_GAIN_CNTL 0x0f
35#define R_10_CHROMA_CNTL_2 0x10
36#define R_11_MODE_DELAY_CNTL 0x11
37#define R_12_RT_SIGNAL_CNTL 0x12
38#define R_13_RT_X_PORT_OUT_CNTL 0x13
39#define R_14_ANAL_ADC_COMPAT_CNTL 0x14
40#define R_15_VGATE_START_FID_CHG 0x15
41#define R_16_VGATE_STOP 0x16
42#define R_17_MISC_VGATE_CONF_AND_MSB 0x17
43#define R_18_RAW_DATA_GAIN_CNTL 0x18
44#define R_19_RAW_DATA_OFF_CNTL 0x19
45#define R_1A_COLOR_KILL_LVL_CNTL 0x1a
46#define R_1B_MISC_TVVCRDET 0x1b
47#define R_1C_ENHAN_COMB_CTRL1 0x1c
48#define R_1D_ENHAN_COMB_CTRL2 0x1d
49#define R_1E_STATUS_BYTE_1_VD_DEC 0x1e
50#define R_1F_STATUS_BYTE_2_VD_DEC 0x1f
51
52/* Component processing and interrupt masking part */
53#define R_23_INPUT_CNTL_5 0x23
54#define R_24_INPUT_CNTL_6 0x24
55#define R_25_INPUT_CNTL_7 0x25
56#define R_29_COMP_DELAY 0x29
57#define R_2A_COMP_BRIGHT_CNTL 0x2a
58#define R_2B_COMP_CONTRAST_CNTL 0x2b
59#define R_2C_COMP_SAT_CNTL 0x2c
60#define R_2D_INTERRUPT_MASK_1 0x2d
61#define R_2E_INTERRUPT_MASK_2 0x2e
62#define R_2F_INTERRUPT_MASK_3 0x2f
63
64/* Audio clock generator part */
65#define R_30_AUD_MAST_CLK_CYCLES_PER_FIELD 0x30
66#define R_34_AUD_MAST_CLK_NOMINAL_INC 0x34
67#define R_38_CLK_RATIO_AMXCLK_TO_ASCLK 0x38
68#define R_39_CLK_RATIO_ASCLK_TO_ALRCLK 0x39
69#define R_3A_AUD_CLK_GEN_BASIC_SETUP 0x3a
70
71/* General purpose VBI data slicer part */
72#define R_40_SLICER_CNTL_1 0x40
73#define R_41_LCR_BASE 0x41
74#define R_58_PROGRAM_FRAMING_CODE 0x58
75#define R_59_H_OFF_FOR_SLICER 0x59
76#define R_5A_V_OFF_FOR_SLICER 0x5a
77#define R_5B_FLD_OFF_AND_MSB_FOR_H_AND_V_OFF 0x5b
78#define R_5D_DID 0x5d
79#define R_5E_SDID 0x5e
80#define R_60_SLICER_STATUS_BYTE_0 0x60
81#define R_61_SLICER_STATUS_BYTE_1 0x61
82#define R_62_SLICER_STATUS_BYTE_2 0x62
83
84/* X port, I port and the scaler part */
85 /* Task independent global settings */
86#define R_80_GLOBAL_CNTL_1 0x80
87#define R_81_V_SYNC_FLD_ID_SRC_SEL_AND_RETIMED_V_F 0x81
88#define R_83_X_PORT_I_O_ENA_AND_OUT_CLK 0x83
89#define R_84_I_PORT_SIGNAL_DEF 0x84
90#define R_85_I_PORT_SIGNAL_POLAR 0x85
91#define R_86_I_PORT_FIFO_FLAG_CNTL_AND_ARBIT 0x86
92#define R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED 0x87
93#define R_88_POWER_SAVE_ADC_PORT_CNTL 0x88
94#define R_8F_STATUS_INFO_SCALER 0x8f
95 /* Task A definition */
96 /* Basic settings and acquisition window definition */
97#define R_90_A_TASK_HANDLING_CNTL 0x90
98#define R_91_A_X_PORT_FORMATS_AND_CONF 0x91
99#define R_92_A_X_PORT_INPUT_REFERENCE_SIGNAL 0x92
100#define R_93_A_I_PORT_OUTPUT_FORMATS_AND_CONF 0x93
101#define R_94_A_HORIZ_INPUT_WINDOW_START 0x94
102#define R_95_A_HORIZ_INPUT_WINDOW_START_MSB 0x95
103#define R_96_A_HORIZ_INPUT_WINDOW_LENGTH 0x96
104#define R_97_A_HORIZ_INPUT_WINDOW_LENGTH_MSB 0x97
105#define R_98_A_VERT_INPUT_WINDOW_START 0x98
106#define R_99_A_VERT_INPUT_WINDOW_START_MSB 0x99
107#define R_9A_A_VERT_INPUT_WINDOW_LENGTH 0x9a
108#define R_9B_A_VERT_INPUT_WINDOW_LENGTH_MSB 0x9b
109#define R_9C_A_HORIZ_OUTPUT_WINDOW_LENGTH 0x9c
110#define R_9D_A_HORIZ_OUTPUT_WINDOW_LENGTH_MSB 0x9d
111#define R_9E_A_VERT_OUTPUT_WINDOW_LENGTH 0x9e
112#define R_9F_A_VERT_OUTPUT_WINDOW_LENGTH_MSB 0x9f
113 /* FIR filtering and prescaling */
114#define R_A0_A_HORIZ_PRESCALING 0xa0
115#define R_A1_A_ACCUMULATION_LENGTH 0xa1
116#define R_A2_A_PRESCALER_DC_GAIN_AND_FIR_PREFILTER 0xa2
117#define R_A4_A_LUMA_BRIGHTNESS_CNTL 0xa4
118#define R_A5_A_LUMA_CONTRAST_CNTL 0xa5
119#define R_A6_A_CHROMA_SATURATION_CNTL 0xa6
120 /* Horizontal phase scaling */
121#define R_A8_A_HORIZ_LUMA_SCALING_INC 0xa8
122#define R_A9_A_HORIZ_LUMA_SCALING_INC_MSB 0xa9
123#define R_AA_A_HORIZ_LUMA_PHASE_OFF 0xaa
124#define R_AC_A_HORIZ_CHROMA_SCALING_INC 0xac
125#define R_AD_A_HORIZ_CHROMA_SCALING_INC_MSB 0xad
126#define R_AE_A_HORIZ_CHROMA_PHASE_OFF 0xae
127#define R_AF_A_HORIZ_CHROMA_PHASE_OFF_MSB 0xaf
128 /* Vertical scaling */
129#define R_B0_A_VERT_LUMA_SCALING_INC 0xb0
130#define R_B1_A_VERT_LUMA_SCALING_INC_MSB 0xb1
131#define R_B2_A_VERT_CHROMA_SCALING_INC 0xb2
132#define R_B3_A_VERT_CHROMA_SCALING_INC_MSB 0xb3
133#define R_B4_A_VERT_SCALING_MODE_CNTL 0xb4
134#define R_B8_A_VERT_CHROMA_PHASE_OFF_00 0xb8
135#define R_B9_A_VERT_CHROMA_PHASE_OFF_01 0xb9
136#define R_BA_A_VERT_CHROMA_PHASE_OFF_10 0xba
137#define R_BB_A_VERT_CHROMA_PHASE_OFF_11 0xbb
138#define R_BC_A_VERT_LUMA_PHASE_OFF_00 0xbc
139#define R_BD_A_VERT_LUMA_PHASE_OFF_01 0xbd
140#define R_BE_A_VERT_LUMA_PHASE_OFF_10 0xbe
141#define R_BF_A_VERT_LUMA_PHASE_OFF_11 0xbf
142 /* Task B definition */
143 /* Basic settings and acquisition window definition */
144#define R_C0_B_TASK_HANDLING_CNTL 0xc0
145#define R_C1_B_X_PORT_FORMATS_AND_CONF 0xc1
146#define R_C2_B_INPUT_REFERENCE_SIGNAL_DEFINITION 0xc2
147#define R_C3_B_I_PORT_FORMATS_AND_CONF 0xc3
148#define R_C4_B_HORIZ_INPUT_WINDOW_START 0xc4
149#define R_C5_B_HORIZ_INPUT_WINDOW_START_MSB 0xc5
150#define R_C6_B_HORIZ_INPUT_WINDOW_LENGTH 0xc6
151#define R_C7_B_HORIZ_INPUT_WINDOW_LENGTH_MSB 0xc7
152#define R_C8_B_VERT_INPUT_WINDOW_START 0xc8
153#define R_C9_B_VERT_INPUT_WINDOW_START_MSB 0xc9
154#define R_CA_B_VERT_INPUT_WINDOW_LENGTH 0xca
155#define R_CB_B_VERT_INPUT_WINDOW_LENGTH_MSB 0xcb
156#define R_CC_B_HORIZ_OUTPUT_WINDOW_LENGTH 0xcc
157#define R_CD_B_HORIZ_OUTPUT_WINDOW_LENGTH_MSB 0xcd
158#define R_CE_B_VERT_OUTPUT_WINDOW_LENGTH 0xce
159#define R_CF_B_VERT_OUTPUT_WINDOW_LENGTH_MSB 0xcf
160 /* FIR filtering and prescaling */
161#define R_D0_B_HORIZ_PRESCALING 0xd0
162#define R_D1_B_ACCUMULATION_LENGTH 0xd1
163#define R_D2_B_PRESCALER_DC_GAIN_AND_FIR_PREFILTER 0xd2
164#define R_D4_B_LUMA_BRIGHTNESS_CNTL 0xd4
165#define R_D5_B_LUMA_CONTRAST_CNTL 0xd5
166#define R_D6_B_CHROMA_SATURATION_CNTL 0xd6
167 /* Horizontal phase scaling */
168#define R_D8_B_HORIZ_LUMA_SCALING_INC 0xd8
169#define R_D9_B_HORIZ_LUMA_SCALING_INC_MSB 0xd9
170#define R_DA_B_HORIZ_LUMA_PHASE_OFF 0xda
171#define R_DC_B_HORIZ_CHROMA_SCALING 0xdc
172#define R_DD_B_HORIZ_CHROMA_SCALING_MSB 0xdd
173#define R_DE_B_HORIZ_PHASE_OFFSET_CRHOMA 0xde
174 /* Vertical scaling */
175#define R_E0_B_VERT_LUMA_SCALING_INC 0xe0
176#define R_E1_B_VERT_LUMA_SCALING_INC_MSB 0xe1
177#define R_E2_B_VERT_CHROMA_SCALING_INC 0xe2
178#define R_E3_B_VERT_CHROMA_SCALING_INC_MSB 0xe3
179#define R_E4_B_VERT_SCALING_MODE_CNTL 0xe4
180#define R_E8_B_VERT_CHROMA_PHASE_OFF_00 0xe8
181#define R_E9_B_VERT_CHROMA_PHASE_OFF_01 0xe9
182#define R_EA_B_VERT_CHROMA_PHASE_OFF_10 0xea
183#define R_EB_B_VERT_CHROMA_PHASE_OFF_11 0xeb
184#define R_EC_B_VERT_LUMA_PHASE_OFF_00 0xec
185#define R_ED_B_VERT_LUMA_PHASE_OFF_01 0xed
186#define R_EE_B_VERT_LUMA_PHASE_OFF_10 0xee
187#define R_EF_B_VERT_LUMA_PHASE_OFF_11 0xef
188
189/* second PLL (PLL2) and Pulsegenerator Programming */
190#define R_F0_LFCO_PER_LINE 0xf0
191#define R_F1_P_I_PARAM_SELECT 0xf1
192#define R_F2_NOMINAL_PLL2_DTO 0xf2
193#define R_F3_PLL_INCREMENT 0xf3
194#define R_F4_PLL2_STATUS 0xf4
195#define R_F5_PULSGEN_LINE_LENGTH 0xf5
196#define R_F6_PULSE_A_POS_LSB_AND_PULSEGEN_CONFIG 0xf6
197#define R_F7_PULSE_A_POS_MSB 0xf7
198#define R_F8_PULSE_B_POS 0xf8
199#define R_F9_PULSE_B_POS_MSB 0xf9
200#define R_FA_PULSE_C_POS 0xfa
201#define R_FB_PULSE_C_POS_MSB 0xfb
202#define R_FF_S_PLL_MAX_PHASE_ERR_THRESH_NUM_LINES 0xff
203
204#if 0
205/* Those structs will be used in the future for debug purposes */
206struct saa711x_reg_descr {
207 u8 reg;
208 int count;
209 char *name;
210};
211
212struct saa711x_reg_descr saa711x_regs[] = {
213 /* REG COUNT NAME */
214 {R_00_CHIP_VERSION,1,
215 "Chip version"},
216
217 /* Video Decoder: R_01_INC_DELAY to R_1F_STATUS_BYTE_2_VD_DEC */
218
219 /* Video Decoder - Frontend part: R_01_INC_DELAY to R_05_INPUT_CNTL_4 */
220 {R_01_INC_DELAY,1,
221 "Increment delay"},
222 {R_02_INPUT_CNTL_1,1,
223 "Analog input control 1"},
224 {R_03_INPUT_CNTL_2,1,
225 "Analog input control 2"},
226 {R_04_INPUT_CNTL_3,1,
227 "Analog input control 3"},
228 {R_05_INPUT_CNTL_4,1,
229 "Analog input control 4"},
230
231 /* Video Decoder - Decoder part: R_06_H_SYNC_START to R_1F_STATUS_BYTE_2_VD_DEC */
232 {R_06_H_SYNC_START,1,
233 "Horizontal sync start"},
234 {R_07_H_SYNC_STOP,1,
235 "Horizontal sync stop"},
236 {R_08_SYNC_CNTL,1,
237 "Sync control"},
238 {R_09_LUMA_CNTL,1,
239 "Luminance control"},
240 {R_0A_LUMA_BRIGHT_CNTL,1,
241 "Luminance brightness control"},
242 {R_0B_LUMA_CONTRAST_CNTL,1,
243 "Luminance contrast control"},
244 {R_0C_CHROMA_SAT_CNTL,1,
245 "Chrominance saturation control"},
246 {R_0D_CHROMA_HUE_CNTL,1,
247 "Chrominance hue control"},
248 {R_0E_CHROMA_CNTL_1,1,
249 "Chrominance control 1"},
250 {R_0F_CHROMA_GAIN_CNTL,1,
251 "Chrominance gain control"},
252 {R_10_CHROMA_CNTL_2,1,
253 "Chrominance control 2"},
254 {R_11_MODE_DELAY_CNTL,1,
255 "Mode/delay control"},
256 {R_12_RT_SIGNAL_CNTL,1,
257 "RT signal control"},
258 {R_13_RT_X_PORT_OUT_CNTL,1,
259 "RT/X port output control"},
260 {R_14_ANAL_ADC_COMPAT_CNTL,1,
261 "Analog/ADC/compatibility control"},
262 {R_15_VGATE_START_FID_CHG, 1,
263 "VGATE start FID change"},
264 {R_16_VGATE_STOP,1,
265 "VGATE stop"},
266 {R_17_MISC_VGATE_CONF_AND_MSB, 1,
267 "Miscellaneous VGATE configuration and MSBs"},
268 {R_18_RAW_DATA_GAIN_CNTL,1,
269 "Raw data gain control",},
270 {R_19_RAW_DATA_OFF_CNTL,1,
271 "Raw data offset control",},
272 {R_1A_COLOR_KILL_LVL_CNTL,1,
273 "Color Killer Level Control"},
274 { R_1B_MISC_TVVCRDET, 1,
275 "MISC /TVVCRDET"},
276 { R_1C_ENHAN_COMB_CTRL1, 1,
277 "Enhanced comb ctrl1"},
278 { R_1D_ENHAN_COMB_CTRL2, 1,
279 "Enhanced comb ctrl1"},
280 {R_1E_STATUS_BYTE_1_VD_DEC,1,
281 "Status byte 1 video decoder"},
282 {R_1F_STATUS_BYTE_2_VD_DEC,1,
283 "Status byte 2 video decoder"},
284
285 /* Component processing and interrupt masking part: 0x20h to R_2F_INTERRUPT_MASK_3 */
286 /* 0x20 to 0x22 - Reserved */
287 {R_23_INPUT_CNTL_5,1,
288 "Analog input control 5"},
289 {R_24_INPUT_CNTL_6,1,
290 "Analog input control 6"},
291 {R_25_INPUT_CNTL_7,1,
292 "Analog input control 7"},
293 /* 0x26 to 0x28 - Reserved */
294 {R_29_COMP_DELAY,1,
295 "Component delay"},
296 {R_2A_COMP_BRIGHT_CNTL,1,
297 "Component brightness control"},
298 {R_2B_COMP_CONTRAST_CNTL,1,
299 "Component contrast control"},
300 {R_2C_COMP_SAT_CNTL,1,
301 "Component saturation control"},
302 {R_2D_INTERRUPT_MASK_1,1,
303 "Interrupt mask 1"},
304 {R_2E_INTERRUPT_MASK_2,1,
305 "Interrupt mask 2"},
306 {R_2F_INTERRUPT_MASK_3,1,
307 "Interrupt mask 3"},
308
309 /* Audio clock generator part: R_30_AUD_MAST_CLK_CYCLES_PER_FIELD to 0x3f */
310 {R_30_AUD_MAST_CLK_CYCLES_PER_FIELD,3,
311 "Audio master clock cycles per field"},
312 /* 0x33 - Reserved */
313 {R_34_AUD_MAST_CLK_NOMINAL_INC,3,
314 "Audio master clock nominal increment"},
315 /* 0x37 - Reserved */
316 {R_38_CLK_RATIO_AMXCLK_TO_ASCLK,1,
317 "Clock ratio AMXCLK to ASCLK"},
318 {R_39_CLK_RATIO_ASCLK_TO_ALRCLK,1,
319 "Clock ratio ASCLK to ALRCLK"},
320 {R_3A_AUD_CLK_GEN_BASIC_SETUP,1,
321 "Audio clock generator basic setup"},
322 /* 0x3b-0x3f - Reserved */
323
324 /* General purpose VBI data slicer part: R_40_SLICER_CNTL_1 to 0x7f */
325 {R_40_SLICER_CNTL_1,1,
326 "Slicer control 1"},
327 {R_41_LCR,23,
328 "R_41_LCR"},
329 {R_58_PROGRAM_FRAMING_CODE,1,
330 "Programmable framing code"},
331 {R_59_H_OFF_FOR_SLICER,1,
332 "Horizontal offset for slicer"},
333 {R_5A_V_OFF_FOR_SLICER,1,
334 "Vertical offset for slicer"},
335 {R_5B_FLD_OFF_AND_MSB_FOR_H_AND_V_OFF,1,
336 "Field offset and MSBs for horizontal and vertical offset"},
337 {R_5D_DID,1,
338 "Header and data identification (R_5D_DID)"},
339 {R_5E_SDID,1,
340 "Sliced data identification (R_5E_SDID) code"},
341 {R_60_SLICER_STATUS_BYTE_0,1,
342 "Slicer status byte 0"},
343 {R_61_SLICER_STATUS_BYTE_1,1,
344 "Slicer status byte 1"},
345 {R_62_SLICER_STATUS_BYTE_2,1,
346 "Slicer status byte 2"},
347 /* 0x63-0x7f - Reserved */
348
349 /* X port, I port and the scaler part: R_80_GLOBAL_CNTL_1 to R_EF_B_VERT_LUMA_PHASE_OFF_11 */
350 /* Task independent global settings: R_80_GLOBAL_CNTL_1 to R_8F_STATUS_INFO_SCALER */
351 {R_80_GLOBAL_CNTL_1,1,
352 "Global control 1"},
353 {R_81_V_SYNC_FLD_ID_SRC_SEL_AND_RETIMED_V_F,1,
354 "Vertical sync and Field ID source selection, retimed V and F signals"},
355 /* 0x82 - Reserved */
356 {R_83_X_PORT_I_O_ENA_AND_OUT_CLK,1,
357 "X port I/O enable and output clock"},
358 {R_84_I_PORT_SIGNAL_DEF,1,
359 "I port signal definitions"},
360 {R_85_I_PORT_SIGNAL_POLAR,1,
361 "I port signal polarities"},
362 {R_86_I_PORT_FIFO_FLAG_CNTL_AND_ARBIT,1,
363 "I port FIFO flag control and arbitration"},
364 {R_87_I_PORT_I_O_ENA_OUT_CLK_AND_GATED, 1,
365 "I port I/O enable output clock and gated"},
366 {R_88_POWER_SAVE_ADC_PORT_CNTL,1,
367 "Power save/ADC port control"},
368 /* 089-0x8e - Reserved */
369 {R_8F_STATUS_INFO_SCALER,1,
370 "Status information scaler part"},
371
372 /* Task A definition: R_90_A_TASK_HANDLING_CNTL to R_BF_A_VERT_LUMA_PHASE_OFF_11 */
373 /* Task A: Basic settings and acquisition window definition */
374 {R_90_A_TASK_HANDLING_CNTL,1,
375 "Task A: Task handling control"},
376 {R_91_A_X_PORT_FORMATS_AND_CONF,1,
377 "Task A: X port formats and configuration"},
378 {R_92_A_X_PORT_INPUT_REFERENCE_SIGNAL,1,
379 "Task A: X port input reference signal definition"},
380 {R_93_A_I_PORT_OUTPUT_FORMATS_AND_CONF,1,
381 "Task A: I port output formats and configuration"},
382 {R_94_A_HORIZ_INPUT_WINDOW_START,2,
383 "Task A: Horizontal input window start"},
384 {R_96_A_HORIZ_INPUT_WINDOW_LENGTH,2,
385 "Task A: Horizontal input window length"},
386 {R_98_A_VERT_INPUT_WINDOW_START,2,
387 "Task A: Vertical input window start"},
388 {R_9A_A_VERT_INPUT_WINDOW_LENGTH,2,
389 "Task A: Vertical input window length"},
390 {R_9C_A_HORIZ_OUTPUT_WINDOW_LENGTH,2,
391 "Task A: Horizontal output window length"},
392 {R_9E_A_VERT_OUTPUT_WINDOW_LENGTH,2,
393 "Task A: Vertical output window length"},
394
395 /* Task A: FIR filtering and prescaling */
396 {R_A0_A_HORIZ_PRESCALING,1,
397 "Task A: Horizontal prescaling"},
398 {R_A1_A_ACCUMULATION_LENGTH,1,
399 "Task A: Accumulation length"},
400 {R_A2_A_PRESCALER_DC_GAIN_AND_FIR_PREFILTER,1,
401 "Task A: Prescaler DC gain and FIR prefilter"},
402 /* 0xa3 - Reserved */
403 {R_A4_A_LUMA_BRIGHTNESS_CNTL,1,
404 "Task A: Luminance brightness control"},
405 {R_A5_A_LUMA_CONTRAST_CNTL,1,
406 "Task A: Luminance contrast control"},
407 {R_A6_A_CHROMA_SATURATION_CNTL,1,
408 "Task A: Chrominance saturation control"},
409 /* 0xa7 - Reserved */
410
411 /* Task A: Horizontal phase scaling */
412 {R_A8_A_HORIZ_LUMA_SCALING_INC,2,
413 "Task A: Horizontal luminance scaling increment"},
414 {R_AA_A_HORIZ_LUMA_PHASE_OFF,1,
415 "Task A: Horizontal luminance phase offset"},
416 /* 0xab - Reserved */
417 {R_AC_A_HORIZ_CHROMA_SCALING_INC,2,
418 "Task A: Horizontal chrominance scaling increment"},
419 {R_AE_A_HORIZ_CHROMA_PHASE_OFF,1,
420 "Task A: Horizontal chrominance phase offset"},
421 /* 0xaf - Reserved */
422
423 /* Task A: Vertical scaling */
424 {R_B0_A_VERT_LUMA_SCALING_INC,2,
425 "Task A: Vertical luminance scaling increment"},
426 {R_B2_A_VERT_CHROMA_SCALING_INC,2,
427 "Task A: Vertical chrominance scaling increment"},
428 {R_B4_A_VERT_SCALING_MODE_CNTL,1,
429 "Task A: Vertical scaling mode control"},
430 /* 0xb5-0xb7 - Reserved */
431 {R_B8_A_VERT_CHROMA_PHASE_OFF_00,1,
432 "Task A: Vertical chrominance phase offset '00'"},
433 {R_B9_A_VERT_CHROMA_PHASE_OFF_01,1,
434 "Task A: Vertical chrominance phase offset '01'"},
435 {R_BA_A_VERT_CHROMA_PHASE_OFF_10,1,
436 "Task A: Vertical chrominance phase offset '10'"},
437 {R_BB_A_VERT_CHROMA_PHASE_OFF_11,1,
438 "Task A: Vertical chrominance phase offset '11'"},
439 {R_BC_A_VERT_LUMA_PHASE_OFF_00,1,
440 "Task A: Vertical luminance phase offset '00'"},
441 {R_BD_A_VERT_LUMA_PHASE_OFF_01,1,
442 "Task A: Vertical luminance phase offset '01'"},
443 {R_BE_A_VERT_LUMA_PHASE_OFF_10,1,
444 "Task A: Vertical luminance phase offset '10'"},
445 {R_BF_A_VERT_LUMA_PHASE_OFF_11,1,
446 "Task A: Vertical luminance phase offset '11'"},
447
448 /* Task B definition: R_C0_B_TASK_HANDLING_CNTL to R_EF_B_VERT_LUMA_PHASE_OFF_11 */
449 /* Task B: Basic settings and acquisition window definition */
450 {R_C0_B_TASK_HANDLING_CNTL,1,
451 "Task B: Task handling control"},
452 {R_C1_B_X_PORT_FORMATS_AND_CONF,1,
453 "Task B: X port formats and configuration"},
454 {R_C2_B_INPUT_REFERENCE_SIGNAL_DEFINITION,1,
455 "Task B: Input reference signal definition"},
456 {R_C3_B_I_PORT_FORMATS_AND_CONF,1,
457 "Task B: I port formats and configuration"},
458 {R_C4_B_HORIZ_INPUT_WINDOW_START,2,
459 "Task B: Horizontal input window start"},
460 {R_C6_B_HORIZ_INPUT_WINDOW_LENGTH,2,
461 "Task B: Horizontal input window length"},
462 {R_C8_B_VERT_INPUT_WINDOW_START,2,
463 "Task B: Vertical input window start"},
464 {R_CA_B_VERT_INPUT_WINDOW_LENGTH,2,
465 "Task B: Vertical input window length"},
466 {R_CC_B_HORIZ_OUTPUT_WINDOW_LENGTH,2,
467 "Task B: Horizontal output window length"},
468 {R_CE_B_VERT_OUTPUT_WINDOW_LENGTH,2,
469 "Task B: Vertical output window length"},
470
471 /* Task B: FIR filtering and prescaling */
472 {R_D0_B_HORIZ_PRESCALING,1,
473 "Task B: Horizontal prescaling"},
474 {R_D1_B_ACCUMULATION_LENGTH,1,
475 "Task B: Accumulation length"},
476 {R_D2_B_PRESCALER_DC_GAIN_AND_FIR_PREFILTER,1,
477 "Task B: Prescaler DC gain and FIR prefilter"},
478 /* 0xd3 - Reserved */
479 {R_D4_B_LUMA_BRIGHTNESS_CNTL,1,
480 "Task B: Luminance brightness control"},
481 {R_D5_B_LUMA_CONTRAST_CNTL,1,
482 "Task B: Luminance contrast control"},
483 {R_D6_B_CHROMA_SATURATION_CNTL,1,
484 "Task B: Chrominance saturation control"},
485 /* 0xd7 - Reserved */
486
487 /* Task B: Horizontal phase scaling */
488 {R_D8_B_HORIZ_LUMA_SCALING_INC,2,
489 "Task B: Horizontal luminance scaling increment"},
490 {R_DA_B_HORIZ_LUMA_PHASE_OFF,1,
491 "Task B: Horizontal luminance phase offset"},
492 /* 0xdb - Reserved */
493 {R_DC_B_HORIZ_CHROMA_SCALING,2,
494 "Task B: Horizontal chrominance scaling"},
495 {R_DE_B_HORIZ_PHASE_OFFSET_CRHOMA,1,
496 "Task B: Horizontal Phase Offset Chroma"},
497 /* 0xdf - Reserved */
498
499 /* Task B: Vertical scaling */
500 {R_E0_B_VERT_LUMA_SCALING_INC,2,
501 "Task B: Vertical luminance scaling increment"},
502 {R_E2_B_VERT_CHROMA_SCALING_INC,2,
503 "Task B: Vertical chrominance scaling increment"},
504 {R_E4_B_VERT_SCALING_MODE_CNTL,1,
505 "Task B: Vertical scaling mode control"},
506 /* 0xe5-0xe7 - Reserved */
507 {R_E8_B_VERT_CHROMA_PHASE_OFF_00,1,
508 "Task B: Vertical chrominance phase offset '00'"},
509 {R_E9_B_VERT_CHROMA_PHASE_OFF_01,1,
510 "Task B: Vertical chrominance phase offset '01'"},
511 {R_EA_B_VERT_CHROMA_PHASE_OFF_10,1,
512 "Task B: Vertical chrominance phase offset '10'"},
513 {R_EB_B_VERT_CHROMA_PHASE_OFF_11,1,
514 "Task B: Vertical chrominance phase offset '11'"},
515 {R_EC_B_VERT_LUMA_PHASE_OFF_00,1,
516 "Task B: Vertical luminance phase offset '00'"},
517 {R_ED_B_VERT_LUMA_PHASE_OFF_01,1,
518 "Task B: Vertical luminance phase offset '01'"},
519 {R_EE_B_VERT_LUMA_PHASE_OFF_10,1,
520 "Task B: Vertical luminance phase offset '10'"},
521 {R_EF_B_VERT_LUMA_PHASE_OFF_11,1,
522 "Task B: Vertical luminance phase offset '11'"},
523
524 /* second PLL (PLL2) and Pulsegenerator Programming */
525 { R_F0_LFCO_PER_LINE, 1,
526 "LFCO's per line"},
527 { R_F1_P_I_PARAM_SELECT,1,
528 "P-/I- Param. Select., PLL Mode, PLL H-Src., LFCO's per line"},
529 { R_F2_NOMINAL_PLL2_DTO,1,
530 "Nominal PLL2 DTO"},
531 {R_F3_PLL_INCREMENT,1,
532 "PLL2 Increment"},
533 {R_F4_PLL2_STATUS,1,
534 "PLL2 Status"},
535 {R_F5_PULSGEN_LINE_LENGTH,1,
536 "Pulsgen. line length"},
537 {R_F6_PULSE_A_POS_LSB_AND_PULSEGEN_CONFIG,1,
538 "Pulse A Position, Pulsgen Resync., Pulsgen. H-Src., Pulsgen. line length"},
539 {R_F7_PULSE_A_POS_MSB,1,
540 "Pulse A Position"},
541 {R_F8_PULSE_B_POS,2,
542 "Pulse B Position"},
543 {R_FA_PULSE_C_POS,2,
544 "Pulse C Position"},
545 /* 0xfc to 0xfe - Reserved */
546 {R_FF_S_PLL_MAX_PHASE_ERR_THRESH_NUM_LINES,1,
547 "S_PLL max. phase, error threshold, PLL2 no. of lines, threshold"},
548};
549#endif
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index f5543166d193..59da79ce2efd 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -41,53 +41,15 @@ config VIDEO_SAA7134_DVB
41 select VIDEO_BUF_DVB 41 select VIDEO_BUF_DVB
42 select FW_LOADER 42 select FW_LOADER
43 select DVB_PLL 43 select DVB_PLL
44 select DVB_MT352 if !DVB_FE_CUSTOMISE
45 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
46 select DVB_NXT200X if !DVB_FE_CUSTOMISE
47 select DVB_TDA10086 if !DVB_FE_CUSTOMISE
48 select DVB_TDA826X if !DVB_FE_CUSTOMISE
49 select DVB_ISL6421 if !DVB_FE_CUSTOMISE
44 ---help--- 50 ---help---
45 This adds support for DVB cards based on the 51 This adds support for DVB cards based on the
46 Philips saa7134 chip. 52 Philips saa7134 chip.
47 53
48 To compile this driver as a module, choose M here: the 54 To compile this driver as a module, choose M here: the
49 module will be called saa7134-dvb. 55 module will be called saa7134-dvb.
50
51 You must also select one or more DVB demodulators.
52 If you are unsure which you need, choose all of them.
53
54config VIDEO_SAA7134_DVB_ALL_FRONTENDS
55 bool "Build all supported frontends for saa7134 based TV cards"
56 default y
57 depends on VIDEO_SAA7134_DVB
58 select DVB_MT352
59 select DVB_TDA1004X
60 select DVB_NXT200X
61 ---help---
62 This builds saa7134-dvb with all currently supported frontend
63 demodulators. If you wish to tweak your configuration, and
64 only include support for the hardware that you need, choose N here.
65
66 If you are unsure, choose Y.
67
68config VIDEO_SAA7134_DVB_MT352
69 bool "Zarlink MT352 DVB-T Support"
70 default y
71 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
72 select DVB_MT352
73 ---help---
74 This adds DVB-T support for cards based on the
75 Philips saa7134 chip and the MT352 demodulator.
76
77config VIDEO_SAA7134_DVB_TDA1004X
78 bool "Phillips TDA10045H/TDA10046H DVB-T Support"
79 default y
80 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
81 select DVB_TDA1004X
82 ---help---
83 This adds DVB-T support for cards based on the
84 Philips saa7134 chip and the TDA10045H/TDA10046H demodulator.
85
86config VIDEO_SAA7134_DVB_NXT200X
87 bool "NXT2002/NXT2004 ATSC Support"
88 default y
89 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
90 select DVB_NXT200X
91 ---help---
92 This adds ATSC 8VSB and QAM64/256 support for cards based on the
93 Philips saa7134 chip and the NXT2002/NXT2004 demodulator.
diff --git a/drivers/media/video/saa7134/Makefile b/drivers/media/video/saa7134/Makefile
index be7b9ee697d6..89a1565b4256 100644
--- a/drivers/media/video/saa7134/Makefile
+++ b/drivers/media/video/saa7134/Makefile
@@ -16,8 +16,5 @@ EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
16EXTRA_CFLAGS += -Idrivers/media/dvb/frontends 16EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
17 17
18extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1 18extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
19extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
20extra-cflags-$(CONFIG_DVB_TDA1004X) += -DHAVE_TDA1004X=1
21extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
22 19
23EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m) 20EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index d73cff1970ae..a39e0136ce3b 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -590,6 +590,11 @@ static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream)
590 590
591static int snd_card_saa7134_capture_close(struct snd_pcm_substream * substream) 591static int snd_card_saa7134_capture_close(struct snd_pcm_substream * substream)
592{ 592{
593 snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
594 struct saa7134_dev *dev = saa7134->dev;
595
596 dev->ctl_mute = 1;
597 saa7134_tvaudio_setmute(dev);
593 return 0; 598 return 0;
594} 599}
595 600
@@ -631,6 +636,9 @@ static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream)
631 runtime->private_free = snd_card_saa7134_runtime_free; 636 runtime->private_free = snd_card_saa7134_runtime_free;
632 runtime->hw = snd_card_saa7134_capture; 637 runtime->hw = snd_card_saa7134_capture;
633 638
639 dev->ctl_mute = 0;
640 saa7134_tvaudio_setmute(dev);
641
634 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) 642 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
635 return err; 643 return err;
636 644
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 927413aded10..aa1db509f3d4 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -1911,7 +1911,7 @@ struct saa7134_board saa7134_boards[] = {
1911 }, 1911 },
1912 }, 1912 },
1913 [SAA7134_BOARD_FLYDVBT_DUO_CARDBUS] = { 1913 [SAA7134_BOARD_FLYDVBT_DUO_CARDBUS] = {
1914 .name = "LifeView/Typhoon FlyDVB-T Duo Cardbus", 1914 .name = "LifeView/Typhoon/Genius FlyDVB-T Duo Cardbus",
1915 .audio_clock = 0x00200000, 1915 .audio_clock = 0x00200000,
1916 .tuner_type = TUNER_PHILIPS_TDA8290, 1916 .tuner_type = TUNER_PHILIPS_TDA8290,
1917 .radio_type = UNSET, 1917 .radio_type = UNSET,
@@ -2891,6 +2891,80 @@ struct saa7134_board saa7134_boards[] = {
2891 .gpio = 0x8000, 2891 .gpio = 0x8000,
2892 }, 2892 },
2893 }, 2893 },
2894 [SAA7134_BOARD_MEDION_MD8800_QUADRO] = {
2895 .name = "Medion Md8800 Quadro",
2896 .audio_clock = 0x00187de7,
2897 .tuner_type = TUNER_PHILIPS_TDA8290,
2898 .radio_type = UNSET,
2899 .tuner_addr = ADDR_UNSET,
2900 .radio_addr = ADDR_UNSET,
2901 .mpeg = SAA7134_MPEG_DVB,
2902 .inputs = {{
2903 .name = name_tv,
2904 .vmux = 1,
2905 .amux = TV,
2906 .tv = 1,
2907 },{
2908 .name = name_comp1,
2909 .vmux = 0,
2910 .amux = LINE2,
2911 },{
2912 .name = name_svideo,
2913 .vmux = 8,
2914 .amux = LINE2,
2915 }},
2916 },
2917 [SAA7134_BOARD_FLYDVBS_LR300] = {
2918 /* LifeView FlyDVB-s */
2919 /* Igor M. Liplianin <liplianin@tut.by> */
2920 .name = "LifeView FlyDVB-S /Acorp TV134DS",
2921 .audio_clock = 0x00200000,
2922 .tuner_type = TUNER_ABSENT,
2923 .radio_type = UNSET,
2924 .tuner_addr = ADDR_UNSET,
2925 .radio_addr = ADDR_UNSET,
2926 .mpeg = SAA7134_MPEG_DVB,
2927 .inputs = {{
2928 .name = name_comp1, /* Composite input */
2929 .vmux = 3,
2930 .amux = LINE1,
2931 },{
2932 .name = name_svideo, /* S-Video signal on S-Video input */
2933 .vmux = 8,
2934 .amux = LINE1,
2935 }},
2936 },
2937 [SAA7134_BOARD_PROTEUS_2309] = {
2938 .name = "Proteus Pro 2309",
2939 .audio_clock = 0x00187de7,
2940 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
2941 .radio_type = UNSET,
2942 .tuner_addr = ADDR_UNSET,
2943 .radio_addr = ADDR_UNSET,
2944 .tda9887_conf = TDA9887_PRESENT,
2945 .inputs = {{
2946 .name = name_tv,
2947 .vmux = 1,
2948 .amux = LINE2,
2949 .tv = 1,
2950 },{
2951 .name = name_comp1,
2952 .vmux = 0,
2953 .amux = LINE2,
2954 },{
2955 .name = name_comp2,
2956 .vmux = 3,
2957 .amux = LINE2,
2958 },{
2959 .name = name_svideo,
2960 .vmux = 8,
2961 .amux = LINE2,
2962 }},
2963 .mute = {
2964 .name = name_mute,
2965 .amux = LINE1,
2966 },
2967 },
2894}; 2968};
2895 2969
2896const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 2970const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -3375,7 +3449,7 @@ struct pci_device_id saa7134_pci_tbl[] = {
3375 .driver_data = SAA7134_BOARD_FLYDVB_TRIO, 3449 .driver_data = SAA7134_BOARD_FLYDVB_TRIO,
3376 },{ 3450 },{
3377 .vendor = PCI_VENDOR_ID_PHILIPS, 3451 .vendor = PCI_VENDOR_ID_PHILIPS,
3378 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, /* SAA 7131E */ 3452 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3379 .subvendor = 0x1461, 3453 .subvendor = 0x1461,
3380 .subdevice = 0x2c05, 3454 .subdevice = 0x2c05,
3381 .driver_data = SAA7134_BOARD_AVERMEDIA_777, 3455 .driver_data = SAA7134_BOARD_AVERMEDIA_777,
@@ -3422,6 +3496,18 @@ struct pci_device_id saa7134_pci_tbl[] = {
3422 .subdevice = 0x0005, 3496 .subdevice = 0x0005,
3423 .driver_data = SAA7134_BOARD_MD7134_BRIDGE_2, 3497 .driver_data = SAA7134_BOARD_MD7134_BRIDGE_2,
3424 },{ 3498 },{
3499 .vendor = PCI_VENDOR_ID_PHILIPS,
3500 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3501 .subvendor = 0x5168,
3502 .subdevice = 0x0300,
3503 .driver_data = SAA7134_BOARD_FLYDVBS_LR300,
3504 },{
3505 .vendor = PCI_VENDOR_ID_PHILIPS,
3506 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3507 .subvendor = 0x4e42,
3508 .subdevice = 0x0300,/* LR300 */
3509 .driver_data = SAA7134_BOARD_FLYDVBS_LR300,
3510 },{
3425 .vendor = PCI_VENDOR_ID_PHILIPS, 3511 .vendor = PCI_VENDOR_ID_PHILIPS,
3426 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 3512 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3427 .subvendor = 0x1489, 3513 .subvendor = 0x1489,
@@ -3446,6 +3532,36 @@ struct pci_device_id saa7134_pci_tbl[] = {
3446 .subdevice = 0x3502, /* whats the difference to 0x3306 ?*/ 3532 .subdevice = 0x3502, /* whats the difference to 0x3306 ?*/
3447 .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS, 3533 .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS,
3448 },{ 3534 },{
3535 .vendor = PCI_VENDOR_ID_PHILIPS,
3536 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3537 .subvendor = 0x16be,
3538 .subdevice = 0x0007,
3539 .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO,
3540 },{
3541 .vendor = PCI_VENDOR_ID_PHILIPS,
3542 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3543 .subvendor = 0x16be,
3544 .subdevice = 0x0008,
3545 .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO,
3546 },{
3547 .vendor = PCI_VENDOR_ID_PHILIPS,
3548 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3549 .subvendor = 0x1461,
3550 .subdevice = 0x2c05,
3551 .driver_data = SAA7134_BOARD_AVERMEDIA_777,
3552 },{
3553 .vendor = PCI_VENDOR_ID_PHILIPS,
3554 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3555 .subvendor = 0x1489,
3556 .subdevice = 0x0502, /* Cardbus version */
3557 .driver_data = SAA7134_BOARD_FLYDVBT_DUO_CARDBUS,
3558 },{
3559 .vendor = PCI_VENDOR_ID_PHILIPS,
3560 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
3561 .subvendor = 0x0919, /* Philips Proteus PRO 2309 */
3562 .subdevice = 0x2003,
3563 .driver_data = SAA7134_BOARD_PROTEUS_2309,
3564 },{
3449 /* --- boards without eeprom + subsystem ID --- */ 3565 /* --- boards without eeprom + subsystem ID --- */
3450 .vendor = PCI_VENDOR_ID_PHILIPS, 3566 .vendor = PCI_VENDOR_ID_PHILIPS,
3451 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 3567 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -3548,6 +3664,12 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3548 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS: 3664 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
3549 case SAA7134_BOARD_FLYDVBT_LR301: 3665 case SAA7134_BOARD_FLYDVBT_LR301:
3550 case SAA7134_BOARD_FLYDVBTDUO: 3666 case SAA7134_BOARD_FLYDVBTDUO:
3667 case SAA7134_BOARD_PROTEUS_2309:
3668 dev->has_remote = SAA7134_REMOTE_GPIO;
3669 break;
3670 case SAA7134_BOARD_FLYDVBS_LR300:
3671 saa_writeb(SAA7134_GPIO_GPMODE3, 0x80);
3672 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x40);
3551 dev->has_remote = SAA7134_REMOTE_GPIO; 3673 dev->has_remote = SAA7134_REMOTE_GPIO;
3552 break; 3674 break;
3553 case SAA7134_BOARD_MD5044: 3675 case SAA7134_BOARD_MD5044:
@@ -3732,6 +3854,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
3732 case SAA7134_BOARD_PHILIPS_TIGER: 3854 case SAA7134_BOARD_PHILIPS_TIGER:
3733 case SAA7134_BOARD_TEVION_DVBT_220RF: 3855 case SAA7134_BOARD_TEVION_DVBT_220RF:
3734 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 3856 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
3857 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
3735 /* this is a hybrid board, initialize to analog mode 3858 /* this is a hybrid board, initialize to analog mode
3736 * and configure firmware eeprom address 3859 * and configure firmware eeprom address
3737 */ 3860 */
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index be3a81fc90a2..09aa62f61af7 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -843,7 +843,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
843 latency = 0x0A; 843 latency = 0x0A;
844 } 844 }
845#endif 845#endif
846 if (pci_pci_problems & PCIPCI_FAIL) { 846 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL)) {
847 printk(KERN_INFO "%s: quirk: this driver and your " 847 printk(KERN_INFO "%s: quirk: this driver and your "
848 "chipset may not work together" 848 "chipset may not work together"
849 " in overlay mode.\n",dev->name); 849 " in overlay mode.\n",dev->name);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 279828b8f299..b6881541e704 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -34,17 +34,14 @@
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include "dvb-pll.h" 35#include "dvb-pll.h"
36 36
37#ifdef HAVE_MT352 37#include "mt352.h"
38# include "mt352.h" 38#include "mt352_priv.h" /* FIXME */
39# include "mt352_priv.h" /* FIXME */ 39#include "tda1004x.h"
40#endif 40#include "nxt200x.h"
41#ifdef HAVE_TDA1004X 41
42# include "tda1004x.h" 42#include "tda10086.h"
43#endif 43#include "tda826x.h"
44#ifdef HAVE_NXT200X 44#include "isl6421.h"
45# include "nxt200x.h"
46#endif
47
48MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 45MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
49MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
50 47
@@ -54,8 +51,6 @@ module_param(antenna_pwr, int, 0444);
54MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); 51MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
55 52
56/* ------------------------------------------------------------------ */ 53/* ------------------------------------------------------------------ */
57
58#ifdef HAVE_MT352
59static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) 54static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
60{ 55{
61 u32 ok; 56 u32 ok;
@@ -185,12 +180,8 @@ static struct mt352_config avermedia_777 = {
185 .demod_address = 0xf, 180 .demod_address = 0xf,
186 .demod_init = mt352_aver777_init, 181 .demod_init = mt352_aver777_init,
187}; 182};
188#endif
189 183
190/* ------------------------------------------------------------------ */ 184/* ------------------------------------------------------------------ */
191
192#ifdef HAVE_TDA1004X
193
194static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params) 185static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
195{ 186{
196 struct saa7134_dev *dev = fe->dvb->priv; 187 struct saa7134_dev *dev = fe->dvb->priv;
@@ -969,11 +960,58 @@ static struct tda1004x_config tevion_dvbt220rf_config = {
969 .request_firmware = NULL, 960 .request_firmware = NULL,
970}; 961};
971 962
972#endif 963/* ------------------------------------------------------------------ */
964
965static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
966{
967 struct saa7134_dev *dev = fe->dvb->priv;
968 static u8 data[] = { 0x3c, 0x33, 0x68};
969 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
970
971 i2c_transfer(&dev->i2c_adap, &msg, 1);
972 philips_tda827xa_tuner_sleep( 0x61, fe);
973 return 0;
974}
975
976static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
977{
978 int ret;
979 struct saa7134_dev *dev = fe->dvb->priv;
980 static u8 tda8290_close[] = { 0x21, 0xc0};
981 static u8 tda8290_open[] = { 0x21, 0x80};
982 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
983 /* close tda8290 i2c bridge */
984 tda8290_msg.buf = tda8290_close;
985 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
986 if (ret != 1)
987 return -EIO;
988 msleep(20);
989 ret = philips_tda827xa_pll_set(0x60, fe, params);
990 if (ret != 0)
991 return ret;
992 /* open tda8290 i2c bridge */
993 tda8290_msg.buf = tda8290_open;
994 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
995 return ret;
996}
997
998static struct tda1004x_config md8800_dvbt_config = {
999 .demod_address = 0x08,
1000 .invert = 1,
1001 .invert_oclk = 0,
1002 .xtal_freq = TDA10046_XTAL_16M,
1003 .agc_config = TDA10046_AGC_TDA827X,
1004 .if_freq = TDA10046_FREQ_045,
1005 .request_firmware = NULL,
1006};
1007
1008static struct tda10086_config flydvbs = {
1009 .demod_address = 0x0e,
1010 .invert = 0,
1011};
973 1012
974/* ------------------------------------------------------------------ */ 1013/* ------------------------------------------------------------------ */
975 1014
976#ifdef HAVE_NXT200X
977static struct nxt200x_config avertvhda180 = { 1015static struct nxt200x_config avertvhda180 = {
978 .demod_address = 0x0a, 1016 .demod_address = 0x0a,
979}; 1017};
@@ -991,7 +1029,6 @@ static struct nxt200x_config kworldatsc110 = {
991 .demod_address = 0x0a, 1029 .demod_address = 0x0a,
992 .set_pll_input = nxt200x_set_pll_input, 1030 .set_pll_input = nxt200x_set_pll_input,
993}; 1031};
994#endif
995 1032
996/* ------------------------------------------------------------------ */ 1033/* ------------------------------------------------------------------ */
997 1034
@@ -1009,29 +1046,26 @@ static int dvb_init(struct saa7134_dev *dev)
1009 dev); 1046 dev);
1010 1047
1011 switch (dev->board) { 1048 switch (dev->board) {
1012#ifdef HAVE_MT352
1013 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 1049 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1014 printk("%s: pinnacle 300i dvb setup\n",dev->name); 1050 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1015 dev->dvb.frontend = mt352_attach(&pinnacle_300i, 1051 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1016 &dev->i2c_adap); 1052 &dev->i2c_adap);
1017 if (dev->dvb.frontend) { 1053 if (dev->dvb.frontend) {
1018 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; 1054 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
1019 } 1055 }
1020 break; 1056 break;
1021
1022 case SAA7134_BOARD_AVERMEDIA_777: 1057 case SAA7134_BOARD_AVERMEDIA_777:
1023 printk("%s: avertv 777 dvb setup\n",dev->name); 1058 printk("%s: avertv 777 dvb setup\n",dev->name);
1024 dev->dvb.frontend = mt352_attach(&avermedia_777, 1059 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1025 &dev->i2c_adap); 1060 &dev->i2c_adap);
1026 if (dev->dvb.frontend) { 1061 if (dev->dvb.frontend) {
1027 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs; 1062 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
1028 } 1063 }
1029 break; 1064 break;
1030#endif
1031#ifdef HAVE_TDA1004X
1032 case SAA7134_BOARD_MD7134: 1065 case SAA7134_BOARD_MD7134:
1033 dev->dvb.frontend = tda10046_attach(&medion_cardbus, 1066 dev->dvb.frontend = dvb_attach(tda10046_attach,
1034 &dev->i2c_adap); 1067 &medion_cardbus,
1068 &dev->i2c_adap);
1035 if (dev->dvb.frontend) { 1069 if (dev->dvb.frontend) {
1036 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; 1070 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1037 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep; 1071 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
@@ -1039,16 +1073,18 @@ static int dvb_init(struct saa7134_dev *dev)
1039 } 1073 }
1040 break; 1074 break;
1041 case SAA7134_BOARD_PHILIPS_TOUGH: 1075 case SAA7134_BOARD_PHILIPS_TOUGH:
1042 dev->dvb.frontend = tda10046_attach(&philips_tu1216_60_config, 1076 dev->dvb.frontend = dvb_attach(tda10046_attach,
1043 &dev->i2c_adap); 1077 &philips_tu1216_60_config,
1078 &dev->i2c_adap);
1044 if (dev->dvb.frontend) { 1079 if (dev->dvb.frontend) {
1045 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init; 1080 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
1046 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params; 1081 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
1047 } 1082 }
1048 break; 1083 break;
1049 case SAA7134_BOARD_FLYDVBTDUO: 1084 case SAA7134_BOARD_FLYDVBTDUO:
1050 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 1085 dev->dvb.frontend = dvb_attach(tda10046_attach,
1051 &dev->i2c_adap); 1086 &tda827x_lifeview_config,
1087 &dev->i2c_adap);
1052 if (dev->dvb.frontend) { 1088 if (dev->dvb.frontend) {
1053 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; 1089 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1054 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep; 1090 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
@@ -1056,8 +1092,9 @@ static int dvb_init(struct saa7134_dev *dev)
1056 } 1092 }
1057 break; 1093 break;
1058 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 1094 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1059 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 1095 dev->dvb.frontend = dvb_attach(tda10046_attach,
1060 &dev->i2c_adap); 1096 &tda827x_lifeview_config,
1097 &dev->i2c_adap);
1061 if (dev->dvb.frontend) { 1098 if (dev->dvb.frontend) {
1062 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; 1099 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1063 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep; 1100 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
@@ -1065,8 +1102,9 @@ static int dvb_init(struct saa7134_dev *dev)
1065 } 1102 }
1066 break; 1103 break;
1067 case SAA7134_BOARD_PHILIPS_EUROPA: 1104 case SAA7134_BOARD_PHILIPS_EUROPA:
1068 dev->dvb.frontend = tda10046_attach(&philips_europa_config, 1105 dev->dvb.frontend = dvb_attach(tda10046_attach,
1069 &dev->i2c_adap); 1106 &philips_europa_config,
1107 &dev->i2c_adap);
1070 if (dev->dvb.frontend) { 1108 if (dev->dvb.frontend) {
1071 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; 1109 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1072 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 1110 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
@@ -1076,8 +1114,9 @@ static int dvb_init(struct saa7134_dev *dev)
1076 } 1114 }
1077 break; 1115 break;
1078 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1116 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1079 dev->dvb.frontend = tda10046_attach(&philips_europa_config, 1117 dev->dvb.frontend = dvb_attach(tda10046_attach,
1080 &dev->i2c_adap); 1118 &philips_europa_config,
1119 &dev->i2c_adap);
1081 if (dev->dvb.frontend) { 1120 if (dev->dvb.frontend) {
1082 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1121 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1083 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; 1122 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
@@ -1085,16 +1124,18 @@ static int dvb_init(struct saa7134_dev *dev)
1085 } 1124 }
1086 break; 1125 break;
1087 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 1126 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1088 dev->dvb.frontend = tda10046_attach(&philips_tu1216_61_config, 1127 dev->dvb.frontend = dvb_attach(tda10046_attach,
1089 &dev->i2c_adap); 1128 &philips_tu1216_61_config,
1129 &dev->i2c_adap);
1090 if (dev->dvb.frontend) { 1130 if (dev->dvb.frontend) {
1091 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init; 1131 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
1092 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params; 1132 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
1093 } 1133 }
1094 break; 1134 break;
1095 case SAA7134_BOARD_PHILIPS_TIGER: 1135 case SAA7134_BOARD_PHILIPS_TIGER:
1096 dev->dvb.frontend = tda10046_attach(&philips_tiger_config, 1136 dev->dvb.frontend = dvb_attach(tda10046_attach,
1097 &dev->i2c_adap); 1137 &philips_tiger_config,
1138 &dev->i2c_adap);
1098 if (dev->dvb.frontend) { 1139 if (dev->dvb.frontend) {
1099 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init; 1140 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1100 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep; 1141 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
@@ -1102,8 +1143,9 @@ static int dvb_init(struct saa7134_dev *dev)
1102 } 1143 }
1103 break; 1144 break;
1104 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1145 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1105 dev->dvb.frontend = tda10046_attach(&philips_tiger_config, 1146 dev->dvb.frontend = dvb_attach(tda10046_attach,
1106 &dev->i2c_adap); 1147 &philips_tiger_config,
1148 &dev->i2c_adap);
1107 if (dev->dvb.frontend) { 1149 if (dev->dvb.frontend) {
1108 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init; 1150 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1109 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep; 1151 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
@@ -1111,8 +1153,9 @@ static int dvb_init(struct saa7134_dev *dev)
1111 } 1153 }
1112 break; 1154 break;
1113 case SAA7134_BOARD_FLYDVBT_LR301: 1155 case SAA7134_BOARD_FLYDVBT_LR301:
1114 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 1156 dev->dvb.frontend = dvb_attach(tda10046_attach,
1115 &dev->i2c_adap); 1157 &tda827x_lifeview_config,
1158 &dev->i2c_adap);
1116 if (dev->dvb.frontend) { 1159 if (dev->dvb.frontend) {
1117 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; 1160 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1118 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep; 1161 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
@@ -1120,16 +1163,18 @@ static int dvb_init(struct saa7134_dev *dev)
1120 } 1163 }
1121 break; 1164 break;
1122 case SAA7134_BOARD_FLYDVB_TRIO: 1165 case SAA7134_BOARD_FLYDVB_TRIO:
1123 dev->dvb.frontend = tda10046_attach(&lifeview_trio_config, 1166 dev->dvb.frontend = dvb_attach(tda10046_attach,
1124 &dev->i2c_adap); 1167 &lifeview_trio_config,
1168 &dev->i2c_adap);
1125 if (dev->dvb.frontend) { 1169 if (dev->dvb.frontend) {
1126 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep; 1170 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1127 dev->dvb.frontend->ops.tuner_ops.set_params = lifeview_trio_tuner_set_params; 1171 dev->dvb.frontend->ops.tuner_ops.set_params = lifeview_trio_tuner_set_params;
1128 } 1172 }
1129 break; 1173 break;
1130 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 1174 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1131 dev->dvb.frontend = tda10046_attach(&ads_tech_duo_config, 1175 dev->dvb.frontend = dvb_attach(tda10046_attach,
1132 &dev->i2c_adap); 1176 &ads_tech_duo_config,
1177 &dev->i2c_adap);
1133 if (dev->dvb.frontend) { 1178 if (dev->dvb.frontend) {
1134 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; 1179 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1135 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep; 1180 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
@@ -1137,37 +1182,63 @@ static int dvb_init(struct saa7134_dev *dev)
1137 } 1182 }
1138 break; 1183 break;
1139 case SAA7134_BOARD_TEVION_DVBT_220RF: 1184 case SAA7134_BOARD_TEVION_DVBT_220RF:
1140 dev->dvb.frontend = tda10046_attach(&tevion_dvbt220rf_config, 1185 dev->dvb.frontend = dvb_attach(tda10046_attach,
1141 &dev->i2c_adap); 1186 &tevion_dvbt220rf_config,
1187 &dev->i2c_adap);
1142 if (dev->dvb.frontend) { 1188 if (dev->dvb.frontend) {
1143 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep; 1189 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1144 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params; 1190 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
1145 } 1191 }
1146 break; 1192 break;
1147 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: 1193 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1148 dev->dvb.frontend = tda10046_attach(&ads_tech_duo_config, 1194 dev->dvb.frontend = dvb_attach(tda10046_attach,
1149 &dev->i2c_adap); 1195 &ads_tech_duo_config,
1196 &dev->i2c_adap);
1150 if (dev->dvb.frontend) { 1197 if (dev->dvb.frontend) {
1151 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; 1198 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1152 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep; 1199 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1153 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params; 1200 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
1154 } 1201 }
1155 break; 1202 break;
1156#endif 1203 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1157#ifdef HAVE_NXT200X 1204 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
1205 &dev->i2c_adap);
1206 if (dev->dvb.frontend) {
1207 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1208 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1209 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1210 }
1211 break;
1158 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1212 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1159 dev->dvb.frontend = nxt200x_attach(&avertvhda180, &dev->i2c_adap); 1213 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1214 &dev->i2c_adap);
1160 if (dev->dvb.frontend) { 1215 if (dev->dvb.frontend) {
1161 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tdhu2); 1216 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1217 NULL, &dvb_pll_tdhu2);
1162 } 1218 }
1163 break; 1219 break;
1164 case SAA7134_BOARD_KWORLD_ATSC110: 1220 case SAA7134_BOARD_KWORLD_ATSC110:
1165 dev->dvb.frontend = nxt200x_attach(&kworldatsc110, &dev->i2c_adap); 1221 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1222 &dev->i2c_adap);
1223 if (dev->dvb.frontend) {
1224 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1225 NULL, &dvb_pll_tuv1236d);
1226 }
1227 break;
1228 case SAA7134_BOARD_FLYDVBS_LR300:
1229 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1230 &dev->i2c_adap);
1166 if (dev->dvb.frontend) { 1231 if (dev->dvb.frontend) {
1167 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tuv1236d); 1232 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1233 &dev->i2c_adap, 0) == NULL) {
1234 printk("%s: No tda826x found!\n", __FUNCTION__);
1235 }
1236 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1237 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1238 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1239 }
1168 } 1240 }
1169 break; 1241 break;
1170#endif
1171 default: 1242 default:
1172 printk("%s: Huh? unknown DVB card?\n",dev->name); 1243 printk("%s: Huh? unknown DVB card?\n",dev->name);
1173 break; 1244 break;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 7c595492c56b..f7ea857d5d73 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -228,6 +228,12 @@ int saa7134_input_init1(struct saa7134_dev *dev)
228 mask_keyup = 0x400000; 228 mask_keyup = 0x400000;
229 polling = 50; // ms 229 polling = 50; // ms
230 break; 230 break;
231 case SAA7134_BOARD_PROTEUS_2309:
232 ir_codes = ir_codes_proteus_2309;
233 mask_keycode = 0x00007F;
234 mask_keyup = 0x000080;
235 polling = 50; // ms
236 break;
231 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 237 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
232 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 238 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
233 ir_codes = ir_codes_videomate_tv_pvr; 239 ir_codes = ir_codes_videomate_tv_pvr;
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index 0db53d192b2a..d31220d20495 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -1046,6 +1046,7 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev)
1046} 1046}
1047 1047
1048EXPORT_SYMBOL(saa_dsp_writel); 1048EXPORT_SYMBOL(saa_dsp_writel);
1049EXPORT_SYMBOL(saa7134_tvaudio_setmute);
1049 1050
1050/* ----------------------------------------------------------- */ 1051/* ----------------------------------------------------------- */
1051/* 1052/*
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index c04ce6152fd5..7db7b9705953 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -223,6 +223,9 @@ struct saa7134_format {
223#define SAA7134_BOARD_MD7134_BRIDGE_2 93 223#define SAA7134_BOARD_MD7134_BRIDGE_2 93
224#define SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS 94 224#define SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS 94
225#define SAA7134_BOARD_FLYVIDEO3000_NTSC 95 225#define SAA7134_BOARD_FLYVIDEO3000_NTSC 95
226#define SAA7134_BOARD_MEDION_MD8800_QUADRO 96
227#define SAA7134_BOARD_FLYDVBS_LR300 97
228#define SAA7134_BOARD_PROTEUS_2309 98
226 229
227#define SAA7134_MAXBOARDS 8 230#define SAA7134_MAXBOARDS 8
228#define SAA7134_INPUT_MAX 8 231#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 8dab481d384a..87ffb0e84a7a 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -480,6 +480,8 @@ static int tda9887_set_config(struct tuner *t, char *buf)
480 } 480 }
481 if ((t->tda9887_config & TDA9887_INTERCARRIER_NTSC) && (t->std & V4L2_STD_NTSC)) 481 if ((t->tda9887_config & TDA9887_INTERCARRIER_NTSC) && (t->std & V4L2_STD_NTSC))
482 buf[1] &= ~cQSS; 482 buf[1] &= ~cQSS;
483 if (t->tda9887_config & TDA9887_GATING_18)
484 buf[3] &= ~cGating_36;
483 return 0; 485 return 0;
484} 486}
485 487
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index abe37cf632c6..63db4e97ae6c 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -10,7 +10,7 @@
10#include <media/v4l2-common.h> 10#include <media/v4l2-common.h>
11 11
12static int offset = 0; 12static int offset = 0;
13module_param(offset, int, 0666); 13module_param(offset, int, 0664);
14MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); 14MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
15 15
16/* ---------------------------------------------------------------------- */ 16/* ---------------------------------------------------------------------- */
@@ -331,6 +331,8 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
331 else if (params->default_top_high) 331 else if (params->default_top_high)
332 config |= TDA9887_TOP(params->default_top_high); 332 config |= TDA9887_TOP(params->default_top_high);
333 } 333 }
334 if (params->default_pll_gating_18)
335 config |= TDA9887_GATING_18;
334 i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config); 336 i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
335 } 337 }
336 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", 338 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
@@ -439,8 +441,6 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
439 buffer[3] = 0xa4; 441 buffer[3] = 0xa4;
440 break; 442 break;
441 } 443 }
442 buffer[0] = (div>>8) & 0x7f;
443 buffer[1] = div & 0xff;
444 if (params->cb_first_if_lower_freq && div < t->last_div) { 444 if (params->cb_first_if_lower_freq && div < t->last_div) {
445 buffer[0] = buffer[2]; 445 buffer[0] = buffer[2];
446 buffer[1] = buffer[3]; 446 buffer[1] = buffer[3];
diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c
index 8b542599ed47..8fff642fad56 100644
--- a/drivers/media/video/tuner-types.c
+++ b/drivers/media/video/tuner-types.c
@@ -650,6 +650,7 @@ static struct tuner_params tuner_microtune_4049_fm5_params[] = {
650 .count = ARRAY_SIZE(tuner_temic_4009f_5_pal_ranges), 650 .count = ARRAY_SIZE(tuner_temic_4009f_5_pal_ranges),
651 .has_tda9887 = 1, 651 .has_tda9887 = 1,
652 .port1_invert_for_secam_lc = 1, 652 .port1_invert_for_secam_lc = 1,
653 .default_pll_gating_18 = 1,
653 }, 654 },
654}; 655};
655 656
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 936e3f746fba..fcaef4bf8289 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -28,6 +28,7 @@
28#include <linux/i2c-algo-bit.h> 28#include <linux/i2c-algo-bit.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
31#include <linux/kthread.h>
31 32
32#include <media/tvaudio.h> 33#include <media/tvaudio.h>
33#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
@@ -124,11 +125,8 @@ struct CHIPSTATE {
124 int input; 125 int input;
125 126
126 /* thread */ 127 /* thread */
127 pid_t tpid; 128 struct task_struct *thread;
128 struct completion texit;
129 wait_queue_head_t wq;
130 struct timer_list wt; 129 struct timer_list wt;
131 int done;
132 int watch_stereo; 130 int watch_stereo;
133 int audmode; 131 int audmode;
134}; 132};
@@ -264,28 +262,23 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
264static void chip_thread_wake(unsigned long data) 262static void chip_thread_wake(unsigned long data)
265{ 263{
266 struct CHIPSTATE *chip = (struct CHIPSTATE*)data; 264 struct CHIPSTATE *chip = (struct CHIPSTATE*)data;
267 wake_up_interruptible(&chip->wq); 265 wake_up_process(chip->thread);
268} 266}
269 267
270static int chip_thread(void *data) 268static int chip_thread(void *data)
271{ 269{
272 DECLARE_WAITQUEUE(wait, current);
273 struct CHIPSTATE *chip = data; 270 struct CHIPSTATE *chip = data;
274 struct CHIPDESC *desc = chiplist + chip->type; 271 struct CHIPDESC *desc = chiplist + chip->type;
275 272
276 daemonize("%s", chip->c.name);
277 allow_signal(SIGTERM);
278 v4l_dbg(1, debug, &chip->c, "%s: thread started\n", chip->c.name); 273 v4l_dbg(1, debug, &chip->c, "%s: thread started\n", chip->c.name);
279 274
280 for (;;) { 275 for (;;) {
281 add_wait_queue(&chip->wq, &wait); 276 set_current_state(TASK_INTERRUPTIBLE);
282 if (!chip->done) { 277 if (!kthread_should_stop())
283 set_current_state(TASK_INTERRUPTIBLE);
284 schedule(); 278 schedule();
285 } 279 set_current_state(TASK_RUNNING);
286 remove_wait_queue(&chip->wq, &wait);
287 try_to_freeze(); 280 try_to_freeze();
288 if (chip->done || signal_pending(current)) 281 if (kthread_should_stop())
289 break; 282 break;
290 v4l_dbg(1, debug, &chip->c, "%s: thread wakeup\n", chip->c.name); 283 v4l_dbg(1, debug, &chip->c, "%s: thread wakeup\n", chip->c.name);
291 284
@@ -301,7 +294,6 @@ static int chip_thread(void *data)
301 } 294 }
302 295
303 v4l_dbg(1, debug, &chip->c, "%s: thread exiting\n", chip->c.name); 296 v4l_dbg(1, debug, &chip->c, "%s: thread exiting\n", chip->c.name);
304 complete_and_exit(&chip->texit, 0);
305 return 0; 297 return 0;
306} 298}
307 299
@@ -1536,19 +1528,18 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1536 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); 1528 chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble));
1537 } 1529 }
1538 1530
1539 chip->tpid = -1; 1531 chip->thread = NULL;
1540 if (desc->checkmode) { 1532 if (desc->checkmode) {
1541 /* start async thread */ 1533 /* start async thread */
1542 init_timer(&chip->wt); 1534 init_timer(&chip->wt);
1543 chip->wt.function = chip_thread_wake; 1535 chip->wt.function = chip_thread_wake;
1544 chip->wt.data = (unsigned long)chip; 1536 chip->wt.data = (unsigned long)chip;
1545 init_waitqueue_head(&chip->wq); 1537 chip->thread = kthread_run(chip_thread, chip, chip->c.name);
1546 init_completion(&chip->texit); 1538 if (IS_ERR(chip->thread)) {
1547 chip->tpid = kernel_thread(chip_thread,(void *)chip,0); 1539 v4l_warn(&chip->c, "%s: failed to create kthread\n",
1548 if (chip->tpid < 0)
1549 v4l_warn(&chip->c, "%s: kernel_thread() failed\n",
1550 chip->c.name); 1540 chip->c.name);
1551 wake_up_interruptible(&chip->wq); 1541 chip->thread = NULL;
1542 }
1552 } 1543 }
1553 return 0; 1544 return 0;
1554} 1545}
@@ -1569,11 +1560,10 @@ static int chip_detach(struct i2c_client *client)
1569 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1560 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1570 1561
1571 del_timer_sync(&chip->wt); 1562 del_timer_sync(&chip->wt);
1572 if (chip->tpid >= 0) { 1563 if (chip->thread) {
1573 /* shutdown async thread */ 1564 /* shutdown async thread */
1574 chip->done = 1; 1565 kthread_stop(chip->thread);
1575 wake_up_interruptible(&chip->wq); 1566 chip->thread = NULL;
1576 wait_for_completion(&chip->texit);
1577 } 1567 }
1578 1568
1579 i2c_detach_client(&chip->c); 1569 i2c_detach_client(&chip->c);
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index d95529e8e513..cd1502ac9560 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -605,6 +605,8 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
605 tvee->tuner_formats |= hauppauge_tuner_fmt[i].id; 605 tvee->tuner_formats |= hauppauge_tuner_fmt[i].id;
606 t_fmt_name1[j++] = hauppauge_tuner_fmt[i].name; 606 t_fmt_name1[j++] = hauppauge_tuner_fmt[i].name;
607 } 607 }
608 }
609 for (i = j = 0; i < 8; i++) {
608 if (t_format2 & (1 << i)) { 610 if (t_format2 & (1 << i)) {
609 tvee->tuner2_formats |= hauppauge_tuner_fmt[i].id; 611 tvee->tuner2_formats |= hauppauge_tuner_fmt[i].id;
610 t_fmt_name2[j++] = hauppauge_tuner_fmt[i].name; 612 t_fmt_name2[j++] = hauppauge_tuner_fmt[i].name;
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index b167ffab2520..bc0a4fc27b24 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -294,7 +294,7 @@ static inline void tvp5150_selmux(struct i2c_client *c)
294 if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable) 294 if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable)
295 input = 8; 295 input = 8;
296 296
297 switch (input) { 297 switch (decoder->route.input) {
298 case TVP5150_COMPOSITE1: 298 case TVP5150_COMPOSITE1:
299 input |= 2; 299 input |= 2;
300 /* fall through */ 300 /* fall through */
@@ -308,6 +308,11 @@ static inline void tvp5150_selmux(struct i2c_client *c)
308 break; 308 break;
309 } 309 }
310 310
311 tvp5150_dbg( 1, "Selecting video route: route input=%i, output=%i "
312 "=> tvp5150 input=%i, opmode=%i\n",
313 decoder->route.input,decoder->route.output,
314 input, opmode );
315
311 tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode); 316 tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode);
312 tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input); 317 tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input);
313}; 318};
diff --git a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c
index 6f31ecc88843..4eee8be88314 100644
--- a/drivers/media/video/usbvideo/konicawc.c
+++ b/drivers/media/video/usbvideo/konicawc.c
@@ -222,6 +222,7 @@ static void konicawc_adjust_picture(struct uvd *uvd)
222static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) 222static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev)
223{ 223{
224 struct input_dev *input_dev; 224 struct input_dev *input_dev;
225 int error;
225 226
226 usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname)); 227 usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname));
227 strncat(cam->input_physname, "/input0", sizeof(cam->input_physname)); 228 strncat(cam->input_physname, "/input0", sizeof(cam->input_physname));
@@ -242,7 +243,13 @@ static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev
242 243
243 input_dev->private = cam; 244 input_dev->private = cam;
244 245
245 input_register_device(cam->input); 246 error = input_register_device(cam->input);
247 if (error) {
248 warn("Failed to register camera's input device, err: %d\n",
249 error);
250 input_free_device(cam->input);
251 cam->input = NULL;
252 }
246} 253}
247 254
248static void konicawc_unregister_input(struct konicawc *cam) 255static void konicawc_unregister_input(struct konicawc *cam)
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 90d48e8510ba..08f9559a6bfa 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -7,6 +7,7 @@
7 * Monroe Williams (monroe@pobox.com) 7 * Monroe Williams (monroe@pobox.com)
8 * 8 *
9 * Supports 3COM HomeConnect PC Digital WebCam 9 * Supports 3COM HomeConnect PC Digital WebCam
10 * Supports Compro PS39U WebCam
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
@@ -60,6 +61,8 @@
60/* Define these values to match your device */ 61/* Define these values to match your device */
61#define USB_VICAM_VENDOR_ID 0x04c1 62#define USB_VICAM_VENDOR_ID 0x04c1
62#define USB_VICAM_PRODUCT_ID 0x009d 63#define USB_VICAM_PRODUCT_ID 0x009d
64#define USB_COMPRO_VENDOR_ID 0x0602
65#define USB_COMPRO_PRODUCT_ID 0x1001
63 66
64#define VICAM_BYTES_PER_PIXEL 3 67#define VICAM_BYTES_PER_PIXEL 3
65#define VICAM_MAX_READ_SIZE (512*242+128) 68#define VICAM_MAX_READ_SIZE (512*242+128)
@@ -1254,6 +1257,7 @@ static struct video_device vicam_template = {
1254/* table of devices that work with this driver */ 1257/* table of devices that work with this driver */
1255static struct usb_device_id vicam_table[] = { 1258static struct usb_device_id vicam_table[] = {
1256 {USB_DEVICE(USB_VICAM_VENDOR_ID, USB_VICAM_PRODUCT_ID)}, 1259 {USB_DEVICE(USB_VICAM_VENDOR_ID, USB_VICAM_PRODUCT_ID)},
1260 {USB_DEVICE(USB_COMPRO_VENDOR_ID, USB_COMPRO_PRODUCT_ID)},
1257 {} /* Terminating entry */ 1261 {} /* Terminating entry */
1258}; 1262};
1259 1263
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index d7c3fcbc80f7..1d899e2db394 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -349,6 +349,8 @@ v4l_compat_translate_ioctl(struct inode *inode,
349 { 349 {
350 struct video_buffer *buffer = arg; 350 struct video_buffer *buffer = arg;
351 351
352 memset(buffer, 0, sizeof(*buffer));
353
352 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); 354 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2);
353 if (err < 0) { 355 if (err < 0) {
354 dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n",err); 356 dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n",err);
@@ -361,7 +363,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
361 switch (fbuf2.fmt.pixelformat) { 363 switch (fbuf2.fmt.pixelformat) {
362 case V4L2_PIX_FMT_RGB332: 364 case V4L2_PIX_FMT_RGB332:
363 buffer->depth = 8; 365 buffer->depth = 8;
364 break; 366 break;
365 case V4L2_PIX_FMT_RGB555: 367 case V4L2_PIX_FMT_RGB555:
366 buffer->depth = 15; 368 buffer->depth = 15;
367 break; 369 break;
@@ -377,9 +379,13 @@ v4l_compat_translate_ioctl(struct inode *inode,
377 default: 379 default:
378 buffer->depth = 0; 380 buffer->depth = 0;
379 } 381 }
380 if (0 != fbuf2.fmt.bytesperline) 382 if (fbuf2.fmt.bytesperline) {
381 buffer->bytesperline = fbuf2.fmt.bytesperline; 383 buffer->bytesperline = fbuf2.fmt.bytesperline;
382 else { 384 if (!buffer->depth && buffer->width)
385 buffer->depth = ((fbuf2.fmt.bytesperline<<3)
386 + (buffer->width-1) )
387 /buffer->width;
388 } else {
383 buffer->bytesperline = 389 buffer->bytesperline =
384 (buffer->width * buffer->depth + 7) & 7; 390 (buffer->width * buffer->depth + 7) & 7;
385 buffer->bytesperline >>= 3; 391 buffer->bytesperline >>= 3;
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 8d972ffdaf98..78d28b03ec93 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -938,6 +938,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
938 case VIDIOC_INT_AUDIO_CLOCK_FREQ: 938 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
939 case VIDIOC_INT_I2S_CLOCK_FREQ: 939 case VIDIOC_INT_I2S_CLOCK_FREQ:
940 case VIDIOC_INT_S_STANDBY: 940 case VIDIOC_INT_S_STANDBY:
941 case VIDIOC_INT_RESET:
941 { 942 {
942 u32 *p=arg; 943 u32 *p=arg;
943 944
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index 7ee8a53cd336..f53edf1923b7 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -223,6 +223,7 @@ fail_dmxdev:
223fail_dmx: 223fail_dmx:
224 dvb_unregister_frontend(dvb->frontend); 224 dvb_unregister_frontend(dvb->frontend);
225fail_frontend: 225fail_frontend:
226 dvb_frontend_detach(dvb->frontend);
226 dvb_unregister_adapter(&dvb->adapter); 227 dvb_unregister_adapter(&dvb->adapter);
227fail_adapter: 228fail_adapter:
228 return result; 229 return result;
@@ -236,6 +237,7 @@ void videobuf_dvb_unregister(struct videobuf_dvb *dvb)
236 dvb_dmxdev_release(&dvb->dmxdev); 237 dvb_dmxdev_release(&dvb->dmxdev);
237 dvb_dmx_release(&dvb->demux); 238 dvb_dmx_release(&dvb->demux);
238 dvb_unregister_frontend(dvb->frontend); 239 dvb_unregister_frontend(dvb->frontend);
240 dvb_frontend_detach(dvb->frontend);
239 dvb_unregister_adapter(&dvb->adapter); 241 dvb_unregister_adapter(&dvb->adapter);
240} 242}
241 243
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index edd7b83c3464..479a0675cf60 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -739,13 +739,13 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
739 case VIDIOC_DQBUF: 739 case VIDIOC_DQBUF:
740 { 740 {
741 struct v4l2_buffer *p=arg; 741 struct v4l2_buffer *p=arg;
742 if (!vfd->vidioc_qbuf) 742 if (!vfd->vidioc_dqbuf)
743 break; 743 break;
744 ret = check_fmt (vfd, p->type); 744 ret = check_fmt (vfd, p->type);
745 if (ret) 745 if (ret)
746 break; 746 break;
747 747
748 ret=vfd->vidioc_qbuf(file, fh, p); 748 ret=vfd->vidioc_dqbuf(file, fh, p);
749 if (!ret) 749 if (!ret)
750 dbgbuf(cmd,vfd,p); 750 dbgbuf(cmd,vfd,p);
751 break; 751 break;
@@ -836,7 +836,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
836 break; 836 break;
837 } 837 }
838 838
839 if (index < 0 || index >= vfd->tvnormsize) { 839 if (index<0 || index >= vfd->tvnormsize) {
840 ret=-EINVAL; 840 ret=-EINVAL;
841 break; 841 break;
842 } 842 }
@@ -1283,9 +1283,29 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1283 case VIDIOC_G_PARM: 1283 case VIDIOC_G_PARM:
1284 { 1284 {
1285 struct v4l2_streamparm *p=arg; 1285 struct v4l2_streamparm *p=arg;
1286 if (!vfd->vidioc_g_parm) 1286 if (vfd->vidioc_g_parm) {
1287 break; 1287 ret=vfd->vidioc_g_parm(file, fh, p);
1288 ret=vfd->vidioc_g_parm(file, fh, p); 1288 } else {
1289 struct v4l2_standard s;
1290
1291 if (!vfd->tvnormsize) {
1292 printk (KERN_WARNING "%s: no TV norms defined!\n",
1293 vfd->name);
1294 break;
1295 }
1296
1297 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1298 return -EINVAL;
1299
1300 v4l2_video_std_construct(&s, vfd->tvnorms[vfd->current_norm].id,
1301 vfd->tvnorms[vfd->current_norm].name);
1302
1303 memset(p,0,sizeof(*p));
1304
1305 p->parm.capture.timeperframe = s.frameperiod;
1306 ret=0;
1307 }
1308
1289 dbgarg (cmd, "type=%d\n", p->type); 1309 dbgarg (cmd, "type=%d\n", p->type);
1290 break; 1310 break;
1291 } 1311 }
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 268e69fdefc6..d1e04f7c530b 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -4404,7 +4404,6 @@ static struct video_device v4l_device_template = {
4404 .name = "NOT SET", 4404 .name = "NOT SET",
4405 //.type = VID_TYPE_CAPTURE | VID_TYPE_SUBCAPTURE | 4405 //.type = VID_TYPE_CAPTURE | VID_TYPE_SUBCAPTURE |
4406 // VID_TYPE_CLIPPING | VID_TYPE_SCALES, VID_TYPE_OVERLAY 4406 // VID_TYPE_CLIPPING | VID_TYPE_SCALES, VID_TYPE_OVERLAY
4407 .hardware = VID_HARDWARE_VINO,
4408 .fops = &vino_fops, 4407 .fops = &vino_fops,
4409 .minor = -1, 4408 .minor = -1,
4410}; 4409};
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 841884af0cc0..e7c01d560b64 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -992,7 +992,8 @@ static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf)
992 struct vivi_fh *fh=priv; 992 struct vivi_fh *fh=priv;
993 struct videobuf_queue *q=&fh->vb_vidq; 993 struct videobuf_queue *q=&fh->vb_vidq;
994 struct v4l2_requestbuffers req; 994 struct v4l2_requestbuffers req;
995 unsigned int i, ret; 995 unsigned int i;
996 int ret;
996 997
997 req.type = q->type; 998 req.type = q->type;
998 req.count = 8; 999 req.count = 8;
@@ -1359,6 +1360,8 @@ static int __init vivi_init(void)
1359 dev->vidq.timeout.data = (unsigned long)dev; 1360 dev->vidq.timeout.data = (unsigned long)dev;
1360 init_timer(&dev->vidq.timeout); 1361 init_timer(&dev->vidq.timeout);
1361 1362
1363 vivi.current_norm = tvnorms[0].id;
1364
1362 ret = video_register_device(&vivi, VFL_TYPE_GRABBER, video_nr); 1365 ret = video_register_device(&vivi, VFL_TYPE_GRABBER, video_nr);
1363 printk(KERN_INFO "Video Technology Magazine Virtual Video Capture Board (Load status: %d)\n", ret); 1366 printk(KERN_INFO "Video Technology Magazine Virtual Video Capture Board (Load status: %d)\n", ret);
1364 return ret; 1367 return ret;
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 1eca7e65d235..8ef31ed7d3f1 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -744,6 +744,6 @@ vpx3220_cleanup (void)
744module_init(vpx3220_init); 744module_init(vpx3220_init);
745module_exit(vpx3220_cleanup); 745module_exit(vpx3220_cleanup);
746 746
747MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video encoder driver"); 747MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver");
748MODULE_AUTHOR("Laurent Pinchart"); 748MODULE_AUTHOR("Laurent Pinchart");
749MODULE_LICENSE("GPL"); 749MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 29f59c36f001..9f21d0ba0f0f 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -1620,10 +1620,10 @@ init_dc10_cards (void)
1620 dprintk(5, KERN_DEBUG "Jotti is een held!\n"); 1620 dprintk(5, KERN_DEBUG "Jotti is een held!\n");
1621 1621
1622 /* some mainboards might not do PCI-PCI data transfer well */ 1622 /* some mainboards might not do PCI-PCI data transfer well */
1623 if (pci_pci_problems & PCIPCI_FAIL) { 1623 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) {
1624 dprintk(1, 1624 dprintk(1,
1625 KERN_WARNING 1625 KERN_WARNING
1626 "%s: chipset may not support reliable PCI-PCI DMA\n", 1626 "%s: chipset does not support reliable PCI-PCI DMA\n",
1627 ZORAN_NAME); 1627 ZORAN_NAME);
1628 } 1628 }
1629 1629
@@ -1631,7 +1631,7 @@ init_dc10_cards (void)
1631 for (i = 0; i < zoran_num; i++) { 1631 for (i = 0; i < zoran_num; i++) {
1632 struct zoran *zr = &zoran[i]; 1632 struct zoran *zr = &zoran[i];
1633 1633
1634 if (pci_pci_problems & PCIPCI_NATOMA && zr->revision <= 1) { 1634 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
1635 zr->jpg_buffers.need_contiguous = 1; 1635 zr->jpg_buffers.need_contiguous = 1;
1636 dprintk(1, 1636 dprintk(1,
1637 KERN_INFO 1637 KERN_INFO
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 5f90db27892b..862a984c2155 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -1512,6 +1512,13 @@ setup_fbuffer (struct file *file,
1512 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) 1512 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO))
1513 return -EPERM; 1513 return -EPERM;
1514 1514
1515 /* Don't allow frame buffer overlay if PCI or AGP is buggy, or on
1516 ALi Magik (that needs very low latency while the card needs a
1517 higher value always) */
1518
1519 if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
1520 return -ENXIO;
1521
1515 /* we need a bytesperline value, even if not given */ 1522 /* we need a bytesperline value, even if not given */
1516 if (!bytesperline) 1523 if (!bytesperline)
1517 bytesperline = width * ((fmt->depth + 7) & ~7) / 8; 1524 bytesperline = width * ((fmt->depth + 7) & ~7) / 8;
diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c
index 50437383ed62..9240638a0134 100644
--- a/drivers/media/video/zr36120.c
+++ b/drivers/media/video/zr36120.c
@@ -987,6 +987,8 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg)
987 VID_TYPE_SCALES; 987 VID_TYPE_SCALES;
988 if (ztv->have_tuner) 988 if (ztv->have_tuner)
989 c.type |= VID_TYPE_TUNER; 989 c.type |= VID_TYPE_TUNER;
990 if (pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL))
991 c.type &= ~VID_TYPE_OVERLAY;
990 if (ztv->have_decoder) { 992 if (ztv->have_decoder) {
991 c.channels = ztv->card->video_inputs; 993 c.channels = ztv->card->video_inputs;
992 c.audios = ztv->card->audio_inputs; 994 c.audios = ztv->card->audio_inputs;
@@ -1284,6 +1286,8 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg)
1284 struct video_buffer v; 1286 struct video_buffer v;
1285 if(!capable(CAP_SYS_ADMIN)) 1287 if(!capable(CAP_SYS_ADMIN))
1286 return -EPERM; 1288 return -EPERM;
1289 if (pcipci_problems & (PCIPCI_FAIL|PCIAGP_FAIL))
1290 return -ENXIO;
1287 if (copy_from_user(&v, arg,sizeof(v))) 1291 if (copy_from_user(&v, arg,sizeof(v)))
1288 return -EFAULT; 1292 return -EFAULT;
1289 DEBUG(printk(CARD_DEBUG "VIDIOCSFBUF(%p,%d,%d,%d,%d)\n",CARD,v.base, v.width,v.height,v.depth,v.bytesperline)); 1293 DEBUG(printk(CARD_DEBUG "VIDIOCSFBUF(%p,%d,%d,%d,%d)\n",CARD,v.base, v.width,v.height,v.depth,v.bytesperline));
@@ -2030,7 +2034,7 @@ void release_zoran(int max)
2030 /* free it */ 2034 /* free it */
2031 free_irq(ztv->dev->irq,ztv); 2035 free_irq(ztv->dev->irq,ztv);
2032 2036
2033 /* unregister i2c_bus */ 2037 /* unregister i2c_bus */
2034 i2c_unregister_bus((&ztv->i2c)); 2038 i2c_unregister_bus((&ztv->i2c));
2035 2039
2036 /* unmap and free memory */ 2040 /* unmap and free memory */