Commit 6da34706 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] az6007: Fix compilation troubles at az6007

Some changes are needed, in order to make az6007 compile with the
upstream tree. Most of the changes are due to the upstream drxk
module.

Even allowing its compilation, the driver is not working yet.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 71d67634
...@@ -350,7 +350,7 @@ static int MT2063_Sleep(struct dvb_frontend *fe) ...@@ -350,7 +350,7 @@ static int MT2063_Sleep(struct dvb_frontend *fe)
/* /*
* ToDo: Add code here to implement a OS blocking * ToDo: Add code here to implement a OS blocking
*/ */
msleep(10); msleep(100);
return 0; return 0;
} }
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include "mt2063.h" #include "mt2063.h"
#include "dvb_ca_en50221.h" #include "dvb_ca_en50221.h"
/* HACK: Should be moved to the right place */
#define USB_PID_AZUREWAVE_6007 0xccd
#define USB_PID_TERRATEC_H7 0x10b4
/* debug */ /* debug */
int dvb_usb_az6007_debug; int dvb_usb_az6007_debug;
module_param_named(debug,dvb_usb_az6007_debug, int, 0644); module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
...@@ -28,30 +32,39 @@ struct az6007_device_state { ...@@ -28,30 +32,39 @@ struct az6007_device_state {
struct dvb_ca_en50221 ca; struct dvb_ca_en50221 ca;
struct mutex ca_mutex; struct mutex ca_mutex;
u8 power_state; u8 power_state;
};
struct drxk3913_config az6007_drxk3913_config_DVBT = { /* Due to DRX-K - probably need changes */
.demod_address = 0x52, int (*gate_ctrl)(struct dvb_frontend *, int);
.min_delay_ms = 100, struct semaphore pll_mutex;
.standard = MTTUNEA_DVBT, bool dont_attach_fe1;
.set_tuner = mt2063_setTune,
.tuner_getlocked = mt2063_lockStatus,
.tuner_MT2063_Open = tuner_MT2063_Open,
.tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
.tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
}; };
struct drxk3913_config az6007_drxk3913_config_DVBC = { struct drxk_config terratec_h7_drxk = {
.demod_address = 0x52, .adr = 0x29,
.min_delay_ms = 100, .single_master = 1,
.standard = MTTUNEA_DVBC, .no_i2c_bridge = 1,
.set_tuner = mt2063_setTune, .microcode_name = "dvb-usb-terratec-h5-drxk.fw",
.tuner_getlocked = mt2063_lockStatus,
.tuner_MT2063_Open = tuner_MT2063_Open,
.tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
.tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
}; };
static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
{
struct dvb_usb_adapter *adap = fe->sec_priv;
struct az6007_device_state *st = adap->priv;
int status;
if (!adap || !st)
return -EINVAL;
if (enable) {
down(&st->pll_mutex);
status = st->gate_ctrl(fe, 1);
} else {
status = st->gate_ctrl(fe, 0);
up(&st->pll_mutex);
}
return status;
}
struct mt2063_config az6007_mt2063_config = { struct mt2063_config az6007_mt2063_config = {
.tuner_address = 0xc0, .tuner_address = 0xc0,
.refclock = 36125000, .refclock = 36125000,
...@@ -87,7 +100,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, ...@@ -87,7 +100,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
{ {
int ret; int ret;
#if 0 #if 0
int i=0, cyc=0, rem=0; int i=0, cyc=0, rem=0;
cyc = blen/64; cyc = blen/64;
rem = blen%64; rem = blen%64;
...@@ -96,7 +109,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, ...@@ -96,7 +109,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index); deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
debug_dump(b,blen,deb_xfer); debug_dump(b,blen,deb_xfer);
#if 0 #if 0
if (blen>64) if (blen>64)
{ {
...@@ -110,7 +123,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, ...@@ -110,7 +123,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
5000)) != 64) { 5000)) != 64) {
warn("usb out operation failed. (%d)",ret); warn("usb out operation failed. (%d)",ret);
return -EIO; return -EIO;
} }
} }
if (rem>0) if (rem>0)
...@@ -127,7 +140,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, ...@@ -127,7 +140,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
} }
} }
else else
#endif #endif
{ {
if ((ret = usb_control_msg(d->udev, if ((ret = usb_control_msg(d->udev,
usb_sndctrlpipe(d->udev,0), usb_sndctrlpipe(d->udev,0),
...@@ -139,7 +152,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, ...@@ -139,7 +152,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
return -EIO; return -EIO;
} }
} }
return 0; return 0;
} }
...@@ -149,9 +162,9 @@ static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) ...@@ -149,9 +162,9 @@ static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
} }
/* keys for the enclosed remote control */ /* keys for the enclosed remote control */
static struct dvb_usb_rc_key az6007_rc_keys[] = { struct rc_map_table rc_map_az6007_table[] = {
{ 0x00, 0x01, KEY_1 }, { 0x0001, KEY_1 },
{ 0x00, 0x02, KEY_2 }, { 0x0002, KEY_2 },
}; };
/* remote control stuff (does not work with my box) */ /* remote control stuff (does not work with my box) */
...@@ -163,7 +176,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 *event, int *state) ...@@ -163,7 +176,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
int i; int i;
/* remove the following return to enabled remote querying */ /* remove the following return to enabled remote querying */
az6007_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10); az6007_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10);
...@@ -257,7 +270,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap) ...@@ -257,7 +270,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
int blen; int blen;
info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev); info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
//reset demodulator //reset demodulator
req = 0xC0; req = 0xC0;
value = 1;//high value = 1;//high
...@@ -268,7 +281,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap) ...@@ -268,7 +281,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
err("az6007_frontend_reset failed 1 !!!"); err("az6007_frontend_reset failed 1 !!!");
return -EIO; return -EIO;
} }
req = 0xC0; req = 0xC0;
value = 0;//low value = 0;//low
index = 3; index = 3;
...@@ -290,11 +303,11 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap) ...@@ -290,11 +303,11 @@ static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
err("az6007_frontend_reset failed 3 !!!"); err("az6007_frontend_reset failed 3 !!!");
return -EIO; return -EIO;
} }
msleep_interruptible(200); msleep_interruptible(200);
info("reset az6007 frontend\n"); info("reset az6007 frontend\n");
return 0; return 0;
} }
...@@ -350,38 +363,55 @@ static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap,int onoff) ...@@ -350,38 +363,55 @@ static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap,int onoff)
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;
int result;
az6007_frontend_poweron(adap); az6007_frontend_poweron(adap);
az6007_frontend_reset(adap); az6007_frontend_reset(adap);
info("az6007_frontend_attach\n"); info("az6007_frontend_attach\n");
if (az6007_type == 0) adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
{ &adap->dev->i2c_adap, &adap->fe2);
info("az6007_drxk3913_config_DVBT\n"); if (!adap->fe) {
adap->fe = drxk3913_attach(&az6007_drxk3913_config_DVBT, &adap->dev->i2c_adap); result = -EINVAL;
goto out_free;
} }
else
{ /* FIXME: do we need a pll semaphore? */
info("az6007_drxk3913_config_DVBC\n"); adap->fe->sec_priv = adap;
adap->fe = drxk3913_attach(&az6007_drxk3913_config_DVBC, &adap->dev->i2c_adap); sema_init(&st->pll_mutex, 1);
} st->gate_ctrl = adap->fe->ops.i2c_gate_ctrl;
if (adap->fe) { adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
if (mt2063_attach(adap->fe, &az6007_mt2063_config, &adap->dev->i2c_adap)) { adap->fe2->id = 1;
info("found STB6100 DVB-C/DVB-T frontend @0x%02x\n",az6007_mt2063_config.tuner_address);
/* Attach mt2063 to DVB-C frontend */
//vp6027_ci_init(adap); if (adap->fe->ops.i2c_gate_ctrl)
} else { adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
adap->fe = NULL; if (!dvb_attach(mt2063_attach, adap->fe, &az6007_mt2063_config,
} &adap->dev->i2c_adap)) {
} result = -EINVAL;
else
{ goto out_free;
adap->fe = NULL;
err("no front-end attached\n");
} }
//az6007_frontend_tsbypass(adap,0); if (adap->fe->ops.i2c_gate_ctrl)
adap->fe->ops.i2c_gate_ctrl(adap->fe, 0);
/* Hack - needed due to drxk */
adap->fe2->tuner_priv = adap->fe->tuner_priv;
memcpy(&adap->fe2->ops.tuner_ops,
&adap->fe->ops.tuner_ops,
sizeof(adap->fe->ops.tuner_ops));
return 0; return 0;
out_free:
if (adap->fe)
dvb_frontend_detach(adap->fe);
adap->fe = NULL;
adap->fe2 = NULL;
return result;
} }
static struct dvb_usb_device_properties az6007_properties; static struct dvb_usb_device_properties az6007_properties;
...@@ -403,7 +433,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num ...@@ -403,7 +433,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
int length; int length;
u8 req; u8 req;
u8 data[512]; u8 data[512];
if (mutex_lock_interruptible(&d->i2c_mutex) < 0) if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN; return -EAGAIN;
if (num > 2) if (num > 2)
...@@ -442,7 +472,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num ...@@ -442,7 +472,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
//printk("Tuner Tuner ReadDATA len=%d ", len); //printk("Tuner Tuner ReadDATA len=%d ", len);
for (j=0; j<len; j++) for (j=0; j<len; j++)
{ {
msg[1].buf[j] = data[j+5]; msg[1].buf[j] = data[j+5];
//printk("data[%d]=%02x ", j, data[j+5]); //printk("data[%d]=%02x ", j, data[j+5]);
} }
//printk("\n"); //printk("\n");
...@@ -458,13 +488,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num ...@@ -458,13 +488,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
value = msg[0].addr | (1<<8); value = msg[0].addr | (1<<8);
length = msg[0].len - 1; length = msg[0].len - 1;
len = msg[0].len - 1; len = msg[0].len - 1;
//printk("Demodulator WriteDATA len=%d ", len); //printk("Demodulator WriteDATA len=%d ", len);
for(j=0;j<len;j++) for(j=0;j<len;j++)
{ {
data[j] = msg[0].buf[j+1]; data[j] = msg[0].buf[j+1];
//printk("data[%d]=%02x ", j, data[j]); //printk("data[%d]=%02x ", j, data[j]);
} }
//printk("\n"); //printk("\n");
ret = az6007_usb_out_op(d,req,value,index,data,length); ret = az6007_usb_out_op(d,req,value,index,data,length);
} }
else //read else //read
...@@ -479,7 +509,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num ...@@ -479,7 +509,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
//printk("Demodulator ReadDATA len=%d ", len); //printk("Demodulator ReadDATA len=%d ", len);
for (j=0; j<len; j++) for (j=0; j<len; j++)
{ {
msg[0].buf[j] = data[j+5]; msg[0].buf[j] = data[j+5];
//printk("data[%d]=%02x ", j, data[j+5]); //printk("data[%d]=%02x ", j, data[j+5]);
} }
//printk("\n"); //printk("\n");
...@@ -521,10 +551,10 @@ int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_propert ...@@ -521,10 +551,10 @@ int az6007_identify_state(struct usb_device *udev, struct dvb_usb_device_propert
static int az6007_usb_probe(struct usb_interface *intf, static int az6007_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
az6007_led_on_off(intf, 0); az6007_led_on_off(intf, 0);
return dvb_usb_device_init(intf, &az6007_properties, return dvb_usb_device_init(intf, &az6007_properties,
THIS_MODULE, NULL, adapter_nr); THIS_MODULE, NULL, adapter_nr);
} }
static struct usb_device_id az6007_usb_table [] = { static struct usb_device_id az6007_usb_table [] = {
...@@ -569,10 +599,12 @@ static struct dvb_usb_device_properties az6007_properties = { ...@@ -569,10 +599,12 @@ static struct dvb_usb_device_properties az6007_properties = {
//.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_key_map = az6007_rc_keys, .rc.legacy = {
.rc_key_map_size = ARRAY_SIZE(az6007_rc_keys), .rc_map_table = rc_map_az6007_table,
.rc_interval = 400, .rc_map_size = ARRAY_SIZE(rc_map_az6007_table),
.rc_query = az6007_rc_query, .rc_interval = 400,
.rc_query = az6007_rc_query,
},
.i2c_algo = &az6007_i2c_algo, .i2c_algo = &az6007_i2c_algo,
.num_device_descs = 2, .num_device_descs = 2,
...@@ -585,10 +617,10 @@ static struct dvb_usb_device_properties az6007_properties = { ...@@ -585,10 +617,10 @@ static struct dvb_usb_device_properties az6007_properties = {
.cold_ids = { &az6007_usb_table[1], NULL }, .cold_ids = { &az6007_usb_table[1], NULL },
.warm_ids = { NULL }, .warm_ids = { NULL },
}, },
{ NULL }, { NULL },
} }
}; };
/* usb specific object needed to register this driver with the usb subsystem */ /* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver az6007_usb_driver = { static struct usb_driver az6007_usb_driver = {
.name = "dvb_usb_az6007", .name = "dvb_usb_az6007",
......
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