Commit 3eee0472 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] ec168: convert to new DVB USB

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f093c388
...@@ -374,7 +374,7 @@ config DVB_USB_FRIIO ...@@ -374,7 +374,7 @@ config DVB_USB_FRIIO
config DVB_USB_EC168 config DVB_USB_EC168
tristate "E3C EC168 DVB-T USB2.0 support" tristate "E3C EC168 DVB-T USB2.0 support"
depends on DVB_USB depends on DVB_USB_V2
select DVB_EC100 select DVB_EC100
select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE
help help
......
...@@ -29,17 +29,13 @@ module_param_named(debug, dvb_usb_ec168_debug, int, 0644); ...@@ -29,17 +29,13 @@ module_param_named(debug, dvb_usb_ec168_debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
static struct ec100_config ec168_ec100_config; static int ec168_ctrl_msg(struct dvb_usb_device *d, struct ec168_req *req)
static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req)
{ {
int ret; int ret;
unsigned int pipe; unsigned int pipe;
u8 request, requesttype; u8 request, requesttype;
u8 *buf; u8 *buf;
switch (req->cmd) { switch (req->cmd) {
case DOWNLOAD_FIRMWARE: case DOWNLOAD_FIRMWARE:
case GPIO: case GPIO:
...@@ -83,15 +79,15 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req) ...@@ -83,15 +79,15 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req)
if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) { if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) {
/* write */ /* write */
memcpy(buf, req->data, req->size); memcpy(buf, req->data, req->size);
pipe = usb_sndctrlpipe(udev, 0); pipe = usb_sndctrlpipe(d->udev, 0);
} else { } else {
/* read */ /* read */
pipe = usb_rcvctrlpipe(udev, 0); pipe = usb_rcvctrlpipe(d->udev, 0);
} }
msleep(1); /* avoid I2C errors */ msleep(1); /* avoid I2C errors */
ret = usb_control_msg(udev, pipe, request, requesttype, req->value, ret = usb_control_msg(d->udev, pipe, request, requesttype, req->value,
req->index, buf, req->size, EC168_USB_TIMEOUT); req->index, buf, req->size, EC168_USB_TIMEOUT);
ec168_debug_dump(request, requesttype, req->value, req->index, buf, ec168_debug_dump(request, requesttype, req->value, req->index, buf,
...@@ -116,12 +112,9 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req) ...@@ -116,12 +112,9 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req)
return ret; return ret;
} }
static int ec168_ctrl_msg(struct dvb_usb_device *d, struct ec168_req *req)
{
return ec168_rw_udev(d->udev, req);
}
/* I2C */ /* I2C */
static struct ec100_config ec168_ec100_config;
static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
int num) int num)
{ {
...@@ -181,7 +174,6 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -181,7 +174,6 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
return i; return i;
} }
static u32 ec168_i2c_func(struct i2c_adapter *adapter) static u32 ec168_i2c_func(struct i2c_adapter *adapter)
{ {
return I2C_FUNC_I2C; return I2C_FUNC_I2C;
...@@ -193,56 +185,32 @@ static struct i2c_algorithm ec168_i2c_algo = { ...@@ -193,56 +185,32 @@ static struct i2c_algorithm ec168_i2c_algo = {
}; };
/* Callbacks for DVB USB */ /* Callbacks for DVB USB */
static struct ec100_config ec168_ec100_config = { static int ec168_identify_state(struct dvb_usb_device *d)
.demod_address = 0xff, /* not real address, demod is integrated */
};
static int ec168_ec100_frontend_attach(struct dvb_usb_adapter *adap)
{ {
int ret;
u8 reply;
struct ec168_req req = {GET_CONFIG, 0, 1, sizeof(reply), &reply};
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
adap->fe_adap[0].fe = dvb_attach(ec100_attach, &ec168_ec100_config,
&adap->dev->i2c_adap);
if (adap->fe_adap[0].fe == NULL)
return -ENODEV;
return 0; ret = ec168_ctrl_msg(d, &req);
} if (ret)
goto error;
static struct mxl5005s_config ec168_mxl5003s_config = { deb_info("%s: reply:%02x\n", __func__, reply);
.i2c_address = 0xc6,
.if_freq = IF_FREQ_4570000HZ,
.xtal_freq = CRYSTAL_FREQ_16000000HZ,
.agc_mode = MXL_SINGLE_AGC,
.tracking_filter = MXL_TF_OFF,
.rssi_enable = MXL_RSSI_ENABLE,
.cap_select = MXL_CAP_SEL_ENABLE,
.div_out = MXL_DIV_OUT_4,
.clock_out = MXL_CLOCK_OUT_DISABLE,
.output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
.top = MXL5005S_TOP_25P2,
.mod_mode = MXL_DIGITAL_MODE,
.if_mode = MXL_ZERO_IF,
.AgcMasterByte = 0x00,
};
static int ec168_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap) if (reply == 0x01)
{ ret = WARM;
deb_info("%s:\n", __func__); else
return dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, ret = COLD;
&ec168_mxl5003s_config) == NULL ? -ENODEV : 0;
}
static int ec168_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) return ret;
{ error:
struct ec168_req req = {STREAMING_CTRL, 0x7f01, 0x0202, 0, NULL}; deb_info("%s: failed:%d\n", __func__, ret);
deb_info("%s: onoff:%d\n", __func__, onoff); return ret;
if (onoff)
req.index = 0x0102;
return ec168_ctrl_msg(adap->dev, &req);
} }
static int ec168_download_firmware(struct usb_device *udev, static int ec168_download_firmware(struct dvb_usb_device *d,
const struct firmware *fw) const struct firmware *fw)
{ {
int i, len, packets, remainder, ret; int i, len, packets, remainder, ret;
u16 addr = 0x0000; /* firmware start address */ u16 addr = 0x0000; /* firmware start address */
...@@ -262,7 +230,7 @@ static int ec168_download_firmware(struct usb_device *udev, ...@@ -262,7 +230,7 @@ static int ec168_download_firmware(struct usb_device *udev,
req.index = addr; req.index = addr;
addr += FW_PACKET_MAX_DATA; addr += FW_PACKET_MAX_DATA;
ret = ec168_rw_udev(udev, &req); ret = ec168_ctrl_msg(d, &req);
if (ret) { if (ret) {
err("firmware download failed:%d packet:%d", ret, i); err("firmware download failed:%d packet:%d", ret, i);
goto error; goto error;
...@@ -274,7 +242,7 @@ static int ec168_download_firmware(struct usb_device *udev, ...@@ -274,7 +242,7 @@ static int ec168_download_firmware(struct usb_device *udev,
req.cmd = SET_CONFIG; req.cmd = SET_CONFIG;
req.value = 0; req.value = 0;
req.index = 0x0001; req.index = 0x0001;
ret = ec168_rw_udev(udev, &req); ret = ec168_ctrl_msg(d, &req);
if (ret) if (ret)
goto error; goto error;
...@@ -282,7 +250,7 @@ static int ec168_download_firmware(struct usb_device *udev, ...@@ -282,7 +250,7 @@ static int ec168_download_firmware(struct usb_device *udev,
req.cmd = GPIO; req.cmd = GPIO;
req.value = 0; req.value = 0;
req.index = 0x0206; req.index = 0x0206;
ret = ec168_rw_udev(udev, &req); ret = ec168_ctrl_msg(d, &req);
if (ret) if (ret)
goto error; goto error;
...@@ -290,7 +258,7 @@ static int ec168_download_firmware(struct usb_device *udev, ...@@ -290,7 +258,7 @@ static int ec168_download_firmware(struct usb_device *udev,
req.cmd = WRITE_I2C; req.cmd = WRITE_I2C;
req.value = 0; req.value = 0;
req.index = 0x00c6; req.index = 0x00c6;
ret = ec168_rw_udev(udev, &req); ret = ec168_ctrl_msg(d, &req);
if (ret) if (ret)
goto error; goto error;
...@@ -300,93 +268,76 @@ static int ec168_download_firmware(struct usb_device *udev, ...@@ -300,93 +268,76 @@ static int ec168_download_firmware(struct usb_device *udev,
return ret; return ret;
} }
static int ec168_identify_state(struct usb_device *udev, static struct ec100_config ec168_ec100_config = {
struct dvb_usb_device_properties *props, .demod_address = 0xff, /* not real address, demod is integrated */
struct dvb_usb_device_description **desc, int *cold) };
static int ec168_ec100_frontend_attach(struct dvb_usb_adapter *adap)
{ {
int ret;
u8 reply;
struct ec168_req req = {GET_CONFIG, 0, 1, sizeof(reply), &reply};
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
adap->fe[0] = dvb_attach(ec100_attach, &ec168_ec100_config,
&adap->dev->i2c_adap);
if (adap->fe[0] == NULL)
return -ENODEV;
ret = ec168_rw_udev(udev, &req); return 0;
if (ret)
goto error;
deb_info("%s: reply:%02x\n", __func__, reply);
if (reply == 0x01)
*cold = 0;
else
*cold = 1;
return ret;
error:
deb_info("%s: failed:%d\n", __func__, ret);
return ret;
} }
/* DVB USB Driver stuff */ static struct mxl5005s_config ec168_mxl5003s_config = {
static struct dvb_usb_device_properties ec168_properties; .i2c_address = 0xc6,
.if_freq = IF_FREQ_4570000HZ,
.xtal_freq = CRYSTAL_FREQ_16000000HZ,
.agc_mode = MXL_SINGLE_AGC,
.tracking_filter = MXL_TF_OFF,
.rssi_enable = MXL_RSSI_ENABLE,
.cap_select = MXL_CAP_SEL_ENABLE,
.div_out = MXL_DIV_OUT_4,
.clock_out = MXL_CLOCK_OUT_DISABLE,
.output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
.top = MXL5005S_TOP_25P2,
.mod_mode = MXL_DIGITAL_MODE,
.if_mode = MXL_ZERO_IF,
.AgcMasterByte = 0x00,
};
static int ec168_probe(struct usb_interface *intf, static int ec168_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
const struct usb_device_id *id)
{ {
int ret; deb_info("%s:\n", __func__);
deb_info("%s: interface:%d\n", __func__, return dvb_attach(mxl5005s_attach, adap->fe[0],
intf->cur_altsetting->desc.bInterfaceNumber); &adap->dev->i2c_adap,
&ec168_mxl5003s_config) == NULL ? -ENODEV : 0;
ret = dvb_usb_device_init(intf, &ec168_properties, THIS_MODULE, NULL,
adapter_nr);
if (ret)
goto error;
return ret;
error:
deb_info("%s: failed:%d\n", __func__, ret);
return ret;
} }
#define E3C_EC168_1689 0 static int ec168_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
#define E3C_EC168_FFFA 1 {
#define E3C_EC168_FFFB 2 struct ec168_req req = {STREAMING_CTRL, 0x7f01, 0x0202, 0, NULL};
#define E3C_EC168_1001 3 deb_info("%s: onoff:%d\n", __func__, onoff);
#define E3C_EC168_1002 4 if (onoff)
req.index = 0x0102;
static struct usb_device_id ec168_id[] = { return ec168_ctrl_msg(adap->dev, &req);
[E3C_EC168_1689] = }
{USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168)},
[E3C_EC168_FFFA] =
{USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_2)},
[E3C_EC168_FFFB] =
{USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_3)},
[E3C_EC168_1001] =
{USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_4)},
[E3C_EC168_1002] =
{USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_5)},
{} /* terminating entry */
};
MODULE_DEVICE_TABLE(usb, ec168_id);
static struct dvb_usb_device_properties ec168_properties = { /* DVB USB Driver stuff */
.caps = DVB_USB_IS_AN_I2C_ADAPTER, /* bInterfaceNumber 0 is HID
* bInterfaceNumber 1 is DVB-T */
static struct dvb_usb_device_properties ec168_props = {
.driver_name = KBUILD_MODNAME,
.owner = THIS_MODULE,
.adapter_nr = adapter_nr,
.bInterfaceNumber = 1,
.usb_ctrl = DEVICE_SPECIFIC, .identify_state = ec168_identify_state,
.download_firmware = ec168_download_firmware,
.firmware = "dvb-usb-ec168.fw", .firmware = "dvb-usb-ec168.fw",
.no_reconnect = 1, .download_firmware = ec168_download_firmware,
.size_of_priv = 0, .i2c_algo = &ec168_i2c_algo,
.frontend_attach = ec168_ec100_frontend_attach,
.tuner_attach = ec168_mxl5003s_tuner_attach,
.streaming_ctrl = ec168_streaming_ctrl,
.num_adapters = 1, .num_adapters = 1,
.adapter = { .adapter = {
{ {
.num_frontends = 1,
.fe = {{
.streaming_ctrl = ec168_streaming_ctrl,
.frontend_attach = ec168_ec100_frontend_attach,
.tuner_attach = ec168_mxl5003s_tuner_attach,
.stream = { .stream = {
.type = USB_BULK, .type = USB_BULK,
.count = 6, .count = 6,
...@@ -397,35 +348,39 @@ static struct dvb_usb_device_properties ec168_properties = { ...@@ -397,35 +348,39 @@ static struct dvb_usb_device_properties ec168_properties = {
} }
} }
}, },
}},
} }
}, },
};
.identify_state = ec168_identify_state, static const struct dvb_usb_driver_info ec168_driver_info = {
.name = "E3C EC168 reference design",
.i2c_algo = &ec168_i2c_algo, .props = &ec168_props,
};
.num_device_descs = 1, static const struct usb_device_id ec168_id[] = {
.devices = { { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168),
{ .driver_info = (kernel_ulong_t) &ec168_driver_info },
.name = "E3C EC168 DVB-T USB2.0 reference design", { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_2),
.cold_ids = { .driver_info = (kernel_ulong_t) &ec168_driver_info },
&ec168_id[E3C_EC168_1689], { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_3),
&ec168_id[E3C_EC168_FFFA], .driver_info = (kernel_ulong_t) &ec168_driver_info },
&ec168_id[E3C_EC168_FFFB], { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_4),
&ec168_id[E3C_EC168_1001], .driver_info = (kernel_ulong_t) &ec168_driver_info },
&ec168_id[E3C_EC168_1002], { USB_DEVICE(USB_VID_E3C, USB_PID_E3C_EC168_5),
NULL}, .driver_info = (kernel_ulong_t) &ec168_driver_info },
.warm_ids = {NULL}, {}
},
}
}; };
MODULE_DEVICE_TABLE(usb, ec168_id);
static struct usb_driver ec168_driver = { static struct usb_driver ec168_driver = {
.name = "dvb_usb_ec168", .name = KBUILD_MODNAME,
.probe = ec168_probe, .id_table = ec168_id,
.disconnect = dvb_usb_device_exit, .probe = dvb_usbv2_probe,
.id_table = ec168_id, .disconnect = dvb_usbv2_disconnect,
.suspend = dvb_usbv2_suspend,
.resume = dvb_usbv2_resume,
.no_dynamic_id = 1,
.soft_unbind = 1,
}; };
module_usb_driver(ec168_driver); module_usb_driver(ec168_driver);
......
...@@ -23,7 +23,17 @@ ...@@ -23,7 +23,17 @@
#define EC168_H #define EC168_H
#define DVB_USB_LOG_PREFIX "ec168" #define DVB_USB_LOG_PREFIX "ec168"
#include "dvb-usb.h" #include "dvb_usb.h"
#ifdef CONFIG_DVB_USB_DEBUG
#define dprintk(var, level, args...) \
do { if ((var & level)) printk(args); } while (0)
#define DVB_USB_DEBUG_STATUS
#else
#define dprintk(args...)
#define debug_dump(b, l, func)
#define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"
#endif
#define deb_info(args...) dprintk(dvb_usb_ec168_debug, 0x01, args) #define deb_info(args...) dprintk(dvb_usb_ec168_debug, 0x01, args)
#define deb_rc(args...) dprintk(dvb_usb_ec168_debug, 0x02, args) #define deb_rc(args...) dprintk(dvb_usb_ec168_debug, 0x02, args)
......
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