Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[pandora-kernel.git] / drivers / media / dvb / dvb-usb / af9015.c
index bf6ff2b..31c0a0e 100644 (file)
@@ -207,12 +207,18 @@ static int af9015_write_reg(struct dvb_usb_device *d, u16 addr, u8 val)
        return af9015_write_regs(d, addr, &val, 1);
 }
 
-static int af9015_read_reg(struct dvb_usb_device *d, u16 addr, u8 *val)
+static int af9015_read_regs(struct dvb_usb_device *d, u16 addr, u8 *val, u8 len)
 {
-       struct req_t req = {READ_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, 1, val};
+       struct req_t req = {READ_MEMORY, AF9015_I2C_DEMOD, addr, 0, 0, len,
+               val};
        return af9015_ctrl_msg(d, &req);
 }
 
+static int af9015_read_reg(struct dvb_usb_device *d, u16 addr, u8 *val)
+{
+       return af9015_read_regs(d, addr, val, 1);
+}
+
 static int af9015_write_reg_i2c(struct dvb_usb_device *d, u8 addr, u16 reg,
        u8 val)
 {
@@ -243,7 +249,7 @@ static int af9015_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
        int ret = 0, i = 0;
        u16 addr;
-       u8 mbox, addr_len;
+       u8 uninitialized_var(mbox), addr_len;
        struct req_t req;
 
 /* TODO: implement bus lock
@@ -282,7 +288,7 @@ Due to that the only way to select correct tuner is use demodulator I2C-gate.
                } else {
                        addr = msg[i].buf[0];
                        addr_len = 1;
-                       mbox = 0;
+                       /* mbox is don't care in that case */
                }
 
                if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
@@ -496,7 +502,8 @@ static int af9015_copy_firmware(struct dvb_usb_device *d)
        /* wait 2nd demodulator ready */
        msleep(100);
 
-       ret = af9015_read_reg_i2c(d, 0x3a, 0x98be, &val);
+       ret = af9015_read_reg_i2c(d,
+               af9015_af9013_config[1].demod_address, 0x98be, &val);
        if (ret)
                goto error;
        else
@@ -599,37 +606,6 @@ free:
        return ret;
 }
 
-static int af9015_download_ir_table(struct dvb_usb_device *d)
-{
-       int i, packets = 0, ret;
-       u16 addr = 0x9a56; /* ir-table start address */
-       struct req_t req = {WRITE_MEMORY, 0, 0, 0, 0, 1, NULL};
-       u8 *data = NULL;
-       deb_info("%s:\n", __func__);
-
-       data = af9015_config.ir_table;
-       packets = af9015_config.ir_table_size;
-
-       /* no remote */
-       if (!packets)
-               goto exit;
-
-       /* load remote ir-table */
-       for (i = 0; i < packets; i++) {
-               req.addr = addr + i;
-               req.data = &data[i];
-               ret = af9015_ctrl_msg(d, &req);
-               if (ret) {
-                       err("ir-table download failed at packet %d with " \
-                               "code %d", i, ret);
-                       return ret;
-               }
-       }
-
-exit:
-       return 0;
-}
-
 static int af9015_init(struct dvb_usb_device *d)
 {
        int ret;
@@ -639,10 +615,6 @@ static int af9015_init(struct dvb_usb_device *d)
        if (ret)
                goto error;
 
-       ret = af9015_download_ir_table(d);
-       if (ret)
-               goto error;
-
 error:
        return ret;
 }
@@ -735,128 +707,102 @@ error:
        return ret;
 }
 
