Commit 0a727c0d authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] Digital TV framework

DVB is very different in its need to analogue video. This merges the
cleaned up version of the DVB framework from Convergence, which has been
around for a couple of years.
parent f232856f
......@@ -8,6 +8,7 @@ tristate 'Video For Linux' CONFIG_VIDEO_DEV
if [ "$CONFIG_VIDEO_DEV" != "n" ]; then
source drivers/media/video/Config.in
source drivers/media/radio/Config.in
source drivers/media/dvb/Config.in
fi
endmenu
......@@ -2,6 +2,6 @@
# Makefile for the kernel multimedia device drivers.
#
obj-y := video/ radio/
obj-y := video/ radio/ dvb/
include $(TOPDIR)/Rules.make
CONFIG_DVB
Support Digital Video Broadcasting hardware. Enable this if you
own a DVB adapter and want to use it or if you compile Linux for
a digital SetTopBox.
API specs and user tools and are available for example from
<http://www.linuxtv.org/>.
Please report problems regarding this driver to the LinuxDVB
mailing list.
You might want add the following lines to your /etc/modules.conf:
alias char-major-250 dvb
alias dvb dvb-ttpci
below dvb-ttpci alps_bsru6 alps_bsrv2 \
grundig_29504-401 grundig_29504-491 \
ves1820
If unsure say N.
#
# Multimedia device configuration
#
mainmenu_option next_comment
comment 'Digital Video Broadcasting Devices'
bool 'DVB For Linux' CONFIG_DVB
if [ "$CONFIG_DVB" != "n" ]; then
source drivers/media/dvb/dvb-core/Config.in
source drivers/media/dvb/frontends/Config.in
comment 'Supported DVB Adapters'
source drivers/media/dvb/av7110/Config.in
fi
endmenu
#
# Makefile for the kernel multimedia device drivers.
#
obj-y := dvb-core/ frontends/ av7110/
include $(TOPDIR)/Rules.make
CONFIG_DVB_CORE
DVB core utility functions for device handling, software fallbacks etc.
Say Y when you have a DVB card and want to use it. If unsure say N.
CONFIG_DVB_DEVFS_ONLY
Drop support for old major/minor device scheme and support only devfs
systems. This saves some code.
If unsure say N.
dep_tristate ' DVB Core Support' CONFIG_DVB_CORE $CONFIG_DVB
if [ "$CONFIG_DVB_CORE" != "n" ]; then
dep_bool ' devfs only' CONFIG_DVB_DEVFS_ONLY $CONFIG_DVB_CORE $CONFIG_DEVFS_FS
fi
#
# Makefile for the kernel DVB device drivers.
#
export-objs := dvb_ksyms.o
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
obj-$(CONFIG_DVB_CORE) += dvb-core.o
include $(TOPDIR)/Rules.make
#ifndef __CRAP_H
#define __CRAP_H
/**
* compatibility crap for old kernels. No guarantee for a working driver
* even when everything compiles.
*/
#include <linux/module.h>
#include <linux/list.h>
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(x)
#endif
#ifndef list_for_each_safe
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
#endif
#endif
This diff is collapsed.
This diff is collapsed.
/*
* dmxdev.h
*
* Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
* & Marcus Metzler <marcus@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 _DMXDEV_H_
#define _DMXDEV_H_
#ifndef __KERNEL__
#define __KERNEL__
#endif
#include <linux/dvb/dmx.h>
#include <linux/version.h>
#include <linux/wait.h>
#include <linux/types.h>
#include <linux/fs.h>
#include "dvbdev.h"
#include "demux.h"
typedef enum {
DMXDEV_TYPE_NONE,
DMXDEV_TYPE_SEC,
DMXDEV_TYPE_PES,
} dmxdev_type_t;
typedef enum {
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;
wait_queue_head_t queue;
int error;
} dmxdev_buffer_t;
typedef struct dmxdev_filter_s {
dvb_device_t *dvbdev;
union {
dmx_section_filter_t *sec;
} filter;
union {
dmx_ts_feed_t *ts;
dmx_section_feed_t *sec;
} feed;
union {
struct dmx_sct_filter_params sec;
struct dmx_pes_filter_params pes;
} params;
int type;
dmxdev_state_t state;
struct dmxdev_s *dev;
dmxdev_buffer_t buffer;
// only for sections
struct timer_list timer;
int todo;
uint8_t secheader[3];
u16 pid;
} dmxdev_filter_t;
typedef struct dmxdev_dvr_s {
int state;
struct dmxdev_s *dev;
dmxdev_buffer_t buffer;
} dmxdev_dvr_t;
typedef struct dmxdev_s {
dvb_device_t *dvbdev;
dvb_device_t *dvr_dvbdev;
dmxdev_filter_t *filter;
dmxdev_dvr_t *dvr;
dmx_demux_t *demux;
int filternum;
int capabilities;
#define DMXDEV_CAP_DUPLEX 1
dmx_frontend_t *dvr_orig_fe;
dmxdev_buffer_t dvr_buffer;
#define DVR_BUFFER_SIZE (10*188*1024)
struct semaphore mutex;
spinlock_t lock;
} dmxdev_t;
int DmxDevInit(dmxdev_t *dmxdev, dvb_adapter_t *);
void DmxDevRelease(dmxdev_t *dmxdev);
#endif /* _DMXDEV_H_ */
This diff is collapsed.
/*
* dvb_demux.h - DVB kernel demux API
*
* Copyright (C) 2000-2001 Marcus Metzler <marcus@convergence.de>
* & Ralph Metzler <ralph@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 _DVB_DEMUX_H_
#define _DVB_DEMUX_H_
#include "demux.h"
#define DMX_TYPE_TS 0
#define DMX_TYPE_SEC 1
#define DMX_TYPE_PES 2
#define DMX_STATE_FREE 0
#define DMX_STATE_ALLOCATED 1
#define DMX_STATE_SET 2
#define DMX_STATE_READY 3
#define DMX_STATE_GO 4
#define DVB_DEMUX_MASK_MAX 18
typedef struct dvb_demux_filter_s {
dmx_section_filter_t filter;
u8 maskandmode [DMX_MAX_FILTER_SIZE];
u8 maskandnotmode [DMX_MAX_FILTER_SIZE];
int doneq;
struct dvb_demux_filter_s *next;
struct dvb_demux_feed_s *feed;
int index;
int state;
int type;
int pesto;
u16 handle;
u16 hw_handle;
struct timer_list timer;
int ts_state;
//u16 pid; //to be removed
} dvb_demux_filter_t;
typedef struct dvb_demux_feed_s {
union {
dmx_ts_feed_t ts;
dmx_section_feed_t sec;
} feed;
union {
dmx_ts_cb ts;
dmx_section_cb sec;
} cb;
struct dvb_demux_s *demux;
int type;
int state;
u16 pid;
u8 *buffer;
int buffer_size;
int descramble;
int check_crc;
struct timespec timeout;
dvb_demux_filter_t *filter;
int cb_length;
int ts_type;
dmx_ts_pes_t pes_type;
u8 secbuf[4096];
int secbufp;
int seclen;
int cc;
u16 peslen;
} dvb_demux_feed_t;
typedef struct dvb_demux_s {
dmx_demux_t dmx;
void *priv;
int filternum;
int feednum;
int (*start_feed)(dvb_demux_feed_t *);
int (*stop_feed)(dvb_demux_feed_t *);
int (*write_to_decoder)(dvb_demux_feed_t *, u8 *, size_t);
int users;
#define MAX_DVB_DEMUX_USERS 10
dvb_demux_filter_t *filter;
dvb_demux_feed_t *feed;
struct list_head frontend_list;
dvb_demux_feed_t *pesfilter[DMX_TS_PES_OTHER];
u16 pids[DMX_TS_PES_OTHER];
int playing;
int recording;
#define DMX_MAX_PID 0x2000
dvb_demux_feed_t *pid2feed[DMX_MAX_PID+1];
u8 tsbuf[188];
int tsbufp;
struct semaphore mutex;
spinlock_t lock;
} dvb_demux_t;
int DvbDmxInit(dvb_demux_t *dvbdemux);
int DvbDmxRelease(dvb_demux_t *dvbdemux);
void DvbDmxSWFilterPackets(dvb_demux_t *dvbdmx, const u8 *buf, int count);
#endif /* _DVB_DEMUX_H_ */
This diff is collapsed.
#ifndef _DVB_FILTER_H_
#define _DVB_FILTER_H_
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include "demux.h"
typedef int (pes2ts_cb_t) (void *, unsigned char *);
typedef struct pes2ts_s {
unsigned char buf[188];
unsigned char cc;
pes2ts_cb_t *cb;
void *priv;
} pes2ts_t;
void pes2ts_init(pes2ts_t *p2ts, unsigned short pid,
pes2ts_cb_t *cb, void *priv);
int pes2ts(pes2ts_t *p2ts, unsigned char *pes, int len);
#define PROG_STREAM_MAP 0xBC
#define PRIVATE_STREAM1 0xBD
#define PADDING_STREAM 0xBE
#define PRIVATE_STREAM2 0xBF
#define AUDIO_STREAM_S 0xC0
#define AUDIO_STREAM_E 0xDF
#define VIDEO_STREAM_S 0xE0
#define VIDEO_STREAM_E 0xEF
#define ECM_STREAM 0xF0
#define EMM_STREAM 0xF1
#define DSM_CC_STREAM 0xF2
#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 SEQUENCE_EXTENSION 0x01
#define SEQUENCE_DISPLAY_EXTENSION 0x02
#define PICTURE_CODING_EXTENSION 0x08
#define QUANT_MATRIX_EXTENSION 0x03
#define PICTURE_DISPLAY_EXTENSION 0x07
#define I_FRAME 0x01
#define B_FRAME 0x02
#define P_FRAME 0x03
/* Initialize sequence_data */
#define INIT_HORIZONTAL_SIZE 720
#define INIT_VERTICAL_SIZE 576
#define INIT_ASPECT_RATIO 0x02
#define INIT_FRAME_RATE 0x03
#define INIT_DISP_HORIZONTAL_SIZE 540
#define INIT_DISP_VERTICAL_SIZE 576
//flags2
#define PTS_DTS_FLAGS 0xC0
#define ESCR_FLAG 0x20
#define ES_RATE_FLAG 0x10
#define DSM_TRICK_FLAG 0x08
#define ADD_CPY_FLAG 0x04
#define PES_CRC_FLAG 0x02
#define PES_EXT_FLAG 0x01
//pts_dts flags
#define PTS_ONLY 0x80
#define PTS_DTS 0xC0
#define TS_SIZE 188
#define TRANS_ERROR 0x80
#define PAY_START 0x40
#define TRANS_PRIO 0x20
#define PID_MASK_HI 0x1F
//flags
#define TRANS_SCRMBL1 0x80
#define TRANS_SCRMBL2 0x40
#define ADAPT_FIELD 0x20
#define PAYLOAD 0x10
#define COUNT_MASK 0x0F
// adaptation flags
#define DISCON_IND 0x80
#define RAND_ACC_IND 0x40
#define ES_PRI_IND 0x20
#define PCR_FLAG 0x10
#define OPCR_FLAG 0x08
#define SPLICE_FLAG 0x04
#define TRANS_PRIV 0x02
#define ADAP_EXT_FLAG 0x01
// adaptation extension flags
#define LTW_FLAG 0x80
#define PIECE_RATE 0x40
#define SEAM_SPLICE 0x20
#define MAX_PLENGTH 0xFFFF
#define MMAX_PLENGTH (256*MAX_PLENGTH)
#ifndef IPACKS
#define IPACKS 2048
#endif
typedef struct ipack_s {
int size;
int found;
u8 *buf;
u8 cid;
uint32_t plength;
u8 plen[2];
u8 flag1;
u8 flag2;
u8 hlength;
u8 pts[5];
u16 *pid;
int mpeg;
u8 check;
int which;
int done;
void *data;
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;
#define OFF_SIZE 4
#define FIRST_FIELD 0
#define SECOND_FIELD 1
#define VIDEO_FRAME_PICTURE 0x03
typedef struct mpg_picture_s{
int channel;
VideoInfo vinfo;
uint32_t *sequence_gop_header;
uint32_t *picture_header;
int32_t time_code;
int low_delay;
int closed_gop;
int broken_link;
int sequence_header_flag;
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;
uint8_t picture_header_parameter;
/* bit 0 - 2: bwd f code
bit 3 : fpb vector
bit 4 - 6: fwd f code
bit 7 : fpf vector */
int mpeg1_flag;
int progressive_sequence;
int sequence_display_extension_flag;
uint32_t sequence_header_data;
int16_t last_frame_centre_horizontal_offset;
int16_t last_frame_centre_vertical_offset;
uint32_t pts[2]; /* [0] 1st field, [1] 2nd field */
int top_field_first;
int repeat_first_field;
int progressive_frame;
int bank;
int forward_bank;
int backward_bank;
int compress;
int16_t frame_centre_horizontal_offset[OFF_SIZE];
/* [0-2] 1st field, [3] 2nd field */
int16_t frame_centre_vertical_offset[OFF_SIZE];
/* [0-2] 1st field, [3] 2nd field */
int16_t temporal_reference[2];
/* [0] 1st field, [1] 2nd field */
int8_t picture_coding_type[2];
/* [0] 1st field, [1] 2nd field */
int8_t picture_structure[2];
/* [0] 1st field, [1] 2nd field */
int8_t picture_display_extension_flag[2];
/* [0] 1st field, [1] 2nd field */
/* picture_display_extenion() 0:no 1:exit*/
int8_t pts_flag[2];
/* [0] 1st field, [1] 2nd field */
} mpg_picture;
typedef struct audio_i{
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;
void reset_ipack(ipack *p);
int instant_repack(u8 *buf, int count, ipack *p);
void init_ipack(ipack *p, int size,
void (*func)(u8 *buf, int size, void *priv));
void free_ipack(ipack * p);
void setup_ts2pes(ipack *pa, ipack *pv, u16 *pida, u16 *pidv,
void (*pes_write)(u8 *buf, int count, void *data),
void *priv);
void ts_to_pes(ipack *p, u8 *buf);
void send_ipack(ipack *p);
void send_ipack_rest(ipack *p);
int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr);
int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr);
int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr);
uint8_t *skip_pes_header(uint8_t **bufp);
void initialize_quant_matrix( uint32_t *matrix );
void initialize_mpg_picture(mpg_picture *pic);
void init_mpg_picture( mpg_picture *pic, int chan, int32_t field_type);
void mpg_set_picture_parameter( int32_t field_type, mpg_picture *pic );
int read_sequence_header(uint8_t *headr, VideoInfo *vi, int pr);
int read_gop_header(uint8_t *headr, mpg_picture *pic, int pr);
int read_picture_header(uint8_t *headr, mpg_picture *pic, int field, int pr);
#endif
This diff is collapsed.
/*
* dvb-core.h
*
* Copyright (C) 2001 Ralph Metzler <ralph@convergence.de>
* overhauled by 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 _DVB_FRONTEND_H_
#define _DVB_FRONTEND_H_
#include <asm/types.h>
#include <linux/sched.h>
#include <linux/ioctl.h>
#include <linux/i2c.h>
#include <linux/module.h>
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(x)
#endif
#include <linux/dvb/frontend.h>
#include "dvb_i2c.h"
#include "dvbdev.h"
/**
* when before_ioctl is registered and returns value 0, ioctl and after_ioctl
* are not executed.
*/
struct dvb_frontend {
int (*before_ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
int (*ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
int (*after_ioctl) (struct dvb_frontend *frontend, unsigned int cmd, void *arg);
struct dvb_i2c_bus *i2c;
void *before_after_data; /* can be used by hardware module... */
void *data; /* can be used by hardware module... */
};
/**
* private frontend command ioctl's.
* keep them in sync with the public ones defined in linux/dvb/frontend.h
*/
#define FE_SLEEP _IO('v', 80)
#define FE_INIT _IO('v', 81)
#define FE_RESET _IO('v', 82)
extern int
dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
unsigned int cmd, void *arg),
struct dvb_i2c_bus *i2c,
void *data,
struct dvb_frontend_info *info);
extern int
dvb_unregister_frontend (int (*ioctl) (struct dvb_frontend *frontend,
unsigned int cmd, void *arg),
struct dvb_i2c_bus *i2c);
/**
* Add special ioctl code performed before and after the main ioctl
* to all frontend devices on the specified DVB adapter.
* This is necessairy because the 22kHz/13V-18V/DiSEqC stuff depends
* heavily on the hardware around the frontend, the same tuner can create
* these signals on about a million different ways...
*
* Return value: number of frontends where the ioctl's were applied.
*/
extern int
dvb_add_frontend_ioctls (struct dvb_adapter_s *adapter,
int (*before_ioctl) (struct dvb_frontend *frontend,
unsigned int cmd, void *arg),
int (*after_ioctl) (struct dvb_frontend *frontend,
unsigned int cmd, void *arg),
void *before_after_data);
extern void
dvb_remove_frontend_ioctls (struct dvb_adapter_s *adapter,
int (*before_ioctl) (struct dvb_frontend *frontend,
unsigned int cmd, void *arg),
int (*after_ioctl) (struct dvb_frontend *frontend,
unsigned int cmd, void *arg));
extern int
dvb_add_frontend_notifier (struct dvb_adapter_s *adapter,
void (*callback) (fe_status_t s, void *data),
void *data);
extern void
dvb_remove_frontend_notifier (struct dvb_adapter_s *adapter,
void (*callback) (fe_status_t s, void *data));
#endif
/*
* dvb_i2c.h: simplified i2c interface for DVB adapters to get rid of i2c-core.c
*
* Copyright (C) 2002 Holger Waechtler for convergence integrated media GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 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.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/module.h>
#include "compat.h"
#include "dvb_i2c.h"
struct dvb_i2c_device {
struct list_head list_head;
struct module *owner;
int (*attach) (struct dvb_i2c_bus *i2c);
void (*detach) (struct dvb_i2c_bus *i2c);
};
LIST_HEAD(dvb_i2c_buslist);
LIST_HEAD(dvb_i2c_devicelist);
DECLARE_MUTEX(dvb_i2c_mutex);
static
int register_i2c_client (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
{
struct dvb_i2c_device *client;
if (!(client = kmalloc (sizeof (struct dvb_i2c_device), GFP_KERNEL)))
return -ENOMEM;
client->detach = dev->detach;
client->owner = dev->owner;
INIT_LIST_HEAD(&client->list_head);
list_add_tail (&client->list_head, &i2c->client_list);
return 0;
}
static
void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
{
if (dev->owner) {
if (!MOD_CAN_QUERY(dev->owner))
return;
__MOD_INC_USE_COUNT(dev->owner);
}
if (dev->attach (i2c) == 0) {
register_i2c_client (i2c, dev);
} else {
if (dev->owner)
__MOD_DEC_USE_COUNT(dev->owner);
}
}
static
void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev)
{
dev->detach (i2c);
if (dev->owner)
__MOD_DEC_USE_COUNT(dev->owner);
}
static
void unregister_i2c_client_from_bus (struct dvb_i2c_device *dev,
struct dvb_i2c_bus *i2c)
{
struct list_head *entry;
list_for_each (entry, &i2c->client_list) {
struct dvb_i2c_device *client;
client = list_entry (entry, struct dvb_i2c_device, list_head);
if (client->detach == dev->detach)
detach_device (i2c, dev);
}
}
static
void unregister_i2c_client_from_all_busses (struct dvb_i2c_device *dev)
{
struct list_head *entry;
list_for_each (entry, &dvb_i2c_buslist) {
struct dvb_i2c_bus *i2c;
i2c = list_entry (entry, struct dvb_i2c_bus, list_head);
unregister_i2c_client_from_bus (dev, i2c);
}
}
static
void unregister_all_clients_from_bus (struct dvb_i2c_bus *i2c)
{
struct list_head *entry, *n;
list_for_each_safe (entry, n, &(i2c->client_list)) {
struct dvb_i2c_device *client;
client = list_entry (entry, struct dvb_i2c_device, list_head);
detach_device (i2c, client);
list_del (entry);
}
}
static
void probe_device_on_all_busses (struct dvb_i2c_device *dev)
{
struct list_head *entry;
list_for_each (entry, &dvb_i2c_buslist) {
struct dvb_i2c_bus *i2c;
i2c = list_entry (entry, struct dvb_i2c_bus, list_head);
try_attach_device (i2c, dev);
}
}
static
void probe_devices_on_bus (struct dvb_i2c_bus *i2c)
{
struct list_head *entry;
list_for_each (entry, &dvb_i2c_devicelist) {
struct dvb_i2c_device *dev;
dev = list_entry (entry, struct dvb_i2c_device, list_head);
try_attach_device (i2c, dev);
}
}
struct dvb_i2c_bus*
dvb_register_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
struct i2c_msg msgs[], int num),
void *data,
struct dvb_adapter_s *adapter,
int id)
{
struct dvb_i2c_bus *i2c;
if (!(i2c = kmalloc (sizeof (struct dvb_i2c_bus), GFP_KERNEL)))
return NULL;
INIT_LIST_HEAD(&i2c->list_head);
INIT_LIST_HEAD(&i2c->client_list);
i2c->xfer = xfer;
i2c->data = data;
i2c->adapter = adapter;
i2c->id = id;
probe_devices_on_bus (i2c);
list_add_tail (&i2c->list_head, &dvb_i2c_buslist);
return i2c;
}
struct dvb_i2c_bus*
dvb_find_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
struct i2c_msg msgs[], int num),
struct dvb_adapter_s *adapter,
int id)
{
struct list_head *entry;
if (down_interruptible (&dvb_i2c_mutex))
return NULL;
list_for_each (entry, &dvb_i2c_buslist) {
struct dvb_i2c_bus *i2c;
i2c = list_entry (entry, struct dvb_i2c_bus, list_head);
if (i2c->xfer == xfer &&
i2c->adapter == adapter &&
i2c->id == id)
{
up (&dvb_i2c_mutex);
return i2c;
}
}
up (&dvb_i2c_mutex);
return NULL;
}
void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
struct i2c_msg msgs[], int num),
struct dvb_adapter_s *adapter,
int id)
{
struct dvb_i2c_bus *i2c = dvb_find_i2c_bus (xfer, adapter, id);
if (i2c) {
unregister_all_clients_from_bus (i2c);
list_del (&i2c->list_head);
kfree (i2c);
}
}
int dvb_register_i2c_device (struct module *owner,
int (*attach) (struct dvb_i2c_bus *i2c),
void (*detach) (struct dvb_i2c_bus *i2c))
{
struct dvb_i2c_device *entry;
if (down_interruptible (&dvb_i2c_mutex))
return -ERESTARTSYS;
if (!(entry = kmalloc (sizeof (struct dvb_i2c_device), GFP_KERNEL)))
return -ENOMEM;
entry->owner = owner;
entry->attach = attach;
entry->detach = detach;
INIT_LIST_HEAD(&entry->list_head);
probe_device_on_all_busses (entry);
list_add_tail (&entry->list_head, &dvb_i2c_devicelist);
up (&dvb_i2c_mutex);
return 0;
}
int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c))
{
struct list_head *entry, *n;
if (down_interruptible (&dvb_i2c_mutex))
return -ERESTARTSYS;
list_for_each_safe (entry, n, &dvb_i2c_devicelist) {
struct dvb_i2c_device *dev;
dev = list_entry (entry, struct dvb_i2c_device, list_head);
if (dev->attach == attach) {
list_del (entry);
unregister_i2c_client_from_all_busses (dev);
kfree (entry);
up (&dvb_i2c_mutex);
return 0;
}
}
up (&dvb_i2c_mutex);
return -EINVAL;
}
/*
* dvb_i2c.h: i2c interface to get rid of i2c-core.c
*
* Copyright (C) 2002 Holger Waechtler for convergence integrated media GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 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.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
#ifndef _DVB_I2C_H_
#define _DVB_I2C_H_
#include <linux/list.h>
#include <linux/i2c.h>
#include "dvbdev.h"
struct dvb_i2c_bus {
struct list_head list_head;
int (*xfer) (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num);
void *data;
struct dvb_adapter_s *adapter;
int id;
struct list_head client_list;
};
extern
struct dvb_i2c_bus* dvb_register_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
struct i2c_msg msgs[],
int num),
void *data,
struct dvb_adapter_s *adapter,
int id);
extern
void dvb_unregister_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
struct i2c_msg msgs[], int num),
struct dvb_adapter_s *adapter,
int id);
extern int dvb_register_i2c_device (struct module *owner,
int (*attach) (struct dvb_i2c_bus *i2c),
void (*detach) (struct dvb_i2c_bus *i2c));
extern int dvb_unregister_i2c_device (int (*attach) (struct dvb_i2c_bus *i2c));
#endif
#include <linux/module.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_net.h"
EXPORT_SYMBOL(DmxDevInit);
EXPORT_SYMBOL(DmxDevRelease);
EXPORT_SYMBOL(DvbDmxInit);
EXPORT_SYMBOL(DvbDmxRelease);
EXPORT_SYMBOL(DvbDmxSWFilterPackets);
EXPORT_SYMBOL(dvb_register_frontend);
EXPORT_SYMBOL(dvb_unregister_frontend);
EXPORT_SYMBOL(dvb_add_frontend_ioctls);
EXPORT_SYMBOL(dvb_remove_frontend_ioctls);
EXPORT_SYMBOL(dvb_add_frontend_notifier);
EXPORT_SYMBOL(dvb_remove_frontend_notifier);
EXPORT_SYMBOL(dvb_register_i2c_bus);
EXPORT_SYMBOL(dvb_unregister_i2c_bus);
EXPORT_SYMBOL(dvb_register_i2c_device);
EXPORT_SYMBOL(dvb_unregister_i2c_device);
EXPORT_SYMBOL(dvb_net_init);
EXPORT_SYMBOL(dvb_net_release);
EXPORT_SYMBOL(dvb_register_adapter);
EXPORT_SYMBOL(dvb_unregister_adapter);
EXPORT_SYMBOL(dvb_register_device);
EXPORT_SYMBOL(dvb_unregister_device);
EXPORT_SYMBOL(dvb_generic_ioctl);
EXPORT_SYMBOL(dvb_generic_open);
EXPORT_SYMBOL(dvb_generic_release);
EXPORT_SYMBOL(generic_usercopy);
EXPORT_SYMBOL(init_ipack);
EXPORT_SYMBOL(reset_ipack);
EXPORT_SYMBOL(free_ipack);
EXPORT_SYMBOL(send_ipack_rest);
EXPORT_SYMBOL(instant_repack);
EXPORT_SYMBOL(pes2ts_init);
EXPORT_SYMBOL(pes2ts);
This diff is collapsed.
/*
* dvb_net.h
*
* Copyright (C) 2001 Convergence integrated media GmbH
* Ralph Metzler <ralph@convergence.de>
*
* 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 _DVB_NET_H_
#define _DVB_NET_H_
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include "dvbdev.h"
#define DVB_NET_DEVICES_MAX 10
#define DVB_NET_MULTICAST_MAX 10
typedef struct dvb_net_priv_s {
struct net_device_stats stats;
char name[6];
u16 pid;
dmx_demux_t *demux;
dmx_section_feed_t *secfeed;
dmx_section_filter_t *secfilter;
int multi_num;
dmx_section_filter_t *multi_secfilter[DVB_NET_MULTICAST_MAX];
unsigned char multi_macs[DVB_NET_MULTICAST_MAX][6];
} dvb_net_priv_t;
typedef struct dvb_net_s {
dvb_device_t *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;
void dvb_net_release(dvb_net_t *);
int dvb_net_init(dvb_adapter_t *, dvb_net_t *, dmx_demux_t *);
#endif
This diff is collapsed.
/*
* dvbdev.h
*
* Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
* & Marcus Metzler <marcus@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 General Lesser 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 _DVBDEV_H_
#define _DVBDEV_H_
#include <linux/types.h>
#include <linux/version.h>
#include <linux/poll.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/list.h>
#define DVB_MAJOR 250
#define DVB_DEVICE_VIDEO 0
#define DVB_DEVICE_AUDIO 1
#define DVB_DEVICE_SEC 2
#define DVB_DEVICE_FRONTEND 3
#define DVB_DEVICE_DEMUX 4
#define DVB_DEVICE_DVR 5
#define DVB_DEVICE_CA 6
#define DVB_DEVICE_NET 7
#define DVB_DEVICE_OSD 8
typedef struct dvb_adapter_s
{
int num;
devfs_handle_t devfs_handle;
struct list_head list_head;
struct list_head device_list;
} dvb_adapter_t;
typedef struct dvb_device
{
struct list_head list_head;
struct file_operations *fops;
devfs_handle_t devfs_handle;
dvb_adapter_t *adapter;
int type;
u32 id;
int users;
int writers;
/* don't really need those !? */
int (*kernel_ioctl)(struct inode *inode, struct file *file,
unsigned int cmd, void *arg); // FIXME: use generic_usercopy()
void *priv;
} dvb_device_t;
int dvb_register_device(dvb_adapter_t *adap, dvb_device_t **pdvbdev,
dvb_device_t *template, void *priv, int type);
void dvb_unregister_device(struct dvb_device *dvbdev);
int dvb_register_adapter(dvb_adapter_t **padap, char *name);
int dvb_unregister_adapter(dvb_adapter_t *adap);
int dvb_generic_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
int dvb_generic_open(struct inode *inode, struct file *file);
int dvb_generic_release(struct inode *inode, struct file *file);
int generic_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 */
/*
* audio.h
*
* Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
* & Marcus Metzler <marcus@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 General Lesser 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 _DVBAUDIO_H_
#define _DVBAUDIO_H_
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#endif
typedef enum {
AUDIO_SOURCE_DEMUX, /* Select the demux as the main source */
AUDIO_SOURCE_MEMORY /* Select internal memory as the main source */
} audio_stream_source_t;
typedef enum {
AUDIO_STOPPED, /* Device is stopped */
AUDIO_PLAYING, /* Device is currently playing */
AUDIO_PAUSED /* Device is paused */
} audio_play_state_t;
typedef enum {
AUDIO_STEREO,
AUDIO_MONO_LEFT,
AUDIO_MONO_RIGHT,
} audio_channel_select_t;
typedef struct audio_status {
int AV_sync_state; /* sync audio and video? */
int mute_state; /* audio is muted */
audio_play_state_t play_state; /* current playback state */
audio_stream_source_t stream_source; /* current stream source */
audio_channel_select_t channel_select; /* currently selected channel */
int bypass_mode; /* pass on audio data to */
} audio_status_t; /* separate decoder hardware */
typedef struct audio_mixer {
unsigned int volume_left;
unsigned int volume_right;
// what else do we need? bass, pass-through, ...
} audio_mixer_t;
typedef
struct audio_karaoke{ /* if Vocal1 or Vocal2 are non-zero, they get mixed */
int vocal1; /* into left and right t at 70% each */
int vocal2; /* if both, Vocal1 and Vocal2 are non-zero, Vocal1 gets*/
int melody; /* mixed into the left channel and */
/* Vocal2 into the right channel at 100% each. */
/* if Melody is non-zero, the melody channel gets mixed*/
} audio_karaoke_t; /* into left and right */
typedef uint16_t audio_attributes_t;
/* bits: descr. */
/* 15-13 audio coding mode (0=ac3, 2=mpeg1, 3=mpeg2ext, 4=LPCM, 6=DTS, */
/* 12 multichannel extension */
/* 11-10 audio type (0=not spec, 1=language included) */
/* 9- 8 audio application mode (0=not spec, 1=karaoke, 2=surround) */
/* 7- 6 Quantization / DRC (mpeg audio: 1=DRC exists)(lpcm: 0=16bit, */
/* 5- 4 Sample frequency fs (0=48kHz, 1=96kHz) */
/* 2- 0 number of audio channels (n+1 channels) */
/* for GET_CAPABILITIES and SET_FORMAT, the latter should only set one bit */
#define AUDIO_CAP_DTS 1
#define AUDIO_CAP_LPCM 2
#define AUDIO_CAP_MP1 4
#define AUDIO_CAP_MP2 8
#define AUDIO_CAP_MP3 16
#define AUDIO_CAP_AAC 32
#define AUDIO_CAP_OGG 64
#define AUDIO_CAP_SDDS 128
#define AUDIO_CAP_AC3 256
#define AUDIO_STOP _IO('o', 1)
#define AUDIO_PLAY _IO('o', 2)
#define AUDIO_PAUSE _IO('o', 3)
#define AUDIO_CONTINUE _IO('o', 4)
#define AUDIO_SELECT_SOURCE _IO('o', 5)
#define AUDIO_SET_MUTE _IO('o', 6)
#define AUDIO_SET_AV_SYNC _IO('o', 7)
#define AUDIO_SET_BYPASS_MODE _IO('o', 8)
#define AUDIO_CHANNEL_SELECT _IO('o', 9)
#define AUDIO_GET_STATUS _IOR('o', 10, audio_status_t)
#define AUDIO_GET_CAPABILITIES _IOR('o', 11, unsigned int)
#define AUDIO_CLEAR_BUFFER _IO('o', 12)
#define AUDIO_SET_ID _IO('o', 13)
#define AUDIO_SET_MIXER _IOW('o', 14, audio_mixer_t)
#define AUDIO_SET_STREAMTYPE _IO('o', 15)
#define AUDIO_SET_EXT_ID _IO('o', 16)
#define AUDIO_SET_ATTRIBUTES _IOW('o', 17, audio_attributes_t)
#define AUDIO_SET_KARAOKE _IOW('o', 18, audio_karaoke_t)
#endif /* _DVBAUDIO_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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