Here is another patch for the skystar2.c.

Please, have a close look before committing it to cvs.

It mainly simply disables the default group filter to check pids
00-1f: IMHO, this default really isn't needed: it only adds unnecessary
complexity to the driver (and added unnecessary work to the poor Flex ;-)

I have _not_ tested this patch very much yet, but it should be fine.


Wolfgang

--- skystar2.c.orig     2003-12-11 15:28:44.000000000 +0000
+++ skystar2.c  2003-12-11 16:06:13.000000000 +0000
@@ -1035,7 +1035,7 @@ static void pid_set_group_pid(struct ada
 {
        u32 value;
 
-       dprintk("%s: pid=%x\n", __FUNCTION__, pid);
+       dprintk("%s: pid=%04x\n", __FUNCTION__, pid);
        value = (pid & 0x3fff) | (read_reg_dw(adapter, 0x30c) & 0xffff0000);
        write_reg_dw(adapter, 0x30c, value);
 }
@@ -1044,7 +1044,7 @@ static void pid_set_group_mask(struct ad
 {
        u32 value;
 
-       dprintk("%s: pid=%x\n", __FUNCTION__, pid);
+       dprintk("%s: mask=%04x\n", __FUNCTION__, pid);
        value = ((pid & 0x3fff) << 0x10) | (read_reg_dw(adapter, 0x30c) & 0xffff);
        write_reg_dw(adapter, 0x30c, value);
 }
@@ -1061,42 +1061,18 @@ static int pid_get_group_mask(struct ada
 }
 */
 
-/*
-static void reset_hardware_pid_filter(struct adapter *adapter)
-{
-       pid_set_stream1_pid(adapter, 0x1fff);
-
-       pid_set_stream2_pid(adapter, 0x1fff);
-       filter_enable_stream2_filter(adapter, 0);
-
-       pid_set_pcr_pid(adapter, 0x1fff);
-       filter_enable_pcr_filter(adapter, 0);
-
-       pid_set_pmt_pid(adapter, 0x1fff);
-       filter_enable_pmt_filter(adapter, 0);
-
-       pid_set_ecm_pid(adapter, 0x1fff);
-       filter_enable_ecm_filter(adapter, 0);
-
-       pid_set_emm_pid(adapter, 0x1fff);
-       filter_enable_emm_filter(adapter, 0);
-}
-*/
-
 static void init_pids(struct adapter *adapter)
 {
        int i;
 
+       dprintk("%s\n", __FUNCTION__);
        adapter->pid_count = 0;
        adapter->whole_bandwidth_count = 0;
-       for (i = 0; i < adapter->useable_hw_filters; i++) {
-               dprintk("%s: setting filter %d to 0x1fff\n", __FUNCTION__, i);
+       for (i = 0; i < adapter->useable_hw_filters; i++)
                adapter->hw_pids[i] = 0x1fff;
-               pid_set_hw_pid(adapter, i, 0x1fff);
-       }
-
-       pid_set_group_pid(adapter, 0);
-       pid_set_group_mask(adapter, 0x1fe0);
+       /* Do we have to disable all hw pids here as well, or was this
+          done by the 'Flex reset' already?
+       */
 }
 
 static void open_whole_bandwidth(struct adapter *adapter)
@@ -1104,19 +1080,13 @@ static void open_whole_bandwidth(struct 
        dprintk("%s:\n", __FUNCTION__);
        pid_set_group_pid(adapter, 0);
        pid_set_group_mask(adapter, 0);
-/*
        filter_enable_mask_filter(adapter, 1);
-*/
 }
 
 static void close_whole_bandwidth(struct adapter *adapter)
 {
        dprintk("%s:\n", __FUNCTION__);
-       pid_set_group_pid(adapter, 0);
-       pid_set_group_mask(adapter, 0x1fe0);
-/*
-       filter_enable_mask_filter(adapter, 1);
-*/
+       filter_enable_mask_filter(adapter, 0);
 }
 
 static void whole_bandwidth_inc(struct adapter *adapter)
@@ -1127,8 +1097,10 @@ static void whole_bandwidth_inc(struct a
 
 static void whole_bandwidth_dec(struct adapter *adapter)
 {
-       if (--adapter->whole_bandwidth_count <= 0)
+       if (--adapter->whole_bandwidth_count <= 0) {
                close_whole_bandwidth(adapter);
+               adapter->whole_bandwidth_count = 0;
+       }
 }
 
 /* The specified PID has to be let through the
@@ -1136,16 +1108,14 @@ static void whole_bandwidth_dec(struct a
    We try to allocate an hardware filter and open whole
    bandwidth when allocation is impossible.
    All pids<=0x1f pass through the group filter.
-   Returns 1 on success, -1 on error */
+   Returns 1 on success, -1 on error
+*/
 static int add_hw_pid(struct adapter *adapter, u16 pid)
 {
        int i;
 
        dprintk("%s: pid=%d\n", __FUNCTION__, pid);
 
-       if (pid <= 0x1f)
-               return 1;
-
        /* we can't use a filter for 0x2000, so no search */
        if (pid != 0x2000) {
                /* find an unused hardware filter */
@@ -1173,9 +1143,6 @@ static int remove_hw_pid(struct adapter 
 
        dprintk("%s: pid=%d\n", __FUNCTION__, pid);
 
-       if (pid <= 0x1f)
-               return 1;
-
        /* we can't use a filter for 0x2000, so no search */
        if (pid != 0x2000) {
                for (i = 0; i < adapter->useable_hw_filters; i++) {
@@ -1198,7 +1165,8 @@ static int remove_hw_pid(struct adapter 
 /* Adds a PID to the filters.
    Adding a pid more than once is possible, we keep reference counts.
    Whole stream available through pid==0x2000.
-   Returns 1 on success, -1 on error */
+   Returns 1 on success, -1 on error
+*/
 static int add_pid(struct adapter *adapter, u16 pid)
 {
        int i;
@@ -1209,12 +1177,12 @@ static int add_pid(struct adapter *adapt
                return -1;
 
        // check if the pid is already present
-       for (i = 0; i < adapter->pid_count; i++)
+       for (i = 0; i < adapter->pid_count; i++) {
                if (adapter->pid_list[i] == pid) {
                        adapter->pid_rc[i]++;   // increment ref counter
                        return 1;
                }
-
+       }
        if (adapter->pid_count == N_PID_SLOTS)
                return -1;      // no more pids can be added
        adapter->pid_list[adapter->pid_count] = pid;    // register pid
@@ -1229,7 +1197,7 @@ static int add_pid(struct adapter *adapt
 /* Removes a PID from the filters. */
 static int remove_pid(struct adapter *adapter, u16 pid)
 {
-       int i, j;
+       int i;
 
        dprintk("%s: pid=%d\n", __FUNCTION__, pid);
 
@@ -1243,8 +1211,8 @@ static int remove_pid(struct adapter *ad
                        if (adapter->pid_rc[i] <= 0) {
                                // remove from the list
                                adapter->pid_count--;
-                               
adapter->pid_list[i]=adapter->pid_list[adapter->pid_count];
-                               adapter->pid_rc[i] = 
adapter->pid_rc[adapter->pid_count];
+                               adapter->pid_list[i] = 
adapter->pid_list[adapter->pid_count];
+                               adapter->pid_rc[i]   = 
adapter->pid_rc[adapter->pid_count];
                                // hardware setting
                                remove_hw_pid(adapter, pid);
                        }
@@ -1522,8 +1490,6 @@ static void open_stream(struct adapter *
 
        ++adapter->capturing;
 
-       filter_enable_mask_filter(adapter, 1);
-
        add_pid(adapter, pid);
 
        dprintk("%s: adapter->dma_status=%x\n", __FUNCTION__, adapter->dma_status);
@@ -1549,7 +1515,6 @@ static void open_stream(struct adapter *
 
                if (dma_mask != 0) {
                        irq_dma_enable_disable_irq(adapter, 1);
-
                        dma_start_stop(adapter, dma_mask, 1);
                }
        }
@@ -1980,17 +1945,11 @@ static void driver_halt(struct pci_dev *
        struct adapter *adapter;
 
        adapter = pci_get_drvdata(pdev);
-
        irq_dma_enable_disable_irq(adapter, 0);
-
        ctrl_enable_receive_data(adapter, 0);
-
        free_adapter_object(adapter);
-
        pci_set_drvdata(pdev, NULL);
-
        release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1));
-
        release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
 }
 

Reply via email to