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()
644 int check_alloc_btres_lock(struct bttv *btv, int bit) in check_alloc_btres_lock() argument
653 if (btv->resources & xbits) { in check_alloc_btres_lock()
659 && 0 == (btv->resources & VIDEO_RESOURCES)) { in check_alloc_btres_lock()
661 __s32 top = btv->crop[!!btv->do_crop].rect.top; in check_alloc_btres_lock()
663 if (btv->vbi_end > top) in check_alloc_btres_lock()
668 btv->crop_start = top; in check_alloc_btres_lock()
670 __s32 end = btv->vbi_fmt.end; in check_alloc_btres_lock()
672 if (end > btv->crop_start) in check_alloc_btres_lock()
676 btv->vbi_end = end; in check_alloc_btres_lock()
680 btv->resources |= bit; in check_alloc_btres_lock()
688 int check_btres(struct bttv *btv, int bit) in check_btres() argument
690 return (btv->resources & bit); in check_btres()
694 int locked_btres(struct bttv *btv, int bit) in locked_btres() argument
696 return (btv->resources & bit); in locked_btres()
701 disclaim_vbi_lines(struct bttv *btv) in disclaim_vbi_lines() argument
703 btv->vbi_end = 0; in disclaim_vbi_lines()
708 disclaim_video_lines(struct bttv *btv) in disclaim_video_lines() argument
713 tvnorm = &bttv_tvnorms[btv->tvnorm]; in disclaim_video_lines()
714 btv->crop_start = tvnorm->cropcap.bounds.top in disclaim_video_lines()
728 void free_btres_lock(struct bttv *btv, int bits) in free_btres_lock() argument
730 if ((btv->resources & bits) != bits) { in free_btres_lock()
734 btv->resources &= ~bits; in free_btres_lock()
736 bits = btv->resources; in free_btres_lock()
739 disclaim_video_lines(btv); in free_btres_lock()
742 disclaim_vbi_lines(btv); in free_btres_lock()
758 static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout) in set_pll_freq() argument
780 static void set_pll(struct bttv *btv) in set_pll() argument
784 if (!btv->pll.pll_crystal) in set_pll()
787 if (btv->pll.pll_ofreq == btv->pll.pll_current) { in set_pll()
788 dprintk("%d: PLL: no change required\n", btv->c.nr); in set_pll()
792 if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) { in set_pll()
794 if (btv->pll.pll_current == 0) in set_pll()
798 btv->c.nr, btv->pll.pll_ifreq); in set_pll()
801 btv->pll.pll_current = 0; in set_pll()
807 btv->c.nr, in set_pll()
808 btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
809 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); in set_pll()
819 btv->pll.pll_current = btv->pll.pll_ofreq; in set_pll()
825 btv->pll.pll_current = -1; in set_pll()
832 static void bt848A_set_timing(struct bttv *btv) in bt848A_set_timing() argument
835 int table_idx = bttv_tvnorms[btv->tvnorm].sram; in bt848A_set_timing()
836 int fsc = bttv_tvnorms[btv->tvnorm].Fsc; in bt848A_set_timing()
838 if (btv->input == btv->dig) { in bt848A_set_timing()
840 btv->c.nr,table_idx); in bt848A_set_timing()
850 btv->pll.pll_ofreq = 27000000; in bt848A_set_timing()
852 set_pll(btv); in bt848A_set_timing()
856 btv->pll.pll_ofreq = fsc; in bt848A_set_timing()
857 set_pll(btv); in bt848A_set_timing()
864 static void bt848_bright(struct bttv *btv, int bright) in bt848_bright() argument
869 btv->bright = bright; in bt848_bright()
876 static void bt848_hue(struct bttv *btv, int hue) in bt848_hue() argument
880 btv->hue = hue; in bt848_hue()
887 static void bt848_contrast(struct bttv *btv, int cont) in bt848_contrast() argument
891 btv->contrast = cont; in bt848_contrast()
901 static void bt848_sat(struct bttv *btv, int color) in bt848_sat() argument
905 btv->saturation = color; in bt848_sat()
908 val_u = ((color * btv->opt_uv_ratio) / 50) >> 7; in bt848_sat()
909 val_v = (((color * (100 - btv->opt_uv_ratio) / 50) >>7)*180L)/254; in bt848_sat()
921 video_mux(struct bttv *btv, unsigned int input) in video_mux() argument
925 if (input >= bttv_tvcards[btv->c.type].video_inputs) in video_mux()
929 mask2 = bttv_tvcards[btv->c.type].gpiomask2; in video_mux()
933 if (input == btv->svhs) { in video_mux()
940 mux = bttv_muxsel(btv, input); in video_mux()
942 dprintk("%d: video mux: input=%d mux=%d\n", btv->c.nr, input, mux); in video_mux()
945 if(bttv_tvcards[btv->c.type].muxsel_hook) in video_mux()
946 bttv_tvcards[btv->c.type].muxsel_hook (btv, input); in video_mux()
956 audio_mux_gpio(struct bttv *btv, int input, int mute) in audio_mux_gpio() argument
960 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, in audio_mux_gpio()
961 bttv_tvcards[btv->c.type].gpiomask); in audio_mux_gpio()
965 mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users) in audio_mux_gpio()
966 && !btv->has_radio_tuner); in audio_mux_gpio()
969 gpio_val = bttv_tvcards[btv->c.type].gpiomute; in audio_mux_gpio()
971 gpio_val = bttv_tvcards[btv->c.type].gpiomux[input]; in audio_mux_gpio()
973 switch (btv->c.type) { in audio_mux_gpio()
976 gpio_val = bttv_tda9880_setnorm(btv, gpio_val); in audio_mux_gpio()
980 gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val); in audio_mux_gpio()
984 bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]); in audio_mux_gpio()
988 audio_mute(struct bttv *btv, int mute) in audio_mute() argument
992 audio_mux_gpio(btv, btv->audio_input, mute); in audio_mute()
994 if (btv->sd_msp34xx) { in audio_mute()
995 ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
999 if (btv->sd_tvaudio) { in audio_mute()
1000 ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1004 if (btv->sd_tda7432) { in audio_mute()
1005 ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE); in audio_mute()
1013 audio_input(struct bttv *btv, int input) in audio_input() argument
1015 audio_mux_gpio(btv, input, btv->mute); in audio_input()
1017 if (btv->sd_msp34xx) { in audio_input()
1028 if (btv->radio_uses_msp_demodulator) { in audio_input()
1053 if (btv->c.type == BTTV_BOARD_VOODOOTV_200) in audio_input()
1060 v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, in audio_input()
1063 if (btv->sd_tvaudio) { in audio_input()
1064 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, in audio_input()
1101 set_tvnorm(struct bttv *btv, unsigned int norm) in set_tvnorm() argument
1107 WARN_ON(btv->tvnorm >= BTTV_TVNORMS); in set_tvnorm()
1111 if (memcmp(&bttv_tvnorms[btv->tvnorm].cropcap, &tvnorm->cropcap, in set_tvnorm()
1113 bttv_crop_reset(&btv->crop[0], norm); in set_tvnorm()
1114 btv->crop[1] = btv->crop[0]; /* current = default */ in set_tvnorm()
1116 if (0 == (btv->resources & VIDEO_RESOURCES)) { in set_tvnorm()
1117 btv->crop_start = tvnorm->cropcap.bounds.top in set_tvnorm()
1122 btv->tvnorm = norm; in set_tvnorm()
1130 bt848A_set_timing(btv); in set_tvnorm()
1132 switch (btv->c.type) { in set_tvnorm()
1135 bttv_tda9880_setnorm(btv, gpio_read()); in set_tvnorm()
1139 bttv_call_all(btv, video, s_std, id); in set_tvnorm()
1146 set_input(struct bttv *btv, unsigned int input, unsigned int norm) in set_input() argument
1150 btv->input = input; in set_input()
1152 spin_lock_irqsave(&btv->s_lock,flags); in set_input()
1153 if (btv->curr.frame_irq) { in set_input()
1155 btv->new_input = input; in set_input()
1157 video_mux(btv,input); in set_input()
1159 spin_unlock_irqrestore(&btv->s_lock,flags); in set_input()
1161 video_mux(btv,input); in set_input()
1163 btv->audio_input = (btv->tuner_type != TUNER_ABSENT && input == 0) ? in set_input()
1165 audio_input(btv, btv->audio_input); in set_input()
1166 set_tvnorm(btv, norm); in set_input()
1169 void init_irqreg(struct bttv *btv) in init_irqreg() argument
1174 if (bttv_tvcards[btv->c.type].no_video) { in init_irqreg()
1180 btwrite((btv->triton1) | in init_irqreg()
1181 (btv->gpioirq ? BT848_INT_GPINT : 0) | in init_irqreg()
1191 static void init_bt848(struct bttv *btv) in init_bt848() argument
1193 if (bttv_tvcards[btv->c.type].no_video) { in init_bt848()
1195 init_irqreg(btv); in init_bt848()
1215 v4l2_ctrl_handler_setup(&btv->ctrl_handler); in init_bt848()
1218 init_irqreg(btv); in init_bt848()
1221 static void bttv_reinit_bt848(struct bttv *btv) in bttv_reinit_bt848() argument
1226 pr_info("%d: reset, reinitialize\n", btv->c.nr); in bttv_reinit_bt848()
1227 spin_lock_irqsave(&btv->s_lock,flags); in bttv_reinit_bt848()
1228 btv->errors=0; in bttv_reinit_bt848()
1229 bttv_set_dma(btv,0); in bttv_reinit_bt848()
1230 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_reinit_bt848()
1232 init_bt848(btv); in bttv_reinit_bt848()
1233 btv->pll.pll_current = -1; in bttv_reinit_bt848()
1234 set_input(btv, btv->input, btv->tvnorm); in bttv_reinit_bt848()
1239 struct bttv *btv = container_of(c->handler, struct bttv, ctrl_handler); in bttv_s_ctrl() local
1244 bt848_bright(btv, c->val); in bttv_s_ctrl()
1247 bt848_hue(btv, c->val); in bttv_s_ctrl()
1250 bt848_contrast(btv, c->val); in bttv_s_ctrl()
1253 bt848_sat(btv, c->val); in bttv_s_ctrl()
1265 audio_mute(btv, c->val); in bttv_s_ctrl()
1266 btv->mute = c->val; in bttv_s_ctrl()
1269 btv->volume_gpio(btv, c->val); in bttv_s_ctrl()
1278 btv->opt_combfilter = c->val; in bttv_s_ctrl()
1290 btv->opt_automute = c->val; in bttv_s_ctrl()
1298 btv->opt_vcr_hack = c->val; in bttv_s_ctrl()
1307 btv->opt_uv_ratio = c->val; in bttv_s_ctrl()
1308 bt848_sat(btv, btv->saturation); in bttv_s_ctrl()
1439 void bttv_gpio_tracking(struct bttv *btv, char *comment) in bttv_gpio_tracking() argument
1445 btv->c.nr, outbits, data & outbits, data & ~outbits, comment); in bttv_gpio_tracking()
1469 struct bttv *btv = vb2_get_drv_priv(q); in queue_setup() local
1470 unsigned int size = btv->fmt->depth * btv->width * btv->height >> 3; in queue_setup()
1484 struct bttv *btv = vb2_get_drv_priv(vq); in buf_queue() local
1488 spin_lock_irqsave(&btv->s_lock, flags); in buf_queue()
1489 if (list_empty(&btv->capture)) { in buf_queue()
1490 btv->loop_irq = BT848_RISC_VIDEO; in buf_queue()
1491 if (vb2_is_streaming(&btv->vbiq)) in buf_queue()
1492 btv->loop_irq |= BT848_RISC_VBI; in buf_queue()
1493 bttv_set_dma(btv, BT848_CAP_CTL_CAPTURE_ODD | in buf_queue()
1496 list_add_tail(&buf->list, &btv->capture); in buf_queue()
1497 spin_unlock_irqrestore(&btv->s_lock, flags); in buf_queue()
1503 struct bttv *btv = vb2_get_drv_priv(vq); in buf_prepare() local
1506 unsigned int size = (btv->fmt->depth * btv->width * btv->height) >> 3; in buf_prepare()
1512 if (btv->field != V4L2_FIELD_ALTERNATE) { in buf_prepare()
1513 buf->vbuf.field = btv->field; in buf_prepare()
1514 } else if (btv->field_last == V4L2_FIELD_TOP) { in buf_prepare()
1516 btv->field_last = V4L2_FIELD_BOTTOM; in buf_prepare()
1519 btv->field_last = V4L2_FIELD_TOP; in buf_prepare()
1523 return bttv_buffer_risc(btv, buf); in buf_prepare()
1529 struct bttv *btv = vb2_get_drv_priv(vq); in buf_cleanup() local
1533 btcx_riscmem_free(btv->c.pci, &buf->top); in buf_cleanup()
1534 btcx_riscmem_free(btv->c.pci, &buf->bottom); in buf_cleanup()
1541 struct bttv *btv = vb2_get_drv_priv(q); in start_streaming() local
1543 if (!check_alloc_btres_lock(btv, RESOURCE_VIDEO_STREAM)) { in start_streaming()
1544 if (btv->field_count) in start_streaming()
1546 while (!list_empty(&btv->capture)) { in start_streaming()
1547 buf = list_entry(btv->capture.next, in start_streaming()
1550 buf->vbuf.sequence = (btv->field_count >> 1) + seqnr++; in start_streaming()
1556 if (!vb2_is_streaming(&btv->vbiq)) { in start_streaming()
1557 init_irqreg(btv); in start_streaming()
1558 btv->field_count = 0; in start_streaming()
1560 btv->framedrop = 0; in start_streaming()
1568 struct bttv *btv = vb2_get_drv_priv(q); in stop_streaming() local
1571 spin_lock_irqsave(&btv->s_lock, flags); in stop_streaming()
1572 free_btres_lock(btv, RESOURCE_VIDEO_STREAM); in stop_streaming()
1573 if (!vb2_is_streaming(&btv->vbiq)) { in stop_streaming()
1577 spin_unlock_irqrestore(&btv->s_lock, flags); in stop_streaming()
1591 static void radio_enable(struct bttv *btv) in radio_enable() argument
1594 if (!btv->has_radio_tuner) { in radio_enable()
1595 btv->has_radio_tuner = 1; in radio_enable()
1596 bttv_call_all(btv, tuner, s_radio); in radio_enable()
1597 btv->audio_input = TVAUDIO_INPUT_RADIO; in radio_enable()
1598 audio_input(btv, btv->audio_input); in radio_enable()
1604 struct bttv *btv = video_drvdata(file); in bttv_s_std() local
1612 btv->std = id; in bttv_s_std()
1613 set_tvnorm(btv, i); in bttv_s_std()
1619 struct bttv *btv = video_drvdata(file); in bttv_g_std() local
1621 *id = btv->std; in bttv_g_std()
1627 struct bttv *btv = video_drvdata(file); in bttv_querystd() local
1639 struct bttv *btv = video_drvdata(file); in bttv_enum_input() local
1641 if (i->index >= bttv_tvcards[btv->c.type].video_inputs) in bttv_enum_input()
1647 if (btv->tuner_type != TUNER_ABSENT && i->index == 0) { in bttv_enum_input()
1651 } else if (i->index == btv->svhs) { in bttv_enum_input()
1657 if (i->index == btv->input) { in bttv_enum_input()
1671 struct bttv *btv = video_drvdata(file); in bttv_g_input() local
1673 *i = btv->input; in bttv_g_input()
1680 struct bttv *btv = video_drvdata(file); in bttv_s_input() local
1682 if (i >= bttv_tvcards[btv->c.type].video_inputs) in bttv_s_input()
1685 set_input(btv, i, btv->tvnorm); in bttv_s_input()
1692 struct bttv *btv = video_drvdata(file); in bttv_s_tuner() local
1697 bttv_call_all(btv, tuner, s_tuner, t); in bttv_s_tuner()
1699 if (btv->audio_mode_gpio) { in bttv_s_tuner()
1702 btv->audio_mode_gpio(btv, ©, 1); in bttv_s_tuner()
1710 struct bttv *btv = video_drvdata(file); in bttv_g_frequency() local
1716 radio_enable(btv); in bttv_g_frequency()
1718 btv->radio_freq : btv->tv_freq; in bttv_g_frequency()
1723 static void bttv_set_frequency(struct bttv *btv, const struct v4l2_frequency *f) in bttv_set_frequency() argument
1727 bttv_call_all(btv, tuner, s_frequency, f); in bttv_set_frequency()
1730 bttv_call_all(btv, tuner, g_frequency, &new_freq); in bttv_set_frequency()
1732 radio_enable(btv); in bttv_set_frequency()
1733 btv->radio_freq = new_freq.frequency; in bttv_set_frequency()
1734 if (btv->has_tea575x) { in bttv_set_frequency()
1735 btv->tea.freq = btv->radio_freq; in bttv_set_frequency()
1736 snd_tea575x_set_freq(&btv->tea); in bttv_set_frequency()
1739 btv->tv_freq = new_freq.frequency; in bttv_set_frequency()
1746 struct bttv *btv = video_drvdata(file); in bttv_s_frequency() local
1751 bttv_set_frequency(btv, f); in bttv_s_frequency()
1758 struct bttv *btv = video_drvdata(file); in bttv_log_status() local
1760 v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name); in bttv_log_status()
1761 bttv_call_all(btv, core, log_status); in bttv_log_status()
1769 struct bttv *btv = video_drvdata(file); in bttv_g_register() local
1782 struct bttv *btv = video_drvdata(file); in bttv_s_register() local
1842 limit_scaled_size_lock(struct bttv *btv, __s32 *width, __s32 *height, in limit_scaled_size_lock() argument
1861 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in limit_scaled_size_lock()
1864 c = &btv->crop[!!btv->do_crop]; in limit_scaled_size_lock()
1866 if (btv->do_crop in limit_scaled_size_lock()
1869 && !locked_btres(btv, VIDEO_RESOURCES)) { in limit_scaled_size_lock()
1882 if (btv->vbi_end > b->top) { in limit_scaled_size_lock()
1883 max_height -= btv->vbi_end - b->top; in limit_scaled_size_lock()
1890 if (btv->vbi_end > c->rect.top) in limit_scaled_size_lock()
1918 if (btv->vbi_end > c->rect.top) { in limit_scaled_size_lock()
1920 c->rect.top = btv->vbi_end; in limit_scaled_size_lock()
1940 static int bttv_switch_type(struct bttv *btv, enum v4l2_buf_type type) in bttv_switch_type() argument
1947 q = &btv->capq; in bttv_switch_type()
1951 q = &btv->vbiq; in bttv_switch_type()
1959 if (check_btres(btv, res)) in bttv_switch_type()
1963 btv->type = type; in bttv_switch_type()
1989 struct bttv *btv = video_drvdata(file); in bttv_g_fmt_vid_cap() local
1991 pix_format_set_size(&f->fmt.pix, btv->fmt, btv->width, btv->height); in bttv_g_fmt_vid_cap()
1992 f->fmt.pix.field = btv->field; in bttv_g_fmt_vid_cap()
1993 f->fmt.pix.pixelformat = btv->fmt->fourcc; in bttv_g_fmt_vid_cap()
2016 struct bttv *btv = video_drvdata(file); in bttv_try_fmt_vid_cap() local
2043 height2 = btv->crop[!!btv->do_crop].rect.height >> 1; in bttv_try_fmt_vid_cap()
2054 rc = limit_scaled_size_lock(btv, &width, &height, field, width_mask, in bttv_try_fmt_vid_cap()
2072 struct bttv *btv = video_drvdata(file); in bttv_s_fmt_vid_cap() local
2077 retval = bttv_switch_type(btv, f->type); in bttv_s_fmt_vid_cap()
2091 retval = limit_scaled_size_lock(btv, &width, &height, f->fmt.pix.field, in bttv_s_fmt_vid_cap()
2099 btv->fmt = fmt; in bttv_s_fmt_vid_cap()
2100 btv->width = f->fmt.pix.width; in bttv_s_fmt_vid_cap()
2101 btv->height = f->fmt.pix.height; in bttv_s_fmt_vid_cap()
2102 btv->field = f->fmt.pix.field; in bttv_s_fmt_vid_cap()
2109 btv->field_last = V4L2_FIELD_BOTTOM; in bttv_s_fmt_vid_cap()
2117 struct bttv *btv = video_drvdata(file); in bttv_querycap() local
2123 strscpy(cap->card, btv->video_dev.name, sizeof(cap->card)); in bttv_querycap()
2126 if (video_is_registered(&btv->vbi_dev)) in bttv_querycap()
2128 if (video_is_registered(&btv->radio_dev)) { in bttv_querycap()
2130 if (btv->has_tea575x) in bttv_querycap()
2138 if (btv->has_saa6588) in bttv_querycap()
2140 if (btv->tuner_type != TUNER_ABSENT) in bttv_querycap()
2167 struct bttv *btv = video_drvdata(file); in bttv_g_parm() local
2172 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, in bttv_g_parm()
2181 struct bttv *btv = video_drvdata(file); in bttv_g_tuner() local
2188 bttv_call_all(btv, tuner, g_tuner, t); in bttv_g_tuner()
2194 if (btv->audio_mode_gpio) in bttv_g_tuner()
2195 btv->audio_mode_gpio(btv, t, 0); in bttv_g_tuner()
2203 struct bttv *btv = video_drvdata(file); in bttv_g_pixelaspect() local
2209 *f = bttv_tvnorms[btv->tvnorm].cropcap.pixelaspect; in bttv_g_pixelaspect()
2215 struct bttv *btv = video_drvdata(file); in bttv_g_selection() local
2222 sel->r = btv->crop[!!btv->do_crop].rect; in bttv_g_selection()
2225 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.defrect; in bttv_g_selection()
2228 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_g_selection()
2239 struct bttv *btv = video_drvdata(file); in bttv_s_selection() local
2259 if (locked_btres(btv, VIDEO_RESOURCES)) in bttv_s_selection()
2262 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; in bttv_s_selection()
2268 b_top = max(b->top, btv->vbi_end); in bttv_s_selection()
2292 btv->crop[1] = c; in bttv_s_selection()
2294 btv->do_crop = 1; in bttv_s_selection()
2296 if (btv->width < c.min_scaled_width) in bttv_s_selection()
2297 btv->width = c.min_scaled_width; in bttv_s_selection()
2298 else if (btv->width > c.max_scaled_width) in bttv_s_selection()
2299 btv->width = c.max_scaled_width; in bttv_s_selection()
2301 if (btv->height < c.min_scaled_height) in bttv_s_selection()
2302 btv->height = c.min_scaled_height; in bttv_s_selection()
2303 else if (btv->height > c.max_scaled_height) in bttv_s_selection()
2304 btv->height = c.max_scaled_height; in bttv_s_selection()
2371 struct bttv *btv = video_drvdata(file); in radio_open() local
2378 dprintk("%d: open called (radio)\n", btv->c.nr); in radio_open()
2380 btv->radio_user++; in radio_open()
2381 audio_mute(btv, btv->mute); in radio_open()
2388 struct bttv *btv = video_drvdata(file); in radio_release() local
2391 btv->radio_user--; in radio_release()
2393 bttv_call_all(btv, core, command, SAA6588_CMD_CLOSE, &cmd); in radio_release()
2395 if (btv->radio_user == 0) in radio_release()
2396 btv->has_radio_tuner = 0; in radio_release()
2405 struct bttv *btv = video_drvdata(file); in radio_g_tuner() local
2411 radio_enable(btv); in radio_g_tuner()
2413 bttv_call_all(btv, tuner, g_tuner, t); in radio_g_tuner()
2415 if (btv->audio_mode_gpio) in radio_g_tuner()
2416 btv->audio_mode_gpio(btv, t, 0); in radio_g_tuner()
2418 if (btv->has_tea575x) in radio_g_tuner()
2419 return snd_tea575x_g_tuner(&btv->tea, t); in radio_g_tuner()
2427 struct bttv *btv = video_drvdata(file); in radio_s_tuner() local
2432 radio_enable(btv); in radio_s_tuner()
2433 bttv_call_all(btv, tuner, s_tuner, t); in radio_s_tuner()
2440 struct bttv *btv = video_drvdata(file); in radio_s_hw_freq_seek() local
2442 if (btv->has_tea575x) in radio_s_hw_freq_seek()
2443 return snd_tea575x_s_hw_freq_seek(file, &btv->tea, a); in radio_s_hw_freq_seek()
2451 struct bttv *btv = video_drvdata(file); in radio_enum_freq_bands() local
2453 if (btv->has_tea575x) in radio_enum_freq_bands()
2454 return snd_tea575x_enum_freq_bands(&btv->tea, band); in radio_enum_freq_bands()
2462 struct bttv *btv = video_drvdata(file); in radio_read() local
2470 radio_enable(btv); in radio_read()
2472 bttv_call_all(btv, core, command, SAA6588_CMD_READ, &cmd); in radio_read()
2479 struct bttv *btv = video_drvdata(file); in radio_poll() local
2483 radio_enable(btv); in radio_poll()
2487 bttv_call_all(btv, core, command, SAA6588_CMD_POLL, &cmd); in radio_poll()
2560 static void bttv_risc_disasm(struct bttv *btv, in bttv_risc_disasm() argument
2566 btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma); in bttv_risc_disasm()
2569 btv->c.v4l2_dev.name, in bttv_risc_disasm()
2574 btv->c.v4l2_dev.name, in bttv_risc_disasm()
2582 static void bttv_print_riscaddr(struct bttv *btv) in bttv_print_riscaddr() argument
2584 pr_info(" main: %08llx\n", (unsigned long long)btv->main.dma); in bttv_print_riscaddr()
2586 btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0, in bttv_print_riscaddr()
2587 btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0); in bttv_print_riscaddr()
2589 btv->curr.top in bttv_print_riscaddr()
2590 ? (unsigned long long)btv->curr.top->top.dma : 0, in bttv_print_riscaddr()
2591 btv->curr.bottom in bttv_print_riscaddr()
2592 ? (unsigned long long)btv->curr.bottom->bottom.dma : 0); in bttv_print_riscaddr()
2593 bttv_risc_disasm(btv, &btv->main); in bttv_print_riscaddr()
2634 static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc) in bttv_irq_debug_low_latency() argument
2637 btv->c.nr, in bttv_irq_debug_low_latency()
2638 (unsigned long)btv->main.dma, in bttv_irq_debug_low_latency()
2639 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]), in bttv_irq_debug_low_latency()
2640 (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]), in bttv_irq_debug_low_latency()
2645 btv->c.nr); in bttv_irq_debug_low_latency()
2649 btv->c.nr); in bttv_irq_debug_low_latency()
2651 btv->c.nr); in bttv_irq_debug_low_latency()
2656 bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set) in bttv_irq_next_video() argument
2663 if (!list_empty(&btv->capture)) { in bttv_irq_next_video()
2665 item = list_entry(btv->capture.next, struct bttv_buffer, list); in bttv_irq_next_video()
2674 item->list.next != &btv->capture) { in bttv_irq_next_video()
2721 btv->c.nr, set->top, set->bottom, in bttv_irq_next_video()
2727 bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup, in bttv_irq_wakeup_video() argument
2736 btv->c.nr, wakeup->top); in bttv_irq_wakeup_video()
2738 wakeup->top->vbuf.sequence = btv->field_count >> 1; in bttv_irq_wakeup_video()
2740 if (btv->field_count == 0) in bttv_irq_wakeup_video()
2747 btv->c.nr, wakeup->top); in bttv_irq_wakeup_video()
2749 wakeup->top->vbuf.sequence = btv->field_count >> 1; in bttv_irq_wakeup_video()
2751 if (btv->field_count == 0) in bttv_irq_wakeup_video()
2757 btv->c.nr, wakeup->bottom); in bttv_irq_wakeup_video()
2759 wakeup->bottom->vbuf.sequence = btv->field_count >> 1; in bttv_irq_wakeup_video()
2761 if (btv->field_count == 0) in bttv_irq_wakeup_video()
2768 bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, in bttv_irq_wakeup_vbi() argument
2774 wakeup->vbuf.sequence = btv->field_count >> 1; in bttv_irq_wakeup_vbi()
2797 if (btv->field_count == 0) in bttv_irq_wakeup_vbi()
2803 struct bttv *btv = from_timer(btv, t, timeout); in bttv_irq_timeout() local
2812 btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total, in bttv_irq_timeout()
2818 spin_lock_irqsave(&btv->s_lock,flags); in bttv_irq_timeout()
2822 old = btv->curr; in bttv_irq_timeout()
2823 ovbi = btv->cvbi; in bttv_irq_timeout()
2824 btv->curr = new; in bttv_irq_timeout()
2825 btv->cvbi = NULL; in bttv_irq_timeout()
2826 btv->loop_irq = 0; in bttv_irq_timeout()
2827 bttv_buffer_activate_video(btv, &new); in bttv_irq_timeout()
2828 bttv_buffer_activate_vbi(btv, NULL); in bttv_irq_timeout()
2829 bttv_set_dma(btv, 0); in bttv_irq_timeout()
2832 bttv_irq_wakeup_video(btv, &old, &new, VB2_BUF_STATE_DONE); in bttv_irq_timeout()
2833 bttv_irq_wakeup_vbi(btv, ovbi, VB2_BUF_STATE_DONE); in bttv_irq_timeout()
2836 if (btv->field_count) in bttv_irq_timeout()
2838 while (!list_empty(&btv->capture)) { in bttv_irq_timeout()
2839 item = list_entry(btv->capture.next, struct bttv_buffer, list); in bttv_irq_timeout()
2842 item->vbuf.sequence = (btv->field_count >> 1) + seqnr++; in bttv_irq_timeout()
2845 while (!list_empty(&btv->vcapture)) { in bttv_irq_timeout()
2846 item = list_entry(btv->vcapture.next, struct bttv_buffer, list); in bttv_irq_timeout()
2849 item->vbuf.sequence = (btv->field_count >> 1) + seqnr++; in bttv_irq_timeout()
2853 btv->errors++; in bttv_irq_timeout()
2854 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_irq_timeout()
2858 bttv_irq_wakeup_top(struct bttv *btv) in bttv_irq_wakeup_top() argument
2860 struct bttv_buffer *wakeup = btv->curr.top; in bttv_irq_wakeup_top()
2865 spin_lock(&btv->s_lock); in bttv_irq_wakeup_top()
2866 btv->curr.top_irq = 0; in bttv_irq_wakeup_top()
2867 btv->curr.top = NULL; in bttv_irq_wakeup_top()
2868 bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); in bttv_irq_wakeup_top()
2870 wakeup->vbuf.sequence = btv->field_count >> 1; in bttv_irq_wakeup_top()
2872 if (btv->field_count == 0) in bttv_irq_wakeup_top()
2874 spin_unlock(&btv->s_lock); in bttv_irq_wakeup_top()
2887 bttv_irq_switch_video(struct bttv *btv) in bttv_irq_switch_video() argument
2893 spin_lock(&btv->s_lock); in bttv_irq_switch_video()
2896 bttv_irq_next_video(btv, &new); in bttv_irq_switch_video()
2898 if ((btv->curr.top && is_active(&btv->curr.top->top, rc)) || in bttv_irq_switch_video()
2899 (btv->curr.bottom && is_active(&btv->curr.bottom->bottom, rc))) { in bttv_irq_switch_video()
2900 btv->framedrop++; in bttv_irq_switch_video()
2902 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_video()
2903 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
2908 old = btv->curr; in bttv_irq_switch_video()
2909 btv->curr = new; in bttv_irq_switch_video()
2910 btv->loop_irq &= ~BT848_RISC_VIDEO; in bttv_irq_switch_video()
2911 bttv_buffer_activate_video(btv, &new); in bttv_irq_switch_video()
2912 bttv_set_dma(btv, 0); in bttv_irq_switch_video()
2915 if (UNSET != btv->new_input) { in bttv_irq_switch_video()
2916 video_mux(btv,btv->new_input); in bttv_irq_switch_video()
2917 btv->new_input = UNSET; in bttv_irq_switch_video()
2921 bttv_irq_wakeup_video(btv, &old, &new, VB2_BUF_STATE_DONE); in bttv_irq_switch_video()
2922 spin_unlock(&btv->s_lock); in bttv_irq_switch_video()
2926 bttv_irq_switch_vbi(struct bttv *btv) in bttv_irq_switch_vbi() argument
2932 spin_lock(&btv->s_lock); in bttv_irq_switch_vbi()
2934 if (!list_empty(&btv->vcapture)) in bttv_irq_switch_vbi()
2935 new = list_entry(btv->vcapture.next, struct bttv_buffer, list); in bttv_irq_switch_vbi()
2936 old = btv->cvbi; in bttv_irq_switch_vbi()
2941 btv->framedrop++; in bttv_irq_switch_vbi()
2943 bttv_irq_debug_low_latency(btv, rc); in bttv_irq_switch_vbi()
2944 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
2949 btv->cvbi = new; in bttv_irq_switch_vbi()
2950 btv->loop_irq &= ~BT848_RISC_VBI; in bttv_irq_switch_vbi()
2951 bttv_buffer_activate_vbi(btv, new); in bttv_irq_switch_vbi()
2952 bttv_set_dma(btv, 0); in bttv_irq_switch_vbi()
2954 bttv_irq_wakeup_vbi(btv, old, VB2_BUF_STATE_DONE); in bttv_irq_switch_vbi()
2955 spin_unlock(&btv->s_lock); in bttv_irq_switch_vbi()
2963 struct bttv *btv; in bttv_irq() local
2966 btv=(struct bttv *)dev_id; in bttv_irq()
2983 btv->c.nr, count, btv->field_count, in bttv_irq()
3002 btv->field_count++; in bttv_irq()
3004 if ((astat & BT848_INT_GPINT) && btv->remote) { in bttv_irq()
3005 bttv_input_irq(btv); in bttv_irq()
3009 btv->i2c_done = stat; in bttv_irq()
3010 wake_up(&btv->i2c_queue); in bttv_irq()
3014 bttv_irq_switch_vbi(btv); in bttv_irq()
3017 bttv_irq_wakeup_top(btv); in bttv_irq()
3020 bttv_irq_switch_video(btv); in bttv_irq()
3022 if ((astat & BT848_INT_HLOCK) && btv->opt_automute) in bttv_irq()
3024 audio_mux_gpio(btv, btv->audio_input, btv->mute); in bttv_irq()
3028 btv->c.nr, in bttv_irq()
3035 bttv_print_riscaddr(btv); in bttv_irq()
3039 btv->c.nr, btread(BT848_RISC_COUNT)); in bttv_irq()
3041 bttv_print_riscaddr(btv); in bttv_irq()
3051 btv->c.nr); in bttv_irq()
3054 btv->c.nr); in bttv_irq()
3065 btv->irq_total++; in bttv_irq()
3067 btv->irq_me++; in bttv_irq()
3075 static int vdev_init(struct bttv *btv, struct video_device *vfd, in vdev_init() argument
3082 vfd->v4l2_dev = &btv->c.v4l2_dev; in vdev_init()
3084 video_set_drvdata(vfd, btv); in vdev_init()
3086 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", in vdev_init()
3087 type_name, bttv_tvcards[btv->c.type].name); in vdev_init()
3088 if (btv->tuner_type == TUNER_ABSENT) { in vdev_init()
3099 q = &btv->capq; in vdev_init()
3103 q = &btv->vbiq; in vdev_init()
3112 q->drv_priv = btv; in vdev_init()
3115 q->lock = &btv->lock; in vdev_init()
3117 q->dev = &btv->c.pci->dev; in vdev_init()
3126 static void bttv_unregister_video(struct bttv *btv) in bttv_unregister_video() argument
3128 video_unregister_device(&btv->video_dev); in bttv_unregister_video()
3129 video_unregister_device(&btv->vbi_dev); in bttv_unregister_video()
3130 video_unregister_device(&btv->radio_dev); in bttv_unregister_video()
3134 static int bttv_register_video(struct bttv *btv) in bttv_register_video() argument
3137 vdev_init(btv, &btv->video_dev, &bttv_video_template, "video"); in bttv_register_video()
3138 btv->video_dev.device_caps = V4L2_CAP_VIDEO_CAPTURE | in bttv_register_video()
3140 if (btv->tuner_type != TUNER_ABSENT) in bttv_register_video()
3141 btv->video_dev.device_caps |= V4L2_CAP_TUNER; in bttv_register_video()
3143 if (video_register_device(&btv->video_dev, VFL_TYPE_VIDEO, in bttv_register_video()
3144 video_nr[btv->c.nr]) < 0) in bttv_register_video()
3147 btv->c.nr, video_device_node_name(&btv->video_dev)); in bttv_register_video()
3148 if (device_create_file(&btv->video_dev.dev, in bttv_register_video()
3150 pr_err("%d: device_create_file 'card' failed\n", btv->c.nr); in bttv_register_video()
3155 vdev_init(btv, &btv->vbi_dev, &bttv_video_template, "vbi"); in bttv_register_video()
3156 btv->vbi_dev.device_caps = V4L2_CAP_VBI_CAPTURE | V4L2_CAP_READWRITE | in bttv_register_video()
3158 if (btv->tuner_type != TUNER_ABSENT) in bttv_register_video()
3159 btv->vbi_dev.device_caps |= V4L2_CAP_TUNER; in bttv_register_video()
3161 if (video_register_device(&btv->vbi_dev, VFL_TYPE_VBI, in bttv_register_video()
3162 vbi_nr[btv->c.nr]) < 0) in bttv_register_video()
3165 btv->c.nr, video_device_node_name(&btv->vbi_dev)); in bttv_register_video()
3167 if (!btv->has_radio) in bttv_register_video()
3170 vdev_init(btv, &btv->radio_dev, &radio_template, "radio"); in bttv_register_video()
3171 btv->radio_dev.device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; in bttv_register_video()
3172 if (btv->has_saa6588) in bttv_register_video()
3173 btv->radio_dev.device_caps |= V4L2_CAP_READWRITE | in bttv_register_video()
3175 if (btv->has_tea575x) in bttv_register_video()
3176 btv->radio_dev.device_caps |= V4L2_CAP_HW_FREQ_SEEK; in bttv_register_video()
3177 btv->radio_dev.ctrl_handler = &btv->radio_ctrl_handler; in bttv_register_video()
3178 if (video_register_device(&btv->radio_dev, VFL_TYPE_RADIO, in bttv_register_video()
3179 radio_nr[btv->c.nr]) < 0) in bttv_register_video()
3182 btv->c.nr, video_device_node_name(&btv->radio_dev)); in bttv_register_video()
3188 bttv_unregister_video(btv); in bttv_register_video()
3215 struct bttv *btv; in bttv_probe() local
3221 bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL); in bttv_probe()
3222 if (btv == NULL) { in bttv_probe()
3226 btv->c.nr = bttv_num; in bttv_probe()
3227 snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name), in bttv_probe()
3228 "bttv%d", btv->c.nr); in bttv_probe()
3231 mutex_init(&btv->lock); in bttv_probe()
3232 spin_lock_init(&btv->s_lock); in bttv_probe()
3233 spin_lock_init(&btv->gpio_lock); in bttv_probe()
3234 init_waitqueue_head(&btv->i2c_queue); in bttv_probe()
3235 INIT_LIST_HEAD(&btv->c.subs); in bttv_probe()
3236 INIT_LIST_HEAD(&btv->capture); in bttv_probe()
3237 INIT_LIST_HEAD(&btv->vcapture); in bttv_probe()
3239 timer_setup(&btv->timeout, bttv_irq_timeout, 0); in bttv_probe()
3241 btv->i2c_rc = -1; in bttv_probe()
3242 btv->tuner_type = UNSET; in bttv_probe()
3243 btv->new_input = UNSET; in bttv_probe()
3244 btv->has_radio=radio[btv->c.nr]; in bttv_probe()
3247 btv->c.pci = dev; in bttv_probe()
3248 btv->id = dev->device; in bttv_probe()
3250 pr_warn("%d: Can't enable device\n", btv->c.nr); in bttv_probe()
3255 pr_warn("%d: No suitable DMA available\n", btv->c.nr); in bttv_probe()
3261 btv->c.v4l2_dev.name)) { in bttv_probe()
3263 btv->c.nr, in bttv_probe()
3271 result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev); in bttv_probe()
3273 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr); in bttv_probe()
3276 hdl = &btv->ctrl_handler; in bttv_probe()
3278 btv->c.v4l2_dev.ctrl_handler = hdl; in bttv_probe()
3279 v4l2_ctrl_handler_init(&btv->radio_ctrl_handler, 6); in bttv_probe()
3281 btv->revision = dev->revision; in bttv_probe()
3284 bttv_num, btv->id, btv->revision, pci_name(dev), in bttv_probe()
3285 btv->c.pci->irq, lat, in bttv_probe()
3289 btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000); in bttv_probe()
3290 if (NULL == btv->bt848_mmio) { in bttv_probe()
3291 pr_err("%d: ioremap() failed\n", btv->c.nr); in bttv_probe()
3297 bttv_idcard(btv); in bttv_probe()
3301 result = request_irq(btv->c.pci->irq, bttv_irq, in bttv_probe()
3302 IRQF_SHARED, btv->c.v4l2_dev.name, (void *)btv); in bttv_probe()
3305 bttv_num, btv->c.pci->irq); in bttv_probe()
3309 if (0 != bttv_handle_chipset(btv)) { in bttv_probe()
3315 btv->opt_combfilter = combfilter; in bttv_probe()
3318 btv->opt_automute = automute; in bttv_probe()
3321 btv->opt_vcr_hack = vcr_hack; in bttv_probe()
3325 btv->opt_uv_ratio = uv_ratio; in bttv_probe()
3331 btv->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); in bttv_probe()
3332 btv->width = 320; in bttv_probe()
3333 btv->height = 240; in bttv_probe()
3334 btv->field = V4L2_FIELD_INTERLACED; in bttv_probe()
3335 btv->input = 0; in bttv_probe()
3336 btv->tvnorm = 0; /* Index into bttv_tvnorms[] i.e. PAL. */ in bttv_probe()
3337 bttv_vbi_fmt_reset(&btv->vbi_fmt, btv->tvnorm); in bttv_probe()
3338 btv->vbi_count[0] = VBI_DEFLINES; in bttv_probe()
3339 btv->vbi_count[1] = VBI_DEFLINES; in bttv_probe()
3340 btv->do_crop = 0; in bttv_probe()
3356 if (btv->volume_gpio) in bttv_probe()
3372 bttv_gpio_tracking(btv,"pre-init"); in bttv_probe()
3374 bttv_risc_init_main(btv); in bttv_probe()
3375 init_bt848(btv); in bttv_probe()
3381 bttv_gpio_tracking(btv,"init"); in bttv_probe()
3384 bttv_init_card1(btv); in bttv_probe()
3387 init_bttv_i2c(btv); in bttv_probe()
3390 bttv_init_card2(btv); in bttv_probe()
3391 bttv_init_tuner(btv); in bttv_probe()
3392 if (btv->tuner_type != TUNER_ABSENT) { in bttv_probe()
3393 bttv_set_frequency(btv, &init_freq); in bttv_probe()
3394 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */ in bttv_probe()
3396 btv->std = V4L2_STD_PAL; in bttv_probe()
3397 init_irqreg(btv); in bttv_probe()
3398 if (!bttv_tvcards[btv->c.type].no_video) in bttv_probe()
3405 audio_mute(btv, 1); in bttv_probe()
3408 if (!bttv_tvcards[btv->c.type].no_video) { in bttv_probe()
3409 v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl, in bttv_probe()
3411 if (btv->radio_ctrl_handler.error) { in bttv_probe()
3412 result = btv->radio_ctrl_handler.error; in bttv_probe()
3415 set_input(btv, btv->input, btv->tvnorm); in bttv_probe()
3416 bttv_crop_reset(&btv->crop[0], btv->tvnorm); in bttv_probe()
3417 btv->crop[1] = btv->crop[0]; /* current = default */ in bttv_probe()
3418 disclaim_vbi_lines(btv); in bttv_probe()
3419 disclaim_video_lines(btv); in bttv_probe()
3420 bttv_register_video(btv); in bttv_probe()
3424 if (bttv_tvcards[btv->c.type].has_dvb) { in bttv_probe()
3425 bttv_sub_add_device(&btv->c, "dvb"); in bttv_probe()
3426 request_modules(btv); in bttv_probe()
3430 init_bttv_i2c_ir(btv); in bttv_probe()
3431 bttv_input_init(btv); in bttv_probe()
3439 free_irq(btv->c.pci->irq,btv); in bttv_probe()
3442 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_probe()
3443 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_probe()
3444 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_probe()
3447 if (btv->bt848_mmio) in bttv_probe()
3448 iounmap(btv->bt848_mmio); in bttv_probe()
3449 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_probe()
3450 pci_resource_len(btv->c.pci,0)); in bttv_probe()
3451 pci_disable_device(btv->c.pci); in bttv_probe()
3454 bttvs[btv->c.nr] = NULL; in bttv_probe()
3455 kfree(btv); in bttv_probe()
3462 struct bttv *btv = to_bttv(v4l2_dev); in bttv_remove() local
3465 pr_info("%d: unloading\n", btv->c.nr); in bttv_remove()
3467 if (bttv_tvcards[btv->c.type].has_dvb) in bttv_remove()
3468 flush_request_modules(btv); in bttv_remove()
3476 bttv_gpio_tracking(btv,"cleanup"); in bttv_remove()
3479 btv->shutdown=1; in bttv_remove()
3480 bttv_input_fini(btv); in bttv_remove()
3481 bttv_sub_del_devices(&btv->c); in bttv_remove()
3484 fini_bttv_i2c(btv); in bttv_remove()
3487 bttv_unregister_video(btv); in bttv_remove()
3490 v4l2_ctrl_handler_free(&btv->ctrl_handler); in bttv_remove()
3491 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler); in bttv_remove()
3492 btcx_riscmem_free(btv->c.pci,&btv->main); in bttv_remove()
3495 free_irq(btv->c.pci->irq,btv); in bttv_remove()
3496 del_timer_sync(&btv->timeout); in bttv_remove()
3497 iounmap(btv->bt848_mmio); in bttv_remove()
3498 release_mem_region(pci_resource_start(btv->c.pci,0), in bttv_remove()
3499 pci_resource_len(btv->c.pci,0)); in bttv_remove()
3500 pci_disable_device(btv->c.pci); in bttv_remove()
3502 v4l2_device_unregister(&btv->c.v4l2_dev); in bttv_remove()
3503 bttvs[btv->c.nr] = NULL; in bttv_remove()
3504 kfree(btv); in bttv_remove()
3512 struct bttv *btv = to_bttv(v4l2_dev); in bttv_suspend() local
3516 dprintk("%d: suspend\n", btv->c.nr); in bttv_suspend()
3519 spin_lock_irqsave(&btv->s_lock,flags); in bttv_suspend()
3521 btv->state.video = btv->curr; in bttv_suspend()
3522 btv->state.vbi = btv->cvbi; in bttv_suspend()
3523 btv->state.loop_irq = btv->loop_irq; in bttv_suspend()
3524 btv->curr = idle; in bttv_suspend()
3525 btv->loop_irq = 0; in bttv_suspend()
3526 bttv_buffer_activate_video(btv, &idle); in bttv_suspend()
3527 bttv_buffer_activate_vbi(btv, NULL); in bttv_suspend()
3528 bttv_set_dma(btv, 0); in bttv_suspend()
3530 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_suspend()
3533 btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN); in bttv_suspend()
3534 btv->state.gpio_data = gpio_read(); in bttv_suspend()
3536 btv->state.disabled = 1; in bttv_suspend()
3543 struct bttv *btv = to_bttv(v4l2_dev); in bttv_resume() local
3546 dprintk("%d: resume\n", btv->c.nr); in bttv_resume()
3548 btv->state.disabled = 0; in bttv_resume()
3551 bttv_reinit_bt848(btv); in bttv_resume()
3552 gpio_inout(0xffffff, btv->state.gpio_enable); in bttv_resume()
3553 gpio_write(btv->state.gpio_data); in bttv_resume()
3556 spin_lock_irqsave(&btv->s_lock,flags); in bttv_resume()
3557 btv->curr = btv->state.video; in bttv_resume()
3558 btv->cvbi = btv->state.vbi; in bttv_resume()
3559 btv->loop_irq = btv->state.loop_irq; in bttv_resume()
3560 bttv_buffer_activate_video(btv, &btv->curr); in bttv_resume()
3561 bttv_buffer_activate_vbi(btv, btv->cvbi); in bttv_resume()
3562 bttv_set_dma(btv, 0); in bttv_resume()
3563 spin_unlock_irqrestore(&btv->s_lock,flags); in bttv_resume()