1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III 4*4882a593Smuzhiyun * flexcop-common.h - common header file for device-specific source files 5*4882a593Smuzhiyun * see flexcop.c for copyright information 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun #ifndef __FLEXCOP_COMMON_H__ 8*4882a593Smuzhiyun #define __FLEXCOP_COMMON_H__ 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun #include <linux/interrupt.h> 11*4882a593Smuzhiyun #include <linux/pci.h> 12*4882a593Smuzhiyun #include <linux/mutex.h> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun #include "flexcop-reg.h" 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #include <media/dmxdev.h> 17*4882a593Smuzhiyun #include <media/dvb_demux.h> 18*4882a593Smuzhiyun #include <media/dvb_net.h> 19*4882a593Smuzhiyun #include <media/dvb_frontend.h> 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun #define FC_MAX_FEED 256 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun #ifndef FC_LOG_PREFIX 24*4882a593Smuzhiyun #warning please define a log prefix for your file, using a default one 25*4882a593Smuzhiyun #define FC_LOG_PREFIX "b2c2-undef" 26*4882a593Smuzhiyun #endif 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun /* Steal from usb.h */ 29*4882a593Smuzhiyun #undef err 30*4882a593Smuzhiyun #define err(format, arg...) \ 31*4882a593Smuzhiyun printk(KERN_ERR FC_LOG_PREFIX ": " format "\n" , ## arg) 32*4882a593Smuzhiyun #undef info 33*4882a593Smuzhiyun #define info(format, arg...) \ 34*4882a593Smuzhiyun printk(KERN_INFO FC_LOG_PREFIX ": " format "\n" , ## arg) 35*4882a593Smuzhiyun #undef warn 36*4882a593Smuzhiyun #define warn(format, arg...) \ 37*4882a593Smuzhiyun printk(KERN_WARNING FC_LOG_PREFIX ": " format "\n" , ## arg) 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun struct flexcop_dma { 40*4882a593Smuzhiyun struct pci_dev *pdev; 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun u8 *cpu_addr0; 43*4882a593Smuzhiyun dma_addr_t dma_addr0; 44*4882a593Smuzhiyun u8 *cpu_addr1; 45*4882a593Smuzhiyun dma_addr_t dma_addr1; 46*4882a593Smuzhiyun u32 size; /* size of each address in bytes */ 47*4882a593Smuzhiyun }; 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun struct flexcop_i2c_adapter { 50*4882a593Smuzhiyun struct flexcop_device *fc; 51*4882a593Smuzhiyun struct i2c_adapter i2c_adap; 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun u8 no_base_addr; 54*4882a593Smuzhiyun flexcop_i2c_port_t port; 55*4882a593Smuzhiyun }; 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun /* Control structure for data definitions that are common to 58*4882a593Smuzhiyun * the B2C2-based PCI and USB devices. 59*4882a593Smuzhiyun */ 60*4882a593Smuzhiyun struct flexcop_device { 61*4882a593Smuzhiyun /* general */ 62*4882a593Smuzhiyun struct device *dev; /* for firmware_class */ 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun #define FC_STATE_DVB_INIT 0x01 65*4882a593Smuzhiyun #define FC_STATE_I2C_INIT 0x02 66*4882a593Smuzhiyun #define FC_STATE_FE_INIT 0x04 67*4882a593Smuzhiyun int init_state; 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun /* device information */ 70*4882a593Smuzhiyun int has_32_hw_pid_filter; 71*4882a593Smuzhiyun flexcop_revision_t rev; 72*4882a593Smuzhiyun flexcop_device_type_t dev_type; 73*4882a593Smuzhiyun flexcop_bus_t bus_type; 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* dvb stuff */ 76*4882a593Smuzhiyun struct dvb_adapter dvb_adapter; 77*4882a593Smuzhiyun struct dvb_frontend *fe; 78*4882a593Smuzhiyun struct dvb_net dvbnet; 79*4882a593Smuzhiyun struct dvb_demux demux; 80*4882a593Smuzhiyun struct dmxdev dmxdev; 81*4882a593Smuzhiyun struct dmx_frontend hw_frontend; 82*4882a593Smuzhiyun struct dmx_frontend mem_frontend; 83*4882a593Smuzhiyun int (*fe_sleep) (struct dvb_frontend *); 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun struct flexcop_i2c_adapter fc_i2c_adap[3]; 86*4882a593Smuzhiyun struct mutex i2c_mutex; 87*4882a593Smuzhiyun struct module *owner; 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun /* options and status */ 90*4882a593Smuzhiyun int extra_feedcount; 91*4882a593Smuzhiyun int feedcount; 92*4882a593Smuzhiyun int pid_filtering; 93*4882a593Smuzhiyun int fullts_streaming_state; 94*4882a593Smuzhiyun int skip_6_hw_pid_filter; 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun /* bus specific callbacks */ 97*4882a593Smuzhiyun flexcop_ibi_value(*read_ibi_reg) (struct flexcop_device *, 98*4882a593Smuzhiyun flexcop_ibi_register); 99*4882a593Smuzhiyun int (*write_ibi_reg) (struct flexcop_device *, 100*4882a593Smuzhiyun flexcop_ibi_register, flexcop_ibi_value); 101*4882a593Smuzhiyun int (*i2c_request) (struct flexcop_i2c_adapter *, 102*4882a593Smuzhiyun flexcop_access_op_t, u8 chipaddr, u8 addr, u8 *buf, u16 len); 103*4882a593Smuzhiyun int (*stream_control) (struct flexcop_device *, int); 104*4882a593Smuzhiyun int (*get_mac_addr) (struct flexcop_device *fc, int extended); 105*4882a593Smuzhiyun void *bus_specific; 106*4882a593Smuzhiyun }; 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun /* exported prototypes */ 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun /* from flexcop.c */ 111*4882a593Smuzhiyun void flexcop_pass_dmx_data(struct flexcop_device *fc, u8 *buf, u32 len); 112*4882a593Smuzhiyun void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no); 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len); 115*4882a593Smuzhiyun void flexcop_device_kfree(struct flexcop_device *); 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun int flexcop_device_initialize(struct flexcop_device *); 118*4882a593Smuzhiyun void flexcop_device_exit(struct flexcop_device *fc); 119*4882a593Smuzhiyun void flexcop_reset_block_300(struct flexcop_device *fc); 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun /* from flexcop-dma.c */ 122*4882a593Smuzhiyun int flexcop_dma_allocate(struct pci_dev *pdev, 123*4882a593Smuzhiyun struct flexcop_dma *dma, u32 size); 124*4882a593Smuzhiyun void flexcop_dma_free(struct flexcop_dma *dma); 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun int flexcop_dma_control_timer_irq(struct flexcop_device *fc, 127*4882a593Smuzhiyun flexcop_dma_index_t no, int onoff); 128*4882a593Smuzhiyun int flexcop_dma_control_size_irq(struct flexcop_device *fc, 129*4882a593Smuzhiyun flexcop_dma_index_t no, int onoff); 130*4882a593Smuzhiyun int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, 131*4882a593Smuzhiyun flexcop_dma_index_t dma_idx); 132*4882a593Smuzhiyun int flexcop_dma_xfer_control(struct flexcop_device *fc, 133*4882a593Smuzhiyun flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index, 134*4882a593Smuzhiyun int onoff); 135*4882a593Smuzhiyun int flexcop_dma_config_timer(struct flexcop_device *fc, 136*4882a593Smuzhiyun flexcop_dma_index_t dma_idx, u8 cycles); 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun /* from flexcop-eeprom.c */ 139*4882a593Smuzhiyun /* the PCI part uses this call to get the MAC address, the USB part has its own */ 140*4882a593Smuzhiyun int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended); 141*4882a593Smuzhiyun 142*4882a593Smuzhiyun /* from flexcop-i2c.c */ 143*4882a593Smuzhiyun /* the PCI part uses this a i2c_request callback, whereas the usb part has its own 144*4882a593Smuzhiyun * one. We have it in flexcop-i2c.c, because it is going via the actual 145*4882a593Smuzhiyun * I2C-channel of the flexcop. 146*4882a593Smuzhiyun */ 147*4882a593Smuzhiyun int flexcop_i2c_request(struct flexcop_i2c_adapter*, flexcop_access_op_t, 148*4882a593Smuzhiyun u8 chipaddr, u8 addr, u8 *buf, u16 len); 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun /* from flexcop-sram.c */ 151*4882a593Smuzhiyun int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, 152*4882a593Smuzhiyun flexcop_sram_dest_target_t target); 153*4882a593Smuzhiyun void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s); 154*4882a593Smuzhiyun void flexcop_sram_ctrl(struct flexcop_device *fc, 155*4882a593Smuzhiyun int usb_wan, int sramdma, int maximumfill); 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun /* global prototypes for the flexcop-chip */ 158*4882a593Smuzhiyun /* from flexcop-fe-tuner.c */ 159*4882a593Smuzhiyun int flexcop_frontend_init(struct flexcop_device *fc); 160*4882a593Smuzhiyun void flexcop_frontend_exit(struct flexcop_device *fc); 161*4882a593Smuzhiyun 162*4882a593Smuzhiyun /* from flexcop-i2c.c */ 163*4882a593Smuzhiyun int flexcop_i2c_init(struct flexcop_device *fc); 164*4882a593Smuzhiyun void flexcop_i2c_exit(struct flexcop_device *fc); 165*4882a593Smuzhiyun 166*4882a593Smuzhiyun /* from flexcop-sram.c */ 167*4882a593Smuzhiyun int flexcop_sram_init(struct flexcop_device *fc); 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun /* from flexcop-misc.c */ 170*4882a593Smuzhiyun void flexcop_determine_revision(struct flexcop_device *fc); 171*4882a593Smuzhiyun void flexcop_device_name(struct flexcop_device *fc, 172*4882a593Smuzhiyun const char *prefix, const char *suffix); 173*4882a593Smuzhiyun void flexcop_dump_reg(struct flexcop_device *fc, 174*4882a593Smuzhiyun flexcop_ibi_register reg, int num); 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun /* from flexcop-hw-filter.c */ 177*4882a593Smuzhiyun int flexcop_pid_feed_control(struct flexcop_device *fc, 178*4882a593Smuzhiyun struct dvb_demux_feed *dvbdmxfeed, int onoff); 179*4882a593Smuzhiyun void flexcop_hw_filter_init(struct flexcop_device *fc); 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff); 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6]); 184*4882a593Smuzhiyun void flexcop_mac_filter_ctrl(struct flexcop_device *fc, int onoff); 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun #endif 187