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()
2608 hdw->unit_number = idx; in pvr2_hdw_create()
2609 unit_pointers[idx] = hdw; in pvr2_hdw_create()
2615 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); in pvr2_hdw_create()
2617 if (hdw->unit_number >= 0) { in pvr2_hdw_create()
2618 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"_%c", in pvr2_hdw_create()
2619 ('a' + hdw->unit_number)); in pvr2_hdw_create()
2622 if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1; in pvr2_hdw_create()
2623 hdw->name[cnt1] = 0; in pvr2_hdw_create()
2625 hdw->workqueue = create_singlethread_workqueue(hdw->name); in pvr2_hdw_create()
2626 INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll); in pvr2_hdw_create()
2629 hdw->unit_number,hdw->name); in pvr2_hdw_create()
2631 hdw->tuner_type = -1; in pvr2_hdw_create()
2632 hdw->flag_ok = !0; in pvr2_hdw_create()
2634 hdw->usb_intf = intf; in pvr2_hdw_create()
2635 hdw->usb_dev = usb_dev; in pvr2_hdw_create()
2637 usb_make_path(hdw->usb_dev, hdw->bus_info, sizeof(hdw->bus_info)); in pvr2_hdw_create()
2639 ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber; in pvr2_hdw_create()
2640 usb_set_interface(hdw->usb_dev,ifnum,0); in pvr2_hdw_create()
2642 mutex_init(&hdw->ctl_lock_mutex); in pvr2_hdw_create()
2643 mutex_init(&hdw->big_lock_mutex); in pvr2_hdw_create()
2645 return hdw; in pvr2_hdw_create()
2647 if (hdw) { in pvr2_hdw_create()
2648 del_timer_sync(&hdw->quiescent_timer); in pvr2_hdw_create()
2649 del_timer_sync(&hdw->decoder_stabilization_timer); in pvr2_hdw_create()
2650 del_timer_sync(&hdw->encoder_run_timer); in pvr2_hdw_create()
2651 del_timer_sync(&hdw->encoder_wait_timer); in pvr2_hdw_create()
2652 if (hdw->workqueue) { in pvr2_hdw_create()
2653 flush_workqueue(hdw->workqueue); in pvr2_hdw_create()
2654 destroy_workqueue(hdw->workqueue); in pvr2_hdw_create()
2655 hdw->workqueue = NULL; in pvr2_hdw_create()
2657 usb_free_urb(hdw->ctl_read_urb); in pvr2_hdw_create()
2658 usb_free_urb(hdw->ctl_write_urb); in pvr2_hdw_create()
2659 kfree(hdw->ctl_read_buffer); in pvr2_hdw_create()
2660 kfree(hdw->ctl_write_buffer); in pvr2_hdw_create()
2661 kfree(hdw->controls); in pvr2_hdw_create()
2662 kfree(hdw->mpeg_ctrl_info); in pvr2_hdw_create()
2663 kfree(hdw); in pvr2_hdw_create()
2671 static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw) in pvr2_hdw_remove_usb_stuff() argument
2673 if (hdw->flag_disconnected) return; in pvr2_hdw_remove_usb_stuff()
2674 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw); in pvr2_hdw_remove_usb_stuff()
2675 if (hdw->ctl_read_urb) { in pvr2_hdw_remove_usb_stuff()
2676 usb_kill_urb(hdw->ctl_read_urb); in pvr2_hdw_remove_usb_stuff()
2677 usb_free_urb(hdw->ctl_read_urb); in pvr2_hdw_remove_usb_stuff()
2678 hdw->ctl_read_urb = NULL; in pvr2_hdw_remove_usb_stuff()
2680 if (hdw->ctl_write_urb) { in pvr2_hdw_remove_usb_stuff()
2681 usb_kill_urb(hdw->ctl_write_urb); in pvr2_hdw_remove_usb_stuff()
2682 usb_free_urb(hdw->ctl_write_urb); in pvr2_hdw_remove_usb_stuff()
2683 hdw->ctl_write_urb = NULL; in pvr2_hdw_remove_usb_stuff()
2685 if (hdw->ctl_read_buffer) { in pvr2_hdw_remove_usb_stuff()
2686 kfree(hdw->ctl_read_buffer); in pvr2_hdw_remove_usb_stuff()
2687 hdw->ctl_read_buffer = NULL; in pvr2_hdw_remove_usb_stuff()
2689 if (hdw->ctl_write_buffer) { in pvr2_hdw_remove_usb_stuff()
2690 kfree(hdw->ctl_write_buffer); in pvr2_hdw_remove_usb_stuff()
2691 hdw->ctl_write_buffer = NULL; in pvr2_hdw_remove_usb_stuff()
2693 hdw->flag_disconnected = !0; in pvr2_hdw_remove_usb_stuff()
2697 v4l2_device_disconnect(&hdw->v4l2_dev); in pvr2_hdw_remove_usb_stuff()
2698 hdw->usb_dev = NULL; in pvr2_hdw_remove_usb_stuff()
2699 hdw->usb_intf = NULL; in pvr2_hdw_remove_usb_stuff()
2700 pvr2_hdw_render_useless(hdw); in pvr2_hdw_remove_usb_stuff()
2703 void pvr2_hdw_set_v4l2_dev(struct pvr2_hdw *hdw, struct video_device *vdev) in pvr2_hdw_set_v4l2_dev() argument
2705 vdev->v4l2_dev = &hdw->v4l2_dev; in pvr2_hdw_set_v4l2_dev()
2709 void pvr2_hdw_destroy(struct pvr2_hdw *hdw) in pvr2_hdw_destroy() argument
2711 if (!hdw) return; in pvr2_hdw_destroy()
2712 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw); in pvr2_hdw_destroy()
2713 if (hdw->workqueue) { in pvr2_hdw_destroy()
2714 flush_workqueue(hdw->workqueue); in pvr2_hdw_destroy()
2715 destroy_workqueue(hdw->workqueue); in pvr2_hdw_destroy()
2716 hdw->workqueue = NULL; in pvr2_hdw_destroy()
2718 del_timer_sync(&hdw->quiescent_timer); in pvr2_hdw_destroy()
2719 del_timer_sync(&hdw->decoder_stabilization_timer); in pvr2_hdw_destroy()
2720 del_timer_sync(&hdw->encoder_run_timer); in pvr2_hdw_destroy()
2721 del_timer_sync(&hdw->encoder_wait_timer); in pvr2_hdw_destroy()
2722 if (hdw->fw_buffer) { in pvr2_hdw_destroy()
2723 kfree(hdw->fw_buffer); in pvr2_hdw_destroy()
2724 hdw->fw_buffer = NULL; in pvr2_hdw_destroy()
2726 if (hdw->vid_stream) { in pvr2_hdw_destroy()
2727 pvr2_stream_destroy(hdw->vid_stream); in pvr2_hdw_destroy()
2728 hdw->vid_stream = NULL; in pvr2_hdw_destroy()
2730 pvr2_i2c_core_done(hdw); in pvr2_hdw_destroy()
2731 v4l2_device_unregister(&hdw->v4l2_dev); in pvr2_hdw_destroy()
2732 pvr2_hdw_remove_usb_stuff(hdw); in pvr2_hdw_destroy()
2734 if ((hdw->unit_number >= 0) && in pvr2_hdw_destroy()
2735 (hdw->unit_number < PVR_NUM) && in pvr2_hdw_destroy()
2736 (unit_pointers[hdw->unit_number] == hdw)) { in pvr2_hdw_destroy()
2737 unit_pointers[hdw->unit_number] = NULL; in pvr2_hdw_destroy()
2740 kfree(hdw->controls); in pvr2_hdw_destroy()
2741 kfree(hdw->mpeg_ctrl_info); in pvr2_hdw_destroy()
2742 kfree(hdw); in pvr2_hdw_destroy()
2746 int pvr2_hdw_dev_ok(struct pvr2_hdw *hdw) in pvr2_hdw_dev_ok() argument
2748 return (hdw && hdw->flag_ok); in pvr2_hdw_dev_ok()
2753 void pvr2_hdw_disconnect(struct pvr2_hdw *hdw) in pvr2_hdw_disconnect() argument
2755 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_disconnect(hdw=%p)",hdw); in pvr2_hdw_disconnect()
2756 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_disconnect()
2757 LOCK_TAKE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2758 pvr2_hdw_remove_usb_stuff(hdw); in pvr2_hdw_disconnect()
2759 LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_disconnect()
2760 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_disconnect()
2765 unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw) in pvr2_hdw_get_ctrl_count() argument
2767 return hdw->control_cnt; in pvr2_hdw_get_ctrl_count()
2772 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_by_index() argument
2775 if (idx >= hdw->control_cnt) return NULL; in pvr2_hdw_get_ctrl_by_index()
2776 return hdw->controls + idx; in pvr2_hdw_get_ctrl_by_index()
2781 struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_by_id() argument
2789 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_by_id()
2790 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_by_id()
2799 struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id) in pvr2_hdw_get_ctrl_v4l() argument
2806 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_v4l()
2807 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_v4l()
2817 struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw, in pvr2_hdw_get_ctrl_nextv4l() argument
2826 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_get_ctrl_nextv4l()
2827 cptr = hdw->controls + idx; in pvr2_hdw_get_ctrl_nextv4l()
2851 static void pvr2_subdev_set_control(struct pvr2_hdw *hdw, int id, in pvr2_subdev_set_control() argument
2859 v4l2_device_call_all(&hdw->v4l2_dev, 0, core, s_ctrl, &ctrl); in pvr2_subdev_set_control()
2862 #define PVR2_SUBDEV_SET_CONTROL(hdw, id, lab) \ argument
2863 if ((hdw)->lab##_dirty || (hdw)->force_dirty) { \
2864 pvr2_subdev_set_control(hdw, id, #lab, (hdw)->lab##_val); \
2867 static v4l2_std_id pvr2_hdw_get_detected_std(struct pvr2_hdw *hdw) in pvr2_hdw_get_detected_std() argument
2870 std = (v4l2_std_id)hdw->std_mask_avail; in pvr2_hdw_get_detected_std()
2871 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_hdw_get_detected_std()
2878 static void pvr2_subdev_update(struct pvr2_hdw *hdw) in pvr2_subdev_update() argument
2886 if (hdw->tuner_updated || hdw->force_dirty) { in pvr2_subdev_update()
2889 hdw->tuner_type); in pvr2_subdev_update()
2890 if (((int)(hdw->tuner_type)) >= 0) { in pvr2_subdev_update()
2893 setup.type = hdw->tuner_type; in pvr2_subdev_update()
2895 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2900 if (hdw->input_dirty || hdw->std_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2902 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_subdev_update()
2903 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2907 vs = hdw->std_mask_cur; in pvr2_subdev_update()
2908 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2910 pvr2_hdw_cx25840_vbi_hack(hdw); in pvr2_subdev_update()
2912 hdw->tuner_signal_stale = !0; in pvr2_subdev_update()
2913 hdw->cropcap_stale = !0; in pvr2_subdev_update()
2916 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_BRIGHTNESS, brightness); in pvr2_subdev_update()
2917 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_CONTRAST, contrast); in pvr2_subdev_update()
2918 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_SATURATION, saturation); in pvr2_subdev_update()
2919 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_HUE, hue); in pvr2_subdev_update()
2920 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_MUTE, mute); in pvr2_subdev_update()
2921 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_VOLUME, volume); in pvr2_subdev_update()
2922 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BALANCE, balance); in pvr2_subdev_update()
2923 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_BASS, bass); in pvr2_subdev_update()
2924 PVR2_SUBDEV_SET_CONTROL(hdw, V4L2_CID_AUDIO_TREBLE, treble); in pvr2_subdev_update()
2926 if (hdw->input_dirty || hdw->audiomode_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2929 vt.type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? in pvr2_subdev_update()
2931 vt.audmode = hdw->audiomode_val; in pvr2_subdev_update()
2932 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt); in pvr2_subdev_update()
2935 if (hdw->freqDirty || hdw->force_dirty) { in pvr2_subdev_update()
2938 fv = pvr2_hdw_get_cur_freq(hdw); in pvr2_subdev_update()
2940 if (hdw->tuner_signal_stale) pvr2_hdw_status_poll(hdw); in pvr2_subdev_update()
2942 if (hdw->tuner_signal_info.capability & V4L2_TUNER_CAP_LOW) { in pvr2_subdev_update()
2950 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_subdev_update()
2956 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, in pvr2_subdev_update()
2960 if (hdw->res_hor_dirty || hdw->res_ver_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2963 fmt.width = hdw->res_hor_val; in pvr2_subdev_update()
2964 fmt.height = hdw->res_ver_val; in pvr2_subdev_update()
2968 v4l2_device_call_all(&hdw->v4l2_dev, 0, video, s_mbus_fmt, &fmt); in pvr2_subdev_update()
2971 if (hdw->srate_dirty || hdw->force_dirty) { in pvr2_subdev_update()
2974 hdw->srate_val); in pvr2_subdev_update()
2975 switch (hdw->srate_val) { in pvr2_subdev_update()
2987 v4l2_device_call_all(&hdw->v4l2_dev, 0, in pvr2_subdev_update()
2994 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) { in pvr2_subdev_update()
2999 (*fp)(hdw, sd); in pvr2_subdev_update()
3002 if (hdw->tuner_signal_stale || hdw->cropcap_stale) { in pvr2_subdev_update()
3003 pvr2_hdw_status_poll(hdw); in pvr2_subdev_update()
3011 static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw) in pvr2_hdw_commit_setup() argument
3016 int commit_flag = hdw->force_dirty; in pvr2_hdw_commit_setup()
3020 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_commit_setup()
3021 cptr = hdw->controls + idx; in pvr2_hdw_commit_setup()
3047 hdw->state_pipeline_config = 0; in pvr2_hdw_commit_setup()
3048 trace_stbit("state_pipeline_config",hdw->state_pipeline_config); in pvr2_hdw_commit_setup()
3049 pvr2_hdw_state_sched(hdw); in pvr2_hdw_commit_setup()
3060 static int pvr2_hdw_commit_execute(struct pvr2_hdw *hdw) in pvr2_hdw_commit_execute() argument
3066 if (hdw->input_dirty && hdw->state_pathway_ok && in pvr2_hdw_commit_execute()
3067 (((hdw->input_val == PVR2_CVAL_INPUT_DTV) ? in pvr2_hdw_commit_execute()
3069 hdw->pathway_state)) { in pvr2_hdw_commit_execute()
3071 hdw->state_pathway_ok = 0; in pvr2_hdw_commit_execute()
3072 trace_stbit("state_pathway_ok", hdw->state_pathway_ok); in pvr2_hdw_commit_execute()
3074 if (!hdw->state_pathway_ok) { in pvr2_hdw_commit_execute()
3081 if (hdw->std_dirty) { in pvr2_hdw_commit_execute()
3084 if (hdw->std_mask_cur & V4L2_STD_525_60) { in pvr2_hdw_commit_execute()
3093 if (nvres != hdw->res_ver_val) { in pvr2_hdw_commit_execute()
3094 hdw->res_ver_val = nvres; in pvr2_hdw_commit_execute()
3095 hdw->res_ver_dirty = !0; in pvr2_hdw_commit_execute()
3099 if (gop_size != hdw->enc_ctl_state.video_gop_size) { in pvr2_hdw_commit_execute()
3108 cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs, in pvr2_hdw_commit_execute()
3119 if (hdw->res_hor_dirty && hdw->cropw_val < hdw->res_hor_val) { in pvr2_hdw_commit_execute()
3120 hdw->cropw_val = hdw->res_hor_val; in pvr2_hdw_commit_execute()
3121 hdw->cropw_dirty = !0; in pvr2_hdw_commit_execute()
3122 } else if (hdw->cropw_dirty) { in pvr2_hdw_commit_execute()
3123 hdw->res_hor_dirty = !0; /* must rescale */ in pvr2_hdw_commit_execute()
3124 hdw->res_hor_val = min(720, hdw->cropw_val); in pvr2_hdw_commit_execute()
3126 if (hdw->res_ver_dirty && hdw->croph_val < hdw->res_ver_val) { in pvr2_hdw_commit_execute()
3127 hdw->croph_val = hdw->res_ver_val; in pvr2_hdw_commit_execute()
3128 hdw->croph_dirty = !0; in pvr2_hdw_commit_execute()
3129 } else if (hdw->croph_dirty) { in pvr2_hdw_commit_execute()
3130 int nvres = hdw->std_mask_cur & V4L2_STD_525_60 ? 480 : 576; in pvr2_hdw_commit_execute()
3131 hdw->res_ver_dirty = !0; in pvr2_hdw_commit_execute()
3132 hdw->res_ver_val = min(nvres, hdw->croph_val); in pvr2_hdw_commit_execute()
3140 (hdw->std_dirty || in pvr2_hdw_commit_execute()
3141 hdw->enc_unsafe_stale || in pvr2_hdw_commit_execute()
3142 hdw->srate_dirty || in pvr2_hdw_commit_execute()
3143 hdw->res_ver_dirty || in pvr2_hdw_commit_execute()
3144 hdw->res_hor_dirty || in pvr2_hdw_commit_execute()
3145 hdw->cropw_dirty || in pvr2_hdw_commit_execute()
3146 hdw->croph_dirty || in pvr2_hdw_commit_execute()
3147 hdw->input_dirty || in pvr2_hdw_commit_execute()
3148 (hdw->active_stream_type != hdw->desired_stream_type)); in pvr2_hdw_commit_execute()
3149 if (disruptive_change && !hdw->state_pipeline_idle) { in pvr2_hdw_commit_execute()
3153 hdw->state_pipeline_pause = !0; in pvr2_hdw_commit_execute()
3157 if (hdw->srate_dirty) { in pvr2_hdw_commit_execute()
3169 c1.value = hdw->srate_val; in pvr2_hdw_commit_execute()
3170 cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs,VIDIOC_S_EXT_CTRLS); in pvr2_hdw_commit_execute()
3173 if (hdw->active_stream_type != hdw->desired_stream_type) { in pvr2_hdw_commit_execute()
3175 hdw->active_stream_type = hdw->desired_stream_type; in pvr2_hdw_commit_execute()
3178 if (hdw->hdw_desc->signal_routing_scheme == in pvr2_hdw_commit_execute()
3182 pvr2_hdw_gpio_get_out(hdw,&b); in pvr2_hdw_commit_execute()
3183 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_commit_execute()
3185 pvr2_hdw_gpio_chg_out(hdw,(1 << 11),~0); in pvr2_hdw_commit_execute()
3188 pvr2_hdw_gpio_chg_out(hdw,(1 << 11),0); in pvr2_hdw_commit_execute()
3193 pvr2_subdev_update(hdw); in pvr2_hdw_commit_execute()
3195 hdw->tuner_updated = 0; in pvr2_hdw_commit_execute()
3196 hdw->force_dirty = 0; in pvr2_hdw_commit_execute()
3197 for (idx = 0; idx < hdw->control_cnt; idx++) { in pvr2_hdw_commit_execute()
3198 cptr = hdw->controls + idx; in pvr2_hdw_commit_execute()
3203 if ((hdw->pathway_state == PVR2_PATHWAY_ANALOG) && in pvr2_hdw_commit_execute()
3204 hdw->state_encoder_run) { in pvr2_hdw_commit_execute()
3208 if (pvr2_encoder_adjust(hdw) < 0) return !0; in pvr2_hdw_commit_execute()
3211 hdw->state_pipeline_config = !0; in pvr2_hdw_commit_execute()
3215 trace_stbit("state_pipeline_config",hdw->state_pipeline_config); in pvr2_hdw_commit_execute()
3220 int pvr2_hdw_commit_ctl(struct pvr2_hdw *hdw) in pvr2_hdw_commit_ctl() argument
3223 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3224 fl = pvr2_hdw_commit_setup(hdw); in pvr2_hdw_commit_ctl()
3225 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_commit_ctl()
3227 return pvr2_hdw_wait(hdw,0); in pvr2_hdw_commit_ctl()
3234 struct pvr2_hdw *hdw = container_of(work,struct pvr2_hdw,workpoll); in pvr2_hdw_worker_poll() local
3235 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_worker_poll()
3236 fl = pvr2_hdw_state_eval(hdw); in pvr2_hdw_worker_poll()
3237 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_worker_poll()
3238 if (fl && hdw->state_func) { in pvr2_hdw_worker_poll()
3239 hdw->state_func(hdw->state_data); in pvr2_hdw_worker_poll()
3244 static int pvr2_hdw_wait(struct pvr2_hdw *hdw,int state) in pvr2_hdw_wait() argument
3247 hdw->state_wait_data, in pvr2_hdw_wait()
3248 (hdw->state_stale == 0) && in pvr2_hdw_wait()
3249 (!state || (hdw->master_state != state))); in pvr2_hdw_wait()
3254 const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw) in pvr2_hdw_get_driver_name() argument
3256 return hdw->name; in pvr2_hdw_get_driver_name()
3260 const char *pvr2_hdw_get_desc(struct pvr2_hdw *hdw) in pvr2_hdw_get_desc() argument
3262 return hdw->hdw_desc->description; in pvr2_hdw_get_desc()
3266 const char *pvr2_hdw_get_type(struct pvr2_hdw *hdw) in pvr2_hdw_get_type() argument
3268 return hdw->hdw_desc->shortname; in pvr2_hdw_get_type()
3272 int pvr2_hdw_is_hsm(struct pvr2_hdw *hdw) in pvr2_hdw_is_hsm() argument
3275 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_is_hsm()
3276 hdw->cmd_buffer[0] = FX2CMD_GET_USB_SPEED; in pvr2_hdw_is_hsm()
3277 result = pvr2_send_request(hdw, in pvr2_hdw_is_hsm()
3278 hdw->cmd_buffer,1, in pvr2_hdw_is_hsm()
3279 hdw->cmd_buffer,1); in pvr2_hdw_is_hsm()
3281 result = (hdw->cmd_buffer[0] != 0); in pvr2_hdw_is_hsm()
3282 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_is_hsm()
3288 void pvr2_hdw_execute_tuner_poll(struct pvr2_hdw *hdw) in pvr2_hdw_execute_tuner_poll() argument
3290 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_execute_tuner_poll()
3291 pvr2_hdw_status_poll(hdw); in pvr2_hdw_execute_tuner_poll()
3292 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_execute_tuner_poll()
3296 static int pvr2_hdw_check_cropcap(struct pvr2_hdw *hdw) in pvr2_hdw_check_cropcap() argument
3298 if (!hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3301 pvr2_hdw_status_poll(hdw); in pvr2_hdw_check_cropcap()
3302 if (hdw->cropcap_stale) { in pvr2_hdw_check_cropcap()
3310 int pvr2_hdw_get_cropcap(struct pvr2_hdw *hdw, struct v4l2_cropcap *pp) in pvr2_hdw_get_cropcap() argument
3313 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_get_cropcap()
3314 stat = pvr2_hdw_check_cropcap(hdw); in pvr2_hdw_get_cropcap()
3316 memcpy(pp, &hdw->cropcap_info, sizeof(hdw->cropcap_info)); in pvr2_hdw_get_cropcap()
3318 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_get_cropcap()
3324 int pvr2_hdw_get_tuner_status(struct pvr2_hdw *hdw,struct v4l2_tuner *vtp) in pvr2_hdw_get_tuner_status() argument
3326 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_get_tuner_status()
3327 if (hdw->tuner_signal_stale) { in pvr2_hdw_get_tuner_status()
3328 pvr2_hdw_status_poll(hdw); in pvr2_hdw_get_tuner_status()
3330 memcpy(vtp,&hdw->tuner_signal_info,sizeof(struct v4l2_tuner)); in pvr2_hdw_get_tuner_status()
3331 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_get_tuner_status()
3343 void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw) in pvr2_hdw_trigger_module_log() argument
3345 int nr = pvr2_hdw_get_unit_number(hdw); in pvr2_hdw_trigger_module_log()
3346 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_trigger_module_log()
3348 v4l2_device_call_all(&hdw->v4l2_dev, 0, core, log_status); in pvr2_hdw_trigger_module_log()
3350 cx2341x_log_status(&hdw->enc_ctl_state, "pvrusb2"); in pvr2_hdw_trigger_module_log()
3351 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_trigger_module_log()
3353 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_trigger_module_log()
3360 static u8 *pvr2_full_eeprom_fetch(struct pvr2_hdw *hdw) in pvr2_full_eeprom_fetch() argument
3380 hdw->eeprom_addr); in pvr2_full_eeprom_fetch()
3381 addr = hdw->eeprom_addr; in pvr2_full_eeprom_fetch()
3420 if ((ret = i2c_transfer(&hdw->i2c_adap, in pvr2_full_eeprom_fetch()
3432 void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, in pvr2_hdw_cpufw_set_enabled() argument
3439 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_cpufw_set_enabled()
3440 if ((hdw->fw_buffer == NULL) == !enable_flag) break; in pvr2_hdw_cpufw_set_enabled()
3445 kfree(hdw->fw_buffer); in pvr2_hdw_cpufw_set_enabled()
3446 hdw->fw_buffer = NULL; in pvr2_hdw_cpufw_set_enabled()
3447 hdw->fw_size = 0; in pvr2_hdw_cpufw_set_enabled()
3448 if (hdw->fw_cpu_flag) { in pvr2_hdw_cpufw_set_enabled()
3451 pvr2_hdw_cpureset_assert(hdw,0); in pvr2_hdw_cpufw_set_enabled()
3456 hdw->fw_cpu_flag = (mode != 2); in pvr2_hdw_cpufw_set_enabled()
3457 if (hdw->fw_cpu_flag) { in pvr2_hdw_cpufw_set_enabled()
3458 hdw->fw_size = (mode == 1) ? 0x4000 : 0x2000; in pvr2_hdw_cpufw_set_enabled()
3461 " (size=%u)", hdw->fw_size); in pvr2_hdw_cpufw_set_enabled()
3462 hdw->fw_buffer = kzalloc(hdw->fw_size,GFP_KERNEL); in pvr2_hdw_cpufw_set_enabled()
3463 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_set_enabled()
3464 hdw->fw_size = 0; in pvr2_hdw_cpufw_set_enabled()
3469 pvr2_hdw_cpureset_assert(hdw,1); in pvr2_hdw_cpufw_set_enabled()
3476 pipe = usb_rcvctrlpipe(hdw->usb_dev, 0); in pvr2_hdw_cpufw_set_enabled()
3477 for(address = 0; address < hdw->fw_size; in pvr2_hdw_cpufw_set_enabled()
3479 ret = usb_control_msg(hdw->usb_dev,pipe, in pvr2_hdw_cpufw_set_enabled()
3482 hdw->fw_buffer+address, in pvr2_hdw_cpufw_set_enabled()
3492 hdw->fw_buffer = pvr2_full_eeprom_fetch(hdw); in pvr2_hdw_cpufw_set_enabled()
3493 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_set_enabled()
3498 hdw->fw_size = EEPROM_SIZE; in pvr2_hdw_cpufw_set_enabled()
3503 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_cpufw_set_enabled()
3508 int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw) in pvr2_hdw_cpufw_get_enabled() argument
3510 return hdw->fw_buffer != NULL; in pvr2_hdw_cpufw_get_enabled()
3514 int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs, in pvr2_hdw_cpufw_get() argument
3518 LOCK_TAKE(hdw->big_lock); do { in pvr2_hdw_cpufw_get()
3522 if (!hdw->fw_buffer) { in pvr2_hdw_cpufw_get()
3527 if (offs >= hdw->fw_size) { in pvr2_hdw_cpufw_get()
3535 if (offs + cnt > hdw->fw_size) cnt = hdw->fw_size - offs; in pvr2_hdw_cpufw_get()
3537 memcpy(buf,hdw->fw_buffer+offs,cnt); in pvr2_hdw_cpufw_get()
3543 } while (0); LOCK_GIVE(hdw->big_lock); in pvr2_hdw_cpufw_get()
3549 int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw, in pvr2_hdw_v4l_get_minor_number() argument
3553 case pvr2_v4l_type_video: return hdw->v4l_minor_number_video; in pvr2_hdw_v4l_get_minor_number()
3554 case pvr2_v4l_type_vbi: return hdw->v4l_minor_number_vbi; in pvr2_hdw_v4l_get_minor_number()
3555 case pvr2_v4l_type_radio: return hdw->v4l_minor_number_radio; in pvr2_hdw_v4l_get_minor_number()
3562 void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw, in pvr2_hdw_v4l_store_minor_number() argument
3566 case pvr2_v4l_type_video: hdw->v4l_minor_number_video = v;break; in pvr2_hdw_v4l_store_minor_number()
3567 case pvr2_v4l_type_vbi: hdw->v4l_minor_number_vbi = v;break; in pvr2_hdw_v4l_store_minor_number()
3568 case pvr2_v4l_type_radio: hdw->v4l_minor_number_radio = v;break; in pvr2_hdw_v4l_store_minor_number()
3576 struct pvr2_hdw *hdw = urb->context; in pvr2_ctl_write_complete() local
3577 hdw->ctl_write_pend_flag = 0; in pvr2_ctl_write_complete()
3578 if (hdw->ctl_read_pend_flag) return; in pvr2_ctl_write_complete()
3579 complete(&hdw->ctl_done); in pvr2_ctl_write_complete()
3585 struct pvr2_hdw *hdw = urb->context; in pvr2_ctl_read_complete() local
3586 hdw->ctl_read_pend_flag = 0; in pvr2_ctl_read_complete()
3587 if (hdw->ctl_write_pend_flag) return; in pvr2_ctl_read_complete()
3588 complete(&hdw->ctl_done); in pvr2_ctl_read_complete()
3594 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_ctl_timeout() local
3595 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { in pvr2_ctl_timeout()
3596 hdw->ctl_timeout_flag = !0; in pvr2_ctl_timeout()
3597 if (hdw->ctl_write_pend_flag) in pvr2_ctl_timeout()
3598 usb_unlink_urb(hdw->ctl_write_urb); in pvr2_ctl_timeout()
3599 if (hdw->ctl_read_pend_flag) in pvr2_ctl_timeout()
3600 usb_unlink_urb(hdw->ctl_read_urb); in pvr2_ctl_timeout()
3609 static int pvr2_send_request_ex(struct pvr2_hdw *hdw, in pvr2_send_request_ex() argument
3617 if (!hdw->ctl_lock_held) { in pvr2_send_request_ex()
3623 if (!hdw->flag_ok && !probe_fl) { in pvr2_send_request_ex()
3629 if (!(hdw->ctl_read_urb && hdw->ctl_write_urb)) { in pvr2_send_request_ex()
3665 hdw->cmd_debug_state = 1; in pvr2_send_request_ex()
3667 hdw->cmd_debug_code = ((unsigned char *)write_data)[0]; in pvr2_send_request_ex()
3669 hdw->cmd_debug_code = 0; in pvr2_send_request_ex()
3671 hdw->cmd_debug_write_len = write_len; in pvr2_send_request_ex()
3672 hdw->cmd_debug_read_len = read_len; in pvr2_send_request_ex()
3675 init_completion(&hdw->ctl_done); in pvr2_send_request_ex()
3676 hdw->ctl_timeout_flag = 0; in pvr2_send_request_ex()
3677 hdw->ctl_write_pend_flag = 0; in pvr2_send_request_ex()
3678 hdw->ctl_read_pend_flag = 0; in pvr2_send_request_ex()
3679 setup_timer(&timer, pvr2_ctl_timeout, (unsigned long)hdw); in pvr2_send_request_ex()
3683 hdw->cmd_debug_state = 2; in pvr2_send_request_ex()
3686 hdw->ctl_write_buffer[idx] = in pvr2_send_request_ex()
3690 usb_fill_bulk_urb(hdw->ctl_write_urb, in pvr2_send_request_ex()
3691 hdw->usb_dev, in pvr2_send_request_ex()
3692 usb_sndbulkpipe(hdw->usb_dev, in pvr2_send_request_ex()
3694 hdw->ctl_write_buffer, in pvr2_send_request_ex()
3697 hdw); in pvr2_send_request_ex()
3698 hdw->ctl_write_urb->actual_length = 0; in pvr2_send_request_ex()
3699 hdw->ctl_write_pend_flag = !0; in pvr2_send_request_ex()
3700 status = usb_submit_urb(hdw->ctl_write_urb,GFP_KERNEL); in pvr2_send_request_ex()
3705 hdw->ctl_write_pend_flag = 0; in pvr2_send_request_ex()
3711 hdw->cmd_debug_state = 3; in pvr2_send_request_ex()
3712 memset(hdw->ctl_read_buffer,0x43,read_len); in pvr2_send_request_ex()
3714 usb_fill_bulk_urb(hdw->ctl_read_urb, in pvr2_send_request_ex()
3715 hdw->usb_dev, in pvr2_send_request_ex()
3716 usb_rcvbulkpipe(hdw->usb_dev, in pvr2_send_request_ex()
3718 hdw->ctl_read_buffer, in pvr2_send_request_ex()
3721 hdw); in pvr2_send_request_ex()
3722 hdw->ctl_read_urb->actual_length = 0; in pvr2_send_request_ex()
3723 hdw->ctl_read_pend_flag = !0; in pvr2_send_request_ex()
3724 status = usb_submit_urb(hdw->ctl_read_urb,GFP_KERNEL); in pvr2_send_request_ex()
3729 hdw->ctl_read_pend_flag = 0; in pvr2_send_request_ex()
3738 hdw->cmd_debug_state = 4; in pvr2_send_request_ex()
3739 while (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { in pvr2_send_request_ex()
3740 wait_for_completion(&hdw->ctl_done); in pvr2_send_request_ex()
3742 hdw->cmd_debug_state = 5; in pvr2_send_request_ex()
3747 hdw->cmd_debug_state = 6; in pvr2_send_request_ex()
3750 if (hdw->ctl_timeout_flag) { in pvr2_send_request_ex()
3761 if ((hdw->ctl_write_urb->status != 0) && in pvr2_send_request_ex()
3762 (hdw->ctl_write_urb->status != -ENOENT) && in pvr2_send_request_ex()
3763 (hdw->ctl_write_urb->status != -ESHUTDOWN) && in pvr2_send_request_ex()
3764 (hdw->ctl_write_urb->status != -ECONNRESET)) { in pvr2_send_request_ex()
3767 status = hdw->ctl_write_urb->status; in pvr2_send_request_ex()
3776 if (hdw->ctl_write_urb->actual_length < write_len) { in pvr2_send_request_ex()
3784 hdw->ctl_write_urb->actual_length); in pvr2_send_request_ex()
3791 if ((hdw->ctl_read_urb->status != 0) && in pvr2_send_request_ex()
3792 (hdw->ctl_read_urb->status != -ENOENT) && in pvr2_send_request_ex()
3793 (hdw->ctl_read_urb->status != -ESHUTDOWN) && in pvr2_send_request_ex()
3794 (hdw->ctl_read_urb->status != -ECONNRESET)) { in pvr2_send_request_ex()
3797 status = hdw->ctl_read_urb->status; in pvr2_send_request_ex()
3806 if (hdw->ctl_read_urb->actual_length < read_len) { in pvr2_send_request_ex()
3814 hdw->ctl_read_urb->actual_length); in pvr2_send_request_ex()
3821 hdw->ctl_read_buffer[idx]; in pvr2_send_request_ex()
3827 hdw->cmd_debug_state = 0; in pvr2_send_request_ex()
3829 pvr2_hdw_render_useless(hdw); in pvr2_send_request_ex()
3835 int pvr2_send_request(struct pvr2_hdw *hdw, in pvr2_send_request() argument
3839 return pvr2_send_request_ex(hdw,HZ*4,0, in pvr2_send_request()
3845 static int pvr2_issue_simple_cmd(struct pvr2_hdw *hdw,u32 cmdcode) in pvr2_issue_simple_cmd() argument
3850 LOCK_TAKE(hdw->ctl_lock); in pvr2_issue_simple_cmd()
3851 hdw->cmd_buffer[0] = cmdcode & 0xffu; in pvr2_issue_simple_cmd()
3856 hdw->cmd_buffer[1] = (cmdcode >> 16) & 0xffu; in pvr2_issue_simple_cmd()
3858 hdw->cmd_buffer[2] = (cmdcode >> 24) & 0xffu; in pvr2_issue_simple_cmd()
3884 " (%u",hdw->cmd_buffer[1]); in pvr2_issue_simple_cmd()
3889 ",%u",hdw->cmd_buffer[2]); in pvr2_issue_simple_cmd()
3899 ret = pvr2_send_request(hdw,hdw->cmd_buffer,cnt,NULL,0); in pvr2_issue_simple_cmd()
3900 LOCK_GIVE(hdw->ctl_lock); in pvr2_issue_simple_cmd()
3905 int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data) in pvr2_write_register() argument
3909 LOCK_TAKE(hdw->ctl_lock); in pvr2_write_register()
3911 hdw->cmd_buffer[0] = FX2CMD_REG_WRITE; /* write register prefix */ in pvr2_write_register()
3912 PVR2_DECOMPOSE_LE(hdw->cmd_buffer,1,data); in pvr2_write_register()
3913 hdw->cmd_buffer[5] = 0; in pvr2_write_register()
3914 hdw->cmd_buffer[6] = (reg >> 8) & 0xff; in pvr2_write_register()
3915 hdw->cmd_buffer[7] = reg & 0xff; in pvr2_write_register()
3918 ret = pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 0); in pvr2_write_register()
3920 LOCK_GIVE(hdw->ctl_lock); in pvr2_write_register()
3926 static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data) in pvr2_read_register() argument
3930 LOCK_TAKE(hdw->ctl_lock); in pvr2_read_register()
3932 hdw->cmd_buffer[0] = FX2CMD_REG_READ; /* read register prefix */ in pvr2_read_register()
3933 hdw->cmd_buffer[1] = 0; in pvr2_read_register()
3934 hdw->cmd_buffer[2] = 0; in pvr2_read_register()
3935 hdw->cmd_buffer[3] = 0; in pvr2_read_register()
3936 hdw->cmd_buffer[4] = 0; in pvr2_read_register()
3937 hdw->cmd_buffer[5] = 0; in pvr2_read_register()
3938 hdw->cmd_buffer[6] = (reg >> 8) & 0xff; in pvr2_read_register()
3939 hdw->cmd_buffer[7] = reg & 0xff; in pvr2_read_register()
3941 ret |= pvr2_send_request(hdw, hdw->cmd_buffer, 8, hdw->cmd_buffer, 4); in pvr2_read_register()
3942 *data = PVR2_COMPOSE_LE(hdw->cmd_buffer,0); in pvr2_read_register()
3944 LOCK_GIVE(hdw->ctl_lock); in pvr2_read_register()
3950 void pvr2_hdw_render_useless(struct pvr2_hdw *hdw) in pvr2_hdw_render_useless() argument
3952 if (!hdw->flag_ok) return; in pvr2_hdw_render_useless()
3955 if (hdw->vid_stream) { in pvr2_hdw_render_useless()
3956 pvr2_stream_setup(hdw->vid_stream,NULL,0,0); in pvr2_hdw_render_useless()
3958 hdw->flag_ok = 0; in pvr2_hdw_render_useless()
3959 trace_stbit("flag_ok",hdw->flag_ok); in pvr2_hdw_render_useless()
3960 pvr2_hdw_state_sched(hdw); in pvr2_hdw_render_useless()
3964 void pvr2_hdw_device_reset(struct pvr2_hdw *hdw) in pvr2_hdw_device_reset() argument
3968 ret = usb_lock_device_for_reset(hdw->usb_dev,NULL); in pvr2_hdw_device_reset()
3970 ret = usb_reset_device(hdw->usb_dev); in pvr2_hdw_device_reset()
3971 usb_unlock_device(hdw->usb_dev); in pvr2_hdw_device_reset()
3986 void pvr2_hdw_cpureset_assert(struct pvr2_hdw *hdw,int val) in pvr2_hdw_cpureset_assert() argument
3992 if (!hdw->usb_dev) return; in pvr2_hdw_cpureset_assert()
4008 pipe = usb_sndctrlpipe(hdw->usb_dev, 0); in pvr2_hdw_cpureset_assert()
4009 ret = usb_control_msg(hdw->usb_dev,pipe,0xa0,0x40,0xe600,0,da,1,HZ); in pvr2_hdw_cpureset_assert()
4013 pvr2_hdw_render_useless(hdw); in pvr2_hdw_cpureset_assert()
4020 int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_deep_reset() argument
4022 return pvr2_issue_simple_cmd(hdw,FX2CMD_DEEP_RESET); in pvr2_hdw_cmd_deep_reset()
4026 int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_powerup() argument
4028 return pvr2_issue_simple_cmd(hdw,FX2CMD_POWER_ON); in pvr2_hdw_cmd_powerup()
4033 int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw) in pvr2_hdw_cmd_decoder_reset() argument
4037 if (hdw->decoder_client_id) { in pvr2_hdw_cmd_decoder_reset()
4038 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, in pvr2_hdw_cmd_decoder_reset()
4040 pvr2_hdw_cx25840_vbi_hack(hdw); in pvr2_hdw_cmd_decoder_reset()
4049 static int pvr2_hdw_cmd_hcw_demod_reset(struct pvr2_hdw *hdw, int onoff) in pvr2_hdw_cmd_hcw_demod_reset() argument
4051 hdw->flag_ok = !0; in pvr2_hdw_cmd_hcw_demod_reset()
4052 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_hcw_demod_reset()
4059 static int pvr2_hdw_cmd_onair_fe_power_ctrl(struct pvr2_hdw *hdw, int onoff) in pvr2_hdw_cmd_onair_fe_power_ctrl() argument
4061 hdw->flag_ok = !0; in pvr2_hdw_cmd_onair_fe_power_ctrl()
4062 return pvr2_issue_simple_cmd(hdw,(onoff ? in pvr2_hdw_cmd_onair_fe_power_ctrl()
4068 static int pvr2_hdw_cmd_onair_digital_path_ctrl(struct pvr2_hdw *hdw, in pvr2_hdw_cmd_onair_digital_path_ctrl() argument
4071 return pvr2_issue_simple_cmd(hdw,(onoff ? in pvr2_hdw_cmd_onair_digital_path_ctrl()
4077 static void pvr2_hdw_cmd_modeswitch(struct pvr2_hdw *hdw,int digitalFl) in pvr2_hdw_cmd_modeswitch() argument
4083 if (cmode == hdw->pathway_state) { in pvr2_hdw_cmd_modeswitch()
4088 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_modeswitch()
4090 pvr2_hdw_cmd_hcw_demod_reset(hdw,digitalFl); in pvr2_hdw_cmd_modeswitch()
4096 pvr2_hdw_cmd_decoder_reset(hdw); in pvr2_hdw_cmd_modeswitch()
4103 pvr2_hdw_cmd_onair_fe_power_ctrl(hdw,digitalFl); in pvr2_hdw_cmd_modeswitch()
4108 pvr2_hdw_untrip_unlocked(hdw); in pvr2_hdw_cmd_modeswitch()
4109 hdw->pathway_state = cmode; in pvr2_hdw_cmd_modeswitch()
4113 static void pvr2_led_ctrl_hauppauge(struct pvr2_hdw *hdw, int onoff) in pvr2_led_ctrl_hauppauge() argument
4122 pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000481); in pvr2_led_ctrl_hauppauge()
4124 pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000401); in pvr2_led_ctrl_hauppauge()
4126 pvr2_hdw_gpio_chg_out(hdw, 0xffffffff, 0x00000000); in pvr2_led_ctrl_hauppauge()
4138 static void pvr2_led_ctrl(struct pvr2_hdw *hdw,int onoff) in pvr2_led_ctrl() argument
4143 if ((!onoff) == (!hdw->led_on)) return; in pvr2_led_ctrl()
4145 hdw->led_on = onoff != 0; in pvr2_led_ctrl()
4147 scheme_id = hdw->hdw_desc->led_scheme; in pvr2_led_ctrl()
4154 if (fp) (*fp)(hdw,onoff); in pvr2_led_ctrl()
4159 static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl) in pvr2_hdw_cmd_usbstream() argument
4165 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in pvr2_hdw_cmd_usbstream()
4166 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4173 if (hdw->pathway_state != PVR2_PATHWAY_DIGITAL) { in pvr2_hdw_cmd_usbstream()
4182 switch (hdw->hdw_desc->digital_control_scheme) { in pvr2_hdw_cmd_usbstream()
4184 return pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4189 ret = pvr2_issue_simple_cmd(hdw, in pvr2_hdw_cmd_usbstream()
4194 return pvr2_hdw_cmd_onair_digital_path_ctrl(hdw,runFl); in pvr2_hdw_cmd_usbstream()
4202 static int state_eval_pathway_ok(struct pvr2_hdw *hdw) in state_eval_pathway_ok() argument
4204 if (hdw->state_pathway_ok) { in state_eval_pathway_ok()
4208 if (!hdw->state_pipeline_idle) { in state_eval_pathway_ok()
4212 pvr2_hdw_cmd_modeswitch(hdw,hdw->input_val == PVR2_CVAL_INPUT_DTV); in state_eval_pathway_ok()
4213 hdw->state_pathway_ok = !0; in state_eval_pathway_ok()
4214 trace_stbit("state_pathway_ok",hdw->state_pathway_ok); in state_eval_pathway_ok()
4220 static int state_eval_encoder_ok(struct pvr2_hdw *hdw) in state_eval_encoder_ok() argument
4222 if (hdw->state_encoder_ok) return 0; in state_eval_encoder_ok()
4223 if (hdw->flag_tripped) return 0; in state_eval_encoder_ok()
4224 if (hdw->state_encoder_run) return 0; in state_eval_encoder_ok()
4225 if (hdw->state_encoder_config) return 0; in state_eval_encoder_ok()
4226 if (hdw->state_decoder_run) return 0; in state_eval_encoder_ok()
4227 if (hdw->state_usbstream_run) return 0; in state_eval_encoder_ok()
4228 if (hdw->pathway_state == PVR2_PATHWAY_DIGITAL) { in state_eval_encoder_ok()
4229 if (!hdw->hdw_desc->flag_digital_requires_cx23416) return 0; in state_eval_encoder_ok()
4230 } else if (hdw->pathway_state != PVR2_PATHWAY_ANALOG) { in state_eval_encoder_ok()
4234 if (pvr2_upload_firmware2(hdw) < 0) { in state_eval_encoder_ok()
4235 hdw->flag_tripped = !0; in state_eval_encoder_ok()
4236 trace_stbit("flag_tripped",hdw->flag_tripped); in state_eval_encoder_ok()
4239 hdw->state_encoder_ok = !0; in state_eval_encoder_ok()
4240 trace_stbit("state_encoder_ok",hdw->state_encoder_ok); in state_eval_encoder_ok()
4246 static int state_eval_encoder_config(struct pvr2_hdw *hdw) in state_eval_encoder_config() argument
4248 if (hdw->state_encoder_config) { in state_eval_encoder_config()
4249 if (hdw->state_encoder_ok) { in state_eval_encoder_config()
4250 if (hdw->state_pipeline_req && in state_eval_encoder_config()
4251 !hdw->state_pipeline_pause) return 0; in state_eval_encoder_config()
4253 hdw->state_encoder_config = 0; in state_eval_encoder_config()
4254 hdw->state_encoder_waitok = 0; in state_eval_encoder_config()
4255 trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); in state_eval_encoder_config()
4257 del_timer_sync(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4259 if (!hdw->state_pathway_ok || in state_eval_encoder_config()
4260 (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || in state_eval_encoder_config()
4261 !hdw->state_encoder_ok || in state_eval_encoder_config()
4262 !hdw->state_pipeline_idle || in state_eval_encoder_config()
4263 hdw->state_pipeline_pause || in state_eval_encoder_config()
4264 !hdw->state_pipeline_req || in state_eval_encoder_config()
4265 !hdw->state_pipeline_config) { in state_eval_encoder_config()
4269 if (timer_pending(&hdw->encoder_wait_timer)) { in state_eval_encoder_config()
4270 del_timer_sync(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4272 if (hdw->state_encoder_waitok) { in state_eval_encoder_config()
4276 hdw->state_encoder_waitok = 0; in state_eval_encoder_config()
4278 hdw->state_encoder_waitok); in state_eval_encoder_config()
4283 if (!hdw->state_encoder_waitok) { in state_eval_encoder_config()
4284 if (!timer_pending(&hdw->encoder_wait_timer)) { in state_eval_encoder_config()
4291 if (!hdw->state_encoder_waitok) { in state_eval_encoder_config()
4292 hdw->encoder_wait_timer.expires = in state_eval_encoder_config()
4295 add_timer(&hdw->encoder_wait_timer); in state_eval_encoder_config()
4303 pvr2_encoder_configure(hdw); in state_eval_encoder_config()
4304 if (hdw->state_encoder_ok) hdw->state_encoder_config = !0; in state_eval_encoder_config()
4306 trace_stbit("state_encoder_config",hdw->state_encoder_config); in state_eval_encoder_config()
4312 static int state_check_disable_encoder_run(struct pvr2_hdw *hdw) in state_check_disable_encoder_run() argument
4314 if (!hdw->state_encoder_ok) { in state_check_disable_encoder_run()
4318 if (!hdw->state_pathway_ok) { in state_check_disable_encoder_run()
4324 switch (hdw->pathway_state) { in state_check_disable_encoder_run()
4326 if (!hdw->state_decoder_run) { in state_check_disable_encoder_run()
4334 if (hdw->state_encoder_runok) { in state_check_disable_encoder_run()
4357 static int state_check_enable_encoder_run(struct pvr2_hdw *hdw) in state_check_enable_encoder_run() argument
4359 if (!hdw->state_encoder_ok) { in state_check_enable_encoder_run()
4363 if (!hdw->state_pathway_ok) { in state_check_enable_encoder_run()
4369 switch (hdw->pathway_state) { in state_check_enable_encoder_run()
4371 if (hdw->state_decoder_run && hdw->state_decoder_ready) { in state_check_enable_encoder_run()
4378 if ((hdw->hdw_desc->digital_control_scheme == in state_check_enable_encoder_run()
4380 !hdw->state_encoder_runok) { in state_check_enable_encoder_run()
4403 static int state_eval_encoder_run(struct pvr2_hdw *hdw) in state_eval_encoder_run() argument
4405 if (hdw->state_encoder_run) { in state_eval_encoder_run()
4406 if (!state_check_disable_encoder_run(hdw)) return 0; in state_eval_encoder_run()
4407 if (hdw->state_encoder_ok) { in state_eval_encoder_run()
4408 del_timer_sync(&hdw->encoder_run_timer); in state_eval_encoder_run()
4409 if (pvr2_encoder_stop(hdw) < 0) return !0; in state_eval_encoder_run()
4411 hdw->state_encoder_run = 0; in state_eval_encoder_run()
4413 if (!state_check_enable_encoder_run(hdw)) return 0; in state_eval_encoder_run()
4414 if (pvr2_encoder_start(hdw) < 0) return !0; in state_eval_encoder_run()
4415 hdw->state_encoder_run = !0; in state_eval_encoder_run()
4416 if (!hdw->state_encoder_runok) { in state_eval_encoder_run()
4417 hdw->encoder_run_timer.expires = jiffies + in state_eval_encoder_run()
4419 add_timer(&hdw->encoder_run_timer); in state_eval_encoder_run()
4422 trace_stbit("state_encoder_run",hdw->state_encoder_run); in state_eval_encoder_run()
4430 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_quiescent_timeout() local
4431 hdw->state_decoder_quiescent = !0; in pvr2_hdw_quiescent_timeout()
4432 trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); in pvr2_hdw_quiescent_timeout()
4433 hdw->state_stale = !0; in pvr2_hdw_quiescent_timeout()
4434 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_quiescent_timeout()
4441 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_decoder_stabilization_timeout() local
4442 hdw->state_decoder_ready = !0; in pvr2_hdw_decoder_stabilization_timeout()
4443 trace_stbit("state_decoder_ready", hdw->state_decoder_ready); in pvr2_hdw_decoder_stabilization_timeout()
4444 hdw->state_stale = !0; in pvr2_hdw_decoder_stabilization_timeout()
4445 queue_work(hdw->workqueue, &hdw->workpoll); in pvr2_hdw_decoder_stabilization_timeout()
4452 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_encoder_wait_timeout() local
4453 hdw->state_encoder_waitok = !0; in pvr2_hdw_encoder_wait_timeout()
4454 trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); in pvr2_hdw_encoder_wait_timeout()
4455 hdw->state_stale = !0; in pvr2_hdw_encoder_wait_timeout()
4456 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_encoder_wait_timeout()
4463 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; in pvr2_hdw_encoder_run_timeout() local
4464 if (!hdw->state_encoder_runok) { in pvr2_hdw_encoder_run_timeout()
4465 hdw->state_encoder_runok = !0; in pvr2_hdw_encoder_run_timeout()
4466 trace_stbit("state_encoder_runok",hdw->state_encoder_runok); in pvr2_hdw_encoder_run_timeout()
4467 hdw->state_stale = !0; in pvr2_hdw_encoder_run_timeout()
4468 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_encoder_run_timeout()
4474 static int state_eval_decoder_run(struct pvr2_hdw *hdw) in state_eval_decoder_run() argument
4476 if (hdw->state_decoder_run) { in state_eval_decoder_run()
4477 if (hdw->state_encoder_ok) { in state_eval_decoder_run()
4478 if (hdw->state_pipeline_req && in state_eval_decoder_run()
4479 !hdw->state_pipeline_pause && in state_eval_decoder_run()
4480 hdw->state_pathway_ok) return 0; in state_eval_decoder_run()
4482 if (!hdw->flag_decoder_missed) { in state_eval_decoder_run()
4483 pvr2_decoder_enable(hdw,0); in state_eval_decoder_run()
4485 hdw->state_decoder_quiescent = 0; in state_eval_decoder_run()
4486 hdw->state_decoder_run = 0; in state_eval_decoder_run()
4488 del_timer_sync(&hdw->quiescent_timer); in state_eval_decoder_run()
4492 del_timer_sync(&hdw->decoder_stabilization_timer); in state_eval_decoder_run()
4493 hdw->state_decoder_ready = 0; in state_eval_decoder_run()
4495 if (!hdw->state_decoder_quiescent) { in state_eval_decoder_run()
4496 if (!timer_pending(&hdw->quiescent_timer)) { in state_eval_decoder_run()
4507 if (!hdw->state_decoder_quiescent) { in state_eval_decoder_run()
4508 hdw->quiescent_timer.expires = in state_eval_decoder_run()
4511 add_timer(&hdw->quiescent_timer); in state_eval_decoder_run()
4519 if (!hdw->state_pathway_ok || in state_eval_decoder_run()
4520 (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || in state_eval_decoder_run()
4521 !hdw->state_pipeline_req || in state_eval_decoder_run()
4522 hdw->state_pipeline_pause || in state_eval_decoder_run()
4523 !hdw->state_pipeline_config || in state_eval_decoder_run()
4524 !hdw->state_encoder_config || in state_eval_decoder_run()
4525 !hdw->state_encoder_ok) return 0; in state_eval_decoder_run()
4526 del_timer_sync(&hdw->quiescent_timer); in state_eval_decoder_run()
4527 if (hdw->flag_decoder_missed) return 0; in state_eval_decoder_run()
4528 if (pvr2_decoder_enable(hdw,!0) < 0) return 0; in state_eval_decoder_run()
4529 hdw->state_decoder_quiescent = 0; in state_eval_decoder_run()
4530 hdw->state_decoder_ready = 0; in state_eval_decoder_run()
4531 hdw->state_decoder_run = !0; in state_eval_decoder_run()
4532 if (hdw->decoder_client_id == PVR2_CLIENT_ID_SAA7115) { in state_eval_decoder_run()
4533 hdw->decoder_stabilization_timer.expires = in state_eval_decoder_run()
4536 add_timer(&hdw->decoder_stabilization_timer); in state_eval_decoder_run()
4538 hdw->state_decoder_ready = !0; in state_eval_decoder_run()
4541 trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); in state_eval_decoder_run()
4542 trace_stbit("state_decoder_run",hdw->state_decoder_run); in state_eval_decoder_run()
4543 trace_stbit("state_decoder_ready", hdw->state_decoder_ready); in state_eval_decoder_run()
4549 static int state_eval_usbstream_run(struct pvr2_hdw *hdw) in state_eval_usbstream_run() argument
4551 if (hdw->state_usbstream_run) { in state_eval_usbstream_run()
4553 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in state_eval_usbstream_run()
4554 fl = (hdw->state_encoder_ok && in state_eval_usbstream_run()
4555 hdw->state_encoder_run); in state_eval_usbstream_run()
4556 } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && in state_eval_usbstream_run()
4557 (hdw->hdw_desc->flag_digital_requires_cx23416)) { in state_eval_usbstream_run()
4558 fl = hdw->state_encoder_ok; in state_eval_usbstream_run()
4561 hdw->state_pipeline_req && in state_eval_usbstream_run()
4562 !hdw->state_pipeline_pause && in state_eval_usbstream_run()
4563 hdw->state_pathway_ok) { in state_eval_usbstream_run()
4566 pvr2_hdw_cmd_usbstream(hdw,0); in state_eval_usbstream_run()
4567 hdw->state_usbstream_run = 0; in state_eval_usbstream_run()
4569 if (!hdw->state_pipeline_req || in state_eval_usbstream_run()
4570 hdw->state_pipeline_pause || in state_eval_usbstream_run()
4571 !hdw->state_pathway_ok) return 0; in state_eval_usbstream_run()
4572 if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { in state_eval_usbstream_run()
4573 if (!hdw->state_encoder_ok || in state_eval_usbstream_run()
4574 !hdw->state_encoder_run) return 0; in state_eval_usbstream_run()
4575 } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && in state_eval_usbstream_run()
4576 (hdw->hdw_desc->flag_digital_requires_cx23416)) { in state_eval_usbstream_run()
4577 if (!hdw->state_encoder_ok) return 0; in state_eval_usbstream_run()
4578 if (hdw->state_encoder_run) return 0; in state_eval_usbstream_run()
4579 if (hdw->hdw_desc->digital_control_scheme == in state_eval_usbstream_run()
4586 if (!hdw->state_encoder_runok) return 0; in state_eval_usbstream_run()
4589 if (pvr2_hdw_cmd_usbstream(hdw,!0) < 0) return 0; in state_eval_usbstream_run()
4590 hdw->state_usbstream_run = !0; in state_eval_usbstream_run()
4592 trace_stbit("state_usbstream_run",hdw->state_usbstream_run); in state_eval_usbstream_run()
4598 static int state_eval_pipeline_config(struct pvr2_hdw *hdw) in state_eval_pipeline_config() argument
4600 if (hdw->state_pipeline_config || in state_eval_pipeline_config()
4601 hdw->state_pipeline_pause) return 0; in state_eval_pipeline_config()
4602 pvr2_hdw_commit_execute(hdw); in state_eval_pipeline_config()
4610 static int state_update_pipeline_state(struct pvr2_hdw *hdw) in state_update_pipeline_state() argument
4615 st = !(hdw->state_encoder_run || in state_update_pipeline_state()
4616 hdw->state_decoder_run || in state_update_pipeline_state()
4617 hdw->state_usbstream_run || in state_update_pipeline_state()
4618 (!hdw->state_decoder_quiescent)); in state_update_pipeline_state()
4619 if (!st != !hdw->state_pipeline_idle) { in state_update_pipeline_state()
4620 hdw->state_pipeline_idle = st; in state_update_pipeline_state()
4623 if (hdw->state_pipeline_idle && hdw->state_pipeline_pause) { in state_update_pipeline_state()
4624 hdw->state_pipeline_pause = 0; in state_update_pipeline_state()
4646 static int pvr2_hdw_state_update(struct pvr2_hdw *hdw) in pvr2_hdw_state_update() argument
4652 if (!hdw->state_stale) return 0; in pvr2_hdw_state_update()
4653 if ((hdw->fw1_state != FW1_STATE_OK) || in pvr2_hdw_state_update()
4654 !hdw->flag_ok) { in pvr2_hdw_state_update()
4655 hdw->state_stale = 0; in pvr2_hdw_state_update()
4667 state_update_pipeline_state(hdw); in pvr2_hdw_state_update()
4669 for (i = 0; (i<ARRAY_SIZE(eval_funcs)) && hdw->flag_ok; i++) { in pvr2_hdw_state_update()
4670 if ((*eval_funcs[i])(hdw)) { in pvr2_hdw_state_update()
4673 state_update_pipeline_state(hdw); in pvr2_hdw_state_update()
4676 } while (check_flag && hdw->flag_ok); in pvr2_hdw_state_update()
4677 hdw->state_stale = 0; in pvr2_hdw_state_update()
4678 trace_stbit("state_stale",hdw->state_stale); in pvr2_hdw_state_update()
4711 static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, in pvr2_hdw_report_unlocked() argument
4719 (hdw->flag_ok ? " <ok>" : " <fail>"), in pvr2_hdw_report_unlocked()
4720 (hdw->flag_init_ok ? " <init>" : " <uninitialized>"), in pvr2_hdw_report_unlocked()
4721 (hdw->flag_disconnected ? " <disconnected>" : in pvr2_hdw_report_unlocked()
4723 (hdw->flag_tripped ? " <tripped>" : ""), in pvr2_hdw_report_unlocked()
4724 (hdw->flag_decoder_missed ? " <no decoder>" : ""), in pvr2_hdw_report_unlocked()
4725 pvr2_pathway_state_name(hdw->pathway_state)); in pvr2_hdw_report_unlocked()
4731 (hdw->state_pipeline_idle ? " <idle>" : ""), in pvr2_hdw_report_unlocked()
4732 (hdw->state_pipeline_config ? in pvr2_hdw_report_unlocked()
4734 (hdw->state_pipeline_req ? " <req>" : ""), in pvr2_hdw_report_unlocked()
4735 (hdw->state_pipeline_pause ? " <pause>" : "")); in pvr2_hdw_report_unlocked()
4740 (hdw->state_decoder_run ? in pvr2_hdw_report_unlocked()
4741 (hdw->state_decoder_ready ? in pvr2_hdw_report_unlocked()
4743 (hdw->state_decoder_quiescent ? in pvr2_hdw_report_unlocked()
4745 (hdw->state_decoder_quiescent ? in pvr2_hdw_report_unlocked()
4747 (hdw->state_encoder_ok ? in pvr2_hdw_report_unlocked()
4749 (hdw->state_encoder_run ? in pvr2_hdw_report_unlocked()
4750 (hdw->state_encoder_runok ? in pvr2_hdw_report_unlocked()
4753 (hdw->state_encoder_runok ? in pvr2_hdw_report_unlocked()
4756 (hdw->state_encoder_config ? in pvr2_hdw_report_unlocked()
4758 (hdw->state_encoder_waitok ? in pvr2_hdw_report_unlocked()
4760 (hdw->state_usbstream_run ? in pvr2_hdw_report_unlocked()
4762 (hdw->state_pathway_ok ? in pvr2_hdw_report_unlocked()
4768 pvr2_get_state_name(hdw->master_state)); in pvr2_hdw_report_unlocked()
4777 tcnt += print_input_mask(hdw->input_avail_mask, in pvr2_hdw_report_unlocked()
4780 if (hdw->input_avail_mask != hdw->input_allowed_mask) { in pvr2_hdw_report_unlocked()
4785 tcnt += print_input_mask(hdw->input_allowed_mask, in pvr2_hdw_report_unlocked()
4793 if (!hdw->vid_stream) break; in pvr2_hdw_report_unlocked()
4794 pvr2_stream_get_stats(hdw->vid_stream, in pvr2_hdw_report_unlocked()
4810 unsigned int id = hdw->ir_scheme_active; in pvr2_hdw_report_unlocked()
4824 static unsigned int pvr2_hdw_report_clients(struct pvr2_hdw *hdw, in pvr2_hdw_report_clients() argument
4836 v4l2_device_for_each_subdev(sd, &hdw->v4l2_dev) { in pvr2_hdw_report_clients()
4864 unsigned int pvr2_hdw_state_report(struct pvr2_hdw *hdw, in pvr2_hdw_state_report() argument
4869 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_state_report()
4871 ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,acnt); in pvr2_hdw_state_report()
4878 ccnt = pvr2_hdw_report_clients(hdw, buf, acnt); in pvr2_hdw_state_report()
4880 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_state_report()
4885 static void pvr2_hdw_state_log_state(struct pvr2_hdw *hdw) in pvr2_hdw_state_log_state() argument
4892 ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,sizeof(buf)); in pvr2_hdw_state_log_state()
4894 printk(KERN_INFO "%s %.*s\n",hdw->name,ccnt,buf); in pvr2_hdw_state_log_state()
4896 ccnt = pvr2_hdw_report_clients(hdw, buf, sizeof(buf)); in pvr2_hdw_state_log_state()
4903 printk(KERN_INFO "%s %.*s\n", hdw->name, lcnt, buf + ucnt); in pvr2_hdw_state_log_state()
4911 static int pvr2_hdw_state_eval(struct pvr2_hdw *hdw) in pvr2_hdw_state_eval() argument
4921 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_state_eval()
4925 state_updated = pvr2_hdw_state_update(hdw); in pvr2_hdw_state_eval()
4927 analog_mode = (hdw->pathway_state != PVR2_PATHWAY_DIGITAL); in pvr2_hdw_state_eval()
4930 if (!hdw->flag_ok) { in pvr2_hdw_state_eval()
4932 } else if (hdw->fw1_state != FW1_STATE_OK) { in pvr2_hdw_state_eval()
4935 hdw->hdw_desc->flag_digital_requires_cx23416) && in pvr2_hdw_state_eval()
4936 !hdw->state_encoder_ok) { in pvr2_hdw_state_eval()
4938 } else if (hdw->flag_tripped || in pvr2_hdw_state_eval()
4939 (analog_mode && hdw->flag_decoder_missed)) { in pvr2_hdw_state_eval()
4941 } else if (hdw->state_usbstream_run && in pvr2_hdw_state_eval()
4943 (hdw->state_encoder_run && hdw->state_decoder_run))) { in pvr2_hdw_state_eval()
4948 if (hdw->master_state != st) { in pvr2_hdw_state_eval()
4951 pvr2_get_state_name(hdw->master_state), in pvr2_hdw_state_eval()
4953 pvr2_led_ctrl(hdw,st == PVR2_STATE_RUN); in pvr2_hdw_state_eval()
4954 hdw->master_state = st; in pvr2_hdw_state_eval()
4960 wake_up(&hdw->state_wait_data); in pvr2_hdw_state_eval()
4964 pvr2_hdw_state_log_state(hdw); in pvr2_hdw_state_eval()
4974 static void pvr2_hdw_state_sched(struct pvr2_hdw *hdw) in pvr2_hdw_state_sched() argument
4976 if (hdw->state_stale) return; in pvr2_hdw_state_sched()
4977 hdw->state_stale = !0; in pvr2_hdw_state_sched()
4978 trace_stbit("state_stale",hdw->state_stale); in pvr2_hdw_state_sched()
4979 queue_work(hdw->workqueue,&hdw->workpoll); in pvr2_hdw_state_sched()
4983 int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_dir() argument
4985 return pvr2_read_register(hdw,PVR2_GPIO_DIR,dp); in pvr2_hdw_gpio_get_dir()
4989 int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_out() argument
4991 return pvr2_read_register(hdw,PVR2_GPIO_OUT,dp); in pvr2_hdw_gpio_get_out()
4995 int pvr2_hdw_gpio_get_in(struct pvr2_hdw *hdw,u32 *dp) in pvr2_hdw_gpio_get_in() argument
4997 return pvr2_read_register(hdw,PVR2_GPIO_IN,dp); in pvr2_hdw_gpio_get_in()
5001 int pvr2_hdw_gpio_chg_dir(struct pvr2_hdw *hdw,u32 msk,u32 val) in pvr2_hdw_gpio_chg_dir() argument
5006 ret = pvr2_read_register(hdw,PVR2_GPIO_DIR,&cval); in pvr2_hdw_gpio_chg_dir()
5018 return pvr2_write_register(hdw,PVR2_GPIO_DIR,nval); in pvr2_hdw_gpio_chg_dir()
5022 int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val) in pvr2_hdw_gpio_chg_out() argument
5027 ret = pvr2_read_register(hdw,PVR2_GPIO_OUT,&cval); in pvr2_hdw_gpio_chg_out()
5038 return pvr2_write_register(hdw,PVR2_GPIO_OUT,nval); in pvr2_hdw_gpio_chg_out()
5042 void pvr2_hdw_status_poll(struct pvr2_hdw *hdw) in pvr2_hdw_status_poll() argument
5044 struct v4l2_tuner *vtp = &hdw->tuner_signal_info; in pvr2_hdw_status_poll()
5046 vtp->type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? in pvr2_hdw_status_poll()
5048 hdw->tuner_signal_stale = 0; in pvr2_hdw_status_poll()
5053 v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, g_tuner, vtp); in pvr2_hdw_status_poll()
5063 hdw->cropcap_stale = 0; in pvr2_hdw_status_poll()
5067 unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *hdw) in pvr2_hdw_get_input_available() argument
5069 return hdw->input_avail_mask; in pvr2_hdw_get_input_available()
5073 unsigned int pvr2_hdw_get_input_allowed(struct pvr2_hdw *hdw) in pvr2_hdw_get_input_allowed() argument
5075 return hdw->input_allowed_mask; in pvr2_hdw_get_input_allowed()
5079 static int pvr2_hdw_set_input(struct pvr2_hdw *hdw,int v) in pvr2_hdw_set_input() argument
5081 if (hdw->input_val != v) { in pvr2_hdw_set_input()
5082 hdw->input_val = v; in pvr2_hdw_set_input()
5083 hdw->input_dirty = !0; in pvr2_hdw_set_input()
5089 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { in pvr2_hdw_set_input()
5090 hdw->freqSelector = 0; in pvr2_hdw_set_input()
5091 hdw->freqDirty = !0; in pvr2_hdw_set_input()
5092 } else if ((hdw->input_val == PVR2_CVAL_INPUT_TV) || in pvr2_hdw_set_input()
5093 (hdw->input_val == PVR2_CVAL_INPUT_DTV)) { in pvr2_hdw_set_input()
5094 hdw->freqSelector = 1; in pvr2_hdw_set_input()
5095 hdw->freqDirty = !0; in pvr2_hdw_set_input()
5101 int pvr2_hdw_set_input_allowed(struct pvr2_hdw *hdw, in pvr2_hdw_set_input_allowed() argument
5107 LOCK_TAKE(hdw->big_lock); in pvr2_hdw_set_input_allowed()
5109 nv = hdw->input_allowed_mask & ~change_mask; in pvr2_hdw_set_input_allowed()
5111 nv &= hdw->input_avail_mask; in pvr2_hdw_set_input_allowed()
5117 hdw->input_allowed_mask = nv; in pvr2_hdw_set_input_allowed()
5118 if ((1 << hdw->input_val) & hdw->input_allowed_mask) { in pvr2_hdw_set_input_allowed()
5125 if (!hdw->input_allowed_mask) { in pvr2_hdw_set_input_allowed()
5129 m = hdw->input_allowed_mask; in pvr2_hdw_set_input_allowed()
5132 pvr2_hdw_set_input(hdw,idx); in pvr2_hdw_set_input_allowed()
5136 LOCK_GIVE(hdw->big_lock); in pvr2_hdw_set_input_allowed()
5142 static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) in pvr2_hdw_get_eeprom_addr() argument
5145 LOCK_TAKE(hdw->ctl_lock); do { in pvr2_hdw_get_eeprom_addr()
5146 hdw->cmd_buffer[0] = FX2CMD_GET_EEPROM_ADDR; in pvr2_hdw_get_eeprom_addr()
5147 result = pvr2_send_request(hdw, in pvr2_hdw_get_eeprom_addr()
5148 hdw->cmd_buffer,1, in pvr2_hdw_get_eeprom_addr()
5149 hdw->cmd_buffer,1); in pvr2_hdw_get_eeprom_addr()
5151 result = hdw->cmd_buffer[0]; in pvr2_hdw_get_eeprom_addr()
5152 } while(0); LOCK_GIVE(hdw->ctl_lock); in pvr2_hdw_get_eeprom_addr()