-struct af9015_setup {
+struct af9015_rc_setup {
        unsigned int id;
-       struct ir_scancode *rc_key_map;
-       unsigned int rc_key_map_size;
-       u8 *ir_table;
-       unsigned int ir_table_size;
+       char *rc_codes;
 };
 
-static const struct af9015_setup *af9015_setup_match(unsigned int id,
-               const struct af9015_setup *table)
+static char *af9015_rc_setup_match(unsigned int id,
+       const struct af9015_rc_setup *table)
 {
-       for (; table->rc_key_map; table++)
+       for (; table->rc_codes; table++)
                if (table->id == id)
-                       return table;
+                       return table->rc_codes;
        return NULL;
 }
 
-static const struct af9015_setup af9015_setup_modparam[] = {
-       { AF9015_REMOTE_A_LINK_DTU_M,
-               ir_codes_af9015_table_a_link, ARRAY_SIZE(ir_codes_af9015_table_a_link),
-               af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) },
-       { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
-               ir_codes_af9015_table_msi, ARRAY_SIZE(ir_codes_af9015_table_msi),
-               af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
-       { AF9015_REMOTE_MYGICTV_U718,
-               ir_codes_af9015_table_mygictv, ARRAY_SIZE(ir_codes_af9015_table_mygictv),
-               af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) },
-       { AF9015_REMOTE_DIGITTRADE_DVB_T,
-               ir_codes_af9015_table_digittrade, ARRAY_SIZE(ir_codes_af9015_table_digittrade),
-               af9015_ir_table_digittrade, ARRAY_SIZE(af9015_ir_table_digittrade) },
-       { AF9015_REMOTE_AVERMEDIA_KS,
-               ir_codes_af9015_table_avermedia, ARRAY_SIZE(ir_codes_af9015_table_avermedia),
-               af9015_ir_table_avermedia_ks, ARRAY_SIZE(af9015_ir_table_avermedia_ks) },
+static const struct af9015_rc_setup af9015_rc_setup_modparam[] = {
+       { AF9015_REMOTE_A_LINK_DTU_M, RC_MAP_ALINK_DTU_M },
+       { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3, RC_MAP_MSI_DIGIVOX_II },
+       { AF9015_REMOTE_MYGICTV_U718, RC_MAP_TOTAL_MEDIA_IN_HAND },
+       { AF9015_REMOTE_DIGITTRADE_DVB_T, RC_MAP_DIGITTRADE },
+       { AF9015_REMOTE_AVERMEDIA_KS, RC_MAP_AVERMEDIA_RM_KS },
        { }
 };
 
-/* don't add new entries here anymore, use hashes instead */
-static const struct af9015_setup af9015_setup_usbids[] = {
-       { USB_VID_LEADTEK,
-               ir_codes_af9015_table_leadtek, ARRAY_SIZE(ir_codes_af9015_table_leadtek),
-               af9015_ir_table_leadtek, ARRAY_SIZE(af9015_ir_table_leadtek) },
-       { USB_VID_VISIONPLUS,
-               ir_codes_af9015_table_twinhan, ARRAY_SIZE(ir_codes_af9015_table_twinhan),
-               af9015_ir_table_twinhan, ARRAY_SIZE(af9015_ir_table_twinhan) },
-       { USB_VID_KWORLD_2, /* TODO: use correct rc keys */
-               ir_codes_af9015_table_twinhan, ARRAY_SIZE(ir_codes_af9015_table_twinhan),
-               af9015_ir_table_kworld, ARRAY_SIZE(af9015_ir_table_kworld) },
-       { USB_VID_AVERMEDIA,
-               ir_codes_af9015_table_avermedia, ARRAY_SIZE(ir_codes_af9015_table_avermedia),
-               af9015_ir_table_avermedia, ARRAY_SIZE(af9015_ir_table_avermedia) },
-       { USB_VID_MSI_2,
-               ir_codes_af9015_table_msi_digivox_iii, ARRAY_SIZE(ir_codes_af9015_table_msi_digivox_iii),
-               af9015_ir_table_msi_digivox_iii, ARRAY_SIZE(af9015_ir_table_msi_digivox_iii) },
-       { USB_VID_TERRATEC,
-               ir_codes_terratec, ARRAY_SIZE(ir_codes_terratec),
-               af9015_ir_terratec, ARRAY_SIZE(af9015_ir_terratec) },
+static const struct af9015_rc_setup af9015_rc_setup_hashes[] = {
+       { 0xb8feb708, RC_MAP_MSI_DIGIVOX_II },
+       { 0xa3703d00, RC_MAP_ALINK_DTU_M },
+       { 0x9b7dc64e, RC_MAP_TOTAL_MEDIA_IN_HAND }, /* MYGICTV U718 */
        { }
 };
 
-static const struct af9015_setup af9015_setup_hashes[] = {
-       { 0xb8feb708,
-               ir_codes_af9015_table_msi, ARRAY_SIZE(ir_codes_af9015_table_msi),
-               af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
-       { 0xa3703d00,
-               ir_codes_af9015_table_a_link, ARRAY_SIZE(ir_codes_af9015_table_a_link),
-               af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) },
-       { 0x9b7dc64e,
-               ir_codes_af9015_table_mygictv, ARRAY_SIZE(ir_codes_af9015_table_mygictv),
-               af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) },
+static const struct af9015_rc_setup af9015_rc_setup_usbids[] = {
+       { (USB_VID_TERRATEC << 16) + USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC,
+               RC_MAP_TERRATEC_SLIM },
+       { (USB_VID_VISIONPLUS << 16) + USB_PID_AZUREWAVE_AD_TU700,
+               RC_MAP_AZUREWAVE_AD_TU700 },
+       { (USB_VID_VISIONPLUS << 16) + USB_PID_TINYTWIN,
+               RC_MAP_AZUREWAVE_AD_TU700 },
+       { (USB_VID_MSI_2 << 16) + USB_PID_MSI_DIGI_VOX_MINI_III,
+               RC_MAP_MSI_DIGIVOX_III },
+       { (USB_VID_LEADTEK << 16) + USB_PID_WINFAST_DTV_DONGLE_GOLD,
+               RC_MAP_LEADTEK_Y04G0051 },
+       { (USB_VID_AVERMEDIA << 16) + USB_PID_AVERMEDIA_VOLAR_X,
+               RC_MAP_AVERMEDIA_M135A },
+       { (USB_VID_AFATECH << 16) + USB_PID_TREKSTOR_DVBT,
+               RC_MAP_TREKSTOR },
+       { (USB_VID_KWORLD_2 << 16) + USB_PID_TINYTWIN_2,
+               RC_MAP_DIGITALNOW_TINYTWIN },
+       { (USB_VID_GTEK << 16) + USB_PID_TINYTWIN_3,
+               RC_MAP_DIGITALNOW_TINYTWIN },
        { }
 };
 
 static void af9015_set_remote_config(struct usb_device *udev,
                struct dvb_usb_device_properties *props)
 {
-       const struct af9015_setup *table = NULL;
-
-       if (dvb_usb_af9015_remote) {
-               /* load remote defined as module param */
-               table = af9015_setup_match(dvb_usb_af9015_remote,
-                               af9015_setup_modparam);
-       } else {
-               u16 vendor = le16_to_cpu(udev->descriptor.idVendor);
-
-               table = af9015_setup_match(af9015_config.eeprom_sum,
-                               af9015_setup_hashes);
-
-               if (!table && vendor == USB_VID_AFATECH) {
-                       /* Check USB manufacturer and product strings and try
-                          to determine correct remote in case of chip vendor
-                          reference IDs are used.
-                          DO NOT ADD ANYTHING NEW HERE. Use hashes instead.
-                        */
-                       char manufacturer[10];
-                       memset(manufacturer, 0, sizeof(manufacturer));
-                       usb_string(udev, udev->descriptor.iManufacturer,
-                               manufacturer, sizeof(manufacturer));
-                       if (!strcmp("MSI", manufacturer)) {
-                               /* iManufacturer 1 MSI
-                                  iProduct      2 MSI K-VOX */
-                               table = af9015_setup_match(
-                                       AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
-                                       af9015_setup_modparam);
-                       } else if (udev->descriptor.idProduct ==
-                               cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
-                               table = &(const struct af9015_setup){ 0,
-                                       ir_codes_af9015_table_trekstor,
-                                       ARRAY_SIZE(ir_codes_af9015_table_trekstor),
-                                       af9015_ir_table_trekstor,
-                                       ARRAY_SIZE(af9015_ir_table_trekstor)
-                               };
-                       }
-               } else if (!table)
-                       table = af9015_setup_match(vendor, af9015_setup_usbids);
+       u16 vid = le16_to_cpu(udev->descriptor.idVendor);
+       u16 pid = le16_to_cpu(udev->descriptor.idProduct);
+
+       /* try to load remote based module param */
+       props->rc.core.rc_codes = af9015_rc_setup_match(
+               dvb_usb_af9015_remote, af9015_rc_setup_modparam);
+
+       /* try to load remote based eeprom hash */
+       if (!props->rc.core.rc_codes)
+               props->rc.core.rc_codes = af9015_rc_setup_match(
+                       af9015_config.eeprom_sum, af9015_rc_setup_hashes);
+
+       /* try to load remote based USB ID */
+       if (!props->rc.core.rc_codes)
+               props->rc.core.rc_codes = af9015_rc_setup_match(
+                       (vid << 16) + pid, af9015_rc_setup_usbids);
+
+       /* try to load remote based USB iManufacturer string */
+       if (!props->rc.core.rc_codes && vid == USB_VID_AFATECH) {
+               /* Check USB manufacturer and product strings and try
+                  to determine correct remote in case of chip vendor
+                  reference IDs are used.
+                  DO NOT ADD ANYTHING NEW HERE. Use hashes instead. */
+               char manufacturer[10];
+               memset(manufacturer, 0, sizeof(manufacturer));
+               usb_string(udev, udev->descriptor.iManufacturer,
+                       manufacturer, sizeof(manufacturer));
+               if (!strcmp("MSI", manufacturer)) {
+                       /* iManufacturer 1 MSI
+                          iProduct      2 MSI K-VOX */
+                       props->rc.core.rc_codes = af9015_rc_setup_match(
+                               AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
+                               af9015_rc_setup_modparam);
+               }
        }
 
-       if (table) {
-               props->rc.legacy.rc_key_map = table->rc_key_map;
-               props->rc.legacy.rc_key_map_size = table->rc_key_map_size;
-               af9015_config.ir_table = table->ir_table;
-               af9015_config.ir_table_size = table->ir_table_size;
-       }
+       /* finally load "empty" just for leaving IR receiver enabled */
+       if (!props->rc.core.rc_codes)
+               props->rc.core.rc_codes = RC_MAP_EMPTY;
+
+       return;
 }
 
 static int af9015_read_config(struct usb_device *udev)
@@ -882,10 +828,9 @@ static int af9015_read_config(struct usb_device *udev)
 
        deb_info("%s: IR mode:%d\n", __func__, val);
        for (i = 0; i < af9015_properties_count; i++) {
-               if (val == AF9015_IR_MODE_DISABLED) {
-                       af9015_properties[i].rc.legacy.rc_key_map = NULL;
-                       af9015_properties[i].rc.legacy.rc_key_map_size  = 0;
-               } else
+               if (val == AF9015_IR_MODE_DISABLED)
+                       af9015_properties[i].rc.core.rc_codes = NULL;
+               else
                        af9015_set_remote_config(udev, &af9015_properties[i]);
        }
 
@@ -1024,9 +969,13 @@ error:
                err("eeprom read failed:%d", ret);
 
        /* AverMedia AVerTV Volar Black HD (A850) device have bad EEPROM
-          content :-( Override some wrong values here. */
+          content :-( Override some wrong values here. Ditto for the
+          AVerTV Red HD+ (A850T) device. */
        if (le16_to_cpu(udev->descriptor.idVendor) == USB_VID_AVERMEDIA &&
-           le16_to_cpu(udev->descriptor.idProduct) == USB_PID_AVERMEDIA_A850) {
+               ((le16_to_cpu(udev->descriptor.idProduct) ==
+                       USB_PID_AVERMEDIA_A850) ||
+               (le16_to_cpu(udev->descriptor.idProduct) ==
+                       USB_PID_AVERMEDIA_A850T))) {
                deb_info("%s: AverMedia A850: overriding config\n", __func__);
                /* disable dual mode */
                af9015_config.dual_mode = 0;
@@ -1063,36 +1012,53 @@ static int af9015_identify_state(struct usb_device *udev,
        return ret;
 }
 
-static int af9015_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
+static int af9015_rc_query(struct dvb_usb_device *d)
 {
-       u8 buf[8];
-       struct req_t req = {GET_IR_CODE, 0, 0, 0, 0, sizeof(buf), buf};
-       struct ir_scancode *keymap = d->props.rc.legacy.rc_key_map;
-       int i, ret;
-
-       memset(buf, 0, sizeof(buf));
+       struct af9015_state *priv = d->priv;
+       int ret;
+       u8 buf[16];
 
-       ret = af9015_ctrl_msg(d, &req);
+       /* read registers needed to detect remote controller code */
+       ret = af9015_read_regs(d, 0x98d9, buf, sizeof(buf));
        if (ret)
-               return ret;
+               goto error;
 
-       *event = 0;
-       *state = REMOTE_NO_KEY_PRESSED;
+       if (buf[14] || buf[15]) {
+               deb_rc("%s: key pressed %02x %02x %02x %02x\n", __func__,
+                       buf[12], buf[13], buf[14], buf[15]);
 
-       for (i = 0; i < d->props.rc.legacy.rc_key_map_size; i++) {
-               if (!buf[1] && rc5_custom(&keymap[i]) == buf[0] &&
-                   rc5_data(&keymap[i]) == buf[2]) {
-                       *event = keymap[i].keycode;
-                       *state = REMOTE_KEY_PRESSED;
-                       break;
+               /* clean IR code from mem */
+               ret = af9015_write_regs(d, 0x98e5, "\x00\x00\x00\x00", 4);
+               if (ret)
+                       goto error;
+
+               if (buf[14] == (u8) ~buf[15]) {
+                       if (buf[12] == (u8) ~buf[13]) {
+                               /* NEC */
+                               priv->rc_keycode = buf[12] << 8 | buf[14];
+                       } else {
+                               /* NEC extended*/
+                               priv->rc_keycode = buf[12] << 16 |
+                                       buf[13] << 8 | buf[14];
+                       }
+                       ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
+               } else {
+                       priv->rc_keycode = 0; /* clear just for sure */
                }
+       } else if (priv->rc_repeat != buf[6] || buf[0]) {
+               deb_rc("%s: key repeated\n", __func__);
+               ir_keydown(d->rc_input_dev, priv->rc_keycode, 0);
+       } else {
+               deb_rc("%s: no key press\n", __func__);
        }
-       if (!buf[1])
-               deb_rc("%s: %02x %02x %02x %02x %02x %02x %02x %02x\n",
-                       __func__, buf[0], buf[1], buf[2], buf[3], buf[4],
-                       buf[5], buf[6], buf[7]);
 
-       return 0;
+       priv->rc_repeat = buf[6];
+
+error:
+       if (ret)
+               err("%s: failed:%d", __func__, ret);
+
+       return ret;
 }
 
 /* init 2nd I2C adapter */
@@ -1104,11 +1070,6 @@ static int af9015_i2c_init(struct dvb_usb_device *d)
 
        strncpy(state->i2c_adap.name, d->desc->name,
                sizeof(state->i2c_adap.name));
-#ifdef I2C_ADAP_CLASS_TV_DIGITAL
-       state->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL,
-#else
-       state->i2c_adap.class = I2C_CLASS_TV_DIGITAL,
-#endif
        state->i2c_adap.algo      = d->props.i2c_algo;
        state->i2c_adap.algo_data = NULL;
        state->i2c_adap.dev.parent = &d->udev->dev;
@@ -1170,7 +1131,7 @@ static struct qt1010_config af9015_qt1010_config = {
 
 static struct tda18271_config af9015_tda18271_config = {
        .gate = TDA18271_GATE_DIGITAL,
-       .small_i2c = 1,
+       .small_i2c = TDA18271_16_BYTE_CHUNK_INIT,
 };
 
 static struct mxl5005s_config af9015_mxl5003_config = {
@@ -1227,7 +1188,7 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
        struct af9015_state *state = adap->dev->priv;
        struct i2c_adapter *i2c_adap;
        int ret;
-       deb_info("%s: \n", __func__);
+       deb_info("%s:\n", __func__);
 
        /* select I2C adapter */
        if (adap->id == 0)
@@ -1325,10 +1286,13 @@ static struct usb_device_id af9015_usb_table[] = {
        {USB_DEVICE(USB_VID_TERRATEC,  USB_PID_TERRATEC_CINERGY_T_STICK_RC)},
        {USB_DEVICE(USB_VID_TERRATEC,
                USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC)},
+/* 35 */{USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850T)},
+       {USB_DEVICE(USB_VID_GTEK,      USB_PID_TINYTWIN_3)},
        {0},
 };
 MODULE_DEVICE_TABLE(usb, af9015_usb_table);
 
+#define AF9015_RC_INTERVAL 500
 static struct dvb_usb_device_properties af9015_properties[] = {
        {
                .caps = DVB_USB_IS_AN_I2C_ADAPTER,
@@ -1379,14 +1343,19 @@ static struct dvb_usb_device_properties af9015_properties[] = {
 
                .identify_state = af9015_identify_state,
 
-               .rc.legacy = {
+               .rc.core = {
+                       .protocol         = IR_TYPE_NEC,
+                       .module_name      = "af9015",
                        .rc_query         = af9015_rc_query,
-                       .rc_interval      = 150,
+                       .rc_interval      = AF9015_RC_INTERVAL,
+                       .rc_props = {
+                               .allowed_protos = IR_TYPE_NEC,
+                       },
                },
 
                .i2c_algo = &af9015_i2c_algo,
 
-               .num_device_descs = 11, /* check max from dvb-usb.h */
+               .num_device_descs = 12, /* check max from dvb-usb.h */
                .devices = {
                        {
                                .name = "Afatech AF9015 DVB-T USB2.0 stick",
@@ -1414,7 +1383,8 @@ static struct dvb_usb_device_properties af9015_properties[] = {
                        {
                                .name = "DigitalNow TinyTwin DVB-T Receiver",
                                .cold_ids = {&af9015_usb_table[5],
-                                            &af9015_usb_table[28], NULL},
+                                            &af9015_usb_table[28],
+                                            &af9015_usb_table[36], NULL},
                                .warm_ids = {NULL},
                        },
                        {
@@ -1448,6 +1418,11 @@ static struct dvb_usb_device_properties af9015_properties[] = {
                                .cold_ids = {&af9015_usb_table[34], NULL},
                                .warm_ids = {NULL},
                        },
+                       {
+                               .name = "AverMedia AVerTV Red HD+ (A850T)",
+                               .cold_ids = {&af9015_usb_table[35], NULL},
+                               .warm_ids = {NULL},
+                       },
                }
        }, {
                .caps = DVB_USB_IS_AN_I2C_ADAPTER,
@@ -1498,9 +1473,14 @@ static struct dvb_usb_device_properties af9015_properties[] = {
 
                .identify_state = af9015_identify_state,
 
-               .rc.legacy = {
+               .rc.core = {
+                       .protocol         = IR_TYPE_NEC,
+                       .module_name      = "af9015",
                        .rc_query         = af9015_rc_query,
-                       .rc_interval      = 150,
+                       .rc_interval      = AF9015_RC_INTERVAL,
+                       .rc_props = {
+                               .allowed_protos = IR_TYPE_NEC,
+                       },
                },
 
                .i2c_algo = &af9015_i2c_algo,
@@ -1607,9 +1587,14 @@ static struct dvb_usb_device_properties af9015_properties[] = {
 
                .identify_state = af9015_identify_state,
 
-               .rc.legacy = {
+               .rc.core = {
+                       .protocol         = IR_TYPE_NEC,
+                       .module_name      = "af9015",
                        .rc_query         = af9015_rc_query,
-                       .rc_interval      = 150,
+                       .rc_interval      = AF9015_RC_INTERVAL,
+                       .rc_props = {
+                               .allowed_protos = IR_TYPE_NEC,
+                       },
                },
 
                .i2c_algo = &af9015_i2c_algo,
@@ -1707,7 +1692,7 @@ static int af9015_usb_probe(struct usb_interface *intf,
 static void af9015_i2c_exit(struct dvb_usb_device *d)
 {
        struct af9015_state *state = d->priv;
-       deb_info("%s: \n", __func__);
+       deb_info("%s:\n", __func__);
 
        /* remove 2nd I2C adapter */
        if (d->state & DVB_USB_STATE_I2C)
@@ -1717,7 +1702,7 @@ static void af9015_i2c_exit(struct dvb_usb_device *d)
 static void af9015_usb_device_exit(struct usb_interface *intf)
 {
        struct dvb_usb_device *d = usb_get_intfdata(intf);
-       deb_info("%s: \n", __func__);
+       deb_info("%s:\n", __func__);
 
        /* remove 2nd I2C adapter */
        if (d != NULL && d->desc != NULL)