summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_net.c37
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.c193
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.h21
3 files changed, 124 insertions, 127 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c
index 64977ba4b..2a4d70a5e 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c
@@ -123,7 +123,6 @@ static void hexdump( const unsigned char *buf, unsigned short len )
struct dvb_net_priv {
int in_use;
struct net_device_stats stats;
- char name[7];
u16 pid;
struct dvb_net *host;
struct dmx_demux *demux;
@@ -228,7 +227,7 @@ int ule_bridged_sndu( struct dvb_net_priv *p )
/* BRIDGE SNDU handling sucks in draft-ietf-ipdvb-ule-03.txt.
* This has to be the last extension header, otherwise it won't work.
* Blame the authors!
- */
+ */
p->ule_bridged = 1;
return 0;
}
@@ -237,7 +236,7 @@ int ule_bridged_sndu( struct dvb_net_priv *p )
/** Handle ULE extension headers.
* Function is called after a successful CRC32 verification of an ULE SNDU to complete its decoding.
* Returns: >= 0: nr. of bytes consumed by next extension header
- * -1: Mandatory extension header that is not recognized or TEST SNDU; discard.
+ * -1: Mandatory extension header that is not recognized or TEST SNDU; discard.
*/
static int handle_one_ule_extension( struct dvb_net_priv *p )
{
@@ -1157,30 +1156,25 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
struct dvb_net_priv *priv;
int result;
int if_num;
- char name[20];
-
- memset(name, 0, sizeof(name));
-
+
if (feedtype != DVB_NET_FEEDTYPE_MPE && feedtype != DVB_NET_FEEDTYPE_ULE)
return -EINVAL;
if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL;
- sprintf(name, "dvb%1d%1d%1d",
- dvbnet->dvbdev->adapter->num, dvbnet->dvbdev->id, if_num);
- /* compatibility fix to keep dvb0_0 format */
- if(name[4] == '0')
- name[4] = '_';
-
- net = alloc_netdev(sizeof(struct dvb_net_priv), name,
- dvb_net_setup);
+ net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", dvb_net_setup);
if (!net)
return -ENOMEM;
- sprintf(net->name, "%s", name);
- printk("dvb_net: created network interface %s\n", net->name);
-
- net->addr_len = 6;
+ 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;
memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
dvbnet->device[if_num] = net;
@@ -1204,6 +1198,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
free_netdev(net);
return result;
}
+ printk("dvb_net: created network interface %s\n", net->name);
return if_num;
}
@@ -1222,7 +1217,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num)
dvb_net_stop(net);
flush_scheduled_work();
printk("dvb_net: removed network interface %s\n", net->name);
- unregister_netdev(net);
+ unregister_netdev(net);
dvbnet->state[num]=0;
dvbnet->device[num] = NULL;
free_netdev(net);
@@ -1247,7 +1242,7 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
-
+
if (!try_module_get(dvbdev->adapter->module))
return -EPERM;
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c
index 433fc6449..2ae489243 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.c
+++ b/linux/drivers/media/dvb/ttpci/av7110.c
@@ -66,8 +66,9 @@
#include "av7110_av.h"
#include "av7110_ca.h"
#include "av7110_ipack.h"
-#define TS_WIDTH (376)
-#define TS_HEIGHT (512)
+
+#define TS_WIDTH 376
+#define TS_HEIGHT 512
#define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
#define TS_MAX_PACKETS (TS_BUFLEN/TS_SIZE)
@@ -1207,10 +1208,10 @@ static void vpeirq(unsigned long data)
u32 olddma = budget->ttbp;
u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
- if(budgetpatch == 0) {
+ if (!budgetpatch) {
printk("av7110.c: vpeirq() called while budgetpatch disabled!"
" check saa7146 IER register\n");
- return;
+ BUG();
}
/* nearest lower position divisible by 188 */
newdma -= newdma % 188;
@@ -1220,19 +1221,21 @@ static void vpeirq(unsigned long data)
budget->ttbp = newdma;
- if (budget->feeding1 == 0 || newdma == olddma)
+ if (!budget->feeding1 || (newdma == olddma))
return;
#if 0
/* track rps1 activity */
- printk("vpeirq: %02x Event Counter 1 0x%04x\n",
+ printk("vpeirq: %02x Event Counter 1 0x%04x\n",
mem[olddma],
- saa7146_read(budget->dev, EC1R) & 0x3fff );
+ saa7146_read(budget->dev, EC1R) & 0x3fff);
#endif
- if (newdma > olddma) /* no wraparound, dump olddma..newdma */
+ if (newdma > olddma)
+ /* no wraparound, dump olddma..newdma */
dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (newdma - olddma) / 188);
- else { /* wraparound, dump olddma..buflen and 0..newdma */
+ else {
+ /* wraparound, dump olddma..buflen and 0..newdma */
dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (TS_BUFLEN - olddma) / 188);
dvb_dmx_swfilter_packets(&budget->demux1, mem, newdma / 188);
}
@@ -1302,7 +1305,7 @@ static int av7110_register(struct av7110 *av7110)
dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
- if(budgetpatch) {
+ if (budgetpatch) {
/* initialize software demux1 without its own frontend
* demux1 hardware is connected to frontend0 of demux0
*/
@@ -1316,7 +1319,7 @@ static int av7110_register(struct av7110 *av7110)
dvbdemux1->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
DMX_MEMORY_BASED_FILTERING);
-
+
dvb_dmx_init(&av7110->demux1);
av7110->dmxdev1.filternum = 256;
@@ -1325,12 +1328,8 @@ static int av7110_register(struct av7110 *av7110)
dvb_dmxdev_init(&av7110->dmxdev1, av7110->dvb_adapter);
- /* demux1 is without it's own frontend */
-
dvb_net_init(av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx);
printk("dvb-ttpci: additional demux1 for budget-patch registered\n");
-
- /* end software demux1 */
}
return 0;
}
@@ -2082,70 +2081,70 @@ static void frontend_init(struct av7110 *av7110)
}
}
-/* Budgetpatch note:
- * Original hardware design by Roberto Deza:
- * There is a DVB_Wiki at
- * http://212.227.36.83/linuxtv/wiki/index.php/Main_Page
- * where is described this 'DVB TT Budget Patch', on Card Modding:
- * http://212.227.36.83/linuxtv/wiki/index.php/DVB_TT_Budget_Patch
- * On the short description there is also a link to a external file,
- * with more details:
- * http://perso.wanadoo.es/jesussolano/Ttf_tsc1.zip
+/* Budgetpatch note:
+ * Original hardware design by Roberto Deza:
+ * There is a DVB_Wiki at
+ * http://212.227.36.83/linuxtv/wiki/index.php/Main_Page
+ * where is described this 'DVB TT Budget Patch', on Card Modding:
+ * http://212.227.36.83/linuxtv/wiki/index.php/DVB_TT_Budget_Patch
+ * On the short description there is also a link to a external file,
+ * with more details:
+ * http://perso.wanadoo.es/jesussolano/Ttf_tsc1.zip
*
- * New software triggering design by Emard that works on
- * original Roberto Deza's hardware:
+ * New software triggering design by Emard that works on
+ * original Roberto Deza's hardware:
*
- * rps1 code for budgetpatch will copy internal HS event to GPIO3 pin.
- * GPIO3 is in budget-patch hardware connectd to port B VSYNC
- * HS is an internal event of 7146, accessible with RPS
- * and temporarily raised high every n lines
- * (n in defined in the RPS_THRESH1 counter threshold)
- * I think HS is raised high on the beginning of the n-th line
- * and remains high until this n-th line that triggered
- * it is completely received. When the receiption of n-th line
- * ends, HS is lowered.
+ * rps1 code for budgetpatch will copy internal HS event to GPIO3 pin.
+ * GPIO3 is in budget-patch hardware connectd to port B VSYNC
+ * HS is an internal event of 7146, accessible with RPS
+ * and temporarily raised high every n lines
+ * (n in defined in the RPS_THRESH1 counter threshold)
+ * I think HS is raised high on the beginning of the n-th line
+ * and remains high until this n-th line that triggered
+ * it is completely received. When the receiption of n-th line
+ * ends, HS is lowered.
*
- * To transmit data over DMA, 7146 needs changing state at
- * port B VSYNC pin. Any changing of port B VSYNC will
- * cause some DMA data transfer, with more or less packets loss.
- * It depends on the phase and frequency of VSYNC and
- * the way of 7146 is instructed to trigger on port B (defined
- * in DD1_INIT register, 3rd nibble from the right valid
- * numbers are 0-7, see datasheet)
+ * To transmit data over DMA, 7146 needs changing state at
+ * port B VSYNC pin. Any changing of port B VSYNC will
+ * cause some DMA data transfer, with more or less packets loss.
+ * It depends on the phase and frequency of VSYNC and
+ * the way of 7146 is instructed to trigger on port B (defined
+ * in DD1_INIT register, 3rd nibble from the right valid
+ * numbers are 0-7, see datasheet)
*
- * The correct triggering can minimize packet loss,
- * dvbtraffic should give this stable bandwidths:
- * 22k transponder = 33814 kbit/s
- * 27.5k transponder = 38045 kbit/s
- * by experiment it is found that the best results
- * (stable bandwidths and almost no packet loss)
- * are obtained using DD1_INIT triggering number 2
- * (Va at rising edge of VS Fa = HS x VS-failing forced toggle)
- * and a VSYNC phase that occurs in the middle of DMA transfer
- * (about byte 188*512=96256 in the DMA window).
+ * The correct triggering can minimize packet loss,
+ * dvbtraffic should give this stable bandwidths:
+ * 22k transponder = 33814 kbit/s
+ * 27.5k transponder = 38045 kbit/s
+ * by experiment it is found that the best results
+ * (stable bandwidths and almost no packet loss)
+ * are obtained using DD1_INIT triggering number 2
+ * (Va at rising edge of VS Fa = HS x VS-failing forced toggle)
+ * and a VSYNC phase that occurs in the middle of DMA transfer
+ * (about byte 188*512=96256 in the DMA window).
*
- * Phase of HS is still not clear to me how to control,
- * It just happens to be so. It can be seen if one enables
- * RPS_IRQ and print Event Counter 1 in vpeirq(). Every
- * time RPS_INTERRUPT is called, the Event Counter 1 will
- * increment. That's how the 7146 is programmed to do event
- * counting in this budget-patch.c
- * I *think* HPS setting has something to do with the phase
- * of HS but I cant be 100% sure in that.
+ * Phase of HS is still not clear to me how to control,
+ * It just happens to be so. It can be seen if one enables
+ * RPS_IRQ and print Event Counter 1 in vpeirq(). Every
+ * time RPS_INTERRUPT is called, the Event Counter 1 will
+ * increment. That's how the 7146 is programmed to do event
+ * counting in this budget-patch.c
+ * I *think* HPS setting has something to do with the phase
+ * of HS but I cant be 100% sure in that.
*
- * hardware debug note: a working budget card (including budget patch)
- * with vpeirq() interrupt setup in mode "0x90" (every 64K) will
- * generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
- * and that means 3*25=75 Hz of interrupt freqency, as seen by
- * watch cat /proc/interrupts
+ * hardware debug note: a working budget card (including budget patch)
+ * with vpeirq() interrupt setup in mode "0x90" (every 64K) will
+ * generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
+ * and that means 3*25=75 Hz of interrupt freqency, as seen by
+ * watch cat /proc/interrupts
*
- * If this frequency is 3x lower (and data received in the DMA
- * buffer don't start with 0x47, but in the middle of packets,
- * whose lengths appear to be like 188 292 188 104 etc.
- * this means VSYNC line is not connected in the hardware.
- * (check soldering pcb and pins)
- * The same behaviour of missing VSYNC can be duplicated on budget
- * cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
+ * If this frequency is 3x lower (and data received in the DMA
+ * buffer don't start with 0x47, but in the middle of packets,
+ * whose lengths appear to be like 188 292 188 104 etc.
+ * this means VSYNC line is not connected in the hardware.
+ * (check soldering pcb and pins)
+ * The same behaviour of missing VSYNC can be duplicated on budget
+ * cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
*/
static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *pci_ext)
{
@@ -2155,22 +2154,22 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
int count = 0;
dprintk(4, "dev: %p\n", dev);
-
+
/* Set RPS_IRQ to 1 to track rps1 activity.
* Enabling this won't send any interrupt to PC CPU.
*/
#define RPS_IRQ 0
- if(budgetpatch == 1) {
+ if (budgetpatch == 1) {
budgetpatch = 0;
- /* autodetect the presence of budget patch
+ /* autodetect the presence of budget patch
* this only works if saa7146 has been recently
* reset with with MASK_31 to MC1
- *
+ *
* will wait for VBI_B event (vertical blank at port B)
* and will reset GPIO3 after VBI_B is detected.
* (GPIO3 should be raised high by CPU to
- * test if GPIO3 will generate vertical blank signal
+ * test if GPIO3 will generate vertical blank signal
* in budget patch GPIO3 is connected to VSYNC_B
*/
@@ -2183,16 +2182,16 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
/* set vsync_b triggering */
saa7146_write(dev, DD1_STREAM_B, 0);
/* port B VSYNC at rising edge */
- saa7146_write(dev, DD1_INIT, 0x00000200);
+ saa7146_write(dev, DD1_INIT, 0x00000200);
saa7146_write(dev, BRS_CTRL, 0x00000000); // VBI
- saa7146_write(dev, MC2,
+ saa7146_write(dev, MC2,
1 * (MASK_08 | MASK_24) | // BRS control
0 * (MASK_09 | MASK_25) | // a
1 * (MASK_10 | MASK_26) | // b
0 * (MASK_06 | MASK_22) | // HPS_CTRL1
0 * (MASK_05 | MASK_21) | // HPS_CTRL2
0 * (MASK_01 | MASK_15) // DEBI
- );
+ );
/* start writing RPS1 code from beginning */
count = 0;
@@ -2216,7 +2215,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
#if RPS_IRQ
/* set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
* use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
- * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
+ * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
*/
saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
/* set event counter 1 treshold to maximum allowed value (rEC p55) */
@@ -2231,11 +2230,11 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
/* now send VSYNC_B to rps1 by rising GPIO3 */
saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
mdelay(10);
- /* if rps1 responded by lowering the GPIO3,
+ /* if rps1 responded by lowering the GPIO3,
* then we have budgetpatch hardware
*/
- if( (saa7146_read(dev, GPIO_CTRL) & 0x10000000) == 0) {
- budgetpatch |= 1;
+ if ((saa7146_read(dev, GPIO_CTRL) & 0x10000000) == 0) {
+ budgetpatch = 1;
printk("dvb-ttpci: BUDGET-PATCH DETECTED.\n");
}
/* Disable RPS1 */
@@ -2278,6 +2277,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
if (i2c_add_adapter(&av7110->i2c_adap) < 0) {
+err_no_mem:
dvb_unregister_adapter (av7110->dvb_adapter);
kfree(av7110);
return -ENOMEM;
@@ -2285,11 +2285,12 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
ttpci_eeprom_parse_mac(&av7110->i2c_adap, av7110->dvb_adapter->proposed_mac);
- if(budgetpatch) {
- if (NULL ==
- (av7110->grabbing =
- saa7146_vmalloc_build_pgtable(dev->pci, length, &av7110->pt)))
- return -ENOMEM;
+ if (budgetpatch) {
+ spin_lock_init(&av7110->feedlock1);
+ av7110->grabbing = saa7146_vmalloc_build_pgtable(
+ dev->pci, length, &av7110->pt);
+ if (!av7110->grabbing)
+ goto err_no_mem;
saa7146_write(dev, PCI_BT_V1, 0x1c1c101f);
saa7146_write(dev, BCS_CTRL, 0x80400040);
/* set dd1 stream a & b */
@@ -2353,9 +2354,9 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
* this is related to TS_WIDTH set in register
* NUM_LINE_BYTE3. If NUM_LINE_BYTE low 16 bits
* are set to TS_WIDTH bytes (TS_WIDTH=2*188),
- * then RPS_THRESH1 should be set to trigger
+ * then RPS_THRESH1 should be set to trigger
* every TS_HEIGHT (512) lines.
- */
+ */
saa7146_write(dev, RPS_THRESH1, (TS_HEIGHT*1) | MASK_12 );
/* Enable RPS1 (rFC p33) */
@@ -2375,9 +2376,6 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
saa7146_write(dev, MC2, 0x077c077c);
saa7146_write(dev, GPIO_CTRL, 0x000000);
}
-
- if(budgetpatch)
- spin_lock_init(&av7110->feedlock1);
tasklet_init (&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110);
tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
@@ -2485,17 +2483,16 @@ err:
return ret;
}
-static int av7110_detach (struct saa7146_dev* saa)
+static int av7110_detach(struct saa7146_dev* saa)
{
struct av7110 *av7110 = (struct av7110*)saa->ext_priv;
dprintk(4, "%p\n", av7110);
- if( 0 == av7110->device_initialized ) {
+ if (!av7110->device_initialized )
return 0;
- }
tasklet_kill(&av7110->vpe_tasklet);
- if(budgetpatch)
+ if (budgetpatch)
saa7146_pgtable_free(saa->pci, &av7110->pt);
av7110_exit_v4l(av7110);
diff --git a/linux/drivers/media/dvb/ttpci/av7110.h b/linux/drivers/media/dvb/ttpci/av7110.h
index ba45214d1..a01f5bdfc 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.h
+++ b/linux/drivers/media/dvb/ttpci/av7110.h
@@ -75,7 +75,7 @@ struct av7110 {
/* devices */
struct dvb_device dvb_dev;
- struct dvb_net dvb_net, dvb_net1;
+ struct dvb_net dvb_net;
struct video_device *v4l_dev;
struct video_device *vbi_dev;
@@ -152,19 +152,24 @@ struct av7110 {
ca_slot_info_t ci_slot[2];
int vidmode;
- struct dmxdev dmxdev, dmxdev1;
- struct dvb_demux demux, demux1;
- spinlock_t feedlock1; /* for budget mode demux1 */
+ struct dmxdev dmxdev;
+ struct dvb_demux demux;
+
+ struct dmx_frontend hw_frontend;
+ struct dmx_frontend mem_frontend;
+
+ /* for budget mode demux1 */
+ struct dmxdev dmxdev1;
+ struct dvb_demux demux1;
+ struct dvb_net dvb_net1;
+ spinlock_t feedlock1;
int feeding1;
u8 tsf;
u32 ttbp;
unsigned char *grabbing;
struct saa7146_pgtable pt;
struct tasklet_struct vpe_tasklet;
-
- struct dmx_frontend hw_frontend, hw_frontend1;
- struct dmx_frontend mem_frontend, mem_frontend1;
-
+
int fe_synced;
struct semaphore pid_mutex;