--- zzzz-none-000/linux-3.10.107/drivers/media/usb/cx231xx/cx231xx-core.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/usb/cx231xx/cx231xx-core.c 2021-02-04 17:41:59.000000000 +0000 @@ -20,16 +20,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "cx231xx.h" #include #include #include #include -#include #include #include #include -#include "cx231xx.h" #include "cx231xx-reg.h" /* #define ENABLE_DEBUG_ISOC_FRAMES */ @@ -99,10 +98,10 @@ mutex_lock(&cx231xx_devlist_mutex); list_add_tail(&ops->next, &cx231xx_extension_devlist); - list_for_each_entry(dev, &cx231xx_devlist, devlist) + list_for_each_entry(dev, &cx231xx_devlist, devlist) { ops->init(dev); - - printk(KERN_INFO DRIVER_NAME ": %s initialized\n", ops->name); + dev_info(dev->dev, "%s initialized\n", ops->name); + } mutex_unlock(&cx231xx_devlist_mutex); return 0; } @@ -113,11 +112,11 @@ struct cx231xx *dev = NULL; mutex_lock(&cx231xx_devlist_mutex); - list_for_each_entry(dev, &cx231xx_devlist, devlist) + list_for_each_entry(dev, &cx231xx_devlist, devlist) { ops->fini(dev); + dev_info(dev->dev, "%s removed\n", ops->name); + } - - printk(KERN_INFO DRIVER_NAME ": %s removed\n", ops->name); list_del(&ops->next); mutex_unlock(&cx231xx_devlist_mutex); } @@ -177,16 +176,9 @@ saddr_len = req_data->saddr_len; /* Set wValue */ - if (saddr_len == 1) /* need check saddr_len == 0 */ - ven_req.wValue = - req_data-> - dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | - _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; - else - ven_req.wValue = - req_data-> - dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | - _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; + ven_req.wValue = (req_data->dev_addr << 9 | _i2c_period << 4 | + saddr_len << 2 | _i2c_nostop << 1 | I2C_SYNC | + _i2c_reserve << 6); /* set channel number */ if (req_data->direction & I2C_M_RD) { @@ -227,10 +219,9 @@ /* call common vendor command request */ status = cx231xx_send_vendor_cmd(dev, &ven_req); - if (status < 0) { - cx231xx_info - ("UsbInterface::sendCommand, failed with status -%d\n", - status); + if (status < 0 && !dev->i2c_scan_running) { + dev_err(dev->dev, "%s: failed with status -%d\n", + __func__, status); } return status; @@ -524,9 +515,9 @@ usb_set_interface(dev->udev, usb_interface_index, dev->video_mode.alt); if (errCode < 0) { - cx231xx_errdev - ("cannot change alt number to %d (error=%i)\n", - dev->video_mode.alt, errCode); + dev_err(dev->dev, + "cannot change alt number to %d (error=%i)\n", + dev->video_mode.alt, errCode); return errCode; } } @@ -600,9 +591,9 @@ } if (alt > 0 && max_pkt_size == 0) { - cx231xx_errdev - ("can't change interface %d alt no. to %d: Max. Pkt size = 0\n", - usb_interface_index, alt); + dev_err(dev->dev, + "can't change interface %d alt no. to %d: Max. Pkt size = 0\n", + usb_interface_index, alt); /*To workaround error number=-71 on EP0 for videograbber, need add following codes.*/ if (dev->board.no_alt_vanc) @@ -616,9 +607,9 @@ if (usb_interface_index > 0) { status = usb_set_interface(dev->udev, usb_interface_index, alt); if (status < 0) { - cx231xx_errdev - ("can't change interface %d alt no. to %d (err=%i)\n", - usb_interface_index, alt, status); + dev_err(dev->dev, + "can't change interface %d alt no. to %d (err=%i)\n", + usb_interface_index, alt, status); return status; } } @@ -662,22 +653,20 @@ cx231xx_coredbg("Enter cx231xx_demod_reset()\n"); - value[1] = (u8) 0x3; - status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, - PWR_CTL_EN, value, 4); - msleep(10); - - value[1] = (u8) 0x0; - status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, - PWR_CTL_EN, value, 4); - msleep(10); - - value[1] = (u8) 0x3; - status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, - PWR_CTL_EN, value, 4); - msleep(10); - - + value[1] = (u8) 0x3; + status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, + PWR_CTL_EN, value, 4); + msleep(10); + + value[1] = (u8) 0x0; + status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, + PWR_CTL_EN, value, 4); + msleep(10); + + value[1] = (u8) 0x3; + status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, + PWR_CTL_EN, value, 4); + msleep(10); status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, 4); @@ -727,6 +716,7 @@ errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); break; case CX231XX_BOARD_HAUPPAUGE_EXETER: + case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx: errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_DIGITAL); break; @@ -745,6 +735,7 @@ case CX231XX_BOARD_CNXT_RDE_253S: case CX231XX_BOARD_CNXT_RDU_253S: case CX231XX_BOARD_HAUPPAUGE_EXETER: + case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx: case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: @@ -766,18 +757,17 @@ u32 *buffer; buffer = kzalloc(4096, GFP_KERNEL); - if (buffer == NULL) { - cx231xx_info("out of mem\n"); + if (buffer == NULL) return -ENOMEM; - } memcpy(&buffer[0], firmware, 4096); ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5), buffer, 4096, &actlen, 2000); if (ret) - cx231xx_info("bulk message failed: %d (%d/%d)", ret, - size, actlen); + dev_err(dev->dev, + "bulk message failed: %d (%d/%d)", ret, + size, actlen); else { errCode = actlen != size ? -1 : 0; } @@ -986,12 +976,8 @@ cx231xx_uninit_isoc(dev); dma_q->p_left_data = kzalloc(4096, GFP_KERNEL); - if (dma_q->p_left_data == NULL) { - cx231xx_info("out of mem\n"); + if (dma_q->p_left_data == NULL) return -ENOMEM; - } - - dev->video_mode.isoc_ctl.isoc_copy = isoc_copy; dev->video_mode.isoc_ctl.num_bufs = num_bufs; @@ -1017,14 +1003,16 @@ dev->video_mode.isoc_ctl.urb = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.isoc_ctl.urb) { - cx231xx_errdev("cannot alloc memory for usb buffers\n"); + dev_err(dev->dev, + "cannot alloc memory for usb buffers\n"); return -ENOMEM; } dev->video_mode.isoc_ctl.transfer_buffer = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.isoc_ctl.transfer_buffer) { - cx231xx_errdev("cannot allocate memory for usbtransfer\n"); + dev_err(dev->dev, + "cannot allocate memory for usbtransfer\n"); kfree(dev->video_mode.isoc_ctl.urb); return -ENOMEM; } @@ -1044,7 +1032,8 @@ for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { urb = usb_alloc_urb(max_packets, GFP_KERNEL); if (!urb) { - cx231xx_err("cannot alloc isoc_ctl.urb %i\n", i); + dev_err(dev->dev, + "cannot alloc isoc_ctl.urb %i\n", i); cx231xx_uninit_isoc(dev); return -ENOMEM; } @@ -1054,10 +1043,10 @@ usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, &urb->transfer_dma); if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) { - cx231xx_err("unable to allocate %i bytes for transfer" - " buffer %i%s\n", - sb_size, i, - in_interrupt() ? " while in int" : ""); + dev_err(dev->dev, + "unable to allocate %i bytes for transfer buffer %i%s\n", + sb_size, i, + in_interrupt() ? " while in int" : ""); cx231xx_uninit_isoc(dev); return -ENOMEM; } @@ -1089,8 +1078,9 @@ rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i], GFP_ATOMIC); if (rc) { - cx231xx_err("submit of urb %i failed (error=%i)\n", i, - rc); + dev_err(dev->dev, + "submit of urb %i failed (error=%i)\n", i, + rc); cx231xx_uninit_isoc(dev); return rc; } @@ -1150,14 +1140,16 @@ dev->video_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.bulk_ctl.urb) { - cx231xx_errdev("cannot alloc memory for usb buffers\n"); + dev_err(dev->dev, + "cannot alloc memory for usb buffers\n"); return -ENOMEM; } dev->video_mode.bulk_ctl.transfer_buffer = kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); if (!dev->video_mode.bulk_ctl.transfer_buffer) { - cx231xx_errdev("cannot allocate memory for usbtransfer\n"); + dev_err(dev->dev, + "cannot allocate memory for usbtransfer\n"); kfree(dev->video_mode.bulk_ctl.urb); return -ENOMEM; } @@ -1177,7 +1169,8 @@ for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) { - cx231xx_err("cannot alloc bulk_ctl.urb %i\n", i); + dev_err(dev->dev, + "cannot alloc bulk_ctl.urb %i\n", i); cx231xx_uninit_bulk(dev); return -ENOMEM; } @@ -1188,10 +1181,10 @@ usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, &urb->transfer_dma); if (!dev->video_mode.bulk_ctl.transfer_buffer[i]) { - cx231xx_err("unable to allocate %i bytes for transfer" - " buffer %i%s\n", - sb_size, i, - in_interrupt() ? " while in int" : ""); + dev_err(dev->dev, + "unable to allocate %i bytes for transfer buffer %i%s\n", + sb_size, i, + in_interrupt() ? " while in int" : ""); cx231xx_uninit_bulk(dev); return -ENOMEM; } @@ -1211,8 +1204,8 @@ rc = usb_submit_urb(dev->video_mode.bulk_ctl.urb[i], GFP_ATOMIC); if (rc) { - cx231xx_err("submit of urb %i failed (error=%i)\n", i, - rc); + dev_err(dev->dev, + "submit of urb %i failed (error=%i)\n", i, rc); cx231xx_uninit_bulk(dev); return rc; } @@ -1299,6 +1292,15 @@ cx231xx_i2c_register(&dev->i2c_bus[1]); cx231xx_i2c_register(&dev->i2c_bus[2]); + cx231xx_i2c_mux_register(dev, 0); + cx231xx_i2c_mux_register(dev, 1); + + /* scan the real bus segments in the order of physical port numbers */ + cx231xx_do_i2c_scan(dev, I2C_0); + cx231xx_do_i2c_scan(dev, I2C_1_MUX_1); + cx231xx_do_i2c_scan(dev, I2C_2); + cx231xx_do_i2c_scan(dev, I2C_1_MUX_3); + /* init hardware */ /* Note : with out calling set power mode function, afe can not be set up correctly */ @@ -1306,18 +1308,18 @@ errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_ENXTERNAL_AV); if (errCode < 0) { - cx231xx_errdev - ("%s: Failed to set Power - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: Failed to set Power - errCode [%d]!\n", + __func__, errCode); return errCode; } } else { errCode = cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV); if (errCode < 0) { - cx231xx_errdev - ("%s: Failed to set Power - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: Failed to set Power - errCode [%d]!\n", + __func__, errCode); return errCode; } } @@ -1330,42 +1332,43 @@ /* initialize Colibri block */ errCode = cx231xx_afe_init_super_block(dev, 0x23c); if (errCode < 0) { - cx231xx_errdev - ("%s: cx231xx_afe init super block - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: cx231xx_afe init super block - errCode [%d]!\n", + __func__, errCode); return errCode; } errCode = cx231xx_afe_init_channels(dev); if (errCode < 0) { - cx231xx_errdev - ("%s: cx231xx_afe init channels - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: cx231xx_afe init channels - errCode [%d]!\n", + __func__, errCode); return errCode; } /* Set DIF in By pass mode */ errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); if (errCode < 0) { - cx231xx_errdev - ("%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", + __func__, errCode); return errCode; } /* I2S block related functions */ errCode = cx231xx_i2s_blk_initialize(dev); if (errCode < 0) { - cx231xx_errdev - ("%s: cx231xx_i2s block initialize - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: cx231xx_i2s block initialize - errCode [%d]!\n", + __func__, errCode); return errCode; } /* init control pins */ errCode = cx231xx_init_ctrl_pin_status(dev); if (errCode < 0) { - cx231xx_errdev("%s: cx231xx_init ctrl pins - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: cx231xx_init ctrl pins - errCode [%d]!\n", + __func__, errCode); return errCode; } @@ -1380,6 +1383,7 @@ case CX231XX_BOARD_CNXT_RDE_253S: case CX231XX_BOARD_CNXT_RDU_253S: case CX231XX_BOARD_HAUPPAUGE_EXETER: + case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx: case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: @@ -1389,9 +1393,9 @@ break; } if (errCode < 0) { - cx231xx_errdev - ("%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", - __func__, errCode); + dev_err(dev->dev, + "%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", + __func__, errCode); return errCode; } @@ -1402,9 +1406,7 @@ if (dev->board.has_dvb) cx231xx_set_alt_setting(dev, INDEX_TS1, 0); - /* set the I2C master port to 3 on channel 1 */ - errCode = cx231xx_enable_i2c_port_3(dev, true); - + errCode = 0; return errCode; } EXPORT_SYMBOL_GPL(cx231xx_dev_init); @@ -1412,6 +1414,8 @@ void cx231xx_dev_uninit(struct cx231xx *dev) { /* Un Initialize I2C bus */ + cx231xx_i2c_mux_unregister(dev, 1); + cx231xx_i2c_mux_unregister(dev, 0); cx231xx_i2c_unregister(&dev->i2c_bus[2]); cx231xx_i2c_unregister(&dev->i2c_bus[1]); cx231xx_i2c_unregister(&dev->i2c_bus[0]); @@ -1466,9 +1470,8 @@ /* call common vendor command request */ status = cx231xx_send_vendor_cmd(dev, &ven_req); if (status < 0) { - cx231xx_info - ("UsbInterface::sendCommand, failed with status -%d\n", - status); + dev_err(dev->dev, "%s: failed with status -%d\n", + __func__, status); } return status; @@ -1489,7 +1492,7 @@ if (status < 0) return status; - tmp = le32_to_cpu(*((u32 *) value)); + tmp = le32_to_cpu(*((__le32 *) value)); tmp |= mode; value[0] = (u8) tmp;