[RFC PATCH 2/3] si2165: Add first driver version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



DVB-T: works with 8MHz BW channels in germany
DVB-C: works with QAM256

TODO:
- Extract firmware into file
- Verify lock is correctly detected
- Strength and Noise reporting
- Set correct bandwidth / qam parameters
- what dvb-c standard is to be announced
- Compiler warnings

Signed-off-by: Matthias Schwarzott <zzam@xxxxxxxxxx>
---
 drivers/media/dvb-frontends/Kconfig       |    9 +
 drivers/media/dvb-frontends/Makefile      |    1 +
 drivers/media/dvb-frontends/si2165.c      | 2790 +++++++++++++++++++++++++++++
 drivers/media/dvb-frontends/si2165.h      |   42 +
 drivers/media/dvb-frontends/si2165_priv.h |   28 +
 5 files changed, 2870 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/si2165.c
 create mode 100644 drivers/media/dvb-frontends/si2165.h
 create mode 100644 drivers/media/dvb-frontends/si2165_priv.h

diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index bddbab4..47fedde 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -56,6 +56,15 @@ config DVB_TDA18271C2DD
 
 	  Say Y when you want to support this tuner.
 
+config DVB_SI2165
+	tristate "Silicon Labs si2165 based"
+	depends on DVB_CORE && I2C
+	default m if !MEDIA_SUBDRV_AUTOSELECT
+	help
+	  A DVB-C/T demodulator.
+
+	  Say Y when you want to support this frontend.
+
 comment "DVB-S (satellite) frontends"
 	depends on DVB_CORE
 
diff --git a/drivers/media/dvb-frontends/Makefile b/drivers/media/dvb-frontends/Makefile
index f9cb43d..ac128c6 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_DVB_STV0367) += stv0367.o
 obj-$(CONFIG_DVB_CXD2820R) += cxd2820r.o
 obj-$(CONFIG_DVB_DRXK) += drxk.o
 obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
