2 * Copyright (C) 2010 Michael Krufky (mkrufky@kernellabs.com)
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, version 2.
8 * see Documentation/dvb/README.dvb-usb for more information
11 #ifndef _DVB_USB_MXL111SF_H_
12 #define _DVB_USB_MXL111SF_H_
14 #ifdef DVB_USB_LOG_PREFIX
15 #undef DVB_USB_LOG_PREFIX
17 #define DVB_USB_LOG_PREFIX "mxl111sf"
19 #include <media/tveeprom.h>
21 #define MXL_EP1_REG_READ 1
22 #define MXL_EP2_REG_WRITE 2
23 #define MXL_EP3_INTERRUPT 3
24 #define MXL_EP4_MPEG2 4
27 #define MXL_EP6_MPEG2 6
29 #ifdef USING_ENUM_mxl111sf_current_mode
30 enum mxl111sf_current_mode
{
31 mxl_mode_dvbt
= MXL_EP4_MPEG2
,
32 mxl_mode_mh
= MXL_EP5_I2S
,
33 mxl_mode_atsc
= MXL_EP6_MPEG2
,
37 enum mxl111sf_gpio_port_expander
{
42 struct mxl111sf_adap_state
{
47 int (*fe_init
)(struct dvb_frontend
*);
48 int (*fe_sleep
)(struct dvb_frontend
*);
51 struct mxl111sf_state
{
52 struct dvb_usb_device
*d
;
54 enum mxl111sf_gpio_port_expander gpio_port_expander
;
55 u8 port_expander_addr
;
60 #define MXL111SF_V8_100 2
61 #define MXL111SF_V8_200 3
64 #ifdef USING_ENUM_mxl111sf_current_mode
65 enum mxl111sf_current_mode current_mode
;
68 #define MXL_TUNER_MODE 0
69 #define MXL_SOC_MODE 1
70 #define MXL_DEV_MODE_MASK 0x01
74 /* use usb alt setting 1 for EP4 ISOC transfer (dvb-t),
75 EP5 BULK transfer (atsc-mh),
76 EP6 BULK transfer (atsc/qam),
77 use usb alt setting 2 for EP4 BULK transfer (dvb-t),
78 EP5 ISOC transfer (atsc-mh),
79 EP6 ISOC transfer (atsc/qam),
87 struct mxl111sf_adap_state adap_state
[3];
90 int mxl111sf_read_reg(struct mxl111sf_state
*state
, u8 addr
, u8
*data
);
91 int mxl111sf_write_reg(struct mxl111sf_state
*state
, u8 addr
, u8 data
);
93 struct mxl111sf_reg_ctrl_info
{
99 int mxl111sf_write_reg_mask(struct mxl111sf_state
*state
,
100 u8 addr
, u8 mask
, u8 data
);
101 int mxl111sf_ctrl_program_regs(struct mxl111sf_state
*state
,
102 struct mxl111sf_reg_ctrl_info
*ctrl_reg_info
);
104 /* needed for hardware i2c functions in mxl111sf-i2c.c:
105 * mxl111sf_i2c_send_data / mxl111sf_i2c_get_data */
106 int mxl111sf_ctrl_msg(struct dvb_usb_device
*d
,
107 u8 cmd
, u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
);
109 #define mxl_printk(kern, fmt, arg...) \
110 printk(kern "%s: " fmt "\n", __func__, ##arg)
112 #define mxl_info(fmt, arg...) \
113 mxl_printk(KERN_INFO, fmt, ##arg)
115 extern int dvb_usb_mxl111sf_debug
;
116 #define mxl_debug(fmt, arg...) \
117 if (dvb_usb_mxl111sf_debug) \
118 mxl_printk(KERN_DEBUG, fmt, ##arg)
120 #define MXL_I2C_DBG 0x04
121 #define MXL_ADV_DBG 0x10
122 #define mxl_debug_adv(fmt, arg...) \
123 if (dvb_usb_mxl111sf_debug & MXL_ADV_DBG) \
124 mxl_printk(KERN_DEBUG, fmt, ##arg)
126 #define mxl_i2c(fmt, arg...) \
127 if (dvb_usb_mxl111sf_debug & MXL_I2C_DBG) \
128 mxl_printk(KERN_DEBUG, fmt, ##arg)
130 #define mxl_i2c_adv(fmt, arg...) \
131 if ((dvb_usb_mxl111sf_debug & (MXL_I2C_DBG | MXL_ADV_DBG)) == \
132 (MXL_I2C_DBG | MXL_ADV_DBG)) \
133 mxl_printk(KERN_DEBUG, fmt, ##arg)
135 /* The following allows the mxl_fail() macro defined below to work
136 * in externel modules, such as mxl111sf-tuner.ko, even though
137 * dvb_usb_mxl111sf_debug is not defined within those modules */
138 #if (defined(__MXL111SF_TUNER_H__)) || (defined(__MXL111SF_DEMOD_H__))
139 #define MXL_ADV_DEBUG_ENABLED MXL_ADV_DBG
141 #define MXL_ADV_DEBUG_ENABLED dvb_usb_mxl111sf_debug
144 #define mxl_fail(ret) \
148 if ((__ret) && (MXL_ADV_DEBUG_ENABLED & MXL_ADV_DBG)) \
149 mxl_printk(KERN_ERR, "error %d on line %d", \
154 #endif /* _DVB_USB_MXL111SF_H_ */