Commit 41f81f68 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] anysee: reimplement demod and tuner attach

Use board ID as base value when selecting correct hardware configuration.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 592d9e21
...@@ -105,6 +105,27 @@ static int anysee_write_reg(struct dvb_usb_device *d, u16 reg, u8 val) ...@@ -105,6 +105,27 @@ static int anysee_write_reg(struct dvb_usb_device *d, u16 reg, u8 val)
return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
} }
/* write single register with mask */
static int anysee_wr_reg_mask(struct dvb_usb_device *d, u16 reg, u8 val,
u8 mask)
{
int ret;
u8 tmp;
/* no need for read if whole reg is written */
if (mask != 0xff) {
ret = anysee_read_reg(d, reg, &tmp);
if (ret)
return ret;
val &= mask;
tmp &= ~mask;
val |= tmp;
}
return anysee_write_reg(d, reg, val);
}
static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id) static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id)
{ {
u8 buf[] = {CMD_GET_HW_INFO}; u8 buf[] = {CMD_GET_HW_INFO};
...@@ -244,134 +265,241 @@ static struct zl10353_config anysee_zl10353_config = { ...@@ -244,134 +265,241 @@ static struct zl10353_config anysee_zl10353_config = {
.parallel_ts = 1, .parallel_ts = 1,
}; };
/*
* New USB device strings: Mfr=1, Product=2, SerialNumber=0
* Manufacturer: AMT.CO.KR
*
* E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=????????
* PCB: ?
* parts: MT352, DTT7579(?), DNOS404ZH102A NIM
*
* E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=????????
* PCB: ?
* parts: ZL10353, DTT7579(?), DNOS404ZH103A NIM
*
* E30 Plus VID=04b4 PID=861f HW=6 FW=1.0 "anysee"
* PCB: 507CD (rev1.1)
* parts: ZL10353, DTT7579(?), CST56I01, DNOS404ZH103A NIM
* OEA=80 OEB=00 OEC=00 OED=ff OEF=fe
* IOD[0] ZL10353 1=enabled
* IOA[7] TS 0=enabled
* tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not)
*
* E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)"
* PCB: 507DC (rev0.2)
* parts: TDA10023, CST56I01, DTOS403IH102B TM
* OEA=80 OEB=00 OEC=00 OED=ff OEF=fe
* IOD[0] TDA10023 1=enabled
*
* E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
* PCB: 507FA (rev0.4)
* parts: TDA10023, TDA8024, DTOS403IH102B TM
* OEA=80 OEB=00 OEC=ff OED=ff OEF=ff
* IOD[5] TDA10023 1=enabled
* IOE[0] tuner 1=enabled
*
* E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
* PCB: 507FA (rev1.1)
* parts: ZL10353, TDA10023, TDA8024, DTOS403IH102B TM
* OEA=80 OEB=00 OEC=ff OED=ff OEF=ff
* DVB-C:
* IOD[5] TDA10023 1=enabled
* IOE[0] tuner 1=enabled
* DVB-T:
* IOD[0] ZL10353 1=enabled
* IOE[0] tuner 0=enabled
* tuner is behind ZL10353 I2C-gate
*/
static int anysee_frontend_attach(struct dvb_usb_adapter *adap) static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
{ {
int ret; int ret;
struct anysee_state *state = adap->dev->priv; struct anysee_state *state = adap->dev->priv;
u8 hw_info[3]; u8 hw_info[3];
u8 io_d; /* IO port D */
/* check which hardware we have /* Check which hardware we have.
We must do this call two times to get reliable values (hw bug). */ * We must do this call two times to get reliable values (hw bug).
*/
ret = anysee_get_hw_info(adap->dev, hw_info); ret = anysee_get_hw_info(adap->dev, hw_info);
if (ret) if (ret)
return ret; goto error;
ret = anysee_get_hw_info(adap->dev, hw_info); ret = anysee_get_hw_info(adap->dev, hw_info);
if (ret) if (ret)
return ret; goto error;
/* Meaning of these info bytes are guessed. */ /* Meaning of these info bytes are guessed. */
info("firmware version:%d.%d hardware id:%d", info("firmware version:%d.%d hardware id:%d",
hw_info[1], hw_info[2], hw_info[0]); hw_info[1], hw_info[2], hw_info[0]);
ret = anysee_read_reg(adap->dev, 0xb0, &io_d); /* IO port D */ state->hw = hw_info[0];
if (ret)
return ret;
deb_info("%s: IO port D:%02x\n", __func__, io_d);
/* Select demod using trial and error method. */
/* Try to attach demodulator in following order:
model demod hw fw
1. E30 MT352 02 2.1
2. E30 ZL10353 02 2.1
3. E30 Combo ZL10353 0f 1.2 DVB-T/C combo
4. E30 Plus ZL10353 06 1.0
5. E30C Plus TDA10023 0a 1.0 rev 0.2
E30C Plus TDA10023 0f 1.2 rev 0.4
E30 Combo TDA10023 0f 1.2 DVB-T/C combo
*/
/* Zarlink MT352 DVB-T demod inside of Samsung DNOS404ZH102A NIM */
adap->fe = dvb_attach(mt352_attach, &anysee_mt352_config,
&adap->dev->i2c_adap);
if (adap->fe != NULL) {
state->tuner = DVB_PLL_THOMSON_DTT7579;
return 0;
}
/* Zarlink ZL10353 DVB-T demod inside of Samsung DNOS404ZH103A NIM */ switch (state->hw) {
adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, case ANYSEE_HW_02: /* 2 */
&adap->dev->i2c_adap); /* E30 */
if (adap->fe != NULL) {
state->tuner = DVB_PLL_THOMSON_DTT7579;
return 0;
}
/* for E30 Combo Plus DVB-T demodulator */ /* attach demod */
if (dvb_usb_anysee_delsys) { adap->fe = dvb_attach(mt352_attach, &anysee_mt352_config,
ret = anysee_write_reg(adap->dev, 0xb0, 0x01); &adap->dev->i2c_adap);
if (ret) if (adap->fe)
return ret; break;
/* Zarlink ZL10353 DVB-T demod */ /* attach demod */
adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config,
&adap->dev->i2c_adap); &adap->dev->i2c_adap);
if (adap->fe != NULL) { if (adap->fe)
state->tuner = DVB_PLL_SAMSUNG_DTOS403IH102A; break;
return 0;
}
}
/* connect demod on IO port D for TDA10023 & ZL10353 */ break;
ret = anysee_write_reg(adap->dev, 0xb0, 0x25); case ANYSEE_HW_507CD: /* 6 */
if (ret) /* E30 Plus */
return ret;
/* Zarlink ZL10353 DVB-T demod inside of Samsung DNOS404ZH103A NIM */ /* enable DVB-T demod on IOD[0] */
adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01);
&adap->dev->i2c_adap); if (ret)
if (adap->fe != NULL) { goto error;
state->tuner = DVB_PLL_THOMSON_DTT7579;
return 0;
}
/* IO port E - E30C rev 0.4 board requires this */ /* enable transport stream on IOA[7] */
ret = anysee_write_reg(adap->dev, 0xb1, 0xa7); ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (0 << 7), 0x80);
if (ret) if (ret)
return ret; goto error;
/* Philips TDA10023 DVB-C demod */ /* attach demod */
adap->fe = dvb_attach(tda10023_attach, &anysee_tda10023_config, adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config,
&adap->dev->i2c_adap, 0x48); &adap->dev->i2c_adap);
if (adap->fe != NULL) { if (adap->fe)
state->tuner = DVB_PLL_SAMSUNG_DTOS403IH102A; break;
return 0;
}
/* return IO port D to init value for safe */ break;
ret = anysee_write_reg(adap->dev, 0xb0, io_d); case ANYSEE_HW_507DC: /* 10 */
if (ret) /* E30 C Plus */
return ret;
/* enable DVB-C demod on IOD[0] */
ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01);
if (ret)
goto error;
/* attach demod */
adap->fe = dvb_attach(tda10023_attach, &anysee_tda10023_config,
&adap->dev->i2c_adap, 0x48);
if (adap->fe)
break;
err("Unknown Anysee version: %02x %02x %02x. " \ break;
"Please report the <linux-media@vger.kernel.org>.", case ANYSEE_HW_507FA: /* 15 */
hw_info[0], hw_info[1], hw_info[2]); /* E30 Combo Plus */
/* E30 C Plus */
if (dvb_usb_anysee_delsys) {
/* disable DVB-C demod on IOD[5] */
ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5),
0x20);
if (ret)
goto error;
/* enable DVB-T demod on IOD[0] */
ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0),
0x01);
if (ret)
goto error;
/* attach demod */
adap->fe = dvb_attach(zl10353_attach,
&anysee_zl10353_config, &adap->dev->i2c_adap);
if (adap->fe)
break;
} else {
/* disable DVB-T demod on IOD[0] */
ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0),
0x01);
if (ret)
goto error;
/* enable DVB-C demod on IOD[5] */
ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5),
0x20);
if (ret)
goto error;
/* attach demod */
adap->fe = dvb_attach(tda10023_attach,
&anysee_tda10023_config, &adap->dev->i2c_adap,
0x48);
if (adap->fe)
break;
}
break;
}
return -ENODEV; if (!adap->fe) {
/* we have no frontend :-( */
ret = -ENODEV;
err("Unknown Anysee version: %02x %02x %02x. " \
"Please report the <linux-media@vger.kernel.org>.",
hw_info[0], hw_info[1], hw_info[2]);
}
error:
return ret;
} }
static int anysee_tuner_attach(struct dvb_usb_adapter *adap) static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
{ {
struct anysee_state *state = adap->dev->priv; struct anysee_state *state = adap->dev->priv;
int ret = 0;
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
switch (state->tuner) { switch (state->hw) {
case DVB_PLL_THOMSON_DTT7579: case ANYSEE_HW_02: /* 2 */
/* Thomson dtt7579 (not sure) PLL inside of: /* E30 */
Samsung DNOS404ZH102A NIM
Samsung DNOS404ZH103A NIM */ /* attach tuner */
dvb_attach(dvb_pll_attach, adap->fe, (0xc2 >> 1), dvb_attach(dvb_pll_attach, adap->fe, (0xc2 >> 1),
NULL, DVB_PLL_THOMSON_DTT7579); NULL, DVB_PLL_THOMSON_DTT7579);
break; break;
case DVB_PLL_SAMSUNG_DTOS403IH102A: case ANYSEE_HW_507CD: /* 6 */
/* Unknown PLL inside of Samsung DTOS403IH102A tuner module */ /* E30 Plus */
/* attach tuner */
dvb_attach(dvb_pll_attach, adap->fe, (0xc2 >> 1),
&adap->dev->i2c_adap, DVB_PLL_THOMSON_DTT7579);
break;
case ANYSEE_HW_507DC: /* 10 */
/* E30 C Plus */
/* attach tuner */
dvb_attach(dvb_pll_attach, adap->fe, (0xc0 >> 1),
&adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A);
break;
case ANYSEE_HW_507FA: /* 15 */
/* E30 Combo Plus */
/* E30 C Plus */
if (dvb_usb_anysee_delsys) {
/* enable DVB-T tuner on IOE[0] */
ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0),
0x01);
if (ret)
goto error;
} else {
/* enable DVB-C tuner on IOE[0] */
ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0),
0x01);
if (ret)
goto error;
}
/* attach tuner */
dvb_attach(dvb_pll_attach, adap->fe, (0xc0 >> 1), dvb_attach(dvb_pll_attach, adap->fe, (0xc0 >> 1),
&adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A);
break; break;
default:
ret = -ENODEV;
} }
return 0; error:
return ret;
} }
static int anysee_rc_query(struct dvb_usb_device *d) static int anysee_rc_query(struct dvb_usb_device *d)
......
...@@ -57,10 +57,27 @@ enum cmd { ...@@ -57,10 +57,27 @@ enum cmd {
}; };
struct anysee_state { struct anysee_state {
u8 tuner; u8 hw; /* PCB ID */
u8 seq; u8 seq;
}; };
#define ANYSEE_HW_02 2 /* E30 */
#define ANYSEE_HW_507CD 6 /* E30 Plus */
#define ANYSEE_HW_507DC 10 /* E30 C Plus */
#define ANYSEE_HW_507SI 11 /* E30 S2 Plus */
#define ANYSEE_HW_507FA 15 /* E30 Combo Plus / E30 C Plus */
#define REG_IOA 0x80 /* Port A (bit addressable) */
#define REG_IOB 0x90 /* Port B (bit addressable) */
#define REG_IOC 0xa0 /* Port C (bit addressable) */
#define REG_IOD 0xb0 /* Port D (bit addressable) */
#define REG_IOE 0xb1 /* Port E (NOT bit addressable) */
#define REG_OEA 0xb2 /* Port A Output Enable */
#define REG_OEB 0xb3 /* Port B Output Enable */
#define REG_OEC 0xb4 /* Port C Output Enable */
#define REG_OED 0xb5 /* Port D Output Enable */
#define REG_OEE 0xb6 /* Port E Output Enable */
#endif #endif
/*************************************************************************** /***************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment