diff options
author | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2005-12-12 11:37:27 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-12-12 19:57:44 +0300 |
commit | afd1a0c9ac281eed3b22b293ccd92af7b0d60889 (patch) | |
tree | 686c03cf1a1a2efb1fba6dc6e682fbb48edc7c58 /drivers/media/dvb/dvb-core | |
parent | 808824b5f73e361503420ee318ca9689781da034 (diff) | |
download | linux-afd1a0c9ac281eed3b22b293ccd92af7b0d60889.tar.xz |
[PATCH] V4L/DVB: (3086c) Whitespaces cleanups part 3
Clean up whitespaces at v4l/dvb files
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/dvb/dvb-core')
-rw-r--r-- | drivers/media/dvb/dvb-core/demux.h | 92 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dmxdev.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dmxdev.h | 64 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_filter.c | 332 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_filter.h | 102 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_frontend.c | 8 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_frontend.h | 8 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_net.c | 42 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_ringbuffer.c | 262 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_ringbuffer.h | 20 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvbdev.c | 142 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvbdev.h | 6 |
13 files changed, 541 insertions, 541 deletions
diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index 7d7b0067f228..9f025825b2d2 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h @@ -86,25 +86,25 @@ enum dmx_success { enum dmx_ts_pes { /* also send packets to decoder (if it exists) */ - DMX_TS_PES_AUDIO0, + DMX_TS_PES_AUDIO0, DMX_TS_PES_VIDEO0, DMX_TS_PES_TELETEXT0, DMX_TS_PES_SUBTITLE0, DMX_TS_PES_PCR0, - DMX_TS_PES_AUDIO1, + DMX_TS_PES_AUDIO1, DMX_TS_PES_VIDEO1, DMX_TS_PES_TELETEXT1, DMX_TS_PES_SUBTITLE1, DMX_TS_PES_PCR1, - DMX_TS_PES_AUDIO2, + DMX_TS_PES_AUDIO2, DMX_TS_PES_VIDEO2, DMX_TS_PES_TELETEXT2, DMX_TS_PES_SUBTITLE2, DMX_TS_PES_PCR2, - DMX_TS_PES_AUDIO3, + DMX_TS_PES_AUDIO3, DMX_TS_PES_VIDEO3, DMX_TS_PES_TELETEXT3, DMX_TS_PES_SUBTITLE3, @@ -121,17 +121,17 @@ enum dmx_ts_pes struct dmx_ts_feed { - int is_filtering; /* Set to non-zero when filtering in progress */ - struct dmx_demux *parent; /* Back-pointer */ - void *priv; /* Pointer to private data of the API client */ - int (*set) (struct dmx_ts_feed *feed, + int is_filtering; /* Set to non-zero when filtering in progress */ + struct dmx_demux *parent; /* Back-pointer */ + void *priv; /* Pointer to private data of the API client */ + int (*set) (struct dmx_ts_feed *feed, u16 pid, int type, enum dmx_ts_pes pes_type, size_t circular_buffer_size, struct timespec timeout); - int (*start_filtering) (struct dmx_ts_feed* feed); - int (*stop_filtering) (struct dmx_ts_feed* feed); + int (*start_filtering) (struct dmx_ts_feed* feed); + int (*stop_filtering) (struct dmx_ts_feed* feed); }; /*--------------------------------------------------------------------------*/ @@ -139,35 +139,35 @@ struct dmx_ts_feed { /*--------------------------------------------------------------------------*/ struct dmx_section_filter { - u8 filter_value [DMX_MAX_FILTER_SIZE]; - u8 filter_mask [DMX_MAX_FILTER_SIZE]; - u8 filter_mode [DMX_MAX_FILTER_SIZE]; - struct dmx_section_feed* parent; /* Back-pointer */ - void* priv; /* Pointer to private data of the API client */ + u8 filter_value [DMX_MAX_FILTER_SIZE]; + u8 filter_mask [DMX_MAX_FILTER_SIZE]; + u8 filter_mode [DMX_MAX_FILTER_SIZE]; + struct dmx_section_feed* parent; /* Back-pointer */ + void* priv; /* Pointer to private data of the API client */ }; struct dmx_section_feed { - int is_filtering; /* Set to non-zero when filtering in progress */ - struct dmx_demux* parent; /* Back-pointer */ - void* priv; /* Pointer to private data of the API client */ + int is_filtering; /* Set to non-zero when filtering in progress */ + struct dmx_demux* parent; /* Back-pointer */ + void* priv; /* Pointer to private data of the API client */ - int check_crc; + int check_crc; u32 crc_val; - u8 *secbuf; - u8 secbuf_base[DMX_MAX_SECFEED_SIZE]; - u16 secbufp, seclen, tsfeedp; + u8 *secbuf; + u8 secbuf_base[DMX_MAX_SECFEED_SIZE]; + u16 secbufp, seclen, tsfeedp; - int (*set) (struct dmx_section_feed* feed, + int (*set) (struct dmx_section_feed* feed, u16 pid, size_t circular_buffer_size, int check_crc); - int (*allocate_filter) (struct dmx_section_feed* feed, + int (*allocate_filter) (struct dmx_section_feed* feed, struct dmx_section_filter** filter); - int (*release_filter) (struct dmx_section_feed* feed, + int (*release_filter) (struct dmx_section_feed* feed, struct dmx_section_filter* filter); - int (*start_filtering) (struct dmx_section_feed* feed); - int (*stop_filtering) (struct dmx_section_feed* feed); + int (*start_filtering) (struct dmx_section_feed* feed); + int (*stop_filtering) (struct dmx_section_feed* feed); }; /*--------------------------------------------------------------------------*/ @@ -205,10 +205,10 @@ enum dmx_frontend_source { }; struct dmx_frontend { - struct list_head connectivity_list; /* List of front-ends that can + struct list_head connectivity_list; /* List of front-ends that can be connected to a particular demux */ - enum dmx_frontend_source source; + enum dmx_frontend_source source; }; /*--------------------------------------------------------------------------*/ @@ -240,38 +240,38 @@ struct dmx_frontend { #define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list) struct dmx_demux { - u32 capabilities; /* Bitfield of capability flags */ - struct dmx_frontend* frontend; /* Front-end connected to the demux */ - void* priv; /* Pointer to private data of the API client */ - int (*open) (struct dmx_demux* demux); - int (*close) (struct dmx_demux* demux); - int (*write) (struct dmx_demux* demux, const char* buf, size_t count); - int (*allocate_ts_feed) (struct dmx_demux* demux, + u32 capabilities; /* Bitfield of capability flags */ + struct dmx_frontend* frontend; /* Front-end connected to the demux */ + void* priv; /* Pointer to private data of the API client */ + int (*open) (struct dmx_demux* demux); + int (*close) (struct dmx_demux* demux); + int (*write) (struct dmx_demux* demux, const char* buf, size_t count); + int (*allocate_ts_feed) (struct dmx_demux* demux, struct dmx_ts_feed** feed, dmx_ts_cb callback); - int (*release_ts_feed) (struct dmx_demux* demux, + int (*release_ts_feed) (struct dmx_demux* demux, struct dmx_ts_feed* feed); - int (*allocate_section_feed) (struct dmx_demux* demux, + int (*allocate_section_feed) (struct dmx_demux* demux, struct dmx_section_feed** feed, dmx_section_cb callback); - int (*release_section_feed) (struct dmx_demux* demux, + int (*release_section_feed) (struct dmx_demux* demux, struct dmx_section_feed* feed); - int (*add_frontend) (struct dmx_demux* demux, + int (*add_frontend) (struct dmx_demux* demux, struct dmx_frontend* frontend); - int (*remove_frontend) (struct dmx_demux* demux, + int (*remove_frontend) (struct dmx_demux* demux, struct dmx_frontend* frontend); - struct list_head* (*get_frontends) (struct dmx_demux* demux); - int (*connect_frontend) (struct dmx_demux* demux, + struct list_head* (*get_frontends) (struct dmx_demux* demux); + int (*connect_frontend) (struct dmx_demux* demux, struct dmx_frontend* frontend); - int (*disconnect_frontend) (struct dmx_demux* demux); + int (*disconnect_frontend) (struct dmx_demux* demux); - int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); + int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); - int (*get_stc) (struct dmx_demux* demux, unsigned int num, + int (*get_stc) (struct dmx_demux* demux, unsigned int num, u64 *stc, unsigned int *base); }; diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 8028c3a5e287..7b8373ad121b 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c @@ -947,7 +947,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, case DMX_GET_STC: if (!dmxdev->demux->get_stc) { - ret=-EINVAL; + ret=-EINVAL; break; } ret = dmxdev->demux->get_stc(dmxdev->demux, diff --git a/drivers/media/dvb/dvb-core/dmxdev.h b/drivers/media/dvb/dvb-core/dmxdev.h index 395a9cd75012..fd72920c2199 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.h +++ b/drivers/media/dvb/dvb-core/dmxdev.h @@ -53,51 +53,51 @@ enum dmxdev_state { }; struct dmxdev_buffer { - u8 *data; - int size; - int pread; - int pwrite; + u8 *data; + int size; + int pread; + int pwrite; wait_queue_head_t queue; - int error; + int error; }; struct dmxdev_filter { struct dvb_device *dvbdev; - union { - struct dmx_section_filter *sec; + union { + struct dmx_section_filter *sec; } filter; - union { - struct dmx_ts_feed *ts; - struct dmx_section_feed *sec; + union { + struct dmx_ts_feed *ts; + struct dmx_section_feed *sec; } feed; - union { - struct dmx_sct_filter_params sec; - struct dmx_pes_filter_params pes; + union { + struct dmx_sct_filter_params sec; + struct dmx_pes_filter_params pes; } params; - int type; - enum dmxdev_state state; - struct dmxdev *dev; - struct dmxdev_buffer buffer; + int type; + enum dmxdev_state state; + struct dmxdev *dev; + struct dmxdev_buffer buffer; struct semaphore mutex; - /* only for sections */ - struct timer_list timer; - int todo; - u8 secheader[3]; + /* only for sections */ + struct timer_list timer; + int todo; + u8 secheader[3]; - u16 pid; + u16 pid; }; struct dmxdev_dvr { - int state; - struct dmxdev *dev; - struct dmxdev_buffer buffer; + int state; + struct dmxdev *dev; + struct dmxdev_buffer buffer; }; @@ -105,16 +105,16 @@ struct dmxdev { struct dvb_device *dvbdev; struct dvb_device *dvr_dvbdev; - struct dmxdev_filter *filter; - struct dmxdev_dvr *dvr; - struct dmx_demux *demux; + struct dmxdev_filter *filter; + struct dmxdev_dvr *dvr; + struct dmx_demux *demux; - int filternum; - int capabilities; + int filternum; + int capabilities; #define DMXDEV_CAP_DUPLEX 1 - struct dmx_frontend *dvr_orig_fe; + struct dmx_frontend *dvr_orig_fe; - struct dmxdev_buffer dvr_buffer; + struct dmxdev_buffer dvr_buffer; #define DVR_BUFFER_SIZE (10*188*1024) struct semaphore mutex; diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index cb2e7d6ba283..5956c35d34ac 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -498,7 +498,7 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot) /* process the CFTABLE_ENTRY tuples, and any after those */ while ((!end_chain) && (address < 0x1000)) { if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, - &tupleLength, tuple)) < 0) + &tupleLength, tuple)) < 0) return status; switch (tupleType) { case 0x1B: // CISTPL_CFTABLE_ENTRY diff --git a/drivers/media/dvb/dvb-core/dvb_filter.c b/drivers/media/dvb/dvb-core/dvb_filter.c index bd5143906084..c49fd0bd7181 100644 --- a/drivers/media/dvb/dvb-core/dvb_filter.c +++ b/drivers/media/dvb/dvb-core/dvb_filter.c @@ -72,12 +72,12 @@ static int read_picture_header(u8 *headr, struct mpg_picture *pic, int field, in u8 pct; if (pr) printk( "Pic header: "); - pic->temporal_reference[field] = (( headr[0] << 2 ) | + pic->temporal_reference[field] = (( headr[0] << 2 ) | (headr[1] & 0x03) )& 0x03ff; if (pr) printk( " temp ref: 0x%04x", pic->temporal_reference[field]); pct = ( headr[1] >> 2 ) & 0x07; - pic->picture_coding_type[field] = pct; + pic->picture_coding_type[field] = pct; if (pr) { switch(pct){ case I_FRAME: @@ -93,17 +93,17 @@ static int read_picture_header(u8 *headr, struct mpg_picture *pic, int field, in } - pic->vinfo.vbv_delay = (( headr[1] >> 5 ) | ( headr[2] << 3) | + pic->vinfo.vbv_delay = (( headr[1] >> 5 ) | ( headr[2] << 3) | ( (headr[3] & 0x1F) << 11) ) & 0xffff; if (pr) printk( " vbv delay: 0x%04x", pic->vinfo.vbv_delay); - pic->picture_header_parameter = ( headr[3] & 0xe0 ) | + pic->picture_header_parameter = ( headr[3] & 0xe0 ) | ((headr[4] & 0x80) >> 3); - if ( pct == B_FRAME ){ - pic->picture_header_parameter |= ( headr[4] >> 3 ) & 0x0f; - } + if ( pct == B_FRAME ){ + pic->picture_header_parameter |= ( headr[4] >> 3 ) & 0x0f; + } if (pr) printk( " pic head param: 0x%x", pic->picture_header_parameter); @@ -124,18 +124,18 @@ static int read_gop_header(u8 *headr, struct mpg_picture *pic, int pr) ((headr[0]<<4)& 0x30)| ((headr[1]>>4)& 0x0F), ((headr[1]<<3)& 0x38)| ((headr[2]>>5)& 0x0F)); - if ( ( headr[3] & 0x40 ) != 0 ){ - pic->closed_gop = 1; - } else { - pic->closed_gop = 0; - } + if ( ( headr[3] & 0x40 ) != 0 ){ + pic->closed_gop = 1; + } else { + pic->closed_gop = 0; + } if (pr) printk("closed: %d", pic->closed_gop); - if ( ( headr[3] & 0x20 ) != 0 ){ - pic->broken_link = 1; - } else { - pic->broken_link = 0; - } + if ( ( headr[3] & 0x20 ) != 0 ){ + pic->broken_link = 1; + } else { + pic->broken_link = 0; + } if (pr) printk(" broken: %d\n", pic->broken_link); return 0; @@ -146,7 +146,7 @@ static int read_gop_header(u8 *headr, struct mpg_picture *pic, int pr) /* needs 8 byte input */ static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr) { - int sw; + int sw; int form = -1; if (pr) printk("Reading sequence header\n"); @@ -154,9 +154,9 @@ static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr) vi->horizontal_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4); vi->vertical_size = ((headr[1] &0x0F) << 8) | (headr[2]); - sw = (int)((headr[3]&0xF0) >> 4) ; + sw = (int)((headr[3]&0xF0) >> 4) ; - switch( sw ){ + switch( sw ){ case 1: if (pr) printk("Videostream: ASPECT: 1:1"); @@ -165,84 +165,84 @@ static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr) case 2: if (pr) printk("Videostream: ASPECT: 4:3"); - vi->aspect_ratio = 133; + vi->aspect_ratio = 133; break; case 3: if (pr) printk("Videostream: ASPECT: 16:9"); - vi->aspect_ratio = 177; + vi->aspect_ratio = 177; break; case 4: if (pr) printk("Videostream: ASPECT: 2.21:1"); - vi->aspect_ratio = 221; + vi->aspect_ratio = 221; break; - case 5 ... 15: + case 5 ... 15: if (pr) printk("Videostream: ASPECT: reserved"); - vi->aspect_ratio = 0; + vi->aspect_ratio = 0; break; - default: - vi->aspect_ratio = 0; - return -1; + default: + vi->aspect_ratio = 0; + return -1; } if (pr) printk(" Size = %dx%d",vi->horizontal_size,vi->vertical_size); - sw = (int)(headr[3]&0x0F); + sw = (int)(headr[3]&0x0F); - switch ( sw ) { + switch ( sw ) { case 1: if (pr) printk(" FRate: 23.976 fps"); - vi->framerate = 23976; + vi->framerate = 23976; form = -1; break; case 2: if (pr) printk(" FRate: 24 fps"); - vi->framerate = 24000; + vi->framerate = 24000; form = -1; break; case 3: if (pr) printk(" FRate: 25 fps"); - vi->framerate = 25000; + vi->framerate = 25000; form = VIDEO_MODE_PAL; break; case 4: if (pr) printk(" FRate: 29.97 fps"); - vi->framerate = 29970; + vi->framerate = 29970; form = VIDEO_MODE_NTSC; break; case 5: if (pr) printk(" FRate: 30 fps"); - vi->framerate = 30000; + vi->framerate = 30000; form = VIDEO_MODE_NTSC; break; case 6: if (pr) printk(" FRate: 50 fps"); - vi->framerate = 50000; + vi->framerate = 50000; form = VIDEO_MODE_PAL; break; case 7: if (pr) printk(" FRate: 60 fps"); - vi->framerate = 60000; + vi->framerate = 60000; form = VIDEO_MODE_NTSC; break; } vi->bit_rate = (headr[4] << 10) | (headr[5] << 2) | (headr[6] & 0x03); - vi->vbv_buffer_size - = (( headr[6] & 0xF8) >> 3 ) | (( headr[7] & 0x1F )<< 5); + vi->vbv_buffer_size + = (( headr[6] & 0xF8) >> 3 ) | (( headr[7] & 0x1F )<< 5); if (pr){ printk(" BRate: %d Mbit/s",4*(vi->bit_rate)/10000); @@ -250,7 +250,7 @@ static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr) printk("\n"); } - vi->video_format = form; + vi->video_format = form; return 0; } @@ -308,7 +308,7 @@ static int get_ainfo(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr) if (!found) return -1; if (c+3 >= count) return -1; - headr = mbuf+c; + headr = mbuf+c; ai->layer = (headr[1] & 0x06) >> 1; @@ -368,7 +368,7 @@ int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int p if (c+5 >= count) return -1; ai->layer = 0; // 0 for AC3 - headr = mbuf+c+2; + headr = mbuf+c+2; frame = (headr[2]&0x3f); ai->bit_rate = ac3_bitrates[frame >> 1]*1000; @@ -396,159 +396,159 @@ EXPORT_SYMBOL(dvb_filter_get_ac3info); #if 0 static u8 *skip_pes_header(u8 **bufp) { - u8 *inbuf = *bufp; - u8 *buf = inbuf; - u8 *pts = NULL; - int skip = 0; + u8 *inbuf = *bufp; + u8 *buf = inbuf; + u8 *pts = NULL; + int skip = 0; static const int mpeg1_skip_table[16] = { 1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff, - 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; - if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */ - if (buf[7] & PTS_ONLY) - pts = buf+9; - else pts = NULL; - buf = inbuf + 9 + inbuf[8]; - } else { /* mpeg1 */ - for (buf = inbuf + 6; *buf == 0xff; buf++) - if (buf == inbuf + 6 + 16) { - break; - } - if ((*buf & 0xc0) == 0x40) - buf += 2; - skip = mpeg1_skip_table [*buf >> 4]; - if (skip == 5 || skip == 10) pts = buf; - else pts = NULL; - - buf += mpeg1_skip_table [*buf >> 4]; - } - - *bufp = buf; - return pts; + if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */ + if (buf[7] & PTS_ONLY) + pts = buf+9; + else pts = NULL; + buf = inbuf + 9 + inbuf[8]; + } else { /* mpeg1 */ + for (buf = inbuf + 6; *buf == 0xff; buf++) + if (buf == inbuf + 6 + 16) { + break; + } + if ((*buf & 0xc0) == 0x40) + buf += 2; + skip = mpeg1_skip_table [*buf >> 4]; + if (skip == 5 || skip == 10) pts = buf; + else pts = NULL; + + buf += mpeg1_skip_table [*buf >> 4]; + } + + *bufp = buf; + return pts; } #endif #if 0 static void initialize_quant_matrix( u32 *matrix ) { - int i; - - matrix[0] = 0x08101013; - matrix[1] = 0x10131616; - matrix[2] = 0x16161616; - matrix[3] = 0x1a181a1b; - matrix[4] = 0x1b1b1a1a; - matrix[5] = 0x1a1a1b1b; - matrix[6] = 0x1b1d1d1d; - matrix[7] = 0x2222221d; - matrix[8] = 0x1d1d1b1b; - matrix[9] = 0x1d1d2020; - matrix[10] = 0x22222526; - matrix[11] = 0x25232322; - matrix[12] = 0x23262628; - matrix[13] = 0x28283030; - matrix[14] = 0x2e2e3838; - matrix[15] = 0x3a454553; - - for ( i = 16 ; i < 32 ; i++ ) - matrix[i] = 0x10101010; + int i; + + matrix[0] = 0x08101013; + matrix[1] = 0x10131616; + matrix[2] = 0x16161616; + matrix[3] = 0x1a181a1b; + matrix[4] = 0x1b1b1a1a; + matrix[5] = 0x1a1a1b1b; + matrix[6] = 0x1b1d1d1d; + matrix[7] = 0x2222221d; + matrix[8] = 0x1d1d1b1b; + matrix[9] = 0x1d1d2020; + matrix[10] = 0x22222526; + matrix[11] = 0x25232322; + matrix[12] = 0x23262628; + matrix[13] = 0x28283030; + matrix[14] = 0x2e2e3838; + matrix[15] = 0x3a454553; + + for ( i = 16 ; i < 32 ; i++ ) + matrix[i] = 0x10101010; } #endif #if 0 static void initialize_mpg_picture(struct mpg_picture *pic) { - int i; - - /* set MPEG1 */ - pic->mpeg1_flag = 1; - pic->profile_and_level = 0x4A ; /* MP@LL */ - pic->progressive_sequence = 1; - pic->low_delay = 0; - - pic->sequence_display_extension_flag = 0; - for ( i = 0 ; i < 4 ; i++ ){ - pic->frame_centre_horizontal_offset[i] = 0; - pic->frame_centre_vertical_offset[i] = 0; - } - pic->last_frame_centre_horizontal_offset = 0; - pic->last_frame_centre_vertical_offset = 0; - - pic->picture_display_extension_flag[0] = 0; - pic->picture_display_extension_flag[1] = 0; - pic->sequence_header_flag = 0; + int i; + + /* set MPEG1 */ + pic->mpeg1_flag = 1; + pic->profile_and_level = 0x4A ; /* MP@LL */ + pic->progressive_sequence = 1; + pic->low_delay = 0; + + pic->sequence_display_extension_flag = 0; + for ( i = 0 ; i < 4 ; i++ ){ + pic->frame_centre_horizontal_offset[i] = 0; + pic->frame_centre_vertical_offset[i] = 0; + } + pic->last_frame_centre_horizontal_offset = 0; + pic->last_frame_centre_vertical_offset = 0; + + pic->picture_display_extension_flag[0] = 0; + pic->picture_display_extension_flag[1] = 0; + pic->sequence_header_flag = 0; pic->gop_flag = 0; - pic->sequence_end_flag = 0; + pic->sequence_end_flag = 0; } #endif #if 0 static void mpg_set_picture_parameter( int32_t field_type, struct mpg_picture *pic ) { - int16_t last_h_offset; - int16_t last_v_offset; - - int16_t *p_h_offset; - int16_t *p_v_offset; - - if ( pic->mpeg1_flag ){ - pic->picture_structure[field_type] = VIDEO_FRAME_PICTURE; - pic->top_field_first = 0; - pic->repeat_first_field = 0; - pic->progressive_frame = 1; - pic->picture_coding_parameter = 0x000010; - } - - /* Reset flag */ - pic->picture_display_extension_flag[field_type] = 0; - - last_h_offset = pic->last_frame_centre_horizontal_offset; - last_v_offset = pic->last_frame_centre_vertical_offset; - if ( field_type == FIRST_FIELD ){ - p_h_offset = pic->frame_centre_horizontal_offset; - p_v_offset = pic->frame_centre_vertical_offset; - *p_h_offset = last_h_offset; - *(p_h_offset + 1) = last_h_offset; - *(p_h_offset + 2) = last_h_offset; - *p_v_offset = last_v_offset; - *(p_v_offset + 1) = last_v_offset; - *(p_v_offset + 2) = last_v_offset; - } else { - pic->frame_centre_horizontal_offset[3] = last_h_offset; - pic->frame_centre_vertical_offset[3] = last_v_offset; - } + int16_t last_h_offset; + int16_t last_v_offset; + + int16_t *p_h_offset; + int16_t *p_v_offset; + + if ( pic->mpeg1_flag ){ + pic->picture_structure[field_type] = VIDEO_FRAME_PICTURE; + pic->top_field_first = 0; + pic->repeat_first_field = 0; + pic->progressive_frame = 1; + pic->picture_coding_parameter = 0x000010; + } + + /* Reset flag */ + pic->picture_display_extension_flag[field_type] = 0; + + last_h_offset = pic->last_frame_centre_horizontal_offset; + last_v_offset = pic->last_frame_centre_vertical_offset; + if ( field_type == FIRST_FIELD ){ + p_h_offset = pic->frame_centre_horizontal_offset; + p_v_offset = pic->frame_centre_vertical_offset; + *p_h_offset = last_h_offset; + *(p_h_offset + 1) = last_h_offset; + *(p_h_offset + 2) = last_h_offset; + *p_v_offset = last_v_offset; + *(p_v_offset + 1) = last_v_offset; + *(p_v_offset + 2) = last_v_offset; + } else { + pic->frame_centre_horizontal_offset[3] = last_h_offset; + pic->frame_centre_vertical_offset[3] = last_v_offset; + } } #endif #if 0 static void init_mpg_picture( struct mpg_picture *pic, int chan, int32_t field_type) { - pic->picture_header = 0; - pic->sequence_header_data - = ( INIT_HORIZONTAL_SIZE << 20 ) - | ( INIT_VERTICAL_SIZE << 8 ) - | ( INIT_ASPECT_RATIO << 4 ) - | ( INIT_FRAME_RATE ); - pic->mpeg1_flag = 0; - pic->vinfo.horizontal_size - = INIT_DISP_HORIZONTAL_SIZE; - pic->vinfo.vertical_size - = INIT_DISP_VERTICAL_SIZE; - pic->picture_display_extension_flag[field_type] - = 0; - pic->pts_flag[field_type] = 0; - - pic->sequence_gop_header = 0; - pic->picture_header = 0; - pic->sequence_header_flag = 0; - pic->gop_flag = 0; - pic->sequence_end_flag = 0; - pic->sequence_display_extension_flag = 0; - pic->last_frame_centre_horizontal_offset = 0; - pic->last_frame_centre_vertical_offset = 0; + pic->picture_header = 0; + pic->sequence_header_data + = ( INIT_HORIZONTAL_SIZE << 20 ) + | ( INIT_VERTICAL_SIZE << 8 ) + | ( INIT_ASPECT_RATIO << 4 ) + | ( INIT_FRAME_RATE ); + pic->mpeg1_flag = 0; + pic->vinfo.horizontal_size + = INIT_DISP_HORIZONTAL_SIZE; + pic->vinfo.vertical_size + = INIT_DISP_VERTICAL_SIZE; + pic->picture_display_extension_flag[field_type] + = 0; + pic->pts_flag[field_type] = 0; + + pic->sequence_gop_header = 0; + pic->picture_header = 0; + pic->sequence_header_flag = 0; + pic->gop_flag = 0; + pic->sequence_end_flag = 0; + pic->sequence_display_extension_flag = 0; + pic->last_frame_centre_horizontal_offset = 0; + pic->last_frame_centre_vertical_offset = 0; pic->channel = chan; } #endif @@ -588,11 +588,11 @@ int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes, buf[1]&=~0x40; } if (!len) - return 0; + return 0; buf[3]=0x30|((p2ts->cc++)&0x0f); rest=183-len; if (rest) { - buf[5]=0x00; + buf[5]=0x00; if (rest-1) memset(buf+6, 0xff, rest-1); } diff --git a/drivers/media/dvb/dvb-core/dvb_filter.h b/drivers/media/dvb/dvb-core/dvb_filter.h index b0848f7836b7..375e3be184b1 100644 --- a/drivers/media/dvb/dvb-core/dvb_filter.h +++ b/drivers/media/dvb/dvb-core/dvb_filter.h @@ -29,8 +29,8 @@ typedef int (dvb_filter_pes2ts_cb_t) (void *, unsigned char *); struct dvb_filter_pes2ts { unsigned char buf[188]; - unsigned char cc; - dvb_filter_pes2ts_cb_t *cb; + unsigned char cc; + dvb_filter_pes2ts_cb_t *cb; void *priv; }; @@ -162,7 +162,7 @@ struct dvb_video_info { u32 bit_rate; u32 comp_bit_rate; u32 vbv_buffer_size; - s16 vbv_delay; + s16 vbv_delay; u32 CSPF; u32 off; }; @@ -173,60 +173,60 @@ struct dvb_video_info { #define VIDEO_FRAME_PICTURE 0x03 struct mpg_picture { - int channel; + int channel; struct dvb_video_info vinfo; - u32 *sequence_gop_header; - u32 *picture_header; - s32 time_code; - int low_delay; - int closed_gop; - int broken_link; - int sequence_header_flag; - int gop_flag; - int sequence_end_flag; - - u8 profile_and_level; - s32 picture_coding_parameter; - u32 matrix[32]; - s8 matrix_change_flag; - - u8 picture_header_parameter; + u32 *sequence_gop_header; + u32 *picture_header; + s32 time_code; + int low_delay; + int closed_gop; + int broken_link; + int sequence_header_flag; + int gop_flag; + int sequence_end_flag; + + u8 profile_and_level; + s32 picture_coding_parameter; + u32 matrix[32]; + s8 matrix_change_flag; + + u8 picture_header_parameter; /* bit 0 - 2: bwd f code bit 3 : fpb vector bit 4 - 6: fwd f code bit 7 : fpf vector */ - int mpeg1_flag; - int progressive_sequence; - int sequence_display_extension_flag; - u32 sequence_header_data; - s16 last_frame_centre_horizontal_offset; - s16 last_frame_centre_vertical_offset; - - u32 pts[2]; /* [0] 1st field, [1] 2nd field */ - int top_field_first; - int repeat_first_field; - int progressive_frame; - int bank; - int forward_bank; - int backward_bank; - int compress; - s16 frame_centre_horizontal_offset[OFF_SIZE]; - /* [0-2] 1st field, [3] 2nd field */ - s16 frame_centre_vertical_offset[OFF_SIZE]; - /* [0-2] 1st field, [3] 2nd field */ - s16 temporal_reference[2]; - /* [0] 1st field, [1] 2nd field */ - - s8 picture_coding_type[2]; - /* [0] 1st field, [1] 2nd field */ - s8 picture_structure[2]; - /* [0] 1st field, [1] 2nd field */ - s8 picture_display_extension_flag[2]; - /* [0] 1st field, [1] 2nd field */ - /* picture_display_extenion() 0:no 1:exit*/ - s8 pts_flag[2]; - /* [0] 1st field, [1] 2nd field */ + int mpeg1_flag; + int progressive_sequence; + int sequence_display_extension_flag; + u32 sequence_header_data; + s16 last_frame_centre_horizontal_offset; + s16 last_frame_centre_vertical_offset; + + u32 pts[2]; /* [0] 1st field, [1] 2nd field */ + int top_field_first; + int repeat_first_field; + int progressive_frame; + int bank; + int forward_bank; + int backward_bank; + int compress; + s16 frame_centre_horizontal_offset[OFF_SIZE]; + /* [0-2] 1st field, [3] 2nd field */ + s16 frame_centre_vertical_offset[OFF_SIZE]; + /* [0-2] 1st field, [3] 2nd field */ + s16 temporal_reference[2]; + /* [0] 1st field, [1] 2nd field */ + + s8 picture_coding_type[2]; + /* [0] 1st field, [1] 2nd field */ + s8 picture_structure[2]; + /* [0] 1st field, [1] 2nd field */ + s8 picture_display_extension_flag[2]; + /* [0] 1st field, [1] 2nd field */ + /* picture_display_extenion() 0:no 1:exit*/ + s8 pts_flag[2]; + /* [0] 1st field, [1] 2nd field */ }; struct dvb_audio_info { diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 6ffa6b216363..95ea5095e07e 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -372,10 +372,10 @@ static int dvb_frontend_thread(void *data) snprintf (name, sizeof(name), "kdvb-fe-%i", fe->dvb->num); - lock_kernel(); - daemonize(name); - sigfillset(¤t->blocked); - unlock_kernel(); + lock_kernel(); + daemonize(name); + sigfillset(¤t->blocked); + unlock_kernel(); fepriv->status = 0; dvb_frontend_init(fe); diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h index 348c9b0b988a..1e0840d02f1f 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/drivers/media/dvb/dvb-core/dvb_frontend.h @@ -41,10 +41,10 @@ #include "dvbdev.h" struct dvb_frontend_tune_settings { - int min_delay_ms; - int step_size; - int max_drift; - struct dvb_frontend_parameters parameters; + int min_delay_ms; + int step_size; + int max_drift; + struct dvb_frontend_parameters parameters; }; struct dvb_frontend; diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index df536bd2e103..86bba81e851e 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -713,7 +713,7 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len, if (buffer1_len > 32768) printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len); /* printk("TS callback: %u bytes, %u TS cells @ %p.\n", - buffer1_len, buffer1_len / TS_SZ, buffer1); */ + buffer1_len, buffer1_len / TS_SZ, buffer1); */ dvb_net_ule(dev, buffer1, buffer1_len); return 0; } @@ -721,8 +721,8 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len, static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) { - u8 *eth; - struct sk_buff *skb; + u8 *eth; + struct sk_buff *skb; struct net_device_stats *stats = &(((struct dvb_net_priv *) dev->priv)->stats); int snap = 0; @@ -754,7 +754,7 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) return; } snap = 8; - } + } if (pkt[7]) { /* FIXME: assemble datagram from multiple sections */ stats->rx_errors++; @@ -778,14 +778,14 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap); /* create ethernet header: */ - eth[0]=pkt[0x0b]; - eth[1]=pkt[0x0a]; - eth[2]=pkt[0x09]; - eth[3]=pkt[0x08]; - eth[4]=pkt[0x04]; - eth[5]=pkt[0x03]; + eth[0]=pkt[0x0b]; + eth[1]=pkt[0x0a]; + eth[2]=pkt[0x09]; + eth[3]=pkt[0x08]; + eth[4]=pkt[0x04]; + eth[5]=pkt[0x03]; - eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0; + eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0; if (snap) { eth[12] = pkt[18]; @@ -807,7 +807,7 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) stats->rx_packets++; stats->rx_bytes+=skb->len; - netif_rx(skb); + netif_rx(skb); } static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len, @@ -815,7 +815,7 @@ static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len, struct dmx_section_filter *filter, enum dmx_success success) { - struct net_device *dev = filter->priv; + struct net_device *dev = filter->priv; /** * we rely on the DVB API definition where exactly one complete @@ -885,8 +885,8 @@ static int dvb_net_feed_start(struct net_device *dev) { int ret = 0, i; struct dvb_net_priv *priv = dev->priv; - struct dmx_demux *demux = priv->demux; - unsigned char *mac = (unsigned char *) dev->dev_addr; + struct dmx_demux *demux = priv->demux; + unsigned char *mac = (unsigned char *) dev->dev_addr; dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode); down(&priv->mutex); @@ -1129,12 +1129,12 @@ static int dvb_net_stop(struct net_device *dev) struct dvb_net_priv *priv = dev->priv; priv->in_use--; - return dvb_net_feed_stop(dev); + return dvb_net_feed_stop(dev); } static struct net_device_stats * dvb_net_get_stats(struct net_device *dev) { - return &((struct dvb_net_priv*) dev->priv)->stats; + return &((struct dvb_net_priv*) dev->priv)->stats; } static void dvb_net_setup(struct net_device *dev) @@ -1360,10 +1360,10 @@ static struct file_operations dvb_net_fops = { }; static struct dvb_device dvbdev_net = { - .priv = NULL, - .users = 1, - .writers = 1, - .fops = &dvb_net_fops, + .priv = NULL, + .users = 1, + .writers = 1, + .fops = &dvb_net_fops, }; diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c index fb6d94a69d71..283c6e9339a4 100644 --- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c +++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c @@ -42,216 +42,216 @@ void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len) { - rbuf->pread=rbuf->pwrite=0; - rbuf->data=data; - rbuf->size=len; + rbuf->pread=rbuf->pwrite=0; + rbuf->data=data; + rbuf->size=len; - init_waitqueue_head(&rbuf->queue); + init_waitqueue_head(&rbuf->queue); - spin_lock_init(&(rbuf->lock)); + spin_lock_init(&(rbuf->lock)); } int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf) { - return (rbuf->pread==rbuf->pwrite); + return (rbuf->pread==rbuf->pwrite); } ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf) { - ssize_t free; + ssize_t free; - free = rbuf->pread - rbuf->pwrite; - if (free <= 0) - free += rbuf->size; - return free-1; + free = rbuf->pread - rbuf->pwrite; + if (free <= 0) + free += rbuf->size; + return free-1; } ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf) { - ssize_t avail; + ssize_t avail; - avail = rbuf->pwrite - rbuf->pread; - if (avail < 0) - avail += rbuf->size; - return avail; + avail = rbuf->pwrite - rbuf->pread; + if (avail < 0) + avail += rbuf->size; + return avail; } void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf) { - rbuf->pread = rbuf->pwrite; + rbuf->pread = rbuf->pwrite; } void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf) { - unsigned long flags; + unsigned long flags; - spin_lock_irqsave(&rbuf->lock, flags); - dvb_ringbuffer_flush(rbuf); - spin_unlock_irqrestore(&rbuf->lock, flags); + spin_lock_irqsave(&rbuf->lock, flags); + dvb_ringbuffer_flush(rbuf); + spin_unlock_irqrestore(&rbuf->lock, flags); - wake_up(&rbuf->queue); + wake_up(&rbuf->queue); } ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, size_t len, int usermem) { - size_t todo = len; - size_t split; - - split = (rbuf->pread + len > rbuf->size) ? rbuf->size - rbuf->pread : 0; - if (split > 0) { - if (!usermem) - memcpy(buf, rbuf->data+rbuf->pread, split); - else - if (copy_to_user(buf, rbuf->data+rbuf->pread, split)) - return -EFAULT; - buf += split; - todo -= split; - rbuf->pread = 0; - } - if (!usermem) - memcpy(buf, rbuf->data+rbuf->pread, todo); - else - if (copy_to_user(buf, rbuf->data+rbuf->pread, todo)) - return -EFAULT; - - rbuf->pread = (rbuf->pread + todo) % rbuf->size; - - return len; + size_t todo = len; + size_t split; + + split = (rbuf->pread + len > rbuf->size) ? rbuf->size - rbuf->pread : 0; + if (split > 0) { + if (!usermem) + memcpy(buf, rbuf->data+rbuf->pread, split); + else + if (copy_to_user(buf, rbuf->data+rbuf->pread, split)) + return -EFAULT; + buf += split; + todo -= split; + rbuf->pread = 0; + } + if (!usermem) + memcpy(buf, rbuf->data+rbuf->pread, todo); + else + if (copy_to_user(buf, rbuf->data+rbuf->pread, todo)) + return -EFAULT; + + rbuf->pread = (rbuf->pread + todo) % rbuf->size; + + return len; } ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, size_t len) { - size_t todo = len; - size_t split; + size_t todo = len; + size_t split; - split = (rbuf->pwrite + len > rbuf->size) ? rbuf->size - rbuf->pwrite : 0; + split = (rbuf->pwrite + len > rbuf->size) ? rbuf->size - rbuf->pwrite : 0; - if (split > 0) { - memcpy(rbuf->data+rbuf->pwrite, buf, split); - buf += split; - todo -= split; - rbuf->pwrite = 0; - } - memcpy(rbuf->data+rbuf->pwrite, buf, todo); - rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size; + if (split > 0) { + memcpy(rbuf->data+rbuf->pwrite, buf, split); + buf += split; + todo -= split; + rbuf->pwrite = 0; + } + memcpy(rbuf->data+rbuf->pwrite, buf, todo); + rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size; - return len; + return len; } ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, size_t len) { - int status; - ssize_t oldpwrite = rbuf->pwrite; + int status; + ssize_t oldpwrite = rbuf->pwrite; - DVB_RINGBUFFER_WRITE_BYTE(rbuf, len >> 8); - DVB_RINGBUFFER_WRITE_BYTE(rbuf, len & 0xff); - DVB_RINGBUFFER_WRITE_BYTE(rbuf, PKT_READY); - status = dvb_ringbuffer_write(rbuf, buf, len); + DVB_RINGBUFFER_WRITE_BYTE(rbuf, len >> 8); + DVB_RINGBUFFER_WRITE_BYTE(rbuf, len & 0xff); + DVB_RINGBUFFER_WRITE_BYTE(rbuf, PKT_READY); + status = dvb_ringbuffer_write(rbuf, buf, len); - if (status < 0) rbuf->pwrite = oldpwrite; - return status; + if (status < 0) rbuf->pwrite = oldpwrite; + return status; } ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx, - int offset, u8* buf, size_t len, int usermem) + int offset, u8* buf, size_t len, int usermem) { - size_t todo; - size_t split; - size_t pktlen; - - pktlen = rbuf->data[idx] << 8; - pktlen |= rbuf->data[(idx + 1) % rbuf->size]; - if (offset > pktlen) return -EINVAL; - if ((offset + len) > pktlen) len = pktlen - offset; - - idx = (idx + DVB_RINGBUFFER_PKTHDRSIZE + offset) % rbuf->size; - todo = len; - split = ((idx + len) > rbuf->size) ? rbuf->size - idx : 0; - if (split > 0) { - if (!usermem) - memcpy(buf, rbuf->data+idx, split); - else - if (copy_to_user(buf, rbuf->data+idx, split)) - return -EFAULT; - buf += split; - todo -= split; - idx = 0; - } - if (!usermem) - memcpy(buf, rbuf->data+idx, todo); - else - if (copy_to_user(buf, rbuf->data+idx, todo)) - return -EFAULT; - - return len; + size_t todo; + size_t split; + size_t pktlen; + + pktlen = rbuf->data[idx] << 8; + pktlen |= rbuf->data[(idx + 1) % rbuf->size]; + if (offset > pktlen) return -EINVAL; + if ((offset + len) > pktlen) len = pktlen - offset; + + idx = (idx + DVB_RINGBUFFER_PKTHDRSIZE + offset) % rbuf->size; + todo = len; + split = ((idx + len) > rbuf->size) ? rbuf->size - idx : 0; + if (split > 0) { + if (!usermem) + memcpy(buf, rbuf->data+idx, split); + else + if (copy_to_user(buf, rbuf->data+idx, split)) + return -EFAULT; + buf += split; + todo -= split; + idx = 0; + } + if (!usermem) + memcpy(buf, rbuf->data+idx, todo); + else + if (copy_to_user(buf, rbuf->data+idx, todo)) + return -EFAULT; + + return len; } void dvb_ringbuffer_pkt_dispose(struct dvb_ringbuffer *rbuf, size_t idx) { - size_t pktlen; - - rbuf->data[(idx + 2) % rbuf->size] = PKT_DISPOSED; - - // clean up disposed packets - while(dvb_ringbuffer_avail(rbuf) > DVB_RINGBUFFER_PKTHDRSIZE) { - if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) { - pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8; - pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1); - DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE); - } else { - // first packet is not disposed, so we stop cleaning now - break; - } - } + size_t pktlen; + + rbuf->data[(idx + 2) % rbuf->size] = PKT_DISPOSED; + + // clean up disposed packets + while(dvb_ringbuffer_avail(rbuf) > DVB_RINGBUFFER_PKTHDRSIZE) { + if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) { + pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8; + pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1); + DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE); + } else { + // first packet is not disposed, so we stop cleaning now + break; + } + } } ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t* pktlen) { - int consumed; - int curpktlen; - int curpktstatus; + int consumed; + int curpktlen; + int curpktstatus; - if (idx == -1) { + if (idx == -1) { idx = rbuf->pread; } else { - curpktlen = rbuf->data[idx] << 8; - curpktlen |= rbuf->data[(idx + 1) % rbuf->size]; - idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size; + curpktlen = rbuf->data[idx] << 8; + curpktlen |= rbuf->data[(idx + 1) % rbuf->size]; + idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size; } - consumed = (idx - rbuf->pread) % rbuf->size; + consumed = (idx - rbuf->pread) % rbuf->size; - while((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) { + while((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) { - curpktlen = rbuf->data[idx] << 8; - curpktlen |= rbuf->data[(idx + 1) % rbuf->size]; - curpktstatus = rbuf->data[(idx + 2) % rbuf->size]; + curpktlen = rbuf->data[idx] << 8; + curpktlen |= rbuf->data[(idx + 1) % rbuf->size]; + curpktstatus = rbuf->data[(idx + 2) % rbuf->size]; - if (curpktstatus == PKT_READY) { - *pktlen = curpktlen; - return idx; - } + if (curpktstatus == PKT_READY) { + *pktlen = curpktlen; + return idx; + } - consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE; - idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size; - } + consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE; + idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size; + } - // no packets available - return -1; + // no packets available + return -1; } diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h index d18e9c4ba9ea..fa476f662f82 100644 --- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h +++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h @@ -31,13 +31,13 @@ #include <linux/wait.h> struct dvb_ringbuffer { - u8 *data; - ssize_t size; - ssize_t pread; - ssize_t pwrite; + u8 *data; + ssize_t size; + ssize_t pread; + ssize_t pwrite; - wait_queue_head_t queue; - spinlock_t lock; + wait_queue_head_t queue; + spinlock_t lock; }; #define DVB_RINGBUFFER_PKTHDRSIZE 3 @@ -106,7 +106,7 @@ extern void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf); ** returns number of bytes transferred or -EFAULT */ extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, - size_t len, int usermem); + size_t len, int usermem); /* write routines & macros */ @@ -121,7 +121,7 @@ extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, ** returns number of bytes transferred or -EFAULT */ extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, - size_t len); + size_t len); /** @@ -133,7 +133,7 @@ extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, * returns Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL. */ extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, - size_t len); + size_t len); /** * Read from a packet in the ringbuffer. Note: unlike dvb_ringbuffer_read(), this @@ -149,7 +149,7 @@ extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, * returns Number of bytes read, or -EFAULT. */ extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx, - int offset, u8* buf, size_t len, int usermem); + int offset, u8* buf, size_t len, int usermem); /** * Dispose of a packet in the ring buffer. diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 477b4fa56430..a4aee8665854 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c @@ -47,7 +47,7 @@ static LIST_HEAD(dvb_adapter_list); static DECLARE_MUTEX(dvbdev_register_lock); static const char * const dnames[] = { - "video", "audio", "sec", "frontend", "demux", "dvr", "ca", + "video", "audio", "sec", "frontend", "demux", "dvr", "ca", "net", "osd" }; @@ -90,15 +90,15 @@ static int dvb_device_open(struct inode *inode, struct file *file) file->private_data = dvbdev; old_fops = file->f_op; - file->f_op = fops_get(dvbdev->fops); - if(file->f_op->open) - err = file->f_op->open(inode,file); - if (err) { - fops_put(file->f_op); - file->f_op = fops_get(old_fops); - } - fops_put(old_fops); - return err; + file->f_op = fops_get(dvbdev->fops); + if(file->f_op->open) + err = file->f_op->open(inode,file); + if (err) { + fops_put(file->f_op); + file->f_op = fops_get(old_fops); + } + fops_put(old_fops); + return err; } return -ENODEV; } @@ -117,21 +117,21 @@ static struct cdev dvb_device_cdev = { int dvb_generic_open(struct inode *inode, struct file *file) { - struct dvb_device *dvbdev = file->private_data; + struct dvb_device *dvbdev = file->private_data; - if (!dvbdev) - return -ENODEV; + if (!dvbdev) + return -ENODEV; if (!dvbdev->users) - return -EBUSY; + return -EBUSY; if ((file->f_flags & O_ACCMODE) == O_RDONLY) { - if (!dvbdev->readers) - return -EBUSY; + if (!dvbdev->readers) + return -EBUSY; dvbdev->readers--; } else { - if (!dvbdev->writers) - return -EBUSY; + if (!dvbdev->writers) + return -EBUSY; dvbdev->writers--; } @@ -143,10 +143,10 @@ EXPORT_SYMBOL(dvb_generic_open); int dvb_generic_release(struct inode *inode, struct file *file) { - struct dvb_device *dvbdev = file->private_data; + struct dvb_device *dvbdev = file->private_data; if (!dvbdev) - return -ENODEV; + return -ENODEV; if ((file->f_flags & O_ACCMODE) == O_RDONLY) { dvbdev->readers++; @@ -163,10 +163,10 @@ EXPORT_SYMBOL(dvb_generic_release); int dvb_generic_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { - struct dvb_device *dvbdev = file->private_data; + struct dvb_device *dvbdev = file->private_data; - if (!dvbdev) - return -ENODEV; + if (!dvbdev) + return -ENODEV; if (!dvbdev->kernel_ioctl) return -EINVAL; @@ -334,63 +334,63 @@ EXPORT_SYMBOL(dvb_unregister_adapter); to the v4l "videodev.o" module, which is unnecessary for some cards (ie. the budget dvb-cards don't need the v4l module...) */ int dvb_usercopy(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, + unsigned int cmd, unsigned long arg, int (*func)(struct inode *inode, struct file *file, unsigned int cmd, void *arg)) { - char sbuf[128]; - void *mbuf = NULL; - void *parg = NULL; - int err = -EINVAL; - - /* Copy arguments into temp kernel buffer */ - switch (_IOC_DIR(cmd)) { - case _IOC_NONE: + char sbuf[128]; + void *mbuf = NULL; + void *parg = NULL; + int err = -EINVAL; + + /* Copy arguments into temp kernel buffer */ + switch (_IOC_DIR(cmd)) { + case _IOC_NONE: /* * For this command, the pointer is actually an integer * argument. */ parg = (void *) arg; break; - case _IOC_READ: /* some v4l ioctls are marked wrong ... */ - case _IOC_WRITE: - case (_IOC_WRITE | _IOC_READ): - if (_IOC_SIZE(cmd) <= sizeof(sbuf)) { - parg = sbuf; - } else { - /* too big to allocate from stack */ - mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); - if (NULL == mbuf) - return -ENOMEM; - parg = mbuf; - } - - err = -EFAULT; - if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) - goto out; - break; - } - - /* call driver */ - if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD) - err = -EINVAL; - - if (err < 0) - goto out; - - /* Copy results into user buffer */ - switch (_IOC_DIR(cmd)) - { - case _IOC_READ: - case (_IOC_WRITE | _IOC_READ): - if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) - err = -EFAULT; - break; - } + case _IOC_READ: /* some v4l ioctls are marked wrong ... */ + case _IOC_WRITE: + case (_IOC_WRITE | _IOC_READ): + if (_IOC_SIZE(cmd) <= sizeof(sbuf)) { + parg = sbuf; + } else { + /* too big to allocate from stack */ + mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); + if (NULL == mbuf) + return -ENOMEM; + parg = mbuf; + } + + err = -EFAULT; + if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) + goto out; + break; + } + + /* call driver */ + if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD) + err = -EINVAL; + + if (err < 0) + goto out; + + /* Copy results into user buffer */ + switch (_IOC_DIR(cmd)) + { + case _IOC_READ: + case (_IOC_WRITE | _IOC_READ): + if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) + err = -EFAULT; + break; + } out: - kfree(mbuf); - return err; + kfree(mbuf); + return err; } static int __init init_dvbdev(void) @@ -427,10 +427,10 @@ error: static void __exit exit_dvbdev(void) { - devfs_remove("dvb"); + devfs_remove("dvb"); class_destroy(dvb_class); cdev_del(&dvb_device_cdev); - unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); + unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); } module_init(init_dvbdev); diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h index a251867f30f1..0cc6e4a0e27c 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.h +++ b/drivers/media/dvb/dvb-core/dvbdev.h @@ -68,8 +68,8 @@ struct dvb_device { int writers; int users; - /* don't really need those !? -- FIXME: use video_usercopy */ - int (*kernel_ioctl)(struct inode *inode, struct file *file, + /* don't really need those !? -- FIXME: use video_usercopy */ + int (*kernel_ioctl)(struct inode *inode, struct file *file, unsigned int cmd, void *arg); void *priv; @@ -97,7 +97,7 @@ we simply define out own dvb_usercopy(), which will hopefully become generic_usercopy() someday... */ extern int dvb_usercopy(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, + unsigned int cmd, unsigned long arg, int (*func)(struct inode *inode, struct file *file, unsigned int cmd, void *arg)); |