18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _DVB_USB_VP7021_H_
38c2ecf20Sopenharmony_ci#define _DVB_USB_VP7021_H_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define DVB_USB_LOG_PREFIX "vp702x"
68c2ecf20Sopenharmony_ci#include "dvb-usb.h"
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ciextern int dvb_usb_vp702x_debug;
98c2ecf20Sopenharmony_ci#define deb_info(args...) dprintk(dvb_usb_vp702x_debug,0x01,args)
108c2ecf20Sopenharmony_ci#define deb_xfer(args...) dprintk(dvb_usb_vp702x_debug,0x02,args)
118c2ecf20Sopenharmony_ci#define deb_rc(args...)   dprintk(dvb_usb_vp702x_debug,0x04,args)
128c2ecf20Sopenharmony_ci#define deb_fe(args...)   dprintk(dvb_usb_vp702x_debug,0x08,args)
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* commands are read and written with USB control messages */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* consecutive read/write operation */
178c2ecf20Sopenharmony_ci#define REQUEST_OUT		0xB2
188c2ecf20Sopenharmony_ci#define REQUEST_IN		0xB3
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0
218c2ecf20Sopenharmony_ci * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer
228c2ecf20Sopenharmony_ci * the returning buffer looks as follows
238c2ecf20Sopenharmony_ci * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define GET_TUNER_STATUS	0x05
268c2ecf20Sopenharmony_ci/* additional in buffer:
278c2ecf20Sopenharmony_ci * 0   1   2    3              4   5   6               7       8
288c2ecf20Sopenharmony_ci * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define GET_SYSTEM_STRING	0x06
318c2ecf20Sopenharmony_ci/* additional in buffer:
328c2ecf20Sopenharmony_ci * 0   1   2   3   4   5   6   7   8
338c2ecf20Sopenharmony_ci * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define SET_DISEQC_CMD		0x08
368c2ecf20Sopenharmony_ci/* additional out buffer:
378c2ecf20Sopenharmony_ci * 0    1  2  3  4
388c2ecf20Sopenharmony_ci * len  X1 X2 X3 X4
398c2ecf20Sopenharmony_ci * additional in buffer:
408c2ecf20Sopenharmony_ci * 0   1 2
418c2ecf20Sopenharmony_ci * N/A 0 0   b[1] == b[2] == 0 -> success, failure otherwise */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define SET_LNB_POWER		0x09
448c2ecf20Sopenharmony_ci/* additional out buffer:
458c2ecf20Sopenharmony_ci * 0    1    2
468c2ecf20Sopenharmony_ci * 0x00 0xff 1 = on, 0 = off
478c2ecf20Sopenharmony_ci * additional in buffer:
488c2ecf20Sopenharmony_ci * 0   1 2
498c2ecf20Sopenharmony_ci * N/A 0 0   b[1] == b[2] == 0 -> success failure otherwise */
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define GET_MAC_ADDRESS		0x0A
528c2ecf20Sopenharmony_ci/* #define GET_MAC_ADDRESS   0x0B */
538c2ecf20Sopenharmony_ci/* additional in buffer:
548c2ecf20Sopenharmony_ci * 0   1   2            3    4    5    6    7    8
558c2ecf20Sopenharmony_ci * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define SET_PID_FILTER		0x11
588c2ecf20Sopenharmony_ci/* additional in buffer:
598c2ecf20Sopenharmony_ci * 0        1        ... 14       15       16
608c2ecf20Sopenharmony_ci * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/* request: 0xB2; i: 0; v: 0;
638c2ecf20Sopenharmony_ci * b[0] != 0 -> tune and lock a channel
648c2ecf20Sopenharmony_ci * 0     1     2       3      4      5      6    7
658c2ecf20Sopenharmony_ci * freq0 freq1 divstep srate0 srate1 srate2 flag chksum
668c2ecf20Sopenharmony_ci */
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/* one direction requests */
698c2ecf20Sopenharmony_ci#define READ_REMOTE_REQ		0xB4
708c2ecf20Sopenharmony_ci/* IN  i: 0; v: 0; b[0] == request, b[1] == key */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define READ_PID_NUMBER_REQ	0xB5
738c2ecf20Sopenharmony_ci/* IN  i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define WRITE_EEPROM_REQ	0xB6
768c2ecf20Sopenharmony_ci/* OUT i: offset; v: value to write; no extra buffer */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define READ_EEPROM_REQ		0xB7
798c2ecf20Sopenharmony_ci/* IN  i: bufferlen; v: offset; buffer with bufferlen bytes */
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define READ_STATUS		0xB8
828c2ecf20Sopenharmony_ci/* IN  i: 0; v: 0; bufferlen 10 */
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define READ_TUNER_REG_REQ	0xB9
858c2ecf20Sopenharmony_ci/* IN  i: 0; v: register; b[0] = value */
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define READ_FX2_REG_REQ	0xBA
888c2ecf20Sopenharmony_ci/* IN  i: offset; v: 0; b[0] = value */
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define WRITE_FX2_REG_REQ	0xBB
918c2ecf20Sopenharmony_ci/* OUT i: offset; v: value to write; 1 byte extra buffer */
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define SET_TUNER_POWER_REQ	0xBC
948c2ecf20Sopenharmony_ci/* IN  i: 0 = power off, 1 = power on */
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define WRITE_TUNER_REG_REQ	0xBD
978c2ecf20Sopenharmony_ci/* IN  i: register, v: value to write, no extra buffer */
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define RESET_TUNER		0xBE
1008c2ecf20Sopenharmony_ci/* IN  i: 0, v: 0, no extra buffer */
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistruct vp702x_device_state {
1038c2ecf20Sopenharmony_ci	struct mutex buf_mutex;
1048c2ecf20Sopenharmony_ci	int buf_len;
1058c2ecf20Sopenharmony_ci	u8 *buf;
1068c2ecf20Sopenharmony_ci};
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciextern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d);
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ciextern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec);
1128c2ecf20Sopenharmony_ciextern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#endif
115