/* * dvb-dibusb.h * * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de) * * 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, version 2. * * for more information see dvb-dibusb-core.c . */ #ifndef __DVB_DIBUSB_H__ #define __DVB_DIBUSB_H__ #include #include #include #include "dvb_frontend.h" #include "dvb_demux.h" #include "dvb_net.h" #include "dmxdev.h" #include "dib3000.h" /* debug */ #ifdef CONFIG_DVB_DIBCOM_DEBUG #define dprintk(level,args...) \ do { if ((debug & level)) { printk(args); } } while (0) #define debug_dump(b,l) if (debug) {\ int i; deb_xfer("%s: %d > ",__FUNCTION__,l); \ for (i = 0; i < l; i++) deb_xfer("%02x ", b[i]); \ deb_xfer("\n");\ } /* module parameters - declared in -core.c */ extern int debug; #else #define dprintk(args...) #define debug_dump(b,l) #endif /* module parameters - declared in -core.c */ extern int pid_parse; extern int rc_query_interval; #define deb_info(args...) dprintk(0x01,args) #define deb_xfer(args...) dprintk(0x02,args) #define deb_alot(args...) dprintk(0x04,args) #define deb_ts(args...) dprintk(0x08,args) #define deb_err(args...) dprintk(0x10,args) #define deb_rc(args...) dprintk(0x20,args) /* generic log methods - taken from usb.h */ #define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg) #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg) /* Version information */ #define DRIVER_VERSION "0.1" #define DRIVER_DESC "Driver for DiBcom based USB Budget DVB-T device" #define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de" typedef enum { DIBUSB1_1 = 0, DIBUSB2_0, DIBUSB1_1_AN2235, } dibusb_type; /* struct for holding properties of the different dibusb device models */ struct dibusb_device_parameter { dibusb_type type; const char **fw_filenames; const char *usb_controller; u16 usb_cpu_csreg; int num_urbs; int urb_buf_size; int default_size; int firmware_bug; int cmd_pipe; int result_pipe; int data_pipe; int (*pll_set) (struct dvb_frontend *,struct dvb_frontend_parameters *); unsigned char pll_addr; unsigned char demod_i2c_addrs[4]; }; /* * for each warm/cold product id a name is stored, this is just beautification, * it could easily done by an PID-array, but then the real names of the devices * would get lost. */ struct dibusb_device { const char *name; u16 cold_product_id; u16 warm_product_id; struct dibusb_device_parameter *parm; }; struct usb_dibusb { /* usb */ struct usb_device * udev; struct dibusb_device * dibdev; #define DIBUSB_STATE_INIT 0x000 #define DIBUSB_STATE_URB_LIST 0x001 #define DIBUSB_STATE_URB_BUF 0x002 #define DIBUSB_STATE_URB_SUBMIT 0x004 #define DIBUSB_STATE_DVB 0x008 #define DIBUSB_STATE_I2C 0x010 #define DIBUSB_STATE_REMOTE 0x020 int init_state; int feedcount; int pid_parse; struct dib3000_xfer_ops xfer_ops; struct urb **urb_list; u8 *buffer; dma_addr_t dma_handle; /* I2C */ struct i2c_adapter i2c_adap; /* locking */ struct semaphore usb_sem; struct semaphore i2c_sem; /* dvb */ struct dvb_adapter *adapter; struct dmxdev dmxdev; struct dvb_demux demux; struct dvb_net dvb_net; struct dvb_frontend* fe; /* remote control */ struct input_dev rc_input_dev; struct work_struct rc_query_work; int rc_input_event; }; /* commonly used functions in the separated files */ /* dvb-dibusb-firmware.c */ int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_device *dibdev); /* dvb-dibusb-remote.c */ int dibusb_remote_exit(struct usb_dibusb *dib); int dibusb_remote_init(struct usb_dibusb *dib); /* dvb-dibusb-fe-i2c.c */ int dibusb_fe_init(struct usb_dibusb* dib); int dibusb_fe_exit(struct usb_dibusb *dib); int dibusb_i2c_init(struct usb_dibusb *dib); int dibusb_i2c_exit(struct usb_dibusb *dib); /* dvb-dibusb-dvb.c */ void dibusb_urb_complete(struct urb *urb, struct pt_regs *ptregs); int dibusb_dvb_init(struct usb_dibusb *dib); int dibusb_dvb_exit(struct usb_dibusb *dib); /* dvb-dibusb-usb.c */ int dibusb_readwrite_usb(struct usb_dibusb *dib, u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen); int dibusb_hw_wakeup(struct usb_dibusb *dib); int dibusb_set_streaming_mode(struct usb_dibusb *dib,u8 mode); int dibusb_streaming(struct usb_dibusb *dib,int onoff); int dibusb_urb_init(struct usb_dibusb *dib); int dibusb_urb_exit(struct usb_dibusb *dib); /* i2c and transfer stuff */ #define DIBUSB_I2C_TIMEOUT HZ*5 /* * types of first byte of each buffer send to USB, applying for * USB1.1 and USB2.0 */ #define DIBUSB_REQ_START_READ 0x00 #define DIBUSB_REQ_START_DEMOD 0x01 #define DIBUSB_REQ_I2C_READ 0x02 #define DIBUSB_REQ_I2C_WRITE 0x03 /* prefix for reading the current RC key */ #define DIBUSB_REQ_POLL_REMOTE 0x04 #define DIBUSB_RC_NEC_EMPTY 0x00 #define DIBUSB_RC_NEC_KEY_PRESSED 0x01 #define DIBUSB_RC_NEC_KEY_REPEATED 0x02 /* 0x05 0xXX */ #define DIBUSB_REQ_SET_STREAMING_MODE 0x05 /* interrupt the internal read loop, when blocking */ #define DIBUSB_REQ_INTR_READ 0x06 /* IO control * 0x07 */ #define DIBUSB_REQ_SET_IOCTL 0x07 /* IOCTL commands */ /* change the power mode in firmware */ #define DIBUSB_IOCTL_CMD_POWER_MODE 0x00 #define DIBUSB_IOCTL_POWER_SLEEP 0x00 #define DIBUSB_IOCTL_POWER_WAKEUP 0x01 /* modify streaming of the FX2 */ #define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01 #define DIBUSB_IOCTL_CMD_DISABLE_STREAM 0x02 #endif