Lines Matching refs:hdw

314 static int pvr2_hdw_set_input(struct pvr2_hdw *hdw,int v);
322 static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
323 static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw);
324 static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
330 static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
334 static int pvr2_hdw_check_cropcap(struct pvr2_hdw *hdw);
335 static v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw);
346 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channelfreq_get() local
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() local
358 unsigned int slotId = hdw->freqProgSlot; in ctrl_channelfreq_set()
360 hdw->freqTable[slotId-1] = v; 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() local
387 hdw->freqProgSlot = v; in ctrl_channelprog_set()
394 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channel_get() local
395 *vp = hdw->freqSelector ? hdw->freqSlotRadio : hdw->freqSlotTelevision; in ctrl_channel_get()
402 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channel_set() local
405 freq = hdw->freqTable[slotId-1]; in ctrl_channel_set()
407 pvr2_hdw_set_cur_freq(hdw,freq); 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()
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()
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()
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()
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()
499 cleft = cptr->hdw->cropl_val; 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()
515 ctop = cptr->hdw->cropt_val; 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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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() local
686 if (hdw->tuner_signal_stale) { in ctrl_freq_max_get()
687 pvr2_hdw_status_poll(hdw); 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() local
708 if (hdw->tuner_signal_stale) { in ctrl_freq_min_get()
709 pvr2_hdw_status_poll(hdw); 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()
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() local
766 ret = cx2341x_ext_ctrls(&hdw->enc_ctl_state, in ctrl_cx2341x_set()
767 hdw->state_encoder_run, &cs, 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()
790 cx2341x_ctrl_query(&cptr->hdw->enc_ctl_state,&qctrl); 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() local
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()
877 *vp = cptr->hdw->std_mask_cur; in ctrl_stdcur_get()
883 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_stdcur_set() local
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() local
906 pvr2_hdw_status_poll(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() local
916 pvr2_hdw_status_poll(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;}
1280 struct usb_device *pvr2_hdw_get_dev(struct pvr2_hdw *hdw) in pvr2_hdw_get_dev() argument
1282 return hdw->usb_dev; in pvr2_hdw_get_dev()
1286 unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw) in pvr2_hdw_get_sn() argument
1288 return hdw->serial_number; in pvr2_hdw_get_sn()
1292 const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *hdw) in pvr2_hdw_get_bus_info() argument
1294 return hdw->bus_info; in pvr2_hdw_get_bus_info()
1298 const char *pvr2_hdw_get_device_identifier(struct pvr2_hdw *hdw) in pvr2_hdw_get_device_identifier() argument
1300 return hdw->identifier; in pvr2_hdw_get_device_identifier()
1304 unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *hdw) in pvr2_hdw_get_cur_freq() argument
1306 return hdw->freqSelector ? hdw->freqValTelevision : hdw->freqValRadio; in pvr2_hdw_get_cur_freq()
1311 static void pvr2_hdw_set_cur_freq(struct pvr2_hdw *hdw,unsigned long val) in pvr2_hdw_set_cur_freq() argument
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()
1338 int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw) in pvr2_hdw_get_unit_number() argument
1340 return hdw->unit_number; in pvr2_hdw_get_unit_number()
1350 static int pvr2_locate_firmware(struct pvr2_hdw *hdw, in pvr2_locate_firmware() argument
1361 &hdw->usb_dev->dev); in pvr2_locate_firmware()
1406 static int pvr2_upload_firmware1(struct pvr2_hdw *hdw) in pvr2_upload_firmware1() argument
1415 if (!hdw->hdw_desc->fx2_firmware.cnt) { in pvr2_upload_firmware1()
1416 hdw->fw1_state = FW1_STATE_OK; in pvr2_upload_firmware1()
1422 hdw->fw1_state = FW1_STATE_FAILED; // default result in pvr2_upload_firmware1()
1426 ret = pvr2_locate_firmware(hdw,&fw_entry,"fx2 controller", 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()
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()
1461 pvr2_hdw_cpureset_assert(hdw,1); in pvr2_upload_firmware1()
1469 ret += usb_control_msg(hdw->usb_dev, pipe, 0xa0, 0x40, address, in pvr2_upload_firmware1()
1476 pvr2_hdw_cpureset_assert(hdw,0); in pvr2_upload_firmware1()
1485 hdw->fw1_state = FW1_STATE_RELOAD; in pvr2_upload_firmware1()
1500 int pvr2_upload_firmware2(struct pvr2_hdw *hdw) in pvr2_upload_firmware2() argument
1512 if (hdw->hdw_desc->flag_skip_cx23416_firmware) { in pvr2_upload_firmware2()
1518 ret = pvr2_locate_firmware(hdw,&fw_entry,"encoder", 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()
1537 ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/ in pvr2_upload_firmware2()
1538 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/ in pvr2_upload_firmware2()
1539 ret |= pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000008); /*gpio output state*/ in pvr2_upload_firmware2()
1540 ret |= pvr2_hdw_cmd_deep_reset(hdw); in pvr2_upload_firmware2()
1541 ret |= pvr2_write_register(hdw, 0xa064, 0x00000000); /*APU command*/ in pvr2_upload_firmware2()
1542 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000408); /*gpio dir*/ in pvr2_upload_firmware2()
1543 ret |= pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000008); /*gpio output state*/ in pvr2_upload_firmware2()
1544 ret |= pvr2_write_register(hdw, 0x9058, 0xffffffed); /*VPU ctrl*/ in pvr2_upload_firmware2()
1545 ret |= pvr2_write_register(hdw, 0x9054, 0xfffffffd); /*reset hw blocks*/ in pvr2_upload_firmware2()
1546 ret |= pvr2_write_register(hdw, 0x07f8, 0x80000800); /*encoder SDRAM refresh*/ in pvr2_upload_firmware2()
1547 ret |= pvr2_write_register(hdw, 0x07fc, 0x0000001a); /*encoder SDRAM pre-charge*/ in pvr2_upload_firmware2()
1548 ret |= pvr2_write_register(hdw, 0x0700, 0x00000000); /*I2C clock*/ in pvr2_upload_firmware2()
1549 ret |= pvr2_write_register(hdw, 0xaa00, 0x00000000); /*unknown*/ in pvr2_upload_firmware2()
1550 ret |= pvr2_write_register(hdw, 0xaa04, 0x00057810); /*unknown*/ in pvr2_upload_firmware2()
1551 ret |= pvr2_write_register(hdw, 0xaa10, 0x00148500); /*unknown*/ in pvr2_upload_firmware2()
1552 ret |= pvr2_write_register(hdw, 0xaa18, 0x00840000); /*unknown*/ in pvr2_upload_firmware2()
1553 ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_FWPOST1); in pvr2_upload_firmware2()
1554 ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_MEMSEL | (1 << 8) | (0 << 16)); in pvr2_upload_firmware2()
1585 pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT); in pvr2_upload_firmware2()
1607 ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,bcnt, in pvr2_upload_firmware2()
1628 ret |= pvr2_write_register(hdw, 0x9054, 0xffffffff); /*reset hw blocks*/ in pvr2_upload_firmware2()
1629 ret |= pvr2_write_register(hdw, 0x9058, 0xffffffe8); /*VPU ctrl*/ in pvr2_upload_firmware2()
1630 ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_MEMSEL | (1 << 8) | (0 << 16)); in pvr2_upload_firmware2()
1638 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_upload_firmware2()
1642 pvr2_hdw_gpio_chg_dir(hdw,(1 << 11),~0); in pvr2_upload_firmware2()
1656 static int pvr2_decoder_enable(struct pvr2_hdw *hdw,int enablefl) in pvr2_decoder_enable() argument
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()
1683 int pvr2_hdw_get_state(struct pvr2_hdw *hdw) in pvr2_hdw_get_state() argument
1685 return hdw->master_state; in pvr2_hdw_get_state()
1689 static int pvr2_hdw_untrip_unlocked(struct pvr2_hdw *hdw) in pvr2_hdw_untrip_unlocked() argument
1691 if (!hdw->flag_tripped) return 0; in pvr2_hdw_untrip_unlocked()
1692 hdw->flag_tripped = 0; in pvr2_hdw_untrip_unlocked()
1699 int pvr2_hdw_untrip(struct pvr2_hdw *hdw) in pvr2_hdw_untrip() argument
1702 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_untrip()
1703 fl = pvr2_hdw_untrip_unlocked(hdw); in pvr2_hdw_untrip()
1704 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_untrip()
1705 if (fl) pvr2_hdw_state_sched(hdw); in pvr2_hdw_untrip()
1712 int pvr2_hdw_get_streaming(struct pvr2_hdw *hdw) in pvr2_hdw_get_streaming() argument
1714 return hdw->state_pipeline_req != 0; in pvr2_hdw_get_streaming()
1718 int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag) in pvr2_hdw_set_streaming() argument
1721 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_set_streaming()
1722 pvr2_hdw_untrip_unlocked(hdw); 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()
1729 pvr2_hdw_state_sched(hdw); in pvr2_hdw_set_streaming()
1730 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_streaming()
1731 if ((ret = pvr2_hdw_wait(hdw,0)) < 0) return ret; in pvr2_hdw_set_streaming()
1733 while ((st = hdw->master_state) != PVR2_STATE_RUN) { in pvr2_hdw_set_streaming()
1735 if ((ret = pvr2_hdw_wait(hdw,st)) < 0) return ret; in pvr2_hdw_set_streaming()
1742 int pvr2_hdw_set_stream_type(struct pvr2_hdw *hdw,enum pvr2_config config) in pvr2_hdw_set_stream_type() argument
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()
1751 pvr2_hdw_state_sched(hdw); in pvr2_hdw_set_stream_type()
1753 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_stream_type()
1755 return pvr2_hdw_wait(hdw,0); in pvr2_hdw_set_stream_type()
1759 static int get_default_tuner_type(struct pvr2_hdw *hdw) in get_default_tuner_type() argument
1761 int unit_number = hdw->unit_number; 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()
1773 static v4l2_std_id get_default_standard(struct pvr2_hdw *hdw) in get_default_standard() argument
1775 int unit_number = hdw->unit_number; in get_default_standard()
1785 static unsigned int get_default_error_tolerance(struct pvr2_hdw *hdw) in get_default_error_tolerance() argument
1787 int unit_number = hdw->unit_number; in get_default_error_tolerance()
1796 static int pvr2_hdw_check_firmware(struct pvr2_hdw *hdw) in pvr2_hdw_check_firmware() argument
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()
1805 result = pvr2_send_request_ex(hdw,HZ*1,!0, 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()
1859 static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw) in pvr2_hdw_setup_std() argument
1865 std1 = get_default_standard(hdw); in pvr2_hdw_setup_std()
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()
1943 static void pvr2_hdw_cx25840_vbi_hack(struct pvr2_hdw *hdw) in pvr2_hdw_cx25840_vbi_hack() argument
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()
1972 static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, in pvr2_hdw_load_subdev() argument
1989 hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
1995 hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2014 mid, fname, hdw->hdw_desc->description); 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()
2035 mid, fname, hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2051 hdw->decoder_client_id = mid; in pvr2_hdw_load_subdev()
2060 static void pvr2_hdw_load_modules(struct pvr2_hdw *hdw) in pvr2_hdw_load_modules() argument
2067 cm = &hdw->hdw_desc->client_modules; in pvr2_hdw_load_modules()
2072 ct = &hdw->hdw_desc->client_table; 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()
2078 pvr2_hdw_render_useless(hdw); in pvr2_hdw_load_modules()
2083 static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw) in pvr2_hdw_setup_low() argument
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()
2100 reloadFl = !pvr2_hdw_check_firmware(hdw); in pvr2_hdw_setup_low()
2107 if (pvr2_upload_firmware1(hdw) != 0) { in pvr2_hdw_setup_low()
2114 hdw->fw1_state = FW1_STATE_OK; in pvr2_hdw_setup_low()
2116 if (!pvr2_hdw_dev_ok(hdw)) return; 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()
2121 pvr2_hdw_cmd_powerup(hdw); in pvr2_hdw_setup_low()
2122 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2126 if (hdw->ir_scheme_active == PVR2_IR_SCHEME_ZILOG) { in pvr2_hdw_setup_low()
2127 pvr2_issue_simple_cmd(hdw, in pvr2_hdw_setup_low()
2134 pvr2_i2c_core_init(hdw); in pvr2_hdw_setup_low()
2135 if (!pvr2_hdw_dev_ok(hdw)) return; 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()
2143 pvr2_issue_simple_cmd(hdw, in pvr2_hdw_setup_low()
2148 pvr2_issue_simple_cmd(hdw, in pvr2_hdw_setup_low()
2155 pvr2_hdw_load_modules(hdw); in pvr2_hdw_setup_low()
2156 if (!pvr2_hdw_dev_ok(hdw)) return; 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()
2167 pvr2_hdw_cx25840_vbi_hack(hdw); 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()
2181 if (hdw->hdw_desc->flag_has_hauppauge_rom) { in pvr2_hdw_setup_low()
2182 ret = pvr2_hdw_get_eeprom_addr(hdw); in pvr2_hdw_setup_low()
2183 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2188 hdw->eeprom_addr = ret; in pvr2_hdw_setup_low()
2189 pvr2_eeprom_analyze(hdw); in pvr2_hdw_setup_low()
2190 if (!pvr2_hdw_dev_ok(hdw)) return; 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()
2204 hdw->unit_number + 'a'); in pvr2_hdw_setup_low()
2206 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1, in pvr2_hdw_setup_low()
2209 hdw->identifier[idx] = 0; in pvr2_hdw_setup_low()
2211 pvr2_hdw_setup_std(hdw); in pvr2_hdw_setup_low()
2213 if (!get_default_tuner_type(hdw)) { in pvr2_hdw_setup_low()
2216 hdw->tuner_type); in pvr2_hdw_setup_low()
2220 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2222 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_hdw_setup_low()
2226 pvr2_hdw_gpio_chg_dir(hdw,(1 << 11),~0); in pvr2_hdw_setup_low()
2229 pvr2_hdw_commit_setup(hdw); in pvr2_hdw_setup_low()
2231 hdw->vid_stream = pvr2_stream_create(); in pvr2_hdw_setup_low()
2232 if (!pvr2_hdw_dev_ok(hdw)) return; 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()
2236 idx = get_default_error_tolerance(hdw); 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()
2246 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2248 hdw->flag_init_ok = !0; in pvr2_hdw_setup_low()
2250 pvr2_hdw_state_sched(hdw); in pvr2_hdw_setup_low()
2257 static void pvr2_hdw_setup(struct pvr2_hdw *hdw) in pvr2_hdw_setup() argument
2259 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) begin",hdw); in pvr2_hdw_setup()
2261 pvr2_hdw_setup_low(hdw); in pvr2_hdw_setup()
2264 hdw,pvr2_hdw_dev_ok(hdw),hdw->flag_init_ok); in pvr2_hdw_setup()
2265 if (pvr2_hdw_dev_ok(hdw)) { 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()
2304 hdw->fw1_state = FW1_STATE_UNKNOWN; in pvr2_hdw_setup()
2305 pvr2_upload_firmware1(hdw); in pvr2_hdw_setup()
2315 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) end",hdw); in pvr2_hdw_setup()
2322 int pvr2_hdw_initialize(struct pvr2_hdw *hdw, in pvr2_hdw_initialize() argument
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()
2338 pvr2_hdw_setup(hdw); 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()
2350 struct pvr2_hdw *hdw = NULL; in pvr2_hdw_create() local
2370 hdw = kzalloc(sizeof(*hdw),GFP_KERNEL); in pvr2_hdw_create()
2372 hdw,hdw_desc->description); in pvr2_hdw_create()
2386 if (!hdw) goto fail; 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()
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()
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()
2469 cx2341x_ctrl_query(&hdw->enc_ctl_state,&qctrl); 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()
2489 cx2341x_ctrl_get_menu(&hdw->enc_ctl_state, 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()
2510 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDAVAIL); 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()
2520 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR); 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()
2530 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDDETECT); 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()
2566 unit_pointers[idx] = hdw; 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()
2605 return hdw; in pvr2_hdw_create()
2607 if (hdw) { 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()
2620 kfree(hdw); in pvr2_hdw_create()
2628 static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw) in pvr2_hdw_remove_usb_stuff() argument
2630 if (hdw->flag_disconnected) return; in pvr2_hdw_remove_usb_stuff()
2631 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw); 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()
2657 pvr2_hdw_render_useless(hdw); in pvr2_hdw_remove_usb_stuff()
2660 void pvr2_hdw_set_v4l2_dev(struct pvr2_hdw *hdw, struct video_device *vdev) in pvr2_hdw_set_v4l2_dev() argument
2662 vdev->v4l2_dev = &hdw->v4l2_dev; in pvr2_hdw_set_v4l2_dev()
2666 void pvr2_hdw_destroy(struct pvr2_hdw *hdw) in pvr2_hdw_destroy() argument
2668 if (!hdw) return; in pvr2_hdw_destroy()
2669 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw); in pvr2_hdw_destroy()
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()
2684 pvr2_hdw_disconnect(hdw); 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()
2696 kfree(hdw); in pvr2_hdw_destroy()
2700 int pvr2_hdw_dev_ok(struct pvr2_hdw *hdw) in pvr2_hdw_dev_ok() argument
2702 return (hdw && hdw->flag_ok); in pvr2_hdw_dev_ok()
2707 void pvr2_hdw_disconnect(struct pvr2_hdw *hdw) in pvr2_hdw_disconnect() argument
2709 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_disconnect(hdw=%p)",hdw); in pvr2_hdw_disconnect()
2710 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_disconnect()
2711 pvr2_i2c_core_done(hdw); in pvr2_hdw_disconnect()
2712 LOCK_TAKE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2713 pvr2_hdw_remove_usb_stuff(hdw); in pvr2_hdw_disconnect()
2714 LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2715 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_disconnect()
2720 unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw) in pvr2_hdw_get_ctrl_count() argument
2722 return hdw->control_cnt; in pvr2_hdw_get_ctrl_count()
2727 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_by_index() argument
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()
2736 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_by_id() argument
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()
2754 struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id) in pvr2_hdw_get_ctrl_v4l() argument
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()
2772 struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_nextv4l() argument
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()
2806 static void pvr2_subdev_set_control(struct pvr2_hdw *hdw, int id, in pvr2_subdev_set_control() argument
2817 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) in pvr2_subdev_set_control()
2821 #define PVR2_SUBDEV_SET_CONTROL(hdw, id, lab) \ argument
2822 if ((hdw)->lab##_dirty || (hdw)->force_dirty) { \
2823 pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \
2826 static v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw) in pvr2_hdw_get_detected_std() argument
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()
2837 static void pvr2_subdev_update(struct pvr2_hdw *hdw) in pvr2_subdev_update() argument
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()
2869 pvr2_hdw_cx25840_vbi_hack(hdw); in pvr2_subdev_update()
2871 hdw->tuner_signal_stale = !0; in pvr2_subdev_update()
2872 hdw->cropcap_stale = !0; in pvr2_subdev_update()
2875 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_BRIGHTNESS, brightness); in pvr2_subdev_update()
2876 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_CONTRAST, contrast); in pvr2_subdev_update()
2877 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_SATURATION, saturation); in pvr2_subdev_update()
2878 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_HUE, hue); in pvr2_subdev_update()
2879 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_MUTE, mute); in pvr2_subdev_update()
2880 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_VOLUME, volume); in pvr2_subdev_update()
2881 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BALANCE, balance); in pvr2_subdev_update()
2882 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BASS, bass); in pvr2_subdev_update()
2883 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_TREBLE, treble); 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()
2897 fv = pvr2_hdw_get_cur_freq(hdw); 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()
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()
2961 (*fp)(hdw, sd); in pvr2_subdev_update()
2964 if (hdw->tuner_signal_stale || hdw->cropcap_stale) { in pvr2_subdev_update()
2965 pvr2_hdw_status_poll(hdw); in pvr2_subdev_update()
2973 static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw) in pvr2_hdw_commit_setup() argument
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()
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()
3011 pvr2_hdw_state_sched(hdw); in pvr2_hdw_commit_setup()
3022 static int pvr2_hdw_commit_execute(struct pvr2_hdw *hdw) in pvr2_hdw_commit_execute() argument
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()
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()
3144 pvr2_hdw_gpio_get_out(hdw,&b); in pvr2_hdw_commit_execute()
3145 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_commit_execute()
3147 pvr2_hdw_gpio_chg_out(hdw,(1 << 11),~0); in pvr2_hdw_commit_execute()
3150 pvr2_hdw_gpio_chg_out(hdw,(1 << 11),0); in pvr2_hdw_commit_execute()
3155 pvr2_subdev_update(hdw); 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()
3165 if ((hdw->pathway_state == PVR2_PATHWAY_ANALOG) && in pvr2_hdw_commit_execute()
3166 hdw->state_encoder_run) { in pvr2_hdw_commit_execute()
3170 if (pvr2_encoder_adjust(hdw) < 0) return !0; in pvr2_hdw_commit_execute()
3173 hdw->state_pipeline_config = !0; in pvr2_hdw_commit_execute()
3177 trace_stbit("state_pipeline_config",hdw->state_pipeline_config); in pvr2_hdw_commit_execute()
3182 int pvr2_hdw_commit_ctl(struct pvr2_hdw *hdw) in pvr2_hdw_commit_ctl() argument
3185 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3186 fl = pvr2_hdw_commit_setup(hdw); in pvr2_hdw_commit_ctl()
3187 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3189 return pvr2_hdw_wait(hdw,0); in pvr2_hdw_commit_ctl()
3196 struct pvr2_hdw *hdw = container_of(work,struct pvr2_hdw,workpoll); in pvr2_hdw_worker_poll() local
3197 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_worker_poll()
3198 fl = pvr2_hdw_state_eval(hdw); 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()
3206 static int pvr2_hdw_wait(struct pvr2_hdw *hdw,int state) in pvr2_hdw_wait() argument
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()
3216 const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw) in pvr2_hdw_get_driver_name() argument
3218 return hdw->name; in pvr2_hdw_get_driver_name()
3222 const char *pvr2_hdw_get_desc(struct pvr2_hdw *hdw) in pvr2_hdw_get_desc() argument
3224 return hdw->hdw_desc->description; in pvr2_hdw_get_desc()
3228 const char *pvr2_hdw_get_type(struct pvr2_hdw *hdw) in pvr2_hdw_get_type() argument
3230 return hdw->hdw_desc->shortname; in pvr2_hdw_get_type()
3234 int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw) in pvr2_hdw_is_hsm() argument
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()
3239 result = pvr2_send_request(hdw, 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()
3250 void pvr2_hdw_execute_tuner_poll(struct pvr2_hdw *hdw) in pvr2_hdw_execute_tuner_poll() argument
3252 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_execute_tuner_poll()
3253 pvr2_hdw_status_poll(hdw); in pvr2_hdw_execute_tuner_poll()
3254 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_execute_tuner_poll()
3258 static int pvr2_hdw_check_cropcap(struct pvr2_hdw *hdw) in pvr2_hdw_check_cropcap() argument
3260 if (!hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3263 pvr2_hdw_status_poll(hdw); in pvr2_hdw_check_cropcap()
3264 if (hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3272 int pvr2_hdw_get_cropcap(struct pvr2_hdw *hdw, struct v4l2_cropcap *pp) in pvr2_hdw_get_cropcap() argument
3275 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_get_cropcap()
3276 stat = pvr2_hdw_check_cropcap(hdw); 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()
3286 int pvr2_hdw_get_tuner_status(struct pvr2_hdw *hdw,struct v4l2_tuner *vtp) in pvr2_hdw_get_tuner_status() argument
3288 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_get_tuner_status()
3290 if (hdw->tuner_signal_stale) { in pvr2_hdw_get_tuner_status()
3291 pvr2_hdw_status_poll(hdw); 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()
3307 void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw) in pvr2_hdw_trigger_module_log() argument
3309 int nr = pvr2_hdw_get_unit_number(hdw); in pvr2_hdw_trigger_module_log()
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()
3316 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_trigger_module_log()
3319 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_trigger_module_log()
3326 static u8 *pvr2_full_eeprom_fetch(struct pvr2_hdw *hdw) in pvr2_full_eeprom_fetch() argument
3345 hdw->eeprom_addr); in pvr2_full_eeprom_fetch()
3346 addr = hdw->eeprom_addr; in pvr2_full_eeprom_fetch()
3384 if ((ret = i2c_transfer(&hdw->i2c_adap, in pvr2_full_eeprom_fetch()
3396 void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, in pvr2_hdw_cpufw_set_enabled() argument
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()
3416 pvr2_hdw_cpureset_assert(hdw,0); 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()
3434 pvr2_hdw_cpureset_assert(hdw,1); 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()
3473 int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw) in pvr2_hdw_cpufw_get_enabled() argument
3475 return hdw->fw_buffer != NULL; in pvr2_hdw_cpufw_get_enabled()
3479 int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs, in pvr2_hdw_cpufw_get() argument
3483 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_cpufw_get()
3488 if (!hdw->fw_buffer) { 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()
3516 int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw, in pvr2_hdw_v4l_get_minor_number() argument
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()
3529 void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw, in pvr2_hdw_v4l_store_minor_number() argument
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() local
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() local
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()
3560 struct pvr2_hdw *hdw; member
3566 struct pvr2_hdw *hdw = timer->hdw; in pvr2_ctl_timeout() local
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()
3582 static int pvr2_send_request_ex(struct pvr2_hdw *hdw, in pvr2_send_request_ex() argument
3590 .hdw = hdw, in pvr2_send_request_ex()
3593 if (!hdw->ctl_lock_held) { in pvr2_send_request_ex()
3598 if (!hdw->flag_ok && !probe_fl) { in pvr2_send_request_ex()
3603 if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) { 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()
3667 hdw); 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()
3676 status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL); 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()
3697 hdw); 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()
3706 status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL); 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()
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()
3757 if (hdw->ctl_write_urb->actual_length < write_len) { 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()
3785 if (hdw->ctl_read_urb->actual_length < read_len) { 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()
3807 pvr2_hdw_render_useless(hdw); in pvr2_send_request_ex()
3815 int pvr2_send_request(struct pvr2_hdw *hdw, in pvr2_send_request() argument
3819 return pvr2_send_request_ex(hdw,HZ*4,0, in pvr2_send_request()
3825 static int pvr2_issue_simple_cmd(struct pvr2_hdw *hdw,u32 cmdcode) in pvr2_issue_simple_cmd() argument
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()
3864 " (%u",hdw->cmd_buffer[1]); in pvr2_issue_simple_cmd()
3869 ",%u",hdw->cmd_buffer[2]); 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()
3885 int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data) in pvr2_write_register() argument
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()
3906 static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data) in pvr2_read_register() argument
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()
3930 void pvr2_hdw_render_useless(struct pvr2_hdw *hdw) in pvr2_hdw_render_useless() argument
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()
3940 pvr2_hdw_state_sched(hdw); in pvr2_hdw_render_useless()
3944 void pvr2_hdw_device_reset(struct pvr2_hdw *hdw) in pvr2_hdw_device_reset() argument
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()
3966 void pvr2_hdw_cpureset_assert(struct pvr2_hdw *hdw,int val) in pvr2_hdw_cpureset_assert() argument
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()
3993 pvr2_hdw_render_useless(hdw); in pvr2_hdw_cpureset_assert()
4000 int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_deep_reset() argument
4002 return pvr2_issue_simple_cmd(hdw,FX2CMD_DEEP_RESET); in pvr2_hdw_cmd_deep_reset()
4006 int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_powerup() argument
4008 return pvr2_issue_simple_cmd(hdw,FX2CMD_POWER_ON); in pvr2_hdw_cmd_powerup()
4013 int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_decoder_reset() argument
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()
4020 pvr2_hdw_cx25840_vbi_hack(hdw); in pvr2_hdw_cmd_decoder_reset()
4029 static int pvr2_hdw_cmd_hcw_demod_reset(struct pvr2_hdw *hdw, int onoff) in pvr2_hdw_cmd_hcw_demod_reset() argument
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()
4040 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_hcw_demod_reset()
4046 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_hcw_demod_reset()
4053 static int pvr2_hdw_cmd_onair_fe_power_ctrl(struct pvr2_hdw *hdw, int onoff) in pvr2_hdw_cmd_onair_fe_power_ctrl() argument
4055 hdw->flag_ok = !0; in pvr2_hdw_cmd_onair_fe_power_ctrl()
4056 return pvr2_issue_simple_cmd(hdw,(onoff ? in pvr2_hdw_cmd_onair_fe_power_ctrl()
4062 static int pvr2_hdw_cmd_onair_digital_path_ctrl(struct pvr2_hdw *hdw, in pvr2_hdw_cmd_onair_digital_path_ctrl() argument
4065 return pvr2_issue_simple_cmd(hdw,(onoff ? in pvr2_hdw_cmd_onair_digital_path_ctrl()
4071 static void pvr2_hdw_cmd_modeswitch(struct pvr2_hdw *hdw,int digitalFl) in pvr2_hdw_cmd_modeswitch() argument
4077 if (cmode == hdw->pathway_state) { in pvr2_hdw_cmd_modeswitch()
4082 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_modeswitch()
4084 pvr2_hdw_cmd_hcw_demod_reset(hdw,digitalFl); in pvr2_hdw_cmd_modeswitch()
4090 pvr2_hdw_cmd_decoder_reset(hdw); in pvr2_hdw_cmd_modeswitch()
4097 pvr2_hdw_cmd_onair_fe_power_ctrl(hdw,digitalFl); in pvr2_hdw_cmd_modeswitch()
4102 pvr2_hdw_untrip_unlocked(hdw); in pvr2_hdw_cmd_modeswitch()
4103 hdw->pathway_state = cmode; in pvr2_hdw_cmd_modeswitch()
4107 static void pvr2_led_ctrl_hauppauge(struct pvr2_hdw *hdw, int onoff) in pvr2_led_ctrl_hauppauge() argument
4116 pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000481); in pvr2_led_ctrl_hauppauge()
4118 pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000401); in pvr2_led_ctrl_hauppauge()
4120 pvr2_hdw_gpio_chg_out(hdw, 0xffffffff, 0x00000000); in pvr2_led_ctrl_hauppauge()
4132 static void pvr2_led_ctrl(struct pvr2_hdw *hdw,int onoff) in pvr2_led_ctrl() argument
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()
4148 if (fp) (*fp)(hdw,onoff); in pvr2_led_ctrl()
4153 static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl) in pvr2_hdw_cmd_usbstream() argument
4159 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in pvr2_hdw_cmd_usbstream()
4160 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4167 if (hdw->pathway_state != PVR2_PATHWAY_DIGITAL) { in pvr2_hdw_cmd_usbstream()
4176 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_usbstream()
4178 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4183 ret = pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4188 return pvr2_hdw_cmd_onair_digital_path_ctrl(hdw,runFl); in pvr2_hdw_cmd_usbstream()
4196 static int state_eval_pathway_ok(struct pvr2_hdw *hdw) in state_eval_pathway_ok() argument
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()
4214 static int state_eval_encoder_ok(struct pvr2_hdw *hdw) in state_eval_encoder_ok() argument
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()
4228 if (pvr2_upload_firmware2(hdw) < 0) { 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()
4240 static int state_eval_encoder_config(struct pvr2_hdw *hdw) in state_eval_encoder_config() argument
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()
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()
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()
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()
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()
4297 pvr2_encoder_configure(hdw); 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()
4306 static int state_check_disable_encoder_run(struct pvr2_hdw *hdw) in state_check_disable_encoder_run() argument
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()
4351 static int state_check_enable_encoder_run(struct pvr2_hdw *hdw) in state_check_enable_encoder_run() argument
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()
4397 static int state_eval_encoder_run(struct pvr2_hdw *hdw) in state_eval_encoder_run() argument
4399 if (hdw->state_encoder_run) { in state_eval_encoder_run()
4400 if (!state_check_disable_encoder_run(hdw)) return 0; 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()
4403 if (pvr2_encoder_stop(hdw) < 0) return !0; in state_eval_encoder_run()
4405 hdw->state_encoder_run = 0; in state_eval_encoder_run()
4407 if (!state_check_enable_encoder_run(hdw)) return 0; in state_eval_encoder_run()
4408 if (pvr2_encoder_start(hdw) < 0) return !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()
4424 struct pvr2_hdw *hdw = from_timer(hdw, t, quiescent_timer); in pvr2_hdw_quiescent_timeout() local
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()
4435 struct pvr2_hdw *hdw = from_timer(hdw, t, decoder_stabilization_timer); in pvr2_hdw_decoder_stabilization_timeout() local
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()
4446 struct pvr2_hdw *hdw = from_timer(hdw, t, encoder_wait_timer); in pvr2_hdw_encoder_wait_timeout() local
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()
4457 struct pvr2_hdw *hdw = from_timer(hdw, t, encoder_run_timer); in pvr2_hdw_encoder_run_timeout() local
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()
4468 static int state_eval_decoder_run(struct pvr2_hdw *hdw) in state_eval_decoder_run() argument
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()
4477 pvr2_decoder_enable(hdw,0); 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()
4482 del_timer_sync(&hdw->quiescent_timer); 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()
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()
4522 if (pvr2_decoder_enable(hdw,!0) < 0) 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()
4543 static int state_eval_usbstream_run(struct pvr2_hdw *hdw) in state_eval_usbstream_run() argument
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()
4560 pvr2_hdw_cmd_usbstream(hdw,0); 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()
4583 if (pvr2_hdw_cmd_usbstream(hdw,!0) < 0) 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()
4592 static int state_eval_pipeline_config(struct pvr2_hdw *hdw) in state_eval_pipeline_config() argument
4594 if (hdw->state_pipeline_config || in state_eval_pipeline_config()
4595 hdw->state_pipeline_pause) return 0; in state_eval_pipeline_config()
4596 pvr2_hdw_commit_execute(hdw); in state_eval_pipeline_config()
4604 static int state_update_pipeline_state(struct pvr2_hdw *hdw) in state_update_pipeline_state() argument
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()
4640 static int pvr2_hdw_state_update(struct pvr2_hdw *hdw) in pvr2_hdw_state_update() argument
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()
4661 state_update_pipeline_state(hdw); in pvr2_hdw_state_update()
4663 for (i = 0; (i<ARRAY_SIZE(eval_funcs)) && hdw->flag_ok; i++) { in pvr2_hdw_state_update()
4664 if ((*eval_funcs[i])(hdw)) { in pvr2_hdw_state_update()
4667 state_update_pipeline_state(hdw); 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()
4705 static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, in pvr2_hdw_report_unlocked() argument
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()
4774 if (hdw->input_avail_mask != hdw->input_allowed_mask) { in pvr2_hdw_report_unlocked()
4779 tcnt += print_input_mask(hdw->input_allowed_mask, 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()
4816 static unsigned int pvr2_hdw_report_clients(struct pvr2_hdw *hdw, in pvr2_hdw_report_clients() argument
4828 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) { in pvr2_hdw_report_clients()
4856 unsigned int pvr2_hdw_state_report(struct pvr2_hdw *hdw, in pvr2_hdw_state_report() argument
4861 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_state_report()
4863 ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,acnt); in pvr2_hdw_state_report()
4870 ccnt = pvr2_hdw_report_clients(hdw, buf, acnt); in pvr2_hdw_state_report()
4872 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_state_report()
4877 static void pvr2_hdw_state_log_state(struct pvr2_hdw *hdw) in pvr2_hdw_state_log_state() argument
4884 ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,sizeof(buf)); in pvr2_hdw_state_log_state()
4886 pr_info("%s %.*s\n", hdw->name, ccnt, buf); in pvr2_hdw_state_log_state()
4888 ccnt = pvr2_hdw_report_clients(hdw, buf, sizeof(buf)); in pvr2_hdw_state_log_state()
4898 pr_info("%s %.*s\n", hdw->name, lcnt, buf + ucnt); in pvr2_hdw_state_log_state()
4906 static int pvr2_hdw_state_eval(struct pvr2_hdw *hdw) in pvr2_hdw_state_eval() argument
4916 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_state_eval()
4920 state_updated = pvr2_hdw_state_update(hdw); in pvr2_hdw_state_eval()
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()
4948 pvr2_led_ctrl(hdw,st == PVR2_STATE_RUN); 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()
4959 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_state_eval()
4969 static void pvr2_hdw_state_sched(struct pvr2_hdw *hdw) in pvr2_hdw_state_sched() argument
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()
4978 int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_dir() argument
4980 return pvr2_read_register(hdw,PVR2_GPIO_DIR,dp); in pvr2_hdw_gpio_get_dir()
4984 int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_out() argument
4986 return pvr2_read_register(hdw,PVR2_GPIO_OUT,dp); in pvr2_hdw_gpio_get_out()
4990 int pvr2_hdw_gpio_get_in(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_in() argument
4992 return pvr2_read_register(hdw,PVR2_GPIO_IN,dp); in pvr2_hdw_gpio_get_in()
4996 int pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val) in pvr2_hdw_gpio_chg_dir() argument
5001 ret = pvr2_read_register(hdw,PVR2_GPIO_DIR,&cval); in pvr2_hdw_gpio_chg_dir()
5012 return pvr2_write_register(hdw,PVR2_GPIO_DIR,nval); in pvr2_hdw_gpio_chg_dir()
5016 int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val) in pvr2_hdw_gpio_chg_out() argument
5021 ret = pvr2_read_register(hdw,PVR2_GPIO_OUT,&cval); in pvr2_hdw_gpio_chg_out()
5032 return pvr2_write_register(hdw,PVR2_GPIO_OUT,nval); in pvr2_hdw_gpio_chg_out()
5036 void pvr2_hdw_status_poll(struct pvr2_hdw *hdw) in pvr2_hdw_status_poll() argument
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()
5047 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, vtp); in pvr2_hdw_status_poll()
5055 hdw->cropcap_stale = 0; in pvr2_hdw_status_poll()
5059 unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *hdw) in pvr2_hdw_get_input_available() argument
5061 return hdw->input_avail_mask; in pvr2_hdw_get_input_available()
5065 unsigned int pvr2_hdw_get_input_allowed(struct pvr2_hdw *hdw) in pvr2_hdw_get_input_allowed() argument
5067 return hdw->input_allowed_mask; in pvr2_hdw_get_input_allowed()
5071 static int pvr2_hdw_set_input(struct pvr2_hdw *hdw,int v) in pvr2_hdw_set_input() argument
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()
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()
5093 int pvr2_hdw_set_input_allowed(struct pvr2_hdw *hdw, in pvr2_hdw_set_input_allowed() argument
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()
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()
5124 pvr2_hdw_set_input(hdw,idx); in pvr2_hdw_set_input_allowed()
5128 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_input_allowed()
5134 static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) in pvr2_hdw_get_eeprom_addr() argument
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()
5139 result = pvr2_send_request(hdw, 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()