162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _DVB_USB_VP7021_H_ 362306a36Sopenharmony_ci#define _DVB_USB_VP7021_H_ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#define DVB_USB_LOG_PREFIX "vp702x" 662306a36Sopenharmony_ci#include "dvb-usb.h" 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciextern int dvb_usb_vp702x_debug; 962306a36Sopenharmony_ci#define deb_info(args...) dprintk(dvb_usb_vp702x_debug,0x01,args) 1062306a36Sopenharmony_ci#define deb_xfer(args...) dprintk(dvb_usb_vp702x_debug,0x02,args) 1162306a36Sopenharmony_ci#define deb_rc(args...) dprintk(dvb_usb_vp702x_debug,0x04,args) 1262306a36Sopenharmony_ci#define deb_fe(args...) dprintk(dvb_usb_vp702x_debug,0x08,args) 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* commands are read and written with USB control messages */ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* consecutive read/write operation */ 1762306a36Sopenharmony_ci#define REQUEST_OUT 0xB2 1862306a36Sopenharmony_ci#define REQUEST_IN 0xB3 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0 2162306a36Sopenharmony_ci * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer 2262306a36Sopenharmony_ci * the returning buffer looks as follows 2362306a36Sopenharmony_ci * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define GET_TUNER_STATUS 0x05 2662306a36Sopenharmony_ci/* additional in buffer: 2762306a36Sopenharmony_ci * 0 1 2 3 4 5 6 7 8 2862306a36Sopenharmony_ci * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */ 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define GET_SYSTEM_STRING 0x06 3162306a36Sopenharmony_ci/* additional in buffer: 3262306a36Sopenharmony_ci * 0 1 2 3 4 5 6 7 8 3362306a36Sopenharmony_ci * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define SET_DISEQC_CMD 0x08 3662306a36Sopenharmony_ci/* additional out buffer: 3762306a36Sopenharmony_ci * 0 1 2 3 4 3862306a36Sopenharmony_ci * len X1 X2 X3 X4 3962306a36Sopenharmony_ci * additional in buffer: 4062306a36Sopenharmony_ci * 0 1 2 4162306a36Sopenharmony_ci * N/A 0 0 b[1] == b[2] == 0 -> success, failure otherwise */ 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define SET_LNB_POWER 0x09 4462306a36Sopenharmony_ci/* additional out buffer: 4562306a36Sopenharmony_ci * 0 1 2 4662306a36Sopenharmony_ci * 0x00 0xff 1 = on, 0 = off 4762306a36Sopenharmony_ci * additional in buffer: 4862306a36Sopenharmony_ci * 0 1 2 4962306a36Sopenharmony_ci * N/A 0 0 b[1] == b[2] == 0 -> success failure otherwise */ 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define GET_MAC_ADDRESS 0x0A 5262306a36Sopenharmony_ci/* #define GET_MAC_ADDRESS 0x0B */ 5362306a36Sopenharmony_ci/* additional in buffer: 5462306a36Sopenharmony_ci * 0 1 2 3 4 5 6 7 8 5562306a36Sopenharmony_ci * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */ 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#define SET_PID_FILTER 0x11 5862306a36Sopenharmony_ci/* additional in buffer: 5962306a36Sopenharmony_ci * 0 1 ... 14 15 16 6062306a36Sopenharmony_ci * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */ 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* request: 0xB2; i: 0; v: 0; 6362306a36Sopenharmony_ci * b[0] != 0 -> tune and lock a channel 6462306a36Sopenharmony_ci * 0 1 2 3 4 5 6 7 6562306a36Sopenharmony_ci * freq0 freq1 divstep srate0 srate1 srate2 flag chksum 6662306a36Sopenharmony_ci */ 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci/* one direction requests */ 6962306a36Sopenharmony_ci#define READ_REMOTE_REQ 0xB4 7062306a36Sopenharmony_ci/* IN i: 0; v: 0; b[0] == request, b[1] == key */ 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#define READ_PID_NUMBER_REQ 0xB5 7362306a36Sopenharmony_ci/* IN i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */ 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#define WRITE_EEPROM_REQ 0xB6 7662306a36Sopenharmony_ci/* OUT i: offset; v: value to write; no extra buffer */ 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define READ_EEPROM_REQ 0xB7 7962306a36Sopenharmony_ci/* IN i: bufferlen; v: offset; buffer with bufferlen bytes */ 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define READ_STATUS 0xB8 8262306a36Sopenharmony_ci/* IN i: 0; v: 0; bufferlen 10 */ 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define READ_TUNER_REG_REQ 0xB9 8562306a36Sopenharmony_ci/* IN i: 0; v: register; b[0] = value */ 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define READ_FX2_REG_REQ 0xBA 8862306a36Sopenharmony_ci/* IN i: offset; v: 0; b[0] = value */ 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define WRITE_FX2_REG_REQ 0xBB 9162306a36Sopenharmony_ci/* OUT i: offset; v: value to write; 1 byte extra buffer */ 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define SET_TUNER_POWER_REQ 0xBC 9462306a36Sopenharmony_ci/* IN i: 0 = power off, 1 = power on */ 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define WRITE_TUNER_REG_REQ 0xBD 9762306a36Sopenharmony_ci/* IN i: register, v: value to write, no extra buffer */ 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define RESET_TUNER 0xBE 10062306a36Sopenharmony_ci/* IN i: 0, v: 0, no extra buffer */ 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_cistruct vp702x_device_state { 10362306a36Sopenharmony_ci struct mutex buf_mutex; 10462306a36Sopenharmony_ci int buf_len; 10562306a36Sopenharmony_ci u8 *buf; 10662306a36Sopenharmony_ci}; 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ciextern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ciextern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); 11262306a36Sopenharmony_ciextern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#endif 115