1*a10e763bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2786baecfSMauro Carvalho Chehab /* Header file for all dibusb-based-receivers. 3786baecfSMauro Carvalho Chehab * 499e44da7SPatrick Boettcher * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de) 5786baecfSMauro Carvalho Chehab * 6670d7adbSMauro Carvalho Chehab * see Documentation/media/dvb-drivers/dvb-usb.rst for more information 7786baecfSMauro Carvalho Chehab */ 8786baecfSMauro Carvalho Chehab #ifndef _DVB_USB_DIBUSB_H_ 9786baecfSMauro Carvalho Chehab #define _DVB_USB_DIBUSB_H_ 10786baecfSMauro Carvalho Chehab 11786baecfSMauro Carvalho Chehab #ifndef DVB_USB_LOG_PREFIX 12786baecfSMauro Carvalho Chehab #define DVB_USB_LOG_PREFIX "dibusb" 13786baecfSMauro Carvalho Chehab #endif 14786baecfSMauro Carvalho Chehab #include "dvb-usb.h" 15786baecfSMauro Carvalho Chehab 16786baecfSMauro Carvalho Chehab #include "dib3000.h" 17786baecfSMauro Carvalho Chehab #include "dib3000mc.h" 18786baecfSMauro Carvalho Chehab #include "mt2060.h" 19786baecfSMauro Carvalho Chehab 20786baecfSMauro Carvalho Chehab /* 21786baecfSMauro Carvalho Chehab * protocol of all dibusb related devices 22786baecfSMauro Carvalho Chehab */ 23786baecfSMauro Carvalho Chehab 24786baecfSMauro Carvalho Chehab /* 25786baecfSMauro Carvalho Chehab * bulk msg to/from endpoint 0x01 26786baecfSMauro Carvalho Chehab * 27786baecfSMauro Carvalho Chehab * general structure: 28786baecfSMauro Carvalho Chehab * request_byte parameter_bytes 29786baecfSMauro Carvalho Chehab */ 30786baecfSMauro Carvalho Chehab 31786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_START_READ 0x00 32786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_START_DEMOD 0x01 33786baecfSMauro Carvalho Chehab 34786baecfSMauro Carvalho Chehab /* 35786baecfSMauro Carvalho Chehab * i2c read 36ad86faadSRaimonds Cicans * bulk write: 0x02 ((7bit i2c_addr << 1) | 0x01) register_bytes length_word 37786baecfSMauro Carvalho Chehab * bulk read: byte_buffer (length_word bytes) 38786baecfSMauro Carvalho Chehab */ 39786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_I2C_READ 0x02 40786baecfSMauro Carvalho Chehab 41786baecfSMauro Carvalho Chehab /* 42786baecfSMauro Carvalho Chehab * i2c write 43786baecfSMauro Carvalho Chehab * bulk write: 0x03 (7bit i2c_addr << 1) register_bytes value_bytes 44786baecfSMauro Carvalho Chehab */ 45786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_I2C_WRITE 0x03 46786baecfSMauro Carvalho Chehab 47786baecfSMauro Carvalho Chehab /* 48786baecfSMauro Carvalho Chehab * polling the value of the remote control 49786baecfSMauro Carvalho Chehab * bulk write: 0x04 50786baecfSMauro Carvalho Chehab * bulk read: byte_buffer (5 bytes) 51786baecfSMauro Carvalho Chehab */ 52786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_POLL_REMOTE 0x04 53786baecfSMauro Carvalho Chehab 54786baecfSMauro Carvalho Chehab /* additional status values for Hauppauge Remote Control Protocol */ 55786baecfSMauro Carvalho Chehab #define DIBUSB_RC_HAUPPAUGE_KEY_PRESSED 0x01 56786baecfSMauro Carvalho Chehab #define DIBUSB_RC_HAUPPAUGE_KEY_EMPTY 0x03 57786baecfSMauro Carvalho Chehab 58786baecfSMauro Carvalho Chehab /* streaming mode: 59786baecfSMauro Carvalho Chehab * bulk write: 0x05 mode_byte 60786baecfSMauro Carvalho Chehab * 61786baecfSMauro Carvalho Chehab * mode_byte is mostly 0x00 62786baecfSMauro Carvalho Chehab */ 63786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_SET_STREAMING_MODE 0x05 64786baecfSMauro Carvalho Chehab 65786baecfSMauro Carvalho Chehab /* interrupt the internal read loop, when blocking */ 66786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_INTR_READ 0x06 67786baecfSMauro Carvalho Chehab 68786baecfSMauro Carvalho Chehab /* io control 69786baecfSMauro Carvalho Chehab * 0x07 cmd_byte param_bytes 70786baecfSMauro Carvalho Chehab * 71786baecfSMauro Carvalho Chehab * param_bytes can be up to 32 bytes 72786baecfSMauro Carvalho Chehab * 73786baecfSMauro Carvalho Chehab * cmd_byte function parameter name 74786baecfSMauro Carvalho Chehab * 0x00 power mode 75786baecfSMauro Carvalho Chehab * 0x00 sleep 76786baecfSMauro Carvalho Chehab * 0x01 wakeup 77786baecfSMauro Carvalho Chehab * 78786baecfSMauro Carvalho Chehab * 0x01 enable streaming 79786baecfSMauro Carvalho Chehab * 0x02 disable streaming 80786baecfSMauro Carvalho Chehab * 81786baecfSMauro Carvalho Chehab * 82786baecfSMauro Carvalho Chehab */ 83786baecfSMauro Carvalho Chehab #define DIBUSB_REQ_SET_IOCTL 0x07 84786baecfSMauro Carvalho Chehab 85786baecfSMauro Carvalho Chehab /* IOCTL commands */ 86786baecfSMauro Carvalho Chehab 87786baecfSMauro Carvalho Chehab /* change the power mode in firmware */ 88786baecfSMauro Carvalho Chehab #define DIBUSB_IOCTL_CMD_POWER_MODE 0x00 89786baecfSMauro Carvalho Chehab #define DIBUSB_IOCTL_POWER_SLEEP 0x00 90786baecfSMauro Carvalho Chehab #define DIBUSB_IOCTL_POWER_WAKEUP 0x01 91786baecfSMauro Carvalho Chehab 92786baecfSMauro Carvalho Chehab /* modify streaming of the FX2 */ 93786baecfSMauro Carvalho Chehab #define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01 94786baecfSMauro Carvalho Chehab #define DIBUSB_IOCTL_CMD_DISABLE_STREAM 0x02 95786baecfSMauro Carvalho Chehab 96426398b1SMauro Carvalho Chehab /* Max transfer size done by I2C transfer functions */ 97426398b1SMauro Carvalho Chehab #define MAX_XFER_SIZE 64 98426398b1SMauro Carvalho Chehab 99786baecfSMauro Carvalho Chehab struct dibusb_state { 100786baecfSMauro Carvalho Chehab struct dib_fe_xfer_ops ops; 101786baecfSMauro Carvalho Chehab int mt2060_present; 102786baecfSMauro Carvalho Chehab u8 tuner_addr; 103786baecfSMauro Carvalho Chehab }; 104786baecfSMauro Carvalho Chehab 105786baecfSMauro Carvalho Chehab struct dibusb_device_state { 106786baecfSMauro Carvalho Chehab /* for RC5 remote control */ 107786baecfSMauro Carvalho Chehab int old_toggle; 108786baecfSMauro Carvalho Chehab int last_repeat_count; 109786baecfSMauro Carvalho Chehab }; 110786baecfSMauro Carvalho Chehab 111786baecfSMauro Carvalho Chehab extern struct i2c_algorithm dibusb_i2c_algo; 112786baecfSMauro Carvalho Chehab 113786baecfSMauro Carvalho Chehab extern int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *); 114786baecfSMauro Carvalho Chehab extern int dibusb_dib3000mc_tuner_attach (struct dvb_usb_adapter *); 115786baecfSMauro Carvalho Chehab 116786baecfSMauro Carvalho Chehab extern int dibusb_streaming_ctrl(struct dvb_usb_adapter *, int); 117786baecfSMauro Carvalho Chehab extern int dibusb_pid_filter(struct dvb_usb_adapter *, int, u16, int); 118786baecfSMauro Carvalho Chehab extern int dibusb_pid_filter_ctrl(struct dvb_usb_adapter *, int); 119786baecfSMauro Carvalho Chehab extern int dibusb2_0_streaming_ctrl(struct dvb_usb_adapter *, int); 120786baecfSMauro Carvalho Chehab 121786baecfSMauro Carvalho Chehab extern int dibusb_power_ctrl(struct dvb_usb_device *, int); 122786baecfSMauro Carvalho Chehab extern int dibusb2_0_power_ctrl(struct dvb_usb_device *, int); 123786baecfSMauro Carvalho Chehab 124786baecfSMauro Carvalho Chehab #define DEFAULT_RC_INTERVAL 150 125786baecfSMauro Carvalho Chehab //#define DEFAULT_RC_INTERVAL 100000 126786baecfSMauro Carvalho Chehab 127786baecfSMauro Carvalho Chehab extern struct rc_map_table rc_map_dibusb_table[]; 128786baecfSMauro Carvalho Chehab extern int dibusb_rc_query(struct dvb_usb_device *, u32 *, int *); 129786baecfSMauro Carvalho Chehab extern int dibusb_read_eeprom_byte(struct dvb_usb_device *, u8, u8 *); 130786baecfSMauro Carvalho Chehab 131786baecfSMauro Carvalho Chehab #endif 132