162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci *  Copyright (C) 2005-6 DiBcom, SA
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef _DIB0700_H_
762306a36Sopenharmony_ci#define _DIB0700_H_
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#define DVB_USB_LOG_PREFIX "dib0700"
1062306a36Sopenharmony_ci#include "dvb-usb.h"
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include "dib07x0.h"
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciextern int dvb_usb_dib0700_debug;
1562306a36Sopenharmony_ci#define deb_info(args...)   dprintk(dvb_usb_dib0700_debug,0x01,args)
1662306a36Sopenharmony_ci#define deb_fw(args...)     dprintk(dvb_usb_dib0700_debug,0x02,args)
1762306a36Sopenharmony_ci#define deb_fwdata(args...) dprintk(dvb_usb_dib0700_debug,0x04,args)
1862306a36Sopenharmony_ci#define deb_data(args...)   dprintk(dvb_usb_dib0700_debug,0x08,args)
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define REQUEST_SET_USB_XFER_LEN    0x0 /* valid only for firmware version */
2162306a36Sopenharmony_ci					/* higher than 1.21 */
2262306a36Sopenharmony_ci#define REQUEST_I2C_READ            0x2
2362306a36Sopenharmony_ci#define REQUEST_I2C_WRITE           0x3
2462306a36Sopenharmony_ci#define REQUEST_POLL_RC             0x4 /* deprecated in firmware v1.20 */
2562306a36Sopenharmony_ci#define REQUEST_JUMPRAM             0x8
2662306a36Sopenharmony_ci#define REQUEST_SET_CLOCK           0xB
2762306a36Sopenharmony_ci#define REQUEST_SET_GPIO            0xC
2862306a36Sopenharmony_ci#define REQUEST_ENABLE_VIDEO        0xF
2962306a36Sopenharmony_ci	// 1 Byte: 4MSB(1 = enable streaming, 0 = disable streaming) 4LSB(Video Mode: 0 = MPEG2 188Bytes, 1 = Analog)
3062306a36Sopenharmony_ci	// 2 Byte: MPEG2 mode:  4MSB(1 = Master Mode, 0 = Slave Mode) 4LSB(Channel 1 = bit0, Channel 2 = bit1)
3162306a36Sopenharmony_ci	// 2 Byte: Analog mode: 4MSB(0 = 625 lines, 1 = 525 lines)    4LSB(     "                "           )
3262306a36Sopenharmony_ci#define REQUEST_SET_I2C_PARAM       0x10
3362306a36Sopenharmony_ci#define REQUEST_SET_RC              0x11
3462306a36Sopenharmony_ci#define REQUEST_NEW_I2C_READ        0x12
3562306a36Sopenharmony_ci#define REQUEST_NEW_I2C_WRITE       0x13
3662306a36Sopenharmony_ci#define REQUEST_GET_VERSION         0x15
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_cistruct dib0700_state {
3962306a36Sopenharmony_ci	u8 channel_state;
4062306a36Sopenharmony_ci	u16 mt2060_if1[2];
4162306a36Sopenharmony_ci	u8 rc_toggle;
4262306a36Sopenharmony_ci	u8 rc_counter;
4362306a36Sopenharmony_ci	u8 is_dib7000pc;
4462306a36Sopenharmony_ci	u8 fw_use_new_i2c_api;
4562306a36Sopenharmony_ci	u8 disable_streaming_master_mode;
4662306a36Sopenharmony_ci	u32 fw_version;
4762306a36Sopenharmony_ci	u32 nb_packet_buffer_size;
4862306a36Sopenharmony_ci	int (*read_status)(struct dvb_frontend *, enum fe_status *);
4962306a36Sopenharmony_ci	int (*sleep)(struct dvb_frontend* fe);
5062306a36Sopenharmony_ci	u8 buf[255];
5162306a36Sopenharmony_ci	struct i2c_client *i2c_client_demod;
5262306a36Sopenharmony_ci	struct i2c_client *i2c_client_tuner;
5362306a36Sopenharmony_ci};
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciint dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
5662306a36Sopenharmony_ci			u32 *romversion, u32 *ramversion, u32 *fwtype);
5762306a36Sopenharmony_ciint dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio,
5862306a36Sopenharmony_ci		     u8 gpio_dir, u8 gpio_val);
5962306a36Sopenharmony_ciint dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3);
6062306a36Sopenharmony_ciint dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx,
6162306a36Sopenharmony_ci		    u8 rxlen);
6262306a36Sopenharmony_ciint dib0700_download_firmware(struct usb_device *d,
6362306a36Sopenharmony_ci			      const struct firmware *fw);
6462306a36Sopenharmony_ciint dib0700_rc_setup(struct dvb_usb_device *d, struct usb_interface *intf);
6562306a36Sopenharmony_ciint dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
6662306a36Sopenharmony_ciint dib0700_identify_state(struct usb_device *d,
6762306a36Sopenharmony_ci			   const struct dvb_usb_device_properties *props,
6862306a36Sopenharmony_ci			   const struct dvb_usb_device_description **desc,
6962306a36Sopenharmony_ci			   int *cold);
7062306a36Sopenharmony_ciint dib0700_change_protocol(struct rc_dev *dev, u64 *rc_proto);
7162306a36Sopenharmony_ciint dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz);
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciextern struct i2c_algorithm dib0700_i2c_algo;
7462306a36Sopenharmony_ciextern int dib0700_device_count;
7562306a36Sopenharmony_ciextern struct dvb_usb_device_properties dib0700_devices[];
7662306a36Sopenharmony_ciextern struct usb_device_id dib0700_usb_id_table[];
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#endif
79