Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81091144 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

[media] az6007: Fix some init sequences and use the right firmwares

parent c108a5a0
Loading
Loading
Loading
Loading
+43 −62
Original line number Original line Diff line number Diff line
@@ -56,7 +56,8 @@ static struct drxk_config terratec_h7_drxk = {
	.single_master = 1,
	.single_master = 1,
	.no_i2c_bridge = 0,
	.no_i2c_bridge = 0,
	.max_size = 64,
	.max_size = 64,
//	.microcode_name = "dvb-usb-terratec-h5-drxk.fw",
	.microcode_name = "dvb-usb-terratec-h7-drxk.fw",
	.parallel_ts = 1,
};
};


static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
@@ -200,53 +201,31 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
	return 0;
	return 0;
}
}


#define AZ6007_POWER	0xbc
#define FX2_SCON1		0xc0
#define AZ6007_TS_THROUGH	0xc7

static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
{
{
	int ret;
	struct dvb_usb_device *d = adap->dev;
	u8 req;
	u16 value;
	u16 index;
	int blen;


	deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
	deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
		 adap, adap->dev);
		 adap, adap->dev);


	req = 0xBC;
	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
	value = 1;		/* power on */
	msleep(150);
	index = 3;
	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
	blen = 0;
	msleep(100);

	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
	msleep(100);
	if (ret != 0) {
	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
		err("az6007_frontend_poweron failed!!!");
	msleep(100);
		return -EIO;
	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
	}
	msleep (10);

	az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
	msleep_interruptible(200);
	msleep (10);

	az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
	req = 0xBC;
	value = 0;		/* power off */
	index = 3;
	blen = 0;

	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
	if (ret != 0) {
		err("az6007_frontend_poweron failed!!!");
		return -EIO;
	}

	msleep_interruptible(200);

	req = 0xBC;
	value = 1;		/* power on */
	index = 3;
	blen = 0;


	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
	if (ret != 0) {
		err("az6007_frontend_poweron failed!!!");
		return -EIO;
	}
	deb_info("az6007_frontend_poweron: OK\n");
	deb_info("az6007_frontend_poweron: OK\n");


	return 0;
	return 0;
@@ -333,25 +312,6 @@ static int az6007_led_on_off(struct usb_interface *intf, int onoff)
	return ret;
	return ret;
}
}


static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap, int onoff)
{
	int ret;
	u8 req;
	u16 value;
	u16 index;
	int blen;
	/* TS through */
	req = 0xC7;
	value = onoff;
	index = 0;
	blen = 0;

	ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
	if (ret != 0)
		return -EIO;
	return 0;
}

static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
{
{
	struct az6007_device_state *st = adap->priv;
	struct az6007_device_state *st = adap->priv;
@@ -409,6 +369,27 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
	return result;
	return result;
}
}


int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
{
	if (!onoff)
		return 0;


	info("Sending poweron sequence");

	az6007_usb_out_op(d, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);

#if 0
	// Seems to be a poweroff sequence
	az6007_usb_out_op(d, 0xbc, 1, 3, NULL, 0);
	az6007_usb_out_op(d, 0xbc, 1, 4, NULL, 0);
	az6007_usb_out_op(d, 0xc0, 0, 3, NULL, 0);
	az6007_usb_out_op(d, 0xc0, 1, 3, NULL, 0);
	az6007_usb_out_op(d, 0xbc, 0, 1, NULL, 0);
#endif
	return 0;
}

static struct dvb_usb_device_properties az6007_properties;
static struct dvb_usb_device_properties az6007_properties;


static void az6007_usb_disconnect(struct usb_interface *intf)
static void az6007_usb_disconnect(struct usb_interface *intf)
@@ -568,7 +549,7 @@ MODULE_DEVICE_TABLE(usb, az6007_usb_table);
static struct dvb_usb_device_properties az6007_properties = {
static struct dvb_usb_device_properties az6007_properties = {
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
	.caps = DVB_USB_IS_AN_I2C_ADAPTER,
	.usb_ctrl = CYPRESS_FX2,
	.usb_ctrl = CYPRESS_FX2,
	.firmware            = "dvb-usb-az6007-03.fw",
	.firmware            = "dvb-usb-terratec-h7-az6007.fw",
	.no_reconnect        = 1,
	.no_reconnect        = 1,


	.identify_state		= az6007_identify_state,
	.identify_state		= az6007_identify_state,
@@ -592,7 +573,7 @@ static struct dvb_usb_device_properties az6007_properties = {
			.size_of_priv     = sizeof(struct az6007_device_state),
			.size_of_priv     = sizeof(struct az6007_device_state),
		}
		}
	},
	},
	/* .power_ctrl       = az6007_power_ctrl, */
	.power_ctrl       = az6007_power_ctrl,
	.read_mac_address = az6007_read_mac_addr,
	.read_mac_address = az6007_read_mac_addr,


	.rc.legacy = {
	.rc.legacy = {