Lines Matching +full:cm +full:- +full:poll +full:- +full:interval

1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <media/v4l2-common.h>
16 #include "pvrusb2-std.h"
17 #include "pvrusb2-util.h"
18 #include "pvrusb2-hdw.h"
19 #include "pvrusb2-i2c-core.h"
20 #include "pvrusb2-eeprom.h"
21 #include "pvrusb2-hdw-internal.h"
22 #include "pvrusb2-encoder.h"
23 #include "pvrusb2-debug.h"
24 #include "pvrusb2-fx2-cmd.h"
25 #include "pvrusb2-wm8775.h"
26 #include "pvrusb2-video-v4l.h"
27 #include "pvrusb2-cx2584x-v4l.h"
28 #include "pvrusb2-cs53l32a.h"
29 #include "pvrusb2-audio.h"
34 /* This defines a minimum interval that the decoder must remain quiet
38 /* This defines a minimum interval that the decoder must be allowed to run
42 /* This defines a minimum interval that the encoder must remain quiet
46 /* This defines the minimum interval that the encoder must successfully run
53 static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
58 static int tuner[PVR_NUM] = { [0 ... PVR_NUM-1] = -1 };
59 static int tolerance[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 };
60 static int video_std[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 };
157 /* Already using audio_mode elsewhere :-( */
246 [PVR2_CVAL_INPUT_SVIDEO] = "s-video",
340 "State bit %s <-- %s", in trace_stbit()
346 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channelfreq_get()
347 if ((hdw->freqProgSlot > 0) && (hdw->freqProgSlot <= FREQTABLE_SIZE)) { in ctrl_channelfreq_get()
348 *vp = hdw->freqTable[hdw->freqProgSlot-1]; in ctrl_channelfreq_get()
357 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channelfreq_set()
358 unsigned int slotId = hdw->freqProgSlot; in ctrl_channelfreq_set()
360 hdw->freqTable[slotId-1] = v; in ctrl_channelfreq_set()
361 /* Handle side effects correctly - if we're tuned to this in ctrl_channelfreq_set()
364 if (hdw->freqSelector) { in ctrl_channelfreq_set()
365 if (hdw->freqSlotRadio == slotId) { in ctrl_channelfreq_set()
366 hdw->freqSlotRadio = 0; in ctrl_channelfreq_set()
369 if (hdw->freqSlotTelevision == slotId) { in ctrl_channelfreq_set()
370 hdw->freqSlotTelevision = 0; in ctrl_channelfreq_set()
379 *vp = cptr->hdw->freqProgSlot; in ctrl_channelprog_get()
385 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channelprog_set()
387 hdw->freqProgSlot = v; in ctrl_channelprog_set()
394 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channel_get()
395 *vp = hdw->freqSelector ? hdw->freqSlotRadio : hdw->freqSlotTelevision; in ctrl_channel_get()
402 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channel_set()
405 freq = hdw->freqTable[slotId-1]; in ctrl_channel_set()
409 if (hdw->freqSelector) { in ctrl_channel_set()
410 hdw->freqSlotRadio = slotId; in ctrl_channel_set()
412 hdw->freqSlotTelevision = slotId; in ctrl_channel_set()
419 *vp = pvr2_hdw_get_cur_freq(cptr->hdw); in ctrl_freq_get()
425 return cptr->hdw->freqDirty != 0; in ctrl_freq_is_dirty()
430 cptr->hdw->freqDirty = 0; in ctrl_freq_clear_dirty()
435 pvr2_hdw_set_cur_freq(cptr->hdw,v); in ctrl_freq_set()
441 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropl_min_get()
442 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropl_min_get()
446 *left = cap->bounds.left; in ctrl_cropl_min_get()
452 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropl_max_get()
453 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropl_max_get()
457 *left = cap->bounds.left; in ctrl_cropl_max_get()
458 if (cap->bounds.width > cptr->hdw->cropw_val) { in ctrl_cropl_max_get()
459 *left += cap->bounds.width - cptr->hdw->cropw_val; in ctrl_cropl_max_get()
466 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropt_min_get()
467 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropt_min_get()
471 *top = cap->bounds.top; in ctrl_cropt_min_get()
477 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropt_max_get()
478 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropt_max_get()
482 *top = cap->bounds.top; in ctrl_cropt_max_get()
483 if (cap->bounds.height > cptr->hdw->croph_val) { in ctrl_cropt_max_get()
484 *top += cap->bounds.height - cptr->hdw->croph_val; in ctrl_cropt_max_get()
491 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropw_max_get()
494 stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropw_max_get()
498 bleftend = cap->bounds.left+cap->bounds.width; in ctrl_cropw_max_get()
499 cleft = cptr->hdw->cropl_val; in ctrl_cropw_max_get()
501 *width = cleft < bleftend ? bleftend-cleft : 0; in ctrl_cropw_max_get()
507 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_croph_max_get()
510 stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_croph_max_get()
514 btopend = cap->bounds.top+cap->bounds.height; in ctrl_croph_max_get()
515 ctop = cptr->hdw->cropt_val; in ctrl_croph_max_get()
517 *height = ctop < btopend ? btopend-ctop : 0; in ctrl_croph_max_get()
523 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbl()
524 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbl()
528 *val = cap->bounds.left; in ctrl_get_cropcapbl()
534 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbt()
535 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbt()
539 *val = cap->bounds.top; in ctrl_get_cropcapbt()
545 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbw()
546 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbw()
550 *val = cap->bounds.width; in ctrl_get_cropcapbw()
556 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbh()
557 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbh()
561 *val = cap->bounds.height; in ctrl_get_cropcapbh()
567 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdl()
568 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdl()
572 *val = cap->defrect.left; in ctrl_get_cropcapdl()
578 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdt()
579 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdt()
583 *val = cap->defrect.top; in ctrl_get_cropcapdt()
589 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdw()
590 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdw()
594 *val = cap->defrect.width; in ctrl_get_cropcapdw()
600 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdh()
601 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdh()
605 *val = cap->defrect.height; in ctrl_get_cropcapdh()
611 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcappan()
612 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcappan()
616 *val = cap->pixelaspect.numerator; in ctrl_get_cropcappan()
622 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcappad()
623 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcappad()
627 *val = cap->pixelaspect.denominator; in ctrl_get_cropcappad()
634 if (cptr->hdw->std_mask_cur & V4L2_STD_525_60) { in ctrl_vres_max_get()
645 if (cptr->hdw->hdw_desc->flag_has_cx25840) { in ctrl_vres_min_get()
655 *vp = cptr->hdw->input_val; in ctrl_get_input()
663 return ((1UL << v) & cptr->hdw->input_allowed_mask) != 0; in ctrl_check_input()
668 return pvr2_hdw_set_input(cptr->hdw,v); in ctrl_set_input()
673 return cptr->hdw->input_dirty != 0; in ctrl_isdirty_input()
678 cptr->hdw->input_dirty = 0; in ctrl_cleardirty_input()
685 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_freq_max_get()
686 if (hdw->tuner_signal_stale) { in ctrl_freq_max_get()
689 fv = hdw->tuner_signal_info.rangehigh; in ctrl_freq_max_get()
695 if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { in ctrl_freq_max_get()
707 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_freq_min_get()
708 if (hdw->tuner_signal_stale) { in ctrl_freq_min_get()
711 fv = hdw->tuner_signal_info.rangelow; in ctrl_freq_min_get()
717 if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { in ctrl_freq_min_get()
728 return cptr->hdw->enc_stale != 0; in ctrl_cx2341x_is_dirty()
733 cptr->hdw->enc_stale = 0; in ctrl_cx2341x_clear_dirty()
734 cptr->hdw->enc_unsafe_stale = 0; in ctrl_cx2341x_clear_dirty()
746 c1.id = cptr->info->v4l_id; in ctrl_cx2341x_get()
747 ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state, 0, &cs, in ctrl_cx2341x_get()
757 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_cx2341x_set()
764 c1.id = cptr->info->v4l_id; in ctrl_cx2341x_set()
766 ret = cx2341x_ext_ctrls(&hdw->enc_ctl_state, in ctrl_cx2341x_set()
767 hdw->state_encoder_run, &cs, in ctrl_cx2341x_set()
769 if (ret == -EBUSY) { in ctrl_cx2341x_set()
775 ret = cx2341x_ext_ctrls(&hdw->enc_ctl_state, in ctrl_cx2341x_set()
778 if (!ret) hdw->enc_unsafe_stale = !0; in ctrl_cx2341x_set()
781 hdw->enc_stale = !0; in ctrl_cx2341x_set()
789 qctrl.id = cptr->info->v4l_id; in ctrl_cx2341x_getv4lflags()
790 cx2341x_ctrl_query(&cptr->hdw->enc_ctl_state,&qctrl); in ctrl_cx2341x_getv4lflags()
794 private to us, and (b) not in read-only storage. Either we do in ctrl_cx2341x_getv4lflags()
797 info = (struct pvr2_ctl_info *)(cptr->info); in ctrl_cx2341x_getv4lflags()
799 if (info->set_value) { in ctrl_cx2341x_getv4lflags()
800 info->set_value = NULL; in ctrl_cx2341x_getv4lflags()
803 if (!(info->set_value)) { in ctrl_cx2341x_getv4lflags()
804 info->set_value = ctrl_cx2341x_set; in ctrl_cx2341x_getv4lflags()
812 *vp = cptr->hdw->state_pipeline_req; in ctrl_streamingenabled_get()
818 *vp = cptr->hdw->master_state; in ctrl_masterstate_get()
824 int result = pvr2_hdw_is_hsm(cptr->hdw); in ctrl_hsm_get()
833 *vp = pvr2_hdw_get_detected_std(cptr->hdw); in ctrl_stddetect_get()
839 *vp = cptr->hdw->std_mask_avail; in ctrl_stdavail_get()
845 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_stdavail_set()
847 ns = hdw->std_mask_avail; in ctrl_stdavail_set()
849 if (ns == hdw->std_mask_avail) return 0; in ctrl_stdavail_set()
850 hdw->std_mask_avail = ns; in ctrl_stdavail_set()
851 hdw->std_info_cur.def.type_bitmask.valid_bits = hdw->std_mask_avail; in ctrl_stdavail_set()
869 return -EINVAL; in ctrl_std_sym_to_val()
877 *vp = cptr->hdw->std_mask_cur; in ctrl_stdcur_get()
883 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_stdcur_set()
885 ns = hdw->std_mask_cur; in ctrl_stdcur_set()
887 if (ns == hdw->std_mask_cur) return 0; in ctrl_stdcur_set()
888 hdw->std_mask_cur = ns; in ctrl_stdcur_set()
889 hdw->std_dirty = !0; in ctrl_stdcur_set()
895 return cptr->hdw->std_dirty != 0; in ctrl_stdcur_is_dirty()
900 cptr->hdw->std_dirty = 0; in ctrl_stdcur_clear_dirty()
905 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_signal_get()
907 *vp = hdw->tuner_signal_info.signal; in ctrl_signal_get()
915 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_audio_modes_present_get()
917 subchan = hdw->tuner_signal_info.rxsubchans; in ctrl_audio_modes_present_get()
962 {*vp = cptr->hdw->vname##_val; return 0;} \
964 {cptr->hdw->vname##_val = v; cptr->hdw->vname##_dirty = !0; return 0;} \
966 {return cptr->hdw->vname##_dirty != 0;} \
968 {cptr->hdw->vname##_dirty = 0;}
1017 DEFINT(-128,127),
1031 DEFINT(-32768,32767),
1038 DEFINT(-32768,32767),
1045 DEFINT(-32768,32767),
1059 DEFINT(-129, 340),
1069 DEFINT(-35, 544),
1282 return hdw->usb_dev; in pvr2_hdw_get_dev()
1288 return hdw->serial_number; in pvr2_hdw_get_sn()
1294 return hdw->bus_info; in pvr2_hdw_get_bus_info()
1300 return hdw->identifier; in pvr2_hdw_get_device_identifier()
1306 return hdw->freqSelector ? hdw->freqValTelevision : hdw->freqValRadio; in pvr2_hdw_get_cur_freq()
1310 driver-core side effects of this action. */
1313 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_set_cur_freq()
1314 if (hdw->freqSelector) { in pvr2_hdw_set_cur_freq()
1316 hdw->freqSelector = 0; in pvr2_hdw_set_cur_freq()
1317 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1319 if (hdw->freqValRadio != val) { in pvr2_hdw_set_cur_freq()
1320 hdw->freqValRadio = val; in pvr2_hdw_set_cur_freq()
1321 hdw->freqSlotRadio = 0; in pvr2_hdw_set_cur_freq()
1322 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1325 if (!(hdw->freqSelector)) { in pvr2_hdw_set_cur_freq()
1327 hdw->freqSelector = 1; in pvr2_hdw_set_cur_freq()
1328 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1330 if (hdw->freqValTelevision != val) { in pvr2_hdw_set_cur_freq()
1331 hdw->freqValTelevision = val; in pvr2_hdw_set_cur_freq()
1332 hdw->freqSlotTelevision = 0; in pvr2_hdw_set_cur_freq()
1333 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1340 return hdw->unit_number; in pvr2_hdw_get_unit_number()
1348 failure. If the return value is -ENOENT then no viable firmware file
1357 int ret = -EINVAL; in pvr2_locate_firmware()
1361 &hdw->usb_dev->dev); in pvr2_locate_firmware()
1368 if (ret == -ENOENT) continue; in pvr2_locate_firmware()
1400 * device to re-enumerate.
1415 if (!hdw->hdw_desc->fx2_firmware.cnt) { in pvr2_upload_firmware1()
1416 hdw->fw1_state = FW1_STATE_OK; in pvr2_upload_firmware1()
1419 return -ENOTTY; in pvr2_upload_firmware1()
1422 hdw->fw1_state = FW1_STATE_FAILED; // default result in pvr2_upload_firmware1()
1427 hdw->hdw_desc->fx2_firmware.cnt, in pvr2_upload_firmware1()
1428 hdw->hdw_desc->fx2_firmware.lst); in pvr2_upload_firmware1()
1430 if (ret == -ENOENT) hdw->fw1_state = FW1_STATE_MISSING; in pvr2_upload_firmware1()
1434 usb_clear_halt(hdw->usb_dev, usb_sndbulkpipe(hdw->usb_dev, 0 & 0x7f)); in pvr2_upload_firmware1()
1436 pipe = usb_sndctrlpipe(hdw->usb_dev, 0); in pvr2_upload_firmware1()
1437 fwsize = fw_entry->size; in pvr2_upload_firmware1()
1440 (!(hdw->hdw_desc->flag_fx2_16kb && (fwsize == 0x4000)))) { in pvr2_upload_firmware1()
1441 if (hdw->hdw_desc->flag_fx2_16kb) { in pvr2_upload_firmware1()
1451 return -ENOMEM; in pvr2_upload_firmware1()
1457 return -ENOMEM; in pvr2_upload_firmware1()
1463 /* upload the firmware to address 0000-1fff in 2048 (=0x800) bytes in pvr2_upload_firmware1()
1468 memcpy(fw_ptr, fw_entry->data + address, 0x800); in pvr2_upload_firmware1()
1469 ret += usb_control_msg(hdw->usb_dev, pipe, 0xa0, 0x40, address, in pvr2_upload_firmware1()
1485 hdw->fw1_state = FW1_STATE_RELOAD; in pvr2_upload_firmware1()
1489 return -EIO; in pvr2_upload_firmware1()
1512 if (hdw->hdw_desc->flag_skip_cx23416_firmware) { in pvr2_upload_firmware2()
1526 hdw->enc_cur_valid = 0; in pvr2_upload_firmware2()
1530 del_timer_sync(&hdw->encoder_run_timer); in pvr2_upload_firmware2()
1531 if (hdw->state_encoder_runok) { in pvr2_upload_firmware2()
1532 hdw->state_encoder_runok = 0; in pvr2_upload_firmware2()
1533 trace_stbit("state_encoder_runok",hdw->state_encoder_runok); in pvr2_upload_firmware2()
1547 ret |= pvr2_write_register(hdw, 0x07fc, 0x0000001a); /*encoder SDRAM pre-charge*/ in pvr2_upload_firmware2()
1565 fw_len = fw_entry->size; in pvr2_upload_firmware2()
1572 ret = -EINVAL; in pvr2_upload_firmware2()
1581 ret = -ENOMEM; in pvr2_upload_firmware2()
1585 pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT); in pvr2_upload_firmware2()
1589 bcnt = fw_len - fw_done; in pvr2_upload_firmware2()
1591 memcpy(fw_ptr, fw_entry->data + fw_done, bcnt); in pvr2_upload_firmware2()
1607 ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,bcnt, in pvr2_upload_firmware2()
1634 "firmware2 upload post-proc failure"); in pvr2_upload_firmware2()
1638 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_upload_firmware2()
1659 this point, we'll broadcast stream on/off to all sub-devices in pvr2_decoder_enable()
1664 v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_stream, enablefl); in pvr2_decoder_enable()
1665 v4l2_device_call_all(&hdw->v4l2_dev, 0, audio, s_stream, enablefl); in pvr2_decoder_enable()
1666 if (hdw->decoder_client_id) { in pvr2_decoder_enable()
1672 if (!hdw->flag_decoder_missed) { in pvr2_decoder_enable()
1675 hdw->flag_decoder_missed = !0; in pvr2_decoder_enable()
1677 hdw->flag_decoder_missed); in pvr2_decoder_enable()
1679 return -EIO; in pvr2_decoder_enable()
1685 return hdw->master_state; in pvr2_hdw_get_state()
1691 if (!hdw->flag_tripped) return 0; in pvr2_hdw_untrip_unlocked()
1692 hdw->flag_tripped = 0; in pvr2_hdw_untrip_unlocked()
1702 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_untrip()
1704 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_untrip()
1714 return hdw->state_pipeline_req != 0; in pvr2_hdw_get_streaming()
1721 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_set_streaming()
1723 if (!enable_flag != !hdw->state_pipeline_req) { in pvr2_hdw_set_streaming()
1724 hdw->state_pipeline_req = enable_flag != 0; in pvr2_hdw_set_streaming()
1726 "/*--TRACE_STREAM--*/ %s", in pvr2_hdw_set_streaming()
1730 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_streaming()
1733 while ((st = hdw->master_state) != PVR2_STATE_RUN) { in pvr2_hdw_set_streaming()
1734 if (st != PVR2_STATE_READY) return -EIO; in pvr2_hdw_set_streaming()
1745 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_set_stream_type()
1746 if ((fl = (hdw->desired_stream_type != config)) != 0) { in pvr2_hdw_set_stream_type()
1747 hdw->desired_stream_type = config; in pvr2_hdw_set_stream_type()
1748 hdw->state_pipeline_config = 0; in pvr2_hdw_set_stream_type()
1750 hdw->state_pipeline_config); in pvr2_hdw_set_stream_type()
1753 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_stream_type()
1761 int unit_number = hdw->unit_number; in get_default_tuner_type()
1762 int tp = -1; in get_default_tuner_type()
1766 if (tp < 0) return -EINVAL; in get_default_tuner_type()
1767 hdw->tuner_type = tp; in get_default_tuner_type()
1768 hdw->tuner_updated = !0; in get_default_tuner_type()
1775 int unit_number = hdw->unit_number; in get_default_standard()
1787 int unit_number = hdw->unit_number; in get_default_error_tolerance()
1803 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_check_firmware()
1804 hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR; in pvr2_hdw_check_firmware()
1806 hdw->cmd_buffer,1, in pvr2_hdw_check_firmware()
1807 hdw->cmd_buffer,1); in pvr2_hdw_check_firmware()
1809 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_check_firmware()
1833 default - which can always be overridden explicitly - and if the user
1866 std3 = std1 ? 0 : hdw->hdw_desc->default_std_mask; in pvr2_hdw_setup_std()
1868 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),hdw->std_mask_eeprom); in pvr2_hdw_setup_std()
1873 hdw->std_mask_avail = hdw->std_mask_eeprom; in pvr2_hdw_setup_std()
1875 std2 = (std1|std3) & ~hdw->std_mask_avail; in pvr2_hdw_setup_std()
1881 hdw->std_mask_avail |= std2; in pvr2_hdw_setup_std()
1884 hdw->std_info_cur.def.type_bitmask.valid_bits = hdw->std_mask_avail; in pvr2_hdw_setup_std()
1891 hdw->std_mask_cur = std1; in pvr2_hdw_setup_std()
1892 hdw->std_dirty = !0; in pvr2_hdw_setup_std()
1900 hdw->std_mask_cur = std3; in pvr2_hdw_setup_std()
1901 hdw->std_dirty = !0; in pvr2_hdw_setup_std()
1910 hdw->std_mask_eeprom) & in pvr2_hdw_setup_std()
1913 hdw->std_mask_eeprom)) continue; in pvr2_hdw_setup_std()
1919 hdw->std_mask_cur = std_eeprom_maps[idx].std; in pvr2_hdw_setup_std()
1920 hdw->std_dirty = !0; in pvr2_hdw_setup_std()
1946 Mike Isely <isely@pobox.com> 19-Nov-2006 - This bit of nuttiness in pvr2_hdw_cx25840_vbi_hack()
1955 if (hdw->decoder_client_id != PVR2_CLIENT_ID_CX25840) { in pvr2_hdw_cx25840_vbi_hack()
1962 hdw->decoder_client_id); in pvr2_hdw_cx25840_vbi_hack()
1967 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, in pvr2_hdw_cx25840_vbi_hack()
1980 /* Arbitrary count - max # i2c addresses we will probe */ in pvr2_hdw_load_subdev()
1983 mid = cd->module_id; in pvr2_hdw_load_subdev()
1989 hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
1990 return -EINVAL; in pvr2_hdw_load_subdev()
1995 hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
1997 i2ccnt = pvr2_copy_i2c_addr_list(i2caddr, cd->i2c_address_list, in pvr2_hdw_load_subdev()
2014 mid, fname, hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2015 return -EINVAL; in pvr2_hdw_load_subdev()
2022 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, in pvr2_hdw_load_subdev()
2028 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, in pvr2_hdw_load_subdev()
2034 …"Module ID %u (%s) for device %s failed to load. Possible missing sub-device kernel module or ini… in pvr2_hdw_load_subdev()
2035 mid, fname, hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2036 return -EIO; in pvr2_hdw_load_subdev()
2039 /* Tag this sub-device instance with the module ID we know about. in pvr2_hdw_load_subdev()
2042 sd->grp_id = mid; in pvr2_hdw_load_subdev()
2044 pvr2_trace(PVR2_TRACE_INFO, "Attached sub-driver %s", fname); in pvr2_hdw_load_subdev()
2047 /* client-specific setup... */ in pvr2_hdw_load_subdev()
2051 hdw->decoder_client_id = mid; in pvr2_hdw_load_subdev()
2063 const struct pvr2_string_table *cm; in pvr2_hdw_load_modules() local
2067 cm = &hdw->hdw_desc->client_modules; in pvr2_hdw_load_modules()
2068 for (idx = 0; idx < cm->cnt; idx++) { in pvr2_hdw_load_modules()
2069 request_module(cm->lst[idx]); in pvr2_hdw_load_modules()
2072 ct = &hdw->hdw_desc->client_table; in pvr2_hdw_load_modules()
2073 for (idx = 0; idx < ct->cnt; idx++) { in pvr2_hdw_load_modules()
2074 if (pvr2_hdw_load_subdev(hdw, &ct->lst[idx]) < 0) okFl = 0; in pvr2_hdw_load_modules()
2077 hdw->flag_modulefail = !0; in pvr2_hdw_load_modules()
2089 if (hdw->hdw_desc->fx2_firmware.cnt) { in pvr2_hdw_setup_low()
2092 (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints in pvr2_hdw_setup_low()
2114 hdw->fw1_state = FW1_STATE_OK; in pvr2_hdw_setup_low()
2118 hdw->force_dirty = !0; in pvr2_hdw_setup_low()
2120 if (!hdw->hdw_desc->flag_no_powerup) { in pvr2_hdw_setup_low()
2126 if (hdw->ir_scheme_active == PVR2_IR_SCHEME_ZILOG) { in pvr2_hdw_setup_low()
2138 if (le16_to_cpu(hdw->usb_dev->descriptor.idVendor) == 0x2040 && in pvr2_hdw_setup_low()
2139 (le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7502 || in pvr2_hdw_setup_low()
2140 le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7510)) { in pvr2_hdw_setup_low()
2158 v4l2_device_call_all(&hdw->v4l2_dev, 0, core, load_fw); in pvr2_hdw_setup_low()
2161 cptr = hdw->controls + idx; in pvr2_hdw_setup_low()
2162 if (cptr->info->skip_init) continue; in pvr2_hdw_setup_low()
2163 if (!cptr->info->set_value) continue; in pvr2_hdw_setup_low()
2164 cptr->info->set_value(cptr,~0,cptr->info->default_value); in pvr2_hdw_setup_low()
2174 hdw->freqValTelevision = default_tv_freq; in pvr2_hdw_setup_low()
2175 hdw->freqValRadio = default_radio_freq; in pvr2_hdw_setup_low()
2178 // thread-safe against the normal pvr2_send_request() mechanism. in pvr2_hdw_setup_low()
2181 if (hdw->hdw_desc->flag_has_hauppauge_rom) { in pvr2_hdw_setup_low()
2188 hdw->eeprom_addr = ret; in pvr2_hdw_setup_low()
2193 hdw->tuner_type = hdw->hdw_desc->default_tuner_type; in pvr2_hdw_setup_low()
2194 hdw->tuner_updated = !0; in pvr2_hdw_setup_low()
2195 hdw->std_mask_eeprom = V4L2_STD_ALL; in pvr2_hdw_setup_low()
2198 if (hdw->serial_number) { in pvr2_hdw_setup_low()
2199 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1, in pvr2_hdw_setup_low()
2200 "sn-%lu", hdw->serial_number); in pvr2_hdw_setup_low()
2201 } else if (hdw->unit_number >= 0) { in pvr2_hdw_setup_low()
2202 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1, in pvr2_hdw_setup_low()
2203 "unit-%c", in pvr2_hdw_setup_low()
2204 hdw->unit_number + 'a'); in pvr2_hdw_setup_low()
2206 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1, in pvr2_hdw_setup_low()
2207 "unit-??"); in pvr2_hdw_setup_low()
2209 hdw->identifier[idx] = 0; in pvr2_hdw_setup_low()
2216 hdw->tuner_type); in pvr2_hdw_setup_low()
2222 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_hdw_setup_low()
2231 hdw->vid_stream = pvr2_stream_create(); in pvr2_hdw_setup_low()
2234 "pvr2_hdw_setup: video stream is %p",hdw->vid_stream); in pvr2_hdw_setup_low()
2235 if (hdw->vid_stream) { in pvr2_hdw_setup_low()
2240 hdw->vid_stream,idx); in pvr2_hdw_setup_low()
2242 pvr2_stream_setup(hdw->vid_stream,hdw->usb_dev, in pvr2_hdw_setup_low()
2248 hdw->flag_init_ok = !0; in pvr2_hdw_setup_low()
2255 This can be a time-consuming operation, which is why it is not done
2264 hdw,pvr2_hdw_dev_ok(hdw),hdw->flag_init_ok); in pvr2_hdw_setup()
2266 if (hdw->flag_init_ok) { in pvr2_hdw_setup()
2272 if (hdw->fw1_state == FW1_STATE_RELOAD) { in pvr2_hdw_setup()
2281 if (hdw->fw1_state == FW1_STATE_MISSING) { in pvr2_hdw_setup()
2288 if (hdw->flag_modulefail) { in pvr2_hdw_setup()
2291 …"***WARNING*** pvrusb2 driver initialization failed due to the failure of one or more sub-device k… in pvr2_hdw_setup()
2304 hdw->fw1_state = FW1_STATE_UNKNOWN; in pvr2_hdw_setup()
2326 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_initialize()
2327 if (hdw->flag_disconnected) { in pvr2_hdw_initialize()
2336 hdw->state_data = callback_data; in pvr2_hdw_initialize()
2337 hdw->state_func = callback_func; in pvr2_hdw_initialize()
2339 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_initialize()
2340 return hdw->flag_init_ok; in pvr2_hdw_initialize()
2361 hdw_desc = (const struct pvr2_device_desc *)(devid->driver_info); in pvr2_hdw_create()
2372 hdw,hdw_desc->description); in pvr2_hdw_create()
2374 hdw_desc->description); in pvr2_hdw_create()
2375 if (hdw_desc->flag_is_experimental) { in pvr2_hdw_create()
2379 hdw_desc->description); in pvr2_hdw_create()
2388 timer_setup(&hdw->quiescent_timer, pvr2_hdw_quiescent_timeout, 0); in pvr2_hdw_create()
2390 timer_setup(&hdw->decoder_stabilization_timer, in pvr2_hdw_create()
2393 timer_setup(&hdw->encoder_wait_timer, pvr2_hdw_encoder_wait_timeout, in pvr2_hdw_create()
2396 timer_setup(&hdw->encoder_run_timer, pvr2_hdw_encoder_run_timeout, 0); in pvr2_hdw_create()
2398 hdw->master_state = PVR2_STATE_DEAD; in pvr2_hdw_create()
2400 init_waitqueue_head(&hdw->state_wait_data); in pvr2_hdw_create()
2402 hdw->tuner_signal_stale = !0; in pvr2_hdw_create()
2403 cx2341x_fill_defaults(&hdw->enc_ctl_state); in pvr2_hdw_create()
2407 if (hdw_desc->flag_has_analogtuner) m |= 1 << PVR2_CVAL_INPUT_TV; in pvr2_hdw_create()
2408 if (hdw_desc->digital_control_scheme != PVR2_DIGITAL_SCHEME_NONE) { in pvr2_hdw_create()
2411 if (hdw_desc->flag_has_svideo) m |= 1 << PVR2_CVAL_INPUT_SVIDEO; in pvr2_hdw_create()
2412 if (hdw_desc->flag_has_composite) m |= 1 << PVR2_CVAL_INPUT_COMPOSITE; in pvr2_hdw_create()
2413 if (hdw_desc->flag_has_fmradio) m |= 1 << PVR2_CVAL_INPUT_RADIO; in pvr2_hdw_create()
2414 hdw->input_avail_mask = m; in pvr2_hdw_create()
2415 hdw->input_allowed_mask = hdw->input_avail_mask; in pvr2_hdw_create()
2419 if (!(hdw->input_avail_mask & (1 << PVR2_CVAL_INPUT_DTV))) { in pvr2_hdw_create()
2420 hdw->pathway_state = PVR2_PATHWAY_ANALOG; in pvr2_hdw_create()
2421 } else if (!(hdw->input_avail_mask & (1 << PVR2_CVAL_INPUT_TV))) { in pvr2_hdw_create()
2422 hdw->pathway_state = PVR2_PATHWAY_DIGITAL; in pvr2_hdw_create()
2425 hdw->control_cnt = CTRLDEF_COUNT; in pvr2_hdw_create()
2426 hdw->control_cnt += MPEGDEF_COUNT; in pvr2_hdw_create()
2427 hdw->controls = kcalloc(hdw->control_cnt, sizeof(struct pvr2_ctrl), in pvr2_hdw_create()
2429 if (!hdw->controls) goto fail; in pvr2_hdw_create()
2430 hdw->hdw_desc = hdw_desc; in pvr2_hdw_create()
2431 hdw->ir_scheme_active = hdw->hdw_desc->ir_scheme; in pvr2_hdw_create()
2432 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_create()
2433 cptr = hdw->controls + idx; in pvr2_hdw_create()
2434 cptr->hdw = hdw; in pvr2_hdw_create()
2437 hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx]; in pvr2_hdw_create()
2440 cptr = hdw->controls + idx; in pvr2_hdw_create()
2441 cptr->info = control_defs+idx; in pvr2_hdw_create()
2445 m = hdw->input_avail_mask; in pvr2_hdw_create()
2448 hdw->input_val = idx; in pvr2_hdw_create()
2453 hdw->mpeg_ctrl_info = kcalloc(MPEGDEF_COUNT, in pvr2_hdw_create()
2454 sizeof(*(hdw->mpeg_ctrl_info)), in pvr2_hdw_create()
2456 if (!hdw->mpeg_ctrl_info) goto fail; in pvr2_hdw_create()
2458 cptr = hdw->controls + idx + CTRLDEF_COUNT; in pvr2_hdw_create()
2459 ciptr = &(hdw->mpeg_ctrl_info[idx].info); in pvr2_hdw_create()
2460 ciptr->desc = hdw->mpeg_ctrl_info[idx].desc; in pvr2_hdw_create()
2461 ciptr->name = mpeg_ids[idx].strid; in pvr2_hdw_create()
2462 ciptr->v4l_id = mpeg_ids[idx].id; in pvr2_hdw_create()
2463 ciptr->skip_init = !0; in pvr2_hdw_create()
2464 ciptr->get_value = ctrl_cx2341x_get; in pvr2_hdw_create()
2465 ciptr->get_v4lflags = ctrl_cx2341x_getv4lflags; in pvr2_hdw_create()
2466 ciptr->is_dirty = ctrl_cx2341x_is_dirty; in pvr2_hdw_create()
2467 if (!idx) ciptr->clear_dirty = ctrl_cx2341x_clear_dirty; in pvr2_hdw_create()
2468 qctrl.id = ciptr->v4l_id; in pvr2_hdw_create()
2469 cx2341x_ctrl_query(&hdw->enc_ctl_state,&qctrl); in pvr2_hdw_create()
2471 ciptr->set_value = ctrl_cx2341x_set; in pvr2_hdw_create()
2473 strscpy(hdw->mpeg_ctrl_info[idx].desc, qctrl.name, in pvr2_hdw_create()
2474 sizeof(hdw->mpeg_ctrl_info[idx].desc)); in pvr2_hdw_create()
2475 ciptr->default_value = qctrl.default_value; in pvr2_hdw_create()
2479 ciptr->type = pvr2_ctl_int; in pvr2_hdw_create()
2480 ciptr->def.type_int.min_value = qctrl.minimum; in pvr2_hdw_create()
2481 ciptr->def.type_int.max_value = qctrl.maximum; in pvr2_hdw_create()
2484 ciptr->type = pvr2_ctl_bool; in pvr2_hdw_create()
2487 ciptr->type = pvr2_ctl_enum; in pvr2_hdw_create()
2488 ciptr->def.type_enum.value_names = in pvr2_hdw_create()
2489 cx2341x_ctrl_get_menu(&hdw->enc_ctl_state, in pvr2_hdw_create()
2490 ciptr->v4l_id); in pvr2_hdw_create()
2492 ciptr->def.type_enum.value_names[cnt1] != NULL; in pvr2_hdw_create()
2494 ciptr->def.type_enum.count = cnt1; in pvr2_hdw_create()
2497 cptr->info = ciptr; in pvr2_hdw_create()
2505 hdw->std_mask_names[idx], in pvr2_hdw_create()
2506 sizeof(hdw->std_mask_names[idx])-1, in pvr2_hdw_create()
2508 hdw->std_mask_names[idx][cnt1] = 0; in pvr2_hdw_create()
2512 memcpy(&hdw->std_info_avail,cptr->info, in pvr2_hdw_create()
2513 sizeof(hdw->std_info_avail)); in pvr2_hdw_create()
2514 cptr->info = &hdw->std_info_avail; in pvr2_hdw_create()
2515 hdw->std_info_avail.def.type_bitmask.bit_names = in pvr2_hdw_create()
2516 hdw->std_mask_ptrs; in pvr2_hdw_create()
2517 hdw->std_info_avail.def.type_bitmask.valid_bits = in pvr2_hdw_create()
2522 memcpy(&hdw->std_info_cur,cptr->info, in pvr2_hdw_create()
2523 sizeof(hdw->std_info_cur)); in pvr2_hdw_create()
2524 cptr->info = &hdw->std_info_cur; in pvr2_hdw_create()
2525 hdw->std_info_cur.def.type_bitmask.bit_names = in pvr2_hdw_create()
2526 hdw->std_mask_ptrs; in pvr2_hdw_create()
2527 hdw->std_info_cur.def.type_bitmask.valid_bits = in pvr2_hdw_create()
2532 memcpy(&hdw->std_info_detect,cptr->info, in pvr2_hdw_create()
2533 sizeof(hdw->std_info_detect)); in pvr2_hdw_create()
2534 cptr->info = &hdw->std_info_detect; in pvr2_hdw_create()
2535 hdw->std_info_detect.def.type_bitmask.bit_names = in pvr2_hdw_create()
2536 hdw->std_mask_ptrs; in pvr2_hdw_create()
2537 hdw->std_info_detect.def.type_bitmask.valid_bits = in pvr2_hdw_create()
2541 hdw->cropcap_stale = !0; in pvr2_hdw_create()
2542 hdw->eeprom_addr = -1; in pvr2_hdw_create()
2543 hdw->unit_number = -1; in pvr2_hdw_create()
2544 hdw->v4l_minor_number_video = -1; in pvr2_hdw_create()
2545 hdw->v4l_minor_number_vbi = -1; in pvr2_hdw_create()
2546 hdw->v4l_minor_number_radio = -1; in pvr2_hdw_create()
2547 hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); in pvr2_hdw_create()
2548 if (!hdw->ctl_write_buffer) goto fail; in pvr2_hdw_create()
2549 hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); in pvr2_hdw_create()
2550 if (!hdw->ctl_read_buffer) goto fail; in pvr2_hdw_create()
2551 hdw->ctl_write_urb = usb_alloc_urb(0,GFP_KERNEL); in pvr2_hdw_create()
2552 if (!hdw->ctl_write_urb) goto fail; in pvr2_hdw_create()
2553 hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); in pvr2_hdw_create()
2554 if (!hdw->ctl_read_urb) goto fail; in pvr2_hdw_create()
2556 if (v4l2_device_register(&intf->dev, &hdw->v4l2_dev) != 0) { in pvr2_hdw_create()
2565 hdw->unit_number = idx; in pvr2_hdw_create()
2572 INIT_WORK(&hdw->workpoll, pvr2_hdw_worker_poll); in pvr2_hdw_create()
2574 if (hdw->unit_number == -1) in pvr2_hdw_create()
2578 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); in pvr2_hdw_create()
2580 if (hdw->unit_number >= 0) { in pvr2_hdw_create()
2581 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"_%c", in pvr2_hdw_create()
2582 ('a' + hdw->unit_number)); in pvr2_hdw_create()
2585 if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1; in pvr2_hdw_create()
2586 hdw->name[cnt1] = 0; in pvr2_hdw_create()
2589 hdw->unit_number,hdw->name); in pvr2_hdw_create()
2591 hdw->tuner_type = -1; in pvr2_hdw_create()
2592 hdw->flag_ok = !0; in pvr2_hdw_create()
2594 hdw->usb_intf = intf; in pvr2_hdw_create()
2595 hdw->usb_dev = usb_dev; in pvr2_hdw_create()
2597 usb_make_path(hdw->usb_dev, hdw->bus_info, sizeof(hdw->bus_info)); in pvr2_hdw_create()
2599 ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber; in pvr2_hdw_create()
2600 usb_set_interface(hdw->usb_dev,ifnum,0); in pvr2_hdw_create()
2602 mutex_init(&hdw->ctl_lock_mutex); in pvr2_hdw_create()
2603 mutex_init(&hdw->big_lock_mutex); in pvr2_hdw_create()
2608 timer_shutdown_sync(&hdw->quiescent_timer); in pvr2_hdw_create()
2609 timer_shutdown_sync(&hdw->decoder_stabilization_timer); in pvr2_hdw_create()
2610 timer_shutdown_sync(&hdw->encoder_run_timer); in pvr2_hdw_create()
2611 timer_shutdown_sync(&hdw->encoder_wait_timer); in pvr2_hdw_create()
2612 flush_work(&hdw->workpoll); in pvr2_hdw_create()
2613 v4l2_device_unregister(&hdw->v4l2_dev); in pvr2_hdw_create()
2614 usb_free_urb(hdw->ctl_read_urb); in pvr2_hdw_create()
2615 usb_free_urb(hdw->ctl_write_urb); in pvr2_hdw_create()
2616 kfree(hdw->ctl_read_buffer); in pvr2_hdw_create()
2617 kfree(hdw->ctl_write_buffer); in pvr2_hdw_create()
2618 kfree(hdw->controls); in pvr2_hdw_create()
2619 kfree(hdw->mpeg_ctrl_info); in pvr2_hdw_create()
2630 if (hdw->flag_disconnected) return; in pvr2_hdw_remove_usb_stuff()
2632 if (hdw->ctl_read_urb) { in pvr2_hdw_remove_usb_stuff()
2633 usb_kill_urb(hdw->ctl_read_urb); in pvr2_hdw_remove_usb_stuff()
2634 usb_free_urb(hdw->ctl_read_urb); in pvr2_hdw_remove_usb_stuff()
2635 hdw->ctl_read_urb = NULL; in pvr2_hdw_remove_usb_stuff()
2637 if (hdw->ctl_write_urb) { in pvr2_hdw_remove_usb_stuff()
2638 usb_kill_urb(hdw->ctl_write_urb); in pvr2_hdw_remove_usb_stuff()
2639 usb_free_urb(hdw->ctl_write_urb); in pvr2_hdw_remove_usb_stuff()
2640 hdw->ctl_write_urb = NULL; in pvr2_hdw_remove_usb_stuff()
2642 if (hdw->ctl_read_buffer) { in pvr2_hdw_remove_usb_stuff()
2643 kfree(hdw->ctl_read_buffer); in pvr2_hdw_remove_usb_stuff()
2644 hdw->ctl_read_buffer = NULL; in pvr2_hdw_remove_usb_stuff()
2646 if (hdw->ctl_write_buffer) { in pvr2_hdw_remove_usb_stuff()
2647 kfree(hdw->ctl_write_buffer); in pvr2_hdw_remove_usb_stuff()
2648 hdw->ctl_write_buffer = NULL; in pvr2_hdw_remove_usb_stuff()
2650 hdw->flag_disconnected = !0; in pvr2_hdw_remove_usb_stuff()
2654 v4l2_device_disconnect(&hdw->v4l2_dev); in pvr2_hdw_remove_usb_stuff()
2655 hdw->usb_dev = NULL; in pvr2_hdw_remove_usb_stuff()
2656 hdw->usb_intf = NULL; in pvr2_hdw_remove_usb_stuff()
2662 vdev->v4l2_dev = &hdw->v4l2_dev; in pvr2_hdw_set_v4l2_dev()
2670 flush_work(&hdw->workpoll); in pvr2_hdw_destroy()
2671 timer_shutdown_sync(&hdw->quiescent_timer); in pvr2_hdw_destroy()
2672 timer_shutdown_sync(&hdw->decoder_stabilization_timer); in pvr2_hdw_destroy()
2673 timer_shutdown_sync(&hdw->encoder_run_timer); in pvr2_hdw_destroy()
2674 timer_shutdown_sync(&hdw->encoder_wait_timer); in pvr2_hdw_destroy()
2675 if (hdw->fw_buffer) { in pvr2_hdw_destroy()
2676 kfree(hdw->fw_buffer); in pvr2_hdw_destroy()
2677 hdw->fw_buffer = NULL; in pvr2_hdw_destroy()
2679 if (hdw->vid_stream) { in pvr2_hdw_destroy()
2680 pvr2_stream_destroy(hdw->vid_stream); in pvr2_hdw_destroy()
2681 hdw->vid_stream = NULL; in pvr2_hdw_destroy()
2683 v4l2_device_unregister(&hdw->v4l2_dev); in pvr2_hdw_destroy()
2687 if ((hdw->unit_number >= 0) && in pvr2_hdw_destroy()
2688 (hdw->unit_number < PVR_NUM) && in pvr2_hdw_destroy()
2689 (unit_pointers[hdw->unit_number] == hdw)) { in pvr2_hdw_destroy()
2690 unit_pointers[hdw->unit_number] = NULL; in pvr2_hdw_destroy()
2694 kfree(hdw->controls); in pvr2_hdw_destroy()
2695 kfree(hdw->mpeg_ctrl_info); in pvr2_hdw_destroy()
2702 return (hdw && hdw->flag_ok); in pvr2_hdw_dev_ok()
2710 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_disconnect()
2712 LOCK_TAKE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2714 LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2715 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_disconnect()
2722 return hdw->control_cnt; in pvr2_hdw_get_ctrl_count()
2726 /* Retrieve a control handle given its index (0..count-1) */
2730 if (idx >= hdw->control_cnt) return NULL; in pvr2_hdw_get_ctrl_by_index()
2731 return hdw->controls + idx; in pvr2_hdw_get_ctrl_by_index()
2735 /* Retrieve a control handle given its index (0..count-1) */
2744 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_by_id()
2745 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_by_id()
2746 i = cptr->info->internal_id; in pvr2_hdw_get_ctrl_by_id()
2761 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_v4l()
2762 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_v4l()
2763 i = cptr->info->v4l_id; in pvr2_hdw_get_ctrl_v4l()
2781 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_nextv4l()
2782 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_nextv4l()
2783 i = cptr->info->v4l_id; in pvr2_hdw_get_ctrl_nextv4l()
2786 if (cp2 && (cp2->info->v4l_id < i)) continue; in pvr2_hdw_get_ctrl_nextv4l()
2817 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) in pvr2_subdev_set_control()
2818 v4l2_s_ctrl(NULL, sd->ctrl_handler, &ctrl); in pvr2_subdev_set_control()
2822 if ((hdw)->lab##_dirty || (hdw)->force_dirty) { \
2823 pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \
2829 std = (v4l2_std_id)hdw->std_mask_avail; in pvr2_hdw_get_detected_std()
2830 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_hdw_get_detected_std()
2836 sub-devices so that they match our current control values. */
2845 if (hdw->tuner_updated || hdw->force_dirty) { in pvr2_subdev_update()
2848 hdw->tuner_type); in pvr2_subdev_update()
2849 if (((int)(hdw->tuner_type)) >= 0) { in pvr2_subdev_update()
2852 setup.type = hdw->tuner_type; in pvr2_subdev_update()
2854 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2859 if (hdw->input_dirty || hdw->std_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2861 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_subdev_update()
2862 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2866 vs = hdw->std_mask_cur; in pvr2_subdev_update()
2867 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2871 hdw->tuner_signal_stale = !0; in pvr2_subdev_update()
2872 hdw->cropcap_stale = !0; in pvr2_subdev_update()
2885 if (hdw->input_dirty || hdw->audiomode_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2888 vt.type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? in pvr2_subdev_update()
2890 vt.audmode = hdw->audiomode_val; in pvr2_subdev_update()
2891 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt); in pvr2_subdev_update()
2894 if (hdw->freqDirty || hdw->force_dirty) { in pvr2_subdev_update()
2899 if (hdw->tuner_signal_stale) pvr2_hdw_status_poll(hdw); in pvr2_subdev_update()
2901 if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { in pvr2_subdev_update()
2907 /* tuner-core currently doesn't seem to care about this, but in pvr2_subdev_update()
2909 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_subdev_update()
2915 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, in pvr2_subdev_update()
2919 if (hdw->res_hor_dirty || hdw->res_ver_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2924 format.format.width = hdw->res_hor_val; in pvr2_subdev_update()
2925 format.format.height = hdw->res_ver_val; in pvr2_subdev_update()
2929 v4l2_device_call_all(&hdw->v4l2_dev, 0, pad, set_fmt, in pvr2_subdev_update()
2933 if (hdw->srate_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2936 hdw->srate_val); in pvr2_subdev_update()
2937 switch (hdw->srate_val) { in pvr2_subdev_update()
2949 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2956 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) { in pvr2_subdev_update()
2957 id = sd->grp_id; in pvr2_subdev_update()
2964 if (hdw->tuner_signal_stale || hdw->cropcap_stale) { in pvr2_subdev_update()
2978 int commit_flag = hdw->force_dirty; in pvr2_hdw_commit_setup()
2982 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_commit_setup()
2983 cptr = hdw->controls + idx; in pvr2_hdw_commit_setup()
2984 if (!cptr->info->is_dirty) continue; in pvr2_hdw_commit_setup()
2985 if (!cptr->info->is_dirty(cptr)) continue; in pvr2_hdw_commit_setup()
2989 bcnt = scnprintf(buf,sizeof(buf),"\"%s\" <-- ", in pvr2_hdw_commit_setup()
2990 cptr->info->name); in pvr2_hdw_commit_setup()
2992 cptr->info->get_value(cptr,&value); in pvr2_hdw_commit_setup()
2995 sizeof(buf)-bcnt,&ccnt); in pvr2_hdw_commit_setup()
2997 bcnt += scnprintf(buf+bcnt,sizeof(buf)-bcnt," <%s>", in pvr2_hdw_commit_setup()
2998 get_ctrl_typename(cptr->info->type)); in pvr2_hdw_commit_setup()
3000 "/*--TRACE_COMMIT--*/ %.*s", in pvr2_hdw_commit_setup()
3009 hdw->state_pipeline_config = 0; in pvr2_hdw_commit_setup()
3010 trace_stbit("state_pipeline_config",hdw->state_pipeline_config); in pvr2_hdw_commit_setup()
3028 if (hdw->input_dirty && hdw->state_pathway_ok && in pvr2_hdw_commit_execute()
3029 (((hdw->input_val == PVR2_CVAL_INPUT_DTV) ? in pvr2_hdw_commit_execute()
3031 hdw->pathway_state)) { in pvr2_hdw_commit_execute()
3033 hdw->state_pathway_ok = 0; in pvr2_hdw_commit_execute()
3034 trace_stbit("state_pathway_ok", hdw->state_pathway_ok); in pvr2_hdw_commit_execute()
3036 if (!hdw->state_pathway_ok) { in pvr2_hdw_commit_execute()
3043 if (hdw->std_dirty) { in pvr2_hdw_commit_execute()
3046 if (hdw->std_mask_cur & V4L2_STD_525_60) { in pvr2_hdw_commit_execute()
3055 if (nvres != hdw->res_ver_val) { in pvr2_hdw_commit_execute()
3056 hdw->res_ver_val = nvres; in pvr2_hdw_commit_execute()
3057 hdw->res_ver_dirty = !0; in pvr2_hdw_commit_execute()
3061 if (gop_size != hdw->enc_ctl_state.video_gop_size) { in pvr2_hdw_commit_execute()
3070 cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs, in pvr2_hdw_commit_execute()
3081 if (hdw->res_hor_dirty && hdw->cropw_val < hdw->res_hor_val) { in pvr2_hdw_commit_execute()
3082 hdw->cropw_val = hdw->res_hor_val; in pvr2_hdw_commit_execute()
3083 hdw->cropw_dirty = !0; in pvr2_hdw_commit_execute()
3084 } else if (hdw->cropw_dirty) { in pvr2_hdw_commit_execute()
3085 hdw->res_hor_dirty = !0; /* must rescale */ in pvr2_hdw_commit_execute()
3086 hdw->res_hor_val = min(720, hdw->cropw_val); in pvr2_hdw_commit_execute()
3088 if (hdw->res_ver_dirty && hdw->croph_val < hdw->res_ver_val) { in pvr2_hdw_commit_execute()
3089 hdw->croph_val = hdw->res_ver_val; in pvr2_hdw_commit_execute()
3090 hdw->croph_dirty = !0; in pvr2_hdw_commit_execute()
3091 } else if (hdw->croph_dirty) { in pvr2_hdw_commit_execute()
3092 int nvres = hdw->std_mask_cur & V4L2_STD_525_60 ? 480 : 576; in pvr2_hdw_commit_execute()
3093 hdw->res_ver_dirty = !0; in pvr2_hdw_commit_execute()
3094 hdw->res_ver_val = min(nvres, hdw->croph_val); in pvr2_hdw_commit_execute()
3099 and decoder -> encoder connection be made quiescent before we in pvr2_hdw_commit_execute()
3102 (hdw->std_dirty || in pvr2_hdw_commit_execute()
3103 hdw->enc_unsafe_stale || in pvr2_hdw_commit_execute()
3104 hdw->srate_dirty || in pvr2_hdw_commit_execute()
3105 hdw->res_ver_dirty || in pvr2_hdw_commit_execute()
3106 hdw->res_hor_dirty || in pvr2_hdw_commit_execute()
3107 hdw->cropw_dirty || in pvr2_hdw_commit_execute()
3108 hdw->croph_dirty || in pvr2_hdw_commit_execute()
3109 hdw->input_dirty || in pvr2_hdw_commit_execute()
3110 (hdw->active_stream_type != hdw->desired_stream_type)); in pvr2_hdw_commit_execute()
3111 if (disruptive_change && !hdw->state_pipeline_idle) { in pvr2_hdw_commit_execute()
3115 hdw->state_pipeline_pause = !0; in pvr2_hdw_commit_execute()
3119 if (hdw->srate_dirty) { in pvr2_hdw_commit_execute()
3131 c1.value = hdw->srate_val; in pvr2_hdw_commit_execute()
3132 cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs,VIDIOC_S_EXT_CTRLS); in pvr2_hdw_commit_execute()
3135 if (hdw->active_stream_type != hdw->desired_stream_type) { in pvr2_hdw_commit_execute()
3137 hdw->active_stream_type = hdw->desired_stream_type; in pvr2_hdw_commit_execute()
3140 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_hdw_commit_execute()
3145 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_commit_execute()
3154 /* Check and update state for all sub-devices. */ in pvr2_hdw_commit_execute()
3157 hdw->tuner_updated = 0; in pvr2_hdw_commit_execute()
3158 hdw->force_dirty = 0; in pvr2_hdw_commit_execute()
3159 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_commit_execute()
3160 cptr = hdw->controls + idx; in pvr2_hdw_commit_execute()
3161 if (!cptr->info->clear_dirty) continue; in pvr2_hdw_commit_execute()
3162 cptr->info->clear_dirty(cptr); in pvr2_hdw_commit_execute()
3165 if ((hdw->pathway_state == PVR2_PATHWAY_ANALOG) && in pvr2_hdw_commit_execute()
3166 hdw->state_encoder_run) { in pvr2_hdw_commit_execute()
3173 hdw->state_pipeline_config = !0; in pvr2_hdw_commit_execute()
3176 cause a later re-fetch. */ in pvr2_hdw_commit_execute()
3177 trace_stbit("state_pipeline_config",hdw->state_pipeline_config); in pvr2_hdw_commit_execute()
3185 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3187 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3197 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_worker_poll()
3199 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_worker_poll()
3200 if (fl && hdw->state_func) { in pvr2_hdw_worker_poll()
3201 hdw->state_func(hdw->state_data); in pvr2_hdw_worker_poll()
3209 hdw->state_wait_data, in pvr2_hdw_wait()
3210 (hdw->state_stale == 0) && in pvr2_hdw_wait()
3211 (!state || (hdw->master_state != state))); in pvr2_hdw_wait()
3218 return hdw->name; in pvr2_hdw_get_driver_name()
3224 return hdw->hdw_desc->description; in pvr2_hdw_get_desc()
3230 return hdw->hdw_desc->shortname; in pvr2_hdw_get_type()
3237 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_is_hsm()
3238 hdw->cmd_buffer[0] = FX2CMD_GET_USB_SPEED; in pvr2_hdw_is_hsm()
3240 hdw->cmd_buffer,1, in pvr2_hdw_is_hsm()
3241 hdw->cmd_buffer,1); in pvr2_hdw_is_hsm()
3243 result = (hdw->cmd_buffer[0] != 0); in pvr2_hdw_is_hsm()
3244 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_is_hsm()
3249 /* Execute poll of tuner status */
3252 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_execute_tuner_poll()
3254 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_execute_tuner_poll()
3260 if (!hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3264 if (hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3265 return -EIO; in pvr2_hdw_check_cropcap()
3275 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_get_cropcap()
3278 memcpy(pp, &hdw->cropcap_info, sizeof(hdw->cropcap_info)); in pvr2_hdw_get_cropcap()
3280 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_get_cropcap()
3288 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_get_tuner_status()
3290 if (hdw->tuner_signal_stale) { in pvr2_hdw_get_tuner_status()
3293 memcpy(vtp,&hdw->tuner_signal_info,sizeof(struct v4l2_tuner)); in pvr2_hdw_get_tuner_status()
3295 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_get_tuner_status()
3303 return hp->vid_stream; in pvr2_hdw_get_video_stream()
3310 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_trigger_module_log()
3313 v4l2_device_call_all(&hdw->v4l2_dev, 0, core, log_status); in pvr2_hdw_trigger_module_log()
3315 cx2341x_log_status(&hdw->enc_ctl_state, "pvrusb2"); in pvr2_hdw_trigger_module_log()
3319 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_trigger_module_log()
3345 hdw->eeprom_addr); in pvr2_full_eeprom_fetch()
3346 addr = hdw->eeprom_addr; in pvr2_full_eeprom_fetch()
3352 /* FX2 documentation states that a 16bit-addressed eeprom is in pvr2_full_eeprom_fetch()
3371 pass - which is what tveeprom is otherwise going to attempt */ in pvr2_full_eeprom_fetch()
3374 if (pcnt + tcnt > EEPROM_SIZE) pcnt = EEPROM_SIZE-tcnt; in pvr2_full_eeprom_fetch()
3375 offs = tcnt + (eepromSize - EEPROM_SIZE); in pvr2_full_eeprom_fetch()
3384 if ((ret = i2c_transfer(&hdw->i2c_adap, in pvr2_full_eeprom_fetch()
3403 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_cpufw_set_enabled()
3405 if ((hdw->fw_buffer == NULL) == !enable_flag) break; in pvr2_hdw_cpufw_set_enabled()
3410 kfree(hdw->fw_buffer); in pvr2_hdw_cpufw_set_enabled()
3411 hdw->fw_buffer = NULL; in pvr2_hdw_cpufw_set_enabled()
3412 hdw->fw_size = 0; in pvr2_hdw_cpufw_set_enabled()
3413 if (hdw->fw_cpu_flag) { in pvr2_hdw_cpufw_set_enabled()
3421 hdw->fw_cpu_flag = (mode != 2); in pvr2_hdw_cpufw_set_enabled()
3422 if (hdw->fw_cpu_flag) { in pvr2_hdw_cpufw_set_enabled()
3423 hdw->fw_size = (mode == 1) ? 0x4000 : 0x2000; in pvr2_hdw_cpufw_set_enabled()
3426 hdw->fw_size); in pvr2_hdw_cpufw_set_enabled()
3427 hdw->fw_buffer = kzalloc(hdw->fw_size,GFP_KERNEL); in pvr2_hdw_cpufw_set_enabled()
3428 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_set_enabled()
3429 hdw->fw_size = 0; in pvr2_hdw_cpufw_set_enabled()
3436 /* download the firmware from address 0000-1fff in 2048 in pvr2_hdw_cpufw_set_enabled()
3441 pipe = usb_rcvctrlpipe(hdw->usb_dev, 0); in pvr2_hdw_cpufw_set_enabled()
3442 for(address = 0; address < hdw->fw_size; in pvr2_hdw_cpufw_set_enabled()
3444 ret = usb_control_msg(hdw->usb_dev,pipe, in pvr2_hdw_cpufw_set_enabled()
3447 hdw->fw_buffer+address, in pvr2_hdw_cpufw_set_enabled()
3457 hdw->fw_buffer = pvr2_full_eeprom_fetch(hdw); in pvr2_hdw_cpufw_set_enabled()
3458 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_set_enabled()
3463 hdw->fw_size = EEPROM_SIZE; in pvr2_hdw_cpufw_set_enabled()
3468 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_cpufw_set_enabled()
3475 return hdw->fw_buffer != NULL; in pvr2_hdw_cpufw_get_enabled()
3482 int ret = -EINVAL; in pvr2_hdw_cpufw_get()
3483 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_cpufw_get()
3488 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_get()
3489 ret = -EIO; in pvr2_hdw_cpufw_get()
3493 if (offs >= hdw->fw_size) { in pvr2_hdw_cpufw_get()
3501 if (offs + cnt > hdw->fw_size) cnt = hdw->fw_size - offs; in pvr2_hdw_cpufw_get()
3503 memcpy(buf,hdw->fw_buffer+offs,cnt); in pvr2_hdw_cpufw_get()
3510 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_cpufw_get()
3520 case pvr2_v4l_type_video: return hdw->v4l_minor_number_video; in pvr2_hdw_v4l_get_minor_number()
3521 case pvr2_v4l_type_vbi: return hdw->v4l_minor_number_vbi; in pvr2_hdw_v4l_get_minor_number()
3522 case pvr2_v4l_type_radio: return hdw->v4l_minor_number_radio; in pvr2_hdw_v4l_get_minor_number()
3523 default: return -1; in pvr2_hdw_v4l_get_minor_number()
3533 case pvr2_v4l_type_video: hdw->v4l_minor_number_video = v;break; in pvr2_hdw_v4l_store_minor_number()
3534 case pvr2_v4l_type_vbi: hdw->v4l_minor_number_vbi = v;break; in pvr2_hdw_v4l_store_minor_number()
3535 case pvr2_v4l_type_radio: hdw->v4l_minor_number_radio = v;break; in pvr2_hdw_v4l_store_minor_number()
3543 struct pvr2_hdw *hdw = urb->context; in pvr2_ctl_write_complete()
3544 hdw->ctl_write_pend_flag = 0; in pvr2_ctl_write_complete()
3545 if (hdw->ctl_read_pend_flag) return; in pvr2_ctl_write_complete()
3546 complete(&hdw->ctl_done); in pvr2_ctl_write_complete()
3552 struct pvr2_hdw *hdw = urb->context; in pvr2_ctl_read_complete()
3553 hdw->ctl_read_pend_flag = 0; in pvr2_ctl_read_complete()
3554 if (hdw->ctl_write_pend_flag) return; in pvr2_ctl_read_complete()
3555 complete(&hdw->ctl_done); in pvr2_ctl_read_complete()
3566 struct pvr2_hdw *hdw = timer->hdw; in pvr2_ctl_timeout()
3568 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { in pvr2_ctl_timeout()
3569 hdw->ctl_timeout_flag = !0; in pvr2_ctl_timeout()
3570 if (hdw->ctl_write_pend_flag) in pvr2_ctl_timeout()
3571 usb_unlink_urb(hdw->ctl_write_urb); in pvr2_ctl_timeout()
3572 if (hdw->ctl_read_pend_flag) in pvr2_ctl_timeout()
3573 usb_unlink_urb(hdw->ctl_read_urb); in pvr2_ctl_timeout()
3581 This can be used to non-lethally probe the health of endpoint 1. */
3593 if (!hdw->ctl_lock_held) { in pvr2_send_request_ex()
3596 return -EDEADLK; in pvr2_send_request_ex()
3598 if (!hdw->flag_ok && !probe_fl) { in pvr2_send_request_ex()
3601 return -EIO; in pvr2_send_request_ex()
3603 if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) { in pvr2_send_request_ex()
3608 return -ENOTTY; in pvr2_send_request_ex()
3617 "Attempted to execute %d byte control-write transfer (limit=%d)", in pvr2_send_request_ex()
3619 return -EINVAL; in pvr2_send_request_ex()
3624 "Attempted to execute %d byte control-read transfer (limit=%d)", in pvr2_send_request_ex()
3626 return -EINVAL; in pvr2_send_request_ex()
3632 return -EINVAL; in pvr2_send_request_ex()
3636 hdw->cmd_debug_state = 1; in pvr2_send_request_ex()
3638 hdw->cmd_debug_code = ((unsigned char *)write_data)[0]; in pvr2_send_request_ex()
3640 hdw->cmd_debug_code = 0; in pvr2_send_request_ex()
3641 hdw->cmd_debug_write_len = write_len; in pvr2_send_request_ex()
3642 hdw->cmd_debug_read_len = read_len; in pvr2_send_request_ex()
3645 init_completion(&hdw->ctl_done); in pvr2_send_request_ex()
3646 hdw->ctl_timeout_flag = 0; in pvr2_send_request_ex()
3647 hdw->ctl_write_pend_flag = 0; in pvr2_send_request_ex()
3648 hdw->ctl_read_pend_flag = 0; in pvr2_send_request_ex()
3653 hdw->cmd_debug_state = 2; in pvr2_send_request_ex()
3656 hdw->ctl_write_buffer[idx] = in pvr2_send_request_ex()
3660 usb_fill_bulk_urb(hdw->ctl_write_urb, in pvr2_send_request_ex()
3661 hdw->usb_dev, in pvr2_send_request_ex()
3662 usb_sndbulkpipe(hdw->usb_dev, in pvr2_send_request_ex()
3664 hdw->ctl_write_buffer, in pvr2_send_request_ex()
3668 hdw->ctl_write_urb->actual_length = 0; in pvr2_send_request_ex()
3669 hdw->ctl_write_pend_flag = !0; in pvr2_send_request_ex()
3670 if (usb_urb_ep_type_check(hdw->ctl_write_urb)) { in pvr2_send_request_ex()
3674 return -EINVAL; in pvr2_send_request_ex()
3676 status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL); in pvr2_send_request_ex()
3679 "Failed to submit write-control URB status=%d", in pvr2_send_request_ex()
3681 hdw->ctl_write_pend_flag = 0; in pvr2_send_request_ex()
3687 hdw->cmd_debug_state = 3; in pvr2_send_request_ex()
3688 memset(hdw->ctl_read_buffer,0x43,read_len); in pvr2_send_request_ex()
3690 usb_fill_bulk_urb(hdw->ctl_read_urb, in pvr2_send_request_ex()
3691 hdw->usb_dev, in pvr2_send_request_ex()
3692 usb_rcvbulkpipe(hdw->usb_dev, in pvr2_send_request_ex()
3694 hdw->ctl_read_buffer, in pvr2_send_request_ex()
3698 hdw->ctl_read_urb->actual_length = 0; in pvr2_send_request_ex()
3699 hdw->ctl_read_pend_flag = !0; in pvr2_send_request_ex()
3700 if (usb_urb_ep_type_check(hdw->ctl_read_urb)) { in pvr2_send_request_ex()
3704 return -EINVAL; in pvr2_send_request_ex()
3706 status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL); in pvr2_send_request_ex()
3709 "Failed to submit read-control URB status=%d", in pvr2_send_request_ex()
3711 hdw->ctl_read_pend_flag = 0; in pvr2_send_request_ex()
3720 hdw->cmd_debug_state = 4; in pvr2_send_request_ex()
3721 while (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { in pvr2_send_request_ex()
3722 wait_for_completion(&hdw->ctl_done); in pvr2_send_request_ex()
3724 hdw->cmd_debug_state = 5; in pvr2_send_request_ex()
3729 hdw->cmd_debug_state = 6; in pvr2_send_request_ex()
3732 if (hdw->ctl_timeout_flag) { in pvr2_send_request_ex()
3733 status = -ETIMEDOUT; in pvr2_send_request_ex()
3736 "Timed out control-write"); in pvr2_send_request_ex()
3743 if ((hdw->ctl_write_urb->status != 0) && in pvr2_send_request_ex()
3744 (hdw->ctl_write_urb->status != -ENOENT) && in pvr2_send_request_ex()
3745 (hdw->ctl_write_urb->status != -ESHUTDOWN) && in pvr2_send_request_ex()
3746 (hdw->ctl_write_urb->status != -ECONNRESET)) { in pvr2_send_request_ex()
3749 status = hdw->ctl_write_urb->status; in pvr2_send_request_ex()
3752 "control-write URB failure, status=%d", in pvr2_send_request_ex()
3757 if (hdw->ctl_write_urb->actual_length < write_len) { in pvr2_send_request_ex()
3759 status = -EIO; in pvr2_send_request_ex()
3762 "control-write URB short, expected=%d got=%d", in pvr2_send_request_ex()
3764 hdw->ctl_write_urb->actual_length); in pvr2_send_request_ex()
3771 if ((hdw->ctl_read_urb->status != 0) && in pvr2_send_request_ex()
3772 (hdw->ctl_read_urb->status != -ENOENT) && in pvr2_send_request_ex()
3773 (hdw->ctl_read_urb->status != -ESHUTDOWN) && in pvr2_send_request_ex()
3774 (hdw->ctl_read_urb->status != -ECONNRESET)) { in pvr2_send_request_ex()
3777 status = hdw->ctl_read_urb->status; in pvr2_send_request_ex()
3780 "control-read URB failure, status=%d", in pvr2_send_request_ex()
3785 if (hdw->ctl_read_urb->actual_length < read_len) { in pvr2_send_request_ex()
3787 status = -EIO; in pvr2_send_request_ex()
3790 "control-read URB short, expected=%d got=%d", in pvr2_send_request_ex()
3792 hdw->ctl_read_urb->actual_length); in pvr2_send_request_ex()
3799 hdw->ctl_read_buffer[idx]; in pvr2_send_request_ex()
3805 hdw->cmd_debug_state = 0; in pvr2_send_request_ex()
3830 LOCK_TAKE(hdw->ctl_lock); in pvr2_issue_simple_cmd()
3831 hdw->cmd_buffer[0] = cmdcode & 0xffu; in pvr2_issue_simple_cmd()
3836 hdw->cmd_buffer[1] = (cmdcode >> 16) & 0xffu; in pvr2_issue_simple_cmd()
3838 hdw->cmd_buffer[2] = (cmdcode >> 24) & 0xffu; in pvr2_issue_simple_cmd()
3848 sizeof(tbuf)-bcnt, in pvr2_issue_simple_cmd()
3854 sizeof(tbuf)-bcnt, in pvr2_issue_simple_cmd()
3863 sizeof(tbuf)-bcnt, in pvr2_issue_simple_cmd()
3864 " (%u",hdw->cmd_buffer[1]); in pvr2_issue_simple_cmd()
3868 sizeof(tbuf)-bcnt, in pvr2_issue_simple_cmd()
3869 ",%u",hdw->cmd_buffer[2]); in pvr2_issue_simple_cmd()
3873 sizeof(tbuf)-bcnt, in pvr2_issue_simple_cmd()
3879 ret = pvr2_send_request(hdw,hdw->cmd_buffer,cnt,NULL,0); in pvr2_issue_simple_cmd()
3880 LOCK_GIVE(hdw->ctl_lock); in pvr2_issue_simple_cmd()
3889 LOCK_TAKE(hdw->ctl_lock); in pvr2_write_register()
3891 hdw->cmd_buffer[0] = FX2CMD_REG_WRITE; /* write register prefix */ in pvr2_write_register()
3892 PVR2_DECOMPOSE_LE(hdw->cmd_buffer,1,data); in pvr2_write_register()
3893 hdw->cmd_buffer[5] = 0; in pvr2_write_register()
3894 hdw->cmd_buffer[6] = (reg >> 8) & 0xff; in pvr2_write_register()
3895 hdw->cmd_buffer[7] = reg & 0xff; in pvr2_write_register()
3898 ret = pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 0); in pvr2_write_register()
3900 LOCK_GIVE(hdw->ctl_lock); in pvr2_write_register()
3910 LOCK_TAKE(hdw->ctl_lock); in pvr2_read_register()
3912 hdw->cmd_buffer[0] = FX2CMD_REG_READ; /* read register prefix */ in pvr2_read_register()
3913 hdw->cmd_buffer[1] = 0; in pvr2_read_register()
3914 hdw->cmd_buffer[2] = 0; in pvr2_read_register()
3915 hdw->cmd_buffer[3] = 0; in pvr2_read_register()
3916 hdw->cmd_buffer[4] = 0; in pvr2_read_register()
3917 hdw->cmd_buffer[5] = 0; in pvr2_read_register()
3918 hdw->cmd_buffer[6] = (reg >> 8) & 0xff; in pvr2_read_register()
3919 hdw->cmd_buffer[7] = reg & 0xff; in pvr2_read_register()
3921 ret |= pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 4); in pvr2_read_register()
3922 *data = PVR2_COMPOSE_LE(hdw->cmd_buffer,0); in pvr2_read_register()
3924 LOCK_GIVE(hdw->ctl_lock); in pvr2_read_register()
3932 if (!hdw->flag_ok) return; in pvr2_hdw_render_useless()
3935 if (hdw->vid_stream) { in pvr2_hdw_render_useless()
3936 pvr2_stream_setup(hdw->vid_stream,NULL,0,0); in pvr2_hdw_render_useless()
3938 hdw->flag_ok = 0; in pvr2_hdw_render_useless()
3939 trace_stbit("flag_ok",hdw->flag_ok); in pvr2_hdw_render_useless()
3948 ret = usb_lock_device_for_reset(hdw->usb_dev,NULL); in pvr2_hdw_device_reset()
3950 ret = usb_reset_device(hdw->usb_dev); in pvr2_hdw_device_reset()
3951 usb_unlock_device(hdw->usb_dev); in pvr2_hdw_device_reset()
3972 if (!hdw->usb_dev) return; in pvr2_hdw_cpureset_assert()
3988 pipe = usb_sndctrlpipe(hdw->usb_dev, 0); in pvr2_hdw_cpureset_assert()
3989 ret = usb_control_msg(hdw->usb_dev,pipe,0xa0,0x40,0xe600,0,da,1,1000); in pvr2_hdw_cpureset_assert()
4017 if (hdw->decoder_client_id) { in pvr2_hdw_cmd_decoder_reset()
4018 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, in pvr2_hdw_cmd_decoder_reset()
4025 return -ENOTTY; in pvr2_hdw_cmd_decoder_reset()
4031 hdw->flag_ok = !0; in pvr2_hdw_cmd_hcw_demod_reset()
4034 if (le16_to_cpu(hdw->usb_dev->descriptor.idVendor) == 0x2040 && in pvr2_hdw_cmd_hcw_demod_reset()
4035 (le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7502 || in pvr2_hdw_cmd_hcw_demod_reset()
4036 le16_to_cpu(hdw->usb_dev->descriptor.idProduct) == 0x7510)) { in pvr2_hdw_cmd_hcw_demod_reset()
4055 hdw->flag_ok = !0; in pvr2_hdw_cmd_onair_fe_power_ctrl()
4077 if (cmode == hdw->pathway_state) { in pvr2_hdw_cmd_modeswitch()
4082 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_modeswitch()
4103 hdw->pathway_state = cmode; in pvr2_hdw_cmd_modeswitch()
4137 if ((!onoff) == (!hdw->led_on)) return; in pvr2_led_ctrl()
4139 hdw->led_on = onoff != 0; in pvr2_led_ctrl()
4141 scheme_id = hdw->hdw_desc->led_scheme; in pvr2_led_ctrl()
4159 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in pvr2_hdw_cmd_usbstream()
4167 if (hdw->pathway_state != PVR2_PATHWAY_DIGITAL) { in pvr2_hdw_cmd_usbstream()
4169 return -EINVAL; in pvr2_hdw_cmd_usbstream()
4176 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_usbstream()
4190 return -EINVAL; in pvr2_hdw_cmd_usbstream()
4198 if (hdw->state_pathway_ok) { in state_eval_pathway_ok()
4202 if (!hdw->state_pipeline_idle) { in state_eval_pathway_ok()
4206 pvr2_hdw_cmd_modeswitch(hdw,hdw->input_val == PVR2_CVAL_INPUT_DTV); in state_eval_pathway_ok()
4207 hdw->state_pathway_ok = !0; in state_eval_pathway_ok()
4208 trace_stbit("state_pathway_ok",hdw->state_pathway_ok); in state_eval_pathway_ok()
4216 if (hdw->state_encoder_ok) return 0; in state_eval_encoder_ok()
4217 if (hdw->flag_tripped) return 0; in state_eval_encoder_ok()
4218 if (hdw->state_encoder_run) return 0; in state_eval_encoder_ok()
4219 if (hdw->state_encoder_config) return 0; in state_eval_encoder_ok()
4220 if (hdw->state_decoder_run) return 0; in state_eval_encoder_ok()
4221 if (hdw->state_usbstream_run) return 0; in state_eval_encoder_ok()
4222 if (hdw->pathway_state == PVR2_PATHWAY_DIGITAL) { in state_eval_encoder_ok()
4223 if (!hdw->hdw_desc->flag_digital_requires_cx23416) return 0; in state_eval_encoder_ok()
4224 } else if (hdw->pathway_state != PVR2_PATHWAY_ANALOG) { in state_eval_encoder_ok()
4229 hdw->flag_tripped = !0; in state_eval_encoder_ok()
4230 trace_stbit("flag_tripped",hdw->flag_tripped); in state_eval_encoder_ok()
4233 hdw->state_encoder_ok = !0; in state_eval_encoder_ok()
4234 trace_stbit("state_encoder_ok",hdw->state_encoder_ok); in state_eval_encoder_ok()
4242 if (hdw->state_encoder_config) { in state_eval_encoder_config()
4243 if (hdw->state_encoder_ok) { in state_eval_encoder_config()
4244 if (hdw->state_pipeline_req && in state_eval_encoder_config()
4245 !hdw->state_pipeline_pause) return 0; in state_eval_encoder_config()
4247 hdw->state_encoder_config = 0; in state_eval_encoder_config()
4248 hdw->state_encoder_waitok = 0; in state_eval_encoder_config()
4249 trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); in state_eval_encoder_config()
4250 /* paranoia - solve race if timer just completed */ in state_eval_encoder_config()
4251 del_timer_sync(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4253 if (!hdw->state_pathway_ok || in state_eval_encoder_config()
4254 (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || in state_eval_encoder_config()
4255 !hdw->state_encoder_ok || in state_eval_encoder_config()
4256 !hdw->state_pipeline_idle || in state_eval_encoder_config()
4257 hdw->state_pipeline_pause || in state_eval_encoder_config()
4258 !hdw->state_pipeline_req || in state_eval_encoder_config()
4259 !hdw->state_pipeline_config) { in state_eval_encoder_config()
4260 /* We must reset the enforced wait interval if in state_eval_encoder_config()
4263 if (timer_pending(&hdw->encoder_wait_timer)) { in state_eval_encoder_config()
4264 del_timer_sync(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4266 if (hdw->state_encoder_waitok) { in state_eval_encoder_config()
4267 /* Must clear the state - therefore we did in state_eval_encoder_config()
4270 hdw->state_encoder_waitok = 0; in state_eval_encoder_config()
4272 hdw->state_encoder_waitok); in state_eval_encoder_config()
4277 if (!hdw->state_encoder_waitok) { in state_eval_encoder_config()
4278 if (!timer_pending(&hdw->encoder_wait_timer)) { in state_eval_encoder_config()
4283 quiet interval before doing something to in state_eval_encoder_config()
4285 if (!hdw->state_encoder_waitok) { in state_eval_encoder_config()
4286 hdw->encoder_wait_timer.expires = in state_eval_encoder_config()
4289 add_timer(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4293 quiet for the interval measured by this in state_eval_encoder_config()
4298 if (hdw->state_encoder_ok) hdw->state_encoder_config = !0; in state_eval_encoder_config()
4300 trace_stbit("state_encoder_config",hdw->state_encoder_config); in state_eval_encoder_config()
4308 if (!hdw->state_encoder_ok) { in state_check_disable_encoder_run()
4312 if (!hdw->state_pathway_ok) { in state_check_disable_encoder_run()
4318 switch (hdw->pathway_state) { in state_check_disable_encoder_run()
4320 if (!hdw->state_decoder_run) { in state_check_disable_encoder_run()
4328 if (hdw->state_encoder_runok) { in state_check_disable_encoder_run()
4353 if (!hdw->state_encoder_ok) { in state_check_enable_encoder_run()
4357 if (!hdw->state_pathway_ok) { in state_check_enable_encoder_run()
4363 switch (hdw->pathway_state) { in state_check_enable_encoder_run()
4365 if (hdw->state_decoder_run && hdw->state_decoder_ready) { in state_check_enable_encoder_run()
4372 if ((hdw->hdw_desc->digital_control_scheme == in state_check_enable_encoder_run()
4374 !hdw->state_encoder_runok) { in state_check_enable_encoder_run()
4399 if (hdw->state_encoder_run) { in state_eval_encoder_run()
4401 if (hdw->state_encoder_ok) { in state_eval_encoder_run()
4402 del_timer_sync(&hdw->encoder_run_timer); in state_eval_encoder_run()
4405 hdw->state_encoder_run = 0; in state_eval_encoder_run()
4409 hdw->state_encoder_run = !0; in state_eval_encoder_run()
4410 if (!hdw->state_encoder_runok) { in state_eval_encoder_run()
4411 hdw->encoder_run_timer.expires = jiffies + in state_eval_encoder_run()
4413 add_timer(&hdw->encoder_run_timer); in state_eval_encoder_run()
4416 trace_stbit("state_encoder_run",hdw->state_encoder_run); in state_eval_encoder_run()
4425 hdw->state_decoder_quiescent = !0; in pvr2_hdw_quiescent_timeout()
4426 trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); in pvr2_hdw_quiescent_timeout()
4427 hdw->state_stale = !0; in pvr2_hdw_quiescent_timeout()
4428 schedule_work(&hdw->workpoll); in pvr2_hdw_quiescent_timeout()
4436 hdw->state_decoder_ready = !0; in pvr2_hdw_decoder_stabilization_timeout()
4437 trace_stbit("state_decoder_ready", hdw->state_decoder_ready); in pvr2_hdw_decoder_stabilization_timeout()
4438 hdw->state_stale = !0; in pvr2_hdw_decoder_stabilization_timeout()
4439 schedule_work(&hdw->workpoll); in pvr2_hdw_decoder_stabilization_timeout()
4447 hdw->state_encoder_waitok = !0; in pvr2_hdw_encoder_wait_timeout()
4448 trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); in pvr2_hdw_encoder_wait_timeout()
4449 hdw->state_stale = !0; in pvr2_hdw_encoder_wait_timeout()
4450 schedule_work(&hdw->workpoll); in pvr2_hdw_encoder_wait_timeout()
4458 if (!hdw->state_encoder_runok) { in pvr2_hdw_encoder_run_timeout()
4459 hdw->state_encoder_runok = !0; in pvr2_hdw_encoder_run_timeout()
4460 trace_stbit("state_encoder_runok",hdw->state_encoder_runok); in pvr2_hdw_encoder_run_timeout()
4461 hdw->state_stale = !0; in pvr2_hdw_encoder_run_timeout()
4462 schedule_work(&hdw->workpoll); in pvr2_hdw_encoder_run_timeout()
4470 if (hdw->state_decoder_run) { in state_eval_decoder_run()
4471 if (hdw->state_encoder_ok) { in state_eval_decoder_run()
4472 if (hdw->state_pipeline_req && in state_eval_decoder_run()
4473 !hdw->state_pipeline_pause && in state_eval_decoder_run()
4474 hdw->state_pathway_ok) return 0; in state_eval_decoder_run()
4476 if (!hdw->flag_decoder_missed) { in state_eval_decoder_run()
4479 hdw->state_decoder_quiescent = 0; in state_eval_decoder_run()
4480 hdw->state_decoder_run = 0; in state_eval_decoder_run()
4481 /* paranoia - solve race if timer(s) just completed */ in state_eval_decoder_run()
4482 del_timer_sync(&hdw->quiescent_timer); in state_eval_decoder_run()
4484 encoder before the previous stabilization interval has in state_eval_decoder_run()
4486 del_timer_sync(&hdw->decoder_stabilization_timer); in state_eval_decoder_run()
4487 hdw->state_decoder_ready = 0; in state_eval_decoder_run()
4489 if (!hdw->state_decoder_quiescent) { in state_eval_decoder_run()
4490 if (!timer_pending(&hdw->quiescent_timer)) { in state_eval_decoder_run()
4498 race - the timer could have run and set in state_eval_decoder_run()
4501 if (!hdw->state_decoder_quiescent) { in state_eval_decoder_run()
4502 hdw->quiescent_timer.expires = in state_eval_decoder_run()
4505 add_timer(&hdw->quiescent_timer); in state_eval_decoder_run()
4513 if (!hdw->state_pathway_ok || in state_eval_decoder_run()
4514 (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || in state_eval_decoder_run()
4515 !hdw->state_pipeline_req || in state_eval_decoder_run()
4516 hdw->state_pipeline_pause || in state_eval_decoder_run()
4517 !hdw->state_pipeline_config || in state_eval_decoder_run()
4518 !hdw->state_encoder_config || in state_eval_decoder_run()
4519 !hdw->state_encoder_ok) return 0; in state_eval_decoder_run()
4520 del_timer_sync(&hdw->quiescent_timer); in state_eval_decoder_run()
4521 if (hdw->flag_decoder_missed) return 0; in state_eval_decoder_run()
4523 hdw->state_decoder_quiescent = 0; in state_eval_decoder_run()
4524 hdw->state_decoder_ready = 0; in state_eval_decoder_run()
4525 hdw->state_decoder_run = !0; in state_eval_decoder_run()
4526 if (hdw->decoder_client_id == PVR2_CLIENT_ID_SAA7115) { in state_eval_decoder_run()
4527 hdw->decoder_stabilization_timer.expires = in state_eval_decoder_run()
4530 add_timer(&hdw->decoder_stabilization_timer); in state_eval_decoder_run()
4532 hdw->state_decoder_ready = !0; in state_eval_decoder_run()
4535 trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); in state_eval_decoder_run()
4536 trace_stbit("state_decoder_run",hdw->state_decoder_run); in state_eval_decoder_run()
4537 trace_stbit("state_decoder_ready", hdw->state_decoder_ready); in state_eval_decoder_run()
4545 if (hdw->state_usbstream_run) { in state_eval_usbstream_run()
4547 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in state_eval_usbstream_run()
4548 fl = (hdw->state_encoder_ok && in state_eval_usbstream_run()
4549 hdw->state_encoder_run); in state_eval_usbstream_run()
4550 } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && in state_eval_usbstream_run()
4551 (hdw->hdw_desc->flag_digital_requires_cx23416)) { in state_eval_usbstream_run()
4552 fl = hdw->state_encoder_ok; in state_eval_usbstream_run()
4555 hdw->state_pipeline_req && in state_eval_usbstream_run()
4556 !hdw->state_pipeline_pause && in state_eval_usbstream_run()
4557 hdw->state_pathway_ok) { in state_eval_usbstream_run()
4561 hdw->state_usbstream_run = 0; in state_eval_usbstream_run()
4563 if (!hdw->state_pipeline_req || in state_eval_usbstream_run()
4564 hdw->state_pipeline_pause || in state_eval_usbstream_run()
4565 !hdw->state_pathway_ok) return 0; in state_eval_usbstream_run()
4566 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in state_eval_usbstream_run()
4567 if (!hdw->state_encoder_ok || in state_eval_usbstream_run()
4568 !hdw->state_encoder_run) return 0; in state_eval_usbstream_run()
4569 } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && in state_eval_usbstream_run()
4570 (hdw->hdw_desc->flag_digital_requires_cx23416)) { in state_eval_usbstream_run()
4571 if (!hdw->state_encoder_ok) return 0; in state_eval_usbstream_run()
4572 if (hdw->state_encoder_run) return 0; in state_eval_usbstream_run()
4573 if (hdw->hdw_desc->digital_control_scheme == in state_eval_usbstream_run()
4580 if (!hdw->state_encoder_runok) return 0; in state_eval_usbstream_run()
4584 hdw->state_usbstream_run = !0; in state_eval_usbstream_run()
4586 trace_stbit("state_usbstream_run",hdw->state_usbstream_run); in state_eval_usbstream_run()
4594 if (hdw->state_pipeline_config || in state_eval_pipeline_config()
4595 hdw->state_pipeline_pause) return 0; in state_eval_pipeline_config()
4609 st = !(hdw->state_encoder_run || in state_update_pipeline_state()
4610 hdw->state_decoder_run || in state_update_pipeline_state()
4611 hdw->state_usbstream_run || in state_update_pipeline_state()
4612 (!hdw->state_decoder_quiescent)); in state_update_pipeline_state()
4613 if (!st != !hdw->state_pipeline_idle) { in state_update_pipeline_state()
4614 hdw->state_pipeline_idle = st; in state_update_pipeline_state()
4617 if (hdw->state_pipeline_idle && hdw->state_pipeline_pause) { in state_update_pipeline_state()
4618 hdw->state_pipeline_pause = 0; in state_update_pipeline_state()
4646 if (!hdw->state_stale) return 0; in pvr2_hdw_state_update()
4647 if ((hdw->fw1_state != FW1_STATE_OK) || in pvr2_hdw_state_update()
4648 !hdw->flag_ok) { in pvr2_hdw_state_update()
4649 hdw->state_stale = 0; in pvr2_hdw_state_update()
4663 for (i = 0; (i<ARRAY_SIZE(eval_funcs)) && hdw->flag_ok; i++) { in pvr2_hdw_state_update()
4670 } while (check_flag && hdw->flag_ok); in pvr2_hdw_state_update()
4671 hdw->state_stale = 0; in pvr2_hdw_state_update()
4672 trace_stbit("state_stale",hdw->state_stale); in pvr2_hdw_state_update()
4685 acnt-tcnt, in print_input_mask()
4713 (hdw->flag_ok ? " <ok>" : " <fail>"), in pvr2_hdw_report_unlocked()
4714 (hdw->flag_init_ok ? " <init>" : " <uninitialized>"), in pvr2_hdw_report_unlocked()
4715 (hdw->flag_disconnected ? " <disconnected>" : in pvr2_hdw_report_unlocked()
4717 (hdw->flag_tripped ? " <tripped>" : ""), in pvr2_hdw_report_unlocked()
4718 (hdw->flag_decoder_missed ? " <no decoder>" : ""), in pvr2_hdw_report_unlocked()
4719 pvr2_pathway_state_name(hdw->pathway_state)); in pvr2_hdw_report_unlocked()
4725 (hdw->state_pipeline_idle ? " <idle>" : ""), in pvr2_hdw_report_unlocked()
4726 (hdw->state_pipeline_config ? in pvr2_hdw_report_unlocked()
4728 (hdw->state_pipeline_req ? " <req>" : ""), in pvr2_hdw_report_unlocked()
4729 (hdw->state_pipeline_pause ? " <pause>" : "")); in pvr2_hdw_report_unlocked()
4734 (hdw->state_decoder_run ? in pvr2_hdw_report_unlocked()
4735 (hdw->state_decoder_ready ? in pvr2_hdw_report_unlocked()
4737 (hdw->state_decoder_quiescent ? in pvr2_hdw_report_unlocked()
4739 (hdw->state_decoder_quiescent ? in pvr2_hdw_report_unlocked()
4741 (hdw->state_encoder_ok ? in pvr2_hdw_report_unlocked()
4743 (hdw->state_encoder_run ? in pvr2_hdw_report_unlocked()
4744 (hdw->state_encoder_runok ? in pvr2_hdw_report_unlocked()
4747 (hdw->state_encoder_runok ? in pvr2_hdw_report_unlocked()
4750 (hdw->state_encoder_config ? in pvr2_hdw_report_unlocked()
4752 (hdw->state_encoder_waitok ? in pvr2_hdw_report_unlocked()
4754 (hdw->state_usbstream_run ? in pvr2_hdw_report_unlocked()
4756 (hdw->state_pathway_ok ? in pvr2_hdw_report_unlocked()
4762 pvr2_get_state_name(hdw->master_state)); in pvr2_hdw_report_unlocked()
4771 tcnt += print_input_mask(hdw->input_avail_mask, in pvr2_hdw_report_unlocked()
4773 acnt-tcnt); in pvr2_hdw_report_unlocked()
4774 if (hdw->input_avail_mask != hdw->input_allowed_mask) { in pvr2_hdw_report_unlocked()
4776 acnt-tcnt, in pvr2_hdw_report_unlocked()
4779 tcnt += print_input_mask(hdw->input_allowed_mask, in pvr2_hdw_report_unlocked()
4781 acnt-tcnt); in pvr2_hdw_report_unlocked()
4787 if (!hdw->vid_stream) break; in pvr2_hdw_report_unlocked()
4788 pvr2_stream_get_stats(hdw->vid_stream, in pvr2_hdw_report_unlocked()
4802 unsigned int id = hdw->ir_scheme_active; in pvr2_hdw_report_unlocked()
4813 /* Generate report containing info about attached sub-devices and attached
4815 actually sub-devices. */
4826 ccnt = scnprintf(buf, acnt, "Associated v4l2-subdev drivers and I2C clients:\n"); in pvr2_hdw_report_clients()
4828 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) { in pvr2_hdw_report_clients()
4829 id = sd->grp_id; in pvr2_hdw_report_clients()
4833 ccnt = scnprintf(buf + tcnt, acnt - tcnt, " %s:", p); in pvr2_hdw_report_clients()
4836 ccnt = scnprintf(buf + tcnt, acnt - tcnt, in pvr2_hdw_report_clients()
4842 ccnt = scnprintf(buf + tcnt, acnt - tcnt, in pvr2_hdw_report_clients()
4843 " %s @ %02x\n", client->name, in pvr2_hdw_report_clients()
4844 client->addr); in pvr2_hdw_report_clients()
4847 ccnt = scnprintf(buf + tcnt, acnt - tcnt, in pvr2_hdw_report_clients()
4861 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_state_report()
4865 bcnt += ccnt; acnt -= ccnt; buf += ccnt; in pvr2_hdw_state_report()
4868 bcnt += ccnt; acnt -= ccnt; buf += ccnt; in pvr2_hdw_state_report()
4871 bcnt += ccnt; acnt -= ccnt; buf += ccnt; in pvr2_hdw_state_report()
4872 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_state_report()
4886 pr_info("%s %.*s\n", hdw->name, ccnt, buf); in pvr2_hdw_state_log_state()
4898 pr_info("%s %.*s\n", hdw->name, lcnt, buf + ucnt); in pvr2_hdw_state_log_state()
4922 analog_mode = (hdw->pathway_state != PVR2_PATHWAY_DIGITAL); in pvr2_hdw_state_eval()
4925 if (!hdw->flag_ok) { in pvr2_hdw_state_eval()
4927 } else if (hdw->fw1_state != FW1_STATE_OK) { in pvr2_hdw_state_eval()
4930 hdw->hdw_desc->flag_digital_requires_cx23416) && in pvr2_hdw_state_eval()
4931 !hdw->state_encoder_ok) { in pvr2_hdw_state_eval()
4933 } else if (hdw->flag_tripped || in pvr2_hdw_state_eval()
4934 (analog_mode && hdw->flag_decoder_missed)) { in pvr2_hdw_state_eval()
4936 } else if (hdw->state_usbstream_run && in pvr2_hdw_state_eval()
4938 (hdw->state_encoder_run && hdw->state_decoder_run))) { in pvr2_hdw_state_eval()
4943 if (hdw->master_state != st) { in pvr2_hdw_state_eval()
4946 pvr2_get_state_name(hdw->master_state), in pvr2_hdw_state_eval()
4949 hdw->master_state = st; in pvr2_hdw_state_eval()
4955 wake_up(&hdw->state_wait_data); in pvr2_hdw_state_eval()
4971 if (hdw->state_stale) return; in pvr2_hdw_state_sched()
4972 hdw->state_stale = !0; in pvr2_hdw_state_sched()
4973 trace_stbit("state_stale",hdw->state_stale); in pvr2_hdw_state_sched()
4974 schedule_work(&hdw->workpoll); in pvr2_hdw_state_sched()
5038 struct v4l2_tuner *vtp = &hdw->tuner_signal_info; in pvr2_hdw_status_poll()
5040 vtp->type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? in pvr2_hdw_status_poll()
5042 hdw->tuner_signal_stale = 0; in pvr2_hdw_status_poll()
5044 using v4l2-subdev - therefore we can't support that AT ALL right in pvr2_hdw_status_poll()
5045 now. (Of course, no sub-drivers seem to implement it either. in pvr2_hdw_status_poll()
5047 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, vtp); in pvr2_hdw_status_poll()
5048 …pvr2_trace(PVR2_TRACE_CHIPS, "subdev status poll type=%u strength=%u audio=0x%x cap=0x%x low=%u hi… in pvr2_hdw_status_poll()
5049 vtp->type, in pvr2_hdw_status_poll()
5050 vtp->signal, vtp->rxsubchans, vtp->capability, in pvr2_hdw_status_poll()
5051 vtp->rangelow, vtp->rangehigh); in pvr2_hdw_status_poll()
5054 there's nobody to answer a poll of cropcap info. */ in pvr2_hdw_status_poll()
5055 hdw->cropcap_stale = 0; in pvr2_hdw_status_poll()
5061 return hdw->input_avail_mask; in pvr2_hdw_get_input_available()
5067 return hdw->input_allowed_mask; in pvr2_hdw_get_input_allowed()
5073 if (hdw->input_val != v) { in pvr2_hdw_set_input()
5074 hdw->input_val = v; in pvr2_hdw_set_input()
5075 hdw->input_dirty = !0; in pvr2_hdw_set_input()
5078 /* Handle side effects - if we switch to a mode that needs the RF in pvr2_hdw_set_input()
5081 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_set_input()
5082 hdw->freqSelector = 0; in pvr2_hdw_set_input()
5083 hdw->freqDirty = !0; in pvr2_hdw_set_input()
5084 } else if ((hdw->input_val == PVR2_CVAL_INPUT_TV) || in pvr2_hdw_set_input()
5085 (hdw->input_val == PVR2_CVAL_INPUT_DTV)) { in pvr2_hdw_set_input()
5086 hdw->freqSelector = 1; in pvr2_hdw_set_input()
5087 hdw->freqDirty = !0; in pvr2_hdw_set_input()
5099 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_set_input_allowed()
5101 nv = hdw->input_allowed_mask & ~change_mask; in pvr2_hdw_set_input_allowed()
5103 nv &= hdw->input_avail_mask; in pvr2_hdw_set_input_allowed()
5106 ret = -EPERM; in pvr2_hdw_set_input_allowed()
5109 hdw->input_allowed_mask = nv; in pvr2_hdw_set_input_allowed()
5110 if ((1UL << hdw->input_val) & hdw->input_allowed_mask) { in pvr2_hdw_set_input_allowed()
5117 if (!hdw->input_allowed_mask) { in pvr2_hdw_set_input_allowed()
5121 m = hdw->input_allowed_mask; in pvr2_hdw_set_input_allowed()
5128 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_input_allowed()
5137 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_get_eeprom_addr()
5138 hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR; in pvr2_hdw_get_eeprom_addr()
5140 hdw->cmd_buffer,1, in pvr2_hdw_get_eeprom_addr()
5141 hdw->cmd_buffer,1); in pvr2_hdw_get_eeprom_addr()
5143 result = hdw->cmd_buffer[0]; in pvr2_hdw_get_eeprom_addr()
5144 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_get_eeprom_addr()