Commit 33e9942c authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] update dvb subsystem core

 - update dvb subsystem core
 - switched from user-land types like __u8 to u8 and uint16_t to u16
   this makes the patch rather large.
 - updated the dvr (digital videorecording) facility
 - renamed some structures, like "struct dmxdev_s" to "struct dmxdev"
 - introduced dvb_functions.[ch], where some linux-kernel specific
   functions are encapsulated.  by this, the dvb subsystem stays quite
   independent from deeper linux kernel functions.
 - moved dvb_usercopy() to dvb_functions.c -- this is essentially
   video_usercopy() which should be generic_usercopy() instead...
 - Made the dvb-core in dvbdev.c work with devfs again.
 - remove all typedefs from structs
 - remove all typedefs from enums
parent 03ff595c
......@@ -3,6 +3,6 @@
#
dvb-core-objs = dvbdev.o dmxdev.o dvb_demux.o dvb_filter.o \
dvb_frontend.o dvb_i2c.o dvb_net.o dvb_ksyms.o dvb_ringbuffer.o
dvb_functions.o dvb_frontend.o dvb_i2c.o dvb_net.o dvb_ksyms.o dvb_ringbuffer.o
obj-$(CONFIG_DVB_CORE) += dvb-core.o
......@@ -25,14 +25,10 @@
#ifndef __DEMUX_H
#define __DEMUX_H
#ifndef __KERNEL__
#define __KERNEL__
#endif
#include <linux/types.h>
#include <asm/types.h>
#include <linux/errno.h>
#include <linux/list.h>
#include <linux/time.h>
#include <linux/errno.h>
/*--------------------------------------------------------------------------*/
/* Common definitions */
......@@ -47,10 +43,10 @@
#endif
/*
* dmx_success_t: Success codes for the Demux Callback API.
* enum dmx_success: Success codes for the Demux Callback API.
*/
typedef enum {
enum dmx_success {
DMX_OK = 0, /* Received Ok */
DMX_LENGTH_ERROR, /* Incorrect length */
DMX_OVERRUN_ERROR, /* Receiver ring buffer overrun */
......@@ -58,7 +54,7 @@ typedef enum {
DMX_FRAME_ERROR, /* Frame alignment error */
DMX_FIFO_ERROR, /* Receiver FIFO overrun */
DMX_MISSED_ERROR /* Receiver missed packet */
} dmx_success_t;
} ;
/*--------------------------------------------------------------------------*/
/* TS packet reception */
......@@ -74,7 +70,7 @@ typedef enum {
/* PES type for filters which write to built-in decoder */
/* these should be kept identical to the types in dmx.h */
typedef enum
enum dmx_ts_pes
{ /* also send packets to decoder (if it exists) */
DMX_TS_PES_AUDIO0,
DMX_TS_PES_VIDEO0,
......@@ -101,7 +97,7 @@ typedef enum
DMX_TS_PES_PCR3,
DMX_TS_PES_OTHER
} dmx_ts_pes_t;
};
#define DMX_TS_PES_AUDIO DMX_TS_PES_AUDIO0
#define DMX_TS_PES_VIDEO DMX_TS_PES_VIDEO0
......@@ -110,39 +106,37 @@ typedef enum
#define DMX_TS_PES_PCR DMX_TS_PES_PCR0
struct dmx_ts_feed_s {
struct dmx_ts_feed {
int is_filtering; /* Set to non-zero when filtering in progress */
struct dmx_demux_s *parent; /* Back-pointer */
struct dmx_demux *parent; /* Back-pointer */
void *priv; /* Pointer to private data of the API client */
int (*set) (struct dmx_ts_feed_s *feed,
uint16_t pid,
int (*set) (struct dmx_ts_feed *feed,
u16 pid,
int type,
dmx_ts_pes_t pes_type,
enum dmx_ts_pes pes_type,
size_t callback_length,
size_t circular_buffer_size,
int descramble,
struct timespec timeout);
int (*start_filtering) (struct dmx_ts_feed_s* feed);
int (*stop_filtering) (struct dmx_ts_feed_s* feed);
int (*start_filtering) (struct dmx_ts_feed* feed);
int (*stop_filtering) (struct dmx_ts_feed* feed);
};
typedef struct dmx_ts_feed_s dmx_ts_feed_t;
/*--------------------------------------------------------------------------*/
/* Section reception */
/*--------------------------------------------------------------------------*/
typedef struct {
__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_s* parent; /* Back-pointer */
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 */
} dmx_section_filter_t;
};
struct dmx_section_feed_s {
struct dmx_section_feed {
int is_filtering; /* Set to non-zero when filtering in progress */
struct dmx_demux_s* parent; /* Back-pointer */
struct dmx_demux* parent; /* Back-pointer */
void* priv; /* Pointer to private data of the API client */
int check_crc;
......@@ -152,19 +146,18 @@ struct dmx_section_feed_s {
int secbufp;
int seclen;
int (*set) (struct dmx_section_feed_s* feed,
__u16 pid,
int (*set) (struct dmx_section_feed* feed,
u16 pid,
size_t circular_buffer_size,
int descramble,
int check_crc);
int (*allocate_filter) (struct dmx_section_feed_s* feed,
dmx_section_filter_t** filter);
int (*release_filter) (struct dmx_section_feed_s* feed,
dmx_section_filter_t* filter);
int (*start_filtering) (struct dmx_section_feed_s* feed);
int (*stop_filtering) (struct dmx_section_feed_s* feed);
int (*allocate_filter) (struct dmx_section_feed* feed,
struct dmx_section_filter** filter);
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);
};
typedef struct dmx_section_feed_s dmx_section_feed_t;
/*--------------------------------------------------------------------------*/
/* Callback functions */
......@@ -174,21 +167,21 @@ typedef int (*dmx_ts_cb) ( const u8 * buffer1,
size_t buffer1_length,
const u8 * buffer2,
size_t buffer2_length,
dmx_ts_feed_t* source,
dmx_success_t success);
struct dmx_ts_feed* source,
enum dmx_success success);
typedef int (*dmx_section_cb) ( const u8 * buffer1,
size_t buffer1_len,
const u8 * buffer2,
size_t buffer2_len,
dmx_section_filter_t * source,
dmx_success_t success);
struct dmx_section_filter * source,
enum dmx_success success);
/*--------------------------------------------------------------------------*/
/* DVB Front-End */
/*--------------------------------------------------------------------------*/
typedef enum {
enum dmx_frontend_source {
DMX_MEMORY_FE,
DMX_FRONTEND_0,
DMX_FRONTEND_1,
......@@ -198,26 +191,22 @@ typedef enum {
DMX_STREAM_1,
DMX_STREAM_2,
DMX_STREAM_3
} dmx_frontend_source_t;
};
typedef struct {
/* The following char* fields point to NULL terminated strings */
char* id; /* Unique front-end identifier */
char* vendor; /* Name of the front-end vendor */
char* model; /* Name of the front-end model */
struct dmx_frontend {
struct list_head connectivity_list; /* List of front-ends that can
be connected to a particular
demux */
void* priv; /* Pointer to private data of the API client */
dmx_frontend_source_t source;
} dmx_frontend_t;
enum dmx_frontend_source source;
};
/*--------------------------------------------------------------------------*/
/* MPEG-2 TS Demux */
/*--------------------------------------------------------------------------*/
/*
* Flags OR'ed in the capabilites field of struct dmx_demux_s.
* Flags OR'ed in the capabilites field of struct dmx_demux.
*/
#define DMX_TS_FILTERING 1
......@@ -236,61 +225,56 @@ typedef struct {
/*
* DMX_FE_ENTRY(): Casts elements in the list of registered
* front-ends from the generic type struct list_head
* to the type * dmx_frontend_t
* to the type * struct dmx_frontend
*.
*/
#define DMX_FE_ENTRY(list) list_entry(list, dmx_frontend_t, connectivity_list)
#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)
struct dmx_demux_s {
/* The following char* fields point to NULL terminated strings */
char* id; /* Unique demux identifier */
char* vendor; /* Name of the demux vendor */
char* model; /* Name of the demux model */
__u32 capabilities; /* Bitfield of capability flags */
dmx_frontend_t* frontend; /* Front-end connected to the demux */
struct dmx_demux {
u32 capabilities; /* Bitfield of capability flags */
struct dmx_frontend* frontend; /* Front-end connected to the demux */
struct list_head reg_list; /* List of registered demuxes */
void* priv; /* Pointer to private data of the API client */
int users; /* Number of users */
int (*open) (struct dmx_demux_s* demux);
int (*close) (struct dmx_demux_s* demux);
int (*write) (struct dmx_demux_s* demux, const char* buf, size_t count);
int (*allocate_ts_feed) (struct dmx_demux_s* demux,
dmx_ts_feed_t** feed,
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_s* demux,
dmx_ts_feed_t* feed);
int (*allocate_section_feed) (struct dmx_demux_s* demux,
dmx_section_feed_t** feed,
int (*release_ts_feed) (struct dmx_demux* demux,
struct dmx_ts_feed* feed);
int (*allocate_section_feed) (struct dmx_demux* demux,
struct dmx_section_feed** feed,
dmx_section_cb callback);
int (*release_section_feed) (struct dmx_demux_s* demux,
dmx_section_feed_t* feed);
int (*descramble_mac_address) (struct dmx_demux_s* demux,
__u8* buffer1,
int (*release_section_feed) (struct dmx_demux* demux,
struct dmx_section_feed* feed);
int (*descramble_mac_address) (struct dmx_demux* demux,
u8* buffer1,
size_t buffer1_length,
__u8* buffer2,
u8* buffer2,
size_t buffer2_length,
__u16 pid);
int (*descramble_section_payload) (struct dmx_demux_s* demux,
__u8* buffer1,
u16 pid);
int (*descramble_section_payload) (struct dmx_demux* demux,
u8* buffer1,
size_t buffer1_length,
__u8* buffer2, size_t buffer2_length,
__u16 pid);
int (*add_frontend) (struct dmx_demux_s* demux,
dmx_frontend_t* frontend);
int (*remove_frontend) (struct dmx_demux_s* demux,
dmx_frontend_t* frontend);
struct list_head* (*get_frontends) (struct dmx_demux_s* demux);
int (*connect_frontend) (struct dmx_demux_s* demux,
dmx_frontend_t* frontend);
int (*disconnect_frontend) (struct dmx_demux_s* demux);
int (*get_pes_pids) (struct dmx_demux_s* demux, __u16 *pids);
int (*get_stc) (struct dmx_demux_s* demux, unsigned int num,
uint64_t *stc, unsigned int *base);
u8* buffer2, size_t buffer2_length,
u16 pid);
int (*add_frontend) (struct dmx_demux* demux,
struct dmx_frontend* frontend);
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 dmx_frontend* frontend);
int (*disconnect_frontend) (struct dmx_demux* demux);
int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
int (*get_stc) (struct dmx_demux* demux, unsigned int num,
u64 *stc, unsigned int *base);
};
typedef struct dmx_demux_s dmx_demux_t;
/*--------------------------------------------------------------------------*/
/* Demux directory */
......@@ -298,14 +282,14 @@ typedef struct dmx_demux_s dmx_demux_t;
/*
* DMX_DIR_ENTRY(): Casts elements in the list of registered
* demuxes from the generic type struct list_head* to the type dmx_demux_t
* demuxes from the generic type struct list_head* to the type struct dmx_demux
*.
*/
#define DMX_DIR_ENTRY(list) list_entry(list, dmx_demux_t, reg_list)
#define DMX_DIR_ENTRY(list) list_entry(list, struct dmx_demux, reg_list)
int dmx_register_demux (dmx_demux_t* demux);
int dmx_unregister_demux (dmx_demux_t* demux);
int dmx_register_demux (struct dmx_demux* demux);
int dmx_unregister_demux (struct dmx_demux* demux);
struct list_head* dmx_get_demuxes (void);
#endif /* #ifndef __DEMUX_H */
......
......@@ -21,41 +21,39 @@
*
*/
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/poll.h>
#include <asm/uaccess.h>
#include <linux/ioctl.h>
#include <linux/wait.h>
#include "dmxdev.h"
#include "dvb_functions.h"
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#include "compat.h"
#endif
//MODULE_DESCRIPTION("");
//MODULE_AUTHOR("Ralph Metzler, Marcus Metzler");
//#ifdef MODULE_LICENSE
//MODULE_LICENSE("GPL");
//#endif
MODULE_PARM(debug,"i");
static int debug = 0;
#define dprintk if (debug) printk
inline dmxdev_filter_t *
inline struct dmxdev_filter *
dvb_dmxdev_file_to_filter(struct file *file)
{
return (dmxdev_filter_t *) file->private_data;
return (struct dmxdev_filter *) file->private_data;
}
inline dmxdev_dvr_t *
dvb_dmxdev_file_to_dvr(dmxdev_t *dmxdev, struct file *file)
inline struct dmxdev_dvr *
dvb_dmxdev_file_to_dvr(struct dmxdev *dmxdev, struct file *file)
{
return (dmxdev_dvr_t *) file->private_data;
return (struct dmxdev_dvr *) file->private_data;
}
static inline void
dvb_dmxdev_buffer_init(dmxdev_buffer_t *buffer)
dvb_dmxdev_buffer_init(struct dmxdev_buffer *buffer)
{
buffer->data=0;
buffer->size=8192;
......@@ -66,7 +64,7 @@ dvb_dmxdev_buffer_init(dmxdev_buffer_t *buffer)
}
static inline
int dvb_dmxdev_buffer_write(dmxdev_buffer_t *buf, const u8 *src, int len)
int dvb_dmxdev_buffer_write(struct dmxdev_buffer *buf, const u8 *src, int len)
{
int split;
int free;
......@@ -101,7 +99,7 @@ int dvb_dmxdev_buffer_write(dmxdev_buffer_t *buf, const u8 *src, int len)
}
static ssize_t
dvb_dmxdev_buffer_read(dmxdev_buffer_t *src, int non_blocking,
dvb_dmxdev_buffer_read(struct dmxdev_buffer *src, int non_blocking,
char *buf, size_t count, loff_t *ppos)
{
unsigned long todo=count;
......@@ -161,8 +159,8 @@ dvb_dmxdev_buffer_read(dmxdev_buffer_t *src, int non_blocking,
return count;
}
static dmx_frontend_t *
get_fe(dmx_demux_t *demux, int type)
static struct dmx_frontend *
get_fe(struct dmx_demux *demux, int type)
{
struct list_head *head, *pos;
......@@ -177,7 +175,7 @@ get_fe(dmx_demux_t *demux, int type)
}
static inline void
dvb_dmxdev_dvr_state_set(dmxdev_dvr_t *dmxdevdvr, int state)
dvb_dmxdev_dvr_state_set(struct dmxdev_dvr *dmxdevdvr, int state)
{
spin_lock_irq(&dmxdevdvr->dev->lock);
dmxdevdvr->state=state;
......@@ -187,8 +185,8 @@ dvb_dmxdev_dvr_state_set(dmxdev_dvr_t *dmxdevdvr, int state)
static int dvb_dvr_open(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
dmx_frontend_t *front;
struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv;
struct dmx_frontend *front;
dprintk ("function : %s\n", __FUNCTION__);
......@@ -236,7 +234,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
static int dvb_dvr_release(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv;
if (down_interruptible (&dmxdev->mutex))
return -ERESTARTSYS;
......@@ -264,7 +262,7 @@ static ssize_t
dvb_dvr_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv;
int ret;
if (!dmxdev->demux->write)
......@@ -282,7 +280,7 @@ static ssize_t
dvb_dvr_read(struct file *file, char *buf, size_t count, loff_t *ppos)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv;
int ret;
//down(&dmxdev->mutex);
......@@ -294,7 +292,7 @@ dvb_dvr_read(struct file *file, char *buf, size_t count, loff_t *ppos)
}
static inline void
dvb_dmxdev_filter_state_set(dmxdev_filter_t *dmxdevfilter, int state)
dvb_dmxdev_filter_state_set(struct dmxdev_filter *dmxdevfilter, int state)
{
spin_lock_irq(&dmxdevfilter->dev->lock);
dmxdevfilter->state=state;
......@@ -302,9 +300,9 @@ dvb_dmxdev_filter_state_set(dmxdev_filter_t *dmxdevfilter, int state)
}
static int
dvb_dmxdev_set_buffer_size(dmxdev_filter_t *dmxdevfilter, unsigned long size)
dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter, unsigned long size)
{
dmxdev_buffer_t *buf=&dmxdevfilter->buffer;
struct dmxdev_buffer *buf=&dmxdevfilter->buffer;
void *mem;
if (buf->size==size)
......@@ -334,7 +332,7 @@ dvb_dmxdev_set_buffer_size(dmxdev_filter_t *dmxdevfilter, unsigned long size)
static void
dvb_dmxdev_filter_timeout(unsigned long data)
{
dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *)data;
struct dmxdev_filter *dmxdevfilter=(struct dmxdev_filter *)data;
dmxdevfilter->buffer.error=-ETIMEDOUT;
spin_lock_irq(&dmxdevfilter->dev->lock);
......@@ -344,7 +342,7 @@ dvb_dmxdev_filter_timeout(unsigned long data)
}
static void
dvb_dmxdev_filter_timer(dmxdev_filter_t *dmxdevfilter)
dvb_dmxdev_filter_timer(struct dmxdev_filter *dmxdevfilter)
{
struct dmx_sct_filter_params *para=&dmxdevfilter->params.sec;
......@@ -360,9 +358,9 @@ dvb_dmxdev_filter_timer(dmxdev_filter_t *dmxdevfilter)
static int
dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
const u8 *buffer2, size_t buffer2_len,
dmx_section_filter_t *filter, dmx_success_t success)
struct dmx_section_filter *filter, enum dmx_success success)
{
dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *) filter->priv;
struct dmxdev_filter *dmxdevfilter=(struct dmxdev_filter *) filter->priv;
int ret;
if (dmxdevfilter->buffer.error) {
......@@ -397,10 +395,10 @@ dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
static int
dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
const u8 *buffer2, size_t buffer2_len,
dmx_ts_feed_t *feed, dmx_success_t success)
struct dmx_ts_feed *feed, enum dmx_success success)
{
dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *) feed->priv;
dmxdev_buffer_t *buffer;
struct dmxdev_filter *dmxdevfilter=(struct dmxdev_filter *) feed->priv;
struct dmxdev_buffer *buffer;
int ret;
spin_lock(&dmxdevfilter->dev->lock);
......@@ -434,7 +432,7 @@ dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
/* stop feed but only mark the specified filter as stopped (state set) */
static int
dvb_dmxdev_feed_stop(dmxdev_filter_t *dmxdevfilter)
dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
{
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
......@@ -456,7 +454,7 @@ dvb_dmxdev_feed_stop(dmxdev_filter_t *dmxdevfilter)
/* start feed associated with the specified filter */
static
int dvb_dmxdev_feed_start(dmxdev_filter_t *filter)
int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
{
dvb_dmxdev_filter_state_set (filter, DMXDEV_STATE_GO);
......@@ -479,11 +477,11 @@ int dvb_dmxdev_feed_start(dmxdev_filter_t *filter)
otherwise release the feed */
static
int dvb_dmxdev_feed_restart(dmxdev_filter_t *filter)
int dvb_dmxdev_feed_restart(struct dmxdev_filter *filter)
{
int i;
dmxdev_t *dmxdev = filter->dev;
uint16_t pid = filter->params.sec.pid;
struct dmxdev *dmxdev = filter->dev;
u16 pid = filter->params.sec.pid;
for (i=0; i<dmxdev->filternum; i++)
if (dmxdev->filter[i].state>=DMXDEV_STATE_GO &&
......@@ -499,7 +497,7 @@ int dvb_dmxdev_feed_restart(dmxdev_filter_t *filter)
}
static int
dvb_dmxdev_filter_stop(dmxdev_filter_t *dmxdevfilter)
dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter)
{
if (dmxdevfilter->state<DMXDEV_STATE_GO)
return 0;
......@@ -535,7 +533,7 @@ dvb_dmxdev_filter_stop(dmxdev_filter_t *dmxdevfilter)
}
static inline int
dvb_dmxdev_filter_reset(dmxdev_filter_t *dmxdevfilter)
dvb_dmxdev_filter_reset(struct dmxdev_filter *dmxdevfilter)
{
if (dmxdevfilter->state<DMXDEV_STATE_SET)
return 0;
......@@ -547,9 +545,9 @@ dvb_dmxdev_filter_reset(dmxdev_filter_t *dmxdevfilter)
}
static int
dvb_dmxdev_filter_start(dmxdev_filter_t *filter)
dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
{
dmxdev_t *dmxdev = filter->dev;
struct dmxdev *dmxdev = filter->dev;
void *mem;
int ret, i;
......@@ -574,8 +572,8 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *filter)
case DMXDEV_TYPE_SEC:
{
struct dmx_sct_filter_params *para=&filter->params.sec;
dmx_section_filter_t **secfilter=&filter->filter.sec;
dmx_section_feed_t **secfeed=&filter->feed.sec;
struct dmx_section_filter **secfilter=&filter->filter.sec;
struct dmx_section_feed **secfeed=&filter->feed.sec;
*secfilter=0;
*secfeed=0;
......@@ -656,13 +654,13 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *filter)
dmx_output_t otype;
int ret;
int ts_type;
dmx_ts_pes_t ts_pes;
dmx_ts_feed_t **tsfeed = &filter->feed.ts;
enum dmx_ts_pes ts_pes;
struct dmx_ts_feed **tsfeed = &filter->feed.ts;
filter->feed.ts = 0;
otype=para->output;
ts_pes=(dmx_ts_pes_t) para->pes_type;
ts_pes=(enum dmx_ts_pes) para->pes_type;
if (ts_pes<DMX_PES_OTHER)
ts_type=TS_DECODER;
......@@ -709,9 +707,9 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *filter)
static int dvb_demux_open(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv;
int i;
dmxdev_filter_t *dmxdevfilter;
struct dmxdev_filter *dmxdevfilter;
if (!dmxdev->filter)
return -EINVAL;
......@@ -745,7 +743,7 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
static
int dvb_dmxdev_filter_free(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter)
int dvb_dmxdev_filter_free(struct dmxdev *dmxdev, struct dmxdev_filter *dmxdevfilter)
{
if (down_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
......@@ -785,8 +783,8 @@ invert_mode(dmx_filter_t *filter)
static int
dvb_dmxdev_filter_set(dmxdev_t *dmxdev,
dmxdev_filter_t *dmxdevfilter,
dvb_dmxdev_filter_set(struct dmxdev *dmxdev,
struct dmxdev_filter *dmxdevfilter,
struct dmx_sct_filter_params *params)
{
dprintk ("function : %s\n", __FUNCTION__);
......@@ -807,8 +805,8 @@ dvb_dmxdev_filter_set(dmxdev_t *dmxdev,
}
static int
dvb_dmxdev_pes_filter_set(dmxdev_t *dmxdev,
dmxdev_filter_t *dmxdevfilter,
dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
struct dmxdev_filter *dmxdevfilter,
struct dmx_pes_filter_params *params)
{
dvb_dmxdev_filter_stop(dmxdevfilter);
......@@ -829,7 +827,7 @@ dvb_dmxdev_pes_filter_set(dmxdev_t *dmxdev,
}
static ssize_t
dvb_dmxdev_read_sec(dmxdev_filter_t *dfil, struct file *file,
dvb_dmxdev_read_sec(struct dmxdev_filter *dfil, struct file *file,
char *buf, size_t count, loff_t *ppos)
{
int result, hcount;
......@@ -871,7 +869,7 @@ dvb_dmxdev_read_sec(dmxdev_filter_t *dfil, struct file *file,
ssize_t
dvb_demux_read(struct file *file, char *buf, size_t count, loff_t *ppos)
{
dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
struct dmxdev_filter *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
int ret=0;
if (down_interruptible(&dmxdevfilter->mutex))
......@@ -892,8 +890,8 @@ dvb_demux_read(struct file *file, char *buf, size_t count, loff_t *ppos)
static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *parg)
{
dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
dmxdev_t *dmxdev=dmxdevfilter->dev;
struct dmxdev_filter *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
struct dmxdev *dmxdev=dmxdevfilter->dev;
unsigned long arg=(unsigned long) parg;
int ret=0;
......@@ -959,7 +957,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
ret=-EINVAL;
break;
}
dmxdev->demux->get_pes_pids(dmxdev->demux, (uint16_t *)parg);
dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg);
break;
case DMX_GET_STC:
......@@ -990,7 +988,7 @@ static int dvb_demux_ioctl(struct inode *inode, struct file *file,
static
unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
{
dmxdev_filter_t *dmxdevfilter = dvb_dmxdev_file_to_filter(file);
struct dmxdev_filter *dmxdevfilter = dvb_dmxdev_file_to_filter(file);
unsigned int mask = 0;
if (!dmxdevfilter)
......@@ -999,7 +997,8 @@ unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
poll_wait(file, &dmxdevfilter->buffer.queue, wait);
if (dmxdevfilter->state != DMXDEV_STATE_GO &&
dmxdevfilter->state != DMXDEV_STATE_DONE)
dmxdevfilter->state != DMXDEV_STATE_DONE &&
dmxdevfilter->state != DMXDEV_STATE_TIMEDOUT)
return 0;
if (dmxdevfilter->buffer.error)
......@@ -1015,8 +1014,8 @@ unsigned int dvb_demux_poll (struct file *file, poll_table *wait)
static
int dvb_demux_release(struct inode *inode, struct file *file)
{
dmxdev_filter_t *dmxdevfilter = dvb_dmxdev_file_to_filter(file);
dmxdev_t *dmxdev = dmxdevfilter->dev;
struct dmxdev_filter *dmxdevfilter = dvb_dmxdev_file_to_filter(file);
struct dmxdev *dmxdev = dmxdevfilter->dev;
return dvb_dmxdev_filter_free(dmxdev, dmxdevfilter);
}
......@@ -1041,7 +1040,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
struct dmxdev *dmxdev=(struct dmxdev *) dvbdev->priv;
int ret=0;
......@@ -1072,7 +1071,7 @@ static
unsigned int dvb_dvr_poll (struct file *file, poll_table *wait)
{
struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
dmxdev_t *dmxdev = (dmxdev_t *) dvbdev->priv;
struct dmxdev *dmxdev = (struct dmxdev *) dvbdev->priv;
unsigned int mask = 0;
dprintk ("function : %s\n", __FUNCTION__);
......@@ -1103,7 +1102,8 @@ struct file_operations dvb_dvr_fops = {
.poll = dvb_dvr_poll,
};
static struct dvb_device dvbdev_dvr = {
static
struct dvb_device dvbdev_dvr = {
.priv = 0,
.users = 1,
.writers = 1,
......@@ -1111,23 +1111,24 @@ static struct dvb_device dvbdev_dvr = {
};
int
dvb_dmxdev_init(dmxdev_t *dmxdev, struct dvb_adapter *dvb_adapter)
dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
{
int i;
if (dmxdev->demux->open(dmxdev->demux)<0)
return -EUSERS;
dmxdev->filter=vmalloc(dmxdev->filternum*sizeof(dmxdev_filter_t));
dmxdev->filter = vmalloc(dmxdev->filternum*sizeof(struct dmxdev_filter));
if (!dmxdev->filter)
return -ENOMEM;
dmxdev->dvr=vmalloc(dmxdev->filternum*sizeof(dmxdev_dvr_t));
dmxdev->dvr = vmalloc(dmxdev->filternum*sizeof(struct dmxdev_dvr));
if (!dmxdev->dvr) {
vfree(dmxdev->filter);
dmxdev->filter=0;
dmxdev->filter = NULL;
return -ENOMEM;
}
sema_init(&dmxdev->mutex, 1);
spin_lock_init(&dmxdev->lock);
for (i=0; i<dmxdev->filternum; i++) {
......@@ -1143,13 +1144,12 @@ dvb_dmxdev_init(dmxdev_t *dmxdev, struct dvb_adapter *dvb_adapter)
dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr, dmxdev, DVB_DEVICE_DVR);
dvb_dmxdev_buffer_init(&dmxdev->dvr_buffer);
/* fixme: is this correct? */
try_module_get(THIS_MODULE);
return 0;
}
void
dvb_dmxdev_release(dmxdev_t *dmxdev)
dvb_dmxdev_release(struct dmxdev *dmxdev)
{
dvb_unregister_device(dmxdev->dvbdev);
dvb_unregister_device(dmxdev->dvr_dvbdev);
......@@ -1162,8 +1162,6 @@ dvb_dmxdev_release(dmxdev_t *dmxdev)
dmxdev->dvr=0;
}
dmxdev->demux->close(dmxdev->demux);
/* fixme: is this correct? */
module_put(THIS_MODULE);
}
......@@ -24,55 +24,54 @@
#ifndef _DMXDEV_H_
#define _DMXDEV_H_
#ifndef __KERNEL__
#define __KERNEL__
#endif
#include <linux/dvb/dmx.h>
#include <linux/version.h>
#include <asm/types.h>
#include <asm/semaphore.h>
#include <linux/spinlock.h>
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/dvb/dmx.h>
#include "dvbdev.h"
#include "demux.h"
typedef enum {
enum dmxdevype {
DMXDEV_TYPE_NONE,
DMXDEV_TYPE_SEC,
DMXDEV_TYPE_PES,
} dmxdev_type_t;
};
typedef enum {
enum dmxdev_state {
DMXDEV_STATE_FREE,
DMXDEV_STATE_ALLOCATED,
DMXDEV_STATE_SET,
DMXDEV_STATE_GO,
DMXDEV_STATE_DONE,
DMXDEV_STATE_TIMEDOUT
} dmxdev_state_t;
};
typedef struct dmxdev_buffer_s {
uint8_t *data;
uint32_t size;
int32_t pread;
int32_t pwrite;
struct dmxdev_buffer {
u8 *data;
int size;
int pread;
int pwrite;
wait_queue_head_t queue;
int error;
} dmxdev_buffer_t;
};
typedef struct dmxdev_filter_s {
struct dmxdev_filter {
struct dvb_device *dvbdev;
union {
dmx_section_filter_t *sec;
struct dmx_section_filter *sec;
} filter;
union {
dmx_ts_feed_t *ts;
dmx_section_feed_t *sec;
struct dmx_ts_feed *ts;
struct dmx_section_feed *sec;
} feed;
union {
......@@ -81,50 +80,50 @@ typedef struct dmxdev_filter_s {
} params;
int type;
dmxdev_state_t state;
struct dmxdev_s *dev;
dmxdev_buffer_t buffer;
enum dmxdev_state state;
struct dmxdev *dev;
struct dmxdev_buffer buffer;
struct semaphore mutex;
// only for sections
/* only for sections */
struct timer_list timer;
int todo;
uint8_t secheader[3];
u8 secheader[3];
u16 pid;
} dmxdev_filter_t;
};
typedef struct dmxdev_dvr_s {
struct dmxdev_dvr {
int state;
struct dmxdev_s *dev;
dmxdev_buffer_t buffer;
} dmxdev_dvr_t;
struct dmxdev *dev;
struct dmxdev_buffer buffer;
};
typedef struct dmxdev_s {
struct dmxdev {
struct dvb_device *dvbdev;
struct dvb_device *dvr_dvbdev;
dmxdev_filter_t *filter;
dmxdev_dvr_t *dvr;
dmx_demux_t *demux;
struct dmxdev_filter *filter;
struct dmxdev_dvr *dvr;
struct dmx_demux *demux;
int filternum;
int capabilities;
#define DMXDEV_CAP_DUPLEX 1
dmx_frontend_t *dvr_orig_fe;
struct dmx_frontend *dvr_orig_fe;
dmxdev_buffer_t dvr_buffer;
struct dmxdev_buffer dvr_buffer;
#define DVR_BUFFER_SIZE (10*188*1024)
struct semaphore mutex;
spinlock_t lock;
} dmxdev_t;
};
int dvb_dmxdev_init(dmxdev_t *dmxdev, struct dvb_adapter *);
void dvb_dmxdev_release(dmxdev_t *dmxdev);
int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *);
void dvb_dmxdev_release(struct dmxdev *dmxdev);
#endif /* _DMXDEV_H_ */
......@@ -21,46 +21,31 @@
*
*/
#include <asm/uaccess.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/poll.h>
#include <linux/version.h>
#include <asm/uaccess.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#include "compat.h"
#else
#include <linux/string.h>
#include <linux/crc32.h>
#endif
#include "dvb_demux.h"
#include "dvb_functions.h"
#define NOBUFS
LIST_HEAD(dmx_muxs);
int dmx_register_demux(dmx_demux_t *demux)
int dmx_register_demux(struct dmx_demux *demux)
{
struct list_head *pos;
if (!(demux->id && demux->vendor && demux->model))
return -EINVAL;
list_for_each(pos, &dmx_muxs) {
if (!strcmp(DMX_DIR_ENTRY(pos)->id, demux->id))
return -EEXIST;
}
demux->users = 0;
list_add(&demux->reg_list, &dmx_muxs);
/* fixme: is this correct? */
try_module_get(THIS_MODULE);
return 0;
}
int dmx_unregister_demux(dmx_demux_t* demux)
int dmx_unregister_demux(struct dmx_demux* demux)
{
struct list_head *pos, *n, *head=&dmx_muxs;
......@@ -69,8 +54,6 @@ int dmx_unregister_demux(dmx_demux_t* demux)
if (demux->users>0)
return -EINVAL;
list_del(pos);
/* fixme: is this correct? */
module_put(THIS_MODULE);
return 0;
}
}
......@@ -211,7 +194,7 @@ int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed)
{
struct dvb_demux *demux = feed->demux;
struct dvb_demux_filter *f = feed->filter;
dmx_section_feed_t *sec = &feed->feed.sec;
struct dmx_section_feed *sec = &feed->feed.sec;
u8 *buf = sec->secbuf;
if (sec->secbufp != sec->seclen)
......@@ -243,7 +226,7 @@ static
int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
{
struct dvb_demux *demux = feed->demux;
dmx_section_feed_t *sec = &feed->feed.sec;
struct dmx_section_feed *sec = &feed->feed.sec;
int p, count;
int ccok, rest;
u8 cc;
......@@ -506,12 +489,14 @@ int dmx_pid_set (u16 pid, struct dvb_demux_feed *feed)
if (pid == feed->pid)
return 0;
if (feed->pid <= DMX_MAX_PID)
list_for_each_safe(pos, n, head)
if (feed->pid <= DMX_MAX_PID) {
list_for_each_safe(pos, n, head) {
if (DMX_FEED_ENTRY(pos)->pid == feed->pid) {
list_del(pos);
break;
}
}
}
list_add(&feed->list_head, head);
feed->pid = pid;
......@@ -521,8 +506,8 @@ int dmx_pid_set (u16 pid, struct dvb_demux_feed *feed)
static
int dmx_ts_feed_set (struct dmx_ts_feed_s* ts_feed, u16 pid, int ts_type,
dmx_ts_pes_t pes_type, size_t callback_length,
int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type,
enum dmx_ts_pes pes_type, size_t callback_length,
size_t circular_buffer_size, int descramble,
struct timespec timeout)
{
......@@ -597,7 +582,7 @@ int dmx_ts_feed_set (struct dmx_ts_feed_s* ts_feed, u16 pid, int ts_type,
static
int dmx_ts_feed_start_filtering(struct dmx_ts_feed_s* ts_feed)
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 *demux = feed->demux;
......@@ -631,7 +616,7 @@ int dmx_ts_feed_start_filtering(struct dmx_ts_feed_s* ts_feed)
}
static
int dmx_ts_feed_stop_filtering(struct dmx_ts_feed_s* ts_feed)
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 *demux = feed->demux;
......@@ -662,7 +647,7 @@ int dmx_ts_feed_stop_filtering(struct dmx_ts_feed_s* ts_feed)
}
static
int dvbdmx_allocate_ts_feed (dmx_demux_t *dmx, dmx_ts_feed_t **ts_feed,
int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **ts_feed,
dmx_ts_cb callback)
{
struct dvb_demux *demux = (struct dvb_demux *) dmx;
......@@ -684,12 +669,12 @@ int dvbdmx_allocate_ts_feed (dmx_demux_t *dmx, dmx_ts_feed_t **ts_feed,
feed->buffer = 0;
(*ts_feed) = &feed->feed.ts;
(*ts_feed)->is_filtering = 0;
(*ts_feed)->parent = dmx;
(*ts_feed)->priv = 0;
(*ts_feed)->set = dmx_ts_feed_set;
(*ts_feed)->is_filtering = 0;
(*ts_feed)->start_filtering = dmx_ts_feed_start_filtering;
(*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering;
(*ts_feed)->set = dmx_ts_feed_set;
if (!(feed->filter = dvb_dmx_filter_alloc(demux))) {
......@@ -708,7 +693,7 @@ int dvbdmx_allocate_ts_feed (dmx_demux_t *dmx, dmx_ts_feed_t **ts_feed,
}
static
int dvbdmx_release_ts_feed(dmx_demux_t *dmx, dmx_ts_feed_t *ts_feed)
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_feed *feed = (struct dvb_demux_feed *) ts_feed;
......@@ -754,8 +739,8 @@ int dvbdmx_release_ts_feed(dmx_demux_t *dmx, dmx_ts_feed_t *ts_feed)
******************************************************************************/
static int
dmx_section_feed_allocate_filter(struct dmx_section_feed_s* feed,
dmx_section_filter_t** filter)
dmx_section_feed_allocate_filter(struct dmx_section_feed* feed,
struct dmx_section_filter** filter)
{
struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
struct dvb_demux *dvbdemux=dvbdmxfeed->demux;
......@@ -767,8 +752,9 @@ dmx_section_feed_allocate_filter(struct dmx_section_feed_s* feed,
dvbdmxfilter=dvb_dmx_filter_alloc(dvbdemux);
if (!dvbdmxfilter) {
up(&dvbdemux->mutex);
return -ENOSPC;
return -EBUSY;
}
spin_lock_irq(&dvbdemux->lock);
*filter=&dvbdmxfilter->filter;
(*filter)->parent=feed;
......@@ -784,8 +770,9 @@ dmx_section_feed_allocate_filter(struct dmx_section_feed_s* feed,
return 0;
}
static int
dmx_section_feed_set(struct dmx_section_feed_s* feed,
dmx_section_feed_set(struct dmx_section_feed* feed,
u16 pid, size_t circular_buffer_size,
int descramble, int check_crc)
{
......@@ -799,16 +786,18 @@ dmx_section_feed_set(struct dmx_section_feed_s* feed,
if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS;
if (dvbdmxfeed->pid <= DMX_MAX_PID)
list_for_each_safe(pos, n, head)
if (dvbdmxfeed->pid <= DMX_MAX_PID) {
list_for_each_safe(pos, n, head) {
if (DMX_FEED_ENTRY(pos)->pid == dvbdmxfeed->pid) {
list_del(pos);
break;
}
}
}
list_add(&dvbdmxfeed->list_head, head);
dvbdmxfeed->pid=pid;
dvbdmxfeed->pid = pid;
dvbdmxfeed->buffer_size=circular_buffer_size;
dvbdmxfeed->descramble=descramble;
if (dvbdmxfeed->descramble) {
......@@ -834,8 +823,8 @@ dmx_section_feed_set(struct dmx_section_feed_s* feed,
static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
{
int i;
dmx_section_filter_t *sf;
struct dvb_demux_filter *f;
struct dmx_section_filter *sf;
u8 mask, mode, doneq;
if (!(f=dvbdmxfeed->filter))
......@@ -855,7 +844,7 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
static int
dmx_section_feed_start_filtering(dmx_section_feed_t *feed)
dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
{
struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
......@@ -895,8 +884,9 @@ dmx_section_feed_start_filtering(dmx_section_feed_t *feed)
return 0;
}
static int
dmx_section_feed_stop_filtering(struct dmx_section_feed_s* feed)
dmx_section_feed_stop_filtering(struct dmx_section_feed* feed)
{
struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
......@@ -918,9 +908,10 @@ dmx_section_feed_stop_filtering(struct dmx_section_feed_s* feed)
return ret;
}
static int
dmx_section_feed_release_filter(dmx_section_feed_t *feed,
dmx_section_filter_t* filter)
dmx_section_feed_release_filter(struct dmx_section_feed *feed,
struct dmx_section_filter* filter)
{
struct dvb_demux_filter *dvbdmxfilter=(struct dvb_demux_filter *) filter, *f;
struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
......@@ -938,9 +929,10 @@ dmx_section_feed_release_filter(dmx_section_feed_t *feed,
spin_lock_irq(&dvbdmx->lock);
f=dvbdmxfeed->filter;
if (f==dvbdmxfilter)
if (f == dvbdmxfilter) {
dvbdmxfeed->filter=dvbdmxfilter->next;
else {
} else {
while(f->next!=dvbdmxfilter)
f=f->next;
f->next=f->next->next;
......@@ -951,8 +943,8 @@ dmx_section_feed_release_filter(dmx_section_feed_t *feed,
return 0;
}
static int dvbdmx_allocate_section_feed(dmx_demux_t *demux,
dmx_section_feed_t **feed,
static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
struct dmx_section_feed **feed,
dmx_section_cb callback)
{
struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
......@@ -977,18 +969,19 @@ static int dvbdmx_allocate_section_feed(dmx_demux_t *demux,
(*feed)->is_filtering=0;
(*feed)->parent=demux;
(*feed)->priv=0;
(*feed)->set=dmx_section_feed_set;
(*feed)->allocate_filter=dmx_section_feed_allocate_filter;
(*feed)->release_filter=dmx_section_feed_release_filter;
(*feed)->start_filtering=dmx_section_feed_start_filtering;
(*feed)->stop_filtering=dmx_section_feed_stop_filtering;
(*feed)->release_filter = dmx_section_feed_release_filter;
up(&dvbdmx->mutex);
return 0;
}
static int dvbdmx_release_section_feed(dmx_demux_t *demux,
dmx_section_feed_t *feed)
static int dvbdmx_release_section_feed(struct dmx_demux *demux,
struct dmx_section_feed *feed)
{
struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
......@@ -1010,11 +1003,12 @@ static int dvbdmx_release_section_feed(dmx_demux_t *demux,
dvbdmxfeed->state=DMX_STATE_FREE;
if (dvbdmxfeed->pid <= DMX_MAX_PID) {
list_for_each_safe(pos, n, head)
list_for_each_safe(pos, n, head) {
if (DMX_FEED_ENTRY(pos)->pid == dvbdmxfeed->pid) {
list_del(pos);
break;
}
}
dvbdmxfeed->pid = 0xffff;
}
......@@ -1027,7 +1021,7 @@ static int dvbdmx_release_section_feed(dmx_demux_t *demux,
* dvb_demux kernel data API calls
******************************************************************************/
static int dvbdmx_open(dmx_demux_t *demux)
static int dvbdmx_open(struct dmx_demux *demux)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
......@@ -1037,7 +1031,8 @@ static int dvbdmx_open(dmx_demux_t *demux)
return 0;
}
static int dvbdmx_close(struct dmx_demux_s *demux)
static int dvbdmx_close(struct dmx_demux *demux)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
......@@ -1048,12 +1043,12 @@ static int dvbdmx_close(struct dmx_demux_s *demux)
return 0;
}
static int dvbdmx_write(dmx_demux_t *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;
if ((!demux->frontend) ||
(demux->frontend->source!=DMX_MEMORY_FE))
if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE))
return -EINVAL;
if (down_interruptible (&dvbdemux->mutex))
......@@ -1065,35 +1060,25 @@ static int dvbdmx_write(dmx_demux_t *demux, const char *buf, size_t count)
}
static int dvbdmx_add_frontend(dmx_demux_t *demux,
dmx_frontend_t *frontend)
static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
struct list_head *pos, *head=&dvbdemux->frontend_list;
if (!(frontend->id && frontend->vendor && frontend->model))
return -EINVAL;
list_for_each(pos, head)
{
if (!strcmp(DMX_FE_ENTRY(pos)->id, frontend->id))
return -EEXIST;
}
struct list_head *head = &dvbdemux->frontend_list;
list_add(&(frontend->connectivity_list), head);
return 0;
}
static int
dvbdmx_remove_frontend(dmx_demux_t *demux,
dmx_frontend_t *frontend)
dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
struct list_head *pos, *n, *head=&dvbdemux->frontend_list;
list_for_each_safe (pos, n, head)
{
if (DMX_FE_ENTRY(pos)==frontend)
{
list_for_each_safe (pos, n, head) {
if (DMX_FE_ENTRY(pos) == frontend) {
list_del(pos);
return 0;
}
......@@ -1101,8 +1086,9 @@ dvbdmx_remove_frontend(dmx_demux_t *demux,
return -ENODEV;
}
static struct list_head *
dvbdmx_get_frontends(dmx_demux_t *demux)
dvbdmx_get_frontends(struct dmx_demux *demux)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
......@@ -1111,8 +1097,8 @@ dvbdmx_get_frontends(dmx_demux_t *demux)
return &dvbdemux->frontend_list;
}
static int dvbdmx_connect_frontend(dmx_demux_t *demux,
dmx_frontend_t *frontend)
int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
......@@ -1127,7 +1113,8 @@ static int dvbdmx_connect_frontend(dmx_demux_t *demux,
return 0;
}
static int dvbdmx_disconnect_frontend(dmx_demux_t *demux)
int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
......@@ -1139,7 +1126,8 @@ static int dvbdmx_disconnect_frontend(dmx_demux_t *demux)
return 0;
}
static int dvbdmx_get_pes_pids(dmx_demux_t *demux, u16 *pids)
static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids)
{
struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
......@@ -1150,8 +1138,8 @@ static int dvbdmx_get_pes_pids(dmx_demux_t *demux, u16 *pids)
int
dvb_dmx_init(struct dvb_demux *dvbdemux)
{
int i;
dmx_demux_t *dmx=&dvbdemux->dmx;
int i, err;
struct dmx_demux *dmx = &dvbdemux->dmx;
dvbdemux->users=0;
dvbdemux->filter=vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter));
......@@ -1176,8 +1164,11 @@ dvb_dmx_init(struct dvb_demux *dvbdemux)
dvbdemux->pesfilter[i]=NULL;
dvbdemux->pids[i]=0xffff;
}
dvbdemux->playing=dvbdemux->recording=0;
INIT_LIST_HEAD(&dvbdemux->feed_list);
dvbdemux->playing = 0;
dvbdemux->recording = 0;
dvbdemux->tsbufp=0;
if (!dvbdemux->check_crc32)
......@@ -1187,9 +1178,8 @@ dvb_dmx_init(struct dvb_demux *dvbdemux)
dvbdemux->memcopy = dvb_dmx_memcopy;
dmx->frontend=0;
dmx->reg_list.next=dmx->reg_list.prev=&dmx->reg_list;
dmx->reg_list.prev = dmx->reg_list.next = &dmx->reg_list;
dmx->priv=(void *) dvbdemux;
//dmx->users=0; // reset in dmx_register_demux()
dmx->open=dvbdmx_open;
dmx->close=dvbdmx_close;
dmx->write=dvbdmx_write;
......@@ -1210,8 +1200,8 @@ dvb_dmx_init(struct dvb_demux *dvbdemux)
sema_init(&dvbdemux->mutex, 1);
spin_lock_init(&dvbdemux->lock);
if (dmx_register_demux(dmx)<0)
return -1;
if ((err = dmx_register_demux(dmx)) < 0)
return err;
return 0;
}
......@@ -1219,7 +1209,7 @@ dvb_dmx_init(struct dvb_demux *dvbdemux)
int
dvb_dmx_release(struct dvb_demux *dvbdemux)
{
dmx_demux_t *dmx=&dvbdemux->dmx;
struct dmx_demux *dmx = &dvbdemux->dmx;
dmx_unregister_demux(dmx);
if (dvbdemux->filter)
......@@ -1228,10 +1218,3 @@ dvb_dmx_release(struct dvb_demux *dvbdemux)
vfree(dvbdemux->feed);
return 0;
}
#if 0
MODULE_DESCRIPTION("Software MPEG Demultiplexer");
MODULE_AUTHOR("Ralph Metzler, Markus Metzler");
MODULE_LICENSE("GPL");
#endif
......@@ -26,7 +26,9 @@
#define _DVB_DEMUX_H_
#include <asm/semaphore.h>
#include <linux/time.h>
#include <linux/timer.h>
#include <linux/spinlock.h>
#include "demux.h"
......@@ -43,7 +45,7 @@
#define DVB_DEMUX_MASK_MAX 18
struct dvb_demux_filter {
dmx_section_filter_t filter;
struct dmx_section_filter filter;
u8 maskandmode [DMX_MAX_FILTER_SIZE];
u8 maskandnotmode [DMX_MAX_FILTER_SIZE];
int doneq;
......@@ -66,8 +68,8 @@ struct dvb_demux_filter {
struct dvb_demux_feed {
union {
dmx_ts_feed_t ts;
dmx_section_feed_t sec;
struct dmx_ts_feed ts;
struct dmx_section_feed sec;
} feed;
union {
......@@ -89,7 +91,7 @@ struct dvb_demux_feed {
int cb_length;
int ts_type;
dmx_ts_pes_t pes_type;
enum dmx_ts_pes pes_type;
int cc;
......@@ -99,7 +101,7 @@ struct dvb_demux_feed {
};
struct dvb_demux {
dmx_demux_t dmx;
struct dmx_demux dmx;
void *priv;
int filternum;
int feednum;
......@@ -140,4 +142,8 @@ void dvb_dmx_swfilter_packet(struct dvb_demux *dvbdmx, const u8 *buf);
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);
int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend);
int dvbdmx_disconnect_frontend(struct dmx_demux *demux);
#endif /* _DVB_DEMUX_H_ */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/string.h>
#include "dvb_filter.h"
unsigned int bitrates[3][16] =
......@@ -6,14 +8,14 @@ unsigned int bitrates[3][16] =
{0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,0},
{0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0}};
uint32_t freq[4] = {441, 480, 320, 0};
u32 freq[4] = {441, 480, 320, 0};
unsigned int ac3_bitrates[32] =
{32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,576,640,
0,0,0,0,0,0,0,0,0,0,0,0,0};
uint32_t ac3_freq[4] = {480, 441, 320, 0};
uint32_t ac3_frames[3][32] =
u32 ac3_freq[4] = {480, 441, 320, 0};
u32 ac3_frames[3][32] =
{{64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024,
1152,1280,0,0,0,0,0,0,0,0,0,0,0,0,0},
{69,87,104,121,139,174,208,243,278,348,417,487,557,696,835,975,1114,
......@@ -67,9 +69,9 @@ void ts_to_pes(ipack *p, u8 *buf) // don't need count (=188)
#if 0
/* needs 5 byte input, returns picture coding type*/
static
int read_picture_header(uint8_t *headr, mpg_picture *pic, int field, int pr)
int read_picture_header(u8 *headr, struct mpg_picture *pic, int field, int pr)
{
uint8_t pct;
u8 pct;
if (pr) printk( "Pic header: ");
pic->temporal_reference[field] = (( headr[0] << 2 ) |
......@@ -114,7 +116,7 @@ int read_picture_header(uint8_t *headr, mpg_picture *pic, int field, int pr)
#if 0
/* needs 4 byte input */
static
int read_gop_header(uint8_t *headr, mpg_picture *pic, int pr)
int read_gop_header(u8 *headr, struct mpg_picture *pic, int pr)
{
if (pr) printk("GOP header: ");
......@@ -146,7 +148,7 @@ int read_gop_header(uint8_t *headr, mpg_picture *pic, int pr)
#if 0
/* needs 8 byte input */
static
int read_sequence_header(uint8_t *headr, VideoInfo *vi, int pr)
int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr)
{
int sw;
int form = -1;
......@@ -261,14 +263,14 @@ int read_sequence_header(uint8_t *headr, VideoInfo *vi, int pr)
#if 0
static
int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr)
int get_vinfo(u8 *mbuf, int count, struct dvb_video_info *vi, int pr)
{
uint8_t *headr;
u8 *headr;
int found = 0;
int c = 0;
while (found < 4 && c+4 < count){
uint8_t *b;
u8 *b;
b = mbuf+c;
if ( b[0] == 0x00 && b[1] == 0x00 && b[2] == 0x01
......@@ -291,15 +293,15 @@ int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr)
#if 0
static
int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
int get_ainfo(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
{
uint8_t *headr;
u8 *headr;
int found = 0;
int c = 0;
int fr = 0;
while (found < 2 && c < count){
uint8_t b[2];
u8 b[2];
memcpy( b, mbuf+c, 2);
if ( b[0] == 0xff && (b[1] & 0xf8) == 0xf8)
......@@ -346,16 +348,16 @@ int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
#endif
int dvb_filter_get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
{
uint8_t *headr;
u8 *headr;
int found = 0;
int c = 0;
uint8_t frame = 0;
u8 frame = 0;
int fr = 0;
while ( !found && c < count){
uint8_t *b = mbuf+c;
u8 *b = mbuf+c;
if ( b[0] == 0x0b && b[1] == 0x77 )
found = 1;
......@@ -378,18 +380,18 @@ int dvb_filter_get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
ai->bit_rate = ac3_bitrates[frame >> 1]*1000;
if (pr)
printk(" BRate: %d kb/s", ai->bit_rate/1000);
printk(" BRate: %d kb/s", (int) ai->bit_rate/1000);
ai->frequency = (headr[2] & 0xc0 ) >> 6;
fr = (headr[2] & 0xc0 ) >> 6;
ai->frequency = freq[fr]*100;
if (pr) printk (" Freq: %d Hz\n", ai->frequency);
if (pr) printk (" Freq: %d Hz\n", (int) ai->frequency);
ai->framesize = ac3_frames[fr][frame >> 1];
if ((frame & 1) && (fr == 1)) ai->framesize++;
ai->framesize = ai->framesize << 1;
if (pr) printk (" Framesize %d\n", ai->framesize);
if (pr) printk (" Framesize %d\n",(int) ai->framesize);
return 0;
......@@ -398,11 +400,11 @@ int dvb_filter_get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
#if 0
static
uint8_t *skip_pes_header(uint8_t **bufp)
u8 *skip_pes_header(u8 **bufp)
{
uint8_t *inbuf = *bufp;
uint8_t *buf = inbuf;
uint8_t *pts = NULL;
u8 *inbuf = *bufp;
u8 *buf = inbuf;
u8 *pts = NULL;
int skip = 0;
static const int mpeg1_skip_table[16] = {
......@@ -437,7 +439,7 @@ uint8_t *skip_pes_header(uint8_t **bufp)
#if 0
static
void initialize_quant_matrix( uint32_t *matrix )
void initialize_quant_matrix( u32 *matrix )
{
int i;
......@@ -465,7 +467,7 @@ void initialize_quant_matrix( uint32_t *matrix )
#if 0
static
void initialize_mpg_picture(mpg_picture *pic)
void initialize_mpg_picture(struct mpg_picture *pic)
{
int i;
......@@ -493,7 +495,7 @@ void initialize_mpg_picture(mpg_picture *pic)
#if 0
static
void mpg_set_picture_parameter( int32_t field_type, mpg_picture *pic )
void mpg_set_picture_parameter( int32_t field_type, struct mpg_picture *pic )
{
int16_t last_h_offset;
int16_t last_v_offset;
......@@ -532,7 +534,7 @@ void mpg_set_picture_parameter( int32_t field_type, mpg_picture *pic )
#if 0
static
void init_mpg_picture( mpg_picture *pic, int chan, int32_t field_type)
void init_mpg_picture( struct mpg_picture *pic, int chan, int32_t field_type)
{
pic->picture_header = 0;
pic->sequence_header_data
......@@ -561,7 +563,7 @@ void init_mpg_picture( mpg_picture *pic, int chan, int32_t field_type)
}
#endif
void dvb_filter_pes2ts_init(dvb_filter_pes2ts_t *p2ts, unsigned short pid,
void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid,
dvb_filter_pes2ts_cb_t *cb, void *priv)
{
unsigned char *buf=p2ts->buf;
......@@ -574,7 +576,7 @@ void dvb_filter_pes2ts_init(dvb_filter_pes2ts_t *p2ts, unsigned short pid,
p2ts->priv=priv;
}
int dvb_filter_pes2ts(dvb_filter_pes2ts_t *p2ts, unsigned char *pes, int len)
int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes, int len)
{
unsigned char *buf=p2ts->buf;
int ret=0, rest;
......
......@@ -2,23 +2,22 @@
#define _DVB_FILTER_H_
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include "demux.h"
typedef int (dvb_filter_pes2ts_cb_t) (void *, unsigned char *);
typedef struct dvb_filter_pes2ts_s {
struct dvb_filter_pes2ts {
unsigned char buf[188];
unsigned char cc;
dvb_filter_pes2ts_cb_t *cb;
void *priv;
} dvb_filter_pes2ts_t;
};
void dvb_filter_pes2ts_init(dvb_filter_pes2ts_t *p2ts, unsigned short pid,
void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid,
dvb_filter_pes2ts_cb_t *cb, void *priv);
int dvb_filter_pes2ts(dvb_filter_pes2ts_t *p2ts, unsigned char *pes, int len);
int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes, int len);
#define PROG_STREAM_MAP 0xBC
......@@ -35,14 +34,14 @@ int dvb_filter_pes2ts(dvb_filter_pes2ts_t *p2ts, unsigned char *pes, int len);
#define ISO13522_STREAM 0xF3
#define PROG_STREAM_DIR 0xFF
#define PICTURE_START 0x00
#define USER_START 0xb2
#define SEQUENCE_HEADER 0xb3
#define SEQUENCE_ERROR 0xb4
#define EXTENSION_START 0xb5
#define SEQUENCE_END 0xb7
#define GOP_START 0xb8
#define EXCEPT_SLICE 0xb0
#define DVB_PICTURE_START 0x00
#define DVB_USER_START 0xb2
#define DVB_SEQUENCE_HEADER 0xb3
#define DVB_SEQUENCE_ERROR 0xb4
#define DVB_EXTENSION_START 0xb5
#define DVB_SEQUENCE_END 0xb7
#define DVB_GOP_START 0xb8
#define DVB_EXCEPT_SLICE 0xb0
#define SEQUENCE_EXTENSION 0x01
#define SEQUENCE_DISPLAY_EXTENSION 0x02
......@@ -111,12 +110,12 @@ int dvb_filter_pes2ts(dvb_filter_pes2ts_t *p2ts, unsigned char *pes, int len);
#define IPACKS 2048
#endif
typedef struct ipack_s {
struct ipack {
int size;
int found;
u8 *buf;
u8 cid;
uint32_t plength;
u32 plength;
u8 plen[2];
u8 flag1;
u8 flag2;
......@@ -131,34 +130,33 @@ typedef struct ipack_s {
void (*func)(u8 *buf, int size, void *priv);
int count;
int repack_subids;
} ipack;
typedef struct video_i{
uint32_t horizontal_size;
uint32_t vertical_size;
uint32_t aspect_ratio;
uint32_t framerate;
uint32_t video_format;
uint32_t bit_rate;
uint32_t comp_bit_rate;
uint32_t vbv_buffer_size;
int16_t vbv_delay;
uint32_t CSPF;
uint32_t off;
} VideoInfo;
};
struct dvb_video_info {
u32 horizontal_size;
u32 vertical_size;
u32 aspect_ratio;
u32 framerate;
u32 video_format;
u32 bit_rate;
u32 comp_bit_rate;
u32 vbv_buffer_size;
s16 vbv_delay;
u32 CSPF;
u32 off;
};
#define OFF_SIZE 4
#define FIRST_FIELD 0
#define SECOND_FIELD 1
#define VIDEO_FRAME_PICTURE 0x03
typedef struct mpg_picture_s{
struct mpg_picture {
int channel;
VideoInfo vinfo;
uint32_t *sequence_gop_header;
uint32_t *picture_header;
int32_t time_code;
struct dvb_video_info vinfo;
u32 *sequence_gop_header;
u32 *picture_header;
s32 time_code;
int low_delay;
int closed_gop;
int broken_link;
......@@ -166,12 +164,12 @@ typedef struct mpg_picture_s{
int gop_flag;
int sequence_end_flag;
uint8_t profile_and_level;
int32_t picture_coding_parameter;
uint32_t matrix[32];
int8_t matrix_change_flag;
u8 profile_and_level;
s32 picture_coding_parameter;
u32 matrix[32];
s8 matrix_change_flag;
uint8_t picture_header_parameter;
u8 picture_header_parameter;
/* bit 0 - 2: bwd f code
bit 3 : fpb vector
bit 4 - 6: fwd f code
......@@ -180,11 +178,11 @@ typedef struct mpg_picture_s{
int mpeg1_flag;
int progressive_sequence;
int sequence_display_extension_flag;
uint32_t sequence_header_data;
int16_t last_frame_centre_horizontal_offset;
int16_t last_frame_centre_vertical_offset;
u32 sequence_header_data;
s16 last_frame_centre_horizontal_offset;
s16 last_frame_centre_vertical_offset;
uint32_t pts[2]; /* [0] 1st field, [1] 2nd field */
u32 pts[2]; /* [0] 1st field, [1] 2nd field */
int top_field_first;
int repeat_first_field;
int progressive_frame;
......@@ -192,39 +190,36 @@ typedef struct mpg_picture_s{
int forward_bank;
int backward_bank;
int compress;
int16_t frame_centre_horizontal_offset[OFF_SIZE];
s16 frame_centre_horizontal_offset[OFF_SIZE];
/* [0-2] 1st field, [3] 2nd field */
int16_t frame_centre_vertical_offset[OFF_SIZE];
s16 frame_centre_vertical_offset[OFF_SIZE];
/* [0-2] 1st field, [3] 2nd field */
int16_t temporal_reference[2];
s16 temporal_reference[2];
/* [0] 1st field, [1] 2nd field */
int8_t picture_coding_type[2];
s8 picture_coding_type[2];
/* [0] 1st field, [1] 2nd field */
int8_t picture_structure[2];
s8 picture_structure[2];
/* [0] 1st field, [1] 2nd field */
int8_t picture_display_extension_flag[2];
s8 picture_display_extension_flag[2];
/* [0] 1st field, [1] 2nd field */
/* picture_display_extenion() 0:no 1:exit*/
int8_t pts_flag[2];
s8 pts_flag[2];
/* [0] 1st field, [1] 2nd field */
} mpg_picture;
};
typedef struct audio_i{
struct dvb_audio_info {
int layer ;
uint32_t bit_rate ;
uint32_t frequency ;
uint32_t mode ;
uint32_t mode_extension ;
uint32_t emphasis ;
uint32_t framesize;
uint32_t off;
} AudioInfo;
int dvb_filter_get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr);
u32 bit_rate;
u32 frequency;
u32 mode;
u32 mode_extension ;
u32 emphasis;
u32 framesize;
u32 off;
};
int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr);
#endif
......@@ -22,8 +22,12 @@
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
#include <asm/processor.h>
#include <asm/semaphore.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/wait.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/module.h>
......@@ -31,6 +35,7 @@
#include "dvb_frontend.h"
#include "dvbdev.h"
#include "dvb_functions.h"
static int dvb_frontend_debug = 0;
......@@ -59,7 +64,7 @@ struct dvb_frontend_data {
struct semaphore sem;
struct list_head list_head;
wait_queue_head_t wait_queue;
struct task_struct *thread;
pid_t thread_pid;
unsigned long release_jiffies;
unsigned long lost_sync_jiffies;
int bending;
......@@ -97,14 +102,6 @@ static LIST_HEAD(frontend_notifier_list);
static DECLARE_MUTEX(frontend_mutex);
static
inline void ddelay (int ms)
{
current->state=TASK_INTERRUPTIBLE;
schedule_timeout((HZ*ms)/1000);
}
static
int dvb_frontend_internal_ioctl (struct dvb_frontend *frontend,
unsigned int cmd, void *arg)
......@@ -116,10 +113,10 @@ int dvb_frontend_internal_ioctl (struct dvb_frontend *frontend,
if (frontend->before_ioctl)
err = frontend->before_ioctl (frontend, cmd, arg);
if (err) {
if (err == -EOPNOTSUPP) {
err = frontend->ioctl (frontend, cmd, arg);
if (err && frontend->after_ioctl)
if ((err == -EOPNOTSUPP) && frontend->after_ioctl)
err = frontend->after_ioctl (frontend, cmd, arg);
}
......@@ -198,7 +195,7 @@ void dvb_call_frontend_notifiers (struct dvb_frontend_data *fe,
fe->lost_sync_jiffies = jiffies;
if (((s ^ fe->status) & FE_HAS_LOCK) && (s & FE_HAS_LOCK))
ddelay (fe->info->notifier_delay);
dvb_delay (fe->info->notifier_delay);
fe->status = s;
......@@ -313,7 +310,7 @@ int dvb_frontend_set_parameters (struct dvb_frontend_data *fe,
dvb_bend_frequency (fe, 0);
dprintk ("%s: f == %i, drift == %i\n",
__FUNCTION__, param->frequency, fe->lnb_drift);
__FUNCTION__, (int) param->frequency, (int) fe->lnb_drift);
param->frequency += fe->lnb_drift + fe->bending;
err = dvb_frontend_internal_ioctl (frontend, FE_SET_FRONTEND, param);
......@@ -391,6 +388,8 @@ void dvb_frontend_recover (struct dvb_frontend_data *fe)
if (fe->info->type == FE_QPSK)
stepsize = fe->parameters.u.qpsk.symbol_rate / 16000;
else if (fe->info->type == FE_QAM)
stepsize = 0;
else
stepsize = fe->info->frequency_stepsize * 2;
......@@ -428,42 +427,31 @@ static
int dvb_frontend_thread (void *data)
{
struct dvb_frontend_data *fe = (struct dvb_frontend_data *) data;
char name [15];
int quality = 0, delay = 3*HZ;
fe_status_t s;
dprintk ("%s\n", __FUNCTION__);
lock_kernel ();
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,61))
daemonize ();
#else
daemonize ("dvb fe");
#endif
/* not needed anymore in 2.5.x, done in daemonize() */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
reparent_to_init ();
#endif
sigfillset (&current->blocked);
fe->thread = current;
snprintf (current->comm, sizeof (current->comm), "kdvb-fe-%i:%i",
snprintf (name, sizeof(name), "kdvb-fe-%i:%i",
fe->frontend.i2c->adapter->num, fe->frontend.i2c->id);
unlock_kernel ();
dvb_call_frontend_notifiers (fe, 0);
dvb_frontend_init (fe);
dvb_kernel_thread_setup (name);
fe->lost_sync_count = -1;
dvb_call_frontend_notifiers (fe, 0);
dvb_frontend_init (fe);
while (!dvb_frontend_is_exiting (fe)) {
up (&fe->sem); /* is locked when we enter the thread... */
interruptible_sleep_on_timeout (&fe->wait_queue, delay);
if (signal_pending(current))
break;
if (down_interruptible (&fe->sem)) {
fe->thread = NULL;
return -ERESTARTSYS;
}
if (down_interruptible (&fe->sem))
break;
if (fe->lost_sync_count == -1)
continue;
......@@ -505,7 +493,11 @@ int dvb_frontend_thread (void *data)
dvb_frontend_internal_ioctl (&fe->frontend, FE_SLEEP, NULL);
up (&fe->sem);
fe->thread = NULL;
fe->thread_pid = 0;
mb();
wake_up_interruptible (&fe->wait_queue);
return 0;
}
......@@ -515,32 +507,63 @@ void dvb_frontend_stop (struct dvb_frontend_data *fe)
{
dprintk ("%s\n", __FUNCTION__);
while (fe->thread) {
fe->exit = 1;
mb();
if (!fe->thread_pid)
return;
/* check if the thread is really alive */
if (kill_proc(fe->thread_pid, 0, 1) == -ESRCH) {
printk("dvb_frontend_stop: thread PID %d already died\n",
fe->thread_pid);
/* make sure the mutex was not held by the thread */
init_MUTEX (&fe->sem);
return;
}
wake_up_interruptible (&fe->wait_queue);
current->state = TASK_INTERRUPTIBLE;
schedule_timeout (5);
if (signal_pending(current))
break;
};
interruptible_sleep_on(&fe->wait_queue);
/* paranoia check */
if (fe->thread_pid)
printk("dvb_frontend_stop: warning: thread PID %d won't exit\n",
fe->thread_pid);
}
static
void dvb_frontend_start (struct dvb_frontend_data *fe)
int dvb_frontend_start (struct dvb_frontend_data *fe)
{
int ret;
dprintk ("%s\n", __FUNCTION__);
if (fe->thread)
if (fe->thread_pid) {
if (!fe->exit)
return 0;
else
dvb_frontend_stop (fe);
}
if (signal_pending(current))
return -EINTR;
if (down_interruptible (&fe->sem))
return;
return -EINTR;
fe->exit = 0;
fe->thread = (void*) ~0;
fe->thread_pid = 0;
mb();
kernel_thread (dvb_frontend_thread, fe, 0);
ret = kernel_thread (dvb_frontend_thread, fe, 0);
if (ret < 0) {
printk("dvb_frontend_start: failed to start kernel_thread (%d)\n", ret);
up(&fe->sem);
return ret;
}
fe->thread_pid = ret;
return 0;
}
......@@ -618,10 +641,12 @@ int dvb_frontend_open (struct inode *inode, struct file *file)
return ret;
if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
dvb_frontend_start (fe);
ret = dvb_frontend_start (fe);
if (ret)
dvb_generic_release (inode, file);
/* empty event queue */
fe->events.eventr = fe->events.eventw;
fe->events.eventr = fe->events.eventw = 0;
}
return ret;
......
......@@ -30,10 +30,7 @@
#include <linux/ioctl.h>
#include <linux/i2c.h>
#include <linux/module.h>
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(x)
#endif
#include <linux/errno.h>
#include <linux/dvb/frontend.h>
......
#include <linux/smp_lock.h>
#include <linux/version.h>
#include <asm/uaccess.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/version.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include <linux/fs.h>
void dvb_kernel_thread_setup (const char *thread_name)
{
lock_kernel ();
daemonize (thread_name);
sigfillset (&current->blocked);
unlock_kernel ();
}
/* if the miracle happens and "generic_usercopy()" is included into
the kernel, then this can vanish. please don't make the mistake and
define this as video_usercopy(). this will introduce a dependecy
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,
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:
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 *)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 *)arg, parg, _IOC_SIZE(cmd)))
err = -EFAULT;
break;
}
out:
if (mbuf)
kfree(mbuf);
return err;
}
EXPORT_SYMBOL(dvb_usercopy);
EXPORT_SYMBOL(dvb_kernel_thread_setup);
#ifndef __DVB_FUNCTIONS_H__
#define __DVB_FUNCTIONS_H__
/**
* a sleeping delay function, waits i ms
*
*/
static inline
void dvb_delay(int i)
{
current->state=TASK_INTERRUPTIBLE;
schedule_timeout((HZ*i)/1000);
}
/* we don't mess with video_usercopy() any more,
we simply define out own dvb_usercopy(), which will hopefull become
generic_usercopy() someday... */
extern int dvb_usercopy(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg,
int (*func)(struct inode *inode, struct file *file,
unsigned int cmd, void *arg));
extern void dvb_kernel_thread_setup (const char *thread_name);
#endif
......@@ -19,16 +19,15 @@
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
#include <asm/semaphore.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#include "compat.h"
#endif
#include "dvb_i2c.h"
#include "dvb_functions.h"
struct dvb_i2c_device {
struct list_head list_head;
......
#include <asm/uaccess.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include "dmxdev.h"
#include "dvb_filter.h"
#include "dvb_frontend.h"
#include "dvb_i2c.h"
#include "dvbdev.h"
#include "dvb_demux.h"
#include "dvb_frontend.h"
#include "dvb_net.h"
/* if the miracle happens and "generic_usercopy()" is included into
the kernel, then this can vanish. please don't make the mistake and
define this as video_usercopy(). this will introduce a dependecy
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,
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:
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 *)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 *)arg, parg, _IOC_SIZE(cmd)))
err = -EFAULT;
break;
}
out:
if (mbuf)
kfree(mbuf);
return err;
}
EXPORT_SYMBOL(dvb_usercopy);
#include "dvb_filter.h"
EXPORT_SYMBOL(dvb_dmxdev_init);
EXPORT_SYMBOL(dvb_dmxdev_release);
......@@ -79,6 +18,8 @@ EXPORT_SYMBOL(dvb_dmx_release);
EXPORT_SYMBOL(dvb_dmx_swfilter_packet);
EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
EXPORT_SYMBOL(dvb_dmx_swfilter);
EXPORT_SYMBOL(dvbdmx_connect_frontend);
EXPORT_SYMBOL(dvbdmx_disconnect_frontend);
EXPORT_SYMBOL(dvb_register_frontend);
EXPORT_SYMBOL(dvb_unregister_frontend);
......
......@@ -25,14 +25,17 @@
*/
#include <asm/uaccess.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/ioctl.h>
#include <linux/slab.h>
#include <linux/dvb/net.h>
#include "dvb_demux.h"
#include "dvb_net.h"
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#include "compat.h"
#endif
#include "dvb_functions.h"
#define DVB_NET_MULTICAST_MAX 10
......@@ -40,11 +43,11 @@ struct dvb_net_priv {
struct net_device_stats stats;
char name[6];
u16 pid;
struct dmx_demux_s *demux;
dmx_section_feed_t *secfeed;
dmx_section_filter_t *secfilter;
struct dmx_demux *demux;
struct dmx_section_feed *secfeed;
struct dmx_section_filter *secfilter;
int multi_num;
dmx_section_filter_t *multi_secfilter[DVB_NET_MULTICAST_MAX];
struct dmx_section_filter *multi_secfilter[DVB_NET_MULTICAST_MAX];
unsigned char multi_macs[DVB_NET_MULTICAST_MAX][6];
int mode;
};
......@@ -135,8 +138,8 @@ dvb_net_sec(struct net_device *dev, const u8 *pkt, int pkt_len)
static int
dvb_net_callback(const u8 *buffer1, size_t buffer1_len,
const u8 *buffer2, size_t buffer2_len,
dmx_section_filter_t *filter,
dmx_success_t success)
struct dmx_section_filter *filter,
enum dmx_success success)
{
struct net_device *dev=(struct net_device *) filter->priv;
......@@ -159,7 +162,7 @@ static u8 mask_promisc[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static int
dvb_net_filter_set(struct net_device *dev,
dmx_section_filter_t **secfilter,
struct dmx_section_filter **secfilter,
u8 *mac, u8 *mac_mask)
{
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
......@@ -205,7 +208,7 @@ dvb_net_feed_start(struct net_device *dev)
{
int ret, i;
struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv;
dmx_demux_t *demux = priv->demux;
struct dmx_demux *demux = priv->demux;
unsigned char *mac = (unsigned char *) dev->dev_addr;
priv->secfeed=0;
......@@ -430,7 +433,7 @@ int
dvb_net_add_if(struct dvb_net *dvbnet, u16 pid)
{
struct net_device *net;
dmx_demux_t *demux;
struct dmx_demux *demux;
struct dvb_net_priv *priv;
int result;
int if_num;
......@@ -524,7 +527,7 @@ int dvb_net_do_ioctl(struct inode *inode, struct file *file,
break;
}
case NET_REMOVE_IF:
return dvb_net_remove_if(dvbnet, (int) parg);
return dvb_net_remove_if(dvbnet, (long) parg);
default:
return -EINVAL;
}
......@@ -569,7 +572,7 @@ dvb_net_release(struct dvb_net *dvbnet)
}
int
dvb_net_init(struct dvb_adapter *adap, struct dvb_net *dvbnet, dmx_demux_t *dmx)
dvb_net_init(struct dvb_adapter *adap, struct dvb_net *dvbnet, struct dmx_demux *dmx)
{
int i;
......
......@@ -33,18 +33,18 @@
#define DVB_NET_DEVICES_MAX 10
typedef struct dvb_net {
struct dvb_net {
struct dvb_device *dvbdev;
int card_num;
int dev_num;
struct net_device device[DVB_NET_DEVICES_MAX];
int state[DVB_NET_DEVICES_MAX];
dmx_demux_t *demux;
} dvb_net_t;
struct dmx_demux *demux;
};
void dvb_net_release(struct dvb_net *);
int dvb_net_init(struct dvb_adapter *, struct dvb_net *, dmx_demux_t *);
int dvb_net_init(struct dvb_adapter *, struct dvb_net *, struct dmx_demux *);
#endif
......@@ -32,16 +32,18 @@
#define __KERNEL_SYSCALLS__
#include <asm/uaccess.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <asm/uaccess.h>
#include <linux/sched.h>
#include <linux/string.h>
#include "dvb_ringbuffer.h"
void dvb_ringbuffer_init(dvb_ringbuffer_t *rbuf, void *data, size_t len)
void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len)
{
rbuf->pread=rbuf->pwrite=0;
rbuf->data=data;
......@@ -50,19 +52,18 @@ void dvb_ringbuffer_init(dvb_ringbuffer_t *rbuf, void *data, size_t len)
init_waitqueue_head(&rbuf->queue);
spin_lock_init(&(rbuf->lock));
rbuf->lock=SPIN_LOCK_UNLOCKED;
}
int dvb_ringbuffer_empty(dvb_ringbuffer_t *rbuf)
int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf)
{
return (rbuf->pread==rbuf->pwrite);
}
ssize_t dvb_ringbuffer_free(dvb_ringbuffer_t *rbuf)
ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf)
{
ssize_t free;
......@@ -74,7 +75,7 @@ ssize_t dvb_ringbuffer_free(dvb_ringbuffer_t *rbuf)
ssize_t dvb_ringbuffer_avail(dvb_ringbuffer_t *rbuf)
ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf)
{
ssize_t avail;
......@@ -86,14 +87,14 @@ ssize_t dvb_ringbuffer_avail(dvb_ringbuffer_t *rbuf)
void dvb_ringbuffer_flush(dvb_ringbuffer_t *rbuf)
void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
{
rbuf->pread = rbuf->pwrite;
}
void dvb_ringbuffer_flush_spinlock_wakeup(dvb_ringbuffer_t *rbuf)
void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf)
{
unsigned long flags;
......@@ -106,7 +107,7 @@ void dvb_ringbuffer_flush_spinlock_wakeup(dvb_ringbuffer_t *rbuf)
ssize_t dvb_ringbuffer_read(dvb_ringbuffer_t *rbuf, u8 *buf, size_t len, int usermem)
ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, size_t len, int usermem)
{
size_t todo = len;
size_t split;
......@@ -135,7 +136,7 @@ ssize_t dvb_ringbuffer_read(dvb_ringbuffer_t *rbuf, u8 *buf, size_t len, int use
ssize_t dvb_ringbuffer_write(dvb_ringbuffer_t *rbuf, const u8 *buf,
ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf,
size_t len, int usermem)
{
size_t todo = len;
......
......@@ -32,8 +32,10 @@
#ifndef _DVB_RINGBUFFER_H_
#define _DVB_RINGBUFFER_H_
#include <linux/spinlock.h>
#include <linux/wait.h>
typedef struct dvb_ringbuffer {
struct dvb_ringbuffer {
u8 *data;
ssize_t size;
ssize_t pread;
......@@ -41,7 +43,7 @@ typedef struct dvb_ringbuffer {
wait_queue_head_t queue;
spinlock_t lock;
} dvb_ringbuffer_t;
};
/*
......@@ -73,25 +75,25 @@ typedef struct dvb_ringbuffer {
*/
/* initialize ring buffer, lock and queue */
extern void dvb_ringbuffer_init(dvb_ringbuffer_t *rbuf, void *data, size_t len);
extern void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len);
/* test whether buffer is empty */
extern int dvb_ringbuffer_empty(dvb_ringbuffer_t *rbuf);
extern int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf);
/* return the number of free bytes in the buffer */
extern ssize_t dvb_ringbuffer_free(dvb_ringbuffer_t *rbuf);
extern ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf);
/* return the number of bytes waiting in the buffer */
extern ssize_t dvb_ringbuffer_avail(dvb_ringbuffer_t *rbuf);
extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf);
/* read routines & macros */
/* ---------------------- */
/* flush buffer */
extern void dvb_ringbuffer_flush(dvb_ringbuffer_t *rbuf);
extern void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf);
/* flush buffer protected by spinlock and wake-up waiting task(s) */
extern void dvb_ringbuffer_flush_spinlock_wakeup(dvb_ringbuffer_t *rbuf);
extern void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf);
/* peek at byte <offs> in the buffer */
#define DVB_RINGBUFFER_PEEK(rbuf,offs) \
......@@ -106,7 +108,7 @@ extern void dvb_ringbuffer_flush_spinlock_wakeup(dvb_ringbuffer_t *rbuf);
** <usermem> specifies whether <buf> resides in user space
** returns number of bytes transferred or -EFAULT
*/
extern ssize_t dvb_ringbuffer_read(dvb_ringbuffer_t *rbuf, u8 *buf,
extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf,
size_t len, int usermem);
......@@ -121,7 +123,7 @@ extern ssize_t dvb_ringbuffer_read(dvb_ringbuffer_t *rbuf, u8 *buf,
** <usermem> specifies whether <buf> resides in user space
** returns number of bytes transferred or -EFAULT
*/
extern ssize_t dvb_ringbuffer_write(dvb_ringbuffer_t *rbuf, const u8 *buf,
extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf,
size_t len, int usermem);
#endif /* _DVB_RINGBUFFER_H_ */
......@@ -21,26 +21,19 @@
*
*/
#include <linux/config.h>
#include <linux/version.h>
#include <asm/types.h>
#include <asm/semaphore.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/version.h>
#include "dvbdev.h"
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
#include "compat.h"
#endif
#include "dvb_functions.h"
static int dvbdev_debug = 0;
#define dprintk if (dvbdev_debug) printk
......@@ -188,8 +181,8 @@ int dvbdev_get_free_id (struct dvb_adapter *adap, int type)
int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
const struct dvb_device *template, void *priv, int type)
{
u32 id;
struct dvb_device *dvbdev;
int id;
if (down_interruptible (&dvbdev_register_lock))
return -ERESTARTSYS;
......@@ -284,10 +277,6 @@ int dvb_register_adapter(struct dvb_adapter **padap, const char *name)
memset (adap, 0, sizeof(struct dvb_adapter));
INIT_LIST_HEAD (&adap->device_list);
/* fixme: is this correct? */
/* No */
try_module_get(THIS_MODULE);
printk ("DVB: registering new adapter (%s).\n", name);
devfs_mk_dir("dvb/adapter%d", num);
......@@ -310,9 +299,6 @@ int dvb_unregister_adapter(struct dvb_adapter *adap)
list_del (&adap->list_head);
up (&dvbdev_register_lock);
kfree (adap);
/* fixme: is this correct? */
/* No. */
module_put(THIS_MODULE);
return 0;
}
......
......@@ -24,9 +24,9 @@
#ifndef _DVBDEV_H_
#define _DVBDEV_H_
#include <linux/types.h>
#include <linux/version.h>
#include <asm/types.h>
#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/list.h>
......@@ -84,9 +84,5 @@ extern int dvb_generic_open (struct inode *inode, struct file *file);
extern int dvb_generic_release (struct inode *inode, struct file *file);
extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
int dvb_usercopy(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg,
int (*func)(struct inode *inode, struct file *file,
unsigned int cmd, void *arg));
#endif /* #ifndef _DVBDEV_H_ */
......@@ -24,10 +24,10 @@
#ifndef _DVBDMX_H_
#define _DVBDMX_H_
#include <asm/types.h>
#ifdef __KERNEL__
#include <linux/types.h>
#include <linux/time.h>
#else
#include <stdint.h>
#include <time.h>
#endif
......@@ -103,18 +103,18 @@ typedef enum
typedef struct dmx_filter
{
uint8_t filter[DMX_FILTER_SIZE];
uint8_t mask[DMX_FILTER_SIZE];
uint8_t mode[DMX_FILTER_SIZE];
__u8 filter[DMX_FILTER_SIZE];
__u8 mask[DMX_FILTER_SIZE];
__u8 mode[DMX_FILTER_SIZE];
} dmx_filter_t;
struct dmx_sct_filter_params
{
uint16_t pid;
__u16 pid;
dmx_filter_t filter;
uint32_t timeout;
uint32_t flags;
__u32 timeout;
__u32 flags;
#define DMX_CHECK_CRC 1
#define DMX_ONESHOT 2
#define DMX_IMMEDIATE_START 4
......@@ -124,11 +124,11 @@ struct dmx_sct_filter_params
struct dmx_pes_filter_params
{
uint16_t pid;
__u16 pid;
dmx_input_t input;
dmx_output_t output;
dmx_pes_type_t pes_type;
uint32_t flags;
__u32 flags;
};
......@@ -143,7 +143,7 @@ struct dmx_event
};
typedef struct dmx_caps {
uint32_t caps;
__u32 caps;
int num_decoders;
} dmx_caps_t;
......@@ -161,7 +161,7 @@ typedef enum {
struct dmx_stc {
unsigned int num; /* input : which STC? 0..N */
unsigned int base; /* output: divisor for stc to get 90 kHz clock */
uint64_t stc; /* output: stc in 'base'*90 kHz units */
__u64 stc; /* output: stc in 'base'*90 kHz units */
};
......@@ -171,7 +171,7 @@ struct dmx_stc {
#define DMX_SET_PES_FILTER _IOW('o',44,struct dmx_pes_filter_params)
#define DMX_SET_BUFFER_SIZE _IO('o',45)
#define DMX_GET_EVENT _IOR('o',46,struct dmx_event)
#define DMX_GET_PES_PIDS _IOR('o',47,uint16_t[5])
#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
#define DMX_GET_CAPS _IOR('o',48,dmx_caps_t)
#define DMX_SET_SOURCE _IOW('o',49,dmx_source_t)
#define DMX_GET_STC _IOWR('o',50,struct dmx_stc)
......
......@@ -26,11 +26,7 @@
#ifndef _DVBFRONTEND_H_
#define _DVBFRONTEND_H_
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#endif
#include <asm/types.h>
typedef enum fe_type {
......@@ -72,14 +68,14 @@ typedef enum fe_caps {
struct dvb_frontend_info {
char name[128];
fe_type_t type;
uint32_t frequency_min;
uint32_t frequency_max;
uint32_t frequency_stepsize;
uint32_t frequency_tolerance;
uint32_t symbol_rate_min;
uint32_t symbol_rate_max;
uint32_t symbol_rate_tolerance; /* ppm */
uint32_t notifier_delay; /* ms */
__u32 frequency_min;
__u32 frequency_max;
__u32 frequency_stepsize;
__u32 frequency_tolerance;
__u32 symbol_rate_min;
__u32 symbol_rate_max;
__u32 symbol_rate_tolerance; /* ppm */
__u32 notifier_delay; /* ms */
fe_caps_t caps;
};
......@@ -89,21 +85,22 @@ struct dvb_frontend_info {
* the meaning of this struct...
*/
struct dvb_diseqc_master_cmd {
uint8_t msg [6]; /* { framing, address, command, data [3] } */
uint8_t msg_len; /* valid values are 3...6 */
__u8 msg [6]; /* { framing, address, command, data [3] } */
__u8 msg_len; /* valid values are 3...6 */
};
struct dvb_diseqc_slave_reply {
uint8_t msg [4]; /* { framing, data [3] } */
uint8_t msg_len; /* valid values are 0...4, 0 means no msg */
__u8 msg [4]; /* { framing, data [3] } */
__u8 msg_len; /* valid values are 0...4, 0 means no msg */
int timeout; /* return from ioctl after timeout ms with */
}; /* errorcode when no message was received */
typedef enum fe_sec_voltage {
SEC_VOLTAGE_13,
SEC_VOLTAGE_18
SEC_VOLTAGE_18,
SEC_VOLTAGE_OFF
} fe_sec_voltage_t;
......@@ -195,13 +192,13 @@ typedef enum fe_hierarchy {
struct dvb_qpsk_parameters {
uint32_t symbol_rate; /* symbol rate in Symbols per second */
__u32 symbol_rate; /* symbol rate in Symbols per second */
fe_code_rate_t fec_inner; /* forward error correction (see above) */
};
struct dvb_qam_parameters {
uint32_t symbol_rate; /* symbol rate in Symbols per second */
__u32 symbol_rate; /* symbol rate in Symbols per second */
fe_code_rate_t fec_inner; /* forward error correction (see above) */
fe_modulation_t modulation; /* modulation type (see above) */
};
......@@ -219,7 +216,7 @@ struct dvb_ofdm_parameters {
struct dvb_frontend_parameters {
uint32_t frequency; /* (absolute) frequency in Hz for QAM/OFDM */
__u32 frequency; /* (absolute) frequency in Hz for QAM/OFDM */
/* intermediate frequency in kHz for QPSK */
fe_spectral_inversion_t inversion;
union {
......@@ -249,10 +246,10 @@ struct dvb_frontend_event {
#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
#define FE_READ_BER _IOR('o', 70, uint32_t)
#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, uint16_t)
#define FE_READ_SNR _IOR('o', 72, uint16_t)
#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, uint32_t)
#define FE_READ_BER _IOR('o', 70, __u32)
#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
#define FE_READ_SNR _IOR('o', 72, __u16)
#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters)
#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters)
......
......@@ -24,16 +24,12 @@
#ifndef _DVBNET_H_
#define _DVBNET_H_
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#endif
#include <asm/types.h>
struct dvb_net_if {
uint16_t pid;
uint16_t if_num;
__u16 pid;
__u16 if_num;
};
......
/*
* version.h
*
* Copyright (C) 2000 Holger Waechtler <holger@convergence.de>
* for convergence integrated media GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _DVBVERSION_H_
#define _DVBVERSION_H_
#define DVB_API_VERSION 3
#endif /*_DVBVERSION_H_*/
......@@ -34,7 +34,8 @@
typedef enum {
VIDEO_FORMAT_4_3, /* Select 4:3 format */
VIDEO_FORMAT_16_9 /* Select 16:9 format. */
VIDEO_FORMAT_16_9, /* Select 16:9 format. */
VIDEO_FORMAT_221_1 /* 2.21:1 */
} video_format_t;
......@@ -56,6 +57,11 @@ typedef enum {
VIDEO_CENTER_CUT_OUT /* use center cut out format */
} video_displayformat_t;
typedef struct {
int w;
int h;
video_format_t aspect_ratio;
} video_size_t;
typedef enum {
VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */
......@@ -74,9 +80,10 @@ typedef enum {
struct video_event {
int32_t type;
#define VIDEO_EVENT_SIZE_CHANGED 1
time_t timestamp;
union {
video_format_t video_format;
video_size_t size;
} u;
};
......@@ -186,6 +193,7 @@ typedef uint16_t video_attributes_t;
#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t)
#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t)
#define VIDEO_SET_ATTRIBUTES _IO('o', 53)
#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
#endif /*_DVBVIDEO_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