.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * |
---|
3 | | - * |
---|
4 | 4 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | 5 | */ |
---|
16 | 6 | |
---|
17 | 7 | #include <linux/errno.h> |
---|
.. | .. |
---|
316 | 306 | {FX2CMD_ONAIR_DTV_STREAMING_OFF, "onair dtv stream off"}, |
---|
317 | 307 | {FX2CMD_ONAIR_DTV_POWER_ON, "onair dtv power on"}, |
---|
318 | 308 | {FX2CMD_ONAIR_DTV_POWER_OFF, "onair dtv power off"}, |
---|
| 309 | + {FX2CMD_HCW_DEMOD_RESET_PIN, "hcw demod reset pin"}, |
---|
| 310 | + {FX2CMD_HCW_MAKO_SLEEP_PIN, "hcw mako sleep pin"}, |
---|
319 | 311 | }; |
---|
320 | 312 | |
---|
321 | 313 | |
---|
.. | .. |
---|
668 | 660 | { |
---|
669 | 661 | if (v < 0 || v > PVR2_CVAL_INPUT_MAX) |
---|
670 | 662 | return 0; |
---|
671 | | - return ((1 << v) & cptr->hdw->input_allowed_mask) != 0; |
---|
| 663 | + return ((1UL << v) & cptr->hdw->input_allowed_mask) != 0; |
---|
672 | 664 | } |
---|
673 | 665 | |
---|
674 | 666 | static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v) |
---|
.. | .. |
---|
792 | 784 | |
---|
793 | 785 | static unsigned int ctrl_cx2341x_getv4lflags(struct pvr2_ctrl *cptr) |
---|
794 | 786 | { |
---|
795 | | - struct v4l2_queryctrl qctrl; |
---|
| 787 | + struct v4l2_queryctrl qctrl = {}; |
---|
796 | 788 | struct pvr2_ctl_info *info; |
---|
797 | 789 | qctrl.id = cptr->info->v4l_id; |
---|
798 | 790 | cx2341x_ctrl_query(&cptr->hdw->enc_ctl_state,&qctrl); |
---|
.. | .. |
---|
872 | 864 | const char *bufPtr,unsigned int bufSize, |
---|
873 | 865 | int *mskp,int *valp) |
---|
874 | 866 | { |
---|
875 | | - int ret; |
---|
876 | 867 | v4l2_std_id id; |
---|
877 | | - ret = pvr2_std_str_to_id(&id,bufPtr,bufSize); |
---|
878 | | - if (ret < 0) return ret; |
---|
| 868 | + if (!pvr2_std_str_to_id(&id, bufPtr, bufSize)) |
---|
| 869 | + return -EINVAL; |
---|
879 | 870 | if (mskp) *mskp = id; |
---|
880 | 871 | if (valp) *valp = id; |
---|
881 | 872 | return 0; |
---|
.. | .. |
---|
1700 | 1691 | if (!hdw->flag_tripped) return 0; |
---|
1701 | 1692 | hdw->flag_tripped = 0; |
---|
1702 | 1693 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
---|
1703 | | - "Clearing driver error statuss"); |
---|
| 1694 | + "Clearing driver error status"); |
---|
1704 | 1695 | return !0; |
---|
1705 | 1696 | } |
---|
1706 | 1697 | |
---|
.. | .. |
---|
2139 | 2130 | ((0) << 16)); |
---|
2140 | 2131 | } |
---|
2141 | 2132 | |
---|
2142 | | - // This step MUST happen after the earlier powerup step. |
---|
| 2133 | + /* This step MUST happen after the earlier powerup step */ |
---|
2143 | 2134 | pvr2_i2c_core_init(hdw); |
---|
2144 | 2135 | if (!pvr2_hdw_dev_ok(hdw)) return; |
---|
| 2136 | + |
---|
| 2137 | + /* Reset demod only on Hauppauge 160xxx platform */ |
---|
| 2138 | + if (le16_to_cpu(hdw->usb_dev->descriptor.idVendor) == 0x2040 && |
---|
| 2139 | + (le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7502 || |
---|
| 2140 | + le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7510)) { |
---|
| 2141 | + pr_info("%s(): resetting 160xxx demod\n", __func__); |
---|
| 2142 | + /* TODO: not sure this is proper place to reset once only */ |
---|
| 2143 | + pvr2_issue_simple_cmd(hdw, |
---|
| 2144 | + FX2CMD_HCW_DEMOD_RESET_PIN | |
---|
| 2145 | + (1 << 8) | |
---|
| 2146 | + ((0) << 16)); |
---|
| 2147 | + usleep_range(10000, 10500); |
---|
| 2148 | + pvr2_issue_simple_cmd(hdw, |
---|
| 2149 | + FX2CMD_HCW_DEMOD_RESET_PIN | |
---|
| 2150 | + (1 << 8) | |
---|
| 2151 | + ((1) << 16)); |
---|
| 2152 | + usleep_range(10000, 10500); |
---|
| 2153 | + } |
---|
2145 | 2154 | |
---|
2146 | 2155 | pvr2_hdw_load_modules(hdw); |
---|
2147 | 2156 | if (!pvr2_hdw_dev_ok(hdw)) return; |
---|
.. | .. |
---|
2435 | 2444 | /* Ensure that default input choice is a valid one. */ |
---|
2436 | 2445 | m = hdw->input_avail_mask; |
---|
2437 | 2446 | if (m) for (idx = 0; idx < (sizeof(m) << 3); idx++) { |
---|
2438 | | - if (!((1 << idx) & m)) continue; |
---|
| 2447 | + if (!((1UL << idx) & m)) continue; |
---|
2439 | 2448 | hdw->input_val = idx; |
---|
2440 | 2449 | break; |
---|
2441 | 2450 | } |
---|
.. | .. |
---|
2461 | 2470 | if (!(qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)) { |
---|
2462 | 2471 | ciptr->set_value = ctrl_cx2341x_set; |
---|
2463 | 2472 | } |
---|
2464 | | - strncpy(hdw->mpeg_ctrl_info[idx].desc,qctrl.name, |
---|
2465 | | - PVR2_CTLD_INFO_DESC_SIZE); |
---|
2466 | | - hdw->mpeg_ctrl_info[idx].desc[PVR2_CTLD_INFO_DESC_SIZE-1] = 0; |
---|
| 2473 | + strscpy(hdw->mpeg_ctrl_info[idx].desc, qctrl.name, |
---|
| 2474 | + sizeof(hdw->mpeg_ctrl_info[idx].desc)); |
---|
2467 | 2475 | ciptr->default_value = qctrl.default_value; |
---|
2468 | 2476 | switch (qctrl.type) { |
---|
2469 | 2477 | default: |
---|
.. | .. |
---|
2492 | 2500 | // Initialize control data regarding video standard masks |
---|
2493 | 2501 | valid_std_mask = pvr2_std_get_usable(); |
---|
2494 | 2502 | for (idx = 0; idx < 32; idx++) { |
---|
2495 | | - if (!(valid_std_mask & (1 << idx))) continue; |
---|
| 2503 | + if (!(valid_std_mask & (1UL << idx))) continue; |
---|
2496 | 2504 | cnt1 = pvr2_std_id_to_str( |
---|
2497 | 2505 | hdw->std_mask_names[idx], |
---|
2498 | 2506 | sizeof(hdw->std_mask_names[idx])-1, |
---|
2499 | | - 1 << idx); |
---|
| 2507 | + 1UL << idx); |
---|
2500 | 2508 | hdw->std_mask_names[idx][cnt1] = 0; |
---|
2501 | 2509 | } |
---|
2502 | 2510 | cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDAVAIL); |
---|
.. | .. |
---|
2561 | 2569 | } while (0); |
---|
2562 | 2570 | mutex_unlock(&pvr2_unit_mtx); |
---|
2563 | 2571 | |
---|
| 2572 | + INIT_WORK(&hdw->workpoll, pvr2_hdw_worker_poll); |
---|
| 2573 | + |
---|
| 2574 | + if (hdw->unit_number == -1) |
---|
| 2575 | + goto fail; |
---|
| 2576 | + |
---|
2564 | 2577 | cnt1 = 0; |
---|
2565 | 2578 | cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); |
---|
2566 | 2579 | cnt1 += cnt2; |
---|
.. | .. |
---|
2571 | 2584 | } |
---|
2572 | 2585 | if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1; |
---|
2573 | 2586 | hdw->name[cnt1] = 0; |
---|
2574 | | - |
---|
2575 | | - INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll); |
---|
2576 | 2587 | |
---|
2577 | 2588 | pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s", |
---|
2578 | 2589 | hdw->unit_number,hdw->name); |
---|
.. | .. |
---|
2599 | 2610 | del_timer_sync(&hdw->encoder_run_timer); |
---|
2600 | 2611 | del_timer_sync(&hdw->encoder_wait_timer); |
---|
2601 | 2612 | flush_work(&hdw->workpoll); |
---|
| 2613 | + v4l2_device_unregister(&hdw->v4l2_dev); |
---|
2602 | 2614 | usb_free_urb(hdw->ctl_read_urb); |
---|
2603 | 2615 | usb_free_urb(hdw->ctl_write_urb); |
---|
2604 | 2616 | kfree(hdw->ctl_read_buffer); |
---|
.. | .. |
---|
3295 | 3307 | int nr = pvr2_hdw_get_unit_number(hdw); |
---|
3296 | 3308 | LOCK_TAKE(hdw->big_lock); |
---|
3297 | 3309 | do { |
---|
3298 | | - printk(KERN_INFO "pvrusb2: ================= START STATUS CARD #%d =================\n", nr); |
---|
| 3310 | + pr_info("pvrusb2: ================= START STATUS CARD #%d =================\n", nr); |
---|
3299 | 3311 | v4l2_device_call_all(&hdw->v4l2_dev, 0, core, log_status); |
---|
3300 | 3312 | pvr2_trace(PVR2_TRACE_INFO,"cx2341x config:"); |
---|
3301 | 3313 | cx2341x_log_status(&hdw->enc_ctl_state, "pvrusb2"); |
---|
3302 | 3314 | pvr2_hdw_state_log_state(hdw); |
---|
3303 | | - printk(KERN_INFO "pvrusb2: ================== END STATUS CARD #%d ==================\n", nr); |
---|
| 3315 | + pr_info("pvrusb2: ================== END STATUS CARD #%d ==================\n", nr); |
---|
3304 | 3316 | } while (0); |
---|
3305 | 3317 | LOCK_GIVE(hdw->big_lock); |
---|
3306 | 3318 | } |
---|
.. | .. |
---|
3320 | 3332 | int ret; |
---|
3321 | 3333 | int mode16 = 0; |
---|
3322 | 3334 | unsigned pcnt,tcnt; |
---|
3323 | | - eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL); |
---|
| 3335 | + eeprom = kzalloc(EEPROM_SIZE, GFP_KERNEL); |
---|
3324 | 3336 | if (!eeprom) { |
---|
3325 | 3337 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
---|
3326 | 3338 | "Failed to allocate memory required to read eeprom"); |
---|
.. | .. |
---|
3355 | 3367 | (1) we're only fetching part of the eeprom, and (2) if we were |
---|
3356 | 3368 | getting the whole thing our I2C driver can't grab it in one |
---|
3357 | 3369 | pass - which is what tveeprom is otherwise going to attempt */ |
---|
3358 | | - memset(eeprom,0,EEPROM_SIZE); |
---|
3359 | 3370 | for (tcnt = 0; tcnt < EEPROM_SIZE; tcnt += pcnt) { |
---|
3360 | 3371 | pcnt = 16; |
---|
3361 | 3372 | if (pcnt + tcnt > EEPROM_SIZE) pcnt = EEPROM_SIZE-tcnt; |
---|
.. | .. |
---|
4013 | 4024 | static int pvr2_hdw_cmd_hcw_demod_reset(struct pvr2_hdw *hdw, int onoff) |
---|
4014 | 4025 | { |
---|
4015 | 4026 | hdw->flag_ok = !0; |
---|
| 4027 | + |
---|
| 4028 | + /* Use this for Hauppauge 160xxx only */ |
---|
| 4029 | + if (le16_to_cpu(hdw->usb_dev->descriptor.idVendor) == 0x2040 && |
---|
| 4030 | + (le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7502 || |
---|
| 4031 | + le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7510)) { |
---|
| 4032 | + pr_debug("%s(): resetting demod on Hauppauge 160xxx platform skipped\n", |
---|
| 4033 | + __func__); |
---|
| 4034 | + /* Can't reset 160xxx or it will trash Demod tristate */ |
---|
| 4035 | + return pvr2_issue_simple_cmd(hdw, |
---|
| 4036 | + FX2CMD_HCW_MAKO_SLEEP_PIN | |
---|
| 4037 | + (1 << 8) | |
---|
| 4038 | + ((onoff ? 1 : 0) << 16)); |
---|
| 4039 | + } |
---|
| 4040 | + |
---|
4016 | 4041 | return pvr2_issue_simple_cmd(hdw, |
---|
4017 | 4042 | FX2CMD_HCW_DEMOD_RESETIN | |
---|
4018 | 4043 | (1 << 8) | |
---|
.. | .. |
---|
4650 | 4675 | unsigned int idx,ccnt; |
---|
4651 | 4676 | unsigned int tcnt = 0; |
---|
4652 | 4677 | for (idx = 0; idx < ARRAY_SIZE(control_values_input); idx++) { |
---|
4653 | | - if (!((1 << idx) & msk)) continue; |
---|
| 4678 | + if (!((1UL << idx) & msk)) continue; |
---|
4654 | 4679 | ccnt = scnprintf(buf+tcnt, |
---|
4655 | 4680 | acnt-tcnt, |
---|
4656 | 4681 | "%s%s", |
---|
.. | .. |
---|
4853 | 4878 | for (idx = 0; ; idx++) { |
---|
4854 | 4879 | ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,sizeof(buf)); |
---|
4855 | 4880 | if (!ccnt) break; |
---|
4856 | | - printk(KERN_INFO "%s %.*s\n",hdw->name,ccnt,buf); |
---|
| 4881 | + pr_info("%s %.*s\n", hdw->name, ccnt, buf); |
---|
4857 | 4882 | } |
---|
4858 | 4883 | ccnt = pvr2_hdw_report_clients(hdw, buf, sizeof(buf)); |
---|
4859 | 4884 | if (ccnt >= sizeof(buf)) |
---|
.. | .. |
---|
4865 | 4890 | while ((lcnt + ucnt < ccnt) && (buf[lcnt + ucnt] != '\n')) { |
---|
4866 | 4891 | lcnt++; |
---|
4867 | 4892 | } |
---|
4868 | | - printk(KERN_INFO "%s %.*s\n", hdw->name, lcnt, buf + ucnt); |
---|
| 4893 | + pr_info("%s %.*s\n", hdw->name, lcnt, buf + ucnt); |
---|
4869 | 4894 | ucnt += lcnt + 1; |
---|
4870 | 4895 | } |
---|
4871 | 4896 | } |
---|
.. | .. |
---|
5077 | 5102 | break; |
---|
5078 | 5103 | } |
---|
5079 | 5104 | hdw->input_allowed_mask = nv; |
---|
5080 | | - if ((1 << hdw->input_val) & hdw->input_allowed_mask) { |
---|
| 5105 | + if ((1UL << hdw->input_val) & hdw->input_allowed_mask) { |
---|
5081 | 5106 | /* Current mode is still in the allowed mask, so |
---|
5082 | 5107 | we're done. */ |
---|
5083 | 5108 | break; |
---|
.. | .. |
---|
5090 | 5115 | } |
---|
5091 | 5116 | m = hdw->input_allowed_mask; |
---|
5092 | 5117 | for (idx = 0; idx < (sizeof(m) << 3); idx++) { |
---|
5093 | | - if (!((1 << idx) & m)) continue; |
---|
| 5118 | + if (!((1UL << idx) & m)) continue; |
---|
5094 | 5119 | pvr2_hdw_set_input(hdw,idx); |
---|
5095 | 5120 | break; |
---|
5096 | 5121 | } |
---|