Lines Matching refs:btv

177 	struct bttv *btv = video_get_drvdata(vfd);  in show_card()  local
178 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); in show_card()
652 int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit) in check_alloc_btres_lock() argument
665 if (btv->resources & xbits) { in check_alloc_btres_lock()
671 && 0 == (btv->resources & VIDEO_RESOURCES)) { in check_alloc_btres_lock()
673 __s32 top = btv->crop[!!fh->do_crop].rect.top; in check_alloc_btres_lock()
675 if (btv->vbi_end > top) in check_alloc_btres_lock()
680 btv->crop_start = top; in check_alloc_btres_lock()
684 if (end > btv->crop_start) in check_alloc_btres_lock()
688 btv->vbi_end = end; in check_alloc_btres_lock()
693 btv->resources |= bit; in check_alloc_btres_lock()
707 int locked_btres(struct bttv *btv, int bit) in locked_btres() argument
709 return (btv->resources & bit); in locked_btres()
714 disclaim_vbi_lines(struct bttv *btv) in disclaim_vbi_lines() argument
716 btv->vbi_end = 0; in disclaim_vbi_lines()
721 disclaim_video_lines(struct bttv *btv) in disclaim_video_lines() argument
726 tvnorm = &bttv_tvnorms[btv->tvnorm]; in disclaim_video_lines()
727 btv->crop_start = tvnorm->cropcap.bounds.top in disclaim_video_lines()
742 void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits) in free_btres_lock() argument
749 btv->resources &= ~bits; in free_btres_lock()
751 bits = btv->resources; in free_btres_lock()
754 disclaim_video_lines(btv); in free_btres_lock()
757 disclaim_vbi_lines(btv); in free_btres_lock()
773 static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout) in set_pll_freq() argument
795 static void set_pll(struct bttv *btv) in set_pll() argument
799 if (!btv->pll.pll_crystal) in set_pll()
802 if (btv->pll.pll_ofreq == btv->pll.pll_current) { in set_pll()
803 dprintk("%d: PLL: no change required\n", btv->c.nr); in set_pll()
807 if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) { in set_pll()
809 if (btv->pll.pll_current == 0) in set_pll()
813 btv->c.nr, btv->pll.pll_ifreq); in set_pll()
816 btv->pll.pll_current = 0; in set_pll()
822 btv->c.nr, in set_pll()
823 btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
824 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
834 btv->pll.pll_current = btv->pll.pll_ofreq; in set_pll()
840 btv->pll.pll_current = -1; in set_pll()
847 static void bt848A_set_timing(struct bttv *btv) in bt848A_set_timing() argument
850 int table_idx = bttv_tvnorms[btv->tvnorm].sram; in bt848A_set_timing()
851 int fsc = bttv_tvnorms[btv->tvnorm].Fsc; in bt848A_set_timing()
853 if (btv->input == btv->dig) { in bt848A_set_timing()
855 btv->c.nr,table_idx); in bt848A_set_timing()
865 btv->pll.pll_ofreq = 27000000; in bt848A_set_timing()
867 set_pll(btv); in bt848A_set_timing()
871 btv->pll.pll_ofreq = fsc; in bt848A_set_timing()
872 set_pll(btv); in bt848A_set_timing()
879 static void bt848_bright(struct bttv *btv, int bright) in bt848_bright() argument
884 btv->bright = bright; in bt848_bright()
891 static void bt848_hue(struct bttv *btv, int hue) in bt848_hue() argument
895 btv->hue = hue; in bt848_hue()
902 static void bt848_contrast(struct bttv *btv, int cont) in bt848_contrast() argument
906 btv->contrast = cont; in bt848_contrast()
916 static void bt848_sat(struct bttv *btv, int color) in bt848_sat() argument
920 btv->saturation = color; in bt848_sat()
923 val_u = ((color * btv->opt_uv_ratio) / 50) >> 7; in bt848_sat()
924 val_v = (((color * (100 - btv->opt_uv_ratio) / 50) >>7)*180L)/254; in bt848_sat()
936 video_mux(struct bttv *btv, unsigned int input) in video_mux() argument
940 if (input >= bttv_tvcards[btv->c.type].video_inputs) in video_mux()
944 mask2 = bttv_tvcards[btv->c.type].gpiomask2; in video_mux()
948 if (input == btv->svhs) { in video_mux()
955 mux = bttv_muxsel(btv, input); in video_mux()
957 dprintk("%d: video mux: input=%d mux=%d\n", btv->c.nr, input, mux); in video_mux()
960 if(bttv_tvcards[btv->c.type].muxsel_hook) in video_mux()
961 bttv_tvcards[btv->c.type].muxsel_hook (btv, input); in video_mux()
971 audio_mux_gpio(struct bttv *btv, int input, int mute) in audio_mux_gpio() argument
975 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, in audio_mux_gpio()
976 bttv_tvcards[btv->c.type].gpiomask); in audio_mux_gpio()
980 mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users) in audio_mux_gpio()
981 && !btv->has_radio_tuner); in audio_mux_gpio()
984 gpio_val = bttv_tvcards[btv->c.type].gpiomute; in audio_mux_gpio()
986 gpio_val = bttv_tvcards[btv->c.type].gpiomux[input]; in audio_mux_gpio()
988 switch (btv->c.type) { in audio_mux_gpio()
991 gpio_val = bttv_tda9880_setnorm(btv, gpio_val); in audio_mux_gpio()
995 gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val); in audio_mux_gpio()
999 bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]); in audio_mux_gpio()
1003 audio_mute(struct bttv *btv, int mute) in audio_mute() argument
1007 audio_mux_gpio(btv, btv->audio_input, mute); in audio_mute()
1009 if (btv->sd_msp34xx) { in audio_mute()
1010 ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1014 if (btv->sd_tvaudio) { in audio_mute()
1015 ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1019 if (btv->sd_tda7432) { in audio_mute()
1020 ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1028 audio_input(struct bttv *btv, int input) in audio_input() argument
1030 audio_mux_gpio(btv, input, btv->mute); in audio_input()
1032 if (btv->sd_msp34xx) { in audio_input()
1043 if (btv->radio_uses_msp_demodulator) { in audio_input()
1068 if (btv->c.type == BTTV_BOARD_VOODOOTV_200) in audio_input()
1075 v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, in audio_input()
1078 if (btv->sd_tvaudio) { in audio_input()
1079 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, in audio_input()
1116 set_tvnorm(struct bttv *btv, unsigned int norm) in set_tvnorm() argument
1122 BUG_ON(btv->tvnorm >= BTTV_TVNORMS); in set_tvnorm()
1126 if (memcmp(&bttv_tvnorms[btv->tvnorm].cropcap, &tvnorm->cropcap, in set_tvnorm()
1128 bttv_crop_reset(&btv->crop[0], norm); in set_tvnorm()
1129 btv->crop[1] = btv->crop[0]; /* current = default */ in set_tvnorm()
1131 if (0 == (btv->resources & VIDEO_RESOURCES)) { in set_tvnorm()
1132 btv->crop_start = tvnorm->cropcap.bounds.top in set_tvnorm()
1137 btv->tvnorm = norm; in set_tvnorm()
1145 bt848A_set_timing(btv); in set_tvnorm()
1147 switch (btv->c.type) { in set_tvnorm()
1150 bttv_tda9880_setnorm(btv, gpio_read()); in set_tvnorm()
1154 bttv_call_all(btv, video, s_std, id); in set_tvnorm()
1161 set_input(struct bttv *btv, unsigned int input, unsigned int norm) in set_input() argument
1165 btv->input = input; in set_input()
1167 spin_lock_irqsave(&btv->s_lock,flags); in set_input()
1168 if (btv->curr.frame_irq) { in set_input()
1170 btv->new_input = input; in set_input()
1172 video_mux(btv,input); in set_input()
1174 spin_unlock_irqrestore(&btv->s_lock,flags); in set_input()
1176 video_mux(btv,input); in set_input()
1178 btv->audio_input = (btv->tuner_type != TUNER_ABSENT && input == 0) ? in set_input()
1180 audio_input(btv, btv->audio_input); in set_input()
1181 set_tvnorm(btv, norm); in set_input()
1184 static void init_irqreg(struct bttv *btv) in init_irqreg() argument
1189 if (bttv_tvcards[btv->c.type].no_video) { in init_irqreg()
1195 btwrite((btv->triton1) | in init_irqreg()
1196 (btv->gpioirq ? BT848_INT_GPINT : 0) | in init_irqreg()
1206 static void init_bt848(struct bttv *btv) in init_bt848() argument
1208 if (bttv_tvcards[btv->c.type].no_video) { in init_bt848()
1210 init_irqreg(btv); in init_bt848()
1230 v4l2_ctrl_handler_setup(&btv->ctrl_handler); in init_bt848()
1233 init_irqreg(btv); in init_bt848()
1236 static void bttv_reinit_bt848(struct bttv *btv) in bttv_reinit_bt848() argument
1241 pr_info("%d: reset, reinitialize\n", btv->c.nr); in bttv_reinit_bt848()
1242 spin_lock_irqsave(&btv->s_lock,flags); in bttv_reinit_bt848()
1243 btv->errors=0; in bttv_reinit_bt848()
1244 bttv_set_dma(btv,0); in bttv_reinit_bt848()
1245 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_reinit_bt848()
1247 init_bt848(btv); in bttv_reinit_bt848()
1248 btv->pll.pll_current = -1; in bttv_reinit_bt848()
1249 set_input(btv, btv->input, btv->tvnorm); in bttv_reinit_bt848()
1254 struct bttv *btv = container_of(c->handler, struct bttv, ctrl_handler); in bttv_s_ctrl() local
1259 bt848_bright(btv, c->val); in bttv_s_ctrl()
1262 bt848_hue(btv, c->val); in bttv_s_ctrl()
1265 bt848_contrast(btv, c->val); in bttv_s_ctrl()
1268 bt848_sat(btv, c->val); in bttv_s_ctrl()
1280 audio_mute(btv, c->val); in bttv_s_ctrl()
1281 btv->mute = c->val; in bttv_s_ctrl()
1284 btv->volume_gpio(btv, c->val); in bttv_s_ctrl()
1293 btv->opt_combfilter = c->val; in bttv_s_ctrl()
1305 btv->opt_automute = c->val; in bttv_s_ctrl()
1313 btv->opt_vcr_hack = c->val; in bttv_s_ctrl()
1322 btv->opt_uv_ratio = c->val; in bttv_s_ctrl()
1323 bt848_sat(btv, btv->saturation); in bttv_s_ctrl()
1454 void bttv_gpio_tracking(struct bttv *btv, char *comment) in bttv_gpio_tracking() argument
1460 btv->c.nr, outbits, data & outbits, data & ~outbits, comment); in bttv_gpio_tracking()
1463 static void bttv_field_count(struct bttv *btv) in bttv_field_count() argument
1467 if (btv->users) in bttv_field_count()
1476 btv->field_count = 0; in bttv_field_count()
1498 bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh, in bttv_switch_overlay() argument
1507 spin_lock_irqsave(&btv->s_lock,flags); in bttv_switch_overlay()
1508 old = btv->screen; in bttv_switch_overlay()
1509 btv->screen = new; in bttv_switch_overlay()
1510 btv->loop_irq |= 1; in bttv_switch_overlay()
1511 bttv_set_dma(btv, 0x03); in bttv_switch_overlay()
1512 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_switch_overlay()
1516 bttv_dma_free(&fh->cap,btv, old); in bttv_switch_overlay()
1520 free_btres_lock(btv,fh,RESOURCE_OVERLAY); in bttv_switch_overlay()
1528 static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv, in bttv_prepare_buffer() argument
1553 norm = btv->tvnorm; in bttv_prepare_buffer()
1557 if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) { in bttv_prepare_buffer()
1563 norm = btv->tvnorm; in bttv_prepare_buffer()
1564 c = btv->crop[!!fh->do_crop]; in bttv_prepare_buffer()
1612 if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf))) in bttv_prepare_buffer()
1617 if (0 != (rc = bttv_buffer_risc(btv,buf))) in bttv_prepare_buffer()
1624 bttv_dma_free(q,btv,buf); in bttv_prepare_buffer()
1648 return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt, in buffer_prepare()
1657 struct bttv *btv = fh->btv; in buffer_queue() local
1660 list_add_tail(&buf->vb.queue,&btv->capture); in buffer_queue()
1661 if (!btv->curr.frame_irq) { in buffer_queue()
1662 btv->loop_irq |= 1; in buffer_queue()
1663 bttv_set_dma(btv, 0x03); in buffer_queue()
1672 bttv_dma_free(q,fh->btv,buf); in buffer_release()
1682 static void radio_enable(struct bttv *btv) in radio_enable() argument
1685 if (!btv->has_radio_tuner) { in radio_enable()
1686 btv->has_radio_tuner = 1; in radio_enable()
1687 bttv_call_all(btv, tuner, s_radio); in radio_enable()
1688 btv->audio_input = TVAUDIO_INPUT_RADIO; in radio_enable()
1689 audio_input(btv, btv->audio_input); in radio_enable()
1696 struct bttv *btv = fh->btv; in bttv_s_std() local
1704 btv->std = id; in bttv_s_std()
1705 set_tvnorm(btv, i); in bttv_s_std()
1712 struct bttv *btv = fh->btv; in bttv_g_std() local
1714 *id = btv->std; in bttv_g_std()
1721 struct bttv *btv = fh->btv; in bttv_querystd() local
1734 struct bttv *btv = fh->btv; in bttv_enum_input() local
1736 if (i->index >= bttv_tvcards[btv->c.type].video_inputs) in bttv_enum_input()
1742 if (btv->tuner_type != TUNER_ABSENT && i->index == 0) { in bttv_enum_input()
1746 } else if (i->index == btv->svhs) { in bttv_enum_input()
1752 if (i->index == btv->input) { in bttv_enum_input()
1767 struct bttv *btv = fh->btv; in bttv_g_input() local
1769 *i = btv->input; in bttv_g_input()
1777 struct bttv *btv = fh->btv; in bttv_s_input() local
1779 if (i >= bttv_tvcards[btv->c.type].video_inputs) in bttv_s_input()
1782 set_input(btv, i, btv->tvnorm); in bttv_s_input()
1790 struct bttv *btv = fh->btv; in bttv_s_tuner() local
1795 bttv_call_all(btv, tuner, s_tuner, t); in bttv_s_tuner()
1797 if (btv->audio_mode_gpio) { in bttv_s_tuner()
1800 btv->audio_mode_gpio(btv, &copy, 1); in bttv_s_tuner()
1809 struct bttv *btv = fh->btv; in bttv_g_frequency() local
1815 radio_enable(btv); in bttv_g_frequency()
1817 btv->radio_freq : btv->tv_freq; in bttv_g_frequency()
1822 static void bttv_set_frequency(struct bttv *btv, const struct v4l2_frequency *f) in bttv_set_frequency() argument
1826 bttv_call_all(btv, tuner, s_frequency, f); in bttv_set_frequency()
1829 bttv_call_all(btv, tuner, g_frequency, &new_freq); in bttv_set_frequency()
1831 radio_enable(btv); in bttv_set_frequency()
1832 btv->radio_freq = new_freq.frequency; in bttv_set_frequency()
1833 if (btv->has_tea575x) { in bttv_set_frequency()
1834 btv->tea.freq = btv->radio_freq; in bttv_set_frequency()
1835 snd_tea575x_set_freq(&btv->tea); in bttv_set_frequency()
1838 btv->tv_freq = new_freq.frequency; in bttv_set_frequency()
1846 struct bttv *btv = fh->btv; in bttv_s_frequency() local
1851 bttv_set_frequency(btv, f); in bttv_s_frequency()
1859 struct bttv *btv = fh->btv; in bttv_log_status() local
1861 v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name); in bttv_log_status()
1862 bttv_call_all(btv, core, log_status); in bttv_log_status()
1871 struct bttv *btv = fh->btv; in bttv_g_register() local
1885 struct bttv *btv = fh->btv; in bttv_s_register() local
1954 struct bttv *btv = fh->btv; in limit_scaled_size_lock() local
1969 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in limit_scaled_size_lock()
1972 c = &btv->crop[!!fh->do_crop]; in limit_scaled_size_lock()
1977 && !locked_btres(btv, VIDEO_RESOURCES)) { in limit_scaled_size_lock()
1990 if (btv->vbi_end > b->top) { in limit_scaled_size_lock()
1991 max_height -= btv->vbi_end - b->top; in limit_scaled_size_lock()
1998 if (btv->vbi_end > c->rect.top) in limit_scaled_size_lock()
2026 if (btv->vbi_end > c->rect.top) { in limit_scaled_size_lock()
2028 c->rect.top = btv->vbi_end; in limit_scaled_size_lock()
2086 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; in verify_window_lock()
2123 static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, in setup_window_lock() argument
2154 if (NULL != btv->fbuf.base) in setup_window_lock()
2155 n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, in setup_window_lock()
2183 btv->init.ov.w.width = win->w.width; in setup_window_lock()
2184 btv->init.ov.w.height = win->w.height; in setup_window_lock()
2185 btv->init.ov.field = win->field; in setup_window_lock()
2193 new->crop = btv->crop[!!fh->do_crop].rect; in setup_window_lock()
2194 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in setup_window_lock()
2195 retval = bttv_switch_overlay(btv,fh,new); in setup_window_lock()
2310 struct bttv *btv = fh->btv; in bttv_try_fmt_vid_cap() local
2337 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2380 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_cap() local
2414 btv->init.fmt = fmt; in bttv_s_fmt_vid_cap()
2415 btv->init.width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2416 btv->init.height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2425 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_overlay() local
2432 return setup_window_lock(fh, btv, &f->fmt.win, 1); in bttv_s_fmt_vid_overlay()
2439 struct bttv *btv = fh->btv; in bttv_querycap() local
2445 strscpy(cap->card, btv->video_dev.name, sizeof(cap->card)); in bttv_querycap()
2447 "PCI:%s", pci_name(btv->c.pci)); in bttv_querycap()
2452 if (video_is_registered(&btv->vbi_dev)) in bttv_querycap()
2454 if (video_is_registered(&btv->radio_dev)) { in bttv_querycap()
2456 if (btv->has_tea575x) in bttv_querycap()
2464 if (btv->has_saa6588) in bttv_querycap()
2466 if (btv->tuner_type != TUNER_ABSENT) in bttv_querycap()
2525 struct bttv *btv = fh->btv; in bttv_g_fbuf() local
2527 *fb = btv->fbuf; in bttv_g_fbuf()
2538 struct bttv *btv = fh->btv; in bttv_overlay() local
2544 if (unlikely(!btv->fbuf.base)) { in bttv_overlay()
2548 dprintk("%d: overlay: !setup_ok\n", btv->c.nr); in bttv_overlay()
2555 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) in bttv_overlay()
2559 fh->ov.tvnorm = btv->tvnorm; in bttv_overlay()
2561 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_overlay()
2562 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_overlay()
2568 retval = bttv_switch_overlay(btv, fh, new); in bttv_overlay()
2576 struct bttv *btv = fh->btv; in bttv_s_fbuf() local
2607 btv->fbuf.base = fb->base; in bttv_s_fbuf()
2608 btv->fbuf.fmt.width = fb->fmt.width; in bttv_s_fbuf()
2609 btv->fbuf.fmt.height = fb->fmt.height; in bttv_s_fbuf()
2611 btv->fbuf.fmt.bytesperline = fb->fmt.bytesperline; in bttv_s_fbuf()
2613 btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fmt->depth/8; in bttv_s_fbuf()
2617 btv->init.ovfmt = fmt; in bttv_s_fbuf()
2623 btv->init.ov.w.width = fb->fmt.width; in bttv_s_fbuf()
2624 btv->init.ov.w.height = fb->fmt.height; in bttv_s_fbuf()
2634 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_s_fbuf()
2635 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_s_fbuf()
2636 retval = bttv_switch_overlay(btv, fh, new); in bttv_s_fbuf()
2659 struct bttv *btv = fh->btv; in bttv_qbuf() local
2662 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_qbuf()
2679 struct bttv *btv = fh->btv; in bttv_streamon() local
2682 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_streamon()
2692 struct bttv *btv = fh->btv; in bttv_streamoff() local
2700 free_btres_lock(btv, fh, res); in bttv_streamoff()
2708 struct bttv *btv = fh->btv; in bttv_g_parm() local
2713 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, in bttv_g_parm()
2723 struct bttv *btv = fh->btv; in bttv_g_tuner() local
2730 bttv_call_all(btv, tuner, g_tuner, t); in bttv_g_tuner()
2736 if (btv->audio_mode_gpio) in bttv_g_tuner()
2737 btv->audio_mode_gpio(btv, t, 0); in bttv_g_tuner()
2746 struct bttv *btv = fh->btv; in bttv_g_pixelaspect() local
2752 *f = bttv_tvnorms[btv->tvnorm].cropcap.pixelaspect; in bttv_g_pixelaspect()
2759 struct bttv *btv = fh->btv; in bttv_g_selection() local
2772 sel->r = btv->crop[!!fh->do_crop].rect; in bttv_g_selection()
2775 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.defrect; in bttv_g_selection()
2778 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_g_selection()
2790 struct bttv *btv = fh->btv; in bttv_s_selection() local
2811 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { in bttv_s_selection()
2815 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_s_selection()
2821 b_top = max(b->top, btv->vbi_end); in bttv_s_selection()
2845 btv->crop[1] = c; in bttv_s_selection()
2851 btv->init.width = c.min_scaled_width; in bttv_s_selection()
2854 btv->init.width = c.max_scaled_width; in bttv_s_selection()
2859 btv->init.height = c.min_scaled_height; in bttv_s_selection()
2862 btv->init.height = c.max_scaled_height; in bttv_s_selection()
2874 if (fh->btv->errors) in bttv_read()
2875 bttv_reinit_bt848(fh->btv); in bttv_read()
2877 fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]); in bttv_read()
2881 if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) { in bttv_read()
2888 free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ); in bttv_read()
2891 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_read()
2919 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_poll()
2933 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) in bttv_poll()
2961 struct bttv *btv = video_drvdata(file); in bttv_open() local
2977 btv->c.nr, v4l2_type_names[type]); in bttv_open()
2983 btv->users++; in bttv_open()
2986 *fh = btv->init; in bttv_open()
2993 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
2997 fh, &btv->lock); in bttv_open()
2999 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
3003 fh, &btv->lock); in bttv_open()
3004 set_tvnorm(btv,btv->tvnorm); in bttv_open()
3005 set_input(btv, btv->input, btv->tvnorm); in bttv_open()
3006 audio_mute(btv, btv->mute); in bttv_open()
3022 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); in bttv_open()
3024 bttv_field_count(btv); in bttv_open()
3032 struct bttv *btv = fh->btv; in bttv_release() local
3036 bttv_switch_overlay(btv,fh,NULL); in bttv_release()
3041 free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM); in bttv_release()
3048 free_btres_lock(btv, fh, RESOURCE_VIDEO_READ); in bttv_release()
3054 free_btres_lock(btv,fh,RESOURCE_VBI); in bttv_release()
3063 btv->users--; in bttv_release()
3064 bttv_field_count(btv); in bttv_release()
3066 if (!btv->users) in bttv_release()
3067 audio_mute(btv, btv->mute); in bttv_release()
3081 fh->btv->c.nr, v4l2_type_names[fh->type], in bttv_mmap()
3154 struct bttv *btv = video_drvdata(file); in radio_open() local
3159 dprintk("%d: open called (radio)\n", btv->c.nr); in radio_open()
3166 *fh = btv->init; in radio_open()
3169 btv->radio_user++; in radio_open()
3170 audio_mute(btv, btv->mute); in radio_open()
3180 struct bttv *btv = fh->btv; in radio_release() local
3188 btv->radio_user--; in radio_release()
3190 bttv_call_all(btv, core, ioctl, SAA6588_CMD_CLOSE, &cmd); in radio_release()
3192 if (btv->radio_user == 0) in radio_release()
3193 btv->has_radio_tuner = 0; in radio_release()
3200 struct bttv *btv = fh->btv; in radio_g_tuner() local
3206 radio_enable(btv); in radio_g_tuner()
3208 bttv_call_all(btv, tuner, g_tuner, t); in radio_g_tuner()
3210 if (btv->audio_mode_gpio) in radio_g_tuner()
3211 btv->audio_mode_gpio(btv, t, 0); in radio_g_tuner()
3213 if (btv->has_tea575x) in radio_g_tuner()
3214 return snd_tea575x_g_tuner(&btv->tea, t); in radio_g_tuner()
3223 struct bttv *btv = fh->btv; in radio_s_tuner() local
3228 radio_enable(btv); in radio_s_tuner()
3229 bttv_call_all(btv, tuner, s_tuner, t); in radio_s_tuner()
3237 struct bttv *btv = fh->btv; in radio_s_hw_freq_seek() local
3239 if (btv->has_tea575x) in radio_s_hw_freq_seek()
3240 return snd_tea575x_s_hw_freq_seek(file, &btv->tea, a); in radio_s_hw_freq_seek()
3249 struct bttv *btv = fh->btv; in radio_enum_freq_bands() local
3251 if (btv->has_tea575x) in radio_enum_freq_bands()
3252 return snd_tea575x_enum_freq_bands(&btv->tea, band); in radio_enum_freq_bands()
3261 struct bttv *btv = fh->btv; in radio_read() local
3269 radio_enable(btv); in radio_read()
3271 bttv_call_all(btv, core, ioctl, SAA6588_CMD_READ, &cmd); in radio_read()
3279 struct bttv *btv = fh->btv; in radio_poll() local
3288 radio_enable(btv); in radio_poll()
3292 bttv_call_all(btv, core, ioctl, SAA6588_CMD_POLL, &cmd); in radio_poll()
3365 static void bttv_risc_disasm(struct bttv *btv, in bttv_risc_disasm() argument
3371 btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma); in bttv_risc_disasm()
3374 btv->c.v4l2_dev.name, in bttv_risc_disasm()
3379 btv->c.v4l2_dev.name, in bttv_risc_disasm()
3387 static void bttv_print_riscaddr(struct bttv *btv) in bttv_print_riscaddr() argument
3389 pr_info(" main: %08llx\n", (unsigned long long)btv->main.dma); in bttv_print_riscaddr()
3391 btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0, in bttv_print_riscaddr()
3392 btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0); in bttv_print_riscaddr()
3394 btv->curr.top in bttv_print_riscaddr()
3395 ? (unsigned long long)btv->curr.top->top.dma : 0, in bttv_print_riscaddr()
3396 btv->curr.bottom in bttv_print_riscaddr()
3397 ? (unsigned long long)btv->curr.bottom->bottom.dma : 0); in bttv_print_riscaddr()
3399 btv->screen ? (unsigned long long)btv->screen->top.dma : 0, in bttv_print_riscaddr()
3400 btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0); in bttv_print_riscaddr()
3401 bttv_risc_disasm(btv, &btv->main); in bttv_print_riscaddr()
3442 static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc) in bttv_irq_debug_low_latency() argument
3445 btv->c.nr, in bttv_irq_debug_low_latency()
3446 (unsigned long)btv->main.dma, in bttv_irq_debug_low_latency()
3447 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]), in bttv_irq_debug_low_latency()
3448 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]), in bttv_irq_debug_low_latency()
3453 btv->c.nr); in bttv_irq_debug_low_latency()
3457 btv->c.nr); in bttv_irq_debug_low_latency()
3459 btv->c.nr); in bttv_irq_debug_low_latency()
3464 bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set) in bttv_irq_next_video() argument
3471 if (!list_empty(&btv->capture)) { in bttv_irq_next_video()
3473 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_next_video()
3481 (item->vb.queue.next != &btv->capture)) { in bttv_irq_next_video()
3522 if (NULL != btv->screen) { in bttv_irq_next_video()
3523 if (V4L2_FIELD_HAS_BOTH(btv->screen->vb.field)) { in bttv_irq_next_video()
3525 set->top = btv->screen; in bttv_irq_next_video()
3526 set->bottom = btv->screen; in bttv_irq_next_video()
3529 if (V4L2_FIELD_TOP == btv->screen->vb.field && in bttv_irq_next_video()
3531 set->top = btv->screen; in bttv_irq_next_video()
3533 if (V4L2_FIELD_BOTTOM == btv->screen->vb.field && in bttv_irq_next_video()
3535 set->bottom = btv->screen; in bttv_irq_next_video()
3541 btv->c.nr, set->top, set->bottom, in bttv_irq_next_video()
3542 btv->screen, set->frame_irq, set->top_irq); in bttv_irq_next_video()
3547 bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup, in bttv_irq_wakeup_video() argument
3556 btv->c.nr, wakeup->top); in bttv_irq_wakeup_video()
3558 wakeup->top->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3566 btv->c.nr, wakeup->top); in bttv_irq_wakeup_video()
3568 wakeup->top->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3575 btv->c.nr, wakeup->bottom); in bttv_irq_wakeup_video()
3577 wakeup->bottom->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3585 bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, in bttv_irq_wakeup_vbi() argument
3592 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_vbi()
3599 struct bttv *btv = from_timer(btv, t, timeout); in bttv_irq_timeout() local
3607 btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total, in bttv_irq_timeout()
3613 spin_lock_irqsave(&btv->s_lock,flags); in bttv_irq_timeout()
3617 old = btv->curr; in bttv_irq_timeout()
3618 ovbi = btv->cvbi; in bttv_irq_timeout()
3619 btv->curr = new; in bttv_irq_timeout()
3620 btv->cvbi = NULL; in bttv_irq_timeout()
3621 btv->loop_irq = 0; in bttv_irq_timeout()
3622 bttv_buffer_activate_video(btv, &new); in bttv_irq_timeout()
3623 bttv_buffer_activate_vbi(btv, NULL); in bttv_irq_timeout()
3624 bttv_set_dma(btv, 0); in bttv_irq_timeout()
3627 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_ERROR); in bttv_irq_timeout()
3628 bttv_irq_wakeup_vbi(btv, ovbi, VIDEOBUF_ERROR); in bttv_irq_timeout()
3631 while (!list_empty(&btv->capture)) { in bttv_irq_timeout()
3632 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3637 while (!list_empty(&btv->vcapture)) { in bttv_irq_timeout()
3638 item = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3644 btv->errors++; in bttv_irq_timeout()
3645 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_irq_timeout()
3649 bttv_irq_wakeup_top(struct bttv *btv) in bttv_irq_wakeup_top() argument
3651 struct bttv_buffer *wakeup = btv->curr.top; in bttv_irq_wakeup_top()
3656 spin_lock(&btv->s_lock); in bttv_irq_wakeup_top()
3657 btv->curr.top_irq = 0; in bttv_irq_wakeup_top()
3658 btv->curr.top = NULL; in bttv_irq_wakeup_top()
3659 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); in bttv_irq_wakeup_top()
3662 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_top()
3665 spin_unlock(&btv->s_lock); in bttv_irq_wakeup_top()
3678 bttv_irq_switch_video(struct bttv *btv) in bttv_irq_switch_video() argument
3684 spin_lock(&btv->s_lock); in bttv_irq_switch_video()
3687 bttv_irq_next_video(btv, &new); in bttv_irq_switch_video()
3689 if ((btv->curr.top && is_active(&btv->curr.top->top, rc)) || in bttv_irq_switch_video()
3690 (btv->curr.bottom && is_active(&btv->curr.bottom->bottom, rc))) { in bttv_irq_switch_video()
3691 btv->framedrop++; in bttv_irq_switch_video()
3693 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_video()
3694 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
3699 old = btv->curr; in bttv_irq_switch_video()
3700 btv->curr = new; in bttv_irq_switch_video()
3701 btv->loop_irq &= ~1; in bttv_irq_switch_video()
3702 bttv_buffer_activate_video(btv, &new); in bttv_irq_switch_video()
3703 bttv_set_dma(btv, 0); in bttv_irq_switch_video()
3706 if (UNSET != btv->new_input) { in bttv_irq_switch_video()
3707 video_mux(btv,btv->new_input); in bttv_irq_switch_video()
3708 btv->new_input = UNSET; in bttv_irq_switch_video()
3712 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_DONE); in bttv_irq_switch_video()
3713 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
3717 bttv_irq_switch_vbi(struct bttv *btv) in bttv_irq_switch_vbi() argument
3723 spin_lock(&btv->s_lock); in bttv_irq_switch_vbi()
3725 if (!list_empty(&btv->vcapture)) in bttv_irq_switch_vbi()
3726 new = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_switch_vbi()
3727 old = btv->cvbi; in bttv_irq_switch_vbi()
3732 btv->framedrop++; in bttv_irq_switch_vbi()
3734 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_vbi()
3735 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
3740 btv->cvbi = new; in bttv_irq_switch_vbi()
3741 btv->loop_irq &= ~4; in bttv_irq_switch_vbi()
3742 bttv_buffer_activate_vbi(btv, new); in bttv_irq_switch_vbi()
3743 bttv_set_dma(btv, 0); in bttv_irq_switch_vbi()
3745 bttv_irq_wakeup_vbi(btv, old, VIDEOBUF_DONE); in bttv_irq_switch_vbi()
3746 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
3754 struct bttv *btv; in bttv_irq() local
3757 btv=(struct bttv *)dev_id; in bttv_irq()
3774 btv->c.nr, count, btv->field_count, in bttv_irq()
3793 btv->field_count++; in bttv_irq()
3795 if ((astat & BT848_INT_GPINT) && btv->remote) { in bttv_irq()
3796 bttv_input_irq(btv); in bttv_irq()
3800 btv->i2c_done = stat; in bttv_irq()
3801 wake_up(&btv->i2c_queue); in bttv_irq()
3805 bttv_irq_switch_vbi(btv); in bttv_irq()
3808 bttv_irq_wakeup_top(btv); in bttv_irq()
3811 bttv_irq_switch_video(btv); in bttv_irq()
3813 if ((astat & BT848_INT_HLOCK) && btv->opt_automute) in bttv_irq()
3815 audio_mux_gpio(btv, btv->audio_input, btv->mute); in bttv_irq()
3819 btv->c.nr, in bttv_irq()
3826 bttv_print_riscaddr(btv); in bttv_irq()
3830 btv->c.nr, btread(BT848_RISC_COUNT)); in bttv_irq()
3832 bttv_print_riscaddr(btv); in bttv_irq()
3842 btv->c.nr); in bttv_irq()
3845 btv->c.nr); in bttv_irq()
3856 btv->irq_total++; in bttv_irq()
3858 btv->irq_me++; in bttv_irq()
3866 static void vdev_init(struct bttv *btv, in vdev_init() argument
3872 vfd->v4l2_dev = &btv->c.v4l2_dev; in vdev_init()
3874 video_set_drvdata(vfd, btv); in vdev_init()
3876 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", in vdev_init()
3877 type_name, bttv_tvcards[btv->c.type].name); in vdev_init()
3878 if (btv->tuner_type == TUNER_ABSENT) { in vdev_init()
3886 static void bttv_unregister_video(struct bttv *btv) in bttv_unregister_video() argument
3888 video_unregister_device(&btv->video_dev); in bttv_unregister_video()
3889 video_unregister_device(&btv->vbi_dev); in bttv_unregister_video()
3890 video_unregister_device(&btv->radio_dev); in bttv_unregister_video()
3894 static int bttv_register_video(struct bttv *btv) in bttv_register_video() argument
3900 vdev_init(btv, &btv->video_dev, &bttv_video_template, "video"); in bttv_register_video()
3901 btv->video_dev.device_caps = V4L2_CAP_VIDEO_CAPTURE | in bttv_register_video()
3903 if (btv->tuner_type != TUNER_ABSENT) in bttv_register_video()
3904 btv->video_dev.device_caps |= V4L2_CAP_TUNER; in bttv_register_video()
3906 btv->video_dev.device_caps |= V4L2_CAP_VIDEO_OVERLAY; in bttv_register_video()
3908 if (video_register_device(&btv->video_dev, VFL_TYPE_VIDEO, in bttv_register_video()
3909 video_nr[btv->c.nr]) < 0) in bttv_register_video()
3912 btv->c.nr, video_device_node_name(&btv->video_dev)); in bttv_register_video()
3913 if (device_create_file(&btv->video_dev.dev, in bttv_register_video()
3915 pr_err("%d: device_create_file 'card' failed\n", btv->c.nr); in bttv_register_video()
3920 vdev_init(btv, &btv->vbi_dev, &bttv_video_template, "vbi"); in bttv_register_video()
3921 btv->vbi_dev.device_caps = V4L2_CAP_VBI_CAPTURE | V4L2_CAP_READWRITE | in bttv_register_video()
3923 if (btv->tuner_type != TUNER_ABSENT) in bttv_register_video()
3924 btv->vbi_dev.device_caps |= V4L2_CAP_TUNER; in bttv_register_video()
3926 if (video_register_device(&btv->vbi_dev, VFL_TYPE_VBI, in bttv_register_video()
3927 vbi_nr[btv->c.nr]) < 0) in bttv_register_video()
3930 btv->c.nr, video_device_node_name(&btv->vbi_dev)); in bttv_register_video()
3932 if (!btv->has_radio) in bttv_register_video()
3935 vdev_init(btv, &btv->radio_dev, &radio_template, "radio"); in bttv_register_video()
3936 btv->radio_dev.device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; in bttv_register_video()
3937 if (btv->has_saa6588) in bttv_register_video()
3938 btv->radio_dev.device_caps |= V4L2_CAP_READWRITE | in bttv_register_video()
3940 if (btv->has_tea575x) in bttv_register_video()
3941 btv->radio_dev.device_caps |= V4L2_CAP_HW_FREQ_SEEK; in bttv_register_video()
3942 btv->radio_dev.ctrl_handler = &btv->radio_ctrl_handler; in bttv_register_video()
3943 if (video_register_device(&btv->radio_dev, VFL_TYPE_RADIO, in bttv_register_video()
3944 radio_nr[btv->c.nr]) < 0) in bttv_register_video()
3947 btv->c.nr, video_device_node_name(&btv->radio_dev)); in bttv_register_video()
3953 bttv_unregister_video(btv); in bttv_register_video()
3980 struct bttv *btv; in bttv_probe() local
3986 bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL); in bttv_probe()
3987 if (btv == NULL) { in bttv_probe()
3991 btv->c.nr = bttv_num; in bttv_probe()
3992 snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name), in bttv_probe()
3993 "bttv%d", btv->c.nr); in bttv_probe()
3996 mutex_init(&btv->lock); in bttv_probe()
3997 spin_lock_init(&btv->s_lock); in bttv_probe()
3998 spin_lock_init(&btv->gpio_lock); in bttv_probe()
3999 init_waitqueue_head(&btv->i2c_queue); in bttv_probe()
4000 INIT_LIST_HEAD(&btv->c.subs); in bttv_probe()
4001 INIT_LIST_HEAD(&btv->capture); in bttv_probe()
4002 INIT_LIST_HEAD(&btv->vcapture); in bttv_probe()
4004 timer_setup(&btv->timeout, bttv_irq_timeout, 0); in bttv_probe()
4006 btv->i2c_rc = -1; in bttv_probe()
4007 btv->tuner_type = UNSET; in bttv_probe()
4008 btv->new_input = UNSET; in bttv_probe()
4009 btv->has_radio=radio[btv->c.nr]; in bttv_probe()
4012 btv->c.pci = dev; in bttv_probe()
4013 btv->id = dev->device; in bttv_probe()
4015 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_probe()
4020 pr_warn("%d: No suitable DMA available\n", btv->c.nr); in bttv_probe()
4026 btv->c.v4l2_dev.name)) { in bttv_probe()
4028 btv->c.nr, in bttv_probe()
4036 result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev); in bttv_probe()
4038 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr); in bttv_probe()
4041 hdl = &btv->ctrl_handler; in bttv_probe()
4043 btv->c.v4l2_dev.ctrl_handler = hdl; in bttv_probe()
4044 v4l2_ctrl_handler_init(&btv->radio_ctrl_handler, 6); in bttv_probe()
4046 btv->revision = dev->revision; in bttv_probe()
4049 bttv_num, btv->id, btv->revision, pci_name(dev), in bttv_probe()
4050 btv->c.pci->irq, lat, in bttv_probe()
4054 btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000); in bttv_probe()
4055 if (NULL == btv->bt848_mmio) { in bttv_probe()
4056 pr_err("%d: ioremap() failed\n", btv->c.nr); in bttv_probe()
4062 bttv_idcard(btv); in bttv_probe()
4066 result = request_irq(btv->c.pci->irq, bttv_irq, in bttv_probe()
4067 IRQF_SHARED, btv->c.v4l2_dev.name, (void *)btv); in bttv_probe()
4070 bttv_num, btv->c.pci->irq); in bttv_probe()
4074 if (0 != bttv_handle_chipset(btv)) { in bttv_probe()
4080 btv->opt_combfilter = combfilter; in bttv_probe()
4083 btv->opt_automute = automute; in bttv_probe()
4086 btv->opt_vcr_hack = vcr_hack; in bttv_probe()
4090 btv->opt_uv_ratio = uv_ratio; in bttv_probe()
4096 btv->init.btv = btv; in bttv_probe()
4097 btv->init.ov.w.width = 320; in bttv_probe()
4098 btv->init.ov.w.height = 240; in bttv_probe()
4099 btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); in bttv_probe()
4100 btv->init.width = 320; in bttv_probe()
4101 btv->init.height = 240; in bttv_probe()
4102 btv->init.ov.w.width = 320; in bttv_probe()
4103 btv->init.ov.w.height = 240; in bttv_probe()
4104 btv->init.ov.field = V4L2_FIELD_INTERLACED; in bttv_probe()
4105 btv->input = 0; in bttv_probe()
4121 if (btv->volume_gpio) in bttv_probe()
4137 bttv_gpio_tracking(btv,"pre-init"); in bttv_probe()
4139 bttv_risc_init_main(btv); in bttv_probe()
4140 init_bt848(btv); in bttv_probe()
4146 bttv_gpio_tracking(btv,"init"); in bttv_probe()
4149 bttv_init_card1(btv); in bttv_probe()
4152 init_bttv_i2c(btv); in bttv_probe()
4155 bttv_init_card2(btv); in bttv_probe()
4156 bttv_init_tuner(btv); in bttv_probe()
4157 if (btv->tuner_type != TUNER_ABSENT) { in bttv_probe()
4158 bttv_set_frequency(btv, &init_freq); in bttv_probe()
4159 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */ in bttv_probe()
4161 btv->std = V4L2_STD_PAL; in bttv_probe()
4162 init_irqreg(btv); in bttv_probe()
4163 if (!bttv_tvcards[btv->c.type].no_video) in bttv_probe()
4170 audio_mute(btv, 1); in bttv_probe()
4173 if (!bttv_tvcards[btv->c.type].no_video) { in bttv_probe()
4174 v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl, in bttv_probe()
4176 if (btv->radio_ctrl_handler.error) { in bttv_probe()
4177 result = btv->radio_ctrl_handler.error; in bttv_probe()
4180 set_input(btv, 0, btv->tvnorm); in bttv_probe()
4181 bttv_crop_reset(&btv->crop[0], btv->tvnorm); in bttv_probe()
4182 btv->crop[1] = btv->crop[0]; /* current = default */ in bttv_probe()
4183 disclaim_vbi_lines(btv); in bttv_probe()
4184 disclaim_video_lines(btv); in bttv_probe()
4185 bttv_register_video(btv); in bttv_probe()
4189 if (bttv_tvcards[btv->c.type].has_dvb) { in bttv_probe()
4190 bttv_sub_add_device(&btv->c, "dvb"); in bttv_probe()
4191 request_modules(btv); in bttv_probe()
4195 init_bttv_i2c_ir(btv); in bttv_probe()
4196 bttv_input_init(btv); in bttv_probe()
4204 free_irq(btv->c.pci->irq,btv); in bttv_probe()
4207 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_probe()
4208 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_probe()
4209 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_probe()
4212 if (btv->bt848_mmio) in bttv_probe()
4213 iounmap(btv->bt848_mmio); in bttv_probe()
4214 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_probe()
4215 pci_resource_len(btv->c.pci,0)); in bttv_probe()
4216 pci_disable_device(btv->c.pci); in bttv_probe()
4219 bttvs[btv->c.nr] = NULL; in bttv_probe()
4220 kfree(btv); in bttv_probe()
4227 struct bttv *btv = to_bttv(v4l2_dev); in bttv_remove() local
4230 pr_info("%d: unloading\n", btv->c.nr); in bttv_remove()
4232 if (bttv_tvcards[btv->c.type].has_dvb) in bttv_remove()
4233 flush_request_modules(btv); in bttv_remove()
4241 bttv_gpio_tracking(btv,"cleanup"); in bttv_remove()
4244 btv->shutdown=1; in bttv_remove()
4245 bttv_input_fini(btv); in bttv_remove()
4246 bttv_sub_del_devices(&btv->c); in bttv_remove()
4249 fini_bttv_i2c(btv); in bttv_remove()
4252 bttv_unregister_video(btv); in bttv_remove()
4255 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_remove()
4256 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_remove()
4257 btcx_riscmem_free(btv->c.pci,&btv->main); in bttv_remove()
4260 free_irq(btv->c.pci->irq,btv); in bttv_remove()
4261 iounmap(btv->bt848_mmio); in bttv_remove()
4262 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_remove()
4263 pci_resource_len(btv->c.pci,0)); in bttv_remove()
4264 pci_disable_device(btv->c.pci); in bttv_remove()
4266 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_remove()
4267 bttvs[btv->c.nr] = NULL; in bttv_remove()
4268 kfree(btv); in bttv_remove()
4277 struct bttv *btv = to_bttv(v4l2_dev); in bttv_suspend() local
4281 dprintk("%d: suspend %d\n", btv->c.nr, state.event); in bttv_suspend()
4284 spin_lock_irqsave(&btv->s_lock,flags); in bttv_suspend()
4286 btv->state.video = btv->curr; in bttv_suspend()
4287 btv->state.vbi = btv->cvbi; in bttv_suspend()
4288 btv->state.loop_irq = btv->loop_irq; in bttv_suspend()
4289 btv->curr = idle; in bttv_suspend()
4290 btv->loop_irq = 0; in bttv_suspend()
4291 bttv_buffer_activate_video(btv, &idle); in bttv_suspend()
4292 bttv_buffer_activate_vbi(btv, NULL); in bttv_suspend()
4293 bttv_set_dma(btv, 0); in bttv_suspend()
4295 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_suspend()
4298 btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN); in bttv_suspend()
4299 btv->state.gpio_data = gpio_read(); in bttv_suspend()
4305 btv->state.disabled = 1; in bttv_suspend()
4313 struct bttv *btv = to_bttv(v4l2_dev); in bttv_resume() local
4317 dprintk("%d: resume\n", btv->c.nr); in bttv_resume()
4320 if (btv->state.disabled) { in bttv_resume()
4323 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_resume()
4326 btv->state.disabled = 0; in bttv_resume()
4331 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_resume()
4332 btv->state.disabled = 1; in bttv_resume()
4339 bttv_reinit_bt848(btv); in bttv_resume()
4340 gpio_inout(0xffffff, btv->state.gpio_enable); in bttv_resume()
4341 gpio_write(btv->state.gpio_data); in bttv_resume()
4344 spin_lock_irqsave(&btv->s_lock,flags); in bttv_resume()
4345 btv->curr = btv->state.video; in bttv_resume()
4346 btv->cvbi = btv->state.vbi; in bttv_resume()
4347 btv->loop_irq = btv->state.loop_irq; in bttv_resume()
4348 bttv_buffer_activate_video(btv, &btv->curr); in bttv_resume()
4349 bttv_buffer_activate_vbi(btv, btv->cvbi); in bttv_resume()
4350 bttv_set_dma(btv, 0); in bttv_resume()
4351 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_resume()