1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2010-2014 Michael Krufky (mkrufky@linuxtv.org)
5 * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
8 #ifndef _DVB_USB_MXL111SF_H_
9 #define _DVB_USB_MXL111SF_H_
11 #ifdef DVB_USB_LOG_PREFIX
12 #undef DVB_USB_LOG_PREFIX
14 #define DVB_USB_LOG_PREFIX "mxl111sf"
16 #include <media/tveeprom.h>
17 #include <media/media-entity.h>
19 /* Max transfer size done by I2C transfer functions */
20 #define MXL_MAX_XFER_SIZE 64
22 #define MXL_EP1_REG_READ 1
23 #define MXL_EP2_REG_WRITE 2
24 #define MXL_EP3_INTERRUPT 3
25 #define MXL_EP4_MPEG2 4
28 #define MXL_EP6_MPEG2 6
30 #ifdef USING_ENUM_mxl111sf_current_mode
31 enum mxl111sf_current_mode
{
32 mxl_mode_dvbt
= MXL_EP4_MPEG2
,
33 mxl_mode_mh
= MXL_EP5_I2S
,
34 mxl_mode_atsc
= MXL_EP6_MPEG2
,
38 enum mxl111sf_gpio_port_expander
{
43 struct mxl111sf_adap_state
{
48 int (*fe_init
)(struct dvb_frontend
*);
49 int (*fe_sleep
)(struct dvb_frontend
*);
53 MXL111SF_PAD_RF_INPUT
,
58 struct mxl111sf_state
{
59 struct dvb_usb_device
*d
;
61 enum mxl111sf_gpio_port_expander gpio_port_expander
;
62 u8 port_expander_addr
;
67 #define MXL111SF_V8_100 2
68 #define MXL111SF_V8_200 3
71 #ifdef USING_ENUM_mxl111sf_current_mode
72 enum mxl111sf_current_mode current_mode
;
75 #define MXL_TUNER_MODE 0
76 #define MXL_SOC_MODE 1
77 #define MXL_DEV_MODE_MASK 0x01
81 /* use usb alt setting 1 for EP4 ISOC transfer (dvb-t),
82 EP5 BULK transfer (atsc-mh),
83 EP6 BULK transfer (atsc/qam),
84 use usb alt setting 2 for EP4 BULK transfer (dvb-t),
85 EP5 ISOC transfer (atsc-mh),
86 EP6 ISOC transfer (atsc/qam),
94 struct mxl111sf_adap_state adap_state
[3];
95 u8 sndbuf
[MXL_MAX_XFER_SIZE
];
96 u8 rcvbuf
[MXL_MAX_XFER_SIZE
];
97 struct mutex msg_lock
;
98 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
99 struct media_entity tuner
;
100 struct media_pad tuner_pads
[MXL111SF_NUM_PADS
];
104 int mxl111sf_read_reg(struct mxl111sf_state
*state
, u8 addr
, u8
*data
);
105 int mxl111sf_write_reg(struct mxl111sf_state
*state
, u8 addr
, u8 data
);
107 struct mxl111sf_reg_ctrl_info
{
113 int mxl111sf_write_reg_mask(struct mxl111sf_state
*state
,
114 u8 addr
, u8 mask
, u8 data
);
115 int mxl111sf_ctrl_program_regs(struct mxl111sf_state
*state
,
116 struct mxl111sf_reg_ctrl_info
*ctrl_reg_info
);
118 /* needed for hardware i2c functions in mxl111sf-i2c.c:
119 * mxl111sf_i2c_send_data / mxl111sf_i2c_get_data */
120 int mxl111sf_ctrl_msg(struct mxl111sf_state
*state
,
121 u8 cmd
, u8
*wbuf
, int wlen
, u8
*rbuf
, int rlen
);
123 #define mxl_printk(kern, fmt, arg...) \
124 printk(kern "%s: " fmt "\n", __func__, ##arg)
126 #define mxl_info(fmt, arg...) \
127 mxl_printk(KERN_INFO, fmt, ##arg)
129 extern int dvb_usb_mxl111sf_debug
;
130 #define mxl_debug(fmt, arg...) \
131 if (dvb_usb_mxl111sf_debug) \
132 mxl_printk(KERN_DEBUG, fmt, ##arg)
134 #define MXL_I2C_DBG 0x04
135 #define MXL_ADV_DBG 0x10
136 #define mxl_debug_adv(fmt, arg...) \
137 if (dvb_usb_mxl111sf_debug & MXL_ADV_DBG) \
138 mxl_printk(KERN_DEBUG, fmt, ##arg)
140 #define mxl_i2c(fmt, arg...) \
141 if (dvb_usb_mxl111sf_debug & MXL_I2C_DBG) \
142 mxl_printk(KERN_DEBUG, fmt, ##arg)
144 #define mxl_i2c_adv(fmt, arg...) \
145 if ((dvb_usb_mxl111sf_debug & (MXL_I2C_DBG | MXL_ADV_DBG)) == \
146 (MXL_I2C_DBG | MXL_ADV_DBG)) \
147 mxl_printk(KERN_DEBUG, fmt, ##arg)
149 /* The following allows the mxl_fail() macro defined below to work
150 * in externel modules, such as mxl111sf-tuner.ko, even though
151 * dvb_usb_mxl111sf_debug is not defined within those modules */
152 #if (defined(__MXL111SF_TUNER_H__)) || (defined(__MXL111SF_DEMOD_H__))
153 #define MXL_ADV_DEBUG_ENABLED MXL_ADV_DBG
155 #define MXL_ADV_DEBUG_ENABLED dvb_usb_mxl111sf_debug
158 #define mxl_fail(ret) \
162 if ((__ret) && (MXL_ADV_DEBUG_ENABLED & MXL_ADV_DBG)) \
163 mxl_printk(KERN_ERR, "error %d on line %d", \
168 #endif /* _DVB_USB_MXL111SF_H_ */