/* AF-9015 Bus Interface Unit driver Copyright (c) Manu Abraham Copyright (c) AFA Technologies 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __AF9015_PRIV_H #define __AF9015_PRIV_H #include #include "af9015.h" enum af9015_tuner_types { AF9015_TUNER_MT2060D = 130, AF9015_TUNER_MXL5003D = 3, AF9015_TUNER_MXL5005H = 13, #if 0 AF9015_TUNER_QT1010 = xxx AF9015_TUNER_MC44S802 = xxx AF9015_TUNER_MC44S803 = xxx #endif }; enum af9015_ir_types { AF9015_IR_NEC = 0, AF9015_IR_RC6, }; enum af9015_ir_mode { AF9015_IRMODE_DISABLED = 0, AF9015_IRMODE_HID, AF9015_IRMODE_RLC, AF9015_IRMODE_RC6 }; /** * Mode 15: Used normally in PC applications * either USB mode or SERIAL mode * Mode 17: Used in consumer devices with a MPEG decoder * USB mode alongwith a SERIAL mode */ enum af9015_biu_mode { AF9015_BIU_MODE_15 = 1, AF9015_BIU_MODE_17 }; /** * Mode 11: USB 1.1 mode application * Mode 20: USB 2.0 mode application */ enum af9015_usb_mode { AF9015_USB_MODE_11 = 1, AF9015_USB_MODE_20 }; struct af901x_biu_config { // will change it state (biu_state) struct af901x_state *state; // u8 ir_mode; /* from EEPROM, must go out */ enum af9015_ir_mode ir_mode; u8 ts_mode; /* from EEPROM, must go out */ u8 addr; u8 saw_bw; /* from EEPROM, must go out */ u8 osc_type; /*from EEPROM, must go out */ enum af9015_tuner_types tuner; /* from EEPROM, must go out */ enum af9015_ir_types ir_type; /* from EEPROM, must go out */ u32 osc_freq; /* from EEPROM, must go out */ u16 i_freq_0; /* IF 1 */ /* from EEPROM, must go out */ u16 i_freq_1; /* IF 2 */ /* from EEPROM, must go out */ u8 inversion; /* from EEPROM, must go out */ // u8 usb_11; // This is static }; struct af9015_biuconfig_mode { enum af9015_biu_mode biu_mode; enum af9015_usb_mode usb_mode; }; struct af901x_biu { struct dvb_usb_adapter *usb_adapter; struct dvb_usb_device *udev; struct i2c_adapter *i2c; /* we are in the real world */ struct mutex biu_lock; struct i2c_adapter adapter[2]; /* explore virtual worlds */ struct af901x_state *state; struct af901x_config *dmd_config; struct af901x_biu_config biu_config; struct af9015_biuconfig_mode config_mode; u8 biu_seq; }; enum af9015_biu_cmd { AF9015_REQ_CURCONFIG = 0x10, /* 1a) Get current config */ AF9015_REQ_FWDOWNLOAD = 0x11, /* 2a) Download Firmware control messages */ AF9015_REQ_CHKSUMCOMPUTE = 0x12, /* 3a) Calculate Checksum control messages */ AF9015_REQ_BOOTCONTROL = 0x13, /* 4a) Boot control messages */ AF9015_REQ_BIUMMIO_RD = 0x20, /* 5a) USB Memory RD control messages */ AF9015_REQ_BIUMMIO_WR = 0x21, /* 6a) USB Memory WR control messages */ AF9015_REQ_GENERIC_I2C = 0x22, /* 7a) General I2C control messages */ AF9015_REQ_FWCOPY = 0x23, /* 8a) Copy Firmware control messages */ AF9015_REQ_FWVERSION = 0x24, AF9015_REQ_SWRESET = 0x25, /* 9) Software reset control messages */ AF9015_REQ_CMDCTL = 0x26, /* 10a) Control unit command conrtol messages */ AF9015_REQ_PROPRIETARY_IR = 0x27, AF9015_REQ_FWRELINK = 0x5a }; struct af9015_biu_msg { u16 addr; /* Slave address */ enum af9015_biu_cmd biu_cmd; /* Command */ // u8 sequence; // for read u8 reg_addr_msb; // Temporary u8 reg_addr_lsb; // Temporary u8 addr_length; /* page offset */ u16 flags; #define BIU_RD 0x01 u8 *data; /* Data */ u16 length; /* Length of data */ }; #define AF9015_ERROR 0 #define AF9015_NOTICE 1 #define AF9015_INFO 2 #define AF9015_DEBUG 3 #define dprint(x, y, z, format, arg...) do { \ if (z) { \ if ((x > AF9015_ERROR) && (x > y)) \ printk(AF9015_ERR "%s (%d): " format "\n", __func__, state->num, ##arg);\ else if ((x > AF9015_NOTICE) && (x > y)) \ printk(AF9015_ERR "%s (%d): " format "\n", __func__, state->num, ##arg);\ else if ((x > AF9015_INFO) && (x > y)) \ printk(AF9015_ERR "%s (%d): " format "\n", __func__, state->num, ##arg);\ else if ((x > AF9015_DEBUG) && (x > y)) \ printk(AF9015_ERR "%s (%d): " format "\n", __func__, state->num, ##arg);\ } else { \ if (x > y) \ printk(format, ##arg); \ } \ } while (0); #define AF901x_GETFIELD(bitf, val) ((val >> AF901x_OFFST_##bitf) & \ ((1 << AF901x_WIDTH_##bitf) - 1)) #define AF901x_SETFIELD(bitf, mask, val)(mask = (mask & (~(((1 << AF901x_WIDTH_##bitf) - 1)<< \ AF901x_OFFST_##bitf))) | (val << AF901x_OFFST_##bitf)) struct af901x_reg { u16 reg_addr; u8 pos; u8 len; u8 val; }; #define AF901x_SLAVE_DEMOD_ADDR 0x3a #define MERC_ADDR_FW_VER 0x5103 #define MERC_IR_TABLE_BASE_ADDR 0x9A56 #define MERC_ADDR_HW_VER 0x116B #define AF901X_API_VER_0 0 #define AF901X_API_VER_1 1 #define AF901X_API_VER_2 9 #define AF901X_API_VER_3 0 extern int af9015_biu_xfer(struct usb_device *udev, struct af9015_biu_msg *msgs, int num); extern int af9015_i2c_exit(struct af901x_biu *biu); extern int af9015_i2c_init(struct af901x_biu *biu); extern int af9015_biu_read(struct usb_device *udev, struct af9015_biu_msg *msg); extern int af9015_biu_write(struct usb_device *udev, struct af9015_biu_msg *msg); #endif//__AF9015_PRIV_H