Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: [PATCH] Coding style for skystar2.c (both DVB anddvb-kernel)
On Tue, Nov 25, 2003 at 04:32:47PM +0100, Holger Waechtler wrote:
> Roberto Ragusa wrote:
> ...
> I applied your indentination patch to CVS.
>
I'll attach a patch to dvb-kernel skystar2.c to get rid of the endianess
problems.
As I don't think that we will need these checks in the end there, I also
moved the definition of struct packet_header down to the only place where
it is needed at the moment.
I don't think I broke anything...
Wolfgang
--- skystar2.c.orig 2003-11-25 20:18:26.000000000 +0000
+++ skystar2.c 2003-11-25 21:14:50.000000000 +0000
@@ -60,18 +60,6 @@
u8 *buffer;
};
-struct packet_header {
-
- u32 sync_byte;
- u32 transport_error_indicator;
- u32 payload_unit_start_indicator;
- u32 transport_priority;
- u32 pid;
- u32 transport_scrambling_control;
- u32 adaptation_field_control;
- u32 continuity_counter;
-};
-
struct adapter {
struct pci_dev *pdev;
@@ -1809,7 +1797,6 @@
static void interrupt_service_dma1(struct adapter *adapter)
{
struct dvb_demux *dvbdmx = &adapter->demux;
- struct packet_header packet_header;
int n_cur_dma_counter;
u32 n_num_bytes_parsed;
@@ -1856,25 +1843,32 @@
}
if (adapter->capturing != 0) {
- u32 *dq = (u32 *) pb_dma_buf_cur_pos;
+ struct packet_header {
+ u8 sync_byte;
+ u8 transport_error_indicator;
+ u8 payload_unit_start_indicator;
+ u8 transport_priority;
+ u16 pid;
+ u8 transport_scrambling_control;
+ u8 adaptation_field_control;
+ u8 continuity_counter;
+ } packet_header;
+ u8 *p = pb_dma_buf_cur_pos;
+
+ packet_header.sync_byte = p[0];
+ packet_header.transport_error_indicator = (p[1]>>7)&1;
+ packet_header.payload_unit_start_indicator = (p[1]>>6)&1;
+ packet_header.transport_priority = (p[1]>>5)&1;
+ packet_header.pid = ((p[1]&0x1f)<<8) | p[2];
+ packet_header.transport_scrambling_control = (p[3]>>6)&3;
+ packet_header.adaptation_field_control = (p[3]>>4)&3;
+ packet_header.continuity_counter = (p[3]) &0xf;
- packet_header.sync_byte = *dq & 0x000000FF;
- packet_header.transport_error_indicator = *dq & 0x00008000;
- packet_header.payload_unit_start_indicator = *dq & 0x00004000;
- packet_header.transport_priority = *dq & 0x00002000;
- packet_header.pid = ((*dq & 0x00FF0000) >> 0x10) | (*dq & 0x00001F00);
- packet_header.transport_scrambling_control = *dq >> 0x1E;
- packet_header.adaptation_field_control = (*dq & 0x30000000) >> 0x1C;
- packet_header.continuity_counter = (*dq & 0x0F000000) >> 0x18;
-
- if ((packet_header.sync_byte == 0x47) && (packet_header.transport_error_indicator == 0) && (packet_header.pid != 0x1FFF)) {
- if (check_pid(adapter, packet_header.pid & 0x0000FFFF) != 0)
- {
+ if (packet_header.sync_byte == 0x47 && packet_header.transport_error_indicator == 0 && packet_header.pid != 0x1FFF) {
+ if (check_pid(adapter, packet_header.pid) != 0) {
dvb_dmx_swfilter_packets(dvbdmx, pb_dma_buf_cur_pos, dw_default_packet_size / 188);
-
} else {
-
- dprintk("%s: pid=%x\n", __FUNCTION__, packet_header.pid);
+ dprintk("%s: pid=0x%04x\n", __FUNCTION__, (unsigned int)packet_header.pid);
}
}
}
Home |
Main Index |
Thread Index