+obj-$(CONFIG_DVB_SI2165) += si2165.o
 obj-$(CONFIG_DVB_IT913X_FE) += it913x-fe.o
 obj-$(CONFIG_DVB_A8293) += a8293.o
 obj-$(CONFIG_DVB_TDA10071) += tda10071.o
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
new file mode 100644
index 0000000..a7ba8b2
--- /dev/null
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -0,0 +1,2790 @@
+/*
+    Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
+
+    Copyright (C) 2013 Matthias Schwarzott <zzam@xxxxxxxxxx>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    References:
+    http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
+*/
+
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/firmware.h>
+
+#include "dvb_frontend.h"
+#include "si2165_priv.h"
+#include "si2165.h"
+
+// Hauppauge WinTV-HVR-930C-HD uses 16.000 MHz xtal
+
+struct si2165_state {
+	struct i2c_adapter *i2c;
+	/* configuration settings */
+	u8 addr;
+	bool fw_loaded;
+	struct dvb_frontend frontend;
+};
+
+#define DEBUG_OTHER	0x01
+#define DEBUG_I2C_WRITE	0x02
+#define DEBUG_I2C_READ	0x04
+static int debug = 0x05;
+
+#define dprintk(args...) \
+	do { \
+		if (debug & DEBUG_OTHER) \
+			printk(KERN_DEBUG "si2165: " args); \
+	} while (0)
+
+#define deb_i2c_write(args...) \
+	do { \
+		if (debug & DEBUG_I2C_WRITE) \
+			printk(KERN_DEBUG "si2165: i2c write: " args); \
+	} while (0)
+
+#define deb_i2c_read(args...) \
+	do { \
+		if (debug & DEBUG_I2C_READ) \
+			printk(KERN_DEBUG "si2165: i2c read: " args); \
+	} while (0)
+
+#if 0
+static int si2165_read(struct si2165_state *state, const enum si2165_reg_addr reg,
+		      u8 *buf, const size_t count)
+{
+	int ret;
+	struct i2c_msg msg[2];
+	u8 regbuf[1] = { reg };
+
+	msg[0].addr = state->config->demod_address;
+	msg[0].flags = 0;
+	msg[0].buf = regbuf;
+	msg[0].len = 1;
+	msg[1].addr = state->config->demod_address;
+	msg[1].flags = I2C_M_RD;
+	msg[1].buf = buf;
+	msg[1].len = count;
+
+	ret = i2c_transfer(state->i2c, msg, 2);
+
+	if (ret != 2) {
+		printk(KERN_DEBUG "%s: ret == %d\n", __func__, ret);
+		return -EREMOTEIO;
+	}
+
+	if (debug) {
+		int i;
+		dprintk("R(%d):", reg & 0x7f);
+		for (i = 0; i < count; i++)
+			printk(KERN_CONT " %02x", buf[i]);
+		printk("\n");
+	}
+
+	return 0;
+}
+#endif
+
+static int si2165_write(struct si2165_state *state, const u16 reg,
+		       const u8 *src, const int count)
+{
+	int ret;
+	struct i2c_msg msg;
+	u8 buf[2 + 4]; // write a maximum of 4 bytes of data
+	if (count + 2 > sizeof(buf))
+	{
+		dev_warn(&state->i2c->dev,
+			  "%s: i2c wr reg=%04x: count=%d is too big!\n",
+			  KBUILD_MODNAME, reg, count);
+		return -EINVAL; 
+	}
+	buf[0] = reg >> 8;
+	buf[1] = reg & 0xff;
+	memcpy(buf + 2, src, count);
+
+	msg.addr = state->addr;
+	msg.flags = 0;
+	msg.buf = buf;
+	msg.len = count + 2;
+
+	if (debug & DEBUG_I2C_WRITE) {
+		int i;
+		deb_i2c_write(KERN_DEBUG "si2165 i2c write: reg: 0x%04x, data:", reg);
+		for (i = 0; i < count; i++)
+			printk(KERN_CONT " %02x", src[i]);
+		printk(KERN_CONT "\n");
+	}
+
+	ret = i2c_transfer(state->i2c, &msg, 1);
+
+	if (ret != 1) {
+		dprintk("%s: ret == %d\n", __func__, ret);
+		return -EREMOTEIO;
+	}
+
+	return 0;
+}
+
+static int si2165_writereg1(struct si2165_state *state, const u16 reg, u8 val1)
+{
+	return si2165_write(state, reg, &val1, 1);
+}
+
+static int si2165_writereg2(struct si2165_state *state, const u16 reg, u8 val1, u8 val2)
+{
+	u8 buf[2] = { val1, val2 };
+	return si2165_write(state, reg, buf, 2);
+}
+
+static int si2165_writereg3(struct si2165_state *state, const u16 reg, u8 val1, u8 val2, u8 val3)
+{
+	u8 buf[3] = { val1, val2, val3 };
+	return si2165_write(state, reg, buf, 3);
+}
+
+static int si2165_writereg4(struct si2165_state *state, const u16 reg, u8 val1, u8 val2, u8 val3, u8 val4)
+{
+	u8 buf[4] = { val1, val2, val3, val4 };
+	return si2165_write(state, reg, buf, 4);
+}
+
+static int si2165_read(struct si2165_state *state,
+		       const u16 reg, u8 *val, const size_t count)
+{
+	int ret;
+	u8 reg_buf[] = { reg >> 8, reg & 0xff };
+	struct i2c_msg msg[] = {
+		{ .addr = state->addr,
+		  .flags = 0, .buf = reg_buf, .len = 2 },
+		{ .addr = state->addr,
+		  .flags = I2C_M_RD, .buf = val, .len = count },
+	};
+
+	
+	msleep(5);
+
+	ret = i2c_transfer(state->i2c, msg, 2);
+
+	if (ret != 2) {
+		printk("si2165: error (addr %02x reg %04x error (ret == %i)\n",
+		       state->addr, reg, ret);
+		if (ret < 0)
+			return ret;
+		else
+			return -EREMOTEIO;
+	}
+
+	if (debug & DEBUG_I2C_READ) {
+		int i;
+		deb_i2c_read("reg: 0x%04x, data:", reg);
+		for (i = 0; i < count; i++)
+			printk(KERN_CONT " %02x", val[i]);
+		printk(KERN_CONT "\n");
+	}
+	return 0;
+}
+
+static int si2165_readreg1(struct si2165_state *state,
+		       const u16 reg, u8* val)
+{
+	return si2165_read(state, reg, val, 1);
+}
+
+static int si2165_readreg2(struct si2165_state *state,
+		       const u16 reg, u8* val)
+{
+	return si2165_read(state, reg, val, 2);
+}
+
+static int si2165_readreg3(struct si2165_state *state,
+		       const u16 reg, u8* val)
+{
+	return si2165_read(state, reg, val, 3);
+}
+
+#if 0
+static inline u32 si2165_div(u32 a, u32 b)
+{
+	return (a + (b / 2)) / b;
+}
+
+static int si2165_reset(struct si2165_state *state, const u8 full)
+{
+	return si2165_writereg(state, RESET, full ? 0x80 : 0x40);
+}
+
+static int si2165_get_inversion(struct si2165_state *state,
+			       fe_spectral_inversion_t *i)
+{
+	int ret;
+	u8 vit_mode;
+
+	ret = si2165_readreg(state, VIT_MODE, &vit_mode);
+	if (ret < 0)
+		return ret;
+
+	if (vit_mode & 0x80)	/* auto inversion was used */
+		*i = (vit_mode & 0x40) ? INVERSION_ON : INVERSION_OFF;
+
+	return 0;
+}
+
+static int si2165_get_symbol_rate(struct si2165_state *state, u32 *sr)
+{
+	int ret;
+	u8 sym_rate_h;
+	u8 dec_ratio;
+	u16 sym_rat_op;
+	u16 monitor;
+	u8 buf[2];
+
+	ret = si2165_readreg(state, SYM_RATE_H, &sym_rate_h);
+	if (ret < 0)
+		return ret;
+
+	if (sym_rate_h & 0x80) {
+		/* symbol rate search was used */
+		ret = si2165_writereg(state, MON_CTRL, 0x03);
+		if (ret < 0)
+			return ret;
+
+		ret = si2165_read(state, MONITOR_H, buf, sizeof(buf));
+		if (ret < 0)
+			return ret;
+
+		monitor = (buf[0] << 8) | buf[1];
+
+		dprintk("sr(auto) = %u\n",
+		       si2165_div(monitor * 15625, 4));
+	} else {
+		ret = si2165_writereg(state, MON_CTRL, 0x05);
+		if (ret < 0)
+			return ret;
+
+		ret = si2165_read(state, MONITOR_H, buf, sizeof(buf));
+		if (ret < 0)
+			return ret;
+
+		dec_ratio = ((buf[0] >> 5) & 0x07) * 32;
+
+		ret = si2165_read(state, SYM_RAT_OP_H, buf, sizeof(buf));
+		if (ret < 0)
+			return ret;
+
+		sym_rat_op = (buf[0] << 8) | buf[1];
+
+		dprintk("sym_rat_op=%d dec_ratio=%d\n",
+		       sym_rat_op, dec_ratio);
+		dprintk("*sr(manual) = %lu\n",
+		       (((state->xtal * 8192) / (sym_rat_op + 8192)) *
+			2) - dec_ratio);
+	}
+
+	return 0;
+}
+
+static int si2165_get_code_rate(struct si2165_state *state, fe_code_rate_t *cr)
+{
+	const fe_code_rate_t fec_tab[8] =
+	    { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_6_7, FEC_7_8,
+		FEC_AUTO, FEC_AUTO };
+
+	int ret;
+	u8 fec_status;
+
+	ret = si2165_readreg(state, FEC_STATUS, &fec_status);
+	if (ret < 0)
+		return ret;
+
+	*cr = fec_tab[(fec_status >> 4) & 0x07];
+
+	return 0;
+}
+
+static int si2165_initfe(struct dvb_frontend *fe)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 buf[2];
+
+	/* wake up */
+	ret = si2165_writereg(state, CONFIG,
+			(state->freq_mult == 6 ? 0x88 : 0x8c));
+	if (ret < 0)
+		return ret;
+
+	/* wait at least 150 usec */
+	udelay(150);
+
+	/* full reset */
+	ret = si2165_reset(state, 1);
+	if (ret < 0)
+		return ret;
+
+/* Per datasheet, write correct values. 09/28/03 ACCJr.
+ * If we don't do this, we won't get FE_HAS_VITERBI in the VP310. */
+	{
+		u8 buf_def[8] = { 0x14, 0x12, 0x03, 0x02,
+				  0x01, 0x00, 0x00, 0x00 };
+
+		ret = si2165_write(state, VIT_SETUP, buf_def, sizeof(buf_def));
+		if (ret < 0)
+			return ret;
+	}
+
+	switch (state->id) {
+	case ID_ZL10313:
+		/* enable ADC */
+		ret = si2165_writereg(state, GPP_CTRL, 0x80);
+		if (ret < 0)
+			return ret;
+
+		/* configure ZL10313 for optimal ADC performance */
+		buf[0] = 0x80;
+		buf[1] = 0xB0;
+		ret = si2165_write(state, HW_CTRL, buf, 2);
+		if (ret < 0)
+			return ret;
+
+		/* enable MPEG output and ADCs */
+		ret = si2165_writereg(state, HW_CTRL, 0x00);
+		if (ret < 0)
+			return ret;
+
+		ret = si2165_writereg(state, MPEG_CTRL, 0x00);
+		if (ret < 0)
+			return ret;
+
+		break;
+	}
+
+	/* SYS_CLK */
+	buf[0] = si2165_div(state->xtal * state->freq_mult * 2, 1000000);
+
+	/* DISEQC_RATIO */
+	buf[1] = si2165_div(state->xtal, 22000 * 4);
+
+	ret = si2165_write(state, SYS_CLK, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_writereg(state, SNR_THS_HIGH, 0x32);
+	if (ret < 0)
+		return ret;
+
+	/* different MOCLK polarity */
+	switch (state->id) {
+	case ID_ZL10313:
+		buf[0] = 0x33;
+		break;
+	default:
+		buf[0] = 0x53;
+		break;
+	}
+
+	ret = si2165_writereg(state, OP_CTRL, buf[0]);
+	if (ret < 0)
+		return ret;
+
+	/* TS_SW_LIM */
+	buf[0] = 0x8c;
+	buf[1] = 0x98;
+
+	ret = si2165_write(state, TS_SW_LIM_L, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_writereg(state, CS_SW_LIM, 0x69);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int si2165_send_master_cmd(struct dvb_frontend *fe,
+				 struct dvb_diseqc_master_cmd *c)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 diseqc_mode;
+
+	if ((c->msg_len == 0) || (c->msg_len > sizeof(c->msg)))
+		return -EINVAL;
+
+	ret = si2165_readreg(state, DISEQC_MODE, &diseqc_mode);
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_write(state, (0x80 | DISEQC_INSTR), c->msg, c->msg_len);
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_writereg(state, DISEQC_MODE,
+			     (diseqc_mode & 0x40) | ((c->msg_len - 1) << 3)
+			     | 0x04);
+	if (ret < 0)
+		return ret;
+
+	/* is there a better way to wait for message to be transmitted */
+	msleep(100);
+
+	/* set DISEQC_MODE[2:0] to zero if a return message is expected */
+	if (c->msg[0] & 0x02) {
+		ret = si2165_writereg(state, DISEQC_MODE, (diseqc_mode & 0x40));
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int si2165_read_status(struct dvb_frontend *fe, fe_status_t *s)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 status[3];
+
+	*s = 0;
+
+	ret = si2165_read(state, QPSK_STAT_H, status, sizeof(status));
+	if (ret < 0)
+		return ret;
+
+	dprintk("QPSK_STAT_H: 0x%02x, QPSK_STAT_L: 0x%02x,"
+		" FEC_STATUS: 0x%02x\n", status[0], status[1], status[2]);
+
+	if (status[0] & 0xc0)
+		*s |= FE_HAS_SIGNAL;	/* signal noise ratio */
+	if (status[0] & 0x04)
+		*s |= FE_HAS_CARRIER;	/* qpsk carrier lock */
+	if (status[2] & 0x02)
+		*s |= FE_HAS_VITERBI;	/* viterbi lock */
+	if (status[2] & 0x04)
+		*s |= FE_HAS_SYNC;	/* byte align lock */
+	if (status[0] & 0x01)
+		*s |= FE_HAS_LOCK;	/* qpsk lock */
+
+	return 0;
+}
+
+static int si2165_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 buf[3];
+
+	ret = si2165_read(state, RS_BERCNT_H, buf, 3);
+	if (ret < 0)
+		return ret;
+
+	*ber = ((buf[0] << 16) | (buf[1] << 8) | buf[2]) * 64;
+
+	return 0;
+}
+
+
+static int si2165_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 buf[2];
+
+	ret = si2165_read(state, M_SNR_H, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	*snr = 0xFFFF - ((((buf[0] & 0x7f) << 8) | buf[1]) << 1);
+
+	return 0;
+}
+
+static int si2165_read_ucblocks(struct dvb_frontend *fe, u32 *ubc)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 buf[2];
+
+	ret = si2165_read(state, RS_UBC_H, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	*ubc = (buf[0] << 8) | buf[1];
+
+	return 0;
+}
+#endif
+
+static int si2165_upload_firmware(struct si2165_state *state);
+
+static int si2165_init(struct dvb_frontend *fe)
+{
+//	printk("%s: finished\n", __func__);
+	return 0;
+}
+
+static int si2165_sleep(struct dvb_frontend *fe)
+{
+	printk("%s: called\n", __func__);
+	return 0;
+}
+
+static int si2165_read_status(struct dvb_frontend* fe, fe_status_t* status)
+{
+	u8 val[3];
+	u8 lock = 0;
+	struct si2165_state *state = fe->demodulator_priv;
+	bool dvbc = false;
+	bool dvbt = false;
+
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+	u32 delsys  = p->delivery_system;
+
+	printk("%s: called\n", __func__);
+
+ 
+	switch (delsys) {
+	case SYS_DVBT:
+	  dprintk("%s: using DVB-T\n");
+	  dvbt = true;
+	  break;
+	case SYS_DVBC_ANNEX_A:
+	case SYS_DVBC_ANNEX_C:
+	  dprintk("%s: using DVB-C\n");
+	  dvbc = true;
+	  break;
+	default:
+	  return -EINVAL;
+	}
+
+	// seq1
+	si2165_readreg1(state, 0x4e0, &lock);
+	*status = 0;
+	if (lock & 0x01) 
+	{ 
+		*status |= FE_HAS_SIGNAL;
+		*status |= FE_HAS_CARRIER;
+		*status |= FE_HAS_VITERBI;
+		*status |= FE_HAS_SYNC;
+		*status |= FE_HAS_LOCK;
+		printk("%s: has lock\n", __func__);
+	}
+	else
+	{
+		printk("%s: has no lock\n", __func__);
+	}
+	si2165_readreg1(state, 0x3f8, val);
+	si2165_readreg1(state, 0x404, val);
+	si2165_readreg1(state, 0x641, val);
+	si2165_readreg1(state, 0x178, val);
+	
+	// seq2
+	si2165_readreg1(state, 0x4e0, &lock);
+	si2165_readreg1(state, 0x408, val);
+	si2165_readreg1(state, 0x3f8, val);
+	si2165_readreg1(state, 0x400, val);
+	
+	si2165_readreg3(state, 0x2a4, val);
+/*	msleep(1);
+	si2165_readreg3(state, 0x2a4, val);
+	msleep(1);
+	si2165_readreg3(state, 0x2a4, val);
+	printk("0x02a4: msleep 10\n");
+	msleep(10);
+	si2165_readreg3(state, 0x2a4, val);
+*/
+
+//	si2165_readreg2(state, 0x2c0, val);
+//	si2165_readreg2(state, 0x2c0, val);
+
+	si2165_readreg3(state, 0x478, val);
+	si2165_readreg3(state, 0x478, val);
+
+	printk("%s: finished\n", __func__);
+	return 0;
+}
+
+static int si2165_read_signal_strength(struct dvb_frontend *fe,
+				      u16 *signal_strength)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 buf[3];
+	//u32 s;
+	u16 agc;
+
+	ret = si2165_readreg3(state, 0x2a4, buf);
+	//s = buf[1] << 8 | buf[0] << 0;
+	if (ret < 0)
+		return ret;
+
+	agc = buf[2] << 8 | buf[1];
+
+	*signal_strength = ~agc;
+
+	//printk("s=%08x agc=%08x\n", s, agc);
+
+	return 0;
+}
+
+static int si2165_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 buf[3];
+
+	ret = si2165_readreg3(state, 0x478, buf);
+	if (ret < 0)
+		return ret;
+
+	*ber = buf[0] << 16 | buf[1] << 8 | buf[2] << 0;
+
+	/*
+	ret = si2165_read(state, RS_BERCNT_H, buf, 3);
+	if (ret < 0)
+		return ret;
+
+	*ber = ((buf[0] << 16) | (buf[1] << 8) | buf[2]) * 64;
+	*/
+
+	return 0;
+}
+
+
+static int si2165_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	//int ret;
+	//u8 buf[2];
+/*
+	ret = si2165_read(state, M_SNR_H, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	*snr = 0xFFFF - ((((buf[0] & 0x7f) << 8) | buf[1]) << 1);
+*/
+	*snr = 0;
+
+	return 0;
+}
+
+static int si2165_read_ucblocks(struct dvb_frontend *fe, u32 *ubc)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 buf[2];
+/*
+	ret = si2165_read(state, RS_UBC_H, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	*ubc = (buf[0] << 8) | buf[1];
+	*/
+	*ubc = 0;
+
+	return 0;
+}
+
+/*
+static int si2165_upload_firmware_block(struct si2165_state *state, const u16 size, const u8* data)
+{
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x00, 0x00, 0x00, 0x90);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x04, 0x00, 0x00);
+	return 0;
+}
+*/
+
+/*
+struct si2165_fw_block
+{
+       si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+       si2165_writereg4(state, 0x0368, 0x00, 0x00, 0x00, 0x90);
+       si2165_writereg4(state, 0x036c, 0xf0, 0x04, 0x00, 0x00);
+  u16 addr;
+  u8 reg368_3;
+  u8 reg368_4;
+  u16 len;
+  const u8 data[];
+};
+*/
+
+static int si2165_upload_firmware_block(struct si2165_state *state, const u8* data, int len)
+{
+       u16 addr = 0x0000; /* fw_block->addr; */
+       u8 reg368_3 = 0, reg368_4 = 0; /* todo */
+       u8 buf_364[4] = { 0x00, 0x00, 0x00, 0xc0 };
+       u8 buf_368[4] = { 0x00, 0x00, reg368_3, reg368_4 };
+       if (len < 4)
+               return -EINVAL;
+       if (len % 4 != 0)
+               return -EINVAL;
+
+
+       while (len > 0)
+       {
+               u8 blockcount;
+
+               // transfer at most 1kB at a time
+               if (len > 0x100)
+                       blockcount = 0x40;
+               else
+                       blockcount = len >> 2;
+               buf_364[0] = blockcount - 1;
+
+               buf_368[0] = addr >> 8;
+               buf_368[1] = (u8)addr;
+
+               si2165_write(state, 0x0364, buf_364, 4);
+               si2165_write(state, 0x0368, buf_368, 4);
+
+               for (; blockcount > 0; blockcount--)
+               {
+                       /* si2165_write(state, 0x036c, data, 4); */
+                       data += 4;
+                       addr += 4;
+                       len  -= 4;
+               }
+
+       }
+       return 0;
+}
+/*
+static const struct si2165_fw_block fw_data = {
+  .addr = 0x00c0,
+  .reg368_3 = 0x00,
+  .reg368_4 = 0x90,
+  .len = 4,
+  .data = { 0xf0, 0x04, 0x00, 0x00 }
+};
+*/
+
+static int si2165_upload_firmware(struct si2165_state *state)
+{
+	int ret;
+	u8 val[3];
+	const struct firmware *fw = NULL;
+	u8 *fw_file = SI2165_FIRMWARE;
+
+	/* request the firmware, this will block and timeout */
+	ret = request_firmware(&fw, fw_file, state->i2c->dev.parent);
+	if (ret) {
+		dev_err(&state->i2c->dev, "%s: firmare file '%s' not found\n",
+				KBUILD_MODNAME, fw_file);
+		goto err;
+	}
+
+	dev_info(&state->i2c->dev, "%s: downloading firmware from file '%s' site=%d\n",
+			KBUILD_MODNAME, fw_file, fw->size);
+
+	
+	si2165_writereg1(state, 0x00cb, 0x00);
+	si2165_writereg1(state, 0x0344, 0x00);
+	si2165_writereg4(state, 0x0348, 0x00, 0x00, 0x00, 0xf4);
+	si2165_readreg1(state, 0x0341, val); /* returned 0x01 */
+	si2165_writereg1(state, 0x0341, 0x00); // clear bit 0x01
+	
+	si2165_writereg1(state, 0x00c0, 0x00);
+	si2165_readreg1(state, 0x0341, val); /* returned 0x01 */
+	si2165_readreg1(state, 0x035c, val); /* returned 0x03 */
+	si2165_readreg1(state, 0x035c, val); /* returned 0x03 */
+	si2165_writereg1(state, 0x035c, 0x02); // clear bit 0x01
+
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x00, 0x00, 0x00, 0x90);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x04, 0x00, 0x00);
+	
+	si2165_writereg1(state, 0x0344, 0x9a);
+	si2165_writereg1(state, 0x0379, 0x01);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x00, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x5c, 0x16, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x38, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0xb0, 0x15, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x50, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x04, 0x15, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x58, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x58, 0x15, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x60, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x28, 0x0d, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x90, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0xd4, 0x09, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x9c, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x6c, 0x0b, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xb8, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x2c, 0x15, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x48, 0x14, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xdc, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0xc4, 0x03, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x01, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xf4, 0x00, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0xe8, 0x15, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0xec, 0x06, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x68, 0x01, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0xa0, 0x16, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xf0, 0x01, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x40, 0x40, 0x80, 0x80);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x24, 0x02, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x4a, 0x01);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x34, 0x02, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x12, 0x46, 0x0b, 0x70);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x4c, 0x02, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x14, 0x4e, 0x0d, 0x80);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x64, 0x02, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x16, 0x58, 0x0f, 0x95);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x9c, 0x02, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x00, 0x03, 0x02, 0x40);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x03, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x06, 0xd0);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x20, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x10, 0x60, 0x06, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf5, 0x7f, 0x00, 0x94);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x61, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0x1c, 0x60, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xb0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x03, 0x60, 0x2a, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x0b, 0xc0, 0x23, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x0b, 0xc0, 0x03, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x02, 0x92);
+	si2165_writereg4(state, 0x036c, 0x02, 0x60, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xfb, 0xff, 0xbf, 0x04);
+	si2165_writereg4(state, 0x036c, 0x04, 0x60, 0x23, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x05, 0xa0, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0x2c, 0xa3);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0xa6, 0x80);
+	si2165_writereg4(state, 0x036c, 0x14, 0x61, 0x26, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x04, 0x61, 0x26, 0xf0);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x02, 0xa0, 0x2a, 0xb1);
+	si2165_writereg4(state, 0x036c, 0x58, 0x60, 0x12, 0x82);
+	si2165_writereg4(state, 0x036c, 0x01, 0x00, 0x06, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x02, 0x60, 0x13, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x60, 0x61, 0x26, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x18, 0x40, 0x10, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x20, 0xa1, 0x02, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x11);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x12, 0xb0);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x19, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0xc4, 0x20, 0x06, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0xc2, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x2a, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x33, 0x93);
+	si2165_writereg4(state, 0x036c, 0x1c, 0x21, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x19, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xc3, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x24, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x21, 0x06, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x23);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x80, 0x12);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x04, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x1c, 0x96);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0xff, 0x3f, 0x60, 0x90);
+	si2165_writereg4(state, 0x036c, 0x16, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x2a, 0xa1);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0x40, 0x60, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x02, 0x60, 0x2a, 0x83);
+	si2165_writereg4(state, 0x036c, 0x01, 0xc0, 0x02, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x03, 0x00, 0x80, 0x08);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x02, 0x92);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x02, 0x60, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xfa, 0xff, 0xbf, 0x04);
+	si2165_writereg4(state, 0x036c, 0x02, 0x60, 0x2a, 0x83);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x23);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0x14, 0x92);
+	si2165_writereg4(state, 0x036c, 0xdc, 0x21, 0x26, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xcc, 0x60, 0x02, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x80, 0xc2, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xe6, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0x14, 0x82);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x21, 0x26, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xc4, 0x60, 0x00, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0xc4, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x2a, 0xa1);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x34, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0xdc, 0x66, 0x23, 0xde);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0xe1, 0x21, 0x2e, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x90, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x82);
+	si2165_writereg4(state, 0x036c, 0x19, 0x40, 0x28, 0xaf);
+	si2165_writereg4(state, 0x036c, 0xfc, 0x7f, 0x06, 0x82);
+	si2165_writereg4(state, 0x036c, 0x19, 0x00, 0x10, 0xac);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x4c, 0xa0, 0x27, 0xf4);
+	si2165_writereg4(state, 0x036c, 0x54, 0xa0, 0x27, 0xf8);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x2e, 0xa1);
+	si2165_writereg4(state, 0x036c, 0x1d, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xaa);
+	si2165_writereg4(state, 0x036c, 0xf4, 0xbf, 0x27, 0xc2);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xbf, 0x27, 0xee);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0xb2);
+	si2165_writereg4(state, 0x036c, 0xf4, 0xbf, 0x07, 0xf0);
+	si2165_writereg4(state, 0x036c, 0x04, 0xa0, 0xa5, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xa6);
+	si2165_writereg4(state, 0x036c, 0x03, 0x00, 0x80, 0x14);
+	si2165_writereg4(state, 0x036c, 0x18, 0x40, 0x2e, 0x95);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x94);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x05, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa5, 0x80);
+	si2165_writereg4(state, 0x036c, 0x44, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x4c, 0xa0, 0x07, 0xf2);
+	si2165_writereg4(state, 0x036c, 0x17, 0x40, 0x06, 0xb6);
+	si2165_writereg4(state, 0x036c, 0x1b, 0x40, 0xa6, 0x80);
+	si2165_writereg4(state, 0x036c, 0x23, 0x00, 0x80, 0x16);
+	si2165_writereg4(state, 0x036c, 0x19, 0x00, 0x10, 0x82);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0x00, 0x3b);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xbf, 0x07, 0xf8);
+	si2165_writereg4(state, 0x036c, 0x04, 0x62, 0x17, 0xa8);
+	si2165_writereg4(state, 0x036c, 0x1c, 0x40, 0x06, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x28, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0x03, 0x92);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x0a, 0xf2);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0x0b, 0xf0);
+	si2165_writereg4(state, 0x036c, 0x18, 0x60, 0x2e, 0xb7);
+	si2165_writereg4(state, 0x036c, 0x18, 0x20, 0x2e, 0xb9);
+	si2165_writereg4(state, 0x036c, 0x18, 0x20, 0x3f, 0xb1);
+	si2165_writereg4(state, 0x036c, 0x18, 0xe0, 0x3e, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x5e, 0xba);
+	si2165_writereg4(state, 0x036c, 0x19, 0x40, 0x5e, 0xb2);
+	si2165_writereg4(state, 0x036c, 0x1d, 0x40, 0x06, 0xb4);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x10, 0xa0, 0x2e, 0x91);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x40, 0xb4);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x32, 0xbb);
+	si2165_writereg4(state, 0x036c, 0x1d, 0x00, 0xa5, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x40, 0xb0);
+	si2165_writereg4(state, 0x036c, 0x18, 0xe0, 0x3e, 0xb7);
+	si2165_writereg4(state, 0x036c, 0x18, 0x20, 0x3f, 0xb9);
+	si2165_writereg4(state, 0x036c, 0x18, 0x80, 0x8e, 0x80);
+	si2165_writereg4(state, 0x036c, 0x1f, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x34, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x2a, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0x2b, 0xc0);
+	si2165_writereg4(state, 0x036c, 0xff, 0xbf, 0x02, 0x94);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x00, 0x82);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x40, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0xe6, 0xff, 0xbf, 0x06);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x28, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x54, 0xa0, 0x07, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x80, 0x22);
+	si2165_writereg4(state, 0x036c, 0x2c, 0xe1, 0x22, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x2c, 0xe1, 0x02, 0xf2);
+	si2165_writereg4(state, 0x036c, 0x34, 0xe1, 0x02, 0xf4);
+	si2165_writereg4(state, 0x036c, 0x24, 0xe1, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x11, 0x40, 0x06, 0xba);
+	si2165_writereg4(state, 0x036c, 0x12, 0x80, 0x06, 0xb8);
+	si2165_writereg4(state, 0x036c, 0x13, 0x40, 0x00, 0xb6);
+	si2165_writereg4(state, 0x036c, 0x2c, 0xe1, 0x22, 0xfa);
+	si2165_writereg4(state, 0x036c, 0x34, 0xe1, 0x22, 0xf8);
+	si2165_writereg4(state, 0x036c, 0x24, 0xe1, 0x22, 0xf6);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x05, 0xaa);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa5, 0x80);
+	si2165_writereg4(state, 0x036c, 0xc0, 0xff, 0xbf, 0x04);
+	si2165_writereg4(state, 0x036c, 0x04, 0xe0, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x34, 0xb1);
+	si2165_writereg4(state, 0x036c, 0x34, 0xe1, 0x22, 0xe4);
+	si2165_writereg4(state, 0x036c, 0xf9, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x24, 0xe1, 0x22, 0xe6);
+	si2165_writereg4(state, 0x036c, 0x19, 0x40, 0xa7, 0x80);
+	si2165_writereg4(state, 0x036c, 0x1b, 0x40, 0x04, 0xa2);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x06, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x1c, 0x80, 0x04, 0xa4);
+	si2165_writereg4(state, 0x036c, 0xe3, 0xff, 0xbf, 0x08);
+	si2165_writereg4(state, 0x036c, 0x1d, 0xc0, 0x04, 0xa6);
+	si2165_writereg4(state, 0x036c, 0xe1, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x16, 0x40, 0x2d, 0xb5);
+	si2165_writereg4(state, 0x036c, 0xbd, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x40, 0x06, 0xb2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x78, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0xc2, 0x61, 0x08, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x40, 0x26, 0x82);
+	si2165_writereg4(state, 0x036c, 0xe1, 0xa1, 0x0e, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x00, 0xa8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x40, 0xa0, 0x07, 0xf0);
+	si2165_writereg4(state, 0x036c, 0xff, 0x3f, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0xe1, 0xa1, 0x2e, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x28, 0xa1, 0x26, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x24, 0xa1, 0x26, 0xc0);
+	si2165_writereg4(state, 0x036c, 0xe8, 0xbf, 0x07, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x08, 0x20, 0x26, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xe4, 0xbf, 0x27, 0xc0);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xbf, 0x27, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x26, 0xc0);
+	si2165_writereg4(state, 0x036c, 0xa4, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x04, 0x20, 0x26, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x04, 0xa1, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x97, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0xff, 0x7f, 0x06, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x27);
+	si2165_writereg4(state, 0x036c, 0x38, 0xe0, 0x04, 0xda);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x7e, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0xfe, 0x7f, 0x06, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x12, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x7c, 0xff, 0xff, 0x7f);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x38, 0xe0, 0x24, 0xde);
+	si2165_writereg4(state, 0x036c, 0x28, 0xa1, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x24, 0xa1, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x3b, 0xa5);
+	si2165_writereg4(state, 0x036c, 0x11, 0x40, 0x38, 0xa7);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xa1, 0x0e, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x24, 0xa1, 0x26, 0xe6);
+	si2165_writereg4(state, 0x036c, 0x28, 0xa1, 0x26, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x55, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0xe4, 0xa1, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x2a, 0x9b);
+	si2165_writereg4(state, 0x036c, 0x10, 0x60, 0x33, 0xa5);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x1f);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x07, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x40, 0xe0, 0x13, 0x90);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x2b, 0x9b);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x00, 0x22, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x1c, 0xa0, 0x12, 0x92);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x2b, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x24, 0xa1, 0x06, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x19, 0x40, 0x22, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x09, 0x40, 0x06, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x28, 0xa1, 0x06, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x04, 0x60, 0x24, 0xd6);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xa1, 0x0e, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x02, 0xa0);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xa1, 0x2e, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x27);
+	si2165_writereg4(state, 0x036c, 0xcb, 0xe1, 0x0c, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0xa4);
+	si2165_writereg4(state, 0x036c, 0xff, 0x20, 0x0c, 0x96);
+	si2165_writereg4(state, 0x036c, 0x08, 0x80, 0x2c, 0x99);
+	si2165_writereg4(state, 0x036c, 0x0c, 0xc0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x27, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x21);
+	si2165_writereg4(state, 0x036c, 0x28, 0xa1, 0x06, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x24, 0xa1, 0x06, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x80, 0x04, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x30, 0xa1, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x01, 0xe0, 0x3b, 0x93);
+	si2165_writereg4(state, 0x036c, 0x2c, 0xa1, 0x06, 0xf2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x14, 0xa4);
+	si2165_writereg4(state, 0x036c, 0xe4, 0xbf, 0x27, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x40, 0x06, 0x90);
+	si2165_writereg4(state, 0x036c, 0x14, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x3f, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x4c, 0xa1, 0x04, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0xc4, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x38, 0xa1, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0x34, 0xa1, 0x06, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0x82);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x80, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x14, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0xf1, 0xbf, 0x2f, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x3f, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x4c, 0xa1, 0x04, 0xe6);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0xc4, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xbf, 0x2f, 0xd0);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xbf, 0x17, 0xd6);
+	si2165_writereg4(state, 0x036c, 0xd8, 0xbf, 0x37, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x34, 0xa1, 0x04, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xc3, 0x9f);
+	si2165_writereg4(state, 0x036c, 0xd8, 0xbf, 0x07, 0x90);
+	si2165_writereg4(state, 0x036c, 0xe4, 0xbf, 0x07, 0xf4);
+	si2165_writereg4(state, 0x036c, 0xe8, 0xbf, 0x07, 0xe8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x26, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x04, 0x20, 0x26, 0xf4);
+	si2165_writereg4(state, 0x036c, 0x08, 0x20, 0x26, 0xe8);
+	si2165_writereg4(state, 0x036c, 0x49, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xbf, 0x27, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x10, 0xa0, 0x06, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x06, 0xa0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x80, 0x22);
+	si2165_writereg4(state, 0x036c, 0x04, 0xa1, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x40, 0xe0, 0x13, 0xb2);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x08, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x21);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x40, 0x06, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x14, 0x9e);
+	si2165_writereg4(state, 0x036c, 0xdc, 0xa1, 0x26, 0xe2);
+	si2165_writereg4(state, 0x036c, 0xcc, 0xe0, 0x03, 0xda);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0xc3, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xcf, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xa1, 0x2e, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf6, 0xff, 0xbf, 0x12);
+	si2165_writereg4(state, 0x036c, 0x40, 0xe0, 0x13, 0xb2);
+	si2165_writereg4(state, 0x036c, 0xec, 0xfe, 0xff, 0x7f);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xc8, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xa1, 0x2e, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x1f);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x2a, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x2b, 0x9b);
+	si2165_writereg4(state, 0x036c, 0x40, 0xe0, 0x13, 0x94);
+	si2165_writereg4(state, 0x036c, 0x10, 0x60, 0x36, 0xa3);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x80, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x11, 0x40, 0x00, 0xa6);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x2b, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x80, 0x22, 0xe6);
+	si2165_writereg4(state, 0x036c, 0x1c, 0x60, 0x12, 0x96);
+	si2165_writereg4(state, 0x036c, 0x19, 0xc0, 0x02, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x24, 0xa1, 0x06, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x08, 0x80, 0x04, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x19, 0xc0, 0x22, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x40, 0x06, 0xa6);
+	si2165_writereg4(state, 0x036c, 0x04, 0xe0, 0x04, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x28, 0xa1, 0x06, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x03, 0x82);
+	si2165_writereg4(state, 0x036c, 0xa8, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x04, 0xe0, 0x24, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x00, 0xff, 0xff, 0x7f);
+	si2165_writereg4(state, 0x036c, 0x12, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x10, 0xa0, 0x2a, 0x91);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x32, 0x97);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0xb2);
+	si2165_writereg4(state, 0x036c, 0x11, 0x40, 0x2e, 0x95);
+	si2165_writereg4(state, 0x036c, 0x12, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0xf6, 0xfe, 0xff, 0x7f);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x7c, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x38, 0xe0, 0x24, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x12, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0xec, 0xfe, 0xff, 0x7f);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x9a);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x09, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x73, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x0c, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x60, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x54, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0xf5, 0x7f, 0x00, 0xa2);
+	si2165_writereg4(state, 0x036c, 0xe2, 0x21, 0x0e, 0xd6);
+	si2165_writereg4(state, 0x036c, 0xfe, 0xff, 0x02, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1f);
+	si2165_writereg4(state, 0x036c, 0x18, 0xa0, 0x2a, 0x9b);
+	si2165_writereg4(state, 0x036c, 0xc8, 0xe1, 0x13, 0x96);
+	si2165_writereg4(state, 0x036c, 0x18, 0x60, 0x3b, 0x91);
+	si2165_writereg4(state, 0x036c, 0x01, 0xe0, 0x0a, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x02, 0x00, 0x80, 0x26);
+	si2165_writereg4(state, 0x036c, 0x01, 0xe0, 0x0a, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x18, 0xa0, 0x2a, 0x99);
+	si2165_writereg4(state, 0x036c, 0x18, 0x20, 0x3b, 0x93);
+	si2165_writereg4(state, 0x036c, 0xe3, 0x21, 0x4e, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x10, 0x40, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x80, 0x22);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0xe3, 0x21, 0x2e, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x21, 0x2e, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x1c, 0xa0, 0x12, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x2b, 0x95);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x80, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x40, 0x03, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x04, 0x20, 0x02, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x09, 0xc0, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0x0f, 0xc0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x80, 0x28);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x03, 0x98);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x03, 0x98);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf5, 0xff, 0xbf, 0x04);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x2b, 0x95);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x21, 0x0e, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x1b);
+	si2165_writereg4(state, 0x036c, 0xff, 0x60, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x50, 0x60, 0x23, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x02, 0x9e);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x21, 0x2e, 0xde);
+	si2165_writereg4(state, 0x036c, 0xf1, 0x21, 0x0e, 0xd0);
+	si2165_writereg4(state, 0x036c, 0xff, 0x20, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x60, 0x18, 0x94);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0xf1, 0x21, 0x2e, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x60, 0x96);
+	si2165_writereg4(state, 0x036c, 0x02, 0xe0, 0x0a, 0x9a);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x0a, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x38, 0x20, 0x06, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x03, 0x96);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x40, 0x3a, 0x9b);
+	si2165_writereg4(state, 0x036c, 0x44, 0x20, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x00, 0x23, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1f);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x2c, 0x99);
+	si2165_writereg4(state, 0x036c, 0xa0, 0xe2, 0x13, 0x92);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x3a, 0xa3);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x40, 0x12, 0xde);
+	si2165_writereg4(state, 0x036c, 0x84, 0x20, 0x26, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x15, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x40, 0x04, 0x96);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x80, 0x32);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x19);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0xd0, 0xa1, 0x12, 0x92);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x40, 0x12, 0xde);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x0f, 0xc0, 0x22, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x23);
+	si2165_writereg4(state, 0x036c, 0xd0, 0x61, 0x14, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x14, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x01, 0xc0, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0xc9, 0x61, 0x0a, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xbe, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0xe3, 0x21, 0x2e, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x19);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x24, 0x21, 0x03, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x0d, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0xc0, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x28, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x59, 0x00, 0x80, 0x22);
+	si2165_writereg4(state, 0x036c, 0x99, 0x20, 0x0e, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1b);
+	si2165_writereg4(state, 0x036c, 0x99, 0x62, 0x0b, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x96, 0x20, 0x16, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x80, 0x3a, 0x99);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x13, 0xde);
+	si2165_writereg4(state, 0x036c, 0x94, 0x20, 0x16, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x4d, 0x00, 0x80, 0x04);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x94, 0x20, 0x36, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x9b, 0x62, 0x0a, 0xde);
+	si2165_writereg4(state, 0x036c, 0xcf, 0x20, 0x0e, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x80, 0x2a);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x0b, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0xa4, 0x20, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x02, 0x00, 0x80, 0x32);
+	si2165_writereg4(state, 0x036c, 0xa4, 0x20, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x60, 0x03, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xf5, 0xbf, 0x02, 0x92);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x3b, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x09, 0xc0, 0x3b, 0x99);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1f);
+	si2165_writereg4(state, 0x036c, 0xc0, 0xe2, 0x13, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0xb8, 0xa2, 0x12, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x09, 0xc0, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0xe0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x04);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0xff, 0x3f, 0x4a, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x02, 0x00, 0x80, 0x26);
+	si2165_writereg4(state, 0x036c, 0xff, 0xff, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0x03, 0xa0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x07, 0x00, 0x80, 0x14);
+	si2165_writereg4(state, 0x036c, 0x0a, 0xc0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x0a, 0xc0, 0x4b, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x02, 0x00, 0x80, 0x34);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0x02, 0x96);
+	si2165_writereg4(state, 0x036c, 0x0a, 0xc0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf1, 0xff, 0xbf, 0x12);
+	si2165_writereg4(state, 0x036c, 0x09, 0xc0, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x96, 0x62, 0x12, 0x94);
+	si2165_writereg4(state, 0x036c, 0x07, 0xa0, 0x0a, 0xde);
+	si2165_writereg4(state, 0x036c, 0x0f, 0xc0, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x13, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x1a);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x13, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x07, 0xa0, 0x0a, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x22, 0x96);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x98, 0x20, 0x2e, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x99, 0x20, 0x2e, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x2c, 0x20, 0x06, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x02, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x08, 0xa0, 0x8a, 0x80);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x02, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x08, 0x20, 0x8b, 0x80);
+	si2165_writereg4(state, 0x036c, 0x23, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x98, 0x20, 0x0e, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x13, 0xf0);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0xa6, 0x80);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x80, 0x0a);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x1c, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x33, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x19, 0x00, 0x80, 0x30);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x13, 0xde);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x0c, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0xf2, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x98, 0x20, 0x2e, 0xde);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0xea, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x99, 0x20, 0x2e, 0xd6);
+	si2165_writereg4(state, 0x036c, 0xb6, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xa9, 0xff, 0xbf, 0x12);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1b);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x34, 0xa0, 0x02, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0xc2, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x05, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x2c, 0x20, 0x06, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x08, 0x60, 0x88, 0x80);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x98, 0x20, 0x0e, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x34, 0x27, 0x33, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x60, 0x03, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xa9, 0x21, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x2c, 0x20, 0x06, 0xde);
+	si2165_writereg4(state, 0x036c, 0xf5, 0xbf, 0x02, 0x82);
+	si2165_writereg4(state, 0x036c, 0x57, 0x2e, 0x03, 0x96);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0x03, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x00, 0x2b, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x18, 0xe0, 0x12, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x24, 0x8a, 0x80);
+	si2165_writereg4(state, 0x036c, 0x01, 0x80, 0x2a, 0x97);
+	si2165_writereg4(state, 0x036c, 0x18, 0x68, 0x03, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x23, 0x00, 0x80, 0x32);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x06, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x20, 0x06, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x20, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0x3a, 0x93);
+	si2165_writereg4(state, 0x036c, 0x05, 0x60, 0x38, 0x95);
+	si2165_writereg4(state, 0x036c, 0x38, 0x20, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x40, 0x22, 0x90);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0x38, 0x95);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0x22, 0x82);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x40, 0x00, 0x94);
+	si2165_writereg4(state, 0x036c, 0x50, 0xbf, 0x02, 0x82);
+	si2165_writereg4(state, 0x036c, 0x0f, 0xc0, 0x02, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x40, 0x70, 0x94);
+	si2165_writereg4(state, 0x036c, 0xa0, 0x60, 0x02, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x80, 0x5a, 0x92);
+	si2165_writereg4(state, 0x036c, 0x09, 0x40, 0x20, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x0d, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x0c, 0xc0, 0x73, 0x92);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x40, 0x5a, 0x82);
+	si2165_writereg4(state, 0x036c, 0x1c, 0x68, 0x23, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xa0, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x20, 0x68, 0x23, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x01, 0xc0, 0x23, 0x92);
+	si2165_writereg4(state, 0x036c, 0x24, 0x68, 0x23, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x24, 0x68, 0x03, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x28, 0x68, 0x23, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x06, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x24, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x2e, 0x00, 0x80, 0x0a);
+	si2165_writereg4(state, 0x036c, 0x06, 0x20, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x2c, 0x00, 0x80, 0x18);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x04, 0x68, 0x23, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1f);
+	si2165_writereg4(state, 0x036c, 0xdb, 0xe1, 0x0b, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x8c, 0x20, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x60, 0x20, 0x06, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x0a, 0xc0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x80, 0x18);
+	si2165_writereg4(state, 0x036c, 0xfe, 0x7f, 0x08, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0xdc, 0xa1, 0x0a, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x00, 0x20, 0x98);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x40, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0x80, 0x16);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xdc, 0xa1, 0x0a, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x13, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x98, 0x20, 0x2e, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0x20, 0x92);
+	si2165_writereg4(state, 0x036c, 0x14, 0x68, 0x23, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x90, 0x20, 0x26, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x16, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x8c, 0x20, 0x26, 0xc0);
+	si2165_writereg4(state, 0x036c, 0xdc, 0xa1, 0x0a, 0xde);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x40, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xfa, 0xff, 0xbf, 0x04);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xdc, 0xa1, 0x0a, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x34, 0x67, 0x13, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xf6, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x98, 0x20, 0x2e, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x04, 0x68, 0x23, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x34, 0x60, 0x02, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xc3, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0xcc, 0x61, 0x0b, 0xde);
+	si2165_writereg4(state, 0x036c, 0x02, 0xe0, 0x13, 0x96);
+	si2165_writereg4(state, 0x036c, 0xcc, 0x61, 0x2b, 0xd6);
+	si2165_writereg4(state, 0x036c, 0xd8, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0xa0, 0xbd, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x13);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x0e, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x04, 0x61, 0x02, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0xc2, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x42, 0x26, 0x0e, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x02, 0xa0, 0x14, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x42, 0x26, 0x2e, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x12, 0x20, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x74, 0x23, 0x26, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x70, 0x23, 0x26, 0xde);
+	si2165_writereg4(state, 0x036c, 0x42, 0x23, 0x0e, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0x12, 0x82);
+	si2165_writereg4(state, 0x036c, 0x42, 0x23, 0x2e, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x3c, 0x1b);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0x13, 0x82);
+	si2165_writereg4(state, 0x036c, 0x50, 0x63, 0x00, 0xd0);
+	si2165_writereg4(state, 0x036c, 0xb0, 0x63, 0x20, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x84, 0x63, 0x00, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x20, 0x33, 0x93);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x17);
+	si2165_writereg4(state, 0x036c, 0xf5, 0xe1, 0x2a, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0xbe, 0x27, 0xc2);
+	si2165_writereg4(state, 0x036c, 0xf7, 0x09, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x00, 0xbe, 0x07, 0x90);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x25);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x23);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x3f, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x22, 0x26, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x64, 0xa0, 0x14, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x19, 0x00, 0x00, 0x40);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xf4, 0x22, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x10, 0x01, 0x00, 0x40);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x22, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x61, 0x04, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x73, 0x00, 0x00, 0x40);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x22, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0xfc, 0xff, 0xbf, 0x02);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x61, 0x04, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xec, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0xce, 0xa0, 0x2a, 0xe0);
+	si2165_writereg4(state, 0x036c, 0xf4, 0x22, 0x06, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x47, 0x00, 0x00, 0x40);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0xf1, 0xff, 0xbf, 0x30);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x3b);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x61, 0x17, 0xb8);
+	si2165_writereg4(state, 0x036c, 0x34, 0x20, 0x17, 0xfa);
+	si2165_writereg4(state, 0x036c, 0x02, 0x60, 0x2f, 0xb7);
+	si2165_writereg4(state, 0x036c, 0x1d, 0xc0, 0x06, 0x82);
+	si2165_writereg4(state, 0x036c, 0x03, 0x60, 0x28, 0xb7);
+	si2165_writereg4(state, 0x036c, 0x1d, 0xc0, 0x26, 0xb2);
+	si2165_writereg4(state, 0x036c, 0x3a, 0x20, 0x17, 0xf6);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x0f, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x1b, 0x40, 0x76, 0x82);
+	si2165_writereg4(state, 0x036c, 0x38, 0x20, 0x17, 0xf2);
+	si2165_writereg4(state, 0x036c, 0x05, 0x60, 0x00, 0xb8);
+	si2165_writereg4(state, 0x036c, 0x1c, 0xc0, 0x5e, 0x82);
+	si2165_writereg4(state, 0x036c, 0x08, 0x60, 0x2e, 0xb9);
+	si2165_writereg4(state, 0x036c, 0xe8, 0xe3, 0x5e, 0xb4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x1c, 0x80, 0x76, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x33);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x1d, 0x40, 0x70, 0x82);
+	si2165_writereg4(state, 0x036c, 0x56, 0x60, 0x36, 0xde);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x2b, 0xbb);
+	si2165_writereg4(state, 0x036c, 0x6b, 0xe3, 0x5e, 0xb6);
+	si2165_writereg4(state, 0x036c, 0xff, 0x60, 0x08, 0xb4);
+	si2165_writereg4(state, 0x036c, 0x11, 0x60, 0x37, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x1c, 0xc0, 0x76, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x19, 0x80, 0x06, 0xb4);
+	si2165_writereg4(state, 0x036c, 0x1a, 0xc0, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x1a);
+	si2165_writereg4(state, 0x036c, 0x10, 0x60, 0x37, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x19, 0xc0, 0x03, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x1a, 0xc0, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0xff, 0xff, 0xbf, 0x2a);
+	si2165_writereg4(state, 0x036c, 0x19, 0xc0, 0x03, 0x9e);
+	si2165_writereg4(state, 0x036c, 0xff, 0x60, 0x08, 0xba);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x2e, 0xb7);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x36, 0xb3);
+	si2165_writereg4(state, 0x036c, 0x1d, 0xc0, 0x23, 0xb8);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x35);
+	si2165_writereg4(state, 0x036c, 0x1c, 0xa2, 0x16, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x42, 0x6f, 0x5e, 0xba);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x01, 0x40, 0x77, 0xb2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x31);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x35);
+	si2165_writereg4(state, 0x036c, 0x12, 0x20, 0x36, 0xf8);
+	si2165_writereg4(state, 0x036c, 0x54, 0xa0, 0x36, 0xf2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x20, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf8, 0x60, 0x22, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x30, 0x62, 0x32, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x7e, 0x62, 0x32, 0xc0);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x10, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x11);
+	si2165_writereg4(state, 0x036c, 0x4e, 0x62, 0x32, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x54, 0x20, 0x12, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x67, 0x62, 0x0a, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x7f, 0x08, 0x90);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x54, 0xa0, 0x12, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x30, 0xe2, 0x32, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x28, 0x99);
+	si2165_writereg4(state, 0x036c, 0x01, 0x00, 0x03, 0x92);
+	si2165_writereg4(state, 0x036c, 0x9d, 0x21, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x7e, 0xe2, 0x32, 0xd0);
+	si2165_writereg4(state, 0x036c, 0xeb, 0x21, 0x10, 0x82);
+	si2165_writereg4(state, 0x036c, 0x4e, 0xe2, 0x32, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x32, 0x99);
+	si2165_writereg4(state, 0x036c, 0x67, 0xe2, 0x0a, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x7f, 0x0a, 0x82);
+	si2165_writereg4(state, 0x036c, 0x06, 0x60, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x67, 0xe2, 0x2a, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x2b, 0x93);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x17);
+	si2165_writereg4(state, 0x036c, 0x10, 0x60, 0x32, 0x91);
+	si2165_writereg4(state, 0x036c, 0x18, 0xa0, 0x22, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc3, 0x81);
+	si2165_writereg4(state, 0x036c, 0x26, 0xe2, 0x32, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x08, 0x21, 0x04, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0xc0, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x23);
+	si2165_writereg4(state, 0x036c, 0x18, 0x60, 0x04, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x43, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x35, 0x00, 0x80, 0x0a);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x6e, 0x0f, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x19);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x21, 0x13, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x14, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x40, 0x24, 0x06, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x00, 0xe0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x7e, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x34, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x25);
+	si2165_writereg4(state, 0x036c, 0x63, 0x0f, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x34, 0xa0, 0x0c, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x14, 0xe6);
+	si2165_writereg4(state, 0x036c, 0x34, 0xa0, 0x0c, 0xda);
+	si2165_writereg4(state, 0x036c, 0x0d, 0xc0, 0x04, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x40, 0x24, 0x06, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x74, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x34, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x31);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x11, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x70, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x18, 0x20, 0x26, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xf8, 0x20, 0x06, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x40, 0x01, 0x00, 0x40);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x40, 0x24, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x0e, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x27);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x22, 0x16, 0xda);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x65, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x14, 0x60, 0x12, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x1f);
+	si2165_writereg4(state, 0x036c, 0x4e, 0x22, 0x36, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x4c, 0xe0, 0x0b, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x18, 0x60, 0x24, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xc8, 0x20, 0x2e, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x5c, 0x00, 0x80, 0x30);
+	si2165_writereg4(state, 0x036c, 0x14, 0xe0, 0x14, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x21);
+	si2165_writereg4(state, 0x036c, 0x4e, 0x22, 0x36, 0xe4);
+	si2165_writereg4(state, 0x036c, 0x4c, 0x20, 0x0c, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xf9, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x3d, 0x0f, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x61, 0x12, 0x96);
+	si2165_writereg4(state, 0x036c, 0x42, 0xe0, 0x12, 0xda);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x22, 0x16, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x03, 0x98);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x4d, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x42, 0xe0, 0x32, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x4b, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x18, 0x60, 0x24, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0x10, 0xa6);
+	si2165_writereg4(state, 0x036c, 0xe4, 0xa1, 0x12, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x2d, 0x0f, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x05, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x14, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x05, 0xe0, 0x02, 0x82);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x34, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe1, 0x04, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xc2, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x22, 0x16, 0xde);
+	si2165_writereg4(state, 0x036c, 0x00, 0xe0, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x02, 0x00, 0x80, 0x22);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0xa4);
+	si2165_writereg4(state, 0x036c, 0xff, 0x3f, 0x84, 0xa0);
+	si2165_writereg4(state, 0x036c, 0xf3, 0xff, 0xbf, 0x1c);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x35, 0x00, 0x80, 0x22);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x21);
+	si2165_writereg4(state, 0x036c, 0x40, 0x24, 0x06, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0xc1, 0xff, 0xbf, 0x12);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x10, 0x92);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x12, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0xf8, 0x20, 0x06, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x20, 0x1c, 0x96);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x00, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x40, 0xa6);
+	si2165_writereg4(state, 0x036c, 0x08, 0x20, 0x1c, 0x94);
+	si2165_writereg4(state, 0x036c, 0x4e, 0x22, 0x16, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x40, 0xa4);
+	si2165_writereg4(state, 0x036c, 0xc8, 0x20, 0x0e, 0xde);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x19);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x1b);
+	si2165_writereg4(state, 0x036c, 0x18, 0x60, 0x20, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x14, 0x20, 0x33, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x12, 0xc0, 0x8c, 0x80);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x4c, 0x60, 0x2b, 0xde);
+	si2165_writereg4(state, 0x036c, 0xc8, 0x20, 0x2e, 0xc0);
+	si2165_writereg4(state, 0x036c, 0xff, 0x3f, 0x10, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x4e, 0x22, 0x36, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x31);
+	si2165_writereg4(state, 0x036c, 0x66, 0x20, 0x0e, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x19);
+	si2165_writereg4(state, 0x036c, 0x07, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0x13, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x34, 0x20, 0x2b, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x34, 0x20, 0x0b, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x42, 0x6f, 0x5c, 0x82);
+	si2165_writereg4(state, 0x036c, 0x1c, 0xa2, 0x12, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x80, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x40, 0x70, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x12, 0x60, 0x12, 0xda);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x27);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x25);
+	si2165_writereg4(state, 0x036c, 0x34, 0x20, 0x2b, 0xde);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x34, 0xda);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x3c, 0xa0, 0x2c, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x2a, 0xa1);
+	si2165_writereg4(state, 0x036c, 0xee, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0x34, 0x20, 0x2b, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x18, 0x20, 0x24, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x61, 0x10, 0xa6);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0x13, 0x00, 0x10, 0xb4);
+	si2165_writereg4(state, 0x036c, 0x80, 0x62, 0x10, 0xb2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x2f);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x3f, 0x10, 0xaa);
+	si2165_writereg4(state, 0x036c, 0x13, 0x00, 0x10, 0xac);
+	si2165_writereg4(state, 0x036c, 0x03, 0x20, 0x10, 0xa8);
+	si2165_writereg4(state, 0x036c, 0x12, 0x40, 0x0e, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x3a, 0xff, 0xff, 0x7f);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x13, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x10, 0x20, 0x2a, 0x95);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xe1, 0x05, 0xd6);
+	si2165_writereg4(state, 0x036c, 0xce, 0xe0, 0x2a, 0xea);
+	si2165_writereg4(state, 0x036c, 0x10, 0xa0, 0x32, 0xa3);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x24, 0x06, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x56, 0xff, 0xff, 0x7f);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x24, 0x06, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0xff, 0x20, 0x0c, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x42, 0xe0, 0x14, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf7, 0xff, 0xbf, 0x0a);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xe0, 0x24, 0x06, 0xda);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0x04, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x04, 0xa0, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0xe9, 0xff, 0xbf, 0x04);
+	si2165_writereg4(state, 0x036c, 0x4b, 0xa0, 0x2d, 0xe8);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x80, 0x30);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x4b, 0xa0, 0x2e, 0xde);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0xa4, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf1, 0xff, 0xbf, 0x32);
+	si2165_writereg4(state, 0x036c, 0x42, 0xe0, 0x14, 0xd8);
+	si2165_writereg4(state, 0x036c, 0xf2, 0xff, 0xbf, 0x30);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x78, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0xd6, 0xa1, 0x0a, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x09, 0x80, 0x26, 0x82);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x00, 0xb4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0xe0, 0xbf, 0x3f, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0x10, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xb0);
+	si2165_writereg4(state, 0x036c, 0xf8, 0xbf, 0x07, 0xa8);
+	si2165_writereg4(state, 0x036c, 0xd8, 0xbf, 0x07, 0xa6);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x2e, 0xa1);
+	si2165_writereg4(state, 0x036c, 0x1b, 0x00, 0x04, 0xa2);
+	si2165_writereg4(state, 0x036c, 0x4c, 0xa1, 0x04, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x3f, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xc3, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x2c, 0x61, 0x04, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x34, 0x61, 0x04, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xf1, 0xbf, 0x2f, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x3f, 0x20, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x4c, 0xa1, 0x04, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0xc0, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xbf, 0x2f, 0xd0);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xbf, 0x17, 0xde);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x14, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0xd8, 0xbf, 0x37, 0xde);
+	si2165_writereg4(state, 0x036c, 0x34, 0xa1, 0x04, 0xda);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0xc3, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x13, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x14, 0x00, 0x04, 0x96);
+	si2165_writereg4(state, 0x036c, 0x24, 0x61, 0x04, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x06, 0xb0);
+	si2165_writereg4(state, 0x036c, 0xe8, 0xff, 0x22, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0xa6, 0x80);
+	si2165_writereg4(state, 0x036c, 0xe6, 0xff, 0xbf, 0x04);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xff, 0x22, 0xd0);
+	si2165_writereg4(state, 0x036c, 0xec, 0xbf, 0x07, 0xe0);
+	si2165_writereg4(state, 0x036c, 0xe8, 0xbf, 0x07, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x11, 0x00, 0x24, 0xb0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x17, 0x08, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0x50, 0x60, 0x20, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0x38, 0x60, 0x20, 0xc0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0xcf, 0x60, 0x0a, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x02, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x3a, 0xa3, 0x12, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0x13, 0x82);
+	si2165_writereg4(state, 0x036c, 0x73, 0x02, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x2c, 0x20, 0x02, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x80, 0x60, 0x88, 0x80);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x08, 0x00, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x00, 0x80, 0x02, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x5c, 0x20, 0x12, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x06, 0xa7, 0x32, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x1c, 0xa3, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xf3, 0xa6, 0x0a, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0xf3, 0xa6, 0x2a, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x80, 0x30);
+	si2165_writereg4(state, 0x036c, 0xf3, 0xa6, 0x0a, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xfd, 0xff, 0xbf, 0x10);
+	si2165_writereg4(state, 0x036c, 0xfe, 0x7f, 0x0a, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc3, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0xf9, 0x26, 0x0b, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x08, 0xa0);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x15, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0xf3, 0x07, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xc2);
+	si2165_writereg4(state, 0x036c, 0xf9, 0x66, 0x08, 0xd6);
+	si2165_writereg4(state, 0x036c, 0xfe, 0xff, 0x0a, 0x94);
+	si2165_writereg4(state, 0x036c, 0x10, 0x80, 0x12, 0x92);
+	si2165_writereg4(state, 0x036c, 0xf9, 0x66, 0x28, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x88, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x06, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xf0, 0x60, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x0b, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x1a, 0x00, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x1b, 0x00, 0x10, 0x96);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x40, 0xa0, 0x07, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x03, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x02, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1f);
+	si2165_writereg4(state, 0x036c, 0xb8, 0xe1, 0x13, 0x98);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x2b, 0xd2);
+	si2165_writereg4(state, 0x036c, 0xe8, 0xbf, 0x07, 0x9a);
+	si2165_writereg4(state, 0x036c, 0x18, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x19, 0x00, 0x10, 0x92);
+	si2165_writereg4(state, 0x036c, 0x40, 0xa0, 0x23, 0xda);
+	si2165_writereg4(state, 0x036c, 0xa4, 0xfc, 0xff, 0x64);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0xec, 0xbf, 0x07, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xf0, 0xbf, 0x07, 0xc2);
+	si2165_writereg4(state, 0x036c, 0xe8, 0xbf, 0x07, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x24, 0xd6);
+	si2165_writereg4(state, 0x036c, 0x04, 0x20, 0x24, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x08, 0x20, 0x24, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x0c, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x10, 0x00, 0xe8, 0x91);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x3c, 0x03);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0x10, 0x94);
+	si2165_writereg4(state, 0x036c, 0x84, 0xa3, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x12);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0xec, 0xa0, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x05, 0x60, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0x13, 0x82);
+	si2165_writereg4(state, 0x036c, 0x9f, 0x19, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0x13, 0x82);
+	si2165_writereg4(state, 0x036c, 0x09, 0xfe, 0xff, 0x7f);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x02, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x50, 0x63, 0x02, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xb0, 0x63, 0x22, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x84, 0x63, 0x02, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x0f, 0x60, 0x30, 0x93);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x03);
+	si2165_writereg4(state, 0x036c, 0xf5, 0x61, 0x28, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0xc0, 0x13, 0x82);
+	
+	si2165_writereg4(state, 0x0364, 0x3f, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x16, 0x00, 0x60);
+	
+	si2165_writereg4(state, 0x036c, 0x0d, 0x08, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x00, 0x40, 0x10, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x98, 0xbf, 0xe3, 0x9d);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x20, 0x1e, 0x94);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x40, 0x92);
+	si2165_writereg4(state, 0x036c, 0x08, 0x20, 0x1e, 0x82);
+	si2165_writereg4(state, 0x036c, 0x01, 0x00, 0xa0, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x40, 0x82);
+	si2165_writereg4(state, 0x036c, 0x01, 0x40, 0x8a, 0x80);
+	si2165_writereg4(state, 0x036c, 0x3e, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x20, 0x10, 0x98);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x11);
+	si2165_writereg4(state, 0x036c, 0xf8, 0x60, 0x26, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x68, 0x20, 0x02, 0xd4);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x17);
+	si2165_writereg4(state, 0x036c, 0x10, 0xe0, 0x12, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xff, 0xff, 0xbf, 0x2a);
+	si2165_writereg4(state, 0x036c, 0x0a, 0x00, 0x02, 0x90);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x60, 0x0a, 0xd4);
+	si2165_writereg4(state, 0x036c, 0xf8, 0x60, 0x26, 0xf0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x31);
+	si2165_writereg4(state, 0x036c, 0x01, 0xa0, 0x02, 0x82);
+	si2165_writereg4(state, 0x036c, 0xa8, 0x22, 0x06, 0xde);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x60, 0x2a, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x14, 0xe0, 0x03, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x19);
+	si2165_writereg4(state, 0x036c, 0x00, 0x18, 0x00, 0x25);
+	si2165_writereg4(state, 0x036c, 0x34, 0x20, 0x0b, 0xda);
+	si2165_writereg4(state, 0x036c, 0x12, 0x40, 0x14, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x14, 0xe0, 0x23, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x60, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x17, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0x00, 0x20, 0x10, 0xb0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x1b);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x17);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x61, 0x13, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x00, 0xe0, 0x12, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x0c, 0x00, 0x10, 0xa2);
+	si2165_writereg4(state, 0x036c, 0xec, 0x0d, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x42, 0x20, 0x14, 0xd2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x60, 0x02, 0x9e);
+	si2165_writereg4(state, 0x036c, 0x42, 0x20, 0x34, 0xde);
+	si2165_writereg4(state, 0x036c, 0x08, 0xa1, 0x04, 0xd0);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xc2, 0x9f);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x06, 0xb0);
+	si2165_writereg4(state, 0x036c, 0x40, 0x64, 0x06, 0xd8);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0xa3, 0x80);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x80, 0x02);
+	si2165_writereg4(state, 0x036c, 0xff, 0x20, 0x0e, 0x92);
+	si2165_writereg4(state, 0x036c, 0x34, 0x60, 0x0c, 0xc2);
+	si2165_writereg4(state, 0x036c, 0x01, 0x40, 0xa2, 0x80);
+	si2165_writereg4(state, 0x036c, 0xf2, 0xff, 0xbf, 0x0a);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x13);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x15);
+	si2165_writereg4(state, 0x036c, 0x3c, 0x60, 0x0a, 0xde);
+	si2165_writereg4(state, 0x036c, 0x56, 0xa0, 0x12, 0xd8);
+	
+	si2165_writereg4(state, 0x0364, 0x2b, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0xc0, 0x17, 0x00, 0x60);
+	si2165_writereg4(state, 0x036c, 0x07, 0xe0, 0x0b, 0x96);
+	si2165_writereg4(state, 0x036c, 0x04, 0x20, 0x33, 0x9b);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x31);
+	si2165_writereg4(state, 0x036c, 0x0d, 0xc0, 0x5a, 0xa4);
+	si2165_writereg4(state, 0x036c, 0x12, 0x20, 0x16, 0xe2);
+	si2165_writereg4(state, 0x036c, 0x12, 0x40, 0x24, 0xa0);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x18, 0x33);
+	si2165_writereg4(state, 0x036c, 0x09, 0x00, 0x80, 0x10);
+	si2165_writereg4(state, 0x036c, 0x10, 0x60, 0x36, 0xe0);
+	si2165_writereg4(state, 0x036c, 0xcf, 0x0d, 0x00, 0x65);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x10, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x18, 0x11);
+	si2165_writereg4(state, 0x036c, 0xe4, 0x21, 0x12, 0x82);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x10, 0xe0);
+	si2165_writereg4(state, 0x036c, 0x01, 0x20, 0x04, 0xb2);
+	si2165_writereg4(state, 0x036c, 0x42, 0x60, 0x30, 0xf2);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x01);
+	si2165_writereg4(state, 0x036c, 0x08, 0xe0, 0xc7, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0xe8, 0x81);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x4d, 0x01);
+	si2165_writereg4(state, 0x036c, 0x06, 0x00, 0x7c, 0x02);
+	si2165_writereg4(state, 0x036c, 0x05, 0x00, 0x4d, 0x04);
+	si2165_writereg4(state, 0x036c, 0x00, 0x04, 0x4a, 0x01);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+/*	msleep(100); */
+	si2165_readreg2(state, 0x037a, val); /* returned 0x0a, 0xcc */
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x90, 0x00, 0x00, 0x80);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	
+	si2165_writereg4(state, 0x0364, 0x01, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x10, 0x00, 0x08, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg4(state, 0x036c, 0x04, 0x00, 0x00, 0x00);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x00, 0x00, 0x00, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x9c, 0x00, 0x00, 0x80);
+	si2165_writereg4(state, 0x036c, 0xfe, 0xff, 0x00, 0x00);
+	
+	si2165_writereg4(state, 0x0364, 0x00, 0x00, 0x00, 0xc0);
+	si2165_writereg4(state, 0x0368, 0x00, 0x00, 0x00, 0x90);
+	si2165_writereg4(state, 0x036c, 0x00, 0x00, 0x00, 0x00);
+	
+	si2165_readreg1(state, 0x0341, val); /* returned 0x05 */
+	si2165_writereg1(state, 0x0341, 0x07); // set bit 0x02
+	si2165_readreg1(state, 0x035c, val); /* returned 0x02 */
+	si2165_writereg1(state, 0x035c, 0x03); // set bit 0x01
+
+	dev_info(&state->i2c->dev, "%s: fw finished\n", KBUILD_MODNAME);
+
+err:
+	if (fw)
+	{
+		release_firmware(fw);
+		fw = NULL;
+	}
+
+	return 0;
+}
+
+static int si2165_set_parameters(struct dvb_frontend *fe)
+{
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret = 0;
+	u32 delsys  = p->delivery_system;
+	u8 val[3];
+	u32 IF;
+	dprintk("%s: called\n", __func__);
+	dprintk("%s: Freq %d\n", __func__, p->frequency);
+
+	bool load_fw;
+	bool dvbt = false;
+	bool dvbc = false;
+	
+	switch (delsys) {
+	case SYS_DVBT:
+	  dprintk("%s: using DVB-T\n");
+	  dvbt = true;
+	  break;
+	case SYS_DVBC_ANNEX_A:
+	case SYS_DVBC_ANNEX_C:
+	  dprintk("%s: using DVB-C\n");
+	  dvbc = true;
+	  break;
+	default:
+	  return -EINVAL;
+	}
+
+	si2165_writereg1(state, 0x0000, 0x21);
+	si2165_writereg1(state, 0x0104, 0x01);
+	si2165_readreg1(state, 0x0000, val); /* returned 0x21 */
+	si2165_writereg1(state, 0x018b, 0x00);
+	si2165_writereg1(state, 0x0190, 0x01);
+	si2165_readreg1(state, 0x0170, val); /* returned 0x00 */
+	
+	si2165_writereg1(state, 0x0170, 0x00);
+	
+	msleep(1);
+	si2165_readreg1(state, 0x0170, val); /* returned 0x00 */
+	si2165_writereg1(state, 0x0170, 0x00);
+	si2165_writereg1(state, 0x0171, 0x07);
+	si2165_writereg1(state, 0x0646, 0x00);
+
+	msleep(1);
+	si2165_readreg1(state, 0x0641, val); /* returned 0x00 */
+	si2165_writereg1(state, 0x0641, 0x00);
+	si2165_writereg1(state, 0x00e0, 0x00);
+	si2165_writereg1(state, 0x00a3, 0x01);
+
+	si2165_readreg1(state, 0x00a2, val); /* returned 0x87 */
+	si2165_writereg1(state, 0x00a2, 0xb8);
+	si2165_writereg1(state, 0x00a1, 0x08);
+	si2165_writereg1(state, 0x00a0, 0x0c);
+
+	si2165_readreg1(state, 0x00a2, val); /* returned 0xb8 */
+	si2165_writereg1(state, 0x00a2, 0xf8);
+
+	si2165_readreg1(state, 0x00a2, val); /* returned 0xf8 */
+	si2165_writereg1(state, 0x00a2, 0xf8);
+	si2165_writereg1(state, 0x0050, 0x01);
+	si2165_writereg1(state, 0x0096, 0x01);
+
+        {
+          int i;
+          for (i = 0; i < 10; i++)
+          {
+            si2165_readreg1(state, 0x0054, val); /* returned 0x01 */
+            if (val[0] == 0x01)
+              break;
+            msleep(1); // does not work without
+          }
+          printk("%s: got this: i=%d val=0x%02x\n", __func__, i, val[0]);
+	}
+	si2165_writereg1(state, 0x0050, 0x00);
+	si2165_writereg2(state, 0x0470, 0x30, 0x75);
+
+	si2165_readreg1(state, 0x0118, val); /* returned 0x07 */
+	si2165_readreg1(state, 0x0023, val); /* returned 0x03 */
+	
+	si2165_readreg1(state, 0x0344, val); /* returned 0x00 */
+	
+	load_fw = !state->fw_loaded;
+	
+	if (!load_fw && val[0] != 0x9a)
+	{
+	  load_fw = true;
+	}
+	
+	if (load_fw)
+	{
+	  si2165_upload_firmware(state);
+	  state->fw_loaded = true;
+	}
+	else
+	{
+	  printk("%s: firmware already loaded\n", __func__);
+	}
+
+	si2165_writereg1(state, 0x012a, 0x46);
+	si2165_writereg1(state, 0x012c, 0x00);
+	si2165_writereg1(state, 0x012e, 0x0a);
+	si2165_writereg1(state, 0x012f, 0xff);
+	si2165_writereg1(state, 0x0123, 0x70);
+	if (dvbt)
+	{
+	  si2165_writereg1(state, 0x00ec, 0x01);
+	  si2165_writereg1(state, 0x00a0, 0x0c);
+	}
+	else if (dvbc)
+	{
+	  si2165_writereg1(state, 0x00ec, 0x05);
+	  si2165_writereg1(state, 0x00a0, 0x0e);
+	}
+	si2165_readreg1(state, 0x00e0, val); /* returned 0x00 */
+	if (dvbt)
+	{
+	  si2165_writereg4(state, 0x00e8, 0x92, 0x24, 0x49, 0x02);
+	}
+	else if (dvbc)
+	{
+	  si2165_writereg4(state, 0x00e8, 0xb6, 0x6d, 0xdb, 0x02);
+	}
+	si2165_writereg1(state, 0x08f8, 0x00);
+	si2165_readreg1(state, 0x04e4, val); /* returned 0x21 */
+	si2165_writereg1(state, 0x04e4, 0x20); // clear bit 1
+	si2165_writereg2(state, 0x04ef, 0xfe, 0x00);
+	si2165_writereg3(state, 0x04f4, 0x55, 0x55, 0x55);
+	si2165_readreg1(state, 0x04e4, val); /* returned 0x20 */
+	si2165_writereg1(state, 0x04e4, 0x20);
+	si2165_readreg1(state, 0x04e5, val); /* returned 0x03 */
+	si2165_writereg1(state, 0x04e5, 0x03);
+	si2165_readreg1(state, 0x04e5, val); /* returned 0x03 */
+	si2165_writereg1(state, 0x04e5, 0x01);
+	if (dvbt)
+	{
+	  si2165_writereg2(state, 0x0308, 0x20, 0x03);
+	  si2165_writereg4(state, 0x00e4, 0x00, 0x00, 0x10, 0x03);
+	  si2165_writereg1(state, 0x031c, 0x01);
+	  si2165_writereg1(state, 0x00cb, 0x00);
+	  si2165_writereg1(state, 0x016e, 0x41);
+	}
+	else if (dvbc)
+	{
+	  si2165_writereg4(state, 0x00e4, 0x7e, 0xf7, 0x94, 0x04);
+	  si2165_writereg1(state, 0x016e, 0x50);
+	}
+	si2165_writereg1(state, 0x016c, 0x0e);
+	si2165_writereg1(state, 0x016d, 0x10);
+	si2165_writereg1(state, 0x015b, 0x03);
+	if (dvbt)
+	{
+	  si2165_writereg1(state, 0x0150, 0x78);
+	  si2165_writereg1(state, 0x01a0, 0x78);
+	  si2165_writereg1(state, 0x01c8, 0x68);
+	  si2165_writereg2(state, 0x030c, 0x64, 0x00);
+	  si2165_readreg1(state, 0x0387, val); /* returned 0x00 */
+	  si2165_writereg1(state, 0x0387, 0x00);
+	}
+	else if (dvbc)
+	{
+	  si2165_writereg1(state, 0x0150, 0x68);
+	  si2165_writereg1(state, 0x01a0, 0x68);
+	  si2165_writereg1(state, 0x01c8, 0x50);
+	  si2165_readreg1(state, 0x0278, val); /* returned 0x0d */
+	  si2165_writereg1(state, 0x0278, 0x0d);
+	  si2165_writereg1(state, 0x023a, 0x05); // or 0x05
+	  si2165_writereg1(state, 0x0261, 0x09);
+	  si2165_writereg2(state, 0x0350, 0x80, 0x3e);
+	  si2165_writereg1(state, 0x02f4, 0x00);
+	}
+	si2165_writereg4(state, 0x0348, 0x00, 0x00, 0x00, 0xf4);
+	if (dvbt)
+	{
+	  si2165_readreg1(state, 0x0341, val); /* returned 0x01 */
+	  si2165_writereg1(state, 0x0341, 0x00);
+	  si2165_writereg1(state, 0x00c0, 0x00);
+	  si2165_writereg4(state, 0x0384, 0x00, 0x00, 0x00, 0x00);
+	  si2165_writereg1(state, 0x02e0, 0x01);
+	  si2165_readreg1(state, 0x0341, val); /* returned 0x01 */
+	  si2165_readreg1(state, 0x0341, val); /* returned 0x01 */
+	  si2165_writereg1(state, 0x0341, 0x00);
+	  si2165_writereg1(state, 0x00c0, 0x00);
+	  si2165_writereg4(state, 0x0384, 0x00, 0x00, 0x00, 0x00);
+	  si2165_writereg1(state, 0x02e0, 0x01);
+	  si2165_readreg1(state, 0x0341, val); /* returned 0x01 */
+	  si2165_readreg1(state, 0x0118, val); /* returned 0x07 */
+	  si2165_readreg1(state, 0x0023, val); /* returned 0x03 */
+	  si2165_writereg1(state, 0x018b, 0x00);
+	  si2165_writereg1(state, 0x08f8, 0x00);
+	  si2165_readreg1(state, 0x04e4, val); /* returned 0x20 */
+	  si2165_writereg1(state, 0x04e4, 0x20);
+	  si2165_writereg2(state, 0x04ef, 0xfe, 0x00);
+	  si2165_writereg3(state, 0x04f4, 0x55, 0x55, 0x55);
+	  si2165_readreg1(state, 0x04e4, val); /* returned 0x20 */
+	  si2165_writereg1(state, 0x04e4, 0x20);
+	  si2165_readreg1(state, 0x04e5, val); /* returned 0x01 */
+	  si2165_writereg1(state, 0x04e5, 0x01);
+	  si2165_readreg1(state, 0x04e5, val); /* returned 0x01 */
+	  si2165_writereg1(state, 0x04e5, 0x01);
+	}
+	else if (dvbc)
+	{
+	  si2165_writereg4(state, 0x00c4, 0x00, 0x12, 0x7a, 0x00);
+	  si2165_writereg1(state, 0x00cb, 0x01);	
+	  si2165_writereg1(state, 0x00c0, 0x00);
+	  si2165_writereg1(state, 0x012a, 0x46);
+	  si2165_writereg1(state, 0x012c, 0x00);
+	  si2165_writereg1(state, 0x012e, 0x0a);
+	  si2165_writereg1(state, 0x012f, 0xff);
+	  si2165_writereg1(state, 0x0123, 0x70);
+	  si2165_writereg2(state, 0x024c, 0x00, 0x00);
+	  si2165_writereg2(state, 0x027c, 0x00, 0x00);
+	  si2165_writereg1(state, 0x0232, 0x03);
+	  si2165_writereg1(state, 0x02f4, 0x0B); // or 0x0B
+	  si2165_writereg4(state, 0x00e4, 0x30, 0xd7, 0x0e, 0x04); // or 0x30, 0xd7, 0x0e, 0x04
+	  si2165_writereg1(state, 0x00c0, 0x00);
+	  si2165_readreg1(state, 0x0118, val); /* returned 0x07 */
+	  si2165_readreg1(state, 0x0023, val); /* returned 0x03 */
+	  si2165_writereg1(state, 0x018b, 0x00);
+	}
+
+	if (!fe->ops.tuner_ops.get_if_frequency) {
+		pr_err("Error: get_if_frequency() not defined at tuner. Can't work without it!\n");
+		return -EINVAL;
+	}
+
+	// here tuner i2c traffic
+	if (fe->ops.tuner_ops.set_params)
+	{
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 1);
+		fe->ops.tuner_ops.set_params(fe);
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 0);
+	}
+	
+	fe->ops.tuner_ops.get_if_frequency(fe, &IF);
+
+	if (dvbt)
+	{
+	  si2165_writereg4(state, 0x00e8, 0x92, 0x24, 0x49, 0x02);
+	}
+	else if (dvbc)
+	{
+	  si2165_writereg4(state, 0x00e8, 0xb6, 0x6d, 0xdb, 0x02);
+	}
+	si2165_readreg1(state, 0x0341, val); /* returned 0x01 */
+	si2165_writereg1(state, 0x0341, 0x00);
+	si2165_writereg1(state, 0x00c0, 0x00);
+	si2165_writereg4(state, 0x0384, 0x00, 0x00, 0x00, 0x00);
+	si2165_writereg1(state, 0x02e0, 0x01);
+	
+	if (dvbc)
+	{
+	  msleep(20);
+	}
+	
+	printk("%s: finished\n", __func__);
+	return ret;
+}
+
+#if 0
+static int si2165_get_frontend(struct dvb_frontend *fe)
+{
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+
+	ret = si2165_get_inversion(state, &p->inversion);
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_get_symbol_rate(state, &p->symbol_rate);
+	if (ret < 0)
+		return ret;
+
+	ret = si2165_get_code_rate(state, &p->fec_inner);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int si2165_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+
+	u8 val = 0x00;
+	int ret;
+
+	switch (state->id) {
+	case ID_ZL10313:
+		ret = si2165_readreg(state, GPP_CTRL, &val);
+		if (ret < 0)
+			goto error;
+
+		/* preserve this bit to not accidentally shutdown ADC */
+		val &= 0x80;
+		break;
+	}
+
+	if (enable)
+		val |= 0x40;
+	else
+		val &= ~0x40;
+
+	ret = si2165_writereg(state, GPP_CTRL, val);
+
+error:
+	return ret;
+}
+
+static int si2165_sleep(struct dvb_frontend *fe)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	int ret;
+	u8 config;
+
+	/* reset all registers to defaults */
+	ret = si2165_reset(state, 1);
+	if (ret < 0)
+		return ret;
+
+	if (state->id == ID_ZL10313) {
+		/* reset ADC */
+		ret = si2165_writereg(state, GPP_CTRL, 0x00);
+		if (ret < 0)
+			return ret;
+
+		/* full shutdown of ADCs, mpeg bus tristated */
+		ret = si2165_writereg(state, HW_CTRL, 0x0d);
+		if (ret < 0)
+			return ret;
+	}
+
+	ret = si2165_readreg(state, CONFIG, &config);
+	if (ret < 0)
+		return ret;
+
+	/* enter standby */
+	ret = si2165_writereg(state, CONFIG, config & 0x7f);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int si2165_get_tune_settings(struct dvb_frontend *fe,
+		struct dvb_frontend_tune_settings *fesettings)
+{
+	fesettings->min_delay_ms = 50;
+	fesettings->step_size = 0;
+	fesettings->max_drift = 0;
+	return 0;
+}
+
+#endif
+static void si2165_release(struct dvb_frontend *fe)
+{
+	struct si2165_state *state = fe->demodulator_priv;
+	printk("%s: called\n", __func__);
+	kfree(state);
+}
+
+static struct dvb_frontend_ops si2165_ops = {
+	.delsys = { SYS_DVBT, SYS_DVBC_ANNEX_A, SYS_DVBC_ANNEX_C },
+	.info = {
+		.name			= "SI2165",
+		 /* For DVB-C */
+		.symbol_rate_min = 870000,
+		.symbol_rate_max = 11700000,
+		/* For DVB-T */
+		.frequency_stepsize = 166667,
+		.caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
+			FE_CAN_QAM_128 | FE_CAN_QAM_256 | FE_CAN_FEC_AUTO |
+			FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+			FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_MUTE_TS |
+			FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_RECOVER |
+			FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_HIERARCHY_AUTO
+	},
+
+	.release = si2165_release,
+	
+	.init                 = si2165_init,
+	.sleep                = si2165_sleep,
+
+#if 0
+	.sleep = si2165_sleep,
+	.i2c_gate_ctrl = si2165_gate_ctrl,
+#endif
+	.set_frontend = si2165_set_parameters,
+#if 0
+	.get_tune_settings = si2165_get_tune_settings,
+#endif
+	.read_status = si2165_read_status,
+	.read_signal_strength = si2165_read_signal_strength,
+	.read_snr = si2165_read_snr,
+	.read_ber = si2165_read_ber,
+	.read_ucblocks = si2165_read_ucblocks,
+};
+
+struct dvb_frontend *si2165_attach(u8 addr,
+					struct i2c_adapter *i2c)
+{
+	struct si2165_state *state = NULL;
+	u8 val = 0;
+
+	printk("si2165: %s: trying to access registers\n", __func__);
+
+	/* allocate memory for the internal state */
+	state = kzalloc(sizeof(struct si2165_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
+
+	/* setup the state */
+	state->addr = addr;
+	state->i2c = i2c;
+
+	/* check if the demod is there */
+/*	if (si2165_readreg(state, 0x0000, &val) < 0)
+		goto error;
+
+	printk("si2165: %s: read val=%x\n", __func__, val);
+*/
+#if 0
+	si2165_writereg1(state, 0x0000, 0x21);
+
+	si2165_writereg1(state, 0x0104, 0x01);
+
+	si2165_readreg1(state, 0x0000); /* returned 0x21 */
+#endif
+
+
+	/* create dvb_frontend */
+	memcpy(&state->frontend.ops, &si2165_ops,
+		sizeof(struct dvb_frontend_ops));
+	state->frontend.demodulator_priv = state;
+
+	return &state->frontend;
+
+error:
+	kfree(state);
+	return NULL;
+}
+EXPORT_SYMBOL(si2165_attach);
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
+
+MODULE_DESCRIPTION("Silicon Labs si2165 DVB-C/-T Demodulator driver");
+MODULE_AUTHOR("Matthias Schwarzott <zzam@xxxxxxxxxx>");
+MODULE_LICENSE("GPL");
+MODULE_FIRMWARE(SI2165_FIRMWARE);
diff --git a/drivers/media/dvb-frontends/si2165.h b/drivers/media/dvb-frontends/si2165.h
new file mode 100644
index 0000000..3c2dd6b
--- /dev/null
+++ b/drivers/media/dvb-frontends/si2165.h
@@ -0,0 +1,42 @@
+/*
+    Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
+
+    Copyright (C) 2013 Matthias Schwarzott <zzam@xxxxxxxxxx>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    References:
+    http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
+*/
+
+#ifndef _DVB_SI2165_H
+#define _DVB_SI2165_H
+
+#include <linux/dvb/frontend.h>
+
+#if IS_ENABLED(CONFIG_DVB_SI2165)
+struct dvb_frontend *si2165_attach(u8 addr,
+					struct i2c_adapter *i2c);
+#else
+static inline struct dvb_frontend *si2165_attach(
+	u8 addr, struct i2c_adapter *i2c)
+{
+	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+	return NULL;
+}
+#endif /* CONFIG_DVB_SI2165 */
+
+#endif /* _DVB_SI2165_H */
diff --git a/drivers/media/dvb-frontends/si2165_priv.h b/drivers/media/dvb-frontends/si2165_priv.h
new file mode 100644
index 0000000..e905f2d
--- /dev/null
+++ b/drivers/media/dvb-frontends/si2165_priv.h
@@ -0,0 +1,28 @@
+/*
+    Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
+
+    Copyright (C) 2013 Matthias Schwarzott <zzam@xxxxxxxxxx>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef _DVB_SI2165_PRIV
+#define _DVB_SI2165_PRIV
+
+#define SI2165_FIRMWARE "dvb-demod-si2165.fw"
+
+#endif /* _DVB_SI2165_PRIV */
-- 
1.8.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux