Commit dad4a730 authored by Andreas Oberritter's avatar Andreas Oberritter Committed by Linus Torvalds

[PATCH] dvb: core: dvb_demux formatting fixes

Formatting fixes (Lindent + some handwork).
Signed-off-by: default avatarAndreas Oberritter <obi@linuxtv.org>
Signed-off-by: default avatarJohannes Stezenbach <js@linuxtv.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent db574d7d
...@@ -38,55 +38,52 @@ ...@@ -38,55 +38,52 @@
*/ */
// #define DVB_DEMUX_SECTION_LOSS_LOG // #define DVB_DEMUX_SECTION_LOSS_LOG
/****************************************************************************** /******************************************************************************
* static inlined helper functions * static inlined helper functions
******************************************************************************/ ******************************************************************************/
static inline u16 section_length(const u8 *buf) static inline u16 section_length(const u8 *buf)
{ {
return 3+((buf[1]&0x0f)<<8)+buf[2]; return 3 + ((buf[1] & 0x0f) << 8) + buf[2];
} }
static inline u16 ts_pid(const u8 *buf) static inline u16 ts_pid(const u8 *buf)
{ {
return ((buf[1]&0x1f)<<8)+buf[2]; return ((buf[1] & 0x1f) << 8) + buf[2];
} }
static inline u8 payload(const u8 *tsp) static inline u8 payload(const u8 *tsp)
{ {
if (!(tsp[3] & 0x10)) // no payload? if (!(tsp[3] & 0x10)) // no payload?
return 0; return 0;
if (tsp[3] & 0x20) { // adaptation field? if (tsp[3] & 0x20) { // adaptation field?
if (tsp[4] > 183) // corrupted data? if (tsp[4] > 183) // corrupted data?
return 0; return 0;
else else
return 184-1-tsp[4]; return 184 - 1 - tsp[4];
} }
return 184; return 184;
} }
static u32 dvb_dmx_crc32(struct dvb_demux_feed *f, const u8 *src, size_t len)
static u32 dvb_dmx_crc32 (struct dvb_demux_feed *f, const u8 *src, size_t len)
{ {
return (f->feed.sec.crc_val = crc32_be (f->feed.sec.crc_val, src, len)); return (f->feed.sec.crc_val = crc32_be(f->feed.sec.crc_val, src, len));
} }
static void dvb_dmx_memcopy(struct dvb_demux_feed *f, u8 *d, const u8 *s,
static void dvb_dmx_memcopy (struct dvb_demux_feed *f, u8 *d, const u8 *s, size_t len) size_t len)
{ {
memcpy (d, s, len); memcpy(d, s, len);
} }
/****************************************************************************** /******************************************************************************
* Software filter functions * Software filter functions
******************************************************************************/ ******************************************************************************/
static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u8 *buf) static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed,
const u8 *buf)
{ {
int count = payload(buf); int count = payload(buf);
int p; int p;
...@@ -96,12 +93,12 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u ...@@ -96,12 +93,12 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u
if (count == 0) if (count == 0)
return -1; return -1;
p = 188-count; p = 188 - count;
/* /*
cc=buf[3]&0x0f; cc = buf[3] & 0x0f;
ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0; ccok = ((feed->cc + 1) & 0x0f) == cc;
dvbdmxfeed->cc=cc; feed->cc = cc;
if (!ccok) if (!ccok)
printk("missed packet!\n"); printk("missed packet!\n");
*/ */
...@@ -111,17 +108,16 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u ...@@ -111,17 +108,16 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u
feed->peslen += count; feed->peslen += count;
return feed->cb.ts (&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); return feed->cb.ts(&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK);
} }
static int dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *feed,
static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed,
struct dvb_demux_filter *f) struct dvb_demux_filter *f)
{ {
u8 neq = 0; u8 neq = 0;
int i; int i;
for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i]; u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i];
if (f->maskandmode[i] & xor) if (f->maskandmode[i] & xor)
...@@ -133,12 +129,11 @@ static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, ...@@ -133,12 +129,11 @@ static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed,
if (f->doneq && !neq) if (f->doneq && !neq)
return 0; return 0;
return feed->cb.sec (feed->feed.sec.secbuf, feed->feed.sec.seclen, return feed->cb.sec(feed->feed.sec.secbuf, feed->feed.sec.seclen,
NULL, 0, &f->filter, DMX_OK); NULL, 0, &f->filter, DMX_OK);
} }
static inline int dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *feed)
static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed)
{ {
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
struct dvb_demux_filter *f = feed->filter; struct dvb_demux_filter *f = feed->filter;
...@@ -168,26 +163,24 @@ static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) ...@@ -168,26 +163,24 @@ static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed)
return 0; return 0;
} }
static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
{ {
struct dmx_section_feed *sec = &feed->feed.sec; struct dmx_section_feed *sec = &feed->feed.sec;
#ifdef DVB_DEMUX_SECTION_LOSS_LOG #ifdef DVB_DEMUX_SECTION_LOSS_LOG
if(sec->secbufp < sec->tsfeedp) if (sec->secbufp < sec->tsfeedp) {
{
int i, n = sec->tsfeedp - sec->secbufp; int i, n = sec->tsfeedp - sec->secbufp;
/* section padding is done with 0xff bytes entirely. /*
** due to speed reasons, we won't check all of them * Section padding is done with 0xff bytes entirely.
** but just first and last * Due to speed reasons, we won't check all of them
* but just first and last.
*/ */
if(sec->secbuf[0] != 0xff || sec->secbuf[n-1] != 0xff) if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) {
{
printk("dvb_demux.c section ts padding loss: %d/%d\n", printk("dvb_demux.c section ts padding loss: %d/%d\n",
n, sec->tsfeedp); n, sec->tsfeedp);
printk("dvb_demux.c pad data:"); printk("dvb_demux.c pad data:");
for(i = 0; i < n; i++) for (i = 0; i < n; i++)
printk(" %02x", sec->secbuf[i]); printk(" %02x", sec->secbuf[i]);
printk("\n"); printk("\n");
} }
...@@ -199,82 +192,81 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) ...@@ -199,82 +192,81 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
} }
/* /*
** Losless Section Demux 1.4.1 by Emard * Losless Section Demux 1.4.1 by Emard
** Valsecchi Patrick: * Valsecchi Patrick:
** - middle of section A (no PUSI) * - middle of section A (no PUSI)
** - end of section A and start of section B * - end of section A and start of section B
** (with PUSI pointing to the start of the second section) * (with PUSI pointing to the start of the second section)
** *
** In this case, without feed->pusi_seen you'll receive a garbage section * In this case, without feed->pusi_seen you'll receive a garbage section
** consisting of the end of section A. Basically because tsfeedp * consisting of the end of section A. Basically because tsfeedp
** is incemented and the use=0 condition is not raised * is incemented and the use=0 condition is not raised
** when the second packet arrives. * when the second packet arrives.
** *
** Fix: * Fix:
** when demux is started, let feed->pusi_seen = 0 to * when demux is started, let feed->pusi_seen = 0 to
** prevent initial feeding of garbage from the end of * prevent initial feeding of garbage from the end of
** previous section. When you for the first time see PUSI=1 * previous section. When you for the first time see PUSI=1
** then set feed->pusi_seen = 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)
{ {
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
struct dmx_section_feed *sec = &feed->feed.sec; struct dmx_section_feed *sec = &feed->feed.sec;
u16 limit, seclen, n; u16 limit, seclen, n;
if(sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
return 0; return 0;
if(sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
{
#ifdef DVB_DEMUX_SECTION_LOSS_LOG #ifdef DVB_DEMUX_SECTION_LOSS_LOG
printk("dvb_demux.c section buffer full loss: %d/%d\n", printk("dvb_demux.c section buffer full loss: %d/%d\n",
sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, DMX_MAX_SECFEED_SIZE); sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE,
DMX_MAX_SECFEED_SIZE);
#endif #endif
len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp; len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp;
} }
if(len <= 0) if (len <= 0)
return 0; return 0;
demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len); demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len);
sec->tsfeedp += len; sec->tsfeedp += len;
/* ----------------------------------------------------- /*
** Dump all the sections we can find in the data (Emard) * Dump all the sections we can find in the data (Emard)
*/ */
limit = sec->tsfeedp; limit = sec->tsfeedp;
if(limit > DMX_MAX_SECFEED_SIZE) if (limit > DMX_MAX_SECFEED_SIZE)
return -1; /* internal error should never happen */ return -1; /* internal error should never happen */
/* to be sure always set secbuf */ /* to be sure always set secbuf */
sec->secbuf = sec->secbuf_base + sec->secbufp; sec->secbuf = sec->secbuf_base + sec->secbufp;
for(n = 0; sec->secbufp + 2 < limit; n++) for (n = 0; sec->secbufp + 2 < limit; n++) {
{
seclen = section_length(sec->secbuf); seclen = section_length(sec->secbuf);
if(seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE if (seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE
|| seclen + sec->secbufp > limit) || seclen + sec->secbufp > limit)
return 0; return 0;
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) if (feed->pusi_seen)
dvb_dmx_swfilter_section_feed(feed); dvb_dmx_swfilter_section_feed(feed);
#ifdef DVB_DEMUX_SECTION_LOSS_LOG #ifdef DVB_DEMUX_SECTION_LOSS_LOG
else else
printk("dvb_demux.c pusi not seen, discarding section data\n"); printk("dvb_demux.c pusi not seen, discarding section data\n");
#endif #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; /* redundant but saves pointer arithmetic */
} }
return 0; return 0;
} }
static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf) const u8 *buf)
{ {
u8 p, count; u8 p, count;
int ccok, dc_i = 0; int ccok, dc_i = 0;
...@@ -299,51 +291,53 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 ...@@ -299,51 +291,53 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8
if (!ccok || dc_i) { 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",
/* those bytes under sume circumstances will again be reported count);
** in the following dvb_dmx_swfilter_section_new /*
* those bytes under sume circumstances will again be reported
* 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 * Discontinuity detected. Reset pusi_seen = 0 to
* stop feeding of suspicious data until next PUSI=1 arrives
*/ */
feed->pusi_seen = 0; feed->pusi_seen = 0;
dvb_dmx_swfilter_section_new(feed); dvb_dmx_swfilter_section_new(feed);
} }
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 */ /* before start of new section, set pusi_seen = 1 */
feed->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);
} }
#ifdef DVB_DEMUX_SECTION_LOSS_LOG #ifdef DVB_DEMUX_SECTION_LOSS_LOG
else else 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; dvb_dmx_swfilter_section_copy_dump(feed, &buf[p], count);
u8 entire_len = count;
dvb_dmx_swfilter_section_copy_dump(feed, entire, entire_len);
} }
return 0; return 0;
} }
static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed,
static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf) const u8 *buf)
{ {
switch(feed->type) { switch (feed->type) {
case DMX_TYPE_TS: case DMX_TYPE_TS:
if (!feed->feed.ts.is_filtering) if (!feed->feed.ts.is_filtering)
break; break;
...@@ -351,7 +345,8 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con ...@@ -351,7 +345,8 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con
if (feed->ts_type & TS_PAYLOAD_ONLY) if (feed->ts_type & TS_PAYLOAD_ONLY)
dvb_dmx_swfilter_payload(feed, buf); dvb_dmx_swfilter_payload(feed, buf);
else else
feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK); feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts,
DMX_OK);
} }
if (feed->ts_type & TS_DECODER) if (feed->ts_type & TS_DECODER)
if (feed->demux->write_to_decoder) if (feed->demux->write_to_decoder)
...@@ -362,7 +357,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con ...@@ -362,7 +357,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con
if (!feed->feed.sec.is_filtering) if (!feed->feed.sec.is_filtering)
break; break;
if (dvb_dmx_swfilter_section_packet(feed, buf) < 0) if (dvb_dmx_swfilter_section_packet(feed, buf) < 0)
feed->feed.sec.seclen = feed->feed.sec.secbufp=0; feed->feed.sec.seclen = feed->feed.sec.secbufp = 0;
break; break;
default: default:
...@@ -378,7 +373,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con ...@@ -378,7 +373,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con
static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
{ {
struct dvb_demux_feed *feed; struct dvb_demux_feed *feed;
struct list_head *pos, *head=&demux->feed_list; struct list_head *pos, *head = &demux->feed_list;
u16 pid = ts_pid(buf); u16 pid = ts_pid(buf);
int dvr_done = 0; int dvr_done = 0;
...@@ -404,21 +399,21 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) ...@@ -404,21 +399,21 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
} }
} }
void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count) void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
size_t count)
{ {
spin_lock(&demux->lock); spin_lock(&demux->lock);
while (count--) { while (count--) {
if(buf[0] == 0x47) { if (buf[0] == 0x47)
dvb_dmx_swfilter_packet(demux, buf); dvb_dmx_swfilter_packet(demux, buf);
}
buf += 188; buf += 188;
} }
spin_unlock(&demux->lock); spin_unlock(&demux->lock);
} }
EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
{ {
...@@ -426,8 +421,10 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) ...@@ -426,8 +421,10 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
spin_lock(&demux->lock); spin_lock(&demux->lock);
if ((i = demux->tsbufp)) { if (demux->tsbufp) {
if (count < (j=188-i)) { i = demux->tsbufp;
j = 188 - i;
if (count < j) {
memcpy(&demux->tsbuf[i], buf, count); memcpy(&demux->tsbuf[i], buf, count);
demux->tsbufp += count; demux->tsbufp += count;
goto bailout; goto bailout;
...@@ -441,13 +438,13 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) ...@@ -441,13 +438,13 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
while (p < count) { while (p < count) {
if (buf[p] == 0x47) { if (buf[p] == 0x47) {
if (count-p >= 188) { if (count - p >= 188) {
dvb_dmx_swfilter_packet(demux, buf+p); dvb_dmx_swfilter_packet(demux, &buf[p]);
p += 188; p += 188;
} else { } else {
i = count-p; i = count - p;
memcpy(demux->tsbuf, buf+p, i); memcpy(demux->tsbuf, &buf[p], i);
demux->tsbufp=i; demux->tsbufp = i;
goto bailout; goto bailout;
} }
} else } else
...@@ -457,24 +454,29 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) ...@@ -457,24 +454,29 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
bailout: bailout:
spin_unlock(&demux->lock); spin_unlock(&demux->lock);
} }
EXPORT_SYMBOL(dvb_dmx_swfilter); EXPORT_SYMBOL(dvb_dmx_swfilter);
void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
{ {
int p = 0,i, j; int p = 0, i, j;
u8 tmppack[188]; u8 tmppack[188];
spin_lock(&demux->lock); spin_lock(&demux->lock);
if ((i = demux->tsbufp)) { if (demux->tsbufp) {
if (count < (j=204-i)) { i = demux->tsbufp;
j = 204 - i;
if (count < j) {
memcpy(&demux->tsbuf[i], buf, count); memcpy(&demux->tsbuf[i], buf, count);
demux->tsbufp += count; demux->tsbufp += count;
goto bailout; goto bailout;
} }
memcpy(&demux->tsbuf[i], buf, j); memcpy(&demux->tsbuf[i], buf, j);
if ((demux->tsbuf[0] == 0x47)|(demux->tsbuf[0]==0xB8)) { if ((demux->tsbuf[0] == 0x47) | (demux->tsbuf[0] == 0xB8)) {
memcpy(tmppack, demux->tsbuf, 188); memcpy(tmppack, demux->tsbuf, 188);
if (tmppack[0] == 0xB8) tmppack[0] = 0x47; if (tmppack[0] == 0xB8)
tmppack[0] = 0x47;
dvb_dmx_swfilter_packet(demux, tmppack); dvb_dmx_swfilter_packet(demux, tmppack);
} }
demux->tsbufp = 0; demux->tsbufp = 0;
...@@ -482,16 +484,17 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) ...@@ -482,16 +484,17 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
} }
while (p < count) { while (p < count) {
if ((buf[p] == 0x47)|(buf[p] == 0xB8)) { if ((buf[p] == 0x47) | (buf[p] == 0xB8)) {
if (count-p >= 204) { if (count - p >= 204) {
memcpy(tmppack, buf+p, 188); memcpy(tmppack, &buf[p], 188);
if (tmppack[0] == 0xB8) tmppack[0] = 0x47; if (tmppack[0] == 0xB8)
tmppack[0] = 0x47;
dvb_dmx_swfilter_packet(demux, tmppack); dvb_dmx_swfilter_packet(demux, tmppack);
p += 204; p += 204;
} else { } else {
i = count-p; i = count - p;
memcpy(demux->tsbuf, buf+p, i); memcpy(demux->tsbuf, &buf[p], i);
demux->tsbufp=i; demux->tsbufp = i;
goto bailout; goto bailout;
} }
} else { } else {
...@@ -502,14 +505,14 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) ...@@ -502,14 +505,14 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
bailout: bailout:
spin_unlock(&demux->lock); spin_unlock(&demux->lock);
} }
EXPORT_SYMBOL(dvb_dmx_swfilter_204);
EXPORT_SYMBOL(dvb_dmx_swfilter_204);
static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) static struct dvb_demux_filter *dvb_dmx_filter_alloc(struct dvb_demux *demux)
{ {
int i; int i;
for (i=0; i<demux->filternum; i++) for (i = 0; i < demux->filternum; i++)
if (demux->filter[i].state == DMX_STATE_FREE) if (demux->filter[i].state == DMX_STATE_FREE)
break; break;
...@@ -521,11 +524,11 @@ static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) ...@@ -521,11 +524,11 @@ static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux)
return &demux->filter[i]; return &demux->filter[i];
} }
static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux) static struct dvb_demux_feed *dvb_dmx_feed_alloc(struct dvb_demux *demux)
{ {
int i; int i;
for (i=0; i<demux->feednum; i++) for (i = 0; i < demux->feednum; i++)
if (demux->feed[i].state == DMX_STATE_FREE) if (demux->feed[i].state == DMX_STATE_FREE)
break; break;
...@@ -576,17 +579,17 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed) ...@@ -576,17 +579,17 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed)
spin_unlock_irq(&feed->demux->lock); spin_unlock_irq(&feed->demux->lock);
} }
static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
enum dmx_ts_pes pes_type, size_t circular_buffer_size, enum dmx_ts_pes pes_type,
struct timespec timeout) size_t circular_buffer_size, struct timespec timeout)
{ {
struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
if (pid > DMX_MAX_PID) if (pid > DMX_MAX_PID)
return -EINVAL; return -EINVAL;
if (down_interruptible (&demux->mutex)) if (down_interruptible(&demux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (ts_type & TS_DECODER) { if (ts_type & TS_DECODER) {
...@@ -615,7 +618,7 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, ...@@ -615,7 +618,7 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
if (feed->buffer_size) { if (feed->buffer_size) {
#ifdef NOBUFS #ifdef NOBUFS
feed->buffer=NULL; feed->buffer = NULL;
#else #else
feed->buffer = vmalloc(feed->buffer_size); feed->buffer = vmalloc(feed->buffer_size);
if (!feed->buffer) { if (!feed->buffer) {
...@@ -631,14 +634,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, ...@@ -631,14 +634,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
return 0; return 0;
} }
static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed)
static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed)
{ {
struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
int ret; int ret;
if (down_interruptible (&demux->mutex)) if (down_interruptible(&demux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) {
...@@ -665,13 +667,13 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) ...@@ -665,13 +667,13 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed)
return 0; return 0;
} }
static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
{ {
struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
int ret; int ret;
if (down_interruptible (&demux->mutex)) if (down_interruptible(&demux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (feed->state < DMX_STATE_GO) { if (feed->state < DMX_STATE_GO) {
...@@ -695,13 +697,14 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) ...@@ -695,13 +697,14 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed)
return ret; return ret;
} }
static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **ts_feed, static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
struct dmx_ts_feed **ts_feed,
dmx_ts_cb callback) dmx_ts_cb callback)
{ {
struct dvb_demux *demux = (struct dvb_demux *) dmx; struct dvb_demux *demux = (struct dvb_demux *)dmx;
struct dvb_demux_feed *feed; struct dvb_demux_feed *feed;
if (down_interruptible (&demux->mutex)) if (down_interruptible(&demux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (!(feed = dvb_dmx_feed_alloc(demux))) { if (!(feed = dvb_dmx_feed_alloc(demux))) {
...@@ -724,7 +727,6 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** ...@@ -724,7 +727,6 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **
(*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering; (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering;
(*ts_feed)->set = dmx_ts_feed_set; (*ts_feed)->set = dmx_ts_feed_set;
if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { if (!(feed->filter = dvb_dmx_filter_alloc(demux))) {
feed->state = DMX_STATE_FREE; feed->state = DMX_STATE_FREE;
up(&demux->mutex); up(&demux->mutex);
...@@ -740,22 +742,22 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** ...@@ -740,22 +742,22 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **
return 0; return 0;
} }
static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_feed) static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
struct dmx_ts_feed *ts_feed)
{ {
struct dvb_demux *demux = (struct dvb_demux *) dmx; struct dvb_demux *demux = (struct dvb_demux *)dmx;
struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
if (down_interruptible (&demux->mutex)) if (down_interruptible(&demux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (feed->state == DMX_STATE_FREE) { if (feed->state == DMX_STATE_FREE) {
up(&demux->mutex); up(&demux->mutex);
return -EINVAL; return -EINVAL;
} }
#ifndef NOBUFS #ifndef NOBUFS
vfree(feed->buffer); vfree(feed->buffer);
feed->buffer=0; feed->buffer = NULL;
#endif #endif
feed->state = DMX_STATE_FREE; feed->state = DMX_STATE_FREE;
...@@ -772,19 +774,18 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ ...@@ -772,19 +774,18 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_
return 0; return 0;
} }
/****************************************************************************** /******************************************************************************
* dmx_section_feed API calls * dmx_section_feed API calls
******************************************************************************/ ******************************************************************************/
static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
struct dmx_section_filter** filter) struct dmx_section_filter **filter)
{ {
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdemux = dvbdmxfeed->demux; struct dvb_demux *dvbdemux = dvbdmxfeed->demux;
struct dvb_demux_filter *dvbdmxfilter; struct dvb_demux_filter *dvbdmxfilter;
if (down_interruptible (&dvbdemux->mutex)) if (down_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux);
...@@ -808,18 +809,17 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, ...@@ -808,18 +809,17 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed,
return 0; return 0;
} }
static int dmx_section_feed_set(struct dmx_section_feed *feed,
static int dmx_section_feed_set(struct dmx_section_feed* feed,
u16 pid, size_t circular_buffer_size, u16 pid, size_t circular_buffer_size,
int check_crc) int check_crc)
{ {
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdmx = dvbdmxfeed->demux; struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
if (pid > 0x1fff) if (pid > 0x1fff)
return -EINVAL; return -EINVAL;
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
dvb_demux_feed_add(dvbdmxfeed); dvb_demux_feed_add(dvbdmxfeed);
...@@ -831,7 +831,7 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, ...@@ -831,7 +831,7 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed,
#ifdef NOBUFS #ifdef NOBUFS
dvbdmxfeed->buffer = NULL; dvbdmxfeed->buffer = NULL;
#else #else
dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size); dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size);
if (!dvbdmxfeed->buffer) { if (!dvbdmxfeed->buffer) {
up(&dvbdmx->mutex); up(&dvbdmx->mutex);
return -ENOMEM; return -ENOMEM;
...@@ -843,7 +843,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, ...@@ -843,7 +843,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed,
return 0; return 0;
} }
static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
{ {
int i; int i;
...@@ -851,12 +850,12 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) ...@@ -851,12 +850,12 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
struct dmx_section_filter *sf; struct dmx_section_filter *sf;
u8 mask, mode, doneq; u8 mask, mode, doneq;
if (!(f=dvbdmxfeed->filter)) if (!(f = dvbdmxfeed->filter))
return; return;
do { do {
sf = &f->filter; sf = &f->filter;
doneq = 0; doneq = 0;
for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
mode = sf->filter_mode[i]; mode = sf->filter_mode[i];
mask = sf->filter_mask[i]; mask = sf->filter_mask[i];
f->maskandmode[i] = mask & mode; f->maskandmode[i] = mask & mode;
...@@ -866,14 +865,13 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) ...@@ -866,14 +865,13 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
} while ((f = f->next)); } while ((f = f->next));
} }
static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
{ {
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdmx = dvbdmxfeed->demux; struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
int ret; int ret;
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (feed->is_filtering) { if (feed->is_filtering) {
...@@ -912,14 +910,13 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) ...@@ -912,14 +910,13 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
return 0; return 0;
} }
static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed)
{ {
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdmx = dvbdmxfeed->demux; struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
int ret; int ret;
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (!dvbdmx->stop_feed) { if (!dvbdmx->stop_feed) {
...@@ -938,15 +935,14 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) ...@@ -938,15 +935,14 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed)
return ret; return ret;
} }
static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
struct dmx_section_filter* filter) struct dmx_section_filter *filter)
{ {
struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *) filter, *f; struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *)filter, *f;
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdmx = dvbdmxfeed->demux; struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (dvbdmxfilter->feed != dvbdmxfeed) { if (dvbdmxfilter->feed != dvbdmxfeed) {
...@@ -963,7 +959,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, ...@@ -963,7 +959,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
if (f == dvbdmxfilter) { if (f == dvbdmxfilter) {
dvbdmxfeed->filter = dvbdmxfilter->next; dvbdmxfeed->filter = dvbdmxfilter->next;
} else { } else {
while(f->next != dvbdmxfilter) while (f->next != dvbdmxfilter)
f = f->next; f = f->next;
f->next = f->next->next; f->next = f->next->next;
} }
...@@ -978,10 +974,10 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, ...@@ -978,10 +974,10 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
struct dmx_section_feed **feed, struct dmx_section_feed **feed,
dmx_section_cb callback) dmx_section_cb callback)
{ {
struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
struct dvb_demux_feed *dvbdmxfeed; struct dvb_demux_feed *dvbdmxfeed;
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) {
...@@ -999,7 +995,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, ...@@ -999,7 +995,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
dvbdmxfeed->filter = NULL; dvbdmxfeed->filter = NULL;
dvbdmxfeed->buffer = NULL; dvbdmxfeed->buffer = NULL;
(*feed)=&dvbdmxfeed->feed.sec; (*feed) = &dvbdmxfeed->feed.sec;
(*feed)->is_filtering = 0; (*feed)->is_filtering = 0;
(*feed)->parent = demux; (*feed)->parent = demux;
(*feed)->priv = NULL; (*feed)->priv = NULL;
...@@ -1017,21 +1013,21 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, ...@@ -1017,21 +1013,21 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
static int dvbdmx_release_section_feed(struct dmx_demux *demux, static int dvbdmx_release_section_feed(struct dmx_demux *demux,
struct dmx_section_feed *feed) struct dmx_section_feed *feed)
{ {
struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
if (down_interruptible (&dvbdmx->mutex)) if (down_interruptible(&dvbdmx->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
if (dvbdmxfeed->state==DMX_STATE_FREE) { if (dvbdmxfeed->state == DMX_STATE_FREE) {
up(&dvbdmx->mutex); up(&dvbdmx->mutex);
return -EINVAL; return -EINVAL;
} }
#ifndef NOBUFS #ifndef NOBUFS
vfree(dvbdmxfeed->buffer); vfree(dvbdmxfeed->buffer);
dvbdmxfeed->buffer=0; dvbdmxfeed->buffer = NULL;
#endif #endif
dvbdmxfeed->state=DMX_STATE_FREE; dvbdmxfeed->state = DMX_STATE_FREE;
dvb_demux_feed_del(dvbdmxfeed); dvb_demux_feed_del(dvbdmxfeed);
...@@ -1041,14 +1037,13 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, ...@@ -1041,14 +1037,13 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux,
return 0; return 0;
} }
/****************************************************************************** /******************************************************************************
* dvb_demux kernel data API calls * dvb_demux kernel data API calls
******************************************************************************/ ******************************************************************************/
static int dvbdmx_open(struct dmx_demux *demux) static int dvbdmx_open(struct dmx_demux *demux)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
if (dvbdemux->users >= MAX_DVB_DEMUX_USERS) if (dvbdemux->users >= MAX_DVB_DEMUX_USERS)
return -EUSERS; return -EUSERS;
...@@ -1057,10 +1052,9 @@ static int dvbdmx_open(struct dmx_demux *demux) ...@@ -1057,10 +1052,9 @@ static int dvbdmx_open(struct dmx_demux *demux)
return 0; return 0;
} }
static int dvbdmx_close(struct dmx_demux *demux) static int dvbdmx_close(struct dmx_demux *demux)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
if (dvbdemux->users == 0) if (dvbdemux->users == 0)
return -ENODEV; return -ENODEV;
...@@ -1070,15 +1064,14 @@ static int dvbdmx_close(struct dmx_demux *demux) ...@@ -1070,15 +1064,14 @@ static int dvbdmx_close(struct dmx_demux *demux)
return 0; return 0;
} }
static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count)
{ {
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE))
return -EINVAL; return -EINVAL;
if (down_interruptible (&dvbdemux->mutex)) if (down_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
dvb_dmx_swfilter(dvbdemux, buf, count); dvb_dmx_swfilter(dvbdemux, buf, count);
up(&dvbdemux->mutex); up(&dvbdemux->mutex);
...@@ -1088,10 +1081,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) ...@@ -1088,10 +1081,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count)
return count; return count;
} }
static int dvbdmx_add_frontend(struct dmx_demux *demux,
static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) struct dmx_frontend *frontend)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
struct list_head *head = &dvbdemux->frontend_list; struct list_head *head = &dvbdemux->frontend_list;
list_add(&(frontend->connectivity_list), head); list_add(&(frontend->connectivity_list), head);
...@@ -1099,13 +1092,13 @@ static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *fro ...@@ -1099,13 +1092,13 @@ static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *fro
return 0; return 0;
} }
static int dvbdmx_remove_frontend(struct dmx_demux *demux,
static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) struct dmx_frontend *frontend)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
struct list_head *pos, *n, *head = &dvbdemux->frontend_list; struct list_head *pos, *n, *head = &dvbdemux->frontend_list;
list_for_each_safe (pos, n, head) { list_for_each_safe(pos, n, head) {
if (DMX_FE_ENTRY(pos) == frontend) { if (DMX_FE_ENTRY(pos) == frontend) {
list_del(pos); list_del(pos);
return 0; return 0;
...@@ -1115,25 +1108,25 @@ static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend * ...@@ -1115,25 +1108,25 @@ static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *
return -ENODEV; return -ENODEV;
} }
static struct list_head *dvbdmx_get_frontends(struct dmx_demux *demux)
static struct list_head * dvbdmx_get_frontends(struct dmx_demux *demux)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
if (list_empty(&dvbdemux->frontend_list)) if (list_empty(&dvbdemux->frontend_list))
return NULL; return NULL;
return &dvbdemux->frontend_list; return &dvbdemux->frontend_list;
} }
static int dvbdmx_connect_frontend(struct dmx_demux *demux,
static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) struct dmx_frontend *frontend)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
if (demux->frontend) if (demux->frontend)
return -EINVAL; return -EINVAL;
if (down_interruptible (&dvbdemux->mutex)) if (down_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
demux->frontend = frontend; demux->frontend = frontend;
...@@ -1141,12 +1134,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend ...@@ -1141,12 +1134,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend
return 0; return 0;
} }
static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) static int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
if (down_interruptible (&dvbdemux->mutex)) if (down_interruptible(&dvbdemux->mutex))
return -ERESTARTSYS; return -ERESTARTSYS;
demux->frontend = NULL; demux->frontend = NULL;
...@@ -1154,44 +1146,42 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) ...@@ -1154,44 +1146,42 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
return 0; return 0;
} }
static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 * pids)
static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids)
{ {
struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
memcpy(pids, dvbdemux->pids, 5*sizeof(u16)); memcpy(pids, dvbdemux->pids, 5 * sizeof(u16));
return 0; return 0;
} }
int dvb_dmx_init(struct dvb_demux *dvbdemux) int dvb_dmx_init(struct dvb_demux *dvbdemux)
{ {
int i; int i;
struct dmx_demux *dmx = &dvbdemux->dmx; struct dmx_demux *dmx = &dvbdemux->dmx;
dvbdemux->users = 0; dvbdemux->users = 0;
dvbdemux->filter = vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter)); dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter));
if (!dvbdemux->filter) if (!dvbdemux->filter)
return -ENOMEM; return -ENOMEM;
dvbdemux->feed = vmalloc(dvbdemux->feednum*sizeof(struct dvb_demux_feed)); dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed));
if (!dvbdemux->feed) { if (!dvbdemux->feed) {
vfree(dvbdemux->filter); vfree(dvbdemux->filter);
return -ENOMEM; return -ENOMEM;
} }
for (i=0; i<dvbdemux->filternum; i++) { for (i = 0; i < dvbdemux->filternum; i++) {
dvbdemux->filter[i].state = DMX_STATE_FREE; dvbdemux->filter[i].state = DMX_STATE_FREE;
dvbdemux->filter[i].index = i; dvbdemux->filter[i].index = i;
} }
for (i=0; i<dvbdemux->feednum; i++) { for (i = 0; i < dvbdemux->feednum; i++) {
dvbdemux->feed[i].state = DMX_STATE_FREE; dvbdemux->feed[i].state = DMX_STATE_FREE;
dvbdemux->feed[i].index = i; dvbdemux->feed[i].index = i;
} }
INIT_LIST_HEAD(&dvbdemux->frontend_list); INIT_LIST_HEAD(&dvbdemux->frontend_list);
for (i=0; i<DMX_TS_PES_OTHER; i++) { for (i = 0; i < DMX_TS_PES_OTHER; i++) {
dvbdemux->pesfilter[i] = NULL; dvbdemux->pesfilter[i] = NULL;
dvbdemux->pids[i] = 0xffff; dvbdemux->pids[i] = 0xffff;
} }
...@@ -1209,7 +1199,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) ...@@ -1209,7 +1199,7 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
dvbdemux->memcopy = dvb_dmx_memcopy; dvbdemux->memcopy = dvb_dmx_memcopy;
dmx->frontend = NULL; dmx->frontend = NULL;
dmx->priv = (void *) dvbdemux; dmx->priv = dvbdemux;
dmx->open = dvbdmx_open; dmx->open = dvbdmx_open;
dmx->close = dvbdmx_close; dmx->close = dvbdmx_close;
dmx->write = dvbdmx_write; dmx->write = dvbdmx_write;
...@@ -1230,12 +1220,13 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) ...@@ -1230,12 +1220,13 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
return 0; return 0;
} }
EXPORT_SYMBOL(dvb_dmx_init);
EXPORT_SYMBOL(dvb_dmx_init);
void dvb_dmx_release(struct dvb_demux *dvbdemux) void dvb_dmx_release(struct dvb_demux *dvbdemux)
{ {
vfree(dvbdemux->filter); vfree(dvbdemux->filter);
vfree(dvbdemux->feed); vfree(dvbdemux->feed);
} }
EXPORT_SYMBOL(dvb_dmx_release); EXPORT_SYMBOL(dvb_dmx_release);
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
* *
*/ */
#ifndef _DVB_DEMUX_H_ #ifndef _DVB_DEMUX_H_
#define _DVB_DEMUX_H_ #define _DVB_DEMUX_H_
...@@ -45,8 +44,8 @@ ...@@ -45,8 +44,8 @@
struct dvb_demux_filter { struct dvb_demux_filter {
struct dmx_section_filter filter; struct dmx_section_filter filter;
u8 maskandmode [DMX_MAX_FILTER_SIZE]; u8 maskandmode[DMX_MAX_FILTER_SIZE];
u8 maskandnotmode [DMX_MAX_FILTER_SIZE]; u8 maskandnotmode[DMX_MAX_FILTER_SIZE];
int doneq; int doneq;
struct dvb_demux_filter *next; struct dvb_demux_filter *next;
...@@ -59,7 +58,6 @@ struct dvb_demux_filter { ...@@ -59,7 +58,6 @@ struct dvb_demux_filter {
struct timer_list timer; struct timer_list timer;
}; };
#define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head) #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head)
struct dvb_demux_feed { struct dvb_demux_feed {
...@@ -101,13 +99,13 @@ struct dvb_demux { ...@@ -101,13 +99,13 @@ struct dvb_demux {
void *priv; void *priv;
int filternum; int filternum;
int feednum; int feednum;
int (*start_feed) (struct dvb_demux_feed *feed); int (*start_feed)(struct dvb_demux_feed *feed);
int (*stop_feed) (struct dvb_demux_feed *feed); int (*stop_feed)(struct dvb_demux_feed *feed);
int (*write_to_decoder) (struct dvb_demux_feed *feed, int (*write_to_decoder)(struct dvb_demux_feed *feed,
const u8 *buf, size_t len); const u8 *buf, size_t len);
u32 (*check_crc32) (struct dvb_demux_feed *feed, u32 (*check_crc32)(struct dvb_demux_feed *feed,
const u8 *buf, size_t len); const u8 *buf, size_t len);
void (*memcopy) (struct dvb_demux_feed *feed, u8 *dst, void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst,
const u8 *src, size_t len); const u8 *src, size_t len);
int users; int users;
...@@ -131,11 +129,12 @@ struct dvb_demux { ...@@ -131,11 +129,12 @@ struct dvb_demux {
spinlock_t lock; spinlock_t lock;
}; };
int dvb_dmx_init(struct dvb_demux *dvbdemux); int dvb_dmx_init(struct dvb_demux *dvbdemux);
void dvb_dmx_release(struct dvb_demux *dvbdemux); void dvb_dmx_release(struct dvb_demux *dvbdemux);
void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count); void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf,
size_t count);
void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count);
void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count); void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf,
size_t count);
#endif /* _DVB_DEMUX_H_ */ #endif /* _DVB_DEMUX_H_ */
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