Lines Matching refs:btv

190 	struct bttv *btv = video_get_drvdata(vfd);  in show_card()  local
191 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); in show_card()
683 int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit) in check_alloc_btres_lock() argument
696 if (btv->resources & xbits) { in check_alloc_btres_lock()
702 && 0 == (btv->resources & VIDEO_RESOURCES)) { in check_alloc_btres_lock()
704 __s32 top = btv->crop[!!fh->do_crop].rect.top; in check_alloc_btres_lock()
706 if (btv->vbi_end > top) in check_alloc_btres_lock()
711 btv->crop_start = top; in check_alloc_btres_lock()
715 if (end > btv->crop_start) in check_alloc_btres_lock()
719 btv->vbi_end = end; in check_alloc_btres_lock()
724 btv->resources |= bit; in check_alloc_btres_lock()
738 int locked_btres(struct bttv *btv, int bit) in locked_btres() argument
740 return (btv->resources & bit); in locked_btres()
745 disclaim_vbi_lines(struct bttv *btv) in disclaim_vbi_lines() argument
747 btv->vbi_end = 0; in disclaim_vbi_lines()
752 disclaim_video_lines(struct bttv *btv) in disclaim_video_lines() argument
757 tvnorm = &bttv_tvnorms[btv->tvnorm]; in disclaim_video_lines()
758 btv->crop_start = tvnorm->cropcap.bounds.top in disclaim_video_lines()
773 void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits) in free_btres_lock() argument
780 btv->resources &= ~bits; in free_btres_lock()
782 bits = btv->resources; in free_btres_lock()
785 disclaim_video_lines(btv); in free_btres_lock()
788 disclaim_vbi_lines(btv); in free_btres_lock()
804 static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout) in set_pll_freq() argument
826 static void set_pll(struct bttv *btv) in set_pll() argument
830 if (!btv->pll.pll_crystal) in set_pll()
833 if (btv->pll.pll_ofreq == btv->pll.pll_current) { in set_pll()
834 dprintk("%d: PLL: no change required\n", btv->c.nr); in set_pll()
838 if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) { in set_pll()
840 if (btv->pll.pll_current == 0) in set_pll()
844 btv->c.nr, btv->pll.pll_ifreq); in set_pll()
847 btv->pll.pll_current = 0; in set_pll()
853 btv->c.nr, in set_pll()
854 btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
855 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
865 btv->pll.pll_current = btv->pll.pll_ofreq; in set_pll()
871 btv->pll.pll_current = -1; in set_pll()
878 static void bt848A_set_timing(struct bttv *btv) in bt848A_set_timing() argument
881 int table_idx = bttv_tvnorms[btv->tvnorm].sram; in bt848A_set_timing()
882 int fsc = bttv_tvnorms[btv->tvnorm].Fsc; in bt848A_set_timing()
884 if (btv->input == btv->dig) { in bt848A_set_timing()
886 btv->c.nr,table_idx); in bt848A_set_timing()
896 btv->pll.pll_ofreq = 27000000; in bt848A_set_timing()
898 set_pll(btv); in bt848A_set_timing()
902 btv->pll.pll_ofreq = fsc; in bt848A_set_timing()
903 set_pll(btv); in bt848A_set_timing()
910 static void bt848_bright(struct bttv *btv, int bright) in bt848_bright() argument
915 btv->bright = bright; in bt848_bright()
922 static void bt848_hue(struct bttv *btv, int hue) in bt848_hue() argument
926 btv->hue = hue; in bt848_hue()
933 static void bt848_contrast(struct bttv *btv, int cont) in bt848_contrast() argument
937 btv->contrast = cont; in bt848_contrast()
947 static void bt848_sat(struct bttv *btv, int color) in bt848_sat() argument
951 btv->saturation = color; in bt848_sat()
954 val_u = ((color * btv->opt_uv_ratio) / 50) >> 7; in bt848_sat()
955 val_v = (((color * (100 - btv->opt_uv_ratio) / 50) >>7)*180L)/254; in bt848_sat()
967 video_mux(struct bttv *btv, unsigned int input) in video_mux() argument
971 if (input >= bttv_tvcards[btv->c.type].video_inputs) in video_mux()
975 mask2 = bttv_tvcards[btv->c.type].gpiomask2; in video_mux()
979 if (input == btv->svhs) { in video_mux()
986 mux = bttv_muxsel(btv, input); in video_mux()
988 dprintk("%d: video mux: input=%d mux=%d\n", btv->c.nr, input, mux); in video_mux()
991 if(bttv_tvcards[btv->c.type].muxsel_hook) in video_mux()
992 bttv_tvcards[btv->c.type].muxsel_hook (btv, input); in video_mux()
1002 audio_mux_gpio(struct bttv *btv, int input, int mute) in audio_mux_gpio() argument
1006 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, in audio_mux_gpio()
1007 bttv_tvcards[btv->c.type].gpiomask); in audio_mux_gpio()
1011 mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users) in audio_mux_gpio()
1012 && !btv->has_radio_tuner); in audio_mux_gpio()
1015 gpio_val = bttv_tvcards[btv->c.type].gpiomute; in audio_mux_gpio()
1017 gpio_val = bttv_tvcards[btv->c.type].gpiomux[input]; in audio_mux_gpio()
1019 switch (btv->c.type) { in audio_mux_gpio()
1022 gpio_val = bttv_tda9880_setnorm(btv, gpio_val); in audio_mux_gpio()
1026 gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val); in audio_mux_gpio()
1030 bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]); in audio_mux_gpio()
1034 audio_mute(struct bttv *btv, int mute) in audio_mute() argument
1038 audio_mux_gpio(btv, btv->audio_input, mute); in audio_mute()
1040 if (btv->sd_msp34xx) { in audio_mute()
1041 ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1045 if (btv->sd_tvaudio) { in audio_mute()
1046 ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1050 if (btv->sd_tda7432) { in audio_mute()
1051 ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1059 audio_input(struct bttv *btv, int input) in audio_input() argument
1061 audio_mux_gpio(btv, input, btv->mute); in audio_input()
1063 if (btv->sd_msp34xx) { in audio_input()
1074 if (btv->radio_uses_msp_demodulator) { in audio_input()
1099 if (btv->c.type == BTTV_BOARD_VOODOOTV_200) in audio_input()
1106 v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, in audio_input()
1109 if (btv->sd_tvaudio) { in audio_input()
1110 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, in audio_input()
1147 set_tvnorm(struct bttv *btv, unsigned int norm) in set_tvnorm() argument
1153 BUG_ON(btv->tvnorm >= BTTV_TVNORMS); in set_tvnorm()
1157 if (memcmp(&bttv_tvnorms[btv->tvnorm].cropcap, &tvnorm->cropcap, in set_tvnorm()
1159 bttv_crop_reset(&btv->crop[0], norm); in set_tvnorm()
1160 btv->crop[1] = btv->crop[0]; /* current = default */ in set_tvnorm()
1162 if (0 == (btv->resources & VIDEO_RESOURCES)) { in set_tvnorm()
1163 btv->crop_start = tvnorm->cropcap.bounds.top in set_tvnorm()
1168 btv->tvnorm = norm; in set_tvnorm()
1176 bt848A_set_timing(btv); in set_tvnorm()
1178 switch (btv->c.type) { in set_tvnorm()
1181 bttv_tda9880_setnorm(btv, gpio_read()); in set_tvnorm()
1185 bttv_call_all(btv, video, s_std, id); in set_tvnorm()
1192 set_input(struct bttv *btv, unsigned int input, unsigned int norm) in set_input() argument
1196 btv->input = input; in set_input()
1198 spin_lock_irqsave(&btv->s_lock,flags); in set_input()
1199 if (btv->curr.frame_irq) { in set_input()
1201 btv->new_input = input; in set_input()
1203 video_mux(btv,input); in set_input()
1205 spin_unlock_irqrestore(&btv->s_lock,flags); in set_input()
1207 video_mux(btv,input); in set_input()
1209 btv->audio_input = (btv->tuner_type != TUNER_ABSENT && input == 0) ? in set_input()
1211 audio_input(btv, btv->audio_input); in set_input()
1212 set_tvnorm(btv, norm); in set_input()
1215 static void init_irqreg(struct bttv *btv) in init_irqreg() argument
1220 if (bttv_tvcards[btv->c.type].no_video) { in init_irqreg()
1226 btwrite((btv->triton1) | in init_irqreg()
1227 (btv->gpioirq ? BT848_INT_GPINT : 0) | in init_irqreg()
1237 static void init_bt848(struct bttv *btv) in init_bt848() argument
1239 if (bttv_tvcards[btv->c.type].no_video) { in init_bt848()
1241 init_irqreg(btv); in init_bt848()
1261 v4l2_ctrl_handler_setup(&btv->ctrl_handler); in init_bt848()
1264 init_irqreg(btv); in init_bt848()
1267 static void bttv_reinit_bt848(struct bttv *btv) in bttv_reinit_bt848() argument
1272 pr_info("%d: reset, reinitialize\n", btv->c.nr); in bttv_reinit_bt848()
1273 spin_lock_irqsave(&btv->s_lock,flags); in bttv_reinit_bt848()
1274 btv->errors=0; in bttv_reinit_bt848()
1275 bttv_set_dma(btv,0); in bttv_reinit_bt848()
1276 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_reinit_bt848()
1278 init_bt848(btv); in bttv_reinit_bt848()
1279 btv->pll.pll_current = -1; in bttv_reinit_bt848()
1280 set_input(btv, btv->input, btv->tvnorm); in bttv_reinit_bt848()
1285 struct bttv *btv = container_of(c->handler, struct bttv, ctrl_handler); in bttv_s_ctrl() local
1290 bt848_bright(btv, c->val); in bttv_s_ctrl()
1293 bt848_hue(btv, c->val); in bttv_s_ctrl()
1296 bt848_contrast(btv, c->val); in bttv_s_ctrl()
1299 bt848_sat(btv, c->val); in bttv_s_ctrl()
1311 audio_mute(btv, c->val); in bttv_s_ctrl()
1312 btv->mute = c->val; in bttv_s_ctrl()
1315 btv->volume_gpio(btv, c->val); in bttv_s_ctrl()
1324 btv->opt_combfilter = c->val; in bttv_s_ctrl()
1336 btv->opt_automute = c->val; in bttv_s_ctrl()
1344 btv->opt_vcr_hack = c->val; in bttv_s_ctrl()
1353 btv->opt_uv_ratio = c->val; in bttv_s_ctrl()
1354 bt848_sat(btv, btv->saturation); in bttv_s_ctrl()
1485 void bttv_gpio_tracking(struct bttv *btv, char *comment) in bttv_gpio_tracking() argument
1491 btv->c.nr, outbits, data & outbits, data & ~outbits, comment); in bttv_gpio_tracking()
1494 static void bttv_field_count(struct bttv *btv) in bttv_field_count() argument
1498 if (btv->users) in bttv_field_count()
1507 btv->field_count = 0; in bttv_field_count()
1529 bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh, in bttv_switch_overlay() argument
1538 spin_lock_irqsave(&btv->s_lock,flags); in bttv_switch_overlay()
1539 old = btv->screen; in bttv_switch_overlay()
1540 btv->screen = new; in bttv_switch_overlay()
1541 btv->loop_irq |= 1; in bttv_switch_overlay()
1542 bttv_set_dma(btv, 0x03); in bttv_switch_overlay()
1543 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_switch_overlay()
1547 bttv_dma_free(&fh->cap,btv, old); in bttv_switch_overlay()
1551 free_btres_lock(btv,fh,RESOURCE_OVERLAY); in bttv_switch_overlay()
1559 static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv, in bttv_prepare_buffer() argument
1584 norm = btv->tvnorm; in bttv_prepare_buffer()
1588 if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) { in bttv_prepare_buffer()
1594 norm = btv->tvnorm; in bttv_prepare_buffer()
1595 c = btv->crop[!!fh->do_crop]; in bttv_prepare_buffer()
1643 if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf))) in bttv_prepare_buffer()
1648 if (0 != (rc = bttv_buffer_risc(btv,buf))) in bttv_prepare_buffer()
1655 bttv_dma_free(q,btv,buf); in bttv_prepare_buffer()
1679 return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt, in buffer_prepare()
1688 struct bttv *btv = fh->btv; in buffer_queue() local
1691 list_add_tail(&buf->vb.queue,&btv->capture); in buffer_queue()
1692 if (!btv->curr.frame_irq) { in buffer_queue()
1693 btv->loop_irq |= 1; in buffer_queue()
1694 bttv_set_dma(btv, 0x03); in buffer_queue()
1703 bttv_dma_free(q,fh->btv,buf); in buffer_release()
1713 static void radio_enable(struct bttv *btv) in radio_enable() argument
1716 if (!btv->has_radio_tuner) { in radio_enable()
1717 btv->has_radio_tuner = 1; in radio_enable()
1718 bttv_call_all(btv, tuner, s_radio); in radio_enable()
1719 btv->audio_input = TVAUDIO_INPUT_RADIO; in radio_enable()
1720 audio_input(btv, btv->audio_input); in radio_enable()
1727 struct bttv *btv = fh->btv; in bttv_s_std() local
1739 btv->std = id; in bttv_s_std()
1740 set_tvnorm(btv, i); in bttv_s_std()
1750 struct bttv *btv = fh->btv; in bttv_g_std() local
1752 *id = btv->std; in bttv_g_std()
1759 struct bttv *btv = fh->btv; in bttv_querystd() local
1772 struct bttv *btv = fh->btv; in bttv_enum_input() local
1775 if (i->index >= bttv_tvcards[btv->c.type].video_inputs) { in bttv_enum_input()
1783 if (btv->tuner_type != TUNER_ABSENT && i->index == 0) { in bttv_enum_input()
1787 } else if (i->index == btv->svhs) { in bttv_enum_input()
1793 if (i->index == btv->input) { in bttv_enum_input()
1811 struct bttv *btv = fh->btv; in bttv_g_input() local
1813 *i = btv->input; in bttv_g_input()
1821 struct bttv *btv = fh->btv; in bttv_s_input() local
1823 if (i >= bttv_tvcards[btv->c.type].video_inputs) in bttv_s_input()
1826 set_input(btv, i, btv->tvnorm); in bttv_s_input()
1834 struct bttv *btv = fh->btv; in bttv_s_tuner() local
1839 bttv_call_all(btv, tuner, s_tuner, t); in bttv_s_tuner()
1841 if (btv->audio_mode_gpio) { in bttv_s_tuner()
1844 btv->audio_mode_gpio(btv, &copy, 1); in bttv_s_tuner()
1853 struct bttv *btv = fh->btv; in bttv_g_frequency() local
1859 radio_enable(btv); in bttv_g_frequency()
1861 btv->radio_freq : btv->tv_freq; in bttv_g_frequency()
1866 static void bttv_set_frequency(struct bttv *btv, const struct v4l2_frequency *f) in bttv_set_frequency() argument
1870 bttv_call_all(btv, tuner, s_frequency, f); in bttv_set_frequency()
1873 bttv_call_all(btv, tuner, g_frequency, &new_freq); in bttv_set_frequency()
1875 radio_enable(btv); in bttv_set_frequency()
1876 btv->radio_freq = new_freq.frequency; in bttv_set_frequency()
1877 if (btv->has_tea575x) { in bttv_set_frequency()
1878 btv->tea.freq = btv->radio_freq; in bttv_set_frequency()
1879 snd_tea575x_set_freq(&btv->tea); in bttv_set_frequency()
1882 btv->tv_freq = new_freq.frequency; in bttv_set_frequency()
1890 struct bttv *btv = fh->btv; in bttv_s_frequency() local
1895 bttv_set_frequency(btv, f); in bttv_s_frequency()
1903 struct bttv *btv = fh->btv; in bttv_log_status() local
1905 v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name); in bttv_log_status()
1906 bttv_call_all(btv, core, log_status); in bttv_log_status()
1915 struct bttv *btv = fh->btv; in bttv_g_register() local
1929 struct bttv *btv = fh->btv; in bttv_s_register() local
1998 struct bttv *btv = fh->btv; in limit_scaled_size_lock() local
2013 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in limit_scaled_size_lock()
2016 c = &btv->crop[!!fh->do_crop]; in limit_scaled_size_lock()
2021 && !locked_btres(btv, VIDEO_RESOURCES)) { in limit_scaled_size_lock()
2034 if (btv->vbi_end > b->top) { in limit_scaled_size_lock()
2035 max_height -= btv->vbi_end - b->top; in limit_scaled_size_lock()
2042 if (btv->vbi_end > c->rect.top) in limit_scaled_size_lock()
2071 if (btv->vbi_end > c->rect.top) { in limit_scaled_size_lock()
2073 c->rect.top = btv->vbi_end; in limit_scaled_size_lock()
2131 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; in verify_window_lock()
2168 static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, in setup_window_lock() argument
2199 if (NULL != btv->fbuf.base) in setup_window_lock()
2200 n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, in setup_window_lock()
2228 btv->init.ov.w.width = win->w.width; in setup_window_lock()
2229 btv->init.ov.w.height = win->w.height; in setup_window_lock()
2230 btv->init.ov.field = win->field; in setup_window_lock()
2238 new->crop = btv->crop[!!fh->do_crop].rect; in setup_window_lock()
2239 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in setup_window_lock()
2240 retval = bttv_switch_overlay(btv,fh,new); in setup_window_lock()
2355 struct bttv *btv = fh->btv; in bttv_try_fmt_vid_cap() local
2382 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2425 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_cap() local
2459 btv->init.fmt = fmt; in bttv_s_fmt_vid_cap()
2460 btv->init.width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2461 btv->init.height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2470 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_overlay() local
2477 return setup_window_lock(fh, btv, &f->fmt.win, 1); in bttv_s_fmt_vid_overlay()
2485 struct bttv *btv = fh->btv; in bttv_querycap() local
2491 strlcpy(cap->card, btv->video_dev.name, sizeof(cap->card)); in bttv_querycap()
2493 "PCI:%s", pci_name(btv->c.pci)); in bttv_querycap()
2501 if (video_is_registered(&btv->vbi_dev)) in bttv_querycap()
2503 if (video_is_registered(&btv->radio_dev)) in bttv_querycap()
2510 if (btv->has_saa6588) in bttv_querycap()
2512 if (btv->tuner_type != TUNER_ABSENT) in bttv_querycap()
2529 if (btv->has_saa6588) in bttv_querycap()
2532 if (btv->has_tea575x) in bttv_querycap()
2593 struct bttv *btv = fh->btv; in bttv_g_fbuf() local
2595 *fb = btv->fbuf; in bttv_g_fbuf()
2606 struct bttv *btv = fh->btv; in bttv_overlay() local
2612 if (unlikely(!btv->fbuf.base)) { in bttv_overlay()
2616 dprintk("%d: overlay: !setup_ok\n", btv->c.nr); in bttv_overlay()
2623 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) in bttv_overlay()
2627 fh->ov.tvnorm = btv->tvnorm; in bttv_overlay()
2629 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_overlay()
2630 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_overlay()
2636 retval = bttv_switch_overlay(btv, fh, new); in bttv_overlay()
2644 struct bttv *btv = fh->btv; in bttv_s_fbuf() local
2675 btv->fbuf.base = fb->base; in bttv_s_fbuf()
2676 btv->fbuf.fmt.width = fb->fmt.width; in bttv_s_fbuf()
2677 btv->fbuf.fmt.height = fb->fmt.height; in bttv_s_fbuf()
2679 btv->fbuf.fmt.bytesperline = fb->fmt.bytesperline; in bttv_s_fbuf()
2681 btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fmt->depth/8; in bttv_s_fbuf()
2685 btv->init.ovfmt = fmt; in bttv_s_fbuf()
2691 btv->init.ov.w.width = fb->fmt.width; in bttv_s_fbuf()
2692 btv->init.ov.w.height = fb->fmt.height; in bttv_s_fbuf()
2701 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_s_fbuf()
2702 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_s_fbuf()
2703 retval = bttv_switch_overlay(btv, fh, new); in bttv_s_fbuf()
2726 struct bttv *btv = fh->btv; in bttv_qbuf() local
2729 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_qbuf()
2746 struct bttv *btv = fh->btv; in bttv_streamon() local
2749 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_streamon()
2759 struct bttv *btv = fh->btv; in bttv_streamoff() local
2767 free_btres_lock(btv, fh, res); in bttv_streamoff()
2775 struct bttv *btv = fh->btv; in bttv_g_parm() local
2780 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, in bttv_g_parm()
2790 struct bttv *btv = fh->btv; in bttv_g_tuner() local
2797 bttv_call_all(btv, tuner, g_tuner, t); in bttv_g_tuner()
2803 if (btv->audio_mode_gpio) in bttv_g_tuner()
2804 btv->audio_mode_gpio(btv, t, 0); in bttv_g_tuner()
2813 struct bttv *btv = fh->btv; in bttv_cropcap() local
2819 *cap = bttv_tvnorms[btv->tvnorm].cropcap; in bttv_cropcap()
2827 struct bttv *btv = fh->btv; in bttv_g_crop() local
2837 crop->c = btv->crop[!!fh->do_crop].rect; in bttv_g_crop()
2845 struct bttv *btv = fh->btv; in bttv_s_crop() local
2863 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { in bttv_s_crop()
2867 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_s_crop()
2873 b_top = max(b->top, btv->vbi_end); in bttv_s_crop()
2895 btv->crop[1] = c; in bttv_s_crop()
2901 btv->init.width = c.min_scaled_width; in bttv_s_crop()
2904 btv->init.width = c.max_scaled_width; in bttv_s_crop()
2909 btv->init.height = c.min_scaled_height; in bttv_s_crop()
2912 btv->init.height = c.max_scaled_height; in bttv_s_crop()
2924 if (fh->btv->errors) in bttv_read()
2925 bttv_reinit_bt848(fh->btv); in bttv_read()
2927 fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]); in bttv_read()
2931 if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) { in bttv_read()
2938 free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ); in bttv_read()
2941 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_read()
2969 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_poll()
2983 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) in bttv_poll()
3011 struct bttv *btv = video_drvdata(file); in bttv_open() local
3027 btv->c.nr, v4l2_type_names[type]); in bttv_open()
3033 btv->users++; in bttv_open()
3036 *fh = btv->init; in bttv_open()
3043 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
3047 fh, &btv->lock); in bttv_open()
3049 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
3053 fh, &btv->lock); in bttv_open()
3054 set_tvnorm(btv,btv->tvnorm); in bttv_open()
3055 set_input(btv, btv->input, btv->tvnorm); in bttv_open()
3056 audio_mute(btv, btv->mute); in bttv_open()
3072 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); in bttv_open()
3074 bttv_field_count(btv); in bttv_open()
3082 struct bttv *btv = fh->btv; in bttv_release() local
3086 bttv_switch_overlay(btv,fh,NULL); in bttv_release()
3091 free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM); in bttv_release()
3098 free_btres_lock(btv, fh, RESOURCE_VIDEO_READ); in bttv_release()
3104 free_btres_lock(btv,fh,RESOURCE_VBI); in bttv_release()
3113 btv->users--; in bttv_release()
3114 bttv_field_count(btv); in bttv_release()
3116 if (!btv->users) in bttv_release()
3117 audio_mute(btv, btv->mute); in bttv_release()
3131 fh->btv->c.nr, v4l2_type_names[fh->type], in bttv_mmap()
3204 struct bttv *btv = video_drvdata(file); in radio_open() local
3209 dprintk("%d: open called (radio)\n", btv->c.nr); in radio_open()
3216 *fh = btv->init; in radio_open()
3219 btv->radio_user++; in radio_open()
3220 audio_mute(btv, btv->mute); in radio_open()
3230 struct bttv *btv = fh->btv; in radio_release() local
3238 btv->radio_user--; in radio_release()
3240 bttv_call_all(btv, core, ioctl, SAA6588_CMD_CLOSE, &cmd); in radio_release()
3242 if (btv->radio_user == 0) in radio_release()
3243 btv->has_radio_tuner = 0; in radio_release()
3250 struct bttv *btv = fh->btv; in radio_g_tuner() local
3256 radio_enable(btv); in radio_g_tuner()
3258 bttv_call_all(btv, tuner, g_tuner, t); in radio_g_tuner()
3260 if (btv->audio_mode_gpio) in radio_g_tuner()
3261 btv->audio_mode_gpio(btv, t, 0); in radio_g_tuner()
3263 if (btv->has_tea575x) in radio_g_tuner()
3264 return snd_tea575x_g_tuner(&btv->tea, t); in radio_g_tuner()
3273 struct bttv *btv = fh->btv; in radio_s_tuner() local
3278 radio_enable(btv); in radio_s_tuner()
3279 bttv_call_all(btv, tuner, s_tuner, t); in radio_s_tuner()
3287 struct bttv *btv = fh->btv; in radio_s_hw_freq_seek() local
3289 if (btv->has_tea575x) in radio_s_hw_freq_seek()
3290 return snd_tea575x_s_hw_freq_seek(file, &btv->tea, a); in radio_s_hw_freq_seek()
3299 struct bttv *btv = fh->btv; in radio_enum_freq_bands() local
3301 if (btv->has_tea575x) in radio_enum_freq_bands()
3302 return snd_tea575x_enum_freq_bands(&btv->tea, band); in radio_enum_freq_bands()
3311 struct bttv *btv = fh->btv; in radio_read() local
3319 radio_enable(btv); in radio_read()
3321 bttv_call_all(btv, core, ioctl, SAA6588_CMD_READ, &cmd); in radio_read()
3329 struct bttv *btv = fh->btv; in radio_poll() local
3338 radio_enable(btv); in radio_poll()
3342 bttv_call_all(btv, core, ioctl, SAA6588_CMD_POLL, &cmd); in radio_poll()
3415 static void bttv_risc_disasm(struct bttv *btv, in bttv_risc_disasm() argument
3421 btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma); in bttv_risc_disasm()
3424 btv->c.v4l2_dev.name, in bttv_risc_disasm()
3429 btv->c.v4l2_dev.name, in bttv_risc_disasm()
3437 static void bttv_print_riscaddr(struct bttv *btv) in bttv_print_riscaddr() argument
3439 pr_info(" main: %08llx\n", (unsigned long long)btv->main.dma); in bttv_print_riscaddr()
3441 btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0, in bttv_print_riscaddr()
3442 btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0); in bttv_print_riscaddr()
3444 btv->curr.top in bttv_print_riscaddr()
3445 ? (unsigned long long)btv->curr.top->top.dma : 0, in bttv_print_riscaddr()
3446 btv->curr.bottom in bttv_print_riscaddr()
3447 ? (unsigned long long)btv->curr.bottom->bottom.dma : 0); in bttv_print_riscaddr()
3449 btv->screen ? (unsigned long long)btv->screen->top.dma : 0, in bttv_print_riscaddr()
3450 btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0); in bttv_print_riscaddr()
3451 bttv_risc_disasm(btv, &btv->main); in bttv_print_riscaddr()
3492 static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc) in bttv_irq_debug_low_latency() argument
3495 btv->c.nr, in bttv_irq_debug_low_latency()
3496 (unsigned long)btv->main.dma, in bttv_irq_debug_low_latency()
3497 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]), in bttv_irq_debug_low_latency()
3498 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]), in bttv_irq_debug_low_latency()
3504 btv->c.nr); in bttv_irq_debug_low_latency()
3508 btv->c.nr); in bttv_irq_debug_low_latency()
3510 btv->c.nr); in bttv_irq_debug_low_latency()
3515 bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set) in bttv_irq_next_video() argument
3522 if (!list_empty(&btv->capture)) { in bttv_irq_next_video()
3524 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_next_video()
3532 (item->vb.queue.next != &btv->capture)) { in bttv_irq_next_video()
3573 if (NULL != btv->screen) { in bttv_irq_next_video()
3574 if (V4L2_FIELD_HAS_BOTH(btv->screen->vb.field)) { in bttv_irq_next_video()
3576 set->top = btv->screen; in bttv_irq_next_video()
3577 set->bottom = btv->screen; in bttv_irq_next_video()
3580 if (V4L2_FIELD_TOP == btv->screen->vb.field && in bttv_irq_next_video()
3582 set->top = btv->screen; in bttv_irq_next_video()
3584 if (V4L2_FIELD_BOTTOM == btv->screen->vb.field && in bttv_irq_next_video()
3586 set->bottom = btv->screen; in bttv_irq_next_video()
3592 btv->c.nr, set->top, set->bottom, in bttv_irq_next_video()
3593 btv->screen, set->frame_irq, set->top_irq); in bttv_irq_next_video()
3598 bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup, in bttv_irq_wakeup_video() argument
3609 btv->c.nr, wakeup->top); in bttv_irq_wakeup_video()
3611 wakeup->top->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3619 btv->c.nr, wakeup->top); in bttv_irq_wakeup_video()
3621 wakeup->top->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3628 btv->c.nr, wakeup->bottom); in bttv_irq_wakeup_video()
3630 wakeup->bottom->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3638 bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, in bttv_irq_wakeup_vbi() argument
3648 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_vbi()
3655 struct bttv *btv = (struct bttv *)data; in bttv_irq_timeout() local
3663 btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total, in bttv_irq_timeout()
3669 spin_lock_irqsave(&btv->s_lock,flags); in bttv_irq_timeout()
3673 old = btv->curr; in bttv_irq_timeout()
3674 ovbi = btv->cvbi; in bttv_irq_timeout()
3675 btv->curr = new; in bttv_irq_timeout()
3676 btv->cvbi = NULL; in bttv_irq_timeout()
3677 btv->loop_irq = 0; in bttv_irq_timeout()
3678 bttv_buffer_activate_video(btv, &new); in bttv_irq_timeout()
3679 bttv_buffer_activate_vbi(btv, NULL); in bttv_irq_timeout()
3680 bttv_set_dma(btv, 0); in bttv_irq_timeout()
3683 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_ERROR); in bttv_irq_timeout()
3684 bttv_irq_wakeup_vbi(btv, ovbi, VIDEOBUF_ERROR); in bttv_irq_timeout()
3687 while (!list_empty(&btv->capture)) { in bttv_irq_timeout()
3688 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3693 while (!list_empty(&btv->vcapture)) { in bttv_irq_timeout()
3694 item = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3700 btv->errors++; in bttv_irq_timeout()
3701 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_irq_timeout()
3705 bttv_irq_wakeup_top(struct bttv *btv) in bttv_irq_wakeup_top() argument
3707 struct bttv_buffer *wakeup = btv->curr.top; in bttv_irq_wakeup_top()
3712 spin_lock(&btv->s_lock); in bttv_irq_wakeup_top()
3713 btv->curr.top_irq = 0; in bttv_irq_wakeup_top()
3714 btv->curr.top = NULL; in bttv_irq_wakeup_top()
3715 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); in bttv_irq_wakeup_top()
3718 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_top()
3721 spin_unlock(&btv->s_lock); in bttv_irq_wakeup_top()
3734 bttv_irq_switch_video(struct bttv *btv) in bttv_irq_switch_video() argument
3740 spin_lock(&btv->s_lock); in bttv_irq_switch_video()
3743 bttv_irq_next_video(btv, &new); in bttv_irq_switch_video()
3745 if ((btv->curr.top && is_active(&btv->curr.top->top, rc)) || in bttv_irq_switch_video()
3746 (btv->curr.bottom && is_active(&btv->curr.bottom->bottom, rc))) { in bttv_irq_switch_video()
3747 btv->framedrop++; in bttv_irq_switch_video()
3749 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_video()
3750 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
3755 old = btv->curr; in bttv_irq_switch_video()
3756 btv->curr = new; in bttv_irq_switch_video()
3757 btv->loop_irq &= ~1; in bttv_irq_switch_video()
3758 bttv_buffer_activate_video(btv, &new); in bttv_irq_switch_video()
3759 bttv_set_dma(btv, 0); in bttv_irq_switch_video()
3762 if (UNSET != btv->new_input) { in bttv_irq_switch_video()
3763 video_mux(btv,btv->new_input); in bttv_irq_switch_video()
3764 btv->new_input = UNSET; in bttv_irq_switch_video()
3768 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_DONE); in bttv_irq_switch_video()
3769 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
3773 bttv_irq_switch_vbi(struct bttv *btv) in bttv_irq_switch_vbi() argument
3779 spin_lock(&btv->s_lock); in bttv_irq_switch_vbi()
3781 if (!list_empty(&btv->vcapture)) in bttv_irq_switch_vbi()
3782 new = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_switch_vbi()
3783 old = btv->cvbi; in bttv_irq_switch_vbi()
3788 btv->framedrop++; in bttv_irq_switch_vbi()
3790 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_vbi()
3791 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
3796 btv->cvbi = new; in bttv_irq_switch_vbi()
3797 btv->loop_irq &= ~4; in bttv_irq_switch_vbi()
3798 bttv_buffer_activate_vbi(btv, new); in bttv_irq_switch_vbi()
3799 bttv_set_dma(btv, 0); in bttv_irq_switch_vbi()
3801 bttv_irq_wakeup_vbi(btv, old, VIDEOBUF_DONE); in bttv_irq_switch_vbi()
3802 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
3810 struct bttv *btv; in bttv_irq() local
3813 btv=(struct bttv *)dev_id; in bttv_irq()
3830 btv->c.nr, count, btv->field_count, in bttv_irq()
3849 btv->field_count++; in bttv_irq()
3851 if ((astat & BT848_INT_GPINT) && btv->remote) { in bttv_irq()
3852 bttv_input_irq(btv); in bttv_irq()
3856 btv->i2c_done = stat; in bttv_irq()
3857 wake_up(&btv->i2c_queue); in bttv_irq()
3861 bttv_irq_switch_vbi(btv); in bttv_irq()
3864 bttv_irq_wakeup_top(btv); in bttv_irq()
3867 bttv_irq_switch_video(btv); in bttv_irq()
3869 if ((astat & BT848_INT_HLOCK) && btv->opt_automute) in bttv_irq()
3871 audio_mux_gpio(btv, btv->audio_input, btv->mute); in bttv_irq()
3875 btv->c.nr, in bttv_irq()
3882 bttv_print_riscaddr(btv); in bttv_irq()
3886 btv->c.nr, btread(BT848_RISC_COUNT)); in bttv_irq()
3888 bttv_print_riscaddr(btv); in bttv_irq()
3898 btv->c.nr); in bttv_irq()
3901 btv->c.nr); in bttv_irq()
3912 btv->irq_total++; in bttv_irq()
3914 btv->irq_me++; in bttv_irq()
3922 static void vdev_init(struct bttv *btv, in vdev_init() argument
3928 vfd->v4l2_dev = &btv->c.v4l2_dev; in vdev_init()
3930 video_set_drvdata(vfd, btv); in vdev_init()
3932 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", in vdev_init()
3933 type_name, bttv_tvcards[btv->c.type].name); in vdev_init()
3934 if (btv->tuner_type == TUNER_ABSENT) { in vdev_init()
3942 static void bttv_unregister_video(struct bttv *btv) in bttv_unregister_video() argument
3944 video_unregister_device(&btv->video_dev); in bttv_unregister_video()
3945 video_unregister_device(&btv->vbi_dev); in bttv_unregister_video()
3946 video_unregister_device(&btv->radio_dev); in bttv_unregister_video()
3950 static int bttv_register_video(struct bttv *btv) in bttv_register_video() argument
3956 vdev_init(btv, &btv->video_dev, &bttv_video_template, "video"); in bttv_register_video()
3958 if (video_register_device(&btv->video_dev, VFL_TYPE_GRABBER, in bttv_register_video()
3959 video_nr[btv->c.nr]) < 0) in bttv_register_video()
3962 btv->c.nr, video_device_node_name(&btv->video_dev)); in bttv_register_video()
3963 if (device_create_file(&btv->video_dev.dev, in bttv_register_video()
3965 pr_err("%d: device_create_file 'card' failed\n", btv->c.nr); in bttv_register_video()
3970 vdev_init(btv, &btv->vbi_dev, &bttv_video_template, "vbi"); in bttv_register_video()
3972 if (video_register_device(&btv->vbi_dev, VFL_TYPE_VBI, in bttv_register_video()
3973 vbi_nr[btv->c.nr]) < 0) in bttv_register_video()
3976 btv->c.nr, video_device_node_name(&btv->vbi_dev)); in bttv_register_video()
3978 if (!btv->has_radio) in bttv_register_video()
3981 vdev_init(btv, &btv->radio_dev, &radio_template, "radio"); in bttv_register_video()
3982 btv->radio_dev.ctrl_handler = &btv->radio_ctrl_handler; in bttv_register_video()
3983 if (video_register_device(&btv->radio_dev, VFL_TYPE_RADIO, in bttv_register_video()
3984 radio_nr[btv->c.nr]) < 0) in bttv_register_video()
3987 btv->c.nr, video_device_node_name(&btv->radio_dev)); in bttv_register_video()
3993 bttv_unregister_video(btv); in bttv_register_video()
4020 struct bttv *btv; in bttv_probe() local
4026 bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL); in bttv_probe()
4027 if (btv == NULL) { in bttv_probe()
4031 btv->c.nr = bttv_num; in bttv_probe()
4032 snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name), in bttv_probe()
4033 "bttv%d", btv->c.nr); in bttv_probe()
4036 mutex_init(&btv->lock); in bttv_probe()
4037 spin_lock_init(&btv->s_lock); in bttv_probe()
4038 spin_lock_init(&btv->gpio_lock); in bttv_probe()
4039 init_waitqueue_head(&btv->i2c_queue); in bttv_probe()
4040 INIT_LIST_HEAD(&btv->c.subs); in bttv_probe()
4041 INIT_LIST_HEAD(&btv->capture); in bttv_probe()
4042 INIT_LIST_HEAD(&btv->vcapture); in bttv_probe()
4044 init_timer(&btv->timeout); in bttv_probe()
4045 btv->timeout.function = bttv_irq_timeout; in bttv_probe()
4046 btv->timeout.data = (unsigned long)btv; in bttv_probe()
4048 btv->i2c_rc = -1; in bttv_probe()
4049 btv->tuner_type = UNSET; in bttv_probe()
4050 btv->new_input = UNSET; in bttv_probe()
4051 btv->has_radio=radio[btv->c.nr]; in bttv_probe()
4054 btv->c.pci = dev; in bttv_probe()
4055 btv->id = dev->device; in bttv_probe()
4057 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_probe()
4061 pr_warn("%d: No suitable DMA available\n", btv->c.nr); in bttv_probe()
4066 btv->c.v4l2_dev.name)) { in bttv_probe()
4068 btv->c.nr, in bttv_probe()
4075 result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev); in bttv_probe()
4077 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr); in bttv_probe()
4080 hdl = &btv->ctrl_handler; in bttv_probe()
4082 btv->c.v4l2_dev.ctrl_handler = hdl; in bttv_probe()
4083 v4l2_ctrl_handler_init(&btv->radio_ctrl_handler, 6); in bttv_probe()
4085 btv->revision = dev->revision; in bttv_probe()
4088 bttv_num, btv->id, btv->revision, pci_name(dev), in bttv_probe()
4089 btv->c.pci->irq, lat, in bttv_probe()
4093 btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000); in bttv_probe()
4094 if (NULL == btv->bt848_mmio) { in bttv_probe()
4095 pr_err("%d: ioremap() failed\n", btv->c.nr); in bttv_probe()
4101 bttv_idcard(btv); in bttv_probe()
4105 result = request_irq(btv->c.pci->irq, bttv_irq, in bttv_probe()
4106 IRQF_SHARED, btv->c.v4l2_dev.name, (void *)btv); in bttv_probe()
4109 bttv_num, btv->c.pci->irq); in bttv_probe()
4113 if (0 != bttv_handle_chipset(btv)) { in bttv_probe()
4119 btv->opt_combfilter = combfilter; in bttv_probe()
4122 btv->opt_automute = automute; in bttv_probe()
4125 btv->opt_vcr_hack = vcr_hack; in bttv_probe()
4129 btv->opt_uv_ratio = uv_ratio; in bttv_probe()
4135 btv->init.btv = btv; in bttv_probe()
4136 btv->init.ov.w.width = 320; in bttv_probe()
4137 btv->init.ov.w.height = 240; in bttv_probe()
4138 btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); in bttv_probe()
4139 btv->init.width = 320; in bttv_probe()
4140 btv->init.height = 240; in bttv_probe()
4141 btv->init.ov.w.width = 320; in bttv_probe()
4142 btv->init.ov.w.height = 240; in bttv_probe()
4143 btv->init.ov.field = V4L2_FIELD_INTERLACED; in bttv_probe()
4144 btv->input = 0; in bttv_probe()
4160 if (btv->volume_gpio) in bttv_probe()
4176 bttv_gpio_tracking(btv,"pre-init"); in bttv_probe()
4178 bttv_risc_init_main(btv); in bttv_probe()
4179 init_bt848(btv); in bttv_probe()
4185 bttv_gpio_tracking(btv,"init"); in bttv_probe()
4188 bttv_init_card1(btv); in bttv_probe()
4191 init_bttv_i2c(btv); in bttv_probe()
4194 bttv_init_card2(btv); in bttv_probe()
4195 bttv_init_tuner(btv); in bttv_probe()
4196 if (btv->tuner_type != TUNER_ABSENT) { in bttv_probe()
4197 bttv_set_frequency(btv, &init_freq); in bttv_probe()
4198 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */ in bttv_probe()
4200 btv->std = V4L2_STD_PAL; in bttv_probe()
4201 init_irqreg(btv); in bttv_probe()
4202 if (!bttv_tvcards[btv->c.type].no_video) in bttv_probe()
4209 audio_mute(btv, 1); in bttv_probe()
4212 if (!bttv_tvcards[btv->c.type].no_video) { in bttv_probe()
4213 v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl, in bttv_probe()
4215 if (btv->radio_ctrl_handler.error) { in bttv_probe()
4216 result = btv->radio_ctrl_handler.error; in bttv_probe()
4219 set_input(btv, 0, btv->tvnorm); in bttv_probe()
4220 bttv_crop_reset(&btv->crop[0], btv->tvnorm); in bttv_probe()
4221 btv->crop[1] = btv->crop[0]; /* current = default */ in bttv_probe()
4222 disclaim_vbi_lines(btv); in bttv_probe()
4223 disclaim_video_lines(btv); in bttv_probe()
4224 bttv_register_video(btv); in bttv_probe()
4228 if (bttv_tvcards[btv->c.type].has_dvb) { in bttv_probe()
4229 bttv_sub_add_device(&btv->c, "dvb"); in bttv_probe()
4230 request_modules(btv); in bttv_probe()
4234 init_bttv_i2c_ir(btv); in bttv_probe()
4235 bttv_input_init(btv); in bttv_probe()
4243 free_irq(btv->c.pci->irq,btv); in bttv_probe()
4246 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_probe()
4247 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_probe()
4248 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_probe()
4251 if (btv->bt848_mmio) in bttv_probe()
4252 iounmap(btv->bt848_mmio); in bttv_probe()
4253 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_probe()
4254 pci_resource_len(btv->c.pci,0)); in bttv_probe()
4261 struct bttv *btv = to_bttv(v4l2_dev); in bttv_remove() local
4264 pr_info("%d: unloading\n", btv->c.nr); in bttv_remove()
4266 if (bttv_tvcards[btv->c.type].has_dvb) in bttv_remove()
4267 flush_request_modules(btv); in bttv_remove()
4275 bttv_gpio_tracking(btv,"cleanup"); in bttv_remove()
4278 btv->shutdown=1; in bttv_remove()
4279 bttv_input_fini(btv); in bttv_remove()
4280 bttv_sub_del_devices(&btv->c); in bttv_remove()
4283 fini_bttv_i2c(btv); in bttv_remove()
4286 bttv_unregister_video(btv); in bttv_remove()
4289 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_remove()
4290 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_remove()
4291 btcx_riscmem_free(btv->c.pci,&btv->main); in bttv_remove()
4294 free_irq(btv->c.pci->irq,btv); in bttv_remove()
4295 iounmap(btv->bt848_mmio); in bttv_remove()
4296 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_remove()
4297 pci_resource_len(btv->c.pci,0)); in bttv_remove()
4299 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_remove()
4300 bttvs[btv->c.nr] = NULL; in bttv_remove()
4301 kfree(btv); in bttv_remove()
4310 struct bttv *btv = to_bttv(v4l2_dev); in bttv_suspend() local
4314 dprintk("%d: suspend %d\n", btv->c.nr, state.event); in bttv_suspend()
4317 spin_lock_irqsave(&btv->s_lock,flags); in bttv_suspend()
4319 btv->state.video = btv->curr; in bttv_suspend()
4320 btv->state.vbi = btv->cvbi; in bttv_suspend()
4321 btv->state.loop_irq = btv->loop_irq; in bttv_suspend()
4322 btv->curr = idle; in bttv_suspend()
4323 btv->loop_irq = 0; in bttv_suspend()
4324 bttv_buffer_activate_video(btv, &idle); in bttv_suspend()
4325 bttv_buffer_activate_vbi(btv, NULL); in bttv_suspend()
4326 bttv_set_dma(btv, 0); in bttv_suspend()
4328 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_suspend()
4331 btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN); in bttv_suspend()
4332 btv->state.gpio_data = gpio_read(); in bttv_suspend()
4338 btv->state.disabled = 1; in bttv_suspend()
4346 struct bttv *btv = to_bttv(v4l2_dev); in bttv_resume() local
4350 dprintk("%d: resume\n", btv->c.nr); in bttv_resume()
4353 if (btv->state.disabled) { in bttv_resume()
4356 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_resume()
4359 btv->state.disabled = 0; in bttv_resume()
4364 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_resume()
4365 btv->state.disabled = 1; in bttv_resume()
4372 bttv_reinit_bt848(btv); in bttv_resume()
4373 gpio_inout(0xffffff, btv->state.gpio_enable); in bttv_resume()
4374 gpio_write(btv->state.gpio_data); in bttv_resume()
4377 spin_lock_irqsave(&btv->s_lock,flags); in bttv_resume()
4378 btv->curr = btv->state.video; in bttv_resume()
4379 btv->cvbi = btv->state.vbi; in bttv_resume()
4380 btv->loop_irq = btv->state.loop_irq; in bttv_resume()
4381 bttv_buffer_activate_video(btv, &btv->curr); in bttv_resume()
4382 bttv_buffer_activate_vbi(btv, btv->cvbi); in bttv_resume()
4383 bttv_set_dma(btv, 0); in bttv_resume()
4384 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_resume()