X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmedia%2Fdvb%2Fdvb-usb%2Fdigitv.c;h=b5acb11c0bc95bf0bcacedc1c4db84366553e8b1;hb=refs%2Fheads%2Fvserver;hp=caa1346e3063076c74b5a17dcc1e5f905a254a9a;hpb=76828883507a47dae78837ab5dec5a5b4513c667;p=linux-2.6.git diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index caa1346e3..b5acb11c0 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -48,7 +48,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num struct dvb_usb_device *d = i2c_get_adapdata(adap); int i; - if (down_interruptible(&d->i2c_sem) < 0) + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; if (num > 2) @@ -67,7 +67,7 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num break; } - up(&d->i2c_sem); + mutex_unlock(&d->i2c_mutex); return i; } @@ -83,7 +83,7 @@ static struct i2c_algorithm digitv_i2c_algo = { /* Callbacks for DVB USB */ static int digitv_identify_state (struct usb_device *udev, struct - dvb_usb_properties *props, struct dvb_usb_device_description **desc, + dvb_usb_device_properties *props, struct dvb_usb_device_description **desc, int *cold) { *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0; @@ -112,60 +112,135 @@ static int digitv_mt352_demod_init(struct dvb_frontend *fe) static struct mt352_config digitv_mt352_config = { .demod_init = digitv_mt352_demod_init, - .pll_set = dvb_usb_pll_set, }; -static int digitv_nxt6000_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) +static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) { - struct dvb_usb_device *d = fe->dvb->priv; + struct dvb_usb_adapter *adap = fe->dvb->priv; u8 b[5]; - dvb_usb_pll_set(fe,fep,b); - return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0); + dvb_usb_tuner_calc_regs(fe,fep,b, 5); + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); + return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0); } static struct nxt6000_config digitv_nxt6000_config = { .clock_inversion = 1, - .pll_set = digitv_nxt6000_pll_set, }; -static int digitv_frontend_attach(struct dvb_usb_device *d) +static int digitv_frontend_attach(struct dvb_usb_adapter *adap) { - if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL || - (d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) + if ((adap->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &adap->dev->i2c_adap)) != NULL) { + adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; return 0; + } + if ((adap->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &adap->dev->i2c_adap)) != NULL) { + adap->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; + return 0; + } return -EIO; } -static int digitv_tuner_attach(struct dvb_usb_device *d) +static int digitv_tuner_attach(struct dvb_usb_adapter *adap) { - d->pll_addr = 0x60; - d->pll_desc = &dvb_pll_tded4; + adap->pll_addr = 0x60; + adap->pll_desc = &dvb_pll_tded4; return 0; } static struct dvb_usb_rc_key digitv_rc_keys[] = { - { 0x00, 0x16, KEY_POWER }, /* dummy key */ + { 0x5f, 0x55, KEY_0 }, + { 0x6f, 0x55, KEY_1 }, + { 0x9f, 0x55, KEY_2 }, + { 0xaf, 0x55, KEY_3 }, + { 0x5f, 0x56, KEY_4 }, + { 0x6f, 0x56, KEY_5 }, + { 0x9f, 0x56, KEY_6 }, + { 0xaf, 0x56, KEY_7 }, + { 0x5f, 0x59, KEY_8 }, + { 0x6f, 0x59, KEY_9 }, + { 0x9f, 0x59, KEY_TV }, + { 0xaf, 0x59, KEY_AUX }, + { 0x5f, 0x5a, KEY_DVD }, + { 0x6f, 0x5a, KEY_POWER }, + { 0x9f, 0x5a, KEY_MHP }, /* labelled 'Picture' */ + { 0xaf, 0x5a, KEY_AUDIO }, + { 0x5f, 0x65, KEY_INFO }, + { 0x6f, 0x65, KEY_F13 }, /* 16:9 */ + { 0x9f, 0x65, KEY_F14 }, /* 14:9 */ + { 0xaf, 0x65, KEY_EPG }, + { 0x5f, 0x66, KEY_EXIT }, + { 0x6f, 0x66, KEY_MENU }, + { 0x9f, 0x66, KEY_UP }, + { 0xaf, 0x66, KEY_DOWN }, + { 0x5f, 0x69, KEY_LEFT }, + { 0x6f, 0x69, KEY_RIGHT }, + { 0x9f, 0x69, KEY_ENTER }, + { 0xaf, 0x69, KEY_CHANNELUP }, + { 0x5f, 0x6a, KEY_CHANNELDOWN }, + { 0x6f, 0x6a, KEY_VOLUMEUP }, + { 0x9f, 0x6a, KEY_VOLUMEDOWN }, + { 0xaf, 0x6a, KEY_RED }, + { 0x5f, 0x95, KEY_GREEN }, + { 0x6f, 0x95, KEY_YELLOW }, + { 0x9f, 0x95, KEY_BLUE }, + { 0xaf, 0x95, KEY_SUBTITLE }, + { 0x5f, 0x96, KEY_F15 }, /* AD */ + { 0x6f, 0x96, KEY_TEXT }, + { 0x9f, 0x96, KEY_MUTE }, + { 0xaf, 0x96, KEY_REWIND }, + { 0x5f, 0x99, KEY_STOP }, + { 0x6f, 0x99, KEY_PLAY }, + { 0x9f, 0x99, KEY_FASTFORWARD }, + { 0xaf, 0x99, KEY_F16 }, /* chapter */ + { 0x5f, 0x9a, KEY_PAUSE }, + { 0x6f, 0x9a, KEY_PLAY }, + { 0x9f, 0x9a, KEY_RECORD }, + { 0xaf, 0x9a, KEY_F17 }, /* picture in picture */ + { 0x5f, 0xa5, KEY_KPPLUS }, /* zoom in */ + { 0x6f, 0xa5, KEY_KPMINUS }, /* zoom out */ + { 0x9f, 0xa5, KEY_F18 }, /* capture */ + { 0xaf, 0xa5, KEY_F19 }, /* web */ + { 0x5f, 0xa6, KEY_EMAIL }, + { 0x6f, 0xa6, KEY_PHONE }, + { 0x9f, 0xa6, KEY_PC }, }; -/* TODO is it really the NEC protocol ? */ static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) { + int i; u8 key[5]; + u8 b[4] = { 0 }; + + *event = 0; + *state = REMOTE_NO_KEY_PRESSED; digitv_ctrl_msg(d,USB_READ_REMOTE,0,NULL,0,&key[1],4); - /* TODO state, maybe it is VV ? */ + + /* Tell the device we've read the remote. Not sure how necessary + this is, but the Nebula SDK does it. */ + digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); + + /* if something is inside the buffer, simulate key press */ if (key[1] != 0) - key[0] = 0x01; /* if something is inside the buffer, simulate key press */ + { + for (i = 0; i < d->props.rc_key_map_size; i++) { + if (d->props.rc_key_map[i].custom == key[1] && + d->props.rc_key_map[i].data == key[2]) { + *event = d->props.rc_key_map[i].event; + *state = REMOTE_KEY_PRESSED; + return 0; + } + } + } - /* call the universal NEC remote processor, to find out the key's state and event */ - dvb_usb_nec_rc_key_to_event(d,key,event,state); if (key[0] != 0) deb_rc("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]); return 0; } /* DVB USB Driver stuff */ -static struct dvb_usb_properties digitv_properties; +static struct dvb_usb_device_properties digitv_properties; static int digitv_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -192,38 +267,41 @@ static struct usb_device_id digitv_table [] = { }; MODULE_DEVICE_TABLE (usb, digitv_table); -static struct dvb_usb_properties digitv_properties = { +static struct dvb_usb_device_properties digitv_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-digitv-02.fw", - .size_of_priv = 0, - - .frontend_attach = digitv_frontend_attach, - .tuner_attach = digitv_tuner_attach, + .num_adapters = 1, + .adapter = { + { + .frontend_attach = digitv_frontend_attach, + .tuner_attach = digitv_tuner_attach, + + /* parameter for the MPEG2-data transfer */ + .stream = { + .type = USB_BULK, + .count = 7, + .endpoint = 0x02, + .u = { + .bulk = { + .buffersize = 4096, + } + } + }, + } + }, + .identify_state = digitv_identify_state, .rc_interval = 1000, .rc_key_map = digitv_rc_keys, .rc_key_map_size = ARRAY_SIZE(digitv_rc_keys), .rc_query = digitv_rc_query, - .identify_state = digitv_identify_state, - .i2c_algo = &digitv_i2c_algo, .generic_bulk_ctrl_endpoint = 0x01, - /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, - .count = 7, - .endpoint = 0x02, - .u = { - .bulk = { - .buffersize = 4096, - } - } - }, .num_device_descs = 1, .devices = {