Lines Matching refs:btv

177 	struct bttv *btv = video_get_drvdata(vfd);  in card_show()  local
178 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); in card_show()
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()
2085 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; in verify_window_lock()
2119 static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, in setup_window_lock() argument
2146 if (NULL != btv->fbuf.base) in setup_window_lock()
2147 n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, in setup_window_lock()
2175 btv->init.ov.w.width = win->w.width; in setup_window_lock()
2176 btv->init.ov.w.height = win->w.height; in setup_window_lock()
2177 btv->init.ov.field = win->field; in setup_window_lock()
2185 new->crop = btv->crop[!!fh->do_crop].rect; in setup_window_lock()
2186 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in setup_window_lock()
2187 retval = bttv_switch_overlay(btv,fh,new); in setup_window_lock()
2302 struct bttv *btv = fh->btv; in bttv_try_fmt_vid_cap() local
2329 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2372 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_cap() local
2406 btv->init.fmt = fmt; in bttv_s_fmt_vid_cap()
2407 btv->init.width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2408 btv->init.height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2417 struct bttv *btv = fh->btv; in bttv_s_fmt_vid_overlay() local
2424 return setup_window_lock(fh, btv, &f->fmt.win, 1); in bttv_s_fmt_vid_overlay()
2431 struct bttv *btv = fh->btv; in bttv_querycap() local
2437 strscpy(cap->card, btv->video_dev.name, sizeof(cap->card)); in bttv_querycap()
2442 if (video_is_registered(&btv->vbi_dev)) in bttv_querycap()
2444 if (video_is_registered(&btv->radio_dev)) { in bttv_querycap()
2446 if (btv->has_tea575x) in bttv_querycap()
2454 if (btv->has_saa6588) in bttv_querycap()
2456 if (btv->tuner_type != TUNER_ABSENT) in bttv_querycap()
2515 struct bttv *btv = fh->btv; in bttv_g_fbuf() local
2517 *fb = btv->fbuf; in bttv_g_fbuf()
2528 struct bttv *btv = fh->btv; in bttv_overlay() local
2534 if (unlikely(!btv->fbuf.base)) { in bttv_overlay()
2538 dprintk("%d: overlay: !setup_ok\n", btv->c.nr); in bttv_overlay()
2545 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) in bttv_overlay()
2549 fh->ov.tvnorm = btv->tvnorm; in bttv_overlay()
2551 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_overlay()
2552 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_overlay()
2558 retval = bttv_switch_overlay(btv, fh, new); in bttv_overlay()
2566 struct bttv *btv = fh->btv; in bttv_s_fbuf() local
2597 btv->fbuf.base = fb->base; in bttv_s_fbuf()
2598 btv->fbuf.fmt.width = fb->fmt.width; in bttv_s_fbuf()
2599 btv->fbuf.fmt.height = fb->fmt.height; in bttv_s_fbuf()
2601 btv->fbuf.fmt.bytesperline = fb->fmt.bytesperline; in bttv_s_fbuf()
2603 btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fmt->depth/8; in bttv_s_fbuf()
2607 btv->init.ovfmt = fmt; in bttv_s_fbuf()
2613 btv->init.ov.w.width = fb->fmt.width; in bttv_s_fbuf()
2614 btv->init.ov.w.height = fb->fmt.height; in bttv_s_fbuf()
2624 new->crop = btv->crop[!!fh->do_crop].rect; in bttv_s_fbuf()
2625 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); in bttv_s_fbuf()
2626 retval = bttv_switch_overlay(btv, fh, new); in bttv_s_fbuf()
2649 struct bttv *btv = fh->btv; in bttv_qbuf() local
2652 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_qbuf()
2669 struct bttv *btv = fh->btv; in bttv_streamon() local
2672 if (!check_alloc_btres_lock(btv, fh, res)) in bttv_streamon()
2682 struct bttv *btv = fh->btv; in bttv_streamoff() local
2690 free_btres_lock(btv, fh, res); in bttv_streamoff()
2698 struct bttv *btv = fh->btv; in bttv_g_parm() local
2703 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, in bttv_g_parm()
2713 struct bttv *btv = fh->btv; in bttv_g_tuner() local
2720 bttv_call_all(btv, tuner, g_tuner, t); in bttv_g_tuner()
2726 if (btv->audio_mode_gpio) in bttv_g_tuner()
2727 btv->audio_mode_gpio(btv, t, 0); in bttv_g_tuner()
2736 struct bttv *btv = fh->btv; in bttv_g_pixelaspect() local
2742 *f = bttv_tvnorms[btv->tvnorm].cropcap.pixelaspect; in bttv_g_pixelaspect()
2749 struct bttv *btv = fh->btv; in bttv_g_selection() local
2762 sel->r = btv->crop[!!fh->do_crop].rect; in bttv_g_selection()
2765 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.defrect; in bttv_g_selection()
2768 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_g_selection()
2780 struct bttv *btv = fh->btv; in bttv_s_selection() local
2801 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { in bttv_s_selection()
2805 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_s_selection()
2811 b_top = max(b->top, btv->vbi_end); in bttv_s_selection()
2835 btv->crop[1] = c; in bttv_s_selection()
2841 btv->init.width = c.min_scaled_width; in bttv_s_selection()
2844 btv->init.width = c.max_scaled_width; in bttv_s_selection()
2849 btv->init.height = c.min_scaled_height; in bttv_s_selection()
2852 btv->init.height = c.max_scaled_height; in bttv_s_selection()
2864 if (fh->btv->errors) in bttv_read()
2865 bttv_reinit_bt848(fh->btv); in bttv_read()
2867 fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]); in bttv_read()
2871 if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) { in bttv_read()
2878 free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ); in bttv_read()
2881 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_read()
2909 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) in bttv_poll()
2923 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) in bttv_poll()
2951 struct bttv *btv = video_drvdata(file); in bttv_open() local
2967 btv->c.nr, v4l2_type_names[type]); in bttv_open()
2973 btv->users++; in bttv_open()
2976 *fh = btv->init; in bttv_open()
2983 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
2987 fh, &btv->lock); in bttv_open()
2989 &btv->c.pci->dev, &btv->s_lock, in bttv_open()
2993 fh, &btv->lock); in bttv_open()
2994 set_tvnorm(btv,btv->tvnorm); in bttv_open()
2995 set_input(btv, btv->input, btv->tvnorm); in bttv_open()
2996 audio_mute(btv, btv->mute); in bttv_open()
3012 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); in bttv_open()
3014 bttv_field_count(btv); in bttv_open()
3022 struct bttv *btv = fh->btv; in bttv_release() local
3026 bttv_switch_overlay(btv,fh,NULL); in bttv_release()
3031 free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM); in bttv_release()
3038 free_btres_lock(btv, fh, RESOURCE_VIDEO_READ); in bttv_release()
3044 free_btres_lock(btv,fh,RESOURCE_VBI); in bttv_release()
3053 btv->users--; in bttv_release()
3054 bttv_field_count(btv); in bttv_release()
3056 if (!btv->users) in bttv_release()
3057 audio_mute(btv, btv->mute); in bttv_release()
3071 fh->btv->c.nr, v4l2_type_names[fh->type], in bttv_mmap()
3144 struct bttv *btv = video_drvdata(file); in radio_open() local
3149 dprintk("%d: open called (radio)\n", btv->c.nr); in radio_open()
3156 *fh = btv->init; in radio_open()
3159 btv->radio_user++; in radio_open()
3160 audio_mute(btv, btv->mute); in radio_open()
3170 struct bttv *btv = fh->btv; in radio_release() local
3178 btv->radio_user--; in radio_release()
3180 bttv_call_all(btv, core, command, SAA6588_CMD_CLOSE, &cmd); in radio_release()
3182 if (btv->radio_user == 0) in radio_release()
3183 btv->has_radio_tuner = 0; in radio_release()
3190 struct bttv *btv = fh->btv; in radio_g_tuner() local
3196 radio_enable(btv); in radio_g_tuner()
3198 bttv_call_all(btv, tuner, g_tuner, t); in radio_g_tuner()
3200 if (btv->audio_mode_gpio) in radio_g_tuner()
3201 btv->audio_mode_gpio(btv, t, 0); in radio_g_tuner()
3203 if (btv->has_tea575x) in radio_g_tuner()
3204 return snd_tea575x_g_tuner(&btv->tea, t); in radio_g_tuner()
3213 struct bttv *btv = fh->btv; in radio_s_tuner() local
3218 radio_enable(btv); in radio_s_tuner()
3219 bttv_call_all(btv, tuner, s_tuner, t); in radio_s_tuner()
3227 struct bttv *btv = fh->btv; in radio_s_hw_freq_seek() local
3229 if (btv->has_tea575x) in radio_s_hw_freq_seek()
3230 return snd_tea575x_s_hw_freq_seek(file, &btv->tea, a); in radio_s_hw_freq_seek()
3239 struct bttv *btv = fh->btv; in radio_enum_freq_bands() local
3241 if (btv->has_tea575x) in radio_enum_freq_bands()
3242 return snd_tea575x_enum_freq_bands(&btv->tea, band); in radio_enum_freq_bands()
3251 struct bttv *btv = fh->btv; in radio_read() local
3259 radio_enable(btv); in radio_read()
3261 bttv_call_all(btv, core, command, SAA6588_CMD_READ, &cmd); in radio_read()
3269 struct bttv *btv = fh->btv; in radio_poll() local
3278 radio_enable(btv); in radio_poll()
3282 bttv_call_all(btv, core, command, SAA6588_CMD_POLL, &cmd); in radio_poll()
3355 static void bttv_risc_disasm(struct bttv *btv, in bttv_risc_disasm() argument
3361 btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma); in bttv_risc_disasm()
3364 btv->c.v4l2_dev.name, in bttv_risc_disasm()
3369 btv->c.v4l2_dev.name, in bttv_risc_disasm()
3377 static void bttv_print_riscaddr(struct bttv *btv) in bttv_print_riscaddr() argument
3379 pr_info(" main: %08llx\n", (unsigned long long)btv->main.dma); in bttv_print_riscaddr()
3381 btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0, in bttv_print_riscaddr()
3382 btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0); in bttv_print_riscaddr()
3384 btv->curr.top in bttv_print_riscaddr()
3385 ? (unsigned long long)btv->curr.top->top.dma : 0, in bttv_print_riscaddr()
3386 btv->curr.bottom in bttv_print_riscaddr()
3387 ? (unsigned long long)btv->curr.bottom->bottom.dma : 0); in bttv_print_riscaddr()
3389 btv->screen ? (unsigned long long)btv->screen->top.dma : 0, in bttv_print_riscaddr()
3390 btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0); in bttv_print_riscaddr()
3391 bttv_risc_disasm(btv, &btv->main); in bttv_print_riscaddr()
3432 static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc) in bttv_irq_debug_low_latency() argument
3435 btv->c.nr, in bttv_irq_debug_low_latency()
3436 (unsigned long)btv->main.dma, in bttv_irq_debug_low_latency()
3437 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]), in bttv_irq_debug_low_latency()
3438 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]), in bttv_irq_debug_low_latency()
3443 btv->c.nr); in bttv_irq_debug_low_latency()
3447 btv->c.nr); in bttv_irq_debug_low_latency()
3449 btv->c.nr); in bttv_irq_debug_low_latency()
3454 bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set) in bttv_irq_next_video() argument
3461 if (!list_empty(&btv->capture)) { in bttv_irq_next_video()
3463 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_next_video()
3471 (item->vb.queue.next != &btv->capture)) { in bttv_irq_next_video()
3512 if (NULL != btv->screen) { in bttv_irq_next_video()
3513 if (V4L2_FIELD_HAS_BOTH(btv->screen->vb.field)) { in bttv_irq_next_video()
3515 set->top = btv->screen; in bttv_irq_next_video()
3516 set->bottom = btv->screen; in bttv_irq_next_video()
3519 if (V4L2_FIELD_TOP == btv->screen->vb.field && in bttv_irq_next_video()
3521 set->top = btv->screen; in bttv_irq_next_video()
3523 if (V4L2_FIELD_BOTTOM == btv->screen->vb.field && in bttv_irq_next_video()
3525 set->bottom = btv->screen; in bttv_irq_next_video()
3531 btv->c.nr, set->top, set->bottom, in bttv_irq_next_video()
3532 btv->screen, set->frame_irq, set->top_irq); in bttv_irq_next_video()
3537 bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup, in bttv_irq_wakeup_video() argument
3546 btv->c.nr, wakeup->top); in bttv_irq_wakeup_video()
3548 wakeup->top->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
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()
3565 btv->c.nr, wakeup->bottom); in bttv_irq_wakeup_video()
3567 wakeup->bottom->vb.field_count = btv->field_count; in bttv_irq_wakeup_video()
3575 bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, in bttv_irq_wakeup_vbi() argument
3582 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_vbi()
3589 struct bttv *btv = from_timer(btv, t, timeout); in bttv_irq_timeout() local
3597 btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total, in bttv_irq_timeout()
3603 spin_lock_irqsave(&btv->s_lock,flags); in bttv_irq_timeout()
3607 old = btv->curr; in bttv_irq_timeout()
3608 ovbi = btv->cvbi; in bttv_irq_timeout()
3609 btv->curr = new; in bttv_irq_timeout()
3610 btv->cvbi = NULL; in bttv_irq_timeout()
3611 btv->loop_irq = 0; in bttv_irq_timeout()
3612 bttv_buffer_activate_video(btv, &new); in bttv_irq_timeout()
3613 bttv_buffer_activate_vbi(btv, NULL); in bttv_irq_timeout()
3614 bttv_set_dma(btv, 0); in bttv_irq_timeout()
3617 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_ERROR); in bttv_irq_timeout()
3618 bttv_irq_wakeup_vbi(btv, ovbi, VIDEOBUF_ERROR); in bttv_irq_timeout()
3621 while (!list_empty(&btv->capture)) { in bttv_irq_timeout()
3622 item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3627 while (!list_empty(&btv->vcapture)) { in bttv_irq_timeout()
3628 item = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_timeout()
3634 btv->errors++; in bttv_irq_timeout()
3635 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_irq_timeout()
3639 bttv_irq_wakeup_top(struct bttv *btv) in bttv_irq_wakeup_top() argument
3641 struct bttv_buffer *wakeup = btv->curr.top; in bttv_irq_wakeup_top()
3646 spin_lock(&btv->s_lock); in bttv_irq_wakeup_top()
3647 btv->curr.top_irq = 0; in bttv_irq_wakeup_top()
3648 btv->curr.top = NULL; in bttv_irq_wakeup_top()
3649 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); in bttv_irq_wakeup_top()
3652 wakeup->vb.field_count = btv->field_count; in bttv_irq_wakeup_top()
3655 spin_unlock(&btv->s_lock); in bttv_irq_wakeup_top()
3668 bttv_irq_switch_video(struct bttv *btv) in bttv_irq_switch_video() argument
3674 spin_lock(&btv->s_lock); in bttv_irq_switch_video()
3677 bttv_irq_next_video(btv, &new); in bttv_irq_switch_video()
3679 if ((btv->curr.top && is_active(&btv->curr.top->top, rc)) || in bttv_irq_switch_video()
3680 (btv->curr.bottom && is_active(&btv->curr.bottom->bottom, rc))) { in bttv_irq_switch_video()
3681 btv->framedrop++; in bttv_irq_switch_video()
3683 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_video()
3684 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
3689 old = btv->curr; in bttv_irq_switch_video()
3690 btv->curr = new; in bttv_irq_switch_video()
3691 btv->loop_irq &= ~1; in bttv_irq_switch_video()
3692 bttv_buffer_activate_video(btv, &new); in bttv_irq_switch_video()
3693 bttv_set_dma(btv, 0); in bttv_irq_switch_video()
3696 if (UNSET != btv->new_input) { in bttv_irq_switch_video()
3697 video_mux(btv,btv->new_input); in bttv_irq_switch_video()
3698 btv->new_input = UNSET; in bttv_irq_switch_video()
3702 bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_DONE); in bttv_irq_switch_video()
3703 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
3707 bttv_irq_switch_vbi(struct bttv *btv) in bttv_irq_switch_vbi() argument
3713 spin_lock(&btv->s_lock); in bttv_irq_switch_vbi()
3715 if (!list_empty(&btv->vcapture)) in bttv_irq_switch_vbi()
3716 new = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); in bttv_irq_switch_vbi()
3717 old = btv->cvbi; in bttv_irq_switch_vbi()
3722 btv->framedrop++; in bttv_irq_switch_vbi()
3724 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_vbi()
3725 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
3730 btv->cvbi = new; in bttv_irq_switch_vbi()
3731 btv->loop_irq &= ~4; in bttv_irq_switch_vbi()
3732 bttv_buffer_activate_vbi(btv, new); in bttv_irq_switch_vbi()
3733 bttv_set_dma(btv, 0); in bttv_irq_switch_vbi()
3735 bttv_irq_wakeup_vbi(btv, old, VIDEOBUF_DONE); in bttv_irq_switch_vbi()
3736 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
3744 struct bttv *btv; in bttv_irq() local
3747 btv=(struct bttv *)dev_id; in bttv_irq()
3764 btv->c.nr, count, btv->field_count, in bttv_irq()
3783 btv->field_count++; in bttv_irq()
3785 if ((astat & BT848_INT_GPINT) && btv->remote) { in bttv_irq()
3786 bttv_input_irq(btv); in bttv_irq()
3790 btv->i2c_done = stat; in bttv_irq()
3791 wake_up(&btv->i2c_queue); in bttv_irq()
3795 bttv_irq_switch_vbi(btv); in bttv_irq()
3798 bttv_irq_wakeup_top(btv); in bttv_irq()
3801 bttv_irq_switch_video(btv); in bttv_irq()
3803 if ((astat & BT848_INT_HLOCK) && btv->opt_automute) in bttv_irq()
3805 audio_mux_gpio(btv, btv->audio_input, btv->mute); in bttv_irq()
3809 btv->c.nr, in bttv_irq()
3816 bttv_print_riscaddr(btv); in bttv_irq()
3820 btv->c.nr, btread(BT848_RISC_COUNT)); in bttv_irq()
3822 bttv_print_riscaddr(btv); in bttv_irq()
3832 btv->c.nr); in bttv_irq()
3835 btv->c.nr); in bttv_irq()
3846 btv->irq_total++; in bttv_irq()
3848 btv->irq_me++; in bttv_irq()
3856 static void vdev_init(struct bttv *btv, in vdev_init() argument
3862 vfd->v4l2_dev = &btv->c.v4l2_dev; in vdev_init()
3864 video_set_drvdata(vfd, btv); in vdev_init()
3866 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", in vdev_init()
3867 type_name, bttv_tvcards[btv->c.type].name); in vdev_init()
3868 if (btv->tuner_type == TUNER_ABSENT) { in vdev_init()
3876 static void bttv_unregister_video(struct bttv *btv) in bttv_unregister_video() argument
3878 video_unregister_device(&btv->video_dev); in bttv_unregister_video()
3879 video_unregister_device(&btv->vbi_dev); in bttv_unregister_video()
3880 video_unregister_device(&btv->radio_dev); in bttv_unregister_video()
3884 static int bttv_register_video(struct bttv *btv) in bttv_register_video() argument
3890 vdev_init(btv, &btv->video_dev, &bttv_video_template, "video"); in bttv_register_video()
3891 btv->video_dev.device_caps = V4L2_CAP_VIDEO_CAPTURE | in bttv_register_video()
3893 if (btv->tuner_type != TUNER_ABSENT) in bttv_register_video()
3894 btv->video_dev.device_caps |= V4L2_CAP_TUNER; in bttv_register_video()
3896 btv->video_dev.device_caps |= V4L2_CAP_VIDEO_OVERLAY; in bttv_register_video()
3898 if (video_register_device(&btv->video_dev, VFL_TYPE_VIDEO, in bttv_register_video()
3899 video_nr[btv->c.nr]) < 0) in bttv_register_video()
3902 btv->c.nr, video_device_node_name(&btv->video_dev)); in bttv_register_video()
3903 if (device_create_file(&btv->video_dev.dev, in bttv_register_video()
3905 pr_err("%d: device_create_file 'card' failed\n", btv->c.nr); in bttv_register_video()
3910 vdev_init(btv, &btv->vbi_dev, &bttv_video_template, "vbi"); in bttv_register_video()
3911 btv->vbi_dev.device_caps = V4L2_CAP_VBI_CAPTURE | V4L2_CAP_READWRITE | in bttv_register_video()
3913 if (btv->tuner_type != TUNER_ABSENT) in bttv_register_video()
3914 btv->vbi_dev.device_caps |= V4L2_CAP_TUNER; in bttv_register_video()
3916 if (video_register_device(&btv->vbi_dev, VFL_TYPE_VBI, in bttv_register_video()
3917 vbi_nr[btv->c.nr]) < 0) in bttv_register_video()
3920 btv->c.nr, video_device_node_name(&btv->vbi_dev)); in bttv_register_video()
3922 if (!btv->has_radio) in bttv_register_video()
3925 vdev_init(btv, &btv->radio_dev, &radio_template, "radio"); in bttv_register_video()
3926 btv->radio_dev.device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; in bttv_register_video()
3927 if (btv->has_saa6588) in bttv_register_video()
3928 btv->radio_dev.device_caps |= V4L2_CAP_READWRITE | in bttv_register_video()
3930 if (btv->has_tea575x) in bttv_register_video()
3931 btv->radio_dev.device_caps |= V4L2_CAP_HW_FREQ_SEEK; in bttv_register_video()
3932 btv->radio_dev.ctrl_handler = &btv->radio_ctrl_handler; in bttv_register_video()
3933 if (video_register_device(&btv->radio_dev, VFL_TYPE_RADIO, in bttv_register_video()
3934 radio_nr[btv->c.nr]) < 0) in bttv_register_video()
3937 btv->c.nr, video_device_node_name(&btv->radio_dev)); in bttv_register_video()
3943 bttv_unregister_video(btv); in bttv_register_video()
3970 struct bttv *btv; in bttv_probe() local
3976 bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL); in bttv_probe()
3977 if (btv == NULL) { in bttv_probe()
3981 btv->c.nr = bttv_num; in bttv_probe()
3982 snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name), in bttv_probe()
3983 "bttv%d", btv->c.nr); in bttv_probe()
3986 mutex_init(&btv->lock); in bttv_probe()
3987 spin_lock_init(&btv->s_lock); in bttv_probe()
3988 spin_lock_init(&btv->gpio_lock); in bttv_probe()
3989 init_waitqueue_head(&btv->i2c_queue); in bttv_probe()
3990 INIT_LIST_HEAD(&btv->c.subs); in bttv_probe()
3991 INIT_LIST_HEAD(&btv->capture); in bttv_probe()
3992 INIT_LIST_HEAD(&btv->vcapture); in bttv_probe()
3994 timer_setup(&btv->timeout, bttv_irq_timeout, 0); in bttv_probe()
3996 btv->i2c_rc = -1; in bttv_probe()
3997 btv->tuner_type = UNSET; in bttv_probe()
3998 btv->new_input = UNSET; in bttv_probe()
3999 btv->has_radio=radio[btv->c.nr]; in bttv_probe()
4002 btv->c.pci = dev; in bttv_probe()
4003 btv->id = dev->device; in bttv_probe()
4005 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_probe()
4010 pr_warn("%d: No suitable DMA available\n", btv->c.nr); in bttv_probe()
4016 btv->c.v4l2_dev.name)) { in bttv_probe()
4018 btv->c.nr, in bttv_probe()
4026 result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev); in bttv_probe()
4028 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr); in bttv_probe()
4031 hdl = &btv->ctrl_handler; in bttv_probe()
4033 btv->c.v4l2_dev.ctrl_handler = hdl; in bttv_probe()
4034 v4l2_ctrl_handler_init(&btv->radio_ctrl_handler, 6); in bttv_probe()
4036 btv->revision = dev->revision; in bttv_probe()
4039 bttv_num, btv->id, btv->revision, pci_name(dev), in bttv_probe()
4040 btv->c.pci->irq, lat, in bttv_probe()
4044 btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000); in bttv_probe()
4045 if (NULL == btv->bt848_mmio) { in bttv_probe()
4046 pr_err("%d: ioremap() failed\n", btv->c.nr); in bttv_probe()
4052 bttv_idcard(btv); in bttv_probe()
4056 result = request_irq(btv->c.pci->irq, bttv_irq, in bttv_probe()
4057 IRQF_SHARED, btv->c.v4l2_dev.name, (void *)btv); in bttv_probe()
4060 bttv_num, btv->c.pci->irq); in bttv_probe()
4064 if (0 != bttv_handle_chipset(btv)) { in bttv_probe()
4070 btv->opt_combfilter = combfilter; in bttv_probe()
4073 btv->opt_automute = automute; in bttv_probe()
4076 btv->opt_vcr_hack = vcr_hack; in bttv_probe()
4080 btv->opt_uv_ratio = uv_ratio; in bttv_probe()
4086 btv->init.btv = btv; in bttv_probe()
4087 btv->init.ov.w.width = 320; in bttv_probe()
4088 btv->init.ov.w.height = 240; in bttv_probe()
4089 btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); in bttv_probe()
4090 btv->init.width = 320; in bttv_probe()
4091 btv->init.height = 240; in bttv_probe()
4092 btv->init.ov.w.width = 320; in bttv_probe()
4093 btv->init.ov.w.height = 240; in bttv_probe()
4094 btv->init.ov.field = V4L2_FIELD_INTERLACED; in bttv_probe()
4095 btv->input = 0; in bttv_probe()
4111 if (btv->volume_gpio) in bttv_probe()
4127 bttv_gpio_tracking(btv,"pre-init"); in bttv_probe()
4129 bttv_risc_init_main(btv); in bttv_probe()
4130 init_bt848(btv); in bttv_probe()
4136 bttv_gpio_tracking(btv,"init"); in bttv_probe()
4139 bttv_init_card1(btv); in bttv_probe()
4142 init_bttv_i2c(btv); in bttv_probe()
4145 bttv_init_card2(btv); in bttv_probe()
4146 bttv_init_tuner(btv); in bttv_probe()
4147 if (btv->tuner_type != TUNER_ABSENT) { in bttv_probe()
4148 bttv_set_frequency(btv, &init_freq); in bttv_probe()
4149 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */ in bttv_probe()
4151 btv->std = V4L2_STD_PAL; in bttv_probe()
4152 init_irqreg(btv); in bttv_probe()
4153 if (!bttv_tvcards[btv->c.type].no_video) in bttv_probe()
4160 audio_mute(btv, 1); in bttv_probe()
4163 if (!bttv_tvcards[btv->c.type].no_video) { in bttv_probe()
4164 v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl, in bttv_probe()
4166 if (btv->radio_ctrl_handler.error) { in bttv_probe()
4167 result = btv->radio_ctrl_handler.error; in bttv_probe()
4170 set_input(btv, 0, btv->tvnorm); in bttv_probe()
4171 bttv_crop_reset(&btv->crop[0], btv->tvnorm); in bttv_probe()
4172 btv->crop[1] = btv->crop[0]; /* current = default */ in bttv_probe()
4173 disclaim_vbi_lines(btv); in bttv_probe()
4174 disclaim_video_lines(btv); in bttv_probe()
4175 bttv_register_video(btv); in bttv_probe()
4179 if (bttv_tvcards[btv->c.type].has_dvb) { in bttv_probe()
4180 bttv_sub_add_device(&btv->c, "dvb"); in bttv_probe()
4181 request_modules(btv); in bttv_probe()
4185 init_bttv_i2c_ir(btv); in bttv_probe()
4186 bttv_input_init(btv); in bttv_probe()
4194 free_irq(btv->c.pci->irq,btv); in bttv_probe()
4197 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_probe()
4198 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_probe()
4199 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_probe()
4202 if (btv->bt848_mmio) in bttv_probe()
4203 iounmap(btv->bt848_mmio); in bttv_probe()
4204 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_probe()
4205 pci_resource_len(btv->c.pci,0)); in bttv_probe()
4206 pci_disable_device(btv->c.pci); in bttv_probe()
4209 bttvs[btv->c.nr] = NULL; in bttv_probe()
4210 kfree(btv); in bttv_probe()
4217 struct bttv *btv = to_bttv(v4l2_dev); in bttv_remove() local
4220 pr_info("%d: unloading\n", btv->c.nr); in bttv_remove()
4222 if (bttv_tvcards[btv->c.type].has_dvb) in bttv_remove()
4223 flush_request_modules(btv); in bttv_remove()
4231 bttv_gpio_tracking(btv,"cleanup"); in bttv_remove()
4234 btv->shutdown=1; in bttv_remove()
4235 bttv_input_fini(btv); in bttv_remove()
4236 bttv_sub_del_devices(&btv->c); in bttv_remove()
4239 fini_bttv_i2c(btv); in bttv_remove()
4242 bttv_unregister_video(btv); in bttv_remove()
4245 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_remove()
4246 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_remove()
4247 btcx_riscmem_free(btv->c.pci,&btv->main); in bttv_remove()
4250 free_irq(btv->c.pci->irq,btv); in bttv_remove()
4251 iounmap(btv->bt848_mmio); in bttv_remove()
4252 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_remove()
4253 pci_resource_len(btv->c.pci,0)); in bttv_remove()
4254 pci_disable_device(btv->c.pci); in bttv_remove()
4256 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_remove()
4257 bttvs[btv->c.nr] = NULL; in bttv_remove()
4258 kfree(btv); in bttv_remove()
4266 struct bttv *btv = to_bttv(v4l2_dev); in bttv_suspend() local
4270 dprintk("%d: suspend\n", btv->c.nr); in bttv_suspend()
4273 spin_lock_irqsave(&btv->s_lock,flags); in bttv_suspend()
4275 btv->state.video = btv->curr; in bttv_suspend()
4276 btv->state.vbi = btv->cvbi; in bttv_suspend()
4277 btv->state.loop_irq = btv->loop_irq; in bttv_suspend()
4278 btv->curr = idle; in bttv_suspend()
4279 btv->loop_irq = 0; in bttv_suspend()
4280 bttv_buffer_activate_video(btv, &idle); in bttv_suspend()
4281 bttv_buffer_activate_vbi(btv, NULL); in bttv_suspend()
4282 bttv_set_dma(btv, 0); in bttv_suspend()
4284 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_suspend()
4287 btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN); in bttv_suspend()
4288 btv->state.gpio_data = gpio_read(); in bttv_suspend()
4290 btv->state.disabled = 1; in bttv_suspend()
4297 struct bttv *btv = to_bttv(v4l2_dev); in bttv_resume() local
4300 dprintk("%d: resume\n", btv->c.nr); in bttv_resume()
4302 btv->state.disabled = 0; in bttv_resume()
4305 bttv_reinit_bt848(btv); in bttv_resume()
4306 gpio_inout(0xffffff, btv->state.gpio_enable); in bttv_resume()
4307 gpio_write(btv->state.gpio_data); in bttv_resume()
4310 spin_lock_irqsave(&btv->s_lock,flags); in bttv_resume()
4311 btv->curr = btv->state.video; in bttv_resume()
4312 btv->cvbi = btv->state.vbi; in bttv_resume()
4313 btv->loop_irq = btv->state.loop_irq; in bttv_resume()
4314 bttv_buffer_activate_video(btv, &btv->curr); in bttv_resume()
4315 bttv_buffer_activate_vbi(btv, btv->cvbi); in bttv_resume()
4316 bttv_set_dma(btv, 0); in bttv_resume()
4317 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_resume()