Lines Matching refs:hdw
326 static int pvr2_hdw_set_input(struct pvr2_hdw *hdw,int v);
334 static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
335 static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw);
336 static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
342 static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
346 static int pvr2_hdw_check_cropcap(struct pvr2_hdw *hdw);
347 static v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw);
358 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channelfreq_get() local
359 if ((hdw->freqProgSlot > 0) && (hdw->freqProgSlot <= FREQTABLE_SIZE)) { in ctrl_channelfreq_get()
360 *vp = hdw->freqTable[hdw->freqProgSlot-1]; in ctrl_channelfreq_get()
369 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channelfreq_set() local
370 unsigned int slotId = hdw->freqProgSlot; in ctrl_channelfreq_set()
372 hdw->freqTable[slotId-1] = v; in ctrl_channelfreq_set()
376 if (hdw->freqSelector) { in ctrl_channelfreq_set()
377 if (hdw->freqSlotRadio == slotId) { in ctrl_channelfreq_set()
378 hdw->freqSlotRadio = 0; in ctrl_channelfreq_set()
381 if (hdw->freqSlotTelevision == slotId) { in ctrl_channelfreq_set()
382 hdw->freqSlotTelevision = 0; in ctrl_channelfreq_set()
391 *vp = cptr->hdw->freqProgSlot; in ctrl_channelprog_get()
397 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channelprog_set() local
399 hdw->freqProgSlot = v; in ctrl_channelprog_set()
406 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channel_get() local
407 *vp = hdw->freqSelector ? hdw->freqSlotRadio : hdw->freqSlotTelevision; in ctrl_channel_get()
414 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_channel_set() local
417 freq = hdw->freqTable[slotId-1]; in ctrl_channel_set()
419 pvr2_hdw_set_cur_freq(hdw,freq); in ctrl_channel_set()
421 if (hdw->freqSelector) { in ctrl_channel_set()
422 hdw->freqSlotRadio = slotId; in ctrl_channel_set()
424 hdw->freqSlotTelevision = slotId; in ctrl_channel_set()
431 *vp = pvr2_hdw_get_cur_freq(cptr->hdw); in ctrl_freq_get()
437 return cptr->hdw->freqDirty != 0; in ctrl_freq_is_dirty()
442 cptr->hdw->freqDirty = 0; in ctrl_freq_clear_dirty()
447 pvr2_hdw_set_cur_freq(cptr->hdw,v); in ctrl_freq_set()
453 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropl_min_get()
454 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropl_min_get()
464 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropl_max_get()
465 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropl_max_get()
470 if (cap->bounds.width > cptr->hdw->cropw_val) { in ctrl_cropl_max_get()
471 *left += cap->bounds.width - cptr->hdw->cropw_val; in ctrl_cropl_max_get()
478 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropt_min_get()
479 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropt_min_get()
489 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropt_max_get()
490 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropt_max_get()
495 if (cap->bounds.height > cptr->hdw->croph_val) { in ctrl_cropt_max_get()
496 *top += cap->bounds.height - cptr->hdw->croph_val; in ctrl_cropt_max_get()
503 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_cropw_max_get()
506 stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_cropw_max_get()
511 cleft = cptr->hdw->cropl_val; in ctrl_cropw_max_get()
519 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_croph_max_get()
522 stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_croph_max_get()
527 ctop = cptr->hdw->cropt_val; in ctrl_croph_max_get()
535 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbl()
536 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbl()
546 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbt()
547 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbt()
557 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbw()
558 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbw()
568 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapbh()
569 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapbh()
579 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdl()
580 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdl()
590 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdt()
591 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdt()
601 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdw()
602 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdw()
612 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcapdh()
613 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcapdh()
623 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcappan()
624 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcappan()
634 struct v4l2_cropcap *cap = &cptr->hdw->cropcap_info; in ctrl_get_cropcappad()
635 int stat = pvr2_hdw_check_cropcap(cptr->hdw); in ctrl_get_cropcappad()
646 if (cptr->hdw->std_mask_cur & V4L2_STD_525_60) { in ctrl_vres_max_get()
657 if (cptr->hdw->hdw_desc->flag_has_cx25840) { in ctrl_vres_min_get()
667 *vp = cptr->hdw->input_val; in ctrl_get_input()
673 return ((1 << v) & cptr->hdw->input_allowed_mask) != 0; in ctrl_check_input()
678 return pvr2_hdw_set_input(cptr->hdw,v); in ctrl_set_input()
683 return cptr->hdw->input_dirty != 0; in ctrl_isdirty_input()
688 cptr->hdw->input_dirty = 0; in ctrl_cleardirty_input()
695 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_freq_max_get() local
696 if (hdw->tuner_signal_stale) { in ctrl_freq_max_get()
697 pvr2_hdw_status_poll(hdw); in ctrl_freq_max_get()
699 fv = hdw->tuner_signal_info.rangehigh; in ctrl_freq_max_get()
705 if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { in ctrl_freq_max_get()
717 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_freq_min_get() local
718 if (hdw->tuner_signal_stale) { in ctrl_freq_min_get()
719 pvr2_hdw_status_poll(hdw); in ctrl_freq_min_get()
721 fv = hdw->tuner_signal_info.rangelow; in ctrl_freq_min_get()
727 if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { in ctrl_freq_min_get()
738 return cptr->hdw->enc_stale != 0; in ctrl_cx2341x_is_dirty()
743 cptr->hdw->enc_stale = 0; in ctrl_cx2341x_clear_dirty()
744 cptr->hdw->enc_unsafe_stale = 0; in ctrl_cx2341x_clear_dirty()
757 ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state, 0, &cs, in ctrl_cx2341x_get()
767 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_cx2341x_set() local
776 ret = cx2341x_ext_ctrls(&hdw->enc_ctl_state, in ctrl_cx2341x_set()
777 hdw->state_encoder_run, &cs, in ctrl_cx2341x_set()
785 ret = cx2341x_ext_ctrls(&hdw->enc_ctl_state, in ctrl_cx2341x_set()
788 if (!ret) hdw->enc_unsafe_stale = !0; in ctrl_cx2341x_set()
791 hdw->enc_stale = !0; in ctrl_cx2341x_set()
800 cx2341x_ctrl_query(&cptr->hdw->enc_ctl_state,&qctrl); in ctrl_cx2341x_getv4lflags()
822 *vp = cptr->hdw->state_pipeline_req; in ctrl_streamingenabled_get()
828 *vp = cptr->hdw->master_state; in ctrl_masterstate_get()
834 int result = pvr2_hdw_is_hsm(cptr->hdw); in ctrl_hsm_get()
843 *vp = pvr2_hdw_get_detected_std(cptr->hdw); in ctrl_stddetect_get()
849 *vp = cptr->hdw->std_mask_avail; in ctrl_stdavail_get()
855 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_stdavail_set() local
857 ns = hdw->std_mask_avail; in ctrl_stdavail_set()
859 if (ns == hdw->std_mask_avail) return 0; in ctrl_stdavail_set()
860 hdw->std_mask_avail = ns; in ctrl_stdavail_set()
861 hdw->std_info_cur.def.type_bitmask.valid_bits = hdw->std_mask_avail; in ctrl_stdavail_set()
888 *vp = cptr->hdw->std_mask_cur; in ctrl_stdcur_get()
894 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_stdcur_set() local
896 ns = hdw->std_mask_cur; in ctrl_stdcur_set()
898 if (ns == hdw->std_mask_cur) return 0; in ctrl_stdcur_set()
899 hdw->std_mask_cur = ns; in ctrl_stdcur_set()
900 hdw->std_dirty = !0; in ctrl_stdcur_set()
906 return cptr->hdw->std_dirty != 0; in ctrl_stdcur_is_dirty()
911 cptr->hdw->std_dirty = 0; in ctrl_stdcur_clear_dirty()
916 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_signal_get() local
917 pvr2_hdw_status_poll(hdw); in ctrl_signal_get()
918 *vp = hdw->tuner_signal_info.signal; in ctrl_signal_get()
926 struct pvr2_hdw *hdw = cptr->hdw; in ctrl_audio_modes_present_get() local
927 pvr2_hdw_status_poll(hdw); in ctrl_audio_modes_present_get()
928 subchan = hdw->tuner_signal_info.rxsubchans; in ctrl_audio_modes_present_get()
973 {*vp = cptr->hdw->vname##_val; return 0;} \
975 {cptr->hdw->vname##_val = v; cptr->hdw->vname##_dirty = !0; return 0;} \
977 {return cptr->hdw->vname##_dirty != 0;} \
979 {cptr->hdw->vname##_dirty = 0;}
1291 struct usb_device *pvr2_hdw_get_dev(struct pvr2_hdw *hdw) in pvr2_hdw_get_dev() argument
1293 return hdw->usb_dev; in pvr2_hdw_get_dev()
1297 unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw) in pvr2_hdw_get_sn() argument
1299 return hdw->serial_number; in pvr2_hdw_get_sn()
1303 const char *pvr2_hdw_get_bus_info(struct pvr2_hdw *hdw) in pvr2_hdw_get_bus_info() argument
1305 return hdw->bus_info; in pvr2_hdw_get_bus_info()
1309 const char *pvr2_hdw_get_device_identifier(struct pvr2_hdw *hdw) in pvr2_hdw_get_device_identifier() argument
1311 return hdw->identifier; in pvr2_hdw_get_device_identifier()
1315 unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *hdw) in pvr2_hdw_get_cur_freq() argument
1317 return hdw->freqSelector ? hdw->freqValTelevision : hdw->freqValRadio; in pvr2_hdw_get_cur_freq()
1322 static void pvr2_hdw_set_cur_freq(struct pvr2_hdw *hdw,unsigned long val) in pvr2_hdw_set_cur_freq() argument
1324 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_set_cur_freq()
1325 if (hdw->freqSelector) { in pvr2_hdw_set_cur_freq()
1327 hdw->freqSelector = 0; in pvr2_hdw_set_cur_freq()
1328 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1330 if (hdw->freqValRadio != val) { in pvr2_hdw_set_cur_freq()
1331 hdw->freqValRadio = val; in pvr2_hdw_set_cur_freq()
1332 hdw->freqSlotRadio = 0; in pvr2_hdw_set_cur_freq()
1333 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1336 if (!(hdw->freqSelector)) { in pvr2_hdw_set_cur_freq()
1338 hdw->freqSelector = 1; in pvr2_hdw_set_cur_freq()
1339 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1341 if (hdw->freqValTelevision != val) { in pvr2_hdw_set_cur_freq()
1342 hdw->freqValTelevision = val; in pvr2_hdw_set_cur_freq()
1343 hdw->freqSlotTelevision = 0; in pvr2_hdw_set_cur_freq()
1344 hdw->freqDirty = !0; in pvr2_hdw_set_cur_freq()
1349 int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw) in pvr2_hdw_get_unit_number() argument
1351 return hdw->unit_number; in pvr2_hdw_get_unit_number()
1361 static int pvr2_locate_firmware(struct pvr2_hdw *hdw, in pvr2_locate_firmware() argument
1372 &hdw->usb_dev->dev); in pvr2_locate_firmware()
1422 static int pvr2_upload_firmware1(struct pvr2_hdw *hdw) in pvr2_upload_firmware1() argument
1431 if (!hdw->hdw_desc->fx2_firmware.cnt) { in pvr2_upload_firmware1()
1432 hdw->fw1_state = FW1_STATE_OK; in pvr2_upload_firmware1()
1439 hdw->fw1_state = FW1_STATE_FAILED; // default result in pvr2_upload_firmware1()
1443 ret = pvr2_locate_firmware(hdw,&fw_entry,"fx2 controller", in pvr2_upload_firmware1()
1444 hdw->hdw_desc->fx2_firmware.cnt, in pvr2_upload_firmware1()
1445 hdw->hdw_desc->fx2_firmware.lst); in pvr2_upload_firmware1()
1447 if (ret == -ENOENT) hdw->fw1_state = FW1_STATE_MISSING; in pvr2_upload_firmware1()
1451 usb_clear_halt(hdw->usb_dev, usb_sndbulkpipe(hdw->usb_dev, 0 & 0x7f)); in pvr2_upload_firmware1()
1453 pipe = usb_sndctrlpipe(hdw->usb_dev, 0); in pvr2_upload_firmware1()
1457 (!(hdw->hdw_desc->flag_fx2_16kb && (fwsize == 0x4000)))) { in pvr2_upload_firmware1()
1458 if (hdw->hdw_desc->flag_fx2_16kb) { in pvr2_upload_firmware1()
1480 pvr2_hdw_cpureset_assert(hdw,1); in pvr2_upload_firmware1()
1488 ret += usb_control_msg(hdw->usb_dev, pipe, 0xa0, 0x40, address, in pvr2_upload_firmware1()
1495 pvr2_hdw_cpureset_assert(hdw,0); in pvr2_upload_firmware1()
1504 hdw->fw1_state = FW1_STATE_RELOAD; in pvr2_upload_firmware1()
1519 int pvr2_upload_firmware2(struct pvr2_hdw *hdw) in pvr2_upload_firmware2() argument
1531 if (hdw->hdw_desc->flag_skip_cx23416_firmware) { in pvr2_upload_firmware2()
1537 ret = pvr2_locate_firmware(hdw,&fw_entry,"encoder", in pvr2_upload_firmware2()
1545 hdw->enc_cur_valid = 0; in pvr2_upload_firmware2()
1549 del_timer_sync(&hdw->encoder_run_timer); in pvr2_upload_firmware2()
1550 if (hdw->state_encoder_runok) { in pvr2_upload_firmware2()
1551 hdw->state_encoder_runok = 0; in pvr2_upload_firmware2()
1552 trace_stbit("state_encoder_runok",hdw->state_encoder_runok); in pvr2_upload_firmware2()
1556 ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/ in pvr2_upload_firmware2()
1557 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/ in pvr2_upload_firmware2()
1558 ret |= pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000008); /*gpio output state*/ in pvr2_upload_firmware2()
1559 ret |= pvr2_hdw_cmd_deep_reset(hdw); in pvr2_upload_firmware2()
1560 ret |= pvr2_write_register(hdw, 0xa064, 0x00000000); /*APU command*/ in pvr2_upload_firmware2()
1561 ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000408); /*gpio dir*/ in pvr2_upload_firmware2()
1562 ret |= pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000008); /*gpio output state*/ in pvr2_upload_firmware2()
1563 ret |= pvr2_write_register(hdw, 0x9058, 0xffffffed); /*VPU ctrl*/ in pvr2_upload_firmware2()
1564 ret |= pvr2_write_register(hdw, 0x9054, 0xfffffffd); /*reset hw blocks*/ in pvr2_upload_firmware2()
1565 ret |= pvr2_write_register(hdw, 0x07f8, 0x80000800); /*encoder SDRAM refresh*/ in pvr2_upload_firmware2()
1566 ret |= pvr2_write_register(hdw, 0x07fc, 0x0000001a); /*encoder SDRAM pre-charge*/ in pvr2_upload_firmware2()
1567 ret |= pvr2_write_register(hdw, 0x0700, 0x00000000); /*I2C clock*/ in pvr2_upload_firmware2()
1568 ret |= pvr2_write_register(hdw, 0xaa00, 0x00000000); /*unknown*/ in pvr2_upload_firmware2()
1569 ret |= pvr2_write_register(hdw, 0xaa04, 0x00057810); /*unknown*/ in pvr2_upload_firmware2()
1570 ret |= pvr2_write_register(hdw, 0xaa10, 0x00148500); /*unknown*/ in pvr2_upload_firmware2()
1571 ret |= pvr2_write_register(hdw, 0xaa18, 0x00840000); /*unknown*/ in pvr2_upload_firmware2()
1572 ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_FWPOST1); in pvr2_upload_firmware2()
1573 ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_MEMSEL | (1 << 8) | (0 << 16)); in pvr2_upload_firmware2()
1605 pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT); in pvr2_upload_firmware2()
1627 ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,bcnt, in pvr2_upload_firmware2()
1648 ret |= pvr2_write_register(hdw, 0x9054, 0xffffffff); /*reset hw blocks*/ in pvr2_upload_firmware2()
1649 ret |= pvr2_write_register(hdw, 0x9058, 0xffffffe8); /*VPU ctrl*/ in pvr2_upload_firmware2()
1650 ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_MEMSEL | (1 << 8) | (0 << 16)); in pvr2_upload_firmware2()
1658 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_upload_firmware2()
1662 pvr2_hdw_gpio_chg_dir(hdw,(1 << 11),~0); in pvr2_upload_firmware2()
1676 static int pvr2_decoder_enable(struct pvr2_hdw *hdw,int enablefl) in pvr2_decoder_enable() argument
1684 v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_stream, enablefl); in pvr2_decoder_enable()
1685 v4l2_device_call_all(&hdw->v4l2_dev, 0, audio, s_stream, enablefl); in pvr2_decoder_enable()
1686 if (hdw->decoder_client_id) { in pvr2_decoder_enable()
1692 if (!hdw->flag_decoder_missed) { in pvr2_decoder_enable()
1695 hdw->flag_decoder_missed = !0; in pvr2_decoder_enable()
1697 hdw->flag_decoder_missed); in pvr2_decoder_enable()
1703 int pvr2_hdw_get_state(struct pvr2_hdw *hdw) in pvr2_hdw_get_state() argument
1705 return hdw->master_state; in pvr2_hdw_get_state()
1709 static int pvr2_hdw_untrip_unlocked(struct pvr2_hdw *hdw) in pvr2_hdw_untrip_unlocked() argument
1711 if (!hdw->flag_tripped) return 0; in pvr2_hdw_untrip_unlocked()
1712 hdw->flag_tripped = 0; in pvr2_hdw_untrip_unlocked()
1719 int pvr2_hdw_untrip(struct pvr2_hdw *hdw) in pvr2_hdw_untrip() argument
1722 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_untrip()
1723 fl = pvr2_hdw_untrip_unlocked(hdw); in pvr2_hdw_untrip()
1724 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_untrip()
1725 if (fl) pvr2_hdw_state_sched(hdw); in pvr2_hdw_untrip()
1732 int pvr2_hdw_get_streaming(struct pvr2_hdw *hdw) in pvr2_hdw_get_streaming() argument
1734 return hdw->state_pipeline_req != 0; in pvr2_hdw_get_streaming()
1738 int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag) in pvr2_hdw_set_streaming() argument
1741 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_set_streaming()
1742 pvr2_hdw_untrip_unlocked(hdw); in pvr2_hdw_set_streaming()
1743 if ((!enable_flag) != !(hdw->state_pipeline_req)) { in pvr2_hdw_set_streaming()
1744 hdw->state_pipeline_req = enable_flag != 0; in pvr2_hdw_set_streaming()
1749 pvr2_hdw_state_sched(hdw); in pvr2_hdw_set_streaming()
1750 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_streaming()
1751 if ((ret = pvr2_hdw_wait(hdw,0)) < 0) return ret; in pvr2_hdw_set_streaming()
1753 while ((st = hdw->master_state) != PVR2_STATE_RUN) { in pvr2_hdw_set_streaming()
1755 if ((ret = pvr2_hdw_wait(hdw,st)) < 0) return ret; in pvr2_hdw_set_streaming()
1762 int pvr2_hdw_set_stream_type(struct pvr2_hdw *hdw,enum pvr2_config config) in pvr2_hdw_set_stream_type() argument
1765 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_set_stream_type()
1766 if ((fl = (hdw->desired_stream_type != config)) != 0) { in pvr2_hdw_set_stream_type()
1767 hdw->desired_stream_type = config; in pvr2_hdw_set_stream_type()
1768 hdw->state_pipeline_config = 0; in pvr2_hdw_set_stream_type()
1770 hdw->state_pipeline_config); in pvr2_hdw_set_stream_type()
1771 pvr2_hdw_state_sched(hdw); in pvr2_hdw_set_stream_type()
1773 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_stream_type()
1775 return pvr2_hdw_wait(hdw,0); in pvr2_hdw_set_stream_type()
1779 static int get_default_tuner_type(struct pvr2_hdw *hdw) in get_default_tuner_type() argument
1781 int unit_number = hdw->unit_number; in get_default_tuner_type()
1787 hdw->tuner_type = tp; in get_default_tuner_type()
1788 hdw->tuner_updated = !0; in get_default_tuner_type()
1793 static v4l2_std_id get_default_standard(struct pvr2_hdw *hdw) in get_default_standard() argument
1795 int unit_number = hdw->unit_number; in get_default_standard()
1805 static unsigned int get_default_error_tolerance(struct pvr2_hdw *hdw) in get_default_error_tolerance() argument
1807 int unit_number = hdw->unit_number; in get_default_error_tolerance()
1816 static int pvr2_hdw_check_firmware(struct pvr2_hdw *hdw) in pvr2_hdw_check_firmware() argument
1823 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_check_firmware()
1824 hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR; in pvr2_hdw_check_firmware()
1825 result = pvr2_send_request_ex(hdw,HZ*1,!0, in pvr2_hdw_check_firmware()
1826 hdw->cmd_buffer,1, in pvr2_hdw_check_firmware()
1827 hdw->cmd_buffer,1); in pvr2_hdw_check_firmware()
1829 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_check_firmware()
1879 static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw) in pvr2_hdw_setup_std() argument
1885 std1 = get_default_standard(hdw); in pvr2_hdw_setup_std()
1886 std3 = std1 ? 0 : hdw->hdw_desc->default_std_mask; in pvr2_hdw_setup_std()
1888 bcnt = pvr2_std_id_to_str(buf,sizeof(buf),hdw->std_mask_eeprom); in pvr2_hdw_setup_std()
1894 hdw->std_mask_avail = hdw->std_mask_eeprom; in pvr2_hdw_setup_std()
1896 std2 = (std1|std3) & ~hdw->std_mask_avail; in pvr2_hdw_setup_std()
1903 hdw->std_mask_avail |= std2; in pvr2_hdw_setup_std()
1906 hdw->std_info_cur.def.type_bitmask.valid_bits = hdw->std_mask_avail; in pvr2_hdw_setup_std()
1913 hdw->std_mask_cur = std1; in pvr2_hdw_setup_std()
1914 hdw->std_dirty = !0; in pvr2_hdw_setup_std()
1922 hdw->std_mask_cur = std3; in pvr2_hdw_setup_std()
1923 hdw->std_dirty = !0; in pvr2_hdw_setup_std()
1932 hdw->std_mask_eeprom) & in pvr2_hdw_setup_std()
1935 hdw->std_mask_eeprom)) continue; in pvr2_hdw_setup_std()
1941 hdw->std_mask_cur = std_eeprom_maps[idx].std; in pvr2_hdw_setup_std()
1942 hdw->std_dirty = !0; in pvr2_hdw_setup_std()
1965 static void pvr2_hdw_cx25840_vbi_hack(struct pvr2_hdw *hdw) in pvr2_hdw_cx25840_vbi_hack() argument
1977 if (hdw->decoder_client_id != PVR2_CLIENT_ID_CX25840) { in pvr2_hdw_cx25840_vbi_hack()
1985 hdw->decoder_client_id); in pvr2_hdw_cx25840_vbi_hack()
1990 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, in pvr2_hdw_cx25840_vbi_hack()
1995 static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, in pvr2_hdw_load_subdev() argument
2013 hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2019 hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2041 mid, fname, hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2050 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, in pvr2_hdw_load_subdev()
2057 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, in pvr2_hdw_load_subdev()
2066 mid, fname, hdw->hdw_desc->description); in pvr2_hdw_load_subdev()
2082 hdw->decoder_client_id = mid; in pvr2_hdw_load_subdev()
2091 static void pvr2_hdw_load_modules(struct pvr2_hdw *hdw) in pvr2_hdw_load_modules() argument
2098 cm = &hdw->hdw_desc->client_modules; in pvr2_hdw_load_modules()
2103 ct = &hdw->hdw_desc->client_table; in pvr2_hdw_load_modules()
2105 if (pvr2_hdw_load_subdev(hdw, &ct->lst[idx]) < 0) okFl = 0; in pvr2_hdw_load_modules()
2108 hdw->flag_modulefail = !0; in pvr2_hdw_load_modules()
2109 pvr2_hdw_render_useless(hdw); in pvr2_hdw_load_modules()
2114 static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw) in pvr2_hdw_setup_low() argument
2120 if (hdw->hdw_desc->fx2_firmware.cnt) { in pvr2_hdw_setup_low()
2123 (hdw->usb_intf->cur_altsetting->desc.bNumEndpoints in pvr2_hdw_setup_low()
2133 reloadFl = !pvr2_hdw_check_firmware(hdw); in pvr2_hdw_setup_low()
2142 if (pvr2_upload_firmware1(hdw) != 0) { in pvr2_hdw_setup_low()
2149 hdw->fw1_state = FW1_STATE_OK; in pvr2_hdw_setup_low()
2151 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2153 hdw->force_dirty = !0; in pvr2_hdw_setup_low()
2155 if (!hdw->hdw_desc->flag_no_powerup) { in pvr2_hdw_setup_low()
2156 pvr2_hdw_cmd_powerup(hdw); in pvr2_hdw_setup_low()
2157 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2161 if (hdw->ir_scheme_active == PVR2_IR_SCHEME_ZILOG) { in pvr2_hdw_setup_low()
2162 pvr2_issue_simple_cmd(hdw, in pvr2_hdw_setup_low()
2169 pvr2_i2c_core_init(hdw); in pvr2_hdw_setup_low()
2170 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2172 pvr2_hdw_load_modules(hdw); in pvr2_hdw_setup_low()
2173 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2175 v4l2_device_call_all(&hdw->v4l2_dev, 0, core, load_fw); in pvr2_hdw_setup_low()
2178 cptr = hdw->controls + idx; in pvr2_hdw_setup_low()
2184 pvr2_hdw_cx25840_vbi_hack(hdw); in pvr2_hdw_setup_low()
2191 hdw->freqValTelevision = default_tv_freq; in pvr2_hdw_setup_low()
2192 hdw->freqValRadio = default_radio_freq; in pvr2_hdw_setup_low()
2198 if (hdw->hdw_desc->flag_has_hauppauge_rom) { in pvr2_hdw_setup_low()
2199 ret = pvr2_hdw_get_eeprom_addr(hdw); in pvr2_hdw_setup_low()
2200 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2206 hdw->eeprom_addr = ret; in pvr2_hdw_setup_low()
2207 pvr2_eeprom_analyze(hdw); in pvr2_hdw_setup_low()
2208 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2211 hdw->tuner_type = hdw->hdw_desc->default_tuner_type; in pvr2_hdw_setup_low()
2212 hdw->tuner_updated = !0; in pvr2_hdw_setup_low()
2213 hdw->std_mask_eeprom = V4L2_STD_ALL; in pvr2_hdw_setup_low()
2216 if (hdw->serial_number) { in pvr2_hdw_setup_low()
2217 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1, in pvr2_hdw_setup_low()
2218 "sn-%lu", hdw->serial_number); in pvr2_hdw_setup_low()
2219 } else if (hdw->unit_number >= 0) { in pvr2_hdw_setup_low()
2220 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1, in pvr2_hdw_setup_low()
2222 hdw->unit_number + 'a'); in pvr2_hdw_setup_low()
2224 idx = scnprintf(hdw->identifier, sizeof(hdw->identifier) - 1, in pvr2_hdw_setup_low()
2227 hdw->identifier[idx] = 0; in pvr2_hdw_setup_low()
2229 pvr2_hdw_setup_std(hdw); in pvr2_hdw_setup_low()
2231 if (!get_default_tuner_type(hdw)) { in pvr2_hdw_setup_low()
2234 hdw->tuner_type); in pvr2_hdw_setup_low()
2238 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2240 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_hdw_setup_low()
2244 pvr2_hdw_gpio_chg_dir(hdw,(1 << 11),~0); in pvr2_hdw_setup_low()
2247 pvr2_hdw_commit_setup(hdw); in pvr2_hdw_setup_low()
2249 hdw->vid_stream = pvr2_stream_create(); in pvr2_hdw_setup_low()
2250 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2252 "pvr2_hdw_setup: video stream is %p",hdw->vid_stream); in pvr2_hdw_setup_low()
2253 if (hdw->vid_stream) { in pvr2_hdw_setup_low()
2254 idx = get_default_error_tolerance(hdw); in pvr2_hdw_setup_low()
2259 hdw->vid_stream,idx); in pvr2_hdw_setup_low()
2261 pvr2_stream_setup(hdw->vid_stream,hdw->usb_dev, in pvr2_hdw_setup_low()
2265 if (!pvr2_hdw_dev_ok(hdw)) return; in pvr2_hdw_setup_low()
2267 hdw->flag_init_ok = !0; in pvr2_hdw_setup_low()
2269 pvr2_hdw_state_sched(hdw); in pvr2_hdw_setup_low()
2276 static void pvr2_hdw_setup(struct pvr2_hdw *hdw) in pvr2_hdw_setup() argument
2278 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) begin",hdw); in pvr2_hdw_setup()
2280 pvr2_hdw_setup_low(hdw); in pvr2_hdw_setup()
2283 hdw,pvr2_hdw_dev_ok(hdw),hdw->flag_init_ok); in pvr2_hdw_setup()
2284 if (pvr2_hdw_dev_ok(hdw)) { in pvr2_hdw_setup()
2285 if (hdw->flag_init_ok) { in pvr2_hdw_setup()
2292 if (hdw->fw1_state == FW1_STATE_RELOAD) { in pvr2_hdw_setup()
2303 if (hdw->fw1_state == FW1_STATE_MISSING) { in pvr2_hdw_setup()
2312 if (hdw->flag_modulefail) { in pvr2_hdw_setup()
2335 hdw->fw1_state = FW1_STATE_UNKNOWN; in pvr2_hdw_setup()
2336 pvr2_upload_firmware1(hdw); in pvr2_hdw_setup()
2350 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) end",hdw); in pvr2_hdw_setup()
2357 int pvr2_hdw_initialize(struct pvr2_hdw *hdw, in pvr2_hdw_initialize() argument
2361 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_initialize()
2362 if (hdw->flag_disconnected) { in pvr2_hdw_initialize()
2371 hdw->state_data = callback_data; in pvr2_hdw_initialize()
2372 hdw->state_func = callback_func; in pvr2_hdw_initialize()
2373 pvr2_hdw_setup(hdw); in pvr2_hdw_initialize()
2374 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_initialize()
2375 return hdw->flag_init_ok; in pvr2_hdw_initialize()
2385 struct pvr2_hdw *hdw = NULL; in pvr2_hdw_create() local
2408 hdw = kzalloc(sizeof(*hdw),GFP_KERNEL); in pvr2_hdw_create()
2410 hdw,hdw_desc->description); in pvr2_hdw_create()
2426 if (!hdw) goto fail; in pvr2_hdw_create()
2428 setup_timer(&hdw->quiescent_timer, pvr2_hdw_quiescent_timeout, in pvr2_hdw_create()
2429 (unsigned long)hdw); in pvr2_hdw_create()
2431 setup_timer(&hdw->decoder_stabilization_timer, in pvr2_hdw_create()
2433 (unsigned long)hdw); in pvr2_hdw_create()
2435 setup_timer(&hdw->encoder_wait_timer, pvr2_hdw_encoder_wait_timeout, in pvr2_hdw_create()
2436 (unsigned long)hdw); in pvr2_hdw_create()
2438 setup_timer(&hdw->encoder_run_timer, pvr2_hdw_encoder_run_timeout, in pvr2_hdw_create()
2439 (unsigned long)hdw); in pvr2_hdw_create()
2441 hdw->master_state = PVR2_STATE_DEAD; in pvr2_hdw_create()
2443 init_waitqueue_head(&hdw->state_wait_data); in pvr2_hdw_create()
2445 hdw->tuner_signal_stale = !0; in pvr2_hdw_create()
2446 cx2341x_fill_defaults(&hdw->enc_ctl_state); in pvr2_hdw_create()
2457 hdw->input_avail_mask = m; in pvr2_hdw_create()
2458 hdw->input_allowed_mask = hdw->input_avail_mask; in pvr2_hdw_create()
2462 if (!(hdw->input_avail_mask & (1 << PVR2_CVAL_INPUT_DTV))) { in pvr2_hdw_create()
2463 hdw->pathway_state = PVR2_PATHWAY_ANALOG; in pvr2_hdw_create()
2464 } else if (!(hdw->input_avail_mask & (1 << PVR2_CVAL_INPUT_TV))) { in pvr2_hdw_create()
2465 hdw->pathway_state = PVR2_PATHWAY_DIGITAL; in pvr2_hdw_create()
2468 hdw->control_cnt = CTRLDEF_COUNT; in pvr2_hdw_create()
2469 hdw->control_cnt += MPEGDEF_COUNT; in pvr2_hdw_create()
2470 hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt, in pvr2_hdw_create()
2472 if (!hdw->controls) goto fail; in pvr2_hdw_create()
2473 hdw->hdw_desc = hdw_desc; in pvr2_hdw_create()
2474 hdw->ir_scheme_active = hdw->hdw_desc->ir_scheme; in pvr2_hdw_create()
2475 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_create()
2476 cptr = hdw->controls + idx; in pvr2_hdw_create()
2477 cptr->hdw = hdw; in pvr2_hdw_create()
2480 hdw->std_mask_ptrs[idx] = hdw->std_mask_names[idx]; in pvr2_hdw_create()
2483 cptr = hdw->controls + idx; in pvr2_hdw_create()
2488 m = hdw->input_avail_mask; in pvr2_hdw_create()
2491 hdw->input_val = idx; in pvr2_hdw_create()
2496 hdw->mpeg_ctrl_info = kcalloc(MPEGDEF_COUNT, in pvr2_hdw_create()
2497 sizeof(*(hdw->mpeg_ctrl_info)), in pvr2_hdw_create()
2499 if (!hdw->mpeg_ctrl_info) goto fail; in pvr2_hdw_create()
2501 cptr = hdw->controls + idx + CTRLDEF_COUNT; in pvr2_hdw_create()
2502 ciptr = &(hdw->mpeg_ctrl_info[idx].info); in pvr2_hdw_create()
2503 ciptr->desc = hdw->mpeg_ctrl_info[idx].desc; in pvr2_hdw_create()
2512 cx2341x_ctrl_query(&hdw->enc_ctl_state,&qctrl); in pvr2_hdw_create()
2516 strncpy(hdw->mpeg_ctrl_info[idx].desc,qctrl.name, in pvr2_hdw_create()
2518 hdw->mpeg_ctrl_info[idx].desc[PVR2_CTLD_INFO_DESC_SIZE-1] = 0; in pvr2_hdw_create()
2533 cx2341x_ctrl_get_menu(&hdw->enc_ctl_state, in pvr2_hdw_create()
2549 hdw->std_mask_names[idx], in pvr2_hdw_create()
2550 sizeof(hdw->std_mask_names[idx])-1, in pvr2_hdw_create()
2552 hdw->std_mask_names[idx][cnt1] = 0; in pvr2_hdw_create()
2554 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDAVAIL); in pvr2_hdw_create()
2556 memcpy(&hdw->std_info_avail,cptr->info, in pvr2_hdw_create()
2557 sizeof(hdw->std_info_avail)); in pvr2_hdw_create()
2558 cptr->info = &hdw->std_info_avail; in pvr2_hdw_create()
2559 hdw->std_info_avail.def.type_bitmask.bit_names = in pvr2_hdw_create()
2560 hdw->std_mask_ptrs; in pvr2_hdw_create()
2561 hdw->std_info_avail.def.type_bitmask.valid_bits = in pvr2_hdw_create()
2564 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR); in pvr2_hdw_create()
2566 memcpy(&hdw->std_info_cur,cptr->info, in pvr2_hdw_create()
2567 sizeof(hdw->std_info_cur)); in pvr2_hdw_create()
2568 cptr->info = &hdw->std_info_cur; in pvr2_hdw_create()
2569 hdw->std_info_cur.def.type_bitmask.bit_names = in pvr2_hdw_create()
2570 hdw->std_mask_ptrs; in pvr2_hdw_create()
2571 hdw->std_info_cur.def.type_bitmask.valid_bits = in pvr2_hdw_create()
2574 cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDDETECT); in pvr2_hdw_create()
2576 memcpy(&hdw->std_info_detect,cptr->info, in pvr2_hdw_create()
2577 sizeof(hdw->std_info_detect)); in pvr2_hdw_create()
2578 cptr->info = &hdw->std_info_detect; in pvr2_hdw_create()
2579 hdw->std_info_detect.def.type_bitmask.bit_names = in pvr2_hdw_create()
2580 hdw->std_mask_ptrs; in pvr2_hdw_create()
2581 hdw->std_info_detect.def.type_bitmask.valid_bits = in pvr2_hdw_create()
2585 hdw->cropcap_stale = !0; in pvr2_hdw_create()
2586 hdw->eeprom_addr = -1; in pvr2_hdw_create()
2587 hdw->unit_number = -1; in pvr2_hdw_create()
2588 hdw->v4l_minor_number_video = -1; in pvr2_hdw_create()
2589 hdw->v4l_minor_number_vbi = -1; in pvr2_hdw_create()
2590 hdw->v4l_minor_number_radio = -1; in pvr2_hdw_create()
2591 hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); in pvr2_hdw_create()
2592 if (!hdw->ctl_write_buffer) goto fail; in pvr2_hdw_create()
2593 hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); in pvr2_hdw_create()
2594 if (!hdw->ctl_read_buffer) goto fail; in pvr2_hdw_create()
2595 hdw->ctl_write_urb = usb_alloc_urb(0,GFP_KERNEL); in pvr2_hdw_create()
2596 if (!hdw->ctl_write_urb) goto fail; in pvr2_hdw_create()
2597 hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); in pvr2_hdw_create()
2598 if (!hdw->ctl_read_urb) goto fail; in pvr2_hdw_create()
2600 if (v4l2_device_register(&intf->dev, &hdw->v4l2_dev) != 0) { in pvr2_hdw_create()
2609 hdw->unit_number = idx; in pvr2_hdw_create()
2610 unit_pointers[idx] = hdw; in pvr2_hdw_create()
2617 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); in pvr2_hdw_create()
2619 if (hdw->unit_number >= 0) { in pvr2_hdw_create()
2620 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"_%c", in pvr2_hdw_create()
2621 ('a' + hdw->unit_number)); in pvr2_hdw_create()
2624 if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1; in pvr2_hdw_create()
2625 hdw->name[cnt1] = 0; in pvr2_hdw_create()
2627 hdw->workqueue = create_singlethread_workqueue(hdw->name); in pvr2_hdw_create()
2628 INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll); in pvr2_hdw_create()
2631 hdw->unit_number,hdw->name); in pvr2_hdw_create()
2633 hdw->tuner_type = -1; in pvr2_hdw_create()
2634 hdw->flag_ok = !0; in pvr2_hdw_create()
2636 hdw->usb_intf = intf; in pvr2_hdw_create()
2637 hdw->usb_dev = usb_dev; in pvr2_hdw_create()
2639 usb_make_path(hdw->usb_dev, hdw->bus_info, sizeof(hdw->bus_info)); in pvr2_hdw_create()
2641 ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber; in pvr2_hdw_create()
2642 usb_set_interface(hdw->usb_dev,ifnum,0); in pvr2_hdw_create()
2644 mutex_init(&hdw->ctl_lock_mutex); in pvr2_hdw_create()
2645 mutex_init(&hdw->big_lock_mutex); in pvr2_hdw_create()
2647 return hdw; in pvr2_hdw_create()
2649 if (hdw) { in pvr2_hdw_create()
2650 del_timer_sync(&hdw->quiescent_timer); in pvr2_hdw_create()
2651 del_timer_sync(&hdw->decoder_stabilization_timer); in pvr2_hdw_create()
2652 del_timer_sync(&hdw->encoder_run_timer); in pvr2_hdw_create()
2653 del_timer_sync(&hdw->encoder_wait_timer); in pvr2_hdw_create()
2654 if (hdw->workqueue) { in pvr2_hdw_create()
2655 flush_workqueue(hdw->workqueue); in pvr2_hdw_create()
2656 destroy_workqueue(hdw->workqueue); in pvr2_hdw_create()
2657 hdw->workqueue = NULL; in pvr2_hdw_create()
2659 usb_free_urb(hdw->ctl_read_urb); in pvr2_hdw_create()
2660 usb_free_urb(hdw->ctl_write_urb); in pvr2_hdw_create()
2661 kfree(hdw->ctl_read_buffer); in pvr2_hdw_create()
2662 kfree(hdw->ctl_write_buffer); in pvr2_hdw_create()
2663 kfree(hdw->controls); in pvr2_hdw_create()
2664 kfree(hdw->mpeg_ctrl_info); in pvr2_hdw_create()
2665 kfree(hdw); in pvr2_hdw_create()
2673 static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw) in pvr2_hdw_remove_usb_stuff() argument
2675 if (hdw->flag_disconnected) return; in pvr2_hdw_remove_usb_stuff()
2676 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw); in pvr2_hdw_remove_usb_stuff()
2677 if (hdw->ctl_read_urb) { in pvr2_hdw_remove_usb_stuff()
2678 usb_kill_urb(hdw->ctl_read_urb); in pvr2_hdw_remove_usb_stuff()
2679 usb_free_urb(hdw->ctl_read_urb); in pvr2_hdw_remove_usb_stuff()
2680 hdw->ctl_read_urb = NULL; in pvr2_hdw_remove_usb_stuff()
2682 if (hdw->ctl_write_urb) { in pvr2_hdw_remove_usb_stuff()
2683 usb_kill_urb(hdw->ctl_write_urb); in pvr2_hdw_remove_usb_stuff()
2684 usb_free_urb(hdw->ctl_write_urb); in pvr2_hdw_remove_usb_stuff()
2685 hdw->ctl_write_urb = NULL; in pvr2_hdw_remove_usb_stuff()
2687 if (hdw->ctl_read_buffer) { in pvr2_hdw_remove_usb_stuff()
2688 kfree(hdw->ctl_read_buffer); in pvr2_hdw_remove_usb_stuff()
2689 hdw->ctl_read_buffer = NULL; in pvr2_hdw_remove_usb_stuff()
2691 if (hdw->ctl_write_buffer) { in pvr2_hdw_remove_usb_stuff()
2692 kfree(hdw->ctl_write_buffer); in pvr2_hdw_remove_usb_stuff()
2693 hdw->ctl_write_buffer = NULL; in pvr2_hdw_remove_usb_stuff()
2695 hdw->flag_disconnected = !0; in pvr2_hdw_remove_usb_stuff()
2699 v4l2_device_disconnect(&hdw->v4l2_dev); in pvr2_hdw_remove_usb_stuff()
2700 hdw->usb_dev = NULL; in pvr2_hdw_remove_usb_stuff()
2701 hdw->usb_intf = NULL; in pvr2_hdw_remove_usb_stuff()
2702 pvr2_hdw_render_useless(hdw); in pvr2_hdw_remove_usb_stuff()
2705 void pvr2_hdw_set_v4l2_dev(struct pvr2_hdw *hdw, struct video_device *vdev) in pvr2_hdw_set_v4l2_dev() argument
2707 vdev->v4l2_dev = &hdw->v4l2_dev; in pvr2_hdw_set_v4l2_dev()
2711 void pvr2_hdw_destroy(struct pvr2_hdw *hdw) in pvr2_hdw_destroy() argument
2713 if (!hdw) return; in pvr2_hdw_destroy()
2714 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw); in pvr2_hdw_destroy()
2715 if (hdw->workqueue) { in pvr2_hdw_destroy()
2716 flush_workqueue(hdw->workqueue); in pvr2_hdw_destroy()
2717 destroy_workqueue(hdw->workqueue); in pvr2_hdw_destroy()
2718 hdw->workqueue = NULL; in pvr2_hdw_destroy()
2720 del_timer_sync(&hdw->quiescent_timer); in pvr2_hdw_destroy()
2721 del_timer_sync(&hdw->decoder_stabilization_timer); in pvr2_hdw_destroy()
2722 del_timer_sync(&hdw->encoder_run_timer); in pvr2_hdw_destroy()
2723 del_timer_sync(&hdw->encoder_wait_timer); in pvr2_hdw_destroy()
2724 if (hdw->fw_buffer) { in pvr2_hdw_destroy()
2725 kfree(hdw->fw_buffer); in pvr2_hdw_destroy()
2726 hdw->fw_buffer = NULL; in pvr2_hdw_destroy()
2728 if (hdw->vid_stream) { in pvr2_hdw_destroy()
2729 pvr2_stream_destroy(hdw->vid_stream); in pvr2_hdw_destroy()
2730 hdw->vid_stream = NULL; in pvr2_hdw_destroy()
2732 pvr2_i2c_core_done(hdw); in pvr2_hdw_destroy()
2733 v4l2_device_unregister(&hdw->v4l2_dev); in pvr2_hdw_destroy()
2734 pvr2_hdw_remove_usb_stuff(hdw); in pvr2_hdw_destroy()
2737 if ((hdw->unit_number >= 0) && in pvr2_hdw_destroy()
2738 (hdw->unit_number < PVR_NUM) && in pvr2_hdw_destroy()
2739 (unit_pointers[hdw->unit_number] == hdw)) { in pvr2_hdw_destroy()
2740 unit_pointers[hdw->unit_number] = NULL; in pvr2_hdw_destroy()
2744 kfree(hdw->controls); in pvr2_hdw_destroy()
2745 kfree(hdw->mpeg_ctrl_info); in pvr2_hdw_destroy()
2746 kfree(hdw); in pvr2_hdw_destroy()
2750 int pvr2_hdw_dev_ok(struct pvr2_hdw *hdw) in pvr2_hdw_dev_ok() argument
2752 return (hdw && hdw->flag_ok); in pvr2_hdw_dev_ok()
2757 void pvr2_hdw_disconnect(struct pvr2_hdw *hdw) in pvr2_hdw_disconnect() argument
2759 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_disconnect(hdw=%p)",hdw); in pvr2_hdw_disconnect()
2760 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_disconnect()
2761 LOCK_TAKE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2762 pvr2_hdw_remove_usb_stuff(hdw); in pvr2_hdw_disconnect()
2763 LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2764 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_disconnect()
2769 unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw) in pvr2_hdw_get_ctrl_count() argument
2771 return hdw->control_cnt; in pvr2_hdw_get_ctrl_count()
2776 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_by_index() argument
2779 if (idx >= hdw->control_cnt) return NULL; in pvr2_hdw_get_ctrl_by_index()
2780 return hdw->controls + idx; in pvr2_hdw_get_ctrl_by_index()
2785 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_by_id() argument
2793 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_by_id()
2794 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_by_id()
2803 struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id) in pvr2_hdw_get_ctrl_v4l() argument
2810 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_v4l()
2811 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_v4l()
2821 struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_nextv4l() argument
2830 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_nextv4l()
2831 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_nextv4l()
2855 static void pvr2_subdev_set_control(struct pvr2_hdw *hdw, int id, in pvr2_subdev_set_control() argument
2863 v4l2_device_call_all(&hdw->v4l2_dev, 0, core, s_ctrl, &ctrl); in pvr2_subdev_set_control()
2866 #define PVR2_SUBDEV_SET_CONTROL(hdw, id, lab) \ argument
2867 if ((hdw)->lab##_dirty || (hdw)->force_dirty) { \
2868 pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \
2871 static v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw) in pvr2_hdw_get_detected_std() argument
2874 std = (v4l2_std_id)hdw->std_mask_avail; in pvr2_hdw_get_detected_std()
2875 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_hdw_get_detected_std()
2882 static void pvr2_subdev_update(struct pvr2_hdw *hdw) in pvr2_subdev_update() argument
2890 if (hdw->tuner_updated || hdw->force_dirty) { in pvr2_subdev_update()
2893 hdw->tuner_type); in pvr2_subdev_update()
2894 if (((int)(hdw->tuner_type)) >= 0) { in pvr2_subdev_update()
2897 setup.type = hdw->tuner_type; in pvr2_subdev_update()
2899 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2904 if (hdw->input_dirty || hdw->std_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2906 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_subdev_update()
2907 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2911 vs = hdw->std_mask_cur; in pvr2_subdev_update()
2912 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2914 pvr2_hdw_cx25840_vbi_hack(hdw); in pvr2_subdev_update()
2916 hdw->tuner_signal_stale = !0; in pvr2_subdev_update()
2917 hdw->cropcap_stale = !0; in pvr2_subdev_update()
2920 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_BRIGHTNESS, brightness); in pvr2_subdev_update()
2921 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_CONTRAST, contrast); in pvr2_subdev_update()
2922 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_SATURATION, saturation); in pvr2_subdev_update()
2923 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_HUE, hue); in pvr2_subdev_update()
2924 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_MUTE, mute); in pvr2_subdev_update()
2925 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_VOLUME, volume); in pvr2_subdev_update()
2926 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BALANCE, balance); in pvr2_subdev_update()
2927 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BASS, bass); in pvr2_subdev_update()
2928 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_TREBLE, treble); in pvr2_subdev_update()
2930 if (hdw->input_dirty || hdw->audiomode_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2933 vt.type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? in pvr2_subdev_update()
2935 vt.audmode = hdw->audiomode_val; in pvr2_subdev_update()
2936 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt); in pvr2_subdev_update()
2939 if (hdw->freqDirty || hdw->force_dirty) { in pvr2_subdev_update()
2942 fv = pvr2_hdw_get_cur_freq(hdw); in pvr2_subdev_update()
2944 if (hdw->tuner_signal_stale) pvr2_hdw_status_poll(hdw); in pvr2_subdev_update()
2946 if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { in pvr2_subdev_update()
2954 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_subdev_update()
2960 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, in pvr2_subdev_update()
2964 if (hdw->res_hor_dirty || hdw->res_ver_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2969 format.format.width = hdw->res_hor_val; in pvr2_subdev_update()
2970 format.format.height = hdw->res_ver_val; in pvr2_subdev_update()
2974 v4l2_device_call_all(&hdw->v4l2_dev, 0, pad, set_fmt, in pvr2_subdev_update()
2978 if (hdw->srate_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2981 hdw->srate_val); in pvr2_subdev_update()
2982 switch (hdw->srate_val) { in pvr2_subdev_update()
2994 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
3001 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) { in pvr2_subdev_update()
3006 (*fp)(hdw, sd); in pvr2_subdev_update()
3009 if (hdw->tuner_signal_stale || hdw->cropcap_stale) { in pvr2_subdev_update()
3010 pvr2_hdw_status_poll(hdw); in pvr2_subdev_update()
3018 static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw) in pvr2_hdw_commit_setup() argument
3023 int commit_flag = hdw->force_dirty; in pvr2_hdw_commit_setup()
3027 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_commit_setup()
3028 cptr = hdw->controls + idx; in pvr2_hdw_commit_setup()
3054 hdw->state_pipeline_config = 0; in pvr2_hdw_commit_setup()
3055 trace_stbit("state_pipeline_config",hdw->state_pipeline_config); in pvr2_hdw_commit_setup()
3056 pvr2_hdw_state_sched(hdw); in pvr2_hdw_commit_setup()
3067 static int pvr2_hdw_commit_execute(struct pvr2_hdw *hdw) in pvr2_hdw_commit_execute() argument
3073 if (hdw->input_dirty && hdw->state_pathway_ok && in pvr2_hdw_commit_execute()
3074 (((hdw->input_val == PVR2_CVAL_INPUT_DTV) ? in pvr2_hdw_commit_execute()
3076 hdw->pathway_state)) { in pvr2_hdw_commit_execute()
3078 hdw->state_pathway_ok = 0; in pvr2_hdw_commit_execute()
3079 trace_stbit("state_pathway_ok", hdw->state_pathway_ok); in pvr2_hdw_commit_execute()
3081 if (!hdw->state_pathway_ok) { in pvr2_hdw_commit_execute()
3088 if (hdw->std_dirty) { in pvr2_hdw_commit_execute()
3091 if (hdw->std_mask_cur & V4L2_STD_525_60) { in pvr2_hdw_commit_execute()
3100 if (nvres != hdw->res_ver_val) { in pvr2_hdw_commit_execute()
3101 hdw->res_ver_val = nvres; in pvr2_hdw_commit_execute()
3102 hdw->res_ver_dirty = !0; in pvr2_hdw_commit_execute()
3106 if (gop_size != hdw->enc_ctl_state.video_gop_size) { in pvr2_hdw_commit_execute()
3115 cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs, in pvr2_hdw_commit_execute()
3126 if (hdw->res_hor_dirty && hdw->cropw_val < hdw->res_hor_val) { in pvr2_hdw_commit_execute()
3127 hdw->cropw_val = hdw->res_hor_val; in pvr2_hdw_commit_execute()
3128 hdw->cropw_dirty = !0; in pvr2_hdw_commit_execute()
3129 } else if (hdw->cropw_dirty) { in pvr2_hdw_commit_execute()
3130 hdw->res_hor_dirty = !0; /* must rescale */ in pvr2_hdw_commit_execute()
3131 hdw->res_hor_val = min(720, hdw->cropw_val); in pvr2_hdw_commit_execute()
3133 if (hdw->res_ver_dirty && hdw->croph_val < hdw->res_ver_val) { in pvr2_hdw_commit_execute()
3134 hdw->croph_val = hdw->res_ver_val; in pvr2_hdw_commit_execute()
3135 hdw->croph_dirty = !0; in pvr2_hdw_commit_execute()
3136 } else if (hdw->croph_dirty) { in pvr2_hdw_commit_execute()
3137 int nvres = hdw->std_mask_cur & V4L2_STD_525_60 ? 480 : 576; in pvr2_hdw_commit_execute()
3138 hdw->res_ver_dirty = !0; in pvr2_hdw_commit_execute()
3139 hdw->res_ver_val = min(nvres, hdw->croph_val); in pvr2_hdw_commit_execute()
3147 (hdw->std_dirty || in pvr2_hdw_commit_execute()
3148 hdw->enc_unsafe_stale || in pvr2_hdw_commit_execute()
3149 hdw->srate_dirty || in pvr2_hdw_commit_execute()
3150 hdw->res_ver_dirty || in pvr2_hdw_commit_execute()
3151 hdw->res_hor_dirty || in pvr2_hdw_commit_execute()
3152 hdw->cropw_dirty || in pvr2_hdw_commit_execute()
3153 hdw->croph_dirty || in pvr2_hdw_commit_execute()
3154 hdw->input_dirty || in pvr2_hdw_commit_execute()
3155 (hdw->active_stream_type != hdw->desired_stream_type)); in pvr2_hdw_commit_execute()
3156 if (disruptive_change && !hdw->state_pipeline_idle) { in pvr2_hdw_commit_execute()
3160 hdw->state_pipeline_pause = !0; in pvr2_hdw_commit_execute()
3164 if (hdw->srate_dirty) { in pvr2_hdw_commit_execute()
3176 c1.value = hdw->srate_val; in pvr2_hdw_commit_execute()
3177 cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs,VIDIOC_S_EXT_CTRLS); in pvr2_hdw_commit_execute()
3180 if (hdw->active_stream_type != hdw->desired_stream_type) { in pvr2_hdw_commit_execute()
3182 hdw->active_stream_type = hdw->desired_stream_type; in pvr2_hdw_commit_execute()
3185 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_hdw_commit_execute()
3189 pvr2_hdw_gpio_get_out(hdw,&b); in pvr2_hdw_commit_execute()
3190 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_commit_execute()
3192 pvr2_hdw_gpio_chg_out(hdw,(1 << 11),~0); in pvr2_hdw_commit_execute()
3195 pvr2_hdw_gpio_chg_out(hdw,(1 << 11),0); in pvr2_hdw_commit_execute()
3200 pvr2_subdev_update(hdw); in pvr2_hdw_commit_execute()
3202 hdw->tuner_updated = 0; in pvr2_hdw_commit_execute()
3203 hdw->force_dirty = 0; in pvr2_hdw_commit_execute()
3204 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_commit_execute()
3205 cptr = hdw->controls + idx; in pvr2_hdw_commit_execute()
3210 if ((hdw->pathway_state == PVR2_PATHWAY_ANALOG) && in pvr2_hdw_commit_execute()
3211 hdw->state_encoder_run) { in pvr2_hdw_commit_execute()
3215 if (pvr2_encoder_adjust(hdw) < 0) return !0; in pvr2_hdw_commit_execute()
3218 hdw->state_pipeline_config = !0; in pvr2_hdw_commit_execute()
3222 trace_stbit("state_pipeline_config",hdw->state_pipeline_config); in pvr2_hdw_commit_execute()
3227 int pvr2_hdw_commit_ctl(struct pvr2_hdw *hdw) in pvr2_hdw_commit_ctl() argument
3230 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3231 fl = pvr2_hdw_commit_setup(hdw); in pvr2_hdw_commit_ctl()
3232 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3234 return pvr2_hdw_wait(hdw,0); in pvr2_hdw_commit_ctl()
3241 struct pvr2_hdw *hdw = container_of(work,struct pvr2_hdw,workpoll); in pvr2_hdw_worker_poll() local
3242 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_worker_poll()
3243 fl = pvr2_hdw_state_eval(hdw); in pvr2_hdw_worker_poll()
3244 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_worker_poll()
3245 if (fl && hdw->state_func) { in pvr2_hdw_worker_poll()
3246 hdw->state_func(hdw->state_data); in pvr2_hdw_worker_poll()
3251 static int pvr2_hdw_wait(struct pvr2_hdw *hdw,int state) in pvr2_hdw_wait() argument
3254 hdw->state_wait_data, in pvr2_hdw_wait()
3255 (hdw->state_stale == 0) && in pvr2_hdw_wait()
3256 (!state || (hdw->master_state != state))); in pvr2_hdw_wait()
3261 const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw) in pvr2_hdw_get_driver_name() argument
3263 return hdw->name; in pvr2_hdw_get_driver_name()
3267 const char *pvr2_hdw_get_desc(struct pvr2_hdw *hdw) in pvr2_hdw_get_desc() argument
3269 return hdw->hdw_desc->description; in pvr2_hdw_get_desc()
3273 const char *pvr2_hdw_get_type(struct pvr2_hdw *hdw) in pvr2_hdw_get_type() argument
3275 return hdw->hdw_desc->shortname; in pvr2_hdw_get_type()
3279 int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw) in pvr2_hdw_is_hsm() argument
3282 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_is_hsm()
3283 hdw->cmd_buffer[0] = FX2CMD_GET_USB_SPEED; in pvr2_hdw_is_hsm()
3284 result = pvr2_send_request(hdw, in pvr2_hdw_is_hsm()
3285 hdw->cmd_buffer,1, in pvr2_hdw_is_hsm()
3286 hdw->cmd_buffer,1); in pvr2_hdw_is_hsm()
3288 result = (hdw->cmd_buffer[0] != 0); in pvr2_hdw_is_hsm()
3289 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_is_hsm()
3295 void pvr2_hdw_execute_tuner_poll(struct pvr2_hdw *hdw) in pvr2_hdw_execute_tuner_poll() argument
3297 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_execute_tuner_poll()
3298 pvr2_hdw_status_poll(hdw); in pvr2_hdw_execute_tuner_poll()
3299 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_execute_tuner_poll()
3303 static int pvr2_hdw_check_cropcap(struct pvr2_hdw *hdw) in pvr2_hdw_check_cropcap() argument
3305 if (!hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3308 pvr2_hdw_status_poll(hdw); in pvr2_hdw_check_cropcap()
3309 if (hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3317 int pvr2_hdw_get_cropcap(struct pvr2_hdw *hdw, struct v4l2_cropcap *pp) in pvr2_hdw_get_cropcap() argument
3320 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_get_cropcap()
3321 stat = pvr2_hdw_check_cropcap(hdw); in pvr2_hdw_get_cropcap()
3323 memcpy(pp, &hdw->cropcap_info, sizeof(hdw->cropcap_info)); in pvr2_hdw_get_cropcap()
3325 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_get_cropcap()
3331 int pvr2_hdw_get_tuner_status(struct pvr2_hdw *hdw,struct v4l2_tuner *vtp) in pvr2_hdw_get_tuner_status() argument
3333 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_get_tuner_status()
3334 if (hdw->tuner_signal_stale) { in pvr2_hdw_get_tuner_status()
3335 pvr2_hdw_status_poll(hdw); in pvr2_hdw_get_tuner_status()
3337 memcpy(vtp,&hdw->tuner_signal_info,sizeof(struct v4l2_tuner)); in pvr2_hdw_get_tuner_status()
3338 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_get_tuner_status()
3350 void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw) in pvr2_hdw_trigger_module_log() argument
3352 int nr = pvr2_hdw_get_unit_number(hdw); in pvr2_hdw_trigger_module_log()
3353 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_trigger_module_log()
3356 v4l2_device_call_all(&hdw->v4l2_dev, 0, core, log_status); in pvr2_hdw_trigger_module_log()
3358 cx2341x_log_status(&hdw->enc_ctl_state, "pvrusb2"); in pvr2_hdw_trigger_module_log()
3359 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_trigger_module_log()
3362 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_trigger_module_log()
3369 static u8 *pvr2_full_eeprom_fetch(struct pvr2_hdw *hdw) in pvr2_full_eeprom_fetch() argument
3389 hdw->eeprom_addr); in pvr2_full_eeprom_fetch()
3390 addr = hdw->eeprom_addr; in pvr2_full_eeprom_fetch()
3429 if ((ret = i2c_transfer(&hdw->i2c_adap, in pvr2_full_eeprom_fetch()
3441 void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, in pvr2_hdw_cpufw_set_enabled() argument
3448 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_cpufw_set_enabled()
3449 if ((hdw->fw_buffer == NULL) == !enable_flag) break; in pvr2_hdw_cpufw_set_enabled()
3454 kfree(hdw->fw_buffer); in pvr2_hdw_cpufw_set_enabled()
3455 hdw->fw_buffer = NULL; in pvr2_hdw_cpufw_set_enabled()
3456 hdw->fw_size = 0; in pvr2_hdw_cpufw_set_enabled()
3457 if (hdw->fw_cpu_flag) { in pvr2_hdw_cpufw_set_enabled()
3460 pvr2_hdw_cpureset_assert(hdw,0); in pvr2_hdw_cpufw_set_enabled()
3465 hdw->fw_cpu_flag = (mode != 2); in pvr2_hdw_cpufw_set_enabled()
3466 if (hdw->fw_cpu_flag) { in pvr2_hdw_cpufw_set_enabled()
3467 hdw->fw_size = (mode == 1) ? 0x4000 : 0x2000; in pvr2_hdw_cpufw_set_enabled()
3470 " (size=%u)", hdw->fw_size); in pvr2_hdw_cpufw_set_enabled()
3471 hdw->fw_buffer = kzalloc(hdw->fw_size,GFP_KERNEL); in pvr2_hdw_cpufw_set_enabled()
3472 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_set_enabled()
3473 hdw->fw_size = 0; in pvr2_hdw_cpufw_set_enabled()
3478 pvr2_hdw_cpureset_assert(hdw,1); in pvr2_hdw_cpufw_set_enabled()
3485 pipe = usb_rcvctrlpipe(hdw->usb_dev, 0); in pvr2_hdw_cpufw_set_enabled()
3486 for(address = 0; address < hdw->fw_size; in pvr2_hdw_cpufw_set_enabled()
3488 ret = usb_control_msg(hdw->usb_dev,pipe, in pvr2_hdw_cpufw_set_enabled()
3491 hdw->fw_buffer+address, in pvr2_hdw_cpufw_set_enabled()
3501 hdw->fw_buffer = pvr2_full_eeprom_fetch(hdw); in pvr2_hdw_cpufw_set_enabled()
3502 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_set_enabled()
3507 hdw->fw_size = EEPROM_SIZE; in pvr2_hdw_cpufw_set_enabled()
3512 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_cpufw_set_enabled()
3517 int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw) in pvr2_hdw_cpufw_get_enabled() argument
3519 return hdw->fw_buffer != NULL; in pvr2_hdw_cpufw_get_enabled()
3523 int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs, in pvr2_hdw_cpufw_get() argument
3527 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_cpufw_get()
3531 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_get()
3536 if (offs >= hdw->fw_size) { in pvr2_hdw_cpufw_get()
3544 if (offs + cnt > hdw->fw_size) cnt = hdw->fw_size - offs; in pvr2_hdw_cpufw_get()
3546 memcpy(buf,hdw->fw_buffer+offs,cnt); in pvr2_hdw_cpufw_get()
3552 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_cpufw_get()
3558 int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw, in pvr2_hdw_v4l_get_minor_number() argument
3562 case pvr2_v4l_type_video: return hdw->v4l_minor_number_video; in pvr2_hdw_v4l_get_minor_number()
3563 case pvr2_v4l_type_vbi: return hdw->v4l_minor_number_vbi; in pvr2_hdw_v4l_get_minor_number()
3564 case pvr2_v4l_type_radio: return hdw->v4l_minor_number_radio; in pvr2_hdw_v4l_get_minor_number()
3571 void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw, in pvr2_hdw_v4l_store_minor_number() argument
3575 case pvr2_v4l_type_video: hdw->v4l_minor_number_video = v;break; in pvr2_hdw_v4l_store_minor_number()
3576 case pvr2_v4l_type_vbi: hdw->v4l_minor_number_vbi = v;break; in pvr2_hdw_v4l_store_minor_number()
3577 case pvr2_v4l_type_radio: hdw->v4l_minor_number_radio = v;break; in pvr2_hdw_v4l_store_minor_number()
3585 struct pvr2_hdw *hdw = urb->context; in pvr2_ctl_write_complete() local
3586 hdw->ctl_write_pend_flag = 0; in pvr2_ctl_write_complete()
3587 if (hdw->ctl_read_pend_flag) return; in pvr2_ctl_write_complete()
3588 complete(&hdw->ctl_done); in pvr2_ctl_write_complete()
3594 struct pvr2_hdw *hdw = urb->context; in pvr2_ctl_read_complete() local
3595 hdw->ctl_read_pend_flag = 0; in pvr2_ctl_read_complete()
3596 if (hdw->ctl_write_pend_flag) return; in pvr2_ctl_read_complete()
3597 complete(&hdw->ctl_done); in pvr2_ctl_read_complete()
3603 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_ctl_timeout() local
3604 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { in pvr2_ctl_timeout()
3605 hdw->ctl_timeout_flag = !0; in pvr2_ctl_timeout()
3606 if (hdw->ctl_write_pend_flag) in pvr2_ctl_timeout()
3607 usb_unlink_urb(hdw->ctl_write_urb); in pvr2_ctl_timeout()
3608 if (hdw->ctl_read_pend_flag) in pvr2_ctl_timeout()
3609 usb_unlink_urb(hdw->ctl_read_urb); in pvr2_ctl_timeout()
3618 static int pvr2_send_request_ex(struct pvr2_hdw *hdw, in pvr2_send_request_ex() argument
3626 if (!hdw->ctl_lock_held) { in pvr2_send_request_ex()
3632 if (!hdw->flag_ok && !probe_fl) { in pvr2_send_request_ex()
3638 if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) { in pvr2_send_request_ex()
3674 hdw->cmd_debug_state = 1; in pvr2_send_request_ex()
3676 hdw->cmd_debug_code = ((unsigned char *)write_data)[0]; in pvr2_send_request_ex()
3678 hdw->cmd_debug_code = 0; in pvr2_send_request_ex()
3680 hdw->cmd_debug_write_len = write_len; in pvr2_send_request_ex()
3681 hdw->cmd_debug_read_len = read_len; in pvr2_send_request_ex()
3684 init_completion(&hdw->ctl_done); in pvr2_send_request_ex()
3685 hdw->ctl_timeout_flag = 0; in pvr2_send_request_ex()
3686 hdw->ctl_write_pend_flag = 0; in pvr2_send_request_ex()
3687 hdw->ctl_read_pend_flag = 0; in pvr2_send_request_ex()
3688 setup_timer(&timer, pvr2_ctl_timeout, (unsigned long)hdw); in pvr2_send_request_ex()
3692 hdw->cmd_debug_state = 2; in pvr2_send_request_ex()
3695 hdw->ctl_write_buffer[idx] = in pvr2_send_request_ex()
3699 usb_fill_bulk_urb(hdw->ctl_write_urb, in pvr2_send_request_ex()
3700 hdw->usb_dev, in pvr2_send_request_ex()
3701 usb_sndbulkpipe(hdw->usb_dev, in pvr2_send_request_ex()
3703 hdw->ctl_write_buffer, in pvr2_send_request_ex()
3706 hdw); in pvr2_send_request_ex()
3707 hdw->ctl_write_urb->actual_length = 0; in pvr2_send_request_ex()
3708 hdw->ctl_write_pend_flag = !0; in pvr2_send_request_ex()
3709 status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL); in pvr2_send_request_ex()
3714 hdw->ctl_write_pend_flag = 0; in pvr2_send_request_ex()
3720 hdw->cmd_debug_state = 3; in pvr2_send_request_ex()
3721 memset(hdw->ctl_read_buffer,0x43,read_len); in pvr2_send_request_ex()
3723 usb_fill_bulk_urb(hdw->ctl_read_urb, in pvr2_send_request_ex()
3724 hdw->usb_dev, in pvr2_send_request_ex()
3725 usb_rcvbulkpipe(hdw->usb_dev, in pvr2_send_request_ex()
3727 hdw->ctl_read_buffer, in pvr2_send_request_ex()
3730 hdw); in pvr2_send_request_ex()
3731 hdw->ctl_read_urb->actual_length = 0; in pvr2_send_request_ex()
3732 hdw->ctl_read_pend_flag = !0; in pvr2_send_request_ex()
3733 status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL); in pvr2_send_request_ex()
3738 hdw->ctl_read_pend_flag = 0; in pvr2_send_request_ex()
3747 hdw->cmd_debug_state = 4; in pvr2_send_request_ex()
3748 while (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { in pvr2_send_request_ex()
3749 wait_for_completion(&hdw->ctl_done); in pvr2_send_request_ex()
3751 hdw->cmd_debug_state = 5; in pvr2_send_request_ex()
3756 hdw->cmd_debug_state = 6; in pvr2_send_request_ex()
3759 if (hdw->ctl_timeout_flag) { in pvr2_send_request_ex()
3770 if ((hdw->ctl_write_urb->status != 0) && in pvr2_send_request_ex()
3771 (hdw->ctl_write_urb->status != -ENOENT) && in pvr2_send_request_ex()
3772 (hdw->ctl_write_urb->status != -ESHUTDOWN) && in pvr2_send_request_ex()
3773 (hdw->ctl_write_urb->status != -ECONNRESET)) { in pvr2_send_request_ex()
3776 status = hdw->ctl_write_urb->status; in pvr2_send_request_ex()
3785 if (hdw->ctl_write_urb->actual_length < write_len) { in pvr2_send_request_ex()
3793 hdw->ctl_write_urb->actual_length); in pvr2_send_request_ex()
3800 if ((hdw->ctl_read_urb->status != 0) && in pvr2_send_request_ex()
3801 (hdw->ctl_read_urb->status != -ENOENT) && in pvr2_send_request_ex()
3802 (hdw->ctl_read_urb->status != -ESHUTDOWN) && in pvr2_send_request_ex()
3803 (hdw->ctl_read_urb->status != -ECONNRESET)) { in pvr2_send_request_ex()
3806 status = hdw->ctl_read_urb->status; in pvr2_send_request_ex()
3815 if (hdw->ctl_read_urb->actual_length < read_len) { in pvr2_send_request_ex()
3823 hdw->ctl_read_urb->actual_length); in pvr2_send_request_ex()
3830 hdw->ctl_read_buffer[idx]; in pvr2_send_request_ex()
3836 hdw->cmd_debug_state = 0; in pvr2_send_request_ex()
3838 pvr2_hdw_render_useless(hdw); in pvr2_send_request_ex()
3844 int pvr2_send_request(struct pvr2_hdw *hdw, in pvr2_send_request() argument
3848 return pvr2_send_request_ex(hdw,HZ*4,0, in pvr2_send_request()
3854 static int pvr2_issue_simple_cmd(struct pvr2_hdw *hdw,u32 cmdcode) in pvr2_issue_simple_cmd() argument
3859 LOCK_TAKE(hdw->ctl_lock); in pvr2_issue_simple_cmd()
3860 hdw->cmd_buffer[0] = cmdcode & 0xffu; in pvr2_issue_simple_cmd()
3865 hdw->cmd_buffer[1] = (cmdcode >> 16) & 0xffu; in pvr2_issue_simple_cmd()
3867 hdw->cmd_buffer[2] = (cmdcode >> 24) & 0xffu; in pvr2_issue_simple_cmd()
3893 " (%u",hdw->cmd_buffer[1]); in pvr2_issue_simple_cmd()
3898 ",%u",hdw->cmd_buffer[2]); in pvr2_issue_simple_cmd()
3908 ret = pvr2_send_request(hdw,hdw->cmd_buffer,cnt,NULL,0); in pvr2_issue_simple_cmd()
3909 LOCK_GIVE(hdw->ctl_lock); in pvr2_issue_simple_cmd()
3914 int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data) in pvr2_write_register() argument
3918 LOCK_TAKE(hdw->ctl_lock); in pvr2_write_register()
3920 hdw->cmd_buffer[0] = FX2CMD_REG_WRITE; /* write register prefix */ in pvr2_write_register()
3921 PVR2_DECOMPOSE_LE(hdw->cmd_buffer,1,data); in pvr2_write_register()
3922 hdw->cmd_buffer[5] = 0; in pvr2_write_register()
3923 hdw->cmd_buffer[6] = (reg >> 8) & 0xff; in pvr2_write_register()
3924 hdw->cmd_buffer[7] = reg & 0xff; in pvr2_write_register()
3927 ret = pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 0); in pvr2_write_register()
3929 LOCK_GIVE(hdw->ctl_lock); in pvr2_write_register()
3935 static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data) in pvr2_read_register() argument
3939 LOCK_TAKE(hdw->ctl_lock); in pvr2_read_register()
3941 hdw->cmd_buffer[0] = FX2CMD_REG_READ; /* read register prefix */ in pvr2_read_register()
3942 hdw->cmd_buffer[1] = 0; in pvr2_read_register()
3943 hdw->cmd_buffer[2] = 0; in pvr2_read_register()
3944 hdw->cmd_buffer[3] = 0; in pvr2_read_register()
3945 hdw->cmd_buffer[4] = 0; in pvr2_read_register()
3946 hdw->cmd_buffer[5] = 0; in pvr2_read_register()
3947 hdw->cmd_buffer[6] = (reg >> 8) & 0xff; in pvr2_read_register()
3948 hdw->cmd_buffer[7] = reg & 0xff; in pvr2_read_register()
3950 ret |= pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 4); in pvr2_read_register()
3951 *data = PVR2_COMPOSE_LE(hdw->cmd_buffer,0); in pvr2_read_register()
3953 LOCK_GIVE(hdw->ctl_lock); in pvr2_read_register()
3959 void pvr2_hdw_render_useless(struct pvr2_hdw *hdw) in pvr2_hdw_render_useless() argument
3961 if (!hdw->flag_ok) return; in pvr2_hdw_render_useless()
3964 if (hdw->vid_stream) { in pvr2_hdw_render_useless()
3965 pvr2_stream_setup(hdw->vid_stream,NULL,0,0); in pvr2_hdw_render_useless()
3967 hdw->flag_ok = 0; in pvr2_hdw_render_useless()
3968 trace_stbit("flag_ok",hdw->flag_ok); in pvr2_hdw_render_useless()
3969 pvr2_hdw_state_sched(hdw); in pvr2_hdw_render_useless()
3973 void pvr2_hdw_device_reset(struct pvr2_hdw *hdw) in pvr2_hdw_device_reset() argument
3977 ret = usb_lock_device_for_reset(hdw->usb_dev,NULL); in pvr2_hdw_device_reset()
3979 ret = usb_reset_device(hdw->usb_dev); in pvr2_hdw_device_reset()
3980 usb_unlock_device(hdw->usb_dev); in pvr2_hdw_device_reset()
3995 void pvr2_hdw_cpureset_assert(struct pvr2_hdw *hdw,int val) in pvr2_hdw_cpureset_assert() argument
4001 if (!hdw->usb_dev) return; in pvr2_hdw_cpureset_assert()
4017 pipe = usb_sndctrlpipe(hdw->usb_dev, 0); in pvr2_hdw_cpureset_assert()
4018 ret = usb_control_msg(hdw->usb_dev,pipe,0xa0,0x40,0xe600,0,da,1,HZ); in pvr2_hdw_cpureset_assert()
4022 pvr2_hdw_render_useless(hdw); in pvr2_hdw_cpureset_assert()
4029 int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_deep_reset() argument
4031 return pvr2_issue_simple_cmd(hdw,FX2CMD_DEEP_RESET); in pvr2_hdw_cmd_deep_reset()
4035 int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_powerup() argument
4037 return pvr2_issue_simple_cmd(hdw,FX2CMD_POWER_ON); in pvr2_hdw_cmd_powerup()
4042 int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_decoder_reset() argument
4046 if (hdw->decoder_client_id) { in pvr2_hdw_cmd_decoder_reset()
4047 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, in pvr2_hdw_cmd_decoder_reset()
4049 pvr2_hdw_cx25840_vbi_hack(hdw); in pvr2_hdw_cmd_decoder_reset()
4058 static int pvr2_hdw_cmd_hcw_demod_reset(struct pvr2_hdw *hdw, int onoff) in pvr2_hdw_cmd_hcw_demod_reset() argument
4060 hdw->flag_ok = !0; in pvr2_hdw_cmd_hcw_demod_reset()
4061 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_hcw_demod_reset()
4068 static int pvr2_hdw_cmd_onair_fe_power_ctrl(struct pvr2_hdw *hdw, int onoff) in pvr2_hdw_cmd_onair_fe_power_ctrl() argument
4070 hdw->flag_ok = !0; in pvr2_hdw_cmd_onair_fe_power_ctrl()
4071 return pvr2_issue_simple_cmd(hdw,(onoff ? in pvr2_hdw_cmd_onair_fe_power_ctrl()
4077 static int pvr2_hdw_cmd_onair_digital_path_ctrl(struct pvr2_hdw *hdw, in pvr2_hdw_cmd_onair_digital_path_ctrl() argument
4080 return pvr2_issue_simple_cmd(hdw,(onoff ? in pvr2_hdw_cmd_onair_digital_path_ctrl()
4086 static void pvr2_hdw_cmd_modeswitch(struct pvr2_hdw *hdw,int digitalFl) in pvr2_hdw_cmd_modeswitch() argument
4092 if (cmode == hdw->pathway_state) { in pvr2_hdw_cmd_modeswitch()
4097 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_modeswitch()
4099 pvr2_hdw_cmd_hcw_demod_reset(hdw,digitalFl); in pvr2_hdw_cmd_modeswitch()
4105 pvr2_hdw_cmd_decoder_reset(hdw); in pvr2_hdw_cmd_modeswitch()
4112 pvr2_hdw_cmd_onair_fe_power_ctrl(hdw,digitalFl); in pvr2_hdw_cmd_modeswitch()
4117 pvr2_hdw_untrip_unlocked(hdw); in pvr2_hdw_cmd_modeswitch()
4118 hdw->pathway_state = cmode; in pvr2_hdw_cmd_modeswitch()
4122 static void pvr2_led_ctrl_hauppauge(struct pvr2_hdw *hdw, int onoff) in pvr2_led_ctrl_hauppauge() argument
4131 pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000481); in pvr2_led_ctrl_hauppauge()
4133 pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000401); in pvr2_led_ctrl_hauppauge()
4135 pvr2_hdw_gpio_chg_out(hdw, 0xffffffff, 0x00000000); in pvr2_led_ctrl_hauppauge()
4147 static void pvr2_led_ctrl(struct pvr2_hdw *hdw,int onoff) in pvr2_led_ctrl() argument
4152 if ((!onoff) == (!hdw->led_on)) return; in pvr2_led_ctrl()
4154 hdw->led_on = onoff != 0; in pvr2_led_ctrl()
4156 scheme_id = hdw->hdw_desc->led_scheme; in pvr2_led_ctrl()
4163 if (fp) (*fp)(hdw,onoff); in pvr2_led_ctrl()
4168 static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl) in pvr2_hdw_cmd_usbstream() argument
4174 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in pvr2_hdw_cmd_usbstream()
4175 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4182 if (hdw->pathway_state != PVR2_PATHWAY_DIGITAL) { in pvr2_hdw_cmd_usbstream()
4191 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_usbstream()
4193 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4198 ret = pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4203 return pvr2_hdw_cmd_onair_digital_path_ctrl(hdw,runFl); in pvr2_hdw_cmd_usbstream()
4211 static int state_eval_pathway_ok(struct pvr2_hdw *hdw) in state_eval_pathway_ok() argument
4213 if (hdw->state_pathway_ok) { in state_eval_pathway_ok()
4217 if (!hdw->state_pipeline_idle) { in state_eval_pathway_ok()
4221 pvr2_hdw_cmd_modeswitch(hdw,hdw->input_val == PVR2_CVAL_INPUT_DTV); in state_eval_pathway_ok()
4222 hdw->state_pathway_ok = !0; in state_eval_pathway_ok()
4223 trace_stbit("state_pathway_ok",hdw->state_pathway_ok); in state_eval_pathway_ok()
4229 static int state_eval_encoder_ok(struct pvr2_hdw *hdw) in state_eval_encoder_ok() argument
4231 if (hdw->state_encoder_ok) return 0; in state_eval_encoder_ok()
4232 if (hdw->flag_tripped) return 0; in state_eval_encoder_ok()
4233 if (hdw->state_encoder_run) return 0; in state_eval_encoder_ok()
4234 if (hdw->state_encoder_config) return 0; in state_eval_encoder_ok()
4235 if (hdw->state_decoder_run) return 0; in state_eval_encoder_ok()
4236 if (hdw->state_usbstream_run) return 0; in state_eval_encoder_ok()
4237 if (hdw->pathway_state == PVR2_PATHWAY_DIGITAL) { in state_eval_encoder_ok()
4238 if (!hdw->hdw_desc->flag_digital_requires_cx23416) return 0; in state_eval_encoder_ok()
4239 } else if (hdw->pathway_state != PVR2_PATHWAY_ANALOG) { in state_eval_encoder_ok()
4243 if (pvr2_upload_firmware2(hdw) < 0) { in state_eval_encoder_ok()
4244 hdw->flag_tripped = !0; in state_eval_encoder_ok()
4245 trace_stbit("flag_tripped",hdw->flag_tripped); in state_eval_encoder_ok()
4248 hdw->state_encoder_ok = !0; in state_eval_encoder_ok()
4249 trace_stbit("state_encoder_ok",hdw->state_encoder_ok); in state_eval_encoder_ok()
4255 static int state_eval_encoder_config(struct pvr2_hdw *hdw) in state_eval_encoder_config() argument
4257 if (hdw->state_encoder_config) { in state_eval_encoder_config()
4258 if (hdw->state_encoder_ok) { in state_eval_encoder_config()
4259 if (hdw->state_pipeline_req && in state_eval_encoder_config()
4260 !hdw->state_pipeline_pause) return 0; in state_eval_encoder_config()
4262 hdw->state_encoder_config = 0; in state_eval_encoder_config()
4263 hdw->state_encoder_waitok = 0; in state_eval_encoder_config()
4264 trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); in state_eval_encoder_config()
4266 del_timer_sync(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4268 if (!hdw->state_pathway_ok || in state_eval_encoder_config()
4269 (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || in state_eval_encoder_config()
4270 !hdw->state_encoder_ok || in state_eval_encoder_config()
4271 !hdw->state_pipeline_idle || in state_eval_encoder_config()
4272 hdw->state_pipeline_pause || in state_eval_encoder_config()
4273 !hdw->state_pipeline_req || in state_eval_encoder_config()
4274 !hdw->state_pipeline_config) { in state_eval_encoder_config()
4278 if (timer_pending(&hdw->encoder_wait_timer)) { in state_eval_encoder_config()
4279 del_timer_sync(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4281 if (hdw->state_encoder_waitok) { in state_eval_encoder_config()
4285 hdw->state_encoder_waitok = 0; in state_eval_encoder_config()
4287 hdw->state_encoder_waitok); in state_eval_encoder_config()
4292 if (!hdw->state_encoder_waitok) { in state_eval_encoder_config()
4293 if (!timer_pending(&hdw->encoder_wait_timer)) { in state_eval_encoder_config()
4300 if (!hdw->state_encoder_waitok) { in state_eval_encoder_config()
4301 hdw->encoder_wait_timer.expires = in state_eval_encoder_config()
4304 add_timer(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4312 pvr2_encoder_configure(hdw); in state_eval_encoder_config()
4313 if (hdw->state_encoder_ok) hdw->state_encoder_config = !0; in state_eval_encoder_config()
4315 trace_stbit("state_encoder_config",hdw->state_encoder_config); in state_eval_encoder_config()
4321 static int state_check_disable_encoder_run(struct pvr2_hdw *hdw) in state_check_disable_encoder_run() argument
4323 if (!hdw->state_encoder_ok) { in state_check_disable_encoder_run()
4327 if (!hdw->state_pathway_ok) { in state_check_disable_encoder_run()
4333 switch (hdw->pathway_state) { in state_check_disable_encoder_run()
4335 if (!hdw->state_decoder_run) { in state_check_disable_encoder_run()
4343 if (hdw->state_encoder_runok) { in state_check_disable_encoder_run()
4366 static int state_check_enable_encoder_run(struct pvr2_hdw *hdw) in state_check_enable_encoder_run() argument
4368 if (!hdw->state_encoder_ok) { in state_check_enable_encoder_run()
4372 if (!hdw->state_pathway_ok) { in state_check_enable_encoder_run()
4378 switch (hdw->pathway_state) { in state_check_enable_encoder_run()
4380 if (hdw->state_decoder_run && hdw->state_decoder_ready) { in state_check_enable_encoder_run()
4387 if ((hdw->hdw_desc->digital_control_scheme == in state_check_enable_encoder_run()
4389 !hdw->state_encoder_runok) { in state_check_enable_encoder_run()
4412 static int state_eval_encoder_run(struct pvr2_hdw *hdw) in state_eval_encoder_run() argument
4414 if (hdw->state_encoder_run) { in state_eval_encoder_run()
4415 if (!state_check_disable_encoder_run(hdw)) return 0; in state_eval_encoder_run()
4416 if (hdw->state_encoder_ok) { in state_eval_encoder_run()
4417 del_timer_sync(&hdw->encoder_run_timer); in state_eval_encoder_run()
4418 if (pvr2_encoder_stop(hdw) < 0) return !0; in state_eval_encoder_run()
4420 hdw->state_encoder_run = 0; in state_eval_encoder_run()
4422 if (!state_check_enable_encoder_run(hdw)) return 0; in state_eval_encoder_run()
4423 if (pvr2_encoder_start(hdw) < 0) return !0; in state_eval_encoder_run()
4424 hdw->state_encoder_run = !0; in state_eval_encoder_run()
4425 if (!hdw->state_encoder_runok) { in state_eval_encoder_run()
4426 hdw->encoder_run_timer.expires = jiffies + in state_eval_encoder_run()
4428 add_timer(&hdw->encoder_run_timer); in state_eval_encoder_run()
4431 trace_stbit("state_encoder_run",hdw->state_encoder_run); in state_eval_encoder_run()
4439 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_quiescent_timeout() local
4440 hdw->state_decoder_quiescent = !0; in pvr2_hdw_quiescent_timeout()
4441 trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); in pvr2_hdw_quiescent_timeout()
4442 hdw->state_stale = !0; in pvr2_hdw_quiescent_timeout()
4443 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_quiescent_timeout()
4450 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_decoder_stabilization_timeout() local
4451 hdw->state_decoder_ready = !0; in pvr2_hdw_decoder_stabilization_timeout()
4452 trace_stbit("state_decoder_ready", hdw->state_decoder_ready); in pvr2_hdw_decoder_stabilization_timeout()
4453 hdw->state_stale = !0; in pvr2_hdw_decoder_stabilization_timeout()
4454 queue_work(hdw->workqueue, &hdw->workpoll); in pvr2_hdw_decoder_stabilization_timeout()
4461 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_encoder_wait_timeout() local
4462 hdw->state_encoder_waitok = !0; in pvr2_hdw_encoder_wait_timeout()
4463 trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); in pvr2_hdw_encoder_wait_timeout()
4464 hdw->state_stale = !0; in pvr2_hdw_encoder_wait_timeout()
4465 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_encoder_wait_timeout()
4472 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_encoder_run_timeout() local
4473 if (!hdw->state_encoder_runok) { in pvr2_hdw_encoder_run_timeout()
4474 hdw->state_encoder_runok = !0; in pvr2_hdw_encoder_run_timeout()
4475 trace_stbit("state_encoder_runok",hdw->state_encoder_runok); in pvr2_hdw_encoder_run_timeout()
4476 hdw->state_stale = !0; in pvr2_hdw_encoder_run_timeout()
4477 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_encoder_run_timeout()
4483 static int state_eval_decoder_run(struct pvr2_hdw *hdw) in state_eval_decoder_run() argument
4485 if (hdw->state_decoder_run) { in state_eval_decoder_run()
4486 if (hdw->state_encoder_ok) { in state_eval_decoder_run()
4487 if (hdw->state_pipeline_req && in state_eval_decoder_run()
4488 !hdw->state_pipeline_pause && in state_eval_decoder_run()
4489 hdw->state_pathway_ok) return 0; in state_eval_decoder_run()
4491 if (!hdw->flag_decoder_missed) { in state_eval_decoder_run()
4492 pvr2_decoder_enable(hdw,0); in state_eval_decoder_run()
4494 hdw->state_decoder_quiescent = 0; in state_eval_decoder_run()
4495 hdw->state_decoder_run = 0; in state_eval_decoder_run()
4497 del_timer_sync(&hdw->quiescent_timer); in state_eval_decoder_run()
4501 del_timer_sync(&hdw->decoder_stabilization_timer); in state_eval_decoder_run()
4502 hdw->state_decoder_ready = 0; in state_eval_decoder_run()
4504 if (!hdw->state_decoder_quiescent) { in state_eval_decoder_run()
4505 if (!timer_pending(&hdw->quiescent_timer)) { in state_eval_decoder_run()
4516 if (!hdw->state_decoder_quiescent) { in state_eval_decoder_run()
4517 hdw->quiescent_timer.expires = in state_eval_decoder_run()
4520 add_timer(&hdw->quiescent_timer); in state_eval_decoder_run()
4528 if (!hdw->state_pathway_ok || in state_eval_decoder_run()
4529 (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || in state_eval_decoder_run()
4530 !hdw->state_pipeline_req || in state_eval_decoder_run()
4531 hdw->state_pipeline_pause || in state_eval_decoder_run()
4532 !hdw->state_pipeline_config || in state_eval_decoder_run()
4533 !hdw->state_encoder_config || in state_eval_decoder_run()
4534 !hdw->state_encoder_ok) return 0; in state_eval_decoder_run()
4535 del_timer_sync(&hdw->quiescent_timer); in state_eval_decoder_run()
4536 if (hdw->flag_decoder_missed) return 0; in state_eval_decoder_run()
4537 if (pvr2_decoder_enable(hdw,!0) < 0) return 0; in state_eval_decoder_run()
4538 hdw->state_decoder_quiescent = 0; in state_eval_decoder_run()
4539 hdw->state_decoder_ready = 0; in state_eval_decoder_run()
4540 hdw->state_decoder_run = !0; in state_eval_decoder_run()
4541 if (hdw->decoder_client_id == PVR2_CLIENT_ID_SAA7115) { in state_eval_decoder_run()
4542 hdw->decoder_stabilization_timer.expires = in state_eval_decoder_run()
4545 add_timer(&hdw->decoder_stabilization_timer); in state_eval_decoder_run()
4547 hdw->state_decoder_ready = !0; in state_eval_decoder_run()
4550 trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); in state_eval_decoder_run()
4551 trace_stbit("state_decoder_run",hdw->state_decoder_run); in state_eval_decoder_run()
4552 trace_stbit("state_decoder_ready", hdw->state_decoder_ready); in state_eval_decoder_run()
4558 static int state_eval_usbstream_run(struct pvr2_hdw *hdw) in state_eval_usbstream_run() argument
4560 if (hdw->state_usbstream_run) { in state_eval_usbstream_run()
4562 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in state_eval_usbstream_run()
4563 fl = (hdw->state_encoder_ok && in state_eval_usbstream_run()
4564 hdw->state_encoder_run); in state_eval_usbstream_run()
4565 } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && in state_eval_usbstream_run()
4566 (hdw->hdw_desc->flag_digital_requires_cx23416)) { in state_eval_usbstream_run()
4567 fl = hdw->state_encoder_ok; in state_eval_usbstream_run()
4570 hdw->state_pipeline_req && in state_eval_usbstream_run()
4571 !hdw->state_pipeline_pause && in state_eval_usbstream_run()
4572 hdw->state_pathway_ok) { in state_eval_usbstream_run()
4575 pvr2_hdw_cmd_usbstream(hdw,0); in state_eval_usbstream_run()
4576 hdw->state_usbstream_run = 0; in state_eval_usbstream_run()
4578 if (!hdw->state_pipeline_req || in state_eval_usbstream_run()
4579 hdw->state_pipeline_pause || in state_eval_usbstream_run()
4580 !hdw->state_pathway_ok) return 0; in state_eval_usbstream_run()
4581 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in state_eval_usbstream_run()
4582 if (!hdw->state_encoder_ok || in state_eval_usbstream_run()
4583 !hdw->state_encoder_run) return 0; in state_eval_usbstream_run()
4584 } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && in state_eval_usbstream_run()
4585 (hdw->hdw_desc->flag_digital_requires_cx23416)) { in state_eval_usbstream_run()
4586 if (!hdw->state_encoder_ok) return 0; in state_eval_usbstream_run()
4587 if (hdw->state_encoder_run) return 0; in state_eval_usbstream_run()
4588 if (hdw->hdw_desc->digital_control_scheme == in state_eval_usbstream_run()
4595 if (!hdw->state_encoder_runok) return 0; in state_eval_usbstream_run()
4598 if (pvr2_hdw_cmd_usbstream(hdw,!0) < 0) return 0; in state_eval_usbstream_run()
4599 hdw->state_usbstream_run = !0; in state_eval_usbstream_run()
4601 trace_stbit("state_usbstream_run",hdw->state_usbstream_run); in state_eval_usbstream_run()
4607 static int state_eval_pipeline_config(struct pvr2_hdw *hdw) in state_eval_pipeline_config() argument
4609 if (hdw->state_pipeline_config || in state_eval_pipeline_config()
4610 hdw->state_pipeline_pause) return 0; in state_eval_pipeline_config()
4611 pvr2_hdw_commit_execute(hdw); in state_eval_pipeline_config()
4619 static int state_update_pipeline_state(struct pvr2_hdw *hdw) in state_update_pipeline_state() argument
4624 st = !(hdw->state_encoder_run || in state_update_pipeline_state()
4625 hdw->state_decoder_run || in state_update_pipeline_state()
4626 hdw->state_usbstream_run || in state_update_pipeline_state()
4627 (!hdw->state_decoder_quiescent)); in state_update_pipeline_state()
4628 if (!st != !hdw->state_pipeline_idle) { in state_update_pipeline_state()
4629 hdw->state_pipeline_idle = st; in state_update_pipeline_state()
4632 if (hdw->state_pipeline_idle && hdw->state_pipeline_pause) { in state_update_pipeline_state()
4633 hdw->state_pipeline_pause = 0; in state_update_pipeline_state()
4655 static int pvr2_hdw_state_update(struct pvr2_hdw *hdw) in pvr2_hdw_state_update() argument
4661 if (!hdw->state_stale) return 0; in pvr2_hdw_state_update()
4662 if ((hdw->fw1_state != FW1_STATE_OK) || in pvr2_hdw_state_update()
4663 !hdw->flag_ok) { in pvr2_hdw_state_update()
4664 hdw->state_stale = 0; in pvr2_hdw_state_update()
4676 state_update_pipeline_state(hdw); in pvr2_hdw_state_update()
4678 for (i = 0; (i<ARRAY_SIZE(eval_funcs)) && hdw->flag_ok; i++) { in pvr2_hdw_state_update()
4679 if ((*eval_funcs[i])(hdw)) { in pvr2_hdw_state_update()
4682 state_update_pipeline_state(hdw); in pvr2_hdw_state_update()
4685 } while (check_flag && hdw->flag_ok); in pvr2_hdw_state_update()
4686 hdw->state_stale = 0; in pvr2_hdw_state_update()
4687 trace_stbit("state_stale",hdw->state_stale); in pvr2_hdw_state_update()
4720 static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, in pvr2_hdw_report_unlocked() argument
4728 (hdw->flag_ok ? " <ok>" : " <fail>"), in pvr2_hdw_report_unlocked()
4729 (hdw->flag_init_ok ? " <init>" : " <uninitialized>"), in pvr2_hdw_report_unlocked()
4730 (hdw->flag_disconnected ? " <disconnected>" : in pvr2_hdw_report_unlocked()
4732 (hdw->flag_tripped ? " <tripped>" : ""), in pvr2_hdw_report_unlocked()
4733 (hdw->flag_decoder_missed ? " <no decoder>" : ""), in pvr2_hdw_report_unlocked()
4734 pvr2_pathway_state_name(hdw->pathway_state)); in pvr2_hdw_report_unlocked()
4740 (hdw->state_pipeline_idle ? " <idle>" : ""), in pvr2_hdw_report_unlocked()
4741 (hdw->state_pipeline_config ? in pvr2_hdw_report_unlocked()
4743 (hdw->state_pipeline_req ? " <req>" : ""), in pvr2_hdw_report_unlocked()
4744 (hdw->state_pipeline_pause ? " <pause>" : "")); in pvr2_hdw_report_unlocked()
4749 (hdw->state_decoder_run ? in pvr2_hdw_report_unlocked()
4750 (hdw->state_decoder_ready ? in pvr2_hdw_report_unlocked()
4752 (hdw->state_decoder_quiescent ? in pvr2_hdw_report_unlocked()
4754 (hdw->state_decoder_quiescent ? in pvr2_hdw_report_unlocked()
4756 (hdw->state_encoder_ok ? in pvr2_hdw_report_unlocked()
4758 (hdw->state_encoder_run ? in pvr2_hdw_report_unlocked()
4759 (hdw->state_encoder_runok ? in pvr2_hdw_report_unlocked()
4762 (hdw->state_encoder_runok ? in pvr2_hdw_report_unlocked()
4765 (hdw->state_encoder_config ? in pvr2_hdw_report_unlocked()
4767 (hdw->state_encoder_waitok ? in pvr2_hdw_report_unlocked()
4769 (hdw->state_usbstream_run ? in pvr2_hdw_report_unlocked()
4771 (hdw->state_pathway_ok ? in pvr2_hdw_report_unlocked()
4777 pvr2_get_state_name(hdw->master_state)); in pvr2_hdw_report_unlocked()
4786 tcnt += print_input_mask(hdw->input_avail_mask, in pvr2_hdw_report_unlocked()
4789 if (hdw->input_avail_mask != hdw->input_allowed_mask) { in pvr2_hdw_report_unlocked()
4794 tcnt += print_input_mask(hdw->input_allowed_mask, in pvr2_hdw_report_unlocked()
4802 if (!hdw->vid_stream) break; in pvr2_hdw_report_unlocked()
4803 pvr2_stream_get_stats(hdw->vid_stream, in pvr2_hdw_report_unlocked()
4819 unsigned int id = hdw->ir_scheme_active; in pvr2_hdw_report_unlocked()
4833 static unsigned int pvr2_hdw_report_clients(struct pvr2_hdw *hdw, in pvr2_hdw_report_clients() argument
4845 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) { in pvr2_hdw_report_clients()
4873 unsigned int pvr2_hdw_state_report(struct pvr2_hdw *hdw, in pvr2_hdw_state_report() argument
4878 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_state_report()
4880 ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,acnt); in pvr2_hdw_state_report()
4887 ccnt = pvr2_hdw_report_clients(hdw, buf, acnt); in pvr2_hdw_state_report()
4889 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_state_report()
4894 static void pvr2_hdw_state_log_state(struct pvr2_hdw *hdw) in pvr2_hdw_state_log_state() argument
4901 ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,sizeof(buf)); in pvr2_hdw_state_log_state()
4903 printk(KERN_INFO "%s %.*s\n",hdw->name,ccnt,buf); in pvr2_hdw_state_log_state()
4905 ccnt = pvr2_hdw_report_clients(hdw, buf, sizeof(buf)); in pvr2_hdw_state_log_state()
4912 printk(KERN_INFO "%s %.*s\n", hdw->name, lcnt, buf + ucnt); in pvr2_hdw_state_log_state()
4920 static int pvr2_hdw_state_eval(struct pvr2_hdw *hdw) in pvr2_hdw_state_eval() argument
4930 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_state_eval()
4934 state_updated = pvr2_hdw_state_update(hdw); in pvr2_hdw_state_eval()
4936 analog_mode = (hdw->pathway_state != PVR2_PATHWAY_DIGITAL); in pvr2_hdw_state_eval()
4939 if (!hdw->flag_ok) { in pvr2_hdw_state_eval()
4941 } else if (hdw->fw1_state != FW1_STATE_OK) { in pvr2_hdw_state_eval()
4944 hdw->hdw_desc->flag_digital_requires_cx23416) && in pvr2_hdw_state_eval()
4945 !hdw->state_encoder_ok) { in pvr2_hdw_state_eval()
4947 } else if (hdw->flag_tripped || in pvr2_hdw_state_eval()
4948 (analog_mode && hdw->flag_decoder_missed)) { in pvr2_hdw_state_eval()
4950 } else if (hdw->state_usbstream_run && in pvr2_hdw_state_eval()
4952 (hdw->state_encoder_run && hdw->state_decoder_run))) { in pvr2_hdw_state_eval()
4957 if (hdw->master_state != st) { in pvr2_hdw_state_eval()
4960 pvr2_get_state_name(hdw->master_state), in pvr2_hdw_state_eval()
4962 pvr2_led_ctrl(hdw,st == PVR2_STATE_RUN); in pvr2_hdw_state_eval()
4963 hdw->master_state = st; in pvr2_hdw_state_eval()
4969 wake_up(&hdw->state_wait_data); in pvr2_hdw_state_eval()
4973 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_state_eval()
4983 static void pvr2_hdw_state_sched(struct pvr2_hdw *hdw) in pvr2_hdw_state_sched() argument
4985 if (hdw->state_stale) return; in pvr2_hdw_state_sched()
4986 hdw->state_stale = !0; in pvr2_hdw_state_sched()
4987 trace_stbit("state_stale",hdw->state_stale); in pvr2_hdw_state_sched()
4988 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_state_sched()
4992 int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_dir() argument
4994 return pvr2_read_register(hdw,PVR2_GPIO_DIR,dp); in pvr2_hdw_gpio_get_dir()
4998 int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_out() argument
5000 return pvr2_read_register(hdw,PVR2_GPIO_OUT,dp); in pvr2_hdw_gpio_get_out()
5004 int pvr2_hdw_gpio_get_in(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_in() argument
5006 return pvr2_read_register(hdw,PVR2_GPIO_IN,dp); in pvr2_hdw_gpio_get_in()
5010 int pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val) in pvr2_hdw_gpio_chg_dir() argument
5015 ret = pvr2_read_register(hdw,PVR2_GPIO_DIR,&cval); in pvr2_hdw_gpio_chg_dir()
5027 return pvr2_write_register(hdw,PVR2_GPIO_DIR,nval); in pvr2_hdw_gpio_chg_dir()
5031 int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val) in pvr2_hdw_gpio_chg_out() argument
5036 ret = pvr2_read_register(hdw,PVR2_GPIO_OUT,&cval); in pvr2_hdw_gpio_chg_out()
5047 return pvr2_write_register(hdw,PVR2_GPIO_OUT,nval); in pvr2_hdw_gpio_chg_out()
5051 void pvr2_hdw_status_poll(struct pvr2_hdw *hdw) in pvr2_hdw_status_poll() argument
5053 struct v4l2_tuner *vtp = &hdw->tuner_signal_info; in pvr2_hdw_status_poll()
5055 vtp->type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? in pvr2_hdw_status_poll()
5057 hdw->tuner_signal_stale = 0; in pvr2_hdw_status_poll()
5062 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, vtp); in pvr2_hdw_status_poll()
5072 hdw->cropcap_stale = 0; in pvr2_hdw_status_poll()
5076 unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *hdw) in pvr2_hdw_get_input_available() argument
5078 return hdw->input_avail_mask; in pvr2_hdw_get_input_available()
5082 unsigned int pvr2_hdw_get_input_allowed(struct pvr2_hdw *hdw) in pvr2_hdw_get_input_allowed() argument
5084 return hdw->input_allowed_mask; in pvr2_hdw_get_input_allowed()
5088 static int pvr2_hdw_set_input(struct pvr2_hdw *hdw,int v) in pvr2_hdw_set_input() argument
5090 if (hdw->input_val != v) { in pvr2_hdw_set_input()
5091 hdw->input_val = v; in pvr2_hdw_set_input()
5092 hdw->input_dirty = !0; in pvr2_hdw_set_input()
5098 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_set_input()
5099 hdw->freqSelector = 0; in pvr2_hdw_set_input()
5100 hdw->freqDirty = !0; in pvr2_hdw_set_input()
5101 } else if ((hdw->input_val == PVR2_CVAL_INPUT_TV) || in pvr2_hdw_set_input()
5102 (hdw->input_val == PVR2_CVAL_INPUT_DTV)) { in pvr2_hdw_set_input()
5103 hdw->freqSelector = 1; in pvr2_hdw_set_input()
5104 hdw->freqDirty = !0; in pvr2_hdw_set_input()
5110 int pvr2_hdw_set_input_allowed(struct pvr2_hdw *hdw, in pvr2_hdw_set_input_allowed() argument
5116 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_set_input_allowed()
5118 nv = hdw->input_allowed_mask & ~change_mask; in pvr2_hdw_set_input_allowed()
5120 nv &= hdw->input_avail_mask; in pvr2_hdw_set_input_allowed()
5126 hdw->input_allowed_mask = nv; in pvr2_hdw_set_input_allowed()
5127 if ((1 << hdw->input_val) & hdw->input_allowed_mask) { in pvr2_hdw_set_input_allowed()
5134 if (!hdw->input_allowed_mask) { in pvr2_hdw_set_input_allowed()
5138 m = hdw->input_allowed_mask; in pvr2_hdw_set_input_allowed()
5141 pvr2_hdw_set_input(hdw,idx); in pvr2_hdw_set_input_allowed()
5145 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_input_allowed()
5151 static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) in pvr2_hdw_get_eeprom_addr() argument
5154 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_get_eeprom_addr()
5155 hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR; in pvr2_hdw_get_eeprom_addr()
5156 result = pvr2_send_request(hdw, in pvr2_hdw_get_eeprom_addr()
5157 hdw->cmd_buffer,1, in pvr2_hdw_get_eeprom_addr()
5158 hdw->cmd_buffer,1); in pvr2_hdw_get_eeprom_addr()
5160 result = hdw->cmd_buffer[0]; in pvr2_hdw_get_eeprom_addr()
5161 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_get_eeprom_addr()