--- zzzz-none-000/linux-3.10.107/drivers/media/usb/au0828/au0828-cards.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/usb/au0828/au0828-cards.c 2021-02-04 17:41:59.000000000 +0000 @@ -36,17 +36,24 @@ au0828_clear(dev, REG_000, 0x10); } +/* + * WARNING: There's a quirks table at sound/usb/quirks-table.h + * that should also be updated every time a new device with V4L2 support + * is added here. + */ struct au0828_board au0828_boards[] = { [AU0828_BOARD_UNKNOWN] = { .name = "Unknown board", - .tuner_type = UNSET, + .tuner_type = -1U, .tuner_addr = ADDR_UNSET, }, [AU0828_BOARD_HAUPPAUGE_HVR850] = { .name = "Hauppauge HVR850", .tuner_type = TUNER_XC5000, .tuner_addr = 0x61, - .i2c_clk_divider = AU0828_I2C_CLK_20KHZ, + .has_ir_i2c = 1, + .has_analog = 1, + .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, .input = { { .type = AU0828_VMUX_TELEVISION, @@ -71,13 +78,9 @@ .name = "Hauppauge HVR950Q", .tuner_type = TUNER_XC5000, .tuner_addr = 0x61, - /* The au0828 hardware i2c implementation does not properly - support the xc5000's i2c clock stretching. So we need to - lower the clock frequency enough where the 15us clock - stretch fits inside of a normal clock cycle, or else the - au0828 fails to set the STOP bit. A 30 KHz clock puts the - clock pulse width at 18us */ - .i2c_clk_divider = AU0828_I2C_CLK_20KHZ, + .has_ir_i2c = 1, + .has_analog = 1, + .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, .input = { { .type = AU0828_VMUX_TELEVISION, @@ -100,20 +103,20 @@ }, [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = { .name = "Hauppauge HVR950Q rev xxF8", - .tuner_type = UNSET, - .tuner_addr = ADDR_UNSET, + .tuner_type = TUNER_XC5000, + .tuner_addr = 0x61, .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, }, [AU0828_BOARD_DVICO_FUSIONHDTV7] = { .name = "DViCO FusionHDTV USB", - .tuner_type = UNSET, - .tuner_addr = ADDR_UNSET, + .tuner_type = TUNER_XC5000, + .tuner_addr = 0x61, .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, }, [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { .name = "Hauppauge Woodbury", - .tuner_type = UNSET, - .tuner_addr = ADDR_UNSET, + .tuner_type = TUNER_NXP_TDA18271, + .tuner_addr = 0x60, .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, }, }; @@ -141,8 +144,7 @@ mdelay(10); return 0; } else { - printk(KERN_ERR - "%s(): Unknown command.\n", __func__); + pr_err("%s(): Unknown command.\n", __func__); return -EINVAL; } break; @@ -176,12 +178,12 @@ case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ break; default: - printk(KERN_WARNING "%s: warning: " - "unknown hauppauge model #%d\n", __func__, tv.model); + pr_warn("%s: warning: unknown hauppauge model #%d\n", + __func__, tv.model); break; } - printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", + pr_info("%s: hauppauge eeprom: model=%d\n", __func__, tv.model); } @@ -193,8 +195,6 @@ dprintk(1, "%s()\n", __func__); - dev->board = au0828_boards[dev->boardnr]; - if (dev->i2c_rc == 0) { dev->i2c_client.addr = 0xa0 >> 1; tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom)); @@ -227,16 +227,16 @@ sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, "au8522", 0x8e >> 1, NULL); if (sd == NULL) - printk(KERN_ERR "analog subdev registration failed\n"); + pr_err("analog subdev registration failed\n"); } /* Setup tuners */ - if (dev->board.tuner_type != TUNER_ABSENT) { + if (dev->board.tuner_type != TUNER_ABSENT && dev->board.has_analog) { /* Load the tuner module, which does the attach */ sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, "tuner", dev->board.tuner_addr, NULL); if (sd == NULL) - printk(KERN_ERR "tuner subdev registration fail\n"); + pr_err("tuner subdev registration fail\n"); tun_setup.mode_mask = mode_mask; tun_setup.type = dev->board.tuner_type; @@ -270,18 +270,25 @@ * 9 - XC5000 Tuner */ - /* Into reset */ + /* Set relevant GPIOs as outputs (leave the EEPROM W/P + as an input since we will never touch it and it has + a pullup) */ au0828_write(dev, REG_003, 0x02); au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10); + + /* Into reset */ au0828_write(dev, REG_001, 0x0); au0828_write(dev, REG_000, 0x0); - msleep(100); + msleep(50); - /* Out of reset (leave the cs5340 in reset until needed) */ - au0828_write(dev, REG_003, 0x02); - au0828_write(dev, REG_001, 0x02); - au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10); - au0828_write(dev, REG_000, 0x80 | 0x40 | 0x20); + /* Bring power supply out of reset */ + au0828_write(dev, REG_000, 0x80); + msleep(50); + + /* Bring xc5000 and au8522 out of reset (leave the + cs5340 in reset until needed) */ + au0828_write(dev, REG_001, 0x02); /* xc5000 */ + au0828_write(dev, REG_000, 0x80 | 0x20); /* PS + au8522 */ msleep(250); break;