Commit ca583a3c authored by Linus Torvalds's avatar Linus Torvalds

Merge http://lia64.bkbits.net/linux-ia64-release-2.6.11

into ppc970.osdl.org:/home/torvalds/v2.6/linux
parents 97231034 47d3a8f9
...@@ -26,7 +26,7 @@ Produced and reselled by Twinhan: ...@@ -26,7 +26,7 @@ Produced and reselled by Twinhan:
- HAMA DVB-T USB device - HAMA DVB-T USB device
http://www.hama.de/portal/articleId*110620/action*2598 http://www.hama.de/portal/articleId*110620/action*2598
- CTS Portable (Chinese Television System) - CTS Portable (Chinese Television System) (2)
http://www.2cts.tv/ctsportable/ http://www.2cts.tv/ctsportable/
- Unknown USB DVB-T device with vendor ID Hyper-Paltek - Unknown USB DVB-T device with vendor ID Hyper-Paltek
...@@ -46,16 +46,16 @@ Produced and reselled by KWorld: ...@@ -46,16 +46,16 @@ Produced and reselled by KWorld:
Others: Others:
------- -------
- Ultima Electronic/Artec T1 USB TVBOX (AN2135 and AN2235) - Ultima Electronic/Artec T1 USB TVBOX (AN2135, AN2235, AN2235 with Panasonic Tuner)
http://82.161.246.249/products-tvbox.html http://82.161.246.249/products-tvbox.html
- Compro Videomate DVB-U2000 - DVB-T USB - Compro Videomate DVB-U2000 - DVB-T USB (2)
http://www.comprousa.com/products/vmu2000.htm http://www.comprousa.com/products/vmu2000.htm
- Grandtec USB DVB-T - Grandtec USB DVB-T
http://www.grand.com.tw/ http://www.grand.com.tw/
- Avermedia AverTV DVBT USB - Avermedia AverTV DVBT USB (2)
http://www.avermedia.com/ http://www.avermedia.com/
- DiBcom USB DVB-T reference device (non-public) - DiBcom USB DVB-T reference device (non-public)
...@@ -63,16 +63,33 @@ Others: ...@@ -63,16 +63,33 @@ Others:
Supported devices USB2.0 Supported devices USB2.0
======================== ========================
- Twinhan MagicBox II - Twinhan MagicBox II (2)
http://www.twinhan.com/product_terrestrial_7.asp http://www.twinhan.com/product_terrestrial_7.asp
- Yakumo DVB-T mobile - Hanftek UMT-010 (1)
http://www.globalsources.com/si/6008819757082/ProductDetail/Digital-TV/product_id-100046529
- Typhoon/Yakumo/HAMA DVB-T mobile USB2.0 (1)
http://www.yakumo.de/produkte/index.php?pid=1&ag=DVB-T http://www.yakumo.de/produkte/index.php?pid=1&ag=DVB-T
- Artec T1 USB TVBOX (FX2) (2)
- DiBcom USB2.0 DVB-T reference device (non-public) - DiBcom USB2.0 DVB-T reference device (non-public)
1) It is working almost.
2) No test reports received yet.
0. NEWS: 0. NEWS:
2004-01-13 - moved the mirrored pid_filter_table back to dvb-dibusb
- first almost working version for HanfTek UMT-010
- found out, that Yakumo/HAMA/Typhoon are predessors of the HanfTek
2004-01-10 - refactoring completed, now everything is very delightful
- tuner quirks for some weird devices (Artec T1 AN2235 device has sometimes a
Panasonic Tuner assembled). Tunerprobing implemented. Thanks a lot to Gunnar Wittich.
2004-12-29 - after several days of struggling around bug of no returning URBs fixed.
2004-12-26 - refactored the dibusb-driver, splitted into separate files
- i2c-probing enabled
2004-12-06 - possibility for demod i2c-address probing 2004-12-06 - possibility for demod i2c-address probing
- new usb IDs (Compro,Artec) - new usb IDs (Compro,Artec)
2004-11-23 - merged changes from DiB3000MC_ver2.1 2004-11-23 - merged changes from DiB3000MC_ver2.1
...@@ -115,13 +132,15 @@ Supported devices USB2.0 ...@@ -115,13 +132,15 @@ Supported devices USB2.0
1. How to use? 1. How to use?
NOTE: This driver was developed using Linux 2.6.6., NOTE: This driver was developed using Linux 2.6.6.,
it is working with 2.6.7, 2.6.8.1, 2.6.9 . it is working with 2.6.7 and above.
Linux 2.4.x support is not planned, but patches are very welcome. Linux 2.4.x support is not planned, but patches are very welcome.
NOTE: I'm using Debian testing, so the following explaination (especially NOTE: I'm using Debian testing, so the following explaination (especially
the hotplug-path) needn't match your system, but probably it will :). the hotplug-path) needn't match your system, but probably it will :).
The driver is included in the kernel since Linux 2.6.10.
1.1. Firmware 1.1. Firmware
The USB driver needs to download a firmware to start working. The USB driver needs to download a firmware to start working.
...@@ -155,9 +174,13 @@ from withing the dvb-kernel cvs repository. ...@@ -155,9 +174,13 @@ from withing the dvb-kernel cvs repository.
first have a look, which debug level are available: first have a look, which debug level are available:
modinfo dib3000mb modinfo dib3000mb
modinfo dib3000-common
modinfo dib3000mc
modinfo dvb-dibusb modinfo dvb-dibusb
modprobe dib3000-common debug=<level>
modprobe dib3000mb debug=<level> modprobe dib3000mb debug=<level>
modprobe dib3000mc debug=<level>
modprobe dvb-dibusb debug=<level> modprobe dvb-dibusb debug=<level>
should do the trick. should do the trick.
...@@ -168,13 +191,11 @@ turned on. ...@@ -168,13 +191,11 @@ turned on.
At this point you should be able to start a dvb-capable application. For myself At this point you should be able to start a dvb-capable application. For myself
I used mplayer, dvbscan, tzap and kaxtv, they are working. Using the device I used mplayer, dvbscan, tzap and kaxtv, they are working. Using the device
as a slave device in vdr, was not working for me. Some work has to be done in vdr (at least the USB2.0 one) is working.
(patches and comments are very welcome).
2. Known problems and bugs 2. Known problems and bugs
TODO: - none this time
- signal-quality and strength calculations
2.1. Adding support for devices 2.1. Adding support for devices
...@@ -202,9 +223,10 @@ Most of the current supported devices are USB1.1 and thus they have a ...@@ -202,9 +223,10 @@ Most of the current supported devices are USB1.1 and thus they have a
maximum bandwidth of about 5-6 MBit/s when connected to a USB2.0 hub. maximum bandwidth of about 5-6 MBit/s when connected to a USB2.0 hub.
This is not enough for receiving the complete transport stream of a This is not enough for receiving the complete transport stream of a
DVB-T channel (which can be about 16 MBit/s). Normally this is not a DVB-T channel (which can be about 16 MBit/s). Normally this is not a
problem, if you only want to watch TV, but watching a channel while problem, if you only want to watch TV (this does not apply for HDTV),
recording another channel on the same frequency simply does not work. but watching a channel while recording another channel on the same
This applies to all USB1.1 DVB-T devices. frequency simply does not work. This applies to all USB1.1 DVB-T
devices, not only dibusb)
A special problem of the dibusb for the USB1.1 is, that the USB control A special problem of the dibusb for the USB1.1 is, that the USB control
IC has a problem with write accesses while having MPEG2-streaming IC has a problem with write accesses while having MPEG2-streaming
...@@ -218,14 +240,20 @@ due the automatic scanning (introduced in 1.3.x, afaik) and epg-scan. Disabling ...@@ -218,14 +240,20 @@ due the automatic scanning (introduced in 1.3.x, afaik) and epg-scan. Disabling
these features is maybe a solution. Additionally this behaviour of VDR exceeds these features is maybe a solution. Additionally this behaviour of VDR exceeds
the USB1.1 bandwidth. the USB1.1 bandwidth.
Update:
For the USB1.1 and VDR some work has been done (patches and comments are still
very welcome). Maybe the problem is solved in the meantime because I now use
the dmx_sw_filter function instead of dmx_sw_filter_packet. I hope the
linux-dvb software filter is able to get the best of the garbled TS.
2.3. Comments 2.3. Comments
Patches, comments and suggestions are very very welcome Patches, comments and suggestions are very very welcome
3. Acknowledgements 3. Acknowledgements
Amaury Demol (ademol@dibcom.fr) and Francois Kanounnikoff from DiBcom for Amaury Demol (ademol@dibcom.fr) and Francois Kanounnikoff from DiBcom for
providing specs, code and help, on which the dvb-dibusb and dib3000mb are providing specs, code and help, on which the dvb-dibusb, dib3000mb and
based. dib3000mc are based.
David Matthews for identifying a new device type (Artec T1 with AN2235) David Matthews for identifying a new device type (Artec T1 with AN2235)
and for extending dibusb with remote control event handling. Thank you. and for extending dibusb with remote control event handling. Thank you.
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
use File::Temp qw/ tempdir /; use File::Temp qw/ tempdir /;
use IO::Handle; use IO::Handle;
@components = ( "sp8870", "sp887x", "tda10045", "tda10046", "av7110", "dec2000t", "dec2540t", "dec3000s", "vp7041", "dibusb" ); @components = ( "sp8870", "sp887x", "tda10045", "tda10046", "av7110", "dec2000t",
"dec2540t", "dec3000s", "vp7041", "dibusb", "nxt2002" );
# Check args # Check args
syntax() if (scalar(@ARGV) != 1); syntax() if (scalar(@ARGV) != 1);
...@@ -233,6 +234,23 @@ sub dibusb { ...@@ -233,6 +234,23 @@ sub dibusb {
$outfile; $outfile;
} }
sub nxt2002 {
my $sourcefile = "Broadband4PC_4_2_11.zip";
my $url = "http://www.bbti.us/download/windows/$sourcefile";
my $hash = "c6d2ea47a8f456d887ada0cfb718ff2a";
my $outfile = "dvb-fe-nxt2002.fw";
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
checkstandard();
wgetfile($sourcefile, $url);
unzip($sourcefile, $tmpdir);
verify("$tmpdir/SkyNETU.sys", $hash);
extract("$tmpdir/SkyNETU.sys", 375832, 5908, $outfile);
$outfile;
}
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Utilities # Utilities
......
...@@ -67,7 +67,7 @@ struct rt_sigframe { ...@@ -67,7 +67,7 @@ struct rt_sigframe {
struct siginfo info; struct siginfo info;
/* 64 bit ABI allows for 288 bytes below sp before decrementing it. */ /* 64 bit ABI allows for 288 bytes below sp before decrementing it. */
char abigap[288]; char abigap[288];
}; } __attribute__ ((aligned (16)));
/* /*
...@@ -254,7 +254,7 @@ static inline void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs ...@@ -254,7 +254,7 @@ static inline void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs
newsp = (current->sas_ss_sp + current->sas_ss_size); newsp = (current->sas_ss_sp + current->sas_ss_size);
} }
return (void __user *)((newsp - frame_size) & -8ul); return (void __user *)((newsp - frame_size) & -16ul);
} }
/* /*
......
...@@ -380,8 +380,8 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent ...@@ -380,8 +380,8 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
/* disable all irqs */ /* disable all irqs */
saa7146_write(dev, IER, 0); saa7146_write(dev, IER, 0);
/* shut down all dma transfers */ /* shut down all dma transfers and rps tasks */
saa7146_write(dev, MC1, 0x00ff0000); saa7146_write(dev, MC1, 0x30ff0000);
/* clear out any rps-signals pending */ /* clear out any rps-signals pending */
saa7146_write(dev, MC2, 0xf8000000); saa7146_write(dev, MC2, 0xf8000000);
......
...@@ -4,9 +4,11 @@ config DVB_B2C2_SKYSTAR ...@@ -4,9 +4,11 @@ config DVB_B2C2_SKYSTAR
select DVB_STV0299 select DVB_STV0299
select DVB_MT352 select DVB_MT352
select DVB_MT312 select DVB_MT312
select DVB_NXT2002
help help
Support for the Skystar2 PCI DVB card by Technisat, which Support for the Skystar2 PCI DVB card by Technisat, which
is equipped with the FlexCopII chipset by B2C2. is equipped with the FlexCopII chipset by B2C2, and
for the B2C2/BBTI Air2PC-ATSC card.
Say Y if you own such a device and want to use it. Say Y if you own such a device and want to use it.
...@@ -17,7 +19,7 @@ config DVB_B2C2_USB ...@@ -17,7 +19,7 @@ config DVB_B2C2_USB
select DVB_MT352 select DVB_MT352
help help
Support for the Air/Sky/Cable2PC USB DVB device by B2C2. Currently Support for the Air/Sky/Cable2PC USB DVB device by B2C2. Currently
this does nothing, but providing basic function for the used usb the does nothing, but providing basic function for the used usb
protocol. protocol.
Say Y if you own such a device and want to use it. Say Y if you own such a device and want to use it.
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
} }
static int debug; static int debug;
module_param(debug, int, 0x644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,ctrl=4 (or-able))."); MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,ctrl=4 (or-able)).");
#define deb_info(args...) dprintk(0x01,args) #define deb_info(args...) dprintk(0x01,args)
...@@ -89,8 +89,18 @@ struct usb_b2c2_usb { ...@@ -89,8 +89,18 @@ struct usb_b2c2_usb {
/* request types */ /* request types */
typedef enum { typedef enum {
/* something is wrong with this part
RTYPE_READ_DW = (1 << 6), RTYPE_READ_DW = (1 << 6),
RTYPE_WRITE_DW_1 = (3 << 6), RTYPE_WRITE_DW_1 = (3 << 6),
RTYPE_READ_V8_MEMORY = (6 << 6),
RTYPE_WRITE_V8_MEMORY = (7 << 6),
RTYPE_WRITE_V8_FLASH = (8 << 6),
RTYPE_GENERIC = (9 << 6),
*/
RTYPE_READ_DW = (3 << 6),
RTYPE_WRITE_DW_1 = (1 << 6),
RTYPE_READ_V8_MEMORY = (6 << 6), RTYPE_READ_V8_MEMORY = (6 << 6),
RTYPE_WRITE_V8_MEMORY = (7 << 6), RTYPE_WRITE_V8_MEMORY = (7 << 6),
RTYPE_WRITE_V8_FLASH = (8 << 6), RTYPE_WRITE_V8_FLASH = (8 << 6),
...@@ -391,9 +401,9 @@ static int b2c2_init_usb(struct usb_b2c2_usb *b2c2) ...@@ -391,9 +401,9 @@ static int b2c2_init_usb(struct usb_b2c2_usb *b2c2)
} }
/* initialising and submitting iso urbs */ /* initialising and submitting iso urbs */
for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) { for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
deb_info("initializing and submitting urb no. %d (buf_offset: %d).\n",i,buffer_offset);
int frame_offset = 0; int frame_offset = 0;
struct urb *urb = b2c2->iso_urb[i]; struct urb *urb = b2c2->iso_urb[i];
deb_info("initializing and submitting urb no. %d (buf_offset: %d).\n",i,buffer_offset);
urb->dev = b2c2->udev; urb->dev = b2c2->udev;
urb->context = b2c2; urb->context = b2c2;
......
This diff is collapsed.
...@@ -3,6 +3,8 @@ config DVB_BT8XX ...@@ -3,6 +3,8 @@ config DVB_BT8XX
depends on DVB_CORE && PCI && VIDEO_BT848 depends on DVB_CORE && PCI && VIDEO_BT848
select DVB_MT352 select DVB_MT352
select DVB_SP887X select DVB_SP887X
select DVB_NXT6000
select DVB_CX24110
help help
Support for PCI cards based on the Bt8xx PCI bridge. Examples are Support for PCI cards based on the Bt8xx PCI bridge. Examples are
the Nebula cards, the Pinnacle PCTV cards and Twinhan DST cards. the Nebula cards, the Pinnacle PCTV cards and Twinhan DST cards.
...@@ -11,8 +13,5 @@ config DVB_BT8XX ...@@ -11,8 +13,5 @@ config DVB_BT8XX
only compressed MPEG data over the PCI bus, so you need only compressed MPEG data over the PCI bus, so you need
an external software decoder to watch TV on your computer. an external software decoder to watch TV on your computer.
If you have a Twinhan card, don't forget to select
"Twinhan DST based DVB-S/-T frontend".
Say Y if you own such a device and want to use it. Say Y if you own such a device and want to use it.
...@@ -181,6 +181,70 @@ static struct mt352_config thomson_dtt7579_config = { ...@@ -181,6 +181,70 @@ static struct mt352_config thomson_dtt7579_config = {
.pll_set = thomson_dtt7579_pll_set, .pll_set = thomson_dtt7579_pll_set,
}; };
static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
{
u32 freq = params->frequency;
int i, a, n, pump;
u32 band, pll;
u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
1576000,1718000,1856000,2036000,2150000};
u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
0x00102000,0x00104000,0x00108000,0x00110000,
0x00120000,0x00140000};
#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq);
/* This is really the bit driving the tuner chip cx24108 */
if(freq<950000) freq=950000; /* kHz */
if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */
/* decide which VCO to use for the input frequency */
for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++);
printk("cx24108 debug: select vco #%d (f=%d)\n",i,freq);
band=bandsel[i];
/* the gain values must be set by SetSymbolrate */
/* compute the pll divider needed, from Conexant data sheet,
resolved for (n*32+a), remember f(vco) is f(receive) *2 or *4,
depending on the divider bit. It is set to /4 on the 2 lowest
bands */
n=((i<=2?2:1)*freq*10L)/(XTAL/100);
a=n%32; n/=32; if(a==0) n--;
pump=(freq<(osci[i-1]+osci[i])/2);
pll=0xf8000000|
((pump?1:2)<<(14+11))|
((n&0x1ff)<<(5+11))|
((a&0x1f)<<11);
/* everything is shifted left 11 bits to left-align the bits in the
32bit word. Output to the tuner goes MSB-aligned, after all */
printk("cx24108 debug: pump=%d, n=%d, a=%d\n",pump,n,a);
cx24110_pll_write(fe,band);
/* set vga and vca to their widest-band settings, as a precaution.
SetSymbolrate might not be called to set this up */
cx24110_pll_write(fe,0x500c0000);
cx24110_pll_write(fe,0x83f1f800);
cx24110_pll_write(fe,pll);
/* writereg(client,0x56,0x7f);*/
return 0;
}
static int pinnsat_pll_init(struct dvb_frontend* fe)
{
return 0;
}
static struct cx24110_config pctvsat_config = {
.demod_address = 0x55,
.pll_init = pinnsat_pll_init,
.pll_set = cx24108_pll_set,
};
static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
...@@ -220,7 +284,7 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s ...@@ -220,7 +284,7 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s
return request_firmware(fw, name, &bt->bt->dev->dev); return request_firmware(fw, name, &bt->bt->dev->dev);
} }
struct sp887x_config microtune_mt7202dtf_config = { static struct sp887x_config microtune_mt7202dtf_config = {
.demod_address = 0x70, .demod_address = 0x70,
.pll_set = microtune_mt7202dtf_pll_set, .pll_set = microtune_mt7202dtf_pll_set,
...@@ -387,6 +451,13 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) ...@@ -387,6 +451,13 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
break; break;
} }
break; break;
case BTTV_PINNACLESAT:
card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
if (card->fe != NULL) {
break;
}
break;
} }
if (card->fe == NULL) { if (card->fe == NULL) {
...@@ -510,7 +581,14 @@ static int dvb_bt8xx_probe(struct device *dev) ...@@ -510,7 +581,14 @@ static int dvb_bt8xx_probe(struct device *dev)
switch(sub->core->type) switch(sub->core->type)
{ {
/* case BTTV_PINNACLESAT: UNDEFINED HARDWARE */ case BTTV_PINNACLESAT:
card->gpio_mode = 0x0400c060;
/* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
card->op_sync_orin = 0;
card->irq_err_ignore = 0;
break;
#ifdef BTTV_DVICO_DVBT_LITE #ifdef BTTV_DVICO_DVBT_LITE
case BTTV_DVICO_DVBT_LITE: case BTTV_DVICO_DVBT_LITE:
#endif #endif
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
* *
*/ */
#ifndef DVB_BT8XX_H
#define DVB_BT8XX_H
#include <linux/i2c.h> #include <linux/i2c.h>
#include "dvbdev.h" #include "dvbdev.h"
#include "dvb_net.h" #include "dvb_net.h"
...@@ -30,6 +33,7 @@ ...@@ -30,6 +33,7 @@
#include "sp887x.h" #include "sp887x.h"
#include "dst.h" #include "dst.h"
#include "nxt6000.h" #include "nxt6000.h"
#include "cx24110.h"
struct dvb_bt8xx_card { struct dvb_bt8xx_card {
struct semaphore lock; struct semaphore lock;
...@@ -50,3 +54,5 @@ struct dvb_bt8xx_card { ...@@ -50,3 +54,5 @@ struct dvb_bt8xx_card {
struct dvb_frontend* fe; struct dvb_frontend* fe;
}; };
#endif /* DVB_BT8XX_H */
config DVB_DIBUSB config DVB_DIBUSB
tristate "DiBcom USB DVB-T devices (see help for device list)" tristate "DiBcom USB DVB-T devices (see help for a complete device list)"
depends on DVB_CORE && USB depends on DVB_CORE && USB
select FW_LOADER select FW_LOADER
select DVB_DIB3000MB select DVB_DIB3000MB
select DVB_DIB3000MC select DVB_DIB3000MC
select DVB_MT352
help help
Support for USB 1.1 and 2.0 DVB-T devices based on reference designs made by Support for USB 1.1 and 2.0 DVB-T devices based on reference designs made by
DiBcom (<http://www.dibcom.fr>). DiBcom (http://www.dibcom.fr) and C&E.
Devices supported by this driver: Devices supported by this driver:
...@@ -14,12 +15,14 @@ config DVB_DIBUSB ...@@ -14,12 +15,14 @@ config DVB_DIBUSB
TwinhanDTV Magic Box (VP7041e) TwinhanDTV Magic Box (VP7041e)
KWorld V-Stream XPERT DTV - DVB-T USB KWorld V-Stream XPERT DTV - DVB-T USB
Hama DVB-T USB-Box Hama DVB-T USB-Box
DiBcom reference device (non-public) DiBcom reference devices (non-public)
Ultima Electronic/Artec T1 USB TVBOX Ultima Electronic/Artec T1 USB TVBOX
Compro Videomate DVB-U2000 - DVB-T USB Compro Videomate DVB-U2000 - DVB-T USB
Grandtec DVB-T USB Grandtec DVB-T USB
Avermedia AverTV DVBT USB Avermedia AverTV DVBT USB
Yakumo DVB-T mobile USB2.0 Artec T1 USB1.1 and USB2.0 boxes
Yakumo/Typhoon DVB-T USB2.0
Hanftek UMT-010 USB2.0
The VP7041 seems to be identical to "CTS Portable" (Chinese The VP7041 seems to be identical to "CTS Portable" (Chinese
Television System). Television System).
...@@ -27,7 +30,7 @@ config DVB_DIBUSB ...@@ -27,7 +30,7 @@ config DVB_DIBUSB
These devices can be understood as budget ones, they "only" deliver These devices can be understood as budget ones, they "only" deliver
(a part of) the MPEG2 transport stream. (a part of) the MPEG2 transport stream.
A firmware is needed to get the device working. See <file:Documentation/dvb/README.dibusb> A firmware is needed to get the device working. See Documentation/dvb/README.dibusb
details. details.
Say Y if you own such a device and want to use it. You should build it as Say Y if you own such a device and want to use it. You should build it as
...@@ -46,6 +49,7 @@ config DVB_DIBUSB_MISDESIGNED_DEVICES ...@@ -46,6 +49,7 @@ config DVB_DIBUSB_MISDESIGNED_DEVICES
0x0574:0x2235 (Artec T1 USB1.1, cold) 0x0574:0x2235 (Artec T1 USB1.1, cold)
0x04b4:0x8613 (Artec T1 USB2.0, cold) 0x04b4:0x8613 (Artec T1 USB2.0, cold)
0x0574:0x1002 (Artec T1 USB2.0, warm) 0x0574:0x1002 (Artec T1 USB2.0, warm)
0x0574:0x2131 (aged DiBcom USB1.1 test device)
Say Y if your device has one of the mentioned IDs. Say Y if your device has one of the mentioned IDs.
......
dvb-dibusb-objs = dvb-dibusb-core.o \
dvb-dibusb-dvb.o \
dvb-dibusb-fe-i2c.o \
dvb-dibusb-firmware.o \
dvb-dibusb-remote.o \
dvb-dibusb-usb.o \
dvb-dibusb-pid.o
obj-$(CONFIG_DVB_DIBUSB) += dvb-dibusb.o obj-$(CONFIG_DVB_DIBUSB) += dvb-dibusb.o
EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
This diff is collapsed.
/*
* dvb-dibusb-dvb.c is part of the driver for mobile USB Budget DVB-T devices
* based on reference design made by DiBcom (http://www.dibcom.fr/)
*
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
*
* see dvb-dibusb-core.c for more copyright details.
*
* This file contains functions for initializing and handling the
* linux-dvb API.
*/
#include "dvb-dibusb.h"
#include <linux/usb.h>
#include <linux/version.h>
static u32 urb_compl_count;
/*
* MPEG2 TS DVB stuff
*/
void dibusb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
{
struct usb_dibusb *dib = urb->context;
int ret;
deb_ts("urb complete feedcount: %d, status: %d, length: %d\n",dib->feedcount,urb->status,
urb->actual_length);
urb_compl_count++;
if (urb_compl_count % 500 == 0)
deb_info("%d urbs completed so far.\n",urb_compl_count);
switch (urb->status) {
case 0: /* success */
case -ETIMEDOUT: /* NAK */
break;
case -ECONNRESET: /* unlink */
case -ENOENT:
case -ESHUTDOWN:
return;
default: /* error */
warn("urb completition error %d.", urb->status);
}
if (dib->feedcount > 0) {
deb_ts("URB return len: %d\n",urb->actual_length);
if (urb->actual_length % 188)
deb_ts("TS Packets: %d, %d\n", urb->actual_length/188,urb->actual_length % 188);
/* Francois recommends to drop not full-filled packets, even if they may
* contain valid TS packets, at least for USB1.1
*
* if (urb->actual_length == dib->dibdev->parm->default_size && dib->dvb_is_ready) */
if (dib->init_state & DIBUSB_STATE_DVB)
dvb_dmx_swfilter(&dib->demux, (u8*) urb->transfer_buffer,urb->actual_length);
else
deb_ts("URB dropped because of the "
"actual_length or !dvb_is_ready (%d).\n",dib->init_state & DIBUSB_STATE_DVB);
} else
deb_ts("URB dropped because of feedcount.\n");
ret = usb_submit_urb(urb,GFP_ATOMIC);
deb_ts("urb resubmitted, (%d)\n",ret);
}
static int dibusb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
{
struct usb_dibusb *dib = dvbdmxfeed->demux->priv;
int newfeedcount;
if (dib == NULL)
return -ENODEV;
newfeedcount = dib->feedcount + (onoff ? 1 : -1);
/*
* stop feed before setting a new pid if there will be no pid anymore
*/
// if ((dib->dibdev->parm->firmware_bug && dib->feedcount) ||
if (newfeedcount == 0) {
deb_ts("stop feeding\n");
if (dib->xfer_ops.fifo_ctrl != NULL) {
if (dib->xfer_ops.fifo_ctrl(dib->fe,0)) {
err("error while inhibiting fifo.");
return -ENODEV;
}
}
}
dib->feedcount = newfeedcount;
/* get a free pid from the list and activate it on the device
* specific pid_filter
*/
if (dib->pid_parse)
dibusb_ctrl_pid(dib,dvbdmxfeed,onoff);
/*
* start the feed, either if there is the firmware bug or
* if this was the first pid to set and there is still a pid for
* reception.
*/
// if ((dib->dibdev->parm->firmware_bug)
if (dib->feedcount == onoff && dib->feedcount > 0) {
deb_ts("controlling pid parser\n");
if (dib->xfer_ops.pid_parse != NULL) {
if (dib->xfer_ops.pid_parse(dib->fe,dib->pid_parse) < 0) {
err("could not handle pid_parser");
}
}
deb_ts("start feeding\n");
if (dib->xfer_ops.fifo_ctrl != NULL) {
if (dib->xfer_ops.fifo_ctrl(dib->fe,1)) {
err("error while enabling fifo.");
return -ENODEV;
}
}
dibusb_streaming(dib,1);
}
return 0;
}
static int dibusb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
{
deb_ts("start pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid,dvbdmxfeed->type);
return dibusb_ctrl_feed(dvbdmxfeed,1);
}
static int dibusb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
{
deb_ts("stop pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid, dvbdmxfeed->type);
return dibusb_ctrl_feed(dvbdmxfeed,0);
}
int dibusb_dvb_init(struct usb_dibusb *dib)
{
int ret;
urb_compl_count = 0;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,4)
if ((ret = dvb_register_adapter(&dib->adapter, DRIVER_DESC)) < 0) {
#else
if ((ret = dvb_register_adapter(&dib->adapter, DRIVER_DESC ,
THIS_MODULE)) < 0) {
#endif
deb_info("dvb_register_adapter failed: error %d", ret);
goto err;
}
dib->adapter->priv = dib;
/* i2c is done in dibusb_i2c_init */
dib->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
dib->demux.priv = (void *)dib;
/* get pidcount from demod */
dib->demux.feednum = dib->demux.filternum = 255;
dib->demux.start_feed = dibusb_start_feed;
dib->demux.stop_feed = dibusb_stop_feed;
dib->demux.write_to_decoder = NULL;
if ((ret = dvb_dmx_init(&dib->demux)) < 0) {
err("dvb_dmx_init failed: error %d",ret);
goto err_dmx;
}
dib->dmxdev.filternum = dib->demux.filternum;
dib->dmxdev.demux = &dib->demux.dmx;
dib->dmxdev.capabilities = 0;
if ((ret = dvb_dmxdev_init(&dib->dmxdev, dib->adapter)) < 0) {
err("dvb_dmxdev_init failed: error %d",ret);
goto err_dmx_dev;
}
dvb_net_init(dib->adapter, &dib->dvb_net, &dib->demux.dmx);
goto success;
err_dmx_dev:
dvb_dmx_release(&dib->demux);
err_dmx:
dvb_unregister_adapter(dib->adapter);
err:
return ret;
success:
dib->init_state |= DIBUSB_STATE_DVB;
return 0;
}
int dibusb_dvb_exit(struct usb_dibusb *dib)
{
if (dib->init_state & DIBUSB_STATE_DVB) {
dib->init_state &= ~DIBUSB_STATE_DVB;
deb_info("unregistering DVB part\n");
dvb_net_release(&dib->dvb_net);
dib->demux.dmx.close(&dib->demux.dmx);
dvb_dmxdev_release(&dib->dmxdev);
dvb_dmx_release(&dib->demux);
dvb_unregister_adapter(dib->adapter);
}
return 0;
}
This diff is collapsed.
/*
* dvb-dibusb-firmware.c is part of the driver for mobile USB Budget DVB-T devices
* based on reference design made by DiBcom (http://www.dibcom.fr/)
*
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
*
* see dvb-dibusb-core.c for more copyright details.
*
* This file contains functions for downloading the firmware to the device.
*/
#include "dvb-dibusb.h"
#include <linux/firmware.h>
#include <linux/usb.h>
/*
* load a firmware packet to the device
*/
static int dibusb_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len)
{
return usb_control_msg(udev, usb_sndctrlpipe(udev,0),
0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5*HZ);
}
int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_usb_device *dibdev)
{
const struct firmware *fw = NULL;
u16 addr;
u8 *b,*p;
int ret = 0,i;
if ((ret = request_firmware(&fw, dibdev->dev_cl->firmware, &udev->dev)) != 0) {
err("did not find a valid firmware file. (%s) "
"Please see linux/Documentation/dvb/ for more details on firmware-problems.",
dibdev->dev_cl->firmware);
return ret;
}
p = kmalloc(fw->size,GFP_KERNEL);
if (p != NULL) {
u8 reset;
/*
* you cannot use the fw->data as buffer for
* usb_control_msg, a new buffer has to be
* created
*/
memcpy(p,fw->data,fw->size);
/* stop the CPU */
reset = 1;
if ((ret = dibusb_writemem(udev,dibdev->dev_cl->usb_ctrl->cpu_cs_register,&reset,1)) != 1)
err("could not stop the USB controller CPU.");
for(i = 0; p[i+3] == 0 && i < fw->size; ) {
b = (u8 *) &p[i];
addr = *((u16 *) &b[1]);
ret = dibusb_writemem(udev,addr,&b[4],b[0]);
if (ret != b[0]) {
err("error while transferring firmware "
"(transferred size: %d, block size: %d)",
ret,b[0]);
ret = -EINVAL;
break;
}
i += 5 + b[0];
}
/* length in ret */
if (ret > 0)
ret = 0;
/* restart the CPU */
reset = 0;
if (ret || dibusb_writemem(udev,dibdev->dev_cl->usb_ctrl->cpu_cs_register,&reset,1) != 1) {
err("could not restart the USB controller CPU.");
ret = -EINVAL;
}
kfree(p);
} else {
ret = -ENOMEM;
}
release_firmware(fw);
return ret;
}
/*
* dvb-dibusb-pid.c is part of the driver for mobile USB Budget DVB-T devices
* based on reference design made by DiBcom (http://www.dibcom.fr/)
*
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
*
* see dvb-dibusb-core.c for more copyright details.
*
* This file contains functions for initializing and handling the internal
* pid-list. This pid-list mirrors the information currently stored in the
* devices pid-list.
*/
#include "dvb-dibusb.h"
int dibusb_pid_list_init(struct usb_dibusb *dib)
{
int i;
dib->pid_list = kmalloc(sizeof(struct dibusb_pid) * dib->dibdev->dev_cl->demod->pid_filter_count,GFP_KERNEL);
if (dib->pid_list == NULL)
return -ENOMEM;
deb_xfer("initializing %d pids for the pid_list.\n",dib->dibdev->dev_cl->demod->pid_filter_count);
dib->pid_list_lock = SPIN_LOCK_UNLOCKED;
memset(dib->pid_list,0,dib->dibdev->dev_cl->demod->pid_filter_count*(sizeof(struct dibusb_pid)));
for (i=0; i < dib->dibdev->dev_cl->demod->pid_filter_count; i++) {
dib->pid_list[i].index = i;
dib->pid_list[i].pid = 0;
dib->pid_list[i].active = 0;
}
dib->init_state |= DIBUSB_STATE_PIDLIST;
return 0;
}
void dibusb_pid_list_exit(struct usb_dibusb *dib)
{
if (dib->init_state & DIBUSB_STATE_PIDLIST)
kfree(dib->pid_list);
dib->init_state &= ~DIBUSB_STATE_PIDLIST;
}
/* fetch a pid from pid_list and set it on or off */
int dibusb_ctrl_pid(struct usb_dibusb *dib, struct dvb_demux_feed *dvbdmxfeed , int onoff)
{
int i,ret = -1;
unsigned long flags;
u16 pid = dvbdmxfeed->pid;
if (onoff) {
spin_lock_irqsave(&dib->pid_list_lock,flags);
for (i=0; i < dib->dibdev->dev_cl->demod->pid_filter_count; i++)
if (!dib->pid_list[i].active) {
dib->pid_list[i].pid = pid;
dib->pid_list[i].active = 1;
ret = i;
break;
}
dvbdmxfeed->priv = &dib->pid_list[ret];
spin_unlock_irqrestore(&dib->pid_list_lock,flags);
if (dib->xfer_ops.pid_ctrl != NULL)
dib->xfer_ops.pid_ctrl(dib->fe,dib->pid_list[ret].index,dib->pid_list[ret].pid,1);
} else {
struct dibusb_pid *dpid = dvbdmxfeed->priv;
if (dib->xfer_ops.pid_ctrl != NULL)
dib->xfer_ops.pid_ctrl(dib->fe,dpid->index,0,0);
dpid->pid = 0;
dpid->active = 0;
ret = dpid->index;
}
/* a free pid from the list */
deb_info("setting pid: %5d %04x at index %d '%s'\n",pid,pid,ret,onoff ? "on" : "off");
return ret;
}
/*
* dvb-dibusb-remote.c is part of the driver for mobile USB Budget DVB-T devices
* based on reference design made by DiBcom (http://www.dibcom.fr/)
*
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
*
* see dvb-dibusb-core.c for more copyright details.
*
* This file contains functions for handling the event device on the software
* side and the remote control on the hardware side.
*/
#include "dvb-dibusb.h"
/* Table to map raw key codes to key events. This should not be hard-wired
into the kernel. */
static const struct { u8 c0, c1, c2; uint32_t key; } rc_keys [] =
{
/* Key codes for the little Artec T1/Twinhan/HAMA/ remote. */
{ 0x00, 0xff, 0x16, KEY_POWER },
{ 0x00, 0xff, 0x10, KEY_MUTE },
{ 0x00, 0xff, 0x03, KEY_1 },
{ 0x00, 0xff, 0x01, KEY_2 },
{ 0x00, 0xff, 0x06, KEY_3 },
{ 0x00, 0xff, 0x09, KEY_4 },
{ 0x00, 0xff, 0x1d, KEY_5 },
{ 0x00, 0xff, 0x1f, KEY_6 },
{ 0x00, 0xff, 0x0d, KEY_7 },
{ 0x00, 0xff, 0x19, KEY_8 },
{ 0x00, 0xff, 0x1b, KEY_9 },
{ 0x00, 0xff, 0x15, KEY_0 },
{ 0x00, 0xff, 0x05, KEY_CHANNELUP },
{ 0x00, 0xff, 0x02, KEY_CHANNELDOWN },
{ 0x00, 0xff, 0x1e, KEY_VOLUMEUP },
{ 0x00, 0xff, 0x0a, KEY_VOLUMEDOWN },
{ 0x00, 0xff, 0x11, KEY_RECORD },
{ 0x00, 0xff, 0x17, KEY_FAVORITES }, /* Heart symbol - Channel list. */
{ 0x00, 0xff, 0x14, KEY_PLAY },
{ 0x00, 0xff, 0x1a, KEY_STOP },
{ 0x00, 0xff, 0x40, KEY_REWIND },
{ 0x00, 0xff, 0x12, KEY_FASTFORWARD },
{ 0x00, 0xff, 0x0e, KEY_PREVIOUS }, /* Recall - Previous channel. */
{ 0x00, 0xff, 0x4c, KEY_PAUSE },
{ 0x00, 0xff, 0x4d, KEY_SCREEN }, /* Full screen mode. */
{ 0x00, 0xff, 0x54, KEY_AUDIO }, /* MTS - Switch to secondary audio. */
/* additional keys TwinHan VisionPlus, the Artec seemingly not have */
{ 0x00, 0xff, 0x0c, KEY_CANCEL }, /* Cancel */
{ 0x00, 0xff, 0x1c, KEY_EPG }, /* EPG */
{ 0x00, 0xff, 0x00, KEY_TAB }, /* Tab */
{ 0x00, 0xff, 0x48, KEY_INFO }, /* Preview */
{ 0x00, 0xff, 0x04, KEY_LIST }, /* RecordList */
{ 0x00, 0xff, 0x0f, KEY_TEXT }, /* Teletext */
/* Key codes for the KWorld/ADSTech/JetWay remote. */
{ 0x86, 0x6b, 0x12, KEY_POWER },
{ 0x86, 0x6b, 0x0f, KEY_SELECT }, /* source */
{ 0x86, 0x6b, 0x0c, KEY_UNKNOWN }, /* scan */
{ 0x86, 0x6b, 0x0b, KEY_EPG },
{ 0x86, 0x6b, 0x10, KEY_MUTE },
{ 0x86, 0x6b, 0x01, KEY_1 },
{ 0x86, 0x6b, 0x02, KEY_2 },
{ 0x86, 0x6b, 0x03, KEY_3 },
{ 0x86, 0x6b, 0x04, KEY_4 },
{ 0x86, 0x6b, 0x05, KEY_5 },
{ 0x86, 0x6b, 0x06, KEY_6 },
{ 0x86, 0x6b, 0x07, KEY_7 },
{ 0x86, 0x6b, 0x08, KEY_8 },
{ 0x86, 0x6b, 0x09, KEY_9 },
{ 0x86, 0x6b, 0x0a, KEY_0 },
{ 0x86, 0x6b, 0x18, KEY_ZOOM },
{ 0x86, 0x6b, 0x1c, KEY_UNKNOWN }, /* preview */
{ 0x86, 0x6b, 0x13, KEY_UNKNOWN }, /* snap */
{ 0x86, 0x6b, 0x00, KEY_UNDO },
{ 0x86, 0x6b, 0x1d, KEY_RECORD },
{ 0x86, 0x6b, 0x0d, KEY_STOP },
{ 0x86, 0x6b, 0x0e, KEY_PAUSE },
{ 0x86, 0x6b, 0x16, KEY_PLAY },
{ 0x86, 0x6b, 0x11, KEY_BACK },
{ 0x86, 0x6b, 0x19, KEY_FORWARD },
{ 0x86, 0x6b, 0x14, KEY_UNKNOWN }, /* pip */
{ 0x86, 0x6b, 0x15, KEY_ESC },
{ 0x86, 0x6b, 0x1a, KEY_UP },
{ 0x86, 0x6b, 0x1e, KEY_DOWN },
{ 0x86, 0x6b, 0x1f, KEY_LEFT },
{ 0x86, 0x6b, 0x1b, KEY_RIGHT },
};
/*
* Read the remote control and feed the appropriate event.
* NEC protocol is used for remote controls
*/
static int dibusb_read_remote_control(struct usb_dibusb *dib)
{
u8 b[1] = { DIBUSB_REQ_POLL_REMOTE }, rb[5];
int ret;
int i;
if ((ret = dibusb_readwrite_usb(dib,b,1,rb,5)))
return ret;
switch (rb[0]) {
case DIBUSB_RC_NEC_KEY_PRESSED:
/* rb[1-3] is the actual key, rb[4] is a checksum */
deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
rb[1], rb[2], rb[3], rb[4]);
if ((0xff - rb[3]) != rb[4]) {
deb_rc("remote control checksum failed.\n");
break;
}
/* See if we can match the raw key code. */
for (i = 0; i < sizeof(rc_keys)/sizeof(rc_keys[0]); i++) {
if (rc_keys[i].c0 == rb[1] &&
rc_keys[i].c1 == rb[2] &&
rc_keys[i].c2 == rb[3]) {
dib->rc_input_event = rc_keys[i].key;
deb_rc("Translated key 0x%04x\n", dib->rc_input_event);
/* Signal down and up events for this key. */
input_report_key(&dib->rc_input_dev, dib->rc_input_event, 1);
input_report_key(&dib->rc_input_dev, dib->rc_input_event, 0);
input_sync(&dib->rc_input_dev);
break;
}
}
break;
case DIBUSB_RC_NEC_EMPTY: /* No (more) remote control keys. */
break;
case DIBUSB_RC_NEC_KEY_REPEATED:
/* rb[1]..rb[4] are always zero.*/
/* Repeats often seem to occur so for the moment just ignore this. */
deb_rc("Key repeat\n");
break;
default:
break;
}
return 0;
}
/* Remote-control poll function - called every dib->rc_query_interval ms to see
whether the remote control has received anything. */
static void dibusb_remote_query(void *data)
{
struct usb_dibusb *dib = (struct usb_dibusb *) data;
/* TODO: need a lock here. We can simply skip checking for the remote control
if we're busy. */
dibusb_read_remote_control(dib);
schedule_delayed_work(&dib->rc_query_work,
msecs_to_jiffies(rc_query_interval));
}
int dibusb_remote_init(struct usb_dibusb *dib)
{
int i;
if (dib->dibdev->dev_cl->remote_type == DIBUSB_RC_NO)
return 0;
/* Initialise the remote-control structures.*/
init_input_dev(&dib->rc_input_dev);
dib->rc_input_dev.evbit[0] = BIT(EV_KEY);
dib->rc_input_dev.keycodesize = sizeof(unsigned char);
dib->rc_input_dev.keycodemax = KEY_MAX;
dib->rc_input_dev.name = DRIVER_DESC " remote control";
for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i++)
set_bit(rc_keys[i].key, dib->rc_input_dev.keybit);
input_register_device(&dib->rc_input_dev);
dib->rc_input_event = KEY_MAX;
INIT_WORK(&dib->rc_query_work, dibusb_remote_query, dib);
/* Start the remote-control polling. */
if (rc_query_interval < 40)
rc_query_interval = 100; /* default */
info("schedule remote query interval to %d msecs.",rc_query_interval);
schedule_delayed_work(&dib->rc_query_work,msecs_to_jiffies(rc_query_interval));
dib->init_state |= DIBUSB_STATE_REMOTE;
return 0;
}
int dibusb_remote_exit(struct usb_dibusb *dib)
{
if (dib->dibdev->dev_cl->remote_type == DIBUSB_RC_NO)
return 0;
if (dib->init_state & DIBUSB_STATE_REMOTE) {
cancel_delayed_work(&dib->rc_query_work);
flush_scheduled_work();
input_unregister_device(&dib->rc_input_dev);
}
dib->init_state &= ~DIBUSB_STATE_REMOTE;
return 0;
}
/*
* dvb-dibusb-usb.c is part of the driver for mobile USB Budget DVB-T devices
* based on reference design made by DiBcom (http://www.dibcom.fr/)
*
* Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
*
* see dvb-dibusb-core.c for more copyright details.
*
* This file contains functions for initializing and handling the
* usb specific stuff.
*/
#include "dvb-dibusb.h"
#include <linux/version.h>
#include <linux/pci.h>
int dibusb_readwrite_usb(struct usb_dibusb *dib, u8 *wbuf, u16 wlen, u8 *rbuf,
u16 rlen)
{
int actlen,ret = -ENOMEM;
if (wbuf == NULL || wlen == 0)
return -EINVAL;
if ((ret = down_interruptible(&dib->usb_sem)))
return ret;
if (dib->feedcount &&
wbuf[0] == DIBUSB_REQ_I2C_WRITE &&
dib->dibdev->dev_cl->id == DIBUSB1_1)
deb_err("BUG: writing to i2c, while TS-streaming destroys the stream."
"(%x reg: %x %x)\n", wbuf[0],wbuf[2],wbuf[3]);
debug_dump(wbuf,wlen);
ret = usb_bulk_msg(dib->udev,usb_sndbulkpipe(dib->udev,
dib->dibdev->dev_cl->pipe_cmd), wbuf,wlen,&actlen,
DIBUSB_I2C_TIMEOUT);
if (ret)
err("bulk message failed: %d (%d/%d)",ret,wlen,actlen);
else
ret = actlen != wlen ? -1 : 0;
/* an answer is expected, and no error before */
if (!ret && rbuf && rlen) {
ret = usb_bulk_msg(dib->udev,usb_rcvbulkpipe(dib->udev,
dib->dibdev->dev_cl->pipe_cmd),rbuf,rlen,&actlen,
DIBUSB_I2C_TIMEOUT);
if (ret)
err("recv bulk message failed: %d",ret);
else {
deb_alot("rlen: %d\n",rlen);
debug_dump(rbuf,actlen);
}
}
up(&dib->usb_sem);
return ret;
}
/*
* Cypress controls
*/
#if 0
/*
* #if 0'ing the following functions as they are not in use _now_,
* but probably will be sometime.
*/
/*
* do not use this, just a workaround for a bug,
* which will hopefully never occur :).
*/
int dibusb_interrupt_read_loop(struct usb_dibusb *dib)
{
u8 b[1] = { DIBUSB_REQ_INTR_READ };
return dibusb_write_usb(dib,b,1);
}
#endif
static int dibusb_write_usb(struct usb_dibusb *dib, u8 *buf, u16 len)
{
return dibusb_readwrite_usb(dib,buf,len,NULL,0);
}
/*
* ioctl for the firmware
*/
static int dibusb_ioctl_cmd(struct usb_dibusb *dib, u8 cmd, u8 *param, int plen)
{
u8 b[34];
int size = plen > 32 ? 32 : plen;
memset(b,0,34);
b[0] = DIBUSB_REQ_SET_IOCTL;
b[1] = cmd;
if (size > 0)
memcpy(&b[2],param,size);
return dibusb_write_usb(dib,b,34); //2+size);
}
/*
* ioctl for power control
*/
int dibusb_hw_wakeup(struct dvb_frontend *fe)
{
struct usb_dibusb *dib = (struct usb_dibusb *) fe->dvb->priv;
u8 b[1] = { DIBUSB_IOCTL_POWER_WAKEUP };
deb_info("dibusb-device is getting up.\n");
dibusb_ioctl_cmd(dib,DIBUSB_IOCTL_CMD_POWER_MODE, b,1);
if (dib->fe_init)
return dib->fe_init(fe);
return 0;
}
int dibusb_hw_sleep(struct dvb_frontend *fe)
{
struct usb_dibusb *dib = (struct usb_dibusb *) fe->dvb->priv;
u8 b[1] = { DIBUSB_IOCTL_POWER_SLEEP };
deb_info("dibusb-device is going to bed.\n");
dibusb_ioctl_cmd(dib,DIBUSB_IOCTL_CMD_POWER_MODE, b,1);
if (dib->fe_sleep)
return dib->fe_sleep(fe);
return 0;
}
int dibusb_set_streaming_mode(struct usb_dibusb *dib,u8 mode)
{
u8 b[2] = { DIBUSB_REQ_SET_STREAMING_MODE, mode };
return dibusb_readwrite_usb(dib,b,2,NULL,0);
}
int dibusb_streaming(struct usb_dibusb *dib,int onoff)
{
switch (dib->dibdev->dev_cl->id) {
case DIBUSB2_0:
if (onoff)
return dibusb_ioctl_cmd(dib,DIBUSB_IOCTL_CMD_ENABLE_STREAM,NULL,0);
else
return dibusb_ioctl_cmd(dib,DIBUSB_IOCTL_CMD_DISABLE_STREAM,NULL,0);
break;
case UMT2_0:
return dibusb_set_streaming_mode(dib,onoff);
break;
default:
break;
}
return 0;
}
int dibusb_urb_init(struct usb_dibusb *dib)
{
int ret,i,bufsize;
/*
* when reloading the driver w/o replugging the device
* a timeout occures, this helps
*/
usb_clear_halt(dib->udev,usb_sndbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_cmd));
usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_cmd));
usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_data));
/* allocate the array for the data transfer URBs */
dib->urb_list = kmalloc(dib->dibdev->dev_cl->urb_count*sizeof(struct urb *),GFP_KERNEL);
if (dib->urb_list == NULL)
return -ENOMEM;
memset(dib->urb_list,0,dib->dibdev->dev_cl->urb_count*sizeof(struct urb *));
dib->init_state |= DIBUSB_STATE_URB_LIST;
bufsize = dib->dibdev->dev_cl->urb_count*dib->dibdev->dev_cl->urb_buffer_size;
deb_info("allocate %d bytes as buffersize for all URBs\n",bufsize);
/* allocate the actual buffer for the URBs */
if ((dib->buffer = pci_alloc_consistent(NULL,bufsize,&dib->dma_handle)) == NULL) {
deb_info("not enough memory.\n");
return -ENOMEM;
}
deb_info("allocation complete\n");
memset(dib->buffer,0,bufsize);
dib->init_state |= DIBUSB_STATE_URB_BUF;
/* allocate and submit the URBs */
for (i = 0; i < dib->dibdev->dev_cl->urb_count; i++) {
if (!(dib->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC))) {
return -ENOMEM;
}
deb_info("submitting URB no. %d\n",i);
usb_fill_bulk_urb( dib->urb_list[i], dib->udev,
usb_rcvbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_data),
&dib->buffer[i*dib->dibdev->dev_cl->urb_buffer_size],
dib->dibdev->dev_cl->urb_buffer_size,
dibusb_urb_complete, dib);
dib->urb_list[i]->transfer_flags = 0;
if ((ret = usb_submit_urb(dib->urb_list[i],GFP_ATOMIC))) {
err("could not submit buffer urb no. %d\n",i);
return ret;
}
dib->init_state |= DIBUSB_STATE_URB_SUBMIT;
}
dib->pid_parse = 1;
switch (dib->dibdev->dev_cl->id) {
case DIBUSB2_0:
if (dib->udev->speed == USB_SPEED_HIGH && !pid_parse) {
dib->pid_parse = 0;
info("running at HIGH speed, will deliver the complete TS.");
} else
info("will use pid_parsing.");
break;
default:
break;
}
return 0;
}
int dibusb_urb_exit(struct usb_dibusb *dib)
{
int i;
if (dib->init_state & DIBUSB_STATE_URB_LIST) {
for (i = 0; i < dib->dibdev->dev_cl->urb_count; i++) {
if (dib->urb_list[i] != NULL) {
deb_info("killing URB no. %d.\n",i);
/* stop the URBs */
usb_kill_urb(dib->urb_list[i]);
deb_info("freeing URB no. %d.\n",i);
/* free the URBs */
usb_free_urb(dib->urb_list[i]);
}
}
/* free the urb array */
kfree(dib->urb_list);
dib->init_state &= ~DIBUSB_STATE_URB_SUBMIT;
dib->init_state &= ~DIBUSB_STATE_URB_LIST;
}
if (dib->init_state & DIBUSB_STATE_URB_BUF)
pci_free_consistent(NULL,
dib->dibdev->dev_cl->urb_buffer_size*dib->dibdev->dev_cl->urb_count,
dib->buffer,dib->dma_handle);
dib->init_state &= ~DIBUSB_STATE_URB_BUF;
return 0;
}
This diff is collapsed.
This diff is collapsed.
...@@ -247,7 +247,22 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) ...@@ -247,7 +247,22 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
} }
/* /*
** Losless Section Demux 1.4 by Emard ** Losless Section Demux 1.4.1 by Emard
** Valsecchi Patrick:
** - middle of section A (no PUSI)
** - end of section A and start of section B
** (with PUSI pointing to the start of the second section)
**
** In this case, without feed->pusi_seen you'll receive a garbage section
** consisting of the end of section A. Basically because tsfeedp
** is incemented and the use=0 condition is not raised
** when the second packet arrives.
**
** Fix:
** when demux is started, let feed->pusi_seen = 0 to
** prevent initial feeding of garbage from the end of
** previous section. When you for the first time see PUSI=1
** then set feed->pusi_seen = 1
*/ */
static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len) static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len)
{ {
...@@ -293,7 +308,12 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const ...@@ -293,7 +308,12 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const
sec->seclen = seclen; sec->seclen = seclen;
sec->crc_val = ~0; sec->crc_val = ~0;
/* dump [secbuf .. secbuf+seclen) */ /* dump [secbuf .. secbuf+seclen) */
if(feed->pusi_seen)
dvb_dmx_swfilter_section_feed(feed); dvb_dmx_swfilter_section_feed(feed);
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
else
printk("dvb_demux.c pusi not seen, discarding section data\n");
#endif
sec->secbufp += seclen; /* secbufp and secbuf moving together is */ sec->secbufp += seclen; /* secbufp and secbuf moving together is */
sec->secbuf += seclen; /* redundand but saves pointer arithmetic */ sec->secbuf += seclen; /* redundand but saves pointer arithmetic */
} }
...@@ -305,7 +325,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const ...@@ -305,7 +325,7 @@ static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const
static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf) static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
{ {
u8 p, count; u8 p, count;
int ccok; int ccok, dc_i = 0;
u8 cc; u8 cc;
count = payload(buf); count = payload(buf);
...@@ -316,31 +336,41 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 ...@@ -316,31 +336,41 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8
p = 188-count; /* payload start */ p = 188-count; /* payload start */
cc = buf[3] & 0x0f; cc = buf[3] & 0x0f;
ccok = ((feed->cc+1) & 0x0f) == cc ? 1 : 0; ccok = ((feed->cc + 1) & 0x0f) == cc;
feed->cc = cc; feed->cc = cc;
if(ccok == 0)
{ if (buf[3] & 0x20) {
/* adaption field present, check for discontinuity_indicator */
if ((buf[4] > 0) && (buf[5] & 0x80))
dc_i = 1;
}
if (!ccok || dc_i) {
#ifdef DVB_DEMUX_SECTION_LOSS_LOG #ifdef DVB_DEMUX_SECTION_LOSS_LOG
printk("dvb_demux.c discontinuity detected %d bytes lost\n", count); printk("dvb_demux.c discontinuity detected %d bytes lost\n", count);
/* those bytes under sume circumstances will again be reported /* those bytes under sume circumstances will again be reported
** in the following dvb_dmx_swfilter_section_new ** in the following dvb_dmx_swfilter_section_new
*/ */
#endif #endif
/* Discontinuity detected. Reset pusi_seen = 0 to
** stop feeding of suspicious data until next PUSI=1 arrives
*/
feed->pusi_seen = 0;
dvb_dmx_swfilter_section_new(feed); dvb_dmx_swfilter_section_new(feed);
return 0; return 0;
} }
if(buf[1] & 0x40) if (buf[1] & 0x40) {
{
// PUSI=1 (is set), section boundary is here // PUSI=1 (is set), section boundary is here
if(count > 1 && buf[p] < count) if (count > 1 && buf[p] < count) {
{
const u8 *before = buf+p+1; const u8 *before = buf+p+1;
u8 before_len = buf[p]; u8 before_len = buf[p];
const u8 *after = before+before_len; const u8 *after = before+before_len;
u8 after_len = count-1-before_len; u8 after_len = count-1-before_len;
dvb_dmx_swfilter_section_copy_dump(feed, before, before_len); dvb_dmx_swfilter_section_copy_dump(feed, before, before_len);
/* before start of new section, set pusi_seen = 1 */
feed->pusi_seen = 1;
dvb_dmx_swfilter_section_new(feed); dvb_dmx_swfilter_section_new(feed);
dvb_dmx_swfilter_section_copy_dump(feed, after, after_len); dvb_dmx_swfilter_section_copy_dump(feed, after, after_len);
} }
...@@ -349,9 +379,7 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 ...@@ -349,9 +379,7 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8
if(count > 0) if(count > 0)
printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count);
#endif #endif
} } else {
else
{
// PUSI=0 (is not set), no section boundary // PUSI=0 (is not set), no section boundary
const u8 *entire = buf+p; const u8 *entire = buf+p;
u8 entire_len = count; u8 entire_len = count;
...@@ -784,10 +812,8 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ ...@@ -784,10 +812,8 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_
} }
#ifndef NOBUFS #ifndef NOBUFS
if (feed->buffer) {
vfree(feed->buffer); vfree(feed->buffer);
feed->buffer=0; feed->buffer=0;
}
#endif #endif
feed->state = DMX_STATE_FREE; feed->state = DMX_STATE_FREE;
...@@ -1055,10 +1081,8 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, ...@@ -1055,10 +1081,8 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
return -EINVAL; return -EINVAL;
} }
#ifndef NOBUFS #ifndef NOBUFS
if (dvbdmxfeed->buffer) {
vfree(dvbdmxfeed->buffer); vfree(dvbdmxfeed->buffer);
dvbdmxfeed->buffer=0; dvbdmxfeed->buffer=0;
}
#endif #endif
dvbdmxfeed->state=DMX_STATE_FREE; dvbdmxfeed->state=DMX_STATE_FREE;
...@@ -1269,9 +1293,7 @@ int dvb_dmx_release(struct dvb_demux *dvbdemux) ...@@ -1269,9 +1293,7 @@ int dvb_dmx_release(struct dvb_demux *dvbdemux)
struct dmx_demux *dmx = &dvbdemux->dmx; struct dmx_demux *dmx = &dvbdemux->dmx;
dmx_unregister_demux(dmx); dmx_unregister_demux(dmx);
if (dvbdemux->filter)
vfree(dvbdemux->filter); vfree(dvbdemux->filter);
if (dvbdemux->feed)
vfree(dvbdemux->feed); vfree(dvbdemux->feed);
return 0; return 0;
} }
......
...@@ -93,6 +93,7 @@ struct dvb_demux_feed { ...@@ -93,6 +93,7 @@ struct dvb_demux_feed {
enum dmx_ts_pes pes_type; enum dmx_ts_pes pes_type;
int cc; int cc;
int pusi_seen; /* prevents feeding of garbage from previous section */
u16 peslen; u16 peslen;
......
This diff is collapsed.
...@@ -115,28 +115,7 @@ struct dvb_frontend { ...@@ -115,28 +115,7 @@ struct dvb_frontend {
struct dvb_frontend_ops* ops; struct dvb_frontend_ops* ops;
struct dvb_adapter *dvb; struct dvb_adapter *dvb;
void* demodulator_priv; void* demodulator_priv;
void* frontend_priv;
struct dvb_device *dvbdev;
struct dvb_frontend_parameters parameters;
struct dvb_fe_events events;
struct semaphore sem;
struct list_head list_head;
wait_queue_head_t wait_queue;
pid_t thread_pid;
unsigned long release_jiffies;
int state;
int bending;
int lnb_drift;
int inversion;
int auto_step;
int auto_sub_step;
int started_auto_step;
int min_delay;
int max_drift;
int step_size;
int exit;
int wakeup;
fe_status_t status;
}; };
extern int dvb_register_frontend(struct dvb_adapter* dvb, extern int dvb_register_frontend(struct dvb_adapter* dvb,
......
...@@ -123,7 +123,6 @@ static void hexdump( const unsigned char *buf, unsigned short len ) ...@@ -123,7 +123,6 @@ static void hexdump( const unsigned char *buf, unsigned short len )
struct dvb_net_priv { struct dvb_net_priv {
int in_use; int in_use;
struct net_device_stats stats; struct net_device_stats stats;
char name[6];
u16 pid; u16 pid;
struct dvb_net *host; struct dvb_net *host;
struct dmx_demux *demux; struct dmx_demux *demux;
...@@ -1165,12 +1164,17 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype) ...@@ -1165,12 +1164,17 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
if ((if_num = get_if(dvbnet)) < 0) if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL; return -EINVAL;
net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", dvb_net_setup);
dvb_net_setup);
if (!net) if (!net)
return -ENOMEM; return -ENOMEM;
sprintf(net->name, "dvb%d_%d", dvbnet->dvbdev->adapter->num, if_num); if (dvbnet->dvbdev->id)
snprintf(net->name, IFNAMSIZ, "dvb%d%u%d",
dvbnet->dvbdev->adapter->num, dvbnet->dvbdev->id, if_num);
else
/* compatibility fix to keep dvb0_0 format */
snprintf(net->name, IFNAMSIZ, "dvb%d_%d",
dvbnet->dvbdev->adapter->num, if_num);
net->addr_len = 6; net->addr_len = 6;
memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6); memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
...@@ -1196,6 +1200,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype) ...@@ -1196,6 +1200,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
free_netdev(net); free_netdev(net);
return result; return result;
} }
printk("dvb_net: created network interface %s\n", net->name);
return if_num; return if_num;
} }
...@@ -1214,6 +1219,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num) ...@@ -1214,6 +1219,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num)
dvb_net_stop(net); dvb_net_stop(net);
flush_scheduled_work(); flush_scheduled_work();
printk("dvb_net: removed network interface %s\n", net->name);
unregister_netdev(net); unregister_netdev(net);
dvbnet->state[num]=0; dvbnet->state[num]=0;
dvbnet->device[num] = NULL; dvbnet->device[num] = NULL;
......
...@@ -46,6 +46,7 @@ comment "DVB-T (terrestrial) frontends" ...@@ -46,6 +46,7 @@ comment "DVB-T (terrestrial) frontends"
config DVB_SP8870 config DVB_SP8870
tristate "Spase sp8870 based" tristate "Spase sp8870 based"
depends on DVB_CORE depends on DVB_CORE
select FW_LOADER
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
...@@ -56,6 +57,7 @@ config DVB_SP8870 ...@@ -56,6 +57,7 @@ config DVB_SP8870
config DVB_SP887X config DVB_SP887X
tristate "Spase sp887x based" tristate "Spase sp887x based"
depends on DVB_CORE depends on DVB_CORE
select FW_LOADER
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
...@@ -84,6 +86,7 @@ config DVB_L64781 ...@@ -84,6 +86,7 @@ config DVB_L64781
config DVB_TDA1004X config DVB_TDA1004X
tristate "Philips TDA10045H/TDA10046H based" tristate "Philips TDA10045H/TDA10046H based"
depends on DVB_CORE depends on DVB_CORE
select FW_LOADER
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
...@@ -145,4 +148,13 @@ config DVB_STV0297 ...@@ -145,4 +148,13 @@ config DVB_STV0297
help help
A DVB-C tuner module. Say Y when you want to support this frontend. A DVB-C tuner module. Say Y when you want to support this frontend.
comment "ATSC (North American/Korean Terresterial DTV) frontends"
depends on DVB_CORE
config DVB_NXT2002
tristate "Nxt2002 based"
depends on DVB_CORE
help
An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
endmenu endmenu
...@@ -24,3 +24,5 @@ obj-$(CONFIG_DVB_CX22702) += cx22702.o ...@@ -24,3 +24,5 @@ obj-$(CONFIG_DVB_CX22702) += cx22702.o
obj-$(CONFIG_DVB_TDA80XX) += tda80xx.o obj-$(CONFIG_DVB_TDA80XX) += tda80xx.o
obj-$(CONFIG_DVB_TDA10021) += tda10021.o obj-$(CONFIG_DVB_TDA10021) += tda10021.o
obj-$(CONFIG_DVB_STV0297) += stv0297.o obj-$(CONFIG_DVB_STV0297) += stv0297.o
obj-$(CONFIG_DVB_NXT2002) += nxt2002.o
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#ifdef CONFIG_DVB_DIBCOM_DEBUG #ifdef CONFIG_DVB_DIBCOM_DEBUG
static int debug; static int debug;
module_param(debug, int, 0x644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c,4=srch (|-able))."); MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c,4=srch (|-able)).");
#endif #endif
#define deb_info(args...) dprintk(0x01,args) #define deb_info(args...) dprintk(0x01,args)
...@@ -42,65 +42,6 @@ int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val) ...@@ -42,65 +42,6 @@ int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val)
return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0; return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0;
} }
int dib3000_init_pid_list(struct dib3000_state *state, int num)
{
int i;
if (state != NULL) {
state->pid_list = kmalloc(sizeof(struct dib3000_pid) * num,GFP_KERNEL);
if (state->pid_list == NULL)
return -ENOMEM;
deb_info("initializing %d pids for the pid_list.\n",num);
spin_lock_init(&state->pid_list_lock);
memset(state->pid_list,0,num*(sizeof(struct dib3000_pid)));
for (i=0; i < num; i++) {
state->pid_list[i].pid = 0;
state->pid_list[i].active = 0;
}
state->feedcount = 0;
} else
return -EINVAL;
return 0;
}
void dib3000_dealloc_pid_list(struct dib3000_state *state)
{
if (state != NULL && state->pid_list != NULL)
kfree(state->pid_list);
}
/* fetch a pid from pid_list */
int dib3000_get_pid_index(struct dib3000_pid pid_list[], int num_pids, int pid,
spinlock_t *pid_list_lock,int onoff)
{
int i,ret = -1;
unsigned long flags;
spin_lock_irqsave(pid_list_lock,flags);
for (i=0; i < num_pids; i++)
if (onoff) {
if (!pid_list[i].active) {
pid_list[i].pid = pid;
pid_list[i].active = 1;
ret = i;
break;
}
} else {
if (pid_list[i].active && pid_list[i].pid == pid) {
pid_list[i].pid = 0;
pid_list[i].active = 0;
ret = i;
break;
}
}
deb_info("setting pid: %5d %04x at index %d '%s'\n",pid,pid,ret,onoff ? "on" : "off");
spin_unlock_irqrestore(pid_list_lock,flags);
return ret;
}
int dib3000_search_status(u16 irq,u16 lock) int dib3000_search_status(u16 irq,u16 lock)
{ {
if (irq & 0x02) { if (irq & 0x02) {
...@@ -139,7 +80,4 @@ EXPORT_SYMBOL(dib3000_seq); ...@@ -139,7 +80,4 @@ EXPORT_SYMBOL(dib3000_seq);
EXPORT_SYMBOL(dib3000_read_reg); EXPORT_SYMBOL(dib3000_read_reg);
EXPORT_SYMBOL(dib3000_write_reg); EXPORT_SYMBOL(dib3000_write_reg);
EXPORT_SYMBOL(dib3000_init_pid_list);
EXPORT_SYMBOL(dib3000_dealloc_pid_list);
EXPORT_SYMBOL(dib3000_get_pid_index);
EXPORT_SYMBOL(dib3000_search_status); EXPORT_SYMBOL(dib3000_search_status);
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* DiBcom (http://www.dibcom.fr/) * DiBcom (http://www.dibcom.fr/)
* *
* Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de) * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
* *
* based on GPL code from DibCom, which has * based on GPL code from DibCom, which has
* *
...@@ -29,19 +29,10 @@ ...@@ -29,19 +29,10 @@
#include "dvb_frontend.h" #include "dvb_frontend.h"
#include "dib3000.h" #include "dib3000.h"
/* info and err, taken from usb.h, if there is anything available like by default, /* info and err, taken from usb.h, if there is anything available like by default. */
* please change ! #define err(format, arg...) printk(KERN_ERR "dib3000mX: " format "\n" , ## arg)
*/ #define info(format, arg...) printk(KERN_INFO "dib3000mX: " format "\n" , ## arg)
#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg) #define warn(format, arg...) printk(KERN_WARNING "dib3000mX: " format "\n" , ## arg)
#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
/* a PID for the pid_filter list, when in use */
struct dib3000_pid
{
u16 pid;
int active;
};
/* frontend state */ /* frontend state */
struct dib3000_state { struct dib3000_state {
...@@ -52,25 +43,18 @@ struct dib3000_state { ...@@ -52,25 +43,18 @@ struct dib3000_state {
/* configuration settings */ /* configuration settings */
struct dib3000_config config; struct dib3000_config config;
spinlock_t pid_list_lock;
struct dib3000_pid *pid_list;
int feedcount;
struct dvb_frontend frontend; struct dvb_frontend frontend;
int timing_offset; int timing_offset;
int timing_offset_comp_done; int timing_offset_comp_done;
fe_bandwidth_t last_tuned_bw;
u32 last_tuned_freq;
}; };
/* commonly used methods by the dib3000mb/mc/p frontend */ /* commonly used methods by the dib3000mb/mc/p frontend */
extern int dib3000_read_reg(struct dib3000_state *state, u16 reg); extern int dib3000_read_reg(struct dib3000_state *state, u16 reg);
extern int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val); extern int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val);
extern int dib3000_init_pid_list(struct dib3000_state *state, int num);
extern void dib3000_dealloc_pid_list(struct dib3000_state *state);
extern int dib3000_get_pid_index(struct dib3000_pid pid_list[], int num_pids,
int pid, spinlock_t *pid_list_lock,int onoff);
extern int dib3000_search_status(u16 irq,u16 lock); extern int dib3000_search_status(u16 irq,u16 lock);
/* handy shortcuts */ /* handy shortcuts */
...@@ -81,7 +65,7 @@ extern int dib3000_search_status(u16 irq,u16 lock); ...@@ -81,7 +65,7 @@ extern int dib3000_search_status(u16 irq,u16 lock);
#define wr_foreach(a,v) { int i; \ #define wr_foreach(a,v) { int i; \
if (sizeof(a) != sizeof(v)) \ if (sizeof(a) != sizeof(v)) \
err("sizeof: %zd %zd is different",sizeof(a),sizeof(v));\ err("sizeof: %d %d is different",sizeof(a),sizeof(v));\
for (i=0; i < sizeof(a)/sizeof(u16); i++) \ for (i=0; i < sizeof(a)/sizeof(u16); i++) \
wr(a[i],v[i]); \ wr(a[i],v[i]); \
} }
...@@ -136,8 +120,8 @@ extern int dib3000_search_status(u16 irq,u16 lock); ...@@ -136,8 +120,8 @@ extern int dib3000_search_status(u16 irq,u16 lock);
#define DIB3000_DDS_INVERSION_OFF ( 0) #define DIB3000_DDS_INVERSION_OFF ( 0)
#define DIB3000_DDS_INVERSION_ON ( 1) #define DIB3000_DDS_INVERSION_ON ( 1)
#define DIB3000_TUNER_WRITE_ENABLE(a) (0xffff & (a << 7)) #define DIB3000_TUNER_WRITE_ENABLE(a) (0xffff & (a << 8))
#define DIB3000_TUNER_WRITE_DISABLE(a) (0xffff & ((a << 7) | (1 << 7))) #define DIB3000_TUNER_WRITE_DISABLE(a) (0xffff & ((a << 8) | (1 << 7)))
/* for auto search */ /* for auto search */
extern u16 dib3000_seq[2][2][2]; extern u16 dib3000_seq[2][2][2];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* public header file of the frontend drivers for mobile DVB-T demodulators * public header file of the frontend drivers for mobile DVB-T demodulators
* DiBcom 3000-MB and DiBcom 3000-MC/P (http://www.dibcom.fr/) * DiBcom 3000-MB and DiBcom 3000-MC/P (http://www.dibcom.fr/)
* *
* Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de) * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
* *
* based on GPL code from DibCom, which has * based on GPL code from DibCom, which has
* *
...@@ -31,25 +31,24 @@ struct dib3000_config ...@@ -31,25 +31,24 @@ struct dib3000_config
/* the demodulator's i2c address */ /* the demodulator's i2c address */
u8 demod_address; u8 demod_address;
/* The i2c address of the PLL */ /* PLL maintenance and the i2c address of the PLL */
u8 pll_addr; u8 (*pll_addr)(struct dvb_frontend *fe);
int (*pll_init)(struct dvb_frontend *fe, u8 pll_buf[5]);
/* PLL maintenance */ int (*pll_set)(struct dvb_frontend *fe, struct dvb_frontend_parameters* params, u8 pll_buf[5]);
int (*pll_init)(struct dvb_frontend *fe);
int (*pll_set)(struct dvb_frontend *fe, struct dvb_frontend_parameters* params);
}; };
struct dib3000_xfer_ops struct dib_fe_xfer_ops
{ {
/* pid and transfer handling is done in the demodulator */ /* pid and transfer handling is done in the demodulator */
int (*pid_parse)(struct dvb_frontend *fe, int onoff); int (*pid_parse)(struct dvb_frontend *fe, int onoff);
int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff); int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
int (*pid_ctrl)(struct dvb_frontend *fe, int pid, int onoff); int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
}; };
extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
struct i2c_adapter* i2c, struct dib3000_xfer_ops *xfer_ops); struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
extern struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config, extern struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
struct i2c_adapter* i2c, struct dib3000_xfer_ops *xfer_ops); struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
#endif // DIB3000_H #endif // DIB3000_H
This diff is collapsed.
This diff is collapsed.
...@@ -58,16 +58,26 @@ do { \ ...@@ -58,16 +58,26 @@ do { \
if (debug) printk(KERN_DEBUG "mt352: " args); \ if (debug) printk(KERN_DEBUG "mt352: " args); \
} while (0) } while (0)
int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen) static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
{ {
struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv; struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
u8 buf[2] = { reg, val };
struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0,
.buf = ibuf, .len = ilen }; .buf = buf, .len = 2 };
int err = i2c_transfer(state->i2c, &msg, 1); int err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) { if (err != 1) {
dprintk("mt352_write() failed (err = %d)!\n", err); dprintk("mt352_write() to reg %x failed (err = %d)!\n", reg, err);
return err; return err;
} }
return 0;
}
int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
{
int err,i;
for (i=0; i < ilen-1; i++)
if ((err = mt352_single_write(fe,ibuf[0]+i,ibuf[i+1])))
return err;
return 0; return 0;
} }
...@@ -92,9 +102,10 @@ static u8 mt352_read_register(struct mt352_state* state, u8 reg) ...@@ -92,9 +102,10 @@ static u8 mt352_read_register(struct mt352_state* state, u8 reg)
return b1[0]; return b1[0];
} }
u8 mt352_read(struct dvb_frontend *fe, u8 reg)
{
return mt352_read_register(fe->demodulator_priv,reg);
}
...@@ -556,3 +567,4 @@ MODULE_LICENSE("GPL"); ...@@ -556,3 +567,4 @@ MODULE_LICENSE("GPL");
EXPORT_SYMBOL(mt352_attach); EXPORT_SYMBOL(mt352_attach);
EXPORT_SYMBOL(mt352_write); EXPORT_SYMBOL(mt352_write);
EXPORT_SYMBOL(mt352_read);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment