1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _DVB_USB_CXUSB_H_ 3 #define _DVB_USB_CXUSB_H_ 4 5 #include <linux/i2c.h> 6 #include <linux/mutex.h> 7 8 #define DVB_USB_LOG_PREFIX "cxusb" 9 #include "dvb-usb.h" 10 11 /* usb commands - some of it are guesses, don't have a reference yet */ 12 #define CMD_BLUEBIRD_GPIO_RW 0x05 13 14 #define CMD_I2C_WRITE 0x08 15 #define CMD_I2C_READ 0x09 16 17 #define CMD_GPIO_READ 0x0d 18 #define CMD_GPIO_WRITE 0x0e 19 #define GPIO_TUNER 0x02 20 21 #define CMD_POWER_OFF 0xdc 22 #define CMD_POWER_ON 0xde 23 24 #define CMD_STREAMING_ON 0x36 25 #define CMD_STREAMING_OFF 0x37 26 27 #define CMD_AVER_STREAM_ON 0x18 28 #define CMD_AVER_STREAM_OFF 0x19 29 30 #define CMD_GET_IR_CODE 0x47 31 32 #define CMD_ANALOG 0x50 33 #define CMD_DIGITAL 0x51 34 35 /* Max transfer size done by I2C transfer functions */ 36 #define MAX_XFER_SIZE 80 37 38 struct cxusb_state { 39 u8 gpio_write_state[3]; 40 bool gpio_write_refresh[3]; 41 struct i2c_client *i2c_client_demod; 42 struct i2c_client *i2c_client_tuner; 43 44 unsigned char data[MAX_XFER_SIZE]; 45 46 struct mutex stream_mutex; 47 u8 last_lock; 48 int (*fe_read_status)(struct dvb_frontend *fe, 49 enum fe_status *status); 50 }; 51 52 enum cxusb_open_type { 53 CXUSB_OPEN_INIT, CXUSB_OPEN_NONE, 54 CXUSB_OPEN_ANALOG, CXUSB_OPEN_DIGITAL 55 }; 56 57 struct cxusb_medion_dev { 58 /* has to be the first one */ 59 struct cxusb_state state; 60 61 struct dvb_usb_device *dvbdev; 62 63 enum cxusb_open_type open_type; 64 unsigned int open_ctr; 65 struct mutex open_lock; 66 }; 67 68 /* defines for "debug" module parameter */ 69 #define CXUSB_DBG_RC BIT(0) 70 #define CXUSB_DBG_I2C BIT(1) 71 #define CXUSB_DBG_MISC BIT(2) 72 73 extern int dvb_usb_cxusb_debug; 74 75 int cxusb_ctrl_msg(struct dvb_usb_device *d, 76 u8 cmd, const u8 *wbuf, int wlen, u8 *rbuf, int rlen); 77 78 static inline int cxusb_medion_analog_init(struct dvb_usb_device *dvbdev) 79 { 80 return -EINVAL; 81 } 82 83 static inline int cxusb_medion_register_analog(struct dvb_usb_device *dvbdev) 84 { 85 return 0; 86 } 87 88 static inline void cxusb_medion_unregister_analog(struct dvb_usb_device *dvbdev) 89 { 90 } 91 92 int cxusb_medion_get(struct dvb_usb_device *dvbdev, 93 enum cxusb_open_type open_type); 94 void cxusb_medion_put(struct dvb_usb_device *dvbdev); 95 96 #endif 97