18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* Header file for all dibusb-based-receivers. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de) 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifndef _DVB_USB_DIBUSB_H_ 98c2ecf20Sopenharmony_ci#define _DVB_USB_DIBUSB_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef DVB_USB_LOG_PREFIX 128c2ecf20Sopenharmony_ci #define DVB_USB_LOG_PREFIX "dibusb" 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci#include "dvb-usb.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include "dib3000.h" 178c2ecf20Sopenharmony_ci#include "dib3000mc.h" 188c2ecf20Sopenharmony_ci#include "mt2060.h" 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * protocol of all dibusb related devices 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * bulk msg to/from endpoint 0x01 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * general structure: 288c2ecf20Sopenharmony_ci * request_byte parameter_bytes 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define DIBUSB_REQ_START_READ 0x00 328c2ecf20Sopenharmony_ci#define DIBUSB_REQ_START_DEMOD 0x01 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * i2c read 368c2ecf20Sopenharmony_ci * bulk write: 0x02 ((7bit i2c_addr << 1) | 0x01) register_bytes length_word 378c2ecf20Sopenharmony_ci * bulk read: byte_buffer (length_word bytes) 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ci#define DIBUSB_REQ_I2C_READ 0x02 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* 428c2ecf20Sopenharmony_ci * i2c write 438c2ecf20Sopenharmony_ci * bulk write: 0x03 (7bit i2c_addr << 1) register_bytes value_bytes 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci#define DIBUSB_REQ_I2C_WRITE 0x03 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* 488c2ecf20Sopenharmony_ci * polling the value of the remote control 498c2ecf20Sopenharmony_ci * bulk write: 0x04 508c2ecf20Sopenharmony_ci * bulk read: byte_buffer (5 bytes) 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci#define DIBUSB_REQ_POLL_REMOTE 0x04 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* additional status values for Hauppauge Remote Control Protocol */ 558c2ecf20Sopenharmony_ci#define DIBUSB_RC_HAUPPAUGE_KEY_PRESSED 0x01 568c2ecf20Sopenharmony_ci#define DIBUSB_RC_HAUPPAUGE_KEY_EMPTY 0x03 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* streaming mode: 598c2ecf20Sopenharmony_ci * bulk write: 0x05 mode_byte 608c2ecf20Sopenharmony_ci * 618c2ecf20Sopenharmony_ci * mode_byte is mostly 0x00 628c2ecf20Sopenharmony_ci */ 638c2ecf20Sopenharmony_ci#define DIBUSB_REQ_SET_STREAMING_MODE 0x05 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* interrupt the internal read loop, when blocking */ 668c2ecf20Sopenharmony_ci#define DIBUSB_REQ_INTR_READ 0x06 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* io control 698c2ecf20Sopenharmony_ci * 0x07 cmd_byte param_bytes 708c2ecf20Sopenharmony_ci * 718c2ecf20Sopenharmony_ci * param_bytes can be up to 32 bytes 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * cmd_byte function parameter name 748c2ecf20Sopenharmony_ci * 0x00 power mode 758c2ecf20Sopenharmony_ci * 0x00 sleep 768c2ecf20Sopenharmony_ci * 0x01 wakeup 778c2ecf20Sopenharmony_ci * 788c2ecf20Sopenharmony_ci * 0x01 enable streaming 798c2ecf20Sopenharmony_ci * 0x02 disable streaming 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * 828c2ecf20Sopenharmony_ci */ 838c2ecf20Sopenharmony_ci#define DIBUSB_REQ_SET_IOCTL 0x07 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* IOCTL commands */ 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* change the power mode in firmware */ 888c2ecf20Sopenharmony_ci#define DIBUSB_IOCTL_CMD_POWER_MODE 0x00 898c2ecf20Sopenharmony_ci#define DIBUSB_IOCTL_POWER_SLEEP 0x00 908c2ecf20Sopenharmony_ci#define DIBUSB_IOCTL_POWER_WAKEUP 0x01 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* modify streaming of the FX2 */ 938c2ecf20Sopenharmony_ci#define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01 948c2ecf20Sopenharmony_ci#define DIBUSB_IOCTL_CMD_DISABLE_STREAM 0x02 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* Max transfer size done by I2C transfer functions */ 978c2ecf20Sopenharmony_ci#define MAX_XFER_SIZE 64 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistruct dibusb_state { 1008c2ecf20Sopenharmony_ci struct dib_fe_xfer_ops ops; 1018c2ecf20Sopenharmony_ci int mt2060_present; 1028c2ecf20Sopenharmony_ci u8 tuner_addr; 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistruct dibusb_device_state { 1068c2ecf20Sopenharmony_ci /* for RC5 remote control */ 1078c2ecf20Sopenharmony_ci int old_toggle; 1088c2ecf20Sopenharmony_ci int last_repeat_count; 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ciextern struct i2c_algorithm dibusb_i2c_algo; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciextern int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *); 1148c2ecf20Sopenharmony_ciextern int dibusb_dib3000mc_tuner_attach (struct dvb_usb_adapter *); 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciextern int dibusb_streaming_ctrl(struct dvb_usb_adapter *, int); 1178c2ecf20Sopenharmony_ciextern int dibusb_pid_filter(struct dvb_usb_adapter *, int, u16, int); 1188c2ecf20Sopenharmony_ciextern int dibusb_pid_filter_ctrl(struct dvb_usb_adapter *, int); 1198c2ecf20Sopenharmony_ciextern int dibusb2_0_streaming_ctrl(struct dvb_usb_adapter *, int); 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciextern int dibusb_power_ctrl(struct dvb_usb_device *, int); 1228c2ecf20Sopenharmony_ciextern int dibusb2_0_power_ctrl(struct dvb_usb_device *, int); 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#define DEFAULT_RC_INTERVAL 150 1258c2ecf20Sopenharmony_ci//#define DEFAULT_RC_INTERVAL 100000 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ciextern struct rc_map_table rc_map_dibusb_table[]; 1288c2ecf20Sopenharmony_ciextern int dibusb_rc_query(struct dvb_usb_device *, u32 *, int *); 1298c2ecf20Sopenharmony_ciextern int dibusb_read_eeprom_byte(struct dvb_usb_device *, u8, u8 *); 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#endif 132