/* dvb-usb.h is part of the DVB USB library. * * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * * the headerfile, all dvb-usb-drivers have to include. */ #ifndef __DVB_USB_H__ #define __DVB_USB_H__ #include #include #include #include "dvb_frontend.h" #include "dvb_demux.h" #include "dvb_net.h" #include "dmxdev.h" #include "dvb-usb-ids.h" /* debug */ #ifdef CONFIG_DVB_USB_DEBUG #define dprintk(var,level,args...) \ do { if ((var & level)) { printk(args); } } while (0) #define debug_dump(b,l,func) {\ int loop_; \ for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \ func("\n");\ } #define DVB_USB_DEBUG_STATUS #else #define dprintk(args...) #define debug_dump(b,l) #define DVB_USB_DEBUG_STATUS " (debugging is not enabled)" #endif /* generic log methods - taken from usb.h */ #ifndef DVB_USB_LOG_PREFIX #define DVB_USB_LOG_PREFIX "dvb-usb (please define a log prefix)" #endif #undef err #define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) #undef info #define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) #undef warn #define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) struct dvb_usb_device_description { const char *name; /* real name of the box */ #define DVB_USB_ID_MAX_NUM 15 struct usb_device_id *cold_ids[DVB_USB_ID_MAX_NUM]; /* list of USB ids when this device is at pre firmware state */ struct usb_device_id *warm_ids[DVB_USB_ID_MAX_NUM]; /* list of USB ids when this device is at post firmware state */ }; struct dvb_usb_device; /* properties of an dvb-usb-device */ struct dvb_usb_properties { #define DVB_USB_HAS_PID_FILTER 0x01 #define DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF 0x02 #define DVB_USB_NEED_PID_FILTERING 0x04 #define DVB_USB_IS_AN_I2C_ADAPTER 0x08 int caps; #define CYPRESS_AN2135 0 #define CYPRESS_AN2235 1 #define CYPRESS_FX2 2 int usb_ctrl; /* usb controller */ const char *firmware; /* valid firmware filenames */ int (*streaming_ctrl) (struct dvb_usb_device *, int); /* control the MPEG2-TS streaming of the device */ int (*pid_filter) (struct dvb_usb_device *, int, u16, int); /* if the device has a hardware pid filter */ int (*pid_filter_ctrl) (struct dvb_usb_device *, int); /* if the device has a hardware pid filter to en-/disable */ int (*read_mac_address) (struct dvb_usb_device *, u8 []); /* callback for reading the MAC address */ int (*power_ctrl) (struct dvb_usb_device *, int); /* power control callback of the device */ int (*frontend_attach) (struct dvb_usb_device *); /* each device has to know about its frontends */ struct dvb_usb_device_description * (*identify_desc_quirk) (void); /* the device is not distinuishable just by its USB IDs */ #define REMOTE_NO_KEY_PRESSED 0x00 #define REMOTE_KEY_PRESSED 0x01 #define REMOTE_KEY_REPEAT 0x02 int (*init_rc) (struct dvb_usb_device *); /* remote query callback - NULL no ir-receiver */ int (*query_rc) (struct dvb_usb_device *, u32 *, int *); /* remote query callback - NULL no ir-receiver */ int rc_interval; /* i2c algorithm, if any */ struct i2c_algorithm i2c_algo; /* endpoint for generic bulk read/write operations (used by many drivers for controlling the device) */ int generic_bulk_ctrl_endpoint; /* MPEG2 TS transfer description */ struct { #define DVB_USB_BULK 1 #define DVB_USB_ISOC 2 int type; int count; int endpoint; union { struct { int buffersize; /* per URB */ } bulk; struct { int framesperurb; int framesize; } isoc; } u; } urb; int num_device_descs; struct dvb_usb_device_description devices[]; }; struct dvb_usb_device { struct dvb_usb_properties props; struct dvb_usb_device_description *desc; #define DVB_USB_STATE_INIT 0x000 #define DVB_USB_STATE_URB_LIST 0x001 #define DVB_USB_STATE_URB_BUF 0x002 #define DVB_USB_STATE_DVB 0x004 #define DVB_USB_STATE_I2C 0x008 #define DVB_USB_STATE_REMOTE 0x010 #define DVB_USB_STATE_URB_SUBMIT 0x020 int init_state; /* usb */ struct usb_device *udev; struct urb **urb_list; u8 *buffer; dma_addr_t dma_handle; int urbs_initialized; int urbs_submitted; int feedcount; int pid_filtering; /* locking */ struct semaphore usb_sem; /* i2c */ struct semaphore i2c_sem; struct i2c_adapter i2c_adap; /* dvb */ struct dvb_adapter dvb_adap; struct dmxdev dmxdev; struct dvb_demux demux; struct dvb_net dvb_net; struct dvb_frontend* fe; int (*fe_sleep) (struct dvb_frontend *); int (*fe_init) (struct dvb_frontend *); /* remote control */ struct input_dev rc_input_dev; struct work_struct rc_query_work; u32 last_event; int last_state; void *priv; }; extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *); extern void dvb_usb_device_exit(struct usb_interface *); /* the generic read/write method for device control */ extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16); extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16); /* common used remote control parsing */ struct dvb_usb_nec_rc_key { u8 c0,c1,c2; u32 key; }; extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, struct dvb_usb_nec_rc_key[],int, u8[], u32 *, int *); #endif